diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2014-03-24 16:43:41 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2014-03-24 16:43:41 +0000 |
commit | bf638cabbe348680e7132eafb1091dfca2c0b8a5 (patch) | |
tree | e028072c3080583b20f7dc4411f278cb49cd06dd /src/transport/gnunet-service-transport_neighbours.c | |
parent | a2fb5eb15adad0bf20cd7a495abad2b128d2e8b1 (diff) | |
download | gnunet-bf638cabbe348680e7132eafb1091dfca2c0b8a5.tar.gz gnunet-bf638cabbe348680e7132eafb1091dfca2c0b8a5.zip |
checking incoming connection behaviour:
- removing blacklist checks for incoming checks
- adjusting blacklist check on connect to report to ATS
- incoming blacklist check states did not set timeouts
- timeouts not set for PS_CONNECT_RECV_BLACKLIST_INBOUND in handle_connect
Diffstat (limited to 'src/transport/gnunet-service-transport_neighbours.c')
-rw-r--r-- | src/transport/gnunet-service-transport_neighbours.c | 163 |
1 files changed, 108 insertions, 55 deletions
diff --git a/src/transport/gnunet-service-transport_neighbours.c b/src/transport/gnunet-service-transport_neighbours.c index daab28191..5ce09223c 100644 --- a/src/transport/gnunet-service-transport_neighbours.c +++ b/src/transport/gnunet-service-transport_neighbours.c | |||
@@ -1751,19 +1751,20 @@ send_session_connect (struct NeighbourAddress *na) | |||
1751 | 1751 | ||
1752 | 1752 | ||
1753 | /** | 1753 | /** |
1754 | * Send a SESSION_CONNECT_ACK message via the given address. | 1754 | * Send a CONNECT_ACK message via the given address. |
1755 | * | 1755 | * |
1756 | * @param address address to use | 1756 | * @param address address to use |
1757 | * @param session session to use | 1757 | * @param session session to use |
1758 | * @param timestamp timestamp to use for the ACK message | 1758 | * @param timestamp timestamp to use for the ACK message |
1759 | */ | 1759 | */ |
1760 | static void | 1760 | static void |
1761 | send_session_connect_ack_message (const struct GNUNET_HELLO_Address *address, | 1761 | send_connect_ack_message (const struct GNUNET_HELLO_Address *address, |
1762 | struct Session *session, | 1762 | struct Session *session, |
1763 | struct GNUNET_TIME_Absolute timestamp) | 1763 | struct GNUNET_TIME_Absolute timestamp) |
1764 | { | 1764 | { |
1765 | struct GNUNET_TRANSPORT_PluginFunctions *papi; | 1765 | struct GNUNET_TRANSPORT_PluginFunctions *papi; |
1766 | struct SessionConnectMessage connect_msg; | 1766 | struct SessionConnectMessage connect_msg; |
1767 | struct NeighbourMapEntry *n; | ||
1767 | 1768 | ||
1768 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1769 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1769 | "Sending CONNECT_ACK to peer `%s'\n", | 1770 | "Sending CONNECT_ACK to peer `%s'\n", |
@@ -1788,12 +1789,43 @@ send_session_connect_ack_message (const struct GNUNET_HELLO_Address *address, | |||
1788 | connect_msg.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_CONNECT_ACK); | 1789 | connect_msg.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_CONNECT_ACK); |
1789 | connect_msg.reserved = htonl (0); | 1790 | connect_msg.reserved = htonl (0); |
1790 | connect_msg.timestamp = GNUNET_TIME_absolute_hton (timestamp); | 1791 | connect_msg.timestamp = GNUNET_TIME_absolute_hton (timestamp); |
1791 | (void) papi->send (papi->cls, | 1792 | |
1793 | if (GNUNET_SYSERR == papi->send (papi->cls, | ||
1792 | session, | 1794 | session, |
1793 | (const char *) &connect_msg, sizeof (struct SessionConnectMessage), | 1795 | (const char *) &connect_msg, sizeof (struct SessionConnectMessage), |
1794 | UINT_MAX, | 1796 | UINT_MAX, |
1795 | GNUNET_TIME_UNIT_FOREVER_REL, | 1797 | GNUNET_TIME_UNIT_FOREVER_REL, |
1796 | NULL, NULL); | 1798 | NULL, NULL)) |
1799 | { | ||
1800 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
1801 | _("Failed to transmit CONNECT_ACK message via plugin to %s\n"), | ||
1802 | GST_plugins_a2s (address)); | ||
1803 | |||
1804 | n = lookup_neighbour (&address->peer); | ||
1805 | if (NULL == n) | ||
1806 | { | ||
1807 | GNUNET_break (0); | ||
1808 | return; | ||
1809 | } | ||
1810 | /* Hard failure to send the CONNECT_ACK message with this address: | ||
1811 | Destroy session (and address) */ | ||
1812 | if (GNUNET_YES == GNUNET_HELLO_address_check_option(address, | ||
1813 | GNUNET_HELLO_ADDRESS_INFO_INBOUND)) | ||
1814 | { | ||
1815 | GNUNET_ATS_address_destroyed (GST_ats, address, session); | ||
1816 | GNUNET_ATS_address_destroyed (GST_ats, address, NULL); | ||
1817 | } | ||
1818 | else | ||
1819 | { | ||
1820 | GNUNET_ATS_address_destroyed (GST_ats, address, session); | ||
1821 | } | ||
1822 | |||
1823 | /* Remove address and request and additional one */ | ||
1824 | unset_primary_address (n); | ||
1825 | set_state_and_timeout (n, GNUNET_TRANSPORT_PS_INIT_ATS, | ||
1826 | GNUNET_TIME_relative_to_absolute (ATS_RESPONSE_TIMEOUT)); | ||
1827 | return; | ||
1828 | } | ||
1797 | 1829 | ||
1798 | } | 1830 | } |
1799 | 1831 | ||
@@ -2180,7 +2212,7 @@ GST_neighbours_try_connect (const struct GNUNET_PeerIdentity *target) | |||
2180 | * @param result #GNUNET_OK if the address is allowed | 2212 | * @param result #GNUNET_OK if the address is allowed |
2181 | */ | 2213 | */ |
2182 | static void | 2214 | static void |
2183 | handle_test_blacklist_cont (void *cls, | 2215 | handle_connect_blacklist_check_cont (void *cls, |
2184 | const struct GNUNET_PeerIdentity *peer, | 2216 | const struct GNUNET_PeerIdentity *peer, |
2185 | int result) | 2217 | int result) |
2186 | { | 2218 | { |
@@ -2197,17 +2229,16 @@ handle_test_blacklist_cont (void *cls, | |||
2197 | (GNUNET_OK == result) ? "allowed" : "FORBIDDEN"); | 2229 | (GNUNET_OK == result) ? "allowed" : "FORBIDDEN"); |
2198 | if (GNUNET_OK == result) | 2230 | if (GNUNET_OK == result) |
2199 | { | 2231 | { |
2232 | /* Blacklist agreed on connecting to a peer with this address */ | ||
2233 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
2234 | "Notifying ATS peer's `%s' %s address `%s' session %p\n", | ||
2235 | GNUNET_i2s (peer), | ||
2236 | (GNUNET_YES == GNUNET_HELLO_address_check_option(bcc->na.address, | ||
2237 | GNUNET_HELLO_ADDRESS_INFO_INBOUND)) ? "inbound" : "outbound", | ||
2238 | GST_plugins_a2s (bcc->na.address), bcc->na.session); | ||
2200 | GST_ats_add_address (bcc->na.address, bcc->na.session, NULL, 0); | 2239 | GST_ats_add_address (bcc->na.address, bcc->na.session, NULL, 0); |
2201 | } | 2240 | } |
2202 | else | 2241 | |
2203 | { | ||
2204 | /* Blacklist disagreed on connecting to a peer with this address | ||
2205 | * Destroy address because we are not allowed to use it | ||
2206 | */ | ||
2207 | if (NULL != bcc->na.session) | ||
2208 | GNUNET_ATS_address_destroyed (GST_ats, bcc->na.address, bcc->na.session); | ||
2209 | GNUNET_ATS_address_destroyed (GST_ats, bcc->na.address, NULL); | ||
2210 | } | ||
2211 | if (NULL == (n = lookup_neighbour (peer))) | 2242 | if (NULL == (n = lookup_neighbour (peer))) |
2212 | { | 2243 | { |
2213 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2244 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
@@ -2216,7 +2247,7 @@ handle_test_blacklist_cont (void *cls, | |||
2216 | goto cleanup; /* nobody left to care about new address */ | 2247 | goto cleanup; /* nobody left to care about new address */ |
2217 | } | 2248 | } |
2218 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2249 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2219 | "Received blacklist result for peer `%s' in state %s/%s\n", | 2250 | "Received connect blacklist check result for peer `%s' in state %s/%s\n", |
2220 | GNUNET_i2s (peer), | 2251 | GNUNET_i2s (peer), |
2221 | GNUNET_TRANSPORT_ps2s (n->state), | 2252 | GNUNET_TRANSPORT_ps2s (n->state), |
2222 | print_ack_state (n->ack_state)); | 2253 | print_ack_state (n->ack_state)); |
@@ -2232,25 +2263,41 @@ handle_test_blacklist_cont (void *cls, | |||
2232 | possibility */ | 2263 | possibility */ |
2233 | break; | 2264 | break; |
2234 | case GNUNET_TRANSPORT_PS_CONNECT_SENT: | 2265 | case GNUNET_TRANSPORT_PS_CONNECT_SENT: |
2266 | #if 0 | ||
2267 | /* TODO Why should I send an connect ACK message */ | ||
2235 | /* waiting on CONNECT_ACK, send ACK if one is pending */ | 2268 | /* waiting on CONNECT_ACK, send ACK if one is pending */ |
2269 | |||
2236 | if ( (GNUNET_OK == result) && | 2270 | if ( (GNUNET_OK == result) && |
2237 | (ACK_SEND_CONNECT_ACK == n->ack_state) ) | 2271 | (ACK_SEND_CONNECT_ACK == n->ack_state) ) |
2238 | { | 2272 | { |
2239 | n->ack_state = ACK_SEND_SESSION_ACK; | 2273 | n->ack_state = ACK_SEND_SESSION_ACK; |
2240 | send_session_connect_ack_message (n->primary_address.address, | 2274 | send_connect_ack_message (n->primary_address.address, |
2241 | n->primary_address.session, | 2275 | n->primary_address.session, |
2242 | n->connect_ack_timestamp); | 2276 | n->connect_ack_timestamp); |
2243 | } | 2277 | } |
2278 | #endif | ||
2244 | break; | 2279 | break; |
2245 | case GNUNET_TRANSPORT_PS_CONNECT_RECV_BLACKLIST_INBOUND: | 2280 | case GNUNET_TRANSPORT_PS_CONNECT_RECV_BLACKLIST_INBOUND: |
2246 | set_state_and_timeout (n, GNUNET_TRANSPORT_PS_CONNECT_RECV_ATS, | 2281 | if (GNUNET_OK == result) |
2247 | GNUNET_TIME_relative_to_absolute (ATS_RESPONSE_TIMEOUT)); | 2282 | { |
2248 | GNUNET_ATS_reset_backoff (GST_ats, peer); | 2283 | /* We received a connect request and blacklist allowed to communicate |
2249 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2284 | * with this peer, request an address from ATS*/ |
2250 | "Suggesting address for peer %s to ATS\n", | 2285 | set_state_and_timeout (n, GNUNET_TRANSPORT_PS_CONNECT_RECV_ATS, |
2251 | GNUNET_i2s (peer)); | 2286 | GNUNET_TIME_relative_to_absolute (ATS_RESPONSE_TIMEOUT)); |
2252 | n->suggest_handle = GNUNET_ATS_suggest_address (GST_ats, peer, | 2287 | GNUNET_ATS_reset_backoff (GST_ats, peer); |
2253 | &address_suggest_cont, n); | 2288 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2289 | "Requesting address for peer %s to ATS\n", | ||
2290 | GNUNET_i2s (peer)); | ||
2291 | if (NULL == n->suggest_handle) | ||
2292 | n->suggest_handle = GNUNET_ATS_suggest_address (GST_ats, peer, | ||
2293 | &address_suggest_cont, n); | ||
2294 | else | ||
2295 | GNUNET_ATS_reset_backoff (GST_ats, peer); | ||
2296 | } | ||
2297 | else | ||
2298 | { | ||
2299 | /* FIXME: state handling required! */ | ||
2300 | } | ||
2254 | break; | 2301 | break; |
2255 | case GNUNET_TRANSPORT_PS_CONNECT_RECV_ATS: | 2302 | case GNUNET_TRANSPORT_PS_CONNECT_RECV_ATS: |
2256 | /* waiting on ATS suggestion, don't care about blacklist */ | 2303 | /* waiting on ATS suggestion, don't care about blacklist */ |
@@ -2266,7 +2313,7 @@ handle_test_blacklist_cont (void *cls, | |||
2266 | { | 2313 | { |
2267 | set_state_and_timeout (n, GNUNET_TRANSPORT_PS_CONNECT_RECV_ACK, | 2314 | set_state_and_timeout (n, GNUNET_TRANSPORT_PS_CONNECT_RECV_ACK, |
2268 | GNUNET_TIME_relative_to_absolute (SETUP_CONNECTION_TIMEOUT)); | 2315 | GNUNET_TIME_relative_to_absolute (SETUP_CONNECTION_TIMEOUT)); |
2269 | send_session_connect_ack_message (bcc->na.address, | 2316 | send_connect_ack_message (bcc->na.address, |
2270 | bcc->na.session, | 2317 | bcc->na.session, |
2271 | n->connect_ack_timestamp); | 2318 | n->connect_ack_timestamp); |
2272 | if (ACK_SEND_CONNECT_ACK == n->ack_state) | 2319 | if (ACK_SEND_CONNECT_ACK == n->ack_state) |
@@ -2297,7 +2344,7 @@ handle_test_blacklist_cont (void *cls, | |||
2297 | (ACK_SEND_CONNECT_ACK == n->ack_state) ) | 2344 | (ACK_SEND_CONNECT_ACK == n->ack_state) ) |
2298 | { | 2345 | { |
2299 | n->ack_state = ACK_SEND_SESSION_ACK; | 2346 | n->ack_state = ACK_SEND_SESSION_ACK; |
2300 | send_session_connect_ack_message (n->primary_address.address, | 2347 | send_connect_ack_message (n->primary_address.address, |
2301 | n->primary_address.session, | 2348 | n->primary_address.session, |
2302 | n->connect_ack_timestamp); | 2349 | n->connect_ack_timestamp); |
2303 | } | 2350 | } |
@@ -2313,7 +2360,7 @@ handle_test_blacklist_cont (void *cls, | |||
2313 | (ACK_SEND_CONNECT_ACK == n->ack_state) ) | 2360 | (ACK_SEND_CONNECT_ACK == n->ack_state) ) |
2314 | { | 2361 | { |
2315 | n->ack_state = ACK_SEND_SESSION_ACK; | 2362 | n->ack_state = ACK_SEND_SESSION_ACK; |
2316 | send_session_connect_ack_message (bcc->na.address, | 2363 | send_connect_ack_message (bcc->na.address, |
2317 | bcc->na.session, | 2364 | bcc->na.session, |
2318 | n->connect_ack_timestamp); | 2365 | n->connect_ack_timestamp); |
2319 | } | 2366 | } |
@@ -2341,7 +2388,7 @@ handle_test_blacklist_cont (void *cls, | |||
2341 | (ACK_SEND_CONNECT_ACK == n->ack_state) ) | 2388 | (ACK_SEND_CONNECT_ACK == n->ack_state) ) |
2342 | { | 2389 | { |
2343 | n->ack_state = ACK_SEND_SESSION_ACK; | 2390 | n->ack_state = ACK_SEND_SESSION_ACK; |
2344 | send_session_connect_ack_message (n->primary_address.address, | 2391 | send_connect_ack_message (n->primary_address.address, |
2345 | n->primary_address.session, | 2392 | n->primary_address.session, |
2346 | n->connect_ack_timestamp); | 2393 | n->connect_ack_timestamp); |
2347 | } | 2394 | } |
@@ -2370,7 +2417,7 @@ handle_test_blacklist_cont (void *cls, | |||
2370 | (ACK_SEND_CONNECT_ACK == n->ack_state) ) | 2417 | (ACK_SEND_CONNECT_ACK == n->ack_state) ) |
2371 | { | 2418 | { |
2372 | n->ack_state = ACK_SEND_SESSION_ACK; | 2419 | n->ack_state = ACK_SEND_SESSION_ACK; |
2373 | send_session_connect_ack_message (n->primary_address.address, | 2420 | send_connect_ack_message (n->primary_address.address, |
2374 | n->primary_address.session, | 2421 | n->primary_address.session, |
2375 | n->connect_ack_timestamp); | 2422 | n->connect_ack_timestamp); |
2376 | } | 2423 | } |
@@ -2397,8 +2444,8 @@ handle_test_blacklist_cont (void *cls, | |||
2397 | 2444 | ||
2398 | 2445 | ||
2399 | /** | 2446 | /** |
2400 | * We want to know if connecting to a particular peer via | 2447 | * We received a CONNECT message and want to know if connecting to a particular |
2401 | * a particular address is allowed. Check it! | 2448 | * peer via a particular address is allowed. Check it! |
2402 | * | 2449 | * |
2403 | * @param peer identity of the peer to switch the address for | 2450 | * @param peer identity of the peer to switch the address for |
2404 | * @param ts time at which the check was initiated | 2451 | * @param ts time at which the check was initiated |
@@ -2407,7 +2454,7 @@ handle_test_blacklist_cont (void *cls, | |||
2407 | * @param session session to use (or NULL) | 2454 | * @param session session to use (or NULL) |
2408 | */ | 2455 | */ |
2409 | static void | 2456 | static void |
2410 | check_blacklist (const struct GNUNET_PeerIdentity *peer, | 2457 | connect_check_blacklist (const struct GNUNET_PeerIdentity *peer, |
2411 | struct GNUNET_TIME_Absolute ts, | 2458 | struct GNUNET_TIME_Absolute ts, |
2412 | const struct GNUNET_HELLO_Address *address, | 2459 | const struct GNUNET_HELLO_Address *address, |
2413 | struct Session *session) | 2460 | struct Session *session) |
@@ -2426,8 +2473,8 @@ check_blacklist (const struct GNUNET_PeerIdentity *peer, | |||
2426 | bc_tail, | 2473 | bc_tail, |
2427 | bcc); | 2474 | bcc); |
2428 | if (NULL != (bc = GST_blacklist_test_allowed (peer, | 2475 | if (NULL != (bc = GST_blacklist_test_allowed (peer, |
2429 | address->transport_name, | 2476 | (NULL != address) ? address->transport_name : NULL, |
2430 | &handle_test_blacklist_cont, bcc))) | 2477 | &handle_connect_blacklist_check_cont, bcc))) |
2431 | bcc->bc = bc; | 2478 | bcc->bc = bc; |
2432 | /* if NULL == bc, 'cont' was already called and 'bcc' already free'd, so | 2479 | /* if NULL == bc, 'cont' was already called and 'bcc' already free'd, so |
2433 | we must only store 'bc' if 'bc' is non-NULL... */ | 2480 | we must only store 'bc' if 'bc' is non-NULL... */ |
@@ -2479,7 +2526,10 @@ GST_neighbours_handle_connect (const struct GNUNET_MessageHeader *message, | |||
2479 | ts = GNUNET_TIME_absolute_ntoh (scm->timestamp); | 2526 | ts = GNUNET_TIME_absolute_ntoh (scm->timestamp); |
2480 | n = lookup_neighbour (peer); | 2527 | n = lookup_neighbour (peer); |
2481 | if (NULL == n) | 2528 | if (NULL == n) |
2529 | { | ||
2530 | /* This is a new neighbour and set to not connected */ | ||
2482 | n = setup_neighbour (peer); | 2531 | n = setup_neighbour (peer); |
2532 | } | ||
2483 | 2533 | ||
2484 | /* Remember this CONNECT message in neighbour */ | 2534 | /* Remember this CONNECT message in neighbour */ |
2485 | n->ack_state = ACK_SEND_CONNECT_ACK; | 2535 | n->ack_state = ACK_SEND_CONNECT_ACK; |
@@ -2493,13 +2543,15 @@ GST_neighbours_handle_connect (const struct GNUNET_MessageHeader *message, | |||
2493 | switch (n->state) | 2543 | switch (n->state) |
2494 | { | 2544 | { |
2495 | case GNUNET_TRANSPORT_PS_NOT_CONNECTED: | 2545 | case GNUNET_TRANSPORT_PS_NOT_CONNECTED: |
2496 | /* Do a blacklist check for the new address */ | 2546 | /* Check if we are allowed to connect with this peer and this address */ |
2497 | set_state (n, GNUNET_TRANSPORT_PS_CONNECT_RECV_BLACKLIST_INBOUND); | 2547 | set_state_and_timeout (n, GNUNET_TRANSPORT_PS_CONNECT_RECV_BLACKLIST_INBOUND, |
2498 | check_blacklist (peer, ts, address, session); | 2548 | GNUNET_TIME_relative_to_absolute (BLACKLIST_RESPONSE_TIMEOUT)); |
2549 | connect_check_blacklist (peer, ts, address, session); | ||
2499 | break; | 2550 | break; |
2500 | case GNUNET_TRANSPORT_PS_INIT_ATS: | 2551 | case GNUNET_TRANSPORT_PS_INIT_ATS: |
2501 | /* CONNECT message takes priority over us asking ATS for address */ | 2552 | /* CONNECT message takes priority over us asking ATS for address */ |
2502 | set_state (n, GNUNET_TRANSPORT_PS_CONNECT_RECV_BLACKLIST_INBOUND); | 2553 | set_state_and_timeout (n, GNUNET_TRANSPORT_PS_CONNECT_RECV_BLACKLIST_INBOUND, |
2554 | GNUNET_TIME_relative_to_absolute (BLACKLIST_RESPONSE_TIMEOUT)); | ||
2503 | /* fallthrough */ | 2555 | /* fallthrough */ |
2504 | case GNUNET_TRANSPORT_PS_CONNECT_SENT: | 2556 | case GNUNET_TRANSPORT_PS_CONNECT_SENT: |
2505 | case GNUNET_TRANSPORT_PS_CONNECT_RECV_BLACKLIST_INBOUND: | 2557 | case GNUNET_TRANSPORT_PS_CONNECT_RECV_BLACKLIST_INBOUND: |
@@ -2508,7 +2560,7 @@ GST_neighbours_handle_connect (const struct GNUNET_MessageHeader *message, | |||
2508 | case GNUNET_TRANSPORT_PS_CONNECT_RECV_ACK: | 2560 | case GNUNET_TRANSPORT_PS_CONNECT_RECV_ACK: |
2509 | /* It can never hurt to have an alternative address in the above cases, | 2561 | /* It can never hurt to have an alternative address in the above cases, |
2510 | see if it is allowed */ | 2562 | see if it is allowed */ |
2511 | check_blacklist (peer, ts, address, session); | 2563 | connect_check_blacklist (peer, ts, address, session); |
2512 | break; | 2564 | break; |
2513 | case GNUNET_TRANSPORT_PS_CONNECTED: | 2565 | case GNUNET_TRANSPORT_PS_CONNECTED: |
2514 | /* we are already connected and can thus send the ACK immediately; | 2566 | /* we are already connected and can thus send the ACK immediately; |
@@ -2517,16 +2569,16 @@ GST_neighbours_handle_connect (const struct GNUNET_MessageHeader *message, | |||
2517 | GNUNET_assert (NULL != n->primary_address.address); | 2569 | GNUNET_assert (NULL != n->primary_address.address); |
2518 | GNUNET_assert (NULL != n->primary_address.session); | 2570 | GNUNET_assert (NULL != n->primary_address.session); |
2519 | n->ack_state = ACK_UNDEFINED; | 2571 | n->ack_state = ACK_UNDEFINED; |
2520 | send_session_connect_ack_message (n->primary_address.address, | 2572 | send_connect_ack_message (n->primary_address.address, |
2521 | n->primary_address.session, ts); | 2573 | n->primary_address.session, ts); |
2522 | check_blacklist (peer, ts, address, session); | 2574 | connect_check_blacklist (peer, ts, address, session); |
2523 | break; | 2575 | break; |
2524 | case GNUNET_TRANSPORT_PS_RECONNECT_ATS: | 2576 | case GNUNET_TRANSPORT_PS_RECONNECT_ATS: |
2525 | case GNUNET_TRANSPORT_PS_RECONNECT_BLACKLIST: | 2577 | case GNUNET_TRANSPORT_PS_RECONNECT_BLACKLIST: |
2526 | case GNUNET_TRANSPORT_PS_RECONNECT_SENT: | 2578 | case GNUNET_TRANSPORT_PS_RECONNECT_SENT: |
2527 | /* It can never hurt to have an alternative address in the above cases, | 2579 | /* It can never hurt to have an alternative address in the above cases, |
2528 | see if it is allowed */ | 2580 | see if it is allowed */ |
2529 | check_blacklist (peer, ts, address, session); | 2581 | connect_check_blacklist (peer, ts, address, session); |
2530 | break; | 2582 | break; |
2531 | case GNUNET_TRANSPORT_PS_CONNECTED_SWITCHING_BLACKLIST: | 2583 | case GNUNET_TRANSPORT_PS_CONNECTED_SWITCHING_BLACKLIST: |
2532 | case GNUNET_TRANSPORT_PS_CONNECTED_SWITCHING_CONNECT_SENT: | 2584 | case GNUNET_TRANSPORT_PS_CONNECTED_SWITCHING_CONNECT_SENT: |
@@ -2536,9 +2588,9 @@ GST_neighbours_handle_connect (const struct GNUNET_MessageHeader *message, | |||
2536 | GNUNET_assert (NULL != n->primary_address.address); | 2588 | GNUNET_assert (NULL != n->primary_address.address); |
2537 | GNUNET_assert (NULL != n->primary_address.session); | 2589 | GNUNET_assert (NULL != n->primary_address.session); |
2538 | n->ack_state = ACK_UNDEFINED; | 2590 | n->ack_state = ACK_UNDEFINED; |
2539 | send_session_connect_ack_message (n->primary_address.address, | 2591 | send_connect_ack_message (n->primary_address.address, |
2540 | n->primary_address.session, ts); | 2592 | n->primary_address.session, ts); |
2541 | check_blacklist (peer, ts, address, session); | 2593 | connect_check_blacklist (peer, ts, address, session); |
2542 | break; | 2594 | break; |
2543 | case GNUNET_TRANSPORT_PS_DISCONNECT: | 2595 | case GNUNET_TRANSPORT_PS_DISCONNECT: |
2544 | /* get rid of remains without terminating sessions, ready to re-try */ | 2596 | /* get rid of remains without terminating sessions, ready to re-try */ |
@@ -2669,7 +2721,7 @@ switch_address_bl_check_cont (void *cls, | |||
2669 | if (ACK_SEND_CONNECT_ACK == n->ack_state) | 2721 | if (ACK_SEND_CONNECT_ACK == n->ack_state) |
2670 | { | 2722 | { |
2671 | n->ack_state = ACK_SEND_SESSION_ACK; | 2723 | n->ack_state = ACK_SEND_SESSION_ACK; |
2672 | send_session_connect_ack_message (n->primary_address.address, | 2724 | send_connect_ack_message (n->primary_address.address, |
2673 | n->primary_address.session, | 2725 | n->primary_address.session, |
2674 | n->connect_ack_timestamp); | 2726 | n->connect_ack_timestamp); |
2675 | } | 2727 | } |
@@ -2686,7 +2738,7 @@ switch_address_bl_check_cont (void *cls, | |||
2686 | /* Send an ACK message as a response to the CONNECT msg */ | 2738 | /* Send an ACK message as a response to the CONNECT msg */ |
2687 | set_state_and_timeout (n, GNUNET_TRANSPORT_PS_CONNECT_RECV_ACK, | 2739 | set_state_and_timeout (n, GNUNET_TRANSPORT_PS_CONNECT_RECV_ACK, |
2688 | GNUNET_TIME_relative_to_absolute (SETUP_CONNECTION_TIMEOUT)); | 2740 | GNUNET_TIME_relative_to_absolute (SETUP_CONNECTION_TIMEOUT)); |
2689 | send_session_connect_ack_message (n->primary_address.address, | 2741 | send_connect_ack_message (n->primary_address.address, |
2690 | n->primary_address.session, | 2742 | n->primary_address.session, |
2691 | n->connect_ack_timestamp); | 2743 | n->connect_ack_timestamp); |
2692 | if (ACK_SEND_CONNECT_ACK == n->ack_state) | 2744 | if (ACK_SEND_CONNECT_ACK == n->ack_state) |
@@ -2695,7 +2747,7 @@ switch_address_bl_check_cont (void *cls, | |||
2695 | break; | 2747 | break; |
2696 | case GNUNET_TRANSPORT_PS_CONNECT_RECV_BLACKLIST_INBOUND: | 2748 | case GNUNET_TRANSPORT_PS_CONNECT_RECV_BLACKLIST_INBOUND: |
2697 | set_timeout (n, GNUNET_TIME_relative_to_absolute (BLACKLIST_RESPONSE_TIMEOUT)); | 2749 | set_timeout (n, GNUNET_TIME_relative_to_absolute (BLACKLIST_RESPONSE_TIMEOUT)); |
2698 | check_blacklist (&n->id, n->connect_ack_timestamp, | 2750 | /* REMOVE */ connect_check_blacklist (&n->id, n->connect_ack_timestamp, |
2699 | blc_ctx->address, blc_ctx->session); | 2751 | blc_ctx->address, blc_ctx->session); |
2700 | break; | 2752 | break; |
2701 | case GNUNET_TRANSPORT_PS_CONNECT_RECV_BLACKLIST: | 2753 | case GNUNET_TRANSPORT_PS_CONNECT_RECV_BLACKLIST: |
@@ -2706,7 +2758,7 @@ switch_address_bl_check_cont (void *cls, | |||
2706 | blc_ctx->bandwidth_in, blc_ctx->bandwidth_out, GNUNET_NO); | 2758 | blc_ctx->bandwidth_in, blc_ctx->bandwidth_out, GNUNET_NO); |
2707 | set_state_and_timeout (n, GNUNET_TRANSPORT_PS_CONNECT_RECV_BLACKLIST, | 2759 | set_state_and_timeout (n, GNUNET_TRANSPORT_PS_CONNECT_RECV_BLACKLIST, |
2708 | GNUNET_TIME_relative_to_absolute (BLACKLIST_RESPONSE_TIMEOUT)); | 2760 | GNUNET_TIME_relative_to_absolute (BLACKLIST_RESPONSE_TIMEOUT)); |
2709 | check_blacklist (&n->id, n->connect_ack_timestamp, | 2761 | /* REMOVE */ connect_check_blacklist (&n->id, n->connect_ack_timestamp, |
2710 | blc_ctx->address, blc_ctx->session); | 2762 | blc_ctx->address, blc_ctx->session); |
2711 | break; | 2763 | break; |
2712 | case GNUNET_TRANSPORT_PS_CONNECTED: | 2764 | case GNUNET_TRANSPORT_PS_CONNECTED: |
@@ -2724,7 +2776,7 @@ switch_address_bl_check_cont (void *cls, | |||
2724 | set_state (n, GNUNET_TRANSPORT_PS_CONNECTED_SWITCHING_BLACKLIST); | 2776 | set_state (n, GNUNET_TRANSPORT_PS_CONNECTED_SWITCHING_BLACKLIST); |
2725 | set_alternative_address (n, blc_ctx->address, blc_ctx->session, | 2777 | set_alternative_address (n, blc_ctx->address, blc_ctx->session, |
2726 | blc_ctx->bandwidth_in, blc_ctx->bandwidth_out); | 2778 | blc_ctx->bandwidth_in, blc_ctx->bandwidth_out); |
2727 | check_blacklist (&n->id, GNUNET_TIME_absolute_get (), | 2779 | /* REMOVE */ connect_check_blacklist (&n->id, GNUNET_TIME_absolute_get (), |
2728 | blc_ctx->address, blc_ctx->session); | 2780 | blc_ctx->address, blc_ctx->session); |
2729 | break; | 2781 | break; |
2730 | case GNUNET_TRANSPORT_PS_RECONNECT_ATS: | 2782 | case GNUNET_TRANSPORT_PS_RECONNECT_ATS: |
@@ -2732,7 +2784,7 @@ switch_address_bl_check_cont (void *cls, | |||
2732 | blc_ctx->bandwidth_in, blc_ctx->bandwidth_out, GNUNET_NO); | 2784 | blc_ctx->bandwidth_in, blc_ctx->bandwidth_out, GNUNET_NO); |
2733 | set_state_and_timeout (n, GNUNET_TRANSPORT_PS_RECONNECT_BLACKLIST, | 2785 | set_state_and_timeout (n, GNUNET_TRANSPORT_PS_RECONNECT_BLACKLIST, |
2734 | GNUNET_TIME_relative_to_absolute (BLACKLIST_RESPONSE_TIMEOUT)); | 2786 | GNUNET_TIME_relative_to_absolute (BLACKLIST_RESPONSE_TIMEOUT)); |
2735 | check_blacklist (&n->id, n->connect_ack_timestamp, | 2787 | /* REMOVE */ connect_check_blacklist (&n->id, n->connect_ack_timestamp, |
2736 | blc_ctx->address, blc_ctx->session); | 2788 | blc_ctx->address, blc_ctx->session); |
2737 | break; | 2789 | break; |
2738 | case GNUNET_TRANSPORT_PS_RECONNECT_BLACKLIST: | 2790 | case GNUNET_TRANSPORT_PS_RECONNECT_BLACKLIST: |
@@ -2741,7 +2793,7 @@ switch_address_bl_check_cont (void *cls, | |||
2741 | set_primary_address (n, blc_ctx->address, blc_ctx->session, | 2793 | set_primary_address (n, blc_ctx->address, blc_ctx->session, |
2742 | blc_ctx->bandwidth_in, blc_ctx->bandwidth_out, GNUNET_NO); | 2794 | blc_ctx->bandwidth_in, blc_ctx->bandwidth_out, GNUNET_NO); |
2743 | set_timeout (n, GNUNET_TIME_relative_to_absolute (BLACKLIST_RESPONSE_TIMEOUT)); | 2795 | set_timeout (n, GNUNET_TIME_relative_to_absolute (BLACKLIST_RESPONSE_TIMEOUT)); |
2744 | check_blacklist (&n->id, n->connect_ack_timestamp, | 2796 | /* REMOVE */ connect_check_blacklist (&n->id, n->connect_ack_timestamp, |
2745 | blc_ctx->address, blc_ctx->session); | 2797 | blc_ctx->address, blc_ctx->session); |
2746 | break; | 2798 | break; |
2747 | case GNUNET_TRANSPORT_PS_RECONNECT_SENT: | 2799 | case GNUNET_TRANSPORT_PS_RECONNECT_SENT: |
@@ -2751,7 +2803,7 @@ switch_address_bl_check_cont (void *cls, | |||
2751 | blc_ctx->bandwidth_in, blc_ctx->bandwidth_out, GNUNET_NO); | 2803 | blc_ctx->bandwidth_in, blc_ctx->bandwidth_out, GNUNET_NO); |
2752 | set_state_and_timeout (n, GNUNET_TRANSPORT_PS_RECONNECT_BLACKLIST, | 2804 | set_state_and_timeout (n, GNUNET_TRANSPORT_PS_RECONNECT_BLACKLIST, |
2753 | GNUNET_TIME_relative_to_absolute (BLACKLIST_RESPONSE_TIMEOUT)); | 2805 | GNUNET_TIME_relative_to_absolute (BLACKLIST_RESPONSE_TIMEOUT)); |
2754 | check_blacklist (&n->id, n->connect_ack_timestamp, | 2806 | /* REMOVE */ connect_check_blacklist (&n->id, n->connect_ack_timestamp, |
2755 | blc_ctx->address, blc_ctx->session); | 2807 | blc_ctx->address, blc_ctx->session); |
2756 | break; | 2808 | break; |
2757 | case GNUNET_TRANSPORT_PS_CONNECTED_SWITCHING_BLACKLIST: | 2809 | case GNUNET_TRANSPORT_PS_CONNECTED_SWITCHING_BLACKLIST: |
@@ -2765,7 +2817,7 @@ switch_address_bl_check_cont (void *cls, | |||
2765 | /* ATS asks us to switch a life connection, update blacklist check */ | 2817 | /* ATS asks us to switch a life connection, update blacklist check */ |
2766 | set_primary_address (n, blc_ctx->address, blc_ctx->session, | 2818 | set_primary_address (n, blc_ctx->address, blc_ctx->session, |
2767 | blc_ctx->bandwidth_in, blc_ctx->bandwidth_out, GNUNET_NO); | 2819 | blc_ctx->bandwidth_in, blc_ctx->bandwidth_out, GNUNET_NO); |
2768 | check_blacklist (&n->id, GNUNET_TIME_absolute_get (), | 2820 | /* REMOVE */ connect_check_blacklist (&n->id, GNUNET_TIME_absolute_get (), |
2769 | blc_ctx->address, blc_ctx->session); | 2821 | blc_ctx->address, blc_ctx->session); |
2770 | break; | 2822 | break; |
2771 | case GNUNET_TRANSPORT_PS_CONNECTED_SWITCHING_CONNECT_SENT: | 2823 | case GNUNET_TRANSPORT_PS_CONNECTED_SWITCHING_CONNECT_SENT: |
@@ -2780,7 +2832,7 @@ switch_address_bl_check_cont (void *cls, | |||
2780 | set_state (n, GNUNET_TRANSPORT_PS_CONNECTED_SWITCHING_BLACKLIST); | 2832 | set_state (n, GNUNET_TRANSPORT_PS_CONNECTED_SWITCHING_BLACKLIST); |
2781 | set_alternative_address (n, blc_ctx->address, blc_ctx->session, | 2833 | set_alternative_address (n, blc_ctx->address, blc_ctx->session, |
2782 | blc_ctx->bandwidth_in, blc_ctx->bandwidth_out); | 2834 | blc_ctx->bandwidth_in, blc_ctx->bandwidth_out); |
2783 | check_blacklist (&n->id, GNUNET_TIME_absolute_get (), | 2835 | /* REMOVE */ connect_check_blacklist (&n->id, GNUNET_TIME_absolute_get (), |
2784 | blc_ctx->address, blc_ctx->session); | 2836 | blc_ctx->address, blc_ctx->session); |
2785 | break; | 2837 | break; |
2786 | case GNUNET_TRANSPORT_PS_DISCONNECT: | 2838 | case GNUNET_TRANSPORT_PS_DISCONNECT: |
@@ -3385,7 +3437,8 @@ GST_neighbours_handle_connect_ack (const struct GNUNET_MessageHeader *message, | |||
3385 | break; | 3437 | break; |
3386 | case GNUNET_TRANSPORT_PS_CONNECTED_SWITCHING_CONNECT_SENT: | 3438 | case GNUNET_TRANSPORT_PS_CONNECTED_SWITCHING_CONNECT_SENT: |
3387 | /* new address worked; adopt it and go back to connected! */ | 3439 | /* new address worked; adopt it and go back to connected! */ |
3388 | set_state_and_timeout (n, GNUNET_TRANSPORT_PS_CONNECTED, GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT)); | 3440 | set_state_and_timeout (n, GNUNET_TRANSPORT_PS_CONNECTED, |
3441 | GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT)); | ||
3389 | GNUNET_break (GNUNET_NO == n->alternative_address.ats_active); | 3442 | GNUNET_break (GNUNET_NO == n->alternative_address.ats_active); |
3390 | 3443 | ||
3391 | GST_ats_add_address (n->alternative_address.address, | 3444 | GST_ats_add_address (n->alternative_address.address, |