resolv.h revision 36898
11539Srgrimes/*-
21539Srgrimes * Copyright (c) 1983, 1987, 1989, 1993
31539Srgrimes *	The Regents of the University of California.  All rights reserved.
41539Srgrimes *
51539Srgrimes * Redistribution and use in source and binary forms, with or without
61539Srgrimes * modification, are permitted provided that the following conditions
71539Srgrimes * are met:
81539Srgrimes * 1. Redistributions of source code must retain the above copyright
91539Srgrimes *    notice, this list of conditions and the following disclaimer.
101539Srgrimes * 2. Redistributions in binary form must reproduce the above copyright
111539Srgrimes *    notice, this list of conditions and the following disclaimer in the
121539Srgrimes *    documentation and/or other materials provided with the distribution.
131539Srgrimes * 3. All advertising materials mentioning features or use of this software
141539Srgrimes *    must display the following acknowledgement:
151539Srgrimes *	This product includes software developed by the University of
161539Srgrimes *	California, Berkeley and its contributors.
171539Srgrimes * 4. Neither the name of the University nor the names of its contributors
181539Srgrimes *    may be used to endorse or promote products derived from this software
191539Srgrimes *    without specific prior written permission.
201539Srgrimes *
211539Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
221539Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
231539Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
241539Srgrimes * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
251539Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
261539Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
271539Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
281539Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
291539Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
301539Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
311539Srgrimes * SUCH DAMAGE.
3236888Speter */
3336888Speter
3436888Speter/*
3536888Speter * Portions Copyright (c) 1996 by Internet Software Consortium.
361539Srgrimes *
371539Srgrimes * Permission to use, copy, modify, and distribute this software for any
381539Srgrimes * purpose with or without fee is hereby granted, provided that the above
3936888Speter * copyright notice and this permission notice appear in all copies.
408858Srgrimes *
4136888Speter * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
4236888Speter * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
4336888Speter * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
4436888Speter * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
451539Srgrimes * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
461539Srgrimes * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
471539Srgrimes * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
481539Srgrimes * SOFTWARE.
4936888Speter */
5036888Speter
5136888Speter/*
523070Spst *	@(#)resolv.h	8.1 (Berkeley) 6/2/93
5336888Speter *	From Id: resolv.h,v 8.12 1998/04/28 19:36:46 halley Exp $
5436898Speter *	$Id: resolv.h,v 1.15 1998/06/11 08:55:13 peter Exp $
551539Srgrimes */
561539Srgrimes
571539Srgrimes#ifndef _RESOLV_H_
581539Srgrimes#define	_RESOLV_H_
591539Srgrimes
603070Spst#include <sys/param.h>
611539Srgrimes#include <sys/types.h>
623070Spst#include <sys/cdefs.h>
633070Spst#include <stdio.h>
643070Spst
651539Srgrimes/*
6621055Speter * Revision information.  This is the release date in YYYYMMDD format.
6721055Speter * It can change every day so the right thing to do with it is use it
6821055Speter * in preprocessor commands such as "#if (__RES > 19931104)".  Do not
693070Spst * compare for equality; rather, use it to determine whether your resolver
703070Spst * is new enough to contain a certain feature.
713070Spst */
723070Spst
7321055Speter#define	__RES	19960801
743070Spst
753070Spst/*
7636888Speter * This used to be defined in res_query.c, now it's in herror.c.  It was
7736888Speter * never extern'd by any *.h file before it was placed here.  herror.c is
7836888Speter * part of libresolv.a even though it might make more sense in libnetdb.a
7936888Speter * or even libnet.a.
8036888Speter */
8136888Speter
8236888Speterextern int h_errno;
8336888Speter
8436888Speter/*
851539Srgrimes * Resolver configuration file.
861539Srgrimes * Normally not present, but may contain the address of the
871539Srgrimes * inital name server(s) to query and the domain search list.
881539Srgrimes */
891539Srgrimes
901539Srgrimes#ifndef _PATH_RESCONF
913070Spst#define	_PATH_RESCONF        "/etc/resolv.conf"
921539Srgrimes#endif
931539Srgrimes
941539Srgrimes/*
951539Srgrimes * Global defines and variables for resolver stub.
961539Srgrimes */
971539Srgrimes#define	MAXNS			3	/* max # name servers we'll track */
981539Srgrimes#define	MAXDFLSRCH		3	/* # default domain levels to try */
991539Srgrimes#define	MAXDNSRCH		6	/* max # domains in search path */
1001539Srgrimes#define	LOCALDOMAINPARTS	2	/* min levels in name that is "local" */
1011539Srgrimes
1021539Srgrimes#define	RES_TIMEOUT		5	/* min. seconds between retries */
1033070Spst#define	MAXRESOLVSORT		10	/* number of net to sort on */
1043070Spst#define	RES_MAXNDOTS		15	/* should reflect bit field size */
1051539Srgrimes
1061539Srgrimesstruct __res_state {
1071539Srgrimes	int	retrans;	 	/* retransmition time interval */
1081539Srgrimes	int	retry;			/* number of times to retransmit */
1093070Spst	u_long	options;		/* option flags - see below. */
1101539Srgrimes	int	nscount;		/* number of name servers */
1113070Spst	struct sockaddr_in
1123070Spst		nsaddr_list[MAXNS];	/* address of name server */
1131539Srgrimes#define	nsaddr	nsaddr_list[0]		/* for backward compatibility */
11421055Speter	u_short	id;			/* current message id */
1151539Srgrimes	char	*dnsrch[MAXDNSRCH+1];	/* components of domain to search */
11621055Speter	char	defdname[256];		/* default domain (deprecated) */
1173070Spst	u_long	pfcode;			/* RES_PRF_ flags - see below. */
1183070Spst	unsigned ndots:4;		/* threshold for initial abs. query */
1193070Spst	unsigned nsort:4;		/* number of elements in sort_list[] */
1203070Spst	char	unused[3];
1213070Spst	struct {
1223070Spst		struct in_addr	addr;
1233070Spst		u_int32_t	mask;
1243070Spst	} sort_list[MAXRESOLVSORT];
12521055Speter	char	pad[72];		/* on an i386 this means 512b total */
1261539Srgrimes};
1271539Srgrimes
1281539Srgrimes/*
1291539Srgrimes * Resolver options (keep these in synch with res_debug.c, please)
1301539Srgrimes */
13110132Speter#define RES_INIT	0x00000001	/* address initialized */
13210132Speter#define RES_DEBUG	0x00000002	/* print debug messages */
13310132Speter#define RES_AAONLY	0x00000004	/* authoritative answers only (!IMPL)*/
13410132Speter#define RES_USEVC	0x00000008	/* use virtual circuit */
13510132Speter#define RES_PRIMARY	0x00000010	/* query primary server only (!IMPL) */
13613771Smpp#define RES_IGNTC	0x00000020	/* ignore truncation errors */
13710132Speter#define RES_RECURSE	0x00000040	/* recursion desired */
13810132Speter#define RES_DEFNAMES	0x00000080	/* use default domain name */
13910132Speter#define RES_STAYOPEN	0x00000100	/* Keep TCP socket open */
14010132Speter#define RES_DNSRCH	0x00000200	/* search up local domain tree */
1413070Spst#define	RES_INSECURE1	0x00000400	/* type 1 security disabled */
1423070Spst#define	RES_INSECURE2	0x00000800	/* type 2 security disabled */
14310132Speter#define	RES_NOALIASES	0x00001000	/* shuts off HOSTALIASES feature */
14417902Speter#define	RES_USE_INET6	0x00002000	/* use/map IPv6 in gethostbyname() */
14528982Sbrian#define	RES_NOTLDQUERY	0x00004000	/* Don't query TLD names */
1461539Srgrimes
14710132Speter#define RES_DEFAULT	(RES_RECURSE | RES_DEFNAMES | RES_DNSRCH)
1481539Srgrimes
1491539Srgrimes/*
1501539Srgrimes * Resolver "pfcode" values.  Used by dig.
1511539Srgrimes */
1523070Spst#define	RES_PRF_STATS	0x00000001
15336888Speter#define	RES_PRF_UPDATE	0x00000002
1543070Spst#define	RES_PRF_CLASS   0x00000004
1553070Spst#define	RES_PRF_CMD	0x00000008
1563070Spst#define	RES_PRF_QUES	0x00000010
1573070Spst#define	RES_PRF_ANS	0x00000020
1583070Spst#define	RES_PRF_AUTH	0x00000040
1593070Spst#define	RES_PRF_ADD	0x00000080
1603070Spst#define	RES_PRF_HEAD1	0x00000100
1613070Spst#define	RES_PRF_HEAD2	0x00000200
1623070Spst#define	RES_PRF_TTLID	0x00000400
1633070Spst#define	RES_PRF_HEADX	0x00000800
1643070Spst#define	RES_PRF_QUERY	0x00001000
1653070Spst#define	RES_PRF_REPLY	0x00002000
1663070Spst#define	RES_PRF_INIT    0x00004000
1673070Spst/*			0x00008000	*/
1681539Srgrimes
1693070Spsttypedef enum { res_goahead, res_nextns, res_modified, res_done, res_error }
1703070Spst	res_sendhookact;
1711539Srgrimes
1723070Spsttypedef res_sendhookact (*res_send_qhook)__P((struct sockaddr_in * const *ns,
1733070Spst					      const u_char **query,
1743070Spst					      int *querylen,
1753070Spst					      u_char *ans,
1763070Spst					      int anssiz,
1773070Spst					      int *resplen));
1783070Spst
1793070Spsttypedef res_sendhookact (*res_send_rhook)__P((const struct sockaddr_in *ns,
1803070Spst					      const u_char *query,
1813070Spst					      int querylen,
1823070Spst					      u_char *ans,
1833070Spst					      int anssiz,
1843070Spst					      int *resplen));
1853070Spst
18621055Speterstruct res_sym {
18721055Speter	int	number;		/* Identifying number, like T_MX */
18821055Speter	char *	name;		/* Its symbolic name, like "MX" */
18921055Speter	char *	humanname;	/* Its fun name, like "mail exchanger" */
19021055Speter};
19121055Speter
1921539Srgrimesextern struct __res_state _res;
19321055Speterextern const struct res_sym __p_class_syms[];
19421055Speterextern const struct res_sym __p_type_syms[];
1951539Srgrimes
1961539Srgrimes/* Private routines shared between libc/net, named, nslookup and others. */
19717902Speter#define	res_hnok	__res_hnok
19817902Speter#define	res_ownok	__res_ownok
19917902Speter#define	res_mailok	__res_mailok
20017902Speter#define	res_dnok	__res_dnok
20121055Speter#define	sym_ston	__sym_ston
20221055Speter#define	sym_ntos	__sym_ntos
20321055Speter#define	sym_ntop	__sym_ntop
20421055Speter#define	b64_ntop	__b64_ntop
20521055Speter#define	b64_pton	__b64_pton
20617902Speter#define	loc_ntoa	__loc_ntoa
20717902Speter#define	loc_aton	__loc_aton
20836898Speter#define	fp_resstat	__fp_resstat
20936898Speter#define	p_query		__p_query
2101539Srgrimes#define	dn_skipname	__dn_skipname
21121055Speter#define	fp_resstat	__fp_resstat
2121539Srgrimes#define	fp_query	__fp_query
2133070Spst#define	fp_nquery	__fp_nquery
2141539Srgrimes#define	hostalias	__hostalias
2151539Srgrimes#define	putlong		__putlong
2161539Srgrimes#define	putshort	__putshort
2173070Spst#define	p_class		__p_class
2183070Spst#define	p_time		__p_time
2193070Spst#define	p_type		__p_type
22021055Speter#define	p_query		__p_query
2213070Spst#define	p_cdnname	__p_cdnname
22236898Speter#define	p_section	__p_section
2233070Spst#define	p_cdname	__p_cdname
22421055Speter#define	p_fqnname	__p_fqnname
2253070Spst#define	p_fqname	__p_fqname
2263070Spst#define	p_option	__p_option
22721055Speter#define	p_secstodate	__p_secstodate
22821055Speter#define	dn_count_labels	__dn_count_labels
22921055Speter#define	dn_comp		__dn_comp
23036898Speter#define	dn_expand	__dn_expand
23136898Speter#define	res_init	__res_init
23210132Speter#define	res_randomid	__res_randomid
23336898Speter#define	res_query	__res_query
23436898Speter#define	res_search	__res_search
23536898Speter#define	res_querydomain	__res_querydomain
23636898Speter#define	res_mkquery	__res_mkquery
23736898Speter#define	res_send	__res_send
23810132Speter#define	res_isourserver	__res_isourserver
23910132Speter#define	res_nameinquery	__res_nameinquery
24010132Speter#define	res_queriesmatch __res_queriesmatch
24121055Speter#define	res_close	__res_close
24236898Speter#define	res_mkupdate	__res_mkupdate
24336898Speter#define	res_mkupdrec	__res_mkupdrec
24436898Speter#define	res_freeupdrec	__res_freeupdrec
2453070Spst
2461539Srgrimes__BEGIN_DECLS
24721055Speterint		res_hnok __P((const char *));
24821055Speterint		res_ownok __P((const char *));
24921055Speterint		res_mailok __P((const char *));
25021055Speterint		res_dnok __P((const char *));
25136888Speterint		sym_ston __P((const struct res_sym *, const char *, int *));
25221055Speterconst char *	sym_ntos __P((const struct res_sym *, int, int *));
25321055Speterconst char *	sym_ntop __P((const struct res_sym *, int, int *));
25421055Speterint		b64_ntop __P((u_char const *, size_t, char *, size_t));
25521055Speterint		b64_pton __P((char const *, u_char *, size_t));
25621055Speterint		loc_aton __P((const char *, u_char *));
25721055Speterconst char *	loc_ntoa __P((const u_char *, char *));
25821055Speterint		dn_skipname __P((const u_char *, const u_char *));
25921055Spetervoid		fp_resstat __P((struct __res_state *, FILE *));
26021055Spetervoid		fp_query __P((const u_char *, FILE *));
26121055Spetervoid		fp_nquery __P((const u_char *, int, FILE *));
26221055Speterconst char *	hostalias __P((const char *));
26321055Spetervoid		putlong __P((u_int32_t, u_char *));
26421055Spetervoid		putshort __P((u_int16_t, u_char *));
26521055Speterconst char *	p_class __P((int));
26621055Speterconst char *	p_time __P((u_int32_t));
26721055Speterconst char *	p_type __P((int));
26821055Spetervoid		p_query __P((const u_char *));
26921055Speterconst u_char *	p_cdnname __P((const u_char *, const u_char *, int, FILE *));
27021055Speterconst u_char *	p_cdname __P((const u_char *, const u_char *, FILE *));
27121055Speterconst u_char *	p_fqnname __P((const u_char *, const u_char *,
27221055Speter			       int, char *, int));
27321055Speterconst u_char *	p_fqname __P((const u_char *, const u_char *, FILE *));
27421055Speterconst char *	p_option __P((u_long));
27521055Speterchar *		p_secstodate __P((u_long));
27636888Speterint		dn_count_labels __P((const char *));
27721055Speterint		dn_comp __P((const char *, u_char *, int,
27821055Speter			     u_char **, u_char **));
27921055Speterint		dn_expand __P((const u_char *, const u_char *, const u_char *,
28021055Speter			       char *, int));
28121055Speterint		res_init __P((void));
28221055Speteru_int		res_randomid __P((void));
28321055Speterint		res_query __P((const char *, int, int, u_char *, int));
28421055Speterint		res_search __P((const char *, int, int, u_char *, int));
28521055Speterint		res_querydomain __P((const char *, const char *, int, int,
28621055Speter				     u_char *, int));
28721055Speterint		res_mkquery __P((int, const char *, int, int, const u_char *,
28821055Speter				 int, const u_char *, u_char *, int));
28921055Speterint		res_send __P((const u_char *, int, u_char *, int));
29021055Speterint		res_isourserver __P((const struct sockaddr_in *));
29121055Speterint		res_nameinquery __P((const char *, int, int,
29221055Speter				     const u_char *, const u_char *));
29321055Speterint		res_queriesmatch __P((const u_char *, const u_char *,
29421055Speter				      const u_char *, const u_char *));
29521055Spetervoid		res_close __P((void));
29636888Speterconst char *	p_section __P((int, int));
29736898Speter/* XXX The following depend on the ns_updrec typedef in arpa/nameser.h */
29836898Speter#ifdef _ARPA_NAMESER_H_
29936888Speterint		res_update __P((ns_updrec *));
30036888Speterint		res_mkupdate __P((ns_updrec *, u_char *, int));
30136888Speterns_updrec *	res_mkupdrec __P((int, const char *, u_int, u_int, u_long));
30236888Spetervoid		res_freeupdrec __P((ns_updrec *));
30336898Speter#endif
3041539Srgrimes__END_DECLS
3051539Srgrimes
3061539Srgrimes#endif /* !_RESOLV_H_ */
307