diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2014-03-26 14:16:41 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2014-03-26 14:16:41 +0000 |
commit | c62fc947fac80856859ee2969616285d40c4682c (patch) | |
tree | 7c7c0d1bf2f630762fecfdb81c745b10a8eda0a2 /src/transport/gnunet-service-transport_neighbours.c | |
parent | b3ae4a7b2968d55786feb9e2e75f38d700ecc42f (diff) | |
download | gnunet-c62fc947fac80856859ee2969616285d40c4682c.tar.gz gnunet-c62fc947fac80856859ee2969616285d40c4682c.zip |
removing GNUNET_TRANSPORT_PS_CONNECT_RECV_BLACKLIST state
Diffstat (limited to 'src/transport/gnunet-service-transport_neighbours.c')
-rw-r--r-- | src/transport/gnunet-service-transport_neighbours.c | 94 |
1 files changed, 28 insertions, 66 deletions
diff --git a/src/transport/gnunet-service-transport_neighbours.c b/src/transport/gnunet-service-transport_neighbours.c index af1c4372e..527c99ab5 100644 --- a/src/transport/gnunet-service-transport_neighbours.c +++ b/src/transport/gnunet-service-transport_neighbours.c | |||
@@ -1096,7 +1096,6 @@ disconnect_neighbour (struct NeighbourMapEntry *n) | |||
1096 | set_state (n, GNUNET_TRANSPORT_PS_DISCONNECT); | 1096 | set_state (n, GNUNET_TRANSPORT_PS_DISCONNECT); |
1097 | break; | 1097 | break; |
1098 | case GNUNET_TRANSPORT_PS_CONNECT_RECV_ATS: | 1098 | case GNUNET_TRANSPORT_PS_CONNECT_RECV_ATS: |
1099 | case GNUNET_TRANSPORT_PS_CONNECT_RECV_BLACKLIST: | ||
1100 | /* we never ACK'ed the other peer's request, no need to send DISCONNECT */ | 1099 | /* we never ACK'ed the other peer's request, no need to send DISCONNECT */ |
1101 | set_state (n, GNUNET_TRANSPORT_PS_DISCONNECT_FINISHED); | 1100 | set_state (n, GNUNET_TRANSPORT_PS_DISCONNECT_FINISHED); |
1102 | free_neighbour (n, GNUNET_NO); | 1101 | free_neighbour (n, GNUNET_NO); |
@@ -1790,7 +1789,7 @@ send_session_connect_ack_cont (void *cls, | |||
1790 | 1789 | ||
1791 | /* Remove address and request and additional one */ | 1790 | /* Remove address and request and additional one */ |
1792 | unset_primary_address (n); | 1791 | unset_primary_address (n); |
1793 | 1792 | n->ack_state = ACK_SEND_CONNECT_ACK; | |
1794 | set_state_and_timeout (n, GNUNET_TRANSPORT_PS_CONNECT_RECV_ATS, | 1793 | set_state_and_timeout (n, GNUNET_TRANSPORT_PS_CONNECT_RECV_ATS, |
1795 | GNUNET_TIME_relative_to_absolute (ATS_RESPONSE_TIMEOUT)); | 1794 | GNUNET_TIME_relative_to_absolute (ATS_RESPONSE_TIMEOUT)); |
1796 | return; | 1795 | return; |
@@ -1867,6 +1866,7 @@ send_connect_ack_message (const struct GNUNET_HELLO_Address *address, | |||
1867 | 1866 | ||
1868 | /* Remove address and request and additional one */ | 1867 | /* Remove address and request and additional one */ |
1869 | unset_primary_address (n); | 1868 | unset_primary_address (n); |
1869 | n->ack_state = ACK_SEND_CONNECT_ACK; | ||
1870 | set_state_and_timeout (n, GNUNET_TRANSPORT_PS_CONNECT_RECV_ATS, | 1870 | set_state_and_timeout (n, GNUNET_TRANSPORT_PS_CONNECT_RECV_ATS, |
1871 | GNUNET_TIME_relative_to_absolute (ATS_RESPONSE_TIMEOUT)); | 1871 | GNUNET_TIME_relative_to_absolute (ATS_RESPONSE_TIMEOUT)); |
1872 | return; | 1872 | return; |
@@ -2203,7 +2203,6 @@ GST_neighbours_try_connect (const struct GNUNET_PeerIdentity *target) | |||
2203 | case GNUNET_TRANSPORT_PS_INIT_ATS: | 2203 | case GNUNET_TRANSPORT_PS_INIT_ATS: |
2204 | case GNUNET_TRANSPORT_PS_CONNECT_SENT: | 2204 | case GNUNET_TRANSPORT_PS_CONNECT_SENT: |
2205 | case GNUNET_TRANSPORT_PS_CONNECT_RECV_ATS: | 2205 | case GNUNET_TRANSPORT_PS_CONNECT_RECV_ATS: |
2206 | case GNUNET_TRANSPORT_PS_CONNECT_RECV_BLACKLIST: | ||
2207 | case GNUNET_TRANSPORT_PS_CONNECT_RECV_ACK: | 2206 | case GNUNET_TRANSPORT_PS_CONNECT_RECV_ACK: |
2208 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 2207 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
2209 | "Ignoring request to try to connect to `%s', already trying!\n", | 2208 | "Ignoring request to try to connect to `%s', already trying!\n", |
@@ -2328,42 +2327,6 @@ handle_connect_blacklist_check_cont (void *cls, | |||
2328 | case GNUNET_TRANSPORT_PS_CONNECT_RECV_ATS: | 2327 | case GNUNET_TRANSPORT_PS_CONNECT_RECV_ATS: |
2329 | /* waiting on ATS suggestion, don't care about blacklist */ | 2328 | /* waiting on ATS suggestion, don't care about blacklist */ |
2330 | break; | 2329 | break; |
2331 | case GNUNET_TRANSPORT_PS_CONNECT_RECV_BLACKLIST: | ||
2332 | if (GNUNET_YES != address_matches (&bcc->na, &n->primary_address)) | ||
2333 | { | ||
2334 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
2335 | "Blacklist result ignored, as it is not for our primary address\n"); | ||
2336 | break; /* result for an address we currently don't care about */ | ||
2337 | } | ||
2338 | if (GNUNET_OK == result) | ||
2339 | { | ||
2340 | set_state_and_timeout (n, GNUNET_TRANSPORT_PS_CONNECT_RECV_ACK, | ||
2341 | GNUNET_TIME_relative_to_absolute (SETUP_CONNECTION_TIMEOUT)); | ||
2342 | send_connect_ack_message (bcc->na.address, | ||
2343 | bcc->na.session, | ||
2344 | n->connect_ack_timestamp); | ||
2345 | if (ACK_SEND_CONNECT_ACK == n->ack_state) | ||
2346 | n->ack_state = ACK_SEND_SESSION_ACK; | ||
2347 | } | ||
2348 | else | ||
2349 | { | ||
2350 | struct GNUNET_TRANSPORT_PluginFunctions *plugin; | ||
2351 | |||
2352 | plugin = GST_plugins_find (bcc->na.address->transport_name); | ||
2353 | if ( (NULL != plugin) && | ||
2354 | (NULL != bcc->na.session) ) | ||
2355 | { | ||
2356 | plugin->disconnect_session (plugin->cls, | ||
2357 | bcc->na.session); | ||
2358 | break; | ||
2359 | } | ||
2360 | GNUNET_break (NULL != plugin); | ||
2361 | free_address (&n->primary_address); | ||
2362 | set_state_and_timeout (n, GNUNET_TRANSPORT_PS_INIT_ATS, | ||
2363 | GNUNET_TIME_relative_to_absolute (ATS_RESPONSE_TIMEOUT)); | ||
2364 | GNUNET_ATS_reset_backoff (GST_ats, peer); | ||
2365 | } | ||
2366 | break; | ||
2367 | case GNUNET_TRANSPORT_PS_CONNECT_RECV_ACK: | 2330 | case GNUNET_TRANSPORT_PS_CONNECT_RECV_ACK: |
2368 | /* waiting on SESSION_ACK, send ACK if one is pending */ | 2331 | /* waiting on SESSION_ACK, send ACK if one is pending */ |
2369 | if ( (GNUNET_OK == result) && | 2332 | if ( (GNUNET_OK == result) && |
@@ -2587,7 +2550,6 @@ GST_neighbours_handle_connect (const struct GNUNET_MessageHeader *message, | |||
2587 | break; | 2550 | break; |
2588 | case GNUNET_TRANSPORT_PS_CONNECT_SENT: | 2551 | case GNUNET_TRANSPORT_PS_CONNECT_SENT: |
2589 | case GNUNET_TRANSPORT_PS_CONNECT_RECV_ATS: | 2552 | case GNUNET_TRANSPORT_PS_CONNECT_RECV_ATS: |
2590 | case GNUNET_TRANSPORT_PS_CONNECT_RECV_BLACKLIST: | ||
2591 | case GNUNET_TRANSPORT_PS_CONNECT_RECV_ACK: | 2553 | case GNUNET_TRANSPORT_PS_CONNECT_RECV_ACK: |
2592 | /* It can never hurt to have an alternative address in the above cases, | 2554 | /* It can never hurt to have an alternative address in the above cases, |
2593 | see if it is allowed */ | 2555 | see if it is allowed */ |
@@ -2753,8 +2715,7 @@ switch_address_bl_check_cont (void *cls, | |||
2753 | { | 2715 | { |
2754 | n->ack_state = ACK_SEND_SESSION_ACK; | 2716 | n->ack_state = ACK_SEND_SESSION_ACK; |
2755 | send_connect_ack_message (n->primary_address.address, | 2717 | send_connect_ack_message (n->primary_address.address, |
2756 | n->primary_address.session, | 2718 | n->primary_address.session, n->connect_ack_timestamp); |
2757 | n->connect_ack_timestamp); | ||
2758 | } | 2719 | } |
2759 | /* ATS suggests a different address, switch again */ | 2720 | /* ATS suggests a different address, switch again */ |
2760 | set_primary_address (n, blc_ctx->address, blc_ctx->session, | 2721 | set_primary_address (n, blc_ctx->address, blc_ctx->session, |
@@ -2776,18 +2737,20 @@ switch_address_bl_check_cont (void *cls, | |||
2776 | n->connect_ack_timestamp); | 2737 | n->connect_ack_timestamp); |
2777 | if (ACK_SEND_CONNECT_ACK == n->ack_state) | 2738 | if (ACK_SEND_CONNECT_ACK == n->ack_state) |
2778 | n->ack_state = ACK_SEND_SESSION_ACK; | 2739 | n->ack_state = ACK_SEND_SESSION_ACK; |
2779 | |||
2780 | break; | 2740 | break; |
2781 | case GNUNET_TRANSPORT_PS_CONNECT_RECV_BLACKLIST: | ||
2782 | case GNUNET_TRANSPORT_PS_CONNECT_RECV_ACK: | 2741 | case GNUNET_TRANSPORT_PS_CONNECT_RECV_ACK: |
2783 | /* ATS asks us to switch while we were trying to connect; switch to new | 2742 | /* ATS asks us to switch while we were trying to connect; switch to new |
2784 | address and check blacklist again */ | 2743 | address and check blacklist again */ |
2785 | set_primary_address (n, blc_ctx->address, blc_ctx->session, | 2744 | set_primary_address (n, blc_ctx->address, blc_ctx->session, |
2786 | blc_ctx->bandwidth_in, blc_ctx->bandwidth_out, GNUNET_NO); | 2745 | blc_ctx->bandwidth_in, blc_ctx->bandwidth_out, GNUNET_NO); |
2787 | set_state_and_timeout (n, GNUNET_TRANSPORT_PS_CONNECT_RECV_BLACKLIST, | 2746 | set_state_and_timeout (n, GNUNET_TRANSPORT_PS_CONNECT_RECV_ACK, |
2788 | GNUNET_TIME_relative_to_absolute (BLACKLIST_RESPONSE_TIMEOUT)); | 2747 | GNUNET_TIME_relative_to_absolute (SETUP_CONNECTION_TIMEOUT)); |
2789 | /* REMOVE */ connect_check_blacklist (&n->id, n->connect_ack_timestamp, | 2748 | if ( (ACK_SEND_CONNECT_ACK == n->ack_state) ) |
2790 | blc_ctx->address, blc_ctx->session); | 2749 | { |
2750 | n->ack_state = ACK_SEND_SESSION_ACK; | ||
2751 | send_connect_ack_message (n->primary_address.address, | ||
2752 | n->primary_address.session, n->connect_ack_timestamp); | ||
2753 | } | ||
2791 | break; | 2754 | break; |
2792 | case GNUNET_TRANSPORT_PS_CONNECTED: | 2755 | case GNUNET_TRANSPORT_PS_CONNECTED: |
2793 | GNUNET_assert (NULL != n->primary_address.address); | 2756 | GNUNET_assert (NULL != n->primary_address.address); |
@@ -3195,16 +3158,6 @@ master_task (void *cls, | |||
3195 | return; | 3158 | return; |
3196 | } | 3159 | } |
3197 | break; | 3160 | break; |
3198 | case GNUNET_TRANSPORT_PS_CONNECT_RECV_BLACKLIST: | ||
3199 | if (0 == delay.rel_value_us) | ||
3200 | { | ||
3201 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
3202 | "Connection to `%s' timed out waiting BLACKLIST to approve address to use for CONNECT_ACK\n", | ||
3203 | GNUNET_i2s (&n->id)); | ||
3204 | free_neighbour (n, GNUNET_NO); | ||
3205 | return; | ||
3206 | } | ||
3207 | break; | ||
3208 | case GNUNET_TRANSPORT_PS_CONNECT_RECV_ACK: | 3161 | case GNUNET_TRANSPORT_PS_CONNECT_RECV_ACK: |
3209 | if (0 == delay.rel_value_us) | 3162 | if (0 == delay.rel_value_us) |
3210 | { | 3163 | { |
@@ -3421,7 +3374,6 @@ GST_neighbours_handle_connect_ack (const struct GNUNET_MessageHeader *message, | |||
3421 | send_session_ack_message (n); | 3374 | send_session_ack_message (n); |
3422 | break; | 3375 | break; |
3423 | case GNUNET_TRANSPORT_PS_CONNECT_RECV_ATS: | 3376 | case GNUNET_TRANSPORT_PS_CONNECT_RECV_ATS: |
3424 | case GNUNET_TRANSPORT_PS_CONNECT_RECV_BLACKLIST: | ||
3425 | case GNUNET_TRANSPORT_PS_CONNECT_RECV_ACK: | 3377 | case GNUNET_TRANSPORT_PS_CONNECT_RECV_ACK: |
3426 | GNUNET_STATISTICS_update (GST_stats, | 3378 | GNUNET_STATISTICS_update (GST_stats, |
3427 | gettext_noop | 3379 | gettext_noop |
@@ -3561,7 +3513,6 @@ GST_neighbours_session_terminated (const struct GNUNET_PeerIdentity *peer, | |||
3561 | GNUNET_TIME_relative_to_absolute (ATS_RESPONSE_TIMEOUT)); | 3513 | GNUNET_TIME_relative_to_absolute (ATS_RESPONSE_TIMEOUT)); |
3562 | break; | 3514 | break; |
3563 | case GNUNET_TRANSPORT_PS_CONNECT_RECV_ATS: | 3515 | case GNUNET_TRANSPORT_PS_CONNECT_RECV_ATS: |
3564 | case GNUNET_TRANSPORT_PS_CONNECT_RECV_BLACKLIST: | ||
3565 | case GNUNET_TRANSPORT_PS_CONNECT_RECV_ACK: | 3516 | case GNUNET_TRANSPORT_PS_CONNECT_RECV_ACK: |
3566 | /* error on inbound session; free neighbour entirely */ | 3517 | /* error on inbound session; free neighbour entirely */ |
3567 | free_address (&n->primary_address); | 3518 | free_address (&n->primary_address); |
@@ -3656,10 +3607,16 @@ GST_neighbours_handle_session_ack (const struct GNUNET_MessageHeader *message, | |||
3656 | } | 3607 | } |
3657 | /* check if we are in a plausible state for having sent | 3608 | /* check if we are in a plausible state for having sent |
3658 | a CONNECT_ACK. If not, return, otherwise break */ | 3609 | a CONNECT_ACK. If not, return, otherwise break */ |
3659 | if ( ( (GNUNET_TRANSPORT_PS_CONNECT_RECV_ACK != n->state) && | 3610 | |
3611 | /* TODO I have no idea we we should state GNUNET_TRANSPORT_PS_CONNECT_SENT | ||
3612 | * Perhaps SWITCHING? Have to check */ | ||
3613 | if ( /*(*/ (GNUNET_TRANSPORT_PS_CONNECT_RECV_ACK != n->state) /* && | ||
3660 | (GNUNET_TRANSPORT_PS_CONNECT_SENT != n->state) ) || | 3614 | (GNUNET_TRANSPORT_PS_CONNECT_SENT != n->state) ) || |
3661 | (ACK_SEND_SESSION_ACK != n->ack_state) ) | 3615 | (ACK_SEND_SESSION_ACK != n->ack_state) */) |
3662 | { | 3616 | { |
3617 | if (GNUNET_TRANSPORT_PS_CONNECT_SENT != n->state) | ||
3618 | GNUNET_break (0); /* TESTING */ | ||
3619 | |||
3663 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 3620 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
3664 | "Received SESSION_ACK message from peer `%s' in state %s/%s\n", | 3621 | "Received SESSION_ACK message from peer `%s' in state %s/%s\n", |
3665 | GNUNET_i2s (peer), | 3622 | GNUNET_i2s (peer), |
@@ -3670,18 +3627,24 @@ GST_neighbours_handle_session_ack (const struct GNUNET_MessageHeader *message, | |||
3670 | GNUNET_NO); | 3627 | GNUNET_NO); |
3671 | return GNUNET_OK; | 3628 | return GNUNET_OK; |
3672 | } | 3629 | } |
3630 | /* We are connected */ | ||
3673 | set_state_and_timeout (n, GNUNET_TRANSPORT_PS_CONNECTED, GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT)); | 3631 | set_state_and_timeout (n, GNUNET_TRANSPORT_PS_CONNECTED, GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT)); |
3674 | GNUNET_STATISTICS_set (GST_stats, | 3632 | GNUNET_STATISTICS_set (GST_stats, |
3675 | gettext_noop ("# peers connected"), | 3633 | gettext_noop ("# peers connected"), |
3676 | ++neighbours_connected, | 3634 | ++neighbours_connected, |
3677 | GNUNET_NO); | 3635 | GNUNET_NO); |
3636 | |||
3637 | /* Notify about connection */ | ||
3678 | connect_notify_cb (callback_cls, &n->id, | 3638 | connect_notify_cb (callback_cls, &n->id, |
3679 | n->primary_address.bandwidth_in, | 3639 | n->primary_address.bandwidth_in, |
3680 | n->primary_address.bandwidth_out); | 3640 | n->primary_address.bandwidth_out); |
3681 | 3641 | ||
3682 | GST_ats_add_address (n->primary_address.address, | 3642 | /* Add session to ATS since no session was given (NULL) and we may have |
3683 | n->primary_address.session, | 3643 | * obtained a new session */ |
3684 | NULL, 0); | 3644 | GST_ats_add_address (n->primary_address.address, n->primary_address.session, |
3645 | NULL, 0); | ||
3646 | |||
3647 | /* Set primary address to used */ | ||
3685 | set_primary_address (n, | 3648 | set_primary_address (n, |
3686 | n->primary_address.address, | 3649 | n->primary_address.address, |
3687 | n->primary_address.session, | 3650 | n->primary_address.session, |
@@ -3949,7 +3912,6 @@ GST_neighbour_get_latency (const struct GNUNET_PeerIdentity *peer) | |||
3949 | case GNUNET_TRANSPORT_PS_NOT_CONNECTED: | 3912 | case GNUNET_TRANSPORT_PS_NOT_CONNECTED: |
3950 | case GNUNET_TRANSPORT_PS_INIT_ATS: | 3913 | case GNUNET_TRANSPORT_PS_INIT_ATS: |
3951 | case GNUNET_TRANSPORT_PS_CONNECT_RECV_ATS: | 3914 | case GNUNET_TRANSPORT_PS_CONNECT_RECV_ATS: |
3952 | case GNUNET_TRANSPORT_PS_CONNECT_RECV_BLACKLIST: | ||
3953 | case GNUNET_TRANSPORT_PS_CONNECT_RECV_ACK: | 3915 | case GNUNET_TRANSPORT_PS_CONNECT_RECV_ACK: |
3954 | case GNUNET_TRANSPORT_PS_CONNECT_SENT: | 3916 | case GNUNET_TRANSPORT_PS_CONNECT_SENT: |
3955 | case GNUNET_TRANSPORT_PS_DISCONNECT: | 3917 | case GNUNET_TRANSPORT_PS_DISCONNECT: |