mirror of
https://github.com/reactos/reactos.git
synced 2024-12-29 02:25:17 +00:00
[DHCPCSRV] Send an ARP request to check if an automatic private address is available
This commit is contained in:
parent
894cc4ac0c
commit
2047cf3613
1 changed files with 36 additions and 12 deletions
|
@ -1071,6 +1071,10 @@ state_panic(void *ipp)
|
||||||
struct interface_info *ip = ipp;
|
struct interface_info *ip = ipp;
|
||||||
uint16_t address_low;
|
uint16_t address_low;
|
||||||
int i;
|
int i;
|
||||||
|
IPAddr IpAddress;
|
||||||
|
ULONG Buffer[20];
|
||||||
|
ULONG BufferSize;
|
||||||
|
DWORD ret;
|
||||||
PDHCP_ADAPTER Adapter = AdapterFindInfo(ip);
|
PDHCP_ADAPTER Adapter = AdapterFindInfo(ip);
|
||||||
|
|
||||||
note("No DHCPOFFERS received.");
|
note("No DHCPOFFERS received.");
|
||||||
|
@ -1082,14 +1086,34 @@ state_panic(void *ipp)
|
||||||
|
|
||||||
/* FIXME: The address generation code sucks */
|
/* FIXME: The address generation code sucks */
|
||||||
srand(0);
|
srand(0);
|
||||||
|
|
||||||
|
for (;;)
|
||||||
|
{
|
||||||
address_low = rand();
|
address_low = rand();
|
||||||
for (i = 0; i < ip->hw_address.hlen; i++)
|
for (i = 0; i < ip->hw_address.hlen; i++)
|
||||||
address_low += ip->hw_address.haddr[i];
|
address_low += ip->hw_address.haddr[i];
|
||||||
AddIPAddress(htonl(0xA9FE0000 | address_low), //169.254.X.X
|
|
||||||
htonl(0xFFFF0000), //255.255.0.0
|
IpAddress = htonl(0xA9FE0000 | address_low); // 169.254.X.X
|
||||||
|
|
||||||
|
/* Send an ARP request to check if the IP address is already in use */
|
||||||
|
BufferSize = sizeof(Buffer);
|
||||||
|
ret = SendARP(IpAddress,
|
||||||
|
IpAddress,
|
||||||
|
Buffer,
|
||||||
|
&BufferSize);
|
||||||
|
DH_DbgPrint(MID_TRACE,("DHCPCSVC: SendARP returned %lu\n", ret));
|
||||||
|
if (ret != 0)
|
||||||
|
{
|
||||||
|
/* The IP address is not in use */
|
||||||
|
DH_DbgPrint(MID_TRACE,("DHCPCSVC: Using automatic private address\n"));
|
||||||
|
AddIPAddress(IpAddress,
|
||||||
|
htonl(0xFFFF0000), // 255.255.0.0
|
||||||
Adapter->IfMib.dwIndex,
|
Adapter->IfMib.dwIndex,
|
||||||
&Adapter->NteContext,
|
&Adapter->NteContext,
|
||||||
&Adapter->NteInstance);
|
&Adapter->NteInstance);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue