Import of bind-9.3.2-P1
[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.9 2005/10/13 02:33:58 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.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_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>
51 <code>)</code>;</td>
52 </tr>
53 </table>
54 <table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" style="padding-bottom: 1em">
55 <tr>
56 <td><code class="funcdef">
57 lwres_result_t
58 <b class="fsfunc">lwres_addr_parse</b>(</code></td>
59 <td> </td>
60 <td>, </td>
61 </tr>
62 <tr>
63 <td> </td>
64 <td> </td>
65 <td>
66 <code>)</code>;</td>
67 </tr>
68 </table>
69 <table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" style="padding-bottom: 1em">
70 <tr>
71 <td><code class="funcdef">
72 lwres_result_t
73 <b class="fsfunc">lwres_getaddrsbyname</b>(</code></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 lwres_result_t
98 <b class="fsfunc">lwres_getnamebyaddr</b>(</code></td>
99 <td> </td>
100 <td>, </td>
101 </tr>
102 <tr>
103 <td> </td>
104 <td> </td>
105 <td>, </td>
106 </tr>
107 <tr>
108 <td> </td>
109 <td> </td>
110 <td>, </td>
111 </tr>
112 <tr>
113 <td> </td>
114 <td> </td>
115 <td>, </td>
116 </tr>
117 <tr>
118 <td> </td>
119 <td> </td>
120 <td>
121 <code>)</code>;</td>
122 </tr>
123 </table>
124 </div>
125 </div>
126 <div class="refsect1" lang="en">
127 <a name="id2525921"></a><h2>DESCRIPTION</h2>
128 <p>
129 <code class="function">lwres_string_parse()</code> retrieves a DNS-encoded
130 string starting the current pointer of lightweight resolver buffer
131 <em class="parameter"><code>b</code></em>: i.e.  <code class="constant">b-&gt;current</code>.
132 When the function returns, the address of the first byte of the
133 encoded string is returned via <em class="parameter"><code>*c</code></em> and the
134 length of that string is given by <em class="parameter"><code>*len</code></em>.  The
135 buffer's current pointer is advanced to point at the character
136 following the string length, the encoded string, and the trailing
137 <span class="type">NULL</span> character.
138 </p>
139 <p>
140 <code class="function">lwres_addr_parse()</code> extracts an address from the
141 buffer <em class="parameter"><code>b</code></em>.  The buffer's current pointer
142 <code class="constant">b-&gt;current</code> is presumed to point at an encoded
143 address: the address preceded by a 32-bit protocol family identifier
144 and a 16-bit length field.  The encoded address is copied to
145 <code class="constant">addr-&gt;address</code> and
146 <code class="constant">addr-&gt;length</code> indicates the size in bytes of
147 the address that was copied.  <code class="constant">b-&gt;current</code> is
148 advanced to point at the next byte of available data in the buffer
149 following the encoded address.
150 </p>
151 <p>
152 <code class="function">lwres_getaddrsbyname()</code>
153 and
154 <code class="function">lwres_getnamebyaddr()</code>
155 use the
156 <span class="type">lwres_gnbaresponse_t</span>
157 structure defined below:
158 </p>
159 <pre class="programlisting">
160 typedef struct {
161         lwres_uint32_t          flags;
162         lwres_uint16_t          naliases;
163         lwres_uint16_t          naddrs;
164         char                   *realname;
165         char                  **aliases;
166         lwres_uint16_t          realnamelen;
167         lwres_uint16_t         *aliaslen;
168         lwres_addrlist_t        addrs;
169         void                   *base;
170         size_t                  baselen;
171 } lwres_gabnresponse_t;
172 </pre>
173 <p>
174 The contents of this structure are not manipulated directly but
175 they are controlled through the
176 <span class="citerefentry"><span class="refentrytitle">lwres_gabn</span>(3
177 )</span>
178 functions.
179 </p>
180 <p>
181 The lightweight resolver uses
182 <code class="function">lwres_getaddrsbyname()</code> to perform foward lookups.
183 Hostname <em class="parameter"><code>name</code></em> is looked up using the resolver
184 context <em class="parameter"><code>ctx</code></em> for memory allocation.
185 <em class="parameter"><code>addrtypes</code></em> is a bitmask indicating which type of
186 addresses are to be looked up.  Current values for this bitmask are
187 <span class="type">LWRES_ADDRTYPE_V4</span> for IPv4 addresses and
188 <span class="type">LWRES_ADDRTYPE_V6</span> for IPv6 addresses.  Results of the
189 lookup are returned in <em class="parameter"><code>*structp</code></em>.
190 </p>
191 <p>
192 <code class="function">lwres_getnamebyaddr()</code> performs reverse lookups.
193 Resolver context <em class="parameter"><code>ctx</code></em> is used for memory
194 allocation.  The address type is indicated by
195 <em class="parameter"><code>addrtype</code></em>: <span class="type">LWRES_ADDRTYPE_V4</span> or
196 <span class="type">LWRES_ADDRTYPE_V6</span>.  The address to be looked up is given
197 by <em class="parameter"><code>addr</code></em> and its length is
198 <em class="parameter"><code>addrlen</code></em> bytes.  The result of the function call
199 is made available through <em class="parameter"><code>*structp</code></em>.
200 </p>
201 </div>
202 <div class="refsect1" lang="en">
203 <a name="id2526060"></a><h2>RETURN VALUES</h2>
204 <p>
205 Successful calls to
206 <code class="function">lwres_string_parse()</code>
207 and
208 <code class="function">lwres_addr_parse()</code>
209 return
210 <span class="errorcode">LWRES_R_SUCCESS.</span>
211 Both functions return
212 <span class="errorcode">LWRES_R_FAILURE</span>
213 if the buffer is corrupt or
214 <span class="errorcode">LWRES_R_UNEXPECTEDEND</span>
215 if the buffer has less space than expected for the components of the
216 encoded string or address.
217 </p>
218 <p>
219 <code class="function">lwres_getaddrsbyname()</code>
220 returns
221 <span class="errorcode">LWRES_R_SUCCESS</span>
222 on success and it returns
223 <span class="errorcode">LWRES_R_NOTFOUND</span>
224 if the hostname
225 <em class="parameter"><code>name</code></em>
226 could not be found.
227 </p>
228 <p>
229 <span class="errorcode">LWRES_R_SUCCESS</span>
230 is returned by a successful call to
231 <code class="function">lwres_getnamebyaddr()</code>.
232 </p>
233 <p>
234 Both
235 <code class="function">lwres_getaddrsbyname()</code>
236 and
237 <code class="function">lwres_getnamebyaddr()</code>
238 return
239 <span class="errorcode">LWRES_R_NOMEMORY</span>
240 when memory allocation requests fail and
241 <span class="errorcode">LWRES_R_UNEXPECTEDEND</span>
242 if the buffers used for sending queries and receiving replies are too
243 small.
244 </p>
245 </div>
246 <div class="refsect1" lang="en">
247 <a name="id2526130"></a><h2>SEE ALSO</h2>
248 <p>
249 <span class="citerefentry"><span class="refentrytitle">lwres_buffer</span>(3)</span>,
250
251 <span class="citerefentry"><span class="refentrytitle">lwres_gabn</span>(3)</span>.
252 </p>
253 </div>
254 </div></body>
255 </html>