diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2011-12-13 16:20:08 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2011-12-13 16:20:08 +0000 |
commit | 7a438fbe3fef1e86c970d0c86c01156b587ecd3e (patch) | |
tree | dd29306ecd6d7e3bbec393c9d3633846759c7c1c /src/transport/plugin_transport_tcp.c | |
parent | 46e6c331e6c462f2de9f168b25276dbc7970760e (diff) | |
download | gnunet-7a438fbe3fef1e86c970d0c86c01156b587ecd3e.tar.gz gnunet-7a438fbe3fef1e86c970d0c86c01156b587ecd3e.zip |
changes:
changed order of startup since ats is now required for plugins
transport provides ATS handles for plugins
network detection for tcp
Diffstat (limited to 'src/transport/plugin_transport_tcp.c')
-rw-r--r-- | src/transport/plugin_transport_tcp.c | 33 |
1 files changed, 30 insertions, 3 deletions
diff --git a/src/transport/plugin_transport_tcp.c b/src/transport/plugin_transport_tcp.c index 1f5327c93..bfe1dc805 100644 --- a/src/transport/plugin_transport_tcp.c +++ b/src/transport/plugin_transport_tcp.c | |||
@@ -295,6 +295,10 @@ struct Session | |||
295 | */ | 295 | */ |
296 | int is_nat; | 296 | int is_nat; |
297 | 297 | ||
298 | /** | ||
299 | * ATS network type in NBO | ||
300 | */ | ||
301 | uint32_t ats_address_network_type; | ||
298 | }; | 302 | }; |
299 | 303 | ||
300 | 304 | ||
@@ -1122,6 +1126,15 @@ tcp_plugin_send (void *cls, const struct GNUNET_PeerIdentity *target, | |||
1122 | session->connect_addr = GNUNET_malloc (addrlen); | 1126 | session->connect_addr = GNUNET_malloc (addrlen); |
1123 | memcpy (session->connect_addr, addr, addrlen); | 1127 | memcpy (session->connect_addr, addr, addrlen); |
1124 | session->connect_alen = addrlen; | 1128 | session->connect_alen = addrlen; |
1129 | if ((addrlen != 0) && (plugin->env->ats != NULL)) | ||
1130 | { | ||
1131 | struct GNUNET_ATS_Information ats; | ||
1132 | GNUNET_assert(plugin->env->ats != NULL); | ||
1133 | ats = GNUNET_ATS_address_get_type(plugin->env->ats, sb ,sbs); | ||
1134 | session->ats_address_network_type = ats.value; | ||
1135 | } | ||
1136 | else | ||
1137 | GNUNET_break (0); | ||
1125 | } | 1138 | } |
1126 | else /* session != NULL */ | 1139 | else /* session != NULL */ |
1127 | { | 1140 | { |
@@ -1605,6 +1618,7 @@ handle_tcp_welcome (void *cls, struct GNUNET_SERVER_Client *client, | |||
1605 | "Found address `%s' for incoming connection\n", | 1618 | "Found address `%s' for incoming connection\n", |
1606 | GNUNET_a2s (vaddr, alen)); | 1619 | GNUNET_a2s (vaddr, alen)); |
1607 | #endif | 1620 | #endif |
1621 | |||
1608 | if (alen == sizeof (struct sockaddr_in)) | 1622 | if (alen == sizeof (struct sockaddr_in)) |
1609 | { | 1623 | { |
1610 | s4 = vaddr; | 1624 | s4 = vaddr; |
@@ -1624,6 +1638,15 @@ handle_tcp_welcome (void *cls, struct GNUNET_SERVER_Client *client, | |||
1624 | session->connect_alen = sizeof (struct IPv6TcpAddress); | 1638 | session->connect_alen = sizeof (struct IPv6TcpAddress); |
1625 | } | 1639 | } |
1626 | 1640 | ||
1641 | if (plugin->env->ats != NULL) | ||
1642 | { | ||
1643 | struct GNUNET_ATS_Information ats; | ||
1644 | GNUNET_assert(plugin->env->ats != NULL); | ||
1645 | ats = GNUNET_ATS_address_get_type(plugin->env->ats, vaddr ,alen); | ||
1646 | session->ats_address_network_type = ats.value; | ||
1647 | } | ||
1648 | else | ||
1649 | GNUNET_break (0); | ||
1627 | GNUNET_free (vaddr); | 1650 | GNUNET_free (vaddr); |
1628 | } | 1651 | } |
1629 | else | 1652 | else |
@@ -1731,10 +1754,14 @@ handle_tcp_data (void *cls, struct GNUNET_SERVER_Client *client, | |||
1731 | GNUNET_STATISTICS_update (plugin->env->stats, | 1754 | GNUNET_STATISTICS_update (plugin->env->stats, |
1732 | gettext_noop ("# bytes received via TCP"), | 1755 | gettext_noop ("# bytes received via TCP"), |
1733 | ntohs (message->size), GNUNET_NO); | 1756 | ntohs (message->size), GNUNET_NO); |
1734 | struct GNUNET_ATS_Information distance; | 1757 | struct GNUNET_ATS_Information distance[2]; |
1758 | |||
1759 | distance[0].type = htonl (GNUNET_ATS_QUALITY_NET_DISTANCE); | ||
1760 | distance[0].value = htonl (1); | ||
1761 | distance[1].type = htonl (GNUNET_ATS_NETWORK_TYPE); | ||
1762 | distance[1].value = session->ats_address_network_type; | ||
1763 | GNUNET_break (ntohl(session->ats_address_network_type) != GNUNET_ATS_NET_UNSPECIFIED); | ||
1735 | 1764 | ||
1736 | distance.type = htonl (GNUNET_ATS_QUALITY_NET_DISTANCE); | ||
1737 | distance.value = htonl (1); | ||
1738 | delay = | 1765 | delay = |
1739 | plugin->env->receive (plugin->env->cls, &session->target, message, | 1766 | plugin->env->receive (plugin->env->cls, &session->target, message, |
1740 | (const struct GNUNET_ATS_Information *) &distance, | 1767 | (const struct GNUNET_ATS_Information *) &distance, |