lwres_packet.html revision cedb0bd0c1e3c461b7e479a16d3adfd5b150f1f4
1245N/A<!--
2362N/A - Copyright (C) 2004, 2005 Internet Systems Consortium, Inc. ("ISC")
1245N/A - Copyright (C) 2000, 2001 Internet Software Consortium.
1245N/A -
1245N/A - Permission to use, copy, modify, and distribute this software for any
1245N/A - purpose with or without fee is hereby granted, provided that the above
2362N/A - copyright notice and this permission notice appear in all copies.
1245N/A -
2362N/A - THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
1245N/A - REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
1245N/A - AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
1245N/A - INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
1245N/A - LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
1245N/A - OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
1245N/A - PERFORMANCE OF THIS SOFTWARE.
1245N/A-->
1245N/A<!-- $Id: lwres_packet.html,v 1.21 2005/10/13 03:14:02 marka Exp $ -->
1245N/A<html>
1245N/A<head>
1245N/A<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
2362N/A<title>lwres_packet</title>
2362N/A<meta name="generator" content="DocBook XSL Stylesheets V1.69.1">
2362N/A</head>
1245N/A<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="refentry" lang="en">
1245N/A<a name="id2463721"></a><div class="titlepage"></div>
1245N/A<div class="refnamediv">
1245N/A<h2>Name</h2>
1245N/A<p>lwres_lwpacket_renderheader, lwres_lwpacket_parseheader &#8212; lightweight resolver packet handling functions</p>
1245N/A</div>
1245N/A<div class="refsynopsisdiv">
1245N/A<h2>Synopsis</h2>
1245N/A<div class="funcsynopsis">
1245N/A<pre class="funcsynopsisinfo">#include &lt;lwres/lwpacket.h&gt;</pre>
1245N/A<table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" style="padding-bottom: 1em">
1245N/A<tr>
1245N/A<td><code class="funcdef">
1245N/Alwres_result_t
1245N/A<b class="fsfunc">lwres_lwpacket_renderheader</b>(</code></td>
1245N/A<td>lwres_buffer_t *�</td>
1245N/A<td>
1245N/A<var class="pdparam">b</var>, </td>
1245N/A</tr>
1245N/A<tr>
1245N/A<td>�</td>
1245N/A<td>lwres_lwpacket_t *�</td>
1245N/A<td>
1245N/A<var class="pdparam">pkt</var><code>)</code>;</td>
1245N/A</tr>
1245N/A</table>
1245N/A<table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0">
1245N/A<tr>
1245N/A<td><code class="funcdef">
1245N/Alwres_result_t
1245N/A<b class="fsfunc">lwres_lwpacket_parseheader</b>(</code></td>
1245N/A<td>lwres_buffer_t *�</td>
1245N/A<td>
1245N/A<var class="pdparam">b</var>, </td>
1245N/A</tr>
1245N/A<tr>
1245N/A<td>�</td>
1245N/A<td>lwres_lwpacket_t *�</td>
1245N/A<td>
1245N/A<var class="pdparam">pkt</var><code>)</code>;</td>
1245N/A</tr>
1245N/A</table>
1245N/A</div>
1245N/A</div>
1245N/A<div class="refsect1" lang="en">
1245N/A<a name="id2525882"></a><h2>DESCRIPTION</h2>
1245N/A<p>
1245N/A These functions rely on a
1245N/A <span class="type">struct lwres_lwpacket</span>
1245N/A which is defined in
1245N/A <code class="filename">lwres/lwpacket.h</code>.
1245N/A </p>
1245N/A<pre class="programlisting">
1245N/Atypedef struct lwres_lwpacket lwres_lwpacket_t;
1245N/A </pre>
1245N/A<p>
1245N/A </p>
1245N/A<pre class="programlisting">
1245N/Astruct lwres_lwpacket {
1245N/A lwres_uint32_t length;
1245N/A lwres_uint16_t version;
1245N/A lwres_uint16_t pktflags;
1245N/A lwres_uint32_t serial;
1245N/A lwres_uint32_t opcode;
1245N/A lwres_uint32_t result;
1245N/A lwres_uint32_t recvlength;
1245N/A lwres_uint16_t authtype;
1245N/A lwres_uint16_t authlength;
1245N/A};
1245N/A</pre>
1245N/A<p>
1245N/A </p>
1245N/A<p>
1245N/A The elements of this structure are:
1245N/A </p>
1245N/A<div class="variablelist"><dl>
1245N/A<dt><span class="term"><code class="constant">length</code></span></dt>
1245N/A<dd><p>
1245N/A the overall packet length, including the entire packet header.
1245N/A This field is filled in by the lwres_gabn_*() and lwres_gnba_*()
1245N/A calls.
1245N/A </p></dd>
1245N/A<dt><span class="term"><code class="constant">version</code></span></dt>
1245N/A<dd><p>
1245N/A the header format. There is currently only one format,
1245N/A <span class="type">LWRES_LWPACKETVERSION_0</span>.
1245N/A
1245N/A This field is filled in by the lwres_gabn_*() and lwres_gnba_*()
1245N/A calls.
1245N/A </p></dd>
1245N/A<dt><span class="term"><code class="constant">pktflags</code></span></dt>
1245N/A<dd><p>
1245N/A library-defined flags for this packet: for instance whether the
1245N/A packet
1245N/A is a request or a reply. Flag values can be set, but not defined
1245N/A by
1245N/A the caller.
1245N/A This field is filled in by the application wit the exception of
1245N/A the
1245N/A LWRES_LWPACKETFLAG_RESPONSE bit, which is set by the library in
1245N/A the
1245N/A lwres_gabn_*() and lwres_gnba_*() calls.
1245N/A </p></dd>
1245N/A<dt><span class="term"><code class="constant">serial</code></span></dt>
1245N/A<dd><p>
1245N/A is set by the requestor and is returned in all replies. If two
1245N/A or more
1245N/A packets from the same source have the same serial number and are
1245N/A from
1245N/A the same source, they are assumed to be duplicates and the
1245N/A latter ones
1245N/A may be dropped.
1245N/A This field must be set by the application.
1245N/A </p></dd>
1245N/A<dt><span class="term"><code class="constant">opcode</code></span></dt>
<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="id2526199"></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>