]>
Commit | Line | Data |
---|---|---|
942cecd7 | 1 | /* |
afb19109 | 2 | * Copyright (c) 2015-2018 Apple Inc. All rights reserved. |
942cecd7 A |
3 | * |
4 | * @APPLE_LICENSE_HEADER_START@ | |
5 | * | |
6 | * This file contains Original Code and/or Modifications of Original Code | |
7 | * as defined in and that are subject to the Apple Public Source License | |
8 | * Version 2.0 (the 'License'). You may not use this file except in | |
9 | * compliance with the License. Please obtain a copy of the License at | |
10 | * http://www.opensource.apple.com/apsl/ and read it before using this | |
11 | * file. | |
12 | * | |
13 | * The Original Code and all software distributed under the License are | |
14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER | |
15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, | |
16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. | |
18 | * Please see the License for the specific language governing rights and | |
19 | * limitations under the License. | |
20 | * | |
21 | * @APPLE_LICENSE_HEADER_END@ | |
22 | */ | |
23 | ||
24 | #import "controller.h" | |
25 | ||
afb19109 A |
26 | static Boolean |
27 | haveNetworkExtensionFramework() | |
28 | { | |
29 | Boolean haveFramework; | |
30 | ||
31 | haveFramework = ([NEPolicy class] != nil); | |
32 | return haveFramework; | |
33 | } | |
34 | ||
942cecd7 | 35 | void |
f715d946 | 36 | process_AgentMonitor(void) |
942cecd7 | 37 | { |
afb19109 A |
38 | if (!haveNetworkExtensionFramework()) { |
39 | return; | |
40 | } | |
41 | ||
942cecd7 A |
42 | SC_log(LOG_DEBUG, "Triggering AgentMonitor"); |
43 | @autoreleasepool { | |
44 | AgentController *controller = [AgentController sharedController]; | |
45 | if (controller == nil) { | |
46 | SC_log(LOG_ERR, "AgentController could not be initialized"); | |
47 | return; | |
48 | } | |
49 | ||
50 | dispatch_sync(controller.controllerQueue, ^{ | |
51 | [[AgentController sharedController] processDNSChanges]; | |
52 | [[AgentController sharedController] processProxyChanges]; | |
53 | }); | |
54 | } | |
55 | ||
56 | return; | |
57 | } | |
58 | ||
59 | void | |
f715d946 | 60 | process_AgentMonitor_DNS(void) |
942cecd7 | 61 | { |
afb19109 A |
62 | if (!haveNetworkExtensionFramework()) { |
63 | return; | |
64 | } | |
65 | ||
942cecd7 A |
66 | SC_log(LOG_DEBUG, "Triggering AgentMonitor for DNS"); |
67 | @autoreleasepool { | |
68 | AgentController *controller = [AgentController sharedController]; | |
69 | if (controller == nil) { | |
70 | SC_log(LOG_ERR, "AgentController could not be initialized"); | |
71 | return; | |
72 | } | |
73 | ||
74 | dispatch_sync(controller.controllerQueue, ^{ | |
75 | [[AgentController sharedController] processDNSChanges]; | |
76 | }); | |
77 | } | |
78 | ||
79 | return; | |
80 | } | |
81 | ||
82 | void | |
f715d946 | 83 | process_AgentMonitor_Proxy(void) |
942cecd7 | 84 | { |
afb19109 A |
85 | if (!haveNetworkExtensionFramework()) { |
86 | return; | |
87 | } | |
88 | ||
942cecd7 A |
89 | SC_log(LOG_DEBUG, "Triggering AgentMonitor for Proxy"); |
90 | @autoreleasepool { | |
91 | AgentController *controller = [AgentController sharedController]; | |
92 | if (controller == nil) { | |
93 | SC_log(LOG_ERR, "AgentController could not be initialized"); | |
94 | return; | |
95 | } | |
96 | ||
97 | dispatch_sync(controller.controllerQueue, ^{ | |
98 | [[AgentController sharedController] processProxyChanges]; | |
99 | }); | |
100 | } | |
101 | ||
102 | return; | |
103 | } | |
104 | ||
105 | const void * | |
106 | copy_proxy_information_for_agent_uuid(uuid_t uuid, uint64_t *length) | |
107 | { | |
108 | __block const void *buffer = NULL; | |
afb19109 A |
109 | |
110 | if (!haveNetworkExtensionFramework()) { | |
111 | return NULL; | |
112 | } | |
113 | ||
942cecd7 A |
114 | @autoreleasepool { |
115 | AgentController *controller = [AgentController sharedController]; | |
116 | if (controller == nil) { | |
117 | SC_log(LOG_ERR, "AgentController could not be initialized"); | |
118 | return NULL; | |
119 | } | |
120 | ||
121 | dispatch_sync(controller.controllerQueue, ^{ | |
122 | buffer = [[AgentController sharedController] copyProxyAgentData:uuid | |
123 | length:length]; | |
124 | }); | |
125 | } | |
126 | ||
127 | return buffer; | |
128 | } | |
129 | ||
130 | const void * | |
131 | copy_dns_information_for_agent_uuid(uuid_t uuid, uint64_t *length) | |
132 | { | |
133 | __block const void *buffer = NULL; | |
afb19109 A |
134 | |
135 | if (!haveNetworkExtensionFramework()) { | |
136 | return NULL; | |
137 | } | |
138 | ||
942cecd7 A |
139 | @autoreleasepool { |
140 | AgentController *controller = [AgentController sharedController]; | |
141 | if (controller == nil) { | |
142 | SC_log(LOG_ERR, "AgentController could not be initialized"); | |
143 | return NULL; | |
144 | } | |
145 | ||
146 | dispatch_sync(controller.controllerQueue, ^{ | |
147 | buffer = [[AgentController sharedController] copyDNSAgentData:uuid | |
148 | length:length]; | |
149 | }); | |
150 | } | |
151 | ||
152 | return buffer; | |
153 | } |