Remove building with NOCRYPTO option
[minix.git] / external / bsd / bind / dist / lib / lwres / man / lwres_resutil.docbook
blob0a0c4704aa2da45ef539abb915b14e0c065b6515
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 "&#8212;">]>
4 <!--
5  - Copyright (C) 2004, 2005, 2007, 2014  Internet Systems Consortium, Inc. ("ISC")
6  - Copyright (C) 2000, 2001  Internet Software Consortium.
7  -
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.
11  -
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.
19 -->
21 <refentry>
23   <refentryinfo>
24     <date>June 18, 2007</date>
25   </refentryinfo>
27   <refmeta>
28     <refentrytitle>lwres_resutil</refentrytitle>
29     <manvolnum>3</manvolnum>
30     <refmiscinfo>BIND9</refmiscinfo>
31   </refmeta>
33   <docinfo>
34     <copyright>
35       <year>2004</year>
36       <year>2005</year>
37       <year>2007</year>
38       <year>2014</year>
39       <holder>Internet Systems Consortium, Inc. ("ISC")</holder>
40     </copyright>
41     <copyright>
42       <year>2000</year>
43       <year>2001</year>
44       <holder>Internet Software Consortium.</holder>
45     </copyright>
46   </docinfo>
48   <refnamediv>
49     <refname>lwres_string_parse</refname>
50     <refname>lwres_addr_parse</refname>
51     <refname>lwres_getaddrsbyname</refname>
52     <refname>lwres_getnamebyaddr</refname>
53     <refpurpose>lightweight resolver utility functions</refpurpose>
54   </refnamediv>
55   <refsynopsisdiv>
56     <funcsynopsis>
57 <funcsynopsisinfo>#include &lt;lwres/lwres.h&gt;</funcsynopsisinfo>
58 <funcprototype>
59         <funcdef>
60 lwres_result_t
61 <function>lwres_string_parse</function></funcdef>
62         <paramdef>lwres_buffer_t *<parameter>b</parameter></paramdef>
63         <paramdef>char **<parameter>c</parameter></paramdef>
64         <paramdef>lwres_uint16_t *<parameter>len</parameter></paramdef>
65         </funcprototype>
66 <funcprototype>
67         <funcdef>
68 lwres_result_t
69 <function>lwres_addr_parse</function></funcdef>
70         <paramdef>lwres_buffer_t *<parameter>b</parameter></paramdef>
71         <paramdef>lwres_addr_t *<parameter>addr</parameter></paramdef>
72         </funcprototype>
73 <funcprototype>
74         <funcdef>
75 lwres_result_t
76 <function>lwres_getaddrsbyname</function></funcdef>
77         <paramdef>lwres_context_t *<parameter>ctx</parameter></paramdef>
78         <paramdef>const char *<parameter>name</parameter></paramdef>
79         <paramdef>lwres_uint32_t <parameter>addrtypes</parameter></paramdef>
80         <paramdef>lwres_gabnresponse_t **<parameter>structp</parameter></paramdef>
81         </funcprototype>
82 <funcprototype>
83         <funcdef>
84 lwres_result_t
85 <function>lwres_getnamebyaddr</function></funcdef>
86         <paramdef>lwres_context_t *<parameter>ctx</parameter></paramdef>
87         <paramdef>lwres_uint32_t <parameter>addrtype</parameter></paramdef>
88         <paramdef>lwres_uint16_t <parameter>addrlen</parameter></paramdef>
89         <paramdef>const unsigned char *<parameter>addr</parameter></paramdef>
90         <paramdef>lwres_gnbaresponse_t **<parameter>structp</parameter></paramdef>
91       </funcprototype>
92 </funcsynopsis>
93   </refsynopsisdiv>
95   <refsect1>
96     <title>DESCRIPTION</title>
98     <para><function>lwres_string_parse()</function>
99       retrieves a DNS-encoded string starting the current pointer of
100       lightweight resolver buffer <parameter>b</parameter>: i.e.
101       <constant>b-&gt;current</constant>.  When the function returns,
102       the address of the first byte of the encoded string is returned
103       via <parameter>*c</parameter> and the length of that string is
104       given by <parameter>*len</parameter>.  The buffer's current
105       pointer is advanced to point at the character following the
106       string length, the encoded string, and the trailing
107       <type>NULL</type> character.
108     </para>
110     <para><function>lwres_addr_parse()</function>
111       extracts an address from the buffer <parameter>b</parameter>.
112       The buffer's current pointer <constant>b-&gt;current</constant>
113       is presumed to point at an encoded address: the address preceded
114       by a 32-bit protocol family identifier and a 16-bit length
115       field.  The encoded address is copied to
116       <constant>addr-&gt;address</constant> and
117       <constant>addr-&gt;length</constant> indicates the size in bytes
118       of the address that was copied.
119       <constant>b-&gt;current</constant> is advanced to point at the
120       next byte of available data in the buffer following the encoded
121       address.
122     </para>
124     <para><function>lwres_getaddrsbyname()</function>
125       and <function>lwres_getnamebyaddr()</function> use the
126       <type>lwres_gnbaresponse_t</type> structure defined below:
127     </para>
129 <para><programlisting>
130 typedef struct {
131         lwres_uint32_t          flags;
132         lwres_uint16_t          naliases;
133         lwres_uint16_t          naddrs;
134         char                   *realname;
135         char                  **aliases;
136         lwres_uint16_t          realnamelen;
137         lwres_uint16_t         *aliaslen;
138         lwres_addrlist_t        addrs;
139         void                   *base;
140         size_t                  baselen;
141 } lwres_gabnresponse_t;
142 </programlisting></para>
144     <para>
145       The contents of this structure are not manipulated directly but
146       they are controlled through the
147       <citerefentry>
148         <refentrytitle>lwres_gabn</refentrytitle><manvolnum>3</manvolnum>
149       </citerefentry>
150       functions.
151     </para>
153     <para>
154       The lightweight resolver uses
155       <function>lwres_getaddrsbyname()</function> to perform
156       forward lookups.
157       Hostname <parameter>name</parameter> is looked up using the
158       resolver
159       context <parameter>ctx</parameter> for memory allocation.
160       <parameter>addrtypes</parameter> is a bitmask indicating
161       which type of
162       addresses are to be looked up.  Current values for this bitmask are
163       <type>LWRES_ADDRTYPE_V4</type> for IPv4 addresses and
164       <type>LWRES_ADDRTYPE_V6</type> for IPv6 addresses.  Results of the
165       lookup are returned in <parameter>*structp</parameter>.
166     </para>
168     <para><function>lwres_getnamebyaddr()</function>
169       performs reverse lookups.  Resolver context
170       <parameter>ctx</parameter> is used for memory allocation.  The
171       address type is indicated by <parameter>addrtype</parameter>:
172       <type>LWRES_ADDRTYPE_V4</type> or
173       <type>LWRES_ADDRTYPE_V6</type>.  The address to be looked up is
174       given by <parameter>addr</parameter> and its length is
175       <parameter>addrlen</parameter> bytes.  The result of the
176       function call is made available through
177       <parameter>*structp</parameter>.
178     </para>
179   </refsect1>
181   <refsect1>
182     <title>RETURN VALUES</title>
183     <para>
184       Successful calls to
185       <function>lwres_string_parse()</function>
186       and
187       <function>lwres_addr_parse()</function>
188       return
189       <errorcode>LWRES_R_SUCCESS.</errorcode>
190       Both functions return
191       <errorcode>LWRES_R_FAILURE</errorcode>
192       if the buffer is corrupt or
193       <errorcode>LWRES_R_UNEXPECTEDEND</errorcode>
194       if the buffer has less space than expected for the components of the
195       encoded string or address.
196     </para>
198     <para><function>lwres_getaddrsbyname()</function>
199       returns <errorcode>LWRES_R_SUCCESS</errorcode> on success and it
200       returns <errorcode>LWRES_R_NOTFOUND</errorcode> if the hostname
201       <parameter>name</parameter> could not be found.
202     </para>
203     <para><errorcode>LWRES_R_SUCCESS</errorcode>
204       is returned by a successful call to
205       <function>lwres_getnamebyaddr()</function>.
206     </para>
208     <para>
209       Both
210       <function>lwres_getaddrsbyname()</function>
211       and
212       <function>lwres_getnamebyaddr()</function>
213       return
214       <errorcode>LWRES_R_NOMEMORY</errorcode>
215       when memory allocation requests fail and
216       <errorcode>LWRES_R_UNEXPECTEDEND</errorcode>
217       if the buffers used for sending queries and receiving replies are too
218       small.
219     </para>
221   </refsect1>
222   <refsect1>
223     <title>SEE ALSO</title>
224     <para><citerefentry>
225         <refentrytitle>lwres_buffer</refentrytitle><manvolnum>3</manvolnum>
226       </citerefentry>,
228       <citerefentry>
229         <refentrytitle>lwres_gabn</refentrytitle><manvolnum>3</manvolnum>
230       </citerefentry>.
231     </para>
233   </refsect1>
234 </refentry><!--
235  - Local variables:
236  - mode: sgml
237  - End: