Update all device.c files.
authorGuus Sliepen <guus@tinc-vpn.org>
Fri, 18 Jul 2003 13:41:37 +0000 (13:41 +0000)
committerGuus Sliepen <guus@tinc-vpn.org>
Fri, 18 Jul 2003 13:41:37 +0000 (13:41 +0000)
src/cygwin/device.c
src/darwin/device.c
src/freebsd/device.c
src/linux/device.c
src/net_socket.c
src/netbsd/device.c
src/openbsd/device.c
src/solaris/device.c

index 39efbb0..4e73e4c 100644 (file)
     along with this program; if not, write to the Free Software\r
     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.\r
 \r
     along with this program; if not, write to the Free Software\r
     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.\r
 \r
-    $Id: device.c,v 1.1.2.8 2003/07/15 16:27:39 guus Exp $\r
+    $Id: device.c,v 1.1.2.9 2003/07/18 13:41:35 guus Exp $\r
 */\r
 \r
 */\r
 \r
-#include "config.h"\r
-\r
-#include <stdio.h>\r
-#include <stdbool.h>\r
-#include <errno.h>\r
-#include <sys/types.h>\r
-#include <sys/stat.h>\r
-#include <signal.h>\r
-#include <fcntl.h>\r
-#include <unistd.h>\r
-#include <string.h>\r
+#include "system.h"\r
+\r
 #include <w32api/windows.h>\r
 #include <w32api/winioctl.h>\r
 \r
 #include <w32api/windows.h>\r
 #include <w32api/winioctl.h>\r
 \r
-// #include <utils.h>\r
 #include "conf.h"\r
 #include "conf.h"\r
-#include "net.h"\r
 #include "logger.h"\r
 #include "logger.h"\r
+#include "net.h"\r
 #include "route.h"\r
 #include "route.h"\r
-\r
-#include "system.h"\r
+#include "utils.h"\r
+#include "xalloc.h"\r
 \r
 /* Definitions from CIPE */\r
 \r
 \r
 /* Definitions from CIPE */\r
 \r
index 3da6726..ef6c777 100644 (file)
     along with this program; if not, write to the Free Software
     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
     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 <stdio.h>
-#include <errno.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/ioctl.h>
-#include <sys/socket.h>
-#include <fcntl.h>
-#include <net/if.h>
-#include <unistd.h>
-#include <string.h>
+#include "system.h"
 
 
-#include <utils.h>
 #include "conf.h"
 #include "conf.h"
-#include "net.h"
 #include "logger.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;
 
 #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;
 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, "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));
 
        if((device_fd = open(device, O_RDWR | O_NONBLOCK)) < 0) {
                logger(LOG_ERR, _("Could not open %s: %s"), device, strerror(errno));
index 2850fd6..b85923b 100644 (file)
     along with this program; if not, write to the Free Software
     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
     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 <stdio.h>
-#include <errno.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/ioctl.h>
-#include <sys/socket.h>
-#include <fcntl.h>
-#include <net/if.h>
-#include <unistd.h>
-#include <string.h>
+#include "system.h"
 
 
-#include <utils.h>
 #include "conf.h"
 #include "conf.h"
-#include "net.h"
 #include "logger.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;
 
 #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;
 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, "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));
 
        if((device_fd = open(device, O_RDWR | O_NONBLOCK)) < 0) {
                logger(LOG_ERR, _("Could not open %s: %s"), device, strerror(errno));
index 08d9364..caee254 100644 (file)
@@ -17,7 +17,7 @@
     along with this program; if not, write to the Free Software
     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
     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"
 */
 
 #include "system.h"
@@ -48,7 +48,7 @@ enum {
 int device_fd = -1;
 int device_type;
 char *device;
 int device_fd = -1;
 int device_type;
 char *device;
-char *interface;
+char *iface;
 char ifrname[IFNAMSIZ];
 char *device_info;
 
 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, "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
 #ifdef HAVE_TUNTAP
-               interface = netname;
+               iface = netname;
 #else
 #else
-               interface = rindex(device, '/') ? rindex(device, '/') + 1 : device;
+               iface = rindex(device, '/') ? rindex(device, '/') + 1 : device;
 #endif
        device_fd = open(device, O_RDWR | O_NONBLOCK);
 
 #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)");
        }
 
                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);
 
        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);
        } 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
        {
        } else
 #endif
        {
@@ -108,7 +108,7 @@ int setup_device(void)
                        overwrite_mac = 1;
                device_info = _("Linux ethertap device");
                device_type = DEVICE_TYPE_ETHERTAP;
                        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);
        }
 
        logger(LOG_INFO, _("%s is a %s"), device, device_info);
index bb5208f..90458d2 100644 (file)
@@ -17,7 +17,7 @@
     along with this program; if not, write to the Free Software
     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
     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"
 */
 
 #include "system.h"
@@ -48,10 +48,8 @@ int setup_listen_socket(sockaddr_t *sa)
        int nfd, flags;
        char *addrstr;
        int option;
        int nfd, flags;
        char *addrstr;
        int option;
-#if defined(SOL_SOCKET) && defined(SO_BINDTODEVICE)
        char *interface;
        struct ifreq ifr;
        char *interface;
        struct ifreq ifr;
-#endif
 
        cp();
 
 
        cp();
 
index 3f07639..0064fde 100644 (file)
     along with this program; if not, write to the Free Software
     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
     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 <stdio.h>
-#include <errno.h>
-#include <sys/types.h>
-#include <sys/uio.h>
-#include <sys/stat.h>
-#include <sys/ioctl.h>
-#include <sys/socket.h>
-#include <fcntl.h>
-#include <net/if.h>
-#include <unistd.h>
-#include <string.h>
-
-#include <utils.h>
+#include "system.h"
+
 #include "conf.h"
 #include "conf.h"
-#include "net.h"
 #include "logger.h"
 #include "logger.h"
-
-#include "system.h"
+#include "net.h"
+#include "utils.h"
 
 #define DEFAULT_DEVICE "/dev/tun0"
 
 
 #define DEFAULT_DEVICE "/dev/tun0"
 
@@ -49,7 +35,7 @@
 int device_fd = -1;
 int device_type;
 char *device;
 int device_fd = -1;
 int device_type;
 char *device;
-char *interface;
+char *iface;
 char *device_info;
 
 int device_total_in = 0;
 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, "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;
        if((device_fd = open(device, O_RDWR | O_NONBLOCK)) < 0) {
                logger(LOG_ERR, _("Could not open %s: %s"), device, strerror(errno));
                return -1;
index e9b4bbd..9af2e3e 100644 (file)
     along with this program; if not, write to the Free Software
     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
     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 <stdio.h>
-#include <errno.h>
-#include <sys/types.h>
-#include <sys/uio.h>
-#include <sys/stat.h>
-#include <sys/ioctl.h>
-#include <sys/socket.h>
-#include <fcntl.h>
-#include <net/if.h>
-#include <unistd.h>
-#include <string.h>
-
-#include <utils.h>
+#include "system.h"
+
 #include "conf.h"
 #include "conf.h"
-#include "net.h"
 #include "logger.h"
 #include "logger.h"
-
-#include "system.h"
+#include "net.h"
+#include "utils.h"
 
 #define DEFAULT_DEVICE "/dev/tun0"
 
 
 #define DEFAULT_DEVICE "/dev/tun0"
 
@@ -49,7 +35,7 @@
 int device_fd = -1;
 int device_type;
 char *device;
 int device_fd = -1;
 int device_type;
 char *device;
-char *interface;
+char *iface;
 char *device_info;
 
 int device_total_in = 0;
 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, "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;
        if((device_fd = open(device, O_RDWR | O_NONBLOCK)) < 0) {
                logger(LOG_ERR, _("Could not open %s: %s"), device, strerror(errno));
                return -1;
index 5183721..3cafa23 100644 (file)
     along with this program; if not, write to the Free Software
     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
     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 <stdio.h>
-#include <errno.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <sys/socket.h>
-#include <net/if.h>
-#include <unistd.h>
-#include <string.h>
-#include <sys/ioctl.h>
 #include <sys/stropts.h>
 #include <sys/sockio.h>
 #include <net/if_tun.h>
 
 #include <sys/stropts.h>
 #include <sys/sockio.h>
 #include <net/if_tun.h>
 
-#define DEFAULT_DEVICE "/dev/tun"
-
-#include <utils.h>
 #include "conf.h"
 #include "conf.h"
-#include "net.h"
 #include "logger.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;
 
 int device_fd = -1;
 int device_type;
 char *device = NULL;
-char *interface = NULL;
+char *iface = NULL;
 char ifrname[IFNAMSIZ];
 char *device_info = NULL;
 
 char ifrname[IFNAMSIZ];
 char *device_info = NULL;
 
@@ -112,8 +100,8 @@ int setup_device(void)
                return -1;
        }
 
                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");
 
 
        device_info = _("Solaris tun device");