aboutsummaryrefslogtreecommitdiff
path: root/src/transport/gnunet-service-transport_neighbours.c
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2012-06-15 13:11:46 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2012-06-15 13:11:46 +0000
commit0bb2d2a34cbd8f1c0118f6203eaf9f41a1570fa7 (patch)
treeac8af3c2af3091c8945838a5f2403821efa10c27 /src/transport/gnunet-service-transport_neighbours.c
parent1dfa405cdd6ad888dff6386d4abecf44ef3828ab (diff)
downloadgnunet-0bb2d2a34cbd8f1c0118f6203eaf9f41a1570fa7.tar.gz
gnunet-0bb2d2a34cbd8f1c0118f6203eaf9f41a1570fa7.zip
- changed behavior when receiving CONNECT messages ... inbound session and NAT tests work again
Diffstat (limited to 'src/transport/gnunet-service-transport_neighbours.c')
-rw-r--r--src/transport/gnunet-service-transport_neighbours.c58
1 files changed, 40 insertions, 18 deletions
diff --git a/src/transport/gnunet-service-transport_neighbours.c b/src/transport/gnunet-service-transport_neighbours.c
index dd724e87b..d1a999376 100644
--- a/src/transport/gnunet-service-transport_neighbours.c
+++ b/src/transport/gnunet-service-transport_neighbours.c
@@ -221,10 +221,10 @@ struct MessageQueue
221 * Possible state of a neighbour. Initially, we are S_NOT_CONNECTED. 221 * Possible state of a neighbour. Initially, we are S_NOT_CONNECTED.
222 * 222 *
223 * Then, there are two main paths. If we receive a CONNECT message, we 223 * Then, there are two main paths. If we receive a CONNECT message, we
224 * first run a check against the blacklist and ask ATS for a 224 * first run a check against the blacklist (S_CONNECT_RECV_BLACKLIST_INBOUND).
225 * suggestion. (S_CONNECT_RECV_ATS). If the blacklist comes back 225 * If this check is successful, we give the inbound address to ATS.
226 * positive, we give the address to ATS. If ATS makes a suggestion, 226 * After the check we ask ATS for a suggestion (S_CONNECT_RECV_ATS).
227 * we ALSO give that suggestion to the blacklist 227 * If ATS makes a suggestion, we ALSO give that suggestion to the blacklist
228 * (S_CONNECT_RECV_BLACKLIST). Once the blacklist approves the 228 * (S_CONNECT_RECV_BLACKLIST). Once the blacklist approves the
229 * address we got from ATS, we send our CONNECT_ACK and go to 229 * address we got from ATS, we send our CONNECT_ACK and go to
230 * S_CONNECT_RECV_ACK. If we receive a SESSION_ACK, we go to 230 * S_CONNECT_RECV_ACK. If we receive a SESSION_ACK, we go to
@@ -302,6 +302,11 @@ enum State
302 S_CONNECT_SENT, 302 S_CONNECT_SENT,
303 303
304 /** 304 /**
305 * Received a CONNECT, do a blacklist check for inbound address
306 */
307 S_CONNECT_RECV_BLACKLIST_INBOUND,
308
309 /**
305 * Received a CONNECT, asking ATS about address suggestions. 310 * Received a CONNECT, asking ATS about address suggestions.
306 */ 311 */
307 S_CONNECT_RECV_ATS, 312 S_CONNECT_RECV_ATS,
@@ -639,6 +644,9 @@ print_state (int state)
639 case S_CONNECT_SENT: 644 case S_CONNECT_SENT:
640 return "S_CONNECT_SENT"; 645 return "S_CONNECT_SENT";
641 break; 646 break;
647 case S_CONNECT_RECV_BLACKLIST_INBOUND:
648 return "S_CONNECT_RECV_BLACKLIST_INBOUND";
649 break;
642 case S_CONNECT_RECV_ATS: 650 case S_CONNECT_RECV_ATS:
643 return "S_CONNECT_RECV_ATS"; 651 return "S_CONNECT_RECV_ATS";
644 break; 652 break;
@@ -832,7 +840,6 @@ set_address (struct NeighbourAddress *na,
832 if (GNUNET_YES == is_active) 840 if (GNUNET_YES == is_active)
833 { 841 {
834 /* Telling ATS about new session */ 842 /* Telling ATS about new session */
835 GNUNET_ATS_address_add (GST_ats, na->address, na->session, NULL, 0);
836 GNUNET_ATS_address_in_use (GST_ats, na->address, na->session, GNUNET_YES); 843 GNUNET_ATS_address_in_use (GST_ats, na->address, na->session, GNUNET_YES);
837 GST_validation_set_address_use (na->address, na->session, GNUNET_YES, __LINE__); 844 GST_validation_set_address_use (na->address, na->session, GNUNET_YES, __LINE__);
838 845
@@ -1728,14 +1735,6 @@ handle_test_blacklist_cont (void *cls,
1728 "Connection to new address of peer `%s' based on blacklist is `%s'\n", 1735 "Connection to new address of peer `%s' based on blacklist is `%s'\n",
1729 GNUNET_i2s (peer), 1736 GNUNET_i2s (peer),
1730 (GNUNET_OK == result) ? "allowed" : "FORBIDDEN"); 1737 (GNUNET_OK == result) ? "allowed" : "FORBIDDEN");
1731 if (GNUNET_OK == result)
1732 {
1733 /* valid new address, let ATS know! */
1734 GNUNET_ATS_address_add (GST_ats,
1735 bcc->na.address,
1736 bcc->na.session,
1737 bcc->ats, bcc->ats_count);
1738 }
1739 if (NULL == (n = lookup_neighbour (peer))) 1738 if (NULL == (n = lookup_neighbour (peer)))
1740 goto cleanup; /* nobody left to care about new address */ 1739 goto cleanup; /* nobody left to care about new address */
1741 switch (n->state) 1740 switch (n->state)
@@ -1791,9 +1790,23 @@ handle_test_blacklist_cont (void *cls,
1791 n->connect_ack_timestamp); 1790 n->connect_ack_timestamp);
1792 } 1791 }
1793 break; 1792 break;
1793 case S_CONNECT_RECV_BLACKLIST_INBOUND:
1794 if (GNUNET_OK == result)
1795 {
1796 /* valid new address, let ATS know! */
1797 GNUNET_ATS_address_add (GST_ats,
1798 bcc->na.address,
1799 bcc->na.session,
1800 bcc->ats, bcc->ats_count);
1801 }
1802 n->state = S_CONNECT_RECV_ATS;
1803 n->timeout = GNUNET_TIME_relative_to_absolute (ATS_RESPONSE_TIMEOUT);
1804 GNUNET_ATS_reset_backoff (GST_ats, peer);
1805 GNUNET_ATS_suggest_address (GST_ats, peer);
1806 break;
1794 case S_CONNECT_RECV_ATS: 1807 case S_CONNECT_RECV_ATS:
1795 /* still waiting on ATS suggestion, don't care about blacklist */ 1808 /* still waiting on ATS suggestion, don't care about blacklist */
1796 break; 1809 break;
1797 case S_CONNECT_RECV_BLACKLIST: 1810 case S_CONNECT_RECV_BLACKLIST:
1798 if (GNUNET_YES != address_matches (&bcc->na, &n->primary_address)) 1811 if (GNUNET_YES != address_matches (&bcc->na, &n->primary_address))
1799 break; /* result for an address we currently don't care about */ 1812 break; /* result for an address we currently don't care about */
@@ -2016,10 +2029,8 @@ GST_neighbours_handle_connect (const struct GNUNET_MessageHeader *message,
2016 switch (n->state) 2029 switch (n->state)
2017 { 2030 {
2018 case S_NOT_CONNECTED: 2031 case S_NOT_CONNECTED:
2019 n->state = S_CONNECT_RECV_ATS; 2032 n->state = S_CONNECT_RECV_BLACKLIST_INBOUND;
2020 n->timeout = GNUNET_TIME_relative_to_absolute (ATS_RESPONSE_TIMEOUT); 2033 /* Do a blacklist check for the new address */
2021 GNUNET_ATS_reset_backoff (GST_ats, peer);
2022 GNUNET_ATS_suggest_address (GST_ats, peer);
2023 check_blacklist (peer, ts, address, session, ats, ats_count); 2034 check_blacklist (peer, ts, address, session, ats, ats_count);
2024 break; 2035 break;
2025 case S_INIT_ATS: 2036 case S_INIT_ATS:
@@ -2352,6 +2363,17 @@ master_task (void *cls,
2352 return; 2363 return;
2353 } 2364 }
2354 break; 2365 break;
2366 case S_CONNECT_RECV_BLACKLIST_INBOUND:
2367 if (0 == delay.rel_value)
2368 {
2369 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2370 "Connection to `%s' timed out waiting BLACKLIST to approve address to use for received CONNECT\n",
2371 GNUNET_i2s (&n->id));
2372 n->state = S_DISCONNECT_FINISHED;
2373 free_neighbour (n, GNUNET_NO);
2374 return;
2375 }
2376 break;
2355 case S_CONNECT_RECV_ATS: 2377 case S_CONNECT_RECV_ATS:
2356 if (0 == delay.rel_value) 2378 if (0 == delay.rel_value)
2357 { 2379 {