aboutsummaryrefslogtreecommitdiff
path: root/src/transport
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2013-12-12 16:17:10 +0000
committerChristian Grothoff <christian@grothoff.org>2013-12-12 16:17:10 +0000
commitb10f26ae8caab6299b94f00a319a6424be57a386 (patch)
tree5764c07a2a61a8e2fb8f0a94c885942b5fb028a5 /src/transport
parent54811540b75f59ca8dd54f96d6fe9f8f3743011d (diff)
downloadgnunet-b10f26ae8caab6299b94f00a319a6424be57a386.tar.gz
gnunet-b10f26ae8caab6299b94f00a319a6424be57a386.zip
-be stricter during handshake, close sessions with broken interactions aggressively
Diffstat (limited to 'src/transport')
-rw-r--r--src/transport/gnunet-service-transport.c78
-rw-r--r--src/transport/gnunet-service-transport.h4
-rw-r--r--src/transport/gnunet-service-transport_neighbours.c112
-rw-r--r--src/transport/gnunet-service-transport_neighbours.h66
-rw-r--r--src/transport/gnunet-service-transport_plugins.h1
-rw-r--r--src/transport/gnunet-service-transport_validation.c121
-rw-r--r--src/transport/gnunet-service-transport_validation.h9
-rw-r--r--src/transport/plugin_transport_tcp.c38
-rw-r--r--src/transport/test_transport_defaults.conf4
-rw-r--r--src/transport/transport.conf.in2
10 files changed, 273 insertions, 162 deletions
diff --git a/src/transport/gnunet-service-transport.c b/src/transport/gnunet-service-transport.c
index d96a284c7..6b62c17fe 100644
--- a/src/transport/gnunet-service-transport.c
+++ b/src/transport/gnunet-service-transport.c
@@ -124,7 +124,6 @@ process_hello_update (void *cls, const struct GNUNET_MessageHeader *hello)
124} 124}
125 125
126 126
127
128/** 127/**
129 * We received some payload. Prepare to pass it on to our clients. 128 * We received some payload. Prepare to pass it on to our clients.
130 * 129 *
@@ -178,14 +177,36 @@ process_payload (const struct GNUNET_PeerIdentity *peer,
178 177
179 178
180/** 179/**
180 * Force plugin to terminate session due to communication
181 * issue.
182 *
183 * @param plugin_name name of the plugin
184 * @param session session to termiante
185 */
186static void
187kill_session (const char *plugin_name,
188 struct Session *session)
189{
190 struct GNUNET_TRANSPORT_PluginFunctions *plugin;
191
192 plugin = GST_plugins_find (plugin_name);
193 if (NULL == plugin)
194 {
195 GNUNET_break (0);
196 return;
197 }
198 plugin->disconnect_session (plugin->cls,
199 session);
200}
201
202
203/**
181 * Function called by the transport for each received message. 204 * Function called by the transport for each received message.
182 * This function should also be called with "NULL" for the
183 * message to signal that the other peer disconnected.
184 * 205 *
185 * @param cls closure, const char* with the name of the plugin we received the message from 206 * @param cls closure, const char* with the name of the plugin we received the message from
186 * @param peer (claimed) identity of the other peer 207 * @param peer (claimed) identity of the other peer
187 * @param message the message, NULL if we only care about 208 * @param message the message, NULL if we only care about
188 * learning about the delay until we should receive again -- FIXME! 209 * learning about the delay until we should receive again
189 * @param session identifier used for this session (NULL for plugins 210 * @param session identifier used for this session (NULL for plugins
190 * that do not offer bi-directional communication to the sender 211 * that do not offer bi-directional communication to the sender
191 * using the same "connection") 212 * using the same "connection")
@@ -236,30 +257,57 @@ GST_receive_callback (void *cls,
236 /* Legacy HELLO message, discard */ 257 /* Legacy HELLO message, discard */
237 return ret; 258 return ret;
238 case GNUNET_MESSAGE_TYPE_HELLO: 259 case GNUNET_MESSAGE_TYPE_HELLO:
239 GST_validation_handle_hello (message); 260 if (GNUNET_OK !=
261 GST_validation_handle_hello (message))
262 {
263 GNUNET_break_op (0);
264 kill_session (plugin_name, session);
265 }
240 return ret; 266 return ret;
241 case GNUNET_MESSAGE_TYPE_TRANSPORT_PING: 267 case GNUNET_MESSAGE_TYPE_TRANSPORT_PING:
242 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK, 268 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK,
243 "Processing `%s' from `%s'\n", "PING", 269 "Processing `%s' from `%s'\n", "PING",
244 (sender_address != 270 (sender_address !=
245 NULL) ? GST_plugins_a2s (&address) : TRANSPORT_SESSION_INBOUND_STRING); 271 NULL) ? GST_plugins_a2s (&address) : TRANSPORT_SESSION_INBOUND_STRING);
246 GST_validation_handle_ping (peer, message, &address, session); 272 if (GNUNET_OK !=
273 GST_validation_handle_ping (peer, message, &address, session))
274 kill_session (plugin_name, session);
247 break; 275 break;
248 case GNUNET_MESSAGE_TYPE_TRANSPORT_PONG: 276 case GNUNET_MESSAGE_TYPE_TRANSPORT_PONG:
249 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK, 277 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK,
250 "Processing `%s' from `%s'\n", "PONG", 278 "Processing `%s' from `%s'\n", "PONG",
251 (sender_address != 279 (sender_address !=
252 NULL) ? GST_plugins_a2s (&address) : TRANSPORT_SESSION_INBOUND_STRING); 280 NULL) ? GST_plugins_a2s (&address) : TRANSPORT_SESSION_INBOUND_STRING);
253 GST_validation_handle_pong (peer, message); 281 if (GNUNET_OK !=
282 GST_validation_handle_pong (peer, message))
283 {
284 GNUNET_break_op (0);
285 kill_session (plugin_name, session);
286 }
254 break; 287 break;
255 case GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_CONNECT: 288 case GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_CONNECT:
256 GST_neighbours_handle_connect (message, peer, &address, session); 289 if (GNUNET_OK !=
290 GST_neighbours_handle_connect (message, peer, &address, session))
291 {
292 GNUNET_break_op (0);
293 kill_session (plugin_name, session);
294 }
257 break; 295 break;
258 case GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_CONNECT_ACK: 296 case GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_CONNECT_ACK:
259 GST_neighbours_handle_connect_ack (message, peer, &address, session); 297 if (GNUNET_OK !=
298 GST_neighbours_handle_connect_ack (message, peer, &address, session))
299 {
300 GNUNET_break_op (0);
301 kill_session (plugin_name, session);
302 }
260 break; 303 break;
261 case GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_ACK: 304 case GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_ACK:
262 GST_neighbours_handle_session_ack (message, peer, &address, session); 305 if (GNUNET_OK !=
306 GST_neighbours_handle_session_ack (message, peer, &address, session))
307 {
308 GNUNET_break_op (0);
309 kill_session (plugin_name, session);
310 }
263 break; 311 break;
264 case GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_DISCONNECT: 312 case GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_DISCONNECT:
265 GST_neighbours_handle_disconnect_message (peer, message); 313 GST_neighbours_handle_disconnect_message (peer, message);
@@ -370,6 +418,7 @@ plugin_env_address_to_type (void *cls,
370 size_t addrlen) 418 size_t addrlen)
371{ 419{
372 struct GNUNET_ATS_Information ats; 420 struct GNUNET_ATS_Information ats;
421
373 ats.type = htonl (GNUNET_ATS_NETWORK_TYPE); 422 ats.type = htonl (GNUNET_ATS_NETWORK_TYPE);
374 ats.value = htonl (GNUNET_ATS_NET_UNSPECIFIED); 423 ats.value = htonl (GNUNET_ATS_NET_UNSPECIFIED);
375 if (GST_ats == NULL) 424 if (GST_ats == NULL)
@@ -381,9 +430,10 @@ plugin_env_address_to_type (void *cls,
381 ((addr->sa_family != AF_INET6) && (addrlen != sizeof (struct sockaddr_in6))) && 430 ((addr->sa_family != AF_INET6) && (addrlen != sizeof (struct sockaddr_in6))) &&
382 (addr->sa_family != AF_UNIX)) 431 (addr->sa_family != AF_UNIX))
383 { 432 {
384 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Malformed address with length %u `%s'\n", 433 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
434 "Malformed address with length %u `%s'\n",
385 addrlen, 435 addrlen,
386 GNUNET_a2s(addr, addrlen)); 436 GNUNET_a2s (addr, addrlen));
387 GNUNET_break (0); 437 GNUNET_break (0);
388 return ats; 438 return ats;
389 } 439 }
@@ -621,8 +671,8 @@ ats_request_address_change (void *cls,
621 return; 671 return;
622 } 672 }
623 GST_neighbours_switch_to_address (&address->peer, address, session, ats, 673 GST_neighbours_switch_to_address (&address->peer, address, session, ats,
624 ats_count, bandwidth_in, 674 ats_count, bandwidth_in,
625 bandwidth_out); 675 bandwidth_out);
626} 676}
627 677
628 678
diff --git a/src/transport/gnunet-service-transport.h b/src/transport/gnunet-service-transport.h
index 66da0163e..01a821a4e 100644
--- a/src/transport/gnunet-service-transport.h
+++ b/src/transport/gnunet-service-transport.h
@@ -101,7 +101,7 @@ GST_receive_callback (void *cls,
101 */ 101 */
102void 102void
103GST_ats_add_address (const struct GNUNET_HELLO_Address *address, 103GST_ats_add_address (const struct GNUNET_HELLO_Address *address,
104 struct Session *session); 104 struct Session *session);
105 105
106 106
107/** 107/**
@@ -111,7 +111,7 @@ GST_ats_add_address (const struct GNUNET_HELLO_Address *address,
111 * @param address the address 111 * @param address the address
112 * @param session the session 112 * @param session the session
113 * @param ats performance information 113 * @param ats performance information
114 * @param ats_count number of elements in ats 114 * @param ats_count number of elements in @a ats
115 */ 115 */
116void 116void
117GST_ats_update_metrics (const struct GNUNET_PeerIdentity *peer, 117GST_ats_update_metrics (const struct GNUNET_PeerIdentity *peer,
diff --git a/src/transport/gnunet-service-transport_neighbours.c b/src/transport/gnunet-service-transport_neighbours.c
index a3b5639a0..fe3cadc56 100644
--- a/src/transport/gnunet-service-transport_neighbours.c
+++ b/src/transport/gnunet-service-transport_neighbours.c
@@ -774,7 +774,7 @@ send_outbound_quota (const struct GNUNET_PeerIdentity *target,
774 * Release its resources and give appropriate notifications 774 * Release its resources and give appropriate notifications
775 * to ATS and other subsystems. 775 * to ATS and other subsystems.
776 * 776 *
777 * @param na address we are done with; 'na' itself must NOT be 'free'd, only the contents! 777 * @param na address we are done with; @a na itself must NOT be 'free'd, only the contents!
778 */ 778 */
779static void 779static void
780free_address (struct NeighbourAddress *na) 780free_address (struct NeighbourAddress *na)
@@ -1817,10 +1817,15 @@ handle_test_blacklist_cont (void *cls,
1817 struct NeighbourMapEntry *n; 1817 struct NeighbourMapEntry *n;
1818 1818
1819 bcc->bc = NULL; 1819 bcc->bc = NULL;
1820 GNUNET_CONTAINER_DLL_remove (bc_head,
1821 bc_tail,
1822 bcc);
1820 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1823 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1821 "Connection to new address of peer `%s' based on blacklist is `%s'\n", 1824 "Connection to new address of peer `%s' based on blacklist is `%s'\n",
1822 GNUNET_i2s (peer), 1825 GNUNET_i2s (peer),
1823 (GNUNET_OK == result) ? "allowed" : "FORBIDDEN"); 1826 (GNUNET_OK == result) ? "allowed" : "FORBIDDEN");
1827 if (GNUNET_OK == result)
1828 GST_ats_add_address (bcc->na.address, bcc->na.session);
1824 if (NULL == (n = lookup_neighbour (peer))) 1829 if (NULL == (n = lookup_neighbour (peer)))
1825 goto cleanup; /* nobody left to care about new address */ 1830 goto cleanup; /* nobody left to care about new address */
1826 switch (n->state) 1831 switch (n->state)
@@ -1831,7 +1836,8 @@ handle_test_blacklist_cont (void *cls,
1831 free_neighbour (n, GNUNET_NO); 1836 free_neighbour (n, GNUNET_NO);
1832 break; 1837 break;
1833 case S_INIT_ATS: 1838 case S_INIT_ATS:
1834 /* still waiting on ATS suggestion */ 1839 /* waiting on ATS suggestion; still, pass address to ATS as a
1840 possibility */
1835 break; 1841 break;
1836 case S_INIT_BLACKLIST: 1842 case S_INIT_BLACKLIST:
1837 /* check if the address the blacklist was fine with matches 1843 /* check if the address the blacklist was fine with matches
@@ -1877,20 +1883,21 @@ handle_test_blacklist_cont (void *cls,
1877 } 1883 }
1878 break; 1884 break;
1879 case S_CONNECT_RECV_BLACKLIST_INBOUND: 1885 case S_CONNECT_RECV_BLACKLIST_INBOUND:
1880 if (GNUNET_OK == result)
1881 GST_ats_add_address (bcc->na.address, bcc->na.session);
1882
1883 n->state = S_CONNECT_RECV_ATS; 1886 n->state = S_CONNECT_RECV_ATS;
1884 n->timeout = GNUNET_TIME_relative_to_absolute (ATS_RESPONSE_TIMEOUT); 1887 n->timeout = GNUNET_TIME_relative_to_absolute (ATS_RESPONSE_TIMEOUT);
1885 GNUNET_ATS_reset_backoff (GST_ats, peer); 1888 GNUNET_ATS_reset_backoff (GST_ats, peer);
1886 n->suggest_handle = GNUNET_ATS_suggest_address (GST_ats, peer); 1889 n->suggest_handle = GNUNET_ATS_suggest_address (GST_ats, peer);
1887 break; 1890 break;
1888 case S_CONNECT_RECV_ATS: 1891 case S_CONNECT_RECV_ATS:
1889 /* still waiting on ATS suggestion, don't care about blacklist */ 1892 /* waiting on ATS suggestion, don't care about blacklist */
1890 break; 1893 break;
1891 case S_CONNECT_RECV_BLACKLIST: 1894 case S_CONNECT_RECV_BLACKLIST:
1892 if (GNUNET_YES != address_matches (&bcc->na, &n->primary_address)) 1895 if (GNUNET_YES != address_matches (&bcc->na, &n->primary_address))
1896 {
1897 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1898 "Blacklist result ignored, as it is not for our primary address\n");
1893 break; /* result for an address we currently don't care about */ 1899 break; /* result for an address we currently don't care about */
1900 }
1894 if (GNUNET_OK == result) 1901 if (GNUNET_OK == result)
1895 { 1902 {
1896 n->timeout = GNUNET_TIME_relative_to_absolute (SETUP_CONNECTION_TIMEOUT); 1903 n->timeout = GNUNET_TIME_relative_to_absolute (SETUP_CONNECTION_TIMEOUT);
@@ -1903,10 +1910,20 @@ handle_test_blacklist_cont (void *cls,
1903 } 1910 }
1904 else 1911 else
1905 { 1912 {
1906 // FIXME: should also possibly destroy session with plugin!? 1913 struct GNUNET_TRANSPORT_PluginFunctions *plugin;
1914
1915 plugin = GST_plugins_find (bcc->na.address->transport_name);
1916 if ( (NULL != plugin) &&
1917 (NULL != bcc->na.session) )
1918 {
1919 plugin->disconnect_session (plugin->cls,
1920 bcc->na.session);
1921 break;
1922 }
1923 GNUNET_break (NULL != plugin);
1907 GNUNET_ATS_address_destroyed (GST_ats, 1924 GNUNET_ATS_address_destroyed (GST_ats,
1908 bcc->na.address, 1925 bcc->na.address,
1909 NULL); 1926 NULL);
1910 free_address (&n->primary_address); 1927 free_address (&n->primary_address);
1911 n->state = S_INIT_ATS; 1928 n->state = S_INIT_ATS;
1912 n->timeout = GNUNET_TIME_relative_to_absolute (ATS_RESPONSE_TIMEOUT); 1929 n->timeout = GNUNET_TIME_relative_to_absolute (ATS_RESPONSE_TIMEOUT);
@@ -2016,9 +2033,6 @@ handle_test_blacklist_cont (void *cls,
2016 } 2033 }
2017 cleanup: 2034 cleanup:
2018 GNUNET_HELLO_address_free (bcc->na.address); 2035 GNUNET_HELLO_address_free (bcc->na.address);
2019 GNUNET_CONTAINER_DLL_remove (bc_head,
2020 bc_tail,
2021 bcc);
2022 GNUNET_free (bcc); 2036 GNUNET_free (bcc);
2023} 2037}
2024 2038
@@ -2042,7 +2056,7 @@ check_blacklist (const struct GNUNET_PeerIdentity *peer,
2042 struct BlackListCheckContext *bcc; 2056 struct BlackListCheckContext *bcc;
2043 struct GST_BlacklistCheck *bc; 2057 struct GST_BlacklistCheck *bc;
2044 2058
2045 bcc = GNUNET_malloc (sizeof (struct BlackListCheckContext)); 2059 bcc = GNUNET_new (struct BlackListCheckContext);
2046 bcc->na.address = GNUNET_HELLO_address_copy (address); 2060 bcc->na.address = GNUNET_HELLO_address_copy (address);
2047 bcc->na.session = session; 2061 bcc->na.session = session;
2048 bcc->na.connect_timestamp = ts; 2062 bcc->na.connect_timestamp = ts;
@@ -2067,8 +2081,9 @@ check_blacklist (const struct GNUNET_PeerIdentity *peer,
2067 * @param address address of the other peer, NULL if other peer 2081 * @param address address of the other peer, NULL if other peer
2068 * connected to us 2082 * connected to us
2069 * @param session session to use (or NULL) 2083 * @param session session to use (or NULL)
2084 * @return #GNUNET_OK if the message was fine, #GNUNET_SYSERR on serious error
2070 */ 2085 */
2071void 2086int
2072GST_neighbours_handle_connect (const struct GNUNET_MessageHeader *message, 2087GST_neighbours_handle_connect (const struct GNUNET_MessageHeader *message,
2073 const struct GNUNET_PeerIdentity *peer, 2088 const struct GNUNET_PeerIdentity *peer,
2074 const struct GNUNET_HELLO_Address *address, 2089 const struct GNUNET_HELLO_Address *address,
@@ -2084,14 +2099,19 @@ GST_neighbours_handle_connect (const struct GNUNET_MessageHeader *message,
2084 if (ntohs (message->size) != sizeof (struct SessionConnectMessage)) 2099 if (ntohs (message->size) != sizeof (struct SessionConnectMessage))
2085 { 2100 {
2086 GNUNET_break_op (0); 2101 GNUNET_break_op (0);
2087 return; 2102 return GNUNET_SYSERR;
2088 } 2103 }
2089 GNUNET_STATISTICS_update (GST_stats, 2104 GNUNET_STATISTICS_update (GST_stats,
2090 gettext_noop 2105 gettext_noop
2091 ("# CONNECT messages received"), 2106 ("# CONNECT messages received"),
2092 1, GNUNET_NO); 2107 1, GNUNET_NO);
2093 if (NULL == neighbours) 2108 if (NULL == neighbours)
2094 return; /* we're shutting down */ 2109 {
2110 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
2111 _("CONNECT request from peer `%s' ignored due impending shutdown\n"),
2112 GNUNET_i2s (peer));
2113 return GNUNET_OK; /* we're shutting down */
2114 }
2095 scm = (const struct SessionConnectMessage *) message; 2115 scm = (const struct SessionConnectMessage *) message;
2096 GNUNET_break_op (0 == ntohl (scm->reserved)); 2116 GNUNET_break_op (0 == ntohl (scm->reserved));
2097 ts = GNUNET_TIME_absolute_ntoh (scm->timestamp); 2117 ts = GNUNET_TIME_absolute_ntoh (scm->timestamp);
@@ -2169,9 +2189,9 @@ GST_neighbours_handle_connect (const struct GNUNET_MessageHeader *message,
2169 "Unhandled state `%s'\n", 2189 "Unhandled state `%s'\n",
2170 print_state (n->state)); 2190 print_state (n->state));
2171 GNUNET_break (0); 2191 GNUNET_break (0);
2172 free_neighbour (n, GNUNET_NO); 2192 return GNUNET_SYSERR;
2173 break;
2174 } 2193 }
2194 return GNUNET_OK;
2175} 2195}
2176 2196
2177 2197
@@ -2485,33 +2505,32 @@ utilization_transmission (void *cls,
2485 2505
2486} 2506}
2487 2507
2508
2488void 2509void
2489GST_neighbours_notify_data_recv (const struct GNUNET_PeerIdentity *peer, 2510GST_neighbours_notify_data_recv (const struct GNUNET_PeerIdentity *peer,
2490 const struct GNUNET_HELLO_Address *address, 2511 const struct GNUNET_HELLO_Address *address,
2491 struct Session *session, 2512 struct Session *session,
2492 const struct GNUNET_MessageHeader *message) 2513 const struct GNUNET_MessageHeader *message)
2493{ 2514{
2494 struct NeighbourMapEntry *n; 2515 struct NeighbourMapEntry *n;
2516
2495 n = lookup_neighbour (peer); 2517 n = lookup_neighbour (peer);
2496 if (NULL == n) 2518 if (NULL == n)
2497 { 2519 return;
2498 return;
2499 }
2500 n->util_total_bytes_recv += ntohs(message->size); 2520 n->util_total_bytes_recv += ntohs(message->size);
2501} 2521}
2502 2522
2523
2503void 2524void
2504GST_neighbours_notify_payload_recv (const struct GNUNET_PeerIdentity *peer, 2525GST_neighbours_notify_payload_recv (const struct GNUNET_PeerIdentity *peer,
2505 const struct GNUNET_HELLO_Address *address, 2526 const struct GNUNET_HELLO_Address *address,
2506 struct Session *session, 2527 struct Session *session,
2507 const struct GNUNET_MessageHeader *message) 2528 const struct GNUNET_MessageHeader *message)
2508{ 2529{
2509 struct NeighbourMapEntry *n; 2530 struct NeighbourMapEntry *n;
2510 n = lookup_neighbour (peer); 2531 n = lookup_neighbour (peer);
2511 if (NULL == n) 2532 if (NULL == n)
2512 { 2533 return;
2513 return;
2514 }
2515 n->util_payload_bytes_recv += ntohs(message->size); 2534 n->util_payload_bytes_recv += ntohs(message->size);
2516} 2535}
2517 2536
@@ -2779,8 +2798,9 @@ send_session_ack_message (struct NeighbourMapEntry *n)
2779 * @param address address of the other peer, NULL if other peer 2798 * @param address address of the other peer, NULL if other peer
2780 * connected to us 2799 * connected to us
2781 * @param session session to use (or NULL) 2800 * @param session session to use (or NULL)
2801 * @return #GNUNET_OK if the message was fine, #GNUNET_SYSERR on serious error
2782 */ 2802 */
2783void 2803int
2784GST_neighbours_handle_connect_ack (const struct GNUNET_MessageHeader *message, 2804GST_neighbours_handle_connect_ack (const struct GNUNET_MessageHeader *message,
2785 const struct GNUNET_PeerIdentity *peer, 2805 const struct GNUNET_PeerIdentity *peer,
2786 const struct GNUNET_HELLO_Address *address, 2806 const struct GNUNET_HELLO_Address *address,
@@ -2797,7 +2817,7 @@ GST_neighbours_handle_connect_ack (const struct GNUNET_MessageHeader *message,
2797 if (ntohs (message->size) != sizeof (struct SessionConnectMessage)) 2817 if (ntohs (message->size) != sizeof (struct SessionConnectMessage))
2798 { 2818 {
2799 GNUNET_break_op (0); 2819 GNUNET_break_op (0);
2800 return; 2820 return GNUNET_SYSERR;
2801 } 2821 }
2802 GNUNET_STATISTICS_update (GST_stats, 2822 GNUNET_STATISTICS_update (GST_stats,
2803 gettext_noop 2823 gettext_noop
@@ -2811,7 +2831,7 @@ GST_neighbours_handle_connect_ack (const struct GNUNET_MessageHeader *message,
2811 gettext_noop 2831 gettext_noop
2812 ("# unexpected CONNECT_ACK messages (no peer)"), 2832 ("# unexpected CONNECT_ACK messages (no peer)"),
2813 1, GNUNET_NO); 2833 1, GNUNET_NO);
2814 return; 2834 return GNUNET_SYSERR;
2815 } 2835 }
2816 ts = GNUNET_TIME_absolute_ntoh (scm->timestamp); 2836 ts = GNUNET_TIME_absolute_ntoh (scm->timestamp);
2817 switch (n->state) 2837 switch (n->state)
@@ -2819,7 +2839,7 @@ GST_neighbours_handle_connect_ack (const struct GNUNET_MessageHeader *message,
2819 case S_NOT_CONNECTED: 2839 case S_NOT_CONNECTED:
2820 GNUNET_break (0); 2840 GNUNET_break (0);
2821 free_neighbour (n, GNUNET_NO); 2841 free_neighbour (n, GNUNET_NO);
2822 return; 2842 return GNUNET_SYSERR;
2823 case S_INIT_ATS: 2843 case S_INIT_ATS:
2824 case S_INIT_BLACKLIST: 2844 case S_INIT_BLACKLIST:
2825 GNUNET_STATISTICS_update (GST_stats, 2845 GNUNET_STATISTICS_update (GST_stats,
@@ -2829,7 +2849,11 @@ GST_neighbours_handle_connect_ack (const struct GNUNET_MessageHeader *message,
2829 break; 2849 break;
2830 case S_CONNECT_SENT: 2850 case S_CONNECT_SENT:
2831 if (ts.abs_value_us != n->primary_address.connect_timestamp.abs_value_us) 2851 if (ts.abs_value_us != n->primary_address.connect_timestamp.abs_value_us)
2832 break; /* ACK does not match our original CONNECT message */ 2852 {
2853 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
2854 "CONNECT_ACK ignored as the timestamp does not match our CONNECT request\n");
2855 return GNUNET_OK;
2856 }
2833 n->state = S_CONNECTED; 2857 n->state = S_CONNECTED;
2834 n->timeout = GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT); 2858 n->timeout = GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT);
2835 GNUNET_STATISTICS_set (GST_stats, 2859 GNUNET_STATISTICS_set (GST_stats,
@@ -2901,7 +2925,7 @@ GST_neighbours_handle_connect_ack (const struct GNUNET_MessageHeader *message,
2901 gettext_noop 2925 gettext_noop
2902 ("# unexpected CONNECT_ACK messages (disconnecting)"), 2926 ("# unexpected CONNECT_ACK messages (disconnecting)"),
2903 1, GNUNET_NO); 2927 1, GNUNET_NO);
2904 break; 2928 return GNUNET_SYSERR;
2905 case S_DISCONNECT_FINISHED: 2929 case S_DISCONNECT_FINISHED:
2906 GNUNET_assert (0); 2930 GNUNET_assert (0);
2907 break; 2931 break;
@@ -2910,8 +2934,9 @@ GST_neighbours_handle_connect_ack (const struct GNUNET_MessageHeader *message,
2910 "Unhandled state `%s'\n", 2934 "Unhandled state `%s'\n",
2911 print_state (n->state)); 2935 print_state (n->state));
2912 GNUNET_break (0); 2936 GNUNET_break (0);
2913 break; 2937 return GNUNET_SYSERR;
2914 } 2938 }
2939 return GNUNET_OK;
2915} 2940}
2916 2941
2917 2942
@@ -2939,7 +2964,8 @@ GST_neighbours_session_terminated (const struct GNUNET_PeerIdentity *peer,
2939 bcc_next = bcc->next; 2964 bcc_next = bcc->next;
2940 if (bcc->na.session == session) 2965 if (bcc->na.session == session)
2941 { 2966 {
2942 GST_blacklist_test_cancel (bcc->bc); 2967 if (NULL != bcc->bc)
2968 GST_blacklist_test_cancel (bcc->bc);
2943 GNUNET_HELLO_address_free (bcc->na.address); 2969 GNUNET_HELLO_address_free (bcc->na.address);
2944 GNUNET_CONTAINER_DLL_remove (bc_head, 2970 GNUNET_CONTAINER_DLL_remove (bc_head,
2945 bc_tail, 2971 bc_tail,
@@ -3057,8 +3083,9 @@ GST_neighbours_session_terminated (const struct GNUNET_PeerIdentity *peer,
3057 * @param address address of the other peer, NULL if other peer 3083 * @param address address of the other peer, NULL if other peer
3058 * connected to us 3084 * connected to us
3059 * @param session session to use (or NULL) 3085 * @param session session to use (or NULL)
3086 * @return #GNUNET_OK if the message was fine, #GNUNET_SYSERR on serious error
3060 */ 3087 */
3061void 3088int
3062GST_neighbours_handle_session_ack (const struct GNUNET_MessageHeader *message, 3089GST_neighbours_handle_session_ack (const struct GNUNET_MessageHeader *message,
3063 const struct GNUNET_PeerIdentity *peer, 3090 const struct GNUNET_PeerIdentity *peer,
3064 const struct GNUNET_HELLO_Address *address, 3091 const struct GNUNET_HELLO_Address *address,
@@ -3072,14 +3099,14 @@ GST_neighbours_handle_session_ack (const struct GNUNET_MessageHeader *message,
3072 if (ntohs (message->size) != sizeof (struct GNUNET_MessageHeader)) 3099 if (ntohs (message->size) != sizeof (struct GNUNET_MessageHeader))
3073 { 3100 {
3074 GNUNET_break_op (0); 3101 GNUNET_break_op (0);
3075 return; 3102 return GNUNET_SYSERR;
3076 } 3103 }
3077 GNUNET_STATISTICS_update (GST_stats, 3104 GNUNET_STATISTICS_update (GST_stats,
3078 gettext_noop 3105 gettext_noop
3079 ("# SESSION_ACK messages received"), 3106 ("# SESSION_ACK messages received"),
3080 1, GNUNET_NO); 3107 1, GNUNET_NO);
3081 if (NULL == (n = lookup_neighbour (peer))) 3108 if (NULL == (n = lookup_neighbour (peer)))
3082 return; 3109 return GNUNET_SYSERR;
3083 /* check if we are in a plausible state for having sent 3110 /* check if we are in a plausible state for having sent
3084 a CONNECT_ACK. If not, return, otherwise break */ 3111 a CONNECT_ACK. If not, return, otherwise break */
3085 if ( ( (S_CONNECT_RECV_ACK != n->state) && 3112 if ( ( (S_CONNECT_RECV_ACK != n->state) &&
@@ -3094,7 +3121,7 @@ GST_neighbours_handle_session_ack (const struct GNUNET_MessageHeader *message,
3094 GNUNET_STATISTICS_update (GST_stats, 3121 GNUNET_STATISTICS_update (GST_stats,
3095 gettext_noop ("# unexpected SESSION_ACK messages"), 1, 3122 gettext_noop ("# unexpected SESSION_ACK messages"), 1,
3096 GNUNET_NO); 3123 GNUNET_NO);
3097 return; 3124 return GNUNET_SYSERR;
3098 } 3125 }
3099 n->state = S_CONNECTED; 3126 n->state = S_CONNECTED;
3100 n->timeout = GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT); 3127 n->timeout = GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT);
@@ -3113,6 +3140,7 @@ GST_neighbours_handle_session_ack (const struct GNUNET_MessageHeader *message,
3113 n->primary_address.bandwidth_in, 3140 n->primary_address.bandwidth_in,
3114 n->primary_address.bandwidth_out, 3141 n->primary_address.bandwidth_out,
3115 GNUNET_YES); 3142 GNUNET_YES);
3143 return GNUNET_OK;
3116} 3144}
3117 3145
3118 3146
diff --git a/src/transport/gnunet-service-transport_neighbours.h b/src/transport/gnunet-service-transport_neighbours.h
index 9ba1918c3..f58a74faf 100644
--- a/src/transport/gnunet-service-transport_neighbours.h
+++ b/src/transport/gnunet-service-transport_neighbours.h
@@ -48,7 +48,7 @@
48 */ 48 */
49void 49void
50GST_neighbours_start (void *cls, 50GST_neighbours_start (void *cls,
51 NotifyConnect connect_cb, 51 NotifyConnect connect_cb,
52 GNUNET_TRANSPORT_NotifyDisconnect disconnect_cb, 52 GNUNET_TRANSPORT_NotifyDisconnect disconnect_cb,
53 GNUNET_TRANSPORT_PeerIterateCallback peer_address_cb, 53 GNUNET_TRANSPORT_PeerIterateCallback peer_address_cb,
54 unsigned int max_fds); 54 unsigned int max_fds);
@@ -74,7 +74,7 @@ GST_neighbours_try_connect (const struct GNUNET_PeerIdentity *target);
74 * Test if we're connected to the given peer. 74 * Test if we're connected to the given peer.
75 * 75 *
76 * @param target peer to test 76 * @param target peer to test
77 * @return GNUNET_YES if we are connected, GNUNET_NO if not 77 * @return #GNUNET_YES if we are connected, #GNUNET_NO if not
78 */ 78 */
79int 79int
80GST_neighbours_test_connected (const struct GNUNET_PeerIdentity *target); 80GST_neighbours_test_connected (const struct GNUNET_PeerIdentity *target);
@@ -84,7 +84,7 @@ GST_neighbours_test_connected (const struct GNUNET_PeerIdentity *target);
84 * Function called after the transmission is done. 84 * Function called after the transmission is done.
85 * 85 *
86 * @param cls closure 86 * @param cls closure
87 * @param success GNUNET_OK on success, GNUNET_NO on failure, GNUNET_SYSERR if we're not connected 87 * @param success #GNUNET_OK on success, #GNUNET_NO on failure, #GNUNET_SYSERR if we're not connected
88 */ 88 */
89typedef void (*GST_NeighbourSendContinuation) (void *cls, int success, 89typedef void (*GST_NeighbourSendContinuation) (void *cls, int success,
90 size_t bytes_payload, 90 size_t bytes_payload,
@@ -96,10 +96,10 @@ typedef void (*GST_NeighbourSendContinuation) (void *cls, int success,
96 * 96 *
97 * @param target destination 97 * @param target destination
98 * @param msg message to send 98 * @param msg message to send
99 * @param msg_size number of bytes in msg 99 * @param msg_size number of bytes in @a msg
100 * @param timeout when to fail with timeout 100 * @param timeout when to fail with timeout
101 * @param cont function to call when done 101 * @param cont function to call when done
102 * @param cont_cls closure for 'cont' 102 * @param cont_cls closure for @a cont
103 */ 103 */
104void 104void
105GST_neighbours_send (const struct GNUNET_PeerIdentity *target, const void *msg, 105GST_neighbours_send (const struct GNUNET_PeerIdentity *target, const void *msg,
@@ -114,8 +114,8 @@ GST_neighbours_send (const struct GNUNET_PeerIdentity *target, const void *msg,
114 * 114 *
115 * @param sender sender of the message 115 * @param sender sender of the message
116 * @param size size of the message 116 * @param size size of the message
117 * @param do_forward set to GNUNET_YES if the message should be forwarded to clients 117 * @param do_forward set to #GNUNET_YES if the message should be forwarded to clients
118 * GNUNET_NO if the neighbour is not connected or violates the quota 118 * #GNUNET_NO if the neighbour is not connected or violates the quota
119 * @return how long to wait before reading more from this sender 119 * @return how long to wait before reading more from this sender
120 */ 120 */
121struct GNUNET_TIME_Relative 121struct GNUNET_TIME_Relative
@@ -185,7 +185,7 @@ typedef void (*GST_NeighbourIterator) (void *cls,
185 * Iterate over all connected neighbours. 185 * Iterate over all connected neighbours.
186 * 186 *
187 * @param cb function to call 187 * @param cb function to call
188 * @param cb_cls closure for cb 188 * @param cb_cls closure for @a cb
189 */ 189 */
190void 190void
191GST_neighbours_iterate (GST_NeighbourIterator cb, void *cb_cls); 191GST_neighbours_iterate (GST_NeighbourIterator cb, void *cb_cls);
@@ -196,7 +196,7 @@ GST_neighbours_iterate (GST_NeighbourIterator cb, void *cb_cls);
196 * 196 *
197 * @param peer identity of the peer where the session died 197 * @param peer identity of the peer where the session died
198 * @param session session that is gone 198 * @param session session that is gone
199 * @return GNUNET_YES if this was a session used, GNUNET_NO if 199 * @return #GNUNET_YES if this was a session used, #GNUNET_NO if
200 * this session was not in use 200 * this session was not in use
201 */ 201 */
202int 202int
@@ -206,25 +206,29 @@ GST_neighbours_session_terminated (const struct GNUNET_PeerIdentity *peer,
206 206
207void 207void
208GST_neighbours_notify_data_recv (const struct GNUNET_PeerIdentity *peer, 208GST_neighbours_notify_data_recv (const struct GNUNET_PeerIdentity *peer,
209 const struct GNUNET_HELLO_Address *address, 209 const struct GNUNET_HELLO_Address *address,
210 struct Session *session, 210 struct Session *session,
211 const struct GNUNET_MessageHeader *message); 211 const struct GNUNET_MessageHeader *message);
212
212 213
213void 214void
214GST_neighbours_notify_payload_recv (const struct GNUNET_PeerIdentity *peer, 215GST_neighbours_notify_payload_recv (const struct GNUNET_PeerIdentity *peer,
215 const struct GNUNET_HELLO_Address *address, 216 const struct GNUNET_HELLO_Address *address,
216 struct Session *session, 217 struct Session *session,
217 const struct GNUNET_MessageHeader *message); 218 const struct GNUNET_MessageHeader *message);
219
218 220
219void 221void
220GST_neighbours_notify_payload_sent (const struct GNUNET_PeerIdentity *peer, 222GST_neighbours_notify_payload_sent (const struct GNUNET_PeerIdentity *peer,
221 size_t size); 223 size_t size);
224
222 225
223void 226void
224GST_neighbours_notify_data_sent (const struct GNUNET_PeerIdentity *peer, 227GST_neighbours_notify_data_sent (const struct GNUNET_PeerIdentity *peer,
225 const struct GNUNET_HELLO_Address *address, 228 const struct GNUNET_HELLO_Address *address,
226 struct Session *session, 229 struct Session *session,
227 size_t size); 230 size_t size);
231
228 232
229/** 233/**
230 * For an existing neighbour record, set the active connection to 234 * For an existing neighbour record, set the active connection to
@@ -241,12 +245,12 @@ GST_neighbours_notify_data_sent (const struct GNUNET_PeerIdentity *peer,
241 */ 245 */
242void 246void
243GST_neighbours_switch_to_address (const struct GNUNET_PeerIdentity *peer, 247GST_neighbours_switch_to_address (const struct GNUNET_PeerIdentity *peer,
244 const struct GNUNET_HELLO_Address 248 const struct GNUNET_HELLO_Address *address,
245 *address, struct Session *session, 249 struct Session *session,
246 const struct GNUNET_ATS_Information *ats, 250 const struct GNUNET_ATS_Information *ats,
247 uint32_t ats_count, 251 uint32_t ats_count,
248 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, 252 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
249 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out); 253 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out);
250 254
251 255
252/** 256/**
@@ -258,8 +262,9 @@ GST_neighbours_switch_to_address (const struct GNUNET_PeerIdentity *peer,
258 * @param address address of the other peer, NULL if other peer 262 * @param address address of the other peer, NULL if other peer
259 * connected to us 263 * connected to us
260 * @param session session to use (or NULL) 264 * @param session session to use (or NULL)
265 * @return #GNUNET_OK if the message was fine, #GNUNET_SYSERR on serious error
261 */ 266 */
262void 267int
263GST_neighbours_handle_connect (const struct GNUNET_MessageHeader *message, 268GST_neighbours_handle_connect (const struct GNUNET_MessageHeader *message,
264 const struct GNUNET_PeerIdentity *peer, 269 const struct GNUNET_PeerIdentity *peer,
265 const struct GNUNET_HELLO_Address *address, 270 const struct GNUNET_HELLO_Address *address,
@@ -275,8 +280,9 @@ GST_neighbours_handle_connect (const struct GNUNET_MessageHeader *message,
275 * @param address address of the other peer, NULL if other peer 280 * @param address address of the other peer, NULL if other peer
276 * connected to us 281 * connected to us
277 * @param session session to use (or NULL) 282 * @param session session to use (or NULL)
283 * @return #GNUNET_OK if the message was fine, #GNUNET_SYSERR on serious error
278 */ 284 */
279void 285int
280GST_neighbours_handle_connect_ack (const struct GNUNET_MessageHeader *message, 286GST_neighbours_handle_connect_ack (const struct GNUNET_MessageHeader *message,
281 const struct GNUNET_PeerIdentity *peer, 287 const struct GNUNET_PeerIdentity *peer,
282 const struct GNUNET_HELLO_Address *address, 288 const struct GNUNET_HELLO_Address *address,
@@ -285,15 +291,17 @@ GST_neighbours_handle_connect_ack (const struct GNUNET_MessageHeader *message,
285 291
286/** 292/**
287 * We received a 'SESSION_ACK' message from the other peer. 293 * We received a 'SESSION_ACK' message from the other peer.
288 * FIXME: describe what this means! 294 * If we sent a 'CONNECT_ACK' last, this means we are now
295 * connected. Otherwise, do nothing.
289 * 296 *
290 * @param message possibly a 'struct SessionConnectMessage' (check format) 297 * @param message possibly a 'struct SessionConnectMessage' (check format)
291 * @param peer identity of the peer to switch the address for 298 * @param peer identity of the peer to switch the address for
292 * @param address address of the other peer, NULL if other peer 299 * @param address address of the other peer, NULL if other peer
293 * connected to us 300 * connected to us
294 * @param session session to use (or NULL) 301 * @param session session to use (or NULL)
302 * @return #GNUNET_OK if the message was fine, #GNUNET_SYSERR on serious error
295 */ 303 */
296void 304int
297GST_neighbours_handle_session_ack (const struct GNUNET_MessageHeader *message, 305GST_neighbours_handle_session_ack (const struct GNUNET_MessageHeader *message,
298 const struct GNUNET_PeerIdentity *peer, 306 const struct GNUNET_PeerIdentity *peer,
299 const struct GNUNET_HELLO_Address *address, 307 const struct GNUNET_HELLO_Address *address,
diff --git a/src/transport/gnunet-service-transport_plugins.h b/src/transport/gnunet-service-transport_plugins.h
index 2dc91de73..9d8d503f8 100644
--- a/src/transport/gnunet-service-transport_plugins.h
+++ b/src/transport/gnunet-service-transport_plugins.h
@@ -70,6 +70,7 @@ GST_plugins_unload (void);
70struct GNUNET_TRANSPORT_PluginFunctions * 70struct GNUNET_TRANSPORT_PluginFunctions *
71GST_plugins_find (const char *name); 71GST_plugins_find (const char *name);
72 72
73
73/** 74/**
74 * Obtain the plugin API based on a the stripped plugin name after the underscore. 75 * Obtain the plugin API based on a the stripped plugin name after the underscore.
75 * 76 *
diff --git a/src/transport/gnunet-service-transport_validation.c b/src/transport/gnunet-service-transport_validation.c
index afe7ac467..c0e605114 100644
--- a/src/transport/gnunet-service-transport_validation.c
+++ b/src/transport/gnunet-service-transport_validation.c
@@ -931,8 +931,9 @@ multicast_pong (void *cls,
931 * @param hdr the PING 931 * @param hdr the PING
932 * @param sender_address the sender address as we got it 932 * @param sender_address the sender address as we got it
933 * @param session session we got the PING from 933 * @param session session we got the PING from
934 * @return #GNUNET_OK if the message was fine, #GNUNET_SYSERR on serious error
934 */ 935 */
935void 936int
936GST_validation_handle_ping (const struct GNUNET_PeerIdentity *sender, 937GST_validation_handle_ping (const struct GNUNET_PeerIdentity *sender,
937 const struct GNUNET_MessageHeader *hdr, 938 const struct GNUNET_MessageHeader *hdr,
938 const struct GNUNET_HELLO_Address *sender_address, 939 const struct GNUNET_HELLO_Address *sender_address,
@@ -956,7 +957,7 @@ GST_validation_handle_ping (const struct GNUNET_PeerIdentity *sender,
956 if (ntohs (hdr->size) < sizeof (struct TransportPingMessage)) 957 if (ntohs (hdr->size) < sizeof (struct TransportPingMessage))
957 { 958 {
958 GNUNET_break_op (0); 959 GNUNET_break_op (0);
959 return; 960 return GNUNET_SYSERR;
960 } 961 }
961 ping = (const struct TransportPingMessage *) hdr; 962 ping = (const struct TransportPingMessage *) hdr;
962 if (0 != 963 if (0 !=
@@ -967,7 +968,7 @@ GST_validation_handle_ping (const struct GNUNET_PeerIdentity *sender,
967 gettext_noop 968 gettext_noop
968 ("# PING message for different peer received"), 1, 969 ("# PING message for different peer received"), 1,
969 GNUNET_NO); 970 GNUNET_NO);
970 return; 971 return GNUNET_SYSERR;
971 } 972 }
972 GNUNET_STATISTICS_update (GST_stats, 973 GNUNET_STATISTICS_update (GST_stats,
973 gettext_noop ("# PING messages received"), 1, 974 gettext_noop ("# PING messages received"), 1,
@@ -986,7 +987,7 @@ GST_validation_handle_ping (const struct GNUNET_PeerIdentity *sender,
986 if (NULL == addrend) 987 if (NULL == addrend)
987 { 988 {
988 GNUNET_break_op (0); 989 GNUNET_break_op (0);
989 return; 990 return GNUNET_SYSERR;
990 } 991 }
991 addrend++; 992 addrend++;
992 slen = strlen (addr) + 1; 993 slen = strlen (addr) + 1;
@@ -998,38 +999,40 @@ GST_validation_handle_ping (const struct GNUNET_PeerIdentity *sender,
998 999
999 if (NULL == address.transport_name) 1000 if (NULL == address.transport_name)
1000 { 1001 {
1001 GNUNET_break (0); 1002 GNUNET_break (0);
1002 } 1003 }
1003 1004
1004 if (0 != strstr (address.transport_name, "_client")) 1005 if (0 != strstr (address.transport_name, "_client"))
1005 { 1006 {
1006 plugin_name = GNUNET_strdup (address.transport_name); 1007 plugin_name = GNUNET_strdup (address.transport_name);
1007 pos = strstr (plugin_name, "_client"); 1008 pos = strstr (plugin_name, "_client");
1008 GNUNET_assert (NULL != pos); 1009 GNUNET_assert (NULL != pos);
1009 GNUNET_snprintf (pos, strlen ("_server") + 1, "%s", "_server"); 1010 GNUNET_snprintf (pos, strlen ("_server") + 1, "%s", "_server");
1010 } 1011 }
1011 else 1012 else
1012 plugin_name = GNUNET_strdup (address.transport_name); 1013 plugin_name = GNUNET_strdup (address.transport_name);
1013 1014
1014 if (NULL == (papi = GST_plugins_find (plugin_name))) 1015 if (NULL == (papi = GST_plugins_find (plugin_name)))
1015 { 1016 {
1016 /* we don't have the plugin for this address */ 1017 /* we don't have the plugin for this address */
1017 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Plugin `%s' not available, cannot confirm having this address \n", 1018 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1018 plugin_name); 1019 _("Plugin `%s' not available, cannot confirm having this address\n"),
1020 plugin_name);
1019 GNUNET_free (plugin_name); 1021 GNUNET_free (plugin_name);
1020 return; 1022 return GNUNET_SYSERR;
1021 } 1023 }
1022 GNUNET_free (plugin_name); 1024 GNUNET_free (plugin_name);
1023 if (GNUNET_OK != papi->check_address (papi->cls, addrend, alen)) 1025 if (GNUNET_OK != papi->check_address (papi->cls, addrend, alen))
1024 { 1026 {
1025 GNUNET_STATISTICS_update (GST_stats, 1027 GNUNET_STATISTICS_update (GST_stats,
1026 gettext_noop 1028 gettext_noop
1027 ("# failed address checks during validation"), 1, 1029 ("# failed address checks during validation"), 1,
1028 GNUNET_NO); 1030 GNUNET_NO);
1029 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Address `%s' is not one of my addresses, not confirming PING\n", 1031 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1030 GST_plugins_a2s (&address)); 1032 _("Address `%s' is not one of my addresses, not confirming PING\n"),
1031 return; 1033 GST_plugins_a2s (&address));
1032 } 1034 return GNUNET_SYSERR;
1035 }
1033 else 1036 else
1034 { 1037 {
1035 GNUNET_STATISTICS_update (GST_stats, 1038 GNUNET_STATISTICS_update (GST_stats,
@@ -1046,10 +1049,10 @@ GST_validation_handle_ping (const struct GNUNET_PeerIdentity *sender,
1046 if (GNUNET_NO == buggy) 1049 if (GNUNET_NO == buggy)
1047 { 1050 {
1048 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1051 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1049 "Not confirming PING from peer `%s' with address `%s' since I cannot confirm having this address.\n", 1052 _("Not confirming PING from peer `%s' with address `%s' since I cannot confirm having this address.\n"),
1050 GNUNET_i2s (sender), 1053 GNUNET_i2s (sender),
1051 GST_plugins_a2s (&address)); 1054 GST_plugins_a2s (&address));
1052 return; 1055 return GNUNET_SYSERR;
1053 } 1056 }
1054 else 1057 else
1055 { 1058 {
@@ -1145,8 +1148,8 @@ GST_validation_handle_ping (const struct GNUNET_PeerIdentity *sender,
1145 NULL, NULL); 1148 NULL, NULL);
1146 if (-1 != ret) 1149 if (-1 != ret)
1147 GST_neighbours_notify_data_sent (sender, 1150 GST_neighbours_notify_data_sent (sender,
1148 sender_address, session, pong->header.size); 1151 sender_address, session,
1149 1152 pong->header.size);
1150 } 1153 }
1151 } 1154 }
1152 if (ret != -1) 1155 if (ret != -1)
@@ -1160,7 +1163,7 @@ GST_validation_handle_ping (const struct GNUNET_PeerIdentity *sender,
1160 ("# PONGs unicast via reliable transport"), 1, 1163 ("# PONGs unicast via reliable transport"), 1,
1161 GNUNET_NO); 1164 GNUNET_NO);
1162 GNUNET_free (pong); 1165 GNUNET_free (pong);
1163 return; 1166 return GNUNET_OK;
1164 } 1167 }
1165 1168
1166 /* no reliable method found, try transmission via all known addresses */ 1169 /* no reliable method found, try transmission via all known addresses */
@@ -1168,13 +1171,15 @@ GST_validation_handle_ping (const struct GNUNET_PeerIdentity *sender,
1168 gettext_noop 1171 gettext_noop
1169 ("# PONGs multicast to all available addresses"), 1, 1172 ("# PONGs multicast to all available addresses"), 1,
1170 GNUNET_NO); 1173 GNUNET_NO);
1171 GST_validation_get_addresses (sender, &multicast_pong, pong); 1174 GST_validation_get_addresses (sender,
1175 &multicast_pong, pong);
1172 GNUNET_free (pong); 1176 GNUNET_free (pong);
1177 return GNUNET_OK;
1173} 1178}
1174 1179
1175 1180
1176/** 1181/**
1177 * Context for the 'validate_address' function 1182 * Context for the #validate_address_iterator() function
1178 */ 1183 */
1179struct ValidateAddressContext 1184struct ValidateAddressContext
1180{ 1185{
@@ -1187,6 +1192,7 @@ struct ValidateAddressContext
1187 * Public key of the peer whose address is being validated. 1192 * Public key of the peer whose address is being validated.
1188 */ 1193 */
1189 struct GNUNET_CRYPTO_EddsaPublicKey public_key; 1194 struct GNUNET_CRYPTO_EddsaPublicKey public_key;
1195
1190}; 1196};
1191 1197
1192 1198
@@ -1194,7 +1200,7 @@ struct ValidateAddressContext
1194 * Iterator callback to go over all addresses and try to validate them 1200 * Iterator callback to go over all addresses and try to validate them
1195 * (unless blocked or already validated). 1201 * (unless blocked or already validated).
1196 * 1202 *
1197 * @param cls pointer to a 'struct ValidateAddressContext' 1203 * @param cls pointer to a `struct ValidateAddressContext`
1198 * @param address the address 1204 * @param address the address
1199 * @param expiration expiration time 1205 * @param expiration expiration time
1200 * @return #GNUNET_OK (keep the address) 1206 * @return #GNUNET_OK (keep the address)
@@ -1218,7 +1224,7 @@ validate_address_iterator (void *cls,
1218 { 1224 {
1219 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1225 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1220 "Starting validation for fresh address %s\n", 1226 "Starting validation for fresh address %s\n",
1221 GST_plugins_a2s (ve->address)); 1227 GST_plugins_a2s (ve->address));
1222 ve->revalidation_task = GNUNET_SCHEDULER_add_now (&revalidate_address, ve); 1228 ve->revalidation_task = GNUNET_SCHEDULER_add_now (&revalidate_address, ve);
1223 } 1229 }
1224 return GNUNET_OK; 1230 return GNUNET_OK;
@@ -1252,8 +1258,9 @@ add_valid_peer_address (void *cls, size_t max, void *buf)
1252 * 1258 *
1253 * @param sender peer sending the PONG 1259 * @param sender peer sending the PONG
1254 * @param hdr the PONG 1260 * @param hdr the PONG
1261 * @return #GNUNET_OK if the message was fine, #GNUNET_SYSERR on serious error
1255 */ 1262 */
1256void 1263int
1257GST_validation_handle_pong (const struct GNUNET_PeerIdentity *sender, 1264GST_validation_handle_pong (const struct GNUNET_PeerIdentity *sender,
1258 const struct GNUNET_MessageHeader *hdr) 1265 const struct GNUNET_MessageHeader *hdr)
1259{ 1266{
@@ -1272,7 +1279,7 @@ GST_validation_handle_pong (const struct GNUNET_PeerIdentity *sender,
1272 if (ntohs (hdr->size) < sizeof (struct TransportPongMessage)) 1279 if (ntohs (hdr->size) < sizeof (struct TransportPongMessage))
1273 { 1280 {
1274 GNUNET_break_op (0); 1281 GNUNET_break_op (0);
1275 return; 1282 return GNUNET_SYSERR;
1276 } 1283 }
1277 GNUNET_STATISTICS_update (GST_stats, 1284 GNUNET_STATISTICS_update (GST_stats,
1278 gettext_noop ("# PONG messages received"), 1, 1285 gettext_noop ("# PONG messages received"), 1,
@@ -1288,7 +1295,7 @@ GST_validation_handle_pong (const struct GNUNET_PeerIdentity *sender,
1288 if (NULL == addr) 1295 if (NULL == addr)
1289 { 1296 {
1290 GNUNET_break_op (0); 1297 GNUNET_break_op (0);
1291 return; 1298 return GNUNET_SYSERR;
1292 } 1299 }
1293 addr++; 1300 addr++;
1294 slen = strlen (tname) + 1; 1301 slen = strlen (tname) + 1;
@@ -1304,13 +1311,13 @@ GST_validation_handle_pong (const struct GNUNET_PeerIdentity *sender,
1304 gettext_noop 1311 gettext_noop
1305 ("# PONGs dropped, no matching pending validation"), 1312 ("# PONGs dropped, no matching pending validation"),
1306 1, GNUNET_NO); 1313 1, GNUNET_NO);
1307 return; 1314 return GNUNET_OK;
1308 } 1315 }
1309 /* now check that PONG is well-formed */ 1316 /* now check that PONG is well-formed */
1310 if (0 != memcmp (&ve->pid, sender, sizeof (struct GNUNET_PeerIdentity))) 1317 if (0 != memcmp (&ve->pid, sender, sizeof (struct GNUNET_PeerIdentity)))
1311 { 1318 {
1312 GNUNET_break_op (0); 1319 GNUNET_break_op (0);
1313 return; 1320 return GNUNET_SYSERR;
1314 } 1321 }
1315 if (GNUNET_TIME_absolute_get_remaining 1322 if (GNUNET_TIME_absolute_get_remaining
1316 (GNUNET_TIME_absolute_ntoh (pong->expiration)).rel_value_us == 0) 1323 (GNUNET_TIME_absolute_ntoh (pong->expiration)).rel_value_us == 0)
@@ -1319,7 +1326,7 @@ GST_validation_handle_pong (const struct GNUNET_PeerIdentity *sender,
1319 gettext_noop 1326 gettext_noop
1320 ("# PONGs dropped, signature expired"), 1, 1327 ("# PONGs dropped, signature expired"), 1,
1321 GNUNET_NO); 1328 GNUNET_NO);
1322 return; 1329 return GNUNET_SYSERR;
1323 } 1330 }
1324 1331
1325 sig_res = GNUNET_SYSERR; 1332 sig_res = GNUNET_SYSERR;
@@ -1348,13 +1355,20 @@ GST_validation_handle_pong (const struct GNUNET_PeerIdentity *sender,
1348 &pong->purpose, &pong->signature, 1355 &pong->purpose, &pong->signature,
1349 &ve->public_key); 1356 &ve->public_key);
1350 if (sig_res == GNUNET_SYSERR) 1357 if (sig_res == GNUNET_SYSERR)
1358 {
1359 GNUNET_break_op (0);
1351 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 1360 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
1352 "Failed to verify: invalid signature on address %s:%s from peer `%s'\n", 1361 "Failed to verify: invalid signature on address %s:%s from peer `%s'\n",
1353 tname, GST_plugins_a2s (ve->address),GNUNET_i2s (sender)); 1362 tname,
1363 GST_plugins_a2s (ve->address),
1364 GNUNET_i2s (sender));
1365 }
1354 } 1366 }
1355
1356 if (sig_res == GNUNET_SYSERR) 1367 if (sig_res == GNUNET_SYSERR)
1357 return; 1368 {
1369 GNUNET_break_op (0);
1370 return GNUNET_SYSERR;
1371 }
1358 1372
1359 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1373 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1360 "Address validated for peer `%s' with plugin `%s': `%s'\n", 1374 "Address validated for peer `%s' with plugin `%s': `%s'\n",
@@ -1367,6 +1381,7 @@ GST_validation_handle_pong (const struct GNUNET_PeerIdentity *sender,
1367 ve->latency = GNUNET_TIME_absolute_get_duration (ve->send_time); 1381 ve->latency = GNUNET_TIME_absolute_get_duration (ve->send_time);
1368 { 1382 {
1369 struct GNUNET_ATS_Information ats[2]; 1383 struct GNUNET_ATS_Information ats[2];
1384
1370 ats[0].type = htonl (GNUNET_ATS_QUALITY_NET_DELAY); 1385 ats[0].type = htonl (GNUNET_ATS_QUALITY_NET_DELAY);
1371 ats[0].value = htonl ((uint32_t) ve->latency.rel_value_us); 1386 ats[0].value = htonl ((uint32_t) ve->latency.rel_value_us);
1372 ats[1].type = htonl (GNUNET_ATS_NETWORK_TYPE); 1387 ats[1].type = htonl (GNUNET_ATS_NETWORK_TYPE);
@@ -1381,7 +1396,9 @@ GST_validation_handle_pong (const struct GNUNET_PeerIdentity *sender,
1381 validations_running); 1396 validations_running);
1382 } 1397 }
1383 else 1398 else
1384 GNUNET_break (0); 1399 {
1400 GNUNET_break (0);
1401 }
1385 1402
1386 /* build HELLO to store in PEERINFO */ 1403 /* build HELLO to store in PEERINFO */
1387 ve->copied = GNUNET_NO; 1404 ve->copied = GNUNET_NO;
@@ -1390,6 +1407,7 @@ GST_validation_handle_pong (const struct GNUNET_PeerIdentity *sender,
1390 GNUNET_NO); 1407 GNUNET_NO);
1391 GNUNET_PEERINFO_add_peer (GST_peerinfo, hello, NULL, NULL); 1408 GNUNET_PEERINFO_add_peer (GST_peerinfo, hello, NULL, NULL);
1392 GNUNET_free (hello); 1409 GNUNET_free (hello);
1410 return GNUNET_OK;
1393} 1411}
1394 1412
1395 1413
@@ -1398,8 +1416,9 @@ GST_validation_handle_pong (const struct GNUNET_PeerIdentity *sender,
1398 * validation. 1416 * validation.
1399 * 1417 *
1400 * @param hello the HELLO we received 1418 * @param hello the HELLO we received
1419 * @return #GNUNET_OK if the message was fine, #GNUNET_SYSERR on serious error
1401 */ 1420 */
1402void 1421int
1403GST_validation_handle_hello (const struct GNUNET_MessageHeader *hello) 1422GST_validation_handle_hello (const struct GNUNET_MessageHeader *hello)
1404{ 1423{
1405 const struct GNUNET_HELLO_Message *hm = 1424 const struct GNUNET_HELLO_Message *hm =
@@ -1409,17 +1428,18 @@ GST_validation_handle_hello (const struct GNUNET_MessageHeader *hello)
1409 int friend; 1428 int friend;
1410 1429
1411 friend = GNUNET_HELLO_is_friend_only (hm); 1430 friend = GNUNET_HELLO_is_friend_only (hm);
1412 if (((GNUNET_YES != friend) && (GNUNET_NO != friend)) || 1431 if ( ( (GNUNET_YES != friend) &&
1413 (GNUNET_OK != GNUNET_HELLO_get_id (hm, &vac.pid)) || 1432 (GNUNET_NO != friend) ) ||
1414 (GNUNET_OK != GNUNET_HELLO_get_key (hm, &vac.public_key))) 1433 (GNUNET_OK != GNUNET_HELLO_get_id (hm, &vac.pid)) ||
1434 (GNUNET_OK != GNUNET_HELLO_get_key (hm, &vac.public_key)))
1415 { 1435 {
1416 /* malformed HELLO */ 1436 /* malformed HELLO */
1417 GNUNET_break (0); 1437 GNUNET_break_op (0);
1418 return; 1438 return GNUNET_SYSERR;
1419 } 1439 }
1420 if (0 == 1440 if (0 ==
1421 memcmp (&GST_my_identity, &vac.pid, sizeof (struct GNUNET_PeerIdentity))) 1441 memcmp (&GST_my_identity, &vac.pid, sizeof (struct GNUNET_PeerIdentity)))
1422 return; 1442 return GNUNET_OK;
1423 /* Add peer identity without addresses to peerinfo service */ 1443 /* Add peer identity without addresses to peerinfo service */
1424 h = GNUNET_HELLO_create (&vac.public_key, NULL, NULL, friend); 1444 h = GNUNET_HELLO_create (&vac.public_key, NULL, NULL, friend);
1425 GNUNET_PEERINFO_add_peer (GST_peerinfo, h, NULL, NULL); 1445 GNUNET_PEERINFO_add_peer (GST_peerinfo, h, NULL, NULL);
@@ -1433,11 +1453,12 @@ GST_validation_handle_hello (const struct GNUNET_MessageHeader *hello)
1433 GNUNET_HELLO_iterate_addresses (hm, GNUNET_NO, 1453 GNUNET_HELLO_iterate_addresses (hm, GNUNET_NO,
1434 &validate_address_iterator, 1454 &validate_address_iterator,
1435 &vac)); 1455 &vac));
1456 return GNUNET_OK;
1436} 1457}
1437 1458
1438 1459
1439/** 1460/**
1440 * Closure for 'iterate_addresses' 1461 * Closure for #iterate_addresses().
1441 */ 1462 */
1442struct IteratorContext 1463struct IteratorContext
1443{ 1464{
@@ -1447,7 +1468,7 @@ struct IteratorContext
1447 GST_ValidationAddressCallback cb; 1468 GST_ValidationAddressCallback cb;
1448 1469
1449 /** 1470 /**
1450 * Closure for 'cb'. 1471 * Closure for @e cb.
1451 */ 1472 */
1452 void *cb_cls; 1473 void *cb_cls;
1453 1474
@@ -1457,9 +1478,9 @@ struct IteratorContext
1457/** 1478/**
1458 * Call the callback in the closure for each validation entry. 1479 * Call the callback in the closure for each validation entry.
1459 * 1480 *
1460 * @param cls the 'struct GST_ValidationIteratorContext' 1481 * @param cls the `struct IteratorContext`
1461 * @param key the peer's identity 1482 * @param key the peer's identity
1462 * @param value the 'struct ValidationEntry' 1483 * @param value the `struct ValidationEntry`
1463 * @return #GNUNET_OK (continue to iterate) 1484 * @return #GNUNET_OK (continue to iterate)
1464 */ 1485 */
1465static int 1486static int
diff --git a/src/transport/gnunet-service-transport_validation.h b/src/transport/gnunet-service-transport_validation.h
index 3408f50bb..c37484f13 100644
--- a/src/transport/gnunet-service-transport_validation.h
+++ b/src/transport/gnunet-service-transport_validation.h
@@ -89,8 +89,9 @@ GST_validation_get_address_latency (const struct GNUNET_PeerIdentity *sender,
89 * @param hdr the PING 89 * @param hdr the PING
90 * @param sender_address address of the sender, NULL if we did not initiate 90 * @param sender_address address of the sender, NULL if we did not initiate
91 * @param session session we got the PING from 91 * @param session session we got the PING from
92 * @return #GNUNET_OK if the message was fine, #GNUNET_SYSERR on serious error
92 */ 93 */
93void 94int
94GST_validation_handle_ping (const struct GNUNET_PeerIdentity *sender, 95GST_validation_handle_ping (const struct GNUNET_PeerIdentity *sender,
95 const struct GNUNET_MessageHeader *hdr, 96 const struct GNUNET_MessageHeader *hdr,
96 const struct GNUNET_HELLO_Address *sender_address, 97 const struct GNUNET_HELLO_Address *sender_address,
@@ -103,8 +104,9 @@ GST_validation_handle_ping (const struct GNUNET_PeerIdentity *sender,
103 * 104 *
104 * @param sender peer sending the PONG 105 * @param sender peer sending the PONG
105 * @param hdr the PONG 106 * @param hdr the PONG
107 * @return #GNUNET_OK if the message was fine, #GNUNET_SYSERR on serious error
106 */ 108 */
107void 109int
108GST_validation_handle_pong (const struct GNUNET_PeerIdentity *sender, 110GST_validation_handle_pong (const struct GNUNET_PeerIdentity *sender,
109 const struct GNUNET_MessageHeader *hdr); 111 const struct GNUNET_MessageHeader *hdr);
110 112
@@ -114,8 +116,9 @@ GST_validation_handle_pong (const struct GNUNET_PeerIdentity *sender,
114 * validation. 116 * validation.
115 * 117 *
116 * @param hello the HELLO we received 118 * @param hello the HELLO we received
119 * @return #GNUNET_OK if the message was fine, #GNUNET_SYSERR on serious error
117 */ 120 */
118void 121int
119GST_validation_handle_hello (const struct GNUNET_MessageHeader *hello); 122GST_validation_handle_hello (const struct GNUNET_MessageHeader *hello);
120 123
121 124
diff --git a/src/transport/plugin_transport_tcp.c b/src/transport/plugin_transport_tcp.c
index c70bb8ef7..72ac5b2b8 100644
--- a/src/transport/plugin_transport_tcp.c
+++ b/src/transport/plugin_transport_tcp.c
@@ -1608,25 +1608,25 @@ static struct PrettyPrinterContext *ppc_dll_tail;
1608 */ 1608 */
1609struct PrettyPrinterContext 1609struct PrettyPrinterContext
1610{ 1610{
1611 /** 1611 /**
1612 * DLL 1612 * DLL
1613 */ 1613 */
1614 struct PrettyPrinterContext *next; 1614 struct PrettyPrinterContext *next;
1615 1615
1616 /** 1616 /**
1617 * DLL 1617 * DLL
1618 */ 1618 */
1619 struct PrettyPrinterContext *prev; 1619 struct PrettyPrinterContext *prev;
1620 1620
1621 /** 1621 /**
1622 * Timeout task 1622 * Timeout task
1623 */ 1623 */
1624 GNUNET_SCHEDULER_TaskIdentifier timeout_task; 1624 GNUNET_SCHEDULER_TaskIdentifier timeout_task;
1625 1625
1626 /** 1626 /**
1627 * Resolver handle 1627 * Resolver handle
1628 */ 1628 */
1629 struct GNUNET_RESOLVER_RequestHandle *resolver_handle; 1629 struct GNUNET_RESOLVER_RequestHandle *resolver_handle;
1630 1630
1631 /** 1631 /**
1632 * Function to call with the result. 1632 * Function to call with the result.
diff --git a/src/transport/test_transport_defaults.conf b/src/transport/test_transport_defaults.conf
index d34b60dbc..7a064fa21 100644
--- a/src/transport/test_transport_defaults.conf
+++ b/src/transport/test_transport_defaults.conf
@@ -5,10 +5,10 @@ GNUNET_TEST_HOME = /tmp/test-transport-api/
5TIMEOUT = 300 s 5TIMEOUT = 300 s
6 6
7[arm] 7[arm]
8DEFAULTSERVICES = 8DEFAULTSERVICES =
9 9
10[transport] 10[transport]
11PREFIX = 11PREFIX = valgrind
12 12
13[core] 13[core]
14AUTOSTART = NO 14AUTOSTART = NO
diff --git a/src/transport/transport.conf.in b/src/transport/transport.conf.in
index 14867c572..0464ba841 100644
--- a/src/transport/transport.conf.in
+++ b/src/transport/transport.conf.in
@@ -3,7 +3,7 @@ AUTOSTART = @AUTOSTART@
3@JAVAPORT@PORT = 2091 3@JAVAPORT@PORT = 2091
4HOSTNAME = localhost 4HOSTNAME = localhost
5BINARY = gnunet-service-transport 5BINARY = gnunet-service-transport
6#PREFIX = valgrind 6# PREFIX = valgrind
7NEIGHBOUR_LIMIT = 50 7NEIGHBOUR_LIMIT = 50
8ACCEPT_FROM = 127.0.0.1; 8ACCEPT_FROM = 127.0.0.1;
9ACCEPT_FROM6 = ::1; 9ACCEPT_FROM6 = ::1;