]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/bind9/lib/lwres/man/lwres_gethostent.docbook
This commit was generated by cvs2svn to compensate for changes in r163299,
[FreeBSD/FreeBSD.git] / contrib / bind9 / lib / lwres / man / lwres_gethostent.docbook
1 <!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.0//EN"
2                "http://www.oasis-open.org/docbook/xml/4.0/docbookx.dtd"
3                [<!ENTITY mdash "&#8212;">]>
4 <!--
5  - Copyright (C) 2004, 2005  Internet Systems Consortium, Inc. ("ISC")
6  - Copyright (C) 2001  Internet Software Consortium.
7  -
8  - Permission to use, copy, modify, and distribute this software for any
9  - purpose with or without fee is hereby granted, provided that the above
10  - copyright notice and this permission notice appear in all copies.
11  -
12  - THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
13  - REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
14  - AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
15  - INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
16  - LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
17  - OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
18  - PERFORMANCE OF THIS SOFTWARE.
19 -->
20
21 <!-- $Id: lwres_gethostent.docbook,v 1.5.206.3 2005/05/13 01:22:36 marka Exp $ -->
22
23 <refentry>
24
25 <refentryinfo>
26 <date>Jun 30, 2000</date>
27 </refentryinfo>
28
29 <refmeta>
30 <refentrytitle>lwres_gethostent</refentrytitle>
31 <manvolnum>3</manvolnum>
32 <refmiscinfo>BIND9</refmiscinfo>
33 </refmeta>
34
35   <docinfo>
36     <copyright>
37       <year>2004</year>
38       <year>2005</year>
39       <holder>Internet Systems Consortium, Inc. ("ISC")</holder>
40     </copyright>
41     <copyright>
42       <year>2001</year>
43       <holder>Internet Software Consortium.</holder>
44     </copyright>
45   </docinfo>
46
47 <refnamediv>
48 <refname>lwres_gethostbyname</refname>
49 <refname>lwres_gethostbyname2</refname>
50 <refname>lwres_gethostbyaddr</refname>
51 <refname>lwres_gethostent</refname>
52 <refname>lwres_sethostent</refname>
53 <refname>lwres_endhostent</refname>
54 <refname>lwres_gethostbyname_r</refname>
55 <refname>lwres_gethostbyaddr_r</refname>
56 <refname>lwres_gethostent_r</refname>
57 <refname>lwres_sethostent_r</refname>
58 <refname>lwres_endhostent_r</refname>
59 <refpurpose>lightweight resolver get network host entry</refpurpose>
60 </refnamediv>
61 <refsynopsisdiv>
62 <funcsynopsis>
63 <funcsynopsisinfo>#include &lt;lwres/netdb.h&gt;</funcsynopsisinfo>
64 <funcprototype>
65 <funcdef>
66 struct hostent *
67 <function>lwres_gethostbyname</function></funcdef>
68 <paramdef>const char *name</paramdef>
69 </funcprototype>
70 <funcprototype>
71 <funcdef>
72 struct hostent *
73 <function>lwres_gethostbyname2</function></funcdef>
74 <paramdef>const char *name</paramdef>
75 <paramdef>int af</paramdef>
76 </funcprototype>
77 <funcprototype>
78 <funcdef>
79 struct hostent *
80 <function>lwres_gethostbyaddr</function></funcdef>
81 <paramdef>const char *addr</paramdef>
82 <paramdef>int len</paramdef>
83 <paramdef>int type</paramdef>
84 </funcprototype>
85 <funcprototype>
86 <funcdef>
87 struct hostent *
88 <function>lwres_gethostent</function></funcdef>
89 <paramdef>void</paramdef>
90 </funcprototype>
91 <funcprototype>
92 <funcdef>
93 void
94 <function>lwres_sethostent</function></funcdef>
95 <paramdef>int stayopen</paramdef>
96 </funcprototype>
97 <funcprototype>
98 <funcdef>
99 void
100 <function>lwres_endhostent</function></funcdef>
101 <paramdef>void</paramdef>
102 </funcprototype>
103 <funcprototype>
104 <funcdef>
105 struct hostent *
106 <function>lwres_gethostbyname_r</function></funcdef>
107 <paramdef>const char *name</paramdef>
108 <paramdef>struct hostent *resbuf</paramdef>
109 <paramdef>char *buf</paramdef>
110 <paramdef>int buflen</paramdef>
111 <paramdef>int *error</paramdef>
112 </funcprototype>
113 <funcprototype>
114 <funcdef>
115 struct hostent  *
116 <function>lwres_gethostbyaddr_r</function></funcdef>
117 <paramdef>const char *addr</paramdef>
118 <paramdef>int len</paramdef>
119 <paramdef>int type</paramdef>
120 <paramdef>struct hostent *resbuf</paramdef>
121 <paramdef>char *buf</paramdef>
122 <paramdef>int buflen</paramdef>
123 <paramdef>int *error</paramdef>
124 </funcprototype>
125 <funcprototype>
126 <funcdef>
127 struct hostent  *
128 <function>lwres_gethostent_r</function></funcdef>
129 <paramdef>struct hostent *resbuf</paramdef>
130 <paramdef>char *buf</paramdef>
131 <paramdef>int buflen</paramdef>
132 <paramdef>int *error</paramdef>
133 </funcprototype>
134 <funcprototype>
135 <funcdef>
136 void
137 <function>lwres_sethostent_r</function></funcdef>
138 <paramdef>int stayopen</paramdef>
139 </funcprototype>
140 <funcprototype>
141 <funcdef>
142 void
143 <function>lwres_endhostent_r</function></funcdef>
144 <paramdef>void</paramdef>
145 </funcprototype>
146 </funcsynopsis>
147 </refsynopsisdiv>
148
149 <refsect1>
150 <title>DESCRIPTION</title>
151 <para>
152 These functions provide hostname-to-address and
153 address-to-hostname lookups by means of the lightweight resolver.
154 They are similar to the standard
155 <citerefentry>
156 <refentrytitle>gethostent</refentrytitle><manvolnum>3
157 </manvolnum>
158 </citerefentry>
159 functions provided by most operating systems.
160 They use a
161 <type>struct hostent</type>
162 which is usually defined in
163 <filename>&lt;namedb.h&gt;</filename>.
164
165 <programlisting>
166 struct  hostent {
167         char    *h_name;        /* official name of host */
168         char    **h_aliases;    /* alias list */
169         int     h_addrtype;     /* host address type */
170         int     h_length;       /* length of address */
171         char    **h_addr_list;  /* list of addresses from name server */
172 };
173 #define h_addr  h_addr_list[0]  /* address, for backward compatibility */
174 </programlisting>
175 </para>
176 <para>
177 The members of this structure are:
178 <variablelist>
179 <varlistentry><term><constant>h_name</constant></term>
180 <listitem>
181 <para>
182 The official (canonical) name of the host.
183 </para>
184 </listitem></varlistentry>
185 <varlistentry><term><constant>h_aliases</constant></term>
186 <listitem>
187 <para>
188 A NULL-terminated array of alternate names (nicknames) for the host.
189 </para>
190 </listitem></varlistentry>
191 <varlistentry><term><constant>h_addrtype</constant></term>
192 <listitem>
193 <para>
194 The type of address being returned &mdash;
195 <type>PF_INET</type>
196 or
197 <type>PF_INET6</type>.
198 </para>
199 </listitem></varlistentry>
200 <varlistentry><term><constant>h_length</constant></term>
201 <listitem>
202 <para>
203 The length of the address in bytes.
204 </para>
205 </listitem></varlistentry>
206 <varlistentry><term><constant>h_addr_list</constant></term>
207 <listitem>
208 <para>
209 A <type>NULL</type>
210 terminated array of network addresses for the host.
211 Host addresses are returned in network byte order.
212 </para>
213 </listitem></varlistentry>
214 </variablelist>
215 </para>
216 <para>
217 For backward compatibility with very old software,
218 <constant>h_addr</constant>
219 is the first address in
220 <constant>h_addr_list.</constant>
221 </para>
222 <para>
223 <function>lwres_gethostent()</function>,
224 <function>lwres_sethostent()</function>,
225 <function>lwres_endhostent()</function>,
226 <function>lwres_gethostent_r()</function>,
227 <function>lwres_sethostent_r()</function>
228 and
229 <function>lwres_endhostent_r()</function>
230 provide iteration over the known host entries on systems that
231 provide such functionality through facilities like
232 <filename>/etc/hosts</filename>
233 or NIS.  The lightweight resolver does not currently implement
234 these functions; it only provides them as stub functions that always
235 return failure.
236 </para>
237
238 <para>
239 <function>lwres_gethostbyname()</function> and
240 <function>lwres_gethostbyname2()</function> look up the hostname
241 <parameter>name</parameter>.
242 <function>lwres_gethostbyname()</function> always looks for an IPv4
243 address while <function>lwres_gethostbyname2()</function> looks for an
244 address of protocol family <parameter>af</parameter>: either
245 <type>PF_INET</type> or <type>PF_INET6</type> &mdash; IPv4 or IPV6
246 addresses respectively.  Successful calls of the functions return a
247 <type>struct hostent</type>for the name that was looked up.
248 <type>NULL</type> is returned if the lookups by
249 <function>lwres_gethostbyname()</function> or
250 <function>lwres_gethostbyname2()</function> fail.
251 </para>
252
253 <para>
254 Reverse lookups of addresses are performed by
255 <function>lwres_gethostbyaddr()</function>.
256 <parameter>addr</parameter> is an address of length
257 <parameter>len</parameter> bytes and protocol family
258 <parameter>type</parameter> &mdash; <type>PF_INET</type> or
259 <type>PF_INET6</type>.
260 <function>lwres_gethostbyname_r()</function> is a thread-safe function
261 for forward lookups.  If an error occurs, an error code is returned in
262 <parameter>*error</parameter>.
263 <parameter>resbuf</parameter> is a pointer to a <type>struct
264 hostent</type> which is initialised by a successful call to
265 <function>lwres_gethostbyname_r()</function> .
266 <parameter>buf</parameter> is a buffer of length
267 <parameter>len</parameter> bytes which is used to store the
268 <constant>h_name</constant>, <constant>h_aliases</constant>, and
269 <constant>h_addr_list</constant> elements of the <type>struct
270 hostent</type> returned in <parameter>resbuf</parameter>.
271 Successful calls to <function>lwres_gethostbyname_r()</function>
272 return <parameter>resbuf</parameter>,
273 which is a pointer to the <type>struct hostent</type> it created.
274 </para>
275
276 <para>
277 <function>lwres_gethostbyaddr_r()</function> is a thread-safe function
278 that performs a reverse lookup of address <parameter>addr</parameter>
279 which is <parameter>len</parameter> bytes long and is of protocol
280 family <parameter>type</parameter> &mdash; <type>PF_INET</type> or
281 <type>PF_INET6</type>.  If an error occurs, the error code is returned
282 in <parameter>*error</parameter>.  The other function parameters are
283 identical to those in <function>lwres_gethostbyname_r()</function>.
284 <parameter>resbuf</parameter> is a pointer to a <type>struct
285 hostent</type> which is initialised by a successful call to
286 <function>lwres_gethostbyaddr_r()</function>.
287 <parameter>buf</parameter> is a buffer of length
288 <parameter>len</parameter> bytes which is used to store the
289 <constant>h_name</constant>, <constant>h_aliases</constant>, and
290 <constant>h_addr_list</constant> elements of the <type>struct
291 hostent</type> returned in <parameter>resbuf</parameter>.  Successful
292 calls to <function>lwres_gethostbyaddr_r()</function> return
293 <parameter>resbuf</parameter>, which is a pointer to the
294 <function>struct hostent()</function> it created.
295 </para>
296
297 </refsect1>
298
299 <refsect1>
300 <title>RETURN VALUES</title>
301 <para>
302 The functions
303 <function>lwres_gethostbyname()</function>,
304 <function>lwres_gethostbyname2()</function>,
305 <function>lwres_gethostbyaddr()</function>,
306 and
307 <function>lwres_gethostent()</function>
308 return NULL to indicate an error.  In this case the global variable
309 <type>lwres_h_errno</type>
310 will contain one of the following error codes defined in
311 <filename>&lt;lwres/netdb.h&gt;</filename>:
312
313 <variablelist>
314 <varlistentry><term><constant>HOST_NOT_FOUND</constant></term>
315 <listitem>
316 <para>
317 The host or address was not found.
318 </para>
319 </listitem></varlistentry>
320 <varlistentry><term><constant>TRY_AGAIN</constant></term>
321 <listitem>
322 <para>
323 A recoverable error occurred, e.g., a timeout.
324 Retrying the lookup may succeed.
325 </para>
326 </listitem></varlistentry>
327 <varlistentry><term><constant>NO_RECOVERY</constant></term>
328 <listitem>
329 <para>
330 A non-recoverable error occurred.
331 </para>
332 </listitem></varlistentry>
333 <varlistentry><term><constant>NO_DATA</constant></term>
334 <listitem>
335 <para>
336 The name exists, but has no address information
337 associated with it (or vice versa in the case
338 of a reverse lookup).  The code NO_ADDRESS
339 is accepted as a synonym for NO_DATA for backwards
340 compatibility.
341 </para>
342 </listitem></varlistentry>
343 </variablelist>
344 </para>
345
346 <para>
347 <citerefentry>
348 <refentrytitle>lwres_hstrerror</refentrytitle><manvolnum>3
349 </manvolnum>
350 </citerefentry>
351 translates these error codes to suitable error messages.
352 </para>
353
354 <para>
355 <function>lwres_gethostent()</function>
356 and
357 <function>lwres_gethostent_r()</function>
358 always return
359 <type>NULL</type>.
360 </para>
361
362 <para>
363 Successful calls to <function>lwres_gethostbyname_r()</function> and
364 <function>lwres_gethostbyaddr_r()</function> return
365 <parameter>resbuf</parameter>, a pointer to the <type>struct
366 hostent</type> that was initialised by these functions.  They return
367 <type>NULL</type> if the lookups fail or if <parameter>buf</parameter>
368 was too small to hold the list of addresses and names referenced by
369 the <constant>h_name</constant>, <constant>h_aliases</constant>, and
370 <constant>h_addr_list</constant> elements of the <type>struct
371 hostent</type>.  If <parameter>buf</parameter> was too small, both
372 <function>lwres_gethostbyname_r()</function> and
373 <function>lwres_gethostbyaddr_r()</function> set the global variable
374 <type>errno</type> to <errorcode>ERANGE</errorcode>.
375 </para>
376
377 </refsect1>
378 <refsect1>
379 <title>SEE ALSO</title>
380 <para>
381 <citerefentry>
382 <refentrytitle>gethostent</refentrytitle><manvolnum>3</manvolnum>
383 </citerefentry>,
384
385 <citerefentry>
386 <refentrytitle>lwres_getipnode</refentrytitle><manvolnum>3</manvolnum>
387 </citerefentry>,
388
389 <citerefentry>
390 <refentrytitle>lwres_hstrerror</refentrytitle><manvolnum>3
391 </manvolnum>
392 </citerefentry>
393 </para>
394 </refsect1>
395
396 <refsect1>
397 <title>BUGS</title>
398 <para>
399 <function>lwres_gethostbyname()</function>,
400 <function>lwres_gethostbyname2()</function>,
401 <function>lwres_gethostbyaddr()</function>
402 and
403 <function>lwres_endhostent()</function>
404 are not thread safe; they return pointers to static data and 
405 provide error codes through a global variable.
406 Thread-safe versions for name and address lookup are provided by
407 <function>lwres_gethostbyname_r()</function>,
408 and
409 <function>lwres_gethostbyaddr_r()</function>
410 respectively.
411 </para>
412 <para>
413 The resolver daemon does not currently support any non-DNS
414 name services such as 
415 <filename>/etc/hosts</filename>
416 or
417 <type>NIS</type>,
418 consequently the above functions don't, either.
419 </para>
420 </refsect1>
421 </refentry>