From 27294d85406ed2c51b53112b42915141f866ff1e Mon Sep 17 00:00:00 2001 From: Matthias Wachs Date: Thu, 15 Jul 2010 09:31:18 +0000 Subject: not skipping loopback devices --- src/transport/Makefile.am | 14 ++++++++++++++ src/transport/plugin_transport_http.c | 13 +++++++++---- src/transport/test_plugin_transport_http.c | 6 ++++-- src/transport/test_transport_api_reliability.c | 11 +++++++++++ 4 files changed, 38 insertions(+), 6 deletions(-) diff --git a/src/transport/Makefile.am b/src/transport/Makefile.am index 0eba52a6d..c3e722723 100644 --- a/src/transport/Makefile.am +++ b/src/transport/Makefile.am @@ -134,6 +134,8 @@ check_PROGRAMS = \ test_transport_api_udp_nat \ test_transport_api_reliability_tcp \ test_transport_api_reliability_tcp_nat \ + test_transport_api_reliability_http \ + test_transport_api_reliability_udp \ test_transport_api_http # TODO: add tests for nat, etc. @@ -172,6 +174,18 @@ test_transport_api_reliability_tcp_nat_LDADD = \ $(top_builddir)/src/transport/libgnunettransport.la \ $(top_builddir)/src/util/libgnunetutil.la +test_transport_api_reliability_udp_SOURCES = \ + test_transport_api_reliability.c +test_transport_api_reliability_udp_LDADD = \ + $(top_builddir)/src/transport/libgnunettransport.la \ + $(top_builddir)/src/util/libgnunetutil.la + +test_transport_api_reliability_http_SOURCES = \ + test_transport_api_reliability.c +test_transport_api_reliability_http_LDADD = \ + $(top_builddir)/src/transport/libgnunettransport.la \ + $(top_builddir)/src/util/libgnunetutil.la + test_transport_api_udp_SOURCES = \ test_transport_api.c test_transport_api_udp_LDADD = \ diff --git a/src/transport/plugin_transport_http.c b/src/transport/plugin_transport_http.c index 418402aa1..d654a0c82 100644 --- a/src/transport/plugin_transport_http.c +++ b/src/transport/plugin_transport_http.c @@ -39,7 +39,6 @@ #include "microhttpd.h" #include - #define DEBUG_CURL GNUNET_NO #define DEBUG_HTTP GNUNET_NO #define DEBUG_CONNECTIONS GNUNET_NO @@ -1891,10 +1890,11 @@ http_plugin_address_suggested (void *cls, if (addrlen == sizeof (struct IPv4HttpAddress)) { v4 = (struct IPv4HttpAddress *) addr; + /* Not skipping loopback if (INADDR_LOOPBACK == ntohl(v4->ipv4_addr)) { return GNUNET_SYSERR; - } + } */ port = ntohs (v4->u_port); if (port != plugin->port_inbound) { @@ -1998,11 +1998,13 @@ process_interfaces (void *cls, if (af == AF_INET) { t4 = GNUNET_malloc(sizeof(struct IPv4HttpAddress)); + /* Not skipping loopback addresses if (INADDR_LOOPBACK == ntohl(((struct sockaddr_in *) addr)->sin_addr.s_addr)) { - /* skip loopback addresses */ + return GNUNET_OK; } + */ t4->ipv4_addr = ((struct sockaddr_in *) addr)->sin_addr.s_addr; t4->u_port = htons (plugin->port_inbound); plugin->env->notify_address(plugin->env->cls,"http",t4, sizeof (struct IPv4HttpAddress), GNUNET_TIME_UNIT_FOREVER_REL); @@ -2016,17 +2018,20 @@ process_interfaces (void *cls, /* skip link local addresses */ return GNUNET_OK; } + /* Not skipping loopback addresses if (IN6_IS_ADDR_LOOPBACK (&((struct sockaddr_in6 *) addr)->sin6_addr)) { - /* skip loopback addresses */ + return GNUNET_OK; } + */ memcpy (&t6->ipv6_addr, &((struct sockaddr_in6 *) addr)->sin6_addr, sizeof (struct in6_addr)); t6->u6_port = htons (plugin->port_inbound); plugin->env->notify_address(plugin->env->cls,"http",t6,sizeof (struct IPv6HttpAddress) , GNUNET_TIME_UNIT_FOREVER_REL); } + return GNUNET_NO; return GNUNET_OK; } diff --git a/src/transport/test_plugin_transport_http.c b/src/transport/test_plugin_transport_http.c index 97817229a..db24628f6 100644 --- a/src/transport/test_plugin_transport_http.c +++ b/src/transport/test_plugin_transport_http.c @@ -41,6 +41,8 @@ #include "gnunet_statistics_service.h" #include "transport.h" #include +#include +#include #define VERBOSE GNUNET_YES #define DEBUG GNUNET_NO @@ -1252,9 +1254,9 @@ run (void *cls, GNUNET_assert (GNUNET_SYSERR == suggest_res); /* Suggesting addresses with wrong address*/ - failing_addr.ipv4_addr = htonl(INADDR_LOOPBACK); + failing_addr.ipv4_addr = htonl(0xffc00000); failing_addr.u_port = htons(12389); - suggest_res = api->check_address (api->cls,&failing_addr,sizeof (struct IPv4HttpAddress)); + suggest_res = api->check_address (api->cls,&failing_addr,100); GNUNET_assert (GNUNET_SYSERR == suggest_res); /* test sending to client */ diff --git a/src/transport/test_transport_api_reliability.c b/src/transport/test_transport_api_reliability.c index c80a1e328..a7ab6407d 100644 --- a/src/transport/test_transport_api_reliability.c +++ b/src/transport/test_transport_api_reliability.c @@ -80,6 +80,8 @@ static int is_tcp_nat; static int is_http; +static int is_udp; + static int connected; static unsigned long long total_bytes; @@ -447,6 +449,11 @@ run (void *cls, setup_peer (&p1, "test_transport_api_http_peer1.conf"); setup_peer (&p2, "test_transport_api_http_peer2.conf"); } + else if (is_udp) + { + setup_peer (&p1, "test_transport_api_udp_peer1.conf"); + setup_peer (&p2, "test_transport_api_udp_peer2.conf"); + } else if (is_tcp_nat) { setup_peer (&p1, "test_transport_api_tcp_nat_peer1.conf"); @@ -507,6 +514,10 @@ main (int argc, char *argv[]) { is_http = GNUNET_YES; } + else if (strstr(argv[0], "udp") != NULL) + { + is_udp = GNUNET_YES; + } GNUNET_log_setup ("test-transport-api-reliability", #if VERBOSE "DEBUG", -- cgit v1.2.3