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
|
<!--
- 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_gnba</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_gnba</A
></H1
><DIV
CLASS="REFNAMEDIV"
><A
NAME="AEN8"
></A
><H2
>Name</H2
>lwres_gnbarequest_render, lwres_gnbaresponse_render, lwres_gnbarequest_parse, lwres_gnbaresponse_parse, lwres_gnbaresponse_free, lwres_gnbarequest_free -- lightweight resolver getnamebyaddress 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 <lwres/lwres.h></PRE
><P
><CODE
><CODE
CLASS="FUNCDEF"
>lwres_result_t
lwres_gnbarequest_render</CODE
>(lwres_context_t *ctx, lwres_gnbarequest_t *req, lwres_lwpacket_t *pkt, lwres_buffer_t *b);</CODE
></P
><P
><CODE
><CODE
CLASS="FUNCDEF"
>lwres_result_t
lwres_gnbaresponse_render</CODE
>(lwres_context_t *ctx, lwres_gnbaresponse_t *req, lwres_lwpacket_t *pkt, lwres_buffer_t *b);</CODE
></P
><P
><CODE
><CODE
CLASS="FUNCDEF"
>lwres_result_t
lwres_gnbarequest_parse</CODE
>(lwres_context_t *ctx, lwres_buffer_t *b, lwres_lwpacket_t *pkt, lwres_gnbarequest_t **structp);</CODE
></P
><P
><CODE
><CODE
CLASS="FUNCDEF"
>lwres_result_t
lwres_gnbaresponse_parse</CODE
>(lwres_context_t *ctx, lwres_buffer_t *b, lwres_lwpacket_t *pkt, lwres_gnbaresponse_t **structp);</CODE
></P
><P
><CODE
><CODE
CLASS="FUNCDEF"
>void
lwres_gnbaresponse_free</CODE
>(lwres_context_t *ctx, lwres_gnbaresponse_t **structp);</CODE
></P
><P
><CODE
><CODE
CLASS="FUNCDEF"
>void
lwres_gnbarequest_free</CODE
>(lwres_context_t *ctx, lwres_gnbarequest_t **structp);</CODE
></P
><P
></P
></DIV
></DIV
><DIV
CLASS="REFSECT1"
><A
NAME="AEN61"
></A
><H2
>DESCRIPTION</H2
><P
>These are low-level routines for creating and parsing
lightweight resolver address-to-name lookup request and
response messages.</P
><P
>There are four main functions for the getnamebyaddr opcode.
One render function converts a getnamebyaddr request structure —
<SPAN
CLASS="TYPE"
>lwres_gnbarequest_t</SPAN
> —
to the lightweight resolver's canonical format.
It is complemented by a parse function that converts a packet in this
canonical format to a getnamebyaddr request structure.
Another render function converts the getnamebyaddr response structure —
<SPAN
CLASS="TYPE"
>lwres_gnbaresponse_t</SPAN
>
to the canonical format.
This is complemented by a parse function which converts a packet in
canonical format to a getnamebyaddr 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_GETNAMEBYADDR 0x00010002U
typedef struct {
lwres_uint32_t flags;
lwres_addr_t addr;
} lwres_gnbarequest_t;
typedef struct {
lwres_uint32_t flags;
lwres_uint16_t naliases;
char *realname;
char **aliases;
lwres_uint16_t realnamelen;
lwres_uint16_t *aliaslen;
void *base;
size_t baselen;
} lwres_gnbaresponse_t;</PRE
></P
><P
><TT
CLASS="FUNCTION"
>lwres_gnbarequest_render()</TT
>
uses resolver context
<TT
CLASS="VARNAME"
>ctx</TT
>
to convert getnamebyaddr request structure
<TT
CLASS="VARNAME"
>req</TT
>
to canonical format.
The packet header structure
<TT
CLASS="VARNAME"
>pkt</TT
>
is initialised and transferred to
buffer
<TT
CLASS="VARNAME"
>b</TT
>.
The contents of
<TT
CLASS="VARNAME"
>*req</TT
>
are then appended to the buffer in canonical format.
<TT
CLASS="FUNCTION"
>lwres_gnbaresponse_render()</TT
>
performs the same task, except it converts a getnamebyaddr response structure
<SPAN
CLASS="TYPE"
>lwres_gnbaresponse_t</SPAN
>
to the lightweight resolver's canonical format.</P
><P
><TT
CLASS="FUNCTION"
>lwres_gnbarequest_parse()</TT
>
uses context
<TT
CLASS="VARNAME"
>ctx</TT
>
to convert the contents of packet
<TT
CLASS="VARNAME"
>pkt</TT
>
to a
<SPAN
CLASS="TYPE"
>lwres_gnbarequest_t</SPAN
>
structure.
Buffer
<TT
CLASS="VARNAME"
>b</TT
>
provides space to be used for storing this structure.
When the function succeeds, the resulting
<SPAN
CLASS="TYPE"
>lwres_gnbarequest_t</SPAN
>
is made available through
<TT
CLASS="VARNAME"
>*structp</TT
>.
<TT
CLASS="FUNCTION"
>lwres_gnbaresponse_parse()</TT
>
offers the same semantics as
<TT
CLASS="FUNCTION"
>lwres_gnbarequest_parse()</TT
>
except it yields a
<SPAN
CLASS="TYPE"
>lwres_gnbaresponse_t</SPAN
>
structure.</P
><P
><TT
CLASS="FUNCTION"
>lwres_gnbaresponse_free()</TT
>
and
<TT
CLASS="FUNCTION"
>lwres_gnbarequest_free()</TT
>
release the memory in resolver context
<TT
CLASS="VARNAME"
>ctx</TT
>
that was allocated to the
<SPAN
CLASS="TYPE"
>lwres_gnbaresponse_t</SPAN
>
or
<SPAN
CLASS="TYPE"
>lwres_gnbarequest_t</SPAN
>
structures referenced via
<TT
CLASS="VARNAME"
>structp</TT
>.
Any memory associated with ancillary buffers and strings for those
structures is also discarded.</P
></DIV
><DIV
CLASS="REFSECT1"
><A
NAME="AEN97"
></A
><H2
>RETURN VALUES</H2
><P
>The getnamebyaddr opcode functions
<TT
CLASS="FUNCTION"
>lwres_gnbarequest_render()</TT
>,
<TT
CLASS="FUNCTION"
>lwres_gnbaresponse_render()</TT
>
<TT
CLASS="FUNCTION"
>lwres_gnbarequest_parse()</TT
>
and
<TT
CLASS="FUNCTION"
>lwres_gnbaresponse_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="VARNAME"
>b</TT
>
is too small to accommodate the packet header or the
<SPAN
CLASS="TYPE"
>lwres_gnbarequest_t</SPAN
>
and
<SPAN
CLASS="TYPE"
>lwres_gnbaresponse_t</SPAN
>
structures.
<TT
CLASS="FUNCTION"
>lwres_gnbarequest_parse()</TT
>
and
<TT
CLASS="FUNCTION"
>lwres_gnbaresponse_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="STRUCTFIELD"
><I
>pktflags</I
></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="AEN116"
></A
><H2
>SEE ALSO</H2
><P
><SPAN
CLASS="CITEREFENTRY"
><SPAN
CLASS="REFENTRYTITLE"
>lwres_packet</SPAN
>(3)</SPAN
>.</P
></DIV
></BODY
></HTML
>
|