- if(!get_config_string(lookup_config(config_tree, "Interface"), &interface))
- interface = rindex(device, '/') ? rindex(device, '/') + 1 : device;
- cp if((device_fd = open(device, O_RDWR | O_NONBLOCK)) < 0) {
- syslog(LOG_ERR, _("Could not open %s: %s"), device, strerror(errno));
- return -1;
+ 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 false;
+ }
+
+ if(get_config_string(lookup_config(config_tree, "DeviceType"), &type)) {
+ if(!strcasecmp(type, "tun"))
+ device_type = DEVICE_TYPE_TUN;
+ else if(!strcasecmp(type, "tap"))
+ device_type = DEVICE_TYPE_TAP;
+ else {
+ logger(LOG_ERR, _("Unknown device type %s!"), type);
+ return false;
+ }
+ } else {
+ if(strstr(device, "tap"))
+ device_type = DEVICE_TYPE_TAP;
+ }
+
+ switch(device_type) {
+ default:
+ device_type = DEVICE_TYPE_TUN;
+ case DEVICE_TYPE_TUN:
+ device_info = _("MacOS/X tun device");
+ break;
+ case DEVICE_TYPE_TAP:
+ if(routing_mode == RMODE_ROUTER)
+ overwrite_mac = true;
+ device_info = _("MacOS/X tap device");
+ break;