#include "gnunet_protocols.h"
#include "nat.h"
-#define DEBUG_NAT GNUNET_NO
/**
* Our server.
*/
struct GNUNET_NETWORK_Handle *s;
- /**
+ /**
* Data to transmit.
*/
uint16_t data;
* Task called by the scheduler once we can do the TCP send
* (or once we failed to connect...).
*
- * @param ctx the 'struct TcpContext'
+ * @param cls the 'struct TcpContext'
* @param tc scheduler context
*/
static void
/**
* Try to send 'data' to the
* IP 'dst_ipv4' at port 'dport' via TCP.
- *
- * @param dst_ivp4 target IP
+ *
+ * @param dst_ipv4 target IP
* @param dport target port
* @param data data to send
*/
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_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,
+ GNUNET_NETWORK_socket_connect (s, (const struct sockaddr *) &sa,
sizeof (sa))) && (errno != EINPROGRESS))
{
GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "connect");
/**
* Try to send 'data' to the
* IP 'dst_ipv4' at port 'dport' via UDP.
- *
- * @param dst_ivp4 target IP
+ *
+ * @param dst_ipv4 target IP
* @param dport target port
* @param data data to send
*/
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_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)))
+ if (-1 ==
+ GNUNET_NETWORK_socket_sendto (s, &data, sizeof (data),
+ (const struct sockaddr *) &sa, sizeof (sa)))
GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "sendto");
GNUNET_NETWORK_socket_close (s);
}
/**
* We've received a request to probe a NAT
* traversal. Do it.
- *
+ *
* @param cls unused
* @param client handle to client (we always close)
* @param msg message with details about what to test
*/
static void
-test (void *cls,
- struct GNUNET_SERVER_Client *client,
+test (void *cls, struct GNUNET_SERVER_Client *client,
const struct GNUNET_MessageHeader *msg)
{
const struct GNUNET_NAT_TestMessage *tm;
/**
* Task run during shutdown.
*
- * @param ctx unused
+ * @param cls unused
* @param tc scheduler context
*/
static void
* @param c configuration
*/
static void
-run (void *cls,
- char *const *args,
- const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c)
+run (void *cls, char *const *args, const char *cfgfile,
+ const struct GNUNET_CONFIGURATION_Handle *c)
{
static const struct GNUNET_SERVER_MessageHandler handlers[] = {
{&test, NULL, GNUNET_MESSAGE_TYPE_NAT_TEST,
};
cfg = c;
- if ((args[0] == NULL) ||
- (1 != SSCANF (args[0], "%u", &port)) || (0 == port) || (65536 <= port))
+ if ((args[0] == NULL) || (1 != SSCANF (args[0], "%u", &port)) || (0 == port)
+ || (65536 <= port))
{
- fprintf (stderr,
+ FPRINTF (stderr,
_
("Please pass valid port number as the first argument! (got `%s')\n"),
args[0]);
in4.sin_len = sizeof (in4);
in6.sin6_len = sizeof (in6);
#endif
- server = GNUNET_SERVER_create (NULL, NULL,
- (struct sockaddr * const *) sa,
- slen, GNUNET_TIME_UNIT_SECONDS, GNUNET_YES);
+ server =
+ GNUNET_SERVER_create (NULL, NULL, (struct sockaddr * const *) sa, slen,
+ GNUNET_TIME_UNIT_SECONDS, GNUNET_YES);
GNUNET_SERVER_add_handlers (server, handlers);
- GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
- &shutdown_task, NULL);
+ GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task,
+ NULL);
}
};
if (GNUNET_OK !=
- GNUNET_PROGRAM_run (argc, argv,
- "gnunet-nat-server [options] PORT",
- _("GNUnet NAT traversal test helper daemon"),
- options, &run, NULL))
+ GNUNET_PROGRAM_run (argc, argv, "gnunet-nat-server [options] PORT",
+ _("GNUnet NAT traversal test helper daemon"), options,
+ &run, NULL))
return 1;
return 0;
}