aboutsummaryrefslogtreecommitdiff
path: root/src/transport
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-08-12 08:46:13 +0000
committerChristian Grothoff <christian@grothoff.org>2011-08-12 08:46:13 +0000
commitd220651a00e92367387e6f0d881c8115fc9e2973 (patch)
treea65a6728b0dae8fef53f33562bd5e66dab633458 /src/transport
parent7aa67c67037822517403e04668a2c56513d79cc6 (diff)
downloadgnunet-d220651a00e92367387e6f0d881c8115fc9e2973.tar.gz
gnunet-d220651a00e92367387e6f0d881c8115fc9e2973.zip
validation should notify async callbacks about updates
Diffstat (limited to 'src/transport')
-rw-r--r--src/transport/gnunet-service-transport_validation.c77
1 files changed, 54 insertions, 23 deletions
diff --git a/src/transport/gnunet-service-transport_validation.c b/src/transport/gnunet-service-transport_validation.c
index 6a300abcb..13522931a 100644
--- a/src/transport/gnunet-service-transport_validation.c
+++ b/src/transport/gnunet-service-transport_validation.c
@@ -248,6 +248,28 @@ struct CheckHelloValidatedContext
248 248
249 249
250/** 250/**
251 * Opaque handle to stop incremental validation address callbacks.
252 */
253struct GST_ValidationIteratorContext
254{
255 /**
256 * Function to call on each address.
257 */
258 GST_ValidationAddressCallback cb;
259
260 /**
261 * Closure for 'cb'.
262 */
263 void *cb_cls;
264
265 /**
266 * Which peer are we monitoring?
267 */
268 struct GNUNET_PeerIdentity target;
269};
270
271
272/**
251 * Head of linked list of HELLOs awaiting validation. 273 * Head of linked list of HELLOs awaiting validation.
252 */ 274 */
253static struct CheckHelloValidatedContext *chvc_head; 275static struct CheckHelloValidatedContext *chvc_head;
@@ -386,6 +408,34 @@ find_validation_entry (const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *pub
386 408
387 409
388/** 410/**
411 * Notify validation watcher that an entry is now valid
412 *
413 * @param cls 'struct ValidationEntry' that is now valid
414 * @param key peer identity (unused)
415 * @param value a 'GST_ValidationIteratorContext' to notify
416 * @return GNUNET_YES (continue to iterate)
417 */
418static int
419notify_valid (void *cls,
420 const GNUNET_HashCode *key,
421 void *value)
422{
423 struct ValidationEntry *ve = cls;
424 struct GST_ValidationIteratorContext *vic = value;
425
426 vic->cb (vic->cb_cls,
427 &ve->public_key,
428 &vic->target,
429 ve->valid_until,
430 ve->validation_block,
431 ve->transport_name,
432 ve->addr,
433 ve->addrlen);
434 return GNUNET_OK;
435}
436
437
438/**
389 * Iterator which adds the given address to the set of validated 439 * Iterator which adds the given address to the set of validated
390 * addresses. 440 * addresses.
391 * 441 *
@@ -418,10 +468,13 @@ add_valid_address (void *cls,
418 GNUNET_break (0); 468 GNUNET_break (0);
419 return GNUNET_OK; /* invalid HELLO !? */ 469 return GNUNET_OK; /* invalid HELLO !? */
420 } 470 }
421
422 ve = find_validation_entry (&public_key, &pid, tname, addr, addrlen); 471 ve = find_validation_entry (&public_key, &pid, tname, addr, addrlen);
423 ve->valid_until = GNUNET_TIME_absolute_max (ve->valid_until, 472 ve->valid_until = GNUNET_TIME_absolute_max (ve->valid_until,
424 expiration); 473 expiration);
474 GNUNET_CONTAINER_multihashmap_get_multiple (notify_map,
475 &pid.hashPubKey,
476 &notify_valid,
477 ve);
425 return GNUNET_OK; 478 return GNUNET_OK;
426} 479}
427 480
@@ -1092,28 +1145,6 @@ GST_validation_handle_hello (const struct GNUNET_MessageHeader *hello)
1092 1145
1093 1146
1094/** 1147/**
1095 * Opaque handle to stop incremental validation address callbacks.
1096 */
1097struct GST_ValidationIteratorContext
1098{
1099 /**
1100 * Function to call on each address.
1101 */
1102 GST_ValidationAddressCallback cb;
1103
1104 /**
1105 * Closure for 'cb'.
1106 */
1107 void *cb_cls;
1108
1109 /**
1110 * Which peer are we monitoring?
1111 */
1112 struct GNUNET_PeerIdentity target;
1113};
1114
1115
1116/**
1117 * Call the callback in the closure for each validation entry. 1148 * Call the callback in the closure for each validation entry.
1118 * 1149 *
1119 * @param cls the 'struct GST_ValidationIteratorContext' 1150 * @param cls the 'struct GST_ValidationIteratorContext'