iphlpapi: Default to a default gateway when choosing the best route.
This commit is contained in:
parent
5cc527d30d
commit
00c97a61bf
@ -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
|
|||||||
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
|
|||||||
}
|
}
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user