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 "IPMonitorControl.h"
39 #include <IOKit/IOKitLib.h>
44 // base CFType information
51 SCPreferencesRef prefs
;
59 } SCNetworkSetPrivate
, *SCNetworkSetPrivateRef
;
64 // base CFType information
68 CFStringRef serviceID
;
71 SCNetworkInterfaceRef interface
;
74 SCPreferencesRef prefs
;
76 // store (for live SCNetworkService)
77 SCDynamicStoreRef store
;
82 // external identifiers
83 CFMutableDictionaryRef externalIDs
;
85 } SCNetworkServicePrivate
, *SCNetworkServicePrivateRef
;
90 // base CFType information
97 SCNetworkServiceRef service
;
99 } SCNetworkProtocolPrivate
, *SCNetworkProtocolPrivateRef
;
104 // base CFType information
105 CFRuntimeBase cfBase
;
107 // interface information
108 CFStringRef interface_type
; // interface type
112 // [non-localized] name
113 CFStringRef name
; // non-localized [display] name
116 CFStringRef localized_name
; // localized [display] name
117 CFStringRef localized_key
;
118 CFStringRef localized_arg1
;
119 CFStringRef localized_arg2
;
121 // [layered] interface
122 SCNetworkInterfaceRef interface
;
124 // prefs (for associated service, BOND interfaces, and VLAN interfaces)
125 SCPreferencesRef prefs
;
128 SCDynamicStoreRef store
;
130 // serviceID (NULL if not associated with a service)
131 CFStringRef serviceID
;
133 // unsaved configuration (when prefs not [yet] available)
134 CFMutableDictionaryRef unsaved
;
136 // [SCPreferences] interface entity information
137 CFStringRef entity_device
; // interface device
138 CFStringRef entity_device_unique
; // ... UniqueIdentifier
139 CFStringRef entity_type
; // interface type
140 CFStringRef entity_subtype
; // interface subtype
142 // configuration information
143 CFMutableArrayRef supported_interface_types
;
144 CFMutableArrayRef supported_protocol_types
;
146 // IORegistry (service plane) information
148 CFStringRef addressString
;
150 CFStringRef configurationAction
;
152 CFStringRef location
;
155 CFMutableDictionaryRef overrides
;
157 Boolean trustRequired
;
161 CFNumberRef subfamily
;
169 unsigned int sort_order
; // sort order for this interface
171 // for BOND interfaces
172 Boolean supportsBond
;
174 CFArrayRef interfaces
;
176 CFDictionaryRef options
;
179 // for Bridge interfaces
180 Boolean supportsBridge
;
182 CFArrayRef interfaces
;
183 CFDictionaryRef options
;
186 // for VLAN interfaces
187 Boolean supportsVLAN
;
189 SCNetworkInterfaceRef interface
;
190 CFNumberRef tag
; // e.g. 1 <= tag <= 4094
191 CFDictionaryRef options
;
194 // for interface rank assertions
195 IPMonitorControlRef IPMonitorControl
;
197 } SCNetworkInterfacePrivate
, *SCNetworkInterfacePrivateRef
;
204 #pragma mark SCNetworkInterface configuration (internal)
207 __SCNetworkInterfaceMatchesName (CFStringRef name
,
211 __SCNetworkInterfaceCopyAll_IONetworkInterface (Boolean keep_pre_configured
);
214 @function __SCNetworkInterfaceCopyStorageEntity
215 @discussion Create interface entity of network interface as seen in
216 NetworkInterfaces.plist
217 @param interface The network interface from which interface entity is create
218 @result Dictionary which contains information about interface entity
219 You must release the returned value.
222 __SCNetworkInterfaceCopyStorageEntity (SCNetworkInterfaceRef interface
);
225 @function __SCNetworkInterfaceCopyStoredWithPreferences
226 @discussion Create an array of network interfaces, which is present in the preferences
227 in NetworkInteraces.plist
228 @param ni_prefs Preference for network interfaces
229 @result Array which contains SCNetworkInterfaceRef.
230 You must release the returned value.
233 CFArrayRef
// SCNetworkInterfaceRef
234 __SCNetworkInterfaceCopyStoredWithPreferences (SCPreferencesRef ni_prefs
);
236 SCNetworkInterfacePrivateRef
237 __SCNetworkInterfaceCreateCopy (CFAllocatorRef allocator
,
238 SCNetworkInterfaceRef interface
,
239 SCPreferencesRef prefs
,
240 CFStringRef serviceID
);
243 @function __SCNetworkInterfaceCreateMappingUsingBSDName
244 @discussion This function creates mapping of BSD name and network interface using
245 preferences which point to the NetworkInterfaces.plist file.
246 @param interfaces An array of network interfaces to use for the mapping.
247 @result BSD Mapping in a dictionary.
248 You must release the returned value.
251 __SCNetworkInterfaceCreateMappingUsingBSDName (CFArrayRef interfaces
);
253 SCNetworkInterfaceRef
254 __SCNetworkInterfaceCreateWithNIPreferencesUsingBSDName(CFAllocatorRef allocator
,
255 SCPreferencesRef ni_prefs
,
256 CFStringRef bsdName
);
258 SCNetworkInterfacePrivateRef
259 __SCNetworkInterfaceCreatePrivate (CFAllocatorRef allocator
,
260 SCNetworkInterfaceRef interface
,
261 SCPreferencesRef prefs
,
262 CFStringRef serviceID
);
264 SCNetworkInterfacePrivateRef
265 _SCBondInterfaceCreatePrivate (CFAllocatorRef allocator
,
266 CFStringRef bond_if
);
268 SCNetworkInterfacePrivateRef
269 _SCBridgeInterfaceCreatePrivate (CFAllocatorRef allocator
,
270 CFStringRef bridge_if
);
272 SCNetworkInterfacePrivateRef
273 _SCVLANInterfaceCreatePrivate (CFAllocatorRef allocator
,
274 CFStringRef vlan_if
);
277 __SCNetworkInterfaceCopyInterfaceEntity (SCNetworkInterfaceRef interface
);
280 __SCNetworkInterfaceCopyDeepConfiguration (SCNetworkSetRef set
,
281 SCNetworkInterfaceRef interface
);
283 #if !TARGET_OS_IPHONE
285 __SCNetworkInterfaceCopyXLocalizedDisplayName (SCNetworkInterfaceRef interface
);
288 __SCNetworkInterfaceCopyXNonLocalizedDisplayName(SCNetworkInterfaceRef interface
);
289 #endif // !TARGET_OS_IPHONE
292 __SCNetworkInterfaceGetDefaultConfigurationType (SCNetworkInterfaceRef interface
);
295 __SCNetworkInterfaceGetEntitySubType (SCNetworkInterfaceRef interface
);
298 __SCNetworkInterfaceGetEntityType (SCNetworkInterfaceRef interface
);
301 __SCNetworkInterfaceGetNonLocalizedDisplayName (SCNetworkInterfaceRef interface
);
304 __SCNetworkInterfaceSetUserDefinedName(SCNetworkInterfaceRef interface
, CFStringRef name
);
307 @function __SCNetworkInterfaceGetUserDefinedName
308 @discussion This function returns the user defined name of the interface if available
309 @param interface The network interface.
310 @result String containing the user defined name.
313 __SCNetworkInterfaceGetUserDefinedName(SCNetworkInterfaceRef interface
);
316 @function __SCNetworkInterfaceIsActive
317 @discussion Identifies if the configuration of network interface is active or not
318 @param interface The network interface
319 @result TRUE if the interface configuration is active.
322 __SCNetworkInterfaceIsActive (SCNetworkInterfaceRef interface
);
325 __SCNetworkInterfaceIsMember (SCPreferencesRef prefs
,
326 SCNetworkInterfaceRef interface
);
329 __SCNetworkInterfaceEntityIsPPTP (CFDictionaryRef entity
);
332 __SCNetworkInterfaceIsValidExtendedConfigurationType
333 (SCNetworkInterfaceRef interface
,
334 CFStringRef extendedType
,
335 Boolean requirePerInterface
);
338 __SCNetworkInterfaceGetTemplateOverrides (SCNetworkInterfaceRef interface
,
339 CFStringRef overrideType
);
342 __SCNetworkInterfaceOrder (SCNetworkInterfaceRef interface
);
345 @function __SCNetworkInterfaceSaveStoredWithPreferences
346 @discussion Saves the array of interfaces in the preferences passed in the function. The interfaces
347 which are already present in the prefs file are replaced.
348 @param prefs Preferences which contain the interfaces to be replaced. If NULL, then preferences on
350 @param interfacesToSave The new interfaces array which is to be stored in preferences.
351 @result TRUE if saving of the new interfaces was successful.
355 __SCNetworkInterfaceSaveStoredWithPreferences (SCPreferencesRef prefs
,
356 CFArrayRef interfacesToSave
);
359 __SCNetworkInterfaceSetConfiguration (SCNetworkInterfaceRef interface
,
360 CFStringRef extendedType
,
361 CFDictionaryRef config
,
365 __SCNetworkInterfaceSetDeepConfiguration (SCNetworkSetRef set
,
366 SCNetworkInterfaceRef interface
,
370 @function __SCNetworkInterfaceSetIOInterfaceUnity
371 @discussion Will allow the caller to set IO Interface Unit
372 @param interface The network interface
373 @param unit The new interface unit to set
377 __SCNetworkInterfaceSetIOInterfaceUnit (SCNetworkInterfaceRef interface
,
381 __SCNetworkInterfaceSupportsVLAN (CFStringRef bsd_if
);
384 __SCBondInterfaceListCollectMembers (CFArrayRef interfaces
,
385 CFMutableSetRef set
);
388 __SCBondInterfaceSetMemberInterfaces (SCBondInterfaceRef bond
,
392 __SCBridgeInterfaceListCollectMembers (CFArrayRef interfaces
,
393 CFMutableSetRef set
);
396 __SCBridgeInterfaceSetMemberInterfaces (SCBridgeInterfaceRef bridge
,
400 _SCNetworkInterfaceCacheOpen(void);
403 _SCNetworkInterfaceCacheClose(void);
406 #pragma mark SCNetworkProtocol configuration (internal)
409 SCNetworkProtocolPrivateRef
410 __SCNetworkProtocolCreatePrivate (CFAllocatorRef allocator
,
411 CFStringRef entityID
,
412 SCNetworkServiceRef service
);
415 __SCNetworkProtocolIsValidType (CFStringRef protocolType
);
419 #pragma mark SCNetworkService configuration (internal)
422 CFArrayRef
/* of SCNetworkServiceRef's */
423 __SCNetworkServiceCopyAllEnabled (SCPreferencesRef prefs
);
425 CFArrayRef
/* of SCNetworkInterfaceRef's */
426 __SCNetworkServiceCopyAllInterfaces (SCPreferencesRef prefs
);
428 SCNetworkServicePrivateRef
429 __SCNetworkServiceCreatePrivate (CFAllocatorRef allocator
,
430 SCPreferencesRef prefs
,
431 CFStringRef serviceID
,
432 SCNetworkInterfaceRef interface
);
435 __SCNetworkServiceExists (SCNetworkServiceRef service
);
438 __SCNetworkServiceExistsForInterface (CFArrayRef services
,
439 SCNetworkInterfaceRef interface
);
442 __SCNetworkServiceCreate (SCPreferencesRef prefs
,
443 SCNetworkInterfaceRef interface
,
444 CFStringRef userDefinedName
);
447 __SCNetworkServiceIsPPTP (SCNetworkServiceRef service
);
451 __SCNetworkCreateDefaultNIPrefs (CFStringRef prefsID
);
454 @function __SCNetworkServiceMigrateNew
455 @discussion Adds network service to SCPreferencesRef if it doesn't exists
456 @param prefs SCPreferencesRef
457 @param service The network service
458 @param bsdMapping Mapping of interface names between configurations
459 @result TRUE if add service to prefs is successful
462 __SCNetworkServiceMigrateNew (SCPreferencesRef prefs
,
463 SCNetworkServiceRef service
,
464 CFDictionaryRef bsdMapping
,
465 CFDictionaryRef setMapping
,
466 CFDictionaryRef serviceSetMapping
);
469 __SCNetworkServiceAddProtocolToService (SCNetworkServiceRef service
,
470 CFStringRef protocolType
,
471 CFDictionaryRef configuration
,
475 #pragma mark SCNetworkSet configuration (internal)
479 __SCNetworkSetExists (SCNetworkSetRef set
);
487 __log_SCNetworkConfiguration (void);
491 #pragma mark Miscellaneous (internal)
495 __copyInterfaceTemplate (CFStringRef interfaceType
,
496 CFStringRef childInterfaceType
);
499 __copyProtocolTemplate (CFStringRef interfaceType
,
500 CFStringRef childInterfaceType
,
501 CFStringRef protocolType
);
504 __getPrefsConfiguration (SCPreferencesRef prefs
,
508 __setPrefsConfiguration (SCPreferencesRef prefs
,
510 CFDictionaryRef config
,
511 Boolean keepInactive
);
514 __getPrefsEnabled (SCPreferencesRef prefs
,
518 __setPrefsEnabled (SCPreferencesRef prefs
,
523 __createInterface (int s
,
524 CFStringRef interface
);
527 __destroyInterface (int s
,
528 CFStringRef interface
);
531 __SCPreferencesPathCreateUniqueChild_WithMoreSCFCompatibility
532 (SCPreferencesRef prefs
,
536 __extract_password (SCPreferencesRef prefs
,
537 CFDictionaryRef config
,
538 CFStringRef passwordKey
,
539 CFStringRef encryptionKey
,
540 CFStringRef encryptionKeyChainValue
,
541 CFStringRef unique_id
,
542 CFDataRef
*password
);
545 __remove_password (SCPreferencesRef prefs
,
546 CFDictionaryRef config
,
547 CFStringRef passwordKey
,
548 CFStringRef encryptionKey
,
549 CFStringRef encryptionKeyChainValue
,
550 CFStringRef unique_id
,
551 CFDictionaryRef
*newConfig
);
554 __rank_to_str (SCNetworkServicePrimaryRank rank
,
555 CFStringRef
*rankStr
);
558 __str_to_rank (CFStringRef rankStr
,
559 SCNetworkServicePrimaryRank
*rank
);
563 #endif /* _SCNETWORKCONFIGURATIONINTERNAL_H */