1 .\" Copyright (C) 2004, 2005 Internet Systems Consortium, Inc. ("ISC")
2 .\" Copyright (C) 2001 Internet Software Consortium.
4 .\" Permission to use, copy, modify, and distribute this software for any
5 .\" purpose with or without fee is hereby granted, provided that the above
6 .\" copyright notice and this permission notice appear in all copies.
8 .\" THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
9 .\" REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
10 .\" AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
11 .\" INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
12 .\" LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
13 .\" OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
14 .\" PERFORMANCE OF THIS SOFTWARE.
16 .\" $Id: lwres_gethostent.3,v 1.16.2.1.8.6 2006/06/29 13:02:31 marka Exp $
20 .\" Title: lwres_gethostent
22 .\" Generator: DocBook XSL Stylesheets v1.70.1 <http://docbook.sf.net/>
23 .\" Date: Jun 30, 2000
27 .TH "LWRES_GETHOSTENT" "3" "Jun 30, 2000" "BIND9" "BIND9"
28 .\" disable hyphenation
30 .\" disable justification (adjust text to left margin only)
33 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
36 #include <lwres/netdb.h>
39 .BI "struct hostent * lwres_gethostbyname(const\ char\ *name);"
41 .BI "struct hostent * lwres_gethostbyname2(const\ char\ *name, int\ af);"
43 .BI "struct hostent * lwres_gethostbyaddr(const\ char\ *addr, int\ len, int\ type);"
45 .BI "struct hostent * lwres_gethostent(void);"
47 .BI "void lwres_sethostent(int\ stayopen);"
49 .BI "void lwres_endhostent(void);"
51 .BI "struct hostent * lwres_gethostbyname_r(const\ char\ *name, struct\ hostent\ *resbuf, char\ *buf, int\ buflen, int\ *error);"
53 .BI "struct hostent * lwres_gethostbyaddr_r(const\ char\ *addr, int\ len, int\ type, struct\ hostent\ *resbuf, char\ *buf, int\ buflen, int\ *error);"
55 .BI "struct hostent * lwres_gethostent_r(struct\ hostent\ *resbuf, char\ *buf, int\ buflen, int\ *error);"
57 .BI "void lwres_sethostent_r(int\ stayopen);"
59 .BI "void lwres_endhostent_r(void);"
62 These functions provide hostname\-to\-address and address\-to\-hostname lookups by means of the lightweight resolver. They are similar to the standard
64 functions provided by most operating systems. They use a
66 which is usually defined in
72 char *h_name; /* official name of host */
73 char **h_aliases; /* alias list */
74 int h_addrtype; /* host address type */
75 int h_length; /* length of address */
76 char **h_addr_list; /* list of addresses from name server */
78 #define h_addr h_addr_list[0] /* address, for backward compatibility */
83 The members of this structure are:
86 The official (canonical) name of the host.
89 A NULL\-terminated array of alternate names (nicknames) for the host.
92 The type of address being returned \(em
98 The length of the address in bytes.
103 terminated array of network addresses for the host. Host addresses are returned in network byte order.
105 For backward compatibility with very old software,
107 is the first address in
110 \fBlwres_gethostent()\fR,
111 \fBlwres_sethostent()\fR,
112 \fBlwres_endhostent()\fR,
113 \fBlwres_gethostent_r()\fR,
114 \fBlwres_sethostent_r()\fR
116 \fBlwres_endhostent_r()\fR
117 provide iteration over the known host entries on systems that provide such functionality through facilities like
119 or NIS. The lightweight resolver does not currently implement these functions; it only provides them as stub functions that always return failure.
121 \fBlwres_gethostbyname()\fR
123 \fBlwres_gethostbyname2()\fR
126 \fBlwres_gethostbyname()\fR
127 always looks for an IPv4 address while
128 \fBlwres_gethostbyname2()\fR
129 looks for an address of protocol family
134 \(em IPv4 or IPV6 addresses respectively. Successful calls of the functions return a
135 \fBstruct hostent\fRfor the name that was looked up.
137 is returned if the lookups by
138 \fBlwres_gethostbyname()\fR
140 \fBlwres_gethostbyname2()\fR
143 Reverse lookups of addresses are performed by
144 \fBlwres_gethostbyaddr()\fR.
146 is an address of length
148 bytes and protocol family
154 \fBlwres_gethostbyname_r()\fR
155 is a thread\-safe function for forward lookups. If an error occurs, an error code is returned in
160 which is initialised by a successful call to
161 \fBlwres_gethostbyname_r()\fR
164 is a buffer of length
166 bytes which is used to store the
173 \fIresbuf\fR. Successful calls to
174 \fBlwres_gethostbyname_r()\fR
176 \fIresbuf\fR, which is a pointer to the
180 \fBlwres_gethostbyaddr_r()\fR
181 is a thread\-safe function that performs a reverse lookup of address
185 bytes long and is of protocol family
190 \fBPF_INET6\fR. If an error occurs, the error code is returned in
191 \fI*error\fR. The other function parameters are identical to those in
192 \fBlwres_gethostbyname_r()\fR.
196 which is initialised by a successful call to
197 \fBlwres_gethostbyaddr_r()\fR.
199 is a buffer of length
201 bytes which is used to store the
208 \fIresbuf\fR. Successful calls to
209 \fBlwres_gethostbyaddr_r()\fR
211 \fIresbuf\fR, which is a pointer to the
212 \fBstruct hostent()\fR
217 \fBlwres_gethostbyname()\fR,
218 \fBlwres_gethostbyname2()\fR,
219 \fBlwres_gethostbyaddr()\fR, and
220 \fBlwres_gethostent()\fR
221 return NULL to indicate an error. In this case the global variable
223 will contain one of the following error codes defined in
224 \fI<lwres/netdb.h>\fR:
227 The host or address was not found.
230 A recoverable error occurred, e.g., a timeout. Retrying the lookup may succeed.
233 A non\-recoverable error occurred.
236 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 compatibility.
238 \fBlwres_hstrerror\fR(3 )
239 translates these error codes to suitable error messages.
241 \fBlwres_gethostent()\fR
243 \fBlwres_gethostent_r()\fR
248 \fBlwres_gethostbyname_r()\fR
250 \fBlwres_gethostbyaddr_r()\fR
252 \fIresbuf\fR, a pointer to the
254 that was initialised by these functions. They return
256 if the lookups fail or if
258 was too small to hold the list of addresses and names referenced by the
263 \fBstruct hostent\fR. If
266 \fBlwres_gethostbyname_r()\fR
268 \fBlwres_gethostbyaddr_r()\fR
269 set the global variable
276 \fBlwres_getipnode\fR(3),
277 \fBlwres_hstrerror\fR(3 )
280 \fBlwres_gethostbyname()\fR,
281 \fBlwres_gethostbyname2()\fR,
282 \fBlwres_gethostbyaddr()\fR
284 \fBlwres_endhostent()\fR
285 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
286 \fBlwres_gethostbyname_r()\fR, and
287 \fBlwres_gethostbyaddr_r()\fR
290 The resolver daemon does not currently support any non\-DNS name services such as
293 \fBNIS\fR, consequently the above functions don't, either.
295 Copyright \(co 2004, 2005 Internet Systems Consortium, Inc. ("ISC")