* 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?
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",
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;
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"),
#include "gnunet_nat_lib.h"
#include "nat.h"
+#define DEBUG_NAT GNUNET_NO
+
/**
* How long do we give upnpc to create a mapping?
*/
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);
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,
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 */
{
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
}
{
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);
}
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;
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);
#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)
/**
#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)
#include "gnunet_nat_lib.h"
-#define VERBOSE GNUNET_YES
+#define VERBOSE GNUNET_NO
/**