1N/A<!
DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN" 1N/A [<!ENTITY mdash "—">]>
1N/A - Copyright (C) 2004, 2005 Internet Systems Consortium, Inc. ("ISC") 1N/A - Copyright (C) 2000, 2001, 2003 Internet Software Consortium. 1N/A - Permission to use, copy, modify, and distribute this software for any 1N/A - purpose with or without fee is hereby granted, provided that the above 1N/A - copyright notice and this permission notice appear in all copies. 1N/A - THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH 1N/A - REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 1N/A - AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, 1N/A - INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 1N/A - LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE 1N/A - OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 1N/A - PERFORMANCE OF THIS SOFTWARE. 1N/A <
date>Jun 30, 2000</
date>
1N/A <
refentrytitle>lwres_getipnode</
refentrytitle>
1N/A <
manvolnum>3</
manvolnum>
1N/A <
refmiscinfo>BIND9</
refmiscinfo>
1N/A <
holder>Internet Systems Consortium, Inc. ("ISC")</
holder>
1N/A <
holder>Internet Software Consortium.</
holder>
1N/A <
refname>lwres_getipnodebyname</
refname>
1N/A <
refname>lwres_getipnodebyaddr</
refname>
1N/A <
refname>lwres_freehostent</
refname>
1N/A <
refpurpose>lightweight resolver nodename / address translation API</
refpurpose>
1N/A<
function>lwres_getipnodebyname</
function></
funcdef>
1N/A <
paramdef>const char *<
parameter>name</
parameter></
paramdef>
1N/A <
paramdef>int <
parameter>af</
parameter></
paramdef>
1N/A <
paramdef>int <
parameter>flags</
parameter></
paramdef>
1N/A <
paramdef>int *<
parameter>error_num</
parameter></
paramdef>
1N/A<
function>lwres_getipnodebyaddr</
function></
funcdef>
1N/A <
paramdef>const void *<
parameter>src</
parameter></
paramdef>
1N/A <
paramdef>size_t <
parameter>len</
parameter></
paramdef>
1N/A <
paramdef>int <
parameter>af</
parameter></
paramdef>
1N/A <
paramdef>int *<
parameter>error_num</
parameter></
paramdef>
1N/A<
function>lwres_freehostent</
function></
funcdef>
1N/A <
paramdef>struct hostent *<
parameter>he</
parameter></
paramdef>
1N/A <
title>DESCRIPTION</
title>
1N/A These functions perform thread safe, protocol independent
1N/A nodename-to-address and address-to-nodename
1N/A translation as defined in RFC2553.
1N/A <
type>struct hostent</
type>
1N/A <
para><
programlisting>
1N/A char *h_name; /* official name of host */
1N/A char **h_aliases; /* alias list */
1N/A int h_addrtype; /* host address type */
1N/A int h_length; /* length of address */
1N/A char **h_addr_list; /* list of addresses from name server */
1N/A#define h_addr h_addr_list[0] /* address, for backward compatibility */
1N/A The members of this structure are:
1N/A <
term><
constant>h_name</
constant></
term>
1N/A The official (canonical) name of the host.
1N/A <
term><
constant>h_aliases</
constant></
term>
1N/A A NULL-terminated array of alternate names (nicknames) for the
1N/A <
term><
constant>h_addrtype</
constant></
term>
1N/A The type of address being returned - usually
1N/A <
type>PF_INET</
type>
1N/A <
type>PF_INET6</
type>.
1N/A <
term><
constant>h_length</
constant></
term>
1N/A The length of the address in bytes.
1N/A <
term><
constant>h_addr_list</
constant></
term>
1N/A terminated array of network addresses for the host.
1N/A Host addresses are returned in network byte order.
1N/A <
para><
function>lwres_getipnodebyname()</
function>
1N/A looks up addresses of protocol family <
parameter>af</
parameter>
1N/A for the hostname <
parameter>name</
parameter>. The
1N/A <
parameter>flags</
parameter> parameter contains ORed flag bits
1N/A to specify the types of addresses that are searched for, and the
1N/A types of addresses that are returned. The flag bits are:
1N/A <
term><
constant>AI_V4MAPPED</
constant></
term>
1N/A This is used with an
1N/A <
parameter>af</
parameter>
1N/A of AF_INET6, and causes IPv4 addresses to be returned as
1N/A <
term><
constant>AI_ALL</
constant></
term>
1N/A This is used with an
1N/A <
parameter>af</
parameter>
1N/A of AF_INET6, and causes all known addresses (IPv6 and IPv4) to
1N/A If AI_V4MAPPED is also set, the IPv4 addresses are return as
<
term><
constant>AI_ADDRCONFIG</
constant></
term>
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.
<
term><
constant>AI_DEFAULT</
constant></
term>
<
constant>AI_V4MAPPED</
constant>
<
constant>AI_ADDRCONFIG</
constant>
<
para><
function>lwres_getipnodebyaddr()</
function>
performs a reverse lookup of address <
parameter>src</
parameter>
which is <
parameter>len</
parameter> bytes long.
<
parameter>af</
parameter> denotes the protocol family, typically
<
type>PF_INET</
type> or <
type>PF_INET6</
type>.
<
para><
function>lwres_freehostent()</
function>
releases all the memory associated with the <
type>struct
hostent</
type> pointer <
parameter>he</
parameter>. Any memory
allocated for the <
constant>h_name</
constant>,
<
constant>h_addr_list</
constant> and
<
constant>h_aliases</
constant> is freed, as is the memory for
the <
type>hostent</
type> structure itself.
<
title>RETURN VALUES</
title>
<
function>lwres_getipnodebyname()</
function>
<
function>lwres_getipnodebyaddr()</
function>
<
parameter>*error_num</
parameter>
to an appropriate error code and the function returns a
The error codes and their meanings are defined in
<
term><
constant>HOST_NOT_FOUND</
constant></
term>
<
term><
constant>NO_ADDRESS</
constant></
term>
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.
<
term><
constant>TRY_AGAIN</
constant></
term>
A temporary and possibly transient error occurred, such as a
failure of a server to respond. The request may succeed if
<
term><
constant>NO_RECOVERY</
constant></
term>
An unexpected failure occurred, and retrying the request
<
refentrytitle>lwres_hstrerror</
refentrytitle><
manvolnum>3</
manvolnum>
translates these error codes to suitable error messages.
<
refentrytitle>RFC2553</
refentrytitle>
<
refentrytitle>lwres</
refentrytitle><
manvolnum>3</
manvolnum>
<
refentrytitle>lwres_gethostent</
refentrytitle><
manvolnum>3</
manvolnum>
<
refentrytitle>lwres_getaddrinfo</
refentrytitle><
manvolnum>3</
manvolnum>
<
refentrytitle>lwres_getnameinfo</
refentrytitle><
manvolnum>3</
manvolnum>
<
refentrytitle>lwres_hstrerror</
refentrytitle><
manvolnum>3</
manvolnum>