mirror of
https://github.com/reactos/reactos.git
synced 2024-08-28 22:28:36 +00:00
- Delete Gateway Address from TcpipSettings when the gateway has been removed
- Correctly check if there is Gateway set when initializing - Delete all old routes when applying changes - Add new gateway when applying changes svn path=/trunk/; revision=37059
This commit is contained in:
parent
8d12e8d2cd
commit
ad83e0cde9
|
@ -2174,6 +2174,15 @@ StoreTcpipBasicSettings(
|
||||||
/* store default gateway */
|
/* store default gateway */
|
||||||
This->pCurrentConfig->Gw->IpAddress = dwIpAddr;
|
This->pCurrentConfig->Gw->IpAddress = dwIpAddr;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (This->pCurrentConfig->Gw)
|
||||||
|
{
|
||||||
|
IP_ADDR * pNextGw = This->pCurrentConfig->Gw->Next;
|
||||||
|
CoTaskMemFree(This->pCurrentConfig->Gw);
|
||||||
|
This->pCurrentConfig->Gw = pNextGw;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -2304,7 +2313,7 @@ InitializeTcpipBasicDlgCtrls(
|
||||||
/* set current hostmask */
|
/* set current hostmask */
|
||||||
SendDlgItemMessageA(hwndDlg, IDC_SUBNETMASK, IPM_SETADDRESS, 0, (LPARAM)pCurSettings->Ip->u.Subnetmask);
|
SendDlgItemMessageA(hwndDlg, IDC_SUBNETMASK, IPM_SETADDRESS, 0, (LPARAM)pCurSettings->Ip->u.Subnetmask);
|
||||||
}
|
}
|
||||||
if (pCurSettings->Gw->IpAddress)
|
if (pCurSettings->Gw && pCurSettings->Gw->IpAddress)
|
||||||
{
|
{
|
||||||
/* set current gateway */
|
/* set current gateway */
|
||||||
SendDlgItemMessageA(hwndDlg, IDC_DEFGATEWAY, IPM_SETADDRESS, 0, (LPARAM)pCurSettings->Gw->IpAddress);
|
SendDlgItemMessageA(hwndDlg, IDC_DEFGATEWAY, IPM_SETADDRESS, 0, (LPARAM)pCurSettings->Gw->IpAddress);
|
||||||
|
@ -3211,38 +3220,82 @@ INetCfgComponentControl_fnApplyRegistryChanges(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pStr = CreateMultiSzString(pCurrentConfig->Gw, IPADDR, &dwSize, FALSE);
|
if (pOldConfig->Gw)
|
||||||
if(pStr)
|
|
||||||
{
|
{
|
||||||
RegSetValueExW(hKey, L"DefaultGateway", 0, REG_MULTI_SZ, (LPBYTE)pStr, dwSize);
|
dwSize = 0;
|
||||||
CoTaskMemFree(pStr);
|
if (GetIpForwardTable(NULL, &dwSize, FALSE) == ERROR_INSUFFICIENT_BUFFER)
|
||||||
|
{
|
||||||
|
DWORD Index;
|
||||||
|
PMIB_IPFORWARDTABLE pIpForwardTable = (PMIB_IPFORWARDTABLE)CoTaskMemAlloc(dwSize);
|
||||||
|
if (pIpForwardTable)
|
||||||
|
{
|
||||||
|
if (GetIpForwardTable(pIpForwardTable, &dwSize, FALSE) == NO_ERROR)
|
||||||
|
{
|
||||||
|
for (Index = 0; Index < pIpForwardTable->dwNumEntries; Index++)
|
||||||
|
{
|
||||||
|
if (pIpForwardTable->table[Index].dwForwardIfIndex == pOldConfig->Index)
|
||||||
|
{
|
||||||
|
DeleteIpForwardEntry(&pIpForwardTable->table[Index]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
CoTaskMemFree(pIpForwardTable);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pStr = CreateMultiSzString(pCurrentConfig->Gw, METRIC, &dwSize, FALSE);
|
if (pCurrentConfig->Gw)
|
||||||
if(pStr)
|
|
||||||
{
|
{
|
||||||
RegSetValueExW(hKey, L"DefaultGatewayMetric", 0, REG_MULTI_SZ, (LPBYTE)pStr, dwSize);
|
MIB_IPFORWARDROW RouterMib;
|
||||||
CoTaskMemFree(pStr);
|
ZeroMemory(&RouterMib, sizeof(MIB_IPFORWARDROW));
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!pCurrentConfig->Ns || pCurrentConfig->AutoconfigActive)
|
RouterMib.dwForwardMetric1 = 1;
|
||||||
{
|
RouterMib.dwForwardIfIndex = pOldConfig->Index;
|
||||||
RegSetValueExW(hKey, L"NameServer", 0, REG_SZ, (LPBYTE)L"", 1 * sizeof(WCHAR));
|
RouterMib.dwForwardNextHop = htonl(pCurrentConfig->Gw->IpAddress);
|
||||||
}
|
|
||||||
else
|
//TODO
|
||||||
{
|
// add multiple gw addresses when required
|
||||||
pStr = CreateMultiSzString(pCurrentConfig->Ns, IPADDR, &dwSize, TRUE);
|
|
||||||
if(pStr)
|
if (CreateIpForwardEntry(&RouterMib) == NO_ERROR)
|
||||||
{
|
{
|
||||||
RegSetValueExW(hKey, L"NameServer", 0, REG_SZ, (LPBYTE)pStr, dwSize);
|
pStr = CreateMultiSzString(pCurrentConfig->Gw, IPADDR, &dwSize, FALSE);
|
||||||
RegDeleteValueW(hKey, L"DhcpNameServer");
|
if(pStr)
|
||||||
CoTaskMemFree(pStr);
|
{
|
||||||
|
RegSetValueExW(hKey, L"DefaultGateway", 0, REG_MULTI_SZ, (LPBYTE)pStr, dwSize);
|
||||||
|
CoTaskMemFree(pStr);
|
||||||
|
}
|
||||||
|
|
||||||
|
pStr = CreateMultiSzString(pCurrentConfig->Gw, METRIC, &dwSize, FALSE);
|
||||||
|
if(pStr)
|
||||||
|
{
|
||||||
|
RegSetValueExW(hKey, L"DefaultGatewayMetric", 0, REG_MULTI_SZ, (LPBYTE)pStr, dwSize);
|
||||||
|
CoTaskMemFree(pStr);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
RegSetValueExW(hKey, L"DefaultGateway", 0, REG_MULTI_SZ, (LPBYTE)L"", 1 * sizeof(WCHAR));
|
||||||
|
RegSetValueExW(hKey, L"DefaultGatewayMetric", 0, REG_MULTI_SZ, (LPBYTE)L"\0", sizeof(WCHAR) * 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!pCurrentConfig->Ns || pCurrentConfig->AutoconfigActive)
|
||||||
|
{
|
||||||
|
RegSetValueExW(hKey, L"NameServer", 0, REG_SZ, (LPBYTE)L"", 1 * sizeof(WCHAR));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pStr = CreateMultiSzString(pCurrentConfig->Ns, IPADDR, &dwSize, TRUE);
|
||||||
|
if(pStr)
|
||||||
|
{
|
||||||
|
RegSetValueExW(hKey, L"NameServer", 0, REG_SZ, (LPBYTE)pStr, dwSize);
|
||||||
|
RegDeleteValueW(hKey, L"DhcpNameServer");
|
||||||
|
CoTaskMemFree(pStr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
RegCloseKey(hKey);
|
||||||
}
|
}
|
||||||
RegCloseKey(hKey);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue