lwres_packet.docbook revision c1a883f2e04d94e99c433b1f6cfd0c0338f4ed85
0N/A<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
0N/A "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd"
0N/A [<!ENTITY mdash "&#8212;">]>
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 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.
873N/A-->
0N/A
0N/A<!-- $Id: lwres_packet.docbook,v 1.12 2007/01/29 23:57:22 marka Exp $ -->
0N/A<refentry>
0N/A
0N/A <refentryinfo>
868N/A <date>Jun 30, 2000</date>
0N/A </refentryinfo>
0N/A
0N/A <refmeta>
0N/A <refentrytitle>lwres_packet</refentrytitle>
0N/A <manvolnum>3</manvolnum>
0N/A <refmiscinfo>BIND9</refmiscinfo>
0N/A </refmeta>
0N/A
629N/A <docinfo>
629N/A <copyright>
338N/A <year>2004</year>
0N/A <year>2005</year>
0N/A <year>2007</year>
0N/A <holder>Internet Systems Consortium, Inc. ("ISC")</holder>
0N/A </copyright>
0N/A <copyright>
0N/A <year>2000</year>
0N/A <year>2001</year>
0N/A <holder>Internet Software Consortium.</holder>
0N/A </copyright>
0N/A </docinfo>
0N/A
0N/A <refnamediv>
0N/A <refname>lwres_lwpacket_renderheader</refname>
0N/A <refname>lwres_lwpacket_parseheader</refname>
629N/A <refpurpose>lightweight resolver packet handling functions</refpurpose>
629N/A </refnamediv>
629N/A <refsynopsisdiv>
629N/A <funcsynopsis>
629N/A<funcsynopsisinfo>#include &lt;lwres/lwpacket.h&gt;</funcsynopsisinfo>
0N/A<funcprototype>
0N/A <funcdef>
0N/Alwres_result_t
0N/A<function>lwres_lwpacket_renderheader</function></funcdef>
0N/A <paramdef>lwres_buffer_t *<parameter>b</parameter></paramdef>
0N/A <paramdef>lwres_lwpacket_t *<parameter>pkt</parameter></paramdef>
0N/A </funcprototype>
0N/A<funcprototype>
0N/A <funcdef>
0N/Alwres_result_t
0N/A<function>lwres_lwpacket_parseheader</function></funcdef>
0N/A <paramdef>lwres_buffer_t *<parameter>b</parameter></paramdef>
629N/A <paramdef>lwres_lwpacket_t *<parameter>pkt</parameter></paramdef>
0N/A </funcprototype>
0N/A</funcsynopsis>
0N/A </refsynopsisdiv>
0N/A <refsect1>
0N/A <title>DESCRIPTION</title>
0N/A <para>
0N/A These functions rely on a
0N/A <type>struct lwres_lwpacket</type>
0N/A which is defined in
0N/A <filename>lwres/lwpacket.h</filename>.
0N/A </para>
0N/A
0N/A <para><programlisting>
0N/Atypedef struct lwres_lwpacket lwres_lwpacket_t;
0N/A </programlisting>
0N/A </para>
0N/A <para><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</programlisting>
0N/A </para>
0N/A
0N/A <para>
0N/A The elements of this structure are:
0N/A <variablelist>
0N/A <varlistentry>
0N/A <term><constant>length</constant></term>
0N/A <listitem>
0N/A <para>
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 </para>
0N/A </listitem>
0N/A </varlistentry>
0N/A <varlistentry>
0N/A <term><constant>version</constant></term>
0N/A <listitem>
0N/A <para>
0N/A the header format. There is currently only one format,
629N/A <type>LWRES_LWPACKETVERSION_0</type>.
629N/A
629N/A This field is filled in by the lwres_gabn_*() and lwres_gnba_*()
629N/A calls.
629N/A </para>
629N/A </listitem>
629N/A </varlistentry>
629N/A <varlistentry>
629N/A <term><constant>pktflags</constant></term>
629N/A <listitem>
629N/A <para>
629N/A library-defined flags for this packet: for instance whether the
629N/A packet
629N/A is a request or a reply. Flag values can be set, but not defined
629N/A by
629N/A the caller.
629N/A This field is filled in by the application wit the exception of
629N/A the
629N/A LWRES_LWPACKETFLAG_RESPONSE bit, which is set by the library in
629N/A the
629N/A lwres_gabn_*() and lwres_gnba_*() calls.
629N/A </para>
629N/A </listitem>
629N/A </varlistentry>
629N/A <varlistentry>
629N/A <term><constant>serial</constant></term>
629N/A <listitem>
629N/A <para>
629N/A is set by the requestor and is returned in all replies. If two
629N/A or more
629N/A packets from the same source have the same serial number and are
629N/A from
629N/A the same source, they are assumed to be duplicates and the
629N/A latter ones
629N/A may be dropped.
629N/A This field must be set by the application.
629N/A </para>
629N/A </listitem>
0N/A </varlistentry>
0N/A <varlistentry>
0N/A <term><constant>opcode</constant></term>
0N/A <listitem>
0N/A <para>
0N/A indicates the operation.
0N/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.
0N/A </para>
0N/A </listitem>
0N/A </varlistentry>
0N/A <varlistentry>
0N/A <term><constant>result</constant></term>
0N/A <listitem>
0N/A <para>
629N/A is only valid for replies.
629N/A Results between 0x04000000 and 0xffffffff are application
629N/A defined.
629N/A Results between 0x00000000 and 0x03ffffff are reserved for
629N/A library use.
629N/A This field is filled in by the lwres_gabn_*() and lwres_gnba_*()
629N/A calls.
629N/A </para>
629N/A </listitem>
629N/A </varlistentry>
629N/A <varlistentry>
629N/A <term><constant>recvlength</constant></term>
629N/A <listitem>
629N/A <para>
629N/A is the maximum buffer size that the receiver can handle on
629N/A requests
629N/A and the size of the buffer needed to satisfy a request when the
629N/A buffer
629N/A is too large for replies.
629N/A This field is supplied by the application.
629N/A </para>
629N/A </listitem>
629N/A </varlistentry>
629N/A <varlistentry>
629N/A <term><constant>authtype</constant></term>
629N/A <listitem>
629N/A <para>
629N/A defines the packet level authentication that is used.
629N/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 </para>
0N/A </listitem>
0N/A </varlistentry>
0N/A <varlistentry>
0N/A <term><constant>authlen</constant></term>
0N/A <listitem>
0N/A <para>
0N/A gives the length of the authentication data.
0N/A Since packet authentication is currently not used, this must be
0N/A zero.
0N/A </para>
0N/A </listitem>
0N/A </varlistentry>
0N/A </variablelist>
0N/A </para>
0N/A <para>
0N/A The following opcodes are currently defined:
0N/A <variablelist>
0N/A <varlistentry>
0N/A <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.
</para>
</listitem>
</varlistentry>
<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.
</para>
</listitem>
</varlistentry>
<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>
</varlistentry>
</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>
</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><!--
- Local variables:
- mode: sgml
- End:
-->