d6fa26d0adaec6c910115be34fe7a5a5f402c14fMark Andrews<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
5347c0fcb04eaea19d9f39795646239f487c6207Tinderbox User - Copyright (C) 2001, 2004, 2005, 2007, 2014-2016 Internet Systems Consortium, Inc. ("ISC")
5347c0fcb04eaea19d9f39795646239f487c6207Tinderbox User - This Source Code Form is subject to the terms of the Mozilla Public
5347c0fcb04eaea19d9f39795646239f487c6207Tinderbox User - License, v. 2.0. If a copy of the MPL was not distributed with this
5347c0fcb04eaea19d9f39795646239f487c6207Tinderbox User - file, You can obtain one at http://mozilla.org/MPL/2.0/.
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
fd2597f75693a2279fdf588bd40dfe2407c42028Tinderbox User<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
fd2597f75693a2279fdf588bd40dfe2407c42028Tinderbox User<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="refentry">
fd2597f75693a2279fdf588bd40dfe2407c42028Tinderbox User<a name="id-1"></a><div class="titlepage"></div>
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User lwres_gethostbyname,
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User lwres_gethostbyname2,
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User lwres_gethostbyaddr,
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User lwres_gethostent,
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User lwres_sethostent,
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User lwres_endhostent,
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User lwres_gethostbyname_r,
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User lwres_gethostbyaddr_r,
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User lwres_gethostent_r,
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User lwres_sethostent_r,
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User lwres_endhostent_r
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User — lightweight resolver get network host entry
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein<pre class="funcsynopsisinfo">#include <lwres/netdb.h></pre>
fd2597f75693a2279fdf588bd40dfe2407c42028Tinderbox User<table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austeinstruct hostent *
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein<b class="fsfunc">lwres_gethostbyname</b>(</code></td>
2eeb74d1cf5355dd98f6d507a10086e16bb08c4bTinderbox User<td>const char *<var class="pdparam">name</var><code>)</code>;</td>
fd2597f75693a2279fdf588bd40dfe2407c42028Tinderbox User<table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;">
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austeinstruct hostent *
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein<b class="fsfunc">lwres_gethostbyname2</b>(</code></td>
2eeb74d1cf5355dd98f6d507a10086e16bb08c4bTinderbox User<td>const char *<var class="pdparam">name</var>, </td>
2eeb74d1cf5355dd98f6d507a10086e16bb08c4bTinderbox User<td>int <var class="pdparam">af</var><code>)</code>;</td>
fd2597f75693a2279fdf588bd40dfe2407c42028Tinderbox User<table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;">
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austeinstruct hostent *
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein<b class="fsfunc">lwres_gethostbyaddr</b>(</code></td>
2eeb74d1cf5355dd98f6d507a10086e16bb08c4bTinderbox User<td>const char *<var class="pdparam">addr</var>, </td>
2eeb74d1cf5355dd98f6d507a10086e16bb08c4bTinderbox User<td>int <var class="pdparam">type</var><code>)</code>;</td>
fd2597f75693a2279fdf588bd40dfe2407c42028Tinderbox User<table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austeinstruct hostent *
e21a2904f02a03fa06b6db04d348f65fe9c67b2bMark Andrews<b class="fsfunc">lwres_gethostent</b>(</code></td>
fd2597f75693a2279fdf588bd40dfe2407c42028Tinderbox User<table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr>
e21a2904f02a03fa06b6db04d348f65fe9c67b2bMark Andrews<b class="fsfunc">lwres_sethostent</b>(</code></td>
2eeb74d1cf5355dd98f6d507a10086e16bb08c4bTinderbox User<td>int <var class="pdparam">stayopen</var><code>)</code>;</td>
fd2597f75693a2279fdf588bd40dfe2407c42028Tinderbox User<table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr>
e21a2904f02a03fa06b6db04d348f65fe9c67b2bMark Andrews<b class="fsfunc">lwres_endhostent</b>(</code></td>
fd2597f75693a2279fdf588bd40dfe2407c42028Tinderbox User<table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;">
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austeinstruct hostent *
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein<b class="fsfunc">lwres_gethostbyname_r</b>(</code></td>
2eeb74d1cf5355dd98f6d507a10086e16bb08c4bTinderbox User<td>const char *<var class="pdparam">name</var>, </td>
2eeb74d1cf5355dd98f6d507a10086e16bb08c4bTinderbox User<td>struct hostent *<var class="pdparam">resbuf</var>, </td>
2eeb74d1cf5355dd98f6d507a10086e16bb08c4bTinderbox User<td>char *<var class="pdparam">buf</var>, </td>
2eeb74d1cf5355dd98f6d507a10086e16bb08c4bTinderbox User<td>int <var class="pdparam">buflen</var>, </td>
2eeb74d1cf5355dd98f6d507a10086e16bb08c4bTinderbox User<td>int *<var class="pdparam">error</var><code>)</code>;</td>
fd2597f75693a2279fdf588bd40dfe2407c42028Tinderbox User<table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;">
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austeinstruct hostent *
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein<b class="fsfunc">lwres_gethostbyaddr_r</b>(</code></td>
2eeb74d1cf5355dd98f6d507a10086e16bb08c4bTinderbox User<td>const char *<var class="pdparam">addr</var>, </td>
2eeb74d1cf5355dd98f6d507a10086e16bb08c4bTinderbox User<td>int <var class="pdparam">type</var>, </td>
2eeb74d1cf5355dd98f6d507a10086e16bb08c4bTinderbox User<td>struct hostent *<var class="pdparam">resbuf</var>, </td>
2eeb74d1cf5355dd98f6d507a10086e16bb08c4bTinderbox User<td>char *<var class="pdparam">buf</var>, </td>
2eeb74d1cf5355dd98f6d507a10086e16bb08c4bTinderbox User<td>int <var class="pdparam">buflen</var>, </td>
2eeb74d1cf5355dd98f6d507a10086e16bb08c4bTinderbox User<td>int *<var class="pdparam">error</var><code>)</code>;</td>
fd2597f75693a2279fdf588bd40dfe2407c42028Tinderbox User<table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;">
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austeinstruct hostent *
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein<b class="fsfunc">lwres_gethostent_r</b>(</code></td>
2eeb74d1cf5355dd98f6d507a10086e16bb08c4bTinderbox User<td>struct hostent *<var class="pdparam">resbuf</var>, </td>
2eeb74d1cf5355dd98f6d507a10086e16bb08c4bTinderbox User<td>char *<var class="pdparam">buf</var>, </td>
2eeb74d1cf5355dd98f6d507a10086e16bb08c4bTinderbox User<td>int <var class="pdparam">buflen</var>, </td>
2eeb74d1cf5355dd98f6d507a10086e16bb08c4bTinderbox User<td>int *<var class="pdparam">error</var><code>)</code>;</td>
fd2597f75693a2279fdf588bd40dfe2407c42028Tinderbox User<table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr>
e21a2904f02a03fa06b6db04d348f65fe9c67b2bMark Andrews<b class="fsfunc">lwres_sethostent_r</b>(</code></td>
2eeb74d1cf5355dd98f6d507a10086e16bb08c4bTinderbox User<td>int <var class="pdparam">stayopen</var><code>)</code>;</td>
fd2597f75693a2279fdf588bd40dfe2407c42028Tinderbox User<table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr>
e21a2904f02a03fa06b6db04d348f65fe9c67b2bMark Andrews<b class="fsfunc">lwres_endhostent_r</b>(</code></td>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein These functions provide hostname-to-address and
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein address-to-hostname lookups by means of the lightweight resolver.
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein They are similar to the standard
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User <span class="refentrytitle">gethostent</span>(3)
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein functions provided by most operating systems.
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein which is usually defined in
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austeinstruct hostent {
8eea877894ea5bcf5cdd9ca124a8601ad421d753Andreas Gustafsson char *h_name; /* official name of host */
8eea877894ea5bcf5cdd9ca124a8601ad421d753Andreas Gustafsson char **h_aliases; /* alias list */
8eea877894ea5bcf5cdd9ca124a8601ad421d753Andreas Gustafsson int h_addrtype; /* host address type */
8eea877894ea5bcf5cdd9ca124a8601ad421d753Andreas Gustafsson int h_length; /* length of address */
8eea877894ea5bcf5cdd9ca124a8601ad421d753Andreas Gustafsson char **h_addr_list; /* list of addresses from name server */
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein#define h_addr h_addr_list[0] /* address, for backward compatibility */
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein The members of this structure are:
fd2597f75693a2279fdf588bd40dfe2407c42028Tinderbox User<div class="variablelist"><dl class="variablelist">
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein<dt><span class="term"><code class="constant">h_name</code></span></dt>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein The official (canonical) name of the host.
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein<dt><span class="term"><code class="constant">h_aliases</code></span></dt>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein A NULL-terminated array of alternate names (nicknames) for the
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein<dt><span class="term"><code class="constant">h_addrtype</code></span></dt>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein The type of address being returned —
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein<dt><span class="term"><code class="constant">h_length</code></span></dt>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein The length of the address in bytes.
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein<dt><span class="term"><code class="constant">h_addr_list</code></span></dt>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein terminated array of network addresses for the host.
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein Host addresses are returned in network byte order.
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein For backward compatibility with very old software,
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein is the first address in
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User <p><code class="function">lwres_gethostent()</code>,
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein <code class="function">lwres_sethostent()</code>,
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein <code class="function">lwres_endhostent()</code>,
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein <code class="function">lwres_gethostent_r()</code>,
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein <code class="function">lwres_sethostent_r()</code>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein <code class="function">lwres_endhostent_r()</code>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein provide iteration over the known host entries on systems that
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein provide such functionality through facilities like
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein or NIS. The lightweight resolver does not currently implement
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein these functions; it only provides them as stub functions that always
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein return failure.
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User <p><code class="function">lwres_gethostbyname()</code>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein and <code class="function">lwres_gethostbyname2()</code> look up the
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein hostname <em class="parameter"><code>name</code></em>.
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein <code class="function">lwres_gethostbyname()</code> always looks for an
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein IPv4 address while <code class="function">lwres_gethostbyname2()</code>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein looks for an address of protocol family
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein <em class="parameter"><code>af</code></em>: either <span class="type">PF_INET</span> or
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein <span class="type">PF_INET6</span> — IPv4 or IPV6 addresses
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein respectively. Successful calls of the functions return a
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein <span class="type">struct hostent</span>for the name that was looked up.
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein <span class="type">NULL</span> is returned if the lookups by
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein <code class="function">lwres_gethostbyname()</code> or
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein <code class="function">lwres_gethostbyname2()</code> fail.
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein Reverse lookups of addresses are performed by
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein <code class="function">lwres_gethostbyaddr()</code>.
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein <em class="parameter"><code>addr</code></em> is an address of length
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein <em class="parameter"><code>len</code></em> bytes and protocol family
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein <em class="parameter"><code>type</code></em> — <span class="type">PF_INET</span> or
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein <code class="function">lwres_gethostbyname_r()</code> is a
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein thread-safe function
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein for forward lookups. If an error occurs, an error code is returned in
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein <em class="parameter"><code>resbuf</code></em> is a pointer to a
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein <span class="type">struct hostent</span> which is initialised by a successful call to
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein <code class="function">lwres_gethostbyname_r()</code>.
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein <em class="parameter"><code>buf</code></em> is a buffer of length
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein <em class="parameter"><code>len</code></em> bytes which is used to store the
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein <code class="constant">h_name</code>, <code class="constant">h_aliases</code>, and
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein <code class="constant">h_addr_list</code> elements of the
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein <span class="type">struct hostent</span> returned in <em class="parameter"><code>resbuf</code></em>.
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein Successful calls to <code class="function">lwres_gethostbyname_r()</code>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein return <em class="parameter"><code>resbuf</code></em>,
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein which is a pointer to the <span class="type">struct hostent</span> it created.
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User <p><code class="function">lwres_gethostbyaddr_r()</code>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein is a thread-safe function
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein that performs a reverse lookup of address <em class="parameter"><code>addr</code></em>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein which is <em class="parameter"><code>len</code></em> bytes long and is of
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein family <em class="parameter"><code>type</code></em> — <span class="type">PF_INET</span> or
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein <span class="type">PF_INET6</span>. If an error occurs, the error code is returned
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein in <em class="parameter"><code>*error</code></em>. The other function
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein parameters are
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein identical to those in <code class="function">lwres_gethostbyname_r()</code>.
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein <em class="parameter"><code>resbuf</code></em> is a pointer to a
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein <span class="type">struct hostent</span> which is initialised by a successful call to
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein <code class="function">lwres_gethostbyaddr_r()</code>.
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein <em class="parameter"><code>buf</code></em> is a buffer of length
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein <em class="parameter"><code>len</code></em> bytes which is used to store the
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein <code class="constant">h_name</code>, <code class="constant">h_aliases</code>, and
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein <code class="constant">h_addr_list</code> elements of the
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein <span class="type">struct hostent</span> returned in <em class="parameter"><code>resbuf</code></em>.
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein Successful calls to <code class="function">lwres_gethostbyaddr_r()</code> return
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein <em class="parameter"><code>resbuf</code></em>, which is a pointer to the
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein <code class="function">struct hostent()</code> it created.
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein The functions
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein <code class="function">lwres_gethostbyname()</code>,
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein <code class="function">lwres_gethostbyname2()</code>,
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein <code class="function">lwres_gethostbyaddr()</code>,
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein <code class="function">lwres_gethostent()</code>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein return NULL to indicate an error. In this case the global variable
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein will contain one of the following error codes defined in
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein <code class="filename"><lwres/netdb.h></code>:
fd2597f75693a2279fdf588bd40dfe2407c42028Tinderbox User<div class="variablelist"><dl class="variablelist">
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein<dt><span class="term"><code class="constant">HOST_NOT_FOUND</code></span></dt>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein The host or address was not found.
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein<dt><span class="term"><code class="constant">TRY_AGAIN</code></span></dt>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein A recoverable error occurred, e.g., a timeout.
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein Retrying the lookup may succeed.
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein<dt><span class="term"><code class="constant">NO_RECOVERY</code></span></dt>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein A non-recoverable error occurred.
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein<dt><span class="term"><code class="constant">NO_DATA</code></span></dt>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein The name exists, but has no address information
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein associated with it (or vice versa in the case
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein of a reverse lookup). The code NO_ADDRESS
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein is accepted as a synonym for NO_DATA for backwards
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein compatibility.
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User <span class="refentrytitle">lwres_hstrerror</span>(3)
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein translates these error codes to suitable error messages.
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User <p><code class="function">lwres_gethostent()</code>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein and <code class="function">lwres_gethostent_r()</code>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein Successful calls to <code class="function">lwres_gethostbyname_r()</code> and
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein <code class="function">lwres_gethostbyaddr_r()</code> return
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein <em class="parameter"><code>resbuf</code></em>, a pointer to the
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein <span class="type">struct hostent</span> that was initialised by these functions. They return
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein <span class="type">NULL</span> if the lookups fail or if <em class="parameter"><code>buf</code></em>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein was too small to hold the list of addresses and names referenced by
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein the <code class="constant">h_name</code>, <code class="constant">h_aliases</code>, and
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein <code class="constant">h_addr_list</code> elements of the
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein If <em class="parameter"><code>buf</code></em> was too small, both
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein <code class="function">lwres_gethostbyname_r()</code> and
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein <code class="function">lwres_gethostbyaddr_r()</code> set the global
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein <span class="type">errno</span> to <span class="errorcode">ERANGE</span>.
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User <span class="refentrytitle">gethostent</span>(3)
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User <span class="refentrytitle">lwres_getipnode</span>(3)
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User <span class="refentrytitle">lwres_hstrerror</span>(3)
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User <p><code class="function">lwres_gethostbyname()</code>,
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein <code class="function">lwres_gethostbyname2()</code>,
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein <code class="function">lwres_gethostbyaddr()</code>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein <code class="function">lwres_endhostent()</code>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein are not thread safe; they return pointers to static data and
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein provide error codes through a global variable.
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein Thread-safe versions for name and address lookup are provided by
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein <code class="function">lwres_gethostbyname_r()</code>,
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein <code class="function">lwres_gethostbyaddr_r()</code>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein respectively.
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein The resolver daemon does not currently support any non-DNS
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein name services such as
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein consequently the above functions don't, either.