lwres_noop.html revision d6fa26d0adaec6c910115be34fe7a5a5f402c14f
d6fa26d0adaec6c910115be34fe7a5a5f402c14fMark Andrews<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
5347c0fcb04eaea19d9f39795646239f487c6207Tinderbox User - Copyright (C) 2000, 2001, 2004, 2005, 2007, 2014-2016 Internet Systems Consortium, Inc. ("ISC")
5347c0fcb04eaea19d9f39795646239f487c6207Tinderbox User - This Source Code Form is subject to the terms of the Mozilla Public
5347c0fcb04eaea19d9f39795646239f487c6207Tinderbox User - License, v. 2.0. If a copy of the MPL was not distributed with this
5347c0fcb04eaea19d9f39795646239f487c6207Tinderbox User - file, You can obtain one at http://mozilla.org/MPL/2.0/.
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
fd2597f75693a2279fdf588bd40dfe2407c42028Tinderbox User<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
fd2597f75693a2279fdf588bd40dfe2407c42028Tinderbox User<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="refentry">
fd2597f75693a2279fdf588bd40dfe2407c42028Tinderbox User<a name="id-1"></a><div class="titlepage"></div>
fd2597f75693a2279fdf588bd40dfe2407c42028Tinderbox User<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>
fd2597f75693a2279fdf588bd40dfe2407c42028Tinderbox User<table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;">
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austeinlwres_result_t
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein<b class="fsfunc">lwres_nooprequest_render</b>(</code></td>
2eeb74d1cf5355dd98f6d507a10086e16bb08c4bTinderbox User<td>lwres_context_t *<var class="pdparam">ctx</var>, </td>
2eeb74d1cf5355dd98f6d507a10086e16bb08c4bTinderbox User<td>lwres_nooprequest_t *<var class="pdparam">req</var>, </td>
2eeb74d1cf5355dd98f6d507a10086e16bb08c4bTinderbox User<td>lwres_lwpacket_t *<var class="pdparam">pkt</var>, </td>
2eeb74d1cf5355dd98f6d507a10086e16bb08c4bTinderbox User<td>lwres_buffer_t *<var class="pdparam">b</var><code>)</code>;</td>
fd2597f75693a2279fdf588bd40dfe2407c42028Tinderbox User<table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;">
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austeinlwres_result_t
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein<b class="fsfunc">lwres_noopresponse_render</b>(</code></td>
2eeb74d1cf5355dd98f6d507a10086e16bb08c4bTinderbox User<td>lwres_context_t *<var class="pdparam">ctx</var>, </td>
2eeb74d1cf5355dd98f6d507a10086e16bb08c4bTinderbox User<td>lwres_noopresponse_t *<var class="pdparam">req</var>, </td>
2eeb74d1cf5355dd98f6d507a10086e16bb08c4bTinderbox User<td>lwres_lwpacket_t *<var class="pdparam">pkt</var>, </td>
2eeb74d1cf5355dd98f6d507a10086e16bb08c4bTinderbox User<td>lwres_buffer_t *<var class="pdparam">b</var><code>)</code>;</td>
fd2597f75693a2279fdf588bd40dfe2407c42028Tinderbox User<table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;">
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austeinlwres_result_t
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein<b class="fsfunc">lwres_nooprequest_parse</b>(</code></td>
2eeb74d1cf5355dd98f6d507a10086e16bb08c4bTinderbox User<td>lwres_context_t *<var class="pdparam">ctx</var>, </td>
2eeb74d1cf5355dd98f6d507a10086e16bb08c4bTinderbox User<td>lwres_buffer_t *<var class="pdparam">b</var>, </td>
2eeb74d1cf5355dd98f6d507a10086e16bb08c4bTinderbox User<td>lwres_lwpacket_t *<var class="pdparam">pkt</var>, </td>
2eeb74d1cf5355dd98f6d507a10086e16bb08c4bTinderbox User<td>lwres_nooprequest_t **<var class="pdparam">structp</var><code>)</code>;</td>
fd2597f75693a2279fdf588bd40dfe2407c42028Tinderbox User<table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;">
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austeinlwres_result_t
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein<b class="fsfunc">lwres_noopresponse_parse</b>(</code></td>
2eeb74d1cf5355dd98f6d507a10086e16bb08c4bTinderbox User<td>lwres_context_t *<var class="pdparam">ctx</var>, </td>
2eeb74d1cf5355dd98f6d507a10086e16bb08c4bTinderbox User<td>lwres_buffer_t *<var class="pdparam">b</var>, </td>
2eeb74d1cf5355dd98f6d507a10086e16bb08c4bTinderbox User<td>lwres_lwpacket_t *<var class="pdparam">pkt</var>, </td>
2eeb74d1cf5355dd98f6d507a10086e16bb08c4bTinderbox User<td>lwres_noopresponse_t **<var class="pdparam">structp</var><code>)</code>;</td>
fd2597f75693a2279fdf588bd40dfe2407c42028Tinderbox User<table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;">
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein<b class="fsfunc">lwres_noopresponse_free</b>(</code></td>
2eeb74d1cf5355dd98f6d507a10086e16bb08c4bTinderbox User<td>lwres_context_t *<var class="pdparam">ctx</var>, </td>
2eeb74d1cf5355dd98f6d507a10086e16bb08c4bTinderbox User<td>lwres_noopresponse_t **<var class="pdparam">structp</var><code>)</code>;</td>
fd2597f75693a2279fdf588bd40dfe2407c42028Tinderbox User<table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;">
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein<b class="fsfunc">lwres_nooprequest_free</b>(</code></td>
2eeb74d1cf5355dd98f6d507a10086e16bb08c4bTinderbox User<td>lwres_context_t *<var class="pdparam">ctx</var>, </td>
2eeb74d1cf5355dd98f6d507a10086e16bb08c4bTinderbox User<td>lwres_nooprequest_t **<var class="pdparam">structp</var><code>)</code>;</td>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein These are low-level routines for creating and parsing
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein lightweight resolver no-op request and response messages.
2eeb74d1cf5355dd98f6d507a10086e16bb08c4bTinderbox User The no-op message is analogous to a <span class="command"><strong>ping</strong></span>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein a packet is sent to the resolver daemon and is simply echoed back.
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein The opcode is intended to allow a client to determine if the server is
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein operational or not.
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein There are four main functions for the no-op opcode.
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein One render function converts a no-op request structure —
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein <span class="type">lwres_nooprequest_t</span> —
a24330c4805a224191ab687d0291963062fe3355Tinderbox User to the lightweight resolver's canonical format.
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein It is complemented by a parse function that converts a packet in this
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein canonical format to a no-op request structure.
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein Another render function converts the no-op response structure —
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein to the canonical format.
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein This is complemented by a parse function which converts a packet in
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein canonical format to a no-op response structure.
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein These structures are defined in
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein They are shown below.
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein#define LWRES_OPCODE_NOOP 0x00000000U
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafssontypedef struct {
8eea877894ea5bcf5cdd9ca124a8601ad421d753Andreas Gustafsson lwres_uint16_t datalength;
8eea877894ea5bcf5cdd9ca124a8601ad421d753Andreas Gustafsson unsigned char *data;
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson} lwres_nooprequest_t;
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafssontypedef struct {
8eea877894ea5bcf5cdd9ca124a8601ad421d753Andreas Gustafsson lwres_uint16_t datalength;
8eea877894ea5bcf5cdd9ca124a8601ad421d753Andreas Gustafsson unsigned char *data;
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein} lwres_noopresponse_t;
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein Although the structures have different types, they are identical.
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein This is because the no-op opcode simply echos whatever data was sent:
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein the response is therefore identical to the request.
fd2597f75693a2279fdf588bd40dfe2407c42028Tinderbox User<p><code class="function">lwres_nooprequest_render()</code>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein uses resolver context <em class="parameter"><code>ctx</code></em> to convert
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein no-op request structure <em class="parameter"><code>req</code></em> to canonical
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein format. The packet header structure <em class="parameter"><code>pkt</code></em>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein is initialised and transferred to buffer
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein <em class="parameter"><code>b</code></em>. The contents of
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein <em class="parameter"><code>*req</code></em> are then appended to the buffer in
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein canonical format.
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein <code class="function">lwres_noopresponse_render()</code> performs the
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein same task, except it converts a no-op response structure
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein <span class="type">lwres_noopresponse_t</span> to the lightweight resolver's
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein canonical format.
fd2597f75693a2279fdf588bd40dfe2407c42028Tinderbox User<p><code class="function">lwres_nooprequest_parse()</code>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein uses context <em class="parameter"><code>ctx</code></em> to convert the contents
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein of packet <em class="parameter"><code>pkt</code></em> to a
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein <span class="type">lwres_nooprequest_t</span> structure. Buffer
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein <em class="parameter"><code>b</code></em> provides space to be used for storing
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein this structure. When the function succeeds, the resulting
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein <span class="type">lwres_nooprequest_t</span> is made available through
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein <em class="parameter"><code>*structp</code></em>.
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein <code class="function">lwres_noopresponse_parse()</code> offers the same
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein semantics as <code class="function">lwres_nooprequest_parse()</code>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein except it yields a <span class="type">lwres_noopresponse_t</span> structure.
fd2597f75693a2279fdf588bd40dfe2407c42028Tinderbox User<p><code class="function">lwres_noopresponse_free()</code>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein and <code class="function">lwres_nooprequest_free()</code> release the
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein memory in resolver context <em class="parameter"><code>ctx</code></em> that was
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein allocated to the <span class="type">lwres_noopresponse_t</span> or
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein <span class="type">lwres_nooprequest_t</span> structures referenced via
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein <em class="parameter"><code>structp</code></em>.
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein The no-op opcode functions
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein <code class="function">lwres_nooprequest_render()</code>,
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein <code class="function">lwres_noopresponse_render()</code>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein <code class="function">lwres_nooprequest_parse()</code>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein <code class="function">lwres_noopresponse_parse()</code>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein if memory allocation fails.
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein <span class="errorcode">LWRES_R_UNEXPECTEDEND</span>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein is returned if the available space in the buffer
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein is too small to accommodate the packet header or the
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein <code class="function">lwres_nooprequest_parse()</code>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein <code class="function">lwres_noopresponse_parse()</code>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein <span class="errorcode">LWRES_R_UNEXPECTEDEND</span>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein if the buffer is not empty after decoding the received packet.
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein These functions will return
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein in the packet header structure
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein indicate that the packet is not a response to an earlier query.
fd2597f75693a2279fdf588bd40dfe2407c42028Tinderbox User<p><span class="citerefentry"><span class="refentrytitle">lwres_packet</span>(3)</span>