2 - Copyright (C) 2004, 2005, 2007, 2014, 2015 Internet Systems Consortium, Inc. ("ISC")
3 - Copyright (C) 2000, 2001 Internet Software Consortium.
5 - Permission to use, copy, modify, and/or 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.
19 <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
20 <title>lwres_gabn</title>
21 <meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
23 <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="refentry">
24 <a name="id-1"></a><div class="titlepage"></div>
25 <div class="refnamediv">
27 <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>
29 <div class="refsynopsisdiv">
31 <div class="funcsynopsis">
32 <pre class="funcsynopsisinfo">#include <lwres/lwres.h></pre>
33 <table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;">
35 <td><code class="funcdef">
37 <b class="fsfunc">lwres_gabnrequest_render</b>(</code></td>
38 <td>lwres_context_t *<var class="pdparam">ctx</var>, </td>
42 <td>lwres_gabnrequest_t *<var class="pdparam">req</var>, </td>
46 <td>lwres_lwpacket_t *<var class="pdparam">pkt</var>, </td>
50 <td>lwres_buffer_t *<var class="pdparam">b</var><code>)</code>;</td>
53 <div class="funcprototype-spacer"> </div>
54 <table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;">
56 <td><code class="funcdef">
58 <b class="fsfunc">lwres_gabnresponse_render</b>(</code></td>
59 <td>lwres_context_t *<var class="pdparam">ctx</var>, </td>
63 <td>lwres_gabnresponse_t *<var class="pdparam">req</var>, </td>
67 <td>lwres_lwpacket_t *<var class="pdparam">pkt</var>, </td>
71 <td>lwres_buffer_t *<var class="pdparam">b</var><code>)</code>;</td>
74 <div class="funcprototype-spacer"> </div>
75 <table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;">
77 <td><code class="funcdef">
79 <b class="fsfunc">lwres_gabnrequest_parse</b>(</code></td>
80 <td>lwres_context_t *<var class="pdparam">ctx</var>, </td>
84 <td>lwres_buffer_t *<var class="pdparam">b</var>, </td>
88 <td>lwres_lwpacket_t *<var class="pdparam">pkt</var>, </td>
92 <td>lwres_gabnrequest_t **<var class="pdparam">structp</var><code>)</code>;</td>
95 <div class="funcprototype-spacer"> </div>
96 <table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;">
98 <td><code class="funcdef">
100 <b class="fsfunc">lwres_gabnresponse_parse</b>(</code></td>
101 <td>lwres_context_t *<var class="pdparam">ctx</var>, </td>
105 <td>lwres_buffer_t *<var class="pdparam">b</var>, </td>
109 <td>lwres_lwpacket_t *<var class="pdparam">pkt</var>, </td>
113 <td>lwres_gabnresponse_t **<var class="pdparam">structp</var><code>)</code>;</td>
116 <div class="funcprototype-spacer"> </div>
117 <table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;">
119 <td><code class="funcdef">
121 <b class="fsfunc">lwres_gabnresponse_free</b>(</code></td>
122 <td>lwres_context_t *<var class="pdparam">ctx</var>, </td>
126 <td>lwres_gabnresponse_t **<var class="pdparam">structp</var><code>)</code>;</td>
129 <div class="funcprototype-spacer"> </div>
130 <table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;">
132 <td><code class="funcdef">
134 <b class="fsfunc">lwres_gabnrequest_free</b>(</code></td>
135 <td>lwres_context_t *<var class="pdparam">ctx</var>, </td>
139 <td>lwres_gabnrequest_t **<var class="pdparam">structp</var><code>)</code>;</td>
142 <div class="funcprototype-spacer"> </div>
145 <div class="refsection">
146 <a name="id-1.7"></a><h2>DESCRIPTION</h2>
148 These are low-level routines for creating and parsing
149 lightweight resolver name-to-address lookup request and
153 There are four main functions for the getaddrbyname opcode.
154 One render function converts a getaddrbyname request structure —
155 <span class="type">lwres_gabnrequest_t</span> —
156 to the lightweight resolver's canonical format.
157 It is complemented by a parse function that converts a packet in this
158 canonical format to a getaddrbyname request structure.
159 Another render function converts the getaddrbyname response structure
160 — <span class="type">lwres_gabnresponse_t</span> —
161 to the canonical format.
162 This is complemented by a parse function which converts a packet in
163 canonical format to a getaddrbyname response structure.
166 These structures are defined in
167 <code class="filename"><lwres/lwres.h></code>.
168 They are shown below.
170 <pre class="programlisting">
171 #define LWRES_OPCODE_GETADDRSBYNAME 0x00010001U
175 <pre class="programlisting">
176 typedef struct lwres_addr lwres_addr_t;
177 typedef LWRES_LIST(lwres_addr_t) lwres_addrlist_t;
181 <pre class="programlisting">
183 lwres_uint32_t flags;
184 lwres_uint32_t addrtypes;
185 lwres_uint16_t namelen;
187 } lwres_gabnrequest_t;
191 <pre class="programlisting">
193 lwres_uint32_t flags;
194 lwres_uint16_t naliases;
195 lwres_uint16_t naddrs;
198 lwres_uint16_t realnamelen;
199 lwres_uint16_t *aliaslen;
200 lwres_addrlist_t addrs;
203 } lwres_gabnresponse_t;
207 <p><code class="function">lwres_gabnrequest_render()</code>
208 uses resolver context <em class="parameter"><code>ctx</code></em> to convert
209 getaddrbyname request structure <em class="parameter"><code>req</code></em> to
210 canonical format. The packet header structure
211 <em class="parameter"><code>pkt</code></em> is initialised and transferred to
212 buffer <em class="parameter"><code>b</code></em>.
214 The contents of <em class="parameter"><code>*req</code></em> are then appended to
215 the buffer in canonical format.
216 <code class="function">lwres_gabnresponse_render()</code> performs the
217 same task, except it converts a getaddrbyname response structure
218 <span class="type">lwres_gabnresponse_t</span> to the lightweight resolver's
221 <p><code class="function">lwres_gabnrequest_parse()</code>
222 uses context <em class="parameter"><code>ctx</code></em> to convert the contents
223 of packet <em class="parameter"><code>pkt</code></em> to a
224 <span class="type">lwres_gabnrequest_t</span> structure. Buffer
225 <em class="parameter"><code>b</code></em> provides space to be used for storing
226 this structure. When the function succeeds, the resulting
227 <span class="type">lwres_gabnrequest_t</span> is made available through
228 <em class="parameter"><code>*structp</code></em>.
230 <code class="function">lwres_gabnresponse_parse()</code> offers the same
231 semantics as <code class="function">lwres_gabnrequest_parse()</code>
232 except it yields a <span class="type">lwres_gabnresponse_t</span> structure.
234 <p><code class="function">lwres_gabnresponse_free()</code>
235 and <code class="function">lwres_gabnrequest_free()</code> release the
236 memory in resolver context <em class="parameter"><code>ctx</code></em> that was
237 allocated to the <span class="type">lwres_gabnresponse_t</span> or
238 <span class="type">lwres_gabnrequest_t</span> structures referenced via
239 <em class="parameter"><code>structp</code></em>.
241 Any memory associated with ancillary buffers and strings for
242 those structures is also discarded.
245 <div class="refsection">
246 <a name="id-1.8"></a><h2>RETURN VALUES</h2>
248 The getaddrbyname opcode functions
249 <code class="function">lwres_gabnrequest_render()</code>,
250 <code class="function">lwres_gabnresponse_render()</code>
251 <code class="function">lwres_gabnrequest_parse()</code>
253 <code class="function">lwres_gabnresponse_parse()</code>
255 <span class="errorcode">LWRES_R_SUCCESS</span>
258 <span class="errorcode">LWRES_R_NOMEMORY</span>
259 if memory allocation fails.
260 <span class="errorcode">LWRES_R_UNEXPECTEDEND</span>
261 is returned if the available space in the buffer
262 <em class="parameter"><code>b</code></em>
263 is too small to accommodate the packet header or the
264 <span class="type">lwres_gabnrequest_t</span>
266 <span class="type">lwres_gabnresponse_t</span>
268 <code class="function">lwres_gabnrequest_parse()</code>
270 <code class="function">lwres_gabnresponse_parse()</code>
272 <span class="errorcode">LWRES_R_UNEXPECTEDEND</span>
273 if the buffer is not empty after decoding the received packet.
274 These functions will return
275 <span class="errorcode">LWRES_R_FAILURE</span>
277 <code class="varname">pktflags</code>
278 in the packet header structure
279 <span class="type">lwres_lwpacket_t</span>
280 indicate that the packet is not a response to an earlier query.
283 <div class="refsection">
284 <a name="id-1.9"></a><h2>SEE ALSO</h2>
285 <p><span class="citerefentry"><span class="refentrytitle">lwres_packet</span>(3)</span>