diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2014-02-12 06:39:22 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2014-02-12 06:39:22 +0000 |
commit | 4ba1042bb27cde309c059841b94aac6b2353fe21 (patch) | |
tree | 8d7f452f370b4127b6f242342a64d143df24ad9b /src | |
parent | b4d236b4174317bafc62d697a4801d64203a1a4c (diff) | |
download | gnunet-4ba1042bb27cde309c059841b94aac6b2353fe21.tar.gz gnunet-4ba1042bb27cde309c059841b94aac6b2353fe21.zip |
Continue with address suggestion after try connect black list check
Related to moving blacklist check before address switching as described in
mantis #3262
Diffstat (limited to 'src')
-rw-r--r-- | src/transport/gnunet-service-transport_neighbours.c | 38 |
1 files changed, 28 insertions, 10 deletions
diff --git a/src/transport/gnunet-service-transport_neighbours.c b/src/transport/gnunet-service-transport_neighbours.c index 42ff650c1..cfeadc9d6 100644 --- a/src/transport/gnunet-service-transport_neighbours.c +++ b/src/transport/gnunet-service-transport_neighbours.c | |||
@@ -1915,6 +1915,9 @@ address_matches (const struct NeighbourAddress *a1, | |||
1915 | } | 1915 | } |
1916 | 1916 | ||
1917 | 1917 | ||
1918 | /* We received a address suggestion after requesting an address in | ||
1919 | * try_connect or after receiving a connect, switch to address | ||
1920 | */ | ||
1918 | static void | 1921 | static void |
1919 | address_suggest_cont (void *cls, | 1922 | address_suggest_cont (void *cls, |
1920 | const struct GNUNET_PeerIdentity *peer, | 1923 | const struct GNUNET_PeerIdentity *peer, |
@@ -1923,7 +1926,8 @@ address_suggest_cont (void *cls, | |||
1923 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, | 1926 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, |
1924 | const struct GNUNET_ATS_Information *ats, uint32_t ats_count) | 1927 | const struct GNUNET_ATS_Information *ats, uint32_t ats_count) |
1925 | { | 1928 | { |
1926 | 1929 | GST_neighbours_switch_to_address(peer, address, session, ats, ats_count, | |
1930 | bandwidth_in, bandwidth_out); | ||
1927 | } | 1931 | } |
1928 | 1932 | ||
1929 | 1933 | ||
@@ -1944,7 +1948,14 @@ struct BlacklistCheckSwitchContext | |||
1944 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out; | 1948 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out; |
1945 | }; | 1949 | }; |
1946 | 1950 | ||
1947 | 1951 | /** | |
1952 | * Black list check result for try_connect call | ||
1953 | * If connection to the peer is allowed request adddress and | ||
1954 | * | ||
1955 | * @param cls blc_ctx bl context | ||
1956 | * @param peer the peer | ||
1957 | * @param result the result | ||
1958 | */ | ||
1948 | static void | 1959 | static void |
1949 | try_connect_bl_check_cont (void *cls, | 1960 | try_connect_bl_check_cont (void *cls, |
1950 | const struct GNUNET_PeerIdentity *peer, int result) | 1961 | const struct GNUNET_PeerIdentity *peer, int result) |
@@ -1963,7 +1974,8 @@ try_connect_bl_check_cont (void *cls, | |||
1963 | return; | 1974 | return; |
1964 | } | 1975 | } |
1965 | n = setup_neighbour (peer); | 1976 | n = setup_neighbour (peer); |
1966 | set_state_and_timeout (n, GNUNET_TRANSPORT_PS_INIT_ATS, GNUNET_TIME_relative_to_absolute (ATS_RESPONSE_TIMEOUT)); | 1977 | set_state_and_timeout (n, GNUNET_TRANSPORT_PS_INIT_ATS, |
1978 | GNUNET_TIME_relative_to_absolute (ATS_RESPONSE_TIMEOUT)); | ||
1967 | 1979 | ||
1968 | GNUNET_ATS_reset_backoff (GST_ats, peer); | 1980 | GNUNET_ATS_reset_backoff (GST_ats, peer); |
1969 | n->suggest_handle = GNUNET_ATS_suggest_address (GST_ats, peer, | 1981 | n->suggest_handle = GNUNET_ATS_suggest_address (GST_ats, peer, |
@@ -2043,7 +2055,7 @@ GST_neighbours_try_connect (const struct GNUNET_PeerIdentity *target) | |||
2043 | } | 2055 | } |
2044 | } | 2056 | } |
2045 | 2057 | ||
2046 | /* Do blacklist check if connection is allowed */ | 2058 | /* Do blacklist check if connecting to this peer is allowed */ |
2047 | blc_ctx = GNUNET_new (struct BlacklistCheckSwitchContext); | 2059 | blc_ctx = GNUNET_new (struct BlacklistCheckSwitchContext); |
2048 | GNUNET_CONTAINER_DLL_insert (pending_bc_head, pending_bc_tail, blc_ctx); | 2060 | GNUNET_CONTAINER_DLL_insert (pending_bc_head, pending_bc_tail, blc_ctx); |
2049 | 2061 | ||
@@ -2134,13 +2146,15 @@ handle_test_blacklist_cont (void *cls, | |||
2134 | } | 2146 | } |
2135 | if (GNUNET_OK == result) | 2147 | if (GNUNET_OK == result) |
2136 | { | 2148 | { |
2137 | set_state_and_timeout (n, GNUNET_TRANSPORT_PS_CONNECT_SENT, GNUNET_TIME_relative_to_absolute (SETUP_CONNECTION_TIMEOUT)); | 2149 | set_state_and_timeout (n, GNUNET_TRANSPORT_PS_CONNECT_SENT, |
2150 | GNUNET_TIME_relative_to_absolute (SETUP_CONNECTION_TIMEOUT)); | ||
2138 | send_session_connect (&n->primary_address); | 2151 | send_session_connect (&n->primary_address); |
2139 | } | 2152 | } |
2140 | else | 2153 | else |
2141 | { | 2154 | { |
2142 | free_address (&n->primary_address); | 2155 | free_address (&n->primary_address); |
2143 | set_state_and_timeout (n, GNUNET_TRANSPORT_PS_INIT_ATS, GNUNET_TIME_relative_to_absolute (ATS_RESPONSE_TIMEOUT)); | 2156 | set_state_and_timeout (n, GNUNET_TRANSPORT_PS_INIT_ATS, |
2157 | GNUNET_TIME_relative_to_absolute (ATS_RESPONSE_TIMEOUT)); | ||
2144 | } | 2158 | } |
2145 | break; | 2159 | break; |
2146 | case GNUNET_TRANSPORT_PS_CONNECT_SENT: | 2160 | case GNUNET_TRANSPORT_PS_CONNECT_SENT: |
@@ -2155,12 +2169,14 @@ handle_test_blacklist_cont (void *cls, | |||
2155 | } | 2169 | } |
2156 | break; | 2170 | break; |
2157 | case GNUNET_TRANSPORT_PS_CONNECT_RECV_BLACKLIST_INBOUND: | 2171 | case GNUNET_TRANSPORT_PS_CONNECT_RECV_BLACKLIST_INBOUND: |
2158 | set_state_and_timeout (n, GNUNET_TRANSPORT_PS_CONNECT_RECV_ATS, GNUNET_TIME_relative_to_absolute (ATS_RESPONSE_TIMEOUT)); | 2172 | set_state_and_timeout (n, GNUNET_TRANSPORT_PS_CONNECT_RECV_ATS, |
2173 | GNUNET_TIME_relative_to_absolute (ATS_RESPONSE_TIMEOUT)); | ||
2159 | GNUNET_ATS_reset_backoff (GST_ats, peer); | 2174 | GNUNET_ATS_reset_backoff (GST_ats, peer); |
2160 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2175 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2161 | "Suggesting address for peer %s to ATS\n", | 2176 | "Suggesting address for peer %s to ATS\n", |
2162 | GNUNET_i2s (peer)); | 2177 | GNUNET_i2s (peer)); |
2163 | n->suggest_handle = GNUNET_ATS_suggest_address (GST_ats, peer, &address_suggest_cont, n); | 2178 | n->suggest_handle = GNUNET_ATS_suggest_address (GST_ats, peer, |
2179 | &address_suggest_cont, n); | ||
2164 | break; | 2180 | break; |
2165 | case GNUNET_TRANSPORT_PS_CONNECT_RECV_ATS: | 2181 | case GNUNET_TRANSPORT_PS_CONNECT_RECV_ATS: |
2166 | /* waiting on ATS suggestion, don't care about blacklist */ | 2182 | /* waiting on ATS suggestion, don't care about blacklist */ |
@@ -2174,7 +2190,8 @@ handle_test_blacklist_cont (void *cls, | |||
2174 | } | 2190 | } |
2175 | if (GNUNET_OK == result) | 2191 | if (GNUNET_OK == result) |
2176 | { | 2192 | { |
2177 | set_state_and_timeout (n, GNUNET_TRANSPORT_PS_CONNECT_RECV_ACK, GNUNET_TIME_relative_to_absolute (SETUP_CONNECTION_TIMEOUT)); | 2193 | set_state_and_timeout (n, GNUNET_TRANSPORT_PS_CONNECT_RECV_ACK, |
2194 | GNUNET_TIME_relative_to_absolute (SETUP_CONNECTION_TIMEOUT)); | ||
2178 | send_session_connect_ack_message (bcc->na.address, | 2195 | send_session_connect_ack_message (bcc->na.address, |
2179 | bcc->na.session, | 2196 | bcc->na.session, |
2180 | n->connect_ack_timestamp); | 2197 | n->connect_ack_timestamp); |
@@ -2195,7 +2212,8 @@ handle_test_blacklist_cont (void *cls, | |||
2195 | } | 2212 | } |
2196 | GNUNET_break (NULL != plugin); | 2213 | GNUNET_break (NULL != plugin); |
2197 | free_address (&n->primary_address); | 2214 | free_address (&n->primary_address); |
2198 | set_state_and_timeout (n, GNUNET_TRANSPORT_PS_INIT_ATS, GNUNET_TIME_relative_to_absolute (ATS_RESPONSE_TIMEOUT)); | 2215 | set_state_and_timeout (n, GNUNET_TRANSPORT_PS_INIT_ATS, |
2216 | GNUNET_TIME_relative_to_absolute (ATS_RESPONSE_TIMEOUT)); | ||
2199 | GNUNET_ATS_reset_backoff (GST_ats, peer); | 2217 | GNUNET_ATS_reset_backoff (GST_ats, peer); |
2200 | } | 2218 | } |
2201 | break; | 2219 | break; |