HP-UX Reference (11i v1 05/09) - 3 Library Functions A-M (vol 6)
g
getaddrinfo(3N) getaddrinfo(3N)
many commands provide.
A fifth flag bit, NI_DGRAM, specifies that the service is a datagram service, and causes
get-
servbyport()
to be called with a second argument of "udp" instead of its default of "tcp". This is
required for the few ports (512-514) that have different services for UDP and TCP.
These NI_xxx flags are defined in
<netdb.h> along with the AI_xxx flags already defined for getad-
drinfo()
.
Name Service Switch-Based Operation
The getnameinfo()
and getaddrinfo()
library routines internally call the name service switch to
access the
ipnodes database lookup policy configured in the
/etc/nsswitch.conf
file (see
nsswitch.conf(4)) for the name/address resolution, and
services database lookup policy for the
service/port resolution. The lookup policy defines the order and criteria of the supported name services
that can be used for resolution. If addresses are not gathered after contacting all the
ipnodes directives,
and if the caller has set the
ai_family
to AF_INET or set ai_flags to AI_V4MAPPED with an
ai_family of AF_INET6 , getaddrinfo()
/getnameinfo()
uses the hosts directive in the
/etc/nsswitch.conf
file to resolve the hostname/address. In this case, when the
hosts directive
hostname/address resolution fails, the error number returned will be that of the error returned by the
hosts directive lookup. The operations of these name services, Domain Name Server and Nonserver
Modes, are described below:
Domain Name Server Operation
If the local system is configured to use the BIND name server, named (see named(1M) and resolver(4)) for
name/address resolution, the function
getnameinfo()
/getaddrinfo() retrieves the host informa-
tion from the name server. The host names are matched irrespective of upper or lower case alphatets. For
example, the domain names
berkeley.edu , Berkeley.EDU , and BERKELEY.EDU match to the
same entry berkeley.edu in the name server database. When hosts directive is used for
hostname/address resolution, a delay may be observed due to an additional lookup using the sources
specified for hosts directive.
Nonserver Operation
During a name/address resolution, if the database is configured for files resolution,
getnameinfo() and
getaddrinfo() use the /etc/hosts
file for resolution. Similarly, if the services database is
configured for files resolution, the
/etc/services
file is used for resolution. If the /etc/hosts file is
used for name/address resolution, the method used by the functions
getnameinfo() and getad-
drinfo()
to search an address is listed below:
getnameinfo() Sequentially searches the /etc/hosts file for addresses matching the src
parameter till the end of file is encountered.
getaddrinfo() Sequentially searches the /etc/hosts file for a host name (official name or an
alias name) matching the name parameter till the end of file is encountered. The
host names are matched irrespective of upper or lower case alphabets.
AUTHOR
getaddrinfo() was developed by HP.
FILES
/etc/hosts
/etc/services
SEE ALSO
gethostent(3N), switch(4), resolver(3N).
HP-UX 11i Version 1: September 2005 − 4 − Hewlett-Packard Company Section 3−−303