We ran into an obscure problem with iphlpapi that I'd like to get help with. When you boot a linux box without an ethernet connection, and eth0 configuration fails, GetAdaptersInfo does not return MAC address info for eth0.
The problem seems to be that enumerateInterfaces (in dlls/iphlpapi/ifenum.c) doesn't create a record for eth0, because SIOCGIFCONF doesn't return one. Then when GetAdaptersInfo (in dlls/iphlpapi/iphlpapi_main.c) is looping through the interfaces, eth0 isn't there so it doesn't call getInterfacePhysicalByIndex to get the MAC address.
I verified that if I hack an eth0 entry into the table built by enumerateInterfaces, the call to getInterfacePhysicalByIndex works just fine. So the problem is simply a disconnect between what enumerateInterfaces is scanning and what GetAdaptersInfo is trying to scan.
Near as I can tell (and I am no networking guru by any stretch) GetAdaptersInfo is supposed to return MAC info for eth0, even if eth0 has no IP address. Near as I can tell too Windows does return MAC info in this situation. So this looks, again near as I can tell %), like a Wine bug.
Is it a wine bug? Any suggestions for a fix? ... mo
PS: I cc'd Juan Lang who is noted as the author of the code. I hope that isn't bad etiquette...?
Hi Michael,
When you boot a linux box without an ethernet connection, and eth0 configuration fails, GetAdaptersInfo does not return MAC address info for eth0. The problem seems to be that enumerateInterfaces (in dlls/iphlpapi/ifenum.c) doesn't create a record for eth0, because SIOCGIFCONF doesn't return one.
Mmm. Yeah, I think an alternative to SIOCGIFCONF might be the thing. getifaddrs is pretty nice, and it has the additional advantage that it can support IPv6, which SIOCGIFCONF does not. I'm not certain whether it returns "down" interfaces or not, but we can hope so. Unfortunately it's not universally available; when I wrote this code at least, it wasn't around on Debian, though that's since changed. So a configure check and an ifdef would probably be in order.
Near as I can tell (and I am no networking guru by any stretch) GetAdaptersInfo is supposed to return MAC info for eth0, even if eth0 has no IP address.
You're correct, this is a Wine bug.
PS: I cc'd Juan Lang who is noted as the author of the code. I hope that isn't bad etiquette...?
I prefer it in fact. --Juan
__________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com
Juan,
When you boot a linux box without an ethernet connection, and eth0 configuration fails, GetAdaptersInfo does not return MAC address info for eth0. The problem seems to be that enumerateInterfaces (in dlls/iphlpapi/ifenum.c) doesn't create a record for eth0, because SIOCGIFCONF doesn't return one.
Mmm. Yeah, I think an alternative to SIOCGIFCONF might be the thing. getifaddrs is pretty nice, and it has the additional advantage that it can support IPv6, which SIOCGIFCONF does not. I'm not certain whether it returns "down" interfaces or not, but we can hope so. Unfortunately it's
Dang. It doesn't work for down devices. When I run strace on a program that uses getifaddrs, the socket is opened with IPROTO_IP:
socket(PF_INET, SOCK_DGRAM, IPPROTO_IP) = 14 ioctl(14, 0x8912, 0x2084d3a8) = 0 ioctl(14, 0x8912, 0x2084d3a8) = 0 ioctl(14, 0x8913, 0x7804ab38) = 0 ioctl(14, 0x891b, 0x7804ab38) = 0 ioctl(14, 0x8919, 0x7804ab38) = 0 ioctl(14, 0x8913, 0x7804ab58) = 0 ioctl(14, 0x891b, 0x7804ab58) = 0 ioctl(14, 0x8919, 0x7804ab58) = 0
Could it be that eth0 doesn't appear because it isn't configured for IP... that is, has no IP address? I can't figure out what these ioctls are either...?
I'll keep digging, but if you have any clues I would love to hear them! I am shuffling in the dark here... mo
PS: I've attached a diff file that implements getifaddrs for our Wine, 20050419. I didn't do the "configure" step, but put HAVE_IFADDRS_H in. Your code is left in if HAVE_IFADDRS_H is not defined. If you want, take it, check it out and adapt it to the current wine.
Dang. It doesn't work for down devices. When I run strace on a program that uses getifaddrs, the socket is opened with IPROTO_IP:
socket(PF_INET, SOCK_DGRAM, IPPROTO_IP) = 14 ioctl(14, 0x8912, 0x2084d3a8) = 0
That's SIOCGIFCONF. So it looks like getifaddrs isn't doing anything different than SIOCGIFCONF, at least on Linux.
I can't figure out what these ioctls are either...?
Take a look at <linux/sockios.h>
I'll keep digging, but if you have any clues I would love to hear them!
ifconfig -a reports down interfaces. It may just process /proc/net/dev.
--Juan
__________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com