lwres_gethostent.docbook revision 1753d3c4d74241a847794f7e7cfd94cc79be6600
f743002678eb67b99bbc29fee116b65d9530fec0wrowe<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
80833bb9a1bf25dcf19e814438a4b311d2e1f4cffuankg "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd"
a34684a59b60a4173c25035d0c627ef17e6dc215rpluem [<!ENTITY mdash "—">]>
1337c7673efc1f80f634139fbad7cbb98a0dc657ylavic - Copyright (C) 2004, 2005, 2007 Internet Systems Consortium, Inc. ("ISC")
1337c7673efc1f80f634139fbad7cbb98a0dc657ylavic - Copyright (C) 2001 Internet Software Consortium.
4da61833a1cbbca94094f9653fd970582b97a72etrawick - Permission to use, copy, modify, and/or distribute this software for any
4da61833a1cbbca94094f9653fd970582b97a72etrawick - purpose with or without fee is hereby granted, provided that the above
4da61833a1cbbca94094f9653fd970582b97a72etrawick - copyright notice and this permission notice appear in all copies.
4da61833a1cbbca94094f9653fd970582b97a72etrawick - THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
4789804be088bcd86ae637a29cdb7fda25169521jailletc - REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
4789804be088bcd86ae637a29cdb7fda25169521jailletc - AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
4789804be088bcd86ae637a29cdb7fda25169521jailletc - INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
4789804be088bcd86ae637a29cdb7fda25169521jailletc - LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
e50c3026198fd496f183cda4c32a202925476778covener - OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
e50c3026198fd496f183cda4c32a202925476778covener - PERFORMANCE OF THIS SOFTWARE.
6c3b9cebb551140fbb25d58bae08b539b3802133ylavic <refentryinfo>
4f29b65ab4b547ad5dbe506e2d0ff5d12ead9247ylavic </refentryinfo>
506bfe33206b2fece40ef25f695af39dd4130facjkaluza <copyright>
d58a848a016d401b965111e50ef829e1641f7834minfrin <holder>Internet Systems Consortium, Inc. ("ISC")</holder>
d58a848a016d401b965111e50ef829e1641f7834minfrin </copyright>
d58a848a016d401b965111e50ef829e1641f7834minfrin <copyright>
2e6f4d654c96c98b761fb012fd25c5d5b1558c44sf </copyright>
17e6c95f3b22d18acdf8380fb26a8d0e10c80767ylavic <refnamediv>
330e16bea8fe9cace4de90c349750c03dfb1fe64ylavic <refpurpose>lightweight resolver get network host entry</refpurpose>
d7205b1a86c51c27b71a2c458dc453fd53a261c1covener </refnamediv>
d7205b1a86c51c27b71a2c458dc453fd53a261c1covener <refsynopsisdiv>
d7205b1a86c51c27b71a2c458dc453fd53a261c1covener <funcsynopsis>
d7205b1a86c51c27b71a2c458dc453fd53a261c1covener<funcsynopsisinfo>#include <lwres/netdb.h></funcsynopsisinfo>
d7205b1a86c51c27b71a2c458dc453fd53a261c1covener<funcprototype>
44ff304057225e944e220e981d434a046d14cf06covenerstruct hostent *
44ff304057225e944e220e981d434a046d14cf06covener <paramdef>const char *<parameter>name</parameter></paramdef>
5d1ba75b8794925e67591c209085a49279791de9covener </funcprototype>
5d1ba75b8794925e67591c209085a49279791de9covener<funcprototype>
032982212dbcc7c3cce95bf89c503bb56e185ac7kbrandstruct hostent *
032982212dbcc7c3cce95bf89c503bb56e185ac7kbrand <paramdef>const char *<parameter>name</parameter></paramdef>
caad2986f81ab263f7af41467dd622dc9add17f3ylavic </funcprototype>
caad2986f81ab263f7af41467dd622dc9add17f3ylavic<funcprototype>
caad2986f81ab263f7af41467dd622dc9add17f3ylavicstruct hostent *
f7317ff316c2b141feea31bddb74d5d3fa1584edjorton <paramdef>const char *<parameter>addr</parameter></paramdef>
2165214331e4afafca4048f66f303d0253d7b001covener <paramdef>int <parameter>type</parameter></paramdef>
a34684a59b60a4173c25035d0c627ef17e6dc215rpluem </funcprototype>
a34684a59b60a4173c25035d0c627ef17e6dc215rpluem<funcprototype>
1e2d421a36999d292042a5539971070d54aa6c63ylavicstruct hostent *
fa7ed98b9dc94c5845cf845aea0a44ecacd290c9humbedooh </funcprototype>
fa7ed98b9dc94c5845cf845aea0a44ecacd290c9humbedooh<funcprototype>
0b67eb8568cd58bb77082703951679b42cf098actrawick <paramdef>int <parameter>stayopen</parameter></paramdef>
5ef3c61605a3a021ff71f488983cb0065f8e1a79covener </funcprototype>
fb1985a97912b25ec6564c73e610a31e5fc6e25fcovener<funcprototype>
c1a63b8fad09c419c1a64f75993feb8a343a6801ylavic </funcprototype>
c1a63b8fad09c419c1a64f75993feb8a343a6801ylavic<funcprototype>
e6b4bd1113567627ab6bb6c6a7105e1e01a7d889jailletcstruct hostent *
e6b4bd1113567627ab6bb6c6a7105e1e01a7d889jailletc<function>lwres_gethostbyname_r</function></funcdef>
e466c40e1801982602ee0200c9e8b61cc148742djailletc <paramdef>const char *<parameter>name</parameter></paramdef>
e466c40e1801982602ee0200c9e8b61cc148742djailletc <paramdef>struct hostent *<parameter>resbuf</parameter></paramdef>
04983e3bd1754764eec7d6bb772fe3b0bf391771jorton </funcprototype>
04983e3bd1754764eec7d6bb772fe3b0bf391771jorton<funcprototype>
15660979a30d251681463de2e0584853890082accovenerstruct hostent *
49dacedb6c387b786b7911082ff35121a45f414bcovener <paramdef>const char *<parameter>addr</parameter></paramdef>
cfd9415521847b2f9394fad04fb701cfb955f503rjung <paramdef>struct hostent *<parameter>resbuf</parameter></paramdef>
28c31fb73c1264bd1d0ff932573677030b024c7dwrowe <paramdef>int <parameter>buflen</parameter></paramdef>
28c31fb73c1264bd1d0ff932573677030b024c7dwrowe <paramdef>int *<parameter>error</parameter></paramdef>
28c31fb73c1264bd1d0ff932573677030b024c7dwrowe </funcprototype>
28c31fb73c1264bd1d0ff932573677030b024c7dwrowe<funcprototype>
8491e0600f69b0405e156ea8a419653c065c645bcovenerstruct hostent *
63b9f1f5880391261705f696d7d65507bbe9ace3covener <paramdef>struct hostent *<parameter>resbuf</parameter></paramdef>
63b9f1f5880391261705f696d7d65507bbe9ace3covener <paramdef>char *<parameter>buf</parameter></paramdef>
49dacedb6c387b786b7911082ff35121a45f414bcovener <paramdef>int <parameter>buflen</parameter></paramdef>
49dacedb6c387b786b7911082ff35121a45f414bcovener <paramdef>int *<parameter>error</parameter></paramdef>
49dacedb6c387b786b7911082ff35121a45f414bcovener </funcprototype>
49dacedb6c387b786b7911082ff35121a45f414bcovener<funcprototype>
3c990331fc6702119e4f5b8ba9eae3021aea5265jim <paramdef>int <parameter>stayopen</parameter></paramdef>
fc42512879dd0504532f52fe5d0d0383dda96a1eniq </funcprototype>
fc42512879dd0504532f52fe5d0d0383dda96a1eniq<funcprototype>
da0442c0440caef34706e2c2f3af05cb65921cc0jailletc </funcprototype>
983528026996668ea295be95aedb9c7a346af470ylavic</funcsynopsis>
da0442c0440caef34706e2c2f3af05cb65921cc0jailletc </refsynopsisdiv>
15890c9306ba98f6fc243e15a3c4778ddc7d773erpluem These functions provide hostname-to-address and
259878293a997ff49f5ddfc53d3739cbdc25444ecovener address-to-hostname lookups by means of the lightweight resolver.
259878293a997ff49f5ddfc53d3739cbdc25444ecovener They are similar to the standard
259878293a997ff49f5ddfc53d3739cbdc25444ecovener <citerefentry>
259878293a997ff49f5ddfc53d3739cbdc25444ecovener <refentrytitle>gethostent</refentrytitle><manvolnum>3</manvolnum>
15890c9306ba98f6fc243e15a3c4778ddc7d773erpluem </citerefentry>
b54b024c06a19926832d77d40ba35ad8c41e4d3dminfrin functions provided by most operating systems.
65967d05f839dbf27cf91d91fa79585eeae19660minfrin which is usually defined in
8152945ae46857b170cb227e79bb799f4fc7710dminfrinstruct hostent {
8152945ae46857b170cb227e79bb799f4fc7710dminfrin char *h_name; /* official name of host */
8152945ae46857b170cb227e79bb799f4fc7710dminfrin char **h_aliases; /* alias list */
8152945ae46857b170cb227e79bb799f4fc7710dminfrin int h_addrtype; /* host address type */
75f5c2db254c0167a0e396254460de09b775d203trawick int h_length; /* length of address */
75f5c2db254c0167a0e396254460de09b775d203trawick char **h_addr_list; /* list of addresses from name server */
4f0358189bfa57b8e75bd6b94db264302a8f336amrumph#define h_addr h_addr_list[0] /* address, for backward compatibility */
4f0358189bfa57b8e75bd6b94db264302a8f336amrumph</programlisting>
5716f9c6daa92dde5f2f9d11ed63f7c9549c223atrawick The members of this structure are:
5716f9c6daa92dde5f2f9d11ed63f7c9549c223atrawick <variablelist>
5716f9c6daa92dde5f2f9d11ed63f7c9549c223atrawick <varlistentry>
54d750a84a175d8e338880514d440773eb986b50covener The official (canonical) name of the host.
54d750a84a175d8e338880514d440773eb986b50covener </listitem>
54d750a84a175d8e338880514d440773eb986b50covener </varlistentry>
54d750a84a175d8e338880514d440773eb986b50covener <varlistentry>
83b50288fa7d306324bba68832011ea08f5c7832covener A NULL-terminated array of alternate names (nicknames) for the
5f066f496cd9f20a2a701255bc67d44e7cb46daetrawick </listitem>
5f066f496cd9f20a2a701255bc67d44e7cb46daetrawick </varlistentry>
5f066f496cd9f20a2a701255bc67d44e7cb46daetrawick <varlistentry>
2e15620d724fb8e3a5be183b917359a2fd6e9468covener The type of address being returned —
b8efdc95bec9cf089aa1be0bfd07d46aa1137a7acovener </listitem>
b8efdc95bec9cf089aa1be0bfd07d46aa1137a7acovener </varlistentry>
b8efdc95bec9cf089aa1be0bfd07d46aa1137a7acovener <varlistentry>
179565be4043d7e5f9161aa75271fa0a001866d9covener The length of the address in bytes.
179565be4043d7e5f9161aa75271fa0a001866d9covener </listitem>
111436a32ba1254291e4883292fb116d15fe8f64covener </varlistentry>
fce4949fb0b309a5744afcd503c6ed2d35621ee2covener <varlistentry>
7b7430e701e9a31ce809da7c220bb8dfcf68c86etrawick terminated array of network addresses for the host.
7b7430e701e9a31ce809da7c220bb8dfcf68c86etrawick Host addresses are returned in network byte order.
ccc20788c1e5fc973f36df634399c89acb70deaejerenkrantz </varlistentry>
273e512f20f262e5e2aa8e0e83371d1929fb76adjkaluza </variablelist>
efe780dcf13b2b95effabf897d694d8f23feac74trawick For backward compatibility with very old software,
fe83f60b41477b14a37edcfcd1f7f5c5a1ebfe44minfrin is the first address in
135ddda3a989215d2bedbcf1529bfb269c3eda23niq provide iteration over the known host entries on systems that
135ddda3a989215d2bedbcf1529bfb269c3eda23niq provide such functionality through facilities like
001a44c352f89c9ec332ffd3e0a6927dcd19432chumbedooh or NIS. The lightweight resolver does not currently implement
001a44c352f89c9ec332ffd3e0a6927dcd19432chumbedooh these functions; it only provides them as stub functions that always
efe780dcf13b2b95effabf897d694d8f23feac74trawick return failure.
9b0076ddd1103e5fa9c1f9bafde4b06ce244fbaecovener and <function>lwres_gethostbyname2()</function> look up the
249d09d51808cb7981af99762c3b3736ca126cd5jkaluza <function>lwres_gethostbyname()</function> always looks for an
249d09d51808cb7981af99762c3b3736ca126cd5jkaluza IPv4 address while <function>lwres_gethostbyname2()</function>
249d09d51808cb7981af99762c3b3736ca126cd5jkaluza looks for an address of protocol family
249d09d51808cb7981af99762c3b3736ca126cd5jkaluza <parameter>af</parameter>: either <type>PF_INET</type> or
56589be3d7a3e9343370df240010c6928cc78b39jkaluza <type>PF_INET6</type> — IPv4 or IPV6 addresses
56589be3d7a3e9343370df240010c6928cc78b39jkaluza respectively. Successful calls of the functions return a
56589be3d7a3e9343370df240010c6928cc78b39jkaluza <type>struct hostent</type>for the name that was looked up.
f87299dab99bc04b51a6b8cad51b6795db862c0atrawick Reverse lookups of addresses are performed by
85eacfc96a04547ef25aabbc06440039715084c2jorton <parameter>type</parameter> — <type>PF_INET</type> or
a4df2cd1e1391575a327c2a90ba4315f805a0a78covener thread-safe function
a4df2cd1e1391575a327c2a90ba4315f805a0a78covener for forward lookups. If an error occurs, an error code is returned in
cb666b29f81df1d11d65002250153353568021fccovener <type>struct hostent</type> which is initialised by a successful call to
1c2cab00d988fc48cbe59032cf76cc0bab20d6f7covener <parameter>len</parameter> bytes which is used to store the
6a80c3c6f4b8ea7ba5e89402b8b779b09ce020e0covener <constant>h_name</constant>, <constant>h_aliases</constant>, and
75a230a728338d84dcfe81edd375352f34de22d0covener <type>struct hostent</type> returned in <parameter>resbuf</parameter>.
75a230a728338d84dcfe81edd375352f34de22d0covener Successful calls to <function>lwres_gethostbyname_r()</function>
1f50dc34ae069adeed20b2986e5ffdefa5c410e0covener which is a pointer to the <type>struct hostent</type> it created.
63a5ea80bddcc84a462e40f402b4f330e0e05411covener is a thread-safe function
63a5ea80bddcc84a462e40f402b4f330e0e05411covener that performs a reverse lookup of address <parameter>addr</parameter>
65a4e663b82f8bce28ac22ab2edfd7502de36998sf family <parameter>type</parameter> — <type>PF_INET</type> or
65a4e663b82f8bce28ac22ab2edfd7502de36998sf <type>PF_INET6</type>. If an error occurs, the error code is returned
74e7f6c55fd67b10cb400b3f6d1dc718a303d944minfrin parameters are
74e7f6c55fd67b10cb400b3f6d1dc718a303d944minfrin identical to those in <function>lwres_gethostbyname_r()</function>.
74e7f6c55fd67b10cb400b3f6d1dc718a303d944minfrin <type>struct hostent</type> which is initialised by a successful call to
a511a29faf2ff7ead3b67680154a624effb31aafminfrin <parameter>len</parameter> bytes which is used to store the
a511a29faf2ff7ead3b67680154a624effb31aafminfrin <constant>h_name</constant>, <constant>h_aliases</constant>, and
63921358ef93fcb41bc71d9894221ba3d7fbb87bminfrin <type>struct hostent</type> returned in <parameter>resbuf</parameter>.
63921358ef93fcb41bc71d9894221ba3d7fbb87bminfrin Successful calls to <function>lwres_gethostbyaddr_r()</function> return
63921358ef93fcb41bc71d9894221ba3d7fbb87bminfrin <parameter>resbuf</parameter>, which is a pointer to the
6d601599d3d65df0410eae6e573e75b2dbfb1fb4minfrin </refsect1>
05a5a9c3e16f21566e1b61f4bd68025ce1b741ccjoes The functions
ef82e8fa164e0a1f8b813f7deb6b7ead96018c94niq return NULL to indicate an error. In this case the global variable
ef82e8fa164e0a1f8b813f7deb6b7ead96018c94niq will contain one of the following error codes defined in
c12917da693bae4028a1d5a5e8224bceed8c739dsf <variablelist>
c12917da693bae4028a1d5a5e8224bceed8c739dsf <varlistentry>
eafcc0ebf263d0ba69855b6e10958c4c1a2361bdsf <listitem>
eafcc0ebf263d0ba69855b6e10958c4c1a2361bdsf The host or address was not found.
d7ffd2da16d58b1a0de212e4d56f7aebb72bef26sf </listitem>
d7ffd2da16d58b1a0de212e4d56f7aebb72bef26sf </varlistentry>
d7ffd2da16d58b1a0de212e4d56f7aebb72bef26sf <varlistentry>
4576c1a9ef54cd1e5555ee07d016a7f559f80338sf <listitem>
9811aed12bbc71783d2e544ccb5fecd193843eadsf A recoverable error occurred, e.g., a timeout.
9811aed12bbc71783d2e544ccb5fecd193843eadsf Retrying the lookup may succeed.
88fac54d9d64f85bbdab5d7010816f4377f95bd7rjung </listitem>
88fac54d9d64f85bbdab5d7010816f4377f95bd7rjung </varlistentry>
bd3f5647b96d378d9c75c954e3f13582af32c643sf <varlistentry>
bd3f5647b96d378d9c75c954e3f13582af32c643sf <listitem>
bd3f5647b96d378d9c75c954e3f13582af32c643sf A non-recoverable error occurred.
2a7beea91d46beb41f043a84eaad060047ee04aafabien </listitem>
2a7beea91d46beb41f043a84eaad060047ee04aafabien </varlistentry>
2a7beea91d46beb41f043a84eaad060047ee04aafabien <varlistentry>
584a85dd4047e38d3ed3a29b6662fcc9d100ae4csf <listitem>
f21e9e3d0bfb7a507ecc5bc963f2159d693503d1sf The name exists, but has no address information
f21e9e3d0bfb7a507ecc5bc963f2159d693503d1sf associated with it (or vice versa in the case
f21e9e3d0bfb7a507ecc5bc963f2159d693503d1sf of a reverse lookup). The code NO_ADDRESS
f6b9c755a0b793e8a3a3aebd327ca20a86478117sf is accepted as a synonym for NO_DATA for backwards
f6b9c755a0b793e8a3a3aebd327ca20a86478117sf compatibility.
132ee6ac1c26d6e8953836316ba50734eefab47bsf </listitem>
132ee6ac1c26d6e8953836316ba50734eefab47bsf </varlistentry>
132ee6ac1c26d6e8953836316ba50734eefab47bsf </variablelist>
536d2e7cd1fdec1255b8c3bdf41fdc714c506a54trawick <refentrytitle>lwres_hstrerror</refentrytitle><manvolnum>3</manvolnum>
536d2e7cd1fdec1255b8c3bdf41fdc714c506a54trawick </citerefentry>
536d2e7cd1fdec1255b8c3bdf41fdc714c506a54trawick translates these error codes to suitable error messages.
79c5787b92ac5f0e1cc82393816c77a006399316trawick Successful calls to <function>lwres_gethostbyname_r()</function> and
7b395e4e878c28a4784919cfd2e704ddd14a3390jorton <type>struct hostent</type> that was initialised by these functions. They return
7b395e4e878c28a4784919cfd2e704ddd14a3390jorton <type>NULL</type> if the lookups fail or if <parameter>buf</parameter>
7b395e4e878c28a4784919cfd2e704ddd14a3390jorton was too small to hold the list of addresses and names referenced by
7b395e4e878c28a4784919cfd2e704ddd14a3390jorton the <constant>h_name</constant>, <constant>h_aliases</constant>, and
3e4e54d4e3fc0123c63d57aa84ac7ad7a8c73ff8jorton <function>lwres_gethostbyaddr_r()</function> set the global
53e9b27aba029b18be814df40bcf6f0428771d1efuankg </refsect1>
6bb524f1895f30265a1431afc460977d391cb36bsf <refentrytitle>gethostent</refentrytitle><manvolnum>3</manvolnum>
ca61ccd0c306c2c72df153688ba1b49f3eceed80sf </citerefentry>,
e6dd71992459d05a676b98b7963423dc5dc1e24aminfrin <citerefentry>
e6dd71992459d05a676b98b7963423dc5dc1e24aminfrin <refentrytitle>lwres_getipnode</refentrytitle><manvolnum>3</manvolnum>
e6dd71992459d05a676b98b7963423dc5dc1e24aminfrin </citerefentry>,
23f1535d6a60817d2846bac0aea230ea475d7dccminfrin <citerefentry>
23f1535d6a60817d2846bac0aea230ea475d7dccminfrin <refentrytitle>lwres_hstrerror</refentrytitle><manvolnum>3</manvolnum>
23f1535d6a60817d2846bac0aea230ea475d7dccminfrin </citerefentry>
ec7520b24cd80d34d82bbcaca153cbb23cc04bc0rjung </refsect1>
6249dfa569d3b4f1f539665b979a80c6e335d93etrawick are not thread safe; they return pointers to static data and
0827cb14e550f6f65018431c22c2c913631c8f25kbrand provide error codes through a global variable.
6249dfa569d3b4f1f539665b979a80c6e335d93etrawick Thread-safe versions for name and address lookup are provided by
74499a117b3b2cd9666715a14f90c0e5d1a4ee8ajim respectively.
cfa64348224b66dd1c9979b809406c4d15b1c137fielding The resolver daemon does not currently support any non-DNS
74499a117b3b2cd9666715a14f90c0e5d1a4ee8ajim name services such as