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