[DHCPCSVC] Change automatic address assignment to use hardware address

According to RFC 3927, the pseudo-random number generation algorithm MUST be chosen
so that different hosts do not generate the same sequence of numbers, and that the
pseudo-random number generator SHOULD be seeded using a value derived from the
IEEE 802 MAC address, so that a host will usually select the same IPv4 Link-Local
address each time it is booted.
This commit is contained in:
Hervé Poussineau 2021-04-19 23:21:35 +02:00
parent 0dedb9b474
commit 1ff3d1c395

View file

@ -1069,6 +1069,8 @@ void
state_panic(void *ipp)
{
struct interface_info *ip = ipp;
uint16_t address_low;
int i;
PDHCP_ADAPTER Adapter = AdapterFindInfo(ip);
note("No DHCPOFFERS received.");
@ -1079,7 +1081,11 @@ state_panic(void *ipp)
DbgPrint("DHCPCSVC: Failed to receive a response from a DHCP server. An automatic private address will be assigned.\n");
/* FIXME: The address generation code sucks */
AddIPAddress(htonl(0xA9FE0000 | (rand() % 0xFFFF)), //169.254.X.X
srand(0);
address_low = rand();
for (i = 0; i < ip->hw_address.hlen; i++)
address_low += ip->hw_address.haddr[i];
AddIPAddress(htonl(0xA9FE0000 | address_low), //169.254.X.X
htonl(0xFFFF0000), //255.255.0.0
Adapter->IfMib.dwIndex,
&Adapter->NteContext,