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_noop</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_nooprequest_render, lwres_noopresponse_render, lwres_nooprequest_parse, lwres_noopresponse_parse, lwres_noopresponse_free, lwres_nooprequest_free — lightweight resolver no-op message handling</p>
29 <div class="refsynopsisdiv">
31 <div class="funcsynopsis">
32 <pre class="funcsynopsisinfo">
33 #include <lwres/lwres.h></pre>
34 <table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;">
36 <td><code class="funcdef">
38 <b class="fsfunc">lwres_nooprequest_render</b>(</code></td>
39 <td>lwres_context_t *<var class="pdparam">ctx</var>, </td>
43 <td>lwres_nooprequest_t *<var class="pdparam">req</var>, </td>
47 <td>lwres_lwpacket_t *<var class="pdparam">pkt</var>, </td>
51 <td>lwres_buffer_t *<var class="pdparam">b</var><code>)</code>;</td>
54 <div class="funcprototype-spacer"> </div>
55 <table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;">
57 <td><code class="funcdef">
59 <b class="fsfunc">lwres_noopresponse_render</b>(</code></td>
60 <td>lwres_context_t *<var class="pdparam">ctx</var>, </td>
64 <td>lwres_noopresponse_t *<var class="pdparam">req</var>, </td>
68 <td>lwres_lwpacket_t *<var class="pdparam">pkt</var>, </td>
72 <td>lwres_buffer_t *<var class="pdparam">b</var><code>)</code>;</td>
75 <div class="funcprototype-spacer"> </div>
76 <table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;">
78 <td><code class="funcdef">
80 <b class="fsfunc">lwres_nooprequest_parse</b>(</code></td>
81 <td>lwres_context_t *<var class="pdparam">ctx</var>, </td>
85 <td>lwres_buffer_t *<var class="pdparam">b</var>, </td>
89 <td>lwres_lwpacket_t *<var class="pdparam">pkt</var>, </td>
93 <td>lwres_nooprequest_t **<var class="pdparam">structp</var><code>)</code>;</td>
96 <div class="funcprototype-spacer"> </div>
97 <table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;">
99 <td><code class="funcdef">
101 <b class="fsfunc">lwres_noopresponse_parse</b>(</code></td>
102 <td>lwres_context_t *<var class="pdparam">ctx</var>, </td>
106 <td>lwres_buffer_t *<var class="pdparam">b</var>, </td>
110 <td>lwres_lwpacket_t *<var class="pdparam">pkt</var>, </td>
114 <td>lwres_noopresponse_t **<var class="pdparam">structp</var><code>)</code>;</td>
117 <div class="funcprototype-spacer"> </div>
118 <table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;">
120 <td><code class="funcdef">
122 <b class="fsfunc">lwres_noopresponse_free</b>(</code></td>
123 <td>lwres_context_t *<var class="pdparam">ctx</var>, </td>
127 <td>lwres_noopresponse_t **<var class="pdparam">structp</var><code>)</code>;</td>
130 <div class="funcprototype-spacer"> </div>
131 <table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;">
133 <td><code class="funcdef">
135 <b class="fsfunc">lwres_nooprequest_free</b>(</code></td>
136 <td>lwres_context_t *<var class="pdparam">ctx</var>, </td>
140 <td>lwres_nooprequest_t **<var class="pdparam">structp</var><code>)</code>;</td>
143 <div class="funcprototype-spacer"> </div>
146 <div class="refsection">
147 <a name="id-1.7"></a><h2>DESCRIPTION</h2>
149 These are low-level routines for creating and parsing
150 lightweight resolver no-op request and response messages.
153 The no-op message is analogous to a <span class="command"><strong>ping</strong></span>
155 a packet is sent to the resolver daemon and is simply echoed back.
156 The opcode is intended to allow a client to determine if the server is
160 There are four main functions for the no-op opcode.
161 One render function converts a no-op request structure —
162 <span class="type">lwres_nooprequest_t</span> —
163 to the lightweight resolver's canonical format.
164 It is complemented by a parse function that converts a packet in this
165 canonical format to a no-op request structure.
166 Another render function converts the no-op response structure —
167 <span class="type">lwres_noopresponse_t</span>
168 to the canonical format.
169 This is complemented by a parse function which converts a packet in
170 canonical format to a no-op response structure.
173 These structures are defined in
174 <code class="filename">lwres/lwres.h</code>.
176 They are shown below.
178 <pre class="programlisting">
179 #define LWRES_OPCODE_NOOP 0x00000000U
183 <pre class="programlisting">
185 lwres_uint16_t datalength;
187 } lwres_nooprequest_t;
191 <pre class="programlisting">
193 lwres_uint16_t datalength;
195 } lwres_noopresponse_t;
200 Although the structures have different types, they are identical.
201 This is because the no-op opcode simply echos whatever data was sent:
202 the response is therefore identical to the request.
204 <p><code class="function">lwres_nooprequest_render()</code>
205 uses resolver context <em class="parameter"><code>ctx</code></em> to convert
206 no-op request structure <em class="parameter"><code>req</code></em> to canonical
207 format. The packet header structure <em class="parameter"><code>pkt</code></em>
208 is initialised and transferred to buffer
209 <em class="parameter"><code>b</code></em>. The contents of
210 <em class="parameter"><code>*req</code></em> are then appended to the buffer in
212 <code class="function">lwres_noopresponse_render()</code> performs the
213 same task, except it converts a no-op response structure
214 <span class="type">lwres_noopresponse_t</span> to the lightweight resolver's
217 <p><code class="function">lwres_nooprequest_parse()</code>
218 uses context <em class="parameter"><code>ctx</code></em> to convert the contents
219 of packet <em class="parameter"><code>pkt</code></em> to a
220 <span class="type">lwres_nooprequest_t</span> structure. Buffer
221 <em class="parameter"><code>b</code></em> provides space to be used for storing
222 this structure. When the function succeeds, the resulting
223 <span class="type">lwres_nooprequest_t</span> is made available through
224 <em class="parameter"><code>*structp</code></em>.
225 <code class="function">lwres_noopresponse_parse()</code> offers the same
226 semantics as <code class="function">lwres_nooprequest_parse()</code>
227 except it yields a <span class="type">lwres_noopresponse_t</span> structure.
229 <p><code class="function">lwres_noopresponse_free()</code>
230 and <code class="function">lwres_nooprequest_free()</code> release the
231 memory in resolver context <em class="parameter"><code>ctx</code></em> that was
232 allocated to the <span class="type">lwres_noopresponse_t</span> or
233 <span class="type">lwres_nooprequest_t</span> structures referenced via
234 <em class="parameter"><code>structp</code></em>.
237 <div class="refsection">
238 <a name="id-1.8"></a><h2>RETURN VALUES</h2>
240 The no-op opcode functions
241 <code class="function">lwres_nooprequest_render()</code>,
243 <code class="function">lwres_noopresponse_render()</code>
244 <code class="function">lwres_nooprequest_parse()</code>
246 <code class="function">lwres_noopresponse_parse()</code>
248 <span class="errorcode">LWRES_R_SUCCESS</span>
251 <span class="errorcode">LWRES_R_NOMEMORY</span>
252 if memory allocation fails.
253 <span class="errorcode">LWRES_R_UNEXPECTEDEND</span>
254 is returned if the available space in the buffer
255 <em class="parameter"><code>b</code></em>
256 is too small to accommodate the packet header or the
257 <span class="type">lwres_nooprequest_t</span>
259 <span class="type">lwres_noopresponse_t</span>
261 <code class="function">lwres_nooprequest_parse()</code>
263 <code class="function">lwres_noopresponse_parse()</code>
265 <span class="errorcode">LWRES_R_UNEXPECTEDEND</span>
266 if the buffer is not empty after decoding the received packet.
267 These functions will return
268 <span class="errorcode">LWRES_R_FAILURE</span>
270 <code class="constant">pktflags</code>
271 in the packet header structure
272 <span class="type">lwres_lwpacket_t</span>
273 indicate that the packet is not a response to an earlier query.
276 <div class="refsection">
277 <a name="id-1.9"></a><h2>SEE ALSO</h2>
278 <p><span class="citerefentry"><span class="refentrytitle">lwres_packet</span>(3)</span>