diff options
author | Christian Grothoff <christian@grothoff.org> | 2015-02-02 22:25:48 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2015-02-02 22:25:48 +0000 |
commit | 69c3a52cfa679175da8f06bdcb8e2e4195465e44 (patch) | |
tree | 73109126cfcf1a807c5dc1e778f40b955fc959c5 /src/transport/gnunet-service-transport_neighbours.c | |
parent | c42deb089faffd654e27bf661ce85d5c1bb38b7a (diff) | |
download | gnunet-69c3a52cfa679175da8f06bdcb8e2e4195465e44.tar.gz gnunet-69c3a52cfa679175da8f06bdcb8e2e4195465e44.zip |
avoid passing both PeerIdentity and Address (which contains PeerIdentity) if address is always present as then this is redundant
Diffstat (limited to 'src/transport/gnunet-service-transport_neighbours.c')
-rw-r--r-- | src/transport/gnunet-service-transport_neighbours.c | 181 |
1 files changed, 92 insertions, 89 deletions
diff --git a/src/transport/gnunet-service-transport_neighbours.c b/src/transport/gnunet-service-transport_neighbours.c index 48bd8cdf8..8119d4cba 100644 --- a/src/transport/gnunet-service-transport_neighbours.c +++ b/src/transport/gnunet-service-transport_neighbours.c | |||
@@ -377,7 +377,7 @@ struct NeighbourMapEntry | |||
377 | /** | 377 | /** |
378 | * Time where we should cut the connection (timeout) if we don't | 378 | * Time where we should cut the connection (timeout) if we don't |
379 | * make progress in the state machine (or get a KEEPALIVE_RESPONSE | 379 | * make progress in the state machine (or get a KEEPALIVE_RESPONSE |
380 | * if we are in S_CONNECTED). | 380 | * if we are in #S_CONNECTED). |
381 | */ | 381 | */ |
382 | struct GNUNET_TIME_Absolute timeout; | 382 | struct GNUNET_TIME_Absolute timeout; |
383 | 383 | ||
@@ -418,7 +418,7 @@ struct NeighbourMapEntry | |||
418 | * (once we have an address to use and the peer has been allowed by our | 418 | * (once we have an address to use and the peer has been allowed by our |
419 | * blacklist). Initially set to #ACK_UNDEFINED. Set to #ACK_SEND_SYN_ACK | 419 | * blacklist). Initially set to #ACK_UNDEFINED. Set to #ACK_SEND_SYN_ACK |
420 | * if we need to send a SYN_ACK. Set to #ACK_SEND_ACK if we did | 420 | * if we need to send a SYN_ACK. Set to #ACK_SEND_ACK if we did |
421 | * send a SYN_ACK and should go to 'S_CONNECTED' upon receiving a | 421 | * send a SYN_ACK and should go to #S_CONNECTED upon receiving a |
422 | * 'ACK' (regardless of what our own state machine might say). | 422 | * 'ACK' (regardless of what our own state machine might say). |
423 | */ | 423 | */ |
424 | enum GST_ACK_State ack_state; | 424 | enum GST_ACK_State ack_state; |
@@ -659,18 +659,21 @@ free_address (struct NeighbourAddress *na) | |||
659 | * @param s the new state | 659 | * @param s the new state |
660 | */ | 660 | */ |
661 | static void | 661 | static void |
662 | set_state (struct NeighbourMapEntry *n, enum GNUNET_TRANSPORT_PeerState s) | 662 | set_state (struct NeighbourMapEntry *n, |
663 | enum GNUNET_TRANSPORT_PeerState s) | ||
663 | { | 664 | { |
664 | n->state = s; | 665 | n->state = s; |
665 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Neighbour `%s' changed state to %s\n", | 666 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
666 | GNUNET_i2s (&n->id), | 667 | "Neighbour `%s' changed state to %s\n", |
667 | GNUNET_TRANSPORT_ps2s(s)); | 668 | GNUNET_i2s (&n->id), |
669 | GNUNET_TRANSPORT_ps2s(s)); | ||
668 | neighbour_change_cb (callback_cls, | 670 | neighbour_change_cb (callback_cls, |
669 | &n->id, | 671 | &n->id, |
670 | n->primary_address.address, | 672 | n->primary_address.address, |
671 | n->state, n->timeout, | 673 | n->state, |
672 | n->primary_address.bandwidth_in, | 674 | n->timeout, |
673 | n->primary_address.bandwidth_out); | 675 | n->primary_address.bandwidth_in, |
676 | n->primary_address.bandwidth_out); | ||
674 | } | 677 | } |
675 | 678 | ||
676 | 679 | ||
@@ -683,21 +686,23 @@ set_state (struct NeighbourMapEntry *n, enum GNUNET_TRANSPORT_PeerState s) | |||
683 | */ | 686 | */ |
684 | static void | 687 | static void |
685 | set_state_and_timeout (struct NeighbourMapEntry *n, | 688 | set_state_and_timeout (struct NeighbourMapEntry *n, |
686 | enum GNUNET_TRANSPORT_PeerState s, | 689 | enum GNUNET_TRANSPORT_PeerState s, |
687 | struct GNUNET_TIME_Absolute timeout) | 690 | struct GNUNET_TIME_Absolute timeout) |
688 | { | 691 | { |
689 | n->state = s; | 692 | n->state = s; |
690 | n->timeout = timeout; | 693 | n->timeout = timeout; |
691 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Neighbour `%s' changed state to %s with timeout %s\n", | 694 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
692 | GNUNET_i2s (&n->id), | 695 | "Neighbour `%s' changed state to %s with timeout %s\n", |
693 | GNUNET_TRANSPORT_ps2s(s), | 696 | GNUNET_i2s (&n->id), |
694 | GNUNET_STRINGS_absolute_time_to_string (timeout)); | 697 | GNUNET_TRANSPORT_ps2s(s), |
698 | GNUNET_STRINGS_absolute_time_to_string (timeout)); | ||
695 | neighbour_change_cb (callback_cls, | 699 | neighbour_change_cb (callback_cls, |
696 | &n->id, | 700 | &n->id, |
697 | n->primary_address.address, | 701 | n->primary_address.address, |
698 | n->state, n->timeout, | 702 | n->state, |
699 | n->primary_address.bandwidth_in, | 703 | n->timeout, |
700 | n->primary_address.bandwidth_out); | 704 | n->primary_address.bandwidth_in, |
705 | n->primary_address.bandwidth_out); | ||
701 | } | 706 | } |
702 | 707 | ||
703 | 708 | ||
@@ -709,7 +714,7 @@ set_state_and_timeout (struct NeighbourMapEntry *n, | |||
709 | */ | 714 | */ |
710 | static void | 715 | static void |
711 | set_timeout (struct NeighbourMapEntry *n, | 716 | set_timeout (struct NeighbourMapEntry *n, |
712 | struct GNUNET_TIME_Absolute timeout) | 717 | struct GNUNET_TIME_Absolute timeout) |
713 | { | 718 | { |
714 | n->timeout = timeout; | 719 | n->timeout = timeout; |
715 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 720 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
@@ -717,11 +722,11 @@ set_timeout (struct NeighbourMapEntry *n, | |||
717 | GNUNET_i2s (&n->id), | 722 | GNUNET_i2s (&n->id), |
718 | GNUNET_STRINGS_absolute_time_to_string (timeout)); | 723 | GNUNET_STRINGS_absolute_time_to_string (timeout)); |
719 | neighbour_change_cb (callback_cls, | 724 | neighbour_change_cb (callback_cls, |
720 | &n->id, | 725 | &n->id, |
721 | n->primary_address.address, | 726 | n->primary_address.address, |
722 | n->state, n->timeout, | 727 | n->state, n->timeout, |
723 | n->primary_address.bandwidth_in, | 728 | n->primary_address.bandwidth_in, |
724 | n->primary_address.bandwidth_out); | 729 | n->primary_address.bandwidth_out); |
725 | } | 730 | } |
726 | 731 | ||
727 | 732 | ||
@@ -876,7 +881,8 @@ set_primary_address (struct NeighbourMapEntry *n, | |||
876 | neighbour_change_cb (callback_cls, | 881 | neighbour_change_cb (callback_cls, |
877 | &n->id, | 882 | &n->id, |
878 | n->primary_address.address, | 883 | n->primary_address.address, |
879 | n->state, n->timeout, | 884 | n->state, |
885 | n->timeout, | ||
880 | n->primary_address.bandwidth_in, | 886 | n->primary_address.bandwidth_in, |
881 | n->primary_address.bandwidth_out); | 887 | n->primary_address.bandwidth_out); |
882 | } | 888 | } |
@@ -891,16 +897,16 @@ set_primary_address (struct NeighbourMapEntry *n, | |||
891 | static void | 897 | static void |
892 | unset_primary_address (struct NeighbourMapEntry *n) | 898 | unset_primary_address (struct NeighbourMapEntry *n) |
893 | { | 899 | { |
894 | /* Unset primary address */ | 900 | /* Notify monitoring about change */ |
895 | free_address (&n->primary_address); | ||
896 | |||
897 | /* Notify monitoring about it */ | ||
898 | neighbour_change_cb (callback_cls, | 901 | neighbour_change_cb (callback_cls, |
899 | &n->id, | 902 | &n->id, |
900 | NULL, | 903 | n->primary_address.address, |
901 | n->state, n->timeout, | 904 | n->state, |
902 | n->primary_address.bandwidth_in, | 905 | n->timeout, |
903 | n->primary_address.bandwidth_out); | 906 | GNUNET_BANDWIDTH_value_init (0), |
907 | GNUNET_BANDWIDTH_value_init (0)); | ||
908 | /* Unset primary address */ | ||
909 | free_address (&n->primary_address); | ||
904 | } | 910 | } |
905 | 911 | ||
906 | 912 | ||
@@ -1048,8 +1054,9 @@ send_with_session (struct NeighbourMapEntry *n, | |||
1048 | cont, cont_cls)))) && | 1054 | cont, cont_cls)))) && |
1049 | (NULL != cont)) | 1055 | (NULL != cont)) |
1050 | cont (cont_cls, &n->id, GNUNET_SYSERR, msgbuf_size, 0); | 1056 | cont (cont_cls, &n->id, GNUNET_SYSERR, msgbuf_size, 0); |
1051 | GST_neighbours_notify_data_sent (&n->id, | 1057 | GST_neighbours_notify_data_sent (n->primary_address.address, |
1052 | n->primary_address.address, n->primary_address.session, msgbuf_size); | 1058 | n->primary_address.session, |
1059 | msgbuf_size); | ||
1053 | GNUNET_break (NULL != papi); | 1060 | GNUNET_break (NULL != papi); |
1054 | return result; | 1061 | return result; |
1055 | } | 1062 | } |
@@ -1841,8 +1848,7 @@ send_syn (struct NeighbourAddress *na) | |||
1841 | break; | 1848 | break; |
1842 | } | 1849 | } |
1843 | } | 1850 | } |
1844 | GST_neighbours_notify_data_sent (&na->address->peer, | 1851 | GST_neighbours_notify_data_sent (na->address, |
1845 | na->address, | ||
1846 | na->session, | 1852 | na->session, |
1847 | sizeof (struct TransportSynMessage)); | 1853 | sizeof (struct TransportSynMessage)); |
1848 | } | 1854 | } |
@@ -1901,8 +1907,8 @@ send_session_connect_ack_cont (void *cls, | |||
1901 | */ | 1907 | */ |
1902 | static void | 1908 | static void |
1903 | send_connect_ack_message (const struct GNUNET_HELLO_Address *address, | 1909 | send_connect_ack_message (const struct GNUNET_HELLO_Address *address, |
1904 | struct Session *session, | 1910 | struct Session *session, |
1905 | struct GNUNET_TIME_Absolute timestamp) | 1911 | struct GNUNET_TIME_Absolute timestamp) |
1906 | { | 1912 | { |
1907 | struct GNUNET_TRANSPORT_PluginFunctions *papi; | 1913 | struct GNUNET_TRANSPORT_PluginFunctions *papi; |
1908 | struct TransportSynMessage connect_msg; | 1914 | struct TransportSynMessage connect_msg; |
@@ -2738,7 +2744,6 @@ switch_address_bl_check_cont (void *cls, | |||
2738 | * Before accepting this addresses and actively using it, a blacklist check | 2744 | * Before accepting this addresses and actively using it, a blacklist check |
2739 | * is performed. If this blacklist check fails the address will be destroyed. | 2745 | * is performed. If this blacklist check fails the address will be destroyed. |
2740 | * | 2746 | * |
2741 | * @param peer identity of the peer to switch the address for | ||
2742 | * @param address address of the other peer, | 2747 | * @param address address of the other peer, |
2743 | * @param session session to use or NULL if transport should initiate a session | 2748 | * @param session session to use or NULL if transport should initiate a session |
2744 | * @param bandwidth_in inbound quota to be used when connection is up, | 2749 | * @param bandwidth_in inbound quota to be used when connection is up, |
@@ -2747,8 +2752,7 @@ switch_address_bl_check_cont (void *cls, | |||
2747 | * 0 to disconnect from peer | 2752 | * 0 to disconnect from peer |
2748 | */ | 2753 | */ |
2749 | void | 2754 | void |
2750 | GST_neighbours_switch_to_address (const struct GNUNET_PeerIdentity *peer, | 2755 | GST_neighbours_switch_to_address (const struct GNUNET_HELLO_Address *address, |
2751 | const struct GNUNET_HELLO_Address *address, | ||
2752 | struct Session *session, | 2756 | struct Session *session, |
2753 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, | 2757 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, |
2754 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out) | 2758 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out) |
@@ -2759,13 +2763,13 @@ GST_neighbours_switch_to_address (const struct GNUNET_PeerIdentity *peer, | |||
2759 | 2763 | ||
2760 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2764 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2761 | "ATS has decided on an address for peer %s\n", | 2765 | "ATS has decided on an address for peer %s\n", |
2762 | GNUNET_i2s (peer)); | 2766 | GNUNET_i2s (&address->peer)); |
2763 | GNUNET_assert (NULL != address->transport_name); | 2767 | GNUNET_assert (NULL != address->transport_name); |
2764 | if (NULL == (n = lookup_neighbour (peer))) | 2768 | if (NULL == (n = lookup_neighbour (&address->peer))) |
2765 | { | 2769 | { |
2766 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2770 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2767 | "Peer %s is unknown, suggestion ignored\n", | 2771 | "Peer %s is unknown, suggestion ignored\n", |
2768 | GNUNET_i2s (peer)); | 2772 | GNUNET_i2s (&address->peer)); |
2769 | return; | 2773 | return; |
2770 | } | 2774 | } |
2771 | 2775 | ||
@@ -2786,12 +2790,15 @@ GST_neighbours_switch_to_address (const struct GNUNET_PeerIdentity *peer, | |||
2786 | } | 2790 | } |
2787 | 2791 | ||
2788 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2792 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2789 | "ATS suggests %s address '%s' session %p for " | 2793 | "ATS suggests %s address '%s' session %p for " |
2790 | "peer `%s' in state %s/%s \n", | 2794 | "peer `%s' in state %s/%s \n", |
2791 | GNUNET_HELLO_address_check_option (address, | 2795 | GNUNET_HELLO_address_check_option (address, |
2792 | GNUNET_HELLO_ADDRESS_INFO_INBOUND) ? "inbound" : "outbound", | 2796 | GNUNET_HELLO_ADDRESS_INFO_INBOUND) ? "inbound" : "outbound", |
2793 | GST_plugins_a2s (address), session, GNUNET_i2s (peer), | 2797 | GST_plugins_a2s (address), |
2794 | GNUNET_TRANSPORT_ps2s (n->state), print_ack_state (n->ack_state)); | 2798 | session, |
2799 | GNUNET_i2s (&address->peer), | ||
2800 | GNUNET_TRANSPORT_ps2s (n->state), | ||
2801 | print_ack_state (n->ack_state)); | ||
2795 | 2802 | ||
2796 | /* Perform blacklist check */ | 2803 | /* Perform blacklist check */ |
2797 | blc_ctx = GNUNET_new (struct BlacklistCheckSwitchContext); | 2804 | blc_ctx = GNUNET_new (struct BlacklistCheckSwitchContext); |
@@ -2802,7 +2809,7 @@ GST_neighbours_switch_to_address (const struct GNUNET_PeerIdentity *peer, | |||
2802 | GNUNET_CONTAINER_DLL_insert (pending_bc_head, | 2809 | GNUNET_CONTAINER_DLL_insert (pending_bc_head, |
2803 | pending_bc_tail, | 2810 | pending_bc_tail, |
2804 | blc_ctx); | 2811 | blc_ctx); |
2805 | if (NULL != (blc = GST_blacklist_test_allowed (peer, | 2812 | if (NULL != (blc = GST_blacklist_test_allowed (&address->peer, |
2806 | address->transport_name, | 2813 | address->transport_name, |
2807 | &switch_address_bl_check_cont, | 2814 | &switch_address_bl_check_cont, |
2808 | blc_ctx))) | 2815 | blc_ctx))) |
@@ -2908,14 +2915,13 @@ utilization_transmission (void *cls, | |||
2908 | 2915 | ||
2909 | 2916 | ||
2910 | void | 2917 | void |
2911 | GST_neighbours_notify_data_recv (const struct GNUNET_PeerIdentity *peer, | 2918 | GST_neighbours_notify_data_recv (const struct GNUNET_HELLO_Address *address, |
2912 | const struct GNUNET_HELLO_Address *address, | ||
2913 | struct Session *session, | 2919 | struct Session *session, |
2914 | const struct GNUNET_MessageHeader *message) | 2920 | const struct GNUNET_MessageHeader *message) |
2915 | { | 2921 | { |
2916 | struct NeighbourMapEntry *n; | 2922 | struct NeighbourMapEntry *n; |
2917 | 2923 | ||
2918 | n = lookup_neighbour (peer); | 2924 | n = lookup_neighbour (&address->peer); |
2919 | if (NULL == n) | 2925 | if (NULL == n) |
2920 | return; | 2926 | return; |
2921 | n->util_total_bytes_recv += ntohs(message->size); | 2927 | n->util_total_bytes_recv += ntohs(message->size); |
@@ -2923,13 +2929,13 @@ GST_neighbours_notify_data_recv (const struct GNUNET_PeerIdentity *peer, | |||
2923 | 2929 | ||
2924 | 2930 | ||
2925 | void | 2931 | void |
2926 | GST_neighbours_notify_payload_recv (const struct GNUNET_PeerIdentity *peer, | 2932 | GST_neighbours_notify_payload_recv (const struct GNUNET_HELLO_Address *address, |
2927 | const struct GNUNET_HELLO_Address *address, | ||
2928 | struct Session *session, | 2933 | struct Session *session, |
2929 | const struct GNUNET_MessageHeader *message) | 2934 | const struct GNUNET_MessageHeader *message) |
2930 | { | 2935 | { |
2931 | struct NeighbourMapEntry *n; | 2936 | struct NeighbourMapEntry *n; |
2932 | n = lookup_neighbour (peer); | 2937 | |
2938 | n = lookup_neighbour (&address->peer); | ||
2933 | if (NULL == n) | 2939 | if (NULL == n) |
2934 | return; | 2940 | return; |
2935 | n->util_payload_bytes_recv += ntohs(message->size); | 2941 | n->util_payload_bytes_recv += ntohs(message->size); |
@@ -2937,13 +2943,13 @@ GST_neighbours_notify_payload_recv (const struct GNUNET_PeerIdentity *peer, | |||
2937 | 2943 | ||
2938 | 2944 | ||
2939 | void | 2945 | void |
2940 | GST_neighbours_notify_data_sent (const struct GNUNET_PeerIdentity *peer, | 2946 | GST_neighbours_notify_data_sent (const struct GNUNET_HELLO_Address *address, |
2941 | const struct GNUNET_HELLO_Address *address, | ||
2942 | struct Session *session, | 2947 | struct Session *session, |
2943 | size_t size) | 2948 | size_t size) |
2944 | { | 2949 | { |
2945 | struct NeighbourMapEntry *n; | 2950 | struct NeighbourMapEntry *n; |
2946 | n = lookup_neighbour (peer); | 2951 | |
2952 | n = lookup_neighbour (&address->peer); | ||
2947 | if (NULL == n) | 2953 | if (NULL == n) |
2948 | return; | 2954 | return; |
2949 | if (n->primary_address.session != session) | 2955 | if (n->primary_address.session != session) |
@@ -3154,9 +3160,8 @@ send_session_ack_message (struct NeighbourMapEntry *n) | |||
3154 | */ | 3160 | */ |
3155 | int | 3161 | int |
3156 | GST_neighbours_handle_session_syn_ack (const struct GNUNET_MessageHeader *message, | 3162 | GST_neighbours_handle_session_syn_ack (const struct GNUNET_MessageHeader *message, |
3157 | const struct GNUNET_PeerIdentity *peer, | 3163 | const struct GNUNET_HELLO_Address *address, |
3158 | const struct GNUNET_HELLO_Address *address, | 3164 | struct Session *session) |
3159 | struct Session *session) | ||
3160 | { | 3165 | { |
3161 | const struct TransportSynMessage *scm; | 3166 | const struct TransportSynMessage *scm; |
3162 | struct GNUNET_TIME_Absolute ts; | 3167 | struct GNUNET_TIME_Absolute ts; |
@@ -3164,7 +3169,7 @@ GST_neighbours_handle_session_syn_ack (const struct GNUNET_MessageHeader *messag | |||
3164 | 3169 | ||
3165 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 3170 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
3166 | "Received SYN_ACK message from peer `%s'\n", | 3171 | "Received SYN_ACK message from peer `%s'\n", |
3167 | GNUNET_i2s (peer)); | 3172 | GNUNET_i2s (&address->peer)); |
3168 | 3173 | ||
3169 | if (ntohs (message->size) != sizeof (struct TransportSynMessage)) | 3174 | if (ntohs (message->size) != sizeof (struct TransportSynMessage)) |
3170 | { | 3175 | { |
@@ -3177,7 +3182,7 @@ GST_neighbours_handle_session_syn_ack (const struct GNUNET_MessageHeader *messag | |||
3177 | 1, GNUNET_NO); | 3182 | 1, GNUNET_NO); |
3178 | scm = (const struct TransportSynMessage *) message; | 3183 | scm = (const struct TransportSynMessage *) message; |
3179 | GNUNET_break_op (ntohl (scm->reserved) == 0); | 3184 | GNUNET_break_op (ntohl (scm->reserved) == 0); |
3180 | if (NULL == (n = lookup_neighbour (peer))) | 3185 | if (NULL == (n = lookup_neighbour (&address->peer))) |
3181 | { | 3186 | { |
3182 | GNUNET_STATISTICS_update (GST_stats, | 3187 | GNUNET_STATISTICS_update (GST_stats, |
3183 | gettext_noop | 3188 | gettext_noop |
@@ -3211,7 +3216,8 @@ GST_neighbours_handle_session_syn_ack (const struct GNUNET_MessageHeader *messag | |||
3211 | gettext_noop ("# peers connected"), | 3216 | gettext_noop ("# peers connected"), |
3212 | ++neighbours_connected, | 3217 | ++neighbours_connected, |
3213 | GNUNET_NO); | 3218 | GNUNET_NO); |
3214 | connect_notify_cb (callback_cls, &n->id, | 3219 | connect_notify_cb (callback_cls, |
3220 | &n->id, | ||
3215 | n->primary_address.bandwidth_in, | 3221 | n->primary_address.bandwidth_in, |
3216 | n->primary_address.bandwidth_out); | 3222 | n->primary_address.bandwidth_out); |
3217 | /* Tell ATS that the outbound session we created to send SYN was successful */ | 3223 | /* Tell ATS that the outbound session we created to send SYN was successful */ |
@@ -3433,15 +3439,12 @@ GST_neighbours_session_terminated (const struct GNUNET_PeerIdentity *peer, | |||
3433 | * connected. Otherwise, do nothing. | 3439 | * connected. Otherwise, do nothing. |
3434 | * | 3440 | * |
3435 | * @param message possibly a 'struct SessionConnectMessage' (check format) | 3441 | * @param message possibly a 'struct SessionConnectMessage' (check format) |
3436 | * @param peer identity of the peer to switch the address for | 3442 | * @param address address of the other peer |
3437 | * @param address address of the other peer, NULL if other peer | ||
3438 | * connected to us | ||
3439 | * @param session session to use (or NULL) | 3443 | * @param session session to use (or NULL) |
3440 | * @return #GNUNET_OK if the message was fine, #GNUNET_SYSERR on serious error | 3444 | * @return #GNUNET_OK if the message was fine, #GNUNET_SYSERR on serious error |
3441 | */ | 3445 | */ |
3442 | int | 3446 | int |
3443 | GST_neighbours_handle_session_ack (const struct GNUNET_MessageHeader *message, | 3447 | GST_neighbours_handle_session_ack (const struct GNUNET_MessageHeader *message, |
3444 | const struct GNUNET_PeerIdentity *peer, | ||
3445 | const struct GNUNET_HELLO_Address *address, | 3448 | const struct GNUNET_HELLO_Address *address, |
3446 | struct Session *session) | 3449 | struct Session *session) |
3447 | { | 3450 | { |
@@ -3449,7 +3452,7 @@ GST_neighbours_handle_session_ack (const struct GNUNET_MessageHeader *message, | |||
3449 | 3452 | ||
3450 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 3453 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
3451 | "Received ACK message from peer `%s'\n", | 3454 | "Received ACK message from peer `%s'\n", |
3452 | GNUNET_i2s (peer)); | 3455 | GNUNET_i2s (&address->peer)); |
3453 | if (ntohs (message->size) != sizeof (struct GNUNET_MessageHeader)) | 3456 | if (ntohs (message->size) != sizeof (struct GNUNET_MessageHeader)) |
3454 | { | 3457 | { |
3455 | GNUNET_break_op (0); | 3458 | GNUNET_break_op (0); |
@@ -3459,7 +3462,7 @@ GST_neighbours_handle_session_ack (const struct GNUNET_MessageHeader *message, | |||
3459 | gettext_noop | 3462 | gettext_noop |
3460 | ("# ACK messages received"), | 3463 | ("# ACK messages received"), |
3461 | 1, GNUNET_NO); | 3464 | 1, GNUNET_NO); |
3462 | if (NULL == (n = lookup_neighbour (peer))) | 3465 | if (NULL == (n = lookup_neighbour (&address->peer))) |
3463 | { | 3466 | { |
3464 | GNUNET_break_op (0); | 3467 | GNUNET_break_op (0); |
3465 | return GNUNET_SYSERR; | 3468 | return GNUNET_SYSERR; |
@@ -3468,7 +3471,7 @@ GST_neighbours_handle_session_ack (const struct GNUNET_MessageHeader *message, | |||
3468 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 3471 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
3469 | "Received %s for peer `%s' in state %s/%s\n", | 3472 | "Received %s for peer `%s' in state %s/%s\n", |
3470 | "ACK", | 3473 | "ACK", |
3471 | GNUNET_i2s (peer), | 3474 | GNUNET_i2s (&address->peer), |
3472 | GNUNET_TRANSPORT_ps2s (n->state), | 3475 | GNUNET_TRANSPORT_ps2s (n->state), |
3473 | print_ack_state (n->ack_state)); | 3476 | print_ack_state (n->ack_state)); |
3474 | 3477 | ||
@@ -3488,7 +3491,7 @@ GST_neighbours_handle_session_ack (const struct GNUNET_MessageHeader *message, | |||
3488 | { | 3491 | { |
3489 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 3492 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
3490 | "Received unexpected ACK message from peer `%s' in state %s/%s\n", | 3493 | "Received unexpected ACK message from peer `%s' in state %s/%s\n", |
3491 | GNUNET_i2s (peer), | 3494 | GNUNET_i2s (&address->peer), |
3492 | GNUNET_TRANSPORT_ps2s (n->state), | 3495 | GNUNET_TRANSPORT_ps2s (n->state), |
3493 | print_ack_state (n->ack_state)); | 3496 | print_ack_state (n->ack_state)); |
3494 | 3497 | ||
@@ -3502,14 +3505,14 @@ GST_neighbours_handle_session_ack (const struct GNUNET_MessageHeader *message, | |||
3502 | if (GNUNET_NO == GST_neighbours_test_connected(&n->id)) | 3505 | if (GNUNET_NO == GST_neighbours_test_connected(&n->id)) |
3503 | { | 3506 | { |
3504 | /* Notify about connection */ | 3507 | /* Notify about connection */ |
3505 | connect_notify_cb (callback_cls, &n->id, | 3508 | connect_notify_cb (callback_cls, |
3506 | n->primary_address.bandwidth_in, | 3509 | &n->id, |
3507 | n->primary_address.bandwidth_out);\ | 3510 | n->primary_address.bandwidth_in, |
3508 | 3511 | n->primary_address.bandwidth_out); | |
3509 | GNUNET_STATISTICS_set (GST_stats, | 3512 | GNUNET_STATISTICS_set (GST_stats, |
3510 | gettext_noop ("# peers connected"), | 3513 | gettext_noop ("# peers connected"), |
3511 | ++neighbours_connected, | 3514 | ++neighbours_connected, |
3512 | GNUNET_NO); | 3515 | GNUNET_NO); |
3513 | } | 3516 | } |
3514 | 3517 | ||
3515 | if (GNUNET_TRANSPORT_PS_SWITCH_SYN_SENT == n->state) | 3518 | if (GNUNET_TRANSPORT_PS_SWITCH_SYN_SENT == n->state) |
@@ -3673,7 +3676,7 @@ GST_neighbours_handle_disconnect_message (const struct GNUNET_PeerIdentity *peer | |||
3673 | 3676 | ||
3674 | 3677 | ||
3675 | /** | 3678 | /** |
3676 | * Closure for the neighbours_iterate function. | 3679 | * Closure for the #neighbours_iterate() function. |
3677 | */ | 3680 | */ |
3678 | struct IteratorContext | 3681 | struct IteratorContext |
3679 | { | 3682 | { |
@@ -3683,7 +3686,7 @@ struct IteratorContext | |||
3683 | GST_NeighbourIterator cb; | 3686 | GST_NeighbourIterator cb; |
3684 | 3687 | ||
3685 | /** | 3688 | /** |
3686 | * Closure for 'cb'. | 3689 | * Closure for @e cb. |
3687 | */ | 3690 | */ |
3688 | void *cb_cls; | 3691 | void *cb_cls; |
3689 | }; | 3692 | }; |