From ba83da554b37c2706d3991e01798c6f0390ad20d Mon Sep 17 00:00:00 2001 From: Apple Date: Mon, 20 Feb 2006 21:45:42 +0000 Subject: [PATCH] configd-137.2.tar.gz --- Plugins/ATconfig/Info.plist | 2 +- Plugins/IPMonitor/Info.plist | 2 +- Plugins/IPMonitor/dns-configuration.c | 123 +-- Plugins/IPMonitor/ip_plugin.c | 12 +- Plugins/InterfaceNamer/Info.plist | 2 +- Plugins/KernelEventMonitor/Info.plist | 2 +- Plugins/Kicker/Info.plist | 2 +- Plugins/LinkConfiguration/Info.plist | 2 +- Plugins/PreferencesMonitor/Info.plist | 2 +- Plugins/PreferencesMonitor/prefsmon.c | 3 + SystemConfiguration.fproj/Info.plist | 6 +- .../NetworkConfiguration.plist | 55 +- SystemConfiguration.fproj/SCDOpen.c | 1 + SystemConfiguration.fproj/SCLocation.c | 2 + .../SCNetworkConfigurationInternal.c | 54 +- .../SCNetworkConfigurationInternal.h | 15 +- .../SCNetworkConnection.c | 4 + .../SCNetworkInterface.c | 705 +++++++----------- .../SCNetworkReachability.c | 18 +- SystemConfiguration.fproj/SCNetworkService.c | 84 +-- SystemConfiguration.fproj/SCPLock.c | 2 + SystemConfiguration.fproj/SCPPath.c | 123 +-- SystemConfiguration.fproj/SCProxies.c | 4 +- configd.tproj/plugin_support.c | 18 +- configd.xcode/project.pbxproj | 16 +- scutil.tproj/scutil.c | 1 + 26 files changed, 478 insertions(+), 782 deletions(-) diff --git a/Plugins/ATconfig/Info.plist b/Plugins/ATconfig/Info.plist index b7032f7..79a296b 100644 --- a/Plugins/ATconfig/Info.plist +++ b/Plugins/ATconfig/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType BNDL CFBundleShortVersionString - 1.8.3 + 1.8.5 CFBundleSignature ???? CFBundleVersion diff --git a/Plugins/IPMonitor/Info.plist b/Plugins/IPMonitor/Info.plist index eacab67..32df8de 100644 --- a/Plugins/IPMonitor/Info.plist +++ b/Plugins/IPMonitor/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType BNDL CFBundleShortVersionString - 1.8.3 + 1.8.5 CFBundleSignature ???? CFBundleVersion diff --git a/Plugins/IPMonitor/dns-configuration.c b/Plugins/IPMonitor/dns-configuration.c index d8ed304..bcbae5a 100644 --- a/Plugins/IPMonitor/dns-configuration.c +++ b/Plugins/IPMonitor/dns-configuration.c @@ -108,8 +108,6 @@ add_supplemental(CFMutableArrayRef supplemental, CFDictionaryRef dns, uint32_t d num = CFNumberCreate(NULL, kCFNumberIntType, &defaultOrder); CFDictionarySetValue(match_resolver, kSCPropNetDNSSearchOrder, num); CFRelease(num); - - defaultOrder++; // if multiple domains, maintain ordering } match_order = CFDictionaryGetValue(match_resolver, kSCPropNetDNSSearchOrder); @@ -293,42 +291,6 @@ compareBySearchOrder(const void *val1, const void *val2, void *context) } -static CFStringRef -trimDomain(CFStringRef domain) -{ - CFIndex length; - CFRange range; - Boolean trimmed = FALSE; - - if (!isA_CFString(domain)) { - return NULL; - } - - // remove trailing dots - length = CFStringGetLength(domain); - while (CFStringFindWithOptions(domain, - CFSTR("."), - CFRangeMake(0, length), - kCFCompareAnchored|kCFCompareBackwards, - &range)) { - trimmed = TRUE; - length = range.location; - } - - if (length == 0) { - return NULL; - } - - if (trimmed) { - domain = CFStringCreateWithSubstring(NULL, domain, CFRangeMake(0, length)); - } else { - CFRetain(domain); - } - - return domain; -} - - static void update_search_domains(CFMutableDictionaryRef *defaultDomain, CFArrayRef supplemental) { @@ -337,13 +299,13 @@ update_search_domains(CFMutableDictionaryRef *defaultDomain, CFArrayRef suppleme CFArrayRef defaultSearchDomains = NULL; CFIndex defaultSearchIndex = 0; CFIndex i; + CFIndex n; CFMutableArrayRef mySearchDomains; CFMutableArrayRef mySupplemental = (CFMutableArrayRef)supplemental; - CFIndex n_supplemental; Boolean searchDomainAdded = FALSE; - n_supplemental = CFArrayGetCount(supplemental); - if (n_supplemental == 0) { + n = CFArrayGetCount(supplemental); + if (n == 0) { // if no supplemental domains return; } @@ -361,36 +323,20 @@ update_search_domains(CFMutableDictionaryRef *defaultDomain, CFArrayRef suppleme defaultSearchDomains = CFDictionaryGetValue(*defaultDomain, kSCPropNetDNSSearchDomains); } - mySearchDomains = CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks); - if (isA_CFArray(defaultSearchDomains)) { - CFIndex n_search; - - n_search = CFArrayGetCount(defaultSearchDomains); - for (i = 0; i < n_search; i++) { - CFStringRef search; - - search = CFArrayGetValueAtIndex(defaultSearchDomains, i); - search = trimDomain(search); - if (search != NULL) { - CFArrayAppendValue(mySearchDomains, search); - CFRelease(search); - } - } + mySearchDomains = CFArrayCreateMutableCopy(NULL, 0, defaultSearchDomains); } else { - defaultDomainName = trimDomain(defaultDomainName); - if (defaultDomainName != NULL) { + mySearchDomains = CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks); + if (isA_CFString(defaultDomainName)) { char *domain; - int domain_parts = 1; - char *dp; + int domain_parts = 1; + char *dp; domain = _SC_cfstring_to_cstring(defaultDomainName, NULL, 0, kCFStringEncodingUTF8); - CFRelease(defaultDomainName); - // count domain parts for (dp = domain; *dp != '\0'; dp++) { if (*dp == '.') { domain_parts++; @@ -399,13 +345,13 @@ update_search_domains(CFMutableDictionaryRef *defaultDomain, CFArrayRef suppleme dp = domain; for (i = LOCALDOMAINPARTS; i <= domain_parts; i++) { - CFStringRef search; + CFStringRef searchDomain; - search = CFStringCreateWithCString(NULL, - dp, - kCFStringEncodingUTF8); - CFArrayAppendValue(mySearchDomains, search); - CFRelease(search); + searchDomain = CFStringCreateWithCString(NULL, + dp, + kCFStringEncodingUTF8); + CFArrayAppendValue(mySearchDomains, searchDomain); + CFRelease(searchDomain); dp = strchr(dp, '.') + 1; } @@ -414,17 +360,16 @@ update_search_domains(CFMutableDictionaryRef *defaultDomain, CFArrayRef suppleme } } - if (n_supplemental > 1) { + if (n > 1) { mySupplemental = CFArrayCreateMutableCopy(NULL, 0, supplemental); CFArraySortValues(mySupplemental, - CFRangeMake(0, n_supplemental), + CFRangeMake(0, n), compareBySearchOrder, NULL); } - for (i = 0; i < n_supplemental; i++) { + for (i = 0; i < n; i++) { CFDictionaryRef dns; - CFIndex domainIndex; CFNumberRef num; CFStringRef supplementalDomain; uint32_t supplementalOrder; @@ -432,21 +377,13 @@ update_search_domains(CFMutableDictionaryRef *defaultDomain, CFArrayRef suppleme dns = CFArrayGetValueAtIndex(mySupplemental, i); supplementalDomain = CFDictionaryGetValue(dns, kSCPropNetDNSDomainName); - supplementalDomain = trimDomain(supplementalDomain); - if (supplementalDomain == NULL) { + if (CFArrayContainsValue(mySearchDomains, + CFRangeMake(0, CFArrayGetCount(mySearchDomains)), + supplementalDomain)) { + // if supplemental domain is already in the search list continue; } - if (CFStringHasSuffix(supplementalDomain, CFSTR(".in-addr.arpa")) || - CFStringHasSuffix(supplementalDomain, CFSTR(".ip6.arpa" ))) { - CFRelease(supplementalDomain); - continue; - } - - domainIndex = CFArrayGetFirstIndexOfValue(mySearchDomains, - CFRangeMake(0, CFArrayGetCount(mySearchDomains)), - supplementalDomain); - num = CFDictionaryGetValue(dns, kSCPropNetDNSSearchOrder); if (!isA_CFNumber(num) || !CFNumberGetValue(num, kCFNumberIntType, &supplementalOrder)) { @@ -454,27 +391,15 @@ update_search_domains(CFMutableDictionaryRef *defaultDomain, CFArrayRef suppleme } if (supplementalOrder < defaultOrder) { - if (domainIndex != kCFNotFound) { - // if supplemental domain is already in the search list - CFArrayRemoveValueAtIndex(mySearchDomains, domainIndex); - if (domainIndex < defaultSearchIndex) { - defaultSearchIndex--; - } - } CFArrayInsertValueAtIndex(mySearchDomains, defaultSearchIndex, supplementalDomain); defaultSearchIndex++; - searchDomainAdded = TRUE; } else { - if (domainIndex == kCFNotFound) { - // add to the (end of the) search list - CFArrayAppendValue(mySearchDomains, supplementalDomain); - searchDomainAdded = TRUE; - } + CFArrayAppendValue(mySearchDomains, supplementalDomain); } - CFRelease(supplementalDomain); + searchDomainAdded = TRUE; } if (searchDomainAdded) { @@ -567,7 +492,7 @@ create_resolver(CFDictionaryRef dns) p = strchr(buf, '%'); if (p != NULL) { - addr.sin6.sin6_scope_id = if_nametoindex(p + 1); + addr.sin6.sin6_scope_id = if_nametoindex(p+1); } addr.sin6.sin6_len = sizeof(addr.sin6); diff --git a/Plugins/IPMonitor/ip_plugin.c b/Plugins/IPMonitor/ip_plugin.c index daa9065..8603a74 100644 --- a/Plugins/IPMonitor/ip_plugin.c +++ b/Plugins/IPMonitor/ip_plugin.c @@ -1697,16 +1697,20 @@ update_dnsinfo(CFStringRef primary, CFArrayRef service_order, keyChangeListRef k { CFDictionaryRef dict = NULL; - if (primary == NULL) { - dns_configuration_set(NULL, NULL, NULL); - } else { + if (primary != NULL) { CFDictionaryRef service_dict; service_dict = CFDictionaryGetValue(S_service_state_dict, primary); if (service_dict != NULL) { dict = CFDictionaryGetValue(service_dict, kSCEntNetDNS); } - + } + if (dict == NULL) { + /* update DNS configuration */ + dns_configuration_set(NULL, NULL, NULL); + } + else { + /* update DNS configuration */ dns_configuration_set(dict, S_service_state_dict, service_order); } keyChangeListNotifyKey(keys, S_notify_dnsinfo); diff --git a/Plugins/InterfaceNamer/Info.plist b/Plugins/InterfaceNamer/Info.plist index a65b992..31fdb04 100644 --- a/Plugins/InterfaceNamer/Info.plist +++ b/Plugins/InterfaceNamer/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType BNDL CFBundleShortVersionString - 1.8.3 + 1.8.5 CFBundleSignature ???? CFBundleVersion diff --git a/Plugins/KernelEventMonitor/Info.plist b/Plugins/KernelEventMonitor/Info.plist index d223f68..ce479f2 100644 --- a/Plugins/KernelEventMonitor/Info.plist +++ b/Plugins/KernelEventMonitor/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType BNDL CFBundleShortVersionString - 1.8.3 + 1.8.5 CFBundleSignature ???? CFBundleVersion diff --git a/Plugins/Kicker/Info.plist b/Plugins/Kicker/Info.plist index 17bf9e3..64d854e 100644 --- a/Plugins/Kicker/Info.plist +++ b/Plugins/Kicker/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType BNDL CFBundleShortVersionString - 1.8.3 + 1.8.5 CFBundleSignature ???? CFBundleVersion diff --git a/Plugins/LinkConfiguration/Info.plist b/Plugins/LinkConfiguration/Info.plist index f403d7d..8953675 100644 --- a/Plugins/LinkConfiguration/Info.plist +++ b/Plugins/LinkConfiguration/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType BNDL CFBundleShortVersionString - 1.8.3 + 1.8.5 CFBundleSignature ???? CFBundleVersion diff --git a/Plugins/PreferencesMonitor/Info.plist b/Plugins/PreferencesMonitor/Info.plist index 578b826..67b3375 100644 --- a/Plugins/PreferencesMonitor/Info.plist +++ b/Plugins/PreferencesMonitor/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType BNDL CFBundleShortVersionString - 1.8.3 + 1.8.5 CFBundleSignature ???? CFBundleVersion diff --git a/Plugins/PreferencesMonitor/prefsmon.c b/Plugins/PreferencesMonitor/prefsmon.c index 3d42d36..c961457 100644 --- a/Plugins/PreferencesMonitor/prefsmon.c +++ b/Plugins/PreferencesMonitor/prefsmon.c @@ -46,6 +46,8 @@ #include + + static SCPreferencesRef prefs = NULL; static SCDynamicStoreRef store = NULL; @@ -198,6 +200,7 @@ updateConfiguration(SCPreferencesRef prefs, CFMutableArrayRef patterns; CFDictionaryRef set = NULL; + if ((notificationType & kSCPreferencesNotificationApply) != kSCPreferencesNotificationApply) { return; } diff --git a/SystemConfiguration.fproj/Info.plist b/SystemConfiguration.fproj/Info.plist index 4f233ea..04a6369 100644 --- a/SystemConfiguration.fproj/Info.plist +++ b/SystemConfiguration.fproj/Info.plist @@ -7,7 +7,7 @@ CFBundleExecutable SystemConfiguration CFBundleGetInfoString - 1.8.3 + 1.8.5 CFBundleIdentifier com.apple.SystemConfiguration CFBundleInfoDictionaryVersion @@ -17,10 +17,10 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 1.8.3 + 1.8.5 CFBundleSignature ???? CFBundleVersion - 1.8.3 + 1.8.5 diff --git a/SystemConfiguration.fproj/NetworkConfiguration.plist b/SystemConfiguration.fproj/NetworkConfiguration.plist index 46a3254..a56f100 100644 --- a/SystemConfiguration.fproj/NetworkConfiguration.plist +++ b/SystemConfiguration.fproj/NetworkConfiguration.plist @@ -23,7 +23,7 @@ Modem ConnectionScript - Apple Internal 56K Modem (v.34) + Apple Internal 56K Modem (v.92) DataCompression 1 DialMode @@ -88,47 +88,6 @@ VerboseLogging 0 - PPP-IEEE80211 - - ACSPEnabled - 0 - CommDisplayTerminalWindow - 0 - CommRedialCount - 1 - CommRedialEnabled - 1 - CommRedialInterval - 5 - CommUseTerminalScript - 0 - DialOnDemand - 0 - DisconnectOnIdle - 0 - DisconnectOnIdleTimer - 1800 - DisconnectOnLogout - 1 - DisconnectOnSleep - 1 - IPCPCompressionVJ - 1 - IdleReminder - 0 - IdleReminderTimer - 1800 - LCPEchoEnabled - 1 - LCPEchoFailure - 4 - LCPEchoInterval - 10 - Logfile - /var/log/ppp.log - VerboseLogging - 0 - PPP-IrDA PPP-L2TP @@ -263,12 +222,7 @@ IEEE80211 AppleTalk - - ConfigMethod - Node - __INACTIVE__ - - + DNS IPv4 @@ -277,10 +231,7 @@ DHCP IPv6 - - ConfigMethod - Automatic - + Proxies FTPPassive diff --git a/SystemConfiguration.fproj/SCDOpen.c b/SystemConfiguration.fproj/SCDOpen.c index 77352f5..aa66c3e 100644 --- a/SystemConfiguration.fproj/SCDOpen.c +++ b/SystemConfiguration.fproj/SCDOpen.c @@ -246,6 +246,7 @@ __SCDynamicStoreCreatePrivate(CFAllocatorRef allocator, /* initialize runtime */ pthread_once(&initialized, __SCDynamicStoreInitialize); + /* allocate session */ size = sizeof(SCDynamicStorePrivate) - sizeof(CFRuntimeBase); storePrivate = (SCDynamicStorePrivateRef)_CFRuntimeCreateInstance(allocator, diff --git a/SystemConfiguration.fproj/SCLocation.c b/SystemConfiguration.fproj/SCLocation.c index 602ab54..bf049ce 100644 --- a/SystemConfiguration.fproj/SCLocation.c +++ b/SystemConfiguration.fproj/SCLocation.c @@ -32,6 +32,7 @@ #include #include + CFStringRef SCDynamicStoreKeyCreateLocation(CFAllocatorRef allocator) { @@ -77,6 +78,7 @@ SCDynamicStoreCopyLocation(SCDynamicStoreRef store) done : + if (tempSession) CFRelease(store); if (dict) CFRelease(dict); diff --git a/SystemConfiguration.fproj/SCNetworkConfigurationInternal.c b/SystemConfiguration.fproj/SCNetworkConfigurationInternal.c index 14266e6..d9f1579 100644 --- a/SystemConfiguration.fproj/SCNetworkConfigurationInternal.c +++ b/SystemConfiguration.fproj/SCNetworkConfigurationInternal.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004,2005 Apple Computer, Inc. All rights reserved. + * Copyright (c) 2004 Apple Computer, Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -72,20 +72,26 @@ __setPrefsConfiguration(SCPreferencesRef prefs, CFDictionaryRef config, Boolean keepInactive) { - CFMutableDictionaryRef newConfig; - Boolean ok; + CFMutableDictionaryRef newConfig = NULL; + Boolean ok = FALSE; - if (!isA_CFDictionary(config)) { - _SCErrorSet(kSCStatusInvalidArgument); - return FALSE; + if (config != NULL) { + if (!isA_CFDictionary(config)) { + _SCErrorSet(kSCStatusInvalidArgument); + return FALSE; + } + newConfig = CFDictionaryCreateMutableCopy(NULL, 0, config); + } else { + newConfig = CFDictionaryCreateMutable(NULL, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); } - newConfig = CFDictionaryCreateMutableCopy(NULL, 0, config); - if (keepInactive) { CFDictionaryRef curConfig; - // preserve enabled/disabled state + /* + * preserve enabled/disabled state + */ + curConfig = SCPreferencesPathGetValue(prefs, path); if (isA_CFDictionary(curConfig) && CFDictionaryContainsKey(curConfig, kSCResvInactive)) { // if currently disabled @@ -96,10 +102,22 @@ __setPrefsConfiguration(SCPreferencesRef prefs, } } - // set new configuration - ok = SCPreferencesPathSetValue(prefs, path, newConfig); + /* + * set new configuration + */ - CFRelease(newConfig); + if (CFDictionaryGetCount(newConfig) == 0) { + CFRelease(newConfig); + newConfig = NULL; + } + + if (newConfig == NULL) { + ok = SCPreferencesPathRemoveValue(prefs, path); + } else { + ok = SCPreferencesPathSetValue(prefs, path, newConfig); + } + + if (newConfig != NULL) CFRelease(newConfig); return ok; } @@ -127,7 +145,10 @@ __setPrefsEnabled(SCPreferencesRef prefs, CFMutableDictionaryRef newConfig = NULL; Boolean ok = FALSE; - // preserve current configuration + /* + * preserve current configuration + */ + curConfig = SCPreferencesPathGetValue(prefs, path); if (curConfig != NULL) { if (!isA_CFDictionary(curConfig)) { @@ -147,7 +168,10 @@ __setPrefsEnabled(SCPreferencesRef prefs, CFDictionarySetValue(newConfig, kSCResvInactive, kCFBooleanTrue); } - // update configuration + /* + * update configuration + */ + if (CFDictionaryGetCount(newConfig) == 0) { CFRelease(newConfig); newConfig = NULL; @@ -194,7 +218,7 @@ __copyTemplates() return NULL; } - // convert the XML data into a property list + /* convert the XML data into a property list */ templates = CFPropertyListCreateFromXMLData(NULL, xmlTemplates, kCFPropertyListImmutable, &xmlError); CFRelease(xmlTemplates); if (templates == NULL) { diff --git a/SystemConfiguration.fproj/SCNetworkConfigurationInternal.h b/SystemConfiguration.fproj/SCNetworkConfigurationInternal.h index 0a3f2dd..e0c981b 100644 --- a/SystemConfiguration.fproj/SCNetworkConfigurationInternal.h +++ b/SystemConfiguration.fproj/SCNetworkConfigurationInternal.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2005 Apple Computer, Inc. All rights reserved. + * Copyright (c) 2004 Apple Computer, Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -104,6 +104,7 @@ typedef struct { // [SCPreferences] interface entity information CFStringRef entity_device; // interface device + CFStringRef entity_hardware; // interface hardware CFStringRef entity_type; // interface type CFStringRef entity_subtype; // interface subtype @@ -116,8 +117,7 @@ typedef struct { Boolean builtin; CFStringRef location; CFStringRef path; - CFStringRef modemCCL; - Boolean modemIsV92; + Boolean supportsDeviceOnHold; Boolean supportsBond; Boolean supportsVLAN; @@ -156,9 +156,6 @@ __SCNetworkInterfaceCreatePrivate (CFAllocatorRef allocator, SCNetworkServiceRef service, io_string_t path); -CFDictionaryRef -__SCNetworkInterfaceCopyInterfaceEntity (SCNetworkInterfaceRef interface); - SCNetworkInterfaceRef __SCNetworkInterfaceCreateWithEntity (CFAllocatorRef allocator, CFDictionaryRef interface_entity, @@ -167,12 +164,6 @@ __SCNetworkInterfaceCreateWithEntity (CFAllocatorRef allocator, CFArrayRef __SCNetworkInterfaceCopyDeepConfiguration (SCNetworkInterfaceRef interface); -CFStringRef -__SCNetworkInterfaceGetModemCCL (SCNetworkInterfaceRef interface); - -Boolean -__SCNetworkInterfaceIsModemV92 (SCNetworkInterfaceRef interface); - Boolean __SCNetworkInterfaceSetConfiguration (SCNetworkInterfaceRef interface, CFDictionaryRef config, diff --git a/SystemConfiguration.fproj/SCNetworkConnection.c b/SystemConfiguration.fproj/SCNetworkConnection.c index eb67e80..88d9170 100644 --- a/SystemConfiguration.fproj/SCNetworkConnection.c +++ b/SystemConfiguration.fproj/SCNetworkConnection.c @@ -61,6 +61,7 @@ #include "pppcontroller.h" #include + /* ------------------------------------------------------------------------------------------- ------------------------------------------------------------------------------------------- */ @@ -415,6 +416,7 @@ SCNetworkConnectionCreateWithServiceID(CFAllocatorRef allocator, return NULL; } + connectionPrivate = __SCNetworkConnectionCreatePrivate(allocator, serviceID, callout, context); return (SCNetworkConnectionRef)connectionPrivate; @@ -983,6 +985,7 @@ SCNetworkConnectionCopyUserPreferences(CFDictionaryRef selectionOptions, Boolean success = FALSE; int status; + envdebug = getenv("PPPDebug"); if (envdebug) { if (sscanf(envdebug, "%d", &debug) != 1) @@ -1211,6 +1214,7 @@ SCNetworkConnectionPrivateCopyDefaultServiceIDForDial(SCDynamicStoreRef session, CFPropertyListRef lastServiceSelectedInIC = NULL; + // we found the service the user last had open in IC if (lastServiceSelectedInIC != NULL) { // make sure its a PPP service diff --git a/SystemConfiguration.fproj/SCNetworkInterface.c b/SystemConfiguration.fproj/SCNetworkInterface.c index 9943ed1..058a032 100644 --- a/SystemConfiguration.fproj/SCNetworkInterface.c +++ b/SystemConfiguration.fproj/SCNetworkInterface.c @@ -59,15 +59,10 @@ #include "SCNetworkConfiguration.h" #include "SCNetworkConfigurationInternal.h" -#include #include #include #include -#include -#include -#include #include -#include static CFStringRef __SCNetworkInterfaceCopyDescription (CFTypeRef cf); @@ -119,6 +114,7 @@ static SCNetworkInterfacePrivate __kSCNetworkInterfaceIPv4 = { NULL, // service NULL, // unsaved NULL, // entity_device + NULL, // entity_hardware NULL, // entity_type NULL, // entity_subtype NULL, // supported_interface_types @@ -127,8 +123,7 @@ static SCNetworkInterfacePrivate __kSCNetworkInterfaceIPv4 = { FALSE, // builtin NULL, // location NULL, // path - NULL, // modemCCL - FALSE, // modemIsV92 + FALSE, // supportsDeviceOnHold FALSE, // supportsBond FALSE, // supportsVLAN kSortUnknown // sort_order @@ -151,29 +146,28 @@ const SCNetworkInterfaceRef kSCNetworkInterfaceIPv4 = (SCNetworkInterfaceRef static const struct { const CFStringRef *interface_type; - const CFStringRef *entity_hardware; Boolean per_interface_config; uint32_t supported_interfaces; const CFStringRef *ppp_subtype; uint32_t supported_protocols; } configurations[] = { - // interface type entity_hardware if config? interface types PPP sub-type interface protocols - // ===================================== ================= ========== ======================= ======================================= ========================================= - { &kSCNetworkInterfaceType6to4 , &kSCEntNet6to4 , FALSE, doNone, NULL, doIPv6 }, - { &kSCNetworkInterfaceTypeBluetooth , &kSCEntNetModem , FALSE, doPPP, &kSCValNetInterfaceSubTypePPPSerial, doNone }, - { &kSCNetworkInterfaceTypeBond , &kSCEntNetEthernet, TRUE , doNone, NULL, doAppleTalk|doDNS|doIPv4|doIPv6|doProxies }, - { &kSCNetworkInterfaceTypeEthernet , &kSCEntNetEthernet, TRUE , doPPP, &kSCValNetInterfaceSubTypePPPoE, doAppleTalk|doDNS|doIPv4|doIPv6|doProxies }, - { &kSCNetworkInterfaceTypeFireWire , &kSCEntNetFireWire, TRUE , doNone, NULL, doDNS|doIPv4|doIPv6|doProxies }, - { &kSCNetworkInterfaceTypeIEEE80211 , &kSCEntNetAirPort , TRUE , doPPP, &kSCValNetInterfaceSubTypePPPoE, doAppleTalk|doDNS|doIPv4|doIPv6|doProxies }, - { &kSCNetworkInterfaceTypeIrDA , &kSCEntNetModem , FALSE, doPPP, &kSCValNetInterfaceSubTypePPPSerial, doNone }, - { &kSCNetworkInterfaceTypeL2TP , NULL , FALSE, doPPP, &kSCValNetInterfaceSubTypeL2TP, doNone }, - { &kSCNetworkInterfaceTypeModem , &kSCEntNetModem , FALSE, doPPP, &kSCValNetInterfaceSubTypePPPSerial, doNone }, - { &kSCNetworkInterfaceTypePPP , &kSCEntNetPPP , FALSE, doNone, NULL, doDNS|doIPv4|doIPv6|doProxies }, - { &kSCNetworkInterfaceTypePPTP , NULL , FALSE, doPPP, &kSCValNetInterfaceSubTypePPTP, doNone }, - { &kSCNetworkInterfaceTypeSerial , &kSCEntNetModem , FALSE, doPPP, &kSCValNetInterfaceSubTypePPPSerial, doNone }, - { &kSCNetworkInterfaceTypeVLAN , &kSCEntNetEthernet, TRUE , doNone, NULL, doAppleTalk|doDNS|doIPv4|doIPv6|doProxies }, - // ===================================== ================= ========== ======================= ======================================= ========================================= - { &kSCNetworkInterfaceTypeIPv4 , NULL , FALSE, do6to4|doL2TP|doPPTP, NULL, doNone } + // interface type if config? interface types PPP sub-type interface protocols + // ===================================== ========== ======================= ======================================= ========================================= + { &kSCNetworkInterfaceType6to4 , FALSE, doNone, NULL, doIPv6 }, + { &kSCNetworkInterfaceTypeBluetooth , FALSE, doPPP, &kSCValNetInterfaceSubTypePPPSerial, doNone }, + { &kSCNetworkInterfaceTypeBond , TRUE, doNone, NULL, doAppleTalk|doDNS|doIPv4|doIPv6|doProxies }, + { &kSCNetworkInterfaceTypeEthernet , TRUE, doPPP, &kSCValNetInterfaceSubTypePPPoE, doAppleTalk|doDNS|doIPv4|doIPv6|doProxies }, + { &kSCNetworkInterfaceTypeFireWire , TRUE, doNone, NULL, doDNS|doIPv4|doIPv6|doProxies }, + { &kSCNetworkInterfaceTypeIEEE80211 , TRUE, doPPP, &kSCValNetInterfaceSubTypePPPoE, doAppleTalk|doDNS|doIPv4|doIPv6|doProxies }, + { &kSCNetworkInterfaceTypeIrDA , FALSE, doPPP, &kSCValNetInterfaceSubTypePPPSerial, doNone }, + { &kSCNetworkInterfaceTypeL2TP , FALSE, doPPP, &kSCValNetInterfaceSubTypeL2TP, doNone }, + { &kSCNetworkInterfaceTypeModem , FALSE, doPPP, &kSCValNetInterfaceSubTypePPPSerial, doNone }, + { &kSCNetworkInterfaceTypePPP , FALSE, doNone, NULL, doDNS|doIPv4|doIPv6|doProxies }, + { &kSCNetworkInterfaceTypePPTP , FALSE, doPPP, &kSCValNetInterfaceSubTypePPTP, doNone }, + { &kSCNetworkInterfaceTypeSerial , FALSE, doPPP, &kSCValNetInterfaceSubTypePPPSerial, doNone }, + { &kSCNetworkInterfaceTypeVLAN , TRUE, doNone, NULL, doAppleTalk|doDNS|doIPv4|doIPv6|doProxies }, + // ===================================== ========== ======================= ======================================= ========================================= + { &kSCNetworkInterfaceTypeIPv4 , FALSE, do6to4|doPPTP|doL2TP, NULL, doNone } }; @@ -216,10 +210,12 @@ __SCNetworkInterfaceCopyDescription(CFTypeRef cf) SCNetworkInterfacePrivateRef interfacePrivate = (SCNetworkInterfacePrivateRef)cf; result = CFStringCreateMutable(allocator, 0); - CFStringAppendFormat(result, NULL, CFSTR(" {"), cf, allocator); + CFStringAppendFormat(result, NULL, CFSTR(" { "), cf, allocator); CFStringAppendFormat(result, NULL, CFSTR("type = %@"), interfacePrivate->interface_type); - CFStringAppendFormat(result, NULL, CFSTR(", entity_device = %@"), interfacePrivate->entity_device); - CFStringAppendFormat(result, NULL, CFSTR(", entity_type = %@"), interfacePrivate->entity_type); + CFStringAppendFormat(result, NULL, CFSTR(", entity = %@ / %@ / %@"), + interfacePrivate->entity_device, + interfacePrivate->entity_hardware, + interfacePrivate->entity_type); if (interfacePrivate->entity_subtype != NULL) { CFStringAppendFormat(result, NULL, CFSTR(" / %@"), interfacePrivate->entity_subtype); } @@ -243,23 +239,21 @@ __SCNetworkInterfaceCopyDescription(CFTypeRef cf) if (interfacePrivate->location != NULL) { CFStringAppendFormat(result, NULL, CFSTR(", location = %@"), interfacePrivate->location); } - if (interfacePrivate->path != NULL) { - CFStringAppendFormat(result, NULL, CFSTR(", path = %@"), interfacePrivate->path); - } - if (interfacePrivate->modemCCL != NULL) { - CFStringAppendFormat(result, NULL, CFSTR(", modemCCL = %@"), interfacePrivate->modemCCL); - } + CFStringAppendFormat(result, NULL, CFSTR(", path = %@"), interfacePrivate->path); CFStringAppendFormat(result, NULL, CFSTR(", order = %d"), interfacePrivate->sort_order); + if (interfacePrivate->service != NULL) { CFStringAppendFormat(result, NULL, CFSTR(", service=%@"), interfacePrivate->service); } + if (interfacePrivate->interface != NULL) { CFStringAppendFormat(result, NULL, CFSTR(", interface=%@"), interfacePrivate->interface); } + if (interfacePrivate->unsaved != NULL) { CFStringAppendFormat(result, NULL, CFSTR(", unsaved=%@"), interfacePrivate->unsaved); } - CFStringAppendFormat(result, NULL, CFSTR("}")); + CFStringAppendFormat(result, NULL, CFSTR(" }")); return result; } @@ -305,9 +299,6 @@ __SCNetworkInterfaceDeallocate(CFTypeRef cf) if (interfacePrivate->path != NULL) CFRelease(interfacePrivate->path); - if (interfacePrivate->modemCCL != NULL) - CFRelease(interfacePrivate->modemCCL); - return; } @@ -399,6 +390,7 @@ __SCNetworkInterfaceCreatePrivate(CFAllocatorRef allocator, interfacePrivate->service = service; interfacePrivate->unsaved = NULL; interfacePrivate->entity_device = NULL; + interfacePrivate->entity_hardware = NULL; interfacePrivate->entity_type = NULL; interfacePrivate->entity_subtype = NULL; interfacePrivate->supported_interface_types = NULL; @@ -408,8 +400,7 @@ __SCNetworkInterfaceCreatePrivate(CFAllocatorRef allocator, interfacePrivate->path = (path != NULL) ? CFStringCreateWithCString(NULL, path, kCFStringEncodingUTF8) : NULL; interfacePrivate->location = NULL; - interfacePrivate->modemCCL = NULL; - interfacePrivate->modemIsV92 = FALSE; + interfacePrivate->supportsDeviceOnHold = FALSE; interfacePrivate->supportsBond = FALSE; interfacePrivate->supportsVLAN = FALSE; interfacePrivate->sort_order = kSortUnknown; @@ -720,80 +711,77 @@ static CFStringRef pci_slot(io_registry_entry_t interface, CFTypeRef *pci_slot_name) { kern_return_t kr; - io_registry_entry_t parent; - CFMutableStringRef slot; - CFTypeRef slot_name; + io_registry_entry_t slot = interface; - slot = NULL; if (pci_slot_name != NULL) *pci_slot_name = NULL; - slot_name = IORegistryEntryCreateCFProperty(interface, CFSTR("AAPL,slot-name"), NULL, 0); - if (slot_name != NULL) { - CFIndex i; - - slot = CFStringCreateMutable(NULL, 0); - if (isA_CFString(slot_name)) { - if (pci_slot_name != NULL) *pci_slot_name = CFStringCreateCopy(NULL, slot_name); - CFStringAppend(slot, slot_name); - } else if (isA_CFData(slot_name)) { - if (pci_slot_name != NULL) *pci_slot_name = CFDataCreateCopy(NULL, slot_name); - CFStringAppendCString(slot, - (const char *)CFDataGetBytePtr(slot_name), - kCFStringEncodingUTF8); - } + while (slot != MACH_PORT_NULL) { + io_registry_entry_t parent; + CFTypeRef slot_name; + + slot_name = IORegistryEntryCreateCFProperty(slot, CFSTR("AAPL,slot-name"), NULL, 0); + if (slot_name != NULL) { + Boolean found; + + found = IOStringValueHasPrefix(slot_name, CFSTR("slot")); + if (found) { + CFIndex i; + CFMutableStringRef name; + + // if we found a slot # + name = CFStringCreateMutable(NULL, 0); + if (isA_CFString(slot_name)) { + if (pci_slot_name != NULL) *pci_slot_name = CFStringCreateCopy(NULL, slot_name); + CFStringAppend(name, slot_name); + } else if (isA_CFData(slot_name)) { + if (pci_slot_name != NULL) *pci_slot_name = CFDataCreateCopy(NULL, slot_name); + CFStringAppendCString(name, + (const char *)CFDataGetBytePtr(slot_name), + kCFStringEncodingUTF8); + } - if (CFStringGetLength(slot) > 5) { - (void) CFStringFindAndReplace(slot, - CFSTR("slot-"), - CFSTR(""), - CFRangeMake(0, 5), - kCFCompareCaseInsensitive|kCFCompareAnchored); - } + (void) CFStringFindAndReplace(name, + CFSTR("slot-"), + CFSTR(""), + CFRangeMake(0, 5), + kCFCompareCaseInsensitive|kCFCompareAnchored); + for (i = 0; i < sizeof(slot_mappings)/sizeof(slot_mappings[0]); i++) { + if (CFStringCompareWithOptions(name, + slot_mappings[i].name, + CFRangeMake(0, CFStringGetLength(slot_mappings[i].name)), + kCFCompareCaseInsensitive) == kCFCompareEqualTo) { + CFRelease(name); + name = (CFMutableStringRef)CFRetain(slot_mappings[i].slot); + break; + } + } - for (i = 0; i < sizeof(slot_mappings)/sizeof(slot_mappings[0]); i++) { - if (CFStringCompare(slot, - slot_mappings[i].name, - kCFCompareCaseInsensitive) == kCFCompareEqualTo) { - CFRelease(slot); - slot = (CFMutableStringRef)CFRetain(slot_mappings[i].slot); - break; + CFRelease(slot_name); + if (slot != interface) IOObjectRelease(slot); + return name; } - } - - CFRelease(slot_name); - } - - kr = IORegistryEntryGetParentEntry(interface, kIOServicePlane, &parent); - switch (kr) { - case kIOReturnSuccess : { - CFTypeRef parent_pci_slot_name = NULL; - CFStringRef parent_slot; - - parent_slot = pci_slot(parent, &parent_pci_slot_name); - if (parent_slot != NULL) { - if (slot != NULL) CFRelease(slot); - slot = (CFMutableStringRef)parent_slot; - if (pci_slot_name != NULL) { - if (*pci_slot_name != NULL) CFRelease(*pci_slot_name); - *pci_slot_name = parent_pci_slot_name; - } else { - CFRelease(parent_pci_slot_name); - } - } + CFRelease(slot_name); + } - IOObjectRelease(parent); - break; + kr = IORegistryEntryGetParentEntry(slot, kIOServicePlane, &parent); + if (slot != interface) IOObjectRelease(slot); + switch (kr) { + case kIOReturnSuccess : + slot = parent; + break; + case kIOReturnNoDevice : + // if we have hit the root node without finding a slot # + goto done; + default : + SCLog(TRUE, LOG_INFO, CFSTR("pci_slot IORegistryEntryGetParentEntry() failed, kr = 0x%x"), kr); + goto done; } - case kIOReturnNoDevice : - // if we have hit the root node - break; - default : - SCLog(TRUE, LOG_DEBUG, CFSTR("pci_slot IORegistryEntryGetParentEntry() failed, kr = 0x%x"), kr); - break; } - return slot; + done : + + return NULL; } @@ -849,7 +837,7 @@ pci_port(mach_port_t masterPort, CFTypeRef slot_name, CFStringRef bsdName) kr = IOServiceGetMatchingServices(masterPort, matching, &slot_iterator); if (kr != kIOReturnSuccess) { - SCLog(TRUE, LOG_DEBUG, CFSTR("pci_port IOServiceGetMatchingServices() failed, kr = 0x%x"), kr); + SCPrint(TRUE, stderr, CFSTR("IOServiceGetMatchingServices() failed, kr = 0x%x\n"), kr); return MACH_PORT_NULL; } @@ -864,7 +852,7 @@ pci_port(mach_port_t masterPort, CFTypeRef slot_name, CFStringRef bsdName) kIORegistryIterateRecursively, &child_iterator); if (kr != kIOReturnSuccess) { - SCLog(TRUE, LOG_DEBUG, CFSTR("pci_port IORegistryEntryCreateIterator() failed, kr = 0x%x"), kr); + SCPrint(TRUE, stderr, CFSTR("IORegistryEntryCreateIterator() failed, kr = 0x%x\n"), kr); return MACH_PORT_NULL; } @@ -934,16 +922,43 @@ pci_slot_info(mach_port_t masterPort, io_registry_entry_t interface, CFStringRef static Boolean isBuiltIn(io_registry_entry_t interface) { - CFStringRef slot; + kern_return_t kr; + io_registry_entry_t slot = interface; - slot = pci_slot(interface, NULL); - if (slot != NULL) { - // interfaces which have a "slot" are not built-in - CFRelease(slot); - return FALSE; + while (slot != MACH_PORT_NULL) { + io_registry_entry_t parent; + CFTypeRef slot_name; + + slot_name = IORegistryEntryCreateCFProperty(slot, CFSTR("AAPL,slot-name"), NULL, 0); + if (slot_name != NULL) { + Boolean found; + + found = IOStringValueHasPrefix(slot_name, CFSTR("slot")); + CFRelease(slot_name); + + if (found) { + // if we found a slot # then this is not a built-in interface + if (slot != interface) IOObjectRelease(slot); + return FALSE; + } + } + + kr = IORegistryEntryGetParentEntry(slot, kIOServicePlane, &parent); + if (slot != interface) IOObjectRelease(slot); + switch (kr) { + case kIOReturnSuccess : + slot = parent; + break; + case kIOReturnNoDevice : + // if we have hit the root node without finding a slot # + return TRUE; + default : + SCLog(TRUE, LOG_INFO, CFSTR("isBuiltIn IORegistryEntryGetParentEntry() failed, kr = 0x%x"), kr); + return FALSE; + } } - return TRUE; + return FALSE; } @@ -971,12 +986,16 @@ processNetworkInterface(mach_port_t masterPort, CFDictionaryRef bus_dict) { CFBooleanRef bVal; + io_name_t c_IOClass; + io_name_t c_IOName; + io_name_t i_IOClass; int ift = -1; int iVal; CFNumberRef num; CFStringRef str; - // interface type + // get the interface type + num = CFDictionaryGetValue(interface_dict, CFSTR(kIOInterfaceType)); if (!isA_CFNumber(num) || !CFNumberGetValue(num, kCFNumberIntType, &ift)) { @@ -988,21 +1007,35 @@ processNetworkInterface(mach_port_t masterPort, case IFT_ETHER : // Type, Hardware - if ((IOObjectConformsTo(controller, "IO80211Controller")) || - (IOObjectConformsTo(controller, "AirPortPCI" )) || - (IOObjectConformsTo(controller, "AirPortDriver" ))) { + if (IOObjectGetClass(interface, i_IOClass) != KERN_SUCCESS) { + i_IOClass[0] = '\0'; + } + if (IOObjectGetClass(controller, c_IOClass) != KERN_SUCCESS) { + c_IOClass[0] = '\0'; + } + if (IORegistryEntryGetName(controller, c_IOName) != KERN_SUCCESS) { + c_IOName[0] = '\0'; + } + + if ((strcmp(i_IOClass, "IO80211Interface" ) == 0) || + (strcmp(c_IOClass, "AirPortPCI" ) == 0) || + (strcmp(c_IOClass, "AirPortDriver" ) == 0) || + (strcmp(c_IOName , "AppleWireless80211") == 0)) { interfacePrivate->interface_type = kSCNetworkInterfaceTypeIEEE80211; interfacePrivate->entity_type = kSCEntNetEthernet; + interfacePrivate->entity_hardware = kSCEntNetAirPort; interfacePrivate->sort_order = kSortAirPort; } else { str = IODictionaryCopyCFStringValue(bus_dict, CFSTR("name")); if ((str != NULL) && CFEqual(str, CFSTR("radio"))) { interfacePrivate->interface_type = kSCNetworkInterfaceTypeEthernet; // ?? interfacePrivate->entity_type = kSCEntNetEthernet; + interfacePrivate->entity_hardware = kSCEntNetEthernet; // ?? interfacePrivate->sort_order = kSortOtherWireless; } else { interfacePrivate->interface_type = kSCNetworkInterfaceTypeEthernet; interfacePrivate->entity_type = kSCEntNetEthernet; + interfacePrivate->entity_hardware = kSCEntNetEthernet; interfacePrivate->sort_order = kSortEthernet; // BOND support only enabled for ethernet devices @@ -1091,6 +1124,7 @@ processNetworkInterface(mach_port_t masterPort, // Entity interfacePrivate->entity_type = kSCEntNetFireWire; + interfacePrivate->entity_hardware = kSCEntNetFireWire; // built-in interfacePrivate->builtin = isBuiltIn(interface); @@ -1113,7 +1147,7 @@ processNetworkInterface(mach_port_t masterPort, break; default : - SCLog(TRUE, LOG_DEBUG, CFSTR("processNetworkInterface() failed, unknown interface type = %d"), ift); + SCPrint(TRUE, stderr, CFSTR("Unknown interface type = %d\n"), ift); return FALSE; } @@ -1185,18 +1219,18 @@ processSerialInterface(mach_port_t masterPort, // Modem interfacePrivate->interface_type = kSCNetworkInterfaceTypeModem; - // V.92 support + // DeviceOnHold support val = IORegistryEntrySearchCFProperty(interface, kIOServicePlane, CFSTR(kIODeviceSupportsHoldKey), NULL, kIORegistryIterateRecursively | kIORegistryIterateParents); if (val != NULL) { - uint32_t v92; + uint32_t supportsHold; if (isA_CFNumber(val) && - CFNumberGetValue(val, kCFNumberSInt32Type, &v92)) { - interfacePrivate->modemIsV92 = (v92 == 1); + CFNumberGetValue(val, kCFNumberSInt32Type, &supportsHold)) { + interfacePrivate->supportsDeviceOnHold = (supportsHold == 1); } CFRelease(val); } @@ -1214,6 +1248,7 @@ processSerialInterface(mach_port_t masterPort, if (CFEqual(ift, CFSTR(kIOSerialBSDModemType))) { // if modem isModem = TRUE; + interfacePrivate->entity_hardware = kSCEntNetModem; if (CFEqual(str, CFSTR("modem"))) { interfacePrivate->builtin = TRUE; @@ -1225,6 +1260,7 @@ processSerialInterface(mach_port_t masterPort, } } else if (CFEqual(ift, CFSTR(kIOSerialBSDRS232Type))) { // if serial port + interfacePrivate->entity_hardware = kSCEntNetModem; interfacePrivate->sort_order = kSortSerialPort; } else { return FALSE; @@ -1233,24 +1269,13 @@ processSerialInterface(mach_port_t masterPort, // Entity (Device) interfacePrivate->entity_device = IODictionaryCopyCFStringValue(interface_dict, CFSTR(kIOTTYDeviceKey)); - // modem CCL - val = IORegistryEntrySearchCFProperty(interface, - kIOServicePlane, - CFSTR("ModemCCL"), - NULL, - kIORegistryIterateRecursively | kIORegistryIterateParents); - if (val != NULL) { - interfacePrivate->modemCCL = IOCopyCFStringValue(val); - CFRelease(val); - } - // localized name if (CFEqual(interfacePrivate->interface_type, kSCNetworkInterfaceTypeIrDA)) { interfacePrivate->localized_key = CFSTR("irda"); } else if (CFEqual(interfacePrivate->interface_type, kSCNetworkInterfaceTypeBluetooth)) { interfacePrivate->localized_key = CFSTR("bluetooth"); } else { - CFStringRef localized = NULL; + CFStringRef localized; CFMutableStringRef port; port = CFStringCreateMutableCopy(NULL, 0, str); @@ -1260,12 +1285,10 @@ processSerialInterface(mach_port_t masterPort, CFStringAppend(port, CFSTR("-port")); } - if (bundle != NULL) { - localized = CFBundleCopyLocalizedString(bundle, - port, - port, - NETWORKINTERFACE_LOCALIZATIONS); - } + localized = CFBundleCopyLocalizedString(bundle, + port, + port, + NETWORKINTERFACE_LOCALIZATIONS); if (localized != NULL) { if (!CFEqual(port, localized)) { // if localization available @@ -1297,14 +1320,7 @@ processSerialInterface(mach_port_t masterPort, // if we have a [somewhat reasonable?] product name CFRelease(interfacePrivate->localized_name); interfacePrivate->localized_name = CFRetain(productName); - - // if not provided, also check if the product name - // matches a CCL script - if (interfacePrivate->modemCCL == NULL) { - interfacePrivate->modemCCL = CFRetain(productName); - } } - CFRelease(productName); } } @@ -1313,55 +1329,6 @@ processSerialInterface(mach_port_t masterPort, CFRelease(port); } - // validate the CCL script - if (interfacePrivate->modemCCL != NULL) { - char ccl[MAXPATHLEN]; - char path[MAXPATHLEN]; - NSSearchPathEnumerationState state; - Boolean valid = FALSE; - - (void) _SC_cfstring_to_cstring(interfacePrivate->modemCCL, - ccl, - sizeof(ccl), - kCFStringEncodingUTF8); - - state = NSStartSearchPathEnumeration(NSLibraryDirectory, - NSLocalDomainMask|NSSystemDomainMask); - while ((state = NSGetNextSearchPathEnumeration(state, path))) { - struct stat statBuf; - - if (ccl[0] == '/') { - path[0] = '\0'; // if modemCCL is a full path - } else { - strlcat(path, "/Modem Scripts/", sizeof(path)); - strlcat(path, ccl, sizeof(path)); - } - - if (stat(path, &statBuf) == 0) { - if (S_ISREG(statBuf.st_mode)) { - // if we have a valid CCL script - valid = TRUE; - break; - } - } else { - if (errno == ENOENT) { - continue; - } - - SCLog(TRUE, LOG_DEBUG, - CFSTR("processSerialInterface stat() failed: %s"), - strerror(errno)); - break; - } - } - - if (!valid) { - // if the CCL script is not valid - CFRelease(interfacePrivate->modemCCL); - interfacePrivate->modemCCL = NULL; - } - } - return TRUE; } @@ -1376,7 +1343,7 @@ findMatchingInterfaces(mach_port_t masterPort, CFDictionaryRef matching, process kr = IOServiceGetMatchingServices(masterPort, matching, &iterator); if (kr != kIOReturnSuccess) { - SCLog(TRUE, LOG_DEBUG, CFSTR("findMatchingInterfaces IOServiceGetMatchingServices() failed, kr = 0x%x"), kr); + SCPrint(TRUE, stderr, CFSTR("IOServiceGetMatchingServices() failed, kr = 0x%x\n"), kr); return NULL; } @@ -1484,6 +1451,7 @@ SCNetworkInterfaceCreateWithBond(BondInterfaceRef bond) interfacePrivate->interface_type = kSCNetworkInterfaceTypeBond; interfacePrivate->entity_type = kSCEntNetEthernet; + interfacePrivate->entity_hardware = kSCEntNetEthernet; interfacePrivate->entity_device = CFStringCreateCopy(NULL, bond_if); interfacePrivate->builtin = TRUE; interfacePrivate->sort_order = kSortBond; @@ -1571,6 +1539,7 @@ SCNetworkInterfaceCreateWithVLAN(VLANInterfaceRef vlan) interfacePrivate->interface_type = kSCNetworkInterfaceTypeVLAN; interfacePrivate->entity_type = kSCEntNetEthernet; + interfacePrivate->entity_hardware = kSCEntNetEthernet; interfacePrivate->entity_device = CFStringCreateCopy(NULL, vlan_if); interfacePrivate->builtin = TRUE; interfacePrivate->sort_order = kSortVLAN; @@ -1638,185 +1607,7 @@ findVLANInterfaces(CFStringRef match) } -/* ---------- helper functions ---------- */ - - -static CFIndex -findConfiguration(CFStringRef interface_type) -{ - CFIndex i; - - for (i = 0; i < sizeof(configurations)/sizeof(configurations[0]); i++) { - if (CFEqual(interface_type, *configurations[i].interface_type)) { - return i; - } - } - - return kCFNotFound; -} - - -static CFArrayRef -copyConfigurationPaths(SCNetworkInterfacePrivateRef interfacePrivate) -{ - CFMutableArrayRef array = NULL; - CFIndex interfaceIndex; - CFStringRef path; - SCNetworkServicePrivateRef servicePrivate; - - servicePrivate = (SCNetworkServicePrivateRef)interfacePrivate->service; - if (servicePrivate == NULL) { - // if not associated with a service (yet) - return NULL; - } - - array = CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks); - - interfaceIndex = findConfiguration(interfacePrivate->interface_type); - if (interfaceIndex == kCFNotFound) { - // unknown interface type, use per-service configuration preferences - path = SCPreferencesPathKeyCreateNetworkServiceEntity(NULL, // allocator - servicePrivate->serviceID, // service - interfacePrivate->interface_type); // entity - CFArrayAppendValue(array, path); - CFRelease(path); - goto done; - } - - if (configurations[interfaceIndex].entity_hardware == NULL) { - // if no configuration information can be associated with this interface type - CFRelease(array); - array = NULL; - goto done; - } - - if (configurations[interfaceIndex].per_interface_config) { - CFIndex i; - CFIndex n; - CFArrayRef sets; - - // known interface type, per-interface configuration preferences - // - // 1. look for all sets which contain the associated service - // 2. add a per-set path for the interface configuration for - // each set. - - sets = SCNetworkSetCopyAll(servicePrivate->prefs); - n = (sets != NULL) ? CFArrayGetCount(sets) : 0; - - for (i = 0; i < n; i++) { - CFArrayRef services; - SCNetworkSetRef set; - - set = CFArrayGetValueAtIndex(sets, i); - services = SCNetworkSetCopyServices(set); - if (CFArrayContainsValue(services, - CFRangeMake(0, CFArrayGetCount(services)), - interfacePrivate->service)) { - path = SCPreferencesPathKeyCreateSetNetworkInterfaceEntity(NULL, // allocator - SCNetworkSetGetSetID(set), // set - interfacePrivate->entity_device, // service - *configurations[interfaceIndex].entity_hardware); // entity - CFArrayAppendValue(array, path); - CFRelease(path); - } - CFRelease(services); - } - - if (CFArrayGetCount(array) == 0) { - CFRelease(array); - array = NULL; - } - - if (sets != NULL) CFRelease(sets); - } else { - // known interface type, per-service configuration preferences - path = SCPreferencesPathKeyCreateNetworkServiceEntity(NULL, // allocator - servicePrivate->serviceID, // service - *configurations[interfaceIndex].entity_hardware); // entity - CFArrayAppendValue(array, path); - CFRelease(path); - } - - done : - - return array; -} - - -/* ---------- preferences entity for interface ---------- */ - - -__private_extern__ CFDictionaryRef -__SCNetworkInterfaceCopyInterfaceEntity(SCNetworkInterfaceRef interface) -{ - CFMutableDictionaryRef entity; - CFIndex interfaceIndex; - SCNetworkInterfacePrivateRef interfacePrivate = (SCNetworkInterfacePrivateRef)interface; - - entity = CFDictionaryCreateMutable(NULL, - 0, - &kCFTypeDictionaryKeyCallBacks, - &kCFTypeDictionaryValueCallBacks); - if (interfacePrivate->entity_type != NULL) { - CFDictionarySetValue(entity, - kSCPropNetInterfaceType, - interfacePrivate->entity_type); - } - if (interfacePrivate->entity_subtype != NULL) { - CFDictionarySetValue(entity, - kSCPropNetInterfaceSubType, - interfacePrivate->entity_subtype); - } - if (interfacePrivate->entity_device != NULL) { - CFDictionarySetValue(entity, - kSCPropNetInterfaceDeviceName, - interfacePrivate->entity_device); - } - - // match the "hardware" with the lowest layer - while (TRUE) { - SCNetworkInterfaceRef nextInterface; - - nextInterface = SCNetworkInterfaceGetInterface(interface); - if (nextInterface == NULL) { - break; - } - - interface = nextInterface; - } - interfacePrivate = (SCNetworkInterfacePrivateRef)interface; - - interfaceIndex = findConfiguration(interfacePrivate->interface_type); - if (interfaceIndex != kCFNotFound) { - if (configurations[interfaceIndex].entity_hardware != NULL) { - CFDictionarySetValue(entity, - kSCPropNetInterfaceHardware, - *configurations[interfaceIndex].entity_hardware); - } - } else { - CFDictionarySetValue(entity, - kSCPropNetInterfaceHardware, - interfacePrivate->interface_type); - } - - if (CFEqual(interfacePrivate->interface_type, kSCNetworkInterfaceTypeModem) && - interfacePrivate->modemIsV92) { - int one = 1; - CFNumberRef num; - - num = CFNumberCreate(NULL, kCFNumberIntType, &one); - CFDictionarySetValue(entity, - kSCPropNetInterfaceSupportsModemOnHold, - num); - CFRelease(num); - } - - return entity; -} - - -/* ---------- interface from preferences entity ---------- */ +/* ---------- interface from preferences ---------- */ __private_extern__ SCNetworkInterfaceRef @@ -1831,9 +1622,6 @@ __SCNetworkInterfaceCreateWithEntity(CFAllocatorRef allocator, static mach_port_t masterPort = MACH_PORT_NULL; CFArrayRef matching_interfaces = NULL; - /* initialize runtime (and kSCNetworkInterfaceIPv4) */ - pthread_once(&initialized, __SCNetworkInterfaceInitialize); - if (masterPort == MACH_PORT_NULL) { kern_return_t kr; @@ -1923,9 +1711,6 @@ __SCNetworkInterfaceCreateWithEntity(CFAllocatorRef allocator, interfacePrivate = (SCNetworkInterfacePrivateRef)SCNetworkInterfaceCreateWithInterface(kSCNetworkInterfaceIPv4, kSCNetworkInterfaceType6to4); - } else if (CFStringFind(ifType, CFSTR("."), 0).location != kCFNotFound) { - interfacePrivate = (SCNetworkInterfacePrivateRef)SCNetworkInterfaceCreateWithInterface(kSCNetworkInterfaceIPv4, - ifType); } if (matching_interfaces != NULL) { @@ -1964,7 +1749,7 @@ __SCNetworkInterfaceCreateWithEntity(CFAllocatorRef allocator, CFRetain(interfacePrivate); break; default : - SCLog(TRUE, LOG_DEBUG, CFSTR("__SCNetworkInterfaceCreateWithEntity() failed, more than one interface matches %@"), ifDevice); + SCPrint(TRUE, stderr, CFSTR("more than one interface matches %@\n"), ifDevice); if (matching_interfaces != NULL) CFRelease(matching_interfaces); _SCErrorSet(kSCStatusFailed); return NULL; @@ -1975,8 +1760,6 @@ __SCNetworkInterfaceCreateWithEntity(CFAllocatorRef allocator, done : if (interfacePrivate == NULL) { - CFStringRef entity_hardware; - /* * if device not present on this system */ @@ -1984,11 +1767,11 @@ __SCNetworkInterfaceCreateWithEntity(CFAllocatorRef allocator, interfacePrivate->entity_type = ifType; interfacePrivate->entity_subtype = ifSubType; interfacePrivate->entity_device = (ifDevice != NULL) ? CFStringCreateCopy(NULL, ifDevice) : NULL; + interfacePrivate->entity_hardware = CFDictionaryGetValue(interface_entity, kSCPropNetInterfaceHardware); - entity_hardware = CFDictionaryGetValue(interface_entity, kSCPropNetInterfaceHardware); if (CFEqual(ifType, kSCValNetInterfaceTypeEthernet)) { - if ((entity_hardware != NULL) && - CFEqual(entity_hardware, kSCEntNetAirPort)) { + if ((interfacePrivate->entity_hardware != NULL) && + CFEqual(interfacePrivate->entity_hardware, kSCEntNetAirPort)) { interfacePrivate->interface_type = kSCNetworkInterfaceTypeIEEE80211; } else { interfacePrivate->interface_type = kSCNetworkInterfaceTypeEthernet; @@ -2036,6 +1819,100 @@ __SCNetworkInterfaceCreateWithEntity(CFAllocatorRef allocator, } +/* ---------- helper functions ---------- */ + + +static CFIndex +findConfiguration(CFStringRef interface_type) +{ + CFIndex i; + + for (i = 0; i < sizeof(configurations)/sizeof(configurations[0]); i++) { + if (CFEqual(interface_type, *configurations[i].interface_type)) { + return i; + } + } + + return kCFNotFound; +} + + +static CFArrayRef +copyConfigurationPaths(SCNetworkInterfacePrivateRef interfacePrivate) +{ + CFMutableArrayRef array = NULL; + CFIndex interfaceIndex; + CFStringRef path; + SCNetworkServicePrivateRef servicePrivate; + + interfaceIndex = findConfiguration(interfacePrivate->interface_type); + if (interfaceIndex == kCFNotFound) { + // if unknown interface type + return NULL; + } + + servicePrivate = (SCNetworkServicePrivateRef)interfacePrivate->service; + if (servicePrivate == NULL) { + // if not associated with a service (yet) + return NULL; + } + + array = CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks); + + if (configurations[interfaceIndex].per_interface_config) { + CFIndex i; + CFIndex n; + CFArrayRef sets; + + /* + * per-interface configuration preferences + * + * 1. look for all sets which contain the associated service + * 2. add a per-set path for the interface configuration for + * each set. + */ + + sets = SCNetworkSetCopyAll(servicePrivate->prefs); + n = (sets != NULL) ? CFArrayGetCount(sets) : 0; + + for (i = 0; i < n; i++) { + CFArrayRef services; + SCNetworkSetRef set; + + set = CFArrayGetValueAtIndex(sets, i); + services = SCNetworkSetCopyServices(set); + if (CFArrayContainsValue(services, + CFRangeMake(0, CFArrayGetCount(services)), + interfacePrivate->service)) { + path = SCPreferencesPathKeyCreateSetNetworkInterfaceEntity(NULL, // allocator + SCNetworkSetGetSetID(set), // set + interfacePrivate->entity_device, // service + interfacePrivate->entity_type); // entity + CFArrayAppendValue(array, path); + CFRelease(path); + } + CFRelease(services); + } + + if (CFArrayGetCount(array) == 0) { + CFRelease(array); + array = NULL; + } + + CFRelease(sets); + } else { + // per-service configuration preferences + path = SCPreferencesPathKeyCreateNetworkServiceEntity(NULL, // allocator + servicePrivate->serviceID, // service + interfacePrivate->entity_type); // entity + CFArrayAppendValue(array, path); + CFRelease(path); + } + + return array; +} + + /* ---------- SCNetworkInterface APIs ---------- */ @@ -2133,13 +2010,13 @@ SCNetworkInterfaceGetSupportedInterfaceTypes(SCNetworkInterfaceRef interface) CFIndex i; SCNetworkInterfacePrivateRef interfacePrivate = (SCNetworkInterfacePrivateRef)interface; - /* initialize runtime (and kSCNetworkInterfaceIPv4) */ - pthread_once(&initialized, __SCNetworkInterfaceInitialize); - if (interfacePrivate->supported_interface_types != NULL) { goto done; } + /* initialize runtime (and kSCNetworkInterfaceIPv4) */ + pthread_once(&initialized, __SCNetworkInterfaceInitialize); + i = findConfiguration(interfacePrivate->interface_type); if (i != kCFNotFound) { if (configurations[i].supported_interfaces != doNone) { @@ -2171,13 +2048,13 @@ SCNetworkInterfaceGetSupportedProtocolTypes(SCNetworkInterfaceRef interface) CFIndex i; SCNetworkInterfacePrivateRef interfacePrivate = (SCNetworkInterfacePrivateRef)interface; - /* initialize runtime (and kSCNetworkInterfaceIPv4) */ - pthread_once(&initialized, __SCNetworkInterfaceInitialize); - if (interfacePrivate->supported_protocol_types != NULL) { goto done; } + /* initialize runtime (and kSCNetworkInterfaceIPv4) */ + pthread_once(&initialized, __SCNetworkInterfaceInitialize); + i = findConfiguration(interfacePrivate->interface_type); if (i != kCFNotFound) { if (configurations[i].supported_protocols != doNone) { @@ -2270,17 +2147,13 @@ SCNetworkInterfaceCreateWithInterface(SCNetworkInterfaceRef child, CFStringRef i parentPrivate->interface_type = kSCNetworkInterfaceType6to4; parentPrivate->entity_type = kSCEntNet6to4; parentPrivate->entity_device = CFRetain(CFSTR("stf0")); - } else if (CFStringFind(interfaceType, CFSTR("."), 0).location != kCFNotFound) { - // if custom interface type - parentPrivate->interface_type = interfaceType; - parentPrivate->entity_type = interfaceType; // interface config goes into a - // a dictionary with the same - // name as the interfaceType + CFRetain(parentPrivate->entity_device); } else { // unknown interface type goto fail; } + parentPrivate->entity_hardware = childPrivate->entity_hardware; parentPrivate->sort_order = childPrivate->sort_order; return (SCNetworkInterfaceRef)parentPrivate; @@ -2348,7 +2221,6 @@ SCNetworkInterfaceGetHardwareAddressString(SCNetworkInterfaceRef interface) return interfacePrivate->address; } - SCNetworkInterfaceRef SCNetworkInterfaceGetInterface(SCNetworkInterfaceRef interface) { @@ -2379,11 +2251,13 @@ SCNetworkInterfaceGetLocalizedDisplayName(SCNetworkInterfaceRef interface) CFStringRef child = NULL; CFMutableStringRef local = NULL; + pthread_once(&initialized, __SCNetworkInterfaceInitialize); /* initialize runtime */ + if (interfacePrivate->interface != NULL) { child = SCNetworkInterfaceGetLocalizedDisplayName(interfacePrivate->interface); } - if ((bundle != NULL) && (interfacePrivate->localized_key != NULL)) { + if (interfacePrivate->localized_key != NULL) { CFStringRef fmt; fmt = CFBundleCopyLocalizedString(bundle, @@ -2429,26 +2303,6 @@ SCNetworkInterfaceGetLocalizedDisplayName(SCNetworkInterfaceRef interface) } -__private_extern__ -CFStringRef -__SCNetworkInterfaceGetModemCCL(SCNetworkInterfaceRef interface) -{ - SCNetworkInterfacePrivateRef interfacePrivate = (SCNetworkInterfacePrivateRef)interface; - - return interfacePrivate->modemCCL; -} - - -__private_extern__ -Boolean -__SCNetworkInterfaceIsModemV92(SCNetworkInterfaceRef interface) -{ - SCNetworkInterfacePrivateRef interfacePrivate = (SCNetworkInterfacePrivateRef)interface; - - return interfacePrivate->modemIsV92; -} - - CFTypeID SCNetworkInterfaceGetTypeID(void) { @@ -2518,11 +2372,8 @@ __SCNetworkInterfaceCreateCopy(CFAllocatorRef allocator, SCNetworkInterfacePrivateRef oldPrivate = (SCNetworkInterfacePrivateRef)interface; SCNetworkInterfacePrivateRef newPrivate; - /* initialize runtime (and kSCNetworkInterfaceIPv4) */ - pthread_once(&initialized, __SCNetworkInterfaceInitialize); - newPrivate = __SCNetworkInterfaceCreatePrivate(NULL, NULL, NULL, NULL); - newPrivate->interface_type = oldPrivate->interface_type; + newPrivate->interface_type = CFRetain(oldPrivate->interface_type); if (oldPrivate->interface != NULL) { newPrivate->interface = (SCNetworkInterfaceRef)__SCNetworkInterfaceCreateCopy(NULL, // allocator oldPrivate->interface, // interface @@ -2532,6 +2383,7 @@ __SCNetworkInterfaceCreateCopy(CFAllocatorRef allocator, newPrivate->service = service; newPrivate->unsaved = (oldPrivate->unsaved != NULL) ? CFRetain(oldPrivate->unsaved) : NULL; newPrivate->entity_device = (oldPrivate->entity_device != NULL) ? CFRetain(oldPrivate->entity_device) : NULL; + newPrivate->entity_hardware = CFRetain(oldPrivate->entity_hardware); newPrivate->entity_type = oldPrivate->entity_type; newPrivate->entity_subtype = oldPrivate->entity_subtype; if (oldPrivate->supported_interface_types != NULL) { @@ -2544,8 +2396,7 @@ __SCNetworkInterfaceCreateCopy(CFAllocatorRef allocator, newPrivate->builtin = oldPrivate->builtin; newPrivate->path = (oldPrivate->path != NULL) ? CFRetain(oldPrivate->path) : NULL; newPrivate->location = (oldPrivate->location != NULL) ? CFRetain(oldPrivate->location) : NULL; - newPrivate->modemCCL = (oldPrivate->modemCCL != NULL) ? CFRetain(oldPrivate->modemCCL) : NULL; - newPrivate->modemIsV92 = oldPrivate->modemIsV92; + newPrivate->supportsDeviceOnHold = oldPrivate->supportsDeviceOnHold; newPrivate->supportsBond = oldPrivate->supportsBond; newPrivate->supportsVLAN = oldPrivate->supportsVLAN; newPrivate->sort_order = oldPrivate->sort_order; diff --git a/SystemConfiguration.fproj/SCNetworkReachability.c b/SystemConfiguration.fproj/SCNetworkReachability.c index 038c61b..f28d6f3 100644 --- a/SystemConfiguration.fproj/SCNetworkReachability.c +++ b/SystemConfiguration.fproj/SCNetworkReachability.c @@ -61,6 +61,8 @@ #include + + #define kSCNetworkFlagsFirstResolvePending (1<<31) @@ -1696,26 +1698,14 @@ _SC_checkResolverReachability(SCDynamicStoreRef *storeP, } } else if (default_resolver->domain != NULL) { char *dp; - int domain_parts = 0; + int domain_parts = 1; - // count domain parts for (dp = default_resolver->domain; *dp != '\0'; dp++) { if (*dp == '.') { domain_parts++; } } - // remove trailing dots - for (dp--; (dp >= default_resolver->domain) && (*dp == '.'); dp--) { - *dp = '\0'; - domain_parts--; - } - - if (dp >= default_resolver->domain) { - // dots are separators, bump # of components - domain_parts++; - } - dp = default_resolver->domain; for (i = LOCALDOMAINPARTS; !found && (i <= domain_parts); i++) { int ret; @@ -2069,6 +2059,7 @@ SCNetworkReachabilityGetFlags(SCNetworkReachabilityRef target, return TRUE; } + ok = __SCNetworkReachabilityGetFlags(&store, target, flags, NULL, FALSE); *flags &= ~kSCNetworkFlagsFirstResolvePending; if (store != NULL) CFRelease(store); @@ -2282,6 +2273,7 @@ rlsPerform(void *info) SCLog(_sc_debug, LOG_DEBUG, CFSTR("process reachability change")); + pthread_mutex_lock(&targetPrivate->lock); /* update reachability, notify if status changed */ diff --git a/SystemConfiguration.fproj/SCNetworkService.c b/SystemConfiguration.fproj/SCNetworkService.c index 5a88d53..db30ae7 100644 --- a/SystemConfiguration.fproj/SCNetworkService.c +++ b/SystemConfiguration.fproj/SCNetworkService.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2005 Apple Computer, Inc. All rights reserved. + * Copyright (c) 2004 Apple Computer, Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -478,7 +478,8 @@ static Boolean __SCNetworkServiceSetInterfaceEntity(SCNetworkServiceRef service, SCNetworkInterfaceRef interface) { - CFDictionaryRef entity; + CFMutableDictionaryRef entity; + SCNetworkInterfacePrivateRef interfacePrivate = (SCNetworkInterfacePrivateRef)interface; Boolean ok; CFStringRef path; SCNetworkServicePrivateRef servicePrivate = (SCNetworkServicePrivateRef)service; @@ -486,7 +487,41 @@ __SCNetworkServiceSetInterfaceEntity(SCNetworkServiceRef service, path = SCPreferencesPathKeyCreateNetworkServiceEntity(NULL, // allocator servicePrivate->serviceID, // service kSCEntNetInterface); // entity - entity = __SCNetworkInterfaceCopyInterfaceEntity(interface); + entity = CFDictionaryCreateMutable(NULL, + 0, + &kCFTypeDictionaryKeyCallBacks, + &kCFTypeDictionaryValueCallBacks); + if (interfacePrivate->entity_type != NULL) { + CFDictionarySetValue(entity, + kSCPropNetInterfaceType, + interfacePrivate->entity_type); + } + if (interfacePrivate->entity_subtype != NULL) { + CFDictionarySetValue(entity, + kSCPropNetInterfaceSubType, + interfacePrivate->entity_subtype); + } + if (interfacePrivate->entity_device != NULL) { + CFDictionarySetValue(entity, + kSCPropNetInterfaceDeviceName, + interfacePrivate->entity_device); + } + if (interfacePrivate->entity_hardware != NULL) { + CFDictionarySetValue(entity, + kSCPropNetInterfaceHardware, + interfacePrivate->entity_hardware); + } + if (CFEqual(interfacePrivate->interface_type, kSCNetworkInterfaceTypeModem) && + interfacePrivate->supportsDeviceOnHold) { + int one = 1; + CFNumberRef num; + + num = CFNumberCreate(NULL, kCFNumberIntType, &one); + CFDictionarySetValue(entity, + kSCPropNetInterfaceSupportsModemOnHold, + num); + CFRelease(num); + } ok = SCPreferencesPathSetValue(servicePrivate->prefs, path, entity); CFRelease(entity); CFRelease(path); @@ -505,20 +540,6 @@ SCNetworkServiceCreate(SCPreferencesRef prefs, SCNetworkInterfaceRef interface) CFStringRef prefix; CFStringRef serviceID; SCNetworkServicePrivateRef servicePrivate; - CFArrayRef supported_protocols; - - // only allow network interfaces which support one or more protocols - // to be added to a service. The one exception is that we allow - // third-party interface types to be configured. - supported_protocols = SCNetworkInterfaceGetSupportedProtocolTypes(interface); - if (supported_protocols == NULL) { - CFStringRef interface_type; - - interface_type = SCNetworkInterfaceGetInterfaceType(interface); - if (CFStringFind(interface_type, CFSTR("."), 0).location == kCFNotFound) { - return NULL; - } - } // establish the service prefix = SCPreferencesPathKeyCreateNetworkServices(NULL); @@ -551,35 +572,13 @@ SCNetworkServiceCreate(SCPreferencesRef prefs, SCNetworkInterfaceRef interface) CFStringRef interfaceType; interfaceType = SCNetworkInterfaceGetInterfaceType(interface); - childInterface = SCNetworkInterfaceGetInterface(interface); + childInterface = SCNetworkInterfaceGetInterface(servicePrivate->interface); if (childInterface != NULL) { childInterfaceType = SCNetworkInterfaceGetInterfaceType(childInterface); } config = __copyInterfaceTemplate(interfaceType, childInterfaceType); if (config != NULL) { - if (CFEqual(interfaceType, kSCNetworkInterfaceTypeModem) || - CFEqual(interfaceType, kSCNetworkInterfaceTypeSerial)) { - CFStringRef modemCCL; - - modemCCL = __SCNetworkInterfaceGetModemCCL(interface); - if (modemCCL == NULL) { - if (__SCNetworkInterfaceIsModemV92(interface)) { - modemCCL = CFSTR("Apple Internal 56K Modem (v.92)"); - } - } - - if (modemCCL != NULL) { - CFMutableDictionaryRef newConfig; - - newConfig = CFDictionaryCreateMutableCopy(NULL, 0, config); - CFDictionarySetValue(newConfig, kSCPropNetModemConnectionScript, modemCCL); - - CFRelease(config); - config = newConfig; - } - } - (void) __SCNetworkInterfaceSetConfiguration(interface, config, TRUE); CFRelease(config); } @@ -589,7 +588,7 @@ SCNetworkServiceCreate(SCPreferencesRef prefs, SCNetworkInterfaceRef interface) (void) __SCNetworkServiceSetInterfaceEntity((SCNetworkServiceRef)servicePrivate, servicePrivate->interface); - // push the [deep] interface configuration into the service. + // push the [deep] interface configuration into into the service. interface_config = __SCNetworkInterfaceCopyDeepConfiguration(servicePrivate->interface); __SCNetworkInterfaceSetDeepConfiguration(servicePrivate->interface, interface_config); @@ -699,8 +698,7 @@ SCNetworkServiceRemove(SCNetworkServiceRef service) set = CFArrayGetValueAtIndex(sets, i); ok = SCNetworkSetRemoveService(set, service); if (!ok && (SCError() != kSCStatusNoKey)) { - CFRelease(sets); - return ok; + break; } } CFRelease(sets); diff --git a/SystemConfiguration.fproj/SCPLock.c b/SystemConfiguration.fproj/SCPLock.c index f7b1551..7b7af2c 100644 --- a/SystemConfiguration.fproj/SCPLock.c +++ b/SystemConfiguration.fproj/SCPLock.c @@ -40,6 +40,7 @@ #include #include + Boolean SCPreferencesLock(SCPreferencesRef prefs, Boolean wait) { @@ -71,6 +72,7 @@ SCPreferencesLock(SCPreferencesRef prefs, Boolean wait) } } + pthread_mutex_lock(&prefsPrivate->lock); if (prefsPrivate->session == NULL) { diff --git a/SystemConfiguration.fproj/SCPPath.c b/SystemConfiguration.fproj/SCPPath.c index dce62a0..ef817dd 100644 --- a/SystemConfiguration.fproj/SCPPath.c +++ b/SystemConfiguration.fproj/SCPPath.c @@ -60,13 +60,18 @@ normalizePath(CFStringRef path) for (i = nElements; i > 0; i--) { CFStringRef pathElement; - pathElement = CFArrayGetValueAtIndex(elements, i - 1); + pathElement = CFArrayGetValueAtIndex(elements, i-1); if (CFStringGetLength(pathElement) == 0) { - CFArrayRemoveValueAtIndex(elements, i - 1); + CFArrayRemoveValueAtIndex(elements, i-1); nElements--; } } + if (nElements < 1) { + CFRelease(elements); + return NULL; + } + return elements; } @@ -81,6 +86,7 @@ getPath(SCPreferencesRef prefs, CFStringRef path, CFDictionaryRef *entity) CFIndex nElements; CFIndex nLinks = 0; Boolean ok = FALSE; + SCPreferencesPrivateRef prefsPrivate = (SCPreferencesPrivateRef)prefs; CFDictionaryRef value = NULL; elements = normalizePath(path); @@ -89,21 +95,16 @@ getPath(SCPreferencesRef prefs, CFStringRef path, CFDictionaryRef *entity) return FALSE; } + __SCPreferencesAccess(prefs); + restart : nElements = CFArrayGetCount(elements); - - if (nElements < 1) { - SCPreferencesPrivateRef prefsPrivate = (SCPreferencesPrivateRef)prefs; - - __SCPreferencesAccess(prefs); - value = prefsPrivate->prefs; - } - for (i = 0; i < nElements; i++) { element = CFArrayGetValueAtIndex(elements, i); if (i == 0) { - value = SCPreferencesGetValue(prefs, CFArrayGetValueAtIndex(elements, 0)); + value = CFDictionaryGetValue(prefsPrivate->prefs, + CFArrayGetValueAtIndex(elements, 0)); } else { value = CFDictionaryGetValue(value, element); } @@ -119,7 +120,7 @@ getPath(SCPreferencesRef prefs, CFStringRef path, CFDictionaryRef *entity) goto done; } - if ((i < nElements - 1) && + if ((i < nElements-1) && CFDictionaryGetValueIfPresent(value, kSCResvLink, (const void **)&link)) { /* * if not the last path component and this @@ -144,7 +145,7 @@ getPath(SCPreferencesRef prefs, CFStringRef path, CFDictionaryRef *entity) newElements = CFArrayCreateMutableCopy(NULL, 0, linkElements); CFArrayAppendArray(newElements, elements, - CFRangeMake(i + 1, nElements-i - 1)); + CFRangeMake(i+1, nElements-i-1)); CFRelease(elements); elements = newElements; @@ -173,13 +174,9 @@ setPath(SCPreferencesRef prefs, CFStringRef path, CFDictionaryRef entity) CFIndex nLinks = 0; CFDictionaryRef newEntity = NULL; CFDictionaryRef node = NULL; - CFMutableArrayRef nodes = NULL; + CFMutableArrayRef nodes; Boolean ok = FALSE; - - if ((entity != NULL) && !isA_CFDictionary(entity)) { - _SCErrorSet(kSCStatusInvalidArgument); - return FALSE; - } + SCPreferencesPrivateRef prefsPrivate = (SCPreferencesPrivateRef)prefs; elements = normalizePath(path); if (elements == NULL) { @@ -187,38 +184,16 @@ setPath(SCPreferencesRef prefs, CFStringRef path, CFDictionaryRef entity) return FALSE; } + __SCPreferencesAccess(prefs); + restart : nElements = CFArrayGetCount(elements); - - if (nElements < 1) { - SCPreferencesPrivateRef prefsPrivate = (SCPreferencesPrivateRef)prefs; - - __SCPreferencesAccess(prefs); - - if (prefsPrivate->prefs != NULL) { - CFRelease(prefsPrivate->prefs); - } - - if (entity == NULL) { - prefsPrivate->prefs = CFDictionaryCreateMutable(NULL, - 0, - &kCFTypeDictionaryKeyCallBacks, - &kCFTypeDictionaryValueCallBacks); - } else { - prefsPrivate->prefs = CFDictionaryCreateMutableCopy(NULL, 0, entity); - } - - prefsPrivate->changed = TRUE; - ok = TRUE; - goto done; - } - - nodes = CFArrayCreateMutable(NULL, nElements - 1, &kCFTypeArrayCallBacks); + nodes = CFArrayCreateMutable(NULL, nElements-1, &kCFTypeArrayCallBacks); for (i = 0; i < nElements - 1; i++) { element = CFArrayGetValueAtIndex(elements, i); if (i == 0) { - node = SCPreferencesGetValue(prefs, element); + node = CFDictionaryGetValue(prefsPrivate->prefs, element); } else { node = CFDictionaryGetValue(node, element); @@ -244,7 +219,7 @@ setPath(SCPreferencesRef prefs, CFStringRef path, CFDictionaryRef entity) goto done; } - if ((i < nElements - 1) && + if ((i < nElements-1) && CFDictionaryGetValueIfPresent(node, kSCResvLink, (const void **)&link)) { /* * if not the last path component and this @@ -269,7 +244,7 @@ setPath(SCPreferencesRef prefs, CFStringRef path, CFDictionaryRef entity) newElements = CFArrayCreateMutableCopy(NULL, 0, linkElements); CFArrayAppendArray(newElements, elements, - CFRangeMake(i + 1, nElements-i - 1)); + CFRangeMake(i+1, nElements-i-1)); CFRelease(elements); elements = newElements; @@ -278,40 +253,25 @@ setPath(SCPreferencesRef prefs, CFStringRef path, CFDictionaryRef entity) } } - /* - * make sure that the last component doesn't step on top - * of a non-dictionary component. - */ - element = CFArrayGetValueAtIndex(elements, nElements - 1); - if (nElements > 1) { - node = CFArrayGetValueAtIndex(nodes, nElements - 2); - node = CFDictionaryGetValue(node, element); - } else { - node = SCPreferencesGetValue(prefs, element); - } - if ((node != NULL) && !isA_CFDictionary(node)) { - // we won't step on a non-dictionary component - _SCErrorSet(kSCStatusInvalidArgument); - goto done; - } - - if (entity != NULL) { + if (entity) { newEntity = CFRetain(entity); } for (i = nElements - 1; i >= 0; i--) { element = CFArrayGetValueAtIndex(elements, i); if (i == 0) { - if (newEntity != NULL) { - ok = SCPreferencesSetValue(prefs, element, newEntity); + if (newEntity) { + CFDictionarySetValue(prefsPrivate->prefs, element, newEntity); } else { - ok = SCPreferencesRemoveValue(prefs, element); + CFDictionaryRemoveValue(prefsPrivate->prefs, element); } + prefsPrivate->changed = TRUE; + ok = TRUE; } else { CFMutableDictionaryRef newNode; - node = CFArrayGetValueAtIndex(nodes, i - 1); + node = CFArrayGetValueAtIndex(nodes, i-1); newNode = CFDictionaryCreateMutableCopy(NULL, 0, node); - if (newEntity != NULL) { + if (newEntity) { CFDictionarySetValue(newNode, element, newEntity); CFRelease(newEntity); } else { @@ -325,13 +285,13 @@ setPath(SCPreferencesRef prefs, CFStringRef path, CFDictionaryRef entity) newEntity = newNode; } } - if (newEntity != NULL) { + if (newEntity) { CFRelease(newEntity); } done : - if (nodes != NULL) CFRelease(nodes); + CFRelease(nodes); CFRelease(elements); return ok; } @@ -456,22 +416,7 @@ SCPreferencesPathSetValue(SCPreferencesRef prefs, return FALSE; } -#define NETPREF_NEEDS_REPAIR -#ifdef NETPREF_NEEDS_REPAIR - if (CFEqual(path, CFSTR("/CurrentSet")) && isA_CFString(value)) { -// static Boolean warned = FALSE; -// if (!warned) { -// SCPrint(TRUE, stderr, CFSTR("SCPreferencesPathSetValue(, %@, ) called with non-dictionary value\n"), path); -// warned = TRUE; -// } - return SCPreferencesSetValue(prefs, CFSTR("CurrentSet"), value); - } -#endif // NETPREF_NEEDS_REPAIR - - if (!isA_CFDictionary(value)) { -#ifdef NETPREF_NEEDS_REPAIR -SCPrint(TRUE, stderr, CFSTR("SCPreferencesPathSetValue(, %@, ) called with non-dictionary value\n"), path); -#endif // NETPREF_NEEDS_REPAIR + if (!value) { _SCErrorSet(kSCStatusInvalidArgument); return FALSE; } @@ -496,7 +441,7 @@ SCPreferencesPathSetLink(SCPreferencesRef prefs, return FALSE; } - if (!isA_CFString(link)) { + if (!link) { _SCErrorSet(kSCStatusInvalidArgument); return FALSE; } diff --git a/SystemConfiguration.fproj/SCProxies.c b/SystemConfiguration.fproj/SCProxies.c index 9caf2cd..e15f541 100644 --- a/SystemConfiguration.fproj/SCProxies.c +++ b/SystemConfiguration.fproj/SCProxies.c @@ -35,6 +35,8 @@ #include + + CFStringRef SCDynamicStoreKeyCreateProxies(CFAllocatorRef allocator) { @@ -121,7 +123,6 @@ SCDynamicStoreCopyProxies(SCDynamicStoreRef store) Boolean tempSession = FALSE; - /* copy proxy information from dynamic store */ if (store == NULL) { @@ -257,6 +258,7 @@ SCDynamicStoreCopyProxies(SCDynamicStoreRef store) } } + proxies = CFDictionaryCreateCopy(NULL, newProxies); CFRelease(newProxies); diff --git a/configd.tproj/plugin_support.c b/configd.tproj/plugin_support.c index 52fa072..97357ca 100644 --- a/configd.tproj/plugin_support.c +++ b/configd.tproj/plugin_support.c @@ -82,8 +82,8 @@ static CFRunLoopRef plugin_runLoop = NULL; #ifdef ppc -//extern SCDynamicStoreBundleLoadFunction load_ATconfig; -//extern SCDynamicStoreBundleStopFunction stop_ATconfig; +extern SCDynamicStoreBundleLoadFunction load_ATconfig; +extern SCDynamicStoreBundleStopFunction stop_ATconfig; #endif /* ppc */ extern SCDynamicStoreBundleLoadFunction load_IPMonitor; extern SCDynamicStoreBundlePrimeFunction prime_IPMonitor; @@ -108,13 +108,13 @@ typedef struct { static const builtin builtin_plugins[] = { #ifdef ppc -// { -// CFSTR("com.apple.SystemConfiguration.ATconfig"), -// &load_ATconfig, -// NULL, -// NULL, -// &stop_ATconfig -// }, + { + CFSTR("com.apple.SystemConfiguration.ATconfig"), + &load_ATconfig, + NULL, + NULL, + &stop_ATconfig + }, #endif /* ppc */ { CFSTR("com.apple.SystemConfiguration.IPMonitor"), diff --git a/configd.xcode/project.pbxproj b/configd.xcode/project.pbxproj index 4c5e1bf..ad7bbea 100644 --- a/configd.xcode/project.pbxproj +++ b/configd.xcode/project.pbxproj @@ -245,7 +245,7 @@ buildRules = ( ); buildSettings = { - CURRENT_PROJECT_VERSION = 136.2; + CURRENT_PROJECT_VERSION = 137.2; DEAD_CODE_STRIPPING = YES; FRAMEWORK_SEARCH_PATHS = "$(SYMROOT)"; INSTALL_MODE_FLAG = "a-w,a+rX"; @@ -609,7 +609,7 @@ buildRules = ( ); buildSettings = { - CURRENT_PROJECT_VERSION = 136.2; + CURRENT_PROJECT_VERSION = 137.2; DEAD_CODE_STRIPPING = YES; FRAMEWORK_SEARCH_PATHS = "$(SYMROOT)"; INSTALL_MODE_FLAG = "a-w,a+rX,u+s"; @@ -1949,12 +1949,12 @@ buildRules = ( ); buildSettings = { - CURRENT_PROJECT_VERSION = 136.2; + CURRENT_PROJECT_VERSION = 137.2; DEAD_CODE_STRIPPING = YES; FRAMEWORK_SEARCH_PATHS = "$(SYMROOT)"; INSTALL_MODE_FLAG = "a-w,a+rX"; INSTALL_PATH = /usr/sbin; - LIBRARY_SEARCH_PATHS = "$(SYMROOT) /usr/local/lib/SystemConfiguration"; + LIBRARY_SEARCH_PATHS = "\"$(SYMROOT)\" /usr/local/lib/SystemConfiguration"; OTHER_CFLAGS = "-fconstant-cfstrings"; OTHER_LDFLAGS = "-prebind_all_twolevel_modules"; PRODUCT_NAME = configd; @@ -3895,7 +3895,7 @@ }; 15CB6A7705C0722B0099E85F = { buildSettings = { - CURRENT_PROJECT_VERSION = 136.2; + CURRENT_PROJECT_VERSION = 137.2; FRAMEWORK_SEARCH_PATHS = ""; HEADER_SEARCH_PATHS = ""; INSTALL_GROUP = wheel; @@ -4132,7 +4132,7 @@ buildRules = ( ); buildSettings = { - CURRENT_PROJECT_VERSION = 136.2; + CURRENT_PROJECT_VERSION = 137.2; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; HEADER_SEARCH_PATHS = "$(SYSTEM_LIBRARY_DIR)/Frameworks/System.framework/PrivateHeaders"; @@ -5474,14 +5474,13 @@ buildRules = ( ); buildSettings = { - CURRENT_PROJECT_VERSION = 136.2; + CURRENT_PROJECT_VERSION = 137.2; HEADER_SEARCH_PATHS = "$(SYSTEM_LIBRARY_DIR)/Frameworks/System.framework/PrivateHeaders"; INFOPLIST_FILE = Plugins/ATconfig/Info.plist; INSTALL_MODE_FLAG = "a-w,a+rX"; INSTALL_PATH = "$(SYSTEM_LIBRARY_DIR)/SystemConfiguration"; OTHER_CFLAGS = "-fconstant-cfstrings"; PRODUCT_NAME = ATconfig; - VALID_ARCHS = ppc; VERSIONING_SYSTEM = "apple-generic"; WARNING_CFLAGS = "-Wall -Wno-unknown-pragmas"; WRAPPER_EXTENSION = bundle; @@ -5539,6 +5538,7 @@ buildRules = ( ); buildSettings = { + HEADER_SEARCH_PATHS = "$(SYSTEM_LIBRARY_DIR)/Frameworks/System.framework/PrivateHeaders"; INSTALL_MODE_FLAG = "a-w,a+rX"; INSTALL_PATH = /usr/local/lib/SystemConfiguration; LIBRARY_STYLE = STATIC; diff --git a/scutil.tproj/scutil.c b/scutil.tproj/scutil.c index 09b6f0a..8909745 100644 --- a/scutil.tproj/scutil.c +++ b/scutil.tproj/scutil.c @@ -133,6 +133,7 @@ getLine(char *buf, int len, InputRef src) history(src->h, &ev, H_ENTER, buf); } + return buf; } -- 2.47.2