Merge from vendor branch BZIP:
[dragonfly.git] / contrib / bind-9.3 / lib / lwres / man / lwres_resutil.html
1 <!--
2  - Copyright (C) 2004, 2005 Internet Systems Consortium, Inc. ("ISC")
3  - Copyright (C) 2000, 2001 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_resutil.html,v 1.8.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_resutil</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_string_parse, lwres_addr_parse, lwres_getaddrsbyname, lwres_getnamebyaddr &#8212; lightweight resolver utility functions</p>
29 </div>
30 <div class="refsynopsisdiv">
31 <h2>Synopsis</h2>
32 <div class="funcsynopsis">
33 <pre class="funcsynopsisinfo">#include &lt;lwres/lwres.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 lwres_result_t
38 <b class="fsfunc">lwres_string_parse</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 lwres_result_t
63 <b class="fsfunc">lwres_addr_parse</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>
76 <code>)</code>;</td>
77 </tr>
78 </table>
79 <table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" style="padding-bottom: 1em">
80 <tr>
81 <td><code class="funcdef">
82 lwres_result_t
83 <b class="fsfunc">lwres_getaddrsbyname</b>(</code></td>
84 <td> </td>
85 <td>, </td>
86 </tr>
87 <tr>
88 <td> </td>
89 <td> </td>
90 <td>, </td>
91 </tr>
92 <tr>
93 <td> </td>
94 <td> </td>
95 <td>, </td>
96 </tr>
97 <tr>
98 <td> </td>
99 <td> </td>
100 <td>, </td>
101 </tr>
102 <tr>
103 <td> </td>
104 <td> </td>
105 <td>
106 <code>)</code>;</td>
107 </tr>
108 </table>
109 <table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0">
110 <tr>
111 <td><code class="funcdef">
112 lwres_result_t
113 <b class="fsfunc">lwres_getnamebyaddr</b>(</code></td>
114 <td> </td>
115 <td>, </td>
116 </tr>
117 <tr>
118 <td> </td>
119 <td> </td>
120 <td>, </td>
121 </tr>
122 <tr>
123 <td> </td>
124 <td> </td>
125 <td>, </td>
126 </tr>
127 <tr>
128 <td> </td>
129 <td> </td>
130 <td>, </td>
131 </tr>
132 <tr>
133 <td> </td>
134 <td> </td>
135 <td>, </td>
136 </tr>
137 <tr>
138 <td> </td>
139 <td> </td>
140 <td>
141 <code>)</code>;</td>
142 </tr>
143 </table>
144 </div>
145 </div>
146 <div class="refsect1" lang="en">
147 <a name="id2549485"></a><h2>DESCRIPTION</h2>
148 <p>
149 <code class="function">lwres_string_parse()</code> retrieves a DNS-encoded
150 string starting the current pointer of lightweight resolver buffer
151 <em class="parameter"><code>b</code></em>: i.e.  <code class="constant">b-&gt;current</code>.
152 When the function returns, the address of the first byte of the
153 encoded string is returned via <em class="parameter"><code>*c</code></em> and the
154 length of that string is given by <em class="parameter"><code>*len</code></em>.  The
155 buffer's current pointer is advanced to point at the character
156 following the string length, the encoded string, and the trailing
157 <span class="type">NULL</span> character.
158 </p>
159 <p>
160 <code class="function">lwres_addr_parse()</code> extracts an address from the
161 buffer <em class="parameter"><code>b</code></em>.  The buffer's current pointer
162 <code class="constant">b-&gt;current</code> is presumed to point at an encoded
163 address: the address preceded by a 32-bit protocol family identifier
164 and a 16-bit length field.  The encoded address is copied to
165 <code class="constant">addr-&gt;address</code> and
166 <code class="constant">addr-&gt;length</code> indicates the size in bytes of
167 the address that was copied.  <code class="constant">b-&gt;current</code> is
168 advanced to point at the next byte of available data in the buffer
169 following the encoded address.
170 </p>
171 <p>
172 <code class="function">lwres_getaddrsbyname()</code>
173 and
174 <code class="function">lwres_getnamebyaddr()</code>
175 use the
176 <span class="type">lwres_gnbaresponse_t</span>
177 structure defined below:
178 </p>
179 <pre class="programlisting">
180 typedef struct {
181         lwres_uint32_t          flags;
182         lwres_uint16_t          naliases;
183         lwres_uint16_t          naddrs;
184         char                   *realname;
185         char                  **aliases;
186         lwres_uint16_t          realnamelen;
187         lwres_uint16_t         *aliaslen;
188         lwres_addrlist_t        addrs;
189         void                   *base;
190         size_t                  baselen;
191 } lwres_gabnresponse_t;
192 </pre>
193 <p>
194 The contents of this structure are not manipulated directly but
195 they are controlled through the
196 <span class="citerefentry"><span class="refentrytitle">lwres_gabn</span>(3
197 )</span>
198 functions.
199 </p>
200 <p>
201 The lightweight resolver uses
202 <code class="function">lwres_getaddrsbyname()</code> to perform foward lookups.
203 Hostname <em class="parameter"><code>name</code></em> is looked up using the resolver
204 context <em class="parameter"><code>ctx</code></em> for memory allocation.
205 <em class="parameter"><code>addrtypes</code></em> is a bitmask indicating which type of
206 addresses are to be looked up.  Current values for this bitmask are
207 <span class="type">LWRES_ADDRTYPE_V4</span> for IPv4 addresses and
208 <span class="type">LWRES_ADDRTYPE_V6</span> for IPv6 addresses.  Results of the
209 lookup are returned in <em class="parameter"><code>*structp</code></em>.
210 </p>
211 <p>
212 <code class="function">lwres_getnamebyaddr()</code> performs reverse lookups.
213 Resolver context <em class="parameter"><code>ctx</code></em> is used for memory
214 allocation.  The address type is indicated by
215 <em class="parameter"><code>addrtype</code></em>: <span class="type">LWRES_ADDRTYPE_V4</span> or
216 <span class="type">LWRES_ADDRTYPE_V6</span>.  The address to be looked up is given
217 by <em class="parameter"><code>addr</code></em> and its length is
218 <em class="parameter"><code>addrlen</code></em> bytes.  The result of the function call
219 is made available through <em class="parameter"><code>*structp</code></em>.
220 </p>
221 </div>
222 <div class="refsect1" lang="en">
223 <a name="id2549693"></a><h2>RETURN VALUES</h2>
224 <p>
225 Successful calls to
226 <code class="function">lwres_string_parse()</code>
227 and
228 <code class="function">lwres_addr_parse()</code>
229 return
230 <span class="errorcode">LWRES_R_SUCCESS.</span>
231 Both functions return
232 <span class="errorcode">LWRES_R_FAILURE</span>
233 if the buffer is corrupt or
234 <span class="errorcode">LWRES_R_UNEXPECTEDEND</span>
235 if the buffer has less space than expected for the components of the
236 encoded string or address.
237 </p>
238 <p>
239 <code class="function">lwres_getaddrsbyname()</code>
240 returns
241 <span class="errorcode">LWRES_R_SUCCESS</span>
242 on success and it returns
243 <span class="errorcode">LWRES_R_NOTFOUND</span>
244 if the hostname
245 <em class="parameter"><code>name</code></em>
246 could not be found.
247 </p>
248 <p>
249 <span class="errorcode">LWRES_R_SUCCESS</span>
250 is returned by a successful call to
251 <code class="function">lwres_getnamebyaddr()</code>.
252 </p>
253 <p>
254 Both
255 <code class="function">lwres_getaddrsbyname()</code>
256 and
257 <code class="function">lwres_getnamebyaddr()</code>
258 return
259 <span class="errorcode">LWRES_R_NOMEMORY</span>
260 when memory allocation requests fail and
261 <span class="errorcode">LWRES_R_UNEXPECTEDEND</span>
262 if the buffers used for sending queries and receiving replies are too
263 small.
264 </p>
265 </div>
266 <div class="refsect1" lang="en">
267 <a name="id2549763"></a><h2>SEE ALSO</h2>
268 <p>
269 <span class="citerefentry"><span class="refentrytitle">lwres_buffer</span>(3)</span>,
270
271 <span class="citerefentry"><span class="refentrytitle">lwres_gabn</span>(3)</span>.
272 </p>
273 </div>
274 </div></body>
275 </html>