lwres_packet.html revision 75c0816e8295e180f4bc7f10db3d0d880383bc1c
985687b4e080182c1a3a2173df02b94a5b78b24fBob Halley - Copyright (C) 2004, 2005 Internet Systems Consortium, Inc. ("ISC")
985687b4e080182c1a3a2173df02b94a5b78b24fBob Halley - Copyright (C) 2000, 2001 Internet Software Consortium.
985687b4e080182c1a3a2173df02b94a5b78b24fBob Halley - Permission to use, copy, modify, and distribute this software for any
985687b4e080182c1a3a2173df02b94a5b78b24fBob Halley - purpose with or without fee is hereby granted, provided that the above
985687b4e080182c1a3a2173df02b94a5b78b24fBob Halley - copyright notice and this permission notice appear in all copies.
985687b4e080182c1a3a2173df02b94a5b78b24fBob Halley - THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
985687b4e080182c1a3a2173df02b94a5b78b24fBob Halley - REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
985687b4e080182c1a3a2173df02b94a5b78b24fBob Halley - AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
985687b4e080182c1a3a2173df02b94a5b78b24fBob Halley - INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
985687b4e080182c1a3a2173df02b94a5b78b24fBob Halley - LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
985687b4e080182c1a3a2173df02b94a5b78b24fBob Halley - OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
985687b4e080182c1a3a2173df02b94a5b78b24fBob Halley - PERFORMANCE OF THIS SOFTWARE.
985687b4e080182c1a3a2173df02b94a5b78b24fBob Halley<!-- $Id: lwres_packet.html,v 1.17 2005/05/13 03:14:16 marka Exp $ -->
985687b4e080182c1a3a2173df02b94a5b78b24fBob Halley<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
904a5734375869ffb504ed8cde6b68cafadb6d64Bob Halley<meta name="generator" content="DocBook XSL Stylesheets V1.68.1">
985687b4e080182c1a3a2173df02b94a5b78b24fBob Halley<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="refentry" lang="en">
52637f592f705ca93fadc218e403fd55e8ce4aeaMark Andrews<a name="id2456836"></a><div class="titlepage"></div>
904a5734375869ffb504ed8cde6b68cafadb6d64Bob Halley<p>lwres_lwpacket_renderheader, lwres_lwpacket_parseheader — lightweight resolver packet handling functions</p>
52637f592f705ca93fadc218e403fd55e8ce4aeaMark Andrews<pre class="funcsynopsisinfo">#include <lwres/lwpacket.h></pre>
52637f592f705ca93fadc218e403fd55e8ce4aeaMark Andrews<table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" style="padding-bottom: 1em">
985687b4e080182c1a3a2173df02b94a5b78b24fBob Halleylwres_result_t
985687b4e080182c1a3a2173df02b94a5b78b24fBob Halley<b class="fsfunc">lwres_lwpacket_renderheader</b>(</code></td>
52637f592f705ca93fadc218e403fd55e8ce4aeaMark Andrews<var class="pdparam">pkt</var><code>)</code>;</td>
52637f592f705ca93fadc218e403fd55e8ce4aeaMark Andrews<table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0">
985687b4e080182c1a3a2173df02b94a5b78b24fBob Halleylwres_result_t
1ef8965366d91e02a4672c35a187d30aa4a4c72cMark Andrews<b class="fsfunc">lwres_lwpacket_parseheader</b>(</code></td>
52637f592f705ca93fadc218e403fd55e8ce4aeaMark Andrews<var class="pdparam">pkt</var><code>)</code>;</td>
52637f592f705ca93fadc218e403fd55e8ce4aeaMark Andrews These functions rely on a
52637f592f705ca93fadc218e403fd55e8ce4aeaMark Andrews <span class="type">struct lwres_lwpacket</span>
52637f592f705ca93fadc218e403fd55e8ce4aeaMark Andrews which is defined in
52637f592f705ca93fadc218e403fd55e8ce4aeaMark Andrews <code class="filename">lwres/lwpacket.h</code>.
52637f592f705ca93fadc218e403fd55e8ce4aeaMark Andrewstypedef struct lwres_lwpacket lwres_lwpacket_t;
52637f592f705ca93fadc218e403fd55e8ce4aeaMark Andrewsstruct lwres_lwpacket {
52637f592f705ca93fadc218e403fd55e8ce4aeaMark Andrews lwres_uint32_t length;
52637f592f705ca93fadc218e403fd55e8ce4aeaMark Andrews lwres_uint16_t version;
52637f592f705ca93fadc218e403fd55e8ce4aeaMark Andrews lwres_uint16_t pktflags;
52637f592f705ca93fadc218e403fd55e8ce4aeaMark Andrews lwres_uint32_t serial;
52637f592f705ca93fadc218e403fd55e8ce4aeaMark Andrews lwres_uint32_t opcode;
52637f592f705ca93fadc218e403fd55e8ce4aeaMark Andrews lwres_uint32_t result;
52637f592f705ca93fadc218e403fd55e8ce4aeaMark Andrews lwres_uint32_t recvlength;
52637f592f705ca93fadc218e403fd55e8ce4aeaMark Andrews lwres_uint16_t authtype;
52637f592f705ca93fadc218e403fd55e8ce4aeaMark Andrews lwres_uint16_t authlength;
52637f592f705ca93fadc218e403fd55e8ce4aeaMark Andrews The elements of this structure are:
52637f592f705ca93fadc218e403fd55e8ce4aeaMark Andrews<dt><span class="term"><code class="constant">length</code></span></dt>
52637f592f705ca93fadc218e403fd55e8ce4aeaMark Andrews the overall packet length, including the entire packet header.
52637f592f705ca93fadc218e403fd55e8ce4aeaMark Andrews This field is filled in by the lwres_gabn_*() and lwres_gnba_*()
52637f592f705ca93fadc218e403fd55e8ce4aeaMark Andrews<dt><span class="term"><code class="constant">version</code></span></dt>
52637f592f705ca93fadc218e403fd55e8ce4aeaMark Andrews the header format. There is currently only one format,
52637f592f705ca93fadc218e403fd55e8ce4aeaMark Andrews <span class="type">LWRES_LWPACKETVERSION_0</span>.
52637f592f705ca93fadc218e403fd55e8ce4aeaMark Andrews This field is filled in by the lwres_gabn_*() and lwres_gnba_*()
52637f592f705ca93fadc218e403fd55e8ce4aeaMark Andrews<dt><span class="term"><code class="constant">pktflags</code></span></dt>
52637f592f705ca93fadc218e403fd55e8ce4aeaMark Andrews library-defined flags for this packet: for instance whether the
52637f592f705ca93fadc218e403fd55e8ce4aeaMark Andrews is a request or a reply. Flag values can be set, but not defined
52637f592f705ca93fadc218e403fd55e8ce4aeaMark Andrews This field is filled in by the application wit the exception of
52637f592f705ca93fadc218e403fd55e8ce4aeaMark Andrews LWRES_LWPACKETFLAG_RESPONSE bit, which is set by the library in
52637f592f705ca93fadc218e403fd55e8ce4aeaMark Andrews lwres_gabn_*() and lwres_gnba_*() calls.
52637f592f705ca93fadc218e403fd55e8ce4aeaMark Andrews<dt><span class="term"><code class="constant">serial</code></span></dt>
52637f592f705ca93fadc218e403fd55e8ce4aeaMark Andrews is set by the requestor and is returned in all replies. If two
52637f592f705ca93fadc218e403fd55e8ce4aeaMark Andrews packets from the same source have the same serial number and are
52637f592f705ca93fadc218e403fd55e8ce4aeaMark Andrews the same source, they are assumed to be duplicates and the
52637f592f705ca93fadc218e403fd55e8ce4aeaMark Andrews may be dropped.
52637f592f705ca93fadc218e403fd55e8ce4aeaMark Andrews This field must be set by the application.
52637f592f705ca93fadc218e403fd55e8ce4aeaMark Andrews<dt><span class="term"><code class="constant">opcode</code></span></dt>
52637f592f705ca93fadc218e403fd55e8ce4aeaMark Andrews indicates the operation.
52637f592f705ca93fadc218e403fd55e8ce4aeaMark Andrews Opcodes between 0x00000000 and 0x03ffffff are
52637f592f705ca93fadc218e403fd55e8ce4aeaMark Andrews reserved for use by the lightweight resolver library. Opcodes
52637f592f705ca93fadc218e403fd55e8ce4aeaMark Andrews 0x04000000 and 0xffffffff are application defined.
52637f592f705ca93fadc218e403fd55e8ce4aeaMark Andrews This field is filled in by the lwres_gabn_*() and lwres_gnba_*()
52637f592f705ca93fadc218e403fd55e8ce4aeaMark Andrews<dt><span class="term"><code class="constant">result</code></span></dt>
52637f592f705ca93fadc218e403fd55e8ce4aeaMark Andrews is only valid for replies.
52637f592f705ca93fadc218e403fd55e8ce4aeaMark Andrews Results between 0x04000000 and 0xffffffff are application
52637f592f705ca93fadc218e403fd55e8ce4aeaMark Andrews Results between 0x00000000 and 0x03ffffff are reserved for
52637f592f705ca93fadc218e403fd55e8ce4aeaMark Andrews library use.
52637f592f705ca93fadc218e403fd55e8ce4aeaMark Andrews This field is filled in by the lwres_gabn_*() and lwres_gnba_*()
52637f592f705ca93fadc218e403fd55e8ce4aeaMark Andrews<dt><span class="term"><code class="constant">recvlength</code></span></dt>
52637f592f705ca93fadc218e403fd55e8ce4aeaMark Andrews is the maximum buffer size that the receiver can handle on
52637f592f705ca93fadc218e403fd55e8ce4aeaMark Andrews and the size of the buffer needed to satisfy a request when the
52637f592f705ca93fadc218e403fd55e8ce4aeaMark Andrews is too large for replies.
52637f592f705ca93fadc218e403fd55e8ce4aeaMark Andrews This field is supplied by the application.
52637f592f705ca93fadc218e403fd55e8ce4aeaMark Andrews<dt><span class="term"><code class="constant">authtype</code></span></dt>
52637f592f705ca93fadc218e403fd55e8ce4aeaMark Andrews defines the packet level authentication that is used.
52637f592f705ca93fadc218e403fd55e8ce4aeaMark Andrews Authorisation types between 0x1000 and 0xffff are application
52637f592f705ca93fadc218e403fd55e8ce4aeaMark Andrews and types between 0x0000 and 0x0fff are reserved for library
52637f592f705ca93fadc218e403fd55e8ce4aeaMark Andrews Currently these are not used and must be zero.
52637f592f705ca93fadc218e403fd55e8ce4aeaMark Andrews<dt><span class="term"><code class="constant">authlen</code></span></dt>
52637f592f705ca93fadc218e403fd55e8ce4aeaMark Andrews gives the length of the authentication data.
52637f592f705ca93fadc218e403fd55e8ce4aeaMark Andrews Since packet authentication is currently not used, this must be
52637f592f705ca93fadc218e403fd55e8ce4aeaMark Andrews The following opcodes are currently defined:
52637f592f705ca93fadc218e403fd55e8ce4aeaMark Andrews<dt><span class="term"><code class="constant">NOOP</code></span></dt>
52637f592f705ca93fadc218e403fd55e8ce4aeaMark Andrews Success is always returned and the packet contents are echoed.
52637f592f705ca93fadc218e403fd55e8ce4aeaMark Andrews The lwres_noop_*() functions should be used for this type.
52637f592f705ca93fadc218e403fd55e8ce4aeaMark Andrews<dt><span class="term"><code class="constant">GETADDRSBYNAME</code></span></dt>
52637f592f705ca93fadc218e403fd55e8ce4aeaMark Andrews returns all known addresses for a given name.
52637f592f705ca93fadc218e403fd55e8ce4aeaMark Andrews The lwres_gabn_*() functions should be used for this type.
52637f592f705ca93fadc218e403fd55e8ce4aeaMark Andrews<dt><span class="term"><code class="constant">GETNAMEBYADDR</code></span></dt>
52637f592f705ca93fadc218e403fd55e8ce4aeaMark Andrews return the hostname for the given address.
52637f592f705ca93fadc218e403fd55e8ce4aeaMark Andrews The lwres_gnba_*() functions should be used for this type.
52637f592f705ca93fadc218e403fd55e8ce4aeaMark Andrews<p><code class="function">lwres_lwpacket_renderheader()</code>
52637f592f705ca93fadc218e403fd55e8ce4aeaMark Andrews transfers the contents of lightweight resolver packet structure
52637f592f705ca93fadc218e403fd55e8ce4aeaMark Andrews <span class="type">lwres_lwpacket_t</span> <em class="parameter"><code>*pkt</code></em> in
52637f592f705ca93fadc218e403fd55e8ce4aeaMark Andrews network byte order to the lightweight resolver buffer,
52637f592f705ca93fadc218e403fd55e8ce4aeaMark Andrews<p><code class="function">lwres_lwpacket_parseheader()</code>
52637f592f705ca93fadc218e403fd55e8ce4aeaMark Andrews performs the converse operation. It transfers data in network
de10b83a231451e03d08b3293c503d11ea03a90bMark Andrews byte order from buffer <em class="parameter"><code>*b</code></em> to resolver
de10b83a231451e03d08b3293c503d11ea03a90bMark Andrews packet <em class="parameter"><code>*pkt</code></em>. The contents of the buffer
de10b83a231451e03d08b3293c503d11ea03a90bMark Andrews <em class="parameter"><code>b</code></em> should correspond to a
52637f592f705ca93fadc218e403fd55e8ce4aeaMark Andrews Successful calls to
52637f592f705ca93fadc218e403fd55e8ce4aeaMark Andrews <code class="function">lwres_lwpacket_renderheader()</code> and
52637f592f705ca93fadc218e403fd55e8ce4aeaMark Andrews <code class="function">lwres_lwpacket_parseheader()</code> return
c1e7aff941dbf40090fec49300e728ad017d4f0cMark Andrews <span class="errorcode">LWRES_R_SUCCESS</span>. If there is insufficient
52637f592f705ca93fadc218e403fd55e8ce4aeaMark Andrews space to copy data between the buffer <em class="parameter"><code>*b</code></em> and
52637f592f705ca93fadc218e403fd55e8ce4aeaMark Andrews lightweight resolver packet <em class="parameter"><code>*pkt</code></em> both
52637f592f705ca93fadc218e403fd55e8ce4aeaMark Andrews return <span class="errorcode">LWRES_R_UNEXPECTEDEND</span>.