]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/bind9/lib/lwres/man/lwres_resutil.docbook
This commit was generated by cvs2svn to compensate for changes in r162852,
[FreeBSD/FreeBSD.git] / contrib / bind9 / lib / lwres / man / lwres_resutil.docbook
1 <!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.0//EN"
2                "http://www.oasis-open.org/docbook/xml/4.0/docbookx.dtd"
3                [<!ENTITY mdash "&#8212;">]>
4 <!--
5  - Copyright (C) 2004, 2005  Internet Systems Consortium, Inc. ("ISC")
6  - Copyright (C) 2000, 2001  Internet Software Consortium.
7  -
8  - Permission to use, copy, modify, and 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 -->
20
21 <!-- $Id: lwres_resutil.docbook,v 1.5.206.3 2005/05/12 21:36:16 sra Exp $ -->
22
23 <refentry>
24
25 <refentryinfo>
26 <date>Jun 30, 2000</date>
27 </refentryinfo>
28
29 <refmeta>
30   <refentrytitle>lwres_resutil</refentrytitle>
31   <manvolnum>3</manvolnum>
32   <refmiscinfo>BIND9</refmiscinfo>
33 </refmeta>
34
35   <docinfo>
36     <copyright>
37       <year>2004</year>
38       <year>2005</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>
47
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 *b</paramdef>
63 <paramdef>char **c</paramdef>
64 <paramdef>lwres_uint16_t *len</paramdef>
65 </funcprototype>
66 <funcprototype>
67 <funcdef>
68 lwres_result_t
69 <function>lwres_addr_parse</function></funcdef>
70 <paramdef>lwres_buffer_t *b</paramdef>
71 <paramdef>lwres_addr_t *addr</paramdef>
72 </funcprototype>
73 <funcprototype>
74 <funcdef>
75 lwres_result_t
76 <function>lwres_getaddrsbyname</function></funcdef>
77 <paramdef>lwres_context_t *ctx</paramdef>
78 <paramdef>const char *name</paramdef>
79 <paramdef>lwres_uint32_t addrtypes</paramdef>
80 <paramdef>lwres_gabnresponse_t **structp</paramdef>
81 </funcprototype>
82 <funcprototype>
83 <funcdef>
84 lwres_result_t
85 <function>lwres_getnamebyaddr</function></funcdef>
86 <paramdef>lwres_context_t *ctx</paramdef>
87 <paramdef>lwres_uint32_t addrtype</paramdef>
88 <paramdef>lwres_uint16_t addrlen</paramdef>
89 <paramdef>const unsigned char *addr</paramdef>
90 <paramdef>lwres_gnbaresponse_t **structp</paramdef>
91 </funcprototype>
92 </funcsynopsis>
93 </refsynopsisdiv>
94
95 <refsect1>
96 <title>DESCRIPTION</title>
97
98 <para>
99 <function>lwres_string_parse()</function> retrieves a DNS-encoded
100 string starting the current pointer of lightweight resolver buffer
101 <parameter>b</parameter>: i.e.  <constant>b-&gt;current</constant>.
102 When the function returns, the address of the first byte of the
103 encoded string is returned via <parameter>*c</parameter> and the
104 length of that string is given by <parameter>*len</parameter>.  The
105 buffer's current pointer is advanced to point at the character
106 following the string length, the encoded string, and the trailing
107 <type>NULL</type> character.
108 </para>
109
110 <para>
111 <function>lwres_addr_parse()</function> extracts an address from the
112 buffer <parameter>b</parameter>.  The buffer's current pointer
113 <constant>b-&gt;current</constant> is presumed to point at an encoded
114 address: the address preceded by a 32-bit protocol family identifier
115 and a 16-bit length 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 of
118 the address that was copied.  <constant>b-&gt;current</constant> is
119 advanced to point at the next byte of available data in the buffer
120 following the encoded address.
121 </para>
122
123 <para>
124 <function>lwres_getaddrsbyname()</function>
125 and
126 <function>lwres_getnamebyaddr()</function>
127 use the
128 <type>lwres_gnbaresponse_t</type>
129 structure defined below:
130 <programlisting>
131 typedef struct {
132         lwres_uint32_t          flags;
133         lwres_uint16_t          naliases;
134         lwres_uint16_t          naddrs;
135         char                   *realname;
136         char                  **aliases;
137         lwres_uint16_t          realnamelen;
138         lwres_uint16_t         *aliaslen;
139         lwres_addrlist_t        addrs;
140         void                   *base;
141         size_t                  baselen;
142 } lwres_gabnresponse_t;
143 </programlisting>
144 The contents of this structure are not manipulated directly but
145 they are controlled through the
146 <citerefentry>
147 <refentrytitle>lwres_gabn</refentrytitle><manvolnum>3
148 </manvolnum>
149 </citerefentry>
150 functions.
151 </para>
152
153 <para>
154 The lightweight resolver uses
155 <function>lwres_getaddrsbyname()</function> to perform foward lookups.
156 Hostname <parameter>name</parameter> is looked up using the resolver
157 context <parameter>ctx</parameter> for memory allocation.
158 <parameter>addrtypes</parameter> is a bitmask indicating which type of
159 addresses are to be looked up.  Current values for this bitmask are
160 <type>LWRES_ADDRTYPE_V4</type> for IPv4 addresses and
161 <type>LWRES_ADDRTYPE_V6</type> for IPv6 addresses.  Results of the
162 lookup are returned in <parameter>*structp</parameter>.
163 </para>
164
165 <para>
166 <function>lwres_getnamebyaddr()</function> performs reverse lookups.
167 Resolver context <parameter>ctx</parameter> is used for memory
168 allocation.  The address type is indicated by
169 <parameter>addrtype</parameter>: <type>LWRES_ADDRTYPE_V4</type> or
170 <type>LWRES_ADDRTYPE_V6</type>.  The address to be looked up is given
171 by <parameter>addr</parameter> and its length is
172 <parameter>addrlen</parameter> bytes.  The result of the function call
173 is made available through <parameter>*structp</parameter>.
174 </para>
175 </refsect1>
176
177 <refsect1>
178 <title>RETURN VALUES</title>
179 <para>
180 Successful calls to
181 <function>lwres_string_parse()</function>
182 and
183 <function>lwres_addr_parse()</function>
184 return
185 <errorcode>LWRES_R_SUCCESS.</errorcode>
186 Both functions return
187 <errorcode>LWRES_R_FAILURE</errorcode>
188 if the buffer is corrupt or
189 <errorcode>LWRES_R_UNEXPECTEDEND</errorcode>
190 if the buffer has less space than expected for the components of the
191 encoded string or address.
192 </para>
193 <para>
194 <function>lwres_getaddrsbyname()</function>
195 returns
196 <errorcode>LWRES_R_SUCCESS</errorcode>
197 on success and it returns
198 <errorcode>LWRES_R_NOTFOUND</errorcode>
199 if the hostname
200 <parameter>name</parameter>
201 could not be found.
202 </para>
203 <para>
204 <errorcode>LWRES_R_SUCCESS</errorcode>
205 is returned by a successful call to
206 <function>lwres_getnamebyaddr()</function>.
207 </para>
208
209 <para>
210 Both
211 <function>lwres_getaddrsbyname()</function>
212 and
213 <function>lwres_getnamebyaddr()</function>
214 return
215 <errorcode>LWRES_R_NOMEMORY</errorcode>
216 when memory allocation requests fail and
217 <errorcode>LWRES_R_UNEXPECTEDEND</errorcode>
218 if the buffers used for sending queries and receiving replies are too
219 small.
220 </para>
221
222 </refsect1>
223 <refsect1>
224 <title>SEE ALSO</title>
225 <para>
226 <citerefentry>
227 <refentrytitle>lwres_buffer</refentrytitle><manvolnum>3</manvolnum>
228 </citerefentry>,
229
230 <citerefentry>
231 <refentrytitle>lwres_gabn</refentrytitle><manvolnum>3</manvolnum>
232 </citerefentry>.
233 </para>
234
235 </refsect1>
236 </refentry>