aboutsummaryrefslogtreecommitdiff
path: root/src/transport/gnunet-service-transport_validation.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-08-06 16:48:46 +0000
committerChristian Grothoff <christian@grothoff.org>2011-08-06 16:48:46 +0000
commit10120fb0e995a8607898347ea48e12ca907e8840 (patch)
tree75ad18bc9c1d5df8c384f1a854dc421ce62bb5bc /src/transport/gnunet-service-transport_validation.c
parent0b864bf9aa08f0c21085d56c925100c4f4eb1c72 (diff)
downloadgnunet-10120fb0e995a8607898347ea48e12ca907e8840.tar.gz
gnunet-10120fb0e995a8607898347ea48e12ca907e8840.zip
remember notifies
Diffstat (limited to 'src/transport/gnunet-service-transport_validation.c')
-rw-r--r--src/transport/gnunet-service-transport_validation.c25
1 files changed, 23 insertions, 2 deletions
diff --git a/src/transport/gnunet-service-transport_validation.c b/src/transport/gnunet-service-transport_validation.c
index 9b62881d6..23140b7c3 100644
--- a/src/transport/gnunet-service-transport_validation.c
+++ b/src/transport/gnunet-service-transport_validation.c
@@ -177,6 +177,11 @@ static struct CheckHelloValidatedContext *chvc_tail;
177 */ 177 */
178static struct GNUNET_CONTAINER_MultiHashMap *validation_map; 178static struct GNUNET_CONTAINER_MultiHashMap *validation_map;
179 179
180/**
181 * Map of PeerIdentities to 'struct GST_ValidationIteratorContext's.
182 */
183static struct GNUNET_CONTAINER_MultiHashMap *notify_map;
184
180 185
181/** 186/**
182 * Start the validation subsystem. 187 * Start the validation subsystem.
@@ -185,6 +190,7 @@ void
185GST_validation_start () 190GST_validation_start ()
186{ 191{
187 validation_map = GNUNET_CONTAINER_multihashmap_create (VALIDATION_MAP_SIZE); 192 validation_map = GNUNET_CONTAINER_multihashmap_create (VALIDATION_MAP_SIZE);
193 notify_map = GNUNET_CONTAINER_multihashmap_create (VALIDATION_MAP_SIZE);
188} 194}
189 195
190 196
@@ -227,6 +233,9 @@ GST_validation_stop ()
227 NULL); 233 NULL);
228 GNUNET_CONTAINER_multihashmap_destroy (validation_map); 234 GNUNET_CONTAINER_multihashmap_destroy (validation_map);
229 validation_map = NULL; 235 validation_map = NULL;
236 GNUNET_assert (GNUNET_CONTAINER_multihashmap_size (notify_map) == 0);
237 GNUNET_CONTAINER_multihashmap_destroy (notify_map);
238 notify_map = NULL;
230 while (NULL != (chvc = chvc_head)) 239 while (NULL != (chvc = chvc_head))
231 { 240 {
232 GNUNET_CONTAINER_DLL_remove (chvc_head, 241 GNUNET_CONTAINER_DLL_remove (chvc_head,
@@ -482,6 +491,11 @@ struct GST_ValidationIteratorContext
482 * Closure for 'cb'. 491 * Closure for 'cb'.
483 */ 492 */
484 void *cb_cls; 493 void *cb_cls;
494
495 /**
496 * Which peer are we monitoring?
497 */
498 struct GNUNET_PeerIdentity target;
485}; 499};
486 500
487 501
@@ -535,6 +549,7 @@ GST_validation_get_addresses (const struct GNUNET_PeerIdentity *target,
535 vic = GNUNET_malloc (sizeof (struct GST_ValidationIteratorContext)); 549 vic = GNUNET_malloc (sizeof (struct GST_ValidationIteratorContext));
536 vic->cb = cb; 550 vic->cb = cb;
537 vic->cb_cls = cb_cls; 551 vic->cb_cls = cb_cls;
552 vic->target = *target;
538 GNUNET_CONTAINER_multihashmap_get_multiple (validation_map, 553 GNUNET_CONTAINER_multihashmap_get_multiple (validation_map,
539 &target->hashPubKey, 554 &target->hashPubKey,
540 &iterate_addresses, 555 &iterate_addresses,
@@ -544,7 +559,10 @@ GST_validation_get_addresses (const struct GNUNET_PeerIdentity *target,
544 GNUNET_free (vic); 559 GNUNET_free (vic);
545 return NULL; 560 return NULL;
546 } 561 }
547 /* FIXME: install 'vic' somewhere */ 562 GNUNET_CONTAINER_multihashmap_put (notify_map,
563 &target->hashPubKey,
564 vic,
565 GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
548 return vic; 566 return vic;
549} 567}
550 568
@@ -557,7 +575,10 @@ GST_validation_get_addresses (const struct GNUNET_PeerIdentity *target,
557void 575void
558GST_validation_get_addresses_cancel (struct GST_ValidationIteratorContext *ctx) 576GST_validation_get_addresses_cancel (struct GST_ValidationIteratorContext *ctx)
559{ 577{
560 /* FIXME: remove 'vic' from DS */ 578 GNUNET_assert (GNUNET_OK ==
579 GNUNET_CONTAINER_multihashmap_remove (notify_map,
580 &ctx->target.hashPubKey,
581 ctx));
561 GNUNET_free (ctx); 582 GNUNET_free (ctx);
562} 583}
563 584