183N/A - Copyright (C) 2004, 2005, 2007 Internet Systems Consortium, Inc. ("ISC") 183N/A - Copyright (C) 2000, 2001, 2003 Internet Software Consortium. 183N/A - Permission to use, copy, modify, and/or distribute this software for any 183N/A - purpose with or without fee is hereby granted, provided that the above 183N/A - copyright notice and this permission notice appear in all copies. 183N/A - THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH 183N/A - REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 183N/A - AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, 183N/A - INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 183N/A - LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE 183N/A - OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 183N/A - PERFORMANCE OF THIS SOFTWARE. 183N/A<
meta http-
equiv="Content-Type" content="text/html; charset=ISO-8859-1">
183N/A<
title>lwres_getipnode</
title>
183N/A<
meta name="generator" content="DocBook XSL Stylesheets V1.71.1">
183N/A<
body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><
div class="refentry" lang="en">
183N/A<
a name="id2476275"></
a><
div class="titlepage"></
div>
183N/A<
div class="refnamediv">
<
p>lwres_getipnodebyname, lwres_getipnodebyaddr, lwres_freehostent — lightweight resolver nodename / address translation API</
p>
<
div class="refsynopsisdiv">
<
div class="funcsynopsis">
<
pre class="funcsynopsisinfo">#include <
lwres/
netdb.h></
pre>
<
table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" style="padding-bottom: 1em">
<
td><
code class="funcdef">
<
b class="fsfunc">lwres_getipnodebyname</
b>(</
code></
td>
<
var class="pdparam">name</
var>, </
td>
<
var class="pdparam">af</
var>, </
td>
<
var class="pdparam">flags</
var>, </
td>
<
var class="pdparam">error_num</
var><
code>)</
code>;</
td>
<
table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" style="padding-bottom: 1em">
<
td><
code class="funcdef">
<
b class="fsfunc">lwres_getipnodebyaddr</
b>(</
code></
td>
<
var class="pdparam">src</
var>, </
td>
<
var class="pdparam">len</
var>, </
td>
<
var class="pdparam">af</
var>, </
td>
<
var class="pdparam">error_num</
var><
code>)</
code>;</
td>
<
table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0"><
tr>
<
td><
code class="funcdef">
<
b class="fsfunc">lwres_freehostent</
b>(</
code></
td>
<
td>struct hostent *�</
td>
<
var class="pdparam">he</
var><
code>)</
code>;</
td>
<
div class="refsect1" lang="en">
<
a name="id2543431"></
a><
h2>DESCRIPTION</
h2>
These functions perform thread safe, protocol independent
nodename-to-address and address-to-nodename
translation as defined in RFC2553.
<
span class="type">struct hostent</
span>
<
pre class="programlisting">
char *h_name; /* official name of host */
char **h_aliases; /* alias list */
int h_addrtype; /* host address type */
int h_length; /* length of address */
char **h_addr_list; /* list of addresses from name server */
#define h_addr h_addr_list[0] /* address, for backward compatibility */
The members of this structure are:
<
div class="variablelist"><
dl>
<
dt><
span class="term"><
code class="constant">h_name</
code></
span></
dt>
The official (canonical) name of the host.
<
dt><
span class="term"><
code class="constant">h_aliases</
code></
span></
dt>
A NULL-terminated array of alternate names (nicknames) for the
<
dt><
span class="term"><
code class="constant">h_addrtype</
code></
span></
dt>
The type of address being returned - usually
<
span class="type">PF_INET</
span>
<
span class="type">PF_INET6</
span>.
<
dt><
span class="term"><
code class="constant">h_length</
code></
span></
dt>
The length of the address in bytes.
<
dt><
span class="term"><
code class="constant">h_addr_list</
code></
span></
dt>
<
span class="type">NULL</
span>
terminated array of network addresses for the host.
Host addresses are returned in network byte order.
<
p><
code class="function">lwres_getipnodebyname()</
code>
looks up addresses of protocol family <
em class="parameter"><
code>af</
code></
em>
for the hostname <
em class="parameter"><
code>name</
code></
em>. The
<
em class="parameter"><
code>flags</
code></
em> parameter contains ORed flag bits
to specify the types of addresses that are searched for, and the
types of addresses that are returned. The flag bits are:
<
div class="variablelist"><
dl>
<
dt><
span class="term"><
code class="constant">AI_V4MAPPED</
code></
span></
dt>
<
em class="parameter"><
code>af</
code></
em>
of AF_INET6, and causes IPv4 addresses to be returned as
<
dt><
span class="term"><
code class="constant">AI_ALL</
code></
span></
dt>
<
em class="parameter"><
code>af</
code></
em>
of AF_INET6, and causes all known addresses (IPv6 and IPv4) to
If AI_V4MAPPED is also set, the IPv4 addresses are return as
<
dt><
span class="term"><
code class="constant">AI_ADDRCONFIG</
code></
span></
dt>
Only return an IPv6 or IPv4 address if here is an active network
interface of that type. This is not currently implemented
in the BIND 9 lightweight resolver, and the flag is ignored.
<
dt><
span class="term"><
code class="constant">AI_DEFAULT</
code></
span></
dt>
<
code class="constant">AI_V4MAPPED</
code>
<
code class="constant">AI_ADDRCONFIG</
code>
<
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><
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.
<
div class="refsect1" lang="en">
<
a name="id2543689"></
a><
h2>RETURN VALUES</
h2>
<
code class="function">lwres_getipnodebyname()</
code>
<
code class="function">lwres_getipnodebyaddr()</
code>
<
em class="parameter"><
code>*error_num</
code></
em>
to an appropriate error code and the function returns a
<
span class="type">NULL</
span>
The error codes and their meanings are defined in
<
div class="variablelist"><
dl>
<
dt><
span class="term"><
code class="constant">HOST_NOT_FOUND</
code></
span></
dt>
<
dt><
span class="term"><
code class="constant">NO_ADDRESS</
code></
span></
dt>
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.
<
dt><
span class="term"><
code class="constant">TRY_AGAIN</
code></
span></
dt>
A temporary and possibly transient error occurred, such as a
failure of a server to respond. The request may succeed if
<
dt><
span class="term"><
code class="constant">NO_RECOVERY</
code></
span></
dt>
An unexpected failure occurred, and retrying the request
<
p><
span class="citerefentry"><
span class="refentrytitle">lwres_hstrerror</
span>(3)</
span>
translates these error codes to suitable error messages.
<
div class="refsect1" lang="en">
<
a name="id2543786"></
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>.