diff options
Diffstat (limited to 'src/lib/libc/net/resolver.3')
-rw-r--r-- | src/lib/libc/net/resolver.3 | 398 |
1 files changed, 398 insertions, 0 deletions
diff --git a/src/lib/libc/net/resolver.3 b/src/lib/libc/net/resolver.3 new file mode 100644 index 0000000000..93b365a619 --- /dev/null +++ b/src/lib/libc/net/resolver.3 | |||
@@ -0,0 +1,398 @@ | |||
1 | .\" $OpenBSD: resolver.3,v 1.29 2014/01/21 03:15:45 schwarze Exp $ | ||
2 | .\" | ||
3 | .\" Copyright (c) 1985, 1991, 1993 | ||
4 | .\" The Regents of the University of California. All rights reserved. | ||
5 | .\" | ||
6 | .\" Redistribution and use in source and binary forms, with or without | ||
7 | .\" modification, are permitted provided that the following conditions | ||
8 | .\" are met: | ||
9 | .\" 1. Redistributions of source code must retain the above copyright | ||
10 | .\" notice, this list of conditions and the following disclaimer. | ||
11 | .\" 2. Redistributions in binary form must reproduce the above copyright | ||
12 | .\" notice, this list of conditions and the following disclaimer in the | ||
13 | .\" documentation and/or other materials provided with the distribution. | ||
14 | .\" 3. Neither the name of the University nor the names of its contributors | ||
15 | .\" may be used to endorse or promote products derived from this software | ||
16 | .\" without specific prior written permission. | ||
17 | .\" | ||
18 | .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | ||
19 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
20 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
21 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | ||
22 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
23 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
24 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
25 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
26 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
27 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
28 | .\" SUCH DAMAGE. | ||
29 | .\" | ||
30 | .Dd $Mdocdate: January 21 2014 $ | ||
31 | .Dt RESOLVER 3 | ||
32 | .Os | ||
33 | .Sh NAME | ||
34 | .Nm res_query , | ||
35 | .Nm res_search , | ||
36 | .Nm res_mkquery , | ||
37 | .Nm res_send , | ||
38 | .Nm res_init , | ||
39 | .Nm dn_comp , | ||
40 | .Nm dn_expand | ||
41 | .Nd resolver routines | ||
42 | .Sh SYNOPSIS | ||
43 | .In sys/types.h | ||
44 | .In netinet/in.h | ||
45 | .In arpa/nameser.h | ||
46 | .In resolv.h | ||
47 | .Ft int | ||
48 | .Fo res_query | ||
49 | .Fa "const char *dname" | ||
50 | .Fa "int class" | ||
51 | .Fa "int type" | ||
52 | .Fa "unsigned char *answer" | ||
53 | .Fa "int anslen" | ||
54 | .Fc | ||
55 | .Ft int | ||
56 | .Fo res_search | ||
57 | .Fa "const char *dname" | ||
58 | .Fa "int class" | ||
59 | .Fa "int type" | ||
60 | .Fa "unsigned char *answer" | ||
61 | .Fa "int anslen" | ||
62 | .Fc | ||
63 | .Ft int | ||
64 | .Fo res_mkquery | ||
65 | .Fa "int op" | ||
66 | .Fa "const char *dname" | ||
67 | .Fa "int class" | ||
68 | .Fa "int type" | ||
69 | .Fa "const unsigned char *data" | ||
70 | .Fa "int datalen" | ||
71 | .Fa "const unsigned char *newrr" | ||
72 | .Fa "unsigned char *buf" | ||
73 | .Fa "int buflen" | ||
74 | .Fc | ||
75 | .Ft int | ||
76 | .Fo res_send | ||
77 | .Fa "const unsigned char *msg" | ||
78 | .Fa "int msglen" | ||
79 | .Fa "unsigned char *answer" | ||
80 | .Fa "int anslen" | ||
81 | .Fc | ||
82 | .Ft int | ||
83 | .Fn res_init "void" | ||
84 | .Ft int | ||
85 | .Fo dn_comp | ||
86 | .Fa "const char *exp_dn" | ||
87 | .Fa "unsigned char *comp_dn" | ||
88 | .Fa "int length" | ||
89 | .Fa "unsigned char **dnptrs" | ||
90 | .Fa "unsigned char **lastdnptr" | ||
91 | .Fc | ||
92 | .Ft int | ||
93 | .Fo dn_expand | ||
94 | .Fa "const unsigned char *msg" | ||
95 | .Fa "const unsigned char *eomorig" | ||
96 | .Fa "const unsigned char *comp_dn" | ||
97 | .Fa "char *exp_dn" | ||
98 | .Fa "int length" | ||
99 | .Fc | ||
100 | .Sh DESCRIPTION | ||
101 | These routines are used for making, sending, and interpreting | ||
102 | query and reply messages with Internet domain name servers. | ||
103 | .Pp | ||
104 | Global configuration and state information that is used by the | ||
105 | resolver routines is kept in the structure | ||
106 | .Li _res . | ||
107 | Most of the values have reasonable defaults and can be ignored. | ||
108 | Options stored in | ||
109 | .Li _res.options | ||
110 | are defined in | ||
111 | .In resolv.h | ||
112 | and are as follows. | ||
113 | Options are stored as a simple bit mask containing the bitwise OR | ||
114 | of the options enabled. | ||
115 | .Bl -tag -width RES_USE_DNSSEC | ||
116 | .It Dv RES_INIT | ||
117 | True if the initial name server address and default domain name are | ||
118 | initialized (i.e.\& | ||
119 | .Fn res_init | ||
120 | has been called). | ||
121 | .It Dv RES_DEBUG | ||
122 | Print debugging messages, | ||
123 | if libc is compiled with | ||
124 | .Dv DEBUG . | ||
125 | By default on | ||
126 | .Ox | ||
127 | this option does nothing. | ||
128 | .It Dv RES_AAONLY | ||
129 | Accept authoritative answers only. | ||
130 | With this option, | ||
131 | .Fn res_send | ||
132 | should continue until it finds an authoritative answer or finds an error. | ||
133 | Currently this is not implemented. | ||
134 | .It Dv RES_USEVC | ||
135 | Use TCP connections for queries instead of UDP datagrams. | ||
136 | .It Dv RES_PRIMARY | ||
137 | Query the primary name server only. | ||
138 | Currently this is not implemented. | ||
139 | .It Dv RES_IGNTC | ||
140 | Ignore truncation errors, i.e. don't retry with TCP. | ||
141 | .It Dv RES_RECURSE | ||
142 | Set the recursion-desired bit in queries. | ||
143 | .Pf ( Fn res_send | ||
144 | does not do iterative queries and expects the name server | ||
145 | to handle recursion.) | ||
146 | This option is enabled by default. | ||
147 | .It Dv RES_DEFNAMES | ||
148 | If set, | ||
149 | .Fn res_search | ||
150 | will append the default domain name to single-component names | ||
151 | (those that do not contain a dot). | ||
152 | This option is enabled by default. | ||
153 | .It Dv RES_STAYOPEN | ||
154 | Used with | ||
155 | .Dv RES_USEVC | ||
156 | to keep the TCP connection open between queries. | ||
157 | This is useful only in programs that regularly do many queries. | ||
158 | UDP should be the normal mode used. | ||
159 | .It Dv RES_DNSRCH | ||
160 | If this option is set, | ||
161 | .Fn res_search | ||
162 | will search for host names in the current domain and in parent domains; see | ||
163 | .Xr hostname 7 . | ||
164 | This is used by the standard host lookup routine | ||
165 | .Xr gethostbyname 3 . | ||
166 | This option is enabled by default. | ||
167 | .It Dv RES_INSECURE_1 | ||
168 | Do not require the IP source address on the reply packet | ||
169 | to be equal to the server's address. | ||
170 | .It Dv RES_INSECURE_2 | ||
171 | Do not check if the query section of the reply packet | ||
172 | is equal to that of the query packet. | ||
173 | .It Dv RES_NOALIASES | ||
174 | Turn off the | ||
175 | .Ev HOSTALIASES | ||
176 | feature. | ||
177 | See | ||
178 | .Xr hostname 7 | ||
179 | for more information. | ||
180 | .It Dv RES_USE_INET6 | ||
181 | Enables support for IPv6-only applications. | ||
182 | This causes IPv4 addresses to be returned as an IPv4 mapped address. | ||
183 | For example, 10.1.1.1 will be returned as ::ffff:10.1.1.1. | ||
184 | The option is not meaningful on | ||
185 | .Ox . | ||
186 | .It Dv RES_USE_EDNS0 | ||
187 | Attach an OPT pseudo-RR for the EDNS0 extension, | ||
188 | as specified in RFC 2671. | ||
189 | This informs DNS servers of a client's receive buffer size, | ||
190 | allowing them to take advantage of a non-default receive buffer size, | ||
191 | and thus to send larger replies. | ||
192 | DNS query packets with the EDNS0 extension are not compatible with | ||
193 | non-EDNS0 DNS servers. | ||
194 | .It Dv RES_USE_DNSSEC | ||
195 | Request that the resolver uses | ||
196 | Domain Name System Security Extensions (DNSSEC), | ||
197 | as defined in RFCs 4033, 4034, and 4035. | ||
198 | .El | ||
199 | .Pp | ||
200 | The | ||
201 | .Fn res_init | ||
202 | routine reads the configuration file (if any; see | ||
203 | .Xr resolv.conf 5 ) | ||
204 | to get the default domain name, search list, and the Internet address | ||
205 | of the local name server(s). | ||
206 | If no server is configured, the host running | ||
207 | the resolver is tried. | ||
208 | The current domain name is defined by the hostname | ||
209 | if not specified in the configuration file; | ||
210 | it can be overridden by the environment variable | ||
211 | .Ev LOCALDOMAIN . | ||
212 | This environment variable may contain several blank-separated | ||
213 | tokens if you wish to override the | ||
214 | .Fa search list | ||
215 | on a per-process basis. | ||
216 | This is similar to the | ||
217 | .Fa search | ||
218 | command in the configuration file. | ||
219 | Another environment variable | ||
220 | .Ev RES_OPTIONS | ||
221 | can be set to override certain internal resolver options which | ||
222 | are otherwise set by changing fields in the | ||
223 | .Fa _res | ||
224 | structure or are inherited from the configuration file's | ||
225 | .Fa options | ||
226 | command. | ||
227 | The syntax of the | ||
228 | .Ev RES_OPTIONS | ||
229 | environment variable is explained in | ||
230 | .Xr resolv.conf 5 . | ||
231 | Initialization normally occurs on the first call | ||
232 | to one of the following routines. | ||
233 | .Pp | ||
234 | The | ||
235 | .Fn res_query | ||
236 | function provides an interface to the server query mechanism. | ||
237 | It constructs a query, sends it to the local server, | ||
238 | awaits a response, and makes preliminary checks on the reply. | ||
239 | The query requests information of the specified | ||
240 | .Fa type | ||
241 | and | ||
242 | .Fa class | ||
243 | for the specified fully qualified domain name | ||
244 | .Fa dname . | ||
245 | The reply message is left in the | ||
246 | .Fa answer | ||
247 | buffer with length | ||
248 | .Fa anslen | ||
249 | supplied by the caller. | ||
250 | Values for the | ||
251 | .Fa class | ||
252 | and | ||
253 | .Fa type | ||
254 | fields | ||
255 | are defined in | ||
256 | .In arpa/nameser.h . | ||
257 | .Pp | ||
258 | The | ||
259 | .Fn res_search | ||
260 | routine makes a query and awaits a response like | ||
261 | .Fn res_query , | ||
262 | but in addition, it implements the default and search rules controlled by the | ||
263 | .Dv RES_DEFNAMES | ||
264 | and | ||
265 | .Dv RES_DNSRCH | ||
266 | options. | ||
267 | It returns the first successful reply. | ||
268 | .Pp | ||
269 | The remaining routines are lower-level routines used by | ||
270 | .Fn res_query . | ||
271 | The | ||
272 | .Fn res_mkquery | ||
273 | function constructs a standard query message and places it in | ||
274 | .Fa buf . | ||
275 | It returns the size of the query, or \-1 if the query is larger than | ||
276 | .Fa buflen . | ||
277 | The query type | ||
278 | .Fa op | ||
279 | is usually | ||
280 | .Dv QUERY , | ||
281 | but can be any of the query types defined in | ||
282 | .In arpa/nameser.h . | ||
283 | The domain name for the query is given by | ||
284 | .Fa dname . | ||
285 | .Fa newrr | ||
286 | is currently unused but is intended for making update messages. | ||
287 | .Pp | ||
288 | The | ||
289 | .Fn res_send | ||
290 | routine sends a pre-formatted query and returns an answer. | ||
291 | It will call | ||
292 | .Fn res_init | ||
293 | if | ||
294 | .Dv RES_INIT | ||
295 | is not set, send the query to the local name server, and | ||
296 | handle timeouts and retries. | ||
297 | The length of the reply message is returned, or \-1 if there were errors. | ||
298 | .Pp | ||
299 | The | ||
300 | .Fn dn_comp | ||
301 | function compresses the domain name | ||
302 | .Fa exp_dn | ||
303 | and stores it in | ||
304 | .Fa comp_dn . | ||
305 | The size of the compressed name is returned or \-1 if there were errors. | ||
306 | The size of the array pointed to by | ||
307 | .Fa comp_dn | ||
308 | is given by | ||
309 | .Fa length . | ||
310 | The compression uses an array of pointers | ||
311 | .Fa dnptrs | ||
312 | to previously compressed names in the current message. | ||
313 | The first pointer points | ||
314 | to the beginning of the message and the list ends with | ||
315 | .Dv NULL . | ||
316 | The limit to the array is specified by | ||
317 | .Fa lastdnptr . | ||
318 | A side effect of | ||
319 | .Fn dn_comp | ||
320 | is to update the list of pointers for labels inserted into the message | ||
321 | as the name is compressed. | ||
322 | If | ||
323 | .Fa dnptrs | ||
324 | is | ||
325 | .Dv NULL , | ||
326 | names are not compressed. | ||
327 | If | ||
328 | .Fa lastdnptr | ||
329 | is | ||
330 | .Dv NULL , | ||
331 | the list of labels is not updated. | ||
332 | .Pp | ||
333 | The | ||
334 | .Fn dn_expand | ||
335 | entry expands the compressed domain name | ||
336 | .Fa comp_dn | ||
337 | to a full domain name. | ||
338 | The compressed name is contained in a query or reply message; | ||
339 | .Fa msg | ||
340 | is a pointer to the beginning of the message. | ||
341 | The uncompressed name is placed in the buffer indicated by | ||
342 | .Fa exp_dn | ||
343 | which is of size | ||
344 | .Fa length . | ||
345 | The size of compressed name is returned or \-1 if there was an error. | ||
346 | .Sh FILES | ||
347 | .Bl -tag -width "/etc/resolv.confXX" | ||
348 | .It Pa /etc/resolv.conf | ||
349 | The configuration file. | ||
350 | .El | ||
351 | .Sh SEE ALSO | ||
352 | .Xr gethostbyname 3 , | ||
353 | .Xr resolv.conf 5 , | ||
354 | .Xr hostname 7 , | ||
355 | .Xr named 8 | ||
356 | .Rs | ||
357 | .%T Name Server Operations Guide for BIND | ||
358 | .Re | ||
359 | .Sh STANDARDS | ||
360 | .Rs | ||
361 | .%A M. Stahl | ||
362 | .%D November 1987 | ||
363 | .%R RFC 1032 | ||
364 | .%T Domain Administrators Guide | ||
365 | .Re | ||
366 | .Pp | ||
367 | .Rs | ||
368 | .%A M. Lottor | ||
369 | .%D November 1987 | ||
370 | .%R RFC 1033 | ||
371 | .%T Domain Administrators Operations Guide | ||
372 | .Re | ||
373 | .Pp | ||
374 | .Rs | ||
375 | .%A P. Mockapetris | ||
376 | .%D November 1987 | ||
377 | .%R RFC 1034 | ||
378 | .%T Domain Names \(en Concepts and Facilities | ||
379 | .Re | ||
380 | .Pp | ||
381 | .Rs | ||
382 | .%A P. Mockapetris | ||
383 | .%D November 1987 | ||
384 | .%R RFC 1035 | ||
385 | .%T Domain Names \(en Implementation and Specification | ||
386 | .Re | ||
387 | .Pp | ||
388 | .Rs | ||
389 | .%A J. Klensin | ||
390 | .%D October 2008 | ||
391 | .%R RFC 5321 | ||
392 | .%T Simple Mail Transfer Protocol | ||
393 | .Re | ||
394 | .Sh HISTORY | ||
395 | The | ||
396 | .Nm | ||
397 | function appeared in | ||
398 | .Bx 4.3 . | ||