2 * Copyright (c) 2004-2018 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 "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
;
160 Boolean trustRequired
;
164 CFNumberRef subfamily
;
172 int sort_order
; // sort order for this interface
174 // for BOND interfaces
175 Boolean supportsBond
;
177 CFArrayRef interfaces
;
179 CFDictionaryRef options
;
182 // for Bridge interfaces
183 Boolean supportsBridge
;
185 CFArrayRef interfaces
;
186 CFDictionaryRef options
;
189 // for VLAN interfaces
190 Boolean supportsVLAN
;
192 SCNetworkInterfaceRef interface
;
193 CFNumberRef tag
; // e.g. 1 <= tag <= 4094
194 CFDictionaryRef options
;
197 #if !TARGET_OS_SIMULATOR
198 // for interface rank assertions
199 IPMonitorControlRef IPMonitorControl
;
200 #endif // !TARGET_OS_SIMULATOR
201 } SCNetworkInterfacePrivate
, *SCNetworkInterfacePrivateRef
;
208 #pragma mark SCNetworkInterface configuration (internal)
211 __SCNetworkInterfaceMatchesName (CFStringRef name
,
215 __SCNetworkInterfaceCopyAll_IONetworkInterface (Boolean keep_pre_configured
);
218 @function __SCNetworkInterfaceCopyStorageEntity
219 @discussion Create interface entity of network interface as seen in
220 NetworkInterfaces.plist
221 @param interface The network interface from which interface entity is create
222 @result Dictionary which contains information about interface entity
223 You must release the returned value.
226 __SCNetworkInterfaceCopyStorageEntity (SCNetworkInterfaceRef interface
);
229 @function __SCNetworkInterfaceCopyStoredWithPreferences
230 @discussion Create an array of network interfaces, which is present in the preferences
231 in NetworkInteraces.plist
232 @param ni_prefs Preference for network interfaces
233 @result Array which contains SCNetworkInterfaceRef.
234 You must release the returned value.
237 CFArrayRef
// SCNetworkInterfaceRef
238 __SCNetworkInterfaceCopyStoredWithPreferences (SCPreferencesRef ni_prefs
);
240 SCNetworkInterfacePrivateRef
241 __SCNetworkInterfaceCreateCopy (CFAllocatorRef allocator
,
242 SCNetworkInterfaceRef interface
,
243 SCPreferencesRef prefs
,
244 CFStringRef serviceID
);
247 @function __SCNetworkInterfaceCreateMappingUsingBSDName
248 @discussion This function creates mapping of BSD name and network interface using
249 preferences which point to the NetworkInterfaces.plist file.
250 @param interfaces An array of network interfaces to use for the mapping.
251 @result BSD Mapping in a dictionary.
252 You must release the returned value.
255 __SCNetworkInterfaceCreateMappingUsingBSDName (CFArrayRef interfaces
);
257 SCNetworkInterfaceRef
258 __SCNetworkInterfaceCreateWithNIPreferencesUsingBSDName(CFAllocatorRef allocator
,
259 SCPreferencesRef ni_prefs
,
260 CFStringRef bsdName
);
262 SCNetworkInterfacePrivateRef
263 __SCNetworkInterfaceCreatePrivate (CFAllocatorRef allocator
,
264 SCNetworkInterfaceRef interface
,
265 SCPreferencesRef prefs
,
266 CFStringRef serviceID
);
268 SCNetworkInterfacePrivateRef
269 _SCBondInterfaceCreatePrivate (CFAllocatorRef allocator
,
270 CFStringRef bond_if
);
272 SCNetworkInterfacePrivateRef
273 _SCBridgeInterfaceCreatePrivate (CFAllocatorRef allocator
,
274 CFStringRef bridge_if
);
276 SCNetworkInterfacePrivateRef
277 _SCVLANInterfaceCreatePrivate (CFAllocatorRef allocator
,
278 CFStringRef vlan_if
);
281 __SCNetworkInterfaceCopyInterfaceEntity (SCNetworkInterfaceRef interface
);
284 __SCNetworkInterfaceCopyDeepConfiguration (SCNetworkSetRef set
,
285 SCNetworkInterfaceRef interface
);
287 #if !TARGET_OS_IPHONE
289 __SCNetworkInterfaceCopyXLocalizedDisplayName (SCNetworkInterfaceRef interface
);
292 __SCNetworkInterfaceCopyXNonLocalizedDisplayName(SCNetworkInterfaceRef interface
);
293 #endif // !TARGET_OS_IPHONE
296 __SCNetworkInterfaceGetDefaultConfigurationType (SCNetworkInterfaceRef interface
);
299 __SCNetworkInterfaceGetEntitySubType (SCNetworkInterfaceRef interface
);
302 __SCNetworkInterfaceGetEntityType (SCNetworkInterfaceRef interface
);
305 __SCNetworkInterfaceGetNonLocalizedDisplayName (SCNetworkInterfaceRef interface
);
308 __SCNetworkInterfaceSetUserDefinedName(SCNetworkInterfaceRef interface
, CFStringRef name
);
311 @function __SCNetworkInterfaceGetUserDefinedName
312 @discussion This function returns the user defined name of the interface if available
313 @param interface The network interface.
314 @result String containing the user defined name.
317 __SCNetworkInterfaceGetUserDefinedName(SCNetworkInterfaceRef interface
);
320 @function __SCNetworkInterfaceIsActive
321 @discussion Identifies if the configuration of network interface is active or not
322 @param interface The network interface
323 @result TRUE if the interface configuration is active.
326 __SCNetworkInterfaceIsActive (SCNetworkInterfaceRef interface
);
329 __SCNetworkInterfaceIsMember (SCPreferencesRef prefs
,
330 SCNetworkInterfaceRef interface
);
333 __SCNetworkInterfaceEntityIsPPTP (CFDictionaryRef entity
);
336 __SCNetworkInterfaceIsValidExtendedConfigurationType
337 (SCNetworkInterfaceRef interface
,
338 CFStringRef extendedType
,
339 Boolean requirePerInterface
);
342 __SCNetworkInterfaceGetTemplateOverrides (SCNetworkInterfaceRef interface
,
343 CFStringRef overrideType
);
346 __SCNetworkInterfaceOrder (SCNetworkInterfaceRef interface
);
349 @function __SCNetworkInterfaceSaveStoredWithPreferences
350 @discussion Saves the array of interfaces in the preferences passed in the function. The interfaces
351 which are already present in the prefs file are replaced.
352 @param prefs Preferences which contain the interfaces to be replaced. If NULL, then preferences on
354 @param interfacesToSave The new interfaces array which is to be stored in preferences.
355 @result TRUE if saving of the new interfaces was successful.
359 __SCNetworkInterfaceSaveStoredWithPreferences (SCPreferencesRef prefs
,
360 CFArrayRef interfacesToSave
);
363 __SCNetworkInterfaceSetConfiguration (SCNetworkInterfaceRef interface
,
364 CFStringRef extendedType
,
365 CFDictionaryRef config
,
369 __SCNetworkInterfaceSetDeepConfiguration (SCNetworkSetRef set
,
370 SCNetworkInterfaceRef interface
,
374 @function __SCNetworkInterfaceSetIOInterfaceUnity
375 @discussion Will allow the caller to set IO Interface Unit
376 @param interface The network interface
377 @param unit The new interface unit to set
381 __SCNetworkInterfaceSetIOInterfaceUnit (SCNetworkInterfaceRef interface
,
385 __SCNetworkInterfaceSupportsVLAN (CFStringRef bsd_if
);
388 __SCBondInterfaceListCollectMembers (CFArrayRef interfaces
,
389 CFMutableSetRef set
);
392 __SCBondInterfaceSetMemberInterfaces (SCBondInterfaceRef bond
,
396 __SCBridgeInterfaceListCollectMembers (CFArrayRef interfaces
,
397 CFMutableSetRef set
);
400 __SCBridgeInterfaceSetMemberInterfaces (SCBridgeInterfaceRef bridge
,
404 _SCNetworkInterfaceCacheOpen(void);
407 _SCNetworkInterfaceCacheClose(void);
410 #pragma mark SCNetworkProtocol configuration (internal)
413 SCNetworkProtocolPrivateRef
414 __SCNetworkProtocolCreatePrivate (CFAllocatorRef allocator
,
415 CFStringRef entityID
,
416 SCNetworkServiceRef service
);
419 __SCNetworkProtocolIsValidType (CFStringRef protocolType
);
423 #pragma mark SCNetworkService configuration (internal)
426 CFArrayRef
/* of SCNetworkServiceRef's */
427 __SCNetworkServiceCopyAllEnabled (SCPreferencesRef prefs
);
429 CFArrayRef
/* of SCNetworkInterfaceRef's */
430 __SCNetworkServiceCopyAllInterfaces (SCPreferencesRef prefs
);
432 SCNetworkServicePrivateRef
433 __SCNetworkServiceCreatePrivate (CFAllocatorRef allocator
,
434 SCPreferencesRef prefs
,
435 CFStringRef serviceID
,
436 SCNetworkInterfaceRef interface
);
439 __SCNetworkServiceExistsForInterface (CFArrayRef services
,
440 SCNetworkInterfaceRef interface
);
443 __SCNetworkServiceCreate (SCPreferencesRef prefs
,
444 SCNetworkInterfaceRef interface
,
445 CFStringRef userDefinedName
);
448 __SCNetworkServiceIsPPTP (SCNetworkServiceRef service
);
452 __SCNetworkCreateDefaultNIPrefs (CFStringRef prefsID
);
455 @function __SCNetworkServiceMigrateNew
456 @discussion Adds network service to SCPreferencesRef if it doesn't exists
457 @param prefs SCPreferencesRef
458 @param service The network service
459 @param bsdMapping Mapping of interface names between configurations
460 @result TRUE if add service to prefs is successful
463 __SCNetworkServiceMigrateNew (SCPreferencesRef prefs
,
464 SCNetworkServiceRef service
,
465 CFDictionaryRef bsdMapping
,
466 CFDictionaryRef setMapping
,
467 CFDictionaryRef serviceSetMapping
);
470 __SCNetworkServiceAddProtocolToService (SCNetworkServiceRef service
,
471 CFStringRef protocolType
,
472 CFDictionaryRef configuration
,
476 #pragma mark SCNetworkSet configuration (internal)
484 __log_SCNetworkConfiguration (void);
488 #pragma mark Miscellaneous (internal)
492 __copyInterfaceTemplate (CFStringRef interfaceType
,
493 CFStringRef childInterfaceType
);
496 __copyProtocolTemplate (CFStringRef interfaceType
,
497 CFStringRef childInterfaceType
,
498 CFStringRef protocolType
);
501 __getPrefsConfiguration (SCPreferencesRef prefs
,
505 __setPrefsConfiguration (SCPreferencesRef prefs
,
507 CFDictionaryRef config
,
508 Boolean keepInactive
);
511 __getPrefsEnabled (SCPreferencesRef prefs
,
515 __setPrefsEnabled (SCPreferencesRef prefs
,
520 __createInterface (int s
,
521 CFStringRef interface
);
524 __destroyInterface (int s
,
525 CFStringRef interface
);
528 __SCPreferencesPathCreateUniqueChild_WithMoreSCFCompatibility
529 (SCPreferencesRef prefs
,
533 __extract_password (SCPreferencesRef prefs
,
534 CFDictionaryRef config
,
535 CFStringRef passwordKey
,
536 CFStringRef encryptionKey
,
537 CFStringRef encryptionKeyChainValue
,
538 CFStringRef unique_id
,
539 CFDataRef
*password
);
542 __remove_password (SCPreferencesRef prefs
,
543 CFDictionaryRef config
,
544 CFStringRef passwordKey
,
545 CFStringRef encryptionKey
,
546 CFStringRef encryptionKeyChainValue
,
547 CFStringRef unique_id
,
548 CFDictionaryRef
*newConfig
);
551 __rank_to_str (SCNetworkServicePrimaryRank rank
,
552 CFStringRef
*rankStr
);
555 __str_to_rank (CFStringRef rankStr
,
556 SCNetworkServicePrimaryRank
*rank
);
560 #endif /* _SCNETWORKCONFIGURATIONINTERNAL_H */