Re: HW address w/o connection in iphlpapi

2006-01-24 Thread most
> Really?  It works for me.  You mean boot with no link, or what?  I did
> that, and if_nameindex still returned eth0.

Right. if_nameindex does not return eth0 if I boot up without an ethernet
connection. Maybe this is a system dependent thing? I am running on a RH8
based system.

The if_nameindex code looked a little nicer, but a loop on
if_indextoname() is  not so bad.

- mo




Re: HW address w/o connection in iphlpapi

2006-01-24 Thread most
>> Wait. This works better than getifaddrs. It successfully returns info
>> for "down" devices on my RH8 based linux box, with my creaky old
>> wine-20050419.
> (snip)

Yikes! It turns out if_nameindex() doesn't return info for down devices,
but if_indextoname() does. It's all so touchy... So, attached is an
alternate patch using if_indextoname() that does work; my last one
doesn't.

Just for kicks I also attached a cpp file adapted from MSDN that can do a
quick test. To build it do:

$ wineg++ -c show-eths.cpp
$ wineg++ -o show-eths.exe.so show-eths.o
$ wine ./show-eths.exe.so

You should get a listing for eth0 whether you boot with an ethernet
connection or not. Note that to witness the problem you have to actually
reboot with no ethernet connection. Just doing "ifdown eth0" isn't enough.

> Cool, thanks for that.  Like I mention in the comments, if_nameindex has
> the disadvantage that it doesn't handle virtual interfaces.  I'll try to
> hack this up to use a combination of if_nameindex and SIOCGIFCONF if I
> can, but feel free to beat me to it ;)

I'm betting you'll get there first! %) ... mo

wine-20050419-muse-ifenum.patch
Description: Binary data


show-eths.cpp
Description: Binary data



Re: HW address w/o connection in iphlpapi

2006-01-17 Thread most
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.


ifenum.patch
Description: Binary data



HW address w/o connection in iphlpapi

2006-01-16 Thread most
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...?