View Issue Details

IDProjectCategoryView StatusLast Update
0001625GNUnetNAT traversal librarypublic2011-09-19 10:45
ReporterLRN Assigned Tomilan  
PriorityhighSeverityblockReproducibilityalways
Status closedResolutionfixed 
Summary0001625: Broken includes in src/nat
Description"$(top_srcdir)/include" resolves into "/include" for me, which means including MSys headers, which are designed for different compiler version and environment.
TagsNo tags attached.
Attached Files
0001-Fix-include-path-and-include-order-in-src-nat.patch (1,191 bytes)   
From e54c5b02bc34c0fab5d36f6bde06d47d7e0943f7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=D0=A0=D1=83=D1=81=D0=BB=D0=B0=D0=BD=20=D0=98=D0=B6=D0=B1=D1=83=D0=BB=D0=B0=D1=82=D0=BE=D0=B2?= <lrn1986@gmail.com>
Date: Wed, 1 Dec 2010 08:19:39 +0300
Subject: [PATCH] Fix include path and include order in src/nat

---
 src/nat/Makefile.am |    1 -
 src/nat/upnp.c      |    5 +++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/nat/Makefile.am b/src/nat/Makefile.am
index 50edd5f..af06528 100644
--- a/src/nat/Makefile.am
+++ b/src/nat/Makefile.am
@@ -20,7 +20,6 @@ libgnunetnat_la_SOURCES = \
   nat.c 
 
 libgnunetnat_la_CFLAGS = \
- -I$(top_scrdir)/include \
  -DDEBUG_UPNP -g -O0
 
 libgnunetnat_la_LIBADD = \
diff --git a/src/nat/upnp.c b/src/nat/upnp.c
index 23168d2..4435741 100644
--- a/src/nat/upnp.c
+++ b/src/nat/upnp.c
@@ -30,13 +30,14 @@
  *
  * @author Milan Bouchet-Valat
  */
+#include "platform.h"
+#include "gnunet_common.h"
+
 #include <stdlib.h>
 #include <assert.h>
 #include <errno.h>
 #include <string.h>
 
-#include "platform.h"
-#include "gnunet_common.h"
 #include "gnunet_nat_lib.h"
 #include "nat.h"
 #include "upnp-discover.h"
-- 
1.7.3.1.msysgit.0

0001-Fix-W32-interface-listing-and-nat_test.patch (1,799 bytes)   
From 63728d1e8806cdb9352f3dd1685d5ddf6ffa1836 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=D0=A0=D1=83=D1=81=D0=BB=D0=B0=D0=BD=20=D0=98=D0=B6=D0=B1=D1=83=D0=BB=D0=B0=D1=82=D0=BE=D0=B2?= <lrn1986@gmail.com>
Date: Thu, 2 Dec 2010 21:27:35 +0300
Subject: [PATCH] Fix W32 interface listing, and nat_test

---
 src/nat/test_nat.c    |   16 ++++------------
 src/util/os_network.c |    4 ++--
 2 files changed, 6 insertions(+), 14 deletions(-)

diff --git a/src/nat/test_nat.c b/src/nat/test_nat.c
index 6f22269..b305196 100644
--- a/src/nat/test_nat.c
+++ b/src/nat/test_nat.c
@@ -76,22 +76,14 @@ process_if (void *cls,
 {
   struct addr_cls *data = cls;
 
-  if (addr)
+  if (addr && addrlen > 0)
     {
-      data->addr = addr;
+      data->addr = memcpy (GNUNET_malloc (addrlen), addr, addrlen);
       data->addrlen = addrlen;
+      if (isDefault)
+        return GNUNET_SYSERR;
     }
-
-  if (strcmp (name, "eth1") == 0 && addr->sa_family == AF_INET)
-    return GNUNET_SYSERR;
-
   return GNUNET_OK;
-
-
-  if (isDefault && addr)
-    return GNUNET_SYSERR;
-  else
-    return GNUNET_OK;
 }
 
 static void
diff --git a/src/util/os_network.c b/src/util/os_network.c
index 453eea6..498f6ac 100644
--- a/src/util/os_network.c
+++ b/src/util/os_network.c
@@ -153,9 +153,9 @@ GNUNET_OS_network_interfaces_list (GNUNET_OS_NetworkInterfaceProcessor proc,
               if (GNUNET_OK !=
                   proc (proc_cls,
                         szEntry,
-                        pAddrTable->table[dwIfIdx].dwIndex == dwExternalNIC,
+                        pTable->table[dwIfIdx].dwIndex == dwExternalNIC,
                         (const struct sockaddr *) &sa,
-                        0))
+                        sizeof (sa)))
                 break;
             }
         }
-- 
1.7.3.1.msysgit.0

0001-Fix-W32-interface-listing-and-nat_test-v2.patch (1,864 bytes)   
From dc82ca9d80a66ac815706dd216db369f74e369f5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=D0=A0=D1=83=D1=81=D0=BB=D0=B0=D0=BD=20=D0=98=D0=B6=D0=B1=D1=83=D0=BB=D0=B0=D1=82=D0=BE=D0=B2?= <lrn1986@gmail.com>
Date: Thu, 2 Dec 2010 21:39:50 +0300
Subject: [PATCH] Fix W32 interface listing, and nat_test (v2)

---
 src/nat/test_nat.c    |   18 ++++++------------
 src/util/os_network.c |    4 ++--
 2 files changed, 8 insertions(+), 14 deletions(-)

diff --git a/src/nat/test_nat.c b/src/nat/test_nat.c
index 6f22269..dba4a40 100644
--- a/src/nat/test_nat.c
+++ b/src/nat/test_nat.c
@@ -76,22 +76,16 @@ process_if (void *cls,
 {
   struct addr_cls *data = cls;
 
-  if (addr)
+  if (addr && addrlen > 0)
     {
-      data->addr = addr;
+      if (data->addr)
+        GNUNET_free (data->addr);
+      data->addr = memcpy (GNUNET_malloc (addrlen), addr, addrlen);
       data->addrlen = addrlen;
+      if (isDefault)
+        return GNUNET_SYSERR;
     }
-
-  if (strcmp (name, "eth1") == 0 && addr->sa_family == AF_INET)
-    return GNUNET_SYSERR;
-
   return GNUNET_OK;
-
-
-  if (isDefault && addr)
-    return GNUNET_SYSERR;
-  else
-    return GNUNET_OK;
 }
 
 static void
diff --git a/src/util/os_network.c b/src/util/os_network.c
index 453eea6..498f6ac 100644
--- a/src/util/os_network.c
+++ b/src/util/os_network.c
@@ -153,9 +153,9 @@ GNUNET_OS_network_interfaces_list (GNUNET_OS_NetworkInterfaceProcessor proc,
               if (GNUNET_OK !=
                   proc (proc_cls,
                         szEntry,
-                        pAddrTable->table[dwIfIdx].dwIndex == dwExternalNIC,
+                        pTable->table[dwIfIdx].dwIndex == dwExternalNIC,
                         (const struct sockaddr *) &sa,
-                        0))
+                        sizeof (sa)))
                 break;
             }
         }
-- 
1.7.3.1.msysgit.0

Activities

milan

2010-12-02 14:31

reporter   ~0004195

I don't know where I found this
-I$(top_scrdir)/include \
line, but it's clearly wrong, since includes are set at the top of the file via the INCLUDES variable. Anyway path to includes should be $(top_scrdir)/src/include.

So patch is OK AFAIK.

LRN

2010-12-02 19:36

reporter   ~0004196

Uploaded 0001-Fix-W32-interface-listing-and-nat_test.patch - further fixes for nat test.

LRN

2010-12-02 19:41

reporter   ~0004197

Uploaded 0001-Fix-W32-interface-listing-and-nat_test-v2.patch, which fixes a small memory leak (not really critical, since this is a testcase, not a real application).

milan

2010-12-03 20:09

reporter   ~0004198

I committed both patches in revisions 13876 and 13877. (Second patch with a small fix to remove the const keyword for the address in the closure.)

Issue History

Date Modified Username Field Change
2010-12-01 06:22 LRN New Issue
2010-12-01 06:22 LRN File Added: 0001-Fix-include-path-and-include-order-in-src-nat.patch
2010-12-02 14:31 milan Note Added: 0004195
2010-12-02 19:36 LRN File Added: 0001-Fix-W32-interface-listing-and-nat_test.patch
2010-12-02 19:36 LRN Note Added: 0004196
2010-12-02 19:40 LRN File Added: 0001-Fix-W32-interface-listing-and-nat_test-v2.patch
2010-12-02 19:41 LRN Note Added: 0004197
2010-12-03 20:09 milan Note Added: 0004198
2010-12-03 20:09 milan Status new => resolved
2010-12-03 20:09 milan Fixed in Version => Git master
2010-12-03 20:09 milan Resolution open => fixed
2010-12-03 20:09 milan Assigned To => milan
2010-12-23 23:50 Christian Grothoff Status resolved => closed
2011-09-19 10:45 Christian Grothoff Fixed in Version Git master => 0.9.0pre3
2011-09-19 10:45 Christian Grothoff Target Version => 0.9.0pre3