From 9c33605f5ec2ac0cd7d9dfd3c10aec56aaa9c35e Mon Sep 17 00:00:00 2001 From: Koichiro IWAO Date: Tue, 30 May 2023 23:01:37 +0900 Subject: [PATCH] Cedar: Don't hardcode prefix for UNIX virtual network interface --- src/Cedar/Cedar.h | 2 ++ src/Cedar/SM.c | 3 ++- src/Cedar/VLanUnix.c | 6 +++--- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/Cedar/Cedar.h b/src/Cedar/Cedar.h index 2c9fafbf..7e3c88e0 100644 --- a/src/Cedar/Cedar.h +++ b/src/Cedar/Cedar.h @@ -675,6 +675,8 @@ // ////////////////////////////////////////////////////////////////////// +#define UNIX_VLAN_IFACE_PREFIX "vpn" // Prefix of UNIX virual LAN card interface + #ifndef UNIX_BSD #define TAP_FILENAME_1 "/dev/net/tun" #define TAP_FILENAME_2 "/dev/tun" diff --git a/src/Cedar/SM.c b/src/Cedar/SM.c index b0b5f2ae..ce6d49b7 100644 --- a/src/Cedar/SM.c +++ b/src/Cedar/SM.c @@ -7987,7 +7987,8 @@ void SmBridgeDlgOnOk(HWND hWnd, SM_SERVER *s) StrCpy(t.HubName, sizeof(t.HubName), hub); t.TapMode = tapmode; - if (InStrEx(t.DeviceName, "vpn", false) || InStrEx(t.DeviceName, "tun", false) + if (InStrEx(t.DeviceName, UNIX_VLAN_IFACE_PREFIX, false) + || InStrEx(t.DeviceName, "tun", false) || InStrEx(t.DeviceName, "tap", false)) { // Trying to make a local bridge to the VPN device diff --git a/src/Cedar/VLanUnix.c b/src/Cedar/VLanUnix.c index b4ede360..b4ae5f35 100644 --- a/src/Cedar/VLanUnix.c +++ b/src/Cedar/VLanUnix.c @@ -554,7 +554,7 @@ int UnixCreateTapDeviceEx(char *name, char *prefix, UCHAR *mac_address, bool cre } int UnixCreateTapDevice(char *name, UCHAR *mac_address, bool create_up) { - return UnixCreateTapDeviceEx(name, "vpn", mac_address, create_up); + return UnixCreateTapDeviceEx(name, UNIX_VLAN_IFACE_PREFIX, mac_address, create_up); } // Close the tap device @@ -662,7 +662,7 @@ bool UnixVLanCreateEx(char *name, char *prefix, UCHAR *mac_address, bool create_ } bool UnixVLanCreate(char *name, UCHAR *mac_address, bool create_up) { - return UnixVLanCreateEx(name, "vpn", mac_address, create_up); + return UnixVLanCreateEx(name, UNIX_VLAN_IFACE_PREFIX, mac_address, create_up); } // Set a VLAN up/down @@ -689,7 +689,7 @@ bool UnixVLanSetState(char* name, bool state_up) return false; } - GenerateTunName(name, "vpn", eth_name, sizeof(eth_name)); + GenerateTunName(name, UNIX_VLAN_IFACE_PREFIX, eth_name, sizeof(eth_name)); Zero(&ifr, sizeof(ifr)); StrCpy(ifr.ifr_name, sizeof(ifr.ifr_name), eth_name);