]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/bind9/lib/lwres/man/lwres.docbook
This commit was generated by cvs2svn to compensate for changes in r162621,
[FreeBSD/FreeBSD.git] / contrib / bind9 / lib / lwres / man / lwres.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.docbook,v 1.3.206.3 2005/05/12 21:36:11 sra Exp $ -->
22
23 <refentry>
24 <refentryinfo>
25
26 <date>Jun 30, 2000</date>
27 </refentryinfo>
28 <refmeta>
29 <refentrytitle>lwres</refentrytitle>
30 <manvolnum>3</manvolnum>
31 <refmiscinfo>BIND9</refmiscinfo>
32 </refmeta>
33
34   <docinfo>
35     <copyright>
36       <year>2004</year>
37       <year>2005</year>
38       <holder>Internet Systems Consortium, Inc. ("ISC")</holder>
39     </copyright>
40     <copyright>
41       <year>2000</year>
42       <year>2001</year>
43       <holder>Internet Software Consortium.</holder>
44     </copyright>
45   </docinfo>
46
47 <refnamediv>
48 <refname>lwres</refname>
49 <refpurpose>introduction to the lightweight resolver library</refpurpose>
50 </refnamediv>
51
52 <refsynopsisdiv>
53 <funcsynopsis>
54 <funcsynopsisinfo>#include &lt;lwres/lwres.h&gt;</funcsynopsisinfo>
55 </funcsynopsis>
56 </refsynopsisdiv>
57
58 <refsect1>
59 <title>DESCRIPTION</title>
60 <para>
61 The BIND 9 lightweight resolver library is a simple, name service
62 independent stub resolver library.  It provides hostname-to-address
63 and address-to-hostname lookup services to applications by
64 transmitting lookup requests to a resolver daemon
65 <command>lwresd</command>
66 running on the local host. The resover daemon performs the
67 lookup using the DNS or possibly other name service protocols,
68 and returns the results to the application through the library.  
69 The library and resolver daemon communicate using a simple
70 UDP-based protocol.
71 </para>
72 </refsect1>
73
74 <refsect1>
75 <title>OVERVIEW</title>
76 <para>
77 The lwresd library implements multiple name service APIs.
78 The standard
79 <function>gethostbyname()</function>,
80 <function>gethostbyaddr()</function>,
81 <function>gethostbyname_r()</function>,
82 <function>gethostbyaddr_r()</function>,
83 <function>getaddrinfo()</function>,
84 <function>getipnodebyname()</function>,
85 and
86 <function>getipnodebyaddr()</function>
87 functions are all supported.  To allow the lwres library to coexist
88 with system libraries that define functions of the same name,
89 the library defines these functions with names prefixed by
90 <literal>lwres_</literal>.
91 To define the standard names, applications must include the
92 header file
93 <filename>&lt;lwres/netdb.h&gt;</filename>
94 which contains macro definitions mapping the standard function names
95 into
96 <literal>lwres_</literal>
97 prefixed ones.  Operating system vendors who integrate the lwres
98 library into their base distributions should rename the functions
99 in the library proper so that the renaming macros are not needed.
100 </para>
101 <para>
102 The library also provides a native API consisting of the functions
103 <function>lwres_getaddrsbyname()</function>
104 and
105 <function>lwres_getnamebyaddr()</function>.
106 These may be called by applications that require more detailed
107 control over the lookup process than the standard functions
108 provide.
109 </para>
110 <para>
111 In addition to these name service independent address lookup
112 functions, the library implements a new, experimental API
113 for looking up arbitrary DNS resource records, using the
114 <function>lwres_getaddrsbyname()</function>
115 function.
116 </para>
117 <para>
118 Finally, there is a low-level API for converting lookup
119 requests and responses to and from raw lwres protocol packets.  
120 This API can be used by clients requiring nonblocking operation, 
121 and is also used when implementing the server side of the lwres
122 protocol, for example in the
123 <command>lwresd</command>
124 resolver daemon.  The use of this low-level API in clients
125 and servers is outlined in the following sections.
126 </para>
127 </refsect1>
128 <refsect1>
129 <title>CLIENT-SIDE LOW-LEVEL API CALL FLOW</title>
130 <para>
131 When a client program wishes to make an lwres request using the
132 native low-level API, it typically performs the following 
133 sequence of actions.
134 </para>
135 <para>
136 (1) Allocate or use an existing <type>lwres_packet_t</type>,
137 called <varname>pkt</varname> below.
138 </para>
139 <para>
140 (2) Set <structfield>pkt.recvlength</structfield> to the maximum length we will accept.  
141 This is done so the receiver of our packets knows how large our receive 
142 buffer is.  The "default" is a constant in
143 <filename>lwres.h</filename>: <constant>LWRES_RECVLENGTH = 4096</constant>.
144 </para>
145 <para>
146 (3) Set <structfield>pkt.serial</structfield>
147 to a unique serial number.  This value is echoed
148 back to the application by the remote server.
149 </para>
150 <para>
151 (4) Set <structfield>pkt.pktflags</structfield>.  Usually this is set to 0.
152 </para>
153 <para>
154 (5) Set <structfield>pkt.result</structfield> to 0.
155 </para>
156 <para>
157 (6) Call <function>lwres_*request_render()</function>, 
158 or marshall in the data using the primitives
159 such as <function>lwres_packet_render()</function>
160 and storing the packet data.
161 </para>
162 <para>
163 (7) Transmit the resulting buffer.
164 </para>
165 <para>
166 (8) Call <function>lwres_*response_parse()</function>
167 to parse any packets received.
168 </para>
169 <para>
170 (9) Verify that the opcode and serial match a request, and process the
171 packet specific information contained in the body.
172 </para>
173 </refsect1>
174 <refsect1>
175 <title>SERVER-SIDE LOW-LEVEL API CALL FLOW</title>
176 <para>
177 When implementing the server side of the lightweight resolver
178 protocol using the lwres library, a sequence of actions like the
179 following is typically involved in processing each request packet.
180 </para>
181 <para>
182 Note that the same <type>lwres_packet_t</type> is used
183 in both the <function>_parse()</function> and <function>_render()</function> calls,
184 with only a few modifications made
185 to the packet header's contents between uses.  This method is recommended
186 as it keeps the serial, opcode, and other fields correct.
187 </para>
188 <para>
189 (1) When a packet is received, call <function>lwres_*request_parse()</function> to
190 unmarshall it.  This returns a <type>lwres_packet_t</type> (also called <varname>pkt</varname>, below)
191 as well as a data specific type, such as <type>lwres_gabnrequest_t</type>.
192 </para>
193 <para>
194 (2) Process the request in the data specific type.
195 </para>
196 <para>
197 (3) Set the <structfield>pkt.result</structfield>,
198 <structfield>pkt.recvlength</structfield> as above.  All other fields can
199 be left untouched since they were filled in by the <function>*_parse()</function> call
200 above.  If using <function>lwres_*response_render()</function>,
201 <structfield>pkt.pktflags</structfield> will be set up
202 properly.  Otherwise, the <constant>LWRES_LWPACKETFLAG_RESPONSE</constant> bit should be
203 set.
204 </para>
205 <para>
206 (4) Call the data specific rendering function, such as
207 <function>lwres_gabnresponse_render()</function>.
208 </para>
209 <para>
210 (5) Send the resulting packet to the client.
211 </para>
212 <para>
213 </para>
214 </refsect1>
215 <refsect1>
216 <title>SEE ALSO</title>
217 <para>
218 <citerefentry>
219 <refentrytitle>lwres_gethostent</refentrytitle><manvolnum>3</manvolnum>
220 </citerefentry>,
221
222 <citerefentry>
223 <refentrytitle>lwres_getipnode</refentrytitle><manvolnum>3</manvolnum>
224 </citerefentry>,
225
226 <citerefentry>
227 <refentrytitle>lwres_getnameinfo</refentrytitle><manvolnum>3</manvolnum>
228 </citerefentry>,
229
230 <citerefentry>
231 <refentrytitle>lwres_noop</refentrytitle><manvolnum>3</manvolnum>
232 </citerefentry>,
233
234 <citerefentry>
235 <refentrytitle>lwres_gabn</refentrytitle><manvolnum>3</manvolnum>
236 </citerefentry>,
237
238 <citerefentry>
239 <refentrytitle>lwres_gnba</refentrytitle><manvolnum>3</manvolnum>
240 </citerefentry>,
241
242 <citerefentry>
243 <refentrytitle>lwres_context</refentrytitle><manvolnum>3</manvolnum>
244 </citerefentry>,
245
246 <citerefentry>
247 <refentrytitle>lwres_config</refentrytitle><manvolnum>3</manvolnum>
248 </citerefentry>,
249
250 <citerefentry>
251 <refentrytitle>resolver</refentrytitle><manvolnum>5</manvolnum>
252 </citerefentry>,
253
254 <citerefentry>
255 <refentrytitle>lwresd</refentrytitle><manvolnum>8</manvolnum>
256 </citerefentry>.
257
258 </para>
259 </refsect1>
260 </refentry>