From ec346597fba6b7fdec3939de40b3b7aba322049d Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Mon, 11 Jul 2011 14:54:27 +0000 Subject: [PATCH] fixes --- src/nat/gnunet-nat-server.c | 16 +++++++++++++++- src/nat/nat.c | 4 ++-- src/nat/test_nat.c | 1 - src/nat/test_nat_mini.c | 1 - src/nat/test_nat_test_data.conf | 2 +- 5 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/nat/gnunet-nat-server.c b/src/nat/gnunet-nat-server.c index 1c639596f..bf4318a91 100644 --- a/src/nat/gnunet-nat-server.c +++ b/src/nat/gnunet-nat-server.c @@ -29,6 +29,8 @@ #include "gnunet_protocols.h" #include "nat.h" +#define DEBUG_NAT GNUNET_NO + /** * Our server. */ @@ -56,10 +58,12 @@ try_anat (uint32_t dst_ipv4, struct GNUNET_NAT_Handle *h; struct sockaddr_in sa; +#if DEBUG_NAT GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Asking for connection reversal with %x and code %u\n", (unsigned int) dst_ipv4, (unsigned int) dport); +#endif h = GNUNET_NAT_register (cfg, is_tcp, dport, @@ -111,7 +115,11 @@ tcp_send (void *cls, ctx->s)) ) { if (-1 == GNUNET_NETWORK_socket_send (ctx->s, &ctx->data, sizeof (ctx->data))) - GNUNET_log_strerror (GNUNET_ERROR_TYPE_DEBUG, "send"); + { +#if DEBUG_NAT + GNUNET_log_strerror (GNUNET_ERROR_TYPE_DEBUG, "send"); +#endif + } GNUNET_NETWORK_socket_shutdown (ctx->s, SHUT_RDWR); } GNUNET_NETWORK_socket_close (ctx->s); @@ -149,9 +157,11 @@ try_send_tcp (uint32_t dst_ipv4, #endif sa.sin_addr.s_addr = dst_ipv4; sa.sin_port = htons (dport); +#if DEBUG_NAT GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending TCP message to `%s'\n", GNUNET_a2s ((struct sockaddr*) &sa, sizeof (sa))); +#endif if ( (GNUNET_OK != GNUNET_NETWORK_socket_connect (s, (const struct sockaddr*) &sa, sizeof (sa))) && @@ -199,9 +209,11 @@ try_send_udp (uint32_t dst_ipv4, #endif sa.sin_addr.s_addr = dst_ipv4; sa.sin_port = htons (dport); +#if DEBUG_NAT GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending UDP packet to `%s'\n", GNUNET_a2s ((struct sockaddr*) &sa, sizeof (sa))); +#endif if (-1 == GNUNET_NETWORK_socket_sendto (s, &data, sizeof(data), (const struct sockaddr*) &sa, sizeof (sa))) @@ -226,8 +238,10 @@ test (void *cls, const struct GNUNET_NAT_TestMessage *tm; uint16_t dport; +#if DEBUG_NAT GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received test request\n"); +#endif tm = (const struct GNUNET_NAT_TestMessage*) msg; dport = ntohs (tm->dport); if (0 == dport) diff --git a/src/nat/nat.c b/src/nat/nat.c index d09fd79fc..5bcf970c1 100644 --- a/src/nat/nat.c +++ b/src/nat/nat.c @@ -423,11 +423,13 @@ add_to_address_list_as_is (struct GNUNET_NAT_Handle *h, GNUNET_CONTAINER_DLL_insert (h->lal_head, h->lal_tail, lal); +#if DEBUG_NAT GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "nat", "Adding address `%s' from source %d\n", GNUNET_a2s (arg, arg_size), src); +#endif if (NULL != h->address_callback) h->address_callback (h->callback_cls, GNUNET_YES, @@ -1229,8 +1231,6 @@ GNUNET_NAT_register (const struct GNUNET_CONFIGURATION_Handle *cfg, h->use_hostname = GNUNET_CONFIGURATION_get_value_yesno (cfg, "nat", "USE_HOSTNAME"); - if (h->use_localaddresses) - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "USE LOCALADDR enabled!\n"); h->disable_ipv6 = GNUNET_CONFIGURATION_get_value_yesno(cfg, "nat", "DISABLEV6"); diff --git a/src/nat/test_nat.c b/src/nat/test_nat.c index cb011c7af..c58d83224 100644 --- a/src/nat/test_nat.c +++ b/src/nat/test_nat.c @@ -129,7 +129,6 @@ run (void *cls, struct addr_cls data; struct sockaddr *addr; - GNUNET_log_setup ("test-nat", "DEBUG", NULL); data.addr = NULL; GNUNET_OS_network_interfaces_list (process_if, &data); if (NULL == data.addr) diff --git a/src/nat/test_nat_mini.c b/src/nat/test_nat_mini.c index e7b8294c8..ee0115cb1 100644 --- a/src/nat/test_nat_mini.c +++ b/src/nat/test_nat_mini.c @@ -82,7 +82,6 @@ run (void *cls, { struct GNUNET_NAT_MiniHandle *mini; - GNUNET_log_setup ("test-nat-mini", "DEBUG", NULL); GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Requesting NAT redirection for port %u...\n", PORT); diff --git a/src/nat/test_nat_test_data.conf b/src/nat/test_nat_test_data.conf index 41324bb0a..c5d9f161e 100644 --- a/src/nat/test_nat_test_data.conf +++ b/src/nat/test_nat_test_data.conf @@ -40,4 +40,4 @@ INTERNAL_ADDRESS = 127.0.0.1 # Disable IPv6 support DISABLEV6 = YES -x + -- 2.25.1