From d0b3e5dbeaee7cd8c6f3d8eedd1c92be0864d027 Mon Sep 17 00:00:00 2001 From: Apple Date: Tue, 11 Oct 2011 22:51:44 +0000 Subject: [PATCH] configd-395.7.tar.gz --- Plugins/IPMonitor/Info.plist | 2 +- Plugins/InterfaceNamer/Info.plist | 2 +- Plugins/KernelEventMonitor/Info.plist | 2 +- Plugins/LinkConfiguration/Info.plist | 2 +- Plugins/Logger/Info-Embedded.plist | 2 +- Plugins/Logger/Info.plist | 2 +- Plugins/NetworkIdentification/Info.plist | 2 +- Plugins/PreferencesMonitor/Info.plist | 2 +- SCMonitor/Info.plist | 2 +- .../English.lproj/NetworkInterface.strings | Bin 4888 -> 5854 bytes SystemConfiguration.fproj/Info-Embedded.plist | 2 +- SystemConfiguration.fproj/Info.plist | 2 +- .../SCNetworkInterface.c | 284 +++++++++++------- 13 files changed, 192 insertions(+), 114 deletions(-) diff --git a/Plugins/IPMonitor/Info.plist b/Plugins/IPMonitor/Info.plist index 473dee5..52c80f5 100644 --- a/Plugins/IPMonitor/Info.plist +++ b/Plugins/IPMonitor/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType BNDL CFBundleShortVersionString - 1.11 + 1.11.1 CFBundleSignature ???? CFBundleVersion diff --git a/Plugins/InterfaceNamer/Info.plist b/Plugins/InterfaceNamer/Info.plist index 2dbc4b4..244ec1a 100644 --- a/Plugins/InterfaceNamer/Info.plist +++ b/Plugins/InterfaceNamer/Info.plist @@ -17,7 +17,7 @@ CFBundlePackageType BNDL CFBundleShortVersionString - 1.11 + 1.11.1 CFBundleSignature ???? CFBundleVersion diff --git a/Plugins/KernelEventMonitor/Info.plist b/Plugins/KernelEventMonitor/Info.plist index 995a930..024f038 100644 --- a/Plugins/KernelEventMonitor/Info.plist +++ b/Plugins/KernelEventMonitor/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType BNDL CFBundleShortVersionString - 1.11 + 1.11.1 CFBundleSignature ???? CFBundleVersion diff --git a/Plugins/LinkConfiguration/Info.plist b/Plugins/LinkConfiguration/Info.plist index a4e758f..21adc60 100644 --- a/Plugins/LinkConfiguration/Info.plist +++ b/Plugins/LinkConfiguration/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType BNDL CFBundleShortVersionString - 1.11 + 1.11.1 CFBundleSignature ???? CFBundleVersion diff --git a/Plugins/Logger/Info-Embedded.plist b/Plugins/Logger/Info-Embedded.plist index 42509e5..db9e629 100644 --- a/Plugins/Logger/Info-Embedded.plist +++ b/Plugins/Logger/Info-Embedded.plist @@ -15,7 +15,7 @@ CFBundlePackageType BNDL CFBundleShortVersionString - 1.11 + 1.11.1 CFBundleSignature ???? CFBundleVersion diff --git a/Plugins/Logger/Info.plist b/Plugins/Logger/Info.plist index a5ca3f6..b8c904d 100644 --- a/Plugins/Logger/Info.plist +++ b/Plugins/Logger/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType BNDL CFBundleShortVersionString - 1.11 + 1.11.1 CFBundleSignature ???? CFBundleVersion diff --git a/Plugins/NetworkIdentification/Info.plist b/Plugins/NetworkIdentification/Info.plist index f3aa421..db066bd 100644 --- a/Plugins/NetworkIdentification/Info.plist +++ b/Plugins/NetworkIdentification/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType BNDL CFBundleShortVersionString - 1.11 + 1.11.1 CFBundleSignature ???? CFBundleVersion diff --git a/Plugins/PreferencesMonitor/Info.plist b/Plugins/PreferencesMonitor/Info.plist index d202828..59113e5 100644 --- a/Plugins/PreferencesMonitor/Info.plist +++ b/Plugins/PreferencesMonitor/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType BNDL CFBundleShortVersionString - 1.11 + 1.11.1 CFBundleSignature ???? CFBundleVersion diff --git a/SCMonitor/Info.plist b/SCMonitor/Info.plist index 0f5dca2..1889870 100644 --- a/SCMonitor/Info.plist +++ b/SCMonitor/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType BNDL CFBundleShortVersionString - 1.11 + 1.11.1 CFBundleSignature ???? CFBundleVersion diff --git a/SystemConfiguration.fproj/English.lproj/NetworkInterface.strings b/SystemConfiguration.fproj/English.lproj/NetworkInterface.strings index fe6b31b7bdf48cec1e1088599dae58108e1327cb..c88493feea4dfaf9435bd3213b51a8f79081c73c 100644 GIT binary patch delta 487 zcmbQCc29T1K1R_Jh75*MhCGH8hE#?kh9ri3h8%{Hi4SEbe_&)24Z$Wkxsg$MvJE2# zcCC{=8D*ty859_l7_jQz+{nnxj6>^07Q9*~CkhEqj$#qOV>v&IB0kGOCTxykxxmHi z$WQ=;IY3W`FoaFs$gT?VuP%xx&<~*u!3<77pI9?+0ihCu3qvMDF<4(BLnSaAgeNcH z7Xs8@%)ODWjIAZrcF-bS7Xm)2w+HLNCCRd kkRQs1xoEPzKs=`s&@BPL=t8Ifvf(Of`A=`2Cs4%%0D{wQ9RL6T delta 38 wcmV+>0NMZEEtn>-z5%nq0>%Qfj0UC(lY|l;lWGz`lcW>Clll@?vt$%{0zjt^rvLx| diff --git a/SystemConfiguration.fproj/Info-Embedded.plist b/SystemConfiguration.fproj/Info-Embedded.plist index 5597be5..9112621 100644 --- a/SystemConfiguration.fproj/Info-Embedded.plist +++ b/SystemConfiguration.fproj/Info-Embedded.plist @@ -17,7 +17,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 1.11 + 1.11.1 CFBundleSignature ???? CFBundleVersion diff --git a/SystemConfiguration.fproj/Info.plist b/SystemConfiguration.fproj/Info.plist index 5597be5..9112621 100644 --- a/SystemConfiguration.fproj/Info.plist +++ b/SystemConfiguration.fproj/Info.plist @@ -17,7 +17,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 1.11 + 1.11.1 CFBundleSignature ???? CFBundleVersion diff --git a/SystemConfiguration.fproj/SCNetworkInterface.c b/SystemConfiguration.fproj/SCNetworkInterface.c index c751a62..5820ad2 100644 --- a/SystemConfiguration.fproj/SCNetworkInterface.c +++ b/SystemConfiguration.fproj/SCNetworkInterface.c @@ -71,6 +71,10 @@ #define kIODeviceSupportsHoldKey "V92Modem" #endif +#ifndef kPCIThunderboltString +#define kPCIThunderboltString "PCI-Thunderbolt" +#endif + #ifndef kUSBProductString #define kUSBProductString "USB Product Name" #endif @@ -1223,6 +1227,13 @@ static const struct { }; +static const CFStringRef slot_prefixes[] = { + CFSTR("thunderbolt slot "), + CFSTR("pci slot "), + CFSTR("slot-"), +}; + + static CFStringRef pci_slot(io_registry_entry_t interface, CFTypeRef *pci_slot_name) { @@ -1249,12 +1260,17 @@ pci_slot(io_registry_entry_t interface, CFTypeRef *pci_slot_name) kCFStringEncodingUTF8); } - if (CFStringGetLength(slot) > 5) { - (void) CFStringFindAndReplace(slot, - CFSTR("slot-"), - CFSTR(""), - CFRangeMake(0, 5), - kCFCompareCaseInsensitive|kCFCompareAnchored); + for (i = 0; i < sizeof(slot_prefixes)/sizeof(slot_prefixes[0]); i++) { + CFIndex len; + + len = CFStringGetLength(slot_prefixes[i]); + if (CFStringGetLength(slot) > len) { + (void) CFStringFindAndReplace(slot, + slot_prefixes[i], + CFSTR(""), + CFRangeMake(0, len), + kCFCompareCaseInsensitive|kCFCompareAnchored); + } } for (i = 0; i < sizeof(slot_mappings)/sizeof(slot_mappings[0]); i++) { @@ -1315,7 +1331,7 @@ compare_bsdNames(const void *val1, const void *val2, void *context) static CFStringRef -pci_port(CFTypeRef slot_name, CFStringRef bsdName) +pci_port(CFTypeRef slot_name, int ift, CFStringRef bsdName) { CFIndex n; CFStringRef port_name = NULL; @@ -1378,15 +1394,33 @@ pci_port(CFTypeRef slot_name, CFStringRef bsdName) while ((child = IOIteratorNext(child_iterator)) != MACH_PORT_NULL) { if (IOObjectConformsTo(child, kIONetworkInterfaceClass)) { - CFStringRef if_bsdName; - - if_bsdName = IORegistryEntryCreateCFProperty(child, - CFSTR(kIOBSDNameKey), - NULL, - 0); - if (if_bsdName != NULL) { - CFArrayAppendValue(port_names, if_bsdName); - CFRelease(if_bsdName); + CFNumberRef child_if_type; + int child_ift = ift; + + child_if_type = IORegistryEntryCreateCFProperty(child, + CFSTR(kIOInterfaceType), + NULL, + 0); + if (child_if_type != NULL) { + if (!isA_CFNumber(child_if_type) || + !CFNumberGetValue(child_if_type, kCFNumberIntType, &child_ift)) { + // assume that it's a match + child_ift = ift; + } + CFRelease(child_if_type); + } + + if (ift == child_ift) { + CFStringRef if_bsdName; + + if_bsdName = IORegistryEntryCreateCFProperty(child, + CFSTR(kIOBSDNameKey), + NULL, + 0); + if (if_bsdName != NULL) { + CFArrayAppendValue(port_names, if_bsdName); + CFRelease(if_bsdName); + } } } IOObjectRelease(child); @@ -1411,7 +1445,7 @@ pci_port(CFTypeRef slot_name, CFStringRef bsdName) static Boolean -pci_slot_info(io_registry_entry_t interface, CFStringRef *slot_name, CFStringRef *port_name) +pci_slot_info(io_registry_entry_t interface, int ift, CFStringRef *slot_name, CFStringRef *port_name) { CFStringRef bsd_name; Boolean ok = FALSE; @@ -1428,7 +1462,7 @@ pci_slot_info(io_registry_entry_t interface, CFStringRef *slot_name, CFStringRef *slot_name = pci_slot(interface, &pci_slot_name); if (*slot_name != NULL) { if (pci_slot_name != NULL) { - *port_name = pci_port(pci_slot_name, bsd_name); + *port_name = pci_port(pci_slot_name, ift, bsd_name); CFRelease(pci_slot_name); } ok = TRUE; @@ -1500,6 +1534,25 @@ isBluetoothBuiltin(Boolean *haveController) } +static Boolean +isThunderbolt(io_registry_entry_t interface) +{ + CFTypeRef val; + + val = IORegistryEntrySearchCFProperty(interface, + kIOServicePlane, + CFSTR(kPCIThunderboltString), + NULL, + kIORegistryIterateRecursively | kIORegistryIterateParents); + if (val != NULL) { + CFRelease(val); + return TRUE; + } + + return FALSE; +} + + static void processUSBInterface(SCNetworkInterfacePrivateRef interfacePrivate, io_registry_entry_t interface, @@ -1530,6 +1583,53 @@ processUSBInterface(SCNetworkInterfacePrivateRef interfacePrivate, } +static Boolean +update_interface_name(SCNetworkInterfacePrivateRef interfacePrivate, + io_registry_entry_t interface, + Boolean useUSBInfo) +{ + Boolean updated = FALSE; + CFTypeRef val; + + // check if a "Product Name" has been provided + val = IORegistryEntrySearchCFProperty(interface, + kIOServicePlane, + CFSTR(kIOPropertyProductNameKey), + NULL, + kIORegistryIterateRecursively | kIORegistryIterateParents); + if ((val == NULL) && useUSBInfo && (interfacePrivate->usb.name != NULL)) { + // else, use "USB Product Name" if available + val = CFRetain(interfacePrivate->usb.name); + } + if (val != NULL) { + CFStringRef productName; + + productName = IOCopyCFStringValue(val); + CFRelease(val); + + if (productName != NULL) { + if (CFStringGetLength(productName) > 0) { + // if we have a [somewhat reasonable?] product name + if (interfacePrivate->name != NULL) { + CFRelease(interfacePrivate->name); + } + interfacePrivate->name = CFRetain(productName); + if (interfacePrivate->localized_name != NULL) { + CFRelease(interfacePrivate->localized_name); + } + interfacePrivate->localized_name = copy_interface_string(bundle, productName, TRUE); + + updated = TRUE; + } + + CFRelease(productName); + } + } + + return updated; +} + + #pragma mark - #pragma mark Interface enumeration @@ -1740,19 +1840,33 @@ processNetworkInterface(SCNetworkInterfacePrivateRef interfacePrivate, CFStringRef port_name; CFStringRef slot_name; - if (pci_slot_info(interface, &slot_name, &port_name)) { - if (port_name == NULL) { - interfacePrivate->localized_key = CFSTR("pci-ether"); - interfacePrivate->localized_arg1 = slot_name; + // set interface "name" + if (!update_interface_name(interfacePrivate, interface, FALSE) && + pci_slot_info(interface, ift, &slot_name, &port_name)) { + if (isThunderbolt(interface)) { + if (port_name == NULL) { + interfacePrivate->localized_key = CFSTR("thunderbolt-ether"); + interfacePrivate->localized_arg1 = slot_name; + } else { + interfacePrivate->localized_key = CFSTR("thunderbolt-multiether"); + interfacePrivate->localized_arg1 = slot_name; + interfacePrivate->localized_arg2 = port_name; + } + } else { - interfacePrivate->localized_key = CFSTR("pci-multiether"); - interfacePrivate->localized_arg1 = slot_name; - interfacePrivate->localized_arg2 = port_name; + if (port_name == NULL) { + interfacePrivate->localized_key = CFSTR("pci-ether"); + interfacePrivate->localized_arg1 = slot_name; + } else { + interfacePrivate->localized_key = CFSTR("pci-multiether"); + interfacePrivate->localized_arg1 = slot_name; + interfacePrivate->localized_arg2 = port_name; + } } } } else if (CFEqual(provider, CFSTR("IOUSBDevice")) || CFEqual(provider, CFSTR("IOUSBInterface"))) { - + // get USB info (if available) processUSBInterface(interfacePrivate, interface, interface_dict, @@ -1761,38 +1875,8 @@ processNetworkInterface(SCNetworkInterfacePrivateRef interfacePrivate, bus, bus_dict); - // check if a "Product Name" has been provided - val = IORegistryEntrySearchCFProperty(interface, - kIOServicePlane, - CFSTR(kIOPropertyProductNameKey), - NULL, - kIORegistryIterateRecursively | kIORegistryIterateParents); - if ((val == NULL) && (interfacePrivate->usb.name != NULL)) { - // else, use "USB Product Name" if available - val = CFRetain(interfacePrivate->usb.name); - } - if (val != NULL) { - CFStringRef productName; - - productName = IOCopyCFStringValue(val); - CFRelease(val); - - if (productName != NULL) { - if (CFStringGetLength(productName) > 0) { - // if we have a [somewhat reasonable?] product name - if (interfacePrivate->name != NULL) { - CFRelease(interfacePrivate->name); - } - interfacePrivate->name = CFRetain(productName); - if (interfacePrivate->localized_name != NULL) { - CFRelease(interfacePrivate->localized_name); - } - interfacePrivate->localized_name = copy_interface_string(bundle, productName, TRUE); - } - - CFRelease(productName); - } - } else { + // set interface "name" + if (!update_interface_name(interfacePrivate, interface, TRUE)) { interfacePrivate->localized_key = CFSTR("usb-ether"); interfacePrivate->localized_arg1 = IODictionaryCopyCFStringValue(interface_dict, CFSTR(kIOBSDNameKey)); } @@ -1825,12 +1909,31 @@ processNetworkInterface(SCNetworkInterfacePrivateRef interfacePrivate, if (interfacePrivate->builtin) { interfacePrivate->localized_key = CFSTR("firewire"); } else { + CFStringRef port_name; CFStringRef slot_name; - slot_name = pci_slot(interface, NULL); - if (slot_name != NULL) { - interfacePrivate->localized_key = CFSTR("pci-firewire"); - interfacePrivate->localized_arg1 = slot_name; + // set interface "name" + if (!update_interface_name(interfacePrivate, interface, FALSE) && + pci_slot_info(interface, ift, &slot_name, &port_name)) { + if (isThunderbolt(interface)) { + if (port_name == NULL) { + interfacePrivate->localized_key = CFSTR("thunderbolt-firewire"); + interfacePrivate->localized_arg1 = slot_name; + } else { + interfacePrivate->localized_key = CFSTR("thunderbolt-multifirewire"); + interfacePrivate->localized_arg1 = slot_name; + interfacePrivate->localized_arg2 = port_name; + } + } else { + if (port_name == NULL) { + interfacePrivate->localized_key = CFSTR("pci-firewire"); + interfacePrivate->localized_arg1 = slot_name; + } else { + interfacePrivate->localized_key = CFSTR("pci-multifirewire"); + interfacePrivate->localized_arg1 = slot_name; + interfacePrivate->localized_arg2 = port_name; + } + } } } @@ -2219,47 +2322,22 @@ processSerialInterface(SCNetworkInterfacePrivateRef interfacePrivate, } if (!isModem || !CFEqual(base, CFSTR("modem"))) { - CFStringRef productName; - - // check if a "Product Name" has been provided - val = IORegistryEntrySearchCFProperty(interface, - kIOServicePlane, - CFSTR(kIOPropertyProductNameKey), - NULL, - kIORegistryIterateRecursively | kIORegistryIterateParents); - if (val == NULL) { - // check if a "USB Product Name" has been provided - val = IORegistryEntrySearchCFProperty(interface, - kIOServicePlane, - CFSTR(kUSBProductString), - NULL, - kIORegistryIterateRecursively | kIORegistryIterateParents); - } - if (val != NULL) { - productName = IOCopyCFStringValue(val); - CFRelease(val); - - if (productName != NULL) { - if (CFStringGetLength(productName) > 0) { - // if we have a [somewhat reasonable?] product name - if (interfacePrivate->name != NULL) { - CFRelease(interfacePrivate->name); - } - interfacePrivate->name = CFRetain(productName); - if (interfacePrivate->localized_name != NULL) { - CFRelease(interfacePrivate->localized_name); - } - interfacePrivate->localized_name = copy_interface_string(bundle, productName, TRUE); - - // if not provided, also check if the product name - // matches a CCL script - if ((modemCCL == NULL) && - is_valid_connection_script(productName)) { - set_connection_script(interfacePrivate, productName); - } - } - - CFRelease(productName); + // get USB info (if available) + processUSBInterface(interfacePrivate, + interface, + interface_dict, + controller, + controller_dict, + bus, + bus_dict); + + // set interface "name" + if (update_interface_name(interfacePrivate, interface, TRUE)) { + // if "ModemCCL" not provided, also check if the product/interface + // name matches a CCL script + if ((modemCCL == NULL) && + is_valid_connection_script(interfacePrivate->name)) { + set_connection_script(interfacePrivate, interfacePrivate->name); } } } -- 2.45.2