aboutsummaryrefslogtreecommitdiff
path: root/src/nat/gnunet-nat-server.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-07-11 14:54:27 +0000
committerChristian Grothoff <christian@grothoff.org>2011-07-11 14:54:27 +0000
commitec346597fba6b7fdec3939de40b3b7aba322049d (patch)
treee386f9ea31440a63f2c38c49705930d9ca99f289 /src/nat/gnunet-nat-server.c
parent8dc32abbeff6b4b348253afed6c60543665a34c2 (diff)
downloadgnunet-ec346597fba6b7fdec3939de40b3b7aba322049d.tar.gz
gnunet-ec346597fba6b7fdec3939de40b3b7aba322049d.zip
fixes
Diffstat (limited to 'src/nat/gnunet-nat-server.c')
-rw-r--r--src/nat/gnunet-nat-server.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/nat/gnunet-nat-server.c b/src/nat/gnunet-nat-server.c
index 1c639596f..bf4318a91 100644
--- a/src/nat/gnunet-nat-server.c
+++ b/src/nat/gnunet-nat-server.c
@@ -29,6 +29,8 @@
29#include "gnunet_protocols.h" 29#include "gnunet_protocols.h"
30#include "nat.h" 30#include "nat.h"
31 31
32#define DEBUG_NAT GNUNET_NO
33
32/** 34/**
33 * Our server. 35 * Our server.
34 */ 36 */
@@ -56,10 +58,12 @@ try_anat (uint32_t dst_ipv4,
56 struct GNUNET_NAT_Handle *h; 58 struct GNUNET_NAT_Handle *h;
57 struct sockaddr_in sa; 59 struct sockaddr_in sa;
58 60
61#if DEBUG_NAT
59 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 62 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
60 "Asking for connection reversal with %x and code %u\n", 63 "Asking for connection reversal with %x and code %u\n",
61 (unsigned int) dst_ipv4, 64 (unsigned int) dst_ipv4,
62 (unsigned int) dport); 65 (unsigned int) dport);
66#endif
63 h = GNUNET_NAT_register (cfg, 67 h = GNUNET_NAT_register (cfg,
64 is_tcp, 68 is_tcp,
65 dport, 69 dport,
@@ -111,7 +115,11 @@ tcp_send (void *cls,
111 ctx->s)) ) 115 ctx->s)) )
112 { 116 {
113 if (-1 == GNUNET_NETWORK_socket_send (ctx->s, &ctx->data, sizeof (ctx->data))) 117 if (-1 == GNUNET_NETWORK_socket_send (ctx->s, &ctx->data, sizeof (ctx->data)))
114 GNUNET_log_strerror (GNUNET_ERROR_TYPE_DEBUG, "send"); 118 {
119#if DEBUG_NAT
120 GNUNET_log_strerror (GNUNET_ERROR_TYPE_DEBUG, "send");
121#endif
122 }
115 GNUNET_NETWORK_socket_shutdown (ctx->s, SHUT_RDWR); 123 GNUNET_NETWORK_socket_shutdown (ctx->s, SHUT_RDWR);
116 } 124 }
117 GNUNET_NETWORK_socket_close (ctx->s); 125 GNUNET_NETWORK_socket_close (ctx->s);
@@ -149,9 +157,11 @@ try_send_tcp (uint32_t dst_ipv4,
149#endif 157#endif
150 sa.sin_addr.s_addr = dst_ipv4; 158 sa.sin_addr.s_addr = dst_ipv4;
151 sa.sin_port = htons (dport); 159 sa.sin_port = htons (dport);
160#if DEBUG_NAT
152 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 161 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
153 "Sending TCP message to `%s'\n", 162 "Sending TCP message to `%s'\n",
154 GNUNET_a2s ((struct sockaddr*) &sa, sizeof (sa))); 163 GNUNET_a2s ((struct sockaddr*) &sa, sizeof (sa)));
164#endif
155 if ( (GNUNET_OK != 165 if ( (GNUNET_OK !=
156 GNUNET_NETWORK_socket_connect (s, 166 GNUNET_NETWORK_socket_connect (s,
157 (const struct sockaddr*) &sa, sizeof (sa))) && 167 (const struct sockaddr*) &sa, sizeof (sa))) &&
@@ -199,9 +209,11 @@ try_send_udp (uint32_t dst_ipv4,
199#endif 209#endif
200 sa.sin_addr.s_addr = dst_ipv4; 210 sa.sin_addr.s_addr = dst_ipv4;
201 sa.sin_port = htons (dport); 211 sa.sin_port = htons (dport);
212#if DEBUG_NAT
202 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 213 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
203 "Sending UDP packet to `%s'\n", 214 "Sending UDP packet to `%s'\n",
204 GNUNET_a2s ((struct sockaddr*) &sa, sizeof (sa))); 215 GNUNET_a2s ((struct sockaddr*) &sa, sizeof (sa)));
216#endif
205 if (-1 == GNUNET_NETWORK_socket_sendto (s, 217 if (-1 == GNUNET_NETWORK_socket_sendto (s,
206 &data, sizeof(data), 218 &data, sizeof(data),
207 (const struct sockaddr*) &sa, sizeof (sa))) 219 (const struct sockaddr*) &sa, sizeof (sa)))
@@ -226,8 +238,10 @@ test (void *cls,
226 const struct GNUNET_NAT_TestMessage *tm; 238 const struct GNUNET_NAT_TestMessage *tm;
227 uint16_t dport; 239 uint16_t dport;
228 240
241#if DEBUG_NAT
229 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 242 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
230 "Received test request\n"); 243 "Received test request\n");
244#endif
231 tm = (const struct GNUNET_NAT_TestMessage*) msg; 245 tm = (const struct GNUNET_NAT_TestMessage*) msg;
232 dport = ntohs (tm->dport); 246 dport = ntohs (tm->dport);
233 if (0 == dport) 247 if (0 == dport)