diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2011-12-14 10:25:30 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2011-12-14 10:25:30 +0000 |
commit | 99f22366b29bf928a4fb18c36a63bf4d3b122e88 (patch) | |
tree | 7a302d0c0ee2c76f2dc2146a58a0a4b6fc54f083 /src/transport | |
parent | 2a46bac24eaca8ce16d12359e88f4a9d3cf49c28 (diff) | |
download | gnunet-99f22366b29bf928a4fb18c36a63bf4d3b122e88.tar.gz gnunet-99f22366b29bf928a4fb18c36a63bf4d3b122e88.zip |
WAN/LAN for HTTP/S
Diffstat (limited to 'src/transport')
-rw-r--r-- | src/transport/plugin_transport_http.c | 29 | ||||
-rw-r--r-- | src/transport/plugin_transport_http.h | 5 | ||||
-rw-r--r-- | src/transport/plugin_transport_http_server.c | 6 | ||||
-rw-r--r-- | src/transport/plugin_transport_tcp.c | 1 |
4 files changed, 34 insertions, 7 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); |
diff --git a/src/transport/plugin_transport_http.h b/src/transport/plugin_transport_http.h index 6835beab4..84a92c284 100644 --- a/src/transport/plugin_transport_http.h +++ b/src/transport/plugin_transport_http.h | |||
@@ -325,6 +325,11 @@ struct Session | |||
325 | size_t addrlen; | 325 | size_t addrlen; |
326 | 326 | ||
327 | /** | 327 | /** |
328 | * ATS network type in NBO | ||
329 | */ | ||
330 | uint32_t ats_address_network_type; | ||
331 | |||
332 | /** | ||
328 | * To whom are we talking to | 333 | * To whom are we talking to |
329 | */ | 334 | */ |
330 | struct GNUNET_PeerIdentity target; | 335 | struct GNUNET_PeerIdentity target; |
diff --git a/src/transport/plugin_transport_http_server.c b/src/transport/plugin_transport_http_server.c index 24c27aced..10c8268b1 100644 --- a/src/transport/plugin_transport_http_server.c +++ b/src/transport/plugin_transport_http_server.c | |||
@@ -369,7 +369,7 @@ server_lookup_session (struct Plugin *plugin, | |||
369 | struct Session *t; | 369 | struct Session *t; |
370 | struct ServerConnection *sc = NULL; | 370 | struct ServerConnection *sc = NULL; |
371 | const union MHD_ConnectionInfo *conn_info; | 371 | const union MHD_ConnectionInfo *conn_info; |
372 | 372 | struct GNUNET_ATS_Information ats; | |
373 | struct IPv4HttpAddress a4; | 373 | struct IPv4HttpAddress a4; |
374 | struct IPv6HttpAddress a6; | 374 | struct IPv6HttpAddress a6; |
375 | struct sockaddr_in *s4; | 375 | struct sockaddr_in *s4; |
@@ -521,6 +521,7 @@ create: | |||
521 | GNUNET_i2s (&target)); | 521 | GNUNET_i2s (&target)); |
522 | #endif | 522 | #endif |
523 | 523 | ||
524 | |||
524 | switch (conn_info->client_addr->sa_family) | 525 | switch (conn_info->client_addr->sa_family) |
525 | { | 526 | { |
526 | case (AF_INET): | 527 | case (AF_INET): |
@@ -529,6 +530,7 @@ create: | |||
529 | memcpy (&a4.ipv4_addr, &s4->sin_addr, sizeof (struct in_addr)); | 530 | memcpy (&a4.ipv4_addr, &s4->sin_addr, sizeof (struct in_addr)); |
530 | a = &a4; | 531 | a = &a4; |
531 | a_len = sizeof (struct IPv4HttpAddress); | 532 | a_len = sizeof (struct IPv4HttpAddress); |
533 | ats = plugin->env->get_address_type (plugin->env->cls, (const struct sockaddr *) s4, sizeof (struct sockaddr_in)); | ||
532 | break; | 534 | break; |
533 | case (AF_INET6): | 535 | case (AF_INET6): |
534 | s6 = ((struct sockaddr_in6 *) conn_info->client_addr); | 536 | s6 = ((struct sockaddr_in6 *) conn_info->client_addr); |
@@ -536,12 +538,14 @@ create: | |||
536 | memcpy (&a6.ipv6_addr, &s6->sin6_addr, sizeof (struct in6_addr)); | 538 | memcpy (&a6.ipv6_addr, &s6->sin6_addr, sizeof (struct in6_addr)); |
537 | a = &a6; | 539 | a = &a6; |
538 | a_len = sizeof (struct IPv6HttpAddress); | 540 | a_len = sizeof (struct IPv6HttpAddress); |
541 | ats = plugin->env->get_address_type (plugin->env->cls, (const struct sockaddr *) s6, sizeof (struct sockaddr_in6)); | ||
539 | break; | 542 | break; |
540 | default: | 543 | default: |
541 | GNUNET_break (0); | 544 | GNUNET_break (0); |
542 | goto error; | 545 | goto error; |
543 | } | 546 | } |
544 | s = create_session (plugin, &target, a, a_len, NULL, NULL); | 547 | s = create_session (plugin, &target, a, a_len, NULL, NULL); |
548 | s->ats_address_network_type = ats.value; | ||
545 | 549 | ||
546 | s->inbound = GNUNET_YES; | 550 | s->inbound = GNUNET_YES; |
547 | s->next_receive = GNUNET_TIME_absolute_get_zero (); | 551 | s->next_receive = GNUNET_TIME_absolute_get_zero (); |
diff --git a/src/transport/plugin_transport_tcp.c b/src/transport/plugin_transport_tcp.c index dfd4ccee0..347ff8d14 100644 --- a/src/transport/plugin_transport_tcp.c +++ b/src/transport/plugin_transport_tcp.c | |||
@@ -581,6 +581,7 @@ create_session (struct Plugin *plugin, const struct GNUNET_PeerIdentity *target, | |||
581 | ret->client = client; | 581 | ret->client = client; |
582 | ret->target = *target; | 582 | ret->target = *target; |
583 | ret->expecting_welcome = GNUNET_YES; | 583 | ret->expecting_welcome = GNUNET_YES; |
584 | ret->ats_address_network_type = htonl (GNUNET_ATS_NET_UNSPECIFIED); | ||
584 | pm = GNUNET_malloc (sizeof (struct PendingMessage) + | 585 | pm = GNUNET_malloc (sizeof (struct PendingMessage) + |
585 | sizeof (struct WelcomeMessage)); | 586 | sizeof (struct WelcomeMessage)); |
586 | pm->msg = (const char *) &pm[1]; | 587 | pm->msg = (const char *) &pm[1]; |