diff options
author | deraadt <> | 1995-10-18 08:42:23 +0000 |
---|---|---|
committer | deraadt <> | 1995-10-18 08:42:23 +0000 |
commit | 0527d29da443886d92e9a418180c5b25a5f8d270 (patch) | |
tree | 86b3a64928451a669cefa27900e5884036b4e349 /src/lib/libc/net/resolver.3 | |
download | openbsd-0527d29da443886d92e9a418180c5b25a5f8d270.tar.gz openbsd-0527d29da443886d92e9a418180c5b25a5f8d270.tar.bz2 openbsd-0527d29da443886d92e9a418180c5b25a5f8d270.zip |
initial import of NetBSD tree
Diffstat (limited to 'src/lib/libc/net/resolver.3')
-rw-r--r-- | src/lib/libc/net/resolver.3 | 344 |
1 files changed, 344 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..99abe17f03 --- /dev/null +++ b/src/lib/libc/net/resolver.3 | |||
@@ -0,0 +1,344 @@ | |||
1 | .\" $NetBSD: resolver.3,v 1.5 1995/02/25 06:21:02 cgd 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. All advertising materials mentioning features or use of this software | ||
15 | .\" must display the following acknowledgement: | ||
16 | .\" This product includes software developed by the University of | ||
17 | .\" California, Berkeley and its contributors. | ||
18 | .\" 4. Neither the name of the University nor the names of its contributors | ||
19 | .\" may be used to endorse or promote products derived from this software | ||
20 | .\" without specific prior written permission. | ||
21 | .\" | ||
22 | .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | ||
23 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
24 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
25 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | ||
26 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
27 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
28 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
29 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
30 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
31 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
32 | .\" SUCH DAMAGE. | ||
33 | .\" | ||
34 | .\" @(#)resolver.3 8.1 (Berkeley) 6/4/93 | ||
35 | .\" | ||
36 | .Dd June 4, 1993 | ||
37 | .Dt RESOLVER 3 | ||
38 | .Os BSD 4.3 | ||
39 | .Sh NAME | ||
40 | .Nm res_query , | ||
41 | .Nm res_search , | ||
42 | .Nm res_mkquery , | ||
43 | .Nm res_send , | ||
44 | .Nm res_init , | ||
45 | .Nm dn_comp , | ||
46 | .Nm dn_expand | ||
47 | .Nd resolver routines | ||
48 | .Sh SYNOPSIS | ||
49 | .Fd #include <sys/types.h> | ||
50 | .Fd #include <netinet/in.h> | ||
51 | .Fd #include <arpa/nameser.h> | ||
52 | .Fd #include <resolv.h> | ||
53 | .Fo res_query | ||
54 | .Fa "char *dname" | ||
55 | .Fa "int class" | ||
56 | .Fa "int type" | ||
57 | .Fa "u_char *answer" | ||
58 | .Fa "int anslen" | ||
59 | .Fc | ||
60 | .Fo res_search | ||
61 | .Fa "char *dname" | ||
62 | .Fa "int class" | ||
63 | .Fa "int type" | ||
64 | .Fa "u_char *answer" | ||
65 | .Fa "int anslen" | ||
66 | .Fc | ||
67 | .Fo res_mkquery | ||
68 | .Fa "int op" | ||
69 | .Fa "char *dname" | ||
70 | .Fa "int class" | ||
71 | .Fa "int type" | ||
72 | .Fa "char *data" | ||
73 | .Fa "int datalen" | ||
74 | .Fa "struct rrec *newrr" | ||
75 | .Fa "char *buf" | ||
76 | .Fa "int buflen" | ||
77 | .Fc | ||
78 | .Fo res_send | ||
79 | .Fa "char *msg" | ||
80 | .Fa "int msglen" | ||
81 | .Fa "char *answer" | ||
82 | .Fa "int anslen" | ||
83 | .Fc | ||
84 | .Fn res_init | ||
85 | .Fo dn_comp | ||
86 | .Fa "char *exp_dn" | ||
87 | .Fa "char *comp_dn" | ||
88 | .Fa "int length" | ||
89 | .Fa "char **dnptrs" | ||
90 | .Fa "char **lastdnptr" | ||
91 | .Fc | ||
92 | .Fo dn_expand | ||
93 | .Fa "u_char *msg" | ||
94 | .Fa "u_char *eomorig" | ||
95 | .Fa "u_char *comp_dn" | ||
96 | .Fa "u_char *exp_dn" | ||
97 | .Fa "int length" | ||
98 | .Fc | ||
99 | .Sh DESCRIPTION | ||
100 | These routines are used for making, sending and interpreting | ||
101 | query and reply messages with Internet domain name servers. | ||
102 | .Pp | ||
103 | Global configuration and state information that is used by the | ||
104 | resolver routines is kept in the structure | ||
105 | .Em _res . | ||
106 | Most of the values have reasonable defaults and can be ignored. | ||
107 | Options | ||
108 | stored in | ||
109 | .Em _res.options | ||
110 | are defined in | ||
111 | .Pa 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_DEFNAMES | ||
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 | .It Dv RES_AAONLY | ||
124 | Accept authoritative answers only. | ||
125 | With this option, | ||
126 | .Fn res_send | ||
127 | should continue until it finds an authoritative answer or finds an error. | ||
128 | Currently this is not implemented. | ||
129 | .It Dv RES_USEVC | ||
130 | Use | ||
131 | .Tn TCP | ||
132 | connections for queries instead of | ||
133 | .Tn UDP | ||
134 | datagrams. | ||
135 | .It Dv RES_STAYOPEN | ||
136 | Used with | ||
137 | .Dv RES_USEVC | ||
138 | to keep the | ||
139 | .Tn TCP | ||
140 | connection open between | ||
141 | queries. | ||
142 | This is useful only in programs that regularly do many queries. | ||
143 | .Tn UDP | ||
144 | should be the normal mode used. | ||
145 | .It Dv RES_IGNTC | ||
146 | Unused currently (ignore truncation errors, i.e., don't retry with | ||
147 | .Tn TCP ) . | ||
148 | .It Dv RES_RECURSE | ||
149 | Set the recursion-desired bit in queries. | ||
150 | This is the default. | ||
151 | .Pf ( Fn res_send | ||
152 | does not do iterative queries and expects the name server | ||
153 | to handle recursion.) | ||
154 | .It Dv RES_DEFNAMES | ||
155 | If set, | ||
156 | .Fn res_search | ||
157 | will append the default domain name to single-component names | ||
158 | (those that do not contain a dot). | ||
159 | This option is enabled by default. | ||
160 | .It Dv RES_DNSRCH | ||
161 | If this option is set, | ||
162 | .Fn res_search | ||
163 | will search for host names in the current domain and in parent domains; see | ||
164 | .Xr hostname 7 . | ||
165 | This is used by the standard host lookup routine | ||
166 | .Xr gethostbyname 3 . | ||
167 | This option is enabled by default. | ||
168 | .El | ||
169 | .Pp | ||
170 | The | ||
171 | .Fn res_init | ||
172 | routine | ||
173 | reads the configuration file (if any; see | ||
174 | .Xr resolv.conf 5 ) | ||
175 | to get the default domain name, | ||
176 | search list and | ||
177 | the Internet address of the local name server(s). | ||
178 | If no server is configured, the host running | ||
179 | the resolver is tried. | ||
180 | The current domain name is defined by the hostname | ||
181 | if not specified in the configuration file; | ||
182 | it can be overridden by the environment variable | ||
183 | .Ev LOCALDOMAIN . | ||
184 | This environment variable may contain several blank-separated | ||
185 | tokens if you wish to override the | ||
186 | .Fa search list | ||
187 | on a per-process basis. | ||
188 | This is similar to the | ||
189 | .Fa search | ||
190 | command in the configuration file. | ||
191 | Another environment variable | ||
192 | .Ev RES_OPTIONS | ||
193 | can be set to override certain internal resolver options which | ||
194 | are otherwise set by changing fields in the | ||
195 | .Fa _res | ||
196 | structure or are inherited from the configuration file's | ||
197 | .Fa options | ||
198 | command. | ||
199 | The syntax of the | ||
200 | .Ev RES_OPTIONS | ||
201 | environment variable is explained in | ||
202 | .Xr resolv.conf 5 . | ||
203 | Initialization normally occurs on the first call | ||
204 | to one of the following routines. | ||
205 | .Pp | ||
206 | The | ||
207 | .Fn res_query | ||
208 | function provides an interface to the server query mechanism. | ||
209 | It constructs a query, sends it to the local server, | ||
210 | awaits a response, and makes preliminary checks on the reply. | ||
211 | The query requests information of the specified | ||
212 | .Fa type | ||
213 | and | ||
214 | .Fa class | ||
215 | for the specified fully-qualified domain name | ||
216 | .Fa dname . | ||
217 | The reply message is left in the | ||
218 | .Fa answer | ||
219 | buffer with length | ||
220 | .Fa anslen | ||
221 | supplied by the caller. | ||
222 | .Pp | ||
223 | The | ||
224 | .Fn res_search | ||
225 | routine makes a query and awaits a response like | ||
226 | .Fn res_query , | ||
227 | but in addition, it implements the default and search rules | ||
228 | controlled by the | ||
229 | .Dv RES_DEFNAMES | ||
230 | and | ||
231 | .Dv RES_DNSRCH | ||
232 | options. | ||
233 | It returns the first successful reply. | ||
234 | .Pp | ||
235 | The remaining routines are lower-level routines used by | ||
236 | .Fn res_query . | ||
237 | The | ||
238 | .Fn res_mkquery | ||
239 | function | ||
240 | constructs a standard query message and places it in | ||
241 | .Fa buf . | ||
242 | It returns the size of the query, or \-1 if the query is | ||
243 | larger than | ||
244 | .Fa buflen . | ||
245 | The query type | ||
246 | .Fa op | ||
247 | is usually | ||
248 | .Dv QUERY , | ||
249 | but can be any of the query types defined in | ||
250 | .Aq Pa arpa/nameser.h . | ||
251 | The domain name for the query is given by | ||
252 | .Fa dname . | ||
253 | .Fa Newrr | ||
254 | is currently unused but is intended for making update messages. | ||
255 | .Pp | ||
256 | The | ||
257 | .Fn res_send | ||
258 | routine | ||
259 | sends a pre-formatted query and returns an answer. | ||
260 | It will call | ||
261 | .Fn res_init | ||
262 | if | ||
263 | .Dv RES_INIT | ||
264 | is not set, send the query to the local name server, and | ||
265 | handle timeouts and retries. | ||
266 | The length of the reply message is returned, or | ||
267 | \-1 if there were errors. | ||
268 | .Pp | ||
269 | The | ||
270 | .Fn dn_comp | ||
271 | function | ||
272 | compresses the domain name | ||
273 | .Fa exp_dn | ||
274 | and stores it in | ||
275 | .Fa comp_dn . | ||
276 | The size of the compressed name is returned or \-1 if there were errors. | ||
277 | The size of the array pointed to by | ||
278 | .Fa comp_dn | ||
279 | is given by | ||
280 | .Fa length . | ||
281 | The compression uses | ||
282 | an array of pointers | ||
283 | .Fa dnptrs | ||
284 | to previously-compressed names in the current message. | ||
285 | The first pointer points to | ||
286 | to the beginning of the message and the list ends with | ||
287 | .Dv NULL . | ||
288 | The limit to the array is specified by | ||
289 | .Fa lastdnptr . | ||
290 | A side effect of | ||
291 | .Fn dn_comp | ||
292 | is to update the list of pointers for | ||
293 | labels inserted into the message | ||
294 | as the name is compressed. | ||
295 | If | ||
296 | .Em dnptr | ||
297 | is | ||
298 | .Dv NULL, names are not compressed. | ||
299 | If | ||
300 | .Fa lastdnptr | ||
301 | is | ||
302 | .Dv NULL , | ||
303 | the list of labels is not updated. | ||
304 | .Pp | ||
305 | The | ||
306 | .Fn dn_expand | ||
307 | entry | ||
308 | expands the compressed domain name | ||
309 | .Fa comp_dn | ||
310 | to a full domain name | ||
311 | The compressed name is contained in a query or reply message; | ||
312 | .Fa msg | ||
313 | is a pointer to the beginning of the message. | ||
314 | The uncompressed name is placed in the buffer indicated by | ||
315 | .Fa exp_dn | ||
316 | which is of size | ||
317 | .Fa length . | ||
318 | The size of compressed name is returned or \-1 if there was an error. | ||
319 | .Sh FILES | ||
320 | .Bl -tag -width Pa | ||
321 | /etc/resolv.conf | ||
322 | The configuration file | ||
323 | see | ||
324 | .Xr resolv.conf 5 . | ||
325 | .El | ||
326 | .Sh SEE ALSO | ||
327 | .Xr gethostbyname 3 , | ||
328 | .Xr named 8 , | ||
329 | .Xr resolv.conf 5 , | ||
330 | .Xr hostname 7 , | ||
331 | .Pp | ||
332 | .%T RFC1032 , | ||
333 | .%T RFC1033 , | ||
334 | .%T RFC1034 , | ||
335 | .%T RFC1035 , | ||
336 | .%T RFC974 | ||
337 | .Rs | ||
338 | .%T "Name Server Operations Guide for BIND" | ||
339 | .Re | ||
340 | .Sh HISTORY | ||
341 | The | ||
342 | .Nm | ||
343 | function appeared in | ||
344 | .Bx 4.3 . | ||