2 * Copyright (c) 2005-2009 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 <Availability.h>
28 #include <TargetConditionals.h>
29 #include <sys/cdefs.h>
30 #include <CoreFoundation/CoreFoundation.h>
31 #include <SystemConfiguration/SystemConfiguration.h>
32 #include <SystemConfiguration/SCValidation.h>
33 #include <IOKit/IOKitLib.h>
36 @header SCNetworkConfigurationPrivate
43 #pragma mark SCNetworkInterface configuration (SPI)
47 @group Interface configuration
50 static __inline__ CFTypeRef
51 isA_SCNetworkInterface(CFTypeRef obj
)
53 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
)) {
94 #endif // !TARGET_OS_IPHONE
97 @function _SCNetworkInterfaceCompare
98 @discussion Compares two SCNetworkInterface objects.
99 @param val1 The SCNetworkInterface object.
100 @param val2 The SCNetworkInterface object.
101 @param context Not used.
102 @result A comparison result.
105 _SCNetworkInterfaceCompare (const void *val1
,
107 void *context
) __OSX_AVAILABLE_STARTING(__MAC_10_5
,__IPHONE_2_0
);
110 @function _SCNetworkInterfaceCopySlashDevPath
111 @discussion Returns the /dev pathname for the interface.
112 @param interface The network interface.
113 @result The /dev pathname associated with the interface (e.g. "/dev/modem");
114 NULL if no path is available.
117 _SCNetworkInterfaceCopySlashDevPath (SCNetworkInterfaceRef interface
) __OSX_AVAILABLE_STARTING(__MAC_10_6
,__IPHONE_3_0
);
119 #define kIncludeNoVirtualInterfaces 0x0
120 #define kIncludeVLANInterfaces 0x1
121 #define kIncludeBondInterfaces 0x2
122 #define kIncludeAllVirtualInterfaces 0xffffffff
125 @function _SCNetworkInterfaceCreateWithBSDName
126 @discussion Create a new network interface associated with the provided
127 BSD interface name. This API supports Ethhernet, FireWire, and
128 IEEE 802.11 interfaces.
129 @param bsdName The BSD interface name.
130 @param flags Indicates whether virtual (Bond, VLAN)
131 network interfaces should be included.
132 @result A reference to the new SCNetworkInterface.
133 You must release the returned value.
135 SCNetworkInterfaceRef
136 _SCNetworkInterfaceCreateWithBSDName (CFAllocatorRef allocator
,
138 UInt32 flags
) __OSX_AVAILABLE_STARTING(__MAC_10_5
,__IPHONE_2_0
);
141 @function _SCNetworkInterfaceCreateWithEntity
142 @discussion Create a new network interface associated with the provided
143 SCDynamicStore service entity dictionary.
144 @param interface_entity The entity dictionary.
145 @param service The network service.
146 @result A reference to the new SCNetworkInterface.
147 You must release the returned value.
149 SCNetworkInterfaceRef
150 _SCNetworkInterfaceCreateWithEntity (CFAllocatorRef allocator
,
151 CFDictionaryRef interface_entity
,
152 SCNetworkServiceRef service
) __OSX_AVAILABLE_STARTING(__MAC_10_5
,__IPHONE_2_0
);
155 @function _SCNetworkInterfaceCreateWithIONetworkInterfaceObject
156 @discussion Create a new network interface associated with the provided
157 IORegistry "IONetworkInterface" object.
158 @param if_obj The IONetworkInterface object.
159 @result A reference to the new SCNetworkInterface.
160 You must release the returned value.
162 SCNetworkInterfaceRef
163 _SCNetworkInterfaceCreateWithIONetworkInterfaceObject (io_object_t if_obj
) __OSX_AVAILABLE_STARTING(__MAC_10_5
,__IPHONE_2_0
);
165 #define kSCNetworkInterfaceConfigurationActionKey CFSTR("New Interface Detected Action")
166 #define kSCNetworkInterfaceConfigurationActionValueNone CFSTR("None")
167 #define kSCNetworkInterfaceConfigurationActionValuePrompt CFSTR("Prompt")
168 #define kSCNetworkInterfaceConfigurationActionValueConfigure CFSTR("Configure")
171 @function _SCNetworkInterfaceCopyInterfaceInfo
172 @discussion Returns interface details
173 @param interface The network interface.
174 @result A dictionary with details about the network interface.
177 _SCNetworkInterfaceCopyInterfaceInfo (SCNetworkInterfaceRef interface
) __OSX_AVAILABLE_STARTING(__MAC_10_6
,__IPHONE_3_0
);
180 @function _SCNetworkInterfaceGetConfigurationAction
181 @discussion Returns a user-notification / auto-configuration action for the interface.
182 @param interface The network interface.
183 @result The user-notification / auto-configuration action;
184 NULL if the default action should be used.
187 _SCNetworkInterfaceGetConfigurationAction (SCNetworkInterfaceRef interface
) __OSX_AVAILABLE_STARTING(__MAC_10_6
,__IPHONE_2_0
);
190 @function _SCNetworkInterfaceGetHardwareAddress
191 @discussion Returns a link layer address for the interface.
192 @param interface The network interface.
193 @result The hardware (MAC) address for the interface.
194 NULL if no hardware address is available.
197 _SCNetworkInterfaceGetHardwareAddress (SCNetworkInterfaceRef interface
) __OSX_AVAILABLE_STARTING(__MAC_10_5
,__IPHONE_2_0
);
200 @function _SCNetworkInterfaceGetIOInterfaceType
201 @discussion Returns the IOInterfaceType for the interface.
202 @param interface The network interface.
203 @result The IOInterfaceType associated with the interface
206 _SCNetworkInterfaceGetIOInterfaceType (SCNetworkInterfaceRef interface
) __OSX_AVAILABLE_STARTING(__MAC_10_5
,__IPHONE_2_0
);
209 @function _SCNetworkInterfaceGetIOInterfaceUnit
210 @discussion Returns the IOInterfaceUnit for the interface.
211 @param interface The network interface.
212 @result The IOInterfaceUnit associated with the interface;
213 NULL if no IOLocation is available.
216 _SCNetworkInterfaceGetIOInterfaceUnit (SCNetworkInterfaceRef interface
) __OSX_AVAILABLE_STARTING(__MAC_10_5
,__IPHONE_2_0
);
219 @function _SCNetworkInterfaceGetIOPath
220 @discussion Returns the IOPath for the interface.
221 @param interface The network interface.
222 @result The IOPath associated with the interface;
223 NULL if no IOPath is available.
226 _SCNetworkInterfaceGetIOPath (SCNetworkInterfaceRef interface
) __OSX_AVAILABLE_STARTING(__MAC_10_5
,__IPHONE_2_0
);
229 @function _SCNetworkInterfaceIsBluetoothPAN
230 @discussion Identifies if a network interface is a Bluetooth PAN device.
231 @param interface The network interface.
232 @result TRUE if the interface is a Bluetooth PAN device.
235 _SCNetworkInterfaceIsBluetoothPAN (SCNetworkInterfaceRef interface
) __OSX_AVAILABLE_STARTING(__MAC_10_6
,__IPHONE_3_0
);
238 @function _SCNetworkInterfaceIsBuiltin
239 @discussion Identifies if a network interface is "built-in".
240 @param interface The network interface.
241 @result TRUE if the interface is "built-in".
244 _SCNetworkInterfaceIsBuiltin (SCNetworkInterfaceRef interface
) __OSX_AVAILABLE_STARTING(__MAC_10_5
,__IPHONE_2_0
);
247 @function _SCNetworkInterfaceIsTethered
248 @discussion Identifies if a network interface is an Apple tethered device (e.g. an iPhone).
249 @param interface The network interface.
250 @result TRUE if the interface is a tethered device.
253 _SCNetworkInterfaceIsTethered (SCNetworkInterfaceRef interface
) __OSX_AVAILABLE_STARTING(__MAC_10_6
,__IPHONE_3_0
);
256 @function _SCNetworkInterfaceIsModemV92
257 @discussion Identifies if a modem network interface supports
259 @param interface The network interface.
260 @result TRUE if the interface is "v.92" modem.
263 _SCNetworkInterfaceIsModemV92 (SCNetworkInterfaceRef interface
) __OSX_AVAILABLE_STARTING(__MAC_10_5
,__IPHONE_2_0
);
266 @function _SCNetworkInterfaceForceConfigurationRefresh
267 @discussion Forces a configuration refresh of the
269 @param ifName Network interface name.
270 @result TRUE if the refresh was successfully posted.
273 _SCNetworkInterfaceForceConfigurationRefresh (CFStringRef ifName
) __OSX_AVAILABLE_STARTING(__MAC_10_5
,__IPHONE_2_0
);
276 @function _SCBondInterfaceCopyActive
277 @discussion Returns all Ethernet Bond interfaces on the system.
278 @result The list of SCBondInterface interfaces on the system.
279 You must release the returned value.
282 _SCBondInterfaceCopyActive (void) __OSX_AVAILABLE_STARTING(__MAC_10_5
,__IPHONE_NA
);
285 @function _SCBondInterfaceUpdateConfiguration
286 @discussion Updates the bond interface configuration.
287 @param prefs The "preferences" session.
288 @result TRUE if the bond interface configuration was updated.; FALSE if the
289 an error was encountered.
292 _SCBondInterfaceUpdateConfiguration (SCPreferencesRef prefs
) __OSX_AVAILABLE_STARTING(__MAC_10_5
,__IPHONE_NA
);
295 @function SCBondInterfaceSetMode
296 @discussion Set the mode on the bond interface.
297 @param bond The bond interface on which to adjust the mode.
298 @param mode The mode value (0=IF_BOND_MODE_LACP,1=IF_BOND_MODE_STATIC)
299 @result TRUE if operation succeeded.
302 SCBondInterfaceSetMode (SCBondInterfaceRef bond
,
303 CFNumberRef mode
) __OSX_AVAILABLE_STARTING(__MAC_10_5
,__IPHONE_NA
);
306 @function SCBondInterfaceSetMode
307 @discussion Return the mode for the given bond interface.
308 @param bond The bond interface to get the mode from.
309 @result A CFNumberRef containing the mode (IF_BOND_MODE_{LACP,STATIC}).
312 SCBondInterfaceGetMode (SCBondInterfaceRef bond
) __OSX_AVAILABLE_STARTING(__MAC_10_5
,__IPHONE_NA
);
315 @function _SCVLANInterfaceCopyActive
316 @discussion Returns all VLAN interfaces on the system.
317 @result The list of SCVLANInterface interfaces on the system.
318 You must release the returned value.
321 _SCVLANInterfaceCopyActive (void) __OSX_AVAILABLE_STARTING(__MAC_10_5
,__IPHONE_NA
);
324 @function _SCVLANInterfaceUpdateConfiguration
325 @discussion Updates the VLAN interface configuration.
326 @param prefs The "preferences" session.
327 @result TRUE if the VLAN interface configuration was updated.; FALSE if the
328 an error was encountered.
331 _SCVLANInterfaceUpdateConfiguration (SCPreferencesRef prefs
) __OSX_AVAILABLE_STARTING(__MAC_10_5
,__IPHONE_NA
);
335 #pragma mark SCNetworkInterface Password SPIs
339 kSCNetworkInterfacePasswordTypePPP
= 1,
340 kSCNetworkInterfacePasswordTypeIPSecSharedSecret
,
341 kSCNetworkInterfacePasswordTypeEAPOL
,
342 kSCNetworkInterfacePasswordTypeIPSecXAuth
,
344 typedef uint32_t SCNetworkInterfacePasswordType
;
347 SCNetworkInterfaceCheckPassword (SCNetworkInterfaceRef interface
,
348 SCNetworkInterfacePasswordType passwordType
) __OSX_AVAILABLE_STARTING(__MAC_10_5
,__IPHONE_2_0
);
351 SCNetworkInterfaceCopyPassword (SCNetworkInterfaceRef interface
,
352 SCNetworkInterfacePasswordType passwordType
) __OSX_AVAILABLE_STARTING(__MAC_10_5
,__IPHONE_2_0
);
355 SCNetworkInterfaceRemovePassword (SCNetworkInterfaceRef interface
,
356 SCNetworkInterfacePasswordType passwordType
) __OSX_AVAILABLE_STARTING(__MAC_10_5
,__IPHONE_2_0
);
359 SCNetworkInterfaceSetPassword (SCNetworkInterfaceRef interface
,
360 SCNetworkInterfacePasswordType passwordType
,
362 CFDictionaryRef options
) __OSX_AVAILABLE_STARTING(__MAC_10_5
,__IPHONE_2_0
);
366 #pragma mark SCNetworkProtocol configuration (SPI)
370 @group Protocol configuration
374 static __inline__ CFTypeRef
375 isA_SCNetworkProtocol(CFTypeRef obj
)
377 return (isA_CFType(obj
, SCNetworkProtocolGetTypeID()));
382 #pragma mark SCNetworkService configuration (SPI)
386 @group Service configuration
390 static __inline__ CFTypeRef
391 isA_SCNetworkService(CFTypeRef obj
)
393 return (isA_CFType(obj
, SCNetworkServiceGetTypeID()));
397 kSCNetworkServicePrimaryRankDefault
= 0,
398 kSCNetworkServicePrimaryRankFirst
= 1,
399 kSCNetworkServicePrimaryRankLast
= 2,
400 kSCNetworkServicePrimaryRankNever
= 3
402 typedef uint32_t SCNetworkServicePrimaryRank
;
405 @function _SCNetworkServiceCopyActive
406 @discussion Returns the network service with the specified identifier.
408 Note: The service returned by this SPI differs from the SCNetworkServiceCopy
409 API in that queries and operations interact with the "active" service
410 represented in the SCDynamicStore. Only a limited subset of the
411 SCNetworkService APIs are supported.
412 @param prefs The dynamic store session.
413 @param serviceID The unique identifier for the service.
414 @result A reference to the SCNetworkService represented in the SCDynamicStore;
415 NULL if the serviceID does not exist in the SCDynamicStore or if an
416 error was encountered.
417 You must release the returned value.
420 _SCNetworkServiceCopyActive (SCDynamicStoreRef store
,
421 CFStringRef serviceID
) __OSX_AVAILABLE_STARTING(__MAC_10_6
,__IPHONE_2_1
);
424 @function SCNetworkServiceGetPrimaryRank
425 @discussion Returns the primary service rank associated with a service.
426 @param service The network service.
427 @result The primary service rank associated with the specified application;
428 kSCNetworkServicePrimaryRankDefault if no rank is associated with the
429 application or an error was encountered.
431 SCNetworkServicePrimaryRank
432 SCNetworkServiceGetPrimaryRank (SCNetworkServiceRef service
) __OSX_AVAILABLE_STARTING(__MAC_10_6
,__IPHONE_2_0
);
435 @function SCNetworkServiceSetPrimaryRank
436 @discussion Updates the the primary service rank associated with a service.
437 @param service The network service.
438 @param newRank The new primary service rank; kSCNetworkServicePrimaryRankDefault
439 if the default service rank should be used.
440 @result TRUE if the rank was stored; FALSE if an error was encountered.
442 Notes : The kSCNetworkServicePrimaryRankFirst and kSCNetworkServicePrimaryRankLast
443 values can only valid as a transient setting.
446 SCNetworkServiceSetPrimaryRank (SCNetworkServiceRef service
,
447 SCNetworkServicePrimaryRank newRank
) __OSX_AVAILABLE_STARTING(__MAC_10_6
,__IPHONE_2_0
);
451 #pragma mark SCNetworkSet configuration (SPI)
455 @group Set configuration
459 static __inline__ CFTypeRef
460 isA_SCNetworkSet(CFTypeRef obj
)
462 return (isA_CFType(obj
, SCNetworkSetGetTypeID()));
467 @function SCNetworkSetEstablishDefaultConfiguration
468 @discussion Updates a network set by adding services for
469 any network interface that is not currently
471 If the provided set contains one (or more) services, new
472 services will only be added for those interfaces that are
473 not represented in *any* set.
474 Otherwise, new services will be added for those interfaces
475 that are not represented in the provided set.
476 The new services are established with "default" configuration
478 @param set The network set.
479 @result TRUE if the configuration was updated; FALSE if no
480 changes were required or if an error was encountered.
483 SCNetworkSetEstablishDefaultConfiguration (SCNetworkSetRef set
) __OSX_AVAILABLE_STARTING(__MAC_10_5
,__IPHONE_2_0
);
486 @function SCNetworkSetEstablishDefaultInterfaceConfiguration
487 @discussion Updates a network set by adding services for
488 the specified network interface if is not currently
490 If the provided set contains one (or more) services, new
491 services will only be added for interfaces that are not
492 represented in *any* set.
493 Otherwise, new services will be added for interfaces that
494 are not represented in the provided set.
495 The new services are established with "default" configuration
497 @param set The network set.
498 @param interface The network interface.
499 @result TRUE if the configuration was updated; FALSE if no
500 changes were required or if an error was encountered.
503 SCNetworkSetEstablishDefaultInterfaceConfiguration (SCNetworkSetRef set
,
504 SCNetworkInterfaceRef interface
) __OSX_AVAILABLE_STARTING(__MAC_10_5
,__IPHONE_2_0
);
508 #endif /* _SCNETWORKCONFIGURATIONPRIVATE_H */