X-Git-Url: https://www.tinc-vpn.org/git/browse?p=tinc;a=blobdiff_plain;f=src%2Fbsd%2Fdevice.c;h=95e65f9cbfa9bb866f27d95f488ea87e71035047;hp=e3148bd3ca7521f51c100a3906c607b7a82d5ad1;hb=6714a74b30e1cbf9fe45b14c00d0ebebf8f26c4c;hpb=1da40f9723142d87ed3634c7b45c911e3d5c93b5 diff --git a/src/bsd/device.c b/src/bsd/device.c index e3148bd3..95e65f9c 100644 --- a/src/bsd/device.c +++ b/src/bsd/device.c @@ -49,9 +49,7 @@ typedef enum device_type { #ifdef ENABLE_TUNEMU DEVICE_TYPE_TUNEMU, #endif -#ifdef HAVE_NET_IF_UTUN_H DEVICE_TYPE_UTUN, -#endif } device_type_t; int device_fd = -1; @@ -200,18 +198,19 @@ static bool setup_device(void) { // Guess what the corresponding interface is called - char *realname; + char *realname = NULL; #if defined(HAVE_FDEVNAME) - realname = fdevname(device_fd) ? : device; + realname = fdevname(device_fd); #elif defined(HAVE_DEVNAME) struct stat buf; if(!fstat(device_fd, &buf)) - realname = devname(buf.st_rdev, S_IFCHR) ? : device; -#else - realname = device; + realname = devname(buf.st_rdev, S_IFCHR); #endif + if(!realname) + realname = device; + if(!get_config_string(lookup_config(config_tree, "Interface"), &iface)) iface = xstrdup(strrchr(realname, '/') ? strrchr(realname, '/') + 1 : realname); else if(strcmp(iface, strrchr(realname, '/') ? strrchr(realname, '/') + 1 : realname))