ntop / n2n

Peer-to-peer VPN
GNU General Public License v3.0
6.14k stars 928 forks source link

Solaris (Openindiana) n2n tools Makefile does not take LD flags from main Makefile #1069

Closed benf33 closed 1 year ago

benf33 commented 1 year ago

on SunOS 5.11, when you run a configure, main Makefile contains the following :

#For OpenSolaris (Solaris too?)                                                                                                                                                                                     
ifeq ($(shell uname), SunOS)                                                                                                                                                                                        
LIBS_EDGE+=-lsocket -lnsl                                                                                                                                                                                           
LIBS_SN+=-lsocket -lnsl                                                                                                                                                                                             
endif

but the tools/Makefile does not contains this block and thus does not link properly : build fails. Adding the block manually to tools/Makefile allow to compile.

benf33 commented 1 year ago

Full patch (created with git diff) to compile under Openindiana is the following.

diff --git a/n2n.h b/n2n.h
index e5018db..9a31b29 100644
--- a/n2n.h
+++ b/n2n.h
@@ -82,6 +82,16 @@
 #include <netinet/in_systm.h>
 #endif /* #ifdef __FreeBSD__ */

+#if (__sun && __SVR4)
+#include <inttypes.h>
+typedef uint8_t  u_int8_t;
+typedef uint16_t u_int16_t;
+typedef uint32_t u_int32_t;
+typedef uint64_t u_int64_t;
+#define MAX(a,b) (a > b ? a : b)
+#define MIN(a,b) (a < b ? a : b)
+#endif
+
 #include <syslog.h>
 #include <sys/wait.h>

diff --git a/tools/Makefile.in b/tools/Makefile.in
index bcb3e02..eae7f74 100644
--- a/tools/Makefile.in
+++ b/tools/Makefile.in
@@ -14,6 +14,12 @@ else
 SBINDIR=$(PREFIX)/sbin
 endif

+#For OpenSolaris (Solaris too?)
+ifeq ($(shell uname), SunOS)
+LIBS_EDGE+=-lsocket -lnsl
+LIBS_SN+=-lsocket -lnsl
+endif
+
 LIBS_EDGE_OPT=@N2N_LIBS@
 LIBS_EDGE+=$(LIBS_EDGE_OPT)
 HEADERS=../n2n_wire.h ../n2n.h ../twofish.h ../n2n_transforms.h
diff --git a/tuntap_freebsd.c b/tuntap_freebsd.c
index 7404c95..4b1de2c 100644
--- a/tuntap_freebsd.c
+++ b/tuntap_freebsd.c
@@ -18,7 +18,7 @@

 #include "n2n.h"

-#ifdef __FreeBSD__
+#if defined __FreeBSD__ || defined __sun

 void tuntap_close(tuntap_dev *device);

It is rough, I know. You may want to rework the merge of SunOS into tuntap_freebsd.c (create a tuntap_sunos.c ?) I don't know where you pull the MIN/MAX functions from on linux so I had to define them, you may want to relocate that in the proper section of the code. I am quite surprised to find section related to solaris in the Makefile.in but the code misses anything related to that OS.

benf33 commented 1 year ago

Discard this issue as the n2n version I was working on was not up to date.