1
0
mirror of https://github.com/SoftEtherVPN/SoftEtherVPN.git synced 2025-12-15 22:51:34 +03:00

Cedar: DHCP server now assigns static IPv4 address, if present in user note

This works for all VPN protocols.

In SessionMain(): for DHCPDISCOVER and DHCPREQUEST frames, write the static IP address (which is retrieved from the user notes) in the SIADDR field of DHCPHEADER.

In VirtualDhcpServer(): for DHCPDISCOVER and DHCPREQUEST frames, read the static IP address from the SIADDR field of DHCPHEADER and assign it to the client.
This commit is contained in:
PeTeeR
2020-10-12 04:56:30 +02:00
committed by Davide Beatrici
parent 1c4b257a1b
commit b890c7d813
6 changed files with 240 additions and 10 deletions

View File

@ -1318,3 +1318,40 @@ bool GetUserMacAddressFromUserNote(UCHAR *mac, wchar_t *note)
return ret;
}
// Get the static IPv4 address from the user's note string
UINT GetUserIPv4AddressFromUserNote32(wchar_t *note)
{
bool ret = false;
UINT ip32 = 0;
UINT i = UniSearchStrEx(note, USER_IPV4_STR_PREFIX, 0, false);
if (i != INFINITE)
{
wchar_t *ipv4str_start = &note[i + UniStrLen(USER_IPV4_STR_PREFIX)];
wchar_t ipv4str2[MAX_SIZE];
UNI_TOKEN_LIST *tokens;
UniStrCpy(ipv4str2, sizeof(ipv4str2), ipv4str_start);
UniTrim(ipv4str2);
tokens = UniParseToken(ipv4str2, L" ,/()[]");
if (tokens != NULL)
{
if (tokens->NumTokens >= 1)
{
wchar_t *ipv4str = tokens->Token[0];
if (UniIsEmptyStr(ipv4str) == false)
{
char ipv4str_a[MAX_SIZE];
UniToStr(ipv4str_a, sizeof(ipv4str_a), ipv4str);
ip32 = StrToIP32(ipv4str_a);
}
}
UniFreeToken(tokens);
}
}
return ip32;
}