2 - Copyright (C) 2004, 2005, 2007, 2014 Internet Systems Consortium, Inc. ("ISC")
3 - Copyright (C) 2000, 2001 Internet Software Consortium.
5 - Permission to use, copy, modify, and/or 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.
9 - THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
10 - REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
11 - AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
12 - INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
13 - LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
14 - OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15 - PERFORMANCE OF THIS SOFTWARE.
20 <meta http-equiv=
"Content-Type" content=
"text/html; charset=ISO-8859-1">
21 <title>lwres_packet
</title>
22 <meta name=
"generator" content=
"DocBook XSL Stylesheets V1.71.1">
24 <body bgcolor=
"white" text=
"black" link=
"#0000FF" vlink=
"#840084" alink=
"#0000FF"><div class=
"refentry" lang=
"en">
25 <a name=
"id2476275"></a><div class=
"titlepage"></div>
26 <div class=
"refnamediv">
28 <p>lwres_lwpacket_renderheader, lwres_lwpacket_parseheader
— lightweight resolver packet handling functions
</p>
30 <div class=
"refsynopsisdiv">
32 <div class=
"funcsynopsis">
33 <pre class=
"funcsynopsisinfo">#include
<lwres/lwpacket.h
></pre>
34 <table border=
"0" summary=
"Function synopsis" cellspacing=
"0" cellpadding=
"0" style=
"padding-bottom: 1em">
36 <td><code class=
"funcdef">
38 <b class=
"fsfunc">lwres_lwpacket_renderheader
</b>(
</code></td>
39 <td>lwres_buffer_t *
</td>
41 <var class=
"pdparam">b
</var>,
</td>
45 <td>lwres_lwpacket_t *
</td>
47 <var class=
"pdparam">pkt
</var><code>)
</code>;
</td>
50 <table border=
"0" summary=
"Function synopsis" cellspacing=
"0" cellpadding=
"0">
52 <td><code class=
"funcdef">
54 <b class=
"fsfunc">lwres_lwpacket_parseheader
</b>(
</code></td>
55 <td>lwres_buffer_t *
</td>
57 <var class=
"pdparam">b
</var>,
</td>
61 <td>lwres_lwpacket_t *
</td>
63 <var class=
"pdparam">pkt
</var><code>)
</code>;
</td>
68 <div class=
"refsect1" lang=
"en">
69 <a name=
"id2543399"></a><h2>DESCRIPTION
</h2>
71 These functions rely on a
72 <span class=
"type">struct lwres_lwpacket
</span>
74 <code class=
"filename">lwres/lwpacket.h
</code>.
76 <pre class=
"programlisting">
77 typedef struct lwres_lwpacket lwres_lwpacket_t;
81 <pre class=
"programlisting">
82 struct lwres_lwpacket {
83 lwres_uint32_t length;
84 lwres_uint16_t version;
85 lwres_uint16_t pktflags;
86 lwres_uint32_t serial;
87 lwres_uint32_t opcode;
88 lwres_uint32_t result;
89 lwres_uint32_t recvlength;
90 lwres_uint16_t authtype;
91 lwres_uint16_t authlength;
97 The elements of this structure are:
99 <div class=
"variablelist"><dl>
100 <dt><span class=
"term"><code class=
"constant">length
</code></span></dt>
102 the overall packet length, including the entire packet header.
103 This field is filled in by the lwres_gabn_*() and lwres_gnba_*()
106 <dt><span class=
"term"><code class=
"constant">version
</code></span></dt>
108 the header format. There is currently only one format,
109 <span class=
"type">LWRES_LWPACKETVERSION_0
</span>.
111 This field is filled in by the lwres_gabn_*() and lwres_gnba_*()
114 <dt><span class=
"term"><code class=
"constant">pktflags
</code></span></dt>
116 library-defined flags for this packet: for instance whether the
118 is a request or a reply. Flag values can be set, but not defined
121 This field is filled in by the application wit the exception of
123 LWRES_LWPACKETFLAG_RESPONSE bit, which is set by the library in
125 lwres_gabn_*() and lwres_gnba_*() calls.
127 <dt><span class=
"term"><code class=
"constant">serial
</code></span></dt>
129 is set by the requestor and is returned in all replies. If two
131 packets from the same source have the same serial number and are
133 the same source, they are assumed to be duplicates and the
136 This field must be set by the application.
138 <dt><span class=
"term"><code class=
"constant">opcode
</code></span></dt>
140 indicates the operation.
141 Opcodes between
0x00000000 and
0x03ffffff are
142 reserved for use by the lightweight resolver library. Opcodes
144 0x04000000 and
0xffffffff are application defined.
145 This field is filled in by the lwres_gabn_*() and lwres_gnba_*()
148 <dt><span class=
"term"><code class=
"constant">result
</code></span></dt>
150 is only valid for replies.
151 Results between
0x04000000 and
0xffffffff are application
153 Results between
0x00000000 and
0x03ffffff are reserved for
155 This field is filled in by the lwres_gabn_*() and lwres_gnba_*()
158 <dt><span class=
"term"><code class=
"constant">recvlength
</code></span></dt>
160 is the maximum buffer size that the receiver can handle on
162 and the size of the buffer needed to satisfy a request when the
164 is too large for replies.
165 This field is supplied by the application.
167 <dt><span class=
"term"><code class=
"constant">authtype
</code></span></dt>
169 defines the packet level authentication that is used.
170 Authorisation types between
0x1000 and
0xffff are application
172 and types between
0x0000 and
0x0fff are reserved for library
174 Currently these are not used and must be zero.
176 <dt><span class=
"term"><code class=
"constant">authlen
</code></span></dt>
178 gives the length of the authentication data.
179 Since packet authentication is currently not used, this must be
186 The following opcodes are currently defined:
188 <div class=
"variablelist"><dl>
189 <dt><span class=
"term"><code class=
"constant">NOOP
</code></span></dt>
191 Success is always returned and the packet contents are echoed.
192 The lwres_noop_*() functions should be used for this type.
194 <dt><span class=
"term"><code class=
"constant">GETADDRSBYNAME
</code></span></dt>
196 returns all known addresses for a given name.
197 The lwres_gabn_*() functions should be used for this type.
199 <dt><span class=
"term"><code class=
"constant">GETNAMEBYADDR
</code></span></dt>
201 return the hostname for the given address.
202 The lwres_gnba_*() functions should be used for this type.
207 <p><code class=
"function">lwres_lwpacket_renderheader()
</code>
208 transfers the contents of lightweight resolver packet structure
209 <span class=
"type">lwres_lwpacket_t
</span> <em class=
"parameter"><code>*pkt
</code></em> in
210 network byte order to the lightweight resolver buffer,
211 <em class=
"parameter"><code>*b
</code></em>.
213 <p><code class=
"function">lwres_lwpacket_parseheader()
</code>
214 performs the converse operation. It transfers data in network
215 byte order from buffer
<em class=
"parameter"><code>*b
</code></em> to resolver
216 packet
<em class=
"parameter"><code>*pkt
</code></em>. The contents of the buffer
217 <em class=
"parameter"><code>b
</code></em> should correspond to a
218 <span class=
"type">lwres_lwpacket_t
</span>.
221 <div class=
"refsect1" lang=
"en">
222 <a name=
"id2543716"></a><h2>RETURN VALUES
</h2>
225 <code class=
"function">lwres_lwpacket_renderheader()
</code> and
226 <code class=
"function">lwres_lwpacket_parseheader()
</code> return
227 <span class=
"errorcode">LWRES_R_SUCCESS
</span>. If there is insufficient
228 space to copy data between the buffer
<em class=
"parameter"><code>*b
</code></em> and
229 lightweight resolver packet
<em class=
"parameter"><code>*pkt
</code></em> both
231 return
<span class=
"errorcode">LWRES_R_UNEXPECTEDEND
</span>.