Subject: Re: PF_UNIX in getaddrinfo(3)
To: <>
From: Ignatios Souvatzis <is@netbsd.org>
List: tech-net
Date: 02/17/2002 15:27:03
On Sun, Feb 17, 2002 at 11:47:13AM +0100, Mario Kemper wrote:
> 
> i'm porting an application from Linux to NetBSD. The author uses
> unix domain socket as well as ip sockets. He uses getaddrinfo in both 
> cases. While this seems to be no problem under Linux it fails under NetBSD
> as PF_UNIX (PF_LOCAL) is explicitly not supported under NetBSD (PF_LOCAL is
> #ifdef'ed 0 in getaddrinfo.c). Is there a specific reason for this? 
> Does PF_LOCAL violate some standard or is it simply not yet implemented?

1003.1-2001's getaddrinfo() information seems not to demand its
implementation. In fact, it only talks about AF_UNSPEC (any that might 
be present), AF_INET and (optional) AF_INET6.

It certainly is an interesting approach to use getaddrinfo() (or the old
gethostname()) to resolve an AF_UNIX name (which is just a filename that 
happens to point to a socket) - all it can do is return an addrinfo structure
containing a pointer to the unchanged name, copy the socket type from the 
hints and set the address family to AF_UNIX.

Hm, how does it guess that the address familiy is AF_UNIX if you don't tell
it that in the hints? You don't know the socket is there until you try to open
it...

As a workaround, you can easily pass those three values to the socket()
and the connect() etc. calls yourself. Should be about 5 lines of code.

I can see that you can keep codesize a bit smaller in applications like
yours - 

Regards
	-is