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.9 2005/10/13 02:33:56 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.69.1">
23 </head>
24 <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="refentry" lang="en">
25 <a name="id2463721"></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>
56 <code>)</code>;</td>
57 </tr>
58 </table>
59 <table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" style="padding-bottom: 1em">
60 <tr>
61 <td><code class="funcdef">
62 struct hostent *
63 <b class="fsfunc">lwres_getipnodebyaddr</b>(</code></td>
64 <td> </td>
65 <td>, </td>
66 </tr>
67 <tr>
68 <td> </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>
81 <code>)</code>;</td>
82 </tr>
83 </table>
84 <table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0"><tr>
85 <td><code class="funcdef">
86 void
87 <b class="fsfunc">lwres_freehostent</b>(</code></td>
88 <td> </td>
89 <td>
90 <code>)</code>;</td>
91 </tr></table>
92 </div>
93 </div>
94 <div class="refsect1" lang="en">
95 <a name="id2525896"></a><h2>DESCRIPTION</h2>
96 <p>
97 These functions perform thread safe, protocol independent
98 nodename-to-address and address-to-nodename 
99 translation as defined in RFC2553.
100 </p>
101 <p>
102 They use a
103 <span class="type">struct hostent</span>
104 which is defined in
105 <code class="filename">namedb.h</code>:
106 </p>
107 <pre class="programlisting">
108 struct  hostent {
109         char    *h_name;        /* official name of host */
110         char    **h_aliases;    /* alias list */
111         int     h_addrtype;     /* host address type */
112         int     h_length;       /* length of address */
113         char    **h_addr_list;  /* list of addresses from name server */
114 };
115 #define h_addr  h_addr_list[0]  /* address, for backward compatibility */
116 </pre>
117 <p>
118 </p>
119 <p>
120 The members of this structure are:
121 </p>
122 <div class="variablelist"><dl>
123 <dt><span class="term"><code class="constant">h_name</code></span></dt>
124 <dd><p>
125 The official (canonical) name of the host.
126 </p></dd>
127 <dt><span class="term"><code class="constant">h_aliases</code></span></dt>
128 <dd><p>
129 A NULL-terminated array of alternate names (nicknames) for the host.
130 </p></dd>
131 <dt><span class="term"><code class="constant">h_addrtype</code></span></dt>
132 <dd><p>
133 The type of address being returned - usually
134 <span class="type">PF_INET</span>
135 or
136 <span class="type">PF_INET6</span>.
137
138 </p></dd>
139 <dt><span class="term"><code class="constant">h_length</code></span></dt>
140 <dd><p>
141 The length of the address in bytes.
142 </p></dd>
143 <dt><span class="term"><code class="constant">h_addr_list</code></span></dt>
144 <dd><p>
145 A
146 <span class="type">NULL</span>
147 terminated array of network addresses for the host.
148 Host addresses are returned in network byte order.
149 </p></dd>
150 </dl></div>
151 <p>
152 </p>
153 <p>
154 <code class="function">lwres_getipnodebyname()</code>
155 looks up addresses of protocol family
156 <em class="parameter"><code>af</code></em>
157
158 for the hostname
159 <em class="parameter"><code>name</code></em>.
160
161 The
162 <em class="parameter"><code>flags</code></em>
163 parameter contains ORed flag bits to 
164 specify the types of addresses that are searched
165 for, and the types of addresses that are returned. 
166 The flag bits are:
167 </p>
168 <div class="variablelist"><dl>
169 <dt><span class="term"><code class="constant">AI_V4MAPPED</code></span></dt>
170 <dd><p>
171 This is used with an
172 <em class="parameter"><code>af</code></em>
173 of AF_INET6, and causes IPv4 addresses to be returned as IPv4-mapped
174 IPv6 addresses.
175 </p></dd>
176 <dt><span class="term"><code class="constant">AI_ALL</code></span></dt>
177 <dd><p>
178 This is used with an
179 <em class="parameter"><code>af</code></em>
180 of AF_INET6, and causes all known addresses (IPv6 and IPv4) to be returned.
181 If AI_V4MAPPED is also set, the IPv4 addresses are return as mapped
182 IPv6 addresses.
183 </p></dd>
184 <dt><span class="term"><code class="constant">AI_ADDRCONFIG</code></span></dt>
185 <dd><p>
186 Only return an IPv6 or IPv4 address if here is an active network
187 interface of that type.  This is not currently implemented
188 in the BIND 9 lightweight resolver, and the flag is ignored.
189 </p></dd>
190 <dt><span class="term"><code class="constant">AI_DEFAULT</code></span></dt>
191 <dd><p>
192 This default sets the
193 <code class="constant">AI_V4MAPPED</code>
194 and
195 <code class="constant">AI_ADDRCONFIG</code>
196 flag bits.
197 </p></dd>
198 </dl></div>
199 <p>
200 </p>
201 <p>
202 <code class="function">lwres_getipnodebyaddr()</code>
203 performs a reverse lookup
204 of address
205 <em class="parameter"><code>src</code></em>
206 which is
207 <em class="parameter"><code>len</code></em>
208 bytes long.
209 <em class="parameter"><code>af</code></em>
210 denotes the protocol family, typically
211 <span class="type">PF_INET</span>
212 or
213 <span class="type">PF_INET6</span>.
214
215 </p>
216 <p>
217 <code class="function">lwres_freehostent()</code>
218 releases all the memory associated with
219 the
220 <span class="type">struct hostent</span>
221 pointer
222 <em class="parameter"><code>he</code></em>.
223
224 Any memory allocated for the
225 <code class="constant">h_name</code>,
226
227 <code class="constant">h_addr_list</code>
228 and
229 <code class="constant">h_aliases</code>
230 is freed, as is the memory for the
231 <span class="type">hostent</span>
232 structure itself.
233 </p>
234 </div>
235 <div class="refsect1" lang="en">
236 <a name="id2526131"></a><h2>RETURN VALUES</h2>
237 <p>
238 If an error occurs,
239 <code class="function">lwres_getipnodebyname()</code>
240 and
241 <code class="function">lwres_getipnodebyaddr()</code>
242 set
243 <em class="parameter"><code>*error_num</code></em>
244 to an appropriate error code and the function returns a
245 <span class="type">NULL</span>
246 pointer.
247 The error codes and their meanings are defined in
248 <code class="filename">&lt;lwres/netdb.h&gt;</code>:
249 </p>
250 <div class="variablelist"><dl>
251 <dt><span class="term"><code class="constant">HOST_NOT_FOUND</code></span></dt>
252 <dd><p>
253 No such host is known.
254 </p></dd>
255 <dt><span class="term"><code class="constant">NO_ADDRESS</code></span></dt>
256 <dd><p>
257 The server recognised the request and the name but no address is
258 available.  Another type of request to the name server for the
259 domain might return an answer.
260 </p></dd>
261 <dt><span class="term"><code class="constant">TRY_AGAIN</code></span></dt>
262 <dd><p>
263 A temporary and possibly transient error occurred, such as a
264 failure of a server to respond.  The request may succeed if
265 retried.
266 </p></dd>
267 <dt><span class="term"><code class="constant">NO_RECOVERY</code></span></dt>
268 <dd><p>
269 An unexpected failure occurred, and retrying the request
270 is pointless.
271 </p></dd>
272 </dl></div>
273 <p>
274 </p>
275 <p>
276 <span class="citerefentry"><span class="refentrytitle">lwres_hstrerror</span>(3
277 )</span>
278 translates these error codes to suitable error messages.
279 </p>
280 </div>
281 <div class="refsect1" lang="en">
282 <a name="id2526290"></a><h2>SEE ALSO</h2>
283 <p>
284 <span class="citerefentry"><span class="refentrytitle">RFC2553</span></span>,
285
286 <span class="citerefentry"><span class="refentrytitle">lwres</span>(3)</span>,
287
288 <span class="citerefentry"><span class="refentrytitle">lwres_gethostent</span>(3)</span>,
289
290 <span class="citerefentry"><span class="refentrytitle">lwres_getaddrinfo</span>(3)</span>,
291
292 <span class="citerefentry"><span class="refentrytitle">lwres_getnameinfo</span>(3)</span>,
293
294 <span class="citerefentry"><span class="refentrytitle">lwres_hstrerror</span>(3)</span>.
295 </p>
296 </div>
297 </div></body>
298 </html>