https://git.reactos.org/?p=reactos.git;a=commitdiff;h=1ff3d1c395644af497cccc...
commit 1ff3d1c395644af497cccc56dc1a548136a23ec4 Author: Hervé Poussineau hpoussin@reactos.org AuthorDate: Mon Apr 19 23:21:35 2021 +0200 Commit: Hervé Poussineau hpoussin@reactos.org CommitDate: Tue Apr 20 18:28:36 2021 +0200
[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. --- base/services/dhcpcsvc/dhcp/dhclient.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/base/services/dhcpcsvc/dhcp/dhclient.c b/base/services/dhcpcsvc/dhcp/dhclient.c index f840f5b876c..81fcd9c5000 100644 --- a/base/services/dhcpcsvc/dhcp/dhclient.c +++ b/base/services/dhcpcsvc/dhcp/dhclient.c @@ -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,