- 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;
+
+ get_config_string(lookup_config(config_tree, "DeviceType"), &type);
+
+ if(type && strcasecmp(type, "tun") && strcasecmp(type, "tap")) {
+ logger(LOG_ERR, "Unknown device type %s!", type);
+ return false;
+ }
+
+ 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)";
+ }
+
+#ifdef IFF_ONE_QUEUE
+
+ /* Set IFF_ONE_QUEUE flag... */
+ if(get_config_bool(lookup_config(config_tree, "IffOneQueue"), &t1q) && t1q) {
+ ifr.ifr_flags |= IFF_ONE_QUEUE;
+ }
+
+#endif
+
+ if(iface) {
+ strncpy(ifr.ifr_name, iface, IFNAMSIZ);
+ ifr.ifr_name[IFNAMSIZ - 1] = 0;
+ }
+
+ if(!ioctl(device_fd, TUNSETIFF, &ifr)) {