Commit 00c97a61 authored by Juan Lang's avatar Juan Lang Committed by Alexandre Julliard

iphlpapi: Default to a default gateway when choosing the best route.

parent 5cc527d3
...@@ -853,7 +853,7 @@ DWORD WINAPI GetBestRoute(DWORD dwDestAddr, DWORD dwSourceAddr, PMIB_IPFORWARDRO ...@@ -853,7 +853,7 @@ DWORD WINAPI GetBestRoute(DWORD dwDestAddr, DWORD dwSourceAddr, PMIB_IPFORWARDRO
return ERROR_INVALID_PARAMETER; return ERROR_INVALID_PARAMETER;
ret = AllocateAndGetIpForwardTableFromStack(&table, FALSE, GetProcessHeap(), 0); ret = AllocateAndGetIpForwardTableFromStack(&table, FALSE, GetProcessHeap(), 0);
if (table && !ret) { if (!ret) {
DWORD ndx, matchedBits, matchedNdx = table->dwNumEntries; DWORD ndx, matchedBits, matchedNdx = table->dwNumEntries;
for (ndx = 0, matchedBits = 0; ndx < table->dwNumEntries; ndx++) { for (ndx = 0, matchedBits = 0; ndx < table->dwNumEntries; ndx++) {
...@@ -869,6 +869,11 @@ DWORD WINAPI GetBestRoute(DWORD dwDestAddr, DWORD dwSourceAddr, PMIB_IPFORWARDRO ...@@ -869,6 +869,11 @@ DWORD WINAPI GetBestRoute(DWORD dwDestAddr, DWORD dwSourceAddr, PMIB_IPFORWARDRO
matchedBits = numShifts; matchedBits = numShifts;
matchedNdx = ndx; matchedNdx = ndx;
} }
else if (!matchedBits && table->table[ndx].dwForwardType ==
MIB_IPROUTE_TYPE_INDIRECT) {
/* default to a default gateway */
matchedNdx = ndx;
}
} }
} }
if (matchedNdx < table->dwNumEntries) { if (matchedNdx < table->dwNumEntries) {
...@@ -881,8 +886,6 @@ DWORD WINAPI GetBestRoute(DWORD dwDestAddr, DWORD dwSourceAddr, PMIB_IPFORWARDRO ...@@ -881,8 +886,6 @@ DWORD WINAPI GetBestRoute(DWORD dwDestAddr, DWORD dwSourceAddr, PMIB_IPFORWARDRO
} }
HeapFree(GetProcessHeap(), 0, table); HeapFree(GetProcessHeap(), 0, table);
} }
else if (!ret)
ret = ERROR_OUTOFMEMORY;
TRACE("returning %d\n", ret); TRACE("returning %d\n", ret);
return ret; return ret;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment