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 */
|
||||
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
|
||||
{
|
||||
|
@ -2304,7 +2313,7 @@ InitializeTcpipBasicDlgCtrls(
|
|||
/* set current hostmask */
|
||||
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 */
|
||||
SendDlgItemMessageA(hwndDlg, IDC_DEFGATEWAY, IPM_SETADDRESS, 0, (LPARAM)pCurSettings->Gw->IpAddress);
|
||||
|
@ -3211,6 +3220,44 @@ INetCfgComponentControl_fnApplyRegistryChanges(
|
|||
}
|
||||
}
|
||||
|
||||
if (pOldConfig->Gw)
|
||||
{
|
||||
dwSize = 0;
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (pCurrentConfig->Gw)
|
||||
{
|
||||
MIB_IPFORWARDROW RouterMib;
|
||||
ZeroMemory(&RouterMib, sizeof(MIB_IPFORWARDROW));
|
||||
|
||||
RouterMib.dwForwardMetric1 = 1;
|
||||
RouterMib.dwForwardIfIndex = pOldConfig->Index;
|
||||
RouterMib.dwForwardNextHop = htonl(pCurrentConfig->Gw->IpAddress);
|
||||
|
||||
//TODO
|
||||
// add multiple gw addresses when required
|
||||
|
||||
if (CreateIpForwardEntry(&RouterMib) == NO_ERROR)
|
||||
{
|
||||
pStr = CreateMultiSzString(pCurrentConfig->Gw, IPADDR, &dwSize, FALSE);
|
||||
if(pStr)
|
||||
{
|
||||
|
@ -3225,6 +3272,12 @@ INetCfgComponentControl_fnApplyRegistryChanges(
|
|||
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)
|
||||
{
|
||||
|
@ -3242,7 +3295,7 @@ INetCfgComponentControl_fnApplyRegistryChanges(
|
|||
}
|
||||
RegCloseKey(hKey);
|
||||
}
|
||||
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue