1 <!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
2 "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd"
3 [<!ENTITY mdash "—">]>
5 - Copyright (C) 2004, 2005, 2007, 2012 Internet Systems Consortium, Inc. ("ISC")
6 - Copyright (C) 2000, 2001, 2003 Internet Software Consortium.
8 - Permission to use, copy, modify, and/or distribute this software for any
9 - purpose with or without fee is hereby granted, provided that the above
10 - copyright notice and this permission notice appear in all copies.
12 - THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
13 - REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
14 - AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
15 - INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
16 - LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
17 - OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
18 - PERFORMANCE OF THIS SOFTWARE.
25 <date>Jun 30, 2000</date>
29 <refentrytitle>lwres_getipnode</refentrytitle>
30 <manvolnum>3</manvolnum>
31 <refmiscinfo>BIND9</refmiscinfo>
40 <holder>Internet Systems Consortium, Inc. ("ISC")</holder>
46 <holder>Internet Software Consortium.</holder>
51 <refname>lwres_getipnodebyname</refname>
52 <refname>lwres_getipnodebyaddr</refname>
53 <refname>lwres_freehostent</refname>
54 <refpurpose>lightweight resolver nodename / address translation API</refpurpose>
58 <funcsynopsisinfo>#include <lwres/netdb.h></funcsynopsisinfo>
62 <function>lwres_getipnodebyname</function></funcdef>
63 <paramdef>const char *<parameter>name</parameter></paramdef>
64 <paramdef>int <parameter>af</parameter></paramdef>
65 <paramdef>int <parameter>flags</parameter></paramdef>
66 <paramdef>int *<parameter>error_num</parameter></paramdef>
71 <function>lwres_getipnodebyaddr</function></funcdef>
72 <paramdef>const void *<parameter>src</parameter></paramdef>
73 <paramdef>size_t <parameter>len</parameter></paramdef>
74 <paramdef>int <parameter>af</parameter></paramdef>
75 <paramdef>int *<parameter>error_num</parameter></paramdef>
80 <function>lwres_freehostent</function></funcdef>
81 <paramdef>struct hostent *<parameter>he</parameter></paramdef>
87 <title>DESCRIPTION</title>
90 These functions perform thread safe, protocol independent
91 nodename-to-address and address-to-nodename
92 translation as defined in RFC2553.
97 <type>struct hostent</type>
99 <filename>namedb.h</filename>:
101 <para><programlisting>
103 char *h_name; /* official name of host */
104 char **h_aliases; /* alias list */
105 int h_addrtype; /* host address type */
106 int h_length; /* length of address */
107 char **h_addr_list; /* list of addresses from name server */
109 #define h_addr h_addr_list[0] /* address, for backward compatibility */
114 The members of this structure are:
117 <term><constant>h_name</constant></term>
120 The official (canonical) name of the host.
125 <term><constant>h_aliases</constant></term>
128 A NULL-terminated array of alternate names (nicknames) for the
134 <term><constant>h_addrtype</constant></term>
137 The type of address being returned - usually
140 <type>PF_INET6</type>.
146 <term><constant>h_length</constant></term>
149 The length of the address in bytes.
154 <term><constant>h_addr_list</constant></term>
159 terminated array of network addresses for the host.
160 Host addresses are returned in network byte order.
167 <para><function>lwres_getipnodebyname()</function>
168 looks up addresses of protocol family <parameter>af</parameter>
169 for the hostname <parameter>name</parameter>. The
170 <parameter>flags</parameter> parameter contains ORed flag bits
171 to specify the types of addresses that are searched for, and the
172 types of addresses that are returned. The flag bits are:
176 <term><constant>AI_V4MAPPED</constant></term>
180 <parameter>af</parameter>
181 of AF_INET6, and causes IPv4 addresses to be returned as
188 <term><constant>AI_ALL</constant></term>
192 <parameter>af</parameter>
193 of AF_INET6, and causes all known addresses (IPv6 and IPv4) to
195 If AI_V4MAPPED is also set, the IPv4 addresses are return as
202 <term><constant>AI_ADDRCONFIG</constant></term>
205 Only return an IPv6 or IPv4 address if here is an active network
206 interface of that type. This is not currently implemented
207 in the BIND 9 lightweight resolver, and the flag is ignored.
212 <term><constant>AI_DEFAULT</constant></term>
215 This default sets the
216 <constant>AI_V4MAPPED</constant>
218 <constant>AI_ADDRCONFIG</constant>
226 <para><function>lwres_getipnodebyaddr()</function>
227 performs a reverse lookup of address <parameter>src</parameter>
228 which is <parameter>len</parameter> bytes long.
229 <parameter>af</parameter> denotes the protocol family, typically
230 <type>PF_INET</type> or <type>PF_INET6</type>.
232 <para><function>lwres_freehostent()</function>
233 releases all the memory associated with the <type>struct
234 hostent</type> pointer <parameter>he</parameter>. Any memory
235 allocated for the <constant>h_name</constant>,
236 <constant>h_addr_list</constant> and
237 <constant>h_aliases</constant> is freed, as is the memory for
238 the <type>hostent</type> structure itself.
242 <title>RETURN VALUES</title>
245 <function>lwres_getipnodebyname()</function>
247 <function>lwres_getipnodebyaddr()</function>
249 <parameter>*error_num</parameter>
250 to an appropriate error code and the function returns a
253 The error codes and their meanings are defined in
254 <filename><lwres/netdb.h></filename>:
257 <term><constant>HOST_NOT_FOUND</constant></term>
260 No such host is known.
265 <term><constant>NO_ADDRESS</constant></term>
268 The server recognised the request and the name but no address is
269 available. Another type of request to the name server for the
270 domain might return an answer.
275 <term><constant>TRY_AGAIN</constant></term>
278 A temporary and possibly transient error occurred, such as a
279 failure of a server to respond. The request may succeed if
285 <term><constant>NO_RECOVERY</constant></term>
288 An unexpected failure occurred, and retrying the request
296 <refentrytitle>lwres_hstrerror</refentrytitle><manvolnum>3</manvolnum>
298 translates these error codes to suitable error messages.
302 <title>SEE ALSO</title>
304 <refentrytitle>RFC2553</refentrytitle>
308 <refentrytitle>lwres</refentrytitle><manvolnum>3</manvolnum>
312 <refentrytitle>lwres_gethostent</refentrytitle><manvolnum>3</manvolnum>
316 <refentrytitle>lwres_getaddrinfo</refentrytitle><manvolnum>3</manvolnum>
320 <refentrytitle>lwres_getnameinfo</refentrytitle><manvolnum>3</manvolnum>
324 <refentrytitle>lwres_hstrerror</refentrytitle><manvolnum>3</manvolnum>