gnunet_vpn_helper_SOURCES = \
gnunet-vpn-helper.c \
gnunet-vpn-helper-p.h \
- tun.h tun.c
+ gnunet-vpn-tun.h gnunet-vpn-tun.c
# debug.c debug.h \
# packet.h packet.c \
#include <unistd.h>
#include "gnunet-vpn-helper-p.h"
-#include "tun.h"
+#include "gnunet-vpn-tun.h"
#ifndef _LINUX_IN6_H
// This is in linux/include/net/ipv6.h.
--- /dev/null
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/ioctl.h>
+#include <sys/stat.h>
+
+#include <linux/if.h>
+#include <linux/if_tun.h>
+
+#include <fcntl.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <stdlib.h>
+
+/**
+ * Creates a tun-interface called dev;
+ * dev is asumed to point to a char[IFNAMSIZ]
+ * if *dev == 0, uses the name supplied by the kernel
+ * returns the fd to the tun or -1
+ */
+int init_tun(char *dev) {{{
+ if (!dev) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ struct ifreq ifr;
+ int fd, err;
+
+ if( (fd = open("/dev/net/tun", O_RDWR)) < 0 ) {
+ fprintf(stderr, "opening /dev/net/tun: %m\n");
+ return -1;
+ }
+
+ memset(&ifr, 0, sizeof(ifr));
+
+ ifr.ifr_flags = IFF_TUN;
+
+ if (*dev)
+ strncpy(ifr.ifr_name, dev, IFNAMSIZ);
+
+ if ((err = ioctl(fd, TUNSETIFF, (void *) &ifr)) < 0 ){
+ close(fd);
+ fprintf(stderr, "ioctl'ing /dev/net/tun: %m\n");
+ return err;
+ }
+
+ strcpy(dev, ifr.ifr_name);
+ return fd;
+}}}
--- /dev/null
+#ifndef _GNTUN_TUN_H_
+#define _GNTUN_TUN_H_
+
+/**
+ * Creates a tun-interface called dev;
+ * if *dev == 0, uses the name supplied by the kernel
+ * returns the fd to the tun or -1
+ */
+int init_tun(char *dev);
+
+#endif
+++ /dev/null
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/ioctl.h>
-#include <sys/stat.h>
-
-#include <linux/if.h>
-#include <linux/if_tun.h>
-
-#include <fcntl.h>
-#include <unistd.h>
-#include <stdio.h>
-#include <string.h>
-#include <errno.h>
-#include <stdlib.h>
-
-/**
- * Creates a tun-interface called dev;
- * dev is asumed to point to a char[IFNAMSIZ]
- * if *dev == 0, uses the name supplied by the kernel
- * returns the fd to the tun or -1
- */
-int init_tun(char *dev) {{{
- if (!dev) {
- errno = EINVAL;
- return -1;
- }
-
- struct ifreq ifr;
- int fd, err;
-
- if( (fd = open("/dev/net/tun", O_RDWR)) < 0 ) {
- fprintf(stderr, "opening /dev/net/tun: %m\n");
- return -1;
- }
-
- memset(&ifr, 0, sizeof(ifr));
-
- ifr.ifr_flags = IFF_TUN;
-
- if (*dev)
- strncpy(ifr.ifr_name, dev, IFNAMSIZ);
-
- if ((err = ioctl(fd, TUNSETIFF, (void *) &ifr)) < 0 ){
- close(fd);
- fprintf(stderr, "ioctl'ing /dev/net/tun: %m\n");
- return err;
- }
-
- strcpy(dev, ifr.ifr_name);
- return fd;
-}}}
+++ /dev/null
-#ifndef _GNTUN_TUN_H_
-#define _GNTUN_TUN_H_
-
-/**
- * Creates a tun-interface called dev;
- * if *dev == 0, uses the name supplied by the kernel
- * returns the fd to the tun or -1
- */
-int init_tun(char *dev);
-
-#endif