diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2010-07-15 09:31:18 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2010-07-15 09:31:18 +0000 |
commit | 27294d85406ed2c51b53112b42915141f866ff1e (patch) | |
tree | 6d0587bc8befdf4f21925fa7f261a86b875354fc | |
parent | 763874144cd579ce60a6a749e3a11b202d38f853 (diff) | |
download | gnunet-27294d85406ed2c51b53112b42915141f866ff1e.tar.gz gnunet-27294d85406ed2c51b53112b42915141f866ff1e.zip |
not skipping loopback devices
-rw-r--r-- | src/transport/Makefile.am | 14 | ||||
-rw-r--r-- | src/transport/plugin_transport_http.c | 13 | ||||
-rw-r--r-- | src/transport/test_plugin_transport_http.c | 6 | ||||
-rw-r--r-- | 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 = \ | |||
134 | test_transport_api_udp_nat \ | 134 | test_transport_api_udp_nat \ |
135 | test_transport_api_reliability_tcp \ | 135 | test_transport_api_reliability_tcp \ |
136 | test_transport_api_reliability_tcp_nat \ | 136 | test_transport_api_reliability_tcp_nat \ |
137 | test_transport_api_reliability_http \ | ||
138 | test_transport_api_reliability_udp \ | ||
137 | test_transport_api_http | 139 | test_transport_api_http |
138 | # TODO: add tests for nat, etc. | 140 | # TODO: add tests for nat, etc. |
139 | 141 | ||
@@ -172,6 +174,18 @@ test_transport_api_reliability_tcp_nat_LDADD = \ | |||
172 | $(top_builddir)/src/transport/libgnunettransport.la \ | 174 | $(top_builddir)/src/transport/libgnunettransport.la \ |
173 | $(top_builddir)/src/util/libgnunetutil.la | 175 | $(top_builddir)/src/util/libgnunetutil.la |
174 | 176 | ||
177 | test_transport_api_reliability_udp_SOURCES = \ | ||
178 | test_transport_api_reliability.c | ||
179 | test_transport_api_reliability_udp_LDADD = \ | ||
180 | $(top_builddir)/src/transport/libgnunettransport.la \ | ||
181 | $(top_builddir)/src/util/libgnunetutil.la | ||
182 | |||
183 | test_transport_api_reliability_http_SOURCES = \ | ||
184 | test_transport_api_reliability.c | ||
185 | test_transport_api_reliability_http_LDADD = \ | ||
186 | $(top_builddir)/src/transport/libgnunettransport.la \ | ||
187 | $(top_builddir)/src/util/libgnunetutil.la | ||
188 | |||
175 | test_transport_api_udp_SOURCES = \ | 189 | test_transport_api_udp_SOURCES = \ |
176 | test_transport_api.c | 190 | test_transport_api.c |
177 | test_transport_api_udp_LDADD = \ | 191 | 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 @@ | |||
39 | #include "microhttpd.h" | 39 | #include "microhttpd.h" |
40 | #include <curl/curl.h> | 40 | #include <curl/curl.h> |
41 | 41 | ||
42 | |||
43 | #define DEBUG_CURL GNUNET_NO | 42 | #define DEBUG_CURL GNUNET_NO |
44 | #define DEBUG_HTTP GNUNET_NO | 43 | #define DEBUG_HTTP GNUNET_NO |
45 | #define DEBUG_CONNECTIONS GNUNET_NO | 44 | #define DEBUG_CONNECTIONS GNUNET_NO |
@@ -1891,10 +1890,11 @@ http_plugin_address_suggested (void *cls, | |||
1891 | if (addrlen == sizeof (struct IPv4HttpAddress)) | 1890 | if (addrlen == sizeof (struct IPv4HttpAddress)) |
1892 | { | 1891 | { |
1893 | v4 = (struct IPv4HttpAddress *) addr; | 1892 | v4 = (struct IPv4HttpAddress *) addr; |
1893 | /* Not skipping loopback | ||
1894 | if (INADDR_LOOPBACK == ntohl(v4->ipv4_addr)) | 1894 | if (INADDR_LOOPBACK == ntohl(v4->ipv4_addr)) |
1895 | { | 1895 | { |
1896 | return GNUNET_SYSERR; | 1896 | return GNUNET_SYSERR; |
1897 | } | 1897 | } */ |
1898 | port = ntohs (v4->u_port); | 1898 | port = ntohs (v4->u_port); |
1899 | if (port != plugin->port_inbound) | 1899 | if (port != plugin->port_inbound) |
1900 | { | 1900 | { |
@@ -1998,11 +1998,13 @@ process_interfaces (void *cls, | |||
1998 | if (af == AF_INET) | 1998 | if (af == AF_INET) |
1999 | { | 1999 | { |
2000 | t4 = GNUNET_malloc(sizeof(struct IPv4HttpAddress)); | 2000 | t4 = GNUNET_malloc(sizeof(struct IPv4HttpAddress)); |
2001 | /* Not skipping loopback addresses | ||
2001 | if (INADDR_LOOPBACK == ntohl(((struct sockaddr_in *) addr)->sin_addr.s_addr)) | 2002 | if (INADDR_LOOPBACK == ntohl(((struct sockaddr_in *) addr)->sin_addr.s_addr)) |
2002 | { | 2003 | { |
2003 | /* skip loopback addresses */ | 2004 | |
2004 | return GNUNET_OK; | 2005 | return GNUNET_OK; |
2005 | } | 2006 | } |
2007 | */ | ||
2006 | t4->ipv4_addr = ((struct sockaddr_in *) addr)->sin_addr.s_addr; | 2008 | t4->ipv4_addr = ((struct sockaddr_in *) addr)->sin_addr.s_addr; |
2007 | t4->u_port = htons (plugin->port_inbound); | 2009 | t4->u_port = htons (plugin->port_inbound); |
2008 | plugin->env->notify_address(plugin->env->cls,"http",t4, sizeof (struct IPv4HttpAddress), GNUNET_TIME_UNIT_FOREVER_REL); | 2010 | 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, | |||
2016 | /* skip link local addresses */ | 2018 | /* skip link local addresses */ |
2017 | return GNUNET_OK; | 2019 | return GNUNET_OK; |
2018 | } | 2020 | } |
2021 | /* Not skipping loopback addresses | ||
2019 | if (IN6_IS_ADDR_LOOPBACK (&((struct sockaddr_in6 *) addr)->sin6_addr)) | 2022 | if (IN6_IS_ADDR_LOOPBACK (&((struct sockaddr_in6 *) addr)->sin6_addr)) |
2020 | { | 2023 | { |
2021 | /* skip loopback addresses */ | 2024 | |
2022 | return GNUNET_OK; | 2025 | return GNUNET_OK; |
2023 | } | 2026 | } |
2027 | */ | ||
2024 | memcpy (&t6->ipv6_addr, | 2028 | memcpy (&t6->ipv6_addr, |
2025 | &((struct sockaddr_in6 *) addr)->sin6_addr, | 2029 | &((struct sockaddr_in6 *) addr)->sin6_addr, |
2026 | sizeof (struct in6_addr)); | 2030 | sizeof (struct in6_addr)); |
2027 | t6->u6_port = htons (plugin->port_inbound); | 2031 | t6->u6_port = htons (plugin->port_inbound); |
2028 | plugin->env->notify_address(plugin->env->cls,"http",t6,sizeof (struct IPv6HttpAddress) , GNUNET_TIME_UNIT_FOREVER_REL); | 2032 | plugin->env->notify_address(plugin->env->cls,"http",t6,sizeof (struct IPv6HttpAddress) , GNUNET_TIME_UNIT_FOREVER_REL); |
2029 | } | 2033 | } |
2034 | return GNUNET_NO; | ||
2030 | return GNUNET_OK; | 2035 | return GNUNET_OK; |
2031 | } | 2036 | } |
2032 | 2037 | ||
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 @@ | |||
41 | #include "gnunet_statistics_service.h" | 41 | #include "gnunet_statistics_service.h" |
42 | #include "transport.h" | 42 | #include "transport.h" |
43 | #include <curl/curl.h> | 43 | #include <curl/curl.h> |
44 | #include <netinet/in.h> | ||
45 | #include <arpa/inet.h> | ||
44 | 46 | ||
45 | #define VERBOSE GNUNET_YES | 47 | #define VERBOSE GNUNET_YES |
46 | #define DEBUG GNUNET_NO | 48 | #define DEBUG GNUNET_NO |
@@ -1252,9 +1254,9 @@ run (void *cls, | |||
1252 | GNUNET_assert (GNUNET_SYSERR == suggest_res); | 1254 | GNUNET_assert (GNUNET_SYSERR == suggest_res); |
1253 | 1255 | ||
1254 | /* Suggesting addresses with wrong address*/ | 1256 | /* Suggesting addresses with wrong address*/ |
1255 | failing_addr.ipv4_addr = htonl(INADDR_LOOPBACK); | 1257 | failing_addr.ipv4_addr = htonl(0xffc00000); |
1256 | failing_addr.u_port = htons(12389); | 1258 | failing_addr.u_port = htons(12389); |
1257 | suggest_res = api->check_address (api->cls,&failing_addr,sizeof (struct IPv4HttpAddress)); | 1259 | suggest_res = api->check_address (api->cls,&failing_addr,100); |
1258 | GNUNET_assert (GNUNET_SYSERR == suggest_res); | 1260 | GNUNET_assert (GNUNET_SYSERR == suggest_res); |
1259 | 1261 | ||
1260 | /* test sending to client */ | 1262 | /* 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; | |||
80 | 80 | ||
81 | static int is_http; | 81 | static int is_http; |
82 | 82 | ||
83 | static int is_udp; | ||
84 | |||
83 | static int connected; | 85 | static int connected; |
84 | 86 | ||
85 | static unsigned long long total_bytes; | 87 | static unsigned long long total_bytes; |
@@ -447,6 +449,11 @@ run (void *cls, | |||
447 | setup_peer (&p1, "test_transport_api_http_peer1.conf"); | 449 | setup_peer (&p1, "test_transport_api_http_peer1.conf"); |
448 | setup_peer (&p2, "test_transport_api_http_peer2.conf"); | 450 | setup_peer (&p2, "test_transport_api_http_peer2.conf"); |
449 | } | 451 | } |
452 | else if (is_udp) | ||
453 | { | ||
454 | setup_peer (&p1, "test_transport_api_udp_peer1.conf"); | ||
455 | setup_peer (&p2, "test_transport_api_udp_peer2.conf"); | ||
456 | } | ||
450 | else if (is_tcp_nat) | 457 | else if (is_tcp_nat) |
451 | { | 458 | { |
452 | setup_peer (&p1, "test_transport_api_tcp_nat_peer1.conf"); | 459 | setup_peer (&p1, "test_transport_api_tcp_nat_peer1.conf"); |
@@ -507,6 +514,10 @@ main (int argc, char *argv[]) | |||
507 | { | 514 | { |
508 | is_http = GNUNET_YES; | 515 | is_http = GNUNET_YES; |
509 | } | 516 | } |
517 | else if (strstr(argv[0], "udp") != NULL) | ||
518 | { | ||
519 | is_udp = GNUNET_YES; | ||
520 | } | ||
510 | GNUNET_log_setup ("test-transport-api-reliability", | 521 | GNUNET_log_setup ("test-transport-api-reliability", |
511 | #if VERBOSE | 522 | #if VERBOSE |
512 | "DEBUG", | 523 | "DEBUG", |