From: Guus Sliepen Date: Fri, 18 Jul 2003 13:41:37 +0000 (+0000) Subject: Update all device.c files. X-Git-Tag: release-1.0~57 X-Git-Url: https://git.tinc-vpn.org/git/browse?a=commitdiff_plain;h=00ddbf5723511d80fbd2522fc503bd409dc6189a;p=tinc Update all device.c files. --- diff --git a/src/cygwin/device.c b/src/cygwin/device.c index 39efbb0c..4e73e4c4 100644 --- a/src/cygwin/device.c +++ b/src/cygwin/device.c @@ -17,30 +17,20 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id: device.c,v 1.1.2.8 2003/07/15 16:27:39 guus Exp $ + $Id: device.c,v 1.1.2.9 2003/07/18 13:41:35 guus Exp $ */ -#include "config.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include "system.h" + #include #include -// #include #include "conf.h" -#include "net.h" #include "logger.h" +#include "net.h" #include "route.h" - -#include "system.h" +#include "utils.h" +#include "xalloc.h" /* Definitions from CIPE */ diff --git a/src/darwin/device.c b/src/darwin/device.c index 3da6726e..ef6c7777 100644 --- a/src/darwin/device.c +++ b/src/darwin/device.c @@ -17,35 +17,22 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id: device.c,v 1.1.2.8 2003/07/12 17:41:47 guus Exp $ + $Id: device.c,v 1.1.2.9 2003/07/18 13:41:36 guus Exp $ */ -#include "config.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include "system.h" -#include #include "conf.h" -#include "net.h" #include "logger.h" - -#include "system.h" +#include "net.h" +#include "utils.h" #define DEFAULT_DEVICE "/dev/tun0" int device_fd = -1; int device_type; char *device; -char *interface; +char *iface; char *device_info; int device_total_in = 0; int device_total_out = 0; @@ -57,8 +44,8 @@ int setup_device(void) if(!get_config_string(lookup_config(config_tree, "Device"), &device)) device = DEFAULT_DEVICE; - if(!get_config_string(lookup_config(config_tree, "Interface"), &interface)) - interface = rindex(device, '/') ? rindex(device, '/') + 1 : device; + if(!get_config_string(lookup_config(config_tree, "Interface"), &iface)) + iface = rindex(device, '/') ? rindex(device, '/') + 1 : device; if((device_fd = open(device, O_RDWR | O_NONBLOCK)) < 0) { logger(LOG_ERR, _("Could not open %s: %s"), device, strerror(errno)); diff --git a/src/freebsd/device.c b/src/freebsd/device.c index 2850fd6d..b85923b4 100644 --- a/src/freebsd/device.c +++ b/src/freebsd/device.c @@ -17,35 +17,22 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id: device.c,v 1.1.2.11 2003/07/12 17:41:47 guus Exp $ + $Id: device.c,v 1.1.2.12 2003/07/18 13:41:36 guus Exp $ */ -#include "config.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include "system.h" -#include #include "conf.h" -#include "net.h" #include "logger.h" - -#include "system.h" +#include "net.h" +#include "utils.h" #define DEFAULT_DEVICE "/dev/tap0" int device_fd = -1; int device_type; char *device; -char *interface; +char *iface; char *device_info; int device_total_in = 0; int device_total_out = 0; @@ -57,8 +44,8 @@ int setup_device(void) if(!get_config_string(lookup_config(config_tree, "Device"), &device)) device = DEFAULT_DEVICE; - if(!get_config_string(lookup_config(config_tree, "Interface"), &interface)) - interface = rindex(device, '/') ? rindex(device, '/') + 1 : device; + if(!get_config_string(lookup_config(config_tree, "Interface"), &iface)) + iface = rindex(device, '/') ? rindex(device, '/') + 1 : device; if((device_fd = open(device, O_RDWR | O_NONBLOCK)) < 0) { logger(LOG_ERR, _("Could not open %s: %s"), device, strerror(errno)); diff --git a/src/linux/device.c b/src/linux/device.c index 08d9364d..caee2548 100644 --- a/src/linux/device.c +++ b/src/linux/device.c @@ -17,7 +17,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id: device.c,v 1.1.2.18 2003/07/17 15:06:27 guus Exp $ + $Id: device.c,v 1.1.2.19 2003/07/18 13:41:36 guus Exp $ */ #include "system.h" @@ -48,7 +48,7 @@ enum { int device_fd = -1; int device_type; char *device; -char *interface; +char *iface; char ifrname[IFNAMSIZ]; char *device_info; @@ -64,11 +64,11 @@ int setup_device(void) if(!get_config_string(lookup_config(config_tree, "Device"), &device)) device = DEFAULT_DEVICE; - if(!get_config_string(lookup_config(config_tree, "Interface"), &interface)) + if(!get_config_string(lookup_config(config_tree, "Interface"), &iface)) #ifdef HAVE_TUNTAP - interface = netname; + iface = netname; #else - interface = rindex(device, '/') ? rindex(device, '/') + 1 : device; + iface = rindex(device, '/') ? rindex(device, '/') + 1 : device; #endif device_fd = open(device, O_RDWR | O_NONBLOCK); @@ -91,16 +91,16 @@ int setup_device(void) device_info = _("Linux tun/tap device (tap mode)"); } - if(interface) - strncpy(ifr.ifr_name, interface, IFNAMSIZ); + if(iface) + strncpy(ifr.ifr_name, iface, IFNAMSIZ); if(!ioctl(device_fd, TUNSETIFF, (void *) &ifr)) { strncpy(ifrname, ifr.ifr_name, IFNAMSIZ); - interface = ifrname; + iface = ifrname; } else if(!ioctl(device_fd, (('T' << 8) | 202), (void *) &ifr)) { logger(LOG_WARNING, _("Old ioctl() request was needed for %s"), device); strncpy(ifrname, ifr.ifr_name, IFNAMSIZ); - interface = ifrname; + iface = ifrname; } else #endif { @@ -108,7 +108,7 @@ int setup_device(void) overwrite_mac = 1; device_info = _("Linux ethertap device"); device_type = DEVICE_TYPE_ETHERTAP; - interface = rindex(device, '/') ? rindex(device, '/') + 1 : device; + iface = rindex(device, '/') ? rindex(device, '/') + 1 : device; } logger(LOG_INFO, _("%s is a %s"), device, device_info); diff --git a/src/net_socket.c b/src/net_socket.c index bb5208f8..90458d28 100644 --- a/src/net_socket.c +++ b/src/net_socket.c @@ -17,7 +17,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id: net_socket.c,v 1.1.2.27 2003/07/17 15:06:26 guus Exp $ + $Id: net_socket.c,v 1.1.2.28 2003/07/18 13:41:35 guus Exp $ */ #include "system.h" @@ -48,10 +48,8 @@ int setup_listen_socket(sockaddr_t *sa) int nfd, flags; char *addrstr; int option; -#if defined(SOL_SOCKET) && defined(SO_BINDTODEVICE) char *interface; struct ifreq ifr; -#endif cp(); diff --git a/src/netbsd/device.c b/src/netbsd/device.c index 3f076392..0064fdef 100644 --- a/src/netbsd/device.c +++ b/src/netbsd/device.c @@ -17,29 +17,15 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id: device.c,v 1.1.2.10 2003/07/12 17:41:48 guus Exp $ + $Id: device.c,v 1.1.2.11 2003/07/18 13:41:36 guus Exp $ */ -#include "config.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include +#include "system.h" + #include "conf.h" -#include "net.h" #include "logger.h" - -#include "system.h" +#include "net.h" +#include "utils.h" #define DEFAULT_DEVICE "/dev/tun0" @@ -49,7 +35,7 @@ int device_fd = -1; int device_type; char *device; -char *interface; +char *iface; char *device_info; int device_total_in = 0; @@ -62,8 +48,8 @@ int setup_device(void) if(!get_config_string(lookup_config(config_tree, "Device"), &device)) device = DEFAULT_DEVICE; - if(!get_config_string(lookup_config(config_tree, "Interface"), &interface)) - interface = rindex(device, '/') ? rindex(device, '/') + 1 : device; + if(!get_config_string(lookup_config(config_tree, "Interface"), &iface)) + iface = rindex(device, '/') ? rindex(device, '/') + 1 : device; if((device_fd = open(device, O_RDWR | O_NONBLOCK)) < 0) { logger(LOG_ERR, _("Could not open %s: %s"), device, strerror(errno)); return -1; diff --git a/src/openbsd/device.c b/src/openbsd/device.c index e9b4bbdd..9af2e3e3 100644 --- a/src/openbsd/device.c +++ b/src/openbsd/device.c @@ -17,29 +17,15 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id: device.c,v 1.1.2.15 2003/07/12 17:41:48 guus Exp $ + $Id: device.c,v 1.1.2.16 2003/07/18 13:41:36 guus Exp $ */ -#include "config.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include +#include "system.h" + #include "conf.h" -#include "net.h" #include "logger.h" - -#include "system.h" +#include "net.h" +#include "utils.h" #define DEFAULT_DEVICE "/dev/tun0" @@ -49,7 +35,7 @@ int device_fd = -1; int device_type; char *device; -char *interface; +char *iface; char *device_info; int device_total_in = 0; @@ -62,8 +48,8 @@ int setup_device(void) if(!get_config_string(lookup_config(config_tree, "Device"), &device)) device = DEFAULT_DEVICE; - if(!get_config_string(lookup_config(config_tree, "Interface"), &interface)) - interface = rindex(device, '/') ? rindex(device, '/') + 1 : device; + if(!get_config_string(lookup_config(config_tree, "Interface"), &iface)) + iface = rindex(device, '/') ? rindex(device, '/') + 1 : device; if((device_fd = open(device, O_RDWR | O_NONBLOCK)) < 0) { logger(LOG_ERR, _("Could not open %s: %s"), device, strerror(errno)); return -1; diff --git a/src/solaris/device.c b/src/solaris/device.c index 5183721c..3cafa238 100644 --- a/src/solaris/device.c +++ b/src/solaris/device.c @@ -17,39 +17,27 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id: device.c,v 1.1.2.14 2003/07/12 17:41:48 guus Exp $ + $Id: device.c,v 1.1.2.15 2003/07/18 13:41:37 guus Exp $ */ -#include "config.h" +#include "system.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include #include #include #include -#define DEFAULT_DEVICE "/dev/tun" - -#include #include "conf.h" -#include "net.h" #include "logger.h" +#include "net.h" +#include "utils.h" -#include "system.h" +#define DEFAULT_DEVICE "/dev/tun" int device_fd = -1; int device_type; char *device = NULL; -char *interface = NULL; +char *iface = NULL; char ifrname[IFNAMSIZ]; char *device_info = NULL; @@ -112,8 +100,8 @@ int setup_device(void) return -1; } - if(!get_config_string(lookup_config(config_tree, "Interface"), &interface)) - asprintf(&interface, "tun%d", ppa); + if(!get_config_string(lookup_config(config_tree, "Interface"), &iface)) + asprintf(&iface, "tun%d", ppa); device_info = _("Solaris tun device");