lwres_noop.html revision 794b79e6bbc3f5db1ea6ae154d739b9f1ef1a375
ec79b29695b183f794264bbb578c51e93d1f9b1emartin - Copyright (C) 2004, 2005, 2007, 2014 Internet Systems Consortium, Inc. ("ISC")
1a5f954324f2584984fc9cee7a7a8ebe8ef39aeajim - Copyright (C) 2000, 2001 Internet Software Consortium.
65cb7f00eca6689c8a89dc809359991ade1285bcwrowe - Permission to use, copy, modify, and/or distribute this software for any
65cb7f00eca6689c8a89dc809359991ade1285bcwrowe - purpose with or without fee is hereby granted, provided that the above
65cb7f00eca6689c8a89dc809359991ade1285bcwrowe - copyright notice and this permission notice appear in all copies.
65cb7f00eca6689c8a89dc809359991ade1285bcwrowe - THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
475311484e1d0f01d41e0f48bfecf1f4bca2ff07rpluem - REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
475311484e1d0f01d41e0f48bfecf1f4bca2ff07rpluem - AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
475311484e1d0f01d41e0f48bfecf1f4bca2ff07rpluem - INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
e2bb6b0c7c3677acdf102b743a2218aa37725c81rpluem - LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
e2bb6b0c7c3677acdf102b743a2218aa37725c81rpluem - OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
e2bb6b0c7c3677acdf102b743a2218aa37725c81rpluem - PERFORMANCE OF THIS SOFTWARE.
4cb2a91bff46cc80d156f5654c922b0243f928cfmturk<!-- $Id$ -->
4cb2a91bff46cc80d156f5654c922b0243f928cfmturk<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
b9138a18a2e9312afaa87cb323e5b845a64ef0a2rpluem<meta name="generator" content="DocBook XSL Stylesheets V1.71.1">
b9138a18a2e9312afaa87cb323e5b845a64ef0a2rpluem<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="refentry" lang="en">
0d529159d06aec095a1e0612e2d629c98dc75512rpluem<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>
3511969853863eeb6e80018afe63831e5bf81447rpluem<table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" style="padding-bottom: 1em">
c6d33447e28403a90ad817dba4df75fae785be28pquernalwres_result_t
439ccf2a084e1da566548931c585cbcc3a9e7f4cminfrin<b class="fsfunc">lwres_nooprequest_render</b>(</code></td>
f09bf2676d29e43c211b663f5c9423815d83395fniq<table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" style="padding-bottom: 1em">
11a0edf478ca9c59d80bf73491d89cf019259feeniqlwres_result_t
11a0edf478ca9c59d80bf73491d89cf019259feeniq<b class="fsfunc">lwres_noopresponse_render</b>(</code></td>
81bd9331da3bd0f53255d52b1475480ff3a4b395trawick<table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" style="padding-bottom: 1em">
cd3bbd6d2df78d6c75e5d159a81ef8bdd5f70df9trawicklwres_result_t
cd3bbd6d2df78d6c75e5d159a81ef8bdd5f70df9trawick<b class="fsfunc">lwres_nooprequest_parse</b>(</code></td>
3e155218733389e7b1ea3a9ffd0aea533fd929cechrisd<var class="pdparam">structp</var><code>)</code>;</td>
dd6199828976e6c7850ca6abd7a1ceba99e9ed16chrisd<table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" style="padding-bottom: 1em">
ab43b4a17b2ac31ccb1cf280be8c42a8a314cecbjortonlwres_result_t
ab43b4a17b2ac31ccb1cf280be8c42a8a314cecbjorton<b class="fsfunc">lwres_noopresponse_parse</b>(</code></td>
dec02391360e503cd3437d16bed765dc653b9de5minfrin<var class="pdparam">structp</var><code>)</code>;</td>
686ce4eade942e515b1725d0c9751da36b759a6ctrawick<table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" style="padding-bottom: 1em">
4bd465052c4a0c8d41e573ee7a90c312d980355fchrisd<b class="fsfunc">lwres_noopresponse_free</b>(</code></td>
a87e2a23083aa62229307482afbb3b802a0c2105mturk<table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0">
8fd638698262130d00458b2c95548f6f94875847rpluem<b class="fsfunc">lwres_nooprequest_free</b>(</code></td>
127aef4ce9f7b6b32a95c5ed9a93b796d18755e6rpluem<var class="pdparam">structp</var><code>)</code>;</td>
88d0e50f16b21d4d0af0a48da7ad28fb5991834crpluem These are low-level routines for creating and parsing
88d0e50f16b21d4d0af0a48da7ad28fb5991834crpluem lightweight resolver no-op request and response messages.
15264721069299ec26493e21d56bf8ff7faf6f0drpluem The no-op message is analogous to a <span><strong class="command">ping</strong></span>
11e1b16b907afb7de0678e28fe4849d9029e2df8rpluem a packet is sent to the resolver daemon and is simply echoed back.
25a81ea1bca1c89cda713c4d23660e487b1488a0rpluem The opcode is intended to allow a client to determine if the server is
25a81ea1bca1c89cda713c4d23660e487b1488a0rpluem operational or not.
48fa058fe468025347930610ac2473094fa0f4e4chrisd There are four main functions for the no-op opcode.
48fa058fe468025347930610ac2473094fa0f4e4chrisd One render function converts a no-op request structure —
3ec4328f079d8867cc323155e59678ad9437914frooneg <span class="type">lwres_nooprequest_t</span> —
3ec4328f079d8867cc323155e59678ad9437914frooneg to the lighweight resolver's canonical format.
3ec4328f079d8867cc323155e59678ad9437914frooneg It is complemented by a parse function that converts a packet in this
de0d0b50c96fae59c28e09fed61b0d15cfa4147bchrisd canonical format to a no-op request structure.
de0d0b50c96fae59c28e09fed61b0d15cfa4147bchrisd Another render function converts the no-op response structure —
de0d0b50c96fae59c28e09fed61b0d15cfa4147bchrisd to the canonical format.
de0d0b50c96fae59c28e09fed61b0d15cfa4147bchrisd This is complemented by a parse function which converts a packet in
de0d0b50c96fae59c28e09fed61b0d15cfa4147bchrisd canonical format to a no-op response structure.
db78659055df54243bca678c35bd2ce7e31a9237rooneg These structures are defined in
95817edd05387a5276f51fcd5db79fc21b89b55brooneg They are shown below.
63689d77e084e36b8194fb6df5adfc0344965e01trawick#define LWRES_OPCODE_NOOP 0x00000000U
69c36bbae91de0e99a682aaae9d6fa61fceb2771bnicholestypedef struct {
69c36bbae91de0e99a682aaae9d6fa61fceb2771bnicholes lwres_uint16_t datalength;
69c36bbae91de0e99a682aaae9d6fa61fceb2771bnicholes unsigned char *data;
a1a615ca49b162d71d88089210395c9a9cfeb539rpluem} lwres_nooprequest_t;
a1a615ca49b162d71d88089210395c9a9cfeb539rpluemtypedef struct {
69c36bbae91de0e99a682aaae9d6fa61fceb2771bnicholes lwres_uint16_t datalength;
69c36bbae91de0e99a682aaae9d6fa61fceb2771bnicholes unsigned char *data;
69c36bbae91de0e99a682aaae9d6fa61fceb2771bnicholes} lwres_noopresponse_t;
69c36bbae91de0e99a682aaae9d6fa61fceb2771bnicholes Although the structures have different types, they are identical.
69c36bbae91de0e99a682aaae9d6fa61fceb2771bnicholes This is because the no-op opcode simply echos whatever data was sent:
69c36bbae91de0e99a682aaae9d6fa61fceb2771bnicholes the response is therefore identical to the request.
69c36bbae91de0e99a682aaae9d6fa61fceb2771bnicholes<p><code class="function">lwres_nooprequest_render()</code>
69c36bbae91de0e99a682aaae9d6fa61fceb2771bnicholes uses resolver context <em class="parameter"><code>ctx</code></em> to convert
69c36bbae91de0e99a682aaae9d6fa61fceb2771bnicholes no-op request structure <em class="parameter"><code>req</code></em> to canonical
69c36bbae91de0e99a682aaae9d6fa61fceb2771bnicholes format. The packet header structure <em class="parameter"><code>pkt</code></em>
69c36bbae91de0e99a682aaae9d6fa61fceb2771bnicholes is initialised and transferred to buffer
69c36bbae91de0e99a682aaae9d6fa61fceb2771bnicholes <em class="parameter"><code>b</code></em>. The contents of
69c36bbae91de0e99a682aaae9d6fa61fceb2771bnicholes <em class="parameter"><code>*req</code></em> are then appended to the buffer in
a1a615ca49b162d71d88089210395c9a9cfeb539rpluem canonical format.
1b0dce86d7fc8a5aa4c89b05255be26e508c615crpluem <code class="function">lwres_noopresponse_render()</code> performs the
1b0dce86d7fc8a5aa4c89b05255be26e508c615crpluem same task, except it converts a no-op response structure
1b0dce86d7fc8a5aa4c89b05255be26e508c615crpluem <span class="type">lwres_noopresponse_t</span> to the lightweight resolver's
1b0dce86d7fc8a5aa4c89b05255be26e508c615crpluem canonical format.
edc5389f50ce4153e6192740f3c7a188c8cf8d67niq<p><code class="function">lwres_nooprequest_parse()</code>
6c05afd314b4ddd545d63b4ff5de822cc30eec79trawick uses context <em class="parameter"><code>ctx</code></em> to convert the contents
6c05afd314b4ddd545d63b4ff5de822cc30eec79trawick of packet <em class="parameter"><code>pkt</code></em> to a
6c05afd314b4ddd545d63b4ff5de822cc30eec79trawick <span class="type">lwres_nooprequest_t</span> structure. Buffer
13cd67e9c1dacbd6b9f040bda337c725cedd98f3brianp <em class="parameter"><code>b</code></em> provides space to be used for storing
13cd67e9c1dacbd6b9f040bda337c725cedd98f3brianp this structure. When the function succeeds, the resulting
a623efbff95aab78da9e030524b0fa69b054f6d0brianp <span class="type">lwres_nooprequest_t</span> is made available through
a623efbff95aab78da9e030524b0fa69b054f6d0brianp <code class="function">lwres_noopresponse_parse()</code> offers the same
a623efbff95aab78da9e030524b0fa69b054f6d0brianp semantics as <code class="function">lwres_nooprequest_parse()</code>
a623efbff95aab78da9e030524b0fa69b054f6d0brianp except it yields a <span class="type">lwres_noopresponse_t</span> structure.
0b4b04d8621478ba59f0a6ba2950ddc02ab92b58colm<p><code class="function">lwres_noopresponse_free()</code>
0b4b04d8621478ba59f0a6ba2950ddc02ab92b58colm and <code class="function">lwres_nooprequest_free()</code> release the
0b4b04d8621478ba59f0a6ba2950ddc02ab92b58colm memory in resolver context <em class="parameter"><code>ctx</code></em> that was
2f1bb5376c5c4022383bb729679ca751dd75a2eabrianp allocated to the <span class="type">lwres_noopresponse_t</span> or
2f1bb5376c5c4022383bb729679ca751dd75a2eabrianp <span class="type">lwres_nooprequest_t</span> structures referenced via
2d5532b13110a8d85653da92e97795b09cc25cc2trawick The no-op opcode functions
b38565306421ff53e9f7499bc728d6df5cec294dpquerna <code class="function">lwres_nooprequest_render()</code>,
b38565306421ff53e9f7499bc728d6df5cec294dpquerna <code class="function">lwres_noopresponse_render()</code>
b38565306421ff53e9f7499bc728d6df5cec294dpquerna <code class="function">lwres_nooprequest_parse()</code>
74499a117b3b2cd9666715a14f90c0e5d1a4ee8ajim <code class="function">lwres_noopresponse_parse()</code>
cfa64348224b66dd1c9979b809406c4d15b1c137fielding on success.
74499a117b3b2cd9666715a14f90c0e5d1a4ee8ajim They return
74499a117b3b2cd9666715a14f90c0e5d1a4ee8ajim if memory allocation fails.
cfa64348224b66dd1c9979b809406c4d15b1c137fielding <span class="errorcode">LWRES_R_UNEXPECTEDEND</span>
74499a117b3b2cd9666715a14f90c0e5d1a4ee8ajim is returned if the available space in the buffer
74499a117b3b2cd9666715a14f90c0e5d1a4ee8ajim is too small to accommodate the packet header or the