1 <!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
2 "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd"
3 [<!ENTITY mdash "—">]>
5 - Copyright (C) 2004, 2005, 2007, 2012 Internet Systems Consortium, Inc. ("ISC")
6 - Copyright (C) 2000, 2001 Internet Software Consortium.
8 - Permission to use, copy, modify, and/or 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.
25 <date>Jun 30, 2000</date>
29 <refentrytitle>lwres_packet</refentrytitle>
30 <manvolnum>3</manvolnum>
31 <refmiscinfo>BIND9</refmiscinfo>
40 <holder>Internet Systems Consortium, Inc. ("ISC")</holder>
45 <holder>Internet Software Consortium.</holder>
50 <refname>lwres_lwpacket_renderheader</refname>
51 <refname>lwres_lwpacket_parseheader</refname>
52 <refpurpose>lightweight resolver packet handling functions</refpurpose>
56 <funcsynopsisinfo>#include <lwres/lwpacket.h></funcsynopsisinfo>
60 <function>lwres_lwpacket_renderheader</function></funcdef>
61 <paramdef>lwres_buffer_t *<parameter>b</parameter></paramdef>
62 <paramdef>lwres_lwpacket_t *<parameter>pkt</parameter></paramdef>
67 <function>lwres_lwpacket_parseheader</function></funcdef>
68 <paramdef>lwres_buffer_t *<parameter>b</parameter></paramdef>
69 <paramdef>lwres_lwpacket_t *<parameter>pkt</parameter></paramdef>
74 <title>DESCRIPTION</title>
76 These functions rely on a
77 <type>struct lwres_lwpacket</type>
79 <filename>lwres/lwpacket.h</filename>.
82 <para><programlisting>
83 typedef struct lwres_lwpacket lwres_lwpacket_t;
86 <para><programlisting>
87 struct lwres_lwpacket {
88 lwres_uint32_t length;
89 lwres_uint16_t version;
90 lwres_uint16_t pktflags;
91 lwres_uint32_t serial;
92 lwres_uint32_t opcode;
93 lwres_uint32_t result;
94 lwres_uint32_t recvlength;
95 lwres_uint16_t authtype;
96 lwres_uint16_t authlength;
102 The elements of this structure are:
105 <term><constant>length</constant></term>
108 the overall packet length, including the entire packet header.
109 This field is filled in by the lwres_gabn_*() and lwres_gnba_*()
115 <term><constant>version</constant></term>
118 the header format. There is currently only one format,
119 <type>LWRES_LWPACKETVERSION_0</type>.
121 This field is filled in by the lwres_gabn_*() and lwres_gnba_*()
127 <term><constant>pktflags</constant></term>
130 library-defined flags for this packet: for instance whether the
132 is a request or a reply. Flag values can be set, but not defined
135 This field is filled in by the application wit the exception of
137 LWRES_LWPACKETFLAG_RESPONSE bit, which is set by the library in
139 lwres_gabn_*() and lwres_gnba_*() calls.
144 <term><constant>serial</constant></term>
147 is set by the requestor and is returned in all replies. If two
149 packets from the same source have the same serial number and are
151 the same source, they are assumed to be duplicates and the
154 This field must be set by the application.
159 <term><constant>opcode</constant></term>
162 indicates the operation.
163 Opcodes between 0x00000000 and 0x03ffffff are
164 reserved for use by the lightweight resolver library. Opcodes
166 0x04000000 and 0xffffffff are application defined.
167 This field is filled in by the lwres_gabn_*() and lwres_gnba_*()
173 <term><constant>result</constant></term>
176 is only valid for replies.
177 Results between 0x04000000 and 0xffffffff are application
179 Results between 0x00000000 and 0x03ffffff are reserved for
181 This field is filled in by the lwres_gabn_*() and lwres_gnba_*()
187 <term><constant>recvlength</constant></term>
190 is the maximum buffer size that the receiver can handle on
192 and the size of the buffer needed to satisfy a request when the
194 is too large for replies.
195 This field is supplied by the application.
200 <term><constant>authtype</constant></term>
203 defines the packet level authentication that is used.
204 Authorisation types between 0x1000 and 0xffff are application
206 and types between 0x0000 and 0x0fff are reserved for library
208 Currently these are not used and must be zero.
213 <term><constant>authlen</constant></term>
216 gives the length of the authentication data.
217 Since packet authentication is currently not used, this must be
225 The following opcodes are currently defined:
228 <term><constant>NOOP</constant></term>
231 Success is always returned and the packet contents are echoed.
232 The lwres_noop_*() functions should be used for this type.
237 <term><constant>GETADDRSBYNAME</constant></term>
240 returns all known addresses for a given name.
241 The lwres_gabn_*() functions should be used for this type.
246 <term><constant>GETNAMEBYADDR</constant></term>
249 return the hostname for the given address.
250 The lwres_gnba_*() functions should be used for this type.
257 <para><function>lwres_lwpacket_renderheader()</function>
258 transfers the contents of lightweight resolver packet structure
259 <type>lwres_lwpacket_t</type> <parameter>*pkt</parameter> in
260 network byte order to the lightweight resolver buffer,
261 <parameter>*b</parameter>.
264 <para><function>lwres_lwpacket_parseheader()</function>
265 performs the converse operation. It transfers data in network
266 byte order from buffer <parameter>*b</parameter> to resolver
267 packet <parameter>*pkt</parameter>. The contents of the buffer
268 <parameter>b</parameter> should correspond to a
269 <type>lwres_lwpacket_t</type>.
275 <title>RETURN VALUES</title>
278 <function>lwres_lwpacket_renderheader()</function> and
279 <function>lwres_lwpacket_parseheader()</function> return
280 <errorcode>LWRES_R_SUCCESS</errorcode>. If there is insufficient
281 space to copy data between the buffer <parameter>*b</parameter> and
282 lightweight resolver packet <parameter>*pkt</parameter> both
284 return <errorcode>LWRES_R_UNEXPECTEDEND</errorcode>.