iphlpapi: Filter out no-ip addresses when building ip address table.
This commit is contained in:
parent
a91d69190e
commit
1e263e663b
|
@ -696,7 +696,11 @@ static DWORD enumIPAddresses(PDWORD pcAddresses, struct ifconf *ifc)
|
||||||
if (ioctlRet == 0) {
|
if (ioctlRet == 0) {
|
||||||
ifPtr = ifc->ifc_buf;
|
ifPtr = ifc->ifc_buf;
|
||||||
while (ifPtr && ifPtr < ifc->ifc_buf + ifc->ifc_len) {
|
while (ifPtr && ifPtr < ifc->ifc_buf + ifc->ifc_len) {
|
||||||
numAddresses++;
|
struct ifreq *ifr = (struct ifreq *)ifPtr;
|
||||||
|
|
||||||
|
if (ifr->ifr_addr.sa_family == AF_INET)
|
||||||
|
numAddresses++;
|
||||||
|
|
||||||
ifPtr += ifreq_len((struct ifreq *)ifPtr);
|
ifPtr += ifreq_len((struct ifreq *)ifPtr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -752,6 +756,11 @@ DWORD getIPAddrTable(PMIB_IPADDRTABLE *ppIpAddrTable, HANDLE heap, DWORD flags)
|
||||||
while (!ret && ifPtr && ifPtr < ifc.ifc_buf + ifc.ifc_len) {
|
while (!ret && ifPtr && ifPtr < ifc.ifc_buf + ifc.ifc_len) {
|
||||||
struct ifreq *ifr = (struct ifreq *)ifPtr;
|
struct ifreq *ifr = (struct ifreq *)ifPtr;
|
||||||
|
|
||||||
|
ifPtr += ifreq_len(ifr);
|
||||||
|
|
||||||
|
if (ifr->ifr_addr.sa_family != AF_INET)
|
||||||
|
continue;
|
||||||
|
|
||||||
ret = getInterfaceIndexByName(ifr->ifr_name,
|
ret = getInterfaceIndexByName(ifr->ifr_name,
|
||||||
&(*ppIpAddrTable)->table[i].dwIndex);
|
&(*ppIpAddrTable)->table[i].dwIndex);
|
||||||
memcpy(&(*ppIpAddrTable)->table[i].dwAddr, ifr->ifr_addr.sa_data + 2,
|
memcpy(&(*ppIpAddrTable)->table[i].dwAddr, ifr->ifr_addr.sa_data + 2,
|
||||||
|
@ -770,7 +779,6 @@ DWORD getIPAddrTable(PMIB_IPADDRTABLE *ppIpAddrTable, HANDLE heap, DWORD flags)
|
||||||
|
|
||||||
(*ppIpAddrTable)->table[i].unused1 = 0;
|
(*ppIpAddrTable)->table[i].unused1 = 0;
|
||||||
(*ppIpAddrTable)->table[i].wType = 0;
|
(*ppIpAddrTable)->table[i].wType = 0;
|
||||||
ifPtr += ifreq_len(ifr);
|
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue