aboutsummaryrefslogtreecommitdiff
path: root/src/nat
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2012-05-06 01:12:57 +0000
committerChristian Grothoff <christian@grothoff.org>2012-05-06 01:12:57 +0000
commit9fac6b6eefdc9144053f736fd388cb2199a97046 (patch)
tree82740a981b7f6ae973d915aa77797acd9db668b2 /src/nat
parent23d8d343d5c70481ecf78ec4fafc698907f3e8a9 (diff)
-removing legacy ifdefs, fixing log statements
Diffstat (limited to 'src/nat')
-rw-r--r--src/nat/gnunet-nat-server.c10
-rw-r--r--src/nat/nat.c12
-rw-r--r--src/nat/nat.h1
-rw-r--r--src/nat/nat_mini.c4
-rw-r--r--src/nat/nat_test.c14
5 files changed, 0 insertions, 41 deletions
diff --git a/src/nat/gnunet-nat-server.c b/src/nat/gnunet-nat-server.c
index 0336ecc9d8..9b6846cf0e 100644
--- a/src/nat/gnunet-nat-server.c
+++ b/src/nat/gnunet-nat-server.c
@@ -55,11 +55,9 @@ try_anat (uint32_t dst_ipv4, uint16_t dport, int is_tcp)
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, 0, NULL, NULL, NULL, NULL, NULL);
memset (&sa, 0, sizeof (sa));
sa.sin_family = AF_INET;
@@ -107,9 +105,7 @@ tcp_send (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
if (-1 ==
GNUNET_NETWORK_socket_send (ctx->s, &ctx->data, sizeof (ctx->data)))
{
-#if DEBUG_NAT
GNUNET_log_strerror (GNUNET_ERROR_TYPE_DEBUG, "send");
-#endif
}
GNUNET_NETWORK_socket_shutdown (ctx->s, SHUT_RDWR);
}
@@ -146,10 +142,8 @@ try_send_tcp (uint32_t dst_ipv4, uint16_t dport, uint16_t data)
#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))) && (errno != EINPROGRESS))
@@ -192,10 +186,8 @@ try_send_udp (uint32_t dst_ipv4, uint16_t dport, uint16_t data)
#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)))
@@ -219,9 +211,7 @@ test (void *cls, struct GNUNET_SERVER_Client *client,
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 53301ebb12..1b6556cbf7 100644
--- a/src/nat/nat.c
+++ b/src/nat/nat.c
@@ -422,10 +422,8 @@ add_to_address_list_as_is (struct GNUNET_NAT_Handle *h,
lal->addrlen = arg_size;
lal->source = src;
GNUNET_CONTAINER_DLL_insert (h->lal_head, h->lal_tail, lal);
-#if DEBUG_NAT
LOG (GNUNET_ERROR_TYPE_DEBUG, "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, arg, arg_size);
}
@@ -750,10 +748,8 @@ nat_server_read (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
GNUNET_DISK_file_read (h->server_stdout_handle, mybuf, sizeof (mybuf));
if (bytes < 1)
{
-#if DEBUG_NAT
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Finished reading from server stdout with code: %d\n", bytes);
-#endif
if (0 != GNUNET_OS_process_kill (h->server_proc, SIGTERM))
GNUNET_log_from_strerror (GNUNET_ERROR_TYPE_WARNING, "nat", "kill");
GNUNET_OS_process_wait (h->server_proc);
@@ -809,10 +805,8 @@ nat_server_read (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
return;
}
sin_addr.sin_port = htons ((uint16_t) port);
-#if DEBUG_NAT
LOG (GNUNET_ERROR_TYPE_DEBUG, "gnunet-helper-nat-server read: %s:%d\n", mybuf,
port);
-#endif
h->reversal_callback (h->callback_cls, (const struct sockaddr *) &sin_addr,
sizeof (sin_addr));
h->server_read_task =
@@ -837,10 +831,8 @@ start_gnunet_nat_server (struct GNUNET_NAT_Handle *h)
(h->server_stdout =
GNUNET_DISK_pipe (GNUNET_YES, GNUNET_YES, GNUNET_NO, GNUNET_YES))))
{
-#if DEBUG_NAT
LOG (GNUNET_ERROR_TYPE_DEBUG, "Starting `%s' at `%s'\n",
"gnunet-helper-nat-server", h->internal_address);
-#endif
/* Start the server process */
h->server_proc =
GNUNET_OS_start_process (GNUNET_NO, NULL, h->server_stdout,
@@ -1079,11 +1071,9 @@ GNUNET_NAT_register (const struct GNUNET_CONFIGURATION_Handle *cfg, int is_tcp,
struct in_addr in_addr;
unsigned int i;
-#if DEBUG_NAT
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Registered with NAT service at port %u with %u IP bound local addresses\n",
(unsigned int) adv_port, num_addrs);
-#endif
h = GNUNET_malloc (sizeof (struct GNUNET_NAT_Handle));
h->server_retry_delay = GNUNET_TIME_UNIT_SECONDS;
h->cfg = cfg;
@@ -1338,11 +1328,9 @@ GNUNET_NAT_run_client (struct GNUNET_NAT_Handle *h,
return GNUNET_SYSERR;
}
GNUNET_snprintf (port_as_string, sizeof (port_as_string), "%d", h->adv_port);
-#if DEBUG_NAT
LOG (GNUNET_ERROR_TYPE_DEBUG,
_("Running gnunet-helper-nat-client %s %s %u\n"), h->internal_address,
inet4, (unsigned int) h->adv_port);
-#endif
proc =
GNUNET_OS_start_process (GNUNET_NO,
NULL, NULL, "gnunet-helper-nat-client",
diff --git a/src/nat/nat.h b/src/nat/nat.h
index efab3a7a77..a0ef465933 100644
--- a/src/nat/nat.h
+++ b/src/nat/nat.h
@@ -28,7 +28,6 @@
#define NAT_H
#include "gnunet_util_lib.h"
-#define DEBUG_NAT GNUNET_EXTRA_LOGGING
GNUNET_NETWORK_STRUCT_BEGIN
diff --git a/src/nat/nat_mini.c b/src/nat/nat_mini.c
index 84cc841867..864a7f04e6 100644
--- a/src/nat/nat_mini.c
+++ b/src/nat/nat_mini.c
@@ -524,9 +524,7 @@ process_unmap_output (void *cls, const char *line)
if (NULL == line)
{
-#if DEBUG_NAT
LOG (GNUNET_ERROR_TYPE_DEBUG, "UPnP unmap done\n");
-#endif
GNUNET_OS_command_stop (mini->unmap_cmd);
mini->unmap_cmd = NULL;
GNUNET_free (mini);
@@ -577,10 +575,8 @@ GNUNET_NAT_mini_map_stop (struct GNUNET_NAT_MiniHandle *mini)
* often are the same, but it might... */
GNUNET_snprintf (pstr, sizeof (pstr), "%u",
(unsigned int) ntohs (mini->current_addr.sin_port));
-#if DEBUG_NAT
LOG (GNUNET_ERROR_TYPE_DEBUG, "Unmapping port %u with UPnP\n",
ntohs (mini->current_addr.sin_port));
-#endif
mini->unmap_cmd =
GNUNET_OS_command_run (&process_unmap_output, mini, UNMAP_TIMEOUT,
"upnpc", "upnpc", "-d", pstr,
diff --git a/src/nat/nat_test.c b/src/nat/nat_test.c
index 98ce82e732..5704d34846 100644
--- a/src/nat/nat_test.c
+++ b/src/nat/nat_test.c
@@ -180,10 +180,8 @@ reversal_cb (void *cls, const struct sockaddr *addr, socklen_t addrlen)
sa = (const struct sockaddr_in *) addr;
if (h->data != sa->sin_port)
{
-#if DEBUG_NAT
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Received connection reversal request for wrong port\n");
-#endif
return; /* wrong port */
}
/* report success */
@@ -214,17 +212,13 @@ do_udp_read (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
if (data == tst->data)
tst->report (tst->report_cls, GNUNET_OK);
-#if DEBUG_NAT
else
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Received data mismatches expected value\n");
-#endif
}
-#if DEBUG_NAT
else
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Failed to receive data from inbound connection\n");
-#endif
}
@@ -252,17 +246,13 @@ do_read (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
if (data == tst->data)
tst->report (tst->report_cls, GNUNET_OK);
-#if DEBUG_NAT
else
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Received data mismatches expected value\n");
-#endif
}
-#if DEBUG_NAT
else
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Failed to receive data from inbound connection\n");
-#endif
GNUNET_NETWORK_socket_close (na->sock);
GNUNET_free (na);
}
@@ -294,10 +284,8 @@ do_accept (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
GNUNET_log_strerror (GNUNET_ERROR_TYPE_INFO, "accept");
return; /* odd error */
}
-#if DEBUG_NAT
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Got an inbound connection, waiting for data\n");
-#endif
wl = GNUNET_malloc (sizeof (struct NatActivity));
wl->sock = s;
wl->h = tst;
@@ -331,10 +319,8 @@ addr_cb (void *cls, int add_remove, const struct sockaddr *addr,
return;
if (addrlen != sizeof (struct sockaddr_in))
return; /* ignore IPv6 here */
-#if DEBUG_NAT
LOG (GNUNET_ERROR_TYPE_DEBUG, "Asking gnunet-nat-server to connect to `%s'\n",
GNUNET_a2s (addr, addrlen));
-#endif
sa = (const struct sockaddr_in *) addr;
msg.header.size = htons (sizeof (struct GNUNET_NAT_TestMessage));
msg.header.type = htons (GNUNET_MESSAGE_TYPE_NAT_TEST);