2 * Copyright (c) 2004-2017 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
27 #include <TargetConditionals.h>
28 #include <CoreFoundation/CoreFoundation.h>
29 #include <CoreFoundation/CFRuntime.h>
32 #define SC_LOG_HANDLE __log_SCNetworkConfiguration()
33 #endif // SC_LOG_HANDLE
34 #include <SystemConfiguration/SystemConfiguration.h>
35 #include <SystemConfiguration/SCPrivate.h>
36 #include <SystemConfiguration/SCValidation.h>
37 #include <SystemConfiguration/SCPreferencesPathKey.h>
38 #include <IOKit/IOKitLib.h>
40 #if !TARGET_OS_SIMULATOR
41 #include "IPMonitorControl.h"
42 #endif // !TARGET_OS_SIMULATOR
47 // base CFType information
54 SCPreferencesRef prefs
;
62 } SCNetworkSetPrivate
, *SCNetworkSetPrivateRef
;
67 // base CFType information
71 CFStringRef serviceID
;
74 SCNetworkInterfaceRef interface
;
77 SCPreferencesRef prefs
;
79 // store (for live SCNetworkService)
80 SCDynamicStoreRef store
;
85 // external identifiers
86 CFMutableDictionaryRef externalIDs
;
88 } SCNetworkServicePrivate
, *SCNetworkServicePrivateRef
;
93 // base CFType information
100 SCNetworkServiceRef service
;
102 } SCNetworkProtocolPrivate
, *SCNetworkProtocolPrivateRef
;
107 // base CFType information
108 CFRuntimeBase cfBase
;
110 // interface information
111 CFStringRef interface_type
; // interface type
115 // [non-localized] name
116 CFStringRef name
; // non-localized [display] name
119 CFStringRef localized_name
; // localized [display] name
120 CFStringRef localized_key
;
121 CFStringRef localized_arg1
;
122 CFStringRef localized_arg2
;
124 // [layered] interface
125 SCNetworkInterfaceRef interface
;
127 // prefs (for associated service, BOND interfaces, and VLAN interfaces)
128 SCPreferencesRef prefs
;
131 SCDynamicStoreRef store
;
133 // serviceID (NULL if not associated with a service)
134 CFStringRef serviceID
;
136 // unsaved configuration (when prefs not [yet] available)
137 CFMutableDictionaryRef unsaved
;
139 // [SCPreferences] interface entity information
140 CFStringRef entity_device
; // interface device
141 CFStringRef entity_device_unique
; // ... UniqueIdentifier
142 CFStringRef entity_type
; // interface type
143 CFStringRef entity_subtype
; // interface subtype
145 // configuration information
146 CFMutableArrayRef supported_interface_types
;
147 CFMutableArrayRef supported_protocol_types
;
149 // IORegistry (service plane) information
151 CFStringRef addressString
;
153 CFStringRef configurationAction
;
155 CFStringRef location
;
158 CFMutableDictionaryRef overrides
;
163 CFNumberRef subfamily
;
171 int sort_order
; // sort order for this interface
173 // for BOND interfaces
174 Boolean supportsBond
;
176 CFArrayRef interfaces
;
178 CFDictionaryRef options
;
181 // for Bridge interfaces
182 Boolean supportsBridge
;
184 CFArrayRef interfaces
;
185 CFDictionaryRef options
;
188 // for VLAN interfaces
189 Boolean supportsVLAN
;
191 SCNetworkInterfaceRef interface
;
192 CFNumberRef tag
; // e.g. 1 <= tag <= 4094
193 CFDictionaryRef options
;
196 #if !TARGET_OS_SIMULATOR
197 // for interface rank assertions
198 IPMonitorControlRef IPMonitorControl
;
199 #endif // !TARGET_OS_SIMULATOR
200 } SCNetworkInterfacePrivate
, *SCNetworkInterfacePrivateRef
;
207 #pragma mark SCNetworkInterface configuration (internal)
210 __SCNetworkInterfaceMatchesName (CFStringRef name
,
214 __SCNetworkInterfaceCopyAll_IONetworkInterface (Boolean keep_pre_configured
);
217 @function __SCNetworkInterfaceCopyStorageEntity
218 @discussion Create interface entity of network interface as seen in
219 NetworkInterfaces.plist
220 @param interface The network interface from which interface entity is create
221 @result Dictionary which contains information about interface entity
222 You must release the returned value.
225 __SCNetworkInterfaceCopyStorageEntity (SCNetworkInterfaceRef interface
);
228 @function __SCNetworkInterfaceCopyStoredWithPreferences
229 @discussion Create an array of network interfaces, which is present in the preferences
230 in NetworkInteraces.plist
231 @param ni_prefs Preference for network interfaces
232 @result Array which contains SCNetworkInterfaceRef.
233 You must release the returned value.
236 CFArrayRef
// SCNetworkInterfaceRef
237 __SCNetworkInterfaceCopyStoredWithPreferences (SCPreferencesRef ni_prefs
);
239 SCNetworkInterfacePrivateRef
240 __SCNetworkInterfaceCreateCopy (CFAllocatorRef allocator
,
241 SCNetworkInterfaceRef interface
,
242 SCPreferencesRef prefs
,
243 CFStringRef serviceID
);
246 @function __SCNetworkInterfaceCreateMappingUsingBSDName
247 @discussion This function creates mapping of BSD name and network interface using
248 preferences which point to the NetworkInterfaces.plist file.
249 @param interfaces An array of network interfaces to use for the mapping.
250 @result BSD Mapping in a dictionary.
251 You must release the returned value.
254 __SCNetworkInterfaceCreateMappingUsingBSDName (CFArrayRef interfaces
);
256 SCNetworkInterfaceRef
257 __SCNetworkInterfaceCreateWithNIPreferencesUsingBSDName(CFAllocatorRef allocator
,
258 SCPreferencesRef ni_prefs
,
259 CFStringRef bsdName
);
261 SCNetworkInterfacePrivateRef
262 __SCNetworkInterfaceCreatePrivate (CFAllocatorRef allocator
,
263 SCNetworkInterfaceRef interface
,
264 SCPreferencesRef prefs
,
265 CFStringRef serviceID
);
267 SCNetworkInterfacePrivateRef
268 _SCBondInterfaceCreatePrivate (CFAllocatorRef allocator
,
269 CFStringRef bond_if
);
271 SCNetworkInterfacePrivateRef
272 _SCBridgeInterfaceCreatePrivate (CFAllocatorRef allocator
,
273 CFStringRef bridge_if
);
275 SCNetworkInterfacePrivateRef
276 _SCVLANInterfaceCreatePrivate (CFAllocatorRef allocator
,
277 CFStringRef vlan_if
);
280 __SCNetworkInterfaceCopyInterfaceEntity (SCNetworkInterfaceRef interface
);
283 __SCNetworkInterfaceCopyDeepConfiguration (SCNetworkSetRef set
,
284 SCNetworkInterfaceRef interface
);
286 #if !TARGET_OS_IPHONE
288 __SCNetworkInterfaceCopyXLocalizedDisplayName (SCNetworkInterfaceRef interface
);
291 __SCNetworkInterfaceCopyXNonLocalizedDisplayName(SCNetworkInterfaceRef interface
);
292 #endif // !TARGET_OS_IPHONE
295 __SCNetworkInterfaceCreateCapabilities (SCNetworkInterfaceRef interface
,
297 CFDictionaryRef capability_options
);
300 __SCNetworkInterfaceCreateMediaOptions (SCNetworkInterfaceRef interface
,
301 CFDictionaryRef media_options
);
304 __SCNetworkInterfaceGetDefaultConfigurationType (SCNetworkInterfaceRef interface
);
307 __SCNetworkInterfaceGetEntitySubType (SCNetworkInterfaceRef interface
);
310 __SCNetworkInterfaceGetEntityType (SCNetworkInterfaceRef interface
);
313 __SCNetworkInterfaceGetNonLocalizedDisplayName (SCNetworkInterfaceRef interface
);
316 __SCNetworkInterfaceSetDisableUntilNeededValue (SCNetworkInterfaceRef interface
,
320 __SCNetworkInterfaceSetUserDefinedName(SCNetworkInterfaceRef interface
, CFStringRef name
);
323 @function __SCNetworkInterfaceGetUserDefinedName
324 @discussion This function returns the user defined name of the interface if available
325 @param interface The network interface.
326 @result String containing the user defined name.
329 __SCNetworkInterfaceGetUserDefinedName(SCNetworkInterfaceRef interface
);
332 @function __SCNetworkInterfaceIsActive
333 @discussion Identifies if the configuration of network interface is active or not
334 @param interface The network interface
335 @result TRUE if the interface configuration is active.
338 __SCNetworkInterfaceIsActive (SCNetworkInterfaceRef interface
);
341 __SCNetworkInterfaceIsMember (SCPreferencesRef prefs
,
342 SCNetworkInterfaceRef interface
);
345 __SCNetworkInterfaceEntityIsPPTP (CFDictionaryRef entity
);
348 __SCNetworkInterfaceIsValidExtendedConfigurationType
349 (SCNetworkInterfaceRef interface
,
350 CFStringRef extendedType
,
351 Boolean requirePerInterface
);
354 __SCNetworkInterfaceGetTemplateOverrides (SCNetworkInterfaceRef interface
,
355 CFStringRef overrideType
);
358 __SCNetworkInterfaceOrder (SCNetworkInterfaceRef interface
);
361 @function __SCNetworkInterfaceSaveStoredWithPreferences
362 @discussion Saves the array of interfaces in the preferences passed in the function. The interfaces
363 which are already present in the prefs file are replaced.
364 @param prefs Preferences which contain the interfaces to be replaced. If NULL, then preferences on
366 @param interfacesToSave The new interfaces array which is to be stored in preferences.
367 @result TRUE if saving of the new interfaces was successful.
371 __SCNetworkInterfaceSaveStoredWithPreferences (SCPreferencesRef prefs
,
372 CFArrayRef interfacesToSave
);
375 __SCNetworkInterfaceSetConfiguration (SCNetworkInterfaceRef interface
,
376 CFStringRef extendedType
,
377 CFDictionaryRef config
,
381 __SCNetworkInterfaceSetDeepConfiguration (SCNetworkSetRef set
,
382 SCNetworkInterfaceRef interface
,
386 @function __SCNetworkInterfaceSetIOInterfaceUnity
387 @discussion Will allow the caller to set IO Interface Unit
388 @param interface The network interface
389 @param unit The new interface unit to set
393 __SCNetworkInterfaceSetIOInterfaceUnit (SCNetworkInterfaceRef interface
,
397 __SCNetworkInterfaceSupportsVLAN (CFStringRef bsd_if
);
400 __SCBondInterfaceListCollectMembers (CFArrayRef interfaces
,
401 CFMutableSetRef set
);
404 __SCBondInterfaceSetMemberInterfaces (SCBondInterfaceRef bond
,
408 __SCBridgeInterfaceListCollectMembers (CFArrayRef interfaces
,
409 CFMutableSetRef set
);
412 __SCBridgeInterfaceSetMemberInterfaces (SCBridgeInterfaceRef bridge
,
416 _SCNetworkInterfaceCacheOpen();
419 _SCNetworkInterfaceCacheClose();
422 #pragma mark SCNetworkProtocol configuration (internal)
425 SCNetworkProtocolPrivateRef
426 __SCNetworkProtocolCreatePrivate (CFAllocatorRef allocator
,
427 CFStringRef entityID
,
428 SCNetworkServiceRef service
);
431 __SCNetworkProtocolIsValidType (CFStringRef protocolType
);
435 #pragma mark SCNetworkService configuration (internal)
438 CFArrayRef
/* of SCNetworkServiceRef's */
439 __SCNetworkServiceCopyAllEnabled (SCPreferencesRef prefs
);
441 CFArrayRef
/* of SCNetworkInterfaceRef's */
442 __SCNetworkServiceCopyAllInterfaces (SCPreferencesRef prefs
);
444 SCNetworkServicePrivateRef
445 __SCNetworkServiceCreatePrivate (CFAllocatorRef allocator
,
446 SCPreferencesRef prefs
,
447 CFStringRef serviceID
,
448 SCNetworkInterfaceRef interface
);
451 __SCNetworkServiceExistsForInterface (CFArrayRef services
,
452 SCNetworkInterfaceRef interface
);
455 __SCNetworkServiceCreate (SCPreferencesRef prefs
,
456 SCNetworkInterfaceRef interface
,
457 CFStringRef userDefinedName
);
460 __SCNetworkServiceIsPPTP (SCNetworkServiceRef service
);
464 __SCNetworkCreateDefaultNIPrefs (CFStringRef prefsID
);
467 @function __SCNetworkServiceMigrateNew
468 @discussion Adds network service to SCPreferencesRef if it doesn't exists
469 @param prefs SCPreferencesRef
470 @param service The network service
471 @param bsdMapping Mapping of interface names between configurations
472 @result TRUE if add service to prefs is successful
475 __SCNetworkServiceMigrateNew (SCPreferencesRef prefs
,
476 SCNetworkServiceRef service
,
477 CFDictionaryRef bsdMapping
,
478 CFDictionaryRef setMapping
,
479 CFDictionaryRef serviceSetMapping
);
482 __SCNetworkServiceAddProtocolToService (SCNetworkServiceRef service
,
483 CFStringRef protocolType
,
484 CFDictionaryRef configuration
,
488 #pragma mark SCNetworkSet configuration (internal)
496 __log_SCNetworkConfiguration ();
500 #pragma mark Miscellaneous (internal)
504 __copyInterfaceTemplate (CFStringRef interfaceType
,
505 CFStringRef childInterfaceType
);
508 __copyProtocolTemplate (CFStringRef interfaceType
,
509 CFStringRef childInterfaceType
,
510 CFStringRef protocolType
);
513 __getPrefsConfiguration (SCPreferencesRef prefs
,
517 __setPrefsConfiguration (SCPreferencesRef prefs
,
519 CFDictionaryRef config
,
520 Boolean keepInactive
);
523 __getPrefsEnabled (SCPreferencesRef prefs
,
527 __setPrefsEnabled (SCPreferencesRef prefs
,
532 __createInterface (int s
,
533 CFStringRef interface
);
536 __destroyInterface (int s
,
537 CFStringRef interface
);
540 __SCPreferencesPathCreateUniqueChild_WithMoreSCFCompatibility
541 (SCPreferencesRef prefs
,
545 __extract_password (SCPreferencesRef prefs
,
546 CFDictionaryRef config
,
547 CFStringRef passwordKey
,
548 CFStringRef encryptionKey
,
549 CFStringRef encryptionKeyChainValue
,
550 CFStringRef unique_id
,
551 CFDataRef
*password
);
554 __remove_password (SCPreferencesRef prefs
,
555 CFDictionaryRef config
,
556 CFStringRef passwordKey
,
557 CFStringRef encryptionKey
,
558 CFStringRef encryptionKeyChainValue
,
559 CFStringRef unique_id
,
560 CFDictionaryRef
*newConfig
);
563 __rank_to_str (SCNetworkServicePrimaryRank rank
,
564 CFStringRef
*rankStr
);
567 __str_to_rank (CFStringRef rankStr
,
568 SCNetworkServicePrimaryRank
*rank
);
572 #endif /* _SCNETWORKCONFIGURATIONINTERNAL_H */