/contrib/bind9/lib/lwres/man/lwres_packet.html

https://bitbucket.org/freebsd/freebsd-head/ · HTML · 235 lines · 217 code · 1 blank · 17 comment · 0 complexity · ed5551e0224a8d573d5fc8074c0e95c1 MD5 · raw file

  1. <!--
  2. - Copyright (C) 2004, 2005, 2007, 2012 Internet Systems Consortium, Inc. ("ISC")
  3. - Copyright (C) 2000, 2001 Internet Software Consortium.
  4. -
  5. - Permission to use, copy, modify, and/or distribute this software for any
  6. - purpose with or without fee is hereby granted, provided that the above
  7. - copyright notice and this permission notice appear in all copies.
  8. -
  9. - THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
  10. - REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
  11. - AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
  12. - INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  13. - LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
  14. - OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. - PERFORMANCE OF THIS SOFTWARE.
  16. -->
  17. <!-- $Id$ -->
  18. <html>
  19. <head>
  20. <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
  21. <title>lwres_packet</title>
  22. <meta name="generator" content="DocBook XSL Stylesheets V1.71.1">
  23. </head>
  24. <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="refentry" lang="en">
  25. <a name="id2476275"></a><div class="titlepage"></div>
  26. <div class="refnamediv">
  27. <h2>Name</h2>
  28. <p>lwres_lwpacket_renderheader, lwres_lwpacket_parseheader &#8212; lightweight resolver packet handling functions</p>
  29. </div>
  30. <div class="refsynopsisdiv">
  31. <h2>Synopsis</h2>
  32. <div class="funcsynopsis">
  33. <pre class="funcsynopsisinfo">#include &lt;lwres/lwpacket.h&gt;</pre>
  34. <table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" style="padding-bottom: 1em">
  35. <tr>
  36. <td><code class="funcdef">
  37. lwres_result_t
  38. <b class="fsfunc">lwres_lwpacket_renderheader</b>(</code></td>
  39. <td>lwres_buffer_t * </td>
  40. <td>
  41. <var class="pdparam">b</var>, </td>
  42. </tr>
  43. <tr>
  44. <td> </td>
  45. <td>lwres_lwpacket_t * </td>
  46. <td>
  47. <var class="pdparam">pkt</var><code>)</code>;</td>
  48. </tr>
  49. </table>
  50. <table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0">
  51. <tr>
  52. <td><code class="funcdef">
  53. lwres_result_t
  54. <b class="fsfunc">lwres_lwpacket_parseheader</b>(</code></td>
  55. <td>lwres_buffer_t * </td>
  56. <td>
  57. <var class="pdparam">b</var>, </td>
  58. </tr>
  59. <tr>
  60. <td> </td>
  61. <td>lwres_lwpacket_t * </td>
  62. <td>
  63. <var class="pdparam">pkt</var><code>)</code>;</td>
  64. </tr>
  65. </table>
  66. </div>
  67. </div>
  68. <div class="refsect1" lang="en">
  69. <a name="id2543394"></a><h2>DESCRIPTION</h2>
  70. <p>
  71. These functions rely on a
  72. <span class="type">struct lwres_lwpacket</span>
  73. which is defined in
  74. <code class="filename">lwres/lwpacket.h</code>.
  75. </p>
  76. <pre class="programlisting">
  77. typedef struct lwres_lwpacket lwres_lwpacket_t;
  78. </pre>
  79. <p>
  80. </p>
  81. <pre class="programlisting">
  82. struct lwres_lwpacket {
  83. lwres_uint32_t length;
  84. lwres_uint16_t version;
  85. lwres_uint16_t pktflags;
  86. lwres_uint32_t serial;
  87. lwres_uint32_t opcode;
  88. lwres_uint32_t result;
  89. lwres_uint32_t recvlength;
  90. lwres_uint16_t authtype;
  91. lwres_uint16_t authlength;
  92. };
  93. </pre>
  94. <p>
  95. </p>
  96. <p>
  97. The elements of this structure are:
  98. </p>
  99. <div class="variablelist"><dl>
  100. <dt><span class="term"><code class="constant">length</code></span></dt>
  101. <dd><p>
  102. the overall packet length, including the entire packet header.
  103. This field is filled in by the lwres_gabn_*() and lwres_gnba_*()
  104. calls.
  105. </p></dd>
  106. <dt><span class="term"><code class="constant">version</code></span></dt>
  107. <dd><p>
  108. the header format. There is currently only one format,
  109. <span class="type">LWRES_LWPACKETVERSION_0</span>.
  110. This field is filled in by the lwres_gabn_*() and lwres_gnba_*()
  111. calls.
  112. </p></dd>
  113. <dt><span class="term"><code class="constant">pktflags</code></span></dt>
  114. <dd><p>
  115. library-defined flags for this packet: for instance whether the
  116. packet
  117. is a request or a reply. Flag values can be set, but not defined
  118. by
  119. the caller.
  120. This field is filled in by the application wit the exception of
  121. the
  122. LWRES_LWPACKETFLAG_RESPONSE bit, which is set by the library in
  123. the
  124. lwres_gabn_*() and lwres_gnba_*() calls.
  125. </p></dd>
  126. <dt><span class="term"><code class="constant">serial</code></span></dt>
  127. <dd><p>
  128. is set by the requestor and is returned in all replies. If two
  129. or more
  130. packets from the same source have the same serial number and are
  131. from
  132. the same source, they are assumed to be duplicates and the
  133. latter ones
  134. may be dropped.
  135. This field must be set by the application.
  136. </p></dd>
  137. <dt><span class="term"><code class="constant">opcode</code></span></dt>
  138. <dd><p>
  139. indicates the operation.
  140. Opcodes between 0x00000000 and 0x03ffffff are
  141. reserved for use by the lightweight resolver library. Opcodes
  142. between
  143. 0x04000000 and 0xffffffff are application defined.
  144. This field is filled in by the lwres_gabn_*() and lwres_gnba_*()
  145. calls.
  146. </p></dd>
  147. <dt><span class="term"><code class="constant">result</code></span></dt>
  148. <dd><p>
  149. is only valid for replies.
  150. Results between 0x04000000 and 0xffffffff are application
  151. defined.
  152. Results between 0x00000000 and 0x03ffffff are reserved for
  153. library use.
  154. This field is filled in by the lwres_gabn_*() and lwres_gnba_*()
  155. calls.
  156. </p></dd>
  157. <dt><span class="term"><code class="constant">recvlength</code></span></dt>
  158. <dd><p>
  159. is the maximum buffer size that the receiver can handle on
  160. requests
  161. and the size of the buffer needed to satisfy a request when the
  162. buffer
  163. is too large for replies.
  164. This field is supplied by the application.
  165. </p></dd>
  166. <dt><span class="term"><code class="constant">authtype</code></span></dt>
  167. <dd><p>
  168. defines the packet level authentication that is used.
  169. Authorisation types between 0x1000 and 0xffff are application
  170. defined
  171. and types between 0x0000 and 0x0fff are reserved for library
  172. use.
  173. Currently these are not used and must be zero.
  174. </p></dd>
  175. <dt><span class="term"><code class="constant">authlen</code></span></dt>
  176. <dd><p>
  177. gives the length of the authentication data.
  178. Since packet authentication is currently not used, this must be
  179. zero.
  180. </p></dd>
  181. </dl></div>
  182. <p>
  183. </p>
  184. <p>
  185. The following opcodes are currently defined:
  186. </p>
  187. <div class="variablelist"><dl>
  188. <dt><span class="term"><code class="constant">NOOP</code></span></dt>
  189. <dd><p>
  190. Success is always returned and the packet contents are echoed.
  191. The lwres_noop_*() functions should be used for this type.
  192. </p></dd>
  193. <dt><span class="term"><code class="constant">GETADDRSBYNAME</code></span></dt>
  194. <dd><p>
  195. returns all known addresses for a given name.
  196. The lwres_gabn_*() functions should be used for this type.
  197. </p></dd>
  198. <dt><span class="term"><code class="constant">GETNAMEBYADDR</code></span></dt>
  199. <dd><p>
  200. return the hostname for the given address.
  201. The lwres_gnba_*() functions should be used for this type.
  202. </p></dd>
  203. </dl></div>
  204. <p>
  205. </p>
  206. <p><code class="function">lwres_lwpacket_renderheader()</code>
  207. transfers the contents of lightweight resolver packet structure
  208. <span class="type">lwres_lwpacket_t</span> <em class="parameter"><code>*pkt</code></em> in
  209. network byte order to the lightweight resolver buffer,
  210. <em class="parameter"><code>*b</code></em>.
  211. </p>
  212. <p><code class="function">lwres_lwpacket_parseheader()</code>
  213. performs the converse operation. It transfers data in network
  214. byte order from buffer <em class="parameter"><code>*b</code></em> to resolver
  215. packet <em class="parameter"><code>*pkt</code></em>. The contents of the buffer
  216. <em class="parameter"><code>b</code></em> should correspond to a
  217. <span class="type">lwres_lwpacket_t</span>.
  218. </p>
  219. </div>
  220. <div class="refsect1" lang="en">
  221. <a name="id2543710"></a><h2>RETURN VALUES</h2>
  222. <p>
  223. Successful calls to
  224. <code class="function">lwres_lwpacket_renderheader()</code> and
  225. <code class="function">lwres_lwpacket_parseheader()</code> return
  226. <span class="errorcode">LWRES_R_SUCCESS</span>. If there is insufficient
  227. space to copy data between the buffer <em class="parameter"><code>*b</code></em> and
  228. lightweight resolver packet <em class="parameter"><code>*pkt</code></em> both
  229. functions
  230. return <span class="errorcode">LWRES_R_UNEXPECTEDEND</span>.
  231. </p>
  232. </div>
  233. </div></body>
  234. </html>