#include "gnunet_protocols.h"
#include "nat.h"
+#define DEBUG_NAT GNUNET_NO
+
/**
* Our server.
*/
struct GNUNET_NAT_Handle *h;
struct sockaddr_in sa;
+#if DEBUG_NAT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Asking for connection reversal with %x and code %u\n",
(unsigned int) dst_ipv4,
(unsigned int) dport);
+#endif
h = GNUNET_NAT_register (cfg,
is_tcp,
dport,
ctx->s)) )
{
if (-1 == GNUNET_NETWORK_socket_send (ctx->s, &ctx->data, sizeof (ctx->data)))
- GNUNET_log_strerror (GNUNET_ERROR_TYPE_DEBUG, "send");
+ {
+#if DEBUG_NAT
+ GNUNET_log_strerror (GNUNET_ERROR_TYPE_DEBUG, "send");
+#endif
+ }
GNUNET_NETWORK_socket_shutdown (ctx->s, SHUT_RDWR);
}
GNUNET_NETWORK_socket_close (ctx->s);
#endif
sa.sin_addr.s_addr = dst_ipv4;
sa.sin_port = htons (dport);
+#if DEBUG_NAT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Sending TCP message to `%s'\n",
GNUNET_a2s ((struct sockaddr*) &sa, sizeof (sa)));
+#endif
if ( (GNUNET_OK !=
GNUNET_NETWORK_socket_connect (s,
(const struct sockaddr*) &sa, sizeof (sa))) &&
#endif
sa.sin_addr.s_addr = dst_ipv4;
sa.sin_port = htons (dport);
+#if DEBUG_NAT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Sending UDP packet to `%s'\n",
GNUNET_a2s ((struct sockaddr*) &sa, sizeof (sa)));
+#endif
if (-1 == GNUNET_NETWORK_socket_sendto (s,
&data, sizeof(data),
(const struct sockaddr*) &sa, sizeof (sa)))
const struct GNUNET_NAT_TestMessage *tm;
uint16_t dport;
+#if DEBUG_NAT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Received test request\n");
+#endif
tm = (const struct GNUNET_NAT_TestMessage*) msg;
dport = ntohs (tm->dport);
if (0 == dport)
GNUNET_CONTAINER_DLL_insert (h->lal_head,
h->lal_tail,
lal);
+#if DEBUG_NAT
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG,
"nat",
"Adding address `%s' from source %d\n",
GNUNET_a2s (arg, arg_size),
src);
+#endif
if (NULL != h->address_callback)
h->address_callback (h->callback_cls,
GNUNET_YES,
h->use_hostname = GNUNET_CONFIGURATION_get_value_yesno (cfg,
"nat",
"USE_HOSTNAME");
- if (h->use_localaddresses)
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "USE LOCALADDR enabled!\n");
h->disable_ipv6 = GNUNET_CONFIGURATION_get_value_yesno(cfg,
"nat",
"DISABLEV6");