diff options
author | ng0 <ng0@n0.is> | 2019-11-22 23:38:31 +0000 |
---|---|---|
committer | ng0 <ng0@n0.is> | 2019-11-22 23:38:31 +0000 |
commit | 00ddb1c1d483f8d870ed2293bf14da6b7b9259a1 (patch) | |
tree | 50e3d10bb95f99e1f9c63a85df5c548e4af6e113 /src/exit | |
parent | f4690d7c8e707e4777eac03f7410337b9f26df30 (diff) | |
download | gnunet-00ddb1c1d483f8d870ed2293bf14da6b7b9259a1.tar.gz gnunet-00ddb1c1d483f8d870ed2293bf14da6b7b9259a1.zip |
exit: initial (very rough, builds) *BSD support - to the point
where the Linux specific binaries would still be used, thus marked
as experimental.
Diffstat (limited to 'src/exit')
-rw-r--r-- | src/exit/Makefile.am | 6 | ||||
-rw-r--r-- | src/exit/gnunet-helper-exit.c | 38 |
2 files changed, 43 insertions, 1 deletions
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 = \ | |||
17 | if LINUX | 17 | if LINUX |
18 | EXITBIN = gnunet-helper-exit | 18 | EXITBIN = gnunet-helper-exit |
19 | endif | 19 | endif |
20 | # For testing purposes: | ||
21 | if HAVE_EXPERIMENTAL | ||
22 | if XBSD | ||
23 | EXITBIN = gnunet-helper-exit | ||
24 | endif | ||
25 | endif | ||
20 | 26 | ||
21 | 27 | ||
22 | libexec_PROGRAMS = \ | 28 | 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 @@ | |||
42 | * - Philipp Tölke | 42 | * - Philipp Tölke |
43 | */ | 43 | */ |
44 | #include "platform.h" | 44 | #include "platform.h" |
45 | #include <linux/if_tun.h> | 45 | |
46 | #ifdef IF_TUN_HDR | ||
47 | #include IF_TUN_HDR | ||
48 | #endif | ||
49 | |||
50 | #if defined(BSD) || defined(SOLARIS) | ||
51 | #define ifr_netmask ifr_ifru.ifru_addr | ||
52 | #define SIOGIFINDEX SIOCGIFINDEX | ||
53 | #endif | ||
46 | 54 | ||
47 | /** | 55 | /** |
48 | * Need 'struct GNUNET_MessageHeader'. | 56 | * Need 'struct GNUNET_MessageHeader'. |
@@ -182,6 +190,7 @@ fork_and_exec (const char *file, | |||
182 | * if *dev == '\\0', uses the name supplied by the kernel; | 190 | * if *dev == '\\0', uses the name supplied by the kernel; |
183 | * @return the fd to the tun or -1 on error | 191 | * @return the fd to the tun or -1 on error |
184 | */ | 192 | */ |
193 | #ifdef IFF_TUN /* LINUX */ | ||
185 | static int | 194 | static int |
186 | init_tun (char *dev) | 195 | init_tun (char *dev) |
187 | { | 196 | { |
@@ -225,7 +234,34 @@ init_tun (char *dev) | |||
225 | strcpy (dev, ifr.ifr_name); | 234 | strcpy (dev, ifr.ifr_name); |
226 | return fd; | 235 | return fd; |
227 | } | 236 | } |
237 | #else /* BSD et al, including DARWIN */ | ||
228 | 238 | ||
239 | #ifdef SIOCIFCREATE | ||
240 | static int | ||
241 | init_tun(char *dev) | ||
242 | { | ||
243 | int fd; | ||
244 | int s; | ||
245 | struct ifreq ifr; | ||
246 | |||
247 | fd = open(dev, O_RDWR); | ||
248 | if(fd == -1) | ||
249 | { | ||
250 | s = socket(AF_INET, SOCK_DGRAM, 0); | ||
251 | if (s < 0) | ||
252 | return -1; | ||
253 | memset(&ifr, 0, sizeof(ifr)); | ||
254 | strncpy(ifr.ifr_name, dev + 5, sizeof(ifr.ifr_name) - 1); | ||
255 | if (!ioctl(s, SIOCIFCREATE, &ifr)) | ||
256 | fd = open(dev, O_RDWR); | ||
257 | close(s); | ||
258 | } | ||
259 | return fd; | ||
260 | } | ||
261 | #else | ||
262 | #define init_tun(dev) open(dev, O_RDWR) | ||
263 | #endif | ||
264 | #endif /* !IFF_TUN (BSD) */ | ||
229 | 265 | ||
230 | /** | 266 | /** |
231 | * @brief Sets the IPv6-Address given in address on the interface dev | 267 | * @brief Sets the IPv6-Address given in address on the interface dev |