Author: cgutman
Date: Fri Jul 23 21:57:08 2010
New Revision: 48213
URL:
http://svn.reactos.org/svn/reactos?rev=48213&view=rev
Log:
[DHCPCSVC]
- Generate a link-local IP address if DHCP fails
- Don't destroy the IP addresses in the registry
Modified:
trunk/reactos/dll/win32/dhcpcsvc/dhcp/dhclient.c
trunk/reactos/dll/win32/dhcpcsvc/include/rosdhcp.h
Modified: trunk/reactos/dll/win32/dhcpcsvc/dhcp/dhclient.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/dhcpcsvc/dhcp/dh…
==============================================================================
--- trunk/reactos/dll/win32/dhcpcsvc/dhcp/dhclient.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/dhcpcsvc/dhcp/dhclient.c [iso-8859-1] Fri Jul 23 21:57:08
2010
@@ -574,8 +574,6 @@
strcat(Buffer, ".");
}
RegSetValueExA(hkey, "DhcpSubnetMask", 0, REG_SZ, (LPBYTE)Buffer,
strlen(Buffer)+1);
- RegSetValueExA(hkey, "IPAddress", 0, REG_SZ,
(LPBYTE)"0.0.0.0", 8);
- RegSetValueExA(hkey, "SubnetMask", 0, REG_SZ,
(LPBYTE)"0.0.0.0", 8);
dwEnableDHCP = 1;
RegSetValueExA(hkey, "EnableDHCP", 0, REG_DWORD,
(LPBYTE)&dwEnableDHCP, sizeof(DWORD));
}
@@ -614,7 +612,6 @@
strcat(Buffer, ".");
}
RegSetValueExA(hkey, "DhcpDefaultGateway", 0, REG_SZ,
(LPBYTE)Buffer, strlen(Buffer)+1);
- RegSetValueExA(hkey, "DefaultGateway", 0, REG_SZ,
(LPBYTE)"0.0.0.0", 8);
}
}
@@ -1103,6 +1100,7 @@
state_panic(void *ipp)
{
struct interface_info *ip = ipp;
+ PDHCP_ADAPTER Adapter = AdapterFindInfo(ip);
time_t cur_time;
time(&cur_time);
@@ -1113,7 +1111,19 @@
ip->client->state = S_INIT;
add_timeout(cur_time + ip->client->config->retry_interval, state_init,
ip);
- /* XXX Take any failure actions necessary */
+
+ if (!Adapter->NteContext)
+ {
+ /* Generate an automatic private address */
+ 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
+ htonl(0xFFFF0000), //255.255.0.0
+ Adapter->IfMib.dwIndex,
+ &Adapter->NteContext,
+ &Adapter->NteInstance);
+ }
}
void
Modified: trunk/reactos/dll/win32/dhcpcsvc/include/rosdhcp.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/dhcpcsvc/include…
==============================================================================
--- trunk/reactos/dll/win32/dhcpcsvc/include/rosdhcp.h [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/dhcpcsvc/include/rosdhcp.h [iso-8859-1] Fri Jul 23 21:57:08
2010
@@ -18,9 +18,9 @@
#undef IGNORE
#undef ACCEPT
#undef PREFER
-#define DHCP_DISCOVER_INTERVAL 15
-#define DHCP_REBOOT_TIMEOUT 300
-#define DHCP_PANIC_TIMEOUT DHCP_REBOOT_TIMEOUT * 3
+#define DHCP_DISCOVER_INTERVAL 5
+#define DHCP_REBOOT_TIMEOUT 10
+#define DHCP_PANIC_TIMEOUT 20
#define DHCP_BACKOFF_MAX 300
#define DHCP_DEFAULT_LEASE_TIME 43200 /* 12 hours */
#define _PATH_DHCLIENT_PID
"\\systemroot\\system32\\drivers\\etc\\dhclient.pid"