2 * Copyright (c) 2004-2007, 2009, 2010-2013, 2015-2020 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@
25 * Modification History
27 * May 27, 2004 Allan Nathanson <ajn@apple.com>
32 #include "SCNetworkConfigurationInternal.h"
33 #include "SCPreferencesInternal.h"
35 #include <sys/ioctl.h>
40 #pragma mark SCNetworkConfiguration logging
43 __private_extern__ os_log_t
44 __log_SCNetworkConfiguration(void)
46 static os_log_t log
= NULL
;
49 log
= os_log_create("com.apple.SystemConfiguration", "SCNetworkConfiguration");
57 logConfiguration_NetworkInterfaces(int level
, const char *description
, SCPreferencesRef prefs
)
59 CFArrayRef interfaces
;
61 interfaces
= SCPreferencesGetValue(prefs
, INTERFACES
);
62 if (isA_CFArray(interfaces
)) {
63 CFStringRef model
= SCPreferencesGetValue(prefs
, MODEL
);
64 CFIndex n
= CFArrayGetCount(interfaces
);
66 SC_log(level
, "%s%sinterfaces (%@)",
67 description
!= NULL
? description
: "",
68 description
!= NULL
? " " : "",
69 model
!= NULL
? model
: CFSTR("No model"));
71 for (CFIndex i
= 0; i
< n
; i
++) {
77 dict
= CFArrayGetValueAtIndex(interfaces
, i
);
78 if (!isA_CFDictionary(dict
)) {
82 bsdName
= CFDictionaryGetValue(dict
, CFSTR(kSCNetworkInterfaceBSDName
));
83 if (!isA_CFString(bsdName
)) {
87 info
= CFDictionaryGetValue(dict
, CFSTR(kSCNetworkInterfaceInfo
));
88 name
= CFDictionaryGetValue(info
, kSCPropUserDefinedName
);
89 SC_log(level
, " %@ (%@)",
91 name
!= NULL
? name
: CFSTR("???"));
98 logConfiguration_preferences(int level
, const char *description
, SCPreferencesRef prefs
)
100 CFStringRef model
= SCPreferencesGetValue(prefs
, MODEL
);
102 CFMutableArrayRef orphans
;
106 SC_log(level
, "%s%sconfiguration (%@)",
107 description
!= NULL
? description
: "",
108 description
!= NULL
? " " : "",
109 model
!= NULL
? model
: CFSTR("No model"));
111 services
= SCNetworkServiceCopyAll(prefs
);
112 if (services
!= NULL
) {
113 orphans
= CFArrayCreateMutableCopy(NULL
, 0, services
);
116 orphans
= CFArrayCreateMutable(NULL
, 0, &kCFTypeArrayCallBacks
);
119 sets
= SCNetworkSetCopyAll(prefs
);
121 n
= CFArrayGetCount(sets
);
122 for (CFIndex i
= 0; i
< n
; i
++) {
125 set
= CFArrayGetValueAtIndex(sets
, i
);
126 SC_log(level
, " Set %@ (%@)",
127 SCNetworkSetGetSetID(set
),
128 SCNetworkSetGetName(set
));
130 services
= SCNetworkSetCopyServices(set
);
131 if (services
!= NULL
) {
136 order
= SCNetworkSetGetServiceOrder(set
);
138 nOrder
= CFArrayGetCount(order
);
141 n
= CFArrayGetCount(services
);
143 CFMutableArrayRef sorted
;
145 sorted
= CFArrayCreateMutableCopy(NULL
, 0, services
);
146 CFArraySortValues(sorted
,
147 CFRangeMake(0, CFArrayGetCount(sorted
)),
148 _SCNetworkServiceCompare
,
154 for (CFIndex i
= 0; i
< n
; i
++) {
156 SCNetworkInterfaceRef interface
;
158 CFIndex orderIndex
= kCFNotFound
;
159 SCNetworkServiceRef service
;
160 CFStringRef serviceName
;
161 CFStringRef serviceID
;
162 CFStringRef userDefinedName
;
164 service
= CFArrayGetValueAtIndex(services
, i
);
165 serviceID
= SCNetworkServiceGetServiceID(service
);
166 serviceName
= SCNetworkServiceGetName(service
);
167 if (serviceName
== NULL
) serviceName
= CFSTR("");
169 interface
= SCNetworkServiceGetInterface(service
);
170 bsdName
= SCNetworkInterfaceGetBSDName(interface
);
172 userDefinedName
= __SCNetworkInterfaceGetUserDefinedName(interface
);
173 if (_SC_CFEqual(serviceName
, userDefinedName
)) {
174 userDefinedName
= NULL
;
178 orderIndex
= CFArrayGetFirstIndexOfValue(order
,
179 CFRangeMake(0, nOrder
),
182 if (orderIndex
!= kCFNotFound
) {
183 SC_log(level
, " Service %2ld : %@, %2d (%@%s%@%s%@)",
186 __SCNetworkInterfaceOrder(SCNetworkServiceGetInterface(service
)), // temp?
188 bsdName
!= NULL
? ", " : "",
189 bsdName
!= NULL
? bsdName
: CFSTR(""),
190 userDefinedName
!= NULL
? " : " : "",
191 userDefinedName
!= NULL
? userDefinedName
: CFSTR(""));
193 SC_log(level
, " Service : %@, %2d (%@%s%@%s%@)",
195 __SCNetworkInterfaceOrder(SCNetworkServiceGetInterface(service
)), // temp?
197 bsdName
!= NULL
? ", " : "",
198 bsdName
!= NULL
? bsdName
: CFSTR(""),
199 userDefinedName
!= NULL
? " : " : "",
200 userDefinedName
!= NULL
? userDefinedName
: CFSTR(""));
203 o
= CFArrayGetFirstIndexOfValue(orphans
, CFRangeMake(0, CFArrayGetCount(orphans
)), service
);
204 if (o
!= kCFNotFound
) {
205 CFArrayRemoveValueAtIndex(orphans
, o
);
216 n
= CFArrayGetCount(orphans
);
218 SC_log(level
, " Orphans");
220 for (CFIndex i
= 0; i
< n
; i
++) {
222 SCNetworkInterfaceRef interface
;
223 SCNetworkServiceRef service
;
224 CFStringRef serviceName
;
225 CFStringRef serviceID
;
227 service
= CFArrayGetValueAtIndex(orphans
, i
);
228 serviceID
= SCNetworkServiceGetServiceID(service
);
229 serviceName
= SCNetworkServiceGetName(service
);
230 if (serviceName
== NULL
) serviceName
= CFSTR("");
232 interface
= SCNetworkServiceGetInterface(service
);
233 bsdName
= SCNetworkInterfaceGetBSDName(interface
);
235 SC_log(level
, " Service : %@, %2d (%@%s%@)",
237 __SCNetworkInterfaceOrder(SCNetworkServiceGetInterface(service
)), // temp?
239 bsdName
!= NULL
? ", " : "",
240 bsdName
!= NULL
? bsdName
: CFSTR(""));
249 __SCNetworkConfigurationReport(int level
, const char *description
, SCPreferencesRef prefs
, SCPreferencesRef ni_prefs
)
251 logConfiguration_NetworkInterfaces(level
, description
, ni_prefs
);
252 logConfiguration_preferences (level
, description
, prefs
);
262 isEffectivelyEmptyConfiguration(CFDictionaryRef config
)
264 Boolean empty
= FALSE
;
267 n
= isA_CFDictionary(config
) ? CFDictionaryGetCount(config
) : 0;
274 if (CFDictionaryContainsKey(config
, kSCResvInactive
)) {
275 // ignore [effectively] empty configuration entities
287 __private_extern__ CFDictionaryRef
288 __SCNetworkConfigurationGetValue(SCPreferencesRef prefs
, CFStringRef path
)
290 CFDictionaryRef config
;
292 config
= SCPreferencesPathGetValue(prefs
, path
);
293 if (isEffectivelyEmptyConfiguration(config
)) {
294 // ignore [effectively] empty configuration entities
302 __private_extern__ Boolean
303 __SCNetworkConfigurationSetValue(SCPreferencesRef prefs
,
305 CFDictionaryRef config
,
306 Boolean keepInactive
)
309 CFDictionaryRef curConfig
;
310 CFMutableDictionaryRef newConfig
= NULL
;
313 if ((config
!= NULL
) && !isA_CFDictionary(config
)) {
314 _SCErrorSet(kSCStatusInvalidArgument
);
318 curConfig
= SCPreferencesPathGetValue(prefs
, path
);
319 curConfig
= isA_CFDictionary(curConfig
);
321 if (config
!= NULL
) {
322 newConfig
= CFDictionaryCreateMutableCopy(NULL
, 0, config
);
326 if (config
== NULL
) {
327 newConfig
= CFDictionaryCreateMutable(NULL
,
329 &kCFTypeDictionaryKeyCallBacks
,
330 &kCFTypeDictionaryValueCallBacks
);
333 if (isA_CFDictionary(curConfig
) && CFDictionaryContainsKey(curConfig
, kSCResvInactive
)) {
334 // if currently disabled
335 CFDictionarySetValue(newConfig
, kSCResvInactive
, kCFBooleanTrue
);
337 // if currently enabled
338 CFDictionaryRemoveValue(newConfig
, kSCResvInactive
);
342 // check if the configuration changed
343 changed
= !_SC_CFEqual(curConfig
, newConfig
);
345 // set new configuration
348 if (newConfig
!= NULL
) CFRelease(newConfig
);
350 } else if (newConfig
!= NULL
) {
351 // if new configuration (or we are preserving a disabled state), update the prefs
352 ok
= SCPreferencesPathSetValue(prefs
, path
, newConfig
);
353 CFRelease(newConfig
);
356 ok
= SCPreferencesPathRemoveValue(prefs
, path
);
357 if (!ok
&& (SCError() == kSCStatusNoKey
)) {
366 __private_extern__ Boolean
367 __getPrefsEnabled(SCPreferencesRef prefs
, CFStringRef path
)
369 CFDictionaryRef config
;
371 config
= SCPreferencesPathGetValue(prefs
, path
);
372 if (isA_CFDictionary(config
) && CFDictionaryContainsKey(config
, kSCResvInactive
)) {
380 __private_extern__ Boolean
381 __setPrefsEnabled(SCPreferencesRef prefs
,
386 CFDictionaryRef curConfig
;
387 CFMutableDictionaryRef newConfig
= NULL
;
390 // preserve current configuration
391 curConfig
= SCPreferencesPathGetValue(prefs
, path
);
392 if (curConfig
!= NULL
) {
393 if (!isA_CFDictionary(curConfig
)) {
394 _SCErrorSet(kSCStatusFailed
);
397 newConfig
= CFDictionaryCreateMutableCopy(NULL
, 0, curConfig
);
401 CFDictionaryRemoveValue(newConfig
, kSCResvInactive
);
404 CFDictionarySetValue(newConfig
, kSCResvInactive
, kCFBooleanTrue
);
409 newConfig
= CFDictionaryCreateMutable(NULL
, 0, &kCFTypeDictionaryKeyCallBacks
, &kCFTypeDictionaryValueCallBacks
);
410 CFDictionarySetValue(newConfig
, kSCResvInactive
, kCFBooleanTrue
);
414 // check if the configuration changed
415 changed
= !_SC_CFEqual(curConfig
, newConfig
);
417 // set new configuration
420 if (newConfig
!= NULL
) CFRelease(newConfig
);
422 } else if (newConfig
!= NULL
) {
423 // if updated configuration (or we are establishing as disabled)
425 ok
= SCPreferencesPathSetValue(prefs
, path
, newConfig
);
426 CFRelease(newConfig
);
428 ok
= SCPreferencesPathRemoveValue(prefs
, path
);
429 if (!ok
&& (SCError() == kSCStatusNoKey
)) {
438 #define SYSTEMCONFIGURATION_RESOURCES_PATH SYSTEMCONFIGURATION_FRAMEWORK_PATH "/Resources"
440 #define SYSTEMCONFIGURATION_RESOURCES_PATH SYSTEMCONFIGURATION_FRAMEWORK_PATH
441 #endif // TARGET_OS_OSX
443 #define NETWORKCONFIGURATION_RESOURCE_FILE "NetworkConfiguration.plist"
445 static CFDictionaryRef
449 CFDictionaryRef templates
;
452 bundle
= _SC_CFBundleGet();
453 if (bundle
== NULL
) {
457 url
= CFBundleCopyResourceURL(bundle
, CFSTR("NetworkConfiguration"), CFSTR("plist"), NULL
);
459 SC_log(LOG_ERR
, "failed to GET resource URL to \"%s\". Trying harder...", NETWORKCONFIGURATION_RESOURCE_FILE
);
460 url
= CFURLCreateWithFileSystemPath(NULL
,
461 CFSTR(SYSTEMCONFIGURATION_RESOURCES_PATH
463 NETWORKCONFIGURATION_RESOURCE_FILE
),
464 kCFURLPOSIXPathStyle
,
468 SC_log(LOG_ERR
, "failed to CREATE resource URL to \"%s\"", SYSTEMCONFIGURATION_RESOURCES_PATH
470 NETWORKCONFIGURATION_RESOURCE_FILE
);
475 templates
= _SCCreatePropertyListFromResource(url
);
478 if ((templates
!= NULL
) && !isA_CFDictionary(templates
)) {
479 CFRelease(templates
);
487 __private_extern__ CFDictionaryRef
488 __copyInterfaceTemplate(CFStringRef interfaceType
,
489 CFStringRef childInterfaceType
)
491 CFDictionaryRef interface
= NULL
;
492 CFDictionaryRef interfaces
;
493 CFDictionaryRef templates
;
495 templates
= __copyTemplates();
496 if (templates
== NULL
) {
500 interfaces
= CFDictionaryGetValue(templates
, CFSTR("Interface"));
501 if (!isA_CFDictionary(interfaces
)) {
502 CFRelease(templates
);
506 if (childInterfaceType
== NULL
) {
507 interface
= CFDictionaryGetValue(interfaces
, interfaceType
);
509 CFStringRef expandedType
;
511 if (CFStringFind(childInterfaceType
, CFSTR("."), 0).location
!= kCFNotFound
) {
513 childInterfaceType
= CFSTR("*");
516 expandedType
= CFStringCreateWithFormat(NULL
,
521 interface
= CFDictionaryGetValue(interfaces
, expandedType
);
522 CFRelease(expandedType
);
525 if (isA_CFDictionary(interface
) && (CFDictionaryGetCount(interface
) > 0)) {
531 CFRelease(templates
);
537 __private_extern__ CFDictionaryRef
538 __copyProtocolTemplate(CFStringRef interfaceType
,
539 CFStringRef childInterfaceType
,
540 CFStringRef protocolType
)
542 CFDictionaryRef interface
= NULL
;
543 CFDictionaryRef protocol
= NULL
;
544 CFDictionaryRef protocols
;
545 CFDictionaryRef templates
;
547 templates
= __copyTemplates();
548 if (templates
== NULL
) {
552 protocols
= CFDictionaryGetValue(templates
, CFSTR("Protocol"));
553 if (!isA_CFDictionary(protocols
)) {
554 CFRelease(templates
);
558 if (childInterfaceType
== NULL
) {
559 interface
= CFDictionaryGetValue(protocols
, interfaceType
);
561 CFStringRef expandedType
;
563 if (CFStringFind(childInterfaceType
, CFSTR("."), 0).location
!= kCFNotFound
) {
565 childInterfaceType
= CFSTR("*");
568 expandedType
= CFStringCreateWithFormat(NULL
,
573 interface
= CFDictionaryGetValue(protocols
, expandedType
);
574 CFRelease(expandedType
);
577 if (isA_CFDictionary(interface
)) {
578 protocol
= CFDictionaryGetValue(interface
, protocolType
);
579 if (isA_CFDictionary(protocol
)) {
586 CFRelease(templates
);
592 __private_extern__ Boolean
593 __createInterface(int s
, CFStringRef interface
)
597 memset(&ifr
, 0, sizeof(ifr
));
598 (void) _SC_cfstring_to_cstring(interface
,
600 sizeof(ifr
.ifr_name
),
601 kCFStringEncodingASCII
);
603 if (ioctl(s
, SIOCIFCREATE
, &ifr
) == -1) {
604 SC_log(LOG_NOTICE
, "could not create interface \"%@\": %s",
614 __private_extern__ Boolean
615 __destroyInterface(int s
, CFStringRef interface
)
619 memset(&ifr
, 0, sizeof(ifr
));
620 (void) _SC_cfstring_to_cstring(interface
,
622 sizeof(ifr
.ifr_name
),
623 kCFStringEncodingASCII
);
625 if (ioctl(s
, SIOCIFDESTROY
, &ifr
) == -1) {
626 SC_log(LOG_NOTICE
, "could not destroy interface \"%@\": %s",
637 * For rdar://problem/4685223
639 * To keep MoreSCF happy we need to ensure that the first "Set" and
640 * "NetworkService" have a [less than] unique identifier that can
641 * be parsed as a numeric string.
643 * Note: this backwards compatibility code must be enabled using the
646 * sudo defaults write \
647 * /Library/Preferences/SystemConfiguration/preferences \
653 __SCPreferencesPathCreateUniqueChild_WithMoreSCFCompatibility(SCPreferencesRef prefs
, CFStringRef prefix
)
655 static int hack
= -1;
656 CFStringRef path
= NULL
;
661 enable
= SCPreferencesGetValue(prefs
, CFSTR("MoreSCF"));
662 hack
= (isA_CFBoolean(enable
) && CFBooleanGetValue(enable
)) ? 1 : 0;
666 CFDictionaryRef dict
;
669 path
= CFStringCreateWithFormat(NULL
, NULL
, CFSTR("%@/%@"), prefix
, CFSTR("0"));
670 dict
= SCPreferencesPathGetValue(prefs
, path
);
672 // if path "0" exists
677 // unique child with path "0" does not exist, create
678 dict
= CFDictionaryCreate(NULL
,
680 &kCFTypeDictionaryKeyCallBacks
,
681 &kCFTypeDictionaryValueCallBacks
);
682 ok
= SCPreferencesPathSetValue(prefs
, path
, dict
);
696 __copy_legacy_password(CFTypeRef password
)
698 if (password
== NULL
) {
702 if (isA_CFData(password
)) {
705 n
= CFDataGetLength(password
);
706 if ((n
% sizeof(UniChar
)) == 0) {
707 CFStringEncoding encoding
;
711 encoding
= (*(CFDataGetBytePtr(password
) + 1) == 0x00) ? kCFStringEncodingUTF16LE
: kCFStringEncodingUTF16BE
;
712 #else // __LITTLE_ENDIAN__
713 encoding
= (*(CFDataGetBytePtr(password
) ) == 0x00) ? kCFStringEncodingUTF16BE
: kCFStringEncodingUTF16LE
;
715 str
= CFStringCreateWithBytes(NULL
,
716 (const UInt8
*)CFDataGetBytePtr(password
),
720 password
= CFStringCreateExternalRepresentation(NULL
,
722 kCFStringEncodingUTF8
,
728 } else if (isA_CFString(password
) && (CFStringGetLength(password
) > 0)) {
729 // convert password to CFData
730 password
= CFStringCreateExternalRepresentation(NULL
,
732 kCFStringEncodingUTF8
,
744 __extract_password(SCPreferencesRef prefs
,
745 CFDictionaryRef config
,
746 CFStringRef passwordKey
,
747 CFStringRef encryptionKey
,
748 CFStringRef encryptionKeyChainValue
,
749 CFStringRef unique_id
,
752 CFStringRef encryption
= NULL
;
753 Boolean exists
= FALSE
;
755 // check for keychain password
756 if (config
!= NULL
) {
757 encryption
= CFDictionaryGetValue(config
, encryptionKey
);
759 if ((encryption
== NULL
) ||
760 (isA_CFString(encryption
) &&
761 CFEqual(encryption
, encryptionKeyChainValue
))) {
763 if (password
!= NULL
) {
765 *password
= _SCPreferencesSystemKeychainPasswordItemCopy(prefs
, unique_id
);
767 *password
= _SCSecKeychainPasswordItemCopy(NULL
, unique_id
);
769 exists
= (*password
!= NULL
);
772 exists
= _SCPreferencesSystemKeychainPasswordItemExists(prefs
, unique_id
);
774 exists
= _SCSecKeychainPasswordItemExists(NULL
, unique_id
);
779 // as needed, check for in-line password
780 if (!exists
&& (encryption
== NULL
) && (config
!= NULL
)) {
781 CFDataRef inline_password
;
783 inline_password
= CFDictionaryGetValue(config
, passwordKey
);
784 inline_password
= __copy_legacy_password(inline_password
);
785 if (inline_password
!= NULL
) {
788 if (password
!= NULL
) {
789 *password
= inline_password
;
791 CFRelease(inline_password
);
802 __remove_password(SCPreferencesRef prefs
,
803 CFDictionaryRef config
,
804 CFStringRef passwordKey
,
805 CFStringRef encryptionKey
,
806 CFStringRef encryptionKeyChainValue
,
807 CFStringRef unique_id
,
808 CFDictionaryRef
*newConfig
)
810 CFStringRef encryption
= NULL
;
813 // check for keychain password
814 if (config
!= NULL
) {
815 encryption
= CFDictionaryGetValue(config
, encryptionKey
);
817 if ((encryption
== NULL
) ||
818 (isA_CFString(encryption
) &&
819 CFEqual(encryption
, encryptionKeyChainValue
))) {
820 // remove keychain password
822 ok
= _SCPreferencesSystemKeychainPasswordItemRemove(prefs
, unique_id
);
824 ok
= _SCSecKeychainPasswordItemRemove(NULL
, unique_id
);
828 // as needed, check if we have an in-line password that we can remove
829 if (!ok
&& (encryption
== NULL
) && (config
!= NULL
)) {
830 CFDataRef inline_password
;
832 inline_password
= CFDictionaryGetValue(config
, passwordKey
);
833 inline_password
= __copy_legacy_password(inline_password
);
834 if (inline_password
!= NULL
) {
835 CFRelease(inline_password
);
840 if (newConfig
!= NULL
) {
841 if (ok
&& (config
!= NULL
)) {
842 CFMutableDictionaryRef temp
;
844 temp
= CFDictionaryCreateMutableCopy(NULL
, 0, config
);
845 CFDictionaryRemoveValue(temp
, passwordKey
);
846 CFDictionaryRemoveValue(temp
, encryptionKey
);
847 *newConfig
= (CFDictionaryRef
)temp
;
857 __private_extern__ Boolean
858 __rank_to_str(SCNetworkServicePrimaryRank rank
, CFStringRef
*rankStr
)
861 case kSCNetworkServicePrimaryRankDefault
:
864 case kSCNetworkServicePrimaryRankFirst
:
865 *rankStr
= kSCValNetServicePrimaryRankFirst
;
867 case kSCNetworkServicePrimaryRankLast
:
868 *rankStr
= kSCValNetServicePrimaryRankLast
;
870 case kSCNetworkServicePrimaryRankNever
:
871 *rankStr
= kSCValNetServicePrimaryRankNever
;
873 case kSCNetworkServicePrimaryRankScoped
:
874 *rankStr
= kSCValNetServicePrimaryRankScoped
;
884 __private_extern__ Boolean
885 __str_to_rank(CFStringRef rankStr
, SCNetworkServicePrimaryRank
*rank
)
887 if (isA_CFString(rankStr
)) {
888 if (CFEqual(rankStr
, kSCValNetServicePrimaryRankFirst
)) {
889 *rank
= kSCNetworkServicePrimaryRankFirst
;
890 } else if (CFEqual(rankStr
, kSCValNetServicePrimaryRankLast
)) {
891 *rank
= kSCNetworkServicePrimaryRankLast
;
892 } else if (CFEqual(rankStr
, kSCValNetServicePrimaryRankNever
)) {
893 *rank
= kSCNetworkServicePrimaryRankNever
;
894 } else if (CFEqual(rankStr
, kSCValNetServicePrimaryRankScoped
)) {
895 *rank
= kSCNetworkServicePrimaryRankScoped
;
899 } else if (rankStr
== NULL
) {
900 *rank
= kSCNetworkServicePrimaryRankDefault
;
909 #define kSCNetworkConfigurationFlagsBypassSystemInterfaces (1<<0)
910 #define kSCNetworkConfigurationFlagsBypassSystemInterfacesForced (1<<1)
914 _SCNetworkConfigurationBypassSystemInterfaces(SCPreferencesRef prefs
)
919 nc_flags
= __SCPreferencesGetNetworkConfigurationFlags(prefs
);
920 bypass
= ((nc_flags
& kSCNetworkConfigurationFlagsBypassSystemInterfaces
) != 0);
922 (nc_flags
& kSCNetworkConfigurationFlagsBypassSystemInterfacesForced
) != 0) {
923 // if bypass flag explicitly requested
927 if (!__SCPreferencesUsingDefaultPrefs(prefs
)) {
928 // if not using the default prefs (i.e. /L/P/SC/preferences.plist)
937 _SCNetworkConfigurationSetBypassSystemInterfaces(SCPreferencesRef prefs
, Boolean shouldBypass
)
941 nc_flags
= __SCPreferencesGetNetworkConfigurationFlags(prefs
);
943 nc_flags
|= kSCNetworkConfigurationFlagsBypassSystemInterfaces
;
945 nc_flags
&= ~kSCNetworkConfigurationFlagsBypassSystemInterfaces
;
947 nc_flags
|= kSCNetworkConfigurationFlagsBypassSystemInterfacesForced
;
948 __SCPreferencesSetNetworkConfigurationFlags(prefs
, nc_flags
);