0N/A<!
DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook V4.1//EN">
0N/A - Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC") 0N/A - Copyright (C) 2001, 2003 Internet Software Consortium. 0N/A - Permission to use, copy, modify, and distribute this software for any 0N/A - purpose with or without fee is hereby granted, provided that the above 0N/A - copyright notice and this permission notice appear in all copies. 0N/A - THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH 0N/A - REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 0N/A - AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, 0N/A - INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 0N/A - LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE 0N/A - OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 0N/A - PERFORMANCE OF THIS SOFTWARE. 0N/A<
date>Jun 30, 2000</
date>
0N/A<
refentrytitle>lwres_getaddrinfo</
refentrytitle>
91N/A<
manvolnum>3</
manvolnum>
0N/A<
refmiscinfo>BIND9</
refmiscinfo>
0N/A<
refname>lwres_getaddrinfo</
refname>
0N/A<
refname>lwres_freeaddrinfo</
refname>
0N/A<
refpurpose>socket address structure to host and service name</
refpurpose>
2080N/A<
function>lwres_getaddrinfo</
function></
funcdef>
2080N/A<
paramdef>const char *hostname</
paramdef>
3041N/A<
paramdef>const char *servname</
paramdef>
3041N/A<
paramdef>const struct addrinfo *hints</
paramdef>
3041N/A<
paramdef>struct addrinfo **res</
paramdef>
0N/A<
function>lwres_freeaddrinfo</
function></
funcdef>
0N/A<
paramdef>struct addrinfo *ai</
paramdef>
0N/AIf the operating system does not provide a
1879N/A<
type>struct addrinfo</
type>,
0N/Athe following structure is used:
475N/A int ai_flags; /* AI_PASSIVE, AI_CANONNAME */
0N/A int ai_family; /* PF_xxx */
3178N/A int ai_socktype; /* SOCK_xxx */
0N/A int ai_protocol; /* 0 or IPPROTO_xxx for IPv4 and IPv6 */
0N/A size_t ai_addrlen; /* length of ai_addr */
603N/A char *ai_canonname; /* canonical name for hostname */
603N/A struct sockaddr *ai_addr; /* binary address */
0N/A struct addrinfo *ai_next; /* next structure in linked list */
0N/A<
title>DESCRIPTION</
title>
0N/A<
function>lwres_getaddrinfo()</
function>
0N/Ais used to get a list of IP addresses and port numbers for host
0N/A<
parameter>hostname</
parameter>
0N/A<
parameter>servname</
parameter>.
0N/AThe function is the lightweight resolver's implementation of
0N/A<
function>getaddrinfo()</
function>
0N/Aas defined in RFC2133.
0N/A<
parameter>hostname</
parameter>
0N/A<
parameter>servname</
parameter>
0N/Aare pointers to null-terminated
0N/A<
parameter>hostname</
parameter>
0N/Ais either a host name or a numeric host address string: a dotted decimal
0N/AIPv4 address or an IPv6 address.
0N/A<
parameter>servname</
parameter>
0N/Ais either a decimal port number or a service name as listed in
0N/A<
parameter>hints</
parameter>
0N/Ais an optional pointer to a
0N/A<
type>struct addrinfo</
type>.
0N/AThis structure can be used to provide hints concerning the type of socket
0N/Athat the caller supports or wishes to use.
3178N/AThe caller can supply the following structure elements in
0N/A<
parameter>*hints</
parameter>:
0N/A<
varlistentry><
term><
constant>ai_family</
constant></
term>
0N/A<
para>The protocol family that should be used.
0N/A<
constant>ai_family</
constant>
0N/A<
type>PF_UNSPEC</
type>,
0N/Ait means the caller will accept any protocol family supported by the
0N/A</
para></
listitem></
varlistentry>
0N/A<
varlistentry><
term><
constant>ai_socktype</
constant></
term>
0N/Adenotes the type of socket —
0N/A<
type>SOCK_STREAM</
type>,
0N/A<
type>SOCK_DGRAM</
type>
0N/A<
type>SOCK_RAW</
type>
0N/A— that is wanted.
3487N/A<
constant>ai_socktype</
constant>
3487N/Ais zero the caller will accept any socket type.
475N/A<
varlistentry><
term><
constant>ai_protocol</
constant></
term>
475N/Aindicates which transport protocol is wanted: IPPROTO_UDP or
475N/A<
constant>ai_protocol</
constant>
475N/Ais zero the caller will accept any protocol.
1396N/A<
varlistentry><
term><
constant>ai_flags</
constant></
term>
0N/A<
type>AI_CANONNAME</
type>
0N/Abit is set, a successful call to
0N/A<
function>lwres_getaddrinfo()</
function>
0N/Awill return a null-terminated string containing the canonical name
0N/Aof the specified hostname in
0N/A<
constant>ai_canonname</
constant>
0N/A<
type>addrinfo</
type>
0N/A<
type>AI_PASSIVE</
type>
475N/Abit indicates that the returned socket address structure is intended
0N/A<
refentrytitle>bind</
refentrytitle><
manvolnum>2</
manvolnum>
0N/AIn this case, if the hostname argument is a
0N/Apointer, then the IP address portion of the socket
0N/Aaddress structure will be set to
0N/A<
type>INADDR_ANY</
type>
0N/A<
type>IN6ADDR_ANY_INIT</
type>
0N/A<
constant>ai_flags</
constant>
0N/A<
type>AI_PASSIVE</
type>
0N/Abit, the returned socket address structure will be ready
0N/A<
refentrytitle>connect</
refentrytitle><
manvolnum>2
0N/Afor a connection-oriented protocol or
0N/A<
refentrytitle>connect</
refentrytitle><
manvolnum>2</
manvolnum>
0N/A<
refentrytitle>sendto</
refentrytitle><
manvolnum>2</
manvolnum>
475N/A<
refentrytitle>sendmsg</
refentrytitle><
manvolnum>2
475N/Aif a connectionless protocol was chosen.
475N/AThe IP address portion of the socket address structure will be
475N/Aset to the loopback address if
475N/A<
parameter>hostname</
parameter>
0N/A<
type>AI_PASSIVE</
type>
0N/A<
constant>ai_flags</
constant>.
0N/A<
constant>ai_flags</
constant>
0N/A<
parameter>hostname</
parameter>
0N/Ashould be treated as a numeric string defining an IPv4 or IPv6 address
0N/Aand no name resolution should be attempted.
0N/AAll other elements of the <
type>struct addrinfo</
type> passed
via <
parameter>hints</
parameter> must be zero.
A <
parameter>hints</
parameter> of <
type>NULL</
type> is treated as if
the caller provided a <
type>struct addrinfo</
type> initialized to zero
with <
constant>ai_family</
constant>set to
<
constant>PF_UNSPEC</
constant>.
After a successful call to
<
function>lwres_getaddrinfo()</
function>,
<
parameter>*res</
parameter>
is a pointer to a linked list of one or more
<
type>struct addrinfo</
type>
in this list cn be processed by following
<
constant>ai_next</
constant>
<
constant>ai_family</
constant>,
<
constant>ai_socktype</
constant>,
<
constant>ai_protocol</
constant>
structure contain the corresponding arguments for a call to
<
refentrytitle>socket</
refentrytitle><
manvolnum>2</
manvolnum>
structure in the list, the
<
constant>ai_addr</
constant>
member points to a filled-in socket address structure of length
<
constant>ai_addrlen</
constant>.
All of the information returned by
<
function>lwres_getaddrinfo()</
function>
is dynamically allocated: the addrinfo structures, and the socket
address structures and canonical host name strings pointed to by the
<
constant>addrinfo</
constant>structures.
Memory allocated for the dynamically allocated structures created by
<
function>lwres_getaddrinfo()</
function>
<
function>lwres_freeaddrinfo()</
function>.
<
parameter>ai</
parameter>
<
type>struct addrinfo</
type>
<
function>lwres_getaddrinfo()</
function>.
<
title>RETURN VALUES</
title>
<
function>lwres_getaddrinfo()</
function>
returns zero on success or one of the error codes listed in
<
refentrytitle>gai_strerror</
refentrytitle><
manvolnum>3
<
parameter>hostname</
parameter>
<
parameter>servname</
parameter>
<
function>lwres_getaddrinfo()</
function>
<
errorcode>EAI_NONAME</
errorcode>.
<
refentrytitle>lwres</
refentrytitle><
manvolnum>3</
manvolnum>
<
refentrytitle>lwres_getaddrinfo</
refentrytitle><
manvolnum>3</
manvolnum>
<
refentrytitle>lwres_freeaddrinfo</
refentrytitle><
manvolnum>3</
manvolnum>
<
refentrytitle>lwres_gai_strerror</
refentrytitle><
manvolnum>3</
manvolnum>
<
refentrytitle>RFC2133</
refentrytitle>
<
refentrytitle>getservbyname</
refentrytitle><
manvolnum>3</
manvolnum>
<
refentrytitle>bind</
refentrytitle><
manvolnum>2</
manvolnum>
<
refentrytitle>connect</
refentrytitle><
manvolnum>2</
manvolnum>
<
refentrytitle>sendto</
refentrytitle><
manvolnum>2</
manvolnum>
<
refentrytitle>sendmsg</
refentrytitle><
manvolnum>2</
manvolnum>
<
refentrytitle>socket</
refentrytitle><
manvolnum>2</
manvolnum>