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.5 2005/10/13 02:33:53 marka Exp $
20 .\" ** You probably do not want to edit this file directly **
21 .\" It was generated using the DocBook XSL Stylesheets (version 1.69.1).
22 .\" Instead of manually editing it, you probably should edit the DocBook XML
23 .\" source for it and then use the DocBook XSL Stylesheets to regenerate it.
24 .TH "LWRES_GETHOSTENT" "3" "Jun 30, 2000" "BIND9" "BIND9"
25 .\" disable hyphenation
27 .\" disable justification (adjust text to left margin only)
30 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
33 #include <lwres/netdb.h>
36 \fBstruct\ hostent\ *\ \fBlwres_gethostbyname\fR\fR\fB(\fR\fBconst\ char\ *name\fR\fB);\fR
38 \fBstruct\ hostent\ *\ \fBlwres_gethostbyname2\fR\fR\fB(\fR\fBconst\ char\ *name\fR\fB, \fR\fBint\ af\fR\fB);\fR
40 \fBstruct\ hostent\ *\ \fBlwres_gethostbyaddr\fR\fR\fB(\fR\fBconst\ char\ *addr\fR\fB, \fR\fBint\ len\fR\fB, \fR\fBint\ type\fR\fB);\fR
42 \fBstruct\ hostent\ *\ \fBlwres_gethostent\fR\fR\fB(\fR\fBvoid\fR\fB);\fR
44 \fBvoid\ \fBlwres_sethostent\fR\fR\fB(\fR\fBint\ stayopen\fR\fB);\fR
46 \fBvoid\ \fBlwres_endhostent\fR\fR\fB(\fR\fBvoid\fR\fB);\fR
48 \fBstruct\ hostent\ *\ \fBlwres_gethostbyname_r\fR\fR\fB(\fR\fBconst\ char\ *name\fR\fB, \fR\fBstruct\ hostent\ *resbuf\fR\fB, \fR\fBchar\ *buf\fR\fB, \fR\fBint\ buflen\fR\fB, \fR\fBint\ *error\fR\fB);\fR
50 \fBstruct\ hostent\ *\ \fBlwres_gethostbyaddr_r\fR\fR\fB(\fR\fBconst\ char\ *addr\fR\fB, \fR\fBint\ len\fR\fB, \fR\fBint\ type\fR\fB, \fR\fBstruct\ hostent\ *resbuf\fR\fB, \fR\fBchar\ *buf\fR\fB, \fR\fBint\ buflen\fR\fB, \fR\fBint\ *error\fR\fB);\fR
52 \fBstruct\ hostent\ *\ \fBlwres_gethostent_r\fR\fR\fB(\fR\fBstruct\ hostent\ *resbuf\fR\fB, \fR\fBchar\ *buf\fR\fB, \fR\fBint\ buflen\fR\fB, \fR\fBint\ *error\fR\fB);\fR
54 \fBvoid\ \fBlwres_sethostent_r\fR\fR\fB(\fR\fBint\ stayopen\fR\fB);\fR
56 \fBvoid\ \fBlwres_endhostent_r\fR\fR\fB(\fR\fBvoid\fR\fB);\fR
59 These functions provide hostname\-to\-address and address\-to\-hostname lookups by means of the lightweight resolver. They are similar to the standard
61 functions provided by most operating systems. They use a
63 which is usually defined in
68 char *h_name; /* official name of host */
69 char **h_aliases; /* alias list */
70 int h_addrtype; /* host address type */
71 int h_length; /* length of address */
72 char **h_addr_list; /* list of addresses from name server */
74 #define h_addr h_addr_list[0] /* address, for backward compatibility */
78 The members of this structure are:
81 The official (canonical) name of the host.
84 A NULL\-terminated array of alternate names (nicknames) for the host.
87 The type of address being returned \(em
93 The length of the address in bytes.
98 terminated array of network addresses for the host. Host addresses are returned in network byte order.
100 For backward compatibility with very old software,
102 is the first address in
105 \fBlwres_gethostent()\fR,
106 \fBlwres_sethostent()\fR,
107 \fBlwres_endhostent()\fR,
108 \fBlwres_gethostent_r()\fR,
109 \fBlwres_sethostent_r()\fR
111 \fBlwres_endhostent_r()\fR
112 provide iteration over the known host entries on systems that provide such functionality through facilities like
114 or NIS. The lightweight resolver does not currently implement these functions; it only provides them as stub functions that always return failure.
116 \fBlwres_gethostbyname()\fR
118 \fBlwres_gethostbyname2()\fR
121 \fBlwres_gethostbyname()\fR
122 always looks for an IPv4 address while
123 \fBlwres_gethostbyname2()\fR
124 looks for an address of protocol family
129 \(em IPv4 or IPV6 addresses respectively. Successful calls of the functions return a
130 \fBstruct hostent\fRfor the name that was looked up.
132 is returned if the lookups by
133 \fBlwres_gethostbyname()\fR
135 \fBlwres_gethostbyname2()\fR
138 Reverse lookups of addresses are performed by
139 \fBlwres_gethostbyaddr()\fR.
141 is an address of length
143 bytes and protocol family
149 \fBlwres_gethostbyname_r()\fR
150 is a thread\-safe function for forward lookups. If an error occurs, an error code is returned in
155 which is initialised by a successful call to
156 \fBlwres_gethostbyname_r()\fR
159 is a buffer of length
161 bytes which is used to store the
168 \fIresbuf\fR. Successful calls to
169 \fBlwres_gethostbyname_r()\fR
171 \fIresbuf\fR, which is a pointer to the
175 \fBlwres_gethostbyaddr_r()\fR
176 is a thread\-safe function that performs a reverse lookup of address
180 bytes long and is of protocol family
185 \fBPF_INET6\fR. If an error occurs, the error code is returned in
186 \fI*error\fR. The other function parameters are identical to those in
187 \fBlwres_gethostbyname_r()\fR.
191 which is initialised by a successful call to
192 \fBlwres_gethostbyaddr_r()\fR.
194 is a buffer of length
196 bytes which is used to store the
203 \fIresbuf\fR. Successful calls to
204 \fBlwres_gethostbyaddr_r()\fR
206 \fIresbuf\fR, which is a pointer to the
207 \fBstruct hostent()\fR
212 \fBlwres_gethostbyname()\fR,
213 \fBlwres_gethostbyname2()\fR,
214 \fBlwres_gethostbyaddr()\fR, and
215 \fBlwres_gethostent()\fR
216 return NULL to indicate an error. In this case the global variable
218 will contain one of the following error codes defined in
219 \fI<lwres/netdb.h>\fR:
222 The host or address was not found.
225 A recoverable error occurred, e.g., a timeout. Retrying the lookup may succeed.
228 A non\-recoverable error occurred.
231 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.
233 \fBlwres_hstrerror\fR(3 )
234 translates these error codes to suitable error messages.
236 \fBlwres_gethostent()\fR
238 \fBlwres_gethostent_r()\fR
243 \fBlwres_gethostbyname_r()\fR
245 \fBlwres_gethostbyaddr_r()\fR
247 \fIresbuf\fR, a pointer to the
249 that was initialised by these functions. They return
251 if the lookups fail or if
253 was too small to hold the list of addresses and names referenced by the
258 \fBstruct hostent\fR. If
261 \fBlwres_gethostbyname_r()\fR
263 \fBlwres_gethostbyaddr_r()\fR
264 set the global variable
271 \fBlwres_getipnode\fR(3),
272 \fBlwres_hstrerror\fR(3 )
275 \fBlwres_gethostbyname()\fR,
276 \fBlwres_gethostbyname2()\fR,
277 \fBlwres_gethostbyaddr()\fR
279 \fBlwres_endhostent()\fR
280 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
281 \fBlwres_gethostbyname_r()\fR, and
282 \fBlwres_gethostbyaddr_r()\fR
285 The resolver daemon does not currently support any non\-DNS name services such as
288 \fBNIS\fR, consequently the above functions don't, either.