diff options
Diffstat (limited to 'src/include/gnunet_dht_service.h')
-rw-r--r-- | src/include/gnunet_dht_service.h | 163 |
1 files changed, 91 insertions, 72 deletions
diff --git a/src/include/gnunet_dht_service.h b/src/include/gnunet_dht_service.h index 6660f646b..7c7f646e6 100644 --- a/src/include/gnunet_dht_service.h +++ b/src/include/gnunet_dht_service.h | |||
@@ -90,29 +90,29 @@ struct GNUNET_DHT_FindPeerHandle; | |||
90 | * Options for routing. | 90 | * Options for routing. |
91 | */ | 91 | */ |
92 | enum GNUNET_DHT_RouteOption | 92 | enum GNUNET_DHT_RouteOption |
93 | { | 93 | { |
94 | /** | 94 | /** |
95 | * Default. Do nothing special. | 95 | * Default. Do nothing special. |
96 | */ | 96 | */ |
97 | GNUNET_DHT_RO_NONE = 0, | 97 | GNUNET_DHT_RO_NONE = 0, |
98 | 98 | ||
99 | /** | 99 | /** |
100 | * Each peer along the way should look at 'enc' (otherwise | 100 | * Each peer along the way should look at 'enc' (otherwise |
101 | * only the k-peers closest to the key should look at it). | 101 | * only the k-peers closest to the key should look at it). |
102 | */ | 102 | */ |
103 | GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE = 1, | 103 | GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE = 1, |
104 | 104 | ||
105 | /** | 105 | /** |
106 | * We should keep track of the route that the message | 106 | * We should keep track of the route that the message |
107 | * took in the P2P network. | 107 | * took in the P2P network. |
108 | */ | 108 | */ |
109 | GNUNET_DHT_RO_RECORD_ROUTE = 2, | 109 | GNUNET_DHT_RO_RECORD_ROUTE = 2, |
110 | 110 | ||
111 | /** | 111 | /** |
112 | * Possible message option for query key randomization. | 112 | * Possible message option for query key randomization. |
113 | */ | 113 | */ |
114 | GNUNET_DHT_RO_BART = 4 | 114 | GNUNET_DHT_RO_BART = 4 |
115 | }; | 115 | }; |
116 | 116 | ||
117 | 117 | ||
118 | /** | 118 | /** |
@@ -123,9 +123,9 @@ enum GNUNET_DHT_RouteOption | |||
123 | * processing multiple GET/FIND requests in parallel | 123 | * processing multiple GET/FIND requests in parallel |
124 | * @return NULL on error | 124 | * @return NULL on error |
125 | */ | 125 | */ |
126 | struct GNUNET_DHT_Handle * | 126 | struct GNUNET_DHT_Handle *GNUNET_DHT_connect (const struct |
127 | GNUNET_DHT_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, | 127 | GNUNET_CONFIGURATION_Handle *cfg, |
128 | unsigned int ht_len); | 128 | unsigned int ht_len); |
129 | 129 | ||
130 | 130 | ||
131 | /** | 131 | /** |
@@ -133,8 +133,7 @@ GNUNET_DHT_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
133 | * | 133 | * |
134 | * @param handle connection to shut down | 134 | * @param handle connection to shut down |
135 | */ | 135 | */ |
136 | void | 136 | void GNUNET_DHT_disconnect (struct GNUNET_DHT_Handle *handle); |
137 | GNUNET_DHT_disconnect (struct GNUNET_DHT_Handle *handle); | ||
138 | 137 | ||
139 | 138 | ||
140 | /* *************** Standard API: get and put ******************* */ | 139 | /* *************** Standard API: get and put ******************* */ |
@@ -165,8 +164,7 @@ GNUNET_DHT_put (struct GNUNET_DHT_Handle *handle, | |||
165 | const char *data, | 164 | const char *data, |
166 | struct GNUNET_TIME_Absolute exp, | 165 | struct GNUNET_TIME_Absolute exp, |
167 | struct GNUNET_TIME_Relative timeout, | 166 | struct GNUNET_TIME_Relative timeout, |
168 | GNUNET_SCHEDULER_Task cont, | 167 | GNUNET_SCHEDULER_Task cont, void *cont_cls); |
169 | void *cont_cls); | ||
170 | 168 | ||
171 | 169 | ||
172 | /** | 170 | /** |
@@ -184,14 +182,15 @@ GNUNET_DHT_put (struct GNUNET_DHT_Handle *handle, | |||
184 | * @param size number of bytes in data | 182 | * @param size number of bytes in data |
185 | * @param data pointer to the result data | 183 | * @param data pointer to the result data |
186 | */ | 184 | */ |
187 | typedef void (*GNUNET_DHT_GetIterator)(void *cls, | 185 | typedef void (*GNUNET_DHT_GetIterator) (void *cls, |
188 | struct GNUNET_TIME_Absolute exp, | 186 | struct GNUNET_TIME_Absolute exp, |
189 | const GNUNET_HashCode * key, | 187 | const GNUNET_HashCode * key, |
190 | const struct GNUNET_PeerIdentity * const *get_path, | 188 | const struct GNUNET_PeerIdentity * |
191 | const struct GNUNET_PeerIdentity * const *put_path, | 189 | const *get_path, |
192 | enum GNUNET_BLOCK_Type type, | 190 | const struct GNUNET_PeerIdentity * |
193 | size_t size, | 191 | const *put_path, |
194 | const void *data); | 192 | enum GNUNET_BLOCK_Type type, |
193 | size_t size, const void *data); | ||
195 | 194 | ||
196 | 195 | ||
197 | 196 | ||
@@ -215,19 +214,23 @@ typedef void (*GNUNET_DHT_GetIterator)(void *cls, | |||
215 | * | 214 | * |
216 | * @return handle to stop the async get | 215 | * @return handle to stop the async get |
217 | */ | 216 | */ |
218 | struct GNUNET_DHT_GetHandle * | 217 | struct GNUNET_DHT_GetHandle *GNUNET_DHT_get_start (struct GNUNET_DHT_Handle |
219 | GNUNET_DHT_get_start (struct GNUNET_DHT_Handle *handle, | 218 | *handle, |
220 | struct GNUNET_TIME_Relative timeout, | 219 | struct GNUNET_TIME_Relative |
221 | enum GNUNET_BLOCK_Type type, | 220 | timeout, |
222 | const GNUNET_HashCode * key, | 221 | enum GNUNET_BLOCK_Type type, |
223 | uint32_t desired_replication_level, | 222 | const GNUNET_HashCode * key, |
224 | enum GNUNET_DHT_RouteOption options, | 223 | uint32_t |
225 | const struct GNUNET_CONTAINER_BloomFilter *bf, | 224 | desired_replication_level, |
226 | int32_t bf_mutator, | 225 | enum GNUNET_DHT_RouteOption |
227 | const void *xquery, | 226 | options, |
228 | size_t xquery_size, | 227 | const struct |
229 | GNUNET_DHT_GetIterator iter, | 228 | GNUNET_CONTAINER_BloomFilter |
230 | void *iter_cls); | 229 | *bf, int32_t bf_mutator, |
230 | const void *xquery, | ||
231 | size_t xquery_size, | ||
232 | GNUNET_DHT_GetIterator iter, | ||
233 | void *iter_cls); | ||
231 | 234 | ||
232 | 235 | ||
233 | /** | 236 | /** |
@@ -238,8 +241,7 @@ GNUNET_DHT_get_start (struct GNUNET_DHT_Handle *handle, | |||
238 | * On return get_handle will no longer be valid, caller | 241 | * On return get_handle will no longer be valid, caller |
239 | * must not use again!!! | 242 | * must not use again!!! |
240 | */ | 243 | */ |
241 | void | 244 | void GNUNET_DHT_get_stop (struct GNUNET_DHT_GetHandle *get_handle); |
242 | GNUNET_DHT_get_stop (struct GNUNET_DHT_GetHandle *get_handle); | ||
243 | 245 | ||
244 | 246 | ||
245 | /* ******** Special high-level API for finding peers *********** */ | 247 | /* ******** Special high-level API for finding peers *********** */ |
@@ -251,8 +253,9 @@ GNUNET_DHT_get_stop (struct GNUNET_DHT_GetHandle *get_handle); | |||
251 | * @param cls closure | 253 | * @param cls closure |
252 | * @param peer hello of a target (peer near key) | 254 | * @param peer hello of a target (peer near key) |
253 | */ | 255 | */ |
254 | typedef void (*GNUNET_DHT_FindPeerProcessor)(void *cls, | 256 | typedef void (*GNUNET_DHT_FindPeerProcessor) (void *cls, |
255 | const struct GNUNET_HELLO_Message *peer); | 257 | const struct GNUNET_HELLO_Message |
258 | * peer); | ||
256 | 259 | ||
257 | 260 | ||
258 | /** | 261 | /** |
@@ -267,13 +270,21 @@ typedef void (*GNUNET_DHT_FindPeerProcessor)(void *cls, | |||
267 | * @param proc_cls closure for proc | 270 | * @param proc_cls closure for proc |
268 | * @return handle to stop the async get, NULL on error | 271 | * @return handle to stop the async get, NULL on error |
269 | */ | 272 | */ |
270 | struct GNUNET_DHT_FindPeerHandle * | 273 | struct GNUNET_DHT_FindPeerHandle *GNUNET_DHT_find_peer_start (struct |
271 | GNUNET_DHT_find_peer_start (struct GNUNET_DHT_Handle *handle, | 274 | GNUNET_DHT_Handle |
272 | struct GNUNET_TIME_Relative timeout, | 275 | *handle, |
273 | const GNUNET_HashCode *key, | 276 | struct |
274 | enum GNUNET_DHT_RouteOption options, | 277 | GNUNET_TIME_Relative |
275 | GNUNET_DHT_FindPeerProcessor proc, | 278 | timeout, |
276 | void *proc_cls); | 279 | const |
280 | GNUNET_HashCode * | ||
281 | key, | ||
282 | enum | ||
283 | GNUNET_DHT_RouteOption | ||
284 | options, | ||
285 | GNUNET_DHT_FindPeerProcessor | ||
286 | proc, | ||
287 | void *proc_cls); | ||
277 | 288 | ||
278 | 289 | ||
279 | /** | 290 | /** |
@@ -300,10 +311,12 @@ GNUNET_DHT_find_peer_stop (struct GNUNET_DHT_FindPeerHandle *find_peer_handle); | |||
300 | * to the peers on the PUT path (or NULL if not recorded) | 311 | * to the peers on the PUT path (or NULL if not recorded) |
301 | * @param reply response | 312 | * @param reply response |
302 | */ | 313 | */ |
303 | typedef void (*GNUNET_DHT_ReplyProcessor)(void *cls, | 314 | typedef void (*GNUNET_DHT_ReplyProcessor) (void *cls, |
304 | const GNUNET_HashCode *key, | 315 | const GNUNET_HashCode * key, |
305 | const struct GNUNET_PeerIdentity * const *outgoing_path, | 316 | const struct GNUNET_PeerIdentity * |
306 | const struct GNUNET_MessageHeader *reply); | 317 | const *outgoing_path, |
318 | const struct GNUNET_MessageHeader * | ||
319 | reply); | ||
307 | 320 | ||
308 | 321 | ||
309 | /** | 322 | /** |
@@ -327,17 +340,25 @@ typedef void (*GNUNET_DHT_ReplyProcessor)(void *cls, | |||
327 | * @param cont_cls closure for cont | 340 | * @param cont_cls closure for cont |
328 | * @return handle to stop the request, NULL if the request is "fire and forget" | 341 | * @return handle to stop the request, NULL if the request is "fire and forget" |
329 | */ | 342 | */ |
330 | struct GNUNET_DHT_RouteHandle * | 343 | struct GNUNET_DHT_RouteHandle *GNUNET_DHT_route_start (struct GNUNET_DHT_Handle |
331 | GNUNET_DHT_route_start (struct GNUNET_DHT_Handle *handle, | 344 | *handle, |
332 | const GNUNET_HashCode *key, | 345 | const GNUNET_HashCode * |
333 | uint32_t desired_replication_level, | 346 | key, |
334 | enum GNUNET_DHT_RouteOption options, | 347 | uint32_t |
335 | const struct GNUNET_MessageHeader *enc, | 348 | desired_replication_level, |
336 | struct GNUNET_TIME_Relative timeout, | 349 | enum |
337 | GNUNET_DHT_ReplyProcessor iter, | 350 | GNUNET_DHT_RouteOption |
338 | void *iter_cls, | 351 | options, |
339 | GNUNET_SCHEDULER_Task cont, | 352 | const struct |
340 | void *cont_cls); | 353 | GNUNET_MessageHeader |
354 | *enc, | ||
355 | struct | ||
356 | GNUNET_TIME_Relative | ||
357 | timeout, | ||
358 | GNUNET_DHT_ReplyProcessor | ||
359 | iter, void *iter_cls, | ||
360 | GNUNET_SCHEDULER_Task | ||
361 | cont, void *cont_cls); | ||
341 | 362 | ||
342 | 363 | ||
343 | 364 | ||
@@ -346,8 +367,7 @@ GNUNET_DHT_route_start (struct GNUNET_DHT_Handle *handle, | |||
346 | * | 367 | * |
347 | * @param route_handle operation to stop. | 368 | * @param route_handle operation to stop. |
348 | */ | 369 | */ |
349 | void | 370 | void GNUNET_DHT_route_stop (struct GNUNET_DHT_RouteHandle *route_handle); |
350 | GNUNET_DHT_route_stop (struct GNUNET_DHT_RouteHandle *route_handle); | ||
351 | 371 | ||
352 | 372 | ||
353 | /* ***** Special API for controlling DHT routing maintenance ******* */ | 373 | /* ***** Special API for controlling DHT routing maintenance ******* */ |
@@ -366,8 +386,7 @@ GNUNET_DHT_route_stop (struct GNUNET_DHT_RouteHandle *route_handle); | |||
366 | */ | 386 | */ |
367 | void | 387 | void |
368 | GNUNET_DHT_find_peers (struct GNUNET_DHT_Handle *handle, | 388 | GNUNET_DHT_find_peers (struct GNUNET_DHT_Handle *handle, |
369 | GNUNET_SCHEDULER_Task cont, | 389 | GNUNET_SCHEDULER_Task cont, void *cont_cls); |
370 | void *cont_cls); | ||
371 | 390 | ||
372 | /* ***** Special API for testing robustness with malicious peers ******* */ | 391 | /* ***** Special API for testing robustness with malicious peers ******* */ |
373 | 392 | ||
@@ -387,9 +406,9 @@ GNUNET_DHT_find_peers (struct GNUNET_DHT_Handle *handle, | |||
387 | * @param cont_cls closure for cont | 406 | * @param cont_cls closure for cont |
388 | * | 407 | * |
389 | */ | 408 | */ |
390 | void | 409 | void |
391 | GNUNET_DHT_set_malicious_dropper (struct GNUNET_DHT_Handle *handle, GNUNET_SCHEDULER_Task cont, | 410 | GNUNET_DHT_set_malicious_dropper (struct GNUNET_DHT_Handle *handle, |
392 | void *cont_cls); | 411 | GNUNET_SCHEDULER_Task cont, void *cont_cls); |
393 | 412 | ||
394 | 413 | ||
395 | /** | 414 | /** |
@@ -401,10 +420,10 @@ GNUNET_DHT_set_malicious_dropper (struct GNUNET_DHT_Handle *handle, GNUNET_SCHED | |||
401 | * @param cont continuation to call when done (transmitting request to service) | 420 | * @param cont continuation to call when done (transmitting request to service) |
402 | * @param cont_cls closure for cont | 421 | * @param cont_cls closure for cont |
403 | */ | 422 | */ |
404 | void | 423 | void |
405 | GNUNET_DHT_set_malicious_putter (struct GNUNET_DHT_Handle *handle, | 424 | GNUNET_DHT_set_malicious_putter (struct GNUNET_DHT_Handle *handle, |
406 | struct GNUNET_TIME_Relative frequency, GNUNET_SCHEDULER_Task cont, | 425 | struct GNUNET_TIME_Relative frequency, |
407 | void *cont_cls); | 426 | GNUNET_SCHEDULER_Task cont, void *cont_cls); |
408 | 427 | ||
409 | 428 | ||
410 | /** | 429 | /** |
@@ -418,8 +437,8 @@ GNUNET_DHT_set_malicious_putter (struct GNUNET_DHT_Handle *handle, | |||
418 | */ | 437 | */ |
419 | void | 438 | void |
420 | GNUNET_DHT_set_malicious_getter (struct GNUNET_DHT_Handle *handle, | 439 | GNUNET_DHT_set_malicious_getter (struct GNUNET_DHT_Handle *handle, |
421 | struct GNUNET_TIME_Relative frequency, GNUNET_SCHEDULER_Task cont, | 440 | struct GNUNET_TIME_Relative frequency, |
422 | void *cont_cls); | 441 | GNUNET_SCHEDULER_Task cont, void *cont_cls); |
423 | 442 | ||
424 | 443 | ||
425 | #endif | 444 | #endif |