diff options
Diffstat (limited to 'src')
40 files changed, 419 insertions, 552 deletions
diff --git a/src/cadet/gnunet-service-cadet_dht.c b/src/cadet/gnunet-service-cadet_dht.c index 6caac474d..d44a50f50 100644 --- a/src/cadet/gnunet-service-cadet_dht.c +++ b/src/cadet/gnunet-service-cadet_dht.c | |||
@@ -112,16 +112,15 @@ static struct GNUNET_TIME_Relative announce_delay; | |||
112 | static void | 112 | static void |
113 | dht_get_id_handler (void *cls, struct GNUNET_TIME_Absolute exp, | 113 | dht_get_id_handler (void *cls, struct GNUNET_TIME_Absolute exp, |
114 | const struct GNUNET_HashCode *key, | 114 | const struct GNUNET_HashCode *key, |
115 | const struct GNUNET_PeerIdentity *get_path, | 115 | const struct GNUNET_DHT_PathElement *get_path, |
116 | unsigned int get_path_length, | 116 | unsigned int get_path_length, |
117 | const struct GNUNET_PeerIdentity *put_path, | 117 | const struct GNUNET_DHT_PathElement *put_path, |
118 | unsigned int put_path_length, | 118 | unsigned int put_path_length, |
119 | enum GNUNET_BLOCK_Type type, | 119 | enum GNUNET_BLOCK_Type type, |
120 | size_t size, | 120 | size_t size, |
121 | const void *data) | 121 | const void *data) |
122 | { | 122 | { |
123 | const struct GNUNET_HELLO_Message *hello = data; | 123 | const struct GNUNET_HELLO_Message *hello = data; |
124 | struct CadetPeer *peer; | ||
125 | 124 | ||
126 | GCPP_try_path_from_dht (get_path, | 125 | GCPP_try_path_from_dht (get_path, |
127 | get_path_length, | 126 | get_path_length, |
@@ -131,7 +130,9 @@ dht_get_id_handler (void *cls, struct GNUNET_TIME_Absolute exp, | |||
131 | (ntohs (hello->header.size) == size) && | 130 | (ntohs (hello->header.size) == size) && |
132 | (size == GNUNET_HELLO_size (hello))) | 131 | (size == GNUNET_HELLO_size (hello))) |
133 | { | 132 | { |
134 | peer = GCP_get (&put_path[0], | 133 | struct CadetPeer *peer; |
134 | |||
135 | peer = GCP_get (&put_path[0].pred, | ||
135 | GNUNET_YES); | 136 | GNUNET_YES); |
136 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 137 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
137 | "Got HELLO for %s\n", | 138 | "Got HELLO for %s\n", |
diff --git a/src/cadet/gnunet-service-cadet_paths.c b/src/cadet/gnunet-service-cadet_paths.c index 2da4e2708..aa31aaa74 100644 --- a/src/cadet/gnunet-service-cadet_paths.c +++ b/src/cadet/gnunet-service-cadet_paths.c | |||
@@ -468,9 +468,9 @@ extend_path (struct CadetPeerPath *path, | |||
468 | * @return a path through the network | 468 | * @return a path through the network |
469 | */ | 469 | */ |
470 | void | 470 | void |
471 | GCPP_try_path_from_dht (const struct GNUNET_PeerIdentity *get_path, | 471 | GCPP_try_path_from_dht (const struct GNUNET_DHT_PathElement *get_path, |
472 | unsigned int get_path_length, | 472 | unsigned int get_path_length, |
473 | const struct GNUNET_PeerIdentity *put_path, | 473 | const struct GNUNET_DHT_PathElement *put_path, |
474 | unsigned int put_path_length) | 474 | unsigned int put_path_length) |
475 | { | 475 | { |
476 | struct CadetPeer *cpath[get_path_length + put_path_length]; | 476 | struct CadetPeer *cpath[get_path_length + put_path_length]; |
@@ -490,8 +490,8 @@ GCPP_try_path_from_dht (const struct GNUNET_PeerIdentity *get_path, | |||
490 | const struct GNUNET_PeerIdentity *pid; | 490 | const struct GNUNET_PeerIdentity *pid; |
491 | 491 | ||
492 | pid = (off < get_path_length) | 492 | pid = (off < get_path_length) |
493 | ? &get_path[get_path_length - off - 1] | 493 | ? &get_path[get_path_length - off - 1].pred |
494 | : &put_path[get_path_length + put_path_length - off - 1]; | 494 | : &put_path[get_path_length + put_path_length - off - 1].pred; |
495 | /* Check that I am not in the path */ | 495 | /* Check that I am not in the path */ |
496 | if (0 == GNUNET_memcmp (&my_full_id, | 496 | if (0 == GNUNET_memcmp (&my_full_id, |
497 | pid)) | 497 | pid)) |
diff --git a/src/cadet/gnunet-service-cadet_paths.h b/src/cadet/gnunet-service-cadet_paths.h index 3961dd721..afd193596 100644 --- a/src/cadet/gnunet-service-cadet_paths.h +++ b/src/cadet/gnunet-service-cadet_paths.h | |||
@@ -28,6 +28,7 @@ | |||
28 | #define GNUNET_SERVICE_CADET_PATHS_H | 28 | #define GNUNET_SERVICE_CADET_PATHS_H |
29 | 29 | ||
30 | #include "gnunet_util_lib.h" | 30 | #include "gnunet_util_lib.h" |
31 | #include "gnunet_dht_service.h" | ||
31 | #include "gnunet-service-cadet.h" | 32 | #include "gnunet-service-cadet.h" |
32 | 33 | ||
33 | /** | 34 | /** |
@@ -42,9 +43,9 @@ | |||
42 | * @param put_path_length length of the @a put_path | 43 | * @param put_path_length length of the @a put_path |
43 | */ | 44 | */ |
44 | void | 45 | void |
45 | GCPP_try_path_from_dht (const struct GNUNET_PeerIdentity *get_path, | 46 | GCPP_try_path_from_dht (const struct GNUNET_DHT_PathElement *get_path, |
46 | unsigned int get_path_length, | 47 | unsigned int get_path_length, |
47 | const struct GNUNET_PeerIdentity *put_path, | 48 | const struct GNUNET_DHT_PathElement *put_path, |
48 | unsigned int put_path_length); | 49 | unsigned int put_path_length); |
49 | 50 | ||
50 | 51 | ||
diff --git a/src/datacache/datacache.c b/src/datacache/datacache.c index 8b665e705..944a99aad 100644 --- a/src/datacache/datacache.c +++ b/src/datacache/datacache.c | |||
@@ -243,7 +243,7 @@ GNUNET_DATACACHE_put (struct GNUNET_DATACACHE_Handle *h, | |||
243 | enum GNUNET_BLOCK_Type type, | 243 | enum GNUNET_BLOCK_Type type, |
244 | struct GNUNET_TIME_Absolute discard_time, | 244 | struct GNUNET_TIME_Absolute discard_time, |
245 | unsigned int path_info_len, | 245 | unsigned int path_info_len, |
246 | const struct GNUNET_PeerIdentity *path_info) | 246 | const struct GNUNET_DHT_PathElement *path_info) |
247 | { | 247 | { |
248 | ssize_t used; | 248 | ssize_t used; |
249 | 249 | ||
diff --git a/src/datacache/perf_datacache.c b/src/datacache/perf_datacache.c index ce3b4c25d..84bc4a852 100644 --- a/src/datacache/perf_datacache.c +++ b/src/datacache/perf_datacache.c | |||
@@ -47,21 +47,27 @@ static const char *plugin_name; | |||
47 | 47 | ||
48 | static int | 48 | static int |
49 | checkIt (void *cls, | 49 | checkIt (void *cls, |
50 | const struct GNUNET_HashCode *key, size_t size, const char *data, | 50 | const struct GNUNET_HashCode *key, |
51 | size_t size, | ||
52 | const char *data, | ||
51 | enum GNUNET_BLOCK_Type type, | 53 | enum GNUNET_BLOCK_Type type, |
52 | struct GNUNET_TIME_Absolute exp, | 54 | struct GNUNET_TIME_Absolute exp, |
53 | unsigned int path_len, | 55 | unsigned int path_len, |
54 | const struct GNUNET_PeerIdentity *path) | 56 | const struct GNUNET_DHT_PathElement *path) |
55 | { | 57 | { |
56 | if ((size == sizeof(struct GNUNET_HashCode)) && (0 == memcmp (data, cls, | 58 | if ( (size == sizeof(struct GNUNET_HashCode)) && |
57 | size))) | 59 | (0 == memcmp (data, |
60 | cls, | ||
61 | size)) ) | ||
58 | found++; | 62 | found++; |
59 | return GNUNET_OK; | 63 | return GNUNET_OK; |
60 | } | 64 | } |
61 | 65 | ||
62 | 66 | ||
63 | static void | 67 | static void |
64 | run (void *cls, char *const *args, const char *cfgfile, | 68 | run (void *cls, |
69 | char *const *args, | ||
70 | const char *cfgfile, | ||
65 | const struct GNUNET_CONFIGURATION_Handle *cfg) | 71 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
66 | { | 72 | { |
67 | struct GNUNET_DATACACHE_Handle *h; | 73 | struct GNUNET_DATACACHE_Handle *h; |
diff --git a/src/datacache/plugin_datacache_heap.c b/src/datacache/plugin_datacache_heap.c index 20d18458d..fbd3aea9a 100644 --- a/src/datacache/plugin_datacache_heap.c +++ b/src/datacache/plugin_datacache_heap.c | |||
@@ -80,7 +80,7 @@ struct Value | |||
80 | /** | 80 | /** |
81 | * Path information. | 81 | * Path information. |
82 | */ | 82 | */ |
83 | struct GNUNET_PeerIdentity *path_info; | 83 | struct GNUNET_DHT_PathElement *path_info; |
84 | 84 | ||
85 | /** | 85 | /** |
86 | * Payload (actual payload follows this struct) | 86 | * Payload (actual payload follows this struct) |
@@ -125,7 +125,7 @@ struct PutContext | |||
125 | /** | 125 | /** |
126 | * Path information. | 126 | * Path information. |
127 | */ | 127 | */ |
128 | const struct GNUNET_PeerIdentity *path_info; | 128 | const struct GNUNET_DHT_PathElement *path_info; |
129 | 129 | ||
130 | /** | 130 | /** |
131 | * Number of bytes in @e data. | 131 | * Number of bytes in @e data. |
@@ -181,7 +181,8 @@ put_cb (void *cls, | |||
181 | put_ctx->path_info_len); | 181 | put_ctx->path_info_len); |
182 | GNUNET_memcpy (val->path_info, | 182 | GNUNET_memcpy (val->path_info, |
183 | put_ctx->path_info, | 183 | put_ctx->path_info, |
184 | put_ctx->path_info_len * sizeof(struct GNUNET_PeerIdentity)); | 184 | put_ctx->path_info_len * sizeof(struct |
185 | GNUNET_DHT_PathElement)); | ||
185 | GNUNET_CONTAINER_heap_update_cost (val->hn, | 186 | GNUNET_CONTAINER_heap_update_cost (val->hn, |
186 | val->discard_time.abs_value_us); | 187 | val->discard_time.abs_value_us); |
187 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 188 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
@@ -219,7 +220,7 @@ heap_plugin_put (void *cls, | |||
219 | enum GNUNET_BLOCK_Type type, | 220 | enum GNUNET_BLOCK_Type type, |
220 | struct GNUNET_TIME_Absolute discard_time, | 221 | struct GNUNET_TIME_Absolute discard_time, |
221 | unsigned int path_info_len, | 222 | unsigned int path_info_len, |
222 | const struct GNUNET_PeerIdentity *path_info) | 223 | const struct GNUNET_DHT_PathElement *path_info) |
223 | { | 224 | { |
224 | struct Plugin *plugin = cls; | 225 | struct Plugin *plugin = cls; |
225 | struct Value *val; | 226 | struct Value *val; |
@@ -255,7 +256,7 @@ heap_plugin_put (void *cls, | |||
255 | path_info_len); | 256 | path_info_len); |
256 | GNUNET_memcpy (val->path_info, | 257 | GNUNET_memcpy (val->path_info, |
257 | path_info, | 258 | path_info, |
258 | path_info_len * sizeof(struct GNUNET_PeerIdentity)); | 259 | path_info_len * sizeof(struct GNUNET_DHT_PathElement)); |
259 | (void) GNUNET_CONTAINER_multihashmap_put (plugin->map, | 260 | (void) GNUNET_CONTAINER_multihashmap_put (plugin->map, |
260 | &val->key, | 261 | &val->key, |
261 | val, | 262 | val, |
diff --git a/src/datacache/plugin_datacache_postgres.c b/src/datacache/plugin_datacache_postgres.c index 070619137..6a44c44a5 100644 --- a/src/datacache/plugin_datacache_postgres.c +++ b/src/datacache/plugin_datacache_postgres.c | |||
@@ -156,7 +156,7 @@ postgres_plugin_put (void *cls, | |||
156 | enum GNUNET_BLOCK_Type type, | 156 | enum GNUNET_BLOCK_Type type, |
157 | struct GNUNET_TIME_Absolute discard_time, | 157 | struct GNUNET_TIME_Absolute discard_time, |
158 | unsigned int path_info_len, | 158 | unsigned int path_info_len, |
159 | const struct GNUNET_PeerIdentity *path_info) | 159 | const struct GNUNET_DHT_PathElement *path_info) |
160 | { | 160 | { |
161 | struct Plugin *plugin = cls; | 161 | struct Plugin *plugin = cls; |
162 | uint32_t type32 = (uint32_t) type; | 162 | uint32_t type32 = (uint32_t) type; |
@@ -168,7 +168,7 @@ postgres_plugin_put (void *cls, | |||
168 | GNUNET_PQ_query_param_fixed_size (data, data_size), | 168 | GNUNET_PQ_query_param_fixed_size (data, data_size), |
169 | GNUNET_PQ_query_param_fixed_size (path_info, | 169 | GNUNET_PQ_query_param_fixed_size (path_info, |
170 | path_info_len * sizeof(struct | 170 | path_info_len * sizeof(struct |
171 | GNUNET_PeerIdentity)), | 171 | GNUNET_DHT_PathElement)), |
172 | GNUNET_PQ_query_param_end | 172 | GNUNET_PQ_query_param_end |
173 | }; | 173 | }; |
174 | enum GNUNET_DB_QueryStatus ret; | 174 | enum GNUNET_DB_QueryStatus ret; |
@@ -227,7 +227,7 @@ handle_results (void *cls, | |||
227 | uint32_t type; | 227 | uint32_t type; |
228 | void *data; | 228 | void *data; |
229 | size_t data_size; | 229 | size_t data_size; |
230 | struct GNUNET_PeerIdentity *path; | 230 | struct GNUNET_DHT_PathElement *path; |
231 | size_t path_len; | 231 | size_t path_len; |
232 | struct GNUNET_PQ_ResultSpec rs[] = { | 232 | struct GNUNET_PQ_ResultSpec rs[] = { |
233 | GNUNET_PQ_result_spec_absolute_time ("discard_time", | 233 | GNUNET_PQ_result_spec_absolute_time ("discard_time", |
@@ -251,12 +251,12 @@ handle_results (void *cls, | |||
251 | GNUNET_break (0); | 251 | GNUNET_break (0); |
252 | return; | 252 | return; |
253 | } | 253 | } |
254 | if (0 != (path_len % sizeof(struct GNUNET_PeerIdentity))) | 254 | if (0 != (path_len % sizeof(struct GNUNET_DHT_PathElement))) |
255 | { | 255 | { |
256 | GNUNET_break (0); | 256 | GNUNET_break (0); |
257 | path_len = 0; | 257 | path_len = 0; |
258 | } | 258 | } |
259 | path_len %= sizeof(struct GNUNET_PeerIdentity); | 259 | path_len %= sizeof(struct GNUNET_DHT_PathElement); |
260 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 260 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
261 | "Found result of size %u bytes and type %u in database\n", | 261 | "Found result of size %u bytes and type %u in database\n", |
262 | (unsigned int) data_size, | 262 | (unsigned int) data_size, |
@@ -446,7 +446,7 @@ extract_result_cb (void *cls, | |||
446 | uint32_t type; | 446 | uint32_t type; |
447 | void *data; | 447 | void *data; |
448 | size_t data_size; | 448 | size_t data_size; |
449 | struct GNUNET_PeerIdentity *path; | 449 | struct GNUNET_DHT_PathElement *path; |
450 | size_t path_len; | 450 | size_t path_len; |
451 | struct GNUNET_HashCode key; | 451 | struct GNUNET_HashCode key; |
452 | struct GNUNET_PQ_ResultSpec rs[] = { | 452 | struct GNUNET_PQ_ResultSpec rs[] = { |
@@ -473,12 +473,12 @@ extract_result_cb (void *cls, | |||
473 | GNUNET_break (0); | 473 | GNUNET_break (0); |
474 | return; | 474 | return; |
475 | } | 475 | } |
476 | if (0 != (path_len % sizeof(struct GNUNET_PeerIdentity))) | 476 | if (0 != (path_len % sizeof(struct GNUNET_DHT_PathElement))) |
477 | { | 477 | { |
478 | GNUNET_break (0); | 478 | GNUNET_break (0); |
479 | path_len = 0; | 479 | path_len = 0; |
480 | } | 480 | } |
481 | path_len %= sizeof(struct GNUNET_PeerIdentity); | 481 | path_len %= sizeof(struct GNUNET_DHT_PathElement); |
482 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 482 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
483 | "Found result of size %u bytes and type %u in database\n", | 483 | "Found result of size %u bytes and type %u in database\n", |
484 | (unsigned int) data_size, | 484 | (unsigned int) data_size, |
diff --git a/src/datacache/plugin_datacache_sqlite.c b/src/datacache/plugin_datacache_sqlite.c index 0c894556b..d08b32caf 100644 --- a/src/datacache/plugin_datacache_sqlite.c +++ b/src/datacache/plugin_datacache_sqlite.c | |||
@@ -192,7 +192,7 @@ sqlite_plugin_put (void *cls, | |||
192 | enum GNUNET_BLOCK_Type type, | 192 | enum GNUNET_BLOCK_Type type, |
193 | struct GNUNET_TIME_Absolute discard_time, | 193 | struct GNUNET_TIME_Absolute discard_time, |
194 | unsigned int path_info_len, | 194 | unsigned int path_info_len, |
195 | const struct GNUNET_PeerIdentity *path_info) | 195 | const struct GNUNET_DHT_PathElement *path_info) |
196 | { | 196 | { |
197 | struct Plugin *plugin = cls; | 197 | struct Plugin *plugin = cls; |
198 | uint32_t type32 = type; | 198 | uint32_t type32 = type; |
@@ -204,7 +204,7 @@ sqlite_plugin_put (void *cls, | |||
204 | GNUNET_SQ_query_param_fixed_size (data, size), | 204 | GNUNET_SQ_query_param_fixed_size (data, size), |
205 | GNUNET_SQ_query_param_fixed_size (path_info, | 205 | GNUNET_SQ_query_param_fixed_size (path_info, |
206 | path_info_len | 206 | path_info_len |
207 | * sizeof(struct GNUNET_PeerIdentity)), | 207 | * sizeof(struct GNUNET_DHT_PathElement)), |
208 | GNUNET_SQ_query_param_end }; | 208 | GNUNET_SQ_query_param_end }; |
209 | 209 | ||
210 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 210 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
@@ -265,7 +265,7 @@ sqlite_plugin_get (void *cls, | |||
265 | uint32_t off; | 265 | uint32_t off; |
266 | unsigned int total; | 266 | unsigned int total; |
267 | size_t psize; | 267 | size_t psize; |
268 | struct GNUNET_PeerIdentity *path; | 268 | struct GNUNET_DHT_PathElement *path; |
269 | struct GNUNET_SQ_QueryParam params_count[] = | 269 | struct GNUNET_SQ_QueryParam params_count[] = |
270 | { GNUNET_SQ_query_param_auto_from_type (key), | 270 | { GNUNET_SQ_query_param_auto_from_type (key), |
271 | GNUNET_SQ_query_param_uint32 (&type32), | 271 | GNUNET_SQ_query_param_uint32 (&type32), |
@@ -339,13 +339,13 @@ sqlite_plugin_get (void *cls, | |||
339 | GNUNET_SQ_reset (plugin->dbh, plugin->get_stmt); | 339 | GNUNET_SQ_reset (plugin->dbh, plugin->get_stmt); |
340 | break; | 340 | break; |
341 | } | 341 | } |
342 | if (0 != psize % sizeof(struct GNUNET_PeerIdentity)) | 342 | if (0 != psize % sizeof(struct GNUNET_DHT_PathElement)) |
343 | { | 343 | { |
344 | GNUNET_break (0); | 344 | GNUNET_break (0); |
345 | psize = 0; | 345 | psize = 0; |
346 | path = NULL; | 346 | path = NULL; |
347 | } | 347 | } |
348 | psize /= sizeof(struct GNUNET_PeerIdentity); | 348 | psize /= sizeof(struct GNUNET_DHT_PathElement); |
349 | cnt++; | 349 | cnt++; |
350 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 350 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
351 | "Found %u-byte result when processing GET for key `%s'\n", | 351 | "Found %u-byte result when processing GET for key `%s'\n", |
@@ -476,7 +476,7 @@ sqlite_plugin_get_closest (void *cls, | |||
476 | size_t psize; | 476 | size_t psize; |
477 | uint32_t type; | 477 | uint32_t type; |
478 | struct GNUNET_HashCode hc; | 478 | struct GNUNET_HashCode hc; |
479 | struct GNUNET_PeerIdentity *path; | 479 | struct GNUNET_DHT_PathElement *path; |
480 | struct GNUNET_SQ_QueryParam params[] = | 480 | struct GNUNET_SQ_QueryParam params[] = |
481 | { GNUNET_SQ_query_param_auto_from_type (key), | 481 | { GNUNET_SQ_query_param_auto_from_type (key), |
482 | GNUNET_SQ_query_param_absolute_time (&now), | 482 | GNUNET_SQ_query_param_absolute_time (&now), |
@@ -510,13 +510,13 @@ sqlite_plugin_get_closest (void *cls, | |||
510 | GNUNET_break (0); | 510 | GNUNET_break (0); |
511 | break; | 511 | break; |
512 | } | 512 | } |
513 | if (0 != psize % sizeof(struct GNUNET_PeerIdentity)) | 513 | if (0 != psize % sizeof(struct GNUNET_DHT_PathElement)) |
514 | { | 514 | { |
515 | GNUNET_break (0); | 515 | GNUNET_break (0); |
516 | psize = 0; | 516 | psize = 0; |
517 | path = NULL; | 517 | path = NULL; |
518 | } | 518 | } |
519 | psize /= sizeof(struct GNUNET_PeerIdentity); | 519 | psize /= sizeof(struct GNUNET_DHT_PathElement); |
520 | cnt++; | 520 | cnt++; |
521 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 521 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
522 | "Found %u-byte result at %s when processing GET_CLOSE\n", | 522 | "Found %u-byte result at %s when processing GET_CLOSE\n", |
diff --git a/src/datacache/plugin_datacache_template.c b/src/datacache/plugin_datacache_template.c index 09279f55c..231413ce9 100644 --- a/src/datacache/plugin_datacache_template.c +++ b/src/datacache/plugin_datacache_template.c | |||
@@ -63,7 +63,7 @@ template_plugin_put (void *cls, | |||
63 | enum GNUNET_BLOCK_Type type, | 63 | enum GNUNET_BLOCK_Type type, |
64 | struct GNUNET_TIME_Absolute discard_time, | 64 | struct GNUNET_TIME_Absolute discard_time, |
65 | unsigned int path_info_len, | 65 | unsigned int path_info_len, |
66 | const struct GNUNET_PeerIdentity *path_info) | 66 | const struct GNUNET_DHT_PathElement *path_info) |
67 | { | 67 | { |
68 | GNUNET_break (0); | 68 | GNUNET_break (0); |
69 | return -1; | 69 | return -1; |
diff --git a/src/datacache/test_datacache.c b/src/datacache/test_datacache.c index 6f6e4eec1..5740d2b7d 100644 --- a/src/datacache/test_datacache.c +++ b/src/datacache/test_datacache.c | |||
@@ -46,7 +46,7 @@ checkIt (void *cls, | |||
46 | enum GNUNET_BLOCK_Type type, | 46 | enum GNUNET_BLOCK_Type type, |
47 | struct GNUNET_TIME_Absolute exp, | 47 | struct GNUNET_TIME_Absolute exp, |
48 | unsigned int path_len, | 48 | unsigned int path_len, |
49 | const struct GNUNET_PeerIdentity *path) | 49 | const struct GNUNET_DHT_PathElement *path) |
50 | { | 50 | { |
51 | (void) key; | 51 | (void) key; |
52 | (void) type; | 52 | (void) type; |
diff --git a/src/datacache/test_datacache_data_postgres.conf b/src/datacache/test_datacache_data_postgres.conf index 47c954b55..92313157c 100644 --- a/src/datacache/test_datacache_data_postgres.conf +++ b/src/datacache/test_datacache_data_postgres.conf | |||
@@ -4,6 +4,4 @@ QUOTA = 1 MB | |||
4 | DATABASE = postgres | 4 | DATABASE = postgres |
5 | 5 | ||
6 | [datacache-postgres] | 6 | [datacache-postgres] |
7 | CONFIG = connect_timeout=10; dbname=gnunetcheck | 7 | CONFIG = postgres:///gnunetcheck |
8 | |||
9 | |||
diff --git a/src/dht/dht_api.c b/src/dht/dht_api.c index 727f1a1f6..1ba2f7277 100644 --- a/src/dht/dht_api.c +++ b/src/dht/dht_api.c | |||
@@ -260,7 +260,7 @@ struct GNUNET_DHT_Handle | |||
260 | * @param h DHT handle to reconnect | 260 | * @param h DHT handle to reconnect |
261 | * @return #GNUNET_YES on success, #GNUNET_NO on failure. | 261 | * @return #GNUNET_YES on success, #GNUNET_NO on failure. |
262 | */ | 262 | */ |
263 | static int | 263 | static enum GNUNET_GenericReturnValue |
264 | try_connect (struct GNUNET_DHT_Handle *h); | 264 | try_connect (struct GNUNET_DHT_Handle *h); |
265 | 265 | ||
266 | 266 | ||
@@ -344,7 +344,7 @@ send_get_known_results (struct GNUNET_DHT_GetHandle *gh, | |||
344 | * @param value the `struct GNUNET_DHT_GetHandle *` | 344 | * @param value the `struct GNUNET_DHT_GetHandle *` |
345 | * @return #GNUNET_YES (always) | 345 | * @return #GNUNET_YES (always) |
346 | */ | 346 | */ |
347 | static int | 347 | static enum GNUNET_GenericReturnValue |
348 | add_get_request_to_pending (void *cls, | 348 | add_get_request_to_pending (void *cls, |
349 | const struct GNUNET_HashCode *key, | 349 | const struct GNUNET_HashCode *key, |
350 | void *value) | 350 | void *value) |
@@ -488,7 +488,7 @@ mq_error_handler (void *cls, | |||
488 | * @return #GNUNET_OK if everything went fine, | 488 | * @return #GNUNET_OK if everything went fine, |
489 | * #GNUNET_SYSERR if the message is malformed. | 489 | * #GNUNET_SYSERR if the message is malformed. |
490 | */ | 490 | */ |
491 | static int | 491 | static enum GNUNET_GenericReturnValue |
492 | check_monitor_get (void *cls, | 492 | check_monitor_get (void *cls, |
493 | const struct GNUNET_DHT_MonitorGetMessage *msg) | 493 | const struct GNUNET_DHT_MonitorGetMessage *msg) |
494 | { | 494 | { |
@@ -496,7 +496,7 @@ check_monitor_get (void *cls, | |||
496 | uint16_t msize = ntohs (msg->header.size) - sizeof(*msg); | 496 | uint16_t msize = ntohs (msg->header.size) - sizeof(*msg); |
497 | 497 | ||
498 | if ((plen > UINT16_MAX) || | 498 | if ((plen > UINT16_MAX) || |
499 | (plen * sizeof(struct GNUNET_PeerIdentity) != msize)) | 499 | (plen * sizeof(struct GNUNET_DHT_PathElement) != msize)) |
500 | { | 500 | { |
501 | GNUNET_break (0); | 501 | GNUNET_break (0); |
502 | return GNUNET_SYSERR; | 502 | return GNUNET_SYSERR; |
@@ -534,7 +534,7 @@ handle_monitor_get (void *cls, | |||
534 | ntohl (msg->hop_count), | 534 | ntohl (msg->hop_count), |
535 | ntohl (msg->desired_replication_level), | 535 | ntohl (msg->desired_replication_level), |
536 | ntohl (msg->get_path_length), | 536 | ntohl (msg->get_path_length), |
537 | (struct GNUNET_PeerIdentity *) &msg[1], | 537 | (struct GNUNET_DHT_PathElement *) &msg[1], |
538 | &msg->key); | 538 | &msg->key); |
539 | } | 539 | } |
540 | } | 540 | } |
@@ -548,7 +548,7 @@ handle_monitor_get (void *cls, | |||
548 | * @return #GNUNET_OK if everything went fine, | 548 | * @return #GNUNET_OK if everything went fine, |
549 | * #GNUNET_SYSERR if the message is malformed. | 549 | * #GNUNET_SYSERR if the message is malformed. |
550 | */ | 550 | */ |
551 | static int | 551 | static enum GNUNET_GenericReturnValue |
552 | check_monitor_get_resp (void *cls, | 552 | check_monitor_get_resp (void *cls, |
553 | const struct GNUNET_DHT_MonitorGetRespMessage *msg) | 553 | const struct GNUNET_DHT_MonitorGetRespMessage *msg) |
554 | { | 554 | { |
@@ -557,7 +557,7 @@ check_monitor_get_resp (void *cls, | |||
557 | uint32_t putl = ntohl (msg->put_path_length); | 557 | uint32_t putl = ntohl (msg->put_path_length); |
558 | 558 | ||
559 | if ((getl + putl < getl) || | 559 | if ((getl + putl < getl) || |
560 | ((msize / sizeof(struct GNUNET_PeerIdentity)) < getl + putl)) | 560 | ((msize / sizeof(struct GNUNET_DHT_PathElement)) < getl + putl)) |
561 | { | 561 | { |
562 | GNUNET_break (0); | 562 | GNUNET_break (0); |
563 | return GNUNET_SYSERR; | 563 | return GNUNET_SYSERR; |
@@ -578,12 +578,12 @@ handle_monitor_get_resp (void *cls, | |||
578 | { | 578 | { |
579 | struct GNUNET_DHT_Handle *handle = cls; | 579 | struct GNUNET_DHT_Handle *handle = cls; |
580 | size_t msize = ntohs (msg->header.size) - sizeof(*msg); | 580 | size_t msize = ntohs (msg->header.size) - sizeof(*msg); |
581 | const struct GNUNET_PeerIdentity *path; | 581 | const struct GNUNET_DHT_PathElement *path; |
582 | uint32_t getl = ntohl (msg->get_path_length); | 582 | uint32_t getl = ntohl (msg->get_path_length); |
583 | uint32_t putl = ntohl (msg->put_path_length); | 583 | uint32_t putl = ntohl (msg->put_path_length); |
584 | struct GNUNET_DHT_MonitorHandle *mh; | 584 | struct GNUNET_DHT_MonitorHandle *mh; |
585 | 585 | ||
586 | path = (const struct GNUNET_PeerIdentity *) &msg[1]; | 586 | path = (const struct GNUNET_DHT_PathElement *) &msg[1]; |
587 | for (mh = handle->monitor_head; NULL != mh; mh = mh->next) | 587 | for (mh = handle->monitor_head; NULL != mh; mh = mh->next) |
588 | { | 588 | { |
589 | if (NULL == mh->get_resp_cb) | 589 | if (NULL == mh->get_resp_cb) |
@@ -603,8 +603,8 @@ handle_monitor_get_resp (void *cls, | |||
603 | GNUNET_TIME_absolute_ntoh (msg->expiration_time), | 603 | GNUNET_TIME_absolute_ntoh (msg->expiration_time), |
604 | &msg->key, | 604 | &msg->key, |
605 | (const void *) &path[getl + putl], | 605 | (const void *) &path[getl + putl], |
606 | msize - sizeof(struct GNUNET_PeerIdentity) * (putl | 606 | msize - sizeof(struct GNUNET_DHT_PathElement) * (putl |
607 | + getl)); | 607 | + getl)); |
608 | } | 608 | } |
609 | } | 609 | } |
610 | 610 | ||
@@ -617,7 +617,7 @@ handle_monitor_get_resp (void *cls, | |||
617 | * @return #GNUNET_OK if everything went fine, | 617 | * @return #GNUNET_OK if everything went fine, |
618 | * #GNUNET_SYSERR if the message is malformed. | 618 | * #GNUNET_SYSERR if the message is malformed. |
619 | */ | 619 | */ |
620 | static int | 620 | static enum GNUNET_GenericReturnValue |
621 | check_monitor_put (void *cls, | 621 | check_monitor_put (void *cls, |
622 | const struct GNUNET_DHT_MonitorPutMessage *msg) | 622 | const struct GNUNET_DHT_MonitorPutMessage *msg) |
623 | { | 623 | { |
@@ -626,7 +626,7 @@ check_monitor_put (void *cls, | |||
626 | 626 | ||
627 | msize = ntohs (msg->header.size) - sizeof(*msg); | 627 | msize = ntohs (msg->header.size) - sizeof(*msg); |
628 | putl = ntohl (msg->put_path_length); | 628 | putl = ntohl (msg->put_path_length); |
629 | if ((msize / sizeof(struct GNUNET_PeerIdentity)) < putl) | 629 | if ((msize / sizeof(struct GNUNET_DHT_PathElement)) < putl) |
630 | { | 630 | { |
631 | GNUNET_break (0); | 631 | GNUNET_break (0); |
632 | return GNUNET_SYSERR; | 632 | return GNUNET_SYSERR; |
@@ -648,10 +648,10 @@ handle_monitor_put (void *cls, | |||
648 | struct GNUNET_DHT_Handle *handle = cls; | 648 | struct GNUNET_DHT_Handle *handle = cls; |
649 | size_t msize = ntohs (msg->header.size) - sizeof(*msg); | 649 | size_t msize = ntohs (msg->header.size) - sizeof(*msg); |
650 | uint32_t putl = ntohl (msg->put_path_length); | 650 | uint32_t putl = ntohl (msg->put_path_length); |
651 | const struct GNUNET_PeerIdentity *path; | 651 | const struct GNUNET_DHT_PathElement *path; |
652 | struct GNUNET_DHT_MonitorHandle *mh; | 652 | struct GNUNET_DHT_MonitorHandle *mh; |
653 | 653 | ||
654 | path = (const struct GNUNET_PeerIdentity *) &msg[1]; | 654 | path = (const struct GNUNET_DHT_PathElement *) &msg[1]; |
655 | for (mh = handle->monitor_head; NULL != mh; mh = mh->next) | 655 | for (mh = handle->monitor_head; NULL != mh; mh = mh->next) |
656 | { | 656 | { |
657 | if (NULL == mh->put_cb) | 657 | if (NULL == mh->put_cb) |
@@ -672,7 +672,7 @@ handle_monitor_put (void *cls, | |||
672 | GNUNET_TIME_absolute_ntoh (msg->expiration_time), | 672 | GNUNET_TIME_absolute_ntoh (msg->expiration_time), |
673 | &msg->key, | 673 | &msg->key, |
674 | (const void *) &path[putl], | 674 | (const void *) &path[putl], |
675 | msize - sizeof(struct GNUNET_PeerIdentity) * putl); | 675 | msize - sizeof(struct GNUNET_DHT_PathElement) * putl); |
676 | } | 676 | } |
677 | } | 677 | } |
678 | 678 | ||
@@ -685,7 +685,7 @@ handle_monitor_put (void *cls, | |||
685 | * @return #GNUNET_OK if everything went fine, | 685 | * @return #GNUNET_OK if everything went fine, |
686 | * #GNUNET_SYSERR if the message is malformed. | 686 | * #GNUNET_SYSERR if the message is malformed. |
687 | */ | 687 | */ |
688 | static int | 688 | static enum GNUNET_GenericReturnValue |
689 | check_client_result (void *cls, | 689 | check_client_result (void *cls, |
690 | const struct GNUNET_DHT_ClientResultMessage *msg) | 690 | const struct GNUNET_DHT_ClientResultMessage *msg) |
691 | { | 691 | { |
@@ -695,12 +695,12 @@ check_client_result (void *cls, | |||
695 | size_t meta_length; | 695 | size_t meta_length; |
696 | 696 | ||
697 | meta_length = | 697 | meta_length = |
698 | sizeof(struct GNUNET_PeerIdentity) * (get_path_length + put_path_length); | 698 | sizeof(struct GNUNET_DHT_PathElement) * (get_path_length + put_path_length); |
699 | if ((msize < meta_length) || | 699 | if ((msize < meta_length) || |
700 | (get_path_length > | 700 | (get_path_length > |
701 | GNUNET_MAX_MESSAGE_SIZE / sizeof(struct GNUNET_PeerIdentity)) || | 701 | GNUNET_MAX_MESSAGE_SIZE / sizeof(struct GNUNET_DHT_PathElement)) || |
702 | (put_path_length > | 702 | (put_path_length > |
703 | GNUNET_MAX_MESSAGE_SIZE / sizeof(struct GNUNET_PeerIdentity))) | 703 | GNUNET_MAX_MESSAGE_SIZE / sizeof(struct GNUNET_DHT_PathElement))) |
704 | { | 704 | { |
705 | GNUNET_break (0); | 705 | GNUNET_break (0); |
706 | return GNUNET_SYSERR; | 706 | return GNUNET_SYSERR; |
@@ -717,7 +717,7 @@ check_client_result (void *cls, | |||
717 | * @param value the `struct GNUNET_DHT_GetHandle` of a request matching the same key | 717 | * @param value the `struct GNUNET_DHT_GetHandle` of a request matching the same key |
718 | * @return #GNUNET_YES to continue to iterate over all results | 718 | * @return #GNUNET_YES to continue to iterate over all results |
719 | */ | 719 | */ |
720 | static int | 720 | static enum GNUNET_GenericReturnValue |
721 | process_client_result (void *cls, | 721 | process_client_result (void *cls, |
722 | const struct GNUNET_HashCode *key, | 722 | const struct GNUNET_HashCode *key, |
723 | void *value) | 723 | void *value) |
@@ -727,8 +727,8 @@ process_client_result (void *cls, | |||
727 | size_t msize = ntohs (crm->header.size) - sizeof(*crm); | 727 | size_t msize = ntohs (crm->header.size) - sizeof(*crm); |
728 | uint32_t put_path_length = ntohl (crm->put_path_length); | 728 | uint32_t put_path_length = ntohl (crm->put_path_length); |
729 | uint32_t get_path_length = ntohl (crm->get_path_length); | 729 | uint32_t get_path_length = ntohl (crm->get_path_length); |
730 | const struct GNUNET_PeerIdentity *put_path; | 730 | const struct GNUNET_DHT_PathElement *put_path; |
731 | const struct GNUNET_PeerIdentity *get_path; | 731 | const struct GNUNET_DHT_PathElement *get_path; |
732 | struct GNUNET_HashCode hc; | 732 | struct GNUNET_HashCode hc; |
733 | size_t data_length; | 733 | size_t data_length; |
734 | size_t meta_length; | 734 | size_t meta_length; |
@@ -746,18 +746,18 @@ process_client_result (void *cls, | |||
746 | } | 746 | } |
747 | /* FIXME: might want to check that type matches */ | 747 | /* FIXME: might want to check that type matches */ |
748 | meta_length = | 748 | meta_length = |
749 | sizeof(struct GNUNET_PeerIdentity) * (get_path_length + put_path_length); | 749 | sizeof(struct GNUNET_DHT_PathElement) * (get_path_length + put_path_length); |
750 | data_length = msize - meta_length; | 750 | data_length = msize - meta_length; |
751 | put_path = (const struct GNUNET_PeerIdentity *) &crm[1]; | 751 | put_path = (const struct GNUNET_DHT_PathElement *) &crm[1]; |
752 | get_path = &put_path[put_path_length]; | 752 | get_path = &put_path[put_path_length]; |
753 | { | 753 | { |
754 | char *pp; | 754 | char *pp; |
755 | char *gp; | 755 | char *gp; |
756 | 756 | ||
757 | gp = GNUNET_STRINGS_pp2s (get_path, | 757 | gp = GNUNET_DHT_pp2s (get_path, |
758 | get_path_length); | 758 | get_path_length); |
759 | pp = GNUNET_STRINGS_pp2s (put_path, | 759 | pp = GNUNET_DHT_pp2s (put_path, |
760 | put_path_length); | 760 | put_path_length); |
761 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 761 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
762 | "Giving %u byte reply for %s to application (GP: %s, PP: %s)\n", | 762 | "Giving %u byte reply for %s to application (GP: %s, PP: %s)\n", |
763 | (unsigned int) data_length, | 763 | (unsigned int) data_length, |
@@ -838,7 +838,7 @@ handle_put_cont (void *cls) | |||
838 | * @param h DHT handle to reconnect | 838 | * @param h DHT handle to reconnect |
839 | * @return #GNUNET_YES on success, #GNUNET_NO on failure. | 839 | * @return #GNUNET_YES on success, #GNUNET_NO on failure. |
840 | */ | 840 | */ |
841 | static int | 841 | static enum GNUNET_GenericReturnValue |
842 | try_connect (struct GNUNET_DHT_Handle *h) | 842 | try_connect (struct GNUNET_DHT_Handle *h) |
843 | { | 843 | { |
844 | struct GNUNET_MQ_MessageHandler handlers[] = { | 844 | struct GNUNET_MQ_MessageHandler handlers[] = { |
@@ -878,14 +878,6 @@ try_connect (struct GNUNET_DHT_Handle *h) | |||
878 | } | 878 | } |
879 | 879 | ||
880 | 880 | ||
881 | /** | ||
882 | * Initialize the connection with the DHT service. | ||
883 | * | ||
884 | * @param cfg configuration to use | ||
885 | * @param ht_len size of the internal hash table to use for | ||
886 | * processing multiple GET/FIND requests in parallel | ||
887 | * @return handle to the DHT service, or NULL on error | ||
888 | */ | ||
889 | struct GNUNET_DHT_Handle * | 881 | struct GNUNET_DHT_Handle * |
890 | GNUNET_DHT_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, | 882 | GNUNET_DHT_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, |
891 | unsigned int ht_len) | 883 | unsigned int ht_len) |
@@ -909,11 +901,6 @@ GNUNET_DHT_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
909 | } | 901 | } |
910 | 902 | ||
911 | 903 | ||
912 | /** | ||
913 | * Shutdown connection with the DHT service. | ||
914 | * | ||
915 | * @param handle handle of the DHT connection to stop | ||
916 | */ | ||
917 | void | 904 | void |
918 | GNUNET_DHT_disconnect (struct GNUNET_DHT_Handle *handle) | 905 | GNUNET_DHT_disconnect (struct GNUNET_DHT_Handle *handle) |
919 | { | 906 | { |
@@ -942,26 +929,6 @@ GNUNET_DHT_disconnect (struct GNUNET_DHT_Handle *handle) | |||
942 | } | 929 | } |
943 | 930 | ||
944 | 931 | ||
945 | /** | ||
946 | * Perform a PUT operation storing data in the DHT. FIXME: we should | ||
947 | * change the protocol to get a confirmation for the PUT from the DHT | ||
948 | * and call 'cont' only after getting the confirmation; otherwise, the | ||
949 | * client has no good way of telling if the 'PUT' message actually got | ||
950 | * to the DHT service! | ||
951 | * | ||
952 | * @param handle handle to DHT service | ||
953 | * @param key the key to store under | ||
954 | * @param desired_replication_level estimate of how many | ||
955 | * nearest peers this request should reach | ||
956 | * @param options routing options for this message | ||
957 | * @param type type of the value | ||
958 | * @param size number of bytes in data; must be less than 64k | ||
959 | * @param data the data to store | ||
960 | * @param exp desired expiration time for the value | ||
961 | * @param cont continuation to call when done (transmitting request to service) | ||
962 | * You must not call #GNUNET_DHT_disconnect in this continuation | ||
963 | * @param cont_cls closure for @a cont | ||
964 | */ | ||
965 | struct GNUNET_DHT_PutHandle * | 932 | struct GNUNET_DHT_PutHandle * |
966 | GNUNET_DHT_put (struct GNUNET_DHT_Handle *handle, | 933 | GNUNET_DHT_put (struct GNUNET_DHT_Handle *handle, |
967 | const struct GNUNET_HashCode *key, | 934 | const struct GNUNET_HashCode *key, |
@@ -1020,17 +987,6 @@ GNUNET_DHT_put (struct GNUNET_DHT_Handle *handle, | |||
1020 | } | 987 | } |
1021 | 988 | ||
1022 | 989 | ||
1023 | /** | ||
1024 | * Cancels a DHT PUT operation. Note that the PUT request may still | ||
1025 | * go out over the network (we can't stop that); However, if the PUT | ||
1026 | * has not yet been sent to the service, cancelling the PUT will stop | ||
1027 | * this from happening (but there is no way for the user of this API | ||
1028 | * to tell if that is the case). The only use for this API is to | ||
1029 | * prevent a later call to 'cont' from #GNUNET_DHT_put (e.g. because | ||
1030 | * the system is shutting down). | ||
1031 | * | ||
1032 | * @param ph put operation to cancel ('cont' will no longer be called) | ||
1033 | */ | ||
1034 | void | 990 | void |
1035 | GNUNET_DHT_put_cancel (struct GNUNET_DHT_PutHandle *ph) | 991 | GNUNET_DHT_put_cancel (struct GNUNET_DHT_PutHandle *ph) |
1036 | { | 992 | { |
@@ -1047,21 +1003,6 @@ GNUNET_DHT_put_cancel (struct GNUNET_DHT_PutHandle *ph) | |||
1047 | } | 1003 | } |
1048 | 1004 | ||
1049 | 1005 | ||
1050 | /** | ||
1051 | * Perform an asynchronous GET operation on the DHT identified. | ||
1052 | * | ||
1053 | * @param handle handle to the DHT service | ||
1054 | * @param type expected type of the response object | ||
1055 | * @param key the key to look up | ||
1056 | * @param desired_replication_level estimate of how many | ||
1057 | nearest peers this request should reach | ||
1058 | * @param options routing options for this message | ||
1059 | * @param xquery extended query data (can be NULL, depending on type) | ||
1060 | * @param xquery_size number of bytes in @a xquery | ||
1061 | * @param iter function to call on each result | ||
1062 | * @param iter_cls closure for @a iter | ||
1063 | * @return handle to stop the async get | ||
1064 | */ | ||
1065 | struct GNUNET_DHT_GetHandle * | 1006 | struct GNUNET_DHT_GetHandle * |
1066 | GNUNET_DHT_get_start (struct GNUNET_DHT_Handle *handle, | 1007 | GNUNET_DHT_get_start (struct GNUNET_DHT_Handle *handle, |
1067 | enum GNUNET_BLOCK_Type type, | 1008 | enum GNUNET_BLOCK_Type type, |
@@ -1111,16 +1052,6 @@ GNUNET_DHT_get_start (struct GNUNET_DHT_Handle *handle, | |||
1111 | } | 1052 | } |
1112 | 1053 | ||
1113 | 1054 | ||
1114 | /** | ||
1115 | * Tell the DHT not to return any of the following known results | ||
1116 | * to this client. | ||
1117 | * | ||
1118 | * @param get_handle get operation for which results should be filtered | ||
1119 | * @param num_results number of results to be blocked that are | ||
1120 | * provided in this call (size of the @a results array) | ||
1121 | * @param results array of hash codes over the 'data' of the results | ||
1122 | * to be blocked | ||
1123 | */ | ||
1124 | void | 1055 | void |
1125 | GNUNET_DHT_get_filter_known_results (struct GNUNET_DHT_GetHandle *get_handle, | 1056 | GNUNET_DHT_get_filter_known_results (struct GNUNET_DHT_GetHandle *get_handle, |
1126 | unsigned int num_results, | 1057 | unsigned int num_results, |
@@ -1145,11 +1076,6 @@ GNUNET_DHT_get_filter_known_results (struct GNUNET_DHT_GetHandle *get_handle, | |||
1145 | } | 1076 | } |
1146 | 1077 | ||
1147 | 1078 | ||
1148 | /** | ||
1149 | * Stop async DHT-get. | ||
1150 | * | ||
1151 | * @param get_handle handle to the GET operation to stop | ||
1152 | */ | ||
1153 | void | 1079 | void |
1154 | GNUNET_DHT_get_stop (struct GNUNET_DHT_GetHandle *get_handle) | 1080 | GNUNET_DHT_get_stop (struct GNUNET_DHT_GetHandle *get_handle) |
1155 | { | 1081 | { |
@@ -1183,18 +1109,6 @@ GNUNET_DHT_get_stop (struct GNUNET_DHT_GetHandle *get_handle) | |||
1183 | } | 1109 | } |
1184 | 1110 | ||
1185 | 1111 | ||
1186 | /** | ||
1187 | * Start monitoring the local DHT service. | ||
1188 | * | ||
1189 | * @param handle Handle to the DHT service. | ||
1190 | * @param type Type of blocks that are of interest. | ||
1191 | * @param key Key of data of interest, NULL for all. | ||
1192 | * @param get_cb Callback to process monitored get messages. | ||
1193 | * @param get_resp_cb Callback to process monitored get response messages. | ||
1194 | * @param put_cb Callback to process monitored put messages. | ||
1195 | * @param cb_cls Closure for callbacks. | ||
1196 | * @return Handle to stop monitoring. | ||
1197 | */ | ||
1198 | struct GNUNET_DHT_MonitorHandle * | 1112 | struct GNUNET_DHT_MonitorHandle * |
1199 | GNUNET_DHT_monitor_start (struct GNUNET_DHT_Handle *handle, | 1113 | GNUNET_DHT_monitor_start (struct GNUNET_DHT_Handle *handle, |
1200 | enum GNUNET_BLOCK_Type type, | 1114 | enum GNUNET_BLOCK_Type type, |
@@ -1227,13 +1141,6 @@ GNUNET_DHT_monitor_start (struct GNUNET_DHT_Handle *handle, | |||
1227 | } | 1141 | } |
1228 | 1142 | ||
1229 | 1143 | ||
1230 | /** | ||
1231 | * Stop monitoring. | ||
1232 | * | ||
1233 | * @param mh The handle to the monitor request returned by monitor_start. | ||
1234 | * | ||
1235 | * On return get_handle will no longer be valid, caller must not use again!!! | ||
1236 | */ | ||
1237 | void | 1144 | void |
1238 | GNUNET_DHT_monitor_stop (struct GNUNET_DHT_MonitorHandle *mh) | 1145 | GNUNET_DHT_monitor_stop (struct GNUNET_DHT_MonitorHandle *mh) |
1239 | { | 1146 | { |
@@ -1262,4 +1169,28 @@ GNUNET_DHT_monitor_stop (struct GNUNET_DHT_MonitorHandle *mh) | |||
1262 | } | 1169 | } |
1263 | 1170 | ||
1264 | 1171 | ||
1172 | char * | ||
1173 | GNUNET_DHT_pp2s (const struct GNUNET_DHT_PathElement *path, | ||
1174 | unsigned int path_len) | ||
1175 | { | ||
1176 | char *buf; | ||
1177 | size_t off; | ||
1178 | size_t plen = path_len * 5 + 1; | ||
1179 | |||
1180 | GNUNET_assert (path_len < UINT32_MAX / 5); | ||
1181 | off = 0; | ||
1182 | buf = GNUNET_malloc (plen); | ||
1183 | for (unsigned int i = 0; i < path_len; i++) | ||
1184 | { | ||
1185 | off += GNUNET_snprintf (&buf[off], | ||
1186 | plen - off, | ||
1187 | "%s%s", | ||
1188 | GNUNET_i2s (&path[i].pred), | ||
1189 | (i == path_len - 1) ? "" : "-"); | ||
1190 | } | ||
1191 | return buf; | ||
1192 | |||
1193 | } | ||
1194 | |||
1195 | |||
1265 | /* end of dht_api.c */ | 1196 | /* end of dht_api.c */ |
diff --git a/src/dht/gnunet-dht-get.c b/src/dht/gnunet-dht-get.c index c8a1cb735..f1076490b 100644 --- a/src/dht/gnunet-dht-get.c +++ b/src/dht/gnunet-dht-get.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | Copyright (C) 2001, 2002, 2004, 2005, 2006, 2007, 2009 GNUnet e.V. | 3 | Copyright (C) 2001, 2002, 2004, 2005, 2006, 2007, 2009, 2022 GNUnet e.V. |
4 | 4 | ||
5 | GNUnet is free software: you can redistribute it and/or modify it | 5 | GNUnet is free software: you can redistribute it and/or modify it |
6 | under the terms of the GNU Affero General Public License as published | 6 | under the terms of the GNU Affero General Public License as published |
@@ -146,16 +146,17 @@ static void | |||
146 | get_result_iterator (void *cls, | 146 | get_result_iterator (void *cls, |
147 | struct GNUNET_TIME_Absolute exp, | 147 | struct GNUNET_TIME_Absolute exp, |
148 | const struct GNUNET_HashCode *key, | 148 | const struct GNUNET_HashCode *key, |
149 | const struct GNUNET_PeerIdentity *get_path, | 149 | const struct GNUNET_DHT_PathElement *get_path, |
150 | unsigned int get_path_length, | 150 | unsigned int get_path_length, |
151 | const struct GNUNET_PeerIdentity *put_path, | 151 | const struct GNUNET_DHT_PathElement *put_path, |
152 | unsigned int put_path_length, | 152 | unsigned int put_path_length, |
153 | enum GNUNET_BLOCK_Type type, | 153 | enum GNUNET_BLOCK_Type type, |
154 | size_t size, | 154 | size_t size, |
155 | const void *data) | 155 | const void *data) |
156 | { | 156 | { |
157 | fprintf (stdout, | 157 | fprintf (stdout, |
158 | (GNUNET_BLOCK_TYPE_TEST == type) ? _ ("Result %d, type %d:\n%.*s\n") | 158 | (GNUNET_BLOCK_TYPE_TEST == type) |
159 | ? _ ("Result %d, type %d:\n%.*s\n") | ||
159 | : _ ("Result %d, type %d:\n"), | 160 | : _ ("Result %d, type %d:\n"), |
160 | result_count, | 161 | result_count, |
161 | type, | 162 | type, |
@@ -163,13 +164,22 @@ get_result_iterator (void *cls, | |||
163 | (char *) data); | 164 | (char *) data); |
164 | if (verbose) | 165 | if (verbose) |
165 | { | 166 | { |
166 | fprintf (stdout, " GET path: "); | 167 | fprintf (stdout, |
168 | " GET path: "); | ||
167 | for (unsigned int i = 0; i < get_path_length; i++) | 169 | for (unsigned int i = 0; i < get_path_length; i++) |
168 | fprintf (stdout, "%s%s", (0 == i) ? "" : "-", GNUNET_i2s (&get_path[i])); | 170 | fprintf (stdout, |
169 | fprintf (stdout, "\n PUT path: "); | 171 | "%s%s", |
172 | (0 == i) ? "" : "-", | ||
173 | GNUNET_i2s (&get_path[i].pred)); | ||
174 | fprintf (stdout, | ||
175 | "\n PUT path: "); | ||
170 | for (unsigned int i = 0; i < put_path_length; i++) | 176 | for (unsigned int i = 0; i < put_path_length; i++) |
171 | fprintf (stdout, "%s%s", (0 == i) ? "" : "-", GNUNET_i2s (&put_path[i])); | 177 | fprintf (stdout, |
172 | fprintf (stdout, "\n"); | 178 | "%s%s", |
179 | (0 == i) ? "" : "-", | ||
180 | GNUNET_i2s (&put_path[i].pred)); | ||
181 | fprintf (stdout, | ||
182 | "\n"); | ||
173 | } | 183 | } |
174 | result_count++; | 184 | result_count++; |
175 | } | 185 | } |
@@ -194,13 +204,17 @@ run (void *cls, | |||
194 | cfg = c; | 204 | cfg = c; |
195 | if (NULL == query_key) | 205 | if (NULL == query_key) |
196 | { | 206 | { |
197 | fprintf (stderr, "%s", _ ("Must provide key for DHT GET!\n")); | 207 | fprintf (stderr, |
208 | "%s", | ||
209 | _ ("Must provide key for DHT GET!\n")); | ||
198 | ret = 1; | 210 | ret = 1; |
199 | return; | 211 | return; |
200 | } | 212 | } |
201 | if (NULL == (dht_handle = GNUNET_DHT_connect (cfg, 1))) | 213 | if (NULL == (dht_handle = GNUNET_DHT_connect (cfg, 1))) |
202 | { | 214 | { |
203 | fprintf (stderr, "%s", _ ("Failed to connect to DHT service!\n")); | 215 | fprintf (stderr, |
216 | "%s", | ||
217 | _ ("Failed to connect to DHT service!\n")); | ||
204 | ret = 1; | 218 | ret = 1; |
205 | return; | 219 | return; |
206 | } | 220 | } |
@@ -238,39 +252,45 @@ run (void *cls, | |||
238 | int | 252 | int |
239 | main (int argc, char *const *argv) | 253 | main (int argc, char *const *argv) |
240 | { | 254 | { |
241 | struct GNUNET_GETOPT_CommandLineOption options[] = | 255 | struct GNUNET_GETOPT_CommandLineOption options[] = { |
242 | { GNUNET_GETOPT_option_string ('k', | 256 | GNUNET_GETOPT_option_string ( |
243 | "key", | 257 | 'k', |
244 | "KEY", | 258 | "key", |
245 | gettext_noop ("the query key"), | 259 | "KEY", |
246 | &query_key), | 260 | gettext_noop ("the query key"), |
261 | &query_key), | ||
247 | GNUNET_GETOPT_option_uint ( | 262 | GNUNET_GETOPT_option_uint ( |
248 | 'r', | 263 | 'r', |
249 | "replication", | 264 | "replication", |
250 | "LEVEL", | 265 | "LEVEL", |
251 | gettext_noop ("how many parallel requests (replicas) to create"), | 266 | gettext_noop ("how many parallel requests (replicas) to create"), |
252 | &replication), | 267 | &replication), |
253 | GNUNET_GETOPT_option_uint ('t', | 268 | GNUNET_GETOPT_option_uint ( |
254 | "type", | 269 | 't', |
255 | "TYPE", | 270 | "type", |
256 | gettext_noop ("the type of data to look for"), | 271 | "TYPE", |
257 | &query_type), | 272 | gettext_noop ("the type of data to look for"), |
273 | &query_type), | ||
258 | GNUNET_GETOPT_option_relative_time ( | 274 | GNUNET_GETOPT_option_relative_time ( |
259 | 'T', | 275 | 'T', |
260 | "timeout", | 276 | "timeout", |
261 | "TIMEOUT", | 277 | "TIMEOUT", |
262 | gettext_noop ("how long to execute this query before giving up?"), | 278 | gettext_noop ("how long to execute this query before giving up?"), |
263 | &timeout_request), | 279 | &timeout_request), |
264 | GNUNET_GETOPT_option_flag ('x', | 280 | GNUNET_GETOPT_option_flag ( |
265 | "demultiplex", | 281 | 'x', |
266 | gettext_noop ( | 282 | "demultiplex", |
267 | "use DHT's demultiplex everywhere option"), | 283 | gettext_noop ( |
268 | &demultixplex_everywhere), | 284 | "use DHT's demultiplex everywhere option"), |
285 | &demultixplex_everywhere), | ||
269 | GNUNET_GETOPT_option_verbose (&verbose), | 286 | GNUNET_GETOPT_option_verbose (&verbose), |
270 | GNUNET_GETOPT_OPTION_END }; | 287 | GNUNET_GETOPT_OPTION_END |
288 | }; | ||
271 | 289 | ||
272 | 290 | ||
273 | if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv)) | 291 | if (GNUNET_OK != |
292 | GNUNET_STRINGS_get_utf8_args (argc, argv, | ||
293 | &argc, &argv)) | ||
274 | return 2; | 294 | return 2; |
275 | return (GNUNET_OK == | 295 | return (GNUNET_OK == |
276 | GNUNET_PROGRAM_run ( | 296 | GNUNET_PROGRAM_run ( |
diff --git a/src/dht/gnunet-dht-monitor.c b/src/dht/gnunet-dht-monitor.c index 8dc14e223..b4ec497e4 100644 --- a/src/dht/gnunet-dht-monitor.c +++ b/src/dht/gnunet-dht-monitor.c | |||
@@ -137,7 +137,7 @@ get_callback (void *cls, | |||
137 | uint32_t hop_count, | 137 | uint32_t hop_count, |
138 | uint32_t desired_replication_level, | 138 | uint32_t desired_replication_level, |
139 | unsigned int path_length, | 139 | unsigned int path_length, |
140 | const struct GNUNET_PeerIdentity *path, | 140 | const struct GNUNET_DHT_PathElement *path, |
141 | const struct GNUNET_HashCode *key) | 141 | const struct GNUNET_HashCode *key) |
142 | { | 142 | { |
143 | fprintf (stdout, | 143 | fprintf (stdout, |
@@ -166,9 +166,9 @@ get_callback (void *cls, | |||
166 | static void | 166 | static void |
167 | get_resp_callback (void *cls, | 167 | get_resp_callback (void *cls, |
168 | enum GNUNET_BLOCK_Type type, | 168 | enum GNUNET_BLOCK_Type type, |
169 | const struct GNUNET_PeerIdentity *get_path, | 169 | const struct GNUNET_DHT_PathElement *get_path, |
170 | unsigned int get_path_length, | 170 | unsigned int get_path_length, |
171 | const struct GNUNET_PeerIdentity *put_path, | 171 | const struct GNUNET_DHT_PathElement *put_path, |
172 | unsigned int put_path_length, | 172 | unsigned int put_path_length, |
173 | struct GNUNET_TIME_Absolute exp, | 173 | struct GNUNET_TIME_Absolute exp, |
174 | const struct GNUNET_HashCode *key, | 174 | const struct GNUNET_HashCode *key, |
@@ -211,7 +211,7 @@ put_callback (void *cls, | |||
211 | uint32_t hop_count, | 211 | uint32_t hop_count, |
212 | uint32_t desired_replication_level, | 212 | uint32_t desired_replication_level, |
213 | unsigned int path_length, | 213 | unsigned int path_length, |
214 | const struct GNUNET_PeerIdentity *path, | 214 | const struct GNUNET_DHT_PathElement *path, |
215 | struct GNUNET_TIME_Absolute exp, | 215 | struct GNUNET_TIME_Absolute exp, |
216 | const struct GNUNET_HashCode *key, | 216 | const struct GNUNET_HashCode *key, |
217 | const void *data, | 217 | const void *data, |
diff --git a/src/dht/gnunet-dht-put.c b/src/dht/gnunet-dht-put.c index 7ee4ec185..531107ef2 100644 --- a/src/dht/gnunet-dht-put.c +++ b/src/dht/gnunet-dht-put.c | |||
@@ -179,48 +179,57 @@ run (void *cls, | |||
179 | int | 179 | int |
180 | main (int argc, char *const *argv) | 180 | main (int argc, char *const *argv) |
181 | { | 181 | { |
182 | struct GNUNET_GETOPT_CommandLineOption options[] = | 182 | struct GNUNET_GETOPT_CommandLineOption options[] = { |
183 | { GNUNET_GETOPT_option_string ('d', | 183 | GNUNET_GETOPT_option_string ( |
184 | "data", | 184 | 'd', |
185 | "DATA", | 185 | "data", |
186 | gettext_noop ( | 186 | "DATA", |
187 | "the data to insert under the key"), | 187 | gettext_noop ( |
188 | &data), | 188 | "the data to insert under the key"), |
189 | &data), | ||
189 | GNUNET_GETOPT_option_relative_time ( | 190 | GNUNET_GETOPT_option_relative_time ( |
190 | 'e', | 191 | 'e', |
191 | "expiration", | 192 | "expiration", |
192 | "EXPIRATION", | 193 | "EXPIRATION", |
193 | gettext_noop ("how long to store this entry in the dht (in seconds)"), | 194 | gettext_noop ("how long to store this entry in the dht (in seconds)"), |
194 | &expiration), | 195 | &expiration), |
195 | GNUNET_GETOPT_option_string ('k', | 196 | GNUNET_GETOPT_option_string ( |
196 | "key", | 197 | 'k', |
197 | "KEY", | 198 | "key", |
198 | gettext_noop ("the query key"), | 199 | "KEY", |
199 | &query_key), | 200 | gettext_noop ("the query key"), |
200 | GNUNET_GETOPT_option_flag ('x', | 201 | &query_key), |
201 | "demultiplex", | 202 | GNUNET_GETOPT_option_flag ( |
202 | gettext_noop ( | 203 | 'x', |
203 | "use DHT's demultiplex everywhere option"), | 204 | "demultiplex", |
204 | &demultixplex_everywhere), | 205 | gettext_noop ( |
205 | GNUNET_GETOPT_option_uint ('r', | 206 | "use DHT's demultiplex everywhere option"), |
206 | "replication", | 207 | &demultixplex_everywhere), |
207 | "LEVEL", | 208 | GNUNET_GETOPT_option_uint ( |
208 | gettext_noop ("how many replicas to create"), | 209 | 'r', |
209 | &replication), | 210 | "replication", |
210 | GNUNET_GETOPT_option_flag ('R', | 211 | "LEVEL", |
211 | "record", | 212 | gettext_noop ("how many replicas to create"), |
212 | gettext_noop ("use DHT's record route option"), | 213 | &replication), |
213 | &record_route), | 214 | GNUNET_GETOPT_option_flag ( |
214 | GNUNET_GETOPT_option_uint ('t', | 215 | 'R', |
215 | "type", | 216 | "record", |
216 | "TYPE", | 217 | gettext_noop ("use DHT's record route option"), |
217 | gettext_noop ("the type to insert data as"), | 218 | &record_route), |
218 | &query_type), | 219 | GNUNET_GETOPT_option_uint ( |
220 | 't', | ||
221 | "type", | ||
222 | "TYPE", | ||
223 | gettext_noop ("the type to insert data as"), | ||
224 | &query_type), | ||
219 | GNUNET_GETOPT_option_verbose (&verbose), | 225 | GNUNET_GETOPT_option_verbose (&verbose), |
220 | GNUNET_GETOPT_OPTION_END }; | 226 | GNUNET_GETOPT_OPTION_END |
227 | }; | ||
221 | 228 | ||
222 | 229 | ||
223 | if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv)) | 230 | if (GNUNET_OK != |
231 | GNUNET_STRINGS_get_utf8_args (argc, argv, | ||
232 | &argc, &argv)) | ||
224 | return 2; | 233 | return 2; |
225 | expiration = GNUNET_TIME_UNIT_HOURS; | 234 | expiration = GNUNET_TIME_UNIT_HOURS; |
226 | return (GNUNET_OK == | 235 | return (GNUNET_OK == |
diff --git a/src/dht/gnunet-service-dht.h b/src/dht/gnunet-service-dht.h index e9b1ff63a..367ff426e 100644 --- a/src/dht/gnunet-service-dht.h +++ b/src/dht/gnunet-service-dht.h | |||
@@ -73,7 +73,7 @@ void | |||
73 | GDS_CLIENTS_handle_reply (const struct GDS_DATACACHE_BlockData *bd, | 73 | GDS_CLIENTS_handle_reply (const struct GDS_DATACACHE_BlockData *bd, |
74 | const struct GNUNET_HashCode *query_hash, | 74 | const struct GNUNET_HashCode *query_hash, |
75 | unsigned int get_path_length, | 75 | unsigned int get_path_length, |
76 | const struct GNUNET_PeerIdentity *get_path); | 76 | const struct GNUNET_DHT_PathElement *get_path); |
77 | 77 | ||
78 | 78 | ||
79 | /** | 79 | /** |
@@ -94,7 +94,7 @@ GDS_CLIENTS_process_get (enum GNUNET_DHT_RouteOption options, | |||
94 | uint32_t hop_count, | 94 | uint32_t hop_count, |
95 | uint32_t desired_replication_level, | 95 | uint32_t desired_replication_level, |
96 | unsigned int path_length, | 96 | unsigned int path_length, |
97 | const struct GNUNET_PeerIdentity *path, | 97 | const struct GNUNET_DHT_PathElement *path, |
98 | const struct GNUNET_HashCode *key); | 98 | const struct GNUNET_HashCode *key); |
99 | 99 | ||
100 | 100 | ||
@@ -108,7 +108,7 @@ GDS_CLIENTS_process_get (enum GNUNET_DHT_RouteOption options, | |||
108 | */ | 108 | */ |
109 | void | 109 | void |
110 | GDS_CLIENTS_process_get_resp (const struct GDS_DATACACHE_BlockData *bd, | 110 | GDS_CLIENTS_process_get_resp (const struct GDS_DATACACHE_BlockData *bd, |
111 | const struct GNUNET_PeerIdentity *get_path, | 111 | const struct GNUNET_DHT_PathElement *get_path, |
112 | unsigned int get_path_length); | 112 | unsigned int get_path_length); |
113 | 113 | ||
114 | 114 | ||
diff --git a/src/dht/gnunet-service-dht_clients.c b/src/dht/gnunet-service-dht_clients.c index 245130dbc..a1c3024de 100644 --- a/src/dht/gnunet-service-dht_clients.c +++ b/src/dht/gnunet-service-dht_clients.c | |||
@@ -644,8 +644,8 @@ handle_dht_local_get (void *cls, | |||
644 | cqr->type, | 644 | cqr->type, |
645 | 0, /* hop count */ | 645 | 0, /* hop count */ |
646 | cqr->replication, | 646 | cqr->replication, |
647 | 1, /* path length */ | 647 | 0, /* path length */ |
648 | GDS_NEIGHBOURS_get_id (), | 648 | NULL, |
649 | &get->key); | 649 | &get->key); |
650 | /* start remote requests */ | 650 | /* start remote requests */ |
651 | if (NULL != retry_task) | 651 | if (NULL != retry_task) |
@@ -867,7 +867,7 @@ struct ForwardReplyContext | |||
867 | /** | 867 | /** |
868 | * GET path taken. | 868 | * GET path taken. |
869 | */ | 869 | */ |
870 | const struct GNUNET_PeerIdentity *get_path; | 870 | const struct GNUNET_DHT_PathElement *get_path; |
871 | 871 | ||
872 | /** | 872 | /** |
873 | * Number of entries in @e get_path. | 873 | * Number of entries in @e get_path. |
@@ -900,7 +900,7 @@ forward_reply (void *cls, | |||
900 | enum GNUNET_BLOCK_ReplyEvaluationResult eval; | 900 | enum GNUNET_BLOCK_ReplyEvaluationResult eval; |
901 | bool do_free; | 901 | bool do_free; |
902 | struct GNUNET_HashCode ch; | 902 | struct GNUNET_HashCode ch; |
903 | struct GNUNET_PeerIdentity *paths; | 903 | struct GNUNET_DHT_PathElement *paths; |
904 | 904 | ||
905 | LOG_TRAFFIC (GNUNET_ERROR_TYPE_DEBUG, | 905 | LOG_TRAFFIC (GNUNET_ERROR_TYPE_DEBUG, |
906 | "CLIENT-RESULT %s\n", | 906 | "CLIENT-RESULT %s\n", |
@@ -989,7 +989,7 @@ forward_reply (void *cls, | |||
989 | env = GNUNET_MQ_msg_extra (reply, | 989 | env = GNUNET_MQ_msg_extra (reply, |
990 | frc->bd->data_size | 990 | frc->bd->data_size |
991 | + (frc->get_path_length + frc->bd->put_path_length) | 991 | + (frc->get_path_length + frc->bd->put_path_length) |
992 | * sizeof(struct GNUNET_PeerIdentity), | 992 | * sizeof(struct GNUNET_DHT_PathElement), |
993 | GNUNET_MESSAGE_TYPE_DHT_CLIENT_RESULT); | 993 | GNUNET_MESSAGE_TYPE_DHT_CLIENT_RESULT); |
994 | reply->type = htonl (frc->bd->type); | 994 | reply->type = htonl (frc->bd->type); |
995 | reply->get_path_length = htonl (frc->get_path_length); | 995 | reply->get_path_length = htonl (frc->get_path_length); |
@@ -997,13 +997,14 @@ forward_reply (void *cls, | |||
997 | reply->unique_id = record->unique_id; | 997 | reply->unique_id = record->unique_id; |
998 | reply->expiration = GNUNET_TIME_absolute_hton (frc->bd->expiration_time); | 998 | reply->expiration = GNUNET_TIME_absolute_hton (frc->bd->expiration_time); |
999 | reply->key = frc->bd->key; | 999 | reply->key = frc->bd->key; |
1000 | paths = (struct GNUNET_PeerIdentity *) &reply[1]; | 1000 | paths = (struct GNUNET_DHT_PathElement *) &reply[1]; |
1001 | GNUNET_memcpy (paths, | 1001 | GNUNET_memcpy (paths, |
1002 | frc->bd->put_path, | 1002 | frc->bd->put_path, |
1003 | sizeof(struct GNUNET_PeerIdentity) * frc->bd->put_path_length); | 1003 | sizeof(struct GNUNET_DHT_PathElement) |
1004 | * frc->bd->put_path_length); | ||
1004 | GNUNET_memcpy (&paths[frc->bd->put_path_length], | 1005 | GNUNET_memcpy (&paths[frc->bd->put_path_length], |
1005 | frc->get_path, | 1006 | frc->get_path, |
1006 | sizeof(struct GNUNET_PeerIdentity) * frc->get_path_length); | 1007 | sizeof(struct GNUNET_DHT_PathElement) * frc->get_path_length); |
1007 | GNUNET_memcpy (&paths[frc->get_path_length + frc->bd->put_path_length], | 1008 | GNUNET_memcpy (&paths[frc->get_path_length + frc->bd->put_path_length], |
1008 | frc->bd->data, | 1009 | frc->bd->data, |
1009 | frc->bd->data_size); | 1010 | frc->bd->data_size); |
@@ -1023,13 +1024,13 @@ void | |||
1023 | GDS_CLIENTS_handle_reply (const struct GDS_DATACACHE_BlockData *bd, | 1024 | GDS_CLIENTS_handle_reply (const struct GDS_DATACACHE_BlockData *bd, |
1024 | const struct GNUNET_HashCode *query_hash, | 1025 | const struct GNUNET_HashCode *query_hash, |
1025 | unsigned int get_path_length, | 1026 | unsigned int get_path_length, |
1026 | const struct GNUNET_PeerIdentity *get_path) | 1027 | const struct GNUNET_DHT_PathElement *get_path) |
1027 | { | 1028 | { |
1028 | struct ForwardReplyContext frc; | 1029 | struct ForwardReplyContext frc; |
1029 | size_t msize = sizeof (struct GNUNET_DHT_ClientResultMessage) | 1030 | size_t msize = sizeof (struct GNUNET_DHT_ClientResultMessage) |
1030 | + bd->data_size | 1031 | + bd->data_size |
1031 | + (get_path_length + bd->put_path_length) | 1032 | + (get_path_length + bd->put_path_length) |
1032 | * sizeof(struct GNUNET_PeerIdentity); | 1033 | * sizeof(struct GNUNET_DHT_PathElement); |
1033 | 1034 | ||
1034 | if (msize >= GNUNET_MAX_MESSAGE_SIZE) | 1035 | if (msize >= GNUNET_MAX_MESSAGE_SIZE) |
1035 | { | 1036 | { |
@@ -1203,7 +1204,7 @@ struct GetActionContext | |||
1203 | uint32_t hop_count; | 1204 | uint32_t hop_count; |
1204 | uint32_t desired_replication_level; | 1205 | uint32_t desired_replication_level; |
1205 | unsigned int get_path_length; | 1206 | unsigned int get_path_length; |
1206 | const struct GNUNET_PeerIdentity *get_path; | 1207 | const struct GNUNET_DHT_PathElement *get_path; |
1207 | const struct GNUNET_HashCode *key; | 1208 | const struct GNUNET_HashCode *key; |
1208 | }; | 1209 | }; |
1209 | 1210 | ||
@@ -1222,10 +1223,10 @@ get_action (void *cls, | |||
1222 | struct GetActionContext *gac = cls; | 1223 | struct GetActionContext *gac = cls; |
1223 | struct GNUNET_MQ_Envelope *env; | 1224 | struct GNUNET_MQ_Envelope *env; |
1224 | struct GNUNET_DHT_MonitorGetMessage *mmsg; | 1225 | struct GNUNET_DHT_MonitorGetMessage *mmsg; |
1225 | struct GNUNET_PeerIdentity *msg_path; | 1226 | struct GNUNET_DHT_PathElement *msg_path; |
1226 | size_t msize; | 1227 | size_t msize; |
1227 | 1228 | ||
1228 | msize = gac->get_path_length * sizeof(struct GNUNET_PeerIdentity); | 1229 | msize = gac->get_path_length * sizeof(struct GNUNET_DHT_PathElement); |
1229 | env = GNUNET_MQ_msg_extra (mmsg, | 1230 | env = GNUNET_MQ_msg_extra (mmsg, |
1230 | msize, | 1231 | msize, |
1231 | GNUNET_MESSAGE_TYPE_DHT_MONITOR_GET); | 1232 | GNUNET_MESSAGE_TYPE_DHT_MONITOR_GET); |
@@ -1235,10 +1236,10 @@ get_action (void *cls, | |||
1235 | mmsg->desired_replication_level = htonl (gac->desired_replication_level); | 1236 | mmsg->desired_replication_level = htonl (gac->desired_replication_level); |
1236 | mmsg->get_path_length = htonl (gac->get_path_length); | 1237 | mmsg->get_path_length = htonl (gac->get_path_length); |
1237 | mmsg->key = *gac->key; | 1238 | mmsg->key = *gac->key; |
1238 | msg_path = (struct GNUNET_PeerIdentity *) &mmsg[1]; | 1239 | msg_path = (struct GNUNET_DHT_PathElement *) &mmsg[1]; |
1239 | GNUNET_memcpy (msg_path, | 1240 | GNUNET_memcpy (msg_path, |
1240 | gac->get_path, | 1241 | gac->get_path, |
1241 | gac->get_path_length * sizeof(struct GNUNET_PeerIdentity)); | 1242 | gac->get_path_length * sizeof(struct GNUNET_DHT_PathElement)); |
1242 | GNUNET_MQ_send (m->ch->mq, | 1243 | GNUNET_MQ_send (m->ch->mq, |
1243 | env); | 1244 | env); |
1244 | } | 1245 | } |
@@ -1262,7 +1263,7 @@ GDS_CLIENTS_process_get (enum GNUNET_DHT_RouteOption options, | |||
1262 | uint32_t hop_count, | 1263 | uint32_t hop_count, |
1263 | uint32_t desired_replication_level, | 1264 | uint32_t desired_replication_level, |
1264 | unsigned int path_length, | 1265 | unsigned int path_length, |
1265 | const struct GNUNET_PeerIdentity *path, | 1266 | const struct GNUNET_DHT_PathElement *path, |
1266 | const struct GNUNET_HashCode *key) | 1267 | const struct GNUNET_HashCode *key) |
1267 | { | 1268 | { |
1268 | struct GetActionContext gac = { | 1269 | struct GetActionContext gac = { |
@@ -1288,7 +1289,7 @@ GDS_CLIENTS_process_get (enum GNUNET_DHT_RouteOption options, | |||
1288 | struct ResponseActionContext | 1289 | struct ResponseActionContext |
1289 | { | 1290 | { |
1290 | const struct GDS_DATACACHE_BlockData *bd; | 1291 | const struct GDS_DATACACHE_BlockData *bd; |
1291 | const struct GNUNET_PeerIdentity *get_path; | 1292 | const struct GNUNET_DHT_PathElement *get_path; |
1292 | unsigned int get_path_length; | 1293 | unsigned int get_path_length; |
1293 | }; | 1294 | }; |
1294 | 1295 | ||
@@ -1309,12 +1310,12 @@ response_action (void *cls, | |||
1309 | 1310 | ||
1310 | struct GNUNET_MQ_Envelope *env; | 1311 | struct GNUNET_MQ_Envelope *env; |
1311 | struct GNUNET_DHT_MonitorGetRespMessage *mmsg; | 1312 | struct GNUNET_DHT_MonitorGetRespMessage *mmsg; |
1312 | struct GNUNET_PeerIdentity *path; | 1313 | struct GNUNET_DHT_PathElement *path; |
1313 | size_t msize; | 1314 | size_t msize; |
1314 | 1315 | ||
1315 | msize = bd->data_size; | 1316 | msize = bd->data_size; |
1316 | msize += (resp_ctx->get_path_length + bd->put_path_length) | 1317 | msize += (resp_ctx->get_path_length + bd->put_path_length) |
1317 | * sizeof(struct GNUNET_PeerIdentity); | 1318 | * sizeof(struct GNUNET_DHT_PathElement); |
1318 | env = GNUNET_MQ_msg_extra (mmsg, | 1319 | env = GNUNET_MQ_msg_extra (mmsg, |
1319 | msize, | 1320 | msize, |
1320 | GNUNET_MESSAGE_TYPE_DHT_MONITOR_GET_RESP); | 1321 | GNUNET_MESSAGE_TYPE_DHT_MONITOR_GET_RESP); |
@@ -1323,14 +1324,14 @@ response_action (void *cls, | |||
1323 | mmsg->get_path_length = htonl (resp_ctx->get_path_length); | 1324 | mmsg->get_path_length = htonl (resp_ctx->get_path_length); |
1324 | mmsg->expiration_time = GNUNET_TIME_absolute_hton (bd->expiration_time); | 1325 | mmsg->expiration_time = GNUNET_TIME_absolute_hton (bd->expiration_time); |
1325 | mmsg->key = bd->key; | 1326 | mmsg->key = bd->key; |
1326 | path = (struct GNUNET_PeerIdentity *) &mmsg[1]; | 1327 | path = (struct GNUNET_DHT_PathElement *) &mmsg[1]; |
1327 | GNUNET_memcpy (path, | 1328 | GNUNET_memcpy (path, |
1328 | bd->put_path, | 1329 | bd->put_path, |
1329 | bd->put_path_length * sizeof(struct GNUNET_PeerIdentity)); | 1330 | bd->put_path_length * sizeof(struct GNUNET_DHT_PathElement)); |
1330 | GNUNET_memcpy (path, | 1331 | GNUNET_memcpy (path, |
1331 | resp_ctx->get_path, | 1332 | resp_ctx->get_path, |
1332 | resp_ctx->get_path_length * sizeof(struct | 1333 | resp_ctx->get_path_length * sizeof(struct |
1333 | GNUNET_PeerIdentity)); | 1334 | GNUNET_DHT_PathElement)); |
1334 | GNUNET_memcpy (&path[resp_ctx->get_path_length], | 1335 | GNUNET_memcpy (&path[resp_ctx->get_path_length], |
1335 | bd->data, | 1336 | bd->data, |
1336 | bd->data_size); | 1337 | bd->data_size); |
@@ -1341,7 +1342,7 @@ response_action (void *cls, | |||
1341 | 1342 | ||
1342 | void | 1343 | void |
1343 | GDS_CLIENTS_process_get_resp (const struct GDS_DATACACHE_BlockData *bd, | 1344 | GDS_CLIENTS_process_get_resp (const struct GDS_DATACACHE_BlockData *bd, |
1344 | const struct GNUNET_PeerIdentity *get_path, | 1345 | const struct GNUNET_DHT_PathElement *get_path, |
1345 | unsigned int get_path_length) | 1346 | unsigned int get_path_length) |
1346 | { | 1347 | { |
1347 | struct ResponseActionContext rac = { | 1348 | struct ResponseActionContext rac = { |
@@ -1384,12 +1385,12 @@ put_action (void *cls, | |||
1384 | const struct GDS_DATACACHE_BlockData *bd = put_ctx->bd; | 1385 | const struct GDS_DATACACHE_BlockData *bd = put_ctx->bd; |
1385 | struct GNUNET_MQ_Envelope *env; | 1386 | struct GNUNET_MQ_Envelope *env; |
1386 | struct GNUNET_DHT_MonitorPutMessage *mmsg; | 1387 | struct GNUNET_DHT_MonitorPutMessage *mmsg; |
1387 | struct GNUNET_PeerIdentity *msg_path; | 1388 | struct GNUNET_DHT_PathElement *msg_path; |
1388 | size_t msize; | 1389 | size_t msize; |
1389 | 1390 | ||
1390 | msize = bd->data_size | 1391 | msize = bd->data_size |
1391 | + bd->put_path_length | 1392 | + bd->put_path_length |
1392 | * sizeof(struct GNUNET_PeerIdentity); | 1393 | * sizeof(struct GNUNET_DHT_PathElement); |
1393 | env = GNUNET_MQ_msg_extra (mmsg, | 1394 | env = GNUNET_MQ_msg_extra (mmsg, |
1394 | msize, | 1395 | msize, |
1395 | GNUNET_MESSAGE_TYPE_DHT_MONITOR_PUT); | 1396 | GNUNET_MESSAGE_TYPE_DHT_MONITOR_PUT); |
@@ -1400,10 +1401,10 @@ put_action (void *cls, | |||
1400 | mmsg->put_path_length = htonl (bd->put_path_length); | 1401 | mmsg->put_path_length = htonl (bd->put_path_length); |
1401 | mmsg->key = bd->key; | 1402 | mmsg->key = bd->key; |
1402 | mmsg->expiration_time = GNUNET_TIME_absolute_hton (bd->expiration_time); | 1403 | mmsg->expiration_time = GNUNET_TIME_absolute_hton (bd->expiration_time); |
1403 | msg_path = (struct GNUNET_PeerIdentity *) &mmsg[1]; | 1404 | msg_path = (struct GNUNET_DHT_PathElement *) &mmsg[1]; |
1404 | GNUNET_memcpy (msg_path, | 1405 | GNUNET_memcpy (msg_path, |
1405 | bd->put_path, | 1406 | bd->put_path, |
1406 | bd->put_path_length * sizeof(struct GNUNET_PeerIdentity)); | 1407 | bd->put_path_length * sizeof(struct GNUNET_DHT_PathElement)); |
1407 | GNUNET_memcpy (&msg_path[bd->put_path_length], | 1408 | GNUNET_memcpy (&msg_path[bd->put_path_length], |
1408 | bd->data, | 1409 | bd->data, |
1409 | bd->data_size); | 1410 | bd->data_size); |
diff --git a/src/dht/gnunet-service-dht_datacache.c b/src/dht/gnunet-service-dht_datacache.c index 214c4a3f4..cb778717b 100644 --- a/src/dht/gnunet-service-dht_datacache.c +++ b/src/dht/gnunet-service-dht_datacache.c | |||
@@ -152,7 +152,7 @@ datacache_get_iterator (void *cls, | |||
152 | enum GNUNET_BLOCK_Type type, | 152 | enum GNUNET_BLOCK_Type type, |
153 | struct GNUNET_TIME_Absolute exp, | 153 | struct GNUNET_TIME_Absolute exp, |
154 | unsigned int put_path_length, | 154 | unsigned int put_path_length, |
155 | const struct GNUNET_PeerIdentity *put_path) | 155 | const struct GNUNET_DHT_PathElement *put_path) |
156 | { | 156 | { |
157 | struct GetRequestContext *ctx = cls; | 157 | struct GetRequestContext *ctx = cls; |
158 | enum GNUNET_BLOCK_ReplyEvaluationResult eval; | 158 | enum GNUNET_BLOCK_ReplyEvaluationResult eval; |
@@ -301,7 +301,8 @@ datacache_get_successors_iterator (void *cls, | |||
301 | enum GNUNET_BLOCK_Type type, | 301 | enum GNUNET_BLOCK_Type type, |
302 | struct GNUNET_TIME_Absolute exp, | 302 | struct GNUNET_TIME_Absolute exp, |
303 | unsigned int put_path_length, | 303 | unsigned int put_path_length, |
304 | const struct GNUNET_PeerIdentity *put_path) | 304 | const struct |
305 | GNUNET_DHT_PathElement *put_path) | ||
305 | { | 306 | { |
306 | const struct SuccContext *sc = cls; | 307 | const struct SuccContext *sc = cls; |
307 | struct GDS_DATACACHE_BlockData bd = { | 308 | struct GDS_DATACACHE_BlockData bd = { |
diff --git a/src/dht/gnunet-service-dht_datacache.h b/src/dht/gnunet-service-dht_datacache.h index 249bb8ee3..691a51e0e 100644 --- a/src/dht/gnunet-service-dht_datacache.h +++ b/src/dht/gnunet-service-dht_datacache.h | |||
@@ -50,7 +50,7 @@ struct GDS_DATACACHE_BlockData | |||
50 | /** | 50 | /** |
51 | * PUT path taken by the block, array of peer identities. | 51 | * PUT path taken by the block, array of peer identities. |
52 | */ | 52 | */ |
53 | const struct GNUNET_PeerIdentity *put_path; | 53 | const struct GNUNET_DHT_PathElement *put_path; |
54 | 54 | ||
55 | /** | 55 | /** |
56 | * Actual block data. | 56 | * Actual block data. |
diff --git a/src/dht/gnunet-service-dht_neighbours.c b/src/dht/gnunet-service-dht_neighbours.c index 35502e0f5..e100ae2ee 100644 --- a/src/dht/gnunet-service-dht_neighbours.c +++ b/src/dht/gnunet-service-dht_neighbours.c | |||
@@ -346,11 +346,6 @@ struct ConnectInfo | |||
346 | static int cache_results; | 346 | static int cache_results; |
347 | 347 | ||
348 | /** | 348 | /** |
349 | * Should routing details be logged to stderr (for debugging)? | ||
350 | */ | ||
351 | static int log_route_details_stderr; | ||
352 | |||
353 | /** | ||
354 | * The lowest currently used bucket, initially 0 (for 0-bits matching bucket). | 349 | * The lowest currently used bucket, initially 0 (for 0-bits matching bucket). |
355 | */ | 350 | */ |
356 | static unsigned int closest_bucket; | 351 | static unsigned int closest_bucket; |
@@ -1437,7 +1432,7 @@ GDS_NEIGHBOURS_handle_get (enum GNUNET_BLOCK_Type type, | |||
1437 | struct GNUNET_MQ_Envelope *env; | 1432 | struct GNUNET_MQ_Envelope *env; |
1438 | struct PeerGetMessage *pgm; | 1433 | struct PeerGetMessage *pgm; |
1439 | char *xq; | 1434 | char *xq; |
1440 | 1435 | ||
1441 | if (GNUNET_MQ_get_length (target->mq) >= MAXIMUM_PENDING_PER_PEER) | 1436 | if (GNUNET_MQ_get_length (target->mq) >= MAXIMUM_PENDING_PER_PEER) |
1442 | { | 1437 | { |
1443 | /* skip */ | 1438 | /* skip */ |
@@ -1503,20 +1498,20 @@ GDS_NEIGHBOURS_handle_reply (struct PeerInfo *pi, | |||
1503 | const struct GDS_DATACACHE_BlockData *bd, | 1498 | const struct GDS_DATACACHE_BlockData *bd, |
1504 | const struct GNUNET_HashCode *query_hash, | 1499 | const struct GNUNET_HashCode *query_hash, |
1505 | unsigned int get_path_length, | 1500 | unsigned int get_path_length, |
1506 | const struct GNUNET_PeerIdentity *get_path) | 1501 | const struct GNUNET_DHT_PathElement *get_path) |
1507 | { | 1502 | { |
1508 | struct GNUNET_MQ_Envelope *env; | 1503 | struct GNUNET_MQ_Envelope *env; |
1509 | struct PeerResultMessage *prm; | 1504 | struct PeerResultMessage *prm; |
1510 | struct GNUNET_PeerIdentity *paths; | 1505 | struct GNUNET_DHT_PathElement *paths; |
1511 | size_t msize; | 1506 | size_t msize; |
1512 | 1507 | ||
1513 | msize = bd->data_size + (get_path_length + bd->put_path_length) | 1508 | msize = bd->data_size + (get_path_length + bd->put_path_length) |
1514 | * sizeof(struct GNUNET_PeerIdentity); | 1509 | * sizeof(struct GNUNET_DHT_PathElement); |
1515 | if ( (msize + sizeof(struct PeerResultMessage) >= GNUNET_MAX_MESSAGE_SIZE) || | 1510 | if ( (msize + sizeof(struct PeerResultMessage) >= GNUNET_MAX_MESSAGE_SIZE) || |
1516 | (get_path_length > | 1511 | (get_path_length > |
1517 | GNUNET_MAX_MESSAGE_SIZE / sizeof(struct GNUNET_PeerIdentity)) || | 1512 | GNUNET_MAX_MESSAGE_SIZE / sizeof(struct GNUNET_DHT_PathElement)) || |
1518 | (bd->put_path_length > | 1513 | (bd->put_path_length > |
1519 | GNUNET_MAX_MESSAGE_SIZE / sizeof(struct GNUNET_PeerIdentity)) || | 1514 | GNUNET_MAX_MESSAGE_SIZE / sizeof(struct GNUNET_DHT_PathElement)) || |
1520 | (bd->data_size > GNUNET_MAX_MESSAGE_SIZE)) | 1515 | (bd->data_size > GNUNET_MAX_MESSAGE_SIZE)) |
1521 | { | 1516 | { |
1522 | GNUNET_break (0); | 1517 | GNUNET_break (0); |
@@ -1551,13 +1546,13 @@ GDS_NEIGHBOURS_handle_reply (struct PeerInfo *pi, | |||
1551 | prm->get_path_length = htonl (get_path_length); | 1546 | prm->get_path_length = htonl (get_path_length); |
1552 | prm->expiration_time = GNUNET_TIME_absolute_hton (bd->expiration_time); | 1547 | prm->expiration_time = GNUNET_TIME_absolute_hton (bd->expiration_time); |
1553 | prm->key = *query_hash; | 1548 | prm->key = *query_hash; |
1554 | paths = (struct GNUNET_PeerIdentity *) &prm[1]; | 1549 | paths = (struct GNUNET_DHT_PathElement *) &prm[1]; |
1555 | GNUNET_memcpy (paths, | 1550 | GNUNET_memcpy (paths, |
1556 | bd->put_path, | 1551 | bd->put_path, |
1557 | bd->put_path_length * sizeof(struct GNUNET_PeerIdentity)); | 1552 | bd->put_path_length * sizeof(struct GNUNET_DHT_PathElement)); |
1558 | GNUNET_memcpy (&paths[bd->put_path_length], | 1553 | GNUNET_memcpy (&paths[bd->put_path_length], |
1559 | get_path, | 1554 | get_path, |
1560 | get_path_length * sizeof(struct GNUNET_PeerIdentity)); | 1555 | get_path_length * sizeof(struct GNUNET_DHT_PathElement)); |
1561 | GNUNET_memcpy (&paths[bd->put_path_length + get_path_length], | 1556 | GNUNET_memcpy (&paths[bd->put_path_length + get_path_length], |
1562 | bd->data, | 1557 | bd->data, |
1563 | bd->data_size); | 1558 | bd->data_size); |
@@ -1582,7 +1577,7 @@ core_init (void *cls, | |||
1582 | GNUNET_i2s (identity)); | 1577 | GNUNET_i2s (identity)); |
1583 | my_identity = *identity; | 1578 | my_identity = *identity; |
1584 | GNUNET_CRYPTO_hash (identity, | 1579 | GNUNET_CRYPTO_hash (identity, |
1585 | sizeof(struct GNUNET_PeerIdentity), | 1580 | sizeof(struct GNUNET_PeerIdentity), |
1586 | &my_identity_hash); | 1581 | &my_identity_hash); |
1587 | GNUNET_SERVICE_resume (GDS_service); | 1582 | GNUNET_SERVICE_resume (GDS_service); |
1588 | } | 1583 | } |
@@ -1605,9 +1600,9 @@ check_dht_p2p_put (void *cls, | |||
1605 | (void) cls; | 1600 | (void) cls; |
1606 | if ( (msize < | 1601 | if ( (msize < |
1607 | sizeof(struct PeerPutMessage) | 1602 | sizeof(struct PeerPutMessage) |
1608 | + putlen * sizeof(struct GNUNET_PeerIdentity)) || | 1603 | + putlen * sizeof(struct GNUNET_DHT_PathElement)) || |
1609 | (putlen > | 1604 | (putlen > |
1610 | GNUNET_MAX_MESSAGE_SIZE / sizeof(struct GNUNET_PeerIdentity)) ) | 1605 | GNUNET_MAX_MESSAGE_SIZE / sizeof(struct GNUNET_DHT_PathElement)) ) |
1611 | { | 1606 | { |
1612 | GNUNET_break_op (0); | 1607 | GNUNET_break_op (0); |
1613 | return GNUNET_SYSERR; | 1608 | return GNUNET_SYSERR; |
@@ -1635,13 +1630,13 @@ handle_dht_p2p_put (void *cls, | |||
1635 | .expiration_time = GNUNET_TIME_absolute_ntoh (put->expiration_time), | 1630 | .expiration_time = GNUNET_TIME_absolute_ntoh (put->expiration_time), |
1636 | .type = ntohl (put->type) | 1631 | .type = ntohl (put->type) |
1637 | }; | 1632 | }; |
1638 | const struct GNUNET_PeerIdentity *put_path | 1633 | const struct GNUNET_DHT_PathElement *put_path |
1639 | = (const struct GNUNET_PeerIdentity *) &put[1]; | 1634 | = (const struct GNUNET_DHT_PathElement *) &put[1]; |
1640 | uint32_t putlen | 1635 | uint32_t putlen |
1641 | = ntohl (put->put_path_length); | 1636 | = ntohl (put->put_path_length); |
1642 | 1637 | ||
1643 | bd.data_size = msize - (sizeof(*put) | 1638 | bd.data_size = msize - (sizeof(*put) |
1644 | + putlen * sizeof(struct GNUNET_PeerIdentity)); | 1639 | + putlen * sizeof(struct GNUNET_DHT_PathElement)); |
1645 | bd.data = &put_path[putlen]; | 1640 | bd.data = &put_path[putlen]; |
1646 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1641 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1647 | "PUT for `%s' from %s\n", | 1642 | "PUT for `%s' from %s\n", |
@@ -1663,35 +1658,6 @@ handle_dht_p2p_put (void *cls, | |||
1663 | "# P2P PUT bytes received", | 1658 | "# P2P PUT bytes received", |
1664 | msize, | 1659 | msize, |
1665 | GNUNET_NO); | 1660 | GNUNET_NO); |
1666 | if (GNUNET_YES == log_route_details_stderr) | ||
1667 | { | ||
1668 | char *tmp; | ||
1669 | char *pp; | ||
1670 | struct GNUNET_HashCode mxor; | ||
1671 | struct GNUNET_HashCode pxor; | ||
1672 | |||
1673 | GNUNET_CRYPTO_hash_xor (&my_identity_hash, | ||
1674 | &put->key, | ||
1675 | &mxor); | ||
1676 | GNUNET_CRYPTO_hash_xor (&peer->phash, | ||
1677 | &put->key, | ||
1678 | &pxor); | ||
1679 | pp = GNUNET_STRINGS_pp2s (put_path, | ||
1680 | putlen); | ||
1681 | tmp = GNUNET_strdup (GNUNET_i2s (&my_identity)); | ||
1682 | LOG_TRAFFIC (GNUNET_ERROR_TYPE_DEBUG, | ||
1683 | "R5N PUT %s: %s->%s (%u, %u=>%u, PP: %s)\n", | ||
1684 | GNUNET_h2s (&put->key), | ||
1685 | GNUNET_i2s (peer->id), | ||
1686 | tmp, | ||
1687 | ntohl (put->hop_count), | ||
1688 | GNUNET_CRYPTO_hash_count_leading_zeros (&pxor), | ||
1689 | GNUNET_CRYPTO_hash_count_leading_zeros (&mxor), | ||
1690 | pp); | ||
1691 | GNUNET_free (pp); | ||
1692 | GNUNET_free (tmp); | ||
1693 | } | ||
1694 | |||
1695 | { | 1661 | { |
1696 | struct GNUNET_HashCode test_key; | 1662 | struct GNUNET_HashCode test_key; |
1697 | enum GNUNET_GenericReturnValue ret; | 1663 | enum GNUNET_GenericReturnValue ret; |
@@ -1733,7 +1699,7 @@ handle_dht_p2p_put (void *cls, | |||
1733 | 1699 | ||
1734 | { | 1700 | { |
1735 | struct GNUNET_CONTAINER_BloomFilter *bf; | 1701 | struct GNUNET_CONTAINER_BloomFilter *bf; |
1736 | struct GNUNET_PeerIdentity pp[putlen + 1]; | 1702 | struct GNUNET_DHT_PathElement pp[putlen + 1]; |
1737 | 1703 | ||
1738 | bf = GNUNET_CONTAINER_bloomfilter_init (put->bloomfilter, | 1704 | bf = GNUNET_CONTAINER_bloomfilter_init (put->bloomfilter, |
1739 | DHT_BLOOM_SIZE, | 1705 | DHT_BLOOM_SIZE, |
@@ -1742,7 +1708,7 @@ handle_dht_p2p_put (void *cls, | |||
1742 | GNUNET_CONTAINER_bloomfilter_test (bf, | 1708 | GNUNET_CONTAINER_bloomfilter_test (bf, |
1743 | &peer->phash)); | 1709 | &peer->phash)); |
1744 | /* extend 'put path' by sender */ | 1710 | /* extend 'put path' by sender */ |
1745 | bd.put_path = (const struct GNUNET_PeerIdentity *) pp; | 1711 | bd.put_path = (const struct GNUNET_DHT_PathElement *) pp; |
1746 | bd.put_path_length = putlen + 1; | 1712 | bd.put_path_length = putlen + 1; |
1747 | if (0 != (options & GNUNET_DHT_RO_RECORD_ROUTE)) | 1713 | if (0 != (options & GNUNET_DHT_RO_RECORD_ROUTE)) |
1748 | { | 1714 | { |
@@ -1752,18 +1718,22 @@ handle_dht_p2p_put (void *cls, | |||
1752 | for (unsigned int j = 0; j < i; j++) | 1718 | for (unsigned int j = 0; j < i; j++) |
1753 | { | 1719 | { |
1754 | GNUNET_break (0 != | 1720 | GNUNET_break (0 != |
1755 | GNUNET_memcmp (&pp[i], | 1721 | GNUNET_memcmp (&pp[i].pred, |
1756 | &pp[j])); | 1722 | &pp[j].pred)); |
1757 | } | 1723 | } |
1758 | GNUNET_break (0 != | 1724 | GNUNET_break (0 != |
1759 | GNUNET_memcmp (&pp[i], | 1725 | GNUNET_memcmp (&pp[i].pred, |
1760 | peer->id)); | 1726 | peer->id)); |
1761 | } | 1727 | } |
1762 | #endif | 1728 | #endif |
1763 | GNUNET_memcpy (pp, | 1729 | GNUNET_memcpy (pp, |
1764 | put_path, | 1730 | put_path, |
1765 | putlen * sizeof(struct GNUNET_PeerIdentity)); | 1731 | putlen * sizeof(struct GNUNET_DHT_PathElement)); |
1766 | pp[putlen] = *peer->id; | 1732 | pp[putlen].pred = *peer->id; |
1733 | /* zero-out signature, not valid until we actually do forward! */ | ||
1734 | memset (&pp[putlen].sig, | ||
1735 | 0, | ||
1736 | sizeof (pp[putlen].sig)); | ||
1767 | putlen++; | 1737 | putlen++; |
1768 | } | 1738 | } |
1769 | else | 1739 | else |
@@ -1938,17 +1908,6 @@ handle_local_result (void *cls, | |||
1938 | { | 1908 | { |
1939 | struct PeerInfo *peer = cls; | 1909 | struct PeerInfo *peer = cls; |
1940 | 1910 | ||
1941 | { | ||
1942 | char *pp; | ||
1943 | |||
1944 | pp = GNUNET_STRINGS_pp2s (bd->put_path, | ||
1945 | bd->put_path_length); | ||
1946 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1947 | "Found local result for %s (PP: %s)\n", | ||
1948 | GNUNET_h2s (&bd->key), | ||
1949 | pp); | ||
1950 | GNUNET_free (pp); | ||
1951 | } | ||
1952 | GDS_NEIGHBOURS_handle_reply (peer, | 1911 | GDS_NEIGHBOURS_handle_reply (peer, |
1953 | bd, | 1912 | bd, |
1954 | &bd->key, | 1913 | &bd->key, |
@@ -1996,7 +1955,8 @@ handle_dht_p2p_get (void *cls, | |||
1996 | uint32_t hop_count = ntohl (get->hop_count); | 1955 | uint32_t hop_count = ntohl (get->hop_count); |
1997 | size_t reply_bf_size = msize - (sizeof(*get) + xquery_size); | 1956 | size_t reply_bf_size = msize - (sizeof(*get) + xquery_size); |
1998 | enum GNUNET_BLOCK_Type type = (enum GNUNET_BLOCK_Type) ntohl (get->type); | 1957 | enum GNUNET_BLOCK_Type type = (enum GNUNET_BLOCK_Type) ntohl (get->type); |
1999 | enum GNUNET_DHT_RouteOption options = (enum GNUNET_DHT_RouteOption) ntohl (get->options); | 1958 | enum GNUNET_DHT_RouteOption options = (enum GNUNET_DHT_RouteOption) ntohl ( |
1959 | get->options); | ||
2000 | enum GNUNET_BLOCK_ReplyEvaluationResult eval = GNUNET_BLOCK_REPLY_OK_MORE; | 1960 | enum GNUNET_BLOCK_ReplyEvaluationResult eval = GNUNET_BLOCK_REPLY_OK_MORE; |
2001 | const void *xquery = (const void *) &get[1]; | 1961 | const void *xquery = (const void *) &get[1]; |
2002 | 1962 | ||
@@ -2009,31 +1969,6 @@ handle_dht_p2p_get (void *cls, | |||
2009 | "# P2P GET bytes received", | 1969 | "# P2P GET bytes received", |
2010 | msize, | 1970 | msize, |
2011 | GNUNET_NO); | 1971 | GNUNET_NO); |
2012 | if (GNUNET_YES == log_route_details_stderr) | ||
2013 | { | ||
2014 | char *tmp; | ||
2015 | struct GNUNET_HashCode mxor; | ||
2016 | struct GNUNET_HashCode pxor; | ||
2017 | |||
2018 | GNUNET_CRYPTO_hash_xor (&my_identity_hash, | ||
2019 | &get->key, | ||
2020 | &mxor); | ||
2021 | GNUNET_CRYPTO_hash_xor (&peer->phash, | ||
2022 | &get->key, | ||
2023 | &pxor); | ||
2024 | tmp = GNUNET_strdup (GNUNET_i2s (&my_identity)); | ||
2025 | LOG_TRAFFIC (GNUNET_ERROR_TYPE_DEBUG, | ||
2026 | "R5N GET %s: %s->%s (%u, %u=>%u) xq: %.*s\n", | ||
2027 | GNUNET_h2s (&get->key), | ||
2028 | GNUNET_i2s (peer->id), | ||
2029 | tmp, | ||
2030 | hop_count, | ||
2031 | GNUNET_CRYPTO_hash_count_leading_zeros (&pxor), | ||
2032 | GNUNET_CRYPTO_hash_count_leading_zeros (&mxor), | ||
2033 | ntohl (get->xquery_size), | ||
2034 | (const char *) xquery); | ||
2035 | GNUNET_free (tmp); | ||
2036 | } | ||
2037 | if (GNUNET_NO == | 1972 | if (GNUNET_NO == |
2038 | GNUNET_BLOCK_check_query (GDS_block_context, | 1973 | GNUNET_BLOCK_check_query (GDS_block_context, |
2039 | type, | 1974 | type, |
@@ -2096,13 +2031,13 @@ handle_dht_p2p_get (void *cls, | |||
2096 | } | 2031 | } |
2097 | } | 2032 | } |
2098 | else | 2033 | else |
2099 | { | 2034 | { |
2100 | GNUNET_STATISTICS_update (GDS_stats, | 2035 | GNUNET_STATISTICS_update (GDS_stats, |
2101 | "# P2P GET requests ONLY routed", | 2036 | "# P2P GET requests ONLY routed", |
2102 | 1, | 2037 | 1, |
2103 | GNUNET_NO); | 2038 | GNUNET_NO); |
2104 | } | 2039 | } |
2105 | 2040 | ||
2106 | /* remember request for routing replies */ | 2041 | /* remember request for routing replies */ |
2107 | GDS_ROUTING_add (peer->id, | 2042 | GDS_ROUTING_add (peer->id, |
2108 | type, | 2043 | type, |
@@ -2115,7 +2050,8 @@ handle_dht_p2p_get (void *cls, | |||
2115 | /* P2P forwarding */ | 2050 | /* P2P forwarding */ |
2116 | { | 2051 | { |
2117 | bool forwarded = false; | 2052 | bool forwarded = false; |
2118 | uint32_t desired_replication_level = ntohl (get->desired_replication_level); | 2053 | uint32_t desired_replication_level = ntohl ( |
2054 | get->desired_replication_level); | ||
2119 | 2055 | ||
2120 | if (eval != GNUNET_BLOCK_REPLY_OK_LAST) | 2056 | if (eval != GNUNET_BLOCK_REPLY_OK_LAST) |
2121 | forwarded = (GNUNET_OK == | 2057 | forwarded = (GNUNET_OK == |
@@ -2129,8 +2065,8 @@ handle_dht_p2p_get (void *cls, | |||
2129 | bg, | 2065 | bg, |
2130 | peer_bf)); | 2066 | peer_bf)); |
2131 | GDS_CLIENTS_process_get ( | 2067 | GDS_CLIENTS_process_get ( |
2132 | options | | 2068 | options |
2133 | (forwarded | 2069 | | (forwarded |
2134 | ? 0 | 2070 | ? 0 |
2135 | : GNUNET_DHT_RO_LAST_HOP), | 2071 | : GNUNET_DHT_RO_LAST_HOP), |
2136 | type, | 2072 | type, |
@@ -2158,7 +2094,7 @@ static void | |||
2158 | process_reply_with_path (const struct GDS_DATACACHE_BlockData *bd, | 2094 | process_reply_with_path (const struct GDS_DATACACHE_BlockData *bd, |
2159 | const struct GNUNET_HashCode *query_hash, | 2095 | const struct GNUNET_HashCode *query_hash, |
2160 | unsigned int get_path_length, | 2096 | unsigned int get_path_length, |
2161 | const struct GNUNET_PeerIdentity *get_path) | 2097 | const struct GNUNET_DHT_PathElement *get_path) |
2162 | { | 2098 | { |
2163 | /* forward to local clients */ | 2099 | /* forward to local clients */ |
2164 | GDS_CLIENTS_handle_reply (bd, | 2100 | GDS_CLIENTS_handle_reply (bd, |
@@ -2170,16 +2106,16 @@ process_reply_with_path (const struct GDS_DATACACHE_BlockData *bd, | |||
2170 | get_path_length); | 2106 | get_path_length); |
2171 | if (GNUNET_YES == cache_results) | 2107 | if (GNUNET_YES == cache_results) |
2172 | { | 2108 | { |
2173 | struct GNUNET_PeerIdentity xput_path[GNUNET_NZL (get_path_length | 2109 | struct GNUNET_DHT_PathElement xput_path[GNUNET_NZL (get_path_length |
2174 | + bd->put_path_length)]; | 2110 | + bd->put_path_length)]; |
2175 | struct GDS_DATACACHE_BlockData bdx = *bd; | 2111 | struct GDS_DATACACHE_BlockData bdx = *bd; |
2176 | 2112 | ||
2177 | GNUNET_memcpy (xput_path, | 2113 | GNUNET_memcpy (xput_path, |
2178 | bd->put_path, | 2114 | bd->put_path, |
2179 | bd->put_path_length * sizeof(struct GNUNET_PeerIdentity)); | 2115 | bd->put_path_length * sizeof(struct GNUNET_DHT_PathElement)); |
2180 | GNUNET_memcpy (&xput_path[bd->put_path_length], | 2116 | GNUNET_memcpy (&xput_path[bd->put_path_length], |
2181 | get_path, | 2117 | get_path, |
2182 | get_path_length * sizeof(struct GNUNET_PeerIdentity)); | 2118 | get_path_length * sizeof(struct GNUNET_DHT_PathElement)); |
2183 | bdx.put_path = xput_path; | 2119 | bdx.put_path = xput_path; |
2184 | bdx.put_path_length += get_path_length; | 2120 | bdx.put_path_length += get_path_length; |
2185 | GDS_DATACACHE_handle_put (&bdx); | 2121 | GDS_DATACACHE_handle_put (&bdx); |
@@ -2211,11 +2147,11 @@ check_dht_p2p_result (void *cls, | |||
2211 | if ( (msize < | 2147 | if ( (msize < |
2212 | sizeof(struct PeerResultMessage) | 2148 | sizeof(struct PeerResultMessage) |
2213 | + (get_path_length + put_path_length) | 2149 | + (get_path_length + put_path_length) |
2214 | * sizeof(struct GNUNET_PeerIdentity)) || | 2150 | * sizeof(struct GNUNET_DHT_PathElement)) || |
2215 | (get_path_length > | 2151 | (get_path_length > |
2216 | GNUNET_MAX_MESSAGE_SIZE / sizeof(struct GNUNET_PeerIdentity)) || | 2152 | GNUNET_MAX_MESSAGE_SIZE / sizeof(struct GNUNET_DHT_PathElement)) || |
2217 | (put_path_length > | 2153 | (put_path_length > |
2218 | GNUNET_MAX_MESSAGE_SIZE / sizeof(struct GNUNET_PeerIdentity)) ) | 2154 | GNUNET_MAX_MESSAGE_SIZE / sizeof(struct GNUNET_DHT_PathElement)) ) |
2219 | { | 2155 | { |
2220 | GNUNET_break_op (0); | 2156 | GNUNET_break_op (0); |
2221 | return GNUNET_SYSERR; | 2157 | return GNUNET_SYSERR; |
@@ -2239,11 +2175,11 @@ handle_dht_p2p_result (void *cls, | |||
2239 | uint32_t get_path_length = ntohl (prm->get_path_length); | 2175 | uint32_t get_path_length = ntohl (prm->get_path_length); |
2240 | struct GDS_DATACACHE_BlockData bd = { | 2176 | struct GDS_DATACACHE_BlockData bd = { |
2241 | .expiration_time = GNUNET_TIME_absolute_ntoh (prm->expiration_time), | 2177 | .expiration_time = GNUNET_TIME_absolute_ntoh (prm->expiration_time), |
2242 | .put_path = (const struct GNUNET_PeerIdentity *) &prm[1], | 2178 | .put_path = (const struct GNUNET_DHT_PathElement *) &prm[1], |
2243 | .put_path_length = ntohl (prm->put_path_length), | 2179 | .put_path_length = ntohl (prm->put_path_length), |
2244 | .type = ntohl (prm->type) | 2180 | .type = ntohl (prm->type) |
2245 | }; | 2181 | }; |
2246 | const struct GNUNET_PeerIdentity *get_path | 2182 | const struct GNUNET_DHT_PathElement *get_path |
2247 | = &bd.put_path[bd.put_path_length]; | 2183 | = &bd.put_path[bd.put_path_length]; |
2248 | 2184 | ||
2249 | /* parse and validate message */ | 2185 | /* parse and validate message */ |
@@ -2259,7 +2195,7 @@ handle_dht_p2p_result (void *cls, | |||
2259 | bd.data = (const void *) &get_path[get_path_length]; | 2195 | bd.data = (const void *) &get_path[get_path_length]; |
2260 | bd.data_size = msize - (sizeof(struct PeerResultMessage) | 2196 | bd.data_size = msize - (sizeof(struct PeerResultMessage) |
2261 | + (get_path_length + bd.put_path_length) | 2197 | + (get_path_length + bd.put_path_length) |
2262 | * sizeof(struct GNUNET_PeerIdentity)); | 2198 | * sizeof(struct GNUNET_DHT_PathElement)); |
2263 | GNUNET_STATISTICS_update (GDS_stats, | 2199 | GNUNET_STATISTICS_update (GDS_stats, |
2264 | "# P2P RESULTS received", | 2200 | "# P2P RESULTS received", |
2265 | 1, | 2201 | 1, |
@@ -2295,29 +2231,6 @@ handle_dht_p2p_result (void *cls, | |||
2295 | } | 2231 | } |
2296 | } | 2232 | } |
2297 | 2233 | ||
2298 | if (GNUNET_YES == log_route_details_stderr) | ||
2299 | { | ||
2300 | char *tmp; | ||
2301 | char *pp; | ||
2302 | char *gp; | ||
2303 | |||
2304 | gp = GNUNET_STRINGS_pp2s (get_path, | ||
2305 | get_path_length); | ||
2306 | pp = GNUNET_STRINGS_pp2s (bd.put_path, | ||
2307 | bd.put_path_length); | ||
2308 | tmp = GNUNET_strdup (GNUNET_i2s (&my_identity)); | ||
2309 | LOG_TRAFFIC (GNUNET_ERROR_TYPE_DEBUG, | ||
2310 | "R5N RESULT %s: %s->%s (GP: %s, PP: %s)\n", | ||
2311 | GNUNET_h2s (&prm->key), | ||
2312 | GNUNET_i2s (peer->id), | ||
2313 | tmp, | ||
2314 | gp, | ||
2315 | pp); | ||
2316 | GNUNET_free (gp); | ||
2317 | GNUNET_free (pp); | ||
2318 | GNUNET_free (tmp); | ||
2319 | } | ||
2320 | |||
2321 | /* if we got a HELLO, consider it for our own routing table */ | 2234 | /* if we got a HELLO, consider it for our own routing table */ |
2322 | if (GNUNET_BLOCK_TYPE_DHT_HELLO == bd.type) | 2235 | if (GNUNET_BLOCK_TYPE_DHT_HELLO == bd.type) |
2323 | { | 2236 | { |
@@ -2352,7 +2265,7 @@ handle_dht_p2p_result (void *cls, | |||
2352 | /* First, check if 'peer' is already on the path, and if | 2265 | /* First, check if 'peer' is already on the path, and if |
2353 | so, truncate it instead of expanding. */ | 2266 | so, truncate it instead of expanding. */ |
2354 | for (unsigned int i = 0; i <= get_path_length; i++) | 2267 | for (unsigned int i = 0; i <= get_path_length; i++) |
2355 | if (0 == GNUNET_memcmp (&get_path[i], | 2268 | if (0 == GNUNET_memcmp (&get_path[i].pred, |
2356 | peer->id)) | 2269 | peer->id)) |
2357 | { | 2270 | { |
2358 | process_reply_with_path (&bd, | 2271 | process_reply_with_path (&bd, |
@@ -2363,12 +2276,15 @@ handle_dht_p2p_result (void *cls, | |||
2363 | 2276 | ||
2364 | /* Need to append 'peer' to 'get_path' (normal case) */ | 2277 | /* Need to append 'peer' to 'get_path' (normal case) */ |
2365 | { | 2278 | { |
2366 | struct GNUNET_PeerIdentity xget_path[get_path_length + 1]; | 2279 | struct GNUNET_DHT_PathElement xget_path[get_path_length + 1]; |
2367 | 2280 | ||
2368 | GNUNET_memcpy (xget_path, | 2281 | GNUNET_memcpy (xget_path, |
2369 | get_path, | 2282 | get_path, |
2370 | get_path_length * sizeof(struct GNUNET_PeerIdentity)); | 2283 | get_path_length * sizeof(struct GNUNET_DHT_PathElement)); |
2371 | xget_path[get_path_length] = *peer->id; | 2284 | xget_path[get_path_length].pred = *peer->id; |
2285 | memset (&xget_path[get_path_length].sig, | ||
2286 | 0, | ||
2287 | sizeof (xget_path[get_path_length].sig)); | ||
2372 | process_reply_with_path (&bd, | 2288 | process_reply_with_path (&bd, |
2373 | &prm->key, | 2289 | &prm->key, |
2374 | get_path_length + 1, xget_path); | 2290 | get_path_length + 1, xget_path); |
@@ -2411,8 +2327,6 @@ GDS_NEIGHBOURS_init () | |||
2411 | "DHT", | 2327 | "DHT", |
2412 | "CACHE_RESULTS"); | 2328 | "CACHE_RESULTS"); |
2413 | 2329 | ||
2414 | log_route_details_stderr = | ||
2415 | (NULL != getenv ("GNUNET_DHT_ROUTE_DEBUG")) ? GNUNET_YES : GNUNET_NO; | ||
2416 | ats_ch = GNUNET_ATS_connectivity_init (GDS_cfg); | 2330 | ats_ch = GNUNET_ATS_connectivity_init (GDS_cfg); |
2417 | core_api = GNUNET_CORE_connect (GDS_cfg, | 2331 | core_api = GNUNET_CORE_connect (GDS_cfg, |
2418 | NULL, | 2332 | NULL, |
diff --git a/src/dht/gnunet-service-dht_neighbours.h b/src/dht/gnunet-service-dht_neighbours.h index 28468c740..35bbb125d 100644 --- a/src/dht/gnunet-service-dht_neighbours.h +++ b/src/dht/gnunet-service-dht_neighbours.h | |||
@@ -42,7 +42,7 @@ struct PeerInfo; | |||
42 | 42 | ||
43 | /** | 43 | /** |
44 | * Lookup peer by peer's identity. | 44 | * Lookup peer by peer's identity. |
45 | * | 45 | * |
46 | * @param target peer to look up | 46 | * @param target peer to look up |
47 | * @return NULL if we are not connected to @a target | 47 | * @return NULL if we are not connected to @a target |
48 | */ | 48 | */ |
@@ -118,7 +118,7 @@ GDS_NEIGHBOURS_handle_reply (struct PeerInfo *pi, | |||
118 | const struct GDS_DATACACHE_BlockData *bd, | 118 | const struct GDS_DATACACHE_BlockData *bd, |
119 | const struct GNUNET_HashCode *query_hash, | 119 | const struct GNUNET_HashCode *query_hash, |
120 | unsigned int get_path_length, | 120 | unsigned int get_path_length, |
121 | const struct GNUNET_PeerIdentity *get_path); | 121 | const struct GNUNET_DHT_PathElement *get_path); |
122 | 122 | ||
123 | 123 | ||
124 | /** | 124 | /** |
diff --git a/src/dht/gnunet-service-dht_routing.c b/src/dht/gnunet-service-dht_routing.c index ec36eae75..e7b5c3571 100644 --- a/src/dht/gnunet-service-dht_routing.c +++ b/src/dht/gnunet-service-dht_routing.c | |||
@@ -109,7 +109,7 @@ struct ProcessContext | |||
109 | /** | 109 | /** |
110 | * Path of the reply. | 110 | * Path of the reply. |
111 | */ | 111 | */ |
112 | const struct GNUNET_PeerIdentity *get_path; | 112 | const struct GNUNET_DHT_PathElement *get_path; |
113 | 113 | ||
114 | /** | 114 | /** |
115 | * Number of entries in @e get_path. | 115 | * Number of entries in @e get_path. |
@@ -181,7 +181,7 @@ process (void *cls, | |||
181 | case GNUNET_BLOCK_REPLY_TYPE_NOT_SUPPORTED: | 181 | case GNUNET_BLOCK_REPLY_TYPE_NOT_SUPPORTED: |
182 | { | 182 | { |
183 | struct PeerInfo *pi; | 183 | struct PeerInfo *pi; |
184 | 184 | ||
185 | GNUNET_STATISTICS_update (GDS_stats, | 185 | GNUNET_STATISTICS_update (GDS_stats, |
186 | "# Good REPLIES matched against routing table", | 186 | "# Good REPLIES matched against routing table", |
187 | 1, | 187 | 1, |
@@ -244,7 +244,7 @@ void | |||
244 | GDS_ROUTING_process (const struct GDS_DATACACHE_BlockData *bd, | 244 | GDS_ROUTING_process (const struct GDS_DATACACHE_BlockData *bd, |
245 | const struct GNUNET_HashCode *query_hash, | 245 | const struct GNUNET_HashCode *query_hash, |
246 | unsigned int get_path_length, | 246 | unsigned int get_path_length, |
247 | const struct GNUNET_PeerIdentity *get_path) | 247 | const struct GNUNET_DHT_PathElement *get_path) |
248 | { | 248 | { |
249 | struct ProcessContext pc = { | 249 | struct ProcessContext pc = { |
250 | .bd = bd, | 250 | .bd = bd, |
diff --git a/src/dht/gnunet-service-dht_routing.h b/src/dht/gnunet-service-dht_routing.h index 1a1514cc5..1e35f3dc0 100644 --- a/src/dht/gnunet-service-dht_routing.h +++ b/src/dht/gnunet-service-dht_routing.h | |||
@@ -47,7 +47,7 @@ void | |||
47 | GDS_ROUTING_process (const struct GDS_DATACACHE_BlockData *bd, | 47 | GDS_ROUTING_process (const struct GDS_DATACACHE_BlockData *bd, |
48 | const struct GNUNET_HashCode *query_hash, | 48 | const struct GNUNET_HashCode *query_hash, |
49 | unsigned int get_path_length, | 49 | unsigned int get_path_length, |
50 | const struct GNUNET_PeerIdentity *get_path); | 50 | const struct GNUNET_DHT_PathElement *get_path); |
51 | 51 | ||
52 | 52 | ||
53 | /** | 53 | /** |
diff --git a/src/dht/gnunet_dht_profiler.c b/src/dht/gnunet_dht_profiler.c index ba50c3d1a..bac101bdd 100644 --- a/src/dht/gnunet_dht_profiler.c +++ b/src/dht/gnunet_dht_profiler.c | |||
@@ -469,9 +469,9 @@ static void | |||
469 | get_iter (void *cls, | 469 | get_iter (void *cls, |
470 | struct GNUNET_TIME_Absolute exp, | 470 | struct GNUNET_TIME_Absolute exp, |
471 | const struct GNUNET_HashCode *key, | 471 | const struct GNUNET_HashCode *key, |
472 | const struct GNUNET_PeerIdentity *get_path, | 472 | const struct GNUNET_DHT_PathElement *get_path, |
473 | unsigned int get_path_length, | 473 | unsigned int get_path_length, |
474 | const struct GNUNET_PeerIdentity *put_path, | 474 | const struct GNUNET_DHT_PathElement *put_path, |
475 | unsigned int put_path_length, | 475 | unsigned int put_path_length, |
476 | enum GNUNET_BLOCK_Type type, | 476 | enum GNUNET_BLOCK_Type type, |
477 | size_t size, const void *data) | 477 | size_t size, const void *data) |
diff --git a/src/dht/test_dht_api.c b/src/dht/test_dht_api.c index 957c71d7f..4d557bba8 100644 --- a/src/dht/test_dht_api.c +++ b/src/dht/test_dht_api.c | |||
@@ -87,9 +87,9 @@ static void | |||
87 | test_get_iterator (void *cls, | 87 | test_get_iterator (void *cls, |
88 | struct GNUNET_TIME_Absolute exp, | 88 | struct GNUNET_TIME_Absolute exp, |
89 | const struct GNUNET_HashCode *key, | 89 | const struct GNUNET_HashCode *key, |
90 | const struct GNUNET_PeerIdentity *get_path, | 90 | const struct GNUNET_DHT_PathElement *get_path, |
91 | unsigned int get_path_length, | 91 | unsigned int get_path_length, |
92 | const struct GNUNET_PeerIdentity *put_path, | 92 | const struct GNUNET_DHT_PathElement *put_path, |
93 | unsigned int put_path_length, | 93 | unsigned int put_path_length, |
94 | enum GNUNET_BLOCK_Type type, | 94 | enum GNUNET_BLOCK_Type type, |
95 | size_t size, | 95 | size_t size, |
diff --git a/src/dht/test_dht_monitor.c b/src/dht/test_dht_monitor.c index 95fb37bcd..8af02ad8a 100644 --- a/src/dht/test_dht_monitor.c +++ b/src/dht/test_dht_monitor.c | |||
@@ -174,9 +174,9 @@ timeout_task_cb (void *cls) | |||
174 | static void | 174 | static void |
175 | dht_get_handler (void *cls, struct GNUNET_TIME_Absolute exp, | 175 | dht_get_handler (void *cls, struct GNUNET_TIME_Absolute exp, |
176 | const struct GNUNET_HashCode *key, | 176 | const struct GNUNET_HashCode *key, |
177 | const struct GNUNET_PeerIdentity *get_path, | 177 | const struct GNUNET_DHT_PathElement *get_path, |
178 | unsigned int get_path_length, | 178 | unsigned int get_path_length, |
179 | const struct GNUNET_PeerIdentity *put_path, | 179 | const struct GNUNET_DHT_PathElement *put_path, |
180 | unsigned int put_path_length, | 180 | unsigned int put_path_length, |
181 | enum GNUNET_BLOCK_Type type, | 181 | enum GNUNET_BLOCK_Type type, |
182 | size_t size, const void *data) | 182 | size_t size, const void *data) |
@@ -261,7 +261,7 @@ monitor_get_cb (void *cls, | |||
261 | uint32_t hop_count, | 261 | uint32_t hop_count, |
262 | uint32_t desired_replication_level, | 262 | uint32_t desired_replication_level, |
263 | unsigned int path_length, | 263 | unsigned int path_length, |
264 | const struct GNUNET_PeerIdentity *path, | 264 | const struct GNUNET_DHT_PathElement *path, |
265 | const struct GNUNET_HashCode *key) | 265 | const struct GNUNET_HashCode *key) |
266 | { | 266 | { |
267 | unsigned int i; | 267 | unsigned int i; |
@@ -298,7 +298,7 @@ monitor_put_cb (void *cls, | |||
298 | uint32_t hop_count, | 298 | uint32_t hop_count, |
299 | uint32_t desired_replication_level, | 299 | uint32_t desired_replication_level, |
300 | unsigned int path_length, | 300 | unsigned int path_length, |
301 | const struct GNUNET_PeerIdentity *path, | 301 | const struct GNUNET_DHT_PathElement *path, |
302 | struct GNUNET_TIME_Absolute exp, | 302 | struct GNUNET_TIME_Absolute exp, |
303 | const struct GNUNET_HashCode *key, | 303 | const struct GNUNET_HashCode *key, |
304 | const void *data, | 304 | const void *data, |
@@ -334,9 +334,9 @@ monitor_put_cb (void *cls, | |||
334 | static void | 334 | static void |
335 | monitor_res_cb (void *cls, | 335 | monitor_res_cb (void *cls, |
336 | enum GNUNET_BLOCK_Type type, | 336 | enum GNUNET_BLOCK_Type type, |
337 | const struct GNUNET_PeerIdentity *get_path, | 337 | const struct GNUNET_DHT_PathElement *get_path, |
338 | unsigned int get_path_length, | 338 | unsigned int get_path_length, |
339 | const struct GNUNET_PeerIdentity *put_path, | 339 | const struct GNUNET_DHT_PathElement *put_path, |
340 | unsigned int put_path_length, | 340 | unsigned int put_path_length, |
341 | struct GNUNET_TIME_Absolute exp, | 341 | struct GNUNET_TIME_Absolute exp, |
342 | const struct GNUNET_HashCode *key, | 342 | const struct GNUNET_HashCode *key, |
diff --git a/src/dht/test_dht_topo.c b/src/dht/test_dht_topo.c index 7f737ea03..dfe969bb9 100644 --- a/src/dht/test_dht_topo.c +++ b/src/dht/test_dht_topo.c | |||
@@ -302,9 +302,9 @@ static void | |||
302 | dht_get_handler (void *cls, | 302 | dht_get_handler (void *cls, |
303 | struct GNUNET_TIME_Absolute exp, | 303 | struct GNUNET_TIME_Absolute exp, |
304 | const struct GNUNET_HashCode *key, | 304 | const struct GNUNET_HashCode *key, |
305 | const struct GNUNET_PeerIdentity *get_path, | 305 | const struct GNUNET_DHT_PathElement *get_path, |
306 | unsigned int get_path_length, | 306 | unsigned int get_path_length, |
307 | const struct GNUNET_PeerIdentity *put_path, | 307 | const struct GNUNET_DHT_PathElement *put_path, |
308 | unsigned int put_path_length, | 308 | unsigned int put_path_length, |
309 | enum GNUNET_BLOCK_Type type, | 309 | enum GNUNET_BLOCK_Type type, |
310 | size_t size, | 310 | size_t size, |
diff --git a/src/fs/gnunet-service-fs_pr.c b/src/fs/gnunet-service-fs_pr.c index c3fe5ff58..beb29a506 100644 --- a/src/fs/gnunet-service-fs_pr.c +++ b/src/fs/gnunet-service-fs_pr.c | |||
@@ -1102,9 +1102,9 @@ static void | |||
1102 | handle_dht_reply (void *cls, | 1102 | handle_dht_reply (void *cls, |
1103 | struct GNUNET_TIME_Absolute exp, | 1103 | struct GNUNET_TIME_Absolute exp, |
1104 | const struct GNUNET_HashCode *key, | 1104 | const struct GNUNET_HashCode *key, |
1105 | const struct GNUNET_PeerIdentity *get_path, | 1105 | const struct GNUNET_DHT_PathElement *get_path, |
1106 | unsigned int get_path_length, | 1106 | unsigned int get_path_length, |
1107 | const struct GNUNET_PeerIdentity *put_path, | 1107 | const struct GNUNET_DHT_PathElement *put_path, |
1108 | unsigned int put_path_length, | 1108 | unsigned int put_path_length, |
1109 | enum GNUNET_BLOCK_Type type, | 1109 | enum GNUNET_BLOCK_Type type, |
1110 | size_t size, | 1110 | size_t size, |
diff --git a/src/gns/gnunet-service-gns_resolver.c b/src/gns/gnunet-service-gns_resolver.c index 958bf2e94..51e650b4f 100644 --- a/src/gns/gnunet-service-gns_resolver.c +++ b/src/gns/gnunet-service-gns_resolver.c | |||
@@ -2456,9 +2456,9 @@ static void | |||
2456 | handle_dht_response (void *cls, | 2456 | handle_dht_response (void *cls, |
2457 | struct GNUNET_TIME_Absolute exp, | 2457 | struct GNUNET_TIME_Absolute exp, |
2458 | const struct GNUNET_HashCode *key, | 2458 | const struct GNUNET_HashCode *key, |
2459 | const struct GNUNET_PeerIdentity *get_path, | 2459 | const struct GNUNET_DHT_PathElement *get_path, |
2460 | unsigned int get_path_length, | 2460 | unsigned int get_path_length, |
2461 | const struct GNUNET_PeerIdentity *put_path, | 2461 | const struct GNUNET_DHT_PathElement *put_path, |
2462 | unsigned int put_path_length, | 2462 | unsigned int put_path_length, |
2463 | enum GNUNET_BLOCK_Type type, | 2463 | enum GNUNET_BLOCK_Type type, |
2464 | size_t size, | 2464 | size_t size, |
diff --git a/src/include/gnunet_datacache_lib.h b/src/include/gnunet_datacache_lib.h index 519c36bb4..11076e3e7 100644 --- a/src/include/gnunet_datacache_lib.h +++ b/src/include/gnunet_datacache_lib.h | |||
@@ -39,6 +39,7 @@ | |||
39 | 39 | ||
40 | #include "gnunet_util_lib.h" | 40 | #include "gnunet_util_lib.h" |
41 | #include "gnunet_block_lib.h" | 41 | #include "gnunet_block_lib.h" |
42 | #include "gnunet_dht_service.h" | ||
42 | 43 | ||
43 | #ifdef __cplusplus | 44 | #ifdef __cplusplus |
44 | extern "C" | 45 | extern "C" |
@@ -89,15 +90,15 @@ GNUNET_DATACACHE_destroy (struct GNUNET_DATACACHE_Handle *h); | |||
89 | * @param path_info a path through the network | 90 | * @param path_info a path through the network |
90 | * @return #GNUNET_OK to continue iterating, #GNUNET_SYSERR to abort | 91 | * @return #GNUNET_OK to continue iterating, #GNUNET_SYSERR to abort |
91 | */ | 92 | */ |
92 | typedef int | 93 | typedef enum GNUNET_GenericReturnValue |
93 | (*GNUNET_DATACACHE_Iterator) (void *cls, | 94 | (*GNUNET_DATACACHE_Iterator)(void *cls, |
94 | const struct GNUNET_HashCode *key, | 95 | const struct GNUNET_HashCode *key, |
95 | size_t data_size, | 96 | size_t data_size, |
96 | const char *data, | 97 | const char *data, |
97 | enum GNUNET_BLOCK_Type type, | 98 | enum GNUNET_BLOCK_Type type, |
98 | struct GNUNET_TIME_Absolute exp, | 99 | struct GNUNET_TIME_Absolute exp, |
99 | unsigned int path_info_len, | 100 | unsigned int path_info_len, |
100 | const struct GNUNET_PeerIdentity *path_info); | 101 | const struct GNUNET_DHT_PathElement *path_info); |
101 | 102 | ||
102 | 103 | ||
103 | /** | 104 | /** |
@@ -114,7 +115,7 @@ typedef int | |||
114 | * @param path_info a path through the network | 115 | * @param path_info a path through the network |
115 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error, #GNUNET_NO if duplicate | 116 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error, #GNUNET_NO if duplicate |
116 | */ | 117 | */ |
117 | int | 118 | enum GNUNET_GenericReturnValue |
118 | GNUNET_DATACACHE_put (struct GNUNET_DATACACHE_Handle *h, | 119 | GNUNET_DATACACHE_put (struct GNUNET_DATACACHE_Handle *h, |
119 | const struct GNUNET_HashCode *key, | 120 | const struct GNUNET_HashCode *key, |
120 | uint32_t xor_distance, | 121 | uint32_t xor_distance, |
@@ -123,7 +124,7 @@ GNUNET_DATACACHE_put (struct GNUNET_DATACACHE_Handle *h, | |||
123 | enum GNUNET_BLOCK_Type type, | 124 | enum GNUNET_BLOCK_Type type, |
124 | struct GNUNET_TIME_Absolute discard_time, | 125 | struct GNUNET_TIME_Absolute discard_time, |
125 | unsigned int path_info_len, | 126 | unsigned int path_info_len, |
126 | const struct GNUNET_PeerIdentity *path_info); | 127 | const struct GNUNET_DHT_PathElement *path_info); |
127 | 128 | ||
128 | 129 | ||
129 | /** | 130 | /** |
diff --git a/src/include/gnunet_datacache_plugin.h b/src/include/gnunet_datacache_plugin.h index 5d5cac12c..24570be72 100644 --- a/src/include/gnunet_datacache_plugin.h +++ b/src/include/gnunet_datacache_plugin.h | |||
@@ -124,7 +124,7 @@ struct GNUNET_DATACACHE_PluginFunctions | |||
124 | enum GNUNET_BLOCK_Type type, | 124 | enum GNUNET_BLOCK_Type type, |
125 | struct GNUNET_TIME_Absolute discard_time, | 125 | struct GNUNET_TIME_Absolute discard_time, |
126 | unsigned int path_info_len, | 126 | unsigned int path_info_len, |
127 | const struct GNUNET_PeerIdentity *path_info); | 127 | const struct GNUNET_DHT_PathElement *path_info); |
128 | 128 | ||
129 | 129 | ||
130 | /** | 130 | /** |
diff --git a/src/include/gnunet_dht_service.h b/src/include/gnunet_dht_service.h index 15da9ecdd..d33ef2f0d 100644 --- a/src/include/gnunet_dht_service.h +++ b/src/include/gnunet_dht_service.h | |||
@@ -257,7 +257,9 @@ GNUNET_DHT_put_cancel (struct GNUNET_DHT_PutHandle *ph); | |||
257 | * @param get_path_length number of entries in @a get_path | 257 | * @param get_path_length number of entries in @a get_path |
258 | * @param put_path peers on the PUT path (or NULL if not recorded) | 258 | * @param put_path peers on the PUT path (or NULL if not recorded) |
259 | * [0] = origin, [length - 1] = datastore | 259 | * [0] = origin, [length - 1] = datastore |
260 | * @param put_path_length number of entries in @a put_path | 260 | * @param put_path_length number of entries in @a put_path, |
261 | * note that the last signature will be all zeros as | ||
262 | * we did not forward and thus did not sign! | ||
261 | * @param type type of the result | 263 | * @param type type of the result |
262 | * @param size number of bytes in @a data | 264 | * @param size number of bytes in @a data |
263 | * @param data pointer to the result data | 265 | * @param data pointer to the result data |
@@ -266,9 +268,9 @@ typedef void | |||
266 | (*GNUNET_DHT_GetIterator) (void *cls, | 268 | (*GNUNET_DHT_GetIterator) (void *cls, |
267 | struct GNUNET_TIME_Absolute exp, | 269 | struct GNUNET_TIME_Absolute exp, |
268 | const struct GNUNET_HashCode *key, | 270 | const struct GNUNET_HashCode *key, |
269 | const struct GNUNET_PeerIdentity *get_path, | 271 | const struct GNUNET_DHT_PathElement *get_path, |
270 | unsigned int get_path_length, | 272 | unsigned int get_path_length, |
271 | const struct GNUNET_PeerIdentity *put_path, | 273 | const struct GNUNET_DHT_PathElement *put_path, |
272 | unsigned int put_path_length, | 274 | unsigned int put_path_length, |
273 | enum GNUNET_BLOCK_Type type, | 275 | enum GNUNET_BLOCK_Type type, |
274 | size_t size, | 276 | size_t size, |
@@ -343,6 +345,8 @@ struct GNUNET_DHT_MonitorHandle; | |||
343 | * @param hop_count Hop count so far. | 345 | * @param hop_count Hop count so far. |
344 | * @param path_length number of entries in @a path (or 0 if not recorded). | 346 | * @param path_length number of entries in @a path (or 0 if not recorded). |
345 | * @param path peers on the GET path (or NULL if not recorded). | 347 | * @param path peers on the GET path (or NULL if not recorded). |
348 | * note that the last signature will be all zeros as | ||
349 | * we did not forward and thus did not sign! | ||
346 | * @param desired_replication_level Desired replication level. | 350 | * @param desired_replication_level Desired replication level. |
347 | * @param key Key of the requested data. | 351 | * @param key Key of the requested data. |
348 | */ | 352 | */ |
@@ -353,7 +357,7 @@ typedef void | |||
353 | uint32_t hop_count, | 357 | uint32_t hop_count, |
354 | uint32_t desired_replication_level, | 358 | uint32_t desired_replication_level, |
355 | unsigned int path_length, | 359 | unsigned int path_length, |
356 | const struct GNUNET_PeerIdentity *path, | 360 | const struct GNUNET_DHT_PathElement *path, |
357 | const struct GNUNET_HashCode *key); | 361 | const struct GNUNET_HashCode *key); |
358 | 362 | ||
359 | 363 | ||
@@ -363,6 +367,8 @@ typedef void | |||
363 | * @param cls Closure. | 367 | * @param cls Closure. |
364 | * @param type The type of data in the result. | 368 | * @param type The type of data in the result. |
365 | * @param get_path Peers on GET path (or NULL if not recorded). | 369 | * @param get_path Peers on GET path (or NULL if not recorded). |
370 | * note that the last signature will be all zeros as | ||
371 | * we did not forward and thus did not sign! | ||
366 | * @param get_path_length number of entries in @a get_path. | 372 | * @param get_path_length number of entries in @a get_path. |
367 | * @param put_path peers on the PUT path (or NULL if not recorded). | 373 | * @param put_path peers on the PUT path (or NULL if not recorded). |
368 | * @param put_path_length number of entries in @a get_path. | 374 | * @param put_path_length number of entries in @a get_path. |
@@ -374,9 +380,9 @@ typedef void | |||
374 | typedef void | 380 | typedef void |
375 | (*GNUNET_DHT_MonitorGetRespCB) (void *cls, | 381 | (*GNUNET_DHT_MonitorGetRespCB) (void *cls, |
376 | enum GNUNET_BLOCK_Type type, | 382 | enum GNUNET_BLOCK_Type type, |
377 | const struct GNUNET_PeerIdentity *get_path, | 383 | const struct GNUNET_DHT_PathElement *get_path, |
378 | unsigned int get_path_length, | 384 | unsigned int get_path_length, |
379 | const struct GNUNET_PeerIdentity *put_path, | 385 | const struct GNUNET_DHT_PathElement *put_path, |
380 | unsigned int put_path_length, | 386 | unsigned int put_path_length, |
381 | struct GNUNET_TIME_Absolute exp, | 387 | struct GNUNET_TIME_Absolute exp, |
382 | const struct GNUNET_HashCode *key, | 388 | const struct GNUNET_HashCode *key, |
@@ -393,6 +399,8 @@ typedef void | |||
393 | * @param hop_count Hop count so far. | 399 | * @param hop_count Hop count so far. |
394 | * @param path_length number of entries in @a path (or 0 if not recorded). | 400 | * @param path_length number of entries in @a path (or 0 if not recorded). |
395 | * @param path peers on the PUT path (or NULL if not recorded). | 401 | * @param path peers on the PUT path (or NULL if not recorded). |
402 | * note that the last signature will be all zeros as | ||
403 | * we did not forward and thus did not sign! | ||
396 | * @param desired_replication_level Desired replication level. | 404 | * @param desired_replication_level Desired replication level. |
397 | * @param exp Expiration time of the data. | 405 | * @param exp Expiration time of the data. |
398 | * @param key Key under which data is to be stored. | 406 | * @param key Key under which data is to be stored. |
@@ -406,7 +414,7 @@ typedef void | |||
406 | uint32_t hop_count, | 414 | uint32_t hop_count, |
407 | uint32_t desired_replication_level, | 415 | uint32_t desired_replication_level, |
408 | unsigned int path_length, | 416 | unsigned int path_length, |
409 | const struct GNUNET_PeerIdentity *path, | 417 | const struct GNUNET_DHT_PathElement *path, |
410 | struct GNUNET_TIME_Absolute exp, | 418 | struct GNUNET_TIME_Absolute exp, |
411 | const struct GNUNET_HashCode *key, | 419 | const struct GNUNET_HashCode *key, |
412 | const void *data, | 420 | const void *data, |
@@ -446,6 +454,18 @@ void | |||
446 | GNUNET_DHT_monitor_stop (struct GNUNET_DHT_MonitorHandle *handle); | 454 | GNUNET_DHT_monitor_stop (struct GNUNET_DHT_MonitorHandle *handle); |
447 | 455 | ||
448 | 456 | ||
457 | /** | ||
458 | * Convert a peer path to a human-readable string. | ||
459 | * | ||
460 | * @param path array of path elements to convert to a string | ||
461 | * @param num_pids length of the @a pids array | ||
462 | * @return string representing the array of @a pids | ||
463 | */ | ||
464 | char * | ||
465 | GNUNET_DHT_pp2s (const struct GNUNET_DHT_PathElement *path, | ||
466 | unsigned int path_len); | ||
467 | |||
468 | |||
449 | #if 0 /* keep Emacsens' auto-indent happy */ | 469 | #if 0 /* keep Emacsens' auto-indent happy */ |
450 | { | 470 | { |
451 | #endif | 471 | #endif |
diff --git a/src/include/gnunet_strings_lib.h b/src/include/gnunet_strings_lib.h index 2e0c720ee..ef9d5ac58 100644 --- a/src/include/gnunet_strings_lib.h +++ b/src/include/gnunet_strings_lib.h | |||
@@ -457,18 +457,6 @@ GNUNET_STRINGS_urldecode (const char *data, | |||
457 | 457 | ||
458 | 458 | ||
459 | /** | 459 | /** |
460 | * Convert a peer path to a human-readable string. | ||
461 | * | ||
462 | * @param pids array of PIDs to convert to a string | ||
463 | * @param num_pids length of the @a pids array | ||
464 | * @return string representing the array of @a pids | ||
465 | */ | ||
466 | char * | ||
467 | GNUNET_STRINGS_pp2s (const struct GNUNET_PeerIdentity *pids, | ||
468 | unsigned int num_pids); | ||
469 | |||
470 | |||
471 | /** | ||
472 | * Parse a path that might be an URI. | 460 | * Parse a path that might be an URI. |
473 | * | 461 | * |
474 | * @param path path to parse. Must be NULL-terminated. | 462 | * @param path path to parse. Must be NULL-terminated. |
diff --git a/src/pt/gnunet-daemon-pt.c b/src/pt/gnunet-daemon-pt.c index da4374223..b79a8e464 100644 --- a/src/pt/gnunet-daemon-pt.c +++ b/src/pt/gnunet-daemon-pt.c | |||
@@ -1140,9 +1140,9 @@ static void | |||
1140 | handle_dht_result (void *cls, | 1140 | handle_dht_result (void *cls, |
1141 | struct GNUNET_TIME_Absolute exp, | 1141 | struct GNUNET_TIME_Absolute exp, |
1142 | const struct GNUNET_HashCode *key, | 1142 | const struct GNUNET_HashCode *key, |
1143 | const struct GNUNET_PeerIdentity *get_path, | 1143 | const struct GNUNET_DHT_PathElement *get_path, |
1144 | unsigned int get_path_length, | 1144 | unsigned int get_path_length, |
1145 | const struct GNUNET_PeerIdentity *put_path, | 1145 | const struct GNUNET_DHT_PathElement *put_path, |
1146 | unsigned int put_path_length, | 1146 | unsigned int put_path_length, |
1147 | enum GNUNET_BLOCK_Type type, | 1147 | enum GNUNET_BLOCK_Type type, |
1148 | size_t size, const void *data) | 1148 | size_t size, const void *data) |
diff --git a/src/regex/gnunet-regex-profiler.c b/src/regex/gnunet-regex-profiler.c index bd223ae8e..75a1d2f99 100644 --- a/src/regex/gnunet-regex-profiler.c +++ b/src/regex/gnunet-regex-profiler.c | |||
@@ -23,11 +23,7 @@ | |||
23 | * @brief Regex profiler for testing distributed regex use. | 23 | * @brief Regex profiler for testing distributed regex use. |
24 | * @author Bartlomiej Polot | 24 | * @author Bartlomiej Polot |
25 | * @author Maximilian Szengel | 25 | * @author Maximilian Szengel |
26 | * | ||
27 | */ | 26 | */ |
28 | |||
29 | #include <string.h> | ||
30 | |||
31 | #include "platform.h" | 27 | #include "platform.h" |
32 | #include "gnunet_applications.h" | 28 | #include "gnunet_applications.h" |
33 | #include "gnunet_util_lib.h" | 29 | #include "gnunet_util_lib.h" |
@@ -727,9 +723,9 @@ find_string (void *cls); | |||
727 | static void | 723 | static void |
728 | regex_found_handler (void *cls, | 724 | regex_found_handler (void *cls, |
729 | const struct GNUNET_PeerIdentity *id, | 725 | const struct GNUNET_PeerIdentity *id, |
730 | const struct GNUNET_PeerIdentity *get_path, | 726 | const struct GNUNET_DHT_PathElement *get_path, |
731 | unsigned int get_path_length, | 727 | unsigned int get_path_length, |
732 | const struct GNUNET_PeerIdentity *put_path, | 728 | const struct GNUNET_DHT_PathElement *put_path, |
733 | unsigned int put_path_length) | 729 | unsigned int put_path_length) |
734 | { | 730 | { |
735 | struct RegexPeer *peer = cls; | 731 | struct RegexPeer *peer = cls; |
@@ -1558,53 +1554,56 @@ int | |||
1558 | main (int argc, char *const *argv) | 1554 | main (int argc, char *const *argv) |
1559 | { | 1555 | { |
1560 | struct GNUNET_GETOPT_CommandLineOption options[] = { | 1556 | struct GNUNET_GETOPT_CommandLineOption options[] = { |
1561 | GNUNET_GETOPT_option_filename ('o', | 1557 | GNUNET_GETOPT_option_filename ( |
1562 | "output-file", | 1558 | 'o', |
1563 | "FILENAME", | 1559 | "output-file", |
1564 | gettext_noop ( | 1560 | "FILENAME", |
1565 | "name of the file for writing statistics"), | 1561 | gettext_noop ( |
1566 | &data_filename), | 1562 | "name of the file for writing statistics"), |
1567 | 1563 | &data_filename), | |
1568 | GNUNET_GETOPT_option_relative_time ('t', | 1564 | GNUNET_GETOPT_option_relative_time ( |
1569 | "matching-timeout", | 1565 | 't', |
1570 | "TIMEOUT", | 1566 | "matching-timeout", |
1571 | gettext_noop ( | 1567 | "TIMEOUT", |
1572 | "wait TIMEOUT before ending the experiment"), | 1568 | gettext_noop ( |
1573 | &search_timeout_time), | 1569 | "wait TIMEOUT before ending the experiment"), |
1574 | 1570 | &search_timeout_time), | |
1575 | GNUNET_GETOPT_option_filename ('p', | 1571 | GNUNET_GETOPT_option_filename ( |
1576 | "policy-dir", | 1572 | 'p', |
1577 | "DIRECTORY", | 1573 | "policy-dir", |
1578 | gettext_noop ("directory with policy files"), | 1574 | "DIRECTORY", |
1579 | &policy_dir), | 1575 | gettext_noop ("directory with policy files"), |
1580 | 1576 | &policy_dir), | |
1581 | 1577 | GNUNET_GETOPT_option_filename ( | |
1582 | GNUNET_GETOPT_option_filename ('s', | 1578 | 's', |
1583 | "strings-file", | 1579 | "strings-file", |
1584 | "FILENAME", | 1580 | "FILENAME", |
1585 | gettext_noop ( | 1581 | gettext_noop ( |
1586 | "name of file with input strings"), | 1582 | "name of file with input strings"), |
1587 | &strings_file), | 1583 | &strings_file), |
1588 | 1584 | GNUNET_GETOPT_option_filename ( | |
1589 | GNUNET_GETOPT_option_filename ('H', | 1585 | 'H', |
1590 | "hosts-file", | 1586 | "hosts-file", |
1591 | "FILENAME", | 1587 | "FILENAME", |
1592 | gettext_noop ( | 1588 | gettext_noop ( |
1593 | "name of file with hosts' names"), | 1589 | "name of file with hosts' names"), |
1594 | &hosts_file), | 1590 | &hosts_file), |
1595 | 1591 | ||
1596 | GNUNET_GETOPT_OPTION_END | 1592 | GNUNET_GETOPT_OPTION_END |
1597 | }; | 1593 | }; |
1598 | int ret; | 1594 | int ret; |
1599 | 1595 | ||
1600 | if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv)) | 1596 | if (GNUNET_OK != |
1597 | GNUNET_STRINGS_get_utf8_args (argc, argv, | ||
1598 | &argc, &argv)) | ||
1601 | return 2; | 1599 | return 2; |
1602 | result = GNUNET_SYSERR; | 1600 | result = GNUNET_SYSERR; |
1603 | ret = | 1601 | ret = |
1604 | GNUNET_PROGRAM_run (argc, argv, | 1602 | GNUNET_PROGRAM_run (argc, argv, |
1605 | "gnunet-regex-profiler", | 1603 | "gnunet-regex-profiler", |
1606 | _ ("Profiler for regex"), | 1604 | _ ("Profiler for regex"), |
1607 | options, &run, NULL); | 1605 | options, |
1606 | &run, NULL); | ||
1608 | if (GNUNET_OK != ret) | 1607 | if (GNUNET_OK != ret) |
1609 | return ret; | 1608 | return ret; |
1610 | if (GNUNET_OK != result) | 1609 | if (GNUNET_OK != result) |
diff --git a/src/regex/gnunet-service-regex.c b/src/regex/gnunet-service-regex.c index 7a5cc1f05..deaa6112e 100644 --- a/src/regex/gnunet-service-regex.c +++ b/src/regex/gnunet-service-regex.c | |||
@@ -196,9 +196,9 @@ handle_announce (void *cls, | |||
196 | static void | 196 | static void |
197 | handle_search_result (void *cls, | 197 | handle_search_result (void *cls, |
198 | const struct GNUNET_PeerIdentity *id, | 198 | const struct GNUNET_PeerIdentity *id, |
199 | const struct GNUNET_PeerIdentity *get_path, | 199 | const struct GNUNET_DHT_PathElement *get_path, |
200 | unsigned int get_path_length, | 200 | unsigned int get_path_length, |
201 | const struct GNUNET_PeerIdentity *put_path, | 201 | const struct GNUNET_DHT_PathElement *put_path, |
202 | unsigned int put_path_length) | 202 | unsigned int put_path_length) |
203 | { | 203 | { |
204 | struct ClientEntry *ce = cls; | 204 | struct ClientEntry *ce = cls; |
@@ -209,15 +209,15 @@ handle_search_result (void *cls, | |||
209 | 209 | ||
210 | if ((get_path_length >= 65536) || | 210 | if ((get_path_length >= 65536) || |
211 | (put_path_length >= 65536) || | 211 | (put_path_length >= 65536) || |
212 | ( ((get_path_length + put_path_length) * sizeof(struct | 212 | ( ((get_path_length + put_path_length) |
213 | GNUNET_PeerIdentity)) | 213 | * sizeof(struct GNUNET_PeerIdentity)) |
214 | + sizeof(struct ResultMessage) >= GNUNET_MAX_MESSAGE_SIZE) ) | 214 | + sizeof(struct ResultMessage) >= GNUNET_MAX_MESSAGE_SIZE) ) |
215 | { | 215 | { |
216 | GNUNET_break (0); | 216 | GNUNET_break (0); |
217 | return; | 217 | return; |
218 | } | 218 | } |
219 | size = (get_path_length + put_path_length) * sizeof(struct | 219 | size = (get_path_length + put_path_length) |
220 | GNUNET_PeerIdentity); | 220 | * sizeof(struct GNUNET_PeerIdentity); |
221 | env = GNUNET_MQ_msg_extra (result, | 221 | env = GNUNET_MQ_msg_extra (result, |
222 | size, | 222 | size, |
223 | GNUNET_MESSAGE_TYPE_REGEX_RESULT); | 223 | GNUNET_MESSAGE_TYPE_REGEX_RESULT); |
@@ -225,12 +225,10 @@ handle_search_result (void *cls, | |||
225 | result->put_path_length = htons ((uint16_t) put_path_length); | 225 | result->put_path_length = htons ((uint16_t) put_path_length); |
226 | result->id = *id; | 226 | result->id = *id; |
227 | gp = &result->id; | 227 | gp = &result->id; |
228 | GNUNET_memcpy (&gp[1], | 228 | for (unsigned int i = 0; i<get_path_length; i++) |
229 | get_path, | 229 | gp[i + 1] = get_path[i].pred; |
230 | get_path_length * sizeof(struct GNUNET_PeerIdentity)); | 230 | for (unsigned int i = 0; i<put_path_length; i++) |
231 | GNUNET_memcpy (&gp[1 + get_path_length], | 231 | gp[i + get_path_length + 1] = put_path[i].pred; |
232 | put_path, | ||
233 | put_path_length * sizeof(struct GNUNET_PeerIdentity)); | ||
234 | GNUNET_MQ_send (ce->mq, | 232 | GNUNET_MQ_send (ce->mq, |
235 | env); | 233 | env); |
236 | } | 234 | } |
diff --git a/src/regex/regex_internal.h b/src/regex/regex_internal.h index 8f29cff33..5b434b30c 100644 --- a/src/regex/regex_internal.h +++ b/src/regex/regex_internal.h | |||
@@ -340,10 +340,10 @@ REGEX_INTERNAL_construct_nfa (const char *regex, const size_t len); | |||
340 | * | 340 | * |
341 | * @return GNUNET_YES to proceed traversal, GNUNET_NO to stop. | 341 | * @return GNUNET_YES to proceed traversal, GNUNET_NO to stop. |
342 | */ | 342 | */ |
343 | typedef int (*REGEX_INTERNAL_traverse_check) (void *cls, | 343 | typedef int |
344 | struct REGEX_INTERNAL_State *s, | 344 | (*REGEX_INTERNAL_traverse_check) (void *cls, |
345 | struct REGEX_INTERNAL_Transition * | 345 | struct REGEX_INTERNAL_State *s, |
346 | t); | 346 | struct REGEX_INTERNAL_Transition *t); |
347 | 347 | ||
348 | 348 | ||
349 | /** | 349 | /** |
@@ -353,9 +353,10 @@ typedef int (*REGEX_INTERNAL_traverse_check) (void *cls, | |||
353 | * @param count current count of the state, from 0 to a->state_count -1. | 353 | * @param count current count of the state, from 0 to a->state_count -1. |
354 | * @param s state. | 354 | * @param s state. |
355 | */ | 355 | */ |
356 | typedef void (*REGEX_INTERNAL_traverse_action) (void *cls, | 356 | typedef void |
357 | const unsigned int count, | 357 | (*REGEX_INTERNAL_traverse_action) (void *cls, |
358 | struct REGEX_INTERNAL_State *s); | 358 | const unsigned int count, |
359 | struct REGEX_INTERNAL_State *s); | ||
359 | 360 | ||
360 | 361 | ||
361 | /** | 362 | /** |
diff --git a/src/regex/regex_internal_dht.c b/src/regex/regex_internal_dht.c index 3fb74c319..2248de1f1 100644 --- a/src/regex/regex_internal_dht.c +++ b/src/regex/regex_internal_dht.c | |||
@@ -384,9 +384,9 @@ regex_next_edge (const struct RegexBlock *block, | |||
384 | static void | 384 | static void |
385 | dht_get_string_accept_handler (void *cls, struct GNUNET_TIME_Absolute exp, | 385 | dht_get_string_accept_handler (void *cls, struct GNUNET_TIME_Absolute exp, |
386 | const struct GNUNET_HashCode *key, | 386 | const struct GNUNET_HashCode *key, |
387 | const struct GNUNET_PeerIdentity *get_path, | 387 | const struct GNUNET_DHT_PathElement *get_path, |
388 | unsigned int get_path_length, | 388 | unsigned int get_path_length, |
389 | const struct GNUNET_PeerIdentity *put_path, | 389 | const struct GNUNET_DHT_PathElement *put_path, |
390 | unsigned int put_path_length, | 390 | unsigned int put_path_length, |
391 | enum GNUNET_BLOCK_Type type, | 391 | enum GNUNET_BLOCK_Type type, |
392 | size_t size, const void *data) | 392 | size_t size, const void *data) |
@@ -464,9 +464,9 @@ regex_find_path (const struct GNUNET_HashCode *key, | |||
464 | static void | 464 | static void |
465 | dht_get_string_handler (void *cls, struct GNUNET_TIME_Absolute exp, | 465 | dht_get_string_handler (void *cls, struct GNUNET_TIME_Absolute exp, |
466 | const struct GNUNET_HashCode *key, | 466 | const struct GNUNET_HashCode *key, |
467 | const struct GNUNET_PeerIdentity *get_path, | 467 | const struct GNUNET_DHT_PathElement *get_path, |
468 | unsigned int get_path_length, | 468 | unsigned int get_path_length, |
469 | const struct GNUNET_PeerIdentity *put_path, | 469 | const struct GNUNET_DHT_PathElement *put_path, |
470 | unsigned int put_path_length, | 470 | unsigned int put_path_length, |
471 | enum GNUNET_BLOCK_Type type, | 471 | enum GNUNET_BLOCK_Type type, |
472 | size_t size, const void *data) | 472 | size_t size, const void *data) |
diff --git a/src/regex/regex_internal_lib.h b/src/regex/regex_internal_lib.h index 94fac19f9..9baf84995 100644 --- a/src/regex/regex_internal_lib.h +++ b/src/regex/regex_internal_lib.h | |||
@@ -221,9 +221,9 @@ REGEX_INTERNAL_announce_cancel (struct REGEX_INTERNAL_Announcement *h); | |||
221 | typedef void | 221 | typedef void |
222 | (*REGEX_INTERNAL_Found)(void *cls, | 222 | (*REGEX_INTERNAL_Found)(void *cls, |
223 | const struct GNUNET_PeerIdentity *id, | 223 | const struct GNUNET_PeerIdentity *id, |
224 | const struct GNUNET_PeerIdentity *get_path, | 224 | const struct GNUNET_DHT_PathElement *get_path, |
225 | unsigned int get_path_length, | 225 | unsigned int get_path_length, |
226 | const struct GNUNET_PeerIdentity *put_path, | 226 | const struct GNUNET_DHT_PathElement *put_path, |
227 | unsigned int put_path_length); | 227 | unsigned int put_path_length); |
228 | 228 | ||
229 | 229 | ||
diff --git a/src/util/strings.c b/src/util/strings.c index db672da87..76125b92e 100644 --- a/src/util/strings.c +++ b/src/util/strings.c | |||
@@ -69,29 +69,6 @@ GNUNET_STRINGS_buffer_fill (char *buffer, | |||
69 | } | 69 | } |
70 | 70 | ||
71 | 71 | ||
72 | char * | ||
73 | GNUNET_STRINGS_pp2s (const struct GNUNET_PeerIdentity *pids, | ||
74 | unsigned int num_pids) | ||
75 | { | ||
76 | char *buf; | ||
77 | size_t off; | ||
78 | size_t plen = num_pids * 5 + 1; | ||
79 | |||
80 | GNUNET_assert (num_pids < UINT32_MAX / 5); | ||
81 | off = 0; | ||
82 | buf = GNUNET_malloc (plen); | ||
83 | for (unsigned int i = 0; i < num_pids; i++) | ||
84 | { | ||
85 | off += GNUNET_snprintf (&buf[off], | ||
86 | plen - off, | ||
87 | "%s%s", | ||
88 | GNUNET_i2s (&pids[i]), | ||
89 | (i == num_pids - 1) ? "" : "-"); | ||
90 | } | ||
91 | return buf; | ||
92 | } | ||
93 | |||
94 | |||
95 | unsigned int | 72 | unsigned int |
96 | GNUNET_STRINGS_buffer_tokenize (const char *buffer, | 73 | GNUNET_STRINGS_buffer_tokenize (const char *buffer, |
97 | size_t size, | 74 | size_t size, |