xref: /freebsd/include/arpa/nameser.h (revision 42b388439bd3795e09258c57a74ce9eec3651c7b)
1*6e778a7eSPedro F. Giffuni /*-
2*6e778a7eSPedro F. Giffuni  * SPDX-License-Identifier: (ISC AND BSD-3-Clause)
3*6e778a7eSPedro F. Giffuni  *
4046c3635SPedro F. Giffuni  * Portions Copyright (C) 2004, 2005, 2008, 2009  Internet Systems Consortium, Inc. ("ISC")
5046c3635SPedro F. Giffuni  * Portions Copyright (C) 1996-2003  Internet Software Consortium.
6046c3635SPedro F. Giffuni  *
7046c3635SPedro F. Giffuni  * Permission to use, copy, modify, and/or distribute this software for any
8046c3635SPedro F. Giffuni  * purpose with or without fee is hereby granted, provided that the above
9046c3635SPedro F. Giffuni  * copyright notice and this permission notice appear in all copies.
10046c3635SPedro F. Giffuni  *
11046c3635SPedro F. Giffuni  * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
12046c3635SPedro F. Giffuni  * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
13046c3635SPedro F. Giffuni  * AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
14046c3635SPedro F. Giffuni  * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
15046c3635SPedro F. Giffuni  * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
16046c3635SPedro F. Giffuni  * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17046c3635SPedro F. Giffuni  * PERFORMANCE OF THIS SOFTWARE.
18046c3635SPedro F. Giffuni  */
19046c3635SPedro F. Giffuni 
202321c474SPedro F. Giffuni /*-
2159deaec5SRodney W. Grimes  * Copyright (c) 1983, 1989, 1993
2259deaec5SRodney W. Grimes  *    The Regents of the University of California.  All rights reserved.
2359deaec5SRodney W. Grimes  *
2459deaec5SRodney W. Grimes  * Redistribution and use in source and binary forms, with or without
2559deaec5SRodney W. Grimes  * modification, are permitted provided that the following conditions
2659deaec5SRodney W. Grimes  * are met:
2759deaec5SRodney W. Grimes  * 1. Redistributions of source code must retain the above copyright
2859deaec5SRodney W. Grimes  *    notice, this list of conditions and the following disclaimer.
2959deaec5SRodney W. Grimes  * 2. Redistributions in binary form must reproduce the above copyright
3059deaec5SRodney W. Grimes  *    notice, this list of conditions and the following disclaimer in the
3159deaec5SRodney W. Grimes  *    documentation and/or other materials provided with the distribution.
322cca9f8fSWarner Losh  * 3. Neither the name of the University nor the names of its contributors
3359deaec5SRodney W. Grimes  *    may be used to endorse or promote products derived from this software
3459deaec5SRodney W. Grimes  *    without specific prior written permission.
3559deaec5SRodney W. Grimes  *
3659deaec5SRodney W. Grimes  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
3759deaec5SRodney W. Grimes  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
3859deaec5SRodney W. Grimes  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
3959deaec5SRodney W. Grimes  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
4059deaec5SRodney W. Grimes  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
4159deaec5SRodney W. Grimes  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
4259deaec5SRodney W. Grimes  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
4359deaec5SRodney W. Grimes  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
4459deaec5SRodney W. Grimes  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
4559deaec5SRodney W. Grimes  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
4659deaec5SRodney W. Grimes  * SUCH DAMAGE.
470160f9c0SPeter Wemm  */
480160f9c0SPeter Wemm 
490160f9c0SPeter Wemm /*
50046c3635SPedro F. Giffuni  *	$Id: nameser.h,v 1.16 2009/03/03 01:52:48 each Exp $
5159deaec5SRodney W. Grimes  */
5259deaec5SRodney W. Grimes 
53d58a9efdSPeter Wemm #ifndef _ARPA_NAMESER_H_
54d58a9efdSPeter Wemm #define _ARPA_NAMESER_H_
5559deaec5SRodney W. Grimes 
56dde4a85dSHajimu UMEMOTO /*! \file */
57dde4a85dSHajimu UMEMOTO 
580160f9c0SPeter Wemm #define BIND_4_COMPAT
590160f9c0SPeter Wemm 
605342d17fSHajimu UMEMOTO #include <sys/param.h>
6159deaec5SRodney W. Grimes #include <sys/types.h>
621363f04cSPaul Traina #include <sys/cdefs.h>
631363f04cSPaul Traina 
64dde4a85dSHajimu UMEMOTO /*%
655342d17fSHajimu UMEMOTO  * Revision information.  This is the release date in YYYYMMDD format.
665342d17fSHajimu UMEMOTO  * It can change every day so the right thing to do with it is use it
675342d17fSHajimu UMEMOTO  * in preprocessor commands such as "#if (__NAMESER > 19931104)".  Do not
685342d17fSHajimu UMEMOTO  * compare for equality; rather, use it to determine whether your libbind.a
695342d17fSHajimu UMEMOTO  * contains a new enough lib/nameser/ to support the feature you need.
701363f04cSPaul Traina  */
711363f04cSPaul Traina 
72046c3635SPedro F. Giffuni #define __NAMESER	20090302	/*%< New interface version stamp. */
7359deaec5SRodney W. Grimes /*
74dde4a85dSHajimu UMEMOTO  * Define constants based on RFC0883, RFC1034, RFC 1035
7559deaec5SRodney W. Grimes  */
76dde4a85dSHajimu UMEMOTO #define NS_PACKETSZ	512	/*%< default UDP packet size */
77046c3635SPedro F. Giffuni #define NS_MAXDNAME	1025	/*%< maximum domain name (presentation format)*/
78dde4a85dSHajimu UMEMOTO #define NS_MAXMSG	65535	/*%< maximum message size */
79dde4a85dSHajimu UMEMOTO #define NS_MAXCDNAME	255	/*%< maximum compressed domain name */
80dde4a85dSHajimu UMEMOTO #define NS_MAXLABEL	63	/*%< maximum length of domain label */
81046c3635SPedro F. Giffuni #define NS_MAXLABELS	128	/*%< theoretical max #/labels per domain name */
82046c3635SPedro F. Giffuni #define NS_MAXNNAME	256	/*%< maximum uncompressed (binary) domain name*/
83046c3635SPedro F. Giffuni #define	NS_MAXPADDR	(sizeof "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff")
84dde4a85dSHajimu UMEMOTO #define NS_HFIXEDSZ	12	/*%< #/bytes of fixed data in header */
85dde4a85dSHajimu UMEMOTO #define NS_QFIXEDSZ	4	/*%< #/bytes of fixed data in query */
86dde4a85dSHajimu UMEMOTO #define NS_RRFIXEDSZ	10	/*%< #/bytes of fixed data in r record */
87dde4a85dSHajimu UMEMOTO #define NS_INT32SZ	4	/*%< #/bytes of data in a u_int32_t */
88dde4a85dSHajimu UMEMOTO #define NS_INT16SZ	2	/*%< #/bytes of data in a u_int16_t */
89dde4a85dSHajimu UMEMOTO #define NS_INT8SZ	1	/*%< #/bytes of data in a u_int8_t */
90dde4a85dSHajimu UMEMOTO #define NS_INADDRSZ	4	/*%< IPv4 T_A */
91dde4a85dSHajimu UMEMOTO #define NS_IN6ADDRSZ	16	/*%< IPv6 T_AAAA */
92dde4a85dSHajimu UMEMOTO #define NS_CMPRSFLGS	0xc0	/*%< Flag bits indicating name compression. */
93dde4a85dSHajimu UMEMOTO #define NS_DEFAULTPORT	53	/*%< For both TCP and UDP. */
9459deaec5SRodney W. Grimes /*
950160f9c0SPeter Wemm  * These can be expanded with synonyms, just keep ns_parse.c:ns_parserecord()
960160f9c0SPeter Wemm  * in synch with it.
9759deaec5SRodney W. Grimes  */
980160f9c0SPeter Wemm typedef enum __ns_sect {
99dde4a85dSHajimu UMEMOTO 	ns_s_qd = 0,		/*%< Query: Question. */
100dde4a85dSHajimu UMEMOTO 	ns_s_zn = 0,		/*%< Update: Zone. */
101dde4a85dSHajimu UMEMOTO 	ns_s_an = 1,		/*%< Query: Answer. */
102dde4a85dSHajimu UMEMOTO 	ns_s_pr = 1,		/*%< Update: Prerequisites. */
103dde4a85dSHajimu UMEMOTO 	ns_s_ns = 2,		/*%< Query: Name servers. */
104dde4a85dSHajimu UMEMOTO 	ns_s_ud = 2,		/*%< Update: Update. */
105dde4a85dSHajimu UMEMOTO 	ns_s_ar = 3,		/*%< Query|Update: Additional records. */
1060160f9c0SPeter Wemm 	ns_s_max = 4
1070160f9c0SPeter Wemm } ns_sect;
10859deaec5SRodney W. Grimes 
109dde4a85dSHajimu UMEMOTO /*%
110eacd600eSPedro F. Giffuni  * Network name (compressed or not) type.  Equivalent to a pointer when used
111046c3635SPedro F. Giffuni  * in a function prototype.  Can be const'd.
112046c3635SPedro F. Giffuni  */
113046c3635SPedro F. Giffuni typedef u_char ns_nname[NS_MAXNNAME];
114046c3635SPedro F. Giffuni typedef const u_char *ns_nname_ct;
115046c3635SPedro F. Giffuni typedef u_char *ns_nname_t;
116046c3635SPedro F. Giffuni 
117046c3635SPedro F. Giffuni struct ns_namemap { ns_nname_ct base; int len; };
118046c3635SPedro F. Giffuni typedef struct ns_namemap *ns_namemap_t;
119046c3635SPedro F. Giffuni typedef const struct ns_namemap *ns_namemap_ct;
120046c3635SPedro F. Giffuni 
121046c3635SPedro F. Giffuni /*%
1220160f9c0SPeter Wemm  * This is a message handle.  It is caller allocated and has no dynamic data.
1230160f9c0SPeter Wemm  * This structure is intended to be opaque to all but ns_parse.c, thus the
1240160f9c0SPeter Wemm  * leading _'s on the member names.  Use the accessor functions, not the _'s.
12559deaec5SRodney W. Grimes  */
1260160f9c0SPeter Wemm typedef struct __ns_msg {
1270160f9c0SPeter Wemm 	const u_char	*_msg, *_eom;
1280160f9c0SPeter Wemm 	u_int16_t	_id, _flags, _counts[ns_s_max];
1290160f9c0SPeter Wemm 	const u_char	*_sections[ns_s_max];
1300160f9c0SPeter Wemm 	ns_sect		_sect;
1310160f9c0SPeter Wemm 	int		_rrnum;
1325342d17fSHajimu UMEMOTO 	const u_char	*_msg_ptr;
1330160f9c0SPeter Wemm } ns_msg;
1340160f9c0SPeter Wemm 
1350160f9c0SPeter Wemm /* Private data structure - do not use from outside library. */
1360160f9c0SPeter Wemm struct _ns_flagdata {  int mask, shift;  };
1370160f9c0SPeter Wemm extern struct _ns_flagdata _ns_flagdata[];
1380160f9c0SPeter Wemm 
1390160f9c0SPeter Wemm /* Accessor macros - this is part of the public interface. */
1405342d17fSHajimu UMEMOTO 
1410160f9c0SPeter Wemm #define ns_msg_id(handle) ((handle)._id + 0)
1420160f9c0SPeter Wemm #define ns_msg_base(handle) ((handle)._msg + 0)
1430160f9c0SPeter Wemm #define ns_msg_end(handle) ((handle)._eom + 0)
1440160f9c0SPeter Wemm #define ns_msg_size(handle) ((handle)._eom - (handle)._msg)
1450160f9c0SPeter Wemm #define ns_msg_count(handle, section) ((handle)._counts[section] + 0)
14659deaec5SRodney W. Grimes 
147dde4a85dSHajimu UMEMOTO /*%
1480160f9c0SPeter Wemm  * This is a parsed record.  It is caller allocated and has no dynamic data.
14959deaec5SRodney W. Grimes  */
1500160f9c0SPeter Wemm typedef	struct __ns_rr {
1515342d17fSHajimu UMEMOTO 	char		name[NS_MAXDNAME];
1520160f9c0SPeter Wemm 	u_int16_t	type;
153f05a5680SPeter Wemm 	u_int16_t	rr_class;
1540160f9c0SPeter Wemm 	u_int32_t	ttl;
1550160f9c0SPeter Wemm 	u_int16_t	rdlength;
1560160f9c0SPeter Wemm 	const u_char *	rdata;
1570160f9c0SPeter Wemm } ns_rr;
1580160f9c0SPeter Wemm 
159046c3635SPedro F. Giffuni /*
160046c3635SPedro F. Giffuni  * Same thing, but using uncompressed network binary names, and real C types.
161046c3635SPedro F. Giffuni  */
162046c3635SPedro F. Giffuni typedef	struct __ns_rr2 {
163046c3635SPedro F. Giffuni 	ns_nname	nname;
164046c3635SPedro F. Giffuni 	size_t		nnamel;
165046c3635SPedro F. Giffuni 	int		type;
166046c3635SPedro F. Giffuni 	int		rr_class;
167046c3635SPedro F. Giffuni 	u_int		ttl;
168046c3635SPedro F. Giffuni 	int		rdlength;
169046c3635SPedro F. Giffuni 	const u_char *	rdata;
170046c3635SPedro F. Giffuni } ns_rr2;
171046c3635SPedro F. Giffuni 
1720160f9c0SPeter Wemm /* Accessor macros - this is part of the public interface. */
1730160f9c0SPeter Wemm #define ns_rr_name(rr)	(((rr).name[0] != '\0') ? (rr).name : ".")
174046c3635SPedro F. Giffuni #define ns_rr_nname(rr)	((const ns_nname_t)(rr).nname)
175046c3635SPedro F. Giffuni #define ns_rr_nnamel(rr) ((rr).nnamel + 0)
1765342d17fSHajimu UMEMOTO #define ns_rr_type(rr)	((ns_type)((rr).type + 0))
1775342d17fSHajimu UMEMOTO #define ns_rr_class(rr)	((ns_class)((rr).rr_class + 0))
1780160f9c0SPeter Wemm #define ns_rr_ttl(rr)	((rr).ttl + 0)
1790160f9c0SPeter Wemm #define ns_rr_rdlen(rr)	((rr).rdlength + 0)
1800160f9c0SPeter Wemm #define ns_rr_rdata(rr)	((rr).rdata + 0)
1810160f9c0SPeter Wemm 
182dde4a85dSHajimu UMEMOTO /*%
1830160f9c0SPeter Wemm  * These don't have to be in the same order as in the packet flags word,
1840160f9c0SPeter Wemm  * and they can even overlap in some cases, but they will need to be kept
1850160f9c0SPeter Wemm  * in synch with ns_parse.c:ns_flagdata[].
1860160f9c0SPeter Wemm  */
1870160f9c0SPeter Wemm typedef enum __ns_flag {
188dde4a85dSHajimu UMEMOTO 	ns_f_qr,		/*%< Question/Response. */
189dde4a85dSHajimu UMEMOTO 	ns_f_opcode,		/*%< Operation code. */
190dde4a85dSHajimu UMEMOTO 	ns_f_aa,		/*%< Authoritative Answer. */
191dde4a85dSHajimu UMEMOTO 	ns_f_tc,		/*%< Truncation occurred. */
192dde4a85dSHajimu UMEMOTO 	ns_f_rd,		/*%< Recursion Desired. */
193dde4a85dSHajimu UMEMOTO 	ns_f_ra,		/*%< Recursion Available. */
194dde4a85dSHajimu UMEMOTO 	ns_f_z,			/*%< MBZ. */
195dde4a85dSHajimu UMEMOTO 	ns_f_ad,		/*%< Authentic Data (DNSSEC). */
196dde4a85dSHajimu UMEMOTO 	ns_f_cd,		/*%< Checking Disabled (DNSSEC). */
197dde4a85dSHajimu UMEMOTO 	ns_f_rcode,		/*%< Response code. */
1980160f9c0SPeter Wemm 	ns_f_max
1990160f9c0SPeter Wemm } ns_flag;
2000160f9c0SPeter Wemm 
201dde4a85dSHajimu UMEMOTO /*%
2020160f9c0SPeter Wemm  * Currently defined opcodes.
2030160f9c0SPeter Wemm  */
2040160f9c0SPeter Wemm typedef enum __ns_opcode {
205dde4a85dSHajimu UMEMOTO 	ns_o_query = 0,		/*%< Standard query. */
206dde4a85dSHajimu UMEMOTO 	ns_o_iquery = 1,	/*%< Inverse query (deprecated/unsupported). */
207dde4a85dSHajimu UMEMOTO 	ns_o_status = 2,	/*%< Name server status query (unsupported). */
2080160f9c0SPeter Wemm 				/* Opcode 3 is undefined/reserved. */
209dde4a85dSHajimu UMEMOTO 	ns_o_notify = 4,	/*%< Zone change notification. */
210dde4a85dSHajimu UMEMOTO 	ns_o_update = 5,	/*%< Zone update message. */
2110160f9c0SPeter Wemm 	ns_o_max = 6
2120160f9c0SPeter Wemm } ns_opcode;
2130160f9c0SPeter Wemm 
214dde4a85dSHajimu UMEMOTO /*%
2150160f9c0SPeter Wemm  * Currently defined response codes.
2160160f9c0SPeter Wemm  */
2170160f9c0SPeter Wemm typedef	enum __ns_rcode {
218dde4a85dSHajimu UMEMOTO 	ns_r_noerror = 0,	/*%< No error occurred. */
219dde4a85dSHajimu UMEMOTO 	ns_r_formerr = 1,	/*%< Format error. */
220dde4a85dSHajimu UMEMOTO 	ns_r_servfail = 2,	/*%< Server failure. */
221dde4a85dSHajimu UMEMOTO 	ns_r_nxdomain = 3,	/*%< Name error. */
222dde4a85dSHajimu UMEMOTO 	ns_r_notimpl = 4,	/*%< Unimplemented. */
223dde4a85dSHajimu UMEMOTO 	ns_r_refused = 5,	/*%< Operation refused. */
2240160f9c0SPeter Wemm 	/* these are for BIND_UPDATE */
225dde4a85dSHajimu UMEMOTO 	ns_r_yxdomain = 6,	/*%< Name exists */
226dde4a85dSHajimu UMEMOTO 	ns_r_yxrrset = 7,	/*%< RRset exists */
227dde4a85dSHajimu UMEMOTO 	ns_r_nxrrset = 8,	/*%< RRset does not exist */
228dde4a85dSHajimu UMEMOTO 	ns_r_notauth = 9,	/*%< Not authoritative for zone */
229dde4a85dSHajimu UMEMOTO 	ns_r_notzone = 10,	/*%< Zone of record different from zone section */
2305342d17fSHajimu UMEMOTO 	ns_r_max = 11,
2315342d17fSHajimu UMEMOTO 	/* The following are EDNS extended rcodes */
2325342d17fSHajimu UMEMOTO 	ns_r_badvers = 16,
2335342d17fSHajimu UMEMOTO 	/* The following are TSIG errors */
2345342d17fSHajimu UMEMOTO 	ns_r_badsig = 16,
2355342d17fSHajimu UMEMOTO 	ns_r_badkey = 17,
2365342d17fSHajimu UMEMOTO 	ns_r_badtime = 18
2370160f9c0SPeter Wemm } ns_rcode;
2380160f9c0SPeter Wemm 
2390160f9c0SPeter Wemm /* BIND_UPDATE */
2400160f9c0SPeter Wemm typedef enum __ns_update_operation {
2410160f9c0SPeter Wemm 	ns_uop_delete = 0,
2420160f9c0SPeter Wemm 	ns_uop_add = 1,
2430160f9c0SPeter Wemm 	ns_uop_max = 2
2440160f9c0SPeter Wemm } ns_update_operation;
2450160f9c0SPeter Wemm 
246dde4a85dSHajimu UMEMOTO /*%
2475342d17fSHajimu UMEMOTO  * This structure is used for TSIG authenticated messages
2480160f9c0SPeter Wemm  */
2495342d17fSHajimu UMEMOTO struct ns_tsig_key {
2505342d17fSHajimu UMEMOTO 	char name[NS_MAXDNAME], alg[NS_MAXDNAME];
2515342d17fSHajimu UMEMOTO 	unsigned char *data;
2525342d17fSHajimu UMEMOTO 	int len;
2530160f9c0SPeter Wemm };
2545342d17fSHajimu UMEMOTO typedef struct ns_tsig_key ns_tsig_key;
2555342d17fSHajimu UMEMOTO 
256dde4a85dSHajimu UMEMOTO /*%
2575342d17fSHajimu UMEMOTO  * This structure is used for TSIG authenticated TCP messages
2585342d17fSHajimu UMEMOTO  */
2595342d17fSHajimu UMEMOTO struct ns_tcp_tsig_state {
2605342d17fSHajimu UMEMOTO 	int counter;
2615342d17fSHajimu UMEMOTO 	struct dst_key *key;
2625342d17fSHajimu UMEMOTO 	void *ctx;
2635342d17fSHajimu UMEMOTO 	unsigned char sig[NS_PACKETSZ];
2645342d17fSHajimu UMEMOTO 	int siglen;
2655342d17fSHajimu UMEMOTO };
2665342d17fSHajimu UMEMOTO typedef struct ns_tcp_tsig_state ns_tcp_tsig_state;
2675342d17fSHajimu UMEMOTO 
2685342d17fSHajimu UMEMOTO #define NS_TSIG_FUDGE 300
2695342d17fSHajimu UMEMOTO #define NS_TSIG_TCP_COUNT 100
2705342d17fSHajimu UMEMOTO #define NS_TSIG_ALG_HMAC_MD5 "HMAC-MD5.SIG-ALG.REG.INT"
2715342d17fSHajimu UMEMOTO 
2725342d17fSHajimu UMEMOTO #define NS_TSIG_ERROR_NO_TSIG -10
2735342d17fSHajimu UMEMOTO #define NS_TSIG_ERROR_NO_SPACE -11
2745342d17fSHajimu UMEMOTO #define NS_TSIG_ERROR_FORMERR -12
2750160f9c0SPeter Wemm 
276dde4a85dSHajimu UMEMOTO /*%
2770160f9c0SPeter Wemm  * Currently defined type values for resources and queries.
2780160f9c0SPeter Wemm  */
2790160f9c0SPeter Wemm typedef enum __ns_type {
280dde4a85dSHajimu UMEMOTO 	ns_t_invalid = 0,	/*%< Cookie. */
281dde4a85dSHajimu UMEMOTO 	ns_t_a = 1,		/*%< Host address. */
282dde4a85dSHajimu UMEMOTO 	ns_t_ns = 2,		/*%< Authoritative server. */
283dde4a85dSHajimu UMEMOTO 	ns_t_md = 3,		/*%< Mail destination. */
284dde4a85dSHajimu UMEMOTO 	ns_t_mf = 4,		/*%< Mail forwarder. */
285dde4a85dSHajimu UMEMOTO 	ns_t_cname = 5,		/*%< Canonical name. */
286dde4a85dSHajimu UMEMOTO 	ns_t_soa = 6,		/*%< Start of authority zone. */
287dde4a85dSHajimu UMEMOTO 	ns_t_mb = 7,		/*%< Mailbox domain name. */
288dde4a85dSHajimu UMEMOTO 	ns_t_mg = 8,		/*%< Mail group member. */
289dde4a85dSHajimu UMEMOTO 	ns_t_mr = 9,		/*%< Mail rename name. */
290dde4a85dSHajimu UMEMOTO 	ns_t_null = 10,		/*%< Null resource record. */
291dde4a85dSHajimu UMEMOTO 	ns_t_wks = 11,		/*%< Well known service. */
292dde4a85dSHajimu UMEMOTO 	ns_t_ptr = 12,		/*%< Domain name pointer. */
293dde4a85dSHajimu UMEMOTO 	ns_t_hinfo = 13,	/*%< Host information. */
294dde4a85dSHajimu UMEMOTO 	ns_t_minfo = 14,	/*%< Mailbox information. */
295dde4a85dSHajimu UMEMOTO 	ns_t_mx = 15,		/*%< Mail routing information. */
296dde4a85dSHajimu UMEMOTO 	ns_t_txt = 16,		/*%< Text strings. */
297dde4a85dSHajimu UMEMOTO 	ns_t_rp = 17,		/*%< Responsible person. */
298dde4a85dSHajimu UMEMOTO 	ns_t_afsdb = 18,	/*%< AFS cell database. */
299dde4a85dSHajimu UMEMOTO 	ns_t_x25 = 19,		/*%< X_25 calling address. */
300dde4a85dSHajimu UMEMOTO 	ns_t_isdn = 20,		/*%< ISDN calling address. */
301dde4a85dSHajimu UMEMOTO 	ns_t_rt = 21,		/*%< Router. */
302dde4a85dSHajimu UMEMOTO 	ns_t_nsap = 22,		/*%< NSAP address. */
303dde4a85dSHajimu UMEMOTO 	ns_t_nsap_ptr = 23,	/*%< Reverse NSAP lookup (deprecated). */
304dde4a85dSHajimu UMEMOTO 	ns_t_sig = 24,		/*%< Security signature. */
305dde4a85dSHajimu UMEMOTO 	ns_t_key = 25,		/*%< Security key. */
306dde4a85dSHajimu UMEMOTO 	ns_t_px = 26,		/*%< X.400 mail mapping. */
307dde4a85dSHajimu UMEMOTO 	ns_t_gpos = 27,		/*%< Geographical position (withdrawn). */
308046c3635SPedro F. Giffuni 	ns_t_aaaa = 28,		/*%< IPv6 Address. */
309dde4a85dSHajimu UMEMOTO 	ns_t_loc = 29,		/*%< Location Information. */
310dde4a85dSHajimu UMEMOTO 	ns_t_nxt = 30,		/*%< Next domain (security). */
311dde4a85dSHajimu UMEMOTO 	ns_t_eid = 31,		/*%< Endpoint identifier. */
312dde4a85dSHajimu UMEMOTO 	ns_t_nimloc = 32,	/*%< Nimrod Locator. */
313dde4a85dSHajimu UMEMOTO 	ns_t_srv = 33,		/*%< Server Selection. */
314dde4a85dSHajimu UMEMOTO 	ns_t_atma = 34,		/*%< ATM Address */
315dde4a85dSHajimu UMEMOTO 	ns_t_naptr = 35,	/*%< Naming Authority PoinTeR */
316dde4a85dSHajimu UMEMOTO 	ns_t_kx = 36,		/*%< Key Exchange */
317dde4a85dSHajimu UMEMOTO 	ns_t_cert = 37,		/*%< Certification record */
318046c3635SPedro F. Giffuni 	ns_t_a6 = 38,		/*%< IPv6 address (experimental) */
319046c3635SPedro F. Giffuni 	ns_t_dname = 39,	/*%< Non-terminal DNAME */
320dde4a85dSHajimu UMEMOTO 	ns_t_sink = 40,		/*%< Kitchen sink (experimentatl) */
321dde4a85dSHajimu UMEMOTO 	ns_t_opt = 41,		/*%< EDNS0 option (meta-RR) */
322dde4a85dSHajimu UMEMOTO 	ns_t_apl = 42,		/*%< Address prefix list (RFC3123) */
323046c3635SPedro F. Giffuni 	ns_t_ds = 43,		/*%< Delegation Signer */
324046c3635SPedro F. Giffuni 	ns_t_sshfp = 44,	/*%< SSH Fingerprint */
325046c3635SPedro F. Giffuni 	ns_t_ipseckey = 45,	/*%< IPSEC Key */
326046c3635SPedro F. Giffuni 	ns_t_rrsig = 46,	/*%< RRset Signature */
327046c3635SPedro F. Giffuni 	ns_t_nsec = 47,		/*%< Negative security */
328046c3635SPedro F. Giffuni 	ns_t_dnskey = 48,	/*%< DNS Key */
329046c3635SPedro F. Giffuni 	ns_t_dhcid = 49,	/*%< Dynamic host configuratin identifier */
330046c3635SPedro F. Giffuni 	ns_t_nsec3 = 50,	/*%< Negative security type 3 */
331046c3635SPedro F. Giffuni 	ns_t_nsec3param = 51,	/*%< Negative security type 3 parameters */
332046c3635SPedro F. Giffuni 	ns_t_hip = 55,		/*%< Host Identity Protocol */
333046c3635SPedro F. Giffuni 	ns_t_spf = 99,		/*%< Sender Policy Framework */
334dde4a85dSHajimu UMEMOTO 	ns_t_tkey = 249,	/*%< Transaction key */
335dde4a85dSHajimu UMEMOTO 	ns_t_tsig = 250,	/*%< Transaction signature. */
336dde4a85dSHajimu UMEMOTO 	ns_t_ixfr = 251,	/*%< Incremental zone transfer. */
337dde4a85dSHajimu UMEMOTO 	ns_t_axfr = 252,	/*%< Transfer zone of authority. */
338dde4a85dSHajimu UMEMOTO 	ns_t_mailb = 253,	/*%< Transfer mailbox records. */
339dde4a85dSHajimu UMEMOTO 	ns_t_maila = 254,	/*%< Transfer mail agent records. */
340dde4a85dSHajimu UMEMOTO 	ns_t_any = 255,		/*%< Wildcard match. */
341dde4a85dSHajimu UMEMOTO 	ns_t_zxfr = 256,	/*%< BIND-specific, nonstandard. */
342046c3635SPedro F. Giffuni 	ns_t_dlv = 32769,	/*%< DNSSEC look-aside validatation. */
3430160f9c0SPeter Wemm 	ns_t_max = 65536
3440160f9c0SPeter Wemm } ns_type;
34559deaec5SRodney W. Grimes 
3465342d17fSHajimu UMEMOTO /* Exclusively a QTYPE? (not also an RTYPE) */
3475342d17fSHajimu UMEMOTO #define	ns_t_qt_p(t) (ns_t_xfr_p(t) || (t) == ns_t_any || \
3485342d17fSHajimu UMEMOTO 		      (t) == ns_t_mailb || (t) == ns_t_maila)
3495342d17fSHajimu UMEMOTO /* Some kind of meta-RR? (not a QTYPE, but also not an RTYPE) */
3505342d17fSHajimu UMEMOTO #define	ns_t_mrr_p(t) ((t) == ns_t_tsig || (t) == ns_t_opt)
3515342d17fSHajimu UMEMOTO /* Exclusively an RTYPE? (not also a QTYPE or a meta-RR) */
3525342d17fSHajimu UMEMOTO #define ns_t_rr_p(t) (!ns_t_qt_p(t) && !ns_t_mrr_p(t))
3535342d17fSHajimu UMEMOTO #define ns_t_udp_p(t) ((t) != ns_t_axfr && (t) != ns_t_zxfr)
3545342d17fSHajimu UMEMOTO #define ns_t_xfr_p(t) ((t) == ns_t_axfr || (t) == ns_t_ixfr || \
3555342d17fSHajimu UMEMOTO 		       (t) == ns_t_zxfr)
3565342d17fSHajimu UMEMOTO 
357dde4a85dSHajimu UMEMOTO /*%
35859deaec5SRodney W. Grimes  * Values for class field
35959deaec5SRodney W. Grimes  */
3600160f9c0SPeter Wemm typedef enum __ns_class {
361dde4a85dSHajimu UMEMOTO 	ns_c_invalid = 0,	/*%< Cookie. */
362dde4a85dSHajimu UMEMOTO 	ns_c_in = 1,		/*%< Internet. */
363dde4a85dSHajimu UMEMOTO 	ns_c_2 = 2,		/*%< unallocated/unsupported. */
364dde4a85dSHajimu UMEMOTO 	ns_c_chaos = 3,		/*%< MIT Chaos-net. */
365dde4a85dSHajimu UMEMOTO 	ns_c_hs = 4,		/*%< MIT Hesiod. */
36659deaec5SRodney W. Grimes 	/* Query class values which do not appear in resource records */
367dde4a85dSHajimu UMEMOTO 	ns_c_none = 254,	/*%< for prereq. sections in update requests */
368dde4a85dSHajimu UMEMOTO 	ns_c_any = 255,		/*%< Wildcard match. */
3690160f9c0SPeter Wemm 	ns_c_max = 65536
3700160f9c0SPeter Wemm } ns_class;
37159deaec5SRodney W. Grimes 
3725342d17fSHajimu UMEMOTO /* DNSSEC constants. */
3735342d17fSHajimu UMEMOTO 
3745342d17fSHajimu UMEMOTO typedef enum __ns_key_types {
375dde4a85dSHajimu UMEMOTO 	ns_kt_rsa = 1,		/*%< key type RSA/MD5 */
376dde4a85dSHajimu UMEMOTO 	ns_kt_dh  = 2,		/*%< Diffie Hellman */
377dde4a85dSHajimu UMEMOTO 	ns_kt_dsa = 3,		/*%< Digital Signature Standard (MANDATORY) */
378dde4a85dSHajimu UMEMOTO 	ns_kt_private = 254	/*%< Private key type starts with OID */
3795342d17fSHajimu UMEMOTO } ns_key_types;
3805342d17fSHajimu UMEMOTO 
3815342d17fSHajimu UMEMOTO typedef enum __ns_cert_types {
382dde4a85dSHajimu UMEMOTO 	cert_t_pkix = 1,	/*%< PKIX (X.509v3) */
383dde4a85dSHajimu UMEMOTO 	cert_t_spki = 2,	/*%< SPKI */
384dde4a85dSHajimu UMEMOTO 	cert_t_pgp  = 3,	/*%< PGP */
385dde4a85dSHajimu UMEMOTO 	cert_t_url  = 253,	/*%< URL private type */
386dde4a85dSHajimu UMEMOTO 	cert_t_oid  = 254	/*%< OID private type */
3875342d17fSHajimu UMEMOTO } ns_cert_types;
3885342d17fSHajimu UMEMOTO 
3895342d17fSHajimu UMEMOTO /* Flags field of the KEY RR rdata. */
390dde4a85dSHajimu UMEMOTO #define	NS_KEY_TYPEMASK		0xC000	/*%< Mask for "type" bits */
391dde4a85dSHajimu UMEMOTO #define	NS_KEY_TYPE_AUTH_CONF	0x0000	/*%< Key usable for both */
392dde4a85dSHajimu UMEMOTO #define	NS_KEY_TYPE_CONF_ONLY	0x8000	/*%< Key usable for confidentiality */
393dde4a85dSHajimu UMEMOTO #define	NS_KEY_TYPE_AUTH_ONLY	0x4000	/*%< Key usable for authentication */
394dde4a85dSHajimu UMEMOTO #define	NS_KEY_TYPE_NO_KEY	0xC000	/*%< No key usable for either; no key */
395f3f42e96SPeter Wemm /* The type bits can also be interpreted independently, as single bits: */
396dde4a85dSHajimu UMEMOTO #define	NS_KEY_NO_AUTH		0x8000	/*%< Key unusable for authentication */
397dde4a85dSHajimu UMEMOTO #define	NS_KEY_NO_CONF		0x4000	/*%< Key unusable for confidentiality */
3985342d17fSHajimu UMEMOTO #define	NS_KEY_RESERVED2	0x2000	/* Security is *mandatory* if bit=0 */
399dde4a85dSHajimu UMEMOTO #define	NS_KEY_EXTENDED_FLAGS	0x1000	/*%< reserved - must be zero */
400dde4a85dSHajimu UMEMOTO #define	NS_KEY_RESERVED4	0x0800  /*%< reserved - must be zero */
401dde4a85dSHajimu UMEMOTO #define	NS_KEY_RESERVED5	0x0400  /*%< reserved - must be zero */
402dde4a85dSHajimu UMEMOTO #define	NS_KEY_NAME_TYPE	0x0300	/*%< these bits determine the type */
403dde4a85dSHajimu UMEMOTO #define	NS_KEY_NAME_USER	0x0000	/*%< key is assoc. with user */
404dde4a85dSHajimu UMEMOTO #define	NS_KEY_NAME_ENTITY	0x0200	/*%< key is assoc. with entity eg host */
405dde4a85dSHajimu UMEMOTO #define	NS_KEY_NAME_ZONE	0x0100	/*%< key is zone key */
406dde4a85dSHajimu UMEMOTO #define	NS_KEY_NAME_RESERVED	0x0300	/*%< reserved meaning */
407dde4a85dSHajimu UMEMOTO #define	NS_KEY_RESERVED8	0x0080  /*%< reserved - must be zero */
408dde4a85dSHajimu UMEMOTO #define	NS_KEY_RESERVED9	0x0040  /*%< reserved - must be zero */
409dde4a85dSHajimu UMEMOTO #define	NS_KEY_RESERVED10	0x0020  /*%< reserved - must be zero */
410dde4a85dSHajimu UMEMOTO #define	NS_KEY_RESERVED11	0x0010  /*%< reserved - must be zero */
411dde4a85dSHajimu UMEMOTO #define	NS_KEY_SIGNATORYMASK	0x000F	/*%< key can sign RR's of same name */
4125342d17fSHajimu UMEMOTO #define	NS_KEY_RESERVED_BITMASK ( NS_KEY_RESERVED2 | \
4130160f9c0SPeter Wemm 				  NS_KEY_RESERVED4 | \
4145342d17fSHajimu UMEMOTO 				  NS_KEY_RESERVED5 | \
4155342d17fSHajimu UMEMOTO 				  NS_KEY_RESERVED8 | \
4165342d17fSHajimu UMEMOTO 				  NS_KEY_RESERVED9 | \
4170160f9c0SPeter Wemm 				  NS_KEY_RESERVED10 | \
4180160f9c0SPeter Wemm 				  NS_KEY_RESERVED11 )
419dde4a85dSHajimu UMEMOTO #define NS_KEY_RESERVED_BITMASK2 0xFFFF /*%< no bits defined here */
420f3f42e96SPeter Wemm /* The Algorithm field of the KEY and SIG RR's is an integer, {1..254} */
421dde4a85dSHajimu UMEMOTO #define	NS_ALG_MD5RSA		1	/*%< MD5 with RSA */
422dde4a85dSHajimu UMEMOTO #define	NS_ALG_DH               2	/*%< Diffie Hellman KEY */
423dde4a85dSHajimu UMEMOTO #define	NS_ALG_DSA              3	/*%< DSA KEY */
4245342d17fSHajimu UMEMOTO #define	NS_ALG_DSS              NS_ALG_DSA
425dde4a85dSHajimu UMEMOTO #define	NS_ALG_EXPIRE_ONLY	253	/*%< No alg, no security */
426dde4a85dSHajimu UMEMOTO #define	NS_ALG_PRIVATE_OID	254	/*%< Key begins with OID giving alg */
4275342d17fSHajimu UMEMOTO /* Protocol values  */
4285342d17fSHajimu UMEMOTO /* value 0 is reserved */
4295342d17fSHajimu UMEMOTO #define NS_KEY_PROT_TLS         1
4305342d17fSHajimu UMEMOTO #define NS_KEY_PROT_EMAIL       2
4315342d17fSHajimu UMEMOTO #define NS_KEY_PROT_DNSSEC      3
4325342d17fSHajimu UMEMOTO #define NS_KEY_PROT_IPSEC       4
4335342d17fSHajimu UMEMOTO #define NS_KEY_PROT_ANY		255
4345342d17fSHajimu UMEMOTO 
435f3f42e96SPeter Wemm /* Signatures */
436dde4a85dSHajimu UMEMOTO #define	NS_MD5RSA_MIN_BITS	 512	/*%< Size of a mod or exp in bits */
4375342d17fSHajimu UMEMOTO #define	NS_MD5RSA_MAX_BITS	4096
4380160f9c0SPeter Wemm 	/* Total of binary mod and exp */
4390160f9c0SPeter Wemm #define	NS_MD5RSA_MAX_BYTES	((NS_MD5RSA_MAX_BITS+7/8)*2+3)
440f3f42e96SPeter Wemm 	/* Max length of text sig block */
4410160f9c0SPeter Wemm #define	NS_MD5RSA_MAX_BASE64	(((NS_MD5RSA_MAX_BYTES+2)/3)*4)
4425342d17fSHajimu UMEMOTO #define NS_MD5RSA_MIN_SIZE	((NS_MD5RSA_MIN_BITS+7)/8)
4435342d17fSHajimu UMEMOTO #define NS_MD5RSA_MAX_SIZE	((NS_MD5RSA_MAX_BITS+7)/8)
4445342d17fSHajimu UMEMOTO 
4455342d17fSHajimu UMEMOTO #define NS_DSA_SIG_SIZE         41
4465342d17fSHajimu UMEMOTO #define NS_DSA_MIN_SIZE         213
4475342d17fSHajimu UMEMOTO #define NS_DSA_MAX_BYTES        405
448f3f42e96SPeter Wemm 
4490160f9c0SPeter Wemm /* Offsets into SIG record rdata to find various values */
450dde4a85dSHajimu UMEMOTO #define	NS_SIG_TYPE	0	/*%< Type flags */
451dde4a85dSHajimu UMEMOTO #define	NS_SIG_ALG	2	/*%< Algorithm */
452dde4a85dSHajimu UMEMOTO #define	NS_SIG_LABELS	3	/*%< How many labels in name */
453dde4a85dSHajimu UMEMOTO #define	NS_SIG_OTTL	4	/*%< Original TTL */
454dde4a85dSHajimu UMEMOTO #define	NS_SIG_EXPIR	8	/*%< Expiration time */
455dde4a85dSHajimu UMEMOTO #define	NS_SIG_SIGNED	12	/*%< Signature time */
456dde4a85dSHajimu UMEMOTO #define	NS_SIG_FOOT	16	/*%< Key footprint */
457dde4a85dSHajimu UMEMOTO #define	NS_SIG_SIGNER	18	/*%< Domain name of who signed it */
4580160f9c0SPeter Wemm /* How RR types are represented as bit-flags in NXT records */
4590160f9c0SPeter Wemm #define	NS_NXT_BITS 8
4600160f9c0SPeter Wemm #define	NS_NXT_BIT_SET(  n,p) (p[(n)/NS_NXT_BITS] |=  (0x80>>((n)%NS_NXT_BITS)))
4610160f9c0SPeter Wemm #define	NS_NXT_BIT_CLEAR(n,p) (p[(n)/NS_NXT_BITS] &= ~(0x80>>((n)%NS_NXT_BITS)))
4620160f9c0SPeter Wemm #define	NS_NXT_BIT_ISSET(n,p) (p[(n)/NS_NXT_BITS] &   (0x80>>((n)%NS_NXT_BITS)))
4635342d17fSHajimu UMEMOTO #define NS_NXT_MAX 127
464f3f42e96SPeter Wemm 
465dde4a85dSHajimu UMEMOTO /*%
46654ebdd63SHajimu UMEMOTO  * EDNS0 extended flags and option codes, host order.
4675342d17fSHajimu UMEMOTO  */
4685342d17fSHajimu UMEMOTO #define NS_OPT_DNSSEC_OK	0x8000U
46954ebdd63SHajimu UMEMOTO #define NS_OPT_NSID             3
47059deaec5SRodney W. Grimes 
471dde4a85dSHajimu UMEMOTO /*%
47259deaec5SRodney W. Grimes  * Inline versions of get/put short/long.  Pointer is advanced.
47359deaec5SRodney W. Grimes  */
4745342d17fSHajimu UMEMOTO #define NS_GET16(s, cp) do { \
4755342d17fSHajimu UMEMOTO 	register const u_char *t_cp = (const u_char *)(cp); \
4761363f04cSPaul Traina 	(s) = ((u_int16_t)t_cp[0] << 8) \
4771363f04cSPaul Traina 	    | ((u_int16_t)t_cp[1]) \
4781363f04cSPaul Traina 	    ; \
4790160f9c0SPeter Wemm 	(cp) += NS_INT16SZ; \
4805342d17fSHajimu UMEMOTO } while (0)
48159deaec5SRodney W. Grimes 
4825342d17fSHajimu UMEMOTO #define NS_GET32(l, cp) do { \
4835342d17fSHajimu UMEMOTO 	register const u_char *t_cp = (const u_char *)(cp); \
4841363f04cSPaul Traina 	(l) = ((u_int32_t)t_cp[0] << 24) \
4851363f04cSPaul Traina 	    | ((u_int32_t)t_cp[1] << 16) \
4861363f04cSPaul Traina 	    | ((u_int32_t)t_cp[2] << 8) \
4871363f04cSPaul Traina 	    | ((u_int32_t)t_cp[3]) \
4881363f04cSPaul Traina 	    ; \
4890160f9c0SPeter Wemm 	(cp) += NS_INT32SZ; \
4905342d17fSHajimu UMEMOTO } while (0)
49159deaec5SRodney W. Grimes 
4925342d17fSHajimu UMEMOTO #define NS_PUT16(s, cp) do { \
49359deaec5SRodney W. Grimes 	register u_int16_t t_s = (u_int16_t)(s); \
49459deaec5SRodney W. Grimes 	register u_char *t_cp = (u_char *)(cp); \
49559deaec5SRodney W. Grimes 	*t_cp++ = t_s >> 8; \
49659deaec5SRodney W. Grimes 	*t_cp   = t_s; \
4970160f9c0SPeter Wemm 	(cp) += NS_INT16SZ; \
4985342d17fSHajimu UMEMOTO } while (0)
49959deaec5SRodney W. Grimes 
5005342d17fSHajimu UMEMOTO #define NS_PUT32(l, cp) do { \
50159deaec5SRodney W. Grimes 	register u_int32_t t_l = (u_int32_t)(l); \
50259deaec5SRodney W. Grimes 	register u_char *t_cp = (u_char *)(cp); \
50359deaec5SRodney W. Grimes 	*t_cp++ = t_l >> 24; \
50459deaec5SRodney W. Grimes 	*t_cp++ = t_l >> 16; \
50559deaec5SRodney W. Grimes 	*t_cp++ = t_l >> 8; \
50659deaec5SRodney W. Grimes 	*t_cp   = t_l; \
5070160f9c0SPeter Wemm 	(cp) += NS_INT32SZ; \
5085342d17fSHajimu UMEMOTO } while (0)
50959deaec5SRodney W. Grimes 
510dde4a85dSHajimu UMEMOTO /*%
5115342d17fSHajimu UMEMOTO  * ANSI C identifier hiding for bind's lib/nameser.
5120160f9c0SPeter Wemm  */
5135342d17fSHajimu UMEMOTO #define	ns_msg_getflag		__ns_msg_getflag
5140160f9c0SPeter Wemm #define ns_get16		__ns_get16
5150160f9c0SPeter Wemm #define ns_get32		__ns_get32
5160160f9c0SPeter Wemm #define ns_put16		__ns_put16
5170160f9c0SPeter Wemm #define ns_put32		__ns_put32
5180160f9c0SPeter Wemm #define ns_initparse		__ns_initparse
5195342d17fSHajimu UMEMOTO #define ns_skiprr		__ns_skiprr
5200160f9c0SPeter Wemm #define ns_parserr		__ns_parserr
521046c3635SPedro F. Giffuni #define ns_parserr2		__ns_parserr2
5220160f9c0SPeter Wemm #define	ns_sprintrr		__ns_sprintrr
5230160f9c0SPeter Wemm #define	ns_sprintrrf		__ns_sprintrrf
5240160f9c0SPeter Wemm #define	ns_format_ttl		__ns_format_ttl
5250160f9c0SPeter Wemm #define	ns_parse_ttl		__ns_parse_ttl
5265342d17fSHajimu UMEMOTO #if 0
5275342d17fSHajimu UMEMOTO #define ns_datetosecs		__ns_datetosecs
5285342d17fSHajimu UMEMOTO #endif
5295342d17fSHajimu UMEMOTO #define	ns_name_ntol		__ns_name_ntol
5300160f9c0SPeter Wemm #define	ns_name_ntop		__ns_name_ntop
5310160f9c0SPeter Wemm #define	ns_name_pton		__ns_name_pton
532046c3635SPedro F. Giffuni #define	ns_name_pton2		__ns_name_pton2
5330160f9c0SPeter Wemm #define	ns_name_unpack		__ns_name_unpack
534046c3635SPedro F. Giffuni #define	ns_name_unpack2		__ns_name_unpack2
5350160f9c0SPeter Wemm #define	ns_name_pack		__ns_name_pack
5360160f9c0SPeter Wemm #define	ns_name_compress	__ns_name_compress
5370160f9c0SPeter Wemm #define	ns_name_uncompress	__ns_name_uncompress
538a1848754SHajimu UMEMOTO #define	ns_name_skip		__ns_name_skip
5395342d17fSHajimu UMEMOTO #define	ns_name_rollback	__ns_name_rollback
540046c3635SPedro F. Giffuni #define	ns_name_length		__ns_name_length
541046c3635SPedro F. Giffuni #define	ns_name_eq		__ns_name_eq
542046c3635SPedro F. Giffuni #define	ns_name_owned		__ns_name_owned
543046c3635SPedro F. Giffuni #define	ns_name_map		__ns_name_map
544046c3635SPedro F. Giffuni #define	ns_name_labels		__ns_name_labels
5455342d17fSHajimu UMEMOTO #if 0
5465342d17fSHajimu UMEMOTO #define	ns_sign			__ns_sign
5475342d17fSHajimu UMEMOTO #define	ns_sign2		__ns_sign2
5485342d17fSHajimu UMEMOTO #define	ns_sign_tcp		__ns_sign_tcp
5495342d17fSHajimu UMEMOTO #define	ns_sign_tcp2		__ns_sign_tcp2
5505342d17fSHajimu UMEMOTO #define	ns_sign_tcp_init	__ns_sign_tcp_init
5515342d17fSHajimu UMEMOTO #define ns_find_tsig		__ns_find_tsig
5525342d17fSHajimu UMEMOTO #define	ns_verify		__ns_verify
5535342d17fSHajimu UMEMOTO #define	ns_verify_tcp		__ns_verify_tcp
5545342d17fSHajimu UMEMOTO #define	ns_verify_tcp_init	__ns_verify_tcp_init
555d808369aSHajimu UMEMOTO #endif
5565342d17fSHajimu UMEMOTO #define	ns_samedomain		__ns_samedomain
557d808369aSHajimu UMEMOTO #if 0
5585342d17fSHajimu UMEMOTO #define	ns_subdomain		__ns_subdomain
5595342d17fSHajimu UMEMOTO #endif
5605342d17fSHajimu UMEMOTO #define	ns_makecanon		__ns_makecanon
5615342d17fSHajimu UMEMOTO #define	ns_samename		__ns_samename
5620160f9c0SPeter Wemm 
5630160f9c0SPeter Wemm __BEGIN_DECLS
5645342d17fSHajimu UMEMOTO int		ns_msg_getflag(ns_msg, int);
565bb28f3c2SWarner Losh u_int		ns_get16(const u_char *);
566bb28f3c2SWarner Losh u_long		ns_get32(const u_char *);
567bb28f3c2SWarner Losh void		ns_put16(u_int, u_char *);
568bb28f3c2SWarner Losh void		ns_put32(u_long, u_char *);
569bb28f3c2SWarner Losh int		ns_initparse(const u_char *, int, ns_msg *);
5705342d17fSHajimu UMEMOTO int		ns_skiprr(const u_char *, const u_char *, ns_sect, int);
571bb28f3c2SWarner Losh int		ns_parserr(ns_msg *, ns_sect, int, ns_rr *);
572e4576472SHajimu UMEMOTO int		ns_parserr2(ns_msg *, ns_sect, int, ns_rr2 *);
573bb28f3c2SWarner Losh int		ns_sprintrr(const ns_msg *, const ns_rr *,
574bb28f3c2SWarner Losh 			    const char *, const char *, char *, size_t);
575bb28f3c2SWarner Losh int		ns_sprintrrf(const u_char *, size_t, const char *,
5760160f9c0SPeter Wemm 			     ns_class, ns_type, u_long, const u_char *,
5770160f9c0SPeter Wemm 			     size_t, const char *, const char *,
578bb28f3c2SWarner Losh 			     char *, size_t);
579bb28f3c2SWarner Losh int		ns_format_ttl(u_long, char *, size_t);
580bb28f3c2SWarner Losh int		ns_parse_ttl(const char *, u_long *);
5815342d17fSHajimu UMEMOTO #if 0
5825342d17fSHajimu UMEMOTO u_int32_t	ns_datetosecs(const char *cp, int *errp);
5835342d17fSHajimu UMEMOTO #endif
5845342d17fSHajimu UMEMOTO int		ns_name_ntol(const u_char *, u_char *, size_t);
585bb28f3c2SWarner Losh int		ns_name_ntop(const u_char *, char *, size_t);
586bb28f3c2SWarner Losh int		ns_name_pton(const char *, u_char *, size_t);
587e4576472SHajimu UMEMOTO int		ns_name_pton2(const char *, u_char *, size_t, size_t *);
588bb28f3c2SWarner Losh int		ns_name_unpack(const u_char *, const u_char *,
589bb28f3c2SWarner Losh 			       const u_char *, u_char *, size_t);
590e4576472SHajimu UMEMOTO int		ns_name_unpack2(const u_char *, const u_char *,
591046c3635SPedro F. Giffuni 				const u_char *, u_char *, size_t,
592e4576472SHajimu UMEMOTO 				size_t *);
593bb28f3c2SWarner Losh int		ns_name_pack(const u_char *, u_char *, int,
594bb28f3c2SWarner Losh 			     const u_char **, const u_char **);
595bb28f3c2SWarner Losh int		ns_name_uncompress(const u_char *, const u_char *,
596bb28f3c2SWarner Losh 				   const u_char *, char *, size_t);
597bb28f3c2SWarner Losh int		ns_name_compress(const char *, u_char *, size_t,
598bb28f3c2SWarner Losh 				 const u_char **, const u_char **);
599bb28f3c2SWarner Losh int		ns_name_skip(const u_char **, const u_char *);
6005342d17fSHajimu UMEMOTO void		ns_name_rollback(const u_char *, const u_char **,
6015342d17fSHajimu UMEMOTO 				 const u_char **);
602046c3635SPedro F. Giffuni ssize_t		ns_name_length(ns_nname_ct, size_t);
603046c3635SPedro F. Giffuni int		ns_name_eq(ns_nname_ct, size_t, ns_nname_ct, size_t);
604046c3635SPedro F. Giffuni int		ns_name_owned(ns_namemap_ct, int, ns_namemap_ct, int);
605046c3635SPedro F. Giffuni int		ns_name_map(ns_nname_ct, size_t, ns_namemap_t, int);
606046c3635SPedro F. Giffuni int		ns_name_labels(ns_nname_ct, size_t);
6075342d17fSHajimu UMEMOTO #if 0
6085342d17fSHajimu UMEMOTO int		ns_sign(u_char *, int *, int, int, void *,
6095342d17fSHajimu UMEMOTO 			const u_char *, int, u_char *, int *, time_t);
6105342d17fSHajimu UMEMOTO int		ns_sign2(u_char *, int *, int, int, void *,
6115342d17fSHajimu UMEMOTO 			 const u_char *, int, u_char *, int *, time_t,
6125342d17fSHajimu UMEMOTO 			 u_char **, u_char **);
6135342d17fSHajimu UMEMOTO int		ns_sign_tcp(u_char *, int *, int, int,
6145342d17fSHajimu UMEMOTO 			    ns_tcp_tsig_state *, int);
6155342d17fSHajimu UMEMOTO int		ns_sign_tcp2(u_char *, int *, int, int,
6165342d17fSHajimu UMEMOTO 			     ns_tcp_tsig_state *, int,
6175342d17fSHajimu UMEMOTO 			     u_char **, u_char **);
6185342d17fSHajimu UMEMOTO int		ns_sign_tcp_init(void *, const u_char *, int,
6195342d17fSHajimu UMEMOTO 				 ns_tcp_tsig_state *);
6205342d17fSHajimu UMEMOTO u_char		*ns_find_tsig(u_char *, u_char *);
6215342d17fSHajimu UMEMOTO int		ns_verify(u_char *, int *, void *,
6225342d17fSHajimu UMEMOTO 			  const u_char *, int, u_char *, int *,
6235342d17fSHajimu UMEMOTO 			  time_t *, int);
6245342d17fSHajimu UMEMOTO int		ns_verify_tcp(u_char *, int *, ns_tcp_tsig_state *, int);
6255342d17fSHajimu UMEMOTO int		ns_verify_tcp_init(void *, const u_char *, int,
6265342d17fSHajimu UMEMOTO 				   ns_tcp_tsig_state *);
627d808369aSHajimu UMEMOTO #endif
6285342d17fSHajimu UMEMOTO int		ns_samedomain(const char *, const char *);
629d808369aSHajimu UMEMOTO #if 0
6305342d17fSHajimu UMEMOTO int		ns_subdomain(const char *, const char *);
6315342d17fSHajimu UMEMOTO #endif
6325342d17fSHajimu UMEMOTO int		ns_makecanon(const char *, char *, size_t);
6335342d17fSHajimu UMEMOTO int		ns_samename(const char *, const char *);
6340160f9c0SPeter Wemm __END_DECLS
6350160f9c0SPeter Wemm 
6360160f9c0SPeter Wemm #ifdef BIND_4_COMPAT
6370160f9c0SPeter Wemm #include <arpa/nameser_compat.h>
6380160f9c0SPeter Wemm #endif
6390160f9c0SPeter Wemm 
640d58a9efdSPeter Wemm #endif /* !_ARPA_NAMESER_H_ */
641dde4a85dSHajimu UMEMOTO /*! \file */
642