1 /* $NetBSD: types.h,v 1.9 2025/01/26 16:25:29 christos Exp $ */ 2 3 /* 4 * Copyright (C) Internet Systems Consortium, Inc. ("ISC") 5 * 6 * SPDX-License-Identifier: MPL-2.0 7 * 8 * This Source Code Form is subject to the terms of the Mozilla Public 9 * License, v. 2.0. If a copy of the MPL was not distributed with this 10 * file, you can obtain one at https://mozilla.org/MPL/2.0/. 11 * 12 * See the COPYRIGHT file distributed with this work for additional 13 * information regarding copyright ownership. 14 */ 15 16 #pragma once 17 18 /*! \file dns/types.h 19 * \brief 20 * Including this file gives you type declarations suitable for use in 21 * .h files, which lets us avoid circular type reference problems. 22 * \brief 23 * To actually use a type or get declarations of its methods, you must 24 * include the appropriate .h file too. 25 */ 26 27 #include <inttypes.h> 28 #include <stdbool.h> 29 #include <stdio.h> 30 31 #include <isc/types.h> 32 33 #include <dns/trace.h> 34 35 typedef struct dns_acl dns_acl_t; 36 typedef struct dns_aclelement dns_aclelement_t; 37 typedef struct dns_aclenv dns_aclenv_t; 38 typedef struct dns_adb dns_adb_t; 39 typedef struct dns_adbaddrinfo dns_adbaddrinfo_t; 40 typedef ISC_LIST(dns_adbaddrinfo_t) dns_adbaddrinfolist_t; 41 typedef struct dns_adbentry dns_adbentry_t; 42 typedef struct dns_adbfind dns_adbfind_t; 43 typedef ISC_LIST(dns_adbfind_t) dns_adbfindlist_t; 44 typedef struct dns_badcache dns_badcache_t; 45 typedef struct dns_byaddr dns_byaddr_t; 46 typedef struct dns_catz_zonemodmethods dns_catz_zonemodmethods_t; 47 typedef struct dns_catz_entry_options dns_catz_options_t; 48 typedef struct dns_catz_entry dns_catz_entry_t; 49 typedef struct dns_catz_coo dns_catz_coo_t; 50 typedef struct dns_catz_zone dns_catz_zone_t; 51 typedef struct dns_catz_changed dns_catz_changed_t; 52 typedef struct dns_catz_zones dns_catz_zones_t; 53 typedef struct dns_client dns_client_t; 54 typedef void dns_clientrestrans_t; 55 typedef void dns_clientreqtrans_t; 56 typedef void dns_clientupdatetrans_t; 57 typedef struct dns_cache dns_cache_t; 58 typedef uint16_t dns_cert_t; 59 typedef struct dns_compress dns_compress_t; 60 typedef enum dns_compress_flags dns_compress_flags_t; 61 typedef struct dns_compress_slot dns_compress_slot_t; 62 typedef struct dns_db dns_db_t; 63 typedef struct dns_dbimplementation dns_dbimplementation_t; 64 typedef struct dns_dbiterator dns_dbiterator_t; 65 typedef void dns_dbload_t; 66 typedef void dns_dbnode_t; 67 typedef struct dns_dbonupdatelistener dns_dbonupdatelistener_t; 68 typedef void dns_dbversion_t; 69 typedef struct dns_dlzimplementation dns_dlzimplementation_t; 70 typedef struct dns_dlzdb dns_dlzdb_t; 71 typedef ISC_LIST(dns_dlzdb_t) dns_dlzdblist_t; 72 typedef struct dns_dyndbctx dns_dyndbctx_t; 73 typedef struct dns_sdlzimplementation dns_sdlzimplementation_t; 74 typedef enum dns_decompress dns_decompress_t; 75 typedef struct dns_dispatch dns_dispatch_t; 76 typedef struct dns_dispatchlist dns_dispatchlist_t; 77 typedef struct dns_dispatchset dns_dispatchset_t; 78 typedef struct dns_dispatchmgr dns_dispatchmgr_t; 79 typedef struct dns_dispentry dns_dispentry_t; 80 typedef struct dns_dns64 dns_dns64_t; 81 typedef ISC_LIST(dns_dns64_t) dns_dns64list_t; 82 typedef struct dns_dnsseckey dns_dnsseckey_t; 83 typedef ISC_LIST(dns_dnsseckey_t) dns_dnsseckeylist_t; 84 typedef uint8_t dns_dsdigest_t; 85 typedef struct dns_dtdata dns_dtdata_t; 86 typedef struct dns_dtenv dns_dtenv_t; 87 typedef struct dns_dtmsg dns_dtmsg_t; 88 typedef uint16_t dns_dtmsgtype_t; 89 typedef struct dns_dumpctx dns_dumpctx_t; 90 typedef struct dns_ecs dns_ecs_t; 91 typedef struct dns_ednsopt dns_ednsopt_t; 92 typedef struct dns_fetch dns_fetch_t; 93 typedef struct dns_fixedname dns_fixedname_t; 94 typedef struct dns_forwarders dns_forwarders_t; 95 typedef struct dns_forwarder dns_forwarder_t; 96 typedef struct dns_fwdtable dns_fwdtable_t; 97 typedef struct dns_geoip_databases dns_geoip_databases_t; 98 typedef struct dns_glue dns_glue_t; 99 typedef struct dns_iptable dns_iptable_t; 100 typedef uint32_t dns_iterations_t; 101 typedef struct dns_kasp dns_kasp_t; 102 typedef ISC_LIST(dns_kasp_t) dns_kasplist_t; 103 typedef struct dns_kasp_digest dns_kasp_digest_t; 104 typedef ISC_LIST(dns_kasp_digest_t) dns_kasp_digestlist_t; 105 typedef struct dns_kasp_key dns_kasp_key_t; 106 typedef ISC_LIST(dns_kasp_key_t) dns_kasp_keylist_t; 107 typedef struct dns_kasp_nsec3param dns_kasp_nsec3param_t; 108 typedef uint16_t dns_keyflags_t; 109 typedef struct dns_keynode dns_keynode_t; 110 typedef ISC_LIST(dns_keynode_t) dns_keynodelist_t; 111 typedef struct dns_keytable dns_keytable_t; 112 typedef uint16_t dns_keytag_t; 113 typedef struct dns_keystore dns_keystore_t; 114 typedef ISC_LIST(dns_keystore_t) dns_keystorelist_t; 115 typedef struct dns_loadctx dns_loadctx_t; 116 typedef struct dns_loadmgr dns_loadmgr_t; 117 typedef struct dns_masterrawheader dns_masterrawheader_t; 118 typedef uint64_t dns_masterstyle_flags_t; 119 typedef struct dns_message dns_message_t; 120 typedef uint16_t dns_messageid_t; 121 typedef isc_region_t dns_label_t; 122 typedef struct dns_name dns_name_t; 123 typedef struct dns_nametree dns_nametree_t; 124 typedef ISC_LIST(dns_name_t) dns_namelist_t; 125 typedef struct dns_ntatable dns_ntatable_t; 126 typedef struct dns_ntnode dns_ntnode_t; 127 typedef uint16_t dns_opcode_t; 128 typedef struct dns_order dns_order_t; 129 typedef struct dns_peer dns_peer_t; 130 typedef struct dns_peerlist dns_peerlist_t; 131 typedef struct dns_slabheader_proof dns_slabheader_proof_t; 132 typedef struct dns_rbt dns_rbt_t; 133 typedef struct dns_rbtdb dns_rbtdb_t; 134 typedef struct dns_rbtdb_version dns_rbtdb_version_t; 135 typedef struct dns_rbtnode dns_rbtnode_t; 136 typedef ISC_LIST(dns_rbtnode_t) dns_rbtnodelist_t; 137 typedef uint16_t dns_rcode_t; 138 typedef struct dns_rdata dns_rdata_t; 139 typedef struct dns_rdatacallbacks dns_rdatacallbacks_t; 140 typedef uint16_t dns_rdataclass_t; 141 typedef struct dns_rdatalist dns_rdatalist_t; 142 typedef struct dns_rdataset dns_rdataset_t; 143 typedef ISC_LIST(dns_rdataset_t) dns_rdatasetlist_t; 144 typedef struct dns_rdatasetiter dns_rdatasetiter_t; 145 typedef uint16_t dns_rdatatype_t; 146 typedef struct dns_remote dns_remote_t; 147 typedef struct dns_request dns_request_t; 148 typedef struct dns_requestmgr dns_requestmgr_t; 149 typedef struct dns_resolver dns_resolver_t; 150 typedef struct dns_rpsdb dns_rpsdb_t; 151 typedef struct dns_qpnode dns_qpnode_t; 152 typedef uint8_t dns_secalg_t; 153 typedef uint8_t dns_secproto_t; 154 typedef struct dns_signature dns_signature_t; 155 typedef struct dns_skr dns_skr_t; 156 typedef struct dns_slabheader dns_slabheader_t; 157 typedef ISC_LIST(dns_slabheader_t) dns_slabheaderlist_t; 158 typedef struct dns_sortlist_arg dns_sortlist_arg_t; 159 typedef struct dns_ssurule dns_ssurule_t; 160 typedef struct dns_ssutable dns_ssutable_t; 161 typedef struct dns_stats dns_stats_t; 162 typedef uint32_t dns_rdatastatstype_t; 163 typedef struct dns_tkeyctx dns_tkeyctx_t; 164 typedef struct dns_transport dns_transport_t; 165 typedef struct dns_transport_list dns_transport_list_t; 166 typedef uint16_t dns_trust_t; 167 typedef struct dns_tsigkeyring dns_tsigkeyring_t; 168 typedef struct dns_tsigkey dns_tsigkey_t; 169 typedef uint32_t dns_ttl_t; 170 typedef uint32_t dns_typepair_t; 171 typedef struct dns_update_state dns_update_state_t; 172 typedef struct dns_validator dns_validator_t; 173 typedef struct dns_view dns_view_t; 174 typedef ISC_LIST(dns_view_t) dns_viewlist_t; 175 typedef struct dns_zone dns_zone_t; 176 typedef ISC_LIST(dns_zone_t) dns_zonelist_t; 177 typedef struct dns_zonemgr dns_zonemgr_t; 178 typedef struct dns_zt dns_zt_t; 179 typedef struct dns_ipkeylist dns_ipkeylist_t; 180 181 typedef struct dst_gssapi_signverifyctx dst_gssapi_signverifyctx_t; 182 183 typedef enum { dns_hash_sha1 = 1 } dns_hash_t; 184 185 typedef enum { 186 dns_fwdpolicy_none = 0, 187 dns_fwdpolicy_first = 1, 188 dns_fwdpolicy_only = 2 189 } dns_fwdpolicy_t; 190 191 typedef enum { 192 dns_namereln_none = 0, 193 dns_namereln_contains = 1, 194 dns_namereln_subdomain = 2, 195 dns_namereln_equal = 3, 196 dns_namereln_commonancestor = 4 197 } dns_namereln_t; 198 199 typedef enum { dns_one_answer, dns_many_answers } dns_transfer_format_t; 200 201 typedef enum { 202 dns_dbtype_zone = 0, 203 dns_dbtype_cache = 1, 204 dns_dbtype_stub = 3 205 } dns_dbtype_t; 206 207 typedef enum { 208 dns_dbtree_main = 0, 209 dns_dbtree_nsec = 1, 210 dns_dbtree_nsec3 = 2 211 } dns_dbtree_t; 212 213 typedef enum { 214 dns_checkdstype_no = 0, 215 dns_checkdstype_yes = 1, 216 dns_checkdstype_explicit = 2 217 } dns_checkdstype_t; 218 219 typedef enum { 220 dns_notifytype_no = 0, 221 dns_notifytype_yes = 1, 222 dns_notifytype_explicit = 2, 223 dns_notifytype_masteronly = 3 224 } dns_notifytype_t; 225 226 typedef enum { 227 dns_minimal_no = 0, 228 dns_minimal_yes = 1, 229 dns_minimal_noauth = 2, 230 dns_minimal_noauthrec = 3 231 } dns_minimaltype_t; 232 233 typedef enum { 234 dns_dialuptype_no = 0, 235 dns_dialuptype_yes = 1, 236 dns_dialuptype_notify = 2, 237 dns_dialuptype_notifypassive = 3, 238 dns_dialuptype_refresh = 4, 239 dns_dialuptype_passive = 5 240 } dns_dialuptype_t; 241 242 typedef enum { 243 dns_masterformat_none = 0, 244 dns_masterformat_text = 1, 245 dns_masterformat_raw = 2, 246 } dns_masterformat_t; 247 248 typedef enum { 249 dns_expire_lru = 0, 250 dns_expire_ttl = 1, 251 dns_expire_flush = 2, 252 } dns_expire_t; 253 254 /* 255 * These are generated by gen.c. 256 */ 257 #include <dns/enumclass.h> /* Provides dns_rdataclass_t. */ 258 #include <dns/enumtype.h> /* Provides dns_rdatatype_t. */ 259 260 /*% 261 * rcodes. 262 */ 263 enum { 264 /* 265 * Standard rcodes. 266 */ 267 dns_rcode_noerror = 0, 268 #define dns_rcode_noerror ((dns_rcode_t)dns_rcode_noerror) 269 dns_rcode_formerr = 1, 270 #define dns_rcode_formerr ((dns_rcode_t)dns_rcode_formerr) 271 dns_rcode_servfail = 2, 272 #define dns_rcode_servfail ((dns_rcode_t)dns_rcode_servfail) 273 dns_rcode_nxdomain = 3, 274 #define dns_rcode_nxdomain ((dns_rcode_t)dns_rcode_nxdomain) 275 dns_rcode_notimp = 4, 276 #define dns_rcode_notimp ((dns_rcode_t)dns_rcode_notimp) 277 dns_rcode_refused = 5, 278 #define dns_rcode_refused ((dns_rcode_t)dns_rcode_refused) 279 dns_rcode_yxdomain = 6, 280 #define dns_rcode_yxdomain ((dns_rcode_t)dns_rcode_yxdomain) 281 dns_rcode_yxrrset = 7, 282 #define dns_rcode_yxrrset ((dns_rcode_t)dns_rcode_yxrrset) 283 dns_rcode_nxrrset = 8, 284 #define dns_rcode_nxrrset ((dns_rcode_t)dns_rcode_nxrrset) 285 dns_rcode_notauth = 9, 286 #define dns_rcode_notauth ((dns_rcode_t)dns_rcode_notauth) 287 dns_rcode_notzone = 10, 288 #define dns_rcode_notzone ((dns_rcode_t)dns_rcode_notzone) 289 /* 290 * Extended rcodes. 291 */ 292 dns_rcode_badvers = 16, 293 #define dns_rcode_badvers ((dns_rcode_t)dns_rcode_badvers) 294 dns_rcode_badcookie = 23 295 #define dns_rcode_badcookie ((dns_rcode_t)dns_rcode_badcookie) 296 /* 297 * Update dns_rcodestats_create() and 298 *dns_rcodestats_increment() 299 * and this comment if a rcode > 300 *dns_rcode_badcookie is assigned. 301 */ 302 /* Private space [3841..4095] */ 303 }; 304 305 /*% 306 * TSIG errors. 307 */ 308 enum { 309 dns_tsigerror_badsig = 16, 310 dns_tsigerror_badkey = 17, 311 dns_tsigerror_badtime = 18, 312 dns_tsigerror_badmode = 19, 313 dns_tsigerror_badname = 20, 314 dns_tsigerror_badalg = 21, 315 dns_tsigerror_badtrunc = 22 316 }; 317 318 /*% 319 * Opcodes. 320 */ 321 enum { 322 dns_opcode_query = 0, 323 #define dns_opcode_query ((dns_opcode_t)dns_opcode_query) 324 dns_opcode_iquery = 1, 325 #define dns_opcode_iquery ((dns_opcode_t)dns_opcode_iquery) 326 dns_opcode_status = 2, 327 #define dns_opcode_status ((dns_opcode_t)dns_opcode_status) 328 dns_opcode_notify = 4, 329 #define dns_opcode_notify ((dns_opcode_t)dns_opcode_notify) 330 dns_opcode_update = 5 /* dynamic update */ 331 #define dns_opcode_update ((dns_opcode_t)dns_opcode_update) 332 }; 333 334 /*% 335 * Trust levels. Must be kept in sync with trustnames[] in masterdump.c. 336 */ 337 enum { 338 /* Sentinel value; no data should have this trust level. */ 339 dns_trust_none = 0, 340 #define dns_trust_none ((dns_trust_t)dns_trust_none) 341 342 /*% 343 * Subject to DNSSEC validation but has not yet been validated 344 * dns_trust_pending_additional (from the additional section). 345 */ 346 dns_trust_pending_additional = 1, 347 #define dns_trust_pending_additional ((dns_trust_t)dns_trust_pending_additional) 348 349 dns_trust_pending_answer = 2, 350 #define dns_trust_pending_answer ((dns_trust_t)dns_trust_pending_answer) 351 352 /*% Received in the additional section of a response. */ 353 dns_trust_additional = 3, 354 #define dns_trust_additional ((dns_trust_t)dns_trust_additional) 355 356 /* Received in a referral response. */ 357 dns_trust_glue = 4, 358 #define dns_trust_glue ((dns_trust_t)dns_trust_glue) 359 360 /* Answer from a non-authoritative server */ 361 dns_trust_answer = 5, 362 #define dns_trust_answer ((dns_trust_t)dns_trust_answer) 363 364 /* Received in the authority section as part of an 365 * authoritative response */ 366 dns_trust_authauthority = 6, 367 #define dns_trust_authauthority ((dns_trust_t)dns_trust_authauthority) 368 369 /* Answer from an authoritative server */ 370 dns_trust_authanswer = 7, 371 #define dns_trust_authanswer ((dns_trust_t)dns_trust_authanswer) 372 373 /* Successfully DNSSEC validated */ 374 dns_trust_secure = 8, 375 #define dns_trust_secure ((dns_trust_t)dns_trust_secure) 376 377 /* This server is authoritative */ 378 dns_trust_ultimate = 9 379 #define dns_trust_ultimate ((dns_trust_t)dns_trust_ultimate) 380 }; 381 382 #define DNS_TRUST_PENDING(x) \ 383 ((x) == dns_trust_pending_answer || (x) == dns_trust_pending_additional) 384 #define DNS_TRUST_ADDITIONAL(x) \ 385 ((x) == dns_trust_additional || (x) == dns_trust_pending_additional) 386 #define DNS_TRUST_GLUE(x) ((x) == dns_trust_glue) 387 #define DNS_TRUST_ANSWER(x) ((x) == dns_trust_answer) 388 389 /*% 390 * Name checking severities. 391 */ 392 typedef enum { 393 dns_severity_ignore, 394 dns_severity_warn, 395 dns_severity_fail 396 } dns_severity_t; 397 398 /*% 399 * DNS Serial Number Update Method. 400 * 401 * \li _none: Keep the current serial. 402 * \li _increment: Add one to the current serial, skipping 0. 403 * \li _unixtime: Set to the seconds since 00:00 Jan 1, 1970, 404 * if possible. 405 * \li _date: Set to today's date in YYYYMMDDVV format: 406 * (Year, Month, Day, Version) 407 */ 408 typedef enum { 409 dns_updatemethod_none = 0, 410 dns_updatemethod_increment, 411 dns_updatemethod_unixtime, 412 dns_updatemethod_date 413 } dns_updatemethod_t; 414 415 typedef enum { 416 dns_stale_answer_no, 417 dns_stale_answer_yes, 418 dns_stale_answer_conf 419 } dns_stale_answer_t; 420 421 typedef struct { 422 const char *string; 423 size_t count; 424 } dns_indent_t; 425 426 /* 427 * Functions. 428 */ 429 typedef void (*dns_dumpdonefunc_t)(void *, isc_result_t); 430 431 typedef void (*dns_loaddonefunc_t)(void *, isc_result_t); 432 433 typedef void (*dns_rawdatafunc_t)(dns_zone_t *, dns_masterrawheader_t *); 434 435 typedef isc_result_t (*dns_addrdatasetfunc_t)(void *arg, const dns_name_t *name, 436 dns_rdataset_t *rdataset 437 DNS__DB_FLARG); 438 typedef void (*dns_transactionfunc_t)(void *arg); 439 440 typedef isc_result_t (*dns_additionaldatafunc_t)( 441 void *arg, const dns_name_t *name, dns_rdatatype_t type, 442 dns_rdataset_t *rdataset DNS__DB_FLARG); 443 444 typedef isc_result_t (*dns_digestfunc_t)(void *, isc_region_t *); 445 446 typedef void (*dns_xfrindone_t)(dns_zone_t *, uint32_t *, isc_result_t); 447 448 typedef void (*dns_updatecallback_t)(void *, isc_result_t, dns_message_t *); 449 450 typedef int (*dns_rdatasetorderfunc_t)(const dns_rdata_t *, const void *); 451 452 typedef bool (*dns_checkmxfunc_t)(dns_zone_t *, const dns_name_t *, 453 const dns_name_t *); 454 455 typedef bool (*dns_checksrvfunc_t)(dns_zone_t *, const dns_name_t *, 456 const dns_name_t *); 457 458 typedef bool (*dns_checknsfunc_t)(dns_zone_t *, const dns_name_t *, 459 const dns_name_t *, dns_rdataset_t *, 460 dns_rdataset_t *); 461 462 typedef bool (*dns_isselffunc_t)(dns_view_t *, dns_tsigkey_t *, 463 const isc_sockaddr_t *, const isc_sockaddr_t *, 464 dns_rdataclass_t, void *); 465 466 typedef void (*dns_nseclog_t)(void *val, int, const char *, ...); 467