Use \*[Am] and \*[Gt], like before the previous revision; use .In; minor other changes.

This commit is contained in:
wiz 2005-01-12 14:44:11 +00:00
parent 2abf3ae985
commit 379e07e3ac
1 changed files with 13 additions and 15 deletions

View File

@ -1,4 +1,4 @@
.\" $NetBSD: getnameinfo.3,v 1.33 2005/01/11 07:26:57 itojun Exp $ .\" $NetBSD: getnameinfo.3,v 1.34 2005/01/12 14:44:11 wiz Exp $
.\" $KAME: getnameinfo.3,v 1.37 2005/01/05 03:23:05 itojun Exp $ .\" $KAME: getnameinfo.3,v 1.37 2005/01/05 03:23:05 itojun Exp $
.\" $OpenBSD: getnameinfo.3,v 1.36 2004/12/21 09:48:20 jmc Exp $ .\" $OpenBSD: getnameinfo.3,v 1.36 2004/12/21 09:48:20 jmc Exp $
.\" .\"
@ -24,9 +24,9 @@
.Nm getnameinfo .Nm getnameinfo
.Nd socket address structure to hostname and service name .Nd socket address structure to hostname and service name
.Sh SYNOPSIS .Sh SYNOPSIS
.Fd #include <sys/types.h> .In sys/types.h
.Fd #include <sys/socket.h> .In sys/socket.h
.Fd #include <netdb.h> .In netdb.h
.Ft int .Ft int
.Fn getnameinfo "const struct sockaddr *sa" "socklen_t salen" "char *host" \ .Fn getnameinfo "const struct sockaddr *sa" "socklen_t salen" "char *host" \
"size_t hostlen" "char *serv" "size_t servlen" "int flags" "size_t hostlen" "char *serv" "size_t servlen" "int flags"
@ -70,8 +70,7 @@ The maximum value for
.Fa hostlen .Fa hostlen
is is
.Dv NI_MAXHOST .Dv NI_MAXHOST
and and the maximum value for
the maximum value for
.Fa servlen .Fa servlen
is is
.Dv NI_MAXSERV , .Dv NI_MAXSERV ,
@ -84,7 +83,7 @@ host name or service string plus a byte for the NUL terminator.
The The
.Fa flags .Fa flags
argument is formed by argument is formed by
.Tn OR Ns 'ing .Sy OR Ns 'ing
the following values: the following values:
.Bl -tag -width "NI_NUMERICHOSTXX" .Bl -tag -width "NI_NUMERICHOSTXX"
.It Dv NI_NOFQDN .It Dv NI_NOFQDN
@ -137,7 +136,7 @@ Observe that there is no hardcoded reference to a particular address family.
struct sockaddr *sa; /* input */ struct sockaddr *sa; /* input */
char hbuf[NI_MAXHOST], sbuf[NI_MAXSERV]; char hbuf[NI_MAXHOST], sbuf[NI_MAXSERV];
if (getnameinfo(sa, sa->sa_len, hbuf, sizeof(hbuf), sbuf, if (getnameinfo(sa, sa-\*[Gt]sa_len, hbuf, sizeof(hbuf), sbuf,
sizeof(sbuf), NI_NUMERICHOST | NI_NUMERICSERV)) { sizeof(sbuf), NI_NUMERICHOST | NI_NUMERICSERV)) {
errx(1, "could not get numeric hostname"); errx(1, "could not get numeric hostname");
/*NOTREACHED*/ /*NOTREACHED*/
@ -150,7 +149,7 @@ The following version checks if the socket address has a reverse address mapping
struct sockaddr *sa; /* input */ struct sockaddr *sa; /* input */
char hbuf[NI_MAXHOST]; char hbuf[NI_MAXHOST];
if (getnameinfo(sa, sa->sa_len, hbuf, sizeof(hbuf), NULL, 0, if (getnameinfo(sa, sa-\*[Gt]sa_len, hbuf, sizeof(hbuf), NULL, 0,
NI_NAMEREQD)) { NI_NAMEREQD)) {
errx(1, "could not resolve hostname"); errx(1, "could not resolve hostname");
/*NOTREACHED*/ /*NOTREACHED*/
@ -192,7 +191,7 @@ printf("host=%s\en", hbuf);
.Rs .Rs
.%A Craig Metz .%A Craig Metz
.%T Protocol Independence Using the Sockets API .%T Protocol Independence Using the Sockets API
.%B "Proceedings of the freenix track: 2000 USENIX annual technical conference" .%B "Proceedings of the FREENIX track: 2000 USENIX annual technical conference"
.%D June 2000 .%D June 2000
.Re .Re
.Sh STANDARDS .Sh STANDARDS
@ -201,7 +200,7 @@ The
function is defined by the function is defined by the
.St -p1003.1g-2000 .St -p1003.1g-2000
draft specification and documented in draft specification and documented in
.Tn "RFC 2553" , .Sy "RFC 2553" ,
.Dq Basic Socket Interface Extensions for IPv6 . .Dq Basic Socket Interface Extensions for IPv6 .
.Sh CAVEATS .Sh CAVEATS
.Fn getnameinfo .Fn getnameinfo
@ -230,8 +229,7 @@ To prevent such attacks, the use of
.Dv NI_NAMEREQD .Dv NI_NAMEREQD
is recommended when the result of is recommended when the result of
.Fn getnameinfo .Fn getnameinfo
is used is used for access control purposes:
for access control purposes:
.Bd -literal -offset indent .Bd -literal -offset indent
struct sockaddr *sa; struct sockaddr *sa;
socklen_t salen; socklen_t salen;
@ -242,10 +240,10 @@ int error;
error = getnameinfo(sa, salen, addr, sizeof(addr), error = getnameinfo(sa, salen, addr, sizeof(addr),
NULL, 0, NI_NAMEREQD); NULL, 0, NI_NAMEREQD);
if (error == 0) { if (error == 0) {
memset(&hints, 0, sizeof(hints)); memset(\*[Am]hints, 0, sizeof(hints));
hints.ai_socktype = SOCK_DGRAM; /*dummy*/ hints.ai_socktype = SOCK_DGRAM; /*dummy*/
hints.ai_flags = AI_NUMERICHOST; hints.ai_flags = AI_NUMERICHOST;
if (getaddrinfo(addr, "0", &hints, &res) == 0) { if (getaddrinfo(addr, "0", \*[Am]hints, \*[Am]res) == 0) {
/* malicious PTR record */ /* malicious PTR record */
freeaddrinfo(res); freeaddrinfo(res);
printf("bogus PTR record\en"); printf("bogus PTR record\en");