aboutsummaryrefslogtreecommitdiff
path: root/src/transport/gnunet-service-transport_validation.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/transport/gnunet-service-transport_validation.c')
-rw-r--r--src/transport/gnunet-service-transport_validation.c688
1 files changed, 302 insertions, 386 deletions
diff --git a/src/transport/gnunet-service-transport_validation.c b/src/transport/gnunet-service-transport_validation.c
index 86c51c729..f618a2b1a 100644
--- a/src/transport/gnunet-service-transport_validation.c
+++ b/src/transport/gnunet-service-transport_validation.c
@@ -66,12 +66,12 @@
66 66
67/** 67/**
68 * Priority to use for PINGs 68 * Priority to use for PINGs
69 */ 69 */
70#define PING_PRIORITY 2 70#define PING_PRIORITY 2
71 71
72/** 72/**
73 * Priority to use for PONGs 73 * Priority to use for PONGs
74 */ 74 */
75#define PONG_PRIORITY 4 75#define PONG_PRIORITY 4
76 76
77 77
@@ -154,7 +154,7 @@ struct TransportPongMessage
154/** 154/**
155 * Information about an address under validation 155 * Information about an address under validation
156 */ 156 */
157struct ValidationEntry 157struct ValidationEntry
158{ 158{
159 159
160 /** 160 /**
@@ -176,7 +176,7 @@ struct ValidationEntry
176 /** 176 /**
177 * Public key of the peer. 177 * Public key of the peer.
178 */ 178 */
179 struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded public_key; 179 struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded public_key;
180 180
181 /** 181 /**
182 * The identity of the peer. 182 * The identity of the peer.
@@ -206,7 +206,7 @@ struct ValidationEntry
206 * otherwise a time in the future if we're currently denying re-validation 206 * otherwise a time in the future if we're currently denying re-validation
207 */ 207 */
208 struct GNUNET_TIME_Absolute validation_block; 208 struct GNUNET_TIME_Absolute validation_block;
209 209
210 /** 210 /**
211 * Challenge number we used. 211 * Challenge number we used.
212 */ 212 */
@@ -277,7 +277,7 @@ struct ValidationEntryMatchContext
277 * Where to store the result? 277 * Where to store the result?
278 */ 278 */
279 struct ValidationEntry *ve; 279 struct ValidationEntry *ve;
280 280
281 /** 281 /**
282 * Transport name we're looking for. 282 * Transport name we're looking for.
283 */ 283 */
@@ -305,20 +305,18 @@ struct ValidationEntryMatchContext
305 * GNUNET_NO if the entry does match 305 * GNUNET_NO if the entry does match
306 */ 306 */
307static int 307static int
308validation_entry_match (void *cls, 308validation_entry_match (void *cls, const GNUNET_HashCode * key, void *value)
309 const GNUNET_HashCode *key,
310 void *value)
311{ 309{
312 struct ValidationEntryMatchContext *vemc = cls; 310 struct ValidationEntryMatchContext *vemc = cls;
313 struct ValidationEntry *ve = value; 311 struct ValidationEntry *ve = value;
314 312
315 if ( (ve->addrlen == vemc->addrlen) && 313 if ((ve->addrlen == vemc->addrlen) &&
316 (0 == memcmp (ve->addr, vemc->addr, ve->addrlen)) && 314 (0 == memcmp (ve->addr, vemc->addr, ve->addrlen)) &&
317 (0 == strcmp (ve->transport_name, vemc->transport_name)) ) 315 (0 == strcmp (ve->transport_name, vemc->transport_name)))
318 { 316 {
319 vemc->ve = ve; 317 vemc->ve = ve;
320 return GNUNET_NO; 318 return GNUNET_NO;
321 } 319 }
322 return GNUNET_YES; 320 return GNUNET_YES;
323} 321}
324 322
@@ -340,11 +338,9 @@ validation_entry_match (void *cls,
340 * if we don't have an existing entry and no public key was given 338 * if we don't have an existing entry and no public key was given
341 */ 339 */
342static struct ValidationEntry * 340static struct ValidationEntry *
343find_validation_entry (const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *public_key, 341find_validation_entry (const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded
344 const struct GNUNET_PeerIdentity *neighbour, 342 *public_key, const struct GNUNET_PeerIdentity *neighbour,
345 const char *tname, 343 const char *tname, const char *addr, size_t addrlen)
346 const char *addr,
347 size_t addrlen)
348{ 344{
349 struct ValidationEntryMatchContext vemc; 345 struct ValidationEntryMatchContext vemc;
350 struct ValidationEntry *ve; 346 struct ValidationEntry *ve;
@@ -354,26 +350,25 @@ find_validation_entry (const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *pub
354 vemc.addr = addr; 350 vemc.addr = addr;
355 vemc.addrlen = addrlen; 351 vemc.addrlen = addrlen;
356 GNUNET_CONTAINER_multihashmap_get_multiple (validation_map, 352 GNUNET_CONTAINER_multihashmap_get_multiple (validation_map,
357 &neighbour->hashPubKey, 353 &neighbour->hashPubKey,
358 &validation_entry_match, 354 &validation_entry_match, &vemc);
359 &vemc);
360 if (NULL != (ve = vemc.ve)) 355 if (NULL != (ve = vemc.ve))
361 return ve; 356 return ve;
362 if (public_key == NULL) 357 if (public_key == NULL)
363 return NULL; 358 return NULL;
364 ve = GNUNET_malloc (sizeof (struct ValidationEntry) + addrlen); 359 ve = GNUNET_malloc (sizeof (struct ValidationEntry) + addrlen);
365 ve->transport_name = GNUNET_strdup (tname); 360 ve->transport_name = GNUNET_strdup (tname);
366 ve->addr = (void*) &ve[1]; 361 ve->addr = (void *) &ve[1];
367 ve->public_key = *public_key; 362 ve->public_key = *public_key;
368 ve->pid = *neighbour; 363 ve->pid = *neighbour;
369 ve->challenge = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_NONCE, 364 ve->challenge = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_NONCE,
370 UINT32_MAX); 365 UINT32_MAX);
371 memcpy (&ve[1], addr, addrlen); 366 memcpy (&ve[1], addr, addrlen);
372 ve->addrlen = addrlen; 367 ve->addrlen = addrlen;
373 GNUNET_CONTAINER_multihashmap_put (validation_map, 368 GNUNET_CONTAINER_multihashmap_put (validation_map,
374 &neighbour->hashPubKey, 369 &neighbour->hashPubKey,
375 ve, 370 ve,
376 GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); 371 GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
377 return ve; 372 return ve;
378} 373}
379 374
@@ -391,10 +386,9 @@ find_validation_entry (const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *pub
391 */ 386 */
392static int 387static int
393add_valid_address (void *cls, 388add_valid_address (void *cls,
394 const char *tname, 389 const char *tname,
395 struct GNUNET_TIME_Absolute expiration, 390 struct GNUNET_TIME_Absolute expiration,
396 const void *addr, 391 const void *addr, uint16_t addrlen)
397 uint16_t addrlen)
398{ 392{
399 const struct GNUNET_HELLO_Message *hello = cls; 393 const struct GNUNET_HELLO_Message *hello = cls;
400 struct ValidationEntry *ve; 394 struct ValidationEntry *ve;
@@ -402,26 +396,20 @@ add_valid_address (void *cls,
402 struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded public_key; 396 struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded public_key;
403 397
404 if (GNUNET_TIME_absolute_get_remaining (expiration).rel_value == 0) 398 if (GNUNET_TIME_absolute_get_remaining (expiration).rel_value == 0)
405 return GNUNET_OK; /* expired */ 399 return GNUNET_OK; /* expired */
406 if ( (GNUNET_OK != 400 if ((GNUNET_OK !=
407 GNUNET_HELLO_get_id (hello, &pid)) || 401 GNUNET_HELLO_get_id (hello, &pid)) ||
408 (GNUNET_OK != 402 (GNUNET_OK != GNUNET_HELLO_get_key (hello, &public_key)))
409 GNUNET_HELLO_get_key (hello, &public_key)) ) 403 {
410 { 404 GNUNET_break (0);
411 GNUNET_break (0); 405 return GNUNET_OK; /* invalid HELLO !? */
412 return GNUNET_OK; /* invalid HELLO !? */ 406 }
413 }
414 ve = find_validation_entry (&public_key, &pid, tname, addr, addrlen); 407 ve = find_validation_entry (&public_key, &pid, tname, addr, addrlen);
415 ve->valid_until = GNUNET_TIME_absolute_max (ve->valid_until, 408 ve->valid_until = GNUNET_TIME_absolute_max (ve->valid_until, expiration);
416 expiration);
417 GNUNET_ATS_address_update (GST_ats, 409 GNUNET_ATS_address_update (GST_ats,
418 &pid, 410 &pid,
419 ve->valid_until, 411 ve->valid_until,
420 tname, 412 tname, NULL, addr, addrlen, NULL, 0);
421 NULL,
422 addr,
423 addrlen,
424 NULL, 0);
425 return GNUNET_OK; 413 return GNUNET_OK;
426} 414}
427 415
@@ -436,31 +424,29 @@ add_valid_address (void *cls,
436 */ 424 */
437static void 425static void
438process_peerinfo_hello (void *cls, 426process_peerinfo_hello (void *cls,
439 const struct GNUNET_PeerIdentity *peer, 427 const struct GNUNET_PeerIdentity *peer,
440 const struct GNUNET_HELLO_Message *hello, 428 const struct GNUNET_HELLO_Message *hello,
441 const char *err_msg) 429 const char *err_msg)
442{ 430{
443 GNUNET_assert (NULL != peer); 431 GNUNET_assert (NULL != peer);
444 if (NULL == hello) 432 if (NULL == hello)
445 return; 433 return;
446 GNUNET_assert (NULL == 434 GNUNET_assert (NULL ==
447 GNUNET_HELLO_iterate_addresses (hello, 435 GNUNET_HELLO_iterate_addresses (hello,
448 GNUNET_NO, 436 GNUNET_NO,
449 &add_valid_address, 437 &add_valid_address,
450 (void*) hello)); 438 (void *) hello));
451} 439}
452 440
453 441
454/** 442/**
455 * Start the validation subsystem. 443 * Start the validation subsystem.
456 */ 444 */
457void 445void
458GST_validation_start () 446GST_validation_start ()
459{ 447{
460 validation_map = GNUNET_CONTAINER_multihashmap_create (VALIDATION_MAP_SIZE); 448 validation_map = GNUNET_CONTAINER_multihashmap_create (VALIDATION_MAP_SIZE);
461 pnc = GNUNET_PEERINFO_notify (GST_cfg, 449 pnc = GNUNET_PEERINFO_notify (GST_cfg, &process_peerinfo_hello, NULL);
462 &process_peerinfo_hello,
463 NULL);
464} 450}
465 451
466 452
@@ -473,27 +459,24 @@ GST_validation_start ()
473 * @return GNUNET_YES (continue to iterate) 459 * @return GNUNET_YES (continue to iterate)
474 */ 460 */
475static int 461static int
476cleanup_validation_entry (void *cls, 462cleanup_validation_entry (void *cls, const GNUNET_HashCode * key, void *value)
477 const GNUNET_HashCode *key,
478 void *value)
479{ 463{
480 struct ValidationEntry *ve = value; 464 struct ValidationEntry *ve = value;
481 465
482 if (NULL != ve->bc) 466 if (NULL != ve->bc)
483 { 467 {
484 GST_blacklist_test_cancel (ve->bc); 468 GST_blacklist_test_cancel (ve->bc);
485 ve->bc = NULL; 469 ve->bc = NULL;
486 } 470 }
487 GNUNET_break (GNUNET_OK == 471 GNUNET_break (GNUNET_OK ==
488 GNUNET_CONTAINER_multihashmap_remove (validation_map, 472 GNUNET_CONTAINER_multihashmap_remove (validation_map,
489 &ve->pid.hashPubKey, 473 &ve->pid.hashPubKey, ve));
490 ve));
491 GNUNET_free (ve->transport_name); 474 GNUNET_free (ve->transport_name);
492 if (GNUNET_SCHEDULER_NO_TASK != ve->timeout_task) 475 if (GNUNET_SCHEDULER_NO_TASK != ve->timeout_task)
493 { 476 {
494 GNUNET_SCHEDULER_cancel (ve->timeout_task); 477 GNUNET_SCHEDULER_cancel (ve->timeout_task);
495 ve->timeout_task = GNUNET_SCHEDULER_NO_TASK; 478 ve->timeout_task = GNUNET_SCHEDULER_NO_TASK;
496 } 479 }
497 GNUNET_free (ve); 480 GNUNET_free (ve);
498 return GNUNET_OK; 481 return GNUNET_OK;
499} 482}
@@ -508,17 +491,14 @@ GST_validation_stop ()
508 struct CheckHelloValidatedContext *chvc; 491 struct CheckHelloValidatedContext *chvc;
509 492
510 GNUNET_CONTAINER_multihashmap_iterate (validation_map, 493 GNUNET_CONTAINER_multihashmap_iterate (validation_map,
511 &cleanup_validation_entry, 494 &cleanup_validation_entry, NULL);
512 NULL);
513 GNUNET_CONTAINER_multihashmap_destroy (validation_map); 495 GNUNET_CONTAINER_multihashmap_destroy (validation_map);
514 validation_map = NULL; 496 validation_map = NULL;
515 while (NULL != (chvc = chvc_head)) 497 while (NULL != (chvc = chvc_head))
516 { 498 {
517 GNUNET_CONTAINER_DLL_remove (chvc_head, 499 GNUNET_CONTAINER_DLL_remove (chvc_head, chvc_tail, chvc);
518 chvc_tail, 500 GNUNET_free (chvc);
519 chvc); 501 }
520 GNUNET_free (chvc);
521 }
522 GNUNET_PEERINFO_notify_cancel (pnc); 502 GNUNET_PEERINFO_notify_cancel (pnc);
523} 503}
524 504
@@ -530,16 +510,15 @@ GST_validation_stop ()
530 * @param tc scheduler context (unused) 510 * @param tc scheduler context (unused)
531 */ 511 */
532static void 512static void
533timeout_hello_validation (void *cls, 513timeout_hello_validation (void *cls,
534 const struct GNUNET_SCHEDULER_TaskContext *tc) 514 const struct GNUNET_SCHEDULER_TaskContext *tc)
535{ 515{
536 struct ValidationEntry *ve = cls; 516 struct ValidationEntry *ve = cls;
537 517
538 ve->timeout_task = GNUNET_SCHEDULER_NO_TASK; 518 ve->timeout_task = GNUNET_SCHEDULER_NO_TASK;
539 GNUNET_STATISTICS_update (GST_stats, 519 GNUNET_STATISTICS_update (GST_stats,
540 gettext_noop ("# address records discarded"), 520 gettext_noop ("# address records discarded"),
541 1, 521 1, GNUNET_NO);
542 GNUNET_NO);
543 cleanup_validation_entry (NULL, &ve->pid.hashPubKey, ve); 522 cleanup_validation_entry (NULL, &ve->pid.hashPubKey, ve);
544} 523}
545 524
@@ -561,13 +540,12 @@ timeout_hello_validation (void *cls,
561 */ 540 */
562static void 541static void
563multicast_pong (void *cls, 542multicast_pong (void *cls,
564 const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *public_key, 543 const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded
565 const struct GNUNET_PeerIdentity *target, 544 *public_key, const struct GNUNET_PeerIdentity *target,
566 struct GNUNET_TIME_Absolute valid_until, 545 struct GNUNET_TIME_Absolute valid_until,
567 struct GNUNET_TIME_Absolute validation_block, 546 struct GNUNET_TIME_Absolute validation_block,
568 const char *plugin_name, 547 const char *plugin_name, const void *plugin_address,
569 const void *plugin_address, 548 size_t plugin_address_len)
570 size_t plugin_address_len)
571{ 549{
572 struct TransportPongMessage *pong = cls; 550 struct TransportPongMessage *pong = cls;
573 struct GNUNET_TRANSPORT_PluginFunctions *papi; 551 struct GNUNET_TRANSPORT_PluginFunctions *papi;
@@ -576,16 +554,14 @@ multicast_pong (void *cls,
576 if (papi == NULL) 554 if (papi == NULL)
577 return; 555 return;
578 (void) papi->send (papi->cls, 556 (void) papi->send (papi->cls,
579 target, 557 target,
580 (const char*) pong, 558 (const char *) pong,
581 ntohs (pong->header.size), 559 ntohs (pong->header.size),
582 PONG_PRIORITY, 560 PONG_PRIORITY,
583 HELLO_REVALIDATION_START_TIME, 561 HELLO_REVALIDATION_START_TIME,
584 NULL, 562 NULL,
585 plugin_address, 563 plugin_address,
586 plugin_address_len, 564 plugin_address_len, GNUNET_YES, NULL, NULL);
587 GNUNET_YES,
588 NULL, NULL);
589} 565}
590 566
591 567
@@ -602,11 +578,11 @@ multicast_pong (void *cls,
602 */ 578 */
603void 579void
604GST_validation_handle_ping (const struct GNUNET_PeerIdentity *sender, 580GST_validation_handle_ping (const struct GNUNET_PeerIdentity *sender,
605 const struct GNUNET_MessageHeader *hdr, 581 const struct GNUNET_MessageHeader *hdr,
606 const char *plugin_name, 582 const char *plugin_name,
607 struct Session *session, 583 struct Session *session,
608 const void *sender_address, 584 const void *sender_address,
609 size_t sender_address_len) 585 size_t sender_address_len)
610{ 586{
611 const struct TransportPingMessage *ping; 587 const struct TransportPingMessage *ping;
612 struct TransportPongMessage *pong; 588 struct TransportPongMessage *pong;
@@ -620,124 +596,113 @@ GST_validation_handle_ping (const struct GNUNET_PeerIdentity *sender,
620 ssize_t ret; 596 ssize_t ret;
621 597
622 if (ntohs (hdr->size) < sizeof (struct TransportPingMessage)) 598 if (ntohs (hdr->size) < sizeof (struct TransportPingMessage))
623 { 599 {
624 GNUNET_break_op (0); 600 GNUNET_break_op (0);
625 return; 601 return;
626 } 602 }
627 ping = (const struct TransportPingMessage *) hdr; 603 ping = (const struct TransportPingMessage *) hdr;
628 if (0 != memcmp (&ping->target, 604 if (0 != memcmp (&ping->target,
629 &GST_my_identity, 605 &GST_my_identity, sizeof (struct GNUNET_PeerIdentity)))
630 sizeof (struct GNUNET_PeerIdentity))) 606 {
631 { 607 GNUNET_break_op (0);
632 GNUNET_break_op (0); 608 return;
633 return; 609 }
634 }
635 GNUNET_STATISTICS_update (GST_stats, 610 GNUNET_STATISTICS_update (GST_stats,
636 gettext_noop ("# PING messages received"), 611 gettext_noop ("# PING messages received"),
637 1, 612 1, GNUNET_NO);
638 GNUNET_NO); 613 addr = (const char *) &ping[1];
639 addr = (const char*) &ping[1];
640 alen = ntohs (hdr->size) - sizeof (struct TransportPingMessage); 614 alen = ntohs (hdr->size) - sizeof (struct TransportPingMessage);
641 /* peer wants to confirm that this is one of our addresses, this is what is 615 /* peer wants to confirm that this is one of our addresses, this is what is
642 used for address validation */ 616 * used for address validation */
643 617
644 addrend = memchr (addr, '\0', alen); 618 addrend = memchr (addr, '\0', alen);
645 if (NULL == addrend) 619 if (NULL == addrend)
646 { 620 {
647 GNUNET_break_op (0); 621 GNUNET_break_op (0);
648 return; 622 return;
649 } 623 }
650 addrend++; 624 addrend++;
651 slen = strlen(addr); 625 slen = strlen (addr);
652 alen -= slen; 626 alen -= slen;
653 627
654 if (GNUNET_YES != 628 if (GNUNET_YES !=
655 GST_hello_test_address (addr, 629 GST_hello_test_address (addr, addrend, alen, &sig_cache, &sig_cache_exp))
656 addrend, 630 {
657 alen, 631 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
658 &sig_cache, 632 _
659 &sig_cache_exp)) 633 ("Not confirming PING with address `%s' since I cannot confirm having this address.\n"),
660 { 634 GST_plugins_a2s (addr, addrend, alen));
661 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 635 return;
662 _("Not confirming PING with address `%s' since I cannot confirm having this address.\n"), 636 }
663 GST_plugins_a2s (addr, 637
664 addrend,
665 alen));
666 return;
667 }
668
669 pong = GNUNET_malloc (sizeof (struct TransportPongMessage) + alen + slen); 638 pong = GNUNET_malloc (sizeof (struct TransportPongMessage) + alen + slen);
670 pong->header.size = htons (sizeof (struct TransportPongMessage) + alen + slen); 639 pong->header.size =
640 htons (sizeof (struct TransportPongMessage) + alen + slen);
671 pong->header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_PONG); 641 pong->header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_PONG);
672 pong->purpose.size = 642 pong->purpose.size =
673 htonl (sizeof (struct GNUNET_CRYPTO_RsaSignaturePurpose) + 643 htonl (sizeof (struct GNUNET_CRYPTO_RsaSignaturePurpose) +
674 sizeof (uint32_t) + 644 sizeof (uint32_t) +
675 sizeof (struct GNUNET_TIME_AbsoluteNBO) + 645 sizeof (struct GNUNET_TIME_AbsoluteNBO) + alen + slen);
676 alen + slen);
677 pong->purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_PONG_OWN); 646 pong->purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_PONG_OWN);
678 pong->challenge = ping->challenge; 647 pong->challenge = ping->challenge;
679 pong->addrlen = htonl(alen + slen); 648 pong->addrlen = htonl (alen + slen);
680 memcpy (&pong[1], addr, slen); 649 memcpy (&pong[1], addr, slen);
681 memcpy (&((char*)&pong[1])[slen], addrend, alen); 650 memcpy (&((char *) &pong[1])[slen], addrend, alen);
682 if (GNUNET_TIME_absolute_get_remaining (*sig_cache_exp).rel_value < PONG_SIGNATURE_LIFETIME.rel_value / 4) 651 if (GNUNET_TIME_absolute_get_remaining (*sig_cache_exp).rel_value <
683 { 652 PONG_SIGNATURE_LIFETIME.rel_value / 4)
684 /* create / update cached sig */ 653 {
654 /* create / update cached sig */
685#if DEBUG_TRANSPORT 655#if DEBUG_TRANSPORT
686 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 656 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
687 "Creating PONG signature to indicate ownership.\n"); 657 "Creating PONG signature to indicate ownership.\n");
688#endif 658#endif
689 *sig_cache_exp = GNUNET_TIME_relative_to_absolute (PONG_SIGNATURE_LIFETIME); 659 *sig_cache_exp = GNUNET_TIME_relative_to_absolute (PONG_SIGNATURE_LIFETIME);
690 pong->expiration = GNUNET_TIME_absolute_hton (*sig_cache_exp); 660 pong->expiration = GNUNET_TIME_absolute_hton (*sig_cache_exp);
691 GNUNET_assert (GNUNET_OK == 661 GNUNET_assert (GNUNET_OK ==
692 GNUNET_CRYPTO_rsa_sign (GST_my_private_key, 662 GNUNET_CRYPTO_rsa_sign (GST_my_private_key,
693 &pong->purpose, 663 &pong->purpose, sig_cache));
694 sig_cache)); 664 }
695 }
696 else 665 else
697 { 666 {
698 pong->expiration = GNUNET_TIME_absolute_hton (*sig_cache_exp); 667 pong->expiration = GNUNET_TIME_absolute_hton (*sig_cache_exp);
699 } 668 }
700 pong->signature = *sig_cache; 669 pong->signature = *sig_cache;
701 670
702 /* first see if the session we got this PING from can be used to transmit 671 /* first see if the session we got this PING from can be used to transmit
703 a response reliably */ 672 * a response reliably */
704 papi = GST_plugins_find (plugin_name); 673 papi = GST_plugins_find (plugin_name);
705 if (papi == NULL) 674 if (papi == NULL)
706 ret = -1; 675 ret = -1;
707 else 676 else
708 ret = papi->send (papi->cls, 677 ret = papi->send (papi->cls,
709 sender, 678 sender,
710 (const char*) pong, 679 (const char *) pong,
711 ntohs (pong->header.size), 680 ntohs (pong->header.size),
712 PONG_PRIORITY, 681 PONG_PRIORITY,
713 HELLO_REVALIDATION_START_TIME, 682 HELLO_REVALIDATION_START_TIME,
714 session, 683 session,
715 sender_address, 684 sender_address,
716 sender_address_len, 685 sender_address_len, GNUNET_SYSERR, NULL, NULL);
717 GNUNET_SYSERR,
718 NULL, NULL);
719 if (ret != -1) 686 if (ret != -1)
720 { 687 {
721 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 688 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
722 "Transmitted PONG to `%s' via reliable mechanism\n", 689 "Transmitted PONG to `%s' via reliable mechanism\n",
723 GNUNET_i2s (sender)); 690 GNUNET_i2s (sender));
724 /* done! */ 691 /* done! */
725 GNUNET_STATISTICS_update (GST_stats, 692 GNUNET_STATISTICS_update (GST_stats,
726 gettext_noop ("# PONGs unicast via reliable transport"), 693 gettext_noop
727 1, 694 ("# PONGs unicast via reliable transport"), 1,
728 GNUNET_NO); 695 GNUNET_NO);
729 GNUNET_free (pong); 696 GNUNET_free (pong);
730 return; 697 return;
731 } 698 }
732 699
733 /* no reliable method found, try transmission via all known addresses */ 700 /* no reliable method found, try transmission via all known addresses */
734 GNUNET_STATISTICS_update (GST_stats, 701 GNUNET_STATISTICS_update (GST_stats,
735 gettext_noop ("# PONGs multicast to all available addresses"), 702 gettext_noop
736 1, 703 ("# PONGs multicast to all available addresses"), 1,
737 GNUNET_NO); 704 GNUNET_NO);
738 GST_validation_get_addresses (sender, 705 GST_validation_get_addresses (sender, &multicast_pong, pong);
739 &multicast_pong,
740 pong);
741 GNUNET_free (pong); 706 GNUNET_free (pong);
742} 707}
743 708
@@ -749,7 +714,7 @@ struct ValidateAddressContext
749{ 714{
750 /** 715 /**
751 * Hash of the public key of the peer whose address is being validated. 716 * Hash of the public key of the peer whose address is being validated.
752 */ 717 */
753 struct GNUNET_PeerIdentity pid; 718 struct GNUNET_PeerIdentity pid;
754 719
755 /** 720 /**
@@ -769,8 +734,7 @@ struct ValidateAddressContext
769 */ 734 */
770static void 735static void
771transmit_ping_if_allowed (void *cls, 736transmit_ping_if_allowed (void *cls,
772 const struct GNUNET_PeerIdentity *pid, 737 const struct GNUNET_PeerIdentity *pid, int result)
773 int result)
774{ 738{
775 struct ValidationEntry *ve = cls; 739 struct ValidationEntry *ve = cls;
776 struct TransportPingMessage ping; 740 struct TransportPingMessage ping;
@@ -783,63 +747,55 @@ transmit_ping_if_allowed (void *cls,
783 747
784 ve->bc = NULL; 748 ve->bc = NULL;
785 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 749 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
786 "Transmitting plain PING to `%s'\n", 750 "Transmitting plain PING to `%s'\n", GNUNET_i2s (pid));
787 GNUNET_i2s (pid)); 751 ping.header.size = htons (sizeof (struct TransportPingMessage));
788 ping.header.size = htons(sizeof(struct TransportPingMessage)); 752 ping.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_PING);
789 ping.header.type = htons(GNUNET_MESSAGE_TYPE_TRANSPORT_PING); 753 ping.challenge = htonl (ve->challenge);
790 ping.challenge = htonl(ve->challenge);
791 ping.target = *pid; 754 ping.target = *pid;
792 755
793 slen = strlen(ve->transport_name) + 1; 756 slen = strlen (ve->transport_name) + 1;
794 hello = GST_hello_get (); 757 hello = GST_hello_get ();
795 hsize = ntohs (hello->size); 758 hsize = ntohs (hello->size);
796 tsize = sizeof(struct TransportPingMessage) + ve->addrlen + slen + hsize; 759 tsize = sizeof (struct TransportPingMessage) + ve->addrlen + slen + hsize;
797 if (tsize >= GNUNET_SERVER_MAX_MESSAGE_SIZE) 760 if (tsize >= GNUNET_SERVER_MAX_MESSAGE_SIZE)
798 { 761 {
799 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 762 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
800 _("Not transmitting `%s' with `%s', message too big (%u bytes!). This should not happen.\n"), 763 _
801 "HELLO", 764 ("Not transmitting `%s' with `%s', message too big (%u bytes!). This should not happen.\n"),
802 "PING", 765 "HELLO", "PING", (unsigned int) tsize);
803 (unsigned int) tsize); 766 /* message too big (!?), get rid of HELLO */
804 /* message too big (!?), get rid of HELLO */ 767 hsize = 0;
805 hsize = 0; 768 tsize = sizeof (struct TransportPingMessage) + ve->addrlen + slen + hsize;
806 tsize = sizeof(struct TransportPingMessage) + ve->addrlen + slen + hsize; 769 }
807 }
808 { 770 {
809 char message_buf[tsize]; 771 char message_buf[tsize];
810 772
811 memcpy(message_buf, hello, hsize); 773 memcpy (message_buf, hello, hsize);
812 memcpy(&message_buf[hsize], &ping, sizeof (struct TransportPingMessage)); 774 memcpy (&message_buf[hsize], &ping, sizeof (struct TransportPingMessage));
813 memcpy(&message_buf[sizeof (struct TransportPingMessage) + hsize], 775 memcpy (&message_buf[sizeof (struct TransportPingMessage) + hsize],
814 ve->transport_name, 776 ve->transport_name, slen);
815 slen); 777 memcpy (&message_buf[sizeof (struct TransportPingMessage) + slen + hsize],
816 memcpy(&message_buf[sizeof (struct TransportPingMessage) + slen + hsize], 778 ve->addr, ve->addrlen);
817 ve->addr,
818 ve->addrlen);
819 papi = GST_plugins_find (ve->transport_name); 779 papi = GST_plugins_find (ve->transport_name);
820 if (papi == NULL) 780 if (papi == NULL)
821 ret = -1; 781 ret = -1;
822 else 782 else
823 ret = papi->send (papi->cls, 783 ret = papi->send (papi->cls,
824 pid, 784 pid,
825 message_buf, 785 message_buf,
826 tsize, 786 tsize,
827 PING_PRIORITY, 787 PING_PRIORITY,
828 HELLO_REVALIDATION_START_TIME, 788 HELLO_REVALIDATION_START_TIME, NULL /* no session */ ,
829 NULL /* no session */, 789 ve->addr, ve->addrlen, GNUNET_YES, NULL, NULL);
830 ve->addr,
831 ve->addrlen,
832 GNUNET_YES,
833 NULL, NULL);
834 } 790 }
835 if (-1 != ret) 791 if (-1 != ret)
836 { 792 {
837 ve->send_time = GNUNET_TIME_absolute_get (); 793 ve->send_time = GNUNET_TIME_absolute_get ();
838 GNUNET_STATISTICS_update (GST_stats, 794 GNUNET_STATISTICS_update (GST_stats,
839 gettext_noop ("# PING without HELLO messages sent"), 795 gettext_noop
840 1, 796 ("# PING without HELLO messages sent"), 1,
841 GNUNET_NO); 797 GNUNET_NO);
842 } 798 }
843} 799}
844 800
845 801
@@ -856,10 +812,9 @@ transmit_ping_if_allowed (void *cls,
856 */ 812 */
857static int 813static int
858validate_address (void *cls, 814validate_address (void *cls,
859 const char *tname, 815 const char *tname,
860 struct GNUNET_TIME_Absolute expiration, 816 struct GNUNET_TIME_Absolute expiration,
861 const void *addr, 817 const void *addr, uint16_t addrlen)
862 uint16_t addrlen)
863{ 818{
864 const struct ValidateAddressContext *vac = cls; 819 const struct ValidateAddressContext *vac = cls;
865 const struct GNUNET_PeerIdentity *pid = &vac->pid; 820 const struct GNUNET_PeerIdentity *pid = &vac->pid;
@@ -867,23 +822,21 @@ validate_address (void *cls,
867 struct GST_BlacklistCheck *bc; 822 struct GST_BlacklistCheck *bc;
868 823
869 if (GNUNET_TIME_absolute_get_remaining (expiration).rel_value == 0) 824 if (GNUNET_TIME_absolute_get_remaining (expiration).rel_value == 0)
870 return GNUNET_OK; /* expired */ 825 return GNUNET_OK; /* expired */
871 ve = find_validation_entry (&vac->public_key, pid, tname, addr, addrlen); 826 ve = find_validation_entry (&vac->public_key, pid, tname, addr, addrlen);
872 if (GNUNET_TIME_absolute_get_remaining (ve->validation_block).rel_value > 0) 827 if (GNUNET_TIME_absolute_get_remaining (ve->validation_block).rel_value > 0)
873 return GNUNET_OK; /* blocked */ 828 return GNUNET_OK; /* blocked */
874 if ( (GNUNET_SCHEDULER_NO_TASK != ve->timeout_task) && 829 if ((GNUNET_SCHEDULER_NO_TASK != ve->timeout_task) &&
875 (GNUNET_TIME_absolute_get_remaining (ve->valid_until).rel_value > 0) ) 830 (GNUNET_TIME_absolute_get_remaining (ve->valid_until).rel_value > 0))
876 return GNUNET_OK; /* revalidation task already scheduled & still valid */ 831 return GNUNET_OK; /* revalidation task already scheduled & still valid */
877 ve->validation_block = GNUNET_TIME_relative_to_absolute (HELLO_REVALIDATION_START_TIME); 832 ve->validation_block =
833 GNUNET_TIME_relative_to_absolute (HELLO_REVALIDATION_START_TIME);
878 if (GNUNET_SCHEDULER_NO_TASK != ve->timeout_task) 834 if (GNUNET_SCHEDULER_NO_TASK != ve->timeout_task)
879 GNUNET_SCHEDULER_cancel (ve->timeout_task); 835 GNUNET_SCHEDULER_cancel (ve->timeout_task);
880 ve->timeout_task = GNUNET_SCHEDULER_add_delayed (HELLO_REVALIDATION_START_TIME, 836 ve->timeout_task =
881 &timeout_hello_validation, 837 GNUNET_SCHEDULER_add_delayed (HELLO_REVALIDATION_START_TIME,
882 ve); 838 &timeout_hello_validation, ve);
883 bc = GST_blacklist_test_allowed (pid, 839 bc = GST_blacklist_test_allowed (pid, tname, &transmit_ping_if_allowed, ve);
884 tname,
885 &transmit_ping_if_allowed,
886 ve);
887 if (NULL != bc) 840 if (NULL != bc)
888 ve->bc = bc; 841 ve->bc = bc;
889 return GNUNET_OK; 842 return GNUNET_OK;
@@ -897,8 +850,7 @@ validate_address (void *cls,
897 * @param tc scheduler context (unused) 850 * @param tc scheduler context (unused)
898 */ 851 */
899static void 852static void
900revalidate_address (void *cls, 853revalidate_address (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
901 const struct GNUNET_SCHEDULER_TaskContext *tc)
902{ 854{
903 struct ValidationEntry *ve = cls; 855 struct ValidationEntry *ve = cls;
904 struct GNUNET_TIME_Relative delay; 856 struct GNUNET_TIME_Relative delay;
@@ -907,24 +859,20 @@ revalidate_address (void *cls,
907 ve->timeout_task = GNUNET_SCHEDULER_NO_TASK; 859 ve->timeout_task = GNUNET_SCHEDULER_NO_TASK;
908 delay = GNUNET_TIME_absolute_get_remaining (ve->validation_block); 860 delay = GNUNET_TIME_absolute_get_remaining (ve->validation_block);
909 if (delay.rel_value > 0) 861 if (delay.rel_value > 0)
910 { 862 {
911 /* should wait a bit longer */ 863 /* should wait a bit longer */
912 ve->timeout_task = GNUNET_SCHEDULER_add_delayed (delay, 864 ve->timeout_task = GNUNET_SCHEDULER_add_delayed (delay,
913 &revalidate_address, 865 &revalidate_address, ve);
914 ve); 866 return;
915 return; 867 }
916 }
917 GNUNET_STATISTICS_update (GST_stats, 868 GNUNET_STATISTICS_update (GST_stats,
918 gettext_noop ("# address revalidations started"), 869 gettext_noop ("# address revalidations started"),
919 1, 870 1, GNUNET_NO);
920 GNUNET_NO);
921 vac.pid = ve->pid; 871 vac.pid = ve->pid;
922 vac.public_key = ve->public_key; 872 vac.public_key = ve->public_key;
923 validate_address (&vac, 873 validate_address (&vac,
924 ve->transport_name, 874 ve->transport_name,
925 ve->valid_until, 875 ve->valid_until, ve->addr, (uint16_t) ve->addrlen);
926 ve->addr,
927 (uint16_t) ve->addrlen);
928} 876}
929 877
930 878
@@ -936,18 +884,13 @@ revalidate_address (void *cls,
936 * @param buf where to add the address 884 * @param buf where to add the address
937 */ 885 */
938static size_t 886static size_t
939add_valid_peer_address (void *cls, 887add_valid_peer_address (void *cls, size_t max, void *buf)
940 size_t max,
941 void *buf)
942{ 888{
943 struct ValidationEntry *ve = cls; 889 struct ValidationEntry *ve = cls;
944 890
945 return GNUNET_HELLO_add_address (ve->transport_name, 891 return GNUNET_HELLO_add_address (ve->transport_name,
946 ve->valid_until, 892 ve->valid_until,
947 ve->addr, 893 ve->addr, ve->addrlen, buf, max);
948 ve->addrlen,
949 buf,
950 max);
951} 894}
952 895
953 896
@@ -960,7 +903,7 @@ add_valid_peer_address (void *cls,
960 */ 903 */
961void 904void
962GST_validation_handle_pong (const struct GNUNET_PeerIdentity *sender, 905GST_validation_handle_pong (const struct GNUNET_PeerIdentity *sender,
963 const struct GNUNET_MessageHeader *hdr) 906 const struct GNUNET_MessageHeader *hdr)
964{ 907{
965 const struct TransportPongMessage *pong; 908 const struct TransportPongMessage *pong;
966 struct ValidationEntry *ve; 909 struct ValidationEntry *ve;
@@ -973,97 +916,78 @@ GST_validation_handle_pong (const struct GNUNET_PeerIdentity *sender,
973 struct GNUNET_HELLO_Message *hello; 916 struct GNUNET_HELLO_Message *hello;
974 917
975 if (ntohs (hdr->size) < sizeof (struct TransportPongMessage)) 918 if (ntohs (hdr->size) < sizeof (struct TransportPongMessage))
976 { 919 {
977 GNUNET_break_op (0); 920 GNUNET_break_op (0);
978 return; 921 return;
979 } 922 }
980 GNUNET_STATISTICS_update (GST_stats, 923 GNUNET_STATISTICS_update (GST_stats,
981 gettext_noop ("# PONG messages received"), 924 gettext_noop ("# PONG messages received"),
982 1, 925 1, GNUNET_NO);
983 GNUNET_NO);
984 pong = (const struct TransportPongMessage *) hdr; 926 pong = (const struct TransportPongMessage *) hdr;
985 addr = (const char*) &pong[1]; 927 addr = (const char *) &pong[1];
986 alen = ntohs (hdr->size) - sizeof (struct TransportPongMessage); 928 alen = ntohs (hdr->size) - sizeof (struct TransportPongMessage);
987 addrend = memchr (addr, '\0', alen); 929 addrend = memchr (addr, '\0', alen);
988 if (NULL == addrend) 930 if (NULL == addrend)
989 { 931 {
990 GNUNET_break_op (0); 932 GNUNET_break_op (0);
991 return; 933 return;
992 } 934 }
993 addrend++; 935 addrend++;
994 slen = strlen(addr); 936 slen = strlen (addr);
995 alen -= slen; 937 alen -= slen;
996 ve = find_validation_entry (NULL, 938 ve = find_validation_entry (NULL, sender, addr, addrend, alen);
997 sender,
998 addr,
999 addrend,
1000 alen);
1001 if (NULL == ve) 939 if (NULL == ve)
1002 { 940 {
1003 GNUNET_STATISTICS_update (GST_stats, 941 GNUNET_STATISTICS_update (GST_stats,
1004 gettext_noop ("# PONGs dropped, no matching pending validation"), 942 gettext_noop
1005 1, 943 ("# PONGs dropped, no matching pending validation"),
1006 GNUNET_NO); 944 1, GNUNET_NO);
1007 return; 945 return;
1008 } 946 }
1009 /* now check that PONG is well-formed */ 947 /* now check that PONG is well-formed */
1010 if (0 != memcmp (&ve->pid, 948 if (0 != memcmp (&ve->pid, sender, sizeof (struct GNUNET_PeerIdentity)))
1011 sender, 949 {
1012 sizeof (struct GNUNET_PeerIdentity))) 950 GNUNET_break_op (0);
1013 { 951 return;
1014 GNUNET_break_op (0); 952 }
1015 return; 953
1016 } 954 if (GNUNET_TIME_absolute_get_remaining
1017 955 (GNUNET_TIME_absolute_ntoh (pong->expiration)).rel_value == 0)
1018 if (GNUNET_TIME_absolute_get_remaining (GNUNET_TIME_absolute_ntoh (pong->expiration)).rel_value == 0) 956 {
1019 { 957 GNUNET_STATISTICS_update (GST_stats,
1020 GNUNET_STATISTICS_update (GST_stats, 958 gettext_noop
1021 gettext_noop ("# PONGs dropped, signature expired"), 959 ("# PONGs dropped, signature expired"), 1,
1022 1, 960 GNUNET_NO);
1023 GNUNET_NO); 961 return;
1024 return; 962 }
1025 }
1026 if (GNUNET_OK != 963 if (GNUNET_OK !=
1027 GNUNET_CRYPTO_rsa_verify (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_PONG_OWN, 964 GNUNET_CRYPTO_rsa_verify (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_PONG_OWN,
1028 &pong->purpose, 965 &pong->purpose,
1029 &pong->signature, 966 &pong->signature, &ve->public_key))
1030 &ve->public_key)) 967 {
1031 { 968 GNUNET_break_op (0);
1032 GNUNET_break_op (0); 969 return;
1033 return; 970 }
1034 } 971
1035
1036 /* validity achieved, remember it! */ 972 /* validity achieved, remember it! */
1037 ve->valid_until = GNUNET_TIME_relative_to_absolute (HELLO_ADDRESS_EXPIRATION); 973 ve->valid_until = GNUNET_TIME_relative_to_absolute (HELLO_ADDRESS_EXPIRATION);
1038 GNUNET_ATS_address_update (GST_ats, 974 GNUNET_ATS_address_update (GST_ats, &ve->pid, ve->valid_until, ve->transport_name, NULL, ve->addr, ve->addrlen, NULL, 0); /* FIXME: compute and add latency here... */
1039 &ve->pid,
1040 ve->valid_until,
1041 ve->transport_name,
1042 NULL,
1043 ve->addr,
1044 ve->addrlen,
1045 NULL, 0); /* FIXME: compute and add latency here... */
1046 975
1047 /* build HELLO to store in PEERINFO */ 976 /* build HELLO to store in PEERINFO */
1048 hello = GNUNET_HELLO_create (&ve->public_key, 977 hello = GNUNET_HELLO_create (&ve->public_key, &add_valid_peer_address, ve);
1049 &add_valid_peer_address, 978 GNUNET_PEERINFO_add_peer (GST_peerinfo, hello);
1050 ve);
1051 GNUNET_PEERINFO_add_peer (GST_peerinfo,
1052 hello);
1053 GNUNET_free (hello); 979 GNUNET_free (hello);
1054 980
1055 if (GNUNET_SCHEDULER_NO_TASK != ve->timeout_task) 981 if (GNUNET_SCHEDULER_NO_TASK != ve->timeout_task)
1056 GNUNET_SCHEDULER_cancel (ve->timeout_task); 982 GNUNET_SCHEDULER_cancel (ve->timeout_task);
1057 983
1058 /* randomly delay by up to 1h to avoid synchronous validations */ 984 /* randomly delay by up to 1h to avoid synchronous validations */
1059 rdelay = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 985 rdelay = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 60 * 60);
1060 60 * 60);
1061 delay = GNUNET_TIME_relative_add (HELLO_REVALIDATION_START_TIME, 986 delay = GNUNET_TIME_relative_add (HELLO_REVALIDATION_START_TIME,
1062 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 987 GNUNET_TIME_relative_multiply
1063 rdelay)); 988 (GNUNET_TIME_UNIT_SECONDS, rdelay));
1064 ve->timeout_task = GNUNET_SCHEDULER_add_delayed (delay, 989 ve->timeout_task =
1065 &revalidate_address, 990 GNUNET_SCHEDULER_add_delayed (delay, &revalidate_address, ve);
1066 ve);
1067} 991}
1068 992
1069 993
@@ -1076,23 +1000,22 @@ GST_validation_handle_pong (const struct GNUNET_PeerIdentity *sender,
1076void 1000void
1077GST_validation_handle_hello (const struct GNUNET_MessageHeader *hello) 1001GST_validation_handle_hello (const struct GNUNET_MessageHeader *hello)
1078{ 1002{
1079 const struct GNUNET_HELLO_Message* hm = (const struct GNUNET_HELLO_Message*) hello; 1003 const struct GNUNET_HELLO_Message *hm =
1004 (const struct GNUNET_HELLO_Message *) hello;
1080 struct ValidateAddressContext vac; 1005 struct ValidateAddressContext vac;
1081 1006
1082 if ( (GNUNET_OK != 1007 if ((GNUNET_OK !=
1083 GNUNET_HELLO_get_id (hm, &vac.pid)) || 1008 GNUNET_HELLO_get_id (hm, &vac.pid)) ||
1084 (GNUNET_OK != 1009 (GNUNET_OK != GNUNET_HELLO_get_key (hm, &vac.public_key)))
1085 GNUNET_HELLO_get_key (hm, &vac.public_key)) ) 1010 {
1086 { 1011 /* malformed HELLO */
1087 /* malformed HELLO */ 1012 GNUNET_break (0);
1088 GNUNET_break (0); 1013 return;
1089 return; 1014 }
1090 }
1091 GNUNET_assert (NULL == 1015 GNUNET_assert (NULL ==
1092 GNUNET_HELLO_iterate_addresses (hm, 1016 GNUNET_HELLO_iterate_addresses (hm,
1093 GNUNET_NO, 1017 GNUNET_NO,
1094 &validate_address, 1018 &validate_address, &vac));
1095 &vac));
1096} 1019}
1097 1020
1098 1021
@@ -1123,21 +1046,16 @@ struct IteratorContext
1123 * @return GNUNET_OK (continue to iterate) 1046 * @return GNUNET_OK (continue to iterate)
1124 */ 1047 */
1125static int 1048static int
1126iterate_addresses (void *cls, 1049iterate_addresses (void *cls, const GNUNET_HashCode * key, void *value)
1127 const GNUNET_HashCode *key,
1128 void *value)
1129{ 1050{
1130 struct IteratorContext *ic = cls; 1051 struct IteratorContext *ic = cls;
1131 struct ValidationEntry *ve = value; 1052 struct ValidationEntry *ve = value;
1132 1053
1133 ic->cb (ic->cb_cls, 1054 ic->cb (ic->cb_cls,
1134 &ve->public_key, 1055 &ve->public_key,
1135 &ve->pid, 1056 &ve->pid,
1136 ve->valid_until, 1057 ve->valid_until,
1137 ve->validation_block, 1058 ve->validation_block, ve->transport_name, ve->addr, ve->addrlen);
1138 ve->transport_name,
1139 ve->addr,
1140 ve->addrlen);
1141 return GNUNET_OK; 1059 return GNUNET_OK;
1142} 1060}
1143 1061
@@ -1156,17 +1074,15 @@ iterate_addresses (void *cls,
1156 */ 1074 */
1157void 1075void
1158GST_validation_get_addresses (const struct GNUNET_PeerIdentity *target, 1076GST_validation_get_addresses (const struct GNUNET_PeerIdentity *target,
1159 GST_ValidationAddressCallback cb, 1077 GST_ValidationAddressCallback cb, void *cb_cls)
1160 void *cb_cls)
1161{ 1078{
1162 struct IteratorContext ic; 1079 struct IteratorContext ic;
1163 1080
1164 ic.cb = cb; 1081 ic.cb = cb;
1165 ic.cb_cls = cb_cls; 1082 ic.cb_cls = cb_cls;
1166 GNUNET_CONTAINER_multihashmap_get_multiple (validation_map, 1083 GNUNET_CONTAINER_multihashmap_get_multiple (validation_map,
1167 &target->hashPubKey, 1084 &target->hashPubKey,
1168 &iterate_addresses, 1085 &iterate_addresses, &ic);
1169 &ic);
1170} 1086}
1171 1087
1172 1088