lwres_packet.html revision b0e8629055a766d4555a005a283c2889a5974945
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<!--
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews - Copyright (C) 2004, 2005, 2007 Internet Systems Consortium, Inc. ("ISC")
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson - Copyright (C) 2000, 2001 Internet Software Consortium.
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews -
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews - Permission to use, copy, modify, and distribute this software for any
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews - purpose with or without fee is hereby granted, provided that the above
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson - copyright notice and this permission notice appear in all copies.
2eeb74d1cf5355dd98f6d507a10086e16bb08c4bTinderbox User -
14a656f94b1fd0ababd84a772228dfa52276ba15Evan Hunt - THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
14a656f94b1fd0ababd84a772228dfa52276ba15Evan Hunt - REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
14a656f94b1fd0ababd84a772228dfa52276ba15Evan Hunt - AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
14a656f94b1fd0ababd84a772228dfa52276ba15Evan Hunt - INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
14a656f94b1fd0ababd84a772228dfa52276ba15Evan Hunt - LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein - OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
14a656f94b1fd0ababd84a772228dfa52276ba15Evan Hunt - PERFORMANCE OF THIS SOFTWARE.
14a656f94b1fd0ababd84a772228dfa52276ba15Evan Hunt-->
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein<!-- $Id: lwres_packet.html,v 1.26 2007/01/30 00:24:59 marka Exp $ -->
86b0285d7e65601645db4090d62ee6cb63abad6cAndreas Gustafsson<html>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein<head>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein<title>lwres_packet</title>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein<meta name="generator" content="DocBook XSL Stylesheets V1.71.1">
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein</head>
86b0285d7e65601645db4090d62ee6cb63abad6cAndreas Gustafsson<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="refentry" lang="en">
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein<a name="id2476275"></a><div class="titlepage"></div>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein<div class="refnamediv">
194e2dfffa6a167b8eef0ad11864026b423a1c30Mark Andrews<h2>Name</h2>
194e2dfffa6a167b8eef0ad11864026b423a1c30Mark Andrews<p>lwres_lwpacket_renderheader, lwres_lwpacket_parseheader &#8212; lightweight resolver packet handling functions</p>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein</div>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein<div class="refsynopsisdiv">
c1a883f2e04d94e99c433b1f6cfd0c0338f4ed85Mark Andrews<h2>Synopsis</h2>
938440694b33cd752e9e4b71a526368b4811c177Tinderbox User<div class="funcsynopsis">
19c7b1a0293498a3e36692c59646ed6e15ffc8d0Tinderbox User<pre class="funcsynopsisinfo">#include &lt;lwres/lwpacket.h&gt;</pre>
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews<table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" style="padding-bottom: 1em">
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein<tr>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein<td><code class="funcdef">
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austeinlwres_result_t
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein<b class="fsfunc">lwres_lwpacket_renderheader</b>(</code></td>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein<td>lwres_buffer_t *�</td>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein<td>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein<var class="pdparam">b</var>, </td>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein</tr>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein<tr>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein<td>�</td>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein<td>lwres_lwpacket_t *�</td>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<td>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<var class="pdparam">pkt</var><code>)</code>;</td>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein</tr>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson</table>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0">
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein<tr>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein<td><code class="funcdef">
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafssonlwres_result_t
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein<b class="fsfunc">lwres_lwpacket_parseheader</b>(</code></td>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<td>lwres_buffer_t *�</td>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<td>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein<var class="pdparam">b</var>, </td>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein</tr>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<tr>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein<td>�</td>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<td>lwres_lwpacket_t *�</td>
14a656f94b1fd0ababd84a772228dfa52276ba15Evan Hunt<td>
30eec077db2bdcb6f2a0dc388a3cdde2ede75ec1Mark Andrews<var class="pdparam">pkt</var><code>)</code>;</td>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson</tr>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein</table>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein</div>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein</div>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein<div class="refsect1" lang="en">
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein<a name="id2543389"></a><h2>DESCRIPTION</h2>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein<p>
86b0285d7e65601645db4090d62ee6cb63abad6cAndreas Gustafsson These functions rely on a
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein <span class="type">struct lwres_lwpacket</span>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein which is defined in
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein <code class="filename">lwres/lwpacket.h</code>.
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein </p>
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson<pre class="programlisting">
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austeintypedef struct lwres_lwpacket lwres_lwpacket_t;
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein </pre>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein<p>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein </p>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein<pre class="programlisting">
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austeinstruct lwres_lwpacket {
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein lwres_uint32_t length;
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein lwres_uint16_t version;
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein lwres_uint16_t pktflags;
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein lwres_uint32_t serial;
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein lwres_uint32_t opcode;
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein lwres_uint32_t result;
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein lwres_uint32_t recvlength;
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein lwres_uint16_t authtype;
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein lwres_uint16_t authlength;
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein};
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein</pre>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein<p>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein </p>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein<p>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein The elements of this structure are:
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein </p>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein<div class="variablelist"><dl>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein<dt><span class="term"><code class="constant">length</code></span></dt>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein<dd><p>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein the overall packet length, including the entire packet header.
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein This field is filled in by the lwres_gabn_*() and lwres_gnba_*()
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein calls.
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein </p></dd>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein<dt><span class="term"><code class="constant">version</code></span></dt>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein<dd><p>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein the header format. There is currently only one format,
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein <span class="type">LWRES_LWPACKETVERSION_0</span>.
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein This field is filled in by the lwres_gabn_*() and lwres_gnba_*()
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein calls.
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein </p></dd>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein<dt><span class="term"><code class="constant">pktflags</code></span></dt>
14a656f94b1fd0ababd84a772228dfa52276ba15Evan Hunt<dd><p>
86b0285d7e65601645db4090d62ee6cb63abad6cAndreas Gustafsson library-defined flags for this packet: for instance whether the
14a656f94b1fd0ababd84a772228dfa52276ba15Evan Hunt packet
30eec077db2bdcb6f2a0dc388a3cdde2ede75ec1Mark Andrews is a request or a reply. Flag values can be set, but not defined
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein by
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein the caller.
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein This field is filled in by the application wit the exception of
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein the
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein LWRES_LWPACKETFLAG_RESPONSE bit, which is set by the library in
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein the
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein lwres_gabn_*() and lwres_gnba_*() calls.
14a656f94b1fd0ababd84a772228dfa52276ba15Evan Hunt </p></dd>
14a656f94b1fd0ababd84a772228dfa52276ba15Evan Hunt<dt><span class="term"><code class="constant">serial</code></span></dt>
30eec077db2bdcb6f2a0dc388a3cdde2ede75ec1Mark Andrews<dd><p>
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein is set by the requestor and is returned in all replies. If two
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein or more
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein packets from the same source have the same serial number and are
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson from
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein the same source, they are assumed to be duplicates and the
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein latter ones
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein may be dropped.
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein This field must be set by the application.
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson </p></dd>
14a656f94b1fd0ababd84a772228dfa52276ba15Evan Hunt<dt><span class="term"><code class="constant">opcode</code></span></dt>
14a656f94b1fd0ababd84a772228dfa52276ba15Evan Hunt<dd><p>
indicates the operation.
Opcodes between 0x00000000 and 0x03ffffff are
reserved for use by the lightweight resolver library. Opcodes
between
0x04000000 and 0xffffffff are application defined.
This field is filled in by the lwres_gabn_*() and lwres_gnba_*()
calls.
</p></dd>
<dt><span class="term"><code class="constant">result</code></span></dt>
<dd><p>
is only valid for replies.
Results between 0x04000000 and 0xffffffff are application
defined.
Results between 0x00000000 and 0x03ffffff are reserved for
library use.
This field is filled in by the lwres_gabn_*() and lwres_gnba_*()
calls.
</p></dd>
<dt><span class="term"><code class="constant">recvlength</code></span></dt>
<dd><p>
is the maximum buffer size that the receiver can handle on
requests
and the size of the buffer needed to satisfy a request when the
buffer
is too large for replies.
This field is supplied by the application.
</p></dd>
<dt><span class="term"><code class="constant">authtype</code></span></dt>
<dd><p>
defines the packet level authentication that is used.
Authorisation types between 0x1000 and 0xffff are application
defined
and types between 0x0000 and 0x0fff are reserved for library
use.
Currently these are not used and must be zero.
</p></dd>
<dt><span class="term"><code class="constant">authlen</code></span></dt>
<dd><p>
gives the length of the authentication data.
Since packet authentication is currently not used, this must be
zero.
</p></dd>
</dl></div>
<p>
</p>
<p>
The following opcodes are currently defined:
</p>
<div class="variablelist"><dl>
<dt><span class="term"><code class="constant">NOOP</code></span></dt>
<dd><p>
Success is always returned and the packet contents are echoed.
The lwres_noop_*() functions should be used for this type.
</p></dd>
<dt><span class="term"><code class="constant">GETADDRSBYNAME</code></span></dt>
<dd><p>
returns all known addresses for a given name.
The lwres_gabn_*() functions should be used for this type.
</p></dd>
<dt><span class="term"><code class="constant">GETNAMEBYADDR</code></span></dt>
<dd><p>
return the hostname for the given address.
The lwres_gnba_*() functions should be used for this type.
</p></dd>
</dl></div>
<p>
</p>
<p><code class="function">lwres_lwpacket_renderheader()</code>
transfers the contents of lightweight resolver packet structure
<span class="type">lwres_lwpacket_t</span> <em class="parameter"><code>*pkt</code></em> in
network byte order to the lightweight resolver buffer,
<em class="parameter"><code>*b</code></em>.
</p>
<p><code class="function">lwres_lwpacket_parseheader()</code>
performs the converse operation. It transfers data in network
byte order from buffer <em class="parameter"><code>*b</code></em> to resolver
packet <em class="parameter"><code>*pkt</code></em>. The contents of the buffer
<em class="parameter"><code>b</code></em> should correspond to a
<span class="type">lwres_lwpacket_t</span>.
</p>
</div>
<div class="refsect1" lang="en">
<a name="id2543706"></a><h2>RETURN VALUES</h2>
<p>
Successful calls to
<code class="function">lwres_lwpacket_renderheader()</code> and
<code class="function">lwres_lwpacket_parseheader()</code> return
<span class="errorcode">LWRES_R_SUCCESS</span>. If there is insufficient
space to copy data between the buffer <em class="parameter"><code>*b</code></em> and
lightweight resolver packet <em class="parameter"><code>*pkt</code></em> both
functions
return <span class="errorcode">LWRES_R_UNEXPECTEDEND</span>.
</p>
</div>
</div></body>
</html>