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

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