this repo has no description
at fixPythonPipStalling 563 lines 15 kB view raw
1/* 2 * Copyright (c) 2004-2018 Apple Inc. All rights reserved. 3 * 4 * @APPLE_LICENSE_HEADER_START@ 5 * 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 11 * file. 12 * 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. 20 * 21 * @APPLE_LICENSE_HEADER_END@ 22 */ 23 24#ifndef _SCNETWORKCONFIGURATIONINTERNAL_H 25#define _SCNETWORKCONFIGURATIONINTERNAL_H 26 27#include <TargetConditionals.h> 28#include <CoreFoundation/CoreFoundation.h> 29#include <CoreFoundation/CFRuntime.h> 30 31#ifndef SC_LOG_HANDLE 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> 40 41 42typedef struct { 43 44 // base CFType information 45 CFRuntimeBase cfBase; 46 47 // set id 48 CFStringRef setID; 49 50 // prefs 51 SCPreferencesRef prefs; 52 53 // name 54 CFStringRef name; 55 56 // misc 57 Boolean established; 58 59} SCNetworkSetPrivate, *SCNetworkSetPrivateRef; 60 61 62typedef struct { 63 64 // base CFType information 65 CFRuntimeBase cfBase; 66 67 // service id 68 CFStringRef serviceID; 69 70 // interface 71 SCNetworkInterfaceRef interface; 72 73 // prefs 74 SCPreferencesRef prefs; 75 76 // store (for live SCNetworkService) 77 SCDynamicStoreRef store; 78 79 // name 80 CFStringRef name; 81 82 // external identifiers 83 CFMutableDictionaryRef externalIDs; 84 85} SCNetworkServicePrivate, *SCNetworkServicePrivateRef; 86 87 88typedef struct { 89 90 // base CFType information 91 CFRuntimeBase cfBase; 92 93 // entity id 94 CFStringRef entityID; 95 96 // service 97 SCNetworkServiceRef service; 98 99} SCNetworkProtocolPrivate, *SCNetworkProtocolPrivateRef; 100 101 102typedef struct { 103 104 // base CFType information 105 CFRuntimeBase cfBase; 106 107 // interface information 108 CFStringRef interface_type; // interface type 109 110 Boolean active; 111 112 // [non-localized] name 113 CFStringRef name; // non-localized [display] name 114 115 // localized name 116 CFStringRef localized_name; // localized [display] name 117 CFStringRef localized_key; 118 CFStringRef localized_arg1; 119 CFStringRef localized_arg2; 120 121 // [layered] interface 122 SCNetworkInterfaceRef interface; 123 124 // prefs (for associated service, BOND interfaces, and VLAN interfaces) 125 SCPreferencesRef prefs; 126 127 // SCDynamicStore 128 SCDynamicStoreRef store; 129 130 // serviceID (NULL if not associated with a service) 131 CFStringRef serviceID; 132 133 // unsaved configuration (when prefs not [yet] available) 134 CFMutableDictionaryRef unsaved; 135 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 141 142 // configuration information 143 CFMutableArrayRef supported_interface_types; 144 CFMutableArrayRef supported_protocol_types; 145 146 // IORegistry (service plane) information 147 CFDataRef address; 148 CFStringRef addressString; 149 Boolean builtin; 150 CFStringRef configurationAction; 151 Boolean hidden; 152 CFStringRef location; 153 CFStringRef path; 154 uint64_t entryID; 155 CFMutableDictionaryRef overrides; 156 CFStringRef prefix; 157 Boolean trustRequired; 158 CFNumberRef type; 159 CFNumberRef unit; 160 CFNumberRef family; 161 CFNumberRef subfamily; 162 struct { 163 CFStringRef name; 164 CFNumberRef vid; 165 CFNumberRef pid; 166 } usb; 167 168 // misc 169 unsigned int sort_order; // sort order for this interface 170 171 // for BOND interfaces 172 Boolean supportsBond; 173 struct { 174 CFArrayRef interfaces; 175 CFNumberRef mode; 176 CFDictionaryRef options; 177 } bond; 178 179 // for Bridge interfaces 180 Boolean supportsBridge; 181 struct { 182 CFArrayRef interfaces; 183 CFDictionaryRef options; 184 } bridge; 185 186 // for VLAN interfaces 187 Boolean supportsVLAN; 188 struct { 189 SCNetworkInterfaceRef interface; 190 CFNumberRef tag; // e.g. 1 <= tag <= 4094 191 CFDictionaryRef options; 192 } vlan; 193 194 // for interface rank assertions 195 IPMonitorControlRef IPMonitorControl; 196 197} SCNetworkInterfacePrivate, *SCNetworkInterfacePrivateRef; 198 199 200__BEGIN_DECLS 201 202 203#pragma mark - 204#pragma mark SCNetworkInterface configuration (internal) 205 206Boolean 207__SCNetworkInterfaceMatchesName (CFStringRef name, 208 CFStringRef key); 209 210CFArrayRef 211__SCNetworkInterfaceCopyAll_IONetworkInterface (Boolean keep_pre_configured); 212 213/*! 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. 220 */ 221CFDictionaryRef 222__SCNetworkInterfaceCopyStorageEntity (SCNetworkInterfaceRef interface); 223 224/*! 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. 231 */ 232 233CFArrayRef // SCNetworkInterfaceRef 234__SCNetworkInterfaceCopyStoredWithPreferences (SCPreferencesRef ni_prefs); 235 236SCNetworkInterfacePrivateRef 237__SCNetworkInterfaceCreateCopy (CFAllocatorRef allocator, 238 SCNetworkInterfaceRef interface, 239 SCPreferencesRef prefs, 240 CFStringRef serviceID); 241 242/*! 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. 249 */ 250CFDictionaryRef 251__SCNetworkInterfaceCreateMappingUsingBSDName (CFArrayRef interfaces); 252 253SCNetworkInterfaceRef 254__SCNetworkInterfaceCreateWithNIPreferencesUsingBSDName(CFAllocatorRef allocator, 255 SCPreferencesRef ni_prefs, 256 CFStringRef bsdName); 257 258SCNetworkInterfacePrivateRef 259__SCNetworkInterfaceCreatePrivate (CFAllocatorRef allocator, 260 SCNetworkInterfaceRef interface, 261 SCPreferencesRef prefs, 262 CFStringRef serviceID); 263 264SCNetworkInterfacePrivateRef 265_SCBondInterfaceCreatePrivate (CFAllocatorRef allocator, 266 CFStringRef bond_if); 267 268SCNetworkInterfacePrivateRef 269_SCBridgeInterfaceCreatePrivate (CFAllocatorRef allocator, 270 CFStringRef bridge_if); 271 272SCNetworkInterfacePrivateRef 273_SCVLANInterfaceCreatePrivate (CFAllocatorRef allocator, 274 CFStringRef vlan_if); 275 276CFDictionaryRef 277__SCNetworkInterfaceCopyInterfaceEntity (SCNetworkInterfaceRef interface); 278 279CFArrayRef 280__SCNetworkInterfaceCopyDeepConfiguration (SCNetworkSetRef set, 281 SCNetworkInterfaceRef interface); 282 283#if !TARGET_OS_IPHONE 284CFStringRef 285__SCNetworkInterfaceCopyXLocalizedDisplayName (SCNetworkInterfaceRef interface); 286 287CFStringRef 288__SCNetworkInterfaceCopyXNonLocalizedDisplayName(SCNetworkInterfaceRef interface); 289#endif // !TARGET_OS_IPHONE 290 291CFStringRef 292__SCNetworkInterfaceGetDefaultConfigurationType (SCNetworkInterfaceRef interface); 293 294CFStringRef 295__SCNetworkInterfaceGetEntitySubType (SCNetworkInterfaceRef interface); 296 297CFStringRef 298__SCNetworkInterfaceGetEntityType (SCNetworkInterfaceRef interface); 299 300CFStringRef 301__SCNetworkInterfaceGetNonLocalizedDisplayName (SCNetworkInterfaceRef interface); 302 303void 304__SCNetworkInterfaceSetUserDefinedName(SCNetworkInterfaceRef interface, CFStringRef name); 305 306/*! 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. 311 */ 312CFStringRef 313__SCNetworkInterfaceGetUserDefinedName(SCNetworkInterfaceRef interface); 314 315/*! 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. 320 */ 321Boolean 322__SCNetworkInterfaceIsActive (SCNetworkInterfaceRef interface); 323 324Boolean 325__SCNetworkInterfaceIsMember (SCPreferencesRef prefs, 326 SCNetworkInterfaceRef interface); 327 328Boolean 329__SCNetworkInterfaceEntityIsPPTP (CFDictionaryRef entity); 330 331Boolean 332__SCNetworkInterfaceIsValidExtendedConfigurationType 333 (SCNetworkInterfaceRef interface, 334 CFStringRef extendedType, 335 Boolean requirePerInterface); 336 337CFPropertyListRef 338__SCNetworkInterfaceGetTemplateOverrides (SCNetworkInterfaceRef interface, 339 CFStringRef overrideType); 340 341int 342__SCNetworkInterfaceOrder (SCNetworkInterfaceRef interface); 343 344/*! 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 349 the system are used. 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. 352 */ 353 354Boolean 355__SCNetworkInterfaceSaveStoredWithPreferences (SCPreferencesRef prefs, 356 CFArrayRef interfacesToSave); 357 358Boolean 359__SCNetworkInterfaceSetConfiguration (SCNetworkInterfaceRef interface, 360 CFStringRef extendedType, 361 CFDictionaryRef config, 362 Boolean okToHold); 363 364void 365__SCNetworkInterfaceSetDeepConfiguration (SCNetworkSetRef set, 366 SCNetworkInterfaceRef interface, 367 CFArrayRef configs); 368 369/*! 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 374 375 */ 376void 377__SCNetworkInterfaceSetIOInterfaceUnit (SCNetworkInterfaceRef interface, 378 CFNumberRef unit); 379 380Boolean 381__SCNetworkInterfaceSupportsVLAN (CFStringRef bsd_if); 382 383void 384__SCBondInterfaceListCollectMembers (CFArrayRef interfaces, 385 CFMutableSetRef set); 386 387Boolean 388__SCBondInterfaceSetMemberInterfaces (SCBondInterfaceRef bond, 389 CFArrayRef members); 390 391void 392__SCBridgeInterfaceListCollectMembers (CFArrayRef interfaces, 393 CFMutableSetRef set); 394 395Boolean 396__SCBridgeInterfaceSetMemberInterfaces (SCBridgeInterfaceRef bridge, 397 CFArrayRef members); 398 399void 400_SCNetworkInterfaceCacheOpen(void); 401 402void 403_SCNetworkInterfaceCacheClose(void); 404 405#pragma mark - 406#pragma mark SCNetworkProtocol configuration (internal) 407 408 409SCNetworkProtocolPrivateRef 410__SCNetworkProtocolCreatePrivate (CFAllocatorRef allocator, 411 CFStringRef entityID, 412 SCNetworkServiceRef service); 413 414Boolean 415__SCNetworkProtocolIsValidType (CFStringRef protocolType); 416 417 418#pragma mark - 419#pragma mark SCNetworkService configuration (internal) 420 421 422CFArrayRef /* of SCNetworkServiceRef's */ 423__SCNetworkServiceCopyAllEnabled (SCPreferencesRef prefs); 424 425CFArrayRef /* of SCNetworkInterfaceRef's */ 426__SCNetworkServiceCopyAllInterfaces (SCPreferencesRef prefs); 427 428SCNetworkServicePrivateRef 429__SCNetworkServiceCreatePrivate (CFAllocatorRef allocator, 430 SCPreferencesRef prefs, 431 CFStringRef serviceID, 432 SCNetworkInterfaceRef interface); 433 434Boolean 435__SCNetworkServiceExists (SCNetworkServiceRef service); 436 437Boolean 438__SCNetworkServiceExistsForInterface (CFArrayRef services, 439 SCNetworkInterfaceRef interface); 440 441Boolean 442__SCNetworkServiceCreate (SCPreferencesRef prefs, 443 SCNetworkInterfaceRef interface, 444 CFStringRef userDefinedName); 445 446Boolean 447__SCNetworkServiceIsPPTP (SCNetworkServiceRef service); 448 449 450SCPreferencesRef 451__SCNetworkCreateDefaultNIPrefs (CFStringRef prefsID); 452 453/*! 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 460 */ 461Boolean 462__SCNetworkServiceMigrateNew (SCPreferencesRef prefs, 463 SCNetworkServiceRef service, 464 CFDictionaryRef bsdMapping, 465 CFDictionaryRef setMapping, 466 CFDictionaryRef serviceSetMapping); 467 468void 469__SCNetworkServiceAddProtocolToService (SCNetworkServiceRef service, 470 CFStringRef protocolType, 471 CFDictionaryRef configuration, 472 Boolean enabled); 473 474#pragma mark - 475#pragma mark SCNetworkSet configuration (internal) 476 477 478Boolean 479__SCNetworkSetExists (SCNetworkSetRef set); 480 481 482#pragma mark - 483#pragma mark Logging 484 485 486os_log_t 487__log_SCNetworkConfiguration (void); 488 489 490#pragma mark - 491#pragma mark Miscellaneous (internal) 492 493 494CFDictionaryRef 495__copyInterfaceTemplate (CFStringRef interfaceType, 496 CFStringRef childInterfaceType); 497 498CFDictionaryRef 499__copyProtocolTemplate (CFStringRef interfaceType, 500 CFStringRef childInterfaceType, 501 CFStringRef protocolType); 502 503CFDictionaryRef 504__getPrefsConfiguration (SCPreferencesRef prefs, 505 CFStringRef path); 506 507Boolean 508__setPrefsConfiguration (SCPreferencesRef prefs, 509 CFStringRef path, 510 CFDictionaryRef config, 511 Boolean keepInactive); 512 513Boolean 514__getPrefsEnabled (SCPreferencesRef prefs, 515 CFStringRef path); 516 517Boolean 518__setPrefsEnabled (SCPreferencesRef prefs, 519 CFStringRef path, 520 Boolean enabled); 521 522Boolean 523__createInterface (int s, 524 CFStringRef interface); 525 526Boolean 527__destroyInterface (int s, 528 CFStringRef interface); 529 530CFStringRef 531__SCPreferencesPathCreateUniqueChild_WithMoreSCFCompatibility 532 (SCPreferencesRef prefs, 533 CFStringRef prefix); 534 535Boolean 536__extract_password (SCPreferencesRef prefs, 537 CFDictionaryRef config, 538 CFStringRef passwordKey, 539 CFStringRef encryptionKey, 540 CFStringRef encryptionKeyChainValue, 541 CFStringRef unique_id, 542 CFDataRef *password); 543 544Boolean 545__remove_password (SCPreferencesRef prefs, 546 CFDictionaryRef config, 547 CFStringRef passwordKey, 548 CFStringRef encryptionKey, 549 CFStringRef encryptionKeyChainValue, 550 CFStringRef unique_id, 551 CFDictionaryRef *newConfig); 552 553Boolean 554__rank_to_str (SCNetworkServicePrimaryRank rank, 555 CFStringRef *rankStr); 556 557Boolean 558__str_to_rank (CFStringRef rankStr, 559 SCNetworkServicePrimaryRank *rank); 560 561__END_DECLS 562 563#endif /* _SCNETWORKCONFIGURATIONINTERNAL_H */