mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 06:33:01 +00:00
[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:
parent
0dedb9b474
commit
1ff3d1c395
1 changed files with 7 additions and 1 deletions
|
@ -1069,6 +1069,8 @@ void
|
||||||
state_panic(void *ipp)
|
state_panic(void *ipp)
|
||||||
{
|
{
|
||||||
struct interface_info *ip = ipp;
|
struct interface_info *ip = ipp;
|
||||||
|
uint16_t address_low;
|
||||||
|
int i;
|
||||||
PDHCP_ADAPTER Adapter = AdapterFindInfo(ip);
|
PDHCP_ADAPTER Adapter = AdapterFindInfo(ip);
|
||||||
|
|
||||||
note("No DHCPOFFERS received.");
|
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");
|
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 */
|
/* 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
|
htonl(0xFFFF0000), //255.255.0.0
|
||||||
Adapter->IfMib.dwIndex,
|
Adapter->IfMib.dwIndex,
|
||||||
&Adapter->NteContext,
|
&Adapter->NteContext,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue