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, 2012 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.
25 <date>Jun 30, 2000</date>
29 <refentrytitle>lwres_gnba</refentrytitle>
30 <manvolnum>3</manvolnum>
31 <refmiscinfo>BIND9</refmiscinfo>
40 <holder>Internet Systems Consortium, Inc. ("ISC")</holder>
45 <holder>Internet Software Consortium.</holder>
50 <refname>lwres_gnbarequest_render</refname>
51 <refname>lwres_gnbaresponse_render</refname>
52 <refname>lwres_gnbarequest_parse</refname>
53 <refname>lwres_gnbaresponse_parse</refname>
54 <refname>lwres_gnbaresponse_free</refname>
55 <refname>lwres_gnbarequest_free</refname>
56 <refpurpose>lightweight resolver getnamebyaddress message handling</refpurpose>
63 #include <lwres/lwres.h>
69 <function>lwres_gnbarequest_render</function>
71 <paramdef>lwres_context_t *<parameter>ctx</parameter></paramdef>
72 <paramdef>lwres_gnbarequest_t *<parameter>req</parameter></paramdef>
73 <paramdef>lwres_lwpacket_t *<parameter>pkt</parameter></paramdef>
74 <paramdef>lwres_buffer_t *<parameter>b</parameter></paramdef>
80 <function>lwres_gnbaresponse_render</function>
82 <paramdef>lwres_context_t *<parameter>ctx</parameter></paramdef>
83 <paramdef>lwres_gnbaresponse_t *<parameter>req</parameter></paramdef>
84 <paramdef>lwres_lwpacket_t *<parameter>pkt</parameter></paramdef>
85 <paramdef>lwres_buffer_t *<parameter>b</parameter></paramdef>
90 <function>lwres_gnbarequest_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_gnbarequest_t **<parameter>structp</parameter></paramdef>
99 <function>lwres_gnbaresponse_parse</function></funcdef>
100 <paramdef>lwres_context_t *<parameter>ctx</parameter></paramdef>
101 <paramdef>lwres_buffer_t *<parameter>b</parameter></paramdef>
102 <paramdef>lwres_lwpacket_t *<parameter>pkt</parameter></paramdef>
103 <paramdef>lwres_gnbaresponse_t **<parameter>structp</parameter></paramdef>
109 <function>lwres_gnbaresponse_free</function>
111 <paramdef>lwres_context_t *<parameter>ctx</parameter></paramdef>
112 <paramdef>lwres_gnbaresponse_t **<parameter>structp</parameter></paramdef>
117 <function>lwres_gnbarequest_free</function></funcdef>
118 <paramdef>lwres_context_t *<parameter>ctx</parameter></paramdef>
119 <paramdef>lwres_gnbarequest_t **<parameter>structp</parameter></paramdef>
126 <title>DESCRIPTION</title>
128 These are low-level routines for creating and parsing
129 lightweight resolver address-to-name lookup request and
133 There are four main functions for the getnamebyaddr opcode.
134 One render function converts a getnamebyaddr request structure —
135 <type>lwres_gnbarequest_t</type> —
136 to the lightweight resolver's canonical format.
137 It is complemented by a parse function that converts a packet in this
138 canonical format to a getnamebyaddr request structure.
139 Another render function converts the getnamebyaddr response structure
141 <type>lwres_gnbaresponse_t</type>
142 to the canonical format.
143 This is complemented by a parse function which converts a packet in
144 canonical format to a getnamebyaddr response structure.
147 These structures are defined in
148 <filename>lwres/lwres.h</filename>.
149 They are shown below.
151 <para><programlisting>
152 #define LWRES_OPCODE_GETNAMEBYADDR 0x00010002U
155 <para><programlisting>
157 lwres_uint32_t flags;
159 } lwres_gnbarequest_t;
162 <para><programlisting>
164 lwres_uint32_t flags;
165 lwres_uint16_t naliases;
168 lwres_uint16_t realnamelen;
169 lwres_uint16_t *aliaslen;
172 } lwres_gnbaresponse_t;
176 <para><function>lwres_gnbarequest_render()</function>
177 uses resolver context <varname>ctx</varname> to convert
178 getnamebyaddr request structure <varname>req</varname> to
179 canonical format. The packet header structure
180 <varname>pkt</varname> is initialised and transferred to buffer
181 <varname>b</varname>. The contents of <varname>*req</varname>
182 are then appended to the buffer in canonical format.
183 <function>lwres_gnbaresponse_render()</function> performs the
184 same task, except it converts a getnamebyaddr response structure
185 <type>lwres_gnbaresponse_t</type> to the lightweight resolver's
189 <para><function>lwres_gnbarequest_parse()</function>
190 uses context <varname>ctx</varname> to convert the contents of
191 packet <varname>pkt</varname> to a
192 <type>lwres_gnbarequest_t</type> structure. Buffer
193 <varname>b</varname> provides space to be used for storing this
194 structure. When the function succeeds, the resulting
195 <type>lwres_gnbarequest_t</type> is made available through
196 <varname>*structp</varname>.
197 <function>lwres_gnbaresponse_parse()</function> offers the same
198 semantics as <function>lwres_gnbarequest_parse()</function>
199 except it yields a <type>lwres_gnbaresponse_t</type> structure.
202 <para><function>lwres_gnbaresponse_free()</function>
203 and <function>lwres_gnbarequest_free()</function> release the
204 memory in resolver context <varname>ctx</varname> that was
205 allocated to the <type>lwres_gnbaresponse_t</type> or
206 <type>lwres_gnbarequest_t</type> structures referenced via
207 <varname>structp</varname>. Any memory associated with
208 ancillary buffers and strings for those structures is also
214 <title>RETURN VALUES</title>
216 The getnamebyaddr opcode functions
217 <function>lwres_gnbarequest_render()</function>,
218 <function>lwres_gnbaresponse_render()</function>
219 <function>lwres_gnbarequest_parse()</function>
221 <function>lwres_gnbaresponse_parse()</function>
223 <errorcode>LWRES_R_SUCCESS</errorcode>
226 <errorcode>LWRES_R_NOMEMORY</errorcode>
227 if memory allocation fails.
228 <errorcode>LWRES_R_UNEXPECTEDEND</errorcode>
229 is returned if the available space in the buffer
231 is too small to accommodate the packet header or the
232 <type>lwres_gnbarequest_t</type>
234 <type>lwres_gnbaresponse_t</type>
236 <function>lwres_gnbarequest_parse()</function>
238 <function>lwres_gnbaresponse_parse()</function>
240 <errorcode>LWRES_R_UNEXPECTEDEND</errorcode>
241 if the buffer is not empty after decoding the received packet.
242 These functions will return
243 <errorcode>LWRES_R_FAILURE</errorcode>
245 <structfield>pktflags</structfield>
246 in the packet header structure
247 <type>lwres_lwpacket_t</type>
248 indicate that the packet is not a response to an earlier query.
252 <title>SEE ALSO</title>
254 <refentrytitle>lwres_packet</refentrytitle><manvolnum>3</manvolnum>