summaryrefslogtreecommitdiffstats
path: root/lib/lwres/man/lwres_getipnode.html
blob: 49e2c14d8b2e79c50316218089e1739364268300 (plain)
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
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!--
 - Copyright (C) 2000, 2001, 2003-2005, 2007, 2014-2016, 2018, 2019 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/.
-->
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>lwres_getipnode</title>
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="refentry">
<a name="id-1"></a><div class="titlepage"></div>
  
  

  

  

  <div class="refnamediv">
<h2>Name</h2>
<p>
    lwres_getipnodebyname, 
    lwres_getipnodebyaddr, 
    lwres_freehostent
     &#8212; lightweight resolver nodename / address translation API
  </p>
</div>
  <div class="refsynopsisdiv">
<h2>Synopsis</h2>
    <div class="funcsynopsis">
<pre class="funcsynopsisinfo">#include &lt;lwres/netdb.h&gt;</pre>
<table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;">
<tr>
<td><code class="funcdef">
struct hostent *
<b class="fsfunc">lwres_getipnodebyname</b>(</code></td>
<td>const char *<var class="pdparam">name</var>, </td>
</tr>
<tr>
<td></td>
<td>int <var class="pdparam">af</var>, </td>
</tr>
<tr>
<td></td>
<td>int <var class="pdparam">flags</var>, </td>
</tr>
<tr>
<td></td>
<td>int *<var class="pdparam">error_num</var><code>)</code>;</td>
</tr>
</table>
<div class="funcprototype-spacer"></div>
<table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;">
<tr>
<td><code class="funcdef">
struct hostent *
<b class="fsfunc">lwres_getipnodebyaddr</b>(</code></td>
<td>const void *<var class="pdparam">src</var>, </td>
</tr>
<tr>
<td></td>
<td>size_t <var class="pdparam">len</var>, </td>
</tr>
<tr>
<td></td>
<td>int <var class="pdparam">af</var>, </td>
</tr>
<tr>
<td></td>
<td>int *<var class="pdparam">error_num</var><code>)</code>;</td>
</tr>
</table>
<div class="funcprototype-spacer"></div>
<table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr>
<td><code class="funcdef">
void
<b class="fsfunc">lwres_freehostent</b>(</code></td>
<td>struct hostent *<var class="pdparam">he</var><code>)</code>;</td>
</tr></table>
<div class="funcprototype-spacer"></div>
</div>
  </div>

  <div class="refsection">
<a name="id-1.7"></a><h2>DESCRIPTION</h2>


    <p>
      These functions perform thread safe, protocol independent
      nodename-to-address and address-to-nodename
      translation as defined in RFC2553.
    </p>

    <p>
      They use a
      <span class="type">struct hostent</span>
      which is defined in
      <code class="filename">namedb.h</code>:
    </p>
    <pre class="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 */
</pre>
<p>
    </p>

    <p>
      The members of this structure are:
      </p>
<div class="variablelist"><dl class="variablelist">
<dt><span class="term"><code class="constant">h_name</code></span></dt>
<dd>
            <p>
              The official (canonical) name of the host.
            </p>
          </dd>
<dt><span class="term"><code class="constant">h_aliases</code></span></dt>
<dd>
            <p>
              A NULL-terminated array of alternate names (nicknames) for the
              host.
            </p>
          </dd>
<dt><span class="term"><code class="constant">h_addrtype</code></span></dt>
<dd>
            <p>
              The type of address being returned - usually
              <span class="type">PF_INET</span>
              or
              <span class="type">PF_INET6</span>.

            </p>
          </dd>
<dt><span class="term"><code class="constant">h_length</code></span></dt>
<dd>
            <p>
              The length of the address in bytes.
            </p>
          </dd>
<dt><span class="term"><code class="constant">h_addr_list</code></span></dt>
<dd>
            <p>
              A
              <span class="type">NULL</span>
              terminated array of network addresses for the host.
              Host addresses are returned in network byte order.
            </p>
          </dd>
</dl></div>
<p>
    </p>

    <p><code class="function">lwres_getipnodebyname()</code>
      looks up addresses of protocol family <em class="parameter"><code>af</code></em>
      for the hostname <em class="parameter"><code>name</code></em>.  The
      <em class="parameter"><code>flags</code></em> 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:

      </p>
<div class="variablelist"><dl class="variablelist">
<dt><span class="term"><code class="constant">AI_V4MAPPED</code></span></dt>
<dd>
            <p>
              This is used with an
              <em class="parameter"><code>af</code></em>
              of AF_INET6, and causes IPv4 addresses to be returned as
              IPv4-mapped
              IPv6 addresses.
            </p>
          </dd>
<dt><span class="term"><code class="constant">AI_ALL</code></span></dt>
<dd>
            <p>
              This is used with an
              <em class="parameter"><code>af</code></em>
              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.
            </p>
          </dd>
<dt><span class="term"><code class="constant">AI_ADDRCONFIG</code></span></dt>
<dd>
            <p>
              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.
            </p>
          </dd>
<dt><span class="term"><code class="constant">AI_DEFAULT</code></span></dt>
<dd>
            <p>
              This default sets the
              <code class="constant">AI_V4MAPPED</code>
              and
              <code class="constant">AI_ADDRCONFIG</code>
              flag bits.
            </p>
          </dd>
</dl></div>
<p>
    </p>

    <p><code class="function">lwres_getipnodebyaddr()</code>
      performs a reverse lookup of address <em class="parameter"><code>src</code></em>
      which is <em class="parameter"><code>len</code></em> bytes long.
      <em class="parameter"><code>af</code></em> denotes the protocol family, typically
      <span class="type">PF_INET</span> or <span class="type">PF_INET6</span>.
    </p>
    <p><code class="function">lwres_freehostent()</code>
      releases all the memory associated with the <span class="type">struct
      hostent</span> pointer <em class="parameter"><code>he</code></em>.  Any memory
      allocated for the <code class="constant">h_name</code>,
      <code class="constant">h_addr_list</code> and
      <code class="constant">h_aliases</code> is freed, as is the memory for
      the <span class="type">hostent</span> structure itself.
    </p>
  </div>
  <div class="refsection">
<a name="id-1.8"></a><h2>RETURN VALUES</h2>

    <p>
      If an error occurs,
      <code class="function">lwres_getipnodebyname()</code>
      and
      <code class="function">lwres_getipnodebyaddr()</code>
      set
      <em class="parameter"><code>*error_num</code></em>
      to an appropriate error code and the function returns a
      <span class="type">NULL</span>
      pointer.
      The error codes and their meanings are defined in
      <code class="filename">&lt;lwres/netdb.h&gt;</code>:
      </p>
<div class="variablelist"><dl class="variablelist">
<dt><span class="term"><code class="constant">HOST_NOT_FOUND</code></span></dt>
<dd>
            <p>
              No such host is known.
            </p>
          </dd>
<dt><span class="term"><code class="constant">NO_ADDRESS</code></span></dt>
<dd>
            <p>
              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.
            </p>
          </dd>
<dt><span class="term"><code class="constant">TRY_AGAIN</code></span></dt>
<dd>
            <p>
              A temporary and possibly transient error occurred, such as a
              failure of a server to respond.  The request may succeed if
              retried.
            </p>
          </dd>
<dt><span class="term"><code class="constant">NO_RECOVERY</code></span></dt>
<dd>
            <p>
              An unexpected failure occurred, and retrying the request
              is pointless.
            </p>
          </dd>
</dl></div>
<p>
    </p>
    <p><span class="citerefentry">
        <span class="refentrytitle">lwres_hstrerror</span>(3)
      </span>
      translates these error codes to suitable error messages.
    </p>
  </div>
  <div class="refsection">
<a name="id-1.9"></a><h2>SEE ALSO</h2>

    <p><span class="citerefentry">
        <span class="refentrytitle">RFC2553</span>
      </span>,

      <span class="citerefentry">
        <span class="refentrytitle">lwres</span>(3)
      </span>,

      <span class="citerefentry">
        <span class="refentrytitle">lwres_gethostent</span>(3)
      </span>,

      <span class="citerefentry">
        <span class="refentrytitle">lwres_getaddrinfo</span>(3)
      </span>,

      <span class="citerefentry">
        <span class="refentrytitle">lwres_getnameinfo</span>(3)
      </span>,

      <span class="citerefentry">
        <span class="refentrytitle">lwres_hstrerror</span>(3)
      </span>.
    </p>
  </div>
</div></body>
</html>