2 * Copyright (c) 2000, 2001, 2003-2005, 2007-2011, 2013-2020 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@
24 #ifndef _SCPREFERENCESINTERNAL_H
25 #define _SCPREFERENCESINTERNAL_H
27 #include <dispatch/dispatch.h>
28 #include <sys/types.h>
32 #include <os/state_private.h>
33 #include <CoreFoundation/CoreFoundation.h>
34 #include <CoreFoundation/CFRuntime.h>
37 #define SC_LOG_HANDLE __log_SCPreferences
38 #endif // SC_LOG_HANDLE
39 #include <SystemConfiguration/SystemConfiguration.h>
40 #include <SystemConfiguration/SCValidation.h>
41 #include <SystemConfiguration/SCPrivate.h>
43 #include <SystemConfiguration/SCPreferences.h>
44 #include <SystemConfiguration/SCDynamicStore.h>
47 #define PREFS_DEFAULT_DIR_PATH_RELATIVE "Library/Preferences/SystemConfiguration"
48 #define PREFS_DEFAULT_DIR_RELATIVE CFSTR(PREFS_DEFAULT_DIR_PATH_RELATIVE "/")
50 #define PREFS_DEFAULT_DIR_PATH "/" PREFS_DEFAULT_DIR_PATH_RELATIVE
51 #define PREFS_DEFAULT_DIR CFSTR(PREFS_DEFAULT_DIR_PATH)
53 #define PREFS_DEFAULT_CONFIG_PLIST "preferences.plist"
54 #define PREFS_DEFAULT_CONFIG CFSTR(PREFS_DEFAULT_CONFIG_PLIST)
56 #define PREFS_DEFAULT_DIR_OLD CFSTR("/var/db/SystemConfiguration")
57 #define PREFS_DEFAULT_CONFIG_OLD CFSTR("preferences.xml")
59 #define PREFS_DEFAULT_USER_DIR CFSTR("Library/Preferences")
61 #define INTERFACES_DEFAULT_CONFIG_PLIST "NetworkInterfaces.plist"
62 #define INTERFACES_DEFAULT_CONFIG CFSTR(INTERFACES_DEFAULT_CONFIG_PLIST)
63 #define INTERFACES CFSTR("Interfaces")
66 /* Define the per-preference-handle structure */
69 /* base CFType information */
82 CFDictionaryRef options
;
84 /* configuration file */
88 /* preferences lock, lock file */
92 struct timeval lockTime
;
94 /* configuration file signature */
98 SCDynamicStoreRef session
;
99 SCDynamicStoreRef sessionNoO_EXLOCK
;
102 /* configd session keys */
103 CFStringRef sessionKeyLock
;
104 CFStringRef sessionKeyCommit
;
105 CFStringRef sessionKeyApply
;
107 /* run loop source, callout, context, rl scheduling info */
109 CFRunLoopSourceRef rls
;
110 SCPreferencesCallBack rlsFunction
;
111 SCPreferencesContext rlsContext
;
112 CFMutableArrayRef rlList
;
113 dispatch_queue_t dispatchQueue
; // SCPreferencesSetDispatchQueue
116 CFMutableDictionaryRef prefs
;
118 /* companion preferences, manipulate under lock */
119 SCPreferencesRef parent
; // [strong] reference from companion to parent
120 CFMutableDictionaryRef companions
; // [weak] reference from parent to companions
126 uint32_t nc_flags
; // SCNetworkConfiguration flags
128 /* authorization, helper */
129 CFDataRef authorizationData
;
130 mach_port_t helper_port
;
132 } SCPreferencesPrivate
, *SCPreferencesPrivateRef
;
135 /* Define signature data */
137 int64_t st_dev
; /* inode's device */
138 uint64_t st_ino
; /* inode's number */
139 uint64_t tv_sec
; /* time of last data modification */
141 off_t st_size
; /* file size, in bytes */
142 } SCPSignatureData
, *SCPSignatureDataRef
;
147 static __inline__ CFTypeRef
148 isA_SCPreferences(CFTypeRef obj
)
150 return (isA_CFType(obj
, SCPreferencesGetTypeID()));
154 __log_SCPreferences (void);
157 __SCPreferencesCreate_helper (SCPreferencesRef prefs
);
160 __SCPreferencesAccess (SCPreferencesRef prefs
);
163 __SCPreferencesAddSessionKeys (SCPreferencesRef prefs
);
166 __SCPreferencesAddSession (SCPreferencesRef prefs
);
169 __SCPreferencesRemoveSession (SCPreferencesRef prefs
);
172 __SCPreferencesUpdateLockedState (SCPreferencesRef prefs
,
177 __SCPSignatureFromStatbuf (const struct stat
*statBuf
);
180 __SCPreferencesPath (CFAllocatorRef allocator
,
182 Boolean useNewPrefs
);
185 __SCPreferencesPrefsSize (SCPreferencesRef prefs
);
189 _SCPNotificationKey (CFAllocatorRef allocator
,
194 __SCPreferencesGetNetworkConfigurationFlags
195 (SCPreferencesRef prefs
);
198 __SCPreferencesSetNetworkConfigurationFlags
199 (SCPreferencesRef prefs
,
203 __SCPreferencesUsingDefaultPrefs (SCPreferencesRef prefs
);
206 __SCPreferencesCreateNIPrefsFromPrefs (SCPreferencesRef prefs
);
210 #endif /* _SCPREFERENCESINTERNAL_H */