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