resolv.h revision 1.4 1 /*
2 * Copyright (c) 1983, 1987, 1989 The Regents of the University of California.
3 * 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. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by the University of
16 * California, Berkeley and its contributors.
17 * 4. Neither the name of the University nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 *
33 * from: @(#)resolv.h 5.15 (Berkeley) 4/3/91
34 * $Id: resolv.h,v 1.4 1994/04/07 06:58:30 deraadt Exp $
35 */
36
37 #ifndef _RESOLV_H_
38 #define _RESOLV_H_
39
40 /*
41 * revision information. this is the release date in YYYYMMDD format.
42 * it can change every day so the right thing to do with it is use it
43 * in preprocessor commands such as "#if (__RES > 19931104)". do not
44 * compare for equality; rather, use it to determine whether your resolver
45 * is new enough to contain a certain feature.
46 */
47
48 #define __RES 19931104
49
50 /*
51 * Resolver configuration file.
52 * Normally not present, but may contain the address of the
53 * inital name server(s) to query and the domain search list.
54 */
55
56 #ifndef _PATH_RESCONF
57 #define _PATH_RESCONF "/etc/resolv.conf"
58 #endif
59
60 /*
61 * Global defines and variables for resolver stub.
62 */
63 #define MAXNS 3 /* max # name servers we'll track */
64 #define MAXDFLSRCH 3 /* # default domain levels to try */
65 #define MAXDNSRCH 6 /* max # domains in search path */
66 #define LOCALDOMAINPARTS 2 /* min levels in name that is "local" */
67 #define MAXDNSLUS 4 /* max # of host lookup types */
68
69 #define RES_TIMEOUT 5 /* min. seconds between retries */
70 #define MAXRESOLVSORT 10 /* number of net to sort on */
71 #define RES_MAXNDOTS 15 /* should reflect bit field size */
72
73 struct __res_state {
74 int retrans; /* retransmition time interval */
75 int retry; /* number of times to retransmit */
76 long options; /* option flags - see below. */
77 int nscount; /* number of name servers */
78 struct sockaddr_in nsaddr_list[MAXNS]; /* address of name server */
79 #define nsaddr nsaddr_list[0] /* for backward compatibility */
80 u_short id; /* current packet id */
81 char *dnsrch[MAXDNSRCH+1]; /* components of domain to search */
82 char defdname[MAXDNAME]; /* default domain */
83 long pfcode; /* RES_PRF_ flags - see below. */
84 u_char ndots:4; /* threshold for initial abs. query */
85 u_char nsort:4; /* number of elements in sort_list[] */
86 char unused[3];
87 struct {
88 struct in_addr addr;
89 u_long mask;
90 } sort_list[MAXRESOLVSORT];
91 char lookups[MAXDNSLUS];
92 };
93
94 /*
95 * Resolver options
96 */
97 #define RES_INIT 0x0001 /* address initialized */
98 #define RES_DEBUG 0x0002 /* print debug messages */
99 #define RES_AAONLY 0x0004 /* authoritative answers only */
100 #define RES_USEVC 0x0008 /* use virtual circuit */
101 #define RES_PRIMARY 0x0010 /* query primary server only */
102 #define RES_IGNTC 0x0020 /* ignore trucation errors */
103 #define RES_RECURSE 0x0040 /* recursion desired */
104 #define RES_DEFNAMES 0x0080 /* use default domain name */
105 #define RES_STAYOPEN 0x0100 /* Keep TCP socket open */
106 #define RES_DNSRCH 0x0200 /* search up local domain tree */
107
108 #define RES_DEFAULT (RES_RECURSE | RES_DEFNAMES | RES_DNSRCH)
109
110 /*
111 * Resolver "pfcode" values. Used by dig.
112 */
113 #define RES_PRF_STATS 0x0001
114 /* 0x0002 */
115 #define RES_PRF_CLASS 0x0004
116 #define RES_PRF_CMD 0x0008
117 #define RES_PRF_QUES 0x0010
118 #define RES_PRF_ANS 0x0020
119 #define RES_PRF_AUTH 0x0040
120 #define RES_PRF_ADD 0x0080
121 #define RES_PRF_HEAD1 0x0100
122 #define RES_PRF_HEAD2 0x0200
123 #define RES_PRF_TTLID 0x0400
124 #define RES_PRF_HEADX 0x0800
125 #define RES_PRF_QUERY 0x1000
126 #define RES_PRF_REPLY 0x2000
127 #define RES_PRF_INIT 0x4000
128 /* 0x8000 */
129
130 extern struct __res_state _res;
131
132 #include <sys/cdefs.h>
133 #include <stdio.h>
134
135 /* Private routines shared between libc/net, named, nslookup and others. */
136 #define dn_skipname __dn_skipname
137 #define fp_query __fp_query
138 #define hostalias __hostalias
139 #define putlong __putlong
140 #define putshort __putshort
141 #define p_class __p_class
142 #define p_time __p_time
143 #define p_type __p_type
144 __BEGIN_DECLS
145 int __dn_skipname __P((const u_char *, const u_char *));
146 void __fp_query __P((char *, FILE *));
147 char *__hostalias __P((const char *));
148 void __putlong __P((u_long, u_char *));
149 void __putshort __P((u_short, u_char *));
150 char *__p_class __P((int));
151 char *__p_time __P((u_long));
152 char *__p_type __P((int));
153
154 int dn_comp __P((const u_char *, u_char *, int, u_char **, u_char **));
155 int dn_expand __P((const u_char *, const u_char *, const u_char *,
156 u_char *, int));
157 int res_init __P((void));
158 int res_mkquery __P((int, const char *, int, int, const char *, int,
159 const char *, char *, int));
160 int res_send __P((const char *, int, char *, int));
161 __END_DECLS
162
163 #endif /* !_RESOLV_H_ */
164