[IPHLPAPI] Fix IcmpSendEcho output when host is not reachable

- Add missing error code to DDK/NDIS
- Fix error code in IP driver
- Patch MSAFD to reply correct WSA error code
- Fix IcmpSendEcho function
  - Fix returning error code in ICMP_ECHO_REPLY (see MSDN)
  - Fix returning host address (using GetBestInterface and GetIpAddrTable functions)
- Fix GetBestRoute function (it is used by GetBestInterface)

Relates to #318 and CORE-14241
This commit is contained in:
Stanislav Motylkov 2018-01-24 00:28:55 +03:00 committed by Ged Murphy
parent 3624c5d6fd
commit 63ad8a71c0
5 changed files with 68 additions and 14 deletions

View file

@ -767,18 +767,19 @@ DWORD WINAPI GetBestRoute(DWORD dwDestAddr, DWORD dwSourceAddr, PMIB_IPFORWARDRO
AllocateAndGetIpForwardTableFromStack(&table, FALSE, GetProcessHeap(), 0);
if (table) {
DWORD ndx, matchedBits, matchedNdx = 0;
DWORD ndx, minMaskSize, matchedNdx = 0;
for (ndx = 0, matchedBits = 0; ndx < table->dwNumEntries; ndx++) {
for (ndx = 0, minMaskSize = 255; ndx < table->dwNumEntries; ndx++) {
if ((dwDestAddr & table->table[ndx].dwForwardMask) ==
(table->table[ndx].dwForwardDest & table->table[ndx].dwForwardMask)) {
DWORD numShifts, mask;
DWORD hostMaskSize;
for (numShifts = 0, mask = table->table[ndx].dwForwardMask;
mask && !(mask & 1); mask >>= 1, numShifts++)
;
if (numShifts > matchedBits) {
matchedBits = numShifts;
if (!_BitScanForward(&hostMaskSize, ntohl(table->table[ndx].dwForwardMask)))
{
hostMaskSize = 32;
}
if (hostMaskSize < minMaskSize) {
minMaskSize = hostMaskSize;
matchedNdx = ndx;
}
}