Subject: getnameinfo() with NI_NUMERIC****

From: Hideaki YOSHIFUJI (吉藤英明) <[email-masked]>
Date: Wed, 19 Jan 2000 00:55:23 +0900

Hi.

About getnameinfo(), RFC2553 says:

|   The POSIX 1003.1g specification includes no function to perform the
|   reverse conversion from getaddrinfo(): to look up a nodename and
|   service name, given the binary address and port.  Therefore, we
|   define the following function:

|      int getnameinfo(const struct sockaddr *sa, socklen_t salen,
|                      char *host, size_t hostlen,
|                      char *serv, size_t servlen,
|                      int flags);

|   The first argument, sa, points to either a sockaddr_in structure (for
|   IPv4) or a sockaddr_in6 structure (for IPv6) that holds the IP
|   address and port number.  The salen argument gives the length of the
|   sockaddr_in or sockaddr_in6 structure.

The GNU C Library, used as Linux C library, extends getnameindo() 
to accept a pointer to sockaddr_un structure for PF_LOCAL sockets. 
I think this extension is natural because getnamefinfo() is a 
reverse-function of protocol-independent getaddrinfo() function.
But, at this time, there are some issues, and I'd like to discuss 
them on this list.

[1] NI_NUMERICHOST

If we call getnameinfo() with NI_NUMERICHOST, it should returns 
in the numeric form of the host's address if sockaddr_in{,6} 
structure is given.  On the other hand, getnameinfo() of the current 
glibc always returns "localhost" string as a host with sockaddr_un 
even if getnameinfo() is called with NI_NUMERICHOST.
Since "localhost" doen't seem numeric (36-based number??),
applications should be cofused. Which is the most appropriate?
 1) return in an error
 2) return INADDR_LOOPBACK ("127.0.0.1") ?
 3) return IN6ADDR_LOOPBACK ("::1") ?
 4) "-1"
 5) ""
 6) "localhost"
 7) ?

[2] NI_NUMERICSERV

If we call getnemeinfo() with NI_NUMERICSERV, it returns in the 
numeric form of the service address (port number).
The getnameinfo() of the current glibc always returns pathname 
like "/tmp/22", "/tmp/fileasdfgh", or "/whatever/path/to/file".
1st one is from getaddrinfo("localhost", "22") with PF_LOCAL 
(or PF_UNSPEC) hints.  Next one is from getaddrinfo("localhost", 
NULL) (path is automatically selected), and the last one can 
be obttained if you call getaddrinfo("localhost", 
"/whatever/path/to/file"). Which is the most appropriate?
 1) return in an error
 2) return number if pathname matches ^/tmp/([0-9][0-9]*)$.
    (I mean, if "/tmp/22", it returns "22")
    otherwise, return in an error.
 3) current behavior (pathname)
 4) ?

[3]

When I complained about above issues, Ulrich Drepper at gnu.org / 
cygnus.com said,
|I've looked a bit closer at the specification and found that it only
|mentions AF_INET and AF_INET6.  So whoever calls getnameinfo for
|AF_LOCAL must expect everything since the behaviour is unspecified.

How do you think about this opinion?

Thanks in advance.

-- 
Hideaki YOSHIFUJI <[email-masked]>
Web Page: http://www.ecei.tohoku.ac.jp/%7Eyoshfuji/
PGP5i FP: F731 6599 5EB2 BBA7 1515  1323 1806 A96F 5700 6B25 
--------------------------------------------------------------------
IETF IPng Working Group Mailing List
IPng Home Page:                      http://playground.sun.com/ipng
FTP archive:                      ftp://playground.sun.com/pub/ipng
Direct all administrative requests to [email-masked]
--------------------------------------------------------------------