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