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