2 * Copyright (c) 2004-2008 Apple Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
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
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.
21 * @APPLE_LICENSE_HEADER_END@
25 * Modification History
27 * March 9, 2004 Allan Nathanson <ajn@apple.com>
35 #include <sys/types.h>
36 #include <servers/bootstrap.h>
37 #include <mach/mach.h>
38 #include <mach/mach_error.h>
39 #include <bsm/libbsm.h>
41 #include <CoreFoundation/CoreFoundation.h>
42 #include <SystemConfiguration/SCPrivate.h>
44 #include "dnsinfo_server.h"
45 #include "dnsinfo_private.h"
47 static CFDataRef shared_dns_info
= NULL
;
51 _shared_dns_infoGet(mach_port_t server
, dnsDataOut_t
*dataRef
, mach_msg_type_number_t
*dataLen
)
56 if (shared_dns_info
!= NULL
) {
57 if (!_SCSerializeData(shared_dns_info
, (void **)dataRef
, (CFIndex
*)dataLen
)) {
68 _shared_dns_infoSet(mach_port_t server
,
70 mach_msg_type_number_t dataLen
,
71 audit_token_t audit_token
)
74 CFDataRef new_dns_info
= NULL
;
75 const char *notify_key
;
77 if ((dataRef
!= NULL
) && (dataLen
> 0)) {
78 if (!_SCUnserializeData(&new_dns_info
, (void *)dataRef
, dataLen
)) {
83 audit_token_to_au32(audit_token
,
96 if ((shared_dns_info
!= NULL
) &&
97 (new_dns_info
!= NULL
) &&
98 CFEqual(shared_dns_info
, new_dns_info
)) {
99 CFRelease(new_dns_info
);
103 if (shared_dns_info
!= NULL
) CFRelease(shared_dns_info
);
104 shared_dns_info
= new_dns_info
;
106 notify_key
= _dns_configuration_notify_key();
107 if (notify_key
!= NULL
) {
110 status
= notify_post(notify_key
);
111 if (status
!= NOTIFY_STATUS_OK
) {
112 SCLog(TRUE
, LOG_ERR
, CFSTR("notify_post() failed: %d"), status
);
113 // notification posting failures are non-fatal
121 if (new_dns_info
!= NULL
) CFRelease(new_dns_info
);