Blame lib/lwres/man/lwres_getaddrinfo.docbook

Packit Service ae04f2
Packit Service ae04f2
]>
Packit Service ae04f2
Packit Service ae04f2
 - Copyright (C) Internet Systems Consortium, Inc. ("ISC")
Packit Service ae04f2
 -
Packit Service ae04f2
 - This Source Code Form is subject to the terms of the Mozilla Public
Packit Service ae04f2
 - License, v. 2.0. If a copy of the MPL was not distributed with this
Packit Service ae04f2
 - file, You can obtain one at http://mozilla.org/MPL/2.0/.
Packit Service ae04f2
 -
Packit Service ae04f2
 - See the COPYRIGHT file distributed with this work for additional
Packit Service ae04f2
 - information regarding copyright ownership.
Packit Service ae04f2
-->
Packit Service ae04f2
Packit Service ae04f2
Packit Service ae04f2
<refentry xmlns:db="http://docbook.org/ns/docbook" version="5.0">
Packit Service ae04f2
  <info>
Packit Service ae04f2
    <date>2007-06-18</date>
Packit Service ae04f2
  </info>
Packit Service ae04f2
  <refentryinfo>
Packit Service ae04f2
    <corpname>ISC</corpname>
Packit Service ae04f2
    <corpauthor>Internet Systems Consortium, Inc.</corpauthor>
Packit Service ae04f2
  </refentryinfo>
Packit Service ae04f2
Packit Service ae04f2
  <refmeta>
Packit Service ae04f2
    <refentrytitle>lwres_getaddrinfo</refentrytitle>
Packit Service ae04f2
    <manvolnum>3</manvolnum>
Packit Service ae04f2
    <refmiscinfo>BIND9</refmiscinfo>
Packit Service ae04f2
  </refmeta>
Packit Service ae04f2
Packit Service ae04f2
  <docinfo>
Packit Service ae04f2
    <copyright>
Packit Service ae04f2
      <year>2000</year>
Packit Service ae04f2
      <year>2001</year>
Packit Service ae04f2
      <year>2003</year>
Packit Service ae04f2
      <year>2004</year>
Packit Service ae04f2
      <year>2005</year>
Packit Service ae04f2
      <year>2007</year>
Packit Service ae04f2
      <year>2014</year>
Packit Service ae04f2
      <year>2015</year>
Packit Service ae04f2
      <year>2016</year>
Packit Service ae04f2
      <year>2018</year>
Packit Service ae04f2
      <year>2019</year>
Packit Service ae04f2
      <year>2020</year>
Packit Service ae04f2
      <holder>Internet Systems Consortium, Inc. ("ISC")</holder>
Packit Service ae04f2
    </copyright>
Packit Service ae04f2
  </docinfo>
Packit Service ae04f2
Packit Service ae04f2
  <refnamediv>
Packit Service ae04f2
    <refname>lwres_getaddrinfo</refname>
Packit Service ae04f2
    <refname>lwres_freeaddrinfo</refname>
Packit Service ae04f2
    <refpurpose>socket address structure to host and service name</refpurpose>
Packit Service ae04f2
  </refnamediv>
Packit Service ae04f2
  <refsynopsisdiv>
Packit Service ae04f2
    <funcsynopsis>
Packit Service ae04f2
<funcsynopsisinfo>#include <lwres/netdb.h></funcsynopsisinfo>
Packit Service ae04f2
<funcprototype>
Packit Service ae04f2
        <funcdef>
Packit Service ae04f2
int
Packit Service ae04f2
<function>lwres_getaddrinfo</function></funcdef>
Packit Service ae04f2
        <paramdef>const char *<parameter>hostname</parameter></paramdef>
Packit Service ae04f2
        <paramdef>const char *<parameter>servname</parameter></paramdef>
Packit Service ae04f2
        <paramdef>const struct addrinfo *<parameter>hints</parameter></paramdef>
Packit Service ae04f2
        <paramdef>struct addrinfo **<parameter>res</parameter></paramdef>
Packit Service ae04f2
        </funcprototype>
Packit Service ae04f2
<funcprototype>
Packit Service ae04f2
        <funcdef>
Packit Service ae04f2
void
Packit Service ae04f2
<function>lwres_freeaddrinfo</function></funcdef>
Packit Service ae04f2
        <paramdef>struct addrinfo *<parameter>ai</parameter></paramdef>
Packit Service ae04f2
      </funcprototype>
Packit Service ae04f2
</funcsynopsis>
Packit Service ae04f2
Packit Service ae04f2
    <para>
Packit Service ae04f2
      If the operating system does not provide a
Packit Service ae04f2
      <type>struct addrinfo</type>,
Packit Service ae04f2
      the following structure is used:
Packit Service ae04f2
    </para>
Packit Service ae04f2
    <para><programlisting>
Packit Service ae04f2
struct  addrinfo {
Packit Service ae04f2
        int             ai_flags;       /* AI_PASSIVE, AI_CANONNAME */
Packit Service ae04f2
        int             ai_family;      /* PF_xxx */
Packit Service ae04f2
        int             ai_socktype;    /* SOCK_xxx */
Packit Service ae04f2
        int             ai_protocol;    /* 0 or IPPROTO_xxx for IPv4 and IPv6 */
Packit Service ae04f2
        size_t          ai_addrlen;     /* length of ai_addr */
Packit Service ae04f2
        char            *ai_canonname;  /* canonical name for hostname */
Packit Service ae04f2
        struct sockaddr *ai_addr;       /* binary address */
Packit Service ae04f2
        struct addrinfo *ai_next;       /* next structure in linked list */
Packit Service ae04f2
};
Packit Service ae04f2
</programlisting>
Packit Service ae04f2
    </para>
Packit Service ae04f2
Packit Service ae04f2
  </refsynopsisdiv>
Packit Service ae04f2
Packit Service ae04f2
  <refsection><info><title>DESCRIPTION</title></info>
Packit Service ae04f2
Packit Service ae04f2
Packit Service ae04f2
    <para><function>lwres_getaddrinfo()</function>
Packit Service ae04f2
      is used to get a list of IP addresses and port numbers for host
Packit Service ae04f2
      <parameter>hostname</parameter> and service
Packit Service ae04f2
      <parameter>servname</parameter>.
Packit Service ae04f2
Packit Service ae04f2
      The function is the lightweight resolver's implementation of
Packit Service ae04f2
      <function>getaddrinfo()</function> as defined in RFC2133.
Packit Service ae04f2
      <parameter>hostname</parameter> and
Packit Service ae04f2
      <parameter>servname</parameter> are pointers to null-terminated
Packit Service ae04f2
      strings or <type>NULL</type>.
Packit Service ae04f2
Packit Service ae04f2
      <parameter>hostname</parameter> is either a host name or a
Packit Service ae04f2
      numeric host address string: a dotted decimal IPv4 address or an
Packit Service ae04f2
      IPv6 address.  <parameter>servname</parameter> is either a
Packit Service ae04f2
      decimal port number or a service name as listed in
Packit Service ae04f2
      <filename>/etc/services</filename>.
Packit Service ae04f2
    </para>
Packit Service ae04f2
Packit Service ae04f2
    <para><parameter>hints</parameter>
Packit Service ae04f2
      is an optional pointer to a
Packit Service ae04f2
      <type>struct addrinfo</type>.
Packit Service ae04f2
      This structure can be used to provide hints concerning the type of
Packit Service ae04f2
      socket
Packit Service ae04f2
      that the caller supports or wishes to use.
Packit Service ae04f2
      The caller can supply the following structure elements in
Packit Service ae04f2
      <parameter>*hints</parameter>:
Packit Service ae04f2
Packit Service ae04f2
      <variablelist>
Packit Service ae04f2
        <varlistentry>
Packit Service ae04f2
          <term><constant>ai_family</constant></term>
Packit Service ae04f2
          <listitem>
Packit Service ae04f2
            <para>
Packit Service ae04f2
              The protocol family that should be used.
Packit Service ae04f2
              When
Packit Service ae04f2
              <constant>ai_family</constant>
Packit Service ae04f2
              is set to
Packit Service ae04f2
              <type>PF_UNSPEC</type>,
Packit Service ae04f2
              it means the caller will accept any protocol family supported by
Packit Service ae04f2
              the
Packit Service ae04f2
              operating system.
Packit Service ae04f2
            </para>
Packit Service ae04f2
          </listitem>
Packit Service ae04f2
        </varlistentry>
Packit Service ae04f2
        <varlistentry>
Packit Service ae04f2
          <term><constant>ai_socktype</constant></term>
Packit Service ae04f2
          <listitem>
Packit Service ae04f2
            <para>
Packit Service ae04f2
              denotes the type of socket —
Packit Service ae04f2
              <type>SOCK_STREAM</type>,
Packit Service ae04f2
              <type>SOCK_DGRAM</type>
Packit Service ae04f2
              or
Packit Service ae04f2
              <type>SOCK_RAW</type>
Packit Service ae04f2
              — that is wanted.
Packit Service ae04f2
              When
Packit Service ae04f2
              <constant>ai_socktype</constant>
Packit Service ae04f2
              is zero the caller will accept any socket type.
Packit Service ae04f2
            </para>
Packit Service ae04f2
          </listitem>
Packit Service ae04f2
        </varlistentry>
Packit Service ae04f2
        <varlistentry>
Packit Service ae04f2
          <term><constant>ai_protocol</constant></term>
Packit Service ae04f2
          <listitem>
Packit Service ae04f2
            <para>
Packit Service ae04f2
              indicates which transport protocol is wanted: IPPROTO_UDP or
Packit Service ae04f2
              IPPROTO_TCP.
Packit Service ae04f2
              If
Packit Service ae04f2
              <constant>ai_protocol</constant>
Packit Service ae04f2
              is zero the caller will accept any protocol.
Packit Service ae04f2
            </para>
Packit Service ae04f2
          </listitem>
Packit Service ae04f2
        </varlistentry>
Packit Service ae04f2
        <varlistentry>
Packit Service ae04f2
          <term><constant>ai_flags</constant></term>
Packit Service ae04f2
          <listitem>
Packit Service ae04f2
            <para>
Packit Service ae04f2
              Flag bits.
Packit Service ae04f2
              If the
Packit Service ae04f2
              <type>AI_CANONNAME</type>
Packit Service ae04f2
              bit is set, a successful call to
Packit Service ae04f2
              <function>lwres_getaddrinfo()</function>
Packit Service ae04f2
              will return a null-terminated string containing the canonical
Packit Service ae04f2
              name
Packit Service ae04f2
              of the specified hostname in
Packit Service ae04f2
              <constant>ai_canonname</constant>
Packit Service ae04f2
              of the first
Packit Service ae04f2
              <type>addrinfo</type>
Packit Service ae04f2
              structure returned.
Packit Service ae04f2
              Setting the
Packit Service ae04f2
              <type>AI_PASSIVE</type>
Packit Service ae04f2
              bit indicates that the returned socket address structure is
Packit Service ae04f2
              intended
Packit Service ae04f2
              for used in a call to
Packit Service ae04f2
              <citerefentry>
Packit Service ae04f2
                <refentrytitle>bind</refentrytitle><manvolnum>2</manvolnum>
Packit Service ae04f2
              </citerefentry>.
Packit Service ae04f2
Packit Service ae04f2
              In this case, if the hostname argument is a
Packit Service ae04f2
              <type>NULL</type>
Packit Service ae04f2
              pointer, then the IP address portion of the socket
Packit Service ae04f2
              address structure will be set to
Packit Service ae04f2
              <type>INADDR_ANY</type>
Packit Service ae04f2
              for an IPv4 address or
Packit Service ae04f2
              <type>IN6ADDR_ANY_INIT</type>
Packit Service ae04f2
              for an IPv6 address.
Packit Service ae04f2
            </para>
Packit Service ae04f2
            <para>
Packit Service ae04f2
              When
Packit Service ae04f2
              <constant>ai_flags</constant>
Packit Service ae04f2
              does not set the
Packit Service ae04f2
              <type>AI_PASSIVE</type>
Packit Service ae04f2
              bit, the returned socket address structure will be ready
Packit Service ae04f2
              for use in a call to
Packit Service ae04f2
              <citerefentry>
Packit Service ae04f2
                <refentrytitle>connect</refentrytitle><manvolnum>2</manvolnum>
Packit Service ae04f2
              </citerefentry>
Packit Service ae04f2
              for a connection-oriented protocol or
Packit Service ae04f2
              <citerefentry>
Packit Service ae04f2
                <refentrytitle>connect</refentrytitle><manvolnum>2</manvolnum>
Packit Service ae04f2
              </citerefentry>,
Packit Service ae04f2
Packit Service ae04f2
              <citerefentry>
Packit Service ae04f2
                <refentrytitle>sendto</refentrytitle><manvolnum>2</manvolnum>
Packit Service ae04f2
              </citerefentry>,
Packit Service ae04f2
Packit Service ae04f2
              or
Packit Service ae04f2
              <citerefentry>
Packit Service ae04f2
                <refentrytitle>sendmsg</refentrytitle><manvolnum>2</manvolnum>
Packit Service ae04f2
              </citerefentry>
Packit Service ae04f2
              if a connectionless protocol was chosen.
Packit Service ae04f2
              The IP address portion of the socket address structure will be
Packit Service ae04f2
              set to the loopback address if
Packit Service ae04f2
              <parameter>hostname</parameter>
Packit Service ae04f2
              is a
Packit Service ae04f2
              <type>NULL</type>
Packit Service ae04f2
              pointer and
Packit Service ae04f2
              <type>AI_PASSIVE</type>
Packit Service ae04f2
              is not set in
Packit Service ae04f2
              <constant>ai_flags</constant>.
Packit Service ae04f2
            </para>
Packit Service ae04f2
            <para>
Packit Service ae04f2
              If
Packit Service ae04f2
              <constant>ai_flags</constant>
Packit Service ae04f2
              is set to
Packit Service ae04f2
              <type>AI_NUMERICHOST</type>
Packit Service ae04f2
              it indicates that
Packit Service ae04f2
              <parameter>hostname</parameter>
Packit Service ae04f2
              should be treated as a numeric string defining an IPv4 or IPv6
Packit Service ae04f2
              address
Packit Service ae04f2
              and no name resolution should be attempted.
Packit Service ae04f2
            </para>
Packit Service ae04f2
          </listitem>
Packit Service ae04f2
        </varlistentry>
Packit Service ae04f2
      </variablelist>
Packit Service ae04f2
    </para>
Packit Service ae04f2
Packit Service ae04f2
    <para>
Packit Service ae04f2
      All other elements of the <type>struct addrinfo</type> passed
Packit Service ae04f2
      via <parameter>hints</parameter> must be zero.
Packit Service ae04f2
    </para>
Packit Service ae04f2
Packit Service ae04f2
    <para>
Packit Service ae04f2
      A <parameter>hints</parameter> of <type>NULL</type> is
Packit Service ae04f2
      treated as if
Packit Service ae04f2
      the caller provided a <type>struct addrinfo</type> initialized to zero
Packit Service ae04f2
      with <constant>ai_family</constant>set to
Packit Service ae04f2
      <constant>PF_UNSPEC</constant>.
Packit Service ae04f2
    </para>
Packit Service ae04f2
Packit Service ae04f2
    <para>
Packit Service ae04f2
      After a successful call to
Packit Service ae04f2
      <function>lwres_getaddrinfo()</function>,
Packit Service ae04f2
      <parameter>*res</parameter>
Packit Service ae04f2
      is a pointer to a linked list of one or more
Packit Service ae04f2
      <type>addrinfo</type>
Packit Service ae04f2
      structures.
Packit Service ae04f2
      Each
Packit Service ae04f2
      <type>struct addrinfo</type>
Packit Service ae04f2
      in this list cn be processed by following
Packit Service ae04f2
      the
Packit Service ae04f2
      <constant>ai_next</constant>
Packit Service ae04f2
      pointer, until a
Packit Service ae04f2
      <type>NULL</type>
Packit Service ae04f2
      pointer is encountered.
Packit Service ae04f2
      The three members
Packit Service ae04f2
      <constant>ai_family</constant>,
Packit Service ae04f2
      <constant>ai_socktype</constant>,
Packit Service ae04f2
      and
Packit Service ae04f2
      <constant>ai_protocol</constant>
Packit Service ae04f2
      in each
Packit Service ae04f2
      returned
Packit Service ae04f2
      <type>addrinfo</type>
Packit Service ae04f2
      structure contain the corresponding arguments for a call to
Packit Service ae04f2
      <citerefentry>
Packit Service ae04f2
        <refentrytitle>socket</refentrytitle><manvolnum>2</manvolnum>
Packit Service ae04f2
      </citerefentry>.
Packit Service ae04f2
      For each
Packit Service ae04f2
      <type>addrinfo</type>
Packit Service ae04f2
      structure in the list, the
Packit Service ae04f2
      <constant>ai_addr</constant>
Packit Service ae04f2
      member points to a filled-in socket address structure of length
Packit Service ae04f2
      <constant>ai_addrlen</constant>.
Packit Service ae04f2
    </para>
Packit Service ae04f2
Packit Service ae04f2
    <para>
Packit Service ae04f2
      All of the information returned by
Packit Service ae04f2
      <function>lwres_getaddrinfo()</function>
Packit Service ae04f2
      is dynamically allocated: the addrinfo structures, and the socket
Packit Service ae04f2
      address structures and canonical host name strings pointed to by the
Packit Service ae04f2
      <constant>addrinfo</constant>structures.
Packit Service ae04f2
      Memory allocated for the dynamically allocated structures created by
Packit Service ae04f2
      a successful call to
Packit Service ae04f2
      <function>lwres_getaddrinfo()</function>
Packit Service ae04f2
      is released by
Packit Service ae04f2
      <function>lwres_freeaddrinfo()</function>.
Packit Service ae04f2
      <parameter>ai</parameter>
Packit Service ae04f2
      is a pointer to a
Packit Service ae04f2
      <type>struct addrinfo</type>
Packit Service ae04f2
      created by a call to
Packit Service ae04f2
      <function>lwres_getaddrinfo()</function>.
Packit Service ae04f2
    </para>
Packit Service ae04f2
Packit Service ae04f2
  </refsection>
Packit Service ae04f2
Packit Service ae04f2
  <refsection><info><title>RETURN VALUES</title></info>
Packit Service ae04f2
Packit Service ae04f2
Packit Service ae04f2
    <para><function>lwres_getaddrinfo()</function>
Packit Service ae04f2
      returns zero on success or one of the error codes listed in
Packit Service ae04f2
      <citerefentry>
Packit Service ae04f2
        <refentrytitle>gai_strerror</refentrytitle><manvolnum>3</manvolnum>
Packit Service ae04f2
      </citerefentry>
Packit Service ae04f2
      if an error occurs.  If both <parameter>hostname</parameter> and
Packit Service ae04f2
      <parameter>servname</parameter> are <type>NULL</type>
Packit Service ae04f2
      <function>lwres_getaddrinfo()</function> returns
Packit Service ae04f2
      <errorcode>EAI_NONAME</errorcode>.
Packit Service ae04f2
    </para>
Packit Service ae04f2
  </refsection>
Packit Service ae04f2
  <refsection><info><title>SEE ALSO</title></info>
Packit Service ae04f2
Packit Service ae04f2
    <para><citerefentry>
Packit Service ae04f2
        <refentrytitle>lwres</refentrytitle><manvolnum>3</manvolnum>
Packit Service ae04f2
      </citerefentry>,
Packit Service ae04f2
Packit Service ae04f2
      <citerefentry>
Packit Service ae04f2
        <refentrytitle>lwres_getaddrinfo</refentrytitle><manvolnum>3</manvolnum>
Packit Service ae04f2
      </citerefentry>,
Packit Service ae04f2
Packit Service ae04f2
      <citerefentry>
Packit Service ae04f2
        <refentrytitle>lwres_freeaddrinfo</refentrytitle><manvolnum>3</manvolnum>
Packit Service ae04f2
      </citerefentry>,
Packit Service ae04f2
Packit Service ae04f2
      <citerefentry>
Packit Service ae04f2
        <refentrytitle>lwres_gai_strerror</refentrytitle><manvolnum>3</manvolnum>
Packit Service ae04f2
      </citerefentry>,
Packit Service ae04f2
Packit Service ae04f2
      <citerefentry>
Packit Service ae04f2
        <refentrytitle>RFC2133</refentrytitle>
Packit Service ae04f2
      </citerefentry>,
Packit Service ae04f2
Packit Service ae04f2
      <citerefentry>
Packit Service ae04f2
        <refentrytitle>getservbyname</refentrytitle><manvolnum>3</manvolnum>
Packit Service ae04f2
      </citerefentry>,
Packit Service ae04f2
Packit Service ae04f2
      <citerefentry>
Packit Service ae04f2
        <refentrytitle>bind</refentrytitle><manvolnum>2</manvolnum>
Packit Service ae04f2
      </citerefentry>,
Packit Service ae04f2
Packit Service ae04f2
      <citerefentry>
Packit Service ae04f2
        <refentrytitle>connect</refentrytitle><manvolnum>2</manvolnum>
Packit Service ae04f2
      </citerefentry>,
Packit Service ae04f2
Packit Service ae04f2
      <citerefentry>
Packit Service ae04f2
        <refentrytitle>sendto</refentrytitle><manvolnum>2</manvolnum>
Packit Service ae04f2
      </citerefentry>,
Packit Service ae04f2
Packit Service ae04f2
      <citerefentry>
Packit Service ae04f2
        <refentrytitle>sendmsg</refentrytitle><manvolnum>2</manvolnum>
Packit Service ae04f2
      </citerefentry>,
Packit Service ae04f2
Packit Service ae04f2
      <citerefentry>
Packit Service ae04f2
        <refentrytitle>socket</refentrytitle><manvolnum>2</manvolnum>
Packit Service ae04f2
      </citerefentry>.
Packit Service ae04f2
    </para>
Packit Service ae04f2
Packit Service ae04f2
  </refsection>
Packit Service ae04f2
</refentry>