summaryrefslogtreecommitdiff
path: root/usr.sbin/bind/lib/lwres/man/lwres_noop.html
blob: fdb5da103ffa90fe484d630b863eae2b3eee717c (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
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
<!--
 - 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_noop</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_noop</A
></H1
><DIV
CLASS="REFNAMEDIV"
><A
NAME="AEN8"
></A
><H2
>Name</H2
>lwres_nooprequest_render, lwres_noopresponse_render, lwres_nooprequest_parse, lwres_noopresponse_parse, lwres_noopresponse_free, lwres_nooprequest_free&nbsp;--&nbsp;lightweight resolver no-op message handling</DIV
><DIV
CLASS="REFSYNOPSISDIV"
><A
NAME="AEN16"
></A
><H2
>Synopsis</H2
><DIV
CLASS="FUNCSYNOPSIS"
><A
NAME="AEN17"
></A
><P
></P
><PRE
CLASS="FUNCSYNOPSISINFO"
>#include &lt;lwres/lwres.h&gt;</PRE
><P
><CODE
><CODE
CLASS="FUNCDEF"
>lwres_result_t
lwres_nooprequest_render</CODE
>(lwres_context_t *ctx, lwres_nooprequest_t *req, lwres_lwpacket_t *pkt, lwres_buffer_t *b);</CODE
></P
><P
><CODE
><CODE
CLASS="FUNCDEF"
>lwres_result_t
lwres_noopresponse_render</CODE
>(lwres_context_t *ctx, lwres_noopresponse_t *req, lwres_lwpacket_t *pkt, lwres_buffer_t *b);</CODE
></P
><P
><CODE
><CODE
CLASS="FUNCDEF"
>lwres_result_t
lwres_nooprequest_parse</CODE
>(lwres_context_t *ctx, lwres_buffer_t *b, lwres_lwpacket_t *pkt, lwres_nooprequest_t **structp);</CODE
></P
><P
><CODE
><CODE
CLASS="FUNCDEF"
>lwres_result_t
lwres_noopresponse_parse</CODE
>(lwres_context_t *ctx, lwres_buffer_t *b, lwres_lwpacket_t *pkt, lwres_noopresponse_t **structp);</CODE
></P
><P
><CODE
><CODE
CLASS="FUNCDEF"
>void
lwres_noopresponse_free</CODE
>(lwres_context_t *ctx, lwres_noopresponse_t **structp);</CODE
></P
><P
><CODE
><CODE
CLASS="FUNCDEF"
>void
lwres_nooprequest_free</CODE
>(lwres_context_t *ctx, lwres_nooprequest_t **structp);</CODE
></P
><P
></P
></DIV
></DIV
><DIV
CLASS="REFSECT1"
><A
NAME="AEN57"
></A
><H2
>DESCRIPTION</H2
><P
>These are low-level routines for creating and parsing
lightweight resolver no-op request and response messages.</P
><P
>The no-op message is analogous to a <B
CLASS="COMMAND"
>ping</B
> packet: 
a packet is sent to the resolver daemon and is simply echoed back.
The opcode is intended to allow a client to determine if the server is
operational or not.</P
><P
>There are four main functions for the no-op opcode.
One render function converts a no-op request structure &mdash;
<SPAN
CLASS="TYPE"
>lwres_nooprequest_t</SPAN
> &mdash;
to the lighweight resolver's canonical format.
It is complemented by a parse function that converts a packet in this
canonical format to a no-op request structure.
Another render function converts the no-op response structure &mdash;
<SPAN
CLASS="TYPE"
>lwres_noopresponse_t</SPAN
>
to the canonical format.
This is complemented by a parse function which converts a packet in
canonical format to a no-op response structure.</P
><P
>These structures are defined in
<TT
CLASS="FILENAME"
>lwres/lwres.h</TT
>.

They are shown below.
<PRE
CLASS="PROGRAMLISTING"
>#define LWRES_OPCODE_NOOP       0x00000000U

typedef struct {
        lwres_uint16_t  datalength;
        unsigned char   *data;
} lwres_nooprequest_t;

typedef struct {
        lwres_uint16_t  datalength;
        unsigned char   *data;
} lwres_noopresponse_t;</PRE
>
Although the structures have different types, they are identical.
This is because the no-op opcode simply echos whatever data was sent:
the response is therefore identical to the request.</P
><P
><TT
CLASS="FUNCTION"
>lwres_nooprequest_render()</TT
> uses resolver
context <TT
CLASS="PARAMETER"
><I
>ctx</I
></TT
> to convert no-op request structure
<TT
CLASS="PARAMETER"
><I
>req</I
></TT
> to canonical format.  The packet header
structure <TT
CLASS="PARAMETER"
><I
>pkt</I
></TT
> is initialised and transferred to
buffer <TT
CLASS="PARAMETER"
><I
>b</I
></TT
>.  The contents of
<TT
CLASS="PARAMETER"
><I
>*req</I
></TT
> are then appended to the buffer in
canonical format.  <TT
CLASS="FUNCTION"
>lwres_noopresponse_render()</TT
>
performs the same task, except it converts a no-op response structure
<SPAN
CLASS="TYPE"
>lwres_noopresponse_t</SPAN
> to the lightweight resolver's
canonical format.</P
><P
><TT
CLASS="FUNCTION"
>lwres_nooprequest_parse()</TT
> uses context
<TT
CLASS="PARAMETER"
><I
>ctx</I
></TT
> to convert the contents of packet
<TT
CLASS="PARAMETER"
><I
>pkt</I
></TT
> to a <SPAN
CLASS="TYPE"
>lwres_nooprequest_t</SPAN
>
structure.  Buffer <TT
CLASS="PARAMETER"
><I
>b</I
></TT
> provides space to be used
for storing this structure.  When the function succeeds, the resulting
<SPAN
CLASS="TYPE"
>lwres_nooprequest_t</SPAN
> is made available through
<TT
CLASS="PARAMETER"
><I
>*structp</I
></TT
>.
<TT
CLASS="FUNCTION"
>lwres_noopresponse_parse()</TT
> offers the same
semantics as <TT
CLASS="FUNCTION"
>lwres_nooprequest_parse()</TT
> except it
yields a <SPAN
CLASS="TYPE"
>lwres_noopresponse_t</SPAN
> structure.</P
><P
><TT
CLASS="FUNCTION"
>lwres_noopresponse_free()</TT
> and
<TT
CLASS="FUNCTION"
>lwres_nooprequest_free()</TT
> release the memory in
resolver context <TT
CLASS="PARAMETER"
><I
>ctx</I
></TT
> that was allocated to the
<SPAN
CLASS="TYPE"
>lwres_noopresponse_t</SPAN
> or <SPAN
CLASS="TYPE"
>lwres_nooprequest_t</SPAN
>
structures referenced via <TT
CLASS="PARAMETER"
><I
>structp</I
></TT
>.</P
></DIV
><DIV
CLASS="REFSECT1"
><A
NAME="AEN95"
></A
><H2
>RETURN VALUES</H2
><P
>The no-op opcode functions
<TT
CLASS="FUNCTION"
>lwres_nooprequest_render()</TT
>,

<TT
CLASS="FUNCTION"
>lwres_noopresponse_render()</TT
>
<TT
CLASS="FUNCTION"
>lwres_nooprequest_parse()</TT
>
and
<TT
CLASS="FUNCTION"
>lwres_noopresponse_parse()</TT
>
all return
<SPAN
CLASS="ERRORCODE"
>LWRES_R_SUCCESS</SPAN
>
on success.
They return
<SPAN
CLASS="ERRORCODE"
>LWRES_R_NOMEMORY</SPAN
>
if memory allocation fails.
<SPAN
CLASS="ERRORCODE"
>LWRES_R_UNEXPECTEDEND</SPAN
>
is returned if the available space in the buffer
<TT
CLASS="PARAMETER"
><I
>b</I
></TT
>
is too small to accommodate the packet header or the
<SPAN
CLASS="TYPE"
>lwres_nooprequest_t</SPAN
>
and
<SPAN
CLASS="TYPE"
>lwres_noopresponse_t</SPAN
>
structures.
<TT
CLASS="FUNCTION"
>lwres_nooprequest_parse()</TT
>
and
<TT
CLASS="FUNCTION"
>lwres_noopresponse_parse()</TT
>
will return
<SPAN
CLASS="ERRORCODE"
>LWRES_R_UNEXPECTEDEND</SPAN
>
if the buffer is not empty after decoding the received packet.
These functions will return
<SPAN
CLASS="ERRORCODE"
>LWRES_R_FAILURE</SPAN
>
if
<TT
CLASS="CONSTANT"
>pktflags</TT
>
in the packet header structure
<SPAN
CLASS="TYPE"
>lwres_lwpacket_t</SPAN
>
indicate that the packet is not a response to an earlier query.</P
></DIV
><DIV
CLASS="REFSECT1"
><A
NAME="AEN114"
></A
><H2
>SEE ALSO</H2
><P
><SPAN
CLASS="CITEREFENTRY"
><SPAN
CLASS="REFENTRYTITLE"
>lwres_packet</SPAN
>(3)</SPAN
></P
></DIV
></BODY
></HTML
>