logging
authorChristian Grothoff <christian@grothoff.org>
Mon, 11 Jul 2011 14:49:46 +0000 (14:49 +0000)
committerChristian Grothoff <christian@grothoff.org>
Mon, 11 Jul 2011 14:49:46 +0000 (14:49 +0000)
src/nat/nat.c
src/nat/nat_mini.c
src/nat/nat_test.c
src/nat/test_nat.c
src/nat/test_nat_mini.c
src/nat/test_nat_test.c

index bf956587723d48a4f3c72bf2b7053874db3f02d1..d09fd79fc93199e2170a74c859fc17ee117d444b 100644 (file)
  *     external IP address retrieval
  * @author Milan Bouchet-Valat
  * @author Christian Grothoff
- *
- * TODO:
- * - implement UPnP/PMP support
  */
 #include "platform.h"
 #include "gnunet_util_lib.h"
 #include "gnunet_resolver_service.h"
 #include "gnunet_nat_lib.h"
 
+#define DEBUG_NAT GNUNET_NO
+
 /**
  * How often do we scan for changes in our IP address from our local
  * interfaces?
@@ -767,7 +766,7 @@ nat_server_read (void *cls,
                                sizeof(mybuf));
   if (bytes < 1)
     {
-#if DEBUG_TCP_NAT
+#if DEBUG_NAT
       GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG,
                       "nat",
                       "Finished reading from server stdout with code: %d\n", 
@@ -1136,10 +1135,13 @@ GNUNET_NAT_register (const struct GNUNET_CONFIGURATION_Handle *cfg,
   struct in_addr in_addr;
   unsigned int i;
 
-  GNUNET_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);
+#if DEBUG_NAT
+  GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG,
+                  "nat",
+                  "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;
@@ -1432,7 +1434,7 @@ GNUNET_NAT_run_client (struct GNUNET_NAT_Handle *h,
                   sizeof (port_as_string),
                   "%d", 
                   h->adv_port);
-#if DEBUG_TCP_NAT
+#if DEBUG_NAT
   GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG,
                   "nat",
                   _("Running gnunet-helper-nat-client %s %s %u\n"), 
index c8ac65edb00ed9aa8d84b135ebc889b22857281c..b82866c78b6473473836fc414661e0a5a5650200 100644 (file)
@@ -28,6 +28,8 @@
 #include "gnunet_nat_lib.h"
 #include "nat.h"
 
+#define DEBUG_NAT GNUNET_NO
+
 /**
  * How long do we give upnpc to create a mapping?
  */
@@ -453,8 +455,11 @@ process_unmap_output (void *cls,
 
   if (NULL == line)
     {
-      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                 "UPnP unmap done\n");
+#if DEBUG_NAT
+      GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG,
+                      "nat",
+                      "UPnP unmap done\n");
+#endif
       GNUNET_OS_command_stop (mini->unmap_cmd);
       mini->unmap_cmd = NULL;
       GNUNET_free (mini);
@@ -506,9 +511,12 @@ GNUNET_NAT_mini_map_stop (struct GNUNET_NAT_MiniHandle *mini)
   GNUNET_snprintf (pstr, sizeof (pstr),
                   "%u",
                   (unsigned int) ntohs (mini->current_addr.sin_port));
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-             "Unmapping port %u\n",
-             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));
+#endif
   mini->unmap_cmd = GNUNET_OS_command_run (&process_unmap_output,
                                           mini,
                                           UNMAP_TIMEOUT,
index 8a46a96fab392faf016f3d1e13dc2af07cc8658f..8c9933cdb884f4c76a20da2cb43064af6f559444 100644 (file)
@@ -179,8 +179,11 @@ reversal_cb (void *cls,
   sa = (const struct sockaddr_in *) addr;
   if (h->data != sa->sin_port)
     {
-      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                 "Received connection reversal request for wrong port\n");
+#if DEBUG_NAT
+      GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG,
+                      "nat",
+                      "Received connection reversal request for wrong port\n");
+#endif
       return; /* wrong port */
     }
   /* report success */
@@ -216,13 +219,19 @@ do_udp_read (void *cls,
     {
       if (data == tst->data)
        tst->report (tst->report_cls, GNUNET_OK);
+#if DEBUG_NAT
       else
-       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                   "Received data mismatches expected value\n");
+       GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG,
+                        "nat",
+                        "Received data mismatches expected value\n");
+#endif
     }
+#if DEBUG_NAT
   else
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-               "Failed to receive data from inbound connection\n");
+    GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG,
+                    "nat",
+                    "Failed to receive data from inbound connection\n");
+#endif
 }
 
 
@@ -256,13 +265,19 @@ do_read (void *cls,
     {
       if (data == tst->data)
        tst->report (tst->report_cls, GNUNET_OK);
+#if DEBUG_NAT
       else
-       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                   "Received data mismatches expected value\n");
+       GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG,
+                        "nat"
+                        "Received data mismatches expected value\n");
+#endif
     }
+#if DEBUG_NAT
   else
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-               "Failed to receive data from inbound connection\n");
+    GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG,
+                    "nat",
+                    "Failed to receive data from inbound connection\n");
+#endif
   GNUNET_NETWORK_socket_close (na->sock);
   GNUNET_free (na);
 }
@@ -296,8 +311,11 @@ do_accept (void *cls,
       GNUNET_log_strerror (GNUNET_ERROR_TYPE_INFO, "accept");
       return; /* odd error */
     }
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-             "Got an inbound connection, waiting for data\n");
+#if DEBUG_NAT 
+  GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG,
+                  "nat",
+                  "Got an inbound connection, waiting for data\n");
+#endif
   wl = GNUNET_malloc (sizeof (struct NatActivity));
   wl->sock = s;
   wl->h = tst;
@@ -336,9 +354,12 @@ addr_cb (void *cls,
     return;
   if (addrlen != sizeof (struct sockaddr_in))
     return; /* ignore IPv6 here */
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-             "Asking gnunet-nat-server to connect to `%s'\n",
-             GNUNET_a2s (addr, addrlen));
+#if DEBUG_NAT
+  GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG,
+                  "nat",
+                  "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);
index 72cff0915fb73209a710e807a5f17925e52b578d..cb011c7afd20583fddc28add7d2679c7c549f4f9 100644 (file)
 #include "gnunet_nat_lib.h"
 
 
-#define VERBOSE GNUNET_YES
+#define VERBOSE GNUNET_NO
 
 
-/* Time to wait before stopping NAT, in seconds */
-#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 60)
+/**
+ * Time to wait before stopping NAT, in seconds 
+ */
+#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5)
 
 
 /**
index 4e708c41323f3ecae69722be5a790fd42ddf2c43..e7b8294c8da0055f37045c15eaaf2a9304e063de 100644 (file)
@@ -36,7 +36,7 @@
 #include "gnunet_nat_lib.h"
 
 
-#define VERBOSE GNUNET_YES
+#define VERBOSE GNUNET_NO
 
 /* Time to wait before stopping NAT, in seconds */
 #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5)
index a7c7ff96712fef76f3e0ae2a8707044ab5e47dfc..32c4fb2d8f7556b27bec13458d8d09db2bdca1e8 100644 (file)
@@ -31,7 +31,7 @@
 #include "gnunet_nat_lib.h"
 
 
-#define VERBOSE GNUNET_YES
+#define VERBOSE GNUNET_NO
 
 
 /**