2 - Copyright (C) 2004, 2005 Internet Systems Consortium, Inc. ("ISC")
3 - Copyright (C) 2000, 2001 Internet Software Consortium.
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.
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.
17 <!-- $Id: lwres_gabn.html,v 1.6.2.1.4.11 2006/06/29 13:02:31 marka Exp $ -->
20 <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
21 <title>lwres_gabn</title>
22 <meta name="generator" content="DocBook XSL Stylesheets V1.70.1">
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">
28 <p>lwres_gabnrequest_render, lwres_gabnresponse_render, lwres_gabnrequest_parse, lwres_gabnresponse_parse, lwres_gabnresponse_free, lwres_gabnrequest_free — lightweight resolver getaddrbyname message handling</p>
30 <div class="refsynopsisdiv">
32 <div class="funcsynopsis">
33 <pre class="funcsynopsisinfo">#include <lwres/lwres.h></pre>
34 <table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" style="padding-bottom: 1em">
36 <td><code class="funcdef">
38 <b class="fsfunc">lwres_gabnrequest_render</b>(</code></td>
64 <table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" style="padding-bottom: 1em">
66 <td><code class="funcdef">
68 <b class="fsfunc">lwres_gabnresponse_render</b>(</code></td>
94 <table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" style="padding-bottom: 1em">
96 <td><code class="funcdef">
98 <b class="fsfunc">lwres_gabnrequest_parse</b>(</code></td>
124 <table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" style="padding-bottom: 1em">
126 <td><code class="funcdef">
128 <b class="fsfunc">lwres_gabnresponse_parse</b>(</code></td>
154 <table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" style="padding-bottom: 1em">
156 <td><code class="funcdef">
158 <b class="fsfunc">lwres_gabnresponse_free</b>(</code></td>
174 <table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0">
176 <td><code class="funcdef">
178 <b class="fsfunc">lwres_gabnrequest_free</b>(</code></td>
196 <div class="refsect1" lang="en">
197 <a name="id2549528"></a><h2>DESCRIPTION</h2>
199 These are low-level routines for creating and parsing
200 lightweight resolver name-to-address lookup request and
204 There are four main functions for the getaddrbyname opcode.
205 One render function converts a getaddrbyname request structure —
206 <span class="type">lwres_gabnrequest_t</span> —
207 to the lighweight resolver's canonical format.
208 It is complemented by a parse function that converts a packet in this
209 canonical format to a getaddrbyname request structure.
210 Another render function converts the getaddrbyname response structure —
211 <span class="type">lwres_gabnresponse_t</span> —
212 to the canonical format.
213 This is complemented by a parse function which converts a packet in
214 canonical format to a getaddrbyname response structure.
217 These structures are defined in
218 <code class="filename"><lwres/lwres.h></code>.
219 They are shown below.
221 <pre class="programlisting">
222 #define LWRES_OPCODE_GETADDRSBYNAME 0x00010001U
224 typedef struct lwres_addr lwres_addr_t;
225 typedef LWRES_LIST(lwres_addr_t) lwres_addrlist_t;
228 lwres_uint32_t flags;
229 lwres_uint32_t addrtypes;
230 lwres_uint16_t namelen;
232 } lwres_gabnrequest_t;
235 lwres_uint32_t flags;
236 lwres_uint16_t naliases;
237 lwres_uint16_t naddrs;
240 lwres_uint16_t realnamelen;
241 lwres_uint16_t *aliaslen;
242 lwres_addrlist_t addrs;
245 } lwres_gabnresponse_t;
250 <code class="function">lwres_gabnrequest_render()</code>
251 uses resolver context
252 <em class="parameter"><code>ctx</code></em>
253 to convert getaddrbyname request structure
254 <em class="parameter"><code>req</code></em>
256 The packet header structure
257 <em class="parameter"><code>pkt</code></em>
258 is initialised and transferred to
260 <em class="parameter"><code>b</code></em>.
263 <em class="parameter"><code>*req</code></em>
264 are then appended to the buffer in canonical format.
265 <code class="function">lwres_gabnresponse_render()</code>
266 performs the same task, except it converts a getaddrbyname response structure
267 <span class="type">lwres_gabnresponse_t</span>
268 to the lightweight resolver's canonical format.
271 <code class="function">lwres_gabnrequest_parse()</code>
273 <em class="parameter"><code>ctx</code></em>
274 to convert the contents of packet
275 <em class="parameter"><code>pkt</code></em>
277 <span class="type">lwres_gabnrequest_t</span>
280 <em class="parameter"><code>b</code></em>
281 provides space to be used for storing this structure.
282 When the function succeeds, the resulting
283 <span class="type">lwres_gabnrequest_t</span>
284 is made available through
285 <em class="parameter"><code>*structp</code></em>.
287 <code class="function">lwres_gabnresponse_parse()</code>
288 offers the same semantics as
289 <code class="function">lwres_gabnrequest_parse()</code>
291 <span class="type">lwres_gabnresponse_t</span>
295 <code class="function">lwres_gabnresponse_free()</code>
297 <code class="function">lwres_gabnrequest_free()</code>
298 release the memory in resolver context
299 <em class="parameter"><code>ctx</code></em>
300 that was allocated to the
301 <span class="type">lwres_gabnresponse_t</span>
303 <span class="type">lwres_gabnrequest_t</span>
304 structures referenced via
305 <em class="parameter"><code>structp</code></em>.
307 Any memory associated with ancillary buffers and strings for those
308 structures is also discarded.
311 <div class="refsect1" lang="en">
312 <a name="id2549720"></a><h2>RETURN VALUES</h2>
314 The getaddrbyname opcode functions
315 <code class="function">lwres_gabnrequest_render()</code>,
316 <code class="function">lwres_gabnresponse_render()</code>
317 <code class="function">lwres_gabnrequest_parse()</code>
319 <code class="function">lwres_gabnresponse_parse()</code>
321 <span class="errorcode">LWRES_R_SUCCESS</span>
324 <span class="errorcode">LWRES_R_NOMEMORY</span>
325 if memory allocation fails.
326 <span class="errorcode">LWRES_R_UNEXPECTEDEND</span>
327 is returned if the available space in the buffer
328 <em class="parameter"><code>b</code></em>
329 is too small to accommodate the packet header or the
330 <span class="type">lwres_gabnrequest_t</span>
332 <span class="type">lwres_gabnresponse_t</span>
334 <code class="function">lwres_gabnrequest_parse()</code>
336 <code class="function">lwres_gabnresponse_parse()</code>
338 <span class="errorcode">LWRES_R_UNEXPECTEDEND</span>
339 if the buffer is not empty after decoding the received packet.
340 These functions will return
341 <span class="errorcode">LWRES_R_FAILURE</span>
343 <em class="structfield"><code>pktflags</code></em>
344 in the packet header structure
345 <span class="type">lwres_lwpacket_t</span>
346 indicate that the packet is not a response to an earlier query.
349 <div class="refsect1" lang="en">
350 <a name="id2549853"></a><h2>SEE ALSO</h2>
352 <span class="citerefentry"><span class="refentrytitle">lwres_packet</span>(3