2 - Copyright (C) 2004, 2005 Internet Systems Consortium, Inc. ("ISC")
3 - Copyright (C) 2000, 2001, 2003 Internet Software Consortium.
5 - Permission to use, copy, modify, and 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.
17 <!-- $Id: lwres_getipnode.html,v 1.7.2.1.4.11 2006/06/29 13:02:31 marka Exp $ -->
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.70.1">
24 <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="refentry" lang="en">
25 <a name="id2482688"></a><div class="titlepage"></div>
26 <div class="refnamediv">
28 <p>lwres_getipnodebyname, lwres_getipnodebyaddr, lwres_freehostent — lightweight resolver nodename / address translation API</p>
30 <div class="refsynopsisdiv">
32 <div class="funcsynopsis">
33 <pre class="funcsynopsisinfo">#include <lwres/netdb.h></pre>
34 <table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" style="padding-bottom: 1em">
36 <td><code class="funcdef">
38 <b class="fsfunc">lwres_getipnodebyname</b>(</code></td>
64 <table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" style="padding-bottom: 1em">
66 <td><code class="funcdef">
68 <b class="fsfunc">lwres_getipnodebyaddr</b>(</code></td>
94 <table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0">
96 <td><code class="funcdef">
98 <b class="fsfunc">lwres_freehostent</b>(</code></td>
112 <div class="refsect1" lang="en">
113 <a name="id2549461"></a><h2>DESCRIPTION</h2>
115 These functions perform thread safe, protocol independent
116 nodename-to-address and address-to-nodename
117 translation as defined in RFC2553.
121 <span class="type">struct hostent</span>
123 <code class="filename">namedb.h</code>:
125 <pre class="programlisting">
127 char *h_name; /* official name of host */
128 char **h_aliases; /* alias list */
129 int h_addrtype; /* host address type */
130 int h_length; /* length of address */
131 char **h_addr_list; /* list of addresses from name server */
133 #define h_addr h_addr_list[0] /* address, for backward compatibility */
138 The members of this structure are:
140 <div class="variablelist"><dl>
141 <dt><span class="term"><code class="constant">h_name</code></span></dt>
143 The official (canonical) name of the host.
145 <dt><span class="term"><code class="constant">h_aliases</code></span></dt>
147 A NULL-terminated array of alternate names (nicknames) for the host.
149 <dt><span class="term"><code class="constant">h_addrtype</code></span></dt>
151 The type of address being returned - usually
152 <span class="type">PF_INET</span>
154 <span class="type">PF_INET6</span>.
157 <dt><span class="term"><code class="constant">h_length</code></span></dt>
159 The length of the address in bytes.
161 <dt><span class="term"><code class="constant">h_addr_list</code></span></dt>
164 <span class="type">NULL</span>
165 terminated array of network addresses for the host.
166 Host addresses are returned in network byte order.
172 <code class="function">lwres_getipnodebyname()</code>
173 looks up addresses of protocol family
174 <em class="parameter"><code>af</code></em>
177 <em class="parameter"><code>name</code></em>.
180 <em class="parameter"><code>flags</code></em>
181 parameter contains ORed flag bits to
182 specify the types of addresses that are searched
183 for, and the types of addresses that are returned.
186 <div class="variablelist"><dl>
187 <dt><span class="term"><code class="constant">AI_V4MAPPED</code></span></dt>
190 <em class="parameter"><code>af</code></em>
191 of AF_INET6, and causes IPv4 addresses to be returned as IPv4-mapped
194 <dt><span class="term"><code class="constant">AI_ALL</code></span></dt>
197 <em class="parameter"><code>af</code></em>
198 of AF_INET6, and causes all known addresses (IPv6 and IPv4) to be returned.
199 If AI_V4MAPPED is also set, the IPv4 addresses are return as mapped
202 <dt><span class="term"><code class="constant">AI_ADDRCONFIG</code></span></dt>
204 Only return an IPv6 or IPv4 address if here is an active network
205 interface of that type. This is not currently implemented
206 in the BIND 9 lightweight resolver, and the flag is ignored.
208 <dt><span class="term"><code class="constant">AI_DEFAULT</code></span></dt>
210 This default sets the
211 <code class="constant">AI_V4MAPPED</code>
213 <code class="constant">AI_ADDRCONFIG</code>
220 <code class="function">lwres_getipnodebyaddr()</code>
221 performs a reverse lookup
223 <em class="parameter"><code>src</code></em>
225 <em class="parameter"><code>len</code></em>
227 <em class="parameter"><code>af</code></em>
228 denotes the protocol family, typically
229 <span class="type">PF_INET</span>
231 <span class="type">PF_INET6</span>.
235 <code class="function">lwres_freehostent()</code>
236 releases all the memory associated with
238 <span class="type">struct hostent</span>
240 <em class="parameter"><code>he</code></em>.
242 Any memory allocated for the
243 <code class="constant">h_name</code>,
245 <code class="constant">h_addr_list</code>
247 <code class="constant">h_aliases</code>
248 is freed, as is the memory for the
249 <span class="type">hostent</span>
253 <div class="refsect1" lang="en">
254 <a name="id2549832"></a><h2>RETURN VALUES</h2>
257 <code class="function">lwres_getipnodebyname()</code>
259 <code class="function">lwres_getipnodebyaddr()</code>
261 <em class="parameter"><code>*error_num</code></em>
262 to an appropriate error code and the function returns a
263 <span class="type">NULL</span>
265 The error codes and their meanings are defined in
266 <code class="filename"><lwres/netdb.h></code>:
268 <div class="variablelist"><dl>
269 <dt><span class="term"><code class="constant">HOST_NOT_FOUND</code></span></dt>
271 No such host is known.
273 <dt><span class="term"><code class="constant">NO_ADDRESS</code></span></dt>
275 The server recognised the request and the name but no address is
276 available. Another type of request to the name server for the
277 domain might return an answer.
279 <dt><span class="term"><code class="constant">TRY_AGAIN</code></span></dt>
281 A temporary and possibly transient error occurred, such as a
282 failure of a server to respond. The request may succeed if
285 <dt><span class="term"><code class="constant">NO_RECOVERY</code></span></dt>
287 An unexpected failure occurred, and retrying the request
294 <span class="citerefentry"><span class="refentrytitle">lwres_hstrerror</span>(3
296 translates these error codes to suitable error messages.
299 <div class="refsect1" lang="en">
300 <a name="id2549923"></a><h2>SEE ALSO</h2>
302 <span class="citerefentry"><span class="refentrytitle">RFC2553</span></span>,
304 <span class="citerefentry"><span class="refentrytitle">lwres</span>(3)</span>,
306 <span class="citerefentry"><span class="refentrytitle">lwres_gethostent</span>(3)</span>,
308 <span class="citerefentry"><span class="refentrytitle">lwres_getaddrinfo</span>(3)</span>,
310 <span class="citerefentry"><span class="refentrytitle">lwres_getnameinfo</span>(3)</span>,
312 <span class="citerefentry"><span class="refentrytitle">lwres_hstrerror</span>(3)</span>.