0N/A<!
DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN" 0N/A [<!ENTITY mdash "—">]>
0N/A - Copyright (C) 2004, 2005, 2007 Internet Systems Consortium, Inc. ("ISC") 0N/A - Copyright (C) 2000, 2001 Internet Software Consortium. 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 - 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. 868N/A <
date>Jun 30, 2000</
date>
0N/A <
refentrytitle>lwres_packet</
refentrytitle>
0N/A <
manvolnum>3</
manvolnum>
0N/A <
refmiscinfo>BIND9</
refmiscinfo>
0N/A <
holder>Internet Systems Consortium, Inc. ("ISC")</
holder>
0N/A <
holder>Internet Software Consortium.</
holder>
0N/A <
refname>lwres_lwpacket_renderheader</
refname>
0N/A <
refname>lwres_lwpacket_parseheader</
refname>
629N/A <
refpurpose>lightweight resolver packet handling functions</
refpurpose>
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<
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 <
title>DESCRIPTION</
title>
0N/A These functions rely on a
0N/A <
type>struct lwres_lwpacket</
type>
0N/A <
para><
programlisting>
0N/Atypedef struct lwres_lwpacket lwres_lwpacket_t;
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 The elements of this structure are:
0N/A <
term><
constant>length</
constant></
term>
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 <
term><
constant>version</
constant></
term>
0N/A the header format. There is currently only one format,
629N/A <
type>LWRES_LWPACKETVERSION_0</
type>.
629N/A This field is filled in by the lwres_gabn_*() and lwres_gnba_*()
629N/A <
term><
constant>pktflags</
constant></
term>
629N/A library-defined flags for this packet: for instance whether the
629N/A is a request or a reply. Flag values can be set, but not defined
629N/A This field is filled in by the application wit the exception of
629N/A LWRES_LWPACKETFLAG_RESPONSE bit, which is set by the library in
629N/A lwres_gabn_*() and lwres_gnba_*() calls.
629N/A <
term><
constant>serial</
constant></
term>
629N/A is set by the requestor and is returned in all replies. If two
629N/A packets from the same source have the same serial number and are
629N/A the same source, they are assumed to be duplicates and the
629N/A This field must be set by the application.
0N/A <
term><
constant>opcode</
constant></
term>
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 0x04000000 and 0xffffffff are application defined.
0N/A This field is filled in by the lwres_gabn_*() and lwres_gnba_*()
0N/A <
term><
constant>result</
constant></
term>
629N/A is only valid for replies.
629N/A Results between 0x04000000 and 0xffffffff are application
629N/A Results between 0x00000000 and 0x03ffffff are reserved for
629N/A This field is filled in by the lwres_gabn_*() and lwres_gnba_*()
629N/A <
term><
constant>recvlength</
constant></
term>
629N/A is the maximum buffer size that the receiver can handle on
629N/A and the size of the buffer needed to satisfy a request when the
629N/A is too large for replies.
629N/A This field is supplied by the application.
629N/A <
term><
constant>authtype</
constant></
term>
629N/A defines the packet level authentication that is used.
629N/A Authorisation types between 0x1000 and 0xffff are application
0N/A and types between 0x0000 and 0x0fff are reserved for library
0N/A Currently these are not used and must be zero.
0N/A <
term><
constant>authlen</
constant></
term>
0N/A gives the length of the authentication data.
0N/A Since packet authentication is currently not used, this must be
0N/A The following opcodes are currently defined:
0N/A <
term><
constant>NOOP</
constant></
term>
Success is always returned and the packet contents are echoed.
The lwres_noop_*() functions should be used for this type.
<
term><
constant>GETADDRSBYNAME</
constant></
term>
returns all known addresses for a given name.
The lwres_gabn_*() functions should be used for this type.
<
term><
constant>GETNAMEBYADDR</
constant></
term>
return the hostname for the given address.
The lwres_gnba_*() functions should be used for this type.
<
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><
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>.
<
title>RETURN VALUES</
title>
<
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
return <
errorcode>LWRES_R_UNEXPECTEDEND</
errorcode>.