Author: janderwald
Date: Tue Oct 28 10:31:36 2008
New Revision: 37041
URL:
http://svn.reactos.org/svn/reactos?rev=37041&view=rev
Log:
- Store NTEContext for IPAddress
- Call DeleteIPAddress and AddIPAddress for adapters when applying changes
Modified:
trunk/reactos/dll/win32/netcfgx/tcpipconf_notify.c
Modified: trunk/reactos/dll/win32/netcfgx/tcpipconf_notify.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/netcfgx/tcpipcon…
==============================================================================
--- trunk/reactos/dll/win32/netcfgx/tcpipconf_notify.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/netcfgx/tcpipconf_notify.c [iso-8859-1] Tue Oct 28 10:31:36
2008
@@ -34,6 +34,7 @@
DWORD Subnetmask;
USHORT Metric;
}u;
+ ULONG NTEContext;
struct tagIP_ADDR * Next;
}IP_ADDR;
@@ -115,6 +116,7 @@
HRESULT InitializeTcpipBasicDlgCtrls(HWND hwndDlg, TcpipSettings * pCurSettings);
VOID InsertColumnToListView(HWND hDlgCtrl, UINT ResId, UINT SubItem, UINT Size);
INT_PTR StoreTcpipBasicSettings(HWND hwndDlg, TcpipConfNotifyImpl * This, BOOL bApply);
+HRESULT Initialize(TcpipConfNotifyImpl * This);
VOID
DisplayError(UINT ResTxt, UINT ResTitle, UINT Type)
@@ -2373,6 +2375,7 @@
if (Type == SUBMASK)
{
pNew->u.Subnetmask = GetIpAddressFromStringA(pCurrent->IpMask.String);
+ pNew->NTEContext = pCurrent->Context;
}
else if (Type == METRIC)
{
@@ -2632,6 +2635,7 @@
HKEY hKey;
DWORD dwSize;
+
This->pCurrentConfig->pDNS = (TcpipAdvancedDNSDlgSettings*)
CoTaskMemAlloc(sizeof(TcpipAdvancedDNSDlgSettings));
if (!This->pCurrentConfig->pDNS)
return E_FAIL;
@@ -2748,7 +2752,7 @@
HRESULT
-InitializeTcpipBasicDlg(TcpipConfNotifyImpl * This)
+Initialize(TcpipConfNotifyImpl * This)
{
DWORD dwSize;
WCHAR szBuffer[50];
@@ -2876,7 +2880,7 @@
HRESULT hr;
TcpipConfNotifyImpl * This = (TcpipConfNotifyImpl*)iface;
- hr = InitializeTcpipBasicDlg(This);
+ hr = Initialize(This);
if (FAILED(hr))
return hr;
@@ -3092,24 +3096,37 @@
LPOLESTR pStr;
DWORD dwSize;
WCHAR szBuffer[200];
+ TcpipSettings * pCurrentConfig, *pOldConfig;
+ ULONG NTEInstance;
TcpipConfNotifyImpl * This = impl_from_INetCfgComponentControl(iface);
+ pCurrentConfig = This->pCurrentConfig;
+ This->pCurrentConfig = NULL;
+
+ if (FAILED(Initialize(This)))
+ {
+ This->pCurrentConfig = pCurrentConfig;
+ return E_FAIL;
+ }
+ pOldConfig = This->pCurrentConfig;
+ This->pCurrentConfig = pCurrentConfig;
+
//MessageBoxW(NULL, L"INetCfgComponentControl_fnApplyRegistryChanges",
NULL, MB_OK);
if (RegCreateKeyExW(hKey,
L"SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters", 0, NULL, 0,
KEY_WRITE, NULL, &hKey, NULL) == ERROR_SUCCESS)
{
- if (This->pCurrentConfig->pDNS)
- {
- RegSetValueExW(hKey, L"UseDomainNameDevolution", 0, REG_DWORD,
(LPBYTE)&This->pCurrentConfig->pDNS->UseDomainNameDevolution,
sizeof(DWORD));
- RegSetValueExW(hKey, L"SearchList", 0, REG_SZ,
(LPBYTE)This->pCurrentConfig->pDNS->szSearchList,
- (wcslen(This->pCurrentConfig->pDNS->szSearchList)+1) *
sizeof(WCHAR));
- }
- if (This->pCurrentConfig->pFilter)
+ if (pCurrentConfig->pDNS)
+ {
+ RegSetValueExW(hKey, L"UseDomainNameDevolution", 0, REG_DWORD,
(LPBYTE)&pCurrentConfig->pDNS->UseDomainNameDevolution, sizeof(DWORD));
+ RegSetValueExW(hKey, L"SearchList", 0, REG_SZ,
(LPBYTE)pCurrentConfig->pDNS->szSearchList,
+ (wcslen(pCurrentConfig->pDNS->szSearchList)+1) *
sizeof(WCHAR));
+ }
+ if (pCurrentConfig->pFilter)
{
RegSetValueExW(hKey, L"EnableSecurityFilters", 0, REG_DWORD,
-
(LPBYTE)&This->pCurrentConfig->pFilter->EnableSecurityFilters,
sizeof(DWORD));
+ (LPBYTE)&pCurrentConfig->pFilter->EnableSecurityFilters,
sizeof(DWORD));
}
RegCloseKey(hKey);
}
@@ -3122,7 +3139,7 @@
if (RegCreateKeyExW(HKEY_LOCAL_MACHINE, szBuffer, 0, NULL, 0, KEY_WRITE, NULL,
&hKey, NULL) == ERROR_SUCCESS)
{
- if (This->pCurrentConfig->pDNS)
+ if (pCurrentConfig->pDNS)
{
RegSetValueExW(hKey, L"RegisterAdapterName", 0, REG_DWORD,
(LPBYTE)&This->pCurrentConfig->pDNS->RegisterAdapterName, sizeof(DWORD));
RegSetValueExW(hKey, L"RegistrationEnabled", 0, REG_DWORD,
(LPBYTE)&This->pCurrentConfig->pDNS->RegistrationEnabled, sizeof(DWORD));
@@ -3130,60 +3147,78 @@
(wcslen(This->pCurrentConfig->pDNS->szDomain)+1) *
sizeof(WCHAR));
}
#if 0
- if (This->pCurrentConfig->pFilter)
- {
- if (This->pCurrentConfig->pFilter->szTCPAllowedPorts)
+ if (pCurrentConfig->pFilter)
+ {
+ if (pCurrentConfig->pFilter->szTCPAllowedPorts)
{
RegSetValueExW(hKey, L"TCPAllowedPorts", 0, REG_MULTI_SZ,
-
(LPBYTE)This->pCurrentConfig->pFilter->szTCPAllowedPorts,
- This->pCurrentConfig->pFilter->TCPSize);
- }
- if (This->pCurrentConfig->pFilter->szUDPAllowedPorts)
+ (LPBYTE)pCurrentConfig->pFilter->szTCPAllowedPorts,
+ pCurrentConfig->pFilter->TCPSize);
+ }
+ if (pCurrentConfig->pFilter->szUDPAllowedPorts)
{
RegSetValueExW(hKey, L"UDPAllowedPorts", 0, REG_MULTI_SZ,
-
(LPBYTE)This->pCurrentConfig->pFilter->szUDPAllowedPorts,
- This->pCurrentConfig->pFilter->UDPSize);
- }
- if (This->pCurrentConfig->pFilter->szRawIPAllowedProtocols)
+ (LPBYTE)pCurrentConfig->pFilter->szUDPAllowedPorts,
+ pCurrentConfig->pFilter->UDPSize);
+ }
+ if (pCurrentConfig->pFilter->szRawIPAllowedProtocols)
{
RegSetValueExW(hKey, L"RawIPAllowedProtocols", 0, REG_MULTI_SZ,
-
(LPBYTE)This->pCurrentConfig->pFilter->szRawIPAllowedProtocols,
- This->pCurrentConfig->pFilter->IPSize);
+ (LPBYTE)pCurrentConfig->pFilter->szRawIPAllowedProtocols,
+ pCurrentConfig->pFilter->IPSize);
}
}
#endif
- RegSetValueExW(hKey, L"EnableDHCP", 0, REG_DWORD,
(LPBYTE)&This->pCurrentConfig->DhcpEnabled, sizeof(DWORD));
- if (This->pCurrentConfig->DhcpEnabled)
+ RegSetValueExW(hKey, L"EnableDHCP", 0, REG_DWORD,
(LPBYTE)&pCurrentConfig->DhcpEnabled, sizeof(DWORD));
+ if (pCurrentConfig->DhcpEnabled)
{
RegSetValueExW(hKey, L"IPAddress", 0, REG_MULTI_SZ,
(LPBYTE)L"0.0.0.0\0", 9 * sizeof(WCHAR));
RegSetValueExW(hKey, L"SubnetMask", 0, REG_MULTI_SZ,
(LPBYTE)L"0.0.0.0\0", 9 * sizeof(WCHAR));
RegSetValueExW(hKey, L"DefaultGateway", 0, REG_MULTI_SZ,
(LPBYTE)L"\0", 2 * sizeof(WCHAR));
RegSetValueExW(hKey, L"DefaultGatewayMetric", 0, REG_MULTI_SZ,
(LPBYTE)L"\0", 2 * sizeof(WCHAR));
+ if (!pOldConfig->DhcpEnabled)
+ {
+ DeleteIPAddress(pOldConfig->Ip->NTEContext);
+ //FIXME
+ // start dhcp client service for the adapter
+ }
}
else
{
- pStr = CreateMultiSzString(This->pCurrentConfig->Ip, IPADDR,
&dwSize, FALSE);
- if(pStr)
- {
- RegSetValueExW(hKey, L"IPAddress", 0, REG_MULTI_SZ,
(LPBYTE)pStr, dwSize);
- CoTaskMemFree(pStr);
- }
-
- pStr = CreateMultiSzString(This->pCurrentConfig->Ip, SUBMASK,
&dwSize, FALSE);
- if(pStr)
- {
- RegSetValueExW(hKey, L"SubnetMask", 0, REG_MULTI_SZ,
(LPBYTE)pStr, dwSize);
- CoTaskMemFree(pStr);
- }
-
- pStr = CreateMultiSzString(This->pCurrentConfig->Gw, IPADDR,
&dwSize, FALSE);
+ if (!pOldConfig->DhcpEnabled)
+ {
+ DeleteIPAddress(pOldConfig->Ip->NTEContext);
+ //TODO
+ //delete multiple ip addresses when required
+ }
+
+ //TODO
+ // add multiple ip addresses when required
+ if (AddIPAddress(pCurrentConfig->Ip->IpAddress,
pCurrentConfig->Ip->u.Subnetmask, pCurrentConfig->Index,
&pCurrentConfig->Ip->NTEContext, &NTEInstance) == NO_ERROR)
+ {
+ pStr = CreateMultiSzString(pCurrentConfig->Ip, IPADDR, &dwSize,
FALSE);
+ if(pStr)
+ {
+ RegSetValueExW(hKey, L"IPAddress", 0, REG_MULTI_SZ,
(LPBYTE)pStr, dwSize);
+ CoTaskMemFree(pStr);
+ }
+
+ pStr = CreateMultiSzString(pCurrentConfig->Ip, SUBMASK, &dwSize,
FALSE);
+ if(pStr)
+ {
+ RegSetValueExW(hKey, L"SubnetMask", 0, REG_MULTI_SZ,
(LPBYTE)pStr, dwSize);
+ CoTaskMemFree(pStr);
+ }
+ }
+
+ pStr = CreateMultiSzString(pCurrentConfig->Gw, IPADDR, &dwSize,
FALSE);
if(pStr)
{
RegSetValueExW(hKey, L"DefaultGateway", 0, REG_MULTI_SZ,
(LPBYTE)pStr, dwSize);
CoTaskMemFree(pStr);
}
- pStr = CreateMultiSzString(This->pCurrentConfig->Gw, METRIC,
&dwSize, FALSE);
+ pStr = CreateMultiSzString(pCurrentConfig->Gw, METRIC, &dwSize,
FALSE);
if(pStr)
{
RegSetValueExW(hKey, L"DefaultGatewayMetric", 0, REG_MULTI_SZ,
(LPBYTE)pStr, dwSize);
@@ -3191,13 +3226,13 @@
}
}
- if (!This->pCurrentConfig->Ns ||
This->pCurrentConfig->AutoconfigActive)
+ if (!pCurrentConfig->Ns || pCurrentConfig->AutoconfigActive)
{
RegSetValueExW(hKey, L"NameServer", 0, REG_SZ,
(LPBYTE)L"", 1 * sizeof(WCHAR));
}
else
{
- pStr = CreateMultiSzString(This->pCurrentConfig->Ns, IPADDR,
&dwSize, TRUE);
+ pStr = CreateMultiSzString(pCurrentConfig->Ns, IPADDR, &dwSize,
TRUE);
if(pStr)
{
RegSetValueExW(hKey, L"NameServer", 0, REG_SZ, (LPBYTE)pStr,
dwSize);
@@ -3207,7 +3242,6 @@
}
RegCloseKey(hKey);
}
-
return S_OK;
}