PageRenderTime 23ms CodeModel.GetById 15ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 1ms

/contrib/bind9/lib/lwres/man/lwres.docbook

https://bitbucket.org/freebsd/freebsd-head/
Unknown | 266 lines | 249 code | 17 blank | 0 comment | 0 complexity | 5780140269933cb4a47db1e252e4e1a7 MD5 | raw file
  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  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-->
 20
 21<!-- $Id: lwres.docbook,v 1.10 2007/06/18 23:47:51 tbox Exp $ -->
 22<refentry>
 23
 24  <refentryinfo>
 25    <date>Jun 30, 2000</date>
 26  </refentryinfo>
 27
 28  <refmeta>
 29    <refentrytitle>lwres</refentrytitle>
 30    <manvolnum>3</manvolnum>
 31    <refmiscinfo>BIND9</refmiscinfo>
 32  </refmeta>
 33  <refnamediv>
 34    <refname>lwres</refname>
 35    <refpurpose>introduction to the lightweight resolver library</refpurpose>
 36  </refnamediv>
 37
 38  <docinfo>
 39    <copyright>
 40      <year>2004</year>
 41      <year>2005</year>
 42      <year>2007</year>
 43      <holder>Internet Systems Consortium, Inc. ("ISC")</holder>
 44    </copyright>
 45    <copyright>
 46      <year>2000</year>
 47      <year>2001</year>
 48      <holder>Internet Software Consortium.</holder>
 49    </copyright>
 50  </docinfo>
 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
141      we will accept.
142      This is done so the receiver of our packets knows how large our receive
143      buffer is.  The "default" is a constant in
144      <filename>lwres.h</filename>: <constant>LWRES_RECVLENGTH = 4096</constant>.
145    </para>
146    <para>
147      (3) Set <structfield>pkt.serial</structfield>
148      to a unique serial number.  This value is echoed
149      back to the application by the remote server.
150    </para>
151    <para>
152      (4) Set <structfield>pkt.pktflags</structfield>.  Usually this is set to
153      0.
154    </para>
155    <para>
156      (5) Set <structfield>pkt.result</structfield> to 0.
157    </para>
158    <para>
159      (6) Call <function>lwres_*request_render()</function>,
160      or marshall in the data using the primitives
161      such as <function>lwres_packet_render()</function>
162      and storing the packet data.
163    </para>
164    <para>
165      (7) Transmit the resulting buffer.
166    </para>
167    <para>
168      (8) Call <function>lwres_*response_parse()</function>
169      to parse any packets received.
170    </para>
171    <para>
172      (9) Verify that the opcode and serial match a request, and process the
173      packet specific information contained in the body.
174    </para>
175  </refsect1>
176  <refsect1>
177    <title>SERVER-SIDE LOW-LEVEL API CALL FLOW</title>
178    <para>
179      When implementing the server side of the lightweight resolver
180      protocol using the lwres library, a sequence of actions like the
181      following is typically involved in processing each request packet.
182    </para>
183    <para>
184      Note that the same <type>lwres_packet_t</type> is used
185      in both the <function>_parse()</function> and <function>_render()</function> calls,
186      with only a few modifications made
187      to the packet header's contents between uses.  This method is
188      recommended
189      as it keeps the serial, opcode, and other fields correct.
190    </para>
191    <para>
192      (1) When a packet is received, call <function>lwres_*request_parse()</function> to
193      unmarshall it.  This returns a <type>lwres_packet_t</type> (also called <varname>pkt</varname>, below)
194      as well as a data specific type, such as <type>lwres_gabnrequest_t</type>.
195    </para>
196    <para>
197      (2) Process the request in the data specific type.
198    </para>
199    <para>
200      (3) Set the <structfield>pkt.result</structfield>,
201      <structfield>pkt.recvlength</structfield> as above.  All other fields
202      can
203      be left untouched since they were filled in by the <function>*_parse()</function> call
204      above.  If using <function>lwres_*response_render()</function>,
205      <structfield>pkt.pktflags</structfield> will be set up
206      properly.  Otherwise, the <constant>LWRES_LWPACKETFLAG_RESPONSE</constant> bit should be
207      set.
208    </para>
209    <para>
210      (4) Call the data specific rendering function, such as
211      <function>lwres_gabnresponse_render()</function>.
212    </para>
213    <para>
214      (5) Send the resulting packet to the client.
215    </para>
216    <para></para>
217  </refsect1>
218  <refsect1>
219    <title>SEE ALSO</title>
220    <para><citerefentry>
221        <refentrytitle>lwres_gethostent</refentrytitle><manvolnum>3</manvolnum>
222      </citerefentry>,
223
224      <citerefentry>
225        <refentrytitle>lwres_getipnode</refentrytitle><manvolnum>3</manvolnum>
226      </citerefentry>,
227
228      <citerefentry>
229        <refentrytitle>lwres_getnameinfo</refentrytitle><manvolnum>3</manvolnum>
230      </citerefentry>,
231
232      <citerefentry>
233        <refentrytitle>lwres_noop</refentrytitle><manvolnum>3</manvolnum>
234      </citerefentry>,
235
236      <citerefentry>
237        <refentrytitle>lwres_gabn</refentrytitle><manvolnum>3</manvolnum>
238      </citerefentry>,
239
240      <citerefentry>
241        <refentrytitle>lwres_gnba</refentrytitle><manvolnum>3</manvolnum>
242      </citerefentry>,
243
244      <citerefentry>
245        <refentrytitle>lwres_context</refentrytitle><manvolnum>3</manvolnum>
246      </citerefentry>,
247
248      <citerefentry>
249        <refentrytitle>lwres_config</refentrytitle><manvolnum>3</manvolnum>
250      </citerefentry>,
251
252      <citerefentry>
253        <refentrytitle>resolver</refentrytitle><manvolnum>5</manvolnum>
254      </citerefentry>,
255
256      <citerefentry>
257        <refentrytitle>lwresd</refentrytitle><manvolnum>8</manvolnum>
258      </citerefentry>.
259
260    </para>
261  </refsect1>
262</refentry><!--
263 - Local variables:
264 - mode: sgml
265 - End:
266-->