aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-10-10 13:57:17 +0000
committerChristian Grothoff <christian@grothoff.org>2011-10-10 13:57:17 +0000
commit64f93505159d734411000a3097650e8d472c1d9b (patch)
treeb943c59c47cc3935b3c8e377221fe3a79f709dcd /src
parent2d32b2ca9b0497490e4215a2c15d236b16a77f19 (diff)
downloadgnunet-64f93505159d734411000a3097650e8d472c1d9b.tar.gz
gnunet-64f93505159d734411000a3097650e8d472c1d9b.zip
use LOG macro in nat.c
Diffstat (limited to 'src')
-rw-r--r--src/nat/nat_mini.c11
-rw-r--r--src/nat/nat_test.c31
2 files changed, 20 insertions, 22 deletions
diff --git a/src/nat/nat_mini.c b/src/nat/nat_mini.c
index 8014a451d..5a83d7a4f 100644
--- a/src/nat/nat_mini.c
+++ b/src/nat/nat_mini.c
@@ -28,6 +28,7 @@
28#include "gnunet_nat_lib.h" 28#include "gnunet_nat_lib.h"
29#include "nat.h" 29#include "nat.h"
30 30
31#define LOG(kind,...) GNUNET_log_from (kind, "nat", __VA_ARGS__)
31 32
32/** 33/**
33 * How long do we give upnpc to create a mapping? 34 * How long do we give upnpc to create a mapping?
@@ -163,8 +164,7 @@ GNUNET_NAT_mini_get_external_ipv4 (struct GNUNET_TIME_Relative timeout,
163{ 164{
164 struct GNUNET_NAT_ExternalHandle *eh; 165 struct GNUNET_NAT_ExternalHandle *eh;
165 166
166 if (GNUNET_SYSERR == 167 if (GNUNET_SYSERR == GNUNET_OS_check_helper_binary ("external-ip"))
167 GNUNET_OS_check_helper_binary ("external-ip"))
168 return NULL; 168 return NULL;
169 eh = GNUNET_malloc (sizeof (struct GNUNET_NAT_ExternalHandle)); 169 eh = GNUNET_malloc (sizeof (struct GNUNET_NAT_ExternalHandle));
170 eh->cb = cb; 170 eh->cb = cb;
@@ -525,7 +525,7 @@ process_unmap_output (void *cls, const char *line)
525 if (NULL == line) 525 if (NULL == line)
526 { 526 {
527#if DEBUG_NAT 527#if DEBUG_NAT
528 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "nat", "UPnP unmap done\n"); 528 LOG (GNUNET_ERROR_TYPE_DEBUG, "UPnP unmap done\n");
529#endif 529#endif
530 GNUNET_OS_command_stop (mini->unmap_cmd); 530 GNUNET_OS_command_stop (mini->unmap_cmd);
531 mini->unmap_cmd = NULL; 531 mini->unmap_cmd = NULL;
@@ -578,9 +578,8 @@ GNUNET_NAT_mini_map_stop (struct GNUNET_NAT_MiniHandle *mini)
578 GNUNET_snprintf (pstr, sizeof (pstr), "%u", 578 GNUNET_snprintf (pstr, sizeof (pstr), "%u",
579 (unsigned int) ntohs (mini->current_addr.sin_port)); 579 (unsigned int) ntohs (mini->current_addr.sin_port));
580#if DEBUG_NAT 580#if DEBUG_NAT
581 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "nat", 581 LOG (GNUNET_ERROR_TYPE_DEBUG, "Unmapping port %u with UPnP\n",
582 "Unmapping port %u with UPnP\n", 582 ntohs (mini->current_addr.sin_port));
583 ntohs (mini->current_addr.sin_port));
584#endif 583#endif
585 mini->unmap_cmd = 584 mini->unmap_cmd =
586 GNUNET_OS_command_run (&process_unmap_output, mini, UNMAP_TIMEOUT, 585 GNUNET_OS_command_run (&process_unmap_output, mini, UNMAP_TIMEOUT,
diff --git a/src/nat/nat_test.c b/src/nat/nat_test.c
index a524831e4..b6e2a744c 100644
--- a/src/nat/nat_test.c
+++ b/src/nat/nat_test.c
@@ -28,6 +28,7 @@
28#include "gnunet_nat_lib.h" 28#include "gnunet_nat_lib.h"
29#include "nat.h" 29#include "nat.h"
30 30
31#define LOG(kind,...) GNUNET_log_from (kind, "nat", __VA_ARGS__)
31 32
32/** 33/**
33 * Entry we keep for each incoming connection. 34 * Entry we keep for each incoming connection.
@@ -178,8 +179,8 @@ reversal_cb (void *cls, const struct sockaddr *addr, socklen_t addrlen)
178 if (h->data != sa->sin_port) 179 if (h->data != sa->sin_port)
179 { 180 {
180#if DEBUG_NAT 181#if DEBUG_NAT
181 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "nat", 182 LOG (GNUNET_ERROR_TYPE_DEBUG,
182 "Received connection reversal request for wrong port\n"); 183 "Received connection reversal request for wrong port\n");
183#endif 184#endif
184 return; /* wrong port */ 185 return; /* wrong port */
185 } 186 }
@@ -213,14 +214,14 @@ do_udp_read (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
213 tst->report (tst->report_cls, GNUNET_OK); 214 tst->report (tst->report_cls, GNUNET_OK);
214#if DEBUG_NAT 215#if DEBUG_NAT
215 else 216 else
216 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "nat", 217 LOG (GNUNET_ERROR_TYPE_DEBUG,
217 "Received data mismatches expected value\n"); 218 "Received data mismatches expected value\n");
218#endif 219#endif
219 } 220 }
220#if DEBUG_NAT 221#if DEBUG_NAT
221 else 222 else
222 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "nat", 223 LOG (GNUNET_ERROR_TYPE_DEBUG,
223 "Failed to receive data from inbound connection\n"); 224 "Failed to receive data from inbound connection\n");
224#endif 225#endif
225} 226}
226 227
@@ -251,15 +252,14 @@ do_read (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
251 tst->report (tst->report_cls, GNUNET_OK); 252 tst->report (tst->report_cls, GNUNET_OK);
252#if DEBUG_NAT 253#if DEBUG_NAT
253 else 254 else
254 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, 255 LOG (GNUNET_ERROR_TYPE_DEBUG,
255 "nat", 256 "Received data mismatches expected value\n");
256 "Received data mismatches expected value\n");
257#endif 257#endif
258 } 258 }
259#if DEBUG_NAT 259#if DEBUG_NAT
260 else 260 else
261 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "nat", 261 LOG (GNUNET_ERROR_TYPE_DEBUG,
262 "Failed to receive data from inbound connection\n"); 262 "Failed to receive data from inbound connection\n");
263#endif 263#endif
264 GNUNET_NETWORK_socket_close (na->sock); 264 GNUNET_NETWORK_socket_close (na->sock);
265 GNUNET_free (na); 265 GNUNET_free (na);
@@ -293,8 +293,8 @@ do_accept (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
293 return; /* odd error */ 293 return; /* odd error */
294 } 294 }
295#if DEBUG_NAT 295#if DEBUG_NAT
296 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "nat", 296 LOG (GNUNET_ERROR_TYPE_DEBUG,
297 "Got an inbound connection, waiting for data\n"); 297 "Got an inbound connection, waiting for data\n");
298#endif 298#endif
299 wl = GNUNET_malloc (sizeof (struct NatActivity)); 299 wl = GNUNET_malloc (sizeof (struct NatActivity));
300 wl->sock = s; 300 wl->sock = s;
@@ -330,9 +330,8 @@ addr_cb (void *cls, int add_remove, const struct sockaddr *addr,
330 if (addrlen != sizeof (struct sockaddr_in)) 330 if (addrlen != sizeof (struct sockaddr_in))
331 return; /* ignore IPv6 here */ 331 return; /* ignore IPv6 here */
332#if DEBUG_NAT 332#if DEBUG_NAT
333 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "nat", 333 LOG (GNUNET_ERROR_TYPE_DEBUG, "Asking gnunet-nat-server to connect to `%s'\n",
334 "Asking gnunet-nat-server to connect to `%s'\n", 334 GNUNET_a2s (addr, addrlen));
335 GNUNET_a2s (addr, addrlen));
336#endif 335#endif
337 sa = (const struct sockaddr_in *) addr; 336 sa = (const struct sockaddr_in *) addr;
338 msg.header.size = htons (sizeof (struct GNUNET_NAT_TestMessage)); 337 msg.header.size = htons (sizeof (struct GNUNET_NAT_TestMessage));