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