-cp
- if((device_fd = open(device, O_RDWR | O_NONBLOCK)) < 0)
- {
- syslog(LOG_ERR, _("Could not open %s: %s"), device, strerror(errno));
- return -1;
- }
-cp
- /* Set default MAC address for ethertap devices */
-
- mymac.type = SUBNET_MAC;
- mymac.net.mac.address.x[0] = 0xfe;
- mymac.net.mac.address.x[1] = 0xfd;
- mymac.net.mac.address.x[2] = 0x00;
- mymac.net.mac.address.x[3] = 0x00;
- mymac.net.mac.address.x[4] = 0x00;
- mymac.net.mac.address.x[5] = 0x00;
-
-#ifdef HAVE_TUNTAP
- /* Ok now check if this is an old ethertap or a new tun/tap thingie */
-
- memset(&ifr, 0, sizeof(ifr));
-cp
- ifr.ifr_flags = IFF_TAP | IFF_NO_PI;
- if (interface)
- strncpy(ifr.ifr_name, interface, IFNAMSIZ);
-cp
- if (!ioctl(device_fd, TUNSETIFF, (void *) &ifr))
- {
- device_info = _("Linux tun/tap device");
- device_type = DEVICE_TYPE_TUNTAP;
- strncpy(ifrname, ifr.ifr_name, IFNAMSIZ);
- interface = ifrname;
- }
- else
- if (!ioctl(device_fd, (('T'<< 8) | 202), (void *) &ifr))
- {
- syslog(LOG_WARNING, _("Old ioctl() request was needed for %s"), device);
- device_type = DEVICE_TYPE_TUNTAP;
- device_info = _("Linux tun/tap device");
- strncpy(ifrname, ifr.ifr_name, IFNAMSIZ);
- interface = ifrname;
- }
- else
+ device_fd = open(device, O_RDWR | O_NONBLOCK);
+
+ if(device_fd < 0) {
+ logger(LOG_ERR, _("Could not open %s: %s"), device, strerror(errno));
+ return false;
+ }
+
+#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);
+ if(routing_mode == RMODE_ROUTER) {
+ ifr.ifr_flags = IFF_TUN;
+ device_type = DEVICE_TYPE_TUN;
+ device_info = _("Linux tun/tap device (tun mode)");
+ } else {
+ ifr.ifr_flags = IFF_TAP | IFF_NO_PI;
+ device_type = DEVICE_TYPE_TAP;
+ device_info = _("Linux tun/tap device (tap mode)");
+ }
+
+ if(iface)
+ strncpy(ifr.ifr_name, iface, IFNAMSIZ);
+
+ if(!ioctl(device_fd, TUNSETIFF, &ifr)) {
+ strncpy(ifrname, ifr.ifr_name, IFNAMSIZ);
+ if(iface) free(iface);
+ iface = xstrdup(ifrname);
+ } else if(!ioctl(device_fd, (('T' << 8) | 202), &ifr)) {
+ logger(LOG_WARNING, _("Old ioctl() request was needed for %s"), device);
+ strncpy(ifrname, ifr.ifr_name, IFNAMSIZ);
+ if(iface) free(iface);
+ iface = xstrdup(ifrname);
+ } else