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.9 2005/10/13 02:33:56 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.69.1">
24 <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="refentry" lang="en">
25 <a name="id2463721"></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>
59 <table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" style="padding-bottom: 1em">
61 <td><code class="funcdef">
63 <b class="fsfunc">lwres_getipnodebyaddr</b>(</code></td>
84 <table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0"><tr>
85 <td><code class="funcdef">
87 <b class="fsfunc">lwres_freehostent</b>(</code></td>
94 <div class="refsect1" lang="en">
95 <a name="id2525896"></a><h2>DESCRIPTION</h2>
97 These functions perform thread safe, protocol independent
98 nodename-to-address and address-to-nodename
99 translation as defined in RFC2553.
103 <span class="type">struct hostent</span>
105 <code class="filename">namedb.h</code>:
107 <pre class="programlisting">
109 char *h_name; /* official name of host */
110 char **h_aliases; /* alias list */
111 int h_addrtype; /* host address type */
112 int h_length; /* length of address */
113 char **h_addr_list; /* list of addresses from name server */
115 #define h_addr h_addr_list[0] /* address, for backward compatibility */
120 The members of this structure are:
122 <div class="variablelist"><dl>
123 <dt><span class="term"><code class="constant">h_name</code></span></dt>
125 The official (canonical) name of the host.
127 <dt><span class="term"><code class="constant">h_aliases</code></span></dt>
129 A NULL-terminated array of alternate names (nicknames) for the host.
131 <dt><span class="term"><code class="constant">h_addrtype</code></span></dt>
133 The type of address being returned - usually
134 <span class="type">PF_INET</span>
136 <span class="type">PF_INET6</span>.
139 <dt><span class="term"><code class="constant">h_length</code></span></dt>
141 The length of the address in bytes.
143 <dt><span class="term"><code class="constant">h_addr_list</code></span></dt>
146 <span class="type">NULL</span>
147 terminated array of network addresses for the host.
148 Host addresses are returned in network byte order.
154 <code class="function">lwres_getipnodebyname()</code>
155 looks up addresses of protocol family
156 <em class="parameter"><code>af</code></em>
159 <em class="parameter"><code>name</code></em>.
162 <em class="parameter"><code>flags</code></em>
163 parameter contains ORed flag bits to
164 specify the types of addresses that are searched
165 for, and the types of addresses that are returned.
168 <div class="variablelist"><dl>
169 <dt><span class="term"><code class="constant">AI_V4MAPPED</code></span></dt>
172 <em class="parameter"><code>af</code></em>
173 of AF_INET6, and causes IPv4 addresses to be returned as IPv4-mapped
176 <dt><span class="term"><code class="constant">AI_ALL</code></span></dt>
179 <em class="parameter"><code>af</code></em>
180 of AF_INET6, and causes all known addresses (IPv6 and IPv4) to be returned.
181 If AI_V4MAPPED is also set, the IPv4 addresses are return as mapped
184 <dt><span class="term"><code class="constant">AI_ADDRCONFIG</code></span></dt>
186 Only return an IPv6 or IPv4 address if here is an active network
187 interface of that type. This is not currently implemented
188 in the BIND 9 lightweight resolver, and the flag is ignored.
190 <dt><span class="term"><code class="constant">AI_DEFAULT</code></span></dt>
192 This default sets the
193 <code class="constant">AI_V4MAPPED</code>
195 <code class="constant">AI_ADDRCONFIG</code>
202 <code class="function">lwres_getipnodebyaddr()</code>
203 performs a reverse lookup
205 <em class="parameter"><code>src</code></em>
207 <em class="parameter"><code>len</code></em>
209 <em class="parameter"><code>af</code></em>
210 denotes the protocol family, typically
211 <span class="type">PF_INET</span>
213 <span class="type">PF_INET6</span>.
217 <code class="function">lwres_freehostent()</code>
218 releases all the memory associated with
220 <span class="type">struct hostent</span>
222 <em class="parameter"><code>he</code></em>.
224 Any memory allocated for the
225 <code class="constant">h_name</code>,
227 <code class="constant">h_addr_list</code>
229 <code class="constant">h_aliases</code>
230 is freed, as is the memory for the
231 <span class="type">hostent</span>
235 <div class="refsect1" lang="en">
236 <a name="id2526131"></a><h2>RETURN VALUES</h2>
239 <code class="function">lwres_getipnodebyname()</code>
241 <code class="function">lwres_getipnodebyaddr()</code>
243 <em class="parameter"><code>*error_num</code></em>
244 to an appropriate error code and the function returns a
245 <span class="type">NULL</span>
247 The error codes and their meanings are defined in
248 <code class="filename"><lwres/netdb.h></code>:
250 <div class="variablelist"><dl>
251 <dt><span class="term"><code class="constant">HOST_NOT_FOUND</code></span></dt>
253 No such host is known.
255 <dt><span class="term"><code class="constant">NO_ADDRESS</code></span></dt>
257 The server recognised the request and the name but no address is
258 available. Another type of request to the name server for the
259 domain might return an answer.
261 <dt><span class="term"><code class="constant">TRY_AGAIN</code></span></dt>
263 A temporary and possibly transient error occurred, such as a
264 failure of a server to respond. The request may succeed if
267 <dt><span class="term"><code class="constant">NO_RECOVERY</code></span></dt>
269 An unexpected failure occurred, and retrying the request
276 <span class="citerefentry"><span class="refentrytitle">lwres_hstrerror</span>(3
278 translates these error codes to suitable error messages.
281 <div class="refsect1" lang="en">
282 <a name="id2526290"></a><h2>SEE ALSO</h2>
284 <span class="citerefentry"><span class="refentrytitle">RFC2553</span></span>,
286 <span class="citerefentry"><span class="refentrytitle">lwres</span>(3)</span>,
288 <span class="citerefentry"><span class="refentrytitle">lwres_gethostent</span>(3)</span>,
290 <span class="citerefentry"><span class="refentrytitle">lwres_getaddrinfo</span>(3)</span>,
292 <span class="citerefentry"><span class="refentrytitle">lwres_getnameinfo</span>(3)</span>,
294 <span class="citerefentry"><span class="refentrytitle">lwres_hstrerror</span>(3)</span>.