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

https://bitbucket.org/freebsd/freebsd-head/ · HTML · 279 lines · 255 code · 7 blank · 17 comment · 0 complexity · 12b16571180607b05143abb64d4558af MD5 · raw file

  1. <!--
  2. - Copyright (C) 2004, 2005, 2007, 2012 Internet Systems Consortium, Inc. ("ISC")
  3. - Copyright (C) 2000, 2001, 2003 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_getipnode</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_getipnodebyname, lwres_getipnodebyaddr, lwres_freehostent &#8212; lightweight resolver nodename / address translation API</p>
  29. </div>
  30. <div class="refsynopsisdiv">
  31. <h2>Synopsis</h2>
  32. <div class="funcsynopsis">
  33. <pre class="funcsynopsisinfo">#include &lt;lwres/netdb.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. struct hostent *
  38. <b class="fsfunc">lwres_getipnodebyname</b>(</code></td>
  39. <td>const char * </td>
  40. <td>
  41. <var class="pdparam">name</var>, </td>
  42. </tr>
  43. <tr>
  44. <td> </td>
  45. <td>int  </td>
  46. <td>
  47. <var class="pdparam">af</var>, </td>
  48. </tr>
  49. <tr>
  50. <td> </td>
  51. <td>int  </td>
  52. <td>
  53. <var class="pdparam">flags</var>, </td>
  54. </tr>
  55. <tr>
  56. <td> </td>
  57. <td>int * </td>
  58. <td>
  59. <var class="pdparam">error_num</var><code>)</code>;</td>
  60. </tr>
  61. </table>
  62. <table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" style="padding-bottom: 1em">
  63. <tr>
  64. <td><code class="funcdef">
  65. struct hostent *
  66. <b class="fsfunc">lwres_getipnodebyaddr</b>(</code></td>
  67. <td>const void * </td>
  68. <td>
  69. <var class="pdparam">src</var>, </td>
  70. </tr>
  71. <tr>
  72. <td> </td>
  73. <td>size_t  </td>
  74. <td>
  75. <var class="pdparam">len</var>, </td>
  76. </tr>
  77. <tr>
  78. <td> </td>
  79. <td>int  </td>
  80. <td>
  81. <var class="pdparam">af</var>, </td>
  82. </tr>
  83. <tr>
  84. <td> </td>
  85. <td>int * </td>
  86. <td>
  87. <var class="pdparam">error_num</var><code>)</code>;</td>
  88. </tr>
  89. </table>
  90. <table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0"><tr>
  91. <td><code class="funcdef">
  92. void
  93. <b class="fsfunc">lwres_freehostent</b>(</code></td>
  94. <td>struct hostent * </td>
  95. <td>
  96. <var class="pdparam">he</var><code>)</code>;</td>
  97. </tr></table>
  98. </div>
  99. </div>
  100. <div class="refsect1" lang="en">
  101. <a name="id2543435"></a><h2>DESCRIPTION</h2>
  102. <p>
  103. These functions perform thread safe, protocol independent
  104. nodename-to-address and address-to-nodename
  105. translation as defined in RFC2553.
  106. </p>
  107. <p>
  108. They use a
  109. <span class="type">struct hostent</span>
  110. which is defined in
  111. <code class="filename">namedb.h</code>:
  112. </p>
  113. <pre class="programlisting">
  114. struct hostent {
  115. char *h_name; /* official name of host */
  116. char **h_aliases; /* alias list */
  117. int h_addrtype; /* host address type */
  118. int h_length; /* length of address */
  119. char **h_addr_list; /* list of addresses from name server */
  120. };
  121. #define h_addr h_addr_list[0] /* address, for backward compatibility */
  122. </pre>
  123. <p>
  124. </p>
  125. <p>
  126. The members of this structure are:
  127. </p>
  128. <div class="variablelist"><dl>
  129. <dt><span class="term"><code class="constant">h_name</code></span></dt>
  130. <dd><p>
  131. The official (canonical) name of the host.
  132. </p></dd>
  133. <dt><span class="term"><code class="constant">h_aliases</code></span></dt>
  134. <dd><p>
  135. A NULL-terminated array of alternate names (nicknames) for the
  136. host.
  137. </p></dd>
  138. <dt><span class="term"><code class="constant">h_addrtype</code></span></dt>
  139. <dd><p>
  140. The type of address being returned - usually
  141. <span class="type">PF_INET</span>
  142. or
  143. <span class="type">PF_INET6</span>.
  144. </p></dd>
  145. <dt><span class="term"><code class="constant">h_length</code></span></dt>
  146. <dd><p>
  147. The length of the address in bytes.
  148. </p></dd>
  149. <dt><span class="term"><code class="constant">h_addr_list</code></span></dt>
  150. <dd><p>
  151. A
  152. <span class="type">NULL</span>
  153. terminated array of network addresses for the host.
  154. Host addresses are returned in network byte order.
  155. </p></dd>
  156. </dl></div>
  157. <p>
  158. </p>
  159. <p><code class="function">lwres_getipnodebyname()</code>
  160. looks up addresses of protocol family <em class="parameter"><code>af</code></em>
  161. for the hostname <em class="parameter"><code>name</code></em>. The
  162. <em class="parameter"><code>flags</code></em> parameter contains ORed flag bits
  163. to specify the types of addresses that are searched for, and the
  164. types of addresses that are returned. The flag bits are:
  165. </p>
  166. <div class="variablelist"><dl>
  167. <dt><span class="term"><code class="constant">AI_V4MAPPED</code></span></dt>
  168. <dd><p>
  169. This is used with an
  170. <em class="parameter"><code>af</code></em>
  171. of AF_INET6, and causes IPv4 addresses to be returned as
  172. IPv4-mapped
  173. IPv6 addresses.
  174. </p></dd>
  175. <dt><span class="term"><code class="constant">AI_ALL</code></span></dt>
  176. <dd><p>
  177. This is used with an
  178. <em class="parameter"><code>af</code></em>
  179. of AF_INET6, and causes all known addresses (IPv6 and IPv4) to
  180. be returned.
  181. If AI_V4MAPPED is also set, the IPv4 addresses are return as
  182. mapped
  183. IPv6 addresses.
  184. </p></dd>
  185. <dt><span class="term"><code class="constant">AI_ADDRCONFIG</code></span></dt>
  186. <dd><p>
  187. Only return an IPv6 or IPv4 address if here is an active network
  188. interface of that type. This is not currently implemented
  189. in the BIND 9 lightweight resolver, and the flag is ignored.
  190. </p></dd>
  191. <dt><span class="term"><code class="constant">AI_DEFAULT</code></span></dt>
  192. <dd><p>
  193. This default sets the
  194. <code class="constant">AI_V4MAPPED</code>
  195. and
  196. <code class="constant">AI_ADDRCONFIG</code>
  197. flag bits.
  198. </p></dd>
  199. </dl></div>
  200. <p>
  201. </p>
  202. <p><code class="function">lwres_getipnodebyaddr()</code>
  203. performs a reverse lookup of address <em class="parameter"><code>src</code></em>
  204. which is <em class="parameter"><code>len</code></em> bytes long.
  205. <em class="parameter"><code>af</code></em> denotes the protocol family, typically
  206. <span class="type">PF_INET</span> or <span class="type">PF_INET6</span>.
  207. </p>
  208. <p><code class="function">lwres_freehostent()</code>
  209. releases all the memory associated with the <span class="type">struct
  210. hostent</span> pointer <em class="parameter"><code>he</code></em>. Any memory
  211. allocated for the <code class="constant">h_name</code>,
  212. <code class="constant">h_addr_list</code> and
  213. <code class="constant">h_aliases</code> is freed, as is the memory for
  214. the <span class="type">hostent</span> structure itself.
  215. </p>
  216. </div>
  217. <div class="refsect1" lang="en">
  218. <a name="id2543693"></a><h2>RETURN VALUES</h2>
  219. <p>
  220. If an error occurs,
  221. <code class="function">lwres_getipnodebyname()</code>
  222. and
  223. <code class="function">lwres_getipnodebyaddr()</code>
  224. set
  225. <em class="parameter"><code>*error_num</code></em>
  226. to an appropriate error code and the function returns a
  227. <span class="type">NULL</span>
  228. pointer.
  229. The error codes and their meanings are defined in
  230. <code class="filename">&lt;lwres/netdb.h&gt;</code>:
  231. </p>
  232. <div class="variablelist"><dl>
  233. <dt><span class="term"><code class="constant">HOST_NOT_FOUND</code></span></dt>
  234. <dd><p>
  235. No such host is known.
  236. </p></dd>
  237. <dt><span class="term"><code class="constant">NO_ADDRESS</code></span></dt>
  238. <dd><p>
  239. The server recognised the request and the name but no address is
  240. available. Another type of request to the name server for the
  241. domain might return an answer.
  242. </p></dd>
  243. <dt><span class="term"><code class="constant">TRY_AGAIN</code></span></dt>
  244. <dd><p>
  245. A temporary and possibly transient error occurred, such as a
  246. failure of a server to respond. The request may succeed if
  247. retried.
  248. </p></dd>
  249. <dt><span class="term"><code class="constant">NO_RECOVERY</code></span></dt>
  250. <dd><p>
  251. An unexpected failure occurred, and retrying the request
  252. is pointless.
  253. </p></dd>
  254. </dl></div>
  255. <p>
  256. </p>
  257. <p><span class="citerefentry"><span class="refentrytitle">lwres_hstrerror</span>(3)</span>
  258. translates these error codes to suitable error messages.
  259. </p>
  260. </div>
  261. <div class="refsect1" lang="en">
  262. <a name="id2543790"></a><h2>SEE ALSO</h2>
  263. <p><span class="citerefentry"><span class="refentrytitle">RFC2553</span></span>,
  264. <span class="citerefentry"><span class="refentrytitle">lwres</span>(3)</span>,
  265. <span class="citerefentry"><span class="refentrytitle">lwres_gethostent</span>(3)</span>,
  266. <span class="citerefentry"><span class="refentrytitle">lwres_getaddrinfo</span>(3)</span>,
  267. <span class="citerefentry"><span class="refentrytitle">lwres_getnameinfo</span>(3)</span>,
  268. <span class="citerefentry"><span class="refentrytitle">lwres_hstrerror</span>(3)</span>.
  269. </p>
  270. </div>
  271. </div></body>
  272. </html>