diff options
author | Christian Grothoff <christian@grothoff.org> | 2012-05-06 01:12:57 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2012-05-06 01:12:57 +0000 |
commit | 9fac6b6eefdc9144053f736fd388cb2199a97046 (patch) | |
tree | 82740a981b7f6ae973d915aa77797acd9db668b2 /src/nat | |
parent | 23d8d343d5c70481ecf78ec4fafc698907f3e8a9 (diff) | |
download | gnunet-9fac6b6eefdc9144053f736fd388cb2199a97046.tar.gz gnunet-9fac6b6eefdc9144053f736fd388cb2199a97046.zip |
-removing legacy ifdefs, fixing log statements
Diffstat (limited to 'src/nat')
-rw-r--r-- | src/nat/gnunet-nat-server.c | 10 | ||||
-rw-r--r-- | src/nat/nat.c | 12 | ||||
-rw-r--r-- | src/nat/nat.h | 1 | ||||
-rw-r--r-- | src/nat/nat_mini.c | 4 | ||||
-rw-r--r-- | src/nat/nat_test.c | 14 |
5 files changed, 0 insertions, 41 deletions
diff --git a/src/nat/gnunet-nat-server.c b/src/nat/gnunet-nat-server.c index 0336ecc9d..9b6846cf0 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) | |||
55 | struct GNUNET_NAT_Handle *h; | 55 | struct GNUNET_NAT_Handle *h; |
56 | struct sockaddr_in sa; | 56 | struct sockaddr_in sa; |
57 | 57 | ||
58 | #if DEBUG_NAT | ||
59 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 58 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
60 | "Asking for connection reversal with %x and code %u\n", | 59 | "Asking for connection reversal with %x and code %u\n", |
61 | (unsigned int) dst_ipv4, (unsigned int) dport); | 60 | (unsigned int) dst_ipv4, (unsigned int) dport); |
62 | #endif | ||
63 | h = GNUNET_NAT_register (cfg, is_tcp, dport, 0, NULL, NULL, NULL, NULL, NULL); | 61 | h = GNUNET_NAT_register (cfg, is_tcp, dport, 0, NULL, NULL, NULL, NULL, NULL); |
64 | memset (&sa, 0, sizeof (sa)); | 62 | memset (&sa, 0, sizeof (sa)); |
65 | sa.sin_family = AF_INET; | 63 | sa.sin_family = AF_INET; |
@@ -107,9 +105,7 @@ tcp_send (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
107 | if (-1 == | 105 | if (-1 == |
108 | GNUNET_NETWORK_socket_send (ctx->s, &ctx->data, sizeof (ctx->data))) | 106 | GNUNET_NETWORK_socket_send (ctx->s, &ctx->data, sizeof (ctx->data))) |
109 | { | 107 | { |
110 | #if DEBUG_NAT | ||
111 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_DEBUG, "send"); | 108 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_DEBUG, "send"); |
112 | #endif | ||
113 | } | 109 | } |
114 | GNUNET_NETWORK_socket_shutdown (ctx->s, SHUT_RDWR); | 110 | GNUNET_NETWORK_socket_shutdown (ctx->s, SHUT_RDWR); |
115 | } | 111 | } |
@@ -146,10 +142,8 @@ try_send_tcp (uint32_t dst_ipv4, uint16_t dport, uint16_t data) | |||
146 | #endif | 142 | #endif |
147 | sa.sin_addr.s_addr = dst_ipv4; | 143 | sa.sin_addr.s_addr = dst_ipv4; |
148 | sa.sin_port = htons (dport); | 144 | sa.sin_port = htons (dport); |
149 | #if DEBUG_NAT | ||
150 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending TCP message to `%s'\n", | 145 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending TCP message to `%s'\n", |
151 | GNUNET_a2s ((struct sockaddr *) &sa, sizeof (sa))); | 146 | GNUNET_a2s ((struct sockaddr *) &sa, sizeof (sa))); |
152 | #endif | ||
153 | if ((GNUNET_OK != | 147 | if ((GNUNET_OK != |
154 | GNUNET_NETWORK_socket_connect (s, (const struct sockaddr *) &sa, | 148 | GNUNET_NETWORK_socket_connect (s, (const struct sockaddr *) &sa, |
155 | sizeof (sa))) && (errno != EINPROGRESS)) | 149 | sizeof (sa))) && (errno != EINPROGRESS)) |
@@ -192,10 +186,8 @@ try_send_udp (uint32_t dst_ipv4, uint16_t dport, uint16_t data) | |||
192 | #endif | 186 | #endif |
193 | sa.sin_addr.s_addr = dst_ipv4; | 187 | sa.sin_addr.s_addr = dst_ipv4; |
194 | sa.sin_port = htons (dport); | 188 | sa.sin_port = htons (dport); |
195 | #if DEBUG_NAT | ||
196 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending UDP packet to `%s'\n", | 189 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending UDP packet to `%s'\n", |
197 | GNUNET_a2s ((struct sockaddr *) &sa, sizeof (sa))); | 190 | GNUNET_a2s ((struct sockaddr *) &sa, sizeof (sa))); |
198 | #endif | ||
199 | if (-1 == | 191 | if (-1 == |
200 | GNUNET_NETWORK_socket_sendto (s, &data, sizeof (data), | 192 | GNUNET_NETWORK_socket_sendto (s, &data, sizeof (data), |
201 | (const struct sockaddr *) &sa, sizeof (sa))) | 193 | (const struct sockaddr *) &sa, sizeof (sa))) |
@@ -219,9 +211,7 @@ test (void *cls, struct GNUNET_SERVER_Client *client, | |||
219 | const struct GNUNET_NAT_TestMessage *tm; | 211 | const struct GNUNET_NAT_TestMessage *tm; |
220 | uint16_t dport; | 212 | uint16_t dport; |
221 | 213 | ||
222 | #if DEBUG_NAT | ||
223 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received test request\n"); | 214 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received test request\n"); |
224 | #endif | ||
225 | tm = (const struct GNUNET_NAT_TestMessage *) msg; | 215 | tm = (const struct GNUNET_NAT_TestMessage *) msg; |
226 | dport = ntohs (tm->dport); | 216 | dport = ntohs (tm->dport); |
227 | if (0 == dport) | 217 | if (0 == dport) |
diff --git a/src/nat/nat.c b/src/nat/nat.c index 53301ebb1..1b6556cbf 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, | |||
422 | lal->addrlen = arg_size; | 422 | lal->addrlen = arg_size; |
423 | lal->source = src; | 423 | lal->source = src; |
424 | GNUNET_CONTAINER_DLL_insert (h->lal_head, h->lal_tail, lal); | 424 | GNUNET_CONTAINER_DLL_insert (h->lal_head, h->lal_tail, lal); |
425 | #if DEBUG_NAT | ||
426 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Adding address `%s' from source %d\n", | 425 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Adding address `%s' from source %d\n", |
427 | GNUNET_a2s (arg, arg_size), src); | 426 | GNUNET_a2s (arg, arg_size), src); |
428 | #endif | ||
429 | if (NULL != h->address_callback) | 427 | if (NULL != h->address_callback) |
430 | h->address_callback (h->callback_cls, GNUNET_YES, arg, arg_size); | 428 | h->address_callback (h->callback_cls, GNUNET_YES, arg, arg_size); |
431 | } | 429 | } |
@@ -750,10 +748,8 @@ nat_server_read (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
750 | GNUNET_DISK_file_read (h->server_stdout_handle, mybuf, sizeof (mybuf)); | 748 | GNUNET_DISK_file_read (h->server_stdout_handle, mybuf, sizeof (mybuf)); |
751 | if (bytes < 1) | 749 | if (bytes < 1) |
752 | { | 750 | { |
753 | #if DEBUG_NAT | ||
754 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 751 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
755 | "Finished reading from server stdout with code: %d\n", bytes); | 752 | "Finished reading from server stdout with code: %d\n", bytes); |
756 | #endif | ||
757 | if (0 != GNUNET_OS_process_kill (h->server_proc, SIGTERM)) | 753 | if (0 != GNUNET_OS_process_kill (h->server_proc, SIGTERM)) |
758 | GNUNET_log_from_strerror (GNUNET_ERROR_TYPE_WARNING, "nat", "kill"); | 754 | GNUNET_log_from_strerror (GNUNET_ERROR_TYPE_WARNING, "nat", "kill"); |
759 | GNUNET_OS_process_wait (h->server_proc); | 755 | GNUNET_OS_process_wait (h->server_proc); |
@@ -809,10 +805,8 @@ nat_server_read (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
809 | return; | 805 | return; |
810 | } | 806 | } |
811 | sin_addr.sin_port = htons ((uint16_t) port); | 807 | sin_addr.sin_port = htons ((uint16_t) port); |
812 | #if DEBUG_NAT | ||
813 | LOG (GNUNET_ERROR_TYPE_DEBUG, "gnunet-helper-nat-server read: %s:%d\n", mybuf, | 808 | LOG (GNUNET_ERROR_TYPE_DEBUG, "gnunet-helper-nat-server read: %s:%d\n", mybuf, |
814 | port); | 809 | port); |
815 | #endif | ||
816 | h->reversal_callback (h->callback_cls, (const struct sockaddr *) &sin_addr, | 810 | h->reversal_callback (h->callback_cls, (const struct sockaddr *) &sin_addr, |
817 | sizeof (sin_addr)); | 811 | sizeof (sin_addr)); |
818 | h->server_read_task = | 812 | h->server_read_task = |
@@ -837,10 +831,8 @@ start_gnunet_nat_server (struct GNUNET_NAT_Handle *h) | |||
837 | (h->server_stdout = | 831 | (h->server_stdout = |
838 | GNUNET_DISK_pipe (GNUNET_YES, GNUNET_YES, GNUNET_NO, GNUNET_YES)))) | 832 | GNUNET_DISK_pipe (GNUNET_YES, GNUNET_YES, GNUNET_NO, GNUNET_YES)))) |
839 | { | 833 | { |
840 | #if DEBUG_NAT | ||
841 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Starting `%s' at `%s'\n", | 834 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Starting `%s' at `%s'\n", |
842 | "gnunet-helper-nat-server", h->internal_address); | 835 | "gnunet-helper-nat-server", h->internal_address); |
843 | #endif | ||
844 | /* Start the server process */ | 836 | /* Start the server process */ |
845 | h->server_proc = | 837 | h->server_proc = |
846 | GNUNET_OS_start_process (GNUNET_NO, NULL, h->server_stdout, | 838 | 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, | |||
1079 | struct in_addr in_addr; | 1071 | struct in_addr in_addr; |
1080 | unsigned int i; | 1072 | unsigned int i; |
1081 | 1073 | ||
1082 | #if DEBUG_NAT | ||
1083 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1074 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1084 | "Registered with NAT service at port %u with %u IP bound local addresses\n", | 1075 | "Registered with NAT service at port %u with %u IP bound local addresses\n", |
1085 | (unsigned int) adv_port, num_addrs); | 1076 | (unsigned int) adv_port, num_addrs); |
1086 | #endif | ||
1087 | h = GNUNET_malloc (sizeof (struct GNUNET_NAT_Handle)); | 1077 | h = GNUNET_malloc (sizeof (struct GNUNET_NAT_Handle)); |
1088 | h->server_retry_delay = GNUNET_TIME_UNIT_SECONDS; | 1078 | h->server_retry_delay = GNUNET_TIME_UNIT_SECONDS; |
1089 | h->cfg = cfg; | 1079 | h->cfg = cfg; |
@@ -1338,11 +1328,9 @@ GNUNET_NAT_run_client (struct GNUNET_NAT_Handle *h, | |||
1338 | return GNUNET_SYSERR; | 1328 | return GNUNET_SYSERR; |
1339 | } | 1329 | } |
1340 | GNUNET_snprintf (port_as_string, sizeof (port_as_string), "%d", h->adv_port); | 1330 | GNUNET_snprintf (port_as_string, sizeof (port_as_string), "%d", h->adv_port); |
1341 | #if DEBUG_NAT | ||
1342 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1331 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1343 | _("Running gnunet-helper-nat-client %s %s %u\n"), h->internal_address, | 1332 | _("Running gnunet-helper-nat-client %s %s %u\n"), h->internal_address, |
1344 | inet4, (unsigned int) h->adv_port); | 1333 | inet4, (unsigned int) h->adv_port); |
1345 | #endif | ||
1346 | proc = | 1334 | proc = |
1347 | GNUNET_OS_start_process (GNUNET_NO, | 1335 | GNUNET_OS_start_process (GNUNET_NO, |
1348 | NULL, NULL, "gnunet-helper-nat-client", | 1336 | NULL, NULL, "gnunet-helper-nat-client", |
diff --git a/src/nat/nat.h b/src/nat/nat.h index efab3a7a7..a0ef46593 100644 --- a/src/nat/nat.h +++ b/src/nat/nat.h | |||
@@ -28,7 +28,6 @@ | |||
28 | #define NAT_H | 28 | #define NAT_H |
29 | #include "gnunet_util_lib.h" | 29 | #include "gnunet_util_lib.h" |
30 | 30 | ||
31 | #define DEBUG_NAT GNUNET_EXTRA_LOGGING | ||
32 | 31 | ||
33 | GNUNET_NETWORK_STRUCT_BEGIN | 32 | GNUNET_NETWORK_STRUCT_BEGIN |
34 | 33 | ||
diff --git a/src/nat/nat_mini.c b/src/nat/nat_mini.c index 84cc84186..864a7f04e 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) | |||
524 | 524 | ||
525 | if (NULL == line) | 525 | if (NULL == line) |
526 | { | 526 | { |
527 | #if DEBUG_NAT | ||
528 | LOG (GNUNET_ERROR_TYPE_DEBUG, "UPnP unmap done\n"); | 527 | LOG (GNUNET_ERROR_TYPE_DEBUG, "UPnP unmap done\n"); |
529 | #endif | ||
530 | GNUNET_OS_command_stop (mini->unmap_cmd); | 528 | GNUNET_OS_command_stop (mini->unmap_cmd); |
531 | mini->unmap_cmd = NULL; | 529 | mini->unmap_cmd = NULL; |
532 | GNUNET_free (mini); | 530 | GNUNET_free (mini); |
@@ -577,10 +575,8 @@ GNUNET_NAT_mini_map_stop (struct GNUNET_NAT_MiniHandle *mini) | |||
577 | * often are the same, but it might... */ | 575 | * often are the same, but it might... */ |
578 | GNUNET_snprintf (pstr, sizeof (pstr), "%u", | 576 | GNUNET_snprintf (pstr, sizeof (pstr), "%u", |
579 | (unsigned int) ntohs (mini->current_addr.sin_port)); | 577 | (unsigned int) ntohs (mini->current_addr.sin_port)); |
580 | #if DEBUG_NAT | ||
581 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Unmapping port %u with UPnP\n", | 578 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Unmapping port %u with UPnP\n", |
582 | ntohs (mini->current_addr.sin_port)); | 579 | ntohs (mini->current_addr.sin_port)); |
583 | #endif | ||
584 | mini->unmap_cmd = | 580 | mini->unmap_cmd = |
585 | GNUNET_OS_command_run (&process_unmap_output, mini, UNMAP_TIMEOUT, | 581 | GNUNET_OS_command_run (&process_unmap_output, mini, UNMAP_TIMEOUT, |
586 | "upnpc", "upnpc", "-d", pstr, | 582 | "upnpc", "upnpc", "-d", pstr, |
diff --git a/src/nat/nat_test.c b/src/nat/nat_test.c index 98ce82e73..5704d3484 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) | |||
180 | sa = (const struct sockaddr_in *) addr; | 180 | sa = (const struct sockaddr_in *) addr; |
181 | if (h->data != sa->sin_port) | 181 | if (h->data != sa->sin_port) |
182 | { | 182 | { |
183 | #if DEBUG_NAT | ||
184 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 183 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
185 | "Received connection reversal request for wrong port\n"); | 184 | "Received connection reversal request for wrong port\n"); |
186 | #endif | ||
187 | return; /* wrong port */ | 185 | return; /* wrong port */ |
188 | } | 186 | } |
189 | /* report success */ | 187 | /* report success */ |
@@ -214,17 +212,13 @@ do_udp_read (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
214 | { | 212 | { |
215 | if (data == tst->data) | 213 | if (data == tst->data) |
216 | tst->report (tst->report_cls, GNUNET_OK); | 214 | tst->report (tst->report_cls, GNUNET_OK); |
217 | #if DEBUG_NAT | ||
218 | else | 215 | else |
219 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 216 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
220 | "Received data mismatches expected value\n"); | 217 | "Received data mismatches expected value\n"); |
221 | #endif | ||
222 | } | 218 | } |
223 | #if DEBUG_NAT | ||
224 | else | 219 | else |
225 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 220 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
226 | "Failed to receive data from inbound connection\n"); | 221 | "Failed to receive data from inbound connection\n"); |
227 | #endif | ||
228 | } | 222 | } |
229 | 223 | ||
230 | 224 | ||
@@ -252,17 +246,13 @@ do_read (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
252 | { | 246 | { |
253 | if (data == tst->data) | 247 | if (data == tst->data) |
254 | tst->report (tst->report_cls, GNUNET_OK); | 248 | tst->report (tst->report_cls, GNUNET_OK); |
255 | #if DEBUG_NAT | ||
256 | else | 249 | else |
257 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 250 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
258 | "Received data mismatches expected value\n"); | 251 | "Received data mismatches expected value\n"); |
259 | #endif | ||
260 | } | 252 | } |
261 | #if DEBUG_NAT | ||
262 | else | 253 | else |
263 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 254 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
264 | "Failed to receive data from inbound connection\n"); | 255 | "Failed to receive data from inbound connection\n"); |
265 | #endif | ||
266 | GNUNET_NETWORK_socket_close (na->sock); | 256 | GNUNET_NETWORK_socket_close (na->sock); |
267 | GNUNET_free (na); | 257 | GNUNET_free (na); |
268 | } | 258 | } |
@@ -294,10 +284,8 @@ do_accept (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
294 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_INFO, "accept"); | 284 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_INFO, "accept"); |
295 | return; /* odd error */ | 285 | return; /* odd error */ |
296 | } | 286 | } |
297 | #if DEBUG_NAT | ||
298 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 287 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
299 | "Got an inbound connection, waiting for data\n"); | 288 | "Got an inbound connection, waiting for data\n"); |
300 | #endif | ||
301 | wl = GNUNET_malloc (sizeof (struct NatActivity)); | 289 | wl = GNUNET_malloc (sizeof (struct NatActivity)); |
302 | wl->sock = s; | 290 | wl->sock = s; |
303 | wl->h = tst; | 291 | wl->h = tst; |
@@ -331,10 +319,8 @@ addr_cb (void *cls, int add_remove, const struct sockaddr *addr, | |||
331 | return; | 319 | return; |
332 | if (addrlen != sizeof (struct sockaddr_in)) | 320 | if (addrlen != sizeof (struct sockaddr_in)) |
333 | return; /* ignore IPv6 here */ | 321 | return; /* ignore IPv6 here */ |
334 | #if DEBUG_NAT | ||
335 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Asking gnunet-nat-server to connect to `%s'\n", | 322 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Asking gnunet-nat-server to connect to `%s'\n", |
336 | GNUNET_a2s (addr, addrlen)); | 323 | GNUNET_a2s (addr, addrlen)); |
337 | #endif | ||
338 | sa = (const struct sockaddr_in *) addr; | 324 | sa = (const struct sockaddr_in *) addr; |
339 | msg.header.size = htons (sizeof (struct GNUNET_NAT_TestMessage)); | 325 | msg.header.size = htons (sizeof (struct GNUNET_NAT_TestMessage)); |
340 | msg.header.type = htons (GNUNET_MESSAGE_TYPE_NAT_TEST); | 326 | msg.header.type = htons (GNUNET_MESSAGE_TYPE_NAT_TEST); |