iphlpapi: Use the dst sa_family for the netmask too.

Signed-off-by: Stefan Dösinger <stefan@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Stefan Dösinger 2020-04-12 14:24:56 +02:00 committed by Alexandre Julliard
parent 7f4beb0883
commit 4932eec313
1 changed files with 9 additions and 2 deletions

View File

@ -1508,6 +1508,7 @@ DWORD WINAPI AllocateAndGetIpForwardTableFromStack(PMIB_IPFORWARDTABLE *ppIpForw
for (next = buf; next < lim; next += rtm->rtm_msglen) for (next = buf; next < lim; next += rtm->rtm_msglen)
{ {
int i; int i;
sa_family_t dst_family = AF_UNSPEC;
rtm = (struct rt_msghdr *)next; rtm = (struct rt_msghdr *)next;
@ -1551,7 +1552,10 @@ DWORD WINAPI AllocateAndGetIpForwardTableFromStack(PMIB_IPFORWARDTABLE *ppIpForw
if (sa->sa_len == 0) { if (sa->sa_len == 0) {
addr = 0; addr = 0;
}else { }else {
switch(sa->sa_family) { /* Apple's netstat prints the netmask together with the destination
* and only looks at the destination's address family. The netmask's
* sa_family sometimes contains the non-existent value 0xff. */
switch(i == RTA_NETMASK ? dst_family : sa->sa_family) {
case AF_INET: { case AF_INET: {
struct sockaddr_in *sin = (struct sockaddr_in *)sa; struct sockaddr_in *sin = (struct sockaddr_in *)sa;
addr = sin->sin_addr.s_addr; addr = sin->sin_addr.s_addr;
@ -1575,7 +1579,10 @@ DWORD WINAPI AllocateAndGetIpForwardTableFromStack(PMIB_IPFORWARDTABLE *ppIpForw
switch (i) switch (i)
{ {
case RTA_DST: row.dwForwardDest = addr; break; case RTA_DST:
row.dwForwardDest = addr;
dst_family = sa->sa_family;
break;
case RTA_GATEWAY: row.dwForwardNextHop = addr; break; case RTA_GATEWAY: row.dwForwardNextHop = addr; break;
case RTA_NETMASK: row.dwForwardMask = addr; break; case RTA_NETMASK: row.dwForwardMask = addr; break;
default: default: