2 - Copyright (C) 2004, 2005, 2007, 2014, 2015 Internet Systems Consortium, Inc. ("ISC")
3 - Copyright (C) 2000, 2001, 2003 Internet Software Consortium.
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.
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.
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">
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">
27 <p>lwres_getipnodebyname, lwres_getipnodebyaddr, lwres_freehostent — lightweight resolver nodename / address translation API</p>
29 <div class="refsynopsisdiv">
31 <div class="funcsynopsis">
32 <pre class="funcsynopsisinfo">#include <lwres/netdb.h></pre>
33 <table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;">
35 <td><code class="funcdef">
37 <b class="fsfunc">lwres_getipnodebyname</b>(</code></td>
38 <td>const char *<var class="pdparam">name</var>, </td>
42 <td>int <var class="pdparam">af</var>, </td>
46 <td>int <var class="pdparam">flags</var>, </td>
50 <td>int *<var class="pdparam">error_num</var><code>)</code>;</td>
53 <div class="funcprototype-spacer"> </div>
54 <table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;">
56 <td><code class="funcdef">
58 <b class="fsfunc">lwres_getipnodebyaddr</b>(</code></td>
59 <td>const void *<var class="pdparam">src</var>, </td>
63 <td>size_t <var class="pdparam">len</var>, </td>
67 <td>int <var class="pdparam">af</var>, </td>
71 <td>int *<var class="pdparam">error_num</var><code>)</code>;</td>
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">
78 <b class="fsfunc">lwres_freehostent</b>(</code></td>
79 <td>struct hostent *<var class="pdparam">he</var><code>)</code>;</td>
81 <div class="funcprototype-spacer"> </div>
84 <div class="refsection">
85 <a name="id-1.7"></a><h2>DESCRIPTION</h2>
87 These functions perform thread safe, protocol independent
88 nodename-to-address and address-to-nodename
89 translation as defined in RFC2553.
93 <span class="type">struct hostent</span>
95 <code class="filename">namedb.h</code>:
97 <pre class="programlisting">
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 */
105 #define h_addr h_addr_list[0] /* address, for backward compatibility */
110 The members of this structure are:
112 <div class="variablelist"><dl class="variablelist">
113 <dt><span class="term"><code class="constant">h_name</code></span></dt>
115 The official (canonical) name of the host.
117 <dt><span class="term"><code class="constant">h_aliases</code></span></dt>
119 A NULL-terminated array of alternate names (nicknames) for the
122 <dt><span class="term"><code class="constant">h_addrtype</code></span></dt>
124 The type of address being returned - usually
125 <span class="type">PF_INET</span>
127 <span class="type">PF_INET6</span>.
130 <dt><span class="term"><code class="constant">h_length</code></span></dt>
132 The length of the address in bytes.
134 <dt><span class="term"><code class="constant">h_addr_list</code></span></dt>
137 <span class="type">NULL</span>
138 terminated array of network addresses for the host.
139 Host addresses are returned in network byte order.
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:
152 <div class="variablelist"><dl class="variablelist">
153 <dt><span class="term"><code class="constant">AI_V4MAPPED</code></span></dt>
156 <em class="parameter"><code>af</code></em>
157 of AF_INET6, and causes IPv4 addresses to be returned as
161 <dt><span class="term"><code class="constant">AI_ALL</code></span></dt>
164 <em class="parameter"><code>af</code></em>
165 of AF_INET6, and causes all known addresses (IPv6 and IPv4) to
167 If AI_V4MAPPED is also set, the IPv4 addresses are return as
171 <dt><span class="term"><code class="constant">AI_ADDRCONFIG</code></span></dt>
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.
177 <dt><span class="term"><code class="constant">AI_DEFAULT</code></span></dt>
179 This default sets the
180 <code class="constant">AI_V4MAPPED</code>
182 <code class="constant">AI_ADDRCONFIG</code>
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>.
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.
203 <div class="refsection">
204 <a name="id-1.8"></a><h2>RETURN VALUES</h2>
207 <code class="function">lwres_getipnodebyname()</code>
209 <code class="function">lwres_getipnodebyaddr()</code>
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>
215 The error codes and their meanings are defined in
216 <code class="filename"><lwres/netdb.h></code>:
218 <div class="variablelist"><dl class="variablelist">
219 <dt><span class="term"><code class="constant">HOST_NOT_FOUND</code></span></dt>
221 No such host is known.
223 <dt><span class="term"><code class="constant">NO_ADDRESS</code></span></dt>
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.
229 <dt><span class="term"><code class="constant">TRY_AGAIN</code></span></dt>
231 A temporary and possibly transient error occurred, such as a
232 failure of a server to respond. The request may succeed if
235 <dt><span class="term"><code class="constant">NO_RECOVERY</code></span></dt>
237 An unexpected failure occurred, and retrying the request
243 <p><span class="citerefentry"><span class="refentrytitle">lwres_hstrerror</span>(3)</span>
244 translates these error codes to suitable error messages.
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>,
251 <span class="citerefentry"><span class="refentrytitle">lwres</span>(3)</span>,
253 <span class="citerefentry"><span class="refentrytitle">lwres_gethostent</span>(3)</span>,
255 <span class="citerefentry"><span class="refentrytitle">lwres_getaddrinfo</span>(3)</span>,
257 <span class="citerefentry"><span class="refentrytitle">lwres_getnameinfo</span>(3)</span>,
259 <span class="citerefentry"><span class="refentrytitle">lwres_hstrerror</span>(3)</span>.