On 8 August 2011 20:58, Steven McCoy <[email protected]> wrote: > On 8 August 2011 18:47, Martin Sustrik <[email protected]> wrote: > >> Hi Steven, >> >> I guess there may be a problem here: >> >> for (ifaddrs *ifp = ifa; ifp != NULL ;ifp = ifp->ifa_next) >> { >> if (ifp->ifa_addr == NULL) >> continue; >> >> int family = ifp->ifa_addr->sa_family; >> >> if ((family == AF_INET >> || (!ipv4only_ && family == AF_INET6)) >> && !strcmp (interface_, ifp->ifa_name)) >> { >> memcpy (addr_, ifp->ifa_addr, >> (family == AF_INET) ? sizeof (struct sockaddr_in) >> : sizeof (struct sockaddr_in6)); >> found = true; >> break; >> } >> } >> >> Specifically, if you have both IPv4 and IPv6 interface with the same name >> and ipv4only is false, it depends on ordering of the results in getifaddrs() >> resultset which of those two is returned. >> >> I would suppose in such case IPv6 address should be returned. >> >> > The "correct method" would be to implement precedence per gai.conf, i.e. RFC > 3484 sorting. > > http://linux.die.net/man/5/gai.conf > > I found some BSD/MIT license code from within Google Android that implements this:
http://source-android.frandroid.com/bionic/libc/netbsd/net/getaddrinfo.c Subsequently you could later implement OS override by reading gai.conf or pulling in netsh prefixpolicy on Windows. Actually this is pretty neat: http://msdn.microsoft.com/en-us/library/ms740614(v=vs.85).aspx -- Steve-o
_______________________________________________ zeromq-dev mailing list [email protected] http://lists.zeromq.org/mailman/listinfo/zeromq-dev
