getaddrinfo() implementation in glibc does not conform with POSIX in regards with AI_ALL flag. If address family is AF_INET6 and flags are AI_ALL | AI_V4MAPPED, getaddrinfo() should return all IPv6 address _and_ all IPv4 adresses (as IPv4-mapped ones). However glibc implementation returns only IPV6 adresses (if they exists). I use glibc-2.3.5 of Fedora Core 4, but looking at getaddrinfo.c source, the behaviour applies on latest version as well. In my opinion the condition at line 632 of getaddrinfo.c (revision 1.81.2.4.2.1) is not correct. /* If we do not have to look for IPv4 and IPv6 together, use the simple, old functions. */ 632: if (req->ai_family == AF_INET || req->ai_family == AF_INET6) because resolution on IPV4 adresses must be performed even if family is AF_INET6, when AI_ALL flag is used in conjunction with AI_V4MAPPED. ----------------------------------------------------------------------------- Citation from POSIX (contained in rfc3493 as well): If the AI_V4MAPPED flag is specified along with an ai_family of AF_INET6, then getaddrinfo() shall return IPv4-mapped IPv6 addresses on finding no matching IPv6 addresses ( ai_addrlen shall be 16). The AI_V4MAPPED flag shall be ignored unless ai_family equals AF_INET6. If the AI_ALL flag is used with the AI_V4MAPPED flag, then getaddrinfo() shall return all matching IPv6 and IPv4 addresses. The AI_ALL flag without the AI_V4MAPPED flag is ignored. ------------------------------------------------------------------------------- In the attachment there is a test program getaddrinfo_AI_ALL.c, which test the AI_ALL | AI_V4MAPPED combination. When called ./getaddinfo_AI_ALL www.kame.net it returns IPv6 address, but with correct getaddrinfo() it should return IPv4-mapped IPv6.
Created attachment 732 [details] test program for AI_ALL flag in getaddrinfo()
Fixed in the CVS trunk.