3211N/A<!
DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook V4.1//EN">
3211N/A - Copyright (C) 2001 Internet Software Consortium. 3211N/A - Permission to use, copy, modify, and distribute this software for any 3211N/A - purpose with or without fee is hereby granted, provided that the above 3211N/A - copyright notice and this permission notice appear in all copies. 3211N/A - THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM 3211N/A - DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL 3211N/A - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL 3211N/A - INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, 3211N/A - INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING 3211N/A - FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 3211N/A - NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION 3211N/A - WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 3211N/A<
refentrytitle>lwres_gethostent</
refentrytitle>
3211N/A<
refmiscinfo>BIND9</
refmiscinfo>
3211N/A<
refname>lwres_gethostbyname</
refname>
3211N/A<
refname>lwres_gethostbyname2</
refname>
3211N/A<
refname>lwres_gethostbyaddr</
refname>
3211N/A<
refname>lwres_gethostent</
refname>
3211N/A<
refname>lwres_sethostent</
refname>
3211N/A<
refname>lwres_endhostent</
refname>
3211N/A<
refname>lwres_gethostbyname_r</
refname>
3211N/A<
refname>lwres_gethostbyaddr_r</
refname>
3211N/A<
refname>lwres_gethostent_r</
refname>
3211N/A<
refname>lwres_sethostent_r</
refname>
3211N/A<
refname>lwres_endhostent_r</
refname>
3211N/A<
refpurpose>lightweight resolver get network host entry</
refpurpose>
3211N/A<
function>lwres_gethostbyname</
function></
funcdef>
3211N/A<
paramdef>const char *name</
paramdef>
3211N/A<
function>lwres_gethostbyname2</
function></
funcdef>
3211N/A<
paramdef>const char *name</
paramdef>
3211N/A<
function>lwres_gethostbyaddr</
function></
funcdef>
3211N/A<
paramdef>const char *addr</
paramdef>
3211N/A<
paramdef>int len</
paramdef>
3211N/A<
paramdef>int type</
paramdef>
3211N/A<
function>lwres_gethostent</
function></
funcdef>
3211N/A<
function>lwres_sethostent</
function></
funcdef>
3211N/A<
paramdef>int stayopen</
paramdef>
3211N/A<
function>lwres_endhostent</
function></
funcdef>
3211N/A<
function>lwres_gethostbyname_r</
function></
funcdef>
3211N/A<
paramdef>const char *name</
paramdef>
3211N/A<
paramdef>struct hostent *resbuf</
paramdef>
3211N/A<
paramdef>char *buf</
paramdef>
3211N/A<
paramdef>int buflen</
paramdef>
3211N/A<
paramdef>int *error</
paramdef>
3211N/A<
function>lwres_gethostbyaddr_r</
function></
funcdef>
3211N/A<
paramdef>const char *addr</
paramdef>
3211N/A<
paramdef>int len</
paramdef>
3211N/A<
paramdef>int type</
paramdef>
3211N/A<
paramdef>struct hostent *resbuf</
paramdef>
3211N/A<
paramdef>char *buf</
paramdef>
3211N/A<
paramdef>int buflen</
paramdef>
3211N/A<
paramdef>int *error</
paramdef>
3211N/A<
function>lwres_gethostent_r</
function></
funcdef>
3211N/A<
paramdef>struct hostent *resbuf</
paramdef>
3211N/A<
paramdef>char *buf</
paramdef>
3211N/A<
paramdef>int buflen</
paramdef>
3211N/A<
paramdef>int *error</
paramdef>
3211N/A<
function>lwres_sethostent_r</
function></
funcdef>
3211N/A<
paramdef>int stayopen</
paramdef>
3211N/A<
function>lwres_endhostent_r</
function></
funcdef>
3211N/AThese functions provide hostname-to-address and
3211N/Aaddress-to-hostname lookups by means of the lightweight resolver.
They are similar to the standard
<
refentrytitle>gethostent</
refentrytitle><
manvolnum>3
functions provided by most operating systems.
<
type>struct hostent</
type>
which is usually defined in
char *h_name; /* official name of host */
char **h_aliases; /* alias list */
int h_addrtype; /* host address type */
int h_length; /* length of address */
char **h_addr_list; /* list of addresses from name server */
#define h_addr h_addr_list[0] /* address, for backward compatibility */
The members of this structure are:
<
varlistentry><
term><
constant>h_name</
constant></
term>
The official (canonical) name of the host.
<
varlistentry><
term><
constant>h_aliases</
constant></
term>
A NULL-terminated array of alternate names (nicknames) for the host.
<
varlistentry><
term><
constant>h_addrtype</
constant></
term>
The type of address being returned —
<
varlistentry><
term><
constant>h_length</
constant></
term>
The length of the address in bytes.
<
varlistentry><
term><
constant>h_addr_list</
constant></
term>
terminated array of network addresses for the host.
Host addresses are returned in network byte order.
For backward compatibility with very old software,
<
constant>h_addr</
constant>
<
constant>h_addr_list.</
constant>
<
function>lwres_gethostent()</
function>,
<
function>lwres_sethostent()</
function>,
<
function>lwres_endhostent()</
function>,
<
function>lwres_gethostent_r()</
function>,
<
function>lwres_sethostent_r()</
function>
<
function>lwres_endhostent_r()</
function>
provide iteration over the known host entries on systems that
provide such functionality through facilities like
or NIS. The lightweight resolver does not currently implement
these functions; it only provides them as stub functions that always
<
function>lwres_gethostbyname()</
function>
<
function>lwres_gethostbyname2()</
function>
<
parameter>name</
parameter>.
<
function>lwres_gethostbyname()</
function>
always looks for an IPv4 address while
<
function>lwres_gethostbyname2()</
function>
looks for an address of protocol family
<
parameter>af</
parameter>:
— IPv4 or IPV6 addresses respectively.
Successful calls of the functions return a
<
type>struct hostent</
type>for
the name that was looked up.
is returned if the lookups by
<
function>lwres_gethostbyname()</
function>
<
function>lwres_gethostbyname2()</
function>
Reverse lookups of addresses are performed by
<
function>lwres_gethostbyaddr()</
function>.
<
parameter>addr</
parameter>
<
parameter>len</
parameter>
bytes and protocol family
<
parameter>type</
parameter> —
<
function>lwres_gethostbyname_r()</
function>
is a thread-safe function for forward lookups.
If an error occurs, an error code is returned in
<
parameter>*error</
parameter>.
<
parameter>resbuf</
parameter>
<
type>struct hostent</
type>
which is initialised by a successful call to
<
function>lwres_gethostbyname_r()</
function> .
<
parameter>buf</
parameter>
<
parameter>len</
parameter>
bytes which is used to store the
<
constant>h_name</
constant>,
<
constant>h_aliases</
constant>,
<
constant>h_addr_list</
constant>
<
type>struct hostent</
type>
<
parameter>resbuf</
parameter>.
<
function>lwres_gethostbyname_r()</
function>
<
parameter>resbuf</
parameter>,
which is a pointer to the
<
type>struct hostent</
type>
<
function>lwres_gethostbyaddr_r()</
function>
is a thread-safe function that performs a reverse lookup of address
<
parameter>addr</
parameter>
<
parameter>len</
parameter>
and is of protocol family
<
parameter>type</
parameter> —
If an error occurs, the error code is returned in
<
parameter>*error</
parameter>.
The other function parameters are identical to those in
<
function>lwres_gethostbyname_r()</
function>.
<
parameter>resbuf</
parameter>
<
type>struct hostent</
type>
which is initialised by a successful call to
<
function>lwres_gethostbyaddr_r()</
function>.
<
parameter>buf</
parameter>
<
parameter>len</
parameter>
bytes which is used to store the
<
constant>h_name</
constant>,
<
constant>h_aliases</
constant>,
<
constant>h_addr_list</
constant>
<
type>struct hostent</
type>
<
parameter>resbuf</
parameter>.
<
function>lwres_gethostbyaddr_r()</
function>
<
parameter>resbuf</
parameter>,
which is a pointer to the
<
function>struct hostent()</
function>
<
title>RETURN VALUES</
title>
<
function>lwres_gethostbyname()</
function>,
<
function>lwres_gethostbyname2()</
function>,
<
function>lwres_gethostbyaddr()</
function>,
<
function>lwres_gethostent()</
function>
return NULL to indicate an error. In this case the global variable
<
type>lwres_h_errno</
type>
will contain one of the following error codes defined in
<
varlistentry><
term><
constant>HOST_NOT_FOUND</
constant></
term>
The host or address was not found.
<
varlistentry><
term><
constant>TRY_AGAIN</
constant></
term>
A recoverable error occurred,
e.g., a timeout.
Retrying the lookup may succeed.
<
varlistentry><
term><
constant>NO_RECOVERY</
constant></
term>
A non-recoverable error occurred.
<
varlistentry><
term><
constant>NO_DATA</
constant></
term>
The name exists, but has no address information
associated with it (or vice versa in the case
of a reverse lookup). The code NO_ADDRESS
is accepted as a synonym for NO_DATA for backwards
<
refentrytitle>lwres_hstrerror</
refentrytitle><
manvolnum>3
translates these error codes to suitable error messages.
<
function>lwres_gethostent()</
function>
<
function>lwres_gethostent_r()</
function>
<
function>lwres_gethostbyname_r()</
function>
<
function>lwres_gethostbyaddr_r()</
function>
<
parameter>resbuf</
parameter>,
<
type>struct hostent</
type>
that was initialised by these functions.
<
parameter>buf</
parameter>
was too small to hold the list of addresses and names referenced by
<
constant>h_name</
constant>,
<
constant>h_aliases</
constant>,
<
constant>h_addr_list</
constant>
<
type>struct hostent</
type>.
<
parameter>buf</
parameter>
<
function>lwres_gethostbyname_r()</
function>
<
function>lwres_gethostbyaddr_r()</
function>
<
errorcode>ERANGE</
errorcode>.
<
refentrytitle>gethostent</
refentrytitle><
manvolnum>3</
manvolnum>
<
refentrytitle>lwres_getipnode</
refentrytitle><
manvolnum>3</
manvolnum>
<
refentrytitle>lwres_hstrerror</
refentrytitle><
manvolnum>3
<
function>lwres_gethostbyname()</
function>,
<
function>lwres_gethostbyname2()</
function>,
<
function>lwres_gethostbyaddr()</
function>
<
function>lwres_endhostent()</
function>
are not thread safe; they return pointers to static data and
provide error codes through a global variable.
Thread-safe versions for name and address lookup are provided by
<
function>lwres_gethostbyname_r()</
function>,
<
function>lwres_gethostbyaddr_r()</
function>
The resolver daemon does not currently support any non-DNS
consequently the above functions don't, either.