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