give pitfall examples.
in response to couple of PRs including 10666. sync with kame.
This commit is contained in:
parent
a6d6bce652
commit
e3256888e3
|
@ -1,5 +1,5 @@
|
|||
.\" $NetBSD: getaddrinfo.3,v 1.12 2000/06/30 16:48:47 itojun Exp $
|
||||
.\" $KAME: getaddrinfo.3,v 1.15 2000/06/30 16:46:00 itojun Exp $
|
||||
.\" $NetBSD: getaddrinfo.3,v 1.13 2000/07/25 02:33:30 itojun Exp $
|
||||
.\" $KAME: getaddrinfo.3,v 1.19 2000/07/25 02:27:44 itojun Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 1983, 1987, 1991, 1993
|
||||
.\" The Regents of the University of California. All rights reserved.
|
||||
|
@ -169,6 +169,73 @@ structure initialized to zero with
|
|||
set to
|
||||
.Dv PF_UNSPEC .
|
||||
.Pp
|
||||
Though the
|
||||
.Fa hints
|
||||
argument allows you to leave
|
||||
.Fa ai_socktype
|
||||
or
|
||||
.Fa ai_protocol
|
||||
unspecified
|
||||
.Pq by setting those members to zero ,
|
||||
the arguments must sufficiently be consistent and unambiguous.
|
||||
Here are pitfall cases you may encounter:
|
||||
.Bl -bullet
|
||||
.It
|
||||
.Fn getaddrinfo
|
||||
will raise error if members in
|
||||
.Fa hints
|
||||
structure is not consistent.
|
||||
For example, for internet address families,
|
||||
.Fn getaddrinfo
|
||||
will raise error if you specify
|
||||
.Dv SOCK_STREAM
|
||||
to
|
||||
.Fa ai_socktype
|
||||
while you specify
|
||||
.Dv IPPROTO_UDP
|
||||
to
|
||||
.Fa ai_protocol .
|
||||
.It
|
||||
If you specify a
|
||||
.Fa servname
|
||||
which is defined only for certain
|
||||
.Fa ai_socktype ,
|
||||
.Fn getaddrinfo
|
||||
will raise error because the arguments are not consistent.
|
||||
For example,
|
||||
.Fn getaddrinfo
|
||||
will raise error if you ask for
|
||||
.Dq Li tftp
|
||||
service on
|
||||
.Dv SOCK_STREAM .
|
||||
.It
|
||||
For internet address families, if you specify
|
||||
.Fa servname
|
||||
while you set
|
||||
.Fa ai_socktype
|
||||
to
|
||||
.Dv SOCK_RAW ,
|
||||
.Fa getaddrinfo
|
||||
will raise error, because service names are not defined for the internet
|
||||
.Dv SOCK_RAW
|
||||
space.
|
||||
.It
|
||||
If you specify numeric
|
||||
.Fa servname ,
|
||||
while leaving
|
||||
.Fa ai_socktype
|
||||
and
|
||||
.Fa ai_protocol
|
||||
unspecified,
|
||||
.Fn getaddrinfo
|
||||
will raise error.
|
||||
This is because the numeric
|
||||
.Fa servname
|
||||
does not identify any socket type, and
|
||||
.Fn getaddrinfo
|
||||
is not allowed to glob the argument in such case.
|
||||
.El
|
||||
.Pp
|
||||
Upon successful return a pointer to a linked list of one or more
|
||||
.Li addrinfo
|
||||
structures is returned through the final argument.
|
||||
|
@ -518,7 +585,7 @@ indicate an unknown error.
|
|||
.%A Atsushi Onoe
|
||||
.%T "An Extension of Format for IPv6 Scoped Addresses"
|
||||
.%R internet draft
|
||||
.%N draft-ietf-ipngwg-scopedaddr-format-01.txt
|
||||
.%N draft-ietf-ipngwg-scopedaddr-format-02.txt
|
||||
.%O work in progress material
|
||||
.Re
|
||||
.Rs
|
||||
|
|
Loading…
Reference in New Issue