2 * Copyright (c) 2004-2015 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 _SCNETWORKCONFIGURATIONINTERNAL_H
25 #define _SCNETWORKCONFIGURATIONINTERNAL_H
28 #include <TargetConditionals.h>
29 #include <CoreFoundation/CoreFoundation.h>
30 #include <CoreFoundation/CFRuntime.h>
31 #include <SystemConfiguration/SystemConfiguration.h>
32 #include <SystemConfiguration/SCPreferencesPathKey.h>
33 #include <SystemConfiguration/SCNetworkConfigurationPrivate.h>
34 #include <IOKit/IOKitLib.h>
36 #if !TARGET_IPHONE_SIMULATOR
37 #include "IPMonitorControl.h"
38 #endif // !TARGET_IPHONE_SIMULATOR
43 // base CFType information
50 SCPreferencesRef prefs
;
58 } SCNetworkSetPrivate
, *SCNetworkSetPrivateRef
;
63 // base CFType information
67 CFStringRef serviceID
;
70 SCNetworkInterfaceRef interface
;
73 SCPreferencesRef prefs
;
75 // store (for live SCNetworkService)
76 SCDynamicStoreRef store
;
81 // external identifiers
82 CFMutableDictionaryRef externalIDs
;
84 } SCNetworkServicePrivate
, *SCNetworkServicePrivateRef
;
89 // base CFType information
96 SCNetworkServiceRef service
;
98 } SCNetworkProtocolPrivate
, *SCNetworkProtocolPrivateRef
;
103 // base CFType information
104 CFRuntimeBase cfBase
;
106 // interface information
107 CFStringRef interface_type
; // interface type
111 // [non-localized] name
112 CFStringRef name
; // non-localized [display] name
115 CFStringRef localized_name
; // localized [display] name
116 CFStringRef localized_key
;
117 CFStringRef localized_arg1
;
118 CFStringRef localized_arg2
;
120 // [layered] interface
121 SCNetworkInterfaceRef interface
;
123 // prefs (for associated service, BOND interfaces, and VLAN interfaces)
124 SCPreferencesRef prefs
;
127 SCDynamicStoreRef store
;
129 // serviceID (NULL if not associated with a service)
130 CFStringRef serviceID
;
132 // unsaved configuration (when prefs not [yet] available)
133 CFMutableDictionaryRef unsaved
;
135 // [SCPreferences] interface entity information
136 CFStringRef entity_device
; // interface device
137 CFStringRef entity_device_unique
; // ... UniqueIdentifier
138 CFStringRef entity_type
; // interface type
139 CFStringRef entity_subtype
; // interface subtype
141 // configuration information
142 CFMutableArrayRef supported_interface_types
;
143 CFMutableArrayRef supported_protocol_types
;
145 // IORegistry (service plane) information
147 CFStringRef addressString
;
149 CFStringRef configurationAction
;
151 CFStringRef location
;
154 CFMutableDictionaryRef overrides
;
166 int sort_order
; // sort order for this interface
168 // for BOND interfaces
169 Boolean supportsBond
;
171 CFArrayRef interfaces
;
173 CFDictionaryRef options
;
176 // for Bridge interfaces
177 Boolean supportsBridge
;
179 CFArrayRef interfaces
;
180 CFDictionaryRef options
;
183 // for VLAN interfaces
184 Boolean supportsVLAN
;
186 SCNetworkInterfaceRef interface
;
187 CFNumberRef tag
; // e.g. 1 <= tag <= 4094
188 CFDictionaryRef options
;
191 #if !TARGET_IPHONE_SIMULATOR
192 // for interface rank assertions
193 IPMonitorControlRef IPMonitorControl
;
194 #endif // !TARGET_IPHONE_SIMULATOR
195 } SCNetworkInterfacePrivate
, *SCNetworkInterfacePrivateRef
;
202 #pragma mark SCNetworkInterface configuration (internal)
205 __SCNetworkInterfaceMatchesName (CFStringRef name
, CFStringRef key
);
208 __SCNetworkInterfaceCopyAll_IONetworkInterface (void);
211 @function __SCNetworkInterfaceCopyStorageEntity
212 @discussion Create interface entity of network interface as seen in
213 NetworkInterfaces.plist
214 @param interface The network interface from which interface entity is create
215 @result Dictionary which contains information about interface entity
216 You must release the returned value.
219 __SCNetworkInterfaceCopyStorageEntity (SCNetworkInterfaceRef interface
);
222 @function __SCNetworkInterfaceCopyStoredWithPreferences
223 @discussion Create an array of network interfaces, which is present in the preferences
224 in NetworkInteraces.plist
225 @param ni_prefs Preference for network interfaces
226 @result Array which contains SCNetworkInterfaceRef.
227 You must release the returned value.
230 CFArrayRef
// SCNetworkInterfaceRef
231 __SCNetworkInterfaceCopyStoredWithPreferences (SCPreferencesRef ni_prefs
);
233 SCNetworkInterfacePrivateRef
234 __SCNetworkInterfaceCreateCopy (CFAllocatorRef allocator
,
235 SCNetworkInterfaceRef interface
,
236 SCPreferencesRef prefs
,
237 CFStringRef serviceID
);
240 @function __SCNetworkInterfaceCreateMappingUsingBSDName
241 @discussion This function creates mapping of BSD name and network interface using
242 preferences which point to the NetworkInterfaces.plist file.
243 @param ni_prefs Preferences pointing to NetworkInterfaces.plist
244 @result BSD Mapping in a dictionary.
245 You must release the returned value.
248 __SCNetworkInterfaceCreateMappingUsingBSDName(CFArrayRef interfaces
);
250 SCNetworkInterfaceRef
251 __SCNetworkInterfaceCreateWithNIPreferencesUsingBSDName(CFAllocatorRef allocator
,
252 SCPreferencesRef ni_prefs
,
253 CFStringRef bsdName
);
255 SCNetworkInterfacePrivateRef
256 __SCNetworkInterfaceCreatePrivate (CFAllocatorRef allocator
,
257 SCNetworkInterfaceRef interface
,
258 SCPreferencesRef prefs
,
259 CFStringRef serviceID
);
261 SCNetworkInterfacePrivateRef
262 _SCBondInterfaceCreatePrivate (CFAllocatorRef allocator
,
263 CFStringRef bond_if
);
265 SCNetworkInterfacePrivateRef
266 _SCBridgeInterfaceCreatePrivate (CFAllocatorRef allocator
,
267 CFStringRef bridge_if
);
269 SCNetworkInterfacePrivateRef
270 _SCVLANInterfaceCreatePrivate (CFAllocatorRef allocator
,
271 CFStringRef vlan_if
);
274 __SCNetworkInterfaceCopyInterfaceEntity (SCNetworkInterfaceRef interface
);
277 __SCNetworkInterfaceCopyDeepConfiguration (SCNetworkSetRef set
,
278 SCNetworkInterfaceRef interface
);
280 #if !TARGET_OS_IPHONE
282 __SCNetworkInterfaceCopyXLocalizedDisplayName (SCNetworkInterfaceRef interface
);
285 __SCNetworkInterfaceCopyXNonLocalizedDisplayName(SCNetworkInterfaceRef interface
);
286 #endif // !TARGET_OS_IPHONE
289 __SCNetworkInterfaceCreateCapabilities (SCNetworkInterfaceRef interface
,
291 CFDictionaryRef capability_options
);
294 __SCNetworkInterfaceCreateMediaOptions (SCNetworkInterfaceRef interface
,
295 CFDictionaryRef media_options
);
298 __SCNetworkInterfaceGetDefaultConfigurationType (SCNetworkInterfaceRef interface
);
301 __SCNetworkInterfaceGetEntitySubType (SCNetworkInterfaceRef interface
);
304 __SCNetworkInterfaceGetEntityType (SCNetworkInterfaceRef interface
);
307 __SCNetworkInterfaceGetNonLocalizedDisplayName (SCNetworkInterfaceRef interface
);
310 __SCNetworkInterfaceSetUserDefinedName(SCNetworkInterfaceRef interface
, CFStringRef name
);
313 @function __SCNetworkInterfaceGetUserDefinedName
314 @discussion This function returns the user defined name of the interface if available
315 @param interface The network interface.
316 @result String containing the user defined name.
319 __SCNetworkInterfaceGetUserDefinedName(SCNetworkInterfaceRef interface
);
322 @function __SCNetworkInterfaceIsActive
323 @discussion Identifies if the configuration of network interface is active or not
324 @param interface The network interface
325 @result TRUE if the interface configuration is active.
328 __SCNetworkInterfaceIsActive (SCNetworkInterfaceRef interface
);
331 __SCNetworkInterfaceIsMember (SCPreferencesRef prefs
,
332 SCNetworkInterfaceRef interface
);
335 __SCNetworkInterfaceIsValidExtendedConfigurationType
336 (SCNetworkInterfaceRef interface
,
337 CFStringRef extendedType
,
338 Boolean requirePerInterface
);
341 __SCNetworkInterfaceGetTemplateOverrides (SCNetworkInterfaceRef interface
,
342 CFStringRef overrideType
);
345 __SCNetworkInterfaceOrder (SCNetworkInterfaceRef interface
);
348 @function __SCNetworkInterfaceSaveStoredWithPreferences
349 @discussion Saves the array of interfaces in the preferences passed in the function. The interfaces
350 which are already present in the prefs file are replaced.
351 @param prefs Preferences which contain the interfaces to be replaced. If NULL, then preferences on
353 @param interfacesToSave The new interfaces array which is to be stored in preferences.
354 @result TRUE if saving of the new interfaces was successful.
358 __SCNetworkInterfaceSaveStoredWithPreferences (SCPreferencesRef prefs
,
359 CFArrayRef interfacesToSave
);
362 __SCNetworkInterfaceSetConfiguration (SCNetworkInterfaceRef interface
,
363 CFStringRef extendedType
,
364 CFDictionaryRef config
,
368 __SCNetworkInterfaceSetDeepConfiguration (SCNetworkSetRef set
,
369 SCNetworkInterfaceRef interface
,
373 @function __SCNetworkInterfaceSetIOInterfaceUnity
374 @discussion Will allow the caller to set IO Interface Unit
375 @param interface The network interface
376 @param unit The new interface unit to set
380 __SCNetworkInterfaceSetIOInterfaceUnit (SCNetworkInterfaceRef interface
,
384 __SCNetworkInterfaceSupportsVLAN (CFStringRef bsd_if
);
387 __SCBondInterfaceListCollectMembers (CFArrayRef interfaces
,
388 CFMutableSetRef set
);
391 __SCBondInterfaceSetMemberInterfaces (SCBondInterfaceRef bond
,
395 __SCBridgeInterfaceListCollectMembers (CFArrayRef interfaces
,
396 CFMutableSetRef set
);
399 __SCBridgeInterfaceSetMemberInterfaces (SCBridgeInterfaceRef bridge
,
403 #pragma mark SCNetworkProtocol configuration (internal)
406 SCNetworkProtocolPrivateRef
407 __SCNetworkProtocolCreatePrivate (CFAllocatorRef allocator
,
408 CFStringRef entityID
,
409 SCNetworkServiceRef service
);
412 __SCNetworkProtocolIsValidType (CFStringRef protocolType
);
416 #pragma mark SCNetworkService configuration (internal)
419 CFArrayRef
/* of SCNetworkServiceRef's */
420 __SCNetworkServiceCopyAllEnabled (SCPreferencesRef prefs
);
422 CFArrayRef
/* of SCNetworkInterfaceRef's */
423 __SCNetworkServiceCopyAllInterfaces (SCPreferencesRef prefs
);
425 SCNetworkServicePrivateRef
426 __SCNetworkServiceCreatePrivate (CFAllocatorRef allocator
,
427 SCPreferencesRef prefs
,
428 CFStringRef serviceID
,
429 SCNetworkInterfaceRef interface
);
432 __SCNetworkServiceExistsForInterface (CFArrayRef services
,
433 SCNetworkInterfaceRef interface
);
436 __SCNetworkServiceCreate (SCPreferencesRef prefs
,
437 SCNetworkInterfaceRef interface
,
438 CFStringRef userDefinedName
);
441 __SCNetworkCreateDefaultNIPrefs (CFStringRef prefsID
);
444 @function __SCNetworkServiceMigrateNew
445 @discussion Adds network service to SCPreferencesRef if it doesn't exists
446 @param prefs SCPreferencesRef
447 @param service The network service
448 @param bsdMapping Mapping of interface names between configurations
449 @result TRUE if add service to prefs is successful
452 __SCNetworkServiceMigrateNew (SCPreferencesRef prefs
,
453 SCNetworkServiceRef service
,
454 CFDictionaryRef bsdMapping
,
455 CFDictionaryRef setMapping
,
456 CFDictionaryRef serviceSetMapping
);
459 __SCNetworkServiceAddProtocolToService (SCNetworkServiceRef service
,
460 CFStringRef protocolType
,
461 CFDictionaryRef configuration
,
465 #pragma mark SCNetworkSet configuration (internal)
469 #pragma mark Miscellaneous (internal)
473 __copyInterfaceTemplate (CFStringRef interfaceType
,
474 CFStringRef childInterfaceType
);
477 __copyProtocolTemplate (CFStringRef interfaceType
,
478 CFStringRef childInterfaceType
,
479 CFStringRef protocolType
);
482 __getPrefsConfiguration (SCPreferencesRef prefs
,
486 __setPrefsConfiguration (SCPreferencesRef prefs
,
488 CFDictionaryRef config
,
489 Boolean keepInactive
);
492 __getPrefsEnabled (SCPreferencesRef prefs
,
496 __setPrefsEnabled (SCPreferencesRef prefs
,
501 __createInterface (int s
,
502 CFStringRef interface
);
505 __destroyInterface (int s
,
506 CFStringRef interface
);
509 __SCPreferencesPathCreateUniqueChild_WithMoreSCFCompatibility
510 (SCPreferencesRef prefs
,
514 __extract_password (SCPreferencesRef prefs
,
515 CFDictionaryRef config
,
516 CFStringRef passwordKey
,
517 CFStringRef encryptionKey
,
518 CFStringRef encryptionKeyChainValue
,
519 CFStringRef unique_id
,
520 CFDataRef
*password
);
523 __remove_password (SCPreferencesRef prefs
,
524 CFDictionaryRef config
,
525 CFStringRef passwordKey
,
526 CFStringRef encryptionKey
,
527 CFStringRef encryptionKeyChainValue
,
528 CFStringRef unique_id
,
529 CFDictionaryRef
*newConfig
);
532 __rank_to_str (SCNetworkServicePrimaryRank rank
,
533 CFStringRef
*rankStr
);
536 __str_to_rank (CFStringRef rankStr
,
537 SCNetworkServicePrimaryRank
*rank
);
541 #endif /* _SCNETWORKCONFIGURATIONINTERNAL_H */