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, 2014 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.
24 <date>June 18, 2007</date>
28 <refentrytitle>lwres_packet</refentrytitle>
29 <manvolnum>3</manvolnum>
30 <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 *<parameter>b</parameter></paramdef>
61 <paramdef>lwres_lwpacket_t *<parameter>pkt</parameter></paramdef>
66 <function>lwres_lwpacket_parseheader</function></funcdef>
67 <paramdef>lwres_buffer_t *<parameter>b</parameter></paramdef>
68 <paramdef>lwres_lwpacket_t *<parameter>pkt</parameter></paramdef>
73 <title>DESCRIPTION</title>
75 These functions rely on a
76 <type>struct lwres_lwpacket</type>
78 <filename>lwres/lwpacket.h</filename>.
81 <para><programlisting>
82 typedef struct lwres_lwpacket lwres_lwpacket_t;
85 <para><programlisting>
86 struct lwres_lwpacket {
87 lwres_uint32_t length;
88 lwres_uint16_t version;
89 lwres_uint16_t pktflags;
90 lwres_uint32_t serial;
91 lwres_uint32_t opcode;
92 lwres_uint32_t result;
93 lwres_uint32_t recvlength;
94 lwres_uint16_t authtype;
95 lwres_uint16_t authlength;
101 The elements of this structure are:
104 <term><constant>length</constant></term>
107 the overall packet length, including the entire packet header.
108 This field is filled in by the lwres_gabn_*() and lwres_gnba_*()
114 <term><constant>version</constant></term>
117 the header format. There is currently only one format,
118 <type>LWRES_LWPACKETVERSION_0</type>.
120 This field is filled in by the lwres_gabn_*() and lwres_gnba_*()
126 <term><constant>pktflags</constant></term>
129 library-defined flags for this packet: for instance whether the
131 is a request or a reply. Flag values can be set, but not defined
134 This field is filled in by the application wit the exception of
136 LWRES_LWPACKETFLAG_RESPONSE bit, which is set by the library in
138 lwres_gabn_*() and lwres_gnba_*() calls.
143 <term><constant>serial</constant></term>
146 is set by the requestor and is returned in all replies. If two
148 packets from the same source have the same serial number and are
150 the same source, they are assumed to be duplicates and the
153 This field must be set by the application.
158 <term><constant>opcode</constant></term>
161 indicates the operation.
162 Opcodes between 0x00000000 and 0x03ffffff are
163 reserved for use by the lightweight resolver library. Opcodes
165 0x04000000 and 0xffffffff are application defined.
166 This field is filled in by the lwres_gabn_*() and lwres_gnba_*()
172 <term><constant>result</constant></term>
175 is only valid for replies.
176 Results between 0x04000000 and 0xffffffff are application
178 Results between 0x00000000 and 0x03ffffff are reserved for
180 This field is filled in by the lwres_gabn_*() and lwres_gnba_*()
186 <term><constant>recvlength</constant></term>
189 is the maximum buffer size that the receiver can handle on
191 and the size of the buffer needed to satisfy a request when the
193 is too large for replies.
194 This field is supplied by the application.
199 <term><constant>authtype</constant></term>
202 defines the packet level authentication that is used.
203 Authorisation types between 0x1000 and 0xffff are application
205 and types between 0x0000 and 0x0fff are reserved for library
207 Currently these are not used and must be zero.
212 <term><constant>authlen</constant></term>
215 gives the length of the authentication data.
216 Since packet authentication is currently not used, this must be
224 The following opcodes are currently defined:
227 <term><constant>NOOP</constant></term>
230 Success is always returned and the packet contents are echoed.
231 The lwres_noop_*() functions should be used for this type.
236 <term><constant>GETADDRSBYNAME</constant></term>
239 returns all known addresses for a given name.
240 The lwres_gabn_*() functions should be used for this type.
245 <term><constant>GETNAMEBYADDR</constant></term>
248 return the hostname for the given address.
249 The lwres_gnba_*() functions should be used for this type.
256 <para><function>lwres_lwpacket_renderheader()</function>
257 transfers the contents of lightweight resolver packet structure
258 <type>lwres_lwpacket_t</type> <parameter>*pkt</parameter> in
259 network byte order to the lightweight resolver buffer,
260 <parameter>*b</parameter>.
263 <para><function>lwres_lwpacket_parseheader()</function>
264 performs the converse operation. It transfers data in network
265 byte order from buffer <parameter>*b</parameter> to resolver
266 packet <parameter>*pkt</parameter>. The contents of the buffer
267 <parameter>b</parameter> should correspond to a
268 <type>lwres_lwpacket_t</type>.
274 <title>RETURN VALUES</title>
277 <function>lwres_lwpacket_renderheader()</function> and
278 <function>lwres_lwpacket_parseheader()</function> return
279 <errorcode>LWRES_R_SUCCESS</errorcode>. If there is insufficient
280 space to copy data between the buffer <parameter>*b</parameter> and
281 lightweight resolver packet <parameter>*pkt</parameter> both
283 return <errorcode>LWRES_R_UNEXPECTEDEND</errorcode>.