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