Merge from vendor branch OPENSSL:
[dragonfly.git] / contrib / bind-9.3 / lib / lwres / man / lwres_gethostent.3
1 .\" Copyright (C) 2004, 2005 Internet Systems Consortium, Inc. ("ISC")
2 .\" Copyright (C) 2001 Internet Software Consortium.
3 .\" 
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.
7 .\" 
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.
15 .\"
16 .\" $Id: lwres_gethostent.3,v 1.16.2.1.8.6 2006/06/29 13:02:31 marka Exp $
17 .\"
18 .hy 0
19 .ad l
20 .\"     Title: lwres_gethostent
21 .\"    Author: 
22 .\" Generator: DocBook XSL Stylesheets v1.70.1 <http://docbook.sf.net/>
23 .\"      Date: Jun 30, 2000
24 .\"    Manual: BIND9
25 .\"    Source: BIND9
26 .\"
27 .TH "LWRES_GETHOSTENT" "3" "Jun 30, 2000" "BIND9" "BIND9"
28 .\" disable hyphenation
29 .nh
30 .\" disable justification (adjust text to left margin only)
31 .ad l
32 .SH "NAME"
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
34 .SH "SYNOPSIS"
35 .nf
36 #include <lwres/netdb.h>
37 .fi
38 .HP 37
39 .BI "struct hostent * lwres_gethostbyname(const\ char\ *name);"
40 .HP 38
41 .BI "struct hostent * lwres_gethostbyname2(const\ char\ *name, int\ af);"
42 .HP 37
43 .BI "struct hostent * lwres_gethostbyaddr(const\ char\ *addr, int\ len, int\ type);"
44 .HP 34
45 .BI "struct hostent * lwres_gethostent(void);"
46 .HP 22
47 .BI "void lwres_sethostent(int\ stayopen);"
48 .HP 22
49 .BI "void lwres_endhostent(void);"
50 .HP 39
51 .BI "struct hostent * lwres_gethostbyname_r(const\ char\ *name, struct\ hostent\ *resbuf, char\ *buf, int\ buflen, int\ *error);"
52 .HP 39
53 .BI "struct hostent * lwres_gethostbyaddr_r(const\ char\ *addr, int\ len, int\ type, struct\ hostent\ *resbuf, char\ *buf, int\ buflen, int\ *error);"
54 .HP 36
55 .BI "struct hostent * lwres_gethostent_r(struct\ hostent\ *resbuf, char\ *buf, int\ buflen, int\ *error);"
56 .HP 24
57 .BI "void lwres_sethostent_r(int\ stayopen);"
58 .HP 24
59 .BI "void lwres_endhostent_r(void);"
60 .SH "DESCRIPTION"
61 .PP
62 These functions provide hostname\-to\-address and address\-to\-hostname lookups by means of the lightweight resolver. They are similar to the standard
63 \fBgethostent\fR(3 )
64 functions provided by most operating systems. They use a
65 \fBstruct hostent\fR
66 which is usually defined in
67 \fI<namedb.h>\fR.
68 .sp
69 .RS 3n
70 .nf
71 struct  hostent {
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 */
77 };
78 #define h_addr  h_addr_list[0]  /* address, for backward compatibility */
79 .fi
80 .RE
81 .sp
82 .PP
83 The members of this structure are:
84 .TP 3n
85 \fBh_name\fR
86 The official (canonical) name of the host.
87 .TP 3n
88 \fBh_aliases\fR
89 A NULL\-terminated array of alternate names (nicknames) for the host.
90 .TP 3n
91 \fBh_addrtype\fR
92 The type of address being returned \(em
93 \fBPF_INET\fR
94 or
95 \fBPF_INET6\fR.
96 .TP 3n
97 \fBh_length\fR
98 The length of the address in bytes.
99 .TP 3n
100 \fBh_addr_list\fR
101 A
102 \fBNULL\fR
103 terminated array of network addresses for the host. Host addresses are returned in network byte order.
104 .PP
105 For backward compatibility with very old software,
106 \fBh_addr\fR
107 is the first address in
108 \fBh_addr_list.\fR
109 .PP
110 \fBlwres_gethostent()\fR,
111 \fBlwres_sethostent()\fR,
112 \fBlwres_endhostent()\fR,
113 \fBlwres_gethostent_r()\fR,
114 \fBlwres_sethostent_r()\fR
115 and
116 \fBlwres_endhostent_r()\fR
117 provide iteration over the known host entries on systems that provide such functionality through facilities like
118 \fI/etc/hosts\fR
119 or NIS. The lightweight resolver does not currently implement these functions; it only provides them as stub functions that always return failure.
120 .PP
121 \fBlwres_gethostbyname()\fR
122 and
123 \fBlwres_gethostbyname2()\fR
124 look up the hostname
125 \fIname\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
130 \fIaf\fR: either
131 \fBPF_INET\fR
132 or
133 \fBPF_INET6\fR
134 \(em IPv4 or IPV6 addresses respectively. Successful calls of the functions return a
135 \fBstruct hostent\fRfor the name that was looked up.
136 \fBNULL\fR
137 is returned if the lookups by
138 \fBlwres_gethostbyname()\fR
139 or
140 \fBlwres_gethostbyname2()\fR
141 fail.
142 .PP
143 Reverse lookups of addresses are performed by
144 \fBlwres_gethostbyaddr()\fR.
145 \fIaddr\fR
146 is an address of length
147 \fIlen\fR
148 bytes and protocol family
149 \fItype\fR
150 \(em
151 \fBPF_INET\fR
152 or
153 \fBPF_INET6\fR.
154 \fBlwres_gethostbyname_r()\fR
155 is a thread\-safe function for forward lookups. If an error occurs, an error code is returned in
156 \fI*error\fR.
157 \fIresbuf\fR
158 is a pointer to a
159 \fBstruct hostent\fR
160 which is initialised by a successful call to
161 \fBlwres_gethostbyname_r()\fR
162 .
163 \fIbuf\fR
164 is a buffer of length
165 \fIlen\fR
166 bytes which is used to store the
167 \fBh_name\fR,
168 \fBh_aliases\fR, and
169 \fBh_addr_list\fR
170 elements of the
171 \fBstruct hostent\fR
172 returned in
173 \fIresbuf\fR. Successful calls to
174 \fBlwres_gethostbyname_r()\fR
175 return
176 \fIresbuf\fR, which is a pointer to the
177 \fBstruct hostent\fR
178 it created.
179 .PP
180 \fBlwres_gethostbyaddr_r()\fR
181 is a thread\-safe function that performs a reverse lookup of address
182 \fIaddr\fR
183 which is
184 \fIlen\fR
185 bytes long and is of protocol family
186 \fItype\fR
187 \(em
188 \fBPF_INET\fR
189 or
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.
193 \fIresbuf\fR
194 is a pointer to a
195 \fBstruct hostent\fR
196 which is initialised by a successful call to
197 \fBlwres_gethostbyaddr_r()\fR.
198 \fIbuf\fR
199 is a buffer of length
200 \fIlen\fR
201 bytes which is used to store the
202 \fBh_name\fR,
203 \fBh_aliases\fR, and
204 \fBh_addr_list\fR
205 elements of the
206 \fBstruct hostent\fR
207 returned in
208 \fIresbuf\fR. Successful calls to
209 \fBlwres_gethostbyaddr_r()\fR
210 return
211 \fIresbuf\fR, which is a pointer to the
212 \fBstruct hostent()\fR
213 it created.
214 .SH "RETURN VALUES"
215 .PP
216 The functions
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
222 \fBlwres_h_errno\fR
223 will contain one of the following error codes defined in
224 \fI<lwres/netdb.h>\fR:
225 .TP 3n
226 \fBHOST_NOT_FOUND\fR
227 The host or address was not found.
228 .TP 3n
229 \fBTRY_AGAIN\fR
230 A recoverable error occurred, e.g., a timeout. Retrying the lookup may succeed.
231 .TP 3n
232 \fBNO_RECOVERY\fR
233 A non\-recoverable error occurred.
234 .TP 3n
235 \fBNO_DATA\fR
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.
237 .PP
238 \fBlwres_hstrerror\fR(3 )
239 translates these error codes to suitable error messages.
240 .PP
241 \fBlwres_gethostent()\fR
242 and
243 \fBlwres_gethostent_r()\fR
244 always return
245 \fBNULL\fR.
246 .PP
247 Successful calls to
248 \fBlwres_gethostbyname_r()\fR
249 and
250 \fBlwres_gethostbyaddr_r()\fR
251 return
252 \fIresbuf\fR, a pointer to the
253 \fBstruct hostent\fR
254 that was initialised by these functions. They return
255 \fBNULL\fR
256 if the lookups fail or if
257 \fIbuf\fR
258 was too small to hold the list of addresses and names referenced by the
259 \fBh_name\fR,
260 \fBh_aliases\fR, and
261 \fBh_addr_list\fR
262 elements of the
263 \fBstruct hostent\fR. If
264 \fIbuf\fR
265 was too small, both
266 \fBlwres_gethostbyname_r()\fR
267 and
268 \fBlwres_gethostbyaddr_r()\fR
269 set the global variable
270 \fBerrno\fR
271 to
272 \fBERANGE\fR.
273 .SH "SEE ALSO"
274 .PP
275 \fBgethostent\fR(3),
276 \fBlwres_getipnode\fR(3),
277 \fBlwres_hstrerror\fR(3 )
278 .SH "BUGS"
279 .PP
280 \fBlwres_gethostbyname()\fR,
281 \fBlwres_gethostbyname2()\fR,
282 \fBlwres_gethostbyaddr()\fR
283 and
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
288 respectively.
289 .PP
290 The resolver daemon does not currently support any non\-DNS name services such as
291 \fI/etc/hosts\fR
292 or
293 \fBNIS\fR, consequently the above functions don't, either.
294 .SH "COPYRIGHT"
295 Copyright \(co 2004, 2005 Internet Systems Consortium, Inc. ("ISC")