1 <!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
2 "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd"
3 [<!ENTITY mdash "—">]>
5 - Copyright (C) 2004, 2005, 2007, 2014 Internet Systems Consortium, Inc. ("ISC")
6 - Copyright (C) 2000, 2001 Internet Software Consortium.
8 - Permission to use, copy, modify, and/or distribute this software for any
9 - purpose with or without fee is hereby granted, provided that the above
10 - copyright notice and this permission notice appear in all copies.
12 - THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
13 - REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
14 - AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
15 - INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
16 - LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
17 - OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
18 - PERFORMANCE OF THIS SOFTWARE.
24 <date>June 18, 2007</date>
28 <refentrytitle>lwres_gabn</refentrytitle>
29 <manvolnum>3</manvolnum>
30 <refmiscinfo>BIND9</refmiscinfo>
39 <holder>Internet Systems Consortium, Inc. ("ISC")</holder>
44 <holder>Internet Software Consortium.</holder>
49 <refname>lwres_gabnrequest_render</refname>
50 <refname>lwres_gabnresponse_render</refname>
51 <refname>lwres_gabnrequest_parse</refname>
52 <refname>lwres_gabnresponse_parse</refname>
53 <refname>lwres_gabnresponse_free</refname>
54 <refname>lwres_gabnrequest_free</refname>
55 <refpurpose>lightweight resolver getaddrbyname message handling</refpurpose>
59 <funcsynopsisinfo>#include <lwres/lwres.h></funcsynopsisinfo>
63 <function>lwres_gabnrequest_render</function></funcdef>
64 <paramdef>lwres_context_t *<parameter>ctx</parameter></paramdef>
65 <paramdef>lwres_gabnrequest_t *<parameter>req</parameter></paramdef>
66 <paramdef>lwres_lwpacket_t *<parameter>pkt</parameter></paramdef>
67 <paramdef>lwres_buffer_t *<parameter>b</parameter></paramdef>
72 <function>lwres_gabnresponse_render</function></funcdef>
73 <paramdef>lwres_context_t *<parameter>ctx</parameter></paramdef>
74 <paramdef>lwres_gabnresponse_t *<parameter>req</parameter></paramdef>
75 <paramdef>lwres_lwpacket_t *<parameter>pkt</parameter></paramdef>
76 <paramdef>lwres_buffer_t *<parameter>b</parameter></paramdef>
81 <function>lwres_gabnrequest_parse</function></funcdef>
82 <paramdef>lwres_context_t *<parameter>ctx</parameter></paramdef>
83 <paramdef>lwres_buffer_t *<parameter>b</parameter></paramdef>
84 <paramdef>lwres_lwpacket_t *<parameter>pkt</parameter></paramdef>
85 <paramdef>lwres_gabnrequest_t **<parameter>structp</parameter></paramdef>
90 <function>lwres_gabnresponse_parse</function></funcdef>
91 <paramdef>lwres_context_t *<parameter>ctx</parameter></paramdef>
92 <paramdef>lwres_buffer_t *<parameter>b</parameter></paramdef>
93 <paramdef>lwres_lwpacket_t *<parameter>pkt</parameter></paramdef>
94 <paramdef>lwres_gabnresponse_t **<parameter>structp</parameter></paramdef>
99 <function>lwres_gabnresponse_free</function></funcdef>
100 <paramdef>lwres_context_t *<parameter>ctx</parameter></paramdef>
101 <paramdef>lwres_gabnresponse_t **<parameter>structp</parameter></paramdef>
106 <function>lwres_gabnrequest_free</function></funcdef>
107 <paramdef>lwres_context_t *<parameter>ctx</parameter></paramdef>
108 <paramdef>lwres_gabnrequest_t **<parameter>structp</parameter></paramdef>
113 <title>DESCRIPTION</title>
115 These are low-level routines for creating and parsing
116 lightweight resolver name-to-address lookup request and
120 There are four main functions for the getaddrbyname opcode.
121 One render function converts a getaddrbyname request structure —
122 <type>lwres_gabnrequest_t</type> —
123 to the lightweight resolver's canonical format.
124 It is complemented by a parse function that converts a packet in this
125 canonical format to a getaddrbyname request structure.
126 Another render function converts the getaddrbyname response structure
127 — <type>lwres_gabnresponse_t</type> —
128 to the canonical format.
129 This is complemented by a parse function which converts a packet in
130 canonical format to a getaddrbyname response structure.
133 These structures are defined in
134 <filename><lwres/lwres.h></filename>.
135 They are shown below.
137 <para><programlisting>
138 #define LWRES_OPCODE_GETADDRSBYNAME 0x00010001U
141 <para><programlisting>
142 typedef struct lwres_addr lwres_addr_t;
143 typedef LWRES_LIST(lwres_addr_t) lwres_addrlist_t;
146 <para><programlisting>
148 lwres_uint32_t flags;
149 lwres_uint32_t addrtypes;
150 lwres_uint16_t namelen;
152 } lwres_gabnrequest_t;
155 <para><programlisting>
157 lwres_uint32_t flags;
158 lwres_uint16_t naliases;
159 lwres_uint16_t naddrs;
162 lwres_uint16_t realnamelen;
163 lwres_uint16_t *aliaslen;
164 lwres_addrlist_t addrs;
167 } lwres_gabnresponse_t;
171 <para><function>lwres_gabnrequest_render()</function>
172 uses resolver context <parameter>ctx</parameter> to convert
173 getaddrbyname request structure <parameter>req</parameter> to
174 canonical format. The packet header structure
175 <parameter>pkt</parameter> is initialised and transferred to
176 buffer <parameter>b</parameter>.
178 The contents of <parameter>*req</parameter> are then appended to
179 the buffer in canonical format.
180 <function>lwres_gabnresponse_render()</function> performs the
181 same task, except it converts a getaddrbyname response structure
182 <type>lwres_gabnresponse_t</type> to the lightweight resolver's
186 <para><function>lwres_gabnrequest_parse()</function>
187 uses context <parameter>ctx</parameter> to convert the contents
188 of packet <parameter>pkt</parameter> to a
189 <type>lwres_gabnrequest_t</type> structure. Buffer
190 <parameter>b</parameter> provides space to be used for storing
191 this structure. When the function succeeds, the resulting
192 <type>lwres_gabnrequest_t</type> is made available through
193 <parameter>*structp</parameter>.
195 <function>lwres_gabnresponse_parse()</function> offers the same
196 semantics as <function>lwres_gabnrequest_parse()</function>
197 except it yields a <type>lwres_gabnresponse_t</type> structure.
200 <para><function>lwres_gabnresponse_free()</function>
201 and <function>lwres_gabnrequest_free()</function> release the
202 memory in resolver context <parameter>ctx</parameter> that was
203 allocated to the <type>lwres_gabnresponse_t</type> or
204 <type>lwres_gabnrequest_t</type> structures referenced via
205 <parameter>structp</parameter>.
207 Any memory associated with ancillary buffers and strings for
208 those structures is also discarded.
212 <title>RETURN VALUES</title>
214 The getaddrbyname opcode functions
215 <function>lwres_gabnrequest_render()</function>,
216 <function>lwres_gabnresponse_render()</function>
217 <function>lwres_gabnrequest_parse()</function>
219 <function>lwres_gabnresponse_parse()</function>
221 <errorcode>LWRES_R_SUCCESS</errorcode>
224 <errorcode>LWRES_R_NOMEMORY</errorcode>
225 if memory allocation fails.
226 <errorcode>LWRES_R_UNEXPECTEDEND</errorcode>
227 is returned if the available space in the buffer
228 <parameter>b</parameter>
229 is too small to accommodate the packet header or the
230 <type>lwres_gabnrequest_t</type>
232 <type>lwres_gabnresponse_t</type>
234 <function>lwres_gabnrequest_parse()</function>
236 <function>lwres_gabnresponse_parse()</function>
238 <errorcode>LWRES_R_UNEXPECTEDEND</errorcode>
239 if the buffer is not empty after decoding the received packet.
240 These functions will return
241 <errorcode>LWRES_R_FAILURE</errorcode>
243 <structfield>pktflags</structfield>
244 in the packet header structure
245 <type>lwres_lwpacket_t</type>
246 indicate that the packet is not a response to an earlier query.
250 <title>SEE ALSO</title>
252 <refentrytitle>lwres_packet</refentrytitle><manvolnum>3</manvolnum>