1 <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook V4.1//EN">
3 - Copyright (C) 2001 Internet Software Consortium.
5 - Permission to use, copy, modify, and distribute this software for any
6 - purpose with or without fee is hereby granted, provided that the above
7 - copyright notice and this permission notice appear in all copies.
9 - THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM
10 - DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
11 - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
12 - INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
13 - INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
14 - FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
15 - NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
16 - WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19 <!-- $Id: lwres_getipnode.docbook,v 1.1 2004/03/15 20:35:25 as Exp $ -->
24 <date>Jun 30, 2000</date>
28 <refentrytitle>lwres_getipnode</refentrytitle>
29 <manvolnum>3</manvolnum>
30 <refmiscinfo>BIND9</refmiscinfo>
34 <refname>lwres_getipnodebyname</refname>
35 <refname>lwres_getipnodebyaddr</refname>
36 <refname>lwres_freehostent</refname>
37 <refpurpose>lightweight resolver nodename / address translation API</refpurpose>
41 <funcsynopsisinfo>#include <lwres/netdb.h></funcsynopsisinfo>
45 <function>lwres_getipnodebyname</function></funcdef>
46 <paramdef>const char *name</paramdef>
47 <paramdef>int af</paramdef>
48 <paramdef>int flags</paramdef>
49 <paramdef>int *error_num</paramdef>
54 <function>lwres_getipnodebyaddr</function></funcdef>
55 <paramdef>const void *src</paramdef>
56 <paramdef>size_t len</paramdef>
57 <paramdef>int af</paramdef>
58 <paramdef>int *error_num</paramdef>
63 <function>lwres_freehostent</function></funcdef>
64 <paramdef>struct hostent *he</paramdef>
70 <title>DESCRIPTION</title>
73 These functions perform thread safe, protocol independent
74 nodename-to-address and address-to-nodename
75 translation as defined in RFC2553.
80 <type>struct hostent</type>
82 <filename>namedb.h</filename>:
85 char *h_name; /* official name of host */
86 char **h_aliases; /* alias list */
87 int h_addrtype; /* host address type */
88 int h_length; /* length of address */
89 char **h_addr_list; /* list of addresses from name server */
91 #define h_addr h_addr_list[0] /* address, for backward compatibility */
96 The members of this structure are:
98 <varlistentry><term><constant>h_name</constant></term>
101 The official (canonical) name of the host.
103 </listitem></varlistentry>
104 <varlistentry><term><constant>h_aliases</constant></term>
107 A NULL-terminated array of alternate names (nicknames) for the host.
109 </listitem></varlistentry>
110 <varlistentry><term><constant>h_addrtype</constant></term>
113 The type of address being returned - usually
116 <type>PF_INET6</type>.
119 </listitem></varlistentry>
120 <varlistentry><term><constant>h_length</constant></term>
123 The length of the address in bytes.
125 </listitem></varlistentry>
126 <varlistentry><term><constant>h_addr_list</constant></term>
131 terminated array of network addresses for the host.
132 Host addresses are returned in network byte order.
134 </listitem></varlistentry>
138 <function>lwres_getipnodebyname()</function>
139 looks up addresses of protocol family
140 <parameter>af</parameter>
143 <parameter>name</parameter>.
146 <parameter>flags</parameter>
147 parameter contains ORed flag bits to
148 specify the types of addresses that are searched
149 for, and the types of addresses that are returned.
152 <varlistentry><term><constant>AI_V4MAPPED</constant></term>
156 <parameter>af</parameter>
157 of AF_INET6, and causes IPv4 addresses to be returned as IPv4-mapped
160 </listitem></varlistentry>
161 <varlistentry><term><constant>AI_ALL</constant></term>
165 <parameter>af</parameter>
166 of AF_INET6, and causes all known addresses (IPv6 and IPv4) to be returned.
167 If AI_V4MAPPED is also set, the IPv4 addresses are return as mapped
170 </listitem></varlistentry>
171 <varlistentry><term><constant>AI_ADDRCONFIG</constant></term>
174 Only return an IPv6 or IPv4 address if here is an active network
175 interface of that type. This is not currently implemented
176 in the BIND 9 lightweight resolver, and the flag is ignored.
178 </listitem></varlistentry>
179 <varlistentry><term><constant>AI_DEFAULT</constant></term>
182 This default sets the
183 <constant>AI_V4MAPPED</constant>
185 <constant>AI_ADDRCONFIG</constant>
188 </listitem></varlistentry>
192 <function>lwres_getipnodebyaddr()</function>
193 performs a reverse lookup
195 <parameter>src</parameter>
197 <parameter>len</parameter>
199 <parameter>af</parameter>
200 denotes the protocol family, typically
203 <type>PF_INET6</type>.
207 <function>lwres_freehostent()</function>
208 releases all the memory associated with
210 <type>struct hostent</type>
212 <parameter>he</parameter>.
214 Any memory allocated for the
215 <constant>h_name</constant>,
217 <constant>h_addr_list</constant>
219 <constant>h_aliases</constant>
220 is freed, as is the memory for the
226 <title>RETURN VALUES</title>
229 <function>lwres_getipnodebyname()</function>
231 <function>lwres_getipnodebyaddr()</function>
233 <parameter>*error_num</parameter>
234 to an approriate error code and the function returns a
237 The error codes and their meanings are defined in
238 <filename><lwres/netdb.h></filename>:
240 <varlistentry><term><constant>HOST_NOT_FOUND</constant></term>
243 No such host is known.
245 </listitem></varlistentry>
246 <varlistentry><term><constant>NO_ADDRESS</constant></term>
249 The server recognised the request and the name but no address is
250 available. Another type of request to the name server for the
251 domain might return an answer.
253 </listitem></varlistentry>
254 <varlistentry><term><constant>TRY_AGAIN</constant></term>
257 A temporary and possibly transient error occurred, such as a
258 failure of a server to respond. The request may succeed if
261 </listitem></varlistentry>
262 <varlistentry><term><constant>NO_RECOVERY</constant></term>
265 An unexpected failure occurred, and retrying the request
268 </listitem></varlistentry>
273 <refentrytitle>lwres_hstrerror</refentrytitle><manvolnum>3
276 translates these error codes to suitable error messages.
280 <title>SEE ALSO</title>
283 <refentrytitle>RFC2553</refentrytitle>
287 <refentrytitle>lwres</refentrytitle><manvolnum>3</manvolnum>
291 <refentrytitle>lwres_gethostent</refentrytitle><manvolnum>3</manvolnum>
295 <refentrytitle>lwres_getaddrinfo</refentrytitle><manvolnum>3</manvolnum>
299 <refentrytitle>lwres_getnameinfo</refentrytitle><manvolnum>3</manvolnum>
303 <refentrytitle>lwres_hstrerror</refentrytitle><manvolnum>3</manvolnum>