aboutsummaryrefslogtreecommitdiff
path: root/src/dht/dht.h
diff options
context:
space:
mode:
authorNathan S. Evans <evans@in.tum.de>2010-07-20 11:33:59 +0000
committerNathan S. Evans <evans@in.tum.de>2010-07-20 11:33:59 +0000
commitcf1d9e9e9f7765a9849f6f41f33ccb7615272eb5 (patch)
tree49f527798f9688dd9e64b82715ed2a415eb71888 /src/dht/dht.h
parent0e35fa03c78b3e1f7c023ff554df7b315870b11c (diff)
downloadgnunet-cf1d9e9e9f7765a9849f6f41f33ccb7615272eb5.tar.gz
gnunet-cf1d9e9e9f7765a9849f6f41f33ccb7615272eb5.zip
dht testcases and some minor other changes...
Diffstat (limited to 'src/dht/dht.h')
-rw-r--r--src/dht/dht.h171
1 files changed, 159 insertions, 12 deletions
diff --git a/src/dht/dht.h b/src/dht/dht.h
index 319f6d26f..c6c9de1e1 100644
--- a/src/dht/dht.h
+++ b/src/dht/dht.h
@@ -29,9 +29,21 @@
29 29
30#define DEBUG_DHT GNUNET_NO 30#define DEBUG_DHT GNUNET_NO
31 31
32#define DEBUG_DHT_ROUTING GNUNET_YES
33
34#define DHT_BLOOM_SIZE 16
35
36#define DHT_BLOOM_K 8
37
38#define MAX_OUTSTANDING_FORWARDS 100
39
40#define DHT_FORWARD_TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MINUTES, 5)
41
42#define DHT_SEND_PRIORITY 4
43
32typedef void (*GNUNET_DHT_MessageReceivedHandler) (void *cls, 44typedef void (*GNUNET_DHT_MessageReceivedHandler) (void *cls,
33 const struct GNUNET_MessageHeader 45 const struct GNUNET_MessageHeader
34 * msg); 46 *msg);
35 47
36/** 48/**
37 * Message which indicates the DHT should cancel outstanding 49 * Message which indicates the DHT should cancel outstanding
@@ -54,17 +66,23 @@ struct GNUNET_DHT_StopMessage
54 */ 66 */
55 uint64_t unique_id GNUNET_PACKED; 67 uint64_t unique_id GNUNET_PACKED;
56 68
69 /**
70 * Key of this request
71 */
72 GNUNET_HashCode key;
73
57}; 74};
58 75
59 76
60/** 77/**
61 * Generic DHT message, indicates that a route request 78 * Generic DHT message, indicates that a route request
62 * should be issued. 79 * should be issued, if coming from a client. Shared
80 * usage for api->server and P2P message passing.
63 */ 81 */
64struct GNUNET_DHT_RouteMessage 82struct GNUNET_DHT_RouteMessage
65{ 83{
66 /** 84 /**
67 * Type: GNUNET_MESSAGE_TYPE_DHT_ROUTE 85 * Type: GNUNET_MESSAGE_TYPE_LOCAL_DHT_ROUTE
68 */ 86 */
69 struct GNUNET_MessageHeader header; 87 struct GNUNET_MessageHeader header;
70 88
@@ -94,10 +112,13 @@ struct GNUNET_DHT_RouteMessage
94 112
95}; 113};
96 114
115/**
116 * Generic local route result message
117 */
97struct GNUNET_DHT_RouteResultMessage 118struct GNUNET_DHT_RouteResultMessage
98{ 119{
99 /** 120 /**
100 * Type: GNUNET_MESSAGE_TYPE_DHT_ROUTE_RESULT 121 * Type: GNUNET_MESSAGE_TYPE_LOCAL_DHT_ROUTE_RESULT
101 */ 122 */
102 struct GNUNET_MessageHeader header; 123 struct GNUNET_MessageHeader header;
103 124
@@ -107,25 +128,146 @@ struct GNUNET_DHT_RouteResultMessage
107 uint32_t options GNUNET_PACKED; 128 uint32_t options GNUNET_PACKED;
108 129
109 /** 130 /**
131 * Unique ID identifying this request (necessary for
132 * client to compare to sent requests)
133 */
134 uint64_t unique_id GNUNET_PACKED;
135
136 /**
110 * The key that was searched for 137 * The key that was searched for
111 */ 138 */
112 GNUNET_HashCode key; 139 GNUNET_HashCode key;
113 140
141 /* GNUNET_MessageHeader *enc actual DHT message, copied to end of this dealy do */
142};
143
144/**
145 * Generic P2P DHT route message
146 */
147struct GNUNET_DHT_P2PRouteMessage
148{
149 /**
150 * Type: GNUNET_MESSAGE_TYPE_P2P_DHT_ROUTE
151 */
152 struct GNUNET_MessageHeader header;
153
154 /**
155 * Message options
156 */
157 uint32_t options GNUNET_PACKED;
158
159 /**
160 * Hop count
161 */
162 uint32_t hop_count GNUNET_PACKED;
163
164 /**
165 * Network size estimate
166 */
167 uint32_t network_size GNUNET_PACKED;
168
169 /**
170 * Replication level for this message
171 */
172 uint32_t desired_replication_level GNUNET_PACKED;
173
114 /** 174 /**
115 * Unique ID identifying this request 175 * Unique ID identifying this request
116 */ 176 */
117 uint64_t unique_id GNUNET_PACKED; 177 uint64_t unique_id GNUNET_PACKED;
118 178
179 /*
180 * Bloomfilter to stop circular routes
181 */
182 char bloomfilter[DHT_BLOOM_SIZE];
183
184 /**
185 * FIXME: add DHT logging for analysis!
186 */
187#if LOG_SQL
188 /*
189 * Unique query id for sql database interaction.
190 */
191 uint64_t queryuid;
192
193 /*
194 * Unique trial id for sql database interaction
195 */
196 uint64_t trialuid;
197
198#endif
199
200 /**
201 * The key to search for
202 */
203 GNUNET_HashCode key;
204
205 /* GNUNET_MessageHeader *enc actual DHT message, copied to end of this dealy do */
206
207};
208
209/**
210 * Generic P2P route result
211 *
212 * FIXME: One question is how much to include for a route result message.
213 * Assuming a peer receives such a message, but has no record of a
214 * route message, what should it do? It can either drop the message
215 * or try to forward it towards the original peer... However, for
216 * that to work we would need to include the original peer identity
217 * in the GET request, which adds even more data to the message.
218 */
219struct GNUNET_DHT_P2PRouteResultMessage
220{
221 /**
222 * Type: GNUNET_MESSAGE_TYPE_P2P_DHT_ROUTE_RESULT
223 */
224 struct GNUNET_MessageHeader header;
225
226 /**
227 * Message options
228 */
229 uint32_t options GNUNET_PACKED;
230
231 /**
232 * Hop count
233 */
234 uint32_t hop_count GNUNET_PACKED;
235
236 /**
237 * Unique ID identifying this request (may not be set)
238 */
239 uint64_t unique_id GNUNET_PACKED;
240
241 /*
242 * Bloomfilter to stop circular routes
243 */
244 char bloomfilter[DHT_BLOOM_SIZE];
245
246 /**
247 * The key that was searched for
248 */
249 GNUNET_HashCode key;
250
251#if FORWARD_UNKNOWN
252 /**
253 * Network size estimate
254 */
255 uint32_t network_size GNUNET_PACKED;
256#endif
257
119 /* GNUNET_MessageHeader *enc actual DHT message, copied to end of this dealy do */ 258 /* GNUNET_MessageHeader *enc actual DHT message, copied to end of this dealy do */
120}; 259};
121 260
261
122/** 262/**
123 * Message to insert data into the DHT 263 * Message to insert data into the DHT, shared
264 * between api->server communication and P2P communication.
265 * The type must be different for the two purposes.
124 */ 266 */
125struct GNUNET_DHT_PutMessage 267struct GNUNET_DHT_PutMessage
126{ 268{
127 /** 269 /**
128 * Type: GNUNET_MESSAGE_TYPE_DHT_PUT 270 * Type: GNUNET_MESSAGE_TYPE_DHT_PUT / GNUNET_MESSAGE_TYPE_P2P_DHT_PUT
129 */ 271 */
130 struct GNUNET_MessageHeader header; 272 struct GNUNET_MessageHeader header;
131 273
@@ -148,12 +290,15 @@ struct GNUNET_DHT_PutMessage
148 290
149 291
150/** 292/**
151 * Message to request data from the DHT 293 * Message to request data from the DHT, shared
294 * between P2P requests and local get requests.
295 * Main difference is that if the request comes in
296 * locally we need to remember it (for client response).
152 */ 297 */
153struct GNUNET_DHT_GetMessage 298struct GNUNET_DHT_GetMessage
154{ 299{
155 /** 300 /**
156 * Type: GNUNET_MESSAGE_TYPE_DHT_GET 301 * Type: GNUNET_MESSAGE_TYPE_DHT_GET / GNUNET_MESSAGE_TYPE_P2P_DHT_GET
157 */ 302 */
158 struct GNUNET_MessageHeader header; 303 struct GNUNET_MessageHeader header;
159 304
@@ -165,12 +310,14 @@ struct GNUNET_DHT_GetMessage
165}; 310};
166 311
167/** 312/**
168 * Message to return data from the DHT 313 * Message to return data either to the client API
314 * or to respond to a request received from another
315 * peer. Shared format, different types.
169 */ 316 */
170struct GNUNET_DHT_GetResultMessage 317struct GNUNET_DHT_GetResultMessage
171{ 318{
172 /** 319 /**
173 * Type: GNUNET_MESSAGE_TYPE_DHT_GET_RESULT 320 * Type: GNUNET_MESSAGE_TYPE_DHT_GET_RESULT / GNUNET_MESSAGE_TYPE_DHT_P2P_GET_RESULT
174 */ 321 */
175 struct GNUNET_MessageHeader header; 322 struct GNUNET_MessageHeader header;
176 323
@@ -180,9 +327,9 @@ struct GNUNET_DHT_GetResultMessage
180 uint32_t type; 327 uint32_t type;
181 328
182 /** 329 /**
183 * The key to search for 330 * The key that was searched for
184 */ 331 */
185 GNUNET_HashCode key; 332 //GNUNET_HashCode key;
186 333
187 /** 334 /**
188 * When does this entry expire? 335 * When does this entry expire?