363N/A - Copyright (C) 2000, 2001 Internet Software Consortium. 363N/A - Permission to use, copy, modify, and distribute this software for any 363N/A - purpose with or without fee is hereby granted, provided that the above 363N/A - copyright notice and this permission notice appear in all copies. 363N/A - THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM 363N/A - DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL 363N/A - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL 363N/A - INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, 363N/A - INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING 363N/A - FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 363N/A - NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION 363N/A - WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 363N/A>lwres_gethostent</
TITLE 363N/ACONTENT="Modular DocBook HTML Stylesheet Version 1.61 365N/A>lwres_gethostbyname, lwres_gethostbyname2, lwres_gethostbyaddr, lwres_gethostent, lwres_sethostent, lwres_endhostent, lwres_gethostbyname_r, lwres_gethostbyaddr_r, lwres_gethostent_r, lwres_sethostent_r, lwres_endhostent_r -- lightweight resolver get network host entry</
DIV 363N/ACLASS="FUNCSYNOPSISINFO" 363N/Alwres_gethostbyname2</
CODE 363N/A>(const char *name, int af);</
CODE 363N/Alwres_gethostbyaddr</
CODE 2221N/A>(const char *addr, int len, int type);</
CODE 363N/Alwres_gethostbyname_r</
CODE 363N/A>(const char *name, struct hostent *resbuf, char *buf, int buflen, int *error);</
CODE 363N/Alwres_gethostbyaddr_r</
CODE 363N/A>(const char *addr, int len, int type, struct hostent *resbuf, char *buf, int buflen, int *error);</
CODE 363N/Alwres_gethostent_r</
CODE 363N/A>(struct hostent *resbuf, char *buf, int buflen, int *error);</
CODE >These functions provide hostname-to-address and
address-to-hostname lookups by means of the lightweight resolver.
They are similar to the standard
functions provided by most operating systems.
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 */</
PRE>The members of this structure are:
>The official (canonical) name of the host.</
P>A NULL-terminated array of alternate names (nicknames) for the host.</
P>The type of address being returned —
>The length of the address in bytes.</
Pterminated array of network addresses for the host.
Host addresses are returned in network byte order.</
P>For backward compatibility with very old software,
>lwres_gethostent_r()</
TT>lwres_sethostent_r()</
TT>lwres_endhostent_r()</
TTprovide 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
>lwres_gethostbyname()</
TT>lwres_gethostbyname2()</
TT>lwres_gethostbyname()</
TTalways looks for an IPv4 address while
>lwres_gethostbyname2()</
TTlooks for an address of protocol family
— IPv4 or IPV6 addresses respectively.
Successful calls of the functions return a
the name that was looked up.
is returned if the lookups by
>lwres_gethostbyname()</
TT>lwres_gethostbyname2()</
TT>Reverse lookups of addresses are performed by
>lwres_gethostbyaddr()</
TTbytes and protocol family
>lwres_gethostbyname_r()</
TTis a thread-safe function for forward lookups.
If an error occurs, an error code is returned in
which is initialised by a successful call to
>lwres_gethostbyname_r()</
TTbytes which is used to store the
>lwres_gethostbyname_r()</
TTwhich is a pointer to the
>lwres_gethostbyaddr_r()</
TTis a thread-safe function that performs a reverse lookup of address
and is of protocol family
If an error occurs, the error code is returned in
The other function parameters are identical to those in
>lwres_gethostbyname_r()</
TTwhich is initialised by a successful call to
>lwres_gethostbyaddr_r()</
TTbytes which is used to store the
>lwres_gethostbyaddr_r()</
TTwhich is a pointer to the
>lwres_gethostbyname()</
TT>lwres_gethostbyname2()</
TT>lwres_gethostbyaddr()</
TTreturn NULL to indicate an error. In this case the global variable
will contain one of the following error codes defined in
>The host or address was not found.</
P>A recoverable error occurred,
e.g., a timeout.
Retrying the lookup may succeed.</
P>A non-recoverable error occurred.</
P>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
translates these error codes to suitable error messages.</
P>lwres_gethostent_r()</
TT>lwres_gethostbyname_r()</
TT>lwres_gethostbyaddr_r()</
TTthat was initialised by these functions.
was too small to hold the list of addresses and names referenced by
>lwres_gethostbyname_r()</
TT>lwres_gethostbyaddr_r()</
TT>lwres_gethostbyname()</
TT>lwres_gethostbyname2()</
TT>lwres_gethostbyaddr()</
TTare 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
>lwres_gethostbyname_r()</
TT>lwres_gethostbyaddr_r()</
TT>The resolver daemon does not currently support any non-DNS
consequently the above functions don't, either.</
P