diff options
Diffstat (limited to 'src/include/gnunet_dht_service.h')
-rw-r--r-- | src/include/gnunet_dht_service.h | 146 |
1 files changed, 62 insertions, 84 deletions
diff --git a/src/include/gnunet_dht_service.h b/src/include/gnunet_dht_service.h index 1fdd63ee0..d798482e3 100644 --- a/src/include/gnunet_dht_service.h +++ b/src/include/gnunet_dht_service.h | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet | 2 | This file is part of GNUnet |
3 | Copyright (C) 2004-2013 GNUnet e.V. | 3 | Copyright (C) 2004-2013, 2016 GNUnet e.V. |
4 | 4 | ||
5 | GNUnet is free software; you can redistribute it and/or modify | 5 | GNUnet is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published | 6 | it under the terms of the GNU General Public License as published |
@@ -152,8 +152,9 @@ struct GNUNET_DHT_PutHandle; | |||
152 | * after the PUT message was transmitted | 152 | * after the PUT message was transmitted |
153 | * (so we don't know if it was received or not) | 153 | * (so we don't know if it was received or not) |
154 | */ | 154 | */ |
155 | typedef void (*GNUNET_DHT_PutContinuation)(void *cls, | 155 | typedef void |
156 | int success); | 156 | (*GNUNET_DHT_PutContinuation)(void *cls, |
157 | int success); | ||
157 | 158 | ||
158 | 159 | ||
159 | /** | 160 | /** |
@@ -168,7 +169,6 @@ typedef void (*GNUNET_DHT_PutContinuation)(void *cls, | |||
168 | * @param size number of bytes in @a data; must be less than 64k | 169 | * @param size number of bytes in @a data; must be less than 64k |
169 | * @param data the data to store | 170 | * @param data the data to store |
170 | * @param exp desired expiration time for the value | 171 | * @param exp desired expiration time for the value |
171 | * @param timeout how long to wait for transmission of this request | ||
172 | * @param cont continuation to call when done (transmitting request to service) | 172 | * @param cont continuation to call when done (transmitting request to service) |
173 | * You must not call #GNUNET_DHT_disconnect in this continuation | 173 | * You must not call #GNUNET_DHT_disconnect in this continuation |
174 | * @param cont_cls closure for @a cont | 174 | * @param cont_cls closure for @a cont |
@@ -181,9 +181,9 @@ GNUNET_DHT_put (struct GNUNET_DHT_Handle *handle, | |||
181 | uint32_t desired_replication_level, | 181 | uint32_t desired_replication_level, |
182 | enum GNUNET_DHT_RouteOption options, | 182 | enum GNUNET_DHT_RouteOption options, |
183 | enum GNUNET_BLOCK_Type type, | 183 | enum GNUNET_BLOCK_Type type, |
184 | size_t size, const void *data, | 184 | size_t size, |
185 | const void *data, | ||
185 | struct GNUNET_TIME_Absolute exp, | 186 | struct GNUNET_TIME_Absolute exp, |
186 | struct GNUNET_TIME_Relative timeout, | ||
187 | GNUNET_DHT_PutContinuation cont, | 187 | GNUNET_DHT_PutContinuation cont, |
188 | void *cont_cls); | 188 | void *cont_cls); |
189 | 189 | ||
@@ -220,15 +220,17 @@ GNUNET_DHT_put_cancel (struct GNUNET_DHT_PutHandle *ph); | |||
220 | * @param size number of bytes in @a data | 220 | * @param size number of bytes in @a data |
221 | * @param data pointer to the result data | 221 | * @param data pointer to the result data |
222 | */ | 222 | */ |
223 | typedef void (*GNUNET_DHT_GetIterator) (void *cls, | 223 | typedef void |
224 | struct GNUNET_TIME_Absolute exp, | 224 | (*GNUNET_DHT_GetIterator) (void *cls, |
225 | const struct GNUNET_HashCode *key, | 225 | struct GNUNET_TIME_Absolute exp, |
226 | const struct GNUNET_PeerIdentity *get_path, | 226 | const struct GNUNET_HashCode *key, |
227 | unsigned int get_path_length, | 227 | const struct GNUNET_PeerIdentity *get_path, |
228 | const struct GNUNET_PeerIdentity *put_path, | 228 | unsigned int get_path_length, |
229 | unsigned int put_path_length, | 229 | const struct GNUNET_PeerIdentity *put_path, |
230 | enum GNUNET_BLOCK_Type type, | 230 | unsigned int put_path_length, |
231 | size_t size, const void *data); | 231 | enum GNUNET_BLOCK_Type type, |
232 | size_t size, | ||
233 | const void *data); | ||
232 | 234 | ||
233 | 235 | ||
234 | /** | 236 | /** |
@@ -245,7 +247,6 @@ typedef void (*GNUNET_DHT_GetIterator) (void *cls, | |||
245 | * @param xquery_size number of bytes in @a xquery | 247 | * @param xquery_size number of bytes in @a xquery |
246 | * @param iter function to call on each result | 248 | * @param iter function to call on each result |
247 | * @param iter_cls closure for @a iter | 249 | * @param iter_cls closure for @a iter |
248 | * | ||
249 | * @return handle to stop the async get | 250 | * @return handle to stop the async get |
250 | */ | 251 | */ |
251 | struct GNUNET_DHT_GetHandle * | 252 | struct GNUNET_DHT_GetHandle * |
@@ -254,8 +255,10 @@ GNUNET_DHT_get_start (struct GNUNET_DHT_Handle *handle, | |||
254 | const struct GNUNET_HashCode *key, | 255 | const struct GNUNET_HashCode *key, |
255 | uint32_t desired_replication_level, | 256 | uint32_t desired_replication_level, |
256 | enum GNUNET_DHT_RouteOption options, | 257 | enum GNUNET_DHT_RouteOption options, |
257 | const void *xquery, size_t xquery_size, | 258 | const void *xquery, |
258 | GNUNET_DHT_GetIterator iter, void *iter_cls); | 259 | size_t xquery_size, |
260 | GNUNET_DHT_GetIterator iter, | ||
261 | void *iter_cls); | ||
259 | 262 | ||
260 | 263 | ||
261 | /** | 264 | /** |
@@ -265,7 +268,7 @@ GNUNET_DHT_get_start (struct GNUNET_DHT_Handle *handle, | |||
265 | * @param get_handle get operation for which results should be filtered | 268 | * @param get_handle get operation for which results should be filtered |
266 | * @param num_results number of results to be blocked that are | 269 | * @param num_results number of results to be blocked that are |
267 | * provided in this call (size of the @a results array) | 270 | * provided in this call (size of the @a results array) |
268 | * @param results array of hash codes over the 'data' of the results | 271 | * @param results array of hash codes over the `data` of the results |
269 | * to be blocked | 272 | * to be blocked |
270 | */ | 273 | */ |
271 | void | 274 | void |
@@ -277,9 +280,6 @@ GNUNET_DHT_get_filter_known_results (struct GNUNET_DHT_GetHandle *get_handle, | |||
277 | * Stop async DHT-get. Frees associated resources. | 280 | * Stop async DHT-get. Frees associated resources. |
278 | * | 281 | * |
279 | * @param get_handle GET operation to stop. | 282 | * @param get_handle GET operation to stop. |
280 | * | ||
281 | * On return get_handle will no longer be valid, caller | ||
282 | * must not use again!!! | ||
283 | */ | 283 | */ |
284 | void | 284 | void |
285 | GNUNET_DHT_get_stop (struct GNUNET_DHT_GetHandle *get_handle); | 285 | GNUNET_DHT_get_stop (struct GNUNET_DHT_GetHandle *get_handle); |
@@ -304,14 +304,16 @@ struct GNUNET_DHT_MonitorHandle; | |||
304 | * @param desired_replication_level Desired replication level. | 304 | * @param desired_replication_level Desired replication level. |
305 | * @param key Key of the requested data. | 305 | * @param key Key of the requested data. |
306 | */ | 306 | */ |
307 | typedef void (*GNUNET_DHT_MonitorGetCB) (void *cls, | 307 | typedef void |
308 | enum GNUNET_DHT_RouteOption options, | 308 | (*GNUNET_DHT_MonitorGetCB) (void *cls, |
309 | enum GNUNET_BLOCK_Type type, | 309 | enum GNUNET_DHT_RouteOption options, |
310 | uint32_t hop_count, | 310 | enum GNUNET_BLOCK_Type type, |
311 | uint32_t desired_replication_level, | 311 | uint32_t hop_count, |
312 | unsigned int path_length, | 312 | uint32_t desired_replication_level, |
313 | const struct GNUNET_PeerIdentity *path, | 313 | unsigned int path_length, |
314 | const struct GNUNET_HashCode * key); | 314 | const struct GNUNET_PeerIdentity *path, |
315 | const struct GNUNET_HashCode *key); | ||
316 | |||
315 | 317 | ||
316 | /** | 318 | /** |
317 | * Callback called on each GET reply going through the DHT. | 319 | * Callback called on each GET reply going through the DHT. |
@@ -327,16 +329,18 @@ typedef void (*GNUNET_DHT_MonitorGetCB) (void *cls, | |||
327 | * @param data Pointer to the result data. | 329 | * @param data Pointer to the result data. |
328 | * @param size Number of bytes in @a data. | 330 | * @param size Number of bytes in @a data. |
329 | */ | 331 | */ |
330 | typedef void (*GNUNET_DHT_MonitorGetRespCB) (void *cls, | 332 | typedef void |
331 | enum GNUNET_BLOCK_Type type, | 333 | (*GNUNET_DHT_MonitorGetRespCB) (void *cls, |
332 | const struct GNUNET_PeerIdentity *get_path, | 334 | enum GNUNET_BLOCK_Type type, |
333 | unsigned int get_path_length, | 335 | const struct GNUNET_PeerIdentity *get_path, |
334 | const struct GNUNET_PeerIdentity *put_path, | 336 | unsigned int get_path_length, |
335 | unsigned int put_path_length, | 337 | const struct GNUNET_PeerIdentity *put_path, |
336 | struct GNUNET_TIME_Absolute exp, | 338 | unsigned int put_path_length, |
337 | const struct GNUNET_HashCode *key, | 339 | struct GNUNET_TIME_Absolute exp, |
338 | const void *data, | 340 | const struct GNUNET_HashCode *key, |
339 | size_t size); | 341 | const void *data, |
342 | size_t size); | ||
343 | |||
340 | 344 | ||
341 | /** | 345 | /** |
342 | * Callback called on each PUT request going through the DHT. | 346 | * Callback called on each PUT request going through the DHT. |
@@ -351,19 +355,22 @@ typedef void (*GNUNET_DHT_MonitorGetRespCB) (void *cls, | |||
351 | * @param exp Expiration time of the data. | 355 | * @param exp Expiration time of the data. |
352 | * @param key Key under which data is to be stored. | 356 | * @param key Key under which data is to be stored. |
353 | * @param data Pointer to the data carried. | 357 | * @param data Pointer to the data carried. |
354 | * @param size Number of bytes in data. | 358 | * @param size Number of bytes in @a data. |
355 | */ | 359 | */ |
356 | typedef void (*GNUNET_DHT_MonitorPutCB) (void *cls, | 360 | typedef void |
357 | enum GNUNET_DHT_RouteOption options, | 361 | (*GNUNET_DHT_MonitorPutCB) (void *cls, |
358 | enum GNUNET_BLOCK_Type type, | 362 | enum GNUNET_DHT_RouteOption options, |
359 | uint32_t hop_count, | 363 | enum GNUNET_BLOCK_Type type, |
360 | uint32_t desired_replication_level, | 364 | uint32_t hop_count, |
361 | unsigned int path_length, | 365 | uint32_t desired_replication_level, |
362 | const struct GNUNET_PeerIdentity *path, | 366 | unsigned int path_length, |
363 | struct GNUNET_TIME_Absolute exp, | 367 | const struct GNUNET_PeerIdentity *path, |
364 | const struct GNUNET_HashCode *key, | 368 | struct GNUNET_TIME_Absolute exp, |
365 | const void *data, | 369 | const struct GNUNET_HashCode *key, |
366 | size_t size); | 370 | const void *data, |
371 | size_t size); | ||
372 | |||
373 | |||
367 | 374 | ||
368 | /** | 375 | /** |
369 | * Start monitoring the local DHT service. | 376 | * Start monitoring the local DHT service. |
@@ -389,44 +396,15 @@ GNUNET_DHT_monitor_start (struct GNUNET_DHT_Handle *handle, | |||
389 | 396 | ||
390 | /** | 397 | /** |
391 | * Stop monitoring. | 398 | * Stop monitoring. |
392 | * On return handle will no longer be valid, caller must not use again!!! | 399 | * On return handle will no longer be valid, caller must not use it anymore. |
393 | * | 400 | * |
394 | * @param handle The handle to the monitor request returned by monitor_start. | 401 | * @param handle The handle to the monitor request returned by |
402 | * #GNUNET_DHT_monitor_start(). | ||
395 | */ | 403 | */ |
396 | void | 404 | void |
397 | GNUNET_DHT_monitor_stop (struct GNUNET_DHT_MonitorHandle *handle); | 405 | GNUNET_DHT_monitor_stop (struct GNUNET_DHT_MonitorHandle *handle); |
398 | 406 | ||
399 | 407 | ||
400 | #if ENABLE_MALICIOUS | ||
401 | /** | ||
402 | * Type of a Malicious continuation. You must not call | ||
403 | * #GNUNET_DHT_disconnect in this continuation. | ||
404 | * | ||
405 | * @param cls closure | ||
406 | * @param success #GNUNET_OK if the set malicious request was transmitted, | ||
407 | * #GNUNET_NO on timeout, | ||
408 | * #GNUNET_SYSERR on disconnect from service | ||
409 | * after the PUT message was transmitted | ||
410 | * (so we don't know if it was received or not) | ||
411 | */ | ||
412 | typedef void (*GNUNET_DHT_ActMaliciousContinuation)(void *cls, | ||
413 | int success); | ||
414 | |||
415 | /** | ||
416 | * Turn the DHT service to act malicious | ||
417 | * | ||
418 | * @param handle the DHT handle | ||
419 | * @param action 1 to make the service malicious; 0 to make it benign | ||
420 | FIXME: perhaps make this an enum of known malicious behaviors? | ||
421 | */ | ||
422 | struct GNUNET_DHT_ActMaliciousHandle * | ||
423 | GNUNET_DHT_act_malicious (struct GNUNET_DHT_Handle *handle, | ||
424 | unsigned int action, | ||
425 | GNUNET_DHT_PutContinuation cont, | ||
426 | void *cont_cls); | ||
427 | #endif | ||
428 | |||
429 | |||
430 | #if 0 /* keep Emacsens' auto-indent happy */ | 408 | #if 0 /* keep Emacsens' auto-indent happy */ |
431 | { | 409 | { |
432 | #endif | 410 | #endif |