xref: /netbsd-src/include/resolv.h (revision ce63d6c20fc4ec8ddc95c84bb229e3c4ecf82b69)
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  *	@(#)resolv.h	5.15 (Berkeley) 4/3/91
34  */
35 
36 #ifndef _RESOLV_H_
37 #define	_RESOLV_H_
38 
39 /*
40  * Resolver configuration file.
41  * Normally not present, but may contain the address of the
42  * inital name server(s) to query and the domain search list.
43  */
44 
45 #ifndef _PATH_RESCONF
46 #define _PATH_RESCONF        "/etc/resolv.conf"
47 #endif
48 
49 /*
50  * Global defines and variables for resolver stub.
51  */
52 #define	MAXNS			3	/* max # name servers we'll track */
53 #define	MAXDFLSRCH		3	/* # default domain levels to try */
54 #define	MAXDNSRCH		6	/* max # domains in search path */
55 #define	LOCALDOMAINPARTS	2	/* min levels in name that is "local" */
56 
57 #define	RES_TIMEOUT		5	/* min. seconds between retries */
58 
59 struct state {
60 	int	retrans;	 	/* retransmition time interval */
61 	int	retry;			/* number of times to retransmit */
62 	long	options;		/* option flags - see below. */
63 	int	nscount;		/* number of name servers */
64 	struct	sockaddr_in nsaddr_list[MAXNS];	/* address of name server */
65 #define	nsaddr	nsaddr_list[0]		/* for backward compatibility */
66 	u_short	id;			/* current packet id */
67 	char	defdname[MAXDNAME];	/* default domain */
68 	char	*dnsrch[MAXDNSRCH+1];	/* components of domain to search */
69 };
70 
71 /*
72  * Resolver options
73  */
74 #define RES_INIT	0x0001		/* address initialized */
75 #define RES_DEBUG	0x0002		/* print debug messages */
76 #define RES_AAONLY	0x0004		/* authoritative answers only */
77 #define RES_USEVC	0x0008		/* use virtual circuit */
78 #define RES_PRIMARY	0x0010		/* query primary server only */
79 #define RES_IGNTC	0x0020		/* ignore trucation errors */
80 #define RES_RECURSE	0x0040		/* recursion desired */
81 #define RES_DEFNAMES	0x0080		/* use default domain name */
82 #define RES_STAYOPEN	0x0100		/* Keep TCP socket open */
83 #define RES_DNSRCH	0x0200		/* search up local domain tree */
84 
85 #define RES_DEFAULT	(RES_RECURSE | RES_DEFNAMES | RES_DNSRCH)
86 
87 extern struct state _res;
88 
89 #include <sys/cdefs.h>
90 #include <stdio.h>
91 
92 /* Private routines shared between libc/net, named, nslookup and others. */
93 #define	dn_skipname	__dn_skipname
94 #define	fp_query	__fp_query
95 #define	hostalias	__hostalias
96 #define	putlong		__putlong
97 #define	putshort	__putshort
98 #define p_class		__p_class
99 #define p_time		__p_time
100 #define p_type		__p_type
101 __BEGIN_DECLS
102 int	 __dn_skipname __P((const u_char *, const u_char *));
103 void	 __fp_query __P((char *, FILE *));
104 char	*__hostalias __P((const char *));
105 void	 __putlong __P((u_long, u_char *));
106 void	 __putshort __P((u_short, u_char *));
107 char	*__p_class __P((int));
108 char	*__p_time __P((u_long));
109 char	*__p_type __P((int));
110 
111 int	 dn_comp __P((const u_char *, u_char *, int, u_char **, u_char **));
112 int	 dn_expand __P((const u_char *, const u_char *, const u_char *,
113 		u_char *, int));
114 int	 res_init __P((void));
115 int	 res_mkquery __P((int, const char *, int, int, const char *, int,
116 		const struct rrec *, char *, int));
117 int	 res_send __P((const char *, int, char *, int));
118 __END_DECLS
119 
120 #endif /* !_RESOLV_H_ */
121