Author: janderwald
Date: Fri Oct 17 15:01:58 2008
New Revision: 36799
URL:
http://svn.reactos.org/svn/reactos?rev=36799&view=rev
Log:
* Store more settings in registry
Modified:
trunk/reactos/base/services/dhcp/dhclient.c
Modified: trunk/reactos/base/services/dhcp/dhclient.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/services/dhcp/dhclien…
==============================================================================
--- trunk/reactos/base/services/dhcp/dhclient.c [iso-8859-1] (original)
+++ trunk/reactos/base/services/dhcp/dhclient.c [iso-8859-1] Fri Oct 17 15:01:58 2008
@@ -489,7 +489,16 @@
}
void setup_adapter( PDHCP_ADAPTER Adapter, struct client_lease *new_lease ) {
+ CHAR Buffer[200] =
"SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters\\Interfaces\\";
struct iaddr netmask;
+ HKEY hkey;
+ int i;
+ DWORD dwEnableDHCP;
+
+ strcat(Buffer, Adapter->DhclientInfo.name);
+ if (RegOpenKeyExA(HKEY_LOCAL_MACHINE, Buffer, 0, KEY_WRITE, &hkey) !=
ERROR_SUCCESS)
+ hkey = NULL;
+
if( Adapter->NteContext )
DeleteIPAddress( Adapter->NteContext );
@@ -501,13 +510,27 @@
memcpy( netmask.iabuf,
new_lease->options[DHO_SUBNET_MASK].data,
new_lease->options[DHO_SUBNET_MASK].len );
-
Status = AddIPAddress
( *((ULONG*)new_lease->address.iabuf),
*((ULONG*)netmask.iabuf),
Adapter->IfMib.dwIndex,
&Adapter->NteContext,
&Adapter->NteInstance );
+ if (hkey) {
+ RegSetValueExA(hkey, "DhcpIPAddress", 0, REG_SZ,
(LPBYTE)new_lease->address.iabuf, strlen(new_lease->address.iabuf)+1);
+ Buffer[0] = '\0';
+ for(i = 0; i < new_lease->options[DHO_SUBNET_MASK].len; i++)
+ {
+ sprintf(&Buffer[strlen(Buffer)], "%u",
new_lease->options[DHO_SUBNET_MASK].data[i]);
+ if (i + 1 < new_lease->options[DHO_SUBNET_MASK].len)
+ 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));
+ }
if( !NT_SUCCESS(Status) )
warning("AddIPAddress: %lx\n", Status);
@@ -536,7 +559,22 @@
warning("CreateIpForwardEntry: %lx\n", Status);
else
old_default_route = RouterMib.dwForwardNextHop;
+
+ if (hkey) {
+ Buffer[0] = '\0';
+ for(i = 0; i < new_lease->options[DHO_ROUTERS].len; i++)
+ {
+ sprintf(&Buffer[strlen(Buffer)], "%u",
new_lease->options[DHO_ROUTERS].data[i]);
+ if (i + 1 < new_lease->options[DHO_ROUTERS].len)
+ 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);
+ }
}
+
+ if (hkey)
+ RegCloseKey(hkey);
}