summaryrefslogtreecommitdiffstats
path: root/lib/dns/include/dns/types.h
blob: 6465962bd4119454d9271674cbc2c1a6cd5994d0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
/*
 * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
 *
 * SPDX-License-Identifier: MPL-2.0
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, you can obtain one at https://mozilla.org/MPL/2.0/.
 *
 * See the COPYRIGHT file distributed with this work for additional
 * information regarding copyright ownership.
 */

#pragma once

/*! \file dns/types.h
 * \brief
 * Including this file gives you type declarations suitable for use in
 * .h files, which lets us avoid circular type reference problems.
 * \brief
 * To actually use a type or get declarations of its methods, you must
 * include the appropriate .h file too.
 */

#include <inttypes.h>
#include <stdbool.h>
#include <stdio.h>

#include <isc/types.h>

typedef struct dns_acl	       dns_acl_t;
typedef struct dns_aclelement  dns_aclelement_t;
typedef struct dns_aclenv      dns_aclenv_t;
typedef struct dns_adb	       dns_adb_t;
typedef struct dns_adbaddrinfo dns_adbaddrinfo_t;
typedef ISC_LIST(dns_adbaddrinfo_t) dns_adbaddrinfolist_t;
typedef struct dns_adbentry dns_adbentry_t;
typedef struct dns_adbfind  dns_adbfind_t;
typedef ISC_LIST(dns_adbfind_t) dns_adbfindlist_t;
typedef struct dns_badcache	       dns_badcache_t;
typedef struct dns_byaddr	       dns_byaddr_t;
typedef struct dns_catz_zonemodmethods dns_catz_zonemodmethods_t;
typedef struct dns_catz_entry_options  dns_catz_options_t;
typedef struct dns_catz_entry	       dns_catz_entry_t;
typedef struct dns_catz_coo	       dns_catz_coo_t;
typedef struct dns_catz_zone	       dns_catz_zone_t;
typedef struct dns_catz_changed	       dns_catz_changed_t;
typedef struct dns_catz_zones	       dns_catz_zones_t;
typedef struct dns_client	       dns_client_t;
typedef void			       dns_clientrestrans_t;
typedef void			       dns_clientreqtrans_t;
typedef void			       dns_clientupdatetrans_t;
typedef struct dns_cache	       dns_cache_t;
typedef uint16_t		       dns_cert_t;
typedef struct dns_compress	       dns_compress_t;
typedef struct dns_db		       dns_db_t;
typedef struct dns_dbimplementation    dns_dbimplementation_t;
typedef struct dns_dbiterator	       dns_dbiterator_t;
typedef void			       dns_dbload_t;
typedef void			       dns_dbnode_t;
typedef struct dns_dbonupdatelistener  dns_dbonupdatelistener_t;
typedef void			       dns_dbversion_t;
typedef struct dns_dlzimplementation   dns_dlzimplementation_t;
typedef struct dns_dlzdb	       dns_dlzdb_t;
typedef ISC_LIST(dns_dlzdb_t) dns_dlzdblist_t;
typedef struct dns_dyndbctx	      dns_dyndbctx_t;
typedef struct dns_sdlzimplementation dns_sdlzimplementation_t;
typedef struct dns_decompress	      dns_decompress_t;
typedef struct dns_dispatch	      dns_dispatch_t;
typedef struct dns_dispatchlist	      dns_dispatchlist_t;
typedef struct dns_dispatchset	      dns_dispatchset_t;
typedef struct dns_dispatchmgr	      dns_dispatchmgr_t;
typedef struct dns_dispentry	      dns_dispentry_t;
typedef struct dns_dns64	      dns_dns64_t;
typedef ISC_LIST(dns_dns64_t) dns_dns64list_t;
typedef struct dns_dnsseckey dns_dnsseckey_t;
typedef ISC_LIST(dns_dnsseckey_t) dns_dnsseckeylist_t;
typedef uint8_t			   dns_dsdigest_t;
typedef struct dns_dtdata	   dns_dtdata_t;
typedef struct dns_dtenv	   dns_dtenv_t;
typedef struct dns_dtmsg	   dns_dtmsg_t;
typedef uint16_t		   dns_dtmsgtype_t;
typedef struct dns_dumpctx	   dns_dumpctx_t;
typedef struct dns_ecs		   dns_ecs_t;
typedef struct dns_ednsopt	   dns_ednsopt_t;
typedef struct dns_fetch	   dns_fetch_t;
typedef struct dns_fixedname	   dns_fixedname_t;
typedef struct dns_forwarders	   dns_forwarders_t;
typedef struct dns_forwarder	   dns_forwarder_t;
typedef struct dns_fwdtable	   dns_fwdtable_t;
typedef struct dns_geoip_databases dns_geoip_databases_t;
typedef struct dns_iptable	   dns_iptable_t;
typedef uint32_t		   dns_iterations_t;
typedef struct dns_kasp		   dns_kasp_t;
typedef ISC_LIST(dns_kasp_t) dns_kasplist_t;
typedef struct dns_kasp_key dns_kasp_key_t;
typedef ISC_LIST(dns_kasp_key_t) dns_kasp_keylist_t;
typedef struct dns_kasp_nsec3param dns_kasp_nsec3param_t;
typedef uint16_t		   dns_keyflags_t;
typedef struct dns_keynode	   dns_keynode_t;
typedef ISC_LIST(dns_keynode_t) dns_keynodelist_t;
typedef struct dns_keytable	   dns_keytable_t;
typedef uint16_t		   dns_keytag_t;
typedef struct dns_loadctx	   dns_loadctx_t;
typedef struct dns_loadmgr	   dns_loadmgr_t;
typedef struct dns_masterrawheader dns_masterrawheader_t;
typedef uint64_t		   dns_masterstyle_flags_t;
typedef struct dns_message	   dns_message_t;
typedef uint16_t		   dns_messageid_t;
typedef isc_region_t		   dns_label_t;
typedef struct dns_lookup	   dns_lookup_t;
typedef struct dns_name		   dns_name_t;
typedef ISC_LIST(dns_name_t) dns_namelist_t;
typedef struct dns_nta		  dns_nta_t;
typedef struct dns_ntatable	  dns_ntatable_t;
typedef uint16_t		  dns_opcode_t;
typedef unsigned char		  dns_offsets_t[128];
typedef struct dns_order	  dns_order_t;
typedef struct dns_peer		  dns_peer_t;
typedef struct dns_peerlist	  dns_peerlist_t;
typedef struct dns_rbt		  dns_rbt_t;
typedef uint16_t		  dns_rcode_t;
typedef struct dns_rdata	  dns_rdata_t;
typedef struct dns_rdatacallbacks dns_rdatacallbacks_t;
typedef uint16_t		  dns_rdataclass_t;
typedef struct dns_rdatalist	  dns_rdatalist_t;
typedef struct dns_rdataset	  dns_rdataset_t;
typedef ISC_LIST(dns_rdataset_t) dns_rdatasetlist_t;
typedef struct dns_rdatasetiter	     dns_rdatasetiter_t;
typedef uint16_t		     dns_rdatatype_t;
typedef struct dns_request	     dns_request_t;
typedef struct dns_requestmgr	     dns_requestmgr_t;
typedef struct dns_resolver	     dns_resolver_t;
typedef struct dns_sdbimplementation dns_sdbimplementation_t;
typedef uint8_t			     dns_secalg_t;
typedef uint8_t			     dns_secproto_t;
typedef struct dns_signature	     dns_signature_t;
typedef struct dns_sortlist_arg	     dns_sortlist_arg_t;
typedef struct dns_ssurule	     dns_ssurule_t;
typedef struct dns_ssutable	     dns_ssutable_t;
typedef struct dns_stats	     dns_stats_t;
typedef uint32_t		     dns_rdatastatstype_t;
typedef struct dns_tkeyctx	     dns_tkeyctx_t;
typedef uint16_t		     dns_trust_t;
typedef struct dns_tsec		     dns_tsec_t;
typedef struct dns_tsig_keyring	     dns_tsig_keyring_t;
typedef struct dns_tsigkey	     dns_tsigkey_t;
typedef uint32_t		     dns_ttl_t;
typedef struct dns_update_state	     dns_update_state_t;
typedef struct dns_validator	     dns_validator_t;
typedef struct dns_view		     dns_view_t;
typedef ISC_LIST(dns_view_t) dns_viewlist_t;
typedef struct dns_zone dns_zone_t;
typedef ISC_LIST(dns_zone_t) dns_zonelist_t;
typedef struct dns_zonemgr   dns_zonemgr_t;
typedef struct dns_zt	     dns_zt_t;
typedef struct dns_ipkeylist dns_ipkeylist_t;

typedef struct dst_gssapi_signverifyctx dst_gssapi_signverifyctx_t;

typedef enum { dns_hash_sha1 = 1 } dns_hash_t;

typedef enum {
	dns_fwdpolicy_none = 0,
	dns_fwdpolicy_first = 1,
	dns_fwdpolicy_only = 2
} dns_fwdpolicy_t;

typedef enum {
	dns_namereln_none = 0,
	dns_namereln_contains = 1,
	dns_namereln_subdomain = 2,
	dns_namereln_equal = 3,
	dns_namereln_commonancestor = 4
} dns_namereln_t;

typedef enum { dns_one_answer, dns_many_answers } dns_transfer_format_t;

typedef enum {
	dns_dbtype_zone = 0,
	dns_dbtype_cache = 1,
	dns_dbtype_stub = 3
} dns_dbtype_t;

typedef enum {
	dns_dbtree_main = 0,
	dns_dbtree_nsec = 1,
	dns_dbtree_nsec3 = 2
} dns_dbtree_t;

typedef enum {
	dns_notifytype_no = 0,
	dns_notifytype_yes = 1,
	dns_notifytype_explicit = 2,
	dns_notifytype_masteronly = 3
} dns_notifytype_t;

typedef enum {
	dns_minimal_no = 0,
	dns_minimal_yes = 1,
	dns_minimal_noauth = 2,
	dns_minimal_noauthrec = 3
} dns_minimaltype_t;

typedef enum {
	dns_dialuptype_no = 0,
	dns_dialuptype_yes = 1,
	dns_dialuptype_notify = 2,
	dns_dialuptype_notifypassive = 3,
	dns_dialuptype_refresh = 4,
	dns_dialuptype_passive = 5
} dns_dialuptype_t;

typedef enum {
	dns_masterformat_none = 0,
	dns_masterformat_text = 1,
	dns_masterformat_raw = 2,
} dns_masterformat_t;

/*
 * These are generated by gen.c.
 */
#include <dns/enumclass.h> /* Provides dns_rdataclass_t. */
#include <dns/enumtype.h>  /* Provides dns_rdatatype_t. */

/*%
 * rcodes.
 */
enum {
	/*
	 * Standard rcodes.
	 */
	dns_rcode_noerror = 0,
#define dns_rcode_noerror ((dns_rcode_t)dns_rcode_noerror)
	dns_rcode_formerr = 1,
#define dns_rcode_formerr ((dns_rcode_t)dns_rcode_formerr)
	dns_rcode_servfail = 2,
#define dns_rcode_servfail ((dns_rcode_t)dns_rcode_servfail)
	dns_rcode_nxdomain = 3,
#define dns_rcode_nxdomain ((dns_rcode_t)dns_rcode_nxdomain)
	dns_rcode_notimp = 4,
#define dns_rcode_notimp ((dns_rcode_t)dns_rcode_notimp)
	dns_rcode_refused = 5,
#define dns_rcode_refused ((dns_rcode_t)dns_rcode_refused)
	dns_rcode_yxdomain = 6,
#define dns_rcode_yxdomain ((dns_rcode_t)dns_rcode_yxdomain)
	dns_rcode_yxrrset = 7,
#define dns_rcode_yxrrset ((dns_rcode_t)dns_rcode_yxrrset)
	dns_rcode_nxrrset = 8,
#define dns_rcode_nxrrset ((dns_rcode_t)dns_rcode_nxrrset)
	dns_rcode_notauth = 9,
#define dns_rcode_notauth ((dns_rcode_t)dns_rcode_notauth)
	dns_rcode_notzone = 10,
#define dns_rcode_notzone ((dns_rcode_t)dns_rcode_notzone)
	/*
	 * Extended rcodes.
	 */
	dns_rcode_badvers = 16,
#define dns_rcode_badvers ((dns_rcode_t)dns_rcode_badvers)
	dns_rcode_badcookie = 23
#define dns_rcode_badcookie ((dns_rcode_t)dns_rcode_badcookie)
	/*
	 * Update dns_rcodestats_create() and
	 *dns_rcodestats_increment()
	 * and this comment if a rcode >
	 *dns_rcode_badcookie is assigned.
	 */
	/* Private space [3841..4095] */
};

/*%
 * TSIG errors.
 */
enum {
	dns_tsigerror_badsig = 16,
	dns_tsigerror_badkey = 17,
	dns_tsigerror_badtime = 18,
	dns_tsigerror_badmode = 19,
	dns_tsigerror_badname = 20,
	dns_tsigerror_badalg = 21,
	dns_tsigerror_badtrunc = 22
};

/*%
 * Opcodes.
 */
enum {
	dns_opcode_query = 0,
#define dns_opcode_query ((dns_opcode_t)dns_opcode_query)
	dns_opcode_iquery = 1,
#define dns_opcode_iquery ((dns_opcode_t)dns_opcode_iquery)
	dns_opcode_status = 2,
#define dns_opcode_status ((dns_opcode_t)dns_opcode_status)
	dns_opcode_notify = 4,
#define dns_opcode_notify ((dns_opcode_t)dns_opcode_notify)
	dns_opcode_update = 5 /* dynamic update */
#define dns_opcode_update ((dns_opcode_t)dns_opcode_update)
};

/*%
 * Trust levels.  Must be kept in sync with trustnames[] in masterdump.c.
 */
enum {
	/* Sentinel value; no data should have this trust level. */
	dns_trust_none = 0,
#define dns_trust_none ((dns_trust_t)dns_trust_none)

	/*%
	 * Subject to DNSSEC validation but has not yet been validated
	 * dns_trust_pending_additional (from the additional section).
	 */
	dns_trust_pending_additional = 1,
#define dns_trust_pending_additional ((dns_trust_t)dns_trust_pending_additional)

	dns_trust_pending_answer = 2,
#define dns_trust_pending_answer ((dns_trust_t)dns_trust_pending_answer)

	/*% Received in the additional section of a response. */
	dns_trust_additional = 3,
#define dns_trust_additional ((dns_trust_t)dns_trust_additional)

	/* Received in a referral response. */
	dns_trust_glue = 4,
#define dns_trust_glue ((dns_trust_t)dns_trust_glue)

	/* Answer from a non-authoritative server */
	dns_trust_answer = 5,
#define dns_trust_answer ((dns_trust_t)dns_trust_answer)

	/*  Received in the authority section as part of an
	 *  authoritative response */
	dns_trust_authauthority = 6,
#define dns_trust_authauthority ((dns_trust_t)dns_trust_authauthority)

	/* Answer from an authoritative server */
	dns_trust_authanswer = 7,
#define dns_trust_authanswer ((dns_trust_t)dns_trust_authanswer)

	/* Successfully DNSSEC validated */
	dns_trust_secure = 8,
#define dns_trust_secure ((dns_trust_t)dns_trust_secure)

	/* This server is authoritative */
	dns_trust_ultimate = 9
#define dns_trust_ultimate ((dns_trust_t)dns_trust_ultimate)
};

#define DNS_TRUST_PENDING(x) \
	((x) == dns_trust_pending_answer || (x) == dns_trust_pending_additional)
#define DNS_TRUST_ADDITIONAL(x) \
	((x) == dns_trust_additional || (x) == dns_trust_pending_additional)
#define DNS_TRUST_GLUE(x)   ((x) == dns_trust_glue)
#define DNS_TRUST_ANSWER(x) ((x) == dns_trust_answer)

/*%
 * Name checking severities.
 */
typedef enum {
	dns_severity_ignore,
	dns_severity_warn,
	dns_severity_fail
} dns_severity_t;

/*%
 * DNS Serial Number Update Method.
 *
 * \li	_none:		Keep the current serial.
 * \li	_increment:	Add one to the current serial, skipping 0.
 * \li	_unixtime:	Set to the seconds since 00:00 Jan 1, 1970,
 *			if possible.
 * \li	_date:		Set to today's date in YYYYMMDDVV format:
 *                      (Year, Month, Day, Version)
 */
typedef enum {
	dns_updatemethod_none = 0,
	dns_updatemethod_increment,
	dns_updatemethod_unixtime,
	dns_updatemethod_date
} dns_updatemethod_t;

typedef enum {
	dns_stale_answer_no,
	dns_stale_answer_yes,
	dns_stale_answer_conf
} dns_stale_answer_t;

typedef struct {
	const char *string;
	size_t	    count;
} dns_indent_t;

/*
 * Functions.
 */
typedef void (*dns_dumpdonefunc_t)(void *, isc_result_t);

typedef void (*dns_loaddonefunc_t)(void *, isc_result_t);

typedef void (*dns_rawdatafunc_t)(dns_zone_t *, dns_masterrawheader_t *);

typedef isc_result_t (*dns_addrdatasetfunc_t)(void *, const dns_name_t *,
					      dns_rdataset_t *);

typedef isc_result_t (*dns_additionaldatafunc_t)(void *, const dns_name_t *,
						 dns_rdatatype_t,
						 dns_rdataset_t *);

typedef isc_result_t (*dns_digestfunc_t)(void *, isc_region_t *);

typedef void (*dns_xfrindone_t)(dns_zone_t *, isc_result_t);

typedef void (*dns_updatecallback_t)(void *, isc_result_t, dns_message_t *);

typedef int (*dns_rdatasetorderfunc_t)(const dns_rdata_t *, const void *);

typedef bool (*dns_checkmxfunc_t)(dns_zone_t *, const dns_name_t *,
				  const dns_name_t *);

typedef bool (*dns_checksrvfunc_t)(dns_zone_t *, const dns_name_t *,
				   const dns_name_t *);

typedef bool (*dns_checknsfunc_t)(dns_zone_t *, const dns_name_t *,
				  const dns_name_t *, dns_rdataset_t *,
				  dns_rdataset_t *);

typedef bool (*dns_isselffunc_t)(dns_view_t *, dns_tsigkey_t *,
				 const isc_sockaddr_t *, const isc_sockaddr_t *,
				 dns_rdataclass_t, void *);

typedef void (*dns_nseclog_t)(void *val, int, const char *, ...);