lwres_noop.html revision 4abdfc917e6635a7c81d1f931a0c79227e72d025
2a20a2f8432a15b530e0a6b0998c32f40aef82a8gregames - Copyright (C) 2004, 2005 Internet Systems Consortium, Inc. ("ISC")
e6cc28a5eb3371ba0c38e941855e71ff0054f50erbb - Copyright (C) 2000, 2001 Internet Software Consortium.
e6cc28a5eb3371ba0c38e941855e71ff0054f50erbb - Permission to use, copy, modify, and distribute this software for any
e6cc28a5eb3371ba0c38e941855e71ff0054f50erbb - purpose with or without fee is hereby granted, provided that the above
e6cc28a5eb3371ba0c38e941855e71ff0054f50erbb - copyright notice and this permission notice appear in all copies.
e6cc28a5eb3371ba0c38e941855e71ff0054f50erbb - THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
e6cc28a5eb3371ba0c38e941855e71ff0054f50erbb - REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
cf233fb4b439415a2bf7bab7e622afd994e0bebftrawick - AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
cf233fb4b439415a2bf7bab7e622afd994e0bebftrawick - INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
cf233fb4b439415a2bf7bab7e622afd994e0bebftrawick - LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
cf233fb4b439415a2bf7bab7e622afd994e0bebftrawick - OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
ae64f3e7385f21ca9d4f30cc7f8702a9ac1034b6trawick - PERFORMANCE OF THIS SOFTWARE.
2a20a2f8432a15b530e0a6b0998c32f40aef82a8gregames<!-- $Id: lwres_noop.html,v 1.24 2007/01/26 23:29:04 marka Exp $ -->
2a20a2f8432a15b530e0a6b0998c32f40aef82a8gregames<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
2a20a2f8432a15b530e0a6b0998c32f40aef82a8gregames<meta name="generator" content="DocBook XSL Stylesheets V1.71.1">
2a20a2f8432a15b530e0a6b0998c32f40aef82a8gregames<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="refentry" lang="en">
2a20a2f8432a15b530e0a6b0998c32f40aef82a8gregames<a name="id2476275"></a><div class="titlepage"></div>
f99bffd6087564cf9c05cc29d1c6b38d94e0ed30gregames<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>
8458877c9ba0af86acd590eea531476adde3d02dmartin<table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" style="padding-bottom: 1em">
644be6f54749d2d9950d2c4d2ac448f7af016d26martinlwres_result_t
644be6f54749d2d9950d2c4d2ac448f7af016d26martin<b class="fsfunc">lwres_nooprequest_render</b>(</code></td>
c927e13f298c42251296d33cc1fa3eb8232b843daaron<table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" style="padding-bottom: 1em">
9126ed10455a2a98a3a51c68ed1b356e1873e8e6aaronlwres_result_t
9126ed10455a2a98a3a51c68ed1b356e1873e8e6aaron<b class="fsfunc">lwres_noopresponse_render</b>(</code></td>
526a776292f420ffeea0d081c61971ed381fad20stoddard<table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" style="padding-bottom: 1em">
526a776292f420ffeea0d081c61971ed381fad20stoddardlwres_result_t
526a776292f420ffeea0d081c61971ed381fad20stoddard<b class="fsfunc">lwres_nooprequest_parse</b>(</code></td>
83b031099aa3dc8a5fd2f708e397818cbd16c9aajerenkrantz<table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" style="padding-bottom: 1em">
01e77cadbd9ad4962993380245bcc033dde523e4rbblwres_result_t
01e77cadbd9ad4962993380245bcc033dde523e4rbb<b class="fsfunc">lwres_noopresponse_parse</b>(</code></td>
8b91dcac0e1ef7796c72d16b0962267313cac486jerenkrantz<var class="pdparam">structp</var><code>)</code>;</td>
6ce942b017db75b559a42bdc2d7b8ea9e869a956wrowe<table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" style="padding-bottom: 1em">
6ce942b017db75b559a42bdc2d7b8ea9e869a956wrowe<b class="fsfunc">lwres_noopresponse_free</b>(</code></td>
574f6ff9ee80ef4f772649c5c8319b764a8abe42jerenkrantz<var class="pdparam">structp</var><code>)</code>;</td>
6d7d70dbda8e461d87f2d41e323755496ae3ebc7trawick<table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0">
a310497ca9c5112d759871e1b7d9f6a40fb78bcfwrowe<b class="fsfunc">lwres_nooprequest_free</b>(</code></td>
e36ef0d081aa59867688bcbb3da65952ec16fae3rbb These are low-level routines for creating and parsing
e36ef0d081aa59867688bcbb3da65952ec16fae3rbb lightweight resolver no-op request and response messages.
52df98b165194a0ad68885f49f81fdaf56ece568wrowe The no-op message is analogous to a <span><strong class="command">ping</strong></span>
52df98b165194a0ad68885f49f81fdaf56ece568wrowe a packet is sent to the resolver daemon and is simply echoed back.
2c294c31addd5c957bafe6e78c4a30d423ad6e80rbb The opcode is intended to allow a client to determine if the server is
2c294c31addd5c957bafe6e78c4a30d423ad6e80rbb operational or not.
7e44dd5082cd865068285e8f915bb5f045e0bb80lars There are four main functions for the no-op opcode.
7e44dd5082cd865068285e8f915bb5f045e0bb80lars One render function converts a no-op request structure —
7e44dd5082cd865068285e8f915bb5f045e0bb80lars to the lighweight resolver's canonical format.
44a4ee1140769173da7bc2b42d1a686e3260ad84wrowe It is complemented by a parse function that converts a packet in this
44a4ee1140769173da7bc2b42d1a686e3260ad84wrowe canonical format to a no-op request structure.
44a4ee1140769173da7bc2b42d1a686e3260ad84wrowe Another render function converts the no-op response structure —
44a4ee1140769173da7bc2b42d1a686e3260ad84wrowe to the canonical format.
e379fc6d7f79163700290d92ce75deb4f3005301jerenkrantz This is complemented by a parse function which converts a packet in
e379fc6d7f79163700290d92ce75deb4f3005301jerenkrantz canonical format to a no-op response structure.
978faa9e29e0f0c42e66c07240e562325a4717b0jerenkrantz These structures are defined in
976501adbc040220270f7d1d77c4b8373033be69wrowe They are shown below.
976501adbc040220270f7d1d77c4b8373033be69wrowe#define LWRES_OPCODE_NOOP 0x00000000U
10a00688adcf1df367b1243810beedaabe6b1abeminfrintypedef struct {
8a3a703eae0e35f674b189181609545c6fc77a09rbb lwres_uint16_t datalength;
8a3a703eae0e35f674b189181609545c6fc77a09rbb unsigned char *data;
8a3a703eae0e35f674b189181609545c6fc77a09rbb} lwres_nooprequest_t;
9d41fafe32b324c197f25224207fc6ce34f085bfrbbtypedef struct {
9d41fafe32b324c197f25224207fc6ce34f085bfrbb lwres_uint16_t datalength;
9d41fafe32b324c197f25224207fc6ce34f085bfrbb unsigned char *data;
9d41fafe32b324c197f25224207fc6ce34f085bfrbb} lwres_noopresponse_t;
8c83461e53ca7d204e1d634f0c78199d60320d7bjerenkrantz Although the structures have different types, they are identical.
8c83461e53ca7d204e1d634f0c78199d60320d7bjerenkrantz This is because the no-op opcode simply echos whatever data was sent:
8c83461e53ca7d204e1d634f0c78199d60320d7bjerenkrantz the response is therefore identical to the request.
8e5842bc05146bb5c171e53b00b24063d17c666cjerenkrantz<p><code class="function">lwres_nooprequest_render()</code>
8e5842bc05146bb5c171e53b00b24063d17c666cjerenkrantz uses resolver context <em class="parameter"><code>ctx</code></em> to convert
cdb15137887e284797e9510029098dc725b4dacfjerenkrantz no-op request structure <em class="parameter"><code>req</code></em> to canonical
cdb15137887e284797e9510029098dc725b4dacfjerenkrantz format. The packet header structure <em class="parameter"><code>pkt</code></em>
798c7c11dc2fe3b08e591e9c76fc1a84857f2cd4jerenkrantz is initialised and transferred to buffer
798c7c11dc2fe3b08e591e9c76fc1a84857f2cd4jerenkrantz <em class="parameter"><code>b</code></em>. The contents of
798c7c11dc2fe3b08e591e9c76fc1a84857f2cd4jerenkrantz <em class="parameter"><code>*req</code></em> are then appended to the buffer in
798c7c11dc2fe3b08e591e9c76fc1a84857f2cd4jerenkrantz canonical format.
abaaa634d7cee882b7c4bf078ded749ebf11997erbb <code class="function">lwres_noopresponse_render()</code> performs the
abaaa634d7cee882b7c4bf078ded749ebf11997erbb same task, except it converts a no-op response structure
abaaa634d7cee882b7c4bf078ded749ebf11997erbb <span class="type">lwres_noopresponse_t</span> to the lightweight resolver's
abaaa634d7cee882b7c4bf078ded749ebf11997erbb canonical format.
0aa8e8fd5a242948518655f2296b3c76386754e5jerenkrantz<p><code class="function">lwres_nooprequest_parse()</code>
0aa8e8fd5a242948518655f2296b3c76386754e5jerenkrantz uses context <em class="parameter"><code>ctx</code></em> to convert the contents
de3abad1fe263e577bb11e99b358836bd901397crbb of packet <em class="parameter"><code>pkt</code></em> to a
de3abad1fe263e577bb11e99b358836bd901397crbb <span class="type">lwres_nooprequest_t</span> structure. Buffer
de3abad1fe263e577bb11e99b358836bd901397crbb <em class="parameter"><code>b</code></em> provides space to be used for storing
de3abad1fe263e577bb11e99b358836bd901397crbb this structure. When the function succeeds, the resulting
de3abad1fe263e577bb11e99b358836bd901397crbb <span class="type">lwres_nooprequest_t</span> is made available through
de3abad1fe263e577bb11e99b358836bd901397crbb <code class="function">lwres_noopresponse_parse()</code> offers the same
de3abad1fe263e577bb11e99b358836bd901397crbb semantics as <code class="function">lwres_nooprequest_parse()</code>
de3abad1fe263e577bb11e99b358836bd901397crbb except it yields a <span class="type">lwres_noopresponse_t</span> structure.
0a549489abdb309ef25483431e1e5610ed4ba7a8gstein<p><code class="function">lwres_noopresponse_free()</code>
0a549489abdb309ef25483431e1e5610ed4ba7a8gstein and <code class="function">lwres_nooprequest_free()</code> release the
0a549489abdb309ef25483431e1e5610ed4ba7a8gstein memory in resolver context <em class="parameter"><code>ctx</code></em> that was
0a549489abdb309ef25483431e1e5610ed4ba7a8gstein allocated to the <span class="type">lwres_noopresponse_t</span> or
0a549489abdb309ef25483431e1e5610ed4ba7a8gstein <span class="type">lwres_nooprequest_t</span> structures referenced via
f00d1e76bae896c2f6a520eec69b1d0d802d4108jerenkrantz The no-op opcode functions
58097d7d8d1a394092374b9f6ddf76b7993724a4rbb <code class="function">lwres_nooprequest_render()</code>,
58097d7d8d1a394092374b9f6ddf76b7993724a4rbb <code class="function">lwres_noopresponse_render()</code>
2f6cebd6b8bf0b044f6579d23117a4a3c364a554wrowe <code class="function">lwres_noopresponse_parse()</code>
2f6cebd6b8bf0b044f6579d23117a4a3c364a554wrowe on success.
070d2f9fd52a3f0e45ca7ae1235c5a5755b80d24rbb They return
070d2f9fd52a3f0e45ca7ae1235c5a5755b80d24rbb if memory allocation fails.
070d2f9fd52a3f0e45ca7ae1235c5a5755b80d24rbb is returned if the available space in the buffer
7c19ce86bbd72bba1d018522250f5f315ffbc0afjerenkrantz is too small to accommodate the packet header or the
2264fbcbab4c796c4222c30393c0b218c98b6befrbb structures.
e099672a13ea4ff4a11f130406f1baecba5949bajerenkrantz <code class="function">lwres_noopresponse_parse()</code>
9b29e0cfeb2c89a047806cc4a2a764afed6bb170wrowe if the buffer is not empty after decoding the received packet.
9b29e0cfeb2c89a047806cc4a2a764afed6bb170wrowe These functions will return
441bd066858500e75e4f63ef149120bcf523de58jerenkrantz in the packet header structure
d6a93816bfaa5b3de5f2e6cb0d172cbe20dd056ejerenkrantz indicate that the packet is not a response to an earlier query.
c839614b4216fe34f6346668ad646aca2c0f23c6wrowe<p><span class="citerefentry"><span class="refentrytitle">lwres_packet</span>(3)</span>