[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnunet] 02/03: exit: initial (very rough, builds) *BSD support - to the
From: |
gnunet |
Subject: |
[gnunet] 02/03: exit: initial (very rough, builds) *BSD support - to the point where the Linux specific binaries would still be used, thus marked as experimental. |
Date: |
Sat, 23 Nov 2019 00:43:45 +0100 |
This is an automated email from the git hooks/post-receive script.
ng0 pushed a commit to branch master
in repository gnunet.
commit 00ddb1c1d483f8d870ed2293bf14da6b7b9259a1
Author: ng0 <address@hidden>
AuthorDate: Fri Nov 22 23:38:31 2019 +0000
exit: initial (very rough, builds) *BSD support - to the point
where the Linux specific binaries would still be used, thus marked
as experimental.
---
src/exit/Makefile.am | 6 ++++++
src/exit/gnunet-helper-exit.c | 38 +++++++++++++++++++++++++++++++++++++-
2 files changed, 43 insertions(+), 1 deletion(-)
diff --git a/src/exit/Makefile.am b/src/exit/Makefile.am
index c0323d0d6..811761ed0 100644
--- a/src/exit/Makefile.am
+++ b/src/exit/Makefile.am
@@ -17,6 +17,12 @@ dist_pkgcfg_DATA = \
if LINUX
EXITBIN = gnunet-helper-exit
endif
+# For testing purposes:
+if HAVE_EXPERIMENTAL
+if XBSD
+EXITBIN = gnunet-helper-exit
+endif
+endif
libexec_PROGRAMS = \
diff --git a/src/exit/gnunet-helper-exit.c b/src/exit/gnunet-helper-exit.c
index cf322725d..9d20a0c50 100644
--- a/src/exit/gnunet-helper-exit.c
+++ b/src/exit/gnunet-helper-exit.c
@@ -42,7 +42,15 @@
* - Philipp Tölke
*/
#include "platform.h"
-#include <linux/if_tun.h>
+
+#ifdef IF_TUN_HDR
+#include IF_TUN_HDR
+#endif
+
+#if defined(BSD) || defined(SOLARIS)
+#define ifr_netmask ifr_ifru.ifru_addr
+#define SIOGIFINDEX SIOCGIFINDEX
+#endif
/**
* Need 'struct GNUNET_MessageHeader'.
@@ -182,6 +190,7 @@ fork_and_exec (const char *file,
* if *dev == '\\0', uses the name supplied by the kernel;
* @return the fd to the tun or -1 on error
*/
+#ifdef IFF_TUN /* LINUX */
static int
init_tun (char *dev)
{
@@ -225,7 +234,34 @@ init_tun (char *dev)
strcpy (dev, ifr.ifr_name);
return fd;
}
+#else /* BSD et al, including DARWIN */
+#ifdef SIOCIFCREATE
+static int
+init_tun(char *dev)
+{
+ int fd;
+ int s;
+ struct ifreq ifr;
+
+ fd = open(dev, O_RDWR);
+ if(fd == -1)
+ {
+ s = socket(AF_INET, SOCK_DGRAM, 0);
+ if (s < 0)
+ return -1;
+ memset(&ifr, 0, sizeof(ifr));
+ strncpy(ifr.ifr_name, dev + 5, sizeof(ifr.ifr_name) - 1);
+ if (!ioctl(s, SIOCIFCREATE, &ifr))
+ fd = open(dev, O_RDWR);
+ close(s);
+ }
+ return fd;
+}
+#else
+#define init_tun(dev) open(dev, O_RDWR)
+#endif
+#endif /* !IFF_TUN (BSD) */
/**
* @brief Sets the IPv6-Address given in address on the interface dev
--
To stop receiving notification emails like this one, please contact
address@hidden.