1 /* $NetBSD: types.h,v 1.12 2026/04/08 00:16:14 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 uint8_t dns_dsyncscheme_t; 86 typedef struct dns_dtdata dns_dtdata_t; 87 typedef struct dns_dtenv dns_dtenv_t; 88 typedef struct dns_dtmsg dns_dtmsg_t; 89 typedef uint16_t dns_dtmsgtype_t; 90 typedef struct dns_dumpctx dns_dumpctx_t; 91 typedef struct dns_ecs dns_ecs_t; 92 typedef struct dns_ednsopt dns_ednsopt_t; 93 typedef struct dns_fetch dns_fetch_t; 94 typedef struct dns_fixedname dns_fixedname_t; 95 typedef struct dns_forwarders dns_forwarders_t; 96 typedef struct dns_forwarder dns_forwarder_t; 97 typedef struct dns_fwdtable dns_fwdtable_t; 98 typedef struct dns_geoip_databases dns_geoip_databases_t; 99 typedef struct dns_glue dns_glue_t; 100 typedef struct dns_gluelist dns_gluelist_t; 101 typedef struct dns_iptable dns_iptable_t; 102 typedef uint32_t dns_iterations_t; 103 typedef struct dns_kasp dns_kasp_t; 104 typedef ISC_LIST(dns_kasp_t) dns_kasplist_t; 105 typedef struct dns_kasp_digest dns_kasp_digest_t; 106 typedef ISC_LIST(dns_kasp_digest_t) dns_kasp_digestlist_t; 107 typedef struct dns_kasp_key dns_kasp_key_t; 108 typedef ISC_LIST(dns_kasp_key_t) dns_kasp_keylist_t; 109 typedef struct dns_kasp_nsec3param dns_kasp_nsec3param_t; 110 typedef uint16_t dns_keyflags_t; 111 typedef struct dns_keynode dns_keynode_t; 112 typedef ISC_LIST(dns_keynode_t) dns_keynodelist_t; 113 typedef struct dns_keytable dns_keytable_t; 114 typedef uint16_t dns_keytag_t; 115 typedef struct dns_keystore dns_keystore_t; 116 typedef ISC_LIST(dns_keystore_t) dns_keystorelist_t; 117 typedef struct dns_loadctx dns_loadctx_t; 118 typedef struct dns_loadmgr dns_loadmgr_t; 119 typedef struct dns_masterrawheader dns_masterrawheader_t; 120 typedef uint64_t dns_masterstyle_flags_t; 121 typedef struct dns_message dns_message_t; 122 typedef uint16_t dns_messageid_t; 123 typedef isc_region_t dns_label_t; 124 typedef struct dns_name dns_name_t; 125 typedef struct dns_nametree dns_nametree_t; 126 typedef ISC_LIST(dns_name_t) dns_namelist_t; 127 typedef struct dns_ntatable dns_ntatable_t; 128 typedef struct dns_ntnode dns_ntnode_t; 129 typedef uint16_t dns_opcode_t; 130 typedef struct dns_order dns_order_t; 131 typedef struct dns_peer dns_peer_t; 132 typedef struct dns_peerlist dns_peerlist_t; 133 typedef struct dns_slabheader_proof dns_slabheader_proof_t; 134 typedef struct dns_rbt dns_rbt_t; 135 typedef struct dns_rbtdb dns_rbtdb_t; 136 typedef struct dns_rbtdb_version dns_rbtdb_version_t; 137 typedef struct dns_rbtnode dns_rbtnode_t; 138 typedef ISC_LIST(dns_rbtnode_t) dns_rbtnodelist_t; 139 typedef uint16_t dns_rcode_t; 140 typedef struct dns_rdata dns_rdata_t; 141 typedef struct dns_rdatacallbacks dns_rdatacallbacks_t; 142 typedef uint16_t dns_rdataclass_t; 143 typedef struct dns_rdatalist dns_rdatalist_t; 144 typedef struct dns_rdataset dns_rdataset_t; 145 typedef ISC_LIST(dns_rdataset_t) dns_rdatasetlist_t; 146 typedef struct dns_rdatasetiter dns_rdatasetiter_t; 147 typedef uint16_t dns_rdatatype_t; 148 typedef struct dns_remote dns_remote_t; 149 typedef struct dns_request dns_request_t; 150 typedef struct dns_requestmgr dns_requestmgr_t; 151 typedef struct dns_resolver dns_resolver_t; 152 typedef struct dns_rpsdb dns_rpsdb_t; 153 typedef struct dns_qpnode dns_qpnode_t; 154 typedef uint8_t dns_secalg_t; 155 typedef uint8_t dns_secproto_t; 156 typedef struct dns_signature dns_signature_t; 157 typedef struct dns_skr dns_skr_t; 158 typedef struct dns_slabheader dns_slabheader_t; 159 typedef ISC_LIST(dns_slabheader_t) dns_slabheaderlist_t; 160 typedef struct dns_sortlist_arg dns_sortlist_arg_t; 161 typedef struct dns_ssurule dns_ssurule_t; 162 typedef struct dns_ssutable dns_ssutable_t; 163 typedef struct dns_stats dns_stats_t; 164 typedef uint32_t dns_rdatastatstype_t; 165 typedef struct dns_tkeyctx dns_tkeyctx_t; 166 typedef struct dns_transport dns_transport_t; 167 typedef struct dns_transport_list dns_transport_list_t; 168 typedef uint16_t dns_trust_t; 169 typedef struct dns_tsigkeyring dns_tsigkeyring_t; 170 typedef struct dns_tsigkey dns_tsigkey_t; 171 typedef uint32_t dns_ttl_t; 172 typedef uint32_t dns_typepair_t; 173 typedef struct dns_update_state dns_update_state_t; 174 typedef struct dns_validator dns_validator_t; 175 typedef struct dns_view dns_view_t; 176 typedef ISC_LIST(dns_view_t) dns_viewlist_t; 177 typedef struct dns_zone dns_zone_t; 178 typedef ISC_LIST(dns_zone_t) dns_zonelist_t; 179 typedef struct dns_zonemgr dns_zonemgr_t; 180 typedef struct dns_zt dns_zt_t; 181 typedef struct dns_ipkeylist dns_ipkeylist_t; 182 183 typedef struct dst_gssapi_signverifyctx dst_gssapi_signverifyctx_t; 184 185 typedef enum { dns_hash_sha1 = 1 } dns_hash_t; 186 187 typedef enum { 188 DNS_DIFFOP_ADD = 0, /*%< Add an RR. */ 189 DNS_DIFFOP_DEL = 1, /*%< Delete an RR. */ 190 DNS_DIFFOP_EXISTS = 2, /*%< Assert RR existence. */ 191 DNS_DIFFOP_ADDRESIGN = 4, /*%< ADD + RESIGN. */ 192 DNS_DIFFOP_DELRESIGN = 5 /*%< DEL + RESIGN. */ 193 } dns_diffop_t; 194 195 typedef enum { 196 dns_fwdpolicy_none = 0, 197 dns_fwdpolicy_first = 1, 198 dns_fwdpolicy_only = 2 199 } dns_fwdpolicy_t; 200 201 typedef enum { 202 dns_namereln_none = 0, 203 dns_namereln_contains = 1, 204 dns_namereln_subdomain = 2, 205 dns_namereln_equal = 3, 206 dns_namereln_commonancestor = 4 207 } dns_namereln_t; 208 209 typedef enum { dns_one_answer, dns_many_answers } dns_transfer_format_t; 210 211 typedef enum { 212 dns_dbtype_zone = 0, 213 dns_dbtype_cache = 1, 214 dns_dbtype_stub = 3 215 } dns_dbtype_t; 216 217 typedef enum { 218 dns_dbtree_main = 0, 219 dns_dbtree_nsec = 1, 220 dns_dbtree_nsec3 = 2 221 } dns_dbtree_t; 222 223 typedef enum { 224 dns_checkdstype_no = 0, 225 dns_checkdstype_yes = 1, 226 dns_checkdstype_explicit = 2 227 } dns_checkdstype_t; 228 229 typedef enum { 230 dns_notifytype_no = 0, 231 dns_notifytype_yes = 1, 232 dns_notifytype_explicit = 2, 233 dns_notifytype_masteronly = 3 234 } dns_notifytype_t; 235 236 typedef enum { 237 dns_minimal_no = 0, 238 dns_minimal_yes = 1, 239 dns_minimal_noauth = 2, 240 dns_minimal_noauthrec = 3 241 } dns_minimaltype_t; 242 243 typedef enum { 244 dns_dialuptype_no = 0, 245 dns_dialuptype_yes = 1, 246 dns_dialuptype_notify = 2, 247 dns_dialuptype_notifypassive = 3, 248 dns_dialuptype_refresh = 4, 249 dns_dialuptype_passive = 5 250 } dns_dialuptype_t; 251 252 typedef enum { 253 dns_masterformat_none = 0, 254 dns_masterformat_text = 1, 255 dns_masterformat_raw = 2, 256 } dns_masterformat_t; 257 258 typedef enum { 259 dns_expire_lru = 0, 260 dns_expire_ttl = 1, 261 dns_expire_flush = 2, 262 } dns_expire_t; 263 264 /* 265 * These are generated by gen.c. 266 */ 267 #include <dns/enumclass.h> /* Provides dns_rdataclass_t. */ 268 #include <dns/enumtype.h> /* Provides dns_rdatatype_t. */ 269 270 /*% 271 * rcodes. 272 */ 273 enum { 274 /* 275 * Standard rcodes. 276 */ 277 dns_rcode_noerror = 0, 278 #define dns_rcode_noerror ((dns_rcode_t)dns_rcode_noerror) 279 dns_rcode_formerr = 1, 280 #define dns_rcode_formerr ((dns_rcode_t)dns_rcode_formerr) 281 dns_rcode_servfail = 2, 282 #define dns_rcode_servfail ((dns_rcode_t)dns_rcode_servfail) 283 dns_rcode_nxdomain = 3, 284 #define dns_rcode_nxdomain ((dns_rcode_t)dns_rcode_nxdomain) 285 dns_rcode_notimp = 4, 286 #define dns_rcode_notimp ((dns_rcode_t)dns_rcode_notimp) 287 dns_rcode_refused = 5, 288 #define dns_rcode_refused ((dns_rcode_t)dns_rcode_refused) 289 dns_rcode_yxdomain = 6, 290 #define dns_rcode_yxdomain ((dns_rcode_t)dns_rcode_yxdomain) 291 dns_rcode_yxrrset = 7, 292 #define dns_rcode_yxrrset ((dns_rcode_t)dns_rcode_yxrrset) 293 dns_rcode_nxrrset = 8, 294 #define dns_rcode_nxrrset ((dns_rcode_t)dns_rcode_nxrrset) 295 dns_rcode_notauth = 9, 296 #define dns_rcode_notauth ((dns_rcode_t)dns_rcode_notauth) 297 dns_rcode_notzone = 10, 298 #define dns_rcode_notzone ((dns_rcode_t)dns_rcode_notzone) 299 /* 300 * Extended rcodes. 301 */ 302 dns_rcode_badvers = 16, 303 #define dns_rcode_badvers ((dns_rcode_t)dns_rcode_badvers) 304 dns_rcode_badcookie = 23 305 #define dns_rcode_badcookie ((dns_rcode_t)dns_rcode_badcookie) 306 /* 307 * Update dns_rcodestats_create() and 308 *dns_rcodestats_increment() 309 * and this comment if a rcode > 310 *dns_rcode_badcookie is assigned. 311 */ 312 /* Private space [3841..4095] */ 313 }; 314 315 /*% 316 * TSIG errors. 317 */ 318 enum { 319 dns_tsigerror_badsig = 16, 320 dns_tsigerror_badkey = 17, 321 dns_tsigerror_badtime = 18, 322 dns_tsigerror_badmode = 19, 323 dns_tsigerror_badname = 20, 324 dns_tsigerror_badalg = 21, 325 dns_tsigerror_badtrunc = 22 326 }; 327 328 /*% 329 * Opcodes. 330 */ 331 enum { 332 dns_opcode_query = 0, 333 #define dns_opcode_query ((dns_opcode_t)dns_opcode_query) 334 dns_opcode_iquery = 1, 335 #define dns_opcode_iquery ((dns_opcode_t)dns_opcode_iquery) 336 dns_opcode_status = 2, 337 #define dns_opcode_status ((dns_opcode_t)dns_opcode_status) 338 dns_opcode_notify = 4, 339 #define dns_opcode_notify ((dns_opcode_t)dns_opcode_notify) 340 dns_opcode_update = 5 /* dynamic update */ 341 #define dns_opcode_update ((dns_opcode_t)dns_opcode_update) 342 }; 343 344 /*% 345 * Trust levels. Must be kept in sync with trustnames[] in masterdump.c. 346 */ 347 enum { 348 /* Sentinel value; no data should have this trust level. */ 349 dns_trust_none = 0, 350 #define dns_trust_none ((dns_trust_t)dns_trust_none) 351 352 /*% 353 * Subject to DNSSEC validation but has not yet been validated 354 * dns_trust_pending_additional (from the additional section). 355 */ 356 dns_trust_pending_additional = 1, 357 #define dns_trust_pending_additional ((dns_trust_t)dns_trust_pending_additional) 358 359 dns_trust_pending_answer = 2, 360 #define dns_trust_pending_answer ((dns_trust_t)dns_trust_pending_answer) 361 362 /*% Received in the additional section of a response. */ 363 dns_trust_additional = 3, 364 #define dns_trust_additional ((dns_trust_t)dns_trust_additional) 365 366 /* Received in a referral response. */ 367 dns_trust_glue = 4, 368 #define dns_trust_glue ((dns_trust_t)dns_trust_glue) 369 370 /* Answer from a non-authoritative server */ 371 dns_trust_answer = 5, 372 #define dns_trust_answer ((dns_trust_t)dns_trust_answer) 373 374 /* Received in the authority section as part of an 375 * authoritative response */ 376 dns_trust_authauthority = 6, 377 #define dns_trust_authauthority ((dns_trust_t)dns_trust_authauthority) 378 379 /* Answer from an authoritative server */ 380 dns_trust_authanswer = 7, 381 #define dns_trust_authanswer ((dns_trust_t)dns_trust_authanswer) 382 383 /* Successfully DNSSEC validated */ 384 dns_trust_secure = 8, 385 #define dns_trust_secure ((dns_trust_t)dns_trust_secure) 386 387 /* This server is authoritative */ 388 dns_trust_ultimate = 9 389 #define dns_trust_ultimate ((dns_trust_t)dns_trust_ultimate) 390 }; 391 392 #define DNS_TRUST_PENDING(x) \ 393 ((x) == dns_trust_pending_answer || (x) == dns_trust_pending_additional) 394 #define DNS_TRUST_ADDITIONAL(x) \ 395 ((x) == dns_trust_additional || (x) == dns_trust_pending_additional) 396 #define DNS_TRUST_GLUE(x) ((x) == dns_trust_glue) 397 #define DNS_TRUST_ANSWER(x) ((x) == dns_trust_answer) 398 #define DNS_TRUST_SECURE(x) ((x) >= dns_trust_secure) 399 400 /*% 401 * Name checking severities. 402 */ 403 typedef enum { 404 dns_severity_ignore, 405 dns_severity_warn, 406 dns_severity_fail 407 } dns_severity_t; 408 409 /*% 410 * DNS Serial Number Update Method. 411 * 412 * \li _none: Keep the current serial. 413 * \li _increment: Add one to the current serial, skipping 0. 414 * \li _unixtime: Set to the seconds since 00:00 Jan 1, 1970, 415 * if possible. 416 * \li _date: Set to today's date in YYYYMMDDVV format: 417 * (Year, Month, Day, Version) 418 */ 419 typedef enum { 420 dns_updatemethod_none = 0, 421 dns_updatemethod_increment, 422 dns_updatemethod_unixtime, 423 dns_updatemethod_date 424 } dns_updatemethod_t; 425 426 typedef enum { 427 dns_stale_answer_no, 428 dns_stale_answer_yes, 429 dns_stale_answer_conf 430 } dns_stale_answer_t; 431 432 typedef struct { 433 const char *string; 434 size_t count; 435 } dns_indent_t; 436 437 /* 438 * Functions. 439 */ 440 typedef void (*dns_dumpdonefunc_t)(void *, isc_result_t); 441 442 typedef void (*dns_loaddonefunc_t)(void *, isc_result_t); 443 444 typedef void (*dns_rawdatafunc_t)(dns_zone_t *, dns_masterrawheader_t *); 445 446 typedef isc_result_t (*dns_addrdatasetfunc_t)(void *arg, const dns_name_t *name, 447 dns_rdataset_t *rdataset, 448 dns_diffop_t op DNS__DB_FLARG); 449 typedef void (*dns_transactionfunc_t)(void *arg); 450 451 typedef isc_result_t (*dns_additionaldatafunc_t)( 452 void *arg, const dns_name_t *name, dns_rdatatype_t type, 453 dns_rdataset_t *rdataset DNS__DB_FLARG); 454 455 typedef isc_result_t (*dns_digestfunc_t)(void *, isc_region_t *); 456 457 typedef void (*dns_xfrindone_t)(dns_zone_t *, uint32_t *, isc_result_t); 458 459 typedef void (*dns_updatecallback_t)(void *, isc_result_t, dns_message_t *); 460 461 typedef int (*dns_rdatasetorderfunc_t)(const dns_rdata_t *, const void *); 462 463 typedef bool (*dns_checkmxfunc_t)(dns_zone_t *, const dns_name_t *, 464 const dns_name_t *); 465 466 typedef bool (*dns_checksrvfunc_t)(dns_zone_t *, const dns_name_t *, 467 const dns_name_t *); 468 469 typedef bool (*dns_checknsfunc_t)(dns_zone_t *, const dns_name_t *, 470 const dns_name_t *, dns_rdataset_t *, 471 dns_rdataset_t *); 472 473 typedef bool (*dns_isselffunc_t)(dns_view_t *, dns_tsigkey_t *, 474 const isc_sockaddr_t *, const isc_sockaddr_t *, 475 dns_rdataclass_t, void *); 476 477 typedef void (*dns_nseclog_t)(void *val, int, const char *, ...); 478