notes for next steps with NAT
authorChristian Grothoff <christian@grothoff.org>
Sun, 25 Dec 2016 18:20:16 +0000 (19:20 +0100)
committerChristian Grothoff <christian@grothoff.org>
Sun, 25 Dec 2016 18:20:16 +0000 (19:20 +0100)
src/nat/gnunet-nat-server.c
src/nat/gnunet-nat.c
src/nat/gnunet-service-nat.c

index 6722deefba0ab4716e66b71c37e017ab8df9f615..1692a8ef1bfc554547731b749799d800d0f19fa6 100644 (file)
@@ -42,8 +42,7 @@ static const struct GNUNET_CONFIGURATION_Handle *cfg;
 
 
 /**
- * Try contacting the peer using autonomous
- * NAT traveral method.
+ * Try contacting the peer using autonomous NAT traveral method.
  *
  * @param dst_ipv4 IPv4 address to send the fake ICMP message
  * @param dport destination port to include in ICMP message
@@ -78,7 +77,7 @@ try_anat (uint32_t dst_ipv4,
 
 
 /**
- * Closure for 'tcp_send'.
+ * Closure for #tcp_send.
  */
 struct TcpContext
 {
@@ -98,7 +97,7 @@ struct TcpContext
  * Task called by the scheduler once we can do the TCP send
  * (or once we failed to connect...).
  *
- * @param cls the 'struct TcpContext'
+ * @param cls the `struct TcpContext`
  */
 static void
 tcp_send (void *cls)
@@ -182,7 +181,7 @@ try_send_tcp (uint32_t dst_ipv4,
 
 /**
  * Try to send @a data to the
- * IP @a dst_ipv4' at port @a dport via UDP.
+ * IP @a dst_ipv4 at port @a dport via UDP.
  *
  * @param dst_ipv4 target IP
  * @param dport target port
@@ -313,12 +312,13 @@ run (void *cls,
   };
 
   cfg = c;
-  if ((args[0] == NULL) || (1 != SSCANF (args[0], "%u", &port)) || (0 == port)
-      || (65536 <= port))
+  if ( (NULL == args[0]) ||
+       (1 != SSCANF (args[0], "%u", &port)) ||
+       (0 == port) ||
+       (65536 <= port) )
   {
     FPRINTF (stderr,
-             _
-             ("Please pass valid port number as the first argument! (got `%s')\n"),
+             _("Please pass valid port number as the first argument! (got `%s')\n"),
              args[0]);
     return;
   }
@@ -332,10 +332,14 @@ run (void *cls,
   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);
-  GNUNET_SERVER_add_handlers (server, handlers);
+  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_shutdown (&shutdown_task,
                                 NULL);
 }
@@ -355,13 +359,19 @@ main (int argc, char *const argv[])
     GNUNET_GETOPT_OPTION_END
   };
 
-  if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
+  if (GNUNET_OK !=
+      GNUNET_STRINGS_get_utf8_args (argc, argv,
+                                   &argc, &argv))
     return 2;
 
   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))
   {
     GNUNET_free ((void*) argv);
     return 1;
index d04a9337a7cc4f2f34c176be2a6cd12877b2bd33..4d0ed572371dca0499bc09f4cb7c0a80f0bb2eba 100644 (file)
@@ -459,7 +459,7 @@ run (void *cls,
   struct sockaddr_in extern_sa;
   struct sockaddr *local_sa;
   struct sockaddr *remote_sa;
-  size_t local_len;
+  socklen_t local_len;
   size_t remote_len;
 
   cfg_file = cfgfile;
@@ -527,9 +527,9 @@ run (void *cls,
   }
   if (NULL != local_addr)
   {
-    local_len = GNUNET_STRINGS_parse_socket_addr (local_addr,
-                                                 &af,
-                                                 &local_sa);
+    local_len = (socklen_t) GNUNET_STRINGS_parse_socket_addr (local_addr,
+                                                             &af,
+                                                             &local_sa);
     if (0 == local_len)
     {
       GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
index 5b5a108eb48d0224a66007a1d0433cc9157cdb9c..762175437e3afca883a18197e8bffcfed78d1c2f 100644 (file)
  *
  * TODO:
  * - test ICMP based NAT traversal
+ * - implement "more" autoconfig:
+ *   re-work gnunet-nat-server & integrate!
  * - implement & test STUN processing to classify NAT;
  *   basically, open port & try different methods.
- * - implement "more" autoconfig
  * - implement NEW logic for external IP detection
  */
 #include "platform.h"