diff options
author | Nathan S. Evans <evans@in.tum.de> | 2010-11-11 11:18:34 +0000 |
---|---|---|
committer | Nathan S. Evans <evans@in.tum.de> | 2010-11-11 11:18:34 +0000 |
commit | 9e921c69007ba709fee460751d7f20237dd56ed7 (patch) | |
tree | 27077c143c90585bdce863f19135e4db17c4a0d6 | |
parent | 1b18069ef2567ffe0994c799d1d179329d629ca9 (diff) | |
download | gnunet-9e921c69007ba709fee460751d7f20237dd56ed7.tar.gz gnunet-9e921c69007ba709fee460751d7f20237dd56ed7.zip |
Adding replication parameter for initiating GET and PUT requests to the DHT.
-rw-r--r-- | src/dht/dht.h | 14 | ||||
-rw-r--r-- | src/dht/dht_api_get_put.c | 12 | ||||
-rw-r--r-- | src/dht/dhtlog.h | 15 | ||||
-rw-r--r-- | src/dht/gnunet-dht-driver.c | 81 | ||||
-rw-r--r-- | src/dht/gnunet-dht-get.c | 1 | ||||
-rw-r--r-- | src/dht/gnunet-dht-put.c | 1 | ||||
-rw-r--r-- | src/dht/gnunet-service-dht.c | 488 | ||||
-rw-r--r-- | src/dht/plugin_dhtlog_dummy.c | 8 | ||||
-rw-r--r-- | src/dht/plugin_dhtlog_mysql.c | 13 | ||||
-rw-r--r-- | src/dht/plugin_dhtlog_mysql_dump.c | 24 | ||||
-rw-r--r-- | src/dht/plugin_dhtlog_mysql_dump_load.c | 23 | ||||
-rw-r--r-- | src/dht/test_dht_api.c | 2 | ||||
-rw-r--r-- | src/dht/test_dht_multipeer.c | 2 | ||||
-rw-r--r-- | src/dht/test_dht_twopeer.c | 4 | ||||
-rw-r--r-- | src/dht/test_dht_twopeer_put_get.c | 2 | ||||
-rw-r--r-- | src/dht/test_dhtlog.c | 2 | ||||
-rw-r--r-- | src/fs/gnunet-service-fs.c | 2 | ||||
-rw-r--r-- | src/include/gnunet_dht_service.h | 63 | ||||
-rw-r--r-- | src/vpn/gnunet-service-dns.c | 2 |
19 files changed, 403 insertions, 356 deletions
diff --git a/src/dht/dht.h b/src/dht/dht.h index bcfc5abd4..094cfb7d8 100644 --- a/src/dht/dht.h +++ b/src/dht/dht.h | |||
@@ -27,7 +27,7 @@ | |||
27 | #ifndef DHT_H_ | 27 | #ifndef DHT_H_ |
28 | #define DHT_H_ | 28 | #define DHT_H_ |
29 | 29 | ||
30 | #define DEBUG_DHT GNUNET_NO | 30 | #define DEBUG_DHT GNUNET_YES |
31 | 31 | ||
32 | /** | 32 | /** |
33 | * Needs to be GNUNET_YES for logging to dhtlog to work! | 33 | * Needs to be GNUNET_YES for logging to dhtlog to work! |
@@ -55,19 +55,11 @@ | |||
55 | #define DHT_FORWARD_TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MINUTES, 5) | 55 | #define DHT_FORWARD_TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MINUTES, 5) |
56 | 56 | ||
57 | /** | 57 | /** |
58 | * FIXME: document. | 58 | * Priority for routing results from other peers through |
59 | * the DHT. | ||
59 | */ | 60 | */ |
60 | #define DHT_SEND_PRIORITY 4 | 61 | #define DHT_SEND_PRIORITY 4 |
61 | 62 | ||
62 | /** | ||
63 | * FIXME: document. | ||
64 | */ | ||
65 | #define DEFAULT_GET_REPLICATION 5 | ||
66 | |||
67 | /** | ||
68 | * FIXME: document. | ||
69 | */ | ||
70 | #define DEFAULT_PUT_REPLICATION 8 | ||
71 | 63 | ||
72 | #define STAT_ROUTES "# DHT ROUTE Requests Seen" | 64 | #define STAT_ROUTES "# DHT ROUTE Requests Seen" |
73 | #define STAT_ROUTE_FORWARDS "# DHT ROUTE Requests Forwarded" | 65 | #define STAT_ROUTE_FORWARDS "# DHT ROUTE Requests Forwarded" |
diff --git a/src/dht/dht_api_get_put.c b/src/dht/dht_api_get_put.c index 98ee8d822..3b7a6d83a 100644 --- a/src/dht/dht_api_get_put.c +++ b/src/dht/dht_api_get_put.c | |||
@@ -39,6 +39,8 @@ | |||
39 | * | 39 | * |
40 | * @param handle handle to DHT service | 40 | * @param handle handle to DHT service |
41 | * @param key the key to store under | 41 | * @param key the key to store under |
42 | * @param desired_replication_level estimate of how many | ||
43 | * nearest peers this request should reach | ||
42 | * @param options routing options for this message | 44 | * @param options routing options for this message |
43 | * @param type type of the value | 45 | * @param type type of the value |
44 | * @param size number of bytes in data; must be less than 64k | 46 | * @param size number of bytes in data; must be less than 64k |
@@ -52,6 +54,7 @@ | |||
52 | void | 54 | void |
53 | GNUNET_DHT_put (struct GNUNET_DHT_Handle *handle, | 55 | GNUNET_DHT_put (struct GNUNET_DHT_Handle *handle, |
54 | const GNUNET_HashCode * key, | 56 | const GNUNET_HashCode * key, |
57 | uint32_t desired_replication_level, | ||
55 | enum GNUNET_DHT_RouteOption options, | 58 | enum GNUNET_DHT_RouteOption options, |
56 | enum GNUNET_BLOCK_Type type, | 59 | enum GNUNET_BLOCK_Type type, |
57 | size_t size, | 60 | size_t size, |
@@ -82,7 +85,7 @@ GNUNET_DHT_put (struct GNUNET_DHT_Handle *handle, | |||
82 | GNUNET_break (NULL == | 85 | GNUNET_break (NULL == |
83 | GNUNET_DHT_route_start (handle, | 86 | GNUNET_DHT_route_start (handle, |
84 | key, | 87 | key, |
85 | DEFAULT_PUT_REPLICATION, options, | 88 | desired_replication_level, options, |
86 | &put_msg->header, | 89 | &put_msg->header, |
87 | timeout, | 90 | timeout, |
88 | NULL, NULL, | 91 | NULL, NULL, |
@@ -168,10 +171,12 @@ get_reply_iterator (void *cls, | |||
168 | * @param timeout how long to wait for transmission of this request to the service | 171 | * @param timeout how long to wait for transmission of this request to the service |
169 | * @param type expected type of the response object | 172 | * @param type expected type of the response object |
170 | * @param key the key to look up | 173 | * @param key the key to look up |
174 | * @param desired_replication_level estimate of how many | ||
175 | nearest peers this request should reach | ||
171 | * @param options routing options for this message | 176 | * @param options routing options for this message |
172 | * @param bf bloom filter associated with query (can be NULL) | 177 | * @param bf bloom filter associated with query (can be NULL) |
173 | * @param bf_mutator mutation value for bf | 178 | * @param bf_mutator mutation value for bf |
174 | * @param xquery extrended query data (can be NULL, depending on type) | 179 | * @param xquery extended query data (can be NULL, depending on type) |
175 | * @param xquery_size number of bytes in xquery | 180 | * @param xquery_size number of bytes in xquery |
176 | * @param iter function to call on each result | 181 | * @param iter function to call on each result |
177 | * @param iter_cls closure for iter | 182 | * @param iter_cls closure for iter |
@@ -183,6 +188,7 @@ GNUNET_DHT_get_start (struct GNUNET_DHT_Handle *handle, | |||
183 | struct GNUNET_TIME_Relative timeout, | 188 | struct GNUNET_TIME_Relative timeout, |
184 | enum GNUNET_BLOCK_Type type, | 189 | enum GNUNET_BLOCK_Type type, |
185 | const GNUNET_HashCode * key, | 190 | const GNUNET_HashCode * key, |
191 | uint32_t desired_replication_level, | ||
186 | enum GNUNET_DHT_RouteOption options, | 192 | enum GNUNET_DHT_RouteOption options, |
187 | const struct GNUNET_CONTAINER_BloomFilter *bf, | 193 | const struct GNUNET_CONTAINER_BloomFilter *bf, |
188 | int32_t bf_mutator, | 194 | int32_t bf_mutator, |
@@ -232,7 +238,7 @@ GNUNET_DHT_get_start (struct GNUNET_DHT_Handle *handle, | |||
232 | get_handle->route_handle = | 238 | get_handle->route_handle = |
233 | GNUNET_DHT_route_start (handle, | 239 | GNUNET_DHT_route_start (handle, |
234 | key, | 240 | key, |
235 | DEFAULT_GET_REPLICATION, | 241 | desired_replication_level, |
236 | options, | 242 | options, |
237 | &get_msg->header, | 243 | &get_msg->header, |
238 | timeout, | 244 | timeout, |
diff --git a/src/dht/dhtlog.h b/src/dht/dhtlog.h index a9608ffd2..d53167a5c 100644 --- a/src/dht/dhtlog.h +++ b/src/dht/dhtlog.h | |||
@@ -71,11 +71,6 @@ typedef enum | |||
71 | struct GNUNET_DHTLOG_TrialInfo | 71 | struct GNUNET_DHTLOG_TrialInfo |
72 | { | 72 | { |
73 | /** | 73 | /** |
74 | * Trialuid, possibly set by insert call. | ||
75 | */ | ||
76 | unsigned long long trialuid; | ||
77 | |||
78 | /** | ||
79 | * Outside of database identifier for the trial. | 74 | * Outside of database identifier for the trial. |
80 | */ | 75 | */ |
81 | unsigned int other_identifier; | 76 | unsigned int other_identifier; |
@@ -142,7 +137,7 @@ struct GNUNET_DHTLOG_TrialInfo | |||
142 | 137 | ||
143 | /** | 138 | /** |
144 | * Routing behaves as it would in Kademlia (modified to work recursively, | 139 | * Routing behaves as it would in Kademlia (modified to work recursively, |
145 | * and with our other GNUnet constraints. | 140 | * and with our other GNUnet constraints). |
146 | */ | 141 | */ |
147 | unsigned int strict_kademlia; | 142 | unsigned int strict_kademlia; |
148 | 143 | ||
@@ -222,13 +217,11 @@ struct GNUNET_DHTLOG_Handle | |||
222 | /* | 217 | /* |
223 | * Update dhttests.trials table with current server time as end time | 218 | * Update dhttests.trials table with current server time as end time |
224 | * | 219 | * |
225 | * @param trialuid trial to update | ||
226 | * @param gets_succeeded how many gets did the trial report successful | 220 | * @param gets_succeeded how many gets did the trial report successful |
227 | * | 221 | * |
228 | * @return GNUNET_OK on success, GNUNET_SYSERR on failure. | 222 | * @return GNUNET_OK on success, GNUNET_SYSERR on failure. |
229 | */ | 223 | */ |
230 | int (*update_trial) (unsigned long long trialuid, | 224 | int (*update_trial) (unsigned int gets_succeeded); |
231 | unsigned int gets_succeeded); | ||
232 | 225 | ||
233 | /* | 226 | /* |
234 | * Update dhttests.nodes table setting the identified | 227 | * Update dhttests.nodes table setting the identified |
@@ -287,13 +280,11 @@ struct GNUNET_DHTLOG_Handle | |||
287 | /* | 280 | /* |
288 | * Update dhttests.trials table with total connections information | 281 | * Update dhttests.trials table with total connections information |
289 | * | 282 | * |
290 | * @param trialuid the trialuid to update | ||
291 | * @param totalConnections the number of connections | 283 | * @param totalConnections the number of connections |
292 | * | 284 | * |
293 | * @return GNUNET_OK on success, GNUNET_SYSERR on failure. | 285 | * @return GNUNET_OK on success, GNUNET_SYSERR on failure. |
294 | */ | 286 | */ |
295 | int (*update_connections) (unsigned long long trialuid, | 287 | int (*update_connections) (unsigned int totalConnections); |
296 | unsigned int totalConnections); | ||
297 | 288 | ||
298 | /* | 289 | /* |
299 | * Update dhttests.trials table with total connections information | 290 | * Update dhttests.trials table with total connections information |
diff --git a/src/dht/gnunet-dht-driver.c b/src/dht/gnunet-dht-driver.c index 39e5eec72..87836c3f5 100644 --- a/src/dht/gnunet-dht-driver.c +++ b/src/dht/gnunet-dht-driver.c | |||
@@ -369,7 +369,7 @@ enum DHT_ROUND_TYPES | |||
369 | /* Globals */ | 369 | /* Globals */ |
370 | 370 | ||
371 | /** | 371 | /** |
372 | * Timeout to let all get requests happen. | 372 | * Timeout to let all GET requests happen. |
373 | */ | 373 | */ |
374 | static struct GNUNET_TIME_Relative all_get_timeout; | 374 | static struct GNUNET_TIME_Relative all_get_timeout; |
375 | 375 | ||
@@ -378,45 +378,114 @@ static struct GNUNET_TIME_Relative all_get_timeout; | |||
378 | */ | 378 | */ |
379 | static struct GNUNET_TIME_Relative get_timeout; | 379 | static struct GNUNET_TIME_Relative get_timeout; |
380 | 380 | ||
381 | /** | ||
382 | * Time to allow for GET requests to be sent to service. | ||
383 | */ | ||
381 | static struct GNUNET_TIME_Relative get_delay; | 384 | static struct GNUNET_TIME_Relative get_delay; |
382 | 385 | ||
386 | /** | ||
387 | * Time to allow for PUT requests to be sent to service. | ||
388 | */ | ||
383 | static struct GNUNET_TIME_Relative put_delay; | 389 | static struct GNUNET_TIME_Relative put_delay; |
384 | 390 | ||
391 | /** | ||
392 | * Delay between sending find peer requests (if | ||
393 | * handled by the driver, no effect if sent by service). | ||
394 | */ | ||
385 | static struct GNUNET_TIME_Relative find_peer_delay; | 395 | static struct GNUNET_TIME_Relative find_peer_delay; |
386 | 396 | ||
397 | /** | ||
398 | * Time between find peer requests | ||
399 | * (find_peer_delay / max_outstanding_find_peer) | ||
400 | */ | ||
387 | static struct GNUNET_TIME_Relative find_peer_offset; | 401 | static struct GNUNET_TIME_Relative find_peer_offset; |
388 | 402 | ||
403 | /** | ||
404 | * How many seconds to allow each peer to start. | ||
405 | */ | ||
389 | static struct GNUNET_TIME_Relative seconds_per_peer_start; | 406 | static struct GNUNET_TIME_Relative seconds_per_peer_start; |
390 | 407 | ||
408 | /** | ||
409 | * Boolean value, should the driver issue find peer requests | ||
410 | * (GNUNET_YES) or should it be left to the service (GNUNET_NO) | ||
411 | */ | ||
391 | static unsigned int do_find_peer; | 412 | static unsigned int do_find_peer; |
392 | 413 | ||
414 | /** | ||
415 | * Boolean value, should replication be done by the dht | ||
416 | * service (GNUNET_YES) or by the driver (GNUNET_NO) | ||
417 | */ | ||
393 | static unsigned int in_dht_replication; | 418 | static unsigned int in_dht_replication; |
394 | 419 | ||
420 | /** | ||
421 | * Size of test data to insert/retrieve during testing. | ||
422 | */ | ||
395 | static unsigned long long test_data_size = DEFAULT_TEST_DATA_SIZE; | 423 | static unsigned long long test_data_size = DEFAULT_TEST_DATA_SIZE; |
396 | 424 | ||
425 | /** | ||
426 | * Maximum number of concurrent PUT requests. | ||
427 | */ | ||
397 | static unsigned long long max_outstanding_puts = DEFAULT_MAX_OUTSTANDING_PUTS; | 428 | static unsigned long long max_outstanding_puts = DEFAULT_MAX_OUTSTANDING_PUTS; |
398 | 429 | ||
430 | /** | ||
431 | * Maximum number of concurrent GET requests. | ||
432 | */ | ||
399 | static unsigned long long max_outstanding_gets = DEFAULT_MAX_OUTSTANDING_GETS; | 433 | static unsigned long long max_outstanding_gets = DEFAULT_MAX_OUTSTANDING_GETS; |
400 | 434 | ||
435 | /** | ||
436 | * Number of nodes issuing malicious GET messages. | ||
437 | */ | ||
401 | static unsigned long long malicious_getters; | 438 | static unsigned long long malicious_getters; |
402 | 439 | ||
440 | /** | ||
441 | * Maximum number of concurrent find peer messages being sent. | ||
442 | */ | ||
403 | static unsigned long long max_outstanding_find_peers; | 443 | static unsigned long long max_outstanding_find_peers; |
404 | 444 | ||
445 | /** | ||
446 | * Number of nodes issuing malicious PUT messages. | ||
447 | */ | ||
405 | static unsigned long long malicious_putters; | 448 | static unsigned long long malicious_putters; |
406 | 449 | ||
450 | /** | ||
451 | * Time (in seconds) to delay between rounds. | ||
452 | */ | ||
407 | static unsigned long long round_delay; | 453 | static unsigned long long round_delay; |
408 | 454 | ||
455 | /** | ||
456 | * How many malicious droppers to seed in the network. | ||
457 | */ | ||
409 | static unsigned long long malicious_droppers; | 458 | static unsigned long long malicious_droppers; |
410 | 459 | ||
460 | /** | ||
461 | * How often to send malicious GET messages. | ||
462 | */ | ||
411 | static struct GNUNET_TIME_Relative malicious_get_frequency; | 463 | static struct GNUNET_TIME_Relative malicious_get_frequency; |
412 | 464 | ||
465 | /** | ||
466 | * How often to send malicious PUT messages. | ||
467 | */ | ||
413 | static struct GNUNET_TIME_Relative malicious_put_frequency; | 468 | static struct GNUNET_TIME_Relative malicious_put_frequency; |
414 | 469 | ||
470 | /** | ||
471 | * How long to send find peer requests. | ||
472 | */ | ||
415 | static unsigned long long settle_time; | 473 | static unsigned long long settle_time; |
416 | 474 | ||
475 | /** | ||
476 | * Handle to the dhtlog service. | ||
477 | */ | ||
417 | static struct GNUNET_DHTLOG_Handle *dhtlog_handle; | 478 | static struct GNUNET_DHTLOG_Handle *dhtlog_handle; |
418 | 479 | ||
419 | static unsigned long long trialuid; | 480 | /** |
481 | * Replication value for GET requests. | ||
482 | */ | ||
483 | static unsigned long long get_replication; | ||
484 | |||
485 | /** | ||
486 | * Replication value for PUT requests. | ||
487 | */ | ||
488 | static unsigned long long put_replication; | ||
420 | 489 | ||
421 | /** | 490 | /** |
422 | * If GNUNET_YES, insert data at the same peers every time. | 491 | * If GNUNET_YES, insert data at the same peers every time. |
@@ -759,7 +828,7 @@ finish_testing (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) | |||
759 | if (dhtlog_handle != NULL) | 828 | if (dhtlog_handle != NULL) |
760 | { | 829 | { |
761 | fprintf(stderr, "Update trial endtime\n"); | 830 | fprintf(stderr, "Update trial endtime\n"); |
762 | dhtlog_handle->update_trial (trialuid, gets_completed); | 831 | dhtlog_handle->update_trial (gets_completed); |
763 | GNUNET_DHTLOG_disconnect(dhtlog_handle); | 832 | GNUNET_DHTLOG_disconnect(dhtlog_handle); |
764 | dhtlog_handle = NULL; | 833 | dhtlog_handle = NULL; |
765 | } | 834 | } |
@@ -985,7 +1054,7 @@ end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) | |||
985 | if (dhtlog_handle != NULL) | 1054 | if (dhtlog_handle != NULL) |
986 | { | 1055 | { |
987 | fprintf(stderr, "Update trial endtime\n"); | 1056 | fprintf(stderr, "Update trial endtime\n"); |
988 | dhtlog_handle->update_trial (trialuid, gets_completed); | 1057 | dhtlog_handle->update_trial (gets_completed); |
989 | GNUNET_DHTLOG_disconnect(dhtlog_handle); | 1058 | GNUNET_DHTLOG_disconnect(dhtlog_handle); |
990 | dhtlog_handle = NULL; | 1059 | dhtlog_handle = NULL; |
991 | } | 1060 | } |
@@ -1736,6 +1805,7 @@ do_get (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) | |||
1736 | get_delay, | 1805 | get_delay, |
1737 | GNUNET_BLOCK_TYPE_TEST, | 1806 | GNUNET_BLOCK_TYPE_TEST, |
1738 | &known_keys[test_get->uid], | 1807 | &known_keys[test_get->uid], |
1808 | get_replication, | ||
1739 | GNUNET_DHT_RO_NONE, | 1809 | GNUNET_DHT_RO_NONE, |
1740 | NULL, 0, | 1810 | NULL, 0, |
1741 | NULL, 0, | 1811 | NULL, 0, |
@@ -1844,6 +1914,7 @@ do_put (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) | |||
1844 | outstanding_puts++; | 1914 | outstanding_puts++; |
1845 | GNUNET_DHT_put(test_put->dht_handle, | 1915 | GNUNET_DHT_put(test_put->dht_handle, |
1846 | &known_keys[test_put->uid], | 1916 | &known_keys[test_put->uid], |
1917 | put_replication, | ||
1847 | GNUNET_DHT_RO_NONE, | 1918 | GNUNET_DHT_RO_NONE, |
1848 | GNUNET_BLOCK_TYPE_TEST, | 1919 | GNUNET_BLOCK_TYPE_TEST, |
1849 | sizeof(data), data, | 1920 | sizeof(data), data, |
@@ -2303,7 +2374,7 @@ topology_callback (void *cls, | |||
2303 | #endif | 2374 | #endif |
2304 | if (dhtlog_handle != NULL) | 2375 | if (dhtlog_handle != NULL) |
2305 | { | 2376 | { |
2306 | dhtlog_handle->update_connections (trialuid, total_connections); | 2377 | dhtlog_handle->update_connections (total_connections); |
2307 | dhtlog_handle->insert_topology(expected_connections); | 2378 | dhtlog_handle->insert_topology(expected_connections); |
2308 | } | 2379 | } |
2309 | 2380 | ||
diff --git a/src/dht/gnunet-dht-get.c b/src/dht/gnunet-dht-get.c index b7dcb6a56..593009fa2 100644 --- a/src/dht/gnunet-dht-get.c +++ b/src/dht/gnunet-dht-get.c | |||
@@ -185,6 +185,7 @@ run (void *cls, | |||
185 | timeout, | 185 | timeout, |
186 | query_type, | 186 | query_type, |
187 | &key, | 187 | &key, |
188 | DEFAULT_GET_REPLICATION, | ||
188 | GNUNET_DHT_RO_NONE, | 189 | GNUNET_DHT_RO_NONE, |
189 | NULL, 0, | 190 | NULL, 0, |
190 | NULL, 0, | 191 | NULL, 0, |
diff --git a/src/dht/gnunet-dht-put.c b/src/dht/gnunet-dht-put.c index 469675409..54c915c15 100644 --- a/src/dht/gnunet-dht-put.c +++ b/src/dht/gnunet-dht-put.c | |||
@@ -151,6 +151,7 @@ run (void *cls, | |||
151 | query_key, data); | 151 | query_key, data); |
152 | GNUNET_DHT_put (dht_handle, | 152 | GNUNET_DHT_put (dht_handle, |
153 | &key, | 153 | &key, |
154 | DEFAULT_PUT_REPLICATION, | ||
154 | GNUNET_DHT_RO_NONE, | 155 | GNUNET_DHT_RO_NONE, |
155 | query_type, | 156 | query_type, |
156 | strlen (data), data, | 157 | strlen (data), data, |
diff --git a/src/dht/gnunet-service-dht.c b/src/dht/gnunet-service-dht.c index 714ba4753..810997e4c 100644 --- a/src/dht/gnunet-service-dht.c +++ b/src/dht/gnunet-service-dht.c | |||
@@ -20,7 +20,7 @@ | |||
20 | 20 | ||
21 | /** | 21 | /** |
22 | * @file dht/gnunet-service-dht.c | 22 | * @file dht/gnunet-service-dht.c |
23 | * @brief main DHT service shell, building block for DHT implementations | 23 | * @brief GNUnet DHT service |
24 | * @author Christian Grothoff | 24 | * @author Christian Grothoff |
25 | * @author Nathan Evans | 25 | * @author Nathan Evans |
26 | */ | 26 | */ |
@@ -110,11 +110,6 @@ | |||
110 | /** | 110 | /** |
111 | * Default replication parameter for find peer messages sent by the dht service. | 111 | * Default replication parameter for find peer messages sent by the dht service. |
112 | */ | 112 | */ |
113 | #define DHT_DEFAULT_PUT_REPLICATION 4 | ||
114 | |||
115 | /** | ||
116 | * Default replication parameter for find peer messages sent by the dht service. | ||
117 | */ | ||
118 | #define DHT_DEFAULT_FIND_PEER_REPLICATION 4 | 113 | #define DHT_DEFAULT_FIND_PEER_REPLICATION 4 |
119 | 114 | ||
120 | /** | 115 | /** |
@@ -1716,7 +1711,7 @@ periodic_ping_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
1716 | { | 1711 | { |
1717 | struct PeerInfo *peer = cls; | 1712 | struct PeerInfo *peer = cls; |
1718 | struct GNUNET_MessageHeader ping_message; | 1713 | struct GNUNET_MessageHeader ping_message; |
1719 | struct DHT_MessageContext message_context; | 1714 | struct DHT_MessageContext msg_ctx; |
1720 | 1715 | ||
1721 | if (tc->reason == GNUNET_SCHEDULER_REASON_SHUTDOWN) | 1716 | if (tc->reason == GNUNET_SCHEDULER_REASON_SHUTDOWN) |
1722 | return; | 1717 | return; |
@@ -1724,11 +1719,11 @@ periodic_ping_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
1724 | ping_message.size = htons(sizeof(struct GNUNET_MessageHeader)); | 1719 | ping_message.size = htons(sizeof(struct GNUNET_MessageHeader)); |
1725 | ping_message.type = htons(GNUNET_MESSAGE_TYPE_DHT_P2P_PING); | 1720 | ping_message.type = htons(GNUNET_MESSAGE_TYPE_DHT_P2P_PING); |
1726 | 1721 | ||
1727 | memset(&message_context, 0, sizeof(struct DHT_MessageContext)); | 1722 | memset(&msg_ctx, 0, sizeof(struct DHT_MessageContext)); |
1728 | #if DEBUG_PING | 1723 | #if DEBUG_PING |
1729 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "%s:%s Sending periodic ping to %s\n", my_short_id, "DHT", GNUNET_i2s(&peer->id)); | 1724 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "%s:%s Sending periodic ping to %s\n", my_short_id, "DHT", GNUNET_i2s(&peer->id)); |
1730 | #endif | 1725 | #endif |
1731 | forward_message(&ping_message, peer, &message_context); | 1726 | forward_message(&ping_message, peer, &msg_ctx); |
1732 | peer->ping_task = GNUNET_SCHEDULER_add_delayed(DHT_DEFAULT_PING_DELAY, &periodic_ping_task, peer); | 1727 | peer->ping_task = GNUNET_SCHEDULER_add_delayed(DHT_DEFAULT_PING_DELAY, &periodic_ping_task, peer); |
1733 | } | 1728 | } |
1734 | 1729 | ||
@@ -1958,13 +1953,13 @@ static int consider_peer (struct GNUNET_PeerIdentity *peer) | |||
1958 | * message to other peers, or to send to our local client. | 1953 | * message to other peers, or to send to our local client. |
1959 | * | 1954 | * |
1960 | * @param msg the result message to be routed | 1955 | * @param msg the result message to be routed |
1961 | * @param message_context context of the message we are routing | 1956 | * @param msg_ctx context of the message we are routing |
1962 | * | 1957 | * |
1963 | * @return the number of peers the message was routed to, | 1958 | * @return the number of peers the message was routed to, |
1964 | * GNUNET_SYSERR on failure | 1959 | * GNUNET_SYSERR on failure |
1965 | */ | 1960 | */ |
1966 | static int route_result_message(struct GNUNET_MessageHeader *msg, | 1961 | static int route_result_message(struct GNUNET_MessageHeader *msg, |
1967 | struct DHT_MessageContext *message_context) | 1962 | struct DHT_MessageContext *msg_ctx) |
1968 | { | 1963 | { |
1969 | struct GNUNET_PeerIdentity new_peer; | 1964 | struct GNUNET_PeerIdentity new_peer; |
1970 | struct DHTQueryRecord *record; | 1965 | struct DHTQueryRecord *record; |
@@ -2005,32 +2000,32 @@ static int route_result_message(struct GNUNET_MessageHeader *msg, | |||
2005 | if (malicious_dropper == GNUNET_YES) | 2000 | if (malicious_dropper == GNUNET_YES) |
2006 | record = NULL; | 2001 | record = NULL; |
2007 | else | 2002 | else |
2008 | record = GNUNET_CONTAINER_multihashmap_get(forward_list.hashmap, &message_context->key); | 2003 | record = GNUNET_CONTAINER_multihashmap_get(forward_list.hashmap, &msg_ctx->key); |
2009 | 2004 | ||
2010 | if (record == NULL) /* No record of this message! */ | 2005 | if (record == NULL) /* No record of this message! */ |
2011 | { | 2006 | { |
2012 | #if DEBUG_DHT | 2007 | #if DEBUG_DHT |
2013 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2008 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2014 | "`%s:%s': Have no record of response key %s uid %llu\n", my_short_id, | 2009 | "`%s:%s': Have no record of response key %s uid %llu\n", my_short_id, |
2015 | "DHT", GNUNET_h2s (&message_context->key), message_context->unique_id); | 2010 | "DHT", GNUNET_h2s (&msg_ctx->key), msg_ctx->unique_id); |
2016 | #endif | 2011 | #endif |
2017 | #if DEBUG_DHT_ROUTING | 2012 | #if DEBUG_DHT_ROUTING |
2018 | if ((debug_routes_extended) && (dhtlog_handle != NULL)) | 2013 | if ((debug_routes_extended) && (dhtlog_handle != NULL)) |
2019 | { | 2014 | { |
2020 | dhtlog_handle->insert_route (NULL, | 2015 | dhtlog_handle->insert_route (NULL, |
2021 | message_context->unique_id, | 2016 | msg_ctx->unique_id, |
2022 | DHTLOG_RESULT, | 2017 | DHTLOG_RESULT, |
2023 | message_context->hop_count, | 2018 | msg_ctx->hop_count, |
2024 | GNUNET_SYSERR, | 2019 | GNUNET_SYSERR, |
2025 | &my_identity, | 2020 | &my_identity, |
2026 | &message_context->key, | 2021 | &msg_ctx->key, |
2027 | message_context->peer, NULL); | 2022 | msg_ctx->peer, NULL); |
2028 | } | 2023 | } |
2029 | #endif | 2024 | #endif |
2030 | if (message_context->bloom != NULL) | 2025 | if (msg_ctx->bloom != NULL) |
2031 | { | 2026 | { |
2032 | GNUNET_CONTAINER_bloomfilter_free(message_context->bloom); | 2027 | GNUNET_CONTAINER_bloomfilter_free(msg_ctx->bloom); |
2033 | message_context->bloom = NULL; | 2028 | msg_ctx->bloom = NULL; |
2034 | } | 2029 | } |
2035 | return 0; | 2030 | return 0; |
2036 | } | 2031 | } |
@@ -2057,15 +2052,15 @@ static int route_result_message(struct GNUNET_MessageHeader *msg, | |||
2057 | #if DEBUG_DHT | 2052 | #if DEBUG_DHT |
2058 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2053 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2059 | "`%s:%s': Sending response key %s uid %llu to client\n", my_short_id, | 2054 | "`%s:%s': Sending response key %s uid %llu to client\n", my_short_id, |
2060 | "DHT", GNUNET_h2s (&message_context->key), message_context->unique_id); | 2055 | "DHT", GNUNET_h2s (&msg_ctx->key), msg_ctx->unique_id); |
2061 | #endif | 2056 | #endif |
2062 | #if DEBUG_DHT_ROUTING | 2057 | #if DEBUG_DHT_ROUTING |
2063 | if ((debug_routes_extended) && (dhtlog_handle != NULL)) | 2058 | if ((debug_routes_extended) && (dhtlog_handle != NULL)) |
2064 | { | 2059 | { |
2065 | dhtlog_handle->insert_route (NULL, message_context->unique_id, DHTLOG_RESULT, | 2060 | dhtlog_handle->insert_route (NULL, msg_ctx->unique_id, DHTLOG_RESULT, |
2066 | message_context->hop_count, | 2061 | msg_ctx->hop_count, |
2067 | GNUNET_YES, &my_identity, &message_context->key, | 2062 | GNUNET_YES, &my_identity, &msg_ctx->key, |
2068 | message_context->peer, NULL); | 2063 | msg_ctx->peer, NULL); |
2069 | } | 2064 | } |
2070 | #endif | 2065 | #endif |
2071 | increment_stats(STAT_RESULTS_TO_CLIENT); | 2066 | increment_stats(STAT_RESULTS_TO_CLIENT); |
@@ -2073,8 +2068,8 @@ static int route_result_message(struct GNUNET_MessageHeader *msg, | |||
2073 | increment_stats(STAT_GET_REPLY); | 2068 | increment_stats(STAT_GET_REPLY); |
2074 | 2069 | ||
2075 | send_reply_to_client(pos->client, msg, | 2070 | send_reply_to_client(pos->client, msg, |
2076 | message_context->unique_id, | 2071 | msg_ctx->unique_id, |
2077 | &message_context->key); | 2072 | &msg_ctx->key); |
2078 | } | 2073 | } |
2079 | else /* Send to peer */ | 2074 | else /* Send to peer */ |
2080 | { | 2075 | { |
@@ -2085,41 +2080,41 @@ static int route_result_message(struct GNUNET_MessageHeader *msg, | |||
2085 | continue; | 2080 | continue; |
2086 | } | 2081 | } |
2087 | 2082 | ||
2088 | if (message_context->bloom == NULL) | 2083 | if (msg_ctx->bloom == NULL) |
2089 | message_context->bloom = GNUNET_CONTAINER_bloomfilter_init (NULL, DHT_BLOOM_SIZE, DHT_BLOOM_K); | 2084 | msg_ctx->bloom = GNUNET_CONTAINER_bloomfilter_init (NULL, DHT_BLOOM_SIZE, DHT_BLOOM_K); |
2090 | GNUNET_CONTAINER_bloomfilter_add (message_context->bloom, &my_identity.hashPubKey); | 2085 | GNUNET_CONTAINER_bloomfilter_add (msg_ctx->bloom, &my_identity.hashPubKey); |
2091 | if ((GNUNET_NO == GNUNET_CONTAINER_bloomfilter_test (message_context->bloom, &peer_info->id.hashPubKey))) | 2086 | if ((GNUNET_NO == GNUNET_CONTAINER_bloomfilter_test (msg_ctx->bloom, &peer_info->id.hashPubKey))) |
2092 | { | 2087 | { |
2093 | #if DEBUG_DHT | 2088 | #if DEBUG_DHT |
2094 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2089 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2095 | "`%s:%s': Forwarding response key %s uid %llu to peer %s\n", my_short_id, | 2090 | "`%s:%s': Forwarding response key %s uid %llu to peer %s\n", my_short_id, |
2096 | "DHT", GNUNET_h2s (&message_context->key), message_context->unique_id, GNUNET_i2s(&peer_info->id)); | 2091 | "DHT", GNUNET_h2s (&msg_ctx->key), msg_ctx->unique_id, GNUNET_i2s(&peer_info->id)); |
2097 | #endif | 2092 | #endif |
2098 | #if DEBUG_DHT_ROUTING | 2093 | #if DEBUG_DHT_ROUTING |
2099 | if ((debug_routes_extended) && (dhtlog_handle != NULL)) | 2094 | if ((debug_routes_extended) && (dhtlog_handle != NULL)) |
2100 | { | 2095 | { |
2101 | dhtlog_handle->insert_route (NULL, message_context->unique_id, | 2096 | dhtlog_handle->insert_route (NULL, msg_ctx->unique_id, |
2102 | DHTLOG_RESULT, | 2097 | DHTLOG_RESULT, |
2103 | message_context->hop_count, | 2098 | msg_ctx->hop_count, |
2104 | GNUNET_NO, &my_identity, &message_context->key, | 2099 | GNUNET_NO, &my_identity, &msg_ctx->key, |
2105 | message_context->peer, &pos->source); | 2100 | msg_ctx->peer, &pos->source); |
2106 | } | 2101 | } |
2107 | #endif | 2102 | #endif |
2108 | forward_result_message(msg, peer_info, message_context); | 2103 | forward_result_message(msg, peer_info, msg_ctx); |
2109 | } | 2104 | } |
2110 | else | 2105 | else |
2111 | { | 2106 | { |
2112 | #if DEBUG_DHT | 2107 | #if DEBUG_DHT |
2113 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2108 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2114 | "`%s:%s': NOT Forwarding response (bloom match) key %s uid %llu to peer %s\n", my_short_id, | 2109 | "`%s:%s': NOT Forwarding response (bloom match) key %s uid %llu to peer %s\n", my_short_id, |
2115 | "DHT", GNUNET_h2s (&message_context->key), message_context->unique_id, GNUNET_i2s(&peer_info->id)); | 2110 | "DHT", GNUNET_h2s (&msg_ctx->key), msg_ctx->unique_id, GNUNET_i2s(&peer_info->id)); |
2116 | #endif | 2111 | #endif |
2117 | } | 2112 | } |
2118 | } | 2113 | } |
2119 | pos = pos->next; | 2114 | pos = pos->next; |
2120 | } | 2115 | } |
2121 | if (message_context->bloom != NULL) | 2116 | if (msg_ctx->bloom != NULL) |
2122 | GNUNET_CONTAINER_bloomfilter_free(message_context->bloom); | 2117 | GNUNET_CONTAINER_bloomfilter_free(msg_ctx->bloom); |
2123 | return 0; | 2118 | return 0; |
2124 | } | 2119 | } |
2125 | 2120 | ||
@@ -2179,7 +2174,7 @@ datacache_get_iterator (void *cls, | |||
2179 | new_msg_ctx->peer = &my_identity; | 2174 | new_msg_ctx->peer = &my_identity; |
2180 | new_msg_ctx->bloom = GNUNET_CONTAINER_bloomfilter_init (NULL, DHT_BLOOM_SIZE, DHT_BLOOM_K); | 2175 | new_msg_ctx->bloom = GNUNET_CONTAINER_bloomfilter_init (NULL, DHT_BLOOM_SIZE, DHT_BLOOM_K); |
2181 | new_msg_ctx->hop_count = 0; | 2176 | new_msg_ctx->hop_count = 0; |
2182 | new_msg_ctx->importance = DHT_DEFAULT_P2P_IMPORTANCE * 2; /* Make result routing a higher priority */ | 2177 | new_msg_ctx->importance = DHT_DEFAULT_P2P_IMPORTANCE + 2; /* Make result routing a higher priority */ |
2183 | new_msg_ctx->timeout = DHT_DEFAULT_P2P_TIMEOUT; | 2178 | new_msg_ctx->timeout = DHT_DEFAULT_P2P_TIMEOUT; |
2184 | increment_stats(STAT_GET_RESPONSE_START); | 2179 | increment_stats(STAT_GET_RESPONSE_START); |
2185 | route_result_message(&get_result->header, new_msg_ctx); | 2180 | route_result_message(&get_result->header, new_msg_ctx); |
@@ -2226,11 +2221,11 @@ datacache_get_iterator (void *cls, | |||
2226 | * peers. | 2221 | * peers. |
2227 | * | 2222 | * |
2228 | * @param msg the message to be routed | 2223 | * @param msg the message to be routed |
2229 | * @param message_context the context containing all pertinent information about the message | 2224 | * @param msg_ctx the context containing all pertinent information about the message |
2230 | */ | 2225 | */ |
2231 | static void | 2226 | static void |
2232 | route_message(const struct GNUNET_MessageHeader *msg, | 2227 | route_message(const struct GNUNET_MessageHeader *msg, |
2233 | struct DHT_MessageContext *message_context); | 2228 | struct DHT_MessageContext *msg_ctx); |
2234 | 2229 | ||
2235 | 2230 | ||
2236 | /** | 2231 | /** |
@@ -2238,13 +2233,13 @@ route_message(const struct GNUNET_MessageHeader *msg, | |||
2238 | * if found, send response either to clients or other peers. | 2233 | * if found, send response either to clients or other peers. |
2239 | * | 2234 | * |
2240 | * @param msg the actual get message | 2235 | * @param msg the actual get message |
2241 | * @param message_context struct containing pertinent information about the get request | 2236 | * @param msg_ctx struct containing pertinent information about the get request |
2242 | * | 2237 | * |
2243 | * @return number of items found for GET request | 2238 | * @return number of items found for GET request |
2244 | */ | 2239 | */ |
2245 | static unsigned int | 2240 | static unsigned int |
2246 | handle_dht_get (const struct GNUNET_MessageHeader *msg, | 2241 | handle_dht_get (const struct GNUNET_MessageHeader *msg, |
2247 | struct DHT_MessageContext *message_context) | 2242 | struct DHT_MessageContext *msg_ctx) |
2248 | { | 2243 | { |
2249 | const struct GNUNET_DHT_GetMessage *get_msg; | 2244 | const struct GNUNET_DHT_GetMessage *get_msg; |
2250 | uint16_t msize; | 2245 | uint16_t msize; |
@@ -2261,30 +2256,30 @@ handle_dht_get (const struct GNUNET_MessageHeader *msg, | |||
2261 | } | 2256 | } |
2262 | get_msg = (const struct GNUNET_DHT_GetMessage *) msg; | 2257 | get_msg = (const struct GNUNET_DHT_GetMessage *) msg; |
2263 | bf_size = ntohs (get_msg->bf_size); | 2258 | bf_size = ntohs (get_msg->bf_size); |
2264 | message_context->xquery_size = ntohs (get_msg->xquery_size); | 2259 | msg_ctx->xquery_size = ntohs (get_msg->xquery_size); |
2265 | message_context->reply_bf_mutator = get_msg->bf_mutator; /* FIXME: ntohl? */ | 2260 | msg_ctx->reply_bf_mutator = get_msg->bf_mutator; /* FIXME: ntohl? */ |
2266 | if (msize != sizeof (struct GNUNET_DHT_GetMessage) + bf_size + message_context->xquery_size) | 2261 | if (msize != sizeof (struct GNUNET_DHT_GetMessage) + bf_size + msg_ctx->xquery_size) |
2267 | { | 2262 | { |
2268 | GNUNET_break (0); | 2263 | GNUNET_break (0); |
2269 | return 0; | 2264 | return 0; |
2270 | } | 2265 | } |
2271 | end = (const char*) &get_msg[1]; | 2266 | end = (const char*) &get_msg[1]; |
2272 | if (message_context->xquery_size == 0) | 2267 | if (msg_ctx->xquery_size == 0) |
2273 | { | 2268 | { |
2274 | message_context->xquery = NULL; | 2269 | msg_ctx->xquery = NULL; |
2275 | } | 2270 | } |
2276 | else | 2271 | else |
2277 | { | 2272 | { |
2278 | message_context->xquery = (const void*) end; | 2273 | msg_ctx->xquery = (const void*) end; |
2279 | end += message_context->xquery_size; | 2274 | end += msg_ctx->xquery_size; |
2280 | } | 2275 | } |
2281 | if (bf_size == 0) | 2276 | if (bf_size == 0) |
2282 | { | 2277 | { |
2283 | message_context->reply_bf = NULL; | 2278 | msg_ctx->reply_bf = NULL; |
2284 | } | 2279 | } |
2285 | else | 2280 | else |
2286 | { | 2281 | { |
2287 | message_context->reply_bf = GNUNET_CONTAINER_bloomfilter_init (end, | 2282 | msg_ctx->reply_bf = GNUNET_CONTAINER_bloomfilter_init (end, |
2288 | bf_size, | 2283 | bf_size, |
2289 | GNUNET_DHT_GET_BLOOMFILTER_K); | 2284 | GNUNET_DHT_GET_BLOOMFILTER_K); |
2290 | } | 2285 | } |
@@ -2295,45 +2290,45 @@ handle_dht_get (const struct GNUNET_MessageHeader *msg, | |||
2295 | my_short_id, | 2290 | my_short_id, |
2296 | "DHT", "GET", | 2291 | "DHT", "GET", |
2297 | type, | 2292 | type, |
2298 | GNUNET_h2s (&message_context->key), | 2293 | GNUNET_h2s (&msg_ctx->key), |
2299 | message_context->unique_id); | 2294 | msg_ctx->unique_id); |
2300 | #endif | 2295 | #endif |
2301 | increment_stats(STAT_GETS); | 2296 | increment_stats(STAT_GETS); |
2302 | results = 0; | 2297 | results = 0; |
2303 | #if HAVE_MALICIOUS | 2298 | #if HAVE_MALICIOUS |
2304 | if (type == GNUNET_BLOCK_DHT_MALICIOUS_MESSAGE_TYPE) | 2299 | if (type == GNUNET_BLOCK_DHT_MALICIOUS_MESSAGE_TYPE) |
2305 | { | 2300 | { |
2306 | GNUNET_CONTAINER_bloomfilter_free (message_context->reply_bf); | 2301 | GNUNET_CONTAINER_bloomfilter_free (msg_ctx->reply_bf); |
2307 | return results; | 2302 | return results; |
2308 | } | 2303 | } |
2309 | #endif | 2304 | #endif |
2310 | message_context->do_forward = GNUNET_YES; | 2305 | msg_ctx->do_forward = GNUNET_YES; |
2311 | if (datacache != NULL) | 2306 | if (datacache != NULL) |
2312 | results | 2307 | results |
2313 | = GNUNET_DATACACHE_get (datacache, | 2308 | = GNUNET_DATACACHE_get (datacache, |
2314 | &message_context->key, type, | 2309 | &msg_ctx->key, type, |
2315 | &datacache_get_iterator, | 2310 | &datacache_get_iterator, |
2316 | message_context); | 2311 | msg_ctx); |
2317 | #if DEBUG_DHT | 2312 | #if DEBUG_DHT |
2318 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2313 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2319 | "`%s:%s': Found %d results for `%s' request uid %llu\n", my_short_id, "DHT", | 2314 | "`%s:%s': Found %d results for `%s' request uid %llu\n", my_short_id, "DHT", |
2320 | results, "GET", message_context->unique_id); | 2315 | results, "GET", msg_ctx->unique_id); |
2321 | #endif | 2316 | #endif |
2322 | if (results >= 1) | 2317 | if (results >= 1) |
2323 | { | 2318 | { |
2324 | #if DEBUG_DHT_ROUTING | 2319 | #if DEBUG_DHT_ROUTING |
2325 | if ((debug_routes) && (dhtlog_handle != NULL)) | 2320 | if ((debug_routes) && (dhtlog_handle != NULL)) |
2326 | { | 2321 | { |
2327 | dhtlog_handle->insert_query (NULL, message_context->unique_id, DHTLOG_GET, | 2322 | dhtlog_handle->insert_query (NULL, msg_ctx->unique_id, DHTLOG_GET, |
2328 | message_context->hop_count, GNUNET_YES, &my_identity, | 2323 | msg_ctx->hop_count, GNUNET_YES, &my_identity, |
2329 | &message_context->key); | 2324 | &msg_ctx->key); |
2330 | } | 2325 | } |
2331 | 2326 | ||
2332 | if ((debug_routes_extended) && (dhtlog_handle != NULL)) | 2327 | if ((debug_routes_extended) && (dhtlog_handle != NULL)) |
2333 | { | 2328 | { |
2334 | dhtlog_handle->insert_route (NULL, message_context->unique_id, DHTLOG_ROUTE, | 2329 | dhtlog_handle->insert_route (NULL, msg_ctx->unique_id, DHTLOG_ROUTE, |
2335 | message_context->hop_count, GNUNET_YES, | 2330 | msg_ctx->hop_count, GNUNET_YES, |
2336 | &my_identity, &message_context->key, message_context->peer, | 2331 | &my_identity, &msg_ctx->key, msg_ctx->peer, |
2337 | NULL); | 2332 | NULL); |
2338 | } | 2333 | } |
2339 | #endif | 2334 | #endif |
@@ -2344,32 +2339,32 @@ handle_dht_get (const struct GNUNET_MessageHeader *msg, | |||
2344 | if (GNUNET_BLOCK_EVALUATION_REQUEST_INVALID | 2339 | if (GNUNET_BLOCK_EVALUATION_REQUEST_INVALID |
2345 | == GNUNET_BLOCK_evaluate (block_context, | 2340 | == GNUNET_BLOCK_evaluate (block_context, |
2346 | type, | 2341 | type, |
2347 | &message_context->key, | 2342 | &msg_ctx->key, |
2348 | &message_context->reply_bf, | 2343 | &msg_ctx->reply_bf, |
2349 | message_context->reply_bf_mutator, | 2344 | msg_ctx->reply_bf_mutator, |
2350 | message_context->xquery, | 2345 | msg_ctx->xquery, |
2351 | message_context->xquery_size, | 2346 | msg_ctx->xquery_size, |
2352 | NULL, 0)) | 2347 | NULL, 0)) |
2353 | { | 2348 | { |
2354 | GNUNET_break_op (0); | 2349 | GNUNET_break_op (0); |
2355 | message_context->do_forward = GNUNET_NO; | 2350 | msg_ctx->do_forward = GNUNET_NO; |
2356 | } | 2351 | } |
2357 | } | 2352 | } |
2358 | 2353 | ||
2359 | if (message_context->hop_count == 0) /* Locally initiated request */ | 2354 | if (msg_ctx->hop_count == 0) /* Locally initiated request */ |
2360 | { | 2355 | { |
2361 | #if DEBUG_DHT_ROUTING | 2356 | #if DEBUG_DHT_ROUTING |
2362 | if ((debug_routes) && (dhtlog_handle != NULL)) | 2357 | if ((debug_routes) && (dhtlog_handle != NULL)) |
2363 | { | 2358 | { |
2364 | dhtlog_handle->insert_query (NULL, message_context->unique_id, DHTLOG_GET, | 2359 | dhtlog_handle->insert_query (NULL, msg_ctx->unique_id, DHTLOG_GET, |
2365 | message_context->hop_count, GNUNET_NO, &my_identity, | 2360 | msg_ctx->hop_count, GNUNET_NO, &my_identity, |
2366 | &message_context->key); | 2361 | &msg_ctx->key); |
2367 | } | 2362 | } |
2368 | #endif | 2363 | #endif |
2369 | } | 2364 | } |
2370 | if (message_context->do_forward == GNUNET_YES) | 2365 | if (msg_ctx->do_forward == GNUNET_YES) |
2371 | route_message (msg, message_context); | 2366 | route_message (msg, msg_ctx); |
2372 | GNUNET_CONTAINER_bloomfilter_free (message_context->reply_bf); | 2367 | GNUNET_CONTAINER_bloomfilter_free (msg_ctx->reply_bf); |
2373 | return results; | 2368 | return results; |
2374 | } | 2369 | } |
2375 | 2370 | ||
@@ -2386,12 +2381,12 @@ remove_recent_find_peer(void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc | |||
2386 | * Server handler for initiating local dht find peer requests | 2381 | * Server handler for initiating local dht find peer requests |
2387 | * | 2382 | * |
2388 | * @param find_msg the actual find peer message | 2383 | * @param find_msg the actual find peer message |
2389 | * @param message_context struct containing pertinent information about the request | 2384 | * @param msg_ctx struct containing pertinent information about the request |
2390 | * | 2385 | * |
2391 | */ | 2386 | */ |
2392 | static void | 2387 | static void |
2393 | handle_dht_find_peer (const struct GNUNET_MessageHeader *find_msg, | 2388 | handle_dht_find_peer (const struct GNUNET_MessageHeader *find_msg, |
2394 | struct DHT_MessageContext *message_context) | 2389 | struct DHT_MessageContext *msg_ctx) |
2395 | { | 2390 | { |
2396 | struct GNUNET_MessageHeader *find_peer_result; | 2391 | struct GNUNET_MessageHeader *find_peer_result; |
2397 | struct GNUNET_DHT_FindPeerMessage *find_peer_message; | 2392 | struct GNUNET_DHT_FindPeerMessage *find_peer_message; |
@@ -2427,13 +2422,13 @@ handle_dht_find_peer (const struct GNUNET_MessageHeader *find_msg, | |||
2427 | increment_stats(STAT_HELLOS_PROVIDED); | 2422 | increment_stats(STAT_HELLOS_PROVIDED); |
2428 | GNUNET_TRANSPORT_offer_hello(transport_handle, other_hello); | 2423 | GNUNET_TRANSPORT_offer_hello(transport_handle, other_hello); |
2429 | GNUNET_CORE_peer_request_connect(cfg, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 5), &peer_id, NULL, NULL); | 2424 | GNUNET_CORE_peer_request_connect(cfg, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 5), &peer_id, NULL, NULL); |
2430 | route_message (find_msg, message_context); | 2425 | route_message (find_msg, msg_ctx); |
2431 | GNUNET_free (other_hello); | 2426 | GNUNET_free (other_hello); |
2432 | return; | 2427 | return; |
2433 | } | 2428 | } |
2434 | else /* We don't want this peer! */ | 2429 | else /* We don't want this peer! */ |
2435 | { | 2430 | { |
2436 | route_message (find_msg, message_context); | 2431 | route_message (find_msg, msg_ctx); |
2437 | GNUNET_free (other_hello); | 2432 | GNUNET_free (other_hello); |
2438 | return; | 2433 | return; |
2439 | } | 2434 | } |
@@ -2443,7 +2438,7 @@ handle_dht_find_peer (const struct GNUNET_MessageHeader *find_msg, | |||
2443 | #if DEBUG_DHT | 2438 | #if DEBUG_DHT |
2444 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2439 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2445 | "`%s:%s': Received `%s' request from client, key %s (msg size %d, we expected %d)\n", | 2440 | "`%s:%s': Received `%s' request from client, key %s (msg size %d, we expected %d)\n", |
2446 | my_short_id, "DHT", "FIND PEER", GNUNET_h2s (&message_context->key), | 2441 | my_short_id, "DHT", "FIND PEER", GNUNET_h2s (&msg_ctx->key), |
2447 | ntohs (find_msg->size), | 2442 | ntohs (find_msg->size), |
2448 | sizeof (struct GNUNET_MessageHeader)); | 2443 | sizeof (struct GNUNET_MessageHeader)); |
2449 | #endif | 2444 | #endif |
@@ -2455,7 +2450,7 @@ handle_dht_find_peer (const struct GNUNET_MessageHeader *find_msg, | |||
2455 | "DHT"); | 2450 | "DHT"); |
2456 | #endif | 2451 | #endif |
2457 | GNUNET_free_non_null (other_hello); | 2452 | GNUNET_free_non_null (other_hello); |
2458 | route_message (find_msg, message_context); | 2453 | route_message (find_msg, msg_ctx); |
2459 | return; | 2454 | return; |
2460 | } | 2455 | } |
2461 | 2456 | ||
@@ -2465,7 +2460,7 @@ handle_dht_find_peer (const struct GNUNET_MessageHeader *find_msg, | |||
2465 | increment_stats(STAT_BLOOM_FIND_PEER); | 2460 | increment_stats(STAT_BLOOM_FIND_PEER); |
2466 | GNUNET_CONTAINER_bloomfilter_free(incoming_bloom); | 2461 | GNUNET_CONTAINER_bloomfilter_free(incoming_bloom); |
2467 | GNUNET_free_non_null(other_hello); | 2462 | GNUNET_free_non_null(other_hello); |
2468 | route_message (find_msg, message_context); | 2463 | route_message (find_msg, msg_ctx); |
2469 | return; /* We match the bloomfilter, do not send a response to this peer (they likely already know us!)*/ | 2464 | return; /* We match the bloomfilter, do not send a response to this peer (they likely already know us!)*/ |
2470 | } | 2465 | } |
2471 | GNUNET_CONTAINER_bloomfilter_free(incoming_bloom); | 2466 | GNUNET_CONTAINER_bloomfilter_free(incoming_bloom); |
@@ -2475,7 +2470,7 @@ handle_dht_find_peer (const struct GNUNET_MessageHeader *find_msg, | |||
2475 | /** | 2470 | /** |
2476 | * Ignore any find peer requests from a peer we have seen very recently. | 2471 | * Ignore any find peer requests from a peer we have seen very recently. |
2477 | */ | 2472 | */ |
2478 | if (GNUNET_YES == GNUNET_CONTAINER_multihashmap_contains(recent_find_peer_requests, &message_context->key)) /* We have recently responded to a find peer request for this peer! */ | 2473 | if (GNUNET_YES == GNUNET_CONTAINER_multihashmap_contains(recent_find_peer_requests, &msg_ctx->key)) /* We have recently responded to a find peer request for this peer! */ |
2479 | { | 2474 | { |
2480 | increment_stats("# dht find peer requests ignored (recently seen!)"); | 2475 | increment_stats("# dht find peer requests ignored (recently seen!)"); |
2481 | GNUNET_free_non_null(other_hello); | 2476 | GNUNET_free_non_null(other_hello); |
@@ -2490,23 +2485,23 @@ handle_dht_find_peer (const struct GNUNET_MessageHeader *find_msg, | |||
2490 | * the network and has no other peers this is a problem (assume all buckets | 2485 | * the network and has no other peers this is a problem (assume all buckets |
2491 | * full, no one will respond!). | 2486 | * full, no one will respond!). |
2492 | */ | 2487 | */ |
2493 | memcpy(&peer_id.hashPubKey, &message_context->key, sizeof(GNUNET_HashCode)); | 2488 | memcpy(&peer_id.hashPubKey, &msg_ctx->key, sizeof(GNUNET_HashCode)); |
2494 | if (GNUNET_NO == consider_peer(&peer_id)) | 2489 | if (GNUNET_NO == consider_peer(&peer_id)) |
2495 | { | 2490 | { |
2496 | increment_stats("# dht find peer requests ignored (do not need!)"); | 2491 | increment_stats("# dht find peer requests ignored (do not need!)"); |
2497 | GNUNET_free_non_null(other_hello); | 2492 | GNUNET_free_non_null(other_hello); |
2498 | route_message (find_msg, message_context); | 2493 | route_message (find_msg, msg_ctx); |
2499 | return; | 2494 | return; |
2500 | } | 2495 | } |
2501 | #endif | 2496 | #endif |
2502 | 2497 | ||
2503 | recent_hash = GNUNET_malloc(sizeof(GNUNET_HashCode)); | 2498 | recent_hash = GNUNET_malloc(sizeof(GNUNET_HashCode)); |
2504 | memcpy(recent_hash, &message_context->key, sizeof(GNUNET_HashCode)); | 2499 | memcpy(recent_hash, &msg_ctx->key, sizeof(GNUNET_HashCode)); |
2505 | if (GNUNET_SYSERR != GNUNET_CONTAINER_multihashmap_put (recent_find_peer_requests, | 2500 | if (GNUNET_SYSERR != GNUNET_CONTAINER_multihashmap_put (recent_find_peer_requests, |
2506 | &message_context->key, NULL, | 2501 | &msg_ctx->key, NULL, |
2507 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)) | 2502 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)) |
2508 | { | 2503 | { |
2509 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Adding recent remove task for key `%s`!\n", GNUNET_h2s(&message_context->key)); | 2504 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Adding recent remove task for key `%s`!\n", GNUNET_h2s(&msg_ctx->key)); |
2510 | /* Only add a task if there wasn't one for this key already! */ | 2505 | /* Only add a task if there wasn't one for this key already! */ |
2511 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 30), | 2506 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 30), |
2512 | &remove_recent_find_peer, recent_hash); | 2507 | &remove_recent_find_peer, recent_hash); |
@@ -2538,11 +2533,11 @@ handle_dht_find_peer (const struct GNUNET_MessageHeader *find_msg, | |||
2538 | "DHT", hello_size); | 2533 | "DHT", hello_size); |
2539 | 2534 | ||
2540 | new_msg_ctx = GNUNET_malloc(sizeof(struct DHT_MessageContext)); | 2535 | new_msg_ctx = GNUNET_malloc(sizeof(struct DHT_MessageContext)); |
2541 | memcpy(new_msg_ctx, message_context, sizeof(struct DHT_MessageContext)); | 2536 | memcpy(new_msg_ctx, msg_ctx, sizeof(struct DHT_MessageContext)); |
2542 | new_msg_ctx->peer = &my_identity; | 2537 | new_msg_ctx->peer = &my_identity; |
2543 | new_msg_ctx->bloom = GNUNET_CONTAINER_bloomfilter_init (NULL, DHT_BLOOM_SIZE, DHT_BLOOM_K); | 2538 | new_msg_ctx->bloom = GNUNET_CONTAINER_bloomfilter_init (NULL, DHT_BLOOM_SIZE, DHT_BLOOM_K); |
2544 | new_msg_ctx->hop_count = 0; | 2539 | new_msg_ctx->hop_count = 0; |
2545 | new_msg_ctx->importance = DHT_DEFAULT_P2P_IMPORTANCE * 2; /* Make find peer requests a higher priority */ | 2540 | new_msg_ctx->importance = DHT_DEFAULT_P2P_IMPORTANCE + 2; /* Make find peer requests a higher priority */ |
2546 | new_msg_ctx->timeout = DHT_DEFAULT_P2P_TIMEOUT; | 2541 | new_msg_ctx->timeout = DHT_DEFAULT_P2P_TIMEOUT; |
2547 | increment_stats(STAT_FIND_PEER_ANSWER); | 2542 | increment_stats(STAT_FIND_PEER_ANSWER); |
2548 | route_result_message(find_peer_result, new_msg_ctx); | 2543 | route_result_message(find_peer_result, new_msg_ctx); |
@@ -2550,14 +2545,14 @@ handle_dht_find_peer (const struct GNUNET_MessageHeader *find_msg, | |||
2550 | #if DEBUG_DHT_ROUTING | 2545 | #if DEBUG_DHT_ROUTING |
2551 | if ((debug_routes) && (dhtlog_handle != NULL)) | 2546 | if ((debug_routes) && (dhtlog_handle != NULL)) |
2552 | { | 2547 | { |
2553 | dhtlog_handle->insert_query (NULL, message_context->unique_id, DHTLOG_FIND_PEER, | 2548 | dhtlog_handle->insert_query (NULL, msg_ctx->unique_id, DHTLOG_FIND_PEER, |
2554 | message_context->hop_count, GNUNET_YES, &my_identity, | 2549 | msg_ctx->hop_count, GNUNET_YES, &my_identity, |
2555 | &message_context->key); | 2550 | &msg_ctx->key); |
2556 | } | 2551 | } |
2557 | #endif | 2552 | #endif |
2558 | GNUNET_free_non_null(other_hello); | 2553 | GNUNET_free_non_null(other_hello); |
2559 | GNUNET_free(find_peer_result); | 2554 | GNUNET_free(find_peer_result); |
2560 | route_message (find_msg, message_context); | 2555 | route_message (find_msg, msg_ctx); |
2561 | } | 2556 | } |
2562 | 2557 | ||
2563 | /** | 2558 | /** |
@@ -2574,11 +2569,11 @@ republish_content(void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); | |||
2574 | * Server handler for initiating local dht put requests | 2569 | * Server handler for initiating local dht put requests |
2575 | * | 2570 | * |
2576 | * @param msg the actual put message | 2571 | * @param msg the actual put message |
2577 | * @param message_context struct containing pertinent information about the request | 2572 | * @param msg_ctx struct containing pertinent information about the request |
2578 | */ | 2573 | */ |
2579 | static void | 2574 | static void |
2580 | handle_dht_put (const struct GNUNET_MessageHeader *msg, | 2575 | handle_dht_put (const struct GNUNET_MessageHeader *msg, |
2581 | struct DHT_MessageContext *message_context) | 2576 | struct DHT_MessageContext *msg_ctx) |
2582 | { | 2577 | { |
2583 | const struct GNUNET_DHT_PutMessage *put_msg; | 2578 | const struct GNUNET_DHT_PutMessage *put_msg; |
2584 | enum GNUNET_BLOCK_Type put_type; | 2579 | enum GNUNET_BLOCK_Type put_type; |
@@ -2611,7 +2606,7 @@ handle_dht_put (const struct GNUNET_MessageHeader *msg, | |||
2611 | } | 2606 | } |
2612 | if ( (GNUNET_YES == ret) && | 2607 | if ( (GNUNET_YES == ret) && |
2613 | (0 != memcmp (&key, | 2608 | (0 != memcmp (&key, |
2614 | &message_context->key, | 2609 | &msg_ctx->key, |
2615 | sizeof (GNUNET_HashCode))) ) | 2610 | sizeof (GNUNET_HashCode))) ) |
2616 | { | 2611 | { |
2617 | /* invalid wrapper: key mismatch! */ | 2612 | /* invalid wrapper: key mismatch! */ |
@@ -2623,60 +2618,60 @@ handle_dht_put (const struct GNUNET_MessageHeader *msg, | |||
2623 | #if DEBUG_DHT | 2618 | #if DEBUG_DHT |
2624 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2619 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2625 | "`%s:%s': Received `%s' request (inserting data!), message type %d, key %s, uid %llu\n", | 2620 | "`%s:%s': Received `%s' request (inserting data!), message type %d, key %s, uid %llu\n", |
2626 | my_short_id, "DHT", "PUT", put_type, GNUNET_h2s (&message_context->key), message_context->unique_id); | 2621 | my_short_id, "DHT", "PUT", put_type, GNUNET_h2s (&msg_ctx->key), msg_ctx->unique_id); |
2627 | #endif | 2622 | #endif |
2628 | #if DEBUG_DHT_ROUTING | 2623 | #if DEBUG_DHT_ROUTING |
2629 | if (message_context->hop_count == 0) /* Locally initiated request */ | 2624 | if (msg_ctx->hop_count == 0) /* Locally initiated request */ |
2630 | { | 2625 | { |
2631 | if ((debug_routes) && (dhtlog_handle != NULL)) | 2626 | if ((debug_routes) && (dhtlog_handle != NULL)) |
2632 | { | 2627 | { |
2633 | dhtlog_handle->insert_query (NULL, message_context->unique_id, DHTLOG_PUT, | 2628 | dhtlog_handle->insert_query (NULL, msg_ctx->unique_id, DHTLOG_PUT, |
2634 | message_context->hop_count, GNUNET_NO, &my_identity, | 2629 | msg_ctx->hop_count, GNUNET_NO, &my_identity, |
2635 | &message_context->key); | 2630 | &msg_ctx->key); |
2636 | } | 2631 | } |
2637 | } | 2632 | } |
2638 | #endif | 2633 | #endif |
2639 | 2634 | ||
2640 | if (message_context->closest != GNUNET_YES) | 2635 | if (msg_ctx->closest != GNUNET_YES) |
2641 | { | 2636 | { |
2642 | route_message (msg, message_context); | 2637 | route_message (msg, msg_ctx); |
2643 | return; | 2638 | return; |
2644 | } | 2639 | } |
2645 | 2640 | ||
2646 | #if DEBUG_DHT | 2641 | #if DEBUG_DHT |
2647 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2642 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2648 | "`%s:%s': Received `%s' request (inserting data!), message type %d, key %s, uid %llu\n", | 2643 | "`%s:%s': Received `%s' request (inserting data!), message type %d, key %s, uid %llu\n", |
2649 | my_short_id, "DHT", "PUT", put_type, GNUNET_h2s (&message_context->key), message_context->unique_id); | 2644 | my_short_id, "DHT", "PUT", put_type, GNUNET_h2s (&msg_ctx->key), msg_ctx->unique_id); |
2650 | #endif | 2645 | #endif |
2651 | 2646 | ||
2652 | #if DEBUG_DHT_ROUTING | 2647 | #if DEBUG_DHT_ROUTING |
2653 | if ((debug_routes_extended) && (dhtlog_handle != NULL)) | 2648 | if ((debug_routes_extended) && (dhtlog_handle != NULL)) |
2654 | { | 2649 | { |
2655 | dhtlog_handle->insert_route (NULL, message_context->unique_id, DHTLOG_ROUTE, | 2650 | dhtlog_handle->insert_route (NULL, msg_ctx->unique_id, DHTLOG_ROUTE, |
2656 | message_context->hop_count, GNUNET_YES, | 2651 | msg_ctx->hop_count, GNUNET_YES, |
2657 | &my_identity, &message_context->key, message_context->peer, | 2652 | &my_identity, &msg_ctx->key, msg_ctx->peer, |
2658 | NULL); | 2653 | NULL); |
2659 | } | 2654 | } |
2660 | 2655 | ||
2661 | if ((debug_routes) && (dhtlog_handle != NULL)) | 2656 | if ((debug_routes) && (dhtlog_handle != NULL)) |
2662 | { | 2657 | { |
2663 | dhtlog_handle->insert_query (NULL, message_context->unique_id, DHTLOG_PUT, | 2658 | dhtlog_handle->insert_query (NULL, msg_ctx->unique_id, DHTLOG_PUT, |
2664 | message_context->hop_count, GNUNET_YES, &my_identity, | 2659 | msg_ctx->hop_count, GNUNET_YES, &my_identity, |
2665 | &message_context->key); | 2660 | &msg_ctx->key); |
2666 | } | 2661 | } |
2667 | #endif | 2662 | #endif |
2668 | 2663 | ||
2669 | increment_stats(STAT_PUTS_INSERTED); | 2664 | increment_stats(STAT_PUTS_INSERTED); |
2670 | if (datacache != NULL) | 2665 | if (datacache != NULL) |
2671 | { | 2666 | { |
2672 | ret = GNUNET_DATACACHE_put (datacache, &message_context->key, data_size, | 2667 | ret = GNUNET_DATACACHE_put (datacache, &msg_ctx->key, data_size, |
2673 | (char *) &put_msg[1], put_type, | 2668 | (char *) &put_msg[1], put_type, |
2674 | GNUNET_TIME_absolute_ntoh(put_msg->expiration)); | 2669 | GNUNET_TIME_absolute_ntoh(put_msg->expiration)); |
2675 | 2670 | ||
2676 | if ((ret == GNUNET_YES) && (do_republish == GNUNET_YES)) | 2671 | if ((ret == GNUNET_YES) && (do_republish == GNUNET_YES)) |
2677 | { | 2672 | { |
2678 | put_context = GNUNET_malloc(sizeof(struct RepublishContext)); | 2673 | put_context = GNUNET_malloc(sizeof(struct RepublishContext)); |
2679 | memcpy(&put_context->key, &message_context->key, sizeof(GNUNET_HashCode)); | 2674 | memcpy(&put_context->key, &msg_ctx->key, sizeof(GNUNET_HashCode)); |
2680 | put_context->type = put_type; | 2675 | put_context->type = put_type; |
2681 | GNUNET_SCHEDULER_add_delayed (dht_republish_frequency, &republish_content, put_context); | 2676 | GNUNET_SCHEDULER_add_delayed (dht_republish_frequency, &republish_content, put_context); |
2682 | } | 2677 | } |
@@ -2687,7 +2682,7 @@ handle_dht_put (const struct GNUNET_MessageHeader *msg, | |||
2687 | my_short_id, "DHT", "PUT"); | 2682 | my_short_id, "DHT", "PUT"); |
2688 | 2683 | ||
2689 | if (stop_on_closest == GNUNET_NO) | 2684 | if (stop_on_closest == GNUNET_NO) |
2690 | route_message (msg, message_context); | 2685 | route_message (msg, msg_ctx); |
2691 | } | 2686 | } |
2692 | 2687 | ||
2693 | /** | 2688 | /** |
@@ -3436,11 +3431,11 @@ static int cache_response(struct DHT_MessageContext *msg_ctx) | |||
3436 | * peers. | 3431 | * peers. |
3437 | * | 3432 | * |
3438 | * @param msg the message to be routed | 3433 | * @param msg the message to be routed |
3439 | * @param message_context the context containing all pertinent information about the message | 3434 | * @param msg_ctx the context containing all pertinent information about the message |
3440 | */ | 3435 | */ |
3441 | static void | 3436 | static void |
3442 | route_message(const struct GNUNET_MessageHeader *msg, | 3437 | route_message(const struct GNUNET_MessageHeader *msg, |
3443 | struct DHT_MessageContext *message_context) | 3438 | struct DHT_MessageContext *msg_ctx) |
3444 | { | 3439 | { |
3445 | int i; | 3440 | int i; |
3446 | struct PeerInfo *selected; | 3441 | struct PeerInfo *selected; |
@@ -3461,29 +3456,26 @@ route_message(const struct GNUNET_MessageHeader *msg, | |||
3461 | #if DEBUG_DHT_ROUTING | 3456 | #if DEBUG_DHT_ROUTING |
3462 | if ((debug_routes_extended) && (dhtlog_handle != NULL)) | 3457 | if ((debug_routes_extended) && (dhtlog_handle != NULL)) |
3463 | { | 3458 | { |
3464 | dhtlog_handle->insert_route (NULL, message_context->unique_id, DHTLOG_ROUTE, | 3459 | dhtlog_handle->insert_route (NULL, msg_ctx->unique_id, DHTLOG_ROUTE, |
3465 | message_context->hop_count, GNUNET_SYSERR, | 3460 | msg_ctx->hop_count, GNUNET_SYSERR, |
3466 | &my_identity, &message_context->key, message_context->peer, | 3461 | &my_identity, &msg_ctx->key, msg_ctx->peer, |
3467 | NULL); | 3462 | NULL); |
3468 | } | 3463 | } |
3469 | #endif | 3464 | #endif |
3470 | if (message_context->bloom != NULL) | 3465 | if (msg_ctx->bloom != NULL) |
3471 | GNUNET_CONTAINER_bloomfilter_free(message_context->bloom); | 3466 | GNUNET_CONTAINER_bloomfilter_free(msg_ctx->bloom); |
3472 | return; | 3467 | return; |
3473 | } | 3468 | } |
3474 | 3469 | ||
3475 | increment_stats(STAT_ROUTES); | 3470 | increment_stats(STAT_ROUTES); |
3476 | /* Semantics of this call means we find whether we are the closest peer out of those already | 3471 | forward_count = get_forward_count(msg_ctx->hop_count, msg_ctx->replication); |
3477 | * routed to on this messages path. | ||
3478 | */ | ||
3479 | forward_count = get_forward_count(message_context->hop_count, message_context->replication); | ||
3480 | GNUNET_asprintf(&stat_forward_count, "# forward counts of %d", forward_count); | 3472 | GNUNET_asprintf(&stat_forward_count, "# forward counts of %d", forward_count); |
3481 | increment_stats(stat_forward_count); | 3473 | increment_stats(stat_forward_count); |
3482 | GNUNET_free(stat_forward_count); | 3474 | GNUNET_free(stat_forward_count); |
3483 | if (message_context->bloom == NULL) | 3475 | if (msg_ctx->bloom == NULL) |
3484 | message_context->bloom = GNUNET_CONTAINER_bloomfilter_init (NULL, DHT_BLOOM_SIZE, DHT_BLOOM_K); | 3476 | msg_ctx->bloom = GNUNET_CONTAINER_bloomfilter_init (NULL, DHT_BLOOM_SIZE, DHT_BLOOM_K); |
3485 | 3477 | ||
3486 | if ((stop_on_closest == GNUNET_YES) && (message_context->closest == GNUNET_YES) && (ntohs(msg->type) == GNUNET_MESSAGE_TYPE_DHT_PUT)) | 3478 | if ((stop_on_closest == GNUNET_YES) && (msg_ctx->closest == GNUNET_YES) && (ntohs(msg->type) == GNUNET_MESSAGE_TYPE_DHT_PUT)) |
3487 | forward_count = 0; | 3479 | forward_count = 0; |
3488 | 3480 | ||
3489 | /** | 3481 | /** |
@@ -3501,7 +3493,7 @@ route_message(const struct GNUNET_MessageHeader *msg, | |||
3501 | * testing driver) we will ignore this restriction for FIND_PEER messages so that | 3493 | * testing driver) we will ignore this restriction for FIND_PEER messages so that |
3502 | * routing tables still get constructed. | 3494 | * routing tables still get constructed. |
3503 | */ | 3495 | */ |
3504 | if ((GNUNET_YES == strict_kademlia) && (message_context->closest == GNUNET_YES) && (message_context->hop_count > 0) && (ntohs(msg->type) != GNUNET_MESSAGE_TYPE_DHT_FIND_PEER)) | 3496 | if ((GNUNET_YES == strict_kademlia) && (msg_ctx->closest == GNUNET_YES) && (msg_ctx->hop_count > 0) && (ntohs(msg->type) != GNUNET_MESSAGE_TYPE_DHT_FIND_PEER)) |
3505 | forward_count = 0; | 3497 | forward_count = 0; |
3506 | 3498 | ||
3507 | #if DEBUG_DHT_ROUTING | 3499 | #if DEBUG_DHT_ROUTING |
@@ -3512,33 +3504,33 @@ route_message(const struct GNUNET_MessageHeader *msg, | |||
3512 | 3504 | ||
3513 | if ((debug_routes_extended) && (dhtlog_handle != NULL)) | 3505 | if ((debug_routes_extended) && (dhtlog_handle != NULL)) |
3514 | { | 3506 | { |
3515 | dhtlog_handle->insert_route (NULL, message_context->unique_id, DHTLOG_ROUTE, | 3507 | dhtlog_handle->insert_route (NULL, msg_ctx->unique_id, DHTLOG_ROUTE, |
3516 | message_context->hop_count, ret, | 3508 | msg_ctx->hop_count, ret, |
3517 | &my_identity, &message_context->key, message_context->peer, | 3509 | &my_identity, &msg_ctx->key, msg_ctx->peer, |
3518 | NULL); | 3510 | NULL); |
3519 | } | 3511 | } |
3520 | #endif | 3512 | #endif |
3521 | 3513 | ||
3522 | 3514 | ||
3523 | GNUNET_CONTAINER_bloomfilter_add (message_context->bloom, &my_identity.hashPubKey); | 3515 | GNUNET_CONTAINER_bloomfilter_add (msg_ctx->bloom, &my_identity.hashPubKey); |
3524 | hash_from_uid (message_context->unique_id, &unique_hash); | 3516 | hash_from_uid (msg_ctx->unique_id, &unique_hash); |
3525 | if (GNUNET_YES == GNUNET_CONTAINER_multihashmap_contains (recent.hashmap, &unique_hash)) | 3517 | if (GNUNET_YES == GNUNET_CONTAINER_multihashmap_contains (recent.hashmap, &unique_hash)) |
3526 | { | 3518 | { |
3527 | recent_req = GNUNET_CONTAINER_multihashmap_get(recent.hashmap, &unique_hash); | 3519 | recent_req = GNUNET_CONTAINER_multihashmap_get(recent.hashmap, &unique_hash); |
3528 | GNUNET_assert(recent_req != NULL); | 3520 | GNUNET_assert(recent_req != NULL); |
3529 | if (0 != memcmp(&recent_req->key, &message_context->key, sizeof(GNUNET_HashCode))) | 3521 | if (0 != memcmp(&recent_req->key, &msg_ctx->key, sizeof(GNUNET_HashCode))) |
3530 | increment_stats(STAT_DUPLICATE_UID); | 3522 | increment_stats(STAT_DUPLICATE_UID); |
3531 | else | 3523 | else |
3532 | { | 3524 | { |
3533 | increment_stats(STAT_RECENT_SEEN); | 3525 | increment_stats(STAT_RECENT_SEEN); |
3534 | GNUNET_CONTAINER_bloomfilter_or2(message_context->bloom, recent_req->bloom, DHT_BLOOM_SIZE); | 3526 | GNUNET_CONTAINER_bloomfilter_or2(msg_ctx->bloom, recent_req->bloom, DHT_BLOOM_SIZE); |
3535 | } | 3527 | } |
3536 | } | 3528 | } |
3537 | else | 3529 | else |
3538 | { | 3530 | { |
3539 | recent_req = GNUNET_malloc(sizeof(struct RecentRequest)); | 3531 | recent_req = GNUNET_malloc(sizeof(struct RecentRequest)); |
3540 | recent_req->uid = message_context->unique_id; | 3532 | recent_req->uid = msg_ctx->unique_id; |
3541 | memcpy(&recent_req->key, &message_context->key, sizeof(GNUNET_HashCode)); | 3533 | memcpy(&recent_req->key, &msg_ctx->key, sizeof(GNUNET_HashCode)); |
3542 | recent_req->remove_task = GNUNET_SCHEDULER_add_delayed(DEFAULT_RECENT_REMOVAL, &remove_recent, recent_req); | 3534 | recent_req->remove_task = GNUNET_SCHEDULER_add_delayed(DEFAULT_RECENT_REMOVAL, &remove_recent, recent_req); |
3543 | recent_req->heap_node = GNUNET_CONTAINER_heap_insert(recent.minHeap, recent_req, GNUNET_TIME_absolute_get().abs_value); | 3535 | recent_req->heap_node = GNUNET_CONTAINER_heap_insert(recent.minHeap, recent_req, GNUNET_TIME_absolute_get().abs_value); |
3544 | recent_req->bloom = GNUNET_CONTAINER_bloomfilter_init (NULL, DHT_BLOOM_SIZE, DHT_BLOOM_K); | 3536 | recent_req->bloom = GNUNET_CONTAINER_bloomfilter_init (NULL, DHT_BLOOM_SIZE, DHT_BLOOM_K); |
@@ -3555,45 +3547,45 @@ route_message(const struct GNUNET_MessageHeader *msg, | |||
3555 | 3547 | ||
3556 | for (i = 0; i < forward_count; i++) | 3548 | for (i = 0; i < forward_count; i++) |
3557 | { | 3549 | { |
3558 | selected = select_peer(&message_context->key, message_context->bloom, message_context->hop_count); | 3550 | selected = select_peer(&msg_ctx->key, msg_ctx->bloom, msg_ctx->hop_count); |
3559 | 3551 | ||
3560 | if (selected != NULL) | 3552 | if (selected != NULL) |
3561 | { | 3553 | { |
3562 | if (GNUNET_CRYPTO_hash_matching_bits(&selected->id.hashPubKey, &message_context->key) >= GNUNET_CRYPTO_hash_matching_bits(&my_identity.hashPubKey, &message_context->key)) | 3554 | if (GNUNET_CRYPTO_hash_matching_bits(&selected->id.hashPubKey, &msg_ctx->key) >= GNUNET_CRYPTO_hash_matching_bits(&my_identity.hashPubKey, &msg_ctx->key)) |
3563 | GNUNET_asprintf(&temp_stat_str, "# requests routed to close(r) peer hop %u", message_context->hop_count); | 3555 | GNUNET_asprintf(&temp_stat_str, "# requests routed to close(r) peer hop %u", msg_ctx->hop_count); |
3564 | else | 3556 | else |
3565 | GNUNET_asprintf(&temp_stat_str, "# requests routed to less close peer hop %u", message_context->hop_count); | 3557 | GNUNET_asprintf(&temp_stat_str, "# requests routed to less close peer hop %u", msg_ctx->hop_count); |
3566 | if (temp_stat_str != NULL) | 3558 | if (temp_stat_str != NULL) |
3567 | { | 3559 | { |
3568 | increment_stats(temp_stat_str); | 3560 | increment_stats(temp_stat_str); |
3569 | GNUNET_free(temp_stat_str); | 3561 | GNUNET_free(temp_stat_str); |
3570 | } | 3562 | } |
3571 | GNUNET_CONTAINER_bloomfilter_add(message_context->bloom, &selected->id.hashPubKey); | 3563 | GNUNET_CONTAINER_bloomfilter_add(msg_ctx->bloom, &selected->id.hashPubKey); |
3572 | #if DEBUG_DHT_ROUTING > 1 | 3564 | #if DEBUG_DHT_ROUTING > 1 |
3573 | nearest = find_closest_peer(&message_context->key); | 3565 | nearest = find_closest_peer(&msg_ctx->key); |
3574 | nearest_buf = GNUNET_strdup(GNUNET_i2s(&nearest->id)); | 3566 | nearest_buf = GNUNET_strdup(GNUNET_i2s(&nearest->id)); |
3575 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 3567 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
3576 | "`%s:%s': Forwarding request key %s uid %llu to peer %s (closest %s, bits %d, distance %u)\n", my_short_id, | 3568 | "`%s:%s': Forwarding request key %s uid %llu to peer %s (closest %s, bits %d, distance %u)\n", my_short_id, |
3577 | "DHT", GNUNET_h2s (&message_context->key), message_context->unique_id, GNUNET_i2s(&selected->id), nearest_buf, GNUNET_CRYPTO_hash_matching_bits(&nearest->id.hashPubKey, message_context->key), distance(&nearest->id.hashPubKey, message_context->key)); | 3569 | "DHT", GNUNET_h2s (&msg_ctx->key), msg_ctx->unique_id, GNUNET_i2s(&selected->id), nearest_buf, GNUNET_CRYPTO_hash_matching_bits(&nearest->id.hashPubKey, msg_ctx->key), distance(&nearest->id.hashPubKey, msg_ctx->key)); |
3578 | GNUNET_free(nearest_buf); | 3570 | GNUNET_free(nearest_buf); |
3579 | #endif | 3571 | #endif |
3580 | #if DEBUG_DHT_ROUTING | 3572 | #if DEBUG_DHT_ROUTING |
3581 | if ((debug_routes_extended) && (dhtlog_handle != NULL)) | 3573 | if ((debug_routes_extended) && (dhtlog_handle != NULL)) |
3582 | { | 3574 | { |
3583 | dhtlog_handle->insert_route (NULL, message_context->unique_id, DHTLOG_ROUTE, | 3575 | dhtlog_handle->insert_route (NULL, msg_ctx->unique_id, DHTLOG_ROUTE, |
3584 | message_context->hop_count, GNUNET_NO, | 3576 | msg_ctx->hop_count, GNUNET_NO, |
3585 | &my_identity, &message_context->key, message_context->peer, | 3577 | &my_identity, &msg_ctx->key, msg_ctx->peer, |
3586 | &selected->id); | 3578 | &selected->id); |
3587 | } | 3579 | } |
3588 | #endif | 3580 | #endif |
3589 | forward_message(msg, selected, message_context); | 3581 | forward_message(msg, selected, msg_ctx); |
3590 | } | 3582 | } |
3591 | } | 3583 | } |
3592 | 3584 | ||
3593 | if (message_context->bloom != NULL) | 3585 | if (msg_ctx->bloom != NULL) |
3594 | { | 3586 | { |
3595 | GNUNET_CONTAINER_bloomfilter_or2(recent_req->bloom, message_context->bloom, DHT_BLOOM_SIZE); | 3587 | GNUNET_CONTAINER_bloomfilter_or2(recent_req->bloom, msg_ctx->bloom, DHT_BLOOM_SIZE); |
3596 | GNUNET_CONTAINER_bloomfilter_free(message_context->bloom); | 3588 | GNUNET_CONTAINER_bloomfilter_free(msg_ctx->bloom); |
3597 | } | 3589 | } |
3598 | } | 3590 | } |
3599 | 3591 | ||
@@ -3604,42 +3596,42 @@ route_message(const struct GNUNET_MessageHeader *msg, | |||
3604 | * peers. | 3596 | * peers. |
3605 | * | 3597 | * |
3606 | * @param msg the message to be routed | 3598 | * @param msg the message to be routed |
3607 | * @param message_context the context containing all pertinent information about the message | 3599 | * @param msg_ctx the context containing all pertinent information about the message |
3608 | */ | 3600 | */ |
3609 | static void | 3601 | static void |
3610 | demultiplex_message(const struct GNUNET_MessageHeader *msg, | 3602 | demultiplex_message(const struct GNUNET_MessageHeader *msg, |
3611 | struct DHT_MessageContext *message_context) | 3603 | struct DHT_MessageContext *msg_ctx) |
3612 | { | 3604 | { |
3613 | message_context->closest = am_closest_peer(&message_context->key, NULL); | 3605 | msg_ctx->closest = am_closest_peer(&msg_ctx->key, NULL); |
3614 | switch (ntohs(msg->type)) | 3606 | switch (ntohs(msg->type)) |
3615 | { | 3607 | { |
3616 | case GNUNET_MESSAGE_TYPE_DHT_GET: /* Add to hashmap of requests seen, search for data (always) */ | 3608 | case GNUNET_MESSAGE_TYPE_DHT_GET: /* Add to hashmap of requests seen, search for data (always) */ |
3617 | cache_response (message_context); | 3609 | cache_response (msg_ctx); |
3618 | handle_dht_get (msg, message_context); | 3610 | handle_dht_get (msg, msg_ctx); |
3619 | break; | 3611 | break; |
3620 | case GNUNET_MESSAGE_TYPE_DHT_PUT: /* Check if closest, if so insert data. */ | 3612 | case GNUNET_MESSAGE_TYPE_DHT_PUT: /* Check if closest, if so insert data. */ |
3621 | increment_stats(STAT_PUTS); | 3613 | increment_stats(STAT_PUTS); |
3622 | handle_dht_put (msg, message_context); | 3614 | handle_dht_put (msg, msg_ctx); |
3623 | break; | 3615 | break; |
3624 | case GNUNET_MESSAGE_TYPE_DHT_FIND_PEER: /* Check if closest and not started by us, check options, add to requests seen */ | 3616 | case GNUNET_MESSAGE_TYPE_DHT_FIND_PEER: /* Check if closest and not started by us, check options, add to requests seen */ |
3625 | increment_stats(STAT_FIND_PEER); | 3617 | increment_stats(STAT_FIND_PEER); |
3626 | if (((message_context->hop_count > 0) && (0 != memcmp(message_context->peer, &my_identity, sizeof(struct GNUNET_PeerIdentity)))) || (message_context->client != NULL)) | 3618 | if (((msg_ctx->hop_count > 0) && (0 != memcmp(msg_ctx->peer, &my_identity, sizeof(struct GNUNET_PeerIdentity)))) || (msg_ctx->client != NULL)) |
3627 | { | 3619 | { |
3628 | cache_response (message_context); | 3620 | cache_response (msg_ctx); |
3629 | if ((message_context->closest == GNUNET_YES) || (message_context->msg_options == GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE)) | 3621 | if ((msg_ctx->closest == GNUNET_YES) || (msg_ctx->msg_options == GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE)) |
3630 | handle_dht_find_peer (msg, message_context); | 3622 | handle_dht_find_peer (msg, msg_ctx); |
3631 | } | 3623 | } |
3632 | else | 3624 | else |
3633 | route_message (msg, message_context); | 3625 | route_message (msg, msg_ctx); |
3634 | #if DEBUG_DHT_ROUTING | 3626 | #if DEBUG_DHT_ROUTING |
3635 | if (message_context->hop_count == 0) /* Locally initiated request */ | 3627 | if (msg_ctx->hop_count == 0) /* Locally initiated request */ |
3636 | { | 3628 | { |
3637 | if ((debug_routes) && (dhtlog_handle != NULL)) | 3629 | if ((debug_routes) && (dhtlog_handle != NULL)) |
3638 | { | 3630 | { |
3639 | dhtlog_handle->insert_dhtkey(NULL, &message_context->key); | 3631 | dhtlog_handle->insert_dhtkey(NULL, &msg_ctx->key); |
3640 | dhtlog_handle->insert_query (NULL, message_context->unique_id, DHTLOG_FIND_PEER, | 3632 | dhtlog_handle->insert_query (NULL, msg_ctx->unique_id, DHTLOG_FIND_PEER, |
3641 | message_context->hop_count, GNUNET_NO, &my_identity, | 3633 | msg_ctx->hop_count, GNUNET_NO, &my_identity, |
3642 | &message_context->key); | 3634 | &msg_ctx->key); |
3643 | } | 3635 | } |
3644 | } | 3636 | } |
3645 | #endif | 3637 | #endif |
@@ -3647,7 +3639,7 @@ demultiplex_message(const struct GNUNET_MessageHeader *msg, | |||
3647 | default: | 3639 | default: |
3648 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 3640 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
3649 | "`%s': Message type (%d) not handled, forwarding anyway!\n", "DHT", ntohs(msg->type)); | 3641 | "`%s': Message type (%d) not handled, forwarding anyway!\n", "DHT", ntohs(msg->type)); |
3650 | route_message (msg, message_context); | 3642 | route_message (msg, msg_ctx); |
3651 | } | 3643 | } |
3652 | } | 3644 | } |
3653 | 3645 | ||
@@ -3690,7 +3682,7 @@ republish_content_iterator (void *cls, | |||
3690 | put_msg->type = htons (type); | 3682 | put_msg->type = htons (type); |
3691 | memcpy (&put_msg[1], data, size); | 3683 | memcpy (&put_msg[1], data, size); |
3692 | new_msg_ctx->unique_id = GNUNET_ntohll (GNUNET_CRYPTO_random_u64(GNUNET_CRYPTO_QUALITY_WEAK, (uint64_t)-1)); | 3684 | new_msg_ctx->unique_id = GNUNET_ntohll (GNUNET_CRYPTO_random_u64(GNUNET_CRYPTO_QUALITY_WEAK, (uint64_t)-1)); |
3693 | new_msg_ctx->replication = ntohl (DHT_DEFAULT_PUT_REPLICATION); | 3685 | new_msg_ctx->replication = ntohl (DEFAULT_PUT_REPLICATION); |
3694 | new_msg_ctx->msg_options = ntohl (0); | 3686 | new_msg_ctx->msg_options = ntohl (0); |
3695 | new_msg_ctx->network_size = estimate_diameter(); | 3687 | new_msg_ctx->network_size = estimate_diameter(); |
3696 | new_msg_ctx->peer = &my_identity; | 3688 | new_msg_ctx->peer = &my_identity; |
@@ -3861,7 +3853,7 @@ static void | |||
3861 | malicious_put_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 3853 | malicious_put_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
3862 | { | 3854 | { |
3863 | static struct GNUNET_DHT_PutMessage put_message; | 3855 | static struct GNUNET_DHT_PutMessage put_message; |
3864 | static struct DHT_MessageContext message_context; | 3856 | static struct DHT_MessageContext msg_ctx; |
3865 | static GNUNET_HashCode key; | 3857 | static GNUNET_HashCode key; |
3866 | uint32_t random_key; | 3858 | uint32_t random_key; |
3867 | 3859 | ||
@@ -3871,24 +3863,24 @@ malicious_put_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
3871 | put_message.header.type = htons(GNUNET_MESSAGE_TYPE_DHT_PUT); | 3863 | put_message.header.type = htons(GNUNET_MESSAGE_TYPE_DHT_PUT); |
3872 | put_message.type = htonl(GNUNET_BLOCK_DHT_MALICIOUS_MESSAGE_TYPE); | 3864 | put_message.type = htonl(GNUNET_BLOCK_DHT_MALICIOUS_MESSAGE_TYPE); |
3873 | put_message.expiration = GNUNET_TIME_absolute_hton(GNUNET_TIME_absolute_get_forever()); | 3865 | put_message.expiration = GNUNET_TIME_absolute_hton(GNUNET_TIME_absolute_get_forever()); |
3874 | memset(&message_context, 0, sizeof(struct DHT_MessageContext)); | 3866 | memset(&msg_ctx, 0, sizeof(struct DHT_MessageContext)); |
3875 | random_key = GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_WEAK, (uint32_t)-1); | 3867 | random_key = GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_WEAK, (uint32_t)-1); |
3876 | GNUNET_CRYPTO_hash(&random_key, sizeof(uint32_t), &key); | 3868 | GNUNET_CRYPTO_hash(&random_key, sizeof(uint32_t), &key); |
3877 | memcpy(&message_context.key, &key, sizeof(GNUNET_HashCode)); | 3869 | memcpy(&msg_ctx.key, &key, sizeof(GNUNET_HashCode)); |
3878 | message_context.unique_id = GNUNET_ntohll (GNUNET_CRYPTO_random_u64(GNUNET_CRYPTO_QUALITY_WEAK, (uint64_t)-1)); | 3870 | msg_ctx.unique_id = GNUNET_ntohll (GNUNET_CRYPTO_random_u64(GNUNET_CRYPTO_QUALITY_WEAK, (uint64_t)-1)); |
3879 | message_context.replication = ntohl (DHT_DEFAULT_FIND_PEER_REPLICATION); | 3871 | msg_ctx.replication = ntohl (DHT_DEFAULT_FIND_PEER_REPLICATION); |
3880 | message_context.msg_options = ntohl (0); | 3872 | msg_ctx.msg_options = ntohl (0); |
3881 | message_context.network_size = estimate_diameter(); | 3873 | msg_ctx.network_size = estimate_diameter(); |
3882 | message_context.peer = &my_identity; | 3874 | msg_ctx.peer = &my_identity; |
3883 | message_context.importance = DHT_DEFAULT_P2P_IMPORTANCE; /* Make result routing a higher priority */ | 3875 | msg_ctx.importance = DHT_DEFAULT_P2P_IMPORTANCE; |
3884 | message_context.timeout = DHT_DEFAULT_P2P_TIMEOUT; | 3876 | msg_ctx.timeout = DHT_DEFAULT_P2P_TIMEOUT; |
3885 | #if DEBUG_DHT_ROUTING | 3877 | #if DEBUG_DHT_ROUTING |
3886 | if (dhtlog_handle != NULL) | 3878 | if (dhtlog_handle != NULL) |
3887 | dhtlog_handle->insert_dhtkey(NULL, &key); | 3879 | dhtlog_handle->insert_dhtkey(NULL, &key); |
3888 | #endif | 3880 | #endif |
3889 | increment_stats(STAT_PUT_START); | 3881 | increment_stats(STAT_PUT_START); |
3890 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "%s:%s Sending malicious PUT message with hash %s\n", my_short_id, "DHT", GNUNET_h2s(&key)); | 3882 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "%s:%s Sending malicious PUT message with hash %s\n", my_short_id, "DHT", GNUNET_h2s(&key)); |
3891 | demultiplex_message(&put_message.header, &message_context); | 3883 | demultiplex_message(&put_message.header, &msg_ctx); |
3892 | GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, malicious_put_frequency), &malicious_put_task, NULL); | 3884 | GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, malicious_put_frequency), &malicious_put_task, NULL); |
3893 | } | 3885 | } |
3894 | 3886 | ||
@@ -3903,7 +3895,7 @@ static void | |||
3903 | malicious_get_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 3895 | malicious_get_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
3904 | { | 3896 | { |
3905 | static struct GNUNET_DHT_GetMessage get_message; | 3897 | static struct GNUNET_DHT_GetMessage get_message; |
3906 | struct DHT_MessageContext message_context; | 3898 | struct DHT_MessageContext msg_ctx; |
3907 | static GNUNET_HashCode key; | 3899 | static GNUNET_HashCode key; |
3908 | uint32_t random_key; | 3900 | uint32_t random_key; |
3909 | 3901 | ||
@@ -3913,24 +3905,24 @@ malicious_get_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
3913 | get_message.header.size = htons(sizeof(struct GNUNET_DHT_GetMessage)); | 3905 | get_message.header.size = htons(sizeof(struct GNUNET_DHT_GetMessage)); |
3914 | get_message.header.type = htons(GNUNET_MESSAGE_TYPE_DHT_GET); | 3906 | get_message.header.type = htons(GNUNET_MESSAGE_TYPE_DHT_GET); |
3915 | get_message.type = htonl(GNUNET_BLOCK_DHT_MALICIOUS_MESSAGE_TYPE); | 3907 | get_message.type = htonl(GNUNET_BLOCK_DHT_MALICIOUS_MESSAGE_TYPE); |
3916 | memset(&message_context, 0, sizeof(struct DHT_MessageContext)); | 3908 | memset(&msg_ctx, 0, sizeof(struct DHT_MessageContext)); |
3917 | random_key = GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_WEAK, (uint32_t)-1); | 3909 | random_key = GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_WEAK, (uint32_t)-1); |
3918 | GNUNET_CRYPTO_hash(&random_key, sizeof(uint32_t), &key); | 3910 | GNUNET_CRYPTO_hash(&random_key, sizeof(uint32_t), &key); |
3919 | memcpy(&message_context.key, &key, sizeof(GNUNET_HashCode)); | 3911 | memcpy(&msg_ctx.key, &key, sizeof(GNUNET_HashCode)); |
3920 | message_context.unique_id = GNUNET_ntohll (GNUNET_CRYPTO_random_u64(GNUNET_CRYPTO_QUALITY_WEAK, (uint64_t)-1)); | 3912 | msg_ctx.unique_id = GNUNET_ntohll (GNUNET_CRYPTO_random_u64(GNUNET_CRYPTO_QUALITY_WEAK, (uint64_t)-1)); |
3921 | message_context.replication = ntohl (DHT_DEFAULT_FIND_PEER_REPLICATION); | 3913 | msg_ctx.replication = ntohl (DHT_DEFAULT_FIND_PEER_REPLICATION); |
3922 | message_context.msg_options = ntohl (0); | 3914 | msg_ctx.msg_options = ntohl (0); |
3923 | message_context.network_size = estimate_diameter(); | 3915 | msg_ctx.network_size = estimate_diameter(); |
3924 | message_context.peer = &my_identity; | 3916 | msg_ctx.peer = &my_identity; |
3925 | message_context.importance = DHT_DEFAULT_P2P_IMPORTANCE; /* Make result routing a higher priority */ | 3917 | msg_ctx.importance = DHT_DEFAULT_P2P_IMPORTANCE; |
3926 | message_context.timeout = DHT_DEFAULT_P2P_TIMEOUT; | 3918 | msg_ctx.timeout = DHT_DEFAULT_P2P_TIMEOUT; |
3927 | #if DEBUG_DHT_ROUTING | 3919 | #if DEBUG_DHT_ROUTING |
3928 | if (dhtlog_handle != NULL) | 3920 | if (dhtlog_handle != NULL) |
3929 | dhtlog_handle->insert_dhtkey(NULL, &key); | 3921 | dhtlog_handle->insert_dhtkey(NULL, &key); |
3930 | #endif | 3922 | #endif |
3931 | increment_stats(STAT_GET_START); | 3923 | increment_stats(STAT_GET_START); |
3932 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "%s:%s Sending malicious GET message with hash %s\n", my_short_id, "DHT", GNUNET_h2s(&key)); | 3924 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "%s:%s Sending malicious GET message with hash %s\n", my_short_id, "DHT", GNUNET_h2s(&key)); |
3933 | demultiplex_message (&get_message.header, &message_context); | 3925 | demultiplex_message (&get_message.header, &msg_ctx); |
3934 | GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, malicious_get_frequency), &malicious_get_task, NULL); | 3926 | GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, malicious_get_frequency), &malicious_get_task, NULL); |
3935 | } | 3927 | } |
3936 | #endif | 3928 | #endif |
@@ -3968,7 +3960,7 @@ static void | |||
3968 | send_find_peer_message (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 3960 | send_find_peer_message (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
3969 | { | 3961 | { |
3970 | struct GNUNET_DHT_FindPeerMessage *find_peer_msg; | 3962 | struct GNUNET_DHT_FindPeerMessage *find_peer_msg; |
3971 | struct DHT_MessageContext message_context; | 3963 | struct DHT_MessageContext msg_ctx; |
3972 | struct GNUNET_TIME_Relative next_send_time; | 3964 | struct GNUNET_TIME_Relative next_send_time; |
3973 | struct GNUNET_CONTAINER_BloomFilter *temp_bloom; | 3965 | struct GNUNET_CONTAINER_BloomFilter *temp_bloom; |
3974 | #if COUNT_INTERVAL | 3966 | #if COUNT_INTERVAL |
@@ -4018,17 +4010,17 @@ send_find_peer_message (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc | |||
4018 | temp_bloom = GNUNET_CONTAINER_bloomfilter_init (NULL, DHT_BLOOM_SIZE, DHT_BLOOM_K); | 4010 | temp_bloom = GNUNET_CONTAINER_bloomfilter_init (NULL, DHT_BLOOM_SIZE, DHT_BLOOM_K); |
4019 | GNUNET_CONTAINER_multihashmap_iterate(all_known_peers, &add_known_to_bloom, temp_bloom); | 4011 | GNUNET_CONTAINER_multihashmap_iterate(all_known_peers, &add_known_to_bloom, temp_bloom); |
4020 | GNUNET_assert(GNUNET_OK == GNUNET_CONTAINER_bloomfilter_get_raw_data(temp_bloom, find_peer_msg->bloomfilter, DHT_BLOOM_SIZE)); | 4012 | GNUNET_assert(GNUNET_OK == GNUNET_CONTAINER_bloomfilter_get_raw_data(temp_bloom, find_peer_msg->bloomfilter, DHT_BLOOM_SIZE)); |
4021 | memset(&message_context, 0, sizeof(struct DHT_MessageContext)); | 4013 | memset(&msg_ctx, 0, sizeof(struct DHT_MessageContext)); |
4022 | memcpy(&message_context.key, &my_identity.hashPubKey, sizeof(GNUNET_HashCode)); | 4014 | memcpy(&msg_ctx.key, &my_identity.hashPubKey, sizeof(GNUNET_HashCode)); |
4023 | message_context.unique_id = GNUNET_ntohll (GNUNET_CRYPTO_random_u64(GNUNET_CRYPTO_QUALITY_STRONG, (uint64_t)-1)); | 4015 | msg_ctx.unique_id = GNUNET_ntohll (GNUNET_CRYPTO_random_u64(GNUNET_CRYPTO_QUALITY_STRONG, (uint64_t)-1)); |
4024 | message_context.replication = DHT_DEFAULT_FIND_PEER_REPLICATION; | 4016 | msg_ctx.replication = DHT_DEFAULT_FIND_PEER_REPLICATION; |
4025 | message_context.msg_options = DHT_DEFAULT_FIND_PEER_OPTIONS; | 4017 | msg_ctx.msg_options = DHT_DEFAULT_FIND_PEER_OPTIONS; |
4026 | message_context.network_size = estimate_diameter(); | 4018 | msg_ctx.network_size = estimate_diameter(); |
4027 | message_context.peer = &my_identity; | 4019 | msg_ctx.peer = &my_identity; |
4028 | message_context.importance = DHT_DEFAULT_FIND_PEER_IMPORTANCE; | 4020 | msg_ctx.importance = DHT_DEFAULT_FIND_PEER_IMPORTANCE; |
4029 | message_context.timeout = DHT_DEFAULT_FIND_PEER_TIMEOUT; | 4021 | msg_ctx.timeout = DHT_DEFAULT_FIND_PEER_TIMEOUT; |
4030 | 4022 | ||
4031 | demultiplex_message(&find_peer_msg->header, &message_context); | 4023 | demultiplex_message(&find_peer_msg->header, &msg_ctx); |
4032 | GNUNET_free(find_peer_msg); | 4024 | GNUNET_free(find_peer_msg); |
4033 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 4025 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
4034 | "`%s:%s': Sent `%s' request to some (?) peers\n", my_short_id, "DHT", | 4026 | "`%s:%s': Sent `%s' request to some (?) peers\n", my_short_id, "DHT", |
@@ -4072,7 +4064,7 @@ handle_dht_local_route_request (void *cls, struct GNUNET_SERVER_Client *client, | |||
4072 | { | 4064 | { |
4073 | const struct GNUNET_DHT_RouteMessage *dht_msg = (const struct GNUNET_DHT_RouteMessage *) message; | 4065 | const struct GNUNET_DHT_RouteMessage *dht_msg = (const struct GNUNET_DHT_RouteMessage *) message; |
4074 | const struct GNUNET_MessageHeader *enc_msg; | 4066 | const struct GNUNET_MessageHeader *enc_msg; |
4075 | struct DHT_MessageContext message_context; | 4067 | struct DHT_MessageContext msg_ctx; |
4076 | 4068 | ||
4077 | enc_msg = (const struct GNUNET_MessageHeader *) &dht_msg[1]; | 4069 | enc_msg = (const struct GNUNET_MessageHeader *) &dht_msg[1]; |
4078 | #if DEBUG_DHT | 4070 | #if DEBUG_DHT |
@@ -4089,16 +4081,16 @@ handle_dht_local_route_request (void *cls, struct GNUNET_SERVER_Client *client, | |||
4089 | if (dhtlog_handle != NULL) | 4081 | if (dhtlog_handle != NULL) |
4090 | dhtlog_handle->insert_dhtkey (NULL, &dht_msg->key); | 4082 | dhtlog_handle->insert_dhtkey (NULL, &dht_msg->key); |
4091 | #endif | 4083 | #endif |
4092 | memset(&message_context, 0, sizeof(struct DHT_MessageContext)); | 4084 | memset(&msg_ctx, 0, sizeof(struct DHT_MessageContext)); |
4093 | message_context.client = find_active_client (client); | 4085 | msg_ctx.client = find_active_client (client); |
4094 | memcpy(&message_context.key, &dht_msg->key, sizeof(GNUNET_HashCode)); | 4086 | memcpy(&msg_ctx.key, &dht_msg->key, sizeof(GNUNET_HashCode)); |
4095 | message_context.unique_id = GNUNET_ntohll (dht_msg->unique_id); | 4087 | msg_ctx.unique_id = GNUNET_ntohll (dht_msg->unique_id); |
4096 | message_context.replication = ntohl (dht_msg->desired_replication_level); | 4088 | msg_ctx.replication = ntohl (dht_msg->desired_replication_level); |
4097 | message_context.msg_options = ntohl (dht_msg->options); | 4089 | msg_ctx.msg_options = ntohl (dht_msg->options); |
4098 | message_context.network_size = estimate_diameter(); | 4090 | msg_ctx.network_size = estimate_diameter(); |
4099 | message_context.peer = &my_identity; | 4091 | msg_ctx.peer = &my_identity; |
4100 | message_context.importance = DHT_DEFAULT_P2P_IMPORTANCE * 4; /* Make local routing a higher priority */ | 4092 | msg_ctx.importance = DHT_DEFAULT_P2P_IMPORTANCE + 4; /* Make local routing a higher priority */ |
4101 | message_context.timeout = DHT_DEFAULT_P2P_TIMEOUT; | 4093 | msg_ctx.timeout = DHT_DEFAULT_P2P_TIMEOUT; |
4102 | if (ntohs(enc_msg->type) == GNUNET_MESSAGE_TYPE_DHT_GET) | 4094 | if (ntohs(enc_msg->type) == GNUNET_MESSAGE_TYPE_DHT_GET) |
4103 | increment_stats(STAT_GET_START); | 4095 | increment_stats(STAT_GET_START); |
4104 | else if (ntohs(enc_msg->type) == GNUNET_MESSAGE_TYPE_DHT_PUT) | 4096 | else if (ntohs(enc_msg->type) == GNUNET_MESSAGE_TYPE_DHT_PUT) |
@@ -4106,7 +4098,7 @@ handle_dht_local_route_request (void *cls, struct GNUNET_SERVER_Client *client, | |||
4106 | else if (ntohs(enc_msg->type) == GNUNET_MESSAGE_TYPE_DHT_FIND_PEER) | 4098 | else if (ntohs(enc_msg->type) == GNUNET_MESSAGE_TYPE_DHT_FIND_PEER) |
4107 | increment_stats(STAT_FIND_PEER_START); | 4099 | increment_stats(STAT_FIND_PEER_START); |
4108 | 4100 | ||
4109 | demultiplex_message(enc_msg, &message_context); | 4101 | demultiplex_message(enc_msg, &msg_ctx); |
4110 | 4102 | ||
4111 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | 4103 | GNUNET_SERVER_receive_done (client, GNUNET_OK); |
4112 | 4104 | ||
@@ -4242,7 +4234,7 @@ handle_dht_p2p_route_request (void *cls, | |||
4242 | #endif | 4234 | #endif |
4243 | struct GNUNET_DHT_P2PRouteMessage *incoming = (struct GNUNET_DHT_P2PRouteMessage *)message; | 4235 | struct GNUNET_DHT_P2PRouteMessage *incoming = (struct GNUNET_DHT_P2PRouteMessage *)message; |
4244 | struct GNUNET_MessageHeader *enc_msg = (struct GNUNET_MessageHeader *)&incoming[1]; | 4236 | struct GNUNET_MessageHeader *enc_msg = (struct GNUNET_MessageHeader *)&incoming[1]; |
4245 | struct DHT_MessageContext *message_context; | 4237 | struct DHT_MessageContext *msg_ctx; |
4246 | 4238 | ||
4247 | if (get_max_send_delay().rel_value > MAX_REQUEST_TIME.rel_value) | 4239 | if (get_max_send_delay().rel_value > MAX_REQUEST_TIME.rel_value) |
4248 | { | 4240 | { |
@@ -4265,20 +4257,20 @@ handle_dht_p2p_route_request (void *cls, | |||
4265 | GNUNET_break_op(0); | 4257 | GNUNET_break_op(0); |
4266 | return GNUNET_YES; | 4258 | return GNUNET_YES; |
4267 | } | 4259 | } |
4268 | message_context = GNUNET_malloc(sizeof (struct DHT_MessageContext)); | 4260 | msg_ctx = GNUNET_malloc(sizeof (struct DHT_MessageContext)); |
4269 | message_context->bloom = GNUNET_CONTAINER_bloomfilter_init(incoming->bloomfilter, DHT_BLOOM_SIZE, DHT_BLOOM_K); | 4261 | msg_ctx->bloom = GNUNET_CONTAINER_bloomfilter_init(incoming->bloomfilter, DHT_BLOOM_SIZE, DHT_BLOOM_K); |
4270 | GNUNET_assert(message_context->bloom != NULL); | 4262 | GNUNET_assert(msg_ctx->bloom != NULL); |
4271 | message_context->hop_count = ntohl(incoming->hop_count); | 4263 | msg_ctx->hop_count = ntohl(incoming->hop_count); |
4272 | memcpy(&message_context->key, &incoming->key, sizeof(GNUNET_HashCode)); | 4264 | memcpy(&msg_ctx->key, &incoming->key, sizeof(GNUNET_HashCode)); |
4273 | message_context->replication = ntohl(incoming->desired_replication_level); | 4265 | msg_ctx->replication = ntohl(incoming->desired_replication_level); |
4274 | message_context->unique_id = GNUNET_ntohll(incoming->unique_id); | 4266 | msg_ctx->unique_id = GNUNET_ntohll(incoming->unique_id); |
4275 | message_context->msg_options = ntohl(incoming->options); | 4267 | msg_ctx->msg_options = ntohl(incoming->options); |
4276 | message_context->network_size = ntohl(incoming->network_size); | 4268 | msg_ctx->network_size = ntohl(incoming->network_size); |
4277 | message_context->peer = peer; | 4269 | msg_ctx->peer = peer; |
4278 | message_context->importance = DHT_DEFAULT_P2P_IMPORTANCE; | 4270 | msg_ctx->importance = DHT_DEFAULT_P2P_IMPORTANCE; |
4279 | message_context->timeout = DHT_DEFAULT_P2P_TIMEOUT; | 4271 | msg_ctx->timeout = DHT_DEFAULT_P2P_TIMEOUT; |
4280 | demultiplex_message(enc_msg, message_context); | 4272 | demultiplex_message(enc_msg, msg_ctx); |
4281 | GNUNET_free(message_context); | 4273 | GNUNET_free(msg_ctx); |
4282 | return GNUNET_YES; | 4274 | return GNUNET_YES; |
4283 | } | 4275 | } |
4284 | 4276 | ||
@@ -4298,7 +4290,7 @@ handle_dht_p2p_route_result (void *cls, | |||
4298 | #endif | 4290 | #endif |
4299 | struct GNUNET_DHT_P2PRouteResultMessage *incoming = (struct GNUNET_DHT_P2PRouteResultMessage *)message; | 4291 | struct GNUNET_DHT_P2PRouteResultMessage *incoming = (struct GNUNET_DHT_P2PRouteResultMessage *)message; |
4300 | struct GNUNET_MessageHeader *enc_msg = (struct GNUNET_MessageHeader *)&incoming[1]; | 4292 | struct GNUNET_MessageHeader *enc_msg = (struct GNUNET_MessageHeader *)&incoming[1]; |
4301 | struct DHT_MessageContext message_context; | 4293 | struct DHT_MessageContext msg_ctx; |
4302 | 4294 | ||
4303 | if (ntohs(enc_msg->size) >= GNUNET_SERVER_MAX_MESSAGE_SIZE - 1) | 4295 | if (ntohs(enc_msg->size) >= GNUNET_SERVER_MAX_MESSAGE_SIZE - 1) |
4304 | { | 4296 | { |
@@ -4306,18 +4298,18 @@ handle_dht_p2p_route_result (void *cls, | |||
4306 | return GNUNET_YES; | 4298 | return GNUNET_YES; |
4307 | } | 4299 | } |
4308 | 4300 | ||
4309 | memset(&message_context, 0, sizeof(struct DHT_MessageContext)); | 4301 | memset(&msg_ctx, 0, sizeof(struct DHT_MessageContext)); |
4310 | // FIXME: call GNUNET_BLOCK_evaluate (...) -- instead of doing your own bloomfilter! | 4302 | // FIXME: call GNUNET_BLOCK_evaluate (...) -- instead of doing your own bloomfilter! |
4311 | message_context.bloom = GNUNET_CONTAINER_bloomfilter_init(incoming->bloomfilter, DHT_BLOOM_SIZE, DHT_BLOOM_K); | 4303 | msg_ctx.bloom = GNUNET_CONTAINER_bloomfilter_init(incoming->bloomfilter, DHT_BLOOM_SIZE, DHT_BLOOM_K); |
4312 | GNUNET_assert(message_context.bloom != NULL); | 4304 | GNUNET_assert(msg_ctx.bloom != NULL); |
4313 | memcpy(&message_context.key, &incoming->key, sizeof(GNUNET_HashCode)); | 4305 | memcpy(&msg_ctx.key, &incoming->key, sizeof(GNUNET_HashCode)); |
4314 | message_context.unique_id = GNUNET_ntohll(incoming->unique_id); | 4306 | msg_ctx.unique_id = GNUNET_ntohll(incoming->unique_id); |
4315 | message_context.msg_options = ntohl(incoming->options); | 4307 | msg_ctx.msg_options = ntohl(incoming->options); |
4316 | message_context.hop_count = ntohl(incoming->hop_count); | 4308 | msg_ctx.hop_count = ntohl(incoming->hop_count); |
4317 | message_context.peer = peer; | 4309 | msg_ctx.peer = peer; |
4318 | message_context.importance = DHT_DEFAULT_P2P_IMPORTANCE * 2; /* Make result routing a higher priority */ | 4310 | msg_ctx.importance = DHT_DEFAULT_P2P_IMPORTANCE + 2; /* Make result routing a higher priority */ |
4319 | message_context.timeout = DHT_DEFAULT_P2P_TIMEOUT; | 4311 | msg_ctx.timeout = DHT_DEFAULT_P2P_TIMEOUT; |
4320 | route_result_message(enc_msg, &message_context); | 4312 | route_result_message(enc_msg, &msg_ctx); |
4321 | return GNUNET_YES; | 4313 | return GNUNET_YES; |
4322 | } | 4314 | } |
4323 | 4315 | ||
diff --git a/src/dht/plugin_dhtlog_dummy.c b/src/dht/plugin_dhtlog_dummy.c index 803ad92ac..3f3cd8de1 100644 --- a/src/dht/plugin_dhtlog_dummy.c +++ b/src/dht/plugin_dhtlog_dummy.c | |||
@@ -41,7 +41,6 @@ | |||
41 | */ | 41 | */ |
42 | int add_trial (struct GNUNET_DHTLOG_TrialInfo *trial_info) | 42 | int add_trial (struct GNUNET_DHTLOG_TrialInfo *trial_info) |
43 | { | 43 | { |
44 | trial_info->trialuid = 42; | ||
45 | return GNUNET_OK; | 44 | return GNUNET_OK; |
46 | } | 45 | } |
47 | 46 | ||
@@ -93,14 +92,12 @@ add_node (unsigned long long *nodeuid, struct GNUNET_PeerIdentity * node) | |||
93 | /* | 92 | /* |
94 | * Update dhttests.trials table with current server time as end time | 93 | * Update dhttests.trials table with current server time as end time |
95 | * | 94 | * |
96 | * @param trialuid trial to update | ||
97 | * @param gets_succeeded how many gets did the testcase report as successful | 95 | * @param gets_succeeded how many gets did the testcase report as successful |
98 | * | 96 | * |
99 | * @return GNUNET_OK on success, GNUNET_SYSERR on failure. | 97 | * @return GNUNET_OK on success, GNUNET_SYSERR on failure. |
100 | */ | 98 | */ |
101 | int | 99 | int |
102 | update_trials (unsigned long long trialuid, | 100 | update_trials (unsigned int gets_succeeded) |
103 | unsigned int gets_succeeded) | ||
104 | { | 101 | { |
105 | return GNUNET_OK; | 102 | return GNUNET_OK; |
106 | } | 103 | } |
@@ -127,13 +124,12 @@ add_generic_stat (const struct GNUNET_PeerIdentity *peer, | |||
127 | /* | 124 | /* |
128 | * Update dhttests.trials table with total connections information | 125 | * Update dhttests.trials table with total connections information |
129 | * | 126 | * |
130 | * @param trialuid the trialuid to update | ||
131 | * @param totalConnections the number of connections | 127 | * @param totalConnections the number of connections |
132 | * | 128 | * |
133 | * @return GNUNET_OK on success, GNUNET_SYSERR on failure. | 129 | * @return GNUNET_OK on success, GNUNET_SYSERR on failure. |
134 | */ | 130 | */ |
135 | int | 131 | int |
136 | add_connections (unsigned long long trialuid, unsigned int totalConnections) | 132 | add_connections (unsigned int totalConnections) |
137 | { | 133 | { |
138 | return GNUNET_OK; | 134 | return GNUNET_OK; |
139 | } | 135 | } |
diff --git a/src/dht/plugin_dhtlog_mysql.c b/src/dht/plugin_dhtlog_mysql.c index 127db015d..5510163b0 100644 --- a/src/dht/plugin_dhtlog_mysql.c +++ b/src/dht/plugin_dhtlog_mysql.c | |||
@@ -850,7 +850,7 @@ int add_trial (struct GNUNET_DHTLOG_TrialInfo *trial_info) | |||
850 | 850 | ||
851 | stmt = mysql_stmt_init(conn); | 851 | stmt = mysql_stmt_init(conn); |
852 | if (GNUNET_OK != | 852 | if (GNUNET_OK != |
853 | (ret = prepared_statement_run (insert_trial, &trial_info->trialuid, | 853 | (ret = prepared_statement_run (insert_trial, ¤t_trial, |
854 | MYSQL_TYPE_LONG, &trial_info->other_identifier, GNUNET_YES, | 854 | MYSQL_TYPE_LONG, &trial_info->other_identifier, GNUNET_YES, |
855 | MYSQL_TYPE_LONG, &trial_info->num_nodes, GNUNET_YES, | 855 | MYSQL_TYPE_LONG, &trial_info->num_nodes, GNUNET_YES, |
856 | MYSQL_TYPE_LONG, &trial_info->topology, GNUNET_YES, | 856 | MYSQL_TYPE_LONG, &trial_info->topology, GNUNET_YES, |
@@ -1149,14 +1149,12 @@ add_node (unsigned long long *nodeuid, struct GNUNET_PeerIdentity * node) | |||
1149 | /* | 1149 | /* |
1150 | * Update dhttests.trials table with current server time as end time | 1150 | * Update dhttests.trials table with current server time as end time |
1151 | * | 1151 | * |
1152 | * @param trialuid trial to update | ||
1153 | * @param gets_succeeded how many gets did the testcase report as successful | 1152 | * @param gets_succeeded how many gets did the testcase report as successful |
1154 | * | 1153 | * |
1155 | * @return GNUNET_OK on success, GNUNET_SYSERR on failure. | 1154 | * @return GNUNET_OK on success, GNUNET_SYSERR on failure. |
1156 | */ | 1155 | */ |
1157 | int | 1156 | int |
1158 | update_trials (unsigned long long trialuid, | 1157 | update_trials (unsigned int gets_succeeded) |
1159 | unsigned int gets_succeeded) | ||
1160 | { | 1158 | { |
1161 | int ret; | 1159 | int ret; |
1162 | 1160 | ||
@@ -1164,7 +1162,7 @@ update_trials (unsigned long long trialuid, | |||
1164 | (ret = prepared_statement_run (update_trial, | 1162 | (ret = prepared_statement_run (update_trial, |
1165 | NULL, | 1163 | NULL, |
1166 | MYSQL_TYPE_LONG, &gets_succeeded, GNUNET_YES, | 1164 | MYSQL_TYPE_LONG, &gets_succeeded, GNUNET_YES, |
1167 | MYSQL_TYPE_LONGLONG, &trialuid, GNUNET_YES, | 1165 | MYSQL_TYPE_LONGLONG, ¤t_trial, GNUNET_YES, |
1168 | -1))) | 1166 | -1))) |
1169 | { | 1167 | { |
1170 | if (ret == GNUNET_SYSERR) | 1168 | if (ret == GNUNET_SYSERR) |
@@ -1215,13 +1213,12 @@ int set_malicious (struct GNUNET_PeerIdentity *peer) | |||
1215 | /* | 1213 | /* |
1216 | * Update dhttests.trials table with total connections information | 1214 | * Update dhttests.trials table with total connections information |
1217 | * | 1215 | * |
1218 | * @param trialuid the trialuid to update | ||
1219 | * @param totalConnections the number of connections | 1216 | * @param totalConnections the number of connections |
1220 | * | 1217 | * |
1221 | * @return GNUNET_OK on success, GNUNET_SYSERR on failure. | 1218 | * @return GNUNET_OK on success, GNUNET_SYSERR on failure. |
1222 | */ | 1219 | */ |
1223 | int | 1220 | int |
1224 | add_connections (unsigned long long trialuid, unsigned int totalConnections) | 1221 | add_connections (unsigned int totalConnections) |
1225 | { | 1222 | { |
1226 | int ret; | 1223 | int ret; |
1227 | 1224 | ||
@@ -1232,7 +1229,7 @@ add_connections (unsigned long long trialuid, unsigned int totalConnections) | |||
1232 | &totalConnections, | 1229 | &totalConnections, |
1233 | GNUNET_YES, | 1230 | GNUNET_YES, |
1234 | MYSQL_TYPE_LONGLONG, | 1231 | MYSQL_TYPE_LONGLONG, |
1235 | &trialuid, GNUNET_YES, -1))) | 1232 | ¤t_trial, GNUNET_YES, -1))) |
1236 | { | 1233 | { |
1237 | if (ret == GNUNET_SYSERR) | 1234 | if (ret == GNUNET_SYSERR) |
1238 | { | 1235 | { |
diff --git a/src/dht/plugin_dhtlog_mysql_dump.c b/src/dht/plugin_dhtlog_mysql_dump.c index 6b6133068..1e549d115 100644 --- a/src/dht/plugin_dhtlog_mysql_dump.c +++ b/src/dht/plugin_dhtlog_mysql_dump.c | |||
@@ -289,7 +289,7 @@ add_extended_topology (const struct GNUNET_PeerIdentity *first, const struct GNU | |||
289 | int add_trial (struct GNUNET_DHTLOG_TrialInfo *trial_info) | 289 | int add_trial (struct GNUNET_DHTLOG_TrialInfo *trial_info) |
290 | { | 290 | { |
291 | int ret; | 291 | int ret; |
292 | trial_info->trialuid = 0; | 292 | |
293 | if (outfile == NULL) | 293 | if (outfile == NULL) |
294 | return GNUNET_SYSERR; | 294 | return GNUNET_SYSERR; |
295 | 295 | ||
@@ -505,23 +505,14 @@ add_node (unsigned long long *nodeuid, struct GNUNET_PeerIdentity * node) | |||
505 | /* | 505 | /* |
506 | * Update dhttests.trials table with current server time as end time | 506 | * Update dhttests.trials table with current server time as end time |
507 | * | 507 | * |
508 | * @param trialuid trial to update | ||
509 | * @param gets_succeeded how many gets did the testcase report as successful | 508 | * @param gets_succeeded how many gets did the testcase report as successful |
510 | * | 509 | * |
511 | * @return GNUNET_OK on success, GNUNET_SYSERR on failure. | 510 | * @return GNUNET_OK on success, GNUNET_SYSERR on failure. |
512 | */ | 511 | */ |
513 | int | 512 | int |
514 | update_trials (unsigned long long trialuid, | 513 | update_trials (unsigned int gets_succeeded) |
515 | unsigned int gets_succeeded) | ||
516 | { | 514 | { |
517 | int ret; | 515 | int ret; |
518 | #if DEBUG_DHTLOG | ||
519 | /* if (trialuid != current_trial) | ||
520 | { | ||
521 | fprintf (stderr, | ||
522 | _("Trialuid to update is not equal to current_trial\n")); | ||
523 | }*/ | ||
524 | #endif | ||
525 | 516 | ||
526 | if (outfile == NULL) | 517 | if (outfile == NULL) |
527 | return GNUNET_SYSERR; | 518 | return GNUNET_SYSERR; |
@@ -573,22 +564,15 @@ set_malicious (struct GNUNET_PeerIdentity *peer) | |||
573 | /* | 564 | /* |
574 | * Update dhttests.trials table with total connections information | 565 | * Update dhttests.trials table with total connections information |
575 | * | 566 | * |
576 | * @param trialuid the trialuid to update | ||
577 | * @param totalConnections the number of connections | 567 | * @param totalConnections the number of connections |
578 | * | 568 | * |
579 | * @return GNUNET_OK on success, GNUNET_SYSERR on failure. | 569 | * @return GNUNET_OK on success, GNUNET_SYSERR on failure. |
580 | */ | 570 | */ |
581 | int | 571 | int |
582 | add_connections (unsigned long long trialuid, unsigned int totalConnections) | 572 | add_connections (unsigned int totalConnections) |
583 | { | 573 | { |
584 | int ret; | 574 | int ret; |
585 | #if DEBUG_DHTLOG | 575 | |
586 | /* if (trialuid != current_trial) | ||
587 | { | ||
588 | fprintf (stderr, | ||
589 | _("Trialuid to update is not equal to current_trial(!)(?)\n")); | ||
590 | }*/ | ||
591 | #endif | ||
592 | if (outfile == NULL) | 576 | if (outfile == NULL) |
593 | return GNUNET_SYSERR; | 577 | return GNUNET_SYSERR; |
594 | 578 | ||
diff --git a/src/dht/plugin_dhtlog_mysql_dump_load.c b/src/dht/plugin_dhtlog_mysql_dump_load.c index a5231d9eb..973b20908 100644 --- a/src/dht/plugin_dhtlog_mysql_dump_load.c +++ b/src/dht/plugin_dhtlog_mysql_dump_load.c | |||
@@ -167,7 +167,6 @@ add_extended_topology (const struct GNUNET_PeerIdentity *first, const struct GNU | |||
167 | int add_trial (struct GNUNET_DHTLOG_TrialInfo *trial_info) | 167 | int add_trial (struct GNUNET_DHTLOG_TrialInfo *trial_info) |
168 | { | 168 | { |
169 | int ret; | 169 | int ret; |
170 | trial_info->trialuid = 0; | ||
171 | if (outfile == NULL) | 170 | if (outfile == NULL) |
172 | return GNUNET_SYSERR; | 171 | return GNUNET_SYSERR; |
173 | 172 | ||
@@ -336,23 +335,14 @@ add_node (unsigned long long *nodeuid, struct GNUNET_PeerIdentity * node) | |||
336 | /* | 335 | /* |
337 | * Update dhttests.trials table with current server time as end time | 336 | * Update dhttests.trials table with current server time as end time |
338 | * | 337 | * |
339 | * @param trialuid trial to update | ||
340 | * @param gets_succeeded how many gets did the testcase report as successful | 338 | * @param gets_succeeded how many gets did the testcase report as successful |
341 | * | 339 | * |
342 | * @return GNUNET_OK on success, GNUNET_SYSERR on failure. | 340 | * @return GNUNET_OK on success, GNUNET_SYSERR on failure. |
343 | */ | 341 | */ |
344 | int | 342 | int |
345 | update_trials (unsigned long long trialuid, | 343 | update_trials (unsigned int gets_succeeded) |
346 | unsigned int gets_succeeded) | ||
347 | { | 344 | { |
348 | int ret; | 345 | int ret; |
349 | #if DEBUG_DHTLOG | ||
350 | /* if (trialuid != current_trial) | ||
351 | { | ||
352 | fprintf (stderr, | ||
353 | _("Trialuid to update is not equal to current_trial\n")); | ||
354 | }*/ | ||
355 | #endif | ||
356 | 346 | ||
357 | if (outfile == NULL) | 347 | if (outfile == NULL) |
358 | return GNUNET_SYSERR; | 348 | return GNUNET_SYSERR; |
@@ -394,22 +384,15 @@ set_malicious (struct GNUNET_PeerIdentity *peer) | |||
394 | /* | 384 | /* |
395 | * Update dhttests.trials table with total connections information | 385 | * Update dhttests.trials table with total connections information |
396 | * | 386 | * |
397 | * @param trialuid the trialuid to update | ||
398 | * @param totalConnections the number of connections | 387 | * @param totalConnections the number of connections |
399 | * | 388 | * |
400 | * @return GNUNET_OK on success, GNUNET_SYSERR on failure. | 389 | * @return GNUNET_OK on success, GNUNET_SYSERR on failure. |
401 | */ | 390 | */ |
402 | int | 391 | int |
403 | add_connections (unsigned long long trialuid, unsigned int totalConnections) | 392 | add_connections (unsigned int totalConnections) |
404 | { | 393 | { |
405 | int ret; | 394 | int ret; |
406 | #if DEBUG_DHTLOG | 395 | |
407 | /* if (trialuid != current_trial) | ||
408 | { | ||
409 | fprintf (stderr, | ||
410 | _("Trialuid to update is not equal to current_trial(!)(?)\n")); | ||
411 | }*/ | ||
412 | #endif | ||
413 | if (outfile == NULL) | 396 | if (outfile == NULL) |
414 | return GNUNET_SYSERR; | 397 | return GNUNET_SYSERR; |
415 | 398 | ||
diff --git a/src/dht/test_dht_api.c b/src/dht/test_dht_api.c index de3d97647..b82d8cd7e 100644 --- a/src/dht/test_dht_api.c +++ b/src/dht/test_dht_api.c | |||
@@ -400,6 +400,7 @@ test_get (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
400 | TOTAL_TIMEOUT, | 400 | TOTAL_TIMEOUT, |
401 | GNUNET_BLOCK_TYPE_TEST, | 401 | GNUNET_BLOCK_TYPE_TEST, |
402 | &hash, | 402 | &hash, |
403 | DEFAULT_GET_REPLICATION, | ||
403 | GNUNET_DHT_RO_NONE, | 404 | GNUNET_DHT_RO_NONE, |
404 | NULL, 0, | 405 | NULL, 0, |
405 | NULL, 0, | 406 | NULL, 0, |
@@ -438,6 +439,7 @@ test_put (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
438 | GNUNET_assert (peer->dht_handle != NULL); | 439 | GNUNET_assert (peer->dht_handle != NULL); |
439 | 440 | ||
440 | GNUNET_DHT_put (peer->dht_handle, &hash, | 441 | GNUNET_DHT_put (peer->dht_handle, &hash, |
442 | DEFAULT_PUT_REPLICATION, | ||
441 | GNUNET_DHT_RO_NONE, | 443 | GNUNET_DHT_RO_NONE, |
442 | GNUNET_BLOCK_TYPE_TEST, | 444 | GNUNET_BLOCK_TYPE_TEST, |
443 | data_size, data, | 445 | data_size, data, |
diff --git a/src/dht/test_dht_multipeer.c b/src/dht/test_dht_multipeer.c index 9c18c4f2e..24618230a 100644 --- a/src/dht/test_dht_multipeer.c +++ b/src/dht/test_dht_multipeer.c | |||
@@ -447,6 +447,7 @@ do_get (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) | |||
447 | GNUNET_TIME_UNIT_FOREVER_REL, | 447 | GNUNET_TIME_UNIT_FOREVER_REL, |
448 | GNUNET_BLOCK_TYPE_TEST, | 448 | GNUNET_BLOCK_TYPE_TEST, |
449 | &key, | 449 | &key, |
450 | DEFAULT_GET_REPLICATION, | ||
450 | GNUNET_DHT_RO_NONE, | 451 | GNUNET_DHT_RO_NONE, |
451 | NULL, 0, | 452 | NULL, 0, |
452 | NULL, 0, | 453 | NULL, 0, |
@@ -515,6 +516,7 @@ do_put (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) | |||
515 | outstanding_puts++; | 516 | outstanding_puts++; |
516 | GNUNET_DHT_put(test_put->dht_handle, | 517 | GNUNET_DHT_put(test_put->dht_handle, |
517 | &key, | 518 | &key, |
519 | DEFAULT_PUT_REPLICATION, | ||
518 | GNUNET_DHT_RO_NONE, | 520 | GNUNET_DHT_RO_NONE, |
519 | GNUNET_BLOCK_TYPE_TEST, | 521 | GNUNET_BLOCK_TYPE_TEST, |
520 | sizeof(data), data, | 522 | sizeof(data), data, |
diff --git a/src/dht/test_dht_twopeer.c b/src/dht/test_dht_twopeer.c index 6f3d5060d..d5923dc11 100644 --- a/src/dht/test_dht_twopeer.c +++ b/src/dht/test_dht_twopeer.c | |||
@@ -220,7 +220,8 @@ get_stop_finished (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) | |||
220 | &stop_retry_get, get_context); | 220 | &stop_retry_get, get_context); |
221 | get_context->get_handle = GNUNET_DHT_get_start(get_context->dht_handle, | 221 | get_context->get_handle = GNUNET_DHT_get_start(get_context->dht_handle, |
222 | GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 5), | 222 | GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 5), |
223 | 0 /* fixme: use real type */, &get_context->peer->hashPubKey, | 223 | 0 /* FIXME: use real type */, &get_context->peer->hashPubKey, |
224 | DEFAULT_GET_REPLICATION, | ||
224 | GNUNET_DHT_RO_NONE, | 225 | GNUNET_DHT_RO_NONE, |
225 | NULL, 0, | 226 | NULL, 0, |
226 | NULL, 0, | 227 | NULL, 0, |
@@ -250,6 +251,7 @@ do_get (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) | |||
250 | GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 5), | 251 | GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 5), |
251 | GNUNET_BLOCK_TYPE_DHT_HELLO, | 252 | GNUNET_BLOCK_TYPE_DHT_HELLO, |
252 | &get_context->peer->hashPubKey, | 253 | &get_context->peer->hashPubKey, |
254 | DEFAULT_GET_REPLICATION, | ||
253 | GNUNET_DHT_RO_NONE, | 255 | GNUNET_DHT_RO_NONE, |
254 | NULL, 0, | 256 | NULL, 0, |
255 | NULL, 0, | 257 | NULL, 0, |
diff --git a/src/dht/test_dht_twopeer_put_get.c b/src/dht/test_dht_twopeer_put_get.c index 0f61f4930..8e10eea6b 100644 --- a/src/dht/test_dht_twopeer_put_get.c +++ b/src/dht/test_dht_twopeer_put_get.c | |||
@@ -239,6 +239,7 @@ do_get (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) | |||
239 | global_get_handle = GNUNET_DHT_get_start(peer2dht, GNUNET_TIME_relative_get_forever(), | 239 | global_get_handle = GNUNET_DHT_get_start(peer2dht, GNUNET_TIME_relative_get_forever(), |
240 | GNUNET_BLOCK_TYPE_TEST, | 240 | GNUNET_BLOCK_TYPE_TEST, |
241 | &key, | 241 | &key, |
242 | DEFAULT_GET_REPLICATION, | ||
242 | GNUNET_DHT_RO_NONE, | 243 | GNUNET_DHT_RO_NONE, |
243 | NULL, 0, | 244 | NULL, 0, |
244 | NULL, 0, | 245 | NULL, 0, |
@@ -272,6 +273,7 @@ do_put (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) | |||
272 | /* Insert the data at the first peer */ | 273 | /* Insert the data at the first peer */ |
273 | GNUNET_DHT_put(peer1dht, | 274 | GNUNET_DHT_put(peer1dht, |
274 | &key, | 275 | &key, |
276 | DEFAULT_PUT_REPLICATION, | ||
275 | GNUNET_DHT_RO_NONE, | 277 | GNUNET_DHT_RO_NONE, |
276 | GNUNET_BLOCK_TYPE_TEST, | 278 | GNUNET_BLOCK_TYPE_TEST, |
277 | sizeof(data), data, | 279 | sizeof(data), data, |
diff --git a/src/dht/test_dhtlog.c b/src/dht/test_dhtlog.c index 06e2db2c4..c8601b191 100644 --- a/src/dht/test_dhtlog.c +++ b/src/dht/test_dhtlog.c | |||
@@ -168,7 +168,7 @@ test (struct GNUNET_DHTLOG_Handle * api) | |||
168 | #if VERBOSE | 168 | #if VERBOSE |
169 | fprintf(stderr, "Insert stat succeeded!\n"); | 169 | fprintf(stderr, "Insert stat succeeded!\n"); |
170 | #endif | 170 | #endif |
171 | ret = api->update_trial (trial_info.trialuid, 787); | 171 | ret = api->update_trial (787); |
172 | CHECK(ret); | 172 | CHECK(ret); |
173 | #if VERBOSE | 173 | #if VERBOSE |
174 | fprintf(stderr, "Update trial succeeded!\n"); | 174 | fprintf(stderr, "Update trial succeeded!\n"); |
diff --git a/src/fs/gnunet-service-fs.c b/src/fs/gnunet-service-fs.c index 1cb5432c7..fd4ec74ed 100644 --- a/src/fs/gnunet-service-fs.c +++ b/src/fs/gnunet-service-fs.c | |||
@@ -1341,6 +1341,7 @@ process_dht_put_content (void *cls, | |||
1341 | #endif | 1341 | #endif |
1342 | GNUNET_DHT_put (dht_handle, | 1342 | GNUNET_DHT_put (dht_handle, |
1343 | key, | 1343 | key, |
1344 | DEFAULT_PUT_REPLICATION, | ||
1344 | GNUNET_DHT_RO_NONE, | 1345 | GNUNET_DHT_RO_NONE, |
1345 | type, | 1346 | type, |
1346 | size, | 1347 | size, |
@@ -2924,6 +2925,7 @@ forward_request_task (void *cls, | |||
2924 | GNUNET_TIME_UNIT_FOREVER_REL, | 2925 | GNUNET_TIME_UNIT_FOREVER_REL, |
2925 | pr->type, | 2926 | pr->type, |
2926 | &pr->query, | 2927 | &pr->query, |
2928 | DEFAULT_GET_REPLICATION, | ||
2927 | GNUNET_DHT_RO_NONE, | 2929 | GNUNET_DHT_RO_NONE, |
2928 | pr->bf, | 2930 | pr->bf, |
2929 | pr->mingle, | 2931 | pr->mingle, |
diff --git a/src/include/gnunet_dht_service.h b/src/include/gnunet_dht_service.h index 7ab818de7..18eab8a9f 100644 --- a/src/include/gnunet_dht_service.h +++ b/src/include/gnunet_dht_service.h | |||
@@ -52,6 +52,20 @@ extern "C" | |||
52 | #define GNUNET_DHT_GET_BLOOMFILTER_K 16 | 52 | #define GNUNET_DHT_GET_BLOOMFILTER_K 16 |
53 | 53 | ||
54 | /** | 54 | /** |
55 | * Non-intelligent default DHT GET replication. | ||
56 | * Should be chosen by application if anything about | ||
57 | * the network is known. | ||
58 | */ | ||
59 | #define DEFAULT_GET_REPLICATION 5 | ||
60 | |||
61 | /** | ||
62 | * Non-intelligent default DHT PUT replication. | ||
63 | * Should be chosen by application if anything about | ||
64 | * the network is known. | ||
65 | */ | ||
66 | #define DEFAULT_PUT_REPLICATION 8 | ||
67 | |||
68 | /** | ||
55 | * Connection to the DHT service. | 69 | * Connection to the DHT service. |
56 | */ | 70 | */ |
57 | struct GNUNET_DHT_Handle; | 71 | struct GNUNET_DHT_Handle; |
@@ -121,33 +135,34 @@ GNUNET_DHT_disconnect (struct GNUNET_DHT_Handle *handle); | |||
121 | /* *************** Standard API: get and put ******************* */ | 135 | /* *************** Standard API: get and put ******************* */ |
122 | 136 | ||
123 | /** | 137 | /** |
124 | * Perform a PUT operation on the DHT identified by 'table' storing | 138 | * Perform a PUT operation storing data in the DHT. |
125 | * a binding of 'key' to 'value'. The peer does not have to be part | ||
126 | * of the table (if so, we will attempt to locate a peer that is!) | ||
127 | * | 139 | * |
128 | * @param handle handle to DHT service | 140 | * @param handle handle to DHT service |
129 | * @param key the key to store data under | 141 | * @param key the key to store under |
142 | * @param desired_replication_level estimate of how many | ||
143 | * nearest peers this request should reach | ||
130 | * @param options routing options for this message | 144 | * @param options routing options for this message |
131 | * @param type type of the value | 145 | * @param type type of the value |
132 | * @param size number of bytes in data; must be less than 64k | 146 | * @param size number of bytes in data; must be less than 64k |
133 | * @param data the data to store | 147 | * @param data the data to store |
134 | * @param exp desired expiration time for the data | 148 | * @param exp desired expiration time for the value |
135 | * @param timeout when to abort if we fail to transmit the request | 149 | * @param timeout how long to wait for transmission of this request |
136 | * for the PUT to the local DHT service | ||
137 | * @param cont continuation to call when done (transmitting request to service) | 150 | * @param cont continuation to call when done (transmitting request to service) |
138 | * @param cont_cls closure for cont | 151 | * @param cont_cls closure for cont |
152 | * @return GNUNET_YES if put message is queued for transmission | ||
139 | */ | 153 | */ |
140 | void | 154 | void |
141 | GNUNET_DHT_put (struct GNUNET_DHT_Handle *handle, | 155 | GNUNET_DHT_put (struct GNUNET_DHT_Handle *handle, |
142 | const GNUNET_HashCode * key, | 156 | const GNUNET_HashCode * key, |
143 | enum GNUNET_DHT_RouteOption options, | 157 | uint32_t desired_replication_level, |
158 | enum GNUNET_DHT_RouteOption options, | ||
144 | enum GNUNET_BLOCK_Type type, | 159 | enum GNUNET_BLOCK_Type type, |
145 | size_t size, | 160 | size_t size, |
146 | const char *data, | 161 | const char *data, |
147 | struct GNUNET_TIME_Absolute exp, | 162 | struct GNUNET_TIME_Absolute exp, |
148 | struct GNUNET_TIME_Relative timeout, | 163 | struct GNUNET_TIME_Relative timeout, |
149 | GNUNET_SCHEDULER_Task cont, | 164 | GNUNET_SCHEDULER_Task cont, |
150 | void *cont_cls); | 165 | void *cont_cls); |
151 | 166 | ||
152 | 167 | ||
153 | /** | 168 | /** |
@@ -177,33 +192,36 @@ typedef void (*GNUNET_DHT_GetIterator)(void *cls, | |||
177 | 192 | ||
178 | 193 | ||
179 | /** | 194 | /** |
180 | * Perform an asynchronous GET operation on the DHT. See | 195 | * Perform an asynchronous GET operation on the DHT identified. See |
181 | * also "GNUNET_BLOCK_evaluate". | 196 | * also "GNUNET_BLOCK_evaluate". |
182 | * | 197 | * |
183 | * @param handle handle to the DHT service | 198 | * @param handle handle to the DHT service |
184 | * @param timeout timeout for this request to be sent to the | 199 | * @param timeout how long to wait for transmission of this request to the service |
185 | * service (this is NOT a timeout for receiving responses) | 200 | * @param type expected type of the response object |
186 | * @param type expected type of the response object (GNUNET_BLOCK_TYPE_FS_*) | ||
187 | * @param key the key to look up | 201 | * @param key the key to look up |
202 | * @param desired_replication_level estimate of how many | ||
203 | nearest peers this request should reach | ||
188 | * @param options routing options for this message | 204 | * @param options routing options for this message |
189 | * @param bf bloom filter associated with query (can be NULL) | 205 | * @param bf bloom filter associated with query (can be NULL) |
190 | * @param bf_mutator mutation value for bf | 206 | * @param bf_mutator mutation value for bf |
191 | * @param xquery extrended query data (can be NULL, depending on type) | 207 | * @param xquery extended query data (can be NULL, depending on type) |
192 | * @param xquery_size number of bytes in xquery | 208 | * @param xquery_size number of bytes in xquery |
193 | * @param iter function to call on each result | 209 | * @param iter function to call on each result |
194 | * @param iter_cls closure for iter | 210 | * @param iter_cls closure for iter |
195 | * @return handle to stop the async get, NULL on error | 211 | * |
212 | * @return handle to stop the async get | ||
196 | */ | 213 | */ |
197 | struct GNUNET_DHT_GetHandle * | 214 | struct GNUNET_DHT_GetHandle * |
198 | GNUNET_DHT_get_start (struct GNUNET_DHT_Handle *handle, | 215 | GNUNET_DHT_get_start (struct GNUNET_DHT_Handle *handle, |
199 | struct GNUNET_TIME_Relative timeout, | 216 | struct GNUNET_TIME_Relative timeout, |
200 | enum GNUNET_BLOCK_Type type, | 217 | enum GNUNET_BLOCK_Type type, |
201 | const GNUNET_HashCode * key, | 218 | const GNUNET_HashCode * key, |
202 | enum GNUNET_DHT_RouteOption options, | 219 | uint32_t desired_replication_level, |
203 | const struct GNUNET_CONTAINER_BloomFilter *bf, | 220 | enum GNUNET_DHT_RouteOption options, |
204 | int32_t bf_mutator, | 221 | const struct GNUNET_CONTAINER_BloomFilter *bf, |
205 | const void *xquery, | 222 | int32_t bf_mutator, |
206 | size_t xquery_size, | 223 | const void *xquery, |
224 | size_t xquery_size, | ||
207 | GNUNET_DHT_GetIterator iter, | 225 | GNUNET_DHT_GetIterator iter, |
208 | void *iter_cls); | 226 | void *iter_cls); |
209 | 227 | ||
@@ -212,6 +230,9 @@ GNUNET_DHT_get_start (struct GNUNET_DHT_Handle *handle, | |||
212 | * Stop async DHT-get. Frees associated resources. | 230 | * Stop async DHT-get. Frees associated resources. |
213 | * | 231 | * |
214 | * @param get_handle GET operation to stop. | 232 | * @param get_handle GET operation to stop. |
233 | * | ||
234 | * On return get_handle will no longer be valid, caller | ||
235 | * must not use again!!! | ||
215 | */ | 236 | */ |
216 | void | 237 | void |
217 | GNUNET_DHT_get_stop (struct GNUNET_DHT_GetHandle *get_handle); | 238 | GNUNET_DHT_get_stop (struct GNUNET_DHT_GetHandle *get_handle); |
diff --git a/src/vpn/gnunet-service-dns.c b/src/vpn/gnunet-service-dns.c index d807df29b..3fd4db534 100644 --- a/src/vpn/gnunet-service-dns.c +++ b/src/vpn/gnunet-service-dns.c | |||
@@ -391,6 +391,7 @@ receive_query(void *cls, | |||
391 | GNUNET_TIME_UNIT_MINUTES, | 391 | GNUNET_TIME_UNIT_MINUTES, |
392 | GNUNET_BLOCK_TYPE_DNS, | 392 | GNUNET_BLOCK_TYPE_DNS, |
393 | &key, | 393 | &key, |
394 | DEFAULT_GET_REPLICATION, | ||
394 | GNUNET_DHT_RO_NONE, | 395 | GNUNET_DHT_RO_NONE, |
395 | NULL, | 396 | NULL, |
396 | 0, | 397 | 0, |
@@ -552,6 +553,7 @@ publish_name (void *cls, | |||
552 | 553 | ||
553 | GNUNET_DHT_put(dht, | 554 | GNUNET_DHT_put(dht, |
554 | &data.service_descriptor, | 555 | &data.service_descriptor, |
556 | DEFAULT_PUT_REPLICATION, | ||
555 | GNUNET_DHT_RO_NONE, | 557 | GNUNET_DHT_RO_NONE, |
556 | GNUNET_BLOCK_TYPE_DNS, | 558 | GNUNET_BLOCK_TYPE_DNS, |
557 | size, | 559 | size, |