lwres_getipnode.html revision cedb0bd0c1e3c461b7e479a16d3adfd5b150f1f4
6c3e745a94ef6b25a4ef9f018d350a7535aa45afTed Gould<!--
6c3e745a94ef6b25a4ef9f018d350a7535aa45afTed Gould - Copyright (C) 2004, 2005 Internet Systems Consortium, Inc. ("ISC")
70eb1fc448cb08acf3468f80fa2296c03b32afd2cilix - Copyright (C) 2000, 2001, 2003 Internet Software Consortium.
6c3e745a94ef6b25a4ef9f018d350a7535aa45afTed Gould -
6c3e745a94ef6b25a4ef9f018d350a7535aa45afTed Gould - Permission to use, copy, modify, and distribute this software for any
6c3e745a94ef6b25a4ef9f018d350a7535aa45afTed Gould - purpose with or without fee is hereby granted, provided that the above
70eb1fc448cb08acf3468f80fa2296c03b32afd2cilix - copyright notice and this permission notice appear in all copies.
6c3e745a94ef6b25a4ef9f018d350a7535aa45afTed Gould -
70eb1fc448cb08acf3468f80fa2296c03b32afd2cilix - THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
70eb1fc448cb08acf3468f80fa2296c03b32afd2cilix - REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
70eb1fc448cb08acf3468f80fa2296c03b32afd2cilix - AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
70eb1fc448cb08acf3468f80fa2296c03b32afd2cilix - INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
70eb1fc448cb08acf3468f80fa2296c03b32afd2cilix - LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
70eb1fc448cb08acf3468f80fa2296c03b32afd2cilix - OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
70eb1fc448cb08acf3468f80fa2296c03b32afd2cilix - PERFORMANCE OF THIS SOFTWARE.
70eb1fc448cb08acf3468f80fa2296c03b32afd2cilix-->
70eb1fc448cb08acf3468f80fa2296c03b32afd2cilix<!-- $Id: lwres_getipnode.html,v 1.20 2005/10/13 03:14:02 marka Exp $ -->
a98d7da87dea01e6c39b3df95b78fc6a397dd685bgk<html>
b1771b4ea91b15a5da4a96f93e8aa78e700fd51ajohanengelen<head>
70eb1fc448cb08acf3468f80fa2296c03b32afd2cilix<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
70eb1fc448cb08acf3468f80fa2296c03b32afd2cilix<title>lwres_getipnode</title>
70eb1fc448cb08acf3468f80fa2296c03b32afd2cilix<meta name="generator" content="DocBook XSL Stylesheets V1.69.1">
70eb1fc448cb08acf3468f80fa2296c03b32afd2cilix</head>
70eb1fc448cb08acf3468f80fa2296c03b32afd2cilix<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="refentry" lang="en">
70eb1fc448cb08acf3468f80fa2296c03b32afd2cilix<a name="id2463721"></a><div class="titlepage"></div>
70eb1fc448cb08acf3468f80fa2296c03b32afd2cilix<div class="refnamediv">
70eb1fc448cb08acf3468f80fa2296c03b32afd2cilix<h2>Name</h2>
36285e420d3124dfe8cd2c5a8ac5a76bf7cdd4c6cilix<p>lwres_getipnodebyname, lwres_getipnodebyaddr, lwres_freehostent &#8212; lightweight resolver nodename / address translation API</p>
36285e420d3124dfe8cd2c5a8ac5a76bf7cdd4c6cilix</div>
25ad3718fb4b96b39930af8e043c8ee1e624fd10cilix<div class="refsynopsisdiv">
36285e420d3124dfe8cd2c5a8ac5a76bf7cdd4c6cilix<h2>Synopsis</h2>
36285e420d3124dfe8cd2c5a8ac5a76bf7cdd4c6cilix<div class="funcsynopsis">
5b20351508dc029f37f23fb7add6d0b43bf47f20johanengelen<pre class="funcsynopsisinfo">#include &lt;lwres/netdb.h&gt;</pre>
5b20351508dc029f37f23fb7add6d0b43bf47f20johanengelen<table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" style="padding-bottom: 1em">
36285e420d3124dfe8cd2c5a8ac5a76bf7cdd4c6cilix<tr>
36285e420d3124dfe8cd2c5a8ac5a76bf7cdd4c6cilix<td><code class="funcdef">
36285e420d3124dfe8cd2c5a8ac5a76bf7cdd4c6cilixstruct hostent *
36285e420d3124dfe8cd2c5a8ac5a76bf7cdd4c6cilix<b class="fsfunc">lwres_getipnodebyname</b>(</code></td>
70eb1fc448cb08acf3468f80fa2296c03b32afd2cilix<td>const char *�</td>
70eb1fc448cb08acf3468f80fa2296c03b32afd2cilix<td>
70eb1fc448cb08acf3468f80fa2296c03b32afd2cilix<var class="pdparam">name</var>, </td>
70eb1fc448cb08acf3468f80fa2296c03b32afd2cilix</tr>
70eb1fc448cb08acf3468f80fa2296c03b32afd2cilix<tr>
70eb1fc448cb08acf3468f80fa2296c03b32afd2cilix<td>�</td>
70eb1fc448cb08acf3468f80fa2296c03b32afd2cilix<td>int �</td>
70eb1fc448cb08acf3468f80fa2296c03b32afd2cilix<td>
70eb1fc448cb08acf3468f80fa2296c03b32afd2cilix<var class="pdparam">af</var>, </td>
70eb1fc448cb08acf3468f80fa2296c03b32afd2cilix</tr>
70eb1fc448cb08acf3468f80fa2296c03b32afd2cilix<tr>
70eb1fc448cb08acf3468f80fa2296c03b32afd2cilix<td>�</td>
70eb1fc448cb08acf3468f80fa2296c03b32afd2cilix<td>int �</td>
70eb1fc448cb08acf3468f80fa2296c03b32afd2cilix<td>
70eb1fc448cb08acf3468f80fa2296c03b32afd2cilix<var class="pdparam">flags</var>, </td>
70eb1fc448cb08acf3468f80fa2296c03b32afd2cilix</tr>
36285e420d3124dfe8cd2c5a8ac5a76bf7cdd4c6cilix<tr>
36285e420d3124dfe8cd2c5a8ac5a76bf7cdd4c6cilix<td>�</td>
74b408ae13ffc5a6e8cfafda04a3edbc5a32c89ccilix<td>int *�</td>
74b408ae13ffc5a6e8cfafda04a3edbc5a32c89ccilix<td>
70eb1fc448cb08acf3468f80fa2296c03b32afd2cilix<var class="pdparam">error_num</var><code>)</code>;</td>
70eb1fc448cb08acf3468f80fa2296c03b32afd2cilix</tr>
fce046713c4cb905f38bf489cc4a73af425f3037Maximilian Albert</table>
70eb1fc448cb08acf3468f80fa2296c03b32afd2cilix<table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" style="padding-bottom: 1em">
70eb1fc448cb08acf3468f80fa2296c03b32afd2cilix<tr>
70eb1fc448cb08acf3468f80fa2296c03b32afd2cilix<td><code class="funcdef">
70eb1fc448cb08acf3468f80fa2296c03b32afd2cilixstruct hostent *
70eb1fc448cb08acf3468f80fa2296c03b32afd2cilix<b class="fsfunc">lwres_getipnodebyaddr</b>(</code></td>
70eb1fc448cb08acf3468f80fa2296c03b32afd2cilix<td>const void *�</td>
70eb1fc448cb08acf3468f80fa2296c03b32afd2cilix<td>
70eb1fc448cb08acf3468f80fa2296c03b32afd2cilix<var class="pdparam">src</var>, </td>
70eb1fc448cb08acf3468f80fa2296c03b32afd2cilix</tr>
a98d7da87dea01e6c39b3df95b78fc6a397dd685bgk<tr>
a98d7da87dea01e6c39b3df95b78fc6a397dd685bgk<td>�</td>
a98d7da87dea01e6c39b3df95b78fc6a397dd685bgk<td>size_t �</td>
d7e43efbcb4e431ff2fc52941513cc1bd614afa5cilix<td>
a98d7da87dea01e6c39b3df95b78fc6a397dd685bgk<var class="pdparam">len</var>, </td>
a98d7da87dea01e6c39b3df95b78fc6a397dd685bgk</tr>
70eb1fc448cb08acf3468f80fa2296c03b32afd2cilix<tr>
ecda720053ff791e35dae3c5c1177bc225b6cdf1johanengelen<td>�</td>
70eb1fc448cb08acf3468f80fa2296c03b32afd2cilix<td>int �</td>
70eb1fc448cb08acf3468f80fa2296c03b32afd2cilix<td>
70eb1fc448cb08acf3468f80fa2296c03b32afd2cilix<var class="pdparam">af</var>, </td>
70eb1fc448cb08acf3468f80fa2296c03b32afd2cilix</tr>
70eb1fc448cb08acf3468f80fa2296c03b32afd2cilix<tr>
70eb1fc448cb08acf3468f80fa2296c03b32afd2cilix<td>�</td>
70eb1fc448cb08acf3468f80fa2296c03b32afd2cilix<td>int *�</td>
70eb1fc448cb08acf3468f80fa2296c03b32afd2cilix<td>
70eb1fc448cb08acf3468f80fa2296c03b32afd2cilix<var class="pdparam">error_num</var><code>)</code>;</td>
8001ba81cb851b38d86650a2fef5817facffb763johanengelen</tr>
70eb1fc448cb08acf3468f80fa2296c03b32afd2cilix</table>
70eb1fc448cb08acf3468f80fa2296c03b32afd2cilix<table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0"><tr>
70eb1fc448cb08acf3468f80fa2296c03b32afd2cilix<td><code class="funcdef">
70eb1fc448cb08acf3468f80fa2296c03b32afd2cilixvoid
70eb1fc448cb08acf3468f80fa2296c03b32afd2cilix<b class="fsfunc">lwres_freehostent</b>(</code></td>
a98d7da87dea01e6c39b3df95b78fc6a397dd685bgk<td>struct hostent *�</td>
70eb1fc448cb08acf3468f80fa2296c03b32afd2cilix<td>
36285e420d3124dfe8cd2c5a8ac5a76bf7cdd4c6cilix<var class="pdparam">he</var><code>)</code>;</td>
36285e420d3124dfe8cd2c5a8ac5a76bf7cdd4c6cilix</tr></table>
70eb1fc448cb08acf3468f80fa2296c03b32afd2cilix</div>
70eb1fc448cb08acf3468f80fa2296c03b32afd2cilix</div>
70eb1fc448cb08acf3468f80fa2296c03b32afd2cilix<div class="refsect1" lang="en">
70eb1fc448cb08acf3468f80fa2296c03b32afd2cilix<a name="id2525924"></a><h2>DESCRIPTION</h2>
70eb1fc448cb08acf3468f80fa2296c03b32afd2cilix<p>
70eb1fc448cb08acf3468f80fa2296c03b32afd2cilix These functions perform thread safe, protocol independent
70eb1fc448cb08acf3468f80fa2296c03b32afd2cilix nodename-to-address and address-to-nodename
70eb1fc448cb08acf3468f80fa2296c03b32afd2cilix translation as defined in RFC2553.
70eb1fc448cb08acf3468f80fa2296c03b32afd2cilix </p>
70eb1fc448cb08acf3468f80fa2296c03b32afd2cilix<p>
70eb1fc448cb08acf3468f80fa2296c03b32afd2cilix They use a
70eb1fc448cb08acf3468f80fa2296c03b32afd2cilix <span class="type">struct hostent</span>
70eb1fc448cb08acf3468f80fa2296c03b32afd2cilix which is defined in
70eb1fc448cb08acf3468f80fa2296c03b32afd2cilix <code class="filename">namedb.h</code>:
70eb1fc448cb08acf3468f80fa2296c03b32afd2cilix </p>
70eb1fc448cb08acf3468f80fa2296c03b32afd2cilix<pre class="programlisting">
70eb1fc448cb08acf3468f80fa2296c03b32afd2cilixstruct hostent {
70eb1fc448cb08acf3468f80fa2296c03b32afd2cilix char *h_name; /* official name of host */
70eb1fc448cb08acf3468f80fa2296c03b32afd2cilix char **h_aliases; /* alias list */
70eb1fc448cb08acf3468f80fa2296c03b32afd2cilix int h_addrtype; /* host address type */
70eb1fc448cb08acf3468f80fa2296c03b32afd2cilix int h_length; /* length of address */
70eb1fc448cb08acf3468f80fa2296c03b32afd2cilix char **h_addr_list; /* list of addresses from name server */
70eb1fc448cb08acf3468f80fa2296c03b32afd2cilix};
70eb1fc448cb08acf3468f80fa2296c03b32afd2cilix#define h_addr h_addr_list[0] /* address, for backward compatibility */
70eb1fc448cb08acf3468f80fa2296c03b32afd2cilix</pre>
70eb1fc448cb08acf3468f80fa2296c03b32afd2cilix<p>
70eb1fc448cb08acf3468f80fa2296c03b32afd2cilix </p>
70eb1fc448cb08acf3468f80fa2296c03b32afd2cilix<p>
70eb1fc448cb08acf3468f80fa2296c03b32afd2cilix The members of this structure are:
70eb1fc448cb08acf3468f80fa2296c03b32afd2cilix </p>
70eb1fc448cb08acf3468f80fa2296c03b32afd2cilix<div class="variablelist"><dl>
70eb1fc448cb08acf3468f80fa2296c03b32afd2cilix<dt><span class="term"><code class="constant">h_name</code></span></dt>
70eb1fc448cb08acf3468f80fa2296c03b32afd2cilix<dd><p>
70eb1fc448cb08acf3468f80fa2296c03b32afd2cilix The official (canonical) name of the host.
d7e43efbcb4e431ff2fc52941513cc1bd614afa5cilix </p></dd>
70eb1fc448cb08acf3468f80fa2296c03b32afd2cilix<dt><span class="term"><code class="constant">h_aliases</code></span></dt>
70eb1fc448cb08acf3468f80fa2296c03b32afd2cilix<dd><p>
70eb1fc448cb08acf3468f80fa2296c03b32afd2cilix A NULL-terminated array of alternate names (nicknames) for the
70eb1fc448cb08acf3468f80fa2296c03b32afd2cilix host.
70eb1fc448cb08acf3468f80fa2296c03b32afd2cilix </p></dd>
70eb1fc448cb08acf3468f80fa2296c03b32afd2cilix<dt><span class="term"><code class="constant">h_addrtype</code></span></dt>
70eb1fc448cb08acf3468f80fa2296c03b32afd2cilix<dd><p>
36285e420d3124dfe8cd2c5a8ac5a76bf7cdd4c6cilix The type of address being returned - usually
36285e420d3124dfe8cd2c5a8ac5a76bf7cdd4c6cilix <span class="type">PF_INET</span>
36285e420d3124dfe8cd2c5a8ac5a76bf7cdd4c6cilix or
36285e420d3124dfe8cd2c5a8ac5a76bf7cdd4c6cilix <span class="type">PF_INET6</span>.
36285e420d3124dfe8cd2c5a8ac5a76bf7cdd4c6cilix
36285e420d3124dfe8cd2c5a8ac5a76bf7cdd4c6cilix </p></dd>
36285e420d3124dfe8cd2c5a8ac5a76bf7cdd4c6cilix<dt><span class="term"><code class="constant">h_length</code></span></dt>
36285e420d3124dfe8cd2c5a8ac5a76bf7cdd4c6cilix<dd><p>
36285e420d3124dfe8cd2c5a8ac5a76bf7cdd4c6cilix The length of the address in bytes.
36285e420d3124dfe8cd2c5a8ac5a76bf7cdd4c6cilix </p></dd>
36285e420d3124dfe8cd2c5a8ac5a76bf7cdd4c6cilix<dt><span class="term"><code class="constant">h_addr_list</code></span></dt>
36285e420d3124dfe8cd2c5a8ac5a76bf7cdd4c6cilix<dd><p>
36285e420d3124dfe8cd2c5a8ac5a76bf7cdd4c6cilix A
36285e420d3124dfe8cd2c5a8ac5a76bf7cdd4c6cilix <span class="type">NULL</span>
36285e420d3124dfe8cd2c5a8ac5a76bf7cdd4c6cilix terminated array of network addresses for the host.
5b20351508dc029f37f23fb7add6d0b43bf47f20johanengelen Host addresses are returned in network byte order.
36285e420d3124dfe8cd2c5a8ac5a76bf7cdd4c6cilix </p></dd>
36285e420d3124dfe8cd2c5a8ac5a76bf7cdd4c6cilix</dl></div>
36285e420d3124dfe8cd2c5a8ac5a76bf7cdd4c6cilix<p>
36285e420d3124dfe8cd2c5a8ac5a76bf7cdd4c6cilix </p>
36285e420d3124dfe8cd2c5a8ac5a76bf7cdd4c6cilix<p><code class="function">lwres_getipnodebyname()</code>
5b20351508dc029f37f23fb7add6d0b43bf47f20johanengelen looks up addresses of protocol family <em class="parameter"><code>af</code></em>
947fb2f89245c19c5bad9dbefb9fd44c2aaed2eccilix for the hostname <em class="parameter"><code>name</code></em>. The
c3521f69a168bb569f01c674683489ea8e98f7f5johanengelen <em class="parameter"><code>flags</code></em> parameter contains ORed flag bits
c3521f69a168bb569f01c674683489ea8e98f7f5johanengelen to specify the types of addresses that are searched for, and the
36285e420d3124dfe8cd2c5a8ac5a76bf7cdd4c6cilix types of addresses that are returned. The flag bits are:
36285e420d3124dfe8cd2c5a8ac5a76bf7cdd4c6cilix
36285e420d3124dfe8cd2c5a8ac5a76bf7cdd4c6cilix </p>
36285e420d3124dfe8cd2c5a8ac5a76bf7cdd4c6cilix<div class="variablelist"><dl>
36285e420d3124dfe8cd2c5a8ac5a76bf7cdd4c6cilix<dt><span class="term"><code class="constant">AI_V4MAPPED</code></span></dt>
5b20351508dc029f37f23fb7add6d0b43bf47f20johanengelen<dd><p>
36285e420d3124dfe8cd2c5a8ac5a76bf7cdd4c6cilix This is used with an
36285e420d3124dfe8cd2c5a8ac5a76bf7cdd4c6cilix <em class="parameter"><code>af</code></em>
36285e420d3124dfe8cd2c5a8ac5a76bf7cdd4c6cilix of AF_INET6, and causes IPv4 addresses to be returned as
36285e420d3124dfe8cd2c5a8ac5a76bf7cdd4c6cilix IPv4-mapped
36285e420d3124dfe8cd2c5a8ac5a76bf7cdd4c6cilix IPv6 addresses.
36285e420d3124dfe8cd2c5a8ac5a76bf7cdd4c6cilix </p></dd>
36285e420d3124dfe8cd2c5a8ac5a76bf7cdd4c6cilix<dt><span class="term"><code class="constant">AI_ALL</code></span></dt>
70eb1fc448cb08acf3468f80fa2296c03b32afd2cilix<dd><p>
70eb1fc448cb08acf3468f80fa2296c03b32afd2cilix This is used with an
70eb1fc448cb08acf3468f80fa2296c03b32afd2cilix <em class="parameter"><code>af</code></em>
70eb1fc448cb08acf3468f80fa2296c03b32afd2cilix of AF_INET6, and causes all known addresses (IPv6 and IPv4) to
70eb1fc448cb08acf3468f80fa2296c03b32afd2cilix be returned.
70eb1fc448cb08acf3468f80fa2296c03b32afd2cilix If AI_V4MAPPED is also set, the IPv4 addresses are return as
70eb1fc448cb08acf3468f80fa2296c03b32afd2cilix mapped
70eb1fc448cb08acf3468f80fa2296c03b32afd2cilix IPv6 addresses.
70eb1fc448cb08acf3468f80fa2296c03b32afd2cilix </p></dd>
70eb1fc448cb08acf3468f80fa2296c03b32afd2cilix<dt><span class="term"><code class="constant">AI_ADDRCONFIG</code></span></dt>
70eb1fc448cb08acf3468f80fa2296c03b32afd2cilix<dd><p>
70eb1fc448cb08acf3468f80fa2296c03b32afd2cilix Only return an IPv6 or IPv4 address if here is an active network
70eb1fc448cb08acf3468f80fa2296c03b32afd2cilix interface of that type. This is not currently implemented
6c3e745a94ef6b25a4ef9f018d350a7535aa45afTed Gould in the BIND 9 lightweight resolver, and the flag is ignored.
</p></dd>
<dt><span class="term"><code class="constant">AI_DEFAULT</code></span></dt>
<dd><p>
This default sets the
<code class="constant">AI_V4MAPPED</code>
and
<code class="constant">AI_ADDRCONFIG</code>
flag bits.
</p></dd>
</dl></div>
<p>
</p>
<p><code class="function">lwres_getipnodebyaddr()</code>
performs a reverse lookup of address <em class="parameter"><code>src</code></em>
which is <em class="parameter"><code>len</code></em> bytes long.
<em class="parameter"><code>af</code></em> denotes the protocol family, typically
<span class="type">PF_INET</span> or <span class="type">PF_INET6</span>.
</p>
<p><code class="function">lwres_freehostent()</code>
releases all the memory associated with the <span class="type">struct
hostent</span> pointer <em class="parameter"><code>he</code></em>. Any memory
allocated for the <code class="constant">h_name</code>,
<code class="constant">h_addr_list</code> and
<code class="constant">h_aliases</code> is freed, as is the memory for
the <span class="type">hostent</span> structure itself.
</p>
</div>
<div class="refsect1" lang="en">
<a name="id2526250"></a><h2>RETURN VALUES</h2>
<p>
If an error occurs,
<code class="function">lwres_getipnodebyname()</code>
and
<code class="function">lwres_getipnodebyaddr()</code>
set
<em class="parameter"><code>*error_num</code></em>
to an appropriate error code and the function returns a
<span class="type">NULL</span>
pointer.
The error codes and their meanings are defined in
<code class="filename">&lt;lwres/netdb.h&gt;</code>:
</p>
<div class="variablelist"><dl>
<dt><span class="term"><code class="constant">HOST_NOT_FOUND</code></span></dt>
<dd><p>
No such host is known.
</p></dd>
<dt><span class="term"><code class="constant">NO_ADDRESS</code></span></dt>
<dd><p>
The server recognised the request and the name but no address is
available. Another type of request to the name server for the
domain might return an answer.
</p></dd>
<dt><span class="term"><code class="constant">TRY_AGAIN</code></span></dt>
<dd><p>
A temporary and possibly transient error occurred, such as a
failure of a server to respond. The request may succeed if
retried.
</p></dd>
<dt><span class="term"><code class="constant">NO_RECOVERY</code></span></dt>
<dd><p>
An unexpected failure occurred, and retrying the request
is pointless.
</p></dd>
</dl></div>
<p>
</p>
<p><span class="citerefentry"><span class="refentrytitle">lwres_hstrerror</span>(3)</span>
translates these error codes to suitable error messages.
</p>
</div>
<div class="refsect1" lang="en">
<a name="id2526347"></a><h2>SEE ALSO</h2>
<p><span class="citerefentry"><span class="refentrytitle">RFC2553</span></span>,
<span class="citerefentry"><span class="refentrytitle">lwres</span>(3)</span>,
<span class="citerefentry"><span class="refentrytitle">lwres_gethostent</span>(3)</span>,
<span class="citerefentry"><span class="refentrytitle">lwres_getaddrinfo</span>(3)</span>,
<span class="citerefentry"><span class="refentrytitle">lwres_getnameinfo</span>(3)</span>,
<span class="citerefentry"><span class="refentrytitle">lwres_hstrerror</span>(3)</span>.
</p>
</div>
</div></body>
</html>