Merge from vendor branch LESS:
[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.5 2005/10/13 02:33:53 marka Exp $
17 .\"
18 .hy 0
19 .ad l
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
26 .nh
27 .\" disable justification (adjust text to left margin only)
28 .ad l
29 .SH "NAME"
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
31 .SH "SYNOPSIS"
32 .nf
33 #include <lwres/netdb.h>
34 .fi
35 .HP 37
36 \fBstruct\ hostent\ *\ \fBlwres_gethostbyname\fR\fR\fB(\fR\fBconst\ char\ *name\fR\fB);\fR
37 .HP 38
38 \fBstruct\ hostent\ *\ \fBlwres_gethostbyname2\fR\fR\fB(\fR\fBconst\ char\ *name\fR\fB, \fR\fBint\ af\fR\fB);\fR
39 .HP 37
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
41 .HP 34
42 \fBstruct\ hostent\ *\ \fBlwres_gethostent\fR\fR\fB(\fR\fBvoid\fR\fB);\fR
43 .HP 22
44 \fBvoid\ \fBlwres_sethostent\fR\fR\fB(\fR\fBint\ stayopen\fR\fB);\fR
45 .HP 22
46 \fBvoid\ \fBlwres_endhostent\fR\fR\fB(\fR\fBvoid\fR\fB);\fR
47 .HP 39
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
49 .HP 39
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
51 .HP 36
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
53 .HP 24
54 \fBvoid\ \fBlwres_sethostent_r\fR\fR\fB(\fR\fBint\ stayopen\fR\fB);\fR
55 .HP 24
56 \fBvoid\ \fBlwres_endhostent_r\fR\fR\fB(\fR\fBvoid\fR\fB);\fR
57 .SH "DESCRIPTION"
58 .PP
59 These functions provide hostname\-to\-address and address\-to\-hostname lookups by means of the lightweight resolver. They are similar to the standard
60 \fBgethostent\fR(3 )
61 functions provided by most operating systems. They use a
62 \fBstruct hostent\fR
63 which is usually defined in
64 \fI<namedb.h>\fR.
65 .sp
66 .nf
67 struct  hostent {
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 */
73 };
74 #define h_addr  h_addr_list[0]  /* address, for backward compatibility */
75 .fi
76 .sp
77 .PP
78 The members of this structure are:
79 .TP
80 \fBh_name\fR
81 The official (canonical) name of the host.
82 .TP
83 \fBh_aliases\fR
84 A NULL\-terminated array of alternate names (nicknames) for the host.
85 .TP
86 \fBh_addrtype\fR
87 The type of address being returned \(em
88 \fBPF_INET\fR
89 or
90 \fBPF_INET6\fR.
91 .TP
92 \fBh_length\fR
93 The length of the address in bytes.
94 .TP
95 \fBh_addr_list\fR
96 A
97 \fBNULL\fR
98 terminated array of network addresses for the host. Host addresses are returned in network byte order.
99 .PP
100 For backward compatibility with very old software,
101 \fBh_addr\fR
102 is the first address in
103 \fBh_addr_list.\fR
104 .PP
105 \fBlwres_gethostent()\fR,
106 \fBlwres_sethostent()\fR,
107 \fBlwres_endhostent()\fR,
108 \fBlwres_gethostent_r()\fR,
109 \fBlwres_sethostent_r()\fR
110 and
111 \fBlwres_endhostent_r()\fR
112 provide iteration over the known host entries on systems that provide such functionality through facilities like
113 \fI/etc/hosts\fR
114 or NIS. The lightweight resolver does not currently implement these functions; it only provides them as stub functions that always return failure.
115 .PP
116 \fBlwres_gethostbyname()\fR
117 and
118 \fBlwres_gethostbyname2()\fR
119 look up the hostname
120 \fIname\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
125 \fIaf\fR: either
126 \fBPF_INET\fR
127 or
128 \fBPF_INET6\fR
129 \(em IPv4 or IPV6 addresses respectively. Successful calls of the functions return a
130 \fBstruct hostent\fRfor the name that was looked up.
131 \fBNULL\fR
132 is returned if the lookups by
133 \fBlwres_gethostbyname()\fR
134 or
135 \fBlwres_gethostbyname2()\fR
136 fail.
137 .PP
138 Reverse lookups of addresses are performed by
139 \fBlwres_gethostbyaddr()\fR.
140 \fIaddr\fR
141 is an address of length
142 \fIlen\fR
143 bytes and protocol family
144 \fItype\fR
145 \(em
146 \fBPF_INET\fR
147 or
148 \fBPF_INET6\fR.
149 \fBlwres_gethostbyname_r()\fR
150 is a thread\-safe function for forward lookups. If an error occurs, an error code is returned in
151 \fI*error\fR.
152 \fIresbuf\fR
153 is a pointer to a
154 \fBstruct hostent\fR
155 which is initialised by a successful call to
156 \fBlwres_gethostbyname_r()\fR
157 .
158 \fIbuf\fR
159 is a buffer of length
160 \fIlen\fR
161 bytes which is used to store the
162 \fBh_name\fR,
163 \fBh_aliases\fR, and
164 \fBh_addr_list\fR
165 elements of the
166 \fBstruct hostent\fR
167 returned in
168 \fIresbuf\fR. Successful calls to
169 \fBlwres_gethostbyname_r()\fR
170 return
171 \fIresbuf\fR, which is a pointer to the
172 \fBstruct hostent\fR
173 it created.
174 .PP
175 \fBlwres_gethostbyaddr_r()\fR
176 is a thread\-safe function that performs a reverse lookup of address
177 \fIaddr\fR
178 which is
179 \fIlen\fR
180 bytes long and is of protocol family
181 \fItype\fR
182 \(em
183 \fBPF_INET\fR
184 or
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.
188 \fIresbuf\fR
189 is a pointer to a
190 \fBstruct hostent\fR
191 which is initialised by a successful call to
192 \fBlwres_gethostbyaddr_r()\fR.
193 \fIbuf\fR
194 is a buffer of length
195 \fIlen\fR
196 bytes which is used to store the
197 \fBh_name\fR,
198 \fBh_aliases\fR, and
199 \fBh_addr_list\fR
200 elements of the
201 \fBstruct hostent\fR
202 returned in
203 \fIresbuf\fR. Successful calls to
204 \fBlwres_gethostbyaddr_r()\fR
205 return
206 \fIresbuf\fR, which is a pointer to the
207 \fBstruct hostent()\fR
208 it created.
209 .SH "RETURN VALUES"
210 .PP
211 The functions
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
217 \fBlwres_h_errno\fR
218 will contain one of the following error codes defined in
219 \fI<lwres/netdb.h>\fR:
220 .TP
221 \fBHOST_NOT_FOUND\fR
222 The host or address was not found.
223 .TP
224 \fBTRY_AGAIN\fR
225 A recoverable error occurred, e.g., a timeout. Retrying the lookup may succeed.
226 .TP
227 \fBNO_RECOVERY\fR
228 A non\-recoverable error occurred.
229 .TP
230 \fBNO_DATA\fR
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.
232 .PP
233 \fBlwres_hstrerror\fR(3 )
234 translates these error codes to suitable error messages.
235 .PP
236 \fBlwres_gethostent()\fR
237 and
238 \fBlwres_gethostent_r()\fR
239 always return
240 \fBNULL\fR.
241 .PP
242 Successful calls to
243 \fBlwres_gethostbyname_r()\fR
244 and
245 \fBlwres_gethostbyaddr_r()\fR
246 return
247 \fIresbuf\fR, a pointer to the
248 \fBstruct hostent\fR
249 that was initialised by these functions. They return
250 \fBNULL\fR
251 if the lookups fail or if
252 \fIbuf\fR
253 was too small to hold the list of addresses and names referenced by the
254 \fBh_name\fR,
255 \fBh_aliases\fR, and
256 \fBh_addr_list\fR
257 elements of the
258 \fBstruct hostent\fR. If
259 \fIbuf\fR
260 was too small, both
261 \fBlwres_gethostbyname_r()\fR
262 and
263 \fBlwres_gethostbyaddr_r()\fR
264 set the global variable
265 \fBerrno\fR
266 to
267 \fBERANGE\fR.
268 .SH "SEE ALSO"
269 .PP
270 \fBgethostent\fR(3),
271 \fBlwres_getipnode\fR(3),
272 \fBlwres_hstrerror\fR(3 )
273 .SH "BUGS"
274 .PP
275 \fBlwres_gethostbyname()\fR,
276 \fBlwres_gethostbyname2()\fR,
277 \fBlwres_gethostbyaddr()\fR
278 and
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
283 respectively.
284 .PP
285 The resolver daemon does not currently support any non\-DNS name services such as
286 \fI/etc/hosts\fR
287 or
288 \fBNIS\fR, consequently the above functions don't, either.