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