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_gnba</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_gnbarequest_render, lwres_gnbaresponse_render, lwres_gnbarequest_parse, lwres_gnbaresponse_parse, lwres_gnbaresponse_free, lwres_gnbarequest_free — lightweight resolver getnamebyaddress message handling</p>
29 <div class="refsynopsisdiv">
31 <div class="funcsynopsis">
32 <pre class="funcsynopsisinfo">
33 #include <lwres/lwres.h>
35 <table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;">
37 <td><code class="funcdef">
39 <b class="fsfunc">lwres_gnbarequest_render</b>
41 <td>lwres_context_t *<var class="pdparam">ctx</var>, </td>
45 <td>lwres_gnbarequest_t *<var class="pdparam">req</var>, </td>
49 <td>lwres_lwpacket_t *<var class="pdparam">pkt</var>, </td>
53 <td>lwres_buffer_t *<var class="pdparam">b</var><code>)</code>;</td>
56 <div class="funcprototype-spacer"> </div>
57 <table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;">
59 <td><code class="funcdef">
61 <b class="fsfunc">lwres_gnbaresponse_render</b>
63 <td>lwres_context_t *<var class="pdparam">ctx</var>, </td>
67 <td>lwres_gnbaresponse_t *<var class="pdparam">req</var>, </td>
71 <td>lwres_lwpacket_t *<var class="pdparam">pkt</var>, </td>
75 <td>lwres_buffer_t *<var class="pdparam">b</var><code>)</code>;</td>
78 <div class="funcprototype-spacer"> </div>
79 <table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;">
81 <td><code class="funcdef">
83 <b class="fsfunc">lwres_gnbarequest_parse</b>(</code></td>
84 <td>lwres_context_t *<var class="pdparam">ctx</var>, </td>
88 <td>lwres_buffer_t *<var class="pdparam">b</var>, </td>
92 <td>lwres_lwpacket_t *<var class="pdparam">pkt</var>, </td>
96 <td>lwres_gnbarequest_t **<var class="pdparam">structp</var><code>)</code>;</td>
99 <div class="funcprototype-spacer"> </div>
100 <table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;">
102 <td><code class="funcdef">
104 <b class="fsfunc">lwres_gnbaresponse_parse</b>(</code></td>
105 <td>lwres_context_t *<var class="pdparam">ctx</var>, </td>
109 <td>lwres_buffer_t *<var class="pdparam">b</var>, </td>
113 <td>lwres_lwpacket_t *<var class="pdparam">pkt</var>, </td>
117 <td>lwres_gnbaresponse_t **<var class="pdparam">structp</var><code>)</code>;</td>
120 <div class="funcprototype-spacer"> </div>
121 <table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;">
123 <td><code class="funcdef">
125 <b class="fsfunc">lwres_gnbaresponse_free</b>
127 <td>lwres_context_t *<var class="pdparam">ctx</var>, </td>
131 <td>lwres_gnbaresponse_t **<var class="pdparam">structp</var><code>)</code>;</td>
134 <div class="funcprototype-spacer"> </div>
135 <table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;">
137 <td><code class="funcdef">
139 <b class="fsfunc">lwres_gnbarequest_free</b>(</code></td>
140 <td>lwres_context_t *<var class="pdparam">ctx</var>, </td>
144 <td>lwres_gnbarequest_t **<var class="pdparam">structp</var><code>)</code>;</td>
147 <div class="funcprototype-spacer"> </div>
150 <div class="refsection">
151 <a name="id-1.7"></a><h2>DESCRIPTION</h2>
153 These are low-level routines for creating and parsing
154 lightweight resolver address-to-name lookup request and
158 There are four main functions for the getnamebyaddr opcode.
159 One render function converts a getnamebyaddr request structure —
160 <span class="type">lwres_gnbarequest_t</span> —
161 to the lightweight resolver's canonical format.
162 It is complemented by a parse function that converts a packet in this
163 canonical format to a getnamebyaddr request structure.
164 Another render function converts the getnamebyaddr response structure
166 <span class="type">lwres_gnbaresponse_t</span>
167 to the canonical format.
168 This is complemented by a parse function which converts a packet in
169 canonical format to a getnamebyaddr response structure.
172 These structures are defined in
173 <code class="filename">lwres/lwres.h</code>.
174 They are shown below.
176 <pre class="programlisting">
177 #define LWRES_OPCODE_GETNAMEBYADDR 0x00010002U
181 <pre class="programlisting">
183 lwres_uint32_t flags;
185 } lwres_gnbarequest_t;
189 <pre class="programlisting">
191 lwres_uint32_t flags;
192 lwres_uint16_t naliases;
195 lwres_uint16_t realnamelen;
196 lwres_uint16_t *aliaslen;
199 } lwres_gnbaresponse_t;
203 <p><code class="function">lwres_gnbarequest_render()</code>
204 uses resolver context <code class="varname">ctx</code> to convert
205 getnamebyaddr request structure <code class="varname">req</code> to
206 canonical format. The packet header structure
207 <code class="varname">pkt</code> is initialised and transferred to buffer
208 <code class="varname">b</code>. The contents of <code class="varname">*req</code>
209 are then appended to the buffer in canonical format.
210 <code class="function">lwres_gnbaresponse_render()</code> performs the
211 same task, except it converts a getnamebyaddr response structure
212 <span class="type">lwres_gnbaresponse_t</span> to the lightweight resolver's
215 <p><code class="function">lwres_gnbarequest_parse()</code>
216 uses context <code class="varname">ctx</code> to convert the contents of
217 packet <code class="varname">pkt</code> to a
218 <span class="type">lwres_gnbarequest_t</span> structure. Buffer
219 <code class="varname">b</code> provides space to be used for storing this
220 structure. When the function succeeds, the resulting
221 <span class="type">lwres_gnbarequest_t</span> is made available through
222 <code class="varname">*structp</code>.
223 <code class="function">lwres_gnbaresponse_parse()</code> offers the same
224 semantics as <code class="function">lwres_gnbarequest_parse()</code>
225 except it yields a <span class="type">lwres_gnbaresponse_t</span> structure.
227 <p><code class="function">lwres_gnbaresponse_free()</code>
228 and <code class="function">lwres_gnbarequest_free()</code> release the
229 memory in resolver context <code class="varname">ctx</code> that was
230 allocated to the <span class="type">lwres_gnbaresponse_t</span> or
231 <span class="type">lwres_gnbarequest_t</span> structures referenced via
232 <code class="varname">structp</code>. Any memory associated with
233 ancillary buffers and strings for those structures is also
237 <div class="refsection">
238 <a name="id-1.8"></a><h2>RETURN VALUES</h2>
240 The getnamebyaddr opcode functions
241 <code class="function">lwres_gnbarequest_render()</code>,
242 <code class="function">lwres_gnbaresponse_render()</code>
243 <code class="function">lwres_gnbarequest_parse()</code>
245 <code class="function">lwres_gnbaresponse_parse()</code>
247 <span class="errorcode">LWRES_R_SUCCESS</span>
250 <span class="errorcode">LWRES_R_NOMEMORY</span>
251 if memory allocation fails.
252 <span class="errorcode">LWRES_R_UNEXPECTEDEND</span>
253 is returned if the available space in the buffer
254 <code class="varname">b</code>
255 is too small to accommodate the packet header or the
256 <span class="type">lwres_gnbarequest_t</span>
258 <span class="type">lwres_gnbaresponse_t</span>
260 <code class="function">lwres_gnbarequest_parse()</code>
262 <code class="function">lwres_gnbaresponse_parse()</code>
264 <span class="errorcode">LWRES_R_UNEXPECTEDEND</span>
265 if the buffer is not empty after decoding the received packet.
266 These functions will return
267 <span class="errorcode">LWRES_R_FAILURE</span>
269 <code class="varname">pktflags</code>
270 in the packet header structure
271 <span class="type">lwres_lwpacket_t</span>
272 indicate that the packet is not a response to an earlier query.
275 <div class="refsection">
276 <a name="id-1.9"></a><h2>SEE ALSO</h2>
277 <p><span class="citerefentry"><span class="refentrytitle">lwres_packet</span>(3)</span>.