]> git.saurik.com Git - apple/mdnsresponder.git/blob - mDNSMacOSX/mdns_objects/mdns_trust_checks.h
mDNSResponder-1310.40.42.tar.gz
[apple/mdnsresponder.git] / mDNSMacOSX / mdns_objects / mdns_trust_checks.h
1 /*
2 * Copyright (c) 2019-2020 Apple Inc. All rights reserved.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * https://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 #ifndef __MDNS_TRUST_CHECKS_H__
18 #define __MDNS_TRUST_CHECKS_H__
19
20 #include "mdns_base.h"
21 #include <dispatch/dispatch.h>
22
23 OS_CLOSED_ENUM(trust_policy_state, int,
24 trust_policy_state_denied = 0,
25 trust_policy_state_granted = 1,
26 trust_policy_state_pending = 2
27 );
28
29 OS_CLOSED_ENUM(trust_request, int,
30 trust_request_bonjour = 0,
31 trust_request_reg_service = 1,
32 trust_request_query = 2
33 );
34
35 MDNS_ASSUME_NONNULL_BEGIN
36
37 static inline const char *
38 _mdns_trust_checks_policy_to_string(trust_policy_state_t state)
39 {
40 switch (state) {
41 case trust_policy_state_denied: return "denied";
42 case trust_policy_state_granted: return "granted";
43 case trust_policy_state_pending: return "pending";
44 default: return "<INVALID STATE>";
45 }
46 }
47
48 static inline const char *
49 _mdns_trust_checks_request_to_string(trust_request_t request)
50 {
51 switch (request) {
52 case trust_request_bonjour: return "bonjour";
53 case trust_request_reg_service: return "reg_service";
54 case trust_request_query: return "query";
55 default: return "<INVALID REQUEST>";
56 }
57 }
58
59 void
60 mdns_trust_checks_init(void);
61
62 typedef void
63 (^_mdns_trust_checks_update_handler_t)(trust_policy_state_t status);
64
65 void
66 mdns_trust_checks_local_network_access_policy_update(audit_token_t *auditToken, dispatch_queue_t queue,
67 const char * _Nullable query, mdns_trust_flags_t flags, _mdns_trust_checks_update_handler_t handler);
68
69 mdns_trust_status_t
70 mdns_trust_checks_check(audit_token_t *audit_token, trust_request_t request, const char * _Nullable query_name,
71 const char * _Nullable service_name, uint16_t qtype, bool force_multicast, mdns_trust_flags_t * _Nullable flags);
72
73 MDNS_ASSUME_NONNULL_END
74
75 #endif // __MDNS_TRUST_CHECKS_H__