]>
Commit | Line | Data |
---|---|---|
28f540f4 | 1 | /* |
e685e07d | 2 | * Copyright (c) 1983, 1987, 1989 |
28f540f4 | 3 | * The Regents of the University of California. All rights reserved. |
835bf8e0 | 4 | * |
28f540f4 RM |
5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions | |
7 | * are met: | |
8 | * 1. Redistributions of source code must retain the above copyright | |
9 | * notice, this list of conditions and the following disclaimer. | |
10 | * 2. Redistributions in binary form must reproduce the above copyright | |
11 | * notice, this list of conditions and the following disclaimer in the | |
12 | * documentation and/or other materials provided with the distribution. | |
28f540f4 RM |
13 | * 4. Neither the name of the University nor the names of its contributors |
14 | * may be used to endorse or promote products derived from this software | |
15 | * without specific prior written permission. | |
835bf8e0 | 16 | * |
28f540f4 RM |
17 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND |
18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | |
21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
27 | * SUCH DAMAGE. | |
28f540f4 RM |
28 | */ |
29 | ||
b43b13ac UD |
30 | /* |
31 | * Portions Copyright (c) 1996-1999 by Internet Software Consortium. | |
32 | * | |
33 | * Permission to use, copy, modify, and distribute this software for any | |
34 | * purpose with or without fee is hereby granted, provided that the above | |
35 | * copyright notice and this permission notice appear in all copies. | |
36 | * | |
37 | * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS | |
38 | * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES | |
39 | * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE | |
40 | * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL | |
41 | * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR | |
42 | * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS | |
43 | * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS | |
44 | * SOFTWARE. | |
45 | */ | |
46 | ||
28f540f4 RM |
47 | /* |
48 | * @(#)resolv.h 8.1 (Berkeley) 6/2/93 | |
e685e07d | 49 | * $BINDId: resolv.h,v 8.31 2000/03/30 20:16:50 vixie Exp $ |
28f540f4 RM |
50 | */ |
51 | ||
e685e07d | 52 | #ifndef _RESOLV_H_ |
64ca3f32 RM |
53 | |
54 | /* These headers are needed for types used in the `struct res_state' | |
55 | declaration. */ | |
56 | #include <sys/types.h> | |
57 | #include <netinet/in.h> | |
58 | ||
535b764d UD |
59 | #ifndef __need_res_state |
60 | # define _RESOLV_H_ | |
a5a0310d | 61 | |
535b764d | 62 | # include <sys/param.h> |
535b764d UD |
63 | # include <sys/cdefs.h> |
64 | # include <stdio.h> | |
65 | # include <arpa/nameser.h> | |
28f540f4 | 66 | #endif |
e685e07d | 67 | |
535b764d UD |
68 | #ifndef __res_state_defined |
69 | # define __res_state_defined | |
28f540f4 RM |
70 | |
71 | /* | |
72 | * Global defines and variables for resolver stub. | |
73 | */ | |
535b764d UD |
74 | # define MAXNS 3 /* max # name servers we'll track */ |
75 | # define MAXDFLSRCH 3 /* # default domain levels to try */ | |
76 | # define MAXDNSRCH 6 /* max # domains in search path */ | |
77 | # define LOCALDOMAINPARTS 2 /* min levels in name that is "local" */ | |
28f540f4 | 78 | |
535b764d UD |
79 | # define RES_TIMEOUT 5 /* min. seconds between retries */ |
80 | # define MAXRESOLVSORT 10 /* number of net to sort on */ | |
81 | # define RES_MAXNDOTS 15 /* should reflect bit field size */ | |
82 | # define RES_MAXRETRANS 30 /* only for resolv.conf/RES_OPTIONS */ | |
83 | # define RES_MAXRETRY 5 /* only for resolv.conf/RES_OPTIONS */ | |
84 | # define RES_DFLRETRY 2 /* Default #/tries. */ | |
85 | # define RES_MAXTIME 65535 /* Infinity, in milliseconds. */ | |
28f540f4 RM |
86 | |
87 | struct __res_state { | |
f87dfb1f | 88 | int retrans; /* retransmition time interval */ |
28f540f4 | 89 | int retry; /* number of times to retransmit */ |
11160cb7 | 90 | unsigned long options; /* option flags - see below. */ |
28f540f4 RM |
91 | int nscount; /* number of name servers */ |
92 | struct sockaddr_in | |
93 | nsaddr_list[MAXNS]; /* address of name server */ | |
535b764d | 94 | # define nsaddr nsaddr_list[0] /* for backward compatibility */ |
11160cb7 | 95 | unsigned short id; /* current message id */ |
ae1ad3ae | 96 | /* 2 byte hole here. */ |
28f540f4 | 97 | char *dnsrch[MAXDNSRCH+1]; /* components of domain to search */ |
845dcb57 | 98 | char defdname[256]; /* default domain (deprecated) */ |
11160cb7 | 99 | unsigned long pfcode; /* RES_PRF_ flags - see below. */ |
28f540f4 RM |
100 | unsigned ndots:4; /* threshold for initial abs. query */ |
101 | unsigned nsort:4; /* number of elements in sort_list[] */ | |
ae1ad3ae UD |
102 | unsigned ipv6_unavail:1; /* connecting to IPv6 server failed */ |
103 | unsigned unused:23; | |
28f540f4 RM |
104 | struct { |
105 | struct in_addr addr; | |
11160cb7 | 106 | uint32_t mask; |
28f540f4 | 107 | } sort_list[MAXRESOLVSORT]; |
ae1ad3ae | 108 | /* 4 byte hole here on 64-bit architectures. */ |
6815a33d FW |
109 | void * __glibc_unused_qhook; |
110 | void * __glibc_unused_rhook; | |
b43b13ac | 111 | int res_h_errno; /* last one set for this context */ |
e685e07d | 112 | int _vcsock; /* PRIVATE: for res_send VC i/o */ |
11160cb7 | 113 | unsigned int _flags; /* PRIVATE: see below */ |
ae1ad3ae | 114 | /* 4 byte hole here on 64-bit architectures. */ |
e685e07d UD |
115 | union { |
116 | char pad[52]; /* On an i386 this means 512b total. */ | |
117 | struct { | |
11160cb7 ZW |
118 | uint16_t nscount; |
119 | uint16_t nsmap[MAXNS]; | |
e685e07d | 120 | int nssocks[MAXNS]; |
11160cb7 ZW |
121 | uint16_t nscount6; |
122 | uint16_t nsinit; | |
438e8239 | 123 | struct sockaddr_in6 *nsaddrs[MAXNS]; |
87bb6b6c UD |
124 | #ifdef _LIBC |
125 | unsigned long long int initstamp | |
126 | __attribute__((packed)); | |
127 | #else | |
128 | unsigned int _initstamp[2]; | |
129 | #endif | |
e685e07d UD |
130 | } _ext; |
131 | } _u; | |
28f540f4 RM |
132 | }; |
133 | ||
b43b13ac | 134 | typedef struct __res_state *res_state; |
535b764d UD |
135 | # undef __need_res_state |
136 | #endif | |
137 | ||
138 | #ifdef _RESOLV_H_ | |
139 | /* | |
140 | * Revision information. This is the release date in YYYYMMDD format. | |
141 | * It can change every day so the right thing to do with it is use it | |
142 | * in preprocessor commands such as "#if (__RES > 19931104)". Do not | |
143 | * compare for equality; rather, use it to determine whether your resolver | |
144 | * is new enough to contain a certain feature. | |
145 | */ | |
146 | ||
147 | #define __RES 19991006 | |
148 | ||
149 | /* | |
150 | * Resolver configuration file. | |
151 | * Normally not present, but may contain the address of the | |
152 | * inital name server(s) to query and the domain search list. | |
153 | */ | |
154 | ||
155 | #ifndef _PATH_RESCONF | |
156 | #define _PATH_RESCONF "/etc/resolv.conf" | |
157 | #endif | |
158 | ||
159 | struct res_sym { | |
160 | int number; /* Identifying number, like T_MX */ | |
161 | char * name; /* Its symbolic name, like "MX" */ | |
162 | char * humanname; /* Its fun name, like "mail exchanger" */ | |
163 | }; | |
b43b13ac UD |
164 | |
165 | /* | |
166 | * Resolver flags (used to be discrete per-module statics ints). | |
167 | */ | |
168 | #define RES_F_VC 0x00000001 /* socket is TCP */ | |
169 | #define RES_F_CONN 0x00000002 /* socket is connected */ | |
2bbb7d5b | 170 | #define RES_F_EDNS0ERR 0x00000004 /* EDNS0 caused errors */ |
b43b13ac UD |
171 | |
172 | /* res_findzonecut() options */ | |
173 | #define RES_EXHAUSTIVE 0x00000001 /* always do all queries */ | |
174 | ||
28f540f4 RM |
175 | /* |
176 | * Resolver options (keep these in synch with res_debug.c, please) | |
177 | */ | |
178 | #define RES_INIT 0x00000001 /* address initialized */ | |
179 | #define RES_DEBUG 0x00000002 /* print debug messages */ | |
bfbd1de1 FW |
180 | #define RES_AAONLY \ |
181 | __glibc_macro_warning ("RES_AAONLY is deprecated") 0x00000004 | |
28f540f4 | 182 | #define RES_USEVC 0x00000008 /* use virtual circuit */ |
bfbd1de1 FW |
183 | #define RES_PRIMARY \ |
184 | __glibc_macro_warning ("RES_PRIMARY is deprecated") 0x00000010 | |
28f540f4 RM |
185 | #define RES_IGNTC 0x00000020 /* ignore trucation errors */ |
186 | #define RES_RECURSE 0x00000040 /* recursion desired */ | |
187 | #define RES_DEFNAMES 0x00000080 /* use default domain name */ | |
188 | #define RES_STAYOPEN 0x00000100 /* Keep TCP socket open */ | |
189 | #define RES_DNSRCH 0x00000200 /* search up local domain tree */ | |
190 | #define RES_INSECURE1 0x00000400 /* type 1 security disabled */ | |
191 | #define RES_INSECURE2 0x00000800 /* type 2 security disabled */ | |
3d61b63c | 192 | #define RES_NOALIASES 0x00001000 /* shuts off HOSTALIASES feature */ |
fa0bc87c | 193 | #define RES_USE_INET6 0x00002000 /* use/map IPv6 in gethostbyname() */ |
b43b13ac | 194 | #define RES_ROTATE 0x00004000 /* rotate ns list after each query */ |
bfbd1de1 FW |
195 | #define RES_NOCHECKNAME \ |
196 | __glibc_macro_warning ("RES_NOCHECKNAME is deprecated") 0x00008000 | |
197 | #define RES_KEEPTSIG \ | |
198 | __glibc_macro_warning ("RES_KEEPTSIG is deprecated") 0x00010000 | |
e685e07d | 199 | #define RES_BLAST 0x00020000 /* blast all recursive servers */ |
ee778b56 UD |
200 | #define RES_USEBSTRING 0x00040000 /* IPv6 reverse lookup with byte |
201 | strings */ | |
340ef046 UD |
202 | #define RES_NOIP6DOTINT 0x00080000 /* Do not use .ip6.int in IPv6 |
203 | reverse lookup */ | |
2bbb7d5b | 204 | #define RES_USE_EDNS0 0x00100000 /* Use EDNS0. */ |
ae061910 | 205 | #define RES_SNGLKUP 0x00200000 /* one outstanding request at a time */ |
44d20bca UD |
206 | #define RES_SNGLKUPREOP 0x00400000 /* -"-, but open new socket for each |
207 | request */ | |
2d0671cb | 208 | #define RES_USE_DNSSEC 0x00800000 /* use DNSSEC using OK bit in OPT */ |
f87dfb1f UD |
209 | #define RES_NOTLDQUERY 0x01000000 /* Do not look up unqualified name |
210 | as a TLD. */ | |
28f540f4 | 211 | |
0acb7b83 | 212 | #define RES_DEFAULT (RES_RECURSE|RES_DEFNAMES|RES_DNSRCH|RES_NOIP6DOTINT) |
28f540f4 RM |
213 | |
214 | /* | |
215 | * Resolver "pfcode" values. Used by dig. | |
216 | */ | |
217 | #define RES_PRF_STATS 0x00000001 | |
b43b13ac | 218 | #define RES_PRF_UPDATE 0x00000002 |
e685e07d | 219 | #define RES_PRF_CLASS 0x00000004 |
28f540f4 RM |
220 | #define RES_PRF_CMD 0x00000008 |
221 | #define RES_PRF_QUES 0x00000010 | |
222 | #define RES_PRF_ANS 0x00000020 | |
223 | #define RES_PRF_AUTH 0x00000040 | |
224 | #define RES_PRF_ADD 0x00000080 | |
225 | #define RES_PRF_HEAD1 0x00000100 | |
226 | #define RES_PRF_HEAD2 0x00000200 | |
227 | #define RES_PRF_TTLID 0x00000400 | |
228 | #define RES_PRF_HEADX 0x00000800 | |
229 | #define RES_PRF_QUERY 0x00001000 | |
230 | #define RES_PRF_REPLY 0x00002000 | |
b43b13ac | 231 | #define RES_PRF_INIT 0x00004000 |
28f540f4 RM |
232 | /* 0x00008000 */ |
233 | ||
b43b13ac | 234 | /* Things involving an internal (static) resolver context. */ |
835bf8e0 | 235 | __BEGIN_DECLS |
f14273c5 | 236 | extern struct __res_state *__res_state(void) __attribute__ ((__const__)); |
835bf8e0 | 237 | __END_DECLS |
e685e07d | 238 | #define _res (*__res_state()) |
fdacb17d | 239 | |
b43b13ac UD |
240 | #define fp_nquery __fp_nquery |
241 | #define fp_query __fp_query | |
242 | #define hostalias __hostalias | |
243 | #define p_query __p_query | |
244 | #define res_close __res_close | |
e685e07d | 245 | #define res_init __res_init |
b43b13ac | 246 | #define res_isourserver __res_isourserver |
e685e07d UD |
247 | #define res_mkquery __res_mkquery |
248 | #define res_query __res_query | |
249 | #define res_querydomain __res_querydomain | |
250 | #define res_search __res_search | |
b43b13ac | 251 | #define res_send __res_send |
28f540f4 | 252 | |
b43b13ac | 253 | __BEGIN_DECLS |
11160cb7 ZW |
254 | void fp_nquery (const unsigned char *, int, FILE *) __THROW; |
255 | void fp_query (const unsigned char *, FILE *) __THROW; | |
79937577 | 256 | const char * hostalias (const char *) __THROW; |
11160cb7 | 257 | void p_query (const unsigned char *) __THROW; |
79937577 UD |
258 | void res_close (void) __THROW; |
259 | int res_init (void) __THROW; | |
260 | int res_isourserver (const struct sockaddr_in *) __THROW; | |
11160cb7 ZW |
261 | int res_mkquery (int, const char *, int, int, |
262 | const unsigned char *, int, const unsigned char *, | |
263 | unsigned char *, int) __THROW; | |
264 | int res_query (const char *, int, int, unsigned char *, int) | |
265 | __THROW; | |
79937577 | 266 | int res_querydomain (const char *, const char *, int, int, |
11160cb7 ZW |
267 | unsigned char *, int) __THROW; |
268 | int res_search (const char *, int, int, unsigned char *, int) | |
269 | __THROW; | |
270 | int res_send (const unsigned char *, int, unsigned char *, int) | |
271 | __THROW; | |
b43b13ac | 272 | __END_DECLS |
df21c858 | 273 | |
b43b13ac UD |
274 | #define b64_ntop __b64_ntop |
275 | #define b64_pton __b64_pton | |
276 | #define dn_comp __dn_comp | |
277 | #define dn_count_labels __dn_count_labels | |
e685e07d | 278 | #define dn_expand __dn_expand |
b43b13ac UD |
279 | #define dn_skipname __dn_skipname |
280 | #define fp_resstat __fp_resstat | |
281 | #define loc_aton __loc_aton | |
282 | #define loc_ntoa __loc_ntoa | |
283 | #define p_cdname __p_cdname | |
284 | #define p_cdnname __p_cdnname | |
285 | #define p_class __p_class | |
286 | #define p_fqname __p_fqname | |
287 | #define p_fqnname __p_fqnname | |
288 | #define p_option __p_option | |
289 | #define p_secstodate __p_secstodate | |
290 | #define p_section __p_section | |
291 | #define p_time __p_time | |
292 | #define p_type __p_type | |
293 | #define p_rcode __p_rcode | |
294 | #define putlong __putlong | |
295 | #define putshort __putshort | |
296 | #define res_dnok __res_dnok | |
b43b13ac UD |
297 | #define res_hnok __res_hnok |
298 | #define res_hostalias __res_hostalias | |
299 | #define res_mailok __res_mailok | |
300 | #define res_nameinquery __res_nameinquery | |
301 | #define res_nclose __res_nclose | |
302 | #define res_ninit __res_ninit | |
303 | #define res_nmkquery __res_nmkquery | |
304 | #define res_npquery __res_npquery | |
305 | #define res_nquery __res_nquery | |
306 | #define res_nquerydomain __res_nquerydomain | |
307 | #define res_nsearch __res_nsearch | |
308 | #define res_nsend __res_nsend | |
309 | #define res_nisourserver __res_nisourserver | |
310 | #define res_ownok __res_ownok | |
311 | #define res_queriesmatch __res_queriesmatch | |
312 | #define res_randomid __res_randomid | |
313 | #define sym_ntop __sym_ntop | |
314 | #define sym_ntos __sym_ntos | |
315 | #define sym_ston __sym_ston | |
28f540f4 | 316 | __BEGIN_DECLS |
79937577 UD |
317 | int res_hnok (const char *) __THROW; |
318 | int res_ownok (const char *) __THROW; | |
319 | int res_mailok (const char *) __THROW; | |
320 | int res_dnok (const char *) __THROW; | |
321 | int sym_ston (const struct res_sym *, const char *, int *) __THROW; | |
322 | const char * sym_ntos (const struct res_sym *, int, int *) __THROW; | |
323 | const char * sym_ntop (const struct res_sym *, int, int *) __THROW; | |
11160cb7 ZW |
324 | int b64_ntop (const unsigned char *, size_t, char *, size_t) |
325 | __THROW; | |
326 | int b64_pton (char const *, unsigned char *, size_t) __THROW; | |
327 | int loc_aton (const char *__ascii, unsigned char *__binary) __THROW; | |
328 | const char * loc_ntoa (const unsigned char *__binary, char *__ascii) __THROW; | |
329 | int dn_skipname (const unsigned char *, const unsigned char *) | |
330 | __THROW; | |
331 | void putlong (uint32_t, unsigned char *) __THROW; | |
332 | void putshort (uint16_t, unsigned char *) __THROW; | |
79937577 | 333 | const char * p_class (int) __THROW; |
11160cb7 | 334 | const char * p_time (uint32_t) __THROW; |
79937577 UD |
335 | const char * p_type (int) __THROW; |
336 | const char * p_rcode (int) __THROW; | |
11160cb7 ZW |
337 | const unsigned char * p_cdnname (const unsigned char *, |
338 | const unsigned char *, int, FILE *) __THROW; | |
339 | const unsigned char * p_cdname (const unsigned char *, const unsigned char *, | |
340 | FILE *) __THROW; | |
341 | const unsigned char * p_fqnname (const unsigned char *__cp, | |
342 | const unsigned char *__msg, | |
343 | int, char *, int) __THROW; | |
344 | const unsigned char * p_fqname (const unsigned char *, | |
345 | const unsigned char *, FILE *) __THROW; | |
346 | const char * p_option (unsigned long __option) __THROW; | |
347 | char * p_secstodate (unsigned long) __THROW; | |
79937577 | 348 | int dn_count_labels (const char *) __THROW; |
11160cb7 ZW |
349 | int dn_comp (const char *, unsigned char *, int, unsigned char **, |
350 | unsigned char **) __THROW; | |
351 | int dn_expand (const unsigned char *, const unsigned char *, | |
352 | const unsigned char *, char *, int) __THROW; | |
353 | unsigned int res_randomid (void) __THROW; | |
79937577 | 354 | int res_nameinquery (const char *, int, int, |
11160cb7 ZW |
355 | const unsigned char *, |
356 | const unsigned char *) __THROW; | |
357 | int res_queriesmatch (const unsigned char *, | |
358 | const unsigned char *, | |
359 | const unsigned char *, | |
360 | const unsigned char *) __THROW; | |
d82a27f8 | 361 | const char * p_section (int __section, int __opcode) __THROW; |
b43b13ac | 362 | /* Things involving a resolver context. */ |
79937577 UD |
363 | int res_ninit (res_state) __THROW; |
364 | int res_nisourserver (const res_state, | |
365 | const struct sockaddr_in *) __THROW; | |
366 | void fp_resstat (const res_state, FILE *) __THROW; | |
11160cb7 ZW |
367 | void res_npquery (const res_state, const unsigned char *, int, |
368 | FILE *) __THROW; | |
79937577 UD |
369 | const char * res_hostalias (const res_state, const char *, char *, size_t) |
370 | __THROW; | |
11160cb7 ZW |
371 | int res_nquery (res_state, const char *, int, int, |
372 | unsigned char *, int) __THROW; | |
373 | int res_nsearch (res_state, const char *, int, int, | |
374 | unsigned char *, int) __THROW; | |
79937577 | 375 | int res_nquerydomain (res_state, const char *, const char *, int, |
11160cb7 | 376 | int, unsigned char *, int) __THROW; |
79937577 | 377 | int res_nmkquery (res_state, int, const char *, int, int, |
11160cb7 ZW |
378 | const unsigned char *, int, |
379 | const unsigned char *, unsigned char *, int) | |
79937577 | 380 | __THROW; |
11160cb7 ZW |
381 | int res_nsend (res_state, const unsigned char *, int, |
382 | unsigned char *, int) __THROW; | |
79937577 | 383 | void res_nclose (res_state) __THROW; |
28f540f4 | 384 | __END_DECLS |
535b764d | 385 | #endif |
28f540f4 | 386 | |
b43b13ac | 387 | #endif /* !_RESOLV_H_ */ |