/*
- * Copyright (c) 2004-2019 Apple Inc. All rights reserved.
+ * Copyright (c) 2004-2020 Apple Inc. All rights reserved.
  *
  * @APPLE_LICENSE_HEADER_START@
  *
 #include <arpa/nameser.h>
 #include <resolv.h>
 #include <notify.h>
-extern uint32_t notify_monitor_file(int token, const char *name, int flags);
+#include <notify_private.h>
 #include <CommonCrypto/CommonDigest.h>
 
 #include <CoreFoundation/CoreFoundation.h>
                return;
        }
 
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wdeprecated"
        status = notify_monitor_file(notify_token, resolver_directory_path, 0);
+#pragma GCC diagnostic pop
        if (status != NOTIFY_STATUS_OK) {
                my_log(LOG_ERR, "notify_monitor_file() failed");
                (void)notify_cancel(notify_token);
        SCDynamicStoreRef       store;
 
        _sc_debug   = TRUE;
-       _sc_log     = FALSE;
+       _sc_log     = kSCLogDestinationFile;
        _sc_verbose = (argc > 1) ? TRUE : FALSE;
 
        store = SCDynamicStoreCreate(NULL, CFSTR("TEST"), NULL, NULL);
 
 #include <netinet/icmp6.h>
 #include <netinet6/in6_var.h>
 #include <netinet6/nd6.h>
-#include <nw/sa_compare.h>
+#include <nw/private.h>
 #include <arpa/inet.h>
 #include <sys/sysctl.h>
 #include <limits.h>
 int
 main(int argc, char **argv)
 {
-    _sc_log     = FALSE;
+    _sc_log     = kSCLogDestinationFile;
 
     S_IPMonitor_debug = kDebugFlag1;
     if (argc > 1) {
 {
     IPv4RouteTestRef * test;
 
-    _sc_log     = FALSE;
+    _sc_log     = kSCLogDestinationFile;
     _sc_verbose = (argc > 1) ? TRUE : FALSE;
     S_IPMonitor_debug = kDebugFlag1 | kDebugFlag2 | kDebugFlag4;
     if (argc > 1) {
 {
     IPv6RouteTestRef * test;
 
-    _sc_log     = FALSE;
+    _sc_log     = kSCLogDestinationFile;
     _sc_verbose = (argc > 1) ? TRUE : FALSE;
     S_IPMonitor_debug = kDebugFlag1 | kDebugFlag2 | kDebugFlag4;
     if (argc > 1) {
 int
 main(int argc, char **argv)
 {
-    _sc_log     = FALSE;
+    _sc_log     = kSCLogDestinationFile;
     _sc_verbose = (argc > 1) ? TRUE : FALSE;
     S_IPMonitor_debug = kDebugFlag1 | kDebugFlag2 | kDebugFlag4;
     if (argc > 1) {
 
 /*
- * Copyright (c) 2011-2017 Apple Inc. All rights reserved.
+ * Copyright (c) 2011-2017, 2020 Apple Inc. All rights reserved.
  *
  * @APPLE_LICENSE_HEADER_START@
  *
        CFDictionaryRef         state_global_ipv4;
        SCDynamicStoreRef       store;
 
-       _sc_log     = FALSE;
+       _sc_log     = kSCLogDestinationFile;
        _sc_verbose = (argc > 1) ? TRUE : FALSE;
 
        store = SCDynamicStoreCreate(NULL, CFSTR("TEST"), NULL, NULL);
 
 /*
- * Copyright (c) 2004-2018 Apple Inc. All rights reserved.
+ * Copyright (c) 2004-2018, 2020 Apple Inc. All rights reserved.
  *
  * @APPLE_LICENSE_HEADER_START@
  *
 
 #ifdef DEBUG
 
-       _sc_log = FALSE;
+       _sc_log = kSCLogDestinationFile;
        if ((argc > 1) && (strcmp(argv[1], "-d") == 0)) {
                _sc_verbose = TRUE;
                argv++;
 
 #else  /* DEBUG */
 
-       _sc_log     = FALSE;
+       _sc_log     = kSCLogDestinationFile;
        _sc_verbose = (argc > 1) ? TRUE : FALSE;
 
        load_hostname((argc > 1) ? TRUE : FALSE);
 
        CFStringRef             serviceID;
        SCDynamicStoreRef       store;
 
-       _sc_log = FALSE;
+       _sc_log = kSCLogDestinationFile;
        if ((argc > 1) && (strcmp(argv[1], "-d") == 0)) {
                _sc_verbose = TRUE;
                argv++;
 
 #else  /* DEBUG */
 
-       _sc_log     = FALSE;
+       _sc_log     = kSCLogDestinationFile;
        _sc_verbose = (argc > 1) ? TRUE : FALSE;
 
        load_smb_configuration((argc > 1) ? TRUE : FALSE);
 
 }
 
 
+#pragma mark -
+#pragma mark Internet Sharing configuration support
+
+
+#if    TARGET_OS_OSX
+
+static SCPreferencesRef        nat_configuration       = NULL;         // com.apple.nat.plist
+static SCPreferencesRef        nat_preferences         = NULL;         // preferences.plist
+
+
+static void
+sharingConfigurationClose(void)
+{
+    if (nat_configuration != NULL) {
+       CFRelease(nat_configuration);
+       nat_configuration = NULL;
+    }
+
+    if (nat_preferences != NULL) {
+       CFRelease(nat_preferences);
+       nat_preferences = NULL;
+    }
+
+    return;
+}
+
+
+static Boolean
+sharingConfigurationUsesInterface(CFStringRef bsdName, Boolean keepOpen)
+{
+    CFDictionaryRef    config;
+    Boolean            isShared        = FALSE;
+
+    if (nat_configuration == NULL) {
+       nat_configuration = SCPreferencesCreate(NULL, CFSTR(MY_PLUGIN_NAME ":sharingConfigurationUsesInterface"), CFSTR("com.apple.nat.plist"));
+       if (nat_configuration == NULL) {
+           return FALSE;
+       }
+    }
+
+    config = SCPreferencesGetValue(nat_configuration, CFSTR("NAT"));
+    if (isA_CFDictionary(config)) {
+       CFBooleanRef    bVal                    = NULL;
+       Boolean         enabled                 = FALSE;
+       CFStringRef     sharedFromServiceID     = NULL;
+       CFArrayRef      sharedToInterfaces      = NULL;
+
+       if (CFDictionaryGetValueIfPresent(config,
+                                         CFSTR("Enabled"),
+                                         (const void **)&bVal) &&
+           isA_CFBoolean(bVal)) {
+           enabled = CFBooleanGetValue(bVal);
+       }
+
+       if (enabled &&
+           CFDictionaryGetValueIfPresent(config,
+                                         CFSTR("SharingDevices"),
+                                         (const void **)&sharedToInterfaces) &&
+           isA_CFArray(sharedToInterfaces)) {
+           CFIndex     n;
+
+           // if "To computers using" interfaces configured
+           n = CFArrayGetCount(sharedToInterfaces);
+           for (CFIndex i = 0; i < n; i++) {
+               CFStringRef     sharedToInterface_bsdName;
+
+               sharedToInterface_bsdName = CFArrayGetValueAtIndex(sharedToInterfaces, i);
+               if (_SC_CFEqual(bsdName, sharedToInterface_bsdName)) {
+                   isShared = TRUE;
+                   break;
+               }
+           }
+       }
+
+       if (enabled &&
+           !isShared &&
+           CFDictionaryGetValueIfPresent(config,
+                                         CFSTR("PrimaryService"),
+                                         (const void **)&sharedFromServiceID) &&
+           isA_CFString(sharedFromServiceID)) {
+           if (nat_preferences == NULL) {
+               nat_preferences = SCPreferencesCreateCompanion(nat_configuration, NULL);
+           }
+           if (nat_preferences != NULL) {
+               SCNetworkServiceRef     sharedFromService;
+
+               // if "Share your connection from" service configured
+               sharedFromService = SCNetworkServiceCopy(nat_preferences, sharedFromServiceID);
+               if (sharedFromService != NULL) {
+                   CFStringRef                 sharedFromService_bsdName;
+                   SCNetworkInterfaceRef       sharedFromService_interface;
+
+                   sharedFromService_interface = SCNetworkServiceGetInterface(sharedFromService);
+                   sharedFromService_bsdName = SCNetworkInterfaceGetBSDName(sharedFromService_interface);
+                   isShared = _SC_CFEqual(bsdName, sharedFromService_bsdName);
+                   CFRelease(sharedFromService);
+               }
+           }
+       }
+    }
+
+    if (!keepOpen) {
+       sharingConfigurationClose();
+    }
+
+    return isShared;
+}
+
+#endif // TARGET_OS_OSX
+
+
 #pragma mark -
 #pragma mark Interface monitoring (e.g. watch for "detach")
 
 #pragma unused(messageArgument)
     switch (messageType) {
        case kIOMessageServiceIsTerminated : {          // if [watched] interface yanked
-           SCNetworkInterfaceRef       remove          = NULL;
+           SCNetworkInterfaceRef       remove;
            CFDataRef                   watched         = (CFDataRef)refCon;
            WatchedInfo                 *watchedInfo    = (WatchedInfo *)(void *)CFDataGetBytePtr(watched);
 
            remove = watchedInfo->interface;
-           if (!_SCNetworkInterfaceIsBuiltin(remove) &&
-               _SCNetworkInterfaceIsApplePreconfigured(remove)) {
-               // if not built-in *and* pre-configured, retain for cleanup
-               CFRetain(remove);
-           } else {
+           if (_SCNetworkInterfaceIsBuiltin(remove)) {
+               // if built-in, keep
+               remove = NULL;
+           } else if (!_SCNetworkInterfaceIsApplePreconfigured(remove)) {
+               // if not pre-configured, keep
                remove = NULL;
+           } else {
+               // if not built-in *and* pre-configured
+               CFRetain(remove);
            }
 
+#if    TARGET_OS_OSX
+           if (remove != NULL) {
+               CFStringRef     bsdName;
+
+               bsdName = SCNetworkInterfaceGetBSDName(remove);
+               if ((bsdName != NULL) && sharingConfigurationUsesInterface(bsdName, FALSE)) {
+                   // if referenced in the Internet Sharing configuration, keep
+                   CFRelease(remove);
+                   remove = NULL;
+               }
+           }
+#endif // TARGET_OS_OSX
+
            CFRetain(watched);
            watchedInfo->callback(watched, messageType, messageArgument);
            watcherRelease(watched);
            CFRelease(watched);
 
            if (remove != NULL) {
-               // if interface is not built-in *and* pre-configured
                SC_log(LOG_INFO, "Interface released unit %@ (from database)",
                       _SCNetworkInterfaceGetIOInterfaceUnit(remove));
                removeInterface(S_dblist, remove, NULL);
                CFNumberGetValue(vidNum, kCFNumberIntType, &vid) &&
                (vid == kIOUSBAppleVendorID)) {
                // if [hidden] Apple interface
+
+#if    TARGET_OS_OSX
+               if (sharingConfigurationUsesInterface(name, TRUE)) {
+                   // do not remove interfaces referenced in the sharing configuration
+                   continue;
+               }
+#endif // TARGET_OS_OSX
+
                goto remove;
            }
        }
        }
     }
 
+#if    TARGET_OS_OSX
+    sharingConfigurationClose();
+#endif // TARGET_OS_OSX
+
     return;
 }
 
     CFArrayRef         interfaces_all;
     CFIndex            n;
 
-    _sc_log     = FALSE;
+    _sc_log     = kSCLogDestinationFile;
     _sc_verbose = (argc > 1) ? TRUE : FALSE;
 
     bundle = CFBundleGetMainBundle();
 int
 main(int argc, char ** argv)
 {
-    _sc_log     = FALSE;
+    _sc_log     = kSCLogDestinationFile;
     _sc_verbose = (argc > 1) ? TRUE : FALSE;
 
     captureBusy();
 
 /*
- * Copyright (c) 2000-2019 Apple Inc. All rights reserved.
+ * Copyright (c) 2000-2020 Apple Inc. All rights reserved.
  *
  * @APPLE_LICENSE_HEADER_START@
  *
 int
 main(int argc, char **argv)
 {
-       _sc_log     = FALSE;
+       _sc_log     = kSCLogDestinationFile;
        _sc_verbose = (argc > 1) ? TRUE : FALSE;
 
        load_KernelEventMonitor(CFBundleGetMainBundle(), (argc > 1) ? TRUE : FALSE);
 
 /*
- * Copyright (c) 2002-2007, 2011, 2013, 2015-2019 Apple Inc. All rights reserved.
+ * Copyright (c) 2002-2007, 2011, 2013, 2015-2020 Apple Inc. All rights reserved.
  *
  * @APPLE_LICENSE_HEADER_START@
  *
 {
        SCPreferencesRef        prefs;
 
-       _sc_log     = FALSE;
+       _sc_log     = kSCLogDestinationFile;
        _sc_verbose = (argc > 1) ? TRUE : FALSE;
 
        prefs = SCPreferencesCreate(NULL, CFSTR("linkconfig"), NULL);
 
 int
 main(int argc, char **argv)
 {
-       _sc_log     = FALSE;
+       _sc_log     = kSCLogDestinationFile;
        _sc_verbose = (argc > 1) ? TRUE : FALSE;
 
        load_PreferencesMonitor(CFBundleGetMainBundle(), (argc > 1) ? TRUE : FALSE);
 
 int
 main(int argc, char **argv)
 {
-       _sc_log     = FALSE;
+       _sc_log     = kSCLogDestinationFile;
        _sc_verbose = (argc > 1) ? TRUE : FALSE;
 
        load_QoSMarking(CFBundleGetMainBundle(), (argc > 1) ? TRUE : FALSE);
 
 /*
- * Copyright (c) 2013, 2015-2018 Apple Inc. All rights reserved.
+ * Copyright (c) 2013, 2015-2020 Apple Inc. All rights reserved.
  *
  * @APPLE_LICENSE_HEADER_START@
  *
 int
 main(int argc, char **argv)
 {
-       _sc_log     = FALSE;
+       _sc_log     = kSCLogDestinationFile;
        _sc_verbose = (argc > 1) ? TRUE : FALSE;
 
        load_SimulatorSupport(CFBundleGetMainBundle(), (argc > 1) ? TRUE : FALSE);
 
 {
        MyType *newOne = (MyType *)malloc(sizeof(MyType));
 
-       _sc_log     = FALSE;
+       _sc_log     = kSCLogDestinationFile;
        _sc_verbose = (argc > 1) ? TRUE : FALSE;
 
        memset(newOne, 0, sizeof(*newOne));
 
 /*
- * Copyright (c) 2015, 2018 Apple Inc. All rights reserved.
+ * Copyright (c) 2015, 2018, 2020 Apple Inc. All rights reserved.
  *
  * @APPLE_LICENSE_HEADER_START@
  *
  */
 
 #import <TargetConditionals.h>
+
+#if    !defined(USING_PUBLIC_SDK)
 @import Foundation;
 @import SystemConfiguration;
 @import SystemConfiguration_Private;
+#else  // !defined(USING_PUBLIC_SDK)
+#include <Foundation/Foundation.h>
+#include <SystemConfiguration/SystemConfiguration.h>
+#endif // !defined(USING_PUBLIC_SDK)
+
+#if    TARGET_OS_MACCATALYST
+#pragma message "Building for IOS_MAC"
+#endif
 
 #define MY_APP_NAME    CFSTR("SCTestObjC")
 #define TARGET_HOST    "www.apple.com"
 
 
-#if    !TARGET_OS_SIMULATOR
+#if    !TARGET_OS_SIMULATOR && !defined(USING_PUBLIC_SDK)
 static void
 test_SCDynamicStore()
 {
        CFRelease(dict);
        CFRelease(key);
 }
-#endif // !TARGET_OS_SIMULATOR
+#endif // !TARGET_OS_SIMULATOR && !defined(USING_PUBLIC_SDK)
 
-#if    !TARGET_OS_SIMULATOR
+#if    !TARGET_OS_SIMULATOR && !defined(USING_PUBLIC_SDK)
 static void
 test_SCNetworkConfiguration()
 {
        
        CFRelease(interfaces);
 }
-#endif // !TARGET_OS_SIMULATOR
+#endif // !TARGET_OS_SIMULATOR && !defined(USING_PUBLIC_SDK)
 
 void
 test_SCNetworkReachability()
        CFRelease(target);
 }
 
-#if    !TARGET_OS_SIMULATOR
+#if    !TARGET_OS_SIMULATOR && !defined(USING_PUBLIC_SDK)
 static void
 test_SCPreferences()
 {
        CFRelease(prefs);
        CFRelease(services);
 }
-#endif // !TARGET_OS_SIMULATOR
+#endif // !TARGET_OS_SIMULATOR && !defined(USING_PUBLIC_SDK)
 
 void
 SCTest()
 {
 
-#if    !TARGET_OS_SIMULATOR
+#if    !TARGET_OS_SIMULATOR && !defined(USING_PUBLIC_SDK)
        test_SCDynamicStore();
-#endif // !TARGET_OS_SIMULATOR
+#endif // !TARGET_OS_SIMULATOR && !defined(USING_PUBLIC_SDK)
 
-#if    !TARGET_OS_SIMULATOR
+#if    !TARGET_OS_SIMULATOR && !defined(USING_PUBLIC_SDK)
        test_SCNetworkConfiguration();
-#endif // !TARGET_OS_SIMULATOR
+#endif // !TARGET_OS_SIMULATOR && !defined(USING_PUBLIC_SDK)
 
        test_SCNetworkReachability();
 
-#if    !TARGET_OS_SIMULATOR
+#if    !TARGET_OS_SIMULATOR && !defined(USING_PUBLIC_SDK)
        test_SCPreferences();
-#endif // !TARGET_OS_SIMULATOR
+#endif // !TARGET_OS_SIMULATOR && !defined(USING_PUBLIC_SDK)
 
 }
 
-int main(int argc, const char * argv[]) {
+int
+main(int argc, const char * argv[]) {
 #pragma unused(argc, argv)
+
+#if    TARGET_OS_MACCATALYST
+#if    !defined(USING_PUBLIC_SDK)
+#include <CoreFoundation/CFPriv.h>
+#else  // !defined(USING_PUBLIC_SDK)
+extern Boolean _CFMZEnabled(void);
+#endif // !defined(USING_PUBLIC_SDK)
+       if (_CFMZEnabled()) {
+               NSLog(@"*** IOS_MAC ***\n");
+       }
+#endif
+
        @autoreleasepool {
                SCTest();
        }
 
 /*
- * Copyright (c) 2004-2019 Apple Inc. All rights reserved.
+ * Copyright (c) 2004-2020 Apple Inc. All rights reserved.
  *
  * @APPLE_LICENSE_HEADER_START@
  *
        if (__SCPreferencesUsingDefaultPrefs(prefs)) {
                ni_prefs = NULL;
        } else {
-               ni_prefs = __SCPreferencesCreateNIPrefsFromPrefs(prefs);
+               ni_prefs = SCPreferencesCreateCompanion(prefs, INTERFACES_DEFAULT_CONFIG);
        }
 
        context.bonds = CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks);
 
 /*
- * Copyright (c) 2009-2018 Apple Inc. All rights reserved.
+ * Copyright (c) 2009-2018, 2020 Apple Inc. All rights reserved.
  *
  * @APPLE_LICENSE_HEADER_START@
  *
        if (__SCPreferencesUsingDefaultPrefs(prefs)) {
                ni_prefs = NULL;
        } else {
-               ni_prefs = __SCPreferencesCreateNIPrefsFromPrefs(prefs);
+               ni_prefs = SCPreferencesCreateCompanion(prefs, INTERFACES_DEFAULT_CONFIG);
        }
+
        context.bridges = CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks);
        context.prefs = prefs;
        context.ni_prefs = ni_prefs;
                                        kSCPrefVirtualNetworkInterfaces,
                                        kSCNetworkInterfaceTypeBridge);
        dict = SCPreferencesPathGetValue(prefs, path);
+       CFRelease(path);
        if (isA_CFDictionary(dict)) {
                my_CFDictionaryApplyFunction(dict, add_configured_interface, &context);
        }
-       CFRelease(path);
+
        if (ni_prefs != NULL) {
                CFRelease(ni_prefs);
        }
 
  */
 
 #include <mach/mach.h>
+#include <mach/mach_time.h>
 #include <mach/mach_error.h>
 #include <servers/bootstrap.h>
 #include <pthread.h>
 #include <sys/time.h>
+
+#define OS_LOG_PACK_SPI
 #include <os/log.h>
 #include <os/log_private.h>
 
 #define INSTALL_ENVIRONMENT    "__OSINSTALL_ENVIRONMENT"
 
 /* framework variables */
-int    _sc_debug       = FALSE;        /* non-zero if debugging enabled */
-int    _sc_verbose     = FALSE;        /* non-zero if verbose logging enabled */
-int    _sc_log         = 1;            /* 0 if SC messages should be written to stdout/stderr,
-                                          1 if SC messages should be logged w/os_log(3),
-                                          2 if SC messages should be logged AND written to stdout/stderr
-                                          3 if SC messages should be logged AND written to stdout/stderr (w/o timestamp) */
+int                    _sc_debug       = FALSE;        /* non-zero if debugging enabled */
+int                    _sc_verbose     = FALSE;        /* non-zero if verbose logging enabled */
+_SCLogDestination      _sc_log         = kSCLogDestinationDefault;
 
 
 #pragma mark -
 
 
 static void
-__SCPrint(FILE *stream, CFStringRef formatString, va_list formatArguments, Boolean trace, Boolean addNL)
+__SCPrint(FILE *stream, CFStringRef formatString, va_list formatArguments, Boolean addTime, Boolean addNL)
 {
        char            *line;
        CFStringRef     str;
        }
 
        pthread_mutex_lock(&lock);
-       if (trace) {
+       if (addTime) {
                struct tm       tm_now;
                struct timeval  tv_now;
 
 }
 
 
+/*
+ * NOTE: We need to keep this function in place (for a least a while) to ensure
+ *       that any [old] code that was using an earlier version of SC_log() will
+ *       have the needed support code to perform the actual logging.  Newly
+ *       compiled code uses the new/replacement _SC_log_send() function.
+ */
 void
 __SC_Log(int level, CFStringRef format_CF, os_log_t log, os_log_type_t type, const char *format, ...)
 {
        va_list         args_log;
        va_list         args_print;
 
-       /*
-        * Note: The following are the expected values for _sc_log
-        *
-        * 0 if SC messages should be written to stdout/stderr
-        * 1 if SC messages should be logged w/os_log(3)
-        * 2 if SC messages should be written to stdout/stderr AND logged
-        * 3 if SC messages should be logged AND written to stdout/stderr (w/o timestamp)
-        */
-
-       if (_sc_log > 0) {
+       if (_sc_log > kSCLogDestinationFile) {
                do_log = TRUE;                  // log requested
                va_start(args_log, format);
 
-               if (_sc_log > 1) {
+               if (_sc_log >= kSCLogDestinationBoth) {
                        do_print = TRUE;        // log AND print requested
                        va_copy(args_print, args_log);
                }
                __SCPrint(stdout,
                          format_CF,
                          args_print,
-                         (_sc_log == 2),       // trace
-                         TRUE);                // add newline
+                         (_sc_log == kSCLogDestinationBoth),   // trace
+                         TRUE);                                // add newline
                va_end(args_print);
        }
 
 }
 
 
+Boolean
+__SC_log_enabled(int level, os_log_t log, os_log_type_t type)
+{
+       if (os_log_type_enabled(log, type)) {
+               return TRUE;
+       }
+
+       if (_sc_log != kSCLogDestinationDefault) {
+               // if os_log'ing not enabled and the messages is targeted to stdout/stderr
+               if (level < LOG_INFO) {
+                       // if not LOG_INFO/LOG_DEBUG message, print
+                       return TRUE;
+               } else if ((level == LOG_INFO) && _sc_verbose) {
+                       // if LOG_INFO and _sc_verbose, print
+                       return TRUE;
+               } else if (_sc_debug) {
+                       // if _sc_debug, print
+                       return TRUE;
+               }
+       }
+
+       if (_SC_isInstallEnvironment()) {
+               // if OSInstaller environment
+               if (level < LOG_INFO) {
+                       // if not LOG_INFO/LOG_DEBUG message, syslog
+                       return TRUE;
+               } else if ((level == LOG_INFO) && _SC_isAppleInternal()) {
+                       // if LOG_INFO and internal, syslog
+                       return TRUE;
+               } else if (_sc_debug) {
+                       // if _sc_debug, syslog
+                       return TRUE;
+               }
+       }
+
+       return FALSE;
+}
+
+
+void
+__SC_log_send(int level, os_log_t log, os_log_type_t type, os_log_pack_t pack)
+{
+       Boolean         addTime         = (_sc_log == kSCLogDestinationBoth);
+       char            buffer[256];
+       const char      *buffer_ptr     = buffer;
+       char            *composed       = NULL;
+       Boolean         do_print        = FALSE;
+       Boolean         do_syslog       = FALSE;
+
+       if (_sc_log > kSCLogDestinationFile) {
+               if (_SC_isInstallEnvironment()) {
+                       /*
+                        * os_log(3) messages are not persisted in the
+                        * install environment.  So, we use syslog(3)
+                        * instead.
+                        */
+                       do_syslog = TRUE;
+               }
+
+               if (_sc_log >= kSCLogDestinationBoth) {
+                       do_print = TRUE;        // log AND print requested
+               }
+       } else {
+               do_print = TRUE;                // print requested
+       }
+
+       if (!do_print && !do_syslog) {
+               // if only os_log requested
+               os_log_pack_send(pack, log, type);
+       } else if (do_print && !do_syslog) {
+               // if os_log and print requested
+               composed = os_log_pack_send_and_compose(pack, log, type, buffer, sizeof(buffer));
+       } else {
+               // if print-only and/or syslog requested
+               mach_get_times(NULL, &pack->olp_continuous_time, &pack->olp_wall_time);
+               composed = os_log_pack_compose(pack, log, type, buffer, sizeof(buffer));
+       }
+
+       if (do_print &&
+           (
+            (level < LOG_INFO)                         ||      // print most messages
+            ((level == LOG_INFO) && _sc_verbose)       ||      // with _sc_verbose, include LOG_INFO
+            _sc_debug                                          // with _sc_debug, include LOG_DEBUG
+           )
+          ) {
+               // if printing
+               pthread_mutex_lock(&lock);
+               if (addTime) {
+                       struct tm       tm_now;
+                       struct timeval  tv_now;
+
+                       tv_now.tv_sec = (time_t)&pack->olp_wall_time.tv_sec;
+                       tv_now.tv_usec = (suseconds_t)((uint64_t)&pack->olp_wall_time.tv_nsec / NSEC_PER_USEC);
+                       (void)localtime_r(&tv_now.tv_sec, &tm_now);
+                       (void)fprintf(stdout, "%2d:%02d:%02d.%03d ",
+                                     tm_now.tm_hour, tm_now.tm_min, tm_now.tm_sec, tv_now.tv_usec / 1000);
+               }
+               (void)fprintf(stdout, "%s\n", composed);
+               fflush (stdout);
+               pthread_mutex_unlock(&lock);
+       }
+
+       if (do_syslog &&
+           (
+            (level < LOG_INFO) ||
+            ((level == LOG_INFO) && _SC_isAppleInternal()) ||
+            _sc_debug
+           )
+          ) {
+               // if [install/upgrade] syslog'ing
+               syslog(level | LOG_INSTALL, "%s", composed);
+       }
+
+       if (composed != buffer_ptr) {
+               free(composed);
+       }
+
+       return;
+}
+
+
 void
 SCLog(Boolean condition, int level, CFStringRef formatString, ...)
 {
         * 3 if SC messages should be logged AND written to stdout/stderr (w/o timestamp)
         */
 
-       if (_sc_log > 0) {
+       if (_sc_log > kSCLogDestinationFile) {
                log = TRUE;             // log requested
                va_start(formatArguments, formatString);
 
-               if (_sc_log > 1) {
+               if (_sc_log >= kSCLogDestinationBoth) {
                        print = TRUE;   // log AND print requested
                        va_copy(formatArguments_print, formatArguments);
                }
                __SCPrint((LOG_PRI(level) > LOG_NOTICE) ? stderr : stdout,
                          formatString,
                          formatArguments_print,
-                         (_sc_log == 2),       // trace
-                         TRUE);                // add newline
+                         (_sc_log == kSCLogDestinationBoth),   // trace
+                         TRUE);                                // add newline
                va_end(formatArguments_print);
        }
 
 
 #pragma mark SCNetworkConfiguration (internal)
 
 
+
 Boolean
-__SCNetworkConfigurationBackup                         (SCPreferencesRef               prefs)          SPI_AVAILABLE(macos(10.15.4), ios(13.4), tvos(13.4), watchos(6.2), bridgeos(4.0));
+__SCNetworkConfigurationBackup                 (SCPreferencesRef       prefs,
+                                                CFStringRef            suffix,
+                                                SCPreferencesRef       relativeTo);
+
 
 
 #pragma mark -
 
  */
 
 
-#define        USE_SC_LOG_OR_PRINT     1               // use '_sc_log' to control os_log, printf
-
 #include "SCNetworkConfigurationInternal.h"
 #include "SCPreferencesInternal.h"
 #include <IOKit/IOBSD.h>
 
 
+#define        logDetails      (_sc_log == kSCLogDestinationDefault) || _sc_debug
+
+
 static Boolean
 savePreferences(SCPreferencesRef       prefs,
                CFStringRef             save_prefsID,
 
 __private_extern__
 Boolean
-__SCNetworkConfigurationBackup(SCPreferencesRef prefs)
+__SCNetworkConfigurationBackup(SCPreferencesRef prefs, CFStringRef suffix, SCPreferencesRef relativeTo)
 {
-       Boolean         ok;
-       CFStringRef     save_prefsID;
-       struct tm       tm_now;
-       struct timeval  tv_now;
-
-       SC_log(LOG_NOTICE, "creating [configuration] backup");
-
-       (void)gettimeofday(&tv_now, NULL);
-       (void)localtime_r(&tv_now.tv_sec, &tm_now);
-       save_prefsID = CFStringCreateWithFormat(NULL,
-                                                NULL,
-                                                CFSTR("preferences-%4d-%02d-%02d-%02d%02d%02d.plist"),
-                                                tm_now.tm_year + 1900,
-                                                tm_now.tm_mon + 1,
-                                                tm_now.tm_mday,
-                                                tm_now.tm_hour,
-                                                tm_now.tm_min,
-                                                tm_now.tm_sec);
-       ok = savePreferences(prefs, save_prefsID, CFSTR(""), FALSE, NULL, NULL);
-       CFRelease(save_prefsID);
+       SCPreferencesRef        backup;
+       CFMutableStringRef      backupPrefsID;
+       Boolean                 ok              = FALSE;
+       CFPropertyListRef       plist;
+       CFRange                 range;
+       SCPreferencesPrivateRef sourcePrivate   = (SCPreferencesPrivateRef)prefs;
+       CFStringRef             sourcePrefsID;
+
+       SC_log(LOG_NOTICE, "creating [%@] backup", suffix);
+
+       sourcePrefsID = (sourcePrivate->prefsID != NULL) ? sourcePrivate->prefsID : PREFS_DEFAULT_CONFIG;
+       backupPrefsID = CFStringCreateMutableCopy(NULL, 0, sourcePrefsID);
+       if (CFStringFindWithOptions(backupPrefsID,
+                                   CFSTR("/"),
+                                   CFRangeMake(0, CFStringGetLength(backupPrefsID)),
+                                   kCFCompareBackwards,
+                                   &range)) {
+               // if slash, remove path prefix
+               range.length   = range.location + 1;
+               range.location = 0;
+               CFStringReplace(backupPrefsID, range, CFSTR(""));
+       }
+       CFStringInsert(backupPrefsID,
+                      CFStringGetLength(backupPrefsID) - sizeof(".plist") + 1,
+                      CFSTR("-"));
+       CFStringInsert(backupPrefsID,
+                      CFStringGetLength(backupPrefsID) - sizeof(".plist") + 1,
+                      suffix);
+       backup = SCPreferencesCreateCompanion(relativeTo, backupPrefsID);
+       CFRelease(backupPrefsID);
+
+       SC_log(LOG_INFO,
+              "__SCNetworkConfigurationBackup()"
+              "\n  relativeTo = %@"
+              "\n  prefs      = %@"
+              "\n  backup     = %@",
+              relativeTo,
+              prefs,
+              backup);
+
+       if (backup != NULL) {
+               plist = SCPreferencesPathGetValue(prefs, CFSTR("/"));
+               SCPreferencesPathSetValue(backup, CFSTR("/"), plist);
+               ok = SCPreferencesCommitChanges(backup);
+               CFRelease(backup);
+       }
+
        return ok;
 }
 
     done :
 
        if (prefs_added) {
-//             if (ok && (prefs_p != NULL)) {
-//                     *prefs_p = CFRetain(prefs);
-//             }
+               // per the expected usage, even if we on-the-fly create
+               // a [preferences.plist] companion it is not returned to
+               // the caller.  So, just release.
                CFRelease(prefs);
        }
 
        CFArrayRef              interfaces;
        CFMutableArrayRef       interfaces_thin;
        CFIndex                 n;
+#if    TARGET_OS_OSX
        CFDictionaryRef         nat_config;
        SCPreferencesRef        nat_prefs;
+#endif // TARGET_OS_OSX
        CFArrayRef              services;
        int                     updated         = 0;
 
 
                        if (bsdName == NULL) {
                                // if no interface name
-                               if ((_sc_log == 1) || _sc_debug) {
+                               if (logDetails) {
                                        SC_log(LOG_INFO,
                                               "skipping service : %@ : %@ (no interface)",
                                               SCNetworkServiceGetServiceID(service),
                                thin = "effectively hidden";
                        } else {
                                // if not HiddenConfiguration
-                               if ((_sc_log == 1) || _sc_debug) {
+                               if (logDetails) {
                                        SC_log(LOG_INFO,
                                               "skipping service : %@ : %@ : %@ (not hidden)",
                                                SCNetworkServiceGetServiceID(service),
                        conflict = serviceMatchesTemplate(prefs, service);
                        if (conflict != NULL) {
                                // if any part of the service's configuration was changed
-                               if ((_sc_log == 1) || _sc_debug) {
+                               if (logDetails) {
                                        SC_log(LOG_INFO,
                                               "skipping service : %@ : %@ : %@ (%s, non-default, %@)",
                                               SCNetworkServiceGetServiceID(service),
                                continue;
                        }
 
-                       if ((_sc_log == 1) || _sc_debug) {
+                       if (logDetails) {
                                SC_log(LOG_INFO, "candidate interface : %@ (%s)", bsdName, thin);
                        }
 
                                bsdName = SCNetworkInterfaceGetBSDName(member);
                                if ((bsdName != NULL) &&
                                    thinRemove(interfaces_thin, bsdName)) {
-                                       if ((_sc_log == 1) || _sc_debug) {
+                                       if (logDetails) {
                                                SC_log(LOG_INFO, "skipping interface : %@ (bond member)", bsdName);
                                        }
                                }
                                bsdName = SCNetworkInterfaceGetBSDName(member);
                                if ((bsdName != NULL) &&
                                    thinRemove(interfaces_thin, bsdName)) {
-                                       if ((_sc_log == 1) || _sc_debug) {
+                                       if (logDetails) {
                                                SC_log(LOG_INFO, "skipping interface : %@ (bridge member)", bsdName);
                                        }
                                }
                        bsdName = SCNetworkInterfaceGetBSDName(physicalInterface);
                        if ((bsdName != NULL) &&
                            thinRemove(interfaces_thin, bsdName)) {
-                               if ((_sc_log == 1) || _sc_debug) {
+                               if (logDetails) {
                                        SC_log(LOG_INFO, "skipping interface : %@ (vlan physical)", bsdName);
                                }
                        }
 
        // remove any "shared" interfaces from the list
 
+#if    TARGET_OS_OSX
        nat_prefs = SCPreferencesCreateCompanion(prefs, CFSTR("com.apple.nat.plist"));
        nat_config = SCPreferencesGetValue(nat_prefs, CFSTR("NAT"));
        if (isA_CFDictionary(nat_config)) {
+               CFBooleanRef    bVal            = NULL;
+               Boolean         enabled         = FALSE;
                CFStringRef     sharedFrom      = NULL;
                CFArrayRef      sharedTo        = NULL;
 
                if (CFDictionaryGetValueIfPresent(nat_config,
+                                                 CFSTR("Enabled"),
+                                                 (const void **)&bVal) &&
+                   isA_CFBoolean(bVal)) {
+                   enabled = CFBooleanGetValue(bVal);
+               }
+
+               if (enabled &&
+                   CFDictionaryGetValueIfPresent(nat_config,
                                                  CFSTR("PrimaryService"),
                                                  (const void **)&sharedFrom) &&
                        isA_CFString(sharedFrom)) {
                                bsdName = SCNetworkInterfaceGetBSDName(interface);
                                if ((bsdName != NULL) &&
                                    thinRemove(interfaces_thin, bsdName)) {
-                                       if ((_sc_log == 1) || _sc_debug) {
+                                       if (logDetails) {
                                                SC_log(LOG_INFO, "skipping interface : %@ (Share your connection from)", bsdName);
                                        }
                                }
                        }
                }
 
-          if (CFDictionaryGetValueIfPresent(nat_config,
-                                            CFSTR("SharingDevices"),
-                                            (const void **)&sharedTo) &&
-                  isA_CFArray(sharedTo)) {
-                  // if "To computers using" interfaces configured
-                  n = CFArrayGetCount(sharedTo);
-                  for (CFIndex i = 0; i < n; i++) {
-                          bsdName = CFArrayGetValueAtIndex(sharedTo, i);
-                          if (thinRemove(interfaces_thin, bsdName)) {
-                                  if ((_sc_log == 1) || _sc_debug) {
-                                          SC_log(LOG_INFO, "skipping interface : %@ (To computers using)", bsdName);
-                                  }
-                          }
-                  }
-          }
+               if (enabled &&
+                   CFDictionaryGetValueIfPresent(nat_config,
+                                                 CFSTR("SharingDevices"),
+                                                 (const void **)&sharedTo) &&
+                   isA_CFArray(sharedTo)) {
+                       // if "To computers using" interfaces configured
+                       n = CFArrayGetCount(sharedTo);
+                       for (CFIndex i = 0; i < n; i++) {
+                               bsdName = CFArrayGetValueAtIndex(sharedTo, i);
+                               if (thinRemove(interfaces_thin, bsdName)) {
+                                       if (logDetails) {
+                                               SC_log(LOG_INFO, "skipping interface : %@ (To computers using)", bsdName);
+                                       }
+                               }
+                       }
+               }
        }
        CFRelease(nat_prefs);
+#endif // TARGET_OS_OSX
 
        // thin preferences.plist
        n = (services != NULL) ? CFArrayGetCount(services) : 0;
                        }
 
                        // remove this service associated with a "thinned" interface
-                       if ((_sc_log == 1) || _sc_verbose) {
+                       if (logDetails || _sc_verbose) {
                                SC_log(LOG_INFO,
                                       "thinned network service : %@ : %@ : %@",
                                       SCNetworkServiceGetServiceID(service),
                }
 
                if (updated > 0) {
-                       if ((_sc_log == 1) || _sc_debug) {
+                       if (logDetails) {
                                SC_log(LOG_NOTICE,
                                       "Updating \"preferences.plist\" (thinned %d service%s)",
                                       updated,
                        bsdName = CFDictionaryGetValue(if_dict, CFSTR(kIOBSDNameKey));
                        if (isThin(interfaces_thin, bsdName)) {
                                if (CFDictionaryContainsKey(if_dict, CFSTR(kSCNetworkInterfaceActive))) {
-                                       if ((_sc_log == 1) || _sc_debug) {
+                                       if (logDetails) {
                                                SC_log(LOG_INFO, "skipping interface : %@ (active)", bsdName);
                                        }
                                } else {
                                        // remove this "thinned" interface
-                                       if ((_sc_log == 1) || _sc_debug || _sc_verbose) {
+                                       if (logDetails || _sc_verbose) {
                                                SC_log(LOG_INFO, "thinned network interface : %@", bsdName);
                                        }
                                        updated++;
                CFRelease(interfaces_new);
 
                if (updated > 0) {
-                       if ((_sc_log == 1) || _sc_debug) {
+                       if (logDetails) {
                                SC_log(LOG_INFO,
                                       "Updating \"NetworkInterfaces.plist\" (thinned %d interface%s)",
                                       updated,
                        // check if serviceID already known/processed
                        if (CFSetContainsValue(known, serviceID)) {
                                // if duplicate/removed service, remove from serviceOrder
-                               if ((_sc_log == 1) || _sc_debug) {
+                               if (logDetails) {
                                        SC_log(LOG_NOTICE,
                                               "set: %@, removing serviceID %@ (duplicate/removed)",
                                               setID,
                        service = SCNetworkServiceCopy(prefs, serviceID);
                        if (service == NULL) {
                                // if no service, remove from serviceOrder
-                               if ((_sc_log == 1) || _sc_debug) {
+                               if (logDetails) {
                                        SC_log(LOG_NOTICE,
                                               "set: %@, removing serviceID %@ (no service)",
                                               setID,
 
                        if (!__SCNetworkServiceExists(service)) {
                                // if service already removed, remove from serviceOrder
-                               if ((_sc_log == 1) || _sc_debug) {
+                               if (logDetails) {
                                        SC_log(LOG_NOTICE,
                                               "set: %@, removing serviceID %@ (service already removed)",
                                               setID,
 
        CFIndex length = 0;
 
        if (!isA_CFString(bsdName)) {
-               SC_log(LOG_DEBUG, "no BSD name");
+               SC_log(LOG_DEBUG, "No BSD name");
                goto done;
        }
 
        }
        bsdName = CFDictionaryGetValue(interface_entity, CFSTR(kSCNetworkInterfaceBSDName));
        if (!isA_CFString(bsdName)) {
-               SC_log(LOG_INFO, "No BSD name");
+               SC_log(LOG_DEBUG, "No BSD name");
                goto done;
        }
        hidden = CFDictionaryGetValue(interface_entity, kSCNetworkInterfaceHiddenConfigurationKey);
                SC_log(LOG_INFO, "No interfaces");
                return NULL;
        }
+
        mappingBSDToInterface = CFDictionaryCreateMutable(NULL, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
 
        for (CFIndex idx = 0; idx < count; idx++) {
 
                bsdName = SCNetworkInterfaceGetBSDName(interface);
                if (!isA_CFString(bsdName)) {
-                       SC_log(LOG_INFO, "No BSD name");
+                       SC_log(LOG_DEBUG, "No BSD name");
                        continue;
                }
                CFDictionaryAddValue(mappingBSDToInterface, bsdName, interface);
        }
+
        if (CFDictionaryGetCount(mappingBSDToInterface) == 0) {
                CFRelease(mappingBSDToInterface);
                mappingBSDToInterface = NULL;
 
        CFMutableArrayRef migrationPaths = NULL;
        CFURLRef prefs;
 
-       if (_SC_isInstallEnvironment()) {
-               _sc_debug = 1;
-       }
-       _SCNetworkConfigurationCopyMigrationPathsWithBaseURL(NULL, &prefs, &interfaces);
-
        migrationPaths = CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks);
-       CFArrayInsertValueAtIndex(migrationPaths, PREFERENCES_PLIST_INDEX, prefs);
-       CFArrayInsertValueAtIndex(migrationPaths, NETWORK_INTERFACES_PLIST_INDEX, interfaces);
-
+       _SCNetworkConfigurationCopyMigrationPathsWithBaseURL(NULL, &prefs, &interfaces);
+       CFArrayAppendValue(migrationPaths, prefs);
+       CFArrayAppendValue(migrationPaths, interfaces);
        CFRelease(prefs);
        CFRelease(interfaces);
+
+       SC_log(LOG_INFO,
+              "_SCNetworkConfigurationCopyMigrationPaths() called%s"
+              "\n  options = %@"
+              "\n  paths   = %@",
+              _SC_isInstallEnvironment() ? " (INSTALLER ENVIRONMENT)" : "",
+              options,
+              migrationPaths);
+
        return migrationPaths;
 }
 
                SC_log(LOG_NOTICE, "Cannot get file system representation for url: %@", configPathURL);
        } else {
                if ((remove(configPathString) != 0) && (errno != ENOENT)) {
-                       SC_log(LOG_INFO, "remove(\"%s\") failed: %s", configPathString, strerror(errno));
+                       SC_log(LOG_NOTICE, "remove(\"%s\") failed: %s", configPathString, strerror(errno));
                }
        }
        CFRelease(configPathURL);
                SC_log(LOG_NOTICE, "Cannot get file system representation for url: %@", configNetworkInterfacesPathURL);
        } else {
                if ((remove(configNetworkInterfacesPathString) != 0) && (errno != ENOENT)) {
-                       SC_log(LOG_INFO, "remove(\"%s\") failed: %s", configNetworkInterfacesPathString, strerror(errno));
+                       SC_log(LOG_NOTICE, "remove(\"%s\") failed: %s", configNetworkInterfacesPathString, strerror(errno));
                }
        }
        CFRelease(configNetworkInterfacesPathURL);
 _SCNetworkConfigurationMakePathIfNeeded(CFURLRef pathURL)
 {
        char    *c;
-       mode_t  newmask;
        char    path[PATH_MAX];
-       char    thepath[PATH_MAX];
-       CFIndex slen=0;
-       struct stat sb;
-       Boolean success = FALSE;
+       Boolean success         = FALSE;
 
        if (!CFURLGetFileSystemRepresentation(pathURL, TRUE, (UInt8 *)path, sizeof(path))) {
                SC_log(LOG_NOTICE, "Cannot get file system representation for url: %@", pathURL);
                return success;
        }
-       SC_log(LOG_INFO, "creating path: %s", path);
-
-       newmask = S_IRWXU | S_IRGRP | S_IROTH | S_IXGRP | S_IXOTH;
 
-       slen = strlen(path);
+       SC_log(LOG_INFO, "creating path: %s", path);
 
-       strlcpy(thepath, path, slen+1);
-       c = thepath;
-       if (*c == '/')
-               c++;
-       for(; !success; c++){
+       c = path;
+       if (*c == '/') {
+               c++;    // skip leading /
+       }
+       for(; !success; c++) {
                if ((*c == '/') || (*c == '\0')){
-                       if (*c == '\0')
+                       if (*c == '\0') {
                                success = TRUE;
-                       else
+                       } else {
                                *c = '\0';
-                       if (mkdir(thepath, newmask)){
-                               if (errno == EEXIST || errno == EISDIR){
-                                       if (stat(thepath, &sb) < 0){
-                                               SC_log(LOG_ERR, "stat returned value < 0");
-                                               break;
-                                       }
-                               } else {
-                                       SC_log(LOG_ERR, "received error: %s", strerror(errno));
+                       }
+                       if (mkdir(path, (S_IRWXU | S_IRGRP | S_IROTH | S_IXGRP | S_IXOTH)) != 0) {
+                               if ((errno != EEXIST) && (errno != EISDIR)) {
+                                       SC_log(LOG_NOTICE, "mkdir(%s) failed: %s", path, strerror(errno));
                                        break;
                                }
                        }
                        *c = '/';
                }
        }
+
        return success;
 }
 
-static SCPreferencesRef
-__SCNetworkCreateDefaultPref(CFStringRef prefsID)
+static void
+__SCNetworkPopulateDefaultPrefs(SCPreferencesRef prefs)
 {
        SCNetworkSetRef         currentSet;
        CFStringRef             model;
-       SCPreferencesRef        prefs;
        CFNumberRef             version;
 
-       prefs = SCPreferencesCreate(NULL, PLUGIN_ID, prefsID);
-       if (prefs == NULL) {
-               return NULL;
-       }
+       SC_log(LOG_INFO,
+              "Populating preferences.plist"
+              "\n  %@",
+              prefs);
 
        currentSet = SCNetworkSetCopyCurrent(prefs);
        if (currentSet == NULL) {
                SCPreferencesSetValue(prefs, MODEL, model);
        }
 
-       version = SCPreferencesGetValue(prefs, MODEL);
+       version = SCPreferencesGetValue(prefs, kSCPrefVersion);
        if (version == NULL) {
                const int       new_version     = NETWORK_CONFIGURATION_VERSION;
 
                CFRelease(version);
        }
 
-       return prefs;
+       return;
 }
 
 __private_extern__
                return;
        }
 
+       SC_log(LOG_INFO,
+              "Populating NetworkInterfaces.plist"
+              "\n  %@",
+              ni_prefs);
+
        networkInterfaces = __SCNetworkInterfaceCopyAll_IONetworkInterface(TRUE);
        if (networkInterfaces == NULL) {
-               SC_log(LOG_NOTICE, "networkInterfaces is NULL");
+               SC_log(LOG_NOTICE, "Cannot populate NetworkInterfaces.plist, no network interfaces");
                return;
        }
 
                SCPreferencesSetValue(ni_prefs, MODEL, model);
        }
 
-       version = SCPreferencesGetValue(ni_prefs, MODEL);
+       version = SCPreferencesGetValue(ni_prefs, kSCPrefVersion);
        if (version == NULL) {
                const int       new_version     = NETWORK_CONFIGURATION_VERSION;
 
        CFURLRef sourceDirConfig = NULL;
        CFURLRef targetDirConfig = NULL;
 
-       if (_SC_isInstallEnvironment()) {
-               _sc_debug = 1;
-       }
+       SC_log(LOG_INFO,
+              "_SCNetworkConfigurationPerformMigration() called%s"
+              "\n  sourceDir  = %@"
+              "\n  currentDir = %@"
+              "\n  targetDir  = %@"
+              "\n  options    = %@",
+              _SC_isInstallEnvironment() ? " (INSTALLER ENVIRONMENT)" : "",
+              sourceDir,
+              currentDir,
+              targetDir,
+              options);
 
        if ((sourceDir != NULL) && !CFURLHasDirectoryPath(sourceDir)) {
-               SC_log(LOG_INFO, "sourceDir is not a directory: %@", sourceDir);
+               SC_log(LOG_NOTICE, "Migration source is not a directory: %@", sourceDir);
                goto done;
        }
 
        if ((currentDir != NULL) && !CFURLHasDirectoryPath(currentDir)) {
-               SC_log(LOG_INFO, "currentDir is not a directory: %@", currentDir);
+               SC_log(LOG_NOTICE, "Migration current is not a directory: %@", currentDir);
                goto done;
        }
 
        if ((targetDir != NULL) && !CFURLHasDirectoryPath(targetDir)) {
-               SC_log(LOG_INFO, "targetDir is not a directory: %@", targetDir);
+               SC_log(LOG_NOTICE, "Migration target is not a directory: %@", targetDir);
                goto done;
        }
 
        // Both sourceDir and currentDir cannot be NULL because NULL value indicates using current system
        if (sourceDir == NULL && currentDir == NULL) {
-               SC_log(LOG_INFO, "Both sourceDir and currentDir are NULL");
+               SC_log(LOG_NOTICE, "Both migration source and current are NULL");
                goto done;
        }
 
                                                                              TRUE,
                                                                              targetDir);
        }
-       // Source directory cannot be the same as Target Directory
+       // Source directory cannot be the same as target directory
        if (CFEqual(sourceDirConfig, targetDirConfig)) {
-               SC_log(LOG_INFO, "Source directory cannot be the same as target directory");
+               SC_log(LOG_NOTICE, "Source directory cannot be the same as target directory");
                goto done;
        }
 
        if ((currentDirConfig == NULL) || !CFEqual(currentDirConfig, targetDirConfig)) {
                if (!_SCNetworkConfigurationMakePathIfNeeded(targetDirConfig)) {
-                       SC_log(LOG_INFO, "Could not create target directory");
+                       SC_log(LOG_NOTICE, "Could not create target directory");
                        goto done;
                }
 
                if (!SCNetworkConfigurationCopyConfigurationFiles(currentDirConfig, targetDirConfig)) {
-                       SC_log(LOG_INFO, "Could not copy configuration files from \"%@\" to \"%@\"",
+                       SC_log(LOG_NOTICE, "Could not copy configuration files from \"%@\" to \"%@\"",
                               currentDirConfig,
                               targetDirConfig);
                } else if (currentDirConfig != NULL) {
 
        // If both source and current configurations point to current system, then no migration needs to be done.
        if ((currentDirConfig != NULL) && CFEqual(sourceDirConfig, currentDirConfig)) {
-               SC_log(LOG_INFO, "No migration needed, source and current configurations point to same path");
+               SC_log(LOG_NOTICE, "No migration needed, source and current configurations have the same path");
                migrationComplete = TRUE;
        } else {
                migrationComplete = _SCNetworkConfigurationMigrateConfiguration(sourceDirConfig, targetDirConfig);
        } else {
                SC_log(LOG_NOTICE, "Migration failed: %s", SCErrorString(SCError()));
 
-               // If migration fails, then remove configuration files from target config if they are
+               // If migration fails, then remove configuration files from target config if they were
                // copied from the current directory
                if (removeTargetOnFailure) {
                        _SCNetworkConfigurationRemoveConfigurationFiles(targetDirConfig);
        if (targetDirConfig != NULL) {
                CFRelease(targetDirConfig);
        }
+
        return paths;
 }
 
        struct stat statStruct = {0, };
 
        if (filePath == NULL) {
-               SC_log(LOG_DEBUG, "filePath is NULL");
+               SC_log(LOG_NOTICE, "_SCNetworkConfigurationMigrateIsFilePresent: No path");
                goto done;
        }
 
 
        statResult = stat(filePathStr, &statStruct);
        if (statResult == 0) {
-               fileExists = TRUE;
+               SCPreferencesRef        prefs;
+               CFStringRef             prefsID;
+
+               if (statStruct.st_size == 0) {
+                       SC_log(LOG_INFO, "_SCNetworkConfigurationMigrateIsFilePresent: empty .plist: %@", filePath);    // REMOVE
+                       goto done;
+               }
+
+               prefsID = CFStringCreateWithCString(NULL, filePathStr, kCFStringEncodingUTF8);
+               prefs = SCPreferencesCreate(NULL, PLUGIN_ID, prefsID);
+               CFRelease(prefsID);
+               if (prefs == NULL) {
+                       SC_log(LOG_NOTICE, "_SCNetworkConfigurationMigrateIsFilePresent: bad .plist: %@", filePath);
+                       goto done;
+               }
+
+               if (!__SCPreferencesIsEmpty(prefs)) {
+                       // if non-empty .plist
+                       fileExists = TRUE;
+               } else {
+                       SC_log(LOG_NOTICE, "_SCNetworkConfigurationMigrateIsFilePresent: effectively empty .plist: %@", filePath);
+               }
+
+               CFRelease(prefs);
        }
 done:
        return fileExists;
 }
 
 static Boolean
-__SCNetworkConfigurationMigrateConfigurationFilesPresent(CFURLRef baseURL, CFArrayRef* migrationPaths)
+__SCNetworkConfigurationMigrateConfigurationFilesPresent(CFURLRef baseURL, CFArrayRef* migrationPaths, Boolean expected)
 {
        Boolean configFilesPresent = FALSE;
        CFIndex count;
        CFURLRef prefs;
 
        if (baseURL == NULL) {
-               SC_log(LOG_INFO, "No base migration URL");
+               SC_log(LOG_NOTICE, "No base migration URL");
                goto done;
        }
 
-       _SCNetworkConfigurationCopyMigrationPathsWithBaseURL(baseURL, &prefs, &interfaces);
-
        migrationPathsMutable = CFArrayCreateMutable(kCFAllocatorDefault, 0, &kCFTypeArrayCallBacks);
-       CFArrayInsertValueAtIndex(migrationPathsMutable, PREFERENCES_PLIST_INDEX, prefs);
-       CFArrayInsertValueAtIndex(migrationPathsMutable, NETWORK_INTERFACES_PLIST_INDEX, interfaces);
-
+       _SCNetworkConfigurationCopyMigrationPathsWithBaseURL(baseURL, &prefs, &interfaces);
+       CFArrayAppendValue(migrationPathsMutable, prefs);
+       CFArrayAppendValue(migrationPathsMutable, interfaces);
        CFRelease(prefs);
        CFRelease(interfaces);
 
        *migrationPaths = migrationPathsMutable;
 
-       if ((*migrationPaths == NULL) ||
-           ((count = CFArrayGetCount(*migrationPaths)) == 0)) {
-               SC_log(LOG_INFO, "No migration paths");
-               goto done;
-       }
-
+       count = CFArrayGetCount(*migrationPaths);
        for (CFIndex idx = 0; idx < count; idx++) {
+               Boolean         present;
+
                filePath = CFArrayGetValueAtIndex(*migrationPaths, idx);
-               if (!_SCNetworkConfigurationMigrateIsFilePresent(filePath)) {
-                       SC_log(LOG_INFO, "Required migration file not present: %@", filePath);
+               present = _SCNetworkConfigurationMigrateIsFilePresent(filePath);
+               if (!present) {
+                       if (expected) {
+                               SC_log(LOG_INFO, "Expected migration file not present: %@", filePath);
+                       }
                        goto done;
                }
        }
 
        interfaceList = __SCNetworkInterfaceCopyStoredWithPreferences(ni_prefs);
        if (interfaceList == NULL) {
-               SC_log(LOG_INFO, "No interfaces");
                goto done;
        }
 
                cfMaxUnit = NULL;
                interface = CFArrayGetValueAtIndex(ifList, idx);
 
-               if (isA_SCNetworkInterface(interface) == NULL) {
+               if (!isA_SCNetworkInterface(interface)) {
                        continue;
                }
 
        SCNetworkInterfaceRef targetInterface;
 
        sourceBuiltinInterfaces = _SCNetworkInterfaceCopyInterfacesFilteredByBuiltinWithPreferences(sourcePrefs, TRUE);
-       if (isA_CFArray(sourceBuiltinInterfaces) == NULL) {
+       if (!isA_CFArray(sourceBuiltinInterfaces)) {
                SC_log(LOG_INFO, "No source built-in interfaces");
                goto done;
        }
        sourceBuiltinInterfaceCount = CFArrayGetCount(sourceBuiltinInterfaces);
 
        targetBuiltinInterfaces = _SCNetworkInterfaceCopyInterfacesFilteredByBuiltinWithPreferences(targetPrefs, TRUE);
-       if (isA_CFArray(targetBuiltinInterfaces) == NULL) {
+       if (!isA_CFArray(targetBuiltinInterfaces)) {
                SC_log(LOG_INFO, "No target built-in interfaces");
                goto done;
        }
-       targetBuiltinInterfaceCount = CFArrayGetCount(targetBuiltinInterfaces);
 
        // Builtin Mapping will try to map all source interfaces into target interfaces
        for (CFIndex idx = 0; idx < sourceBuiltinInterfaceCount; idx++) {
+               Boolean         matched = FALSE;
+
                sourceInterface = CFArrayGetValueAtIndex(sourceBuiltinInterfaces, idx);
+               targetBuiltinInterfaceCount = CFArrayGetCount(targetBuiltinInterfaces);
+
+               for (CFIndex idx2 = 0; idx2 < targetBuiltinInterfaceCount; idx2++) {
+                       CFDataRef       sourceHardwareAddress;
+                       CFDataRef       targetHardwareAddress;
+
+                       targetInterface = CFArrayGetValueAtIndex(targetBuiltinInterfaces, idx2);
+                       sourceHardwareAddress = _SCNetworkInterfaceGetHardwareAddress(sourceInterface);
+                       targetHardwareAddress = _SCNetworkInterfaceGetHardwareAddress(targetInterface);
+                       if (_SC_CFEqual(sourceHardwareAddress, targetHardwareAddress)) {
+                               if (builtinMapping == NULL) {
+                                       builtinMapping = CFDictionaryCreateMutable(NULL, 0,
+                                                                                  &kCFTypeDictionaryKeyCallBacks,
+                                                                                  &kCFTypeDictionaryValueCallBacks);
+                               }
+                               CFDictionaryAddValue(builtinMapping, sourceInterface, targetInterface);
+                               CFArrayRemoveValueAtIndex(targetBuiltinInterfaces, idx2);
+                               matched = TRUE;
+                               break;
+                       }
+               }
+               if (matched) {
+                       // proceed to next source interface
+                       continue;
+               }
+
                for (CFIndex idx2 = 0; idx2 < targetBuiltinInterfaceCount; idx2++) {
                        targetInterface = CFArrayGetValueAtIndex(targetBuiltinInterfaces, idx2);
 
                                break;
                        }
                }
-               targetBuiltinInterfaceCount = CFArrayGetCount(targetBuiltinInterfaces);
        }
 
 done:
        CFNumberRef type;
 
        sourceExternalInterfaces = _SCNetworkInterfaceCopyInterfacesFilteredByBuiltinWithPreferences(sourcePref, FALSE);
-       if (isA_CFArray(sourceExternalInterfaces) == NULL) {
+       if (!isA_CFArray(sourceExternalInterfaces)) {
                SC_log(LOG_INFO, "No source external interfaces");
                goto done;
        }
        }
 
        targetExternalInterfaces = _SCNetworkInterfaceCopyInterfacesFilteredByBuiltinWithPreferences(targetPrefs, FALSE);
-       if (isA_CFArray(targetExternalInterfaces) == NULL) {
+       if (!isA_CFArray(targetExternalInterfaces)) {
                SC_log(LOG_INFO, "No target external interfaces");
                goto done;
        }
 
        // Map all external interfaces which exist in both source and target
        for (CFIndex idx = 0; idx < sourceExternalInterfaceCount; idx++) {
+               Boolean         matched = FALSE;
+
                sourceInterface = CFArrayGetValueAtIndex(sourceExternalInterfaces, idx);
                targetExternalInterfaceCount = CFArrayGetCount(targetExternalInterfaces);
                currentInterfaceUnit = NULL;
 
                for (CFIndex idx2 = 0; idx2 < targetExternalInterfaceCount; idx2++) {
-                       targetInterface = CFArrayGetValueAtIndex(targetExternalInterfaces, idx2);
+                       CFDataRef       sourceHardwareAddress;
+                       CFDataRef       targetHardwareAddress;
 
-                       if (_SCNetworkConfigurationIsInterfaceNamerMappable(sourceInterface, targetInterface, TRUE)) {
+                       targetInterface = CFArrayGetValueAtIndex(targetExternalInterfaces, idx2);
+                       sourceHardwareAddress = _SCNetworkInterfaceGetHardwareAddress(sourceInterface);
+                       targetHardwareAddress = _SCNetworkInterfaceGetHardwareAddress(targetInterface);
+                       if (_SC_CFEqual(sourceHardwareAddress, targetHardwareAddress)) {
                                CFDictionaryAddValue(externalMapping, sourceInterface, targetInterface);
                                CFArrayRemoveValueAtIndex(targetExternalInterfaces, idx2);
+                               matched = TRUE;
                                break;
                        }
                }
+               if (matched) {
+                       // proceed to next source interface
+                       continue;
+               }
 
-               if (!CFDictionaryContainsKey(externalMapping, sourceInterface)) {
-                       // Create new mappings for external source interfaces which don't exist in the target
-                       type = _SCNetworkInterfaceGetIOInterfaceType(sourceInterface);
+               for (CFIndex idx2 = 0; idx2 < targetExternalInterfaceCount; idx2++) {
+                       targetInterface = CFArrayGetValueAtIndex(targetExternalInterfaces, idx2);
 
-                       cfMaxTargetUnit = CFDictionaryGetValue(interfaceTypeToMaxUnitMapping, type);
-                       if (cfMaxTargetUnit != NULL) {
-                               CFNumberGetValue(cfMaxTargetUnit, kCFNumberIntType, &maxTargetUnit);
-                               newTargetUnit = maxTargetUnit + 1;
-                       } else {
-                               newTargetUnit = 0;
+                       if (_SCNetworkConfigurationIsInterfaceNamerMappable(sourceInterface, targetInterface, TRUE)) {
+                               CFDictionaryAddValue(externalMapping, sourceInterface, targetInterface);
+                               CFArrayRemoveValueAtIndex(targetExternalInterfaces, idx2);
+                               matched = TRUE;
+                               break;
                        }
+               }
+               if (matched) {
+                       // proceed to next source interface
+                       continue;
+               }
 
-                       cfMaxTargetUnit = CFNumberCreate(NULL, kCFNumberIntType, &newTargetUnit);
-                       CFDictionarySetValue(interfaceTypeToMaxUnitMapping, type, cfMaxTargetUnit);
+               // Create new mappings for external source interfaces which don't exist in the target
+               type = _SCNetworkInterfaceGetIOInterfaceType(sourceInterface);
 
-                       targetInterface = (SCNetworkInterfaceRef)__SCNetworkInterfaceCreateCopy(NULL, sourceInterface, NULL, NULL);
+               cfMaxTargetUnit = CFDictionaryGetValue(interfaceTypeToMaxUnitMapping, type);
+               if (cfMaxTargetUnit != NULL) {
+                       CFNumberGetValue(cfMaxTargetUnit, kCFNumberIntType, &maxTargetUnit);
+                       newTargetUnit = maxTargetUnit + 1;
+               } else {
+                       newTargetUnit = 0;
+               }
 
-                       SC_log(LOG_DEBUG, "sourceInterface: %p, target Interface: %p", sourceInterface, targetInterface);
+               cfMaxTargetUnit = CFNumberCreate(NULL, kCFNumberIntType, &newTargetUnit);
+               CFDictionarySetValue(interfaceTypeToMaxUnitMapping, type, cfMaxTargetUnit);
 
-                       currentInterfaceUnit = _SCNetworkInterfaceGetIOInterfaceUnit(targetInterface);
-                       if (!isA_CFNumber(currentInterfaceUnit) ||
-                           !CFEqual(currentInterfaceUnit, cfMaxTargetUnit)) {
-                               // Update the interface unit
-                               __SCNetworkInterfaceSetIOInterfaceUnit(targetInterface, cfMaxTargetUnit);
-                       }
+               targetInterface = (SCNetworkInterfaceRef)__SCNetworkInterfaceCreateCopy(NULL, sourceInterface, NULL, NULL);
 
-                       CFDictionaryAddValue(externalMapping, sourceInterface, targetInterface);
+               SC_log(LOG_INFO, "sourceInterface: %p, target Interface: %p", sourceInterface, targetInterface);
 
-                       CFRelease(targetInterface);
-                       targetInterface = NULL;
-                       CFRelease(cfMaxTargetUnit);
-                       cfMaxTargetUnit = NULL;
+               currentInterfaceUnit = _SCNetworkInterfaceGetIOInterfaceUnit(targetInterface);
+               if (!isA_CFNumber(currentInterfaceUnit) ||
+                   !CFEqual(currentInterfaceUnit, cfMaxTargetUnit)) {
+                       // Update the interface unit
+                       __SCNetworkInterfaceSetIOInterfaceUnit(targetInterface, cfMaxTargetUnit);
                }
+
+               CFDictionaryAddValue(externalMapping, sourceInterface, targetInterface);
+
+               CFRelease(targetInterface);
+               targetInterface = NULL;
+               CFRelease(cfMaxTargetUnit);
+               cfMaxTargetUnit = NULL;
+
        }
 done:
        if (sourceExternalInterfaces != NULL) {
                    (((bsdNameToBondServices != NULL) && !CFDictionaryContainsKey(bsdNameToBondServices, bsdName))) &&
                    (((bsdNameToVLANServices != NULL) && !CFDictionaryContainsKey(bsdNameToVLANServices, bsdName)))) {
                        // Not a virtual interface
-                       SC_log(LOG_INFO, "No real interface with BSD name (%@) for service", bsdName);
+                       SC_log(LOG_NOTICE,
+                              "No real interface with BSD name (%@) for service",
+                              bsdName);
 
                        if (repair) {
                                CFArrayAppendValue(interfaceToBeRemoved, serviceInterface);
        serviceInterfaceUserDefinedName = __SCNetworkInterfaceGetUserDefinedName(serviceInterface);
 
        if (!__SCNetworkConfigurationInterfaceNameIsEquiv(interfaceUserDefinedName, serviceInterfaceUserDefinedName)) {
-               SC_log(LOG_INFO, "Interface user defined name (%@) doesn't match service/interface user defined name: %@",
+               SC_log(LOG_NOTICE,
+                      "Interface user defined name (%@) doesn't match service/interface user defined name: %@",
                       interfaceUserDefinedName,
                       serviceInterfaceUserDefinedName);
                *ctx->isValid = FALSE;
                // Check if the service interface name is set to localized key
                if (isA_CFArray(interfacePreserveServiceInformation) != NULL &&
                    __SCNetworkInterfaceMatchesName(interfaceUserDefinedName, serviceInterfaceUserDefinedName)) {
-                       SC_log(LOG_NOTICE, "serviceInterfaceUserDefinedName: %@ is the localized key for interface name: %@", serviceInterfaceUserDefinedName, interfaceUserDefinedName);
+                       SC_log(LOG_NOTICE,
+                              "serviceInterfaceUserDefinedName: %@ is the localized key for interface name: %@",
+                              serviceInterfaceUserDefinedName,
+                              interfaceUserDefinedName);
                        CFArrayAppendValue(interfacePreserveServiceInformation, serviceInterface);
                }
                // Add service interface to the interfaceToBeReplaced list
 
        mappingBSDNameToInterface = __SCNetworkInterfaceCreateMappingUsingBSDName(interfaces);
        CFRelease(interfaces);
-       if (isA_CFDictionary(mappingBSDNameToInterface) == NULL) {
+       if (!isA_CFDictionary(mappingBSDNameToInterface)) {
                goto done;
        }
 
        interfaces = __SCNetworkServiceCopyAllInterfaces(pref);
        if (interfaces == NULL) {
-               SC_log(LOG_INFO, "No interfaces");
+               SC_log(LOG_NOTICE, "No [service] interfaces");
                goto done;
        }
        mappingServiceBSDNameToInterface = __SCNetworkInterfaceCreateMappingUsingBSDName(interfaces);
        CFRelease(interfaces);
-       if (isA_CFDictionary(mappingServiceBSDNameToInterface) == NULL) {
+       if (!isA_CFDictionary(mappingServiceBSDNameToInterface)) {
                goto done;
        }
 
                interface = CFArrayGetValueAtIndex(interfacesWithoutService, idx);
 
                if (!__SCNetworkServiceCreate(pref, interface, NULL)) {
-                       SC_log(LOG_INFO, "Could not add service for interface: %@", interface);
+                       SC_log(LOG_NOTICE, "Could not create service for interface: %@", interface);
                        success = FALSE;
                }
        }
        }
        service = SCNetworkServiceCreate(prefs, interface);
        if (service == NULL) {
-               SC_log(LOG_INFO, "Could not create new service");
+               SC_log(LOG_NOTICE, "Could not create new service");
                goto done;
        }
 
        if (!SCNetworkServiceEstablishDefaultConfiguration(service)) {
+               SC_log(LOG_NOTICE, "SCNetworkServiceEstablishDefaultConfiguration() failed");
                SCNetworkServiceRemove(service);
-               SC_log(LOG_INFO, "SCNetworkServiceEstablishDefaultConfiguration() failed");
                goto done;
        }
 
        // Add service to current set
        currentSet = SCNetworkSetCopyCurrent(prefs);
        if (currentSet == NULL) {
+               SC_log(LOG_NOTICE, "Could not find current set");
                SCNetworkServiceRemove(service);
-               SC_log(LOG_INFO, "Could not find current set");
                goto done;
        }
 
        if (!SCNetworkSetAddService(currentSet, service)) {
+               SC_log(LOG_NOTICE,  "Could not add service to current set");
                SCNetworkServiceRemove(service);
-               SC_log(LOG_INFO,  "Could not add service to current set");
                goto done;
        }
 
                return FALSE;
        }
        // Backup current preferences before making changes
-       __SCNetworkConfigurationBackup(prefs);
+       __SCNetworkConfigurationBackup(prefs, CFSTR("pre-repair"), prefs);
 
        serviceList = SCNetworkServiceCopyAll(prefs);
        CFArrayApplyFunction(serviceList, CFRangeMake(0, CFArrayGetCount(serviceList)), create_bsd_name_service_protocol_mapping, context);
        }
 
        if (CFArrayGetCount(memberInterfacesMutable) == 0) {
-               SC_log(LOG_INFO, "Removing invalid bridge configuration: %@", bridge);
+               SC_log(LOG_NOTICE, "Removing bridge w/no member interfaces: %@", bridge);
                SCBridgeInterfaceRemove(bridge);
        } else {
                SCBridgeInterfaceSetMemberInterfaces(bridge, memberInterfacesMutable);
        }
 
        if (CFArrayGetCount(memberInterfacesMutable) == 0) {
-               SC_log(LOG_INFO, "Removing invalid bond configuration: %@", bond);
+               SC_log(LOG_NOTICE, "Removing bond w/no member interfaces: %@", bond);
                SCBondInterfaceRemove(bond);
        } else {
                SCBondInterfaceSetMemberInterfaces(bond, memberInterfacesMutable);
 
 done:
        if (!isValid) {
-               SC_log(LOG_INFO, "Removing invalid VLAN configuration: %@", vlan);
+               SC_log(LOG_NOTICE, "Removing VLAN w/no physical interface: %@", vlan);
                SCVLANInterfaceRemove(vlan);
        }
 }
                        repairConfiguration = CFBooleanGetValue(repair);
                }
        }
+
+       SC_log(LOG_INFO,
+              "%sbypassing system interfaces for %@",
+              _SCNetworkConfigurationBypassSystemInterfaces(prefs) ? "" : "not ",
+              prefs);
+
        if (!_SCNetworkConfigurationBypassSystemInterfaces(prefs)) {
                _SCNetworkConfigurationSetBypassSystemInterfaces(prefs, TRUE);
                revertBypassSystemInterfaces = TRUE;
        }
-       /*
 
+       /*
         Check the validity by:
         - Comparing if the models are the same
         */
        model = SCPreferencesGetValue(prefs, MODEL);
+       if (!isA_CFString(model)) {
+               SC_log(LOG_INFO,
+                      "Configuration validity check: no \"Model\" property in preferences.plist"
+                      "\n  %@",
+                      prefs);
+       }
        ni_model = SCPreferencesGetValue(ni_prefs, MODEL);
-
-       if (isA_CFString(model) == NULL || isA_CFString(ni_model) == NULL || CFStringCompare(model, ni_model, 0) != kCFCompareEqualTo) {
+       if (!isA_CFString(ni_model)) {
+               SC_log(LOG_INFO,
+                      "Configuration validity check: no \"Model\" property in NetworkInterfaces.plist"
+                      "\n  %@",
+                      ni_prefs);
+       }
+       if (isA_CFString(model) && isA_CFString(ni_model) && !CFEqual(model, ni_model)) {
                isValid = FALSE;
-               SC_log(LOG_INFO, "Model names do not match in preferences.plist and NetworkInterfaces.plist");
+               SC_log(LOG_NOTICE,
+                      "Configuration validity check: model names do not match!"
+                      "\n  %@"
+                      "\n  %@",
+                      prefs,
+                      ni_prefs);
                goto done;
        }
 
         __SCNetworkInterfaceCreateMappingUsingBSDName(SCPreferencesRef prefs);
         */
        interfaces = __SCNetworkInterfaceCopyStoredWithPreferences(ni_prefs);
-       if (!isA_CFArray(interfaces)) {
-               if (interfaces != NULL) CFRelease(interfaces);
-               SC_log(LOG_NOTICE, "No interfaces");
+       if (interfaces == NULL) {
+               SC_log(LOG_NOTICE,
+                      "Configuration validity check: no network interfaces!"
+                      "\n  %@",
+                      ni_prefs);
                isValid = FALSE;
                goto done;
        }
        mappingBSDNameToInterface = __SCNetworkInterfaceCreateMappingUsingBSDName(interfaces);
        CFRelease(interfaces);
-       if (isA_CFDictionary(mappingBSDNameToInterface) == NULL) {
+       if (!isA_CFDictionary(mappingBSDNameToInterface)) {
                isValid = FALSE;
-               SC_log(LOG_INFO, "No BSD name to interface mapping");
+               SC_log(LOG_NOTICE,
+                      "Configuration validity check: no BSD name to network interface mapping!"
+                      "\n  %@",
+                      ni_prefs);
                goto done;
        }
 
        if (!isA_CFArray(interfaces)) {
                if (interfaces != NULL) CFRelease(interfaces);
                isValid = FALSE;
-               SC_log(LOG_INFO, "No interfaces");
+               SC_log(LOG_NOTICE,
+                      "Configuration validity check: no service interfaces!"
+                      "\n  %@",
+                      prefs);
                goto done;
        }
        mappingServiceBSDNameToInterface = __SCNetworkInterfaceCreateMappingUsingBSDName(interfaces);
        CFRelease(interfaces);
-       if (isA_CFDictionary(mappingServiceBSDNameToInterface) == NULL) {
+       if (!isA_CFDictionary(mappingServiceBSDNameToInterface)) {
                isValid = FALSE;
-               SC_log(LOG_INFO, "No Service BSD name to interface mapping");
+               SC_log(LOG_NOTICE,
+                      "Configuration validity check: no BSD name to service interface mapping!"
+                      "\n  %@",
+                      prefs);
                goto done;
        }
 
        CFDictionaryApplyFunction(mappingServiceBSDNameToInterface, _SCNetworkConfigurationValidateInterface, &context);
 
        if (!isValid) {
-               SC_log(LOG_INFO, "mismatch between interface names in NetworkInterfaces.plist and preferences.plist");
+               SC_log(LOG_NOTICE,
+                      "Configuration validity check: mismatch between interface names in NetworkInterfaces.plist and preferences.plist!"
+                      "\n  %@"
+                      "\n  %@",
+                      prefs,
+                      ni_prefs);
                if (repairConfiguration) {
                        isValid = _SCNetworkConfigurationRepairUsingPreferences(prefs, &context);
                        if (!isValid) {
                        }
                        // Save the changes if repair fixed an invalid configuration
                        if (!SCPreferencesCommitChanges(prefs)) {
-                               SC_log(LOG_INFO, "SCPreferencesCommitChanges() failed");
+                               SC_log(LOG_NOTICE, "SCPreferencesCommitChanges() failed");
                        }
                } else {
                        goto done;
                }
        }
+
        /*
         - Check if all the network services mentioned in the SCNetworkSet are actually present in the SCNetworkService array
         */
-
        allServices = SCNetworkServiceCopyAll(prefs);
-       if (isA_CFArray(allServices) == NULL) {
+       if (!isA_CFArray(allServices)) {
                isValid = FALSE;
-               SC_log(LOG_INFO, "No services");
+               SC_log(LOG_NOTICE,
+                      "Configuration validity check: no services!"
+                      "\n  %@",
+                      prefs);
                goto done;
        }
 
        allSets = SCNetworkSetCopyAll(prefs);
-       if (isA_CFArray(allSets) == NULL) {
+       if (!isA_CFArray(allSets)) {
                isValid = FALSE;
-               SC_log(LOG_INFO, "No sets");
+               SC_log(LOG_NOTICE,
+                      "Configuration validity check: no sets!"
+                      "\n  %@",
+                      prefs);
                goto done;
        }
 
        for (CFIndex idx = 0; ((idx < CFArrayGetCount(allSets)) && isValid); idx++) {
                SCNetworkSetRef set = CFArrayGetValueAtIndex(allSets, idx);
 
-               if (isA_SCNetworkSet(set) == NULL) {
-                       SC_log(LOG_INFO, "No set");
-                       continue;
-               }
                setServices = SCNetworkSetCopyServices(set);
                if (setServices == NULL) {
-                       SC_log(LOG_INFO, "No services");
+                       SC_log(LOG_NOTICE,
+                              "Configuration validity check: set w/no services!"
+                              "\n  %@"
+                              "\n  %@",
+                              prefs,
+                              set);
                        continue;
                }
                for (CFIndex idx2 = 0; idx2 < CFArrayGetCount(setServices); idx2++) {
 
                        if (!CFArrayContainsValue(allServices, CFRangeMake(0, CFArrayGetCount(allServices)), service)) {
                                isValid = FALSE;
-                               SC_log(LOG_INFO, "All network services in the network set are not present in SCNetworkService array");
+                               SC_log(LOG_NOTICE,
+                                      "All network services in the network set are not present in SCNetworkService array");
                                break;
                        }
                }
                                SCNetworkServiceRef service = CFArrayGetValueAtIndex(setServiceOrder, idx2);
                                if (!CFArrayContainsValue(setServiceOrder, CFRangeMake(0, CFArrayGetCount(setServiceOrder)), service) &&
                                    !CFArrayContainsValue(allServices, CFRangeMake(0, CFArrayGetCount(allServices)), service)) {
-                                       SC_log(LOG_INFO, "Service: %@ is not present in the service order for set %@", service, set);
+                                       SC_log(LOG_NOTICE,
+                                              "Service: %@ is not present in the service order for set %@",
+                                              service,
+                                              set);
                                        break;
                                }
                        }
        char prefsStr[PATH_MAX];
 
        if (configDir == NULL) {
-               SC_log(LOG_INFO, "Migration files not found in directory: %@",
+               SC_log(LOG_NOTICE, "Migration files not found in directory: %@",
                       (configDir == NULL) ? CFSTR("NULL") : CFURLGetString(configDir));
                goto done;
        }
        SCNetworkInterfaceRef targetInterface = (SCNetworkInterfaceRef)value;
 
        if (CFArrayContainsValue(ctx->externalInterfaceList, CFRangeMake(0, CFArrayGetCount(ctx->externalInterfaceList)), targetInterface)) {
-               SC_log(LOG_INFO, "Target interface (%@) already exists, not adding to NetworkInterfaces.plist", targetInterface);
+               SC_log(LOG_NOTICE, "Target interface (%@) already exists, not adding to NetworkInterfaces.plist", targetInterface);
                return; // If the target interface already exists then do not add it to NetworkInterfaces.plist
        }
        ctx->foundNewInterfaces = TRUE;
        CFMutableArrayRef networkInterfaceList = NULL;
 
        if (ni_prefs == NULL) {
-               SC_log(LOG_INFO, "No NetworkInterfaces.plist");
+               SC_log(LOG_NOTICE, "No NetworkInterfaces.plist");
                return NULL;
        }
 
        if_list = SCPreferencesGetValue(ni_prefs, INTERFACES);
        if (!isA_CFArray(if_list) ||
            ((count = CFArrayGetCount(if_list)) == 0)) {
-               SC_log(LOG_INFO, "No interfaces");
+               SC_log(LOG_NOTICE, "No interfaces");
                return NULL;
        }
 
        }
 
        if (!isA_CFDictionary(externalMapping)) {
-               SC_log(LOG_INFO, "No external mapping");
+               // if no external mapping
                goto done;
        }
 
        CFStringRef targetBSDName = NULL;
 
        sourceBSDName = SCNetworkInterfaceGetBSDName(interfaceKey);
-       if (isA_CFString(sourceBSDName) == NULL) {
+       if (!isA_CFString(sourceBSDName)) {
                return;
        }
 
        targetBSDName = SCNetworkInterfaceGetBSDName(interfaceValue);
-       if (isA_CFString(targetBSDName) == NULL) {
+       if (!isA_CFString(targetBSDName)) {
                return;
        }
 
                        CFRelease(targetSet);
                }
                else {
-                       SC_log(LOG_ERR, "Number of sets in the target should be at least 1, but is found to be %ld", targetCount);
+                       SC_log(LOG_NOTICE, "Number of sets in the target should be at least 1, but is found to be %ld", targetCount);
                        goto done;
                }
        }
                CFRelease(currentSourceSet);
        }
 
-       if (setMapping != NULL) {
-               SC_log(LOG_NOTICE, "Set mapping: %@", setMapping);
-       } else {
-               SC_log(LOG_INFO, "Set mapping: NULL");
-       }
-
        return setMapping;
 }
 
 
        // We need BSD Mapping to successfully create service mapping
        if (bsdNameMapping == NULL) {
-               SC_log(LOG_INFO, "No BSD name mapping");
+               SC_log(LOG_NOTICE, "No BSD name mapping");
                goto done;
        }
        sourceSCNetworkServices = SCNetworkServiceCopyAll(sourcePrefs);
-       if (isA_CFArray(sourceSCNetworkServices) == NULL) {
-               SC_log(LOG_INFO, "No source network services");
+       if (!isA_CFArray(sourceSCNetworkServices)) {
+               SC_log(LOG_NOTICE, "No source network services");
                goto done;
        }
        targetSCNetworkServices = SCNetworkServiceCopyAll(targetPrefs);
-       if (isA_CFArray(targetSCNetworkServices) == NULL) {
-               SC_log(LOG_INFO, "No target network services");
+       if (!isA_CFArray(targetSCNetworkServices)) {
+               SC_log(LOG_NOTICE, "No target network services");
                goto done;
        }
 
 
                sourceInterface = SCNetworkServiceGetInterface(sourceService);
                if (sourceInterface == NULL) {
-                       SC_log(LOG_INFO, "No source interface");
+                       SC_log(LOG_NOTICE, "No source interface");
                        continue;
                }
 
                    (CFEqual(sourceInterfaceType, kSCValNetInterfaceTypeVPN) ||
                     CFEqual(sourceInterfaceType, kSCValNetInterfaceTypePPP))) {
                            sourceInterfaceSubType = __SCNetworkInterfaceGetEntitySubType(sourceInterface);
-                           if (isA_CFString(sourceInterfaceSubType) == NULL) {
-                                   SC_log(LOG_INFO, "No source interface SubType");
+                           if (!isA_CFString(sourceInterfaceSubType)) {
+                                   SC_log(LOG_NOTICE, "No source interface SubType");
                                    continue;
                            }
                }
                        sourceBSDName = SCNetworkInterfaceGetBSDName(sourceInterface);
                        if (!isA_CFString(sourceBSDName) ||
                            !CFDictionaryContainsKey(bsdNameMapping, sourceBSDName)) {
-                               SC_log(LOG_INFO, "No BSD name mapping for %@",
+                               SC_log(LOG_NOTICE, "No BSD name mapping for %@",
                                       (sourceBSDName == NULL) ? CFSTR("NULL") : sourceBSDName);
                                continue;
                        }
 
                        bsdNameMapTarget = CFDictionaryGetValue(bsdNameMapping, sourceBSDName);
-                       if (isA_CFString(bsdNameMapTarget) == NULL) {
-                               SC_log(LOG_INFO, "No BSD name mapping target");
+                       if (!isA_CFString(bsdNameMapTarget)) {
+                               SC_log(LOG_NOTICE, "No BSD name mapping target");
                                continue;
                        }
                }
 
                        targetInterface = SCNetworkServiceGetInterface(targetService);
                        if (targetInterface == NULL) {
-                               SC_log(LOG_INFO, "No target interface");
+                               SC_log(LOG_NOTICE, "No target interface");
                                continue;
                        }
-                       SC_log(LOG_INFO, "targetInterface: %@", targetInterface);
+                       SC_log(LOG_NOTICE, "targetInterface: %@", targetInterface);
                        if (sourceBSDName != NULL) {
                                targetBSDName = SCNetworkInterfaceGetBSDName(targetInterface);
-                               if (isA_CFString(targetBSDName) == NULL) {
-                                       SC_log(LOG_INFO, "No target BSD name");
+                               if (!isA_CFString(targetBSDName)) {
+                                       SC_log(LOG_NOTICE, "No target BSD name");
                                        continue;
                                }
 
                                if (CFEqual(targetBSDName, bsdNameMapTarget)) {
-                                       SC_log(LOG_INFO, "Removing target BSD name: %@", targetBSDName);
+                                       SC_log(LOG_NOTICE, "Removing target BSD name: %@", targetBSDName);
                                        CFDictionaryAddValue(serviceMapping, sourceService, targetService);
                                        CFArrayRemoveValueAtIndex(targetSCNetworkServicesMutable, idx2);
                                        break;
                        } else {
                                // Source Interface Type should be VPN
                                targetInterfaceType = __SCNetworkInterfaceGetEntityType(targetInterface);
-                               if ((isA_CFString(targetInterfaceType) == NULL) ||
+                               if ((!isA_CFString(targetInterfaceType)) ||
                                    (!CFEqual(targetInterfaceType, kSCValNetInterfaceTypeVPN) &&
                                     !CFEqual(targetInterfaceType, kSCValNetInterfaceTypePPP))) {
-                                           SC_log(LOG_INFO, "Unexpected target interface type: %@",
+                                           SC_log(LOG_NOTICE, "Unexpected target interface type: %@",
                                                   (targetInterfaceType != NULL) ? targetInterfaceType : CFSTR("NULL"));
                                            continue;
                                    }
                                targetInterfaceSubType = __SCNetworkInterfaceGetEntitySubType(targetInterface);
-                               if (isA_CFString(targetInterfaceSubType) == NULL) {
-                                       SC_log(LOG_INFO, "No target interface SubType");
+                               if (!isA_CFString(targetInterfaceSubType)) {
+                                       SC_log(LOG_NOTICE, "No target interface SubType");
                                        continue;
                                }
 
                                // Check if the target interface type and the target interface sub type match
                                if (CFEqual(targetInterfaceType, sourceInterfaceType) &&
                                    CFEqual(targetInterfaceSubType, sourceInterfaceSubType)) {
-                                       SC_log(LOG_INFO, "Removing target BSD Name: %@ for VPN", targetBSDName);
+                                       SC_log(LOG_NOTICE, "Removing target BSD Name: %@ for VPN", targetBSDName);
                                        CFDictionaryAddValue(serviceMapping, sourceService, targetService);
                                        CFArrayRemoveValueAtIndex(targetSCNetworkServicesMutable, idx2);
                                        break;
                // Check if sourceService has found a mapping or not, if not the create a NULL mapping to indicate
                // the this service needs to be added and not replaced
                if (!CFDictionaryContainsKey(serviceMapping, sourceService)) {
-                       SC_log(LOG_INFO, "Service needs to be added: %@", sourceService);
+                       SC_log(LOG_NOTICE, "Service needs to be added: %@", sourceService);
                        CFDictionaryAddValue(serviceMapping, sourceService, kCFBooleanFalse);
                }
        }
                CFRelease(targetSCNetworkServicesMutable);
        }
 
-       if (serviceMapping != NULL) {
-               SC_log(LOG_NOTICE, "Service mapping: %@", serviceMapping);
-       } else {
-               SC_log(LOG_INFO, "Service mapping: NULL");
-       }
-
        return serviceMapping;
 }
 
        sourceServiceSetMapping = ctx->serviceSetMapping;
 
        if ((setMapping != NULL || sourceServiceSetMapping != NULL)) {
-               if (isA_SCNetworkService(targetService) != NULL) {
+               if (isA_SCNetworkService(targetService)) {
                        SC_log(LOG_INFO, "Removing target service: %@", targetService);
                        SCNetworkServiceRemove(targetService);
                }
        ServiceMigrationContext context;
        Boolean success = FALSE;
 
+       SC_log(LOG_INFO,
+              "_SCNetworkMigrationDoServiceMigration() called"
+              "\n  sourcePrefs       = %@"
+              "\n  targetPrefs       = %@"
+              "\n  serviceMapping    = %@"
+              "\n  bsdMapping        = %@"
+              "\n  setMapping        = %@"
+              "\n  serviceSetMapping = %@",
+              sourcePrefs,
+              targetPrefs,
+              serviceMapping,
+              bsdMapping,
+              setMapping,
+              serviceSetMapping);
+
        if ((sourcePrefs == NULL) ||
            (targetPrefs == NULL) ||
-           (isA_CFDictionary(serviceMapping) == NULL) ||
-           (isA_CFDictionary(bsdMapping) == NULL)) {
+           !isA_CFDictionary(serviceMapping) ||
+           !isA_CFDictionary(bsdMapping)) {
                SC_log(LOG_INFO, "No sourcePrefs, targetPrefs, serviceMapping, or bsdMapping");
                goto done;
        }
        CFStringRef btmmDSIDPath;
        CFStringRef btmmPath;
 
+       SC_log(LOG_INFO,
+              "_SCNetworkMigrationDoSystemMigration() called"
+              "\n  sourcePrefs = %@"
+              "\n  targetPrefs = %@",
+              sourcePrefs,
+              targetPrefs);
 
        if ((sourcePrefs == NULL) ||
            (targetPrefs == NULL)) {
        hostname = SCPreferencesGetHostName(sourcePrefs);
        if (hostname != NULL) {
                SCPreferencesSetHostName(targetPrefs, hostname);
+               SC_log(LOG_NOTICE, "  copied HostName");
        }
 
        localHostname = _SCPreferencesCopyLocalHostName(sourcePrefs);
        if (localHostname != NULL) {
                SCPreferencesSetLocalHostName(targetPrefs, localHostname);
                CFRelease(localHostname);
+               SC_log(LOG_NOTICE, "  copied LocalHostName");
        }
 
        computerName = _SCPreferencesCopyComputerName(sourcePrefs, &nameEncoding);
        if (computerName != NULL) {
                SCPreferencesSetComputerName(targetPrefs, computerName, nameEncoding);
                CFRelease(computerName);
+               SC_log(LOG_NOTICE, "  copied ComputerName");
        }
 
        btmmPath = CFStringCreateWithFormat(NULL, NULL,
 
        return TRUE;
 }
+
 #if    !TARGET_OS_IPHONE
 
 typedef struct {
 
        newInterface = __SCNetworkInterfaceCreateWithNIPreferencesUsingBSDName(NULL, ctx->ni_prefs, newInterfaceBSDName);
        if (newInterface != NULL) {
-               SC_log(LOG_INFO, "Adding interface to interfaceList: %@", newInterface);
+               SC_log(LOG_INFO, "adding interface to interfaceList: %@", newInterface);
                CFArrayAppendValue(interfaceList, newInterface);
                CFRelease(newInterface);
        }
        newBridge = SCBridgeInterfaceCreate(prefs);
 
        if (!__SCBridgeInterfaceSetMemberInterfaces(newBridge, newInterfaceList)) {
-               SC_log(LOG_INFO, "__SCBridgeInterfaceSetMemberInterfaces() failed");
+               SC_log(LOG_NOTICE, "__SCBridgeInterfaceSetMemberInterfaces() failed");
        }
        CFRelease(newInterfaceList);
 
        for (CFIndex idx = 0; idx < CFArrayGetCount(oldServiceList); idx++) {
                SCNetworkServiceRef oldService = CFArrayGetValueAtIndex(oldServiceList, idx);
                if (!__SCNetworkServiceMigrateNew(prefs, oldService, bridgeBSDNameMapping, setMapping, serviceSetMapping)) {
-                       SC_log(LOG_INFO, "Could not migrate Bridge service: %@", oldService);
+                       SC_log(LOG_NOTICE, "could not migrate bridge service: %@", oldService);
                }
        }
 done:
 
                if ((bsdName != NULL) &&
                    (SCNetworkInterfaceGetInterfaceType(interface) == kSCNetworkInterfaceTypeBridge)) {
-                       SC_log(LOG_INFO, "Removing service: %@", service);
+                       SC_log(LOG_INFO, "removing service: %@", service);
                        SCNetworkServiceRemove(service);
                }
        }
        for (CFIndex idx = 0; idx < CFArrayGetCount(allTargetBridges); idx++) {
                bridge = CFArrayGetValueAtIndex(allTargetBridges, idx);
                if (!SCBridgeInterfaceRemove(bridge)) {
-                       SC_log(LOG_INFO, "SCBridgeInterfaceRemove() failed: %@", bridge);
+                       SC_log(LOG_NOTICE, "SCBridgeInterfaceRemove() failed: %@", bridge);
                        goto done;
                }
        }
 
        newBond = SCBondInterfaceCreate(prefs);
        if (!__SCBondInterfaceSetMemberInterfaces(newBond, newInterfaceList)) {
-               SC_log(LOG_INFO, "__SCBondInterfaceSetMemberInterfaces() failed");
+               SC_log(LOG_NOTICE, "__SCBondInterfaceSetMemberInterfaces() failed");
        }
        CFRelease(newInterfaceList);
 
        for (CFIndex idx = 0; idx < CFArrayGetCount(oldServiceList); idx++) {
                SCNetworkServiceRef oldService = CFArrayGetValueAtIndex(oldServiceList, idx);
                if (!__SCNetworkServiceMigrateNew(prefs, oldService, bondBSDNameMapping, setMapping, serviceSetMapping)) {
-                       SC_log(LOG_INFO, "Could not migrate Bond service: %@", oldService);
+                       SC_log(LOG_NOTICE, "could not migrate bond service: %@", oldService);
                }
        }
 done:
        for (CFIndex idx = 0; idx < CFArrayGetCount(allTargetBonds); idx++) {
                bond = CFArrayGetValueAtIndex(allTargetBonds, idx);
                if (!SCBondInterfaceRemove(bond)) {
-                       SC_log(LOG_INFO, "SCBondInterfaceRemove() failed: %@", bond);
+                       SC_log(LOG_NOTICE, "SCBondInterfaceRemove() failed: %@", bond);
                        goto done;
                }
        }
 
        oldPhysicalInterface = SCVLANInterfaceGetPhysicalInterface(oldVLAN);
        if (oldPhysicalInterface == NULL) {
-               SC_log(LOG_INFO, "No old VLAN physical interface");
+               SC_log(LOG_NOTICE, "No old VLAN physical interface");
                goto done;
        }
 
        oldPhysicalInterfaceName = SCNetworkInterfaceGetBSDName(oldPhysicalInterface);
        if (oldPhysicalInterfaceName == NULL) {
-               SC_log(LOG_INFO, "No old VLAN physical interface name");
+               SC_log(LOG_NOTICE, "No old VLAN physical interface name");
                goto done;
        }
 
        newPhysicalInterfaceName = CFDictionaryGetValue(bsdMapping, oldPhysicalInterfaceName);
        if (newPhysicalInterfaceName == NULL) {
-               SC_log(LOG_INFO, "No new VLAN physical interface name");
+               SC_log(LOG_NOTICE, "No new VLAN physical interface name");
                goto done;
        }
        newPhysicalInterface = __SCNetworkInterfaceCreateWithNIPreferencesUsingBSDName(NULL, ctx->ni_prefs, newPhysicalInterfaceName);
        if (newPhysicalInterface == NULL) {
-               SC_log(LOG_INFO, "Could not create new VLAN physical interface");
+               SC_log(LOG_NOTICE, "Could not create new VLAN physical interface");
                goto done;
        }
 
        vlanTag = SCVLANInterfaceGetTag(oldVLAN);
        if (vlanTag == NULL) {
-               SC_log(LOG_INFO, "No old VLAN interface tag");
+               SC_log(LOG_NOTICE, "No old VLAN interface tag");
                goto done;
        }
 
        newVLAN = SCVLANInterfaceCreate(prefs, newPhysicalInterface, vlanTag);
        if (newVLAN == NULL) {
-               SC_log(LOG_INFO, "Could not create new VLAN interface");
+               SC_log(LOG_NOTICE, "Could not create new VLAN interface");
                goto done;
        }
 
        for (CFIndex idx = 0; idx < CFArrayGetCount(oldServiceList); idx++) {
                oldService = CFArrayGetValueAtIndex(oldServiceList, idx);
                if (!__SCNetworkServiceMigrateNew(prefs, oldService, vlanBSDMapping, setMapping, serviceSetMapping)) {
-                       SC_log(LOG_INFO, "Could not migrate VLAN service: %@", oldService);
+                       SC_log(LOG_NOTICE, "Could not migrate VLAN service: %@", oldService);
                }
        }
 
                vlan = CFArrayGetValueAtIndex(allSourceVLAN, idx);
                CFStringRef vlanBSDName = SCNetworkInterfaceGetBSDName(vlan);
                SCNetworkInterfaceRef physicalInterface = SCVLANInterfaceGetPhysicalInterface(vlan);
-               CFStringRef physicalInterfaceName;
-
-               SC_log(LOG_DEBUG, "physical VLAN interface: %@", physicalInterface);
-
-               physicalInterfaceName = SCNetworkInterfaceGetBSDName(physicalInterface);
-               SC_log(LOG_DEBUG, "physical VLAN interface name: %@", physicalInterfaceName);
+               CFStringRef physicalInterfaceName = SCNetworkInterfaceGetBSDName(physicalInterface);
 
                // Add VLAN to be migrated if the mapping between interfaces exists
                if (CFDictionaryContainsKey(bsdMapping, physicalInterfaceName)) {
        for (CFIndex idx = 0; idx < CFArrayGetCount(allTargetVLAN); idx++) {
                vlan = CFArrayGetValueAtIndex(allTargetVLAN, idx);
                if (!SCVLANInterfaceRemove(vlan)) {
-                       SC_log(LOG_INFO, "SCVLANInterfaceRemove() failed: %@", vlan);
+                       SC_log(LOG_NOTICE, "SCVLANInterfaceRemove() failed: %@", vlan);
                        goto done;
                }
        }
        if (!_SCNetworkMigrationDoBridgeMigration(sourcePrefs, sourceNIPrefs,
                                                 targetPrefs, targetNIPrefs,
                                                 bsdMapping, setMapping, serviceSetMapping)) {
-               SC_log(LOG_INFO, "Bridge migration failed");
+               SC_log(LOG_NOTICE, "Bridge migration failed");
        }
 
        // Handle Bonds
        if (!_SCNetworkMigrationDoBondMigration(sourcePrefs, sourceNIPrefs,
                                               targetPrefs, targetNIPrefs,
                                               bsdMapping, setMapping, serviceSetMapping)) {
-               SC_log(LOG_INFO, "Bond migration failed");
+               SC_log(LOG_NOTICE, "Bond migration failed");
        }
 
        // Handle VLANs
        if (!_SCNetworkMigrationDoVLANMigration(sourcePrefs, sourceNIPrefs,
                                               targetPrefs, targetNIPrefs,
                                               bsdMapping, setMapping, serviceSetMapping)) {
-               SC_log(LOG_INFO, "VLAN migration failed");
+               SC_log(LOG_NOTICE, "VLAN migration failed");
        }
        return TRUE;
 }
        if (*success == FALSE) {
                return;
        }
+
        // Preserving the service order in the source configuration for the services
        // which were migrated into the target configuration
        for (CFIndex idx = 0; idx < CFArrayGetCount(targetServiceOrder); idx++) {
        if (*success == FALSE) {
                return;
        }
-       // Adding all services not present in migratedServiceOrder into nonMigrated service
-       for (CFIndex idx = 0; idx < CFArrayGetCount(migratedServiceOrder); idx++) {
-               CFStringRef migratedServiceID = CFArrayGetValueAtIndex(migratedServiceOrder, idx);
 
-               if (CFEqual(targetServiceID, migratedServiceID)) {
-                       return;
-               }
+       // Adding all services not present in migratedServiceOrder into nonMigrated service
+       if (CFArrayGetFirstIndexOfValue(migratedServiceOrder,
+                                       CFRangeMake(0, CFArrayGetCount(migratedServiceOrder)),
+                                       targetServiceID)) {
+               // if service already present
+               return;
        }
+
        service = SCNetworkServiceCopy(prefs, targetServiceID);
        if (service == NULL) {
                *success = FALSE;
        char sourcePreferencesFileStr[PATH_MAX];
        CFStringRef sourcePreferencesFileString = NULL;
        SCPreferencesRef sourcePrefs = NULL;
+       CFStringRef suffix;
        CFArrayRef targetConfigurationFiles = NULL;             // Path to the target configuration files where migration will take place to
        Boolean targetConfigurationFilesPresent;
        CFStringRef targetModel = NULL;
        Boolean isUpgradeScenario = FALSE;
        CFMutableDictionaryRef validityOptions = NULL;
 
+       SC_log(LOG_INFO,
+              "_SCNetworkConfigurationMigrateConfiguration() called"
+              "\n  sourceDir = %@"
+              "\n  targetDir = %@",
+              sourceDir,
+              targetDir);
+
        // Check if configuration files exist in sourceDir
-       if (!__SCNetworkConfigurationMigrateConfigurationFilesPresent(sourceDir, &sourceConfigurationFiles)) {
-               SC_log(LOG_INFO, "sourceDir: (%@) doesn't contain configuration files", sourceDir);
+       if (!__SCNetworkConfigurationMigrateConfigurationFilesPresent(sourceDir, &sourceConfigurationFiles, TRUE)) {
+               SC_log(LOG_NOTICE, "sourceDir: (%@) missing configuration files", sourceDir);
                goto done;
        }
 
                goto done;
        }
 
-       targetConfigurationFilesPresent = __SCNetworkConfigurationMigrateConfigurationFilesPresent(targetDir, &targetConfigurationFiles);
+       targetConfigurationFilesPresent = __SCNetworkConfigurationMigrateConfigurationFilesPresent(targetDir, &targetConfigurationFiles, FALSE);
        if (!targetConfigurationFilesPresent) {
+               // if the expected configuration files are not present in the target directory
                if (targetConfigurationFiles == NULL) {
-                       SC_log(LOG_DEBUG, "targetConfigurationFiles is NULL");
+                       // but we don't know what files are needed (no target URL)
+                       SC_log(LOG_NOTICE, "targetConfigurationFiles is NULL");
                        goto done;
                }
-               SC_log(LOG_INFO, "targetDir: (%@) doesn't contain configuration files ... Need to create default configuration", targetDir);
        }
 
        targetPreferencesFile = CFArrayGetValueAtIndex(targetConfigurationFiles, PREFERENCES_PLIST_INDEX);
        targetPreferencesFileString = CFStringCreateWithCString(NULL, targetPreferencesFileStr, kCFStringEncodingUTF8);
        targetNetworkInterfaceFileString = CFStringCreateWithCString(NULL, targetNetworkInterfaceFileStr, kCFStringEncodingUTF8);
 
+       SC_log(LOG_INFO,
+              "Migrating network configuration:"
+              "\n  target configuration files %s present"
+              "\n  target preferences.plist path       = %@"
+              "\n  target NetworkInterfaces.plist path = %@",
+              targetConfigurationFilesPresent ? "are" : "are not",
+              targetPreferencesFileString,
+              targetNetworkInterfaceFileString);
+
        if (targetConfigurationFilesPresent) {
                targetPrefs = SCPreferencesCreate(NULL, PLUGIN_ID, targetPreferencesFileString);
                targetNetworkInterfacePrefs = SCPreferencesCreate(NULL, PLUGIN_ID, targetNetworkInterfaceFileString);
                if ((targetPrefs == NULL) || (targetNetworkInterfacePrefs == NULL)) {
+                       SC_log(LOG_NOTICE, "Could not open target prefs/ni_prefs");
                        goto done;
                }
        } else {
-               targetPrefs = __SCNetworkCreateDefaultPref(targetPreferencesFileString);
-               targetNetworkInterfacePrefs =  __SCPreferencesCreateNIPrefsFromPrefs(targetPrefs);
+               // create and populate a new preferences.plist
+               targetPrefs = SCPreferencesCreate(NULL, PLUGIN_ID, targetPreferencesFileString);
+               __SCNetworkPopulateDefaultPrefs(targetPrefs);
 
-               if ((targetPrefs == NULL) || (targetNetworkInterfacePrefs == NULL)) {
-                       SC_log(LOG_DEBUG, "Could not create default configuration");
-                       goto done;
-               }
+               // create and populate a new NetworkInterfaces.plist
+               targetNetworkInterfacePrefs = SCPreferencesCreateCompanion(targetPrefs, INTERFACES_DEFAULT_CONFIG);
+               __SCNetworkPopulateDefaultNIPrefs(targetNetworkInterfacePrefs);
        }
        validityOptions = CFDictionaryCreateMutable(NULL, 0,
                                                    &kCFTypeDictionaryKeyCallBacks,
                                                    &kCFTypeDictionaryValueCallBacks);
        CFDictionaryAddValue(validityOptions, kSCNetworkConfigurationRepair, kCFBooleanTrue);
 
-       SC_log(LOG_DEBUG, "sourcePreferenceFileString: %@\n"
-                         "sourceNetworkInterfaceFileString:%@\n"
-                         "targetPreferencesFileString:%@\n"
-                         "targetNetworkInterfaceFileString:%@",
-              sourcePreferencesFileString,
-              sourceNetworkInterfaceFileString,
-              targetPreferencesFileString,
-              targetNetworkInterfaceFileString);
+       SC_log(LOG_INFO,
+              "Migrating network configuration:"
+              "\n  sourcePrefs                 = %@"
+              "\n  sourceNetworkInterfacePrefs = %@"
+              "\n  targetPrefs                 = %@"
+              "\n  targetNetworkInterfacePrefs = %@",
+              sourcePrefs,
+              sourceNetworkInterfacePrefs,
+              targetPrefs,
+              targetNetworkInterfacePrefs);
 
        // Setting Bypass Interface to avoid looking at system interfaces
        _SCNetworkConfigurationSetBypassSystemInterfaces(sourcePrefs, TRUE);
        targetModel = SCPreferencesGetValue(targetPrefs, MODEL);
 
        isUpgradeScenario = (isA_CFString(sourceModel) && isA_CFString(targetModel) && CFStringCompare(sourceModel, targetModel, 0) == kCFCompareEqualTo);
+       if (isUpgradeScenario) {
+               SC_log(LOG_NOTICE, "Migrating network configuration: performing an \"upgrade\"");
+       } else {
+               SC_log(LOG_NOTICE, "Migrating network configuration: performing a \"migration\"");
+       }
+
+       // create backup of migration source
+       suffix = CFStringCreateWithFormat(NULL, NULL,
+                                         CFSTR("pre-%s-source"),
+                                         isUpgradeScenario ? "upgrade" : "migration");
+       __SCNetworkConfigurationBackup(sourcePrefs, suffix, targetPrefs);
+       __SCNetworkConfigurationBackup(sourceNetworkInterfacePrefs, suffix, targetPrefs);
+       CFRelease(suffix);
+
+       // create backup of migration target
+       suffix = CFStringCreateWithFormat(NULL, NULL,
+                                         CFSTR("pre-%s-%starget"),
+                                         isUpgradeScenario ? "upgrade" : "migration",
+                                         targetConfigurationFilesPresent ? "" : "new-");
+       __SCNetworkConfigurationBackup(targetPrefs, suffix, targetPrefs);
+       __SCNetworkConfigurationBackup(targetNetworkInterfacePrefs, suffix, targetPrefs);
+       CFRelease(suffix);
 
        // Create services for builtin interfaces at source if they don't exist
        (void)_SCNetworkConfigurationCreateBuiltinInterfaceServices(sourcePrefs, sourceNetworkInterfacePrefs);
        if (!_SCNetworkConfigurationCheckValidityWithPreferences(sourcePrefs,
                                                                 sourceNetworkInterfacePrefs,
                                                                 validityOptions)) {
-               SC_log(LOG_INFO, "Source configuration not valid");
+               SC_log(LOG_NOTICE, "Source configuration not valid");
                goto skipServiceMigration;
        }
        // Only call this function if configuration files were not created by default
                if (!_SCNetworkConfigurationCheckValidityWithPreferences(targetPrefs,
                                                                         targetNetworkInterfacePrefs,
                                                                         validityOptions)) {
-                       SC_log(LOG_INFO, "Target configuration not valid");
+                       SC_log(LOG_NOTICE, "Target configuration not valid");
                        goto skipServiceMigration;
                }
        }
-       SC_log(LOG_DEBUG, "This is %san upgrade scenario", isUpgradeScenario ? "" : "not ");
        // Upgrade scenario, source and target models match
        if (isUpgradeScenario) {
                Boolean foundNewInterface = FALSE;
                // Create SCPreferences to copy the target prefs
-               SCPreferencesRef upgradeSourcePrefs = SCPreferencesCreate(NULL, CFSTR("Upgrade Source Prefs"), NULL);
-               SCPreferencesRef upgradeSourceNIPrefs = SCPreferencesCreate(NULL, CFSTR("Upgrade Source NI Prefs"), NULL);
+               SCPreferencesRef upgradeSourcePrefs     = SCPreferencesCreate(NULL, CFSTR("Upgrade Source Prefs"), NULL);
+               SCPreferencesRef upgradeSourceNIPrefs   = SCPreferencesCreate(NULL, CFSTR("Upgrade Source NI Prefs"), INTERFACES_DEFAULT_CONFIG);
+
+               SC_log(LOG_INFO,
+                      "Migrating network configuration:"
+                      "\n  upgradeSourcePrefs [temp]   = %@"
+                      "\n  upgradeSourceNIPrefs [temp] = %@"
+                      "\n  Copying target --> upgrade, source --> target",
+                      upgradeSourcePrefs,
+                      upgradeSourceNIPrefs);
 
                // Content of target prefs
                CFDictionaryRef targetPrefsContent = SCPreferencesPathGetValue(targetPrefs, CFSTR("/"));
 
                // Getting the mapping of the non builtin interfaces between source and target
                externalMapping = _SCNetworkConfigurationCopyExternalInterfaceMapping(upgradeSourceNIPrefs, targetNetworkInterfacePrefs);
+               SC_log(LOG_INFO,
+                      "Upgradng, external interface mapping: %@",
+                      externalMapping);
 
                newTargetNetworkInterfaceEntity = _SCNetworkMigrationCreateNetworkInterfaceArray(targetNetworkInterfacePrefs, externalMapping, &foundNewInterface);
+
+               SC_log(LOG_INFO,
+                      "Upgrading, %s new interfaces"
+                      "\n  newTargetNetworkInterfaceEntity = %@",
+                      foundNewInterface ? "found" : "no",
+                      newTargetNetworkInterfaceEntity);
+
                if (foundNewInterface) {
-                       if (isA_CFArray(newTargetNetworkInterfaceEntity) == NULL) {
-                               SC_log(LOG_INFO, "newTargetNetworkInterfaceEntity is NULL or not of correct type");
+                       if (newTargetNetworkInterfaceEntity == NULL) {
+                               SC_log(LOG_NOTICE, "Upgrading, failed w/no new interface list");
                                CFRelease(upgradeSourcePrefs);
                                CFRelease(upgradeSourceNIPrefs);
                                goto done;
                        }
-                       // Write new interface mapping to NetworkInterfaces.plist
+
+                       // add new interface mapping to NetworkInterfaces.plist
                        if (!__SCNetworkInterfaceSaveStoredWithPreferences(targetNetworkInterfacePrefs, newTargetNetworkInterfaceEntity)) {
-                               SC_log(LOG_INFO, "SCNetworkInterfaceSaveStoreWithPreferences: failed to update NetworkInterfaces.plist");
+                               SC_log(LOG_NOTICE, "Upgrading, failed to update NetworkInterfaces.plist");
                                CFRelease(upgradeSourcePrefs);
                                CFRelease(upgradeSourceNIPrefs);
                                goto done;
                        }
 
-                       // Create BSD Name Mapping to facilitate mapping of services
+                       // create BSD name mapping to facilitate mapping of services
                        bsdNameMapping = _SCNetworkMigrationCreateBSDNameMapping(NULL, externalMapping);
 
                        serviceMapping = _SCNetworkMigrationCreateServiceMappingUsingBSDMapping(upgradeSourcePrefs, targetPrefs, bsdNameMapping);
 
-                       _SCNetworkMigrationDoServiceMigration(upgradeSourcePrefs, targetPrefs,
-                                                             serviceMapping, bsdNameMapping,
-                                                             NULL, NULL);
+                       _SCNetworkMigrationDoServiceMigration(upgradeSourcePrefs,
+                                                             targetPrefs,
+                                                             serviceMapping,
+                                                             bsdNameMapping,
+                                                             NULL,
+                                                             NULL);
                }
                CFRelease(upgradeSourcePrefs);
                CFRelease(upgradeSourceNIPrefs);
        } else {
                builtinMapping = _SCNetworkConfigurationCopyBuiltinMapping(sourceNetworkInterfacePrefs, targetNetworkInterfacePrefs);
+
                externalMapping = _SCNetworkConfigurationCopyExternalInterfaceMapping(sourceNetworkInterfacePrefs, targetNetworkInterfacePrefs);
+               SC_log(LOG_INFO,
+                      "Migrating, external interface mapping: %@",
+                      externalMapping);
 
                newTargetNetworkInterfaceEntity = _SCNetworkMigrationCreateNetworkInterfaceArray(targetNetworkInterfacePrefs, externalMapping, NULL);
-               if (isA_CFArray(newTargetNetworkInterfaceEntity) == NULL) {
-                       SC_log(LOG_INFO, "newTargetNetworkInterfaceEntity is NULL or not of correct type");
+               if (newTargetNetworkInterfaceEntity == NULL) {
+                       SC_log(LOG_NOTICE, "Migrating, failed w/no new interface list");
                        goto done;
                }
+
                // Write new interface mapping to NetworkInterfaces.plist
                if (!__SCNetworkInterfaceSaveStoredWithPreferences(targetNetworkInterfacePrefs, newTargetNetworkInterfaceEntity)) {
-                       SC_log(LOG_INFO, "SCNetworkInterfaceSaveStoreWithPreferences: failed to update NetworkInterfaces.plist");
+                       SC_log(LOG_NOTICE, "Migrating, failed to update NetworkInterfaces.plist");
                        goto done;
                }
-               // Create BSD Name Mapping to facilitate mapping of services
+
+               // create BSD name mapping to facilitate mapping of services
                bsdNameMapping = _SCNetworkMigrationCreateBSDNameMapping(builtinMapping, externalMapping);
 
-               if (isA_CFDictionary(bsdNameMapping) == NULL) {
-                       SC_log(LOG_INFO, "BSD name mapping is NULL");
-                       goto done;
-               }
-               SC_log(LOG_DEBUG, "BSD Name Mapping: %@", bsdNameMapping);
                serviceMapping = _SCNetworkMigrationCreateServiceMappingUsingBSDMapping(sourcePrefs, targetPrefs, bsdNameMapping);
                if (serviceMapping == NULL) {
                        goto done;
                }
 
                setMapping = _SCNetworkMigrationCreateSetMapping(sourcePrefs, targetPrefs);
+
                sourceServiceSetMapping = _SCNetworkMigrationCreateServiceSetMapping(sourcePrefs);
 
                // Perform the migration of services
                if (!_SCNetworkMigrationDoServiceMigration(sourcePrefs, targetPrefs,
                                                          serviceMapping, bsdNameMapping,
                                                          setMapping, sourceServiceSetMapping)) {
-                       SC_log(LOG_INFO, "SCNetworkMigrationDoServiceMigration: failed to complete successfully");
+                       SC_log(LOG_NOTICE, "SCNetworkMigrationDoServiceMigration(): service migration failed");
                        goto done;
                }
 
                if (!_SCNetworkMigrationDoVirtualNetworkInterfaceMigration(sourcePrefs, sourceNetworkInterfacePrefs,
                                                                          targetPrefs, targetNetworkInterfacePrefs,
                                                                          bsdNameMapping, setMapping, sourceServiceSetMapping)) {
-                       SC_log(LOG_INFO, "_SCNetworkMigrationDoVirtualNetworkInterfaceMigration: failed to complete successfully");
+                       SC_log(LOG_NOTICE, "SCNetworkMigrationDoServiceMigration(): virtual interface migration failed");
                }
 #endif // !TARGET_OS_IPHONE
                // Migrate Service Order
                if (!_SCNetworkMigrationDoServiceOrderMigration(sourcePrefs, targetPrefs, setMapping)) {
-                       SC_log(LOG_INFO, "_SCNetworkMigrationDoServiceOrderMigration: failed to complete successfully");
+                       SC_log(LOG_NOTICE, "SCNetworkMigrationDoServiceMigration(): service order migration failed");
                }
        }
 
        // Migrating System Information
        if (!isUpgradeScenario) {
                if (!_SCNetworkMigrationDoSystemMigration(sourcePrefs, targetPrefs)) {
-                       SC_log(LOG_INFO, "_SCNetworkMigrationDoSystemMigration: failed to complete successfully");
+                       SC_log(LOG_NOTICE, "SCNetworkMigrationDoServiceMigration(): system setting migration failed");
                }
        }
        if (!_SCNetworkConfigurationCheckValidityWithPreferences(targetPrefs, targetNetworkInterfacePrefs, validityOptions)) {
-               SC_log(LOG_INFO, "Migrated configuration not valid");
+               SC_log(LOG_NOTICE, "Migrated configuration not valid");
                goto done;
        }
        if (!SCPreferencesCommitChanges(targetPrefs)) {
-               SC_log(LOG_INFO, "SCPreferencesCommitChanges(target preferences.plist) failed: %s", SCErrorString(SCError()));
+               SC_log(LOG_NOTICE, "SCPreferencesCommitChanges(target preferences.plist) failed: %s", SCErrorString(SCError()));
                goto done;
        }
 
        if (!SCPreferencesCommitChanges(targetNetworkInterfacePrefs)) {
-               SC_log(LOG_INFO, "SCPreferencesCommitChanges(target NetworkInterfaces.plist) failed: %s", SCErrorString(SCError()));
+               SC_log(LOG_NOTICE, "SCPreferencesCommitChanges(target NetworkInterfaces.plist) failed: %s", SCErrorString(SCError()));
                goto done;
        }
        migrationSuccess = TRUE;
                                                                                     sizeof(PREFS_DEFAULT_CONFIG_PLIST),
                                                                                     FALSE,
                                                                                     baseConfigURL);
-
        if (!CFURLResourceIsReachable(configPreferencesURL, NULL)) {
-               SC_log(LOG_INFO, "No preferences.plist file");
+               SC_log(LOG_NOTICE, "No preferences.plist file: %@", configPreferencesURL);
                goto done;
        }
 
                                                                                           sizeof(INTERFACES_DEFAULT_CONFIG_PLIST),
                                                                                           FALSE,
                                                                                           baseConfigURL);
-
        if (!CFURLResourceIsReachable(configNetworkInterfacesURL, NULL)) {
-               SC_log(LOG_INFO, "No NetworkInterfaces.plist file");
+               SC_log(LOG_NOTICE, "No NetworkInterfaces.plist file: %@", configNetworkInterfacesURL);
                goto done;
        }
 
                                                                                       baseExpectedConfigURL);
 
        if (!CFURLResourceIsReachable(expectedPreferencesURL, NULL)) {
-               SC_log(LOG_INFO, "No expected preferences.plist file");
+               SC_log(LOG_NOTICE, "No expected preferences.plist file");
                goto done;
        }
 
                                                                                            baseExpectedConfigURL);
 
        if (!CFURLResourceIsReachable(expectedNetworkInterfaceURL, NULL)) {
-               SC_log(LOG_INFO, "No expected NetworkInterfaces.plist file");
+               SC_log(LOG_NOTICE, "No expected NetworkInterfaces.plist file");
                goto done;
        }
 
            expectedConfigPref == NULL ||
            configNetworkInterfacePref == NULL ||
            expectedNetworkInterfacePref == NULL) {
-               SC_log(LOG_INFO, "One of the preferences is NULL");
+               SC_log(LOG_NOTICE, "One of the preferences is NULL");
                isIdentical = FALSE;
        } else {
                isIdentical = (_SCNetworkMigrationAreServicesIdentical(configPref, expectedConfigPref) &&
 
 
        /* initialize non-zero/NULL members */
        MUTEX_INIT(&targetPrivate->lock);
-       if (_sc_log > 0) {
+       if (_sc_log > kSCLogDestinationFile) {
                snprintf(targetPrivate->log_prefix,
                         sizeof(targetPrivate->log_prefix),
                         "[%p] ",
 
                        if (targetDeviceName != NULL) {
                                // update mapping
                                CFDictionarySetValue(interfaceEntityMutable, kSCPropNetInterfaceDeviceName, targetDeviceName);
-                               ni_prefs = __SCPreferencesCreateNIPrefsFromPrefs(prefs);
+                               ni_prefs = SCPreferencesCreateCompanion(prefs, INTERFACES_DEFAULT_CONFIG);
                                ni_interface = __SCNetworkInterfaceCreateWithNIPreferencesUsingBSDName(NULL, ni_prefs, targetDeviceName);
                                if (ni_interface != NULL) {
                                        userDefinedNameInterface = __SCNetworkInterfaceGetUserDefinedName(ni_interface);
 
                return NULL;
        }
 
+
        path = SCPreferencesPathKeyCreateSetNetworkService(NULL, setPrivate->setID, NULL);
        dict = SCPreferencesPathGetValue(setPrivate->prefs, path);
        CFRelease(path);
 
 }
 
 
+__private_extern__
+Boolean
+__SCPreferencesIsEmpty(SCPreferencesRef        prefs)
+{
+       SCPreferencesPrivateRef prefsPrivate    = (SCPreferencesPrivateRef)prefs;
+
+       assert(prefs != NULL);
+       __SCPreferencesAccess(prefs);
+
+       if ((prefsPrivate->prefs == NULL) ||
+           (CFDictionaryGetCount(prefsPrivate->prefs) == 0)) {
+               return TRUE;
+       }
+
+       return FALSE;
+}
+
+
 __private_extern__
 off_t
 __SCPreferencesPrefsSize(SCPreferencesRef prefs)
        return isDefault;
 }
 
-__private_extern__
-SCPreferencesRef
-__SCPreferencesCreateNIPrefsFromPrefs(SCPreferencesRef prefs)
-{
-       SCPreferencesRef        ni_prefs;
-
-       // open [companion] NetworkInterfaces.plist
-       ni_prefs = SCPreferencesCreateCompanion(prefs, INTERFACES_DEFAULT_CONFIG);
-
-       // if needed, populate
-       __SCNetworkPopulateDefaultNIPrefs(ni_prefs);
-
-       return ni_prefs;
-}
-
 CFDataRef
 SCPreferencesGetSignature(SCPreferencesRef prefs)
 {
 
        /*
         * check if the preferences should be removed
         */
-       if (CFDictionaryGetCount(prefsPrivate->prefs) == 0) {
+       if (__SCPreferencesIsEmpty(prefs)) {
                CFBooleanRef    val;
 
                /* if empty */
 
                                                                0,
                                                                &kCFTypeDictionaryKeyCallBacks,
                                                                &kCFTypeDictionaryValueCallBacks);
-               prefsPrivate->changed = TRUE;
+               prefsPrivate->changed = FALSE;
        }
 
        SC_log(LOG_DEBUG, "SCPreferences() access: %s, size=%lld",
 
        prefsPrivate = __SCPreferencesCreate(allocator, name, prefsID, authorizationData, options);
        if (prefsPrivate != NULL) {
-               const char      *astr   = "";
-               const char      *ostr   = "";
+               const char      *opt_none       = "";
+               const char      *opt_1          = opt_none;
+               const char      *opt_2          = opt_none;
 
                if (options != NULL) {
-                       ostr = "options";
+                       opt_2 = "options";
                }
 
                if (authorization != NULL) {
                        if (authorization == kSCPreferencesUseEntitlementAuthorization) {
-                               astr = "entitlement";
+                               opt_1 = "entitlement";
                        } else {
-                               astr = "authorization";
+                               opt_1 = "authorization";
                        }
                }
 
                SC_log(LOG_DEBUG, "create w/%s%s%s %@",
-                      ostr,
-                      ((ostr != "") && (astr != "")) ? " + " : "",
-                      astr,
+                      opt_2,
+                      ((opt_2 != opt_none) && (opt_1 != opt_none)) ? " + " : "",
+                      opt_1,
                       prefsPrivate);
        }
 
 
 Boolean
 __SCPreferencesAddSession              (SCPreferencesRef       prefs);
 
+Boolean
+__SCPreferencesIsEmpty                 (SCPreferencesRef       prefs);
+
 void
 __SCPreferencesRemoveSession           (SCPreferencesRef       prefs);
 
 Boolean
 __SCPreferencesUsingDefaultPrefs       (SCPreferencesRef       prefs);
 
-SCPreferencesRef
-__SCPreferencesCreateNIPrefsFromPrefs  (SCPreferencesRef prefs);
-
 __END_DECLS
 
 #endif /* _SCPREFERENCESINTERNAL_H */
 
 #include <sys/syslog.h>
 #include <mach/message.h>
 #include <os/log.h>
+#include <os/log_private.h>
 #include <os/variant_private.h>
 #include <sys/sysctl.h>
 
 #endif
 
 
-/* framework variables */
-extern int     _sc_debug;      /* non-zero if debugging enabled */
-extern int     _sc_verbose;    /* non-zero if verbose logging enabled */
-extern int     _sc_log;        /* 0 if SC messages should be written to stdout/stderr,
-                                  1 if SC messages should be logged w/os_log(3),
-                                  2 if SC messages should be logged AND written to stdout/stderr
-                                  3 if SC messages should be logged AND written to stdout/stderr (w/o timestamp) */
+/* framework debugging/logging variables */
+typedef CF_ENUM(int, _SCLogDestination) {
+       kSCLogDestinationFile           = 0,    // if SC messages should be written to stdout/stderr
+       kSCLogDestinationDefault        = 1,    // if SC messages should be logged w/os_log(3)
+       kSCLogDestinationBoth           = 2,    // if SC messages should be logged AND written to stdout/stderr
+       kSCLogDestinationBoth_NoTime    = 3,    // if SC messages should be logged AND written to stdout/stderr (w/o timestamp)
+};
+
+extern int                     _sc_debug;      /* non-zero if debugging enabled */
+extern _SCLogDestination       _sc_log;
+extern int                     _sc_verbose;    /* non-zero if verbose logging enabled */
 
 
 /* notify(3) keys */
                of an os_log_t global (or a function that returns an os_log_t)
                *BEFORE* this header is #include'd. In that case, the noted
                log handle will be used.
-
-               Also, by #define'ing SC_LOG_OR_PRINT, we will check the "_sc_log"
-               global to see if the messages should [also] be directed to stdout/stderr.
-
        @param level The syslog(3 logging priority.
        @param __string The format string
        @result The specified message will be written to the unified logging system.
     SC_LOG_HANDLE_TYPE os_log_t        SC_LOG_HANDLE(void);
   #else        // SC_LOG_HANDLE
     #define    SC_LOG_HANDLE   _SC_LOG_DEFAULT         // use [SC] default os_log handle
-    #ifndef    SC_LOG_OR_PRINT
-      #define  USE_SC_LOG_OR_PRINT     1               // and use '_sc_log' to control os_log, printf
-    #endif     // !SC_LOG_OR_PRINT
   #endif       // !SC_LOG_HANDLE
 
-  #if  USE_SC_LOG_OR_PRINT
-    #define    SC_log(__level, __format, ...)                                          \
-       do {                                                                            \
-               os_log_t        __handle = SC_LOG_HANDLE();                             \
-               os_log_type_t   __type   = _SC_syslog_os_log_mapping(__level);          \
-                                                                                       \
-               if (((_sc_log != 1) && ((__level > LOG_DEBUG) || _sc_debug)) ||         \
-                   os_log_type_enabled(__handle, __type)) {                            \
-                       __SC_Log(__level,                                               \
-                                CFSTR( __format ),                                     \
-                                __handle,                                              \
-                                __type,                                                \
-                                __format,                                              \
-                                ## __VA_ARGS__);                                       \
-               }                                                                       \
-       } while (0)
-  #else        // USE_SC_LOG_OR_PRINT
-    #define    SC_log(__level, __format, ...)                                          \
-       do {                                                                            \
-               os_log_t        __handle = SC_LOG_HANDLE();                             \
-               os_log_type_t   __type = _SC_syslog_os_log_mapping(__level);            \
-                                                                                       \
-               os_log_with_type(__handle, __type, __format, ## __VA_ARGS__);           \
-       } while (0)
-  #endif       // USE_SC_LOG_OR_PRINT
-#endif // !SC_log
 
+  #define      SC_log(__level, __format, ...)                                                  \
+    do {                                                                                       \
+       os_log_t        __handle        = SC_LOG_HANDLE();                                      \
+       os_log_type_t   __type          = _SC_syslog_os_log_mapping(__level);                   \
+                                                                                               \
+       if (__SC_log_enabled(__level, __handle, __type)) {                                      \
+               size_t  __pack_size     = os_log_pack_size(__format, ##__VA_ARGS__);            \
+                                                                                               \
+               _Pragma("clang diagnostic push")                                                \
+               _Pragma("clang diagnostic ignored \"-Wvla\"")                                   \
+               _Pragma("clang diagnostic ignored \"-Wgnu-statement-expression\"")              \
+               os_log_pack_decl(__pack, __pack_size);                                          \
+               os_log_pack_fill(__pack, __pack_size, errno, __format, ##__VA_ARGS__);          \
+               _Pragma("clang diagnostic pop")                                                 \
+                                                                                               \
+               __SC_log_send(__level, __handle, __type, __pack);                               \
+       }                                                                                       \
+    } while (0)
+
+/*!
+       @function __SC_log_enabled
+       @discussion Checks to see whether a log message will be issued
+       @param level A syslog(3) logging priority. If less than 0, log message is multi-line
+       @param log The os_log_t handle (for logging)
+       @param type The os_log_type_t type (for logging)
+ */
+Boolean                __SC_log_enabled                (int                    level,
+                                                os_log_t               log,
+                                                os_log_type_t          type);
 
 /*!
-       @function __SC_Log
-       @discussion Issue a log message w/os_log(3) or printf(3).
+       @function __SC_log_send
+       @discussion Issue an os_log_pack message w/os_log(3), syslog(3), or printf(3).
                The specified message will be written to the system message
                logger.
        @param level A syslog(3) logging priority. If less than 0, log message is multi-line
-       @param format_CF The format string (as a CFString for stdout/stderr)
        @param log The os_log_t handle (for logging)
        @param type The os_log_type_t type (for logging)
-       @param format The format string (for logging)
- stream.
- */
-void           __SC_Log                        (int            level,
-                                                CFStringRef    format_CF,
-                                                os_log_t       log,
-                                                os_log_type_t  type,
-                                                const char     *format,
-                                                ...)   CF_FORMAT_FUNCTION(2, 6) __attribute__((format(os_log, 5, 6)));
+       @param pack The os_log_pack_t message
+ */
+void           __SC_log_send                   (int                    level,
+                                                os_log_t               log,
+                                                os_log_type_t          type,
+                                                os_log_pack_t          pack);
+
+#endif // !SC_log
 
 
 /*!
 
 /*
- * Copyright (c) 2018 Apple Inc. All rights reserved.
+ * Copyright (c) 2018, 2020 Apple Inc. All rights reserved.
  *
  * @APPLE_LICENSE_HEADER_START@
  *
 void
 _SCDPluginExecInit             (void);
 
+void
+__SC_Log                       (int            level,
+                                CFStringRef    format_CF,
+                                os_log_t       log,
+                                os_log_type_t  type,
+                                const char     *format,
+                                ...)   CF_FORMAT_FUNCTION(2, 6) __attribute__((format(os_log, 5, 6)));
+
 __END_DECLS
 
 #endif // _SYSTEMCONFIGURATIONINTERNAL_H
 
 /*
- * Copyright (c) 2003-2013, 2015-2018 Apple Inc. All rights reserved.
+ * Copyright (c) 2003-2013, 2015-2018, 2020 Apple Inc. All rights reserved.
  *
  * @APPLE_LICENSE_HEADER_START@
  *
        if (__SCPreferencesUsingDefaultPrefs(prefs)) {
                ni_prefs = NULL;
        } else {
-               ni_prefs = __SCPreferencesCreateNIPrefsFromPrefs(prefs);
+               ni_prefs = SCPreferencesCreateCompanion(prefs, INTERFACES_DEFAULT_CONFIG);
        }
+
        context.vlans = CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks);
        context.ni_prefs = ni_prefs;
        context.prefs = prefs;
        if (isA_CFDictionary(dict)) {
                my_CFDictionaryApplyFunction(dict, add_configured_interface, &context);
        }
+
        if (ni_prefs != NULL) {
                CFRelease(ni_prefs);
        }
 
 /*
- * Copyright (c) 2002-2008, 2010-2015, 2017 Apple Inc. All rights reserved.
+ * Copyright (c) 2002-2008, 2010-2015, 2017, 2020 Apple Inc. All rights reserved.
  *
  * @APPLE_LICENSE_HEADER_START@
  *
 _SecTrustedApplicationCreateFromPath(const char *path, SecTrustedApplicationRef *app)
 {
        #undef SecTrustedApplicationCreateFromPath
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wdeprecated"
        static typeof (SecTrustedApplicationCreateFromPath) *dyfunc = NULL;
+#pragma GCC diagnostic pop
        if (!dyfunc) {
                void *image = __loadSecurity();
                if (image) dyfunc = dlsym(image, "SecTrustedApplicationCreateFromPath");
 
 /*
- * Copyright (c) 2000-2011, 2013-2019 Apple Inc. All rights reserved.
+ * Copyright (c) 2000-2011, 2013-2020 Apple Inc. All rights reserved.
  *
  * @APPLE_LICENSE_HEADER_START@
  *
                case SIGINT :
                case SIGTERM :
                        if (termRequested != NULL) {
-                               if (_sc_log > 0) {
+                               if (_sc_log > kSCLogDestinationFile) {
                                        /*
                                         * if we've received a [shutdown] SIGTERM
                                         * and we are syslog'ing than it's likely
                                         * such, let's also push any remaining log
                                         * messages to stdout/stderr.
                                         */
-                                       _sc_log = 2;
+                                       _sc_log = kSCLogDestinationBoth;
                                }
 
                                /*
         * setup logging.
         */
        if (!forceForeground || forcePlugin) {
-               int             facility        = LOG_DAEMON;
-               int             logopt          = LOG_CONS|LOG_NDELAY|LOG_PID;
-
                if (!is_launchd_job && !forcePlugin) {
                        init_fds();
                }
 
-               if (_configd_verbose) {
-                       logopt |= LOG_CONS;
-               }
-
                if (_SC_isInstallEnvironment()) {
-                       facility = LOG_INSTALL;
+                       openlog("configd",
+                               LOG_CONS|LOG_NDELAY|LOG_PID,    // logopt
+                               LOG_INSTALL);                   // facility
                }
-
-               openlog("configd", logopt, facility);
        } else {
-               _sc_log = FALSE;        /* redirect SCLog() to stdout/stderr */
+               _sc_log = kSCLogDestinationFile;        /* redirect SCLog() to stdout/stderr */
        }
 
        /* add signal handler to catch a SIGHUP */
 
                150BEC1A14CA252200237116 /* dnsinfo_server.c in Sources */ = {isa = PBXBuildFile; fileRef = 15B73F0D05FD1B670096477F /* dnsinfo_server.c */; };
                150D7E1E0D16DC6C00AF4BED /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1520A3DE0846B2DC0010B584 /* Security.framework */; };
                150EC0FF21016BFD0047F4BF /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1547072E0D1F70C80075C28D /* SystemConfiguration.framework */; };
+               1514055A23EC9F3F0007B23F /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1559C4440D349A4E0098FD59 /* SystemConfiguration.framework */; };
                151D060E1EC14C8600E02E48 /* liblog_SystemConfiguration.m in Sources */ = {isa = PBXBuildFile; fileRef = 151D060D1EC14C6700E02E48 /* liblog_SystemConfiguration.m */; };
                1520A3870846829A0010B584 /* CoreFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 15CB6A6F05C0722B0099E85F /* CoreFoundation.framework */; };
                1520A3DF0846B2DD0010B584 /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1520A3DE0846B2DC0010B584 /* Security.framework */; };
                1565D85018B847590097062B /* SCNetworkMigration.c in Sources */ = {isa = PBXBuildFile; fileRef = 55A3DB9D183C2A8200ED3DB7 /* SCNetworkMigration.c */; };
                1565D85118B847F20097062B /* SCNetworkMigration.c in Sources */ = {isa = PBXBuildFile; fileRef = 55A3DB9D183C2A8200ED3DB7 /* SCNetworkMigration.c */; };
                156BD6BC07E0DFA9008698FF /* SCPreferencesSetSpecificPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 156BD6BB07E0DFA9008698FF /* SCPreferencesSetSpecificPrivate.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               15703B2922320A940018D2EE /* test-objC.m in Sources */ = {isa = PBXBuildFile; fileRef = 72D3E66B1AE6EAF600DB4C69 /* test-objC.m */; };
                1572AA8D1D8235940021E093 /* plugin_shared.h in Headers */ = {isa = PBXBuildFile; fileRef = 1572AA8B1D8234500021E093 /* plugin_shared.h */; };
                1572AA8E1D8235A40021E093 /* plugin_shared.h in Headers */ = {isa = PBXBuildFile; fileRef = 1572AA8B1D8234500021E093 /* plugin_shared.h */; };
                1572AA8F1D82375A0021E093 /* plugin_shared.h in Headers */ = {isa = PBXBuildFile; fileRef = 1572AA8B1D8234500021E093 /* plugin_shared.h */; };
                        name = "Copy Files";
                        runOnlyForDeploymentPostprocessing = 1;
                };
-               15E91DBA21893E83001155DC /* CopyFiles */ = {
-                       isa = PBXCopyFilesBuildPhase;
-                       buildActionMask = 2147483647;
-                       dstPath = /usr/share/man/man1/;
-                       dstSubfolderSpec = 0;
-                       files = (
-                       );
-                       runOnlyForDeploymentPostprocessing = 1;
-               };
-               15E91DD221893EE1001155DC /* CopyFiles */ = {
-                       isa = PBXCopyFilesBuildPhase;
-                       buildActionMask = 2147483647;
-                       dstPath = /usr/share/man/man1/;
-                       dstSubfolderSpec = 0;
-                       files = (
-                       );
-                       runOnlyForDeploymentPostprocessing = 1;
-               };
-               15EF89AD21894636003B2C5C /* CopyFiles */ = {
-                       isa = PBXCopyFilesBuildPhase;
-                       buildActionMask = 2147483647;
-                       dstPath = /usr/share/man/man1/;
-                       dstSubfolderSpec = 0;
-                       files = (
-                       );
-                       runOnlyForDeploymentPostprocessing = 1;
-               };
-               15EF89B821894665003B2C5C /* CopyFiles */ = {
-                       isa = PBXCopyFilesBuildPhase;
-                       buildActionMask = 2147483647;
-                       dstPath = /usr/share/man/man1/;
-                       dstSubfolderSpec = 0;
-                       files = (
-                       );
-                       runOnlyForDeploymentPostprocessing = 1;
-               };
                15FF5C380CDF778F00EEC8AA /* CopyFiles */ = {
                        isa = PBXCopyFilesBuildPhase;
                        buildActionMask = 8;
                        name = npt_configd.plist;
                        runOnlyForDeploymentPostprocessing = 1;
                };
-               72D3E65C1AE6EA3900DB4C69 /* CopyFiles */ = {
-                       isa = PBXCopyFilesBuildPhase;
-                       buildActionMask = 2147483647;
-                       dstPath = /usr/share/man/man1/;
-                       dstSubfolderSpec = 0;
-                       files = (
-                       );
-                       runOnlyForDeploymentPostprocessing = 1;
-               };
-               72D3E6671AE6EAF600DB4C69 /* CopyFiles */ = {
-                       isa = PBXCopyFilesBuildPhase;
-                       buildActionMask = 2147483647;
-                       dstPath = /usr/share/man/man1/;
-                       dstSubfolderSpec = 0;
-                       files = (
-                       );
-                       runOnlyForDeploymentPostprocessing = 1;
-               };
                F963400F20FE8E4100F1E1F1 /* CopyFiles */ = {
                        isa = PBXCopyFilesBuildPhase;
                        buildActionMask = 8;
                        buildActionMask = 2147483647;
                        files = (
                                C4666C72206ED01800247AB6 /* EventFactory.framework in Frameworks */,
+                               1514055A23EC9F3F0007B23F /* SystemConfiguration.framework in Frameworks */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
                        productReference = 155F49A21C864F5400E47D08 /* QoSMarking.bundle */;
                        productType = "com.apple.product-type.bundle";
                };
+               15703B2422320A940018D2EE /* SCTest-ObjC-iOSMac */ = {
+                       isa = PBXNativeTarget;
+                       buildConfigurationList = 15703B2D22320A940018D2EE /* Build configuration list for PBXNativeTarget "SCTest-ObjC-iOSMac" */;
+                       buildPhases = (
+                               15703B2722320A940018D2EE /* Flush Module Cache */,
+                               15703B2822320A940018D2EE /* Sources */,
+                               15703B2A22320A940018D2EE /* Frameworks */,
+                       );
+                       buildRules = (
+                       );
+                       dependencies = (
+                       );
+                       name = "SCTest-ObjC-iOSMac";
+                       productName = "SCTest-ObjC";
+                       productType = "com.apple.product-type.tool";
+               };
                1572C4A60CFB55B400E2776E /* SystemConfiguration.framework-Embedded */ = {
                        isa = PBXNativeTarget;
                        buildConfigurationList = 1572C5290CFB55B400E2776E /* Build configuration list for PBXNativeTarget "SystemConfiguration.framework-Embedded" */;
                                15E91DB521893E83001155DC /* Flush Module Cache */,
                                15E91DB621893E83001155DC /* Sources */,
                                15E91DB821893E83001155DC /* Frameworks */,
-                               15E91DBA21893E83001155DC /* CopyFiles */,
                        );
                        buildRules = (
                        );
                        isa = PBXNativeTarget;
                        buildConfigurationList = 15E91DD321893EE1001155DC /* Build configuration list for PBXNativeTarget "SCTest-Swift-Embedded" */;
                        buildPhases = (
+                               15EB93A7243D4AFA0088A86B /* Flush Module Cache */,
                                15E91DCF21893EE1001155DC /* Sources */,
                                15E91DD121893EE1001155DC /* Frameworks */,
-                               15E91DD221893EE1001155DC /* CopyFiles */,
                        );
                        buildRules = (
                        );
                                15EF89A821894636003B2C5C /* Flush Module Cache */,
                                15EF89A921894636003B2C5C /* Sources */,
                                15EF89AB21894636003B2C5C /* Frameworks */,
-                               15EF89AD21894636003B2C5C /* CopyFiles */,
                        );
                        buildRules = (
                        );
                        buildPhases = (
                                15EF89B521894665003B2C5C /* Sources */,
                                15EF89B721894665003B2C5C /* Frameworks */,
-                               15EF89B821894665003B2C5C /* CopyFiles */,
                        );
                        buildRules = (
                        );
                        isa = PBXNativeTarget;
                        buildConfigurationList = 72D3E6621AE6EA3A00DB4C69 /* Build configuration list for PBXNativeTarget "SCTest-Swift" */;
                        buildPhases = (
+                               15EB93A8243D51390088A86B /* Flush Module Cache */,
                                72D3E65A1AE6EA3900DB4C69 /* Sources */,
                                72D3E65B1AE6EA3900DB4C69 /* Frameworks */,
-                               72D3E65C1AE6EA3900DB4C69 /* CopyFiles */,
                        );
                        buildRules = (
                        );
                                150EC0FE21016BAA0047F4BF /* Flush Module Cache */,
                                72D3E6651AE6EAF600DB4C69 /* Sources */,
                                72D3E6661AE6EAF600DB4C69 /* Frameworks */,
-                               72D3E6671AE6EAF600DB4C69 /* CopyFiles */,
                        );
                        buildRules = (
                        );
                        isa = PBXNativeTarget;
                        buildConfigurationList = C4666C77206ED01800247AB6 /* Build configuration list for PBXNativeTarget "SystemConfigurationEventFactory" */;
                        buildPhases = (
+                               1553688B24397CC6004735C3 /* Flush Module Cache */,
                                C4666C6D206ED01800247AB6 /* Sources */,
                                C4666C6E206ED01800247AB6 /* Frameworks */,
                        );
                15CB6A7705C0722B0099E85F /* Project object */ = {
                        isa = PBXProject;
                        attributes = {
-                               LastUpgradeCheck = 1100;
+                               LastUpgradeCheck = 1200;
                                TargetAttributes = {
                                        15401C1C21991506006326B7 = {
                                                CreatedOnToolsVersion = 11.0;
                                        };
                                        72D3E65D1AE6EA3900DB4C69 = {
                                                CreatedOnToolsVersion = 7.0;
+                                               LastSwiftMigration = 1140;
                                        };
                                        72D3E6681AE6EAF600DB4C69 = {
                                                CreatedOnToolsVersion = 7.0;
                                72D3E6681AE6EAF600DB4C69 /* SCTest-ObjC */,
                                15E91DB221893E83001155DC /* SCTest-ObjC-Embedded */,
                                15EF89A521894636003B2C5C /* SCTest-ObjC-EmbeddedSimulator */,
+                               15703B2422320A940018D2EE /* SCTest-ObjC-iOSMac */,
                                72D3E65D1AE6EA3900DB4C69 /* SCTest-Swift */,
                                15E91DCC21893EE1001155DC /* SCTest-Swift-Embedded */,
                                15EF89B221894665003B2C5C /* SCTest-Swift-EmbeddedSimulator */,
                        shellScript = "${SRCROOT}/update-sanitizer-dylib-references";
                        showEnvVarsInLog = 0;
                };
+               1553688B24397CC6004735C3 /* Flush Module Cache */ = {
+                       isa = PBXShellScriptBuildPhase;
+                       buildActionMask = 2147483647;
+                       files = (
+                       );
+                       inputFileListPaths = (
+                       );
+                       inputPaths = (
+                       );
+                       name = "Flush Module Cache";
+                       outputFileListPaths = (
+                       );
+                       outputPaths = (
+                       );
+                       runOnlyForDeploymentPostprocessing = 0;
+                       shellPath = /bin/sh;
+                       shellScript = "rm -rf \"${CLANG_MODULE_CACHE_PATH}\"\n";
+                       showEnvVarsInLog = 0;
+               };
+               15703B2722320A940018D2EE /* Flush Module Cache */ = {
+                       isa = PBXShellScriptBuildPhase;
+                       buildActionMask = 2147483647;
+                       files = (
+                       );
+                       inputFileListPaths = (
+                       );
+                       inputPaths = (
+                       );
+                       name = "Flush Module Cache";
+                       outputFileListPaths = (
+                       );
+                       outputPaths = (
+                       );
+                       runOnlyForDeploymentPostprocessing = 0;
+                       shellPath = /bin/sh;
+                       shellScript = "rm -rf \"${CLANG_MODULE_CACHE_PATH}\"\n";
+                       showEnvVarsInLog = 0;
+               };
                1572C5270CFB55B400E2776E /* get-mobility-info */ = {
                        isa = PBXShellScriptBuildPhase;
                        buildActionMask = 8;
                        shellScript = "rm -rf \"${CLANG_MODULE_CACHE_PATH}\"\n";
                        showEnvVarsInLog = 0;
                };
+               15EB93A7243D4AFA0088A86B /* Flush Module Cache */ = {
+                       isa = PBXShellScriptBuildPhase;
+                       buildActionMask = 2147483647;
+                       files = (
+                       );
+                       inputFileListPaths = (
+                       );
+                       inputPaths = (
+                       );
+                       name = "Flush Module Cache";
+                       outputFileListPaths = (
+                       );
+                       outputPaths = (
+                       );
+                       runOnlyForDeploymentPostprocessing = 0;
+                       shellPath = /bin/sh;
+                       shellScript = "rm -rf \"${CLANG_MODULE_CACHE_PATH}\"\n";
+                       showEnvVarsInLog = 0;
+               };
+               15EB93A8243D51390088A86B /* Flush Module Cache */ = {
+                       isa = PBXShellScriptBuildPhase;
+                       buildActionMask = 2147483647;
+                       files = (
+                       );
+                       inputFileListPaths = (
+                       );
+                       inputPaths = (
+                       );
+                       name = "Flush Module Cache";
+                       outputFileListPaths = (
+                       );
+                       outputPaths = (
+                       );
+                       runOnlyForDeploymentPostprocessing = 0;
+                       shellPath = /bin/sh;
+                       shellScript = "rm -rf \"${CLANG_MODULE_CACHE_PATH}\"\n";
+                       showEnvVarsInLog = 0;
+               };
                15EF89A821894636003B2C5C /* Flush Module Cache */ = {
                        isa = PBXShellScriptBuildPhase;
                        buildActionMask = 2147483647;
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
+               15703B2822320A940018D2EE /* Sources */ = {
+                       isa = PBXSourcesBuildPhase;
+                       buildActionMask = 2147483647;
+                       files = (
+                               15703B2922320A940018D2EE /* test-objC.m in Sources */,
+                       );
+                       runOnlyForDeploymentPostprocessing = 0;
+               };
                1572C4DE0CFB55B400E2776E /* Sources */ = {
                        isa = PBXSourcesBuildPhase;
                        buildActionMask = 2147483647;
                151F5D9C0CCE98E60093AC3B /* Debug */ = {
                        isa = XCBuildConfiguration;
                        buildSettings = {
-                               CODE_SIGN_IDENTITY = "-";
                                DYLIB_COMPATIBILITY_VERSION = 1;
                                DYLIB_CURRENT_VERSION = "$(RC_ProjectSourceVersion)";
                                FRAMEWORK_SEARCH_PATHS = "$(SYMROOT)";
                151F5D9D0CCE98E60093AC3B /* Release */ = {
                        isa = XCBuildConfiguration;
                        buildSettings = {
-                               CODE_SIGN_IDENTITY = "-";
                                DYLIB_COMPATIBILITY_VERSION = 1;
                                DYLIB_CURRENT_VERSION = "$(RC_ProjectSourceVersion)";
                                FRAMEWORK_SEARCH_PATHS = "$(SYMROOT)";
                                        "-lxpc",
                                );
                                "OTHER_LDFLAGS_asan[arch=i386]" = "";
-                               "OTHER_LDFLAGS_asan[sdk=iphoneos*]" = "$(inherited) -L/usr/local/lib/sanitizers -lclang_rt.asan_ios_dynamic";
-                               "OTHER_LDFLAGS_asan[sdk=iphonesimulator*]" = "$(inherited) -L/usr/local/lib/sanitizers -lclang_rt.asan_iossim_dynamic";
-                               "OTHER_LDFLAGS_asan[sdk=macosx*]" = "$(inherited) -L/usr/local/lib/sanitizers -lclang_rt.asan_osx_dynamic";
-                               "OTHER_LDFLAGS_asan[sdk=tvos*]" = "$(inherited) -L/usr/local/lib/sanitizers -lclang_rt.asan_tvos_dynamic";
-                               "OTHER_LDFLAGS_asan[sdk=tvossimulator*]" = "$(inherited) -L/usr/local/lib/sanitizers -lclang_rt.asan_tvosossim_dynamic";
-                               "OTHER_LDFLAGS_asan[sdk=watchos*]" = "$(inherited) -L/usr/local/lib/sanitizers -lclang_rt.asan_watchos_dynamic";
-                               "OTHER_LDFLAGS_asan[sdk=watchsimulator*]" = "$(inherited) -L/usr/local/lib/sanitizers -lclang_rt.asan_watchossim_dynamic";
+                               "OTHER_LDFLAGS_asan[sdk=macosx*]" = "$(inherited) -L/usr/appleinternal/lib/sanitizers -lclang_rt.asan_osx_dynamic";
                                "OTHER_LDFLAGS_tsan[arch=i386]" = "";
-                               "OTHER_LDFLAGS_tsan[sdk=iphoneos*]" = "$(inherited) -L/usr/local/lib/sanitizers -lclang_rt.tsan_ios_dynamic";
-                               "OTHER_LDFLAGS_tsan[sdk=iphonesimulator*]" = "$(inherited) -L/usr/local/lib/sanitizers -lclang_rt.tsan_iossim_dynamic";
-                               "OTHER_LDFLAGS_tsan[sdk=macosx*]" = "$(inherited) -L/usr/local/lib/sanitizers -lclang_rt.tsan_osx_dynamic";
-                               "OTHER_LDFLAGS_tsan[sdk=tvos*]" = "$(inherited) -L/usr/local/lib/sanitizers -lclang_rt.tsan_tvos_dynamic";
-                               "OTHER_LDFLAGS_tsan[sdk=tvossimulator*]" = "$(inherited) -L/usr/local/lib/sanitizers -lclang_rt.tsan_tvosossim_dynamic";
-                               "OTHER_LDFLAGS_tsan[sdk=watchos*]" = "$(inherited) -L/usr/local/lib/sanitizers -lclang_rt.tsan_watchos_dynamic";
-                               "OTHER_LDFLAGS_tsan[sdk=watchsimulator*]" = "$(inherited) -L/usr/local/lib/sanitizers -lclang_rt.tsan_watchossim_dynamic";
+                               "OTHER_LDFLAGS_tsan[sdk=macosx*]" = "$(inherited) -L/usr/appleinternal/lib/sanitizers -lclang_rt.tsan_osx_dynamic";
                                OTHER_TAPI_FLAGS = "$(inherited) -umbrella System --extra-private-header=$(PROJECT_DIR)/libSystemConfiguration/libSystemConfiguration_internal.h --extra-private-header=$(PROJECT_DIR)/nwi/network_information_internal.h --extra-private-header=$(PROJECT_DIR)/nwi/network_config_agent_info_priv.h";
                                PRODUCT_NAME = libsystem_configuration;
                                STRIP_INSTALLED_PRODUCT_asan = NO;
                                        "-lxpc",
                                );
                                "OTHER_LDFLAGS_asan[arch=i386]" = "";
-                               "OTHER_LDFLAGS_asan[sdk=iphoneos*]" = "$(inherited) -L/usr/local/lib/sanitizers -lclang_rt.asan_ios_dynamic";
-                               "OTHER_LDFLAGS_asan[sdk=iphonesimulator*]" = "$(inherited) -L/usr/local/lib/sanitizers -lclang_rt.asan_iossim_dynamic";
-                               "OTHER_LDFLAGS_asan[sdk=macosx*]" = "$(inherited) -L/usr/local/lib/sanitizers -lclang_rt.asan_osx_dynamic";
-                               "OTHER_LDFLAGS_asan[sdk=tvos*]" = "$(inherited) -L/usr/local/lib/sanitizers -lclang_rt.asan_tvos_dynamic";
-                               "OTHER_LDFLAGS_asan[sdk=tvossimulator*]" = "$(inherited) -L/usr/local/lib/sanitizers -lclang_rt.asan_tvosossim_dynamic";
-                               "OTHER_LDFLAGS_asan[sdk=watchos*]" = "$(inherited) -L/usr/local/lib/sanitizers -lclang_rt.asan_watchos_dynamic";
-                               "OTHER_LDFLAGS_asan[sdk=watchsimulator*]" = "$(inherited) -L/usr/local/lib/sanitizers -lclang_rt.asan_watchossim_dynamic";
+                               "OTHER_LDFLAGS_asan[sdk=macosx*]" = "$(inherited) -L/usr/appleinternal/lib/sanitizers -lclang_rt.asan_osx_dynamic";
                                "OTHER_LDFLAGS_tsan[arch=i386]" = "";
-                               "OTHER_LDFLAGS_tsan[sdk=iphoneos*]" = "$(inherited) -L/usr/local/lib/sanitizers -lclang_rt.tsan_ios_dynamic";
-                               "OTHER_LDFLAGS_tsan[sdk=iphonesimulator*]" = "$(inherited) -L/usr/local/lib/sanitizers -lclang_rt.tsan_iossim_dynamic";
-                               "OTHER_LDFLAGS_tsan[sdk=macosx*]" = "$(inherited) -L/usr/local/lib/sanitizers -lclang_rt.tsan_osx_dynamic";
-                               "OTHER_LDFLAGS_tsan[sdk=tvos*]" = "$(inherited) -L/usr/local/lib/sanitizers -lclang_rt.tsan_tvos_dynamic";
-                               "OTHER_LDFLAGS_tsan[sdk=tvossimulator*]" = "$(inherited) -L/usr/local/lib/sanitizers -lclang_rt.tsan_tvosossim_dynamic";
-                               "OTHER_LDFLAGS_tsan[sdk=watchos*]" = "$(inherited) -L/usr/local/lib/sanitizers -lclang_rt.tsan_watchos_dynamic";
-                               "OTHER_LDFLAGS_tsan[sdk=watchsimulator*]" = "$(inherited) -L/usr/local/lib/sanitizers -lclang_rt.tsan_watchossim_dynamic";
+                               "OTHER_LDFLAGS_tsan[sdk=macosx*]" = "$(inherited) -L/usr/appleinternal/lib/sanitizers -lclang_rt.tsan_osx_dynamic";
                                OTHER_TAPI_FLAGS = "$(inherited) -umbrella System --extra-private-header=$(PROJECT_DIR)/libSystemConfiguration/libSystemConfiguration_internal.h --extra-private-header=$(PROJECT_DIR)/nwi/network_information_internal.h --extra-private-header=$(PROJECT_DIR)/nwi/network_config_agent_info_priv.h";
                                PRODUCT_NAME = libsystem_configuration;
                                STRIP_INSTALLED_PRODUCT_asan = NO;
                                );
                                MODULEMAP_FILE = SystemConfiguration.fproj/Modules/SystemConfiguration.modulemap;
                                MODULEMAP_PRIVATE_FILE = SystemConfiguration.fproj/Modules/SystemConfiguration.private.modulemap;
-                               OTHER_CFLAGS = (
-                                       "$(inherited)",
-                                       "-DSC_LOG_OR_PRINT",
-                               );
                                OTHER_CFLAGS_debug = "-O0";
                                OTHER_TAPI_FLAGS = "$(inherited) -DEXCLUDE_VPN_TUNNEL_PLUGIN_FUNCTIONS -I$(SDKROOT)$(SYSTEM_LIBRARY_DIR)/Frameworks/System.framework/PrivateHeaders --extra-private-header=$(PROJECT_DIR)/SystemConfiguration.fproj/SystemConfigurationInternal.h --extra-private-header=$(PROJECT_DIR)/SystemConfiguration.fproj/SCDynamicStoreInternal.h --verify-api-skip-external-headers";
                                PRODUCT_BUNDLE_IDENTIFIER = com.apple.SystemConfiguration;
                                );
                                MODULEMAP_FILE = SystemConfiguration.fproj/Modules/SystemConfiguration.modulemap;
                                MODULEMAP_PRIVATE_FILE = SystemConfiguration.fproj/Modules/SystemConfiguration.private.modulemap;
-                               OTHER_CFLAGS = (
-                                       "$(inherited)",
-                                       "-DSC_LOG_OR_PRINT",
-                               );
                                OTHER_CFLAGS_debug = "-O0";
                                OTHER_TAPI_FLAGS = "$(inherited) -DEXCLUDE_VPN_TUNNEL_PLUGIN_FUNCTIONS -I$(SDKROOT)$(SYSTEM_LIBRARY_DIR)/Frameworks/System.framework/PrivateHeaders --extra-private-header=$(PROJECT_DIR)/SystemConfiguration.fproj/SystemConfigurationInternal.h --extra-private-header=$(PROJECT_DIR)/SystemConfiguration.fproj/SCDynamicStoreInternal.h --verify-api-skip-external-headers";
                                PRODUCT_BUNDLE_IDENTIFIER = com.apple.SystemConfiguration;
                                SDKROOT = macosx.internal;
                                SUPPORTED_PLATFORMS = macosx;
                                SUPPORTS_TEXT_BASED_API = YES;
-                               SWIFT_VERSION = 4.2;
+                               SWIFT_VERSION = 5.0;
                                TAPI_VERIFY_MODE = Pedantic;
                                VERSIONING_SYSTEM = "apple-generic";
                                VERSION_INFO_PREFIX = "__attribute__((visibility(\"hidden\")))";
                                SUPPORTED_PLATFORMS = macosx;
                                SUPPORTS_TEXT_BASED_API = YES;
                                SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
-                               SWIFT_VERSION = 4.2;
+                               SWIFT_VERSION = 5.0;
                                TAPI_VERIFY_MODE = Pedantic;
                                VERSIONING_SYSTEM = "apple-generic";
                                VERSION_INFO_PREFIX = "__attribute__((visibility(\"hidden\")))";
                        };
                        name = Release;
                };
+               15703B2E22320A940018D2EE /* Debug */ = {
+                       isa = XCBuildConfiguration;
+                       buildSettings = {
+                               CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES = YES;
+                               CLANG_ENABLE_MODULES = YES;
+                               CLANG_MODULES_DISABLE_PRIVATE_WARNING = YES;
+                               OTHER_CFLAGS = (
+                                       "$(inherited)",
+                                       "-Wnon-modular-include-in-module",
+                                       "-DUSING_PUBLIC_SDK",
+                               );
+                               PRODUCT_NAME = "$(TARGET_NAME)";
+                               SDKROOT = iphoneos.internal;
+                               "SDK_VARIANT[sdk=macosx*]" = iosmac;
+                               SUPPORTED_PLATFORMS = "macosx iphoneos";
+                               SUPPORTS_IOSMAC = YES;
+                       };
+                       name = Debug;
+               };
+               15703B2F22320A940018D2EE /* Release */ = {
+                       isa = XCBuildConfiguration;
+                       buildSettings = {
+                               CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES = YES;
+                               CLANG_ENABLE_MODULES = YES;
+                               CLANG_MODULES_DISABLE_PRIVATE_WARNING = YES;
+                               OTHER_CFLAGS = (
+                                       "$(inherited)",
+                                       "-Wnon-modular-include-in-module",
+                                       "-DUSING_PUBLIC_SDK",
+                               );
+                               PRODUCT_NAME = "$(TARGET_NAME)";
+                               SDKROOT = iphoneos.internal;
+                               "SDK_VARIANT[sdk=macosx*]" = iosmac;
+                               SUPPORTED_PLATFORMS = "macosx iphoneos";
+                               SUPPORTS_IOSMAC = YES;
+                       };
+                       name = Release;
+               };
                1572C52A0CFB55B400E2776E /* Debug */ = {
                        isa = XCBuildConfiguration;
                        buildSettings = {
                                );
                                MODULEMAP_FILE = SystemConfiguration.fproj/Modules/SystemConfiguration.modulemap;
                                MODULEMAP_PRIVATE_FILE = SystemConfiguration.fproj/Modules/SystemConfiguration.private.modulemap;
-                               OTHER_CFLAGS = (
-                                       "$(inherited)",
-                                       "-DSC_LOG_OR_PRINT",
-                               );
                                OTHER_TAPI_FLAGS = "$(inherited) -DEXCLUDE_VPN_TUNNEL_PLUGIN_FUNCTIONS --extra-private-header=$(PROJECT_DIR)/SystemConfiguration.fproj/SystemConfigurationInternal.h --extra-private-header=$(PROJECT_DIR)/SystemConfiguration.fproj/SCDynamicStoreInternal.h -DNO_TAPI_WARNINGS";
                                PRODUCT_BUNDLE_IDENTIFIER = com.apple.SystemConfiguration;
                                PRODUCT_NAME = SystemConfiguration;
                                );
                                MODULEMAP_FILE = SystemConfiguration.fproj/Modules/SystemConfiguration.modulemap;
                                MODULEMAP_PRIVATE_FILE = SystemConfiguration.fproj/Modules/SystemConfiguration.private.modulemap;
-                               OTHER_CFLAGS = (
-                                       "$(inherited)",
-                                       "-DSC_LOG_OR_PRINT",
-                               );
                                OTHER_TAPI_FLAGS = "$(inherited) -DEXCLUDE_VPN_TUNNEL_PLUGIN_FUNCTIONS --extra-private-header=$(PROJECT_DIR)/SystemConfiguration.fproj/SystemConfigurationInternal.h --extra-private-header=$(PROJECT_DIR)/SystemConfiguration.fproj/SCDynamicStoreInternal.h -DNO_TAPI_WARNINGS";
                                PRODUCT_BUNDLE_IDENTIFIER = com.apple.SystemConfiguration;
                                PRODUCT_NAME = SystemConfiguration;
                                        "-Wl,-upward-lSystem",
                                );
                                "OTHER_LDFLAGS_asan[arch=i386]" = "";
-                               "OTHER_LDFLAGS_asan[sdk=iphoneos*]" = "$(inherited) -L/usr/local/lib/sanitizers -lclang_rt.asan_ios_dynamic";
-                               "OTHER_LDFLAGS_asan[sdk=iphonesimulator*]" = "$(inherited) -L/usr/local/lib/sanitizers -lclang_rt.asan_iossim_dynamic";
-                               "OTHER_LDFLAGS_asan[sdk=macosx*]" = "$(inherited) -L/usr/local/lib/sanitizers -lclang_rt.asan_osx_dynamic";
-                               "OTHER_LDFLAGS_asan[sdk=tvos*]" = "$(inherited) -L/usr/local/lib/sanitizers -lclang_rt.asan_tvos_dynamic";
-                               "OTHER_LDFLAGS_asan[sdk=tvossimulator*]" = "$(inherited) -L/usr/local/lib/sanitizers -lclang_rt.asan_tvosossim_dynamic";
-                               "OTHER_LDFLAGS_asan[sdk=watchos*]" = "$(inherited) -L/usr/local/lib/sanitizers -lclang_rt.asan_watchos_dynamic";
-                               "OTHER_LDFLAGS_asan[sdk=watchsimulator*]" = "$(inherited) -L/usr/local/lib/sanitizers -lclang_rt.asan_watchossim_dynamic";
+                               "OTHER_LDFLAGS_asan[sdk=bridgeos*]" = "$(inherited) -L/usr/appleinternal/lib/sanitizers -lclang_rt.asan_bridgeos_dynamic";
+                               "OTHER_LDFLAGS_asan[sdk=iphoneos*]" = "$(inherited) -L/usr/appleinternal/lib/sanitizers -lclang_rt.asan_ios_dynamic";
+                               "OTHER_LDFLAGS_asan[sdk=iphonesimulator*]" = "$(inherited) -L/usr/appleinternal/lib/sanitizers -lclang_rt.asan_iossim_dynamic";
+                               "OTHER_LDFLAGS_asan[sdk=macosx*]" = "$(inherited) -L/usr/appleinternal/lib/sanitizers -lclang_rt.asan_osx_dynamic";
+                               "OTHER_LDFLAGS_asan[sdk=tvos*]" = "$(inherited) -L/usr/appleinternal/lib/sanitizers -lclang_rt.asan_tvos_dynamic";
+                               "OTHER_LDFLAGS_asan[sdk=tvossimulator*]" = "$(inherited) -L/usr/appleinternal/lib/sanitizers -lclang_rt.asan_tvossim_dynamic";
+                               "OTHER_LDFLAGS_asan[sdk=watchos*]" = "$(inherited) -L/usr/appleinternal/lib/sanitizers -lclang_rt.asan_watchos_dynamic";
+                               "OTHER_LDFLAGS_asan[sdk=watchsimulator*]" = "$(inherited) -L/usr/appleinternal/lib/sanitizers -lclang_rt.asan_watchossim_dynamic";
                                "OTHER_LDFLAGS_tsan[arch=i386]" = "";
-                               "OTHER_LDFLAGS_tsan[sdk=iphoneos*]" = "$(inherited) -L/usr/local/lib/sanitizers -lclang_rt.tsan_ios_dynamic";
-                               "OTHER_LDFLAGS_tsan[sdk=iphonesimulator*]" = "$(inherited) -L/usr/local/lib/sanitizers -lclang_rt.tsan_iossim_dynamic";
-                               "OTHER_LDFLAGS_tsan[sdk=macosx*]" = "$(inherited) -L/usr/local/lib/sanitizers -lclang_rt.tsan_osx_dynamic";
-                               "OTHER_LDFLAGS_tsan[sdk=tvos*]" = "$(inherited) -L/usr/local/lib/sanitizers -lclang_rt.tsan_tvos_dynamic";
-                               "OTHER_LDFLAGS_tsan[sdk=tvossimulator*]" = "$(inherited) -L/usr/local/lib/sanitizers -lclang_rt.tsan_tvosossim_dynamic";
-                               "OTHER_LDFLAGS_tsan[sdk=watchos*]" = "$(inherited) -L/usr/local/lib/sanitizers -lclang_rt.tsan_watchos_dynamic";
-                               "OTHER_LDFLAGS_tsan[sdk=watchsimulator*]" = "$(inherited) -L/usr/local/lib/sanitizers -lclang_rt.tsan_watchossim_dynamic";
+                               "OTHER_LDFLAGS_tsan[sdk=bridgeos*]" = "$(inherited) -L/usr/appleinternal/lib/sanitizers -lclang_rt.tsan_bridgeos_dynamic";
+                               "OTHER_LDFLAGS_tsan[sdk=iphoneos*]" = "$(inherited) -L/usr/appleinternal/lib/sanitizers -lclang_rt.tsan_ios_dynamic";
+                               "OTHER_LDFLAGS_tsan[sdk=iphonesimulator*]" = "$(inherited) -L/usr/appleinternal/lib/sanitizers -lclang_rt.tsan_iossim_dynamic";
+                               "OTHER_LDFLAGS_tsan[sdk=macosx*]" = "$(inherited) -L/usr/appleinternal/lib/sanitizers -lclang_rt.tsan_osx_dynamic";
+                               "OTHER_LDFLAGS_tsan[sdk=tvos*]" = "$(inherited) -L/usr/appleinternal/lib/sanitizers -lclang_rt.tsan_tvos_dynamic";
+                               "OTHER_LDFLAGS_tsan[sdk=tvossimulator*]" = "$(inherited) -L/usr/appleinternal/lib/sanitizers -lclang_rt.tsan_tvossim_dynamic";
+                               "OTHER_LDFLAGS_tsan[sdk=watchos*]" = "$(inherited) -L/usr/appleinternal/lib/sanitizers -lclang_rt.tsan_watchos_dynamic";
+                               "OTHER_LDFLAGS_tsan[sdk=watchsimulator*]" = "$(inherited) -L/usr/appleinternal/lib/sanitizers -lclang_rt.tsan_watchossim_dynamic";
                                OTHER_TAPI_FLAGS = "$(inherited) -umbrella System --extra-private-header=$(PROJECT_DIR)/libSystemConfiguration/libSystemConfiguration_internal.h --extra-private-header=$(PROJECT_DIR)/nwi/network_information_internal.h --extra-private-header=$(PROJECT_DIR)/nwi/network_config_agent_info_priv.h";
                                PRODUCT_NAME = libsystem_configuration;
                                SDKROOT = iphoneos.internal;
                                        "-Wl,-upward-lSystem",
                                );
                                "OTHER_LDFLAGS_asan[arch=i386]" = "";
-                               "OTHER_LDFLAGS_asan[sdk=iphoneos*]" = "$(inherited) -L/usr/local/lib/sanitizers -lclang_rt.asan_ios_dynamic";
-                               "OTHER_LDFLAGS_asan[sdk=iphonesimulator*]" = "$(inherited) -L/usr/local/lib/sanitizers -lclang_rt.asan_iossim_dynamic";
-                               "OTHER_LDFLAGS_asan[sdk=macosx*]" = "$(inherited) -L/usr/local/lib/sanitizers -lclang_rt.asan_osx_dynamic";
-                               "OTHER_LDFLAGS_asan[sdk=tvos*]" = "$(inherited) -L/usr/local/lib/sanitizers -lclang_rt.asan_tvos_dynamic";
-                               "OTHER_LDFLAGS_asan[sdk=tvossimulator*]" = "$(inherited) -L/usr/local/lib/sanitizers -lclang_rt.asan_tvosossim_dynamic";
-                               "OTHER_LDFLAGS_asan[sdk=watchos*]" = "$(inherited) -L/usr/local/lib/sanitizers -lclang_rt.asan_watchos_dynamic";
-                               "OTHER_LDFLAGS_asan[sdk=watchsimulator*]" = "$(inherited) -L/usr/local/lib/sanitizers -lclang_rt.asan_watchossim_dynamic";
+                               "OTHER_LDFLAGS_asan[sdk=bridgeos*]" = "$(inherited) -L/usr/appleinternal/lib/sanitizers -lclang_rt.asan_bridgeos_dynamic";
+                               "OTHER_LDFLAGS_asan[sdk=iphoneos*]" = "$(inherited) -L/usr/appleinternal/lib/sanitizers -lclang_rt.asan_ios_dynamic";
+                               "OTHER_LDFLAGS_asan[sdk=iphonesimulator*]" = "$(inherited) -L/usr/appleinternal/lib/sanitizers -lclang_rt.asan_iossim_dynamic";
+                               "OTHER_LDFLAGS_asan[sdk=macosx*]" = "$(inherited) -L/usr/appleinternal/lib/sanitizers -lclang_rt.asan_osx_dynamic";
+                               "OTHER_LDFLAGS_asan[sdk=tvos*]" = "$(inherited) -L/usr/appleinternal/lib/sanitizers -lclang_rt.asan_tvos_dynamic";
+                               "OTHER_LDFLAGS_asan[sdk=tvossimulator*]" = "$(inherited) -L/usr/appleinternal/lib/sanitizers -lclang_rt.asan_tvossim_dynamic";
+                               "OTHER_LDFLAGS_asan[sdk=watchos*]" = "$(inherited) -L/usr/appleinternal/lib/sanitizers -lclang_rt.asan_watchos_dynamic";
+                               "OTHER_LDFLAGS_asan[sdk=watchsimulator*]" = "$(inherited) -L/usr/appleinternal/lib/sanitizers -lclang_rt.asan_watchossim_dynamic";
                                "OTHER_LDFLAGS_tsan[arch=i386]" = "";
-                               "OTHER_LDFLAGS_tsan[sdk=iphoneos*]" = "$(inherited) -L/usr/local/lib/sanitizers -lclang_rt.tsan_ios_dynamic";
-                               "OTHER_LDFLAGS_tsan[sdk=iphonesimulator*]" = "$(inherited) -L/usr/local/lib/sanitizers -lclang_rt.tsan_iossim_dynamic";
-                               "OTHER_LDFLAGS_tsan[sdk=macosx*]" = "$(inherited) -L/usr/local/lib/sanitizers -lclang_rt.tsan_osx_dynamic";
-                               "OTHER_LDFLAGS_tsan[sdk=tvos*]" = "$(inherited) -L/usr/local/lib/sanitizers -lclang_rt.tsan_tvos_dynamic";
-                               "OTHER_LDFLAGS_tsan[sdk=tvossimulator*]" = "$(inherited) -L/usr/local/lib/sanitizers -lclang_rt.tsan_tvosossim_dynamic";
-                               "OTHER_LDFLAGS_tsan[sdk=watchos*]" = "$(inherited) -L/usr/local/lib/sanitizers -lclang_rt.tsan_watchos_dynamic";
-                               "OTHER_LDFLAGS_tsan[sdk=watchsimulator*]" = "$(inherited) -L/usr/local/lib/sanitizers -lclang_rt.tsan_watchossim_dynamic";
+                               "OTHER_LDFLAGS_tsan[sdk=bridgeos*]" = "$(inherited) -L/usr/appleinternal/lib/sanitizers -lclang_rt.tsan_bridgeos_dynamic";
+                               "OTHER_LDFLAGS_tsan[sdk=iphoneos*]" = "$(inherited) -L/usr/appleinternal/lib/sanitizers -lclang_rt.tsan_ios_dynamic";
+                               "OTHER_LDFLAGS_tsan[sdk=iphonesimulator*]" = "$(inherited) -L/usr/appleinternal/lib/sanitizers -lclang_rt.tsan_iossim_dynamic";
+                               "OTHER_LDFLAGS_tsan[sdk=macosx*]" = "$(inherited) -L/usr/appleinternal/lib/sanitizers -lclang_rt.tsan_osx_dynamic";
+                               "OTHER_LDFLAGS_tsan[sdk=tvos*]" = "$(inherited) -L/usr/appleinternal/lib/sanitizers -lclang_rt.tsan_tvos_dynamic";
+                               "OTHER_LDFLAGS_tsan[sdk=tvossimulator*]" = "$(inherited) -L/usr/appleinternal/lib/sanitizers -lclang_rt.tsan_tvossim_dynamic";
+                               "OTHER_LDFLAGS_tsan[sdk=watchos*]" = "$(inherited) -L/usr/appleinternal/lib/sanitizers -lclang_rt.tsan_watchos_dynamic";
+                               "OTHER_LDFLAGS_tsan[sdk=watchsimulator*]" = "$(inherited) -L/usr/appleinternal/lib/sanitizers -lclang_rt.tsan_watchossim_dynamic";
                                OTHER_TAPI_FLAGS = "$(inherited) -umbrella System --extra-private-header=$(PROJECT_DIR)/libSystemConfiguration/libSystemConfiguration_internal.h --extra-private-header=$(PROJECT_DIR)/nwi/network_information_internal.h --extra-private-header=$(PROJECT_DIR)/nwi/network_config_agent_info_priv.h";
                                PRODUCT_NAME = libsystem_configuration;
                                SDKROOT = iphoneos.internal;
                        isa = XCBuildConfiguration;
                        buildSettings = {
                                CODE_SIGN_ENTITLEMENTS = "configd.tproj/entitlements-ios.plist";
-                               CODE_SIGN_IDENTITY = "-";
                                FRAMEWORK_SEARCH_PATHS = (
                                        "$(SYMROOT)",
                                        "$(SDKROOT)$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks",
                        isa = XCBuildConfiguration;
                        buildSettings = {
                                CODE_SIGN_ENTITLEMENTS = "configd.tproj/entitlements-ios.plist";
-                               CODE_SIGN_IDENTITY = "-";
                                FRAMEWORK_SEARCH_PATHS = (
                                        "$(SYMROOT)",
                                        "$(SDKROOT)$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks",
                                        "$(inherited)",
                                        "-idirafter",
                                        "$(SYSTEM_LIBRARY_DIR)/Frameworks/System.framework/PrivateHeaders",
-                                       "-DSC_LOG_OR_PRINT",
                                );
                                OTHER_TAPI_FLAGS = "$(inherited) -DEXCLUDE_VPN_TUNNEL_PLUGIN_FUNCTIONS --extra-private-header=$(PROJECT_DIR)/SystemConfiguration.fproj/SystemConfigurationInternal.h --extra-private-header=$(PROJECT_DIR)/SystemConfiguration.fproj/SCDynamicStoreInternal.h -DNO_TAPI_WARNINGS";
                                PRODUCT_BUNDLE_IDENTIFIER = com.apple.SystemConfiguration;
                                        "$(inherited)",
                                        "-idirafter",
                                        "$(SYSTEM_LIBRARY_DIR)/Frameworks/System.framework/PrivateHeaders",
-                                       "-DSC_LOG_OR_PRINT",
                                );
                                OTHER_TAPI_FLAGS = "$(inherited) -DEXCLUDE_VPN_TUNNEL_PLUGIN_FUNCTIONS --extra-private-header=$(PROJECT_DIR)/SystemConfiguration.fproj/SystemConfigurationInternal.h --extra-private-header=$(PROJECT_DIR)/SystemConfiguration.fproj/SCDynamicStoreInternal.h -DNO_TAPI_WARNINGS";
                                PRODUCT_BUNDLE_IDENTIFIER = com.apple.SystemConfiguration;
                        buildSettings = {
                                CLANG_ENABLE_OBJC_ARC = YES;
                                CODE_SIGN_ENTITLEMENTS = "sctest/sctest-entitlements.plist";
-                               CODE_SIGN_IDENTITY = "-";
                                FRAMEWORK_SEARCH_PATHS = "$(SDKROOT)$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks";
                                HEADER_SEARCH_PATHS = "$(SDKROOT)$(SYSTEM_LIBRARY_DIR)/Frameworks/System.framework/PrivateHeaders";
                                INSTALL_PATH = /usr/local/bin;
                        buildSettings = {
                                CLANG_ENABLE_OBJC_ARC = YES;
                                CODE_SIGN_ENTITLEMENTS = "sctest/sctest-entitlements.plist";
-                               CODE_SIGN_IDENTITY = "-";
                                FRAMEWORK_SEARCH_PATHS = "$(SDKROOT)$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks";
                                HEADER_SEARCH_PATHS = "$(SDKROOT)$(SYSTEM_LIBRARY_DIR)/Frameworks/System.framework/PrivateHeaders";
                                INSTALL_PATH = /usr/local/bin;
                        buildSettings = {
                                CLANG_ENABLE_OBJC_ARC = YES;
                                CODE_SIGN_ENTITLEMENTS = "sctest/sctest-entitlements.plist";
-                               CODE_SIGN_IDENTITY = "-";
                                FRAMEWORK_SEARCH_PATHS = "$(SDKROOT)$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks";
                                HEADER_SEARCH_PATHS = "$(SDKROOT)$(SYSTEM_LIBRARY_DIR)/Frameworks/System.framework/PrivateHeaders";
                                INSTALL_PATH = /usr/local/bin;
                        buildSettings = {
                                CLANG_ENABLE_OBJC_ARC = YES;
                                CODE_SIGN_ENTITLEMENTS = "sctest/sctest-entitlements.plist";
-                               CODE_SIGN_IDENTITY = "-";
                                FRAMEWORK_SEARCH_PATHS = "$(SDKROOT)$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks";
                                HEADER_SEARCH_PATHS = "$(SDKROOT)$(SYSTEM_LIBRARY_DIR)/Frameworks/System.framework/PrivateHeaders";
                                INSTALL_PATH = /usr/local/bin;
                                OTHER_CFLAGS = (
                                        "$(inherited)",
                                        "-Wnon-modular-include-in-module",
+                                       "-fmodules-cache-path=$(CLANG_MODULE_CACHE_PATH)",
                                );
                                PRODUCT_NAME = "$(TARGET_NAME)";
                        };
                                OTHER_CFLAGS = (
                                        "$(inherited)",
                                        "-Wnon-modular-include-in-module",
+                                       "-fmodules-cache-path=$(CLANG_MODULE_CACHE_PATH)",
                                );
                                PRODUCT_NAME = "$(TARGET_NAME)";
                        };
                        buildSettings = {
                                CLANG_ANALYZER_NONNULL = YES;
                                CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
-                               CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
-                               CLANG_CXX_LIBRARY = "libc++";
                                CLANG_ENABLE_MODULES = YES;
                                CLANG_ENABLE_OBJC_ARC = YES;
                                CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
                                CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
                                CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
                                CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
-                               CODE_SIGN_IDENTITY = "-";
                                CODE_SIGN_STYLE = Automatic;
                                DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
                                DWARF_DSYM_FILE_SHOULD_ACCOMPANY_PRODUCT = YES;
                                        "$(SDKROOT)$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks",
                                        "$(SDKROOT)$(APPLE_INTERNAL_LIBRARY_DIR)/Frameworks",
                                );
-                               GCC_C_LANGUAGE_STANDARD = gnu11;
                                GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
                                GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
                                INFOPLIST_FILE = EventFactory/Info.plist;
                                INSTALL_PATH = "$(APPLE_INTERNAL_LIBRARY_DIR)/Frameworks/EventFactory.framework/PlugIns";
                                LD_RUNPATH_SEARCH_PATHS = "@loader_path/../../../../../";
-                               MACOSX_DEPLOYMENT_TARGET = 10.14;
                                ONLY_ACTIVE_ARCH = YES;
                                PRODUCT_BUNDLE_IDENTIFIER = "com.apple.$(TARGET_NAME)";
                                PRODUCT_NAME = "$(TARGET_NAME)";
                        buildSettings = {
                                CLANG_ANALYZER_NONNULL = YES;
                                CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
-                               CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
-                               CLANG_CXX_LIBRARY = "libc++";
                                CLANG_ENABLE_MODULES = YES;
                                CLANG_ENABLE_OBJC_ARC = YES;
                                CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
                                CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
                                CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
                                CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
-                               CODE_SIGN_IDENTITY = "-";
                                CODE_SIGN_STYLE = Automatic;
                                COPY_PHASE_STRIP = NO;
                                DWARF_DSYM_FILE_SHOULD_ACCOMPANY_PRODUCT = "";
                                        "$(SDKROOT)$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks",
                                        "$(SDKROOT)$(APPLE_INTERNAL_LIBRARY_DIR)/Frameworks",
                                );
-                               GCC_C_LANGUAGE_STANDARD = gnu11;
                                GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
                                GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
                                INFOPLIST_FILE = EventFactory/Info.plist;
                                INSTALL_PATH = "$(APPLE_INTERNAL_LIBRARY_DIR)/Frameworks/EventFactory.framework/PlugIns";
                                LD_RUNPATH_SEARCH_PATHS = "@loader_path/../../../../../";
-                               MACOSX_DEPLOYMENT_TARGET = 10.14;
                                PRODUCT_BUNDLE_IDENTIFIER = "com.apple.$(TARGET_NAME)";
                                PRODUCT_NAME = "$(TARGET_NAME)";
                                SDKROOT = macosx.internal;
                        defaultConfigurationIsVisible = 0;
                        defaultConfigurationName = Release;
                };
+               15703B2D22320A940018D2EE /* Build configuration list for PBXNativeTarget "SCTest-ObjC-iOSMac" */ = {
+                       isa = XCConfigurationList;
+                       buildConfigurations = (
+                               15703B2E22320A940018D2EE /* Debug */,
+                               15703B2F22320A940018D2EE /* Release */,
+                       );
+                       defaultConfigurationIsVisible = 0;
+                       defaultConfigurationName = Release;
+               };
                1572C5290CFB55B400E2776E /* Build configuration list for PBXNativeTarget "SystemConfiguration.framework-Embedded" */ = {
                        isa = XCConfigurationList;
                        buildConfigurations = (
 
 /*
- * Copyright (c) 2004-2008, 2011-2017 Apple Inc. All rights reserved.
+ * Copyright (c) 2004-2008, 2011-2017, 2020 Apple Inc. All rights reserved.
  *
  * @APPLE_LICENSE_HEADER_START@
  *
 main(int argc, char **argv)
 {
        static Boolean verbose = (argc > 1) ? TRUE : FALSE;
-//     _sc_log     = FALSE;
+       _sc_log     = kSCLogDestinationFile;
        _sc_verbose = (argc > 1) ? TRUE : FALSE;
        _sc_debug   = TRUE;
 
        return 0;
 }
 
-#endif  /* MAIN */
+#endif /* MAIN */
 
 #!/bin/sh
 
 #
-#  Copyright © 2015-2019 Apple Inc.
+#  Copyright © 2015-2020 Apple Inc.
 #
 #  get-network-info
 #
        fi
        if [ -e /etc/resolver ]; then
                tar -c -H /etc/resolver                                 > etc-resolver.tar              2>/dev/null
+       elif [ -e /Library/Preferences/SystemConfiguration/resolver ]; then
+               tar -c -H /Library/Preferences/SystemConfiguration/resolver > LPS-resolver.tar          2>/dev/null
+       fi
+
+       MIGRATION_FILES=$(/bin/ls -1                                                            \
+               /Library/Preferences/SystemConfiguration/preferences-pre-*.plist                \
+               /Library/Preferences/SystemConfiguration/NetworkInterfaces-pre-*.plist          \
+               2>/dev/null)
+       if [ -n "${MIGRATION_FILES}" ]; then
+               MIGRATION_FILES+=" /Library/Preferences/SystemConfiguration/preferences.plist"
+               MIGRATION_FILES+=" /Library/Preferences/SystemConfiguration/NetworkInterfaces.plist"
+               tar -c -H ${MIGRATION_FILES}                            > migration.tar                 2>/dev/null
        fi
 }
 
        if [ ${PCAP_STARTED} -ne 0 ]; then
                trap '' SIGINT
                /usr/local/bin/netdiagnose stop sysdiagpcap                                     2>&1    1>/dev/null
-               echo "`date +"%Y-%m-%d %H:%M:%S"`: stop_pcap done"      >> get-network-info.txt
+               echo "`date +"%Y-%m-%d %H:%M:%S"`: stop_pcap"           >> get-network-info.txt
        fi
 }
 
 
 /*
- * Copyright (c) 2012-2018 Apple Inc. All rights reserved.
+ * Copyright (c) 2012-2018, 2020 Apple Inc. All rights reserved.
  *
  * @APPLE_LICENSE_HEADER_START@
  *
 main(int argc, char **argv)
 {
        static Boolean verbose = (argc > 1) ? TRUE : FALSE;
-//     _sc_log     = FALSE;
+       _sc_log     = kSCLogDestinationFile;
        _sc_verbose = (argc > 1) ? TRUE : FALSE;
        _sc_debug   = TRUE;
 
 
 /*
- * Copyright (c) 2000-2009, 2011, 2012, 2014, 2015, 2018 Apple Inc. All rights reserved.
+ * Copyright (c) 2000-2009, 2011, 2012, 2014, 2015, 2018, 2020 Apple Inc. All rights reserved.
  *
  * @APPLE_LICENSE_HEADER_START@
  *
                switch(opt) {
                        case 'd':
                                _sc_debug = TRUE;
-                               _sc_log   = FALSE;      /* enable framework logging */
+                               _sc_log   = kSCLogDestinationFile;      /* enable framework logging */
                                break;
                        case 'v':
                                _sc_verbose = TRUE;
 
                Class testClass;
                SCTest *testClassObject;
 
-               _sc_log = 0;    // print (stdout)
+               _sc_log = kSCLogDestinationFile;        // print (stdout)
 
                if (argc == 1) {
                        usage();
                        }
                }
 
-               _sc_log = 3;    // log AND print (stdout w/o timestamp)
+               _sc_log = kSCLogDestinationBoth_NoTime; // log AND print (stdout w/o timestamp)
 
                testClassObject = [(SCTest *)[testClass alloc] initWithOptions:options];
                if (testClassObject.options[kSCTestGlobalOptionCPU] != nil) {
 
                switch(opt) {
                case 'd':
                        _sc_debug = TRUE;
-                       _sc_log   = FALSE;      /* enable framework logging */
+                       _sc_log   = kSCLogDestinationFile;      /* enable framework logging */
                        break;
                case 'D':
                        doDispatch = TRUE;
                        break;
                case 'v':
                        _sc_verbose = TRUE;
-                       _sc_log     = FALSE;    /* enable framework logging */
+                       _sc_log     = kSCLogDestinationFile;    /* enable framework logging */
                        break;
                case 'p':
                        enablePrivateAPI = TRUE;
 
 #include <histedit.h>
 
 #define SC_LOG_HANDLE          _SC_LOG_DEFAULT
-#define USE_SC_LOG_OR_PRINT    1
 
 #include <SystemConfiguration/SystemConfiguration.h>
 #include <SystemConfiguration/SCPrivate.h>
 
 /*
- * Copyright (c) 2000, 2001, 2003-2018 Apple Inc. All rights reserved.
+ * Copyright (c) 2000, 2001, 2003-2018, 2020 Apple Inc. All rights reserved.
  *
  * @APPLE_LICENSE_HEADER_START@
  *
        }
 
        _sc_log_save = _sc_log;
-       _sc_log = FALSE;
+       _sc_log = kSCLogDestinationFile;
        _dns_configuration_log(dns_config, _sc_debug, NULL);
        _sc_log = _sc_log_save;