Blame lib/lwres/man/lwres_gethostent.docbook

Packit 5ce601
Packit 5ce601
]>
Packit 5ce601
Packit 5ce601
 - Copyright (C) Internet Systems Consortium, Inc. ("ISC")
Packit 5ce601
 -
Packit 5ce601
 - This Source Code Form is subject to the terms of the Mozilla Public
Packit 5ce601
 - License, v. 2.0. If a copy of the MPL was not distributed with this
Packit Service 704ed8
 - file, you can obtain one at https://mozilla.org/MPL/2.0/.
Packit 5ce601
 -
Packit 5ce601
 - See the COPYRIGHT file distributed with this work for additional
Packit 5ce601
 - information regarding copyright ownership.
Packit 5ce601
-->
Packit 5ce601
Packit 5ce601
Packit Service 704ed8
<refentry xmlns="http://docbook.org/ns/docbook" version="5.0">
Packit 5ce601
  <info>
Packit 5ce601
    <date>2007-06-18</date>
Packit 5ce601
  </info>
Packit 5ce601
  <refentryinfo>
Packit 5ce601
    <corpname>ISC</corpname>
Packit 5ce601
    <corpauthor>Internet Systems Consortium, Inc.</corpauthor>
Packit 5ce601
  </refentryinfo>
Packit 5ce601
Packit 5ce601
  <refmeta>
Packit 5ce601
    <refentrytitle>lwres_gethostent</refentrytitle>
Packit 5ce601
    <manvolnum>3</manvolnum>
Packit Service d3afd5
    <refmiscinfo>BIND9</refmiscinfo>
Packit 5ce601
  </refmeta>
Packit 5ce601
Packit 5ce601
  <docinfo>
Packit 5ce601
    <copyright>
Packit 5ce601
      <year>2001</year>
Packit 5ce601
      <year>2004</year>
Packit 5ce601
      <year>2005</year>
Packit 5ce601
      <year>2007</year>
Packit 5ce601
      <year>2014</year>
Packit 5ce601
      <year>2015</year>
Packit 5ce601
      <year>2016</year>
Packit 5ce601
      <year>2018</year>
Packit 5ce601
      <year>2019</year>
Packit 5ce601
      <year>2020</year>
Packit 5ce601
      <holder>Internet Systems Consortium, Inc. ("ISC")</holder>
Packit 5ce601
    </copyright>
Packit 5ce601
  </docinfo>
Packit 5ce601
Packit 5ce601
  <refnamediv>
Packit 5ce601
    <refname>lwres_gethostbyname</refname>
Packit 5ce601
    <refname>lwres_gethostbyname2</refname>
Packit 5ce601
    <refname>lwres_gethostbyaddr</refname>
Packit 5ce601
    <refname>lwres_gethostent</refname>
Packit 5ce601
    <refname>lwres_sethostent</refname>
Packit 5ce601
    <refname>lwres_endhostent</refname>
Packit 5ce601
    <refname>lwres_gethostbyname_r</refname>
Packit 5ce601
    <refname>lwres_gethostbyaddr_r</refname>
Packit 5ce601
    <refname>lwres_gethostent_r</refname>
Packit 5ce601
    <refname>lwres_sethostent_r</refname>
Packit 5ce601
    <refname>lwres_endhostent_r</refname>
Packit 5ce601
    <refpurpose>lightweight resolver get network host entry</refpurpose>
Packit 5ce601
  </refnamediv>
Packit 5ce601
  <refsynopsisdiv>
Packit 5ce601
    <funcsynopsis>
Packit 5ce601
<funcsynopsisinfo>#include <lwres/netdb.h></funcsynopsisinfo>
Packit 5ce601
<funcprototype>
Packit 5ce601
        <funcdef>
Packit 5ce601
struct hostent *
Packit 5ce601
<function>lwres_gethostbyname</function></funcdef>
Packit 5ce601
        <paramdef>const char *<parameter>name</parameter></paramdef>
Packit 5ce601
        </funcprototype>
Packit 5ce601
<funcprototype>
Packit 5ce601
        <funcdef>
Packit 5ce601
struct hostent *
Packit 5ce601
<function>lwres_gethostbyname2</function></funcdef>
Packit 5ce601
        <paramdef>const char *<parameter>name</parameter></paramdef>
Packit 5ce601
        <paramdef>int <parameter>af</parameter></paramdef>
Packit 5ce601
        </funcprototype>
Packit 5ce601
<funcprototype>
Packit 5ce601
        <funcdef>
Packit 5ce601
struct hostent *
Packit 5ce601
<function>lwres_gethostbyaddr</function></funcdef>
Packit 5ce601
        <paramdef>const char *<parameter>addr</parameter></paramdef>
Packit 5ce601
        <paramdef>int <parameter>len</parameter></paramdef>
Packit 5ce601
        <paramdef>int <parameter>type</parameter></paramdef>
Packit 5ce601
        </funcprototype>
Packit 5ce601
<funcprototype>
Packit 5ce601
        <funcdef>
Packit 5ce601
struct hostent *
Packit 5ce601
<function>lwres_gethostent</function></funcdef>
Packit 5ce601
        <paramdef>void</paramdef>
Packit 5ce601
        </funcprototype>
Packit 5ce601
<funcprototype>
Packit 5ce601
        <funcdef>
Packit 5ce601
void
Packit 5ce601
<function>lwres_sethostent</function></funcdef>
Packit 5ce601
        <paramdef>int <parameter>stayopen</parameter></paramdef>
Packit 5ce601
        </funcprototype>
Packit 5ce601
<funcprototype>
Packit 5ce601
        <funcdef>
Packit 5ce601
void
Packit 5ce601
<function>lwres_endhostent</function></funcdef>
Packit 5ce601
        <paramdef>void</paramdef>
Packit 5ce601
        </funcprototype>
Packit 5ce601
<funcprototype>
Packit 5ce601
        <funcdef>
Packit 5ce601
struct hostent *
Packit 5ce601
<function>lwres_gethostbyname_r</function></funcdef>
Packit 5ce601
        <paramdef>const char *<parameter>name</parameter></paramdef>
Packit 5ce601
        <paramdef>struct hostent *<parameter>resbuf</parameter></paramdef>
Packit 5ce601
        <paramdef>char *<parameter>buf</parameter></paramdef>
Packit 5ce601
        <paramdef>int <parameter>buflen</parameter></paramdef>
Packit 5ce601
        <paramdef>int *<parameter>error</parameter></paramdef>
Packit 5ce601
        </funcprototype>
Packit 5ce601
<funcprototype>
Packit 5ce601
        <funcdef>
Packit 5ce601
struct hostent  *
Packit 5ce601
<function>lwres_gethostbyaddr_r</function></funcdef>
Packit 5ce601
        <paramdef>const char *<parameter>addr</parameter></paramdef>
Packit 5ce601
        <paramdef>int <parameter>len</parameter></paramdef>
Packit 5ce601
        <paramdef>int <parameter>type</parameter></paramdef>
Packit 5ce601
        <paramdef>struct hostent *<parameter>resbuf</parameter></paramdef>
Packit 5ce601
        <paramdef>char *<parameter>buf</parameter></paramdef>
Packit 5ce601
        <paramdef>int <parameter>buflen</parameter></paramdef>
Packit 5ce601
        <paramdef>int *<parameter>error</parameter></paramdef>
Packit 5ce601
        </funcprototype>
Packit 5ce601
<funcprototype>
Packit 5ce601
        <funcdef>
Packit 5ce601
struct hostent  *
Packit 5ce601
<function>lwres_gethostent_r</function></funcdef>
Packit 5ce601
        <paramdef>struct hostent *<parameter>resbuf</parameter></paramdef>
Packit 5ce601
        <paramdef>char *<parameter>buf</parameter></paramdef>
Packit 5ce601
        <paramdef>int <parameter>buflen</parameter></paramdef>
Packit 5ce601
        <paramdef>int *<parameter>error</parameter></paramdef>
Packit 5ce601
        </funcprototype>
Packit 5ce601
<funcprototype>
Packit 5ce601
        <funcdef>
Packit 5ce601
void
Packit 5ce601
<function>lwres_sethostent_r</function></funcdef>
Packit 5ce601
        <paramdef>int <parameter>stayopen</parameter></paramdef>
Packit 5ce601
        </funcprototype>
Packit 5ce601
<funcprototype>
Packit 5ce601
        <funcdef>
Packit 5ce601
void
Packit 5ce601
<function>lwres_endhostent_r</function></funcdef>
Packit 5ce601
        <paramdef>void</paramdef>
Packit 5ce601
      </funcprototype>
Packit 5ce601
</funcsynopsis>
Packit 5ce601
  </refsynopsisdiv>
Packit 5ce601
Packit 5ce601
  <refsection><info><title>DESCRIPTION</title></info>
Packit 5ce601
Packit 5ce601
    <para>
Packit 5ce601
      These functions provide hostname-to-address and
Packit 5ce601
      address-to-hostname lookups by means of the lightweight resolver.
Packit 5ce601
      They are similar to the standard
Packit 5ce601
      <citerefentry>
Packit 5ce601
        <refentrytitle>gethostent</refentrytitle><manvolnum>3</manvolnum>
Packit 5ce601
      </citerefentry>
Packit 5ce601
      functions provided by most operating systems.
Packit 5ce601
      They use a
Packit 5ce601
      <type>struct hostent</type>
Packit 5ce601
      which is usually defined in
Packit 5ce601
      <filename><namedb.h></filename>.
Packit 5ce601
    </para>
Packit 5ce601
    <para><programlisting>
Packit 5ce601
struct  hostent {
Packit 5ce601
        char    *h_name;        /* official name of host */
Packit 5ce601
        char    **h_aliases;    /* alias list */
Packit 5ce601
        int     h_addrtype;     /* host address type */
Packit 5ce601
        int     h_length;       /* length of address */
Packit 5ce601
        char    **h_addr_list;  /* list of addresses from name server */
Packit 5ce601
};
Packit 5ce601
#define h_addr  h_addr_list[0]  /* address, for backward compatibility */
Packit 5ce601
</programlisting>
Packit 5ce601
    </para>
Packit 5ce601
    <para>
Packit 5ce601
      The members of this structure are:
Packit 5ce601
      <variablelist>
Packit 5ce601
        <varlistentry>
Packit 5ce601
          <term><constant>h_name</constant></term>
Packit 5ce601
          <listitem>
Packit 5ce601
            <para>
Packit 5ce601
              The official (canonical) name of the host.
Packit 5ce601
            </para>
Packit 5ce601
          </listitem>
Packit 5ce601
        </varlistentry>
Packit 5ce601
        <varlistentry>
Packit 5ce601
          <term><constant>h_aliases</constant></term>
Packit 5ce601
          <listitem>
Packit 5ce601
            <para>
Packit 5ce601
              A NULL-terminated array of alternate names (nicknames) for the
Packit 5ce601
              host.
Packit 5ce601
            </para>
Packit 5ce601
          </listitem>
Packit 5ce601
        </varlistentry>
Packit 5ce601
        <varlistentry>
Packit 5ce601
          <term><constant>h_addrtype</constant></term>
Packit 5ce601
          <listitem>
Packit 5ce601
            <para>
Packit 5ce601
              The type of address being returned —
Packit 5ce601
              <type>PF_INET</type>
Packit 5ce601
              or
Packit 5ce601
              <type>PF_INET6</type>.
Packit 5ce601
            </para>
Packit 5ce601
          </listitem>
Packit 5ce601
        </varlistentry>
Packit 5ce601
        <varlistentry>
Packit 5ce601
          <term><constant>h_length</constant></term>
Packit 5ce601
          <listitem>
Packit 5ce601
            <para>
Packit 5ce601
              The length of the address in bytes.
Packit 5ce601
            </para>
Packit 5ce601
          </listitem>
Packit 5ce601
        </varlistentry>
Packit 5ce601
        <varlistentry>
Packit 5ce601
          <term><constant>h_addr_list</constant></term>
Packit 5ce601
          <listitem>
Packit 5ce601
            <para>
Packit 5ce601
              A <type>NULL</type>
Packit 5ce601
              terminated array of network addresses for the host.
Packit 5ce601
              Host addresses are returned in network byte order.
Packit 5ce601
            </para>
Packit 5ce601
          </listitem>
Packit 5ce601
        </varlistentry>
Packit 5ce601
      </variablelist>
Packit 5ce601
    </para>
Packit 5ce601
    <para>
Packit 5ce601
      For backward compatibility with very old software,
Packit 5ce601
      <constant>h_addr</constant>
Packit 5ce601
      is the first address in
Packit 5ce601
      <constant>h_addr_list.</constant>
Packit 5ce601
    </para>
Packit 5ce601
    <para><function>lwres_gethostent()</function>,
Packit 5ce601
      <function>lwres_sethostent()</function>,
Packit 5ce601
      <function>lwres_endhostent()</function>,
Packit 5ce601
      <function>lwres_gethostent_r()</function>,
Packit 5ce601
      <function>lwres_sethostent_r()</function>
Packit 5ce601
      and
Packit 5ce601
      <function>lwres_endhostent_r()</function>
Packit 5ce601
      provide iteration over the known host entries on systems that
Packit 5ce601
      provide such functionality through facilities like
Packit 5ce601
      <filename>/etc/hosts</filename>
Packit 5ce601
      or NIS.  The lightweight resolver does not currently implement
Packit 5ce601
      these functions; it only provides them as stub functions that always
Packit 5ce601
      return failure.
Packit 5ce601
    </para>
Packit 5ce601
Packit 5ce601
    <para><function>lwres_gethostbyname()</function>
Packit 5ce601
      and <function>lwres_gethostbyname2()</function> look up the
Packit 5ce601
      hostname <parameter>name</parameter>.
Packit 5ce601
      <function>lwres_gethostbyname()</function> always looks for an
Packit 5ce601
      IPv4 address while <function>lwres_gethostbyname2()</function>
Packit 5ce601
      looks for an address of protocol family
Packit 5ce601
      <parameter>af</parameter>: either <type>PF_INET</type> or
Packit 5ce601
      <type>PF_INET6</type> — IPv4 or IPV6 addresses
Packit 5ce601
      respectively.  Successful calls of the functions return a
Packit 5ce601
      <type>struct hostent</type>for the name that was looked up.
Packit 5ce601
      <type>NULL</type> is returned if the lookups by
Packit 5ce601
      <function>lwres_gethostbyname()</function> or
Packit 5ce601
      <function>lwres_gethostbyname2()</function> fail.
Packit 5ce601
    </para>
Packit 5ce601
Packit 5ce601
    <para>
Packit 5ce601
      Reverse lookups of addresses are performed by
Packit 5ce601
      <function>lwres_gethostbyaddr()</function>.
Packit 5ce601
      <parameter>addr</parameter> is an address of length
Packit 5ce601
      <parameter>len</parameter> bytes and protocol family
Packit 5ce601
      <parameter>type</parameter> — <type>PF_INET</type> or
Packit 5ce601
      <type>PF_INET6</type>.
Packit 5ce601
      <function>lwres_gethostbyname_r()</function> is a
Packit 5ce601
      thread-safe function
Packit 5ce601
      for forward lookups.  If an error occurs, an error code is returned in
Packit 5ce601
      <parameter>*error</parameter>.
Packit 5ce601
      <parameter>resbuf</parameter> is a pointer to a
Packit 5ce601
      <type>struct hostent</type> which is initialised by a successful call to
Packit 5ce601
      <function>lwres_gethostbyname_r()</function>.
Packit 5ce601
      <parameter>buf</parameter> is a buffer of length
Packit 5ce601
      <parameter>len</parameter> bytes which is used to store the
Packit 5ce601
      <constant>h_name</constant>, <constant>h_aliases</constant>, and
Packit 5ce601
      <constant>h_addr_list</constant> elements of the
Packit 5ce601
      <type>struct hostent</type> returned in <parameter>resbuf</parameter>.
Packit 5ce601
      Successful calls to <function>lwres_gethostbyname_r()</function>
Packit 5ce601
      return <parameter>resbuf</parameter>,
Packit 5ce601
      which is a pointer to the <type>struct hostent</type> it created.
Packit 5ce601
    </para>
Packit 5ce601
Packit 5ce601
    <para><function>lwres_gethostbyaddr_r()</function>
Packit 5ce601
      is a thread-safe function
Packit 5ce601
      that performs a reverse lookup of address <parameter>addr</parameter>
Packit 5ce601
      which is <parameter>len</parameter> bytes long and is of
Packit 5ce601
      protocol
Packit 5ce601
      family <parameter>type</parameter> — <type>PF_INET</type> or
Packit 5ce601
      <type>PF_INET6</type>.  If an error occurs, the error code is returned
Packit 5ce601
      in <parameter>*error</parameter>.  The other function
Packit 5ce601
      parameters are
Packit 5ce601
      identical to those in <function>lwres_gethostbyname_r()</function>.
Packit 5ce601
      <parameter>resbuf</parameter> is a pointer to a
Packit 5ce601
      <type>struct hostent</type> which is initialised by a successful call to
Packit 5ce601
      <function>lwres_gethostbyaddr_r()</function>.
Packit 5ce601
      <parameter>buf</parameter> is a buffer of length
Packit 5ce601
      <parameter>len</parameter> bytes which is used to store the
Packit 5ce601
      <constant>h_name</constant>, <constant>h_aliases</constant>, and
Packit 5ce601
      <constant>h_addr_list</constant> elements of the
Packit 5ce601
      <type>struct hostent</type> returned in <parameter>resbuf</parameter>.
Packit 5ce601
      Successful calls to <function>lwres_gethostbyaddr_r()</function> return
Packit 5ce601
      <parameter>resbuf</parameter>, which is a pointer to the
Packit 5ce601
      <function>struct hostent()</function> it created.
Packit 5ce601
    </para>
Packit 5ce601
Packit 5ce601
  </refsection>
Packit 5ce601
Packit 5ce601
  <refsection><info><title>RETURN VALUES</title></info>
Packit 5ce601
Packit 5ce601
    <para>
Packit 5ce601
      The functions
Packit 5ce601
      <function>lwres_gethostbyname()</function>,
Packit 5ce601
      <function>lwres_gethostbyname2()</function>,
Packit 5ce601
      <function>lwres_gethostbyaddr()</function>,
Packit 5ce601
      and
Packit 5ce601
      <function>lwres_gethostent()</function>
Packit 5ce601
      return NULL to indicate an error.  In this case the global variable
Packit 5ce601
      <type>lwres_h_errno</type>
Packit 5ce601
      will contain one of the following error codes defined in
Packit 5ce601
      <filename><lwres/netdb.h></filename>:
Packit 5ce601
Packit 5ce601
      <variablelist>
Packit 5ce601
        <varlistentry>
Packit 5ce601
          <term><constant>HOST_NOT_FOUND</constant></term>
Packit 5ce601
          <listitem>
Packit 5ce601
            <para>
Packit 5ce601
              The host or address was not found.
Packit 5ce601
            </para>
Packit 5ce601
          </listitem>
Packit 5ce601
        </varlistentry>
Packit 5ce601
        <varlistentry>
Packit 5ce601
          <term><constant>TRY_AGAIN</constant></term>
Packit 5ce601
          <listitem>
Packit 5ce601
            <para>
Packit 5ce601
              A recoverable error occurred, e.g., a timeout.
Packit 5ce601
              Retrying the lookup may succeed.
Packit 5ce601
            </para>
Packit 5ce601
          </listitem>
Packit 5ce601
        </varlistentry>
Packit 5ce601
        <varlistentry>
Packit 5ce601
          <term><constant>NO_RECOVERY</constant></term>
Packit 5ce601
          <listitem>
Packit 5ce601
            <para>
Packit 5ce601
              A non-recoverable error occurred.
Packit 5ce601
            </para>
Packit 5ce601
          </listitem>
Packit 5ce601
        </varlistentry>
Packit 5ce601
        <varlistentry>
Packit 5ce601
          <term><constant>NO_DATA</constant></term>
Packit 5ce601
          <listitem>
Packit 5ce601
            <para>
Packit 5ce601
              The name exists, but has no address information
Packit 5ce601
              associated with it (or vice versa in the case
Packit 5ce601
              of a reverse lookup).  The code NO_ADDRESS
Packit 5ce601
              is accepted as a synonym for NO_DATA for backwards
Packit 5ce601
              compatibility.
Packit 5ce601
            </para>
Packit 5ce601
          </listitem>
Packit 5ce601
        </varlistentry>
Packit 5ce601
      </variablelist>
Packit 5ce601
    </para>
Packit 5ce601
Packit 5ce601
    <para><citerefentry>
Packit 5ce601
        <refentrytitle>lwres_hstrerror</refentrytitle><manvolnum>3</manvolnum>
Packit 5ce601
      </citerefentry>
Packit 5ce601
      translates these error codes to suitable error messages.
Packit 5ce601
    </para>
Packit 5ce601
Packit 5ce601
    <para><function>lwres_gethostent()</function>
Packit 5ce601
      and <function>lwres_gethostent_r()</function>
Packit 5ce601
      always return <type>NULL</type>.
Packit 5ce601
    </para>
Packit 5ce601
Packit 5ce601
    <para>
Packit 5ce601
      Successful calls to <function>lwres_gethostbyname_r()</function> and
Packit 5ce601
      <function>lwres_gethostbyaddr_r()</function> return
Packit 5ce601
      <parameter>resbuf</parameter>, a pointer to the
Packit 5ce601
      <type>struct hostent</type> that was initialised by these functions.  They return
Packit 5ce601
      <type>NULL</type> if the lookups fail or if <parameter>buf</parameter>
Packit 5ce601
      was too small to hold the list of addresses and names referenced by
Packit 5ce601
      the <constant>h_name</constant>, <constant>h_aliases</constant>, and
Packit 5ce601
      <constant>h_addr_list</constant> elements of the
Packit 5ce601
      <type>struct hostent</type>.
Packit 5ce601
      If <parameter>buf</parameter> was too small, both
Packit 5ce601
      <function>lwres_gethostbyname_r()</function> and
Packit 5ce601
      <function>lwres_gethostbyaddr_r()</function> set the global
Packit 5ce601
      variable
Packit 5ce601
      <type>errno</type> to <errorcode>ERANGE</errorcode>.
Packit 5ce601
    </para>
Packit 5ce601
Packit 5ce601
  </refsection>
Packit 5ce601
  <refsection><info><title>SEE ALSO</title></info>
Packit 5ce601
Packit 5ce601
    <para><citerefentry>
Packit 5ce601
        <refentrytitle>gethostent</refentrytitle><manvolnum>3</manvolnum>
Packit 5ce601
      </citerefentry>,
Packit 5ce601
Packit 5ce601
      <citerefentry>
Packit 5ce601
        <refentrytitle>lwres_getipnode</refentrytitle><manvolnum>3</manvolnum>
Packit 5ce601
      </citerefentry>,
Packit 5ce601
Packit 5ce601
      <citerefentry>
Packit 5ce601
        <refentrytitle>lwres_hstrerror</refentrytitle><manvolnum>3</manvolnum>
Packit 5ce601
      </citerefentry>
Packit 5ce601
    </para>
Packit 5ce601
  </refsection>
Packit 5ce601
Packit 5ce601
  <refsection><info><title>BUGS</title></info>
Packit 5ce601
Packit 5ce601
    <para><function>lwres_gethostbyname()</function>,
Packit 5ce601
      <function>lwres_gethostbyname2()</function>,
Packit 5ce601
      <function>lwres_gethostbyaddr()</function>
Packit 5ce601
      and
Packit 5ce601
      <function>lwres_endhostent()</function>
Packit 5ce601
      are not thread safe; they return pointers to static data and
Packit 5ce601
      provide error codes through a global variable.
Packit 5ce601
      Thread-safe versions for name and address lookup are provided by
Packit 5ce601
      <function>lwres_gethostbyname_r()</function>,
Packit 5ce601
      and
Packit 5ce601
      <function>lwres_gethostbyaddr_r()</function>
Packit 5ce601
      respectively.
Packit 5ce601
    </para>
Packit 5ce601
    <para>
Packit 5ce601
      The resolver daemon does not currently support any non-DNS
Packit 5ce601
      name services such as
Packit 5ce601
      <filename>/etc/hosts</filename>
Packit 5ce601
      or
Packit 5ce601
      <type>NIS</type>,
Packit 5ce601
      consequently the above functions don't, either.
Packit 5ce601
    </para>
Packit 5ce601
  </refsection>
Packit 5ce601
</refentry>