xref: /minix/external/bsd/bind/dist/lib/dns/include/dns/types.h (revision 00b67f09)
1 /*	$NetBSD: types.h,v 1.7 2014/12/10 04:37:58 christos Exp $	*/
2 
3 /*
4  * Copyright (C) 2004-2013  Internet Systems Consortium, Inc. ("ISC")
5  * Copyright (C) 1998-2003  Internet Software Consortium.
6  *
7  * Permission to use, copy, modify, and/or distribute this software for any
8  * purpose with or without fee is hereby granted, provided that the above
9  * copyright notice and this permission notice appear in all copies.
10  *
11  * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
12  * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
13  * AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
14  * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
15  * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
16  * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17  * PERFORMANCE OF THIS SOFTWARE.
18  */
19 
20 /* Id */
21 
22 #ifndef DNS_TYPES_H
23 #define DNS_TYPES_H 1
24 
25 /*! \file dns/types.h
26  * \brief
27  * Including this file gives you type declarations suitable for use in
28  * .h files, which lets us avoid circular type reference problems.
29  * \brief
30  * To actually use a type or get declarations of its methods, you must
31  * include the appropriate .h file too.
32  */
33 
34 #include <stdio.h>
35 
36 #include <isc/types.h>
37 
38 typedef struct dns_acache			dns_acache_t;
39 typedef struct dns_acacheentry			dns_acacheentry_t;
40 typedef struct dns_acachestats			dns_acachestats_t;
41 typedef struct dns_acl 				dns_acl_t;
42 typedef struct dns_aclelement 			dns_aclelement_t;
43 typedef struct dns_aclenv			dns_aclenv_t;
44 typedef struct dns_adb				dns_adb_t;
45 typedef struct dns_adbaddrinfo			dns_adbaddrinfo_t;
46 typedef ISC_LIST(dns_adbaddrinfo_t)		dns_adbaddrinfolist_t;
47 typedef struct dns_adbentry			dns_adbentry_t;
48 typedef struct dns_adbfind			dns_adbfind_t;
49 typedef ISC_LIST(dns_adbfind_t)			dns_adbfindlist_t;
50 typedef struct dns_byaddr			dns_byaddr_t;
51 typedef struct dns_client			dns_client_t;
52 typedef void					dns_clientrestrans_t;
53 typedef void					dns_clientreqtrans_t;
54 typedef void					dns_clientupdatetrans_t;
55 typedef struct dns_cache			dns_cache_t;
56 typedef isc_uint16_t				dns_cert_t;
57 typedef struct dns_compress			dns_compress_t;
58 typedef struct dns_db				dns_db_t;
59 typedef struct dns_dbimplementation		dns_dbimplementation_t;
60 typedef struct dns_dbiterator			dns_dbiterator_t;
61 typedef void					dns_dbload_t;
62 typedef void					dns_dbnode_t;
63 typedef struct dns_dbtable			dns_dbtable_t;
64 typedef void					dns_dbversion_t;
65 typedef struct dns_dlzimplementation		dns_dlzimplementation_t;
66 typedef struct dns_dlzdb			dns_dlzdb_t;
67 typedef ISC_LIST(dns_dlzdb_t)			dns_dlzdblist_t;
68 typedef struct dns_sdlzimplementation		dns_sdlzimplementation_t;
69 typedef struct dns_decompress			dns_decompress_t;
70 typedef struct dns_dispatch			dns_dispatch_t;
71 typedef struct dns_dispatchevent		dns_dispatchevent_t;
72 typedef struct dns_dispatchlist			dns_dispatchlist_t;
73 typedef struct dns_dispatchset			dns_dispatchset_t;
74 typedef struct dns_dispatchmgr			dns_dispatchmgr_t;
75 typedef struct dns_dispentry			dns_dispentry_t;
76 typedef struct dns_dns64			dns_dns64_t;
77 typedef ISC_LIST(dns_dns64_t)			dns_dns64list_t;
78 typedef struct dns_dnsseckey			dns_dnsseckey_t;
79 typedef ISC_LIST(dns_dnsseckey_t)		dns_dnsseckeylist_t;
80 typedef isc_uint8_t				dns_dsdigest_t;
81 typedef struct dns_dumpctx			dns_dumpctx_t;
82 typedef struct dns_ednsopt			dns_ednsopt_t;
83 typedef struct dns_fetch			dns_fetch_t;
84 typedef struct dns_fixedname			dns_fixedname_t;
85 typedef struct dns_forwarders			dns_forwarders_t;
86 typedef struct dns_forwarder			dns_forwarder_t;
87 typedef struct dns_fwdtable			dns_fwdtable_t;
88 typedef struct dns_iptable			dns_iptable_t;
89 typedef isc_uint32_t				dns_iterations_t;
90 typedef isc_uint16_t				dns_keyflags_t;
91 typedef struct dns_keynode			dns_keynode_t;
92 typedef ISC_LIST(dns_keynode_t)			dns_keynodelist_t;
93 typedef struct dns_keytable			dns_keytable_t;
94 typedef isc_uint16_t				dns_keytag_t;
95 typedef struct dns_loadctx			dns_loadctx_t;
96 typedef struct dns_loadmgr			dns_loadmgr_t;
97 typedef struct dns_masterrawheader		dns_masterrawheader_t;
98 typedef struct dns_message			dns_message_t;
99 typedef isc_uint16_t				dns_messageid_t;
100 typedef isc_region_t				dns_label_t;
101 typedef struct dns_lookup			dns_lookup_t;
102 typedef struct dns_name				dns_name_t;
103 typedef ISC_LIST(dns_name_t)			dns_namelist_t;
104 typedef isc_uint16_t				dns_opcode_t;
105 typedef unsigned char				dns_offsets_t[128];
106 typedef struct dns_order			dns_order_t;
107 typedef struct dns_peer				dns_peer_t;
108 typedef struct dns_peerlist			dns_peerlist_t;
109 typedef struct dns_portlist			dns_portlist_t;
110 typedef struct dns_rbt				dns_rbt_t;
111 typedef isc_uint16_t				dns_rcode_t;
112 typedef struct dns_rdata			dns_rdata_t;
113 typedef struct dns_rdatacallbacks		dns_rdatacallbacks_t;
114 typedef isc_uint16_t				dns_rdataclass_t;
115 typedef struct dns_rdatalist			dns_rdatalist_t;
116 typedef struct dns_rdataset			dns_rdataset_t;
117 typedef ISC_LIST(dns_rdataset_t)		dns_rdatasetlist_t;
118 typedef struct dns_rdatasetiter			dns_rdatasetiter_t;
119 typedef isc_uint16_t				dns_rdatatype_t;
120 typedef struct dns_request			dns_request_t;
121 typedef struct dns_requestmgr			dns_requestmgr_t;
122 typedef struct dns_resolver			dns_resolver_t;
123 typedef struct dns_sdbimplementation		dns_sdbimplementation_t;
124 typedef isc_uint8_t				dns_secalg_t;
125 typedef isc_uint8_t				dns_secproto_t;
126 typedef struct dns_signature			dns_signature_t;
127 typedef struct dns_ssurule			dns_ssurule_t;
128 typedef struct dns_ssutable			dns_ssutable_t;
129 typedef struct dns_stats			dns_stats_t;
130 typedef isc_uint32_t				dns_rdatastatstype_t;
131 typedef struct dns_tkeyctx			dns_tkeyctx_t;
132 typedef isc_uint16_t				dns_trust_t;
133 typedef struct dns_tsec				dns_tsec_t;
134 typedef struct dns_tsig_keyring			dns_tsig_keyring_t;
135 typedef struct dns_tsigkey			dns_tsigkey_t;
136 typedef isc_uint32_t				dns_ttl_t;
137 typedef struct dns_validator			dns_validator_t;
138 typedef struct dns_view				dns_view_t;
139 typedef ISC_LIST(dns_view_t)			dns_viewlist_t;
140 typedef struct dns_zone				dns_zone_t;
141 typedef ISC_LIST(dns_zone_t)			dns_zonelist_t;
142 typedef struct dns_zonemgr			dns_zonemgr_t;
143 typedef struct dns_zt				dns_zt_t;
144 
145 /*
146  * If we are not using GSSAPI, define the types we use as opaque types here.
147  */
148 #ifndef GSSAPI
149 typedef struct not_defined_gss_cred_id *gss_cred_id_t;
150 typedef struct not_defined_gss_ctx *gss_ctx_id_t;
151 #endif
152 typedef struct dst_gssapi_signverifyctx dst_gssapi_signverifyctx_t;
153 
154 typedef enum {
155 	dns_hash_sha1 = 1
156 } dns_hash_t;
157 
158 typedef enum {
159 	dns_fwdpolicy_none = 0,
160 	dns_fwdpolicy_first = 1,
161 	dns_fwdpolicy_only = 2
162 } dns_fwdpolicy_t;
163 
164 typedef enum {
165 	dns_namereln_none = 0,
166 	dns_namereln_contains = 1,
167 	dns_namereln_subdomain = 2,
168 	dns_namereln_equal = 3,
169 	dns_namereln_commonancestor = 4
170 } dns_namereln_t;
171 
172 typedef enum {
173 	dns_one_answer, dns_many_answers
174 } dns_transfer_format_t;
175 
176 typedef enum {
177 	dns_dbtype_zone = 0, dns_dbtype_cache = 1, dns_dbtype_stub = 3
178 } dns_dbtype_t;
179 
180 typedef enum {
181 	dns_notifytype_no = 0,
182 	dns_notifytype_yes = 1,
183 	dns_notifytype_explicit = 2,
184 	dns_notifytype_masteronly = 3
185 } dns_notifytype_t;
186 
187 typedef enum {
188 	dns_dialuptype_no = 0,
189 	dns_dialuptype_yes = 1,
190 	dns_dialuptype_notify = 2,
191 	dns_dialuptype_notifypassive = 3,
192 	dns_dialuptype_refresh = 4,
193 	dns_dialuptype_passive = 5
194 } dns_dialuptype_t;
195 
196 typedef enum {
197 	dns_masterformat_none = 0,
198 	dns_masterformat_text = 1,
199 	dns_masterformat_raw  = 2,
200 	dns_masterformat_map = 3
201 } dns_masterformat_t;
202 
203 typedef enum {
204 	dns_aaaa_ok = 0,
205 	dns_aaaa_filter = 1,
206 	dns_aaaa_break_dnssec = 2
207 } dns_aaaa_t;
208 
209 /*
210  * These are generated by gen.c.
211  */
212 #include <dns/enumtype.h>	/* Provides dns_rdatatype_t. */
213 #include <dns/enumclass.h>	/* Provides dns_rdataclass_t. */
214 
215 /*%
216  * rcodes.
217  */
218 enum {
219 	/*
220 	 * Standard rcodes.
221 	 */
222 	dns_rcode_noerror = 0,
223 #define dns_rcode_noerror		((dns_rcode_t)dns_rcode_noerror)
224 	dns_rcode_formerr = 1,
225 #define dns_rcode_formerr		((dns_rcode_t)dns_rcode_formerr)
226 	dns_rcode_servfail = 2,
227 #define dns_rcode_servfail		((dns_rcode_t)dns_rcode_servfail)
228 	dns_rcode_nxdomain = 3,
229 #define dns_rcode_nxdomain		((dns_rcode_t)dns_rcode_nxdomain)
230 	dns_rcode_notimp = 4,
231 #define dns_rcode_notimp		((dns_rcode_t)dns_rcode_notimp)
232 	dns_rcode_refused = 5,
233 #define dns_rcode_refused		((dns_rcode_t)dns_rcode_refused)
234 	dns_rcode_yxdomain = 6,
235 #define dns_rcode_yxdomain		((dns_rcode_t)dns_rcode_yxdomain)
236 	dns_rcode_yxrrset = 7,
237 #define dns_rcode_yxrrset		((dns_rcode_t)dns_rcode_yxrrset)
238 	dns_rcode_nxrrset = 8,
239 #define dns_rcode_nxrrset		((dns_rcode_t)dns_rcode_nxrrset)
240 	dns_rcode_notauth = 9,
241 #define dns_rcode_notauth		((dns_rcode_t)dns_rcode_notauth)
242 	dns_rcode_notzone = 10,
243 #define dns_rcode_notzone		((dns_rcode_t)dns_rcode_notzone)
244 	/*
245 	 * Extended rcodes.
246 	 */
247 	dns_rcode_badvers = 16
248 #define dns_rcode_badvers		((dns_rcode_t)dns_rcode_badvers)
249 };
250 
251 /*%
252  * TSIG errors.
253  */
254 enum {
255 	dns_tsigerror_badsig = 16,
256 	dns_tsigerror_badkey = 17,
257 	dns_tsigerror_badtime = 18,
258 	dns_tsigerror_badmode = 19,
259 	dns_tsigerror_badname = 20,
260 	dns_tsigerror_badalg = 21,
261 	dns_tsigerror_badtrunc = 22
262 };
263 
264 /*%
265  * Opcodes.
266  */
267 enum {
268 	dns_opcode_query = 0,
269 #define dns_opcode_query		((dns_opcode_t)dns_opcode_query)
270 	dns_opcode_iquery = 1,
271 #define dns_opcode_iquery		((dns_opcode_t)dns_opcode_iquery)
272 	dns_opcode_status = 2,
273 #define dns_opcode_status		((dns_opcode_t)dns_opcode_status)
274 	dns_opcode_notify = 4,
275 #define dns_opcode_notify		((dns_opcode_t)dns_opcode_notify)
276 	dns_opcode_update = 5		/* dynamic update */
277 #define dns_opcode_update		((dns_opcode_t)dns_opcode_update)
278 };
279 
280 /*%
281  * Trust levels.  Must be kept in sync with trustnames[] in masterdump.c.
282  */
283 enum {
284 	/* Sentinel value; no data should have this trust level. */
285 	dns_trust_none = 0,
286 #define dns_trust_none			((dns_trust_t)dns_trust_none)
287 
288 	/*%
289 	 * Subject to DNSSEC validation but has not yet been validated
290 	 * dns_trust_pending_additional (from the additional section).
291 	 */
292 	dns_trust_pending_additional = 1,
293 #define dns_trust_pending_additional \
294 		 ((dns_trust_t)dns_trust_pending_additional)
295 
296 	dns_trust_pending_answer = 2,
297 #define dns_trust_pending_answer	((dns_trust_t)dns_trust_pending_answer)
298 
299 	/*% Received in the additional section of a response. */
300 	dns_trust_additional = 3,
301 #define dns_trust_additional		((dns_trust_t)dns_trust_additional)
302 
303 	/* Received in a referral response. */
304 	dns_trust_glue = 4,
305 #define dns_trust_glue			((dns_trust_t)dns_trust_glue)
306 
307 	/* Answer from a non-authoritative server */
308 	dns_trust_answer = 5,
309 #define dns_trust_answer		((dns_trust_t)dns_trust_answer)
310 
311 	/*  Received in the authority section as part of an
312 	    authoritative response */
313 	dns_trust_authauthority = 6,
314 #define dns_trust_authauthority		((dns_trust_t)dns_trust_authauthority)
315 
316 	/* Answer from an authoritative server */
317 	dns_trust_authanswer = 7,
318 #define dns_trust_authanswer		((dns_trust_t)dns_trust_authanswer)
319 
320 	/* Successfully DNSSEC validated */
321 	dns_trust_secure = 8,
322 #define dns_trust_secure		((dns_trust_t)dns_trust_secure)
323 
324 	/* This server is authoritative */
325 	dns_trust_ultimate = 9
326 #define dns_trust_ultimate		((dns_trust_t)dns_trust_ultimate)
327 };
328 
329 #define DNS_TRUST_PENDING(x)		((x) == dns_trust_pending_answer || \
330 					 (x) == dns_trust_pending_additional)
331 #define DNS_TRUST_ADDITIONAL(x)		((x) == dns_trust_additional || \
332 					 (x) == dns_trust_pending_additional)
333 #define DNS_TRUST_GLUE(x)		((x) == dns_trust_glue)
334 #define DNS_TRUST_ANSWER(x)		((x) == dns_trust_answer)
335 
336 
337 /*%
338  * Name checking severities.
339  */
340 typedef enum {
341 	dns_severity_ignore,
342 	dns_severity_warn,
343 	dns_severity_fail
344 } dns_severity_t;
345 
346 /*%
347  * DNS Serial Number Update Method.
348  *
349  * \li	_increment:	Add one to the current serial, skipping 0.
350  * \li	_unixtime:	Set to the seconds since 00:00 Jan 1, 1970,
351  *			if possible.
352  * \li	_yyyymmvv:	Set to Year, Month, Version, if possible.
353  *			(Not yet implemented)
354  */
355 typedef enum {
356 	dns_updatemethod_increment = 0,
357 	dns_updatemethod_unixtime
358 } dns_updatemethod_t;
359 
360 /*
361  * Functions.
362  */
363 typedef void
364 (*dns_dumpdonefunc_t)(void *, isc_result_t);
365 
366 typedef void
367 (*dns_loaddonefunc_t)(void *, isc_result_t);
368 
369 typedef void
370 (*dns_rawdatafunc_t)(dns_zone_t *, dns_masterrawheader_t *);
371 
372 typedef isc_result_t
373 (*dns_addrdatasetfunc_t)(void *, dns_name_t *, dns_rdataset_t *);
374 
375 typedef isc_result_t
376 (*dns_additionaldatafunc_t)(void *, dns_name_t *, dns_rdatatype_t);
377 
378 typedef isc_result_t
379 (*dns_digestfunc_t)(void *, isc_region_t *);
380 
381 typedef void
382 (*dns_xfrindone_t)(dns_zone_t *, isc_result_t);
383 
384 typedef void
385 (*dns_updatecallback_t)(void *, isc_result_t, dns_message_t *);
386 
387 typedef int
388 (*dns_rdatasetorderfunc_t)(const dns_rdata_t *, const void *);
389 
390 typedef isc_boolean_t
391 (*dns_checkmxfunc_t)(dns_zone_t *, dns_name_t *, dns_name_t *);
392 
393 typedef isc_boolean_t
394 (*dns_checksrvfunc_t)(dns_zone_t *, dns_name_t *, dns_name_t *);
395 
396 typedef isc_boolean_t
397 (*dns_checknsfunc_t)(dns_zone_t *, dns_name_t *, dns_name_t *,
398 		     dns_rdataset_t *, dns_rdataset_t *);
399 
400 typedef isc_boolean_t
401 (*dns_isselffunc_t)(dns_view_t *, dns_tsigkey_t *, isc_sockaddr_t *,
402 		    isc_sockaddr_t *, dns_rdataclass_t, void *);
403 
404 typedef isc_result_t
405 (*dns_deserializefunc_t)(void *, FILE *, off_t);
406 
407 typedef void
408 (*dns_nseclog_t)(void *val, int , const char *, ...);
409 
410 #endif /* DNS_TYPES_H */
411