diff options
author | Christian Grothoff <christian@grothoff.org> | 2011-07-11 14:49:46 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2011-07-11 14:49:46 +0000 |
commit | 8dc32abbeff6b4b348253afed6c60543665a34c2 (patch) | |
tree | 0fe942debb1a57fcfef9d3526aab7217377b101a | |
parent | c7c9e6915281826e3027bc215ddffb14c2a72e47 (diff) | |
download | gnunet-8dc32abbeff6b4b348253afed6c60543665a34c2.tar.gz gnunet-8dc32abbeff6b4b348253afed6c60543665a34c2.zip |
logging
-rw-r--r-- | src/nat/nat.c | 20 | ||||
-rw-r--r-- | src/nat/nat_mini.c | 18 | ||||
-rw-r--r-- | src/nat/nat_test.c | 51 | ||||
-rw-r--r-- | src/nat/test_nat.c | 8 | ||||
-rw-r--r-- | src/nat/test_nat_mini.c | 2 | ||||
-rw-r--r-- | src/nat/test_nat_test.c | 2 |
6 files changed, 67 insertions, 34 deletions
diff --git a/src/nat/nat.c b/src/nat/nat.c index bf9565877..d09fd79fc 100644 --- a/src/nat/nat.c +++ b/src/nat/nat.c | |||
@@ -24,15 +24,14 @@ | |||
24 | * external IP address retrieval | 24 | * external IP address retrieval |
25 | * @author Milan Bouchet-Valat | 25 | * @author Milan Bouchet-Valat |
26 | * @author Christian Grothoff | 26 | * @author Christian Grothoff |
27 | * | ||
28 | * TODO: | ||
29 | * - implement UPnP/PMP support | ||
30 | */ | 27 | */ |
31 | #include "platform.h" | 28 | #include "platform.h" |
32 | #include "gnunet_util_lib.h" | 29 | #include "gnunet_util_lib.h" |
33 | #include "gnunet_resolver_service.h" | 30 | #include "gnunet_resolver_service.h" |
34 | #include "gnunet_nat_lib.h" | 31 | #include "gnunet_nat_lib.h" |
35 | 32 | ||
33 | #define DEBUG_NAT GNUNET_NO | ||
34 | |||
36 | /** | 35 | /** |
37 | * How often do we scan for changes in our IP address from our local | 36 | * How often do we scan for changes in our IP address from our local |
38 | * interfaces? | 37 | * interfaces? |
@@ -767,7 +766,7 @@ nat_server_read (void *cls, | |||
767 | sizeof(mybuf)); | 766 | sizeof(mybuf)); |
768 | if (bytes < 1) | 767 | if (bytes < 1) |
769 | { | 768 | { |
770 | #if DEBUG_TCP_NAT | 769 | #if DEBUG_NAT |
771 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, | 770 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, |
772 | "nat", | 771 | "nat", |
773 | "Finished reading from server stdout with code: %d\n", | 772 | "Finished reading from server stdout with code: %d\n", |
@@ -1136,10 +1135,13 @@ GNUNET_NAT_register (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
1136 | struct in_addr in_addr; | 1135 | struct in_addr in_addr; |
1137 | unsigned int i; | 1136 | unsigned int i; |
1138 | 1137 | ||
1139 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1138 | #if DEBUG_NAT |
1140 | "Registered with NAT service at port %u with %u IP bound local addresses\n", | 1139 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, |
1141 | (unsigned int) adv_port, | 1140 | "nat", |
1142 | num_addrs); | 1141 | "Registered with NAT service at port %u with %u IP bound local addresses\n", |
1142 | (unsigned int) adv_port, | ||
1143 | num_addrs); | ||
1144 | #endif | ||
1143 | h = GNUNET_malloc (sizeof (struct GNUNET_NAT_Handle)); | 1145 | h = GNUNET_malloc (sizeof (struct GNUNET_NAT_Handle)); |
1144 | h->server_retry_delay = GNUNET_TIME_UNIT_SECONDS; | 1146 | h->server_retry_delay = GNUNET_TIME_UNIT_SECONDS; |
1145 | h->cfg = cfg; | 1147 | h->cfg = cfg; |
@@ -1432,7 +1434,7 @@ GNUNET_NAT_run_client (struct GNUNET_NAT_Handle *h, | |||
1432 | sizeof (port_as_string), | 1434 | sizeof (port_as_string), |
1433 | "%d", | 1435 | "%d", |
1434 | h->adv_port); | 1436 | h->adv_port); |
1435 | #if DEBUG_TCP_NAT | 1437 | #if DEBUG_NAT |
1436 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, | 1438 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, |
1437 | "nat", | 1439 | "nat", |
1438 | _("Running gnunet-helper-nat-client %s %s %u\n"), | 1440 | _("Running gnunet-helper-nat-client %s %s %u\n"), |
diff --git a/src/nat/nat_mini.c b/src/nat/nat_mini.c index c8ac65edb..b82866c78 100644 --- a/src/nat/nat_mini.c +++ b/src/nat/nat_mini.c | |||
@@ -28,6 +28,8 @@ | |||
28 | #include "gnunet_nat_lib.h" | 28 | #include "gnunet_nat_lib.h" |
29 | #include "nat.h" | 29 | #include "nat.h" |
30 | 30 | ||
31 | #define DEBUG_NAT GNUNET_NO | ||
32 | |||
31 | /** | 33 | /** |
32 | * How long do we give upnpc to create a mapping? | 34 | * How long do we give upnpc to create a mapping? |
33 | */ | 35 | */ |
@@ -453,8 +455,11 @@ process_unmap_output (void *cls, | |||
453 | 455 | ||
454 | if (NULL == line) | 456 | if (NULL == line) |
455 | { | 457 | { |
456 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 458 | #if DEBUG_NAT |
457 | "UPnP unmap done\n"); | 459 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, |
460 | "nat", | ||
461 | "UPnP unmap done\n"); | ||
462 | #endif | ||
458 | GNUNET_OS_command_stop (mini->unmap_cmd); | 463 | GNUNET_OS_command_stop (mini->unmap_cmd); |
459 | mini->unmap_cmd = NULL; | 464 | mini->unmap_cmd = NULL; |
460 | GNUNET_free (mini); | 465 | GNUNET_free (mini); |
@@ -506,9 +511,12 @@ GNUNET_NAT_mini_map_stop (struct GNUNET_NAT_MiniHandle *mini) | |||
506 | GNUNET_snprintf (pstr, sizeof (pstr), | 511 | GNUNET_snprintf (pstr, sizeof (pstr), |
507 | "%u", | 512 | "%u", |
508 | (unsigned int) ntohs (mini->current_addr.sin_port)); | 513 | (unsigned int) ntohs (mini->current_addr.sin_port)); |
509 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 514 | #if DEBUG_NAT |
510 | "Unmapping port %u\n", | 515 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, |
511 | ntohs (mini->current_addr.sin_port)); | 516 | "nat", |
517 | "Unmapping port %u with UPnP\n", | ||
518 | ntohs (mini->current_addr.sin_port)); | ||
519 | #endif | ||
512 | mini->unmap_cmd = GNUNET_OS_command_run (&process_unmap_output, | 520 | mini->unmap_cmd = GNUNET_OS_command_run (&process_unmap_output, |
513 | mini, | 521 | mini, |
514 | UNMAP_TIMEOUT, | 522 | UNMAP_TIMEOUT, |
diff --git a/src/nat/nat_test.c b/src/nat/nat_test.c index 8a46a96fa..8c9933cdb 100644 --- a/src/nat/nat_test.c +++ b/src/nat/nat_test.c | |||
@@ -179,8 +179,11 @@ reversal_cb (void *cls, | |||
179 | sa = (const struct sockaddr_in *) addr; | 179 | sa = (const struct sockaddr_in *) addr; |
180 | if (h->data != sa->sin_port) | 180 | if (h->data != sa->sin_port) |
181 | { | 181 | { |
182 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 182 | #if DEBUG_NAT |
183 | "Received connection reversal request for wrong port\n"); | 183 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, |
184 | "nat", | ||
185 | "Received connection reversal request for wrong port\n"); | ||
186 | #endif | ||
184 | return; /* wrong port */ | 187 | return; /* wrong port */ |
185 | } | 188 | } |
186 | /* report success */ | 189 | /* report success */ |
@@ -216,13 +219,19 @@ do_udp_read (void *cls, | |||
216 | { | 219 | { |
217 | if (data == tst->data) | 220 | if (data == tst->data) |
218 | tst->report (tst->report_cls, GNUNET_OK); | 221 | tst->report (tst->report_cls, GNUNET_OK); |
222 | #if DEBUG_NAT | ||
219 | else | 223 | else |
220 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 224 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, |
221 | "Received data mismatches expected value\n"); | 225 | "nat", |
226 | "Received data mismatches expected value\n"); | ||
227 | #endif | ||
222 | } | 228 | } |
229 | #if DEBUG_NAT | ||
223 | else | 230 | else |
224 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 231 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, |
225 | "Failed to receive data from inbound connection\n"); | 232 | "nat", |
233 | "Failed to receive data from inbound connection\n"); | ||
234 | #endif | ||
226 | } | 235 | } |
227 | 236 | ||
228 | 237 | ||
@@ -256,13 +265,19 @@ do_read (void *cls, | |||
256 | { | 265 | { |
257 | if (data == tst->data) | 266 | if (data == tst->data) |
258 | tst->report (tst->report_cls, GNUNET_OK); | 267 | tst->report (tst->report_cls, GNUNET_OK); |
268 | #if DEBUG_NAT | ||
259 | else | 269 | else |
260 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 270 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, |
261 | "Received data mismatches expected value\n"); | 271 | "nat" |
272 | "Received data mismatches expected value\n"); | ||
273 | #endif | ||
262 | } | 274 | } |
275 | #if DEBUG_NAT | ||
263 | else | 276 | else |
264 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 277 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, |
265 | "Failed to receive data from inbound connection\n"); | 278 | "nat", |
279 | "Failed to receive data from inbound connection\n"); | ||
280 | #endif | ||
266 | GNUNET_NETWORK_socket_close (na->sock); | 281 | GNUNET_NETWORK_socket_close (na->sock); |
267 | GNUNET_free (na); | 282 | GNUNET_free (na); |
268 | } | 283 | } |
@@ -296,8 +311,11 @@ do_accept (void *cls, | |||
296 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_INFO, "accept"); | 311 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_INFO, "accept"); |
297 | return; /* odd error */ | 312 | return; /* odd error */ |
298 | } | 313 | } |
299 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 314 | #if DEBUG_NAT |
300 | "Got an inbound connection, waiting for data\n"); | 315 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, |
316 | "nat", | ||
317 | "Got an inbound connection, waiting for data\n"); | ||
318 | #endif | ||
301 | wl = GNUNET_malloc (sizeof (struct NatActivity)); | 319 | wl = GNUNET_malloc (sizeof (struct NatActivity)); |
302 | wl->sock = s; | 320 | wl->sock = s; |
303 | wl->h = tst; | 321 | wl->h = tst; |
@@ -336,9 +354,12 @@ addr_cb (void *cls, | |||
336 | return; | 354 | return; |
337 | if (addrlen != sizeof (struct sockaddr_in)) | 355 | if (addrlen != sizeof (struct sockaddr_in)) |
338 | return; /* ignore IPv6 here */ | 356 | return; /* ignore IPv6 here */ |
339 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 357 | #if DEBUG_NAT |
340 | "Asking gnunet-nat-server to connect to `%s'\n", | 358 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, |
341 | GNUNET_a2s (addr, addrlen)); | 359 | "nat", |
360 | "Asking gnunet-nat-server to connect to `%s'\n", | ||
361 | GNUNET_a2s (addr, addrlen)); | ||
362 | #endif | ||
342 | sa = (const struct sockaddr_in*) addr; | 363 | sa = (const struct sockaddr_in*) addr; |
343 | msg.header.size = htons (sizeof(struct GNUNET_NAT_TestMessage)); | 364 | msg.header.size = htons (sizeof(struct GNUNET_NAT_TestMessage)); |
344 | msg.header.type = htons (GNUNET_MESSAGE_TYPE_NAT_TEST); | 365 | msg.header.type = htons (GNUNET_MESSAGE_TYPE_NAT_TEST); |
diff --git a/src/nat/test_nat.c b/src/nat/test_nat.c index 72cff0915..cb011c7af 100644 --- a/src/nat/test_nat.c +++ b/src/nat/test_nat.c | |||
@@ -41,11 +41,13 @@ | |||
41 | #include "gnunet_nat_lib.h" | 41 | #include "gnunet_nat_lib.h" |
42 | 42 | ||
43 | 43 | ||
44 | #define VERBOSE GNUNET_YES | 44 | #define VERBOSE GNUNET_NO |
45 | 45 | ||
46 | 46 | ||
47 | /* Time to wait before stopping NAT, in seconds */ | 47 | /** |
48 | #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 60) | 48 | * Time to wait before stopping NAT, in seconds |
49 | */ | ||
50 | #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5) | ||
49 | 51 | ||
50 | 52 | ||
51 | /** | 53 | /** |
diff --git a/src/nat/test_nat_mini.c b/src/nat/test_nat_mini.c index 4e708c413..e7b8294c8 100644 --- a/src/nat/test_nat_mini.c +++ b/src/nat/test_nat_mini.c | |||
@@ -36,7 +36,7 @@ | |||
36 | #include "gnunet_nat_lib.h" | 36 | #include "gnunet_nat_lib.h" |
37 | 37 | ||
38 | 38 | ||
39 | #define VERBOSE GNUNET_YES | 39 | #define VERBOSE GNUNET_NO |
40 | 40 | ||
41 | /* Time to wait before stopping NAT, in seconds */ | 41 | /* Time to wait before stopping NAT, in seconds */ |
42 | #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5) | 42 | #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5) |
diff --git a/src/nat/test_nat_test.c b/src/nat/test_nat_test.c index a7c7ff967..32c4fb2d8 100644 --- a/src/nat/test_nat_test.c +++ b/src/nat/test_nat_test.c | |||
@@ -31,7 +31,7 @@ | |||
31 | #include "gnunet_nat_lib.h" | 31 | #include "gnunet_nat_lib.h" |
32 | 32 | ||
33 | 33 | ||
34 | #define VERBOSE GNUNET_YES | 34 | #define VERBOSE GNUNET_NO |
35 | 35 | ||
36 | 36 | ||
37 | /** | 37 | /** |