summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2010-07-16 10:40:31 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2010-07-16 10:40:31 +0000
commitc627f052adb2151d4ec4b5dbefb8c9f1849598a7 (patch)
treef759841842dfc5d3d20180fa95bc36a8f9b7549c /src
parentf301aa4fd5c7ec64889dcd4a5b6c3621a1895853 (diff)
added configuration value to en-/disable ipv6 usage
Diffstat (limited to 'src')
-rw-r--r--src/transport/plugin_transport_http.c52
-rw-r--r--src/transport/test_plugin_transport_data_http.conf5
-rw-r--r--src/transport/test_plugin_transport_http.c1
-rw-r--r--src/transport/test_transport_api_http_peer1.conf12
-rw-r--r--src/transport/test_transport_api_http_peer2.conf8
5 files changed, 57 insertions, 21 deletions
diff --git a/src/transport/plugin_transport_http.c b/src/transport/plugin_transport_http.c
index d754c7e67..3faa55627 100644
--- a/src/transport/plugin_transport_http.c
+++ b/src/transport/plugin_transport_http.c
@@ -357,6 +357,7 @@ struct Plugin
struct GNUNET_CRYPTO_HashAsciiEncoded my_ascii_hash_ident;
struct in_addr * bind_address;
+ int use_ipv6;
};
@@ -557,15 +558,17 @@ process_interfaces (void *cls,
if (plugin->bind_address != NULL)
{
if (0 == memcmp(plugin->bind_address, &bnd_cmp, sizeof (struct in_addr)))
+ {
plugin->env->notify_address(plugin->env->cls,"http",t4, sizeof (struct IPv4HttpAddress), GNUNET_TIME_UNIT_FOREVER_REL);
+ }
}
else
{
plugin->env->notify_address(plugin->env->cls,"http",t4, sizeof (struct IPv4HttpAddress), GNUNET_TIME_UNIT_FOREVER_REL);
}
-
+ GNUNET_free (t4);
}
- else if ((af == AF_INET6) && (plugin->bind_address == NULL))
+ else if ((af == AF_INET6) && (plugin->use_ipv6==GNUNET_YES) && (plugin->bind_address == NULL))
{
t6 = GNUNET_malloc(sizeof(struct IPv6HttpAddress));
if (IN6_IS_ADDR_LINKLOCAL (&((struct sockaddr_in6 *) addr)->sin6_addr))
@@ -585,6 +588,7 @@ process_interfaces (void *cls,
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);
+ GNUNET_free (t6);
}
//return GNUNET_NO;
return GNUNET_OK;
@@ -1795,10 +1799,8 @@ http_plugin_send (void *cls,
{
struct Plugin *plugin = cls;
struct HTTP_Message *msg;
-
struct HTTP_PeerContext * pc;
struct Session * ps = NULL;
- //struct Session * ps_tmp = NULL;
GNUNET_assert(cls !=NULL);
@@ -2031,8 +2033,8 @@ http_plugin_address_pretty_printer (void *cls,
res = GNUNET_asprintf(&ret,"http://%s:%u/",address,port);
GNUNET_free (address);
GNUNET_assert(res != 0);
-
asc (asc_cls, ret);
+ GNUNET_free_non_null (ret);
}
@@ -2230,7 +2232,11 @@ libgnunet_plugin_transport_http_init (void *cls)
struct GNUNET_TRANSPORT_PluginFunctions *api;
struct GNUNET_TIME_Relative gn_timeout;
long long unsigned int port;
- char * hostname;
+
+ char * hostname = NULL;
+ //struct sockaddr_in b4_addr;
+ //struct sockaddr_in6 b6_addr;
+
GNUNET_assert(cls !=NULL);
#if DEBUG_HTTP
@@ -2241,7 +2247,8 @@ libgnunet_plugin_transport_http_init (void *cls)
plugin->stats = env->stats;
plugin->env = env;
plugin->peers = NULL;
- plugin->bind_address = GNUNET_malloc(sizeof(struct in_addr*));
+ plugin->bind_address = NULL;
+ plugin->use_ipv6 = GNUNET_YES;
api = GNUNET_malloc (sizeof (struct GNUNET_TRANSPORT_PluginFunctions));
api->cls = plugin;
@@ -2255,6 +2262,19 @@ libgnunet_plugin_transport_http_init (void *cls)
GNUNET_CRYPTO_hash_to_enc ( &(plugin->env->my_identity->hashPubKey), &plugin->my_ascii_hash_ident);
/* Reading port number from config file */
+ if (GNUNET_CONFIGURATION_have_value (env->cfg,
+ "transport-http", "USE_IPv6"))
+ {
+ plugin->use_ipv6 = GNUNET_CONFIGURATION_get_value_yesno (env->cfg,
+ "transport-http",
+ "USE_IPv6");
+
+
+
+ }
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "IPV6 is %u\n",plugin->use_ipv6 );
+ /* Reading port number from config file */
if ((GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_number (env->cfg,
"transport-http",
@@ -2279,6 +2299,7 @@ libgnunet_plugin_transport_http_init (void *cls)
"transport-http",
"BINDTO",
&hostname));
+ plugin->bind_address = GNUNET_malloc(sizeof(struct in_addr*));
if (inet_aton(hostname, plugin->bind_address)==0)
{
GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR,
@@ -2288,13 +2309,15 @@ libgnunet_plugin_transport_http_init (void *cls)
GNUNET_free(plugin->bind_address);
plugin->bind_address = NULL;
}
+ GNUNET_free_non_null (hostname);
}
GNUNET_assert ((port > 0) && (port <= 65535));
plugin->port_inbound = port;
gn_timeout = GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT;
unsigned int timeout = (gn_timeout.value) / 1000;
- if ((plugin->http_server_daemon_v4 == NULL) && (plugin->http_server_daemon_v6 == NULL) && (port != 0))
- {
+ if ((plugin->http_server_daemon_v6 == NULL) && (plugin->use_ipv6 == GNUNET_YES) && (port != 0))
+ {
+
plugin->http_server_daemon_v6 = MHD_start_daemon (
#if DEBUG_CONNECTIONS
MHD_USE_DEBUG |
@@ -2303,14 +2326,17 @@ libgnunet_plugin_transport_http_init (void *cls)
port,
&mhd_accept_cb,
plugin , &mdh_access_cb, plugin,
+ //MHD_OPTION_SOCK_ADDR, (struct sockaddr *) &b6_addr,
MHD_OPTION_CONNECTION_LIMIT, (unsigned int) 32,
MHD_OPTION_PER_IP_CONNECTION_LIMIT, (unsigned int) 6,
MHD_OPTION_CONNECTION_TIMEOUT, (unsigned int) timeout,
MHD_OPTION_CONNECTION_MEMORY_LIMIT, (size_t) (16 * 1024),
MHD_OPTION_NOTIFY_COMPLETED, &mhd_termination_cb, NULL,
MHD_OPTION_END);
-
- plugin->http_server_daemon_v4 = MHD_start_daemon (
+ }
+ if ((plugin->http_server_daemon_v4 == NULL) && (plugin->http_server_daemon_v6 == NULL) && (port != 0))
+ {
+ plugin->http_server_daemon_v4 = MHD_start_daemon (
#if DEBUG_CONNECTIONS
MHD_USE_DEBUG |
#endif
@@ -2318,14 +2344,14 @@ libgnunet_plugin_transport_http_init (void *cls)
port,
&mhd_accept_cb,
plugin , &mdh_access_cb, plugin,
- //MHD_OPTION_SOCK_ADDR, (struct sockaddr *) &in4,
+ //MHD_OPTION_SOCK_ADDR, (struct sockaddr *) &b4_addr,
MHD_OPTION_CONNECTION_LIMIT, (unsigned int) 32,
MHD_OPTION_PER_IP_CONNECTION_LIMIT, (unsigned int) 6,
MHD_OPTION_CONNECTION_TIMEOUT, (unsigned int) timeout,
MHD_OPTION_CONNECTION_MEMORY_LIMIT, (size_t) (16 * 1024),
MHD_OPTION_NOTIFY_COMPLETED, &mhd_termination_cb, NULL,
MHD_OPTION_END);
- }
+ }
if (plugin->http_server_daemon_v4 != NULL)
plugin->http_server_task_v4 = http_server_daemon_prepare (plugin, plugin->http_server_daemon_v4);
if (plugin->http_server_daemon_v6 != NULL)
diff --git a/src/transport/test_plugin_transport_data_http.conf b/src/transport/test_plugin_transport_data_http.conf
index 7a14f793a..f17627776 100644
--- a/src/transport/test_plugin_transport_data_http.conf
+++ b/src/transport/test_plugin_transport_data_http.conf
@@ -8,7 +8,10 @@ WEAKRANDOM = YES
[transport-http]
PORT = 12389
DEBUG = NO
-BINDTO = 127.0.0.1
+USE_IPv6 = YES
+#BINDTO4 = 127.0.0.1
+#BINDTO6 = ::1
+
[transport]
PREFIX = valgrind --leak-check=full
diff --git a/src/transport/test_plugin_transport_http.c b/src/transport/test_plugin_transport_http.c
index 24689f81a..fbb758f7e 100644
--- a/src/transport/test_plugin_transport_http.c
+++ b/src/transport/test_plugin_transport_http.c
@@ -1043,6 +1043,7 @@ static void run_connection_tests( int phase , void * cls)
count ++;
type ++;
}
+ GNUNET_free(tmp);
return;
}
diff --git a/src/transport/test_transport_api_http_peer1.conf b/src/transport/test_transport_api_http_peer1.conf
index 2cbf82e5e..9521999ee 100644
--- a/src/transport/test_transport_api_http_peer1.conf
+++ b/src/transport/test_transport_api_http_peer1.conf
@@ -1,7 +1,10 @@
[transport-http]
PORT = 12389
-DEBUG = YES
-BINDTO = 127.0.0.1
+DEBUG = NO
+USE_IPv6 = YES
+#BINDTO4 = 127.0.0.1
+#BINDTO6 = ::1
+
[fs]
AUTOSTART = NO
@@ -35,8 +38,6 @@ MINIMUM-FRIENDS = 0
PLUGINS = http
#PLUGINS = tcp http
DEBUG = NO
-#PREFIX = xterm -T transport2 -e gdb --command=cmd --args
-#PREFIX = valgrind --leak-check=full
ACCEPT_FROM6 = ::1;
ACCEPT_FROM = 127.0.0.1;
NEIGHBOUR_LIMIT = 50
@@ -46,6 +47,9 @@ HOME = $SERVICEHOME
HOSTNAME = localhost
PORT = 12365
UNIXPATH = /tmp/gnunet-p1-service-transport.sock
+#PREFIX = xterm -T transport2 -e gdb --command=cmd --args
+#PREFIX = valgrind --leak-check=full
+#PREFIX = valgrind --tool=massif
[peerinfo]
TRUST = $SERVICEHOME/data/credit/
diff --git a/src/transport/test_transport_api_http_peer2.conf b/src/transport/test_transport_api_http_peer2.conf
index 15a562b6e..ad8e2fb90 100644
--- a/src/transport/test_transport_api_http_peer2.conf
+++ b/src/transport/test_transport_api_http_peer2.conf
@@ -1,7 +1,9 @@
[transport-http]
PORT = 22368
-DEBUG = YES
-BINDTO = 127.0.0.1
+DEBUG = NO
+USE_IPv6 = YES
+#BINDTO4 = 127.0.0.1
+#BINDTO6 = ::1
[fs]
AUTOSTART = NO
@@ -35,7 +37,6 @@ MINIMUM-FRIENDS = 0
PLUGINS = http
#PLUGINS = tcp http
DEBUG = NO
-# PREFIX =
ACCEPT_FROM6 = ::1;
ACCEPT_FROM = 127.0.0.1;
NEIGHBOUR_LIMIT = 50
@@ -47,6 +48,7 @@ PORT = 22365
UNIXPATH = /tmp/gnunet-p2-service-transport.sock
#PREFIX = xterm -T transport1 -e gdb --command=cmd --args
#PREFIX = valgrind --leak-check=full
+#PREFIX = valgrind --tool=massif
[peerinfo]
TRUST = $SERVICEHOME/data/credit/