lwres_packet.docbook revision 8eea877894ea5bcf5cdd9ca124a8601ad421d753
ef604281b397eceb0d9f67b87378b7c0b751967dTrond Norbye<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook V4.1//EN">
ef604281b397eceb0d9f67b87378b7c0b751967dTrond Norbye<!--
ef604281b397eceb0d9f67b87378b7c0b751967dTrond Norbye - Copyright (C) 2001 Internet Software Consortium.
ef604281b397eceb0d9f67b87378b7c0b751967dTrond Norbye -
ef604281b397eceb0d9f67b87378b7c0b751967dTrond Norbye - Permission to use, copy, modify, and distribute this software for any
ef604281b397eceb0d9f67b87378b7c0b751967dTrond Norbye - purpose with or without fee is hereby granted, provided that the above
ef604281b397eceb0d9f67b87378b7c0b751967dTrond Norbye - copyright notice and this permission notice appear in all copies.
ef604281b397eceb0d9f67b87378b7c0b751967dTrond Norbye -
ef604281b397eceb0d9f67b87378b7c0b751967dTrond Norbye - THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM
ef604281b397eceb0d9f67b87378b7c0b751967dTrond Norbye - DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
ef604281b397eceb0d9f67b87378b7c0b751967dTrond Norbye - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
ef604281b397eceb0d9f67b87378b7c0b751967dTrond Norbye - INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
ef604281b397eceb0d9f67b87378b7c0b751967dTrond Norbye - INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
ef604281b397eceb0d9f67b87378b7c0b751967dTrond Norbye - FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
ef604281b397eceb0d9f67b87378b7c0b751967dTrond Norbye - NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
ef604281b397eceb0d9f67b87378b7c0b751967dTrond Norbye - WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
ef604281b397eceb0d9f67b87378b7c0b751967dTrond Norbye-->
ef604281b397eceb0d9f67b87378b7c0b751967dTrond Norbye
ef604281b397eceb0d9f67b87378b7c0b751967dTrond Norbye<!-- $Id: lwres_packet.docbook,v 1.4 2001/04/24 18:11:23 gson Exp $ -->
ef604281b397eceb0d9f67b87378b7c0b751967dTrond Norbye
ef604281b397eceb0d9f67b87378b7c0b751967dTrond Norbye<refentry>
ef604281b397eceb0d9f67b87378b7c0b751967dTrond Norbye<refentryinfo>
ef604281b397eceb0d9f67b87378b7c0b751967dTrond Norbye<date>Jun 30, 2000</date>
ef604281b397eceb0d9f67b87378b7c0b751967dTrond Norbye</refentryinfo>
5e43c87216dfeda97c475a542b371b958b13fed5Patrick Higgins<refmeta>
ef604281b397eceb0d9f67b87378b7c0b751967dTrond Norbye<refentrytitle>lwres_packet</refentrytitle>
ef604281b397eceb0d9f67b87378b7c0b751967dTrond Norbye<manvolnum>3</manvolnum>
ef604281b397eceb0d9f67b87378b7c0b751967dTrond Norbye<refmiscinfo>BIND9</refmiscinfo>
ef604281b397eceb0d9f67b87378b7c0b751967dTrond Norbye</refmeta>
ef604281b397eceb0d9f67b87378b7c0b751967dTrond Norbye<refnamediv>
ef604281b397eceb0d9f67b87378b7c0b751967dTrond Norbye<refname>lwres_lwpacket_renderheader</refname>
5e43c87216dfeda97c475a542b371b958b13fed5Patrick Higgins<refname>lwres_lwpacket_parseheader</refname>
5e43c87216dfeda97c475a542b371b958b13fed5Patrick Higgins<refpurpose>lightweight resolver packet handling functions</refpurpose>
5e43c87216dfeda97c475a542b371b958b13fed5Patrick Higgins</refnamediv>
5e43c87216dfeda97c475a542b371b958b13fed5Patrick Higgins<refsynopsisdiv>
5e43c87216dfeda97c475a542b371b958b13fed5Patrick Higgins<funcsynopsis>
5e43c87216dfeda97c475a542b371b958b13fed5Patrick Higgins<funcsynopsisinfo>#include &lt;lwres/lwpacket.h&gt;</funcsynopsisinfo>
5e43c87216dfeda97c475a542b371b958b13fed5Patrick Higgins<funcprototype>
5e43c87216dfeda97c475a542b371b958b13fed5Patrick Higgins<funcdef>
ef604281b397eceb0d9f67b87378b7c0b751967dTrond Norbyelwres_result_t
5e43c87216dfeda97c475a542b371b958b13fed5Patrick Higgins<function>lwres_lwpacket_renderheader</function></funcdef>
ef604281b397eceb0d9f67b87378b7c0b751967dTrond Norbye<paramdef>lwres_buffer_t *b</paramdef>
ef604281b397eceb0d9f67b87378b7c0b751967dTrond Norbye<paramdef>lwres_lwpacket_t *pkt</paramdef>
ef604281b397eceb0d9f67b87378b7c0b751967dTrond Norbye</funcprototype>
ef604281b397eceb0d9f67b87378b7c0b751967dTrond Norbye<funcprototype>
ef604281b397eceb0d9f67b87378b7c0b751967dTrond Norbye<funcdef>
ef604281b397eceb0d9f67b87378b7c0b751967dTrond Norbyelwres_result_t
ef604281b397eceb0d9f67b87378b7c0b751967dTrond Norbye<function>lwres_lwpacket_parseheader</function></funcdef>
ef604281b397eceb0d9f67b87378b7c0b751967dTrond Norbye<paramdef>lwres_buffer_t *b</paramdef>
ef604281b397eceb0d9f67b87378b7c0b751967dTrond Norbye<paramdef>lwres_lwpacket_t *pkt</paramdef>
ef604281b397eceb0d9f67b87378b7c0b751967dTrond Norbye</funcprototype>
ef604281b397eceb0d9f67b87378b7c0b751967dTrond Norbye</funcsynopsis>
ef604281b397eceb0d9f67b87378b7c0b751967dTrond Norbye</refsynopsisdiv>
ef604281b397eceb0d9f67b87378b7c0b751967dTrond Norbye<refsect1>
ef604281b397eceb0d9f67b87378b7c0b751967dTrond Norbye<title>DESCRIPTION</title>
ef604281b397eceb0d9f67b87378b7c0b751967dTrond Norbye<para>
ef604281b397eceb0d9f67b87378b7c0b751967dTrond NorbyeThese functions rely on a
ef604281b397eceb0d9f67b87378b7c0b751967dTrond Norbye<type>struct lwres_lwpacket</type>
ef604281b397eceb0d9f67b87378b7c0b751967dTrond Norbyewhich is defined in
ef604281b397eceb0d9f67b87378b7c0b751967dTrond Norbye<filename>lwres/lwpacket.h</filename>.
ef604281b397eceb0d9f67b87378b7c0b751967dTrond Norbye
ef604281b397eceb0d9f67b87378b7c0b751967dTrond Norbye<programlisting>
ef604281b397eceb0d9f67b87378b7c0b751967dTrond Norbyetypedef struct lwres_lwpacket lwres_lwpacket_t;
ef604281b397eceb0d9f67b87378b7c0b751967dTrond Norbye
ef604281b397eceb0d9f67b87378b7c0b751967dTrond Norbyestruct lwres_lwpacket {
ef604281b397eceb0d9f67b87378b7c0b751967dTrond Norbye lwres_uint32_t length;
ef604281b397eceb0d9f67b87378b7c0b751967dTrond Norbye lwres_uint16_t version;
ef604281b397eceb0d9f67b87378b7c0b751967dTrond Norbye lwres_uint16_t pktflags;
138a7fea383af1a9084b7ec66d309d1cbc43d5f6Chris Eldredge lwres_uint32_t serial;
ef604281b397eceb0d9f67b87378b7c0b751967dTrond Norbye lwres_uint32_t opcode;
ef604281b397eceb0d9f67b87378b7c0b751967dTrond Norbye lwres_uint32_t result;
138a7fea383af1a9084b7ec66d309d1cbc43d5f6Chris Eldredge lwres_uint32_t recvlength;
138a7fea383af1a9084b7ec66d309d1cbc43d5f6Chris Eldredge lwres_uint16_t authtype;
138a7fea383af1a9084b7ec66d309d1cbc43d5f6Chris Eldredge lwres_uint16_t authlength;
138a7fea383af1a9084b7ec66d309d1cbc43d5f6Chris Eldredge};
138a7fea383af1a9084b7ec66d309d1cbc43d5f6Chris Eldredge</programlisting>
138a7fea383af1a9084b7ec66d309d1cbc43d5f6Chris Eldredge</para>
138a7fea383af1a9084b7ec66d309d1cbc43d5f6Chris Eldredge<para>
138a7fea383af1a9084b7ec66d309d1cbc43d5f6Chris Eldredge</para>
138a7fea383af1a9084b7ec66d309d1cbc43d5f6Chris Eldredge<para>
138a7fea383af1a9084b7ec66d309d1cbc43d5f6Chris EldredgeThe elements of this structure are:
138a7fea383af1a9084b7ec66d309d1cbc43d5f6Chris Eldredge<variablelist>
138a7fea383af1a9084b7ec66d309d1cbc43d5f6Chris Eldredge<varlistentry><term><constant>length</constant></term>
138a7fea383af1a9084b7ec66d309d1cbc43d5f6Chris Eldredge<listitem>
ef604281b397eceb0d9f67b87378b7c0b751967dTrond Norbye<para>
ef604281b397eceb0d9f67b87378b7c0b751967dTrond Norbyethe overall packet length, including the entire packet header.
This field is filled in by the lwres_gabn_*() and lwres_gnba_*()
calls.
</listitem>
<varlistentry><term><constant>version</constant></term>
<listitem>
<para>
the header format. There is currently only one format,
<type>LWRES_LWPACKETVERSION_0</type>.
This field is filled in by the lwres_gabn_*() and lwres_gnba_*()
calls.
</listitem>
<varlistentry><term><constant>pktflags</constant></term>
<listitem>
<para>
library-defined flags for this packet: for instance whether the packet
is a request or a reply. Flag values can be set, but not defined by
the caller.
This field is filled in by the application wit the exception of the
LWRES_LWPACKETFLAG_RESPONSE bit, which is set by the library in the
lwres_gabn_*() and lwres_gnba_*() calls.
</listitem>
<varlistentry><term><constant>serial</constant></term>
<listitem>
<para>
is set by the requestor and is returned in all replies. If two or more
packets from the same source have the same serial number and are from
the same source, they are assumed to be duplicates and the latter ones
may be dropped.
This field must be set by the application.
</listitem>
<varlistentry><term><constant>opcode</constant></term>
<listitem>
<para>
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.
</listitem>
<varlistentry><term><constant>result</constant></term>
<listitem>
<para>
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.
</listitem>
<varlistentry><term><constant>recvlength</constant></term>
<listitem>
<para>
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.
</listitem>
<varlistentry><term><constant>authtype</constant></term>
<listitem>
<para>
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.
</listitem>
<varlistentry><term><constant>authlen</constant></term>
<listitem>
<para>
gives the length of the authentication data.
Since packet authentication is currently not used, this must be zero.
</para>
</listitem>
</variablelist>
</para>
<para>
The following opcodes are currently defined:
<variablelist>
<varlistentry><term><constant>NOOP</constant></term>
<listitem>
<para>
Success is always returned and the packet contents are echoed.
The lwres_noop_*() functions should be used for this type.
</listitem>
<varlistentry><term><constant>GETADDRSBYNAME</constant></term>
<listitem>
<para>
returns all known addresses for a given name.
The lwres_gabn_*() functions should be used for this type.
</listitem>
<varlistentry><term><constant>GETNAMEBYADDR</constant></term>
<listitem>
<para>
return the hostname for the given address.
The lwres_gnba_*() functions should be used for this type.
</para>
</listitem>
</variablelist>
</para>
<para>
<function>lwres_lwpacket_renderheader()</function>
transfers the contents of lightweight resolver packet structure
<type>lwres_lwpacket_t</type>
<parameter>*pkt</parameter>
in network byte order to the lightweight resolver buffer,
<parameter>*b</parameter>.
</para>
<para>
<function>lwres_lwpacket_parseheader()</function>
performs the converse operation.
It transfers data in network byte order from buffer
<parameter>*b</parameter>
to resolver packet
<parameter>*pkt</parameter>.
The contents of the buffer
<parameter>b</parameter>
should correspond to a
<type>lwres_lwpacket_t</type>.
</para>
<para>
Both functions have assertion checks to ensure that
<parameter>b</parameter>
and
<parameter>pkt</parameter>
are not
<type>NULL</type>.
</para>
</refsect1>
<refsect1>
<title>RETURN VALUES</title>
<para>
Successful calls to
<function>lwres_lwpacket_renderheader()</function>
and
<function>lwres_lwpacket_parseheader()</function>
return
<errorcode>LWRES_R_SUCCESS</errorcode>.
If there is insufficient space to copy data between the buffer
<parameter>*b</parameter>
and lightweight resolver packet
<parameter>*pkt</parameter>
both functions return
<errorcode>LWRES_R_UNEXPECTEDEND</errorcode>.
</para>
</refsect1>
</refentry>