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
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!--
- Copyright (C) 2000, 2001, 2004, 2005, 2007, 2014-2016, 2018, 2019 Internet Systems Consortium, Inc. ("ISC")
-
- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/.
-->
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>lwres_gnba</title>
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="refentry">
<a name="id-1"></a><div class="titlepage"></div>
<div class="refnamediv">
<h2>Name</h2>
<p>
lwres_gnbarequest_render,
lwres_gnbaresponse_render,
lwres_gnbarequest_parse,
lwres_gnbaresponse_parse,
lwres_gnbaresponse_free,
lwres_gnbarequest_free
— lightweight resolver getnamebyaddress message handling
</p>
</div>
<div class="refsynopsisdiv">
<h2>Synopsis</h2>
<div class="funcsynopsis">
<pre class="funcsynopsisinfo">
#include <lwres/lwres.h>
</pre>
<table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;">
<tr>
<td><code class="funcdef">
lwres_result_t
<b class="fsfunc">lwres_gnbarequest_render</b>
(</code></td>
<td>lwres_context_t *<var class="pdparam">ctx</var>, </td>
</tr>
<tr>
<td>�</td>
<td>lwres_gnbarequest_t *<var class="pdparam">req</var>, </td>
</tr>
<tr>
<td>�</td>
<td>lwres_lwpacket_t *<var class="pdparam">pkt</var>, </td>
</tr>
<tr>
<td>�</td>
<td>lwres_buffer_t *<var class="pdparam">b</var><code>)</code>;</td>
</tr>
</table>
<div class="funcprototype-spacer">�</div>
<table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;">
<tr>
<td><code class="funcdef">
lwres_result_t
<b class="fsfunc">lwres_gnbaresponse_render</b>
(</code></td>
<td>lwres_context_t *<var class="pdparam">ctx</var>, </td>
</tr>
<tr>
<td>�</td>
<td>lwres_gnbaresponse_t *<var class="pdparam">req</var>, </td>
</tr>
<tr>
<td>�</td>
<td>lwres_lwpacket_t *<var class="pdparam">pkt</var>, </td>
</tr>
<tr>
<td>�</td>
<td>lwres_buffer_t *<var class="pdparam">b</var><code>)</code>;</td>
</tr>
</table>
<div class="funcprototype-spacer">�</div>
<table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;">
<tr>
<td><code class="funcdef">
lwres_result_t
<b class="fsfunc">lwres_gnbarequest_parse</b>(</code></td>
<td>lwres_context_t *<var class="pdparam">ctx</var>, </td>
</tr>
<tr>
<td>�</td>
<td>lwres_buffer_t *<var class="pdparam">b</var>, </td>
</tr>
<tr>
<td>�</td>
<td>lwres_lwpacket_t *<var class="pdparam">pkt</var>, </td>
</tr>
<tr>
<td>�</td>
<td>lwres_gnbarequest_t **<var class="pdparam">structp</var><code>)</code>;</td>
</tr>
</table>
<div class="funcprototype-spacer">�</div>
<table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;">
<tr>
<td><code class="funcdef">
lwres_result_t
<b class="fsfunc">lwres_gnbaresponse_parse</b>(</code></td>
<td>lwres_context_t *<var class="pdparam">ctx</var>, </td>
</tr>
<tr>
<td>�</td>
<td>lwres_buffer_t *<var class="pdparam">b</var>, </td>
</tr>
<tr>
<td>�</td>
<td>lwres_lwpacket_t *<var class="pdparam">pkt</var>, </td>
</tr>
<tr>
<td>�</td>
<td>lwres_gnbaresponse_t **<var class="pdparam">structp</var><code>)</code>;</td>
</tr>
</table>
<div class="funcprototype-spacer">�</div>
<table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;">
<tr>
<td><code class="funcdef">
void
<b class="fsfunc">lwres_gnbaresponse_free</b>
(</code></td>
<td>lwres_context_t *<var class="pdparam">ctx</var>, </td>
</tr>
<tr>
<td>�</td>
<td>lwres_gnbaresponse_t **<var class="pdparam">structp</var><code>)</code>;</td>
</tr>
</table>
<div class="funcprototype-spacer">�</div>
<table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;">
<tr>
<td><code class="funcdef">
void
<b class="fsfunc">lwres_gnbarequest_free</b>(</code></td>
<td>lwres_context_t *<var class="pdparam">ctx</var>, </td>
</tr>
<tr>
<td>�</td>
<td>lwres_gnbarequest_t **<var class="pdparam">structp</var><code>)</code>;</td>
</tr>
</table>
<div class="funcprototype-spacer">�</div>
</div>
</div>
<div class="refsection">
<a name="id-1.7"></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
<code class="filename">lwres/lwres.h</code>.
They are shown below.
</p>
<pre class="programlisting">
#define LWRES_OPCODE_GETNAMEBYADDR 0x00010002U
</pre>
<p>
</p>
<pre class="programlisting">
typedef struct {
uint32_t flags;
lwres_addr_t addr;
} lwres_gnbarequest_t;
</pre>
<p>
</p>
<pre class="programlisting">
typedef struct {
uint32_t flags;
uint16_t naliases;
char *realname;
char **aliases;
uint16_t realnamelen;
uint16_t *aliaslen;
void *base;
size_t baselen;
} lwres_gnbaresponse_t;
</pre>
<p>
</p>
<p><code class="function">lwres_gnbarequest_render()</code>
uses resolver context <code class="varname">ctx</code> to convert
getnamebyaddr request structure <code class="varname">req</code> to
canonical format. The packet header structure
<code class="varname">pkt</code> is initialised and transferred to buffer
<code class="varname">b</code>. The contents of <code class="varname">*req</code>
are then appended to the buffer in canonical format.
<code class="function">lwres_gnbaresponse_render()</code> 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><code class="function">lwres_gnbarequest_parse()</code>
uses context <code class="varname">ctx</code> to convert the contents of
packet <code class="varname">pkt</code> to a
<span class="type">lwres_gnbarequest_t</span> structure. Buffer
<code class="varname">b</code> 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
<code class="varname">*structp</code>.
<code class="function">lwres_gnbaresponse_parse()</code> offers the same
semantics as <code class="function">lwres_gnbarequest_parse()</code>
except it yields a <span class="type">lwres_gnbaresponse_t</span> structure.
</p>
<p><code class="function">lwres_gnbaresponse_free()</code>
and <code class="function">lwres_gnbarequest_free()</code> release the
memory in resolver context <code class="varname">ctx</code> that was
allocated to the <span class="type">lwres_gnbaresponse_t</span> or
<span class="type">lwres_gnbarequest_t</span> structures referenced via
<code class="varname">structp</code>. Any memory associated with
ancillary buffers and strings for those structures is also
discarded.
</p>
</div>
<div class="refsection">
<a name="id-1.8"></a><h2>RETURN VALUES</h2>
<p>
The getnamebyaddr opcode functions
<code class="function">lwres_gnbarequest_render()</code>,
<code class="function">lwres_gnbaresponse_render()</code>
<code class="function">lwres_gnbarequest_parse()</code>
and
<code class="function">lwres_gnbaresponse_parse()</code>
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
<code class="varname">b</code>
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.
<code class="function">lwres_gnbarequest_parse()</code>
and
<code class="function">lwres_gnbaresponse_parse()</code>
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
<code class="varname">pktflags</code>
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="refsection">
<a name="id-1.9"></a><h2>SEE ALSO</h2>
<p><span class="citerefentry">
<span class="refentrytitle">lwres_packet</span>(3)
</span>.
</p>
</div>
</div></body>
</html>
|