50
<refname>lwres_getipnodebyname</refname>
51
<refname>lwres_getipnodebyaddr</refname>
52
<refname>lwres_freehostent</refname>
53
<refpurpose>lightweight resolver nodename / address translation API</refpurpose>
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
57
<funcsynopsisinfo>#include <lwres/netdb.h></funcsynopsisinfo>
61
61
<function>lwres_getipnodebyname</function></funcdef>
62
<paramdef>const char *name</paramdef>
63
<paramdef>int af</paramdef>
64
<paramdef>int flags</paramdef>
65
<paramdef>int *error_num</paramdef>
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
70
<function>lwres_getipnodebyaddr</function></funcdef>
71
<paramdef>const void *src</paramdef>
72
<paramdef>size_t len</paramdef>
73
<paramdef>int af</paramdef>
74
<paramdef>int *error_num</paramdef>
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
79
<function>lwres_freehostent</function></funcdef>
80
<paramdef>struct hostent *he</paramdef>
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>:
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>
101
102
char *h_name; /* official name of host */
102
103
char **h_aliases; /* alias list */
107
108
#define h_addr h_addr_list[0] /* address, for backward compatibility */
108
109
</programlisting>
112
The members of this structure are:
114
<varlistentry><term><constant>h_name</constant></term>
117
The official (canonical) name of the host.
119
</listitem></varlistentry>
120
<varlistentry><term><constant>h_aliases</constant></term>
123
A NULL-terminated array of alternate names (nicknames) for the host.
125
</listitem></varlistentry>
126
<varlistentry><term><constant>h_addrtype</constant></term>
129
The type of address being returned - usually
132
<type>PF_INET6</type>.
135
</listitem></varlistentry>
136
<varlistentry><term><constant>h_length</constant></term>
139
The length of the address in bytes.
141
</listitem></varlistentry>
142
<varlistentry><term><constant>h_addr_list</constant></term>
147
terminated array of network addresses for the host.
148
Host addresses are returned in network byte order.
150
</listitem></varlistentry>
154
<function>lwres_getipnodebyname()</function>
155
looks up addresses of protocol family
156
<parameter>af</parameter>
159
<parameter>name</parameter>.
162
<parameter>flags</parameter>
163
parameter contains ORed flag bits to
164
specify the types of addresses that are searched
165
for, and the types of addresses that are returned.
168
<varlistentry><term><constant>AI_V4MAPPED</constant></term>
172
<parameter>af</parameter>
173
of AF_INET6, and causes IPv4 addresses to be returned as IPv4-mapped
176
</listitem></varlistentry>
177
<varlistentry><term><constant>AI_ALL</constant></term>
181
<parameter>af</parameter>
182
of AF_INET6, and causes all known addresses (IPv6 and IPv4) to be returned.
183
If AI_V4MAPPED is also set, the IPv4 addresses are return as mapped
186
</listitem></varlistentry>
187
<varlistentry><term><constant>AI_ADDRCONFIG</constant></term>
190
Only return an IPv6 or IPv4 address if here is an active network
191
interface of that type. This is not currently implemented
192
in the BIND 9 lightweight resolver, and the flag is ignored.
194
</listitem></varlistentry>
195
<varlistentry><term><constant>AI_DEFAULT</constant></term>
198
This default sets the
199
<constant>AI_V4MAPPED</constant>
201
<constant>AI_ADDRCONFIG</constant>
204
</listitem></varlistentry>
208
<function>lwres_getipnodebyaddr()</function>
209
performs a reverse lookup
211
<parameter>src</parameter>
213
<parameter>len</parameter>
215
<parameter>af</parameter>
216
denotes the protocol family, typically
219
<type>PF_INET6</type>.
223
<function>lwres_freehostent()</function>
224
releases all the memory associated with
226
<type>struct hostent</type>
228
<parameter>he</parameter>.
230
Any memory allocated for the
231
<constant>h_name</constant>,
233
<constant>h_addr_list</constant>
235
<constant>h_aliases</constant>
236
is freed, as is the memory for the
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>:
256
<varlistentry><term><constant>HOST_NOT_FOUND</constant></term>
259
No such host is known.
261
</listitem></varlistentry>
262
<varlistentry><term><constant>NO_ADDRESS</constant></term>
265
The server recognised the request and the name but no address is
266
available. Another type of request to the name server for the
267
domain might return an answer.
269
</listitem></varlistentry>
270
<varlistentry><term><constant>TRY_AGAIN</constant></term>
273
A temporary and possibly transient error occurred, such as a
274
failure of a server to respond. The request may succeed if
277
</listitem></varlistentry>
278
<varlistentry><term><constant>NO_RECOVERY</constant></term>
281
An unexpected failure occurred, and retrying the request
284
</listitem></varlistentry>
289
<refentrytitle>lwres_hstrerror</refentrytitle><manvolnum>3
292
translates these error codes to suitable error messages.
296
<title>SEE ALSO</title>
299
<refentrytitle>RFC2553</refentrytitle>
303
<refentrytitle>lwres</refentrytitle><manvolnum>3</manvolnum>
307
<refentrytitle>lwres_gethostent</refentrytitle><manvolnum>3</manvolnum>
311
<refentrytitle>lwres_getaddrinfo</refentrytitle><manvolnum>3</manvolnum>
315
<refentrytitle>lwres_getnameinfo</refentrytitle><manvolnum>3</manvolnum>
319
<refentrytitle>lwres_hstrerror</refentrytitle><manvolnum>3</manvolnum>
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>