Commit patches from bugboy, fixing bug 2392.

svn path=/trunk/; revision=35669
This commit is contained in:
Art Yerkes 2008-08-26 13:28:44 +00:00
parent 6c68a50dd4
commit 7e88d259cb
2 changed files with 29 additions and 4 deletions

View file

@ -238,6 +238,7 @@ InternTCPIPSettings(HWND Dlg, PTCPIP_PROPERTIES_DATA DlgData) {
BOOL SetDnsByDhcp; BOOL SetDnsByDhcp;
TCHAR pszRegKey[MAX_PATH]; TCHAR pszRegKey[MAX_PATH];
const char *AddressString; const char *AddressString;
char emptyString[]="\0";
DWORD Address = 0; DWORD Address = 0;
LONG rc; LONG rc;
HKEY hKey = NULL; HKEY hKey = NULL;
@ -282,7 +283,7 @@ InternTCPIPSettings(HWND Dlg, PTCPIP_PROPERTIES_DATA DlgData) {
goto cleanup; goto cleanup;
if (DlgData->Dns1 == INADDR_NONE) if (DlgData->Dns1 == INADDR_NONE)
{ {
rc = RegDeleteValue(hKey, _T("NameServer")); rc = RegSetValueExA(hKey, "NameServer",0, REG_SZ, (const BYTE*)emptyString, strlen(emptyString) + 1);
if (rc != ERROR_SUCCESS && rc != ERROR_FILE_NOT_FOUND) if (rc != ERROR_SUCCESS && rc != ERROR_FILE_NOT_FOUND)
goto cleanup; goto cleanup;
} }
@ -445,6 +446,7 @@ LoadDataFromInfo(PTCPIP_PROPERTIES_DATA DlgData, IP_ADAPTER_INFO *Info)
char Dns[MAX_PATH]; char Dns[MAX_PATH];
DWORD Size; DWORD Size;
DWORD Type; DWORD Type;
DWORD dwError;
char *NextDnsServer; char *NextDnsServer;
DlgData->AdapterName = Info->AdapterName; DlgData->AdapterName = Info->AdapterName;
@ -469,7 +471,15 @@ LoadDataFromInfo(PTCPIP_PROPERTIES_DATA DlgData, IP_ADAPTER_INFO *Info)
swprintf(RegKey, swprintf(RegKey,
L"SYSTEM\\CurrentControlSet\\Services\\TCPIP\\Parameters\\Interfaces\\%S", L"SYSTEM\\CurrentControlSet\\Services\\TCPIP\\Parameters\\Interfaces\\%S",
Info->AdapterName); Info->AdapterName);
if (ERROR_SUCCESS == RegOpenKeyW(HKEY_LOCAL_MACHINE, RegKey, &hKey)) { dwError = RegOpenKeyW(HKEY_LOCAL_MACHINE, RegKey, &hKey);
if (dwError != ERROR_SUCCESS)
{
/* Try and fall back on the NameServer in Parameters */
swprintf(RegKey,
L"SYSTEM\\CurrentControlSet\\Services\\TCPIP\\Parameters\\");
}
dwError = RegOpenKeyW(HKEY_LOCAL_MACHINE, RegKey, &hKey);
if (ERROR_SUCCESS == dwError) {
Size = sizeof(Dns); Size = sizeof(Dns);
RegQueryValueExA(hKey, "NameServer", NULL, &Type, (BYTE *)Dns, RegQueryValueExA(hKey, "NameServer", NULL, &Type, (BYTE *)Dns,
&Size); &Size);

View file

@ -88,6 +88,19 @@ DWORD WINAPI AddIPAddress(IPAddr Address, IPMask Netmask, DWORD IfIndex, PULONG
return RtlNtStatusToDosError(addIPAddress(Address, Netmask, IfIndex, NteContext, NteInstance)); return RtlNtStatusToDosError(addIPAddress(Address, Netmask, IfIndex, NteContext, NteInstance));
} }
DWORD getInterfaceGatewayByIndex(DWORD index)
{
DWORD ndx, retVal = 0, numRoutes = getNumRoutes();
RouteTable *table = getRouteTable();
for (ndx = 0; ndx < numRoutes; ndx++)
{
if ((table->routes[ndx].ifIndex == (index - 1)) && (table->routes[ndx].dest == 0))
retVal = table->routes[ndx].gateway;
}
HeapFree(GetProcessHeap(), 0, table);
return retVal;
}
/****************************************************************** /******************************************************************
* AllocateAndGetIfTableFromStack (IPHLPAPI.@) * AllocateAndGetIfTableFromStack (IPHLPAPI.@)
@ -640,6 +653,8 @@ DWORD WINAPI GetAdaptersInfo(PIP_ADAPTER_INFO pAdapterInfo, PULONG pOutBufLen)
ptr->IpAddressList.IpAddress.String); ptr->IpAddressList.IpAddress.String);
toIPAddressString(getInterfaceMaskByIndex(table->indexes[ndx]), toIPAddressString(getInterfaceMaskByIndex(table->indexes[ndx]),
ptr->IpAddressList.IpMask.String); ptr->IpAddressList.IpMask.String);
toIPAddressString(getInterfaceGatewayByIndex(table->indexes[ndx]),
ptr->GatewayList.IpAddress.String);
getDhcpInfoForAdapter(table->indexes[ndx], &dhcpEnabled, getDhcpInfoForAdapter(table->indexes[ndx], &dhcpEnabled,
&dhcpServer, &ptr->LeaseObtained, &dhcpServer, &ptr->LeaseObtained,
&ptr->LeaseExpires); &ptr->LeaseExpires);
@ -1160,7 +1175,7 @@ DWORD WINAPI GetIpForwardTable(PMIB_IPFORWARDTABLE pIpForwardTable, PULONG pdwSi
pIpForwardTable->dwNumEntries = table->numRoutes; pIpForwardTable->dwNumEntries = table->numRoutes;
for (ndx = 0; ndx < numRoutes; ndx++) { for (ndx = 0; ndx < numRoutes; ndx++) {
pIpForwardTable->table[ndx].dwForwardIfIndex = pIpForwardTable->table[ndx].dwForwardIfIndex =
table->routes[ndx].ifIndex; table->routes[ndx].ifIndex + 1;
pIpForwardTable->table[ndx].dwForwardDest = pIpForwardTable->table[ndx].dwForwardDest =
table->routes[ndx].dest; table->routes[ndx].dest;
pIpForwardTable->table[ndx].dwForwardMask = pIpForwardTable->table[ndx].dwForwardMask =
@ -1190,7 +1205,7 @@ DWORD WINAPI GetIpForwardTable(PMIB_IPFORWARDTABLE pIpForwardTable, PULONG pdwSi
sizeof(MIB_IPFORWARDROW), IpForwardTableSorter); sizeof(MIB_IPFORWARDROW), IpForwardTableSorter);
ret = NO_ERROR; ret = NO_ERROR;
} }
free(table); HeapFree(GetProcessHeap(), 0, table);
} }
else else
ret = ERROR_OUTOFMEMORY; ret = ERROR_OUTOFMEMORY;