summaryrefslogtreecommitdiff
path: root/usr.sbin/bind/lib/lwres/man/lwres_packet.html
blob: 5c5828f498157717a806da37f8046a541755b134 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
<!--
 - Copyright (C) 2000, 2001  Internet Software Consortium.
 - 
 - Permission to use, copy, modify, and distribute this software for any
 - purpose with or without fee is hereby granted, provided that the above
 - copyright notice and this permission notice appear in all copies.
 - 
 - THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM
 - DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
 - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
 - INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
 - INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
 - FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
 - NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
 - WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-->
<HTML
><HEAD
><TITLE
>lwres_packet</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.61
"></HEAD
><BODY
CLASS="REFENTRY"
BGCOLOR="#FFFFFF"
TEXT="#000000"
LINK="#0000FF"
VLINK="#840084"
ALINK="#0000FF"
><H1
><A
NAME="AEN1"
>lwres_packet</A
></H1
><DIV
CLASS="REFNAMEDIV"
><A
NAME="AEN8"
></A
><H2
>Name</H2
>lwres_lwpacket_renderheader, lwres_lwpacket_parseheader&nbsp;--&nbsp;lightweight resolver packet handling functions</DIV
><DIV
CLASS="REFSYNOPSISDIV"
><A
NAME="AEN12"
></A
><H2
>Synopsis</H2
><DIV
CLASS="FUNCSYNOPSIS"
><A
NAME="AEN13"
></A
><P
></P
><PRE
CLASS="FUNCSYNOPSISINFO"
>#include &lt;lwres/lwpacket.h&gt;</PRE
><P
><CODE
><CODE
CLASS="FUNCDEF"
>lwres_result_t
lwres_lwpacket_renderheader</CODE
>(lwres_buffer_t *b, lwres_lwpacket_t *pkt);</CODE
></P
><P
><CODE
><CODE
CLASS="FUNCDEF"
>lwres_result_t
lwres_lwpacket_parseheader</CODE
>(lwres_buffer_t *b, lwres_lwpacket_t *pkt);</CODE
></P
><P
></P
></DIV
></DIV
><DIV
CLASS="REFSECT1"
><A
NAME="AEN25"
></A
><H2
>DESCRIPTION</H2
><P
>These functions rely on a
<SPAN
CLASS="TYPE"
>struct lwres_lwpacket</SPAN
>
which is defined in
<TT
CLASS="FILENAME"
>lwres/lwpacket.h</TT
>.

<PRE
CLASS="PROGRAMLISTING"
>typedef struct lwres_lwpacket lwres_lwpacket_t;

struct lwres_lwpacket {
        lwres_uint32_t          length;
        lwres_uint16_t          version;
        lwres_uint16_t          pktflags;
        lwres_uint32_t          serial;
        lwres_uint32_t          opcode;
        lwres_uint32_t          result;
        lwres_uint32_t          recvlength;
        lwres_uint16_t          authtype;
        lwres_uint16_t          authlength;
};</PRE
></P
><P
>The elements of this structure are:
<P
></P
><DIV
CLASS="VARIABLELIST"
><DL
><DT
><TT
CLASS="CONSTANT"
>length</TT
></DT
><DD
><P
>the overall packet length, including the entire packet header.
This field is filled in by the lwres_gabn_*() and lwres_gnba_*()
calls.</P
></DD
><DT
><TT
CLASS="CONSTANT"
>version</TT
></DT
><DD
><P
>the header format. There is currently only one format,
<SPAN
CLASS="TYPE"
>LWRES_LWPACKETVERSION_0</SPAN
>.

This field is filled in by the lwres_gabn_*() and lwres_gnba_*()
calls.</P
></DD
><DT
><TT
CLASS="CONSTANT"
>pktflags</TT
></DT
><DD
><P
>library-defined flags for this packet: for instance whether the packet
is a request or a reply. Flag values can be set, but not defined by
the caller.
This field is filled in by the application wit the exception of the
LWRES_LWPACKETFLAG_RESPONSE bit, which is set by the library in the
lwres_gabn_*() and lwres_gnba_*() calls.</P
></DD
><DT
><TT
CLASS="CONSTANT"
>serial</TT
></DT
><DD
><P
>is set by the requestor and is returned in all replies. If two or more
packets from the same source have the same serial number and are from
the same source, they are assumed to be duplicates and the latter ones
may be dropped.
This field must be set by the application.</P
></DD
><DT
><TT
CLASS="CONSTANT"
>opcode</TT
></DT
><DD
><P
>indicates the operation.
Opcodes between 0x00000000 and 0x03ffffff are
reserved for use by the lightweight resolver library. Opcodes between
0x04000000 and 0xffffffff are application defined.
This field is filled in by the lwres_gabn_*() and lwres_gnba_*()
calls.</P
></DD
><DT
><TT
CLASS="CONSTANT"
>result</TT
></DT
><DD
><P
>is only valid for replies.
Results between 0x04000000 and 0xffffffff are application defined.
Results between 0x00000000 and 0x03ffffff are reserved for library use.
This field is filled in by the lwres_gabn_*() and lwres_gnba_*()
calls.</P
></DD
><DT
><TT
CLASS="CONSTANT"
>recvlength</TT
></DT
><DD
><P
>is the maximum buffer size that the receiver can handle on requests
and the size of the buffer needed to satisfy a request when the buffer
is too large for replies.
This field is supplied by the application.</P
></DD
><DT
><TT
CLASS="CONSTANT"
>authtype</TT
></DT
><DD
><P
>defines the packet level authentication that is used.
Authorisation types between 0x1000 and 0xffff are application defined
and types between 0x0000 and 0x0fff are reserved for library use.
Currently these are not used and must be zero.</P
></DD
><DT
><TT
CLASS="CONSTANT"
>authlen</TT
></DT
><DD
><P
>gives the length of the authentication data.
Since packet authentication is currently not used, this must be zero.</P
></DD
></DL
></DIV
></P
><P
>The following opcodes are currently defined:
<P
></P
><DIV
CLASS="VARIABLELIST"
><DL
><DT
><TT
CLASS="CONSTANT"
>NOOP</TT
></DT
><DD
><P
>Success is always returned and the packet contents are echoed.
The lwres_noop_*() functions should be used for this type.</P
></DD
><DT
><TT
CLASS="CONSTANT"
>GETADDRSBYNAME</TT
></DT
><DD
><P
>returns all known addresses for a given name.
The lwres_gabn_*() functions should be used for this type.</P
></DD
><DT
><TT
CLASS="CONSTANT"
>GETNAMEBYADDR</TT
></DT
><DD
><P
>return the hostname for the given address.
The lwres_gnba_*() functions should be used for this type.</P
></DD
></DL
></DIV
></P
><P
><TT
CLASS="FUNCTION"
>lwres_lwpacket_renderheader()</TT
> transfers the
contents of lightweight resolver packet structure
<SPAN
CLASS="TYPE"
>lwres_lwpacket_t</SPAN
> <TT
CLASS="PARAMETER"
><I
>*pkt</I
></TT
> in network
byte order to the lightweight resolver buffer,
<TT
CLASS="PARAMETER"
><I
>*b</I
></TT
>.</P
><P
><TT
CLASS="FUNCTION"
>lwres_lwpacket_parseheader()</TT
> performs the
converse operation.  It transfers data in network byte order from
buffer <TT
CLASS="PARAMETER"
><I
>*b</I
></TT
> to resolver packet
<TT
CLASS="PARAMETER"
><I
>*pkt</I
></TT
>.  The contents of the buffer
<TT
CLASS="PARAMETER"
><I
>b</I
></TT
> should correspond to a
<SPAN
CLASS="TYPE"
>lwres_lwpacket_t</SPAN
>.</P
></DIV
><DIV
CLASS="REFSECT1"
><A
NAME="AEN107"
></A
><H2
>RETURN VALUES</H2
><P
> Successful calls to
<TT
CLASS="FUNCTION"
>lwres_lwpacket_renderheader()</TT
> and
<TT
CLASS="FUNCTION"
>lwres_lwpacket_parseheader()</TT
> return
<SPAN
CLASS="ERRORCODE"
>LWRES_R_SUCCESS</SPAN
>.  If there is insufficient
space to copy data between the buffer <TT
CLASS="PARAMETER"
><I
>*b</I
></TT
> and
lightweight resolver packet <TT
CLASS="PARAMETER"
><I
>*pkt</I
></TT
> both functions
return <SPAN
CLASS="ERRORCODE"
>LWRES_R_UNEXPECTEDEND</SPAN
>.</P
></DIV
></BODY
></HTML
>