diff options
author | Christian Grothoff <christian@grothoff.org> | 2015-01-17 22:20:18 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2015-01-17 22:20:18 +0000 |
commit | 81b92caa24a83620032438df9c5ee3ea51663a02 (patch) | |
tree | 2b2df659c94e1ead5bbdb5082e50018c39e68796 /src/transport/plugin_transport_http_client.c | |
parent | 4756cb0779daf3e4c33b6e876dce956de7ee6dd8 (diff) | |
download | gnunet-81b92caa24a83620032438df9c5ee3ea51663a02.tar.gz gnunet-81b92caa24a83620032438df9c5ee3ea51663a02.zip |
simplify ATS API and plugin API by returning the network type, instead of an ATS_Information struct
Diffstat (limited to 'src/transport/plugin_transport_http_client.c')
-rw-r--r-- | src/transport/plugin_transport_http_client.c | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/src/transport/plugin_transport_http_client.c b/src/transport/plugin_transport_http_client.c index cc1f39e9a..9c9af57ad 100644 --- a/src/transport/plugin_transport_http_client.c +++ b/src/transport/plugin_transport_http_client.c | |||
@@ -262,9 +262,9 @@ struct Session | |||
262 | unsigned int msgs_in_queue; | 262 | unsigned int msgs_in_queue; |
263 | 263 | ||
264 | /** | 264 | /** |
265 | * ATS network type in NBO | 265 | * ATS network type. |
266 | */ | 266 | */ |
267 | uint32_t ats_address_network_type; | 267 | enum GNUNET_ATS_Network_Type ats_address_network_type; |
268 | }; | 268 | }; |
269 | 269 | ||
270 | 270 | ||
@@ -1173,9 +1173,9 @@ client_receive_mst_cb (void *cls, | |||
1173 | char *stat_txt; | 1173 | char *stat_txt; |
1174 | 1174 | ||
1175 | plugin = s->plugin; | 1175 | plugin = s->plugin; |
1176 | GNUNET_break (s->ats_address_network_type != GNUNET_ATS_NET_UNSPECIFIED); | ||
1176 | atsi.type = htonl (GNUNET_ATS_NETWORK_TYPE); | 1177 | atsi.type = htonl (GNUNET_ATS_NETWORK_TYPE); |
1177 | atsi.value = s->ats_address_network_type; | 1178 | atsi.value = htonl (s->ats_address_network_type); |
1178 | GNUNET_break (s->ats_address_network_type != ntohl (GNUNET_ATS_NET_UNSPECIFIED)); | ||
1179 | 1179 | ||
1180 | delay = s->plugin->env->receive (plugin->env->cls, | 1180 | delay = s->plugin->env->receive (plugin->env->cls, |
1181 | s->address, | 1181 | s->address, |
@@ -1941,7 +1941,7 @@ static enum GNUNET_ATS_Network_Type | |||
1941 | http_client_plugin_get_network (void *cls, | 1941 | http_client_plugin_get_network (void *cls, |
1942 | struct Session *session) | 1942 | struct Session *session) |
1943 | { | 1943 | { |
1944 | return ntohl (session->ats_address_network_type); | 1944 | return session->ats_address_network_type; |
1945 | } | 1945 | } |
1946 | 1946 | ||
1947 | 1947 | ||
@@ -1998,7 +1998,7 @@ http_client_plugin_get_session (void *cls, | |||
1998 | struct HTTP_Client_Plugin *plugin = cls; | 1998 | struct HTTP_Client_Plugin *plugin = cls; |
1999 | struct Session *s; | 1999 | struct Session *s; |
2000 | struct sockaddr *sa; | 2000 | struct sockaddr *sa; |
2001 | struct GNUNET_ATS_Information ats; | 2001 | enum GNUNET_ATS_Network_Type net_type; |
2002 | size_t salen = 0; | 2002 | size_t salen = 0; |
2003 | int res; | 2003 | int res; |
2004 | 2004 | ||
@@ -2021,8 +2021,7 @@ http_client_plugin_get_session (void *cls, | |||
2021 | } | 2021 | } |
2022 | 2022 | ||
2023 | /* Determine network location */ | 2023 | /* Determine network location */ |
2024 | ats.type = htonl (GNUNET_ATS_NETWORK_TYPE); | 2024 | net_type = GNUNET_ATS_NET_UNSPECIFIED; |
2025 | ats.value = htonl (GNUNET_ATS_NET_UNSPECIFIED); | ||
2026 | sa = http_common_socket_from_address (address->address, | 2025 | sa = http_common_socket_from_address (address->address, |
2027 | address->address_length, | 2026 | address->address_length, |
2028 | &res); | 2027 | &res); |
@@ -2039,15 +2038,15 @@ http_client_plugin_get_session (void *cls, | |||
2039 | { | 2038 | { |
2040 | salen = sizeof (struct sockaddr_in6); | 2039 | salen = sizeof (struct sockaddr_in6); |
2041 | } | 2040 | } |
2042 | ats = plugin->env->get_address_type (plugin->env->cls, sa, salen); | 2041 | net_type = plugin->env->get_address_type (plugin->env->cls, sa, salen); |
2043 | GNUNET_free (sa); | 2042 | GNUNET_free (sa); |
2044 | } | 2043 | } |
2045 | else if (GNUNET_NO == res) | 2044 | else if (GNUNET_NO == res) |
2046 | { | 2045 | { |
2047 | /* Cannot convert to sockaddr -> is external hostname */ | 2046 | /* Cannot convert to sockaddr -> is external hostname */ |
2048 | ats.value = htonl (GNUNET_ATS_NET_WAN); | 2047 | net_type = GNUNET_ATS_NET_WAN; |
2049 | } | 2048 | } |
2050 | if (GNUNET_ATS_NET_UNSPECIFIED == ntohl (ats.value)) | 2049 | if (GNUNET_ATS_NET_UNSPECIFIED == net_type) |
2051 | { | 2050 | { |
2052 | GNUNET_break (0); | 2051 | GNUNET_break (0); |
2053 | return NULL; | 2052 | return NULL; |
@@ -2056,7 +2055,7 @@ http_client_plugin_get_session (void *cls, | |||
2056 | s = GNUNET_new (struct Session); | 2055 | s = GNUNET_new (struct Session); |
2057 | s->plugin = plugin; | 2056 | s->plugin = plugin; |
2058 | s->address = GNUNET_HELLO_address_copy (address); | 2057 | s->address = GNUNET_HELLO_address_copy (address); |
2059 | s->ats_address_network_type = ats.value; | 2058 | s->ats_address_network_type = net_type; |
2060 | 2059 | ||
2061 | s->put.state = H_NOT_CONNECTED; | 2060 | s->put.state = H_NOT_CONNECTED; |
2062 | s->timeout = GNUNET_TIME_relative_to_absolute (HTTP_CLIENT_SESSION_TIMEOUT); | 2061 | s->timeout = GNUNET_TIME_relative_to_absolute (HTTP_CLIENT_SESSION_TIMEOUT); |