aboutsummaryrefslogtreecommitdiff
path: root/src/vpn/gnunet-vpn-tun.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/vpn/gnunet-vpn-tun.c')
-rw-r--r--src/vpn/gnunet-vpn-tun.c39
1 files changed, 0 insertions, 39 deletions
diff --git a/src/vpn/gnunet-vpn-tun.c b/src/vpn/gnunet-vpn-tun.c
deleted file mode 100644
index 07def09c7..000000000
--- a/src/vpn/gnunet-vpn-tun.c
+++ /dev/null
@@ -1,39 +0,0 @@
1#include "platform.h"
2#include <linux/if_tun.h>
3
4/**
5 * Creates a tun-interface called dev;
6 * dev is asumed to point to a char[IFNAMSIZ]
7 * if *dev == 0, uses the name supplied by the kernel
8 * returns the fd to the tun or -1
9 */
10int init_tun(char *dev) {{{
11 if (!dev) {
12 errno = EINVAL;
13 return -1;
14 }
15
16 struct ifreq ifr;
17 int fd, err;
18
19 if( (fd = open("/dev/net/tun", O_RDWR)) < 0 ) {
20 fprintf(stderr, "opening /dev/net/tun: %s\n", strerror(errno));
21 return -1;
22 }
23
24 memset(&ifr, 0, sizeof(ifr));
25
26 ifr.ifr_flags = IFF_TUN;
27
28 if (*dev)
29 strncpy(ifr.ifr_name, dev, IFNAMSIZ);
30
31 if ((err = ioctl(fd, TUNSETIFF, (void *) &ifr)) < 0 ){
32 close(fd);
33 fprintf(stderr, "ioctl'ing /dev/net/tun: %s\n", strerror(errno));
34 return err;
35 }
36
37 strcpy(dev, ifr.ifr_name);
38 return fd;
39}}}