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 _SCNetworkInterfaceGetConfigurationAction
172 @discussion Returns a user-notification / auto-configuration action for the interface.
173 @param interface The network interface.
174 @result The user-notification / auto-configuration action;
175 NULL if the default action should be used.
178 _SCNetworkInterfaceGetConfigurationAction (SCNetworkInterfaceRef interface
) __OSX_AVAILABLE_STARTING(__MAC_10_6
,__IPHONE_2_0
);
181 @function _SCNetworkInterfaceGetHardwareAddress
182 @discussion Returns a link layer address for the interface.
183 @param interface The network interface.
184 @result The hardware (MAC) address for the interface.
185 NULL if no hardware address is available.
188 _SCNetworkInterfaceGetHardwareAddress (SCNetworkInterfaceRef interface
) __OSX_AVAILABLE_STARTING(__MAC_10_5
,__IPHONE_2_0
);
191 @function _SCNetworkInterfaceGetIOInterfaceType
192 @discussion Returns the IOInterfaceType for the interface.
193 @param interface The network interface.
194 @result The IOInterfaceType associated with the interface
197 _SCNetworkInterfaceGetIOInterfaceType (SCNetworkInterfaceRef interface
) __OSX_AVAILABLE_STARTING(__MAC_10_5
,__IPHONE_2_0
);
200 @function _SCNetworkInterfaceGetIOInterfaceUnit
201 @discussion Returns the IOInterfaceUnit for the interface.
202 @param interface The network interface.
203 @result The IOInterfaceUnit associated with the interface;
204 NULL if no IOLocation is available.
207 _SCNetworkInterfaceGetIOInterfaceUnit (SCNetworkInterfaceRef interface
) __OSX_AVAILABLE_STARTING(__MAC_10_5
,__IPHONE_2_0
);
210 @function _SCNetworkInterfaceGetIOPath
211 @discussion Returns the IOPath for the interface.
212 @param interface The network interface.
213 @result The IOPath associated with the interface;
214 NULL if no IOPath is available.
217 _SCNetworkInterfaceGetIOPath (SCNetworkInterfaceRef interface
) __OSX_AVAILABLE_STARTING(__MAC_10_5
,__IPHONE_2_0
);
220 @function _SCNetworkInterfaceIsBluetoothPAN
221 @discussion Identifies if a network interface is a Bluetooth PAN device.
222 @param interface The network interface.
223 @result TRUE if the interface is a Bluetooth PAN device.
226 _SCNetworkInterfaceIsBluetoothPAN (SCNetworkInterfaceRef interface
) __OSX_AVAILABLE_STARTING(__MAC_10_6
,__IPHONE_3_0
);
229 @function _SCNetworkInterfaceIsBuiltin
230 @discussion Identifies if a network interface is "built-in".
231 @param interface The network interface.
232 @result TRUE if the interface is "built-in".
235 _SCNetworkInterfaceIsBuiltin (SCNetworkInterfaceRef interface
) __OSX_AVAILABLE_STARTING(__MAC_10_5
,__IPHONE_2_0
);
238 @function _SCNetworkInterfaceIsTethered
239 @discussion Identifies if a network interface is an Apple tethered device (e.g. an iPhone).
240 @param interface The network interface.
241 @result TRUE if the interface is a tethered device.
244 _SCNetworkInterfaceIsTethered (SCNetworkInterfaceRef interface
) __OSX_AVAILABLE_STARTING(__MAC_10_6
,__IPHONE_3_0
);
247 @function _SCNetworkInterfaceIsModemV92
248 @discussion Identifies if a modem network interface supports
250 @param interface The network interface.
251 @result TRUE if the interface is "v.92" modem.
254 _SCNetworkInterfaceIsModemV92 (SCNetworkInterfaceRef interface
) __OSX_AVAILABLE_STARTING(__MAC_10_5
,__IPHONE_2_0
);
257 @function _SCNetworkInterfaceForceConfigurationRefresh
258 @discussion Forces a configuration refresh of the
260 @param ifName Network interface name.
261 @result TRUE if the refresh was successfully posted.
264 _SCNetworkInterfaceForceConfigurationRefresh (CFStringRef ifName
) __OSX_AVAILABLE_STARTING(__MAC_10_5
,__IPHONE_2_0
);
267 @function _SCBondInterfaceCopyActive
268 @discussion Returns all Ethernet Bond interfaces on the system.
269 @result The list of SCBondInterface interfaces on the system.
270 You must release the returned value.
273 _SCBondInterfaceCopyActive (void) __OSX_AVAILABLE_STARTING(__MAC_10_5
,__IPHONE_NA
);
276 @function _SCBondInterfaceUpdateConfiguration
277 @discussion Updates the bond interface configuration.
278 @param prefs The "preferences" session.
279 @result TRUE if the bond interface configuration was updated.; FALSE if the
280 an error was encountered.
283 _SCBondInterfaceUpdateConfiguration (SCPreferencesRef prefs
) __OSX_AVAILABLE_STARTING(__MAC_10_5
,__IPHONE_NA
);
286 @function SCBondInterfaceSetMode
287 @discussion Set the mode on the bond interface.
288 @param bond The bond interface on which to adjust the mode.
289 @param mode The mode value (0=IF_BOND_MODE_LACP,1=IF_BOND_MODE_STATIC)
290 @result TRUE if operation succeeded.
293 SCBondInterfaceSetMode (SCBondInterfaceRef bond
,
294 CFNumberRef mode
) __OSX_AVAILABLE_STARTING(__MAC_10_5
,__IPHONE_NA
);
297 @function SCBondInterfaceSetMode
298 @discussion Return the mode for the given bond interface.
299 @param bond The bond interface to get the mode from.
300 @result A CFNumberRef containing the mode (IF_BOND_MODE_{LACP,STATIC}).
303 SCBondInterfaceGetMode (SCBondInterfaceRef bond
) __OSX_AVAILABLE_STARTING(__MAC_10_5
,__IPHONE_NA
);
306 @function _SCVLANInterfaceCopyActive
307 @discussion Returns all VLAN interfaces on the system.
308 @result The list of SCVLANInterface interfaces on the system.
309 You must release the returned value.
312 _SCVLANInterfaceCopyActive (void) __OSX_AVAILABLE_STARTING(__MAC_10_5
,__IPHONE_NA
);
315 @function _SCVLANInterfaceUpdateConfiguration
316 @discussion Updates the VLAN interface configuration.
317 @param prefs The "preferences" session.
318 @result TRUE if the VLAN interface configuration was updated.; FALSE if the
319 an error was encountered.
322 _SCVLANInterfaceUpdateConfiguration (SCPreferencesRef prefs
) __OSX_AVAILABLE_STARTING(__MAC_10_5
,__IPHONE_NA
);
326 #pragma mark SCNetworkInterface Password SPIs
330 kSCNetworkInterfacePasswordTypePPP
= 1,
331 kSCNetworkInterfacePasswordTypeIPSecSharedSecret
,
332 kSCNetworkInterfacePasswordTypeEAPOL
,
333 kSCNetworkInterfacePasswordTypeIPSecXAuth
,
335 typedef uint32_t SCNetworkInterfacePasswordType
;
338 SCNetworkInterfaceCheckPassword (SCNetworkInterfaceRef interface
,
339 SCNetworkInterfacePasswordType passwordType
) __OSX_AVAILABLE_STARTING(__MAC_10_5
,__IPHONE_2_0
);
342 SCNetworkInterfaceCopyPassword (SCNetworkInterfaceRef interface
,
343 SCNetworkInterfacePasswordType passwordType
) __OSX_AVAILABLE_STARTING(__MAC_10_5
,__IPHONE_2_0
);
346 SCNetworkInterfaceRemovePassword (SCNetworkInterfaceRef interface
,
347 SCNetworkInterfacePasswordType passwordType
) __OSX_AVAILABLE_STARTING(__MAC_10_5
,__IPHONE_2_0
);
350 SCNetworkInterfaceSetPassword (SCNetworkInterfaceRef interface
,
351 SCNetworkInterfacePasswordType passwordType
,
353 CFDictionaryRef options
) __OSX_AVAILABLE_STARTING(__MAC_10_5
,__IPHONE_2_0
);
357 #pragma mark SCNetworkProtocol configuration (SPI)
361 @group Protocol configuration
365 static __inline__ CFTypeRef
366 isA_SCNetworkProtocol(CFTypeRef obj
)
368 return (isA_CFType(obj
, SCNetworkProtocolGetTypeID()));
373 #pragma mark SCNetworkService configuration (SPI)
377 @group Service configuration
381 static __inline__ CFTypeRef
382 isA_SCNetworkService(CFTypeRef obj
)
384 return (isA_CFType(obj
, SCNetworkServiceGetTypeID()));
388 kSCNetworkServicePrimaryRankDefault
= 0,
389 kSCNetworkServicePrimaryRankFirst
= 1,
390 kSCNetworkServicePrimaryRankLast
= 2,
391 kSCNetworkServicePrimaryRankNever
= 3
393 typedef uint32_t SCNetworkServicePrimaryRank
;
396 @function _SCNetworkServiceCopyActive
397 @discussion Returns the network service with the specified identifier.
399 Note: The service returned by this SPI differs from the SCNetworkServiceCopy
400 API in that queries and operations interact with the "active" service
401 represented in the SCDynamicStore. Only a limited subset of the
402 SCNetworkService APIs are supported.
403 @param prefs The dynamic store session.
404 @param serviceID The unique identifier for the service.
405 @result A reference to the SCNetworkService represented in the SCDynamicStore;
406 NULL if the serviceID does not exist in the SCDynamicStore or if an
407 error was encountered.
408 You must release the returned value.
411 _SCNetworkServiceCopyActive (SCDynamicStoreRef store
,
412 CFStringRef serviceID
) __OSX_AVAILABLE_STARTING(__MAC_10_6
,__IPHONE_2_1
);
415 @function SCNetworkServiceGetPrimaryRank
416 @discussion Returns the primary service rank associated with a service.
417 @param service The network service.
418 @result The primary service rank associated with the specified application;
419 kSCNetworkServicePrimaryRankDefault if no rank is associated with the
420 application or an error was encountered.
422 SCNetworkServicePrimaryRank
423 SCNetworkServiceGetPrimaryRank (SCNetworkServiceRef service
) __OSX_AVAILABLE_STARTING(__MAC_10_6
,__IPHONE_2_0
);
426 @function SCNetworkServiceSetPrimaryRank
427 @discussion Updates the the primary service rank associated with a service.
428 @param service The network service.
429 @param newRank The new primary service rank; kSCNetworkServicePrimaryRankDefault
430 if the default service rank should be used.
431 @result TRUE if the rank was stored; FALSE if an error was encountered.
433 Notes : The kSCNetworkServicePrimaryRankFirst and kSCNetworkServicePrimaryRankLast
434 values can only valid as a transient setting.
437 SCNetworkServiceSetPrimaryRank (SCNetworkServiceRef service
,
438 SCNetworkServicePrimaryRank newRank
) __OSX_AVAILABLE_STARTING(__MAC_10_6
,__IPHONE_2_0
);
442 #pragma mark SCNetworkSet configuration (SPI)
446 @group Set configuration
450 static __inline__ CFTypeRef
451 isA_SCNetworkSet(CFTypeRef obj
)
453 return (isA_CFType(obj
, SCNetworkSetGetTypeID()));
458 @function SCNetworkSetEstablishDefaultConfiguration
459 @discussion Updates a network set by adding services for
460 any network interface that is not currently
462 If the provided set contains one (or more) services, new
463 services will only be added for those interfaces that are
464 not represented in *any* set.
465 Otherwise, new services will be added for those interfaces
466 that are not represented in the provided set.
467 The new services are established with "default" configuration
469 @param set The network set.
470 @result TRUE if the configuration was updated; FALSE if no
471 changes were required or if an error was encountered.
474 SCNetworkSetEstablishDefaultConfiguration (SCNetworkSetRef set
) __OSX_AVAILABLE_STARTING(__MAC_10_5
,__IPHONE_2_0
);
477 @function SCNetworkSetEstablishDefaultInterfaceConfiguration
478 @discussion Updates a network set by adding services for
479 the specified network interface if is not currently
481 If the provided set contains one (or more) services, new
482 services will only be added for interfaces that are not
483 represented in *any* set.
484 Otherwise, new services will be added for interfaces that
485 are not represented in the provided set.
486 The new services are established with "default" configuration
488 @param set The network set.
489 @param interface The network interface.
490 @result TRUE if the configuration was updated; FALSE if no
491 changes were required or if an error was encountered.
494 SCNetworkSetEstablishDefaultInterfaceConfiguration (SCNetworkSetRef set
,
495 SCNetworkInterfaceRef interface
) __OSX_AVAILABLE_STARTING(__MAC_10_5
,__IPHONE_2_0
);
499 #endif /* _SCNETWORKCONFIGURATIONPRIVATE_H */