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, 2014 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.
24 <date>June 18, 2007</date>
28 <refentrytitle>lwres_getipnode</refentrytitle>
29 <manvolnum>3</manvolnum>
30 <refmiscinfo>BIND9</refmiscinfo>
39 <holder>Internet Systems Consortium, Inc. ("ISC")</holder>
45 <holder>Internet Software Consortium.</holder>
50 <refname>lwres_getipnodebyname</refname>
51 <refname>lwres_getipnodebyaddr</refname>
52 <refname>lwres_freehostent</refname>
53 <refpurpose>lightweight resolver nodename / address translation API</refpurpose>
57 <funcsynopsisinfo>#include <lwres/netdb.h></funcsynopsisinfo>
61 <function>lwres_getipnodebyname</function></funcdef>
62 <paramdef>const char *<parameter>name</parameter></paramdef>
63 <paramdef>int <parameter>af</parameter></paramdef>
64 <paramdef>int <parameter>flags</parameter></paramdef>
65 <paramdef>int *<parameter>error_num</parameter></paramdef>
70 <function>lwres_getipnodebyaddr</function></funcdef>
71 <paramdef>const void *<parameter>src</parameter></paramdef>
72 <paramdef>size_t <parameter>len</parameter></paramdef>
73 <paramdef>int <parameter>af</parameter></paramdef>
74 <paramdef>int *<parameter>error_num</parameter></paramdef>
79 <function>lwres_freehostent</function></funcdef>
80 <paramdef>struct hostent *<parameter>he</parameter></paramdef>
86 <title>DESCRIPTION</title>
89 These functions perform thread safe, protocol independent
90 nodename-to-address and address-to-nodename
91 translation as defined in RFC2553.
96 <type>struct hostent</type>
98 <filename>namedb.h</filename>:
100 <para><programlisting>
102 char *h_name; /* official name of host */
103 char **h_aliases; /* alias list */
104 int h_addrtype; /* host address type */
105 int h_length; /* length of address */
106 char **h_addr_list; /* list of addresses from name server */
108 #define h_addr h_addr_list[0] /* address, for backward compatibility */
113 The members of this structure are:
116 <term><constant>h_name</constant></term>
119 The official (canonical) name of the host.
124 <term><constant>h_aliases</constant></term>
127 A NULL-terminated array of alternate names (nicknames) for the
133 <term><constant>h_addrtype</constant></term>
136 The type of address being returned - usually
139 <type>PF_INET6</type>.
145 <term><constant>h_length</constant></term>
148 The length of the address in bytes.
153 <term><constant>h_addr_list</constant></term>
158 terminated array of network addresses for the host.
159 Host addresses are returned in network byte order.
166 <para><function>lwres_getipnodebyname()</function>
167 looks up addresses of protocol family <parameter>af</parameter>
168 for the hostname <parameter>name</parameter>. The
169 <parameter>flags</parameter> parameter contains ORed flag bits
170 to specify the types of addresses that are searched for, and the
171 types of addresses that are returned. The flag bits are:
175 <term><constant>AI_V4MAPPED</constant></term>
179 <parameter>af</parameter>
180 of AF_INET6, and causes IPv4 addresses to be returned as
187 <term><constant>AI_ALL</constant></term>
191 <parameter>af</parameter>
192 of AF_INET6, and causes all known addresses (IPv6 and IPv4) to
194 If AI_V4MAPPED is also set, the IPv4 addresses are return as
201 <term><constant>AI_ADDRCONFIG</constant></term>
204 Only return an IPv6 or IPv4 address if here is an active network
205 interface of that type. This is not currently implemented
206 in the BIND 9 lightweight resolver, and the flag is ignored.
211 <term><constant>AI_DEFAULT</constant></term>
214 This default sets the
215 <constant>AI_V4MAPPED</constant>
217 <constant>AI_ADDRCONFIG</constant>
225 <para><function>lwres_getipnodebyaddr()</function>
226 performs a reverse lookup of address <parameter>src</parameter>
227 which is <parameter>len</parameter> bytes long.
228 <parameter>af</parameter> denotes the protocol family, typically
229 <type>PF_INET</type> or <type>PF_INET6</type>.
231 <para><function>lwres_freehostent()</function>
232 releases all the memory associated with the <type>struct
233 hostent</type> pointer <parameter>he</parameter>. Any memory
234 allocated for the <constant>h_name</constant>,
235 <constant>h_addr_list</constant> and
236 <constant>h_aliases</constant> is freed, as is the memory for
237 the <type>hostent</type> structure itself.
241 <title>RETURN VALUES</title>
244 <function>lwres_getipnodebyname()</function>
246 <function>lwres_getipnodebyaddr()</function>
248 <parameter>*error_num</parameter>
249 to an appropriate error code and the function returns a
252 The error codes and their meanings are defined in
253 <filename><lwres/netdb.h></filename>:
256 <term><constant>HOST_NOT_FOUND</constant></term>
259 No such host is known.
264 <term><constant>NO_ADDRESS</constant></term>
267 The server recognised the request and the name but no address is
268 available. Another type of request to the name server for the
269 domain might return an answer.
274 <term><constant>TRY_AGAIN</constant></term>
277 A temporary and possibly transient error occurred, such as a
278 failure of a server to respond. The request may succeed if
284 <term><constant>NO_RECOVERY</constant></term>
287 An unexpected failure occurred, and retrying the request
295 <refentrytitle>lwres_hstrerror</refentrytitle><manvolnum>3</manvolnum>
297 translates these error codes to suitable error messages.
301 <title>SEE ALSO</title>
303 <refentrytitle>RFC2553</refentrytitle>
307 <refentrytitle>lwres</refentrytitle><manvolnum>3</manvolnum>
311 <refentrytitle>lwres_gethostent</refentrytitle><manvolnum>3</manvolnum>
315 <refentrytitle>lwres_getaddrinfo</refentrytitle><manvolnum>3</manvolnum>
319 <refentrytitle>lwres_getnameinfo</refentrytitle><manvolnum>3</manvolnum>
323 <refentrytitle>lwres_hstrerror</refentrytitle><manvolnum>3</manvolnum>