aboutsummaryrefslogtreecommitdiff
path: root/src/transport/plugin_transport_http_client.c
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2014-01-13 16:59:57 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2014-01-13 16:59:57 +0000
commit1257490cb630ade315a196a724d0233e662afb2c (patch)
tree0d9c01593a1aa73d8f6490127b640d67da69b54c /src/transport/plugin_transport_http_client.c
parent35d79cb1941c9f9607195b8760d8a14d836e6397 (diff)
downloadgnunet-1257490cb630ade315a196a724d0233e662afb2c.tar.gz
gnunet-1257490cb630ade315a196a724d0233e662afb2c.zip
implementing 0003268 to inbound information in HELLO addresses
All transport plugin functions are modified to use HELLO addresses instead of peer,address,address_length All plugins are modified to use HELLO addresses internally This commit can break transport functionality: core tests on my system still pass, but transport tests may still fail, errors messages may occurs or crashs Will be fixed asap
Diffstat (limited to 'src/transport/plugin_transport_http_client.c')
-rw-r--r--src/transport/plugin_transport_http_client.c93
1 files changed, 48 insertions, 45 deletions
diff --git a/src/transport/plugin_transport_http_client.c b/src/transport/plugin_transport_http_client.c
index ba7fd45a3..bd4487614 100644
--- a/src/transport/plugin_transport_http_client.c
+++ b/src/transport/plugin_transport_http_client.c
@@ -155,12 +155,7 @@ struct Session
155 /** 155 /**
156 * Address 156 * Address
157 */ 157 */
158 struct HttpAddress *addr; 158 struct GNUNET_HELLO_Address *address;
159
160 /**
161 * Address length
162 */
163 size_t addrlen;
164 159
165 /** 160 /**
166 * ATS network type in NBO 161 * ATS network type in NBO
@@ -587,7 +582,7 @@ client_delete_session (struct Session *s)
587 GNUNET_SERVER_mst_destroy (s->msg_tk); 582 GNUNET_SERVER_mst_destroy (s->msg_tk);
588 s->msg_tk = NULL; 583 s->msg_tk = NULL;
589 } 584 }
590 GNUNET_free (s->addr); 585 GNUNET_HELLO_address_free (s->address);
591 GNUNET_free (s->url); 586 GNUNET_free (s->url);
592 GNUNET_free (s); 587 GNUNET_free (s);
593} 588}
@@ -761,10 +756,11 @@ client_lookup_session (struct HTTP_Client_Plugin *plugin,
761 struct Session *pos; 756 struct Session *pos;
762 757
763 for (pos = plugin->head; NULL != pos; pos = pos->next) 758 for (pos = plugin->head; NULL != pos; pos = pos->next)
759 {
764 if ((0 == memcmp (&address->peer, &pos->target, sizeof (struct GNUNET_PeerIdentity))) && 760 if ((0 == memcmp (&address->peer, &pos->target, sizeof (struct GNUNET_PeerIdentity))) &&
765 (address->address_length == pos->addrlen) && 761 (0 == GNUNET_HELLO_address_cmp(address, pos->address)))
766 (0 == memcmp (address->address, pos->addr, pos->addrlen)))
767 return pos; 762 return pos;
763 }
768 return NULL; 764 return NULL;
769} 765}
770 766
@@ -923,14 +919,10 @@ client_receive_mst_cb (void *cls, void *client,
923 atsi.type = htonl (GNUNET_ATS_NETWORK_TYPE); 919 atsi.type = htonl (GNUNET_ATS_NETWORK_TYPE);
924 atsi.value = s->ats_address_network_type; 920 atsi.value = s->ats_address_network_type;
925 GNUNET_break (s->ats_address_network_type != ntohl (GNUNET_ATS_NET_UNSPECIFIED)); 921 GNUNET_break (s->ats_address_network_type != ntohl (GNUNET_ATS_NET_UNSPECIFIED));
926 delay = s->plugin->env->receive (plugin->env->cls, &s->target, message,
927 s, (const char *) s->addr, s->addrlen);
928 922
923 delay = s->plugin->env->receive (plugin->env->cls, s->address, s, message);
929 plugin->env->update_address_metrics (plugin->env->cls, 924 plugin->env->update_address_metrics (plugin->env->cls,
930 &s->target, 925 s->address, s,
931 s->addr,
932 s->addrlen,
933 s,
934 &atsi, 1); 926 &atsi, 1);
935 927
936 GNUNET_asprintf (&stat_txt, 928 GNUNET_asprintf (&stat_txt,
@@ -949,8 +941,8 @@ client_receive_mst_cb (void *cls, void *client,
949 "Client: peer `%s' address `%s' next read delayed for %s\n", 941 "Client: peer `%s' address `%s' next read delayed for %s\n",
950 GNUNET_i2s (&s->target), 942 GNUNET_i2s (&s->target),
951 http_common_plugin_address_to_string (NULL, 943 http_common_plugin_address_to_string (NULL,
952 s->plugin->protocol, 944 s->plugin->protocol, s->address->address,
953 s->addr, s->addrlen), 945 s->address->address_length),
954 GNUNET_STRINGS_relative_time_to_string (delay, 946 GNUNET_STRINGS_relative_time_to_string (delay,
955 GNUNET_YES)); 947 GNUNET_YES));
956 } 948 }
@@ -1241,8 +1233,8 @@ client_run (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1241static int 1233static int
1242client_connect_get (struct Session *s) 1234client_connect_get (struct Session *s)
1243{ 1235{
1244
1245 CURLMcode mret; 1236 CURLMcode mret;
1237
1246 /* create get connection */ 1238 /* create get connection */
1247 s->client_get = curl_easy_init (); 1239 s->client_get = curl_easy_init ();
1248 s->get.s = s; 1240 s->get.s = s;
@@ -1254,16 +1246,21 @@ client_connect_get (struct Session *s)
1254#endif 1246#endif
1255#if BUILD_HTTPS 1247#if BUILD_HTTPS
1256 curl_easy_setopt (s->client_get, CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1); 1248 curl_easy_setopt (s->client_get, CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1);
1257 if (HTTP_OPTIONS_VERIFY_CERTIFICATE ==
1258 (ntohl (s->addr->options) & HTTP_OPTIONS_VERIFY_CERTIFICATE))
1259 { 1249 {
1260 curl_easy_setopt (s->client_get, CURLOPT_SSL_VERIFYPEER, 1L); 1250 struct HttpAddress *ha;
1261 curl_easy_setopt (s->client_get, CURLOPT_SSL_VERIFYHOST, 2L); 1251 ha = (struct HttpAddress *) s->address->address;
1262 } 1252
1263 else 1253 if (HTTP_OPTIONS_VERIFY_CERTIFICATE ==
1264 { 1254 (ntohl (ha->options) & HTTP_OPTIONS_VERIFY_CERTIFICATE))
1265 curl_easy_setopt (s->client_get, CURLOPT_SSL_VERIFYPEER, 0); 1255 {
1266 curl_easy_setopt (s->client_get, CURLOPT_SSL_VERIFYHOST, 0); 1256 curl_easy_setopt (s->client_get, CURLOPT_SSL_VERIFYPEER, 1L);
1257 curl_easy_setopt (s->client_get, CURLOPT_SSL_VERIFYHOST, 2L);
1258 }
1259 else
1260 {
1261 curl_easy_setopt (s->client_get, CURLOPT_SSL_VERIFYPEER, 0);
1262 curl_easy_setopt (s->client_get, CURLOPT_SSL_VERIFYHOST, 0);
1263 }
1267 } 1264 }
1268 curl_easy_setopt (s->client_get, CURLOPT_PROTOCOLS, CURLPROTO_HTTPS); 1265 curl_easy_setopt (s->client_get, CURLOPT_PROTOCOLS, CURLPROTO_HTTPS);
1269 curl_easy_setopt (s->client_get, CURLOPT_REDIR_PROTOCOLS, CURLPROTO_HTTPS); 1266 curl_easy_setopt (s->client_get, CURLOPT_REDIR_PROTOCOLS, CURLPROTO_HTTPS);
@@ -1334,16 +1331,21 @@ client_connect_put (struct Session *s)
1334#endif 1331#endif
1335#if BUILD_HTTPS 1332#if BUILD_HTTPS
1336 curl_easy_setopt (s->client_put, CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1); 1333 curl_easy_setopt (s->client_put, CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1);
1337 if (HTTP_OPTIONS_VERIFY_CERTIFICATE ==
1338 (ntohl (s->addr->options) & HTTP_OPTIONS_VERIFY_CERTIFICATE))
1339 { 1334 {
1340 curl_easy_setopt (s->client_put, CURLOPT_SSL_VERIFYPEER, 1L); 1335 struct HttpAddress *ha;
1341 curl_easy_setopt (s->client_put, CURLOPT_SSL_VERIFYHOST, 2L); 1336 ha = (struct HttpAddress *) s->address->address;
1342 } 1337
1343 else 1338 if (HTTP_OPTIONS_VERIFY_CERTIFICATE ==
1344 { 1339 (ntohl (ha->options) & HTTP_OPTIONS_VERIFY_CERTIFICATE))
1345 curl_easy_setopt (s->client_put, CURLOPT_SSL_VERIFYPEER, 0); 1340 {
1346 curl_easy_setopt (s->client_put, CURLOPT_SSL_VERIFYHOST, 0); 1341 curl_easy_setopt (s->client_put, CURLOPT_SSL_VERIFYPEER, 1L);
1342 curl_easy_setopt (s->client_put, CURLOPT_SSL_VERIFYHOST, 2L);
1343 }
1344 else
1345 {
1346 curl_easy_setopt (s->client_put, CURLOPT_SSL_VERIFYPEER, 0);
1347 curl_easy_setopt (s->client_put, CURLOPT_SSL_VERIFYHOST, 0);
1348 }
1347 } 1349 }
1348 curl_easy_setopt (s->client_get, CURLOPT_PROTOCOLS, CURLPROTO_HTTPS); 1350 curl_easy_setopt (s->client_get, CURLOPT_PROTOCOLS, CURLPROTO_HTTPS);
1349 curl_easy_setopt (s->client_get, CURLOPT_REDIR_PROTOCOLS, CURLPROTO_HTTPS); 1351 curl_easy_setopt (s->client_get, CURLOPT_REDIR_PROTOCOLS, CURLPROTO_HTTPS);
@@ -1403,8 +1405,7 @@ client_connect (struct Session *s)
1403 1405
1404 /* create url */ 1406 /* create url */
1405 if (NULL == http_common_plugin_address_to_string (NULL, 1407 if (NULL == http_common_plugin_address_to_string (NULL,
1406 plugin->protocol, 1408 plugin->protocol, s->address->address, s->address->address_length))
1407 s->addr, s->addrlen))
1408 { 1409 {
1409 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, 1410 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG,
1410 plugin->name, 1411 plugin->name,
@@ -1414,7 +1415,8 @@ client_connect (struct Session *s)
1414 } 1415 }
1415 1416
1416 GNUNET_asprintf (&s->url, "%s/%s;%u", 1417 GNUNET_asprintf (&s->url, "%s/%s;%u",
1417 http_common_plugin_address_to_url (NULL, s->addr, s->addrlen), 1418 http_common_plugin_address_to_url (NULL, s->address->address,
1419 s->address->address_length),
1418 GNUNET_i2s_full (plugin->env->my_identity), 1420 GNUNET_i2s_full (plugin->env->my_identity),
1419 plugin->last_tag); 1421 plugin->last_tag);
1420 1422
@@ -1567,9 +1569,7 @@ http_client_plugin_get_session (void *cls,
1567 s = GNUNET_new (struct Session); 1569 s = GNUNET_new (struct Session);
1568 s->target = address->peer; 1570 s->target = address->peer;
1569 s->plugin = plugin; 1571 s->plugin = plugin;
1570 s->addr = GNUNET_malloc (address->address_length); 1572 s->address = GNUNET_HELLO_address_copy (address);
1571 memcpy (s->addr, address->address, address->address_length);
1572 s->addrlen = address->address_length;
1573 s->ats_address_network_type = ats.value; 1573 s->ats_address_network_type = ats.value;
1574 s->put_paused = GNUNET_NO; 1574 s->put_paused = GNUNET_NO;
1575 s->put_tmp_disconnecting = GNUNET_NO; 1575 s->put_tmp_disconnecting = GNUNET_NO;
@@ -1579,8 +1579,9 @@ http_client_plugin_get_session (void *cls,
1579 s); 1579 s);
1580 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, 1580 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
1581 "Created new session %p for `%s' address `%s''\n", 1581 "Created new session %p for `%s' address `%s''\n",
1582 s, 1582 s, http_common_plugin_address_to_string (NULL,
1583 http_common_plugin_address_to_string (NULL, plugin->protocol, s->addr, s->addrlen), 1583 plugin->protocol, s->address->address,
1584 s->address->address_length),
1584 GNUNET_i2s (&s->target)); 1585 GNUNET_i2s (&s->target));
1585 1586
1586 /* add new session */ 1587 /* add new session */
@@ -1591,7 +1592,9 @@ http_client_plugin_get_session (void *cls,
1591 { 1592 {
1592 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name, 1593 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name,
1593 "Cannot connect to peer `%s' address `%s''\n", 1594 "Cannot connect to peer `%s' address `%s''\n",
1594 http_common_plugin_address_to_string (NULL, plugin->protocol, s->addr, s->addrlen), 1595 http_common_plugin_address_to_string (NULL,
1596 plugin->protocol, s->address->address,
1597 s->address->address_length),
1595 GNUNET_i2s (&s->target)); 1598 GNUNET_i2s (&s->target));
1596 client_delete_session (s); 1599 client_delete_session (s);
1597 return NULL; 1600 return NULL;