aboutsummaryrefslogtreecommitdiff
path: root/src/transport/gnunet-service-transport_neighbours.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2013-10-06 20:55:28 +0000
committerChristian Grothoff <christian@grothoff.org>2013-10-06 20:55:28 +0000
commit61c39c60565b386e0e12ea669556b030e8cd7180 (patch)
tree59109aeab8297bdc996faca8c4e38ec7426c36cf /src/transport/gnunet-service-transport_neighbours.c
parent780eb09dd8040ecf8649d40ddf8314464e0fc48e (diff)
downloadgnunet-61c39c60565b386e0e12ea669556b030e8cd7180.tar.gz
gnunet-61c39c60565b386e0e12ea669556b030e8cd7180.zip
-remove trailing whitespace
Diffstat (limited to 'src/transport/gnunet-service-transport_neighbours.c')
-rw-r--r--src/transport/gnunet-service-transport_neighbours.c150
1 files changed, 75 insertions, 75 deletions
diff --git a/src/transport/gnunet-service-transport_neighbours.c b/src/transport/gnunet-service-transport_neighbours.c
index 90f45f126..0cffe0aeb 100644
--- a/src/transport/gnunet-service-transport_neighbours.c
+++ b/src/transport/gnunet-service-transport_neighbours.c
@@ -79,7 +79,7 @@
79#define SETUP_CONNECTION_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 15) 79#define SETUP_CONNECTION_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 15)
80 80
81/** 81/**
82 * How long are we willing to wait for a successful reconnect if 82 * How long are we willing to wait for a successful reconnect if
83 * an existing connection went down? Much shorter than the 83 * an existing connection went down? Much shorter than the
84 * usual SETUP_CONNECTION_TIMEOUT as we do not inform the 84 * usual SETUP_CONNECTION_TIMEOUT as we do not inform the
85 * higher layers about the disconnect during this period. 85 * higher layers about the disconnect during this period.
@@ -271,7 +271,7 @@ GNUNET_NETWORK_STRUCT_BEGIN
271 * setup a connection/session for data exchange. A 'SESSION_CONNECT' 271 * setup a connection/session for data exchange. A 'SESSION_CONNECT'
272 * should be answered with a 'SESSION_CONNECT_ACK' with the same body 272 * should be answered with a 'SESSION_CONNECT_ACK' with the same body
273 * to confirm. A 'SESSION_CONNECT_ACK' should then be followed with 273 * to confirm. A 'SESSION_CONNECT_ACK' should then be followed with
274 * a 'SESSION_ACK'. Once the 'SESSION_ACK' is received, both peers 274 * a 'SESSION_ACK'. Once the 'SESSION_ACK' is received, both peers
275 * should be connected. 275 * should be connected.
276 */ 276 */
277struct SessionConnectMessage 277struct SessionConnectMessage
@@ -298,7 +298,7 @@ struct SessionConnectMessage
298 298
299/** 299/**
300 * Message we send to the other peer to notify him that we intentionally 300 * Message we send to the other peer to notify him that we intentionally
301 * are disconnecting (to reduce timeouts). This is just a friendly 301 * are disconnecting (to reduce timeouts). This is just a friendly
302 * notification, peers must not rely on always receiving disconnect 302 * notification, peers must not rely on always receiving disconnect
303 * messages. 303 * messages.
304 */ 304 */
@@ -448,8 +448,8 @@ struct MessageQueue
448 * and set the 'send_connect_ack' to 2. If we then receive a 448 * and set the 'send_connect_ack' to 2. If we then receive a
449 * 'SESSION_ACK', we go to 'S_CONNECTED' (and reset 'send_connect_ack' 449 * 'SESSION_ACK', we go to 'S_CONNECTED' (and reset 'send_connect_ack'
450 * to 0). 450 * to 0).
451 * 451 *
452 */ 452 */
453enum State 453enum State
454{ 454{
455 /** 455 /**
@@ -525,7 +525,7 @@ enum State
525 */ 525 */
526 S_CONNECTED_SWITCHING_BLACKLIST, 526 S_CONNECTED_SWITCHING_BLACKLIST,
527 527
528 /** 528 /**
529 * We have some primary connection, but ATS suggested we switch 529 * We have some primary connection, but ATS suggested we switch
530 * to some alternative; we now sent a CONNECT message for the 530 * to some alternative; we now sent a CONNECT message for the
531 * alternative session to the other peer and waiting for a 531 * alternative session to the other peer and waiting for a
@@ -589,7 +589,7 @@ struct NeighbourAddress
589 * Did we tell ATS that this is our 'active' address? 589 * Did we tell ATS that this is our 'active' address?
590 */ 590 */
591 int ats_active; 591 int ats_active;
592 592
593}; 593};
594 594
595 595
@@ -644,7 +644,7 @@ struct NeighbourMapEntry
644 struct GNUNET_TIME_Absolute keep_alive_time; 644 struct GNUNET_TIME_Absolute keep_alive_time;
645 645
646 /** 646 /**
647 * At what time did we sent the last keep-alive message? Used 647 * At what time did we sent the last keep-alive message? Used
648 * to calculate round-trip time ("latency"). 648 * to calculate round-trip time ("latency").
649 */ 649 */
650 struct GNUNET_TIME_Absolute last_keep_alive_time; 650 struct GNUNET_TIME_Absolute last_keep_alive_time;
@@ -713,7 +713,7 @@ struct NeighbourMapEntry
713 */ 713 */
714struct BlackListCheckContext 714struct BlackListCheckContext
715{ 715{
716 716
717 /** 717 /**
718 * We keep blacklist checks in a DLL. 718 * We keep blacklist checks in a DLL.
719 */ 719 */
@@ -954,7 +954,7 @@ set_address (struct NeighbourAddress *na,
954 int is_active) 954 int is_active)
955{ 955{
956 struct GNUNET_TRANSPORT_PluginFunctions *papi; 956 struct GNUNET_TRANSPORT_PluginFunctions *papi;
957 if (NULL == (papi = GST_plugins_find (address->transport_name))) 957 if (NULL == (papi = GST_plugins_find (address->transport_name)))
958 { 958 {
959 GNUNET_break (0); 959 GNUNET_break (0);
960 return; 960 return;
@@ -976,17 +976,17 @@ set_address (struct NeighbourAddress *na,
976 /* FIXME: is this the right place to set quotas? */ 976 /* FIXME: is this the right place to set quotas? */
977 GST_neighbours_set_incoming_quota (&address->peer, bandwidth_in); 977 GST_neighbours_set_incoming_quota (&address->peer, bandwidth_in);
978 send_outbound_quota (&address->peer, bandwidth_out); 978 send_outbound_quota (&address->peer, bandwidth_out);
979 } 979 }
980 return; 980 return;
981 } 981 }
982 free_address (na); 982 free_address (na);
983 if (NULL == session) 983 if (NULL == session)
984 session = papi->get_session (papi->cls, address); 984 session = papi->get_session (papi->cls, address);
985 if (NULL == session) 985 if (NULL == session)
986 { 986 {
987 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 987 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
988 "Failed to obtain new session for peer `%s' and address '%s'\n", 988 "Failed to obtain new session for peer `%s' and address '%s'\n",
989 GNUNET_i2s (&address->peer), GST_plugins_a2s (address)); 989 GNUNET_i2s (&address->peer), GST_plugins_a2s (address));
990 GNUNET_ATS_address_destroyed (GST_ats, address, NULL); 990 GNUNET_ATS_address_destroyed (GST_ats, address, NULL);
991 return; 991 return;
992 } 992 }
@@ -1037,8 +1037,8 @@ free_neighbour (struct NeighbourMapEntry *n, int keep_sessions)
1037 least internally we need to get clean... */ 1037 least internally we need to get clean... */
1038 if (GNUNET_YES == test_connected (n)) 1038 if (GNUNET_YES == test_connected (n))
1039 { 1039 {
1040 GNUNET_STATISTICS_set (GST_stats, 1040 GNUNET_STATISTICS_set (GST_stats,
1041 gettext_noop ("# peers connected"), 1041 gettext_noop ("# peers connected"),
1042 --neighbours_connected, 1042 --neighbours_connected,
1043 GNUNET_NO); 1043 GNUNET_NO);
1044 disconnect_notify_cb (callback_cls, &n->id); 1044 disconnect_notify_cb (callback_cls, &n->id);
@@ -1226,7 +1226,7 @@ send_disconnect (struct NeighbourMapEntry *n)
1226static void 1226static void
1227disconnect_neighbour (struct NeighbourMapEntry *n) 1227disconnect_neighbour (struct NeighbourMapEntry *n)
1228{ 1228{
1229 /* depending on state, notify neighbour and/or upper layers of this peer 1229 /* depending on state, notify neighbour and/or upper layers of this peer
1230 about disconnect */ 1230 about disconnect */
1231 switch (n->state) 1231 switch (n->state)
1232 { 1232 {
@@ -1238,7 +1238,7 @@ disconnect_neighbour (struct NeighbourMapEntry *n)
1238 free_neighbour (n, GNUNET_NO); 1238 free_neighbour (n, GNUNET_NO);
1239 return; 1239 return;
1240 case S_CONNECT_SENT: 1240 case S_CONNECT_SENT:
1241 send_disconnect (n); 1241 send_disconnect (n);
1242 n->state = S_DISCONNECT; 1242 n->state = S_DISCONNECT;
1243 break; 1243 break;
1244 case S_CONNECT_RECV_BLACKLIST_INBOUND: 1244 case S_CONNECT_RECV_BLACKLIST_INBOUND:
@@ -1250,9 +1250,9 @@ disconnect_neighbour (struct NeighbourMapEntry *n)
1250 return; 1250 return;
1251 case S_CONNECT_RECV_ACK: 1251 case S_CONNECT_RECV_ACK:
1252 /* we DID ACK the other peer's request, must send DISCONNECT */ 1252 /* we DID ACK the other peer's request, must send DISCONNECT */
1253 send_disconnect (n); 1253 send_disconnect (n);
1254 n->state = S_DISCONNECT; 1254 n->state = S_DISCONNECT;
1255 break; 1255 break;
1256 case S_CONNECTED: 1256 case S_CONNECTED:
1257 case S_RECONNECT_BLACKLIST: 1257 case S_RECONNECT_BLACKLIST:
1258 case S_RECONNECT_SENT: 1258 case S_RECONNECT_SENT:
@@ -1261,8 +1261,8 @@ disconnect_neighbour (struct NeighbourMapEntry *n)
1261 /* we are currently connected, need to send disconnect and do 1261 /* we are currently connected, need to send disconnect and do
1262 internal notifications and update statistics */ 1262 internal notifications and update statistics */
1263 send_disconnect (n); 1263 send_disconnect (n);
1264 GNUNET_STATISTICS_set (GST_stats, 1264 GNUNET_STATISTICS_set (GST_stats,
1265 gettext_noop ("# peers connected"), 1265 gettext_noop ("# peers connected"),
1266 --neighbours_connected, 1266 --neighbours_connected,
1267 GNUNET_NO); 1267 GNUNET_NO);
1268 disconnect_notify_cb (callback_cls, &n->id); 1268 disconnect_notify_cb (callback_cls, &n->id);
@@ -1326,7 +1326,7 @@ transmit_send_continuation (void *cls,
1326 n->is_active = NULL; 1326 n->is_active = NULL;
1327 if (GNUNET_SCHEDULER_NO_TASK != n->task) 1327 if (GNUNET_SCHEDULER_NO_TASK != n->task)
1328 GNUNET_SCHEDULER_cancel (n->task); 1328 GNUNET_SCHEDULER_cancel (n->task);
1329 n->task = GNUNET_SCHEDULER_add_now (&master_task, n); 1329 n->task = GNUNET_SCHEDULER_add_now (&master_task, n);
1330 } 1330 }
1331 if (bytes_in_send_queue < mq->message_buf_size) 1331 if (bytes_in_send_queue < mq->message_buf_size)
1332 { 1332 {
@@ -1355,7 +1355,7 @@ transmit_send_continuation (void *cls,
1355 gettext_noop 1355 gettext_noop
1356 ("# transmission failures for messages to other peers"), 1356 ("# transmission failures for messages to other peers"),
1357 1, GNUNET_NO); 1357 1, GNUNET_NO);
1358 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1358 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1359 "Sending message to `%s' of type %u was a %s\n", 1359 "Sending message to `%s' of type %u was a %s\n",
1360 GNUNET_i2s (receiver), 1360 GNUNET_i2s (receiver),
1361 ntohs (((struct GNUNET_MessageHeader *) mq->message_buf)->type), 1361 ntohs (((struct GNUNET_MessageHeader *) mq->message_buf)->type),
@@ -1389,7 +1389,7 @@ try_transmission_to_peer (struct NeighbourMapEntry *n)
1389 GNUNET_break (0); 1389 GNUNET_break (0);
1390 return; 1390 return;
1391 } 1391 }
1392 if ((0 == n->primary_address.address->address_length) && 1392 if ((0 == n->primary_address.address->address_length) &&
1393 (NULL == n->primary_address.session)) 1393 (NULL == n->primary_address.session))
1394 { 1394 {
1395 /* no address, why are we here? */ 1395 /* no address, why are we here? */
@@ -1399,7 +1399,7 @@ try_transmission_to_peer (struct NeighbourMapEntry *n)
1399 if (NULL != n->is_active) 1399 if (NULL != n->is_active)
1400 { 1400 {
1401 /* transmission already pending */ 1401 /* transmission already pending */
1402 return; 1402 return;
1403 } 1403 }
1404 1404
1405 /* timeout messages from the queue that are past their due date */ 1405 /* timeout messages from the queue that are past their due date */
@@ -1535,7 +1535,7 @@ GST_neighbours_keepalive_response (const struct GNUNET_PeerIdentity *neighbour)
1535 n->timeout = GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT); 1535 n->timeout = GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT);
1536 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1536 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1537 "Latency for peer `%s' is %s\n", 1537 "Latency for peer `%s' is %s\n",
1538 GNUNET_i2s (&n->id), 1538 GNUNET_i2s (&n->id),
1539 GNUNET_STRINGS_relative_time_to_string (n->latency, 1539 GNUNET_STRINGS_relative_time_to_string (n->latency,
1540 GNUNET_YES)); 1540 GNUNET_YES));
1541 /* append latency */ 1541 /* append latency */
@@ -1570,7 +1570,7 @@ GST_neighbours_calculate_receive_delay (const struct GNUNET_PeerIdentity
1570{ 1570{
1571 struct NeighbourMapEntry *n; 1571 struct NeighbourMapEntry *n;
1572 struct GNUNET_TIME_Relative ret; 1572 struct GNUNET_TIME_Relative ret;
1573 1573
1574 if (NULL == neighbours) 1574 if (NULL == neighbours)
1575 { 1575 {
1576 *do_forward = GNUNET_NO; 1576 *do_forward = GNUNET_NO;
@@ -1634,7 +1634,7 @@ GST_neighbours_calculate_receive_delay (const struct GNUNET_PeerIdentity
1634 GNUNET_STRINGS_relative_time_to_string (ret, GNUNET_YES)); 1634 GNUNET_STRINGS_relative_time_to_string (ret, GNUNET_YES));
1635 GNUNET_STATISTICS_update (GST_stats, 1635 GNUNET_STATISTICS_update (GST_stats,
1636 gettext_noop ("# ms throttling suggested"), 1636 gettext_noop ("# ms throttling suggested"),
1637 (int64_t) ret.rel_value_us / 1000LL, 1637 (int64_t) ret.rel_value_us / 1000LL,
1638 GNUNET_NO); 1638 GNUNET_NO);
1639 } 1639 }
1640 return ret; 1640 return ret;
@@ -1708,13 +1708,13 @@ send_session_connect (struct NeighbourAddress *na)
1708 struct GNUNET_TRANSPORT_PluginFunctions *papi; 1708 struct GNUNET_TRANSPORT_PluginFunctions *papi;
1709 struct SessionConnectMessage connect_msg; 1709 struct SessionConnectMessage connect_msg;
1710 1710
1711 if (NULL == (papi = GST_plugins_find (na->address->transport_name))) 1711 if (NULL == (papi = GST_plugins_find (na->address->transport_name)))
1712 { 1712 {
1713 GNUNET_break (0); 1713 GNUNET_break (0);
1714 return; 1714 return;
1715 } 1715 }
1716 if (NULL == na->session) 1716 if (NULL == na->session)
1717 na->session = papi->get_session (papi->cls, na->address); 1717 na->session = papi->get_session (papi->cls, na->address);
1718 if (NULL == na->session) 1718 if (NULL == na->session)
1719 { 1719 {
1720 GNUNET_break (0); 1720 GNUNET_break (0);
@@ -1750,13 +1750,13 @@ send_session_connect_ack_message (const struct GNUNET_HELLO_Address *address,
1750 struct GNUNET_TRANSPORT_PluginFunctions *papi; 1750 struct GNUNET_TRANSPORT_PluginFunctions *papi;
1751 struct SessionConnectMessage connect_msg; 1751 struct SessionConnectMessage connect_msg;
1752 1752
1753 if (NULL == (papi = GST_plugins_find (address->transport_name))) 1753 if (NULL == (papi = GST_plugins_find (address->transport_name)))
1754 { 1754 {
1755 GNUNET_break (0); 1755 GNUNET_break (0);
1756 return; 1756 return;
1757 } 1757 }
1758 if (NULL == session) 1758 if (NULL == session)
1759 session = papi->get_session (papi->cls, address); 1759 session = papi->get_session (papi->cls, address);
1760 if (NULL == session) 1760 if (NULL == session)
1761 { 1761 {
1762 GNUNET_break (0); 1762 GNUNET_break (0);
@@ -1788,7 +1788,7 @@ setup_neighbour (const struct GNUNET_PeerIdentity *peer)
1788 struct NeighbourMapEntry *n; 1788 struct NeighbourMapEntry *n;
1789 1789
1790 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1790 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1791 "Creating new neighbour entry for `%s'\n", 1791 "Creating new neighbour entry for `%s'\n",
1792 GNUNET_i2s (peer)); 1792 GNUNET_i2s (peer));
1793 n = MEMDEBUG_malloc (sizeof (struct NeighbourMapEntry), __LINE__); 1793 n = MEMDEBUG_malloc (sizeof (struct NeighbourMapEntry), __LINE__);
1794 n->id = *peer; 1794 n->id = *peer;
@@ -1842,7 +1842,7 @@ GST_neighbours_try_connect (const struct GNUNET_PeerIdentity *target)
1842{ 1842{
1843 struct NeighbourMapEntry *n; 1843 struct NeighbourMapEntry *n;
1844 1844
1845 if (NULL == neighbours) 1845 if (NULL == neighbours)
1846 { 1846 {
1847 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1847 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1848 "Asked to connect to peer `%s' during shutdown\n", 1848 "Asked to connect to peer `%s' during shutdown\n",
@@ -1881,7 +1881,7 @@ GST_neighbours_try_connect (const struct GNUNET_PeerIdentity *target)
1881 "Ignoring request to try to connect to `%s', already trying!\n", 1881 "Ignoring request to try to connect to `%s', already trying!\n",
1882 GNUNET_i2s (target)); 1882 GNUNET_i2s (target));
1883 return; /* already trying */ 1883 return; /* already trying */
1884 case S_CONNECTED: 1884 case S_CONNECTED:
1885 case S_RECONNECT_ATS: 1885 case S_RECONNECT_ATS:
1886 case S_RECONNECT_BLACKLIST: 1886 case S_RECONNECT_BLACKLIST:
1887 case S_RECONNECT_SENT: 1887 case S_RECONNECT_SENT:
@@ -1896,8 +1896,8 @@ GST_neighbours_try_connect (const struct GNUNET_PeerIdentity *target)
1896 free_neighbour (n, GNUNET_NO); 1896 free_neighbour (n, GNUNET_NO);
1897 break; 1897 break;
1898 case S_DISCONNECT_FINISHED: 1898 case S_DISCONNECT_FINISHED:
1899 /* should not be possible */ 1899 /* should not be possible */
1900 GNUNET_assert (0); 1900 GNUNET_assert (0);
1901 default: 1901 default:
1902 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Unhandled state `%s' \n",print_state (n->state)); 1902 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Unhandled state `%s' \n",print_state (n->state));
1903 GNUNET_break (0); 1903 GNUNET_break (0);
@@ -1905,8 +1905,8 @@ GST_neighbours_try_connect (const struct GNUNET_PeerIdentity *target)
1905 break; 1905 break;
1906 } 1906 }
1907 } 1907 }
1908 n = setup_neighbour (target); 1908 n = setup_neighbour (target);
1909 n->state = S_INIT_ATS; 1909 n->state = S_INIT_ATS;
1910 n->timeout = GNUNET_TIME_relative_to_absolute (ATS_RESPONSE_TIMEOUT); 1910 n->timeout = GNUNET_TIME_relative_to_absolute (ATS_RESPONSE_TIMEOUT);
1911 1911
1912 GNUNET_ATS_reset_backoff (GST_ats, target); 1912 GNUNET_ATS_reset_backoff (GST_ats, target);
@@ -1988,7 +1988,7 @@ handle_test_blacklist_cont (void *cls,
1988 n->primary_address.session, 1988 n->primary_address.session,
1989 n->connect_ack_timestamp); 1989 n->connect_ack_timestamp);
1990 } 1990 }
1991 break; 1991 break;
1992 case S_CONNECT_RECV_BLACKLIST_INBOUND: 1992 case S_CONNECT_RECV_BLACKLIST_INBOUND:
1993 if (GNUNET_OK == result) 1993 if (GNUNET_OK == result)
1994 GST_ats_add_address (bcc->na.address, bcc->na.session); 1994 GST_ats_add_address (bcc->na.address, bcc->na.session);
@@ -2011,7 +2011,7 @@ handle_test_blacklist_cont (void *cls,
2011 send_session_connect_ack_message (bcc->na.address, 2011 send_session_connect_ack_message (bcc->na.address,
2012 bcc->na.session, 2012 bcc->na.session,
2013 n->connect_ack_timestamp); 2013 n->connect_ack_timestamp);
2014 if (1 == n->send_connect_ack) 2014 if (1 == n->send_connect_ack)
2015 n->send_connect_ack = 2; 2015 n->send_connect_ack = 2;
2016 } 2016 }
2017 else 2017 else
@@ -2038,13 +2038,13 @@ handle_test_blacklist_cont (void *cls,
2038 n->primary_address.session, 2038 n->primary_address.session,
2039 n->connect_ack_timestamp); 2039 n->connect_ack_timestamp);
2040 } 2040 }
2041 break; 2041 break;
2042 case S_CONNECTED: 2042 case S_CONNECTED:
2043 /* already connected, don't care about blacklist */ 2043 /* already connected, don't care about blacklist */
2044 break; 2044 break;
2045 case S_RECONNECT_ATS: 2045 case S_RECONNECT_ATS:
2046 /* still waiting on ATS suggestion, don't care about blacklist */ 2046 /* still waiting on ATS suggestion, don't care about blacklist */
2047 break; 2047 break;
2048 case S_RECONNECT_BLACKLIST: 2048 case S_RECONNECT_BLACKLIST:
2049 if ( (GNUNET_OK == result) && 2049 if ( (GNUNET_OK == result) &&
2050 (1 == n->send_connect_ack) ) 2050 (1 == n->send_connect_ack) )
@@ -2083,7 +2083,7 @@ handle_test_blacklist_cont (void *cls,
2083 n->primary_address.session, 2083 n->primary_address.session,
2084 n->connect_ack_timestamp); 2084 n->connect_ack_timestamp);
2085 } 2085 }
2086 break; 2086 break;
2087 case S_CONNECTED_SWITCHING_BLACKLIST: 2087 case S_CONNECTED_SWITCHING_BLACKLIST:
2088 if (GNUNET_YES != address_matches (&bcc->na, &n->alternative_address)) 2088 if (GNUNET_YES != address_matches (&bcc->na, &n->alternative_address))
2089 break; /* result for an address we currently don't care about */ 2089 break; /* result for an address we currently don't care about */
@@ -2111,7 +2111,7 @@ handle_test_blacklist_cont (void *cls,
2111 n->primary_address.session, 2111 n->primary_address.session,
2112 n->connect_ack_timestamp); 2112 n->connect_ack_timestamp);
2113 } 2113 }
2114 break; 2114 break;
2115 case S_DISCONNECT: 2115 case S_DISCONNECT:
2116 /* Nothing to do here, ATS will already do what can be done */ 2116 /* Nothing to do here, ATS will already do what can be done */
2117 break; 2117 break;
@@ -2163,10 +2163,10 @@ check_blacklist (const struct GNUNET_PeerIdentity *peer,
2163 GNUNET_CONTAINER_DLL_insert (bc_head, 2163 GNUNET_CONTAINER_DLL_insert (bc_head,
2164 bc_tail, 2164 bc_tail,
2165 bcc); 2165 bcc);
2166 if (NULL != (bc = GST_blacklist_test_allowed (peer, 2166 if (NULL != (bc = GST_blacklist_test_allowed (peer,
2167 address->transport_name, 2167 address->transport_name,
2168 &handle_test_blacklist_cont, bcc))) 2168 &handle_test_blacklist_cont, bcc)))
2169 bcc->bc = bc; 2169 bcc->bc = bc;
2170 /* if NULL == bc, 'cont' was already called and 'bcc' already free'd, so 2170 /* if NULL == bc, 'cont' was already called and 'bcc' already free'd, so
2171 we must only store 'bc' if 'bc' is non-NULL... */ 2171 we must only store 'bc' if 'bc' is non-NULL... */
2172} 2172}
@@ -2193,7 +2193,7 @@ GST_neighbours_handle_connect (const struct GNUNET_MessageHeader *message,
2193 struct GNUNET_TIME_Absolute ts; 2193 struct GNUNET_TIME_Absolute ts;
2194 2194
2195 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2195 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2196 "Received CONNECT message from peer `%s'\n", 2196 "Received CONNECT message from peer `%s'\n",
2197 GNUNET_i2s (peer)); 2197 GNUNET_i2s (peer));
2198 2198
2199 if (ntohs (message->size) != sizeof (struct SessionConnectMessage)) 2199 if (ntohs (message->size) != sizeof (struct SessionConnectMessage))
@@ -2213,7 +2213,7 @@ GST_neighbours_handle_connect (const struct GNUNET_MessageHeader *message,
2213 n->connect_ack_timestamp = ts; 2213 n->connect_ack_timestamp = ts;
2214 2214
2215 switch (n->state) 2215 switch (n->state)
2216 { 2216 {
2217 case S_NOT_CONNECTED: 2217 case S_NOT_CONNECTED:
2218 n->state = S_CONNECT_RECV_BLACKLIST_INBOUND; 2218 n->state = S_CONNECT_RECV_BLACKLIST_INBOUND;
2219 /* Do a blacklist check for the new address */ 2219 /* Do a blacklist check for the new address */
@@ -2229,7 +2229,7 @@ GST_neighbours_handle_connect (const struct GNUNET_MessageHeader *message,
2229 case S_CONNECT_RECV_ATS: 2229 case S_CONNECT_RECV_ATS:
2230 case S_CONNECT_RECV_BLACKLIST: 2230 case S_CONNECT_RECV_BLACKLIST:
2231 case S_CONNECT_RECV_ACK: 2231 case S_CONNECT_RECV_ACK:
2232 /* It can never hurt to have an alternative address in the above cases, 2232 /* It can never hurt to have an alternative address in the above cases,
2233 see if it is allowed */ 2233 see if it is allowed */
2234 check_blacklist (peer, ts, address, session); 2234 check_blacklist (peer, ts, address, session);
2235 break; 2235 break;
@@ -2247,7 +2247,7 @@ GST_neighbours_handle_connect (const struct GNUNET_MessageHeader *message,
2247 case S_RECONNECT_ATS: 2247 case S_RECONNECT_ATS:
2248 case S_RECONNECT_BLACKLIST: 2248 case S_RECONNECT_BLACKLIST:
2249 case S_RECONNECT_SENT: 2249 case S_RECONNECT_SENT:
2250 /* It can never hurt to have an alternative address in the above cases, 2250 /* It can never hurt to have an alternative address in the above cases,
2251 see if it is allowed */ 2251 see if it is allowed */
2252 check_blacklist (peer, ts, address, session); 2252 check_blacklist (peer, ts, address, session);
2253 break; 2253 break;
@@ -2286,7 +2286,7 @@ GST_neighbours_handle_connect (const struct GNUNET_MessageHeader *message,
2286 2286
2287/** 2287/**
2288 * For an existing neighbour record, set the active connection to 2288 * For an existing neighbour record, set the active connection to
2289 * use the given address. 2289 * use the given address.
2290 * 2290 *
2291 * @param peer identity of the peer to switch the address for 2291 * @param peer identity of the peer to switch the address for
2292 * @param address address of the other peer, NULL if other peer 2292 * @param address address of the other peer, NULL if other peer
@@ -2355,7 +2355,7 @@ GST_neighbours_switch_to_address (const struct GNUNET_PeerIdentity *peer,
2355 { 2355 {
2356 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2356 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2357 "Failed to obtain new session for peer `%s' and address '%s'\n", 2357 "Failed to obtain new session for peer `%s' and address '%s'\n",
2358 GNUNET_i2s (&address->peer), GST_plugins_a2s (address)); 2358 GNUNET_i2s (&address->peer), GST_plugins_a2s (address));
2359 GNUNET_ATS_address_destroyed (GST_ats, address, NULL); 2359 GNUNET_ATS_address_destroyed (GST_ats, address, NULL);
2360 return; 2360 return;
2361 } 2361 }
@@ -2529,7 +2529,7 @@ master_task (void *cls,
2529 struct GNUNET_TIME_Relative delay; 2529 struct GNUNET_TIME_Relative delay;
2530 2530
2531 n->task = GNUNET_SCHEDULER_NO_TASK; 2531 n->task = GNUNET_SCHEDULER_NO_TASK;
2532 delay = GNUNET_TIME_absolute_get_remaining (n->timeout); 2532 delay = GNUNET_TIME_absolute_get_remaining (n->timeout);
2533 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2533 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2534 "Master task runs for neighbour `%s' in state %s with timeout in %s\n", 2534 "Master task runs for neighbour `%s' in state %s with timeout in %s\n",
2535 GNUNET_i2s (&n->id), 2535 GNUNET_i2s (&n->id),
@@ -2698,11 +2698,11 @@ master_task (void *cls,
2698 default: 2698 default:
2699 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Unhandled state `%s' \n",print_state (n->state)); 2699 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Unhandled state `%s' \n",print_state (n->state));
2700 GNUNET_break (0); 2700 GNUNET_break (0);
2701 break; 2701 break;
2702 } 2702 }
2703 if ( (S_CONNECTED_SWITCHING_CONNECT_SENT == n->state) || 2703 if ( (S_CONNECTED_SWITCHING_CONNECT_SENT == n->state) ||
2704 (S_CONNECTED_SWITCHING_BLACKLIST == n->state) || 2704 (S_CONNECTED_SWITCHING_BLACKLIST == n->state) ||
2705 (S_CONNECTED == n->state) ) 2705 (S_CONNECTED == n->state) )
2706 { 2706 {
2707 /* if we are *now* in one of these three states, we're sending 2707 /* if we are *now* in one of these three states, we're sending
2708 keep alive messages, so we need to consider the keepalive 2708 keep alive messages, so we need to consider the keepalive
@@ -2789,14 +2789,14 @@ GST_neighbours_handle_connect_ack (const struct GNUNET_MessageHeader *message,
2789 gettext_noop 2789 gettext_noop
2790 ("# unexpected CONNECT_ACK messages (not ready)"), 2790 ("# unexpected CONNECT_ACK messages (not ready)"),
2791 1, GNUNET_NO); 2791 1, GNUNET_NO);
2792 break; 2792 break;
2793 case S_CONNECT_SENT: 2793 case S_CONNECT_SENT:
2794 if (ts.abs_value_us != n->primary_address.connect_timestamp.abs_value_us) 2794 if (ts.abs_value_us != n->primary_address.connect_timestamp.abs_value_us)
2795 break; /* ACK does not match our original CONNECT message */ 2795 break; /* ACK does not match our original CONNECT message */
2796 n->state = S_CONNECTED; 2796 n->state = S_CONNECTED;
2797 n->timeout = GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT); 2797 n->timeout = GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT);
2798 GNUNET_STATISTICS_set (GST_stats, 2798 GNUNET_STATISTICS_set (GST_stats,
2799 gettext_noop ("# peers connected"), 2799 gettext_noop ("# peers connected"),
2800 ++neighbours_connected, 2800 ++neighbours_connected,
2801 GNUNET_NO); 2801 GNUNET_NO);
2802 connect_notify_cb (callback_cls, &n->id, 2802 connect_notify_cb (callback_cls, &n->id,
@@ -2858,7 +2858,7 @@ GST_neighbours_handle_connect_ack (const struct GNUNET_MessageHeader *message,
2858 GNUNET_YES); 2858 GNUNET_YES);
2859 free_address (&n->alternative_address); 2859 free_address (&n->alternative_address);
2860 send_session_ack_message (n); 2860 send_session_ack_message (n);
2861 break; 2861 break;
2862 case S_DISCONNECT: 2862 case S_DISCONNECT:
2863 GNUNET_STATISTICS_update (GST_stats, 2863 GNUNET_STATISTICS_update (GST_stats,
2864 gettext_noop 2864 gettext_noop
@@ -2871,7 +2871,7 @@ GST_neighbours_handle_connect_ack (const struct GNUNET_MessageHeader *message,
2871 default: 2871 default:
2872 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Unhandled state `%s' \n",print_state (n->state)); 2872 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Unhandled state `%s' \n",print_state (n->state));
2873 GNUNET_break (0); 2873 GNUNET_break (0);
2874 break; 2874 break;
2875 } 2875 }
2876} 2876}
2877 2877
@@ -2945,7 +2945,7 @@ GST_neighbours_session_terminated (const struct GNUNET_PeerIdentity *peer,
2945 n->suggest_handle = GNUNET_ATS_suggest_address (GST_ats, &n->id); 2945 n->suggest_handle = GNUNET_ATS_suggest_address (GST_ats, &n->id);
2946 break; 2946 break;
2947 case S_CONNECT_RECV_BLACKLIST_INBOUND: 2947 case S_CONNECT_RECV_BLACKLIST_INBOUND:
2948 case S_CONNECT_RECV_ATS: 2948 case S_CONNECT_RECV_ATS:
2949 case S_CONNECT_RECV_BLACKLIST: 2949 case S_CONNECT_RECV_BLACKLIST:
2950 case S_CONNECT_RECV_ACK: 2950 case S_CONNECT_RECV_ACK:
2951 /* error on inbound session; free neighbour entirely */ 2951 /* error on inbound session; free neighbour entirely */
@@ -2972,7 +2972,7 @@ GST_neighbours_session_terminated (const struct GNUNET_PeerIdentity *peer,
2972 break; 2972 break;
2973 case S_CONNECTED_SWITCHING_BLACKLIST: 2973 case S_CONNECTED_SWITCHING_BLACKLIST:
2974 /* primary went down while we were checking secondary against 2974 /* primary went down while we were checking secondary against
2975 blacklist, adopt secondary as primary */ 2975 blacklist, adopt secondary as primary */
2976 free_address (&n->primary_address); 2976 free_address (&n->primary_address);
2977 n->primary_address = n->alternative_address; 2977 n->primary_address = n->alternative_address;
2978 memset (&n->alternative_address, 0, sizeof (struct NeighbourAddress)); 2978 memset (&n->alternative_address, 0, sizeof (struct NeighbourAddress));
@@ -2981,7 +2981,7 @@ GST_neighbours_session_terminated (const struct GNUNET_PeerIdentity *peer,
2981 break; 2981 break;
2982 case S_CONNECTED_SWITCHING_CONNECT_SENT: 2982 case S_CONNECTED_SWITCHING_CONNECT_SENT:
2983 /* primary went down while we were waiting for CONNECT_ACK on secondary; 2983 /* primary went down while we were waiting for CONNECT_ACK on secondary;
2984 secondary as primary */ 2984 secondary as primary */
2985 free_address (&n->primary_address); 2985 free_address (&n->primary_address);
2986 n->primary_address = n->alternative_address; 2986 n->primary_address = n->alternative_address;
2987 memset (&n->alternative_address, 0, sizeof (struct NeighbourAddress)); 2987 memset (&n->alternative_address, 0, sizeof (struct NeighbourAddress));
@@ -3026,7 +3026,7 @@ GST_neighbours_handle_session_ack (const struct GNUNET_MessageHeader *message,
3026{ 3026{
3027 struct NeighbourMapEntry *n; 3027 struct NeighbourMapEntry *n;
3028 3028
3029 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 3029 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
3030 "Received SESSION_ACK message from peer `%s'\n", 3030 "Received SESSION_ACK message from peer `%s'\n",
3031 GNUNET_i2s (peer)); 3031 GNUNET_i2s (peer));
3032 if (ntohs (message->size) != sizeof (struct GNUNET_MessageHeader)) 3032 if (ntohs (message->size) != sizeof (struct GNUNET_MessageHeader))
@@ -3049,8 +3049,8 @@ GST_neighbours_handle_session_ack (const struct GNUNET_MessageHeader *message,
3049 } 3049 }
3050 n->state = S_CONNECTED; 3050 n->state = S_CONNECTED;
3051 n->timeout = GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT); 3051 n->timeout = GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT);
3052 GNUNET_STATISTICS_set (GST_stats, 3052 GNUNET_STATISTICS_set (GST_stats,
3053 gettext_noop ("# peers connected"), 3053 gettext_noop ("# peers connected"),
3054 ++neighbours_connected, 3054 ++neighbours_connected,
3055 GNUNET_NO); 3055 GNUNET_NO);
3056 connect_notify_cb (callback_cls, &n->id, 3056 connect_notify_cb (callback_cls, &n->id,
@@ -3263,7 +3263,7 @@ GST_neighbours_iterate (GST_NeighbourIterator cb, void *cb_cls)
3263{ 3263{
3264 struct IteratorContext ic; 3264 struct IteratorContext ic;
3265 3265
3266 if (NULL == neighbours) 3266 if (NULL == neighbours)
3267 return; /* can happen during shutdown */ 3267 return; /* can happen during shutdown */
3268 ic.cb = cb; 3268 ic.cb = cb;
3269 ic.cb_cls = cb_cls; 3269 ic.cb_cls = cb_cls;
@@ -3296,7 +3296,7 @@ GST_neighbours_force_disconnect (const struct GNUNET_PeerIdentity *target)
3296 * Obtain current latency information for the given neighbour. 3296 * Obtain current latency information for the given neighbour.
3297 * 3297 *
3298 * @param peer to get the latency for 3298 * @param peer to get the latency for
3299 * @return observed latency of the address, FOREVER if the 3299 * @return observed latency of the address, FOREVER if the
3300 * the connection is not up 3300 * the connection is not up
3301 */ 3301 */
3302struct GNUNET_TIME_Relative 3302struct GNUNET_TIME_Relative
@@ -3305,7 +3305,7 @@ GST_neighbour_get_latency (const struct GNUNET_PeerIdentity *peer)
3305 struct NeighbourMapEntry *n; 3305 struct NeighbourMapEntry *n;
3306 3306
3307 n = lookup_neighbour (peer); 3307 n = lookup_neighbour (peer);
3308 if (NULL == n) 3308 if (NULL == n)
3309 return GNUNET_TIME_UNIT_FOREVER_REL; 3309 return GNUNET_TIME_UNIT_FOREVER_REL;
3310 switch (n->state) 3310 switch (n->state)
3311 { 3311 {
@@ -3332,7 +3332,7 @@ GST_neighbour_get_latency (const struct GNUNET_PeerIdentity *peer)
3332 GNUNET_break (0); 3332 GNUNET_break (0);
3333 break; 3333 break;
3334 } 3334 }
3335 return GNUNET_TIME_UNIT_FOREVER_REL; 3335 return GNUNET_TIME_UNIT_FOREVER_REL;
3336} 3336}
3337 3337
3338 3338
@@ -3388,13 +3388,13 @@ GST_neighbours_start (void *cls,
3388 * @return GNUNET_OK (continue to iterate) 3388 * @return GNUNET_OK (continue to iterate)
3389 */ 3389 */
3390static int 3390static int
3391disconnect_all_neighbours (void *cls, 3391disconnect_all_neighbours (void *cls,
3392 const struct GNUNET_PeerIdentity *key, 3392 const struct GNUNET_PeerIdentity *key,
3393 void *value) 3393 void *value)
3394{ 3394{
3395 struct NeighbourMapEntry *n = value; 3395 struct NeighbourMapEntry *n = value;
3396 3396
3397 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 3397 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
3398 "Disconnecting peer `%4s', %s\n", 3398 "Disconnecting peer `%4s', %s\n",
3399 GNUNET_i2s (&n->id), "SHUTDOWN_TASK"); 3399 GNUNET_i2s (&n->id), "SHUTDOWN_TASK");
3400 n->state = S_DISCONNECT_FINISHED; 3400 n->state = S_DISCONNECT_FINISHED;
@@ -3411,7 +3411,7 @@ GST_neighbours_stop ()
3411{ 3411{
3412 if (NULL == neighbours) 3412 if (NULL == neighbours)
3413 return; 3413 return;
3414 GNUNET_CONTAINER_multipeermap_iterate (neighbours, 3414 GNUNET_CONTAINER_multipeermap_iterate (neighbours,
3415 &disconnect_all_neighbours, 3415 &disconnect_all_neighbours,
3416 NULL); 3416 NULL);
3417 GNUNET_CONTAINER_multipeermap_destroy (neighbours); 3417 GNUNET_CONTAINER_multipeermap_destroy (neighbours);