gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] [gnunet] branch master updated: finish external-ip client n


From: gnunet
Subject: [GNUnet-SVN] [gnunet] branch master updated: finish external-ip client notification, but not yet tested
Date: Sat, 17 Dec 2016 09:09:06 +0100

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

grothoff pushed a commit to branch master
in repository gnunet.

The following commit(s) were added to refs/heads/master by this push:
     new 6c60f59  finish external-ip client notification, but not yet tested
6c60f59 is described below

commit 6c60f595b5bd12945dfcb19141129e8842a09e24
Author: Christian Grothoff <address@hidden>
AuthorDate: Sat Dec 17 09:08:53 2016 +0100

    finish external-ip client notification, but not yet tested
---
 src/nat/gnunet-service-nat.c | 32 +++++++++++++++++++++++++-------
 1 file changed, 25 insertions(+), 7 deletions(-)

diff --git a/src/nat/gnunet-service-nat.c b/src/nat/gnunet-service-nat.c
index bf82ce7..215c421 100644
--- a/src/nat/gnunet-service-nat.c
+++ b/src/nat/gnunet-service-nat.c
@@ -769,23 +769,41 @@ check_notify_client_external_ipv4_change (const struct 
in_addr *v4,
                                          int add)
 {
   struct sockaddr_in sa;
+  uint16_t port;
+  uint16_t bport;
 
-  // FIXME: (1) check if client cares;
-  GNUNET_break (0); // FIXME: implement!
+  /* (1) check if client cares. */
+  if (! ch->natted_address)
+    return;
+  if (0 == (GNUNET_NAT_RF_ADDRESSES & ch->flags))
+    return;
+  bport = 0;
+  for (unsigned int i=0;i<ch->num_addrs;i++)
+  {
+    const struct sockaddr *sa = ch->addrs[i];
+
+    if (AF_INET != sa->sa_family)
+      continue;
+    bport = ntohs (((const struct sockaddr_in *) sa)->sin_port);
+  }
+  if (0 == bport)
+    return; /* IPv6-only */
   
   /* (2) figure out external port, build sockaddr */
+  port = ch->adv_port;
+  if (0 == port)
+    port = bport;
   memset (&sa,
          0,
          sizeof (sa));
   sa.sin_family = AF_INET;
   sa.sin_addr = *v4;
-  sa.sin_port = 42; // FIXME
+  sa.sin_port = htons (port);
   
   /* (3) notify client of change */
-
-  // FIXME: handle case where 'v4' is still in the NAT range
-  // (in case of double-NAT!)
-  notify_client (GNUNET_NAT_AC_GLOBAL_EXTERN,
+  notify_client (is_nat_v4 (v4)
+                ? GNUNET_NAT_AC_LAN_PRIVATE
+                : GNUNET_NAT_AC_GLOBAL_EXTERN,
                 ch,
                 add,
                 &sa,

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



reply via email to

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