[Qt-interest] QNetworkInterface::allInterfaces does not return interfaces without an IP address?
Frank Mertens
frank at cyblogic.de
Fri Jul 31 22:45:51 CEST 2009
Jeroen De Wachter wrote:
> Hello,
>
> I've been testing some things regarding QNetworkInterface and I've
> noticed that when I call QNetworkInterface::allInterfaces on a system
> that does not have IPv6 support, only the interfaces that are up are
> returned.
>
> When I enable IPv6 support in my uClibc-based toolchain (but not in the
> kernel), different calls are used and I do get all interfaces and all
> their addresses.
>
> This seems due to the way QNetworkInterface gets the interface names and
> interface information in qnetworkinterface_unix.cpp
>
> I still need to look further into why this happens exactly (lots of
> #ifdef in there), but I wanted to check if anyone else has seen this
> issue.
I panicked the last time I visited those dark dungeons of Qt's internals.
The solution: Rewrite from scratch:
http://trac.cyblogic.com/libPONA/browser/pona/NetworkInterface.cpp
Sadly its not Qt compatible at all...
>
> Also, I wanted to ask, if a Linux system is detected, why doesn't Qt use
> a more standardized way of doing things? ifconfig parses
> the /proc/dev/net file, for instance, while the ip command is using the
> netlink interface. (though I guess there would need to be a fallback for
> the netlink stuff... Qt will likely run on older kernels that don't
> support it.)
No I don't think, this is the issue.
Netlink is around for quite some time (linux 2.2?).
But Qt is very brave, supporting BSD, Linux and Solaris(no sysctl) with the same code.
The least common denominator are likely some pre-BSB-4.4 ioctls.
If it runs through getifaddrs(3), probably your C-runtime is source of the problem.
More information about the Qt-interest-old
mailing list