Subject: Re: getaddrinfo() and PF_LOCAL
To: Assar Westerlund <email@example.com>
From: Stig Venaas <Stig.Venaas@uninett.no>
Date: 08/01/2001 13:58:52
On Wed, Aug 01, 2001 at 01:55:14PM +0200, Assar Westerlund wrote:
> This is not very much fun. Then you could as well call getaddrinfo
> twice, once with AF_INET and once with AF_INET6, thereby making your
> code not address-family independent.
Yes, it's ugly
> > what is the right ordering between AFs?
> That's another hard question. Take the easy case of just getting an
> AF_INET and an AF_INET6 address with AI_PASSIVE. Then, you might have
> an IPv4 or IPv6-only node, and you should be able to handle just
> getting of the socket families to listen on. But you should probably
> give an error if you don't manage to listen on any of them. On a
> dual-stack node you can get them in any order, and thereby having the
> IPv6 socket `shadow' the IPv4 one, requiring you to understand mapped address.
You might turn off mapped addresses. I think the order should be
AF_INET6, AF_INET, AF_LOCAL. Where other families might fit in I don't
know, and I'm afraid there's no answer that fits all. If you have an
IPv4-only node the socket call with AF_INET6 will simply fail, and the
caller should try the next. Of course one might try to only return
families that are supported by the current configuration. Actually, as
a sysadmin I wouldn't mind being able to configure which families and
in which order they should be returned.