diff options
Diffstat (limited to 'src/dht/gnunet-service-dht_routing.c')
-rw-r--r-- | src/dht/gnunet-service-dht_routing.c | 44 |
1 files changed, 29 insertions, 15 deletions
diff --git a/src/dht/gnunet-service-dht_routing.c b/src/dht/gnunet-service-dht_routing.c index 48bece35e..978c46d73 100644 --- a/src/dht/gnunet-service-dht_routing.c +++ b/src/dht/gnunet-service-dht_routing.c | |||
@@ -160,7 +160,9 @@ struct ProcessContext | |||
160 | * #GNUNET_SYSERR if the result is malformed or type unsupported | 160 | * #GNUNET_SYSERR if the result is malformed or type unsupported |
161 | */ | 161 | */ |
162 | static int | 162 | static int |
163 | process (void *cls, const struct GNUNET_HashCode * key, void *value) | 163 | process (void *cls, |
164 | const struct GNUNET_HashCode *key, | ||
165 | void *value) | ||
164 | { | 166 | { |
165 | struct ProcessContext *pc = cls; | 167 | struct ProcessContext *pc = cls; |
166 | struct RecentRequest *rr = value; | 168 | struct RecentRequest *rr = value; |
@@ -170,7 +172,8 @@ process (void *cls, const struct GNUNET_HashCode * key, void *value) | |||
170 | struct GNUNET_HashCode hc; | 172 | struct GNUNET_HashCode hc; |
171 | const struct GNUNET_HashCode *eval_key; | 173 | const struct GNUNET_HashCode *eval_key; |
172 | 174 | ||
173 | if ((rr->type != GNUNET_BLOCK_TYPE_ANY) && (rr->type != pc->type)) | 175 | if ( (rr->type != GNUNET_BLOCK_TYPE_ANY) && |
176 | (rr->type != pc->type) ) | ||
174 | return GNUNET_OK; /* type missmatch */ | 177 | return GNUNET_OK; /* type missmatch */ |
175 | 178 | ||
176 | if (0 != (rr->options & GNUNET_DHT_RO_RECORD_ROUTE)) | 179 | if (0 != (rr->options & GNUNET_DHT_RO_RECORD_ROUTE)) |
@@ -183,23 +186,26 @@ process (void *cls, const struct GNUNET_HashCode * key, void *value) | |||
183 | gpl = 0; | 186 | gpl = 0; |
184 | ppl = 0; | 187 | ppl = 0; |
185 | } | 188 | } |
186 | if ((0 != (rr->options & GNUNET_DHT_RO_FIND_PEER)) && | 189 | if ( (0 != (rr->options & GNUNET_DHT_RO_FIND_PEER)) && |
187 | (pc->type == GNUNET_BLOCK_TYPE_DHT_HELLO)) | 190 | (pc->type == GNUNET_BLOCK_TYPE_DHT_HELLO) ) |
188 | { | 191 | { |
189 | /* key may not match HELLO, which is OK since | 192 | /* key may not match HELLO, which is OK since |
190 | * the search is approximate. Still, the evaluation | 193 | * the search is approximate. Still, the evaluation |
191 | * would fail since the match is not exact. So | 194 | * would fail since the match is not exact. So |
192 | * we fake it by changing the key to the actual PID ... */ | 195 | * we fake it by changing the key to the actual PID ... */ |
193 | GNUNET_BLOCK_get_key (GDS_block_context, GNUNET_BLOCK_TYPE_DHT_HELLO, | 196 | GNUNET_BLOCK_get_key (GDS_block_context, |
194 | pc->data, pc->data_size, &hc); | 197 | GNUNET_BLOCK_TYPE_DHT_HELLO, |
198 | pc->data, | ||
199 | pc->data_size, | ||
200 | &hc); | ||
195 | eval_key = &hc; | 201 | eval_key = &hc; |
196 | } | 202 | } |
197 | else | 203 | else |
198 | { | 204 | { |
199 | eval_key = key; | 205 | eval_key = key; |
200 | } | 206 | } |
201 | eval = | 207 | eval |
202 | GNUNET_BLOCK_evaluate (GDS_block_context, | 208 | = GNUNET_BLOCK_evaluate (GDS_block_context, |
203 | pc->type, | 209 | pc->type, |
204 | GNUNET_BLOCK_EO_NONE, | 210 | GNUNET_BLOCK_EO_NONE, |
205 | eval_key, | 211 | eval_key, |
@@ -308,7 +314,10 @@ GDS_ROUTING_process (void *cls, | |||
308 | pc.data_size = 0; | 314 | pc.data_size = 0; |
309 | pc.data = ""; /* something not null */ | 315 | pc.data = ""; /* something not null */ |
310 | } | 316 | } |
311 | GNUNET_CONTAINER_multihashmap_get_multiple (recent_map, key, &process, &pc); | 317 | GNUNET_CONTAINER_multihashmap_get_multiple (recent_map, |
318 | key, | ||
319 | &process, | ||
320 | &pc); | ||
312 | } | 321 | } |
313 | 322 | ||
314 | 323 | ||
@@ -345,11 +354,13 @@ expire_oldest_entry () | |||
345 | * @param cls the new 'struct RecentRequest' (to discard upon successful combination) | 354 | * @param cls the new 'struct RecentRequest' (to discard upon successful combination) |
346 | * @param key the query | 355 | * @param key the query |
347 | * @param value the existing 'struct RecentRequest' (to update upon successful combination) | 356 | * @param value the existing 'struct RecentRequest' (to update upon successful combination) |
348 | * @return GNUNET_OK (continue to iterate), | 357 | * @return #GNUNET_OK (continue to iterate), |
349 | * GNUNET_SYSERR if the request was successfully combined | 358 | * #GNUNET_SYSERR if the request was successfully combined |
350 | */ | 359 | */ |
351 | static int | 360 | static int |
352 | try_combine_recent (void *cls, const struct GNUNET_HashCode * key, void *value) | 361 | try_combine_recent (void *cls, |
362 | const struct GNUNET_HashCode *key, | ||
363 | void *value) | ||
353 | { | 364 | { |
354 | struct RecentRequest *in = cls; | 365 | struct RecentRequest *in = cls; |
355 | struct RecentRequest *rr = value; | 366 | struct RecentRequest *rr = value; |
@@ -396,7 +407,8 @@ void | |||
396 | GDS_ROUTING_add (const struct GNUNET_PeerIdentity *sender, | 407 | GDS_ROUTING_add (const struct GNUNET_PeerIdentity *sender, |
397 | enum GNUNET_BLOCK_Type type, | 408 | enum GNUNET_BLOCK_Type type, |
398 | enum GNUNET_DHT_RouteOption options, | 409 | enum GNUNET_DHT_RouteOption options, |
399 | const struct GNUNET_HashCode * key, const void *xquery, | 410 | const struct GNUNET_HashCode *key, |
411 | const void *xquery, | ||
400 | size_t xquery_size, | 412 | size_t xquery_size, |
401 | const struct GNUNET_CONTAINER_BloomFilter *reply_bf, | 413 | const struct GNUNET_CONTAINER_BloomFilter *reply_bf, |
402 | uint32_t reply_bf_mutator) | 414 | uint32_t reply_bf_mutator) |
@@ -419,8 +431,10 @@ GDS_ROUTING_add (const struct GNUNET_PeerIdentity *sender, | |||
419 | recent_req->xquery_size = xquery_size; | 431 | recent_req->xquery_size = xquery_size; |
420 | recent_req->reply_bf_mutator = reply_bf_mutator; | 432 | recent_req->reply_bf_mutator = reply_bf_mutator; |
421 | if (GNUNET_SYSERR == | 433 | if (GNUNET_SYSERR == |
422 | GNUNET_CONTAINER_multihashmap_get_multiple (recent_map, key, | 434 | GNUNET_CONTAINER_multihashmap_get_multiple (recent_map, |
423 | &try_combine_recent, recent_req)) | 435 | key, |
436 | &try_combine_recent, | ||
437 | recent_req)) | ||
424 | { | 438 | { |
425 | GNUNET_STATISTICS_update (GDS_stats, | 439 | GNUNET_STATISTICS_update (GDS_stats, |
426 | gettext_noop | 440 | gettext_noop |