115
121
#define h_addr h_addr_list[0] /* address, for backward compatibility */
120
The members of this structure are:
126
The members of this structure are:
122
128
<div class="variablelist"><dl>
123
129
<dt><span class="term"><code class="constant">h_name</code></span></dt>
125
The official (canonical) name of the host.
131
The official (canonical) name of the host.
127
133
<dt><span class="term"><code class="constant">h_aliases</code></span></dt>
129
A NULL-terminated array of alternate names (nicknames) for the host.
135
A NULL-terminated array of alternate names (nicknames) for the
131
138
<dt><span class="term"><code class="constant">h_addrtype</code></span></dt>
133
The type of address being returned - usually
134
<span class="type">PF_INET</span>
136
<span class="type">PF_INET6</span>.
140
The type of address being returned - usually
141
<span class="type">PF_INET</span>
143
<span class="type">PF_INET6</span>.
139
146
<dt><span class="term"><code class="constant">h_length</code></span></dt>
141
The length of the address in bytes.
148
The length of the address in bytes.
143
150
<dt><span class="term"><code class="constant">h_addr_list</code></span></dt>
146
<span class="type">NULL</span>
147
terminated array of network addresses for the host.
148
Host addresses are returned in network byte order.
153
<span class="type">NULL</span>
154
terminated array of network addresses for the host.
155
Host addresses are returned in network byte order.
154
<code class="function">lwres_getipnodebyname()</code>
155
looks up addresses of protocol family
156
<em class="parameter"><code>af</code></em>
159
<em class="parameter"><code>name</code></em>.
162
<em class="parameter"><code>flags</code></em>
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.
160
<p><code class="function">lwres_getipnodebyname()</code>
161
looks up addresses of protocol family <em class="parameter"><code>af</code></em>
162
for the hostname <em class="parameter"><code>name</code></em>. The
163
<em class="parameter"><code>flags</code></em> parameter contains ORed flag bits
164
to specify the types of addresses that are searched for, and the
165
types of addresses that are returned. The flag bits are:
168
168
<div class="variablelist"><dl>
169
169
<dt><span class="term"><code class="constant">AI_V4MAPPED</code></span></dt>
172
<em class="parameter"><code>af</code></em>
173
of AF_INET6, and causes IPv4 addresses to be returned as IPv4-mapped
172
<em class="parameter"><code>af</code></em>
173
of AF_INET6, and causes IPv4 addresses to be returned as
176
177
<dt><span class="term"><code class="constant">AI_ALL</code></span></dt>
179
<em class="parameter"><code>af</code></em>
180
of AF_INET6, and causes all known addresses (IPv6 and IPv4) to be returned.
181
If AI_V4MAPPED is also set, the IPv4 addresses are return as mapped
180
<em class="parameter"><code>af</code></em>
181
of AF_INET6, and causes all known addresses (IPv6 and IPv4) to
183
If AI_V4MAPPED is also set, the IPv4 addresses are return as
184
187
<dt><span class="term"><code class="constant">AI_ADDRCONFIG</code></span></dt>
186
Only return an IPv6 or IPv4 address if here is an active network
187
interface of that type. This is not currently implemented
188
in the BIND 9 lightweight resolver, and the flag is ignored.
189
Only return an IPv6 or IPv4 address if here is an active network
190
interface of that type. This is not currently implemented
191
in the BIND 9 lightweight resolver, and the flag is ignored.
190
193
<dt><span class="term"><code class="constant">AI_DEFAULT</code></span></dt>
192
This default sets the
193
<code class="constant">AI_V4MAPPED</code>
195
<code class="constant">AI_ADDRCONFIG</code>
195
This default sets the
196
<code class="constant">AI_V4MAPPED</code>
198
<code class="constant">AI_ADDRCONFIG</code>
202
<code class="function">lwres_getipnodebyaddr()</code>
203
performs a reverse lookup
205
<em class="parameter"><code>src</code></em>
207
<em class="parameter"><code>len</code></em>
209
<em class="parameter"><code>af</code></em>
210
denotes the protocol family, typically
211
<span class="type">PF_INET</span>
213
<span class="type">PF_INET6</span>.
217
<code class="function">lwres_freehostent()</code>
218
releases all the memory associated with
220
<span class="type">struct hostent</span>
222
<em class="parameter"><code>he</code></em>.
224
Any memory allocated for the
225
<code class="constant">h_name</code>,
227
<code class="constant">h_addr_list</code>
229
<code class="constant">h_aliases</code>
230
is freed, as is the memory for the
231
<span class="type">hostent</span>
204
<p><code class="function">lwres_getipnodebyaddr()</code>
205
performs a reverse lookup of address <em class="parameter"><code>src</code></em>
206
which is <em class="parameter"><code>len</code></em> bytes long.
207
<em class="parameter"><code>af</code></em> denotes the protocol family, typically
208
<span class="type">PF_INET</span> or <span class="type">PF_INET6</span>.
210
<p><code class="function">lwres_freehostent()</code>
211
releases all the memory associated with the <span class="type">struct
212
hostent</span> pointer <em class="parameter"><code>he</code></em>. Any memory
213
allocated for the <code class="constant">h_name</code>,
214
<code class="constant">h_addr_list</code> and
215
<code class="constant">h_aliases</code> is freed, as is the memory for
216
the <span class="type">hostent</span> structure itself.
235
219
<div class="refsect1" lang="en">
236
<a name="id2526131"></a><h2>RETURN VALUES</h2>
220
<a name="id2543689"></a><h2>RETURN VALUES</h2>
239
<code class="function">lwres_getipnodebyname()</code>
241
<code class="function">lwres_getipnodebyaddr()</code>
243
<em class="parameter"><code>*error_num</code></em>
244
to an appropriate error code and the function returns a
245
<span class="type">NULL</span>
247
The error codes and their meanings are defined in
248
<code class="filename"><lwres/netdb.h></code>:
223
<code class="function">lwres_getipnodebyname()</code>
225
<code class="function">lwres_getipnodebyaddr()</code>
227
<em class="parameter"><code>*error_num</code></em>
228
to an appropriate error code and the function returns a
229
<span class="type">NULL</span>
231
The error codes and their meanings are defined in
232
<code class="filename"><lwres/netdb.h></code>:
250
234
<div class="variablelist"><dl>
251
235
<dt><span class="term"><code class="constant">HOST_NOT_FOUND</code></span></dt>
253
No such host is known.
237
No such host is known.
255
239
<dt><span class="term"><code class="constant">NO_ADDRESS</code></span></dt>
257
The server recognised the request and the name but no address is
258
available. Another type of request to the name server for the
259
domain might return an answer.
241
The server recognised the request and the name but no address is
242
available. Another type of request to the name server for the
243
domain might return an answer.
261
245
<dt><span class="term"><code class="constant">TRY_AGAIN</code></span></dt>
263
A temporary and possibly transient error occurred, such as a
264
failure of a server to respond. The request may succeed if
247
A temporary and possibly transient error occurred, such as a
248
failure of a server to respond. The request may succeed if
267
251
<dt><span class="term"><code class="constant">NO_RECOVERY</code></span></dt>
269
An unexpected failure occurred, and retrying the request
253
An unexpected failure occurred, and retrying the request
276
<span class="citerefentry"><span class="refentrytitle">lwres_hstrerror</span>(3
278
translates these error codes to suitable error messages.
259
<p><span class="citerefentry"><span class="refentrytitle">lwres_hstrerror</span>(3)</span>
260
translates these error codes to suitable error messages.
281
263
<div class="refsect1" lang="en">
282
<a name="id2526290"></a><h2>SEE ALSO</h2>
284
<span class="citerefentry"><span class="refentrytitle">RFC2553</span></span>,
286
<span class="citerefentry"><span class="refentrytitle">lwres</span>(3)</span>,
288
<span class="citerefentry"><span class="refentrytitle">lwres_gethostent</span>(3)</span>,
290
<span class="citerefentry"><span class="refentrytitle">lwres_getaddrinfo</span>(3)</span>,
292
<span class="citerefentry"><span class="refentrytitle">lwres_getnameinfo</span>(3)</span>,
294
<span class="citerefentry"><span class="refentrytitle">lwres_hstrerror</span>(3)</span>.
264
<a name="id2543786"></a><h2>SEE ALSO</h2>
265
<p><span class="citerefentry"><span class="refentrytitle">RFC2553</span></span>,
267
<span class="citerefentry"><span class="refentrytitle">lwres</span>(3)</span>,
269
<span class="citerefentry"><span class="refentrytitle">lwres_gethostent</span>(3)</span>,
271
<span class="citerefentry"><span class="refentrytitle">lwres_getaddrinfo</span>(3)</span>,
273
<span class="citerefentry"><span class="refentrytitle">lwres_getnameinfo</span>(3)</span>,
275
<span class="citerefentry"><span class="refentrytitle">lwres_hstrerror</span>(3)</span>.