]> git.ipfire.org Git - thirdparty/strongswan.git/blob - lib/liblwres/man/lwres_packet.docbook
- import of strongswan-2.7.0
[thirdparty/strongswan.git] / lib / liblwres / man / lwres_packet.docbook
1 <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook V4.1//EN">
2 <!--
3 - Copyright (C) 2001 Internet Software Consortium.
4 -
5 - Permission to use, copy, modify, and distribute this software for any
6 - purpose with or without fee is hereby granted, provided that the above
7 - copyright notice and this permission notice appear in all copies.
8 -
9 - THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM
10 - DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
11 - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
12 - INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
13 - INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
14 - FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
15 - NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
16 - WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 -->
18
19 <!-- $Id: lwres_packet.docbook,v 1.1 2004/03/15 20:35:25 as Exp $ -->
20
21 <refentry>
22
23 <refentryinfo>
24 <date>Jun 30, 2000</date>
25 </refentryinfo>
26
27 <refmeta>
28 <refentrytitle>lwres_packet</refentrytitle>
29 <manvolnum>3</manvolnum>
30 <refmiscinfo>BIND9</refmiscinfo>
31 </refmeta>
32
33 <refnamediv>
34 <refname>lwres_lwpacket_renderheader</refname>
35 <refname>lwres_lwpacket_parseheader</refname>
36 <refpurpose>lightweight resolver packet handling functions</refpurpose>
37 </refnamediv>
38 <refsynopsisdiv>
39 <funcsynopsis>
40 <funcsynopsisinfo>#include &lt;lwres/lwpacket.h&gt;</funcsynopsisinfo>
41 <funcprototype>
42 <funcdef>
43 lwres_result_t
44 <function>lwres_lwpacket_renderheader</function></funcdef>
45 <paramdef>lwres_buffer_t *b</paramdef>
46 <paramdef>lwres_lwpacket_t *pkt</paramdef>
47 </funcprototype>
48 <funcprototype>
49 <funcdef>
50 lwres_result_t
51 <function>lwres_lwpacket_parseheader</function></funcdef>
52 <paramdef>lwres_buffer_t *b</paramdef>
53 <paramdef>lwres_lwpacket_t *pkt</paramdef>
54 </funcprototype>
55 </funcsynopsis>
56 </refsynopsisdiv>
57 <refsect1>
58 <title>DESCRIPTION</title>
59 <para>
60 These functions rely on a
61 <type>struct lwres_lwpacket</type>
62 which is defined in
63 <filename>lwres/lwpacket.h</filename>.
64
65 <programlisting>
66 typedef struct lwres_lwpacket lwres_lwpacket_t;
67
68 struct lwres_lwpacket {
69 lwres_uint32_t length;
70 lwres_uint16_t version;
71 lwres_uint16_t pktflags;
72 lwres_uint32_t serial;
73 lwres_uint32_t opcode;
74 lwres_uint32_t result;
75 lwres_uint32_t recvlength;
76 lwres_uint16_t authtype;
77 lwres_uint16_t authlength;
78 };
79 </programlisting>
80 </para>
81
82 <para>
83 The elements of this structure are:
84 <variablelist>
85 <varlistentry><term><constant>length</constant></term>
86 <listitem>
87 <para>
88 the overall packet length, including the entire packet header.
89 This field is filled in by the lwres_gabn_*() and lwres_gnba_*()
90 calls.
91 </para></listitem></varlistentry>
92 <varlistentry><term><constant>version</constant></term>
93 <listitem>
94 <para>
95 the header format. There is currently only one format,
96 <type>LWRES_LWPACKETVERSION_0</type>.
97
98 This field is filled in by the lwres_gabn_*() and lwres_gnba_*()
99 calls.
100 </para></listitem></varlistentry>
101 <varlistentry><term><constant>pktflags</constant></term>
102 <listitem>
103 <para>
104 library-defined flags for this packet: for instance whether the packet
105 is a request or a reply. Flag values can be set, but not defined by
106 the caller.
107 This field is filled in by the application wit the exception of the
108 LWRES_LWPACKETFLAG_RESPONSE bit, which is set by the library in the
109 lwres_gabn_*() and lwres_gnba_*() calls.
110 </para></listitem></varlistentry>
111 <varlistentry><term><constant>serial</constant></term>
112 <listitem>
113 <para>
114 is set by the requestor and is returned in all replies. If two or more
115 packets from the same source have the same serial number and are from
116 the same source, they are assumed to be duplicates and the latter ones
117 may be dropped.
118 This field must be set by the application.
119 </para></listitem></varlistentry>
120 <varlistentry><term><constant>opcode</constant></term>
121 <listitem>
122 <para>
123 indicates the operation.
124 Opcodes between 0x00000000 and 0x03ffffff are
125 reserved for use by the lightweight resolver library. Opcodes between
126 0x04000000 and 0xffffffff are application defined.
127 This field is filled in by the lwres_gabn_*() and lwres_gnba_*()
128 calls.
129 </para></listitem></varlistentry>
130 <varlistentry><term><constant>result</constant></term>
131 <listitem>
132 <para>
133 is only valid for replies.
134 Results between 0x04000000 and 0xffffffff are application defined.
135 Results between 0x00000000 and 0x03ffffff are reserved for library use.
136 This field is filled in by the lwres_gabn_*() and lwres_gnba_*()
137 calls.
138 </para></listitem></varlistentry>
139 <varlistentry><term><constant>recvlength</constant></term>
140 <listitem>
141 <para>
142 is the maximum buffer size that the receiver can handle on requests
143 and the size of the buffer needed to satisfy a request when the buffer
144 is too large for replies.
145 This field is supplied by the application.
146 </para></listitem></varlistentry>
147 <varlistentry><term><constant>authtype</constant></term>
148 <listitem>
149 <para>
150 defines the packet level authentication that is used.
151 Authorisation types between 0x1000 and 0xffff are application defined
152 and types between 0x0000 and 0x0fff are reserved for library use.
153 Currently these are not used and must be zero.
154 </para></listitem></varlistentry>
155 <varlistentry><term><constant>authlen</constant></term>
156 <listitem>
157 <para>
158 gives the length of the authentication data.
159 Since packet authentication is currently not used, this must be zero.
160 </para></listitem></varlistentry>
161 </variablelist>
162 </para>
163 <para>
164 The following opcodes are currently defined:
165 <variablelist>
166 <varlistentry><term><constant>NOOP</constant></term>
167 <listitem>
168 <para>
169 Success is always returned and the packet contents are echoed.
170 The lwres_noop_*() functions should be used for this type.
171 </para></listitem></varlistentry>
172 <varlistentry><term><constant>GETADDRSBYNAME</constant></term>
173 <listitem>
174 <para>
175 returns all known addresses for a given name.
176 The lwres_gabn_*() functions should be used for this type.
177 </para></listitem></varlistentry>
178 <varlistentry><term><constant>GETNAMEBYADDR</constant></term>
179 <listitem>
180 <para>
181 return the hostname for the given address.
182 The lwres_gnba_*() functions should be used for this type.
183 </para></listitem></varlistentry>
184 </variablelist>
185 </para>
186
187 <para>
188 <function>lwres_lwpacket_renderheader()</function> transfers the
189 contents of lightweight resolver packet structure
190 <type>lwres_lwpacket_t</type> <parameter>*pkt</parameter> in network
191 byte order to the lightweight resolver buffer,
192 <parameter>*b</parameter>.
193 </para>
194
195 <para>
196 <function>lwres_lwpacket_parseheader()</function> performs the
197 converse operation. It transfers data in network byte order from
198 buffer <parameter>*b</parameter> to resolver packet
199 <parameter>*pkt</parameter>. The contents of the buffer
200 <parameter>b</parameter> should correspond to a
201 <type>lwres_lwpacket_t</type>.
202 </para>
203
204 </refsect1>
205
206 <refsect1>
207 <title>RETURN VALUES</title>
208 <para> Successful calls to
209 <function>lwres_lwpacket_renderheader()</function> and
210 <function>lwres_lwpacket_parseheader()</function> return
211 <errorcode>LWRES_R_SUCCESS</errorcode>. If there is insufficient
212 space to copy data between the buffer <parameter>*b</parameter> and
213 lightweight resolver packet <parameter>*pkt</parameter> both functions
214 return <errorcode>LWRES_R_UNEXPECTEDEND</errorcode>.
215 </para>
216
217 </refsect1>
218 </refentry>