xref: /freebsd/include/resolv.h (revision 1363f04ce1b83359b8e4f3fbde56a6ebcee57209)
159deaec5SRodney W. Grimes /*-
259deaec5SRodney W. Grimes  * Copyright (c) 1983, 1987, 1989, 1993
359deaec5SRodney W. Grimes  *	The Regents of the University of California.  All rights reserved.
459deaec5SRodney W. Grimes  *
559deaec5SRodney W. Grimes  * Redistribution and use in source and binary forms, with or without
659deaec5SRodney W. Grimes  * modification, are permitted provided that the following conditions
759deaec5SRodney W. Grimes  * are met:
859deaec5SRodney W. Grimes  * 1. Redistributions of source code must retain the above copyright
959deaec5SRodney W. Grimes  *    notice, this list of conditions and the following disclaimer.
1059deaec5SRodney W. Grimes  * 2. Redistributions in binary form must reproduce the above copyright
1159deaec5SRodney W. Grimes  *    notice, this list of conditions and the following disclaimer in the
1259deaec5SRodney W. Grimes  *    documentation and/or other materials provided with the distribution.
1359deaec5SRodney W. Grimes  * 3. All advertising materials mentioning features or use of this software
1459deaec5SRodney W. Grimes  *    must display the following acknowledgement:
1559deaec5SRodney W. Grimes  *	This product includes software developed by the University of
1659deaec5SRodney W. Grimes  *	California, Berkeley and its contributors.
1759deaec5SRodney W. Grimes  * 4. Neither the name of the University nor the names of its contributors
1859deaec5SRodney W. Grimes  *    may be used to endorse or promote products derived from this software
1959deaec5SRodney W. Grimes  *    without specific prior written permission.
2059deaec5SRodney W. Grimes  *
2159deaec5SRodney W. Grimes  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
2259deaec5SRodney W. Grimes  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2359deaec5SRodney W. Grimes  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2459deaec5SRodney W. Grimes  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
2559deaec5SRodney W. Grimes  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2659deaec5SRodney W. Grimes  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2759deaec5SRodney W. Grimes  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2859deaec5SRodney W. Grimes  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2959deaec5SRodney W. Grimes  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3059deaec5SRodney W. Grimes  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3159deaec5SRodney W. Grimes  * SUCH DAMAGE.
3259deaec5SRodney W. Grimes  *
3359deaec5SRodney W. Grimes  * -
3459deaec5SRodney W. Grimes  * Portions Copyright (c) 1993 by Digital Equipment Corporation.
3559deaec5SRodney W. Grimes  *
3659deaec5SRodney W. Grimes  * Permission to use, copy, modify, and distribute this software for any
3759deaec5SRodney W. Grimes  * purpose with or without fee is hereby granted, provided that the above
3859deaec5SRodney W. Grimes  * copyright notice and this permission notice appear in all copies, and that
3959deaec5SRodney W. Grimes  * the name of Digital Equipment Corporation not be used in advertising or
4059deaec5SRodney W. Grimes  * publicity pertaining to distribution of the document or software without
4159deaec5SRodney W. Grimes  * specific, written prior permission.
4259deaec5SRodney W. Grimes  *
4359deaec5SRodney W. Grimes  * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
4459deaec5SRodney W. Grimes  * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
4559deaec5SRodney W. Grimes  * OF MERCHANTABILITY AND FITNESS.   IN NO EVENT SHALL DIGITAL EQUIPMENT
4659deaec5SRodney W. Grimes  * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
4759deaec5SRodney W. Grimes  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
4859deaec5SRodney W. Grimes  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
4959deaec5SRodney W. Grimes  * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
5059deaec5SRodney W. Grimes  * SOFTWARE.
5159deaec5SRodney W. Grimes  * -
5259deaec5SRodney W. Grimes  * --Copyright--
531363f04cSPaul Traina  *
541363f04cSPaul Traina  *	@(#)resolv.h	8.1 (Berkeley) 6/2/93
551363f04cSPaul Traina  *	From Id: resolv.h,v 4.9.1.2 1993/05/17 09:59:01 vixie Exp
561363f04cSPaul Traina  *	$Id$
5759deaec5SRodney W. Grimes  */
5859deaec5SRodney W. Grimes 
5959deaec5SRodney W. Grimes #ifndef _RESOLV_H_
6059deaec5SRodney W. Grimes #define	_RESOLV_H_
6159deaec5SRodney W. Grimes 
621363f04cSPaul Traina #include <sys/param.h>
6359deaec5SRodney W. Grimes #include <sys/types.h>
641363f04cSPaul Traina #include <sys/cdefs.h>
651363f04cSPaul Traina #include <stdio.h>
661363f04cSPaul Traina 
671363f04cSPaul Traina /*
681363f04cSPaul Traina  * revision information.  this is the release date in YYYYMMDD format.
691363f04cSPaul Traina  * it can change every day so the right thing to do with it is use it
701363f04cSPaul Traina  * in preprocessor commands such as "#if (__RES > 19931104)".  do not
711363f04cSPaul Traina  * compare for equality; rather, use it to determine whether your resolver
721363f04cSPaul Traina  * is new enough to contain a certain feature.
731363f04cSPaul Traina  */
741363f04cSPaul Traina 
751363f04cSPaul Traina #define	__RES	19940415
761363f04cSPaul Traina 
7759deaec5SRodney W. Grimes /*
7859deaec5SRodney W. Grimes  * Resolver configuration file.
7959deaec5SRodney W. Grimes  * Normally not present, but may contain the address of the
8059deaec5SRodney W. Grimes  * inital name server(s) to query and the domain search list.
8159deaec5SRodney W. Grimes  */
8259deaec5SRodney W. Grimes 
8359deaec5SRodney W. Grimes #ifndef _PATH_RESCONF
8459deaec5SRodney W. Grimes #define	_PATH_RESCONF        "/etc/resolv.conf"
8559deaec5SRodney W. Grimes #endif
8659deaec5SRodney W. Grimes 
8759deaec5SRodney W. Grimes /*
8859deaec5SRodney W. Grimes  * Global defines and variables for resolver stub.
8959deaec5SRodney W. Grimes  */
9059deaec5SRodney W. Grimes #define	MAXNS			3	/* max # name servers we'll track */
9159deaec5SRodney W. Grimes #define	MAXDFLSRCH		3	/* # default domain levels to try */
9259deaec5SRodney W. Grimes #define	MAXDNSRCH		6	/* max # domains in search path */
9359deaec5SRodney W. Grimes #define	LOCALDOMAINPARTS	2	/* min levels in name that is "local" */
9459deaec5SRodney W. Grimes 
9559deaec5SRodney W. Grimes #define	RES_TIMEOUT		5	/* min. seconds between retries */
961363f04cSPaul Traina #define	MAXRESOLVSORT		10	/* number of net to sort on */
971363f04cSPaul Traina #define	RES_MAXNDOTS		15	/* should reflect bit field size */
9859deaec5SRodney W. Grimes 
9959deaec5SRodney W. Grimes struct __res_state {
10059deaec5SRodney W. Grimes 	int	retrans;	 	/* retransmition time interval */
10159deaec5SRodney W. Grimes 	int	retry;			/* number of times to retransmit */
1021363f04cSPaul Traina 	u_long	options;		/* option flags - see below. */
10359deaec5SRodney W. Grimes 	int	nscount;		/* number of name servers */
1041363f04cSPaul Traina 	struct sockaddr_in
1051363f04cSPaul Traina 		nsaddr_list[MAXNS];	/* address of name server */
10659deaec5SRodney W. Grimes #define	nsaddr	nsaddr_list[0]		/* for backward compatibility */
10759deaec5SRodney W. Grimes 	u_short	id;			/* current packet id */
10859deaec5SRodney W. Grimes 	char	*dnsrch[MAXDNSRCH+1];	/* components of domain to search */
10959deaec5SRodney W. Grimes 	char	defdname[MAXDNAME];	/* default domain */
1101363f04cSPaul Traina 	u_long	pfcode;			/* RES_PRF_ flags - see below. */
1111363f04cSPaul Traina 	unsigned ndots:4;		/* threshold for initial abs. query */
1121363f04cSPaul Traina 	unsigned nsort:4;		/* number of elements in sort_list[] */
1131363f04cSPaul Traina 	char	unused[3];
1141363f04cSPaul Traina 	struct {
1151363f04cSPaul Traina 		struct in_addr	addr;
1161363f04cSPaul Traina 		u_int32_t	mask;
1171363f04cSPaul Traina 	} sort_list[MAXRESOLVSORT];
11859deaec5SRodney W. Grimes };
11959deaec5SRodney W. Grimes 
12059deaec5SRodney W. Grimes /*
12159deaec5SRodney W. Grimes  * Resolver options (keep these in synch with res_debug.c, please)
12259deaec5SRodney W. Grimes  */
1231363f04cSPaul Traina #define	RES_INIT	0x00000001	/* address initialized */
1241363f04cSPaul Traina #define	RES_DEBUG	0x00000002	/* print debug messages */
1251363f04cSPaul Traina #define	RES_AAONLY	0x00000004	/* authoritative answers only */
1261363f04cSPaul Traina #define	RES_USEVC	0x00000008	/* use virtual circuit */
1271363f04cSPaul Traina #define	RES_PRIMARY	0x00000010	/* query primary server only */
1281363f04cSPaul Traina #define	RES_IGNTC	0x00000020	/* ignore trucation errors */
1291363f04cSPaul Traina #define	RES_RECURSE	0x00000040	/* recursion desired */
1301363f04cSPaul Traina #define	RES_DEFNAMES	0x00000080	/* use default domain name */
1311363f04cSPaul Traina #define	RES_STAYOPEN	0x00000100	/* Keep TCP socket open */
1321363f04cSPaul Traina #define	RES_DNSRCH	0x00000200	/* search up local domain tree */
1331363f04cSPaul Traina #define	RES_INSECURE1	0x00000400	/* type 1 security disabled */
1341363f04cSPaul Traina #define	RES_INSECURE2	0x00000800	/* type 2 security disabled */
13559deaec5SRodney W. Grimes 
13659deaec5SRodney W. Grimes #define	RES_DEFAULT	(RES_RECURSE | RES_DEFNAMES | RES_DNSRCH)
13759deaec5SRodney W. Grimes 
13859deaec5SRodney W. Grimes /*
13959deaec5SRodney W. Grimes  * Resolver "pfcode" values.  Used by dig.
14059deaec5SRodney W. Grimes  */
1411363f04cSPaul Traina #define	RES_PRF_STATS	0x00000001
1421363f04cSPaul Traina /*			0x00000002	*/
1431363f04cSPaul Traina #define	RES_PRF_CLASS   0x00000004
1441363f04cSPaul Traina #define	RES_PRF_CMD	0x00000008
1451363f04cSPaul Traina #define	RES_PRF_QUES	0x00000010
1461363f04cSPaul Traina #define	RES_PRF_ANS	0x00000020
1471363f04cSPaul Traina #define	RES_PRF_AUTH	0x00000040
1481363f04cSPaul Traina #define	RES_PRF_ADD	0x00000080
1491363f04cSPaul Traina #define	RES_PRF_HEAD1	0x00000100
1501363f04cSPaul Traina #define	RES_PRF_HEAD2	0x00000200
1511363f04cSPaul Traina #define	RES_PRF_TTLID	0x00000400
1521363f04cSPaul Traina #define	RES_PRF_HEADX	0x00000800
1531363f04cSPaul Traina #define	RES_PRF_QUERY	0x00001000
1541363f04cSPaul Traina #define	RES_PRF_REPLY	0x00002000
1551363f04cSPaul Traina #define	RES_PRF_INIT    0x00004000
1561363f04cSPaul Traina /*			0x00008000	*/
15759deaec5SRodney W. Grimes 
1581363f04cSPaul Traina /* hooks are still experimental as of 4.9.2 */
1591363f04cSPaul Traina typedef enum { res_goahead, res_nextns, res_modified, res_done, res_error }
1601363f04cSPaul Traina 	res_sendhookact;
1611363f04cSPaul Traina 
1621363f04cSPaul Traina typedef res_sendhookact (*res_send_qhook)__P((struct sockaddr_in * const *ns,
1631363f04cSPaul Traina 					      const u_char **query,
1641363f04cSPaul Traina 					      int *querylen,
1651363f04cSPaul Traina 					      u_char *ans,
1661363f04cSPaul Traina 					      int anssiz,
1671363f04cSPaul Traina 					      int *resplen));
1681363f04cSPaul Traina 
1691363f04cSPaul Traina typedef res_sendhookact (*res_send_rhook)__P((const struct sockaddr_in *ns,
1701363f04cSPaul Traina 					      const u_char *query,
1711363f04cSPaul Traina 					      int querylen,
1721363f04cSPaul Traina 					      u_char *ans,
1731363f04cSPaul Traina 					      int anssiz,
1741363f04cSPaul Traina 					      int *resplen));
17559deaec5SRodney W. Grimes 
17659deaec5SRodney W. Grimes extern struct __res_state _res;
17759deaec5SRodney W. Grimes 
17859deaec5SRodney W. Grimes /* Private routines shared between libc/net, named, nslookup and others. */
17959deaec5SRodney W. Grimes #define	dn_skipname	__dn_skipname
18059deaec5SRodney W. Grimes #define	fp_query	__fp_query
1811363f04cSPaul Traina #define	fp_nquery	__fp_nquery
18259deaec5SRodney W. Grimes #define	hostalias	__hostalias
18359deaec5SRodney W. Grimes #define	putlong		__putlong
18459deaec5SRodney W. Grimes #define	putshort	__putshort
18559deaec5SRodney W. Grimes #define	p_class		__p_class
18659deaec5SRodney W. Grimes #define	p_time		__p_time
18759deaec5SRodney W. Grimes #define	p_type		__p_type
1881363f04cSPaul Traina #define	p_cdnname	__p_cdnname
1891363f04cSPaul Traina #define	p_cdname	__p_cdname
1901363f04cSPaul Traina #define	p_fqname	__p_fqname
1911363f04cSPaul Traina #define	p_rr		__p_rr
1921363f04cSPaul Traina #define	p_option	__p_option
1931363f04cSPaul Traina 
19459deaec5SRodney W. Grimes __BEGIN_DECLS
19559deaec5SRodney W. Grimes int	 __dn_skipname __P((const u_char *, const u_char *));
19659deaec5SRodney W. Grimes void	 __fp_resstat __P((struct __res_state *, FILE *));
1971363f04cSPaul Traina void	 __fp_query __P((const u_char *, FILE *));
1981363f04cSPaul Traina void	 __fp_nquery __P((const u_char *, int, FILE *));
19959deaec5SRodney W. Grimes char	*__hostalias __P((const char *));
20059deaec5SRodney W. Grimes void	 __putlong __P((u_int32_t, u_char *));
2011363f04cSPaul Traina void	 __putshort __P((u_int16_t, u_char *));
20259deaec5SRodney W. Grimes char	*__p_time __P((u_int32_t));
2031363f04cSPaul Traina void	 __p_query __P((const u_char *));
2041363f04cSPaul Traina const u_char *__p_cdnname __P((const u_char *, const u_char *, int, FILE *));
2051363f04cSPaul Traina const u_char *__p_cdname __P((const u_char *, const u_char *, FILE *));
2061363f04cSPaul Traina const u_char *__p_fqname __P((const u_char *, const u_char *, FILE *));
2071363f04cSPaul Traina const u_char *__p_rr __P((const u_char *, const u_char *, FILE *));
2081363f04cSPaul Traina const char *__p_type __P((int));
2091363f04cSPaul Traina const char *__p_class __P((int));
2101363f04cSPaul Traina const char *__p_option __P((u_long option));
2111363f04cSPaul Traina int	 dn_comp __P((const char *, u_char *, int, u_char **, u_char **));
21259deaec5SRodney W. Grimes int	 dn_expand __P((const u_char *, const u_char *, const u_char *,
2131363f04cSPaul Traina 			char *, int));
21459deaec5SRodney W. Grimes int	 res_init __P((void));
2151363f04cSPaul Traina int	 res_query __P((const char *, int, int, u_char *, int));
2161363f04cSPaul Traina int	 res_search __P((const char *, int, int, u_char *, int));
2171363f04cSPaul Traina int	 res_querydomain __P((const char *, const char *, int, int,
2181363f04cSPaul Traina 			      u_char *, int));
2191363f04cSPaul Traina int	 res_mkquery __P((int, const char *, int, int, const u_char *, int,
2201363f04cSPaul Traina 			  const u_char *, u_char *, int));
2211363f04cSPaul Traina int	 res_send __P((const u_char *, int, u_char *, int));
22259deaec5SRodney W. Grimes __END_DECLS
22359deaec5SRodney W. Grimes 
22459deaec5SRodney W. Grimes #endif /* !_RESOLV_H_ */
225