Libinfo-173.tar.gz
[apple/libinfo.git] / dns.subproj / resolv8_compat.h
1 /*
2 * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
7 *
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License'). You may not use this file except in
11 * compliance with the License. Please obtain a copy of the License at
12 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * file.
14 *
15 * The Original Code and all software distributed under the License are
16 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 * Please see the License for the specific language governing rights and
21 * limitations under the License.
22 *
23 * @APPLE_LICENSE_HEADER_END@
24 */
25 /*
26 * ++Copyright++ 1983, 1987, 1989, 1993
27 * -
28 * Copyright (c) 1983, 1987, 1989, 1993
29 * The Regents of the University of California. All rights reserved.
30 *
31 * Redistribution and use in source and binary forms, with or without
32 * modification, are permitted provided that the following conditions
33 * are met:
34 * 1. Redistributions of source code must retain the above copyright
35 * notice, this list of conditions and the following disclaimer.
36 * 2. Redistributions in binary form must reproduce the above copyright
37 * notice, this list of conditions and the following disclaimer in the
38 * documentation and/or other materials provided with the distribution.
39 * 3. All advertising materials mentioning features or use of this software
40 * must display the following acknowledgement:
41 * This product includes software developed by the University of
42 * California, Berkeley and its contributors.
43 * 4. Neither the name of the University nor the names of its contributors
44 * may be used to endorse or promote products derived from this software
45 * without specific prior written permission.
46 *
47 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
48 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
49 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
50 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
51 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
52 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
53 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
54 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
55 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
56 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
57 * SUCH DAMAGE.
58 * -
59 * Portions Copyright (c) 1993 by Digital Equipment Corporation.
60 *
61 * Permission to use, copy, modify, and distribute this software for any
62 * purpose with or without fee is hereby granted, provided that the above
63 * copyright notice and this permission notice appear in all copies, and that
64 * the name of Digital Equipment Corporation not be used in advertising or
65 * publicity pertaining to distribution of the document or software without
66 * specific, written prior permission.
67 *
68 * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
69 * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
70 * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT
71 * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
72 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
73 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
74 * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
75 * SOFTWARE.
76 * -
77 * --Copyright--
78 */
79
80 /*
81 * @(#)resolv.h 8.1 (Berkeley) 6/2/93
82 * $Id: resolv8_compat.h,v 1.2 2003/02/18 17:29:25 majka Exp $
83 */
84
85 #ifndef _RESOLV_H_
86 #define _RESOLV_H_
87
88 #include <sys/param.h>
89 #if (!defined(BSD)) || (BSD < 199306)
90 # include <sys/bitypes.h>
91 #else
92 # include <sys/types.h>
93 #endif
94 #include <sys/cdefs.h>
95 #include <stdio.h>
96
97 /*
98 * revision information. this is the release date in YYYYMMDD format.
99 * it can change every day so the right thing to do with it is use it
100 * in preprocessor commands such as "#if (__RES > 19931104)". do not
101 * compare for equality; rather, use it to determine whether your resolver
102 * is new enough to contain a certain feature.
103 */
104
105 #define __RES 19950621
106
107 /*
108 * Resolver configuration file.
109 * Normally not present, but may contain the address of the
110 * inital name server(s) to query and the domain search list.
111 */
112
113 #ifndef _PATH_RESCONF
114 #define _PATH_RESCONF "/etc/resolv.conf"
115 #endif
116
117 /*
118 * Global defines and variables for resolver stub.
119 */
120 #define MAXNS 3 /* max # name servers we'll track */
121 #define MAXDFLSRCH 3 /* # default domain levels to try */
122 #define MAXDNSRCH 6 /* max # domains in search path */
123 #define LOCALDOMAINPARTS 2 /* min levels in name that is "local" */
124
125 #define RES_TIMEOUT 5 /* min. seconds between retries */
126 #define MAXRESOLVSORT 10 /* number of net to sort on */
127 #define RES_MAXNDOTS 15 /* should reflect bit field size */
128
129 struct __res_state {
130 int retrans; /* retransmition time interval */
131 int retry; /* number of times to retransmit */
132 u_long options; /* option flags - see below. */
133 int nscount; /* number of name servers */
134 struct sockaddr_in
135 nsaddr_list[MAXNS]; /* address of name server */
136 #define nsaddr nsaddr_list[0] /* for backward compatibility */
137 u_short id; /* current packet id */
138 char *dnsrch[MAXDNSRCH+1]; /* components of domain to search */
139 char defdname[MAXDNAME]; /* default domain */
140 u_long pfcode; /* RES_PRF_ flags - see below. */
141 unsigned ndots:4; /* threshold for initial abs. query */
142 unsigned nsort:4; /* number of elements in sort_list[] */
143 char unused[3];
144 struct {
145 struct in_addr addr;
146 u_int32_t mask;
147 } sort_list[MAXRESOLVSORT];
148 };
149
150 /*
151 * Resolver options (keep these in synch with res_debug.c, please)
152 */
153 #define RES_INIT 0x00000001 /* address initialized */
154 #define RES_DEBUG 0x00000002 /* print debug messages */
155 #define RES_AAONLY 0x00000004 /* authoritative answers only (!IMPL)*/
156 #define RES_USEVC 0x00000008 /* use virtual circuit */
157 #define RES_PRIMARY 0x00000010 /* query primary server only (!IMPL) */
158 #define RES_IGNTC 0x00000020 /* ignore trucation errors */
159 #define RES_RECURSE 0x00000040 /* recursion desired */
160 #define RES_DEFNAMES 0x00000080 /* use default domain name */
161 #define RES_STAYOPEN 0x00000100 /* Keep TCP socket open */
162 #define RES_DNSRCH 0x00000200 /* search up local domain tree */
163 #define RES_INSECURE1 0x00000400 /* type 1 security disabled */
164 #define RES_INSECURE2 0x00000800 /* type 2 security disabled */
165 #define RES_NOALIASES 0x00001000 /* shuts off HOSTALIASES feature */
166
167 #define RES_DEFAULT (RES_RECURSE | RES_DEFNAMES | RES_DNSRCH)
168
169 /*
170 * Resolver "pfcode" values. Used by dig.
171 */
172 #define RES_PRF_STATS 0x00000001
173 /* 0x00000002 */
174 #define RES_PRF_CLASS 0x00000004
175 #define RES_PRF_CMD 0x00000008
176 #define RES_PRF_QUES 0x00000010
177 #define RES_PRF_ANS 0x00000020
178 #define RES_PRF_AUTH 0x00000040
179 #define RES_PRF_ADD 0x00000080
180 #define RES_PRF_HEAD1 0x00000100
181 #define RES_PRF_HEAD2 0x00000200
182 #define RES_PRF_TTLID 0x00000400
183 #define RES_PRF_HEADX 0x00000800
184 #define RES_PRF_QUERY 0x00001000
185 #define RES_PRF_REPLY 0x00002000
186 #define RES_PRF_INIT 0x00004000
187 /* 0x00008000 */
188
189 /* hooks are still experimental as of 4.9.2 */
190 typedef enum { res_goahead, res_nextns, res_modified, res_done, res_error }
191 res_sendhookact;
192
193 typedef res_sendhookact (*res_send_qhook)__P((struct sockaddr_in * const *ns,
194 const u_char **query,
195 int *querylen,
196 u_char *ans,
197 int anssiz,
198 int *resplen));
199
200 typedef res_sendhookact (*res_send_rhook)__P((const struct sockaddr_in *ns,
201 const u_char *query,
202 int querylen,
203 u_char *ans,
204 int anssiz,
205 int *resplen));
206
207 extern struct __res_state _res;
208
209 /* Private routines shared between libc/net, named, nslookup and others. */
210 #define dn_skipname __dn_skipname
211 #define fp_query __fp_query
212 #define fp_nquery __fp_nquery
213 #define hostalias __hostalias
214 #define putlong __putlong
215 #define putshort __putshort
216 #define p_class __p_class
217 #define p_time __p_time
218 #define p_type __p_type
219 #define p_cdnname __p_cdnname
220 #define p_cdname __p_cdname
221 #define p_fqname __p_fqname
222 #define p_rr __p_rr
223 #define p_option __p_option
224 #define res_randomid __res_randomid
225 #define res_isourserver __res_isourserver
226 #define res_nameinquery __res_nameinquery
227 #define res_queriesmatch __res_queriesmatch
228 __BEGIN_DECLS
229 int __dn_skipname __P((const u_char *, const u_char *));
230 void __fp_resstat __P((struct __res_state *, FILE *));
231 void __fp_query __P((const u_char *, FILE *));
232 void __fp_nquery __P((const u_char *, int, FILE *));
233 char *__hostalias __P((const char *));
234 void __putlong __P((u_int32_t, u_char *));
235 void __putshort __P((u_int16_t, u_char *));
236 char *__p_time __P((u_int32_t));
237 void __p_query __P((const u_char *));
238 const u_char *__p_cdnname __P((const u_char *, const u_char *, int, FILE *));
239 const u_char *__p_cdname __P((const u_char *, const u_char *, FILE *));
240 const u_char *__p_fqname __P((const u_char *, const u_char *, FILE *));
241 const u_char *__p_rr __P((const u_char *, const u_char *, FILE *));
242 const char *__p_type __P((int));
243 const char *__p_class __P((int));
244 const char *__p_option __P((u_long option));
245 int dn_comp __P((const char *, u_char *, int, u_char **, u_char **));
246 int dn_expand __P((const u_char *, const u_char *, const u_char *,
247 char *, int));
248 int res_init __P((void));
249 u_int16_t res_randomid __P((void));
250 int res_query __P((const char *, int, int, u_char *, int));
251 int res_search __P((const char *, int, int, u_char *, int));
252 int res_querydomain __P((const char *, const char *, int, int,
253 u_char *, int));
254 int res_mkquery __P((int, const char *, int, int, const u_char *, int,
255 const u_char *, u_char *, int));
256 int res_send __P((const u_char *, int, u_char *, int));
257 int res_isourserver __P((const struct sockaddr_in *));
258 int res_nameinquery __P((const char *, int, int,
259 const u_char *, const u_char *));
260 int res_queriesmatch __P((const u_char *, const u_char *,
261 const u_char *, const u_char *));
262 __END_DECLS
263
264 #endif /* !_RESOLV_H_ */