use LOG macro in nat.c
authorChristian Grothoff <christian@grothoff.org>
Mon, 10 Oct 2011 13:57:17 +0000 (13:57 +0000)
committerChristian Grothoff <christian@grothoff.org>
Mon, 10 Oct 2011 13:57:17 +0000 (13:57 +0000)
src/nat/nat_mini.c
src/nat/nat_test.c

index 8014a451d916fd91b9d1c863184b12c7b5d50fa4..5a83d7a4fea22e7dd4ce3b013d9d7aee494175b0 100644 (file)
@@ -28,6 +28,7 @@
 #include "gnunet_nat_lib.h"
 #include "nat.h"
 
+#define LOG(kind,...) GNUNET_log_from (kind, "nat", __VA_ARGS__)
 
 /**
  * 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,
 {
   struct GNUNET_NAT_ExternalHandle *eh;
 
-  if (GNUNET_SYSERR ==
-      GNUNET_OS_check_helper_binary ("external-ip"))
+  if (GNUNET_SYSERR == GNUNET_OS_check_helper_binary ("external-ip"))
     return NULL;
   eh = GNUNET_malloc (sizeof (struct GNUNET_NAT_ExternalHandle));
   eh->cb = cb;
@@ -525,7 +525,7 @@ process_unmap_output (void *cls, const char *line)
   if (NULL == line)
   {
 #if DEBUG_NAT
-    GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "nat", "UPnP unmap done\n");
+    LOG (GNUNET_ERROR_TYPE_DEBUG, "UPnP unmap done\n");
 #endif
     GNUNET_OS_command_stop (mini->unmap_cmd);
     mini->unmap_cmd = NULL;
@@ -578,9 +578,8 @@ GNUNET_NAT_mini_map_stop (struct GNUNET_NAT_MiniHandle *mini)
   GNUNET_snprintf (pstr, sizeof (pstr), "%u",
                    (unsigned int) ntohs (mini->current_addr.sin_port));
 #if DEBUG_NAT
-  GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "nat",
-                   "Unmapping port %u with UPnP\n",
-                   ntohs (mini->current_addr.sin_port));
+  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,
index a524831e4e32d65b918aec86c64a10b46c3232a3..b6e2a744c4571728c92d1f4687c0b3f9202c466a 100644 (file)
@@ -28,6 +28,7 @@
 #include "gnunet_nat_lib.h"
 #include "nat.h"
 
+#define LOG(kind,...) GNUNET_log_from (kind, "nat", __VA_ARGS__)
 
 /**
  * Entry we keep for each incoming connection.
@@ -178,8 +179,8 @@ reversal_cb (void *cls, const struct sockaddr *addr, socklen_t addrlen)
   if (h->data != sa->sin_port)
   {
 #if DEBUG_NAT
-    GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "nat",
-                     "Received connection reversal request for wrong port\n");
+    LOG (GNUNET_ERROR_TYPE_DEBUG,
+         "Received connection reversal request for wrong port\n");
 #endif
     return;                     /* wrong port */
   }
@@ -213,14 +214,14 @@ do_udp_read (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
       tst->report (tst->report_cls, GNUNET_OK);
 #if DEBUG_NAT
     else
-      GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "nat",
-                       "Received data mismatches expected value\n");
+      LOG (GNUNET_ERROR_TYPE_DEBUG,
+           "Received data mismatches expected value\n");
 #endif
   }
 #if DEBUG_NAT
   else
-    GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "nat",
-                     "Failed to receive data from inbound connection\n");
+    LOG (GNUNET_ERROR_TYPE_DEBUG,
+         "Failed to receive data from inbound connection\n");
 #endif
 }
 
@@ -251,15 +252,14 @@ do_read (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
       tst->report (tst->report_cls, GNUNET_OK);
 #if DEBUG_NAT
     else
-      GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG,
-                       "nat",
-                      "Received data mismatches expected value\n");
+      LOG (GNUNET_ERROR_TYPE_DEBUG,
+           "Received data mismatches expected value\n");
 #endif
   }
 #if DEBUG_NAT
   else
-    GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "nat",
-                     "Failed to receive data from inbound connection\n");
+    LOG (GNUNET_ERROR_TYPE_DEBUG,
+         "Failed to receive data from inbound connection\n");
 #endif
   GNUNET_NETWORK_socket_close (na->sock);
   GNUNET_free (na);
@@ -293,8 +293,8 @@ do_accept (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
     return;                     /* odd error */
   }
 #if DEBUG_NAT
-  GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "nat",
-                   "Got an inbound connection, waiting for data\n");
+  LOG (GNUNET_ERROR_TYPE_DEBUG,
+       "Got an inbound connection, waiting for data\n");
 #endif
   wl = GNUNET_malloc (sizeof (struct NatActivity));
   wl->sock = s;
@@ -330,9 +330,8 @@ addr_cb (void *cls, int add_remove, const struct sockaddr *addr,
   if (addrlen != sizeof (struct sockaddr_in))
     return;                     /* ignore IPv6 here */
 #if DEBUG_NAT
-  GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "nat",
-                   "Asking gnunet-nat-server to connect to `%s'\n",
-                   GNUNET_a2s (addr, addrlen));
+  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));