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

Change IP structure so that IPv4 addresses are stored in RFC3493 format

In addition to saving 4 bytes for each instantiation, this change makes IP-related operations faster and clearer.

https://tools.ietf.org/html/rfc3493.html#section-3.7
This commit is contained in:
Davide Beatrici
2021-04-07 21:24:55 +02:00
parent 01663f836d
commit 1708998a11
21 changed files with 295 additions and 403 deletions

View File

@ -683,30 +683,26 @@ UINT GenerateDummyMark(PRAND *p)
// Generate a dummy IP
void GenerateDummyIp(PRAND *p, IP *ip)
{
UINT i;
if (p == NULL || ip == NULL)
{
return;
}
Zero(ip, sizeof(IP));
ZeroIP4(ip);
BYTE *ipv4 = IPV4(ip->address);
for (i = 1;i < 4;i++)
for (BYTE i = 1; i < IPV4_SIZE; ++i)
{
UINT v = 0;
while (true)
BYTE v = 0;
while (v == 0 || v > 254)
{
v = PRandInt(p) % 256;
if (v >= 1 && v <= 254)
{
break;
}
}
ip->addr[i] = (UCHAR)v;
IPV4(ip->address)[i] = v;
}
ip->addr[0] = 127;
IPV4(ip->address)[0] = 127;
}
// Search an entry