1 <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook V4.1//EN">
3 - Copyright (C) 2001 Internet Software Consortium.
5 - Permission to use, copy, modify, and 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 INTERNET SOFTWARE CONSORTIUM
10 - DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
11 - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
12 - INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
13 - INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
14 - FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
15 - NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
16 - WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19 <!-- $Id: lwres_gabn.docbook,v 1.1 2004/03/15 20:35:25 as Exp $ -->
25 <date>Jun 30, 2000</date>
28 <refentrytitle>lwres_gabn</refentrytitle>
29 <manvolnum>3</manvolnum>
30 <refmiscinfo>BIND9</refmiscinfo>
33 <refname>lwres_gabnrequest_render</refname>
34 <refname>lwres_gabnresponse_render</refname>
35 <refname>lwres_gabnrequest_parse</refname>
36 <refname>lwres_gabnresponse_parse</refname>
37 <refname>lwres_gabnresponse_free</refname>
38 <refname>lwres_gabnrequest_free</refname>
39 <refpurpose>lightweight resolver getaddrbyname message handling</refpurpose>
43 <funcsynopsisinfo>#include <lwres/lwres.h></funcsynopsisinfo>
47 <function>lwres_gabnrequest_render</function></funcdef>
48 <paramdef>lwres_context_t *ctx</paramdef>
49 <paramdef>lwres_gabnrequest_t *req</paramdef>
50 <paramdef>lwres_lwpacket_t *pkt</paramdef>
51 <paramdef>lwres_buffer_t *b</paramdef>
56 <function>lwres_gabnresponse_render</function></funcdef>
57 <paramdef>lwres_context_t *ctx</paramdef>
58 <paramdef>lwres_gabnresponse_t *req</paramdef>
59 <paramdef>lwres_lwpacket_t *pkt</paramdef>
60 <paramdef>lwres_buffer_t *b</paramdef>
65 <function>lwres_gabnrequest_parse</function></funcdef>
66 <paramdef>lwres_context_t *ctx</paramdef>
67 <paramdef>lwres_buffer_t *b</paramdef>
68 <paramdef>lwres_lwpacket_t *pkt</paramdef>
69 <paramdef>lwres_gabnrequest_t **structp</paramdef>
74 <function>lwres_gabnresponse_parse</function></funcdef>
75 <paramdef>lwres_context_t *ctx</paramdef>
76 <paramdef>lwres_buffer_t *b</paramdef>
77 <paramdef>lwres_lwpacket_t *pkt</paramdef>
78 <paramdef>lwres_gabnresponse_t **structp</paramdef>
83 <function>lwres_gabnresponse_free</function></funcdef>
84 <paramdef>lwres_context_t *ctx</paramdef>
85 <paramdef>lwres_gabnresponse_t **structp</paramdef>
90 <function>lwres_gabnrequest_free</function></funcdef>
91 <paramdef>lwres_context_t *ctx</paramdef>
92 <paramdef>lwres_gabnrequest_t **structp</paramdef>
97 <title>DESCRIPTION</title>
99 These are low-level routines for creating and parsing
100 lightweight resolver name-to-address lookup request and
103 There are four main functions for the getaddrbyname opcode.
104 One render function converts a getaddrbyname request structure —
105 <type>lwres_gabnrequest_t</type> —
106 to the lighweight resolver's canonical format.
107 It is complemented by a parse function that converts a packet in this
108 canonical format to a getaddrbyname request structure.
109 Another render function converts the getaddrbyname response structure —
110 <type>lwres_gabnresponse_t</type> —
111 to the canonical format.
112 This is complemented by a parse function which converts a packet in
113 canonical format to a getaddrbyname response structure.
116 These structures are defined in
117 <filename><lwres/lwres.h></filename>.
118 They are shown below.
120 #define LWRES_OPCODE_GETADDRSBYNAME 0x00010001U
122 typedef struct lwres_addr lwres_addr_t;
123 typedef LWRES_LIST(lwres_addr_t) lwres_addrlist_t;
126 lwres_uint32_t flags;
127 lwres_uint32_t addrtypes;
128 lwres_uint16_t namelen;
130 } lwres_gabnrequest_t;
133 lwres_uint32_t flags;
134 lwres_uint16_t naliases;
135 lwres_uint16_t naddrs;
138 lwres_uint16_t realnamelen;
139 lwres_uint16_t *aliaslen;
140 lwres_addrlist_t addrs;
143 } lwres_gabnresponse_t;
147 <function>lwres_gabnrequest_render()</function>
148 uses resolver context
149 <parameter>ctx</parameter>
150 to convert getaddrbyname request structure
151 <parameter>req</parameter>
153 The packet header structure
154 <parameter>pkt</parameter>
155 is initialised and transferred to
157 <parameter>b</parameter>.
160 <parameter>*req</parameter>
161 are then appended to the buffer in canonical format.
162 <function>lwres_gabnresponse_render()</function>
163 performs the same task, except it converts a getaddrbyname response structure
164 <type>lwres_gabnresponse_t</type>
165 to the lightweight resolver's canonical format.
168 <function>lwres_gabnrequest_parse()</function>
170 <parameter>ctx</parameter>
171 to convert the contents of packet
172 <parameter>pkt</parameter>
174 <type>lwres_gabnrequest_t</type>
177 <parameter>b</parameter>
178 provides space to be used for storing this structure.
179 When the function succeeds, the resulting
180 <type>lwres_gabnrequest_t</type>
181 is made available through
182 <parameter>*structp</parameter>.
184 <function>lwres_gabnresponse_parse()</function>
185 offers the same semantics as
186 <function>lwres_gabnrequest_parse()</function>
188 <type>lwres_gabnresponse_t</type>
192 <function>lwres_gabnresponse_free()</function>
194 <function>lwres_gabnrequest_free()</function>
195 release the memory in resolver context
196 <parameter>ctx</parameter>
197 that was allocated to the
198 <type>lwres_gabnresponse_t</type>
200 <type>lwres_gabnrequest_t</type>
201 structures referenced via
202 <parameter>structp</parameter>.
204 Any memory associated with ancillary buffers and strings for those
205 structures is also discarded.
209 <title>RETURN VALUES</title>
211 The getaddrbyname opcode functions
212 <function>lwres_gabnrequest_render()</function>,
213 <function>lwres_gabnresponse_render()</function>
214 <function>lwres_gabnrequest_parse()</function>
216 <function>lwres_gabnresponse_parse()</function>
218 <errorcode>LWRES_R_SUCCESS</errorcode>
221 <errorcode>LWRES_R_NOMEMORY</errorcode>
222 if memory allocation fails.
223 <errorcode>LWRES_R_UNEXPECTEDEND</errorcode>
224 is returned if the available space in the buffer
225 <parameter>b</parameter>
226 is too small to accommodate the packet header or the
227 <type>lwres_gabnrequest_t</type>
229 <type>lwres_gabnresponse_t</type>
231 <function>lwres_gabnrequest_parse()</function>
233 <function>lwres_gabnresponse_parse()</function>
235 <errorcode>LWRES_R_UNEXPECTEDEND</errorcode>
236 if the buffer is not empty after decoding the received packet.
237 These functions will return
238 <errorcode>LWRES_R_FAILURE</errorcode>
240 <structfield>pktflags</structfield>
241 in the packet header structure
242 <type>lwres_lwpacket_t</type>
243 indicate that the packet is not a response to an earlier query.
247 <title>SEE ALSO</title>
250 <refentrytitle>lwres_packet</refentrytitle><manvolnum>3