1 | /* |
---|
2 | * Copyright (c) 1983, 1987, 1989 |
---|
3 | * The Regents of the University of California. All rights reserved. |
---|
4 | * |
---|
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. |
---|
13 | * 3. 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. |
---|
16 | * |
---|
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. |
---|
28 | */ |
---|
29 | |
---|
30 | /* |
---|
31 | * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") |
---|
32 | * Portions Copyright (c) 1996-1999 by Internet Software Consortium. |
---|
33 | * |
---|
34 | * Permission to use, copy, modify, and distribute this software for any |
---|
35 | * purpose with or without fee is hereby granted, provided that the above |
---|
36 | * copyright notice and this permission notice appear in all copies. |
---|
37 | * |
---|
38 | * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES |
---|
39 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
---|
40 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR |
---|
41 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
---|
42 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
---|
43 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT |
---|
44 | * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
---|
45 | */ |
---|
46 | |
---|
47 | /*% |
---|
48 | * @(#)resolv.h 8.1 (Berkeley) 6/2/93 |
---|
49 | * $FreeBSD: release/9.0.0/include/resolv.h 203964 2010-02-16 19:39:50Z imp $ |
---|
50 | */ |
---|
51 | |
---|
52 | #ifndef _RESOLV_H_ |
---|
53 | #define _RESOLV_H_ |
---|
54 | |
---|
55 | #include <sys/param.h> |
---|
56 | #include <sys/types.h> |
---|
57 | #include <sys/cdefs.h> |
---|
58 | #include <stdio.h> |
---|
59 | #include <netinet/in.h> /* struct in_addr */ |
---|
60 | |
---|
61 | /*% |
---|
62 | * Revision information. This is the release date in YYYYMMDD format. |
---|
63 | * It can change every day so the right thing to do with it is use it |
---|
64 | * in preprocessor commands such as "#if (__RES > 19931104)". Do not |
---|
65 | * compare for equality; rather, use it to determine whether your resolver |
---|
66 | * is new enough to contain a certain feature. |
---|
67 | */ |
---|
68 | |
---|
69 | #define __RES 19960801 |
---|
70 | |
---|
71 | /*% |
---|
72 | * This used to be defined in res_query.c, now it's in herror.c. It was |
---|
73 | * never extern'd by any *.h file before it was placed here. herror.c is |
---|
74 | * part of libresolv.a even though it might make more sense in libnetdb.a |
---|
75 | * or even libnet.a. |
---|
76 | */ |
---|
77 | |
---|
78 | extern int h_errno; |
---|
79 | |
---|
80 | /*% |
---|
81 | * Resolver configuration file. |
---|
82 | * Normally not present, but may contain the address of the |
---|
83 | * initial name server(s) to query and the domain search list. |
---|
84 | */ |
---|
85 | |
---|
86 | #ifndef _PATH_RESCONF |
---|
87 | #define _PATH_RESCONF "/etc/resolv.conf" |
---|
88 | #endif |
---|
89 | |
---|
90 | typedef enum { res_goahead, res_nextns, res_modified, res_done, res_error } |
---|
91 | res_sendhookact; |
---|
92 | |
---|
93 | typedef res_sendhookact (*res_send_qhook)(struct sockaddr_in * const *ns, |
---|
94 | const u_char **query, |
---|
95 | int *querylen, |
---|
96 | u_char *ans, |
---|
97 | int anssiz, |
---|
98 | int *resplen); |
---|
99 | |
---|
100 | typedef res_sendhookact (*res_send_rhook)(const struct sockaddr_in *ns, |
---|
101 | const u_char *query, |
---|
102 | int querylen, |
---|
103 | u_char *ans, |
---|
104 | int anssiz, |
---|
105 | int *resplen); |
---|
106 | |
---|
107 | struct res_sym { |
---|
108 | int number; /*%< Identifying number, like T_MX */ |
---|
109 | const char * name; /*%< Its symbolic name, like "MX" */ |
---|
110 | const char * humanname; /*%< Its fun name, like "mail exchanger" */ |
---|
111 | }; |
---|
112 | |
---|
113 | /*% |
---|
114 | * Global defines and variables for resolver stub. |
---|
115 | */ |
---|
116 | #define MAXNS 3 /*%< max # name servers we'll track */ |
---|
117 | #define MAXDFLSRCH 3 /*%< # default domain levels to try */ |
---|
118 | #define MAXDNSRCH 6 /*%< max # domains in search path */ |
---|
119 | #define LOCALDOMAINPARTS 2 /*%< min levels in name that is "local" */ |
---|
120 | #define RES_TIMEOUT 5 /*%< min. seconds between retries */ |
---|
121 | #define MAXRESOLVSORT 10 /*%< number of net to sort on */ |
---|
122 | #define RES_MAXNDOTS 15 /*%< should reflect bit field size */ |
---|
123 | |
---|
124 | struct __res_state { |
---|
125 | int retrans; /*%< retransmission time interval */ |
---|
126 | int retry; /*%< number of times to retransmit */ |
---|
127 | u_long options; /*%< option flags - see below. */ |
---|
128 | int nscount; /*%< number of name servers */ |
---|
129 | struct sockaddr_in |
---|
130 | nsaddr_list[MAXNS]; /*%< address of name server */ |
---|
131 | #define nsaddr nsaddr_list[0] /*%< for backward compatibility */ |
---|
132 | u_short id; /*%< current message id */ |
---|
133 | char *dnsrch[MAXDNSRCH+1]; /*%< components of domain to search */ |
---|
134 | char defdname[256]; /*%< default domain (deprecated) */ |
---|
135 | u_long pfcode; /*%< RES_PRF_ flags - see below. */ |
---|
136 | unsigned ndots:4; /*%< threshold for initial abs. query */ |
---|
137 | unsigned nsort:4; /*%< number of elements in sort_list[] */ |
---|
138 | char unused[3]; |
---|
139 | struct { |
---|
140 | struct in_addr addr; |
---|
141 | u_int32_t mask; |
---|
142 | } sort_list[MAXRESOLVSORT]; |
---|
143 | char pad[72]; /* on an i386 this means 512b total */ |
---|
144 | }; |
---|
145 | |
---|
146 | typedef struct __res_state *res_state; |
---|
147 | |
---|
148 | /*% |
---|
149 | * Resolver options (keep these in synch with res_debug.c, please) |
---|
150 | */ |
---|
151 | #define RES_INIT 0x00000001 /*%< address initialized */ |
---|
152 | #define RES_DEBUG 0x00000002 /*%< print debug messages */ |
---|
153 | #define RES_AAONLY 0x00000004 /*%< authoritative answers only (!IMPL)*/ |
---|
154 | #define RES_USEVC 0x00000008 /*%< use virtual circuit */ |
---|
155 | #define RES_PRIMARY 0x00000010 /*%< query primary server only (!IMPL) */ |
---|
156 | #define RES_IGNTC 0x00000020 /*%< ignore truncation errors */ |
---|
157 | #define RES_RECURSE 0x00000040 /*%< recursion desired */ |
---|
158 | #define RES_DEFNAMES 0x00000080 /*%< use default domain name */ |
---|
159 | #define RES_STAYOPEN 0x00000100 /*%< Keep TCP socket open */ |
---|
160 | #define RES_DNSRCH 0x00000200 /*%< search up local domain tree */ |
---|
161 | #define RES_INSECURE1 0x00000400 /*%< type 1 security disabled */ |
---|
162 | #define RES_INSECURE2 0x00000800 /*%< type 2 security disabled */ |
---|
163 | #define RES_NOALIASES 0x00001000 /*%< shuts off HOSTALIASES feature */ |
---|
164 | #define RES_USE_INET6 0x00002000 /*%< use/map IPv6 in gethostbyname() */ |
---|
165 | #define RES_NOTLDQUERY 0x00004000 /*%< Don't query TLD names */ |
---|
166 | |
---|
167 | #define RES_DEFAULT (RES_RECURSE | RES_DEFNAMES | \ |
---|
168 | RES_DNSRCH) |
---|
169 | |
---|
170 | /*% |
---|
171 | * Resolver "pfcode" values. Used by dig. |
---|
172 | */ |
---|
173 | #define RES_PRF_STATS 0x00000001 |
---|
174 | #define RES_PRF_UPDATE 0x00000002 |
---|
175 | #define RES_PRF_CLASS 0x00000004 |
---|
176 | #define RES_PRF_CMD 0x00000008 |
---|
177 | #define RES_PRF_QUES 0x00000010 |
---|
178 | #define RES_PRF_ANS 0x00000020 |
---|
179 | #define RES_PRF_AUTH 0x00000040 |
---|
180 | #define RES_PRF_ADD 0x00000080 |
---|
181 | #define RES_PRF_HEAD1 0x00000100 |
---|
182 | #define RES_PRF_HEAD2 0x00000200 |
---|
183 | #define RES_PRF_TTLID 0x00000400 |
---|
184 | #define RES_PRF_HEADX 0x00000800 |
---|
185 | #define RES_PRF_QUERY 0x00001000 |
---|
186 | #define RES_PRF_REPLY 0x00002000 |
---|
187 | #define RES_PRF_INIT 0x00004000 |
---|
188 | /* 0x00008000 */ |
---|
189 | |
---|
190 | #define fp_nquery __fp_nquery |
---|
191 | #define fp_query __fp_query |
---|
192 | #define hostalias __hostalias |
---|
193 | #define p_query __p_query |
---|
194 | #define res_close __res_close |
---|
195 | #define res_init __res_init |
---|
196 | #define res_isourserver __res_isourserver |
---|
197 | #define res_mkquery __res_mkquery |
---|
198 | #define res_query __res_query |
---|
199 | #define res_querydomain __res_querydomain |
---|
200 | #define res_search __res_search |
---|
201 | #define res_send __res_send |
---|
202 | |
---|
203 | __BEGIN_DECLS |
---|
204 | void fp_nquery(const u_char *, int, FILE *); |
---|
205 | void fp_query(const u_char *, FILE *); |
---|
206 | const char * hostalias(const char *); |
---|
207 | void p_query(const u_char *); |
---|
208 | void res_close(void); |
---|
209 | int res_init(void); |
---|
210 | int res_isourserver(const struct sockaddr_in *); |
---|
211 | int res_mkquery(int, const char *, int, int, const u_char *, |
---|
212 | int, const u_char *, u_char *, int); |
---|
213 | int res_query(const char *, int, int, u_char *, int); |
---|
214 | int res_querydomain(const char *, const char *, int, int, |
---|
215 | u_char *, int); |
---|
216 | int res_search(const char *, int, int, u_char *, int); |
---|
217 | int res_send(const u_char *, int, u_char *, int); |
---|
218 | __END_DECLS |
---|
219 | |
---|
220 | extern struct __res_state _res; |
---|
221 | |
---|
222 | |
---|
223 | extern const struct res_sym __p_class_syms[]; |
---|
224 | extern const struct res_sym __p_type_syms[]; |
---|
225 | |
---|
226 | /* Private routines shared between libc/net, named, nslookup and others. */ |
---|
227 | #define b64_ntop __b64_ntop |
---|
228 | #define b64_pton __b64_pton |
---|
229 | #define dn_comp __dn_comp |
---|
230 | #define dn_count_labels __dn_count_labels |
---|
231 | #define dn_expand __dn_expand |
---|
232 | #define dn_skipname __dn_skipname |
---|
233 | #define fp_resstat __fp_resstat |
---|
234 | #define loc_aton __loc_aton |
---|
235 | #define loc_ntoa __loc_ntoa |
---|
236 | #define p_cdname __p_cdname |
---|
237 | #define p_cdnname __p_cdnname |
---|
238 | #define fp_resstat __fp_resstat |
---|
239 | #define p_class __p_class |
---|
240 | #define p_fqname __p_fqname |
---|
241 | #define p_fqnname __p_fqnname |
---|
242 | #define p_option __p_option |
---|
243 | #define p_secstodate __p_secstodate |
---|
244 | #define p_section __p_section |
---|
245 | #define p_time __p_time |
---|
246 | #define p_type __p_type |
---|
247 | #define putlong __putlong |
---|
248 | #define putshort __putshort |
---|
249 | #define res_dnok __res_dnok |
---|
250 | #define res_hnok __res_hnok |
---|
251 | #define res_mailok __res_mailok |
---|
252 | #define res_nameinquery __res_nameinquery |
---|
253 | #define res_ownok __res_ownok |
---|
254 | #define res_queriesmatch __res_queriesmatch |
---|
255 | #define res_randomid __res_randomid |
---|
256 | #define sym_ntop __sym_ntop |
---|
257 | #define sym_ntos __sym_ntos |
---|
258 | #define sym_ston __sym_ston |
---|
259 | #define res_send_setqhook __res_send_setqhook |
---|
260 | #define res_send_setrhook __res_send_setrhook |
---|
261 | #define res_mkupdate __res_mkupdate |
---|
262 | #define res_mkupdrec __res_mkupdrec |
---|
263 | #define res_freeupdrec __res_freeupdrec |
---|
264 | |
---|
265 | __BEGIN_DECLS |
---|
266 | int res_hnok(const char *); |
---|
267 | int res_ownok(const char *); |
---|
268 | int res_mailok(const char *); |
---|
269 | int res_dnok(const char *); |
---|
270 | int sym_ston(const struct res_sym *, const char *, int *); |
---|
271 | const char * sym_ntos(const struct res_sym *, int, int *); |
---|
272 | const char * sym_ntop(const struct res_sym *, int, int *); |
---|
273 | int b64_ntop(u_char const *, size_t, char *, size_t); |
---|
274 | int b64_pton(char const *, u_char *, size_t); |
---|
275 | int loc_aton(const char *, u_char *); |
---|
276 | const char * loc_ntoa(const u_char *, char *); |
---|
277 | int dn_skipname(const u_char *, const u_char *); |
---|
278 | void fp_resstat(struct __res_state *, FILE *); |
---|
279 | void putlong(u_int32_t, u_char *); |
---|
280 | void putshort(u_int16_t, u_char *); |
---|
281 | const char * p_class(int); |
---|
282 | const char * p_time(u_int32_t); |
---|
283 | const char * p_type(int); |
---|
284 | const u_char * p_cdnname(const u_char *, const u_char *, int, FILE *); |
---|
285 | const u_char * p_cdname(const u_char *, const u_char *, FILE *); |
---|
286 | const u_char * p_fqnname(const u_char *, const u_char *, int, char *, int); |
---|
287 | const u_char * p_fqname(const u_char *, const u_char *, FILE *); |
---|
288 | const char * p_option(u_long); |
---|
289 | char * p_secstodate(u_long); |
---|
290 | int dn_count_labels(const char *); |
---|
291 | int dn_comp(const char *, u_char *, int, u_char **, u_char **); |
---|
292 | int dn_expand(const u_char *, const u_char *, const u_char *, |
---|
293 | char *, int); |
---|
294 | u_int res_randomid(void); |
---|
295 | int res_nameinquery(const char *, int, int, const u_char *, |
---|
296 | const u_char *); |
---|
297 | int res_queriesmatch(const u_char *, const u_char *, |
---|
298 | const u_char *, const u_char *); |
---|
299 | const char * p_section(int, int); |
---|
300 | void res_send_setqhook(res_send_qhook); |
---|
301 | void res_send_setrhook(res_send_rhook); |
---|
302 | |
---|
303 | /* XXX The following depend on the ns_updrec typedef in arpa/nameser.h */ |
---|
304 | #ifdef _ARPA_NAMESER_H_ |
---|
305 | int res_update (ns_updrec *); |
---|
306 | int res_mkupdate (ns_updrec *, u_char *, int); |
---|
307 | ns_updrec * res_mkupdrec (int, const char *, u_int, u_int, u_long); |
---|
308 | void res_freeupdrec (ns_updrec *); |
---|
309 | #endif |
---|
310 | __END_DECLS |
---|
311 | |
---|
312 | #endif /* !_RESOLV_H_ */ |
---|