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:
@ -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
|
||||
|
||||
Reference in New Issue
Block a user