[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: broken IPv6 code



In article <84hf3atfu4.fsf@snoopy.apana.org.au> (at 08 Jan 2001 22:59:15 +1100), Brian May <bam@debian.org> says:

> [1] I am not sure of the getaddrinfo API, but in my code the first
> parameter is set to NULL. I assume this gets all the addresses of the
> configured interfaces on the local machine, and doesn't need to do any
> DNS lookups.

No. If the first argument is NULL (and the second one is not NULL),

 1) if AI_PASSIVE is set to the ai_flags member in the 3rd argument,
    getaddrinfo() will try to "look-up" unspecific addresses;
    :: for ipv6, 0.0.0.0 for ipv4.

 2) if AI_PASSIVE is NOT set, getaddrinfo() will "look-up" loopback
    addresses; ::1 for ipv6, 127.0.0.1 for ipv4.

If the AI_ADDRCONFIG flag is specified then a look-up for ipv6 address
should occur only if the node has at least one IPv6 source address 
configured and a look-up for ipv4 should occur only if the node has 
at least one IPv4 source address configured.  
Note: loopback addresses are not considered as configured sources addresses.

Last paragraph is rfc2553bis thing, and USAGI glibc 2.1 and 2.2 
have this functionality.


> [2] I assume if a program is smart enough to use getaddrinfo, it will
> also be IPv6 compatable. Is this a safe assumption?

For client applications, it should be yes.
For server applications, you must know and consider about
OS dependent behavior; at least at this moment.

-- 
Hideaki YOSHIFUJI @ USAGI Project  <yoshfuji@linux-ipv6.org>
PGP5i FP: F731 6599 5EB2 BBA7 1515  1323 1806 A96F 5700 6B25 



Reply to: