- 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;
-cp
- if((device_fd = open(device, O_RDWR | O_NONBLOCK)) < 0)
- {
- syslog(LOG_ERR, _("Could not open %s: %m"), device);
- 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;
-
- device_info = _("OpenBSD tun device");
-
- syslog(LOG_INFO, _("%s is a %s"), device, device_info);
-cp
- return 0;
+ cp();
+
+ if(!get_config_string(lookup_config(config_tree, "Device"), &device))
+ device = DEFAULT_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 false;
+ }
+
+ device_info = _("OpenBSD tun device");
+
+ logger(LOG_INFO, _("%s is a %s"), device, device_info);
+
+ return true;