ensure nat clients get notifications on disconnect about 'lost' addresses
authorChristian Grothoff <christian@grothoff.org>
Sun, 25 Dec 2016 17:35:15 +0000 (18:35 +0100)
committerChristian Grothoff <christian@grothoff.org>
Sun, 25 Dec 2016 17:35:15 +0000 (18:35 +0100)
doc/man/gnunet-nat.1
src/nat/gnunet-service-nat.c
src/nat/nat_api.c

index 484537eb03fad879df60d5f59967e0189e9c718f..2ba2363998ae8e8f7016e76348edfb42086e1b4a 100644 (file)
@@ -67,7 +67,7 @@ Watch for connection reversal requests.
 
 \fBBasic examples\fR
 
-We are bound to "0.0.0.0:8080" on UDP and want to obtain all applicable IP addresses (BUG: sometimes upnpc fails to create mapping, cause unclear):
+We are bound to "0.0.0.0:8080" on UDP and want to obtain all applicable IP addresses:
 
   # gnunet-nat -i 0.0.0.0:8080 -u
 
@@ -75,7 +75,7 @@ We are bound to "::0" on port 8080 on TCP and want to obtain all applicable IP a
 
   # gnunet-nat -i '[::0]':8080 -t
 
-We are bound to "127.0.0.1:8080" on UDP and want to obtain all applicable IP addresses (BUG: currently fails, also gives IPs from other interfaces in output!):
+We are bound to "127.0.0.1:8080" on UDP and want to obtain all applicable IP addresses:
 
   # gnunet-nat -i 127.0.0.1:8080 -u
 
index e7173e57ad01748ebaae36e555d37c6fafbeb6d8..5b5a108eb48d0224a66007a1d0433cc9157cdb9c 100644 (file)
@@ -28,8 +28,8 @@
  * knowledge about the local network topology.
  *
  * TODO:
- * - TEST UPnPC/PMP-based NAT traversal
- * - implement STUN processing to classify NAT;
+ * - test ICMP based NAT traversal
+ * - implement & test STUN processing to classify NAT;
  *   basically, open port & try different methods.
  * - implement "more" autoconfig
  * - implement NEW logic for external IP detection
index 3fe97ed85108b198dc32c719054adf72af6c0f0b..481bc6fded54b95ada0476ca93b7542926f97b00 100644 (file)
@@ -48,6 +48,11 @@ struct AddrEntry
    */
   struct AddrEntry *prev;
 
+  /**
+   * Address class of the address.
+   */
+  enum GNUNET_NAT_AddressClass ac;
+  
   /**
    * Number of bytes that follow.
    */
@@ -130,11 +135,25 @@ do_connect (void *cls);
 static void
 reconnect (struct GNUNET_NAT_Handle *nh)
 {
+  struct AddrEntry *ae;
+  
   if (NULL != nh->mq)
   {
     GNUNET_MQ_destroy (nh->mq);
     nh->mq = NULL;
   }
+  while (NULL != (ae = nh->ae_head))
+  {
+    GNUNET_CONTAINER_DLL_remove (nh->ae_head,
+                                nh->ae_tail,
+                                ae);
+    nh->address_callback (nh->callback_cls,
+                         GNUNET_NO,
+                         ae->ac,
+                         (const struct sockaddr *) &ae[1],
+                         ae->addrlen);
+    GNUNET_free (ae);
+  }
   nh->reconnect_delay
     = GNUNET_TIME_STD_BACKOFF (nh->reconnect_delay);
   nh->reconnect_task
@@ -260,6 +279,7 @@ handle_address_change_notification (void *cls,
   if (GNUNET_YES == ntohl (acn->add_remove))
   {
     ae = GNUNET_malloc (sizeof (*ae) + alen);
+    ae->ac = ac;
     ae->addrlen = alen;
     GNUNET_memcpy (&ae[1],
                   sa,