diff options
author | Christian Grothoff <christian@grothoff.org> | 2011-11-08 23:20:42 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2011-11-08 23:20:42 +0000 |
commit | a983a0267109b1b6a8e16e476e2f2956a8771b94 (patch) | |
tree | 79bcae73cdb7b87b4f55d4396e79baea76ef53a6 | |
parent | a3f8ef5b89dc44fc3acfb8f081a502f3409e4224 (diff) | |
download | gnunet-a983a0267109b1b6a8e16e476e2f2956a8771b94.tar.gz gnunet-a983a0267109b1b6a8e16e476e2f2956a8771b94.zip |
refactoring how we handle peer addresses in peerinfo/ats/transport/hello subsystems -- use a struct instead of 3--4 arguments
26 files changed, 619 insertions, 766 deletions
diff --git a/src/ats/ats_api_performance.c b/src/ats/ats_api_performance.c index ca489e4a6..8ac88ec63 100644 --- a/src/ats/ats_api_performance.c +++ b/src/ats/ats_api_performance.c | |||
@@ -269,9 +269,10 @@ process_pi_message (struct GNUNET_ATS_PerformanceHandle *ph, | |||
269 | { | 269 | { |
270 | const struct PeerInformationMessage *pi; | 270 | const struct PeerInformationMessage *pi; |
271 | const struct GNUNET_ATS_Information *atsi; | 271 | const struct GNUNET_ATS_Information *atsi; |
272 | const char *address; | 272 | const char *plugin_address; |
273 | const char *plugin_name; | 273 | const char *plugin_name; |
274 | uint16_t address_length; | 274 | struct GNUNET_HELLO_Address address; |
275 | uint16_t plugin_address_length; | ||
275 | uint16_t plugin_name_length; | 276 | uint16_t plugin_name_length; |
276 | uint32_t ats_count; | 277 | uint32_t ats_count; |
277 | 278 | ||
@@ -287,12 +288,12 @@ process_pi_message (struct GNUNET_ATS_PerformanceHandle *ph, | |||
287 | } | 288 | } |
288 | pi = (const struct PeerInformationMessage *) msg; | 289 | pi = (const struct PeerInformationMessage *) msg; |
289 | ats_count = ntohl (pi->ats_count); | 290 | ats_count = ntohl (pi->ats_count); |
290 | address_length = ntohs (pi->address_length); | 291 | plugin_address_length = ntohs (pi->address_length); |
291 | plugin_name_length = ntohs (pi->plugin_name_length); | 292 | plugin_name_length = ntohs (pi->plugin_name_length); |
292 | atsi = (const struct GNUNET_ATS_Information *) &pi[1]; | 293 | atsi = (const struct GNUNET_ATS_Information *) &pi[1]; |
293 | address = (const char *) &atsi[ats_count]; | 294 | plugin_address = (const char *) &atsi[ats_count]; |
294 | plugin_name = &address[address_length]; | 295 | plugin_name = &plugin_address[plugin_address_length]; |
295 | if ((address_length + plugin_name_length + | 296 | if ((plugin_address_length + plugin_name_length + |
296 | ats_count * sizeof (struct GNUNET_ATS_Information) + | 297 | ats_count * sizeof (struct GNUNET_ATS_Information) + |
297 | sizeof (struct PeerInformationMessage) != ntohs (msg->size)) || | 298 | sizeof (struct PeerInformationMessage) != ntohs (msg->size)) || |
298 | (ats_count > | 299 | (ats_count > |
@@ -302,7 +303,11 @@ process_pi_message (struct GNUNET_ATS_PerformanceHandle *ph, | |||
302 | GNUNET_break (0); | 303 | GNUNET_break (0); |
303 | return GNUNET_SYSERR; | 304 | return GNUNET_SYSERR; |
304 | } | 305 | } |
305 | ph->infocb (ph->infocb_cls, &pi->peer, plugin_name, address, address_length, | 306 | address.peer = pi->peer; |
307 | address.address = plugin_address; | ||
308 | address.address_length = plugin_address_length; | ||
309 | address.transport_name = plugin_name; | ||
310 | ph->infocb (ph->infocb_cls, &address, | ||
306 | pi->bandwidth_out, pi->bandwidth_in, atsi, ats_count); | 311 | pi->bandwidth_out, pi->bandwidth_in, atsi, ats_count); |
307 | return GNUNET_OK; | 312 | return GNUNET_OK; |
308 | } | 313 | } |
diff --git a/src/ats/ats_api_scheduling.c b/src/ats/ats_api_scheduling.c index c2e7c0ea9..0885f53e9 100644 --- a/src/ats/ats_api_scheduling.c +++ b/src/ats/ats_api_scheduling.c | |||
@@ -440,11 +440,12 @@ process_ats_message (void *cls, const struct GNUNET_MessageHeader *msg) | |||
440 | struct GNUNET_ATS_SchedulingHandle *sh = cls; | 440 | struct GNUNET_ATS_SchedulingHandle *sh = cls; |
441 | const struct AddressSuggestionMessage *m; | 441 | const struct AddressSuggestionMessage *m; |
442 | const struct GNUNET_ATS_Information *atsi; | 442 | const struct GNUNET_ATS_Information *atsi; |
443 | const char *address; | 443 | const char *plugin_address; |
444 | const char *plugin_name; | 444 | const char *plugin_name; |
445 | uint16_t address_length; | 445 | uint16_t plugin_address_length; |
446 | uint16_t plugin_name_length; | 446 | uint16_t plugin_name_length; |
447 | uint32_t ats_count; | 447 | uint32_t ats_count; |
448 | struct GNUNET_HELLO_Address address; | ||
448 | 449 | ||
449 | if (NULL == msg) | 450 | if (NULL == msg) |
450 | { | 451 | { |
@@ -470,12 +471,12 @@ process_ats_message (void *cls, const struct GNUNET_MessageHeader *msg) | |||
470 | } | 471 | } |
471 | m = (const struct AddressSuggestionMessage *) msg; | 472 | m = (const struct AddressSuggestionMessage *) msg; |
472 | ats_count = ntohl (m->ats_count); | 473 | ats_count = ntohl (m->ats_count); |
473 | address_length = ntohs (m->address_length); | 474 | plugin_address_length = ntohs (m->address_length); |
474 | atsi = (const struct GNUNET_ATS_Information *) &m[1]; | 475 | atsi = (const struct GNUNET_ATS_Information *) &m[1]; |
475 | address = (const char *) &atsi[ats_count]; | 476 | plugin_address = (const char *) &atsi[ats_count]; |
476 | plugin_name = &address[address_length]; | 477 | plugin_name = &plugin_address[plugin_address_length]; |
477 | plugin_name_length = ntohs (m->plugin_name_length); | 478 | plugin_name_length = ntohs (m->plugin_name_length); |
478 | if ((address_length + plugin_name_length + | 479 | if ((plugin_address_length + plugin_name_length + |
479 | ats_count * sizeof (struct GNUNET_ATS_Information) + | 480 | ats_count * sizeof (struct GNUNET_ATS_Information) + |
480 | sizeof (struct AddressSuggestionMessage) != ntohs (msg->size)) || | 481 | sizeof (struct AddressSuggestionMessage) != ntohs (msg->size)) || |
481 | (ats_count > | 482 | (ats_count > |
@@ -500,9 +501,11 @@ process_ats_message (void *cls, const struct GNUNET_MessageHeader *msg) | |||
500 | GNUNET_break (0); | 501 | GNUNET_break (0); |
501 | } | 502 | } |
502 | } | 503 | } |
503 | 504 | address.peer = m->peer; | |
504 | sh->suggest_cb (sh->suggest_cb_cls, &m->peer, plugin_name, address, | 505 | address.address = plugin_address; |
505 | address_length, s, m->bandwidth_out, | 506 | address.address_length = plugin_address_length; |
507 | address.transport_name = plugin_name; | ||
508 | sh->suggest_cb (sh->suggest_cb_cls, &address, s, m->bandwidth_out, | ||
506 | m->bandwidth_in, atsi, ats_count); | 509 | m->bandwidth_in, atsi, ats_count); |
507 | 510 | ||
508 | 511 | ||
@@ -637,19 +640,15 @@ GNUNET_ATS_suggest_address (struct GNUNET_ATS_SchedulingHandle *sh, | |||
637 | * for later use). Update bandwidth assignments. | 640 | * for later use). Update bandwidth assignments. |
638 | * | 641 | * |
639 | * @param sh handle | 642 | * @param sh handle |
640 | * @param peer identity of the new peer | 643 | * @param address the address |
641 | * @param plugin_name name of the transport plugin | ||
642 | * @param plugin_addr address (if available) | ||
643 | * @param plugin_addr_len number of bytes in plugin_addr | ||
644 | * @param session session handle (if available) | 644 | * @param session session handle (if available) |
645 | * @param ats performance data for the address | 645 | * @param ats performance data for the address |
646 | * @param ats_count number of performance records in 'ats' | 646 | * @param ats_count number of performance records in 'ats' |
647 | */ | 647 | */ |
648 | void | 648 | void |
649 | GNUNET_ATS_address_update (struct GNUNET_ATS_SchedulingHandle *sh, | 649 | GNUNET_ATS_address_update (struct GNUNET_ATS_SchedulingHandle *sh, |
650 | const struct GNUNET_PeerIdentity *peer, | 650 | const struct GNUNET_HELLO_Address *address, |
651 | const char *plugin_name, const void *plugin_addr, | 651 | struct Session *session, |
652 | size_t plugin_addr_len, struct Session *session, | ||
653 | const struct GNUNET_ATS_Information *ats, | 652 | const struct GNUNET_ATS_Information *ats, |
654 | uint32_t ats_count) | 653 | uint32_t ats_count) |
655 | { | 654 | { |
@@ -660,12 +659,12 @@ GNUNET_ATS_address_update (struct GNUNET_ATS_SchedulingHandle *sh, | |||
660 | size_t namelen; | 659 | size_t namelen; |
661 | size_t msize; | 660 | size_t msize; |
662 | 661 | ||
663 | namelen = (plugin_name == NULL) ? 0 : strlen (plugin_name) + 1; | 662 | namelen = (address->transport_name == NULL) ? 0 : strlen (address->transport_name) + 1; |
664 | msize = | 663 | msize = |
665 | sizeof (struct AddressUpdateMessage) + plugin_addr_len + | 664 | sizeof (struct AddressUpdateMessage) + address->address_length + |
666 | ats_count * sizeof (struct GNUNET_ATS_Information) + namelen; | 665 | ats_count * sizeof (struct GNUNET_ATS_Information) + namelen; |
667 | if ((msize >= GNUNET_SERVER_MAX_MESSAGE_SIZE) || | 666 | if ((msize >= GNUNET_SERVER_MAX_MESSAGE_SIZE) || |
668 | (plugin_addr_len >= GNUNET_SERVER_MAX_MESSAGE_SIZE) || | 667 | (address->address_length >= GNUNET_SERVER_MAX_MESSAGE_SIZE) || |
669 | (namelen >= GNUNET_SERVER_MAX_MESSAGE_SIZE) || | 668 | (namelen >= GNUNET_SERVER_MAX_MESSAGE_SIZE) || |
670 | (ats_count >= | 669 | (ats_count >= |
671 | GNUNET_SERVER_MAX_MESSAGE_SIZE / sizeof (struct GNUNET_ATS_Information))) | 670 | GNUNET_SERVER_MAX_MESSAGE_SIZE / sizeof (struct GNUNET_ATS_Information))) |
@@ -681,15 +680,15 @@ GNUNET_ATS_address_update (struct GNUNET_ATS_SchedulingHandle *sh, | |||
681 | m->header.type = htons (GNUNET_MESSAGE_TYPE_ATS_ADDRESS_UPDATE); | 680 | m->header.type = htons (GNUNET_MESSAGE_TYPE_ATS_ADDRESS_UPDATE); |
682 | m->header.size = htons (msize); | 681 | m->header.size = htons (msize); |
683 | m->ats_count = htonl (ats_count); | 682 | m->ats_count = htonl (ats_count); |
684 | m->peer = *peer; | 683 | m->peer = address->peer; |
685 | m->address_length = htons (plugin_addr_len); | 684 | m->address_length = htons (address->address_length); |
686 | m->plugin_name_length = htons (namelen); | 685 | m->plugin_name_length = htons (namelen); |
687 | m->session_id = htonl (get_session_id (sh, session, peer)); | 686 | m->session_id = htonl (get_session_id (sh, session, &address->peer)); |
688 | am = (struct GNUNET_ATS_Information *) &m[1]; | 687 | am = (struct GNUNET_ATS_Information *) &m[1]; |
689 | memcpy (am, ats, ats_count * sizeof (struct GNUNET_ATS_Information)); | 688 | memcpy (am, ats, ats_count * sizeof (struct GNUNET_ATS_Information)); |
690 | pm = (char *) &am[ats_count]; | 689 | pm = (char *) &am[ats_count]; |
691 | memcpy (pm, plugin_addr, plugin_addr_len); | 690 | memcpy (pm, address->address, address->address_length); |
692 | memcpy (&pm[plugin_addr_len], plugin_name, namelen); | 691 | memcpy (&pm[address->address_length], address->transport_name, namelen); |
693 | GNUNET_CONTAINER_DLL_insert_tail (sh->pending_head, sh->pending_tail, p); | 692 | GNUNET_CONTAINER_DLL_insert_tail (sh->pending_head, sh->pending_tail, p); |
694 | do_transmit (sh); | 693 | do_transmit (sh); |
695 | } | 694 | } |
@@ -699,19 +698,15 @@ GNUNET_ATS_address_update (struct GNUNET_ATS_SchedulingHandle *sh, | |||
699 | * An address is now in use or not used any more. | 698 | * An address is now in use or not used any more. |
700 | * | 699 | * |
701 | * @param sh handle | 700 | * @param sh handle |
702 | * @param peer identity of the peer | 701 | * @param address the address |
703 | * @param plugin_name name of the transport plugin | ||
704 | * @param plugin_addr address (if available) | ||
705 | * @param plugin_addr_len number of bytes in plugin_addr | ||
706 | * @param session session handle | 702 | * @param session session handle |
707 | * @param in_use GNUNET_YES if this address is now used, GNUNET_NO | 703 | * @param in_use GNUNET_YES if this address is now used, GNUNET_NO |
708 | * if address is not used any more | 704 | * if address is not used any more |
709 | */ | 705 | */ |
710 | void | 706 | void |
711 | GNUNET_ATS_address_in_use (struct GNUNET_ATS_SchedulingHandle *sh, | 707 | GNUNET_ATS_address_in_use (struct GNUNET_ATS_SchedulingHandle *sh, |
712 | const struct GNUNET_PeerIdentity *peer, | 708 | const struct GNUNET_HELLO_Address *address, |
713 | const char *plugin_name, const void *plugin_addr, | 709 | struct Session *session, |
714 | size_t plugin_addr_len, struct Session *session, | ||
715 | int in_use) | 710 | int in_use) |
716 | { | 711 | { |
717 | struct PendingMessage *p; | 712 | struct PendingMessage *p; |
@@ -720,10 +715,10 @@ GNUNET_ATS_address_in_use (struct GNUNET_ATS_SchedulingHandle *sh, | |||
720 | size_t namelen; | 715 | size_t namelen; |
721 | size_t msize; | 716 | size_t msize; |
722 | 717 | ||
723 | namelen = (plugin_name == NULL) ? 0 : strlen (plugin_name) + 1; | 718 | namelen = (address->transport_name == NULL) ? 0 : strlen (address->transport_name) + 1; |
724 | msize = sizeof (struct AddressUseMessage) + plugin_addr_len + namelen; | 719 | msize = sizeof (struct AddressUseMessage) + address->address_length + namelen; |
725 | if ((msize >= GNUNET_SERVER_MAX_MESSAGE_SIZE) || | 720 | if ((msize >= GNUNET_SERVER_MAX_MESSAGE_SIZE) || |
726 | (plugin_addr_len >= GNUNET_SERVER_MAX_MESSAGE_SIZE) || | 721 | (address->address_length >= GNUNET_SERVER_MAX_MESSAGE_SIZE) || |
727 | (namelen >= GNUNET_SERVER_MAX_MESSAGE_SIZE)) | 722 | (namelen >= GNUNET_SERVER_MAX_MESSAGE_SIZE)) |
728 | { | 723 | { |
729 | GNUNET_break (0); | 724 | GNUNET_break (0); |
@@ -736,14 +731,14 @@ GNUNET_ATS_address_in_use (struct GNUNET_ATS_SchedulingHandle *sh, | |||
736 | m = (struct AddressUseMessage *) &p[1]; | 731 | m = (struct AddressUseMessage *) &p[1]; |
737 | m->header.type = htons (GNUNET_MESSAGE_TYPE_ATS_ADDRESS_IN_USE); | 732 | m->header.type = htons (GNUNET_MESSAGE_TYPE_ATS_ADDRESS_IN_USE); |
738 | m->header.size = htons (msize); | 733 | m->header.size = htons (msize); |
739 | m->peer = *peer; | 734 | m->peer = address->peer; |
740 | m->in_use = htons (in_use); | 735 | m->in_use = htons (in_use); |
741 | m->address_length = htons (plugin_addr_len); | 736 | m->address_length = htons (address->address_length); |
742 | m->plugin_name_length = htons (namelen); | 737 | m->plugin_name_length = htons (namelen); |
743 | m->session_id = htonl (get_session_id (sh, session, peer)); | 738 | m->session_id = htonl (get_session_id (sh, session, &address->peer)); |
744 | pm = (char *) &m[1]; | 739 | pm = (char *) &m[1]; |
745 | memcpy (pm, plugin_addr, plugin_addr_len); | 740 | memcpy (pm, address->address, address->address_length); |
746 | memcpy (&pm[plugin_addr_len], plugin_name, namelen); | 741 | memcpy (&pm[address->address_length], address->transport_name, namelen); |
747 | GNUNET_CONTAINER_DLL_insert_tail (sh->pending_head, sh->pending_tail, p); | 742 | GNUNET_CONTAINER_DLL_insert_tail (sh->pending_head, sh->pending_tail, p); |
748 | 743 | ||
749 | do_transmit (sh); | 744 | do_transmit (sh); |
@@ -753,17 +748,13 @@ GNUNET_ATS_address_in_use (struct GNUNET_ATS_SchedulingHandle *sh, | |||
753 | * A session got destroyed, stop including it as a valid address. | 748 | * A session got destroyed, stop including it as a valid address. |
754 | * | 749 | * |
755 | * @param sh handle | 750 | * @param sh handle |
756 | * @param peer identity of the peer | 751 | * @param address the address |
757 | * @param plugin_name name of the transport plugin | ||
758 | * @param plugin_addr address (if available) | ||
759 | * @param plugin_addr_len number of bytes in plugin_addr | ||
760 | * @param session session handle that is no longer valid | 752 | * @param session session handle that is no longer valid |
761 | */ | 753 | */ |
762 | void | 754 | void |
763 | GNUNET_ATS_address_destroyed (struct GNUNET_ATS_SchedulingHandle *sh, | 755 | GNUNET_ATS_address_destroyed (struct GNUNET_ATS_SchedulingHandle *sh, |
764 | const struct GNUNET_PeerIdentity *peer, | 756 | const struct GNUNET_HELLO_Address *address, |
765 | const char *plugin_name, const void *plugin_addr, | 757 | struct Session *session) |
766 | size_t plugin_addr_len, struct Session *session) | ||
767 | { | 758 | { |
768 | struct PendingMessage *p; | 759 | struct PendingMessage *p; |
769 | struct AddressDestroyedMessage *m; | 760 | struct AddressDestroyedMessage *m; |
@@ -772,10 +763,10 @@ GNUNET_ATS_address_destroyed (struct GNUNET_ATS_SchedulingHandle *sh, | |||
772 | size_t msize; | 763 | size_t msize; |
773 | uint32_t session_id; | 764 | uint32_t session_id; |
774 | 765 | ||
775 | namelen = (plugin_name == NULL) ? 0 : strlen (plugin_name) + 1; | 766 | namelen = (address->transport_name == NULL) ? 0 : strlen (address->transport_name) + 1; |
776 | msize = sizeof (struct AddressDestroyedMessage) + plugin_addr_len + namelen; | 767 | msize = sizeof (struct AddressDestroyedMessage) + address->address_length + namelen; |
777 | if ((msize >= GNUNET_SERVER_MAX_MESSAGE_SIZE) || | 768 | if ((msize >= GNUNET_SERVER_MAX_MESSAGE_SIZE) || |
778 | (plugin_addr_len >= GNUNET_SERVER_MAX_MESSAGE_SIZE) || | 769 | (address->address_length >= GNUNET_SERVER_MAX_MESSAGE_SIZE) || |
779 | (namelen >= GNUNET_SERVER_MAX_MESSAGE_SIZE)) | 770 | (namelen >= GNUNET_SERVER_MAX_MESSAGE_SIZE)) |
780 | { | 771 | { |
781 | GNUNET_break (0); | 772 | GNUNET_break (0); |
@@ -790,17 +781,17 @@ GNUNET_ATS_address_destroyed (struct GNUNET_ATS_SchedulingHandle *sh, | |||
790 | m->header.type = htons (GNUNET_MESSAGE_TYPE_ATS_ADDRESS_DESTROYED); | 781 | m->header.type = htons (GNUNET_MESSAGE_TYPE_ATS_ADDRESS_DESTROYED); |
791 | m->header.size = htons (msize); | 782 | m->header.size = htons (msize); |
792 | m->reserved = htonl (0); | 783 | m->reserved = htonl (0); |
793 | m->peer = *peer; | 784 | m->peer = address->peer; |
794 | m->address_length = htons (plugin_addr_len); | 785 | m->address_length = htons (address->address_length); |
795 | m->plugin_name_length = htons (namelen); | 786 | m->plugin_name_length = htons (namelen); |
796 | session_id = get_session_id (sh, session, peer); | 787 | session_id = get_session_id (sh, session, &address->peer); |
797 | m->session_id = htonl (session_id); | 788 | m->session_id = htonl (session_id); |
798 | pm = (char *) &m[1]; | 789 | pm = (char *) &m[1]; |
799 | memcpy (pm, plugin_addr, plugin_addr_len); | 790 | memcpy (pm, address->address, address->address_length); |
800 | memcpy (&pm[plugin_addr_len], plugin_name, namelen); | 791 | memcpy (&pm[address->address_length], address->transport_name, namelen); |
801 | GNUNET_CONTAINER_DLL_insert_tail (sh->pending_head, sh->pending_tail, p); | 792 | GNUNET_CONTAINER_DLL_insert_tail (sh->pending_head, sh->pending_tail, p); |
802 | do_transmit (sh); | 793 | do_transmit (sh); |
803 | remove_session (sh, session_id, peer); | 794 | remove_session (sh, session_id, &address->peer); |
804 | } | 795 | } |
805 | 796 | ||
806 | /* end of ats_api_scheduling.c */ | 797 | /* end of ats_api_scheduling.c */ |
diff --git a/src/ats/test_ats_api_scheduling.c b/src/ats/test_ats_api_scheduling.c index a2ee7f060..d24bb2c73 100644 --- a/src/ats/test_ats_api_scheduling.c +++ b/src/ats/test_ats_api_scheduling.c | |||
@@ -118,22 +118,22 @@ end () | |||
118 | 118 | ||
119 | 119 | ||
120 | static void | 120 | static void |
121 | address_suggest_cb (void *cls, const struct GNUNET_PeerIdentity *peer, | 121 | address_suggest_cb (void *cls, |
122 | const char *plugin_name, const void *plugin_addr, | 122 | const struct GNUNET_HELLO_Address *address, |
123 | size_t plugin_addr_len, struct Session *session, | 123 | struct Session *session, |
124 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, | 124 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, |
125 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, | 125 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, |
126 | const struct GNUNET_ATS_Information *ats, | 126 | const struct GNUNET_ATS_Information *ats, |
127 | uint32_t ats_count) | 127 | uint32_t ats_count) |
128 | { | 128 | { |
129 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ATS suggests address `%s'\n", | 129 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ATS suggests address `%s'\n", |
130 | GNUNET_i2s (peer)); | 130 | GNUNET_i2s (&address->peer)); |
131 | 131 | ||
132 | GNUNET_assert (0 == | 132 | GNUNET_assert (0 == |
133 | memcmp (peer, &p[0].id, sizeof (struct GNUNET_PeerIdentity))); | 133 | memcmp (&address->peer, &p[0].id, sizeof (struct GNUNET_PeerIdentity))); |
134 | GNUNET_assert (0 == strcmp (plugin_name, addr[0].plugin)); | 134 | GNUNET_assert (0 == strcmp (address->transport_name, addr[0].plugin)); |
135 | GNUNET_assert (plugin_addr_len == addr[0].addr_len); | 135 | GNUNET_assert (address->address_length == addr[0].addr_len); |
136 | GNUNET_assert (0 == memcmp (plugin_addr, addr[0].plugin, plugin_addr_len)); | 136 | GNUNET_assert (0 == memcmp (address->address, addr[0].plugin, address->address_length)); |
137 | GNUNET_assert (addr[0].session == session); | 137 | GNUNET_assert (addr[0].session == session); |
138 | 138 | ||
139 | 139 | ||
@@ -166,6 +166,8 @@ static void | |||
166 | check (void *cls, char *const *args, const char *cfgfile, | 166 | check (void *cls, char *const *args, const char *cfgfile, |
167 | const struct GNUNET_CONFIGURATION_Handle *cfg) | 167 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
168 | { | 168 | { |
169 | struct GNUNET_HELLO_Address address0; | ||
170 | |||
169 | ret = GNUNET_SYSERR; | 171 | ret = GNUNET_SYSERR; |
170 | 172 | ||
171 | die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL); | 173 | die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL); |
@@ -198,16 +200,18 @@ check (void *cls, char *const *args, const char *cfgfile, | |||
198 | 200 | ||
199 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Testing address creation\n"); | 201 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Testing address creation\n"); |
200 | 202 | ||
201 | GNUNET_ATS_address_update (ats, &p[0].id, addr[0].plugin, addr[0].addr, | 203 | address0.peer = p[0].id; |
202 | addr[0].addr_len, addr[0].session, NULL, 0); | 204 | address0.transport_name = addr[0].plugin; |
205 | address0.address = addr[0].addr; | ||
206 | address0.address_length = addr[0].addr_len; | ||
207 | GNUNET_ATS_address_update (ats, &address0, addr[0].session, NULL, 0); | ||
203 | 208 | ||
204 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Testing ATS info creation\n"); | 209 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Testing ATS info creation\n"); |
205 | 210 | ||
206 | atsi[0].type = htonl (GNUNET_ATS_UTILIZATION_UP); | 211 | atsi[0].type = htonl (GNUNET_ATS_UTILIZATION_UP); |
207 | atsi[0].value = htonl (1024); | 212 | atsi[0].value = htonl (1024); |
208 | 213 | ||
209 | GNUNET_ATS_address_update (ats, &p[0].id, addr[0].plugin, addr[0].addr, | 214 | GNUNET_ATS_address_update (ats, &address0, addr[0].session, atsi, 1); |
210 | addr[0].addr_len, addr[0].session, atsi, 1); | ||
211 | 215 | ||
212 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Testing ATS info update\n"); | 216 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Testing ATS info update\n"); |
213 | 217 | ||
@@ -217,14 +221,12 @@ check (void *cls, char *const *args, const char *cfgfile, | |||
217 | atsi[1].type = htonl (GNUNET_ATS_UTILIZATION_DOWN); | 221 | atsi[1].type = htonl (GNUNET_ATS_UTILIZATION_DOWN); |
218 | atsi[1].value = htonl (1024); | 222 | atsi[1].value = htonl (1024); |
219 | 223 | ||
220 | GNUNET_ATS_address_update (ats, &p[0].id, addr[0].plugin, addr[0].addr, | 224 | GNUNET_ATS_address_update (ats, &address0, addr[0].session, atsi, 2); |
221 | addr[0].addr_len, addr[0].session, atsi, 2); | ||
222 | 225 | ||
223 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Testing manual address deletion \n"); | 226 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Testing manual address deletion \n"); |
224 | GNUNET_ATS_address_update (ats, &p[1].id, addr[0].plugin, addr[0].addr, | 227 | address0.peer = p[1].id; // FIXME: why? typo in old code? |
225 | addr[0].addr_len, addr[0].session, NULL, 0); | 228 | GNUNET_ATS_address_update (ats, &address0, addr[0].session, NULL, 0); |
226 | GNUNET_ATS_address_destroyed (ats, &p[1].id, addr[0].plugin, addr[0].addr, | 229 | GNUNET_ATS_address_destroyed (ats, &address0, addr[0].session); |
227 | addr[0].addr_len, addr[0].session); | ||
228 | 230 | ||
229 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Requesting peer `%s'\n", | 231 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Requesting peer `%s'\n", |
230 | GNUNET_i2s (&p[0].id)); | 232 | GNUNET_i2s (&p[0].id)); |
diff --git a/src/hello/address.c b/src/hello/address.c index 51fb296c3..5cfa10185 100644 --- a/src/hello/address.c +++ b/src/hello/address.c | |||
@@ -61,4 +61,49 @@ GNUNET_HELLO_address_allocate (const struct GNUNET_PeerIdentity *peer, | |||
61 | return addr; | 61 | return addr; |
62 | } | 62 | } |
63 | 63 | ||
64 | |||
65 | /** | ||
66 | * Copy an address struct. | ||
67 | * | ||
68 | * @param address address to copy | ||
69 | * @return a copy of the address struct | ||
70 | */ | ||
71 | struct GNUNET_HELLO_Address * | ||
72 | GNUNET_HELLO_address_copy (const struct GNUNET_HELLO_Address *address) | ||
73 | { | ||
74 | return GNUNET_HELLO_address_allocate (&address->peer, | ||
75 | address->transport_name, | ||
76 | address->address, | ||
77 | address->address_length); | ||
78 | } | ||
79 | |||
80 | |||
81 | /** | ||
82 | * Compare two addresses. Does NOT compare the peer identity, | ||
83 | * that is assumed already to match! | ||
84 | * | ||
85 | * @param a1 first address | ||
86 | * @param a2 second address | ||
87 | * @return 0 if the addresses are equal, -1 if a1<a2, 1 if a1>a2. | ||
88 | */ | ||
89 | int | ||
90 | GNUNET_HELLO_address_cmp (const struct GNUNET_HELLO_Address *a1, | ||
91 | const struct GNUNET_HELLO_Address *a2) | ||
92 | { | ||
93 | int ret; | ||
94 | |||
95 | ret = strcmp (a1->transport_name, | ||
96 | a2->transport_name); | ||
97 | if (0 != ret) | ||
98 | return ret; | ||
99 | if (a1->address_length < a2->address_length) | ||
100 | return -1; | ||
101 | if (a1->address_length > a2->address_length) | ||
102 | return 1; | ||
103 | return memcmp (a1->address, | ||
104 | a1->address, | ||
105 | a1->address_length); | ||
106 | } | ||
107 | |||
108 | |||
64 | /* end of address.c */ | 109 | /* end of address.c */ |
diff --git a/src/hello/hello.c b/src/hello/hello.c index a95c0eee2..b7f29f539 100644 --- a/src/hello/hello.c +++ b/src/hello/hello.c | |||
@@ -65,38 +65,36 @@ struct GNUNET_HELLO_Message | |||
65 | * Copy the given address information into | 65 | * Copy the given address information into |
66 | * the given buffer using the format of HELLOs. | 66 | * the given buffer using the format of HELLOs. |
67 | * | 67 | * |
68 | * @param tname name of the transport plugin | 68 | * @param addess the address |
69 | * @param expiration expiration for the address | 69 | * @param expiration expiration for the address |
70 | * @param addr the address | ||
71 | * @param addr_len length of the address in bytes | ||
72 | * @param target where to copy the address | 70 | * @param target where to copy the address |
73 | * @param max maximum number of bytes to copy to target | 71 | * @param max maximum number of bytes to copy to target |
74 | * @return number of bytes copied, 0 if | 72 | * @return number of bytes copied, 0 if |
75 | * the target buffer was not big enough. | 73 | * the target buffer was not big enough. |
76 | */ | 74 | */ |
77 | size_t | 75 | size_t |
78 | GNUNET_HELLO_add_address (const char *tname, | 76 | GNUNET_HELLO_add_address (const struct GNUNET_HELLO_Address *address, |
79 | struct GNUNET_TIME_Absolute expiration, | 77 | struct GNUNET_TIME_Absolute expiration, |
80 | const void *addr, uint16_t addr_len, char *target, | 78 | char *target, |
81 | size_t max) | 79 | size_t max) |
82 | { | 80 | { |
83 | uint16_t alen; | 81 | uint16_t alen; |
84 | size_t slen; | 82 | size_t slen; |
85 | struct GNUNET_TIME_AbsoluteNBO exp; | 83 | struct GNUNET_TIME_AbsoluteNBO exp; |
86 | 84 | ||
87 | slen = strlen (tname) + 1; | 85 | slen = strlen (address->transport_name) + 1; |
88 | if (slen + sizeof (uint16_t) + sizeof (struct GNUNET_TIME_AbsoluteNBO) + | 86 | if (slen + sizeof (uint16_t) + sizeof (struct GNUNET_TIME_AbsoluteNBO) + |
89 | addr_len > max) | 87 | address->address_length > max) |
90 | return 0; | 88 | return 0; |
91 | exp = GNUNET_TIME_absolute_hton (expiration); | 89 | exp = GNUNET_TIME_absolute_hton (expiration); |
92 | alen = htons (addr_len); | 90 | alen = htons ((uint16_t) address->address_length); |
93 | memcpy (target, tname, slen); | 91 | memcpy (target, address->transport_name, slen); |
94 | memcpy (&target[slen], &alen, sizeof (uint16_t)); | 92 | memcpy (&target[slen], &alen, sizeof (uint16_t)); |
95 | slen += sizeof (uint16_t); | 93 | slen += sizeof (uint16_t); |
96 | memcpy (&target[slen], &exp, sizeof (struct GNUNET_TIME_AbsoluteNBO)); | 94 | memcpy (&target[slen], &exp, sizeof (struct GNUNET_TIME_AbsoluteNBO)); |
97 | slen += sizeof (struct GNUNET_TIME_AbsoluteNBO); | 95 | slen += sizeof (struct GNUNET_TIME_AbsoluteNBO); |
98 | memcpy (&target[slen], addr, addr_len); | 96 | memcpy (&target[slen], address->address, address->address_length); |
99 | slen += addr_len; | 97 | slen += address->address_length; |
100 | return slen; | 98 | return slen; |
101 | } | 99 | } |
102 | 100 | ||
@@ -207,6 +205,7 @@ GNUNET_HELLO_iterate_addresses (const struct GNUNET_HELLO_Message *msg, | |||
207 | int return_modified, | 205 | int return_modified, |
208 | GNUNET_HELLO_AddressIterator it, void *it_cls) | 206 | GNUNET_HELLO_AddressIterator it, void *it_cls) |
209 | { | 207 | { |
208 | struct GNUNET_HELLO_Address address; | ||
210 | uint16_t msize; | 209 | uint16_t msize; |
211 | struct GNUNET_HELLO_Message *ret; | 210 | struct GNUNET_HELLO_Message *ret; |
212 | const char *inptr; | 211 | const char *inptr; |
@@ -232,6 +231,9 @@ GNUNET_HELLO_iterate_addresses (const struct GNUNET_HELLO_Message *msg, | |||
232 | insize = msize - sizeof (struct GNUNET_HELLO_Message); | 231 | insize = msize - sizeof (struct GNUNET_HELLO_Message); |
233 | wpos = 0; | 232 | wpos = 0; |
234 | woff = (ret != NULL) ? (char *) &ret[1] : NULL; | 233 | woff = (ret != NULL) ? (char *) &ret[1] : NULL; |
234 | GNUNET_CRYPTO_hash (&msg->publicKey, | ||
235 | sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), | ||
236 | &address.peer.hashPubKey); | ||
235 | while (insize > 0) | 237 | while (insize > 0) |
236 | { | 238 | { |
237 | esize = get_hello_address_size (inptr, insize, &alen); | 239 | esize = get_hello_address_size (inptr, insize, &alen); |
@@ -244,9 +246,10 @@ GNUNET_HELLO_iterate_addresses (const struct GNUNET_HELLO_Message *msg, | |||
244 | memcpy (&expire, | 246 | memcpy (&expire, |
245 | &inptr[esize - alen - sizeof (struct GNUNET_TIME_AbsoluteNBO)], | 247 | &inptr[esize - alen - sizeof (struct GNUNET_TIME_AbsoluteNBO)], |
246 | sizeof (struct GNUNET_TIME_AbsoluteNBO)); | 248 | sizeof (struct GNUNET_TIME_AbsoluteNBO)); |
247 | iret = | 249 | address.address = &inptr[esize - alen]; |
248 | it (it_cls, inptr, GNUNET_TIME_absolute_ntoh (expire), | 250 | address.address_length = alen; |
249 | &inptr[esize - alen], alen); | 251 | address.transport_name = inptr; |
252 | iret = it (it_cls, &address, GNUNET_TIME_absolute_ntoh (expire)); | ||
250 | if (iret == GNUNET_SYSERR) | 253 | if (iret == GNUNET_SYSERR) |
251 | { | 254 | { |
252 | if (ret != NULL) | 255 | if (ret != NULL) |
@@ -270,23 +273,21 @@ GNUNET_HELLO_iterate_addresses (const struct GNUNET_HELLO_Message *msg, | |||
270 | 273 | ||
271 | struct ExpireContext | 274 | struct ExpireContext |
272 | { | 275 | { |
273 | const void *addr; | 276 | const struct GNUNET_HELLO_Address *address; |
274 | const char *tname; | ||
275 | uint16_t addrlen; | ||
276 | int found; | 277 | int found; |
277 | struct GNUNET_TIME_Absolute expiration; | 278 | struct GNUNET_TIME_Absolute expiration; |
278 | }; | 279 | }; |
279 | 280 | ||
280 | 281 | ||
281 | static int | 282 | static int |
282 | get_match_exp (void *cls, const char *tname, | 283 | get_match_exp (void *cls, |
283 | struct GNUNET_TIME_Absolute expiration, const void *addr, | 284 | const struct GNUNET_HELLO_Address *address, |
284 | uint16_t addrlen) | 285 | struct GNUNET_TIME_Absolute expiration) |
285 | { | 286 | { |
286 | struct ExpireContext *ec = cls; | 287 | struct ExpireContext *ec = cls; |
287 | 288 | ||
288 | if ((addrlen == ec->addrlen) && (0 == memcmp (addr, ec->addr, addrlen)) && | 289 | if (0 == GNUNET_HELLO_address_cmp (address, |
289 | (0 == strcmp (tname, ec->tname))) | 290 | ec->address)) |
290 | { | 291 | { |
291 | ec->found = GNUNET_YES; | 292 | ec->found = GNUNET_YES; |
292 | ec->expiration = expiration; | 293 | ec->expiration = expiration; |
@@ -310,17 +311,15 @@ struct MergeContext | |||
310 | 311 | ||
311 | 312 | ||
312 | static int | 313 | static int |
313 | copy_latest (void *cls, const char *tname, | 314 | copy_latest (void *cls, |
314 | struct GNUNET_TIME_Absolute expiration, const void *addr, | 315 | const struct GNUNET_HELLO_Address *address, |
315 | uint16_t addrlen) | 316 | struct GNUNET_TIME_Absolute expiration) |
316 | { | 317 | { |
317 | struct MergeContext *mc = cls; | 318 | struct MergeContext *mc = cls; |
318 | struct ExpireContext ec; | 319 | struct ExpireContext ec; |
319 | 320 | ||
320 | ec.addr = addr; | 321 | ec.address = address; |
321 | ec.addrlen = addrlen; | ||
322 | ec.found = GNUNET_NO; | 322 | ec.found = GNUNET_NO; |
323 | ec.tname = tname; | ||
324 | GNUNET_HELLO_iterate_addresses (mc->other, GNUNET_NO, &get_match_exp, &ec); | 323 | GNUNET_HELLO_iterate_addresses (mc->other, GNUNET_NO, &get_match_exp, &ec); |
325 | if ((ec.found == GNUNET_NO) || | 324 | if ((ec.found == GNUNET_NO) || |
326 | (ec.expiration.abs_value < expiration.abs_value) || | 325 | (ec.expiration.abs_value < expiration.abs_value) || |
@@ -328,8 +327,9 @@ copy_latest (void *cls, const char *tname, | |||
328 | (mc->take_equal == GNUNET_YES))) | 327 | (mc->take_equal == GNUNET_YES))) |
329 | { | 328 | { |
330 | mc->ret += | 329 | mc->ret += |
331 | GNUNET_HELLO_add_address (tname, expiration, addr, addrlen, | 330 | GNUNET_HELLO_add_address (address, |
332 | &mc->buf[mc->ret], mc->max - mc->ret); | 331 | expiration, |
332 | &mc->buf[mc->ret], mc->max - mc->ret); | ||
333 | } | 333 | } |
334 | return GNUNET_OK; | 334 | return GNUNET_OK; |
335 | } | 335 | } |
@@ -388,25 +388,23 @@ struct DeltaContext | |||
388 | 388 | ||
389 | 389 | ||
390 | static int | 390 | static int |
391 | delta_match (void *cls, const char *tname, | 391 | delta_match (void *cls, |
392 | struct GNUNET_TIME_Absolute expiration, const void *addr, | 392 | const struct GNUNET_HELLO_Address *address, |
393 | uint16_t addrlen) | 393 | struct GNUNET_TIME_Absolute expiration) |
394 | { | 394 | { |
395 | struct DeltaContext *dc = cls; | 395 | struct DeltaContext *dc = cls; |
396 | int ret; | 396 | int ret; |
397 | struct ExpireContext ec; | 397 | struct ExpireContext ec; |
398 | 398 | ||
399 | ec.addr = addr; | 399 | ec.address = address; |
400 | ec.addrlen = addrlen; | ||
401 | ec.found = GNUNET_NO; | 400 | ec.found = GNUNET_NO; |
402 | ec.tname = tname; | ||
403 | GNUNET_HELLO_iterate_addresses (dc->old_hello, GNUNET_NO, &get_match_exp, | 401 | GNUNET_HELLO_iterate_addresses (dc->old_hello, GNUNET_NO, &get_match_exp, |
404 | &ec); | 402 | &ec); |
405 | if ((ec.found == GNUNET_YES) && | 403 | if ((ec.found == GNUNET_YES) && |
406 | ((ec.expiration.abs_value > expiration.abs_value) || | 404 | ((ec.expiration.abs_value > expiration.abs_value) || |
407 | (ec.expiration.abs_value >= dc->expiration_limit.abs_value))) | 405 | (ec.expiration.abs_value >= dc->expiration_limit.abs_value))) |
408 | return GNUNET_YES; /* skip */ | 406 | return GNUNET_YES; /* skip */ |
409 | ret = dc->it (dc->it_cls, tname, expiration, addr, addrlen); | 407 | ret = dc->it (dc->it_cls, address, expiration); |
410 | return ret; | 408 | return ret; |
411 | } | 409 | } |
412 | 410 | ||
@@ -532,30 +530,26 @@ struct EqualsContext | |||
532 | 530 | ||
533 | const struct GNUNET_HELLO_Message *h2; | 531 | const struct GNUNET_HELLO_Message *h2; |
534 | 532 | ||
535 | const char *tname; | 533 | const struct GNUNET_HELLO_Address *address; |
536 | |||
537 | const void *addr; | ||
538 | 534 | ||
539 | struct GNUNET_TIME_Absolute expiration; | 535 | struct GNUNET_TIME_Absolute expiration; |
540 | 536 | ||
541 | int found; | 537 | int found; |
542 | 538 | ||
543 | uint16_t addrlen; | ||
544 | |||
545 | }; | 539 | }; |
546 | 540 | ||
547 | 541 | ||
548 | static int | 542 | static int |
549 | find_other_matching (void *cls, const char *tname, | 543 | find_other_matching (void *cls, const struct GNUNET_HELLO_Address *address, |
550 | struct GNUNET_TIME_Absolute expiration, const void *addr, | 544 | struct GNUNET_TIME_Absolute expiration) |
551 | uint16_t addrlen) | ||
552 | { | 545 | { |
553 | struct EqualsContext *ec = cls; | 546 | struct EqualsContext *ec = cls; |
554 | 547 | ||
555 | if (expiration.abs_value < ec->expiration_limit.abs_value) | 548 | if (expiration.abs_value < ec->expiration_limit.abs_value) |
556 | return GNUNET_YES; | 549 | return GNUNET_YES; |
557 | if ((addrlen == ec->addrlen) && (0 == strcmp (tname, ec->tname)) && | 550 | if (0 == |
558 | (0 == memcmp (addr, ec->addr, addrlen))) | 551 | GNUNET_HELLO_address_cmp (address, |
552 | ec->address)) | ||
559 | { | 553 | { |
560 | ec->found = GNUNET_YES; | 554 | ec->found = GNUNET_YES; |
561 | if (expiration.abs_value < ec->expiration.abs_value) | 555 | if (expiration.abs_value < ec->expiration.abs_value) |
@@ -567,18 +561,15 @@ find_other_matching (void *cls, const char *tname, | |||
567 | 561 | ||
568 | 562 | ||
569 | static int | 563 | static int |
570 | find_matching (void *cls, const char *tname, | 564 | find_matching (void *cls, const struct GNUNET_HELLO_Address *address, |
571 | struct GNUNET_TIME_Absolute expiration, const void *addr, | 565 | struct GNUNET_TIME_Absolute expiration) |
572 | uint16_t addrlen) | ||
573 | { | 566 | { |
574 | struct EqualsContext *ec = cls; | 567 | struct EqualsContext *ec = cls; |
575 | 568 | ||
576 | if (expiration.abs_value < ec->expiration_limit.abs_value) | 569 | if (expiration.abs_value < ec->expiration_limit.abs_value) |
577 | return GNUNET_YES; | 570 | return GNUNET_YES; |
578 | ec->tname = tname; | 571 | ec->address = address; |
579 | ec->expiration = expiration; | 572 | ec->expiration = expiration; |
580 | ec->addr = addr; | ||
581 | ec->addrlen = addrlen; | ||
582 | ec->found = GNUNET_NO; | 573 | ec->found = GNUNET_NO; |
583 | GNUNET_HELLO_iterate_addresses (ec->h2, GNUNET_NO, &find_other_matching, ec); | 574 | GNUNET_HELLO_iterate_addresses (ec->h2, GNUNET_NO, &find_other_matching, ec); |
584 | if (ec->found == GNUNET_NO) | 575 | if (ec->found == GNUNET_NO) |
@@ -630,9 +621,8 @@ GNUNET_HELLO_equals (const struct GNUNET_HELLO_Message *h1, | |||
630 | 621 | ||
631 | 622 | ||
632 | static int | 623 | static int |
633 | find_min_expire (void *cls, const char *tname, | 624 | find_min_expire (void *cls, const struct GNUNET_HELLO_Address *address, |
634 | struct GNUNET_TIME_Absolute expiration, const void *addr, | 625 | struct GNUNET_TIME_Absolute expiration) |
635 | uint16_t addrlen) | ||
636 | { | 626 | { |
637 | struct GNUNET_TIME_Absolute *min = cls; | 627 | struct GNUNET_TIME_Absolute *min = cls; |
638 | 628 | ||
diff --git a/src/hello/test_hello.c b/src/hello/test_hello.c index b6cdfcf66..ca69dfc18 100644 --- a/src/hello/test_hello.c +++ b/src/hello/test_hello.c | |||
@@ -35,55 +35,58 @@ my_addr_gen (void *cls, size_t max, void *buf) | |||
35 | { | 35 | { |
36 | unsigned int *i = cls; | 36 | unsigned int *i = cls; |
37 | size_t ret; | 37 | size_t ret; |
38 | struct GNUNET_HELLO_Address address; | ||
38 | 39 | ||
39 | #if DEBUG | 40 | #if DEBUG |
40 | fprintf (stderr, "DEBUG: my_addr_gen called with i = %d\n", *i); | 41 | fprintf (stderr, "DEBUG: my_addr_gen called with i = %d\n", *i); |
41 | #endif | 42 | #endif |
42 | if (0 == *i) | 43 | if (0 == *i) |
43 | return 0; | 44 | return 0; |
45 | memset (&address.peer, 0, sizeof (struct GNUNET_PeerIdentity)); | ||
46 | address.address = "address_information"; | ||
47 | address.transport_name = "test"; | ||
48 | address.address_length = *i; | ||
44 | ret = | 49 | ret = |
45 | GNUNET_HELLO_add_address ("test", GNUNET_TIME_absolute_get (), | 50 | GNUNET_HELLO_add_address (&address, GNUNET_TIME_absolute_get (), |
46 | "address_information", *i, buf, max); | 51 | buf, max); |
47 | (*i)--; | 52 | (*i)--; |
48 | return ret; | 53 | return ret; |
49 | } | 54 | } |
50 | 55 | ||
51 | 56 | ||
52 | static int | 57 | static int |
53 | check_addr (void *cls, const char *tname, | 58 | check_addr (void *cls, const struct GNUNET_HELLO_Address *address, |
54 | struct GNUNET_TIME_Absolute expiration, const void *addr, | 59 | struct GNUNET_TIME_Absolute expiration) |
55 | uint16_t addrlen) | ||
56 | { | 60 | { |
57 | unsigned int *i = cls; | 61 | unsigned int *i = cls; |
58 | 62 | ||
59 | #if DEBUG | 63 | #if DEBUG |
60 | fprintf (stderr, "DEBUG: check_addr called with i = %d and addrlen = %u\n", | 64 | fprintf (stderr, "DEBUG: check_addr called with i = %d and addrlen = %u\n", |
61 | *i, addrlen); | 65 | *i, address->address_length); |
62 | #endif | 66 | #endif |
63 | GNUNET_assert (addrlen > 0); | 67 | GNUNET_assert (address->address_length > 0); |
64 | GNUNET_assert (*i & (1 << (addrlen - 1))); | 68 | GNUNET_assert (*i & (1 << (address->address_length - 1))); |
65 | *i -= (1 << (addrlen - 1)); | 69 | *i -= (1 << (address->address_length - 1)); |
66 | GNUNET_assert (0 == strncmp ("address_information", addr, addrlen)); | 70 | GNUNET_assert (0 == strncmp ("address_information", address->address, address->address_length)); |
67 | GNUNET_assert (0 == strcmp ("test", tname)); | 71 | GNUNET_assert (0 == strcmp ("test", address->transport_name)); |
68 | return GNUNET_OK; | 72 | return GNUNET_OK; |
69 | } | 73 | } |
70 | 74 | ||
71 | 75 | ||
72 | static int | 76 | static int |
73 | remove_some (void *cls, const char *tname, | 77 | remove_some (void *cls, const struct GNUNET_HELLO_Address *address, |
74 | struct GNUNET_TIME_Absolute expiration, const void *addr, | 78 | struct GNUNET_TIME_Absolute expiration) |
75 | uint16_t addrlen) | ||
76 | { | 79 | { |
77 | unsigned int *i = cls; | 80 | unsigned int *i = cls; |
78 | 81 | ||
79 | #if DEBUG | 82 | #if DEBUG |
80 | fprintf (stderr, "DEBUG: remove_some called with i = %d and addrlen = %u\n", | 83 | fprintf (stderr, "DEBUG: remove_some called with i = %d and addrlen = %u\n", |
81 | *i, addrlen); | 84 | *i, address->address_length); |
82 | #endif | 85 | #endif |
83 | GNUNET_assert (addrlen > 0); | 86 | GNUNET_assert (address->address_length > 0); |
84 | if (*i & (1 << (addrlen - 1))) | 87 | if (*i & (1 << (address->address_length - 1))) |
85 | { | 88 | { |
86 | *i -= (1 << (addrlen - 1)); | 89 | *i -= (1 << (address->address_length - 1)); |
87 | return GNUNET_NO; | 90 | return GNUNET_NO; |
88 | } | 91 | } |
89 | return GNUNET_OK; | 92 | return GNUNET_OK; |
diff --git a/src/hostlist/hostlist-server.c b/src/hostlist/hostlist-server.c index 69d83b4d4..8e79ace1b 100644 --- a/src/hostlist/hostlist-server.c +++ b/src/hostlist/hostlist-server.c | |||
@@ -141,16 +141,13 @@ finish_response (struct HostSet *results) | |||
141 | * Set 'cls' to GNUNET_YES (we have an address!). | 141 | * Set 'cls' to GNUNET_YES (we have an address!). |
142 | * | 142 | * |
143 | * @param cls closure, an 'int*' | 143 | * @param cls closure, an 'int*' |
144 | * @param tname name of the transport (ignored) | 144 | * @param address the address (ignored) |
145 | * @param expiration expiration time (call is ignored if this is in the past) | 145 | * @param expiration expiration time (call is ignored if this is in the past) |
146 | * @param addr the address (ignored) | ||
147 | * @param addrlen length of the address (ignored) | ||
148 | * @return GNUNET_SYSERR to stop iterating (unless expiration has occured) | 146 | * @return GNUNET_SYSERR to stop iterating (unless expiration has occured) |
149 | */ | 147 | */ |
150 | static int | 148 | static int |
151 | check_has_addr (void *cls, const char *tname, | 149 | check_has_addr (void *cls, const struct GNUNET_HELLO_Address *address, |
152 | struct GNUNET_TIME_Absolute expiration, const void *addr, | 150 | struct GNUNET_TIME_Absolute expiration) |
153 | uint16_t addrlen) | ||
154 | { | 151 | { |
155 | int *arg = cls; | 152 | int *arg = cls; |
156 | 153 | ||
diff --git a/src/include/gnunet_ats_service.h b/src/include/gnunet_ats_service.h index ac963ce1d..a6edc786c 100644 --- a/src/include/gnunet_ats_service.h +++ b/src/include/gnunet_ats_service.h | |||
@@ -28,6 +28,7 @@ | |||
28 | 28 | ||
29 | #include "gnunet_constants.h" | 29 | #include "gnunet_constants.h" |
30 | #include "gnunet_util_lib.h" | 30 | #include "gnunet_util_lib.h" |
31 | #include "gnunet_hello_lib.h" | ||
31 | 32 | ||
32 | 33 | ||
33 | /** | 34 | /** |
@@ -439,10 +440,7 @@ struct Session; | |||
439 | * and address preferences as determined by ATS. | 440 | * and address preferences as determined by ATS. |
440 | * | 441 | * |
441 | * @param cls closure | 442 | * @param cls closure |
442 | * @param peer identity of the new peer | 443 | * @param address suggested address (including peer identity of the peer) |
443 | * @param plugin_name name of the plugin, NULL if we have no suggestion | ||
444 | * @param plugin_addr suggested address, NULL if we have no suggestion | ||
445 | * @param plugin_addr_len number of bytes in plugin_addr | ||
446 | * @param session session to use | 444 | * @param session session to use |
447 | * @param bandwidth_out assigned outbound bandwidth for the connection | 445 | * @param bandwidth_out assigned outbound bandwidth for the connection |
448 | * @param bandwidth_in assigned inbound bandwidth for the connection | 446 | * @param bandwidth_in assigned inbound bandwidth for the connection |
@@ -450,12 +448,7 @@ struct Session; | |||
450 | * @param ats_count number of performance records in 'ats' | 448 | * @param ats_count number of performance records in 'ats' |
451 | */ | 449 | */ |
452 | typedef void (*GNUNET_ATS_AddressSuggestionCallback) (void *cls, | 450 | typedef void (*GNUNET_ATS_AddressSuggestionCallback) (void *cls, |
453 | const struct | 451 | const struct GNUNET_HELLO_Address *address, |
454 | GNUNET_PeerIdentity * | ||
455 | peer, | ||
456 | const char *plugin_name, | ||
457 | const void *plugin_addr, | ||
458 | size_t plugin_addr_len, | ||
459 | struct Session * session, | 452 | struct Session * session, |
460 | struct | 453 | struct |
461 | GNUNET_BANDWIDTH_Value32NBO | 454 | GNUNET_BANDWIDTH_Value32NBO |
@@ -512,19 +505,15 @@ GNUNET_ATS_suggest_address (struct GNUNET_ATS_SchedulingHandle *sh, | |||
512 | * for later use). Update bandwidth assignments. | 505 | * for later use). Update bandwidth assignments. |
513 | * | 506 | * |
514 | * @param sh handle | 507 | * @param sh handle |
515 | * @param peer identity of the new peer | 508 | * @param address updated address |
516 | * @param plugin_name name of the transport plugin | ||
517 | * @param plugin_addr address (if available) | ||
518 | * @param plugin_addr_len number of bytes in plugin_addr | ||
519 | * @param session session handle (if available) | 509 | * @param session session handle (if available) |
520 | * @param ats performance data for the address | 510 | * @param ats performance data for the address |
521 | * @param ats_count number of performance records in 'ats' | 511 | * @param ats_count number of performance records in 'ats' |
522 | */ | 512 | */ |
523 | void | 513 | void |
524 | GNUNET_ATS_address_update (struct GNUNET_ATS_SchedulingHandle *sh, | 514 | GNUNET_ATS_address_update (struct GNUNET_ATS_SchedulingHandle *sh, |
525 | const struct GNUNET_PeerIdentity *peer, | 515 | const struct GNUNET_HELLO_Address *address, |
526 | const char *plugin_name, const void *plugin_addr, | 516 | struct Session *session, |
527 | size_t plugin_addr_len, struct Session *session, | ||
528 | const struct GNUNET_ATS_Information *ats, | 517 | const struct GNUNET_ATS_Information *ats, |
529 | uint32_t ats_count); | 518 | uint32_t ats_count); |
530 | 519 | ||
@@ -533,36 +522,28 @@ GNUNET_ATS_address_update (struct GNUNET_ATS_SchedulingHandle *sh, | |||
533 | * An address is now in use or not used any more. | 522 | * An address is now in use or not used any more. |
534 | * | 523 | * |
535 | * @param sh handle | 524 | * @param sh handle |
536 | * @param peer identity of the peer | 525 | * @param address the address |
537 | * @param plugin_name name of the transport plugin | ||
538 | * @param plugin_addr address (if available) | ||
539 | * @param plugin_addr_len number of bytes in plugin_addr | ||
540 | * @param session session handle | 526 | * @param session session handle |
541 | * @param in_use GNUNET_YES if this address is now used, GNUNET_NO | 527 | * @param in_use GNUNET_YES if this address is now used, GNUNET_NO |
542 | * if address is not used any more | 528 | * if address is not used any more |
543 | */ | 529 | */ |
544 | void | 530 | void |
545 | GNUNET_ATS_address_in_use (struct GNUNET_ATS_SchedulingHandle *sh, | 531 | GNUNET_ATS_address_in_use (struct GNUNET_ATS_SchedulingHandle *sh, |
546 | const struct GNUNET_PeerIdentity *peer, | 532 | const struct GNUNET_HELLO_Address *address, |
547 | const char *plugin_name, const void *plugin_addr, | 533 | struct Session *session, |
548 | size_t plugin_addr_len, struct Session *session, | ||
549 | int in_use); | 534 | int in_use); |
550 | 535 | ||
551 | /** | 536 | /** |
552 | * A session got destroyed, stop including it as a valid address. | 537 | * A session got destroyed, stop including it as a valid address. |
553 | * | 538 | * |
554 | * @param sh handle | 539 | * @param sh handle |
555 | * @param peer identity of the peer | 540 | * @param address the address |
556 | * @param plugin_name name of the transport plugin | ||
557 | * @param plugin_addr address (if available) | ||
558 | * @param plugin_addr_len number of bytes in plugin_addr | ||
559 | * @param session session handle that is no longer valid (if available) | 541 | * @param session session handle that is no longer valid (if available) |
560 | */ | 542 | */ |
561 | void | 543 | void |
562 | GNUNET_ATS_address_destroyed (struct GNUNET_ATS_SchedulingHandle *sh, | 544 | GNUNET_ATS_address_destroyed (struct GNUNET_ATS_SchedulingHandle *sh, |
563 | const struct GNUNET_PeerIdentity *peer, | 545 | const struct GNUNET_HELLO_Address *address, |
564 | const char *plugin_name, const void *plugin_addr, | 546 | struct Session *session); |
565 | size_t plugin_addr_len, struct Session *session); | ||
566 | 547 | ||
567 | 548 | ||
568 | /* ******************************** Performance API ***************************** */ | 549 | /* ******************************** Performance API ***************************** */ |
@@ -577,21 +558,14 @@ struct GNUNET_ATS_PerformanceHandle; | |||
577 | * Signature of a function that is called with QoS information about a peer. | 558 | * Signature of a function that is called with QoS information about a peer. |
578 | * | 559 | * |
579 | * @param cls closure | 560 | * @param cls closure |
580 | * @param peer identity of the new peer | 561 | * @param address the address |
581 | * @param plugin_name name of the plugin, NULL if we have no suggestion | ||
582 | * @param plugin_addr suggested address, NULL if we have no suggestion | ||
583 | * @param plugin_addr_len number of bytes in plugin_addr | ||
584 | * @param bandwidth_out assigned outbound bandwidth for the connection | 562 | * @param bandwidth_out assigned outbound bandwidth for the connection |
585 | * @param bandwidth_in assigned inbound bandwidth for the connection | 563 | * @param bandwidth_in assigned inbound bandwidth for the connection |
586 | * @param ats performance data for the address (as far as known) | 564 | * @param ats performance data for the address (as far as known) |
587 | * @param ats_count number of performance records in 'ats' | 565 | * @param ats_count number of performance records in 'ats' |
588 | */ | 566 | */ |
589 | typedef void (*GNUNET_ATS_PeerInformationCallback) (void *cls, | 567 | typedef void (*GNUNET_ATS_PeerInformationCallback) (void *cls, |
590 | const struct | 568 | const struct GNUNET_HELLO_Address *address, |
591 | GNUNET_PeerIdentity * peer, | ||
592 | const char *plugin_name, | ||
593 | const void *plugin_addr, | ||
594 | size_t plugin_addr_len, | ||
595 | struct | 569 | struct |
596 | GNUNET_BANDWIDTH_Value32NBO | 570 | GNUNET_BANDWIDTH_Value32NBO |
597 | bandwidth_out, | 571 | bandwidth_out, |
diff --git a/src/include/gnunet_hello_lib.h b/src/include/gnunet_hello_lib.h index 4e8554b52..886a41093 100644 --- a/src/include/gnunet_hello_lib.h +++ b/src/include/gnunet_hello_lib.h | |||
@@ -89,6 +89,30 @@ GNUNET_HELLO_address_allocate (const struct GNUNET_PeerIdentity *peer, | |||
89 | 89 | ||
90 | 90 | ||
91 | /** | 91 | /** |
92 | * Copy an address struct. | ||
93 | * | ||
94 | * @param address address to copy | ||
95 | * @return a copy of the address struct | ||
96 | */ | ||
97 | struct GNUNET_HELLO_Address * | ||
98 | GNUNET_HELLO_address_copy (const struct GNUNET_HELLO_Address *address); | ||
99 | |||
100 | |||
101 | /** | ||
102 | * Compare two addresses. Does NOT compare the peer identity, | ||
103 | * that is assumed already to match! | ||
104 | * | ||
105 | * @param a1 first address | ||
106 | * @param a2 second address | ||
107 | * @return 0 if the addresses are equal, -1 if a1<a2, 1 if a1>a2. | ||
108 | */ | ||
109 | int | ||
110 | GNUNET_HELLO_address_cmp (const struct GNUNET_HELLO_Address *a1, | ||
111 | const struct GNUNET_HELLO_Address *a2); | ||
112 | |||
113 | |||
114 | |||
115 | /** | ||
92 | * Free an address. | 116 | * Free an address. |
93 | * | 117 | * |
94 | * @param addr address to free | 118 | * @param addr address to free |
@@ -109,19 +133,17 @@ struct GNUNET_HELLO_Message; | |||
109 | * Copy the given address information into | 133 | * Copy the given address information into |
110 | * the given buffer using the format of HELLOs. | 134 | * the given buffer using the format of HELLOs. |
111 | * | 135 | * |
112 | * @param tname name of the transport plugin | 136 | * @param address address to add |
113 | * @param expiration expiration for the address | 137 | * @param expiration expiration for the address |
114 | * @param addr the address | ||
115 | * @param addr_len length of the address in bytes | ||
116 | * @param target where to copy the address | 138 | * @param target where to copy the address |
117 | * @param max maximum number of bytes to copy to target | 139 | * @param max maximum number of bytes to copy to target |
118 | * @return number of bytes copied, 0 if | 140 | * @return number of bytes copied, 0 if |
119 | * the target buffer was not big enough. | 141 | * the target buffer was not big enough. |
120 | */ | 142 | */ |
121 | size_t | 143 | size_t |
122 | GNUNET_HELLO_add_address (const char *tname, | 144 | GNUNET_HELLO_add_address (const struct GNUNET_HELLO_Address *address, |
123 | struct GNUNET_TIME_Absolute expiration, | 145 | struct GNUNET_TIME_Absolute expiration, |
124 | const void *addr, uint16_t addr_len, char *target, | 146 | char *target, |
125 | size_t max); | 147 | size_t max); |
126 | 148 | ||
127 | 149 | ||
@@ -204,18 +226,15 @@ GNUNET_HELLO_equals (const struct GNUNET_HELLO_Message *h1, | |||
204 | * Iterator callback to go over all addresses. | 226 | * Iterator callback to go over all addresses. |
205 | * | 227 | * |
206 | * @param cls closure | 228 | * @param cls closure |
207 | * @param tname name of the transport | 229 | * @param address the address |
208 | * @param expiration expiration time | 230 | * @param expiration expiration time |
209 | * @param addr the address | ||
210 | * @param addrlen length of the address | ||
211 | * @return GNUNET_OK to keep the address, | 231 | * @return GNUNET_OK to keep the address, |
212 | * GNUNET_NO to delete it from the HELLO | 232 | * GNUNET_NO to delete it from the HELLO |
213 | * GNUNET_SYSERR to stop iterating (but keep current address) | 233 | * GNUNET_SYSERR to stop iterating (but keep current address) |
214 | */ | 234 | */ |
215 | typedef int (*GNUNET_HELLO_AddressIterator) (void *cls, const char *tname, | 235 | typedef int (*GNUNET_HELLO_AddressIterator) (void *cls, |
216 | struct GNUNET_TIME_Absolute | 236 | const struct GNUNET_HELLO_Address *address, |
217 | expiration, const void *addr, | 237 | struct GNUNET_TIME_Absolute expiration); |
218 | uint16_t addrlen); | ||
219 | 238 | ||
220 | 239 | ||
221 | /** | 240 | /** |
diff --git a/src/include/gnunet_transport_service.h b/src/include/gnunet_transport_service.h index de764e7a6..2f027656b 100644 --- a/src/include/gnunet_transport_service.h +++ b/src/include/gnunet_transport_service.h | |||
@@ -293,6 +293,7 @@ struct GNUNET_TRANSPORT_AddressLookupContext; | |||
293 | * @param aluc_cls closure for aluc | 293 | * @param aluc_cls closure for aluc |
294 | * @return handle to cancel the operation, NULL on error | 294 | * @return handle to cancel the operation, NULL on error |
295 | */ | 295 | */ |
296 | // FIXME: use 'GNUNET_HELLO_Address' here! | ||
296 | struct GNUNET_TRANSPORT_AddressLookupContext * | 297 | struct GNUNET_TRANSPORT_AddressLookupContext * |
297 | GNUNET_TRANSPORT_address_lookup (const struct GNUNET_CONFIGURATION_Handle *cfg, | 298 | GNUNET_TRANSPORT_address_lookup (const struct GNUNET_CONFIGURATION_Handle *cfg, |
298 | const char *address, size_t addressLen, | 299 | const char *address, size_t addressLen, |
diff --git a/src/peerinfo-tool/gnunet-peerinfo.c b/src/peerinfo-tool/gnunet-peerinfo.c index 00ab22993..e40615a9b 100644 --- a/src/peerinfo-tool/gnunet-peerinfo.c +++ b/src/peerinfo-tool/gnunet-peerinfo.c | |||
@@ -96,16 +96,14 @@ process_resolved_address (void *cls, const char *address) | |||
96 | * Iterator callback to go over all addresses. | 96 | * Iterator callback to go over all addresses. |
97 | * | 97 | * |
98 | * @param cls closure | 98 | * @param cls closure |
99 | * @param tname name of the transport | 99 | * @param address the address |
100 | * @param expiration expiration time | 100 | * @param expiration expiration time |
101 | * @param addr the address | ||
102 | * @param addrlen length of the address | ||
103 | * @return GNUNET_OK to keep the address and continue | 101 | * @return GNUNET_OK to keep the address and continue |
104 | */ | 102 | */ |
105 | static int | 103 | static int |
106 | count_address (void *cls, const char *tname, | 104 | count_address (void *cls, |
107 | struct GNUNET_TIME_Absolute expiration, const void *addr, | 105 | const struct GNUNET_HELLO_Address *address, |
108 | uint16_t addrlen) | 106 | struct GNUNET_TIME_Absolute expiration) |
109 | { | 107 | { |
110 | struct PrintContext *pc = cls; | 108 | struct PrintContext *pc = cls; |
111 | 109 | ||
@@ -118,20 +116,21 @@ count_address (void *cls, const char *tname, | |||
118 | * Iterator callback to go over all addresses. | 116 | * Iterator callback to go over all addresses. |
119 | * | 117 | * |
120 | * @param cls closure | 118 | * @param cls closure |
121 | * @param tname name of the transport | 119 | * @param address the address |
122 | * @param expiration expiration time | 120 | * @param expiration expiration time |
123 | * @param addr the address | ||
124 | * @param addrlen length of the address | ||
125 | * @return GNUNET_OK to keep the address and continue | 121 | * @return GNUNET_OK to keep the address and continue |
126 | */ | 122 | */ |
127 | static int | 123 | static int |
128 | print_address (void *cls, const char *tname, | 124 | print_address (void *cls, |
129 | struct GNUNET_TIME_Absolute expiration, const void *addr, | 125 | const struct GNUNET_HELLO_Address *address, |
130 | uint16_t addrlen) | 126 | struct GNUNET_TIME_Absolute expiration) |
131 | { | 127 | { |
132 | struct PrintContext *pc = cls; | 128 | struct PrintContext *pc = cls; |
133 | 129 | ||
134 | GNUNET_TRANSPORT_address_lookup (cfg, addr, addrlen, no_resolve, tname, | 130 | GNUNET_TRANSPORT_address_lookup (cfg, |
131 | address->address, | ||
132 | address->address_length, no_resolve, | ||
133 | address->transport_name, | ||
135 | GNUNET_TIME_relative_multiply | 134 | GNUNET_TIME_relative_multiply |
136 | (GNUNET_TIME_UNIT_SECONDS, 10), | 135 | (GNUNET_TIME_UNIT_SECONDS, 10), |
137 | &process_resolved_address, pc); | 136 | &process_resolved_address, pc); |
diff --git a/src/peerinfo/gnunet-service-peerinfo.c b/src/peerinfo/gnunet-service-peerinfo.c index e453621d2..fc7cc781f 100644 --- a/src/peerinfo/gnunet-service-peerinfo.c +++ b/src/peerinfo/gnunet-service-peerinfo.c | |||
@@ -117,23 +117,22 @@ make_info_message (const struct HostEntry *he) | |||
117 | * Address iterator that causes expired entries to be discarded. | 117 | * Address iterator that causes expired entries to be discarded. |
118 | * | 118 | * |
119 | * @param cls pointer to the current time | 119 | * @param cls pointer to the current time |
120 | * @param tname name of the transport | 120 | * @param address the address |
121 | * @param expiration expiration time for the address | 121 | * @param expiration expiration time for the address |
122 | * @param addr the address | ||
123 | * @param addrlen length of addr in bytes | ||
124 | * @return GNUNET_NO if expiration smaller than the current time | 122 | * @return GNUNET_NO if expiration smaller than the current time |
125 | */ | 123 | */ |
126 | static int | 124 | static int |
127 | discard_expired (void *cls, const char *tname, | 125 | discard_expired (void *cls, |
128 | struct GNUNET_TIME_Absolute expiration, const void *addr, | 126 | const struct GNUNET_HELLO_Address *address, |
129 | uint16_t addrlen) | 127 | struct GNUNET_TIME_Absolute expiration) |
130 | { | 128 | { |
131 | const struct GNUNET_TIME_Absolute *now = cls; | 129 | const struct GNUNET_TIME_Absolute *now = cls; |
132 | 130 | ||
133 | if (now->abs_value > expiration.abs_value) | 131 | if (now->abs_value > expiration.abs_value) |
134 | { | 132 | { |
135 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 133 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
136 | _("Removing expired address of transport `%s'\n"), tname); | 134 | _("Removing expired address of transport `%s'\n"), |
135 | address->transport_name); | ||
137 | return GNUNET_NO; | 136 | return GNUNET_NO; |
138 | } | 137 | } |
139 | return GNUNET_OK; | 138 | return GNUNET_OK; |
diff --git a/src/peerinfo/test_peerinfo_api.c b/src/peerinfo/test_peerinfo_api.c index bbdc591f4..607c1fa4e 100644 --- a/src/peerinfo/test_peerinfo_api.c +++ b/src/peerinfo/test_peerinfo_api.c | |||
@@ -45,16 +45,17 @@ static struct GNUNET_PEERINFO_Handle *h; | |||
45 | static unsigned int retries; | 45 | static unsigned int retries; |
46 | 46 | ||
47 | static int | 47 | static int |
48 | check_it (void *cls, const char *tname, struct GNUNET_TIME_Absolute expiration, | 48 | check_it (void *cls, |
49 | const void *addr, uint16_t addrlen) | 49 | const struct GNUNET_HELLO_Address *address, |
50 | struct GNUNET_TIME_Absolute expiration) | ||
50 | { | 51 | { |
51 | unsigned int *agc = cls; | 52 | unsigned int *agc = cls; |
52 | 53 | ||
53 | if (addrlen > 0) | 54 | if (address != NULL) |
54 | { | 55 | { |
55 | GNUNET_assert (0 == strcmp ("peerinfotest", tname)); | 56 | GNUNET_assert (0 == strcmp ("peerinfotest", address->transport_name)); |
56 | GNUNET_assert (0 == strncmp ("Address", addr, addrlen)); | 57 | GNUNET_assert (0 == strncmp ("Address", address->address, address->address_length)); |
57 | (*agc) -= (1 << (addrlen - 1)); | 58 | (*agc) -= (1 << (address->address_length - 1)); |
58 | } | 59 | } |
59 | return GNUNET_OK; | 60 | return GNUNET_OK; |
60 | } | 61 | } |
@@ -65,14 +66,19 @@ address_generator (void *cls, size_t max, void *buf) | |||
65 | { | 66 | { |
66 | size_t *agc = cls; | 67 | size_t *agc = cls; |
67 | size_t ret; | 68 | size_t ret; |
69 | struct GNUNET_HELLO_Address address; | ||
68 | 70 | ||
69 | if (0 == *agc) | 71 | if (0 == *agc) |
70 | return 0; | 72 | return 0; |
73 | memset (&address.peer, 0, sizeof (struct GNUNET_PeerIdentity)); | ||
74 | address.address = "Address"; | ||
75 | address.transport_name = "peerinfotest"; | ||
76 | address.address_length = *agc; | ||
71 | ret = | 77 | ret = |
72 | GNUNET_HELLO_add_address ("peerinfotest", | 78 | GNUNET_HELLO_add_address (&address, |
73 | GNUNET_TIME_relative_to_absolute | 79 | GNUNET_TIME_relative_to_absolute |
74 | (GNUNET_TIME_UNIT_HOURS), "Address", *agc, buf, | 80 | (GNUNET_TIME_UNIT_HOURS), buf, |
75 | max); | 81 | max); |
76 | (*agc)--; | 82 | (*agc)--; |
77 | return ret; | 83 | return ret; |
78 | } | 84 | } |
diff --git a/src/testing/testing.c b/src/testing/testing.c index 175888621..8524e62ed 100644 --- a/src/testing/testing.c +++ b/src/testing/testing.c | |||
@@ -65,9 +65,9 @@ static struct GNUNET_CORE_MessageHandler no_handlers[] = { {NULL, 0, 0} }; | |||
65 | 65 | ||
66 | #if EMPTY_HACK | 66 | #if EMPTY_HACK |
67 | static int | 67 | static int |
68 | test_address (void *cls, const char *tname, | 68 | test_address (void *cls, |
69 | struct GNUNET_TIME_Absolute expiration, const void *addr, | 69 | const struct GNUNET_HELLO_Address *address, |
70 | uint16_t addrlen) | 70 | struct GNUNET_TIME_Absolute expiration) |
71 | { | 71 | { |
72 | int *empty = cls; | 72 | int *empty = cls; |
73 | 73 | ||
diff --git a/src/topology/gnunet-daemon-topology.c b/src/topology/gnunet-daemon-topology.c index 3e4fd2685..38a648afc 100644 --- a/src/topology/gnunet-daemon-topology.c +++ b/src/topology/gnunet-daemon-topology.c | |||
@@ -774,16 +774,13 @@ disconnect_notify (void *cls, const struct GNUNET_PeerIdentity *peer) | |||
774 | * Iterator called on each address. | 774 | * Iterator called on each address. |
775 | * | 775 | * |
776 | * @param cls flag that we will set if we see any addresses | 776 | * @param cls flag that we will set if we see any addresses |
777 | * @param tname name of the transport | 777 | * @param address the address of the peer |
778 | * @param expiration when will the given address expire | 778 | * @param expiration when will the given address expire |
779 | * @param addr the address of the peer | ||
780 | * @param addrlen number of bytes in addr | ||
781 | * @return GNUNET_SYSERR always, to terminate iteration | 779 | * @return GNUNET_SYSERR always, to terminate iteration |
782 | */ | 780 | */ |
783 | static int | 781 | static int |
784 | address_iterator (void *cls, const char *tname, | 782 | address_iterator (void *cls, const struct GNUNET_HELLO_Address *address, |
785 | struct GNUNET_TIME_Absolute expiration, const void *addr, | 783 | struct GNUNET_TIME_Absolute expiration) |
786 | uint16_t addrlen) | ||
787 | { | 784 | { |
788 | int *flag = cls; | 785 | int *flag = cls; |
789 | 786 | ||
diff --git a/src/transport/gnunet-service-transport.c b/src/transport/gnunet-service-transport.c index 11a8e23ae..542eb743e 100644 --- a/src/transport/gnunet-service-transport.c +++ b/src/transport/gnunet-service-transport.c | |||
@@ -25,6 +25,7 @@ | |||
25 | */ | 25 | */ |
26 | #include "platform.h" | 26 | #include "platform.h" |
27 | #include "gnunet_util_lib.h" | 27 | #include "gnunet_util_lib.h" |
28 | #include "gnunet_hello_lib.h" | ||
28 | #include "gnunet_statistics_service.h" | 29 | #include "gnunet_statistics_service.h" |
29 | #include "gnunet_transport_service.h" | 30 | #include "gnunet_transport_service.h" |
30 | #include "gnunet_peerinfo_service.h" | 31 | #include "gnunet_peerinfo_service.h" |
@@ -83,15 +84,13 @@ struct GNUNET_ATS_SchedulingHandle *GST_ats; | |||
83 | * @param target a connected neighbour | 84 | * @param target a connected neighbour |
84 | * @param ats performance information (unused) | 85 | * @param ats performance information (unused) |
85 | * @param ats_count number of records in ats (unused) | 86 | * @param ats_count number of records in ats (unused) |
86 | * @param transport plugin | 87 | * @param address the address |
87 | * @param addr address | ||
88 | * @param addrlen address length | ||
89 | */ | 88 | */ |
90 | static void | 89 | static void |
91 | transmit_our_hello (void *cls, const struct GNUNET_PeerIdentity *target, | 90 | transmit_our_hello (void *cls, const struct GNUNET_PeerIdentity *target, |
92 | const struct GNUNET_ATS_Information *ats, | 91 | const struct GNUNET_ATS_Information *ats, |
93 | uint32_t ats_count, const char *transport, const void *addr, | 92 | uint32_t ats_count, |
94 | size_t addrlen) | 93 | const struct GNUNET_HELLO_Address *address) |
95 | { | 94 | { |
96 | const struct GNUNET_MessageHeader *hello = cls; | 95 | const struct GNUNET_MessageHeader *hello = cls; |
97 | 96 | ||
@@ -200,7 +199,8 @@ process_payload (const struct GNUNET_PeerIdentity *peer, | |||
200 | * (plugins that do not support this, can ignore the return value) | 199 | * (plugins that do not support this, can ignore the return value) |
201 | */ | 200 | */ |
202 | static struct GNUNET_TIME_Relative | 201 | static struct GNUNET_TIME_Relative |
203 | plugin_env_receive_callback (void *cls, const struct GNUNET_PeerIdentity *peer, | 202 | plugin_env_receive_callback (void *cls, |
203 | const struct GNUNET_PeerIdentity *peer, | ||
204 | const struct GNUNET_MessageHeader *message, | 204 | const struct GNUNET_MessageHeader *message, |
205 | const struct GNUNET_ATS_Information *ats, | 205 | const struct GNUNET_ATS_Information *ats, |
206 | uint32_t ats_count, struct Session *session, | 206 | uint32_t ats_count, struct Session *session, |
@@ -209,8 +209,13 @@ plugin_env_receive_callback (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
209 | { | 209 | { |
210 | const char *plugin_name = cls; | 210 | const char *plugin_name = cls; |
211 | struct GNUNET_TIME_Relative ret; | 211 | struct GNUNET_TIME_Relative ret; |
212 | struct GNUNET_HELLO_Address address; | ||
212 | uint16_t type; | 213 | uint16_t type; |
213 | 214 | ||
215 | address.peer = *peer; | ||
216 | address.address = sender_address; | ||
217 | address.address_length = sender_address_len; | ||
218 | address.transport_name = plugin_name; | ||
214 | ret = GNUNET_TIME_UNIT_ZERO; | 219 | ret = GNUNET_TIME_UNIT_ZERO; |
215 | if (NULL == message) | 220 | if (NULL == message) |
216 | goto end; | 221 | goto end; |
@@ -229,37 +234,29 @@ plugin_env_receive_callback (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
229 | #if DEBUG_TRANSPORT | 234 | #if DEBUG_TRANSPORT |
230 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK, | 235 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK, |
231 | "Processing `%s' from `%s'\n", "PING", | 236 | "Processing `%s' from `%s'\n", "PING", |
232 | (sender_address != NULL) ? GST_plugins_a2s (plugin_name, | 237 | (sender_address != NULL) ? GST_plugins_a2s (&address) |
233 | sender_address, | ||
234 | sender_address_len) | ||
235 | : "<inbound>"); | 238 | : "<inbound>"); |
236 | #endif | 239 | #endif |
237 | GST_validation_handle_ping (peer, message, plugin_name, session, | 240 | GST_validation_handle_ping (peer, message, &address, session); |
238 | sender_address, sender_address_len); | ||
239 | break; | 241 | break; |
240 | case GNUNET_MESSAGE_TYPE_TRANSPORT_PONG: | 242 | case GNUNET_MESSAGE_TYPE_TRANSPORT_PONG: |
241 | #if DEBUG_TRANSPORT | 243 | #if DEBUG_TRANSPORT |
242 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK, | 244 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK, |
243 | "Processing `%s' from `%s'\n", "PONG", | 245 | "Processing `%s' from `%s'\n", "PONG", |
244 | (sender_address != NULL) ? GST_plugins_a2s (plugin_name, | 246 | (sender_address != NULL) ? GST_plugins_a2s (&address) |
245 | sender_address, | ||
246 | sender_address_len) | ||
247 | : "<inbound>"); | 247 | : "<inbound>"); |
248 | #endif | 248 | #endif |
249 | GST_validation_handle_pong (peer, message); | 249 | GST_validation_handle_pong (peer, message); |
250 | break; | 250 | break; |
251 | case GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_CONNECT: | 251 | case GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_CONNECT: |
252 | GST_neighbours_handle_connect (message, peer, plugin_name, sender_address, | 252 | GST_neighbours_handle_connect (message, peer, &address, session, ats, ats_count); |
253 | sender_address_len, session, ats, ats_count); | ||
254 | break; | 253 | break; |
255 | case GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_CONNECT_ACK: | 254 | case GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_CONNECT_ACK: |
256 | GST_neighbours_handle_connect_ack (message, peer, plugin_name, | 255 | GST_neighbours_handle_connect_ack (message, peer, &address, |
257 | sender_address, sender_address_len, | ||
258 | session, ats, ats_count); | 256 | session, ats, ats_count); |
259 | break; | 257 | break; |
260 | case GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_ACK: | 258 | case GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_ACK: |
261 | GST_neighbours_handle_ack (message, peer, plugin_name, sender_address, | 259 | GST_neighbours_handle_ack (message, peer, &address, session, ats, ats_count); |
262 | sender_address_len, session, ats, ats_count); | ||
263 | break; | 260 | break; |
264 | case GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_DISCONNECT: | 261 | case GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_DISCONNECT: |
265 | GST_neighbours_handle_disconnect_message (peer, message); | 262 | GST_neighbours_handle_disconnect_message (peer, message); |
@@ -276,8 +273,7 @@ end: | |||
276 | #if 1 | 273 | #if 1 |
277 | /* FIXME: this should not be needed, and not sure it's good to have it, but without | 274 | /* FIXME: this should not be needed, and not sure it's good to have it, but without |
278 | * this connections seem to go extra-slow */ | 275 | * this connections seem to go extra-slow */ |
279 | GNUNET_ATS_address_update (GST_ats, peer, plugin_name, sender_address, | 276 | GNUNET_ATS_address_update (GST_ats, &address, session, ats, ats_count); |
280 | sender_address_len, session, ats, ats_count); | ||
281 | #endif | 277 | #endif |
282 | #if DEBUG_TRANSPORT | 278 | #if DEBUG_TRANSPORT |
283 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 279 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
@@ -304,8 +300,13 @@ plugin_env_address_change_notification (void *cls, int add_remove, | |||
304 | const void *addr, size_t addrlen) | 300 | const void *addr, size_t addrlen) |
305 | { | 301 | { |
306 | const char *plugin_name = cls; | 302 | const char *plugin_name = cls; |
303 | struct GNUNET_HELLO_Address address; | ||
307 | 304 | ||
308 | GST_hello_modify_addresses (add_remove, plugin_name, addr, addrlen); | 305 | address.peer = GST_my_identity; |
306 | address.transport_name = plugin_name; | ||
307 | address.address = addr; | ||
308 | address.address_length = addrlen; | ||
309 | GST_hello_modify_addresses (add_remove, &address); | ||
309 | } | 310 | } |
310 | 311 | ||
311 | 312 | ||
@@ -326,6 +327,8 @@ static void | |||
326 | plugin_env_session_end (void *cls, const struct GNUNET_PeerIdentity *peer, | 327 | plugin_env_session_end (void *cls, const struct GNUNET_PeerIdentity *peer, |
327 | struct Session *session) | 328 | struct Session *session) |
328 | { | 329 | { |
330 | struct GNUNET_HELLO_Address address; | ||
331 | |||
329 | #if DEBUG_TRANSPORT | 332 | #if DEBUG_TRANSPORT |
330 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Session %X to peer `%s' ended \n", | 333 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Session %X to peer `%s' ended \n", |
331 | session, GNUNET_i2s (peer)); | 334 | session, GNUNET_i2s (peer)); |
@@ -335,7 +338,11 @@ plugin_env_session_end (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
335 | "transport-ats", | 338 | "transport-ats", |
336 | "Telling ATS to destroy session %p from peer %s\n", | 339 | "Telling ATS to destroy session %p from peer %s\n", |
337 | session, GNUNET_i2s (peer)); | 340 | session, GNUNET_i2s (peer)); |
338 | GNUNET_ATS_address_destroyed (GST_ats, peer, NULL, NULL, 0, session); | 341 | address.peer = *peer; |
342 | address.address = NULL; | ||
343 | address.address_length = 0; | ||
344 | address.transport_name = cls; | ||
345 | GNUNET_ATS_address_destroyed (GST_ats, &address, session); | ||
339 | GST_neighbours_session_terminated (peer, session); | 346 | GST_neighbours_session_terminated (peer, session); |
340 | } | 347 | } |
341 | 348 | ||
@@ -348,18 +355,15 @@ plugin_env_session_end (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
348 | * actually happened. | 355 | * actually happened. |
349 | * | 356 | * |
350 | * @param cls closure | 357 | * @param cls closure |
351 | * @param peer identity of the peer | 358 | * @param address address to use (for peer given in address) |
352 | * @param plugin_name name of the transport plugin, NULL to disconnect | ||
353 | * @param session session to use (if available) | 359 | * @param session session to use (if available) |
354 | * @param plugin_addr address to use (if available) | ||
355 | * @param plugin_addr_len number of bytes in addr | ||
356 | * @param bandwidth_out assigned outbound bandwidth for the connection, 0 to disconnect from peer | 360 | * @param bandwidth_out assigned outbound bandwidth for the connection, 0 to disconnect from peer |
357 | * @param bandwidth_in assigned inbound bandwidth for the connection, 0 to disconnect from peer | 361 | * @param bandwidth_in assigned inbound bandwidth for the connection, 0 to disconnect from peer |
358 | */ | 362 | */ |
359 | static void | 363 | static void |
360 | ats_request_address_change (void *cls, const struct GNUNET_PeerIdentity *peer, | 364 | ats_request_address_change (void *cls, |
361 | const char *plugin_name, const void *plugin_addr, | 365 | const struct GNUNET_HELLO_Address *address, |
362 | size_t plugin_addr_len, struct Session *session, | 366 | struct Session *session, |
363 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, | 367 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, |
364 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, | 368 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, |
365 | const struct GNUNET_ATS_Information *ats, | 369 | const struct GNUNET_ATS_Information *ats, |
@@ -374,14 +378,14 @@ ats_request_address_change (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
374 | #if DEBUG_TRANSPORT | 378 | #if DEBUG_TRANSPORT |
375 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 379 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
376 | "ATS tells me to disconnect from peer `%s'\n", | 380 | "ATS tells me to disconnect from peer `%s'\n", |
377 | GNUNET_i2s (peer)); | 381 | GNUNET_i2s (&address->peer)); |
378 | #endif | 382 | #endif |
379 | GST_neighbours_force_disconnect (peer); | 383 | GST_neighbours_force_disconnect (&address->peer); |
380 | return; | 384 | return; |
381 | } | 385 | } |
382 | /* will never return GNUNET_YES since connection is to be established */ | 386 | /* will never return GNUNET_YES since connection is to be established */ |
383 | GST_neighbours_switch_to_address_3way (peer, plugin_name, plugin_addr, | 387 | GST_neighbours_switch_to_address_3way (&address->peer, |
384 | plugin_addr_len, session, ats, | 388 | address, session, ats, |
385 | ats_count, bandwidth_in, | 389 | ats_count, bandwidth_in, |
386 | bandwidth_out); | 390 | bandwidth_out); |
387 | } | 391 | } |
diff --git a/src/transport/gnunet-service-transport_blacklist.c b/src/transport/gnunet-service-transport_blacklist.c index 78eea2ff9..b3edc01db 100644 --- a/src/transport/gnunet-service-transport_blacklist.c +++ b/src/transport/gnunet-service-transport_blacklist.c | |||
@@ -550,15 +550,13 @@ struct TestConnectionContext | |||
550 | * @param neighbour neighbour's identity | 550 | * @param neighbour neighbour's identity |
551 | * @param ats performance data | 551 | * @param ats performance data |
552 | * @param ats_count number of entries in ats (excluding 0-termination) | 552 | * @param ats_count number of entries in ats (excluding 0-termination) |
553 | * @param transport plugin | 553 | * @param address the address |
554 | * @param addr address | ||
555 | * @param addrlen address length | ||
556 | */ | 554 | */ |
557 | static void | 555 | static void |
558 | test_connection_ok (void *cls, const struct GNUNET_PeerIdentity *neighbour, | 556 | test_connection_ok (void *cls, const struct GNUNET_PeerIdentity *neighbour, |
559 | const struct GNUNET_ATS_Information *ats, | 557 | const struct GNUNET_ATS_Information *ats, |
560 | uint32_t ats_count, const char *transport, const void *addr, | 558 | uint32_t ats_count, |
561 | size_t addrlen) | 559 | const struct GNUNET_HELLO_Address *address) |
562 | { | 560 | { |
563 | struct TestConnectionContext *tcc = cls; | 561 | struct TestConnectionContext *tcc = cls; |
564 | struct GST_BlacklistCheck *bc; | 562 | struct GST_BlacklistCheck *bc; |
diff --git a/src/transport/gnunet-service-transport_clients.c b/src/transport/gnunet-service-transport_clients.c index ebab72db6..aee592d29 100644 --- a/src/transport/gnunet-service-transport_clients.c +++ b/src/transport/gnunet-service-transport_clients.c | |||
@@ -325,16 +325,14 @@ client_disconnect_notification (void *cls, struct GNUNET_SERVER_Client *client) | |||
325 | * @param peer identity of the neighbour | 325 | * @param peer identity of the neighbour |
326 | * @param ats performance data | 326 | * @param ats performance data |
327 | * @param ats_count number of entries in ats (excluding 0-termination) | 327 | * @param ats_count number of entries in ats (excluding 0-termination) |
328 | * @param transport plugin | 328 | * @param address the address |
329 | * @param addr address | ||
330 | * @param addrlen address length | ||
331 | */ | 329 | */ |
332 | static void | 330 | static void |
333 | notify_client_about_neighbour (void *cls, | 331 | notify_client_about_neighbour (void *cls, |
334 | const struct GNUNET_PeerIdentity *peer, | 332 | const struct GNUNET_PeerIdentity *peer, |
335 | const struct GNUNET_ATS_Information *ats, | 333 | const struct GNUNET_ATS_Information *ats, |
336 | uint32_t ats_count, const char *transport, | 334 | uint32_t ats_count, |
337 | const void *addr, size_t addrlen) | 335 | const struct GNUNET_HELLO_Address *address) |
338 | { | 336 | { |
339 | struct TransportClient *tc = cls; | 337 | struct TransportClient *tc = cls; |
340 | struct ConnectInfoMessage *cim; | 338 | struct ConnectInfoMessage *cim; |
@@ -719,33 +717,28 @@ clients_handle_address_lookup (void *cls, struct GNUNET_SERVER_Client *client, | |||
719 | * | 717 | * |
720 | * @param cls our 'struct GNUNET_SERVER_TransmitContext' (for sending) | 718 | * @param cls our 'struct GNUNET_SERVER_TransmitContext' (for sending) |
721 | * @param public_key public key for the peer, never NULL | 719 | * @param public_key public key for the peer, never NULL |
722 | * @param target peer this change is about, never NULL | ||
723 | * @param valid_until until what time do we consider the address valid? | 720 | * @param valid_until until what time do we consider the address valid? |
724 | * @param validation_block is FOREVER if the address is for an unsupported plugin (from PEERINFO) | 721 | * @param validation_block is FOREVER if the address is for an unsupported plugin (from PEERINFO) |
725 | * is ZERO if the address is considered valid (no validation needed) | 722 | * is ZERO if the address is considered valid (no validation needed) |
726 | * is a time in the future if we're currently denying re-validation | 723 | * is a time in the future if we're currently denying re-validation |
727 | * @param plugin_name name of the plugin | 724 | * @param address address to transmit |
728 | * @param plugin_address binary address | ||
729 | * @param plugin_address_len length of address | ||
730 | */ | 725 | */ |
731 | static void | 726 | static void |
732 | send_address_to_client (void *cls, | 727 | send_address_to_client (void *cls, |
733 | const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded | 728 | const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded |
734 | *public_key, const struct GNUNET_PeerIdentity *target, | 729 | *public_key, |
735 | struct GNUNET_TIME_Absolute valid_until, | 730 | struct GNUNET_TIME_Absolute valid_until, |
736 | struct GNUNET_TIME_Absolute validation_block, | 731 | struct GNUNET_TIME_Absolute validation_block, |
737 | const char *plugin_name, const void *plugin_address, | 732 | const struct GNUNET_HELLO_Address *address) |
738 | size_t plugin_address_len) | ||
739 | { | 733 | { |
740 | struct GNUNET_SERVER_TransmitContext *tc = cls; | 734 | struct GNUNET_SERVER_TransmitContext *tc = cls; |
741 | char *addr_buf; | 735 | char *addr_buf; |
742 | 736 | ||
743 | /* FIXME: move to a binary format!!! */ | 737 | /* FIXME: move to a binary format!!! */ |
744 | GNUNET_asprintf (&addr_buf, "%s --- %s, %s", | 738 | GNUNET_asprintf (&addr_buf, "%s --- %s, %s", |
745 | GST_plugins_a2s (plugin_name, plugin_address, | 739 | GST_plugins_a2s (address), |
746 | plugin_address_len), | ||
747 | (GNUNET_YES == | 740 | (GNUNET_YES == |
748 | GST_neighbours_test_connected (target)) ? "CONNECTED" : | 741 | GST_neighbours_test_connected (&address->peer)) ? "CONNECTED" : |
749 | "DISCONNECTED", | 742 | "DISCONNECTED", |
750 | (GNUNET_TIME_absolute_get_remaining (valid_until).rel_value > | 743 | (GNUNET_TIME_absolute_get_remaining (valid_until).rel_value > |
751 | 0) ? "VALIDATED" : "UNVALIDATED"); | 744 | 0) ? "VALIDATED" : "UNVALIDATED"); |
@@ -789,27 +782,26 @@ clients_handle_peer_address_lookup (void *cls, | |||
789 | * @param neighbour identity of the neighbour | 782 | * @param neighbour identity of the neighbour |
790 | * @param ats performance data | 783 | * @param ats performance data |
791 | * @param ats_count number of entries in ats (excluding 0-termination) | 784 | * @param ats_count number of entries in ats (excluding 0-termination) |
792 | * @param transport plugin | 785 | * @param address the address |
793 | * @param addr address | ||
794 | * @param addrlen address length | ||
795 | */ | 786 | */ |
796 | static void | 787 | static void |
797 | output_addresses (void *cls, const struct GNUNET_PeerIdentity *peer, | 788 | output_addresses (void *cls, const struct GNUNET_PeerIdentity *peer, |
798 | const struct GNUNET_ATS_Information *ats, uint32_t ats_count, | 789 | const struct GNUNET_ATS_Information *ats, uint32_t ats_count, |
799 | const char *transport, const void *addr, size_t addrlen) | 790 | const struct GNUNET_HELLO_Address *address) |
800 | { | 791 | { |
801 | struct GNUNET_SERVER_TransmitContext *tc = cls; | 792 | struct GNUNET_SERVER_TransmitContext *tc = cls; |
802 | struct AddressIterateResponseMessage *msg; | 793 | struct AddressIterateResponseMessage *msg; |
803 | size_t size; | 794 | size_t size; |
795 | size_t slen; | ||
804 | 796 | ||
805 | size = | 797 | slen = strlen (address->transport_name) + 1; |
806 | (sizeof (struct AddressIterateResponseMessage) + strlen (transport) + 1); | 798 | size = (sizeof (struct AddressIterateResponseMessage) + slen); |
807 | msg = GNUNET_malloc (size); | 799 | msg = GNUNET_malloc (size); |
808 | memcpy (&msg->peer, peer, sizeof (struct GNUNET_PeerIdentity)); | 800 | memcpy (&msg->peer, peer, sizeof (struct GNUNET_PeerIdentity)); |
809 | memcpy (&msg[0], transport, strlen (transport) + 1); | 801 | memcpy (&msg[0], address->transport_name, slen); |
810 | msg->addrlen = ntohs (addrlen); | 802 | msg->addrlen = ntohs (address->address_length); |
811 | msg->pluginlen = ntohs (strlen (transport) + 1); | 803 | msg->pluginlen = ntohs (slen); |
812 | 804 | // FIXME: what about 'address->address'!? | |
813 | transmit_binary_to_client (tc, msg, size); | 805 | transmit_binary_to_client (tc, msg, size); |
814 | GNUNET_free (msg); | 806 | GNUNET_free (msg); |
815 | } | 807 | } |
diff --git a/src/transport/gnunet-service-transport_hello.c b/src/transport/gnunet-service-transport_hello.c index 45fdf0a26..8b38a673e 100644 --- a/src/transport/gnunet-service-transport_hello.c +++ b/src/transport/gnunet-service-transport_hello.c | |||
@@ -56,9 +56,9 @@ struct OwnAddressList | |||
56 | struct OwnAddressList *prev; | 56 | struct OwnAddressList *prev; |
57 | 57 | ||
58 | /** | 58 | /** |
59 | * Name of the plugin. | 59 | * The address. |
60 | */ | 60 | */ |
61 | char *plugin_name; | 61 | struct GNUNET_HELLO_Address *address; |
62 | 62 | ||
63 | /** | 63 | /** |
64 | * How long until the current signature expires? (ZERO if the | 64 | * How long until the current signature expires? (ZERO if the |
@@ -71,11 +71,6 @@ struct OwnAddressList | |||
71 | */ | 71 | */ |
72 | struct GNUNET_CRYPTO_RsaSignature pong_signature; | 72 | struct GNUNET_CRYPTO_RsaSignature pong_signature; |
73 | 73 | ||
74 | /** | ||
75 | * Length of addr. | ||
76 | */ | ||
77 | size_t addrlen; | ||
78 | |||
79 | }; | 74 | }; |
80 | 75 | ||
81 | 76 | ||
@@ -143,9 +138,8 @@ address_generator (void *cls, size_t max, void *buf) | |||
143 | if (NULL == gc->addr_pos) | 138 | if (NULL == gc->addr_pos) |
144 | return 0; | 139 | return 0; |
145 | ret = | 140 | ret = |
146 | GNUNET_HELLO_add_address (gc->addr_pos->plugin_name, gc->expiration, | 141 | GNUNET_HELLO_add_address (gc->addr_pos->address, gc->expiration, |
147 | &gc->addr_pos[1], gc->addr_pos->addrlen, buf, | 142 | buf, max); |
148 | max); | ||
149 | gc->addr_pos = gc->addr_pos->next; | 143 | gc->addr_pos = gc->addr_pos->next; |
150 | return ret; | 144 | return ret; |
151 | } | 145 | } |
@@ -253,14 +247,11 @@ GST_hello_get () | |||
253 | * Add or remove an address from this peer's HELLO message. | 247 | * Add or remove an address from this peer's HELLO message. |
254 | * | 248 | * |
255 | * @param addremove GNUNET_YES to add, GNUNET_NO to remove | 249 | * @param addremove GNUNET_YES to add, GNUNET_NO to remove |
256 | * @param plugin_name name of the plugin for which this is an address | 250 | * @param address address to add or remove |
257 | * @param plugin_address address in a plugin-specific format | ||
258 | * @param plugin_address_len number of bytes in plugin_address | ||
259 | */ | 251 | */ |
260 | void | 252 | void |
261 | GST_hello_modify_addresses (int addremove, const char *plugin_name, | 253 | GST_hello_modify_addresses (int addremove, |
262 | const void *plugin_address, | 254 | const struct GNUNET_HELLO_Address *address) |
263 | size_t plugin_address_len) | ||
264 | { | 255 | { |
265 | struct OwnAddressList *al; | 256 | struct OwnAddressList *al; |
266 | 257 | ||
@@ -269,18 +260,18 @@ GST_hello_modify_addresses (int addremove, const char *plugin_name, | |||
269 | (add_remove == | 260 | (add_remove == |
270 | GNUNET_YES) ? "Adding `%s':%s to the set of our addresses\n" : | 261 | GNUNET_YES) ? "Adding `%s':%s to the set of our addresses\n" : |
271 | "Removing `%s':%s from the set of our addresses\n", | 262 | "Removing `%s':%s from the set of our addresses\n", |
272 | GST_plugins_a2s (plugin_name, addr, addrlen), p->short_name); | 263 | GST_plugins_a2s (address), p->short_name); |
273 | #endif | 264 | #endif |
274 | GNUNET_assert (plugin_address != NULL); | 265 | GNUNET_assert (address != NULL); |
275 | if (GNUNET_NO == addremove) | 266 | if (GNUNET_NO == addremove) |
276 | { | 267 | { |
277 | for (al = oal_head; al != NULL; al = al->next) | 268 | for (al = oal_head; al != NULL; al = al->next) |
278 | if ((plugin_address_len == al->addrlen) && | 269 | if (0 == |
279 | (0 == strcmp (al->plugin_name, plugin_name)) && | 270 | GNUNET_HELLO_address_cmp (address, |
280 | (0 == memcmp (plugin_address, &al[1], plugin_address_len))) | 271 | al->address)) |
281 | { | 272 | { |
282 | GNUNET_CONTAINER_DLL_remove (oal_head, oal_tail, al); | 273 | GNUNET_CONTAINER_DLL_remove (oal_head, oal_tail, al); |
283 | GNUNET_free (al->plugin_name); | 274 | GNUNET_HELLO_address_free (al->address); |
284 | GNUNET_free (al); | 275 | GNUNET_free (al); |
285 | refresh_hello (); | 276 | refresh_hello (); |
286 | return; | 277 | return; |
@@ -289,11 +280,9 @@ GST_hello_modify_addresses (int addremove, const char *plugin_name, | |||
289 | GNUNET_break (0); | 280 | GNUNET_break (0); |
290 | return; | 281 | return; |
291 | } | 282 | } |
292 | al = GNUNET_malloc (sizeof (struct OwnAddressList) + plugin_address_len); | 283 | al = GNUNET_malloc (sizeof (struct OwnAddressList)); |
293 | GNUNET_CONTAINER_DLL_insert (oal_head, oal_tail, al); | 284 | GNUNET_CONTAINER_DLL_insert (oal_head, oal_tail, al); |
294 | al->plugin_name = GNUNET_strdup (plugin_name); | 285 | al->address = GNUNET_HELLO_address_copy (address); |
295 | al->addrlen = plugin_address_len; | ||
296 | memcpy (&al[1], plugin_address, plugin_address_len); | ||
297 | refresh_hello (); | 286 | refresh_hello (); |
298 | } | 287 | } |
299 | 288 | ||
@@ -301,9 +290,7 @@ GST_hello_modify_addresses (int addremove, const char *plugin_name, | |||
301 | /** | 290 | /** |
302 | * Test if a particular address is one of ours. | 291 | * Test if a particular address is one of ours. |
303 | * | 292 | * |
304 | * @param plugin_name name of the plugin for which this is an address | 293 | * @param address address to test |
305 | * @param plugin_address address in a plugin-specific format | ||
306 | * @param plugin_address_len number of bytes in plugin_address | ||
307 | * @param sig location where to cache PONG signatures for this address [set] | 294 | * @param sig location where to cache PONG signatures for this address [set] |
308 | * @param sig_expiration how long until the current 'sig' expires? | 295 | * @param sig_expiration how long until the current 'sig' expires? |
309 | * (ZERO if sig was never created) [set] | 296 | * (ZERO if sig was never created) [set] |
@@ -311,17 +298,15 @@ GST_hello_modify_addresses (int addremove, const char *plugin_name, | |||
311 | * GNUNET_NO if not | 298 | * GNUNET_NO if not |
312 | */ | 299 | */ |
313 | int | 300 | int |
314 | GST_hello_test_address (const char *plugin_name, const void *plugin_address, | 301 | GST_hello_test_address (const struct GNUNET_HELLO_Address *address, |
315 | size_t plugin_address_len, | ||
316 | struct GNUNET_CRYPTO_RsaSignature **sig, | 302 | struct GNUNET_CRYPTO_RsaSignature **sig, |
317 | struct GNUNET_TIME_Absolute **sig_expiration) | 303 | struct GNUNET_TIME_Absolute **sig_expiration) |
318 | { | 304 | { |
319 | struct OwnAddressList *al; | 305 | struct OwnAddressList *al; |
320 | 306 | ||
321 | for (al = oal_head; al != NULL; al = al->next) | 307 | for (al = oal_head; al != NULL; al = al->next) |
322 | if ((plugin_address_len == al->addrlen) && | 308 | if (0 == GNUNET_HELLO_address_cmp (address, |
323 | (0 == strcmp (al->plugin_name, plugin_name)) && | 309 | al->address)) |
324 | (0 == memcmp (plugin_address, &al[1], plugin_address_len))) | ||
325 | { | 310 | { |
326 | *sig = &al->pong_signature; | 311 | *sig = &al->pong_signature; |
327 | *sig_expiration = &al->pong_sig_expires; | 312 | *sig_expiration = &al->pong_sig_expires; |
diff --git a/src/transport/gnunet-service-transport_hello.h b/src/transport/gnunet-service-transport_hello.h index 8d15ec6b5..168dd4364 100644 --- a/src/transport/gnunet-service-transport_hello.h +++ b/src/transport/gnunet-service-transport_hello.h | |||
@@ -29,6 +29,7 @@ | |||
29 | #include "gnunet_statistics_service.h" | 29 | #include "gnunet_statistics_service.h" |
30 | #include "gnunet_transport_service.h" | 30 | #include "gnunet_transport_service.h" |
31 | #include "gnunet_util_lib.h" | 31 | #include "gnunet_util_lib.h" |
32 | #include "gnunet_hello_lib.h" | ||
32 | 33 | ||
33 | 34 | ||
34 | 35 | ||
@@ -72,22 +73,17 @@ GST_hello_get (void); | |||
72 | * Add or remove an address from this peer's HELLO message. | 73 | * Add or remove an address from this peer's HELLO message. |
73 | * | 74 | * |
74 | * @param addremove GNUNET_YES to add, GNUNET_NO to remove | 75 | * @param addremove GNUNET_YES to add, GNUNET_NO to remove |
75 | * @param plugin_name name of the plugin for which this is an address | 76 | * @param address address to add or remove |
76 | * @param plugin_address address in a plugin-specific format | ||
77 | * @param plugin_address_len number of bytes in plugin_address | ||
78 | */ | 77 | */ |
79 | void | 78 | void |
80 | GST_hello_modify_addresses (int addremove, const char *plugin_name, | 79 | GST_hello_modify_addresses (int addremove, |
81 | const void *plugin_address, | 80 | const struct GNUNET_HELLO_Address *address); |
82 | size_t plugin_address_len); | ||
83 | 81 | ||
84 | 82 | ||
85 | /** | 83 | /** |
86 | * Test if a particular address is one of ours. | 84 | * Test if a particular address is one of ours. |
87 | * | 85 | * |
88 | * @param plugin_name name of the plugin for which this is an address | 86 | * @param address the address to test |
89 | * @param plugin_address address in a plugin-specific format | ||
90 | * @param plugin_address_len number of bytes in plugin_address | ||
91 | * @param sig location where to cache PONG signatures for this address [set] | 87 | * @param sig location where to cache PONG signatures for this address [set] |
92 | * @param sig_expiration how long until the current 'sig' expires? | 88 | * @param sig_expiration how long until the current 'sig' expires? |
93 | * (ZERO if sig was never created) [set] | 89 | * (ZERO if sig was never created) [set] |
@@ -95,8 +91,7 @@ GST_hello_modify_addresses (int addremove, const char *plugin_name, | |||
95 | * GNUNET_NO if not | 91 | * GNUNET_NO if not |
96 | */ | 92 | */ |
97 | int | 93 | int |
98 | GST_hello_test_address (const char *plugin_name, const void *plugin_address, | 94 | GST_hello_test_address (const struct GNUNET_HELLO_Address *address, |
99 | size_t plugin_address_len, | ||
100 | struct GNUNET_CRYPTO_RsaSignature **sig, | 95 | struct GNUNET_CRYPTO_RsaSignature **sig, |
101 | struct GNUNET_TIME_Absolute **sig_expiration); | 96 | struct GNUNET_TIME_Absolute **sig_expiration); |
102 | 97 | ||
diff --git a/src/transport/gnunet-service-transport_neighbours.c b/src/transport/gnunet-service-transport_neighbours.c index e6b298f4f..a127209dd 100644 --- a/src/transport/gnunet-service-transport_neighbours.c +++ b/src/transport/gnunet-service-transport_neighbours.c | |||
@@ -234,19 +234,9 @@ struct NeighbourMapEntry | |||
234 | struct Session *session; | 234 | struct Session *session; |
235 | 235 | ||
236 | /** | 236 | /** |
237 | * Name of the plugin we currently use. | 237 | * Address we currently use. |
238 | */ | 238 | */ |
239 | char *plugin_name; | 239 | struct GNUNET_HELLO_Address *address; |
240 | |||
241 | /** | ||
242 | * Address used for communicating with the peer, NULL for inbound connections. | ||
243 | */ | ||
244 | void *addr; | ||
245 | |||
246 | /** | ||
247 | * Number of bytes in 'addr'. | ||
248 | */ | ||
249 | size_t addrlen; | ||
250 | 240 | ||
251 | /** | 241 | /** |
252 | * Identity of this neighbour. | 242 | * Identity of this neighbour. |
@@ -432,8 +422,7 @@ reset_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
432 | */ | 422 | */ |
433 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 423 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
434 | "Information for developers: Connection to peer `%s' %s failed in state `%s', resetting connection attempt \n", | 424 | "Information for developers: Connection to peer `%s' %s failed in state `%s', resetting connection attempt \n", |
435 | GNUNET_i2s (&n->id), GST_plugins_a2s (n->plugin_name, n->addr, | 425 | GNUNET_i2s (&n->id), GST_plugins_a2s (n->address), |
436 | n->addrlen), | ||
437 | print_state (n->state)); | 426 | print_state (n->state)); |
438 | 427 | ||
439 | GNUNET_STATISTICS_update (GST_stats, | 428 | GNUNET_STATISTICS_update (GST_stats, |
@@ -445,8 +434,7 @@ reset_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
445 | n->state = S_NOT_CONNECTED; | 434 | n->state = S_NOT_CONNECTED; |
446 | 435 | ||
447 | /* destroying address */ | 436 | /* destroying address */ |
448 | GNUNET_ATS_address_destroyed (GST_ats, &n->id, n->plugin_name, n->addr, | 437 | GNUNET_ATS_address_destroyed (GST_ats, n->address, NULL); |
449 | n->addrlen, NULL); | ||
450 | 438 | ||
451 | /* request new address */ | 439 | /* request new address */ |
452 | if (n->ats_suggest != GNUNET_SCHEDULER_NO_TASK) | 440 | if (n->ats_suggest != GNUNET_SCHEDULER_NO_TASK) |
@@ -496,8 +484,7 @@ change (struct NeighbourMapEntry *n, int state, int line) | |||
496 | #if DEBUG_TRANSPORT | 484 | #if DEBUG_TRANSPORT |
497 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 485 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
498 | "Removed reset task for peer `%s' %s failed in state transition `%s' -> `%s' \n", | 486 | "Removed reset task for peer `%s' %s failed in state transition `%s' -> `%s' \n", |
499 | GNUNET_i2s (&n->id), GST_plugins_a2s (n->plugin_name, | 487 | GNUNET_i2s (&n->id), GST_plugins_a2s (n->address), |
500 | n->addr, n->addrlen), | ||
501 | print_state (n->state), print_state (state)); | 488 | print_state (n->state), print_state (state)); |
502 | #endif | 489 | #endif |
503 | GNUNET_assert (n->state_reset != GNUNET_SCHEDULER_NO_TASK); | 490 | GNUNET_assert (n->state_reset != GNUNET_SCHEDULER_NO_TASK); |
@@ -520,8 +507,7 @@ change (struct NeighbourMapEntry *n, int state, int line) | |||
520 | #if DEBUG_TRANSPORT | 507 | #if DEBUG_TRANSPORT |
521 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 508 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
522 | "Removed reset task for peer `%s' %s failed in state transition `%s' -> `%s' \n", | 509 | "Removed reset task for peer `%s' %s failed in state transition `%s' -> `%s' \n", |
523 | GNUNET_i2s (&n->id), GST_plugins_a2s (n->plugin_name, | 510 | GNUNET_i2s (&n->id), GST_plugins_a2s (n->address), |
524 | n->addr, n->addrlen), | ||
525 | print_state (n->state), print_state (state)); | 511 | print_state (n->state), print_state (state)); |
526 | #endif | 512 | #endif |
527 | GNUNET_assert (n->state_reset != GNUNET_SCHEDULER_NO_TASK); | 513 | GNUNET_assert (n->state_reset != GNUNET_SCHEDULER_NO_TASK); |
@@ -580,7 +566,7 @@ static ssize_t | |||
580 | send_with_plugin (const struct GNUNET_PeerIdentity *target, const char *msgbuf, | 566 | send_with_plugin (const struct GNUNET_PeerIdentity *target, const char *msgbuf, |
581 | size_t msgbuf_size, uint32_t priority, | 567 | size_t msgbuf_size, uint32_t priority, |
582 | struct GNUNET_TIME_Relative timeout, struct Session *session, | 568 | struct GNUNET_TIME_Relative timeout, struct Session *session, |
583 | const char *plugin_name, const void *addr, size_t addrlen, | 569 | const struct GNUNET_HELLO_Address *address, |
584 | int force_address, GNUNET_TRANSPORT_TransmitContinuation cont, | 570 | int force_address, GNUNET_TRANSPORT_TransmitContinuation cont, |
585 | void *cont_cls) | 571 | void *cont_cls) |
586 | { | 572 | { |
@@ -588,21 +574,21 @@ send_with_plugin (const struct GNUNET_PeerIdentity *target, const char *msgbuf, | |||
588 | size_t ret = GNUNET_SYSERR; | 574 | size_t ret = GNUNET_SYSERR; |
589 | 575 | ||
590 | /* FIXME : ats returns an address with all values 0 */ | 576 | /* FIXME : ats returns an address with all values 0 */ |
591 | if (plugin_name == NULL) | 577 | if (address == NULL) |
592 | { | 578 | { |
593 | if (cont != NULL) | 579 | if (cont != NULL) |
594 | cont (cont_cls, target, GNUNET_SYSERR); | 580 | cont (cont_cls, target, GNUNET_SYSERR); |
595 | return GNUNET_SYSERR; | 581 | return GNUNET_SYSERR; |
596 | } | 582 | } |
597 | 583 | ||
598 | if ((session == NULL) && (addr == NULL) && (addrlen == 0)) | 584 | if ((session == NULL) && (address == NULL)) |
599 | { | 585 | { |
600 | if (cont != NULL) | 586 | if (cont != NULL) |
601 | cont (cont_cls, target, GNUNET_SYSERR); | 587 | cont (cont_cls, target, GNUNET_SYSERR); |
602 | return GNUNET_SYSERR; | 588 | return GNUNET_SYSERR; |
603 | } | 589 | } |
604 | 590 | ||
605 | papi = GST_plugins_find (plugin_name); | 591 | papi = GST_plugins_find (address->transport_name); |
606 | if (papi == NULL) | 592 | if (papi == NULL) |
607 | { | 593 | { |
608 | if (cont != NULL) | 594 | if (cont != NULL) |
@@ -612,7 +598,8 @@ send_with_plugin (const struct GNUNET_PeerIdentity *target, const char *msgbuf, | |||
612 | 598 | ||
613 | ret = | 599 | ret = |
614 | papi->send (papi->cls, target, msgbuf, msgbuf_size, 0, timeout, session, | 600 | papi->send (papi->cls, target, msgbuf, msgbuf_size, 0, timeout, session, |
615 | addr, addrlen, GNUNET_YES, cont, cont_cls); | 601 | address->address, |
602 | address->address_length, GNUNET_YES, cont, cont_cls); | ||
616 | 603 | ||
617 | if (ret == -1) | 604 | if (ret == -1) |
618 | { | 605 | { |
@@ -706,7 +693,7 @@ try_transmission_to_peer (struct NeighbourMapEntry *n) | |||
706 | if (NULL == mq) | 693 | if (NULL == mq) |
707 | return; /* no more messages */ | 694 | return; /* no more messages */ |
708 | 695 | ||
709 | if (GST_plugins_find (n->plugin_name) == NULL) | 696 | if (GST_plugins_find (n->address->transport_name) == NULL) |
710 | { | 697 | { |
711 | GNUNET_break (0); | 698 | GNUNET_break (0); |
712 | return; | 699 | return; |
@@ -715,9 +702,10 @@ try_transmission_to_peer (struct NeighbourMapEntry *n) | |||
715 | n->is_active = mq; | 702 | n->is_active = mq; |
716 | mq->n = n; | 703 | mq->n = n; |
717 | 704 | ||
718 | if ((n->session == NULL) && (n->addr == NULL) && (n->addrlen == 0)) | 705 | if ( (n->session == NULL) && (NULL == n->address) ) |
719 | { | 706 | { |
720 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "No address for peer `%s'\n", | 707 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
708 | "No address for peer `%s'\n", | ||
721 | GNUNET_i2s (&n->id)); | 709 | GNUNET_i2s (&n->id)); |
722 | transmit_send_continuation (mq, &n->id, GNUNET_SYSERR); | 710 | transmit_send_continuation (mq, &n->id, GNUNET_SYSERR); |
723 | GNUNET_assert (n->transmission_task == GNUNET_SCHEDULER_NO_TASK); | 711 | GNUNET_assert (n->transmission_task == GNUNET_SCHEDULER_NO_TASK); |
@@ -727,8 +715,8 @@ try_transmission_to_peer (struct NeighbourMapEntry *n) | |||
727 | 715 | ||
728 | ret = | 716 | ret = |
729 | send_with_plugin (&n->id, mq->message_buf, mq->message_buf_size, 0, | 717 | send_with_plugin (&n->id, mq->message_buf, mq->message_buf_size, 0, |
730 | timeout, n->session, n->plugin_name, n->addr, | 718 | timeout, n->session, n->address, |
731 | n->addrlen, GNUNET_YES, &transmit_send_continuation, | 719 | GNUNET_YES, &transmit_send_continuation, |
732 | mq); | 720 | mq); |
733 | if (ret == -1) | 721 | if (ret == -1) |
734 | { | 722 | { |
@@ -789,8 +777,8 @@ send_disconnect_cont (void *cls, const struct GNUNET_PeerIdentity *target, | |||
789 | 777 | ||
790 | static int | 778 | static int |
791 | send_disconnect (const struct GNUNET_PeerIdentity *target, | 779 | send_disconnect (const struct GNUNET_PeerIdentity *target, |
792 | const char *plugin_name, const char *sender_address, | 780 | const struct GNUNET_HELLO_Address *address, |
793 | uint16_t sender_address_len, struct Session *session) | 781 | struct Session *session) |
794 | { | 782 | { |
795 | size_t ret; | 783 | size_t ret; |
796 | struct SessionDisconnectMessage disconnect_msg; | 784 | struct SessionDisconnectMessage disconnect_msg; |
@@ -821,8 +809,8 @@ send_disconnect (const struct GNUNET_PeerIdentity *target, | |||
821 | ret = | 809 | ret = |
822 | send_with_plugin (target, (const char *) &disconnect_msg, | 810 | send_with_plugin (target, (const char *) &disconnect_msg, |
823 | sizeof (disconnect_msg), UINT32_MAX, | 811 | sizeof (disconnect_msg), UINT32_MAX, |
824 | GNUNET_TIME_UNIT_FOREVER_REL, session, plugin_name, | 812 | GNUNET_TIME_UNIT_FOREVER_REL, session, address, |
825 | sender_address, sender_address_len, GNUNET_YES, | 813 | GNUNET_YES, |
826 | &send_disconnect_cont, NULL); | 814 | &send_disconnect_cont, NULL); |
827 | 815 | ||
828 | if (ret == GNUNET_SYSERR) | 816 | if (ret == GNUNET_SYSERR) |
@@ -850,7 +838,7 @@ disconnect_neighbour (struct NeighbourMapEntry *n) | |||
850 | if (is_connected (n) || is_connecting (n)) | 838 | if (is_connected (n) || is_connecting (n)) |
851 | { | 839 | { |
852 | if (GNUNET_OK == | 840 | if (GNUNET_OK == |
853 | send_disconnect (&n->id, n->plugin_name, n->addr, n->addrlen, | 841 | send_disconnect (&n->id, n->address, |
854 | n->session)) | 842 | n->session)) |
855 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sent DISCONNECT_MSG to `%s'\n", | 843 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sent DISCONNECT_MSG to `%s'\n", |
856 | GNUNET_i2s (&n->id)); | 844 | GNUNET_i2s (&n->id)); |
@@ -862,8 +850,7 @@ disconnect_neighbour (struct NeighbourMapEntry *n) | |||
862 | 850 | ||
863 | if (is_connected(n)) | 851 | if (is_connected(n)) |
864 | { | 852 | { |
865 | GNUNET_ATS_address_in_use (GST_ats, &n->id, n->plugin_name, | 853 | GNUNET_ATS_address_in_use (GST_ats, n->address, n->session, GNUNET_NO); |
866 | n->addr, n->addrlen, n->session, GNUNET_NO); | ||
867 | } | 854 | } |
868 | 855 | ||
869 | 856 | ||
@@ -871,16 +858,14 @@ disconnect_neighbour (struct NeighbourMapEntry *n) | |||
871 | return; | 858 | return; |
872 | change_state (n, S_DISCONNECT); | 859 | change_state (n, S_DISCONNECT); |
873 | GST_validation_set_address_use (&n->id, | 860 | GST_validation_set_address_use (&n->id, |
874 | n->plugin_name, | 861 | n->address, |
875 | n->session, | 862 | n->session, |
876 | n->addr, | ||
877 | n->addrlen, | ||
878 | GNUNET_NO); | 863 | GNUNET_NO); |
879 | 864 | ||
880 | if (n->plugin_name != NULL) | 865 | if (n->address != NULL) |
881 | { | 866 | { |
882 | struct GNUNET_TRANSPORT_PluginFunctions *papi; | 867 | struct GNUNET_TRANSPORT_PluginFunctions *papi; |
883 | papi = GST_plugins_find (n->plugin_name); | 868 | papi = GST_plugins_find (n->address->transport_name); |
884 | if (papi != NULL) | 869 | if (papi != NULL) |
885 | papi->disconnect (papi->cls, &n->id); | 870 | papi->disconnect (papi->cls, &n->id); |
886 | } | 871 | } |
@@ -926,16 +911,10 @@ disconnect_neighbour (struct NeighbourMapEntry *n) | |||
926 | GNUNET_SCHEDULER_cancel (n->transmission_task); | 911 | GNUNET_SCHEDULER_cancel (n->transmission_task); |
927 | n->transmission_task = GNUNET_SCHEDULER_NO_TASK; | 912 | n->transmission_task = GNUNET_SCHEDULER_NO_TASK; |
928 | } | 913 | } |
929 | if (NULL != n->plugin_name) | 914 | if (NULL != n->address) |
930 | { | ||
931 | GNUNET_free (n->plugin_name); | ||
932 | n->plugin_name = NULL; | ||
933 | } | ||
934 | if (NULL != n->addr) | ||
935 | { | 915 | { |
936 | GNUNET_free (n->addr); | 916 | GNUNET_HELLO_address_free (n->address); |
937 | n->addr = NULL; | 917 | n->address = NULL; |
938 | n->addrlen = 0; | ||
939 | } | 918 | } |
940 | n->session = NULL; | 919 | n->session = NULL; |
941 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Deleting peer `%4s', %X\n", | 920 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Deleting peer `%4s', %X\n", |
@@ -990,8 +969,8 @@ neighbour_keepalive_task (void *cls, | |||
990 | 969 | ||
991 | send_with_plugin (&n->id, (const void *) &m, sizeof (m), | 970 | send_with_plugin (&n->id, (const void *) &m, sizeof (m), |
992 | UINT32_MAX /* priority */ , | 971 | UINT32_MAX /* priority */ , |
993 | GNUNET_TIME_UNIT_FOREVER_REL, n->session, n->plugin_name, | 972 | GNUNET_TIME_UNIT_FOREVER_REL, n->session, n->address, |
994 | n->addr, n->addrlen, GNUNET_YES, NULL, NULL); | 973 | GNUNET_YES, NULL, NULL); |
995 | } | 974 | } |
996 | 975 | ||
997 | 976 | ||
@@ -1083,14 +1062,12 @@ send_connect_continuation (void *cls, const struct GNUNET_PeerIdentity *target, | |||
1083 | #if DEBUG_TRANSPORT | 1062 | #if DEBUG_TRANSPORT |
1084 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1063 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1085 | "Failed to send CONNECT_MSG to peer `%4s' with plugin `%s' address '%s' session %X, asking ATS for new address \n", | 1064 | "Failed to send CONNECT_MSG to peer `%4s' with plugin `%s' address '%s' session %X, asking ATS for new address \n", |
1086 | GNUNET_i2s (&n->id), n->plugin_name, | 1065 | GNUNET_i2s (&n->id), n->address->transport_name, |
1087 | (n->addrlen == | 1066 | (n->addrlen == |
1088 | 0) ? "<inbound>" : GST_plugins_a2s (n->plugin_name, n->addr, | 1067 | 0) ? "<inbound>" : GST_plugins_a2s (n->address), n->session); |
1089 | n->addrlen), n->session); | ||
1090 | #endif | 1068 | #endif |
1091 | 1069 | ||
1092 | GNUNET_ATS_address_destroyed (GST_ats, &n->id, n->plugin_name, n->addr, | 1070 | GNUNET_ATS_address_destroyed (GST_ats, n->address, NULL); |
1093 | n->addrlen, NULL); | ||
1094 | 1071 | ||
1095 | change_state (n, S_NOT_CONNECTED); | 1072 | change_state (n, S_NOT_CONNECTED); |
1096 | 1073 | ||
@@ -1131,14 +1108,12 @@ send_switch_address_continuation (void *cls, | |||
1131 | #if DEBUG_TRANSPORT | 1108 | #if DEBUG_TRANSPORT |
1132 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1109 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1133 | "Failed to switch connected peer `%s' to plugin `%s' address '%s' session %X, asking ATS for new address \n", | 1110 | "Failed to switch connected peer `%s' to plugin `%s' address '%s' session %X, asking ATS for new address \n", |
1134 | GNUNET_i2s (&n->id), n->plugin_name, | 1111 | GNUNET_i2s (&n->id), n->address->transport_name, |
1135 | (n->addrlen == | 1112 | (n->addrlen == |
1136 | 0) ? "<inbound>" : GST_plugins_a2s (n->plugin_name, n->addr, | 1113 | 0) ? "<inbound>" : GST_plugins_a2s (n->address), n->session); |
1137 | n->addrlen), n->session); | ||
1138 | #endif | 1114 | #endif |
1139 | 1115 | ||
1140 | GNUNET_ATS_address_destroyed (GST_ats, &n->id, n->plugin_name, n->addr, | 1116 | GNUNET_ATS_address_destroyed (GST_ats, n->address, NULL); |
1141 | n->addrlen, NULL); | ||
1142 | 1117 | ||
1143 | if (n->ats_suggest != GNUNET_SCHEDULER_NO_TASK) | 1118 | if (n->ats_suggest != GNUNET_SCHEDULER_NO_TASK) |
1144 | GNUNET_SCHEDULER_cancel (n->ats_suggest); | 1119 | GNUNET_SCHEDULER_cancel (n->ats_suggest); |
@@ -1149,8 +1124,7 @@ send_switch_address_continuation (void *cls, | |||
1149 | return; | 1124 | return; |
1150 | } | 1125 | } |
1151 | /* Tell ATS that switching addresses was successful */ | 1126 | /* Tell ATS that switching addresses was successful */ |
1152 | GNUNET_ATS_address_in_use (GST_ats, &n->id, n->plugin_name, n->addr, | 1127 | GNUNET_ATS_address_in_use (GST_ats, n->address, n->session, GNUNET_YES); |
1153 | n->addrlen, n->addr, GNUNET_YES); | ||
1154 | } | 1128 | } |
1155 | 1129 | ||
1156 | /** | 1130 | /** |
@@ -1177,16 +1151,13 @@ send_connect_ack_continuation (void *cls, | |||
1177 | #if DEBUG_TRANSPORT | 1151 | #if DEBUG_TRANSPORT |
1178 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1152 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1179 | "Failed to send CONNECT_MSG to peer `%4s' with plugin `%s' address '%s' session %X, asking ATS for new address \n", | 1153 | "Failed to send CONNECT_MSG to peer `%4s' with plugin `%s' address '%s' session %X, asking ATS for new address \n", |
1180 | GNUNET_i2s (&n->id), n->plugin_name, | 1154 | GNUNET_i2s (&n->id), n->address->transport_name, |
1181 | (n->addrlen == 0) ? "<inbound>" : GST_plugins_a2s (n->plugin_name, | 1155 | (n->addrlen == 0) ? "<inbound>" : GST_plugins_a2s (n->address), |
1182 | n->addr, | ||
1183 | n->addrlen), | ||
1184 | n->session); | 1156 | n->session); |
1185 | #endif | 1157 | #endif |
1186 | change_state (n, S_NOT_CONNECTED); | 1158 | change_state (n, S_NOT_CONNECTED); |
1187 | 1159 | ||
1188 | GNUNET_ATS_address_destroyed (GST_ats, &n->id, n->plugin_name, n->addr, | 1160 | GNUNET_ATS_address_destroyed (GST_ats, n->address, NULL); |
1189 | n->addrlen, NULL); | ||
1190 | 1161 | ||
1191 | if (n->ats_suggest != GNUNET_SCHEDULER_NO_TASK) | 1162 | if (n->ats_suggest != GNUNET_SCHEDULER_NO_TASK) |
1192 | GNUNET_SCHEDULER_cancel (n->ats_suggest); | 1163 | GNUNET_SCHEDULER_cancel (n->ats_suggest); |
@@ -1201,10 +1172,8 @@ send_connect_ack_continuation (void *cls, | |||
1201 | * the given address. | 1172 | * the given address. |
1202 | * | 1173 | * |
1203 | * @param peer identity of the peer to switch the address for | 1174 | * @param peer identity of the peer to switch the address for |
1204 | * @param plugin_name name of transport that delivered the PONG | ||
1205 | * @param address address of the other peer, NULL if other peer | 1175 | * @param address address of the other peer, NULL if other peer |
1206 | * connected to us | 1176 | * connected to us |
1207 | * @param address_len number of bytes in address | ||
1208 | * @param session session to use (or NULL) | 1177 | * @param session session to use (or NULL) |
1209 | * @param ats performance data | 1178 | * @param ats performance data |
1210 | * @param ats_count number of entries in ats | 1179 | * @param ats_count number of entries in ats |
@@ -1213,8 +1182,7 @@ send_connect_ack_continuation (void *cls, | |||
1213 | */ | 1182 | */ |
1214 | int | 1183 | int |
1215 | GST_neighbours_switch_to_address_3way (const struct GNUNET_PeerIdentity *peer, | 1184 | GST_neighbours_switch_to_address_3way (const struct GNUNET_PeerIdentity *peer, |
1216 | const char *plugin_name, | 1185 | const struct GNUNET_HELLO_Address *address, |
1217 | const void *address, size_t address_len, | ||
1218 | struct Session *session, | 1186 | struct Session *session, |
1219 | const struct GNUNET_ATS_Information *ats, | 1187 | const struct GNUNET_ATS_Information *ats, |
1220 | uint32_t ats_count, | 1188 | uint32_t ats_count, |
@@ -1237,14 +1205,14 @@ GST_neighbours_switch_to_address_3way (const struct GNUNET_PeerIdentity *peer, | |||
1237 | 1205 | ||
1238 | checks_failed = GNUNET_NO; | 1206 | checks_failed = GNUNET_NO; |
1239 | 1207 | ||
1240 | if (plugin_name == NULL) | 1208 | if (address == NULL) |
1241 | { | 1209 | { |
1242 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 1210 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
1243 | "ATS offered suggested us empty address: plugin NULL"); | 1211 | "ATS offered suggested us empty address: plugin NULL"); |
1244 | GNUNET_break_op (0); | 1212 | GNUNET_break_op (0); |
1245 | checks_failed = GNUNET_YES; | 1213 | checks_failed = GNUNET_YES; |
1246 | } | 1214 | } |
1247 | if ((address == NULL) && (address_len == 0) && (session == NULL)) | 1215 | if ( (session == NULL) && (address == NULL) ) |
1248 | { | 1216 | { |
1249 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 1217 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
1250 | "ATS offered suggested us empty address: address NULL & session NULL"); | 1218 | "ATS offered suggested us empty address: address NULL & session NULL"); |
@@ -1258,8 +1226,7 @@ GST_neighbours_switch_to_address_3way (const struct GNUNET_PeerIdentity *peer, | |||
1258 | 1226 | ||
1259 | if (checks_failed == GNUNET_YES) | 1227 | if (checks_failed == GNUNET_YES) |
1260 | { | 1228 | { |
1261 | GNUNET_ATS_address_destroyed (GST_ats, peer, plugin_name, address, | 1229 | GNUNET_ATS_address_destroyed (GST_ats, address, session); |
1262 | address_len, session); | ||
1263 | if (n != NULL) | 1230 | if (n != NULL) |
1264 | GNUNET_ATS_suggest_address (GST_ats, peer); | 1231 | GNUNET_ATS_suggest_address (GST_ats, peer); |
1265 | return GNUNET_NO; | 1232 | return GNUNET_NO; |
@@ -1269,10 +1236,8 @@ GST_neighbours_switch_to_address_3way (const struct GNUNET_PeerIdentity *peer, | |||
1269 | #if DEBUG_TRANSPORT | 1236 | #if DEBUG_TRANSPORT |
1270 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1237 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1271 | "ATS tells us to switch to plugin `%s' address '%s' session %X for %s peer `%s'\n", | 1238 | "ATS tells us to switch to plugin `%s' address '%s' session %X for %s peer `%s'\n", |
1272 | plugin_name, | 1239 | address->transport_name, |
1273 | (address_len == 0) ? "<inbound>" : GST_plugins_a2s (plugin_name, | 1240 | (address_len == 0) ? "<inbound>" : GST_plugins_a2s (address), |
1274 | address, | ||
1275 | address_len), | ||
1276 | session, (is_connected (n) ? "CONNECTED" : "NOT CONNECTED"), | 1241 | session, (is_connected (n) ? "CONNECTED" : "NOT CONNECTED"), |
1277 | GNUNET_i2s (peer)); | 1242 | GNUNET_i2s (peer)); |
1278 | #endif | 1243 | #endif |
@@ -1284,66 +1249,57 @@ GST_neighbours_switch_to_address_3way (const struct GNUNET_PeerIdentity *peer, | |||
1284 | } | 1249 | } |
1285 | 1250 | ||
1286 | // do not switch addresses just update quotas | 1251 | // do not switch addresses just update quotas |
1287 | if ((is_connected (n)) && (address_len == n->addrlen)) | 1252 | if ( (is_connected (n)) && |
1253 | (0 == GNUNET_HELLO_address_cmp (address, | ||
1254 | n->address)) && | ||
1255 | (n->session == session) ) | ||
1288 | { | 1256 | { |
1289 | if ((0 == memcmp (address, n->addr, address_len)) && | 1257 | struct QuotaSetMessage q_msg; |
1290 | (n->session == session)) | 1258 | |
1291 | { | ||
1292 | struct QuotaSetMessage q_msg; | ||
1293 | |||
1294 | #if DEBUG_TRANSPORT | 1259 | #if DEBUG_TRANSPORT |
1295 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1260 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1296 | "Sending outbound quota of %u Bps and inbound quota of %u Bps for peer `%s' to all clients\n", | 1261 | "Sending outbound quota of %u Bps and inbound quota of %u Bps for peer `%s' to all clients\n", |
1297 | ntohl (n->bandwidth_out.value__), | 1262 | ntohl (n->bandwidth_out.value__), |
1298 | ntohl (n->bandwidth_in.value__), GNUNET_i2s (peer)); | 1263 | ntohl (n->bandwidth_in.value__), GNUNET_i2s (peer)); |
1299 | #endif | 1264 | #endif |
1300 | 1265 | ||
1301 | n->bandwidth_in = bandwidth_in; | 1266 | n->bandwidth_in = bandwidth_in; |
1302 | n->bandwidth_out = bandwidth_out; | 1267 | n->bandwidth_out = bandwidth_out; |
1303 | GST_neighbours_set_incoming_quota (&n->id, n->bandwidth_in); | 1268 | GST_neighbours_set_incoming_quota (&n->id, n->bandwidth_in); |
1304 | 1269 | ||
1305 | q_msg.header.size = htons (sizeof (struct QuotaSetMessage)); | 1270 | q_msg.header.size = htons (sizeof (struct QuotaSetMessage)); |
1306 | q_msg.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_SET_QUOTA); | 1271 | q_msg.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_SET_QUOTA); |
1307 | q_msg.quota = n->bandwidth_out; | 1272 | q_msg.quota = n->bandwidth_out; |
1308 | q_msg.peer = (*peer); | 1273 | q_msg.peer = (*peer); |
1309 | GST_clients_broadcast (&q_msg.header, GNUNET_NO); | 1274 | GST_clients_broadcast (&q_msg.header, GNUNET_NO); |
1310 | return GNUNET_NO; | 1275 | return GNUNET_NO; |
1311 | } | ||
1312 | } | 1276 | } |
1313 | if (n->state == S_CONNECTED) | 1277 | if (n->state == S_CONNECTED) |
1314 | GST_validation_set_address_use (&n->id, | 1278 | GST_validation_set_address_use (&n->id, |
1315 | n->plugin_name, | 1279 | n->address, |
1316 | n->session, | 1280 | n->session, |
1317 | n->addr, | ||
1318 | n->addrlen, | ||
1319 | GNUNET_NO); | 1281 | GNUNET_NO); |
1320 | /* This will be a connection switch, tell ATS about it */ | 1282 | /* This will be a connection switch, tell ATS about it */ |
1321 | if (n->state == S_CONNECTED) | 1283 | if (n->state == S_CONNECTED) |
1322 | { | 1284 | { |
1323 | GNUNET_ATS_address_in_use (GST_ats, &n->id, n->plugin_name, n->addr, | 1285 | GNUNET_ATS_address_in_use (GST_ats, n->address, n->session, GNUNET_NO); |
1324 | n->addrlen, n->addr, GNUNET_NO); | ||
1325 | } | 1286 | } |
1326 | 1287 | ||
1327 | /* set new address */ | 1288 | /* set new address */ |
1328 | GNUNET_free_non_null (n->addr); | 1289 | if (NULL != n->address) |
1329 | n->addr = GNUNET_malloc (address_len); | 1290 | GNUNET_HELLO_address_free (n->address); |
1330 | memcpy (n->addr, address, address_len); | 1291 | n->address = GNUNET_HELLO_address_copy (address); |
1331 | n->bandwidth_in = bandwidth_in; | 1292 | n->bandwidth_in = bandwidth_in; |
1332 | n->bandwidth_out = bandwidth_out; | 1293 | n->bandwidth_out = bandwidth_out; |
1333 | n->addrlen = address_len; | ||
1334 | n->session = session; | 1294 | n->session = session; |
1335 | GNUNET_free_non_null (n->plugin_name); | ||
1336 | n->plugin_name = GNUNET_strdup (plugin_name); | ||
1337 | GNUNET_SCHEDULER_cancel (n->timeout_task); | 1295 | GNUNET_SCHEDULER_cancel (n->timeout_task); |
1338 | n->timeout_task = | 1296 | n->timeout_task = |
1339 | GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, | 1297 | GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, |
1340 | &neighbour_timeout_task, n); | 1298 | &neighbour_timeout_task, n); |
1341 | if (n->state == S_CONNECTED) | 1299 | if (n->state == S_CONNECTED) |
1342 | GST_validation_set_address_use (&n->id, | 1300 | GST_validation_set_address_use (&n->id, |
1343 | n->plugin_name, | 1301 | n->address, |
1344 | n->session, | 1302 | n->session, |
1345 | n->addr, | ||
1346 | n->addrlen, | ||
1347 | GNUNET_YES); | 1303 | GNUNET_YES); |
1348 | 1304 | ||
1349 | 1305 | ||
@@ -1368,7 +1324,7 @@ GST_neighbours_switch_to_address_3way (const struct GNUNET_PeerIdentity *peer, | |||
1368 | ret = | 1324 | ret = |
1369 | send_with_plugin (peer, (const char *) &connect_msg, msg_len, | 1325 | send_with_plugin (peer, (const char *) &connect_msg, msg_len, |
1370 | UINT32_MAX, GNUNET_TIME_UNIT_FOREVER_REL, session, | 1326 | UINT32_MAX, GNUNET_TIME_UNIT_FOREVER_REL, session, |
1371 | plugin_name, address, address_len, GNUNET_YES, | 1327 | address, GNUNET_YES, |
1372 | &send_connect_continuation, n); | 1328 | &send_connect_continuation, n); |
1373 | 1329 | ||
1374 | 1330 | ||
@@ -1388,7 +1344,7 @@ GST_neighbours_switch_to_address_3way (const struct GNUNET_PeerIdentity *peer, | |||
1388 | ret = | 1344 | ret = |
1389 | send_with_plugin (&n->id, (const void *) &connect_msg, msg_len, | 1345 | send_with_plugin (&n->id, (const void *) &connect_msg, msg_len, |
1390 | UINT32_MAX, GNUNET_TIME_UNIT_FOREVER_REL, session, | 1346 | UINT32_MAX, GNUNET_TIME_UNIT_FOREVER_REL, session, |
1391 | plugin_name, address, address_len, GNUNET_YES, | 1347 | address, GNUNET_YES, |
1392 | &send_connect_ack_continuation, n); | 1348 | &send_connect_ack_continuation, n); |
1393 | return GNUNET_NO; | 1349 | return GNUNET_NO; |
1394 | } | 1350 | } |
@@ -1406,16 +1362,14 @@ GST_neighbours_switch_to_address_3way (const struct GNUNET_PeerIdentity *peer, | |||
1406 | ret = | 1362 | ret = |
1407 | send_with_plugin (peer, (const char *) &connect_msg, msg_len, | 1363 | send_with_plugin (peer, (const char *) &connect_msg, msg_len, |
1408 | UINT32_MAX, GNUNET_TIME_UNIT_FOREVER_REL, session, | 1364 | UINT32_MAX, GNUNET_TIME_UNIT_FOREVER_REL, session, |
1409 | plugin_name, address, address_len, GNUNET_YES, | 1365 | address, GNUNET_YES, |
1410 | &send_switch_address_continuation, n); | 1366 | &send_switch_address_continuation, n); |
1411 | if (ret == GNUNET_SYSERR) | 1367 | if (ret == GNUNET_SYSERR) |
1412 | { | 1368 | { |
1413 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1369 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1414 | "Failed to send CONNECT_MESSAGE to `%4s' using plugin `%s' address '%s' session %X\n", | 1370 | "Failed to send CONNECT_MESSAGE to `%4s' using address '%s' session %X\n", |
1415 | GNUNET_i2s (peer), plugin_name, | 1371 | GNUNET_i2s (peer), |
1416 | (address_len == | 1372 | GST_plugins_a2s (address), session); |
1417 | 0) ? "<inbound>" : GST_plugins_a2s (plugin_name, address, | ||
1418 | address_len), session); | ||
1419 | } | 1373 | } |
1420 | return GNUNET_NO; | 1374 | return GNUNET_NO; |
1421 | } | 1375 | } |
@@ -1446,10 +1400,8 @@ GST_neighbour_get_latency (const struct GNUNET_PeerIdentity *peer) | |||
1446 | if (NULL == n) | 1400 | if (NULL == n) |
1447 | return GNUNET_TIME_UNIT_FOREVER_REL; | 1401 | return GNUNET_TIME_UNIT_FOREVER_REL; |
1448 | return GST_validation_get_address_latency (peer, | 1402 | return GST_validation_get_address_latency (peer, |
1449 | n->plugin_name, | 1403 | n->address, |
1450 | n->session, | 1404 | n->session); |
1451 | n->addr, | ||
1452 | n->addrlen); | ||
1453 | } | 1405 | } |
1454 | 1406 | ||
1455 | 1407 | ||
@@ -1587,9 +1539,11 @@ GST_neighbours_session_terminated (const struct GNUNET_PeerIdentity *peer, | |||
1587 | return; /* doesn't affect us */ | 1539 | return; /* doesn't affect us */ |
1588 | 1540 | ||
1589 | n->session = NULL; | 1541 | n->session = NULL; |
1590 | GNUNET_free (n->addr); | 1542 | if (NULL != n->address) |
1591 | n->addr = NULL; | 1543 | { |
1592 | n->addrlen = 0; | 1544 | GNUNET_HELLO_address_free (n->address); |
1545 | n->address = NULL; | ||
1546 | } | ||
1593 | 1547 | ||
1594 | /* not connected anymore anyway, shouldn't matter */ | 1548 | /* not connected anymore anyway, shouldn't matter */ |
1595 | if ((!is_connected (n)) && (!is_connecting (n))) | 1549 | if ((!is_connected (n)) && (!is_connecting (n))) |
@@ -1656,7 +1610,7 @@ GST_neighbours_send (const struct GNUNET_PeerIdentity *target, const void *msg, | |||
1656 | return; | 1610 | return; |
1657 | } | 1611 | } |
1658 | 1612 | ||
1659 | if ((n->session == NULL) && (n->addr == NULL) && (n->addrlen == 0)) | 1613 | if ((n->session == NULL) && (n->address == NULL) ) |
1660 | { | 1614 | { |
1661 | GNUNET_STATISTICS_update (GST_stats, | 1615 | GNUNET_STATISTICS_update (GST_stats, |
1662 | gettext_noop | 1616 | gettext_noop |
@@ -1898,7 +1852,7 @@ neighbours_iterate (void *cls, const GNUNET_HashCode * key, void *value) | |||
1898 | if (!is_connected (n)) | 1852 | if (!is_connected (n)) |
1899 | return GNUNET_OK; | 1853 | return GNUNET_OK; |
1900 | 1854 | ||
1901 | ic->cb (ic->cb_cls, &n->id, NULL, 0, n->plugin_name, n->addr, n->addrlen); | 1855 | ic->cb (ic->cb_cls, &n->id, NULL, 0, n->address); |
1902 | return GNUNET_OK; | 1856 | return GNUNET_OK; |
1903 | } | 1857 | } |
1904 | 1858 | ||
@@ -1946,7 +1900,7 @@ GST_neighbours_force_disconnect (const struct GNUNET_PeerIdentity *target) | |||
1946 | return; /* not active */ | 1900 | return; /* not active */ |
1947 | if (is_connected (n)) | 1901 | if (is_connected (n)) |
1948 | { | 1902 | { |
1949 | send_disconnect (&n->id, n->plugin_name, n->addr, n->addrlen, n->session); | 1903 | send_disconnect (&n->id, n->address, n->session); |
1950 | 1904 | ||
1951 | n = lookup_neighbour (target); | 1905 | n = lookup_neighbour (target); |
1952 | if (NULL == n) | 1906 | if (NULL == n) |
@@ -2028,26 +1982,23 @@ GST_neighbours_handle_disconnect_message (const struct GNUNET_PeerIdentity | |||
2028 | GST_neighbours_force_disconnect (peer); | 1982 | GST_neighbours_force_disconnect (peer); |
2029 | } | 1983 | } |
2030 | 1984 | ||
1985 | |||
2031 | /** | 1986 | /** |
2032 | * We received a 'SESSION_CONNECT_ACK' message from the other peer. | 1987 | * We received a 'SESSION_CONNECT_ACK' message from the other peer. |
2033 | * Consider switching to it. | 1988 | * Consider switching to it. |
2034 | * | 1989 | * |
2035 | * @param message possibly a 'struct SessionConnectMessage' (check format) | 1990 | * @param message possibly a 'struct SessionConnectMessage' (check format) |
2036 | * @param peer identity of the peer to switch the address for | 1991 | * @param peer identity of the peer to switch the address for |
2037 | * @param plugin_name name of transport that delivered the PONG | ||
2038 | * @param address address of the other peer, NULL if other peer | 1992 | * @param address address of the other peer, NULL if other peer |
2039 | * connected to us | 1993 | * connected to us |
2040 | * @param address_len number of bytes in address | ||
2041 | * @param session session to use (or NULL) | 1994 | * @param session session to use (or NULL) |
2042 | * @param ats performance data | 1995 | * @param ats performance data |
2043 | * @param ats_count number of entries in ats | 1996 | * @param ats_count number of entries in ats |
2044 | */ | 1997 | */ |
2045 | void | 1998 | void |
2046 | GST_neighbours_handle_connect_ack (const struct GNUNET_MessageHeader *message, | 1999 | GST_neighbours_handle_connect_ack (const struct GNUNET_MessageHeader *message, |
2047 | const struct GNUNET_PeerIdentity *peer, | 2000 | const struct GNUNET_PeerIdentity *peer, |
2048 | const char *plugin_name, | 2001 | const struct GNUNET_HELLO_Address *address, |
2049 | const char *sender_address, | ||
2050 | uint16_t sender_address_len, | ||
2051 | struct Session *session, | 2002 | struct Session *session, |
2052 | const struct GNUNET_ATS_Information *ats, | 2003 | const struct GNUNET_ATS_Information *ats, |
2053 | uint32_t ats_count) | 2004 | uint32_t ats_count) |
@@ -2090,24 +2041,20 @@ GST_neighbours_handle_connect_ack (const struct GNUNET_MessageHeader *message, | |||
2090 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK, | 2041 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK, |
2091 | "transport-ats", | 2042 | "transport-ats", |
2092 | "Giving ATS session %p of plugin %s for peer %s\n", | 2043 | "Giving ATS session %p of plugin %s for peer %s\n", |
2093 | session, plugin_name, GNUNET_i2s (peer)); | 2044 | session, address->transport_name, GNUNET_i2s (peer)); |
2094 | GNUNET_ATS_address_update (GST_ats, peer, plugin_name, sender_address, | 2045 | GNUNET_ATS_address_update (GST_ats, address, session, ats, ats_count); |
2095 | sender_address_len, session, ats, ats_count); | ||
2096 | 2046 | ||
2097 | was_connected = is_connected (n); | 2047 | was_connected = is_connected (n); |
2098 | if (!is_connected (n)) | 2048 | if (!is_connected (n)) |
2099 | { | 2049 | { |
2100 | change_state (n, S_CONNECTED); | 2050 | change_state (n, S_CONNECTED); |
2101 | GST_validation_set_address_use (&n->id, | 2051 | GST_validation_set_address_use (&n->id, |
2102 | n->plugin_name, | 2052 | n->address, |
2103 | n->session, | 2053 | n->session, |
2104 | n->addr, | ||
2105 | n->addrlen, | ||
2106 | GNUNET_YES); | 2054 | GNUNET_YES); |
2107 | } | 2055 | } |
2108 | 2056 | ||
2109 | GNUNET_ATS_address_in_use (GST_ats, &n->id, n->plugin_name, n->addr, | 2057 | GNUNET_ATS_address_in_use (GST_ats, n->address, NULL, GNUNET_YES); |
2110 | n->addrlen, n->addr, GNUNET_YES); | ||
2111 | 2058 | ||
2112 | #if DEBUG_TRANSPORT | 2059 | #if DEBUG_TRANSPORT |
2113 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2060 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
@@ -2124,16 +2071,14 @@ GST_neighbours_handle_connect_ack (const struct GNUNET_MessageHeader *message, | |||
2124 | ret = | 2071 | ret = |
2125 | send_with_plugin (&n->id, (const char *) &msg, msg_len, UINT32_MAX, | 2072 | send_with_plugin (&n->id, (const char *) &msg, msg_len, UINT32_MAX, |
2126 | GNUNET_TIME_UNIT_FOREVER_REL, n->session, | 2073 | GNUNET_TIME_UNIT_FOREVER_REL, n->session, |
2127 | n->plugin_name, n->addr, n->addrlen, GNUNET_YES, NULL, | 2074 | n->address, GNUNET_YES, NULL, |
2128 | NULL); | 2075 | NULL); |
2129 | 2076 | ||
2130 | if (ret == GNUNET_SYSERR) | 2077 | if (ret == GNUNET_SYSERR) |
2131 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2078 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2132 | "Failed to send SESSION_ACK to `%4s' using plugin `%s' address '%s' session %X\n", | 2079 | "Failed to send SESSION_ACK to `%4s' using address '%s' session %X\n", |
2133 | GNUNET_i2s (&n->id), n->plugin_name, | 2080 | GNUNET_i2s (&n->id), |
2134 | (n->addrlen == | 2081 | GST_plugins_a2s (n->address), n->session); |
2135 | 0) ? "<inbound>" : GST_plugins_a2s (n->plugin_name, n->addr, | ||
2136 | n->addrlen), n->session); | ||
2137 | 2082 | ||
2138 | 2083 | ||
2139 | if (!was_connected) | 2084 | if (!was_connected) |
@@ -2148,11 +2093,9 @@ GST_neighbours_handle_connect_ack (const struct GNUNET_MessageHeader *message, | |||
2148 | GNUNET_NO); | 2093 | GNUNET_NO); |
2149 | #if DEBUG_TRANSPORT | 2094 | #if DEBUG_TRANSPORT |
2150 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2095 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2151 | "Notify about connect of `%4s' using plugin `%s' address '%s' session %X LINE %u\n", | 2096 | "Notify about connect of `%4s' using address '%s' session %X LINE %u\n", |
2152 | GNUNET_i2s (&n->id), n->plugin_name, | 2097 | GNUNET_i2s (&n->id), |
2153 | (n->addrlen == | 2098 | GST_plugins_a2s (n->address), n->session, |
2154 | 0) ? "<inbound>" : GST_plugins_a2s (n->plugin_name, n->addr, | ||
2155 | n->addrlen), n->session, | ||
2156 | __LINE__); | 2099 | __LINE__); |
2157 | #endif | 2100 | #endif |
2158 | connect_notify_cb (callback_cls, &n->id, ats, ats_count); | 2101 | connect_notify_cb (callback_cls, &n->id, ats, ats_count); |
@@ -2174,8 +2117,8 @@ GST_neighbours_handle_connect_ack (const struct GNUNET_MessageHeader *message, | |||
2174 | void | 2117 | void |
2175 | GST_neighbours_handle_ack (const struct GNUNET_MessageHeader *message, | 2118 | GST_neighbours_handle_ack (const struct GNUNET_MessageHeader *message, |
2176 | const struct GNUNET_PeerIdentity *peer, | 2119 | const struct GNUNET_PeerIdentity *peer, |
2177 | const char *plugin_name, const char *sender_address, | 2120 | const struct GNUNET_HELLO_Address *address, |
2178 | uint16_t sender_address_len, struct Session *session, | 2121 | struct Session *session, |
2179 | const struct GNUNET_ATS_Information *ats, | 2122 | const struct GNUNET_ATS_Information *ats, |
2180 | uint32_t ats_count) | 2123 | uint32_t ats_count) |
2181 | { | 2124 | { |
@@ -2197,7 +2140,7 @@ GST_neighbours_handle_ack (const struct GNUNET_MessageHeader *message, | |||
2197 | n = lookup_neighbour (peer); | 2140 | n = lookup_neighbour (peer); |
2198 | if (NULL == n) | 2141 | if (NULL == n) |
2199 | { | 2142 | { |
2200 | send_disconnect (peer, plugin_name, sender_address, sender_address_len, | 2143 | send_disconnect (peer, address, |
2201 | session); | 2144 | session); |
2202 | GNUNET_break (0); | 2145 | GNUNET_break (0); |
2203 | return; | 2146 | return; |
@@ -2217,15 +2160,13 @@ GST_neighbours_handle_ack (const struct GNUNET_MessageHeader *message, | |||
2217 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK, | 2160 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK, |
2218 | "transport-ats", | 2161 | "transport-ats", |
2219 | "Giving ATS session %p of plugin %s for peer %s\n", | 2162 | "Giving ATS session %p of plugin %s for peer %s\n", |
2220 | session, plugin_name, GNUNET_i2s (peer)); | 2163 | session, address->transport_name, GNUNET_i2s (peer)); |
2221 | GNUNET_ATS_address_update (GST_ats, peer, plugin_name, sender_address, | 2164 | GNUNET_ATS_address_update (GST_ats, address, session, ats, ats_count); |
2222 | sender_address_len, session, ats, ats_count); | ||
2223 | 2165 | ||
2224 | was_connected = is_connected (n); | 2166 | was_connected = is_connected (n); |
2225 | change_state (n, S_CONNECTED); | 2167 | change_state (n, S_CONNECTED); |
2226 | 2168 | ||
2227 | GNUNET_ATS_address_in_use (GST_ats, &n->id, n->plugin_name, n->addr, | 2169 | GNUNET_ATS_address_in_use (GST_ats, n->address, n->session, GNUNET_YES); |
2228 | n->addrlen, n->addr, GNUNET_YES); | ||
2229 | 2170 | ||
2230 | GST_neighbours_set_incoming_quota (&n->id, n->bandwidth_in); | 2171 | GST_neighbours_set_incoming_quota (&n->id, n->bandwidth_in); |
2231 | 2172 | ||
@@ -2237,10 +2178,8 @@ GST_neighbours_handle_ack (const struct GNUNET_MessageHeader *message, | |||
2237 | if (!was_connected) | 2178 | if (!was_connected) |
2238 | { | 2179 | { |
2239 | GST_validation_set_address_use (&n->id, | 2180 | GST_validation_set_address_use (&n->id, |
2240 | n->plugin_name, | 2181 | n->address, |
2241 | n->session, | 2182 | n->session, |
2242 | n->addr, | ||
2243 | n->addrlen, | ||
2244 | GNUNET_YES); | 2183 | GNUNET_YES); |
2245 | neighbours_connected++; | 2184 | neighbours_connected++; |
2246 | GNUNET_STATISTICS_update (GST_stats, gettext_noop ("# peers connected"), 1, | 2185 | GNUNET_STATISTICS_update (GST_stats, gettext_noop ("# peers connected"), 1, |
@@ -2248,11 +2187,9 @@ GST_neighbours_handle_ack (const struct GNUNET_MessageHeader *message, | |||
2248 | 2187 | ||
2249 | #if DEBUG_TRANSPORT | 2188 | #if DEBUG_TRANSPORT |
2250 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2189 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2251 | "Notify about connect of `%4s' using plugin `%s' address '%s' session %X LINE %u\n", | 2190 | "Notify about connect of `%4s' using address '%s' session %X LINE %u\n", |
2252 | GNUNET_i2s (&n->id), n->plugin_name, | 2191 | GNUNET_i2s (&n->id), |
2253 | (n->addrlen == | 2192 | GST_plugins_a2s (n->address), n->session, |
2254 | 0) ? "<inbound>" : GST_plugins_a2s (n->plugin_name, n->addr, | ||
2255 | n->addrlen), n->session, | ||
2256 | __LINE__); | 2193 | __LINE__); |
2257 | #endif | 2194 | #endif |
2258 | connect_notify_cb (callback_cls, &n->id, ats, ats_count); | 2195 | connect_notify_cb (callback_cls, &n->id, ats, ats_count); |
@@ -2277,11 +2214,7 @@ struct BlackListCheckContext | |||
2277 | 2214 | ||
2278 | struct Session *session; | 2215 | struct Session *session; |
2279 | 2216 | ||
2280 | char *sender_address; | 2217 | struct GNUNET_HELLO_Address *address; |
2281 | |||
2282 | uint16_t sender_address_len; | ||
2283 | |||
2284 | char *plugin_name; | ||
2285 | 2218 | ||
2286 | struct GNUNET_TIME_Absolute ts; | 2219 | struct GNUNET_TIME_Absolute ts; |
2287 | }; | 2220 | }; |
@@ -2305,6 +2238,7 @@ handle_connect_blacklist_cont (void *cls, | |||
2305 | /* not allowed */ | 2238 | /* not allowed */ |
2306 | if (GNUNET_OK != result) | 2239 | if (GNUNET_OK != result) |
2307 | { | 2240 | { |
2241 | GNUNET_HELLO_address_free (bcc->address); | ||
2308 | GNUNET_free (bcc); | 2242 | GNUNET_free (bcc); |
2309 | return; | 2243 | return; |
2310 | } | 2244 | } |
@@ -2318,13 +2252,11 @@ handle_connect_blacklist_cont (void *cls, | |||
2318 | if (NULL != bcc->session) | 2252 | if (NULL != bcc->session) |
2319 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK, | 2253 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK, |
2320 | "transport-ats", | 2254 | "transport-ats", |
2321 | "Giving ATS session %p of plugin %s address `%s' for peer %s\n", | 2255 | "Giving ATS session %p of address `%s' for peer %s\n", |
2322 | bcc->session, bcc->plugin_name, | 2256 | bcc->session, |
2323 | GST_plugins_a2s (bcc->plugin_name, bcc->sender_address, | 2257 | GST_plugins_a2s (bcc->address), |
2324 | bcc->sender_address_len), | ||
2325 | GNUNET_i2s (peer)); | 2258 | GNUNET_i2s (peer)); |
2326 | GNUNET_ATS_address_update (GST_ats, peer, bcc->plugin_name, | 2259 | GNUNET_ATS_address_update (GST_ats, bcc->address, |
2327 | bcc->sender_address, bcc->sender_address_len, | ||
2328 | bcc->session, bcc->ats, bcc->ats_count); | 2260 | bcc->session, bcc->ats, bcc->ats_count); |
2329 | n->connect_ts = bcc->ts; | 2261 | n->connect_ts = bcc->ts; |
2330 | } | 2262 | } |
@@ -2349,20 +2281,16 @@ handle_connect_blacklist_cont (void *cls, | |||
2349 | * | 2281 | * |
2350 | * @param message possibly a 'struct SessionConnectMessage' (check format) | 2282 | * @param message possibly a 'struct SessionConnectMessage' (check format) |
2351 | * @param peer identity of the peer to switch the address for | 2283 | * @param peer identity of the peer to switch the address for |
2352 | * @param plugin_name name of transport that delivered the PONG | ||
2353 | * @param address address of the other peer, NULL if other peer | 2284 | * @param address address of the other peer, NULL if other peer |
2354 | * connected to us | 2285 | * connected to us |
2355 | * @param address_len number of bytes in address | ||
2356 | * @param session session to use (or NULL) | 2286 | * @param session session to use (or NULL) |
2357 | * @param ats performance data | 2287 | * @param ats performance data |
2358 | * @param ats_count number of entries in ats (excluding 0-termination) | 2288 | * @param ats_count number of entries in ats (excluding 0-termination) |
2359 | */ | 2289 | */ |
2360 | void | 2290 | void |
2361 | GST_neighbours_handle_connect (const struct GNUNET_MessageHeader *message, | 2291 | GST_neighbours_handle_connect (const struct GNUNET_MessageHeader *message, |
2362 | const struct GNUNET_PeerIdentity *peer, | 2292 | const struct GNUNET_PeerIdentity *peer, |
2363 | const char *plugin_name, | 2293 | const struct GNUNET_HELLO_Address *address, |
2364 | const char *sender_address, | ||
2365 | uint16_t sender_address_len, | ||
2366 | struct Session *session, | 2294 | struct Session *session, |
2367 | const struct GNUNET_ATS_Information *ats, | 2295 | const struct GNUNET_ATS_Information *ats, |
2368 | uint32_t ats_count) | 2296 | uint32_t ats_count) |
@@ -2391,8 +2319,7 @@ GST_neighbours_handle_connect (const struct GNUNET_MessageHeader *message, | |||
2391 | /* connected peer switches addresses */ | 2319 | /* connected peer switches addresses */ |
2392 | if (is_connected (n)) | 2320 | if (is_connected (n)) |
2393 | { | 2321 | { |
2394 | GNUNET_ATS_address_update (GST_ats, peer, plugin_name, sender_address, | 2322 | GNUNET_ATS_address_update (GST_ats, address, session, ats, ats_count); |
2395 | sender_address_len, session, ats, ats_count); | ||
2396 | return; | 2323 | return; |
2397 | } | 2324 | } |
2398 | } | 2325 | } |
@@ -2401,26 +2328,16 @@ GST_neighbours_handle_connect (const struct GNUNET_MessageHeader *message, | |||
2401 | /* do blacklist check */ | 2328 | /* do blacklist check */ |
2402 | bcc = | 2329 | bcc = |
2403 | GNUNET_malloc (sizeof (struct BlackListCheckContext) + | 2330 | GNUNET_malloc (sizeof (struct BlackListCheckContext) + |
2404 | sizeof (struct GNUNET_ATS_Information) * (ats_count + 1) + | 2331 | sizeof (struct GNUNET_ATS_Information) * (ats_count + 1)); |
2405 | sender_address_len + strlen (plugin_name) + 1); | ||
2406 | |||
2407 | bcc->ts = GNUNET_TIME_absolute_ntoh (scm->timestamp); | 2332 | bcc->ts = GNUNET_TIME_absolute_ntoh (scm->timestamp); |
2408 | |||
2409 | bcc->ats_count = ats_count + 1; | 2333 | bcc->ats_count = ats_count + 1; |
2410 | bcc->sender_address_len = sender_address_len; | 2334 | bcc->address = GNUNET_HELLO_address_copy (address); |
2411 | bcc->session = session; | 2335 | bcc->session = session; |
2412 | |||
2413 | bcc->ats = (struct GNUNET_ATS_Information *) &bcc[1]; | 2336 | bcc->ats = (struct GNUNET_ATS_Information *) &bcc[1]; |
2414 | memcpy (bcc->ats, ats, sizeof (struct GNUNET_ATS_Information) * ats_count); | 2337 | memcpy (bcc->ats, ats, sizeof (struct GNUNET_ATS_Information) * ats_count); |
2415 | bcc->ats[ats_count].type = htonl (GNUNET_ATS_QUALITY_NET_DELAY); | 2338 | bcc->ats[ats_count].type = htonl (GNUNET_ATS_QUALITY_NET_DELAY); |
2416 | bcc->ats[ats_count].value = htonl ((uint32_t) GST_neighbour_get_latency (peer).rel_value); | 2339 | bcc->ats[ats_count].value = htonl ((uint32_t) GST_neighbour_get_latency (peer).rel_value); |
2417 | bcc->sender_address = (char *) &bcc->ats[ats_count + 1]; | 2340 | GST_blacklist_test_allowed (peer, address->transport_name, handle_connect_blacklist_cont, |
2418 | memcpy (bcc->sender_address, sender_address, sender_address_len); | ||
2419 | |||
2420 | bcc->plugin_name = &bcc->sender_address[sender_address_len]; | ||
2421 | strcpy (bcc->plugin_name, plugin_name); | ||
2422 | |||
2423 | GST_blacklist_test_allowed (peer, plugin_name, handle_connect_blacklist_cont, | ||
2424 | bcc); | 2341 | bcc); |
2425 | } | 2342 | } |
2426 | 2343 | ||
diff --git a/src/transport/gnunet-service-transport_neighbours.h b/src/transport/gnunet-service-transport_neighbours.h index 48e54e656..72ced636d 100644 --- a/src/transport/gnunet-service-transport_neighbours.h +++ b/src/transport/gnunet-service-transport_neighbours.h | |||
@@ -152,17 +152,14 @@ GST_neighbours_force_disconnect (const struct GNUNET_PeerIdentity *target); | |||
152 | * @param neighbour identity of the neighbour | 152 | * @param neighbour identity of the neighbour |
153 | * @param ats performance data | 153 | * @param ats performance data |
154 | * @param ats_count number of entries in ats (including 0-termination) | 154 | * @param ats_count number of entries in ats (including 0-termination) |
155 | * @param transport plugin | 155 | * @param address the address (or NULL) |
156 | * @param addr address | ||
157 | * @param addrlen address length | ||
158 | */ | 156 | */ |
159 | typedef void (*GST_NeighbourIterator) (void *cls, | 157 | typedef void (*GST_NeighbourIterator) (void *cls, |
160 | const struct GNUNET_PeerIdentity * | 158 | const struct GNUNET_PeerIdentity * |
161 | neighbour, | 159 | neighbour, |
162 | const struct GNUNET_ATS_Information * | 160 | const struct GNUNET_ATS_Information * |
163 | ats, uint32_t ats_count, | 161 | ats, uint32_t ats_count, |
164 | const char *transport, const void *addr, | 162 | const struct GNUNET_HELLO_Address *address); |
165 | size_t addrlen); | ||
166 | 163 | ||
167 | 164 | ||
168 | /** | 165 | /** |
@@ -191,10 +188,8 @@ GST_neighbours_session_terminated (const struct GNUNET_PeerIdentity *peer, | |||
191 | * use the given address. | 188 | * use the given address. |
192 | * | 189 | * |
193 | * @param peer identity of the peer to switch the address for | 190 | * @param peer identity of the peer to switch the address for |
194 | * @param plugin_name name of transport that delivered the PONG | ||
195 | * @param address address of the other peer, NULL if other peer | 191 | * @param address address of the other peer, NULL if other peer |
196 | * connected to us | 192 | * connected to us |
197 | * @param address_len number of bytes in address | ||
198 | * @param session session to use (or NULL) | 193 | * @param session session to use (or NULL) |
199 | * @param ats performance data | 194 | * @param ats performance data |
200 | * @param ats_count number of entries in ats | 195 | * @param ats_count number of entries in ats |
@@ -204,19 +199,11 @@ GST_neighbours_session_terminated (const struct GNUNET_PeerIdentity *peer, | |||
204 | * connection is not up (yet) | 199 | * connection is not up (yet) |
205 | */ | 200 | */ |
206 | int | 201 | int |
207 | GST_neighbours_switch_to_address (const struct GNUNET_PeerIdentity *peer, | ||
208 | const char *plugin_name, const void *address, | ||
209 | size_t address_len, struct Session *session, | ||
210 | const struct GNUNET_ATS_Information *ats, | ||
211 | uint32_t ats_count); | ||
212 | |||
213 | int | ||
214 | GST_neighbours_switch_to_address_3way (const struct GNUNET_PeerIdentity *peer, | 202 | GST_neighbours_switch_to_address_3way (const struct GNUNET_PeerIdentity *peer, |
215 | const char *plugin_name, | 203 | const struct GNUNET_HELLO_Address *address, |
216 | const void *address, size_t address_len, | 204 | struct Session *session, |
217 | struct Session *session, | 205 | const struct GNUNET_ATS_Information *ats, |
218 | const struct GNUNET_ATS_Information *ats, | 206 | uint32_t ats_count, |
219 | uint32_t ats_count, | ||
220 | struct GNUNET_BANDWIDTH_Value32NBO | 207 | struct GNUNET_BANDWIDTH_Value32NBO |
221 | bandwidth_in, | 208 | bandwidth_in, |
222 | struct GNUNET_BANDWIDTH_Value32NBO | 209 | struct GNUNET_BANDWIDTH_Value32NBO |
@@ -229,10 +216,8 @@ GST_neighbours_switch_to_address_3way (const struct GNUNET_PeerIdentity *peer, | |||
229 | * | 216 | * |
230 | * @param message possibly a 'struct SessionConnectMessage' (check format) | 217 | * @param message possibly a 'struct SessionConnectMessage' (check format) |
231 | * @param peer identity of the peer to switch the address for | 218 | * @param peer identity of the peer to switch the address for |
232 | * @param plugin_name name of transport that delivered the PONG | ||
233 | * @param address address of the other peer, NULL if other peer | 219 | * @param address address of the other peer, NULL if other peer |
234 | * connected to us | 220 | * connected to us |
235 | * @param address_len number of bytes in address | ||
236 | * @param session session to use (or NULL) | 221 | * @param session session to use (or NULL) |
237 | * @param ats performance data | 222 | * @param ats performance data |
238 | * @param ats_count number of entries in ats (excluding 0-termination) | 223 | * @param ats_count number of entries in ats (excluding 0-termination) |
@@ -240,19 +225,28 @@ GST_neighbours_switch_to_address_3way (const struct GNUNET_PeerIdentity *peer, | |||
240 | void | 225 | void |
241 | GST_neighbours_handle_connect (const struct GNUNET_MessageHeader *message, | 226 | GST_neighbours_handle_connect (const struct GNUNET_MessageHeader *message, |
242 | const struct GNUNET_PeerIdentity *peer, | 227 | const struct GNUNET_PeerIdentity *peer, |
243 | const char *plugin_name, | 228 | const struct GNUNET_HELLO_Address *address, |
244 | const char *sender_address, | ||
245 | uint16_t sender_address_len, | ||
246 | struct Session *session, | 229 | struct Session *session, |
247 | const struct GNUNET_ATS_Information *ats, | 230 | const struct GNUNET_ATS_Information *ats, |
248 | uint32_t ats_count); | 231 | uint32_t ats_count); |
249 | 232 | ||
233 | |||
234 | /** | ||
235 | * We received a 'SESSION_CONNECT_ACK' message from the other peer. | ||
236 | * Consider switching to it. | ||
237 | * | ||
238 | * @param message possibly a 'struct SessionConnectMessage' (check format) | ||
239 | * @param peer identity of the peer to switch the address for | ||
240 | * @param address address of the other peer, NULL if other peer | ||
241 | * connected to us | ||
242 | * @param session session to use (or NULL) | ||
243 | * @param ats performance data | ||
244 | * @param ats_count number of entries in ats | ||
245 | */ | ||
250 | void | 246 | void |
251 | GST_neighbours_handle_connect_ack (const struct GNUNET_MessageHeader *message, | 247 | GST_neighbours_handle_connect_ack (const struct GNUNET_MessageHeader *message, |
252 | const struct GNUNET_PeerIdentity *peer, | 248 | const struct GNUNET_PeerIdentity *peer, |
253 | const char *plugin_name, | 249 | const struct GNUNET_HELLO_Address *address, |
254 | const char *sender_address, | ||
255 | uint16_t sender_address_len, | ||
256 | struct Session *session, | 250 | struct Session *session, |
257 | const struct GNUNET_ATS_Information *ats, | 251 | const struct GNUNET_ATS_Information *ats, |
258 | uint32_t ats_count); | 252 | uint32_t ats_count); |
@@ -260,8 +254,8 @@ GST_neighbours_handle_connect_ack (const struct GNUNET_MessageHeader *message, | |||
260 | void | 254 | void |
261 | GST_neighbours_handle_ack (const struct GNUNET_MessageHeader *message, | 255 | GST_neighbours_handle_ack (const struct GNUNET_MessageHeader *message, |
262 | const struct GNUNET_PeerIdentity *peer, | 256 | const struct GNUNET_PeerIdentity *peer, |
263 | const char *plugin_name, const char *sender_address, | 257 | const struct GNUNET_HELLO_Address *address, |
264 | uint16_t sender_address_len, struct Session *session, | 258 | struct Session *session, |
265 | const struct GNUNET_ATS_Information *ats, | 259 | const struct GNUNET_ATS_Information *ats, |
266 | uint32_t ats_count); | 260 | uint32_t ats_count); |
267 | 261 | ||
diff --git a/src/transport/gnunet-service-transport_plugins.c b/src/transport/gnunet-service-transport_plugins.c index 52fcf661d..3c4466753 100644 --- a/src/transport/gnunet-service-transport_plugins.c +++ b/src/transport/gnunet-service-transport_plugins.c | |||
@@ -189,22 +189,20 @@ GST_plugins_find (const char *name) | |||
189 | * Convert a given address to a human-readable format. Note that the | 189 | * Convert a given address to a human-readable format. Note that the |
190 | * return value will be overwritten on the next call to this function. | 190 | * return value will be overwritten on the next call to this function. |
191 | * | 191 | * |
192 | * @param name plugin name | 192 | * @param address the address to convert |
193 | * @param addr binary address in plugin-specific format | ||
194 | * @param addrlen number of bytes in 'addr' | ||
195 | * @return statically allocated (!) human-readable address | 193 | * @return statically allocated (!) human-readable address |
196 | */ | 194 | */ |
197 | const char * | 195 | const char * |
198 | GST_plugins_a2s (const char *name, const void *addr, size_t addrlen) | 196 | GST_plugins_a2s (const struct GNUNET_HELLO_Address *address) |
199 | { | 197 | { |
200 | struct GNUNET_TRANSPORT_PluginFunctions *api; | 198 | struct GNUNET_TRANSPORT_PluginFunctions *api; |
201 | 199 | ||
202 | if (name == NULL) | 200 | if (address == NULL) |
201 | return "<inbound>"; | ||
202 | api = GST_plugins_find (address->transport_name); | ||
203 | if ((api == NULL) || (address->address_length == 0) || (address->address == NULL)) | ||
203 | return NULL; | 204 | return NULL; |
204 | api = GST_plugins_find (name); | 205 | return api->address_to_string (NULL, address->address, address->address_length); |
205 | if ((api == NULL) || (addrlen == 0) || (addr == NULL)) | ||
206 | return NULL; | ||
207 | return api->address_to_string (NULL, addr, addrlen); | ||
208 | } | 206 | } |
209 | 207 | ||
210 | 208 | ||
diff --git a/src/transport/gnunet-service-transport_plugins.h b/src/transport/gnunet-service-transport_plugins.h index 3a49f004f..3cca3ce10 100644 --- a/src/transport/gnunet-service-transport_plugins.h +++ b/src/transport/gnunet-service-transport_plugins.h | |||
@@ -30,6 +30,7 @@ | |||
30 | #include "gnunet_transport_service.h" | 30 | #include "gnunet_transport_service.h" |
31 | #include "gnunet_transport_plugin.h" | 31 | #include "gnunet_transport_plugin.h" |
32 | #include "gnunet_util_lib.h" | 32 | #include "gnunet_util_lib.h" |
33 | #include "gnunet_hello_lib.h" | ||
33 | 34 | ||
34 | 35 | ||
35 | /** | 36 | /** |
@@ -69,13 +70,11 @@ GST_plugins_find (const char *name); | |||
69 | * Convert a given address to a human-readable format. Note that the | 70 | * Convert a given address to a human-readable format. Note that the |
70 | * return value will be overwritten on the next call to this function. | 71 | * return value will be overwritten on the next call to this function. |
71 | * | 72 | * |
72 | * @param name plugin name | 73 | * @param address address to convert |
73 | * @param addr binary address in plugin-specific format | ||
74 | * @param addrlen number of bytes in 'addr' | ||
75 | * @return statically allocated (!) human-readable address | 74 | * @return statically allocated (!) human-readable address |
76 | */ | 75 | */ |
77 | const char * | 76 | const char * |
78 | GST_plugins_a2s (const char *name, const void *addr, size_t addrlen); | 77 | GST_plugins_a2s (const struct GNUNET_HELLO_Address *address); |
79 | 78 | ||
80 | 79 | ||
81 | #endif | 80 | #endif |
diff --git a/src/transport/gnunet-service-transport_validation.c b/src/transport/gnunet-service-transport_validation.c index afc35a3a6..9b93c7508 100644 --- a/src/transport/gnunet-service-transport_validation.c +++ b/src/transport/gnunet-service-transport_validation.c | |||
@@ -175,15 +175,9 @@ struct ValidationEntry | |||
175 | { | 175 | { |
176 | 176 | ||
177 | /** | 177 | /** |
178 | * Name of the transport. | 178 | * The address. |
179 | */ | 179 | */ |
180 | char *transport_name; | 180 | struct GNUNET_HELLO_Address *address; |
181 | |||
182 | /** | ||
183 | * The address, actually a pointer to the end | ||
184 | * of this struct. Do not free! | ||
185 | */ | ||
186 | const void *addr; | ||
187 | 181 | ||
188 | /** | 182 | /** |
189 | * Handle to the blacklist check (if we're currently in it). | 183 | * Handle to the blacklist check (if we're currently in it). |
@@ -196,7 +190,7 @@ struct ValidationEntry | |||
196 | struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded public_key; | 190 | struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded public_key; |
197 | 191 | ||
198 | /** | 192 | /** |
199 | * The identity of the peer. | 193 | * The identity of the peer. FIXME: duplicated (also in 'address') |
200 | */ | 194 | */ |
201 | struct GNUNET_PeerIdentity pid; | 195 | struct GNUNET_PeerIdentity pid; |
202 | 196 | ||
@@ -241,11 +235,6 @@ struct ValidationEntry | |||
241 | uint32_t challenge; | 235 | uint32_t challenge; |
242 | 236 | ||
243 | /** | 237 | /** |
244 | * Length of addr. | ||
245 | */ | ||
246 | size_t addrlen; | ||
247 | |||
248 | /** | ||
249 | * When passing the address in 'add_valid_peer_address', did we | 238 | * When passing the address in 'add_valid_peer_address', did we |
250 | * copy the address to the HELLO yet? | 239 | * copy the address to the HELLO yet? |
251 | */ | 240 | */ |
@@ -318,19 +307,10 @@ struct ValidationEntryMatchContext | |||
318 | struct ValidationEntry *ve; | 307 | struct ValidationEntry *ve; |
319 | 308 | ||
320 | /** | 309 | /** |
321 | * Transport name we're looking for. | ||
322 | */ | ||
323 | const char *transport_name; | ||
324 | |||
325 | /** | ||
326 | * Address we're interested in. | 310 | * Address we're interested in. |
327 | */ | 311 | */ |
328 | const char *addr; | 312 | const struct GNUNET_HELLO_Address *address; |
329 | 313 | ||
330 | /** | ||
331 | * Number of bytes in 'addr'. | ||
332 | */ | ||
333 | size_t addrlen; | ||
334 | }; | 314 | }; |
335 | 315 | ||
336 | 316 | ||
@@ -349,9 +329,9 @@ validation_entry_match (void *cls, const GNUNET_HashCode * key, void *value) | |||
349 | struct ValidationEntryMatchContext *vemc = cls; | 329 | struct ValidationEntryMatchContext *vemc = cls; |
350 | struct ValidationEntry *ve = value; | 330 | struct ValidationEntry *ve = value; |
351 | 331 | ||
352 | if ((ve->addrlen == vemc->addrlen) && | 332 | if (0 == |
353 | (0 == memcmp (ve->addr, vemc->addr, ve->addrlen)) && | 333 | GNUNET_HELLO_address_cmp (ve->address, |
354 | (0 == strcmp (ve->transport_name, vemc->transport_name))) | 334 | vemc->address)) |
355 | { | 335 | { |
356 | vemc->ve = ve; | 336 | vemc->ve = ve; |
357 | return GNUNET_NO; | 337 | return GNUNET_NO; |
@@ -381,7 +361,7 @@ cleanup_validation_entry (void *cls, const GNUNET_HashCode * key, void *value) | |||
381 | GNUNET_break (GNUNET_OK == | 361 | GNUNET_break (GNUNET_OK == |
382 | GNUNET_CONTAINER_multihashmap_remove (validation_map, | 362 | GNUNET_CONTAINER_multihashmap_remove (validation_map, |
383 | &ve->pid.hashPubKey, ve)); | 363 | &ve->pid.hashPubKey, ve)); |
384 | GNUNET_free (ve->transport_name); | 364 | GNUNET_HELLO_address_free (ve->address); |
385 | if (GNUNET_SCHEDULER_NO_TASK != ve->timeout_task) | 365 | if (GNUNET_SCHEDULER_NO_TASK != ve->timeout_task) |
386 | { | 366 | { |
387 | GNUNET_SCHEDULER_cancel (ve->timeout_task); | 367 | GNUNET_SCHEDULER_cancel (ve->timeout_task); |
@@ -454,16 +434,15 @@ transmit_ping_if_allowed (void *cls, const struct GNUNET_PeerIdentity *pid, | |||
454 | 434 | ||
455 | ve->bc = NULL; | 435 | ve->bc = NULL; |
456 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Transmitting plain PING to `%s' %s\n", | 436 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Transmitting plain PING to `%s' %s\n", |
457 | GNUNET_i2s (pid), GST_plugins_a2s (ve->transport_name, ve->addr, | 437 | GNUNET_i2s (pid), GST_plugins_a2s (ve->address)); |
458 | ve->addrlen)); | ||
459 | 438 | ||
460 | slen = strlen (ve->transport_name) + 1; | 439 | slen = strlen (ve->address->transport_name) + 1; |
461 | hello = GST_hello_get (); | 440 | hello = GST_hello_get (); |
462 | hsize = ntohs (hello->size); | 441 | hsize = ntohs (hello->size); |
463 | tsize = sizeof (struct TransportPingMessage) + ve->addrlen + slen + hsize; | 442 | tsize = sizeof (struct TransportPingMessage) + ve->address->address_length + slen + hsize; |
464 | 443 | ||
465 | ping.header.size = | 444 | ping.header.size = |
466 | htons (sizeof (struct TransportPingMessage) + ve->addrlen + slen); | 445 | htons (sizeof (struct TransportPingMessage) + ve->address->address_length + slen); |
467 | ping.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_PING); | 446 | ping.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_PING); |
468 | ping.challenge = htonl (ve->challenge); | 447 | ping.challenge = htonl (ve->challenge); |
469 | ping.target = *pid; | 448 | ping.target = *pid; |
@@ -476,7 +455,7 @@ transmit_ping_if_allowed (void *cls, const struct GNUNET_PeerIdentity *pid, | |||
476 | "HELLO", "PING", (unsigned int) tsize); | 455 | "HELLO", "PING", (unsigned int) tsize); |
477 | /* message too big (!?), get rid of HELLO */ | 456 | /* message too big (!?), get rid of HELLO */ |
478 | hsize = 0; | 457 | hsize = 0; |
479 | tsize = sizeof (struct TransportPingMessage) + ve->addrlen + slen + hsize; | 458 | tsize = sizeof (struct TransportPingMessage) + ve->address->address_length + slen + hsize; |
480 | } | 459 | } |
481 | { | 460 | { |
482 | char message_buf[tsize]; | 461 | char message_buf[tsize]; |
@@ -486,10 +465,10 @@ transmit_ping_if_allowed (void *cls, const struct GNUNET_PeerIdentity *pid, | |||
486 | memcpy (message_buf, hello, hsize); | 465 | memcpy (message_buf, hello, hsize); |
487 | memcpy (&message_buf[hsize], &ping, sizeof (struct TransportPingMessage)); | 466 | memcpy (&message_buf[hsize], &ping, sizeof (struct TransportPingMessage)); |
488 | memcpy (&message_buf[sizeof (struct TransportPingMessage) + hsize], | 467 | memcpy (&message_buf[sizeof (struct TransportPingMessage) + hsize], |
489 | ve->transport_name, slen); | 468 | ve->address->transport_name, slen); |
490 | memcpy (&message_buf[sizeof (struct TransportPingMessage) + slen + hsize], | 469 | memcpy (&message_buf[sizeof (struct TransportPingMessage) + slen + hsize], |
491 | ve->addr, ve->addrlen); | 470 | ve->address, ve->address->address_length); |
492 | papi = GST_plugins_find (ve->transport_name); | 471 | papi = GST_plugins_find (ve->address->transport_name); |
493 | if (papi == NULL) | 472 | if (papi == NULL) |
494 | ret = -1; | 473 | ret = -1; |
495 | else | 474 | else |
@@ -498,7 +477,8 @@ transmit_ping_if_allowed (void *cls, const struct GNUNET_PeerIdentity *pid, | |||
498 | ret = | 477 | ret = |
499 | papi->send (papi->cls, pid, message_buf, tsize, PING_PRIORITY, | 478 | papi->send (papi->cls, pid, message_buf, tsize, PING_PRIORITY, |
500 | ACCEPTABLE_PING_DELAY, NULL /* no session */ , | 479 | ACCEPTABLE_PING_DELAY, NULL /* no session */ , |
501 | ve->addr, ve->addrlen, GNUNET_YES, NULL, NULL); | 480 | ve->address->address, ve->address->address_length, |
481 | GNUNET_YES, NULL, NULL); | ||
502 | } | 482 | } |
503 | } | 483 | } |
504 | if (-1 != ret) | 484 | if (-1 != ret) |
@@ -566,7 +546,8 @@ revalidate_address (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
566 | GNUNET_STATISTICS_update (GST_stats, | 546 | GNUNET_STATISTICS_update (GST_stats, |
567 | gettext_noop ("# address revalidations started"), 1, | 547 | gettext_noop ("# address revalidations started"), 1, |
568 | GNUNET_NO); | 548 | GNUNET_NO); |
569 | bc = GST_blacklist_test_allowed (&ve->pid, ve->transport_name, &transmit_ping_if_allowed, ve); | 549 | bc = GST_blacklist_test_allowed (&ve->pid, ve->address->transport_name, |
550 | &transmit_ping_if_allowed, ve); | ||
570 | if (NULL != bc) | 551 | if (NULL != bc) |
571 | ve->bc = bc; /* only set 'bc' if 'transmit_ping_if_allowed' was not already | 552 | ve->bc = bc; /* only set 'bc' if 'transmit_ping_if_allowed' was not already |
572 | called... */ | 553 | called... */ |
@@ -579,45 +560,36 @@ revalidate_address (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
579 | * without starting any validation). | 560 | * without starting any validation). |
580 | * | 561 | * |
581 | * @param public_key public key of the peer, NULL for unknown | 562 | * @param public_key public key of the peer, NULL for unknown |
582 | * @param neighbour which peer we care about | 563 | * @param address address to find |
583 | * @param tname name of the transport plugin | ||
584 | * @param addr binary address | ||
585 | * @param addrlen length of addr | ||
586 | * @return validation entry matching the given specifications, NULL | 564 | * @return validation entry matching the given specifications, NULL |
587 | * if we don't have an existing entry and no public key was given | 565 | * if we don't have an existing entry and no public key was given |
588 | */ | 566 | */ |
589 | static struct ValidationEntry * | 567 | static struct ValidationEntry * |
590 | find_validation_entry (const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded | 568 | find_validation_entry (const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded |
591 | *public_key, const struct GNUNET_PeerIdentity *neighbour, | 569 | *public_key, const struct GNUNET_HELLO_Address *address) |
592 | const char *tname, const char *addr, size_t addrlen) | ||
593 | { | 570 | { |
594 | struct ValidationEntryMatchContext vemc; | 571 | struct ValidationEntryMatchContext vemc; |
595 | struct ValidationEntry *ve; | 572 | struct ValidationEntry *ve; |
596 | 573 | ||
597 | vemc.ve = NULL; | 574 | vemc.ve = NULL; |
598 | vemc.transport_name = tname; | 575 | vemc.address = address; |
599 | vemc.addr = addr; | ||
600 | vemc.addrlen = addrlen; | ||
601 | GNUNET_CONTAINER_multihashmap_get_multiple (validation_map, | 576 | GNUNET_CONTAINER_multihashmap_get_multiple (validation_map, |
602 | &neighbour->hashPubKey, | 577 | &address->peer.hashPubKey, |
603 | &validation_entry_match, &vemc); | 578 | &validation_entry_match, &vemc); |
604 | if (NULL != (ve = vemc.ve)) | 579 | if (NULL != (ve = vemc.ve)) |
605 | return ve; | 580 | return ve; |
606 | if (public_key == NULL) | 581 | if (public_key == NULL) |
607 | return NULL; | 582 | return NULL; |
608 | ve = GNUNET_malloc (sizeof (struct ValidationEntry) + addrlen); | 583 | ve = GNUNET_malloc (sizeof (struct ValidationEntry)); |
609 | ve->transport_name = GNUNET_strdup (tname); | 584 | ve->address = GNUNET_HELLO_address_copy (address); |
610 | ve->addr = (void *) &ve[1]; | ||
611 | ve->public_key = *public_key; | 585 | ve->public_key = *public_key; |
612 | ve->pid = *neighbour; | 586 | ve->pid = address->peer; |
613 | ve->latency = GNUNET_TIME_UNIT_FOREVER_REL; | 587 | ve->latency = GNUNET_TIME_UNIT_FOREVER_REL; |
614 | ve->challenge = | 588 | ve->challenge = |
615 | GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_NONCE, UINT32_MAX); | 589 | GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_NONCE, UINT32_MAX); |
616 | ve->timeout_task = GNUNET_SCHEDULER_add_delayed (UNVALIDATED_PING_KEEPALIVE, | 590 | ve->timeout_task = GNUNET_SCHEDULER_add_delayed (UNVALIDATED_PING_KEEPALIVE, |
617 | &timeout_hello_validation, ve); | 591 | &timeout_hello_validation, ve); |
618 | memcpy (&ve[1], addr, addrlen); | 592 | GNUNET_CONTAINER_multihashmap_put (validation_map, &address->peer.hashPubKey, ve, |
619 | ve->addrlen = addrlen; | ||
620 | GNUNET_CONTAINER_multihashmap_put (validation_map, &neighbour->hashPubKey, ve, | ||
621 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); | 593 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); |
622 | return ve; | 594 | return ve; |
623 | } | 595 | } |
@@ -628,16 +600,14 @@ find_validation_entry (const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded | |||
628 | * addresses. | 600 | * addresses. |
629 | * | 601 | * |
630 | * @param cls original HELLO message | 602 | * @param cls original HELLO message |
631 | * @param tname name of the transport | 603 | * @param address the address |
632 | * @param expiration expiration time | 604 | * @param expiration expiration time |
633 | * @param addr the address | ||
634 | * @param addrlen length of the address | ||
635 | * @return GNUNET_OK (keep the address) | 605 | * @return GNUNET_OK (keep the address) |
636 | */ | 606 | */ |
637 | static int | 607 | static int |
638 | add_valid_address (void *cls, const char *tname, | 608 | add_valid_address (void *cls, |
639 | struct GNUNET_TIME_Absolute expiration, const void *addr, | 609 | const struct GNUNET_HELLO_Address *address, |
640 | uint16_t addrlen) | 610 | struct GNUNET_TIME_Absolute expiration) |
641 | { | 611 | { |
642 | const struct GNUNET_HELLO_Message *hello = cls; | 612 | const struct GNUNET_HELLO_Message *hello = cls; |
643 | struct ValidationEntry *ve; | 613 | struct ValidationEntry *ve; |
@@ -652,11 +622,11 @@ add_valid_address (void *cls, const char *tname, | |||
652 | GNUNET_break (0); | 622 | GNUNET_break (0); |
653 | return GNUNET_OK; /* invalid HELLO !? */ | 623 | return GNUNET_OK; /* invalid HELLO !? */ |
654 | } | 624 | } |
655 | ve = find_validation_entry (&public_key, &pid, tname, addr, addrlen); | 625 | ve = find_validation_entry (&public_key, address); |
656 | ve->valid_until = GNUNET_TIME_absolute_max (ve->valid_until, expiration); | 626 | ve->valid_until = GNUNET_TIME_absolute_max (ve->valid_until, expiration); |
657 | if (GNUNET_SCHEDULER_NO_TASK == ve->revalidation_task) | 627 | if (GNUNET_SCHEDULER_NO_TASK == ve->revalidation_task) |
658 | ve->revalidation_task = GNUNET_SCHEDULER_add_now (&revalidate_address, ve); | 628 | ve->revalidation_task = GNUNET_SCHEDULER_add_now (&revalidate_address, ve); |
659 | GNUNET_ATS_address_update (GST_ats, &pid, tname, addr, addrlen, NULL, NULL, | 629 | GNUNET_ATS_address_update (GST_ats, address, NULL, NULL, |
660 | 0); | 630 | 0); |
661 | return GNUNET_OK; | 631 | return GNUNET_OK; |
662 | } | 632 | } |
@@ -728,29 +698,27 @@ GST_validation_stop () | |||
728 | * @param validation_block is FOREVER if the address is for an unsupported plugin (from PEERINFO) | 698 | * @param validation_block is FOREVER if the address is for an unsupported plugin (from PEERINFO) |
729 | * is ZERO if the address is considered valid (no validation needed) | 699 | * is ZERO if the address is considered valid (no validation needed) |
730 | * otherwise a time in the future if we're currently denying re-validation | 700 | * otherwise a time in the future if we're currently denying re-validation |
731 | * @param plugin_name name of the plugin | 701 | * @param adress target address |
732 | * @param plugin_address binary address | ||
733 | * @param plugin_address_len length of address | ||
734 | */ | 702 | */ |
735 | static void | 703 | static void |
736 | multicast_pong (void *cls, | 704 | multicast_pong (void *cls, |
737 | const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded | 705 | const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded |
738 | *public_key, const struct GNUNET_PeerIdentity *target, | 706 | *public_key, |
739 | struct GNUNET_TIME_Absolute valid_until, | 707 | struct GNUNET_TIME_Absolute valid_until, |
740 | struct GNUNET_TIME_Absolute validation_block, | 708 | struct GNUNET_TIME_Absolute validation_block, |
741 | const char *plugin_name, const void *plugin_address, | 709 | const struct GNUNET_HELLO_Address *address) |
742 | size_t plugin_address_len) | ||
743 | { | 710 | { |
744 | struct TransportPongMessage *pong = cls; | 711 | struct TransportPongMessage *pong = cls; |
745 | struct GNUNET_TRANSPORT_PluginFunctions *papi; | 712 | struct GNUNET_TRANSPORT_PluginFunctions *papi; |
746 | 713 | ||
747 | papi = GST_plugins_find (plugin_name); | 714 | papi = GST_plugins_find (address->transport_name); |
748 | if (papi == NULL) | 715 | if (papi == NULL) |
749 | return; | 716 | return; |
750 | (void) papi->send (papi->cls, target, (const char *) pong, | 717 | (void) papi->send (papi->cls, &address->peer, (const char *) pong, |
751 | ntohs (pong->header.size), PONG_PRIORITY, | 718 | ntohs (pong->header.size), PONG_PRIORITY, |
752 | ACCEPTABLE_PING_DELAY, NULL, plugin_address, | 719 | ACCEPTABLE_PING_DELAY, NULL, |
753 | plugin_address_len, GNUNET_YES, NULL, NULL); | 720 | address->address, |
721 | address->address_length, GNUNET_YES, NULL, NULL); | ||
754 | } | 722 | } |
755 | 723 | ||
756 | 724 | ||
@@ -759,18 +727,14 @@ multicast_pong (void *cls, | |||
759 | * | 727 | * |
760 | * @param sender peer sending the PING | 728 | * @param sender peer sending the PING |
761 | * @param hdr the PING | 729 | * @param hdr the PING |
730 | * @param sender_address the sender address as we got it | ||
762 | * @param session session we got the PING from | 731 | * @param session session we got the PING from |
763 | * @param plugin_name name of plugin that received the PING | ||
764 | * @param sender_address address of the sender as known to the plugin, NULL | ||
765 | * if we did not initiate the connection | ||
766 | * @param sender_address_len number of bytes in sender_address | ||
767 | */ | 732 | */ |
768 | void | 733 | void |
769 | GST_validation_handle_ping (const struct GNUNET_PeerIdentity *sender, | 734 | GST_validation_handle_ping (const struct GNUNET_PeerIdentity *sender, |
770 | const struct GNUNET_MessageHeader *hdr, | 735 | const struct GNUNET_MessageHeader *hdr, |
771 | const char *plugin_name, struct Session *session, | 736 | const struct GNUNET_HELLO_Address *sender_address, |
772 | const void *sender_address, | 737 | struct Session *session) |
773 | size_t sender_address_len) | ||
774 | { | 738 | { |
775 | const struct TransportPingMessage *ping; | 739 | const struct TransportPingMessage *ping; |
776 | struct TransportPongMessage *pong; | 740 | struct TransportPongMessage *pong; |
@@ -782,6 +746,7 @@ GST_validation_handle_ping (const struct GNUNET_PeerIdentity *sender, | |||
782 | size_t alen; | 746 | size_t alen; |
783 | size_t slen; | 747 | size_t slen; |
784 | ssize_t ret; | 748 | ssize_t ret; |
749 | struct GNUNET_HELLO_Address address; | ||
785 | 750 | ||
786 | if (ntohs (hdr->size) < sizeof (struct TransportPingMessage)) | 751 | if (ntohs (hdr->size) < sizeof (struct TransportPingMessage)) |
787 | { | 752 | { |
@@ -821,15 +786,18 @@ GST_validation_handle_ping (const struct GNUNET_PeerIdentity *sender, | |||
821 | addrend++; | 786 | addrend++; |
822 | slen = strlen (addr) + 1; | 787 | slen = strlen (addr) + 1; |
823 | alen -= slen; | 788 | alen -= slen; |
824 | 789 | address.address = addrend; | |
790 | address.address_length = alen; | ||
791 | address.transport_name = addr; | ||
792 | address.peer = *sender; | ||
825 | if (GNUNET_YES != | 793 | if (GNUNET_YES != |
826 | GST_hello_test_address (addr, addrend, alen, &sig_cache, | 794 | GST_hello_test_address (&address, &sig_cache, |
827 | &sig_cache_exp)) | 795 | &sig_cache_exp)) |
828 | { | 796 | { |
829 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 797 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
830 | _ | 798 | _ |
831 | ("Not confirming PING with address `%s' since I cannot confirm having this address.\n"), | 799 | ("Not confirming PING with address `%s' since I cannot confirm having this address.\n"), |
832 | GST_plugins_a2s (addr, addrend, alen)); | 800 | GST_plugins_a2s (&address)); |
833 | return; | 801 | return; |
834 | } | 802 | } |
835 | } | 803 | } |
@@ -879,15 +847,17 @@ GST_validation_handle_ping (const struct GNUNET_PeerIdentity *sender, | |||
879 | 847 | ||
880 | /* first see if the session we got this PING from can be used to transmit | 848 | /* first see if the session we got this PING from can be used to transmit |
881 | * a response reliably */ | 849 | * a response reliably */ |
882 | papi = GST_plugins_find (plugin_name); | 850 | papi = GST_plugins_find (sender_address->transport_name); |
883 | if (papi == NULL) | 851 | if (papi == NULL) |
884 | ret = -1; | 852 | ret = -1; |
885 | else | 853 | else |
886 | ret = | 854 | ret = |
887 | papi->send (papi->cls, sender, (const char *) pong, | 855 | papi->send (papi->cls, sender, (const char *) pong, |
888 | ntohs (pong->header.size), PONG_PRIORITY, | 856 | ntohs (pong->header.size), PONG_PRIORITY, |
889 | ACCEPTABLE_PING_DELAY, session, sender_address, | 857 | ACCEPTABLE_PING_DELAY, session, |
890 | sender_address_len, GNUNET_SYSERR, NULL, NULL); | 858 | sender_address->address, |
859 | sender_address->address_length, | ||
860 | GNUNET_SYSERR, NULL, NULL); | ||
891 | if (ret != -1) | 861 | if (ret != -1) |
892 | { | 862 | { |
893 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 863 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
@@ -934,24 +904,21 @@ struct ValidateAddressContext | |||
934 | * (unless blocked or already validated). | 904 | * (unless blocked or already validated). |
935 | * | 905 | * |
936 | * @param cls pointer to a 'struct ValidateAddressContext' | 906 | * @param cls pointer to a 'struct ValidateAddressContext' |
937 | * @param tname name of the transport | 907 | * @param address the address |
938 | * @param expiration expiration time | 908 | * @param expiration expiration time |
939 | * @param addr the address | ||
940 | * @param addrlen length of the address | ||
941 | * @return GNUNET_OK (keep the address) | 909 | * @return GNUNET_OK (keep the address) |
942 | */ | 910 | */ |
943 | static int | 911 | static int |
944 | validate_address_iterator (void *cls, const char *tname, | 912 | validate_address_iterator (void *cls, |
945 | struct GNUNET_TIME_Absolute expiration, const void *addr, | 913 | const struct GNUNET_HELLO_Address *address, |
946 | uint16_t addrlen) | 914 | struct GNUNET_TIME_Absolute expiration) |
947 | { | 915 | { |
948 | const struct ValidateAddressContext *vac = cls; | 916 | const struct ValidateAddressContext *vac = cls; |
949 | const struct GNUNET_PeerIdentity *pid = &vac->pid; | ||
950 | struct ValidationEntry *ve; | 917 | struct ValidationEntry *ve; |
951 | 918 | ||
952 | if (GNUNET_TIME_absolute_get_remaining (expiration).rel_value == 0) | 919 | if (GNUNET_TIME_absolute_get_remaining (expiration).rel_value == 0) |
953 | return GNUNET_OK; /* expired */ | 920 | return GNUNET_OK; /* expired */ |
954 | ve = find_validation_entry (&vac->public_key, pid, tname, addr, addrlen); | 921 | ve = find_validation_entry (&vac->public_key, address); |
955 | if (GNUNET_SCHEDULER_NO_TASK == ve->revalidation_task) | 922 | if (GNUNET_SCHEDULER_NO_TASK == ve->revalidation_task) |
956 | ve->revalidation_task = GNUNET_SCHEDULER_add_now (&revalidate_address, | 923 | ve->revalidation_task = GNUNET_SCHEDULER_add_now (&revalidate_address, |
957 | ve); | 924 | ve); |
@@ -976,8 +943,8 @@ add_valid_peer_address (void *cls, size_t max, void *buf) | |||
976 | if (GNUNET_YES == ve->copied) | 943 | if (GNUNET_YES == ve->copied) |
977 | return 0; /* terminate */ | 944 | return 0; /* terminate */ |
978 | ve->copied = GNUNET_YES; | 945 | ve->copied = GNUNET_YES; |
979 | return GNUNET_HELLO_add_address (ve->transport_name, ve->valid_until, | 946 | return GNUNET_HELLO_add_address (ve->address, ve->valid_until, |
980 | ve->addr, ve->addrlen, buf, max); | 947 | buf, max); |
981 | } | 948 | } |
982 | 949 | ||
983 | 950 | ||
@@ -1000,6 +967,7 @@ GST_validation_handle_pong (const struct GNUNET_PeerIdentity *sender, | |||
1000 | size_t slen; | 967 | size_t slen; |
1001 | size_t size; | 968 | size_t size; |
1002 | struct GNUNET_HELLO_Message *hello; | 969 | struct GNUNET_HELLO_Message *hello; |
970 | struct GNUNET_HELLO_Address address; | ||
1003 | 971 | ||
1004 | if (ntohs (hdr->size) < sizeof (struct TransportPongMessage)) | 972 | if (ntohs (hdr->size) < sizeof (struct TransportPongMessage)) |
1005 | { | 973 | { |
@@ -1022,8 +990,11 @@ GST_validation_handle_pong (const struct GNUNET_PeerIdentity *sender, | |||
1022 | addr++; | 990 | addr++; |
1023 | slen = strlen (tname) + 1; | 991 | slen = strlen (tname) + 1; |
1024 | addrlen = size - slen; | 992 | addrlen = size - slen; |
1025 | 993 | address.peer = *sender; | |
1026 | ve = find_validation_entry (NULL, sender, tname, addr, addrlen); | 994 | address.address = addr; |
995 | address.address_length = addrlen; | ||
996 | address.transport_name = tname; | ||
997 | ve = find_validation_entry (NULL, &address); | ||
1027 | if (NULL == ve) | 998 | if (NULL == ve) |
1028 | { | 999 | { |
1029 | GNUNET_STATISTICS_update (GST_stats, | 1000 | GNUNET_STATISTICS_update (GST_stats, |
@@ -1071,8 +1042,7 @@ GST_validation_handle_pong (const struct GNUNET_PeerIdentity *sender, | |||
1071 | 1042 | ||
1072 | ats.type = htonl (GNUNET_ATS_QUALITY_NET_DELAY); | 1043 | ats.type = htonl (GNUNET_ATS_QUALITY_NET_DELAY); |
1073 | ats.value = htonl ((uint32_t) ve->latency.rel_value); | 1044 | ats.value = htonl ((uint32_t) ve->latency.rel_value); |
1074 | GNUNET_ATS_address_update (GST_ats, &ve->pid, ve->transport_name, ve->addr, | 1045 | GNUNET_ATS_address_update (GST_ats, ve->address, NULL, &ats, 1); |
1075 | ve->addrlen, NULL, &ats, 1); | ||
1076 | } | 1046 | } |
1077 | /* build HELLO to store in PEERINFO */ | 1047 | /* build HELLO to store in PEERINFO */ |
1078 | ve->copied = GNUNET_NO; | 1048 | ve->copied = GNUNET_NO; |
@@ -1153,8 +1123,8 @@ iterate_addresses (void *cls, const GNUNET_HashCode * key, void *value) | |||
1153 | struct IteratorContext *ic = cls; | 1123 | struct IteratorContext *ic = cls; |
1154 | struct ValidationEntry *ve = value; | 1124 | struct ValidationEntry *ve = value; |
1155 | 1125 | ||
1156 | ic->cb (ic->cb_cls, &ve->public_key, &ve->pid, ve->valid_until, | 1126 | ic->cb (ic->cb_cls, &ve->public_key, ve->valid_until, |
1157 | ve->revalidation_block, ve->transport_name, ve->addr, ve->addrlen); | 1127 | ve->revalidation_block, ve->address); |
1158 | return GNUNET_OK; | 1128 | return GNUNET_OK; |
1159 | } | 1129 | } |
1160 | 1130 | ||
@@ -1186,25 +1156,20 @@ GST_validation_get_addresses (const struct GNUNET_PeerIdentity *target, | |||
1186 | * Based on this, the validation module will measure latency for the | 1156 | * Based on this, the validation module will measure latency for the |
1187 | * address more or less often. | 1157 | * address more or less often. |
1188 | * | 1158 | * |
1189 | * @param sender peer | 1159 | * @param sender peer FIXME: redundant! |
1190 | * @param plugin_name name of plugin | 1160 | * @param address the address |
1191 | * @param session session | ||
1192 | * @param sender_address address of the sender as known to the plugin, NULL | ||
1193 | * if we did not initiate the connection | ||
1194 | * @param sender_address_len number of bytes in sender_address | ||
1195 | * @param in_use GNUNET_YES if we are now using the address for a connection, | 1161 | * @param in_use GNUNET_YES if we are now using the address for a connection, |
1196 | * GNUNET_NO if we are no longer using the address for a connection | 1162 | * GNUNET_NO if we are no longer using the address for a connection |
1197 | */ | 1163 | */ |
1198 | void | 1164 | void |
1199 | GST_validation_set_address_use (const struct GNUNET_PeerIdentity *sender, | 1165 | GST_validation_set_address_use (const struct GNUNET_PeerIdentity *sender, |
1200 | const char *plugin_name, struct Session *session, | 1166 | const struct GNUNET_HELLO_Address *address, |
1201 | const void *sender_address, | 1167 | struct Session *session, |
1202 | size_t sender_address_len, | ||
1203 | int in_use) | 1168 | int in_use) |
1204 | { | 1169 | { |
1205 | struct ValidationEntry *ve; | 1170 | struct ValidationEntry *ve; |
1206 | 1171 | ||
1207 | ve = find_validation_entry (NULL, sender, plugin_name, sender_address, sender_address_len); | 1172 | ve = find_validation_entry (NULL, address); |
1208 | if (NULL == ve) | 1173 | if (NULL == ve) |
1209 | { | 1174 | { |
1210 | /* FIXME: this can happen for inbound connections (sender_address_len == 0); | 1175 | /* FIXME: this can happen for inbound connections (sender_address_len == 0); |
@@ -1231,23 +1196,19 @@ GST_validation_set_address_use (const struct GNUNET_PeerIdentity *sender, | |||
1231 | * address. | 1196 | * address. |
1232 | * | 1197 | * |
1233 | * @param sender peer | 1198 | * @param sender peer |
1234 | * @param plugin_name name of plugin | 1199 | * @param address the address |
1235 | * @param session session | 1200 | * @param session session |
1236 | * @param sender_address address of the sender as known to the plugin, NULL | ||
1237 | * if we did not initiate the connection | ||
1238 | * @param sender_address_len number of bytes in sender_address | ||
1239 | * @return observed latency of the address, FOREVER if the address was | 1201 | * @return observed latency of the address, FOREVER if the address was |
1240 | * never successfully validated | 1202 | * never successfully validated |
1241 | */ | 1203 | */ |
1242 | struct GNUNET_TIME_Relative | 1204 | struct GNUNET_TIME_Relative |
1243 | GST_validation_get_address_latency (const struct GNUNET_PeerIdentity *sender, | 1205 | GST_validation_get_address_latency (const struct GNUNET_PeerIdentity *sender, |
1244 | const char *plugin_name, struct Session *session, | 1206 | const struct GNUNET_HELLO_Address *address, |
1245 | const void *sender_address, | 1207 | struct Session *session) |
1246 | size_t sender_address_len) | ||
1247 | { | 1208 | { |
1248 | struct ValidationEntry *ve; | 1209 | struct ValidationEntry *ve; |
1249 | 1210 | ||
1250 | ve = find_validation_entry (NULL, sender, plugin_name, sender_address, sender_address_len); | 1211 | ve = find_validation_entry (NULL, address); |
1251 | if (NULL == ve) | 1212 | if (NULL == ve) |
1252 | return GNUNET_TIME_UNIT_FOREVER_REL; | 1213 | return GNUNET_TIME_UNIT_FOREVER_REL; |
1253 | return ve->latency; | 1214 | return ve->latency; |
diff --git a/src/transport/gnunet-service-transport_validation.h b/src/transport/gnunet-service-transport_validation.h index 2d93e508e..a3692e3cf 100644 --- a/src/transport/gnunet-service-transport_validation.h +++ b/src/transport/gnunet-service-transport_validation.h | |||
@@ -29,6 +29,7 @@ | |||
29 | #include "gnunet_statistics_service.h" | 29 | #include "gnunet_statistics_service.h" |
30 | #include "gnunet_transport_plugin.h" | 30 | #include "gnunet_transport_plugin.h" |
31 | #include "gnunet_util_lib.h" | 31 | #include "gnunet_util_lib.h" |
32 | #include "gnunet_hello_lib.h" | ||
32 | 33 | ||
33 | 34 | ||
34 | /** | 35 | /** |
@@ -50,20 +51,16 @@ GST_validation_stop (void); | |||
50 | * Based on this, the validation module will measure latency for the | 51 | * Based on this, the validation module will measure latency for the |
51 | * address more or less often. | 52 | * address more or less often. |
52 | * | 53 | * |
53 | * @param sender peer | 54 | * @param sender peer FIXME: redundant! |
54 | * @param plugin_name name of plugin | 55 | * @param address the address |
55 | * @param session session | 56 | * @param session session |
56 | * @param sender_address address of the sender as known to the plugin, NULL | ||
57 | * if we did not initiate the connection | ||
58 | * @param sender_address_len number of bytes in sender_address | ||
59 | * @param in_use GNUNET_YES if we are now using the address for a connection, | 57 | * @param in_use GNUNET_YES if we are now using the address for a connection, |
60 | * GNUNET_NO if we are no longer using the address for a connection | 58 | * GNUNET_NO if we are no longer using the address for a connection |
61 | */ | 59 | */ |
62 | void | 60 | void |
63 | GST_validation_set_address_use (const struct GNUNET_PeerIdentity *sender, | 61 | GST_validation_set_address_use (const struct GNUNET_PeerIdentity *sender, |
64 | const char *plugin_name, struct Session *session, | 62 | const struct GNUNET_HELLO_Address *address, |
65 | const void *sender_address, | 63 | struct Session *session, |
66 | size_t sender_address_len, | ||
67 | int in_use); | 64 | int in_use); |
68 | 65 | ||
69 | 66 | ||
@@ -72,19 +69,15 @@ GST_validation_set_address_use (const struct GNUNET_PeerIdentity *sender, | |||
72 | * address. | 69 | * address. |
73 | * | 70 | * |
74 | * @param sender peer | 71 | * @param sender peer |
75 | * @param plugin_name name of plugin | 72 | * @param address the address |
76 | * @param session session | 73 | * @param session session |
77 | * @param sender_address address of the sender as known to the plugin, NULL | ||
78 | * if we did not initiate the connection | ||
79 | * @param sender_address_len number of bytes in sender_address | ||
80 | * @return observed latency of the address, FOREVER if the address was | 74 | * @return observed latency of the address, FOREVER if the address was |
81 | * never successfully validated | 75 | * never successfully validated |
82 | */ | 76 | */ |
83 | struct GNUNET_TIME_Relative | 77 | struct GNUNET_TIME_Relative |
84 | GST_validation_get_address_latency (const struct GNUNET_PeerIdentity *sender, | 78 | GST_validation_get_address_latency (const struct GNUNET_PeerIdentity *sender, |
85 | const char *plugin_name, struct Session *session, | 79 | const struct GNUNET_HELLO_Address *address, |
86 | const void *sender_address, | 80 | struct Session *session); |
87 | size_t sender_address_len); | ||
88 | 81 | ||
89 | 82 | ||
90 | /** | 83 | /** |
@@ -92,18 +85,14 @@ GST_validation_get_address_latency (const struct GNUNET_PeerIdentity *sender, | |||
92 | * | 85 | * |
93 | * @param sender peer sending the PING | 86 | * @param sender peer sending the PING |
94 | * @param hdr the PING | 87 | * @param hdr the PING |
95 | * @param plugin_name name of plugin that received the PING | 88 | * @param sender_address address of the sender, NULL if we did not initiate |
96 | * @param session session we got the PING from | 89 | * @param session session we got the PING from |
97 | * @param sender_address address of the sender as known to the plugin, NULL | ||
98 | * if we did not initiate the connection | ||
99 | * @param sender_address_len number of bytes in sender_address | ||
100 | */ | 90 | */ |
101 | void | 91 | void |
102 | GST_validation_handle_ping (const struct GNUNET_PeerIdentity *sender, | 92 | GST_validation_handle_ping (const struct GNUNET_PeerIdentity *sender, |
103 | const struct GNUNET_MessageHeader *hdr, | 93 | const struct GNUNET_MessageHeader *hdr, |
104 | const char *plugin_name, struct Session *session, | 94 | const struct GNUNET_HELLO_Address *sender_address, |
105 | const void *sender_address, | 95 | struct Session *session); |
106 | size_t sender_address_len); | ||
107 | 96 | ||
108 | 97 | ||
109 | /** | 98 | /** |
@@ -134,29 +123,22 @@ GST_validation_handle_hello (const struct GNUNET_MessageHeader *hello); | |||
134 | * | 123 | * |
135 | * @param cls closure | 124 | * @param cls closure |
136 | * @param public_key public key for the peer, never NULL | 125 | * @param public_key public key for the peer, never NULL |
137 | * @param target peer this change is about, never NULL | ||
138 | * @param valid_until is ZERO if we never validated the address, | 126 | * @param valid_until is ZERO if we never validated the address, |
139 | * otherwise a time up to when we consider it (or was) valid | 127 | * otherwise a time up to when we consider it (or was) valid |
140 | * @param validation_block is FOREVER if the address is for an unsupported plugin (from PEERINFO) | 128 | * @param validation_block is FOREVER if the address is for an unsupported plugin (from PEERINFO) |
141 | * is ZERO if the address is considered valid (no validation needed) | 129 | * is ZERO if the address is considered valid (no validation needed) |
142 | * otherwise a time in the future if we're currently denying re-validation | 130 | * otherwise a time in the future if we're currently denying re-validation |
143 | * @param plugin_name name of the plugin | 131 | * @param address the address |
144 | * @param plugin_address binary address | ||
145 | * @param plugin_address_len length of address | ||
146 | */ | 132 | */ |
147 | typedef void (*GST_ValidationAddressCallback) (void *cls, | 133 | typedef void (*GST_ValidationAddressCallback) (void *cls, |
148 | const struct | 134 | const struct |
149 | GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded | 135 | GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded |
150 | * public_key, | 136 | * public_key, |
151 | const struct GNUNET_PeerIdentity | ||
152 | * target, | ||
153 | struct GNUNET_TIME_Absolute | 137 | struct GNUNET_TIME_Absolute |
154 | valid_until, | 138 | valid_until, |
155 | struct GNUNET_TIME_Absolute | 139 | struct GNUNET_TIME_Absolute |
156 | validation_block, | 140 | validation_block, |
157 | const char *plugin_name, | 141 | const struct GNUNET_HELLO_Address *address); |
158 | const void *plugin_address, | ||
159 | size_t plugin_address_len); | ||
160 | 142 | ||
161 | 143 | ||
162 | /** | 144 | /** |