Ignore the Interface option if device rename is impossible.
[tinc] / src / bsd / device.c
index 49508bc..cb65dbb 100644 (file)
@@ -35,7 +35,7 @@
 #endif
 
 #define DEFAULT_TUN_DEVICE "/dev/tun0"
-#if defined(HAVE_FREEBSD) || defined(HAVE_NETBSD)
+#if defined(HAVE_DARWIN) || defined(HAVE_FREEBSD) || defined(HAVE_NETBSD)
 #define DEFAULT_TAP_DEVICE "/dev/tap0"
 #else
 #define DEFAULT_TAP_DEVICE "/dev/tun0"
@@ -73,6 +73,15 @@ static bool setup_device(void) {
        }
 
        if(!get_config_string(lookup_config(config_tree, "Interface"), &iface))
+               iface = NULL;
+#ifndef TAPGIFNAME
+       if (iface) {
+               logger(DEBUG_ALWAYS, LOG_WARNING, "Ignoring specified interface name '%s' as device rename is not supported on this platform", iface);
+               free(iface);
+               iface = NULL;
+       }
+#endif
+       if (!iface)
                iface = xstrdup(strrchr(device, '/') ? strrchr(device, '/') + 1 : device);
 
        if(get_config_string(lookup_config(config_tree, "DeviceType"), &type)) {