1 <!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.0//EN"
2 "http://www.oasis-open.org/docbook/xml/4.0/docbookx.dtd"
3 [<!ENTITY mdash "—">]>
5 - Copyright (C) 2004, 2005 Internet Systems Consortium, Inc. ("ISC")
6 - Copyright (C) 2000, 2001 Internet Software Consortium.
8 - Permission to use, copy, modify, and distribute this software for any
9 - purpose with or without fee is hereby granted, provided that the above
10 - copyright notice and this permission notice appear in all copies.
12 - THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
13 - REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
14 - AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
15 - INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
16 - LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
17 - OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
18 - PERFORMANCE OF THIS SOFTWARE.
21 <!-- $Id: lwres_packet.docbook,v 1.6.206.3 2005/05/12 21:36:16 sra Exp $ -->
26 <date>Jun 30, 2000</date>
30 <refentrytitle>lwres_packet</refentrytitle>
31 <manvolnum>3</manvolnum>
32 <refmiscinfo>BIND9</refmiscinfo>
39 <holder>Internet Systems Consortium, Inc. ("ISC")</holder>
44 <holder>Internet Software Consortium.</holder>
49 <refname>lwres_lwpacket_renderheader</refname>
50 <refname>lwres_lwpacket_parseheader</refname>
51 <refpurpose>lightweight resolver packet handling functions</refpurpose>
55 <funcsynopsisinfo>#include <lwres/lwpacket.h></funcsynopsisinfo>
59 <function>lwres_lwpacket_renderheader</function></funcdef>
60 <paramdef>lwres_buffer_t *b</paramdef>
61 <paramdef>lwres_lwpacket_t *pkt</paramdef>
66 <function>lwres_lwpacket_parseheader</function></funcdef>
67 <paramdef>lwres_buffer_t *b</paramdef>
68 <paramdef>lwres_lwpacket_t *pkt</paramdef>
73 <title>DESCRIPTION</title>
75 These functions rely on a
76 <type>struct lwres_lwpacket</type>
78 <filename>lwres/lwpacket.h</filename>.
81 typedef struct lwres_lwpacket lwres_lwpacket_t;
83 struct lwres_lwpacket {
84 lwres_uint32_t length;
85 lwres_uint16_t version;
86 lwres_uint16_t pktflags;
87 lwres_uint32_t serial;
88 lwres_uint32_t opcode;
89 lwres_uint32_t result;
90 lwres_uint32_t recvlength;
91 lwres_uint16_t authtype;
92 lwres_uint16_t authlength;
98 The elements of this structure are:
100 <varlistentry><term><constant>length</constant></term>
103 the overall packet length, including the entire packet header.
104 This field is filled in by the lwres_gabn_*() and lwres_gnba_*()
106 </para></listitem></varlistentry>
107 <varlistentry><term><constant>version</constant></term>
110 the header format. There is currently only one format,
111 <type>LWRES_LWPACKETVERSION_0</type>.
113 This field is filled in by the lwres_gabn_*() and lwres_gnba_*()
115 </para></listitem></varlistentry>
116 <varlistentry><term><constant>pktflags</constant></term>
119 library-defined flags for this packet: for instance whether the packet
120 is a request or a reply. Flag values can be set, but not defined by
122 This field is filled in by the application wit the exception of the
123 LWRES_LWPACKETFLAG_RESPONSE bit, which is set by the library in the
124 lwres_gabn_*() and lwres_gnba_*() calls.
125 </para></listitem></varlistentry>
126 <varlistentry><term><constant>serial</constant></term>
129 is set by the requestor and is returned in all replies. If two or more
130 packets from the same source have the same serial number and are from
131 the same source, they are assumed to be duplicates and the latter ones
133 This field must be set by the application.
134 </para></listitem></varlistentry>
135 <varlistentry><term><constant>opcode</constant></term>
138 indicates the operation.
139 Opcodes between 0x00000000 and 0x03ffffff are
140 reserved for use by the lightweight resolver library. Opcodes between
141 0x04000000 and 0xffffffff are application defined.
142 This field is filled in by the lwres_gabn_*() and lwres_gnba_*()
144 </para></listitem></varlistentry>
145 <varlistentry><term><constant>result</constant></term>
148 is only valid for replies.
149 Results between 0x04000000 and 0xffffffff are application defined.
150 Results between 0x00000000 and 0x03ffffff are reserved for library use.
151 This field is filled in by the lwres_gabn_*() and lwres_gnba_*()
153 </para></listitem></varlistentry>
154 <varlistentry><term><constant>recvlength</constant></term>
157 is the maximum buffer size that the receiver can handle on requests
158 and the size of the buffer needed to satisfy a request when the buffer
159 is too large for replies.
160 This field is supplied by the application.
161 </para></listitem></varlistentry>
162 <varlistentry><term><constant>authtype</constant></term>
165 defines the packet level authentication that is used.
166 Authorisation types between 0x1000 and 0xffff are application defined
167 and types between 0x0000 and 0x0fff are reserved for library use.
168 Currently these are not used and must be zero.
169 </para></listitem></varlistentry>
170 <varlistentry><term><constant>authlen</constant></term>
173 gives the length of the authentication data.
174 Since packet authentication is currently not used, this must be zero.
175 </para></listitem></varlistentry>
179 The following opcodes are currently defined:
181 <varlistentry><term><constant>NOOP</constant></term>
184 Success is always returned and the packet contents are echoed.
185 The lwres_noop_*() functions should be used for this type.
186 </para></listitem></varlistentry>
187 <varlistentry><term><constant>GETADDRSBYNAME</constant></term>
190 returns all known addresses for a given name.
191 The lwres_gabn_*() functions should be used for this type.
192 </para></listitem></varlistentry>
193 <varlistentry><term><constant>GETNAMEBYADDR</constant></term>
196 return the hostname for the given address.
197 The lwres_gnba_*() functions should be used for this type.
198 </para></listitem></varlistentry>
203 <function>lwres_lwpacket_renderheader()</function> transfers the
204 contents of lightweight resolver packet structure
205 <type>lwres_lwpacket_t</type> <parameter>*pkt</parameter> in network
206 byte order to the lightweight resolver buffer,
207 <parameter>*b</parameter>.
211 <function>lwres_lwpacket_parseheader()</function> performs the
212 converse operation. It transfers data in network byte order from
213 buffer <parameter>*b</parameter> to resolver packet
214 <parameter>*pkt</parameter>. The contents of the buffer
215 <parameter>b</parameter> should correspond to a
216 <type>lwres_lwpacket_t</type>.
222 <title>RETURN VALUES</title>
223 <para> Successful calls to
224 <function>lwres_lwpacket_renderheader()</function> and
225 <function>lwres_lwpacket_parseheader()</function> return
226 <errorcode>LWRES_R_SUCCESS</errorcode>. If there is insufficient
227 space to copy data between the buffer <parameter>*b</parameter> and
228 lightweight resolver packet <parameter>*pkt</parameter> both functions
229 return <errorcode>LWRES_R_UNEXPECTEDEND</errorcode>.