bring in latest KAME get{addr,name}info(3).

getnameinfo(3) globs ai_socktype and ai_protocol correctly.
KAME scopeid extension is implemented.
(draft-ietf-ipngwg-scopedaddr-format-00.txt)

bump up shlib minor
(may not be necessary, but rather big difference in behavior - especially
ai_flags)
This commit is contained in:
itojun 1999-12-13 14:18:31 +00:00
parent 106e6868db
commit 1501f61891
6 changed files with 960 additions and 498 deletions

View File

@ -1,8 +1,8 @@
# $NetBSD: shl.mi,v 1.47 1999/12/13 01:44:30 itojun Exp $
# $NetBSD: shl.mi,v 1.48 1999/12/13 14:18:31 itojun Exp $
./usr/lib/libamu.so.1.1
./usr/lib/libbfd.so.3.0
./usr/lib/libbz2.so.0.0
./usr/lib/libc.so.12.52
./usr/lib/libc.so.12.53
./usr/lib/libcrypt.so.0.0
./usr/lib/libcurses.so.2.5
./usr/lib/libedit.so.2.3

View File

@ -30,18 +30,21 @@
.\" SUCH DAMAGE.
.\"
.\" From: @(#)gethostbyname.3 8.4 (Berkeley) 5/25/95
.\" $Id: getaddrinfo.3,v 1.2 1999/07/03 13:58:31 kleink Exp $
.\" KAME Id: getaddrinfo.3,v 1.5 1999/12/10 04:04:30 itojun Exp
.\"
.Dd May 25, 1995
.Dt GETADDRINFO 3
.Os KAME
.\"
.Sh NAME
.Nm getaddrinfo
.Nm getaddrinfo ,
.Nm freeaddrinfo ,
.Nm gai_strerror
.Nd nodename-to-address translation in protocol-independent manner
.\"
.Sh LIBRARY
.Lb libc
.\"
.Sh SYNOPSIS
.Fd #include <sys/socket.h>
.Fd #include <netdb.h>
@ -52,6 +55,7 @@
.Fn freeaddrinfo "struct addrinfo *ai"
.Ft "char *"
.Fn gai_strerror "int ecode"
.\"
.Sh DESCRIPTION
The
.Fn getaddrinfo
@ -62,8 +66,10 @@ and
.Xr getservbyname 3 ,
in more sophisticated manner.
.Pp
The addrinfo structure is defined as a result of including the
.Li <netdb.h>
The
.Li addrinfo
structure is defined as a result of including the
.Aq Pa netdb.h
header:
.Bd -literal -offset
struct addrinfo { *
@ -157,7 +163,8 @@ pointer, this is the same as if the caller had filled in an
.Li addrinfo
structure initialized to zero with
.Fa ai_family
set to PF_UNSPEC.
set to
.Dv PF_UNSPEC .
.Pp
Upon successful return a pointer to a linked list of one or more
.Li addrinfo
@ -220,7 +227,8 @@ call to
.Pq for a connection-oriented protocol
or either
.Fn connect ,
.Fn sendto , or
.Fn sendto ,
or
.Fn sendmsg
.Pq for a connectionless protocol .
In this case, if the
@ -265,7 +273,7 @@ All of the information returned by
is dynamically allocated:
the
.Li addrinfo
structures, and the socket address structures and canonical node name
structures, the socket address structures, and canonical node name
strings pointed to by the addrinfo structures.
To return this information to the system the function
.Fn freeaddrinfo
@ -294,43 +302,87 @@ If the argument is not one of the
.Dv EAI_xxx
values, the function still returns a pointer to a string whose contents
indicate an unknown error.
.\"
.Sh EXTENSION
The implementation allows experimental numeric IPv6 address notation with
scope identifier.
By appending atmark and scope identifier to addresses, you can fill
.Li sin6_scope_id
field for addresses.
This would make management of scoped address easier,
and allows cut-and-paste input of scoped address.
.Pp
At this moment the code supports only link-local addresses with the format.
Scope identifier is hardcoded to name of hardware interface associated
with the link.
.Po
such as
.Li ne0
.Pc .
Example would be like
.Dq Li fe80::1@ne0 ,
which means
.Do
.Li fe80::1
on the link associated with
.Li ne0
interface
.Dc .
.Pp
The implementation is still very experimental and non-standard.
The current implementation assumes one-by-one relationship between
interface and link, which is not necessarily true from the specification.
.\"
.Sh FILES
.Bl -tag -width /etc/resolv.conf -compact
.It Pa /etc/hosts
.It Pa /etc/host.conf
.It Pa /etc/resolv.conf
.El
.\"
.Sh DIAGNOSTICS
Error return status from
.Fn getaddrinfo
is zero on success and non-zero on errors.
Non-zero error codes are defined in
.Li <netdb.h> ,
.Aq Pa netdb.h ,
and as follows:
.Pp
.Bl -tag -width EAI_ADDRFAMILY -compact
.It Dv EAI_ADDRFAMILY
address family for nodename not supported
address family for
.Fa nodename
not supported
.It Dv EAI_AGAIN
temporary failure in name resolution
.It Dv EAI_BADFLAGS
invalid value for ai_flags
invalid value for
.Fa ai_flags
.It Dv EAI_FAIL
non-recoverable failure in name resolution
.It Dv EAI_FAMILY
ai_family not supported
.Fa ai_family
not supported
.It Dv EAI_MEMORY
memory allocation failure
.It Dv EAI_NODATA
no address associated with nodename
no address associated with
.Fa nodename
.It Dv EAI_NONAME
nodename nor servname provided, or not known
.Fa nodename
nor
.Fa servname
provided, or not known
.It Dv EAI_SERVICE
servname not supported for ai_socktype
.Fa servname
not supported for
.Fa ai_socktype
.It Dv EAI_SOCKTYPE
ai_socktype not supported
.Fa ai_socktype
not supported
.It Dv EAI_SYSTEM
system error returned in errno
system error returned in
.Va errno
.El
.Pp
If called with proper argument,
@ -340,6 +392,7 @@ If the argument is not one of the
.Dv EAI_xxx
values, the function still returns a pointer to a string whose contents
indicate an unknown error.
.\"
.Sh SEE ALSO
.Xr getnameinfo 3 ,
.Xr gethostbyname 3 ,
@ -347,17 +400,28 @@ indicate an unknown error.
.Xr hosts 5 ,
.Xr services 5 ,
.Xr hostname 7 ,
.Xr named 8
.Xr named 8 .
.Pp
R. Gilligan, S. Thomson, J. Bound, and W. Stevens,
``Basic Socket Interface Extensions for IPv6,'' RFC2553, March 1999.
.Rs
.%A R. Gilligan
.%A S. Thomson
.%A J. Bound
.%A W. Stevens
.%T Basic Socket Interface Extensions for IPv6
.%R RFC2553
.%D March 1999
.Re
.\"
.Sh HISTORY
The implementation first appeared in WIDE Hydrangea IPv6 protocol stack kit.
.\"
.Sh STANDARDS
The
.Fn getaddrinfo
function is defined IEEE POSIX 1003.1g draft specification,
and documented in ``Basic Socket Interface Extensions for IPv6''
and documented in
.Dq Basic Socket Interface Extensions for IPv6
.Pq RFC2533 .
.\"
.Sh BUGS
The text was shamelessly copied from RFC2553.

File diff suppressed because it is too large Load Diff

View File

@ -30,22 +30,26 @@
.\" SUCH DAMAGE.
.\"
.\" From: @(#)gethostbyname.3 8.4 (Berkeley) 5/25/95
.\" $Id: getnameinfo.3,v 1.2 1999/07/03 13:58:31 kleink Exp $
.\" KAME Id: getnameinfo.3,v 1.4 1999/12/10 04:04:31 itojun Exp
.\"
.Dd May 25, 1995
.Dt GETNAMEINFO 3
.Os KAME
.\"
.Sh NAME
.Nm getnameinfo
.Nd address-to-nodename translation in protocol-independent manner
.\"
.Sh LIBRARY
.Lb libc
.\"
.Sh SYNOPSIS
.Fd #include <sys/socket.h>
.Fd #include <netdb.h>
.Ft int
.Fn getnameinfo "const struct sockaddr *sa" "socklen_t salen" \
"char *host" "size_t hostlen" "char *serv" "size_t servlen" "int flags"
.\"
.Sh DESCRIPTION
The
.Fn getnameinfo
@ -66,16 +70,16 @@ a non-zero return value indicates failure.
The first argument,
.Fa sa ,
points to either a
.Fa sockaddr_in
.Li sockaddr_in
structure (for IPv4) or a
.Fa sockaddr_in6
.Li sockaddr_in6
structure (for IPv6) that holds the IP address and port number.
The
.Fa salen
argument gives the length of the
.Fa sockaddr_in
.Li sockaddr_in
or
.Fa sockaddr_in6
.Li sockaddr_in6
structure.
.Pp
The function returns the nodename associated with the IP address in
@ -104,7 +108,7 @@ Unfortunately most systems do not provide constants that specify the
maximum size of either a fully-qualified domain name or a service name.
Therefore to aid the application in allocating buffers for these two
returned strings the following constants are defined in
.Li <netdb.h> :
.Aq Pa netdb.h :
.Bd -literal -offset
#define NI_MAXHOST 1025
#define NI_MAXSERV 32
@ -113,7 +117,7 @@ returned strings the following constants are defined in
The first value is actually defined as the constant
.Dv MAXDNAME
in recent versions of BIND's
.Li <arpa/nameser.h>
.Aq Pa arpa/nameser.h
header
.Po
older versions of BIND define this constant to be 256
@ -156,30 +160,50 @@ instead of its name.
The two
.Dv NI_NUMERICxxx
flags are required to support the
.Li "-n"
.Fl n
flag that many commands provide.
.Pp
A fifth flag bit,
.Dv NI_DGRAM ,
specifies that the service is a datagram service, and causes
.Fn getservbyport
to be called with a second argument of "udp" instead of its default of "tcp".
to be called with a second argument of
.Dq udp
instead of its default of
.Dq tcp .
This is required for the few ports (512-514)
that have different services for UDP and TCP.
.Pp
These
.Dv NI_xxx
flags are defined in
.Li <netdb.h> .
.Aq Pa netdb.h .
.\"
.Sh EXTENSION
The implementation allows experimental numeric IPv6 address notation with
scope identifier.
IPv6 link-local address will appear as string like
.Dq Li fe80::1@ne0 ,
if
.Dv NI_WITHSCOPEID
bit is enabled in
.Ar flags
argument.
Refer to
.Xr getaddrinfo 3
for the notation.
.\"
.Sh FILES
.Bl -tag -width /etc/resolv.conf -compact
.It Pa /etc/hosts
.It Pa /etc/host.conf
.It Pa /etc/resolv.conf
.El
.\"
.Sh DIAGNOSTICS
The function indicates successful completion by a zero return value;
a non-zero return value indicates failure.
.\"
.Sh SEE ALSO
.Xr getaddrinfo 3 ,
.Xr gethostbyaddr 3 ,
@ -189,15 +213,26 @@ a non-zero return value indicates failure.
.Xr hostname 7 ,
.Xr named 8
.Pp
R. Gilligan, S. Thomson, J. Bound, and W. Stevens,
``Basic Socket Interface Extensions for IPv6,'' RFC2553, March 1999.
.Rs
.%A R. Gilligan
.%A S. Thomson
.%A J. Bound
.%A W. Stevens
.%T Basic Socket Interface Extensions for IPv6
.%R RFC2553
.%D March 1999
.Re
.\"
.Sh HISTORY
The implementation first appeared in WIDE Hydrangea IPv6 protocol stack kit.
.\"
.Sh STANDARDS
The
.Fn getaddrinfo
function is defined IEEE POSIX 1003.1g draft specification,
and documented in ``Basic Socket Interface Extensions for IPv6''
and documented in
.Dq Basic Socket Interface Extensions for IPv6
.Pq RFC2533 .
.\"
.Sh BUGS
The text was shamelessly copied from RFC2553.

View File

@ -1,4 +1,4 @@
/* $NetBSD: getnameinfo.c,v 1.4 1999/08/22 12:54:02 kleink Exp $ */
/* $NetBSD: getnameinfo.c,v 1.5 1999/12/13 14:18:32 itojun Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@ -32,13 +32,22 @@
/*
* Issues to be discussed:
* - Thread safe-ness must be checked
* - Return values. There seems to be no standard for return value (RFC2133)
* - Return values. There seems to be no standard for return value (RFC2553)
* but INRIA implementation returns EAI_xxx defined for getaddrinfo().
* - RFC2553 says that we should raise error on short buffer. X/Open says
* we need to truncate the result. We obey RFC2553 (and X/Open should be
* modified).
*/
#include "namespace.h"
#if 0
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#endif
#include <sys/types.h>
#include <sys/socket.h>
#include <net/if.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <arpa/nameser.h>
@ -47,6 +56,16 @@
#include <string.h>
#include <stddef.h>
#if 0
#ifndef HAVE_PORTABLE_PROTOTYPE
#include "cdecl_ext.h"
#endif
#ifndef HAVE_ADDRINFO
#include "addrinfo.h"
#endif
#endif
#define SUCCESS 0
#define ANY 0
#define YES 1
@ -95,9 +114,9 @@ getnameinfo(sa, salen, host, hostlen, serv, servlen, flags)
struct servent *sp;
struct hostent *hp;
u_short port;
int family, len, i;
int family, i;
char *addr, *p;
u_long v4a;
u_int32_t v4a;
int h_error;
char numserv[512];
char numaddr[512];
@ -105,8 +124,10 @@ getnameinfo(sa, salen, host, hostlen, serv, servlen, flags)
if (sa == NULL)
return ENI_NOSOCKET;
len = sa->sa_len;
if (len != salen) return ENI_SALEN;
#ifdef HAVE_SA_LEN /*XXX*/
if (sa->sa_len != salen)
return ENI_SALEN;
#endif
family = sa->sa_family;
for (i = 0; afdl[i].a_af; i++)
@ -117,31 +138,42 @@ getnameinfo(sa, salen, host, hostlen, serv, servlen, flags)
return ENI_FAMILY;
found:
if (len != afd->a_socklen) return ENI_SALEN;
if (salen != afd->a_socklen)
return ENI_SALEN;
port = ((struct sockinet *)sa)->si_port; /* network byte order */
addr = (char *)sa + afd->a_off;
if (serv == NULL || servlen == 0) {
/* what we should do? */
} else if (flags & NI_NUMERICSERV) {
snprintf(numserv, sizeof(numserv), "%d", ntohs(port));
if (strlen(numserv) > servlen)
return ENI_MEMORY;
strcpy(serv, numserv);
/*
* do nothing in this case.
* in case you are wondering if "&&" is more correct than
* "||" here: RFC2553 says that serv == NULL OR servlen == 0
* means that the caller does not want the result.
*/
} else {
sp = getservbyport(port, (flags & NI_DGRAM) ? "udp" : "tcp");
if (flags & NI_NUMERICSERV)
sp = NULL;
else {
sp = getservbyport(port,
(flags & NI_DGRAM) ? "udp" : "tcp");
}
if (sp) {
if (strlen(sp->s_name) > servlen)
return ENI_MEMORY;
strcpy(serv, sp->s_name);
} else
return ENI_NOSERVNAME;
} else {
snprintf(numserv, sizeof(numserv), "%d", ntohs(port));
if (strlen(numserv) > servlen)
return ENI_MEMORY;
strcpy(serv, numserv);
}
}
switch (sa->sa_family) {
case AF_INET:
v4a = ntohl(((struct sockaddr_in *)sa)->sin_addr.s_addr);
v4a = (u_int32_t)
ntohl(((struct sockaddr_in *)sa)->sin_addr.s_addr);
if (IN_MULTICAST(v4a) || IN_EXPERIMENTAL(v4a))
flags |= NI_NUMERICHOST;
v4a >>= IN_CLASSA_NSHIFT;
@ -153,7 +185,7 @@ getnameinfo(sa, salen, host, hostlen, serv, servlen, flags)
{
struct sockaddr_in6 *sin6;
sin6 = (struct sockaddr_in6 *)sa;
switch (sin6->sin6_addr.s6_addr8[0]) {
switch (sin6->sin6_addr.s6_addr[0]) {
case 0x00:
if (IN6_IS_ADDR_V4MAPPED(&sin6->sin6_addr))
;
@ -163,8 +195,9 @@ getnameinfo(sa, salen, host, hostlen, serv, servlen, flags)
flags |= NI_NUMERICHOST;
break;
default:
if (IN6_IS_ADDR_LINKLOCAL(&sin6->sin6_addr))
if (IN6_IS_ADDR_LINKLOCAL(&sin6->sin6_addr)) {
flags |= NI_NUMERICHOST;
}
else if (IN6_IS_ADDR_MULTICAST(&sin6->sin6_addr))
flags |= NI_NUMERICHOST;
break;
@ -174,7 +207,12 @@ getnameinfo(sa, salen, host, hostlen, serv, servlen, flags)
#endif
}
if (host == NULL || hostlen == 0) {
/* what should we do? */
/*
* do nothing in this case.
* in case you are wondering if "&&" is more correct than
* "||" here: RFC2553 says that host == NULL OR hostlen == 0
* means that the caller does not want the result.
*/
} else if (flags & NI_NUMERICHOST) {
/* NUMERICHOST and NAMEREQD conflicts with each other */
if (flags & NI_NAMEREQD)
@ -185,6 +223,26 @@ getnameinfo(sa, salen, host, hostlen, serv, servlen, flags)
if (strlen(numaddr) > hostlen)
return ENI_MEMORY;
strcpy(host, numaddr);
#if defined(INET6) && defined(NI_WITHSCOPEID)
if (afd->a_af == AF_INET6 &&
(IN6_IS_ADDR_LINKLOCAL((struct in6_addr *)addr) ||
IN6_IS_ADDR_MULTICAST((struct in6_addr *)addr)) &&
((struct sockaddr_in6 *)sa)->sin6_scope_id) {
#ifndef ALWAYS_WITHSCOPE
if (flags & NI_WITHSCOPEID)
#endif /* !ALWAYS_WITHSCOPE */
{
char *ep = strchr(host, '\0');
unsigned int ifindex =
((struct sockaddr_in6 *)sa)->sin6_scope_id;
*ep = SCOPE_DELIMITER;
if ((if_indextoname(ifindex, ep + 1)) == NULL)
/* XXX what should we do? */
strncpy(ep + 1, "???", 3);
}
}
#endif /* INET6 */
} else {
#ifdef USE_GETIPNODEBY
hp = getipnodebyaddr(addr, afd->a_addrlen, afd->a_af, &h_error);

View File

@ -1,5 +1,5 @@
# $NetBSD: shlib_version,v 1.80 1999/12/01 18:35:15 thorpej Exp $
# $NetBSD: shlib_version,v 1.81 1999/12/13 14:18:32 itojun Exp $
# Remember to update distrib/sets/lists/base/shl.* when changing
#
major=12
minor=52
minor=53