]>
git.saurik.com Git - apple/mdnsresponder.git/blob - mDNSMacOSX/CUPolicy.c
1 /* -*- Mode: C; tab-width: 4 -*-
3 * Copyright (c) 2013 Apple Computer, Inc. All rights reserved.
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
18 #include "mDNSMacOSX.h"
19 #include <network/config.h>
23 mDNSexport
void CUPInit(mDNS
*const m
)
26 m
->p
->handle
= cellular_usage_policy_create_client();
29 LogMsg("CUPInit: cellular_usage_policy_create_client failed");
33 mDNSexport mDNSBool
mDNSPlatformAllowPID(mDNS
*const m
, DNSQuestion
*q
)
35 // Currently the policy applies only for DNS requests sent over cellular interface
36 if (m
->p
->handle
&& q
->qDNSServer
&& q
->qDNSServer
->cellIntf
)
41 allowed
= (mDNSBool
) cellular_usage_policy_is_data_allowed_for_pid(m
->p
->handle
, q
->pid
);
44 xpc_object_t pidx
= xpc_uint64_create(q
->pid
);
47 network_config_cellular_blocked_notify(pidx
, NULL
, NULL
);
48 LogInfo("mDNSPlaformAllowPID: Notified PID(%d) for %##s (%s)", q
->pid
, q
->qname
.c
, DNSTypeName(q
->qtype
));
55 allowed
= (mDNSBool
) cellular_usage_policy_is_data_allowed_for_uuid(m
->p
->handle
, q
->uuid
);
58 xpc_object_t uuidx
= xpc_uuid_create(q
->uuid
);
61 network_config_cellular_blocked_notify(NULL
, uuidx
, NULL
);
62 LogInfo("mDNSPlaformAllowPID: Notified UUID for %##s (%s)", q
->qname
.c
, DNSTypeName(q
->qtype
));
75 #else // TARGET_OS_IPHONE
77 mDNSexport
void CUPInit(mDNS
*const m
)
82 mDNSexport mDNSBool
mDNSPlatformAllowPID(mDNS
*const m
, DNSQuestion
*q
)
86 //LogMsg("mDNSPlatformAllowPID: %##s (%s)", q->qname.c, DNSTypeName(q->qtype));
90 #endif // TARGET_OS_IPHONE