2 * Copyright (c) 2005-2007 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 _SCNETWORKCONFIGURATIONPRIVATE_H
25 #define _SCNETWORKCONFIGURATIONPRIVATE_H
27 #include <AvailabilityMacros.h>
28 #include <sys/cdefs.h>
29 #include <CoreFoundation/CoreFoundation.h>
30 #include <SystemConfiguration/SystemConfiguration.h>
31 #include <SystemConfiguration/SCValidation.h>
32 #include <IOKit/IOKitLib.h>
34 #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1050
37 @header SCNetworkConfigurationPrivate
44 #pragma mark SCNetworkInterface configuration (SPI)
48 @group Interface configuration
51 static __inline__ CFTypeRef
52 isA_SCNetworkInterface(CFTypeRef obj
)
54 return (isA_CFType(obj
, SCNetworkInterfaceGetTypeID()));
57 static __inline__ CFTypeRef
58 isA_SCBondInterface(CFTypeRef obj
)
60 CFStringRef interfaceType
;
62 if (!isA_SCNetworkInterface(obj
)) {
63 // if not an SCNetworkInterface
67 interfaceType
= SCNetworkInterfaceGetInterfaceType((SCNetworkInterfaceRef
)obj
);
68 if (!CFEqual(interfaceType
, kSCNetworkInterfaceTypeBond
)) {
76 static __inline__ CFTypeRef
77 isA_SCVLANInterface(CFTypeRef obj
)
79 CFStringRef interfaceType
;
81 if (!isA_SCNetworkInterface(obj
)) {
82 // if not an SCNetworkInterface
86 interfaceType
= SCNetworkInterfaceGetInterfaceType((SCNetworkInterfaceRef
)obj
);
87 if (!CFEqual(interfaceType
, kSCNetworkInterfaceTypeVLAN
)) {
96 @function _SCNetworkInterfaceCompare
97 @discussion Compares two SCNetworkInterface objects.
98 @param val1 The SCNetworkInterface object.
99 @param val2 The SCNetworkInterface object.
100 @param context Not used.
101 @result A comparison result.
104 _SCNetworkInterfaceCompare (const void *val1
,
106 void *context
) AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER
;
108 #define kIncludeNoVirtualInterfaces 0x0
109 #define kIncludeVLANInterfaces 0x1
110 #define kIncludeBondInterfaces 0x2
111 #define kIncludeAllVirtualInterfaces 0xffffffff
114 @function _SCNetworkInterfaceCreateWithBSDName
115 @discussion Create a new network interface associated with the provided
116 BSD interface name. This API supports Ethhernet, FireWire, and
117 IEEE 802.11 interfaces.
118 @param bsdName The BSD interface name.
119 @param flags Indicates whether virtual (Bond, VLAN)
120 network interfaces should be included.
121 @result A reference to the new SCNetworkInterface.
122 You must release the returned value.
124 SCNetworkInterfaceRef
125 _SCNetworkInterfaceCreateWithBSDName (CFAllocatorRef allocator
,
127 UInt32 flags
) AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER
;
130 @function _SCNetworkInterfaceCreateWithEntity
131 @discussion Create a new network interface associated with the provided
132 SCDynamicStore service entity dictionary.
133 @param interface_entity The entity dictionary.
134 @param service The network service.
135 @result A reference to the new SCNetworkInterface.
136 You must release the returned value.
138 SCNetworkInterfaceRef
139 _SCNetworkInterfaceCreateWithEntity (CFAllocatorRef allocator
,
140 CFDictionaryRef interface_entity
,
141 SCNetworkServiceRef service
) AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER
;
144 @function _SCNetworkInterfaceCreateWithIONetworkInterfaceObject
145 @discussion Create a new network interface associated with the provided
146 IORegistry "IONetworkInterface" object.
147 @param if_obj The IONetworkInterface object.
148 @result A reference to the new SCNetworkInterface.
149 You must release the returned value.
151 SCNetworkInterfaceRef
152 _SCNetworkInterfaceCreateWithIONetworkInterfaceObject (io_object_t if_obj
) AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER
;
155 @function _SCNetworkInterfaceGetHardwareAddress
156 @discussion Returns a link layer address for the interface.
157 @param interface The network interface.
158 @result The hardware (MAC) address for the interface.
159 NULL if no hardware address is available.
162 _SCNetworkInterfaceGetHardwareAddress (SCNetworkInterfaceRef interface
) AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER
;
165 @function _SCNetworkInterfaceGetIOInterfaceType
166 @discussion Returns the IOInterfaceType for the interface.
167 @param interface The network interface.
168 @result The IOInterfaceType associated with the interface
171 _SCNetworkInterfaceGetIOInterfaceType (SCNetworkInterfaceRef interface
) AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER
;
174 @function _SCNetworkInterfaceGetIOInterfaceUnit
175 @discussion Returns the IOInterfaceUnit for the interface.
176 @param interface The network interface.
177 @result The IOInterfaceUnit associated with the interface;
178 NULL if no IOLocation is available.
181 _SCNetworkInterfaceGetIOInterfaceUnit (SCNetworkInterfaceRef interface
) AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER
;
184 @function _SCNetworkInterfaceGetIOPath
185 @discussion Returns the IOPath for the interface.
186 @param interface The network interface.
187 @result The IOPath associated with the interface;
188 NULL if no IOPath is available.
191 _SCNetworkInterfaceGetIOPath (SCNetworkInterfaceRef interface
) AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER
;
194 @function _SCNetworkInterfaceIsBuiltin
195 @discussion Identifies if a network interface is "built-in".
196 @param interface The network interface.
197 @result TRUE if the interface is "built-in".
200 _SCNetworkInterfaceIsBuiltin (SCNetworkInterfaceRef interface
) AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER
;
203 @function _SCNetworkInterfaceIsModemV92
204 @discussion Identifies if a modem network interface supports
206 @param interface The network interface.
207 @result TRUE if the interface is "v.92" modem.
210 _SCNetworkInterfaceIsModemV92 (SCNetworkInterfaceRef interface
) AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER
;
213 @function _SCNetworkInterfaceForceConfigurationRefresh
214 @discussion Forces a configuration refresh of the
216 @param ifName Network interface name.
217 @result TRUE if the refresh was successfully posted.
220 _SCNetworkInterfaceForceConfigurationRefresh (CFStringRef ifName
) AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER
;
223 @function _SCBondInterfaceCopyActive
224 @discussion Returns all Ethernet Bond interfaces on the system.
225 @result The list of SCBondInterface interfaces on the system.
226 You must release the returned value.
229 _SCBondInterfaceCopyActive (void) AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER
;
232 @function _SCBondInterfaceUpdateConfiguration
233 @discussion Updates the bond interface configuration.
234 @param prefs The "preferences" session.
235 @result TRUE if the bond interface configuration was updated.; FALSE if the
236 an error was encountered.
239 _SCBondInterfaceUpdateConfiguration (SCPreferencesRef prefs
) AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER
;
242 @function SCBondInterfaceSetMode
243 @discussion Set the mode on the bond interface.
244 @param bond The bond interface on which to adjust the mode.
245 @param mode The mode value (0=IF_BOND_MODE_LACP,1=IF_BOND_MODE_STATIC)
246 @result TRUE if operation succeeded.
249 SCBondInterfaceSetMode (SCBondInterfaceRef bond
,
250 CFNumberRef mode
) AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER
;
253 @function SCBondInterfaceSetMode
254 @discussion Return the mode for the given bond interface.
255 @param bond The bond interface to get the mode from.
256 @result A CFNumberRef containing the mode (IF_BOND_MODE_{LACP,STATIC}).
259 SCBondInterfaceGetMode (SCBondInterfaceRef bond
) AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER
;
262 @function _SCVLANInterfaceCopyActive
263 @discussion Returns all VLAN interfaces on the system.
264 @result The list of SCVLANInterface interfaces on the system.
265 You must release the returned value.
268 _SCVLANInterfaceCopyActive (void) AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER
;
271 @function _SCVLANInterfaceUpdateConfiguration
272 @discussion Updates the VLAN interface configuration.
273 @param prefs The "preferences" session.
274 @result TRUE if the VLAN interface configuration was updated.; FALSE if the
275 an error was encountered.
278 _SCVLANInterfaceUpdateConfiguration (SCPreferencesRef prefs
) AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER
;
282 #pragma mark SCNetworkInterface Password SPIs
286 kSCNetworkInterfacePasswordTypePPP
= 1,
287 kSCNetworkInterfacePasswordTypeIPSecSharedSecret
,
288 kSCNetworkInterfacePasswordTypeEAPOL
,
290 typedef uint32_t SCNetworkInterfacePasswordType
;
293 SCNetworkInterfaceCheckPassword (SCNetworkInterfaceRef interface
,
294 SCNetworkInterfacePasswordType passwordType
) AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER
;
297 SCNetworkInterfaceCopyPassword (SCNetworkInterfaceRef interface
,
298 SCNetworkInterfacePasswordType passwordType
) AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER
;
301 SCNetworkInterfaceRemovePassword (SCNetworkInterfaceRef interface
,
302 SCNetworkInterfacePasswordType passwordType
) AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER
;
305 SCNetworkInterfaceSetPassword (SCNetworkInterfaceRef interface
,
306 SCNetworkInterfacePasswordType passwordType
,
308 CFDictionaryRef options
) AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER
;
312 #pragma mark SCNetworkProtocol configuration (SPI)
316 @group Protocol configuration
320 static __inline__ CFTypeRef
321 isA_SCNetworkProtocol(CFTypeRef obj
)
323 return (isA_CFType(obj
, SCNetworkProtocolGetTypeID()));
328 #pragma mark SCNetworkService configuration (SPI)
332 @group Service configuration
336 static __inline__ CFTypeRef
337 isA_SCNetworkService(CFTypeRef obj
)
339 return (isA_CFType(obj
, SCNetworkServiceGetTypeID()));
344 #pragma mark SCNetworkSet configuration (SPI)
348 @group Set configuration
352 static __inline__ CFTypeRef
353 isA_SCNetworkSet(CFTypeRef obj
)
355 return (isA_CFType(obj
, SCNetworkSetGetTypeID()));
360 @function SCNetworkSetEstablishDefaultConfiguration
361 @discussion Updates a network set by adding services for
362 any network interface that is not currently
364 If the provided set contains one (or more) services, new
365 services will only be added for those interfaces that are
366 not represented in *any* set.
367 Otherwise, new services will be added for those interfaces
368 that are not represented in the provided set.
369 The new services are established with "default" configuration
371 @param set The network set.
372 @result TRUE if the configuration was updated; FALSE if no
373 changes were required or if an error was encountered.
376 SCNetworkSetEstablishDefaultConfiguration (SCNetworkSetRef set
);
379 @function SCNetworkSetEstablishDefaultInterfaceConfiguration
380 @discussion Updates a network set by adding services for
381 the specified network interface if is not currently
383 If the provided set contains one (or more) services, new
384 services will only be added for interfaces that are not
385 represented in *any* set.
386 Otherwise, new services will be added for interfaces that
387 are not represented in the provided set.
388 The new services are established with "default" configuration
390 @param set The network set.
391 @param interface The network interface.
392 @result TRUE if the configuration was updated; FALSE if no
393 changes were required or if an error was encountered.
396 SCNetworkSetEstablishDefaultInterfaceConfiguration (SCNetworkSetRef set
,
397 SCNetworkInterfaceRef interface
);
401 #endif /* MAC_OS_X_VERSION_MAX_ALLOWED >= 1050 */
403 #endif /* _SCNETWORKCONFIGURATIONPRIVATE_H */