impoved debugging and operation of interface detection

(since it has suddenly decided to fail)
This commit is contained in:
gardners 2012-05-03 17:15:05 +09:30
parent 26ef52cf99
commit 82ca3dde5d
2 changed files with 6 additions and 1 deletions

3
lsif.c
View File

@ -74,6 +74,7 @@ int lsif(void)
/* Get a socket handle. */
sck = socket(PF_INET, SOCK_DGRAM, 0);
if(sck < 0) {
WHY("Failed to gt socket handle to list addresses");
return 1;
}
@ -81,12 +82,14 @@ int lsif(void)
ifc.ifc_len = sizeof(buf);
ifc.ifc_buf = buf;
if(ioctl(sck, SIOCGIFCONF, &ifc) < 0) {
WHY("Failed to read interface list");
return 1;
}
/* Iterate through the list of interfaces. */
ifr = ifc.ifc_req;
nInterfaces = ifc.ifc_len / sizeof(struct ifreq);
WHYF("Examining %d interfaces",nInterfaces);
for(i = 0; i < nInterfaces; i++) {
item = &ifr[i];

View File

@ -606,11 +606,13 @@ int overlay_interface_discover()
}
}
freeifaddrs(ifaddr);
#else
#endif
#ifdef ANDROID
/* Use alternative linux-only method to find and register interfaces. */
lsif();
#else
#ifdef HAVE_IFADDRS_H
#else
#error Don't know how to get interface list on this platform
#endif
#endif