]> git.saurik.com Git - apple/configd.git/commitdiff
configd-395.11.tar.gz mac-os-x-1074 mac-os-x-1075 v395.11
authorApple <opensource@apple.com>
Thu, 10 May 2012 15:23:29 +0000 (15:23 +0000)
committerApple <opensource@apple.com>
Thu, 10 May 2012 15:23:29 +0000 (15:23 +0000)
19 files changed:
Makefile
Plugins/IPMonitor/Info.plist
Plugins/InterfaceNamer/Info.plist
Plugins/InterfaceNamer/ifnamer.c
Plugins/KernelEventMonitor/Info.plist
Plugins/LinkConfiguration/Info.plist
Plugins/Logger/Info-Embedded.plist
Plugins/Logger/Info.plist
Plugins/NetworkIdentification/Info.plist
Plugins/PreferencesMonitor/Info.plist
SCMonitor/Info.plist
SystemConfiguration.fproj/Info-Embedded.plist
SystemConfiguration.fproj/Info.plist
SystemConfiguration.fproj/LinkConfiguration.c
SystemConfiguration.fproj/SCNetworkConfigurationInternal.h
SystemConfiguration.fproj/SCNetworkConfigurationPrivate.h
SystemConfiguration.fproj/SCNetworkInterface.c
SystemConfiguration.fproj/dy_framework.c
SystemConfiguration.fproj/dy_framework.h

index 1102fd323d14e62541b3e00e2059c381effb117d..b3d4dc2949c69cb50c152c3692340fc5f748c7b1 100644 (file)
--- 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
index a29cf26a7b6450f9cb45ab3951a27342b282a7b0..eadcad1bf8c5e9697293a88eaaafb3d9709a43f8 100644 (file)
@@ -15,7 +15,7 @@
        <key>CFBundlePackageType</key>
        <string>BNDL</string>
        <key>CFBundleShortVersionString</key>
-       <string>1.11.2</string>
+       <string>1.11.3</string>
        <key>CFBundleSignature</key>
        <string>????</string>
        <key>CFBundleVersion</key>
index ee235fc2cfd83623a87c9e7ac586200853b06594..d2650f6b8c1d28ac6f2bdda4da9ef5f1f3e333cb 100644 (file)
@@ -17,7 +17,7 @@
        <key>CFBundlePackageType</key>
        <string>BNDL</string>
        <key>CFBundleShortVersionString</key>
-       <string>1.11.2</string>
+       <string>1.11.3</string>
        <key>CFBundleSignature</key>
        <string>????</string>
        <key>CFBundleVersion</key>
index a0d377b7fa9c200b8835d3b4f1eaf2dde254aa7d..ae4d87ab1c6f1445f1a83bc249481d15fcb5c4f1 100644 (file)
 /*
  * Modification History
  *
+ * May 20, 2006                        Joe Liu <joe.liu@apple.com>
+ *                             Allan Nathanson <ajn@apple.com>
+ * - register interface by entryID (and not path)
+ *
  * November 6, 2006            Allan Nathanson <ajn@apple.com>
  *                             Dan Markarian <markarian@apple.com>
  *                             Dieter Siegmund <dieter@apple.com>
 #include <IOKit/IOMessage.h>
 #include <IOKit/network/IONetworkController.h>
 #include <IOKit/network/IONetworkInterface.h>
+#include <IOKit/network/IONetworkStack.h>
 #include <IOKit/usb/USB.h>
 
+#ifdef kIONetworkStackUserCommandKey
+#define        USE_REGISTRY_ENTRY_ID
+#endif
+
+#ifndef        USE_REGISTRY_ENTRY_ID
 // from <IOKit/network/IONetworkStack.h>
-#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;
 
index 146c74e22ded83803c6f897b5f067d3bed0f6c20..2b2602587e91be239d20adef28819e4ddc290d63 100644 (file)
@@ -15,7 +15,7 @@
        <key>CFBundlePackageType</key>
        <string>BNDL</string>
        <key>CFBundleShortVersionString</key>
-       <string>1.11.2</string>
+       <string>1.11.3</string>
        <key>CFBundleSignature</key>
        <string>????</string>
        <key>CFBundleVersion</key>
index 8655cee22dfb4214e3c3e58372ca50cc372c377d..30e9f1d42bf667619ace6f47f39c9d60def15f4c 100644 (file)
@@ -15,7 +15,7 @@
        <key>CFBundlePackageType</key>
        <string>BNDL</string>
        <key>CFBundleShortVersionString</key>
-       <string>1.11.2</string>
+       <string>1.11.3</string>
        <key>CFBundleSignature</key>
        <string>????</string>
        <key>CFBundleVersion</key>
index c0eed0446701e6326ea3e42c3d237884430ecae0..be01e39a05faba8ef0195b6f742929629c9d0738 100644 (file)
@@ -15,7 +15,7 @@
        <key>CFBundlePackageType</key>
        <string>BNDL</string>
        <key>CFBundleShortVersionString</key>
-       <string>1.11.2</string>
+       <string>1.11.3</string>
        <key>CFBundleSignature</key>
        <string>????</string>
        <key>CFBundleVersion</key>
index 1f56695fe0cf0f861682e9c31d1f74b43fd9c192..5247be22d5b486f6fafe000def037e1ee501c20a 100644 (file)
@@ -15,7 +15,7 @@
        <key>CFBundlePackageType</key>
        <string>BNDL</string>
        <key>CFBundleShortVersionString</key>
-       <string>1.11.2</string>
+       <string>1.11.3</string>
        <key>CFBundleSignature</key>
        <string>????</string>
        <key>CFBundleVersion</key>
index b025a55333234eb8701c4587c25537918c00dce0..e8e42f56c4dde71dbd11a5ce058617d54a822df9 100644 (file)
@@ -15,7 +15,7 @@
        <key>CFBundlePackageType</key>
        <string>BNDL</string>
        <key>CFBundleShortVersionString</key>
-       <string>1.11.2</string>
+       <string>1.11.3</string>
        <key>CFBundleSignature</key>
        <string>????</string>
        <key>CFBundleVersion</key>
index 609f4eb01fc11936d70bce03a38fd49886307f6d..bc7fbcb6c40d2052e5471cf831e6af2cb8e148d1 100644 (file)
@@ -15,7 +15,7 @@
        <key>CFBundlePackageType</key>
        <string>BNDL</string>
        <key>CFBundleShortVersionString</key>
-       <string>1.11.2</string>
+       <string>1.11.3</string>
        <key>CFBundleSignature</key>
        <string>????</string>
        <key>CFBundleVersion</key>
index 5a07d4d0b06403040bc5f684f29adae92d71cd92..8789a633c5c3e78fdd3c863197b533e62f446eb4 100644 (file)
@@ -15,7 +15,7 @@
        <key>CFBundlePackageType</key>
        <string>BNDL</string>
        <key>CFBundleShortVersionString</key>
-       <string>1.11.2</string>
+       <string>1.11.3</string>
        <key>CFBundleSignature</key>
        <string>????</string>
        <key>CFBundleVersion</key>
index 40e892977f03826998d1bea2a2c86c338ff19973..e39949325e97e91bdef7bc85ffe9b24715b3412c 100644 (file)
@@ -17,7 +17,7 @@
        <key>CFBundlePackageType</key>
        <string>FMWK</string>
        <key>CFBundleShortVersionString</key>
-       <string>1.11.2</string>
+       <string>1.11.3</string>
        <key>CFBundleSignature</key>
        <string>????</string>
        <key>CFBundleVersion</key>
index 40e892977f03826998d1bea2a2c86c338ff19973..e39949325e97e91bdef7bc85ffe9b24715b3412c 100644 (file)
@@ -17,7 +17,7 @@
        <key>CFBundlePackageType</key>
        <string>FMWK</string>
        <key>CFBundleShortVersionString</key>
-       <string>1.11.2</string>
+       <string>1.11.3</string>
        <key>CFBundleSignature</key>
        <string>????</string>
        <key>CFBundleVersion</key>
index 0d03d7e17e2b7db2a64caf41f04f2141177003b9..85249b035d0db0fe24115dbb4ca7720315e65d57 100644 (file)
@@ -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;
        }
index c7272f39ac8047130b163193ce917a97d795ffc5..ead47e53f55332f3adb9e261c25f8375a6a955fc 100644 (file)
@@ -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,
index 3998ac96cb3833c2a6c917510be466e84d5ec5d7..e04c5ccdbe92bde947da7270c32156f31bf0cbe9 100644 (file)
@@ -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.
index 5820ad27fa5f530d9adda507960b9fa18057691f..6c5fc487a90f16a6261966e8055aeb8f898faa5f 100644 (file)
@@ -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);
        }
index 3bfe8e07c3d0b2c6e7d7ccb37e37b05148433f0f..e69f9aba9781d18ca0290cbb68d635647e8e39eb 100644 (file)
@@ -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)
 {
index e1c928f736f5530f44d6072667d84871440cd17d..6a4359fdb6ccded67ebfcd4def7f595d3a3792c3 100644 (file)
@@ -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,