X-Git-Url: https://tinc-vpn.org/git/browse?a=blobdiff_plain;f=src%2Flinux%2Fdevice.c;h=519896e71c4e513d1559d12ef48a7bfce5b53b71;hb=f02d3ed3e135b5326003e7f69f8331ff6a3cc219;hp=75e771598077a6255e6dbe53b0840514f2250dba;hpb=df3220a1549f992cbf4a9b6e67c1e67b69896c7d;p=tinc diff --git a/src/linux/device.c b/src/linux/device.c index 75e77159..519896e7 100644 --- a/src/linux/device.c +++ b/src/linux/device.c @@ -1,7 +1,7 @@ /* device.c -- Interaction with Linux ethertap and tun/tap device - Copyright (C) 2001-2005 Ivo Timmermans , - 2001-2005 Guus Sliepen + Copyright (C) 2001-2005 Ivo Timmermans, + 2001-2006 Guus Sliepen This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -22,12 +22,8 @@ #include "system.h" -#ifdef HAVE_TUNTAP -#ifdef LINUX_IF_TUN_H -#include LINUX_IF_TUN_H -#else +#ifdef HAVE_LINUX_IF_TUN_H #include -#endif #define DEFAULT_DEVICE "/dev/net/tun" #else #define DEFAULT_DEVICE "/dev/tap0" @@ -55,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(); @@ -65,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; @@ -77,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)); @@ -116,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(); @@ -173,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"), @@ -212,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);