lwres_getaddrinfo.docbook revision ddccd5811feff696ba460dabfb666ce61040f545
a631b30b1ddd8b2ea780371d0d99ba1c05bc7e42Francis Dupont<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook V4.1//EN">
f89a9bcf1c02b9b350b8d29e47b48fdc0d334d2aFrancis Dupont - Copyright (C) 2000, 2001 Internet Software Consortium.
bf0266f286c9350f6579d03cc74429433d8e6381Tinderbox User - Permission to use, copy, modify, and distribute this software for any
a631b30b1ddd8b2ea780371d0d99ba1c05bc7e42Francis Dupont - purpose with or without fee is hereby granted, provided that the above
a631b30b1ddd8b2ea780371d0d99ba1c05bc7e42Francis Dupont - copyright notice and this permission notice appear in all copies.
a631b30b1ddd8b2ea780371d0d99ba1c05bc7e42Francis Dupont - THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM
a631b30b1ddd8b2ea780371d0d99ba1c05bc7e42Francis Dupont - DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
a631b30b1ddd8b2ea780371d0d99ba1c05bc7e42Francis Dupont - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
a631b30b1ddd8b2ea780371d0d99ba1c05bc7e42Francis Dupont - INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
a631b30b1ddd8b2ea780371d0d99ba1c05bc7e42Francis Dupont - INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
a631b30b1ddd8b2ea780371d0d99ba1c05bc7e42Francis Dupont - FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
a631b30b1ddd8b2ea780371d0d99ba1c05bc7e42Francis Dupont - NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
a631b30b1ddd8b2ea780371d0d99ba1c05bc7e42Francis Dupont - WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
a631b30b1ddd8b2ea780371d0d99ba1c05bc7e42Francis Dupont<!-- $Id: lwres_getaddrinfo.docbook,v 1.1 2001/03/31 00:08:09 gson Exp $ -->
a631b30b1ddd8b2ea780371d0d99ba1c05bc7e42Francis Dupont<refentryinfo>
a631b30b1ddd8b2ea780371d0d99ba1c05bc7e42Francis Dupont</refentryinfo>
a631b30b1ddd8b2ea780371d0d99ba1c05bc7e42Francis Dupont<refentrytitle>lwres_getaddrinfo</refentrytitle>
a631b30b1ddd8b2ea780371d0d99ba1c05bc7e42Francis Dupont<refpurpose>socket address structure to host and service name</refpurpose>
a631b30b1ddd8b2ea780371d0d99ba1c05bc7e42Francis Dupont<refsynopsisdiv>
a631b30b1ddd8b2ea780371d0d99ba1c05bc7e42Francis Dupont<funcsynopsis>
bf0266f286c9350f6579d03cc74429433d8e6381Tinderbox User<funcsynopsisinfo>#include <lwres/netdb.h></funcsynopsisinfo>
a631b30b1ddd8b2ea780371d0d99ba1c05bc7e42Francis Dupont<funcprototype>
a631b30b1ddd8b2ea780371d0d99ba1c05bc7e42Francis Dupont<function>lwres_getaddrinfo</function></funcdef>
a631b30b1ddd8b2ea780371d0d99ba1c05bc7e42Francis Dupont<paramdef>const struct addrinfo *hints</paramdef>
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt</funcprototype>
f89a9bcf1c02b9b350b8d29e47b48fdc0d334d2aFrancis Dupont<funcprototype>
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt</funcprototype>
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt</funcsynopsis>
a631b30b1ddd8b2ea780371d0d99ba1c05bc7e42Francis DupontIf the operating system does not provide a
a631b30b1ddd8b2ea780371d0d99ba1c05bc7e42Francis Dupontthe following structure is used:
a631b30b1ddd8b2ea780371d0d99ba1c05bc7e42Francis Dupont<programlisting>
a631b30b1ddd8b2ea780371d0d99ba1c05bc7e42Francis Dupontstruct addrinfo {
a631b30b1ddd8b2ea780371d0d99ba1c05bc7e42Francis Dupont int ai_flags; /* AI_PASSIVE, AI_CANONNAME */
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt int ai_family; /* PF_xxx */
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt int ai_socktype; /* SOCK_xxx */
a631b30b1ddd8b2ea780371d0d99ba1c05bc7e42Francis Dupont int ai_protocol; /* 0 or IPPROTO_xxx for IPv4 and IPv6 */
a631b30b1ddd8b2ea780371d0d99ba1c05bc7e42Francis Dupont size_t ai_addrlen; /* length of ai_addr */
a631b30b1ddd8b2ea780371d0d99ba1c05bc7e42Francis Dupont char *ai_canonname; /* canonical name for hostname */
a631b30b1ddd8b2ea780371d0d99ba1c05bc7e42Francis Dupont struct sockaddr *ai_addr; /* binary address */
a631b30b1ddd8b2ea780371d0d99ba1c05bc7e42Francis Dupont struct addrinfo *ai_next; /* next structure in linked list */
a631b30b1ddd8b2ea780371d0d99ba1c05bc7e42Francis Dupont</programlisting>
a631b30b1ddd8b2ea780371d0d99ba1c05bc7e42Francis Dupont</refsynopsisdiv>
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Huntis used to get a list of IP addresses and port numbers for host
a631b30b1ddd8b2ea780371d0d99ba1c05bc7e42Francis DupontThe function is the lightweight resolver's implementation of
a631b30b1ddd8b2ea780371d0d99ba1c05bc7e42Francis Dupontas defined in RFC2133.
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Huntare pointers to null-terminated
a631b30b1ddd8b2ea780371d0d99ba1c05bc7e42Francis Dupontis either a host name or a numeric host address string: a dotted decimal
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan HuntIPv4 address or an IPv6 address.
a631b30b1ddd8b2ea780371d0d99ba1c05bc7e42Francis Dupontis either a decimal port number or a service name as listed in
f89a9bcf1c02b9b350b8d29e47b48fdc0d334d2aFrancis Dupontis an optional pointer to a
f89a9bcf1c02b9b350b8d29e47b48fdc0d334d2aFrancis DupontThis structure can be used to provide hints concerning the type of socket
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Huntthat the caller supports or wishes to use.
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan HuntThe caller can supply the following structure elements in
f89a9bcf1c02b9b350b8d29e47b48fdc0d334d2aFrancis Dupont<variablelist>
f89a9bcf1c02b9b350b8d29e47b48fdc0d334d2aFrancis Dupont<varlistentry><term><constant>ai_family</constant></term>
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt<para>The protocol family that should be used.
a631b30b1ddd8b2ea780371d0d99ba1c05bc7e42Francis Dupontit means the caller will accept any protocol family supported by the
a631b30b1ddd8b2ea780371d0d99ba1c05bc7e42Francis Dupontoperating system.
a631b30b1ddd8b2ea780371d0d99ba1c05bc7e42Francis Dupont<varlistentry><term><constant>ai_socktype</constant></term>
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Huntdenotes the type of socket —
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt— that is wanted.
f89a9bcf1c02b9b350b8d29e47b48fdc0d334d2aFrancis Dupontis zero the caller will accept any socket type.
f89a9bcf1c02b9b350b8d29e47b48fdc0d334d2aFrancis Dupont<varlistentry><term><constant>ai_protocol</constant></term>
f89a9bcf1c02b9b350b8d29e47b48fdc0d334d2aFrancis Dupontindicates which transport protocol is wanted: IPPROTO_UDP or
a631b30b1ddd8b2ea780371d0d99ba1c05bc7e42Francis Dupontis zero the caller will accept any protocol.
a631b30b1ddd8b2ea780371d0d99ba1c05bc7e42Francis Dupont<varlistentry><term><constant>ai_flags</constant></term>
a631b30b1ddd8b2ea780371d0d99ba1c05bc7e42Francis Dupontbit is set, a successful call to
a631b30b1ddd8b2ea780371d0d99ba1c05bc7e42Francis Dupontwill return a a null-terminated string containing the canonical name
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Huntof the specified hostname in
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Huntstructure returned.
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Huntbit indicates that the returned socket address structure is intended
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Huntfor used in a call to
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt<citerefentry>
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt<refentrytitle>bind</refentrytitle><manvolnum>2</manvolnum>
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt</citerefentry>.
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan HuntIn this case, if the hostname argument is a
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Huntpointer, then the IP address portion of the socket
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Huntaddress structure will be set to
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Huntfor an IPv4 address or
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Huntfor an IPv6 address.
a631b30b1ddd8b2ea780371d0d99ba1c05bc7e42Francis Dupontdoes not set the
a631b30b1ddd8b2ea780371d0d99ba1c05bc7e42Francis Dupontbit, the returned socket address structure will be ready
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Huntfor use in a call to
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt<citerefentry>
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt</citerefentry>
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Huntfor a connection-oriented protocol or
a631b30b1ddd8b2ea780371d0d99ba1c05bc7e42Francis Dupont<citerefentry>
a631b30b1ddd8b2ea780371d0d99ba1c05bc7e42Francis Dupont<refentrytitle>connect</refentrytitle><manvolnum>2</manvolnum>
a631b30b1ddd8b2ea780371d0d99ba1c05bc7e42Francis Dupont</citerefentry>,
a631b30b1ddd8b2ea780371d0d99ba1c05bc7e42Francis Dupont<citerefentry>
f89a9bcf1c02b9b350b8d29e47b48fdc0d334d2aFrancis Dupont<refentrytitle>sendto</refentrytitle><manvolnum>2</manvolnum>
f89a9bcf1c02b9b350b8d29e47b48fdc0d334d2aFrancis Dupont</citerefentry>,
a631b30b1ddd8b2ea780371d0d99ba1c05bc7e42Francis Dupont<citerefentry>
a631b30b1ddd8b2ea780371d0d99ba1c05bc7e42Francis Dupont<refentrytitle>sendmsg</refentrytitle><manvolnum>2
a631b30b1ddd8b2ea780371d0d99ba1c05bc7e42Francis Dupont</citerefentry>
a631b30b1ddd8b2ea780371d0d99ba1c05bc7e42Francis Dupontif a connectionless protocol was chosen.
a631b30b1ddd8b2ea780371d0d99ba1c05bc7e42Francis DupontThe IP address portion of the socket address structure will be
a631b30b1ddd8b2ea780371d0d99ba1c05bc7e42Francis Dupontset to the loopback address if