Merge from vendor branch TCPDUMP:
[dragonfly.git] / contrib / bind-9.3 / lib / lwres / man / lwres_getipnode.html
1 <!--
2  - Copyright (C) 2004, 2005 Internet Systems Consortium, Inc. ("ISC")
3  - Copyright (C) 2000, 2001, 2003 Internet Software Consortium.
4  - 
5  - Permission to use, copy, modify, and distribute this software for any
6  - purpose with or without fee is hereby granted, provided that the above
7  - copyright notice and this permission notice appear in all copies.
8  - 
9  - THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
10  - REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
11  - AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
12  - INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
13  - LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
14  - OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15  - PERFORMANCE OF THIS SOFTWARE.
16 -->
17 <!-- $Id: lwres_getipnode.html,v 1.7.2.1.4.11 2006/06/29 13:02:31 marka Exp $ -->
18 <html>
19 <head>
20 <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
21 <title>lwres_getipnode</title>
22 <meta name="generator" content="DocBook XSL Stylesheets V1.70.1">
23 </head>
24 <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="refentry" lang="en">
25 <a name="id2482688"></a><div class="titlepage"></div>
26 <div class="refnamediv">
27 <h2>Name</h2>
28 <p>lwres_getipnodebyname, lwres_getipnodebyaddr, lwres_freehostent &#8212; lightweight resolver nodename / address translation API</p>
29 </div>
30 <div class="refsynopsisdiv">
31 <h2>Synopsis</h2>
32 <div class="funcsynopsis">
33 <pre class="funcsynopsisinfo">#include &lt;lwres/netdb.h&gt;</pre>
34 <table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" style="padding-bottom: 1em">
35 <tr>
36 <td><code class="funcdef">
37 struct hostent *
38 <b class="fsfunc">lwres_getipnodebyname</b>(</code></td>
39 <td> </td>
40 <td>, </td>
41 </tr>
42 <tr>
43 <td> </td>
44 <td> </td>
45 <td>, </td>
46 </tr>
47 <tr>
48 <td> </td>
49 <td> </td>
50 <td>, </td>
51 </tr>
52 <tr>
53 <td> </td>
54 <td> </td>
55 <td>, </td>
56 </tr>
57 <tr>
58 <td> </td>
59 <td> </td>
60 <td>
61 <code>)</code>;</td>
62 </tr>
63 </table>
64 <table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" style="padding-bottom: 1em">
65 <tr>
66 <td><code class="funcdef">
67 struct hostent *
68 <b class="fsfunc">lwres_getipnodebyaddr</b>(</code></td>
69 <td> </td>
70 <td>, </td>
71 </tr>
72 <tr>
73 <td> </td>
74 <td> </td>
75 <td>, </td>
76 </tr>
77 <tr>
78 <td> </td>
79 <td> </td>
80 <td>, </td>
81 </tr>
82 <tr>
83 <td> </td>
84 <td> </td>
85 <td>, </td>
86 </tr>
87 <tr>
88 <td> </td>
89 <td> </td>
90 <td>
91 <code>)</code>;</td>
92 </tr>
93 </table>
94 <table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0">
95 <tr>
96 <td><code class="funcdef">
97 void
98 <b class="fsfunc">lwres_freehostent</b>(</code></td>
99 <td> </td>
100 <td>
101 <code>)</code>;</td>
102 </tr>
103 <tr>
104 <td> </td>
105 <td> </td>
106 <td>
107 <code>)</code>;</td>
108 </tr>
109 </table>
110 </div>
111 </div>
112 <div class="refsect1" lang="en">
113 <a name="id2549461"></a><h2>DESCRIPTION</h2>
114 <p>
115 These functions perform thread safe, protocol independent
116 nodename-to-address and address-to-nodename 
117 translation as defined in RFC2553.
118 </p>
119 <p>
120 They use a
121 <span class="type">struct hostent</span>
122 which is defined in
123 <code class="filename">namedb.h</code>:
124 </p>
125 <pre class="programlisting">
126 struct  hostent {
127         char    *h_name;        /* official name of host */
128         char    **h_aliases;    /* alias list */
129         int     h_addrtype;     /* host address type */
130         int     h_length;       /* length of address */
131         char    **h_addr_list;  /* list of addresses from name server */
132 };
133 #define h_addr  h_addr_list[0]  /* address, for backward compatibility */
134 </pre>
135 <p>
136 </p>
137 <p>
138 The members of this structure are:
139 </p>
140 <div class="variablelist"><dl>
141 <dt><span class="term"><code class="constant">h_name</code></span></dt>
142 <dd><p>
143 The official (canonical) name of the host.
144 </p></dd>
145 <dt><span class="term"><code class="constant">h_aliases</code></span></dt>
146 <dd><p>
147 A NULL-terminated array of alternate names (nicknames) for the host.
148 </p></dd>
149 <dt><span class="term"><code class="constant">h_addrtype</code></span></dt>
150 <dd><p>
151 The type of address being returned - usually
152 <span class="type">PF_INET</span>
153 or
154 <span class="type">PF_INET6</span>.
155
156 </p></dd>
157 <dt><span class="term"><code class="constant">h_length</code></span></dt>
158 <dd><p>
159 The length of the address in bytes.
160 </p></dd>
161 <dt><span class="term"><code class="constant">h_addr_list</code></span></dt>
162 <dd><p>
163 A
164 <span class="type">NULL</span>
165 terminated array of network addresses for the host.
166 Host addresses are returned in network byte order.
167 </p></dd>
168 </dl></div>
169 <p>
170 </p>
171 <p>
172 <code class="function">lwres_getipnodebyname()</code>
173 looks up addresses of protocol family
174 <em class="parameter"><code>af</code></em>
175
176 for the hostname
177 <em class="parameter"><code>name</code></em>.
178
179 The
180 <em class="parameter"><code>flags</code></em>
181 parameter contains ORed flag bits to 
182 specify the types of addresses that are searched
183 for, and the types of addresses that are returned. 
184 The flag bits are:
185 </p>
186 <div class="variablelist"><dl>
187 <dt><span class="term"><code class="constant">AI_V4MAPPED</code></span></dt>
188 <dd><p>
189 This is used with an
190 <em class="parameter"><code>af</code></em>
191 of AF_INET6, and causes IPv4 addresses to be returned as IPv4-mapped
192 IPv6 addresses.
193 </p></dd>
194 <dt><span class="term"><code class="constant">AI_ALL</code></span></dt>
195 <dd><p>
196 This is used with an
197 <em class="parameter"><code>af</code></em>
198 of AF_INET6, and causes all known addresses (IPv6 and IPv4) to be returned.
199 If AI_V4MAPPED is also set, the IPv4 addresses are return as mapped
200 IPv6 addresses.
201 </p></dd>
202 <dt><span class="term"><code class="constant">AI_ADDRCONFIG</code></span></dt>
203 <dd><p>
204 Only return an IPv6 or IPv4 address if here is an active network
205 interface of that type.  This is not currently implemented
206 in the BIND 9 lightweight resolver, and the flag is ignored.
207 </p></dd>
208 <dt><span class="term"><code class="constant">AI_DEFAULT</code></span></dt>
209 <dd><p>
210 This default sets the
211 <code class="constant">AI_V4MAPPED</code>
212 and
213 <code class="constant">AI_ADDRCONFIG</code>
214 flag bits.
215 </p></dd>
216 </dl></div>
217 <p>
218 </p>
219 <p>
220 <code class="function">lwres_getipnodebyaddr()</code>
221 performs a reverse lookup
222 of address
223 <em class="parameter"><code>src</code></em>
224 which is
225 <em class="parameter"><code>len</code></em>
226 bytes long.
227 <em class="parameter"><code>af</code></em>
228 denotes the protocol family, typically
229 <span class="type">PF_INET</span>
230 or
231 <span class="type">PF_INET6</span>.
232
233 </p>
234 <p>
235 <code class="function">lwres_freehostent()</code>
236 releases all the memory associated with
237 the
238 <span class="type">struct hostent</span>
239 pointer
240 <em class="parameter"><code>he</code></em>.
241
242 Any memory allocated for the
243 <code class="constant">h_name</code>,
244
245 <code class="constant">h_addr_list</code>
246 and
247 <code class="constant">h_aliases</code>
248 is freed, as is the memory for the
249 <span class="type">hostent</span>
250 structure itself.
251 </p>
252 </div>
253 <div class="refsect1" lang="en">
254 <a name="id2549832"></a><h2>RETURN VALUES</h2>
255 <p>
256 If an error occurs,
257 <code class="function">lwres_getipnodebyname()</code>
258 and
259 <code class="function">lwres_getipnodebyaddr()</code>
260 set
261 <em class="parameter"><code>*error_num</code></em>
262 to an appropriate error code and the function returns a
263 <span class="type">NULL</span>
264 pointer.
265 The error codes and their meanings are defined in
266 <code class="filename">&lt;lwres/netdb.h&gt;</code>:
267 </p>
268 <div class="variablelist"><dl>
269 <dt><span class="term"><code class="constant">HOST_NOT_FOUND</code></span></dt>
270 <dd><p>
271 No such host is known.
272 </p></dd>
273 <dt><span class="term"><code class="constant">NO_ADDRESS</code></span></dt>
274 <dd><p>
275 The server recognised the request and the name but no address is
276 available.  Another type of request to the name server for the
277 domain might return an answer.
278 </p></dd>
279 <dt><span class="term"><code class="constant">TRY_AGAIN</code></span></dt>
280 <dd><p>
281 A temporary and possibly transient error occurred, such as a
282 failure of a server to respond.  The request may succeed if
283 retried.
284 </p></dd>
285 <dt><span class="term"><code class="constant">NO_RECOVERY</code></span></dt>
286 <dd><p>
287 An unexpected failure occurred, and retrying the request
288 is pointless.
289 </p></dd>
290 </dl></div>
291 <p>
292 </p>
293 <p>
294 <span class="citerefentry"><span class="refentrytitle">lwres_hstrerror</span>(3
295 )</span>
296 translates these error codes to suitable error messages.
297 </p>
298 </div>
299 <div class="refsect1" lang="en">
300 <a name="id2549923"></a><h2>SEE ALSO</h2>
301 <p>
302 <span class="citerefentry"><span class="refentrytitle">RFC2553</span></span>,
303
304 <span class="citerefentry"><span class="refentrytitle">lwres</span>(3)</span>,
305
306 <span class="citerefentry"><span class="refentrytitle">lwres_gethostent</span>(3)</span>,
307
308 <span class="citerefentry"><span class="refentrytitle">lwres_getaddrinfo</span>(3)</span>,
309
310 <span class="citerefentry"><span class="refentrytitle">lwres_getnameinfo</span>(3)</span>,
311
312 <span class="citerefentry"><span class="refentrytitle">lwres_hstrerror</span>(3)</span>.
313 </p>
314 </div>
315 </div></body>
316 </html>