]> git.saurik.com Git - apple/configd.git/blob - Plugins/IPMonitor/agent-monitor.m
configd-963.30.1.tar.gz
[apple/configd.git] / Plugins / IPMonitor / agent-monitor.m
1 /*
2 * Copyright (c) 2015, 2016 Apple Inc. All rights reserved.
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
26 void
27 process_AgentMonitor()
28 {
29 SC_log(LOG_DEBUG, "Triggering AgentMonitor");
30 @autoreleasepool {
31 AgentController *controller = [AgentController sharedController];
32 if (controller == nil) {
33 SC_log(LOG_ERR, "AgentController could not be initialized");
34 return;
35 }
36
37 dispatch_sync(controller.controllerQueue, ^{
38 [[AgentController sharedController] processDNSChanges];
39 [[AgentController sharedController] processProxyChanges];
40 });
41 }
42
43 return;
44 }
45
46 void
47 process_AgentMonitor_DNS()
48 {
49 SC_log(LOG_DEBUG, "Triggering AgentMonitor for DNS");
50 @autoreleasepool {
51 AgentController *controller = [AgentController sharedController];
52 if (controller == nil) {
53 SC_log(LOG_ERR, "AgentController could not be initialized");
54 return;
55 }
56
57 dispatch_sync(controller.controllerQueue, ^{
58 [[AgentController sharedController] processDNSChanges];
59 });
60 }
61
62 return;
63 }
64
65 void
66 process_AgentMonitor_Proxy()
67 {
68 SC_log(LOG_DEBUG, "Triggering AgentMonitor for Proxy");
69 @autoreleasepool {
70 AgentController *controller = [AgentController sharedController];
71 if (controller == nil) {
72 SC_log(LOG_ERR, "AgentController could not be initialized");
73 return;
74 }
75
76 dispatch_sync(controller.controllerQueue, ^{
77 [[AgentController sharedController] processProxyChanges];
78 });
79 }
80
81 return;
82 }
83
84 const void *
85 copy_proxy_information_for_agent_uuid(uuid_t uuid, uint64_t *length)
86 {
87 __block const void *buffer = NULL;
88 @autoreleasepool {
89 AgentController *controller = [AgentController sharedController];
90 if (controller == nil) {
91 SC_log(LOG_ERR, "AgentController could not be initialized");
92 return NULL;
93 }
94
95 dispatch_sync(controller.controllerQueue, ^{
96 buffer = [[AgentController sharedController] copyProxyAgentData:uuid
97 length:length];
98 });
99 }
100
101 return buffer;
102 }
103
104 const void *
105 copy_dns_information_for_agent_uuid(uuid_t uuid, uint64_t *length)
106 {
107 __block const void *buffer = NULL;
108 @autoreleasepool {
109 AgentController *controller = [AgentController sharedController];
110 if (controller == nil) {
111 SC_log(LOG_ERR, "AgentController could not be initialized");
112 return NULL;
113 }
114
115 dispatch_sync(controller.controllerQueue, ^{
116 buffer = [[AgentController sharedController] copyDNSAgentData:uuid
117 length:length];
118 });
119 }
120
121 return buffer;
122 }