Subject: winex/dlls/iphlpapi ifenum.c,1.5,1.6Update of /var/lib/cvsd/cvsroot/winex/dlls/iphlpapi
In directory agravaine:/tmp/cvs-serv15433/dlls/iphlpapi
Modified Files:
ifenum.c
Log Message:
- fix check for space required on SIOCGIFCONF to support MacOS X
- filter out no-ip addresses when building ip address table
Index: ifenum.c
===================================================================
RCS file: /var/lib/cvsd/cvsroot/winex/dlls/iphlpapi/ifenum.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- ifenum.c 30 Mar 2007 20:11:02 -0000 1.5
+++ ifenum.c 30 Mar 2007 20:17:57 -0000 1.6
@@ -673,14 +673,16 @@
int ioctlRet = 0;
DWORD guessedNumAddresses = 0, numAddresses = 0;
caddr_t ifPtr;
+ int lastlen;
ret = NO_ERROR;
ifc->ifc_len = 0;
ifc->ifc_buf = NULL;
/* there is no way to know the interface count beforehand,
so we need to loop again and again upping our max each time
- until returned < max */
+ until returned is constant across 2 calls */
do {
+ lastlen = ifc->ifc_len;
HeapFree(GetProcessHeap(), 0, ifc->ifc_buf);
if (guessedNumAddresses == 0)
guessedNumAddresses = INITIAL_INTERFACES_ASSUMED;
@@ -689,13 +691,16 @@
ifc->ifc_len = sizeof(struct ifreq) * guessedNumAddresses;
ifc->ifc_buf = HeapAlloc(GetProcessHeap(), 0, ifc->ifc_len);
ioctlRet = ioctl(fd, SIOCGIFCONF, ifc);
- } while (ioctlRet == 0 &&
- ifc->ifc_len == (sizeof(struct ifreq) * guessedNumAddresses));
+ } while ((ioctlRet == 0) && (ifc->ifc_len != lastlen));
if (ioctlRet == 0) {
ifPtr = ifc->ifc_buf;
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);
}
}
@@ -751,6 +756,11 @@
while (!ret && ifPtr && ifPtr < ifc.ifc_buf + ifc.ifc_len) {
struct ifreq *ifr = (struct ifreq *)ifPtr;
+ ifPtr += ifreq_len(ifr);
+
+ if (ifr->ifr_addr.sa_family != AF_INET)
+ continue;
+
ret = getInterfaceIndexByName(ifr->ifr_name,
&(*ppIpAddrTable)->table[i].dwIndex);
memcpy(&(*ppIpAddrTable)->table[i].dwAddr, ifr->ifr_addr.sa_data + 2,
@@ -769,7 +779,6 @@
(*ppIpAddrTable)->table[i].unused1 = 0;
(*ppIpAddrTable)->table[i].wType = 0;
- ifPtr += ifreq_len(ifr);
i++;
}
}
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.