130N/A<!
DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN" 130N/A [<!ENTITY mdash "—">]>
130N/A - Copyright (C) 2004, 2005, 2007 Internet Systems Consortium, Inc. ("ISC") 130N/A - Copyright (C) 2000, 2001, 2003 Internet Software Consortium. 130N/A - Permission to use, copy, modify, and distribute this software for any 130N/A - purpose with or without fee is hereby granted, provided that the above 130N/A - copyright notice and this permission notice appear in all copies. 130N/A - THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH 130N/A - REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 130N/A - AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, 130N/A - INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 130N/A - LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE 130N/A - OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 130N/A - PERFORMANCE OF THIS SOFTWARE. 130N/A <
date>Jun 30, 2000</
date>
130N/A <
refentrytitle>lwres_getipnode</
refentrytitle>
130N/A <
manvolnum>3</
manvolnum>
130N/A <
refmiscinfo>BIND9</
refmiscinfo>
130N/A <
holder>Internet Systems Consortium, Inc. ("ISC")</
holder>
130N/A <
holder>Internet Software Consortium.</
holder>
130N/A <
refname>lwres_getipnodebyname</
refname>
130N/A <
refname>lwres_getipnodebyaddr</
refname>
130N/A <
refname>lwres_freehostent</
refname>
130N/A <
refpurpose>lightweight resolver nodename / address translation API</
refpurpose>
130N/A<
function>lwres_getipnodebyname</
function></
funcdef>
130N/A <
paramdef>const char *<
parameter>name</
parameter></
paramdef>
130N/A <
paramdef>int <
parameter>af</
parameter></
paramdef>
130N/A <
paramdef>int <
parameter>flags</
parameter></
paramdef>
130N/A <
paramdef>int *<
parameter>error_num</
parameter></
paramdef>
130N/A<
function>lwres_getipnodebyaddr</
function></
funcdef>
130N/A <
paramdef>const void *<
parameter>src</
parameter></
paramdef>
130N/A <
paramdef>size_t <
parameter>len</
parameter></
paramdef>
130N/A <
paramdef>int <
parameter>af</
parameter></
paramdef>
130N/A <
paramdef>int *<
parameter>error_num</
parameter></
paramdef>
130N/A<
function>lwres_freehostent</
function></
funcdef>
130N/A <
paramdef>struct hostent *<
parameter>he</
parameter></
paramdef>
130N/A <
title>DESCRIPTION</
title>
130N/A These functions perform thread safe, protocol independent
nodename-to-address and address-to-nodename
translation as defined in RFC2553.
<
type>struct hostent</
type>
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:
<
term><
constant>h_name</
constant></
term>
The official (canonical) name of the host.
<
term><
constant>h_aliases</
constant></
term>
A NULL-terminated array of alternate names (nicknames) for the
<
term><
constant>h_addrtype</
constant></
term>
The type of address being returned - usually
<
term><
constant>h_length</
constant></
term>
The length of the address in bytes.
<
term><
constant>h_addr_list</
constant></
term>
terminated array of network addresses for the host.
Host addresses are returned in network byte order.
<
para><
function>lwres_getipnodebyname()</
function>
looks up addresses of protocol family <
parameter>af</
parameter>
for the hostname <
parameter>name</
parameter>. The
<
parameter>flags</
parameter> 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:
<
term><
constant>AI_V4MAPPED</
constant></
term>
<
parameter>af</
parameter>
of AF_INET6, and causes IPv4 addresses to be returned as
<
term><
constant>AI_ALL</
constant></
term>
<
parameter>af</
parameter>
of AF_INET6, and causes all known addresses (IPv6 and IPv4) to
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>