mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 18:15:11 +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,26 +1071,50 @@ 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;
|
||||||
PDHCP_ADAPTER Adapter = AdapterFindInfo(ip);
|
IPAddr IpAddress;
|
||||||
|
ULONG Buffer[20];
|
||||||
|
ULONG BufferSize;
|
||||||
|
DWORD ret;
|
||||||
|
PDHCP_ADAPTER Adapter = AdapterFindInfo(ip);
|
||||||
|
|
||||||
note("No DHCPOFFERS received.");
|
note("No DHCPOFFERS received.");
|
||||||
|
|
||||||
if (!Adapter->NteContext)
|
if (!Adapter->NteContext)
|
||||||
{
|
{
|
||||||
/* Generate an automatic private address */
|
/* Generate an automatic private address */
|
||||||
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 */
|
||||||
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
|
||||||
Adapter->IfMib.dwIndex,
|
|
||||||
&Adapter->NteContext,
|
/* Send an ARP request to check if the IP address is already in use */
|
||||||
&Adapter->NteInstance);
|
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->NteContext,
|
||||||
|
&Adapter->NteInstance);
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
Loading…
Reference in a new issue