- 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
-#endif
- {
- device_info = _("Linux ethertap device");
- device_type = DEVICE_TYPE_ETHERTAP;
- interface = rindex(device, '/') ? rindex(device, '/') + 1 : device;
+ if((type && !strcasecmp(type, "tun")) || (!type && routing_mode == RMODE_ROUTER)) {
+ ifr.ifr_flags = IFF_TUN;
+ device_type = DEVICE_TYPE_TUN;
+ device_info = "Linux tun/tap device (tun mode)";
+ } else {
+ if (routing_mode == RMODE_ROUTER)
+ overwrite_mac = true;
+ ifr.ifr_flags = IFF_TAP | IFF_NO_PI;
+ device_type = DEVICE_TYPE_TAP;
+ device_info = "Linux tun/tap device (tap mode)";