From: Apple Date: Thu, 10 May 2012 15:23:29 +0000 (+0000) Subject: configd-395.11.tar.gz X-Git-Tag: mac-os-x-1074^0 X-Git-Url: https://git.saurik.com/apple/configd.git/commitdiff_plain/af243a0d9bf37c3818926f82705eec9b22b50a4d configd-395.11.tar.gz --- diff --git a/Makefile b/Makefile index 1102fd3..b3d4dc2 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,6 @@ +PROJECT=$(shell basename `pwd -P` | sed -e 's/\(.*\)-[0-9][0-9.]*$$/\1/') +VERSION=$(shell basename `pwd -P` | sed -e 's/.*-\([0-9][0-9.]*$$\)/\1/') + #---------------------------------------------------------------------- # # Build for [current] release @@ -22,8 +25,6 @@ all : # #---------------------------------------------------------------------- -PROJECT=$(shell basename `pwd -P`) - SNOW_CFLAGS += -D__MAC_10_7=1060 SNOW_CFLAGS += -D__AVAILABILITY_INTERNAL__MAC_10_7=__AVAILABILITY_INTERNAL__MAC_10_6 SNOW_CFLAGS += -D__AVAILABILITY_INTERNAL__MAC_10_5_DEP__MAC_10_7=__AVAILABILITY_INTERNAL__MAC_10_5 diff --git a/Plugins/IPMonitor/Info.plist b/Plugins/IPMonitor/Info.plist index a29cf26..eadcad1 100644 --- a/Plugins/IPMonitor/Info.plist +++ b/Plugins/IPMonitor/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType BNDL CFBundleShortVersionString - 1.11.2 + 1.11.3 CFBundleSignature ???? CFBundleVersion diff --git a/Plugins/InterfaceNamer/Info.plist b/Plugins/InterfaceNamer/Info.plist index ee235fc..d2650f6 100644 --- a/Plugins/InterfaceNamer/Info.plist +++ b/Plugins/InterfaceNamer/Info.plist @@ -17,7 +17,7 @@ CFBundlePackageType BNDL CFBundleShortVersionString - 1.11.2 + 1.11.3 CFBundleSignature ???? CFBundleVersion diff --git a/Plugins/InterfaceNamer/ifnamer.c b/Plugins/InterfaceNamer/ifnamer.c index a0d377b..ae4d87a 100644 --- a/Plugins/InterfaceNamer/ifnamer.c +++ b/Plugins/InterfaceNamer/ifnamer.c @@ -24,6 +24,10 @@ /* * Modification History * + * May 20, 2006 Joe Liu + * Allan Nathanson + * - register interface by entryID (and not path) + * * November 6, 2006 Allan Nathanson * Dan Markarian * Dieter Siegmund @@ -82,15 +86,22 @@ #include #include #include +#include #include +#ifdef kIONetworkStackUserCommandKey +#define USE_REGISTRY_ENTRY_ID +#endif + +#ifndef USE_REGISTRY_ENTRY_ID // from -#define kIONetworkStackUserCommand "IONetworkStackUserCommand" +#define kIONetworkStackUserCommandKey "IONetworkStackUserCommand" enum { kRegisterInterfaceWithFixedUnit = 0, kRegisterInterface, kRegisterAllInterfaces }; +#endif // !USE_REGISTRY_ENTRY_ID #define kSCNetworkInterfaceInfo "SCNetworkInterfaceInfo" #define kSCNetworkInterfaceType "SCNetworkInterfaceType" @@ -317,42 +328,41 @@ writeInterfaceList(CFArrayRef if_list) old_model = SCPreferencesGetValue(prefs, MODEL); new_model = hw_model(); - if ((old_model != NULL) && - (new_model != NULL) && - !CFEqual(old_model, new_model) && - (cur_list != NULL)) { - CFStringRef history; - CFStringRef issue; - - // if interface list was created on other hardware - history = CFStringCreateWithFormat(NULL, NULL, - CFSTR("%@:%@"), - INTERFACES, - old_model); - SCPreferencesSetValue(prefs, history, cur_list); - CFRelease(history); + if ((new_model != NULL) && !_SC_CFEqual(old_model, new_model)) { + // if new hardware + if ((old_model != NULL) && (cur_list != NULL)) { + CFStringRef history; + CFStringRef issue; - SCLog(TRUE, LOG_ERR, - CFSTR(MY_PLUGIN_NAME ": Hardware model changed\n" - MY_PLUGIN_NAME ": created on \"%@\"\n" - MY_PLUGIN_NAME ": now on \"%@\""), - old_model, - new_model); + // if interface list was created on other hardware + history = CFStringCreateWithFormat(NULL, NULL, + CFSTR("%@:%@"), + INTERFACES, + old_model); + SCPreferencesSetValue(prefs, history, cur_list); + CFRelease(history); - issue = CFStringCreateWithFormat(NULL, NULL, - CFSTR("%@ --> %@"), - old_model, - new_model); - reportIssue("Hardware model changed", issue); - CFRelease(issue); - } + SCLog(TRUE, LOG_ERR, + CFSTR(MY_PLUGIN_NAME ": Hardware model changed\n" + MY_PLUGIN_NAME ": created on \"%@\"\n" + MY_PLUGIN_NAME ": now on \"%@\""), + old_model, + new_model); + + issue = CFStringCreateWithFormat(NULL, NULL, + CFSTR("%@ --> %@"), + old_model, + new_model); + reportIssue("Hardware model changed", issue); + CFRelease(issue); + } - if ((new_model != NULL) && - !SCPreferencesSetValue(prefs, MODEL, new_model)) { - SCLog(TRUE, LOG_ERR, - CFSTR(MY_PLUGIN_NAME ": SCPreferencesSetValue failed, %s"), - SCErrorString(SCError())); - goto done; + if (!SCPreferencesSetValue(prefs, MODEL, new_model)) { + SCLog(TRUE, LOG_ERR, + CFSTR(MY_PLUGIN_NAME ": SCPreferencesSetValue failed, %s"), + SCErrorString(SCError())); + goto done; + } } if (!SCPreferencesSetValue(prefs, INTERFACES, if_list)) { @@ -1098,6 +1108,86 @@ getHighestUnitForType(CFNumberRef if_type) return (ret_unit); } +#ifdef USE_REGISTRY_ENTRY_ID +static kern_return_t +registerInterfaceWithIORegistryEntryID(io_connect_t connect, + uint64_t entryID, + CFNumberRef unit, + const int command) +{ + CFDataRef data; + CFMutableDictionaryRef dict; + kern_return_t kr; + CFNumberRef num; + + dict = CFDictionaryCreateMutable(NULL, 0, + &kCFTypeDictionaryKeyCallBacks, + &kCFTypeDictionaryValueCallBacks); + num = CFNumberCreate(NULL, kCFNumberIntType, &command); + CFDictionarySetValue(dict, CFSTR(kIONetworkStackUserCommandKey), num); + CFRelease(num); + data = CFDataCreate(NULL, (void *) &entryID, sizeof(entryID)); + CFDictionarySetValue(dict, CFSTR(kIORegistryEntryIDKey), data); + CFRelease(data); + CFDictionarySetValue(dict, CFSTR(kIOInterfaceUnit), unit); + kr = IOConnectSetCFProperties(connect, dict); + CFRelease(dict); + return kr; +} + +static SCNetworkInterfaceRef +lookupIORegistryEntryID(uint64_t entryID) +{ + io_registry_entry_t entry = MACH_PORT_NULL; + SCNetworkInterfaceRef interface = NULL; + io_iterator_t iterator = MACH_PORT_NULL; + kern_return_t kr; + mach_port_t masterPort = MACH_PORT_NULL; + + kr = IOMasterPort(bootstrap_port, &masterPort); + if (kr != KERN_SUCCESS) { + SCLog(TRUE, LOG_ERR, + CFSTR(MY_PLUGIN_NAME ": IOMasterPort returned 0x%x"), + kr); + goto error; + } + + kr = IOServiceGetMatchingServices(masterPort, + IORegistryEntryIDMatching(entryID), + &iterator); + if ((kr != KERN_SUCCESS) || (iterator == MACH_PORT_NULL)) { + SCLog(TRUE, LOG_ERR, + CFSTR(MY_PLUGIN_NAME ": IOServiceGetMatchingServices(0x%llx) returned 0x%x/%d"), + entryID, + kr, + iterator); + goto error; + } + + entry = IOIteratorNext(iterator); + if (entry == MACH_PORT_NULL) { + SCLog(TRUE, LOG_ERR, + CFSTR(MY_PLUGIN_NAME ": IORegistryEntryIDMatching(0x%llx) failed"), + entryID); + goto error; + } + + interface = _SCNetworkInterfaceCreateWithIONetworkInterfaceObject(entry); + + error: + if (masterPort != MACH_PORT_NULL) { + mach_port_deallocate(mach_task_self(), masterPort); + } + if (entry != MACH_PORT_NULL) { + IOObjectRelease(entry); + } + if (iterator != MACH_PORT_NULL) { + IOObjectRelease(iterator); + } + return (interface); + +} +#else // USE_REGISTRY_ENTRY_ID /* * Function: registerInterface * Purpose: @@ -1105,10 +1195,10 @@ getHighestUnitForType(CFNumberRef if_type) * data link layer (BSD), using the specified unit number. */ static kern_return_t -registerInterface(io_connect_t connect, - CFStringRef path, - CFNumberRef unit, - const int command) +registerInterfaceWithIOServicePath(io_connect_t connect, + CFStringRef path, + CFNumberRef unit, + const int command) { CFMutableDictionaryRef dict; kern_return_t kr; @@ -1118,7 +1208,7 @@ registerInterface(io_connect_t connect, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); num = CFNumberCreate(NULL, kCFNumberIntType, &command); - CFDictionarySetValue(dict, CFSTR(kIONetworkStackUserCommand), num); + CFDictionarySetValue(dict, CFSTR(kIONetworkStackUserCommandKey), num); CFRelease(num); CFDictionarySetValue(dict, CFSTR(kIOPathMatchKey), path); CFDictionarySetValue(dict, CFSTR(kIOInterfaceUnit), unit); @@ -1164,6 +1254,7 @@ lookupIOKitPath(CFStringRef if_path) return (interface); } +#endif // USE_REGISTRY_ENTRY_ID static void displayInterface(SCNetworkInterfaceRef interface) @@ -1225,9 +1316,11 @@ nameInterfaces(CFMutableArrayRef if_list) CFIndex n = CFArrayGetCount(if_list); for (i = 0; i < n; i++) { + uint64_t entryID; SCNetworkInterfaceRef interface; Boolean ok = TRUE; CFStringRef path; + CFStringRef str; CFNumberRef type; CFNumberRef unit; CFIndex where; @@ -1236,6 +1329,7 @@ nameInterfaces(CFMutableArrayRef if_list) path = _SCNetworkInterfaceGetIOPath(interface); type = _SCNetworkInterfaceGetIOInterfaceType(interface); unit = _SCNetworkInterfaceGetIOInterfaceUnit(interface); + entryID = _SCNetworkInterfaceGetIORegistryEntryID(interface); if (unit != NULL) { if (S_debug) { @@ -1258,6 +1352,7 @@ nameInterfaces(CFMutableArrayRef if_list) CFDictionaryRef dbdict; boolean_t is_builtin; kern_return_t kr; + int retries = 0; dbdict = lookupInterfaceByAddress(S_dblist, interface, NULL); if (dbdict != NULL) { @@ -1331,12 +1426,22 @@ nameInterfaces(CFMutableArrayRef if_list) is_builtin ? "built-in" : "next available"); } - kr = registerInterface(S_connect, - path, - unit, - (dbdict == NULL) ? kRegisterInterface : kRegisterInterfaceWithFixedUnit); + retry : + +#ifdef USE_REGISTRY_ENTRY_ID + kr = registerInterfaceWithIORegistryEntryID(S_connect, + entryID, + unit, + (dbdict == NULL) ? kIONetworkStackRegisterInterfaceWithLowestUnit + : kIONetworkStackRegisterInterfaceWithUnit); +#else // USE_REGISTRY_ENTRY_ID + kr = registerInterfaceWithIOServicePath(S_connect, + path, + unit, + (dbdict == NULL) ? kRegisterInterface + : kRegisterInterfaceWithFixedUnit); +#endif // USE_REGISTRY_ENTRY_ID if (kr != KERN_SUCCESS) { - CFStringRef issue; const char *signature; signature = (dbdict == NULL) ? "failed to name new interface" @@ -1345,10 +1450,12 @@ nameInterfaces(CFMutableArrayRef if_list) SCLog(TRUE, LOG_ERR, CFSTR(MY_PLUGIN_NAME ": %s, kr=0x%x\n" MY_PLUGIN_NAME ": path = %@\n" + MY_PLUGIN_NAME ": id = 0x%llx\n" MY_PLUGIN_NAME ": unit = %@"), signature, kr, path, + entryID, unit); if (S_debug) { @@ -1356,19 +1463,59 @@ nameInterfaces(CFMutableArrayRef if_list) } // report issue w/MessageTracer - issue = CFStringCreateWithFormat(NULL, NULL, - CFSTR("kr=0x%x, path=%@, unit=%@"), - kr, - path, - unit); - reportIssue(signature, issue); - CFRelease(issue); + str = CFStringCreateWithFormat(NULL, NULL, + CFSTR("kr=0x%x, path=%@, unit=%@"), + kr, + path, + unit); + reportIssue(signature, str); + CFRelease(str); + + if ((dbdict != NULL) && (retries++ < 5)) { + usleep(50 * 1000); // sleep 50ms between attempts + goto retry; + } ok = FALSE; // ... and don't update the database } else { SCNetworkInterfaceRef new_interface; + if (retries > 0) { + SCLog(TRUE, LOG_ERR, + CFSTR(MY_PLUGIN_NAME ": %s interface named after %d %s\n" + MY_PLUGIN_NAME ": path = %@\n" + MY_PLUGIN_NAME ": unit = %@"), + (dbdict == NULL) ? "New" : "Known", + retries, + (retries == 1) ? "try" : "tries", + path, + unit); + +#ifdef SHOW_NAMING_FAILURE + str = CFStringCreateWithFormat(NULL, + NULL, + CFSTR("\"%s\" interface named after %d %s, unit = %@"), + (dbdict == NULL) ? "New" : "Known", + retries, + (retries == 1) ? "try" : "tries", + unit); + CFUserNotificationDisplayNotice(0, + kCFUserNotificationStopAlertLevel, + NULL, + NULL, + NULL, + str, + CFSTR("Please report repeated failures."), + NULL); + CFRelease(str); +#endif // SHOW_NAMING_FAILURE + } + +#ifdef USE_REGISTRY_ENTRY_ID + new_interface = lookupIORegistryEntryID(entryID); +#else // USE_REGISTRY_ENTRY_ID new_interface = lookupIOKitPath(path); +#endif // USE_REGISTRY_ENTRY_ID if (new_interface != NULL) { CFNumberRef new_unit; diff --git a/Plugins/KernelEventMonitor/Info.plist b/Plugins/KernelEventMonitor/Info.plist index 146c74e..2b26025 100644 --- a/Plugins/KernelEventMonitor/Info.plist +++ b/Plugins/KernelEventMonitor/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType BNDL CFBundleShortVersionString - 1.11.2 + 1.11.3 CFBundleSignature ???? CFBundleVersion diff --git a/Plugins/LinkConfiguration/Info.plist b/Plugins/LinkConfiguration/Info.plist index 8655cee..30e9f1d 100644 --- a/Plugins/LinkConfiguration/Info.plist +++ b/Plugins/LinkConfiguration/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType BNDL CFBundleShortVersionString - 1.11.2 + 1.11.3 CFBundleSignature ???? CFBundleVersion diff --git a/Plugins/Logger/Info-Embedded.plist b/Plugins/Logger/Info-Embedded.plist index c0eed04..be01e39 100644 --- a/Plugins/Logger/Info-Embedded.plist +++ b/Plugins/Logger/Info-Embedded.plist @@ -15,7 +15,7 @@ CFBundlePackageType BNDL CFBundleShortVersionString - 1.11.2 + 1.11.3 CFBundleSignature ???? CFBundleVersion diff --git a/Plugins/Logger/Info.plist b/Plugins/Logger/Info.plist index 1f56695..5247be2 100644 --- a/Plugins/Logger/Info.plist +++ b/Plugins/Logger/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType BNDL CFBundleShortVersionString - 1.11.2 + 1.11.3 CFBundleSignature ???? CFBundleVersion diff --git a/Plugins/NetworkIdentification/Info.plist b/Plugins/NetworkIdentification/Info.plist index b025a55..e8e42f5 100644 --- a/Plugins/NetworkIdentification/Info.plist +++ b/Plugins/NetworkIdentification/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType BNDL CFBundleShortVersionString - 1.11.2 + 1.11.3 CFBundleSignature ???? CFBundleVersion diff --git a/Plugins/PreferencesMonitor/Info.plist b/Plugins/PreferencesMonitor/Info.plist index 609f4eb..bc7fbcb 100644 --- a/Plugins/PreferencesMonitor/Info.plist +++ b/Plugins/PreferencesMonitor/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType BNDL CFBundleShortVersionString - 1.11.2 + 1.11.3 CFBundleSignature ???? CFBundleVersion diff --git a/SCMonitor/Info.plist b/SCMonitor/Info.plist index 5a07d4d..8789a63 100644 --- a/SCMonitor/Info.plist +++ b/SCMonitor/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType BNDL CFBundleShortVersionString - 1.11.2 + 1.11.3 CFBundleSignature ???? CFBundleVersion diff --git a/SystemConfiguration.fproj/Info-Embedded.plist b/SystemConfiguration.fproj/Info-Embedded.plist index 40e8929..e399493 100644 --- a/SystemConfiguration.fproj/Info-Embedded.plist +++ b/SystemConfiguration.fproj/Info-Embedded.plist @@ -17,7 +17,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 1.11.2 + 1.11.3 CFBundleSignature ???? CFBundleVersion diff --git a/SystemConfiguration.fproj/Info.plist b/SystemConfiguration.fproj/Info.plist index 40e8929..e399493 100644 --- a/SystemConfiguration.fproj/Info.plist +++ b/SystemConfiguration.fproj/Info.plist @@ -17,7 +17,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 1.11.2 + 1.11.3 CFBundleSignature ???? CFBundleVersion diff --git a/SystemConfiguration.fproj/LinkConfiguration.c b/SystemConfiguration.fproj/LinkConfiguration.c index 0d03d7e..85249b0 100644 --- a/SystemConfiguration.fproj/LinkConfiguration.c +++ b/SystemConfiguration.fproj/LinkConfiguration.c @@ -1252,7 +1252,7 @@ NetworkInterfaceCopyMediaOptions(CFStringRef interfaceName, SCNetworkInterfacePrivateRef interfacePrivate; Boolean ok; - interfacePrivate = __SCNetworkInterfaceCreatePrivate(NULL, NULL, NULL, NULL, NULL); + interfacePrivate = __SCNetworkInterfaceCreatePrivate(NULL, NULL, NULL, NULL); if (interfacePrivate == NULL) { return FALSE; } @@ -1291,7 +1291,7 @@ NetworkInterfaceCopyMTU(CFStringRef interfaceName, SCNetworkInterfacePrivateRef interfacePrivate; Boolean ok; - interfacePrivate = __SCNetworkInterfaceCreatePrivate(NULL, NULL, NULL, NULL, NULL); + interfacePrivate = __SCNetworkInterfaceCreatePrivate(NULL, NULL, NULL, NULL); if (interfacePrivate == NULL) { return FALSE; } diff --git a/SystemConfiguration.fproj/SCNetworkConfigurationInternal.h b/SystemConfiguration.fproj/SCNetworkConfigurationInternal.h index c7272f3..ead47e5 100644 --- a/SystemConfiguration.fproj/SCNetworkConfigurationInternal.h +++ b/SystemConfiguration.fproj/SCNetworkConfigurationInternal.h @@ -136,6 +136,7 @@ typedef struct { Boolean hidden; CFStringRef location; CFStringRef path; + uint64_t entryID; CFMutableDictionaryRef overrides; Boolean modemIsV92; CFNumberRef type; @@ -195,8 +196,7 @@ SCNetworkInterfacePrivateRef __SCNetworkInterfaceCreatePrivate (CFAllocatorRef allocator, SCNetworkInterfaceRef interface, SCPreferencesRef prefs, - CFStringRef serviceID, - io_string_t path); + CFStringRef serviceID); SCNetworkInterfacePrivateRef _SCBondInterfaceCreatePrivate (CFAllocatorRef allocator, diff --git a/SystemConfiguration.fproj/SCNetworkConfigurationPrivate.h b/SystemConfiguration.fproj/SCNetworkConfigurationPrivate.h index 3998ac9..e04c5cc 100644 --- a/SystemConfiguration.fproj/SCNetworkConfigurationPrivate.h +++ b/SystemConfiguration.fproj/SCNetworkConfigurationPrivate.h @@ -299,6 +299,16 @@ _SCNetworkInterfaceGetIOInterfaceUnit (SCNetworkInterfaceRef interface) __OSX CFStringRef _SCNetworkInterfaceGetIOPath (SCNetworkInterfaceRef interface) __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0); +/*! + @function _SCNetworkInterfaceGetIORegistryEntryID + @discussion Returns the IORegistry entry ID for the interface. + @param interface The network interface. + @result The IORegistry entry ID associated with the interface; + Zero if no entry ID is available. + */ +uint64_t +_SCNetworkInterfaceGetIORegistryEntryID (SCNetworkInterfaceRef interface) __OSX_AVAILABLE_STARTING(__MAC_10_7/*FIXME*/,__IPHONE_5_0); + /*! @function _SCNetworkInterfaceIsBluetoothPAN @discussion Identifies if a network interface is a Bluetooth PAN (GN) device. diff --git a/SystemConfiguration.fproj/SCNetworkInterface.c b/SystemConfiguration.fproj/SCNetworkInterface.c index 5820ad2..6c5fc48 100644 --- a/SystemConfiguration.fproj/SCNetworkInterface.c +++ b/SystemConfiguration.fproj/SCNetworkInterface.c @@ -176,6 +176,7 @@ static SCNetworkInterfacePrivate __kSCNetworkInterfaceIPv4 = { FALSE, // hidden NULL, // location NULL, // path + 0, // entryID NULL, // overrides FALSE, // modemIsV92 NULL, // type @@ -217,6 +218,7 @@ static SCNetworkInterfacePrivate __kSCNetworkInterfaceLoopback = { FALSE, // hidden NULL, // location NULL, // path + 0, // entryID NULL, // overrides FALSE, // modemIsV92 NULL, // type @@ -378,6 +380,9 @@ __SCNetworkInterfaceCopyDescription(CFTypeRef cf) if (interfacePrivate->path != NULL) { CFStringAppendFormat(result, NULL, CFSTR(", path = %@"), interfacePrivate->path); } + if (interfacePrivate->entryID != 0) { + CFStringAppendFormat(result, NULL, CFSTR(", entryID = 0x%llx"), interfacePrivate->entryID); + } if (interfacePrivate->type != NULL) { CFStringAppendFormat(result, NULL, CFSTR(", type = %@"), interfacePrivate->type); } @@ -717,8 +722,7 @@ SCNetworkInterfacePrivateRef __SCNetworkInterfaceCreatePrivate(CFAllocatorRef allocator, SCNetworkInterfaceRef interface, SCPreferencesRef prefs, - CFStringRef serviceID, - io_string_t path) + CFStringRef serviceID) { SCNetworkInterfacePrivateRef interfacePrivate; uint32_t size; @@ -756,9 +760,10 @@ __SCNetworkInterfaceCreatePrivate(CFAllocatorRef allocator, interfacePrivate->addressString = NULL; interfacePrivate->builtin = FALSE; interfacePrivate->configurationAction = NULL; - interfacePrivate->path = (path != NULL) ? CFStringCreateWithCString(NULL, path, kCFStringEncodingUTF8) - : NULL; + interfacePrivate->hidden = FALSE; interfacePrivate->location = NULL; + interfacePrivate->path = NULL; + interfacePrivate->entryID = 0; interfacePrivate->overrides = NULL; interfacePrivate->modemIsV92 = FALSE; interfacePrivate->type = NULL; @@ -857,7 +862,7 @@ _SCBondInterfaceCreatePrivate(CFAllocatorRef allocator, { SCNetworkInterfacePrivateRef interfacePrivate; - interfacePrivate = __SCNetworkInterfaceCreatePrivate(allocator, NULL, NULL, NULL, NULL); + interfacePrivate = __SCNetworkInterfaceCreatePrivate(allocator, NULL, NULL, NULL); if (interfacePrivate == NULL) { return NULL; } @@ -887,7 +892,7 @@ _SCBridgeInterfaceCreatePrivate(CFAllocatorRef allocator, { SCNetworkInterfacePrivateRef interfacePrivate; - interfacePrivate = __SCNetworkInterfaceCreatePrivate(allocator, NULL, NULL, NULL, NULL); + interfacePrivate = __SCNetworkInterfaceCreatePrivate(allocator, NULL, NULL, NULL); if (interfacePrivate == NULL) { return NULL; } @@ -916,7 +921,7 @@ _SCVLANInterfaceCreatePrivate(CFAllocatorRef allocator, { SCNetworkInterfacePrivateRef interfacePrivate; - interfacePrivate = __SCNetworkInterfaceCreatePrivate(allocator, NULL, NULL, NULL, NULL); + interfacePrivate = __SCNetworkInterfaceCreatePrivate(allocator, NULL, NULL, NULL); if (interfacePrivate == NULL) { return NULL; } @@ -2371,6 +2376,7 @@ createInterface(io_registry_entry_t interface, processInterface func) kern_return_t kr; io_string_t path; CFTypeRef val; + uint64_t entryID = 0; kr = IORegistryEntryGetPath(interface, kIOServicePlane, path); if (kr != kIOReturnSuccess) { @@ -2412,7 +2418,16 @@ createInterface(io_registry_entry_t interface, processInterface func) goto done; } - interfacePrivate = __SCNetworkInterfaceCreatePrivate(NULL, NULL, NULL, NULL, path); + /* get the registry entry ID */ + kr = IORegistryEntryGetRegistryEntryID(interface, &entryID); + if (kr != KERN_SUCCESS) { + SCLog(TRUE, LOG_DEBUG, CFSTR("createInterface IORegistryEntryGetRegistryEntryID() failed, kr = 0x%x"), kr); + goto done; + } + + interfacePrivate = __SCNetworkInterfaceCreatePrivate(NULL, NULL, NULL, NULL); + interfacePrivate->path = (path != NULL) ? CFStringCreateWithCString(NULL, path, kCFStringEncodingUTF8) : NULL; + interfacePrivate->entryID = entryID; // configuration [PPP, Modem, DNS, IPv4, IPv6, Proxies, SMB] template overrides val = IORegistryEntrySearchCFProperty(interface, @@ -3386,7 +3401,7 @@ _SCNetworkInterfaceCreateWithEntity(CFAllocatorRef allocator, /* * if device not present on this system */ - interfacePrivate = __SCNetworkInterfaceCreatePrivate(NULL, NULL, NULL, NULL, NULL); + interfacePrivate = __SCNetworkInterfaceCreatePrivate(NULL, NULL, NULL, NULL); interfacePrivate->entity_type = ifType; interfacePrivate->entity_subtype = ifSubType; interfacePrivate->entity_device = (ifDevice != NULL) ? CFStringCreateCopy(NULL, ifDevice) : NULL; @@ -3930,8 +3945,7 @@ SCNetworkInterfaceCreateWithInterface(SCNetworkInterfaceRef child, CFStringRef i parentPrivate = __SCNetworkInterfaceCreatePrivate(NULL, child, childPrivate->prefs, - childPrivate->serviceID, - NULL); + childPrivate->serviceID); if (parentPrivate == NULL) { _SCErrorSet(kSCStatusFailed); return NULL; @@ -6021,6 +6035,15 @@ _SCNetworkInterfaceGetIOPath(SCNetworkInterfaceRef interface) } +uint64_t +_SCNetworkInterfaceGetIORegistryEntryID(SCNetworkInterfaceRef interface) +{ + SCNetworkInterfacePrivateRef interfacePrivate = (SCNetworkInterfacePrivateRef)interface; + + return interfacePrivate->entryID; +} + + Boolean _SCNetworkInterfaceIsBuiltin(SCNetworkInterfaceRef interface) { @@ -6219,7 +6242,7 @@ __SCNetworkInterfaceCreateCopy(CFAllocatorRef allocator, return (SCNetworkInterfacePrivateRef)CFRetain(interface); } - newPrivate = __SCNetworkInterfaceCreatePrivate(NULL, NULL, prefs, serviceID, NULL); + newPrivate = __SCNetworkInterfaceCreatePrivate(NULL, NULL, prefs, serviceID); newPrivate->interface_type = oldPrivate->interface_type; if (oldPrivate->interface != NULL) { newPrivate->interface = (SCNetworkInterfaceRef)__SCNetworkInterfaceCreateCopy(NULL, // allocator @@ -6271,6 +6294,7 @@ __SCNetworkInterfaceCreateCopy(CFAllocatorRef allocator, if (oldPrivate->path != NULL) { newPrivate->path = CFRetain(oldPrivate->path); } + newPrivate->entryID = oldPrivate->entryID; if (oldPrivate->overrides != NULL) { newPrivate->overrides = CFDictionaryCreateMutableCopy(NULL, 0, oldPrivate->overrides); } diff --git a/SystemConfiguration.fproj/dy_framework.c b/SystemConfiguration.fproj/dy_framework.c index 3bfe8e0..e69f9ab 100644 --- a/SystemConfiguration.fproj/dy_framework.c +++ b/SystemConfiguration.fproj/dy_framework.c @@ -63,7 +63,7 @@ __loadIOKit(void) { __private_extern__ CFMutableDictionaryRef -_IOBSDNameMatching(mach_port_t masterPort, unsigned int options, const char *bsdName) +_IOBSDNameMatching(mach_port_t masterPort, uint32_t options, const char *bsdName) { #undef IOBSDNameMatching static typeof (IOBSDNameMatching) *dyfunc = NULL; @@ -218,6 +218,19 @@ _IORegistryEntryGetPath(io_registry_entry_t entry, const io_name_t plane, io_str } +__private_extern__ kern_return_t +_IORegistryEntryGetRegistryEntryID(io_registry_entry_t entry, uint64_t *entryID) +{ + #undef IORegistryEntryGetRegistryEntryID + static typeof (IORegistryEntryGetRegistryEntryID) *dyfunc = NULL; + if (!dyfunc) { + void *image = __loadIOKit(); + if (image) dyfunc = dlsym(image, "IORegistryEntryGetRegistryEntryID"); + } + return dyfunc ? dyfunc(entry, entryID) : KERN_FAILURE; +} + + __private_extern__ CFTypeRef _IORegistryEntrySearchCFProperty(io_registry_entry_t entry, const io_name_t plane, CFStringRef key, CFAllocatorRef allocator, IOOptionBits options) { diff --git a/SystemConfiguration.fproj/dy_framework.h b/SystemConfiguration.fproj/dy_framework.h index e1c928f..6a4359f 100644 --- a/SystemConfiguration.fproj/dy_framework.h +++ b/SystemConfiguration.fproj/dy_framework.h @@ -42,7 +42,7 @@ __BEGIN_DECLS CFMutableDictionaryRef _IOBSDNameMatching ( mach_port_t masterPort, - unsigned int options, + uint32_t options, const char *bsdName ); #define IOBSDNameMatching _IOBSDNameMatching @@ -130,6 +130,13 @@ _IORegistryEntryGetPath ( ); #define IORegistryEntryGetPath _IORegistryEntryGetPath +kern_return_t +_IORegistryEntryGetRegistryEntryID ( + io_registry_entry_t entry, + uint64_t *entryID + ); +#define IORegistryEntryGetRegistryEntryID _IORegistryEntryGetRegistryEntryID + CFTypeRef _IORegistryEntrySearchCFProperty ( io_registry_entry_t entry,