1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
|
<!--
- Copyright (C) Internet Systems Consortium, Inc. ("ISC")
-
- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
- See the COPYRIGHT file distributed with this work for additional
- information regarding copyright ownership.
-->
<!-- Converted by db4-upgrade version 1.0 -->
<refentry xmlns:db="http://docbook.org/ns/docbook" version="5.0">
<info>
<date>2007-06-18</date>
</info>
<refentryinfo>
<corpname>ISC</corpname>
<corpauthor>Internet Systems Consortium, Inc.</corpauthor>
</refentryinfo>
<refmeta>
<refentrytitle>lwres_getipnode</refentrytitle>
<manvolnum>3</manvolnum>
<refmiscinfo>BIND9</refmiscinfo>
</refmeta>
<docinfo>
<copyright>
<year>2000</year>
<year>2001</year>
<year>2003</year>
<year>2004</year>
<year>2005</year>
<year>2007</year>
<year>2014</year>
<year>2015</year>
<year>2016</year>
<year>2018</year>
<year>2019</year>
<holder>Internet Systems Consortium, Inc. ("ISC")</holder>
</copyright>
</docinfo>
<refnamediv>
<refname>lwres_getipnodebyname</refname>
<refname>lwres_getipnodebyaddr</refname>
<refname>lwres_freehostent</refname>
<refpurpose>lightweight resolver nodename / address translation API</refpurpose>
</refnamediv>
<refsynopsisdiv>
<funcsynopsis>
<funcsynopsisinfo>#include <lwres/netdb.h></funcsynopsisinfo>
<funcprototype>
<funcdef>
struct hostent *
<function>lwres_getipnodebyname</function></funcdef>
<paramdef>const char *<parameter>name</parameter></paramdef>
<paramdef>int <parameter>af</parameter></paramdef>
<paramdef>int <parameter>flags</parameter></paramdef>
<paramdef>int *<parameter>error_num</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>
struct hostent *
<function>lwres_getipnodebyaddr</function></funcdef>
<paramdef>const void *<parameter>src</parameter></paramdef>
<paramdef>size_t <parameter>len</parameter></paramdef>
<paramdef>int <parameter>af</parameter></paramdef>
<paramdef>int *<parameter>error_num</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>
void
<function>lwres_freehostent</function></funcdef>
<paramdef>struct hostent *<parameter>he</parameter></paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<refsection><info><title>DESCRIPTION</title></info>
<para>
These functions perform thread safe, protocol independent
nodename-to-address and address-to-nodename
translation as defined in RFC2553.
</para>
<para>
They use a
<type>struct hostent</type>
which is defined in
<filename>namedb.h</filename>:
</para>
<para><programlisting>
struct hostent {
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 */
</programlisting>
</para>
<para>
The members of this structure are:
<variablelist>
<varlistentry>
<term><constant>h_name</constant></term>
<listitem>
<para>
The official (canonical) name of the host.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><constant>h_aliases</constant></term>
<listitem>
<para>
A NULL-terminated array of alternate names (nicknames) for the
host.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><constant>h_addrtype</constant></term>
<listitem>
<para>
The type of address being returned - usually
<type>PF_INET</type>
or
<type>PF_INET6</type>.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><constant>h_length</constant></term>
<listitem>
<para>
The length of the address in bytes.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><constant>h_addr_list</constant></term>
<listitem>
<para>
A
<type>NULL</type>
terminated array of network addresses for the host.
Host addresses are returned in network byte order.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
<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:
<variablelist>
<varlistentry>
<term><constant>AI_V4MAPPED</constant></term>
<listitem>
<para>
This is used with an
<parameter>af</parameter>
of AF_INET6, and causes IPv4 addresses to be returned as
IPv4-mapped
IPv6 addresses.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><constant>AI_ALL</constant></term>
<listitem>
<para>
This is used with an
<parameter>af</parameter>
of AF_INET6, and causes all known addresses (IPv6 and IPv4) to
be returned.
If AI_V4MAPPED is also set, the IPv4 addresses are return as
mapped
IPv6 addresses.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><constant>AI_ADDRCONFIG</constant></term>
<listitem>
<para>
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.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><constant>AI_DEFAULT</constant></term>
<listitem>
<para>
This default sets the
<constant>AI_V4MAPPED</constant>
and
<constant>AI_ADDRCONFIG</constant>
flag bits.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
<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>
<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.
</para>
</refsection>
<refsection><info><title>RETURN VALUES</title></info>
<para>
If an error occurs,
<function>lwres_getipnodebyname()</function>
and
<function>lwres_getipnodebyaddr()</function>
set
<parameter>*error_num</parameter>
to an appropriate error code and the function returns a
<type>NULL</type>
pointer.
The error codes and their meanings are defined in
<filename><lwres/netdb.h></filename>:
<variablelist>
<varlistentry>
<term><constant>HOST_NOT_FOUND</constant></term>
<listitem>
<para>
No such host is known.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><constant>NO_ADDRESS</constant></term>
<listitem>
<para>
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.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><constant>TRY_AGAIN</constant></term>
<listitem>
<para>
A temporary and possibly transient error occurred, such as a
failure of a server to respond. The request may succeed if
retried.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><constant>NO_RECOVERY</constant></term>
<listitem>
<para>
An unexpected failure occurred, and retrying the request
is pointless.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
<para><citerefentry>
<refentrytitle>lwres_hstrerror</refentrytitle><manvolnum>3</manvolnum>
</citerefentry>
translates these error codes to suitable error messages.
</para>
</refsection>
<refsection><info><title>SEE ALSO</title></info>
<para><citerefentry>
<refentrytitle>RFC2553</refentrytitle>
</citerefentry>,
<citerefentry>
<refentrytitle>lwres</refentrytitle><manvolnum>3</manvolnum>
</citerefentry>,
<citerefentry>
<refentrytitle>lwres_gethostent</refentrytitle><manvolnum>3</manvolnum>
</citerefentry>,
<citerefentry>
<refentrytitle>lwres_getaddrinfo</refentrytitle><manvolnum>3</manvolnum>
</citerefentry>,
<citerefentry>
<refentrytitle>lwres_getnameinfo</refentrytitle><manvolnum>3</manvolnum>
</citerefentry>,
<citerefentry>
<refentrytitle>lwres_hstrerror</refentrytitle><manvolnum>3</manvolnum>
</citerefentry>.
</para>
</refsection>
</refentry>
|