aboutsummaryrefslogtreecommitdiff
path: root/src/transport/plugin_transport_tcp.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2015-02-10 23:24:01 +0000
committerChristian Grothoff <christian@grothoff.org>2015-02-10 23:24:01 +0000
commit1c323bd4cbb388a9e7515a1f733a3062bf093aee (patch)
tree7cc525d79149d44840b9f7a0040aaf3e69ecd665 /src/transport/plugin_transport_tcp.c
parentaedaaed687db1ff20b447378f01ad7306921450c (diff)
downloadgnunet-1c323bd4cbb388a9e7515a1f733a3062bf093aee.tar.gz
gnunet-1c323bd4cbb388a9e7515a1f733a3062bf093aee.zip
fixing #3657 (replace ATS_Information with struct), but WIHTOUT fixing ATS testcases yet
Diffstat (limited to 'src/transport/plugin_transport_tcp.c')
-rw-r--r--src/transport/plugin_transport_tcp.c43
1 files changed, 16 insertions, 27 deletions
diff --git a/src/transport/plugin_transport_tcp.c b/src/transport/plugin_transport_tcp.c
index 5396d5247..19ce855d8 100644
--- a/src/transport/plugin_transport_tcp.c
+++ b/src/transport/plugin_transport_tcp.c
@@ -331,6 +331,11 @@ struct Session
331 unsigned int msgs_in_queue; 331 unsigned int msgs_in_queue;
332 332
333 /** 333 /**
334 * Network type of the address.
335 */
336 enum GNUNET_ATS_Network_Type scope;
337
338 /**
334 * Are we still expecting the welcome message? (#GNUNET_YES/#GNUNET_NO) 339 * Are we still expecting the welcome message? (#GNUNET_YES/#GNUNET_NO)
335 */ 340 */
336 int expecting_welcome; 341 int expecting_welcome;
@@ -340,12 +345,9 @@ struct Session
340 */ 345 */
341 int is_nat; 346 int is_nat;
342 347
343 /**
344 * ATS network type in NBO
345 */
346 enum GNUNET_ATS_Network_Type ats_address_network_type;
347}; 348};
348 349
350
349/** 351/**
350 * Encapsulation of all of the state of the plugin. 352 * Encapsulation of all of the state of the plugin.
351 */ 353 */
@@ -1011,7 +1013,7 @@ create_session (struct Plugin *plugin,
1011 session->address = GNUNET_HELLO_address_copy (address); 1013 session->address = GNUNET_HELLO_address_copy (address);
1012 session->target = address->peer; 1014 session->target = address->peer;
1013 session->expecting_welcome = GNUNET_YES; 1015 session->expecting_welcome = GNUNET_YES;
1014 session->ats_address_network_type = GNUNET_ATS_NET_UNSPECIFIED; 1016 session->scope = GNUNET_ATS_NET_UNSPECIFIED;
1015 pm = GNUNET_malloc (sizeof (struct PendingMessage) + 1017 pm = GNUNET_malloc (sizeof (struct PendingMessage) +
1016 sizeof (struct WelcomeMessage)); 1018 sizeof (struct WelcomeMessage));
1017 pm->msg = (const char *) &pm[1]; 1019 pm->msg = (const char *) &pm[1];
@@ -1627,7 +1629,7 @@ tcp_plugin_get_session (void *cls,
1627 } 1629 }
1628 1630
1629 net_type = plugin->env->get_address_type (plugin->env->cls, sb, sbs); 1631 net_type = plugin->env->get_address_type (plugin->env->cls, sb, sbs);
1630 1632 GNUNET_break (net_type != GNUNET_ATS_NET_UNSPECIFIED);
1631 1633
1632 if ((is_natd == GNUNET_YES) && (addrlen == sizeof(struct IPv6TcpAddress))) 1634 if ((is_natd == GNUNET_YES) && (addrlen == sizeof(struct IPv6TcpAddress)))
1633 { 1635 {
@@ -1661,8 +1663,7 @@ tcp_plugin_get_session (void *cls,
1661 address, 1663 address,
1662 NULL, 1664 NULL,
1663 GNUNET_YES); 1665 GNUNET_YES);
1664 session->ats_address_network_type = net_type; 1666 session->scope = net_type;
1665 GNUNET_break (session->ats_address_network_type != GNUNET_ATS_NET_UNSPECIFIED);
1666 session->nat_connection_timeout = GNUNET_SCHEDULER_add_delayed (NAT_TIMEOUT, 1667 session->nat_connection_timeout = GNUNET_SCHEDULER_add_delayed (NAT_TIMEOUT,
1667 &nat_connect_timeout, 1668 &nat_connect_timeout,
1668 session); 1669 session);
@@ -1759,9 +1760,9 @@ tcp_plugin_get_session (void *cls,
1759 address, 1760 address,
1760 GNUNET_SERVER_connect_socket (plugin->server, sa), 1761 GNUNET_SERVER_connect_socket (plugin->server, sa),
1761 GNUNET_NO); 1762 GNUNET_NO);
1762 session->ats_address_network_type = net_type; 1763 session->scope = net_type;
1763 GNUNET_break (session->ats_address_network_type != GNUNET_ATS_NET_UNSPECIFIED); 1764 GNUNET_SERVER_client_set_user_context (session->client,
1764 GNUNET_SERVER_client_set_user_context(session->client, session); 1765 session);
1765 GNUNET_CONTAINER_multipeermap_put (plugin->sessionmap, 1766 GNUNET_CONTAINER_multipeermap_put (plugin->sessionmap,
1766 &session->target, 1767 &session->target,
1767 session, 1768 session,
@@ -2253,6 +2254,7 @@ handle_tcp_nat_probe (void *cls,
2253 GNUNET_SERVER_receive_done (client, GNUNET_OK); 2254 GNUNET_SERVER_receive_done (client, GNUNET_OK);
2254} 2255}
2255 2256
2257
2256/** 2258/**
2257 * We've received a welcome from this peer via TCP. Possibly create a 2259 * We've received a welcome from this peer via TCP. Possibly create a
2258 * fresh client record and send back our welcome. 2260 * fresh client record and send back our welcome.
@@ -2276,8 +2278,6 @@ handle_tcp_welcome (void *cls,
2276 struct IPv6TcpAddress t6; 2278 struct IPv6TcpAddress t6;
2277 const struct sockaddr_in *s4; 2279 const struct sockaddr_in *s4;
2278 const struct sockaddr_in6 *s6; 2280 const struct sockaddr_in6 *s6;
2279 struct GNUNET_ATS_Information ats;
2280
2281 2281
2282 if (0 == memcmp (&wm->clientIdentity, 2282 if (0 == memcmp (&wm->clientIdentity,
2283 plugin->env->my_identity, 2283 plugin->env->my_identity,
@@ -2369,12 +2369,10 @@ handle_tcp_welcome (void *cls,
2369 client, 2369 client,
2370 GNUNET_NO); 2370 GNUNET_NO);
2371 GNUNET_HELLO_address_free (address); 2371 GNUNET_HELLO_address_free (address);
2372 session->ats_address_network_type 2372 session->scope
2373 = plugin->env->get_address_type (plugin->env->cls, 2373 = plugin->env->get_address_type (plugin->env->cls,
2374 vaddr, 2374 vaddr,
2375 alen); 2375 alen);
2376 ats.type = htonl (GNUNET_ATS_NETWORK_TYPE);
2377 ats.value = htonl (session->ats_address_network_type);
2378 LOG (GNUNET_ERROR_TYPE_DEBUG, 2376 LOG (GNUNET_ERROR_TYPE_DEBUG,
2379 "Creating new%s session %p for peer `%s' client %p \n", 2377 "Creating new%s session %p for peer `%s' client %p \n",
2380 GNUNET_HELLO_address_check_option (session->address, 2378 GNUNET_HELLO_address_check_option (session->address,
@@ -2395,7 +2393,7 @@ handle_tcp_welcome (void *cls,
2395 plugin->env->session_start (plugin->env->cls, 2393 plugin->env->session_start (plugin->env->cls,
2396 session->address, 2394 session->address,
2397 session, 2395 session,
2398 &ats, 1); 2396 session->scope);
2399 notify_session_monitor (plugin, 2397 notify_session_monitor (plugin,
2400 session, 2398 session,
2401 GNUNET_TRANSPORT_SS_INIT); 2399 GNUNET_TRANSPORT_SS_INIT);
@@ -2443,7 +2441,6 @@ handle_tcp_data (void *cls,
2443 struct Session *session; 2441 struct Session *session;
2444 struct GNUNET_TIME_Relative delay; 2442 struct GNUNET_TIME_Relative delay;
2445 uint16_t type; 2443 uint16_t type;
2446 struct GNUNET_ATS_Information distance;
2447 2444
2448 type = ntohs (message->type); 2445 type = ntohs (message->type);
2449 if ( (GNUNET_MESSAGE_TYPE_TRANSPORT_TCP_WELCOME == type) || 2446 if ( (GNUNET_MESSAGE_TYPE_TRANSPORT_TCP_WELCOME == type) ||
@@ -2507,10 +2504,6 @@ handle_tcp_data (void *cls,
2507 ntohs (message->size), 2504 ntohs (message->size),
2508 GNUNET_NO); 2505 GNUNET_NO);
2509 2506
2510 distance.type = htonl (GNUNET_ATS_NETWORK_TYPE);
2511 distance.value = htonl ((uint32_t) session->ats_address_network_type);
2512 GNUNET_break (session->ats_address_network_type != GNUNET_ATS_NET_UNSPECIFIED);
2513
2514 GNUNET_assert (GNUNET_CONTAINER_multipeermap_contains_value (plugin->sessionmap, 2507 GNUNET_assert (GNUNET_CONTAINER_multipeermap_contains_value (plugin->sessionmap,
2515 &session->target, 2508 &session->target,
2516 session)); 2509 session));
@@ -2518,10 +2511,6 @@ handle_tcp_data (void *cls,
2518 session->address, 2511 session->address,
2519 session, 2512 session,
2520 message); 2513 message);
2521 plugin->env->update_address_metrics (plugin->env->cls,
2522 session->address,
2523 session,
2524 &distance, 1);
2525 reschedule_session_timeout (session); 2514 reschedule_session_timeout (session);
2526 if (0 == delay.rel_value_us) 2515 if (0 == delay.rel_value_us)
2527 { 2516 {
@@ -2680,7 +2669,7 @@ static enum GNUNET_ATS_Network_Type
2680tcp_plugin_get_network (void *cls, 2669tcp_plugin_get_network (void *cls,
2681 struct Session *session) 2670 struct Session *session)
2682{ 2671{
2683 return session->ats_address_network_type; 2672 return session->scope;
2684} 2673}
2685 2674
2686 2675