2 // dnssec_v2_retrieval.h
5 // Copyright (c) 2020 Apple Inc. All rights reserved.
8 #ifndef DNSSEC_v2_RETRIEVAL_H
9 #define DNSSEC_v2_RETRIEVAL_H
11 #include "mDNSEmbeddedAPI.h" // for mStatus
12 #if MDNSRESPONDER_SUPPORTS(APPLE, DNSSECv2)
13 #include "ClientRequests.h" // QueryRecordOp
14 #include "dnssec_v2_embedded.h" // for dnssec_status_t
15 #include "dnssec_v2_structs.h"
17 typedef enum dnssec_retrieval_result
{
19 dnssec_retrieval_no_error
= 0,
20 dnssec_retrieval_waiting_for_records
= 1,
21 dnssec_retrieval_validate_again
= 2,
22 dnssec_retrieval_no_new_change
= 3,
23 dnssec_retrieval_suppressed
= 4,
24 dnssec_retrieval_cname_removed
= 5,
27 dnssec_retrieval_no_rrsig
= -65537,
28 dnssec_retrieval_zone_not_found
= -65538,
29 dnssec_retrieval_invalid_qtype
= -65539,
30 dnssec_retrieval_record_not_added
= -65540,
31 dnssec_retrieval_no_record
= -65541,
32 dnssec_retrieval_not_qc_add
= -65542,
33 dnssec_retrieval_too_many_zones
= -65543,
34 dnssec_retrieval_query_failed
= -65544,
35 dnssec_retrieval_unknown_error
= -65545,
36 dnssec_retrieval_invalid_wildcard
= -65546,
37 dnssec_retrieval_invalid_internal_state
= -65547,
38 dnssec_retrieval_non_dnskey_ds_record_for_zone
= -65548
39 } dnssec_retrieval_result_t
;
41 //======================================================================================================================
42 // function prototypes
43 //======================================================================================================================
47 initialize_dnssec_status_t(dnssec_status_t
* const _Nonnull status
, const domainname
* const _Nonnull qname
,
48 const mDNSu16 qtype
, const mDNSu32 flags
, void * const _Nonnull context
);
51 uninitialize_dnssec_status_t(dnssec_status_t
* const _Nonnull status
);
53 #pragma mark - dnssec_context_t function prototypes
55 create_dnssec_context_t(
56 QueryRecordClientRequest
* const _Nullable request
,
57 const mDNSu32 request_id
,
58 const domainname
* const _Nonnull question_name
,
59 const mDNSu16 question_type
,
60 const mDNSu16 question_class
,
61 const mDNSInterfaceID _Nullable interface_id
,
62 const mDNSs32 service_id
,
64 const mDNSBool append_search_domains
,
66 const mDNSu8
* _Nullable uuid
,
68 #if MDNSRESPONDER_SUPPORTS(APPLE, AUDIT_TOKEN)
69 const audit_token_t
* _Nullable peer_audit_token_ptr
,
70 const audit_token_t
* _Nullable delegate_audit_token_ptr
,
72 #if MDNSRESPONDER_SUPPORTS(APPLE, QUERIER)
73 const mDNSu8
* _Nullable resolver_uuid
,
74 mDNSBool need_encryption
,
75 const mdns_dns_service_id_t custom_id
,
77 const QueryRecordResultHandler _Nonnull result_handler
,
78 void * const _Nullable result_context
,
79 dnssec_context_t
* const _Nullable primary_dnssec_context
,
80 dnssec_context_t
* _Nullable
* const _Nonnull out_dnssec_context
);
83 print_dnssec_context_t(const dnssec_context_t
* const _Nonnull context
);
86 destroy_dnssec_context_t(dnssec_context_t
* const _Nonnull context
);
88 mDNSexport dnssec_retrieval_result_t
90 mDNS
*const _Nonnull m
,
91 DNSQuestion
* _Nonnull question
,
92 const ResourceRecord
* const _Nonnull answer
,
93 const QC_result add_record
,
94 const DNSServiceErrorType dns_result_error
,
95 dnssec_context_t
* const _Nonnull dnssec_context
);
97 mDNSexport dnssec_retrieval_result_t
98 add_denial_of_existence_records(
99 const mDNS
*const _Nonnull m
,
100 const DNSQuestion
* _Nonnull question
,
101 ResourceRecord
* const _Nonnull answer
,
102 const QC_result add_record
,
103 const DNSServiceErrorType dns_result_error
,
104 dnssec_context_t
* const _Nonnull dnssec_context
);
106 mDNSexport dnssec_retrieval_result_t
107 fetch_necessary_dnssec_records(dnssec_context_t
* const _Nonnull context
, mDNSBool anchor_reached
);
109 // list_t<dnssec_zone_t>
110 mDNSexport dnssec_zone_t
* _Nullable
111 find_dnssec_zone_t(const list_t
* const _Nonnull zones
, const mDNSu8
* const _Nonnull name
);
113 // cnames_with_rrsig_t
115 add_to_cname_with_rrsig_t(cnames_with_rrsig_t
* const _Nonnull cnames_with_rrisg
, ResourceRecord
* const _Nonnull rr
);
118 remove_from_cname_with_rrsig_t(cnames_with_rrsig_t
* const _Nonnull cnames_with_rrisg
, const ResourceRecord
* const _Nonnull rr
);
120 // nsecs_with_rrsig_t
122 add_to_nsec_with_rrsig_t(nsecs_with_rrsig_t
* const _Nonnull nsecs_with_rrisg
, ResourceRecord
* const _Nonnull rr
);
125 remove_from_nsec_with_rrsig_t(nsecs_with_rrsig_t
* const _Nonnull nsecs_with_rrisg
, const ResourceRecord
* const _Nonnull rr
);
127 // nsec3s_with_rrsig_t
129 add_to_nsec3_with_rrsig_t(nsec3s_with_rrsig_t
* const _Nonnull nsec3s_with_rrisg
, ResourceRecord
* const _Nonnull rr
);
132 remove_from_nsec3_with_rrsig_t(nsec3s_with_rrsig_t
* const _Nonnull nsec3s_with_rrisg
, const ResourceRecord
* const _Nonnull rr
);
134 // originals_with_rrsig_t
136 add_to_originals_with_rrsig_t(
137 originals_with_rrsig_t
* const _Nonnull originals_with_rrisg
,
138 ResourceRecord
* const _Nonnull rr
,
139 const mDNSBool answer_from_cache
,
140 const DNSServiceErrorType dns_error
,
141 const QC_result qc_result
);
144 remove_from_originals_with_rrsig_t(
145 originals_with_rrsig_t
* const _Nonnull originals_with_rrisg
,
146 const ResourceRecord
* const _Nonnull rr
);
148 // dnskeys_with_rrsig_t
150 add_to_dnskeys_with_rrsig_t(dnskeys_with_rrsig_t
* const _Nonnull dnskeys_with_rrsig
, ResourceRecord
* const _Nonnull rr
);
153 remove_from_dnskeys_with_rrsig_t(dnskeys_with_rrsig_t
* const _Nonnull dnskeys_with_rrsig
, const ResourceRecord
* const _Nonnull rr
);
157 add_to_dses_with_rrsig_t(dses_with_rrsig_t
* const _Nonnull dses_with_rrsig
, ResourceRecord
* const _Nonnull rr
);
160 remove_from_dses_with_rrsig_t(dses_with_rrsig_t
* const _Nonnull dses_with_rrsig
, const ResourceRecord
* const _Nonnull rr
);
162 // denial_of_existence_records_t
163 mDNSexport denial_of_existence_records_t
* _Nullable
164 create_denial_of_existence_records_t(void);
167 destroy_denial_of_existence_records_t(denial_of_existence_records_t
* const _Nonnull denial_of_existence_records
);
170 destroy_denial_of_existence_records_t_if_nonnull(denial_of_existence_records_t
* const _Nonnull denial_of_existence_records
);
173 add_to_denial_of_existence_records_t(denial_of_existence_records_t
* const _Nonnull denial_of_existence_records
, const ResourceRecord
* const _Nonnull rr
);
177 add_to_dnssec_zone_t(
178 dnssec_zone_t
* const _Nonnull zone
,
179 ResourceRecord
* const _Nonnull rr
,
180 const mDNSu16 question_type
);
182 mDNSexport dnssec_retrieval_result_t
183 update_dnssec_zone_t_from_cache_for_no_error_response(
184 const mDNS
* const _Nonnull m
,
185 const DNSQuestion
* const _Nonnull question
,
186 const ResourceRecord
* const _Nonnull answer
,
187 const QC_result add_record
,
188 dnssec_zone_t
* const _Nonnull zone
);
190 mDNSexport dnssec_retrieval_result_t
191 update_original_from_cache_for_no_error_response(
192 mDNS
* const _Nonnull m
,
193 const DNSQuestion
* const _Nonnull question
,
194 const ResourceRecord
* const _Nonnull answer
,
195 const QC_result add_record
,
196 const DNSServiceErrorType dns_result_error
,
197 dnssec_context_t
* const _Nonnull dnssec_context
);
199 mDNSexport dnssec_retrieval_result_t
200 update_original_from_cache_for_denial_of_existence_response(
201 const mDNS
*const _Nonnull m
,
202 const DNSQuestion
* _Nonnull question
,
203 ResourceRecord
* const _Nonnull answer
,
204 const QC_result add_record
,
205 const DNSServiceErrorType dns_result_error
,
206 dnssec_context_t
* const _Nonnull dnssec_context
);
208 #endif // MDNSRESPONDER_SUPPORTS(APPLE, DNSSECv2)
209 #endif /* DNSSEC_v2_RETRIEVAL_H */