X-Git-Url: https://tinc-vpn.org/git/browse?a=blobdiff_plain;f=src%2Flinux%2Fdevice.c;h=519896e71c4e513d1559d12ef48a7bfce5b53b71;hb=f02d3ed3e135b5326003e7f69f8331ff6a3cc219;hp=3af8df09dc483c4cce869c9db0755d4d0555e639;hpb=0322c0883b76257c0893aa75a510e264056ac15b;p=tinc diff --git a/src/linux/device.c b/src/linux/device.c index 3af8df09..519896e7 100644 --- a/src/linux/device.c +++ b/src/linux/device.c @@ -22,8 +22,12 @@ #include "system.h" +#ifdef HAVE_LINUX_IF_TUN_H #include #define DEFAULT_DEVICE "/dev/net/tun" +#else +#define DEFAULT_DEVICE "/dev/tap0" +#endif #include "conf.h" #include "logger.h" @@ -47,8 +51,7 @@ char *device_info; static int device_total_in = 0; static int device_total_out = 0; -bool setup_device(void) -{ +bool setup_device(void) { struct ifreq ifr; cp(); @@ -57,7 +60,7 @@ bool setup_device(void) device = DEFAULT_DEVICE; if(!get_config_string(lookup_config(config_tree, "Interface"), &iface)) -#ifdef HAVE_TUNTAP +#ifdef HAVE_LINUX_IF_TUN_H iface = netname; #else iface = rindex(device, '/') ? rindex(device, '/') + 1 : device; @@ -69,7 +72,7 @@ bool setup_device(void) return false; } -#ifdef HAVE_TUNTAP +#ifdef HAVE_LINUX_IF_TUN_H /* Ok now check if this is an old ethertap or a new tun/tap thingie */ memset(&ifr, 0, sizeof(ifr)); @@ -108,15 +111,13 @@ bool setup_device(void) return true; } -void close_device(void) -{ +void close_device(void) { cp(); close(device_fd); } -bool read_packet(vpn_packet_t *packet) -{ +bool read_packet(vpn_packet_t *packet) { int lenin; cp(); @@ -165,8 +166,7 @@ bool read_packet(vpn_packet_t *packet) return true; } -bool write_packet(vpn_packet_t *packet) -{ +bool write_packet(vpn_packet_t *packet) { cp(); ifdebug(TRAFFIC) logger(LOG_DEBUG, _("Writing packet of %d bytes to %s"), @@ -204,8 +204,7 @@ bool write_packet(vpn_packet_t *packet) return true; } -void dump_device_stats(void) -{ +void dump_device_stats(void) { cp(); logger(LOG_DEBUG, _("Statistics for %s %s:"), device_info, device);