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_noop.html,v 1.7.2.1.4.9 2005/10/13 02:33:57 marka Exp $ -->
20 <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
21 <title>lwres_noop</title>
22 <meta name="generator" content="DocBook XSL Stylesheets V1.69.1">
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">
28 <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>
30 <div class="refsynopsisdiv">
32 <div class="funcsynopsis">
33 <pre class="funcsynopsisinfo">
34 #include <lwres/lwres.h></pre>
35 <table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" style="padding-bottom: 1em">
37 <td><code class="funcdef">
39 <b class="fsfunc">lwres_nooprequest_render</b>(</code></td>
60 <table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" style="padding-bottom: 1em">
62 <td><code class="funcdef">
64 <b class="fsfunc">lwres_noopresponse_render</b>(</code></td>
85 <table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" style="padding-bottom: 1em">
87 <td><code class="funcdef">
89 <b class="fsfunc">lwres_nooprequest_parse</b>(</code></td>
110 <table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" style="padding-bottom: 1em">
112 <td><code class="funcdef">
114 <b class="fsfunc">lwres_noopresponse_parse</b>(</code></td>
135 <table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" style="padding-bottom: 1em">
137 <td><code class="funcdef">
139 <b class="fsfunc">lwres_noopresponse_free</b>(</code></td>
150 <table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0">
152 <td><code class="funcdef">
154 <b class="fsfunc">lwres_nooprequest_free</b>(</code></td>
167 <div class="refsect1" lang="en">
168 <a name="id2525963"></a><h2>DESCRIPTION</h2>
170 These are low-level routines for creating and parsing
171 lightweight resolver no-op request and response messages.
174 The no-op message is analogous to a <span><strong class="command">ping</strong></span> packet:
175 a packet is sent to the resolver daemon and is simply echoed back.
176 The opcode is intended to allow a client to determine if the server is
180 There are four main functions for the no-op opcode.
181 One render function converts a no-op request structure —
182 <span class="type">lwres_nooprequest_t</span> —
183 to the lighweight resolver's canonical format.
184 It is complemented by a parse function that converts a packet in this
185 canonical format to a no-op request structure.
186 Another render function converts the no-op response structure —
187 <span class="type">lwres_noopresponse_t</span>
188 to the canonical format.
189 This is complemented by a parse function which converts a packet in
190 canonical format to a no-op response structure.
193 These structures are defined in
194 <code class="filename">lwres/lwres.h</code>.
196 They are shown below.
198 <pre class="programlisting">
199 #define LWRES_OPCODE_NOOP 0x00000000U
202 lwres_uint16_t datalength;
204 } lwres_nooprequest_t;
207 lwres_uint16_t datalength;
209 } lwres_noopresponse_t;
212 Although the structures have different types, they are identical.
213 This is because the no-op opcode simply echos whatever data was sent:
214 the response is therefore identical to the request.
217 <code class="function">lwres_nooprequest_render()</code> uses resolver
218 context <em class="parameter"><code>ctx</code></em> to convert no-op request structure
219 <em class="parameter"><code>req</code></em> to canonical format. The packet header
220 structure <em class="parameter"><code>pkt</code></em> is initialised and transferred to
221 buffer <em class="parameter"><code>b</code></em>. The contents of
222 <em class="parameter"><code>*req</code></em> are then appended to the buffer in
223 canonical format. <code class="function">lwres_noopresponse_render()</code>
224 performs the same task, except it converts a no-op response structure
225 <span class="type">lwres_noopresponse_t</span> to the lightweight resolver's
229 <code class="function">lwres_nooprequest_parse()</code> uses context
230 <em class="parameter"><code>ctx</code></em> to convert the contents of packet
231 <em class="parameter"><code>pkt</code></em> to a <span class="type">lwres_nooprequest_t</span>
232 structure. Buffer <em class="parameter"><code>b</code></em> provides space to be used
233 for storing this structure. When the function succeeds, the resulting
234 <span class="type">lwres_nooprequest_t</span> is made available through
235 <em class="parameter"><code>*structp</code></em>.
236 <code class="function">lwres_noopresponse_parse()</code> offers the same
237 semantics as <code class="function">lwres_nooprequest_parse()</code> except it
238 yields a <span class="type">lwres_noopresponse_t</span> structure.
241 <code class="function">lwres_noopresponse_free()</code> and
242 <code class="function">lwres_nooprequest_free()</code> release the memory in
243 resolver context <em class="parameter"><code>ctx</code></em> that was allocated to the
244 <span class="type">lwres_noopresponse_t</span> or <span class="type">lwres_nooprequest_t</span>
245 structures referenced via <em class="parameter"><code>structp</code></em>.
248 <div class="refsect1" lang="en">
249 <a name="id2526096"></a><h2>RETURN VALUES</h2>
251 The no-op opcode functions
252 <code class="function">lwres_nooprequest_render()</code>,
254 <code class="function">lwres_noopresponse_render()</code>
255 <code class="function">lwres_nooprequest_parse()</code>
257 <code class="function">lwres_noopresponse_parse()</code>
259 <span class="errorcode">LWRES_R_SUCCESS</span>
262 <span class="errorcode">LWRES_R_NOMEMORY</span>
263 if memory allocation fails.
264 <span class="errorcode">LWRES_R_UNEXPECTEDEND</span>
265 is returned if the available space in the buffer
266 <em class="parameter"><code>b</code></em>
267 is too small to accommodate the packet header or the
268 <span class="type">lwres_nooprequest_t</span>
270 <span class="type">lwres_noopresponse_t</span>
272 <code class="function">lwres_nooprequest_parse()</code>
274 <code class="function">lwres_noopresponse_parse()</code>
276 <span class="errorcode">LWRES_R_UNEXPECTEDEND</span>
277 if the buffer is not empty after decoding the received packet.
278 These functions will return
279 <span class="errorcode">LWRES_R_FAILURE</span>
281 <code class="constant">pktflags</code>
282 in the packet header structure
283 <span class="type">lwres_lwpacket_t</span>
284 indicate that the packet is not a response to an earlier query.
287 <div class="refsect1" lang="en">
288 <a name="id2526160"></a><h2>SEE ALSO</h2>
290 <span class="citerefentry"><span class="refentrytitle">lwres_packet</span>(3