1 .\" Copyright (C) 2004, 2005, 2007 Internet Systems Consortium, Inc. ("ISC")
2 .\" Copyright (C) 2001 Internet Software Consortium.
4 .\" Permission to use, copy, modify, and/or 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.29.418.1 2009/07/11 01:55:21 tbox Exp $
20 .\" Title: lwres_gethostent
22 .\" Generator: DocBook XSL Stylesheets v1.71.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:
87 The official (canonical) name of the host.
92 A NULL\-terminated array of alternate names (nicknames) for the host.
97 The type of address being returned \(em
105 The length of the address in bytes.
112 terminated array of network addresses for the host. Host addresses are returned in network byte order.
115 For backward compatibility with very old software,
117 is the first address in
120 \fBlwres_gethostent()\fR,
121 \fBlwres_sethostent()\fR,
122 \fBlwres_endhostent()\fR,
123 \fBlwres_gethostent_r()\fR,
124 \fBlwres_sethostent_r()\fR
126 \fBlwres_endhostent_r()\fR
127 provide iteration over the known host entries on systems that provide such functionality through facilities like
129 or NIS. The lightweight resolver does not currently implement these functions; it only provides them as stub functions that always return failure.
131 \fBlwres_gethostbyname()\fR
133 \fBlwres_gethostbyname2()\fR
136 \fBlwres_gethostbyname()\fR
137 always looks for an IPv4 address while
138 \fBlwres_gethostbyname2()\fR
139 looks for an address of protocol family
144 \(em IPv4 or IPV6 addresses respectively. Successful calls of the functions return a
145 \fBstruct hostent\fRfor the name that was looked up.
147 is returned if the lookups by
148 \fBlwres_gethostbyname()\fR
150 \fBlwres_gethostbyname2()\fR
153 Reverse lookups of addresses are performed by
154 \fBlwres_gethostbyaddr()\fR.
156 is an address of length
158 bytes and protocol family
164 \fBlwres_gethostbyname_r()\fR
165 is a thread\-safe function for forward lookups. If an error occurs, an error code is returned in
170 which is initialised by a successful call to
171 \fBlwres_gethostbyname_r()\fR.
173 is a buffer of length
175 bytes which is used to store the
182 \fIresbuf\fR. Successful calls to
183 \fBlwres_gethostbyname_r()\fR
185 \fIresbuf\fR, which is a pointer to the
189 \fBlwres_gethostbyaddr_r()\fR
190 is a thread\-safe function that performs a reverse lookup of address
194 bytes long and is of protocol family
199 \fBPF_INET6\fR. If an error occurs, the error code is returned in
200 \fI*error\fR. The other function parameters are identical to those in
201 \fBlwres_gethostbyname_r()\fR.
205 which is initialised by a successful call to
206 \fBlwres_gethostbyaddr_r()\fR.
208 is a buffer of length
210 bytes which is used to store the
217 \fIresbuf\fR. Successful calls to
218 \fBlwres_gethostbyaddr_r()\fR
220 \fIresbuf\fR, which is a pointer to the
221 \fBstruct hostent()\fR
226 \fBlwres_gethostbyname()\fR,
227 \fBlwres_gethostbyname2()\fR,
228 \fBlwres_gethostbyaddr()\fR, and
229 \fBlwres_gethostent()\fR
230 return NULL to indicate an error. In this case the global variable
232 will contain one of the following error codes defined in
233 \fI<lwres/netdb.h>\fR:
237 The host or address was not found.
242 A recoverable error occurred, e.g., a timeout. Retrying the lookup may succeed.
247 A non\-recoverable error occurred.
252 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.
255 \fBlwres_hstrerror\fR(3)
256 translates these error codes to suitable error messages.
258 \fBlwres_gethostent()\fR
260 \fBlwres_gethostent_r()\fR
265 \fBlwres_gethostbyname_r()\fR
267 \fBlwres_gethostbyaddr_r()\fR
269 \fIresbuf\fR, a pointer to the
271 that was initialised by these functions. They return
273 if the lookups fail or if
275 was too small to hold the list of addresses and names referenced by the
280 \fBstruct hostent\fR. If
283 \fBlwres_gethostbyname_r()\fR
285 \fBlwres_gethostbyaddr_r()\fR
286 set the global variable
293 \fBlwres_getipnode\fR(3),
294 \fBlwres_hstrerror\fR(3)
297 \fBlwres_gethostbyname()\fR,
298 \fBlwres_gethostbyname2()\fR,
299 \fBlwres_gethostbyaddr()\fR
301 \fBlwres_endhostent()\fR
302 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
303 \fBlwres_gethostbyname_r()\fR, and
304 \fBlwres_gethostbyaddr_r()\fR
307 The resolver daemon does not currently support any non\-DNS name services such as
310 \fBNIS\fR, consequently the above functions don't, either.
312 Copyright \(co 2004, 2005, 2007 Internet Systems Consortium, Inc. ("ISC")
314 Copyright \(co 2001 Internet Software Consortium.