gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] [gnunet] 04/05: moving basic logic for launching nat-client


From: gnunet
Subject: [GNUnet-SVN] [gnunet] 04/05: moving basic logic for launching nat-client helper to new NAT service
Date: Wed, 30 Nov 2016 11:14:10 +0100

This is an automated email from the git hooks/post-receive script.

grothoff pushed a commit to branch master
in repository gnunet.

commit 738cbe38dec2f275994c822631bf3aba02a6e6d0
Author: Christian Grothoff <address@hidden>
AuthorDate: Wed Nov 30 08:22:59 2016 +0100

    moving basic logic for launching nat-client helper to new NAT service
---
 src/nat/gnunet-service-nat_helper.c | 65 +++++++++++++++++++++++++++++++++++++
 src/nat/gnunet-service-nat_helper.h | 15 +++++++++
 2 files changed, 80 insertions(+)

diff --git a/src/nat/gnunet-service-nat_helper.c 
b/src/nat/gnunet-service-nat_helper.c
index 4867f56..e476da1 100644
--- a/src/nat/gnunet-service-nat_helper.c
+++ b/src/nat/gnunet-service-nat_helper.c
@@ -342,4 +342,69 @@ GN_stop_gnunet_nat_server_ (struct HelperContext *h)
   GNUNET_free (h);
 }
 
+
+/**
+ * We want to connect to a peer that is behind NAT.  Run the
+ * gnunet-helper-nat-client to send dummy ICMP responses to cause
+ * that peer to connect to us (connection reversal).
+ *
+ * @param internal_address out internal address to use
+ * @param sa the address of the peer (IPv4-only)
+ * @return #GNUNET_SYSERR on error,
+ *         #GNUNET_OK otherwise
+ */
+int
+GN_request_connection_reversal (const char *internal_address,
+                               const struct sockaddr_in *sa)
+{
+  char inet4[INET_ADDRSTRLEN];
+  char port_as_string[6];
+  struct GNUNET_OS_Process *proc;
+  char *binary;
+
+  GNUNET_assert (sa->sin_family == AF_INET);
+  if (NULL == inet_ntop (AF_INET,
+                        &sa->sin_addr,
+                        inet4,
+                        INET_ADDRSTRLEN))
+  {
+    GNUNET_log_from_strerror (GNUNET_ERROR_TYPE_WARNING,
+                              "nat",
+                              "inet_ntop");
+    return GNUNET_SYSERR;
+  }
+  GNUNET_snprintf (port_as_string,
+                   sizeof (port_as_string),
+                   "%d",
+                   ntohs (sa->sin_port));
+  LOG (GNUNET_ERROR_TYPE_DEBUG,
+       _("Running gnunet-helper-nat-client %s %s %u\n"),
+       internal_address,
+       inet4,
+       ntohs (sa->sin_port));
+  binary
+    = GNUNET_OS_get_libexec_binary_path ("gnunet-helper-nat-client");
+  proc
+    = GNUNET_OS_start_process (GNUNET_NO,
+                              0,
+                              NULL,
+                              NULL,
+                              NULL,
+                               binary,
+                               "gnunet-helper-nat-client",
+                               internal_address,
+                               inet4,
+                              port_as_string,
+                              NULL);
+  GNUNET_free (binary);
+  if (NULL == proc)
+    return GNUNET_SYSERR;
+  /* we know that the gnunet-helper-nat-client will terminate virtually
+   * instantly */
+  GNUNET_OS_process_wait (proc);
+  GNUNET_OS_process_destroy (proc);
+  return GNUNET_OK;
+}
+
+
 /* end of gnunet-service-nat_helper.c */
diff --git a/src/nat/gnunet-service-nat_helper.h 
b/src/nat/gnunet-service-nat_helper.h
index c3074d9..861d62c 100644
--- a/src/nat/gnunet-service-nat_helper.h
+++ b/src/nat/gnunet-service-nat_helper.h
@@ -71,4 +71,19 @@ void
 GN_stop_gnunet_nat_server_ (struct HelperContext *h);
 
 
+/**
+ * We want to connect to a peer that is behind NAT.  Run the
+ * gnunet-helper-nat-client to send dummy ICMP responses to cause
+ * that peer to connect to us (connection reversal).
+ *
+ * @param internal_address out internal address to use
+ * @param sa the address of the peer (IPv4-only)
+ * @return #GNUNET_SYSERR on error,
+ *         #GNUNET_OK otherwise
+ */
+int
+GN_request_connection_reversal (const char *internal_address,
+                               const struct sockaddr_in *sa);
+
+
 /* end of gnunet-service-nat_helper.h */

-- 
To stop receiving notification emails like this one, please contact
address@hidden



reply via email to

[Prev in Thread] Current Thread [Next in Thread]