lwres_getaddrinfo.docbook revision 30eec077db2bdcb6f2a0dc388a3cdde2ede75ec1
6031e9c7eb72435516a6828deb2e97533ed0382dludovicp<!ENTITY mdash "—">]>
6031e9c7eb72435516a6828deb2e97533ed0382dludovicp - Copyright (C) 2004, 2005, 2007, 2014, 2015 Internet Systems Consortium, Inc. ("ISC")
6031e9c7eb72435516a6828deb2e97533ed0382dludovicp - Copyright (C) 2000, 2001, 2003 Internet Software Consortium.
6031e9c7eb72435516a6828deb2e97533ed0382dludovicp - Permission to use, copy, modify, and/or distribute this software for any
6031e9c7eb72435516a6828deb2e97533ed0382dludovicp - purpose with or without fee is hereby granted, provided that the above
6031e9c7eb72435516a6828deb2e97533ed0382dludovicp - copyright notice and this permission notice appear in all copies.
3437829f938dbb44527d91fbbc5f430a1243c5a5JnRouvignac - THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
3437829f938dbb44527d91fbbc5f430a1243c5a5JnRouvignac - REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
6031e9c7eb72435516a6828deb2e97533ed0382dludovicp - AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
6031e9c7eb72435516a6828deb2e97533ed0382dludovicp - INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
6031e9c7eb72435516a6828deb2e97533ed0382dludovicp - LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
6031e9c7eb72435516a6828deb2e97533ed0382dludovicp - OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
3437829f938dbb44527d91fbbc5f430a1243c5a5JnRouvignac - PERFORMANCE OF THIS SOFTWARE.
3437829f938dbb44527d91fbbc5f430a1243c5a5JnRouvignac<!-- Converted by db4-upgrade version 1.0 -->
6031e9c7eb72435516a6828deb2e97533ed0382dludovicp<refentry xmlns="http://docbook.org/ns/docbook" version="5.0">
6031e9c7eb72435516a6828deb2e97533ed0382dludovicp <refentryinfo>
6031e9c7eb72435516a6828deb2e97533ed0382dludovicp <corpauthor>Internet Systems Consortium, Inc.</corpauthor>
6031e9c7eb72435516a6828deb2e97533ed0382dludovicp </refentryinfo>
6031e9c7eb72435516a6828deb2e97533ed0382dludovicp <copyright>
6031e9c7eb72435516a6828deb2e97533ed0382dludovicp <holder>Internet Systems Consortium, Inc. ("ISC")</holder>
6031e9c7eb72435516a6828deb2e97533ed0382dludovicp </copyright>
6031e9c7eb72435516a6828deb2e97533ed0382dludovicp <copyright>
6031e9c7eb72435516a6828deb2e97533ed0382dludovicp </copyright>
6031e9c7eb72435516a6828deb2e97533ed0382dludovicp <refnamediv>
6031e9c7eb72435516a6828deb2e97533ed0382dludovicp <refpurpose>socket address structure to host and service name</refpurpose>
6031e9c7eb72435516a6828deb2e97533ed0382dludovicp </refnamediv>
6031e9c7eb72435516a6828deb2e97533ed0382dludovicp <refsynopsisdiv>
6031e9c7eb72435516a6828deb2e97533ed0382dludovicp <funcsynopsis>
6031e9c7eb72435516a6828deb2e97533ed0382dludovicp<funcsynopsisinfo>#include <lwres/netdb.h></funcsynopsisinfo>
6031e9c7eb72435516a6828deb2e97533ed0382dludovicp<funcprototype>
6031e9c7eb72435516a6828deb2e97533ed0382dludovicp <paramdef>const char *<parameter>hostname</parameter></paramdef>
6031e9c7eb72435516a6828deb2e97533ed0382dludovicp <paramdef>const char *<parameter>servname</parameter></paramdef>
6031e9c7eb72435516a6828deb2e97533ed0382dludovicp <paramdef>const struct addrinfo *<parameter>hints</parameter></paramdef>
6031e9c7eb72435516a6828deb2e97533ed0382dludovicp <paramdef>struct addrinfo **<parameter>res</parameter></paramdef>
6031e9c7eb72435516a6828deb2e97533ed0382dludovicp </funcprototype>
6031e9c7eb72435516a6828deb2e97533ed0382dludovicp<funcprototype>
6031e9c7eb72435516a6828deb2e97533ed0382dludovicp <paramdef>struct addrinfo *<parameter>ai</parameter></paramdef>
6031e9c7eb72435516a6828deb2e97533ed0382dludovicp </funcprototype>
6031e9c7eb72435516a6828deb2e97533ed0382dludovicp</funcsynopsis>
6031e9c7eb72435516a6828deb2e97533ed0382dludovicp If the operating system does not provide a
6031e9c7eb72435516a6828deb2e97533ed0382dludovicp the following structure is used:
6031e9c7eb72435516a6828deb2e97533ed0382dludovicpstruct addrinfo {
6031e9c7eb72435516a6828deb2e97533ed0382dludovicp int ai_flags; /* AI_PASSIVE, AI_CANONNAME */
6031e9c7eb72435516a6828deb2e97533ed0382dludovicp int ai_family; /* PF_xxx */
6031e9c7eb72435516a6828deb2e97533ed0382dludovicp int ai_socktype; /* SOCK_xxx */
6031e9c7eb72435516a6828deb2e97533ed0382dludovicp int ai_protocol; /* 0 or IPPROTO_xxx for IPv4 and IPv6 */
6031e9c7eb72435516a6828deb2e97533ed0382dludovicp size_t ai_addrlen; /* length of ai_addr */
6031e9c7eb72435516a6828deb2e97533ed0382dludovicp char *ai_canonname; /* canonical name for hostname */
6031e9c7eb72435516a6828deb2e97533ed0382dludovicp struct sockaddr *ai_addr; /* binary address */
6031e9c7eb72435516a6828deb2e97533ed0382dludovicp struct addrinfo *ai_next; /* next structure in linked list */
6031e9c7eb72435516a6828deb2e97533ed0382dludovicp</programlisting>
6031e9c7eb72435516a6828deb2e97533ed0382dludovicp </refsynopsisdiv>
6031e9c7eb72435516a6828deb2e97533ed0382dludovicp <refsection><info><title>DESCRIPTION</title></info>
6031e9c7eb72435516a6828deb2e97533ed0382dludovicp is used to get a list of IP addresses and port numbers for host
6031e9c7eb72435516a6828deb2e97533ed0382dludovicp The function is the lightweight resolver's implementation of
6031e9c7eb72435516a6828deb2e97533ed0382dludovicp <function>getaddrinfo()</function> as defined in RFC2133.
6031e9c7eb72435516a6828deb2e97533ed0382dludovicp <parameter>servname</parameter> are pointers to null-terminated
6031e9c7eb72435516a6828deb2e97533ed0382dludovicp <parameter>hostname</parameter> is either a host name or a
6031e9c7eb72435516a6828deb2e97533ed0382dludovicp numeric host address string: a dotted decimal IPv4 address or an
6031e9c7eb72435516a6828deb2e97533ed0382dludovicp IPv6 address. <parameter>servname</parameter> is either a
6031e9c7eb72435516a6828deb2e97533ed0382dludovicp decimal port number or a service name as listed in
6031e9c7eb72435516a6828deb2e97533ed0382dludovicp is an optional pointer to a
6031e9c7eb72435516a6828deb2e97533ed0382dludovicp This structure can be used to provide hints concerning the type of
6031e9c7eb72435516a6828deb2e97533ed0382dludovicp that the caller supports or wishes to use.
6031e9c7eb72435516a6828deb2e97533ed0382dludovicp The caller can supply the following structure elements in
6031e9c7eb72435516a6828deb2e97533ed0382dludovicp <variablelist>
6031e9c7eb72435516a6828deb2e97533ed0382dludovicp <varlistentry>
6031e9c7eb72435516a6828deb2e97533ed0382dludovicp The protocol family that should be used.
6031e9c7eb72435516a6828deb2e97533ed0382dludovicp it means the caller will accept any protocol family supported by
6031e9c7eb72435516a6828deb2e97533ed0382dludovicp operating system.
6031e9c7eb72435516a6828deb2e97533ed0382dludovicp </listitem>
6031e9c7eb72435516a6828deb2e97533ed0382dludovicp </varlistentry>
6031e9c7eb72435516a6828deb2e97533ed0382dludovicp <varlistentry>
6031e9c7eb72435516a6828deb2e97533ed0382dludovicp denotes the type of socket —
6031e9c7eb72435516a6828deb2e97533ed0382dludovicp — that is wanted.
6031e9c7eb72435516a6828deb2e97533ed0382dludovicp is zero the caller will accept any socket type.
6031e9c7eb72435516a6828deb2e97533ed0382dludovicp </listitem>
6031e9c7eb72435516a6828deb2e97533ed0382dludovicp </varlistentry>
6031e9c7eb72435516a6828deb2e97533ed0382dludovicp <varlistentry>
6031e9c7eb72435516a6828deb2e97533ed0382dludovicp indicates which transport protocol is wanted: IPPROTO_UDP or
6031e9c7eb72435516a6828deb2e97533ed0382dludovicp IPPROTO_TCP.
6031e9c7eb72435516a6828deb2e97533ed0382dludovicp is zero the caller will accept any protocol.
6031e9c7eb72435516a6828deb2e97533ed0382dludovicp </listitem>
6031e9c7eb72435516a6828deb2e97533ed0382dludovicp </varlistentry>
6031e9c7eb72435516a6828deb2e97533ed0382dludovicp <varlistentry>
6031e9c7eb72435516a6828deb2e97533ed0382dludovicp bit is set, a successful call to
6031e9c7eb72435516a6828deb2e97533ed0382dludovicp will return a null-terminated string containing the canonical
6031e9c7eb72435516a6828deb2e97533ed0382dludovicp of the specified hostname in
6031e9c7eb72435516a6828deb2e97533ed0382dludovicp of the first
6031e9c7eb72435516a6828deb2e97533ed0382dludovicp structure returned.
6031e9c7eb72435516a6828deb2e97533ed0382dludovicp Setting the
6031e9c7eb72435516a6828deb2e97533ed0382dludovicp bit indicates that the returned socket address structure is
6031e9c7eb72435516a6828deb2e97533ed0382dludovicp for used in a call to
6031e9c7eb72435516a6828deb2e97533ed0382dludovicp <citerefentry>
6031e9c7eb72435516a6828deb2e97533ed0382dludovicp <refentrytitle>bind</refentrytitle><manvolnum>2</manvolnum>
6031e9c7eb72435516a6828deb2e97533ed0382dludovicp </citerefentry>.
6031e9c7eb72435516a6828deb2e97533ed0382dludovicp In this case, if the hostname argument is a
6031e9c7eb72435516a6828deb2e97533ed0382dludovicp pointer, then the IP address portion of the socket
6031e9c7eb72435516a6828deb2e97533ed0382dludovicp address structure will be set to
6031e9c7eb72435516a6828deb2e97533ed0382dludovicp for an IPv4 address or
6031e9c7eb72435516a6828deb2e97533ed0382dludovicp for an IPv6 address.