1
0
mirror of https://github.com/SoftEtherVPN/SoftEtherVPN.git synced 2024-12-25 01:29:53 +03:00

Merge pull request #1869 from metalefty/bsdunixvlan-group

Cedar/VLanUnix: assign virtual interface to softether group
This commit is contained in:
Ilya Shipitsin 2023-08-07 08:16:17 +02:00 committed by GitHub
commit f6f2660060
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 0 deletions

View File

@ -485,6 +485,9 @@ int UnixCreateTapDeviceEx(char *name, char *prefix, UCHAR *mac_address, bool cre
}
#endif
// Set interface group
UnixSetIfGroup(s, tap_name, CEDAR_PRODUCT_STR);
if (create_up)
{
Zero(&ifr, sizeof(ifr));
@ -622,6 +625,24 @@ void UnixDestroyClientTapDevice(char *name)
#endif // UNIX_BSD
}
void UnixSetIfGroup(int fd, const char *name, const char *group_name)
{
#ifdef SIOCAIFGROUP
struct ifgroupreq ifgr;
char *tmp;
tmp = CopyStr((char *)group_name);
StrLower(tmp);
Zero(&ifgr, sizeof(ifgr));
StrCpy(ifgr.ifgr_name, sizeof(ifgr.ifgr_name), (char *) name);
StrCpy(ifgr.ifgr_group, sizeof(ifgr.ifgr_group), tmp);
ioctl(fd, SIOCAIFGROUP, &ifgr);
Free(tmp);
#endif
}
#else // NO_VLAN
void UnixCloseDevice(int fd)
@ -636,6 +657,10 @@ void UnixDestroyTapDeviceEx(char *name, char *prefix)
{
}
void UnixSetIfGroup()
{
}
int UnixCreateTapDeviceEx(char *name, char *prefix, UCHAR *mac_address, bool create_up)
{
return -1;

View File

@ -62,6 +62,7 @@ int UnixCreateTapDeviceEx(char *name, char *prefix, UCHAR *mac_address, bool cre
void UnixCloseTapDevice(int fd);
void UnixDestroyBridgeTapDevice(char *name);
void UnixDestroyClientTapDevice(char *name);
void UnixSetIfGroup(int fd, const char *name, const char *group_name);
void UnixVLanInit();
void UnixVLanFree();
bool UnixVLanCreate(char *name, UCHAR *mac_address, bool create_up);