aboutsummaryrefslogtreecommitdiff
path: root/src/transport/plugin_transport_http.c
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2011-12-14 10:25:30 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2011-12-14 10:25:30 +0000
commit99f22366b29bf928a4fb18c36a63bf4d3b122e88 (patch)
tree7a302d0c0ee2c76f2dc2146a58a0a4b6fc54f083 /src/transport/plugin_transport_http.c
parent2a46bac24eaca8ce16d12359e88f4a9d3cf49c28 (diff)
downloadgnunet-99f22366b29bf928a4fb18c36a63bf4d3b122e88.tar.gz
gnunet-99f22366b29bf928a4fb18c36a63bf4d3b122e88.zip
WAN/LAN for HTTP/S
Diffstat (limited to 'src/transport/plugin_transport_http.c')
-rw-r--r--src/transport/plugin_transport_http.c29
1 files changed, 23 insertions, 6 deletions
diff --git a/src/transport/plugin_transport_http.c b/src/transport/plugin_transport_http.c
index 502e26597..b290e5ba2 100644
--- a/src/transport/plugin_transport_http.c
+++ b/src/transport/plugin_transport_http.c
@@ -264,16 +264,19 @@ http_plugin_receive (void *cls, const struct GNUNET_PeerIdentity *peer,
264{ 264{
265 struct Session *s = cls; 265 struct Session *s = cls;
266 struct Plugin *plugin = s->plugin; 266 struct Plugin *plugin = s->plugin;
267 struct GNUNET_ATS_Information distance;
268 struct GNUNET_TIME_Relative delay; 267 struct GNUNET_TIME_Relative delay;
268 struct GNUNET_ATS_Information atsi[2];
269 269
270 distance.type = htonl (GNUNET_ATS_QUALITY_NET_DISTANCE); 270 atsi[0].type = htonl (GNUNET_ATS_QUALITY_NET_DISTANCE);
271 distance.value = htonl (1); 271 atsi[0].value = htonl (1);
272 atsi[1].type = htonl (GNUNET_ATS_NETWORK_TYPE);
273 atsi[1].value = session->ats_address_network_type;
274 GNUNET_break (session->ats_address_network_type != ntohl (GNUNET_ATS_NET_UNSPECIFIED));
272 275
273 delay = 276 delay =
274 plugin->env->receive (plugin->env->cls, &s->target, message, 277 plugin->env->receive (plugin->env->cls, &s->target, message,
275 (const struct GNUNET_ATS_Information *) &distance, 278 (const struct GNUNET_ATS_Information *) &atsi,
276 1, s, s->addr, s->addrlen); 279 2, s, s->addr, s->addrlen);
277 return delay; 280 return delay;
278} 281}
279 282
@@ -452,6 +455,7 @@ create_session (struct Plugin *plugin, const struct GNUNET_PeerIdentity *target,
452 s->addrlen = addrlen; 455 s->addrlen = addrlen;
453 s->next = NULL; 456 s->next = NULL;
454 s->next_receive = GNUNET_TIME_absolute_get_zero (); 457 s->next_receive = GNUNET_TIME_absolute_get_zero ();
458 s->ats_address_network_type = htonl (GNUNET_ATS_NET_UNSPECIFIED);
455 return s; 459 return s;
456} 460}
457 461
@@ -564,10 +568,16 @@ http_plugin_send (void *cls, const struct GNUNET_PeerIdentity *target,
564 GNUNET_i2s (target)); 568 GNUNET_i2s (target));
565#endif 569#endif
566 int res = GNUNET_OK; 570 int res = GNUNET_OK;
567 571 struct GNUNET_ATS_Information ats;
568 if (addrlen == sizeof (struct IPv4HttpAddress)) 572 if (addrlen == sizeof (struct IPv4HttpAddress))
569 { 573 {
570 struct IPv4HttpAddress *a4 = (struct IPv4HttpAddress *) addr; 574 struct IPv4HttpAddress *a4 = (struct IPv4HttpAddress *) addr;
575 struct sockaddr_in s4;
576
577 s4.sin_family = AF_INET;
578 s4.sin_addr.s_addr = a4->ipv4_addr;
579 s4.sin_port = a4->u4_port;
580 ats = plugin->env->get_address_type (plugin->env->cls, (const struct sockaddr *) &s4, sizeof (struct sockaddr_in));
571 581
572 if ((ntohs (a4->u4_port) == 0) || (plugin->ipv4 == GNUNET_NO)) 582 if ((ntohs (a4->u4_port) == 0) || (plugin->ipv4 == GNUNET_NO))
573 res = GNUNET_SYSERR; 583 res = GNUNET_SYSERR;
@@ -575,6 +585,12 @@ http_plugin_send (void *cls, const struct GNUNET_PeerIdentity *target,
575 if (addrlen == sizeof (struct IPv6HttpAddress)) 585 if (addrlen == sizeof (struct IPv6HttpAddress))
576 { 586 {
577 struct IPv6HttpAddress *a6 = (struct IPv6HttpAddress *) addr; 587 struct IPv6HttpAddress *a6 = (struct IPv6HttpAddress *) addr;
588 struct sockaddr_in6 s6;
589
590 s6.sin6_family = AF_INET6;
591 s6.sin6_addr = a6->ipv6_addr;
592 s6.sin6_port = a6->u6_port;
593 ats = plugin->env->get_address_type (plugin->env->cls, (const struct sockaddr *) &s6, sizeof (struct sockaddr_in6));
578 594
579 if ((ntohs (a6->u6_port) == 0) || (plugin->ipv6 == GNUNET_NO)) 595 if ((ntohs (a6->u6_port) == 0) || (plugin->ipv6 == GNUNET_NO))
580 res = GNUNET_SYSERR; 596 res = GNUNET_SYSERR;
@@ -582,6 +598,7 @@ http_plugin_send (void *cls, const struct GNUNET_PeerIdentity *target,
582 if (res == GNUNET_OK) 598 if (res == GNUNET_OK)
583 { 599 {
584 s = create_session (plugin, target, addr, addrlen, cont, cont_cls); 600 s = create_session (plugin, target, addr, addrlen, cont, cont_cls);
601 s->ats_address_network_type = ats.value;
585 GNUNET_CONTAINER_DLL_insert (plugin->head, plugin->tail, s); 602 GNUNET_CONTAINER_DLL_insert (plugin->head, plugin->tail, s);
586 // initiate new connection 603 // initiate new connection
587 res = client_connect (s); 604 res = client_connect (s);