1/*
2 * Copyright (c) 2000-2004, 2006, 2008-2010, 2012 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#ifndef _SYSTEMCONFIGURATION_H
25#define _SYSTEMCONFIGURATION_H
26
27#include <Availability.h>
28#include <sys/cdefs.h>
29#include <CoreFoundation/CoreFoundation.h>
30
31
32/*!
33	@header SystemConfiguration
34	@discussion The System Configuration framework provides access to the
35		data used to configure a running system.  The APIs provided
36		by this framework communicate with the configd daemon.
37
38		The configd daemon manages a dynamic store reflecting the
39		desired configuration settings as well as the current state
40		of the system.  The daemon provides a notification mechanism
41		for processes that need to be aware of changes made to the
42		data.  Lastly, the daemon loads a number of bundles (or
43		plug-ins) that monitor low-level kernel events and, through
44		a set of policy modules, keep the state data up to date.
45 */
46
47/*!
48	@enum Error codes
49	@discussion Returned error codes.
50	@constant kSCStatusOK			Success
51	@constant kSCStatusFailed		Non-specific Failure
52	@constant kSCStatusInvalidArgument	Invalid argument
53	@constant kSCStatusAccessError		Permission denied
54	@constant kSCStatusNoKey		No such key
55	@constant kSCStatusKeyExists		Data associated with key already defined
56	@constant kSCStatusLocked		Lock already held
57	@constant kSCStatusNeedLock		Lock required for this operation
58	@constant kSCStatusNoStoreSession	Configuration daemon session not active
59	@constant kSCStatusNoStoreServer	Configuration daemon not (or no longer) available
60	@constant kSCStatusNotifierActive	Notifier is currently active
61	@constant kSCStatusNoPrefsSession	Preferences session not active
62	@constant kSCStatusPrefsBusy		Preferences update currently in progress
63	@constant kSCStatusNoConfigFile		Configuration file not found
64	@constant kSCStatusNoLink		No such link
65	@constant kSCStatusStale		Write attempted on stale version of object
66	@constant kSCStatusMaxLink		Maximum link count exceeded
67	@constant kSCStatusReachabilityUnknown
68		A determination could not be made regarding the reachability
69		of the specified nodename or address.
70	@constant kSCStatusConnectionNoService	Network service for connection not available
71*/
72enum {
73	/*
74	 * Generic error codes
75	 */
76	kSCStatusOK				= 0,	/* Success */
77	kSCStatusFailed				= 1001,	/* Non-specific failure */
78	kSCStatusInvalidArgument		= 1002,	/* Invalid argument */
79	kSCStatusAccessError			= 1003,	/* Permission denied
80							   - must be root to obtain lock
81							   - could not create access/create preferences
82							 */
83	kSCStatusNoKey				= 1004,	/* No such key */
84	kSCStatusKeyExists			= 1005,	/* Key already defined */
85	kSCStatusLocked				= 1006,	/* Lock already held */
86	kSCStatusNeedLock			= 1007,	/* Lock required for this operation */
87	/*
88	 * SCDynamicStore error codes
89	 */
90	kSCStatusNoStoreSession			= 2001,	/* Configuration daemon session not active */
91	kSCStatusNoStoreServer			= 2002,	/* Configuration daemon not (no longer) available */
92	kSCStatusNotifierActive			= 2003,	/* Notifier is currently active */
93	/*
94	 * SCPreferences error codes
95	 */
96	kSCStatusNoPrefsSession			= 3001,	/* Preference session not active */
97	kSCStatusPrefsBusy			= 3002,	/* Preferences update currently in progress */
98	kSCStatusNoConfigFile			= 3003,	/* Configuration file not found */
99	kSCStatusNoLink				= 3004,	/* No such link */
100	kSCStatusStale				= 3005,	/* Write attempted on stale version of object */
101	kSCStatusMaxLink			= 3006,	/* Maximum link count exceeded */
102	/*
103	 * SCNetwork error codes
104	 */
105	kSCStatusReachabilityUnknown		= 4001,	/* Network reachability cannot be determined */
106	/*
107	 * SCNetworkConnection error codes
108	 */
109	kSCStatusConnectionNoService		= 5001,	/* Network service for connection not available
110							   __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_2_0)
111							 */
112	kSCStatusConnectionIgnore               = 5002, /* Network connection information not available at this time
113							   __OSX_AVAILABLE_STARTING(__MAC_10_9,__IPHONE_6_0)
114							 */
115};
116
117
118/* SCDynamicStore APIs */
119#include <SystemConfiguration/SCDynamicStore.h>
120#include <SystemConfiguration/SCDynamicStoreKey.h>
121#include <SystemConfiguration/SCDynamicStoreCopySpecific.h>
122
123/* SCPreferences APIs */
124#include <SystemConfiguration/SCPreferences.h>
125#include <SystemConfiguration/SCPreferencesPath.h>
126#include <SystemConfiguration/SCPreferencesSetSpecific.h>
127
128/* Schema Definitions (for SCDynamicStore and SCPreferences) */
129#include <SystemConfiguration/SCSchemaDefinitions.h>
130
131/* SCNetworkConfiguration APIs */
132#include <SystemConfiguration/SCNetworkConfiguration.h>
133
134/* SCNetworkReachability and SCNetworkConnection APIs */
135#include <SystemConfiguration/SCNetwork.h>
136#include <SystemConfiguration/SCNetworkReachability.h>
137#include <SystemConfiguration/SCNetworkConnection.h>
138
139/*!
140	@const kCFErrorDomainSystemConfiguration
141	@discussion CFError domain associated with errors reported by
142		the SystemConfiguration.framework.
143 */
144extern const CFStringRef	kCFErrorDomainSystemConfiguration	__OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0);
145
146__BEGIN_DECLS
147
148/*!
149	@function SCCopyLastError
150	@discussion Returns the most recent status or error code generated
151		as the result of calling a System Configuration framework API.
152	@result Returns the last error encountered.
153 */
154CFErrorRef	SCCopyLastError		(void)				__OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0);
155
156/*!
157	@function SCError
158	@discussion Returns the most recent status or error code generated
159		as the result of calling a System Configuration framework API.
160	@result Returns the last error encountered.
161 */
162int		SCError			(void)				__OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0);
163
164/*!
165	@function SCErrorString
166	@discussion Returns a pointer to the message string
167		associated with the specified status or error.
168	@param status The SCDynamicStoreStatus to be returned.
169	@result Returns a pointer to the error message string.
170 */
171const char *	SCErrorString		(int	status)			__OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0);
172
173__END_DECLS
174
175#endif /* _SYSTEMCONFIGURATION_H */
176