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_gabn
</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_gabnrequest_render, lwres_gabnresponse_render, lwres_gabnrequest_parse, lwres_gabnresponse_parse, lwres_gabnresponse_free, lwres_gabnrequest_free
— lightweight resolver getaddrbyname message handling
</p>
30 <div class=
"refsynopsisdiv">
32 <div class=
"funcsynopsis">
33 <pre class=
"funcsynopsisinfo">#include
<lwres/lwres.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_gabnrequest_render
</b>(
</code></td>
39 <td>lwres_context_t *
</td>
41 <var class=
"pdparam">ctx
</var>,
</td>
45 <td>lwres_gabnrequest_t *
</td>
47 <var class=
"pdparam">req
</var>,
</td>
51 <td>lwres_lwpacket_t *
</td>
53 <var class=
"pdparam">pkt
</var>,
</td>
57 <td>lwres_buffer_t *
</td>
59 <var class=
"pdparam">b
</var><code>)
</code>;
</td>
62 <table border=
"0" summary=
"Function synopsis" cellspacing=
"0" cellpadding=
"0" style=
"padding-bottom: 1em">
64 <td><code class=
"funcdef">
66 <b class=
"fsfunc">lwres_gabnresponse_render
</b>(
</code></td>
67 <td>lwres_context_t *
</td>
69 <var class=
"pdparam">ctx
</var>,
</td>
73 <td>lwres_gabnresponse_t *
</td>
75 <var class=
"pdparam">req
</var>,
</td>
79 <td>lwres_lwpacket_t *
</td>
81 <var class=
"pdparam">pkt
</var>,
</td>
85 <td>lwres_buffer_t *
</td>
87 <var class=
"pdparam">b
</var><code>)
</code>;
</td>
90 <table border=
"0" summary=
"Function synopsis" cellspacing=
"0" cellpadding=
"0" style=
"padding-bottom: 1em">
92 <td><code class=
"funcdef">
94 <b class=
"fsfunc">lwres_gabnrequest_parse
</b>(
</code></td>
95 <td>lwres_context_t *
</td>
97 <var class=
"pdparam">ctx
</var>,
</td>
101 <td>lwres_buffer_t *
</td>
103 <var class=
"pdparam">b
</var>,
</td>
107 <td>lwres_lwpacket_t *
</td>
109 <var class=
"pdparam">pkt
</var>,
</td>
113 <td>lwres_gabnrequest_t **
</td>
115 <var class=
"pdparam">structp
</var><code>)
</code>;
</td>
118 <table border=
"0" summary=
"Function synopsis" cellspacing=
"0" cellpadding=
"0" style=
"padding-bottom: 1em">
120 <td><code class=
"funcdef">
122 <b class=
"fsfunc">lwres_gabnresponse_parse
</b>(
</code></td>
123 <td>lwres_context_t *
</td>
125 <var class=
"pdparam">ctx
</var>,
</td>
129 <td>lwres_buffer_t *
</td>
131 <var class=
"pdparam">b
</var>,
</td>
135 <td>lwres_lwpacket_t *
</td>
137 <var class=
"pdparam">pkt
</var>,
</td>
141 <td>lwres_gabnresponse_t **
</td>
143 <var class=
"pdparam">structp
</var><code>)
</code>;
</td>
146 <table border=
"0" summary=
"Function synopsis" cellspacing=
"0" cellpadding=
"0" style=
"padding-bottom: 1em">
148 <td><code class=
"funcdef">
150 <b class=
"fsfunc">lwres_gabnresponse_free
</b>(
</code></td>
151 <td>lwres_context_t *
</td>
153 <var class=
"pdparam">ctx
</var>,
</td>
157 <td>lwres_gabnresponse_t **
</td>
159 <var class=
"pdparam">structp
</var><code>)
</code>;
</td>
162 <table border=
"0" summary=
"Function synopsis" cellspacing=
"0" cellpadding=
"0">
164 <td><code class=
"funcdef">
166 <b class=
"fsfunc">lwres_gabnrequest_free
</b>(
</code></td>
167 <td>lwres_context_t *
</td>
169 <var class=
"pdparam">ctx
</var>,
</td>
173 <td>lwres_gabnrequest_t **
</td>
175 <var class=
"pdparam">structp
</var><code>)
</code>;
</td>
180 <div class=
"refsect1" lang=
"en">
181 <a name=
"id2543531"></a><h2>DESCRIPTION
</h2>
183 These are low-level routines for creating and parsing
184 lightweight resolver name-to-address lookup request and
188 There are four main functions for the getaddrbyname opcode.
189 One render function converts a getaddrbyname request structure
—
190 <span class=
"type">lwres_gabnrequest_t
</span> —
191 to the lightweight resolver's canonical format.
192 It is complemented by a parse function that converts a packet in this
193 canonical format to a getaddrbyname request structure.
194 Another render function converts the getaddrbyname response structure
195 — <span class=
"type">lwres_gabnresponse_t
</span> —
196 to the canonical format.
197 This is complemented by a parse function which converts a packet in
198 canonical format to a getaddrbyname response structure.
201 These structures are defined in
202 <code class=
"filename"><lwres/lwres.h
></code>.
203 They are shown below.
205 <pre class=
"programlisting">
206 #define LWRES_OPCODE_GETADDRSBYNAME
0x00010001U
210 <pre class=
"programlisting">
211 typedef struct lwres_addr lwres_addr_t;
212 typedef LWRES_LIST(lwres_addr_t) lwres_addrlist_t;
216 <pre class=
"programlisting">
218 lwres_uint32_t flags;
219 lwres_uint32_t addrtypes;
220 lwres_uint16_t namelen;
222 } lwres_gabnrequest_t;
226 <pre class=
"programlisting">
228 lwres_uint32_t flags;
229 lwres_uint16_t naliases;
230 lwres_uint16_t naddrs;
233 lwres_uint16_t realnamelen;
234 lwres_uint16_t *aliaslen;
235 lwres_addrlist_t addrs;
238 } lwres_gabnresponse_t;
242 <p><code class=
"function">lwres_gabnrequest_render()
</code>
243 uses resolver context
<em class=
"parameter"><code>ctx
</code></em> to convert
244 getaddrbyname request structure
<em class=
"parameter"><code>req
</code></em> to
245 canonical format. The packet header structure
246 <em class=
"parameter"><code>pkt
</code></em> is initialised and transferred to
247 buffer
<em class=
"parameter"><code>b
</code></em>.
249 The contents of
<em class=
"parameter"><code>*req
</code></em> are then appended to
250 the buffer in canonical format.
251 <code class=
"function">lwres_gabnresponse_render()
</code> performs the
252 same task, except it converts a getaddrbyname response structure
253 <span class=
"type">lwres_gabnresponse_t
</span> to the lightweight resolver's
256 <p><code class=
"function">lwres_gabnrequest_parse()
</code>
257 uses context
<em class=
"parameter"><code>ctx
</code></em> to convert the contents
258 of packet
<em class=
"parameter"><code>pkt
</code></em> to a
259 <span class=
"type">lwres_gabnrequest_t
</span> structure. Buffer
260 <em class=
"parameter"><code>b
</code></em> provides space to be used for storing
261 this structure. When the function succeeds, the resulting
262 <span class=
"type">lwres_gabnrequest_t
</span> is made available through
263 <em class=
"parameter"><code>*structp
</code></em>.
265 <code class=
"function">lwres_gabnresponse_parse()
</code> offers the same
266 semantics as
<code class=
"function">lwres_gabnrequest_parse()
</code>
267 except it yields a
<span class=
"type">lwres_gabnresponse_t
</span> structure.
269 <p><code class=
"function">lwres_gabnresponse_free()
</code>
270 and
<code class=
"function">lwres_gabnrequest_free()
</code> release the
271 memory in resolver context
<em class=
"parameter"><code>ctx
</code></em> that was
272 allocated to the
<span class=
"type">lwres_gabnresponse_t
</span> or
273 <span class=
"type">lwres_gabnrequest_t
</span> structures referenced via
274 <em class=
"parameter"><code>structp
</code></em>.
276 Any memory associated with ancillary buffers and strings for
277 those structures is also discarded.
280 <div class=
"refsect1" lang=
"en">
281 <a name=
"id2543676"></a><h2>RETURN VALUES
</h2>
283 The getaddrbyname opcode functions
284 <code class=
"function">lwres_gabnrequest_render()
</code>,
285 <code class=
"function">lwres_gabnresponse_render()
</code>
286 <code class=
"function">lwres_gabnrequest_parse()
</code>
288 <code class=
"function">lwres_gabnresponse_parse()
</code>
290 <span class=
"errorcode">LWRES_R_SUCCESS
</span>
293 <span class=
"errorcode">LWRES_R_NOMEMORY
</span>
294 if memory allocation fails.
295 <span class=
"errorcode">LWRES_R_UNEXPECTEDEND
</span>
296 is returned if the available space in the buffer
297 <em class=
"parameter"><code>b
</code></em>
298 is too small to accommodate the packet header or the
299 <span class=
"type">lwres_gabnrequest_t
</span>
301 <span class=
"type">lwres_gabnresponse_t
</span>
303 <code class=
"function">lwres_gabnrequest_parse()
</code>
305 <code class=
"function">lwres_gabnresponse_parse()
</code>
307 <span class=
"errorcode">LWRES_R_UNEXPECTEDEND
</span>
308 if the buffer is not empty after decoding the received packet.
309 These functions will return
310 <span class=
"errorcode">LWRES_R_FAILURE
</span>
312 <em class=
"structfield"><code>pktflags
</code></em>
313 in the packet header structure
314 <span class=
"type">lwres_lwpacket_t
</span>
315 indicate that the packet is not a response to an earlier query.
318 <div class=
"refsect1" lang=
"en">
319 <a name=
"id2543742"></a><h2>SEE ALSO
</h2>
320 <p><span class=
"citerefentry"><span class=
"refentrytitle">lwres_packet
</span>(
3)
</span>