From 9de8ab86392ba34369adc6be0bfc21bad9b7caa2 Mon Sep 17 00:00:00 2001 From: Apple Date: Fri, 4 Sep 2015 17:25:53 +0000 Subject: [PATCH] configd-801.1.1.tar.gz --- IPMonitorControl/IPMonitorControl.c | 49 +- IPMonitorControl/IPMonitorControlServer.c | 79 +- .../IPMonitor/Info-EmbeddedSimulator.plist | 4 +- Plugins/IPMonitor/Info.plist | 2 +- Plugins/IPMonitor/Makefile | 87 +- .../Simulator/com.apple.networking.IPMonitor | 1 + Plugins/IPMonitor/dns-configuration.c | 373 +- Plugins/IPMonitor/dns-configuration.h | 2 +- Plugins/IPMonitor/ip_plugin.c | 853 ++- Plugins/IPMonitor/ip_plugin.h | 14 +- Plugins/IPMonitor/proxy-configuration.c | 17 +- Plugins/IPMonitor/routelist_output_filter.sh | 5 +- Plugins/IPMonitor/set-hostname.c | 271 +- Plugins/IPMonitor/smb-configuration.c | 119 +- .../test_ipv4_routelist_reference.txt | 1 - .../test_ipv6_routelist_reference.txt | 1 - Plugins/InterfaceNamer/Info.plist | 2 +- Plugins/InterfaceNamer/ifnamer.c | 667 +- Plugins/KernelEventMonitor/Info.plist | 2 +- Plugins/KernelEventMonitor/ev_dlil.c | 204 +- Plugins/KernelEventMonitor/ev_dlil.h | 11 +- Plugins/KernelEventMonitor/ev_extra.m | 11 +- Plugins/KernelEventMonitor/ev_ipv4.c | 21 +- Plugins/KernelEventMonitor/ev_ipv6.c | 56 +- Plugins/KernelEventMonitor/ev_ipv6.h | 7 +- Plugins/KernelEventMonitor/eventmon.c | 402 +- Plugins/KernelEventMonitor/eventmon.h | 5 +- Plugins/LinkConfiguration/Info.plist | 2 +- Plugins/LinkConfiguration/linkconfig.c | 97 +- Plugins/Logger/Info-Embedded.plist | 54 - Plugins/Logger/Info.plist | 66 - Plugins/Logger/Makefile | 6 - Plugins/Logger/logger.c | 2055 ----- Plugins/PreferencesMonitor/Info.plist | 2 +- Plugins/PreferencesMonitor/prefsmon.c | 234 +- .../Info-EmbeddedSimulator.plist | 31 - Plugins/SCNetworkReachability/Info.plist | 31 - Plugins/SimulatorSupport/Info.plist | 2 +- Plugins/SimulatorSupport/simulator_support.c | 19 +- Plugins/common/IPMonitorControlPrefs.c | 16 +- Plugins/common/cache.c | 14 +- SCMonitor/Info.plist | 2 +- SCMonitor/monitor.c | 20 +- SCTest-ObjC/test-objC.m | 118 + SCTest-Swift/main.swift | 126 + SystemConfiguration.fproj/BondConfiguration.c | 68 +- .../BridgeConfiguration.c | 39 +- SystemConfiguration.fproj/CaptiveNetwork.h | 67 +- SystemConfiguration.fproj/DHCP.c | 13 +- .../DHCPClientPreferences.h | 16 +- SystemConfiguration.fproj/DeviceOnHold.h | 2 +- SystemConfiguration.fproj/Info-Embedded.plist | 2 +- SystemConfiguration.fproj/Info.plist | 2 +- SystemConfiguration.fproj/LinkConfiguration.c | 42 +- .../Modules/sc_modules.modulemap | 22 + SystemConfiguration.fproj/SCD.c | 37 +- SystemConfiguration.fproj/SCDHostName.c | 26 +- SystemConfiguration.fproj/SCDNotifierCancel.c | 8 +- .../SCDNotifierInformViaCallback.c | 80 +- .../SCDNotifierInformViaFD.c | 20 +- .../SCDNotifierInformViaSignal.c | 10 +- SystemConfiguration.fproj/SCDNotifierWait.c | 22 +- SystemConfiguration.fproj/SCDOpen.c | 54 +- SystemConfiguration.fproj/SCDPrivate.c | 221 +- SystemConfiguration.fproj/SCDynamicStore.h | 113 +- .../SCDynamicStoreCopyDHCPInfo.h | 19 +- .../SCDynamicStoreCopySpecific.h | 33 +- SystemConfiguration.fproj/SCDynamicStoreKey.h | 47 +- SystemConfiguration.fproj/SCNetwork.h | 7 +- .../SCNetworkConfiguration.h | 120 +- .../SCNetworkConfigurationInternal.c | 52 +- .../SCNetworkConfigurationInternal.h | 8 +- .../SCNetworkConfigurationPrivate.h | 25 +- .../SCNetworkConnection.c | 407 +- .../SCNetworkConnection.h | 64 +- .../SCNetworkConnectionPrivate.c | 22 +- .../SCNetworkConnectionPrivate.h | 5 +- .../SCNetworkInterface.c | 607 +- .../SCNetworkMigration.c | 1247 +-- .../SCNetworkReachability.c | 6806 +++-------------- .../SCNetworkReachability.h | 57 +- .../SCNetworkReachabilityInternal.h | 360 +- SystemConfiguration.fproj/SCNetworkService.c | 76 +- SystemConfiguration.fproj/SCNetworkSet.c | 57 +- .../SCNetworkSignature.c | 4 +- SystemConfiguration.fproj/SCP.c | 24 +- SystemConfiguration.fproj/SCPApply.c | 22 +- SystemConfiguration.fproj/SCPCommit.c | 55 +- SystemConfiguration.fproj/SCPLock.c | 97 +- SystemConfiguration.fproj/SCPOpen.c | 126 +- SystemConfiguration.fproj/SCPUnlock.c | 15 +- SystemConfiguration.fproj/SCPreferences.h | 61 +- .../SCPreferencesInternal.h | 17 +- SystemConfiguration.fproj/SCPreferencesPath.h | 13 +- .../SCPreferencesPathKey.c | 12 +- .../SCPreferencesSetSpecific.h | 7 +- SystemConfiguration.fproj/SCPrivate.h | 90 +- .../SCSchemaDefinitions.c | 5 +- .../SCSchemaDefinitions.h | 3225 ++------ .../SCSchemaDefinitionsPrivate.h | 1831 ++--- SystemConfiguration.fproj/SNHelper.c | 6 +- .../SystemConfiguration.h | 8 +- SystemConfiguration.fproj/VLANConfiguration.c | 26 +- SystemConfiguration.fproj/VPNAppLayer.c | 2 +- .../VPNAppLayerPrivate.h | 2 +- SystemConfiguration.fproj/VPNConfiguration.c | 2 +- SystemConfiguration.fproj/VPNFlow.c | 2 +- SystemConfiguration.fproj/VPNFlow.h | 2 +- SystemConfiguration.fproj/VPNFlowPrivate.h | 4 - SystemConfiguration.fproj/VPNTunnelPrivate.h | 2 +- SystemConfiguration.fproj/dy_framework.c | 4 +- SystemConfiguration.fproj/dy_framework.h | 3 +- SystemConfiguration.fproj/genSCPreferences.c | 369 +- .../helper/SCHelper_client.c | 26 +- .../helper/SCHelper_server.c | 223 +- SystemConfiguration.fproj/moh.c | 24 +- .../SCNetworkReachabilityServer_client.c | 1218 --- .../SCNetworkReachabilityServer_server.c | 2125 ----- .../reachability/client.c | 100 - .../reachability/server.c | 23 - SystemConfiguration.fproj/scprefs_observer.c | 37 +- SystemConfiguration.fproj/update-headers | 42 +- common/reference_output.sh | 87 + configd.tproj/_SCD.c | 79 +- configd.tproj/_configadd.c | 23 +- configd.tproj/_configclose.c | 15 +- configd.tproj/_configget.c | 30 +- configd.tproj/_configlist.c | 15 +- configd.tproj/_confignotify.c | 19 +- configd.tproj/_configopen.c | 25 +- configd.tproj/_configremove.c | 19 +- configd.tproj/_configset.c | 34 +- configd.tproj/_notifyadd.c | 32 +- configd.tproj/_notifyremove.c | 21 +- configd.tproj/_notifyviafd.c | 24 +- configd.tproj/_snapshot.c | 14 +- configd.tproj/com.apple.configd.plist | 2 + configd.tproj/configd.m | 32 +- configd.tproj/configd_server.c | 40 +- configd.tproj/entitlements-ios.plist | 11 +- configd.tproj/notify_server.c | 10 +- configd.tproj/pattern.c | 24 +- configd.tproj/plugin_support.c | 120 +- configd.tproj/session.c | 56 +- configd.tproj/update-mach-services | 47 +- configd.xcodeproj/project.pbxproj | 1575 ++-- dnsinfo/dnsinfo.h | 7 +- dnsinfo/dnsinfo_copy.c | 280 +- dnsinfo/dnsinfo_create.c | 11 +- dnsinfo/dnsinfo_create.h | 12 +- dnsinfo/dnsinfo_flatfile.c | 4 +- dnsinfo/dnsinfo_internal.h | 442 +- dnsinfo/dnsinfo_private.h | 3 +- dnsinfo/dnsinfo_server.c | 106 +- dnsinfo/dnsinfo_server.h | 3 +- get-mobility-info | 338 +- get-network-info | 557 ++ .../libSystemConfiguration_client.c | 9 +- .../libSystemConfiguration_server.c | 21 +- nwi/Makefile | 40 + nwi/network_information.c | 434 +- nwi/network_information.h | 34 +- nwi/network_information_priv.c | 687 +- nwi/network_information_priv.h | 188 +- nwi/network_information_server.c | 140 +- nwi/network_information_server.h | 3 +- nwi/test_nwi_reference.txt | 215 + scselect.tproj/scselect.c | 19 +- scutil.tproj/nc.c | 27 +- scutil.tproj/prefs.c | 155 +- scutil.tproj/prefs.h | 3 +- scutil.tproj/scutil.c | 10 + scutil.tproj/tests.c | 137 +- 173 files changed, 11271 insertions(+), 21866 deletions(-) create mode 100644 Plugins/IPMonitor/Simulator/com.apple.networking.IPMonitor delete mode 100644 Plugins/Logger/Info-Embedded.plist delete mode 100644 Plugins/Logger/Info.plist delete mode 100644 Plugins/Logger/Makefile delete mode 100644 Plugins/Logger/logger.c delete mode 100644 Plugins/SCNetworkReachability/Info-EmbeddedSimulator.plist delete mode 100644 Plugins/SCNetworkReachability/Info.plist create mode 100644 SCTest-ObjC/test-objC.m create mode 100644 SCTest-Swift/main.swift create mode 100644 SystemConfiguration.fproj/Modules/sc_modules.modulemap delete mode 100644 SystemConfiguration.fproj/VPNFlowPrivate.h delete mode 100644 SystemConfiguration.fproj/reachability/SCNetworkReachabilityServer_client.c delete mode 100644 SystemConfiguration.fproj/reachability/SCNetworkReachabilityServer_server.c delete mode 100644 SystemConfiguration.fproj/reachability/client.c delete mode 100644 SystemConfiguration.fproj/reachability/server.c create mode 100644 common/reference_output.sh create mode 100755 get-network-info create mode 100644 nwi/Makefile create mode 100644 nwi/test_nwi_reference.txt diff --git a/IPMonitorControl/IPMonitorControl.c b/IPMonitorControl/IPMonitorControl.c index 83c6f10..a85ebc2 100644 --- a/IPMonitorControl/IPMonitorControl.c +++ b/IPMonitorControl/IPMonitorControl.c @@ -1,15 +1,15 @@ /* - * Copyright (c) 2013-2014 Apple Inc. All rights reserved. + * Copyright (c) 2013-2015 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ - * + * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. - * + * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, @@ -17,7 +17,7 @@ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. - * + * * @APPLE_LICENSE_HEADER_END@ */ @@ -85,7 +85,7 @@ __IPMonitorControlCopyDebugDesc(CFTypeRef cf) { CFAllocatorRef allocator = CFGetAllocator(cf); IPMonitorControlRef control = (IPMonitorControlRef)cf; - + return (CFStringCreateWithFormat(allocator, NULL, CFSTR(""), control)); @@ -95,7 +95,7 @@ STATIC void __IPMonitorControlDeallocate(CFTypeRef cf) { IPMonitorControlRef control = (IPMonitorControlRef)cf; - + if (control->connection != NULL) { xpc_release(control->connection); } @@ -104,7 +104,7 @@ __IPMonitorControlDeallocate(CFTypeRef cf) } return; } - + /** ** IPMonitorControl support functions **/ @@ -147,18 +147,17 @@ IPMonitorControlHandleResponse(xpc_object_t event, Boolean async, if (type == XPC_TYPE_DICTIONARY) { if (async) { /* we don't expect async responses messages */ - my_log(LOG_NOTICE, "IPMonitorControl: unexpected message"); + my_log(LOG_NOTICE, "unexpected message"); } else { int64_t error; - + error = xpc_dictionary_get_int64(event, kIPMonitorControlResponseKeyError); if (error != 0) { success = FALSE; #ifdef TEST_IPMONITOR_CONTROL - my_log(LOG_NOTICE, - "IPMonitorControl: failure code %lld", error); + my_log(LOG_NOTICE, "failure code %lld", error); #endif /* TEST_IPMONITOR_CONTROL */ } else { @@ -169,7 +168,7 @@ IPMonitorControlHandleResponse(xpc_object_t event, Boolean async, else if (type == XPC_TYPE_ERROR) { if (event == XPC_ERROR_CONNECTION_INTERRUPTED) { #ifdef TEST_IPMONITOR_CONTROL - my_log(LOG_NOTICE, "IPMonitorControl: can retry"); + my_log(LOG_NOTICE, "can retry"); #endif /* TEST_IPMONITOR_CONTROL */ retry = TRUE; } @@ -177,11 +176,11 @@ IPMonitorControlHandleResponse(xpc_object_t event, Boolean async, const char * desc; desc = xpc_dictionary_get_string(event, XPC_ERROR_KEY_DESCRIPTION); - my_log(LOG_NOTICE, "IPMonitorControl: %s", desc); + my_log(LOG_NOTICE, "%s", desc); } } else { - my_log(LOG_NOTICE, "IPMonitorControl: unknown event type : %p", type); + my_log(LOG_NOTICE, "unknown event type : %p", type); } if (retry_p != NULL) { *retry_p = retry; @@ -230,7 +229,7 @@ ApplyInterfaceRank(const void * key, const void * value, void * context) SCNetworkServicePrimaryRank rank; xpc_object_t request; - if (CFStringGetCString(key, ifname, sizeof(ifname), + if (CFStringGetCString(key, ifname, sizeof(ifname), kCFStringEncodingUTF8) == FALSE) { return; } @@ -268,10 +267,14 @@ IPMonitorControlCreate(void) control = __IPMonitorControlAllocate(NULL); queue = dispatch_queue_create("IPMonitorControl", NULL); connection - = xpc_connection_create_mach_service(kIPMonitorControlServerName, + = xpc_connection_create_mach_service(kIPMonitorControlServerName, queue, flags); handler = ^(xpc_object_t event) { - Boolean retry; + os_activity_t activity_id; + Boolean retry; + + activity_id = os_activity_start("processing IPMonitor [rank] reply", + OS_ACTIVITY_FLAG_DEFAULT); (void)IPMonitorControlHandleResponse(event, TRUE, &retry); if (retry && control->assertions != NULL) { @@ -279,6 +282,8 @@ IPMonitorControlCreate(void) ApplyInterfaceRank, control->connection); } + + os_activity_end(activity_id); }; xpc_connection_set_event_handler(connection, handler); control->connection = connection; @@ -296,7 +301,7 @@ IPMonitorControlSetInterfacePrimaryRank(IPMonitorControlRef control, xpc_object_t request; Boolean success = FALSE; - if (CFStringGetCString(ifname_cf, ifname, sizeof(ifname), + if (CFStringGetCString(ifname_cf, ifname, sizeof(ifname), kCFStringEncodingUTF8) == FALSE) { return (FALSE); } @@ -317,7 +322,7 @@ IPMonitorControlSetInterfacePrimaryRank(IPMonitorControlRef control, reply = xpc_connection_send_message_with_reply_sync(control->connection, request); if (reply == NULL) { - my_log(LOG_NOTICE, "IPMonitorControl: failed to send message"); + my_log(LOG_NOTICE, "failed to send message"); break; } success = IPMonitorControlHandleResponse(reply, FALSE, @@ -329,7 +334,7 @@ IPMonitorControlSetInterfacePrimaryRank(IPMonitorControlRef control, if (retry_on_error) { continue; } - my_log(LOG_NOTICE, "IPMonitorControl: fatal error"); + my_log(LOG_NOTICE, "fatal error"); break; } xpc_release(request); @@ -358,7 +363,7 @@ IPMonitorControlGetInterfacePrimaryRank(IPMonitorControlRef control, xpc_object_t request; rank = kSCNetworkServicePrimaryRankDefault; - if (CFStringGetCString(ifname_cf, ifname, sizeof(ifname), + if (CFStringGetCString(ifname_cf, ifname, sizeof(ifname), kCFStringEncodingUTF8) == FALSE) { goto done; } @@ -377,7 +382,7 @@ IPMonitorControlGetInterfacePrimaryRank(IPMonitorControlRef control, reply = xpc_connection_send_message_with_reply_sync(control->connection, request); if (reply == NULL) { - my_log(LOG_NOTICE, "IPMonitorControl: failed to send message"); + my_log(LOG_NOTICE, "failed to send message"); break; } success = IPMonitorControlHandleResponse(reply, FALSE, &retry_on_error); diff --git a/IPMonitorControl/IPMonitorControlServer.c b/IPMonitorControl/IPMonitorControlServer.c index e19ccbb..53ad39d 100644 --- a/IPMonitorControl/IPMonitorControlServer.c +++ b/IPMonitorControl/IPMonitorControlServer.c @@ -1,15 +1,15 @@ /* - * Copyright (c) 2013-2014 Apple Inc. All rights reserved. + * Copyright (c) 2013-2015 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ - * + * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. - * + * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, @@ -17,7 +17,7 @@ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. - * + * * @APPLE_LICENSE_HEADER_END@ */ @@ -45,8 +45,6 @@ #include "IPMonitorControlPrivate.h" #include -STATIC Boolean * S_verbose; - #ifdef TEST_IPMONITOR_CONTROL #define my_log(__level, fmt, ...) SCPrint(TRUE, stdout, CFSTR(fmt "\n"), ## __VA_ARGS__) @@ -178,14 +176,12 @@ AddChangedInterface(const void * key, const void * value, void * context) STATIC void ControlSessionInvalidate(ControlSessionRef session) { - if (*S_verbose) { - my_log(LOG_NOTICE, "Invalidating %p", session); - } + my_log(LOG_DEBUG, "Invalidating %p", session); LIST_REMOVE(session, link); if (session->assertions != NULL) { my_log(LOG_DEBUG, "IPMonitorControlServer: %p pid %d removing assertions %@", - session->connection, + session->connection, xpc_connection_get_pid(session->connection), session->assertions); CFDictionaryApplyFunction(session->assertions, AddChangedInterface, @@ -200,9 +196,7 @@ ControlSessionInvalidate(ControlSessionRef session) STATIC void ControlSessionRelease(void * p) { - if (*S_verbose) { - my_log(LOG_NOTICE, "Releasing %p", p); - } + my_log(LOG_DEBUG, "Releasing %p", p); free(p); return; } @@ -224,9 +218,7 @@ ControlSessionCreate(xpc_connection_t connection) xpc_connection_set_finalizer_f(connection, ControlSessionRelease); xpc_connection_set_context(connection, session); LIST_INSERT_HEAD(&S_ControlSessions, session, link); - if (*S_verbose) { - my_log(LOG_NOTICE, "Created %p (connection %p)", session, connection); - } + my_log(LOG_DEBUG, "Created %p (connection %p)", session, connection); return (session); } @@ -261,7 +253,7 @@ ControlSessionSetInterfaceRank(ControlSessionRef session, } ifname_cf = CFStringCreateWithCString(NULL, ifname, kCFStringEncodingUTF8); - + if (rank == kSCNetworkServicePrimaryRankDefault) { CFDictionaryRemoveValue(session->assertions, ifname_cf); if (CFDictionaryGetCount(session->assertions) == 0) { @@ -325,12 +317,11 @@ IPMonitorControlServerHandleSetInterfaceRank(xpc_connection_t connection, ControlSessionRef session; if (IPMonitorControlServerValidateConnection(connection) == FALSE) { - my_log(LOG_DEBUG, - "IPMonitorControlServer: %p pid %d permission denied", + my_log(LOG_INFO, "connection %p pid %d permission denied", connection, xpc_connection_get_pid(connection)); return (EPERM); } - ifname + ifname = xpc_dictionary_get_string(request, kIPMonitorControlRequestKeyInterfaceName); if (ifname == NULL) { @@ -351,8 +342,7 @@ IPMonitorControlServerHandleSetInterfaceRank(xpc_connection_t connection, } session = ControlSessionGet(connection); ControlSessionSetInterfaceRank(session, ifname, rank); - my_log(LOG_DEBUG, - "IPMonitorControlServer: %p pid %d set %s %u", + my_log(LOG_INFO, "connection %p pid %d set %s %u", connection, xpc_connection_get_pid(connection), ifname, rank); return (0); } @@ -375,7 +365,7 @@ IPMonitorControlServerHandleGetInterfaceRank(xpc_connection_t connection, /* no session, no rank assertion */ return (ENOENT); } - ifname + ifname = xpc_dictionary_get_string(request, kIPMonitorControlRequestKeyInterfaceName); if (ifname == NULL) { @@ -392,10 +382,7 @@ IPMonitorControlServerHandleDisconnect(xpc_connection_t connection) { ControlSessionRef session; - if (*S_verbose) { - my_log(LOG_NOTICE, "IPMonitorControlServer: client %p went away", - connection); - } + my_log(LOG_DEBUG, "IPMonitorControlServer: client %p went away", connection); session = ControlSessionLookup(connection); if (session == NULL) { /* never asserted anything */ @@ -410,15 +397,15 @@ IPMonitorControlServerHandleRequest(xpc_connection_t connection, xpc_object_t request) { xpc_type_t type; - + type = xpc_get_type(request); if (type == XPC_TYPE_DICTIONARY) { int error = 0; uint64_t request_type; xpc_connection_t remote; xpc_object_t reply; - - request_type + + request_type = xpc_dictionary_get_uint64(request, kIPMonitorControlRequestKeyType); reply = xpc_dictionary_create_reply(request); @@ -452,12 +439,11 @@ IPMonitorControlServerHandleRequest(xpc_connection_t connection, IPMonitorControlServerHandleDisconnect(connection); } else if (request == XPC_ERROR_CONNECTION_INTERRUPTED) { - my_log(LOG_NOTICE, - "IPMonitorControlServer: connection interrupted"); + my_log(LOG_INFO, "connection interrupted"); } } else { - my_log(LOG_NOTICE, "IPMonitorControlServer: unexpected event"); + my_log(LOG_NOTICE, "unexpected event"); } return; } @@ -468,7 +454,14 @@ IPMonitorControlServerHandleNewConnection(xpc_connection_t connection) xpc_handler_t handler; handler = ^(xpc_object_t event) { + os_activity_t activity_id; + + activity_id = os_activity_start("processing IPMonitor [rank] request", + OS_ACTIVITY_FLAG_DEFAULT); + IPMonitorControlServerHandleRequest(connection, event); + + os_activity_end(activity_id); }; xpc_connection_set_event_handler(connection, handler); xpc_connection_resume(connection); @@ -487,28 +480,33 @@ IPMonitorControlServerCreate(dispatch_queue_t queue, const char * name) return (NULL); } handler = ^(xpc_object_t event) { + os_activity_t activity_id; xpc_type_t type; - + + activity_id = os_activity_start("processing IPMonitor [rank] connection request", + OS_ACTIVITY_FLAG_DEFAULT); + type = xpc_get_type(event); if (type == XPC_TYPE_CONNECTION) { IPMonitorControlServerHandleNewConnection(event); } else if (type == XPC_TYPE_ERROR) { const char * desc; - + desc = xpc_dictionary_get_string(event, XPC_ERROR_KEY_DESCRIPTION); if (event == XPC_ERROR_CONNECTION_INVALID) { - my_log(LOG_NOTICE, "IPMonitorControlServer: %s", desc); + my_log(LOG_NOTICE, "%s", desc); xpc_release(connection); } else { - my_log(LOG_NOTICE, "IPMonitorControlServer: %s", desc); - } + my_log(LOG_NOTICE, "%s", desc); + } } else { - my_log(LOG_NOTICE, "IPMonitorControlServer: unknown event %p", - type); + my_log(LOG_NOTICE, "unknown event %p", type); } + + os_activity_end(activity_id); }; S_IPMonitorControlServerQueue = queue; xpc_connection_set_event_handler(connection, handler); @@ -523,7 +521,6 @@ IPMonitorControlServerStart(CFRunLoopRef runloop, CFRunLoopSourceRef rls, dispatch_queue_t q; xpc_connection_t connection; - S_verbose = verbose; SetNotificationInfo(runloop, rls); q = dispatch_queue_create("IPMonitorControlServer", NULL); connection = IPMonitorControlServerCreate(q, kIPMonitorControlServerName); diff --git a/Plugins/IPMonitor/Info-EmbeddedSimulator.plist b/Plugins/IPMonitor/Info-EmbeddedSimulator.plist index 9cf9740..31b373f 100644 --- a/Plugins/IPMonitor/Info-EmbeddedSimulator.plist +++ b/Plugins/IPMonitor/Info-EmbeddedSimulator.plist @@ -15,11 +15,11 @@ CFBundlePackageType BNDL CFBundleShortVersionString - 1.14.4 + 1.14 CFBundleSignature ???? CFBundleVersion - 1.13 + 1.14 Requires com.apple.SystemConfiguration.IPConfiguration diff --git a/Plugins/IPMonitor/Info.plist b/Plugins/IPMonitor/Info.plist index 12cdb63..adb5cbd 100644 --- a/Plugins/IPMonitor/Info.plist +++ b/Plugins/IPMonitor/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType BNDL CFBundleShortVersionString - 1.14.4 + 1.14 CFBundleSignature ???? CFBundleVersion diff --git a/Plugins/IPMonitor/Makefile b/Plugins/IPMonitor/Makefile index 044b35a..bf6f4f5 100644 --- a/Plugins/IPMonitor/Makefile +++ b/Plugins/IPMonitor/Makefile @@ -1,95 +1,118 @@ +ifeq ($(PLATFORM),iphoneos) +# iOS internal SDK +ARCHS=armv7 +endif + +ifeq ($(PLATFORM),) +PLATFORM=macosx +endif + +ifeq ($(PLATFORM),macosx) +# Mac OS X internal SDK +ARCHS=x86_64 +endif + +# Mac OS X or iOS internal SDK +SDK=$(PLATFORM).internal +SYSROOT=$(shell xcodebuild -version -sdk $(SDK) Path) +CC = xcrun -sdk $(SDK) cc +PF_INC = -F$(SYSROOT)/System/Library/PrivateFrameworks + +ARCH_FLAGS=$(foreach a,$(ARCHS),-arch $(a)) + EXTRA_CFLAGS= +TEST_INCLUDE=-I. -I../common -I../../dnsinfo -I../../nwi -I../../libSystemConfiguration -I../../SystemConfiguration.fproj -I../../IPMonitorControl -I$(SYSROOT)/System/Library/Frameworks/System.framework/PrivateHeaders -TEST_INCLUDE=-I. -I../common -I../../dnsinfo -I../../nwi -I../../libSystemConfiguration -I../../SystemConfiguration.fproj -I../../IPMonitorControl -I/System/Library/Frameworks/System.framework/PrivateHeaders +REFERENCE_OUTPUT=../../common/reference_output.sh all: test_ipv4_routelist test_ipv6_routelist # ---------- dnsinfo_create.o: ../../dnsinfo/dnsinfo_create.h ../../dnsinfo/dnsinfo_create.c - cc ${TEST_INCLUDE} -Wall -O0 -g -c ../../dnsinfo/dnsinfo_create.c + $(CC) $(PF_INC) $(ARCH_FLAGS) -isysroot $(SYSROOT) ${TEST_INCLUDE} -Wall -O0 -g -c ../../dnsinfo/dnsinfo_create.c dnsinfo_flatfile.o: ../../dnsinfo/dnsinfo_copy.c ../../dnsinfo/dnsinfo_flatfile.c - cc ${TEST_INCLUDE} -D_PATH_RESOLVER_DIR='"/var/tmp/resolver"' -Wall -O0 -g -c ../../dnsinfo/dnsinfo_flatfile.c + $(CC) $(PF_INC) $(ARCH_FLAGS) -isysroot $(SYSROOT) ${TEST_INCLUDE} -D_PATH_RESOLVER_DIR='"/var/tmp/resolver"' -Wall -O0 -g -c ../../dnsinfo/dnsinfo_flatfile.c dnsinfo_server.o: ../../dnsinfo/dnsinfo_copy.c ../../dnsinfo/dnsinfo_server.c - cc ${TEST_INCLUDE} -Wall -O0 -g -c ../../dnsinfo/dnsinfo_server.c + $(CC) $(PF_INC) $(ARCH_FLAGS) -isysroot $(SYSROOT) ${TEST_INCLUDE} -Wall -O0 -g -c ../../dnsinfo/dnsinfo_server.c dns-configuration.o: dns-configuration.h dns-configuration.c dnsinfo_create.o - cc ${TEST_INCLUDE} ${EXTRA_CFLAGS} -Wall -O0 -g -c dns-configuration.c + $(CC) $(PF_INC) $(ARCH_FLAGS) -isysroot $(SYSROOT) ${TEST_INCLUDE} ${EXTRA_CFLAGS} -Wall -O0 -g -c dns-configuration.c network_information_priv.o: ../../nwi/network_information_priv.h ../../nwi/network_information_priv.c - cc ${TEST_INCLUDE} -Wall -O0 -g -c ../../nwi/network_information_priv.c + $(CC) $(PF_INC) $(ARCH_FLAGS) -isysroot $(SYSROOT) ${TEST_INCLUDE} -Wall -O0 -g -c ../../nwi/network_information_priv.c network_information_server.o: ../../nwi/network_information_server.h ../../nwi/network_information_server.c - cc ${TEST_INCLUDE} -Wall -O0 -g -c ../../nwi/network_information_server.c + $(CC) $(PF_INC) $(ARCH_FLAGS) -isysroot $(SYSROOT) ${TEST_INCLUDE} -Wall -O0 -g -c ../../nwi/network_information_server.c proxy-configuration.o: proxy-configuration.h proxy-configuration.c - cc ${TEST_INCLUDE} -Wall -O0 -g -c proxy-configuration.c + $(CC) $(PF_INC) $(ARCH_FLAGS) -isysroot $(SYSROOT) ${TEST_INCLUDE} -Wall -O0 -g -c proxy-configuration.c set-hostname.o: set-hostname.c - cc ${TEST_INCLUDE} ${EXTRA_CFLAGS} -Wall -O0 -g -c set-hostname.c + $(CC) $(PF_INC) $(ARCH_FLAGS) -isysroot $(SYSROOT) ${TEST_INCLUDE} ${EXTRA_CFLAGS} -Wall -O0 -g -c set-hostname.c smb-configuration.o: smb-configuration.c - cc ${TEST_INCLUDE} ${EXTRA_CFLAGS} -Wall -O0 -g -c smb-configuration.c + $(CC) $(PF_INC) $(ARCH_FLAGS) -isysroot $(SYSROOT) ${TEST_INCLUDE} ${EXTRA_CFLAGS} -Wall -O0 -g -c smb-configuration.c libSystemConfiguration_client.o: ../../libSystemConfiguration/libSystemConfiguration_client.h ../../libSystemConfiguration/libSystemConfiguration_client.c - cc ${TEST_INCLUDE} -Wall -O0 -g -c ../../libSystemConfiguration/libSystemConfiguration_client.c + $(CC) $(PF_INC) $(ARCH_FLAGS) -isysroot $(SYSROOT) ${TEST_INCLUDE} -Wall -O0 -g -c ../../libSystemConfiguration/libSystemConfiguration_client.c libSystemConfiguration_server.o: ../../libSystemConfiguration/libSystemConfiguration_server.h ../../libSystemConfiguration/libSystemConfiguration_server.c - cc ${TEST_INCLUDE} -Wall -O0 -g -c ../../libSystemConfiguration/libSystemConfiguration_server.c + $(CC) $(PF_INC) $(ARCH_FLAGS) -isysroot $(SYSROOT) ${TEST_INCLUDE} -Wall -O0 -g -c ../../libSystemConfiguration/libSystemConfiguration_server.c IPMonitorControlPrefs.o: ../common/IPMonitorControlPrefs.h ../common/IPMonitorControlPrefs.c - cc ${TEST_INCLUDE} -Wall -O0 -g -c ../common/IPMonitorControlPrefs.c + $(CC) $(PF_INC) $(ARCH_FLAGS) -isysroot $(SYSROOT) ${TEST_INCLUDE} -Wall -O0 -g -c ../common/IPMonitorControlPrefs.c IPMonitorControlServer.o: ../../IPMonitorControl/IPMonitorControlServer.c - cc ${TEST_INCLUDE} -Wall -O0 -g -c $^ + $(CC) $(PF_INC) $(ARCH_FLAGS) -isysroot $(SYSROOT) ${TEST_INCLUDE} -Wall -O0 -g -c $^ # ---------- dns-configurationX.o: Makefile dns-configuration.h dns-configuration.c dnsinfo_create.o - cc -DMAIN ${TEST_INCLUDE} ${EXTRA_CFLAGS} -Wall -O0 -g -c -o dns-configurationX.o dns-configuration.c + $(CC) $(PF_INC) $(ARCH_FLAGS) -isysroot $(SYSROOT) -DMAIN ${TEST_INCLUDE} ${EXTRA_CFLAGS} -Wall -O0 -g -c -o dns-configurationX.o dns-configuration.c ip_pluginX.o: Makefile ip_plugin.c - cc -DTEST_DNS ${TEST_INCLUDE} ${EXTRA_CFLAGS} -Wall -O0 -g -c -o ip_pluginX.o ip_plugin.c + $(CC) $(PF_INC) $(ARCH_FLAGS) -isysroot $(SYSROOT) -DTEST_DNS ${TEST_INCLUDE} ${EXTRA_CFLAGS} -Wall -O0 -g -c -o ip_pluginX.o ip_plugin.c test_dns: Makefile dnsinfo_create.o dnsinfo_flatfile.o dnsinfo_server.o ip_pluginX.o IPMonitorControlPrefs.o network_information_priv.o network_information_server.o dns-configurationX.o proxy-configuration.o set-hostname.o smb-configuration.o libSystemConfiguration_client.o libSystemConfiguration_server.o IPMonitorControlServer.o - cc -Wall -O0 -g -o test_dns dnsinfo_create.o dnsinfo_flatfile.o dnsinfo_server.o ip_pluginX.o IPMonitorControlPrefs.o network_information_priv.o network_information_server.o dns-configurationX.o proxy-configuration.o set-hostname.o smb-configuration.o libSystemConfiguration_client.o libSystemConfiguration_server.o IPMonitorControlServer.o -framework SystemConfiguration -framework CoreFoundation + $(CC) $(PF_INC) $(ARCH_FLAGS) -isysroot $(SYSROOT) -Wall -O0 -g -o test_dns dnsinfo_create.o dnsinfo_flatfile.o dnsinfo_server.o ip_pluginX.o IPMonitorControlPrefs.o network_information_priv.o network_information_server.o dns-configurationX.o proxy-configuration.o set-hostname.o smb-configuration.o libSystemConfiguration_client.o libSystemConfiguration_server.o IPMonitorControlServer.o -framework SystemConfiguration -framework CoreFoundation # ---------- test_proxy: Makefile proxy-configuration.h proxy-configuration.c - cc -DMAIN -DDEBUG -Wall -O0 -g -o test_proxy proxy-configuration.c ${EXTRA_CFLAGS} -framework SystemConfiguration -framework CoreFoundation + $(CC) $(PF_INC) $(ARCH_FLAGS) -isysroot $(SYSROOT) -DMAIN -DDEBUG -Wall -O0 -g -o test_proxy proxy-configuration.c ${EXTRA_CFLAGS} -framework SystemConfiguration -framework CoreFoundation # ---------- set-hostnameX.o: Makefile set-hostname.h set-hostname.c - cc -DMAIN -DDEBUG ${TEST_INCLUDE} ${EXTRA_CFLAGS} -Wall -O0 -g -c -o set-hostnameX.o set-hostname.c + $(CC) $(PF_INC) $(ARCH_FLAGS) -isysroot $(SYSROOT) -DMAIN -DDEBUG ${TEST_INCLUDE} ${EXTRA_CFLAGS} -Wall -O0 -g -c -o set-hostnameX.o set-hostname.c test_hostname: Makefile dnsinfo_create.o dnsinfo_flatfile.o dnsinfo_server.o ip_pluginX.o IPMonitorControlPrefs.o network_information_priv.o network_information_server.o dns-configuration.o smb-configuration.o proxy-configuration.o set-hostnameX.o libSystemConfiguration_client.o libSystemConfiguration_server.o IPMonitorControlServer.o - cc -Wall -O0 -g -o test_hostname dnsinfo_create.o dnsinfo_flatfile.o dnsinfo_server.o ip_pluginX.o IPMonitorControlPrefs.o network_information_priv.o network_information_server.o dns-configuration.o smb-configuration.o proxy-configuration.o set-hostnameX.o libSystemConfiguration_client.o libSystemConfiguration_server.o IPMonitorControlServer.o ${EXTRA_CFLAGS} -framework SystemConfiguration -framework CoreFoundation + $(CC) $(PF_INC) $(ARCH_FLAGS) -isysroot $(SYSROOT) -Wall -O0 -g -o test_hostname dnsinfo_create.o dnsinfo_flatfile.o dnsinfo_server.o ip_pluginX.o IPMonitorControlPrefs.o network_information_priv.o network_information_server.o dns-configuration.o smb-configuration.o proxy-configuration.o set-hostnameX.o libSystemConfiguration_client.o libSystemConfiguration_server.o IPMonitorControlServer.o ${EXTRA_CFLAGS} -framework SystemConfiguration -framework CoreFoundation # ---------- smb-configurationX.o: smb-configuration.h smb-configuration.c - cc -DMAIN -DDEBUG ${TEST_INCLUDE} ${EXTRA_CFLAGS} -Wall -O0 -g -c -o smb-configurationX.o smb-configuration.c + $(CC) $(PF_INC) $(ARCH_FLAGS) -isysroot $(SYSROOT) -DMAIN -DDEBUG ${TEST_INCLUDE} ${EXTRA_CFLAGS} -Wall -O0 -g -c -o smb-configurationX.o smb-configuration.c test_smb: Makefile dnsinfo_create.o dnsinfo_flatfile.o dnsinfo_server.o ip_pluginX.o IPMonitorControlPrefs.o network_information_priv.o network_information_server.o dns-configuration.o smb-configurationX.o proxy-configuration.o set-hostname.o libSystemConfiguration_client.o libSystemConfiguration_server.o IPMonitorControlServer.o - cc -Wall -O0 -g -o test_smb dnsinfo_create.o dnsinfo_flatfile.o dnsinfo_server.o ip_pluginX.o IPMonitorControlPrefs.o network_information_priv.o network_information_server.o dns-configuration.o smb-configurationX.o proxy-configuration.o set-hostname.o libSystemConfiguration_client.o libSystemConfiguration_server.o IPMonitorControlServer.o ${EXTRA_CFLAGS} -framework SystemConfiguration -framework CoreFoundation + $(CC) $(PF_INC) $(ARCH_FLAGS) -isysroot $(SYSROOT) -Wall -O0 -g -o test_smb dnsinfo_create.o dnsinfo_flatfile.o dnsinfo_server.o ip_pluginX.o IPMonitorControlPrefs.o network_information_priv.o network_information_server.o dns-configuration.o smb-configurationX.o proxy-configuration.o set-hostname.o libSystemConfiguration_client.o libSystemConfiguration_server.o IPMonitorControlServer.o ${EXTRA_CFLAGS} -framework SystemConfiguration -framework CoreFoundation # ---------- test_ipv4_routelist.o: ip_plugin.c - cc -DTEST_IPV4_ROUTELIST ${TEST_INCLUDE} ${EXTRA_CFLAGS} -Wall -O0 -g -c -o $@ $^ + $(CC) $(PF_INC) $(ARCH_FLAGS) -isysroot $(SYSROOT) -DTEST_IPV4_ROUTELIST ${TEST_INCLUDE} ${EXTRA_CFLAGS} -Wall -O0 -g -c -o $@ $^ test_ipv4_routelist: test_ipv4_routelist.o IPMonitorControlPrefs.o dnsinfo_create.o dnsinfo_flatfile.o dnsinfo_server.o network_information_priv.o network_information_server.o smb-configuration.o proxy-configuration.o libSystemConfiguration_server.o IPMonitorControlServer.o - cc -Wformat -Wall -O0 -g -o $@ $^ ${EXTRA_CFLAGS} -framework SystemConfiguration -framework CoreFoundation + $(CC) $(PF_INC) $(ARCH_FLAGS) -isysroot $(SYSROOT) -Wformat -Wall -O0 -g -o $@ $^ ${EXTRA_CFLAGS} -framework SystemConfiguration -framework CoreFoundation test_ipv4_routelist_reference.txt: test_ipv4_routelist - sh test_reference.sh create test_ipv4_routelist test_ipv4_routelist_reference.txt routelist_output_filter.sh + sh $(REFERENCE_OUTPUT) create test_ipv4_routelist test_ipv4_routelist_reference.txt routelist_output_filter.sh test_ipv4_routelist_test: test_ipv4_routelist - sh test_reference.sh test test_ipv4_routelist test_ipv4_routelist_reference.txt routelist_output_filter.sh + sh $(REFERENCE_OUTPUT) test test_ipv4_routelist test_ipv4_routelist_reference.txt routelist_output_filter.sh test_ipv4_routelist_coverage: test_ipv4_routelist test_ipv4_routelist -1 | grep Hit | awk '{print $$2}' | sort | uniq @@ -97,16 +120,16 @@ test_ipv4_routelist_coverage: test_ipv4_routelist # ---------- test_ipv6_routelist.o: ip_plugin.c - cc -DTEST_IPV6_ROUTELIST ${TEST_INCLUDE} ${EXTRA_CFLAGS} -Wall -O0 -g -c -o $@ $^ + $(CC) $(PF_INC) $(ARCH_FLAGS) -isysroot $(SYSROOT) -DTEST_IPV6_ROUTELIST ${TEST_INCLUDE} ${EXTRA_CFLAGS} -Wall -O0 -g -c -o $@ $^ test_ipv6_routelist: test_ipv6_routelist.o IPMonitorControlPrefs.o dnsinfo_create.o dnsinfo_flatfile.o dnsinfo_server.o network_information_priv.o network_information_server.o smb-configuration.o proxy-configuration.o libSystemConfiguration_server.o IPMonitorControlServer.o - cc -Wformat -Wall -O0 -g -o $@ $^ ${EXTRA_CFLAGS} -framework SystemConfiguration -framework CoreFoundation + $(CC) $(PF_INC) $(ARCH_FLAGS) -isysroot $(SYSROOT) -Wformat -Wall -O0 -g -o $@ $^ ${EXTRA_CFLAGS} -framework SystemConfiguration -framework CoreFoundation test_ipv6_routelist_reference.txt: test_ipv6_routelist - sh test_reference.sh create test_ipv6_routelist test_ipv6_routelist_reference.txt routelist_output_filter.sh + sh $(REFERENCE_OUTPUT) create test_ipv6_routelist test_ipv6_routelist_reference.txt routelist_output_filter.sh test_ipv6_routelist_test: test_ipv6_routelist - sh test_reference.sh test test_ipv6_routelist test_ipv6_routelist_reference.txt routelist_output_filter.sh + sh $(REFERENCE_OUTPUT) test test_ipv6_routelist test_ipv6_routelist_reference.txt routelist_output_filter.sh test_ipv6_routelist_coverage: test_ipv6_routelist test_ipv6_routelist -1 | grep Hit | awk '{print $$2}' | sort | uniq @@ -114,10 +137,10 @@ test_ipv6_routelist_coverage: test_ipv6_routelist # ---------- IPMonitor.o: ip_plugin.c - cc -DTEST_IPMONITOR ${TEST_INCLUDE} ${EXTRA_CFLAGS} -Wall -O0 -g -c -o IPMonitor.o ip_plugin.c + $(CC) $(PF_INC) $(ARCH_FLAGS) -isysroot $(SYSROOT) -DTEST_IPMONITOR ${TEST_INCLUDE} ${EXTRA_CFLAGS} -Wall -O0 -g -c -o IPMonitor.o ip_plugin.c IPMonitor: IPMonitor.o IPMonitorControlPrefs.o dnsinfo_create.o dnsinfo_flatfile.o dnsinfo_server.o network_information_priv.o network_information_server.o proxy-configuration.o smb-configuration.o libSystemConfiguration_client.o libSystemConfiguration_server.o - cc -Wall -O0 -g -o IPMonitor IPMonitor.o IPMonitorControlPrefs.o dnsinfo_create.o dnsinfo_flatfile.o dnsinfo_server.o network_information_priv.o network_information_server.o proxy-configuration.o smb-configuration.o libSystemConfiguration_client.o libSystemConfiguration_server.o ${EXTRA_CFLAGS} -framework SystemConfiguration -framework CoreFoundation + $(CC) $(PF_INC) $(ARCH_FLAGS) -isysroot $(SYSROOT) -Wall -O0 -g -o IPMonitor IPMonitor.o IPMonitorControlPrefs.o dnsinfo_create.o dnsinfo_flatfile.o dnsinfo_server.o network_information_priv.o network_information_server.o proxy-configuration.o smb-configuration.o libSystemConfiguration_client.o libSystemConfiguration_server.o ${EXTRA_CFLAGS} -framework SystemConfiguration -framework CoreFoundation # ---------- diff --git a/Plugins/IPMonitor/Simulator/com.apple.networking.IPMonitor b/Plugins/IPMonitor/Simulator/com.apple.networking.IPMonitor new file mode 100644 index 0000000..8f9f9c5 --- /dev/null +++ b/Plugins/IPMonitor/Simulator/com.apple.networking.IPMonitor @@ -0,0 +1 @@ +? [= LoggerID com.apple.networking.IPMonitor] file $ENV(SIMULATOR_LOG_ROOT)/com.apple.networking.IPMonitor.log crashlog rotate=local file_max=1M compress format=$((Time)(local.6))\ $Host\ $(Sender)[$(PID)]\ <$((Level)(str))>:\ $(Message) \ No newline at end of file diff --git a/Plugins/IPMonitor/dns-configuration.c b/Plugins/IPMonitor/dns-configuration.c index e2c31e2..0f2913a 100644 --- a/Plugins/IPMonitor/dns-configuration.c +++ b/Plugins/IPMonitor/dns-configuration.c @@ -1,15 +1,15 @@ /* - * Copyright (c) 2004-2014 Apple Inc. All rights reserved. + * Copyright (c) 2004-2015 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ - * + * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. - * + * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, @@ -17,7 +17,7 @@ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. - * + * * @APPLE_LICENSE_HEADER_END@ */ @@ -56,16 +56,12 @@ extern uint32_t notify_monitor_file(int token, const char *name, int flags); #include "dns-configuration.h" #include +#include "dnsinfo_private.h" +#include "dnsinfo_internal.h" #include "dnsinfo_create.h" #include "dnsinfo_server.h" -#ifdef MAIN -#undef MAIN -#include "dnsinfo_copy.c" -#include "dnsinfo_internal.h" -#define MAIN -#define DNS_CONFIGURATION_DEBUG -#endif // MAIN +#include #include #ifndef kDNSServiceCompMulticastDNS @@ -92,24 +88,39 @@ static CFNumberRef S_pdns_timeout = NULL; -static void -add_dns_query_flags(const void *key, const void *value, void *context) +static uint32_t +dns_resolver_flags_service(CFDictionaryRef service, uint32_t resolver_flags) { - CFDictionaryRef service = value; - uint32_t *query_flags = context; - - // check if the service has v4 or v6 configured - - if ((*query_flags & DNS_RESOLVER_FLAGS_REQUEST_A_RECORDS) == 0 - && service_contains_protocol(service, AF_INET)) { - *query_flags |= DNS_RESOLVER_FLAGS_REQUEST_A_RECORDS; + // check if the service has v4 configured + if (((resolver_flags & DNS_RESOLVER_FLAGS_REQUEST_A_RECORDS) == 0) && + service_contains_protocol(service, AF_INET)) { + resolver_flags |= DNS_RESOLVER_FLAGS_REQUEST_A_RECORDS; } - if ((*query_flags & DNS_RESOLVER_FLAGS_REQUEST_AAAA_RECORDS) == 0 - && service_contains_protocol(service, AF_INET6)) { - *query_flags |= DNS_RESOLVER_FLAGS_REQUEST_AAAA_RECORDS; + + // check if the service has v6 configured + if (((resolver_flags & DNS_RESOLVER_FLAGS_REQUEST_AAAA_RECORDS) == 0) && + service_contains_protocol(service, AF_INET6)) { + resolver_flags |= DNS_RESOLVER_FLAGS_REQUEST_AAAA_RECORDS; } + return resolver_flags; +} + + +static void +add_dns_resolver_flags(const void *key, const void *value, void *context) +{ + CFDictionaryRef service = (CFDictionaryRef)value; +// CFStringRef serviceID = (CFStringRef)key; + uint32_t *resolver_flags = (uint32_t *)context; + + if (service_is_scoped_only(service)) { + return; +} + + // update resovler flags based on configured (and available) protocols + *resolver_flags = dns_resolver_flags_service(service, *resolver_flags); return; } @@ -218,8 +229,33 @@ add_resolver(CFMutableArrayRef resolvers, CFMutableDictionaryRef resolver) } +#define DNS_CONFIGURATION_CONFIGURATION_ID CFSTR("__CONFIGURATION_ID__") + + +static void +add_resolver_signature(CFMutableDictionaryRef resolver, const char *rType, CFStringRef cID, CFIndex rIndex) +{ + CFStringRef str; + + str = CFStringCreateWithFormat(NULL, NULL, + CFSTR("%s:%s%@ %ld"), + rType, + (cID != NULL) ? " " : "", + (cID != NULL) ? cID : CFSTR(""), + rIndex); + CFDictionarySetValue(resolver, DNS_CONFIGURATION_CONFIGURATION_ID, str); + CFRelease(str); + + return; +} + + static void -add_supplemental(CFMutableArrayRef resolvers, CFDictionaryRef dns, uint32_t defaultOrder) +add_supplemental(CFMutableArrayRef resolvers, + CFStringRef serviceID, + CFDictionaryRef dns, + uint32_t defaultOrder, + Boolean scoped) { CFArrayRef domains; CFIndex i; @@ -282,6 +318,10 @@ add_supplemental(CFMutableArrayRef resolvers, CFDictionaryRef dns, uint32_t defa CFDictionaryRemoveValue(match_resolver, kSCPropNetDNSSearchDomains); CFDictionaryRemoveValue(match_resolver, kSCPropNetDNSSortList); + add_resolver_signature(match_resolver, + scoped ? "Supplemental/Scoped" : "Supplemental", + serviceID, + i); add_resolver(resolvers, match_resolver); CFRelease(match_resolver); } @@ -324,10 +364,11 @@ add_supplemental_resolvers(CFMutableArrayRef resolvers, for (i = 0; i < n_services; i++) { uint32_t defaultOrder; CFDictionaryRef dns; + uint32_t dns_resolver_flags; CFStringRef interface; - uint32_t interface_flags; CFMutableDictionaryRef newDNS = NULL; CFDictionaryRef service = (CFDictionaryRef)vals[i]; + CFStringRef serviceID = (CFStringRef)keys[i]; if (!isA_CFDictionary(service)) { continue; @@ -368,9 +409,8 @@ add_supplemental_resolvers(CFMutableArrayRef resolvers, // on the IP[v6] addresses). If we would not be issuing a // query then don't bother adding the configuration. // - interface_flags = 0; - add_dns_query_flags(NULL, scoped_service, &interface_flags); - if (interface_flags == 0) { + dns_resolver_flags = dns_resolver_flags_service(scoped_service, 0); + if (dns_resolver_flags == 0) { continue; } } @@ -387,21 +427,31 @@ add_supplemental_resolvers(CFMutableArrayRef resolvers, /* * Ensure that we have the correct InterfaceName in the DNS configuration * - * scoped_interface [supplemental] interface DNS interface - * ================ ======================== ================= - * NULL NULL NULL (No change) - * NULL en0 NULL - * NULL * NULL - * en0 NULL "en0" - * en0 en0 "en0" (now mutable) - * en0 * "en0" + * scoped_interface [supplemental] interface Trusted config DNS interface + * ================ ======================== ============== ================= + * NULL NULL No NULL (No change) + * NULL en0 No NULL + * NULL * No NULL + * NULL NULL Yes NULL (No change) + * NULL en0 Yes en0 (trusted config w/interface) + * NULL * Yes NULL + * en0 NULL N/A en0 (scoped interface) + * en0 en0 N/A en0 (scoped interface) + * en0 * N/A en0 (scoped interface) */ if ((scoped_interface == NULL) && (interface == NULL)) { newDNS = (CFMutableDictionaryRef)CFRetain(dns); } else { + CFBooleanRef val; + newDNS = CFDictionaryCreateMutableCopy(NULL, 0, dns); if (scoped_interface != NULL) { CFDictionarySetValue(newDNS, kSCPropInterfaceName, scoped_interface); + } else if ((interface != NULL) && + CFDictionaryGetValueIfPresent(dns, DNS_CONFIGURATION_SCOPED_QUERY_KEY, (const void **)&val) && + isA_CFBoolean(val) && + CFBooleanGetValue(val)) { + // leave the [trusted configuration] InterfaceName in place } else { CFDictionaryRemoveValue(newDNS, kSCPropInterfaceName); } @@ -419,8 +469,8 @@ add_supplemental_resolvers(CFMutableArrayRef resolvers, } flags |= DNS_RESOLVER_FLAGS_SCOPED; - // add A/AAAA query flag(s) - flags |= interface_flags; + // add "Request A/AAAA query" flag(s) + flags |= dns_resolver_flags; num = CFNumberCreate(NULL, kCFNumberSInt32Type, &flags); CFDictionarySetValue(newDNS, DNS_CONFIGURATION_FLAGS_KEY, num); @@ -428,7 +478,7 @@ add_supplemental_resolvers(CFMutableArrayRef resolvers, } // add [scoped] resolver entry - add_supplemental(resolvers, newDNS, defaultOrder); + add_supplemental(resolvers, serviceID, newDNS, defaultOrder, (scoped_interface != NULL)); CFRelease(newDNS); } @@ -476,6 +526,7 @@ add_multicast_resolvers(CFMutableArrayRef resolvers, CFArrayRef multicastResolve if (S_mdns_timeout != NULL) { CFDictionarySetValue(resolver, kSCPropNetDNSServerTimeout, S_mdns_timeout); } + add_resolver_signature(resolver, "Multicast DNS", NULL, i); add_resolver(resolvers, resolver); CFRelease(resolver); CFRelease(domain); @@ -520,6 +571,7 @@ add_private_resolvers(CFMutableArrayRef resolvers, CFArrayRef privateResolvers) if (S_pdns_timeout != NULL) { CFDictionarySetValue(resolver, kSCPropNetDNSServerTimeout, S_pdns_timeout); } + add_resolver_signature(resolver, "Private DNS", NULL, i); add_resolver(resolvers, resolver); CFRelease(resolver); CFRelease(domain); @@ -764,7 +816,9 @@ extract_search_domains(CFMutableDictionaryRef defaultDomain, CFArrayRef suppleme static void -add_scoped_resolvers(CFMutableArrayRef scoped, CFDictionaryRef services, CFArrayRef service_order) +add_scoped_resolvers(CFMutableArrayRef scoped, + CFDictionaryRef services, + CFArrayRef service_order) { const void * keys_q[N_QUICK]; const void ** keys = keys_q; @@ -809,6 +863,7 @@ add_scoped_resolvers(CFMutableArrayRef scoped, CFDictionaryRef services, CFArray seen = CFSetCreateMutable(NULL, 0, &kCFTypeSetCallBacks); for (i = 0; i < n_order; i++) { CFDictionaryRef dns; + uint32_t dns_resolver_flags; uint32_t flags; char if_name[IF_NAMESIZE]; CFStringRef interface; @@ -817,7 +872,6 @@ add_scoped_resolvers(CFMutableArrayRef scoped, CFDictionaryRef services, CFArray CFArrayRef searchDomains; CFDictionaryRef service; CFStringRef serviceID; - uint32_t these_flags; serviceID = CFArrayGetValueAtIndex(order, i); service = CFDictionaryGetValue(services, serviceID); @@ -876,12 +930,12 @@ add_scoped_resolvers(CFMutableArrayRef scoped, CFDictionaryRef services, CFArray } flags |= DNS_RESOLVER_FLAGS_SCOPED; - these_flags = 0; - add_dns_query_flags(serviceID, service, &these_flags); - if (these_flags == 0) { + // add "Request A/AAAA query" flag(s) + dns_resolver_flags = dns_resolver_flags_service(service, 0); + if (dns_resolver_flags == 0) { goto skip; } - flags |= these_flags; + flags |= dns_resolver_flags; num = CFNumberCreate(NULL, kCFNumberSInt32Type, &flags); CFDictionarySetValue(newDNS, DNS_CONFIGURATION_FLAGS_KEY, num); @@ -892,6 +946,7 @@ add_scoped_resolvers(CFMutableArrayRef scoped, CFDictionaryRef services, CFArray CFDictionaryRemoveValue(newDNS, kSCPropNetDNSSupplementalMatchOrders); // add the [scoped] resolver + add_resolver_signature(newDNS, "Scoped", serviceID, 0); add_resolver(scoped, newDNS); // add any supplemental resolver configurations for this interface @@ -910,68 +965,86 @@ add_scoped_resolvers(CFMutableArrayRef scoped, CFDictionaryRef services, CFArray static void add_service_specific_resolvers(CFMutableArrayRef resolvers, CFDictionaryRef services) { - CFIndex services_count = (isA_CFDictionary(services) ? CFDictionaryGetCount(services) : 0); + CFIndex i; + CFStringRef keys_q[N_QUICK]; + CFStringRef *keys = keys_q; + CFIndex n_services; + CFMutableSetRef seen; + CFDictionaryRef vals_q[N_QUICK]; + CFDictionaryRef *vals = vals_q; - if (services_count > 0) { - CFIndex key_idx; - CFStringRef keys_q[N_QUICK]; - CFStringRef *keys = keys_q; - CFMutableSetRef seen = CFSetCreateMutable(NULL, 0, &kCFTypeSetCallBacks); + n_services = isA_CFDictionary(services) ? CFDictionaryGetCount(services) : 0; + if (n_services == 0) { + return; // if no services + } - if (services_count > (CFIndex)(sizeof(keys_q) / sizeof(keys_q[0]))) { - keys = CFAllocatorAllocate(kCFAllocatorDefault, services_count * sizeof(keys[0]), 0); - } + if (n_services > (CFIndex)(sizeof(keys_q) / sizeof(keys_q[0]))) { + keys = CFAllocatorAllocate(kCFAllocatorDefault, n_services * sizeof(keys[0]), 0); + vals = CFAllocatorAllocate(kCFAllocatorDefault, n_services * sizeof(vals[0]), 0); + } + CFDictionaryGetKeysAndValues(services, (const void **)keys, (const void **)vals); - CFDictionaryGetKeysAndValues(services, (const void **)keys, NULL); + seen = CFSetCreateMutable(NULL, 0, &kCFTypeSetCallBacks); + for (i = 0; i < n_services; i++) { + CFDictionaryRef dns; + CFNumberRef dns_service_identifier; + CFNumberRef flags_num; + int32_t flags = 0; + CFMutableDictionaryRef new_resolver; + CFDictionaryRef service = vals[i]; + CFStringRef serviceID = keys[i]; - for (key_idx = 0; key_idx < services_count; key_idx++) { - CFDictionaryRef service = CFDictionaryGetValue(services, keys[key_idx]); - CFDictionaryRef dns = CFDictionaryGetValue(service, kSCEntNetDNS); + dns = CFDictionaryGetValue(service, kSCEntNetDNS); + if (!isA_CFDictionary(dns)) { + // if no DNS + continue; + } - if (isA_CFDictionary(dns)) { - CFNumberRef service_identifier = CFDictionaryGetValue(dns, kSCPropNetDNSServiceIdentifier); + dns_service_identifier = CFDictionaryGetValue(dns, kSCPropNetDNSServiceIdentifier); + if (!isA_CFNumber(dns_service_identifier)) { + // if no DNS [vpn] Service Identifier + continue; + } - if (isA_CFNumber(service_identifier)) { - if (!CFSetContainsValue(seen, service_identifier)) { - CFMutableDictionaryRef new_resolver = CFDictionaryCreateMutableCopy(NULL, 0, dns); - CFNumberRef flags_num; - int32_t flags = 0; + if (CFSetContainsValue(seen, dns_service_identifier)) { + my_log(LOG_ERR, "add_service_specific_resolvers: got a resolver with a duplicate service identifier, skipping"); + continue; + } + CFSetSetValue(seen, dns_service_identifier); - CFSetSetValue(seen, service_identifier); + new_resolver = CFDictionaryCreateMutableCopy(NULL, 0, dns); - if (!CFDictionaryGetValueIfPresent(new_resolver, DNS_CONFIGURATION_FLAGS_KEY, (const void **)&flags_num) || - !isA_CFNumber(flags_num) || - !CFNumberGetValue(flags_num, kCFNumberSInt32Type, &flags)) { - flags = 0; - } + if (!CFDictionaryGetValueIfPresent(new_resolver, DNS_CONFIGURATION_FLAGS_KEY, (const void **)&flags_num) || + !isA_CFNumber(flags_num) || + !CFNumberGetValue(flags_num, kCFNumberSInt32Type, &flags)) { + flags = 0; + } - flags |= DNS_RESOLVER_FLAGS_SERVICE_SPECIFIC | DNS_RESOLVER_FLAGS_REQUEST_ALL_RECORDS; + flags |= DNS_RESOLVER_FLAGS_SERVICE_SPECIFIC | DNS_RESOLVER_FLAGS_REQUEST_ALL_RECORDS; - flags_num = CFNumberCreate(NULL, kCFNumberSInt32Type, &flags); - CFDictionarySetValue(new_resolver, DNS_CONFIGURATION_FLAGS_KEY, flags_num); - CFRelease(flags_num); + flags_num = CFNumberCreate(NULL, kCFNumberSInt32Type, &flags); + CFDictionarySetValue(new_resolver, DNS_CONFIGURATION_FLAGS_KEY, flags_num); + CFRelease(flags_num); - if (CFDictionaryContainsKey(new_resolver, kSCPropInterfaceName)) { - CFDictionarySetValue(new_resolver, DNS_CONFIGURATION_SCOPED_QUERY_KEY, kCFBooleanTrue); - } + if (CFDictionaryContainsKey(new_resolver, kSCPropInterfaceName)) { + CFDictionarySetValue(new_resolver, DNS_CONFIGURATION_SCOPED_QUERY_KEY, kCFBooleanTrue); + } - CFDictionaryRemoveValue(new_resolver, kSCPropNetDNSSupplementalMatchDomains); - CFDictionaryRemoveValue(new_resolver, kSCPropNetDNSSupplementalMatchOrders); + CFDictionaryRemoveValue(new_resolver, kSCPropNetDNSSupplementalMatchDomains); + CFDictionaryRemoveValue(new_resolver, kSCPropNetDNSSupplementalMatchOrders); - add_resolver(resolvers, new_resolver); - CFRelease(new_resolver); - } else { - my_log(LOG_ERR, "add_service_specific_resolvers: got a resolver with a duplicate service identifier, skipping"); - } - } - } - } + add_resolver_signature(new_resolver, "Service", serviceID, 0); + add_resolver(resolvers, new_resolver); + CFRelease(new_resolver); + } + CFRelease(seen); - if (keys != keys_q) { - CFAllocatorDeallocate(kCFAllocatorDefault, keys); - } - CFRelease(seen); + if (keys != keys_q) { + CFAllocatorDeallocate(kCFAllocatorDefault, keys); + CFAllocatorDeallocate(kCFAllocatorDefault, vals); } + + return; } @@ -1014,6 +1087,7 @@ add_default_resolver(CFMutableArrayRef resolvers, // add the default resolver + add_resolver_signature(myDefault, "Default", NULL, 0); add_resolver(resolvers, myDefault); CFRelease(myDefault); return; @@ -1235,10 +1309,22 @@ create_resolver(CFDictionaryRef dns) num = CFDictionaryGetValue(dns, kSCPropNetDNSServiceIdentifier); if (isA_CFNumber(num)) { - int service_identifier; + int dns_service_identifier; + + if (CFNumberGetValue(num, kCFNumberIntType, &dns_service_identifier)) { + _dns_resolver_set_service_identifier(&_resolver, (uint32_t)dns_service_identifier); + } + } + + // process configuration ID + str = CFDictionaryGetValue(dns, DNS_CONFIGURATION_CONFIGURATION_ID); + if (isA_CFString(str) && (CFStringGetLength(str) > 0)) { + char *cID; - if (CFNumberGetValue(num, kCFNumberIntType, &service_identifier)) { - _dns_resolver_set_service_identifier(&_resolver, (uint32_t)service_identifier); + cID = _SC_cfstring_to_cstring(str, NULL, 0, kCFStringEncodingUTF8); + if (cID != NULL) { + _dns_resolver_set_configuration_identifier(&_resolver, cID); + CFAllocatorDeallocate(NULL, cID); } } @@ -1251,7 +1337,7 @@ create_resolver(CFDictionaryRef dns) static __inline__ Boolean -isScopedConfiguration(CFDictionaryRef dns) +isDefaultConfiguration(CFDictionaryRef dns) { uint32_t flags; CFNumberRef num; @@ -1260,26 +1346,30 @@ isScopedConfiguration(CFDictionaryRef dns) CFDictionaryGetValueIfPresent(dns, DNS_CONFIGURATION_FLAGS_KEY, (const void **)&num) && (num != NULL) && CFNumberGetValue(num, kCFNumberSInt32Type, &flags) && - ((flags & DNS_RESOLVER_FLAGS_SCOPED) != 0)) { - return TRUE; + (((flags & DNS_RESOLVER_FLAGS_SCOPED ) != 0) || + ((flags & DNS_RESOLVER_FLAGS_SERVICE_SPECIFIC) != 0)) + ) { + // if scoped or service-specific + return FALSE; } - return FALSE; + return TRUE; } + static __inline__ Boolean -isServiceSpecificConfiguration(CFDictionaryRef dns) +isScopedConfiguration(CFDictionaryRef dns) { uint32_t flags; CFNumberRef num; - if (dns != NULL && + if ((dns != NULL) && CFDictionaryGetValueIfPresent(dns, DNS_CONFIGURATION_FLAGS_KEY, (const void **)&num) && - num != NULL && + (num != NULL) && CFNumberGetValue(num, kCFNumberSInt32Type, &flags) && - (flags & DNS_RESOLVER_FLAGS_SERVICE_SPECIFIC)) - { + ((flags & DNS_RESOLVER_FLAGS_SCOPED) != 0)) { + // if scoped return TRUE; } @@ -1485,7 +1575,7 @@ dns_configuration_set(CFDictionaryRef defaultResolver, */ _config = _dns_configuration_create(); - CFDictionaryApplyFunction(services, add_dns_query_flags , &dns_resolver_flags); + CFDictionaryApplyFunction(services, add_dns_resolver_flags, &dns_resolver_flags); for (i = 0; i < n_resolvers; i++) { boolean_t is_default_resolver; @@ -1494,7 +1584,7 @@ dns_configuration_set(CFDictionaryRef defaultResolver, resolver = CFArrayGetValueAtIndex(resolvers, i); - is_default_resolver = (!isScopedConfiguration(resolver) && !isServiceSpecificConfiguration(resolver)); + is_default_resolver = isDefaultConfiguration(resolver); if (is_default_resolver) { CFMutableDictionaryRef new_resolver; CFNumberRef num; @@ -1525,36 +1615,39 @@ dns_configuration_set(CFDictionaryRef defaultResolver, #endif // !TARGET_OS_IPHONE } -#ifdef DNS_CONFIGURATION_DEBUG - { - uint8_t *buf; - dns_config_t *config; - _dns_config_buf_t *config_buf; - uint32_t n_config; - uint32_t n_padding; - - config_buf = (_dns_config_buf_t *)_config; - n_config = sizeof(_dns_config_buf_t) + ntohl(config_buf->n_attribute); - n_padding = ntohl(config_buf->n_padding); - buf = malloc(n_config + n_padding); - bcopy((void *)config_buf, buf, n_config); - bzero(&buf[n_config], n_padding); - config = expand_config((_dns_config_buf_t *)buf); - _dns_configuration_print(config); - free(buf); - } -#endif // DNS_CONFIGURATION_DEBUG - // check if the configuration changed _dns_configuration_signature(&_config, signature, sizeof(signature)); if (bcmp(signature, signature_last, sizeof(signature)) != 0) { // save [new] signature bcopy(signature, signature_last, sizeof(signature)); + my_log(LOG_INFO, "Updating DNS configuration"); + if (_config != NULL) { + uint8_t *buf; + dns_config_t *config; + _dns_config_buf_t *config_buf; + uint32_t n_config; + uint32_t n_padding; + + config_buf = (_dns_config_buf_t *)_config; + n_config = sizeof(_dns_config_buf_t) + ntohl(config_buf->n_attribute); + n_padding = ntohl(config_buf->n_padding); + buf = malloc(n_config + n_padding); + bcopy((void *)config_buf, buf, n_config); + bzero(&buf[n_config], n_padding); + /* ALIGN: cast okay since _dns_config_buf_t is int aligned */ + config = _dns_configuration_expand_config((_dns_config_buf_t *)(void *)buf); + _dns_configuration_log(config, TRUE); + free(buf); + } else { + my_log(LOG_INFO, "*** No DNS configuration"); + } +#ifndef MAIN // save [new] configuration if (!_dns_configuration_store(&_config)) { - my_log(LOG_ERR, "dns_configuration_set: could not store configuration"); + my_log(LOG_ERR, "could not store configuration"); } +#endif // MAIN changed = TRUE; } @@ -1573,27 +1666,36 @@ static SCDynamicStoreCallBack dns_configuration_callout; static void dns_configuration_changed(CFMachPortRef port, void *msg, CFIndex size, void *info) { - CFStringRef key = CFSTR(_PATH_RESOLVER_DIR); - CFArrayRef keys; - Boolean resolvers_now; - static Boolean resolvers_save = FALSE; - struct stat statbuf; + os_activity_t activity_id; + static const CFStringRef key = CFSTR(_PATH_RESOLVER_DIR); + CFArrayRef keys; + Boolean resolvers_now; + static Boolean resolvers_save = FALSE; + struct stat statbuf; + + activity_id = os_activity_start("processing DNS configuration change", + OS_ACTIVITY_FLAG_DEFAULT); resolvers_now = (stat(_PATH_RESOLVER_DIR, &statbuf) == 0); if (!resolvers_save && (resolvers_save == resolvers_now)) { // if we did not (and still do not) have an "/etc/resolvers" // directory than this notification is the result of a change // to the "/etc" directory. - return; + goto done; } resolvers_save = resolvers_now; - my_log(LOG_DEBUG, _PATH_RESOLVER_DIR " changed"); + my_log(LOG_INFO, _PATH_RESOLVER_DIR " changed"); // fake a "DNS" change keys = CFArrayCreate(NULL, (const void **)&key, 1, &kCFTypeArrayCallBacks); (*dns_configuration_callout)(dns_configuration_store, keys, NULL); CFRelease(keys); + + done : + + os_activity_end(activity_id); + return; } @@ -1773,6 +1875,7 @@ main(int argc, char **argv) CFDictionaryRef state_global_ipv4; SCDynamicStoreRef store; + _sc_debug = TRUE; _sc_log = FALSE; _sc_verbose = (argc > 1) ? TRUE : FALSE; diff --git a/Plugins/IPMonitor/dns-configuration.h b/Plugins/IPMonitor/dns-configuration.h index b218d3a..e047cb1 100644 --- a/Plugins/IPMonitor/dns-configuration.h +++ b/Plugins/IPMonitor/dns-configuration.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2008, 2009, 2011, 2012 Apple Inc. All rights reserved. + * Copyright (c) 2006, 2008, 2009, 2011, 2012, 2015 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * diff --git a/Plugins/IPMonitor/ip_plugin.c b/Plugins/IPMonitor/ip_plugin.c index d111ad4..f488f6c 100644 --- a/Plugins/IPMonitor/ip_plugin.c +++ b/Plugins/IPMonitor/ip_plugin.c @@ -1,15 +1,15 @@ /* - * Copyright (c) 2000-2014 Apple Inc. All Rights Reserved. + * Copyright (c) 2000-2015 Apple Inc. All Rights Reserved. * * @APPLE_LICENSE_HEADER_START@ - * + * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. - * + * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, @@ -17,7 +17,7 @@ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. - * + * * @APPLE_LICENSE_HEADER_END@ */ @@ -383,7 +383,8 @@ typedef struct { typedef CF_ENUM(uint16_t, RouteListFlags) { kRouteListFlagsExcludeNWI = 0x0001, - kRouteListFlagsHasDefault = 0x0002 + kRouteListFlagsHasDefault = 0x0002, + kRouteListFlagsScopedOnly = 0x0004 }; #define ROUTELIST_COMMON \ @@ -436,6 +437,7 @@ typedef struct Candidate { CFStringRef if_name; Rank rank; boolean_t ip_is_coupled; + boolean_t ineligible; SCNetworkReachabilityFlags reachability_flags; in_addr addr; in_sockaddr vpn_server_addr; @@ -852,15 +854,15 @@ keyChangeListApplyToStore(keyChangeListRef keys, SCDynamicStoreRef session) if (set == NULL && remove == NULL && notify == NULL) { return; } - if (S_IPMonitor_debug & kDebugFlag1) { + if ((S_IPMonitor_debug & kDebugFlag1) != 0) { if (set != NULL) { - my_log(LOG_DEBUG, "IPMonitor: Setting:\n%@", set); + my_log(LOG_DEBUG, "Setting:\n%@", set); } if (remove != NULL) { - my_log(LOG_DEBUG, "IPMonitor: Removing:\n%@", remove); + my_log(LOG_DEBUG, "Removing:\n%@", remove); } if (notify != NULL) { - my_log(LOG_DEBUG, "IPMonitor: Notifying:\n%@", notify); + my_log(LOG_DEBUG, "Notifying:\n%@", notify); } } (void)SCDynamicStoreSetMultiple(session, set, remove, notify); @@ -885,10 +887,10 @@ S_nwi_ifstate_dump(nwi_ifstate_t ifstate, int i) vpn_ntopbuf, sizeof(vpn_ntopbuf)); } - my_log(LOG_DEBUG, + my_log(LOG_INFO, " [%d]: %s%s%s%s rank 0x%x iaddr %s%s%s reach_flags 0x%x", i, ifstate->ifname, - ifstate->diff_str != NULL ? ifstate->diff_str : "", + nwi_ifstate_get_diff_str(ifstate), (ifstate->flags & NWI_IFSTATE_FLAGS_HAS_DNS) != 0 ? " dns" : "", (ifstate->flags & NWI_IFSTATE_FLAGS_NOT_IN_LIST) != 0 @@ -908,33 +910,43 @@ S_nwi_state_dump(nwi_state_t state) nwi_ifstate_t scan; if (state == NULL) { - my_log(LOG_DEBUG, "nwi_state = "); + my_log(LOG_INFO, "nwi_state = "); return; } - my_log(LOG_DEBUG, + my_log(LOG_INFO, "nwi_state = { " - "gen=%llu size=%u #v4=%u #v6=%u " + "gen=%llu size=%lu #v4=%u #v6=%u " "reach_flags=(v4=0x%x, v6=0x%x) }", state->generation_count, - state->size, + nwi_state_size(state), state->ipv4_count, state->ipv6_count, nwi_state_get_reachability_flags(state, AF_INET), nwi_state_get_reachability_flags(state, AF_INET6)); if (state->ipv4_count) { - my_log(LOG_DEBUG, "IPv4:"); - for (i = 0, scan = state->nwi_ifstates; + my_log(LOG_INFO, "IPv4:"); + for (i = 0, scan = nwi_state_ifstate_list(state, AF_INET); i < state->ipv4_count; i++, scan++) { S_nwi_ifstate_dump(scan, i); } } if (state->ipv6_count) { - my_log(LOG_DEBUG, "IPv6:"); - for (i = 0, scan = state->nwi_ifstates + state->ipv6_start; + my_log(LOG_INFO, "IPv6:"); + for (i = 0, scan = nwi_state_ifstate_list(state, AF_INET6); i < state->ipv6_count; i++, scan++) { S_nwi_ifstate_dump(scan, i); } } + if (state->max_if_count) { + nwi_ifindex_t * ifindex; + + my_log(LOG_INFO, "%d interfaces:", state->if_list_count); + for (i = 0, ifindex = nwi_state_if_list(state); + i < state->if_list_count; + i++, ifindex++) { + my_log(LOG_INFO, "%s", state->ifstate_list[*ifindex].ifname); + } + } return; } @@ -961,17 +973,22 @@ open_routing_socket(void) int sockfd; if ((sockfd = socket(PF_ROUTE, SOCK_RAW, PF_ROUTE)) == -1) { - my_log(LOG_NOTICE, - "IPMonitor: open_routing_socket: socket failed, %s", - strerror(errno)); + my_log(LOG_ERR, "socket() failed: %s", strerror(errno)); } return (sockfd); } static __inline__ int -inet6_dgram_socket() +inet6_dgram_socket(void) { - return (socket(AF_INET6, SOCK_DGRAM, 0)); + int sockfd; + + sockfd = socket(AF_INET6, SOCK_DGRAM, 0); + if (sockfd == -1) { + my_log(LOG_ERR, "socket() failed: %s", strerror(errno)); + } + + return sockfd; } static int @@ -1935,16 +1952,13 @@ RouteProcess(RouteRef route, route->ifindex, kRouteLookupFlagsNone); if (gateway_route == NULL) { - (*route_log)(LOG_NOTICE, route, - "IPMonitor RouteProcess: no gateway route"); + (*route_log)(LOG_NOTICE, route, "no gateway route"); } else { #define MAX_RECURSE_DEPTH 10 /* avoid infinite recursion */ if (context->depth == MAX_RECURSE_DEPTH) { - (*route_log)(LOG_NOTICE, route, - "IPMonitor RouteProcess: " - "routing loop detected, not adding"); + (*route_log)(LOG_NOTICE, route, "routing loop detected, not adding"); return (FALSE); } /* recurse to add gateway route */ @@ -1954,8 +1968,7 @@ RouteProcess(RouteRef route, context); context->depth--; if (added == FALSE) { - (*route_log)(LOG_NOTICE, route, - "IPMonitor RouteProcess: failed to add"); + (*route_log)(LOG_NOTICE, route, "failed to add"); return (FALSE); } } @@ -1969,7 +1982,7 @@ RouteProcess(RouteRef route, switch (retval) { default: my_log(LOG_NOTICE, - "IPMonitor RouteProcess failed to add route, %s:", + "failed to add route, %s:", strerror(retval)); (*route_log)(LOG_NOTICE, route, NULL); break; @@ -2013,8 +2026,8 @@ RouteProcess(RouteRef route, break; default: my_log(LOG_NOTICE, - "IPMonitor RouteProcess failed to remove" - " route, %s", strerror(retval)); + "failed to remove route, %s", + strerror(retval)); (*route_log)(LOG_NOTICE, route, NULL); break; } @@ -2130,8 +2143,7 @@ RouteListFinalize(RouteListInfoRef info, RouteListRef routes) (*info->route_destination)(scan), scan->prefix_length, ifindex, flags); if (route == NULL) { - (*info->route_log)(LOG_NOTICE, (RouteRef)scan, - "IPMonitor: can't resolve excluded route"); + (*info->route_log)(LOG_NOTICE, (RouteRef)scan, "can't resolve excluded route"); } else { if ((S_IPMonitor_debug & kDebugFlag8) != 0) { @@ -2427,7 +2439,7 @@ typedef struct { static int IPv4RouteApply(RouteRef r_route, int cmd, int sockfd) { - int len; + size_t len; int ret = 0; IPv4RouteRef route = (IPv4RouteRef)r_route; route_msg rtmsg; @@ -2450,8 +2462,7 @@ IPv4RouteApply(RouteRef r_route, int cmd, int sockfd) } if (route->ifindex == 0) { my_log(LOG_NOTICE, - "IPMonitor IPv4RouteApply: " IP_FORMAT - " no interface specified, ignoring", + IP_FORMAT " no interface specified, ignoring", IP_LIST(&route->dest)); return (ENXIO); } @@ -2642,17 +2653,17 @@ AddIPv4Route(const void * value, void * context) || !dict_get_ip(dict, kSCPropNetIPv4RouteSubnetMask, &r->mask)) { /* one less route than we expected */ if (dict == NULL) { - my_log(LOG_NOTICE, "IPMonitor: %s route is not a dictionary", + my_log(LOG_NOTICE, "%s route is not a dictionary", ctx->descr); } else { - my_log(LOG_NOTICE, "IPMonitor: %s route is invalid, %@", + my_log(LOG_NOTICE, "%s route is invalid, %@", ctx->descr, dict); } goto skip; } if (IPv4RouteSetPrefixLength(r) == FALSE) { - my_log(LOG_NOTICE, "IPMonitor: %s route has invalid subnet mask, %@", + my_log(LOG_NOTICE, "%s route has invalid subnet mask, %@", ctx->descr, dict); goto skip; } @@ -2681,13 +2692,13 @@ AddIPv4Route(const void * value, void * context) ifindex = my_if_nametoindex(ifname); if (ifindex == 0) { my_log(LOG_NOTICE, - "IPMonitor %s: interface %s does not exist, %@", + "%s: interface %s does not exist, %@", ctx->descr, ifname, dict); goto skip; } else if (ifindex == ctx->ifindex) { my_log(LOG_NOTICE, - "IPMonitor %s: interface %s unexpected, %@", + "%s: interface %s unexpected, %@", ctx->descr, ifname, dict); goto skip; } @@ -2758,6 +2769,7 @@ IPv4RouteListCreateWithDictionary(IPv4RouteListRef routes, IPv4RouteRef r; Rank rank = kRankAssertionDefault; struct in_addr router = { 0 }; + boolean_t scoped_only = FALSE; struct in_addr subnet = { 0 }; if (dict == NULL) { @@ -2786,7 +2798,7 @@ IPv4RouteListCreateWithDictionary(IPv4RouteListRef routes, prefix_length = mask_get_prefix_length(mask); if (prefix_length < 0) { my_log(LOG_NOTICE, - "IPMonitor: ignoring bad subnet mask " + "ignoring bad subnet mask " IP_FORMAT " on %s", IP_LIST(&mask), ifname); } @@ -2848,6 +2860,7 @@ IPv4RouteListCreateWithDictionary(IPv4RouteListRef routes, /* Scoped means all routes for the service get scoped */ primary_rank = rank = kRankAssertionNever; flags |= kRouteFlagsIsScoped; + scoped_only = TRUE; break; case kRankAssertionNever: /* Never means just the default route gets scoped */ @@ -2864,7 +2877,7 @@ IPv4RouteListCreateWithDictionary(IPv4RouteListRef routes, n++; } - if (ifindex != lo0_ifindex()) { + if (ifindex != lo0_ifindex() && router.s_addr != 0) { add_default = TRUE; n++; } @@ -2893,6 +2906,9 @@ IPv4RouteListCreateWithDictionary(IPv4RouteListRef routes, if (exclude_from_nwi) { routes->flags |= kRouteListFlagsExcludeNWI; } + else if (scoped_only) { + routes->flags |= kRouteListFlagsScopedOnly; + } /* start at the beginning */ r = routes->list; @@ -3176,11 +3192,11 @@ AddIPv6Route(const void * value, void * context) || !ipv6_prefix_length_is_valid(r->prefix_length)) { /* one less route than we expected */ if (dict == NULL) { - my_log(LOG_NOTICE, "IPMonitor: %s route is not a dictionary", + my_log(LOG_NOTICE, "%s route is not a dictionary", ctx->descr); } else { - my_log(LOG_NOTICE, "IPMonitor: %s route is invalid, %@", + my_log(LOG_NOTICE, "%s route is invalid, %@", ctx->descr, dict); } goto skip; @@ -3210,13 +3226,13 @@ AddIPv6Route(const void * value, void * context) ifindex = my_if_nametoindex(ifname); if (ifindex == 0) { my_log(LOG_NOTICE, - "IPMonitor %s: interface %s does not exist, %@", + "%s: interface %s does not exist, %@", ctx->descr, ifname, dict); goto skip; } else if (ifindex == ctx->ifindex) { my_log(LOG_NOTICE, - "IPMonitor %s: interface %s unexpected, %@", + "%s: interface %s unexpected, %@", ctx->descr, ifname, dict); goto skip; } @@ -3266,6 +3282,7 @@ IPv6RouteListCreateWithDictionary(IPv6RouteListRef routes, IPv6RouteRef r; Rank rank = kRankAssertionDefault; struct in6_addr router = in6addr_any; + boolean_t scoped_only = FALSE; if (dict == NULL) { return (NULL); @@ -3337,6 +3354,7 @@ IPv6RouteListCreateWithDictionary(IPv6RouteListRef routes, /* Scoped means all routes for the service get scoped */ primary_rank = rank = kRankAssertionNever; flags |= kRouteFlagsIsScoped; + scoped_only = TRUE; break; case kRankAssertionNever: /* Never means just the default route gets scoped */ @@ -3380,6 +3398,9 @@ IPv6RouteListCreateWithDictionary(IPv6RouteListRef routes, if (exclude_from_nwi) { routes->flags |= kRouteListFlagsExcludeNWI; } + else if (scoped_only) { + routes->flags |= kRouteListFlagsScopedOnly; + } /* start at the beginning */ r = routes->list; @@ -3555,7 +3576,7 @@ IPv6RouteApply(RouteRef r_route, int cmd, int sockfd) } if (route->ifindex == 0) { IPv6RouteLog(LOG_NOTICE, (RouteRef)route, - "IPMonitor IPv6RouteApply: no interface specified"); + "no interface specified"); return (ENXIO); } if (sockfd == -1) { @@ -3790,6 +3811,62 @@ service_dict_copy(CFStringRef serviceID) return (service_dict); } +__private_extern__ boolean_t +service_is_scoped_only(CFDictionaryRef service_dict) +{ + nwi_ifstate_t alias; + CFDictionaryRef dict; + char ifname[IFNAMSIZ]; + nwi_ifstate_t ifstate; + CFStringRef interface = NULL; + + // get IPv4 (or IPv6) info + dict = CFDictionaryGetValue(service_dict, kSCEntNetIPv4); + if (dict == NULL) { + dict = CFDictionaryGetValue(service_dict, kSCEntNetIPv6); + } + if (dict == NULL) { + // if no connectivity + return FALSE; + } + + // get interface + interface = ipdict_get_ifname(dict); + if ((interface == NULL) || + !CFStringGetCString(interface, ifname, sizeof(ifname), kCFStringEncodingUTF8)) { + // if no interface / interface name + return FALSE; + } + +#ifdef TEST_DNS + if (S_nwi_state == NULL) { + S_nwi_state = nwi_state_copy(); + } +#endif // TEST_DNS + + // get [nwi] interface state + ifstate = nwi_state_get_ifstate(S_nwi_state, ifname); + if (ifstate == NULL) { + // if unknown state + return FALSE; + } else if ((ifstate->flags & NWI_IFSTATE_FLAGS_NOT_IN_LIST) != 0) { + // if scoped (i.e. not in list) + return TRUE; + } + + // check both both IPv4 and IPv6 + alias = nwi_ifstate_get_alias(ifstate, ifstate->af == AF_INET ? AF_INET6 : AF_INET); + if (alias == NULL) { + // if only one address family + return FALSE; + } else if ((alias->flags & NWI_IFSTATE_FLAGS_NOT_IN_LIST) != 0) { + // if scoped (i.e. not in list) + return TRUE; + } + + return FALSE; +} + static void log_service_entity(int level, CFStringRef serviceID, CFStringRef entity, CFStringRef operation, CFTypeRef val) @@ -3827,7 +3904,7 @@ log_service_entity(int level, CFStringRef serviceID, CFStringRef entity, if (val == NULL) { val = CFSTR(""); } - my_log(level, "IPMonitor: serviceID %@ %@ %@ value = %@", + my_log(level, "serviceID %@ %@ %@ value = %@", serviceID, operation, entity, val); my_CFRelease(&this_val); return; @@ -3880,6 +3957,9 @@ service_dict_get(CFStringRef serviceID, CFStringRef entity) { CFDictionaryRef service_dict; + if (S_service_state_dict == NULL) { + return (NULL); + } service_dict = CFDictionaryGetValue(S_service_state_dict, serviceID); if (service_dict == NULL) { return (NULL); @@ -3957,9 +4037,6 @@ ipv6_service_update_router(CFStringRef serviceID, CFDictionaryRef new_service) } s = inet6_dgram_socket(); if (s < 0) { - my_log(LOG_ERR, - "IPMonitor: ipv6_service_update_router: socket failed, %s", - strerror(errno)); goto done; } /* remove the old router if it was defined */ @@ -3967,19 +4044,16 @@ ipv6_service_update_router(CFStringRef serviceID, CFDictionaryRef new_service) && (new_router == NULL || !IN6_ARE_ADDR_EQUAL(old_router, new_router))) { if (siocdrdel_in6(s, ifindex, old_router) < 0) { - if (errno != EINVAL - || (S_IPMonitor_debug & kDebugFlag1) != 0) { - my_log((errno == EINVAL) ? LOG_DEBUG : LOG_ERR, - "IPMonitor: siocdrdel_in6(%@, %s) failed, %s", - ifname, - inet_ntop(AF_INET6, old_router, - ntopbuf, sizeof(ntopbuf)), - strerror(errno)); - } + my_log((errno == EINVAL) ? LOG_DEBUG : LOG_ERR, + "siocdrdel_in6(%@, %s) failed: %s", + ifname, + inet_ntop(AF_INET6, old_router, + ntopbuf, sizeof(ntopbuf)), + strerror(errno)); } - else if (S_IPMonitor_debug & kDebugFlag1) { - my_log(LOG_DEBUG, - "IPMonitor: %@ removed default route %s", + else { + my_log(LOG_INFO, + "%@ removed default route %s", ifname, inet_ntop(AF_INET6, old_router, ntopbuf, sizeof(ntopbuf))); } @@ -3989,19 +4063,16 @@ ipv6_service_update_router(CFStringRef serviceID, CFDictionaryRef new_service) && (old_router == NULL || !IN6_ARE_ADDR_EQUAL(old_router, new_router))) { if (siocdradd_in6(s, ifindex, new_router, 0) < 0) { - if (errno != EINVAL - || (S_IPMonitor_debug & kDebugFlag1) != 0) { - my_log((errno == EINVAL) ? LOG_DEBUG : LOG_ERR, - "IPMonitor: siocdradd_in6(%@, %s) failed, %s", - ifname, - inet_ntop(AF_INET6, new_router, - ntopbuf, sizeof(ntopbuf)), - strerror(errno)); - } + my_log((errno == EINVAL) ? LOG_DEBUG : LOG_ERR, + "siocdradd_in6(%@, %s) failed: %s", + ifname, + inet_ntop(AF_INET6, new_router, + ntopbuf, sizeof(ntopbuf)), + strerror(errno)); } - else if (S_IPMonitor_debug & kDebugFlag1) { - my_log(LOG_DEBUG, - "IPMonitor: %@ added default route %s", + else { + my_log(LOG_INFO, + "%@ added default route %s", ifname, inet_ntop(AF_INET6, new_router, ntopbuf, sizeof(ntopbuf))); } @@ -4394,12 +4465,10 @@ accumulate_dns_servers(CFArrayRef in_servers, ProtocolFlags active_protos, /* IPv4 address */ if ((active_protos & kProtocolFlagsIPv4) == 0 && ntohl(ip_addr.s_addr) != INADDR_LOOPBACK) { - if ((S_IPMonitor_debug & kDebugFlag1) != 0) { - my_log(LOG_DEBUG, - "IPMonitor: no IPv4 connectivity, " - "ignoring DNS server address " IP_FORMAT, - IP_LIST(&ip_addr)); - } + my_log(LOG_INFO, + "no IPv4 connectivity, " + "ignoring DNS server address " IP_FORMAT, + IP_LIST(&ip_addr)); continue; } @@ -4409,15 +4478,13 @@ accumulate_dns_servers(CFArrayRef in_servers, ProtocolFlags active_protos, /* IPv6 address */ if ((active_protos & kProtocolFlagsIPv6) == 0 && !IN6_IS_ADDR_LOOPBACK(&ipv6_addr)) { - if ((S_IPMonitor_debug & kDebugFlag1) != 0) { - char ntopbuf[INET6_ADDRSTRLEN]; - - my_log(LOG_DEBUG, - "IPMonitor: no IPv6 connectivity, " - "ignoring DNS server address %s", - inet_ntop(AF_INET6, &ipv6_addr, - ntopbuf, sizeof(ntopbuf))); - } + char ntopbuf[INET6_ADDRSTRLEN]; + + my_log(LOG_INFO, + "no IPv6 connectivity, " + "ignoring DNS server address %s", + inet_ntop(AF_INET6, &ipv6_addr, + ntopbuf, sizeof(ntopbuf))); continue; } @@ -4436,9 +4503,7 @@ accumulate_dns_servers(CFArrayRef in_servers, ProtocolFlags active_protos, } else { /* bad IP address */ - my_log(LOG_NOTICE, - "IPMonitor: ignoring bad DNS server address '%@'", - addr); + my_log(LOG_NOTICE, "ignoring bad DNS server address '%@'", addr); continue; } @@ -4454,6 +4519,7 @@ merge_dns_servers(CFMutableDictionaryRef new_dict, CFArrayRef state_servers, CFArrayRef setup_servers, Boolean have_setup, + Boolean trust_state, ProtocolFlags active_protos, CFStringRef interface) { @@ -4505,11 +4571,18 @@ merge_dns_servers(CFMutableDictionaryRef new_dict, * We also add an exception to the "follow the dynamically derived * network configuration" path for on-the-fly (no Setup: content) * network services. + * + * But, we add an exception to the exception to support our own + * VPN code. Here, we look for a "ServiceID" property in the DNS + * entity. If present, and if it matches, then we extend our + * trust even when there is no Setup: content. */ if (CFArrayGetCount(dns_servers) != 0) { CFDictionarySetValue(new_dict, kSCPropNetDNSServerAddresses, dns_servers); - if (have_setup && !have_dns_setup) { + if ((have_setup && !have_dns_setup) || (!have_setup && trust_state)) { + // if this is a "setup"+"state" service with only "state" DNS content (i.e. no + // setup override) or this is a TRUSTED "state"-only service CFDictionarySetValue(new_dict, DNS_CONFIGURATION_SCOPED_QUERY_KEY, kCFBooleanTrue); } } @@ -4551,6 +4624,7 @@ get_dns_changes(CFStringRef serviceID, CFDictionaryRef state_dict, kSCPropNetDNSServiceIdentifier, kSCPropNetDNSSupplementalMatchDomainsNoSearch, }; + Boolean trust_state = FALSE; if ((state_dict == NULL) && (setup_dict == NULL)) { /* there is no DNS content */ @@ -4589,6 +4663,18 @@ get_dns_changes(CFStringRef serviceID, CFDictionaryRef state_dict, setup_dict = NULL; } + if (state_dict != NULL) { + CFStringRef state_serviceID = NULL; + + if (CFDictionaryGetValueIfPresent(state_dict, + kSCPropNetDNSConfirmedServiceID, + (const void **)&state_serviceID) && + isA_CFString(state_serviceID) && + CFEqual(serviceID, state_serviceID)) { + trust_state = TRUE; + } + } + /* merge DNS configuration */ new_dict = CFDictionaryCreateMutable(NULL, 0, &kCFTypeDictionaryKeyCallBacks, @@ -4600,6 +4686,7 @@ get_dns_changes(CFStringRef serviceID, CFDictionaryRef state_dict, kSCPropNetDNSServerAddresses), NULL, FALSE, + trust_state, kProtocolFlagsIPv4 | kProtocolFlagsIPv6, NULL); } @@ -4610,6 +4697,7 @@ get_dns_changes(CFStringRef serviceID, CFDictionaryRef state_dict, my_CFDictionaryGetArray(setup_dict, kSCPropNetDNSServerAddresses), have_setup, + trust_state, active_protos, interface); } @@ -5132,6 +5220,22 @@ get_transient_status_changes(CFStringRef serviceID, return (changed); } +static boolean_t +if_dict_is_expensive(CFDictionaryRef if_dict) +{ + boolean_t is_expensive = FALSE; + + if (isA_CFDictionary(if_dict) != NULL) { + CFBooleanRef expensive; + expensive = CFDictionaryGetValue(if_dict, kSCPropNetLinkExpensive); + if (isA_CFBoolean(expensive) != NULL + && CFBooleanGetValue(expensive)) { + is_expensive = TRUE; + } + } + return is_expensive; +} + static boolean_t service_is_expensive(CFStringRef serviceID, CFDictionaryRef services_info) { @@ -5146,14 +5250,26 @@ service_is_expensive(CFStringRef serviceID, CFDictionaryRef services_info) key = interface_entity_key_copy(ifname, kSCEntNetLink); if_dict = CFDictionaryGetValue(services_info, key); CFRelease(key); - if (isA_CFDictionary(if_dict) != NULL) { - CFBooleanRef expensive; + is_expensive = if_dict_is_expensive(if_dict); + } + return (is_expensive); +} - expensive = CFDictionaryGetValue(if_dict, kSCPropNetLinkExpensive); - if (isA_CFBoolean(expensive) != NULL - && CFBooleanGetValue(expensive)) { - is_expensive = TRUE; - } +static boolean_t +interface_is_expensive(CFStringRef ifname) +{ + boolean_t is_expensive = FALSE; + + if (ifname != NULL) { + CFDictionaryRef if_dict; + CFStringRef key; + + key = interface_entity_key_copy(ifname, kSCEntNetLink); + if_dict = SCDynamicStoreCopyValue(S_session, key); + CFRelease(key); + if (if_dict != NULL) { + is_expensive = if_dict_is_expensive(if_dict); + CFRelease(if_dict); } } return (is_expensive); @@ -5231,11 +5347,11 @@ get_rank_changes(CFStringRef serviceID, CFDictionaryRef state_options, rank_assertion = InterfaceRankGetRankAssertion(if_rank, &rank_assertion_is_set); - if (S_IPMonitor_debug & kDebugFlag1) { - my_log(LOG_DEBUG, - "serviceID %@ interface %@ rank = %@", - serviceID, interface, if_rank); - } + my_log(LOG_INFO, + "serviceID %@ interface %@ rank = %@", + serviceID, + interface, + (if_rank != NULL) ? if_rank : (CFNumberRef)CFSTR("Not set)")); } } @@ -5425,22 +5541,19 @@ set_ipv6_default_interface(IFIndex ifindex) ndifreq.ifindex = lo0_ifindex(); } sock = inet6_dgram_socket(); - if (sock == -1) { + if (sock < 0) { + goto done; + } + if (ioctl(sock, SIOCSDEFIFACE_IN6, (caddr_t)&ndifreq) == -1) { my_log(LOG_ERR, - "IPMonitor: set_ipv6_default_interface: socket failed, %s", + "ioctl(SIOCSDEFIFACE_IN6) failed: %s", strerror(errno)); } else { - if (ioctl(sock, SIOCSDEFIFACE_IN6, (caddr_t)&ndifreq) == -1) { - my_log(LOG_ERR, - "IPMonitor: ioctl(SIOCSDEFIFACE_IN6) failed, %s", - strerror(errno)); - } - else { - success = TRUE; - } - close(sock); + success = TRUE; } + close(sock); +done: return (success); } @@ -5857,8 +5970,9 @@ update_nwi(nwi_state_t state) unsigned char signature[CC_SHA1_DIGEST_LENGTH]; static unsigned char signature_last[CC_SHA1_DIGEST_LENGTH]; - _nwi_state_signature(state, signature, sizeof(signature)); + _nwi_state_compute_sha1_hash(state, signature); if (bcmp(signature, signature_last, sizeof(signature)) == 0) { + my_log(LOG_DEBUG, "Not updating network information"); return FALSE; } @@ -5866,10 +5980,9 @@ update_nwi(nwi_state_t state) bcopy(signature, signature_last, sizeof(signature)); // save [new] configuration - if ((S_IPMonitor_debug & kDebugFlag1) != 0) { - my_log(LOG_DEBUG, "Updating network information"); - S_nwi_state_dump(state); - } + my_log(LOG_INFO, "Updating network information"); + S_nwi_state_dump(state); + if (_nwi_state_store(state) == FALSE) { my_log(LOG_ERR, "Notifying nwi_state_store failed"); } @@ -5951,7 +6064,7 @@ update_smb(CFDictionaryRef services_info, #endif /* !TARGET_OS_IPHONE */ static Rank -get_service_rank(CFArrayRef order, int n_order, CFStringRef serviceID) +get_service_rank(CFArrayRef order, CFIndex n_order, CFStringRef serviceID) { CFIndex i; Rank rank = kRankIndexMask; @@ -6365,7 +6478,7 @@ typedef struct ElectionInfo { CFStringRef entity; int n_services; CFArrayRef order; - int n_order; + CFIndex n_order; ElectionResultsRef results; CFMutableDictionaryRef rank_dict; } ElectionInfo, * ElectionInfoRef; @@ -6441,8 +6554,9 @@ ElectionResultsLog(int level, ElectionResultsRef results, const char * prefix) char ntopbuf[INET6_ADDRSTRLEN]; (void)inet_ntop(results->af, &scan->addr, ntopbuf, sizeof(ntopbuf)); - my_log(level, "%d. %@ serviceID=%@ addr=%s rank=0x%x", - i, scan->if_name, scan->serviceID, ntopbuf, scan->rank); + my_log(level, "%d. %@ serviceID=%@ addr=%s rank=0x%x%s", + i, scan->if_name, scan->serviceID, ntopbuf, scan->rank, + scan->ineligible ? " [ineligible]" : ""); } return; } @@ -6501,7 +6615,7 @@ elect_ip(const void * key, const void * value, void * context); * function. Return the results of the election. */ static ElectionResultsRef -ElectionResultsCopy(int af, CFArrayRef order, int n_order) +ElectionResultsCopy(int af, CFArrayRef order) { int count; ElectionInfo info; @@ -6522,7 +6636,12 @@ ElectionResultsCopy(int af, CFArrayRef order, int n_order) info.results = ElectionResultsAlloc(af, count); info.n_services = count; info.order = order; - info.n_order = n_order; + if (order != NULL) { + info.n_order = CFArrayGetCount(order); + } + else { + info.order = 0; + } CFDictionaryApplyFunction(S_service_state_dict, elect_ip, (void *)&info); if (info.results->count == 0) { ElectionResultsRelease(info.results); @@ -6601,7 +6720,8 @@ get_signature_sha1(CFStringRef signature, static void add_candidate_to_nwi_state(nwi_state_t nwi_state, int af, - CandidateRef candidate, Rank rank) + CandidateRef candidate, Boolean not_in_list, + Boolean not_in_iflist) { uint64_t flags = 0; char ifname[IFNAMSIZ]; @@ -6611,9 +6731,13 @@ add_candidate_to_nwi_state(nwi_state_t nwi_state, int af, /* can't happen */ return; } - if (RANK_ASSERTION_MASK(rank) == kRankAssertionNever) { + if (not_in_list + || RANK_ASSERTION_MASK(candidate->rank) == kRankAssertionNever) { flags |= NWI_IFSTATE_FLAGS_NOT_IN_LIST; } + if (not_in_iflist) { + flags |= NWI_IFSTATE_FLAGS_NOT_IN_IFLIST; + } if (service_dict_get(candidate->serviceID, kSCEntNetDNS) != NULL) { flags |= NWI_IFSTATE_FLAGS_HAS_DNS; } @@ -6624,15 +6748,16 @@ add_candidate_to_nwi_state(nwi_state_t nwi_state, int af, (void)inet_ntop(af, &candidate->addr, ntopbuf, sizeof(ntopbuf)); my_log(LOG_DEBUG, - "Inserting IPv%c [%s] %s " + "Adding IPv%c [%s] %s " "with flags 0x%llx rank 0x%x reach_flags 0x%x", ipvx_char(af), ifname, ntopbuf, - flags, rank, candidate->reachability_flags); + flags, candidate->rank, candidate->reachability_flags); } - ifstate = nwi_insert_ifstate(nwi_state, ifname, af, flags, rank, - (void *)&candidate->addr, - (void *)&candidate->vpn_server_addr, - candidate->reachability_flags); + ifstate = nwi_state_add_ifstate(nwi_state, ifname, af, flags, + candidate->rank, + (void *)&candidate->addr, + (void *)&candidate->vpn_server_addr, + candidate->reachability_flags); if (ifstate != NULL && candidate->signature) { uint8_t hash[CC_SHA1_DIGEST_LENGTH]; @@ -6693,9 +6818,6 @@ ElectionResultsCopyPrimary(ElectionResultsRef results, Boolean primary_is_null = FALSE; RouteListRef routes = NULL; - if (nwi_state != NULL) { - nwi_state_clear(nwi_state, af); - } if (results != NULL) { CandidateRef deferred[results->count]; int deferred_count; @@ -6723,20 +6845,19 @@ ElectionResultsCopyPrimary(ElectionResultsRef results, i < results->count; i++, scan++) { Boolean is_primary = FALSE; - Rank rank = scan->rank; CFDictionaryRef service_dict; RouteListRef service_routes; Boolean skip = FALSE; - if (primary == NULL - && RANK_ASSERTION_MASK(rank) != kRankAssertionNever) { + if (scan->ineligible == FALSE + && primary == NULL + && RANK_ASSERTION_MASK(scan->rank) != kRankAssertionNever) { if (ElectionResultsCandidateNeedsDemotion(other_results, scan)) { - /* demote to RankNever */ + /* demote the service */ my_log(LOG_NOTICE, "IPv%c over %@ demoted: not primary for IPv%c", ipvx_char(af), scan->if_name, ipvx_other_char(af)); - rank = RankMake(rank, kRankAssertionNever); deferred[deferred_count++] = scan; skip = TRUE; } @@ -6749,6 +6870,12 @@ ElectionResultsCopyPrimary(ElectionResultsRef results, service_dict = service_dict_get(scan->serviceID, entity_name); service_routes = ipdict_get_routelist(service_dict); if (service_routes != NULL) { + Rank rank = scan->rank; + + if (skip) { + /* routes are RankNever to prevent becoming primary */ + rank = RankMake(rank, kRankAssertionNever); + } routes = RouteListAddRouteList(info, routes, initial_size, service_routes, rank); if ((service_routes->flags & kRouteListFlagsExcludeNWI) != 0) { @@ -6764,28 +6891,24 @@ ElectionResultsCopyPrimary(ElectionResultsRef results, primary_is_null = TRUE; } } - else { - if (primary_is_null) { - /* everything after the primary must be Never */ - rank = RankMake(rank, kRankAssertionNever); - } + else if (scan->ineligible == FALSE) { + Boolean not_in_iflist; + add_reachability_flags_to_candidate(scan, services_info, af); - add_candidate_to_nwi_state(nwi_state, af, scan, rank); + not_in_iflist + = (service_routes->flags & kRouteListFlagsScopedOnly) != 0; + add_candidate_to_nwi_state(nwi_state, af, scan, + primary_is_null, + not_in_iflist); } } for (i = 0; i < deferred_count; i++) { CandidateRef candidate = deferred[i]; - Rank rank; - /* demote to RankNever */ - rank = RankMake(candidate->rank, kRankAssertionNever); add_reachability_flags_to_candidate(candidate, services_info, af); - add_candidate_to_nwi_state(nwi_state, af, candidate, rank); + add_candidate_to_nwi_state(nwi_state, af, candidate, TRUE, FALSE); } } - if (nwi_state != NULL) { - nwi_state_set_last(nwi_state, af); - } if (ret_routes != NULL) { *ret_routes = routes; } @@ -6845,10 +6968,6 @@ elect_ip(const void * key, const void * value, void * context) /* no connectivity */ return; } - if ((routelist.common->flags & kRouteListFlagsHasDefault) == 0) { - /* no default route, not a candidate for being primary */ - return; - } if_name = CFDictionaryGetValue(service_dict, kSCPropInterfaceName); if (if_name == NULL) { /* need an interface name */ @@ -6860,6 +6979,10 @@ elect_ip(const void * key, const void * value, void * context) } bzero(&candidate, sizeof(candidate)); candidate.serviceID = (CFStringRef)key; + if ((routelist.common->flags & kRouteListFlagsHasDefault) == 0) { + /* no default route means it's ineligible to become primary */ + candidate.ineligible = TRUE; + } candidate.rank = get_service_rank(elect_info->order, elect_info->n_order, candidate.serviceID); if (elect_info->af == AF_INET) { @@ -6927,6 +7050,31 @@ service_changed(CFDictionaryRef services_info, CFStringRef serviceID) return (changed); } +static CFStringRef +serviceID_get_ifname(CFStringRef serviceID) +{ + CFDictionaryRef entity_dict; + CFStringRef ifname = NULL; + + entity_dict = service_dict_get(serviceID, kSCEntNetIPv4); + if (entity_dict == NULL) { + entity_dict = service_dict_get(serviceID, kSCEntNetIPv6); + } + if (entity_dict != NULL) { + ifname = ipdict_get_ifname(entity_dict); + } + return (ifname); +} + +__private_extern__ boolean_t +check_if_service_expensive(CFStringRef serviceID) +{ + CFStringRef ifname; + ifname = serviceID_get_ifname(serviceID); + + return interface_is_expensive(ifname); +} + static CFArrayRef service_order_get(CFDictionaryRef services_info) { @@ -6966,29 +7114,17 @@ set_new_primary(CFStringRef * primary_p, CFStringRef new_primary, if (new_primary != NULL) { if (primary != NULL && CFEqual(new_primary, primary)) { - if ((S_IPMonitor_debug & kDebugFlag1) != 0) { - my_log(LOG_DEBUG, - "IPMonitor: %@ is still primary %s", - new_primary, entity); - } + my_log(LOG_INFO, "%@ is still primary %s", new_primary, entity); } else { my_CFRelease(primary_p); *primary_p = CFRetain(new_primary); - if ((S_IPMonitor_debug & kDebugFlag1) != 0) { - my_log(LOG_DEBUG, - "IPMonitor: %@ is the new primary %s", - new_primary, entity); - } + my_log(LOG_INFO, "%@ is the new primary %s", new_primary, entity); changed = TRUE; } } else if (primary != NULL) { - if ((S_IPMonitor_debug & kDebugFlag1) != 0) { - my_log(LOG_DEBUG, - "IPMonitor: %@ is no longer primary %s", - primary, entity); - } + my_log(LOG_INFO, "%@ is no longer primary %s", primary, entity); my_CFRelease(primary_p); changed = TRUE; } @@ -7046,11 +7182,9 @@ append_serviceIDs_for_interface(CFMutableArrayRef services_changed, } interface = ipdict_get_ifname(ipdict); if (interface != NULL && CFEqual(interface, ifname)) { - if (S_IPMonitor_debug & kDebugFlag1) { - my_log(LOG_DEBUG, - "Found IP service %@ on interface %@.", - serviceID, ifname); - } + my_log(LOG_DEBUG, + "Found IP service %@ on interface %@", + serviceID, ifname); my_CFArrayAppendUniqueValue(services_changed, serviceID); } } @@ -7084,30 +7218,154 @@ get_changed_str(CFStringRef serviceID, CFStringRef entity, return ""; } -static CF_RETURNS_RETAINED CFStringRef -generate_log_changes(nwi_state_t changes_state, - boolean_t dns_changed, - boolean_t dnsinfo_changed, - CFDictionaryRef old_primary_dns, - boolean_t proxy_changed, - CFDictionaryRef old_primary_proxy, - boolean_t smb_changed, - CFDictionaryRef old_primary_smb - ) +#if ! TARGET_IPHONE_SIMULATOR + +#ifdef SIOCSIFNETSIGNATURE +#define MANAGE_IF_SIGNATURE + +static int +inet_dgram_socket(void) { - int idx; - CFMutableStringRef log_output; - nwi_ifstate_t scan; + int sockfd; - log_output = CFStringCreateMutable(NULL, 0); + sockfd = socket(AF_INET, SOCK_DGRAM, 0); + if (sockfd == -1) { + my_log(LOG_ERR, "socket() failed: %s", strerror(errno)); + } - if (changes_state != NULL) { - for (idx = 0; idx < countof(nwi_af_list); idx++) { - CFMutableStringRef changes = NULL; - CFMutableStringRef primary_str = NULL; + return sockfd; +} + +static int +siocsifnetsignature(int s, const char * ifname, int af, + const uint8_t * signature, int signature_length) +{ + struct if_nsreq nsreq; + + bzero(&nsreq, sizeof(nsreq)); + strlcpy(nsreq.ifnsr_name, ifname, sizeof(nsreq.ifnsr_name)); + nsreq.ifnsr_family = af; + if (signature_length > 0) { + if (signature_length > sizeof(nsreq.ifnsr_data)) { + signature_length = sizeof(nsreq.ifnsr_data); + } + nsreq.ifnsr_len = signature_length; + memcpy(nsreq.ifnsr_data, signature, signature_length); + } + return (ioctl(s, SIOCSIFNETSIGNATURE, &nsreq)); +} - scan = nwi_state_get_first_ifstate(changes_state, nwi_af_list[idx]); +static void +process_ifstate_difference(nwi_ifstate_t ifstate, int af, int sockfd) +{ + nwi_ifstate_difference_t diff; + boolean_t set_signature = FALSE; + int signature_length = 0; + diff = nwi_ifstate_get_difference(ifstate); + switch (diff) { + case knwi_ifstate_difference_changed: + /* set signature for this interface */ + set_signature = TRUE; + if ((ifstate->flags & NWI_IFSTATE_FLAGS_HAS_SIGNATURE) != 0) { + signature_length = sizeof(ifstate->signature); + } + break; + case knwi_ifstate_difference_removed: + /* remove signature for this interface */ + set_signature = TRUE; + break; + default: + break; + } + if (set_signature) { + if (siocsifnetsignature(sockfd, ifstate->ifname, af, + ifstate->signature, + signature_length) < 0) { + my_log(LOG_ERR, + "siocsifnetsignature(%s, IPv%c, %d) failed: %s", + ifstate->ifname, ipvx_char(af), + signature_length, + strerror(errno)); + } + else { + my_log(LOG_DEBUG, "IPv%c Network Signature %s %s", + ipvx_char(af), + (signature_length > 0) ? "Set" : "Cleared", + ifstate->ifname); + if (signature_length > 0 + && (S_IPMonitor_debug & kDebugFlag1) != 0) { + int i; + char sig_buf[signature_length * 3 + 1]; + + sig_buf[0] = '\0'; + for (i = 0; i < signature_length; i++) { + char byte_buf[4]; + + snprintf(byte_buf, sizeof(byte_buf), + "%02x ", ifstate->signature[i]); + strlcat(sig_buf, byte_buf, sizeof(sig_buf)); + } + my_log(LOG_DEBUG, "Signature Bytes: %s", sig_buf); + } + } + } + return; +} + +static void +process_state_differences(nwi_state_t state, int af, int sockfd) +{ + int count; + int i; + nwi_ifstate_t scan; + + if (af == AF_INET) { + count = state->ipv4_count; + } + else { + count = state->ipv6_count; + } + for (i = 0, scan = nwi_state_ifstate_list(state, af); + i < count; i++, scan++) { + process_ifstate_difference(scan, af, sockfd); + } + return; +} + +#endif /* SIOCSIFNETSIGNATURE */ + +#endif /* !TARGET_IPHONE_SIMULATOR */ + +static void +process_nwi_changes(CFMutableStringRef log_output, + nwi_state_t changes_state, + boolean_t dns_changed, + boolean_t dnsinfo_changed, + CFDictionaryRef old_primary_dns, + boolean_t proxy_changed, + CFDictionaryRef old_primary_proxy, + boolean_t smb_changed, + CFDictionaryRef old_primary_smb) +{ + int idx; + + if (changes_state != NULL) { + const sa_family_t af_list[] = {AF_INET, AF_INET6}; + nwi_ifstate_t scan; +#ifdef MANAGE_IF_SIGNATURE + int sockfd = inet_dgram_socket(); +#endif /* MANAGE_IF_SIGNATURE */ + + for (idx = 0; idx < countof(af_list); idx++) { + int af = af_list[idx]; + CFMutableStringRef changes = NULL; + CFMutableStringRef primary_str = NULL; + +#ifdef MANAGE_IF_SIGNATURE + process_state_differences(changes_state, af, sockfd); +#endif /* MANAGE_IF_SIGNATURE */ + scan = nwi_state_get_first_ifstate(changes_state, af); while (scan != NULL) { const char * changed_str; @@ -7120,7 +7378,7 @@ generate_log_changes(nwi_state_t changes_state, address = (void *)nwi_ifstate_get_address(scan); addr_str = inet_ntop(scan->af, address, ntopbuf, sizeof(ntopbuf)); - if (primary_str == NULL) { + if (primary_str == NULL) { primary_str = CFStringCreateMutable(NULL, 0); CFStringAppendFormat(primary_str, NULL, CFSTR("%s%s:%s"), @@ -7132,7 +7390,7 @@ generate_log_changes(nwi_state_t changes_state, } CFStringAppendFormat(changes, NULL, CFSTR(", %s"), nwi_ifstate_get_ifname(scan)); - if (strcmp(changed_str, "") != 0) { + if (strcmp(changed_str, "") != 0) { CFStringAppendFormat(changes, NULL, CFSTR("%s:%s"), changed_str, addr_str); } @@ -7143,7 +7401,7 @@ generate_log_changes(nwi_state_t changes_state, if (primary_str != NULL) { CFStringAppendFormat(log_output, NULL, CFSTR(" %s(%@"), - nwi_af_list[idx] == AF_INET ? "v4" : "v6", + af == AF_INET ? "v4" : "v6", primary_str); if (changes != NULL && CFStringGetLength(changes) != 0) { @@ -7156,6 +7414,11 @@ generate_log_changes(nwi_state_t changes_state, my_CFRelease(&changes); } } +#ifdef MANAGE_IF_SIGNATURE + if (sockfd >= 0) { + close(sockfd); + } +#endif /* MANAGE_IF_SIGNATURE */ } if (dns_changed || dnsinfo_changed) { @@ -7190,7 +7453,7 @@ generate_log_changes(nwi_state_t changes_state, } #endif // !TARGET_OS_IPHONE - return log_output; + return; } #pragma mark - @@ -7223,13 +7486,10 @@ post_network_change_when_ready() (!S_dnsinfo_synced || !S_nwi_synced)) { // if we [still] need to wait for the DNS configuration // or network information changes to be ack'd - - if ((S_IPMonitor_debug & kDebugFlag1) != 0) { - my_log(LOG_DEBUG, - "Defer \"" _SC_NOTIFY_NETWORK_CHANGE "\" (%s, %s)", - S_dnsinfo_synced ? "DNS" : "!DNS", - S_nwi_synced ? "nwi" : "!nwi"); - } + my_log(LOG_DEBUG, + "Defer \"" _SC_NOTIFY_NETWORK_CHANGE "\" (%s, %s)", + S_dnsinfo_synced ? "DNS" : "!DNS", + S_nwi_synced ? "nwi" : "!nwi"); return; } @@ -7242,7 +7502,7 @@ post_network_change_when_ready() } // set (and log?) the post time - if ((S_IPMonitor_debug & kDebugFlag1) != 0) { + { struct timeval elapsed; struct timeval end; @@ -7252,7 +7512,7 @@ post_network_change_when_ready() #define QUERY_TIME__FMT "%ld.%6.6d" #define QUERY_TIME__DIV 1 - my_log(LOG_DEBUG, + my_log(LOG_INFO, "Post \"" _SC_NOTIFY_NETWORK_CHANGE "\" (%s: " QUERY_TIME__FMT ": 0x%x)", S_network_change_timeout ? "timeout" : "delayed", elapsed.tv_sec, @@ -7264,7 +7524,7 @@ post_network_change_when_ready() status = notify_post(_SC_NOTIFY_NETWORK_CHANGE_NWI); if (status != NOTIFY_STATUS_OK) { my_log(LOG_ERR, - "IPMonitor: notify_post(" _SC_NOTIFY_NETWORK_CHANGE_NWI ") failed: error=%d", status); + "notify_post(" _SC_NOTIFY_NETWORK_CHANGE_NWI ") failed: error=%d", status); } } @@ -7272,7 +7532,7 @@ post_network_change_when_ready() status = notify_post(_SC_NOTIFY_NETWORK_CHANGE_DNS); if (status != NOTIFY_STATUS_OK) { my_log(LOG_ERR, - "IPMonitor: notify_post(" _SC_NOTIFY_NETWORK_CHANGE_DNS ") failed: error=%d", status); + "notify_post(" _SC_NOTIFY_NETWORK_CHANGE_DNS ") failed: error=%d", status); } } @@ -7280,14 +7540,14 @@ post_network_change_when_ready() status = notify_post(_SC_NOTIFY_NETWORK_CHANGE_PROXY); if (status != NOTIFY_STATUS_OK) { my_log(LOG_ERR, - "IPMonitor: notify_post(" _SC_NOTIFY_NETWORK_CHANGE_PROXY ") failed: error=%d", status); + "notify_post(" _SC_NOTIFY_NETWORK_CHANGE_PROXY ") failed: error=%d", status); } } status = notify_post(_SC_NOTIFY_NETWORK_CHANGE); if (status != NOTIFY_STATUS_OK) { my_log(LOG_ERR, - "IPMonitor: notify_post(" _SC_NOTIFY_NETWORK_CHANGE ") failed: error=%d", status); + "notify_post(" _SC_NOTIFY_NETWORK_CHANGE ") failed: error=%d", status); } S_network_change_needed = 0; @@ -7323,8 +7583,15 @@ post_network_change(uint32_t change) 0, __network_change_queue()); dispatch_source_set_event_handler(S_network_change_timer, ^{ + os_activity_t activity_id; + + activity_id = os_activity_start("posting delayed network change", + OS_ACTIVITY_FLAG_DEFAULT); + S_network_change_timeout = TRUE; post_network_change_when_ready(); + + os_activity_end(activity_id); }); dispatch_source_set_timer(S_network_change_timer, dispatch_time(DISPATCH_TIME_NOW, @@ -7356,9 +7623,8 @@ IPMonitorProcessChanges(SCDynamicStoreRef session, CFArrayRef changed_keys, CFIndex i; keyChangeList keys; CFIndex n; - CFStringRef network_change_msg = NULL; + CFMutableStringRef network_change_msg = NULL; int n_services; - int n_service_order = 0; nwi_state_t old_nwi_state = NULL; CFDictionaryRef old_primary_dns = NULL; CFDictionaryRef old_primary_proxy = NULL; @@ -7381,7 +7647,7 @@ IPMonitorProcessChanges(SCDynamicStoreRef session, CFArrayRef changed_keys, count = CFArrayGetCount(changed_keys); if ((S_IPMonitor_debug & kDebugFlag1) != 0) { my_log(LOG_DEBUG, - "IPMonitor: changed keys %@ (%ld)", changed_keys, count); + "changed keys %@ (%ld)", changed_keys, count); } } if (if_rank_changes == NULL && count == 0) { @@ -7472,9 +7738,8 @@ IPMonitorProcessChanges(SCDynamicStoreRef session, CFArrayRef changed_keys, for (i = 0; i < n; i++) { CFStringRef ifname = CFArrayGetValueAtIndex(if_rank_changes, i); - if (S_IPMonitor_debug & kDebugFlag1) { - my_log(LOG_DEBUG, "Interface rank changed %@", - ifname); + if ((S_IPMonitor_debug & kDebugFlag1) != 0) { + my_log(LOG_DEBUG, "Interface rank changed %@", ifname); } append_serviceIDs_for_interface(service_changes, ifname); } @@ -7484,10 +7749,8 @@ IPMonitorProcessChanges(SCDynamicStoreRef session, CFArrayRef changed_keys, services_info = services_info_copy(session, service_changes); service_order = service_order_get(services_info); if (service_order != NULL) { - n_service_order = (int)CFArrayGetCount(service_order); if ((S_IPMonitor_debug & kDebugFlag1) != 0) { - my_log(LOG_DEBUG, - "IPMonitor: service_order %@ ", service_order); + my_log(LOG_DEBUG, "service_order %@ ", service_order); } } @@ -7540,7 +7803,7 @@ IPMonitorProcessChanges(SCDynamicStoreRef session, CFArrayRef changed_keys, /* ensure S_nwi_state can hold as many services as we have currently */ n_services = (int)CFDictionaryGetCount(S_service_state_dict); - old_nwi_state = nwi_state_copy_priv(S_nwi_state); + old_nwi_state = nwi_state_make_copy(S_nwi_state); S_nwi_state = nwi_state_new(S_nwi_state, n_services); if (global_ipv4_changed) { @@ -7548,30 +7811,33 @@ IPMonitorProcessChanges(SCDynamicStoreRef session, CFArrayRef changed_keys, ElectionResultsRelease(S_ipv4_results); } S_ipv4_results - = ElectionResultsCopy(AF_INET, service_order, n_service_order); - if ((S_IPMonitor_debug & kDebugFlag1) != 0) { - ElectionResultsLog(LOG_DEBUG, S_ipv4_results, "IPv4"); - } + = ElectionResultsCopy(AF_INET, service_order); + ElectionResultsLog(LOG_INFO, S_ipv4_results, "IPv4"); } if (global_ipv6_changed) { if (S_ipv6_results != NULL) { ElectionResultsRelease(S_ipv6_results); } S_ipv6_results - = ElectionResultsCopy(AF_INET6, service_order, n_service_order); - if ((S_IPMonitor_debug & kDebugFlag1) != 0) { - ElectionResultsLog(LOG_DEBUG, S_ipv6_results, "IPv6"); - } + = ElectionResultsCopy(AF_INET6, service_order); + ElectionResultsLog(LOG_INFO, S_ipv6_results, "IPv6"); } if (global_ipv4_changed || global_ipv6_changed || dnsinfo_changed) { - CFStringRef new_primary; - RouteListUnion new_routelist; + CFStringRef new_primary; + CFStringRef new_primary_dns = NULL; + CFStringRef new_primary_proxies = NULL; +#if !TARGET_OS_IPHONE + CFStringRef new_primary_smb = NULL; +#endif /* !TARGET_OS_IPHONE */ + RouteListUnion new_routelist; - /* IPv4 */ - if ((S_IPMonitor_debug & kDebugFlag1) != 0) { - my_log(LOG_DEBUG, - "IPMonitor: electing IPv4 primary"); + if (S_nwi_state != NULL) { + nwi_state_clear(S_nwi_state, AF_INET); + nwi_state_clear(S_nwi_state, AF_INET6); } + + /* IPv4 */ + my_log(LOG_DEBUG, "electing IPv4 primary"); new_routelist.ptr = NULL; new_primary = ElectionResultsCopyPrimary(S_ipv4_results, S_ipv6_results, @@ -7583,10 +7849,7 @@ IPMonitorProcessChanges(SCDynamicStoreRef session, CFArrayRef changed_keys, my_CFRelease(&new_primary); /* IPv6 */ - if ((S_IPMonitor_debug & kDebugFlag1) != 0) { - my_log(LOG_DEBUG, - "IPMonitor: electing IPv6 primary"); - } + my_log(LOG_DEBUG, "electing IPv6 primary"); new_routelist.ptr = NULL; new_primary = ElectionResultsCopyPrimary(S_ipv6_results, S_ipv4_results, @@ -7596,14 +7859,8 @@ IPMonitorProcessChanges(SCDynamicStoreRef session, CFArrayRef changed_keys, (void)set_new_primary(&S_primary_ipv6, new_primary, "IPv6"); update_ipv6(S_primary_ipv6, new_routelist.v6, &keys); my_CFRelease(&new_primary); - } - if (global_ipv4_changed || global_ipv6_changed) { - CFStringRef new_primary_dns = NULL; - CFStringRef new_primary_proxies = NULL; -#if !TARGET_OS_IPHONE - CFStringRef new_primary_smb = NULL; -#endif /* !TARGET_OS_IPHONE */ + nwi_state_finalize(S_nwi_state); if (S_primary_ipv4 != NULL && S_primary_ipv6 != NULL) { /* decide between IPv4 and IPv6 */ @@ -7747,21 +8004,22 @@ IPMonitorProcessChanges(SCDynamicStoreRef session, CFArrayRef changed_keys, my_CFRelease(&services_info); if (changes != 0) { - network_change_msg = - generate_log_changes(changes_state, - dns_changed, - dnsinfo_changed, - old_primary_dns, - proxies_changed, - old_primary_proxy, + network_change_msg = CFStringCreateMutable(NULL, 0); + process_nwi_changes(network_change_msg, + changes_state, + dns_changed, + dnsinfo_changed, + old_primary_dns, + proxies_changed, + old_primary_proxy, #if !TARGET_OS_IPHONE - smb_changed, - old_primary_smb + smb_changed, + old_primary_smb #else // !TARGET_OS_IPHONE - FALSE, // smb_changed - NULL // old_primary_smb + FALSE, // smb_changed + NULL // old_primary_smb #endif // !TARGET_OS_IPHONE - ); + ); } keyChangeListApplyToStore(&keys, session); @@ -7781,18 +8039,18 @@ IPMonitorProcessChanges(SCDynamicStoreRef session, CFArrayRef changed_keys, && (CFStringGetLength(network_change_msg) != 0)) { my_log(LOG_NOTICE, "network changed:%@", network_change_msg); } else if (keyChangeListActive(&keys)) { - my_log(LOG_NOTICE, "network changed."); + my_log(LOG_NOTICE, "network changed"); } else { - my_log(LOG_DEBUG, "network event w/no changes"); + my_log(LOG_INFO, "network event w/no changes"); } my_CFRelease(&network_change_msg); if (changes_state != NULL) { - nwi_state_release(changes_state); + nwi_state_free(changes_state); } if (old_nwi_state != NULL) { - nwi_state_release(old_nwi_state); + nwi_state_free(old_nwi_state); } keyChangeListFree(&keys); @@ -7827,7 +8085,7 @@ watch_proxies() ^{ SCDynamicStoreNotifyValue(NULL, S_state_global_proxies); notify_post(_SC_NOTIFY_NETWORK_CHANGE_PROXY); - my_log(LOG_DEBUG, "IPMonitor: Notifying:\n%@", + my_log(LOG_INFO, "Notifying:\n%@", S_state_global_proxies); }); return; @@ -7848,9 +8106,9 @@ prefs_changed(__unused SCPreferencesRef prefs) S_IPMonitor_debug = kDebugFlagDefault; S_IPMonitor_verbose = TRUE; SCLoggerSetFlags(S_IPMonitor_logger, kSCLoggerFlagsFile | kSCLoggerFlagsDefault); - my_log(LOG_DEBUG, "IPMonitor: Setting logging verbose mode on."); + my_log(LOG_DEBUG, "Setting logging verbose mode on"); } else { - my_log(LOG_DEBUG, "IPMonitor: Setting logging verbose mode off."); + my_log(LOG_DEBUG, "Setting logging verbose mode off"); S_IPMonitor_debug = 0; S_IPMonitor_verbose = FALSE; SCLoggerSetFlags(S_IPMonitor_logger, kSCLoggerFlagsDefault); @@ -7862,9 +8120,6 @@ prefs_changed(__unused SCPreferencesRef prefs) static void my_log_init() { - if (S_IPMonitor_logger != NULL) { - return; - } S_IPMonitor_logger = SCLoggerCreate(LOGGER_ID); return; @@ -7918,26 +8173,26 @@ flush_routes(int s) addr = ntohl(sin->sin_addr.s_addr); if (IN_LOOPBACK(addr)) { my_log(LOG_DEBUG, - "IPMonitor: flush_routes: ignoring loopback route"); + "flush_routes: ignoring loopback route"); continue; } if (IN_LOCAL_GROUP(addr)) { my_log(LOG_DEBUG, - "IPMonitor: flush_routes: ignoring multicast route"); + "flush_routes: ignoring multicast route"); continue; } rtm->rtm_type = RTM_DELETE; rtm->rtm_seq = ++rtm_seq; if (write(s, rtm, rtm->rtm_msglen) < 0) { - my_log(LOG_DEBUG, - "IPMonitor: flush_routes: removing route for " - IP_FORMAT " failed, %s", + my_log(LOG_NOTICE, + "flush_routes: removing route for " + IP_FORMAT " failed: %s", IP_LIST(&sin->sin_addr), strerror(errno)); } else { my_log(LOG_DEBUG, - "IPMonitor: flush_routes: removed route for " IP_FORMAT, + "flush_routes: removed route for " IP_FORMAT, IP_LIST(&sin->sin_addr)); } } @@ -8091,17 +8346,15 @@ ip_plugin_init() if (!SCDynamicStoreSetNotificationKeys(S_session, keys, patterns)) { my_log(LOG_ERR, - "IPMonitor ip_plugin_init " - "SCDynamicStoreSetNotificationKeys failed: %s", - SCErrorString(SCError())); + "SCDynamicStoreSetNotificationKeys() failed: %s", + SCErrorString(SCError())); goto done; } rls = SCDynamicStoreCreateRunLoopSource(NULL, S_session, 0); if (rls == NULL) { my_log(LOG_ERR, - "IPMonitor ip_plugin_init " - "SCDynamicStoreCreateRunLoopSource failed: %s", + "SCDynamicStoreCreateRunLoopSource() failed: %s", SCErrorString(SCError())); goto done; } @@ -8158,9 +8411,13 @@ S_get_plist_boolean(CFDictionaryRef plist, CFStringRef key, static void InterfaceRankChanged(void * info) { + os_activity_t activity_id; CFDictionaryRef assertions = NULL; CFArrayRef changes; + activity_id = os_activity_start("processing IPMonitor [rank] change", + OS_ACTIVITY_FLAG_DEFAULT); + changes = IPMonitorControlServerCopyInterfaceRankInformation(&assertions); if (S_if_rank_dict != NULL) { CFRelease(S_if_rank_dict); @@ -8170,6 +8427,9 @@ InterfaceRankChanged(void * info) IPMonitorProcessChanges(S_session, NULL, changes); CFRelease(changes); } + + os_activity_end(activity_id); + return; } @@ -8212,7 +8472,7 @@ load_IPMonitor(CFBundleRef bundle, Boolean bundleVerbose) } if (bundleVerbose) { S_IPMonitor_debug = kDebugFlagDefault; - S_bundle_logging_verbose = bundleVerbose; + S_bundle_logging_verbose = TRUE; S_IPMonitor_verbose = TRUE; } @@ -8222,17 +8482,15 @@ load_IPMonitor(CFBundleRef bundle, Boolean bundleVerbose) IPMonitorControlPrefsInit(CFRunLoopGetCurrent(), prefs_changed); prefs_changed(NULL); - load_DNSConfiguration(bundle, // bundle S_IPMonitor_logger, // SCLogger - &S_bundle_logging_verbose, // bundleVerbose ^(Boolean inSync) { // syncHandler dispatch_async(__network_change_queue(), ^{ S_dnsinfo_synced = inSync; if (inSync && ((S_network_change_needed & NETWORK_CHANGE_DNS) == 0)) { - // all of the mDNSResponder ack's should result + // all of the DNS service ack's should result // in a [new] network change being posted post_network_change(NETWORK_CHANGE_DNS); } else { @@ -8243,7 +8501,6 @@ load_IPMonitor(CFBundleRef bundle, Boolean bundleVerbose) load_NetworkInformation(bundle, // bundle S_IPMonitor_logger, // SCLogger - &S_bundle_logging_verbose, // bundleVerbose ^(Boolean inSync) { // syncHandler dispatch_async(__network_change_queue(), ^{ S_nwi_synced = inSync; @@ -8267,11 +8524,11 @@ load_IPMonitor(CFBundleRef bundle, Boolean bundleVerbose) #endif /* !TARGET_OS_IPHONE */ #if !TARGET_IPHONE_SIMULATOR - load_hostname((S_IPMonitor_debug & kDebugFlag1) != 0); + load_hostname(TRUE); #endif /* !TARGET_IPHONE_SIMULATOR */ #if !TARGET_OS_IPHONE - load_smb_configuration((S_IPMonitor_debug & kDebugFlag1) != 0); + load_smb_configuration(TRUE); #endif /* !TARGET_OS_IPHONE */ return; @@ -8937,7 +9194,7 @@ make_IPv4RouteList_for_test(IPv4RouteListRef list, CFStringRef descr; descr = IPv4RouteListCopyDescription(r); - SCLog(TRUE, LOG_NOTICE, CFSTR("Adding %@"), descr); + SCPrint(TRUE, stdout, CFSTR("Adding %@"), descr); CFRelease(descr); } ret = IPv4RouteListAddRouteList(list, 1, r, rank); @@ -9606,7 +9863,7 @@ make_IPv6RouteList_for_test(IPv6RouteListRef list, CFStringRef descr; descr = IPv6RouteListCopyDescription(r); - SCLog(TRUE, LOG_NOTICE, CFSTR("Adding %@"), descr); + SCPrint(TRUE, stdout, CFSTR("Adding %@"), descr); CFRelease(descr); } ret = IPv6RouteListAddRouteList(list, 1, r, rank); diff --git a/Plugins/IPMonitor/ip_plugin.h b/Plugins/IPMonitor/ip_plugin.h index 8657994..2f85dd1 100644 --- a/Plugins/IPMonitor/ip_plugin.h +++ b/Plugins/IPMonitor/ip_plugin.h @@ -1,15 +1,15 @@ /* - * Copyright (c) 2012-2014 Apple Inc. All Rights Reserved. + * Copyright (c) 2012-2015 Apple Inc. All Rights Reserved. * * @APPLE_LICENSE_HEADER_START@ - * + * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. - * + * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, @@ -17,7 +17,7 @@ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. - * + * * @APPLE_LICENSE_HEADER_END@ */ @@ -72,6 +72,12 @@ my_if_indextoname(unsigned int idx, char if_name[IFNAMSIZ]); boolean_t service_contains_protocol(CFDictionaryRef service, int af); +boolean_t +service_is_scoped_only(CFDictionaryRef service); + +boolean_t +check_if_service_expensive(CFStringRef serviceID); + CFDictionaryRef ipv4_dict_create(CFDictionaryRef state_dict); diff --git a/Plugins/IPMonitor/proxy-configuration.c b/Plugins/IPMonitor/proxy-configuration.c index 006028d..3645ad3 100644 --- a/Plugins/IPMonitor/proxy-configuration.c +++ b/Plugins/IPMonitor/proxy-configuration.c @@ -389,8 +389,8 @@ copy_app_layer_vpn_proxies(CFDictionaryRef services, CFArrayRef order, CFDiction CFDictionaryRef proxy; CFDictionaryRef service; CFStringRef serviceID; - CFDictionaryRef vpn; - CFStringRef vpn_key; + CFNumberRef isServiceSpecific; + int boolValue = 0; serviceID = CFArrayGetValueAtIndex(order, i); service = CFDictionaryGetValue(services, serviceID); @@ -405,15 +405,9 @@ copy_app_layer_vpn_proxies(CFDictionaryRef services, CFArrayRef order, CFDiction continue; } - vpn_key = SCDynamicStoreKeyCreateNetworkServiceEntity(NULL, - kSCDynamicStoreDomainSetup, - serviceID, - kSCEntNetVPN); - vpn = CFDictionaryGetValue(services_info, vpn_key); - CFRelease(vpn_key); - - if (!isA_CFDictionary(vpn) || !CFDictionaryContainsKey(vpn, kSCPropNetVPNAppRules)) { - // if not App Layer vpn + isServiceSpecific = CFDictionaryGetValue(proxy, kSCPropNetProxiesServiceSpecific); + if (!isA_CFNumber(isServiceSpecific) || !CFNumberGetValue(isServiceSpecific, kCFNumberIntType, &boolValue) || !boolValue) { + // if not a service-specific proxy configuration continue; } @@ -427,6 +421,7 @@ copy_app_layer_vpn_proxies(CFDictionaryRef services, CFArrayRef order, CFDiction newProxy = CFDictionaryCreateMutableCopy(NULL, 0, proxy); CFDictionaryRemoveValue(newProxy, kSCPropNetProxiesSupplementalMatchDomains); CFDictionaryRemoveValue(newProxy, kSCPropNetProxiesSupplementalMatchOrders); + CFDictionaryRemoveValue(newProxy, kSCPropNetProxiesServiceSpecific); if (app_layer_proxies == NULL) { app_layer_proxies = CFDictionaryCreateMutable(NULL, 0, diff --git a/Plugins/IPMonitor/routelist_output_filter.sh b/Plugins/IPMonitor/routelist_output_filter.sh index 90cb275..6e5d7f7 100644 --- a/Plugins/IPMonitor/routelist_output_filter.sh +++ b/Plugins/IPMonitor/routelist_output_filter.sh @@ -1,6 +1,9 @@ #!/bin/sh sed -e 's/^\(Process:.*\[\)[0-9][0-9]*/\1XXXX/' \ - -e 's/^\(Load Address:.*0x\)[0-9a-f][0-9a-f]*/\1XXXX/' \ + -e 's/^\(Load Address:.*\)[0-9a-f][0-9a-f]*/\10xXXXX/' \ + -e '/^Version:.*/d' \ + -e '/^Analysis Tool:.*/d' \ + -e '/^----$/d' \ -e 's/^\(Parent Process:.*\[\)[0-9][0-9]*/\1XXXX/' \ -e 's/^\(Date\/Time: *\)[0-9].*/\1XXXX/' \ -e '/Process [0-9][0-9]*: [0-9][0-9]* nodes malloced/d' \ diff --git a/Plugins/IPMonitor/set-hostname.c b/Plugins/IPMonitor/set-hostname.c index 5003bd1..2c72f6a 100644 --- a/Plugins/IPMonitor/set-hostname.c +++ b/Plugins/IPMonitor/set-hostname.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004-2014 Apple Inc. All rights reserved. + * Copyright (c) 2004-2015 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -48,15 +48,18 @@ #endif // MAIN static SCDynamicStoreRef store = NULL; +static CFRunLoopRef rl = NULL; static CFRunLoopSourceRef rls = NULL; +static dispatch_queue_t queue = NULL; + +static int notify_token = -1; static struct timeval ptrQueryStart; static SCNetworkReachabilityRef ptrTarget = NULL; -static Boolean _verbose = FALSE; - #define HOSTNAME_NOTIFY_KEY "com.apple.system.hostname" +#define SET_HOSTNAME_QUEUE "com.apple.config.set-hostname" CFStringRef copy_dhcp_hostname(CFStringRef serviceID); @@ -76,7 +79,7 @@ set_hostname(CFStringRef hostname) new_name, sizeof(new_name), kCFStringEncodingUTF8) == NULL) { - my_log(LOG_ERR, "could not convert [new] hostname"); + my_log(LOG_NOTICE, "could not convert [new] hostname"); new_name[0] = '\0'; } @@ -212,8 +215,10 @@ ptr_query_stop() return; } + my_log(LOG_INFO, "hostname: ptr query stop"); + SCNetworkReachabilitySetCallback(ptrTarget, NULL, NULL); - SCNetworkReachabilityUnscheduleFromRunLoop(ptrTarget, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode); + SCNetworkReachabilityUnscheduleFromRunLoop(ptrTarget, rl, kCFRunLoopDefaultMode); CFRelease(ptrTarget); ptrTarget = NULL; @@ -221,6 +226,56 @@ ptr_query_stop() } +/* Return a ptr record if the sharing pref name is a matching FQDN */ +static CFStringRef +hostname_match_full(CFArrayRef hosts, CFIndex count, CFStringRef nameToMatch) +{ + CFIndex i; + CFStringRef matchedHostName = NULL; + + for (i = 0; i < count; i++) { + CFStringRef tempHostName; + + tempHostName = CFArrayGetValueAtIndex(hosts, i); + if (CFStringCompare(tempHostName, nameToMatch, kCFCompareCaseInsensitive) == 0) { + matchedHostName = tempHostName; + break; + } + } + return matchedHostName; +} + + +/* Return a ptr record if the sharing pref name matches DNS record's first label */ +static CFStringRef +hostname_match_first_label(CFArrayRef hosts, CFIndex count, CFStringRef nameToMatch) +{ + CFIndex i; + CFStringRef matchedHostName = NULL; + + for (i = 0; i < count; i++) { + CFArrayRef fqdnSeparated; + CFStringRef tempHostName; + + tempHostName = CFArrayGetValueAtIndex(hosts, i); + fqdnSeparated = CFStringCreateArrayBySeparatingStrings(NULL, tempHostName, CFSTR(".")); + if (fqdnSeparated != NULL) { + CFStringRef firstLabel; + Boolean matchFound; + + firstLabel = CFArrayGetValueAtIndex(fqdnSeparated, 0); + matchFound = (CFStringCompare(firstLabel, nameToMatch, kCFCompareCaseInsensitive) == 0); + CFRelease(fqdnSeparated); + if (matchFound) { + matchedHostName = tempHostName; + break; + } + } + } + return matchedHostName; +} + + static void ptr_query_callback(SCNetworkReachabilityRef target, SCNetworkReachabilityFlags flags, void *info) { @@ -230,12 +285,6 @@ ptr_query_callback(SCNetworkReachabilityRef target, SCNetworkReachabilityFlags f (void) gettimeofday(&ptrQueryComplete, NULL); timersub(&ptrQueryComplete, &ptrQueryStart, &ptrQueryElapsed); - if (_verbose) { - my_log(LOG_DEBUG, "ptr query complete%s (query time = %ld.%3.3d)", - (flags & kSCNetworkReachabilityFlagsReachable) ? "" : ", host not found", - ptrQueryElapsed.tv_sec, - ptrQueryElapsed.tv_usec / 1000); - } // use reverse DNS name, if available @@ -248,38 +297,89 @@ ptr_query_callback(SCNetworkReachabilityRef target, SCNetworkReachabilityFlags f */ hosts = SCNetworkReachabilityCopyResolvedAddress(target, &error_num); if (hosts != NULL) { - if (CFArrayGetCount(hosts) > 0) { + CFIndex count = CFArrayGetCount(hosts); + if (count > 0) { + CFStringRef computerName; + CFStringRef localHostName; + + my_log(LOG_INFO, "hostname: ptr query complete (query time = %ld.%3.3d)", + ptrQueryElapsed.tv_sec, + ptrQueryElapsed.tv_usec / 1000); + + // first, check if ComputerName is dns-clean + computerName = _SCPreferencesCopyComputerName(NULL, NULL); + if (computerName != NULL) { + if (_SC_CFStringIsValidDNSName(computerName)) { + CFRange dotsCheck; + + dotsCheck = CFStringFind(computerName, CFSTR("."), 0); + if (dotsCheck.length == 0) { + hostname = hostname_match_first_label(hosts, count, computerName); + } else { + hostname = hostname_match_full(hosts, count, computerName); + } + } + CFRelease(computerName); + } + + // if no match, check LocalHostName against the first label of FQDN + localHostName = (hostname == NULL) ? SCDynamicStoreCopyLocalHostName(store) : NULL; + if (localHostName != NULL) { + hostname = hostname_match_first_label(hosts, count, localHostName); + CFRelease(localHostName); + } + + // if no match, use the first of the returned names + if (hostname == NULL) { + hostname = CFArrayGetValueAtIndex(hosts, 0); + } - hostname = CFArrayGetValueAtIndex(hosts, 0); - my_log(LOG_DEBUG, "hostname (reverse DNS query) = %@", hostname); + my_log(LOG_INFO, "hostname (reverse DNS query) = %@", hostname); set_hostname(hostname); + } else { + my_log(LOG_INFO, "hostname: ptr query complete w/no hosts (query time = %ld.%3.3d)", + ptrQueryElapsed.tv_sec, + ptrQueryElapsed.tv_usec / 1000); } CFRelease(hosts); if (hostname != NULL) { goto done; } + } else { + // if kSCNetworkReachabilityFlagsReachable and hosts == NULL + // it means the PTR request has not come back yet + // we must wait for this callback to be called again + my_log(LOG_INFO, "hostname: ptr query reply w/no hosts (query time = %ld.%3.3d)", + ptrQueryElapsed.tv_sec, + ptrQueryElapsed.tv_usec / 1000); + return; } + } else { + my_log(LOG_INFO, "hostname: ptr query complete, host not found (query time = %ld.%3.3d)", + ptrQueryElapsed.tv_sec, + ptrQueryElapsed.tv_usec / 1000); } // get local (multicast DNS) name, if available hostname = SCDynamicStoreCopyLocalHostName(store); if (hostname != NULL) { - CFMutableStringRef localName; - - my_log(LOG_DEBUG, "hostname (multicast DNS) = %@", hostname); - localName = CFStringCreateMutableCopy(NULL, 0, hostname); - assert(localName != NULL); - CFStringAppend(localName, CFSTR(".local")); - set_hostname(localName); - CFRelease(localName); + CFMutableStringRef localHostName; + + my_log(LOG_INFO, "hostname (multicast DNS) = %@", hostname); + localHostName = CFStringCreateMutableCopy(NULL, 0, hostname); + assert(localHostName != NULL); + CFStringAppend(localHostName, CFSTR(".local")); + set_hostname(localHostName); + CFRelease(localHostName); CFRelease(hostname); goto done; } // use "localhost" if not other name is available + my_log(LOG_INFO, "hostname (localhost)"); set_hostname(CFSTR("localhost")); done : @@ -287,7 +387,7 @@ ptr_query_callback(SCNetworkReachabilityRef target, SCNetworkReachabilityFlags f ptr_query_stop(); #ifdef MAIN - CFRunLoopStop(CFRunLoopGetCurrent()); + CFRunLoopStop(rl); #endif // MAIN return; @@ -330,8 +430,10 @@ ptr_query_start(CFStringRef address) return FALSE; } + my_log(LOG_INFO, "hostname: ptr query start"); + (void) SCNetworkReachabilitySetCallback(ptrTarget, ptr_query_callback, NULL); - (void) SCNetworkReachabilityScheduleWithRunLoop(ptrTarget, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode); + (void) SCNetworkReachabilityScheduleWithRunLoop(ptrTarget, rl, kCFRunLoopDefaultMode); return TRUE; } @@ -354,7 +456,7 @@ update_hostname(SCDynamicStoreRef store, CFArrayRef changedKeys, void *info) hostname = copy_prefs_hostname(store); if (hostname != NULL) { - my_log(LOG_DEBUG, "hostname (prefs) = %@", hostname); + my_log(LOG_INFO, "hostname (prefs) = %@", hostname); set_hostname(hostname); goto done; } @@ -370,7 +472,7 @@ update_hostname(SCDynamicStoreRef store, CFArrayRef changedKeys, void *info) hostname = copy_dhcp_hostname(serviceID); if (hostname != NULL) { - my_log(LOG_DEBUG, "hostname (DHCP) = %@", hostname); + my_log(LOG_INFO, "hostname (DHCP) = %@", hostname); set_hostname(hostname); goto done; } @@ -380,12 +482,18 @@ update_hostname(SCDynamicStoreRef store, CFArrayRef changedKeys, void *info) address = copy_primary_ip(store, serviceID); if (address != NULL) { Boolean ok; + boolean_t isExpensive = FALSE; // start reverse DNS query using primary IP address - ok = ptr_query_start(address); - if (ok) { - // if query started - goto done; + // if primary service is not expensive + isExpensive = check_if_service_expensive(serviceID); + + if (isExpensive == FALSE) { + ok = ptr_query_start(address); + if (ok) { + // if query started + goto done; + } } } @@ -395,14 +503,14 @@ update_hostname(SCDynamicStoreRef store, CFArrayRef changedKeys, void *info) hostname = SCDynamicStoreCopyLocalHostName(store); if (hostname != NULL) { - CFMutableStringRef localName; - - my_log(LOG_DEBUG, "hostname (multicast DNS) = %@", hostname); - localName = CFStringCreateMutableCopy(NULL, 0, hostname); - assert(localName != NULL); - CFStringAppend(localName, CFSTR(".local")); - set_hostname(localName); - CFRelease(localName); + CFMutableStringRef localHostName; + + my_log(LOG_INFO, "hostname (multicast DNS) = %@", hostname); + localHostName = CFStringCreateMutableCopy(NULL, 0, hostname); + assert(localHostName != NULL); + CFStringAppend(localHostName, CFSTR(".local")); + set_hostname(localHostName); + CFRelease(localHostName); goto done; } @@ -426,11 +534,10 @@ load_hostname(Boolean verbose) { CFStringRef key; CFMutableArrayRef keys = NULL; + dispatch_block_t notify_block; + Boolean ok; CFMutableArrayRef patterns = NULL; - - if (verbose) { - _verbose = TRUE; - } + uint32_t status; /* initialize a few globals */ @@ -441,26 +548,19 @@ load_hostname(Boolean verbose) SCErrorString(SCError())); goto error; } + + queue = dispatch_queue_create(SET_HOSTNAME_QUEUE, NULL); + if (queue == NULL) { + my_log(LOG_ERR, + "dispatch_queue_create() failed"); + goto error; + } /* establish notification keys and patterns */ keys = CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks); patterns = CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks); - /* ...watch for primary service / interface changes */ - key = SCDynamicStoreKeyCreateNetworkGlobalEntity(NULL, - kSCDynamicStoreDomainState, - kSCEntNetIPv4); - CFArrayAppendValue(keys, key); - CFRelease(key); - - /* ...watch for DNS configuration changes */ - key = SCDynamicStoreKeyCreateNetworkGlobalEntity(NULL, - kSCDynamicStoreDomainState, - kSCEntNetDNS); - CFArrayAppendValue(keys, key); - CFRelease(key); - /* ...watch for (per-service) DHCP option changes */ key = SCDynamicStoreKeyCreateNetworkServiceEntity(NULL, kSCDynamicStoreDomainState, @@ -480,31 +580,73 @@ load_hostname(Boolean verbose) CFRelease(key); /* register the keys/patterns */ - if (!SCDynamicStoreSetNotificationKeys(store, keys, patterns)) { + ok = SCDynamicStoreSetNotificationKeys(store, keys, patterns); + CFRelease(keys); + CFRelease(patterns); + if (!ok) { my_log(LOG_ERR, "SCDynamicStoreSetNotificationKeys() failed: %s", SCErrorString(SCError())); goto error; } + rl = CFRunLoopGetCurrent(); rls = SCDynamicStoreCreateRunLoopSource(NULL, store, 0); - if (!rls) { + if (rls == NULL) { my_log(LOG_ERR, "SCDynamicStoreCreateRunLoopSource() failed: %s", SCErrorString(SCError())); goto error; } - CFRunLoopAddSource(CFRunLoopGetCurrent(), rls, kCFRunLoopDefaultMode); + CFRunLoopAddSource(rl, rls, kCFRunLoopDefaultMode); + + /* ...watch for primary service/interface and DNS configuration changes */ + notify_block = ^{ + CFArrayRef changes; + CFStringRef key; + + key = SCDynamicStoreKeyCreateNetworkGlobalEntity(NULL, + kSCDynamicStoreDomainState, + kSCEntNetDNS); + changes = CFArrayCreate(NULL, (const void **)&key, 1, &kCFTypeArrayCallBacks); + (*update_hostname)(store, changes, NULL); + CFRelease(changes); + CFRelease(key); + + return; + }; + status = notify_register_dispatch(_SC_NOTIFY_NETWORK_CHANGE, + ¬ify_token, + queue, + ^(int token){ + CFRunLoopPerformBlock(rl, + kCFRunLoopDefaultMode, + notify_block); + CFRunLoopWakeUp(rl); + }); + if (status != NOTIFY_STATUS_OK) { + my_log(LOG_ERR, "notify_register_dispatch() failed: %u", status); + goto error; + } - CFRelease(keys); - CFRelease(patterns); return; error : - if (keys != NULL) CFRelease(keys); - if (patterns != NULL) CFRelease(patterns); - if (store != NULL) CFRelease(store); + if (rls != NULL) { + CFRunLoopRemoveSource(rl, rls, kCFRunLoopDefaultMode); + CFRelease(rls); + rls = NULL; + } + if (store != NULL) { + CFRelease(store); + store = NULL; + } + if (queue != NULL) { + dispatch_release(queue); + queue = NULL; + } + return; } @@ -519,7 +661,6 @@ main(int argc, char **argv) _sc_log = FALSE; if ((argc > 1) && (strcmp(argv[1], "-d") == 0)) { _sc_verbose = TRUE; - _verbose = TRUE; argv++; argc--; } diff --git a/Plugins/IPMonitor/smb-configuration.c b/Plugins/IPMonitor/smb-configuration.c index f93a629..73e0dfd 100644 --- a/Plugins/IPMonitor/smb-configuration.c +++ b/Plugins/IPMonitor/smb-configuration.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2014 Apple Inc. All rights reserved. + * Copyright (c) 2006-2015 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -65,15 +65,16 @@ #define SMB_DEBOUNCE_DELAY 5.0 static SCDynamicStoreRef store = NULL; +static CFRunLoopRef rl = NULL; static CFRunLoopSourceRef rls = NULL; +static int notify_token = -1; + static struct timeval ptrQueryStart; static SCNetworkReachabilityRef ptrTarget = NULL; static CFRunLoopTimerRef timer = NULL; -static Boolean _verbose = FALSE; - static CFAbsoluteTime boottime(void) @@ -450,8 +451,10 @@ ptr_query_stop() return; } + my_log(LOG_INFO, "NetBIOS name: ptr query stop"); + SCNetworkReachabilitySetCallback(ptrTarget, NULL, NULL); - SCNetworkReachabilityUnscheduleFromRunLoop(ptrTarget, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode); + SCNetworkReachabilityUnscheduleFromRunLoop(ptrTarget, rl, kCFRunLoopDefaultMode); CFRelease(ptrTarget); ptrTarget = NULL; @@ -470,12 +473,10 @@ ptr_query_callback(SCNetworkReachabilityRef target, SCNetworkReachabilityFlags f (void) gettimeofday(&ptrQueryComplete, NULL); timersub(&ptrQueryComplete, &ptrQueryStart, &ptrQueryElapsed); - if (_verbose) { - my_log(LOG_DEBUG, "ptr query complete%s (query time = %ld.%3.3d)", - (flags & kSCNetworkReachabilityFlagsReachable) ? "" : ", host not found", - ptrQueryElapsed.tv_sec, - ptrQueryElapsed.tv_usec / 1000); - } + my_log(LOG_INFO, "NetBIOS name: ptr query complete%s (query time = %ld.%3.3d)", + (flags & kSCNetworkReachabilityFlagsReachable) ? "" : ", host not found", + ptrQueryElapsed.tv_sec, + ptrQueryElapsed.tv_usec / 1000); // get network configuration dict = smb_copy_global_configuration(store); @@ -483,7 +484,7 @@ ptr_query_callback(SCNetworkReachabilityRef target, SCNetworkReachabilityFlags f // use NetBIOS name from network configuration (if available) name = CFDictionaryGetValue(dict, kSCPropNetSMBNetBIOSName); if ((name != NULL) && _SC_CFStringIsValidNetBIOSName(name)) { - my_log(LOG_DEBUG, "NetBIOS name (network configuration) = %@", name); + my_log(LOG_INFO, "NetBIOS name (network configuration) = %@", name); goto setDict; } @@ -522,7 +523,7 @@ ptr_query_callback(SCNetworkReachabilityRef target, SCNetworkReachabilityFlags f } if (name != NULL) { if (_SC_CFStringIsValidNetBIOSName(name)) { - my_log(LOG_DEBUG, "NetBIOS name (reverse DNS query) = %@", name); + my_log(LOG_INFO, "NetBIOS name (reverse DNS query) = %@", name); goto setName; } CFRelease(name); @@ -532,7 +533,7 @@ ptr_query_callback(SCNetworkReachabilityRef target, SCNetworkReachabilityFlags f name = SCDynamicStoreCopyLocalHostName(store); if (name != NULL) { if (_SC_CFStringIsValidNetBIOSName(name)) { - my_log(LOG_DEBUG, "NetBIOS name (multicast DNS) = %@", name); + my_log(LOG_INFO, "NetBIOS name (multicast DNS) = %@", name); goto setName; } CFRelease(name); @@ -541,7 +542,7 @@ ptr_query_callback(SCNetworkReachabilityRef target, SCNetworkReachabilityFlags f // use "default" name name = copy_default_name(); if (name != NULL) { - my_log(LOG_DEBUG, "NetBIOS name (default) = %@", name); + my_log(LOG_INFO, "NetBIOS name (default) = %@", name); goto setName; } @@ -564,7 +565,7 @@ ptr_query_callback(SCNetworkReachabilityRef target, SCNetworkReachabilityFlags f ptr_query_stop(); #ifdef MAIN - CFRunLoopStop(CFRunLoopGetCurrent()); + CFRunLoopStop(rl); #endif // MAIN return; @@ -607,8 +608,10 @@ ptr_query_start(CFStringRef address) return FALSE; } + my_log(LOG_INFO, "NetBIOS name: ptr query start"); + (void) SCNetworkReachabilitySetCallback(ptrTarget, ptr_query_callback, NULL); - (void) SCNetworkReachabilityScheduleWithRunLoop(ptrTarget, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode); + (void) SCNetworkReachabilityScheduleWithRunLoop(ptrTarget, rl, kCFRunLoopDefaultMode); return TRUE; } @@ -629,7 +632,7 @@ smb_update_configuration(__unused CFRunLoopTimerRef _timer, void *info) // use NetBIOS name from network configuration (if available) name = CFDictionaryGetValue(dict, kSCPropNetSMBNetBIOSName); if ((name != NULL) && _SC_CFStringIsValidNetBIOSName(name)) { - my_log(LOG_DEBUG, "NetBIOS name (network configuration) = %@", name); + my_log(LOG_INFO, "NetBIOS name (network configuration) = %@", name); goto set; } @@ -662,7 +665,7 @@ smb_update_configuration(__unused CFRunLoopTimerRef _timer, void *info) if (_SC_CFStringIsValidNetBIOSName(name)) { CFMutableDictionaryRef newDict; - my_log(LOG_DEBUG, "NetBIOS name (multicast DNS) = %@", name); + my_log(LOG_INFO, "NetBIOS name (multicast DNS) = %@", name); newDict = CFDictionaryCreateMutableCopy(NULL, 0, dict); CFDictionarySetValue(newDict, kSCPropNetSMBNetBIOSName, name); CFRelease(dict); @@ -678,7 +681,7 @@ smb_update_configuration(__unused CFRunLoopTimerRef _timer, void *info) if (name != NULL) { CFMutableDictionaryRef newDict; - my_log(LOG_DEBUG, "NetBIOS name (default) = %@", name); + my_log(LOG_INFO, "NetBIOS name (default) = %@", name); newDict = CFDictionaryCreateMutableCopy(NULL, 0, dict); CFDictionarySetValue(newDict, kSCPropNetSMBNetBIOSName, name); CFRelease(dict); @@ -738,7 +741,7 @@ configuration_changed(SCDynamicStoreRef store, CFArrayRef changedKeys, void *inf 0, smb_update_configuration, &context); - CFRunLoopAddTimer(CFRunLoopGetCurrent(), timer, kCFRunLoopDefaultMode); + CFRunLoopAddTimer(rl, timer, kCFRunLoopDefaultMode); return; } @@ -750,11 +753,10 @@ load_smb_configuration(Boolean verbose) { CFStringRef key; CFMutableArrayRef keys = NULL; + dispatch_block_t notify_block; + Boolean ok; CFMutableArrayRef patterns = NULL; - - if (verbose) { - _verbose = TRUE; - } + uint32_t status; /* initialize a few globals */ @@ -771,20 +773,6 @@ load_smb_configuration(Boolean verbose) keys = CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks); patterns = CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks); - /* ...watch for primary service / interface changes */ - key = SCDynamicStoreKeyCreateNetworkGlobalEntity(NULL, - kSCDynamicStoreDomainState, - kSCEntNetIPv4); - CFArrayAppendValue(keys, key); - CFRelease(key); - - /* ...watch for DNS configuration changes */ - key = SCDynamicStoreKeyCreateNetworkGlobalEntity(NULL, - kSCDynamicStoreDomainState, - kSCEntNetDNS); - CFArrayAppendValue(keys, key); - CFRelease(key); - /* ...watch for SMB configuration changes */ key = SCDynamicStoreKeyCreateNetworkGlobalEntity(NULL, kSCDynamicStoreDomainState, @@ -803,31 +791,69 @@ load_smb_configuration(Boolean verbose) CFRelease(key); /* register the keys/patterns */ - if (!SCDynamicStoreSetNotificationKeys(store, keys, patterns)) { + ok = SCDynamicStoreSetNotificationKeys(store, keys, patterns); + CFRelease(keys); + CFRelease(patterns); + if (!ok) { my_log(LOG_ERR, "SCDynamicStoreSetNotificationKeys() failed: %s", SCErrorString(SCError())); goto error; } + rl = CFRunLoopGetCurrent(); rls = SCDynamicStoreCreateRunLoopSource(NULL, store, 0); - if (!rls) { + if (rls == NULL) { my_log(LOG_ERR, "SCDynamicStoreCreateRunLoopSource() failed: %s", SCErrorString(SCError())); goto error; } - CFRunLoopAddSource(CFRunLoopGetCurrent(), rls, kCFRunLoopDefaultMode); + CFRunLoopAddSource(rl, rls, kCFRunLoopDefaultMode); + + /* ...watch for primary service/interface and DNS configuration changes */ + notify_block = ^{ + CFArrayRef changes; + CFStringRef key; + + key = SCDynamicStoreKeyCreateNetworkGlobalEntity(NULL, + kSCDynamicStoreDomainState, + kSCEntNetDNS); + changes = CFArrayCreate(NULL, (const void **)&key, 1, &kCFTypeArrayCallBacks); + (*configuration_changed)(store, changes, NULL); + CFRelease(changes); + CFRelease(key); + + return; + }; + status = notify_register_dispatch(_SC_NOTIFY_NETWORK_CHANGE, + ¬ify_token, + dispatch_get_main_queue(), + ^(int token){ + CFRunLoopPerformBlock(rl, + kCFRunLoopDefaultMode, + notify_block); + CFRunLoopWakeUp(rl); + }); + if (status != NOTIFY_STATUS_OK) { + my_log(LOG_ERR, "notify_register_dispatch() failed: %u", status); + goto error; + } - CFRelease(keys); - CFRelease(patterns); return; error : - if (keys != NULL) CFRelease(keys); - if (patterns != NULL) CFRelease(patterns); - if (store != NULL) CFRelease(store); + if (rls != NULL) { + CFRunLoopRemoveSource(rl, rls, kCFRunLoopDefaultMode); + CFRelease(rls); + rls = NULL; + } + if (store != NULL) { + CFRelease(store); + store = NULL; + } + return; } @@ -846,7 +872,6 @@ main(int argc, char **argv) _sc_log = FALSE; if ((argc > 1) && (strcmp(argv[1], "-d") == 0)) { _sc_verbose = TRUE; - _verbose = TRUE; argv++; argc--; } diff --git a/Plugins/IPMonitor/test_ipv4_routelist_reference.txt b/Plugins/IPMonitor/test_ipv4_routelist_reference.txt index 5735e65..19f84cf 100644 --- a/Plugins/IPMonitor/test_ipv4_routelist_reference.txt +++ b/Plugins/IPMonitor/test_ipv4_routelist_reference.txt @@ -18799,7 +18799,6 @@ Process: test_ipv4_routelist [XXXX] Path: XXXX Load Address: 0xXXXX Identifier: test_ipv4_routelist -Version: 0 Code Type: X86-64 Parent Process: sh [XXXX] diff --git a/Plugins/IPMonitor/test_ipv6_routelist_reference.txt b/Plugins/IPMonitor/test_ipv6_routelist_reference.txt index 4a7c27d..5679d1b 100644 --- a/Plugins/IPMonitor/test_ipv6_routelist_reference.txt +++ b/Plugins/IPMonitor/test_ipv6_routelist_reference.txt @@ -1388,7 +1388,6 @@ Process: test_ipv6_routelist [XXXX] Path: XXXX Load Address: 0xXXXX Identifier: test_ipv6_routelist -Version: 0 Code Type: X86-64 Parent Process: sh [XXXX] diff --git a/Plugins/InterfaceNamer/Info.plist b/Plugins/InterfaceNamer/Info.plist index 69e28db..dfaf270 100644 --- a/Plugins/InterfaceNamer/Info.plist +++ b/Plugins/InterfaceNamer/Info.plist @@ -17,7 +17,7 @@ CFBundlePackageType BNDL CFBundleShortVersionString - 1.14.4 + 1.14 CFBundleSignature ???? CFBundleVersion diff --git a/Plugins/InterfaceNamer/ifnamer.c b/Plugins/InterfaceNamer/ifnamer.c index faa4a06..254b90c 100644 --- a/Plugins/InterfaceNamer/ifnamer.c +++ b/Plugins/InterfaceNamer/ifnamer.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001-2014 Apple Inc. All rights reserved. + * Copyright (c) 2001-2015 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -70,7 +70,6 @@ #include #include #include -#include #include @@ -130,12 +129,6 @@ static io_connect_t S_connect = MACH_PORT_NULL; */ static CFMutableArrayRef S_dblist = NULL; -/* - * S_debug - * A boolean that enables additional logging. - */ -static boolean_t S_debug = FALSE; - /* * S_iflist * An array of SCNetworkInterface's representing the @@ -202,15 +195,6 @@ static CFRunLoopTimerRef S_timer = NULL; static double S_stack_timeout = WAIT_STACK_TIMEOUT_DEFAULT; static double S_quiet_timeout = WAIT_QUIET_TIMEOUT_DEFAULT; -#if !TARGET_OS_EMBEDDED -/* - * S_vproc_transaction - * The vproc transaction used to keep launchd from sending us - * a SIGKILL before we've had a chance to set the platform UUID - */ -vproc_transaction_t S_vproc_transaction = NULL; -#endif // !TARGET_OS_EMBEDDED - /* * Virtual network interface configuration * S_prefs : SCPreferences to configuration @@ -292,9 +276,7 @@ writeInterfaceList(CFArrayRef if_list) prefs = SCPreferencesCreate(NULL, MY_PLUGIN_ID, NETWORK_INTERFACES_PREFS); if (prefs == NULL) { - SCLog(TRUE, LOG_ERR, - CFSTR(MY_PLUGIN_NAME ": SCPreferencesCreate failed, %s"), - SCErrorString(SCError())); + SC_log(LOG_NOTICE, "SCPreferencesCreate() failed: %s", SCErrorString(SCError())); return; } @@ -319,10 +301,9 @@ writeInterfaceList(CFArrayRef if_list) SCPreferencesSetValue(prefs, history, cur_list); CFRelease(history); - SCLog(TRUE, LOG_ERR, - CFSTR(MY_PLUGIN_NAME ": Hardware model changed\n" - MY_PLUGIN_NAME ": created on \"%@\"\n" - MY_PLUGIN_NAME ": now on \"%@\""), + SC_log(LOG_INFO, "Hardware model changed\n" + " created on \"%@\"\n" + " now on \"%@\"", old_model, new_model); @@ -334,25 +315,15 @@ writeInterfaceList(CFArrayRef if_list) CFRelease(issue); } - if (!SCPreferencesSetValue(prefs, MODEL, new_model)) { - SCLog(TRUE, LOG_ERR, - CFSTR(MY_PLUGIN_NAME ": SCPreferencesSetValue failed, %s"), - SCErrorString(SCError())); - goto done; - } + SCPreferencesSetValue(prefs, MODEL, new_model); } - if (!SCPreferencesSetValue(prefs, INTERFACES, if_list)) { - SCLog(TRUE, LOG_ERR, - CFSTR(MY_PLUGIN_NAME ": SCPreferencesSetValue failed, %s"), - SCErrorString(SCError())); - goto done; - } + SCPreferencesSetValue(prefs, INTERFACES, if_list); if (!SCPreferencesCommitChanges(prefs)) { - SCLog((SCError() != EROFS), LOG_ERR, - CFSTR(MY_PLUGIN_NAME ": SCPreferencesCommitChanges failed, %s"), - SCErrorString(SCError())); + if (SCError() != EROFS) { + SC_log(LOG_NOTICE, "SCPreferencesCommitChanges() failed: %s", SCErrorString(SCError())); + } goto done; } @@ -362,6 +333,41 @@ done: return; } +static CFPropertyListRef +restoreNIPrefsFromBackup(SCPreferencesRef prefs, CFStringRef current_model) +{ + CFPropertyListRef if_list; + CFStringRef key; + + key = CFStringCreateWithFormat(NULL, 0, CFSTR("%@:%@"), INTERFACES, current_model); + if_list = SCPreferencesGetValue(prefs, key); + if_list = isA_CFArray(if_list); + if (if_list != NULL) { + /* Write the previously backed up Interface list for this hardware */ + writeInterfaceList(if_list); + + /* Synchronize the prefs */ + SCPreferencesSynchronize(prefs); + + /* Re-fetch the interface list */ + if_list = SCPreferencesGetValue(prefs, INTERFACES); + if_list = isA_CFArray(if_list); + if (if_list != NULL) { + /* We do not need the old interface list any more */ + SCPreferencesRemoveValue(prefs, key); + if (!SCPreferencesCommitChanges(prefs)) { + if (SCError() != EROFS) { + SC_log(LOG_NOTICE, "SCPreferencesCommitChanges() failed: %s", SCErrorString(SCError())); + } + if_list = NULL; + } + } + } + + CFRelease(key); + return if_list; +} + static CF_RETURNS_RETAINED CFMutableArrayRef readInterfaceList() { @@ -371,10 +377,8 @@ readInterfaceList() SCPreferencesRef prefs = NULL; prefs = SCPreferencesCreate(NULL, MY_PLUGIN_ID, NETWORK_INTERFACES_PREFS); - if (!prefs) { - SCLog(TRUE, LOG_ERR, - CFSTR(MY_PLUGIN_NAME ": SCPreferencesCreate failed, %s"), - SCErrorString(SCError())); + if (prefs == NULL) { + SC_log(LOG_NOTICE, "SCPreferencesCreate() failed: %s", SCErrorString(SCError())); return (NULL); } @@ -387,8 +391,9 @@ readInterfaceList() new_model = _SC_hw_model(FALSE); if (!_SC_CFEqual(old_model, new_model)) { - // if interface list was created on other hardware - if_list = NULL; + /* if interface list was created on other hardware, + Restore if a backup interface list is present */ + if_list = restoreNIPrefsFromBackup(prefs, new_model); } } @@ -483,9 +488,8 @@ updateBondInterfaceConfiguration(SCPreferencesRef prefs) S_bonds = interfaces; if (!_SCBondInterfaceUpdateConfiguration(prefs)) { - SCLog(TRUE, LOG_ERR, - CFSTR(MY_PLUGIN_NAME ": _SCBondInterfaceUpdateConfiguration failed, %s"), - SCErrorString(SCError())); + SC_log(LOG_NOTICE, "_SCBondInterfaceUpdateConfiguration() failed: %s", + SCErrorString(SCError())); } return; @@ -513,9 +517,8 @@ updateBridgeInterfaceConfiguration(SCPreferencesRef prefs) S_bridges = interfaces; if (!_SCBridgeInterfaceUpdateConfiguration(prefs)) { - SCLog(TRUE, LOG_ERR, - CFSTR(MY_PLUGIN_NAME ": _SCBridgeInterfaceUpdateConfiguration failed, %s"), - SCErrorString(SCError())); + SC_log(LOG_NOTICE, "_SCBridgeInterfaceUpdateConfiguration() failed: %s", + SCErrorString(SCError())); } return; @@ -542,9 +545,8 @@ updateVLANInterfaceConfiguration(SCPreferencesRef prefs) S_vlans = interfaces; if (!_SCVLANInterfaceUpdateConfiguration(prefs)) { - SCLog(TRUE, LOG_ERR, - CFSTR(MY_PLUGIN_NAME ": _SCVLANInterfaceUpdateConfiguration failed, %s"), - SCErrorString(SCError())); + SC_log(LOG_NOTICE, "_SCVLANInterfaceUpdateConfiguration() failed: %s", + SCErrorString(SCError())); } return; @@ -555,10 +557,15 @@ updateVirtualNetworkInterfaceConfiguration(SCPreferencesRef prefs, SCPreferencesNotification notificationType, void *info) { + os_activity_t activity_id; + if ((notificationType & kSCPreferencesNotificationApply) != kSCPreferencesNotificationApply) { return; } + activity_id = os_activity_start("check/update virtual network interface configuration", + OS_ACTIVITY_FLAG_DEFAULT); + if (prefs == NULL) { // if a new interface has been "named" prefs = S_prefs; @@ -584,6 +591,9 @@ updateVirtualNetworkInterfaceConfiguration(SCPreferencesRef prefs, // we are finished with current prefs, wait for changes SCPreferencesSynchronize(prefs); + + os_activity_end(activity_id); + return; } @@ -936,9 +946,7 @@ interfaceExists(CFStringRef prefix, CFNumberRef unit) kr = IOMasterPort(bootstrap_port, &masterPort); if (kr != KERN_SUCCESS) { - SCLog(TRUE, LOG_ERR, - CFSTR(MY_PLUGIN_NAME ": IOMasterPort returned 0x%x"), - kr); + SC_log(LOG_ERR, "IOMasterPort returned 0x%x", kr); goto error; } @@ -1264,9 +1272,7 @@ copyInterfaceForIORegistryEntryID(uint64_t entryID) kr = IOMasterPort(bootstrap_port, &masterPort); if (kr != KERN_SUCCESS) { - SCLog(TRUE, LOG_ERR, - CFSTR(MY_PLUGIN_NAME ": IOMasterPort returned 0x%x"), - kr); + SC_log(LOG_ERR, "IOMasterPort returned 0x%x", kr); goto error; } @@ -1274,19 +1280,16 @@ copyInterfaceForIORegistryEntryID(uint64_t entryID) IORegistryEntryIDMatching(entryID), &iterator); if ((kr != KERN_SUCCESS) || (iterator == MACH_PORT_NULL)) { - SCLog(TRUE, LOG_ERR, - CFSTR(MY_PLUGIN_NAME ": IOServiceGetMatchingServices(0x%llx) returned 0x%x/%d"), - entryID, - kr, - iterator); + SC_log(LOG_NOTICE, "IOServiceGetMatchingServices(0x%llx) returned 0x%x/%d", + entryID, + kr, + iterator); goto error; } entry = IOIteratorNext(iterator); if (entry == MACH_PORT_NULL) { - SCLog(TRUE, LOG_ERR, - CFSTR(MY_PLUGIN_NAME ": IORegistryEntryIDMatching(0x%llx) failed"), - entryID); + SC_log(LOG_NOTICE, "IORegistryEntryIDMatching(0x%llx) failed", entryID); goto error; } @@ -1355,17 +1358,13 @@ copyInterfaceForIOKitPath(CFStringRef if_path) kr = IOMasterPort(bootstrap_port, &masterPort); if (kr != KERN_SUCCESS) { - SCLog(TRUE, LOG_ERR, - CFSTR(MY_PLUGIN_NAME ": IOMasterPort returned 0x%x"), - kr); + SC_log(LOG_ERR, "IOMasterPort returned 0x%x", kr); goto error; } _SC_cfstring_to_cstring(if_path, path, sizeof(path), kCFStringEncodingASCII); entry = IORegistryEntryFromPath(masterPort, path); if (entry == MACH_PORT_NULL) { - SCLog(TRUE, LOG_ERR, - CFSTR(MY_PLUGIN_NAME ": IORegistryEntryFromPath(%@) failed"), - if_path); + SC_log(LOG_NOTICE, "IORegistryEntryFromPath(%@) failed", if_path); goto error; } @@ -1406,8 +1405,7 @@ displayInterface(SCNetworkInterfaceRef interface) type = _SCNetworkInterfaceGetIOInterfaceType(interface); addr = SCNetworkInterfaceGetHardwareAddressString(interface); - SCLog(TRUE, LOG_INFO, - CFSTR(MY_PLUGIN_NAME ": %s%@%sType: %@, %s%@%sMAC address: %@"), + SC_log(LOG_INFO, " %s%@%sType: %@, %s%@%sMAC address: %@", (name != NULL) ? "BSD Name: " : "", (name != NULL) ? name : CFSTR(""), (name != NULL) ? ", " : "", @@ -1510,15 +1508,12 @@ nameInterfaces(CFMutableArrayRef if_list) entryID = _SCNetworkInterfaceGetIORegistryEntryID(interface); if (unit != NULL) { - if (S_debug) { - CFStringRef if_name; - - if_name = SCNetworkInterfaceGetBSDName(interface); - if ((if_name == NULL) || !CFDictionaryContainsKey(S_state, if_name)) { - SCLog(TRUE, LOG_INFO, - CFSTR(MY_PLUGIN_NAME ": Interface already has a unit number")); - displayInterface(interface); - } + CFStringRef if_name; + + if_name = SCNetworkInterfaceGetBSDName(interface); + if ((if_name == NULL) || !CFDictionaryContainsKey(S_state, if_name)) { + SC_log(LOG_INFO, "Interface already has a unit number"); + displayInterface(interface); } // update the list of interfaces that were previously named @@ -1539,9 +1534,7 @@ nameInterfaces(CFMutableArrayRef if_list) unit = CFDictionaryGetValue(dbdict, CFSTR(kIOInterfaceUnit)); CFRetain(unit); - SCLog(S_debug, LOG_INFO, - CFSTR(MY_PLUGIN_NAME ": Interface assigned unit %@ (from database)"), - unit); + SC_log(LOG_INFO, "Interface assigned unit %@ (from database)", unit); } if ((dbdict == NULL) && !isQuiet()) { @@ -1562,9 +1555,7 @@ nameInterfaces(CFMutableArrayRef if_list) unit = CFDictionaryGetValue(dbdict, CFSTR(kIOInterfaceUnit)); CFRetain(unit); - SCLog(S_debug, LOG_INFO, - CFSTR(MY_PLUGIN_NAME ": Interface assigned unit %@ (updating database)"), - unit); + SC_log(LOG_INFO, "Interface assigned unit %@ (updating database)", unit); } } @@ -1596,9 +1587,7 @@ nameInterfaces(CFMutableArrayRef if_list) unit = CFNumberCreate(NULL, kCFNumberIntType, &next_unit); if (!builtinAvailable(interface, unit)) { // if [built-in] unit not available - SCLog(S_debug, LOG_INFO, - CFSTR(MY_PLUGIN_NAME ": Interface not assigned [built-in] unit %@"), - unit); + SC_log(LOG_INFO, "Interface not assigned [built-in] unit %@", unit); CFRelease(unit); unit = NULL; } @@ -1622,10 +1611,9 @@ nameInterfaces(CFMutableArrayRef if_list) unit = CFNumberCreate(NULL, kCFNumberIntType, &next_unit); } - SCLog(S_debug, LOG_INFO, - CFSTR(MY_PLUGIN_NAME ": Interface assigned unit %@ (%s)"), - unit, - is_builtin ? "built-in" : "next available"); + SC_log(LOG_INFO, "Interface assigned unit %@ (%s)", + unit, + is_builtin ? "built-in" : "next available"); } retry : @@ -1651,20 +1639,17 @@ nameInterfaces(CFMutableArrayRef if_list) signature = (dbdict == NULL) ? "failed to name new interface" : "failed to name known interface"; - SCLog(TRUE, LOG_ERR, - CFSTR(MY_PLUGIN_NAME ": %s, kr=0x%x\n" - MY_PLUGIN_NAME ": path = %@\n" - MY_PLUGIN_NAME ": id = 0x%llx\n" - MY_PLUGIN_NAME ": unit = %@"), - signature, - kr, - path, - entryID, - unit); - - if (S_debug) { - displayInterface(interface); - } + SC_log(LOG_NOTICE, "%s, kr=0x%x\n" + " path = %@\n" + " id = 0x%llx\n" + " unit = %@", + signature, + kr, + path, + entryID, + unit); + + displayInterface(interface); // report issue w/MessageTracer str = CFStringCreateWithFormat(NULL, NULL, @@ -1684,15 +1669,14 @@ nameInterfaces(CFMutableArrayRef if_list) CFNumberRef new_unit; if (retries > 0) { - SCLog(TRUE, LOG_ERR, - CFSTR(MY_PLUGIN_NAME ": %s interface named after %d %s\n" - MY_PLUGIN_NAME ": path = %@\n" - MY_PLUGIN_NAME ": unit = %@"), - (dbdict == NULL) ? "New" : "Known", - retries, - (retries == 1) ? "try" : "tries", - path, - unit); + SC_log(LOG_INFO, "%s interface named after %d %s\n" + " path = %@\n" + " unit = %@", + (dbdict == NULL) ? "New" : "Known", + retries, + (retries == 1) ? "try" : "tries", + path, + unit); #ifdef SHOW_NAMING_FAILURE str = CFStringCreateWithFormat(NULL, @@ -1716,16 +1700,12 @@ nameInterfaces(CFMutableArrayRef if_list) new_unit = _SCNetworkInterfaceGetIOInterfaceUnit(new_interface); if (CFEqual(unit, new_unit) == FALSE) { - SCLog(S_debug, LOG_INFO, - CFSTR(MY_PLUGIN_NAME - ": interface type %@ assigned " - "unit %@ instead of %@"), - type, new_unit, unit); - } - if (S_debug) { - displayInterface(new_interface); + SC_log(LOG_INFO, "interface type %@ assigned unit %@ instead of %@", + type, new_unit, unit); } + displayInterface(new_interface); + // update if_list (with the interface name & unit) CFArraySetValueAtIndex(if_list, i, new_interface); CFRelease(new_interface); @@ -1736,8 +1716,7 @@ nameInterfaces(CFMutableArrayRef if_list) // update the list of [built-in] interfaces that were previously named if (lookupInterfaceByUnit(S_prev_active_list, interface, &where) != NULL) { - SCLog(S_debug, LOG_INFO, - CFSTR(MY_PLUGIN_NAME ": and updated database (new address)")); + SC_log(LOG_DEBUG, " and updated database (new address)"); CFArrayRemoveValueAtIndex(S_prev_active_list, where); } } @@ -1763,7 +1742,7 @@ updateNetworkConfiguration(CFArrayRef if_list) set = SCNetworkSetCopyCurrent(prefs); if (set == NULL) { - SCLog(TRUE, LOG_ERR, CFSTR(MY_PLUGIN_NAME ": No current set")); + SC_log(LOG_INFO, "No current set"); goto done; } @@ -1773,9 +1752,8 @@ updateNetworkConfiguration(CFArrayRef if_list) interface = CFArrayGetValueAtIndex(if_list, i); if (SCNetworkSetEstablishDefaultInterfaceConfiguration(set, interface)) { - SCLog(TRUE, LOG_INFO, - CFSTR(MY_PLUGIN_NAME ": adding default configuration for %@"), - SCNetworkInterfaceGetBSDName(interface)); + SC_log(LOG_INFO, "adding default configuration for %@", + SCNetworkInterfaceGetBSDName(interface)); do_commit = TRUE; } } @@ -1785,17 +1763,13 @@ updateNetworkConfiguration(CFArrayRef if_list) ok = SCPreferencesCommitChanges(prefs); if (!ok) { - SCLog(TRUE, LOG_INFO, - CFSTR(MY_PLUGIN_NAME ": updateNetworkConfiguration: SCPreferencesCommitChanges() failed: %s"), - SCErrorString(SCError())); + SC_log(LOG_NOTICE, "SCPreferencesCommitChanges() failed: %s", SCErrorString(SCError())); goto done; } ok = SCPreferencesApplyChanges(prefs); if (!ok) { - SCLog(TRUE, LOG_INFO, - CFSTR(MY_PLUGIN_NAME ": updateNetworkConfiguration: SCPreferencesApplyChanges() failed: %s"), - SCErrorString(SCError())); + SC_log(LOG_NOTICE, "SCPreferencesApplyChanges() failed: %s", SCErrorString(SCError())); goto done; } } @@ -1866,35 +1840,32 @@ updateInterfaces() } if (S_prev_active_list != NULL) { - if (S_debug) { - CFIndex i; - CFIndex n; - - n = CFArrayGetCount(S_prev_active_list); - if (n > 0) { - SCLog(TRUE, LOG_INFO, - CFSTR(MY_PLUGIN_NAME ": Interface%s not [yet] active"), - (n > 1) ? "s" : ""); - } - for (i = 0; i < n; i++) { - CFDictionaryRef if_dict; - CFStringRef name; - CFNumberRef type; - CFNumberRef unit; - - if_dict = CFArrayGetValueAtIndex(S_prev_active_list, i); - name = CFDictionaryGetValue(if_dict, CFSTR(kIOBSDNameKey)); - type = CFDictionaryGetValue(if_dict, CFSTR(kIOInterfaceType)); - unit = CFDictionaryGetValue(if_dict, CFSTR(kIOInterfaceUnit)); - SCLog(TRUE, LOG_INFO, - CFSTR(MY_PLUGIN_NAME ": %s%@%sType: %@, Unit: %@"), - (name != NULL) ? "BSD Name: " : "", - (name != NULL) ? name : CFSTR(""), - (name != NULL) ? ", " : "", - type, - unit); - } + CFIndex i; + CFIndex n; + + n = CFArrayGetCount(S_prev_active_list); + if (n > 0) { + SC_log(LOG_INFO, "Interface%s not [yet] active", + (n > 1) ? "s" : ""); + } + for (i = 0; i < n; i++) { + CFDictionaryRef if_dict; + CFStringRef name; + CFNumberRef type; + CFNumberRef unit; + + if_dict = CFArrayGetValueAtIndex(S_prev_active_list, i); + name = CFDictionaryGetValue(if_dict, CFSTR(kIOBSDNameKey)); + type = CFDictionaryGetValue(if_dict, CFSTR(kIOInterfaceType)); + unit = CFDictionaryGetValue(if_dict, CFSTR(kIOInterfaceUnit)); + SC_log(LOG_INFO, " %s%@%sType: %@, Unit: %@", + (name != NULL) ? "BSD Name: " : "", + (name != NULL) ? name : CFSTR(""), + (name != NULL) ? ", " : "", + type, + unit); } + CFRelease(S_prev_active_list); S_prev_active_list = NULL; } @@ -1905,8 +1876,7 @@ updateInterfaces() * were used during the previous boot. */ addTimestamp(S_state, CFSTR("*RELEASE*")); - SCLog(S_debug, LOG_INFO, - CFSTR(MY_PLUGIN_NAME ": last boot interfaces have been named")); + SC_log(LOG_INFO, "last boot interfaces have been named"); updateStore(); CFRelease(S_prev_active_list); S_prev_active_list = NULL; @@ -1916,178 +1886,14 @@ updateInterfaces() return; } -#if !TARGET_OS_EMBEDDED -static CFComparisonResult -compareMacAddress(const void *val1, const void *val2, void *context) -{ - CFDataRef mac1 = (CFDataRef)val1; - CFDataRef mac2 = (CFDataRef)val2; - CFIndex n1; - CFIndex n2; - CFComparisonResult res; - - n1 = CFDataGetLength(mac1); - n2 = CFDataGetLength(mac2); - if (n1 < n2) { - res = kCFCompareLessThan; - } else if (n2 > n1) { - res = kCFCompareGreaterThan; - } else { - res = bcmp(CFDataGetBytePtr(mac1), CFDataGetBytePtr(mac2), n1); - } - - return res; -} - -static CFStringRef -copyEthernetUUID() -{ - CFDataRef addr; - CFMutableArrayRef addrs = NULL; - CFStringRef guid = NULL; - CFIndex i; - CFIndex n; - - addrs = CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks); - n = (S_dblist != NULL) ? CFArrayGetCount(S_dblist) : 0; - for (i = 0; i < n; i++) { - CFBooleanRef builtin; - CFDictionaryRef dict; - CFStringRef type; - - dict = CFArrayGetValueAtIndex(S_dblist, i); - type = CFDictionaryGetValue(dict, CFSTR(kSCNetworkInterfaceType)); - if (!isA_CFString(type) || !CFEqual(type, kSCNetworkInterfaceTypeEthernet)) { - continue; - } - builtin = CFDictionaryGetValue(dict, CFSTR(kIOBuiltin)); - if (!isA_CFBoolean(builtin) || !CFBooleanGetValue(builtin)) { - continue; - } - addr = CFDictionaryGetValue(dict, CFSTR(kIOMACAddress)); - if (!isA_CFData(addr) || (CFDataGetLength(addr) != ETHER_ADDR_LEN)) { - continue; - } - CFArrayAppendValue(addrs, addr); - } - - if (CFArrayGetCount(addrs) == 0) { - // if no ethernet interfaces, look for wireless - for (i = 0; i < n; i++) { - CFDictionaryRef dict; - CFStringRef type; - - dict = CFArrayGetValueAtIndex(S_dblist, i); - type = CFDictionaryGetValue(dict, CFSTR(kSCNetworkInterfaceType)); - if (!isA_CFString(type) || !CFEqual(type, kSCNetworkInterfaceTypeIEEE80211)) { - continue; - } - addr = CFDictionaryGetValue(dict, CFSTR(kIOMACAddress)); - if (!isA_CFData(addr) || (CFDataGetLength(addr) != ETHER_ADDR_LEN)) { - continue; - } - CFArrayAppendValue(addrs, addr); - } - } - - n = CFArrayGetCount(addrs); - switch (n) { - case 0 : - // if no network interfaces - break; - default : - // sort by MAC address - CFArraySortValues(addrs, CFRangeMake(0, n), compareMacAddress, NULL); - - // fall through - case 1 : { - CFUUIDBytes bytes = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, - 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; - CFUUIDRef uuid; - - // set GUID - addr = CFArrayGetValueAtIndex(addrs, 0); - bcopy(CFDataGetBytePtr(addr), - (void *)&bytes + sizeof(bytes) - ETHER_ADDR_LEN, - ETHER_ADDR_LEN); - uuid = CFUUIDCreateFromUUIDBytes(NULL, bytes); - guid = CFUUIDCreateString(NULL, uuid); - CFRelease(uuid); - - SCLog(TRUE, LOG_INFO, - CFSTR(MY_PLUGIN_NAME ": setting platform UUID [MAC] = %@"), - guid); - break; - } - } - - if (addrs != NULL) CFRelease(addrs); - return guid; -} - -#ifndef kIOPlatformUUIDKey -#define kIOPlatformUUIDKey "IOPlatformUUID" -#endif -static void -updatePlatformUUID() -{ - CFStringRef guid = NULL; - kern_return_t kr; - io_registry_entry_t platform; - - platform = IORegistryEntryFromPath(kIOMasterPortDefault, kIODeviceTreePlane ":/"); - if (platform == MACH_PORT_NULL) { - goto done; - } - - guid = IORegistryEntryCreateCFProperty(platform, CFSTR(kIOPlatformUUIDKey), NULL, 0); - if (guid != NULL) { - // if GUID already defined - goto done; - } - - guid = copyEthernetUUID(); - if (guid == NULL) { - CFUUIDRef uuid; - - uuid = CFUUIDCreate(NULL); - guid = CFUUIDCreateString(NULL, uuid); - CFRelease(uuid); - - SCLog(TRUE, LOG_INFO, - CFSTR(MY_PLUGIN_NAME ": setting platform UUID [random] = %@"), - guid); - } - -if (getenv("DO_NOT_SET_PLATFORM_UUID") == NULL) { - kr = IORegistryEntrySetCFProperty(platform, CFSTR(kIOPlatformUUIDKey), guid); - if (kr != KERN_SUCCESS) { - SCLog(TRUE, LOG_ERR, - CFSTR(MY_PLUGIN_NAME ": IORegistryEntrySetCFProperty(platform UUID) failed, kr=0x%x"), - kr); - } -} - - addTimestamp(S_state, CFSTR("*PLATFORM-UUID*")); - updateStore(); - - done : - - if (S_vproc_transaction != NULL) { - vproc_transaction_end(NULL, S_vproc_transaction); - S_vproc_transaction = NULL; - } - - if (platform != MACH_PORT_NULL) IOObjectRelease(platform); - if (guid != NULL) CFRelease(guid); - return; -} -#endif // !TARGET_OS_EMBEDDED - static void interfaceArrivalCallback(void *refcon, io_iterator_t iter) { - io_object_t obj; + os_activity_t activity_id; + io_object_t obj; + + activity_id = os_activity_start("process new network interface", + OS_ACTIVITY_FLAG_DEFAULT); while ((obj = IOIteratorNext(iter)) != MACH_PORT_NULL) { SCNetworkInterfaceRef interface; @@ -2104,6 +1910,9 @@ interfaceArrivalCallback(void *refcon, io_iterator_t iter) } updateInterfaces(); + + os_activity_end(activity_id); + return; } @@ -2119,9 +1928,13 @@ interfaceArrivalCallback(void *refcon, io_iterator_t iter) static void stackCallback(void *refcon, io_iterator_t iter) { + os_activity_t activity_id; kern_return_t kr; io_object_t stack; + activity_id = os_activity_start("process IONetworkStack", + OS_ACTIVITY_FLAG_DEFAULT); + stack = IOIteratorNext(iter); if (stack == MACH_PORT_NULL) { goto error; @@ -2129,15 +1942,12 @@ stackCallback(void *refcon, io_iterator_t iter) kr = IOServiceOpen(stack, mach_task_self(), 0, &S_connect); if (kr != KERN_SUCCESS) { - SCLog(TRUE, LOG_ERR, - CFSTR(MY_PLUGIN_NAME ": IOServiceOpen returned 0x%x"), - kr); + SC_log(LOG_ERR, "IOServiceOpen returned 0x%x", kr); goto error; } addTimestamp(S_state, CFSTR("*STACK*")); - SCLog(S_debug, LOG_INFO, - CFSTR(MY_PLUGIN_NAME ": IONetworkStack found")); + SC_log(LOG_INFO, "IONetworkStack found"); if (S_stack != MACH_PORT_NULL) { IOObjectRelease(S_stack); @@ -2155,10 +1965,13 @@ stackCallback(void *refcon, io_iterator_t iter) updateInterfaces(); error: + if (stack != MACH_PORT_NULL) { IOObjectRelease(stack); } + os_activity_end(activity_id); + return; } @@ -2168,21 +1981,24 @@ quietCallback(void *refcon, natural_t messageType, void *messageArgument) { + os_activity_t activity_id; + if (messageArgument != NULL) { // if not yet quiet return; } + activity_id = os_activity_start("process IOKit quiet", + OS_ACTIVITY_FLAG_DEFAULT); + if (messageType == kIOMessageServiceBusyStateChange) { addTimestamp(S_state, CFSTR("*QUIET*")); - SCLog(S_debug, LOG_INFO, - CFSTR(MY_PLUGIN_NAME ": IOKit quiet")); + SC_log(LOG_INFO, "IOKit quiet"); } if (S_connect == MACH_PORT_NULL) { - SCLog(TRUE, LOG_ERR, - CFSTR(MY_PLUGIN_NAME ": No network stack object")); - return; + SC_log(LOG_ERR, "No network stack object"); + goto done; } if (S_quiet != MACH_PORT_NULL) { @@ -2199,9 +2015,14 @@ quietCallback(void *refcon, // grab (and name) any additional interfaces. interfaceArrivalCallback((void *)S_notify, S_iter); -#if !TARGET_OS_EMBEDDED - updatePlatformUUID(); -#endif // !TARGET_OS_EMBEDDED + if (messageType == kIOMessageServiceBusyStateChange) { + addTimestamp(S_state, CFSTR("*QUIET&NAMED*")); + updateStore(); + } + + done : + + os_activity_end(activity_id); return; } @@ -2231,9 +2052,7 @@ iterateRegistryBusy(io_iterator_t iterator, CFArrayRef nodes, CFMutableStringRef kr = IORegistryEntryGetName(obj, name); if (kr != kIOReturnSuccess) { - SCLog(TRUE, LOG_ERR, - CFSTR(MY_PLUGIN_NAME ": captureBusy IORegistryEntryGetName returned 0x%x"), - kr); + SC_log(LOG_NOTICE, "IORegistryEntryGetName() returned 0x%x", kr); goto next; } @@ -2249,9 +2068,7 @@ iterateRegistryBusy(io_iterator_t iterator, CFArrayRef nodes, CFMutableStringRef case kIOReturnNotFound : break; default : - SCLog(TRUE, LOG_ERR, - CFSTR(MY_PLUGIN_NAME ": captureBusy IORegistryEntryGetLocationInPlane returned 0x%x"), - kr); + SC_log(LOG_NOTICE, "IORegistryEntryGetLocationInPlane() returned 0x%x", kr); CFRelease(str); goto next; } @@ -2261,9 +2078,7 @@ iterateRegistryBusy(io_iterator_t iterator, CFArrayRef nodes, CFMutableStringRef kr = IOServiceGetBusyStateAndTime(obj, &state, &busy_state, &accumulated_busy_time); if (kr != kIOReturnSuccess) { - SCLog(TRUE, LOG_ERR, - CFSTR(MY_PLUGIN_NAME ": captureBusy IOServiceGetBusyStateAndTime returned 0x%x"), - kr); + SC_log(LOG_NOTICE, "IOServiceGetBusyStateAndTime() returned 0x%x", kr); goto next; } @@ -2293,9 +2108,7 @@ iterateRegistryBusy(io_iterator_t iterator, CFArrayRef nodes, CFMutableStringRef kr = IORegistryIteratorEnterEntry(iterator); if (kr != kIOReturnSuccess) { - SCLog(TRUE, LOG_ERR, - CFSTR(MY_PLUGIN_NAME ": captureBusy IORegistryIteratorEnterEntry returned 0x%x"), - kr); + SC_log(LOG_NOTICE, "IORegistryIteratorEnterEntry() returned 0x%x", kr); goto next; } @@ -2303,9 +2116,7 @@ iterateRegistryBusy(io_iterator_t iterator, CFArrayRef nodes, CFMutableStringRef kr = IORegistryIteratorExitEntry(iterator); if (kr != kIOReturnSuccess) { - SCLog(TRUE, LOG_ERR, - CFSTR(MY_PLUGIN_NAME ": captureBusy IORegistryIteratorExitEntry returned 0x%x"), - kr); + SC_log(LOG_NOTICE, "IORegistryIteratorExitEntry() returned 0x%x", kr); } next : @@ -2332,9 +2143,7 @@ captureBusy() 0, &iterator); if (kr != kIOReturnSuccess) { - SCLog(TRUE, LOG_ERR, - CFSTR(MY_PLUGIN_NAME ": captureBusy IORegistryCreateIterator returned 0x%x"), - kr); + SC_log(LOG_NOTICE, "IORegistryCreateIterator() returned 0x%x", kr); return snapshot; } @@ -2350,7 +2159,11 @@ captureBusy() static void timerCallback(CFRunLoopTimerRef timer, void *info) { - CFStringRef snapshot; + os_activity_t activity_id; + CFStringRef snapshot; + + activity_id = os_activity_start("process IOKit timer", + OS_ACTIVITY_FLAG_DEFAULT); // We've been waiting for IOKit to quiesce and it just // hasn't happenned. Time to just move on! @@ -2358,13 +2171,17 @@ timerCallback(CFRunLoopTimerRef timer, void *info) // log busy nodes snapshot = captureBusy(); - SCLog(TRUE, LOG_ERR, - CFSTR(MY_PLUGIN_NAME ": timed out waiting for IOKit to quiesce\n%@"), - snapshot); + SC_log(LOG_ERR, "timed out waiting for IOKit to quiesce\n%@", snapshot); reportIssue("timed out waiting for IOKit to quiesce", snapshot); CFRelease(snapshot); quietCallback((void *)S_notify, MACH_PORT_NULL, 0, NULL); + + addTimestamp(S_state, CFSTR("*TIMEOUT&NAMED*")); + updateStore(); + + os_activity_end(activity_id); + return; } @@ -2402,24 +2219,20 @@ setup_IOKit(CFBundleRef bundle) // notifications of new devices or state changes. kr = IOMasterPort(bootstrap_port, &masterPort); if (kr != KERN_SUCCESS) { - SCLog(TRUE, LOG_ERR, - CFSTR(MY_PLUGIN_NAME ": IOMasterPort returned 0x%x"), - kr); + SC_log(LOG_ERR, "IOMasterPort returned 0x%x", kr); goto done; } S_notify = IONotificationPortCreate(masterPort); if (S_notify == NULL) { - SCLog(TRUE, LOG_ERR, - CFSTR(MY_PLUGIN_NAME ": IONotificationPortCreate failed")); + SC_log(LOG_ERR, "IONotificationPortCreate failed"); goto done; } // watch IOKit matching activity root = IORegistryEntryFromPath(masterPort, kIOServicePlane ":/"); if (root == MACH_PORT_NULL) { - SCLog(TRUE, LOG_ERR, - CFSTR(MY_PLUGIN_NAME ": IORegistryEntryFromPath failed")); + SC_log(LOG_ERR, "IORegistryEntryFromPath failed"); goto done; } @@ -2430,17 +2243,13 @@ setup_IOKit(CFBundleRef bundle) (void *)S_notify, // refCon &S_quiet); // notification if (kr != KERN_SUCCESS) { - SCLog(TRUE, LOG_ERR, - CFSTR(MY_PLUGIN_NAME ": IOServiceAddInterestNotification returned 0x%x"), - kr); + SC_log(LOG_ERR, "IOServiceAddInterestNotification returned 0x%x", kr); goto done; } kr = IOServiceGetBusyState(root, &busy); if (kr != KERN_SUCCESS) { - SCLog(TRUE, LOG_ERR, - CFSTR(MY_PLUGIN_NAME ": IOServiceGetBusyState returned 0x%x"), - kr); + SC_log(LOG_ERR, "IOServiceGetBusyState returned 0x%x", kr); goto done; } @@ -2453,8 +2262,7 @@ setup_IOKit(CFBundleRef bundle) timerCallback, NULL); if (S_timer == NULL) { - SCLog(TRUE, LOG_ERR, - CFSTR(MY_PLUGIN_NAME ": CFRunLoopTimerCreate failed")); + SC_log(LOG_ERR, "CFRunLoopTimerCreate failed"); goto done; } @@ -2468,9 +2276,7 @@ setup_IOKit(CFBundleRef bundle) (void *)S_notify, // refCon &S_stack); // notification if (kr != KERN_SUCCESS) { - SCLog(TRUE, LOG_ERR, - CFSTR(MY_PLUGIN_NAME ": IOServiceAddMatchingNotification returned 0x%x"), - kr); + SC_log(LOG_ERR, "IOServiceAddMatchingNotification returned 0x%x", kr); goto done; } @@ -2486,9 +2292,7 @@ setup_IOKit(CFBundleRef bundle) (void *)S_notify, // refCon &S_iter); // notification if (kr != KERN_SUCCESS) { - SCLog(TRUE, LOG_ERR, - CFSTR(MY_PLUGIN_NAME ": IOServiceAddMatchingNotification returned 0x%x"), - kr); + SC_log(LOG_ERR, "IOServiceAddMatchingNotification returned 0x%x", kr); goto done; } @@ -2553,17 +2357,14 @@ setup_Virtual(CFBundleRef bundle) // open a SCPreferences session S_prefs = SCPreferencesCreate(NULL, CFSTR(MY_PLUGIN_NAME), NULL); if (S_prefs == NULL) { - SCLog(TRUE, LOG_ERR, - CFSTR(MY_PLUGIN_NAME ": SCPreferencesCreate() failed: %s"), - SCErrorString(SCError())); + SC_log(LOG_ERR, "SCPreferencesCreate() failed: %s", + SCErrorString(SCError())); return FALSE; } // register for change notifications. if (!SCPreferencesSetCallback(S_prefs, updateVirtualNetworkInterfaceConfiguration, NULL)) { - SCLog(TRUE, LOG_ERR, - CFSTR(MY_PLUGIN_NAME ": SCPreferencesSetCallBack() failed: %s"), - SCErrorString(SCError())); + SC_log(LOG_ERR, "SCPreferencesSetCallBack() failed: %s", SCErrorString(SCError())); CFRelease(S_prefs); return FALSE; } @@ -2571,9 +2372,7 @@ setup_Virtual(CFBundleRef bundle) // schedule if (!SCPreferencesScheduleWithRunLoop(S_prefs, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode)) { if (SCError() != kSCStatusNoStoreServer) { - SCLog(TRUE, LOG_ERR, - CFSTR(MY_PLUGIN_NAME ": SCPreferencesScheduleWithRunLoop() failed: %s"), - SCErrorString(SCError())); + SC_log(LOG_ERR, "SCPreferencesScheduleWithRunLoop() failed: %s", SCErrorString(SCError())); CFRelease(S_prefs); return FALSE; } @@ -2599,8 +2398,7 @@ exec_InterfaceNamer(void *arg) if (!isA_CFNumber(num) || !CFNumberGetValue(num, kCFNumberDoubleType, &S_stack_timeout) || (S_stack_timeout <= 0.0)) { - SCLog(TRUE, LOG_ERR, - CFSTR(MY_PLUGIN_NAME ": " WAIT_STACK_TIMEOUT_KEY " value error")); + SC_log(LOG_NOTICE, WAIT_STACK_TIMEOUT_KEY " value error"); S_stack_timeout = WAIT_STACK_TIMEOUT_DEFAULT; } } @@ -2610,8 +2408,7 @@ exec_InterfaceNamer(void *arg) if (!isA_CFNumber(num) || !CFNumberGetValue(num, kCFNumberDoubleType, &S_quiet_timeout) || (S_quiet_timeout <= 0.0)) { - SCLog(TRUE, LOG_ERR, - CFSTR(MY_PLUGIN_NAME ": " WAIT_QUIET_TIMEOUT_KEY " value error")); + SC_log(LOG_NOTICE, WAIT_QUIET_TIMEOUT_KEY " value error"); S_quiet_timeout = WAIT_QUIET_TIMEOUT_DEFAULT; } } @@ -2627,12 +2424,6 @@ exec_InterfaceNamer(void *arg) goto error; } -#if !TARGET_OS_EMBEDDED - // keep launchd from SIGKILL'ing us until after the platform-uuid has - // been updated - S_vproc_transaction = vproc_transaction_begin(NULL); -#endif // !TARGET_OS_EMBEDDED - goto done; error : @@ -2683,10 +2474,6 @@ load_InterfaceNamer(CFBundleRef bundle, Boolean bundleVerbose) pthread_attr_t tattr; pthread_t tid; - if (bundleVerbose) { - S_debug = TRUE; - } - CFRetain(bundle); // released in exec_InterfaceNamer pthread_attr_init(&tattr); @@ -2710,8 +2497,6 @@ main(int argc, char ** argv) _sc_log = FALSE; _sc_verbose = (argc > 1) ? TRUE : FALSE; - S_debug = _sc_verbose; - bundle = CFBundleGetMainBundle(); CFRetain(bundle); // released in exec_InterfaceNamer @@ -2723,46 +2508,6 @@ main(int argc, char ** argv) } #endif /* MAIN */ -#ifdef TEST_PLATFORM_UUID -int -main(int argc, char ** argv) -{ - CFStringRef guid; - CFArrayRef interfaces; - - _sc_log = FALSE; - _sc_verbose = (argc > 1) ? TRUE : FALSE; - - S_dblist = CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks); - interfaces = SCNetworkInterfaceCopyAll(); - if (interfaces != NULL) { - CFIndex i; - CFIndex n; - - n = CFArrayGetCount(interfaces); - for (i = 0; i < n; i++) { - CFDictionaryRef dict; - SCNetworkInterfaceRef interface; - - interface = CFArrayGetValueAtIndex(interfaces, i); - dict = createInterfaceDict(interface); - CFArrayAppendValue(S_dblist, dict); - CFRelease(dict); - } - CFRelease(interfaces); - } - - guid = copyEthernetUUID(); - SCPrint(TRUE, stdout, CFSTR("copyEthernetUUID() = %@\n"), (guid != NULL) ? guid : CFSTR("NULL")); - if (guid != NULL) CFRelease(guid); - - updatePlatformUUID(); - CFRelease(S_dblist); - exit(0); - return 0; -} -#endif /* TEST_PLATFORM_UUID */ - #ifdef TEST_SNAPSHOT int main(int argc, char ** argv) diff --git a/Plugins/KernelEventMonitor/Info.plist b/Plugins/KernelEventMonitor/Info.plist index a56faba..327a47a 100644 --- a/Plugins/KernelEventMonitor/Info.plist +++ b/Plugins/KernelEventMonitor/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType BNDL CFBundleShortVersionString - 1.14.4 + 1.14 CFBundleSignature ???? CFBundleVersion diff --git a/Plugins/KernelEventMonitor/ev_dlil.c b/Plugins/KernelEventMonitor/ev_dlil.c index 03b6834..0e296ef 100644 --- a/Plugins/KernelEventMonitor/ev_dlil.c +++ b/Plugins/KernelEventMonitor/ev_dlil.c @@ -1,15 +1,15 @@ /* - * Copyright (c) 2002-2006, 2009, 2011, 2013 Apple Inc. All rights reserved. + * Copyright (c) 2002-2006, 2009, 2011, 2013, 2015 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ - * + * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. - * + * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, @@ -17,7 +17,7 @@ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. - * + * * @APPLE_LICENSE_HEADER_END@ */ @@ -106,8 +106,10 @@ interface_update_status(const char *if_name, /* update status */ if (CFDictionaryGetCount(newDict) > 0) { + SC_log(LOG_DEBUG, "Update interface link status: %s: %@", if_name, newDict); cache_SCDynamicStoreSetValue(store, key, newDict); } else { + SC_log(LOG_DEBUG, "Update interface link status: %s: ", if_name); cache_SCDynamicStoreRemoveValue(store, key); } @@ -156,8 +158,10 @@ interface_update_quality_metric(const char *if_name, /* update status */ if (CFDictionaryGetCount(newDict) > 0) { + SC_log(LOG_DEBUG, "Update interface link quality: %s: %@", if_name, newDict); cache_SCDynamicStoreSetValue(store, key, newDict); } else { + SC_log(LOG_DEBUG, "Update interface link quality: %s: ", if_name); cache_SCDynamicStoreRemoveValue(store, key); } @@ -177,7 +181,6 @@ link_update_quality_metric(const char *if_name) sock = dgram_socket(AF_INET); if (sock == -1) { - SCLog(TRUE, LOG_NOTICE, CFSTR("socket_get_link_quality: socket open failed, %s"), strerror(errno)); goto done; } @@ -250,6 +253,7 @@ interface_update_link_issues(const char *if_name, CFDictionarySetValue(newDict, kSCPropNetLinkIssuesTimeStamp, timeStamp); CFRelease(timeStamp); + SC_log(LOG_DEBUG, "Update interface link issues: %s: %@", if_name, newDict); cache_SCDynamicStoreSetValue(store, key, newDict); CFRelease(newDict); CFRelease(key); @@ -265,6 +269,8 @@ interface_detaching(const char *if_name) CFStringRef key; CFMutableDictionaryRef newDict; + SC_log(LOG_DEBUG, "Detach interface: %s", if_name); + key = create_interface_key(if_name); newDict = copy_entity(key); CFDictionarySetValue(newDict, kSCPropNetLinkDetaching, @@ -281,6 +287,8 @@ interface_remove(const char *if_name) { CFStringRef key; + SC_log(LOG_DEBUG, "Remove interface: %s", if_name); + key = create_interface_key(if_name); cache_SCDynamicStoreRemoveValue(store, key); CFRelease(key); @@ -312,7 +320,6 @@ link_update_status(const char *if_name, boolean_t attach) sock = dgram_socket(AF_INET); if (sock == -1) { - SCLog(TRUE, LOG_NOTICE, CFSTR("link_update_status: socket open failed, %s"), strerror(errno)); return; } @@ -352,112 +359,148 @@ link_update_status(const char *if_name, boolean_t attach) return; } + __private_extern__ -void -link_add(const char *if_name) +CFMutableArrayRef +interfaceListCopy(void) { - CFStringRef interface; CFStringRef cacheKey; CFDictionaryRef dict; - CFMutableDictionaryRef newDict = NULL; - CFArrayRef ifList; - CFMutableArrayRef newIFList = NULL; - - interface = CFStringCreateWithCString(NULL, if_name, kCFStringEncodingMacRoman); - cacheKey = SCDynamicStoreKeyCreateNetworkInterface(NULL, - kSCDynamicStoreDomainState); + CFMutableArrayRef ret_ifList = NULL; + cacheKey = SCDynamicStoreKeyCreateNetworkInterface(NULL, + kSCDynamicStoreDomainState); dict = cache_SCDynamicStoreCopyValue(store, cacheKey); - if (dict) { - if (isA_CFDictionary(dict)) { - newDict = CFDictionaryCreateMutableCopy(NULL, 0, dict); - ifList = CFDictionaryGetValue(newDict, kSCPropNetInterfaces); - if (isA_CFArray(ifList)) { - newIFList = CFArrayCreateMutableCopy(NULL, 0, ifList); + CFRelease(cacheKey); + if (dict != NULL) { + if (isA_CFDictionary(dict) != NULL) { + CFArrayRef ifList; + + ifList = CFDictionaryGetValue(dict, kSCPropNetInterfaces); + if (isA_CFArray(ifList) != NULL) { + ret_ifList = CFArrayCreateMutableCopy(NULL, 0, ifList); } } CFRelease(dict); } + if (ret_ifList == NULL) { + ret_ifList = CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks); + } + return (ret_ifList); +} - if (!newDict) { - newDict = CFDictionaryCreateMutable(NULL, - 0, - &kCFTypeDictionaryKeyCallBacks, - &kCFTypeDictionaryValueCallBacks); + +__private_extern__ +void +interfaceListUpdate(CFArrayRef ifList) +{ + CFStringRef cacheKey; + CFDictionaryRef dict; + + cacheKey = SCDynamicStoreKeyCreateNetworkInterface(NULL, + kSCDynamicStoreDomainState); + dict = cache_SCDynamicStoreCopyValue(store, cacheKey); + if (dict != NULL && isA_CFDictionary(dict) == NULL) { + CFRelease(dict); + dict = NULL; } + if (dict == NULL) { + dict = CFDictionaryCreate(NULL, + (const void * *)&kSCPropNetInterfaces, + (const void * *)&ifList, + 1, + &kCFTypeDictionaryKeyCallBacks, + &kCFTypeDictionaryValueCallBacks); + cache_SCDynamicStoreSetValue(store, cacheKey, dict); + CFRelease(dict); - if (!newIFList) { - newIFList = CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks); } + else { + CFMutableDictionaryRef newDict; - if (CFArrayContainsValue(newIFList, - CFRangeMake(0, CFArrayGetCount(newIFList)), - interface) == FALSE) { - CFArrayAppendValue(newIFList, interface); - CFDictionarySetValue(newDict, kSCPropNetInterfaces, newIFList); + newDict = CFDictionaryCreateMutableCopy(NULL, 0, dict); + CFRelease(dict); + CFDictionarySetValue(newDict, kSCPropNetInterfaces, ifList); + cache_SCDynamicStoreSetValue(store, cacheKey, newDict); + CFRelease(newDict); } - cache_SCDynamicStoreSetValue(store, cacheKey, newDict); - link_update_status(if_name, TRUE); -#ifdef KEV_DL_LINK_QUALITY_METRIC_CHANGED - link_update_quality_metric(if_name); -#endif /* KEV_DL_LINK_QUALITY_METRIC_CHANGED */ CFRelease(cacheKey); - CFRelease(interface); - if (newDict) CFRelease(newDict); - if (newIFList) CFRelease(newIFList); return; } __private_extern__ -void -link_remove(const char *if_name) +Boolean +interfaceListAddInterface(CFMutableArrayRef ifList, const char * if_name) { - CFStringRef interface; - CFStringRef cacheKey; - CFDictionaryRef dict; - CFMutableDictionaryRef newDict = NULL; - CFArrayRef ifList; - CFMutableArrayRef newIFList = NULL; - CFIndex i; + Boolean added = FALSE; + CFStringRef interface; interface = CFStringCreateWithCString(NULL, if_name, kCFStringEncodingMacRoman); - cacheKey = SCDynamicStoreKeyCreateNetworkInterface(NULL, - kSCDynamicStoreDomainState); - - dict = cache_SCDynamicStoreCopyValue(store, cacheKey); - if (dict) { - if (isA_CFDictionary(dict)) { - newDict = CFDictionaryCreateMutableCopy(NULL, 0, dict); - ifList = CFDictionaryGetValue(newDict, kSCPropNetInterfaces); - if (isA_CFArray(ifList)) { - newIFList = CFArrayCreateMutableCopy(NULL, 0, ifList); - } - } - CFRelease(dict); + if (CFArrayContainsValue(ifList, + CFRangeMake(0, CFArrayGetCount(ifList)), + interface) == FALSE) { + /* interface was added, prime the link-specific values */ + added = TRUE; + CFArrayAppendValue(ifList, interface); + link_update_status(if_name, TRUE); +#ifdef KEV_DL_LINK_QUALITY_METRIC_CHANGED + link_update_quality_metric(if_name); +#endif /* KEV_DL_LINK_QUALITY_METRIC_CHANGED */ } + CFRelease(interface); + return (added); +} - if (!newIFList || - ((i = CFArrayGetFirstIndexOfValue(newIFList, - CFRangeMake(0, CFArrayGetCount(newIFList)), - interface)) == kCFNotFound) - ) { - /* we're not tracking this interface */ - goto done; + +static Boolean +interfaceListRemoveInterface(CFMutableArrayRef ifList, const char * if_name) +{ + CFStringRef interface; + CFIndex where; + + interface = CFStringCreateWithCString(NULL, if_name, kCFStringEncodingMacRoman); + where = CFArrayGetFirstIndexOfValue(ifList, + CFRangeMake(0, CFArrayGetCount(ifList)), + interface); + CFRelease(interface); + if (where != kCFNotFound) { + CFArrayRemoveValueAtIndex(ifList, where); + interface_remove(if_name); } + return (where != kCFNotFound); +} - CFArrayRemoveValueAtIndex(newIFList, i); - CFDictionarySetValue(newDict, kSCPropNetInterfaces, newIFList); - cache_SCDynamicStoreSetValue(store, cacheKey, newDict); - interface_remove(if_name); +__private_extern__ +void +link_add(const char *if_name) +{ + CFMutableArrayRef ifList; - done: + ifList = interfaceListCopy(); + if (interfaceListAddInterface(ifList, if_name)) { + /* interface was added, update the global list */ + messages_add_msg_with_arg("link_add", if_name); + interfaceListUpdate(ifList); + } + CFRelease(ifList); + return; +} - CFRelease(cacheKey); - CFRelease(interface); - if (newDict) CFRelease(newDict); - if (newIFList) CFRelease(newIFList); + +__private_extern__ +void +link_remove(const char *if_name) +{ + CFMutableArrayRef ifList; + + ifList = interfaceListCopy(); + if (interfaceListRemoveInterface(ifList, if_name)) { + /* interface was removed, update the global list */ + interfaceListUpdate(ifList); + } + CFRelease(ifList); return; } @@ -512,6 +555,7 @@ interface_update_idle_state(const char *if_name) if_name_cf, kSCEntNetIdleRoute); + SC_log(LOG_DEBUG, "Post interface idle: %s", if_name); cache_SCDynamicStoreNotifyValue(store, key); CFRelease(key); CFRelease(if_name_cf); diff --git a/Plugins/KernelEventMonitor/ev_dlil.h b/Plugins/KernelEventMonitor/ev_dlil.h index ae3b001..e5318c8 100644 --- a/Plugins/KernelEventMonitor/ev_dlil.h +++ b/Plugins/KernelEventMonitor/ev_dlil.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2004, 2005, 2011-2013 Apple Inc. All rights reserved. + * Copyright (c) 2002-2015 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -53,6 +53,15 @@ void link_remove (const char *if_name); void link_update_status (const char *if_name, boolean_t attach); +CFMutableArrayRef +interfaceListCopy(void); + +void +interfaceListUpdate(CFArrayRef ifList); + +Boolean +interfaceListAddInterface(CFMutableArrayRef ifList, const char * if_name); + __END_DECLS #endif /* _EV_DLIL_H */ diff --git a/Plugins/KernelEventMonitor/ev_extra.m b/Plugins/KernelEventMonitor/ev_extra.m index 9b83799..8f615be 100644 --- a/Plugins/KernelEventMonitor/ev_extra.m +++ b/Plugins/KernelEventMonitor/ev_extra.m @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2014 Apple Inc. All rights reserved. + * Copyright (c) 2013-2015 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -125,7 +125,14 @@ interface_update_expensive(const char *if_name) int dgram_socket(int domain) { - return (socket(domain, SOCK_DGRAM, 0)); + int s; + + s = socket(domain, SOCK_DGRAM, 0); + if (s == -1) { + SC_log(LOG_ERR, "socket() failed: %s", strerror(errno)); + } + + return s; } int diff --git a/Plugins/KernelEventMonitor/ev_ipv4.c b/Plugins/KernelEventMonitor/ev_ipv4.c index bb5d6f1..d0b765e 100644 --- a/Plugins/KernelEventMonitor/ev_ipv4.c +++ b/Plugins/KernelEventMonitor/ev_ipv4.c @@ -1,15 +1,15 @@ /* - * Copyright (c) 2002-2014 Apple Inc. All rights reserved. + * Copyright (c) 2002-2015 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ - * + * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. - * + * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, @@ -17,7 +17,7 @@ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. - * + * * @APPLE_LICENSE_HEADER_END@ */ @@ -116,8 +116,10 @@ updateStore(const void *key, const void *value, void *context) if (!dict || !CFEqual(dict, newDict)) { if (CFDictionaryGetCount(newDict) > 0) { + SC_log(LOG_DEBUG, "Update interface configuration: %@: %@", key, newDict); cache_SCDynamicStoreSetValue(store, key, newDict); } else if (dict) { + SC_log(LOG_DEBUG, "Update interface configuration: %@: ", key); cache_SCDynamicStoreRemoveValue(store, key); } network_changed = TRUE; @@ -151,7 +153,7 @@ ipv4_interface_update(struct ifaddrs *ifap, const char *if_name) if (!ifap) { if (getifaddrs(&ifap_temp) == -1) { - SCLog(TRUE, LOG_ERR, CFSTR("getifaddrs() failed: %s"), strerror(errno)); + SC_log(LOG_NOTICE, "getifaddrs() failed: %s", strerror(errno)); goto error; } ifap = ifap_temp; @@ -260,6 +262,7 @@ ipv4_arp_collision(const char *if_name, struct in_addr ip_addr, int hw_len, cons CFStringAppendFormat(key, NULL, CFSTR("%s%02x"), (i == 0) ? "/" : ":", hw_addr_bytes[i]); } + SC_log(LOG_DEBUG, "Post ARP collision: %@", key); cache_SCDynamicStoreNotifyValue(store, key); CFRelease(key); CFRelease(prefix); @@ -281,6 +284,7 @@ ipv4_port_in_use(uint16_t port, pid_t req_pid) kSCEntNetIPv4, kSCEntNetIPv4PortInUse, port, req_pid); + SC_log(LOG_DEBUG, "Post port-in-use: %@", key); cache_SCDynamicStoreNotifyValue(store, key); CFRelease(key); return; @@ -288,7 +292,7 @@ ipv4_port_in_use(uint16_t port, pid_t req_pid) #endif /* !TARGET_OS_IPHONE */ static void -interface_notify_entity(const char * if_name, CFStringRef entity) +interface_notify_entity(const char * if_name, const char * type, CFStringRef entity) { CFStringRef if_name_cf; CFStringRef key; @@ -300,6 +304,7 @@ interface_notify_entity(const char * if_name, CFStringRef entity) if_name_cf, entity); CFRelease(if_name_cf); + SC_log(LOG_DEBUG, "Post %s: %@", type, key); cache_SCDynamicStoreNotifyValue(store, key); CFRelease(key); return; @@ -308,13 +313,13 @@ interface_notify_entity(const char * if_name, CFStringRef entity) __private_extern__ void ipv4_router_arp_failure(const char * if_name) { - interface_notify_entity(if_name, kSCEntNetIPv4RouterARPFailure); + interface_notify_entity(if_name, "Router ARP failure", kSCEntNetIPv4RouterARPFailure); return; } __private_extern__ void ipv4_router_arp_alive(const char * if_name) { - interface_notify_entity(if_name, kSCEntNetIPv4RouterARPAlive); + interface_notify_entity(if_name, "Router ARP alive", kSCEntNetIPv4RouterARPAlive); return; } diff --git a/Plugins/KernelEventMonitor/ev_ipv6.c b/Plugins/KernelEventMonitor/ev_ipv6.c index 08114b2..7b9f42e 100644 --- a/Plugins/KernelEventMonitor/ev_ipv6.c +++ b/Plugins/KernelEventMonitor/ev_ipv6.c @@ -1,15 +1,15 @@ /* - * Copyright (c) 2002-2007, 2011, 2013 Apple Inc. All rights reserved. + * Copyright (c) 2002-2007, 2011, 2013, 2015 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ - * + * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. - * + * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, @@ -17,7 +17,7 @@ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. - * + * * @APPLE_LICENSE_HEADER_END@ */ @@ -41,6 +41,9 @@ #endif #endif /* NOTYET */ +#ifndef kSCEntNetIPv6DuplicatedAddress +#define kSCEntNetIPv6DuplicatedAddress CFSTR("IPv6DuplicatedAddress") +#endif /* kSCEntNetIPv6DuplicatedAddress */ static void appendAddress(CFMutableDictionaryRef dict, CFStringRef key, struct sockaddr_in6 *sin6) @@ -48,7 +51,7 @@ appendAddress(CFMutableDictionaryRef dict, CFStringRef key, struct sockaddr_in6 CFStringRef addr; CFArrayRef addrs; CFMutableArrayRef newAddrs; - char str[64]; + char str[INET6_ADDRSTRLEN]; addrs = CFDictionaryGetValue(dict, key); if (addrs) { @@ -58,7 +61,7 @@ appendAddress(CFMutableDictionaryRef dict, CFStringRef key, struct sockaddr_in6 } if (inet_ntop(AF_INET6, (const void *)&sin6->sin6_addr, str, sizeof(str)) == NULL) { - SCLog(TRUE, LOG_ERR, CFSTR("inet_ntop() failed: %s"), strerror(errno)); + SC_log(LOG_INFO, "inet_ntop() failed: %s", strerror(errno)); str[0] = '\0'; } @@ -232,8 +235,10 @@ updateStore(const void *key, const void *value, void *context) if (!dict || !CFEqual(dict, newDict)) { if (CFDictionaryGetCount(newDict) > 0) { + SC_log(LOG_DEBUG, "Update interface configuration: %@: %@", key, newDict); cache_SCDynamicStoreSetValue(store, key, newDict); } else if (dict) { + SC_log(LOG_DEBUG, "Update interface configuration: %@: ", key); cache_SCDynamicStoreRemoveValue(store, key); } network_changed = TRUE; @@ -268,7 +273,7 @@ interface_update_ipv6(struct ifaddrs *ifap, const char *if_name) if (!ifap) { if (getifaddrs(&ifap_temp) == -1) { - SCLog(TRUE, LOG_ERR, CFSTR("getifaddrs() failed: %s"), strerror(errno)); + SC_log(LOG_NOTICE, "getifaddrs() failed: %s", strerror(errno)); goto error; } ifap = ifap_temp; @@ -295,7 +300,6 @@ interface_update_ipv6(struct ifaddrs *ifap, const char *if_name) if (sock == -1) { sock = dgram_socket(AF_INET6); if (sock == -1) { - SCLog(TRUE, LOG_NOTICE, CFSTR("interface_update_ipv6: socket open failed, %s"), strerror(errno)); goto error; } } @@ -331,9 +335,7 @@ interface_update_ipv6(struct ifaddrs *ifap, const char *if_name) ifr6.ifr_addr = *sin6; if (ioctl(sock, SIOCGIFAFLAG_IN6, &ifr6) == -1) { /* if flags not available for this address */ - SCLog(TRUE, - (errno != EADDRNOTAVAIL) ? LOG_NOTICE : LOG_DEBUG, - CFSTR("interface_update_ipv6: ioctl failed, %s"), + SC_log((errno != EADDRNOTAVAIL) ? LOG_NOTICE : LOG_DEBUG, "ioctl() failed: %s", strerror(errno)); } @@ -402,3 +404,35 @@ interface_update_ipv6(struct ifaddrs *ifap, const char *if_name) return; } + +__private_extern__ +void +ipv6_duplicated_address(const char * if_name, const struct in6_addr * addr, + int hw_len, const void * hw_addr) +{ + uint8_t * hw_addr_bytes = (uint8_t *)hw_addr; + int i; + CFStringRef if_name_cf; + CFMutableStringRef key; + char ntopbuf[INET6_ADDRSTRLEN]; + CFStringRef prefix; + + if_name_cf = CFStringCreateWithCString(NULL, if_name, + kCFStringEncodingASCII); + prefix = SCDynamicStoreKeyCreateNetworkInterfaceEntity(NULL, + kSCDynamicStoreDomainState, + if_name_cf, + kSCEntNetIPv6DuplicatedAddress); + ntopbuf[0] = '\0'; + (void)inet_ntop(AF_INET6, addr, ntopbuf, sizeof(ntopbuf)); + key = CFStringCreateMutableCopy(NULL, 0, prefix); + CFStringAppendFormat(key, NULL, CFSTR("/%s"), ntopbuf); + for (i = 0; i < hw_len; i++) { + CFStringAppendFormat(key, NULL, CFSTR("%s%02x"), + (i == 0) ? "/" : ":", hw_addr_bytes[i]); + } + cache_SCDynamicStoreNotifyValue(store, key); + CFRelease(key); + CFRelease(prefix); + CFRelease(if_name_cf); +} diff --git a/Plugins/KernelEventMonitor/ev_ipv6.h b/Plugins/KernelEventMonitor/ev_ipv6.h index a009255..562ad50 100644 --- a/Plugins/KernelEventMonitor/ev_ipv6.h +++ b/Plugins/KernelEventMonitor/ev_ipv6.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2004, 2011, 2012 Apple Inc. All rights reserved. + * Copyright (c) 2002, 2004, 2011, 2012, 2015 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -36,8 +36,9 @@ __BEGIN_DECLS -void interface_update_ipv6 (struct ifaddrs *ifap, const char *if_name); - +void interface_update_ipv6(struct ifaddrs *ifap, const char *if_name); +void ipv6_duplicated_address(const char * if_name, const struct in6_addr * addr, + int hw_len, const void * hw_addr); __END_DECLS #endif /* _EV_IPV6_H */ diff --git a/Plugins/KernelEventMonitor/eventmon.c b/Plugins/KernelEventMonitor/eventmon.c index 8249a91..f5ab8f0 100644 --- a/Plugins/KernelEventMonitor/eventmon.c +++ b/Plugins/KernelEventMonitor/eventmon.c @@ -1,15 +1,15 @@ /* - * Copyright (c) 2000-2014 Apple Inc. All rights reserved. + * Copyright (c) 2000-2015 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ - * + * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. - * + * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, @@ -17,7 +17,7 @@ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. - * + * * @APPLE_LICENSE_HEADER_END@ */ @@ -63,91 +63,96 @@ // from ip_fw2.c #define KEV_LOG_SUBCLASS 10 -static const char *inetEventName[] = { - "", - "INET address added", - "INET address changed", - "INET address deleted", - "INET destination address changed", - "INET broadcast address changed", - "INET netmask changed", - "INET ARP collision", - "INET port in use", -}; - -static const char *dlEventName[] = { - "", - "KEV_DL_SIFFLAGS", - "KEV_DL_SIFMETRICS", - "KEV_DL_SIFMTU", - "KEV_DL_SIFPHYS", - "KEV_DL_SIFMEDIA", - "KEV_DL_SIFGENERIC", - "KEV_DL_ADDMULTI", - "KEV_DL_DELMULTI", - "KEV_DL_IF_ATTACHED", - "KEV_DL_IF_DETACHING", - "KEV_DL_IF_DETACHED", - "KEV_DL_LINK_OFF", - "KEV_DL_LINK_ON", - "KEV_DL_PROTO_ATTACHED", - "KEV_DL_PROTO_DETACHED", - "KEV_DL_LINK_ADDRESS_CHANGED", - "KEV_DL_WAKEFLAGS_CHANGED", -#ifdef KEV_DL_IF_IDLE_ROUTE_REFCNT - "KEV_DL_IF_IDLE_ROUTE_REFCNT", -#endif -#ifdef KEV_DL_IFCAP_CHANGED - "KEV_DL_IFCAP_CHANGED", -#endif -#ifdef KEV_DL_LINK_QUALITY_METRIC_CHANGED - "KEV_DL_LINK_QUALITY_METRIC_CHANGED", -#endif -#ifdef KEV_DL_NODE_PRESENCE - "KEV_DL_NODE_PRESENCE" -#endif -#ifdef KEV_DL_NODE_ABSENCE - "KEV_DL_NODE_ABSENCE" -#endif -#ifdef KEV_DL_MASTER_ELECTED - "KEV_DL_MASTER_ELECTED" -#endif -#ifdef KEV_DL_ISSUES - "KEV_DL_ISSUES", -#endif -#ifdef KEV_DL_IFDELEGATE_CHANGED - "KEV_DL_IFDELEGATE_CHANGED", -#endif -}; - -static const char *inet6EventName[] = { - "", - "KEV_INET6_NEW_USER_ADDR", - "KEV_INET6_CHANGED_ADDR", - "KEV_INET6_ADDR_DELETED", - "KEV_INET6_NEW_LL_ADDR", - "KEV_INET6_NEW_RTADV_ADDR", - "KEV_INET6_DEFROUTER" -}; - -#ifdef KEV_ND6_SUBCLASS -static const char *nd6EventNameString[] = { - "", - "KEV_ND6_RA" -}; -#endif // KEV_ND6_SUBCLASS - static dispatch_queue_t S_kev_queue; static dispatch_source_t S_kev_source; __private_extern__ Boolean network_changed = FALSE; __private_extern__ SCDynamicStoreRef store = NULL; __private_extern__ Boolean _verbose = FALSE; + +#define MESSAGES_MAX 100 +static CFMutableArrayRef S_messages; +static Boolean S_messages_modified; + +static void +messages_init(void) +{ + S_messages = CFArrayCreateMutable(NULL, + 0, + &kCFTypeArrayCallBacks); + return; +} + +static void +messages_free(void) +{ + if (S_messages != NULL) { + CFRelease(S_messages); + S_messages = NULL; + } + return; +} + +static Boolean +messages_should_add_message(void) +{ + if (S_messages == NULL + || CFArrayGetCount(S_messages) >= MESSAGES_MAX) { + return (FALSE); + } + return (TRUE); +} + +static void +messages_add_message(CFStringRef message) +{ + if (messages_should_add_message()) { + CFArrayAppendValue(S_messages, message); + S_messages_modified = TRUE; + } + return; +} + +__private_extern__ void +messages_add_msg_with_arg(const char * msg, const char * arg) +{ + if (messages_should_add_message()) { + CFStringRef str; + + str = CFStringCreateWithFormat(NULL, NULL, + CFSTR("%12.8f: %s %s"), + CFAbsoluteTimeGetCurrent(), + msg, arg); + messages_add_message(str); + CFRelease(str); + } + return; +} + +static void +messages_post(void) +{ + if (S_messages != NULL && S_messages_modified) { + SCDynamicStoreSetValue(NULL, + CFSTR("Plugin:KernelEventMonitor"), + S_messages); + S_messages_modified = FALSE; + } + return; +} + __private_extern__ int dgram_socket(int domain) { - return (socket(domain, SOCK_DGRAM, 0)); + int s; + + s = socket(domain, SOCK_DGRAM, 0); + if (s == -1) { + SC_log(LOG_ERR, "socket() failed: %s", strerror(errno)); + } + + return s; } static int @@ -210,7 +215,7 @@ post_network_changed(void) status = notify_post(_SC_NOTIFY_NETWORK_CHANGE); if (status != NOTIFY_STATUS_OK) { - SCLog(TRUE, LOG_ERR, CFSTR("notify_post() failed: error=%u"), status); + SC_log(LOG_NOTICE, "notify_post() failed: error=%u", status); } network_changed = FALSE; @@ -229,9 +234,8 @@ logEvent(CFStringRef evStr, struct kern_event_msg *ev_msg) return; } - SCLog(TRUE, LOG_DEBUG, CFSTR("%@ event:"), evStr); - SCLog(TRUE, LOG_DEBUG, - CFSTR(" Event size=%d, id=%d, vendor=%d, class=%d, subclass=%d, code=%d"), + SC_log(LOG_DEBUG, "%@ event:", evStr); + SC_log(LOG_DEBUG, " Event size=%d, id=%d, vendor=%d, class=%d, subclass=%d, code=%d", ev_msg->total_size, ev_msg->id, ev_msg->vendor_code, @@ -239,35 +243,8 @@ logEvent(CFStringRef evStr, struct kern_event_msg *ev_msg) ev_msg->kev_subclass, ev_msg->event_code); for (i = 0, j = KEV_MSG_HEADER_SIZE; j < ev_msg->total_size; i++, j+=4) { - SCLog(TRUE, LOG_DEBUG, CFSTR(" Event data[%2d] = %08x"), i, ev_msg->event_data[i]); - } -} - -static const char * -inetEventNameString(uint32_t event_code) -{ - if (event_code < sizeof(inetEventName) / sizeof(inetEventName[0])) { - return (inetEventName[event_code]); + SC_log(LOG_DEBUG, " Event data[%2d] = %08x", i, ev_msg->event_data[i]); } - return ("New Apple network INET subcode"); -} - -static const char * -inet6EventNameString(uint32_t event_code) -{ - if (event_code < sizeof(inet6EventName) / sizeof(inet6EventName[0])) { - return (inet6EventName[event_code]); - } - return ("New Apple network INET6 subcode"); -} - -static const char * -dlEventNameString(uint32_t event_code) -{ - if (event_code < sizeof(dlEventName) / sizeof(dlEventName[0])) { - return (dlEventName[event_code]); - } - return ("New Apple network DL subcode"); } static void @@ -282,7 +259,6 @@ static uint8_t info_zero[DLIL_MODARGLEN]; static void processEvent_Apple_Network(struct kern_event_msg *ev_msg) { - const char * eventName = NULL; int dataLen = (ev_msg->total_size - KEV_MSG_HEADER_SIZE); void * event_data = &ev_msg->event_data[0]; Boolean handled = TRUE; @@ -290,7 +266,6 @@ processEvent_Apple_Network(struct kern_event_msg *ev_msg) switch (ev_msg->kev_subclass) { case KEV_INET_SUBCLASS : { - eventName = inetEventNameString(ev_msg->event_code); switch (ev_msg->event_code) { case KEV_INET_NEW_ADDR : case KEV_INET_CHANGED_ADDR : @@ -306,6 +281,7 @@ processEvent_Apple_Network(struct kern_event_msg *ev_msg) break; } copy_if_name(&ev->link_data, ifr_name, sizeof(ifr_name)); + SC_log(LOG_INFO, "Process IPv4 address change: %s: %d", (char *)ifr_name, ev_msg->event_code); ipv4_interface_update(NULL, ifr_name); break; } @@ -319,6 +295,7 @@ processEvent_Apple_Network(struct kern_event_msg *ev_msg) break; } copy_if_name(&ev->link_data, ifr_name, sizeof(ifr_name)); + SC_log(LOG_INFO, "Process ARP collision: %s", (char *)ifr_name); ipv4_arp_collision(ifr_name, ev->ia_ipaddr, ev->hw_len, @@ -333,6 +310,7 @@ processEvent_Apple_Network(struct kern_event_msg *ev_msg) handled = FALSE; break; } + SC_log(LOG_INFO, "Process port-in-use: %hu, %u", ev->port, ev->req_pid); ipv4_port_in_use(ev->port, ev->req_pid); break; } @@ -346,6 +324,7 @@ processEvent_Apple_Network(struct kern_event_msg *ev_msg) break; } copy_if_name(&ev->link_data, ifr_name, sizeof(ifr_name)); + SC_log(LOG_INFO, "Process router ARP failure: %s", (char *)ifr_name); ipv4_router_arp_failure(ifr_name); break; } @@ -358,6 +337,7 @@ processEvent_Apple_Network(struct kern_event_msg *ev_msg) break; } copy_if_name(&ev->link_data, ifr_name, sizeof(ifr_name)); + SC_log(LOG_INFO, "Process router ARP alive: %s", (char *)ifr_name); ipv4_router_arp_alive(ifr_name); break; } @@ -370,7 +350,6 @@ processEvent_Apple_Network(struct kern_event_msg *ev_msg) case KEV_INET6_SUBCLASS : { struct kev_in6_data * ev; - eventName = inet6EventNameString(ev_msg->event_code); ev = (struct kev_in6_data *)event_data; switch (ev_msg->event_code) { case KEV_INET6_NEW_USER_ADDR : @@ -384,7 +363,15 @@ processEvent_Apple_Network(struct kern_event_msg *ev_msg) break; } copy_if_name(&ev->link_data, ifr_name, sizeof(ifr_name)); + SC_log(LOG_INFO, "Process IPv6 address change: %s: %d", (char *)ifr_name, ev_msg->event_code); interface_update_ipv6(NULL, ifr_name); + if (ev_msg->event_code == KEV_INET6_NEW_USER_ADDR + && (ev->ia6_flags & IN6_IFF_DUPLICATED) != 0) { + ipv6_duplicated_address(ifr_name, + &ev->ia_addr.sin6_addr, + ETHER_ADDR_LEN, + &ev->ia_mac); + } break; default : @@ -396,7 +383,6 @@ processEvent_Apple_Network(struct kern_event_msg *ev_msg) case KEV_DL_SUBCLASS : { struct net_event_data * ev; - eventName = dlEventNameString(ev_msg->event_code); ev = (struct net_event_data *)event_data; switch (ev_msg->event_code) { case KEV_DL_IF_ATTACHED : @@ -408,6 +394,7 @@ processEvent_Apple_Network(struct kern_event_msg *ev_msg) break; } copy_if_name(ev, ifr_name, sizeof(ifr_name)); + SC_log(LOG_INFO, "Process interface attach: %s", (char *)ifr_name); link_add(ifr_name); break; @@ -420,6 +407,7 @@ processEvent_Apple_Network(struct kern_event_msg *ev_msg) break; } copy_if_name(ev, ifr_name, sizeof(ifr_name)); + SC_log(LOG_INFO, "Process interface detach: %s", (char *)ifr_name); link_remove(ifr_name); break; @@ -432,6 +420,7 @@ processEvent_Apple_Network(struct kern_event_msg *ev_msg) break; } copy_if_name(ev, ifr_name, sizeof(ifr_name)); + SC_log(LOG_INFO, "Process interface detaching: %s", (char *)ifr_name); interface_detaching(ifr_name); break; @@ -446,6 +435,10 @@ processEvent_Apple_Network(struct kern_event_msg *ev_msg) } copy_if_name(&protoEvent->link_data, ifr_name, sizeof(ifr_name)); + SC_log(LOG_INFO, "Process protocol %s: %s (n=%d)", + (ev_msg->event_code == KEV_DL_PROTO_ATTACHED) ? "attach" : "detach", + (char *)ifr_name, + protoEvent->proto_remaining_count); if (protoEvent->proto_remaining_count == 0) { mark_if_down(ifr_name); } else { @@ -464,6 +457,7 @@ processEvent_Apple_Network(struct kern_event_msg *ev_msg) break; } copy_if_name(ev, ifr_name, sizeof(ifr_name)); + SC_log(LOG_INFO, "Process interface idle: %s", (char *)ifr_name); interface_update_idle_state(ifr_name); break; } @@ -479,6 +473,9 @@ processEvent_Apple_Network(struct kern_event_msg *ev_msg) break; } copy_if_name(ev, ifr_name, sizeof(ifr_name)); + SC_log(LOG_INFO, "Process interface link %s: %s", + (ev_msg->event_code == KEV_DL_LINK_ON) ? "up" : "down", + (char *)ifr_name); link_update_status(ifr_name, FALSE); break; @@ -492,6 +489,9 @@ processEvent_Apple_Network(struct kern_event_msg *ev_msg) break; } copy_if_name(ev, ifr_name, sizeof(ifr_name)); + SC_log(LOG_INFO, "Process interface quality: %s (q=%d)", + (char *)ifr_name, + lqm_data->link_quality_metric); interface_update_quality_metric(ifr_name, lqm_data->link_quality_metric); break; @@ -508,6 +508,8 @@ processEvent_Apple_Network(struct kern_event_msg *ev_msg) break; } copy_if_name(ev, ifr_name, sizeof(ifr_name)); + SC_log(LOG_INFO, "Process interface link issues: %s", + (char *)ifr_name); interface_update_link_issues(ifr_name, issues->timestamp, issues->modid, @@ -543,7 +545,6 @@ processEvent_Apple_Network(struct kern_event_msg *ev_msg) } #ifdef KEV_ND6_SUBCLASS case KEV_ND6_SUBCLASS : { - eventName = nd6EventNameString(ev_msg->event_code); switch (ev_msg->event_code) { case KEV_KEV_ND6_RA : break; @@ -563,14 +564,8 @@ processEvent_Apple_Network(struct kern_event_msg *ev_msg) break; } - if (handled == FALSE) { - CFStringRef evStr; - - evStr = CFStringCreateWithCString(NULL, - (eventName != NULL) ? eventName : "New Apple network subclass", - kCFStringEncodingASCII); - logEvent(evStr, ev_msg); - CFRelease(evStr); + if (!handled) { + logEvent(CFSTR("New Apple network subclass"), ev_msg); } return; } @@ -588,7 +583,7 @@ eventCallback(int so) status = recv(so, &buf, sizeof(buf), 0); if (status == -1) { - SCLog(TRUE, LOG_ERR, CFSTR("recv() failed: %s"), strerror(errno)); + SC_log(LOG_NOTICE, "recv() failed: %s", strerror(errno)); return FALSE; } @@ -596,7 +591,7 @@ eventCallback(int so) while (offset < status) { if ((offset + ev_msg->total_size) > status) { - SCLog(TRUE, LOG_NOTICE, CFSTR("missed SYSPROTO_EVENT event, buffer not big enough")); + SC_log(LOG_NOTICE, "missed SYSPROTO_EVENT event, buffer not big enough"); break; } @@ -630,73 +625,120 @@ eventCallback(int so) cache_write(store); cache_close(); post_network_changed(); + messages_post(); return TRUE; } static void -prime(void) +update_interfaces(const char * msg, Boolean ipv4_ipv6_too) { - struct ifaddrs *ifap = NULL; - struct ifaddrs *scan; - int sock = -1; - - SCLog(_verbose, LOG_DEBUG, CFSTR("prime() called")); - - cache_open(); - - sock = dgram_socket(AF_INET); - if (sock == -1) { - SCLog(TRUE, LOG_ERR, CFSTR("could not get interface list, socket() failed: %s"), strerror(errno)); - goto done; - } + Boolean added = FALSE; + struct ifaddrs * ifap = NULL; + CFMutableArrayRef ifList = NULL; + struct ifaddrs * scan; if (getifaddrs(&ifap) == -1) { - SCLog(TRUE, - LOG_ERR, - CFSTR("could not get interface info, getifaddrs() failed: %s"), - strerror(errno)); + messages_add_msg_with_arg("getifaddrs", strerror(errno)); + SC_log(LOG_NOTICE, "getifaddrs() failed: %s", strerror(errno)); goto done; } /* update list of interfaces & link status */ + ifList = interfaceListCopy(); for (scan = ifap; scan != NULL; scan = scan->ifa_next) { if (scan->ifa_addr == NULL || scan->ifa_addr->sa_family != AF_LINK) { continue; } /* get the per-interface link/media information */ - link_add(scan->ifa_name); + if (interfaceListAddInterface(ifList, scan->ifa_name)) { + messages_add_msg_with_arg(msg, scan->ifa_name); + added = TRUE; + } } - /* - * update IPv4 network addresses already assigned to - * the interfaces. - */ - ipv4_interface_update(ifap, NULL); + /* update the global list if an interface was added */ + if (added) { + interfaceListUpdate(ifList); + } + CFRelease(ifList); - /* - * update IPv6 network addresses already assigned to - * the interfaces. - */ - interface_update_ipv6(ifap, NULL); + /* update IPv4/IPv6 addresses that are already assigned */ + if (ipv4_ipv6_too) { + ipv4_interface_update(ifap, NULL); + interface_update_ipv6(ifap, NULL); + } freeifaddrs(ifap); done: - if (sock != -1) - close(sock); + return; +} + +#define TIMER_INTERVAL (6LL * NSEC_PER_SEC) +#define MAX_TIMER_COUNT 20 + +static void +check_for_new_interfaces(void * context); + +static void +schedule_timer(void) +{ + dispatch_after_f(dispatch_time(DISPATCH_TIME_NOW, TIMER_INTERVAL), + S_kev_queue, + NULL, + check_for_new_interfaces); + return; +} + +static void +check_for_new_interfaces(void * context) +{ + static int count; + char msg[32]; + count++; + snprintf(msg, sizeof(msg), "timeout %d (of %d)", count, MAX_TIMER_COUNT); + cache_open(); + update_interfaces(msg, FALSE); + cache_write(store); + cache_close(); + messages_post(); + + /* schedule the next timer, if needed */ + if (count < MAX_TIMER_COUNT) { + schedule_timer(); + } + else { + messages_free(); + } + + return; +} + +static void +prime(void) +{ + SC_log(LOG_DEBUG, "prime() called"); + + cache_open(); + messages_init(); + update_interfaces("prime", TRUE); cache_write(store); cache_close(); network_changed = TRUE; post_network_changed(); + messages_post(); /* start handling kernel events */ dispatch_resume(S_kev_source); + /* schedule polling timer */ + schedule_timer(); + return; } @@ -709,6 +751,21 @@ prime_KernelEventMonitor() return; } +static Boolean +initialize_store(void) +{ + store = SCDynamicStoreCreate(NULL, + CFSTR("Kernel Event Monitor plug-in"), + NULL, + NULL); + if (store == NULL) { + SC_log(LOG_ERR, "SCDynamicStoreCreate() failed: %s", SCErrorString(SCError())); + return (FALSE); + } + return (TRUE); +} + + __private_extern__ void load_KernelEventMonitor(CFBundleRef bundle, Boolean bundleVerbose) @@ -721,17 +778,11 @@ load_KernelEventMonitor(CFBundleRef bundle, Boolean bundleVerbose) _verbose = TRUE; } - SCLog(_verbose, LOG_DEBUG, CFSTR("load() called")); - SCLog(_verbose, LOG_DEBUG, CFSTR(" bundle ID = %@"), CFBundleGetIdentifier(bundle)); + SC_log(LOG_DEBUG, "load() called"); + SC_log(LOG_DEBUG, " bundle ID = %@", CFBundleGetIdentifier(bundle)); - /* open a "configd" session to allow cache updates */ - store = SCDynamicStoreCreate(NULL, - CFSTR("Kernel Event Monitor plug-in"), - NULL, - NULL); - if (store == NULL) { - SCLog(TRUE, LOG_ERR, CFSTR("SCDnamicStoreCreate() failed: %s"), SCErrorString(SCError())); - SCLog(TRUE, LOG_ERR, CFSTR("kernel event monitor disabled.")); + if (!initialize_store()) { + SC_log(LOG_ERR, "kernel event monitor disabled"); return; } @@ -743,13 +794,13 @@ load_KernelEventMonitor(CFBundleRef bundle, Boolean bundleVerbose) kev_req.kev_class = KEV_NETWORK_CLASS; kev_req.kev_subclass = KEV_ANY_SUBCLASS; status = ioctl(so, SIOCSKEVFILT, &kev_req); - if (status) { - SCLog(TRUE, LOG_ERR, CFSTR("could not establish event filter, ioctl() failed: %s"), strerror(errno)); + if (status != 0) { + SC_log(LOG_ERR, "could not establish event filter, ioctl() failed: %s", strerror(errno)); (void) close(so); so = -1; } } else { - SCLog(TRUE, LOG_ERR, CFSTR("could not open event socket, socket() failed: %s"), strerror(errno)); + SC_log(LOG_ERR, "could not open event socket, socket() failed: %s", strerror(errno)); } if (so != -1) { @@ -757,14 +808,14 @@ load_KernelEventMonitor(CFBundleRef bundle, Boolean bundleVerbose) status = ioctl(so, FIONBIO, &yes); if (status) { - SCLog(TRUE, LOG_ERR, CFSTR("could not set non-blocking io, ioctl() failed: %s"), strerror(errno)); + SC_log(LOG_ERR, "could not set non-blocking io, ioctl() failed: %s", strerror(errno)); (void) close(so); so = -1; } } if (so == -1) { - SCLog(TRUE, LOG_ERR, CFSTR("kernel event monitor disabled.")); + SC_log(LOG_ERR, "kernel event monitor disabled"); CFRelease(store); return; } @@ -776,14 +827,19 @@ load_KernelEventMonitor(CFBundleRef bundle, Boolean bundleVerbose) close(so); }); dispatch_source_set_event_handler(S_kev_source, ^{ + os_activity_t activity_id; Boolean ok; + activity_id = os_activity_start("processing network kernel events", + OS_ACTIVITY_FLAG_DEFAULT); + ok = eventCallback(so); if (!ok) { - SCLog(TRUE, LOG_ERR, CFSTR("kernel event monitor disabled.")); + SC_log(LOG_ERR, "kernel event monitor disabled"); dispatch_source_cancel(S_kev_source); } + os_activity_end(activity_id); }); // NOTE: dispatch_resume() will be called in prime() diff --git a/Plugins/KernelEventMonitor/eventmon.h b/Plugins/KernelEventMonitor/eventmon.h index 9bce032..aabc939 100644 --- a/Plugins/KernelEventMonitor/eventmon.h +++ b/Plugins/KernelEventMonitor/eventmon.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2004, 2005, 2007, 2011, 2012 Apple Inc. All rights reserved. + * Copyright (c) 2002-2015 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -65,6 +65,9 @@ __BEGIN_DECLS int dgram_socket (int domain); +void +messages_add_msg_with_arg(const char * msg, const char * arg); + __END_DECLS #endif /* _EVENTMON_H */ diff --git a/Plugins/LinkConfiguration/Info.plist b/Plugins/LinkConfiguration/Info.plist index d7742b0..63de67e 100644 --- a/Plugins/LinkConfiguration/Info.plist +++ b/Plugins/LinkConfiguration/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType BNDL CFBundleShortVersionString - 1.14.4 + 1.14 CFBundleSignature ???? CFBundleVersion diff --git a/Plugins/LinkConfiguration/linkconfig.c b/Plugins/LinkConfiguration/linkconfig.c index aa11307..0af3e51 100644 --- a/Plugins/LinkConfiguration/linkconfig.c +++ b/Plugins/LinkConfiguration/linkconfig.c @@ -1,15 +1,15 @@ /* - * Copyright (c) 2002-2007, 2011, 2013 Apple Inc. All rights reserved. + * Copyright (c) 2002-2007, 2011, 2013, 2015 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ - * + * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. - * + * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, @@ -17,7 +17,7 @@ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. - * + * * @APPLE_LICENSE_HEADER_END@ */ @@ -51,8 +51,6 @@ static SCDynamicStoreRef store = NULL; static CFRunLoopSourceRef rls = NULL; static CFMutableDictionaryRef wantSettings = NULL; -static Boolean _verbose = FALSE; - #pragma mark - #pragma mark Capabilities @@ -117,14 +115,14 @@ _SCNetworkInterfaceSetCapabilities(SCNetworkInterfaceRef interface, sock = socket(AF_INET, SOCK_DGRAM, 0); if (sock == -1) { - SCLog(TRUE, LOG_ERR, CFSTR("socket() failed: %s"), strerror(errno)); + SC_log(LOG_ERR, "socket() failed: %s", strerror(errno)); return FALSE; } ret = ioctl(sock, SIOCSIFCAP, (caddr_t)&ifr); (void)close(sock); if (ret == -1) { - SCLog(TRUE, LOG_DEBUG, CFSTR("ioctl(SIOCSIFCAP) failed: %s"), strerror(errno)); + SC_log(LOG_INFO, "ioctl(SIOCSIFCAP) failed: %s", strerror(errno)); return FALSE; } #endif // SIOCSIFCAP @@ -195,7 +193,7 @@ _SCNetworkInterfaceSetMediaOptions(SCNetworkInterfaceRef interface, interfaceName = SCNetworkInterfaceGetBSDName(interface); if (interfaceName == NULL) { /* if no BSD interface name */ - SCLog(_verbose, LOG_INFO, CFSTR("no BSD interface name for %@"), interface); + SC_log(LOG_INFO, "no BSD interface name for %@", interface); _SCErrorSet(kSCStatusInvalidArgument); return FALSE; } @@ -203,7 +201,7 @@ _SCNetworkInterfaceSetMediaOptions(SCNetworkInterfaceRef interface, /* get current & available options */ if (!SCNetworkInterfaceCopyMediaOptions(interface, ¤t, NULL, &available, FALSE)) { /* could not get current media options */ - SCLog(_verbose, LOG_INFO, CFSTR("no media options for %@"), interfaceName); + SC_log(LOG_INFO, "no media options for %@", interfaceName); return FALSE; } @@ -233,7 +231,7 @@ _SCNetworkInterfaceSetMediaOptions(SCNetworkInterfaceRef interface, if (!CFArrayContainsValue(available, CFRangeMake(0, CFArrayGetCount(available)), requested)) { /* if requested settings not currently available */ - SCLog(_verbose, LOG_INFO, CFSTR("requested media settings unavailable for %@"), interfaceName); + SC_log(LOG_INFO, "requested media settings unavailable for %@", interfaceName); goto done; } @@ -245,7 +243,7 @@ _SCNetworkInterfaceSetMediaOptions(SCNetworkInterfaceRef interface, sock = socket(AF_INET, SOCK_DGRAM, 0); if (sock == -1) { - SCLog(TRUE, LOG_ERR, CFSTR("socket() failed: %s"), strerror(errno)); + SC_log(LOG_ERR, "socket() failed: %s", strerror(errno)); goto done; } @@ -253,7 +251,7 @@ _SCNetworkInterfaceSetMediaOptions(SCNetworkInterfaceRef interface, (void)_SC_cfstring_to_cstring(interfaceName, ifm.ifm_name, sizeof(ifm.ifm_name), kCFStringEncodingASCII); if (ioctl(sock, SIOCGIFMEDIA, (caddr_t)&ifm) == -1) { - SCLog(TRUE, LOG_DEBUG, CFSTR("ioctl(SIOCGIFMEDIA) failed: %s"), strerror(errno)); + SC_log(LOG_NOTICE, "ioctl(SIOCGIFMEDIA) failed: %s", strerror(errno)); goto done; } @@ -262,11 +260,11 @@ _SCNetworkInterfaceSetMediaOptions(SCNetworkInterfaceRef interface, ifr.ifr_media = ifm.ifm_current & ~(IFM_NMASK|IFM_TMASK|IFM_OMASK|IFM_GMASK); ifr.ifr_media |= newOptions; - SCLog(_verbose, LOG_INFO, CFSTR("old media settings: 0x%8.8x (0x%8.8x)"), ifm.ifm_current, ifm.ifm_active); - SCLog(_verbose, LOG_INFO, CFSTR("new media settings: 0x%8.8x"), ifr.ifr_media); + SC_log(LOG_INFO, "old media settings: 0x%8.8x (0x%8.8x)", ifm.ifm_current, ifm.ifm_active); + SC_log(LOG_INFO, "new media settings: 0x%8.8x", ifr.ifr_media); if (ioctl(sock, SIOCSIFMEDIA, (caddr_t)&ifr) == -1) { - SCLog(TRUE, LOG_DEBUG, CFSTR("%@: ioctl(SIOCSIFMEDIA) failed: %s"), interfaceName, strerror(errno)); + SC_log(LOG_NOTICE, "%@: ioctl(SIOCSIFMEDIA) failed: %s", interfaceName, strerror(errno)); goto done; } @@ -295,21 +293,18 @@ ifconfig_exit(pid_t pid, int status, struct rusage *rusage, void *context) if (WIFEXITED(status)) { if (WEXITSTATUS(status) != 0) { - SCLog(TRUE, LOG_ERR, - CFSTR("ifconfig %s failed, exit status = %d"), - if_name, - WEXITSTATUS(status)); + SC_log(LOG_NOTICE, "ifconfig %s failed, exit status = %d", + if_name, + WEXITSTATUS(status)); } } else if (WIFSIGNALED(status)) { - SCLog(TRUE, LOG_DEBUG, - CFSTR("ifconfig %s: terminated w/signal = %d"), - if_name, - WTERMSIG(status)); + SC_log(LOG_NOTICE, "ifconfig %s: terminated w/signal = %d", + if_name, + WTERMSIG(status)); } else { - SCLog(TRUE, LOG_DEBUG, - CFSTR("ifconfig %s: exit status = %d"), - if_name, - status); + SC_log(LOG_NOTICE, "ifconfig %s: exit status = %d", + if_name, + status); } CFAllocatorDeallocate(NULL, if_name); @@ -384,14 +379,14 @@ _SCNetworkInterfaceSetMTU(SCNetworkInterfaceRef interface, sock = socket(AF_INET, SOCK_DGRAM, 0); if (sock == -1) { - SCLog(TRUE, LOG_ERR, CFSTR("socket() failed: %s"), strerror(errno)); + SC_log(LOG_ERR, "socket() failed: %s", strerror(errno)); return FALSE; } ret = ioctl(sock, SIOCSIFMTU, (caddr_t)&ifr); (void)close(sock); if (ret == -1) { - SCLog(TRUE, LOG_DEBUG, CFSTR("ioctl(SIOCSIFMTU) failed: %s"), strerror(errno)); + SC_log(LOG_NOTICE, "ioctl(SIOCSIFMTU) failed: %s", strerror(errno)); return FALSE; } } @@ -597,11 +592,15 @@ updateLink(CFStringRef interfaceName, CFDictionaryRef options) static void linkConfigChangedCallback(SCDynamicStoreRef store, CFArrayRef changedKeys, void *arg) { + os_activity_t activity_id; CFDictionaryRef changes; CFIndex i; CFIndex n; static CFStringRef prefix = NULL; + activity_id = os_activity_start("processing link configuration changes", + OS_ACTIVITY_FLAG_DEFAULT); + if (prefix == NULL) { prefix = SCDynamicStoreKeyCreate(NULL, CFSTR("%@/%@/%@/"), @@ -612,7 +611,7 @@ linkConfigChangedCallback(SCDynamicStoreRef store, CFArrayRef changedKeys, void changes = SCDynamicStoreCopyMultiple(store, changedKeys, NULL); - n = CFArrayGetCount(changedKeys); + n = (changes != NULL) ? CFArrayGetCount(changedKeys) : 0; for (i = 0; i < n; i++) { CFStringRef key; CFDictionaryRef info; @@ -621,11 +620,13 @@ linkConfigChangedCallback(SCDynamicStoreRef store, CFArrayRef changedKeys, void info = CFDictionaryGetValue(changes, key); if (CFEqual(key, interfacesKey)) { - CFArrayRef interfaces; + if (isA_CFDictionary(info) != NULL) { + CFArrayRef interfaces; - interfaces = CFDictionaryGetValue(info, kSCPropNetInterfaces); - if (isA_CFArray(interfaces)) { - updateInterfaces(interfaces); + interfaces = CFDictionaryGetValue(info, kSCPropNetInterfaces); + if (isA_CFArray(interfaces)) { + updateInterfaces(interfaces); + } } } else { CFStringRef interfaceName; @@ -638,7 +639,11 @@ linkConfigChangedCallback(SCDynamicStoreRef store, CFArrayRef changedKeys, void } } - CFRelease(changes); + if (changes != NULL) { + CFRelease(changes); + } + + os_activity_end(activity_id); return; } @@ -653,12 +658,8 @@ load_LinkConfiguration(CFBundleRef bundle, Boolean bundleVerbose) Boolean ok; CFMutableArrayRef patterns = NULL; - if (bundleVerbose) { - _verbose = TRUE; - } - - SCLog(_verbose, LOG_DEBUG, CFSTR("load() called")); - SCLog(_verbose, LOG_DEBUG, CFSTR(" bundle ID = %@"), CFBundleGetIdentifier(bundle)); + SC_log(LOG_DEBUG, "load() called"); + SC_log(LOG_DEBUG, " bundle ID = %@", CFBundleGetIdentifier(bundle)); /* initialize a few globals */ @@ -677,7 +678,7 @@ load_LinkConfiguration(CFBundleRef bundle, Boolean bundleVerbose) linkConfigChangedCallback, NULL); if (store == NULL) { - SCLog(TRUE, LOG_ERR, CFSTR("SCDynamicStoreCreate() failed: %s"), SCErrorString(SCError())); + SC_log(LOG_ERR, "SCDynamicStoreCreate() failed: %s", SCErrorString(SCError())); goto error; } @@ -719,17 +720,15 @@ load_LinkConfiguration(CFBundleRef bundle, Boolean bundleVerbose) CFRelease(keys); CFRelease(patterns); if (!ok) { - SCLog(TRUE, LOG_ERR, - CFSTR("SCDynamicStoreSetNotificationKeys() failed: %s"), - SCErrorString(SCError())); + SC_log(LOG_NOTICE, "SCDynamicStoreSetNotificationKeys() failed: %s", + SCErrorString(SCError())); goto error; } rls = SCDynamicStoreCreateRunLoopSource(NULL, store, 0); if (rls == NULL) { - SCLog(TRUE, LOG_ERR, - CFSTR("SCDynamicStoreCreateRunLoopSource() failed: %s"), - SCErrorString(SCError())); + SC_log(LOG_NOTICE, "SCDynamicStoreCreateRunLoopSource() failed: %s", + SCErrorString(SCError())); goto error; } diff --git a/Plugins/Logger/Info-Embedded.plist b/Plugins/Logger/Info-Embedded.plist deleted file mode 100644 index 19134ec..0000000 --- a/Plugins/Logger/Info-Embedded.plist +++ /dev/null @@ -1,54 +0,0 @@ - - - - - CFBundleDevelopmentRegion - English - CFBundleExecutable - Logger - CFBundleIdentifier - com.apple.SystemConfiguration.Logger - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - com.apple.SystemConfiguration.Logger - CFBundlePackageType - BNDL - CFBundleShortVersionString - 1.14.4 - CFBundleSignature - ???? - CFBundleVersion - 1.14 - Enabled - - Verbose - - LOG_ALL - - LOG_IO_SYSTEMPOWER_EVENTS - - LOG_NETWORK_KERNEL_EVENTS - - LOG_NETWORK_INFORMATION - - LOG_NOTIFY_DNS_CONFIGURATION - - LOG_NOTIFY_NETWORK_CHANGE - - LOG_SC_NETWORKCHANGE - - LOG_SC_PRIMARYSERVICE - - LOG_SC_REACHABILITY - - LOG_SC_REACHABILITY_HOSTS - - mail.me.com - - Requires - - com.apple.SystemConfiguration.SCNetworkReachability - - - diff --git a/Plugins/Logger/Info.plist b/Plugins/Logger/Info.plist deleted file mode 100644 index f8ba817..0000000 --- a/Plugins/Logger/Info.plist +++ /dev/null @@ -1,66 +0,0 @@ - - - - - CFBundleDevelopmentRegion - English - CFBundleExecutable - Logger - CFBundleIdentifier - com.apple.SystemConfiguration.Logger - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - com.apple.SystemConfiguration.Logger - CFBundlePackageType - BNDL - CFBundleShortVersionString - 1.14.4 - CFBundleSignature - ???? - CFBundleVersion - 1.14 - Enabled - - Verbose - - LOG_ALL - - LOG_IO_SYSTEMPOWER_EVENTS - - LOG_IO_WAKEUUID_EVENTS - - LOG_NETWORK_KERNEL_EVENTS - - LOG_NETWORK_INFORMATION - - LOG_NOTIFY_DNS_CONFIGURATION - - LOG_NOTIFY_NETWORK_CHANGE - - LOG_NOTIFY_SMB_CONFIGURATION - - LOG_NOTIFY_UTMPX_CHANGE - - LOG_SC_BTMM_CONFIGURATION - - LOG_SC_CONSOLEUSER - - LOG_SC_DIRECTORYSERVICES_SEARCHPOLICY - - LOG_SC_NETWORKCHANGE - - LOG_SC_PRIMARYSERVICE - - LOG_SC_REACHABILITY - - LOG_SC_REACHABILITY_HOSTS - - mail.me.com - - Requires - - com.apple.SystemConfiguration.SCNetworkReachability - - - diff --git a/Plugins/Logger/Makefile b/Plugins/Logger/Makefile deleted file mode 100644 index 6e67879..0000000 --- a/Plugins/Logger/Makefile +++ /dev/null @@ -1,6 +0,0 @@ -logger: logger.c - cc -Wall -g -DMAIN -o logger logger.c -framework CoreFoundation -framework SystemConfiguration -framework IOKit - -clean: - rm -rf logger logger.dSYM - diff --git a/Plugins/Logger/logger.c b/Plugins/Logger/logger.c deleted file mode 100644 index ebd68a0..0000000 --- a/Plugins/Logger/logger.c +++ /dev/null @@ -1,2055 +0,0 @@ -/* - * Copyright (c) 2005-2014 Apple Inc. All rights reserved. - * - * @APPLE_LICENSE_HEADER_START@ - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. - * - * The Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. - * - * @APPLE_LICENSE_HEADER_END@ - */ - -/* - * Modification History - * - * January 15, 2005 Allan Nathanson - * - initial revision - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#ifndef TARGET_OS_EMBEDDED -#include -#include -#endif // !TARGET_OS_EMBEDDED - - -/* generic MessageTracer keys */ -#define MSGTRACER_KEY_DOMAIN "com.apple.message.domain" -#define MSGTRACER_KEY_SIG "com.apple.message.signature" -#define MSGTRACER_KEY_UUID "com.apple.message.uuid" -#define MSGTRACER_KEY_VALUE1 "com.apple.message.value" - - -#define MY_ASL_FACILITY "com.apple.SystemConfiguration.Logger" -#define MY_MSGTRACER_DOMAIN "com.apple.network.log" - - -static asl_object_t log_msg = NULL; -static io_connect_t power = MACH_PORT_NULL; -static Boolean verbose = FALSE; - - -static char * -elapsed() -{ - static char str[128]; - struct tm tm_diff; - struct tm tm_now; - struct timeval tv_diff; - struct timeval tv_now; - static struct timeval tv_then = { 0, 0 }; - - (void)gettimeofday(&tv_now, NULL); - - (void)localtime_r(&tv_now.tv_sec, &tm_now); - - timersub(&tv_now, &tv_then, &tv_diff); - (void)localtime_r(&tv_diff.tv_sec, &tm_diff); -#ifdef MAIN - sprintf(str, "%2d:%02d:%02d.%03d (+%ld.%03d)", - tm_now.tm_hour, - tm_now.tm_min, - tm_now.tm_sec, - tv_now.tv_usec / 1000, - tv_diff.tv_sec, - tv_diff.tv_usec / 1000); -#else - sprintf(str, ".%03d (+%ld.%03d)", - tv_now.tv_usec / 1000, - tv_diff.tv_sec, - tv_diff.tv_usec / 1000); -#endif - - tv_then = tv_now; - return str; -} - - -#pragma mark - -#pragma mark [Network] Kernel Events - - -static CFStringRef -copyInterfaceFlags(const char *if_name) -{ - const char * iff_up = "? "; - struct ifreq ifr; - const char *ifm_active = "? "; - int sock; - CFStringRef str = NULL; - - sock = socket(AF_INET, SOCK_DGRAM, 0); - if (sock == -1) { - SCLOG(NULL, NULL, ASL_LEVEL_ERR, CFSTR("socket() failed")); - return NULL; - } - - bzero((char *)&ifr, sizeof(ifr)); - (void) strlcpy(ifr.ifr_name, if_name, sizeof(ifr.ifr_name)); - if (ioctl(sock, SIOCGIFFLAGS, (caddr_t)&ifr) == 0) { - struct ifmediareq ifm; - - iff_up = (ifr.ifr_flags & IFF_UP) ? "yes" : "no "; - - bzero((char *)&ifm, sizeof(ifm)); - (void) strncpy(ifm.ifm_name, if_name, sizeof(ifm.ifm_name)); - if ((ioctl(sock, SIOCGIFMEDIA, (caddr_t)&ifm) == 0) && - (ifm.ifm_count > 0) && - (ifm.ifm_status & IFM_AVALID)) { - ifm_active = (ifm.ifm_status & IFM_ACTIVE) ? "yes" : "no "; - } - - str = CFStringCreateWithFormat(NULL, - NULL, - CFSTR("\n%-5s: IFF_UP = %s IFM_ACTIVE = %s"), - if_name, - iff_up, - ifm_active); - } - - (void)close(sock); - - return str; -} - - -static int -prefixLength(struct sockaddr_in6 *sin6) -{ - register u_int8_t *name = &sin6->sin6_addr.s6_addr[0]; - register int byte; - register int bit; - int plen = 0; - - for (byte = 0; byte < sizeof(struct in6_addr); byte++, plen += 8) { - if (name[byte] != 0xff) { - break; - } - } - - if (byte == sizeof(struct in6_addr)) { - return plen; - } - - for (bit = 7; bit != 0; bit--, plen++) { - if (!(name[byte] & (1 << bit))) { - break; - } - } - - for (; bit != 0; bit--) { - if (name[byte] & (1 << bit)) { - return 0; - } - } - - byte++; - for (; byte < sizeof(struct in6_addr); byte++) { - if (name[byte]) { - return 0; - } - } - - return plen; -} - - -static void -KernelEvent_notification(CFSocketRef s, CFSocketCallBackType type, CFDataRef address, const void *data, void *info) -{ - int so = CFSocketGetNative(s); - size_t status; - union { - char bytes[1024]; - struct kern_event_msg ev_msg1; // first kernel event - } buf; - struct kern_event_msg *ev_msg = &buf.ev_msg1; - size_t offset = 0; - - status = recv(so, &buf, sizeof(buf), 0); - if (status == -1) { - SCLOG(NULL, NULL, ASL_LEVEL_ERR, CFSTR("recv() failed: %s"), strerror(errno)); - CFSocketInvalidate(s); - return; - } - - while (offset < status) { - if ((offset + ev_msg->total_size) > status) { - SCLOG(NULL, NULL, ASL_LEVEL_ERR, CFSTR("missed SYSPROTO_EVENT event, buffer not big enough")); - break; - } - - switch (ev_msg->vendor_code) { - case KEV_VENDOR_APPLE : - switch (ev_msg->kev_class) { - case KEV_NETWORK_CLASS : { - void *event_data = &ev_msg->event_data[0]; - - switch (ev_msg->kev_subclass) { - case KEV_DL_SUBCLASS : { - struct net_event_data *ev; - char if_name[IFNAMSIZ]; - - ev = (struct net_event_data *)event_data; - - snprintf(if_name, IFNAMSIZ, "%s%d", - ev->if_name, - ev->if_unit); - - switch (ev_msg->event_code) { - case KEV_DL_IF_ATTACHED : { - SCLOG(NULL, log_msg, ~ASL_LEVEL_INFO, - CFSTR("%s kernel event: %s: attached"), - elapsed(), - if_name); - break; - } - case KEV_DL_IF_DETACHING : { - SCLOG(NULL, log_msg, ~ASL_LEVEL_INFO, - CFSTR("%s kernel event: %s: detaching"), - elapsed(), - if_name); - break; - } - case KEV_DL_IF_DETACHED : { - SCLOG(NULL, log_msg, ~ASL_LEVEL_INFO, - CFSTR("%s kernel event: %s: detached"), - elapsed(), - if_name); - break; - } - case KEV_DL_LINK_OFF : { - CFStringRef str; - - str = verbose ? copyInterfaceFlags(if_name) : NULL; - SCLOG(NULL, log_msg, ~ASL_LEVEL_INFO, - CFSTR("%s kernel event: %s: link down%@"), - elapsed(), - if_name, - str != NULL ? str : CFSTR("")); - if (str != NULL) CFRelease(str); - break; - } - case KEV_DL_LINK_ON : { - CFStringRef str; - - str = verbose ? copyInterfaceFlags(if_name) : NULL; - SCLOG(NULL, log_msg, ~ASL_LEVEL_INFO, - CFSTR("%s kernel event: %s: link up%@"), - elapsed(), - if_name, - str != NULL ? str : CFSTR("")); - if (str != NULL) CFRelease(str); - break; - } - default : - break; - } - break; - } - case KEV_INET_SUBCLASS : { - char addr[128]; - struct kev_in_data *ev; - char if_name[IFNAMSIZ]; - char mask[128]; - - ev = (struct kev_in_data *)event_data; - - snprintf(if_name, IFNAMSIZ, "%s%d", - ev->link_data.if_name, - ev->link_data.if_unit); - - switch (ev_msg->event_code) { - case KEV_INET_NEW_ADDR : - case KEV_INET_CHANGED_ADDR : - case KEV_INET_ADDR_DELETED : { - struct sockaddr_in sin; - - bzero(&sin, sizeof(sin)); - sin.sin_len = sizeof(sin); - sin.sin_family = AF_INET; - sin.sin_addr = ev->ia_addr; - _SC_sockaddr_to_string((struct sockaddr *)&sin, addr, sizeof(addr)); - - bzero(&sin, sizeof(sin)); - sin.sin_len = sizeof(sin); - sin.sin_family = AF_INET; - sin.sin_addr.s_addr = ntohl(ev->ia_subnetmask); - _SC_sockaddr_to_string((struct sockaddr *)&sin, mask, sizeof(mask)); - break; - } - default : - break; - } - - switch (ev_msg->event_code) { - case KEV_INET_NEW_ADDR : { - SCLOG(NULL, log_msg, ~ASL_LEVEL_INFO, - CFSTR("%s kernel event: %s: IPv4 address added (%s/%s)"), - elapsed(), - if_name, - addr, - mask); - break; - } - case KEV_INET_CHANGED_ADDR : { - SCLOG(NULL, log_msg, ~ASL_LEVEL_INFO, - CFSTR("%s kernel event: %s: IPv4 address changed (%s/%s)"), - elapsed(), - if_name, - addr, - mask); - break; - } - case KEV_INET_ADDR_DELETED : { - SCLOG(NULL, log_msg, ~ASL_LEVEL_INFO, - CFSTR("%s kernel event: %s: IPv4 address removed (%s/%s)"), - elapsed(), - if_name, - addr, - mask); - break; - } - default : - break; - } - break; - } - case KEV_INET6_SUBCLASS : { - char addr[128]; - struct kev_in6_data *ev; - char if_name[IFNAMSIZ]; - int plen = 0; - - ev = (struct kev_in6_data *)event_data; - - snprintf(if_name, IFNAMSIZ, "%s%d", - ev->link_data.if_name, - ev->link_data.if_unit); - - switch (ev_msg->event_code) { - case KEV_INET6_NEW_USER_ADDR : - case KEV_INET6_NEW_LL_ADDR : - case KEV_INET6_CHANGED_ADDR : - case KEV_INET6_ADDR_DELETED : { - _SC_sockaddr_to_string((struct sockaddr *)&ev->ia_addr, addr, sizeof(addr)); - plen = prefixLength(&ev->ia_prefixmask); - break; - } - default : - break; - } - - switch (ev_msg->event_code) { - case KEV_INET6_NEW_USER_ADDR : - case KEV_INET6_NEW_LL_ADDR : { - SCLOG(NULL, log_msg, ~ASL_LEVEL_INFO, - CFSTR("%s kernel event: %s: IPv6 address added (%s/%d)"), - elapsed(), - if_name, - addr, - plen); - break; - } - case KEV_INET6_CHANGED_ADDR : { - SCLOG(NULL, log_msg, ~ASL_LEVEL_INFO, - CFSTR("%s kernel event: %s: IPv6 address changed (%s/%d)"), - elapsed(), - if_name, - addr, - plen); - break; - } - case KEV_INET6_ADDR_DELETED : { - SCLOG(NULL, log_msg, ~ASL_LEVEL_INFO, - CFSTR("%s kernel event: %s: IPv6 address removed"), - elapsed(), - if_name); - break; - } - default : - break; - } - break; - } - default : - break; - } - break; - } - default : - break; - } - break; - default : - /* unrecognized vendor code */ - break; - } - offset += ev_msg->total_size; - ev_msg = (struct kern_event_msg *)(void *)&buf.bytes[offset]; - } - - return; -} - - -static void -add_KernelEvent_notification() -{ - CFSocketRef es; - CFSocketContext es_context = { 0, NULL, NULL, NULL, NULL }; - struct kev_request kev_req; - CFRunLoopSourceRef rls; - int so; - int yes = 1; - - /* Open an event socket */ - so = socket(PF_SYSTEM, SOCK_RAW, SYSPROTO_EVENT); - if (so == -1) { - SCLOG(NULL, NULL, ASL_LEVEL_ERR, CFSTR("socket() failed")); - return; - } - - /* establish filter to return all events */ - kev_req.vendor_code = KEV_VENDOR_APPLE; - kev_req.kev_class = KEV_NETWORK_CLASS; - kev_req.kev_subclass = KEV_ANY_SUBCLASS; - if (ioctl(so, SIOCSKEVFILT, &kev_req) == -1) { - SCLOG(NULL, NULL, ASL_LEVEL_ERR, CFSTR("ioctl(, SIOCSKEVFILT, ) failed")); - (void)close(so); - return; - } - - if (ioctl(so, FIONBIO, &yes) == -1) { - SCLOG(NULL, NULL, ASL_LEVEL_ERR, CFSTR("ioctl(, FIONBIO, ) failed")); - (void)close(so); - return; - } - - /* Create a CFSocketRef for the PF_SYSTEM kernel event socket */ - es = CFSocketCreateWithNative(NULL, - so, - kCFSocketReadCallBack, - KernelEvent_notification, - &es_context); - - /* Create and add a run loop source for the event socket */ - rls = CFSocketCreateRunLoopSource(NULL, es, -1); - CFRelease(es); - - CFRunLoopAddSource(CFRunLoopGetCurrent(), rls, kCFRunLoopDefaultMode); - CFRelease(rls); - - return; -} - - -#pragma mark - -#pragma mark Power Management Events - - -static void -power_notification(void *refcon, io_service_t service, natural_t messageType, void *messageArgument) -{ - switch (messageType) { - case kIOMessageCanDevicePowerOff : - SCLOG(NULL, log_msg, ~ASL_LEVEL_INFO, - CFSTR("%s IORegisterForSystemPower: can device power off?"), - elapsed()); - break; - case kIOMessageDeviceWillPowerOff : - SCLOG(NULL, log_msg, ~ASL_LEVEL_INFO, - CFSTR("%s IORegisterForSystemPower: device will power off"), - elapsed()); - break; - case kIOMessageDeviceWillNotPowerOff : - SCLOG(NULL, log_msg, ~ASL_LEVEL_INFO, - CFSTR("%s IORegisterForSystemPower: device will not power off"), - elapsed()); - break; - case kIOMessageDeviceHasPoweredOn : - SCLOG(NULL, log_msg, ~ASL_LEVEL_INFO, - CFSTR("%s IORegisterForSystemPower: device has powered on"), - elapsed()); - break; - case kIOMessageCanSystemPowerOff : - SCLOG(NULL, log_msg, ~ASL_LEVEL_INFO, - CFSTR("%s IORegisterForSystemPower: can system power off?"), - elapsed()); - break; - case kIOMessageSystemWillPowerOff : - SCLOG(NULL, log_msg, ~ASL_LEVEL_INFO, - CFSTR("%s IORegisterForSystemPower: system will power off"), - elapsed()); - break; - case kIOMessageSystemWillNotPowerOff : - SCLOG(NULL, log_msg, ~ASL_LEVEL_INFO, - CFSTR("%s IORegisterForSystemPower: system will not power off"), - elapsed()); - break; - case kIOMessageCanSystemSleep : - SCLOG(NULL, log_msg, ~ASL_LEVEL_INFO, - CFSTR("%s IORegisterForSystemPower: can system sleep?"), - elapsed()); - /* - * Idle sleep is about to kick in, but applications have - * a chance to allow sleep (by calling IOAllowPowerChange) - * or to prevent sleep (by calling IOCancelPowerChange). - */ - IOAllowPowerChange(power, (long)messageArgument); - break; - case kIOMessageSystemWillSleep : - SCLOG(NULL, log_msg, ~ASL_LEVEL_INFO, - CFSTR("%s IORegisterForSystemPower: system will sleep"), - elapsed()); - IOAllowPowerChange(power, (long)messageArgument); - break; - case kIOMessageSystemWillNotSleep : - SCLOG(NULL, log_msg, ~ASL_LEVEL_INFO, - CFSTR("%s IORegisterForSystemPower: system will not sleep"), - elapsed()); - break; - case kIOMessageSystemHasPoweredOn : - SCLOG(NULL, log_msg, ~ASL_LEVEL_INFO, - CFSTR("%s IORegisterForSystemPower: system has powered on"), - elapsed()); - break; - case kIOMessageSystemWillRestart : - SCLOG(NULL, log_msg, ~ASL_LEVEL_INFO, - CFSTR("%s IORegisterForSystemPower: system will restart"), - elapsed()); - break; - case kIOMessageSystemWillPowerOn : - SCLOG(NULL, log_msg, ~ASL_LEVEL_INFO, - CFSTR("%s IORegisterForSystemPower: system will power on"), - elapsed()); - break; - default : - SCLOG(NULL, log_msg, ~ASL_LEVEL_INFO, - CFSTR("%s IORegisterForSystemPower: message=%08lx"), - elapsed(), - (long unsigned int)messageType); - break; - } - - return; -} - - -static void -add_power_notification() -{ - io_object_t iterator; - IONotificationPortRef notify; - - power = IORegisterForSystemPower(0, ¬ify, power_notification, &iterator); - if (power == MACH_PORT_NULL) { - SCLOG(NULL, NULL, ASL_LEVEL_ERR, CFSTR("IORegisterForSystemPower() failed")); - return; - } - - CFRunLoopAddSource(CFRunLoopGetCurrent(), - IONotificationPortGetRunLoopSource(notify), - kCFRunLoopCommonModes); - - return; -} - - -#ifdef kIOPMMessageSleepWakeUUIDChange -static void -wake_uuid_notification(void *refcon, io_service_t service, natural_t messageType, void *messageArgument) -{ - CFStringRef wake_uuid = NULL; - - if (messageType == kIOPMMessageSleepWakeUUIDChange) { - if (messageArgument == kIOPMMessageSleepWakeUUIDSet) { - wake_uuid = IORegistryEntryCreateCFProperty(service, CFSTR(kIOPMSleepWakeUUIDKey), NULL, 0); - } - - if (wake_uuid != NULL) { - char uuid[256]; - - _SC_cfstring_to_cstring(wake_uuid, uuid, sizeof(uuid), kCFStringEncodingUTF8); - asl_set(log_msg, MSGTRACER_KEY_DOMAIN, MY_MSGTRACER_DOMAIN); - asl_set(log_msg, MSGTRACER_KEY_UUID , uuid); - - SCLOG(NULL, log_msg, ~ASL_LEVEL_INFO, - CFSTR("%s wake UUID notification: UUID set (%@)"), - elapsed(), - wake_uuid); - - CFRelease(wake_uuid); - } else { - asl_unset(log_msg, MSGTRACER_KEY_DOMAIN); - asl_unset(log_msg, MSGTRACER_KEY_UUID); - - SCLOG(NULL, log_msg, ~ASL_LEVEL_INFO, - CFSTR("%s wake UUID notification: UUID not set"), - elapsed()); - } - } - - return; -} - - -static void -add_wake_uuid_notification() -{ - kern_return_t kr; - io_object_t notification = IO_OBJECT_NULL; - IONotificationPortRef notifyPort; - io_service_t service; - - notifyPort = IONotificationPortCreate(kIOMasterPortDefault); - service = IORegistryEntryFromPath(kIOMasterPortDefault, - kIOPowerPlane ":/IOPowerConnection/IOPMrootDomain"); - kr = IOServiceAddInterestNotification(notifyPort, - service, - kIOGeneralInterest, - wake_uuid_notification, - NULL, // refCon - ¬ification); - if (kr != KERN_SUCCESS) { - SCLOG(NULL, NULL, ASL_LEVEL_ERR, - CFSTR("IOServiceAddInterestNotification() failed, kr=0x%x"), - kr); - return; - } - - CFRunLoopAddSource(CFRunLoopGetCurrent(), - IONotificationPortGetRunLoopSource(notifyPort), - kCFRunLoopDefaultMode); - - wake_uuid_notification(NULL, - service, - kIOPMMessageSleepWakeUUIDChange, - kIOPMMessageSleepWakeUUIDSet); - - return; -} -#endif // kIOPMMessageSleepWakeUUIDChange - - -#pragma mark - -#pragma mark SCDynamicStore "network" Events - - -static void -NetworkChange_notification(SCDynamicStoreRef store, CFArrayRef changedKeys, void *context) -{ - CFIndex i; - CFIndex nk; - CFMutableStringRef str; - - str = CFStringCreateMutable(NULL, 0); - CFStringAppendFormat(str, - NULL, - CFSTR("%s SCDynamicStore \"network\" notification"), - elapsed()); - - nk = CFArrayGetCount(changedKeys); - for (i = 0; i < nk; i++) { - CFArrayRef components; - CFStringRef key; - CFIndex nc; - - key = CFArrayGetValueAtIndex(changedKeys, i); - - components = CFStringCreateArrayBySeparatingStrings(NULL, key, CFSTR("/")); - if (components == NULL) { - CFStringAppendFormat(str, NULL, CFSTR("\n%@"), key); - continue; - } - - nc = CFArrayGetCount(components); - switch (nc) { - case 5 : { - CFStringRef entity_id; - - entity_id = CFArrayGetValueAtIndex(components, 4); - if (CFEqual(entity_id, kSCEntNetLink)) { - CFDictionaryRef dict; - const char *val = "?"; - - dict = SCDynamicStoreCopyValue(store, key); - if (dict != NULL) { - CFBooleanRef link; - - link = CFDictionaryGetValue(dict, kSCPropNetLinkActive); - if (link != NULL) { - val = CFBooleanGetValue(link) ? "up" : "down"; - } - - CFRelease(dict); - } - CFStringAppendFormat(str, NULL, CFSTR("\n%@ (%s)"), key, val); - } else if (CFEqual(entity_id, kSCEntNetIPv4) || - CFEqual(entity_id, kSCEntNetIPv6) || - CFEqual(entity_id, kSCEntNetDNS)) { - CFDictionaryRef dict; - - dict = SCDynamicStoreCopyValue(store, key); - if (dict != NULL) { - CFStringRef val; - - val = _SCCopyDescription(dict, NULL); - CFStringAppendFormat(str, NULL, CFSTR("\n%@ : %@"), key, val); - CFRelease(val); - CFRelease(dict); - } else { - CFStringAppendFormat(str, NULL, CFSTR("\n%@ : removed"), key); - } - } else if (CFEqual(entity_id, kSCEntNetAirPort)) { - CFDictionaryRef dict; - - dict = SCDynamicStoreCopyValue(store, key); - if (dict != NULL) { - CFStringRef ssid_str; - - ssid_str = CFDictionaryGetValue(dict, CFSTR("SSID_STR")); - if (ssid_str != NULL) { - CFDataRef bssid; - - bssid = CFDictionaryGetValue(dict, CFSTR("BSSID")); - CFStringAppendFormat(str, NULL, CFSTR("\n%@ : SSID: %@ BSSID: %s"), - key, - ssid_str, - (bssid != NULL) ? ether_ntoa((struct ether_addr *)CFDataGetBytePtr(bssid)) : ""); - } else { - CFStringAppendFormat(str, NULL, CFSTR("\n%@ : no SSID"), key); - } - CFRelease(dict); - } else { - CFStringAppendFormat(str, NULL, CFSTR("\n%@ : removed"), key); - } - } else if (CFEqual(entity_id, kSCEntNetService)) { - CFDictionaryRef dict; - CFStringRef rank = kSCNetworkServicePrimaryRankDefault; - - dict = SCDynamicStoreCopyValue(store, key); - if ((dict == NULL) || - !CFDictionaryGetValueIfPresent(dict, - kSCPropNetServicePrimaryRank, - (const void **)&rank)) { - rank = kSCNetworkServicePrimaryRankDefault; - } - CFStringAppendFormat(str, NULL, CFSTR("\n%@ : Rank = %@"), key, rank); - if (dict != NULL) CFRelease(dict); - } else { - CFStringAppendFormat(str, NULL, CFSTR("\n%@"), key); - } - break; - } - - case 4 : { - static CFStringRef rank_setup_prefix = NULL; - static CFStringRef rank_state_prefix = NULL; - - if (rank_setup_prefix == NULL) { - rank_setup_prefix = SCDynamicStoreKeyCreateNetworkServiceEntity(NULL, - kSCDynamicStoreDomainSetup, - CFSTR(""), - NULL); - rank_state_prefix = SCDynamicStoreKeyCreateNetworkServiceEntity(NULL, - kSCDynamicStoreDomainState, - CFSTR(""), - NULL); - } - - if (CFStringHasPrefix(key, rank_setup_prefix) || - CFStringHasPrefix(key, rank_state_prefix)) { - CFDictionaryRef dict; - CFStringRef rank = kSCNetworkServicePrimaryRankDefault; - - dict = SCDynamicStoreCopyValue(store, key); - if ((dict == NULL) || - !CFDictionaryGetValueIfPresent(dict, - kSCPropNetServicePrimaryRank, - (const void **)&rank)) { - rank = kSCNetworkServicePrimaryRankDefault; - } - CFStringAppendFormat(str, NULL, CFSTR("\n%@ : Rank = %@"), key, rank); - if (dict != NULL) CFRelease(dict); - } else { - CFStringAppendFormat(str, NULL, CFSTR("\n%@"), key); - } - break; - } - - case 2 : - if (CFEqual(CFArrayGetValueAtIndex(components, 1), - CFSTR(kIOPMSystemPowerCapabilitiesKeySuffix))) { - CFNumberRef num; - - num = SCDynamicStoreCopyValue(store, key); - if (num != NULL) { - IOPMSystemPowerStateCapabilities capabilities; - - if (isA_CFNumber(num) && - CFNumberGetValue(num, kCFNumberSInt32Type, &capabilities)) { - CFStringAppendFormat(str, NULL, CFSTR("\n%@ (0x%x)"), key, capabilities); - } - - CFRelease(num); - } - } else { - CFStringAppendFormat(str, NULL, CFSTR("\n%@"), key); - } - break; - - default : - CFStringAppendFormat(str, NULL, CFSTR("\n%@"), key); - break; - } - - CFRelease(components); - } - - SCLOG(NULL, log_msg, ~ASL_LEVEL_INFO, CFSTR("%@"), str); - CFRelease(str); - return; -} - - -static void -add_NetworkChange_keys(CFMutableArrayRef keys, - CFMutableArrayRef patterns, - CFStringRef entity, - Boolean doGlobal, - Boolean doService, - Boolean doInterface) -{ - CFStringRef key; - CFStringRef pattern; - - if (doGlobal) { - key = SCDynamicStoreKeyCreateNetworkGlobalEntity(NULL, kSCDynamicStoreDomainSetup, entity); - CFArrayAppendValue(keys, key); - CFRelease(key); - - key = SCDynamicStoreKeyCreateNetworkGlobalEntity(NULL, kSCDynamicStoreDomainState, entity); - CFArrayAppendValue(keys, key); - CFRelease(key); - } - - if (doService) { - pattern = SCDynamicStoreKeyCreateNetworkServiceEntity(NULL, kSCDynamicStoreDomainSetup, kSCCompAnyRegex, entity); - CFArrayAppendValue(patterns, pattern); - CFRelease(pattern); - - pattern = SCDynamicStoreKeyCreateNetworkServiceEntity(NULL, kSCDynamicStoreDomainState, kSCCompAnyRegex, entity); - CFArrayAppendValue(patterns, pattern); - CFRelease(pattern); - } - - if (doInterface) { - pattern = SCDynamicStoreKeyCreateNetworkInterfaceEntity(NULL, kSCDynamicStoreDomainState, kSCCompAnyRegex, entity); - CFArrayAppendValue(patterns, pattern); - CFRelease(pattern); - } - - return; -} - - -static void -add_NetworkChange_notification() -{ - CFStringRef dns_key; - CFStringRef key; - CFMutableArrayRef keys; - Boolean ok; - CFMutableArrayRef patterns; - SCDynamicStoreRef store; - CFRunLoopSourceRef rls; - - store = SCDynamicStoreCreate(NULL, CFSTR("Logger.bundle-NetworkChange"), NetworkChange_notification, NULL); - if (store == NULL) { - SCLOG(NULL, NULL, ASL_LEVEL_ERR, CFSTR("SCDynamicStoreCreate() failed")); - return; - } - - keys = CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks); - patterns = CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks); - - // Interface list - - key = SCDynamicStoreKeyCreateNetworkInterface(NULL, kSCDynamicStoreDomainState); - CFArrayAppendValue(keys, key); - CFRelease(key); - - // IPv4 - - add_NetworkChange_keys(keys, patterns, kSCEntNetIPv4, TRUE, TRUE, TRUE); - - // IPv6 - - add_NetworkChange_keys(keys, patterns, kSCEntNetIPv6, TRUE, TRUE, TRUE); - - // PPP, VPN - - add_NetworkChange_keys(keys, patterns, kSCEntNetPPP, FALSE, TRUE, TRUE); - add_NetworkChange_keys(keys, patterns, kSCEntNetVPN, FALSE, TRUE, TRUE); - add_NetworkChange_keys(keys, patterns, kSCEntNetL2TP, FALSE, TRUE, TRUE); - add_NetworkChange_keys(keys, patterns, kSCEntNetPPTP, FALSE, TRUE, TRUE); - add_NetworkChange_keys(keys, patterns, kSCEntNetIPSec, FALSE, TRUE, TRUE); - - // Link - - add_NetworkChange_keys(keys, patterns, kSCEntNetLink, FALSE, FALSE, TRUE); - - // AirPort (e.g. BSSID) - - add_NetworkChange_keys(keys, patterns, kSCEntNetAirPort, FALSE, FALSE, TRUE); - - // DNS - - add_NetworkChange_keys(keys, patterns, kSCEntNetDNS, TRUE, TRUE, TRUE); - - dns_key = CFStringCreateWithCString(NULL, - dns_configuration_notify_key(), - kCFStringEncodingASCII); - key = CFStringCreateWithFormat(NULL, NULL, CFSTR("Notify:%@"), dns_key); - CFRelease(dns_key); - CFArrayAppendValue(keys, key); - CFRelease(key); - - // Proxies - - key = SCDynamicStoreKeyCreateProxies(NULL); - CFArrayAppendValue(keys, key); - CFRelease(key); - - // Rank - - add_NetworkChange_keys(keys, patterns, NULL, FALSE, TRUE, FALSE); // per-service - add_NetworkChange_keys(keys, patterns, kSCEntNetService, FALSE, FALSE, TRUE); // per-interface - - // ComputerName, LocalHostName - - key = SCDynamicStoreKeyCreateComputerName(NULL); - CFArrayAppendValue(keys, key); - CFRelease(key); - - key = SCDynamicStoreKeyCreateHostNames(NULL); - CFArrayAppendValue(keys, key); - CFRelease(key); - - // Power Management - - key = SCDynamicStoreKeyCreate(NULL, CFSTR("%@%@"), - kSCDynamicStoreDomainState, - CFSTR(kIOPMSystemPowerCapabilitiesKeySuffix)); - CFArrayAppendValue(keys, key); - CFRelease(key); - - - // Setup monitoring - - ok = SCDynamicStoreSetNotificationKeys(store, keys, patterns); - CFRelease(keys); - CFRelease(patterns); - if (!ok) { - SCLOG(NULL, NULL, ASL_LEVEL_ERR, CFSTR("SCDynamicStoreSetNotificationKeys() failed")); - CFRelease(store); - return; - } - - rls = SCDynamicStoreCreateRunLoopSource(NULL, store, -1); - if (rls == NULL) { - SCLOG(NULL, NULL, ASL_LEVEL_ERR, CFSTR("SCDynamicStoreCreateRunLoopSource() failed")); - CFRelease(store); - return; - } - CFRunLoopAddSource(CFRunLoopGetCurrent(), rls, kCFRunLoopDefaultMode); - CFRelease(rls); - - CFRelease(store); - return; -} - - -static void -PrimaryService_notification(SCDynamicStoreRef store, CFArrayRef changedKeys, void *context) -{ - CFDictionaryRef entity; - CFStringRef key; - static CFStringRef oldPrimary = NULL; - CFStringRef newPrimary = NULL; - - key = SCDynamicStoreKeyCreateNetworkGlobalEntity(NULL, kSCDynamicStoreDomainState, kSCEntNetIPv4); - entity = SCDynamicStoreCopyValue(store, key); - CFRelease(key); - if (isA_CFDictionary(entity) && - CFDictionaryGetValueIfPresent(entity, - kSCDynamicStorePropNetPrimaryService, - (const void **)&newPrimary) && - isA_CFString(newPrimary)) { - CFRetain(newPrimary); - } else { - newPrimary = NULL; - } - - if (!_SC_CFEqual(oldPrimary, newPrimary)) { - if (newPrimary != NULL) { - CFStringRef newInterface; - - newInterface = CFDictionaryGetValue(entity, kSCDynamicStorePropNetPrimaryInterface); - SCLOG(NULL, log_msg, ~ASL_LEVEL_INFO, - CFSTR("%s Primary service: %@ (%@)"), - elapsed(), - newPrimary, - newInterface != NULL ? newInterface : CFSTR("?")); - } else { - SCLOG(NULL, log_msg, ~ASL_LEVEL_INFO, - CFSTR("%s Primary service: removed"), - elapsed()); - } - } - - if (oldPrimary != NULL) CFRelease(oldPrimary); - oldPrimary = newPrimary; - - if (entity != NULL) CFRelease(entity); - return; -} - - -static void -add_PrimaryService_notification() -{ - CFStringRef key; - CFMutableArrayRef keys; - Boolean ok; - SCDynamicStoreRef store; - CFRunLoopSourceRef rls; - - store = SCDynamicStoreCreate(NULL, CFSTR("Logger.bundle-PrimaryService"), PrimaryService_notification, NULL); - if (store == NULL) { - SCLOG(NULL, NULL, ASL_LEVEL_ERR, CFSTR("SCDynamicStoreCreate() failed")); - return; - } - - keys = CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks); - key = SCDynamicStoreKeyCreateNetworkGlobalEntity(NULL, kSCDynamicStoreDomainState, kSCEntNetIPv4); - CFArrayAppendValue(keys, key); - CFRelease(key); - - ok = SCDynamicStoreSetNotificationKeys(store, keys, NULL); - CFRelease(keys); - if (!ok) { - SCLOG(NULL, NULL, ASL_LEVEL_ERR, CFSTR("SCDynamicStoreSetNotificationKeys() failed")); - CFRelease(store); - return; - } - - rls = SCDynamicStoreCreateRunLoopSource(NULL, store, -1); - if (rls == NULL) { - SCLOG(NULL, NULL, ASL_LEVEL_ERR, CFSTR("SCDynamicStoreCreateRunLoopSource() failed")); - CFRelease(store); - return; - } - CFRunLoopAddSource(CFRunLoopGetCurrent(), rls, kCFRunLoopDefaultMode); - CFRelease(rls); - - CFRelease(store); - return; -} - - -#pragma mark - -#pragma mark Reachability Events - - -static void -reachability_notification(SCNetworkReachabilityRef ref, SCNetworkReachabilityFlags flags, void *info) -{ - CFStringRef hostname = (CFStringRef)info; - - SCLOG(NULL, log_msg, ~ASL_LEVEL_INFO, - CFSTR("%s reachability changed: %@: flags=0x%08x"), - elapsed(), - hostname, - flags); - return; -} - - -static void -add_reachability_notification(CFArrayRef hosts) -{ - SCNetworkReachabilityContext context = { 0, NULL, CFRetain, CFRelease, CFCopyDescription }; - CFIndex i; - CFIndex n; - SCNetworkReachabilityRef target; - - struct watch { - in_addr_t addr; - CFStringRef name; - } watchAddresses[] = { { 0, CFSTR("0.0.0.0") }, - { IN_LINKLOCALNETNUM, CFSTR("169.254.0.0") }, - { (u_int32_t)0xe00000fb, CFSTR("224.0.0.251") }, - }; - - for (i = 0; i < sizeof(watchAddresses)/sizeof(watchAddresses[0]); i++) { - struct sockaddr_in sin; - - bzero(&sin, sizeof(sin)); - sin.sin_len = sizeof(sin); - sin.sin_family = AF_INET; - sin.sin_addr.s_addr = htonl(watchAddresses[i].addr); - - target = SCNetworkReachabilityCreateWithAddress(NULL, (struct sockaddr *)&sin); - if (target == NULL) { - SCLOG(NULL, NULL, ASL_LEVEL_ERR, CFSTR("SCNetworkReachabilityCreateWithAddress() failed")); - return; - } - - context.info = (void *)watchAddresses[i].name; - if (!SCNetworkReachabilitySetCallback(target, reachability_notification, &context)) { - SCLOG(NULL, NULL, ASL_LEVEL_ERR, CFSTR("SCNetworkReachabilitySetCallback() failed")); - CFRelease(target); - return; - } - - if (!SCNetworkReachabilityScheduleWithRunLoop(target, CFRunLoopGetCurrent(), kCFRunLoopCommonModes)) { - SCLOG(NULL, NULL, ASL_LEVEL_ERR, CFSTR("SCNetworkReachabilityScheduleWithRunLoop() failed")); - CFRelease(target); - return; - } - - CFRelease(target); - } - - n = (hosts != NULL) ? CFArrayGetCount(hosts) : 0; - for (i = 0; i < n; i++) { - CFStringRef host; - char *nodename; - - host = CFArrayGetValueAtIndex(hosts, i); - if (!isA_CFString(host) || (CFStringGetLength(host) == 0)) { - continue; - } - - nodename = _SC_cfstring_to_cstring(host, NULL, 0, kCFStringEncodingUTF8); - target = SCNetworkReachabilityCreateWithName(NULL, nodename); - CFAllocatorDeallocate(NULL, nodename); - if (target == NULL) { - SCLOG(NULL, NULL, ASL_LEVEL_ERR, CFSTR("SCNetworkReachabilityCreateWithName() failed")); - return; - } - - context.info = (void *)host; - if (!SCNetworkReachabilitySetCallback(target, reachability_notification, &context)) { - SCLOG(NULL, NULL, ASL_LEVEL_ERR, CFSTR("SCNetworkReachabilitySetCallback() failed")); - CFRelease(target); - return; - } - - if (!SCNetworkReachabilityScheduleWithRunLoop(target, CFRunLoopGetCurrent(), kCFRunLoopCommonModes)) { - SCLOG(NULL, NULL, ASL_LEVEL_ERR, CFSTR("SCNetworkReachabilityScheduleWithRunLoop() failed")); - CFRelease(target); - return; - } - - CFRelease(target); - } - - return; -} - - -#pragma mark - -#pragma mark Console User/Information Events - - -#if !TARGET_OS_EMBEDDED -static void -console_notification(SCDynamicStoreRef store, CFArrayRef changedKeys, void *context) -{ - gid_t gid; - CFArrayRef info; - CFMutableStringRef str = CFStringCreateMutable(NULL, 0); - uid_t uid; - CFStringRef user; - - CFStringAppendFormat(str, - NULL, - CFSTR("%s SCDynamicStore console notification"), - elapsed()); - - user = SCDynamicStoreCopyConsoleUser(store, &uid, &gid); - if (user != NULL) { - CFStringAppendFormat(str, NULL, CFSTR("\nconsole user = %@"), user); - CFRelease(user); - } else { - CFStringAppendFormat(str, NULL, CFSTR("\nno console user")); - } - - info = SCDynamicStoreCopyConsoleInformation(store); - if (info != NULL) { - CFIndex i; - CFIndex n; - - n = CFArrayGetCount(info); - for (i = 0; i < n; i++) { - CFDictionaryRef session; - CFNumberRef sessionID; - CFStringRef sessionUserName; - CFBooleanRef sessionOnConsole; - - session = CFArrayGetValueAtIndex(info, i); - sessionID = CFDictionaryGetValue(session, kSCConsoleSessionID); - sessionUserName = CFDictionaryGetValue(session, kSCConsoleSessionUserName); - sessionOnConsole = CFDictionaryGetValue(session, kSCConsoleSessionOnConsole); - - CFStringAppendFormat(str, NULL, CFSTR("\n%ld : id=%@, user=%@, console=%s"), - i, - sessionID, - sessionUserName != NULL ? sessionUserName : CFSTR("?"), - sessionOnConsole != NULL ? CFBooleanGetValue(sessionOnConsole) ? "yes" : "no" : "?"); - } - - CFRelease(info); - } - - SCLOG(NULL, log_msg, ~ASL_LEVEL_INFO, CFSTR("%@"), str); - CFRelease(str); - return; -} - - -static void -add_console_notification() -{ - CFStringRef key; - CFMutableArrayRef keys; - Boolean ok; - SCDynamicStoreRef store; - CFRunLoopSourceRef rls; - - store = SCDynamicStoreCreate(NULL, CFSTR("Logger.bundle-console"), console_notification, NULL); - if (store == NULL) { - SCLOG(NULL, NULL, ASL_LEVEL_ERR, CFSTR("SCDynamicStoreCreate() failed")); - return; - } - - keys = CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks); - - key = SCDynamicStoreKeyCreateConsoleUser(NULL); - CFArrayAppendValue(keys, key); - CFRelease(key); - - ok = SCDynamicStoreSetNotificationKeys(store, keys, NULL); - CFRelease(keys); - if (!ok) { - SCLOG(NULL, NULL, ASL_LEVEL_ERR, CFSTR("SCDynamicStoreSetNotificationKeys() failed")); - CFRelease(store); - return; - } - - rls = SCDynamicStoreCreateRunLoopSource(NULL, store, -1); - if (rls == NULL) { - SCLOG(NULL, NULL, ASL_LEVEL_ERR, CFSTR("SCDynamicStoreCreateRunLoopSource() failed")); - CFRelease(store); - return; - } - CFRunLoopAddSource(CFRunLoopGetCurrent(), rls, kCFRunLoopDefaultMode); - CFRelease(rls); - - CFRelease(store); - return; -} -#endif // !TARGET_OS_EMBEDDED - - -#pragma mark - -#pragma mark Directory Services Events - - -//#include -#ifndef kDSStdNotifySearchPolicyChanged -#define kDSStdNotifySearchPolicyChanged "com.apple.DirectoryService.NotifyTypeStandard:SearchPolicyChanged" -#endif - - -#if !TARGET_OS_EMBEDDED -static void -directoryServices_notification(SCDynamicStoreRef store, CFArrayRef changedKeys, void *context) -{ - CFIndex i; - CFIndex n; - CFMutableStringRef str = CFStringCreateMutable(NULL, 0); - - CFStringAppendFormat(str, - NULL, - CFSTR("%s SCDynamicStore DirectoryServices notification"), - elapsed()); - - n = CFArrayGetCount(changedKeys); - for (i = 0; i < n; i++) { - CFStringRef key; - - key = CFArrayGetValueAtIndex(changedKeys, i); - CFStringAppendFormat(str, NULL, CFSTR("\n%@"), key); - } - - SCLOG(NULL, log_msg, ~ASL_LEVEL_INFO, CFSTR("%@"), str); - CFRelease(str); - return; -} - - -static void -add_DirectoryServices_notification() -{ - CFStringRef key; - CFMutableArrayRef keys; - Boolean ok; - SCDynamicStoreRef store; - CFRunLoopSourceRef rls; - - store = SCDynamicStoreCreate(NULL, CFSTR("Logger.bundle-directoryServices"), directoryServices_notification, NULL); - if (store == NULL) { - SCLOG(NULL, NULL, ASL_LEVEL_ERR, CFSTR("SCDynamicStoreCreate() failed")); - return; - } - - keys = CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks); - - key = CFSTR(kDSStdNotifySearchPolicyChanged); - CFArrayAppendValue(keys, key); -// CFRelease(key); - - ok = SCDynamicStoreSetNotificationKeys(store, keys, NULL); - CFRelease(keys); - if (!ok) { - SCLOG(NULL, NULL, ASL_LEVEL_ERR, CFSTR("SCDynamicStoreSetNotificationKeys() failed")); - CFRelease(store); - return; - } - - rls = SCDynamicStoreCreateRunLoopSource(NULL, store, -1); - if (rls == NULL) { - SCLOG(NULL, NULL, ASL_LEVEL_ERR, CFSTR("SCDynamicStoreCreateRunLoopSource() failed")); - CFRelease(store); - return; - } - CFRunLoopAddSource(CFRunLoopGetCurrent(), rls, kCFRunLoopDefaultMode); - CFRelease(rls); - - CFRelease(store); - return; -} -#endif // !TARGET_OS_EMBEDDED - - -#pragma mark - -#pragma mark DNS Configuration Events - - -static void -dnsinfo_notification(CFMachPortRef port, void *msg, CFIndex size, void *info) -{ - SCLOG(NULL, log_msg, ~ASL_LEVEL_INFO, - CFSTR("%s dnsinfo notification"), - elapsed()); - - return; -} - - -static void -add_dnsinfo_notification() -{ - const char *key; - CFMachPortRef mp; - mach_port_t notify_port; - int notify_token; - CFRunLoopSourceRef rls; - uint32_t status; - - key = dns_configuration_notify_key(); - status = notify_register_mach_port(key, ¬ify_port, 0, ¬ify_token); - if (status != NOTIFY_STATUS_OK) { - SCLOG(NULL, NULL, ASL_LEVEL_ERR, CFSTR("notify_register_mach_port() failed")); - return; - } - - mp = _SC_CFMachPortCreateWithPort("Logger/dns_configuration", notify_port, dnsinfo_notification, NULL); - if (mp == NULL) { - SCLOG(NULL, NULL, ASL_LEVEL_ERR, CFSTR("CFMachPortCreateWithPort() failed")); - (void)notify_cancel(notify_token); - return; - } - - rls = CFMachPortCreateRunLoopSource(NULL, mp, -1); - if (rls == NULL) { - SCLOG(NULL, NULL, ASL_LEVEL_ERR, CFSTR("SCDynamicStoreCreateRunLoopSource() failed")); - CFRelease(mp); - (void)notify_cancel(notify_token); - return; - } - CFRunLoopAddSource(CFRunLoopGetCurrent(), rls, kCFRunLoopDefaultMode); - CFRelease(rls); - - CFRelease(mp); - return; -} - - -#pragma mark - -#pragma mark Network Information Events - - -static void -nwi_notification(CFMachPortRef port, void *msg, CFIndex size, void *info) -{ - SCLOG(NULL, log_msg, ~ASL_LEVEL_INFO, - CFSTR("%s network_information notification"), - elapsed()); - - return; -} - - -static void -add_nwi_notification() -{ - const char *key; - CFMachPortRef mp; - mach_port_t notify_port; - int notify_token; - CFRunLoopSourceRef rls; - uint32_t status; - - key = nwi_state_get_notify_key(); - status = notify_register_mach_port(key, ¬ify_port, 0, ¬ify_token); - if (status != NOTIFY_STATUS_OK) { - SCLOG(NULL, NULL, ASL_LEVEL_ERR, CFSTR("notify_register_mach_port() failed")); - return; - } - - mp = _SC_CFMachPortCreateWithPort("Logger/nwi", notify_port, nwi_notification, NULL); - if (mp == NULL) { - SCLOG(NULL, NULL, ASL_LEVEL_ERR, CFSTR("CFMachPortCreateWithPort() failed")); - (void)notify_cancel(notify_token); - return; - } - - rls = CFMachPortCreateRunLoopSource(NULL, mp, -1); - if (rls == NULL) { - SCLOG(NULL, NULL, ASL_LEVEL_ERR, CFSTR("SCDynamicStoreCreateRunLoopSource() failed")); - CFRelease(mp); - (void)notify_cancel(notify_token); - return; - } - CFRunLoopAddSource(CFRunLoopGetCurrent(), rls, kCFRunLoopDefaultMode); - CFRelease(rls); - - CFRelease(mp); - return; -} - - -#pragma mark - -#pragma mark Network Configuration Change Events - - -static void -network_notification(CFMachPortRef port, void *msg, CFIndex size, void *info) -{ - SCLOG(NULL, log_msg, ~ASL_LEVEL_INFO, - CFSTR("%s network_change notification"), - elapsed()); - - return; -} - - -static void -add_network_notification() -{ - CFMachPortRef mp; - mach_port_t notify_port; - int notify_token; - CFRunLoopSourceRef rls; - uint32_t status; - - status = notify_register_mach_port(_SC_NOTIFY_NETWORK_CHANGE, - ¬ify_port, - 0, - ¬ify_token); - if (status != NOTIFY_STATUS_OK) { - SCLOG(NULL, NULL, ASL_LEVEL_ERR, CFSTR("notify_register_mach_port() failed")); - return; - } - - mp = _SC_CFMachPortCreateWithPort("Logger/network_change", notify_port, network_notification, NULL); - if (mp == NULL) { - SCLOG(NULL, NULL, ASL_LEVEL_ERR, CFSTR("CFMachPortCreateWithPort() failed")); - (void)notify_cancel(notify_token); - return; - } - - rls = CFMachPortCreateRunLoopSource(NULL, mp, -1); - if (rls == NULL) { - SCLOG(NULL, NULL, ASL_LEVEL_ERR, CFSTR("SCDynamicStoreCreateRunLoopSource() failed")); - CFRelease(mp); - (void)notify_cancel(notify_token); - return; - } - CFRunLoopAddSource(CFRunLoopGetCurrent(), rls, kCFRunLoopDefaultMode); - CFRelease(rls); - - CFRelease(mp); - return; -} - - -#pragma mark - -#pragma mark SMB Configuration Events - - -#define SMBCONFIGURATION_NOTIFY_KEY "com.apple.system.SystemConfiguration.smb_configuration" - - -#if !TARGET_OS_EMBEDDED -static void -smbconf_notification(CFMachPortRef port, void *msg, CFIndex size, void *info) -{ - SCLOG(NULL, log_msg, ~ASL_LEVEL_INFO, - CFSTR("%s smb.conf notification"), - elapsed()); - - return; -} - - -static void -add_smbconf_notification() -{ - CFMachPortRef mp; - mach_port_t notify_port; - int notify_token; - CFRunLoopSourceRef rls; - uint32_t status; - - status = notify_register_mach_port(SMBCONFIGURATION_NOTIFY_KEY, - ¬ify_port, - 0, - ¬ify_token); - if (status != NOTIFY_STATUS_OK) { - SCLOG(NULL, NULL, ASL_LEVEL_ERR, CFSTR("notify_register_mach_port() failed")); - return; - } - - mp = _SC_CFMachPortCreateWithPort("Logger/smb_configuration", notify_port, smbconf_notification, NULL); - if (mp == NULL) { - SCLOG(NULL, NULL, ASL_LEVEL_ERR, CFSTR("CFMachPortCreateWithPort() failed")); - (void)notify_cancel(notify_token); - return; - } - - rls = CFMachPortCreateRunLoopSource(NULL, mp, -1); - if (rls == NULL) { - SCLOG(NULL, NULL, ASL_LEVEL_ERR, CFSTR("SCDynamicStoreCreateRunLoopSource() failed")); - CFRelease(mp); - (void)notify_cancel(notify_token); - return; - } - CFRunLoopAddSource(CFRunLoopGetCurrent(), rls, kCFRunLoopDefaultMode); - CFRelease(rls); - - CFRelease(mp); - return; -} -#endif // !TARGET_OS_EMBEDDED - - -#pragma mark - -#pragma mark pututxline Events - - -#ifndef TARGET_OS_EMBEDDED -static const char * -ut_time(struct utmpx *utmpx) -{ - static char str[16]; - struct tm tm; - - (void)localtime_r(&utmpx->ut_tv.tv_sec, &tm); - snprintf(str, sizeof(str), "%2d:%02d:%02d.%03d", - tm.tm_hour, - tm.tm_min, - tm.tm_sec, - utmpx->ut_tv.tv_usec / 1000); - - return str; -} - - -static const char * -ut_id(struct utmpx *utmpx) -{ - char *cp; - static char str[16]; - - cp = utmpx->ut_id + sizeof(utmpx->ut_id); - while(--cp >= utmpx->ut_id && isprint(*cp)) {} - if(cp < utmpx->ut_id) { - snprintf(str, sizeof(str), "%-4.4s", utmpx->ut_id); - } else { - snprintf(str, sizeof(str), - "0x%2.2x%2.2x%2.2x%2.2x", - utmpx->ut_id[0], - utmpx->ut_id[1], - utmpx->ut_id[2], - utmpx->ut_id[3]); - } - - return str; -} - - -static const char * -ut_pid(struct utmpx *utmpx) -{ - static char pid[16]; - - snprintf(pid, sizeof(pid), "%d", utmpx->ut_pid); - - return pid; -} - - -static void -pututxline_notification(CFMachPortRef port, void *msg, CFIndex size, void *info) -{ - CFMutableStringRef str = CFStringCreateMutable(NULL, 0); - struct utmpx *utmpx; - utmpx_t utx; - - CFStringAppendFormat(str, - NULL, - CFSTR("%s pututxline notification"), - elapsed()); - - utx = _openutx(NULL); - while ((utmpx = _getutxent(utx)) != NULL) { - const char * entry_id = NULL; - const char * entry_line = NULL; - const char * entry_pid = NULL; - const char * entry_tv = NULL; - const char * entry_type; - const char * entry_user = NULL; - char line[128]; - int n; - - switch (utmpx->ut_type) { - case BOOT_TIME : // Time of a system boot. - entry_type = "Boot"; - entry_tv = ut_time(utmpx); - break; - case DEAD_PROCESS : // A session leader exited. - entry_type = "Dead process"; - entry_id = ut_id (utmpx); - entry_pid = ut_pid (utmpx); - entry_tv = ut_time(utmpx); - break; - case EMPTY : // No valid user accounting information. - continue; - case INIT_PROCESS : // A process spawned by init(8). - entry_type = "Init process"; - entry_id = ut_id (utmpx); - entry_pid = ut_pid (utmpx); - entry_tv = ut_time(utmpx); - break; - case LOGIN_PROCESS : // The session leader of a logged-in user. - entry_type = "Login"; - entry_id = ut_id (utmpx); - entry_user = utmpx->ut_user; - entry_pid = ut_pid (utmpx); - entry_tv = ut_time(utmpx); - break; - case NEW_TIME : // Time after system clock change. - entry_type = "New time"; - entry_tv = ut_time(utmpx); - break; - case OLD_TIME : // Time before system clock change. - entry_type = "Old time"; - entry_tv = ut_time(utmpx); - break; - case RUN_LVL : // Run level. Provided for compatibility, not used. - entry_type = "Run level"; - break; - case USER_PROCESS : // A user process. - entry_type = "User Process"; - entry_id = ut_id (utmpx); - entry_user = utmpx->ut_user; - entry_line = utmpx->ut_line; - entry_pid = ut_pid (utmpx); - entry_tv = ut_time(utmpx); - break; - case SHUTDOWN_TIME : // Time of system shutdown - entry_type = "Shutdown time"; - entry_tv = ut_time(utmpx); - break; - default : - entry_type = "Unknown"; - break; - } - - snprintf(line, sizeof(line), - // type time id=0x12345678 pid=12345 user=abcdefgh line - "\n%-13s %2s%12s %3s%-10s %4s%-5s %5s%-8s %5s%s", - entry_type, - entry_tv != NULL ? "@ " : "", - entry_tv != NULL ? entry_tv : "", // hh:mm:ss.ddd - entry_id != NULL ? "id=" : "", - entry_id != NULL ? entry_id : "", // 0x12345678 - entry_pid != NULL ? "pid=" : "", - entry_pid != NULL ? entry_pid : "", // ##### - entry_user != NULL ? "user=" : "", - entry_user != NULL ? entry_user : "", // <=256 chars - entry_line != NULL ? "line=" : "", - entry_line != NULL ? entry_line : "" // <= 32 chars - ); - - n = (int)strlen(line) - 1; - while ((n > 0) && (line[n] == ' ')) { - line[n] = '\0'; - --n; - } - - CFStringAppendFormat(str, NULL, CFSTR("%s"), line); - } - _endutxent(utx); - - SCLOG(NULL, log_msg, ~ASL_LEVEL_INFO, CFSTR("%@"), str); - CFRelease(str); - return; -} - - -static void -add_pututxline_notification() -{ - CFMachPortRef mp; - mach_port_t notify_port; - int notify_token; - CFRunLoopSourceRef rls; - uint32_t status; - - status = notify_register_mach_port(UTMPX_CHANGE_NOTIFICATION, ¬ify_port, 0, ¬ify_token); - if (status != NOTIFY_STATUS_OK) { - SCLOG(NULL, NULL, ASL_LEVEL_ERR, CFSTR("notify_register_mach_port() failed")); - return; - } - - mp = _SC_CFMachPortCreateWithPort("Logger/utmpx", notify_port, pututxline_notification, NULL); - if (mp == NULL) { - SCLOG(NULL, NULL, ASL_LEVEL_ERR, CFSTR("CFMachPortCreateWithPort() failed")); - (void)notify_cancel(notify_token); - return; - } - - rls = CFMachPortCreateRunLoopSource(NULL, mp, -1); - if (rls == NULL) { - SCLOG(NULL, NULL, ASL_LEVEL_ERR, CFSTR("SCDynamicStoreCreateRunLoopSource() failed")); - CFRelease(mp); - (void)notify_cancel(notify_token); - return; - } - CFRunLoopAddSource(CFRunLoopGetCurrent(), rls, kCFRunLoopDefaultMode); - CFRelease(rls); - - CFRelease(mp); - return; -} -#endif // !TARGET_OS_EMBEDDED - - -#pragma mark - -#pragma mark BackToMyMac Status Events - - -#ifndef kDSStdNotifyBTMMStatusChanged -#define kDSStdNotifyBTMMStatusChanged "State:/Network/BackToMyMac" -#endif - - -#if !TARGET_OS_EMBEDDED -static void -BTMM_notification(SCDynamicStoreRef store, CFArrayRef changedKeys, void *context) -{ - CFIndex i; - CFIndex n; - CFMutableStringRef str = CFStringCreateMutable(NULL, 0); - - CFStringAppendFormat(str, - NULL, - CFSTR("%s SCDynamicStore Back to My Mac notification"), - elapsed()); - - n = CFArrayGetCount(changedKeys); - for (i = 0; i < n; i++) { - CFStringRef key; - CFDictionaryRef dict; - - key = CFArrayGetValueAtIndex(changedKeys, i); - dict = SCDynamicStoreCopyValue(store, key); - if (dict != NULL) { - CFStringRef val; - - val = _SCCopyDescription(dict, NULL); - CFStringAppendFormat(str, NULL, CFSTR("\n%@ : %@"), key, val); - CFRelease(val); - CFRelease(dict); - } else { - CFStringAppendFormat(str, NULL, CFSTR("\n%@ : removed"), key); - } - } - - SCLOG(NULL, log_msg, ~ASL_LEVEL_INFO, CFSTR("%@"), str); - CFRelease(str); - return; -} - - -static void -add_BTMM_notification() -{ - CFStringRef key; - CFMutableArrayRef keys; - Boolean ok; - SCDynamicStoreRef store; - CFRunLoopSourceRef rls; - - store = SCDynamicStoreCreate(NULL, CFSTR("Logger.bundle-BackToMyMac"), BTMM_notification, NULL); - if (store == NULL) { - SCLOG(NULL, NULL, ASL_LEVEL_ERR, CFSTR("SCDynamicStoreCreate() failed")); - return; - } - - keys = CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks); - - key = CFSTR(kDSStdNotifyBTMMStatusChanged); - CFArrayAppendValue(keys, key); - - ok = SCDynamicStoreSetNotificationKeys(store, keys, NULL); - CFRelease(keys); - if (!ok) { - SCLOG(NULL, NULL, ASL_LEVEL_ERR, CFSTR("SCDynamicStoreSetNotificationKeys() failed")); - CFRelease(store); - return; - } - - rls = SCDynamicStoreCreateRunLoopSource(NULL, store, -1); - if (rls == NULL) { - SCLOG(NULL, NULL, ASL_LEVEL_ERR, CFSTR("SCDynamicStoreCreateRunLoopSource() failed")); - CFRelease(store); - return; - } - CFRunLoopAddSource(CFRunLoopGetCurrent(), rls, kCFRunLoopDefaultMode); - CFRelease(rls); - - CFRelease(store); - return; -} -#endif // !TARGET_OS_EMBEDDED - - -#pragma mark - - - -static __inline__ Boolean -bValFromDictionary(CFDictionaryRef dict, CFStringRef key) -{ - CFBooleanRef bVal; - Boolean result = FALSE; - - if ((dict != NULL) && - CFDictionaryGetValueIfPresent(dict, key, (const void **)&bVal) && - isA_CFBoolean(bVal)) { - result = CFBooleanGetValue(bVal); - } - - return result; -} - - -void -load(CFBundleRef bundle, Boolean bundleVerbose) -{ - CFDictionaryRef config; - Boolean log_all; - - verbose = bundleVerbose; - - log_msg = asl_new(ASL_TYPE_MSG); - asl_set(log_msg, ASL_KEY_FACILITY, MY_ASL_FACILITY); - - elapsed(); - - config = CFBundleGetInfoDictionary(bundle); - config = isA_CFDictionary(config); - log_all = bValFromDictionary(config, CFSTR("LOG_ALL")); - -#ifdef kIOPMMessageSleepWakeUUIDChange - if (log_all || bValFromDictionary(config, CFSTR("LOG_IO_WAKEUUID_EVENTS"))) { - add_wake_uuid_notification(); - } -#endif // kIOPMMessageSleepWakeUUIDChange - - if (log_all || bValFromDictionary(config, CFSTR("LOG_IO_SYSTEMPOWER_EVENTS"))) { - add_power_notification(); - } - - if (log_all || bValFromDictionary(config, CFSTR("LOG_NETWORK_KERNEL_EVENTS"))) { - add_KernelEvent_notification(); - } - - if (log_all || bValFromDictionary(config, CFSTR("LOG_NETWORK_INFORMATION"))) { - add_nwi_notification(); - } - - if (log_all || bValFromDictionary(config, CFSTR("LOG_NOTIFY_DNS_CONFIGURATION"))) { - add_dnsinfo_notification(); - } - - if (log_all || bValFromDictionary(config, CFSTR("LOG_NOTIFY_NETWORK_CHANGE"))) { - add_network_notification(); - } - -#if !TARGET_OS_EMBEDDED - if (log_all || bValFromDictionary(config, CFSTR("LOG_NOTIFY_SMB_CONFIGURATION"))) { - add_smbconf_notification(); - } -#endif // !TARGET_OS_EMBEDDED - -#ifndef TARGET_OS_EMBEDDED - if (log_all || bValFromDictionary(config, CFSTR("LOG_NOTIFY_UTMPX_CHANGE"))) { - add_pututxline_notification(); - } -#endif // !TARGET_OS_EMBEDDED - -#if !TARGET_OS_EMBEDDED - if (log_all || bValFromDictionary(config, CFSTR("LOG_SC_BTMM_CONFIGURATION"))) { - add_BTMM_notification(); - } -#endif // !TARGET_OS_EMBEDDED - -#if !TARGET_OS_EMBEDDED - if (log_all || bValFromDictionary(config, CFSTR("LOG_SC_CONSOLEUSER"))) { - add_console_notification(); - } -#endif // !TARGET_OS_EMBEDDED - -#if !TARGET_OS_EMBEDDED - if (log_all || bValFromDictionary(config, CFSTR("LOG_SC_DIRECTORYSERVICES_SEARCHPOLICY"))) { - add_DirectoryServices_notification(); - } -#endif // !TARGET_OS_EMBEDDED - - if (log_all || bValFromDictionary(config, CFSTR("LOG_SC_NETWORKCHANGE"))) { - add_NetworkChange_notification(); - } - - if (log_all || bValFromDictionary(config, CFSTR("LOG_SC_PRIMARYSERVICE"))) { - add_PrimaryService_notification(); - } - - if (log_all || bValFromDictionary(config, CFSTR("LOG_SC_REACHABILITY"))) { - CFArrayRef hosts = NULL; - - if ((config == NULL) || - !CFDictionaryGetValueIfPresent(config, CFSTR("LOG_SC_REACHABILITY_HOSTS"), (const void **)&hosts) || - !isA_CFArray(hosts) || - (CFArrayGetCount(hosts) == 0)) { - hosts = NULL; - } - - if (verbose) { - _sc_debug = TRUE; - } - - add_reachability_notification(hosts); - } - - return; -} - -#ifdef MAIN - -int -main(int argc, char **argv) -{ - _sc_log = FALSE; - _sc_verbose = (argc > 1) ? TRUE : FALSE; - _sc_debug = TRUE; - - load(CFBundleGetMainBundle(), (argc > 1) ? TRUE : FALSE); - CFRunLoopRun(); - /* not reached */ - exit(0); - return 0; -} - -#endif /* MAIN */ diff --git a/Plugins/PreferencesMonitor/Info.plist b/Plugins/PreferencesMonitor/Info.plist index bb78029..04bfd35 100644 --- a/Plugins/PreferencesMonitor/Info.plist +++ b/Plugins/PreferencesMonitor/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType BNDL CFBundleShortVersionString - 1.14.4 + 1.14 CFBundleSignature ???? CFBundleVersion diff --git a/Plugins/PreferencesMonitor/prefsmon.c b/Plugins/PreferencesMonitor/prefsmon.c index 22ace87..5727a67 100644 --- a/Plugins/PreferencesMonitor/prefsmon.c +++ b/Plugins/PreferencesMonitor/prefsmon.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000-2008, 2010, 2012-2014 Apple Inc. All rights reserved. + * Copyright (c) 2000-2008, 2010, 2012-2015 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -64,8 +64,114 @@ static CFMutableArrayRef unchangedPrefsKeys; /* new prefs keys which match curre static CFMutableArrayRef removedPrefsKeys; /* old prefs keys to be removed */ static Boolean rofs = FALSE; -static Boolean _verbose = FALSE; +static Boolean restorePrefs = FALSE; +#define MY_PLUGIN_NAME "PreferencesMonitor" +#define MY_PLUGIN_ID CFSTR("com.apple.SystemConfiguration." MY_PLUGIN_NAME) + +static Boolean +restorePreferences() +{ + Boolean ok = FALSE; + CFStringRef currentModel = NULL; + CFMutableStringRef modelPrefixStr = NULL; + CFArrayRef keyList = NULL; + CFIndex keyListCount; + CFIndex idx; + Boolean modified = FALSE; + int sc_status = kSCStatusFailed; + + while (TRUE) { + ok = SCPreferencesLock(prefs, TRUE); + if (ok) { + break; + } + + sc_status = SCError(); + if (sc_status == kSCStatusStale) { + SCPreferencesSynchronize(prefs); + } else { + SC_log(LOG_NOTICE, "Could not acquire network configuration lock: %s", + SCErrorString(sc_status)); + return FALSE; + } + } + + keyList = SCPreferencesCopyKeyList(prefs); + if (keyList == NULL) { + goto error; + } + + currentModel = _SC_hw_model(FALSE); + if (currentModel == NULL) { + goto error; + } + + /* Create "model:" string for prefix-check */ + modelPrefixStr = CFStringCreateMutableCopy(NULL, 0, currentModel); + CFStringAppend(modelPrefixStr, CFSTR(":")); + + keyListCount = CFArrayGetCount(keyList); + for (idx = 0; idx < keyListCount; idx++) { + CFStringRef existingKey = CFArrayGetValueAtIndex(keyList, idx); + CFStringRef key; + CFArrayRef splitKey = NULL; + CFPropertyListRef value; + + if (isA_CFString(existingKey) == NULL) { + continue; + } + + if (CFStringHasPrefix(existingKey, modelPrefixStr) == FALSE) { + continue; + } + + splitKey = CFStringCreateArrayBySeparatingStrings(NULL, existingKey, CFSTR(":")); + key = CFArrayGetValueAtIndex(splitKey, 1); + value = SCPreferencesGetValue(prefs, existingKey); + SCPreferencesSetValue(prefs, key, value); + SCPreferencesRemoveValue(prefs, existingKey); + modified = TRUE; + CFRelease(splitKey); + } + + if (modified == TRUE) { + SCPreferencesRef ni_prefs = NULL; + ni_prefs = SCPreferencesCreate(NULL, MY_PLUGIN_ID, CFSTR("NetworkInterfaces.plist")); + if (ni_prefs == NULL) { + goto error; + } + + ok = _SCNetworkConfigurationCheckValidityWithPreferences(prefs, ni_prefs, NULL); + CFRelease(ni_prefs); + + //Commit the changes only if prefs files valid + if (ok == TRUE) { + if (!SCPreferencesCommitChanges(prefs)) { + if (SCError() != EROFS) { + SC_log(LOG_NOTICE, "SCPreferencesCommitChanges() failed: %s", + SCErrorString(SCError())); + } + goto error; + + } + + (void) SCPreferencesApplyChanges(prefs); + } + } + +error: + (void) SCPreferencesUnlock(prefs); + + if (keyList != NULL) { + CFRelease(keyList); + } + if (modelPrefixStr != NULL) { + CFRelease(modelPrefixStr); + } + + return modified; +} static Boolean establishNewPreferences() @@ -89,9 +195,8 @@ establishNewPreferences() if (sc_status == kSCStatusStale) { SCPreferencesSynchronize(prefs); } else { - SCLog(TRUE, LOG_ERR, - CFSTR("Could not acquire network configuration lock: %s"), - SCErrorString(sc_status)); + SC_log(LOG_NOTICE, "Could not acquire network configuration lock: %s", + SCErrorString(sc_status)); return FALSE; } } @@ -195,7 +300,7 @@ establishNewPreferences() if (ok) { ok = SCPreferencesCommitChanges(prefs); if (ok) { - SCLog(TRUE, LOG_NOTICE, CFSTR("New network configuration saved")); + SC_log(LOG_NOTICE, "New network configuration saved"); updated = TRUE; } else { sc_status = SCError(); @@ -215,9 +320,8 @@ establishNewPreferences() } if (!ok) { - SCLog(TRUE, LOG_ERR, - CFSTR("Could not establish network configuration: %s"), - SCErrorString(sc_status)); + SC_log(LOG_NOTICE, "Could not establish network configuration: %s", + SCErrorString(sc_status)); } (void)SCPreferencesUnlock(prefs); @@ -292,8 +396,7 @@ watchQuietEnable() ok = SCDynamicStoreSetNotificationKeys(store, keys, NULL); CFRelease(keys); if (!ok) { - SCLog(TRUE, LOG_ERR, - CFSTR("SCDynamicStoreSetNotificationKeys() failed: %s\n"), SCErrorString(SCError())); + SC_log(LOG_NOTICE, "SCDynamicStoreSetNotificationKeys() failed: %s", SCErrorString(SCError())); watchQuietDisable(); } @@ -302,6 +405,25 @@ watchQuietEnable() +static Boolean +previousConfigurationAvailable() +{ + CFStringRef backupKey = NULL; + CFStringRef currentModel = NULL; + CFPropertyListRef properties = NULL; + + currentModel = _SC_hw_model(FALSE); + if (currentModel == NULL) { + goto done; + } + + /* Currently relying only if a backup of "Sets" is present */ + backupKey = CFStringCreateWithFormat(NULL, NULL, CFSTR("%@:Sets"), currentModel); + properties = SCPreferencesGetValue(prefs, backupKey); + CFRelease(backupKey); +done: + return (properties != NULL); +} static void watchQuietCallback(SCDynamicStoreRef store, CFArrayRef changedKeys, void *info) @@ -322,9 +444,14 @@ watchQuietCallback(SCDynamicStoreRef store, CFArrayRef changedKeys, void *info) static int logged = 0; (void) establishNewPreferences(); + + if (restorePrefs == TRUE) { + (void) restorePreferences(); + restorePrefs = FALSE; + } + if (_timeout && (logged++ == 0)) { - SCLog(TRUE, LOG_NOTICE, - CFSTR("Network configuration creation timed out waiting for IORegistry")); + SC_log(LOG_ERR, "Network configuration creation timed out waiting for IORegistry"); } } @@ -387,10 +514,9 @@ flatten(SCPreferencesRef prefs, subset = SCPreferencesPathGetValue(prefs, link); if (!subset) { /* if error with link */ - SCLog(TRUE, LOG_ERR, - CFSTR("SCPreferencesPathGetValue(,%@,) failed: %s"), - link, - SCErrorString(SCError())); + SC_log(LOG_NOTICE, "SCPreferencesPathGetValue(,%@,) failed: %s", + link, + SCErrorString(SCError())); return; } } @@ -540,7 +666,7 @@ updateSCDynamicStore(SCPreferencesRef prefs) */ keys = SCPreferencesCopyKeyList(prefs); if ((keys == NULL) || (CFArrayGetCount(keys) == 0)) { - SCLog(TRUE, LOG_NOTICE, CFSTR("updateConfiguration(): no preferences.")); + SC_log(LOG_NOTICE, "updateConfiguration(): no preferences"); goto done; } @@ -554,9 +680,8 @@ updateSCDynamicStore(SCPreferencesRef prefs) } if (!isA_CFDictionary(global)) { - SCLog(TRUE, LOG_ERR, - CFSTR("updateConfiguration(): %@ is not a dictionary."), - kSCPrefSystem); + SC_log(LOG_NOTICE, "updateConfiguration(): %@ is not a dictionary", + kSCPrefSystem); goto done; } @@ -575,9 +700,8 @@ updateSCDynamicStore(SCPreferencesRef prefs) } if (!isA_CFString(current)) { - SCLog(TRUE, LOG_ERR, - CFSTR("updateConfiguration(): %@ is not a string."), - kSCPrefCurrentSet); + SC_log(LOG_NOTICE, "updateConfiguration(): %@ is not a string", + kSCPrefCurrentSet); goto done; } @@ -587,17 +711,15 @@ updateSCDynamicStore(SCPreferencesRef prefs) set = SCPreferencesPathGetValue(prefs, current); if (!set) { /* if error with path */ - SCLog(TRUE, LOG_ERR, - CFSTR("%@ value (%@) not valid"), - kSCPrefCurrentSet, - current); + SC_log(LOG_NOTICE, "%@ value (%@) not valid", + kSCPrefCurrentSet, + current); goto done; } if (!isA_CFDictionary(set)) { - SCLog(TRUE, LOG_ERR, - CFSTR("updateConfiguration(): %@ is not a dictionary."), - current); + SC_log(LOG_NOTICE, "updateConfiguration(): %@ is not a dictionary", + current); goto done; } @@ -629,15 +751,12 @@ updateSCDynamicStore(SCPreferencesRef prefs) /* Update the dynamic store */ #ifndef MAIN if (!SCDynamicStoreSetMultiple(store, newPrefs, removedPrefsKeys, NULL)) { - SCLog(TRUE, LOG_ERR, - CFSTR("SCDynamicStoreSetMultiple() failed: %s"), - SCErrorString(SCError())); + SC_log(LOG_NOTICE, "SCDynamicStoreSetMultiple() failed: %s", SCErrorString(SCError())); } #else // !MAIN - SCLog(TRUE, LOG_NOTICE, - CFSTR("SCDynamicStore\nset: %@\nremove: %@\n"), - newPrefs, - removedPrefsKeys); + SC_log(LOG_DEBUG, "SCDynamicStore\nset: %@\nremove: %@", + newPrefs, + removedPrefsKeys); #endif // !MAIN CFRelease(currentPrefs); @@ -656,8 +775,12 @@ updateConfiguration(SCPreferencesRef prefs, SCPreferencesNotification notificationType, void *info) { + os_activity_t activity_id; + activity_id = os_activity_start("processing [SC] preferences.plist changes", + OS_ACTIVITY_FLAG_DEFAULT); + #if !TARGET_OS_IPHONE if ((notificationType & kSCPreferencesNotificationCommit) == kSCPreferencesNotificationCommit) { SCNetworkSetRef current; @@ -672,10 +795,10 @@ updateConfiguration(SCPreferencesRef prefs, #endif /* !TARGET_OS_IPHONE */ if ((notificationType & kSCPreferencesNotificationApply) != kSCPreferencesNotificationApply) { - return; + goto done; } - SCLog(_verbose, LOG_DEBUG, CFSTR("updating configuration")); + SC_log(LOG_INFO, "updating configuration"); /* update SCDynamicStore (Setup:) */ updateSCDynamicStore(prefs); @@ -685,6 +808,10 @@ updateConfiguration(SCPreferencesRef prefs, SCPreferencesSynchronize(prefs); } + done : + + os_activity_end(activity_id); + return; } @@ -693,7 +820,7 @@ __private_extern__ void prime_PreferencesMonitor() { - SCLog(_verbose, LOG_DEBUG, CFSTR("prime() called")); + SC_log(LOG_DEBUG, "prime() called"); /* load the initial configuration from the database */ updateConfiguration(prefs, kSCPreferencesNotificationApply, (void *)store); @@ -708,12 +835,8 @@ load_PreferencesMonitor(CFBundleRef bundle, Boolean bundleVerbose) { Boolean initPrefs = TRUE; - if (bundleVerbose) { - _verbose = TRUE; - } - - SCLog(_verbose, LOG_DEBUG, CFSTR("load() called")); - SCLog(_verbose, LOG_DEBUG, CFSTR(" bundle ID = %@"), CFBundleGetIdentifier(bundle)); + SC_log(LOG_DEBUG, "load() called"); + SC_log(LOG_DEBUG, " bundle ID = %@", CFBundleGetIdentifier(bundle)); /* open a SCDynamicStore session to allow cache updates */ store = SCDynamicStoreCreate(NULL, @@ -721,9 +844,7 @@ load_PreferencesMonitor(CFBundleRef bundle, Boolean bundleVerbose) watchQuietCallback, NULL); if (store == NULL) { - SCLog(TRUE, LOG_ERR, - CFSTR("SCDynamicStoreCreate() failed: %s"), - SCErrorString(SCError())); + SC_log(LOG_NOTICE, "SCDynamicStoreCreate() failed: %s", SCErrorString(SCError())); goto error; } @@ -747,6 +868,7 @@ load_PreferencesMonitor(CFBundleRef bundle, Boolean bundleVerbose) if (old_model != NULL && !_SC_CFEqual(old_model, new_model)) { // if new hardware need_update = TRUE; + restorePrefs = previousConfigurationAvailable(); } } @@ -761,9 +883,7 @@ load_PreferencesMonitor(CFBundleRef bundle, Boolean bundleVerbose) } } } else { - SCLog(TRUE, LOG_ERR, - CFSTR("SCPreferencesCreate() failed: %s"), - SCErrorString(SCError())); + SC_log(LOG_NOTICE, "SCPreferencesCreate() failed: %s", SCErrorString(SCError())); goto error; } @@ -771,16 +891,12 @@ load_PreferencesMonitor(CFBundleRef bundle, Boolean bundleVerbose) * register for change notifications. */ if (!SCPreferencesSetCallback(prefs, updateConfiguration, NULL)) { - SCLog(TRUE, LOG_ERR, - CFSTR("SCPreferencesSetCallBack() failed: %s"), - SCErrorString(SCError())); + SC_log(LOG_NOTICE, "SCPreferencesSetCallBack() failed: %s", SCErrorString(SCError())); goto error; } if (!SCPreferencesScheduleWithRunLoop(prefs, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode)) { - SCLog(TRUE, LOG_ERR, - CFSTR("SCPreferencesScheduleWithRunLoop() failed: %s"), - SCErrorString(SCError())); + SC_log(LOG_NOTICE, "SCPreferencesScheduleWithRunLoop() failed: %s", SCErrorString(SCError())); goto error; } diff --git a/Plugins/SCNetworkReachability/Info-EmbeddedSimulator.plist b/Plugins/SCNetworkReachability/Info-EmbeddedSimulator.plist deleted file mode 100644 index 854a397..0000000 --- a/Plugins/SCNetworkReachability/Info-EmbeddedSimulator.plist +++ /dev/null @@ -1,31 +0,0 @@ - - - - - Builtin - - CFBundleDevelopmentRegion - English - CFBundleExecutable - SCNetworkReachability - CFBundleIdentifier - com.apple.SystemConfiguration.SCNetworkReachability - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - com.apple.SystemConfiguration.SCNetworkReachability - CFBundlePackageType - BNDL - CFBundleShortVersionString - 1.14.4 - CFBundleSignature - ???? - CFBundleVersion - 1.13 - MachServices - - com.apple.SystemConfiguration.SCNetworkReachability_sim - - - - diff --git a/Plugins/SCNetworkReachability/Info.plist b/Plugins/SCNetworkReachability/Info.plist deleted file mode 100644 index 55ce144..0000000 --- a/Plugins/SCNetworkReachability/Info.plist +++ /dev/null @@ -1,31 +0,0 @@ - - - - - Builtin - - CFBundleDevelopmentRegion - English - CFBundleExecutable - SCNetworkReachability - CFBundleIdentifier - com.apple.SystemConfiguration.SCNetworkReachability - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - com.apple.SystemConfiguration.SCNetworkReachability - CFBundlePackageType - BNDL - CFBundleShortVersionString - 1.14.4 - CFBundleSignature - ???? - CFBundleVersion - 1.14 - MachServices - - com.apple.SystemConfiguration.SCNetworkReachability - - - - diff --git a/Plugins/SimulatorSupport/Info.plist b/Plugins/SimulatorSupport/Info.plist index e6d9132..4ae6f27 100644 --- a/Plugins/SimulatorSupport/Info.plist +++ b/Plugins/SimulatorSupport/Info.plist @@ -17,7 +17,7 @@ CFBundlePackageType BNDL CFBundleShortVersionString - 1.14.4 + 1.14 CFBundleSignature ???? CFBundleVersion diff --git a/Plugins/SimulatorSupport/simulator_support.c b/Plugins/SimulatorSupport/simulator_support.c index 529dcb8..7c19e4c 100644 --- a/Plugins/SimulatorSupport/simulator_support.c +++ b/Plugins/SimulatorSupport/simulator_support.c @@ -1,15 +1,15 @@ /* - * Copyright (c) 2013 Apple Inc. All rights reserved. + * Copyright (c) 2013, 2015 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ - * + * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. - * + * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, @@ -17,7 +17,7 @@ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. - * + * * @APPLE_LICENSE_HEADER_END@ */ @@ -44,7 +44,6 @@ #include "cache.h" -static Boolean _verbose = FALSE; static CFMutableArrayRef mirror_keys = NULL; static CFMutableArrayRef mirror_patterns = NULL; static SCDynamicStoreRef store_host = NULL; @@ -198,7 +197,7 @@ prime_SimulatorSupport() CFDictionaryRef content_host; CFIndex n; - SCLog(_verbose, LOG_DEBUG, CFSTR("prime() called")); + SC_log(LOG_DEBUG, "prime() called"); // copy current content from base OS store to _Sim store content_host = SCDynamicStoreCopyMultiple(store_host, mirror_keys, mirror_patterns); @@ -245,12 +244,8 @@ load_SimulatorSupport(CFBundleRef bundle, Boolean bundleVerbose) CFMutableDictionaryRef options; CFRunLoopSourceRef rls; - if (bundleVerbose) { - _verbose = TRUE; - } - - SCLog(_verbose, LOG_DEBUG, CFSTR("load() called")); - SCLog(_verbose, LOG_DEBUG, CFSTR(" bundle ID = %@"), CFBundleGetIdentifier(bundle)); + SC_log(LOG_DEBUG, "load() called"); + SC_log(LOG_DEBUG, " bundle ID = %@", CFBundleGetIdentifier(bundle)); // setup mirror_setup(); diff --git a/Plugins/common/IPMonitorControlPrefs.c b/Plugins/common/IPMonitorControlPrefs.c index c82153e..0edbd8d 100644 --- a/Plugins/common/IPMonitorControlPrefs.c +++ b/Plugins/common/IPMonitorControlPrefs.c @@ -1,15 +1,15 @@ /* - * Copyright (c) 2013 Apple Inc. All rights reserved. + * Copyright (c) 2013, 2015 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ - * + * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. - * + * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, @@ -17,7 +17,7 @@ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. - * + * * @APPLE_LICENSE_HEADER_END@ */ @@ -67,10 +67,18 @@ IPMonitorControlPrefsGet(void) static void prefs_changed(__unused void * arg) { + os_activity_t activity_id; + + activity_id = os_activity_start("processing logging preference change", + OS_ACTIVITY_FLAG_DEFAULT); + /* get the current value */ if (S_callback != NULL) { (*S_callback)(S_prefs); } + + os_activity_end(activity_id); + return; } diff --git a/Plugins/common/cache.c b/Plugins/common/cache.c index fe4e0de..2158148 100644 --- a/Plugins/common/cache.c +++ b/Plugins/common/cache.c @@ -1,15 +1,15 @@ /* - * Copyright (c) 2003, 2004, 2006, 2011 Apple Inc. All rights reserved. + * Copyright (c) 2003, 2004, 2006, 2011, 2015 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ - * + * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. - * + * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, @@ -17,7 +17,7 @@ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. - * + * * @APPLE_LICENSE_HEADER_END@ */ @@ -160,10 +160,8 @@ cache_write(SCDynamicStoreRef store) cached_set, cached_removals, cached_notifys)) { - SCLog(TRUE, - LOG_ERR, - CFSTR("SCDynamicStoreSetMultiple() failed: %s"), - SCErrorString(SCError())); + SC_log(LOG_NOTICE, "SCDynamicStoreSetMultiple() failed: %s", + SCErrorString(SCError())); } } diff --git a/SCMonitor/Info.plist b/SCMonitor/Info.plist index 19d53f4..4496add 100644 --- a/SCMonitor/Info.plist +++ b/SCMonitor/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType BNDL CFBundleShortVersionString - 1.14.4 + 1.14 CFBundleSignature ???? CFBundleVersion diff --git a/SCMonitor/monitor.c b/SCMonitor/monitor.c index b4775b7..cff5c5c 100644 --- a/SCMonitor/monitor.c +++ b/SCMonitor/monitor.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007-2014 Apple Inc. All rights reserved. + * Copyright (c) 2007-2015 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -203,7 +203,7 @@ open_NetworkPrefPane(MyType *myInstance) strlen(NETWORK_PREF_CMD), &aeDesc); if (status != noErr) { - SCLOG(NULL, myInstance->log_msg, ASL_LEVEL_ERR, CFSTR("SCMonitor: AECreateDesc() failed: %d"), (int)status); + SCLOG(NULL, myInstance->log_msg, ASL_LEVEL_ERR, CFSTR("AECreateDesc() failed: %d"), (int)status); } prefSpec.appURL = NULL; @@ -214,7 +214,7 @@ open_NetworkPrefPane(MyType *myInstance) status = LSOpenFromURLSpec(&prefSpec, NULL); if (status != noErr) { - SCLOG(NULL, myInstance->log_msg, ASL_LEVEL_ERR, CFSTR("SCMonitor: LSOpenFromURLSpec() failed: %d"), (int)status); + SCLOG(NULL, myInstance->log_msg, ASL_LEVEL_ERR, CFSTR("LSOpenFromURLSpec() failed: %d"), (int)status); } CFRelease(prefArray); @@ -249,7 +249,7 @@ notify_remove(MyType *myInstance, Boolean cancel) status = CFUserNotificationCancel(myInstance->userNotification); if (status != 0) { SCLOG(NULL, myInstance->log_msg, ASL_LEVEL_ERR, - CFSTR("SCMonitor: CFUserNotificationCancel() failed, status=%d"), + CFSTR("CFUserNotificationCancel() failed, status=%d"), (int)status); } } @@ -278,7 +278,7 @@ notify_reply(CFUserNotificationRef userNotification, CFOptionFlags response_flag } } if (myInstance == NULL) { - SCLOG(NULL, NULL, ASL_LEVEL_ERR, CFSTR("SCMonitor: can't find user notification")); + SCLOG(NULL, NULL, ASL_LEVEL_ERR, CFSTR("can't find user notification")); return; } @@ -348,7 +348,7 @@ notify_add(MyType *myInstance) CFDictionarySetValue(dict, kCFUserNotificationLocalizationURLKey, url); CFRelease(url); } else { - SCLOG(NULL, myInstance->log_msg, ASL_LEVEL_ERR, CFSTR("SCMonitor: can't find bundle")); + SCLOG(NULL, myInstance->log_msg, ASL_LEVEL_ERR, CFSTR("can't find bundle")); goto done; } @@ -418,7 +418,7 @@ notify_add(MyType *myInstance) &error, dict); if (myInstance->userNotification == NULL) { - SCLOG(NULL, myInstance->log_msg, ASL_LEVEL_ERR, CFSTR("SCMonitor: CFUserNotificationCreate() failed, %d"), (int)error); + SCLOG(NULL, myInstance->log_msg, ASL_LEVEL_ERR, CFSTR("CFUserNotificationCreate() failed: %d"), (int)error); goto done; } @@ -428,7 +428,7 @@ notify_add(MyType *myInstance) notify_reply, 0); if (myInstance->userRls == NULL) { - SCLOG(NULL, myInstance->log_msg, ASL_LEVEL_ERR, CFSTR("SCMonitor: CFUserNotificationCreateRunLoopSource() failed")); + SCLOG(NULL, myInstance->log_msg, ASL_LEVEL_ERR, CFSTR("CFUserNotificationCreateRunLoopSource() failed")); CFRelease(myInstance->userNotification); myInstance->userNotification = NULL; goto done; @@ -710,7 +710,7 @@ watcher_add_lan(MyType *myInstance) store = SCDynamicStoreCreate(NULL, CFSTR("SCMonitor"), update_lan, &context); if (store == NULL) { SCLOG(NULL, myInstance->log_msg, ASL_LEVEL_ERR, - CFSTR("SCMonitor: SCDynamicStoreCreate() failed: %s"), + CFSTR("SCDynamicStoreCreate() failed: %s"), SCErrorString(SCError())); return; } @@ -1019,7 +1019,7 @@ watcher_add_serial(MyType *myInstance) myInstance->notifyPort = IONotificationPortCreate(kIOMasterPortDefault); if (myInstance->notifyPort == NULL) { SCLOG(NULL, myInstance->log_msg, ASL_LEVEL_ERR, - CFSTR("SCMonitor: IONotificationPortCreate failed")); + CFSTR("IONotificationPortCreate failed")); return; } diff --git a/SCTest-ObjC/test-objC.m b/SCTest-ObjC/test-objC.m new file mode 100644 index 0000000..90007b9 --- /dev/null +++ b/SCTest-ObjC/test-objC.m @@ -0,0 +1,118 @@ +/* + * Copyright (c) 2015 Apple Inc. All rights reserved. + * + * A Objective-C test target to test SC APIs + * + * Created by Sushant Chavan on 4/21/15. + */ + +@import Foundation; +@import SystemConfiguration; + +#define MY_APP_NAME CFSTR("SCTestObjC") +#define TARGET_HOST "www.apple.com" + +static void +test_SCNetworkConfiguration() +{ + NSLog(@"\n\n*** SCNetworkConfiguration ***\n\n"); + CFIndex count; + CFIndex idx; + CFArrayRef interfaces; + + interfaces = SCNetworkInterfaceCopyAll(); + count = CFArrayGetCount(interfaces); + NSLog(@"Network Interfaces:\n"); + for (idx=0; idx < count; idx++) { + SCNetworkInterfaceRef intf; + CFStringRef bsdName; + + intf = CFArrayGetValueAtIndex(interfaces, idx); + bsdName = SCNetworkInterfaceGetBSDName(intf); + NSLog(@"- %@", bsdName); + } + + CFRelease(interfaces); +} + +static void +test_SCDynamicStore() +{ + NSLog(@"\n\n*** SCDynamicStore ***\n\n"); + CFDictionaryRef dict; + CFStringRef intf; + CFStringRef key; + SCDynamicStoreRef store; + + store = SCDynamicStoreCreate(NULL, MY_APP_NAME, NULL, NULL); + key = SCDynamicStoreKeyCreateNetworkGlobalEntity(NULL, kSCDynamicStoreDomainState, kSCEntNetIPv4); + dict = SCDynamicStoreCopyValue(store, key); + intf = CFDictionaryGetValue(dict, kSCDynamicStorePropNetPrimaryInterface); + NSLog(@"- Primary Interface is %@\n", intf); + + CFRelease(store); + CFRelease(dict); + CFRelease(key); +} + +static void +test_SCPreferences() +{ + NSLog(@"\n\n*** SCPreferences ***\n\n"); + CFIndex count; + CFIndex idx; + CFStringRef model = NULL; + SCPreferencesRef prefs; + CFArrayRef services; + + prefs = SCPreferencesCreate(NULL, MY_APP_NAME, NULL); + model = SCPreferencesGetValue(prefs, CFSTR("Model")); + if (model != NULL) { + NSLog(@"Current model is %@", model); + } + + services = SCNetworkServiceCopyAll(prefs); + count = CFArrayGetCount(services); + NSLog(@"Network Services:\n"); + for (idx = 0; idx < count; idx++) { + SCNetworkServiceRef serv; + CFStringRef servName; + + serv = CFArrayGetValueAtIndex(services, idx); + servName = SCNetworkServiceGetName(serv); + NSLog(@"- %@\n", servName); + } + + CFRelease(prefs); + CFRelease(services); +} + +void +test_SCNetworkReachability() +{ + NSLog(@"\n\n*** SCNetworkReachability ***\n\n"); + SCNetworkReachabilityFlags flags; + SCNetworkReachabilityRef target; + + target = SCNetworkReachabilityCreateWithName(NULL, TARGET_HOST); + (void)SCNetworkReachabilityGetFlags(target, &flags); + NSLog(@"- Reachability flags for "TARGET_HOST": %#x", flags); + + CFRelease(target); +} + +void +SCTest() +{ + test_SCNetworkConfiguration(); + test_SCNetworkReachability(); + test_SCPreferences(); + test_SCDynamicStore(); +} + +int main(int argc, const char * argv[]) { + @autoreleasepool { + SCTest(); + } + return 0; +} diff --git a/SCTest-Swift/main.swift b/SCTest-Swift/main.swift new file mode 100644 index 0000000..aa6b020 --- /dev/null +++ b/SCTest-Swift/main.swift @@ -0,0 +1,126 @@ +/* + * Copyright (c) 2015 Apple Inc. All rights reserved. + * + * A Swift test target to test SC APIs + * + * Created by Sushant Chavan on 4/21/15. +*/ + +import Foundation +import SystemConfiguration + +let target_host = "www.apple.com" +var application = "SCTest-Swift" as CFString + +func +test_SCNetworkConfiguration () +{ + //SCNetworkConfiguration APIs + NSLog("\n\n*** SCNetworkConfiguration ***\n\n") + let interfaceArray:[CFArray] + let count:CFIndex + var idx:CFIndex + + interfaceArray = SCNetworkInterfaceCopyAll() as! [CFArray] + count = CFArrayGetCount(interfaceArray) + NSLog("Network Interfaces:") + for idx = 0; idx < count ; idx++ { + let interface = interfaceArray[idx] + if let bsdName? = SCNetworkInterfaceGetBSDName(interface as! SCNetworkInterface) { + NSLog("- %@", bsdName as String) + } + } +} + +func +test_SCNetworkReachability () +{ + //SCNetworkReachability APIs + NSLog("\n\n*** SCNetworkReachability ***\n\n") + let target:SCNetworkReachability? + var flags:SCNetworkReachabilityFlags = SCNetworkReachabilityFlags.allZeros + + target = SCNetworkReachabilityCreateWithName(nil, target_host) + if target == nil { + NSLog("Error creating target: %s", SCErrorString(SCError())) + return + } + + SCNetworkReachabilityGetFlags(target!, &flags) + NSLog("SCNetworkReachability flags for %@ is %#x", String(target_host), flags.rawValue) +} + +func +test_SCPreferences () +{ + //SCPreferences APIs + NSLog("\n\n*** SCPreferences ***\n\n") + let prefs:SCPreferences? + let networkServices:[CFArray]? + let count:CFIndex + var idx:CFIndex + + prefs = SCPreferencesCreate(nil, application, nil) + if prefs == nil { + NSLog("Error creating prefs: %s", SCErrorString(SCError())) + return + } + + if let model? = SCPreferencesGetValue(prefs!, "Model" as CFString) { + NSLog("Current system model is %@", model as! String) + } + + networkServices = SCNetworkServiceCopyAll(prefs!) as? [CFArray] + if networkServices == nil { + NSLog("Error retrieving network services", SCErrorString(SCError())) + return + } + + count = CFArrayGetCount(networkServices) + NSLog("Network Services:") + for idx = 0; idx < count ; idx++ { + let service = networkServices?[idx] + if let serviceName? = SCNetworkServiceGetName(service as! SCNetworkService) { + NSLog("- %@", serviceName as String) + } + + } +} + +func +test_SCDynamicStore () +{ + //SCDynamicStore APIs + NSLog("\n\n*** SCDynamicStore ***\n\n") + let key:CFString + let store:SCDynamicStore? + let dict:[String:String]? + let primaryIntf:String? + + store = SCDynamicStoreCreate(nil, application, nil, nil) + if store == nil { + NSLog("Error creating session: %s", SCErrorString(SCError())) + return + } + + key = SCDynamicStoreKeyCreateNetworkGlobalEntity(nil, kSCDynamicStoreDomainState, kSCEntNetIPv4) + dict = SCDynamicStoreCopyValue(store, key) as? [String:String] + primaryIntf = dict?[kSCDynamicStorePropNetPrimaryInterface as String] + if (primaryIntf != nil) { + NSLog("Primary interface is %@", primaryIntf!) + } else { + NSLog("Primary interface is unavailable") + } +} + +func +my_main () +{ + test_SCNetworkConfiguration() + test_SCNetworkReachability() + test_SCPreferences() + test_SCDynamicStore() +} + +// Run the test +my_main() diff --git a/SystemConfiguration.fproj/BondConfiguration.c b/SystemConfiguration.fproj/BondConfiguration.c index cb24ada..52f1e9c 100644 --- a/SystemConfiguration.fproj/BondConfiguration.c +++ b/SystemConfiguration.fproj/BondConfiguration.c @@ -1,15 +1,15 @@ /* - * Copyright (c) 2004-2014 Apple Inc. All rights reserved. + * Copyright (c) 2004-2015 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ - * + * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. - * + * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, @@ -17,7 +17,7 @@ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. - * + * * @APPLE_LICENSE_HEADER_END@ */ @@ -67,7 +67,7 @@ inet_dgram_socket() s = socket(AF_INET, SOCK_DGRAM, 0); if (s == -1) { - SCLog(TRUE, LOG_ERR, CFSTR("socket() failed: %s"), strerror(errno)); + SC_log(LOG_ERR, "socket() failed: %s", strerror(errno)); } return s; @@ -153,7 +153,7 @@ add_interface(CFMutableArrayRef *interfaces, CFStringRef if_name, SCPreferencesR interface = _SCNetworkInterfaceCreateWithBSDName(NULL, if_name, kIncludeNoVirtualInterfaces); } - + if (interface != NULL) { CFArrayAppendValue(*interfaces, interface); CFRelease(interface); @@ -262,7 +262,7 @@ SCBondInterfaceCopyAll(SCPreferencesRef prefs) CFDictionaryRef dict; SCPreferencesRef ni_prefs; CFStringRef path; - + if ((prefs == NULL) || (__SCPreferencesUsingDefaultPrefs(prefs) == TRUE)) { ni_prefs = NULL; @@ -270,11 +270,11 @@ SCBondInterfaceCopyAll(SCPreferencesRef prefs) else { ni_prefs = __SCPreferencesCreateNIPrefsFromPrefs(prefs); } - + context.bonds = CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks); context.prefs = prefs; context.ni_prefs = ni_prefs; - + path = CFStringCreateWithFormat(NULL, NULL, CFSTR("/%@/%@"), @@ -413,7 +413,7 @@ _SCBondInterfaceCopyActive(void) if (getifaddrs(&ifap) == -1) { _SCErrorSet(errno); - SCLog(TRUE, LOG_ERR, CFSTR("getifaddrs() failed: %s"), strerror(errno)); + SC_log(LOG_NOTICE, "getifaddrs() failed: %s", strerror(errno)); return NULL; } @@ -447,10 +447,9 @@ _SCBondInterfaceCopyActive(void) continue; } _SCErrorSet(errno); - SCLog(TRUE, LOG_ERR, - CFSTR("if_bond_status_req_copy(%s) failed: %s"), - ifp->ifa_name, - strerror(errno)); + SC_log(LOG_NOTICE, "if_bond_status_req_copy(%s) failed: %s", + ifp->ifa_name, + strerror(errno)); CFRelease(bonds); bonds = NULL; goto done; @@ -1269,10 +1268,9 @@ SCBondInterfaceCopyStatus(SCBondInterfaceRef bond) case ENXIO : break; default : - SCLog(TRUE, LOG_ERR, - CFSTR("siocgifmedia(%s) failed: %s"), - if_name, - strerror(errno)); + SC_log(LOG_NOTICE, "siocgifmedia(%s) failed: %s", + if_name, + strerror(errno)); } goto done; } @@ -1330,10 +1328,9 @@ SCBondInterfaceCopyStatus(SCBondInterfaceRef bond) case ENXIO : break; default : - SCLog(TRUE, LOG_ERR, - CFSTR("siocgifmedia(%s) failed: %s"), - if_name, - strerror(errno)); + SC_log(LOG_NOTICE, "siocgifmedia(%s) failed: %s", + if_name, + strerror(errno)); break; } } @@ -1426,11 +1423,10 @@ __bond_set_mode(int s, CFStringRef bond_if, CFNumberRef mode) breq.ibr_ibru.ibru_int_val = mode_num; if (ioctl(s, SIOCSIFBOND, (caddr_t)&ifr) == -1) { _SCErrorSet(errno); - SCLog(TRUE, LOG_ERR, - CFSTR("could not set mode to %@ on bond \"%@\": %s"), - mode, - bond_if, - strerror(errno)); + SC_log(LOG_ERR, "could not set mode to %@ on bond \"%@\": %s", + mode, + bond_if, + strerror(errno)); return FALSE; } @@ -1462,11 +1458,10 @@ __bond_add_interface(int s, CFStringRef bond_if, CFStringRef interface_if) // add new bond member if (ioctl(s, SIOCSIFBOND, (caddr_t)&ifr) == -1) { _SCErrorSet(errno); - SCLog(TRUE, LOG_ERR, - CFSTR("could not add interface \"%@\" to bond \"%@\": %s"), - interface_if, - bond_if, - strerror(errno)); + SC_log(LOG_ERR, "could not add interface \"%@\" to bond \"%@\": %s", + interface_if, + bond_if, + strerror(errno)); return FALSE; } @@ -1499,11 +1494,10 @@ __bond_remove_interface(int s, CFStringRef bond_if, CFStringRef interface_if) // remove bond member if (ioctl(s, SIOCSIFBOND, (caddr_t)&ifr) == -1) { _SCErrorSet(errno); - SCLog(TRUE, LOG_ERR, - CFSTR("could not remove interface \"%@\" from bond \"%@\": %s"), - interface_if, - bond_if, - strerror(errno)); + SC_log(LOG_ERR, "could not remove interface \"%@\" from bond \"%@\": %s", + interface_if, + bond_if, + strerror(errno)); return FALSE; } diff --git a/SystemConfiguration.fproj/BridgeConfiguration.c b/SystemConfiguration.fproj/BridgeConfiguration.c index ee16a69..53a493f 100644 --- a/SystemConfiguration.fproj/BridgeConfiguration.c +++ b/SystemConfiguration.fproj/BridgeConfiguration.c @@ -1,15 +1,15 @@ /* - * Copyright (c) 2009-2014 Apple Inc. All rights reserved. + * Copyright (c) 2009-2015 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ - * + * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. - * + * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, @@ -17,7 +17,7 @@ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. - * + * * @APPLE_LICENSE_HEADER_END@ */ @@ -67,7 +67,7 @@ inet_dgram_socket() s = socket(AF_INET, SOCK_DGRAM, 0); if (s == -1) { - SCLog(TRUE, LOG_ERR, CFSTR("socket() failed: %s"), strerror(errno)); + SC_log(LOG_ERR, "socket() failed: %s", strerror(errno)); } return s; @@ -259,7 +259,7 @@ SCBridgeInterfaceCopyAll(SCPreferencesRef prefs) context.bridges = CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks); context.prefs = prefs; context.ni_prefs = ni_prefs; - + path = CFStringCreateWithFormat(NULL, NULL, CFSTR("/%@/%@"), @@ -399,7 +399,7 @@ _SCBridgeInterfaceCopyActive(void) if (getifaddrs(&ifap) == -1) { _SCErrorSet(errno); - SCLog(TRUE, LOG_ERR, CFSTR("getifaddrs() failed: %s"), strerror(errno)); + SC_log(LOG_NOTICE, "getifaddrs() failed: %s", strerror(errno)); return NULL; } @@ -444,10 +444,9 @@ _SCBridgeInterfaceCopyActive(void) continue; } _SCErrorSet(errno); - SCLog(TRUE, LOG_ERR, - CFSTR("ifbifconf_copy(%s) failed: %s"), - ifp->ifa_name, - strerror(errno)); + SC_log(LOG_NOTICE, "ifbifconf_copy(%s) failed: %s", + ifp->ifa_name, + strerror(errno)); CFRelease(bridges); bridges = NULL; goto done; @@ -955,11 +954,10 @@ __bridge_add_interface(int s, CFStringRef bridge_if, CFStringRef interface_if) // add new bridge member if (ioctl(s, SIOCSDRVSPEC, (caddr_t)&ifd) == -1) { _SCErrorSet(errno); - SCLog(TRUE, LOG_ERR, - CFSTR("could not add interface \"%@\" to bridge \"%@\": %s"), - interface_if, - bridge_if, - strerror(errno)); + SC_log(LOG_ERR, "could not add interface \"%@\" to bridge \"%@\": %s", + interface_if, + bridge_if, + strerror(errno)); return FALSE; } @@ -993,11 +991,10 @@ __bridge_remove_interface(int s, CFStringRef bridge_if, CFStringRef interface_if // remove bridge member if (ioctl(s, SIOCSDRVSPEC, (caddr_t)&ifd) == -1) { _SCErrorSet(errno); - SCLog(TRUE, LOG_ERR, - CFSTR("could not add interface \"%@\" to bridge \"%@\": %s"), - interface_if, - bridge_if, - strerror(errno)); + SC_log(LOG_ERR, "could not remove interface \"%@\" from bridge \"%@\": %s", + interface_if, + bridge_if, + strerror(errno)); return FALSE; } diff --git a/SystemConfiguration.fproj/CaptiveNetwork.h b/SystemConfiguration.fproj/CaptiveNetwork.h index 316c31b..4ab9655 100644 --- a/SystemConfiguration.fproj/CaptiveNetwork.h +++ b/SystemConfiguration.fproj/CaptiveNetwork.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2012 Apple Inc. All rights reserved. + * Copyright (c) 2009-2015 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -28,6 +28,9 @@ #include #include +CF_IMPLICIT_BRIDGING_ENABLED +CF_ASSUME_NONNULL_BEGIN + /*! @header CaptiveNetwork @discussion The CaptiveNetwork API allows applications to interact @@ -48,8 +51,22 @@ These APIs are treated as advisory only. There is no guarantee or contract that the operating system will take the intended action. + + @note IMPORTANT: This API is deprecated starting in iOS 9. + For captive network applications, this has been completely + replaced by . + For other applications, there is no direct replacement. + Please file a bug describing your use of this API so that + we can consider your requirements as this situation evolves. */ +#define CN_DEPRECATION_NOTICE \ + "For captive network applications, this has been completely " \ + "replaced by . " \ + "For other applications, there is no direct replacement. " \ + "Please file a bug describing your use of this API to that " \ + "we can consider your requirements as this situation evolves." + __BEGIN_DECLS /*! @@ -71,7 +88,10 @@ __BEGIN_DECLS @result Returns TRUE if the operation succeeded, FALSE otherwise. */ Boolean -CNSetSupportedSSIDs (CFArrayRef ssidArray) __OSX_AVAILABLE_STARTING(__MAC_10_8,__IPHONE_4_0); +CNSetSupportedSSIDs (CFArrayRef ssidArray) + __OSX_AVAILABLE_BUT_DEPRECATED_MSG(__MAC_10_8, __MAC_NA, + __IPHONE_4_0, __IPHONE_9_0, + "Replaced by "); /*! @function CNMarkPortalOnline @@ -83,7 +103,10 @@ CNSetSupportedSSIDs (CFArrayRef ssidArray) __OSX_AVAILABLE_STARTING(__MAC_10_8, @result Returns TRUE if the operation succeeded, FALSE otherwise. */ Boolean -CNMarkPortalOnline (CFStringRef interfaceName) __OSX_AVAILABLE_STARTING(__MAC_10_8,__IPHONE_4_0); +CNMarkPortalOnline (CFStringRef interfaceName) + __OSX_AVAILABLE_BUT_DEPRECATED_MSG(__MAC_10_8, __MAC_NA, + __IPHONE_4_0, __IPHONE_9_0, + "Replaced by "); /*! @function CNMarkPortalOffline @@ -93,8 +116,10 @@ CNMarkPortalOnline (CFStringRef interfaceName) __OSX_AVAILABLE_STARTING(__MAC_1 @result Returns TRUE if the operation succeeded, FALSE otherwise. */ Boolean -CNMarkPortalOffline (CFStringRef interfaceName) __OSX_AVAILABLE_STARTING(__MAC_10_8,__IPHONE_4_0); - +CNMarkPortalOffline (CFStringRef interfaceName) + __OSX_AVAILABLE_BUT_DEPRECATED_MSG(__MAC_10_8, __MAC_NA, + __IPHONE_4_0, __IPHONE_9_0, + "Replaced by "); /*! @function CNCopySupportedInterfaces @@ -103,26 +128,38 @@ CNMarkPortalOffline (CFStringRef interfaceName) __OSX_AVAILABLE_STARTING(__MAC_ Returns NULL if an error was encountered. You MUST release the returned value. */ -CFArrayRef -CNCopySupportedInterfaces (void) __OSX_AVAILABLE_STARTING(__MAC_10_8,__IPHONE_4_1); +CFArrayRef __nullable +CNCopySupportedInterfaces (void) + __OSX_AVAILABLE_BUT_DEPRECATED_MSG(__MAC_10_8, __MAC_NA, + __IPHONE_4_1, __IPHONE_9_0, + CN_DEPRECATION_NOTICE); /*! @constant kCNNetworkInfoKeySSIDData @discussion NetworkInfo Dictionary key for SSID in CFData format */ -extern const CFStringRef kCNNetworkInfoKeySSIDData __OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_4_1); +extern const CFStringRef kCNNetworkInfoKeySSIDData + __OSX_AVAILABLE_BUT_DEPRECATED_MSG(__MAC_NA, __MAC_NA, + __IPHONE_4_1, __IPHONE_9_0, + CN_DEPRECATION_NOTICE); /*! @constant kCNNetworkInfoKeySSID @discussion NetworkInfo Dictionary key for SSID in CFString format */ -extern const CFStringRef kCNNetworkInfoKeySSID __OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_4_1); +extern const CFStringRef kCNNetworkInfoKeySSID + __OSX_AVAILABLE_BUT_DEPRECATED_MSG(__MAC_NA, __MAC_NA, + __IPHONE_4_1, __IPHONE_9_0, + CN_DEPRECATION_NOTICE); /*! @constant kCNNetworkInfoKeyBSSID @discussion NetworkInfo Dictionary key for BSSID in CFString format */ -extern const CFStringRef kCNNetworkInfoKeyBSSID __OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_4_1); +extern const CFStringRef kCNNetworkInfoKeyBSSID + __OSX_AVAILABLE_BUT_DEPRECATED_MSG(__MAC_NA, __MAC_NA, + __IPHONE_4_1, __IPHONE_9_0, + CN_DEPRECATION_NOTICE); /*! @function CNCopyCurrentNetworkInfo @@ -143,9 +180,15 @@ extern const CFStringRef kCNNetworkInfoKeyBSSID __OSX_AVAILABLE_STARTING(__MAC Returns NULL if an error was encountered. You MUST release the returned value. */ -CFDictionaryRef -CNCopyCurrentNetworkInfo (CFStringRef interfaceName) __OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_4_1); +CFDictionaryRef __nullable +CNCopyCurrentNetworkInfo (CFStringRef interfaceName) + __OSX_AVAILABLE_BUT_DEPRECATED_MSG(__MAC_NA, __MAC_NA, + __IPHONE_4_1, __IPHONE_9_0, + CN_DEPRECATION_NOTICE); __END_DECLS +CF_ASSUME_NONNULL_END +CF_IMPLICIT_BRIDGING_DISABLED + #endif /* _CAPTIVENETWORK_H */ diff --git a/SystemConfiguration.fproj/DHCP.c b/SystemConfiguration.fproj/DHCP.c index aaf1ba0..d192415 100644 --- a/SystemConfiguration.fproj/DHCP.c +++ b/SystemConfiguration.fproj/DHCP.c @@ -1,15 +1,15 @@ /* - * Copyright (c) 2001, 2003-2005, 2011, 2013 Apple Inc. All rights reserved. + * Copyright (c) 2001, 2003-2005, 2011, 2013, 2015 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ - * + * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. - * + * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, @@ -17,7 +17,7 @@ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. - * + * * @APPLE_LICENSE_HEADER_END@ */ @@ -592,11 +592,6 @@ main(int argc, char * argv[]) count = argc - 3; options = malloc(count); - if (options == NULL) { - fprintf(stderr, "malloc failed %s\n", - strerror(errno)); - exit(1); - } for (i = 0; i < count; i++) { options[i] = atoi(argv[3 + i]); } diff --git a/SystemConfiguration.fproj/DHCPClientPreferences.h b/SystemConfiguration.fproj/DHCPClientPreferences.h index cac5fb2..8d39c98 100644 --- a/SystemConfiguration.fproj/DHCPClientPreferences.h +++ b/SystemConfiguration.fproj/DHCPClientPreferences.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2004, 2005, 2008 Apple Inc. All rights reserved. + * Copyright (c) 2001, 2004, 2005, 2008, 2015 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -31,6 +31,9 @@ #include #include +CF_IMPLICIT_BRIDGING_ENABLED +CF_ASSUME_NONNULL_BEGIN + /*! @header DHCPClientPreferences @discussion The DHCPClientPreferences API allows applications to get and update DHCP preferences. @@ -54,9 +57,9 @@ __BEGIN_DECLS */ Boolean -DHCPClientPreferencesSetApplicationOptions (CFStringRef applicationID, - UInt8 *options, - CFIndex count) __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); +DHCPClientPreferencesSetApplicationOptions (CFStringRef applicationID, + UInt8 * __nullable options, + CFIndex count) __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); /*! @function DHCPClientPreferencesCopyApplicationOptions @@ -71,11 +74,14 @@ DHCPClientPreferencesSetApplicationOptions (CFStringRef applicationID, When you are finished, use free() to release a non-NULL return value. */ -UInt8 * +UInt8 * __nullable DHCPClientPreferencesCopyApplicationOptions (CFStringRef applicationID, CFIndex *count) __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); __END_DECLS +CF_ASSUME_NONNULL_END +CF_IMPLICIT_BRIDGING_DISABLED + #endif /* USE_SYSTEMCONFIGURATION_PRIVATE_HEADERS */ #endif /* _DHCPCLIENTPREFERENCES_H */ diff --git a/SystemConfiguration.fproj/DeviceOnHold.h b/SystemConfiguration.fproj/DeviceOnHold.h index 1f1a361..9577bc6 100644 --- a/SystemConfiguration.fproj/DeviceOnHold.h +++ b/SystemConfiguration.fproj/DeviceOnHold.h @@ -59,7 +59,7 @@ enum @discussion This is the handle to a specific device which is used by the DeviceOnHold APIs. */ -typedef const struct __DeviceOnHoldRef * DeviceOnHoldRef; +typedef const struct CF_BRIDGED_TYPE(id) __DeviceOnHoldRef * DeviceOnHoldRef; __BEGIN_DECLS diff --git a/SystemConfiguration.fproj/Info-Embedded.plist b/SystemConfiguration.fproj/Info-Embedded.plist index ea4c184..b4571b9 100644 --- a/SystemConfiguration.fproj/Info-Embedded.plist +++ b/SystemConfiguration.fproj/Info-Embedded.plist @@ -17,7 +17,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 1.14.4 + 1.14 CFBundleSignature ???? CFBundleVersion diff --git a/SystemConfiguration.fproj/Info.plist b/SystemConfiguration.fproj/Info.plist index ea4c184..b4571b9 100644 --- a/SystemConfiguration.fproj/Info.plist +++ b/SystemConfiguration.fproj/Info.plist @@ -17,7 +17,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 1.14.4 + 1.14 CFBundleSignature ???? CFBundleVersion diff --git a/SystemConfiguration.fproj/LinkConfiguration.c b/SystemConfiguration.fproj/LinkConfiguration.c index f75743f..4b92ea0 100644 --- a/SystemConfiguration.fproj/LinkConfiguration.c +++ b/SystemConfiguration.fproj/LinkConfiguration.c @@ -1,15 +1,15 @@ /* - * Copyright (c) 2002-2007, 2010, 2011, 2013 Apple Inc. All rights reserved. + * Copyright (c) 2002-2007, 2010, 2011, 2013, 2015 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ - * + * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. - * + * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, @@ -17,7 +17,7 @@ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. - * + * * @APPLE_LICENSE_HEADER_END@ */ @@ -107,7 +107,7 @@ __getCapabilities(CFStringRef interfaceName, bzero((void *)&ifr, sizeof(ifr)); if (_SC_cfstring_to_cstring(interfaceName, ifr.ifr_name, sizeof(ifr.ifr_name), kCFStringEncodingASCII) == NULL) { - SCLog(TRUE, LOG_ERR, CFSTR("could not convert interface name")); + SC_log(LOG_NOTICE, "could not convert interface name"); _SCErrorSet(kSCStatusInvalidArgument); return FALSE; } @@ -115,7 +115,7 @@ __getCapabilities(CFStringRef interfaceName, sock = socket(AF_INET, SOCK_DGRAM, 0); if (sock == -1) { _SCErrorSet(errno); - SCLog(TRUE, LOG_ERR, CFSTR("socket() failed: %s"), strerror(errno)); + SC_log(LOG_ERR, "socket() failed: %s", strerror(errno)); return FALSE; } @@ -126,9 +126,7 @@ __getCapabilities(CFStringRef interfaceName, case ENXIO : break; default : - SCLog(TRUE, LOG_ERR, - CFSTR("ioctl(SIOCGIFCAP) failed: %s"), - strerror(errno)); + SC_log(LOG_NOTICE, "ioctl(SIOCGIFCAP) failed: %s", strerror(errno)); } goto done; } @@ -407,25 +405,25 @@ __copyMediaList(CFStringRef interfaceName) bzero((void *)ifm, sizeof(*ifm)); if (_SC_cfstring_to_cstring(interfaceName, ifm->ifm_name, sizeof(ifm->ifm_name), kCFStringEncodingASCII) == NULL) { - SCLog(TRUE, LOG_ERR, CFSTR("could not convert interface name")); + SC_log(LOG_NOTICE, "could not convert interface name"); goto done; } sock = socket(AF_INET, SOCK_DGRAM, 0); if (sock == -1) { - SCLog(TRUE, LOG_ERR, CFSTR("socket() failed: %s"), strerror(errno)); + SC_log(LOG_ERR, "socket() failed: %s", strerror(errno)); goto done; } if (ioctl(sock, SIOCGIFMEDIA, (caddr_t)ifm) == -1) { -// SCLog(TRUE, LOG_DEBUG, CFSTR("ioctl(SIOCGIFMEDIA) failed: %s"), strerror(errno)); +// SC_log(LOG_NOTICE, "ioctl(SIOCGIFMEDIA) failed: %s", strerror(errno)); goto done; } if (ifm->ifm_count > 0) { ifm->ifm_ulist = (int *)CFAllocatorAllocate(NULL, ifm->ifm_count * sizeof(int), 0); if (ioctl(sock, SIOCGIFMEDIA, (caddr_t)ifm) == -1) { - SCLog(TRUE, LOG_DEBUG, CFSTR("ioctl(SIOCGIFMEDIA) failed: %s"), strerror(errno)); + SC_log(LOG_NOTICE, "ioctl(SIOCGIFMEDIA) failed: %s", strerror(errno)); goto done; } } @@ -1021,7 +1019,7 @@ SCNetworkInterfaceCopyMTU(SCNetworkInterfaceRef interface, bzero((void *)&ifr, sizeof(ifr)); if (_SC_cfstring_to_cstring(interfaceName, ifr.ifr_name, sizeof(ifr.ifr_name), kCFStringEncodingASCII) == NULL) { - SCLog(TRUE, LOG_ERR, CFSTR("could not convert interface name")); + SC_log(LOG_NOTICE, "could not convert interface name"); _SCErrorSet(kSCStatusInvalidArgument); return FALSE; } @@ -1029,13 +1027,13 @@ SCNetworkInterfaceCopyMTU(SCNetworkInterfaceRef interface, sock = socket(AF_INET, SOCK_DGRAM, 0); if (sock == -1) { _SCErrorSet(errno); - SCLog(TRUE, LOG_ERR, CFSTR("socket() failed: %s"), strerror(errno)); + SC_log(LOG_ERR, "socket() failed: %s", strerror(errno)); return FALSE; } if (ioctl(sock, SIOCGIFMTU, (caddr_t)&ifr) == -1) { _SCErrorSet(errno); -// SCLog(TRUE, LOG_DEBUG, CFSTR("ioctl(SIOCGIFMTU) failed: %s"), strerror(errno)); +// SC_log(LOG_NOTICE, "ioctl(SIOCGIFMTU) failed: %s", strerror(errno)); goto done; } @@ -1131,7 +1129,7 @@ SCNetworkInterfaceSetMediaOptions(SCNetworkInterfaceRef interface, } if (!SCNetworkInterfaceCopyMediaOptions(interface, NULL, NULL, &available, FALSE)) { - SCLog(_sc_debug, LOG_DEBUG, CFSTR("media type / options not available")); + SC_log(LOG_INFO, "media type / options not available"); goto checked; } @@ -1145,7 +1143,7 @@ SCNetworkInterfaceSetMediaOptions(SCNetworkInterfaceRef interface, !CFArrayContainsValue(subtypes, CFRangeMake(0, CFArrayGetCount(subtypes)), subtype)) { - SCLog(_sc_debug, LOG_DEBUG, CFSTR("media type not valid")); + SC_log(LOG_INFO, "media type not valid"); _SCErrorSet(kSCStatusInvalidArgument); goto checked; } @@ -1155,7 +1153,7 @@ SCNetworkInterfaceSetMediaOptions(SCNetworkInterfaceRef interface, !CFArrayContainsValue(subtype_options, CFRangeMake(0, CFArrayGetCount(subtype_options)), config_options)) { - SCLog(_sc_debug, LOG_DEBUG, CFSTR("media options not valid for \"%@\""), subtype); + SC_log(LOG_INFO, "media options not valid for \"%@\"", subtype); _SCErrorSet(kSCStatusInvalidArgument); goto checked; } @@ -1182,7 +1180,7 @@ SCNetworkInterfaceSetMediaOptions(SCNetworkInterfaceRef interface, } ok = TRUE; } else { - SCLog(_sc_debug, LOG_DEBUG, CFSTR("media type must be specified with options")); + SC_log(LOG_INFO, "media type must be specified with options"); _SCErrorSet(kSCStatusInvalidArgument); } @@ -1211,7 +1209,7 @@ SCNetworkInterfaceSetMTU(SCNetworkInterfaceRef interface, } if (!SCNetworkInterfaceCopyMTU(interface, NULL, &mtu_min, &mtu_max)) { - SCLog(_sc_debug, LOG_DEBUG, CFSTR("MTU bounds not available")); + SC_log(LOG_INFO, "MTU bounds not available"); return FALSE; } @@ -1241,7 +1239,7 @@ SCNetworkInterfaceSetMTU(SCNetworkInterfaceRef interface, } ok = TRUE; } else { - SCLog(_sc_debug, LOG_DEBUG, CFSTR("MTU out of range")); + SC_log(LOG_INFO, "MTU out of range"); _SCErrorSet(kSCStatusInvalidArgument); } diff --git a/SystemConfiguration.fproj/Modules/sc_modules.modulemap b/SystemConfiguration.fproj/Modules/sc_modules.modulemap new file mode 100644 index 0000000..78d273c --- /dev/null +++ b/SystemConfiguration.fproj/Modules/sc_modules.modulemap @@ -0,0 +1,22 @@ +framework module SystemConfiguration [extern_c] { + umbrella header "SystemConfiguration.h" + + export * + module * { export * } + + explicit module CaptiveNetwork { + header "CaptiveNetwork.h" + export * + } + + explicit module DHCPClientPreferences { + header "DHCPClientPreferences.h" + export * + } + + explicit module SCDynamicStoreCopyDHCPInfo { + header "SCDynamicStoreCopyDHCPInfo.h" + export * + } +} + diff --git a/SystemConfiguration.fproj/SCD.c b/SystemConfiguration.fproj/SCD.c index 1463295..666a511 100644 --- a/SystemConfiguration.fproj/SCD.c +++ b/SystemConfiguration.fproj/SCD.c @@ -1,15 +1,15 @@ /* - * Copyright (c) 2000-2008, 2010-2014 Apple Inc. All rights reserved. + * Copyright (c) 2000-2008, 2010-2015 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ - * + * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. - * + * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, @@ -17,7 +17,7 @@ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. - * + * * @APPLE_LICENSE_HEADER_END@ */ @@ -44,10 +44,13 @@ #include "SCDynamicStoreInternal.h" #include "config.h" /* MiG generated file */ +// asl logging +#define INSTALL_FACILITY "install" +#define INSTALL_ENVIRONMENT "__OSINSTALL_ENVIRONMENT" + // LIBASL SPI extern asl_object_t _asl_server_control_query(void); - /* framework variables */ int _sc_debug = FALSE; /* non-zero if debugging enabled */ int _sc_verbose = FALSE; /* non-zero if verbose logging enabled */ @@ -379,15 +382,15 @@ _SCCopyDescription(CFTypeRef cf, CFDictionaryRef formatOptions) static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER; -__private_extern__ Boolean -is_install_environment() { +Boolean +_SC_isInstallEnvironment() { static dispatch_once_t once; static Boolean is_install; - + dispatch_once(&once, ^{ is_install = (getenv(INSTALL_ENVIRONMENT) != NULL); }); - + return is_install; } @@ -403,12 +406,12 @@ __SCLog(asl_object_t asl, asl_object_t msg, int level, CFStringRef formatString, tsd = __SCGetThreadSpecificData(); if (tsd->_asl == NULL) { - tsd->_asl = asl_open(NULL, (is_install_environment() ? INSTALL_FACILITY : NULL), 0); + tsd->_asl = asl_open(NULL, (_SC_isInstallEnvironment() ? INSTALL_FACILITY : NULL), 0); asl_set_filter(tsd->_asl, ASL_FILTER_MASK_UPTO(ASL_LEVEL_DEBUG)); } asl = tsd->_asl; } - + #ifdef ENABLE_SC_FORMATTING str = _CFStringCreateWithFormatAndArgumentsAux(NULL, _SCCopyDescription, @@ -624,16 +627,14 @@ SCPrint(Boolean condition, FILE *stream, CFStringRef formatString, ...) void -SCTrace(Boolean condition, FILE *stream, CFStringRef formatString, ...) +SCTrace(FILE *stream, CFStringRef formatString, ...) { va_list formatArguments; - if (!condition) { - return; - } - va_start(formatArguments, formatString); - __SCPrint(stream, formatString, formatArguments, TRUE, FALSE); + if (stream != NULL) { + __SCPrint(stream, formatString, formatArguments, TRUE, FALSE); + } va_end(formatArguments); return; @@ -760,7 +761,7 @@ __SCLoggerCreate(void) tempLogger = __SCLoggerAllocate(kCFAllocatorDefault); tempLogger->loggerID = NULL; tempLogger->flags = kSCLoggerFlagsDefault; - tempLogger->aslc = asl_open(NULL, (is_install_environment() ? INSTALL_FACILITY : NULL), ASL_OPT_NO_DELAY); + tempLogger->aslc = asl_open(NULL, (_SC_isInstallEnvironment() ? INSTALL_FACILITY : NULL), ASL_OPT_NO_DELAY); tempLogger->aslm = asl_new(ASL_TYPE_MSG); pthread_mutex_init(&(tempLogger->lock), NULL); tempLogger->module_status = kModuleStatusDoesNotExist; diff --git a/SystemConfiguration.fproj/SCDHostName.c b/SystemConfiguration.fproj/SCDHostName.c index ed59896..5e032b1 100644 --- a/SystemConfiguration.fproj/SCDHostName.c +++ b/SystemConfiguration.fproj/SCDHostName.c @@ -43,7 +43,7 @@ #pragma mark ComputerName -__private_extern__ CFStringRef +CFStringRef _SCPreferencesCopyComputerName(SCPreferencesRef prefs, CFStringEncoding *nameEncoding) { @@ -232,6 +232,14 @@ SCPreferencesSetComputerName(SCPreferencesRef prefs, } else { ok = SCPreferencesPathRemoveValue(prefs, path); } + + if (ok) { + if (name != NULL) { + SC_log(LOG_NOTICE, "attempting to set the computer name to \"%@\"", name); + } else { + SC_log(LOG_NOTICE, "attempting to reset the computer name"); + } + } CFRelease(path); CFRelease(newDict); @@ -324,6 +332,14 @@ SCPreferencesSetHostName(SCPreferencesRef prefs, } else { ok = SCPreferencesPathRemoveValue(prefs, path); } + + if (ok) { + if (name != NULL) { + SC_log(LOG_NOTICE, "attempting to set the host name to \"%@\"", name); + } else { + SC_log(LOG_NOTICE, "attempting to reset the host name"); + } + } CFRelease(path); CFRelease(newDict); @@ -563,6 +579,14 @@ SCPreferencesSetLocalHostName(SCPreferencesRef prefs, } else { ok = SCPreferencesPathRemoveValue(prefs, path); } + + if (ok) { + if (name != NULL) { + SC_log(LOG_NOTICE, "attempting to set the local host name to \"%@\"", name); + } else { + SC_log(LOG_NOTICE, "attempting to reset the local host name"); + } + } CFRelease(path); CFRelease(newDict); diff --git a/SystemConfiguration.fproj/SCDNotifierCancel.c b/SystemConfiguration.fproj/SCDNotifierCancel.c index 673f2a5..840f649 100644 --- a/SystemConfiguration.fproj/SCDNotifierCancel.c +++ b/SystemConfiguration.fproj/SCDNotifierCancel.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000-2005, 2008-2011 Apple Inc. All rights reserved. + * Copyright (c) 2000-2005, 2008-2011, 2015 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -57,8 +57,10 @@ SCDynamicStoreNotifyCancel(SCDynamicStoreRef store) /* if no notifications have been registered */ return TRUE; case Using_NotifierInformViaRunLoop : - CFRunLoopSourceInvalidate(storePrivate->rls); - storePrivate->rls = NULL; + if (storePrivate->rls != NULL) { + CFRunLoopSourceInvalidate(storePrivate->rls); + storePrivate->rls = NULL; + } return TRUE; case Using_NotifierInformViaDispatch : (void) SCDynamicStoreSetDispatchQueue(store, NULL); diff --git a/SystemConfiguration.fproj/SCDNotifierInformViaCallback.c b/SystemConfiguration.fproj/SCDNotifierInformViaCallback.c index 4d81d95..ff1e055 100644 --- a/SystemConfiguration.fproj/SCDNotifierInformViaCallback.c +++ b/SystemConfiguration.fproj/SCDNotifierInformViaCallback.c @@ -1,15 +1,15 @@ /* - * Copyright (c) 2000-2005, 2008-2014 Apple Inc. All rights reserved. + * Copyright (c) 2000-2005, 2008-2015 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ - * + * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. - * + * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, @@ -17,7 +17,7 @@ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. - * + * * @APPLE_LICENSE_HEADER_END@ */ @@ -63,20 +63,24 @@ notifyMPCopyDescription(const void *info) static void rlsCallback(CFMachPortRef port, void *msg, CFIndex size, void *info) { + os_activity_t activity_id; mach_no_senders_notification_t *buf = msg; mach_msg_id_t msgid = buf->not_header.msgh_id; SCDynamicStoreRef store = (SCDynamicStoreRef)info; SCDynamicStorePrivateRef storePrivate = (SCDynamicStorePrivateRef)store; + activity_id = os_activity_start("processing SCDynamicStore notification", + OS_ACTIVITY_FLAG_DEFAULT); + if (msgid == MACH_NOTIFY_NO_SENDERS) { /* the server died, disable additional callbacks */ #ifdef DEBUG - SCLog(_sc_verbose, LOG_INFO, CFSTR(" rlsCallback(), notifier port closed")); + SC_log(LOG_DEBUG, " notifier port closed"); #endif /* DEBUG */ #ifdef DEBUG if (port != storePrivate->rlsNotifyPort) { - SCLog(_sc_verbose, LOG_DEBUG, CFSTR("rlsCallback(), why is port != rlsNotifyPort?")); + SC_log(LOG_DEBUG, "why is port != rlsNotifyPort?"); } #endif /* DEBUG */ @@ -84,10 +88,17 @@ rlsCallback(CFMachPortRef port, void *msg, CFIndex size, void *info) (void)__SCDynamicStoreReconnectNotifications(store); } +#ifdef DEBUG + SC_log(LOG_DEBUG, "mach port callback, signal RLS"); +#endif /* DEBUG */ + /* signal the real runloop source */ if (storePrivate->rls != NULL) { CFRunLoopSourceSignal(storePrivate->rls); } + + os_activity_end(activity_id); + return; } @@ -99,9 +110,8 @@ rlsSchedule(void *info, CFRunLoopRef rl, CFStringRef mode) SCDynamicStorePrivateRef storePrivate = (SCDynamicStorePrivateRef)store; #ifdef DEBUG - SCLog(_sc_verbose, LOG_DEBUG, - CFSTR("schedule notifications for mode %@"), - (rl != NULL) ? mode : CFSTR("libdispatch")); + SC_log(LOG_DEBUG, "schedule notifications for mode %@", + (rl != NULL) ? mode : CFSTR("libdispatch")); #endif /* DEBUG */ if (storePrivate->rlList == NULL) { @@ -120,7 +130,7 @@ rlsSchedule(void *info, CFRunLoopRef rl, CFStringRef mode) int sc_status; #ifdef DEBUG - SCLog(_sc_verbose, LOG_DEBUG, CFSTR(" activate callback runloop source")); + SC_log(LOG_DEBUG, " activate callback runloop source"); #endif /* DEBUG */ /* allocate a mach port for the SCDynamicStore notifications */ @@ -137,7 +147,7 @@ rlsSchedule(void *info, CFRunLoopRef rl, CFStringRef mode) #endif // HAVE_MACHPORT_GUARDS if (kr != KERN_SUCCESS) { - SCLog(TRUE, LOG_ERR, CFSTR("rlsSchedule could not allocate mach port: %s"), mach_error_string(kr)); + SC_log(LOG_NOTICE, "could not allocate mach port: %s", mach_error_string(kr)); if ((kr == KERN_NO_SPACE) || (kr == KERN_RESOURCE_SHORTAGE)) { sleep(1); goto retry_allocate; @@ -157,7 +167,7 @@ rlsSchedule(void *info, CFRunLoopRef rl, CFStringRef mode) * only happen if someone stomped on OUR port (so let's leave * the port alone). */ - SCLog(TRUE, LOG_ERR, CFSTR("rlsSchedule mach_port_insert_right(): %s"), mach_error_string(kr)); + SC_log(LOG_NOTICE, "mach_port_insert_right() failed: %s", mach_error_string(kr)); return; } #endif // HAVE_MACHPORT_GUARDS @@ -176,12 +186,12 @@ rlsSchedule(void *info, CFRunLoopRef rl, CFStringRef mode) * only happen if someone stomped on OUR port (so let's leave * the port alone). */ - SCLog(TRUE, LOG_ERR, CFSTR("rlsSchedule mach_port_request_notification(): %s"), mach_error_string(kr)); + SC_log(LOG_NOTICE, "mach_port_request_notification() failed: %s", mach_error_string(kr)); return; } if (oldNotify != MACH_PORT_NULL) { - SCLog(TRUE, LOG_ERR, CFSTR("rlsSchedule(): oldNotify != MACH_PORT_NULL")); + SC_log(LOG_NOTICE, "oldNotify != MACH_PORT_NULL"); } retry : @@ -255,9 +265,8 @@ rlsCancel(void *info, CFRunLoopRef rl, CFStringRef mode) SCDynamicStorePrivateRef storePrivate = (SCDynamicStorePrivateRef)store; #ifdef DEBUG - SCLog(_sc_verbose, LOG_DEBUG, - CFSTR("cancel notifications for mode %@"), - (rl != NULL) ? mode : CFSTR("libdispatch")); + SC_log(LOG_DEBUG, "cancel notifications for mode %@", + (rl != NULL) ? mode : CFSTR("libdispatch")); #endif /* DEBUG */ if ((rl != NULL) && (storePrivate->rlsNotifyRLS != NULL)) { @@ -281,7 +290,7 @@ rlsCancel(void *info, CFRunLoopRef rl, CFStringRef mode) kern_return_t kr; #ifdef DEBUG - SCLog(_sc_verbose, LOG_DEBUG, CFSTR(" cancel callback runloop source")); + SC_log(LOG_DEBUG, " cancel callback runloop source"); #endif /* DEBUG */ __MACH_PORT_DEBUG((storePrivate->rlsNotifyPort != NULL), "*** rlsCancel", @@ -341,15 +350,19 @@ rlsCancel(void *info, CFRunLoopRef rl, CFStringRef mode) static void rlsPerform(void *info) { - CFArrayRef changedKeys; + os_activity_t activity_id; + CFArrayRef changedKeys = NULL; void *context_info; void (*context_release)(const void *); SCDynamicStoreCallBack rlsFunction; SCDynamicStoreRef store = (SCDynamicStoreRef)info; SCDynamicStorePrivateRef storePrivate = (SCDynamicStorePrivateRef)store; + activity_id = os_activity_start("processing SCDynamicStore notification", + OS_ACTIVITY_FLAG_DEFAULT); + #ifdef DEBUG - SCLog(_sc_verbose, LOG_DEBUG, CFSTR(" executing notification function")); + SC_log(LOG_DEBUG, " executing notification function"); #endif /* DEBUG */ changedKeys = SCDynamicStoreCopyNotifiedKeys(store); @@ -358,13 +371,9 @@ rlsPerform(void *info) if (changedKeys == NULL) { changedKeys = CFArrayCreate(NULL, NULL, 0, &kCFTypeArrayCallBacks); } - } else { - if (changedKeys == NULL) { - /* if no changes or something happened to the server */ - return; - } else if (CFArrayGetCount(changedKeys) == 0) { - goto done; - } + } else if ((changedKeys == NULL) || (CFArrayGetCount(changedKeys) == 0)) { + /* if no changes or something happened to the server */ + goto done; } rlsFunction = storePrivate->rlsFunction; @@ -385,7 +394,12 @@ rlsPerform(void *info) done : - CFRelease(changedKeys); + if (changedKeys != NULL) { + CFRelease(changedKeys); + } + + os_activity_end(activity_id); + return; } @@ -406,7 +420,7 @@ rlsRetain(CFTypeRef cf) case Using_NotifierInformViaRunLoop : break; default : - SCLog(TRUE, LOG_ERR, CFSTR("rlsRetain() error: notifyStatus=%d"), storePrivate->notifyStatus); + SC_log(LOG_NOTICE, "unexpected notify status=%d", storePrivate->notifyStatus); break; } @@ -432,7 +446,7 @@ rlsRelease(CFTypeRef cf) CFRelease(store); break; default : - SCLog(TRUE, LOG_ERR, CFSTR("rlsRelease() error: notifyStatus=%d"), storePrivate->notifyStatus); + SC_log(LOG_NOTICE, "unexpected notify status=%d", storePrivate->notifyStatus); break; } @@ -608,7 +622,7 @@ SCDynamicStoreSetDispatchQueue(SCDynamicStoreRef store, dispatch_queue_t queue) mp = CFMachPortGetPort(storePrivate->rlsNotifyPort); source = dispatch_source_create(DISPATCH_SOURCE_TYPE_MACH_RECV, mp, 0, queue); if (source == NULL) { - SCLog(TRUE, LOG_ERR, CFSTR("SCDynamicStore dispatch_source_create() failed")); + SC_log(LOG_NOTICE, "dispatch_source_create() failed"); _SCErrorSet(kSCStatusFailed); goto cleanup; } @@ -630,9 +644,7 @@ SCDynamicStoreSetDispatchQueue(SCDynamicStoreRef store, dispatch_queue_t queue) MACH_MSG_TIMEOUT_NONE, // timeout MACH_PORT_NULL); // notify if (kr != KERN_SUCCESS) { - SCLog(TRUE, LOG_ERR, - CFSTR("SCDynamicStore notification handler, kr=0x%x"), - kr); + SC_log(LOG_NOTICE, "mach_msg() failed, kr=0x%x", kr); return; } diff --git a/SystemConfiguration.fproj/SCDNotifierInformViaFD.c b/SystemConfiguration.fproj/SCDNotifierInformViaFD.c index fc51afe..aecd743 100644 --- a/SystemConfiguration.fproj/SCDNotifierInformViaFD.c +++ b/SystemConfiguration.fproj/SCDNotifierInformViaFD.c @@ -1,15 +1,15 @@ /* - * Copyright (c) 2000, 2001, 2003-2005, 2008-2011, 2013 Apple Inc. All rights reserved. + * Copyright (c) 2000, 2001, 2003-2005, 2008-2011, 2013, 2015 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ - * + * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. - * + * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, @@ -17,7 +17,7 @@ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. - * + * * @APPLE_LICENSE_HEADER_END@ */ @@ -78,7 +78,7 @@ SCDynamicStoreNotifyFileDescriptor(SCDynamicStoreRef store, if ((sock = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) { _SCErrorSet(errno); - SCLog(TRUE, LOG_NOTICE, CFSTR("SCDynamicStoreNotifyFileDescriptor socket(): %s"), strerror(errno)); + SC_log(LOG_ERR, "socket() failed: %s", strerror(errno)); return FALSE; } @@ -104,7 +104,7 @@ SCDynamicStoreNotifyFileDescriptor(SCDynamicStoreRef store, if (bind(sock, (struct sockaddr *)&un, sizeof(un)) == -1) { _SCErrorSet(errno); - SCLog(TRUE, LOG_NOTICE, CFSTR("SCDynamicStoreNotifyFileDescriptor bind(): %s"), strerror(errno)); + SC_log(LOG_ERR, "bind() failed: %s", strerror(errno)); (void) unlink(un.sun_path); (void) close(sock); return FALSE; @@ -112,7 +112,7 @@ SCDynamicStoreNotifyFileDescriptor(SCDynamicStoreRef store, if (listen(sock, 0) == -1) { _SCErrorSet(errno); - SCLog(TRUE, LOG_NOTICE, CFSTR("SCDynamicStoreNotifyFileDescriptor listen(): %s"), strerror(errno)); + SC_log(LOG_ERR, "listen() failed: %s", strerror(errno)); (void) unlink(un.sun_path); (void) close(sock); return FALSE; @@ -142,9 +142,7 @@ SCDynamicStoreNotifyFileDescriptor(SCDynamicStoreRef store, if (sc_status != kSCStatusOK) { _SCErrorSet(sc_status); - SCLog(TRUE, LOG_NOTICE, - CFSTR("SCDynamicStoreNotifyFileDescriptor server error: %s"), - SCErrorString(sc_status)); + SC_log(LOG_NOTICE, "SCDynamicStoreNotifyFileDescriptor server error: %s", SCErrorString(sc_status)); (void) close(sock); return FALSE; } @@ -152,7 +150,7 @@ SCDynamicStoreNotifyFileDescriptor(SCDynamicStoreRef store, *fd = accept(sock, 0, 0); if (*fd == -1) { _SCErrorSet(errno); - SCLog(TRUE, LOG_NOTICE, CFSTR("SCDynamicStoreNotifyFileDescriptor accept(): %s"), strerror(errno)); + SC_log(LOG_ERR, "accept() failed: %s", strerror(errno)); (void) close(sock); return FALSE; } diff --git a/SystemConfiguration.fproj/SCDNotifierInformViaSignal.c b/SystemConfiguration.fproj/SCDNotifierInformViaSignal.c index ddae17a..66fc49b 100644 --- a/SystemConfiguration.fproj/SCDNotifierInformViaSignal.c +++ b/SystemConfiguration.fproj/SCDNotifierInformViaSignal.c @@ -1,15 +1,15 @@ /* - * Copyright (c) 2000, 2001, 2004, 2005, 2009-2011 Apple Inc. All rights reserved. + * Copyright (c) 2000, 2001, 2004, 2005, 2009-2011, 2015 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ - * + * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. - * + * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, @@ -17,7 +17,7 @@ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. - * + * * @APPLE_LICENSE_HEADER_END@ */ @@ -67,7 +67,7 @@ SCDynamicStoreNotifySignal(SCDynamicStoreRef store, pid_t pid, int sig) status = task_for_pid(mach_task_self(), pid, &task); if (status != KERN_SUCCESS) { - SCLog(TRUE, LOG_DEBUG, CFSTR("SCDynamicStoreNotifySignal task_for_pid(): %s"), mach_error_string(status)); + SC_log(LOG_ERR, "task_for_pid() failed: %s", mach_error_string(status)); _SCErrorSet(status); return FALSE; } diff --git a/SystemConfiguration.fproj/SCDNotifierWait.c b/SystemConfiguration.fproj/SCDNotifierWait.c index 751f47f..5ea1ba3 100644 --- a/SystemConfiguration.fproj/SCDNotifierWait.c +++ b/SystemConfiguration.fproj/SCDNotifierWait.c @@ -1,15 +1,15 @@ /* - * Copyright (c) 2000, 2001, 2004, 2006, 2009-2011 Apple Inc. All rights reserved. + * Copyright (c) 2000, 2001, 2004, 2006, 2009-2011, 2015 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ - * + * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. - * + * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, @@ -17,7 +17,7 @@ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. - * + * * @APPLE_LICENSE_HEADER_END@ */ @@ -56,7 +56,7 @@ waitForMachMessage(mach_port_t port) MACH_MSG_TIMEOUT_NONE, /* timeout */ MACH_PORT_NULL); /* notify */ if (status != KERN_SUCCESS) { - SCLog(TRUE, LOG_DEBUG, CFSTR("waitForMachMessage mach_msg(): %s"), mach_error_string(status)); + SC_log(LOG_NOTICE, "mach_msg() failed: %s", mach_error_string(status)); return -1; } @@ -95,7 +95,7 @@ SCDynamicStoreNotifyWait(SCDynamicStoreRef store) /* Allocating port (for server response) */ status = mach_port_allocate(mach_task_self(), MACH_PORT_RIGHT_RECEIVE, &port); if (status != KERN_SUCCESS) { - SCLog(TRUE, LOG_ERR, CFSTR("SCDynamicStoreNotifyWait mach_port_allocate(): %s"), mach_error_string(status)); + SC_log(LOG_ERR, "mach_port_allocate() failed: %s", mach_error_string(status)); _SCErrorSet(status); return FALSE; } @@ -110,7 +110,7 @@ SCDynamicStoreNotifyWait(SCDynamicStoreRef store) * only happen if someone stomped on OUR port (so let's leave * the port alone). */ - SCLog(TRUE, LOG_ERR, CFSTR("SCDynamicStoreNotifyWait mach_port_insert_right(): %s"), mach_error_string(status)); + SC_log(LOG_NOTICE, "mach_port_insert_right() failed: %s", mach_error_string(status)); _SCErrorSet(status); return FALSE; } @@ -129,13 +129,13 @@ SCDynamicStoreNotifyWait(SCDynamicStoreRef store) * only happen if someone stomped on OUR port (so let's leave * the port alone). */ - SCLog(TRUE, LOG_ERR, CFSTR("SCDynamicStoreNotifyWait mach_port_request_notification(): %s"), mach_error_string(status)); + SC_log(LOG_NOTICE, "mach_port_request_notification() failed: %s", mach_error_string(status)); _SCErrorSet(status); return FALSE; } if (oldNotify != MACH_PORT_NULL) { - SCLog(TRUE, LOG_ERR, CFSTR("SCDynamicStoreNotifyWait(): oldNotify != MACH_PORT_NULL")); + SC_log(LOG_NOTICE, "oldNotify != MACH_PORT_NULL"); } retry : @@ -178,7 +178,7 @@ SCDynamicStoreNotifyWait(SCDynamicStoreRef store) if (msgid == MACH_NOTIFY_NO_SENDERS) { /* the server closed the notifier port */ #ifdef DEBUG - SCLog(_sc_verbose, LOG_DEBUG, CFSTR("SCDynamicStoreNotifyWait notifier port closed, destroying port %d"), port); + SC_log(LOG_DEBUG, "notifier port closed, port %d", port); #endif /* DEBUG */ _SCErrorSet(kSCStatusNoStoreServer); return FALSE; @@ -187,7 +187,7 @@ SCDynamicStoreNotifyWait(SCDynamicStoreRef store) if (msgid == -1) { /* one of the mach routines returned an error */ #ifdef DEBUG - SCLog(_sc_verbose, LOG_DEBUG, CFSTR("SCDynamicStoreNotifyWait communication with server failed, destroying port %d"), port); + SC_log(LOG_DEBUG, "communication with server failed, remove port right %d", port); #endif /* DEBUG */ (void) mach_port_mod_refs(mach_task_self(), port, MACH_PORT_RIGHT_RECEIVE , -1); _SCErrorSet(kSCStatusNoStoreServer); diff --git a/SystemConfiguration.fproj/SCDOpen.c b/SystemConfiguration.fproj/SCDOpen.c index e03cfff..e0864b1 100644 --- a/SystemConfiguration.fproj/SCDOpen.c +++ b/SystemConfiguration.fproj/SCDOpen.c @@ -1,15 +1,15 @@ /* - * Copyright (c) 2000-2006, 2008-2014 Apple Inc. All rights reserved. + * Copyright (c) 2000-2006, 2008-2015 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ - * + * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. - * + * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, @@ -17,7 +17,7 @@ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. - * + * * @APPLE_LICENSE_HEADER_END@ */ @@ -272,9 +272,8 @@ __SCDynamicStoreServerPort(SCDynamicStorePrivateRef storePrivate, kern_return_t break; default : #ifdef DEBUG - SCLog(_sc_verbose, LOG_DEBUG, - CFSTR("SCDynamicStoreCreate[WithOptions] bootstrap_look_up() failed: status=%s"), - bootstrap_strerror(*status)); + SC_log(LOG_INFO, "bootstrap_look_up() failed: status=%s", + bootstrap_strerror(*status)); #endif /* DEBUG */ break; } @@ -483,16 +482,12 @@ __SCDynamicStoreAddSession(SCDynamicStorePrivateRef storePrivate) case kSCStatusOK : return TRUE; case BOOTSTRAP_UNKNOWN_SERVICE : - SCLog(TRUE, - (kr == KERN_SUCCESS) ? LOG_DEBUG : LOG_ERR, - CFSTR("SCDynamicStore server not available")); + SC_log((kr == KERN_SUCCESS) ? LOG_INFO : LOG_ERR, "SCDynamicStore server not available"); sc_status = kSCStatusNoStoreServer; break; default : - SCLog(TRUE, - (kr == KERN_SUCCESS) ? LOG_DEBUG : LOG_ERR, - CFSTR("SCDynamicStoreAddSession configopen(): %s"), - SCErrorString(sc_status)); + SC_log((kr == KERN_SUCCESS) ? LOG_INFO : LOG_ERR, "configopen() failed: %s", + SCErrorString(sc_status)); break; } @@ -566,7 +561,7 @@ __SCDynamicStoreCheckRetryAndHandleError(SCDynamicStoreRef store, } } else { /* an unexpected error, leave the [session] port alone */ - SCLog(TRUE, LOG_ERR, CFSTR("%s: %s"), log_str, mach_error_string(status)); + SC_log(LOG_NOTICE, "%s: %s", log_str, mach_error_string(status)); storePrivate->server = MACH_PORT_NULL; } @@ -638,9 +633,7 @@ __SCDynamicStoreReconnectNotifications(SCDynamicStoreRef store) // cancel [old] notifications if (!SCDynamicStoreNotifyCancel(store)) { // if we could not cancel / reconnect - SCLog(TRUE, LOG_DEBUG, - CFSTR("__SCDynamicStoreReconnectNotifications: SCDynamicStoreNotifyCancel() failed: %s"), - SCErrorString(SCError())); + SC_log(LOG_NOTICE, "SCDynamicStoreNotifyCancel() failed: %s", SCErrorString(SCError())); } // set notification keys & patterns @@ -649,9 +642,9 @@ __SCDynamicStoreReconnectNotifications(SCDynamicStoreRef store) storePrivate->keys, storePrivate->patterns); if (!ok) { - SCLog((SCError() != BOOTSTRAP_UNKNOWN_SERVICE), - LOG_ERR, - CFSTR("__SCDynamicStoreReconnectNotifications: SCDynamicStoreSetNotificationKeys() failed")); + if (SCError() != BOOTSTRAP_UNKNOWN_SERVICE) { + SC_log(LOG_NOTICE, "SCDynamicStoreSetNotificationKeys() failed"); + } goto done; } } @@ -664,9 +657,9 @@ __SCDynamicStoreReconnectNotifications(SCDynamicStoreRef store) rls = SCDynamicStoreCreateRunLoopSource(NULL, store, 0); if (rls == NULL) { - SCLog((SCError() != BOOTSTRAP_UNKNOWN_SERVICE), - LOG_ERR, - CFSTR("__SCDynamicStoreReconnectNotifications: SCDynamicStoreCreateRunLoopSource() failed")); + if (SCError() != BOOTSTRAP_UNKNOWN_SERVICE) { + SC_log(LOG_NOTICE, "SCDynamicStoreCreateRunLoopSource() failed"); + } ok = FALSE; break; } @@ -685,9 +678,9 @@ __SCDynamicStoreReconnectNotifications(SCDynamicStoreRef store) case Using_NotifierInformViaDispatch : ok = SCDynamicStoreSetDispatchQueue(store, dispatchQueue); if (!ok) { - SCLog((SCError() != BOOTSTRAP_UNKNOWN_SERVICE), - LOG_ERR, - CFSTR("__SCDynamicStoreReconnectNotifications: SCDynamicStoreSetDispatchQueue() failed")); + if (SCError() != BOOTSTRAP_UNKNOWN_SERVICE) { + SC_log(LOG_NOTICE, "SCDynamicStoreSetDispatchQueue() failed"); + } goto done; } break; @@ -713,10 +706,9 @@ __SCDynamicStoreReconnectNotifications(SCDynamicStoreRef store) } if (!ok) { - SCLog(TRUE, LOG_ERR, - CFSTR("SCDynamicStore server %s, notification (%s) not restored"), - (SCError() == BOOTSTRAP_UNKNOWN_SERVICE) ? "shutdown" : "failed", - notifyType[notifyStatus]); + SC_log(LOG_NOTICE, "SCDynamicStore server %s, notification (%s) not restored", + (SCError() == BOOTSTRAP_UNKNOWN_SERVICE) ? "shutdown" : "failed", + notifyType[notifyStatus]); } // inform the client diff --git a/SystemConfiguration.fproj/SCDPrivate.c b/SystemConfiguration.fproj/SCDPrivate.c index 882729b..398b0ef 100644 --- a/SystemConfiguration.fproj/SCDPrivate.c +++ b/SystemConfiguration.fproj/SCDPrivate.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000-2014 Apple Inc. All rights reserved. + * Copyright (c) 2000-2015 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -320,7 +320,7 @@ _SC_hw_model(Boolean trim) bzero(&hwModel, sizeof(hwModel)); ret = sysctl(mib, sizeof(mib) / sizeof(mib[0]), &hwModel, &n, NULL, 0); if (ret != 0) { - SCLog(TRUE, LOG_ERR, CFSTR("sysctl() CTL_HW/HW_MODEL failed: %s"), strerror(errno)); + SC_log(LOG_NOTICE, "sysctl() CTL_HW/HW_MODEL failed: %s", strerror(errno)); return; } hwModel[sizeof(hwModel) - 1] = '\0'; @@ -367,7 +367,7 @@ _SCSerialize(CFPropertyListRef obj, CFDataRef *xml, void **dataRef, CFIndex *dat 0, NULL); if (myXml == NULL) { - SCLog(TRUE, LOG_ERR, CFSTR("_SCSerialize() failed")); + SC_log(LOG_NOTICE, "CFPropertyListCreateData() failed"); if (xml != NULL) { *xml = NULL; } @@ -394,7 +394,7 @@ _SCSerialize(CFPropertyListRef obj, CFDataRef *xml, void **dataRef, CFIndex *dat (void *)dataRef, &len); if (status != KERN_SUCCESS) { - SCLog(TRUE, LOG_ERR, CFSTR("_SCSerialize(): %s"), mach_error_string(status)); + SC_log(LOG_NOTICE, "vm_read() failed: %s", mach_error_string(status)); CFRelease(myXml); *dataRef = NULL; *dataLen = 0; @@ -423,7 +423,7 @@ _SCUnserialize(CFPropertyListRef *obj, CFDataRef xml, void *dataRef, CFIndex dat status = vm_deallocate(mach_task_self(), (vm_address_t)dataRef, dataLen); if (status != KERN_SUCCESS) { - SCLog(_sc_verbose, LOG_DEBUG, CFSTR("_SCUnserialize(): %s"), mach_error_string(status)); + SC_log(LOG_NOTICE, "vm_deallocate() failed: %s", mach_error_string(status)); /* non-fatal???, proceed */ } } else { @@ -432,7 +432,7 @@ _SCUnserialize(CFPropertyListRef *obj, CFDataRef xml, void *dataRef, CFIndex dat if (*obj == NULL) { if (error != NULL) { - SCLog(TRUE, LOG_ERR, CFSTR("_SCUnserialize(): %@"), error); + SC_log(LOG_NOTICE, "CFPropertyListCreateWithData() faled: %@", error); CFRelease(error); } _SCErrorSet(kSCStatusFailed); @@ -460,7 +460,7 @@ _SCSerializeString(CFStringRef str, CFDataRef *data, void **dataRef, CFIndex *da myData = CFStringCreateExternalRepresentation(NULL, str, kCFStringEncodingUTF8, 0); if (myData == NULL) { - SCLog(TRUE, LOG_ERR, CFSTR("_SCSerializeString() failed")); + SC_log(LOG_NOTICE, "CFStringCreateExternalRepresentation() failed"); if (data != NULL) { *data = NULL; } @@ -488,7 +488,7 @@ _SCSerializeString(CFStringRef str, CFDataRef *data, void **dataRef, CFIndex *da (void *)dataRef, &len); if (status != KERN_SUCCESS) { - SCLog(TRUE, LOG_ERR, CFSTR("_SCSerializeString(): %s"), mach_error_string(status)); + SC_log(LOG_NOTICE, "vm_read() failed: %s", mach_error_string(status)); CFRelease(myData); *dataRef = NULL; *dataLen = 0; @@ -515,7 +515,7 @@ _SCUnserializeString(CFStringRef *str, CFDataRef utf8, void *dataRef, CFIndex da status = vm_deallocate(mach_task_self(), (vm_address_t)dataRef, dataLen); if (status != KERN_SUCCESS) { - SCLog(_sc_verbose, LOG_DEBUG, CFSTR("_SCUnserializeString(): %s"), mach_error_string(status)); + SC_log(LOG_NOTICE, "vm_deallocate() failed: %s", mach_error_string(status)); /* non-fatal???, proceed */ } } else { @@ -523,7 +523,7 @@ _SCUnserializeString(CFStringRef *str, CFDataRef utf8, void *dataRef, CFIndex da } if (*str == NULL) { - SCLog(TRUE, LOG_ERR, CFSTR("_SCUnserializeString() failed")); + SC_log(LOG_NOTICE, "CFStringCreateFromExternalRepresentation() failed"); return FALSE; } @@ -549,7 +549,7 @@ _SCSerializeData(CFDataRef data, void **dataRef, CFIndex *dataLen) (void *)dataRef, &len); if (status != KERN_SUCCESS) { - SCLog(TRUE, LOG_ERR, CFSTR("_SCSerializeData(): %s"), mach_error_string(status)); + SC_log(LOG_NOTICE, "vm_read() failed: %s", mach_error_string(status)); *dataRef = NULL; *dataLen = 0; return FALSE; @@ -569,7 +569,7 @@ _SCUnserializeData(CFDataRef *data, void *dataRef, CFIndex dataLen) *data = CFDataCreate(NULL, dataRef, dataLen); status = vm_deallocate(mach_task_self(), (vm_address_t)dataRef, dataLen); if (status != KERN_SUCCESS) { - SCLog(_sc_verbose, LOG_DEBUG, CFSTR("_SCUnserializeData(): %s"), mach_error_string(status)); + SC_log(LOG_NOTICE, "vm_deallocate() failed: %s", mach_error_string(status)); _SCErrorSet(kSCStatusFailed); return FALSE; } @@ -853,7 +853,6 @@ _SC_unschedule(CFTypeRef obj, CFRunLoopRef runLoop, CFStringRef runLoopMode, CFM #define SYSTEMCONFIGURATION_BUNDLE_ID CFSTR("com.apple.SystemConfiguration") -#define SYSTEMCONFIGURATION_FRAMEWORK_PATH "/System/Library/Frameworks/SystemConfiguration.framework" #define SYSTEMCONFIGURATION_FRAMEWORK_PATH_LEN (sizeof(SYSTEMCONFIGURATION_FRAMEWORK_PATH) - 1) #define SUFFIX_SYM "~sym" @@ -868,58 +867,71 @@ _SC_CFBundleGet(void) static CFBundleRef bundle = NULL; char *env; size_t len; + CFURLRef url; if (bundle != NULL) { - return bundle; + goto done; } bundle = CFBundleGetBundleWithIdentifier(SYSTEMCONFIGURATION_BUNDLE_ID); if (bundle != NULL) { CFRetain(bundle); // we want to hold a reference to the bundle - return bundle; + goto done; + } else { + SC_log(LOG_NOTICE, "could not get CFBundle for \"%@\". Trying harder...", + SYSTEMCONFIGURATION_BUNDLE_ID); } // if appropriate (e.g. when debugging), try a bit harder env = getenv("DYLD_FRAMEWORK_PATH"); len = (env != NULL) ? strlen(env) : 0; - - // trim any trailing slashes - while (len > 1) { - if (env[len - 1] != '/') { - break; + + if (len > 0) { /* We are debugging */ + + // trim any trailing slashes + while (len > 1) { + if (env[len - 1] != '/') { + break; + } + len--; + } + + // if DYLD_FRAMEWORK_PATH is ".../xxx~sym" than try ".../xxx~dst" + if ((len > SUFFIX_SYM_LEN) && + (strncmp(&env[len - SUFFIX_SYM_LEN], SUFFIX_SYM, SUFFIX_SYM_LEN) == 0) && + ((len + SYSTEMCONFIGURATION_FRAMEWORK_PATH_LEN) < MAXPATHLEN)) { + char path[MAXPATHLEN]; + + strlcpy(path, env, sizeof(path)); + strlcpy(&path[len - SUFFIX_SYM_LEN], SUFFIX_DST, sizeof(path) - (len - SUFFIX_SYM_LEN)); + strlcat(&path[len], SYSTEMCONFIGURATION_FRAMEWORK_PATH, sizeof(path) - len); + + url = CFURLCreateFromFileSystemRepresentation(NULL, + (UInt8 *)path, + len + SYSTEMCONFIGURATION_FRAMEWORK_PATH_LEN, + TRUE); + bundle = CFBundleCreate(NULL, url); + CFRelease(url); } - len--; } - - // if DYLD_FRAMEWORK_PATH is ".../xxx~sym" than try ".../xxx~dst" - if ((len > SUFFIX_SYM_LEN) && - (strncmp(&env[len - SUFFIX_SYM_LEN], SUFFIX_SYM, SUFFIX_SYM_LEN) == 0) && - ((len + SYSTEMCONFIGURATION_FRAMEWORK_PATH_LEN) < MAXPATHLEN)) { - char path[MAXPATHLEN]; - CFURLRef url; - - strlcpy(path, env, sizeof(path)); - strlcpy(&path[len - SUFFIX_SYM_LEN], SUFFIX_DST, sizeof(path) - (len - SUFFIX_SYM_LEN)); - strlcat(&path[len], SYSTEMCONFIGURATION_FRAMEWORK_PATH, sizeof(path) - len); - - url = CFURLCreateFromFileSystemRepresentation(NULL, - (UInt8 *)path, - len + SYSTEMCONFIGURATION_FRAMEWORK_PATH_LEN, - TRUE); + + if (bundle == NULL) { /* Try a more "direct" route to get the bundle */ + + url = CFURLCreateWithFileSystemPath(NULL, + CFSTR(SYSTEMCONFIGURATION_FRAMEWORK_PATH), + kCFURLPOSIXPathStyle, + TRUE); + bundle = CFBundleCreate(NULL, url); CFRelease(url); } - + if (bundle == NULL) { - static Boolean warned = FALSE; - - SCLog(!warned, LOG_WARNING, - CFSTR("_SC_CFBundleGet(), could not get CFBundle for \"%@\""), - SYSTEMCONFIGURATION_BUNDLE_ID); - warned = TRUE; + SC_log(LOG_ERR, "could not get CFBundle for \"%@\"", SYSTEMCONFIGURATION_BUNDLE_ID); } +done: return bundle; } @@ -974,6 +986,7 @@ _SC_CFBundleCopyNonLocalizedString(CFBundleRef bundle, CFStringRef key, CFString * for the given strings table. Fall back to using * CFBundleCopyResourceURLForLocalization() below. */ + SC_log(LOG_NOTICE, "%s: failed to create data properties from resource (error=%ld)", __FUNCTION__ , (long)errCode); data = NULL; } CFRelease(url); @@ -996,9 +1009,12 @@ _SC_CFBundleCopyNonLocalizedString(CFBundleRef bundle, CFStringRef key, CFString &errCode); #pragma GCC diagnostic pop if (!ok) { + SC_log(LOG_NOTICE, "%s: failed to create data properties from resource (error=%ld)", __FUNCTION__ , (long)errCode); data = NULL; } CFRelease(url); + } else { + SC_log(LOG_ERR, "%s: failed to get resource url: {bundle:%@, table: %@}", __FUNCTION__,bundle, tableName); } } @@ -1050,10 +1066,9 @@ _SC_CFMachPortCreateWithPort(const char *portDescription, CFStringRef err; char *crash_info = NULL; - SCLog(TRUE, LOG_ERR, - CFSTR("%s: CFMachPortCreateWithPort() failed , port = %p"), - portDescription, - (void *)(uintptr_t)portNum); + SC_log(LOG_NOTICE, "%s: CFMachPortCreateWithPort() failed , port = %p", + portDescription, + (void *)(uintptr_t)portNum); if (port != NULL) { err = CFStringCreateWithFormat(NULL, NULL, CFSTR("%s: CFMachPortCreateWithPort recycled, [old] port = %@"), @@ -1190,7 +1205,7 @@ _SC_logMachPortStatus(void) mach_msg_type_number_t pi, pn, tn; CFMutableStringRef str; - SCLog(TRUE, LOG_NOTICE, CFSTR("----------")); + SC_log(LOG_DEBUG, "----------"); /* report on ALL mach ports associated with this task */ status = mach_port_names(mach_task_self(), &ports, &pn, &types, &tn); @@ -1217,7 +1232,7 @@ _SC_logMachPortStatus(void) *rp = '\0'; CFStringAppendFormat(str, NULL, CFSTR(" %d%s"), ports[pi], rights); } - SCLog(TRUE, LOG_NOTICE, CFSTR("Task ports (n=%d):%@"), pn, str); + SC_log(LOG_DEBUG, "Task ports (n=%d):%@", pn, str); CFRelease(str); } @@ -1265,22 +1280,20 @@ _SC_logMachPortReferences(const char *str, mach_port_t port) status = mach_port_type(mach_task_self(), port, &pt); if (status != KERN_SUCCESS) { - SCLog(TRUE, LOG_NOTICE, - CFSTR("%smach_port_get_refs(..., 0x%x, MACH_PORT_RIGHT_SEND): %s"), - buf, - port, - mach_error_string(status)); + SC_log(LOG_DEBUG, "%smach_port_type(..., 0x%x): %s", + buf, + port, + mach_error_string(status)); return; } if ((pt & MACH_PORT_TYPE_SEND) != 0) { - status = mach_port_get_refs(mach_task_self(), port, MACH_PORT_RIGHT_SEND, &refs_send); + status = mach_port_get_refs(mach_task_self(), port, MACH_PORT_RIGHT_SEND, &refs_send); if (status != KERN_SUCCESS) { - SCLog(TRUE, LOG_NOTICE, - CFSTR("%smach_port_get_refs(..., 0x%x, MACH_PORT_RIGHT_SEND): %s"), - buf, - port, - mach_error_string(status)); + SC_log(LOG_DEBUG, "%smach_port_get_refs(..., 0x%x, MACH_PORT_RIGHT_SEND): %s", + buf, + port, + mach_error_string(status)); return; } } @@ -1288,28 +1301,26 @@ _SC_logMachPortReferences(const char *str, mach_port_t port) if ((pt & MACH_PORT_TYPE_RECEIVE) != 0) { mach_msg_type_number_t count; - status = mach_port_get_refs(mach_task_self(), port, MACH_PORT_RIGHT_RECEIVE, &refs_recv); + status = mach_port_get_refs(mach_task_self(), port, MACH_PORT_RIGHT_RECEIVE, &refs_recv); if (status != KERN_SUCCESS) { - SCLog(TRUE, LOG_NOTICE, - CFSTR("%smach_port_get_refs(..., 0x%x, MACH_PORT_RIGHT_RECEIVE): %s"), - buf, - port, - mach_error_string(status)); + SC_log(LOG_DEBUG, "%smach_port_get_refs(..., 0x%x, MACH_PORT_RIGHT_RECEIVE): %s", + buf, + port, + mach_error_string(status)); return; } count = MACH_PORT_RECEIVE_STATUS_COUNT; status = mach_port_get_attributes(mach_task_self(), - port, - MACH_PORT_RECEIVE_STATUS, - (mach_port_info_t)&recv_status, - &count); + port, + MACH_PORT_RECEIVE_STATUS, + (mach_port_info_t)&recv_status, + &count); if (status != KERN_SUCCESS) { - SCLog(TRUE, LOG_NOTICE, - CFSTR("%smach_port_get_attributes(..., 0x%x, MACH_PORT_RECEIVE_STATUS): %s"), - buf, - port, - mach_error_string(status)); + SC_log(LOG_DEBUG, "%smach_port_get_attributes(..., 0x%x, MACH_PORT_RECEIVE_STATUS): %s", + buf, + port, + mach_error_string(status)); return; } } @@ -1317,23 +1328,21 @@ _SC_logMachPortReferences(const char *str, mach_port_t port) if ((pt & MACH_PORT_TYPE_SEND_ONCE) != 0) { status = mach_port_get_refs(mach_task_self(), port, MACH_PORT_RIGHT_SEND_ONCE, &refs_once); if (status != KERN_SUCCESS) { - SCLog(TRUE, LOG_NOTICE, - CFSTR("%smach_port_get_refs(..., 0x%x, MACH_PORT_RIGHT_SEND_ONCE): %s"), - buf, - port, - mach_error_string(status)); + SC_log(LOG_DEBUG, "%smach_port_get_refs(..., 0x%x, MACH_PORT_RIGHT_SEND_ONCE): %s", + buf, + port, + mach_error_string(status)); return; } } if ((pt & MACH_PORT_TYPE_PORT_SET) != 0) { - status = mach_port_get_refs(mach_task_self(), port, MACH_PORT_RIGHT_PORT_SET, &refs_pset); + status = mach_port_get_refs(mach_task_self(), port, MACH_PORT_RIGHT_PORT_SET, &refs_pset); if (status != KERN_SUCCESS) { - SCLog(TRUE, LOG_NOTICE, - CFSTR("%smach_port_get_refs(..., 0x%x, MACH_PORT_RIGHT_PORT_SET): %s"), - buf, - port, - mach_error_string(status)); + SC_log(LOG_DEBUG, "%smach_port_get_refs(..., 0x%x, MACH_PORT_RIGHT_PORT_SET): %s", + buf, + port, + mach_error_string(status)); return; } } @@ -1341,27 +1350,25 @@ _SC_logMachPortReferences(const char *str, mach_port_t port) if ((pt & MACH_PORT_TYPE_DEAD_NAME) != 0) { status = mach_port_get_refs(mach_task_self(), port, MACH_PORT_RIGHT_DEAD_NAME, &refs_dead); if (status != KERN_SUCCESS) { - SCLog(TRUE, LOG_NOTICE, - CFSTR("%smach_port_get_refs(..., 0x%x, MACH_PORT_RIGHT_DEAD_NAME): %s"), - buf, - port, - mach_error_string(status)); + SC_log(LOG_DEBUG, "%smach_port_get_refs(..., 0x%x, MACH_PORT_RIGHT_DEAD_NAME): %s", + buf, + port, + mach_error_string(status)); return; } } - SCLog(TRUE, LOG_NOTICE, - CFSTR("%smach port 0x%x (%d): send=%d, receive=%d, send once=%d, port set=%d, dead name=%d%s%s"), - buf, - port, - port, - refs_send, - refs_recv, - refs_once, - refs_pset, - refs_dead, - recv_status.mps_nsrequest ? ", no more senders" : "", - ((pt & MACH_PORT_TYPE_DEAD_NAME) != 0) ? ", dead name request" : ""); + SC_log(LOG_DEBUG, "%smach port 0x%x (%d): send=%d, receive=%d, send once=%d, port set=%d, dead name=%d%s%s", + buf, + port, + port, + refs_send, + refs_recv, + refs_once, + refs_pset, + refs_dead, + recv_status.mps_nsrequest ? ", no more senders" : "", + ((pt & MACH_PORT_TYPE_DEAD_NAME) != 0) ? ", dead name request" : ""); return; } @@ -1377,7 +1384,7 @@ _SC_copyBacktrace() n = backtrace(stack, sizeof(stack)/sizeof(stack[0])); if (n == -1) { - SCLog(TRUE, LOG_ERR, CFSTR("backtrace() failed: %s"), strerror(errno)); + SC_log(LOG_NOTICE, "backtrace() failed: %s", strerror(errno)); return NULL; } @@ -1487,7 +1494,7 @@ _SC_crash(const char *crash_info, CFStringRef notifyHeader, CFStringRef notifyMe __crashreporter_info__ = crash_info; #endif // !TARGET_OS_IPHONE - SCLog(TRUE, LOG_ERR, CFSTR("%s"), crash_info); + SC_log(LOG_NOTICE, "%s", crash_info); } if (_SC_isAppleInternal()) { @@ -1530,7 +1537,7 @@ _SC_getconninfo(int socket, struct sockaddr_storage *src_addr, struct sockaddr_s } if (ioctl(socket, SIOCGCONNINFO, &request) != 0) { - SCLog(TRUE, LOG_WARNING, CFSTR("SIOCGCONNINFO failed: %s"), strerror(errno)); + SC_log(LOG_NOTICE, "SIOCGCONNINFO failed: %s", strerror(errno)); return FALSE; } diff --git a/SystemConfiguration.fproj/SCDynamicStore.h b/SystemConfiguration.fproj/SCDynamicStore.h index cc431f4..d6caf33 100644 --- a/SystemConfiguration.fproj/SCDynamicStore.h +++ b/SystemConfiguration.fproj/SCDynamicStore.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2001, 2003-2005, 2008-2010 Apple Inc. All rights reserved. + * Copyright (c) 2000, 2001, 2003-2005, 2008-2010, 2015 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -33,6 +33,8 @@ #include #include +CF_IMPLICIT_BRIDGING_ENABLED +CF_ASSUME_NONNULL_BEGIN /*! @header SCDynamicStore @@ -59,7 +61,7 @@ @discussion This is the handle to an open a dynamic store session with the system configuration daemon. */ -typedef const struct __SCDynamicStore * SCDynamicStoreRef; +typedef const struct CF_BRIDGED_TYPE(id) __SCDynamicStore * SCDynamicStoreRef; /*! @typedef SCDynamicStoreContext @@ -81,10 +83,10 @@ typedef const struct __SCDynamicStore * SCDynamicStoreRef; */ typedef struct { CFIndex version; - void * info; - const void *(*retain)(const void *info); - void (*release)(const void *info); - CFStringRef (*copyDescription)(const void *info); + void * __nullable info; + const void * __nonnull (* __nullable retain)(const void *info); + void (* __nullable release)(const void *info); + CFStringRef __nonnull (* __nullable copyDescription)(const void *info); } SCDynamicStoreContext; /*! @@ -107,9 +109,9 @@ typedef struct { @param info A C pointer to a user-specified block of data. */ typedef void (*SCDynamicStoreCallBack) ( - SCDynamicStoreRef store, - CFArrayRef changedKeys, - void *info + SCDynamicStoreRef store, + CFArrayRef changedKeys, + void * __nullable info ); @@ -142,12 +144,12 @@ SCDynamicStoreGetTypeID (void) __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE @result Returns a reference to the new SCDynamicStore session. You must release the returned value. */ -SCDynamicStoreRef +SCDynamicStoreRef __nullable SCDynamicStoreCreate ( - CFAllocatorRef allocator, - CFStringRef name, - SCDynamicStoreCallBack callout, - SCDynamicStoreContext *context + CFAllocatorRef __nullable allocator, + CFStringRef name, + SCDynamicStoreCallBack __nullable callout, + SCDynamicStoreContext * __nullable context ) __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); /*! @@ -187,13 +189,13 @@ SCDynamicStoreCreate ( @result Returns a reference to the new SCDynamicStore session. You must release the returned value. */ -SCDynamicStoreRef +SCDynamicStoreRef __nullable SCDynamicStoreCreateWithOptions ( - CFAllocatorRef allocator, - CFStringRef name, - CFDictionaryRef storeOptions, - SCDynamicStoreCallBack callout, - SCDynamicStoreContext *context + CFAllocatorRef __nullable allocator, + CFStringRef name, + CFDictionaryRef __nullable storeOptions, + SCDynamicStoreCallBack __nullable callout, + SCDynamicStoreContext * __nullable context ) __OSX_AVAILABLE_STARTING(__MAC_10_4,__IPHONE_2_0/*SPI*/); extern const CFStringRef kSCDynamicStoreUseSessionKeys __OSX_AVAILABLE_STARTING(__MAC_10_4,__IPHONE_2_0/*SPI*/); /* CFBoolean */ @@ -221,11 +223,11 @@ extern const CFStringRef kSCDynamicStoreUseSessionKeys __OSX_AVAILABLE_STARTING You must release the returned value. */ -CFRunLoopSourceRef +CFRunLoopSourceRef __nullable SCDynamicStoreCreateRunLoopSource ( - CFAllocatorRef allocator, - SCDynamicStoreRef store, - CFIndex order + CFAllocatorRef __nullable allocator, + SCDynamicStoreRef store, + CFIndex order ) __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); /*! @@ -240,8 +242,8 @@ SCDynamicStoreCreateRunLoopSource ( */ Boolean SCDynamicStoreSetDispatchQueue ( - SCDynamicStoreRef store, - dispatch_queue_t queue + SCDynamicStoreRef store, + dispatch_queue_t __nullable queue ) __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_4_0/*SPI*/); /*! @@ -255,10 +257,10 @@ SCDynamicStoreSetDispatchQueue ( encountered. You must release the returned value. */ -CFArrayRef +CFArrayRef __nullable SCDynamicStoreCopyKeyList ( - SCDynamicStoreRef store, - CFStringRef pattern + SCDynamicStoreRef __nullable store, + CFStringRef pattern ) __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); /*! @@ -273,9 +275,9 @@ SCDynamicStoreCopyKeyList ( */ Boolean SCDynamicStoreAddValue ( - SCDynamicStoreRef store, - CFStringRef key, - CFPropertyListRef value + SCDynamicStoreRef __nullable store, + CFStringRef key, + CFPropertyListRef value ) __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); /*! @@ -306,10 +308,10 @@ SCDynamicStoreAddTemporaryValue ( key; NULL if no value was located or an error was encountered. You must release the returned value. */ -CFPropertyListRef +CFPropertyListRef __nullable SCDynamicStoreCopyValue ( - SCDynamicStoreRef store, - CFStringRef key + SCDynamicStoreRef __nullable store, + CFStringRef key ) __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); /*! @@ -325,11 +327,11 @@ SCDynamicStoreCopyValue ( NULL if an error was encountered. You must release the returned value. */ -CFDictionaryRef +CFDictionaryRef __nullable SCDynamicStoreCopyMultiple ( - SCDynamicStoreRef store, - CFArrayRef keys, - CFArrayRef patterns + SCDynamicStoreRef __nullable store, + CFArrayRef __nullable keys, + CFArrayRef __nullable patterns ) __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); /*! @@ -343,9 +345,9 @@ SCDynamicStoreCopyMultiple ( */ Boolean SCDynamicStoreSetValue ( - SCDynamicStoreRef store, - CFStringRef key, - CFPropertyListRef value + SCDynamicStoreRef __nullable store, + CFStringRef key, + CFPropertyListRef value ) __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); /*! @@ -359,10 +361,10 @@ SCDynamicStoreSetValue ( */ Boolean SCDynamicStoreSetMultiple ( - SCDynamicStoreRef store, - CFDictionaryRef keysToSet, - CFArrayRef keysToRemove, - CFArrayRef keysToNotify + SCDynamicStoreRef __nullable store, + CFDictionaryRef __nullable keysToSet, + CFArrayRef __nullable keysToRemove, + CFArrayRef __nullable keysToNotify ) __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); /*! @@ -376,8 +378,8 @@ SCDynamicStoreSetMultiple ( */ Boolean SCDynamicStoreRemoveValue ( - SCDynamicStoreRef store, - CFStringRef key + SCDynamicStoreRef __nullable store, + CFStringRef key ) __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); /*! @@ -392,8 +394,8 @@ SCDynamicStoreRemoveValue ( */ Boolean SCDynamicStoreNotifyValue ( - SCDynamicStoreRef store, - CFStringRef key + SCDynamicStoreRef __nullable store, + CFStringRef key ) __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); /*! @@ -410,9 +412,9 @@ SCDynamicStoreNotifyValue ( */ Boolean SCDynamicStoreSetNotificationKeys ( - SCDynamicStoreRef store, - CFArrayRef keys, - CFArrayRef patterns + SCDynamicStoreRef store, + CFArrayRef __nullable keys, + CFArrayRef __nullable patterns ) __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); /*! @@ -427,12 +429,15 @@ SCDynamicStoreSetNotificationKeys ( NULL if an error was encountered. You must release the returned value. */ -CFArrayRef +CFArrayRef __nullable SCDynamicStoreCopyNotifiedKeys ( SCDynamicStoreRef store ) __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); __END_DECLS +CF_ASSUME_NONNULL_END +CF_IMPLICIT_BRIDGING_DISABLED + #endif /* USE_SYSTEMCONFIGURATION_PRIVATE_HEADERS */ #endif /* _SCDYNAMICSTORE_H */ diff --git a/SystemConfiguration.fproj/SCDynamicStoreCopyDHCPInfo.h b/SystemConfiguration.fproj/SCDynamicStoreCopyDHCPInfo.h index 66148ea..794c50f 100644 --- a/SystemConfiguration.fproj/SCDynamicStoreCopyDHCPInfo.h +++ b/SystemConfiguration.fproj/SCDynamicStoreCopyDHCPInfo.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2002, 2004, 2005, 2008, 2012 Apple Inc. All rights reserved. + * Copyright (c) 2001, 2002, 2004, 2005, 2008, 2012, 2015 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -32,6 +32,8 @@ #include #include +CF_IMPLICIT_BRIDGING_ENABLED +CF_ASSUME_NONNULL_BEGIN /*! @header SCDynamicStoreCopyDHCPInfo @@ -59,9 +61,9 @@ __BEGIN_DECLS A non-NULL return value must be released using CFRelease(). */ -CFDictionaryRef -SCDynamicStoreCopyDHCPInfo (SCDynamicStoreRef store, - CFStringRef serviceID) __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); +CFDictionaryRef __nullable +SCDynamicStoreCopyDHCPInfo (SCDynamicStoreRef __nullable store, + CFStringRef __nullable serviceID) __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); /*! @function DHCPInfoGetOptionData @@ -76,7 +78,7 @@ SCDynamicStoreCopyDHCPInfo (SCDynamicStoreRef store, The return value must NOT be released. */ -CFDataRef +CFDataRef __nullable DHCPInfoGetOptionData (CFDictionaryRef info, UInt8 code) __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); @@ -92,7 +94,7 @@ DHCPInfoGetOptionData (CFDictionaryRef info, The return value must NOT be released. */ -CFDateRef +CFDateRef __nullable DHCPInfoGetLeaseStartTime (CFDictionaryRef info) __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); @@ -109,10 +111,13 @@ DHCPInfoGetLeaseStartTime (CFDictionaryRef info) __OSX_AVAILABLE_STARTING(__MAC The return value must NOT be released. */ -CFDateRef +CFDateRef __nullable DHCPInfoGetLeaseExpirationTime (CFDictionaryRef info) __OSX_AVAILABLE_STARTING(__MAC_10_8,__IPHONE_6_0/*SPI*/); __END_DECLS +CF_ASSUME_NONNULL_END +CF_IMPLICIT_BRIDGING_DISABLED + #endif /* USE_SYSTEMCONFIGURATION_PRIVATE_HEADERS */ #endif /* _SCDYNAMICSTORECOPYDHCPINFO_H */ diff --git a/SystemConfiguration.fproj/SCDynamicStoreCopySpecific.h b/SystemConfiguration.fproj/SCDynamicStoreCopySpecific.h index 5b102b0..126b471 100644 --- a/SystemConfiguration.fproj/SCDynamicStoreCopySpecific.h +++ b/SystemConfiguration.fproj/SCDynamicStoreCopySpecific.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000-2005, 2008 Apple Inc. All rights reserved. + * Copyright (c) 2000-2005, 2008, 2015 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -33,6 +33,8 @@ #include #include +CF_IMPLICIT_BRIDGING_ENABLED +CF_ASSUME_NONNULL_BEGIN /*! @header SCDynamicStoreCopySpecific @@ -58,10 +60,10 @@ __BEGIN_DECLS NULL if the name has not been set or if an error was encountered. You must release the returned value. */ -CFStringRef +CFStringRef __nullable SCDynamicStoreCopyComputerName ( - SCDynamicStoreRef store, - CFStringEncoding *nameEncoding + SCDynamicStoreRef __nullable store, + CFStringEncoding * __nullable nameEncoding ) __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); /*! @@ -86,11 +88,11 @@ SCDynamicStoreCopyComputerName ( NULL if no user is logged in or if an error was encountered. You must release the returned value. */ -CFStringRef +CFStringRef __nullable SCDynamicStoreCopyConsoleUser ( - SCDynamicStoreRef store, - uid_t *uid, - gid_t *gid + SCDynamicStoreRef __nullable store, + uid_t * __nullable uid, + gid_t * __nullable gid ) __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_NA); /*! @@ -103,9 +105,9 @@ SCDynamicStoreCopyConsoleUser ( NULL if the name has not been set or if an error was encountered. You must release the returned value. */ -CFStringRef +CFStringRef __nullable SCDynamicStoreCopyLocalHostName ( - SCDynamicStoreRef store + SCDynamicStoreRef __nullable store ) __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); /*! @@ -119,9 +121,9 @@ SCDynamicStoreCopyLocalHostName ( was encountered. You must release the returned value. */ -CFStringRef +CFStringRef __nullable SCDynamicStoreCopyLocation ( - SCDynamicStoreRef store + SCDynamicStoreRef __nullable store ) __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_NA); /*! @@ -204,12 +206,15 @@ SCDynamicStoreCopyLocation ( was encountered. You must release the returned value. */ -CFDictionaryRef +CFDictionaryRef __nullable SCDynamicStoreCopyProxies ( - SCDynamicStoreRef store + SCDynamicStoreRef __nullable store ) __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); __END_DECLS +CF_ASSUME_NONNULL_END +CF_IMPLICIT_BRIDGING_DISABLED + #endif /* USE_SYSTEMCONFIGURATION_PRIVATE_HEADERS */ #endif /* _SCDYNAMICSTORECOPYSPECIFIC_H */ diff --git a/SystemConfiguration.fproj/SCDynamicStoreKey.h b/SystemConfiguration.fproj/SCDynamicStoreKey.h index 7e3fbc0..f53bfa2 100644 --- a/SystemConfiguration.fproj/SCDynamicStoreKey.h +++ b/SystemConfiguration.fproj/SCDynamicStoreKey.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000-2002, 2004, 2005, 2008 Apple Inc. All rights reserved. + * Copyright (c) 2000-2002, 2004, 2005, 2008, 2015 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -31,6 +31,8 @@ #include #include +CF_IMPLICIT_BRIDGING_ENABLED +CF_ASSUME_NONNULL_BEGIN /*! @header SCDynamicStoreKey @@ -62,8 +64,8 @@ __BEGIN_DECLS */ CFStringRef SCDynamicStoreKeyCreate ( - CFAllocatorRef allocator, - CFStringRef fmt, + CFAllocatorRef __nullable allocator, + CFStringRef fmt, ... ) __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); @@ -87,9 +89,9 @@ SCDynamicStoreKeyCreate ( */ CFStringRef SCDynamicStoreKeyCreateNetworkGlobalEntity ( - CFAllocatorRef allocator, - CFStringRef domain, - CFStringRef entity + CFAllocatorRef __nullable allocator, + CFStringRef domain, + CFStringRef entity ) __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); /*! @@ -110,8 +112,8 @@ SCDynamicStoreKeyCreateNetworkGlobalEntity ( */ CFStringRef SCDynamicStoreKeyCreateNetworkInterface ( - CFAllocatorRef allocator, - CFStringRef domain + CFAllocatorRef __nullable allocator, + CFStringRef domain ) __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); /*! @@ -136,10 +138,10 @@ SCDynamicStoreKeyCreateNetworkInterface ( */ CFStringRef SCDynamicStoreKeyCreateNetworkInterfaceEntity ( - CFAllocatorRef allocator, - CFStringRef domain, - CFStringRef ifname, - CFStringRef entity + CFAllocatorRef __nullable allocator, + CFStringRef domain, + CFStringRef ifname, + CFStringRef __nullable entity ) __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); /*! @@ -165,10 +167,10 @@ SCDynamicStoreKeyCreateNetworkInterfaceEntity ( */ CFStringRef SCDynamicStoreKeyCreateNetworkServiceEntity ( - CFAllocatorRef allocator, - CFStringRef domain, - CFStringRef serviceID, - CFStringRef entity + CFAllocatorRef __nullable allocator, + CFStringRef domain, + CFStringRef serviceID, + CFStringRef __nullable entity ) __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); /*! @@ -186,7 +188,7 @@ SCDynamicStoreKeyCreateNetworkServiceEntity ( */ CFStringRef SCDynamicStoreKeyCreateComputerName ( - CFAllocatorRef allocator + CFAllocatorRef __nullable allocator ) __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); /*! @@ -203,7 +205,7 @@ SCDynamicStoreKeyCreateComputerName ( */ CFStringRef SCDynamicStoreKeyCreateConsoleUser ( - CFAllocatorRef allocator + CFAllocatorRef __nullable allocator ) __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_NA); /*! @@ -221,7 +223,7 @@ SCDynamicStoreKeyCreateConsoleUser ( */ CFStringRef SCDynamicStoreKeyCreateHostNames ( - CFAllocatorRef allocator + CFAllocatorRef __nullable allocator ) __OSX_AVAILABLE_STARTING(__MAC_10_2,__IPHONE_2_0/*SPI*/); /*! @@ -239,7 +241,7 @@ SCDynamicStoreKeyCreateHostNames ( */ CFStringRef SCDynamicStoreKeyCreateLocation ( - CFAllocatorRef allocator + CFAllocatorRef __nullable allocator ) __OSX_AVAILABLE_STARTING(__MAC_10_2,__IPHONE_2_0/*SPI*/); /*! @@ -257,10 +259,13 @@ SCDynamicStoreKeyCreateLocation ( */ CFStringRef SCDynamicStoreKeyCreateProxies ( - CFAllocatorRef allocator + CFAllocatorRef __nullable allocator ) __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); __END_DECLS +CF_ASSUME_NONNULL_END +CF_IMPLICIT_BRIDGING_DISABLED + #endif /* USE_SYSTEMCONFIGURATION_PRIVATE_HEADERS */ #endif /* _SCDYNAMICSTOREKEY_H */ diff --git a/SystemConfiguration.fproj/SCNetwork.h b/SystemConfiguration.fproj/SCNetwork.h index 1e0cf19..6829818 100644 --- a/SystemConfiguration.fproj/SCNetwork.h +++ b/SystemConfiguration.fproj/SCNetwork.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2001, 2003-2009 Apple Inc. All rights reserved. + * Copyright (c) 2000, 2001, 2003-2009, 2015 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -30,6 +30,8 @@ #include #include +CF_IMPLICIT_BRIDGING_ENABLED +CF_ASSUME_NONNULL_BEGIN /*! @header SCNetwork @@ -196,4 +198,7 @@ SCNetworkInterfaceRefreshConfiguration ( __END_DECLS +CF_ASSUME_NONNULL_END +CF_IMPLICIT_BRIDGING_DISABLED + #endif /* _SCNETWORK_H */ diff --git a/SystemConfiguration.fproj/SCNetworkConfiguration.h b/SystemConfiguration.fproj/SCNetworkConfiguration.h index 25b99fe..0b5dd20 100644 --- a/SystemConfiguration.fproj/SCNetworkConfiguration.h +++ b/SystemConfiguration.fproj/SCNetworkConfiguration.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004-2011 Apple Inc. All rights reserved. + * Copyright (c) 2004-2011, 2015 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -33,6 +33,9 @@ #include #include +CF_IMPLICIT_BRIDGING_ENABLED +CF_ASSUME_NONNULL_BEGIN + /*! @header SCNetworkConfiguration @discussion The SCNetworkConfiguration API provides access to the @@ -60,7 +63,7 @@ @discussion This is the type of a reference to an object that represents a network interface. */ -typedef const struct __SCNetworkInterface * SCNetworkInterfaceRef; +typedef const struct CF_BRIDGED_TYPE(id) __SCNetworkInterface * SCNetworkInterfaceRef; /*! @const kSCNetworkInterfaceType6to4 @@ -170,7 +173,7 @@ typedef SCNetworkInterfaceRef SCBondInterfaceRef; @discussion This is the type of a reference to an object that represents the status of an Ethernet Bond interface. */ -typedef const struct __SCBondStatus * SCBondStatusRef; +typedef const struct CF_BRIDGED_TYPE(id) __SCBondStatus * SCBondStatusRef; /*! @enum Ethernet Bond Aggregation Status (kSCBondStatusDeviceAggregationStatus) codes @@ -230,7 +233,7 @@ typedef SCNetworkInterfaceRef SCVLANInterfaceRef; @discussion This is the type of a reference to an object that represents a network protocol. */ -typedef const struct __SCNetworkProtocol * SCNetworkProtocolRef; +typedef const struct CF_BRIDGED_TYPE(id) __SCNetworkProtocol * SCNetworkProtocolRef; /* network "protocol" types */ @@ -276,7 +279,7 @@ extern const CFStringRef kSCNetworkProtocolTypeSMB __OSX_AVAILABLE_STARTING @discussion This is the type of a reference to an object that represents a network service. */ -typedef const struct __SCNetworkService * SCNetworkServiceRef; +typedef const struct CF_BRIDGED_TYPE(id) __SCNetworkService * SCNetworkServiceRef; /*! @@ -291,7 +294,7 @@ typedef const struct __SCNetworkService * SCNetworkServiceRef; @discussion This is the type of a reference to an object that represents a network set. */ -typedef const struct __SCNetworkSet * SCNetworkSetRef; +typedef const struct CF_BRIDGED_TYPE(id) __SCNetworkSet * SCNetworkSetRef; __BEGIN_DECLS @@ -332,7 +335,7 @@ SCNetworkInterfaceCopyAll (void) __OSX_AVAILABLE_STARTING(__MAC_10_4,__IP @result The list of SCNetworkInterface types supported by the interface; NULL if no interface types are supported. */ -CFArrayRef /* of kSCNetworkInterfaceTypeXXX CFStringRef's */ +CFArrayRef /* of kSCNetworkInterfaceTypeXXX CFStringRef's */ __nullable SCNetworkInterfaceGetSupportedInterfaceTypes (SCNetworkInterfaceRef interface) __OSX_AVAILABLE_STARTING(__MAC_10_4,__IPHONE_2_0/*SPI*/); /*! @@ -343,7 +346,7 @@ SCNetworkInterfaceGetSupportedInterfaceTypes (SCNetworkInterfaceRef interface) @result The list of SCNetworkProtocol types supported by the interface; NULL if no protocol types are supported. */ -CFArrayRef /* of kSCNetworkProtocolTypeXXX CFStringRef's */ +CFArrayRef /* of kSCNetworkProtocolTypeXXX CFStringRef's */ __nullable SCNetworkInterfaceGetSupportedProtocolTypes (SCNetworkInterfaceRef interface) __OSX_AVAILABLE_STARTING(__MAC_10_4,__IPHONE_2_0/*SPI*/); /*! @@ -357,7 +360,7 @@ SCNetworkInterfaceGetSupportedProtocolTypes (SCNetworkInterfaceRef interface) _ @result A reference to the new SCNetworkInterface. You must release the returned value. */ -SCNetworkInterfaceRef +SCNetworkInterfaceRef __nullable SCNetworkInterfaceCreateWithInterface (SCNetworkInterfaceRef interface, CFStringRef interfaceType) __OSX_AVAILABLE_STARTING(__MAC_10_4,__IPHONE_2_0/*SPI*/); @@ -369,7 +372,7 @@ SCNetworkInterfaceCreateWithInterface (SCNetworkInterfaceRef interface, @result The BSD name associated with the interface (e.g. "en0"); NULL if no BSD name is available. */ -CFStringRef +CFStringRef __nullable SCNetworkInterfaceGetBSDName (SCNetworkInterfaceRef interface) __OSX_AVAILABLE_STARTING(__MAC_10_4,__IPHONE_2_0/*SPI*/); /*! @@ -380,7 +383,7 @@ SCNetworkInterfaceGetBSDName (SCNetworkInterfaceRef interface) __OSX_AVAILABL NULL if no configuration settings are associated with the interface or an error was encountered. */ -CFDictionaryRef +CFDictionaryRef __nullable SCNetworkInterfaceGetConfiguration (SCNetworkInterfaceRef interface) __OSX_AVAILABLE_STARTING(__MAC_10_4,__IPHONE_2_0/*SPI*/); /*! @@ -392,7 +395,7 @@ SCNetworkInterfaceGetConfiguration (SCNetworkInterfaceRef interface) __OSX_AVA NULL if no configuration settings are associated with the interface or an error was encountered. */ -CFDictionaryRef +CFDictionaryRef __nullable SCNetworkInterfaceGetExtendedConfiguration (SCNetworkInterfaceRef interface, CFStringRef extendedType) __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0/*SPI*/); @@ -402,7 +405,7 @@ SCNetworkInterfaceGetExtendedConfiguration (SCNetworkInterfaceRef interface, @param interface The network interface. @result A string representing the hardware (MAC) address for the interface. */ -CFStringRef +CFStringRef __nullable SCNetworkInterfaceGetHardwareAddressString (SCNetworkInterfaceRef interface) __OSX_AVAILABLE_STARTING(__MAC_10_4,__IPHONE_2_0/*SPI*/); /*! @@ -412,7 +415,7 @@ SCNetworkInterfaceGetHardwareAddressString (SCNetworkInterfaceRef interface) __ @result The underlying network interface; NULL if this is a leaf interface. */ -SCNetworkInterfaceRef +SCNetworkInterfaceRef __nullable SCNetworkInterfaceGetInterface (SCNetworkInterfaceRef interface) __OSX_AVAILABLE_STARTING(__MAC_10_4,__IPHONE_2_0/*SPI*/); /*! @@ -421,7 +424,7 @@ SCNetworkInterfaceGetInterface (SCNetworkInterfaceRef interface) __OSX_AVAILA @param interface The network interface. @result The interface type. */ -CFStringRef +CFStringRef __nullable SCNetworkInterfaceGetInterfaceType (SCNetworkInterfaceRef interface) __OSX_AVAILABLE_STARTING(__MAC_10_4,__IPHONE_2_0/*SPI*/); /*! @@ -432,7 +435,7 @@ SCNetworkInterfaceGetInterfaceType (SCNetworkInterfaceRef interface) __OSX_AVA @result A localized, display name for the interface; NULL if no name is available. */ -CFStringRef +CFStringRef __nullable SCNetworkInterfaceGetLocalizedDisplayName (SCNetworkInterfaceRef interface) __OSX_AVAILABLE_STARTING(__MAC_10_4,__IPHONE_2_0/*SPI*/); /*! @@ -481,11 +484,11 @@ SCNetworkInterfaceSetExtendedConfiguration (SCNetworkInterfaceRef interface, @result TRUE if requested information has been returned. */ Boolean -SCNetworkInterfaceCopyMediaOptions (SCNetworkInterfaceRef interface, - CFDictionaryRef *current, - CFDictionaryRef *active, - CFArrayRef *available, - Boolean filter) __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0/*SPI*/); +SCNetworkInterfaceCopyMediaOptions (SCNetworkInterfaceRef interface, + CFDictionaryRef __nullable * __nullable current, + CFDictionaryRef __nullable * __nullable active, + CFArrayRef __nullable * __nullable available, + Boolean filter) __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0/*SPI*/); /*! @function SCNetworkInterfaceCopyMediaSubTypes @@ -496,7 +499,7 @@ SCNetworkInterfaceCopyMediaOptions (SCNetworkInterfaceRef interface, @result An array of available media subtypes CFString's (e.g. 10BaseT/UTP, 100baseTX, etc). NULL if no subtypes are available. */ -CFArrayRef +CFArrayRef __nullable SCNetworkInterfaceCopyMediaSubTypes (CFArrayRef available) __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0/*SPI*/); /*! @@ -510,7 +513,7 @@ SCNetworkInterfaceCopyMediaSubTypes (CFArrayRef available) __OSX_AVAILABLE_ST is returned as an array of CFString's (e.g. , ). NULL if no options are available. */ -CFArrayRef +CFArrayRef __nullable SCNetworkInterfaceCopyMediaSubTypeOptions (CFArrayRef available, CFStringRef subType) __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0/*SPI*/); @@ -531,10 +534,10 @@ SCNetworkInterfaceCopyMediaSubTypeOptions (CFArrayRef available, @result TRUE if requested information has been returned. */ Boolean -SCNetworkInterfaceCopyMTU (SCNetworkInterfaceRef interface, - int *mtu_cur, - int *mtu_min, - int *mtu_max) __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0/*SPI*/); +SCNetworkInterfaceCopyMTU (SCNetworkInterfaceRef interface, + int * __nullable mtu_cur, + int * __nullable mtu_min, + int * __nullable mtu_max) __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0/*SPI*/); /*! @function SCNetworkInterfaceSetMediaOptions @@ -620,7 +623,7 @@ SCBondInterfaceCopyAvailableMemberInterfaces (SCPreferencesRef prefs) __OSX_AV @result A reference to the new SCBondInterface. You must release the returned value. */ -SCBondInterfaceRef +SCBondInterfaceRef __nullable SCBondInterfaceCreate (SCPreferencesRef prefs) __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_4_0/*SPI*/); /*! @@ -638,7 +641,7 @@ SCBondInterfaceRemove (SCBondInterfaceRef bond) __OSX_AVAILABLE_STARTING(__ @param bond The SCBondInterface interface. @result The list of interfaces. */ -CFArrayRef /* of SCNetworkInterfaceRef's */ +CFArrayRef /* of SCNetworkInterfaceRef's */ __nullable SCBondInterfaceGetMemberInterfaces (SCBondInterfaceRef bond) __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_4_0/*SPI*/); /*! @@ -648,7 +651,7 @@ SCBondInterfaceGetMemberInterfaces (SCBondInterfaceRef bond) __OSX_AVAILABLE_ @result The configuration settings associated with the Ethernet Bond interface; NULL if no changes to the default configuration have been saved. */ -CFDictionaryRef +CFDictionaryRef __nullable SCBondInterfaceGetOptions (SCBondInterfaceRef bond) __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_4_0/*SPI*/); /*! @@ -694,7 +697,7 @@ SCBondInterfaceSetOptions (SCBondInterfaceRef bond, @result The status associated with the interface. You must release the returned value. */ -SCBondStatusRef +SCBondStatusRef __nullable SCBondInterfaceCopyStatus (SCBondInterfaceRef bond) __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_4_0/*SPI*/); /*! @@ -711,7 +714,7 @@ SCBondStatusGetTypeID (void) __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHON @param bondStatus The Ethernet Bond status. @result The list of interfaces. */ -CFArrayRef /* of SCNetworkInterfaceRef's */ +CFArrayRef __nullable /* of SCNetworkInterfaceRef's */ SCBondStatusGetMemberInterfaces (SCBondStatusRef bondStatus) __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_4_0/*SPI*/); /*! @@ -727,9 +730,9 @@ SCBondStatusGetMemberInterfaces (SCBondStatusRef bondStatus) __OSX_AVAILABLE_ Bond is returned. As long as one member interface is active then the bond should be operational. */ -CFDictionaryRef -SCBondStatusGetInterfaceStatus (SCBondStatusRef bondStatus, - SCNetworkInterfaceRef interface) __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_4_0/*SPI*/); +CFDictionaryRef __nullable +SCBondStatusGetInterfaceStatus (SCBondStatusRef bondStatus, + SCNetworkInterfaceRef __nullable interface) __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_4_0/*SPI*/); /*! @group Interface configuration (VLAN) @@ -768,7 +771,7 @@ SCVLANInterfaceCopyAvailablePhysicalInterfaces (void) __OSX_AVAILABLE_START Note: the tag must be in the range (1 <= tag <= 4094) */ -SCVLANInterfaceRef +SCVLANInterfaceRef __nullable SCVLANInterfaceCreate (SCPreferencesRef prefs, SCNetworkInterfaceRef physical, CFNumberRef tag) __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_4_0/*SPI*/); @@ -788,7 +791,7 @@ SCVLANInterfaceRemove (SCVLANInterfaceRef vlan) __OSX_AVAILABLE_STARTING(__ @param vlan The SCVLANInterface interface. @result The list of interfaces. */ -SCNetworkInterfaceRef +SCNetworkInterfaceRef __nullable SCVLANInterfaceGetPhysicalInterface (SCVLANInterfaceRef vlan) __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_4_0/*SPI*/); /*! @@ -797,7 +800,7 @@ SCVLANInterfaceGetPhysicalInterface (SCVLANInterfaceRef vlan) __OSX_AVAILABLE @param vlan The SCVLANInterface interface. @result The tag. */ -CFNumberRef +CFNumberRef __nullable SCVLANInterfaceGetTag (SCVLANInterfaceRef vlan) __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_4_0/*SPI*/); /*! @@ -807,7 +810,7 @@ SCVLANInterfaceGetTag (SCVLANInterfaceRef vlan) __OSX_AVAILABLE_STARTING(__ @result The configuration settings associated with the VLAN interface; NULL if no changes to the default configuration have been saved. */ -CFDictionaryRef +CFDictionaryRef __nullable SCVLANInterfaceGetOptions (SCVLANInterfaceRef vlan) __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_4_0/*SPI*/); /*! @@ -874,7 +877,7 @@ SCNetworkProtocolGetTypeID (void) __OSX_AVAILABLE_STARTING(__MAC_10_4,__I NULL if no configuration settings are associated with the protocol or an error was encountered. */ -CFDictionaryRef +CFDictionaryRef __nullable SCNetworkProtocolGetConfiguration (SCNetworkProtocolRef protocol) __OSX_AVAILABLE_STARTING(__MAC_10_4,__IPHONE_2_0/*SPI*/); /*! @@ -892,7 +895,7 @@ SCNetworkProtocolGetEnabled (SCNetworkProtocolRef protocol) __OSX_AVAILABLE_S @param protocol The network protocol. @result The protocol type. */ -CFStringRef +CFStringRef __nullable SCNetworkProtocolGetProtocolType (SCNetworkProtocolRef protocol) __OSX_AVAILABLE_STARTING(__MAC_10_4,__IPHONE_2_0/*SPI*/); /*! @@ -957,7 +960,7 @@ SCNetworkServiceAddProtocolType (SCNetworkServiceRef service, @result The list of SCNetworkService services associated with the preferences. You must release the returned value. */ -CFArrayRef /* of SCNetworkServiceRef's */ +CFArrayRef /* of SCNetworkServiceRef's */ __nullable SCNetworkServiceCopyAll (SCPreferencesRef prefs) __OSX_AVAILABLE_STARTING(__MAC_10_4,__IPHONE_2_0/*SPI*/); /*! @@ -967,7 +970,7 @@ SCNetworkServiceCopyAll (SCPreferencesRef prefs) __OSX_AVAILABLE_STARTING(_ @result The list of SCNetworkProtocol protocols associated with the service. You must release the returned value. */ -CFArrayRef /* of SCNetworkProtocolRef's */ +CFArrayRef /* of SCNetworkProtocolRef's */ __nullable SCNetworkServiceCopyProtocols (SCNetworkServiceRef service) __OSX_AVAILABLE_STARTING(__MAC_10_4,__IPHONE_2_0/*SPI*/); /*! @@ -978,7 +981,7 @@ SCNetworkServiceCopyProtocols (SCNetworkServiceRef service) __OSX_AVAILABLE_S @result A reference to the new SCNetworkService. You must release the returned value. */ -SCNetworkServiceRef +SCNetworkServiceRef __nullable SCNetworkServiceCreate (SCPreferencesRef prefs, SCNetworkInterfaceRef interface) __OSX_AVAILABLE_STARTING(__MAC_10_4,__IPHONE_2_0/*SPI*/); @@ -992,7 +995,7 @@ SCNetworkServiceCreate (SCPreferencesRef prefs, error was encountered. You must release the returned value. */ -SCNetworkServiceRef +SCNetworkServiceRef __nullable SCNetworkServiceCopy (SCPreferencesRef prefs, CFStringRef serviceID) __OSX_AVAILABLE_STARTING(__MAC_10_4,__IPHONE_2_0/*SPI*/); @@ -1024,7 +1027,7 @@ SCNetworkServiceGetEnabled (SCNetworkServiceRef service) __OSX_AVAILABLE_STAR @result A reference to the SCNetworkInterface associated with the service; NULL if an error was encountered. */ -SCNetworkInterfaceRef +SCNetworkInterfaceRef __nullable SCNetworkServiceGetInterface (SCNetworkServiceRef service) __OSX_AVAILABLE_STARTING(__MAC_10_4,__IPHONE_2_0/*SPI*/); /*! @@ -1033,7 +1036,7 @@ SCNetworkServiceGetInterface (SCNetworkServiceRef service) __OSX_AVAILABLE_ST @param service The network service. @result The [user specified] name. */ -CFStringRef +CFStringRef __nullable SCNetworkServiceGetName (SCNetworkServiceRef service) __OSX_AVAILABLE_STARTING(__MAC_10_4,__IPHONE_2_0/*SPI*/); /*! @@ -1045,7 +1048,7 @@ SCNetworkServiceGetName (SCNetworkServiceRef service) __OSX_AVAILABLE_STARTI NULL if this protocol has not been added or if an error was encountered. You must release the returned value. */ -SCNetworkProtocolRef +SCNetworkProtocolRef __nullable SCNetworkServiceCopyProtocol (SCNetworkServiceRef service, CFStringRef protocolType) __OSX_AVAILABLE_STARTING(__MAC_10_4,__IPHONE_2_0/*SPI*/); @@ -1055,7 +1058,7 @@ SCNetworkServiceCopyProtocol (SCNetworkServiceRef service, @param service The network service. @result The service identifier. */ -CFStringRef +CFStringRef __nullable SCNetworkServiceGetServiceID (SCNetworkServiceRef service) __OSX_AVAILABLE_STARTING(__MAC_10_4,__IPHONE_2_0/*SPI*/); /*! @@ -1161,7 +1164,7 @@ SCNetworkSetContainsInterface (SCNetworkSetRef set, @result The list of SCNetworkSet sets associated with the preferences. You must release the returned value. */ -CFArrayRef /* of SCNetworkSetRef's */ +CFArrayRef /* of SCNetworkSetRef's */ __nullable SCNetworkSetCopyAll (SCPreferencesRef prefs) __OSX_AVAILABLE_STARTING(__MAC_10_4,__IPHONE_2_0/*SPI*/); /*! @@ -1170,7 +1173,7 @@ SCNetworkSetCopyAll (SCPreferencesRef prefs) __OSX_AVAILABLE_STARTING(__MAC @param prefs The "preferences" session. @result The current set; NULL if no current set has been defined. */ -SCNetworkSetRef +SCNetworkSetRef __nullable SCNetworkSetCopyCurrent (SCPreferencesRef prefs) __OSX_AVAILABLE_STARTING(__MAC_10_4,__IPHONE_2_0/*SPI*/); /*! @@ -1180,7 +1183,7 @@ SCNetworkSetCopyCurrent (SCPreferencesRef prefs) __OSX_AVAILABLE_STARTING(_ @result The list of SCNetworkService services associated with the set. You must release the returned value. */ -CFArrayRef /* of SCNetworkServiceRef's */ +CFArrayRef /* of SCNetworkServiceRef's */ __nullable SCNetworkSetCopyServices (SCNetworkSetRef set) __OSX_AVAILABLE_STARTING(__MAC_10_4,__IPHONE_2_0/*SPI*/); /*! @@ -1190,7 +1193,7 @@ SCNetworkSetCopyServices (SCNetworkSetRef set) __OSX_AVAILABLE_STARTING(__MA @result A reference to the new SCNetworkSet. You must release the returned value. */ -SCNetworkSetRef +SCNetworkSetRef __nullable SCNetworkSetCreate (SCPreferencesRef prefs) __OSX_AVAILABLE_STARTING(__MAC_10_4,__IPHONE_2_0/*SPI*/); /*! @@ -1203,7 +1206,7 @@ SCNetworkSetCreate (SCPreferencesRef prefs) __OSX_AVAILABLE_STARTING(__MAC_ error was encountered. You must release the returned value. */ -SCNetworkSetRef +SCNetworkSetRef __nullable SCNetworkSetCopy (SCPreferencesRef prefs, CFStringRef setID) __OSX_AVAILABLE_STARTING(__MAC_10_4,__IPHONE_2_0/*SPI*/); @@ -1213,7 +1216,7 @@ SCNetworkSetCopy (SCPreferencesRef prefs, @param set The network set. @result The [user specified] name. */ -CFStringRef +CFStringRef __nullable SCNetworkSetGetName (SCNetworkSetRef set) __OSX_AVAILABLE_STARTING(__MAC_10_4,__IPHONE_2_0/*SPI*/); /*! @@ -1222,7 +1225,7 @@ SCNetworkSetGetName (SCNetworkSetRef set) __OSX_AVAILABLE_STARTING(__MAC_10 @param set The network set. @result The set identifier. */ -CFStringRef +CFStringRef __nullable SCNetworkSetGetSetID (SCNetworkSetRef set) __OSX_AVAILABLE_STARTING(__MAC_10_4,__IPHONE_2_0/*SPI*/); /*! @@ -1235,7 +1238,7 @@ SCNetworkSetGetSetID (SCNetworkSetRef set) __OSX_AVAILABLE_STARTING(__MAC_1 NULL if no service order has been specified or if an error was encountered. */ -CFArrayRef /* of serviceID CFStringRef's */ +CFArrayRef /* of serviceID CFStringRef's */ __nullable SCNetworkSetGetServiceOrder (SCNetworkSetRef set) __OSX_AVAILABLE_STARTING(__MAC_10_4,__IPHONE_2_0/*SPI*/); /*! @@ -1298,5 +1301,8 @@ SCNetworkSetSetServiceOrder (SCNetworkSetRef set, __END_DECLS +CF_ASSUME_NONNULL_END +CF_IMPLICIT_BRIDGING_DISABLED + #endif /* USE_SYSTEMCONFIGURATION_PRIVATE_HEADERS */ #endif /* _SCNETWORKCONFIGURATION_H */ diff --git a/SystemConfiguration.fproj/SCNetworkConfigurationInternal.c b/SystemConfiguration.fproj/SCNetworkConfigurationInternal.c index 3b215c1..3da8a10 100644 --- a/SystemConfiguration.fproj/SCNetworkConfigurationInternal.c +++ b/SystemConfiguration.fproj/SCNetworkConfigurationInternal.c @@ -1,15 +1,15 @@ /* - * Copyright (c) 2004-2007, 2009, 2010, 2012, 2013 Apple Inc. All rights reserved. + * Copyright (c) 2004-2007, 2009, 2010-2013, 2015 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ - * + * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. - * + * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, @@ -17,7 +17,7 @@ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. - * + * * @APPLE_LICENSE_HEADER_END@ */ @@ -190,12 +190,20 @@ __setPrefsEnabled(SCPreferencesRef prefs, return ok; } +#if !TARGET_OS_EMBEDDED +#define SYSTEMCONFIGURATION_RESOURCES_PATH SYSTEMCONFIGURATION_FRAMEWORK_PATH "/Resources" +#else +#define SYSTEMCONFIGURATION_RESOURCES_PATH SYSTEMCONFIGURATION_FRAMEWORK_PATH +#endif // !TARGET_OS_EMBEDDED + +#define NETWORKCONFIGURATION_RESOURCE_FILE "NetworkConfiguration.plist" static CFDictionaryRef __copyTemplates() { CFBundleRef bundle; CFErrorRef error = NULL; + SInt32 errorCode; Boolean ok; CFDictionaryRef templates; CFURLRef url; @@ -208,15 +216,29 @@ __copyTemplates() url = CFBundleCopyResourceURL(bundle, CFSTR("NetworkConfiguration"), CFSTR("plist"), NULL); if (url == NULL) { - return NULL; + SC_log(LOG_ERR, "failed to GET resource URL to \"%s\". Trying harder...", NETWORKCONFIGURATION_RESOURCE_FILE); + url = CFURLCreateWithFileSystemPath(NULL, + CFSTR(SYSTEMCONFIGURATION_RESOURCES_PATH + "/" + NETWORKCONFIGURATION_RESOURCE_FILE), + kCFURLPOSIXPathStyle, + TRUE); + + if (url == NULL) { + SC_log(LOG_ERR, "failed to CREATE resource URL to \"%s\"", SYSTEMCONFIGURATION_RESOURCES_PATH + "/" + NETWORKCONFIGURATION_RESOURCE_FILE); + return NULL; + } } #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wdeprecated" - ok = CFURLCreateDataAndPropertiesFromResource(NULL, url, &xmlTemplates, NULL, NULL, NULL); + ok = CFURLCreateDataAndPropertiesFromResource(NULL, url, &xmlTemplates, NULL, NULL, &errorCode); #pragma GCC diagnostic pop CFRelease(url); if (!ok || (xmlTemplates == NULL)) { + SC_log(LOG_NOTICE, "%s: failed to create data properties from resource (error=%ld)", __FUNCTION__ , (long)errorCode); return NULL; } @@ -225,7 +247,7 @@ __copyTemplates() CFRelease(xmlTemplates); if (templates == NULL) { if (error != NULL) { - SCLog(TRUE, LOG_DEBUG, CFSTR("could not load SCNetworkConfiguration templates: %@"), error); + SC_log(LOG_NOTICE, "could not load SCNetworkConfiguration templates: %@", error); CFRelease(error); } return NULL; @@ -357,11 +379,9 @@ __createInterface(int s, CFStringRef interface) kCFStringEncodingASCII); if (ioctl(s, SIOCIFCREATE, &ifr) == -1) { - SCLog(TRUE, - LOG_ERR, - CFSTR("could not create interface \"%@\": %s"), - interface, - strerror(errno)); + SC_log(LOG_NOTICE, "could not create interface \"%@\": %s", + interface, + strerror(errno)); return FALSE; } @@ -381,11 +401,9 @@ __destroyInterface(int s, CFStringRef interface) kCFStringEncodingASCII); if (ioctl(s, SIOCIFDESTROY, &ifr) == -1) { - SCLog(TRUE, - LOG_ERR, - CFSTR("could not destroy interface \"%@\": %s"), - interface, - strerror(errno)); + SC_log(LOG_NOTICE, "could not destroy interface \"%@\": %s", + interface, + strerror(errno)); return FALSE; } diff --git a/SystemConfiguration.fproj/SCNetworkConfigurationInternal.h b/SystemConfiguration.fproj/SCNetworkConfigurationInternal.h index 6562c21..7ea2b7b 100644 --- a/SystemConfiguration.fproj/SCNetworkConfigurationInternal.h +++ b/SystemConfiguration.fproj/SCNetworkConfigurationInternal.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004-2014 Apple Inc. All rights reserved. + * Copyright (c) 2004-2015 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -455,6 +455,12 @@ __SCNetworkServiceMigrateNew (SCPreferencesRef prefs, CFDictionaryRef setMapping, CFDictionaryRef serviceSetMapping); +void +__SCNetworkServiceAddProtocolToService (SCNetworkServiceRef service, + CFStringRef protocolType, + CFDictionaryRef configuration, + Boolean enabled); + #pragma mark - #pragma mark SCNetworkSet configuration (internal) diff --git a/SystemConfiguration.fproj/SCNetworkConfigurationPrivate.h b/SystemConfiguration.fproj/SCNetworkConfigurationPrivate.h index 8d017e9..73cc02e 100644 --- a/SystemConfiguration.fproj/SCNetworkConfigurationPrivate.h +++ b/SystemConfiguration.fproj/SCNetworkConfigurationPrivate.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005-2014 Apple Inc. All rights reserved. + * Copyright (c) 2005-2015 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -711,6 +711,14 @@ SCNetworkInterfaceSetPassword (SCNetworkInterfaceRef interface, CFDictionaryRef options) __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0); +Boolean +SCNetworkInterfaceGetDisableUntilNeeded (SCNetworkInterfaceRef interface) __OSX_AVAILABLE_STARTING(__MAC_10_11,__IPHONE_9_0); + +Boolean +SCNetworkInterfaceSetDisableUntilNeeded (SCNetworkInterfaceRef interface, + Boolean disable) __OSX_AVAILABLE_STARTING(__MAC_10_11,__IPHONE_9_0); + + #pragma mark - #pragma mark SCNetworkProtocol configuration (SPI) @@ -1096,6 +1104,21 @@ _SCNetworkConfigurationCheckValidity(CFURLRef configDir, CFDictionaryRef options) __OSX_AVAILABLE_STARTING(__MAC_10_10,__IPHONE_8_0); +/*! + @function _SCNetworkConfigurationCheckValidityWithPreferences + @discussion Validates the specified preferences.plist against NetworkInterfaces.plist + @param prefs the preferences ref pointing to the said preferences.plist + @param ni_prefs the preferences ref pointing to the said NetworkInterfaces.plist + @result TRUE if the configurations are valid against each other + + */ + +Boolean +_SCNetworkConfigurationCheckValidityWithPreferences (SCPreferencesRef prefs, + SCPreferencesRef ni_prefs, + CFDictionaryRef options) __OSX_AVAILABLE_STARTING(__MAC_10_11, __IPHONE_9_0); + + /*! @function _SCNetworkMigrationAreConfigurationsIdentical @discussion Compares the migration output between network configurations diff --git a/SystemConfiguration.fproj/SCNetworkConnection.c b/SystemConfiguration.fproj/SCNetworkConnection.c index 991457f..061236f 100644 --- a/SystemConfiguration.fproj/SCNetworkConnection.c +++ b/SystemConfiguration.fproj/SCNetworkConnection.c @@ -1,15 +1,15 @@ /* - * Copyright (c) 2003-2014 Apple Inc. All rights reserved. + * Copyright (c) 2003-2015 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ - * + * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. - * + * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, @@ -17,7 +17,7 @@ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. - * + * * @APPLE_LICENSE_HEADER_END@ */ @@ -380,49 +380,59 @@ __SCNetworkConnectionQueue() static void -__SCNetworkConnectionCallBackRunLoopPerform(SCNetworkConnectionRef connection, - CFRunLoopRef rl, - CFStringRef rl_mode, - SCNetworkConnectionCallBack rlsFunction, - void (*context_release)(const void *), - void *context_info) +__SCNetworkConnectionNotify(SCNetworkConnectionRef connection, + SCNetworkConnectionCallBack rlsFunction, + SCNetworkConnectionStatus nc_status, + void (*context_release)(const void *), + void *context_info) +{ + os_activity_t activity_id; + + activity_id = os_activity_start("processing SCNetworkConnection notification", + OS_ACTIVITY_FLAG_DEFAULT); + (*rlsFunction)(connection, nc_status, context_info); + if ((context_release != NULL) && (context_info != NULL)) { + (*context_release)(context_info); + } + os_activity_end(activity_id); + + return; +} + + +static void +__SCNetworkConnectionCallBackRunLoopPerform(SCNetworkConnectionRef connection, + CFRunLoopRef rl, + CFStringRef rl_mode, + SCNetworkConnectionCallBack rlsFunction, + void (*context_release)(const void *), + void *context_info) { - SCNetworkConnectionStatus nc_status = kSCNetworkConnectionInvalid; + SCNetworkConnectionStatus nc_status; nc_status = SCNetworkConnectionGetStatus(connection); - CFRunLoopPerformBlock(rl, rl_mode, - ^{ - (*rlsFunction)(connection, nc_status, context_info); - if ((context_release != NULL) && (context_info != NULL)) { - (*context_release)(context_info); - } - CFRelease(rl); - CFRelease(rl_mode); - CFRelease(connection); - }); + CFRunLoopPerformBlock(rl, rl_mode, ^{ + __SCNetworkConnectionNotify(connection, rlsFunction, nc_status, context_release, context_info); + CFRelease(connection); + }); CFRunLoopWakeUp(rl); return; } static void -__SCNetworkConnectionCallBackDispatchPerform(SCNetworkConnectionRef connection, - dispatch_queue_t q, - SCNetworkConnectionCallBack rlsFunction, - void (*context_release)(const void *), - void *context_info) +__SCNetworkConnectionCallBackDispatchPerform(SCNetworkConnectionRef connection, + dispatch_queue_t q, + SCNetworkConnectionCallBack rlsFunction, + void (*context_release)(const void *), + void *context_info) { - SCNetworkConnectionStatus nc_status = kSCNetworkConnectionInvalid; + SCNetworkConnectionStatus nc_status; nc_status = SCNetworkConnectionGetStatus(connection); - dispatch_async(q, - ^{ - (*rlsFunction)(connection, nc_status, context_info); - if ((context_release != NULL) && (context_info != NULL)) { - (*context_release)(context_info); - } - dispatch_release(q); - CFRelease(connection); - }); + dispatch_async(q, ^{ + __SCNetworkConnectionNotify(connection, rlsFunction, nc_status, context_release, context_info); + CFRelease(connection); + }); return; } @@ -467,10 +477,7 @@ __SCNetworkConnectionCallBack(void *connection) pthread_mutex_unlock(&connectionPrivate->lock); nc_status = SCNetworkConnectionGetStatus(connection); - (*rlsFunction)(connection, nc_status, context_info); - if ((context_release != NULL) && (context_info != NULL)) { - (*context_release)(context_info); - } + __SCNetworkConnectionNotify(connection, rlsFunction, nc_status, context_release, context_info); CFRelease(connection); /* This releases the reference that we took in the NESessionEventStatusChanged event handler */ return; } @@ -496,10 +503,7 @@ __SCNetworkConnectionCallBack(void *connection) if (!exec_async) { nc_status = SCNetworkConnectionGetStatus(connection); - (*rlsFunction)(connection, nc_status, context_info); - if ((context_release != NULL) && (context_info != NULL)) { - (*context_release)(context_info); - } + __SCNetworkConnectionNotify(connection, rlsFunction, nc_status, context_release, context_info); CFRelease(connection); return; } @@ -508,11 +512,12 @@ __SCNetworkConnectionCallBack(void *connection) assert(q != NULL); dispatch_retain(q); dispatch_async(__SCNetworkConnectionQueue(), ^{ - __SCNetworkConnectionCallBackDispatchPerform(connection, - q, - rlsFunction, - context_release, - context_info); + __SCNetworkConnectionCallBackDispatchPerform(connection, + q, + rlsFunction, + context_release, + context_info); + dispatch_release(q); }); } else { assert(rl != NULL); @@ -525,6 +530,8 @@ __SCNetworkConnectionCallBack(void *connection) rlsFunction, context_release, context_info); + CFRelease(rl); + CFRelease(rl_mode); }); } @@ -541,11 +548,13 @@ __SCNetworkConnectionMachCallBack(CFMachPortRef port, void * msg, CFIndex size, if (msgid == MACH_NOTIFY_NO_SENDERS) { // re-establish notification - SCLog(_sc_verbose, LOG_DEBUG, CFSTR("__SCNetworkConnectionMachCallBack: PPPController server died")); + SC_log(LOG_INFO, "PPPController server died"); (void)__SCNetworkConnectionReconnectNotifications(connection); } __SCNetworkConnectionCallBack(info); + + return; } @@ -630,7 +639,9 @@ __SCNetworkConnectionCreatePrivate(CFAllocatorRef allocator, } if (connectionPrivate->ne_session == NULL) { - SCLog(TRUE, LOG_ERR, CFSTR("SCNetworkConnection failed to create an ne_session: service ID %@ is not a valid UUID"), serviceID); + SC_log(LOG_NOTICE, + "SCNetworkConnection failed to create an ne_session: service ID %@ is not a valid UUID", + serviceID); goto fail; } } @@ -678,9 +689,8 @@ __SCNetworkConnectionServerPort(kern_return_t *status) break; default : #ifdef DEBUG - SCLog(_sc_verbose, LOG_DEBUG, - CFSTR("SCNetworkConnection bootstrap_look_up() failed: status=%s"), - bootstrap_strerror(*status)); + SC_log(LOG_DEBUG, "bootstrap_look_up() failed: status=%s", + bootstrap_strerror(*status)); #endif // DEBUG break; } @@ -778,7 +788,7 @@ __SCNetworkConnectionSessionPort(SCNetworkConnectionPrivateRef connectionPrivate // allocate port (for server response) status = mach_port_allocate(mach_task_self(), MACH_PORT_RIGHT_RECEIVE, ¬ify_port); if (status != KERN_SUCCESS) { - SCLog(TRUE, LOG_ERR, CFSTR("__SCNetworkConnectionSessionPort mach_port_allocate(): %s"), mach_error_string(status)); + SC_log(LOG_ERR, "mach_port_allocate() failed: %s", mach_error_string(status)); sc_status = status; goto done; } @@ -789,7 +799,7 @@ __SCNetworkConnectionSessionPort(SCNetworkConnectionPrivateRef connectionPrivate notify_port, MACH_MSG_TYPE_MAKE_SEND); if (status != KERN_SUCCESS) { - SCLog(TRUE, LOG_ERR, CFSTR("__SCNetworkConnectionSessionPort mach_port_insert_right(): %s"), mach_error_string(status)); + SC_log(LOG_NOTICE, "mach_port_insert_right() failed: %s", mach_error_string(status)); mach_port_mod_refs(mach_task_self(), notify_port, MACH_PORT_RIGHT_RECEIVE, -1); sc_status = status; goto done; @@ -847,10 +857,9 @@ __SCNetworkConnectionSessionPort(SCNetworkConnectionPrivateRef connectionPrivate #endif // HAVE_PPPCONTROLLER_ATTACHWITHPROXY if (status == KERN_SUCCESS) { if (sc_status != kSCStatusOK) { - SCLog(TRUE, LOG_DEBUG, - CFSTR("__SCNetworkConnectionSessionPort : attach w/error, sc_status=%s%s"), - SCErrorString(sc_status), - (connectionPrivate->session_port != MACH_PORT_NULL) ? ", w/session_port!=MACH_PORT_NULL" : ""); + SC_log(LOG_DEBUG, "attach w/error, sc_status=%s%s", + SCErrorString(sc_status), + (connectionPrivate->session_port != MACH_PORT_NULL) ? ", w/session_port!=MACH_PORT_NULL" : ""); if (connectionPrivate->session_port != MACH_PORT_NULL) { __MACH_PORT_DEBUG(TRUE, @@ -872,7 +881,7 @@ __SCNetworkConnectionSessionPort(SCNetworkConnectionPrivateRef connectionPrivate } // our [cached] server port is not valid - SCLog(TRUE, LOG_DEBUG, CFSTR("__SCNetworkConnectionSessionPort : !attach: %s"), SCErrorString(status)); + SC_log(LOG_INFO, "!attach: %s", SCErrorString(status)); if (status == MACH_SEND_INVALID_DEST) { // the server is not yet available __MACH_PORT_DEBUG(TRUE, "*** __SCNetworkConnectionSessionPort notify_port (!dest)", notify_port); @@ -934,14 +943,14 @@ __SCNetworkConnectionSessionPort(SCNetworkConnectionPrivateRef connectionPrivate MACH_MSG_TYPE_MAKE_SEND_ONCE, &oldNotify); if (status != KERN_SUCCESS) { - SCLog(TRUE, LOG_ERR, CFSTR("__SCNetworkConnectionSessionPort mach_port_request_notification(): %s"), mach_error_string(status)); + SC_log(LOG_NOTICE, "mach_port_request_notification() failed: %s", mach_error_string(status)); mach_port_mod_refs(mach_task_self(), notify_port, MACH_PORT_RIGHT_RECEIVE, -1); sc_status = status; goto done; } if (oldNotify != MACH_PORT_NULL) { - SCLog(TRUE, LOG_ERR, CFSTR("__SCNetworkConnectionSessionPort(): oldNotify != MACH_PORT_NULL")); + SC_log(LOG_NOTICE, "oldNotify != MACH_PORT_NULL"); } // create CFMachPort for SCNetworkConnection notification callback @@ -985,14 +994,10 @@ __SCNetworkConnectionSessionPort(SCNetworkConnectionPrivateRef connectionPrivate notify_port); break; case BOOTSTRAP_UNKNOWN_SERVICE : - SCLog(TRUE, - (status == KERN_SUCCESS) ? LOG_DEBUG : LOG_ERR, - CFSTR("PPPController not available")); + SC_log((status == KERN_SUCCESS) ? LOG_NOTICE : LOG_ERR, "PPPController not available"); break; default : - SCLog(TRUE, - (status == KERN_SUCCESS) ? LOG_DEBUG : LOG_ERR, - CFSTR("__SCNetworkConnectionSessionPort pppcontroller_attach(): %s"), + SC_log((status == KERN_SUCCESS) ? LOG_NOTICE : LOG_ERR, "pppcontroller_attach() failed: %s", SCErrorString(sc_status)); break; } @@ -1083,18 +1088,18 @@ __SCNetworkConnectionReconnectNotifications(SCNetworkConnectionRef connection) ok = SCNetworkConnectionScheduleWithRunLoop(connection, rl, rlMode); if (!ok) { - SCLog((SCError() != BOOTSTRAP_UNKNOWN_SERVICE), - LOG_ERR, - CFSTR("__SCNetworkConnectionReconnectNotifications: SCNetworkConnectionScheduleWithRunLoop() failed")); + if (SCError() != BOOTSTRAP_UNKNOWN_SERVICE) { + SC_log(LOG_NOTICE, "SCNetworkConnectionScheduleWithRunLoop() failed"); + } goto done; } } } else if (dispatchQueue != NULL) { ok = SCNetworkConnectionSetDispatchQueue(connection, dispatchQueue); if (!ok) { - SCLog((SCError() != BOOTSTRAP_UNKNOWN_SERVICE), - LOG_ERR, - CFSTR("__SCNetworkConnectionReconnectNotifications: SCNetworkConnectionSetDispatchQueue() failed")); + if (SCError() != BOOTSTRAP_UNKNOWN_SERVICE) { + SC_log(LOG_NOTICE, "SCNetworkConnectionSetDispatchQueue() failed"); + } goto done; } } else { @@ -1112,9 +1117,8 @@ __SCNetworkConnectionReconnectNotifications(SCNetworkConnectionRef connection) } if (!ok) { - SCLog(TRUE, LOG_ERR, - CFSTR("SCNetworkConnection server %s, notification not restored"), - (SCError() == BOOTSTRAP_UNKNOWN_SERVICE) ? "shutdown" : "failed"); + SC_log(LOG_NOTICE, "SCNetworkConnection server %s, notification not restored", + (SCError() == BOOTSTRAP_UNKNOWN_SERVICE) ? "shutdown" : "failed"); } return ok; @@ -1138,7 +1142,7 @@ __SCNetworkConnectionNeedsRetry(SCNetworkConnectionRef connection, (void) mach_port_deallocate(mach_task_self(), connectionPrivate->session_port); } else { // we got an unexpected error, leave the [session] port alone - SCLog(TRUE, LOG_ERR, CFSTR("%s: %s"), error_label, mach_error_string(status)); + SC_log(LOG_NOTICE, "%s: %s", error_label, mach_error_string(status)); } connectionPrivate->session_port = MACH_PORT_NULL; if ((status == MACH_SEND_INVALID_DEST) || (status == MIG_SERVER_DIED)) { @@ -1760,7 +1764,7 @@ SCNetworkConnectionStart(SCNetworkConnectionRef connection, if (debug > 0) { CFMutableDictionaryRef mdict = NULL; - SCLog(TRUE, LOG_DEBUG, CFSTR("SCNetworkConnectionStart (%p)"), connectionPrivate); + SC_log(LOG_INFO, "SCNetworkConnectionStart (%p)", connectionPrivate); if (userOptions != NULL) { CFDictionaryRef dict; @@ -1807,7 +1811,7 @@ SCNetworkConnectionStart(SCNetworkConnectionRef connection, } } - SCLog(TRUE, LOG_DEBUG, CFSTR("User options: %@"), mdict); + SC_log(LOG_INFO, "User options: %@", mdict); if (mdict != NULL) CFRelease(mdict); } @@ -1848,6 +1852,9 @@ SCNetworkConnectionStart(SCNetworkConnectionRef connection, ne_session_start_with_options(connectionPrivate->ne_session, xuser_options); } + /* make sure the xpc_message goes through */ + ne_session_send_barrier(connectionPrivate->ne_session); + if (xuser_options != NULL) { xpc_release(xuser_options); } @@ -1884,7 +1891,7 @@ SCNetworkConnectionStart(SCNetworkConnectionRef connection, if (dataref) CFRelease(dataref); if (debug > 0) { - SCLog(TRUE, LOG_DEBUG, CFSTR("SCNetworkConnectionStart (%p), return: %d"), connectionPrivate, sc_status); + SC_log(LOG_INFO, "SCNetworkConnectionStart (%p), return: %d", connectionPrivate, sc_status); } if (sc_status != kSCStatusOK) { @@ -1917,7 +1924,7 @@ SCNetworkConnectionStop(SCNetworkConnectionRef connection, } if (debug > 0) { - SCLog(TRUE, LOG_DEBUG, CFSTR("SCNetworkConnectionStop (%p)"), connectionPrivate); + SC_log(LOG_INFO, "SCNetworkConnectionStop (%p)", connectionPrivate); } pthread_mutex_lock(&connectionPrivate->lock); @@ -1925,6 +1932,8 @@ SCNetworkConnectionStop(SCNetworkConnectionRef connection, #if !TARGET_IPHONE_SIMULATOR if (__SCNetworkConnectionUsingNetworkExtension(connectionPrivate)) { ne_session_stop(connectionPrivate->ne_session); + /* make sure the xpc_message goes through */ + ne_session_send_barrier(connectionPrivate->ne_session); ok = TRUE; goto done; } @@ -1946,7 +1955,7 @@ SCNetworkConnectionStop(SCNetworkConnectionRef connection, } if (debug > 0) { - SCLog(TRUE, LOG_DEBUG, CFSTR("SCNetworkConnectionStop (%p), return: %d"), connectionPrivate, sc_status); + SC_log(LOG_INFO, "SCNetworkConnectionStop (%p), return: %d", connectionPrivate, sc_status); } if (sc_status != kSCStatusOK) { @@ -1979,7 +1988,7 @@ SCNetworkConnectionSuspend(SCNetworkConnectionRef connection) } if (debug > 0) { - SCLog(TRUE, LOG_DEBUG, CFSTR("SCNetworkConnectionSuspend (%p)"), connectionPrivate); + SC_log(LOG_INFO, "SCNetworkConnectionSuspend (%p)", connectionPrivate); } pthread_mutex_lock(&connectionPrivate->lock); @@ -2008,7 +2017,7 @@ SCNetworkConnectionSuspend(SCNetworkConnectionRef connection) } if (debug > 0) { - SCLog(TRUE, LOG_DEBUG, CFSTR("SCNetworkConnectionSuspend (%p), return: %d"), connectionPrivate, sc_status); + SC_log(LOG_INFO, "SCNetworkConnectionSuspend (%p), return: %d", connectionPrivate, sc_status); } if (sc_status != kSCStatusOK) { @@ -2041,7 +2050,7 @@ SCNetworkConnectionResume(SCNetworkConnectionRef connection) } if (debug > 0) { - SCLog(TRUE, LOG_DEBUG, CFSTR("SCNetworkConnectionResume (%p)"), connectionPrivate); + SC_log(LOG_INFO, "SCNetworkConnectionResume (%p)", connectionPrivate); } pthread_mutex_lock(&connectionPrivate->lock); @@ -2070,7 +2079,7 @@ SCNetworkConnectionResume(SCNetworkConnectionRef connection) } if (debug > 0) { - SCLog(TRUE, LOG_DEBUG, CFSTR("SCNetworkConnectionResume (%p), return: %d"), connectionPrivate, sc_status); + SC_log(LOG_INFO, "SCNetworkConnectionResume (%p), return: %d", connectionPrivate, sc_status); } if (sc_status != kSCStatusOK) { @@ -2105,7 +2114,7 @@ SCNetworkConnectionRefreshOnDemandState(SCNetworkConnectionRef connection) } if (debug > 0) { - SCLog(TRUE, LOG_DEBUG, CFSTR("SCNetworkConnectionRefreshOnDemandState (%p)"), connectionPrivate); + SC_log(LOG_INFO, "SCNetworkConnectionRefreshOnDemandState (%p)", connectionPrivate); } pthread_mutex_lock(&connectionPrivate->lock); @@ -2133,10 +2142,10 @@ SCNetworkConnectionRefreshOnDemandState(SCNetworkConnectionRef connection) if (status == MACH_SEND_INVALID_DEST) { // the server is not yet available - SCLog(TRUE, LOG_ERR, CFSTR("SCNetworkConnectionRefreshOnDemandState (!dest) (%p)"), connectionPrivate); + SC_log(LOG_NOTICE, "SCNetworkConnectionRefreshOnDemandState (!dest) (%p)", connectionPrivate); } else if (status == MIG_SERVER_DIED) { // the server we were using is gone - SCLog(TRUE, LOG_ERR, CFSTR("SCNetworkConnectionRefreshOnDemandState (!mig) (%p)"), connectionPrivate); + SC_log(LOG_NOTICE, "SCNetworkConnectionRefreshOnDemandState (!mig) (%p)", connectionPrivate); } else { // if we got an unexpected error, don't retry sc_status = status; @@ -2145,7 +2154,7 @@ SCNetworkConnectionRefreshOnDemandState(SCNetworkConnectionRef connection) } if (debug > 0) { - SCLog(TRUE, LOG_DEBUG, CFSTR("SCNetworkConnectionRefreshOnDemandState (%p), return: %d/%d"), connectionPrivate, status, sc_status); + SC_log(LOG_INFO, "SCNetworkConnectionRefreshOnDemandState (%p), return: %d/%d", connectionPrivate, status, sc_status); } if (sc_status != kSCStatusOK) { @@ -2361,7 +2370,7 @@ __SCNetworkConnectionScheduleWithRunLoop(SCNetworkConnectionRef connection, mp = CFMachPortGetPort(connectionPrivate->notify_port); source = dispatch_source_create(DISPATCH_SOURCE_TYPE_MACH_RECV, mp, 0, queue); if (source == NULL) { - SCLog(TRUE, LOG_ERR, CFSTR("SCNetworkConnection dispatch_source_create() failed")); + SC_log(LOG_NOTICE, "dispatch_source_create() failed"); _SCErrorSet(kSCStatusFailed); goto done; } @@ -2391,9 +2400,7 @@ __SCNetworkConnectionScheduleWithRunLoop(SCNetworkConnectionRef connection, MACH_MSG_TIMEOUT_NONE, // timeout MACH_PORT_NULL); // notify if (kr != KERN_SUCCESS) { - SCLog(TRUE, LOG_ERR, - CFSTR("SCDynamicStore notification handler, kr=0x%x"), - kr); + SC_log(LOG_NOTICE, "SCDynamicStore notification handler, kr=0x%x", kr); return; } @@ -2441,7 +2448,9 @@ __SCNetworkConnectionScheduleWithRunLoop(SCNetworkConnectionRef connection, CFRunLoopSourceSignal(connectionPrivate->rls); _SC_signalRunLoop(connection, connectionPrivate->rls, connectionPrivate->rlList); } else if (connectionPrivate->dispatchQueue != NULL) { - dispatch_async(connectionPrivate->dispatchQueue, ^{ __SCNetworkConnectionCallBack((void *)connection); }); + dispatch_async(connectionPrivate->dispatchQueue, ^{ + __SCNetworkConnectionCallBack((void *)connection); + }); } pthread_mutex_unlock(&connectionPrivate->lock); } else if (event == NESessionEventCanceled) { @@ -2675,26 +2684,26 @@ SCNetworkConnectionTriggerOnDemandIfNeeded (CFStringRef hostName, CFIndex hostnameSize = 0; pid_t pid = getpid(); uid_t uid = geteuid(); - + /* Require hostName, require non-root user */ if (hostName == NULL || geteuid() == 0) { goto done; } - + hostnameSize = CFStringGetLength(hostName); if (hostnameSize == 0) { goto done; } - + hostname = malloc(hostnameSize + 1); CFStringGetCString(hostName, hostname, hostnameSize + 1, kCFStringEncodingUTF8); - + if (proc_pidinfo(pid, PROC_PIDUNIQIDENTIFIERINFO, 1, &procu, sizeof(procu)) != sizeof(procu)) { goto done; } - + policy_match = ne_session_copy_policy_match(hostname, NULL, NULL, procu.p_uuid, procu.p_uuid, pid, uid, 0, trafficClass); - + NEPolicyServiceActionType action_type = ne_session_policy_match_get_service_action(policy_match); if (action_type == NESessionPolicyActionTrigger || (afterDNSFail && action_type == NESessionPolicyActionTriggerIfNeeded)) { @@ -2704,7 +2713,7 @@ SCNetworkConnectionTriggerOnDemandIfNeeded (CFStringRef hostName, if (start_options != NULL) { xpc_dictionary_set_bool(start_options, NESessionStartOptionIsOnDemandKey, true); xpc_dictionary_set_string(start_options, NESessionStartOptionMatchHostnameKey, hostname); - + ne_session_t new_session = ne_session_create(config_id, ne_session_policy_match_get_service_type(policy_match)); if (new_session != NULL) { dispatch_semaphore_t wait_for_session = dispatch_semaphore_create(0); @@ -2716,6 +2725,11 @@ SCNetworkConnectionTriggerOnDemandIfNeeded (CFStringRef hostName, dispatch_retain(wait_for_session); ne_session_set_event_handler(new_session, __SCNetworkConnectionQueue(), ^(ne_session_event_t event, void *event_data) { + os_activity_t activity_id; + + activity_id = os_activity_start("processing ne_session notification", + OS_ACTIVITY_FLAG_DEFAULT); + if (event == NESessionEventStatusChanged) { dispatch_retain(wait_for_session); ne_session_get_status(new_session, __SCNetworkConnectionQueue(), @@ -2732,6 +2746,8 @@ SCNetworkConnectionTriggerOnDemandIfNeeded (CFStringRef hostName, dispatch_semaphore_signal(wait_for_session); dispatch_release(wait_for_session); } + + os_activity_end(activity_id); }); ne_session_start_with_options(new_session, start_options); } else { @@ -2744,7 +2760,7 @@ SCNetworkConnectionTriggerOnDemandIfNeeded (CFStringRef hostName, dispatch_release(wait_for_session); ne_session_release(new_session); } - + xpc_release(start_options); } } @@ -2753,7 +2769,7 @@ done: if (hostname) { free(hostname); } - + if (policy_match) { free(policy_match); } @@ -2885,128 +2901,13 @@ SCNetworkConnectionGetType(SCNetworkConnectionRef connection) } -static Boolean -validate_flow_properties(CFDictionaryRef flowProperties) -{ - CFStringRef host_name_str; - CFDataRef host_address_data; - CFNumberRef host_port_num; - - if (!isA_CFDictionary(flowProperties)) { - return FALSE; - } - - /* Validate the host name if one was given */ - host_name_str = CFDictionaryGetValue(flowProperties, kSCNetworkConnectionFlowPropertyHostName); - if (host_name_str != NULL && (!isA_CFString(host_name_str) || CFStringGetLength(host_name_str) == 0)) { - return FALSE; - } - - /* Validate the address if one was given */ - host_address_data = CFDictionaryGetValue(flowProperties, kSCNetworkConnectionFlowPropertyHostAddress); - if (host_address_data != NULL) { - struct sockaddr *sock_addr; - - if (!isA_CFData(host_address_data) || CFDataGetLength(host_address_data) < sizeof(struct sockaddr)) { - return FALSE; - } - - sock_addr = (struct sockaddr *)CFDataGetBytePtr(host_address_data); - if (CFDataGetLength(host_address_data) < sock_addr->sa_len) { - return FALSE; - } - - if (sock_addr->sa_family == AF_INET) { - if (sock_addr->sa_len >= sizeof(struct sockaddr_in)) { - struct sockaddr_in *sa_in = (struct sockaddr_in *)(void *)sock_addr; - in_addr_t any = { INADDR_ANY }; - if (memcmp(&sa_in->sin_addr, &any, sizeof(any)) == 0) { - return FALSE; - } - } else { - return FALSE; - } - } else if (sock_addr->sa_family == AF_INET6) { - if (sock_addr->sa_len >= sizeof(struct sockaddr_in6)) { - struct sockaddr_in6 *sa_in6 = (struct sockaddr_in6 *)(void *)sock_addr; - struct in6_addr any = IN6ADDR_ANY_INIT; - if (memcmp(&sa_in6->sin6_addr, &any, sizeof(any)) == 0) { - return FALSE; - } - } - } - } - - /* We must have either a host name or an address */ - if (host_name_str == NULL && host_address_data == NULL) { - return FALSE; - } - - /* Validate the port */ - host_port_num = CFDictionaryGetValue(flowProperties, kSCNetworkConnectionFlowPropertyHostPort); - if (host_port_num != NULL) { - int num; - if (!isA_CFNumber(host_port_num) || !CFNumberGetValue(host_port_num, kCFNumberIntType, &num)) { - return FALSE; - } - - if (num == 0) { - return FALSE; - } - } else { - return FALSE; - } - - return TRUE; -} - - CFDataRef SCNetworkConnectionCopyFlowDivertToken(SCNetworkConnectionRef connection, CFDictionaryRef flowProperties) { - CFDictionaryRef app_properties = NULL; - SCNetworkConnectionPrivateRef connectionPrivate = (SCNetworkConnectionPrivateRef)connection; - CFDataRef token = NULL; - - if (!isA_SCNetworkConnection(connection)) { - _SCErrorSet(kSCStatusInvalidArgument); - goto done; - } - - if (connectionPrivate->service == NULL) { - _SCErrorSet(kSCStatusConnectionNoService); - goto done; - } - - if (connectionPrivate->type != kSCNetworkConnectionTypeAppLayerVPN) { - _SCErrorSet(kSCStatusInvalidArgument); - goto done; - } - - if (!validate_flow_properties(flowProperties)) { - _SCErrorSet(kSCStatusInvalidArgument); - goto done; - } - - app_properties = VPNAppLayerCopyCachedAppProperties(connectionPrivate->client_audit_token, - connectionPrivate->client_pid, - connectionPrivate->client_uuid, - connectionPrivate->client_bundle_id); - if (app_properties == NULL) { - SCLog(TRUE, LOG_ERR, CFSTR("SCNetworkConnectionCopyFlowDivertToken: no cached app properties available")); - _SCErrorSet(kSCStatusFailed); - goto done; - } - - token = VPNAppLayerCreateFlowDivertToken(connection, app_properties, flowProperties); - -done: - if (app_properties != NULL) { - CFRelease(app_properties); - } - - return token; +#pragma unused(connection, flowProperties) + _SCErrorSet(kSCStatusFailed); + return NULL; } @@ -3255,7 +3156,7 @@ __SCNetworkConnectionCopyOnDemandConfiguration(void) if (onDemand_notify_token == -1) { status = notify_register_check(kSCNETWORKCONNECTION_ONDEMAND_NOTIFY_KEY, &onDemand_notify_token); if (status != NOTIFY_STATUS_OK) { - SCLog(TRUE, LOG_ERR, CFSTR("notify_register_check() failed, status=%d"), status); + SC_log(LOG_NOTICE, "notify_register_check() failed, status=%d", status); onDemand_notify_token = -1; } } @@ -3263,7 +3164,7 @@ __SCNetworkConnectionCopyOnDemandConfiguration(void) if (onDemand_notify_token != -1) { status = notify_check(onDemand_notify_token, &changed); if (status != NOTIFY_STATUS_OK) { - SCLog(TRUE, LOG_ERR, CFSTR("notify_check() failed, status=%d"), status); + SC_log(LOG_NOTICE, "notify_check() failed, status=%d", status); (void)notify_cancel(onDemand_notify_token); onDemand_notify_token = -1; } @@ -3272,7 +3173,7 @@ __SCNetworkConnectionCopyOnDemandConfiguration(void) if (changed && (onDemand_notify_token != -1)) { status = notify_get_state(onDemand_notify_token, &triggersCount); if (status != NOTIFY_STATUS_OK) { - SCLog(TRUE, LOG_ERR, CFSTR("notify_get_state() failed, status=%d"), status); + SC_log(LOG_NOTICE, "notify_get_state() failed, status=%d", status); (void)notify_cancel(onDemand_notify_token); onDemand_notify_token = -1; } @@ -3281,11 +3182,8 @@ __SCNetworkConnectionCopyOnDemandConfiguration(void) if (changed || onDemand_force_refresh) { CFStringRef key; - if (_sc_debug || (debug > 0)) { - SCLog(TRUE, LOG_INFO, - CFSTR("OnDemand information %s"), - (onDemand_configuration == NULL) ? "fetched" : "updated"); - } + SC_log(LOG_INFO, "OnDemand information %s", + (onDemand_configuration == NULL) ? "fetched" : "updated"); if (onDemand_configuration != NULL) { CFRelease(onDemand_configuration); @@ -3343,9 +3241,7 @@ __SCNetworkConnectionShouldNeverMatch(CFDictionaryRef trigger, CFStringRef hostN exception = CFArrayGetValueAtIndex(exceptions, exceptionsIndex); if (isA_CFString(exception) && _SC_domainEndsWithDomain(hostName, exception)) { // found matching exception - if (_sc_debug || (debug > 0)) { - SCLog(TRUE, LOG_INFO, CFSTR("OnDemand match exception")); - } + SC_log(LOG_INFO, "OnDemand match exception"); return TRUE; } } @@ -3764,8 +3660,8 @@ __SCNetworkConnectionCopyOnDemandInfoWithName(SCDynamicStoreRef *storeP, if ((*connectionServiceID != NULL) && (CFStringGetLength(*connectionServiceID) > 0)) { CFRetain(*connectionServiceID); } else { - SCLog(TRUE, LOG_INFO, CFSTR("OnDemand%s configuration error, no serviceID"), - onDemandRetry ? " (on retry)" : ""); + SC_log(LOG_INFO, "OnDemand%s configuration error, no serviceID", + onDemandRetry ? " (on retry)" : ""); *connectionServiceID = NULL; ok = FALSE; } @@ -3777,8 +3673,8 @@ __SCNetworkConnectionCopyOnDemandInfoWithName(SCDynamicStoreRef *storeP, if ((*vpnRemoteAddress != NULL) && (CFStringGetLength(*vpnRemoteAddress) > 0)) { CFRetain(*vpnRemoteAddress); } else { - SCLog(TRUE, LOG_INFO, CFSTR("OnDemand%s configuration error, no server address"), - onDemandRetry ? " (on retry)" : ""); + SC_log(LOG_INFO, "OnDemand%s configuration error, no server address", + onDemandRetry ? " (on retry)" : ""); *vpnRemoteAddress = NULL; ok = FALSE; } @@ -3795,11 +3691,9 @@ __SCNetworkConnectionCopyOnDemandInfoWithName(SCDynamicStoreRef *storeP, } sc_status = kSCStatusFailed; } else { - if (_sc_debug || (debug > 0)) { - SCLog(TRUE, LOG_INFO, CFSTR("OnDemand%s match, connection status = %d"), - onDemandRetry ? " (on retry)" : "", - onDemandStatus); - } + SC_log(LOG_INFO, "OnDemand%s match, connection status = %d", + onDemandRetry ? " (on retry)" : "", + onDemandStatus); } } @@ -3807,9 +3701,7 @@ __SCNetworkConnectionCopyOnDemandInfoWithName(SCDynamicStoreRef *storeP, CFRelease(trigger); } -// if (_sc_debug || (debug > 0)) { -// SCLog(TRUE, LOG_INFO, CFSTR("OnDemand domain name(s) not matched")); -// } +// SC_log(LOG_INFO, "OnDemand domain name(s) not matched"); if (configuration != NULL) CFRelease(configuration); if (!ok) { @@ -3830,7 +3722,7 @@ __SCNetworkConnectionCopyUserPreferencesInternal(CFDictionaryRef selectionOption if (notify_userprefs_token == -1) { status = notify_register_check(k_NetworkConnect_Notification, ¬ify_userprefs_token); if (status != NOTIFY_STATUS_OK) { - SCLog(TRUE, LOG_ERR, CFSTR("notify_register_check() failed, status=%d"), status); + SC_log(LOG_NOTICE, "notify_register_check() failed, status=%d", status); (void)notify_cancel(notify_userprefs_token); notify_userprefs_token = -1; } else { @@ -3842,7 +3734,7 @@ __SCNetworkConnectionCopyUserPreferencesInternal(CFDictionaryRef selectionOption if (notify_userprefs_token != -1) { status = notify_check(notify_userprefs_token, &prefsChanged); if (status != NOTIFY_STATUS_OK) { - SCLog(TRUE, LOG_ERR, CFSTR("notify_check() failed, status=%d"), status); + SC_log(LOG_NOTICE, "notify_check() failed, status=%d", status); (void)notify_cancel(notify_userprefs_token); notify_userprefs_token = -1; } @@ -4002,8 +3894,8 @@ __SCNetworkConnectionCopyUserPreferencesInternal(CFDictionaryRef selectionOption } if (debug > 1) { - SCLog(TRUE, LOG_DEBUG, CFSTR("SCNetworkConnectionCopyUserPreferences %@"), success ? CFSTR("succeeded") : CFSTR("failed")); - SCLog(TRUE, LOG_DEBUG, CFSTR("Selection options: %@"), selectionOptions); + SC_log(LOG_INFO, "SCNetworkConnectionCopyUserPreferences %s", success ? "succeeded" : "failed"); + SC_log(LOG_INFO, "Selection options: %@", selectionOptions); } return success; @@ -4029,7 +3921,7 @@ __SCNetworkConnectionCopyUserPreferencesInternal(CFDictionaryRef selectionOption addPasswordFromKeychain(*serviceID, userOptions); } } else { - SCLog(TRUE, LOG_DEBUG, CFSTR("Error, userServices are not of type CFArray!")); + SC_log(LOG_INFO, "Error, userServices are not of type CFArray!"); } CFRelease(userServices); // this is OK because SCNetworkConnectionPrivateISExpectedCFType() checks for NULL @@ -4037,7 +3929,8 @@ __SCNetworkConnectionCopyUserPreferencesInternal(CFDictionaryRef selectionOption } if (debug > 1) { - SCLog(TRUE, LOG_DEBUG, CFSTR("SCNetworkConnectionCopyUserPreferences %@, no selection options"), success ? CFSTR("succeeded") : CFSTR("failed")); + SC_log(LOG_INFO, "SCNetworkConnectionCopyUserPreferences %@, no selection options", + success ? CFSTR("succeeded") : CFSTR("failed")); } return success; @@ -4076,10 +3969,9 @@ SCNetworkConnectionCopyUserPreferences(CFDictionaryRef selectionOptions, &connectionStatus, NULL); if (debug > 1) { - SCLog(TRUE, LOG_DEBUG, - CFSTR("SCNetworkConnectionCopyUserPreferences __SCNetworkConnectionCopyOnDemandInfoWithName returns %d w/status %d"), - success, - connectionStatus); + SC_log(LOG_INFO, "__SCNetworkConnectionCopyOnDemandInfoWithName: return %d, status %d", + success, + connectionStatus); } if (success) { @@ -5040,7 +4932,6 @@ __SCNetworkConnectionGetControllerPortName(void) else{ scnc_server_name = PPPCONTROLLER_SERVER; } - SCLog(TRUE, LOG_DEBUG, CFSTR("__SCNetworkConnectionGetControllerPortName() returns port: %s"), scnc_server_name); } #else scnc_server_name = PPPCONTROLLER_SERVER; diff --git a/SystemConfiguration.fproj/SCNetworkConnection.h b/SystemConfiguration.fproj/SCNetworkConnection.h index 38f89f7..83d6602 100644 --- a/SystemConfiguration.fproj/SCNetworkConnection.h +++ b/SystemConfiguration.fproj/SCNetworkConnection.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2006, 2008-2010 Apple Inc. All rights reserved. + * Copyright (c) 2003-2006, 2008-2010, 2015 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -36,6 +36,8 @@ #include #include +CF_IMPLICIT_BRIDGING_ENABLED +CF_ASSUME_NONNULL_BEGIN /*! @header SCNetworkConnection @@ -56,7 +58,7 @@ @typedef SCNetworkConnectionRef @discussion This is the handle to manage a connection-oriented service. */ -typedef const struct __SCNetworkConnection * SCNetworkConnectionRef; +typedef const struct CF_BRIDGED_TYPE(id) __SCNetworkConnection * SCNetworkConnectionRef; /*! @@ -79,10 +81,10 @@ typedef const struct __SCNetworkConnection * SCNetworkConnectionRef; */ typedef struct { CFIndex version; - void * info; - const void *(*retain)(const void *info); - void (*release)(const void *info); - CFStringRef (*copyDescription)(const void *info); + void * __nullable info; + const void * __nonnull (* __nullable retain)(const void *info); + void (* __nullable release)(const void *info); + CFStringRef __nonnull (* __nullable copyDescription)(const void *info); } SCNetworkConnectionContext; @@ -105,14 +107,13 @@ typedef struct { @constant kSCNetworkConnectionDisconnecting The network connection is disconnecting. */ -enum { +typedef CF_ENUM(int32_t, SCNetworkConnectionStatus) { kSCNetworkConnectionInvalid = -1, kSCNetworkConnectionDisconnected = 0, kSCNetworkConnectionConnecting = 1, kSCNetworkConnectionConnected = 2, kSCNetworkConnectionDisconnecting = 3 }; -typedef int32_t SCNetworkConnectionStatus; /*! @@ -159,7 +160,7 @@ typedef int32_t SCNetworkConnectionStatus; @constant kSCNetworkConnectionPPPWaitingForRedial PPP has found a busy server and is waiting for redial. */ -enum { +typedef CF_ENUM(int32_t, SCNetworkConnectionPPPStatus) { kSCNetworkConnectionPPPDisconnected = 0, kSCNetworkConnectionPPPInitializing = 1, kSCNetworkConnectionPPPConnectingLink = 2, @@ -175,8 +176,6 @@ enum { kSCNetworkConnectionPPPSuspended = 12, kSCNetworkConnectionPPPWaitingForRedial = 13 }; -typedef int32_t SCNetworkConnectionPPPStatus; - /*! @typedef SCNetworkConnectionCallBack @@ -187,9 +186,9 @@ typedef int32_t SCNetworkConnectionPPPStatus; @param info Application-specific information. */ typedef void (*SCNetworkConnectionCallBack) ( - SCNetworkConnectionRef connection, - SCNetworkConnectionStatus status, - void *info + SCNetworkConnectionRef connection, + SCNetworkConnectionStatus status, + void * __nullable info ); @@ -255,9 +254,9 @@ SCNetworkConnectionGetTypeID (void) __OSX_AVAILABLE_STARTING(__MAC_10_3,__IP */ Boolean SCNetworkConnectionCopyUserPreferences ( - CFDictionaryRef selectionOptions, - CFStringRef *serviceID, - CFDictionaryRef *userOptions + CFDictionaryRef __nullable selectionOptions, + CFStringRef __nonnull * __nullable serviceID, + CFDictionaryRef __nonnull * __nullable userOptions ) __OSX_AVAILABLE_STARTING(__MAC_10_3,__IPHONE_2_0/*SPI*/); @@ -282,12 +281,12 @@ SCNetworkConnectionCopyUserPreferences ( callout. @result Returns a reference to the new SCNetworkConnection. */ -SCNetworkConnectionRef +SCNetworkConnectionRef __nullable SCNetworkConnectionCreateWithServiceID ( - CFAllocatorRef allocator, - CFStringRef serviceID, - SCNetworkConnectionCallBack callout, - SCNetworkConnectionContext *context + CFAllocatorRef __nullable allocator, + CFStringRef serviceID, + SCNetworkConnectionCallBack __nullable callout, + SCNetworkConnectionContext * __nullable context ) __OSX_AVAILABLE_STARTING(__MAC_10_3,__IPHONE_2_0/*SPI*/); @@ -297,7 +296,7 @@ SCNetworkConnectionCreateWithServiceID ( @param connection The SCNetworkConnection to obtain status from. @result Returns the service ID associated with the SCNetworkConnection. */ -CFStringRef +CFStringRef __nullable SCNetworkConnectionCopyServiceID ( SCNetworkConnectionRef connection ) __OSX_AVAILABLE_STARTING(__MAC_10_3,__IPHONE_2_0/*SPI*/); @@ -368,7 +367,7 @@ SCNetworkConnectionGetStatus ( @result Returns the status dictionary. If NULL is returned, the error can be retrieved using the SCError function. */ -CFDictionaryRef +CFDictionaryRef __nullable SCNetworkConnectionCopyExtendedStatus ( SCNetworkConnectionRef connection ) __OSX_AVAILABLE_STARTING(__MAC_10_3,__IPHONE_2_0/*SPI*/); @@ -410,7 +409,7 @@ SCNetworkConnectionCopyExtendedStatus ( @result Returns the statistics dictionary. If NULL is returned, the error can be retrieved using the SCError function. */ -CFDictionaryRef +CFDictionaryRef __nullable SCNetworkConnectionCopyStatistics ( SCNetworkConnectionRef connection ) __OSX_AVAILABLE_STARTING(__MAC_10_3,__IPHONE_2_0/*SPI*/); @@ -462,9 +461,9 @@ SCNetworkConnectionCopyStatistics ( */ Boolean SCNetworkConnectionStart ( - SCNetworkConnectionRef connection, - CFDictionaryRef userOptions, - Boolean linger + SCNetworkConnectionRef connection, + CFDictionaryRef __nullable userOptions, + Boolean linger ) __OSX_AVAILABLE_STARTING(__MAC_10_3,__IPHONE_2_0/*SPI*/); @@ -504,7 +503,7 @@ SCNetworkConnectionStop ( The dictionary can be empty if no user options were used. If NULL is returned, the error can be retrieved using the SCError function. */ -CFDictionaryRef +CFDictionaryRef __nullable SCNetworkConnectionCopyUserOptions ( SCNetworkConnectionRef connection ) __OSX_AVAILABLE_STARTING(__MAC_10_3,__IPHONE_2_0/*SPI*/); @@ -558,11 +557,14 @@ SCNetworkConnectionUnscheduleFromRunLoop ( */ Boolean SCNetworkConnectionSetDispatchQueue ( - SCNetworkConnectionRef connection, - dispatch_queue_t queue + SCNetworkConnectionRef connection, + dispatch_queue_t __nullable queue ) __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_4_0/*SPI*/); __END_DECLS +CF_ASSUME_NONNULL_END +CF_IMPLICIT_BRIDGING_DISABLED + #endif /* USE_SYSTEMCONFIGURATION_PRIVATE_HEADERS */ #endif /* _SCNETWORKCONNECTION_H */ diff --git a/SystemConfiguration.fproj/SCNetworkConnectionPrivate.c b/SystemConfiguration.fproj/SCNetworkConnectionPrivate.c index 7b58f62..076261a 100644 --- a/SystemConfiguration.fproj/SCNetworkConnectionPrivate.c +++ b/SystemConfiguration.fproj/SCNetworkConnectionPrivate.c @@ -1,15 +1,15 @@ /* - * Copyright (c) 2006-2012 Apple Inc. All rights reserved. + * Copyright (c) 2006-2012, 2015 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ - * + * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. - * + * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, @@ -17,7 +17,7 @@ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. - * + * * @APPLE_LICENSE_HEADER_END@ */ @@ -230,10 +230,10 @@ logCFPreferencesChange(CFStringRef serviceID, CFArrayRef newPreferences) _SC_cfstring_to_cstring(str, dir, sizeof(dir), kCFStringEncodingUTF8); CFRelease(str); - SCLog(TRUE, LOG_ERR, CFSTR("CFPreferences being updated, old/new in \"%s\""), dir); + SC_log(LOG_NOTICE, "CFPreferences being updated, old/new in \"%s\"", dir); if (mkdir(dir, 0755) == -1) { - SCLog(TRUE, LOG_ERR, CFSTR("logCFPreferencesChange mkdir() failed, error = %s"), SCErrorString(errno)); + SC_log(LOG_NOTICE, "mkdir() failed: %s", SCErrorString(errno)); return; } @@ -247,7 +247,7 @@ logCFPreferencesChange(CFStringRef serviceID, CFArrayRef newPreferences) strlcat(path, "/backtrace", sizeof(path)); fd = open(path, O_WRONLY|O_CREAT|O_TRUNC|O_EXCL, 0644); if (fd == -1) { - SCLog(TRUE, LOG_ERR, CFSTR("logCFPreferencesChange fopen() failed, error = %s"), SCErrorString(errno)); + SC_log(LOG_NOTICE, "fopen() failed: %s", SCErrorString(errno)); CFRelease(trace); return; } @@ -267,13 +267,13 @@ logCFPreferencesChange(CFStringRef serviceID, CFArrayRef newPreferences) strlcat(path, "/old", sizeof(path)); fd = open(path, O_WRONLY|O_CREAT|O_TRUNC|O_EXCL, 0644); if (fd == -1) { - SCLog(TRUE, LOG_ERR, CFSTR("logCFPreferencesChange fopen() failed, error = %s"), SCErrorString(errno)); + SC_log(LOG_NOTICE, "fopen() failed: %s", SCErrorString(errno)); CFRelease(oldPreferences); return; } data = CFPropertyListCreateData(NULL, oldPreferences, kCFPropertyListXMLFormat_v1_0, 0, NULL); if (data == NULL) { - SCLog(TRUE, LOG_ERR, CFSTR("logCFPreferencesChange CFPropertyListCreateData() failed")); + SC_log(LOG_NOTICE, "CFPropertyListCreateData() failed"); close(fd); CFRelease(oldPreferences); return; @@ -293,12 +293,12 @@ logCFPreferencesChange(CFStringRef serviceID, CFArrayRef newPreferences) strlcat(path, "/new", sizeof(path)); fd = open(path, O_WRONLY|O_CREAT|O_TRUNC|O_EXCL, 0644); if (fd == -1) { - SCLog(TRUE, LOG_ERR, CFSTR("logCFPreferencesChange fopen() failed, error = %s"), SCErrorString(errno)); + SC_log(LOG_NOTICE, "fopen() failed: %s", SCErrorString(errno)); return; } data = CFPropertyListCreateData(NULL, newPreferences, kCFPropertyListXMLFormat_v1_0, 0, NULL); if (data == NULL) { - SCLog(TRUE, LOG_ERR, CFSTR("logCFPreferencesChange CFPropertyListCreateData() failed")); + SC_log(LOG_NOTICE, "CFPropertyListCreateData() failed"); close(fd); return; } diff --git a/SystemConfiguration.fproj/SCNetworkConnectionPrivate.h b/SystemConfiguration.fproj/SCNetworkConnectionPrivate.h index df77da3..f5c3aeb 100644 --- a/SystemConfiguration.fproj/SCNetworkConnectionPrivate.h +++ b/SystemConfiguration.fproj/SCNetworkConnectionPrivate.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2008, 2009, 2011-2014 Apple Inc. All rights reserved. + * Copyright (c) 2006, 2008, 2009, 2011-2015 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -25,6 +25,7 @@ #define _SCNETWORKCONNECTIONPRIVATE_H #include +#include #include #if !TARGET_IPHONE_SIMULATOR #include @@ -34,7 +35,7 @@ #include -typedef const struct __SCUserPreferencesRef * SCUserPreferencesRef; +typedef const struct CF_BRIDGED_TYPE(id) __SCUserPreferencesRef * SCUserPreferencesRef; __BEGIN_DECLS diff --git a/SystemConfiguration.fproj/SCNetworkInterface.c b/SystemConfiguration.fproj/SCNetworkInterface.c index f371ca0..5f70eaf 100644 --- a/SystemConfiguration.fproj/SCNetworkInterface.c +++ b/SystemConfiguration.fproj/SCNetworkInterface.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004-2014 Apple Inc. All rights reserved. + * Copyright (c) 2004-2015 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -64,7 +64,7 @@ #include #include #if !TARGET_IPHONE_SIMULATOR -#include +#include #endif // !TARGET_IPHONE_SIMULATOR #include "dy_framework.h" @@ -85,6 +85,7 @@ #include #include #include +#include #include #include #include @@ -93,10 +94,12 @@ #include #include #include +#include #include static CFStringRef copy_interface_string (CFBundleRef bundle, CFStringRef key, Boolean localized); +static CFStringRef __SCNetworkInterfaceCopyDescription (CFTypeRef cf); static CFStringRef __SCNetworkInterfaceCopyFormattingDescription (CFTypeRef cf, CFDictionaryRef formatOptions); static void __SCNetworkInterfaceDeallocate (CFTypeRef cf); static Boolean __SCNetworkInterfaceEqual (CFTypeRef cf1, CFTypeRef cf2); @@ -333,7 +336,7 @@ static const CFRuntimeClass __SCNetworkInterfaceClass = { __SCNetworkInterfaceEqual, // equal __SCNetworkInterfaceHash, // hash __SCNetworkInterfaceCopyFormattingDescription, // copyFormattingDesc - NULL // copyDebugDesc + __SCNetworkInterfaceCopyDescription // copyDebugDesc }; @@ -343,6 +346,11 @@ static pthread_once_t iokit_quiet = PTHREAD_ONCE_INIT; static mach_port_t masterPort = MACH_PORT_NULL; +static CFStringRef +__SCNetworkInterfaceCopyDescription(CFTypeRef cf) +{ + return __SCNetworkInterfaceCopyFormattingDescription(cf, NULL); +} static CFStringRef __SCNetworkInterfaceCopyFormattingDescription(CFTypeRef cf, CFDictionaryRef formatOptions) @@ -383,12 +391,14 @@ __SCNetworkInterfaceCopyFormattingDescription(CFTypeRef cf, CFDictionaryRef form CFIndex dataLen; CFIndex i; - CFStringAppendFormat(result, NULL, CFSTR(", address = 0x")); + CFStringAppendFormat(result, NULL, CFSTR(", address = ")); data = CFDataGetBytePtr(interfacePrivate->address); dataLen = CFDataGetLength(interfacePrivate->address); for (i = 0; i < dataLen; i++) { - CFStringAppendFormat(result, NULL, CFSTR("%02x"), data[i]); + CFStringAppendFormat(result, NULL, CFSTR("%s%02x"), + (i > 0) ? ":" : "", + data[i]); } } CFStringAppendFormat(result, NULL, CFSTR(", builtin = %s"), interfacePrivate->builtin ? "TRUE" : "FALSE"); @@ -753,9 +763,7 @@ __SCNetworkInterfaceInitialize(void) // get mach port used to communication with IOKit kr = IOMasterPort(MACH_PORT_NULL, &masterPort); if (kr != kIOReturnSuccess) { - SCLog(TRUE, LOG_DEBUG, - CFSTR("__SCNetworkInterfaceInitialize(), could not get IOMasterPort, kr = 0x%x"), - kr); + SC_log(LOG_NOTICE, "could not get IOMasterPort, kr = 0x%x", kr); } return; @@ -870,12 +878,12 @@ __SCNetworkInterfaceSupportsVLAN(CFStringRef bsd_if) mib[5] = if_index; /* ask for exactly one interface */ if (sysctl(mib, 6, NULL, &buf_len, NULL, 0) == -1) { - SCLog(TRUE, LOG_ERR, CFSTR("sysctl() size failed: %s"), strerror(errno)); + SC_log(LOG_NOTICE, "sysctl() size failed: %s", strerror(errno)); goto done; } buf = CFAllocatorAllocate(NULL, buf_len, 0); if (sysctl(mib, 6, buf, &buf_len, NULL, 0) == -1) { - SCLog(TRUE, LOG_ERR, CFSTR("sysctl() failed: %s"), strerror(errno)); + SC_log(LOG_NOTICE, "sysctl() failed: %s", strerror(errno)); goto done; } @@ -904,6 +912,48 @@ __SCNetworkInterfaceSupportsVLAN(CFStringRef bsd_if) } +static CFDataRef +__SCCopyMacAddress(CFStringRef ifname) +{ + struct ifaddrs *ifap; + char ifname_c[IFNAMSIZ]; + struct ifaddrs *ifp; + CFDataRef macAddress = NULL; + + if(_SC_cfstring_to_cstring(ifname, + ifname_c, + sizeof(ifname_c), + kCFStringEncodingUTF8) == NULL) { + return NULL; + } + + if (getifaddrs(&ifap) == -1) { + _SCErrorSet(errno); + SC_log(LOG_NOTICE, "getifaddrs() failed: %s", strerror(errno)); + return NULL; + } + + for (ifp = ifap; ifp != NULL; ifp = ifp->ifa_next) { + struct sockaddr_dl *sdl; + + if(strcmp(ifname_c, ifp->ifa_name) != 0) { + continue; + } + + /* ALIGN: cast ok, this should be aligned (getifaddrs). */ + sdl = (struct sockaddr_dl *)(void *)ifp->ifa_addr; + if (sdl->sdl_family != AF_LINK) { + continue; + } + + macAddress = CFDataCreate(NULL, (UInt8 *)LLADDR(sdl), sdl->sdl_alen); + break; + } + freeifaddrs(ifap); + return macAddress; +} + + __private_extern__ SCNetworkInterfacePrivateRef _SCBondInterfaceCreatePrivate(CFAllocatorRef allocator, @@ -919,6 +969,7 @@ _SCBondInterfaceCreatePrivate(CFAllocatorRef allocator, interfacePrivate->interface_type = kSCNetworkInterfaceTypeBond; interfacePrivate->entity_type = kSCValNetInterfaceTypeEthernet; interfacePrivate->entity_device = CFStringCreateCopy(allocator, bond_if); + interfacePrivate->address = __SCCopyMacAddress(interfacePrivate->entity_device); interfacePrivate->builtin = TRUE; interfacePrivate->supportsVLAN = __SCNetworkInterfaceSupportsVLAN(bond_if); interfacePrivate->sort_order = kSortBond; @@ -949,6 +1000,7 @@ _SCBridgeInterfaceCreatePrivate(CFAllocatorRef allocator, interfacePrivate->interface_type = kSCNetworkInterfaceTypeBridge; interfacePrivate->entity_type = kSCValNetInterfaceTypeEthernet; interfacePrivate->entity_device = CFStringCreateCopy(allocator, bridge_if); + interfacePrivate->address = __SCCopyMacAddress(interfacePrivate->entity_device); interfacePrivate->builtin = TRUE; interfacePrivate->supportsVLAN = __SCNetworkInterfaceSupportsVLAN(bridge_if); interfacePrivate->sort_order = kSortBridge; @@ -978,6 +1030,7 @@ _SCVLANInterfaceCreatePrivate(CFAllocatorRef allocator, interfacePrivate->interface_type = kSCNetworkInterfaceTypeVLAN; interfacePrivate->entity_type = kSCValNetInterfaceTypeEthernet; interfacePrivate->entity_device = CFStringCreateCopy(allocator, vlan_if); + interfacePrivate->address = __SCCopyMacAddress(interfacePrivate->entity_device); interfacePrivate->builtin = TRUE; interfacePrivate->sort_order = kSortVLAN; @@ -1395,7 +1448,7 @@ pci_slot(io_registry_entry_t interface, CFTypeRef *pci_slot_name) // if we have hit the root node break; default : - SCLog(TRUE, LOG_DEBUG, CFSTR("pci_slot IORegistryEntryGetParentEntry() failed, kr = 0x%x"), kr); + SC_log(LOG_INFO, "IORegistryEntryGetParentEntry() failed, kr = 0x%x", kr); break; } @@ -1455,7 +1508,7 @@ pci_port(CFTypeRef slot_name, int ift, CFStringRef bsdName) kr = IOServiceGetMatchingServices(masterPort, matching, &slot_iterator); if (kr != kIOReturnSuccess) { - SCLog(TRUE, LOG_DEBUG, CFSTR("pci_port IOServiceGetMatchingServices() failed, kr = 0x%x"), kr); + SC_log(LOG_INFO, "IOServiceGetMatchingServices() failed, kr = 0x%x", kr); return MACH_PORT_NULL; } @@ -1470,7 +1523,7 @@ pci_port(CFTypeRef slot_name, int ift, CFStringRef bsdName) kIORegistryIterateRecursively, &child_iterator); if (kr != kIOReturnSuccess) { - SCLog(TRUE, LOG_DEBUG, CFSTR("pci_port IORegistryEntryCreateIterator() failed, kr = 0x%x"), kr); + SC_log(LOG_INFO, "IORegistryEntryCreateIterator() failed, kr = 0x%x", kr); CFRelease(port_names); return MACH_PORT_NULL; } @@ -1591,7 +1644,7 @@ isBluetoothBuiltin(Boolean *haveController) &iter); if ((kr != kIOReturnSuccess) || (iter == MACH_PORT_NULL)) { if (kr != kIOReturnSuccess) { - SCLog(TRUE, LOG_DEBUG, CFSTR("isBluetoothBuiltin IOServiceGetMatchingServices() failed, kr = 0x%x"), kr); + SC_log(LOG_INFO, "IOServiceGetMatchingServices() failed, kr = 0x%x", kr); } *haveController = FALSE; return FALSE; @@ -1796,7 +1849,7 @@ processNetworkInterface(SCNetworkInterfacePrivateRef interfacePrivate, CFNumberGetValue(num, kCFNumberIntType, &ift)) { interfacePrivate->type = CFRetain(num); } else { - SCLog(TRUE, LOG_DEBUG, CFSTR("processNetworkInterface() failed, no interface type")); + SC_log(LOG_INFO, "no interface type"); return FALSE; } @@ -1984,8 +2037,9 @@ processNetworkInterface(SCNetworkInterfacePrivateRef interfacePrivate, io_registry_entry_t node = interface; while (provider != NULL) { - if (CFEqual(provider, CFSTR("IOUSBDevice")) || - CFEqual(provider, CFSTR("IOUSBInterface"))) { +#if !TARGET_IPHONE_SIMULATOR + if (CFEqual(provider, CFSTR(kIOUSBDeviceClassName)) || + CFEqual(provider, CFSTR(kIOUSBInterfaceClassName))) { // get USB info (if available) processUSBInterface(interfacePrivate, interface, @@ -2002,6 +2056,7 @@ processNetworkInterface(SCNetworkInterfacePrivateRef interfacePrivate, } break; } +#endif // !TARGET_IPHONE_SIMULATOR if (node == interface) { node = controller; @@ -2082,7 +2137,7 @@ processNetworkInterface(SCNetworkInterfacePrivateRef interfacePrivate, break; default : - SCLog(TRUE, LOG_DEBUG, CFSTR("processNetworkInterface() failed, unknown interface type = %d"), ift); + SC_log(LOG_INFO, "unknown interface type = %d", ift); return FALSE; } @@ -2187,9 +2242,7 @@ is_valid_connection_script(CFStringRef script) goto bundle; } - SCLog(TRUE, LOG_DEBUG, - CFSTR("processSerialInterface stat() failed: %s"), - strerror(errno)); + SC_log(LOG_INFO, "stat() failed: %s", strerror(errno)); continue; } if (S_ISREG(statBuf.st_mode)) { @@ -2211,9 +2264,7 @@ is_valid_connection_script(CFStringRef script) continue; } - SCLog(TRUE, LOG_DEBUG, - CFSTR("processSerialInterface stat() failed: %s"), - strerror(errno)); + SC_log(LOG_INFO, "stat() failed: %s", strerror(errno)); continue; } } @@ -2552,6 +2603,28 @@ __SC_IORegistryEntryCopyPath(io_registry_entry_t entry, const io_name_t plane) return str; } +static CFMutableDictionaryRef +copyIORegistryProperties(io_registry_entry_t reg_ent, const CFStringRef *reg_keys, CFIndex numKeys) +{ + CFIndex idx = 0; + CFMutableDictionaryRef reg_dict = NULL; + CFTypeRef value = NULL; + + reg_dict = CFDictionaryCreateMutable(NULL, + 0, + &kCFTypeDictionaryKeyCallBacks , + &kCFTypeDictionaryValueCallBacks); + + for (; idx < numKeys; idx++) { + value = IORegistryEntryCreateCFProperty(reg_ent, reg_keys[idx], NULL, 0); + if (value != NULL) { + CFDictionaryAddValue(reg_dict, reg_keys[idx], value); + CFRelease(value); + } + } + + return reg_dict; +} static SCNetworkInterfaceRef createInterface(io_registry_entry_t interface, processInterface func, @@ -2567,6 +2640,32 @@ createInterface(io_registry_entry_t interface, processInterface func, kern_return_t kr; CFTypeRef val; + // Keys of interest +#if TARGET_IPHONE_SIMULATOR || 1 // while waiting for rdar://19431723 +#else + const CFStringRef interface_dict_keys[] = { + CFSTR(kIOInterfaceType), + CFSTR(kIOBuiltin), + CFSTR(kIOBSDNameKey), + CFSTR(kIOPrimaryInterface), + CFSTR(kIOInterfaceNamePrefix), + CFSTR(kIOInterfaceUnit), + CFSTR(kIOTTYDeviceKey), + CFSTR(kIOTTYBaseNameKey), + CFSTR(kIOSerialBSDTypeKey), + CFSTR(kIOLocation) + }; +#endif // !TARGET_IPHONE_SIMULATOR + + const CFStringRef controller_dict_keys[] = { + CFSTR(kIOFeatures), + CFSTR(kIOMACAddress) + }; + + const CFStringRef bus_dict_keys[] = { + CFSTR("name") + }; + if (hidden_key != NULL) { // check if hidden val = IORegistryEntrySearchCFProperty(interface, @@ -2580,45 +2679,45 @@ createInterface(io_registry_entry_t interface, processInterface func, } } +#if TARGET_IPHONE_SIMULATOR || 1 // while waiting for rdar://19431723 // get the dictionary associated with the [interface] node kr = IORegistryEntryCreateCFProperties(interface, &interface_dict, NULL, kNilOptions); if (kr != kIOReturnSuccess) { - SCLog(TRUE, LOG_DEBUG, CFSTR("createInterface IORegistryEntryCreateCFProperties() failed, kr = 0x%x"), kr); + SC_log(LOG_INFO, "IORegistryEntryCreateCFProperties() failed, kr = 0x%x", kr); goto done; } +#else + interface_dict = copyIORegistryProperties(interface, + interface_dict_keys, + sizeof(interface_dict_keys)/sizeof(interface_dict_keys[0])); +#endif // !TARGET_IPHONE_SIMULATOR // get the controller node kr = IORegistryEntryGetParentEntry(interface, kIOServicePlane, &controller); if (kr != kIOReturnSuccess) { - SCLog(TRUE, LOG_DEBUG, CFSTR("createInterface IORegistryEntryGetParentEntry() failed, kr = 0x%x"), kr); + SC_log(LOG_INFO, "IORegistryEntryGetParentEntry() failed, kr = 0x%x", kr); goto done; } - // get the dictionary associated with the [controller] node - kr = IORegistryEntryCreateCFProperties(controller, &controller_dict, NULL, kNilOptions); - if (kr != kIOReturnSuccess) { - SCLog(TRUE, LOG_DEBUG, CFSTR("createInterface IORegistryEntryCreateCFProperties() failed, kr = 0x%x"), kr); - goto done; - } + controller_dict = copyIORegistryProperties(controller, + controller_dict_keys, + sizeof(controller_dict_keys)/sizeof(controller_dict_keys[0])); // get the bus node kr = IORegistryEntryGetParentEntry(controller, kIOServicePlane, &bus); if (kr != kIOReturnSuccess) { - SCLog(TRUE, LOG_DEBUG, CFSTR("createInterface IORegistryEntryGetParentEntry() failed, kr = 0x%x"), kr); + SC_log(LOG_INFO, "IORegistryEntryGetParentEntry() failed, kr = 0x%x", kr); goto done; } - // get the dictionary associated with the [bus] node - kr = IORegistryEntryCreateCFProperties(bus, &bus_dict, NULL, kNilOptions); - if (kr != kIOReturnSuccess) { - SCLog(TRUE, LOG_DEBUG, CFSTR("createInterface IORegistryEntryCreateCFProperties() failed, kr = 0x%x"), kr); - goto done; - } + bus_dict = copyIORegistryProperties(bus, + bus_dict_keys, + sizeof(bus_dict_keys)/sizeof(bus_dict_keys[0])); // get the registry entry ID kr = IORegistryEntryGetRegistryEntryID(interface, &entryID); if (kr != kIOReturnSuccess) { - SCLog(TRUE, LOG_DEBUG, CFSTR("createInterface IORegistryEntryGetRegistryEntryID() failed, kr = 0x%x"), kr); + SC_log(LOG_INFO, "IORegistryEntryGetRegistryEntryID() failed, kr = 0x%x", kr); goto done; } @@ -2701,7 +2800,7 @@ findMatchingInterfaces(CFDictionaryRef matching, processInterface func, kr = IOServiceGetMatchingServices(masterPort, matching, &iterator); if (kr != kIOReturnSuccess) { - SCLog(TRUE, LOG_DEBUG, CFSTR("findMatchingInterfaces IOServiceGetMatchingServices() failed, kr = 0x%x"), kr); + SC_log(LOG_INFO, "IOServiceGetMatchingServices() failed, kr = 0x%x", kr); return NULL; } @@ -2978,42 +3077,23 @@ extendedConfigurationTypes(SCNetworkInterfaceRef interface) return myContext.types; } +static CFArrayRef +stringCreateArray(CFStringRef str) +{ + return (CFArrayCreate(NULL, (const void **)&str, 1, &kCFTypeArrayCallBacks)); +} static CFArrayRef -copyConfigurationPaths(SCNetworkInterfacePrivateRef interfacePrivate, - CFStringRef extendedType) +copyPerInterfaceConfigurationPaths(SCNetworkInterfacePrivateRef interfacePrivate, + CFStringRef extendedType) { - CFMutableArrayRef array; + CFMutableArrayRef array = NULL; CFIndex i; - CFIndex interfaceIndex; CFIndex n; CFStringRef path; SCNetworkServiceRef service; CFArrayRef sets; - array = CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks); - - interfaceIndex = findConfiguration(interfacePrivate->interface_type); - if (interfaceIndex == kCFNotFound) { - // unknown interface type, use per-service configuration preferences - path = SCPreferencesPathKeyCreateNetworkServiceEntity(NULL, // allocator - interfacePrivate->serviceID, // service - extendedType); // entity - CFArrayAppendValue(array, path); - CFRelease(path); - return array; - } - - if (!configurations[interfaceIndex].per_interface_config) { - // known interface type, per-service configuration preferences - path = SCPreferencesPathKeyCreateNetworkServiceEntity(NULL, // allocator - interfacePrivate->serviceID, // service - extendedType); // entity - CFArrayAppendValue(array, path); - CFRelease(path); - return array; - } - // known interface type, per-interface configuration preferences // // 1. look for all sets which contain the associated service @@ -3041,20 +3121,51 @@ copyConfigurationPaths(SCNetworkInterfacePrivateRef interfacePrivate, SCNetworkSetGetSetID(set), // set interfacePrivate->entity_device, // service extendedType); // entity + if (array == NULL) { + array = CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks); + } CFArrayAppendValue(array, path); CFRelease(path); } CFRelease(services); } - if (CFArrayGetCount(array) == 0) { - CFRelease(array); - array = NULL; - } - CFRelease(service); if (sets != NULL) CFRelease(sets); return array; + +} + +static CFArrayRef +copyConfigurationPaths(SCNetworkInterfacePrivateRef interfacePrivate, + CFStringRef extendedType) +{ + CFArrayRef array; + CFIndex interfaceIndex; + CFStringRef path; + + interfaceIndex = findConfiguration(interfacePrivate->interface_type); + if (interfaceIndex == kCFNotFound) { + // unknown interface type, use per-service configuration preferences + path = SCPreferencesPathKeyCreateNetworkServiceEntity(NULL, // allocator + interfacePrivate->serviceID, // service + extendedType); // entity + array = stringCreateArray(path); + CFRelease(path); + } + + else if (!configurations[interfaceIndex].per_interface_config) { + // known interface type, per-service configuration preferences + path = SCPreferencesPathKeyCreateNetworkServiceEntity(NULL, // allocator + interfacePrivate->serviceID, // service + extendedType); // entity + array = stringCreateArray(path); + CFRelease(path); + } + else { + array = copyPerInterfaceConfigurationPaths(interfacePrivate, extendedType); + } + return (array); } @@ -3371,7 +3482,7 @@ _SCNetworkInterfaceCopyPrefixFromBSDName(CFStringRef bsdName) CFIndex length = 0; if (isA_CFString(bsdName) == NULL) { - SCLog(TRUE, LOG_DEBUG, CFSTR("_SCNetworkInterfaceCopyPrefixFromBSDName: bsdName is NULL or not of the correct type")); + SC_log(LOG_DEBUG, "no BSD name"); goto done; } @@ -3406,12 +3517,12 @@ __SCNetworkInterfaceUpdateBSDName(SCNetworkInterfaceRef interface, CFStringRef c SCNetworkInterfacePrivateRef interfacePrivate = (SCNetworkInterfacePrivateRef)interface; if (isA_SCNetworkInterface(interface) == NULL) { - SCLog(TRUE, LOG_DEBUG, CFSTR("__SCNetworkInterfaceUpdateBSDName: interface is NULL or not of the correct type")); + SC_log(LOG_INFO, "No interface"); goto done; } if (CFEqual(currentBSDName, newBSDName)) { - SCLog(TRUE, LOG_DEBUG, CFSTR("__SCNetworkInterfaceUpdateBSDName: bsdName (%@) is equal to interfacePrivate->entity_device (%@)"), currentBSDName, newBSDName); + // if no change goto done; } @@ -3496,7 +3607,7 @@ __SCNetworkInterfaceSetIOInterfaceUnit (SCNetworkInterfaceRef interface, if (isA_CFString(interfacePrivate->entity_device) != NULL) { CFStringRef interfaceNamePrefix = _SCNetworkInterfaceCopyPrefixFromBSDName(interfacePrivate->entity_device); if (interfaceNamePrefix == NULL) { - SCLog(TRUE, LOG_DEBUG, CFSTR("__SCNetworkInterfaceSetIOInterfaceUnit: interfaceNamePrefix is NULL")); + SC_log(LOG_INFO, "interfaceNamePrefix is NULL"); } else { __SCNetworkInterfaceSetIOInterfacePrefix(interface, interfaceNamePrefix); @@ -3512,12 +3623,12 @@ __SCNetworkInterfaceSetIOInterfaceUnit (SCNetworkInterfaceRef interface, // Update the BSD Name if ((newBSDName == NULL) || (__SCNetworkInterfaceUpdateBSDName(interface, oldBSDName, newBSDName) == FALSE)) { - SCLog(_sc_debug, LOG_DEBUG, CFSTR("__SCNetworkInterfaceSetIOInterfaceUnit: Update BSD Name Failed")); + SC_log(LOG_INFO, "BSD name update failed"); } // Update the path if (__SCNetworkInterfaceUpdateIOPath(interface) == FALSE) { - SCLog(_sc_debug, LOG_DEBUG, CFSTR("__SCNetworkInterfaceSetIOInterfaceUnit: Update IO Path Failed")); + SC_log(LOG_INFO, "IOPath update failed"); } CFRetain(unit); @@ -3658,7 +3769,7 @@ __SCNetworkInterfaceMatchesName(CFStringRef name, CFStringRef key) CFStringRef str; if (bundle == NULL) { - // if no bundle + SC_log(LOG_NOTICE, "%s: no bundle information to compare interface names", __FUNCTION__); return FALSE; } @@ -3721,7 +3832,7 @@ __SCNetworkInterfaceCreateWithStorageEntity (CFAllocatorRef allocator, pthread_once(&initialized, __SCNetworkInterfaceInitialize); if (isA_CFDictionary(interface_entity) == NULL) { - SCLog(TRUE, LOG_DEBUG, CFSTR("__SCNetworkInterfaceCreateWithStorageEntity: interface_entity is NULL or not of the correct type")); + SC_log(LOG_INFO, "No interface entity"); goto done; } active = CFDictionaryGetValue(interface_entity, CFSTR(kSCNetworkInterfaceActive)); @@ -3730,56 +3841,53 @@ __SCNetworkInterfaceCreateWithStorageEntity (CFAllocatorRef allocator, } bsdName = CFDictionaryGetValue(interface_entity, CFSTR(kSCNetworkInterfaceBSDName)); if (isA_CFString(bsdName) == NULL) { - SCLog(TRUE, LOG_DEBUG, CFSTR("__SCNetworkInterfaceCreateWithStorageEntity: bsdName is NULL or not of the correct type")); + SC_log(LOG_INFO, "No BSD name"); goto done; } ioBuiltin = CFDictionaryGetValue(interface_entity, CFSTR(kSCNetworkInterfaceIOBuiltin)); if (isA_CFBoolean(ioBuiltin) == NULL) { - SCLog(TRUE, LOG_DEBUG, CFSTR("__SCNetworkInterfaceCreateWithStorageEntity: ioBuiltin is NULL or not of the correct type")); + SC_log(LOG_INFO, "No IOBuiltin property"); goto done; } ioInterfaceNamePrefix = CFDictionaryGetValue(interface_entity, CFSTR(kSCNetworkInterfaceIOInterfaceNamePrefix)); if (isA_CFString(ioInterfaceNamePrefix) == NULL) { ioInterfaceNamePrefix = _SCNetworkInterfaceCopyPrefixFromBSDName(bsdName); if (ioInterfaceNamePrefix == NULL) { - SCLog(TRUE, LOG_DEBUG, CFSTR("__SCNetworkInterfaceCreateWithStorageEntity: ioInterfaceNamePrefix is NULL or not of the correct type")); + SC_log(LOG_INFO, "No BSD interface name prefix"); goto done; } - } - else { + } else { CFRetain(ioInterfaceNamePrefix); } ioInterfaceType = CFDictionaryGetValue(interface_entity, CFSTR(kSCNetworkInterfaceIOInterfaceType)); if (isA_CFNumber(ioInterfaceType) == NULL) { - SCLog(TRUE, LOG_DEBUG, CFSTR("__SCNetworkInterfaceCreateWithStorageEntity: ioInterfaceType is NULL or not of the correct type")); + SC_log(LOG_INFO, "No IOInterfaceType"); goto done; } if (CFNumberGetValue(ioInterfaceType, kCFNumberIntType, &ioInterfaceTypeNum) == FALSE) { - SCLog(TRUE, LOG_ERR, CFSTR("__SCNetworkInterfaceCreateWithStorageEntity: Count not extract value from ioInterfaceType")); + SC_log(LOG_NOTICE, "Count not extract value from ioInterfaceType"); } - ioInterfaceUnit = CFDictionaryGetValue(interface_entity, CFSTR(kSCNetworkInterfaceIOInterfaceUnit)); if (isA_CFNumber(ioInterfaceUnit) == NULL) { - SCLog(TRUE, LOG_DEBUG, CFSTR("__SCNetworkInterfaceCreateWithStorageEntity: ioInterfaceUnit is NULL or not of the correct type")); + SC_log(LOG_INFO, "No IOInterfaceUnit"); goto done; } ioMACAddress = CFDictionaryGetValue(interface_entity, CFSTR(kSCNetworkInterfaceIOMACAddress)); if (isA_CFData(ioMACAddress) == NULL) { - SCLog(TRUE, LOG_DEBUG, CFSTR("__SCNetworkInterfaceCreateWithStorageEntity: ioMACAddress is NULL or not of the correct type")); + SC_log(LOG_INFO, "No IOMACAddress"); goto done; } ioPathMatch = CFDictionaryGetValue(interface_entity, CFSTR(kSCNetworkInterfaceIOPathMatch)); if (isA_CFString(ioPathMatch) == NULL) { - SCLog(TRUE, LOG_DEBUG, CFSTR("__SCNetworkInterfaceCreateWithStorageEntity: ioPathMatch is NULL or not of the correct type")); + SC_log(LOG_INFO, "No IOPathMatch"); goto done; - } - else { + } else { // Check if Path contains the BSD Name in the end } SCNetworkInterfaceInfo = CFDictionaryGetValue(interface_entity, CFSTR(kSCNetworkInterfaceInfo)); if (isA_CFDictionary(SCNetworkInterfaceInfo) == NULL) { - SCLog(TRUE, LOG_DEBUG, CFSTR("__SCNetworkInterfaceCreateWithStorageEntity: SCNetworkInterfaceInfo is NULL or not of the correct type")); + SC_log(LOG_INFO, "No SCNetworkInterfaceInfo"); goto done; } userDefinedName = CFDictionaryGetValue(SCNetworkInterfaceInfo, kSCPropUserDefinedName); @@ -3791,7 +3899,7 @@ __SCNetworkInterfaceCreateWithStorageEntity (CFAllocatorRef allocator, type = CFDictionaryGetValue(interface_entity, CFSTR(kSCNetworkInterfaceType)); if (isA_CFString(type) == NULL) { - SCLog(TRUE, LOG_DEBUG, CFSTR("__SCNetworkInterfaceCreateWithStorageEntity: type is NULL or not of the correct type")); + SC_log(LOG_INFO, "No SCNetworkInterfaceType"); goto done; } @@ -3812,20 +3920,18 @@ __SCNetworkInterfaceCreateWithStorageEntity (CFAllocatorRef allocator, // Handling interface types to be seen in NetworkInterfaces.plist CFIndex interfaceIndex; - + interfaceIndex = findConfiguration(type); if (interfaceIndex != kCFNotFound) { interfacePrivate->interface_type = *configurations[interfaceIndex].interface_type; - } - else { + } else { interfacePrivate->interface_type = kSCNetworkInterfaceTypeEthernet; } - + // Extracting entity type from value of interface type if (ioInterfaceTypeNum == kInterfaceTypeEthernetValue) { interfacePrivate->entity_type = kSCValNetInterfaceTypeEthernet; // kSCNetworkInterfaceTypeEthernet; - } - else if (ioInterfaceTypeNum == kInterfaceTypeFirewireValue) { + } else if (ioInterfaceTypeNum == kInterfaceTypeFirewireValue) { interfacePrivate->entity_type = kSCValNetInterfaceTypeFireWire; } done: @@ -3858,7 +3964,7 @@ _SCNetworkInterfaceCreateWithEntity(CFAllocatorRef allocator, if (service != NULL) { servicePref = ((SCNetworkServicePrivateRef)service)->prefs; useSystemInterfaces = ((__SCPreferencesUsingDefaultPrefs(servicePref)) && - (__SCPreferencesGetLimitSCNetworkConfiguration(servicePref) == FALSE)); + (__SCPreferencesGetLimitSCNetworkConfiguration(servicePref) == FALSE)); } ifType = CFDictionaryGetValue(interface_entity, kSCPropNetInterfaceType); @@ -4114,7 +4220,7 @@ _SCNetworkInterfaceCreateWithEntity(CFAllocatorRef allocator, } } if (interfacePrivate == NULL) { - SCLog(TRUE, LOG_ERR, CFSTR("_SCNetworkInterfaceCreateWithEntity() failed, more than one interface matches %@"), ifDevice); + SC_log(LOG_NOTICE, "more than one interface matches %@", ifDevice); interfacePrivate = (SCNetworkInterfacePrivateRef)CFArrayGetValueAtIndex(matching_interfaces, 0); } CFRetain(interfacePrivate); @@ -4163,7 +4269,7 @@ _SCNetworkInterfaceCreateWithEntity(CFAllocatorRef allocator, if (CFEqual(ifType, kSCValNetInterfaceTypeEthernet)) { CFStringRef entity_hardware; SCNetworkInterfaceRef virtualInterface; - + if ((useSystemInterfaces == FALSE) && (((virtualInterface = findBridgeInterface(servicePref, ifDevice)) != NULL) || #if !TARGET_OS_IPHONE @@ -4256,21 +4362,21 @@ _SCNetworkInterfaceCreateWithEntity(CFAllocatorRef allocator, if (interfacePrivate == NULL) { return NULL; } - } else if (CFEqual(ifType, kSCValNetInterfaceTypeIPSec)) { - CFRelease(interfacePrivate); - interfacePrivate = (SCNetworkInterfacePrivateRef)SCNetworkInterfaceCreateWithInterface(kSCNetworkInterfaceIPv4, - kSCNetworkInterfaceTypeIPSec); - } else if (CFEqual(ifType, kSCValNetInterfaceType6to4)) { - CFRelease(interfacePrivate); - if (!isA_CFString(ifDevice)) { - return NULL; - } - interfacePrivate = (SCNetworkInterfacePrivateRef)SCNetworkInterfaceCreateWithInterface(kSCNetworkInterfaceIPv4, - kSCNetworkInterfaceType6to4); - } else if (CFEqual(ifType, kSCValNetInterfaceTypeLoopback)) { - CFRelease(interfacePrivate); - interfacePrivate = __SCNetworkInterfaceCreateCopy(NULL, kSCNetworkInterfaceLoopback, NULL, NULL); - } else if (CFStringFind(ifType, CFSTR("."), 0).location != kCFNotFound) { + } else if (CFEqual(ifType, kSCValNetInterfaceTypeIPSec)) { + CFRelease(interfacePrivate); + interfacePrivate = (SCNetworkInterfacePrivateRef)SCNetworkInterfaceCreateWithInterface(kSCNetworkInterfaceIPv4, + kSCNetworkInterfaceTypeIPSec); + } else if (CFEqual(ifType, kSCValNetInterfaceType6to4)) { + CFRelease(interfacePrivate); + if (!isA_CFString(ifDevice)) { + return NULL; + } + interfacePrivate = (SCNetworkInterfacePrivateRef)SCNetworkInterfaceCreateWithInterface(kSCNetworkInterfaceIPv4, + kSCNetworkInterfaceType6to4); + } else if (CFEqual(ifType, kSCValNetInterfaceTypeLoopback)) { + CFRelease(interfacePrivate); + interfacePrivate = __SCNetworkInterfaceCreateCopy(NULL, kSCNetworkInterfaceLoopback, NULL, NULL); + } else if (CFStringFind(ifType, CFSTR("."), 0).location != kCFNotFound) { // if vendor interface if (vendor_interface_types == NULL) { vendor_interface_types = CFSetCreateMutable(NULL, 0, &kCFTypeSetCallBacks); @@ -4508,8 +4614,7 @@ __waitForInterfaces() ok = SCDynamicStoreSetNotificationKeys(store, keys, NULL); CFRelease(keys); if (!ok) { - SCLog(TRUE, LOG_ERR, - CFSTR("SCDynamicStoreSetNotificationKeys() failed: %s"), SCErrorString(SCError())); + SC_log(LOG_NOTICE, "SCDynamicStoreSetNotificationKeys() failed: %s", SCErrorString(SCError())); goto done; } @@ -4534,8 +4639,7 @@ __waitForInterfaces() ok = SCDynamicStoreNotifyWait(store); if (!ok) { - SCLog(TRUE, LOG_ERR, - CFSTR("SCDynamicStoreNotifyWait() failed: %s"), SCErrorString(SCError())); + SC_log(LOG_NOTICE, "SCDynamicStoreNotifyWait() failed: %s", SCErrorString(SCError())); goto done; } @@ -5178,7 +5282,7 @@ SCNetworkInterfaceGetInterfaceType(SCNetworkInterfaceRef interface) static CFStringRef -copy_interface_string(CFBundleRef bundle, CFStringRef key, Boolean localized) +copy_string_from_bundle(CFBundleRef bundle, CFStringRef key, Boolean localized) { CFStringRef str = NULL; @@ -5193,7 +5297,53 @@ copy_interface_string(CFBundleRef bundle, CFStringRef key, Boolean localized) key, NETWORKINTERFACE_LOCALIZATIONS); } + + return str; +} + +static CFStringRef +copy_interface_string(CFBundleRef bundle, CFStringRef key, Boolean localized) +{ + static Boolean reported = FALSE; + CFStringRef str = NULL; + + str = copy_string_from_bundle(bundle, key, localized); + + if (str == NULL) { + SC_log(LOG_ERR, "Received NULL string for the interface key: {Bundle: %@, key: %@, localized: %d}", bundle, + key, + localized); + goto done; + } + + if (CFEqual(str, key) && !reported) { + const CFStringRef knownStrKey = CFSTR("airport"); + CFStringRef knownStrValue = NULL; + + knownStrValue = copy_string_from_bundle(bundle, knownStrKey, localized); + if (knownStrValue == NULL || CFEqual(knownStrValue, knownStrKey)) { + /* We are here because we requested for a localized/non-localized string + based on the localization key, but we were given the same key/NULL back, + implying a bad...bad thing! + */ + SC_log(LOG_ERR, "Failed to retrieve the interface string: {Bundle: %@, key: %@, localized: %d}", bundle, + knownStrKey, + localized); + +#if TARGET_OS_IPHONE + /* ...and we want to know about it! */ + _SC_crash("Failed to retrieve interface string", NULL, NULL); +#endif //TARGET_OS_IPHONE + reported = TRUE; + } + + if (knownStrValue != NULL) { + CFRelease(knownStrValue); + } + } + +done: return str; } @@ -5327,19 +5477,19 @@ __private_extern__ void __SCNetworkInterfaceSetUserDefinedName(SCNetworkInterfaceRef interface, CFStringRef name) { - SCNetworkInterfacePrivateRef interfacePrivate = (SCNetworkInterfacePrivateRef)interface; - - if (!isA_SCNetworkInterface(interface)) { - return; + SCNetworkInterfacePrivateRef interfacePrivate = (SCNetworkInterfacePrivateRef)interface; + + if (!isA_SCNetworkInterface(interface)) { + return; } - if (name != NULL) { - CFRetain(name); + if (name != NULL) { + CFRetain(name); } - if (interfacePrivate->name != NULL) { - CFRelease(interfacePrivate->name); + if (interfacePrivate->name != NULL) { + CFRelease(interfacePrivate->name); } - interfacePrivate->name = name; - + interfacePrivate->name = name; + if (name != NULL) { CFRetain(name); } @@ -7060,7 +7210,7 @@ _SCNetworkInterfaceCopySlashDevPath(SCNetworkInterfaceRef interface) // note: this "matching" dictionary will be consumed by the call to IOServiceGetMatchingServices kr = IOServiceGetMatchingServices(masterPort, matching, &device_iterator); if (kr != kIOReturnSuccess) { - SCLog(TRUE, LOG_DEBUG, CFSTR("IOServiceGetMatchingServices() failed, kr = 0x%x"), kr); + SC_log(LOG_INFO, "IOServiceGetMatchingServices() failed, kr = 0x%x", kr); goto done; } @@ -7488,18 +7638,16 @@ __SCNetworkInterfaceSetDeepConfiguration(SCNetworkSetRef set, SCNetworkInterface if (set == NULL) { // if service is not associated with the set if (!__SCNetworkInterfaceSetConfiguration(interface, defaultType, config, TRUE)) { - SCLog(TRUE, LOG_DEBUG, - CFSTR("__SCNetworkInterfaceSetDeepConfiguration __SCNetworkInterfaceSetConfiguration() failed, interface=%@, type=%@"), - interface, - defaultType); + SC_log(LOG_INFO, "__SCNetworkInterfaceSetConfiguration() failed, interface=%@, type=%@", + interface, + defaultType); } } else { // apply default configuration to this set if (!__SCNetworkInterfaceSetDefaultConfiguration(set, interface, defaultType, config, TRUE)) { - SCLog(TRUE, LOG_DEBUG, - CFSTR("__SCNetworkInterfaceSetDeepConfiguration __SCNetworkInterfaceSetDefaultConfiguration() failed, interface=%@, type=%@"), - interface, - defaultType); + SC_log(LOG_INFO, "__SCNetworkInterfaceSetDefaultConfiguration() failed, interface=%@, type=%@", + interface, + defaultType); } } @@ -7519,10 +7667,9 @@ __SCNetworkInterfaceSetDeepConfiguration(SCNetworkSetRef set, SCNetworkInterface config = NULL; } if (!__SCNetworkInterfaceSetConfiguration(interface, extendedType, config, TRUE)) { - SCLog(TRUE, LOG_DEBUG, - CFSTR("__SCNetworkInterfaceSetDeepConfiguration __SCNetworkInterfaceSetConfiguration() failed, interface=%@, type=%@"), - interface, - defaultType); + SC_log(LOG_INFO, "__SCNetworkInterfaceSetConfiguration() failed, interface=%@, type=%@", + interface, + defaultType); } } @@ -7611,6 +7758,131 @@ SCNetworkInterfaceSetPrimaryRank(SCNetworkInterfaceRef interface, ifName, newRank); } + +static CFIndex +findPerInterfaceConfig(SCNetworkInterfaceRef interface) +{ + CFIndex interfaceIndex; + SCNetworkInterfacePrivateRef interfacePrivate + = (SCNetworkInterfacePrivateRef)interface; + + interfaceIndex = findConfiguration(interfacePrivate->interface_type); + if (interfaceIndex == kCFNotFound + || !configurations[interfaceIndex].per_interface_config) { + return (kCFNotFound); + } + return (interfaceIndex); +} + +Boolean +SCNetworkInterfaceGetDisableUntilNeeded(SCNetworkInterfaceRef interface) +{ + Boolean disable_until_needed = FALSE; + CFNumberRef disable_prop = NULL; + CFIndex interfaceIndex; + SCNetworkInterfacePrivateRef interfacePrivate + = (SCNetworkInterfacePrivateRef)interface; + CFArrayRef path_list; + + if (interfacePrivate->prefs == NULL) { + _SCErrorSet(kSCStatusInvalidArgument); + return (FALSE); + } + interfaceIndex = findPerInterfaceConfig(interface); + if (interfaceIndex == kCFNotFound) { + _SCErrorSet(kSCStatusInvalidArgument); + return (FALSE); + } + path_list = copyPerInterfaceConfigurationPaths(interfacePrivate, NULL); + if (path_list != NULL) { + CFDictionaryRef config; + CFStringRef path = CFArrayGetValueAtIndex(path_list, 0); + + config = __getPrefsConfiguration(interfacePrivate->prefs, path); + CFRelease(path_list); + if (config != NULL) { + int disable = 0; + + disable_prop = CFDictionaryGetValue(config, kSCPropDisableUntilNeeded); + disable_prop = isA_CFNumber(disable_prop); + if (disable_prop != NULL) { + if (CFNumberGetValue(disable_prop, kCFNumberIntType, &disable)) { + disable_until_needed = (disable != 0) ? TRUE : FALSE; + } + else { + /* invalid property, ignore it */ + disable_prop = NULL; + } + } + } + } + if (disable_prop == NULL) { + disable_until_needed + = _SCNetworkInterfaceIsTethered(interface); + } + _SCErrorSet(kSCStatusOK); + return (disable_until_needed); +} + +Boolean +SCNetworkInterfaceSetDisableUntilNeeded(SCNetworkInterfaceRef interface, Boolean disable) +{ + CFIndex count; + CFIndex i; + CFIndex interfaceIndex; + SCNetworkInterfacePrivateRef interfacePrivate + = (SCNetworkInterfacePrivateRef)interface; + Boolean ok = TRUE; + CFArrayRef path_list; + + if (interfacePrivate->prefs == NULL) { + _SCErrorSet(kSCStatusInvalidArgument); + return (FALSE); + } + interfaceIndex = findPerInterfaceConfig(interface); + if (interfaceIndex == kCFNotFound) { + _SCErrorSet(kSCStatusInvalidArgument); + return (FALSE); + } + path_list = copyPerInterfaceConfigurationPaths(interfacePrivate, NULL); + if (path_list == NULL) { + _SCErrorSet(kSCStatusInvalidArgument); + return (FALSE); + } + count = CFArrayGetCount(path_list); + for (i = 0; i < count; i++) { + CFDictionaryRef config; + CFNumberRef disable_prop; + CFMutableDictionaryRef new_config; + CFStringRef path = CFArrayGetValueAtIndex(path_list, i); + int intval; + + config = __getPrefsConfiguration(interfacePrivate->prefs, path); + if (config != NULL) { + new_config + = CFDictionaryCreateMutableCopy(NULL, 0, config); + } + else { + new_config + = CFDictionaryCreateMutable(NULL, 0, + &kCFTypeDictionaryKeyCallBacks, + &kCFTypeDictionaryValueCallBacks); + } + intval = disable ? 1 : 0; + disable_prop = CFNumberCreate(NULL, kCFNumberIntType, &intval); + CFDictionarySetValue(new_config, kSCPropDisableUntilNeeded, + disable_prop); + CFRelease(disable_prop); + ok = __setPrefsConfiguration(interfacePrivate->prefs, path, new_config, FALSE); + CFRelease(new_config); + if (!ok) { + break; + } + } + CFRelease(path_list); + return (ok); +} + #else // !TARGET_IPHONE_SIMULATOR SCNetworkServicePrimaryRank @@ -7627,6 +7899,20 @@ SCNetworkInterfaceSetPrimaryRank(SCNetworkInterfaceRef interface, return (FALSE); } + +Boolean +SCNetworkInterfaceGetDisableUntilNeeded(SCNetworkInterfaceRef interface) +{ + return (FALSE); +} + +Boolean +SCNetworkInterfaceSetDisableUntilNeeded(SCNetworkInterfaceRef interface, Boolean disable) +{ + _SCErrorSet(kSCStatusInvalidArgument); + return (FALSE); +} + #endif // !TARGET_IPHONE_SIMULATOR @@ -7691,7 +7977,7 @@ __SCNetworkInterfaceSaveStoredWithPreferences(SCPreferencesRef prefs, CFArrayRef } if (isA_CFArray(interfacesToSave) == NULL) { - SCLog(TRUE, LOG_DEBUG, CFSTR("interfacesToSave is NULL or not of correct type")); + SC_log(LOG_INFO, "No interfaces to save"); goto done; } SCPreferencesSetValue(prefs, INTERFACES, interfacesToSave); @@ -7713,10 +7999,10 @@ __SCNetworkInterfaceCreateWithNIPreferencesUsingBSDName(CFAllocatorRef allocator CFArrayRef if_list; SCNetworkInterfaceRef interface = NULL; CFStringRef defaultNetworkInterfacePath; - + /* initialize runtime */ pthread_once(&initialized, __SCNetworkInterfaceInitialize); - + if (ni_prefs == NULL) { defaultNetworkInterfacePath = CFStringCreateWithFormat(allocator, NULL, CFSTR("%@/%@"), PREFS_DEFAULT_DIR, NETWORK_INTERFACES_PREFS); ni_prefs = SCPreferencesCreate(allocator, CFSTR("SCNetworkInterface"), defaultNetworkInterfacePath); @@ -7725,22 +8011,22 @@ __SCNetworkInterfaceCreateWithNIPreferencesUsingBSDName(CFAllocatorRef allocator else { CFRetain(ni_prefs); } - + if_list = SCPreferencesGetValue(ni_prefs, INTERFACES); - + if (isA_CFArray(if_list) != NULL) { CFIndex idx; CFIndex count = CFArrayGetCount(if_list); - + for (idx = 0; idx < count; idx++) { CFDictionaryRef dict; CFStringRef tmp_bsdName; - + dict = CFArrayGetValueAtIndex(if_list, idx); if (isA_CFDictionary(dict) == NULL) { continue; } - + tmp_bsdName = CFDictionaryGetValue(dict, CFSTR(kSCNetworkInterfaceBSDName)); if (tmp_bsdName == NULL) { continue; @@ -7751,7 +8037,7 @@ __SCNetworkInterfaceCreateWithNIPreferencesUsingBSDName(CFAllocatorRef allocator } } } - + CFRelease(ni_prefs); return interface; } @@ -7766,9 +8052,8 @@ __SCNetworkInterfaceCreateMappingUsingBSDName(CFArrayRef interfaces) CFIndex count; count = CFArrayGetCount(interfaces); - if (count == 0) { - SCLog(TRUE, LOG_DEBUG, CFSTR("__SCNetworkInterfaceCreateMappingUsingBSDName: Interface count is 0")); + SC_log(LOG_INFO, "No interfaces"); return NULL; } mappingBSDToInterface = CFDictionaryCreateMutable(NULL, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); @@ -7778,7 +8063,7 @@ __SCNetworkInterfaceCreateMappingUsingBSDName(CFArrayRef interfaces) bsdName = SCNetworkInterfaceGetBSDName(interface); if (isA_CFString(bsdName) == NULL) { - SCLog(TRUE, LOG_DEBUG, CFSTR("__SCNetworkInterfaceCreateMappingUsingBSDName: BSDName is NULL or not of the correct type")); + SC_log(LOG_INFO, "No BSD name"); continue; } CFDictionaryAddValue(mappingBSDToInterface, bsdName, interface); @@ -7786,7 +8071,7 @@ __SCNetworkInterfaceCreateMappingUsingBSDName(CFArrayRef interfaces) if (CFDictionaryGetCount(mappingBSDToInterface) == 0) { CFRelease(mappingBSDToInterface); mappingBSDToInterface = NULL; - SCLog(TRUE, LOG_DEBUG, CFSTR("__SCNetworkInterfaceCreateMappingUsingBSDName: Setting mappingBSDToInterface to NULL since it doesn't contain any data")); + SC_log(LOG_INFO, "No mappings"); } return mappingBSDToInterface; diff --git a/SystemConfiguration.fproj/SCNetworkMigration.c b/SystemConfiguration.fproj/SCNetworkMigration.c index b56c246..955562c 100644 --- a/SystemConfiguration.fproj/SCNetworkMigration.c +++ b/SystemConfiguration.fproj/SCNetworkMigration.c @@ -1,15 +1,15 @@ /* - * Copyright (c) 2014 Apple Inc. All rights reserved. + * Copyright (c) 2014-2015 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ - * + * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. - * + * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, @@ -17,7 +17,7 @@ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. - * + * * @APPLE_LICENSE_HEADER_END@ */ @@ -53,6 +53,10 @@ #define PREFERENCES_PLIST_INDEX 0 #define NETWORK_INTERFACES_PLIST_INDEX 1 +#define kProtocolType CFSTR("Protocol Type") +#define kProtocolConfiguration CFSTR("Protocol Configuration") +#define kProtocolEnabled CFSTR("Protocol Enabled") + const CFStringRef kSCNetworkConfigurationMigrationActionKey = CFSTR("MigrationActionKey"); const CFStringRef kSCNetworkConfigurationRepair = CFSTR("ConfigurationRepair"); @@ -104,8 +108,8 @@ _SCNetworkConfigurationCopyMigrationPaths(CFDictionaryRef options) CFURLRef interfaces; CFMutableArrayRef migrationPaths = NULL; CFURLRef prefs; - - if (getenv(INSTALL_ENVIRONMENT) != NULL) { + + if (_SC_isInstallEnvironment()) { _sc_debug = 1; } _SCNetworkConfigurationCopyMigrationPathsWithBaseURL(NULL, &prefs, &interfaces); @@ -122,39 +126,38 @@ _SCNetworkConfigurationCopyMigrationPaths(CFDictionaryRef options) static Boolean _SCNetworkConfigurationRemoveConfigurationFiles(CFURLRef configDir) { - + char configPathString[PATH_MAX]; CFURLRef configPathURL = NULL; char configNetworkInterfacesPathString[PATH_MAX]; CFURLRef configNetworkInterfacesPathURL = NULL; - + _SCNetworkConfigurationCopyMigrationPathsWithBaseURL(configDir, &configPathURL, &configNetworkInterfacesPathURL); - - if(CFURLGetFileSystemRepresentation(configPathURL, TRUE, (UInt8*)configPathString, sizeof(configPathString)) == FALSE) { - SCLog(_sc_debug, LOG_NOTICE, CFSTR("_SCNetworkConfigurationRemoveConfigurationFiles: configPathString is NULL")); - } - else { + + if(!CFURLGetFileSystemRepresentation(configPathURL, + TRUE, + (UInt8*)configPathString, + sizeof(configPathString))) { + SC_log(LOG_NOTICE, "Cannot get file system representation for url: %@", configPathURL); + } else { if (remove(configPathString) != 0) { - SCLog(_sc_debug, LOG_NOTICE, CFSTR("_SCNetworkConfigurationRemoveConfigurationFiles: Removing file failed from: %s. Error is %d"), configPathString, errno); + SC_log(LOG_INFO, "remove(\"%s\") failed: %s", configPathString, strerror(errno)); } } - - if(CFURLGetFileSystemRepresentation(configNetworkInterfacesPathURL, TRUE, (UInt8*)configNetworkInterfacesPathString, sizeof(configNetworkInterfacesPathString)) == FALSE) { - SCLog(_sc_debug, LOG_NOTICE, CFSTR("_SCNetworkConfigurationRemoveConfigurationFiles: configNetwork")); - } - else { + CFRelease(configPathURL); + + if(!CFURLGetFileSystemRepresentation(configNetworkInterfacesPathURL, + TRUE, + (UInt8*)configNetworkInterfacesPathString, + sizeof(configNetworkInterfacesPathString))) { + SC_log(LOG_NOTICE, "Cannot get file system representation for url: %@", configNetworkInterfacesPathURL); + } else { if (remove(configNetworkInterfacesPathString) != 0) { - SCLog(_sc_debug, LOG_NOTICE, CFSTR("_SCNetworkConfigurationRemoveConfigurationFiles: Removing file failed from: %s. Error is %d"), configNetworkInterfacesPathString, errno); + SC_log(LOG_INFO, "remove(\"%s\") failed: %s", configNetworkInterfacesPathString, strerror(errno)); } } - - if (configPathURL != NULL) { - CFRelease(configPathURL); - } - if (configNetworkInterfacesPathURL != NULL) { - CFRelease(configNetworkInterfacesPathURL); - } - + CFRelease(configNetworkInterfacesPathURL); + return TRUE; } @@ -178,38 +181,51 @@ SCNetworkConfigurationCopyConfigurationFiles(CFURLRef configDir, CFURLRef targetPathURL = NULL; _SCNetworkConfigurationCopyMigrationPathsWithBaseURL(targetDir, &targetPathURL, &targetNetworkInterfacesPathURL); - - if (CFURLGetFileSystemRepresentation(targetPathURL, TRUE, (UInt8*)targetPathString, sizeof(targetPathString)) == FALSE) { - SCLog(_sc_debug, LOG_NOTICE, CFSTR("SCNetworkConfigurationCopyConfigurationFiles: targetPathString is NULL")); + + if (!CFURLGetFileSystemRepresentation(targetPathURL, + TRUE, + (UInt8*)targetPathString, + sizeof(targetPathString))) { + SC_log(LOG_NOTICE, "Cannot get file system representation for url: %@", targetPathURL); goto done; } - - if (CFURLGetFileSystemRepresentation(targetNetworkInterfacesPathURL, TRUE, (UInt8*)targetNetworkInterfacesPathString, sizeof(targetNetworkInterfacesPathString)) == FALSE) { - SCLog(_sc_debug, LOG_NOTICE, CFSTR("SCNetworkConfigurationCopyConfigurationFiles: targetNetworkInterfacesPathString is NULL")); + if (!CFURLGetFileSystemRepresentation(targetNetworkInterfacesPathURL, + TRUE, + (UInt8*)targetNetworkInterfacesPathString, + sizeof(targetNetworkInterfacesPathString))) { + SC_log(LOG_NOTICE, "Cannot get file system representation for url: %@", targetNetworkInterfacesPathURL); goto done; } - + if (configDir == NULL) { removeTargetFiles = TRUE; success = TRUE; goto done; } + _SCNetworkConfigurationCopyMigrationPathsWithBaseURL(configDir, &preferencesPathURL, &networkInterfacesPathURL); - if (CFURLGetFileSystemRepresentation(preferencesPathURL, TRUE, (UInt8*)preferencesPathString, sizeof(preferencesPathString)) == FALSE) { - SCLog(_sc_debug, LOG_NOTICE, CFSTR("SCNetworkConfigurationCopyConfigurationFiles: preferencesPathString is NULL")); + if (!CFURLGetFileSystemRepresentation(preferencesPathURL, + TRUE, + (UInt8*)preferencesPathString, + sizeof(preferencesPathString))) { + SC_log(LOG_NOTICE, "Cannot get file system representation for url: %@", preferencesPathURL); goto done; } - - - if (CFURLGetFileSystemRepresentation(networkInterfacesPathURL, TRUE, (UInt8*)networkInterfacesPathString, sizeof(networkInterfacesPathString)) == FALSE) { - SCLog(_sc_debug, LOG_DEBUG, CFSTR("SCNetworkConfigurationCopyConfigurationFiles: networkInterfacePathString is NULL")); + if (!CFURLGetFileSystemRepresentation(networkInterfacesPathURL, + TRUE, + (UInt8*)networkInterfacesPathString, + sizeof(networkInterfacesPathString))) { + SC_log(LOG_NOTICE, "Cannot get file system representation for url: %@", networkInterfacesPathURL); goto done; } - + state = copyfile_state_alloc(); if ((error = copyfile(preferencesPathString, targetPathString, state, COPYFILE_ALL)) != 0) { - SCLog(TRUE, LOG_ERR, CFSTR("SCNetworkConfigurationCopyConfigurationFiles: Copying failed from:%s to %s. Error is %d"), preferencesPathString, targetPathString, errno); + SC_log(LOG_NOTICE, "copyFile(\"%s\", \"%s\", ...) failed: %s", + preferencesPathString, + targetPathString, + strerror(errno)); copyfile_state_free(state); removeTargetFiles = TRUE; goto done; @@ -219,7 +235,10 @@ SCNetworkConfigurationCopyConfigurationFiles(CFURLRef configDir, networkInterfacesState = copyfile_state_alloc(); if ((error = copyfile(networkInterfacesPathString, targetNetworkInterfacesPathString, networkInterfacesState, COPYFILE_ALL)) != 0) { - SCLog(TRUE, LOG_ERR, CFSTR("SCNetworkConfigurationCopyConfigurationFiles: Copying failed from:%s to %s. Error is %d"), networkInterfacesPathString, targetNetworkInterfacesPathString, errno); + SC_log(LOG_NOTICE, "copyFile(\"%s\", \"%s\", ...) failed: %s", + networkInterfacesPathString, + targetNetworkInterfacesPathString, + strerror(errno)); copyfile_state_free(networkInterfacesState); removeTargetFiles = TRUE; goto done; @@ -262,12 +281,12 @@ _SCNetworkConfigurationMakePathIfNeeded(CFURLRef pathURL) struct stat sb; Boolean success = FALSE; - if (CFURLGetFileSystemRepresentation(pathURL, TRUE, (UInt8 *)path, sizeof(path)) == FALSE) { - SCLog(_sc_debug, LOG_NOTICE, CFSTR("_SCNetworkConfigurationMakePathIfNeeded: Could not get character array from target string")); + if (!CFURLGetFileSystemRepresentation(pathURL, TRUE, (UInt8 *)path, sizeof(path))) { + SC_log(LOG_NOTICE, "Cannot get file system representation for url: %@", pathURL); return success; } - SCLog(TRUE, LOG_NOTICE, CFSTR("_SCNetworkConfigurationMakePathIfNeeded: Creating path: %s"), path); - + SC_log(LOG_INFO, "creating path: %s", path); + newmask = S_IRWXU | S_IRGRP | S_IROTH | S_IXGRP | S_IXOTH; slen = strlen(path); @@ -285,11 +304,11 @@ _SCNetworkConfigurationMakePathIfNeeded(CFURLRef pathURL) if ( mkdir( thepath, newmask) ){ if ( errno == EEXIST || errno == EISDIR){ if ( stat(thepath, &sb) < 0){ - printf("stat returned value < 0\n"); + SC_log(LOG_ERR, "stat returned value < 0"); break; } } else { - printf("received error: %s\n", strerror(errno)); + SC_log(LOG_ERR, "received error: %s", strerror(errno)); break; } } @@ -305,17 +324,17 @@ __SCNetworkCreateDefaultPref(CFStringRef prefsID) SCPreferencesRef prefs; SCNetworkSetRef currentSet; CFStringRef model; - + prefs = SCPreferencesCreate(NULL, PLUGIN_ID, prefsID); if (prefs == NULL) { return NULL; } - + currentSet = SCNetworkSetCopyCurrent(prefs); if (currentSet == NULL) { CFBundleRef bundle; CFStringRef setName = NULL; - + currentSet = SCNetworkSetCreate(prefs); bundle = _SC_CFBundleGet(); if (bundle != NULL) { @@ -332,13 +351,13 @@ __SCNetworkCreateDefaultPref(CFStringRef prefsID) } SCNetworkSetEstablishDefaultConfiguration(currentSet); CFRelease(currentSet); - + model = SCPreferencesGetValue(prefs, MODEL); if (model == NULL) { model = _SC_hw_model(FALSE); SCPreferencesSetValue(prefs, MODEL, model); } - + return prefs; } @@ -351,11 +370,12 @@ __SCNetworkCreateDefaultNIPrefs(CFStringRef prefsID) CFArrayRef networkInterfaces; SCPreferencesRef ni_prefs; CFComparisonResult res; - - + + networkInterfaces = __SCNetworkInterfaceCopyAll_IONetworkInterface(); - + if (networkInterfaces == NULL) { + SC_log(LOG_NOTICE, "networkInterfaces is NULL"); return NULL; } if (prefsID == NULL) { @@ -364,40 +384,41 @@ __SCNetworkCreateDefaultNIPrefs(CFStringRef prefsID) else { CFRetain(prefsID); } - + ni_prefs = SCPreferencesCreate(NULL, PLUGIN_ID , prefsID); CFRelease(prefsID); - + if (ni_prefs == NULL) { + SC_log(LOG_NOTICE, "ni_prefs is NULL"); goto done; } - + interfaces = CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks); - + for (CFIndex idx = 0; idx < CFArrayGetCount(networkInterfaces); idx++) { CFIndex idx2 = 0; CFNumberRef if_type; CFNumberRef if_unit; SCNetworkInterfaceRef interface = CFArrayGetValueAtIndex(networkInterfaces, idx); CFDictionaryRef interfaceEntity = __SCNetworkInterfaceCopyStorageEntity(interface); - + if (interfaceEntity == NULL) { continue; } - + if_type = _SCNetworkInterfaceGetIOInterfaceType(interface); if_unit = _SCNetworkInterfaceGetIOInterfaceUnit(interface); - + if ((if_type == NULL) || (if_unit == NULL)) { CFRelease(interfaceEntity); continue; } - + for (idx2 = 0; idx2 < CFArrayGetCount(interfaces); idx2++) { CFNumberRef db_type; CFNumberRef db_unit; CFDictionaryRef dict = CFArrayGetValueAtIndex(interfaces, idx2); - + db_type = CFDictionaryGetValue(dict, CFSTR(kIOInterfaceType)); db_unit = CFDictionaryGetValue(dict, CFSTR(kIOInterfaceUnit)); res = CFNumberCompare(if_type, db_type, NULL); @@ -407,13 +428,13 @@ __SCNetworkCreateDefaultNIPrefs(CFStringRef prefsID) break; } } - + CFArrayInsertValueAtIndex(interfaces, idx2, interfaceEntity); CFRelease(interfaceEntity); - + } SCPreferencesSetValue(ni_prefs, INTERFACES, interfaces); - + model = SCPreferencesGetValue(ni_prefs, MODEL); if (model == NULL) { model = _SC_hw_model(FALSE); @@ -426,7 +447,7 @@ done: if (networkInterfaces != NULL) { CFRelease(networkInterfaces); } - + return ni_prefs; } @@ -445,14 +466,14 @@ _SCNetworkConfigurationPerformMigration(CFURLRef sourceDir, CFURLRef currentDir, Boolean removeTargetOnFailure = FALSE; CFURLRef sourceDirConfig = NULL; CFURLRef targetDirConfig = NULL; - - if (getenv(INSTALL_ENVIRONMENT) != NULL) { + + if (_SC_isInstallEnvironment()) { _sc_debug = 1; } // Both sourceDir and currentDir cannot be NULL because NULL value indicates using current system if (sourceDir == NULL && currentDir == NULL) { - SCLog(_sc_debug, LOG_NOTICE, CFSTR("_SCNetworkConfigurationPerformMigration: Both sourceDir and currentDir are NULL")); + SC_log(LOG_INFO, "Both sourceDir and currentDir are NULL"); goto done; } @@ -480,19 +501,20 @@ _SCNetworkConfigurationPerformMigration(CFURLRef sourceDir, CFURLRef currentDir, } // Source directory cannot be the same as Target Directory if (CFEqual(sourceDirConfig, targetDirConfig)) { - SCLog(_sc_debug, LOG_NOTICE, CFSTR("_SCNetworkConfigurationPerformMigration: Source directory cannot be the same as target directory")); + SC_log(LOG_INFO, "Source directory cannot be the same as target directory"); goto done; } - + if ((currentDirConfig == NULL) || (CFEqual(currentDirConfig, targetDirConfig) == FALSE)) { if (_SCNetworkConfigurationMakePathIfNeeded(targetDirConfig) == FALSE) { - SCLog(_sc_debug, LOG_NOTICE, CFSTR("_SCNetworkConfigurationPerformMigration: Could not create target directory as expected")); + SC_log(LOG_INFO, "Could not create target directory"); goto done; } if (SCNetworkConfigurationCopyConfigurationFiles(currentDirConfig, targetDirConfig) == FALSE) { - SCLog(_sc_debug, LOG_NOTICE, CFSTR("_SCNetworkConfigurationPerformMigration: Could not copy configuration files from %@ to %@"), - currentDirConfig, targetDirConfig); + SC_log(LOG_INFO, "Could not copy configuration files from \"%@\" to \"%@\"", + currentDirConfig, + targetDirConfig); } else if (currentDirConfig != NULL) { removeTargetOnFailure = TRUE; // Configuration files were copied over to target directory @@ -504,13 +526,13 @@ _SCNetworkConfigurationPerformMigration(CFURLRef sourceDir, CFURLRef currentDir, // If both source and current configurations point to current system, then no migration needs to be done. if ((currentDirConfig != NULL) && (CFEqual(sourceDirConfig, currentDirConfig) == TRUE)) { - SCLog(_sc_debug, LOG_NOTICE, CFSTR("_SCNetworkConfigurationPerformMigration: both source and current configurations point to same path ... No migration needs to be done")); + SC_log(LOG_INFO, "No migration needed, source and current configurations point to same path"); migrationComplete = TRUE; } else { migrationComplete = _SCNetworkConfigurationMigrateConfiguration(sourceDirConfig, targetDirConfig); } - SCLog(TRUE, LOG_NOTICE, CFSTR("Migration %s"), migrationComplete ? "complete" : "failed"); + SC_log(LOG_NOTICE, "Migration %s", migrationComplete ? "complete" : "failed"); if (migrationComplete == TRUE) { paths = _SCNetworkConfigurationCopyMigrationPaths(NULL); } @@ -546,17 +568,16 @@ _SCNetworkConfigurationMigrateIsFilePresent(CFURLRef filePath) struct stat statStruct = {0, }; if (filePath == NULL) { - SCLog(_sc_debug, LOG_NOTICE, CFSTR("_SCNetworkConfigurationMigrateIsFilePresent: filePath is NULL")); + SC_log(LOG_DEBUG, "filePath is NULL"); goto done; } - if (CFURLGetFileSystemRepresentation(filePath, TRUE, (UInt8*) filePathStr, sizeof(filePathStr)) == FALSE) { - SCLog(_sc_debug, LOG_NOTICE, CFSTR("_SCNetworkConfigurationMigrateIsFilePresent: Couldn't get file system representation\n")); + if (!CFURLGetFileSystemRepresentation(filePath, TRUE, (UInt8*) filePathStr, sizeof(filePathStr))) { + SC_log(LOG_NOTICE, "Cannot get file system representation for url: %@", filePath); goto done; } statResult = stat(filePathStr, &statStruct); - if (statResult == 0) { fileExists = TRUE; } @@ -575,7 +596,7 @@ __SCNetworkConfigurationMigrateConfigurationFilesPresent(CFURLRef baseURL, CFArr CFURLRef prefs; if (baseURL == NULL) { - SCLog(_sc_debug, LOG_NOTICE, CFSTR("__SCNetworkConfigurationMigrateConfigurationFilesPresent: baseURL is NULL")); + SC_log(LOG_INFO, "No base migration URL"); goto done; } @@ -592,14 +613,14 @@ __SCNetworkConfigurationMigrateConfigurationFilesPresent(CFURLRef baseURL, CFArr if ((*migrationPaths == NULL) || ((count = CFArrayGetCount(*migrationPaths)) == 0)) { - SCLog(_sc_debug, LOG_NOTICE, CFSTR("__SCNetworkConfigurationMigrateConfigurationFilesPresent: migrationPath is NULL or number of elements in migrationPath array is 0")); + SC_log(LOG_INFO, "No migration paths"); goto done; } for (CFIndex idx = 0; idx < count; idx++) { filePath = CFArrayGetValueAtIndex(*migrationPaths, idx); if (_SCNetworkConfigurationMigrateIsFilePresent(filePath) == FALSE) { - SCLog(_sc_debug, LOG_NOTICE, CFSTR("__SCNetworkConfigurationMigrateConfigurationFilesPresent: File not present: %@"), filePath); + SC_log(LOG_INFO, "Required migration file not present: %@", filePath); goto done; } } @@ -611,7 +632,7 @@ done: static CFMutableArrayRef -_SCNetworkInterfaceCopyInterfacesFilteredByBuiltinWithPreferences (SCPreferencesRef ni_prefs, Boolean isBuiltin) +_SCNetworkInterfaceCopyInterfacesFilteredByBuiltinWithPreferences(SCPreferencesRef ni_prefs, Boolean isBuiltin) { CFIndex count = 0; SCNetworkInterfaceRef interface; @@ -620,7 +641,7 @@ _SCNetworkInterfaceCopyInterfacesFilteredByBuiltinWithPreferences (SCPrefere interfaceList = __SCNetworkInterfaceCopyStoredWithPreferences(ni_prefs); if (interfaceList == NULL) { - SCLog(_sc_debug, LOG_NOTICE, CFSTR("_SCNetworkInterfaceCopyInterfacesFilteredByBuiltinWithPreferences: interfaceList is NULL")); + SC_log(LOG_INFO, "No interfaces"); goto done; } @@ -651,22 +672,20 @@ _SCNetworkInterfaceStorageCopyMaxUnitPerInterfaceType(SCPreferencesRef ni_prefs) CFIndex count = 0; CFArrayRef ifList = NULL; SCNetworkInterfaceRef interface; - CFMutableDictionaryRef InterfaceTypeToMaxUnitMapping = NULL; + CFMutableDictionaryRef interfaceTypeToMaxUnitMapping = NULL; CFNumberRef type; CFNumberRef unit; ifList = __SCNetworkInterfaceCopyStoredWithPreferences(ni_prefs); - if (ifList == NULL) { - SCLog(TRUE, LOG_ERR, CFSTR("_SCNetworkInterfaceStorageCopyMaxUnitPerInterfaceType: ifList is NULL")); - return 0; + SC_log(LOG_INFO, "No interfaces"); + return NULL; } - InterfaceTypeToMaxUnitMapping = CFDictionaryCreateMutable(NULL, 0, + interfaceTypeToMaxUnitMapping = CFDictionaryCreateMutable(NULL, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); count = CFArrayGetCount(ifList); - for (CFIndex idx = 0; idx < count; idx++) { cfMaxUnit = NULL; interface = CFArrayGetValueAtIndex(ifList, idx); @@ -676,21 +695,20 @@ _SCNetworkInterfaceStorageCopyMaxUnitPerInterfaceType(SCPreferencesRef ni_prefs) } type = _SCNetworkInterfaceGetIOInterfaceType(interface); - if (isA_CFNumber(type) == NULL) { - SCLog(_sc_debug, LOG_NOTICE, CFSTR("_SCNetworkInterfaceStorageCopyMaxUnitPerInterfaceType: type is NULL")); + SC_log(LOG_INFO, "No interface type"); continue; } - if (CFDictionaryContainsKey(InterfaceTypeToMaxUnitMapping, type) == FALSE) { + if (CFDictionaryContainsKey(interfaceTypeToMaxUnitMapping, type) == FALSE) { int temp = 0; cfMaxUnit = CFNumberCreate(NULL, kCFNumberIntType, &temp); - CFDictionaryAddValue(InterfaceTypeToMaxUnitMapping, type, cfMaxUnit); + CFDictionaryAddValue(interfaceTypeToMaxUnitMapping, type, cfMaxUnit); CFRelease(cfMaxUnit); } if (cfMaxUnit == NULL) { - cfMaxUnit = CFDictionaryGetValue(InterfaceTypeToMaxUnitMapping, type); + cfMaxUnit = CFDictionaryGetValue(interfaceTypeToMaxUnitMapping, type); } unit = _SCNetworkInterfaceGetIOInterfaceUnit(interface); @@ -700,13 +718,13 @@ _SCNetworkInterfaceStorageCopyMaxUnitPerInterfaceType(SCPreferencesRef ni_prefs) } if (CFNumberCompare(unit, cfMaxUnit, NULL) == kCFCompareGreaterThan) { - CFDictionarySetValue(InterfaceTypeToMaxUnitMapping, type, unit); + CFDictionarySetValue(interfaceTypeToMaxUnitMapping, type, unit); } } if (ifList != NULL) { CFRelease(ifList); } - return InterfaceTypeToMaxUnitMapping; + return interfaceTypeToMaxUnitMapping; } static CFMutableDictionaryRef @@ -722,14 +740,14 @@ _SCNetworkConfigurationCopyBuiltinMapping (SCPreferencesRef sourcePrefs, SCPrefe sourceBuiltinInterfaces = _SCNetworkInterfaceCopyInterfacesFilteredByBuiltinWithPreferences(sourcePrefs, TRUE); if (isA_CFArray(sourceBuiltinInterfaces) == NULL) { - SCLog(_sc_debug, LOG_NOTICE, CFSTR("_SCNetworkConfigurationCopyBuiltinMapping: sourceBuiltinInterfaces is NULL")); + SC_log(LOG_INFO, "No source built-in interfaces"); goto done; } sourceBuiltinInterfaceCount = CFArrayGetCount(sourceBuiltinInterfaces); targetBuiltinInterfaces = _SCNetworkInterfaceCopyInterfacesFilteredByBuiltinWithPreferences(targetPrefs, TRUE); if (isA_CFArray(targetBuiltinInterfaces) == NULL) { - SCLog(_sc_debug, LOG_NOTICE, CFSTR("_SCNetworkConfigurationCopyBuiltinMapping: targetBuiltinInterfaces is NULL")); + SC_log(LOG_INFO, "No target built-in interfaces"); goto done; } targetBuiltinInterfaceCount = CFArrayGetCount(targetBuiltinInterfaces); @@ -770,7 +788,7 @@ _SCNetworkConfigurationCopyExternalInterfaceMapping (SCPreferencesRef sourcePref CFNumberRef cfMaxTargetUnit = NULL; CFNumberRef currentInterfaceUnit = NULL; CFMutableDictionaryRef externalMapping = NULL; - CFMutableDictionaryRef InterfaceTypeToMaxUnitMapping = NULL; + CFMutableDictionaryRef interfaceTypeToMaxUnitMapping = NULL; int maxTargetUnit; int newTargetUnit; CFIndex sourceExternalInterfaceCount = 0; @@ -783,23 +801,22 @@ _SCNetworkConfigurationCopyExternalInterfaceMapping (SCPreferencesRef sourcePref sourceExternalInterfaces = _SCNetworkInterfaceCopyInterfacesFilteredByBuiltinWithPreferences(sourcePref, FALSE); if (isA_CFArray(sourceExternalInterfaces) == NULL) { - SCLog(_sc_debug, LOG_NOTICE, CFSTR("_SCNetworkConfigurationCopyExternalInterfaceMapping: sourceExternalInterfaces is NULL")); + SC_log(LOG_INFO, "No source external interfaces"); goto done; } sourceExternalInterfaceCount = CFArrayGetCount(sourceExternalInterfaces); - if (sourceExternalInterfaceCount == 0) { - SCLog(_sc_debug, LOG_NOTICE, CFSTR("_SCNetworkConfigurationCopyExternalInterfaceMapping: sourceExternalInterfaceCount is 0")); + SC_log(LOG_INFO, "No source external interfaces"); goto done; } targetExternalInterfaces = _SCNetworkInterfaceCopyInterfacesFilteredByBuiltinWithPreferences(targetPrefs, FALSE); if (isA_CFArray(targetExternalInterfaces) == NULL) { - SCLog(_sc_debug, LOG_NOTICE, CFSTR("_SCNetworkConfigurationCopyExternalInterfaceMapping: targetExternalInterfaces is NULL")); + SC_log(LOG_INFO, "No target external interfaces"); goto done; } - InterfaceTypeToMaxUnitMapping = _SCNetworkInterfaceStorageCopyMaxUnitPerInterfaceType(targetPrefs); + interfaceTypeToMaxUnitMapping = _SCNetworkInterfaceStorageCopyMaxUnitPerInterfaceType(targetPrefs); externalMapping = CFDictionaryCreateMutable(NULL, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); // Map all external interfaces which exist in both source and target @@ -822,7 +839,7 @@ _SCNetworkConfigurationCopyExternalInterfaceMapping (SCPreferencesRef sourcePref // Create new mappings for external source interfaces which don't exist in the target type = _SCNetworkInterfaceGetIOInterfaceType(sourceInterface); - cfMaxTargetUnit = CFDictionaryGetValue(InterfaceTypeToMaxUnitMapping, type); + cfMaxTargetUnit = CFDictionaryGetValue(interfaceTypeToMaxUnitMapping, type); if (cfMaxTargetUnit != NULL) { CFNumberGetValue(cfMaxTargetUnit, kCFNumberIntType, &maxTargetUnit); newTargetUnit = maxTargetUnit + 1; @@ -832,11 +849,11 @@ _SCNetworkConfigurationCopyExternalInterfaceMapping (SCPreferencesRef sourcePref } cfMaxTargetUnit = CFNumberCreate(NULL, kCFNumberIntType, &newTargetUnit); - CFDictionarySetValue(InterfaceTypeToMaxUnitMapping, type, cfMaxTargetUnit); + CFDictionarySetValue(interfaceTypeToMaxUnitMapping, type, cfMaxTargetUnit); targetInterface = (SCNetworkInterfaceRef)__SCNetworkInterfaceCreateCopy(NULL, sourceInterface, NULL, NULL); - SCLog(_sc_debug, LOG_NOTICE, CFSTR("_SCNetworkConfigurationCopyExternalInterfaceMapping: sourceInterface: %p, target Interface: %p"), sourceInterface, targetInterface); + SC_log(LOG_DEBUG, "sourceInterface: %p, target Interface: %p", sourceInterface, targetInterface); currentInterfaceUnit = _SCNetworkInterfaceGetIOInterfaceUnit(targetInterface); @@ -861,8 +878,8 @@ done: if (targetExternalInterfaces != NULL) { CFRelease(targetExternalInterfaces); } - if (InterfaceTypeToMaxUnitMapping != NULL) { - CFRelease(InterfaceTypeToMaxUnitMapping); + if (interfaceTypeToMaxUnitMapping != NULL) { + CFRelease(interfaceTypeToMaxUnitMapping); } return externalMapping; } @@ -932,7 +949,7 @@ __SCNetworkConfigurationInterfaceNameIsEquiv(CFStringRef interfaceName1, CFStrin CFStringRef interfaceArray[] = { CFSTR("iPhone"), CFSTR("iPad"), CFSTR("iPod"), CFSTR("AppleTV") }; const int interfaceCount = sizeof(interfaceArray) / sizeof(CFStringRef); CFStringRef portSuffix = CFSTR(", Port 1"); - + if ((isA_CFString(interfaceName1) != NULL) && (isA_CFString(interfaceName2) != NULL)) { if (CFEqual(interfaceName1, interfaceName2) == FALSE) { @@ -943,21 +960,21 @@ __SCNetworkConfigurationInterfaceNameIsEquiv(CFStringRef interfaceName1, CFStrin (CFEqual(interfaceName2, CFSTR("Wi-Fi"))))) { return TRUE; } - + if (((CFEqual(interfaceName1, CFSTR("Ethernet"))) || (CFEqual(interfaceName1, CFSTR("Ethernet 1")))) && ((CFEqual(interfaceName2, CFSTR("Ethernet"))) || (CFEqual(interfaceName2, CFSTR("Ethernet 1"))))) { return TRUE; } - + if (((CFStringHasSuffix(interfaceName1, portSuffix) == TRUE) && (CFStringCompareWithOptions(interfaceName1, interfaceName2, CFRangeMake(0, (CFStringGetLength(interfaceName1) - CFStringGetLength(portSuffix))), 0) == kCFCompareEqualTo)) || ((CFStringHasSuffix(interfaceName2, portSuffix) == TRUE) && (CFStringCompareWithOptions(interfaceName2, interfaceName1, CFRangeMake(0, (CFStringGetLength(interfaceName2) - CFStringGetLength(portSuffix))), 0) == kCFCompareEqualTo))) { return TRUE; } - + for (CFIndex idx = 0; idx < interfaceCount; idx++) { CFStringRef tempInterfaceName = interfaceArray[idx]; if ((CFEqual(interfaceName1, tempInterfaceName) == TRUE || @@ -972,7 +989,7 @@ __SCNetworkConfigurationInterfaceNameIsEquiv(CFStringRef interfaceName1, CFStrin return TRUE; } } - + return FALSE; } @@ -989,6 +1006,9 @@ typedef struct { Boolean* isValid; CFMutableArrayRef interfaceToBeRemoved; // SCNetworkInterfaceRef. Services containing the interface will be removed CFMutableArrayRef interfaceToBeReplaced;// SCNetworkInterfaceRef. Services containing the interface will be replaced with default service + CFMutableArrayRef interfacePreserveServiceInformation; // SCNetworkInterfaceRef. Services containing the interface will be replaced with new service which has same configuration as the current service with issue. + CFMutableDictionaryRef bsdNameServiceProtocolPreserveMapping; + SCPreferencesRef prefs; Boolean repair; } SCNetworkConfigurationValidityContext; @@ -1008,7 +1028,8 @@ _SCNetworkConfigurationValidateInterface (const void *key, const void *value, vo CFStringRef serviceInterfaceUserDefinedName = NULL; CFMutableArrayRef interfaceToBeRemoved = ctx->interfaceToBeRemoved; CFMutableArrayRef interfaceToBeReplaced = ctx->interfaceToBeReplaced; - + CFMutableArrayRef interfacePreserveServiceInformation = ctx->interfacePreserveServiceInformation; + // No work needs to be done if we have already made determination that configuration somewhere is not valid, // or we don't intend to repair invalid configuration. if ((*ctx->isValid == FALSE) && (repair == FALSE)) { @@ -1022,8 +1043,8 @@ _SCNetworkConfigurationValidateInterface (const void *key, const void *value, vo (((bsdNameToBondServices != NULL) && (CFDictionaryContainsKey(bsdNameToBondServices, bsdName) == FALSE))) && (((bsdNameToVLANServices != NULL) && (CFDictionaryContainsKey(bsdNameToVLANServices, bsdName) == FALSE)))) { // Not a virtual interface - SCLog(_sc_debug, LOG_NOTICE, CFSTR("_SCNetworkConfigurationValidateInterface: There is no real interface with bsd name: %@ for service"), bsdName); - + SC_log(LOG_INFO, "No real interface with BSD name (%@) for service", bsdName); + if (repair == TRUE) { CFArrayAppendValue(interfaceToBeRemoved, serviceInterface); } @@ -1032,13 +1053,21 @@ _SCNetworkConfigurationValidateInterface (const void *key, const void *value, vo return; } - // TODO: Need to compare between both SCNetworkInterfaceRefs + // Need to compare between both SCNetworkInterfaceRefs interfaceUserDefinedName = __SCNetworkInterfaceGetUserDefinedName(interface); serviceInterfaceUserDefinedName = __SCNetworkInterfaceGetUserDefinedName(serviceInterface); if (__SCNetworkConfigurationInterfaceNameIsEquiv(interfaceUserDefinedName, serviceInterfaceUserDefinedName) == FALSE) { - SCLog(_sc_debug, LOG_NOTICE, CFSTR("_SCNetworkConfigurationValidateInterface: Interface user defined name: %@ doesn't match service interface user defined name: %@"), interfaceUserDefinedName, serviceInterfaceUserDefinedName); + SC_log(LOG_INFO, "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) == TRUE) { + SC_log(LOG_NOTICE, "serviceInterfaceUserDefinedName: %@ is the localized key for interface name: %@", serviceInterfaceUserDefinedName, interfaceUserDefinedName); + CFArrayAppendValue(interfacePreserveServiceInformation, serviceInterface); + } // Add service interface to the interfaceToBeReplaced list if (isA_CFArray(interfaceToBeReplaced) != NULL) { CFArrayAppendValue(interfaceToBeReplaced, interface); @@ -1085,7 +1114,7 @@ _SCNetworkConfigurationCreateBuiltinInterfaceServices(SCPreferencesRef pref, interfaces = __SCNetworkInterfaceCopyStoredWithPreferences(ni_pref); if (interfaces == NULL) { - SCLog(_sc_debug, LOG_NOTICE, CFSTR("_SCNetworkConfigurationCreateBuiltinInterfaceServices: interfaces is NULL or not of the correct type")); + SC_log(LOG_NOTICE, "No interfaces"); goto done; } @@ -1097,7 +1126,7 @@ _SCNetworkConfigurationCreateBuiltinInterfaceServices(SCPreferencesRef pref, interfaces = __SCNetworkServiceCopyAllInterfaces(pref); if (interfaces == NULL) { - SCLog(_sc_debug, LOG_NOTICE, CFSTR("_SCNetworkConfigurationCreateBuiltinInterfaceServices: interfaces is NULL for configPref or not of the correct type")); + SC_log(LOG_INFO, "No interfaces"); goto done; } mappingServiceBSDNameToInterface = __SCNetworkInterfaceCreateMappingUsingBSDName(interfaces); @@ -1120,7 +1149,7 @@ _SCNetworkConfigurationCreateBuiltinInterfaceServices(SCPreferencesRef pref, interface = CFArrayGetValueAtIndex(interfacesWithoutService, idx); if (__SCNetworkServiceCreate(pref, interface, NULL) == FALSE) { - SCLog(_sc_debug, LOG_NOTICE, CFSTR("_SCNetworkConfigurationCreateBuiltinInterfaceServices: Could not add service for interface: %@"), interface); + SC_log(LOG_INFO, "Could not add service for interface: %@", interface); success = FALSE; } } @@ -1139,37 +1168,61 @@ done: } static void -add_default_service(const void *value, void *context) +add_service(const void *value, void *context) { + SCNetworkConfigurationValidityContext *ctx = (SCNetworkConfigurationValidityContext *)context; SCNetworkSetRef currentSet = NULL; + Boolean enabled; SCNetworkInterfaceRef interface = (SCNetworkInterfaceRef)value; - SCPreferencesRef prefs = (SCPreferencesRef)context; + CFDictionaryRef bsdNameServiceProtocolMapping = ctx->bsdNameServiceProtocolPreserveMapping; + SCPreferencesRef prefs = ctx->prefs; SCNetworkServiceRef service; - + CFStringRef bsdName = SCNetworkInterfaceGetBSDName(interface); + CFArrayRef protocolArray = NULL; + + if (isA_CFString(bsdName)) { + protocolArray = CFDictionaryGetValue(bsdNameServiceProtocolMapping, bsdName); + } service = SCNetworkServiceCreate(prefs, interface); - if (service == NULL) { - SCLog(_sc_debug, LOG_NOTICE, CFSTR("add_default_service: Could not create new service")); + SC_log(LOG_INFO, "Could not create new service"); goto done; } - + if (SCNetworkServiceEstablishDefaultConfiguration(service) == FALSE) { SCNetworkServiceRemove(service); - SCLog(_sc_debug, LOG_NOTICE, CFSTR("add_default_service: SCNetworkServiceEstablishDefaultConfiguration failed")); + SC_log(LOG_INFO, "SCNetworkServiceEstablishDefaultConfiguration() failed"); goto done; } + + if (protocolArray != NULL) { + CFIndex protocolArrayCount = CFArrayGetCount(protocolArray); + + for (CFIndex idx = 0; idx < protocolArrayCount; idx++) { + CFDictionaryRef protocolInfo = CFArrayGetValueAtIndex(protocolArray, idx); + CFDictionaryRef configuration = CFDictionaryGetValue(protocolInfo, kProtocolConfiguration); + CFStringRef protocolType = CFDictionaryGetValue(protocolInfo, kProtocolType); + CFBooleanRef cfEnabled = CFDictionaryGetValue(protocolInfo, kProtocolEnabled); + if (cfEnabled) { + enabled = CFBooleanGetValue(cfEnabled); + } else { + enabled = FALSE; + } + __SCNetworkServiceAddProtocolToService(service, protocolType, configuration, enabled); + } + } // Add Service to current set currentSet = SCNetworkSetCopyCurrent(prefs); if (currentSet == NULL) { SCNetworkServiceRemove(service); - SCLog(_sc_debug, LOG_NOTICE, CFSTR("add_default_service: Could not find current set")); + SC_log(LOG_INFO, "Could not find current set"); goto done; } - + if (SCNetworkSetAddService(currentSet, service) == FALSE) { SCNetworkServiceRemove(service); - SCLog(_sc_debug, LOG_NOTICE, CFSTR("add_default_service: Could not add service to current set")); + SC_log(LOG_INFO, "Could not add service to current set"); goto done; } done: @@ -1181,15 +1234,62 @@ done: } } +static void +create_bsd_name_service_protocol_mapping(const void *value, void *context) +{ + SCNetworkConfigurationValidityContext *ctx = (SCNetworkConfigurationValidityContext *)context; + CFArrayRef interfacePreserveServiceInformation = ctx->interfacePreserveServiceInformation; + CFMutableDictionaryRef bsdNameServiceProtocolMapping = ctx->bsdNameServiceProtocolPreserveMapping; + SCNetworkInterfaceRef interface; + SCNetworkServiceRef service = (SCNetworkServiceRef)value; + + interface = SCNetworkServiceGetInterface(service); + + if (CFArrayContainsValue(interfacePreserveServiceInformation, CFRangeMake(0, CFArrayGetCount(interfacePreserveServiceInformation)), interface)) { + CFStringRef bsdName = SCNetworkInterfaceGetBSDName(interface); + if (isA_CFString(bsdName)) { + + CFArrayRef protocols = SCNetworkServiceCopyProtocols(service); + if (protocols != NULL) { + CFMutableArrayRef protocolArray = CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks); + CFIndex protocolCount = CFArrayGetCount(protocols); + + for (CFIndex idx = 0; idx < protocolCount; idx++) { + SCNetworkProtocolRef protocol = CFArrayGetValueAtIndex(protocols, idx); + CFDictionaryRef configuration = SCNetworkProtocolGetConfiguration(protocol); + CFStringRef protocolType = SCNetworkProtocolGetProtocolType(protocol); + Boolean enabled = SCNetworkProtocolGetEnabled(protocol); + + if (configuration == NULL || protocolType == NULL) { + continue; + } + CFMutableDictionaryRef protocolInfo = CFDictionaryCreateMutable(NULL, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); + + CFDictionaryAddValue(protocolInfo, kProtocolType, protocolType); + CFDictionaryAddValue(protocolInfo, kProtocolConfiguration, configuration); + CFDictionaryAddValue(protocolInfo, kProtocolEnabled, enabled ? kCFBooleanTrue : kCFBooleanFalse); + CFArrayAppendValue(protocolArray, protocolInfo); + CFRelease(protocolInfo); + } + CFDictionaryAddValue(bsdNameServiceProtocolMapping, bsdName, protocolArray); + CFRelease(protocols); + CFRelease(protocolArray); + } + + } + } +} + static void remove_service(const void *value, void *context) { + SCNetworkConfigurationValidityContext *ctx = (SCNetworkConfigurationValidityContext *)context; SCNetworkInterfaceRef interface; SCNetworkServiceRef service = (SCNetworkServiceRef)value; - CFArrayRef toBeRemoved = (CFArrayRef)context; - + CFArrayRef toBeRemoved = ctx->interfaceToBeRemoved; + interface = SCNetworkServiceGetInterface(service); - + if (CFArrayContainsValue(toBeRemoved, CFRangeMake(0, CFArrayGetCount(toBeRemoved)), interface)) { SCNetworkServiceRemove(service); } @@ -1215,20 +1315,20 @@ _SCNetworkConfigurationSaveOldConfiguration(SCPreferencesRef prefs) int month; int second; int year; - + currentCalendar = CFCalendarCopyCurrent(); absoluteTime = CFAbsoluteTimeGetCurrent(); - + if (CFCalendarDecomposeAbsoluteTime(currentCalendar, absoluteTime, "yMdHms", &year, &month, &day, &hour, &minute, &second) == FALSE) { - SCLog(_sc_debug, LOG_NOTICE, CFSTR("_SCNetworkConfigurationSaveOldConfiguration: Cannot decompose absolute time")); + SC_log(LOG_INFO, "CFCalendarDecomposeAbsoluteTime() failed"); } keyListCount = (CFIndex)sizeof(keyList)/sizeof(CFStringRef); - + for (CFIndex idx = 0; idx < keyListCount; idx++) { CFStringRef newKey; CFTypeRef value = SCPreferencesGetValue(prefs, keyList[idx]); - + if (value != NULL) { newKey = CFStringCreateWithFormat(NULL, NULL, CFSTR("%d-%d-%d %d:%d:%d : %@"), @@ -1243,13 +1343,14 @@ _SCNetworkConfigurationSaveOldConfiguration(SCPreferencesRef prefs) static Boolean _SCNetworkConfigurationRepairUsingPreferences(SCPreferencesRef prefs, - CFArrayRef interfaceToBeRemoved, - CFArrayRef interfaceToBeReplaced) + SCNetworkConfigurationValidityContext *context) { CFIndex removeCount; CFIndex replaceCount; CFArrayRef serviceList; - + CFArrayRef interfaceToBeRemoved = context->interfaceToBeRemoved; + CFArrayRef interfaceToBeReplaced = context->interfaceToBeReplaced; + removeCount = CFArrayGetCount(interfaceToBeRemoved); replaceCount = CFArrayGetCount(interfaceToBeReplaced); if (removeCount == 0 && @@ -1259,11 +1360,11 @@ _SCNetworkConfigurationRepairUsingPreferences(SCPreferencesRef prefs, } // Backup current preferences before making changes _SCNetworkConfigurationSaveOldConfiguration(prefs); - + serviceList = SCNetworkServiceCopyAll(prefs); - CFArrayApplyFunction(serviceList, CFRangeMake(0, CFArrayGetCount(serviceList)), remove_service, (void*)interfaceToBeRemoved); - - CFArrayApplyFunction(interfaceToBeReplaced, CFRangeMake(0, replaceCount), add_default_service, (void*)prefs); + CFArrayApplyFunction(serviceList, CFRangeMake(0, CFArrayGetCount(serviceList)), create_bsd_name_service_protocol_mapping, context); + CFArrayApplyFunction(serviceList, CFRangeMake(0, CFArrayGetCount(serviceList)), remove_service, (void*)context); + CFArrayApplyFunction(interfaceToBeReplaced, CFRangeMake(0, replaceCount), add_service, (void*)context); CFRelease(serviceList); return TRUE; } @@ -1275,17 +1376,17 @@ validate_bridge(const void *value, void *context) CFArrayRef memberInterfaces = SCBridgeInterfaceGetMemberInterfaces(bridge); CFMutableArrayRef memberInterfacesMutable = CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks); SCPreferencesRef ni_prefs = (SCPreferencesRef)context; - + for (CFIndex idx = 0; idx < CFArrayGetCount(memberInterfaces); idx++) { CFStringRef bsdName; SCNetworkInterfaceRef interface = (SCNetworkInterfaceRef)CFArrayGetValueAtIndex(memberInterfaces, idx); SCNetworkInterfaceRef memberInterface; - + bsdName = SCNetworkInterfaceGetBSDName(interface); if (bsdName == NULL) { continue; } - + // Check if member interface is present memberInterface = __SCNetworkInterfaceCreateWithNIPreferencesUsingBSDName(NULL, ni_prefs, bsdName); if (memberInterface != NULL) { @@ -1293,9 +1394,9 @@ validate_bridge(const void *value, void *context) CFRelease(memberInterface); } } - + if (CFArrayGetCount(memberInterfacesMutable) == 0) { - SCLog(_sc_debug, LOG_NOTICE, CFSTR("validate_bridge: Removing invalid bridge configuration: %@"), bridge); + SC_log(LOG_INFO, "Removing invalid bridge configuration: %@", bridge); SCBridgeInterfaceRemove(bridge); } else { @@ -1311,17 +1412,17 @@ validate_bond(const void *value, void *context) CFArrayRef memberInterfaces = SCBondInterfaceGetMemberInterfaces(bond); CFMutableArrayRef memberInterfacesMutable = CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks); SCPreferencesRef ni_prefs = (SCPreferencesRef)context; - + for (CFIndex idx = 0; idx < CFArrayGetCount(memberInterfaces); idx++) { CFStringRef bsdName; SCNetworkInterfaceRef interface = (SCNetworkInterfaceRef)CFArrayGetValueAtIndex(memberInterfaces, idx); SCNetworkInterfaceRef memberInterface; - + bsdName = SCNetworkInterfaceGetBSDName(interface); if (bsdName == NULL) { continue; } - + // Check if member interface is present memberInterface = __SCNetworkInterfaceCreateWithNIPreferencesUsingBSDName(NULL, ni_prefs, bsdName); if (memberInterface != NULL) { @@ -1329,9 +1430,9 @@ validate_bond(const void *value, void *context) CFRelease(memberInterface); } } - + if (CFArrayGetCount(memberInterfacesMutable) == 0) { - SCLog(_sc_debug, LOG_NOTICE, CFSTR("validate_bond: Removing invalid bond configuration: %@"), bond); + SC_log(LOG_INFO, "Removing invalid bond configuration: %@", bond); SCBondInterfaceRemove(bond); } else { @@ -1350,15 +1451,15 @@ validate_vlan(const void *value, void *context) SCPreferencesRef ni_prefs = (SCPreferencesRef)context; SCNetworkInterfaceRef physicalInterface; SCVLANInterfaceRef vlan = (SCVLANInterfaceRef)value; - + physicalInterface = SCVLANInterfaceGetPhysicalInterface(vlan); bsdName = SCNetworkInterfaceGetBSDName(physicalInterface); - + if (bsdName == NULL) { isValid = FALSE; goto done; } - + // Check if the physical interface is present interface = __SCNetworkInterfaceCreateWithNIPreferencesUsingBSDName(NULL, ni_prefs, bsdName); if (interface == NULL) { @@ -1366,16 +1467,16 @@ validate_vlan(const void *value, void *context) goto done; } CFRelease(interface); - + done: if (isValid == FALSE) { - SCLog(_sc_debug, LOG_NOTICE, CFSTR("validate_vlan: Removing invalid VLAN configuration: %@"), vlan); + SC_log(LOG_INFO, "Removing invalid VLAN configuration: %@", vlan); SCVLANInterfaceRemove(vlan); } } -static Boolean -_SCNetworkConfigurationCheckValidityUsingPreferences(SCPreferencesRef prefs, +Boolean +_SCNetworkConfigurationCheckValidityWithPreferences(SCPreferencesRef prefs, SCPreferencesRef ni_prefs, CFDictionaryRef options) { @@ -1386,61 +1487,83 @@ _SCNetworkConfigurationCheckValidityUsingPreferences(SCPreferencesRef prefs, CFDictionaryRef bsdNameToVLANServices = NULL; SCNetworkConfigurationValidityContext context; CFArrayRef interfaces = NULL; + CFMutableArrayRef interfaceToBeRemoved = NULL; + CFMutableArrayRef interfaceToBeReplaced = NULL; + CFMutableArrayRef interfacePreserveServiceInformation = NULL; + CFMutableDictionaryRef bsdNameServiceProtocolPreserveMapping = NULL; Boolean isValid = TRUE; CFDictionaryRef mappingBSDNameToInterface = NULL; CFDictionaryRef mappingServiceBSDNameToInterface = NULL; + CFStringRef model = NULL; + CFStringRef ni_model = NULL; Boolean repairConfiguration = FALSE; + Boolean revertLimitNetworkConfiguration = FALSE; CFArrayRef setServiceOrder = NULL; CFArrayRef setServices = NULL; - CFMutableArrayRef interfaceToBeRemoved = NULL; - CFMutableArrayRef interfaceToBeReplaced = NULL; - - + if ((isA_CFDictionary(options) != NULL)) { CFBooleanRef repair = CFDictionaryGetValue(options, kSCNetworkConfigurationRepair); if (isA_CFBoolean(repair) != NULL) { repairConfiguration = CFBooleanGetValue(repair); } } - + if (__SCPreferencesGetLimitSCNetworkConfiguration(prefs) == FALSE) { + __SCPreferencesSetLimitSCNetworkConfiguration(prefs, TRUE); + revertLimitNetworkConfiguration = TRUE; + } /* + Check the validity by: - 1) Comparing if the interfaces names mentioned in NetworkInterfaces.plist and preferences.plist match + - Comparing if the models are the same + */ + model = SCPreferencesGetValue(prefs, MODEL); + ni_model = SCPreferencesGetValue(ni_prefs, MODEL); + + if (isA_CFString(model) == NULL || isA_CFString(ni_model) == NULL || CFStringCompare(model, ni_model, 0) != kCFCompareEqualTo) { + isValid = FALSE; + SC_log(LOG_INFO, "Model names do not match in preferences.plist and NetworkInterfaces.plist"); + goto done; + } + + /* + - Comparing if the interfaces names mentioned in NetworkInterfaces.plist and preferences.plist match Use the functions CFDictionaryRef __SCNetworkInterfaceCreateMappingUsingBSDName(SCPreferencesRef prefs); */ interfaces = __SCNetworkInterfaceCopyStoredWithPreferences(ni_prefs); if (isA_CFArray(interfaces) == NULL) { + SC_log(LOG_NOTICE, "No interfaces"); isValid = FALSE; - SCLog(_sc_debug, LOG_NOTICE, CFSTR("_SCNetworkConfigurationCheckValidityUsingPreferences: interfaces is NULL or not of the correct type")); goto done; } mappingBSDNameToInterface = __SCNetworkInterfaceCreateMappingUsingBSDName(interfaces); CFRelease(interfaces); if (isA_CFDictionary(mappingBSDNameToInterface) == NULL) { isValid = FALSE; - SCLog(_sc_debug, LOG_NOTICE, CFSTR("_SCNetworkConfigurationCheckValidityUsingPreferences: mappingBSDNameToInterface is NULL")); + SC_log(LOG_INFO, "No BSD name to interface mapping"); goto done; } interfaces = __SCNetworkServiceCopyAllInterfaces(prefs); if (isA_CFArray(interfaces) == NULL) { isValid = FALSE; - SCLog(_sc_debug, LOG_NOTICE, CFSTR("_SCNetworkConfigurationCheckValidityUsingPreferences: interfaces is NULL for configPref or not of the correct type")); + SC_log(LOG_INFO, "No interfaces"); goto done; } mappingServiceBSDNameToInterface = __SCNetworkInterfaceCreateMappingUsingBSDName(interfaces); CFRelease(interfaces); if (isA_CFDictionary(mappingServiceBSDNameToInterface) == NULL) { isValid = FALSE; - SCLog(_sc_debug, LOG_NOTICE, CFSTR("_SCNetworkConfigurationCheckValidityUsingPreferences: mappingServiceBSDNameToInterface is NULL")); + SC_log(LOG_INFO, "No Service BSD name to interface mapping"); goto done; } if (repairConfiguration) { interfaceToBeRemoved = CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks); interfaceToBeReplaced = CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks); + interfacePreserveServiceInformation = CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks); + bsdNameServiceProtocolPreserveMapping = CFDictionaryCreateMutable(NULL, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); #if !TARGET_OS_IPHONE bsdNameToBridgeServices = _SCNetworkMigrationCopyMappingBSDNameToBridgeServices(prefs); bsdNameToBondServices = _SCNetworkMigrationCopyMappingBSDNameToBondServices(prefs); @@ -1451,23 +1574,26 @@ _SCNetworkConfigurationCheckValidityUsingPreferences(SCPreferencesRef prefs, context.isValid = &isValid; context.interfaceToBeRemoved = interfaceToBeRemoved; context.interfaceToBeReplaced = interfaceToBeReplaced; + context.interfacePreserveServiceInformation = interfacePreserveServiceInformation; context.bsdNameToBridgeServices = bsdNameToBridgeServices; context.bsdNameToBondServices = bsdNameToBondServices; context.bsdNameToVLANServices = bsdNameToVLANServices; context.repair = repairConfiguration; + context.prefs = prefs; + context.bsdNameServiceProtocolPreserveMapping = bsdNameServiceProtocolPreserveMapping; CFDictionaryApplyFunction(mappingServiceBSDNameToInterface, _SCNetworkConfigurationValidateInterface, &context); if (isValid == FALSE) { - SCLog(_sc_debug, LOG_NOTICE, CFSTR("_SCNetworkConfigurationCheckValidityUsingPreferences: Found mismatch between interface names in NetworkInterfaces.plist and preferences.plist")); + SC_log(LOG_INFO, "mismatch between interface names in NetworkInterfaces.plist and preferences.plist"); if (repairConfiguration) { - isValid = _SCNetworkConfigurationRepairUsingPreferences(prefs, interfaceToBeRemoved, interfaceToBeReplaced); + isValid = _SCNetworkConfigurationRepairUsingPreferences(prefs, &context); if (isValid == FALSE) { goto done; } // Save the changes if repair fixed an invalid configuration if (SCPreferencesCommitChanges(prefs) == FALSE) { - SCLog(_sc_debug, LOG_NOTICE, CFSTR("Failed to commit changes from the repaired configuration")); + SC_log(LOG_INFO, "SCPreferencesCommitChanges() failed"); } } else { @@ -1475,21 +1601,20 @@ _SCNetworkConfigurationCheckValidityUsingPreferences(SCPreferencesRef prefs, } } /* - - 2) Check if all the network services mentioned in the SCNetworkSet are actually present in the SCNetworkService array + - 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) { isValid = FALSE; - SCLog(_sc_debug, LOG_NOTICE, CFSTR("_SCNetworkConfigurationCheckValidityUsingPreferences: allServices is NULL")); + SC_log(LOG_INFO, "No services"); goto done; } allSets = SCNetworkSetCopyAll(prefs); if (isA_CFArray(allSets) == NULL) { isValid = FALSE; - SCLog(_sc_debug, LOG_NOTICE, CFSTR("_SCNetworkConfigurationCheckValidityUsingPreferences: allSets is NULL")); + SC_log(LOG_INFO, "No sets"); goto done; } @@ -1497,12 +1622,12 @@ _SCNetworkConfigurationCheckValidityUsingPreferences(SCPreferencesRef prefs, SCNetworkSetRef set = CFArrayGetValueAtIndex(allSets, idx); if (isA_SCNetworkSet(set) == NULL) { - SCLog(_sc_debug, LOG_NOTICE, CFSTR("_SCNetworkConfigurationCheckValidityUsingPreferences: set is NULL")); + SC_log(LOG_INFO, "No set"); continue; } setServices = SCNetworkSetCopyServices(set); if (setServices == NULL) { - SCLog(_sc_debug, LOG_NOTICE, CFSTR("_SCNetworkConfigurationCheckValidityUsingPreferences: setServices is NULL")); + SC_log(LOG_INFO, "No services"); continue; } for (CFIndex idx2 = 0; idx2 < CFArrayGetCount(setServices); idx2++) { @@ -1510,7 +1635,7 @@ _SCNetworkConfigurationCheckValidityUsingPreferences(SCPreferencesRef prefs, if (CFArrayContainsValue(allServices, CFRangeMake(0, CFArrayGetCount(allServices)), service) == FALSE) { isValid = FALSE; - SCLog(_sc_debug, LOG_NOTICE, CFSTR("_SCNetworkConfigurationCheckValidityUsingPreferences: All network services in the network set are not present in SCNetworkService array")); + SC_log(LOG_INFO, "All network services in the network set are not present in SCNetworkService array"); break; } } @@ -1519,7 +1644,7 @@ _SCNetworkConfigurationCheckValidityUsingPreferences(SCPreferencesRef prefs, } /* - 3) Check if service IDs in service order do exist in the SET + - Check if service IDs in service order do exist in the SET */ setServiceOrder = SCNetworkSetGetServiceOrder(set); if (setServiceOrder != NULL) { @@ -1527,7 +1652,7 @@ _SCNetworkConfigurationCheckValidityUsingPreferences(SCPreferencesRef prefs, SCNetworkServiceRef service = CFArrayGetValueAtIndex(setServiceOrder, idx2); if ((CFArrayContainsValue(setServiceOrder, CFRangeMake(0, CFArrayGetCount(setServiceOrder)), service) == FALSE) && (CFArrayContainsValue(allServices, CFRangeMake(0, CFArrayGetCount(allServices)), service) == FALSE)) { - SCLog(_sc_debug, LOG_NOTICE, CFSTR("Service: %@ is not present in the service order for set %@"), service, set); + SC_log(LOG_INFO, "Service: %@ is not present in the service order for set %@", service, set); break; } } @@ -1537,9 +1662,9 @@ _SCNetworkConfigurationCheckValidityUsingPreferences(SCPreferencesRef prefs, setServices = NULL; } } - + /* - 4) Check if the virtual network interfaces have valid member interfaces + - Check if the virtual network interfaces have valid member interfaces */ CFArrayRef bridges = SCBridgeInterfaceCopyAll(prefs); if (bridges != NULL) { @@ -1591,6 +1716,15 @@ done: if (interfaceToBeReplaced != NULL) { CFRelease(interfaceToBeReplaced); } + if (interfacePreserveServiceInformation != NULL) { + CFRelease(interfacePreserveServiceInformation); + } + if (bsdNameServiceProtocolPreserveMapping != NULL) { + CFRelease(bsdNameServiceProtocolPreserveMapping); + } + if (revertLimitNetworkConfiguration ) { + __SCPreferencesSetLimitSCNetworkConfiguration(prefs, FALSE); + } return isValid; } @@ -1608,26 +1742,27 @@ _SCNetworkConfigurationCheckValidity(CFURLRef configDir, CFDictionaryRef options Boolean isValid = FALSE; char networkInterfaceStr[PATH_MAX]; char prefsStr[PATH_MAX]; - + if (configDir == NULL) { - SCLog(_sc_debug, LOG_NOTICE, CFSTR("_SCNetworkConfigurationCheckValidity: Migration files not found in directory: %@"), ((configDir == NULL) ? CFSTR("NULL") : CFURLGetString(configDir))); + SC_log(LOG_INFO, "Migration files not found in directory: %@", + (configDir == NULL) ? CFSTR("NULL") : CFURLGetString(configDir)); goto done; } baseURL = CFURLCreateWithFileSystemPathRelativeToBase(NULL, PREFS_DEFAULT_DIR_RELATIVE, kCFURLPOSIXPathStyle, TRUE, configDir); - + configPreferenceFile = CFURLCreateFromFileSystemRepresentationRelativeToBase(NULL, (const UInt8*)PREFS_DEFAULT_CONFIG_PLIST, sizeof(PREFS_DEFAULT_CONFIG_PLIST), FALSE, baseURL); configNetworkInterfaceFile = CFURLCreateFromFileSystemRepresentationRelativeToBase(NULL, (const UInt8*)NETWORK_INTERFACES_PREFS_PLIST, sizeof(NETWORK_INTERFACES_PREFS_PLIST), FALSE, baseURL); - - if (CFURLGetFileSystemRepresentation(configPreferenceFile, TRUE, (UInt8*)prefsStr, sizeof(prefsStr)) == FALSE) { - SCLog(_sc_debug, LOG_NOTICE, CFSTR("_SCNetworkConfigurationCheckValidity: Could not extract preferences information")); + + if (!CFURLGetFileSystemRepresentation(configPreferenceFile, TRUE, (UInt8*)prefsStr, sizeof(prefsStr))) { + SC_log(LOG_NOTICE, "Cannot get file system representation for url: %@", configPreferenceFile); goto done; } - if (CFURLGetFileSystemRepresentation(configNetworkInterfaceFile, TRUE, (UInt8*)networkInterfaceStr, sizeof(networkInterfaceStr)) == FALSE) { - SCLog(_sc_debug, LOG_NOTICE, CFSTR("_SCNetworkConfigurationCheckValidity: Could not extract network interface information")); + if (!CFURLGetFileSystemRepresentation(configNetworkInterfaceFile, TRUE, (UInt8*)networkInterfaceStr, sizeof(networkInterfaceStr))) { + SC_log(LOG_NOTICE, "Cannot get file system representation for url: %@", configNetworkInterfaceFile); goto done; } - + configPreferencesFileString = CFStringCreateWithFormat(NULL, NULL, CFSTR("%s"), prefsStr); configNetworkInterfaceFileString = CFStringCreateWithFormat(NULL, NULL, CFSTR("%s"), networkInterfaceStr); @@ -1644,7 +1779,7 @@ _SCNetworkConfigurationCheckValidity(CFURLRef configDir, CFDictionaryRef options // This function compares preferences.plist and NetworkInterfaces.plist and verifies if the values are correct // Checking interface mismatch for validity - isValid = _SCNetworkConfigurationCheckValidityUsingPreferences(configPref, configNetworkInterfacePref, options); + isValid = _SCNetworkConfigurationCheckValidityWithPreferences(configPref, configNetworkInterfacePref, options); done: if (baseURL != NULL) { @@ -1678,6 +1813,7 @@ done: typedef struct { CFMutableArrayRef externalInterfaceList; CFMutableArrayRef networkInterfaceList; + Boolean foundNewInterfaces; } SCExternalMappingContext; static void @@ -1688,9 +1824,10 @@ _SCNetworkConfigurationCollectInterfaceStorageEntity(const void *key, const void SCNetworkInterfaceRef targetInterface = (SCNetworkInterfaceRef)value; if (CFArrayContainsValue(ctx->externalInterfaceList, CFRangeMake(0, CFArrayGetCount(ctx->externalInterfaceList)), targetInterface) == TRUE) { - SCLog(_sc_debug, LOG_NOTICE, CFSTR("_SCNetworkConfigurationCollectInterfaceStorageEntity: Target Interface %@ already exists, thus do no add it to NetworkInterfaces.plist"), targetInterface); + SC_log(LOG_INFO, "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; interface_entity = __SCNetworkInterfaceCopyStorageEntity(targetInterface); if (interface_entity != NULL) { @@ -1700,7 +1837,7 @@ _SCNetworkConfigurationCollectInterfaceStorageEntity(const void *key, const void } static CFArrayRef // CFDictionaryRef -_SCNetworkMigrationCreateNetworkInterfaceArray(SCPreferencesRef ni_prefs, CFDictionaryRef externalMapping) +_SCNetworkMigrationCreateNetworkInterfaceArray(SCPreferencesRef ni_prefs, CFDictionaryRef externalMapping, Boolean *hasNewInterface) { SCExternalMappingContext context; CFIndex count = 0; @@ -1710,7 +1847,7 @@ _SCNetworkMigrationCreateNetworkInterfaceArray(SCPreferencesRef ni_prefs, CFDict CFMutableArrayRef networkInterfaceList = NULL; if (ni_prefs == NULL) { - SCLog(_sc_debug, LOG_NOTICE, CFSTR("_SCNetworkMigrationCreateNetworkInterfaceArray: ni_prefs are NULL")); + SC_log(LOG_INFO, "No NetworkInterfaces.plist"); return NULL; } @@ -1718,7 +1855,7 @@ _SCNetworkMigrationCreateNetworkInterfaceArray(SCPreferencesRef ni_prefs, CFDict if ((isA_CFArray(if_list) == NULL) || ((count = CFArrayGetCount(if_list)) == 0)) { - SCLog(_sc_debug, LOG_NOTICE, CFSTR("_SCNetworkMigrationCreateNetworkInterfaceArray: if_list is NULL or interface count is 0")); + SC_log(LOG_INFO, "No interfaces"); return NULL; } @@ -1734,16 +1871,20 @@ _SCNetworkMigrationCreateNetworkInterfaceArray(SCPreferencesRef ni_prefs, CFDict } if (isA_CFDictionary(externalMapping) == NULL) { - SCLog(_sc_debug, LOG_NOTICE, CFSTR("_SCNetworkMigrationCreateNetworkInterfaceArray: externalMapping is NULL or not of the correct type")); + SC_log(LOG_INFO, "No external mapping"); goto done; } // Add any new external interfaces found externalInterfaceList = _SCNetworkInterfaceCopyInterfacesFilteredByBuiltinWithPreferences(ni_prefs, FALSE); context.externalInterfaceList = externalInterfaceList; context.networkInterfaceList = networkInterfaceList; + context.foundNewInterfaces = FALSE; CFDictionaryApplyFunction(externalMapping, _SCNetworkConfigurationCollectInterfaceStorageEntity, &context); + if (hasNewInterface != NULL) { + *hasNewInterface = context.foundNewInterfaces; + } done: if (externalInterfaceList != NULL) { CFRelease(externalInterfaceList); @@ -1786,7 +1927,7 @@ _SCNetworkMigrationCreateBSDNameMapping(CFDictionaryRef internalMapping, CFDicti if ((internalMapping == NULL) && externalMapping == NULL) { goto done; } - + if (internalMapping != NULL) { CFDictionaryApplyFunction(internalMapping, SCNetworkMigrationMapSourceToTargetName, bsdNameMapping); } @@ -1794,7 +1935,7 @@ _SCNetworkMigrationCreateBSDNameMapping(CFDictionaryRef internalMapping, CFDicti if (externalMapping != NULL) { CFDictionaryApplyFunction(externalMapping, SCNetworkMigrationMapSourceToTargetName, bsdNameMapping); } - + done: return bsdNameMapping; } @@ -1814,14 +1955,14 @@ _SCNetworkMigrationCreateServiceSetMapping(SCPreferencesRef prefs) CFArrayRef services = NULL; CFMutableArrayRef setList = NULL; CFArrayRef sets = NULL; - + services = SCNetworkServiceCopyAll(prefs); if (services == NULL) { goto done; } for (CFIndex idx = 0; idx < CFArrayGetCount(services); idx++) { service = CFArrayGetValueAtIndex(services, idx); - + if (CFDictionaryContainsKey(serviceSetMapping, service) == FALSE) { setList = CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks); CFDictionaryAddValue(serviceSetMapping, service, setList); @@ -1829,16 +1970,16 @@ _SCNetworkMigrationCreateServiceSetMapping(SCPreferencesRef prefs) } } CFRelease(services); - + sets = SCNetworkSetCopyAll(prefs); if (sets == NULL) { goto done; } - + for (CFIndex idx = 0; idx < CFArrayGetCount(sets); idx++) { SCNetworkSetRef set = CFArrayGetValueAtIndex(sets, idx); services = SCNetworkSetCopyServices(set); - + for (CFIndex idx2 = 0; idx2 < CFArrayGetCount(services); idx2++) { service = CFArrayGetValueAtIndex(services, idx2); setList = (CFMutableArrayRef)CFDictionaryGetValue(serviceSetMapping, service); @@ -1848,7 +1989,7 @@ _SCNetworkMigrationCreateServiceSetMapping(SCPreferencesRef prefs) } CFRelease(services); } - + done: if (sets != NULL) { CFRelease(sets); @@ -1864,28 +2005,54 @@ _SCNetworkMigrationCreateSetMapping(SCPreferencesRef sourcePrefs, CFMutableDictionaryRef setMapping = NULL; CFStringRef setName; CFArrayRef sourceSets = NULL; + CFIndex targetCount; + SCNetworkSetRef targetSet; CFArrayRef targetSets = NULL; CFMutableArrayRef targetSetsMutable = NULL; - + sourceSets = SCNetworkSetCopyAll(sourcePrefs); targetSets = SCNetworkSetCopyAll(targetPrefs); - + if (sourceSets == NULL || targetSets == NULL) { goto done; } targetSetsMutable = CFArrayCreateMutableCopy(NULL, 0, targetSets); - + targetCount = CFArrayGetCount(targetSetsMutable); + setMapping = CFDictionaryCreateMutable(NULL, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); - + currentSourceSet = SCNetworkSetCopyCurrent(sourcePrefs); - + + // Mapping the current source set to the first target set, and setting it as current set + if (currentSourceSet != NULL) { + if (targetCount > 0) { + targetSet = CFArrayGetValueAtIndex(targetSetsMutable, 0); + CFRetain(targetSet); + CFArrayRemoveValueAtIndex(targetSetsMutable, 0); + + setName = SCNetworkSetGetName(currentSourceSet); + SCNetworkSetSetName(targetSet, setName); + CFDictionaryAddValue(setMapping, currentSourceSet, targetSet); + SCNetworkSetSetCurrent(targetSet); + 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); + goto done; + } + } + for (CFIndex idx = 0; idx < CFArrayGetCount(sourceSets); idx++) { SCNetworkSetRef sourceSet = CFArrayGetValueAtIndex(sourceSets, idx); - CFIndex targetCount = CFArrayGetCount(targetSetsMutable); - SCNetworkSetRef targetSet; - + + if ((currentSourceSet != NULL) && (CFEqual(sourceSet, currentSourceSet) == TRUE)) { + continue; + } + + targetCount = CFArrayGetCount(targetSetsMutable); setName = SCNetworkSetGetName(sourceSet); + if (targetCount > 0) { targetSet = CFArrayGetValueAtIndex(targetSetsMutable, 0); CFRetain(targetSet); @@ -1894,16 +2061,12 @@ _SCNetworkMigrationCreateSetMapping(SCPreferencesRef sourcePrefs, else { targetSet = SCNetworkSetCreate(targetPrefs); } - SCNetworkSetSetName(targetSet, setName); CFDictionaryAddValue(setMapping, sourceSet, targetSet); - - if (CFEqual(sourceSet, currentSourceSet) == TRUE) { - SCNetworkSetSetCurrent(targetSet); - } + CFRelease(targetSet); } - + done: if (sourceSets != NULL) { CFRelease(sourceSets); @@ -1948,17 +2111,17 @@ _SCNetworkMigrationCreateServiceMappingUsingBSDMapping(SCPreferencesRef sourcePr // We need BSD Mapping to successfully create service mapping if (bsdNameMapping == NULL) { - SCLog(_sc_debug, LOG_NOTICE, CFSTR("_SCNetworkMigrationCreateServiceMappingUsingBSDMapping: BSD Name Mapping is NULL")); + SC_log(LOG_INFO, "No BSD name mapping"); goto done; } sourceSCNetworkServices = SCNetworkServiceCopyAll(sourcePrefs); if (isA_CFArray(sourceSCNetworkServices) == NULL) { - SCLog(_sc_debug, LOG_NOTICE, CFSTR("_SCNetworkMigrationCreateServiceMappingUsingBSDMapping: sourceSCNetworkServices is NULL or not of the correct CFType")); + SC_log(LOG_INFO, "No source network services"); goto done; } targetSCNetworkServices = SCNetworkServiceCopyAll(targetPrefs); if (isA_CFArray(targetSCNetworkServices) == NULL) { - SCLog(_sc_debug, LOG_NOTICE, CFSTR("_SCNetworkMigrationCreateServiceMappingUsingBSDMapping: targetSCNetworkServices is NULL or not of the correct CFType")); + SC_log(LOG_INFO, "No target network services"); goto done; } @@ -1981,9 +2144,8 @@ _SCNetworkMigrationCreateServiceMappingUsingBSDMapping(SCPreferencesRef sourcePr sourceService = (SCNetworkServiceRef) CFArrayGetValueAtIndex(sourceSCNetworkServicesMutable, idx); sourceInterface = SCNetworkServiceGetInterface(sourceService); - if (sourceInterface == NULL) { - SCLog(_sc_debug, LOG_NOTICE, CFSTR("_SCNetworkMigrationCreateServiceMappingUsingBSDMapping: sourceInterface is NULL or not of the correct type")); + SC_log(LOG_INFO, "No source interface"); continue; } @@ -1993,25 +2155,26 @@ _SCNetworkMigrationCreateServiceMappingUsingBSDMapping(SCPreferencesRef sourcePr (CFEqual(sourceInterfaceType, kSCValNetInterfaceTypePPP) == TRUE))) { sourceInterfaceSubType = __SCNetworkInterfaceGetEntitySubType(sourceInterface); if (isA_CFString(sourceInterfaceSubType) == NULL) { - SCLog(_sc_debug, LOG_NOTICE, CFSTR("_SCNetworkMigrationCreateServiceMappingUsingBSDMapping: sourceInterfaceSubType is NULL or not of the correct type")); + SC_log(LOG_INFO, "No source interface SubType"); continue; } } else if (((isA_CFString(sourceInterfaceType) != NULL) && - (CFEqual(sourceInterfaceType, kSCValNetInterfaceTypeIPSec) == FALSE) && + (CFEqual(sourceInterfaceType, kSCValNetInterfaceTypeIPSec) == FALSE) && (CFEqual(sourceInterfaceType, kSCValNetInterfaceType6to4) == FALSE) && (CFEqual(sourceInterfaceType, kSCValNetInterfaceTypeLoopback) == FALSE)) || (isA_CFString(sourceInterfaceType) == NULL)) { sourceBSDName = SCNetworkInterfaceGetBSDName(sourceInterface); if ((isA_CFString(sourceBSDName) == NULL) || (CFDictionaryContainsKey(bsdNameMapping, sourceBSDName)) == FALSE) { - SCLog(_sc_debug, LOG_NOTICE, CFSTR("_SCNetworkMigrationCreateServiceMappingUsingBSDMapping: bsdNameMapping doesn't contain sourceBSDName: %@"), (sourceBSDName == NULL) ? CFSTR("NULL") : sourceBSDName); + SC_log(LOG_INFO, "No BSD name mapping for %@", + (sourceBSDName == NULL) ? CFSTR("NULL") : sourceBSDName); continue; } bsdNameMapTarget = CFDictionaryGetValue(bsdNameMapping, sourceBSDName); if (isA_CFString(bsdNameMapTarget) == NULL) { - SCLog(_sc_debug, LOG_NOTICE, CFSTR("_SCNetworkMigrationCreateServiceMappingUsingBSDMapping: bsdNameMapTarget is NULL or not of the correct CFType")); + SC_log(LOG_INFO, "No BSD name mapping target"); continue; } } @@ -2027,19 +2190,19 @@ _SCNetworkMigrationCreateServiceMappingUsingBSDMapping(SCPreferencesRef sourcePr targetInterface = SCNetworkServiceGetInterface(targetService); if (targetInterface == NULL) { - SCLog(_sc_debug, LOG_NOTICE, CFSTR("_SCNetworkMigrationCreateServiceMappingUsingBSDMapping: targetInterface is NULL or not of the correct type")); + SC_log(LOG_INFO, "No target interface"); continue; } - SCLog(_sc_debug, LOG_NOTICE, CFSTR("targetInterface: %@"), targetInterface); + SC_log(LOG_INFO, "targetInterface: %@", targetInterface); if (sourceBSDName != NULL) { targetBSDName = SCNetworkInterfaceGetBSDName(targetInterface); if (isA_CFString(targetBSDName) == NULL) { - SCLog(_sc_debug, LOG_NOTICE, CFSTR("_SCNetworkMigrationCreateServiceMappingUsingBSDMapping: targetBSDName is NULL or not of the correct type")); + SC_log(LOG_INFO, "No target BSD name"); continue; } if (CFEqual(targetBSDName, bsdNameMapTarget) == TRUE) { - SCLog(_sc_debug, LOG_NOTICE, CFSTR("_SCNetworkMigrationCreateServiceMappingUsingBSDMapping: Removing target BSD Name: %@"), targetBSDName); + SC_log(LOG_INFO, "Removing target BSD name: %@", targetBSDName); CFDictionaryAddValue(serviceMapping, sourceService, targetService); CFArrayRemoveValueAtIndex(targetSCNetworkServicesMutable, idx2); break; @@ -2051,19 +2214,20 @@ _SCNetworkMigrationCreateServiceMappingUsingBSDMapping(SCPreferencesRef sourcePr if ((isA_CFString(targetInterfaceType) == NULL) || ((CFEqual(targetInterfaceType, kSCValNetInterfaceTypeVPN) == FALSE) && (CFEqual(targetInterfaceType, kSCValNetInterfaceTypePPP) == FALSE))) { - SCLog(_sc_debug, LOG_NOTICE, CFSTR("_SCNetworkMigrationCreateServiceMappingUsingBSDMapping: targetInterfaceType is NULL or not of the correct type : %@"), (targetInterfaceType != NULL) ? targetInterfaceType : CFSTR("NULL")); + SC_log(LOG_INFO, "Unexpected target interface type: %@", + (targetInterfaceType != NULL) ? targetInterfaceType : CFSTR("NULL")); continue; } targetInterfaceSubType = __SCNetworkInterfaceGetEntitySubType(targetInterface); if (isA_CFString(targetInterfaceSubType) == NULL) { - SCLog(_sc_debug, LOG_NOTICE, CFSTR("_SCNetworkMigrationCreateServiceMappingUsingBSDMapping: targetInterfaceSubType is NULL or not of the correct type: %@"), (targetInterfaceSubType != NULL) ? targetInterfaceSubType : CFSTR("NULL")); + SC_log(LOG_INFO, "No target interface SubType"); continue; } // Check if the target interface type and the target interface sub type match if ((CFEqual(targetInterfaceType, sourceInterfaceType) == TRUE) && (CFEqual(targetInterfaceSubType, sourceInterfaceSubType) == TRUE)) { - SCLog(_sc_debug, LOG_NOTICE, CFSTR("_SCNetworkMigrationCreateServiceMappingUsingBSDMapping: Removing target BSD Name: %@ for VPN"), targetBSDName); + SC_log(LOG_INFO, "Removing target BSD Name: %@ for VPN", targetBSDName); CFDictionaryAddValue(serviceMapping, sourceService, targetService); CFArrayRemoveValueAtIndex(targetSCNetworkServicesMutable, idx2); break; @@ -2073,7 +2237,7 @@ _SCNetworkMigrationCreateServiceMappingUsingBSDMapping(SCPreferencesRef sourcePr // 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) == FALSE) { - SCLog(_sc_debug, LOG_NOTICE, CFSTR("_SCNetworkMigrationCreateServiceMappingUsingBSDMapping: Service needs to be added: %@"), sourceService); + SC_log(LOG_INFO, "Service needs to be added: %@", sourceService); CFDictionaryAddValue(serviceMapping, sourceService, kCFBooleanFalse); } } @@ -2118,14 +2282,16 @@ ServiceMigrationAddOrReplace(const void *key, const void *value, void *context) bsdMapping = ctx->bsdMapping; setMapping = ctx->setMapping; sourceServiceSetMapping = ctx->serviceSetMapping; - - if (isA_SCNetworkService(targetService) != NULL) { - SCLog(_sc_debug, LOG_NOTICE, CFSTR("ServiceMigrationAddOrReplace: Removing target service: %@"), targetService); - SCNetworkServiceRemove(targetService); + + if ((setMapping != NULL || sourceServiceSetMapping != NULL)) { + if (isA_SCNetworkService(targetService) != NULL) { + SC_log(LOG_INFO, "Removing target service: %@", targetService); + SCNetworkServiceRemove(targetService); + } } - SCLog(_sc_debug, LOG_NOTICE, CFSTR("ServiceMigrationAddOrReplace: Adding service with %@"), sourceService); + SC_log(LOG_INFO, "Adding service: %@", sourceService); if (__SCNetworkServiceMigrateNew(targetPrefs, sourceService, bsdMapping, setMapping, sourceServiceSetMapping) == FALSE) { - SCLog(_sc_debug, LOG_NOTICE, CFSTR("Could not Add Service: %@"), sourceService); + SC_log(LOG_INFO, "Could not add service: %@", sourceService); } } @@ -2141,14 +2307,14 @@ _SCNetworkMigrationDoServiceMigration(SCPreferencesRef sourcePrefs, SCPreference (targetPrefs == NULL) || (isA_CFDictionary(serviceMapping) == NULL) || (isA_CFDictionary(bsdMapping) == NULL)) { - SCLog(_sc_debug, LOG_NOTICE, CFSTR("_SCNetworkMigrationDoServiceMigration: targetPrefs or serviceMapping or bsdMapping is NULL")); + SC_log(LOG_INFO, "No sourcePrefs, targetPrefs, serviceMapping, or bsdMapping"); goto done; } context.targetPrefs = targetPrefs; context.bsdMapping = bsdMapping; context.setMapping = setMapping; context.serviceSetMapping = serviceSetMapping; - + CFDictionaryApplyFunction(serviceMapping, ServiceMigrationAddOrReplace, &context); success = TRUE; @@ -2167,8 +2333,8 @@ _SCNetworkMigrationDoSystemMigration(SCPreferencesRef sourcePrefs, SCPreferences CFDictionaryRef btmmDSID = NULL; CFStringRef btmmDSIDPath; CFStringRef btmmPath; - - + + if ((sourcePrefs == NULL) || (targetPrefs == NULL)) { return FALSE; @@ -2191,25 +2357,25 @@ _SCNetworkMigrationDoSystemMigration(SCPreferencesRef sourcePrefs, SCPreferences SCPreferencesSetComputerName(targetPrefs, computerName, nameEncoding); CFRelease(computerName); } - + btmmPath = CFStringCreateWithFormat(NULL, NULL, CFSTR("/%@/%@/%@"), kSCPrefSystem, kSCCompNetwork, BACK_TO_MY_MAC); btmm = SCPreferencesPathGetValue(sourcePrefs, btmmPath); - + if (btmm != NULL) { SCPreferencesPathSetValue(targetPrefs, btmmPath, btmm); } CFRelease(btmmPath); - + btmmDSIDPath = CFStringCreateWithFormat(NULL, NULL, CFSTR("/%@/%@/%@"), kSCPrefSystem, kSCCompNetwork, BACK_TO_MY_MAC_DSIDS); - + btmmDSID = SCPreferencesPathGetValue(sourcePrefs, btmmDSIDPath); if (btmmDSID != NULL) { SCPreferencesPathSetValue(targetPrefs, btmmDSIDPath, btmmDSID); @@ -2245,18 +2411,18 @@ add_virtual_interface(const void *value, void *context) CFStringRef oldInterfaceBSDName = (CFStringRef)value; SCNetworkInterfaceRef newInterface; CFStringRef newInterfaceBSDName; - - SCLog(_sc_debug, LOG_NOTICE, CFSTR("old interface BSD name is %@"), oldInterfaceBSDName); + + SC_log(LOG_INFO, "old BSD interface name: %@", oldInterfaceBSDName); + newInterfaceBSDName = CFDictionaryGetValue(bsdMapping, oldInterfaceBSDName); if (newInterfaceBSDName == NULL) { return; } - - SCLog(_sc_debug, LOG_NOTICE, CFSTR("new interface BSD name is %@"), newInterfaceBSDName); + SC_log(LOG_INFO, "new BSD interface name: %@", newInterfaceBSDName); + newInterface = __SCNetworkInterfaceCreateWithNIPreferencesUsingBSDName(NULL, ctx->ni_prefs, newInterfaceBSDName); - if (newInterface != NULL) { - SCLog(_sc_debug, LOG_NOTICE, CFSTR("Adding interface to interfaceList: %@"), newInterface); + SC_log(LOG_INFO, "Adding interface to interfaceList: %@", newInterface); CFArrayAppendValue(interfaceList, newInterface); CFRelease(newInterface); } @@ -2281,47 +2447,47 @@ add_target_bridge(const void *key, const void *value, void *context) SCPreferencesRef prefs = ctx->prefs; CFDictionaryRef serviceSetMapping = ctx->serviceSetMapping; CFDictionaryRef setMapping = ctx->setMapping; - + newInterfaceList = CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks); - + memberListContext.bsdMapping = ctx->bsdMapping; memberListContext.interfaceList = newInterfaceList; memberListContext.ni_prefs = ctx->ni_prefs; - + CFArrayApplyFunction(oldInterfaceList, CFRangeMake(0, CFArrayGetCount(oldInterfaceList)), add_virtual_interface, &memberListContext); - + newBridge = SCBridgeInterfaceCreate(prefs); - + if (__SCBridgeInterfaceSetMemberInterfaces(newBridge, newInterfaceList) == FALSE) { - SCLog(_sc_debug, LOG_NOTICE, CFSTR("add_target_bridge: Adding Member Interfaces failed")); + SC_log(LOG_INFO, "__SCBridgeInterfaceSetMemberInterfaces() failed"); } CFRelease(newInterfaceList); - + bridgeOptions = SCBridgeInterfaceGetOptions(oldBridge); if (bridgeOptions != NULL) { SCBridgeInterfaceSetOptions(newBridge, bridgeOptions); } - + bridgeName = SCNetworkInterfaceGetLocalizedDisplayName(oldBridge); - + if (bridgeName != NULL) { SCBridgeInterfaceSetLocalizedDisplayName(newBridge, bridgeName); } - + oldBSDName = SCNetworkInterfaceGetBSDName(oldBridge); if (oldBSDName == NULL) { goto done; } - + oldServiceList = CFDictionaryGetValue(bsdNameToServiceMapping, oldBSDName); if (oldServiceList == NULL) { goto done; } - + for (CFIndex idx = 0; idx < CFArrayGetCount(oldServiceList); idx++) { SCNetworkServiceRef oldService = CFArrayGetValueAtIndex(oldServiceList, idx); if (__SCNetworkServiceMigrateNew(prefs, oldService, bridgeBSDNameMapping, setMapping, serviceSetMapping) == FALSE) { - SCLog(_sc_debug, LOG_NOTICE, CFSTR("add_target_bridge: Could not migrate service: %@"), oldService); + SC_log(LOG_INFO, "Could not migrate Bridge service: %@", oldService); } } done: @@ -2332,15 +2498,15 @@ static void _SCNetworkMigrationRemoveBridgeServices(SCPreferencesRef prefs) { CFArrayRef services = SCNetworkServiceCopyAll(prefs); - + for (CFIndex idx = 0; idx < CFArrayGetCount(services); idx++) { SCNetworkServiceRef service = CFArrayGetValueAtIndex(services, idx); SCNetworkInterfaceRef interface = SCNetworkServiceGetInterface(service); CFStringRef bsdName = SCNetworkInterfaceGetBSDName(interface); - + if ((bsdName != NULL) && - SCNetworkInterfaceGetInterfaceType(interface) == kSCNetworkInterfaceTypeBridge) { - SCLog(TRUE, LOG_NOTICE, CFSTR("_SCNetworkMigrationRemoveBridgeServices: Removing services: %@"), service); + (SCNetworkInterfaceGetInterfaceType(interface) == kSCNetworkInterfaceTypeBridge)) { + SC_log(LOG_INFO, "Removing service: %@", service); SCNetworkServiceRemove(service); } } @@ -2353,12 +2519,12 @@ _SCNetworkMigrationCopyMappingBSDNameToBridgeServices(SCPreferencesRef prefs) { CFArrayRef services = SCNetworkServiceCopyAll(prefs); CFMutableDictionaryRef bridgeServices = CFDictionaryCreateMutable(NULL, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); - + for (CFIndex idx = 0; idx < CFArrayGetCount(services); idx++) { SCNetworkServiceRef service = CFArrayGetValueAtIndex(services, idx); SCNetworkInterfaceRef interface = SCNetworkServiceGetInterface(service); CFStringRef bsdName = SCNetworkInterfaceGetBSDName(interface); - + if ((bsdName != NULL) && SCNetworkInterfaceGetInterfaceType(interface) == kSCNetworkInterfaceTypeBridge) { CFMutableArrayRef serviceList; @@ -2394,29 +2560,29 @@ _SCNetworkMigrationDoBridgeMigration (SCPreferencesRef sourcePrefs, SCVirtualInterfaceContext context; CFIndex count = 0; Boolean success = FALSE; - + allSourceBridges = SCBridgeInterfaceCopyAll(sourcePrefs); allTargetBridges = SCBridgeInterfaceCopyAll(targetPrefs); - + bsdNameToBridgeServices = _SCNetworkMigrationCopyMappingBSDNameToBridgeServices(sourcePrefs); - + bridgeInterfaceMapping = CFDictionaryCreateMutable(NULL, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); bridgeMapping = CFDictionaryCreateMutable(NULL, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); - + // Create Bridge Interface Mapping for (CFIndex idx = 0; idx < CFArrayGetCount(allSourceBridges); idx++) { bridge = CFArrayGetValueAtIndex(allSourceBridges, idx); CFArrayRef bridgeMembers = SCBridgeInterfaceGetMemberInterfaces(bridge); CFMutableArrayRef interfaceList; - + interfaceList = CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks); for (CFIndex idx2 = 0; idx2 < CFArrayGetCount(bridgeMembers); idx2++) { CFStringRef interfaceName = NULL; SCNetworkInterfaceRef interface = NULL; - + interface = CFArrayGetValueAtIndex(bridgeMembers, idx2); interfaceName = SCNetworkInterfaceGetBSDName(interface); - + if (CFDictionaryContainsKey(bsdMapping, interfaceName) == TRUE) { CFStringRef bridgeNewName = CFStringCreateWithFormat(NULL, NULL, CFSTR("bridge%ld"), count); CFDictionaryAddValue(bridgeMapping, interfaceName, bridgeNewName); @@ -2432,16 +2598,16 @@ _SCNetworkMigrationDoBridgeMigration (SCPreferencesRef sourcePrefs, } // Remove bridge services from target _SCNetworkMigrationRemoveBridgeServices(targetPrefs); - + // Remove Target Bridges for (CFIndex idx = 0; idx < CFArrayGetCount(allTargetBridges); idx++) { bridge = CFArrayGetValueAtIndex(allTargetBridges, idx); if (SCBridgeInterfaceRemove(bridge) == FALSE) { - SCLog(_sc_debug, LOG_NOTICE, CFSTR("_SCNetworkMigrationDoBridgeMigration: Could not remove bridge: %@"), bridge); + SC_log(LOG_INFO, "SCBridgeInterfaceRemove() failed: %@", bridge); goto done; } } - + context.prefs = targetPrefs; context.ni_prefs = targetNIPrefs; context.bsdMapping = bsdMapping; @@ -2449,10 +2615,10 @@ _SCNetworkMigrationDoBridgeMigration (SCPreferencesRef sourcePrefs, context.mappingBSDNameToService = bsdNameToBridgeServices; context.setMapping = setMapping; context.serviceSetMapping = serviceSetMapping; - + // Add Bridge configurations at the target using mapping CFDictionaryApplyFunction(bridgeInterfaceMapping, add_target_bridge, &context); - + success = TRUE; done: CFRelease(allSourceBridges); @@ -2483,31 +2649,31 @@ add_target_bond(const void *key, const void *value, void *context) SCPreferencesRef prefs = ctx->prefs; CFDictionaryRef serviceSetMapping = ctx->serviceSetMapping; CFDictionaryRef setMapping = ctx->setMapping; - + newInterfaceList = CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks); - + memberListContext.bsdMapping = ctx->bsdMapping; memberListContext.interfaceList = newInterfaceList; memberListContext.ni_prefs = ctx->ni_prefs; - + CFArrayApplyFunction(oldInterfaceList, CFRangeMake(0, CFArrayGetCount(oldInterfaceList)), add_virtual_interface, &memberListContext); - + newBond = SCBondInterfaceCreate(prefs); if (__SCBondInterfaceSetMemberInterfaces(newBond, newInterfaceList) == FALSE) { - SCLog(_sc_debug, LOG_NOTICE, CFSTR("add_target_bond: Adding member interface failed.")); + SC_log(LOG_INFO, "__SCBondInterfaceSetMemberInterfaces() failed"); } CFRelease(newInterfaceList); - + bondOptions = SCBondInterfaceGetOptions(oldBond); if (bondOptions != NULL) { SCBondInterfaceSetOptions(newBond, bondOptions); } - + bondName = SCNetworkInterfaceGetLocalizedDisplayName(oldBond); if (bondName != NULL) { SCBondInterfaceSetLocalizedDisplayName(newBond, bondName); } - + bondMode = SCBondInterfaceGetMode(oldBond); if (bondMode != NULL) { SCBondInterfaceSetMode(newBond, bondMode); @@ -2516,16 +2682,16 @@ add_target_bond(const void *key, const void *value, void *context) if (oldBSDName == NULL) { goto done; } - + oldServiceList = CFDictionaryGetValue(bsdNameToServiceMapping, oldBSDName); if (oldServiceList == NULL) { goto done; } - + for (CFIndex idx = 0; idx < CFArrayGetCount(oldServiceList); idx++) { SCNetworkServiceRef oldService = CFArrayGetValueAtIndex(oldServiceList, idx); if (__SCNetworkServiceMigrateNew(prefs, oldService, bondBSDNameMapping, setMapping, serviceSetMapping) == FALSE) { - SCLog(_sc_debug, LOG_NOTICE, CFSTR("add_target_bond: Could not migrate service: %@"), oldService); + SC_log(LOG_INFO, "Could not migrate Bond service: %@", oldService); } } done: @@ -2536,12 +2702,12 @@ static void _SCNetworkMigrationRemoveBondServices(SCPreferencesRef prefs) { CFArrayRef services = SCNetworkServiceCopyAll(prefs); - + for (CFIndex idx = 0; idx < CFArrayGetCount(services); idx++) { SCNetworkServiceRef service = CFArrayGetValueAtIndex(services, idx); SCNetworkInterfaceRef interface = SCNetworkServiceGetInterface(service); CFStringRef bsdName = SCNetworkInterfaceGetBSDName(interface); - + if ((bsdName != NULL) && SCNetworkInterfaceGetInterfaceType(interface) == kSCNetworkInterfaceTypeBond) { SCNetworkServiceRemove(service); @@ -2556,12 +2722,12 @@ _SCNetworkMigrationCopyMappingBSDNameToBondServices(SCPreferencesRef prefs) { CFArrayRef services = SCNetworkServiceCopyAll(prefs); CFMutableDictionaryRef bondServices = CFDictionaryCreateMutable(NULL, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); - + for (CFIndex idx = 0; idx < CFArrayGetCount(services); idx++) { SCNetworkServiceRef service = CFArrayGetValueAtIndex(services, idx); SCNetworkInterfaceRef interface = SCNetworkServiceGetInterface(service); CFStringRef bsdName = SCNetworkInterfaceGetBSDName(interface); - + if ((bsdName != NULL) && SCNetworkInterfaceGetInterfaceType(interface) == kSCNetworkInterfaceTypeBond) { CFMutableArrayRef serviceList; @@ -2597,12 +2763,12 @@ _SCNetworkMigrationDoBondMigration (SCPreferencesRef sourcePrefs, SCVirtualInterfaceContext context; CFIndex count = 0; Boolean success = FALSE; - + allSourceBonds = SCBondInterfaceCopyAll(sourcePrefs); allTargetBonds = SCBondInterfaceCopyAll(targetPrefs); - + bsdNameToBondServices = _SCNetworkMigrationCopyMappingBSDNameToBondServices(sourcePrefs); - + bondInterfaceMapping = CFDictionaryCreateMutable(NULL, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); bondMapping = CFDictionaryCreateMutable(NULL, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); // Create Bond Interface mapping @@ -2610,15 +2776,15 @@ _SCNetworkMigrationDoBondMigration (SCPreferencesRef sourcePrefs, bond = CFArrayGetValueAtIndex(allSourceBonds, idx); CFArrayRef bondMembers = SCBondInterfaceGetMemberInterfaces(bond); CFMutableArrayRef interfaceList; - + interfaceList = CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks); for (CFIndex idx2 = 0; idx2 < CFArrayGetCount(bondMembers); idx2++) { CFStringRef interfaceName; SCNetworkInterfaceRef interface; - + interface = CFArrayGetValueAtIndex(bondMembers, idx2); interfaceName = SCNetworkInterfaceGetBSDName(interface); - + if (CFDictionaryContainsKey(bsdMapping, interfaceName) == TRUE) { CFStringRef bondNewName = CFStringCreateWithFormat(NULL, NULL, CFSTR("bond%ld"), count); CFDictionaryAddValue(bondMapping, interfaceName, bondNewName); @@ -2634,16 +2800,16 @@ _SCNetworkMigrationDoBondMigration (SCPreferencesRef sourcePrefs, } // Remove bond services from target _SCNetworkMigrationRemoveBondServices(targetPrefs); - + // Remove Target Bonds for (CFIndex idx = 0; idx < CFArrayGetCount(allTargetBonds); idx++) { bond = CFArrayGetValueAtIndex(allTargetBonds, idx); if (SCBondInterfaceRemove(bond) == FALSE) { - SCLog(_sc_debug, LOG_NOTICE, CFSTR("_SCNetworkMigrationDoBondMigration: Could not remove bond: %@"), bond); + SC_log(LOG_INFO, "SCBondInterfaceRemove() failed: %@", bond); goto done; } } - + context.prefs = targetPrefs; context.ni_prefs = targetNIPrefs; context.bsdMapping = bsdMapping; @@ -2651,10 +2817,10 @@ _SCNetworkMigrationDoBondMigration (SCPreferencesRef sourcePrefs, context.mappingBSDNameToService = bsdNameToBondServices; context.setMapping = setMapping; context.serviceSetMapping = serviceSetMapping; - + // Add Bond configurations at the target using mapping CFDictionaryApplyFunction(bondInterfaceMapping, add_target_bond, &context); - + success = TRUE; done: CFRelease(allSourceBonds); @@ -2687,70 +2853,70 @@ add_target_vlan(const void *value, void *context) CFNumberRef vlanTag; CFStringRef vlanName; CFDictionaryRef vlanOptions; - + bsdMapping = ctx->bsdMapping; + oldPhysicalInterface = SCVLANInterfaceGetPhysicalInterface(oldVLAN); - if (oldPhysicalInterface == NULL) { - SCLog(_sc_debug, LOG_NOTICE, CFSTR("add_target_vlan: oldPhysicalInterface is NULL")); + SC_log(LOG_INFO, "No old VLAN physical interface"); goto done; } + oldPhysicalInterfaceName = SCNetworkInterfaceGetBSDName(oldPhysicalInterface); - if (oldPhysicalInterfaceName == NULL) { - SCLog(_sc_debug, LOG_NOTICE, CFSTR("add_target_vlan: oldPhysicalInterfaceName is NULL")); + SC_log(LOG_INFO, "No old VLAN physical interface name"); goto done; } - + newPhysicalInterfaceName = CFDictionaryGetValue(bsdMapping, oldPhysicalInterfaceName); if (newPhysicalInterfaceName == NULL) { - SCLog(_sc_debug, LOG_NOTICE, CFSTR("add_target_vlan: newPhysicalInterfaceName is NULL")); + SC_log(LOG_INFO, "No new VLAN physical interface name"); goto done; } newPhysicalInterface = __SCNetworkInterfaceCreateWithNIPreferencesUsingBSDName(NULL, ctx->ni_prefs, newPhysicalInterfaceName); if (newPhysicalInterface == NULL) { - SCLog(_sc_debug, LOG_NOTICE, CFSTR("add_target_vlan: newPhysicalInterface is NULL")); + SC_log(LOG_INFO, "Could not create new VLAN physical interface"); goto done; } - + vlanTag = SCVLANInterfaceGetTag(oldVLAN); if (vlanTag == NULL) { - SCLog(_sc_debug, LOG_NOTICE, CFSTR("add_target_vlan: vlanTag is NULL")); + SC_log(LOG_INFO, "No old VLAN interface tag"); goto done; } - + newVLAN = SCVLANInterfaceCreate(prefs, newPhysicalInterface, vlanTag); if (newVLAN == NULL) { - SCLog(_sc_debug, LOG_NOTICE, CFSTR("add_target_vlan: Could not create newVLAN")); + SC_log(LOG_INFO, "Could not create new VLAN interface"); } - + vlanName = SCNetworkInterfaceGetLocalizedDisplayName(oldVLAN); if (vlanName != NULL) { SCVLANInterfaceSetLocalizedDisplayName(newVLAN, vlanName); } - + vlanOptions = SCVLANInterfaceGetOptions(oldVLAN); if (vlanOptions != NULL) { SCVLANInterfaceSetOptions(newVLAN, vlanOptions); } oldBSDName = SCNetworkInterfaceGetBSDName(oldVLAN); - + if (oldBSDName == NULL) { goto done; } - + oldServiceList = CFDictionaryGetValue(bsdNameToServiceMapping, oldBSDName); if (oldServiceList == NULL) { goto done; } - + for (CFIndex idx = 0; idx < CFArrayGetCount(oldServiceList); idx++) { oldService = CFArrayGetValueAtIndex(oldServiceList, idx); if (__SCNetworkServiceMigrateNew(prefs, oldService, vlanBSDMapping, setMapping, serviceSetMapping) == FALSE) { - SCLog(_sc_debug, LOG_NOTICE, CFSTR("add_target_vlan: Could not migrate service: %@"), oldService); + SC_log(LOG_INFO, "Could not migrate VLAN service: %@", oldService); } } - + done: if (newPhysicalInterface != NULL) { CFRelease(newPhysicalInterface); @@ -2764,18 +2930,18 @@ static void _SCNetworkMigrationRemoveVLANServices(SCPreferencesRef prefs) { CFArrayRef services = SCNetworkServiceCopyAll(prefs); - + for (CFIndex idx = 0; idx < CFArrayGetCount(services); idx++) { SCNetworkServiceRef service = CFArrayGetValueAtIndex(services, idx); SCNetworkInterfaceRef interface = SCNetworkServiceGetInterface(service); CFStringRef bsdName = SCNetworkInterfaceGetBSDName(interface); - + if ((bsdName != NULL) && SCNetworkInterfaceGetInterfaceType(interface) == kSCNetworkInterfaceTypeVLAN) { SCNetworkServiceRemove(service); } } - + CFRelease(services); } @@ -2785,12 +2951,12 @@ _SCNetworkMigrationCopyMappingBSDNameToVLANServices(SCPreferencesRef prefs) { CFArrayRef services = SCNetworkServiceCopyAll(prefs); CFMutableDictionaryRef vlanServices = CFDictionaryCreateMutable(NULL, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); - + for (CFIndex idx = 0; idx < CFArrayGetCount(services); idx++) { SCNetworkServiceRef service = CFArrayGetValueAtIndex(services, idx); SCNetworkInterfaceRef interface = SCNetworkServiceGetInterface(service); CFStringRef bsdName = SCNetworkInterfaceGetBSDName(interface); - + if ((bsdName != NULL) && SCNetworkInterfaceGetInterfaceType(interface) == kSCNetworkInterfaceTypeVLAN) { CFMutableArrayRef serviceList; @@ -2825,26 +2991,26 @@ _SCNetworkMigrationDoVLANMigration (SCPreferencesRef sourcePrefs, CFMutableArrayRef vlanList; CFMutableDictionaryRef vlanMapping; CFDictionaryRef bsdNameToVLANServices; - + allSourceVLAN = SCVLANInterfaceCopyAll(sourcePrefs); allTargetVLAN = SCVLANInterfaceCopyAll(targetPrefs); - + bsdNameToVLANServices = _SCNetworkMigrationCopyMappingBSDNameToVLANServices(sourcePrefs); - + vlanList = CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks); vlanMapping = CFDictionaryCreateMutable(NULL, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); - + for (CFIndex idx = 0; idx < CFArrayGetCount(allSourceVLAN); idx++) { vlan = CFArrayGetValueAtIndex(allSourceVLAN, idx); CFStringRef vlanBSDName = SCNetworkInterfaceGetBSDName(vlan); SCNetworkInterfaceRef physicalInterface = SCVLANInterfaceGetPhysicalInterface(vlan); CFStringRef physicalInterfaceName; - - SCLog(_sc_debug, LOG_NOTICE, CFSTR("_SCNetworkMigrationDoVLANMigration: physical interface is %@"), physicalInterface); - + + SC_log(LOG_DEBUG, "physical VLAN interface: %@", physicalInterface); + physicalInterfaceName = SCNetworkInterfaceGetBSDName(physicalInterface); - SCLog(_sc_debug, LOG_NOTICE, CFSTR("_SCNetworkMigrationDoVLANMigration: Physical Interface name is %@"), physicalInterfaceName); - + SC_log(LOG_DEBUG, "physical VLAN interface name: %@", physicalInterfaceName); + // Add VLAN to be migrated if the mapping between interfaces exists if (CFDictionaryContainsKey(bsdMapping, physicalInterfaceName) == TRUE) { CFStringRef vlanNewName = CFStringCreateWithFormat(NULL, NULL, CFSTR("vlan%ld"), count); @@ -2856,16 +3022,16 @@ _SCNetworkMigrationDoVLANMigration (SCPreferencesRef sourcePrefs, } // Remove vlan services from target _SCNetworkMigrationRemoveVLANServices(targetPrefs); - + // Remove Target VLANs for (CFIndex idx = 0; idx < CFArrayGetCount(allTargetVLAN); idx++) { vlan = CFArrayGetValueAtIndex(allTargetVLAN, idx); if (SCVLANInterfaceRemove(vlan) == FALSE) { - SCLog(_sc_debug, LOG_NOTICE, CFSTR("_SCNetworkMigrationDoVLANMigration: Could not remove VLAN: %@"), vlan); + SC_log(LOG_INFO, "SCVLANInterfaceRemove() failed: %@", vlan); goto done; } } - + context.prefs = targetPrefs; context.ni_prefs = targetNIPrefs; context.bsdMapping = bsdMapping; @@ -2873,10 +3039,10 @@ _SCNetworkMigrationDoVLANMigration (SCPreferencesRef sourcePrefs, context.mappingBSDNameToService = bsdNameToVLANServices; context.setMapping = setMapping; context.serviceSetMapping = serviceSetMapping; - + // Add VLAN configurations at the target using vlanList CFArrayApplyFunction(vlanList, CFRangeMake(0, CFArrayGetCount(vlanList)), add_target_vlan, &context); - + success = TRUE; done: CFRelease(allSourceVLAN); @@ -2900,21 +3066,21 @@ _SCNetworkMigrationDoVirtualNetworkInterfaceMigration(SCPreferencesRef sourcePre if (_SCNetworkMigrationDoBridgeMigration(sourcePrefs, sourceNIPrefs, targetPrefs, targetNIPrefs, bsdMapping, setMapping, serviceSetMapping) == FALSE) { - SCLog(_sc_debug, LOG_NOTICE, CFSTR("_SCNetworkMigrationDoVirtualNetworkInterfaceMigration: Bridge migration failed")); + SC_log(LOG_INFO, "Bridge migration failed"); } - + // Handle Bonds if (_SCNetworkMigrationDoBondMigration(sourcePrefs, sourceNIPrefs, targetPrefs, targetNIPrefs, bsdMapping, setMapping, serviceSetMapping) == FALSE) { - SCLog(_sc_debug, LOG_NOTICE, CFSTR("_SCNetworkMigrationDoVirtualNetworkInterfaceMigration: Bond migration failed")); + SC_log(LOG_INFO, "Bond migration failed"); } - + // Handle VLANs if (_SCNetworkMigrationDoVLANMigration(sourcePrefs, sourceNIPrefs, targetPrefs, targetNIPrefs, bsdMapping, setMapping, serviceSetMapping) == FALSE) { - SCLog(_sc_debug, LOG_NOTICE, CFSTR("_SCNetworkMigrationDoVirtualNetworkInterfaceMigration: VLAN migration failed")); + SC_log(LOG_INFO, "VLAN migration failed"); } return TRUE; } @@ -2935,7 +3101,7 @@ create_migrated_order(const void *value, void *context) CFArrayRef targetServiceOrder = ctx->serviceOrder; CFStringRef migratedServiceID = (CFStringRef)value; Boolean *success = ctx->success; - + if (*success == FALSE) { return; } @@ -2960,14 +3126,14 @@ create_non_migrated_service_list(const void *value, void *context) SCNetworkServiceRef service; Boolean *success = ctx->success; CFStringRef targetServiceID = (CFStringRef)value; - + 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) == TRUE) { return; } @@ -2977,7 +3143,7 @@ create_non_migrated_service_list(const void *value, void *context) *success = FALSE; return; } - + CFArrayAppendValue(nonMigratedService, service); CFRelease(service); } @@ -2995,13 +3161,13 @@ preserve_service_order(const void *key, const void *value, void *context) SCNetworkSetRef targetSet = (SCNetworkSetRef)value; SCNetworkSetPrivateRef targetPrivate = (SCNetworkSetPrivateRef)targetSet; CFArrayRef targetServiceOrder = NULL; - + if (*success == FALSE) { return; } migratedServiceOrder = CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks); nonMigratedServices = CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks); - + sourceServiceOrder = SCNetworkSetGetServiceOrder(sourceSet); if (sourceServiceOrder == NULL) { goto done; @@ -3010,29 +3176,29 @@ preserve_service_order(const void *key, const void *value, void *context) if (targetServiceOrder == NULL) { goto done; } - + migrated_context.prefs = NULL; migrated_context.serviceOrder = targetServiceOrder; migrated_context.serviceListMutable = migratedServiceOrder; migrated_context.success = success; - + // Creating a list of service IDs which were migrated in the target set // while maintaining the service order or the source set CFArrayApplyFunction(sourceServiceOrder, CFRangeMake(0, CFArrayGetCount(sourceServiceOrder)), create_migrated_order, &migrated_context); - + if (success == FALSE) { goto done; } - + non_migrated_context.prefs = targetPrivate->prefs; non_migrated_context.serviceOrder = migratedServiceOrder; non_migrated_context.serviceListMutable = nonMigratedServices; non_migrated_context.success = success; - + // Creating a list of all the services which were not migrated from the source set to the // target set CFArrayApplyFunction(targetServiceOrder, CFRangeMake(0, CFArrayGetCount(targetServiceOrder)), create_non_migrated_service_list, &non_migrated_context); - + // Remove non migrated service for (CFIndex idx = 0; idx < CFArrayGetCount(nonMigratedServices); idx++) { SCNetworkServiceRef service = CFArrayGetValueAtIndex(nonMigratedServices, idx); @@ -3040,18 +3206,18 @@ preserve_service_order(const void *key, const void *value, void *context) } // Set migrated service order SCNetworkSetSetServiceOrder(targetSet, migratedServiceOrder); - + // Add non migrated services for (CFIndex idx = 0; idx < CFArrayGetCount(nonMigratedServices); idx++) { SCNetworkServiceRef service = CFArrayGetValueAtIndex(nonMigratedServices, idx); SCNetworkSetAddService(targetSet, service); } - + done: CFRelease(migratedServiceOrder); CFRelease(nonMigratedServices); return; - + } static Boolean @@ -3060,12 +3226,12 @@ _SCNetworkMigrationDoServiceOrderMigration(SCPreferencesRef sourcePrefs, CFDictionaryRef setMapping) { Boolean success = TRUE; - + if (isA_CFDictionary(setMapping) == NULL) { success = FALSE; goto done; } - + CFDictionaryApplyFunction(setMapping, preserve_service_order, &success); done: return success; @@ -3078,50 +3244,53 @@ done: static Boolean _SCNetworkConfigurationMigrateConfiguration(CFURLRef sourceDir, CFURLRef targetDir) { - CFDictionaryRef bsdNameMapping = NULL; // Mapping between BSD name and SCNetworkInterfaceRef to help with mapping services - CFMutableDictionaryRef builtinMapping = NULL; // Mapping between builtin interfaces between source and target configurations: (SCNetworkInterfaceRef -> SCNetworkInterfaceRef) - CFMutableDictionaryRef externalMapping = NULL; // Mapping between external interfaces between source and target configurations: (SCNetworkInterfaceRef -> SCNetworkInterfaceRef) + CFDictionaryRef bsdNameMapping = NULL; // Mapping between BSD name and SCNetworkInterfaceRef to help with mapping services + CFMutableDictionaryRef builtinMapping = NULL; // Mapping between builtin interfaces between source and target configurations: (SCNetworkInterfaceRef -> SCNetworkInterfaceRef) + CFMutableDictionaryRef externalMapping = NULL; // Mapping between external interfaces between source and target configurations: (SCNetworkInterfaceRef -> SCNetworkInterfaceRef) Boolean migrationSuccess = FALSE; - CFArrayRef newTargetNetworkInterfaceEntity = NULL; // Array of Interface Entity which used to create new target interfaces created during migration - CFDictionaryRef serviceMapping = NULL; // Mapping between services of source to target. (SCNetworkServicesRef -> SCNetworkServicesRef) + CFArrayRef newTargetNetworkInterfaceEntity = NULL; // Array of Interface Entity which used to create new target interfaces created during migration + CFDictionaryRef serviceMapping = NULL; // Mapping between services of source to target. (SCNetworkServicesRef -> SCNetworkServicesRef) CFDictionaryRef setMapping = NULL; CFDictionaryRef sourceServiceSetMapping = NULL; - CFArrayRef sourceConfigurationFiles = NULL; // Path to the source configuration files which need to be migrated - CFURLRef sourceNetworkInterfaceFile = NULL; // Source CFURLRef for preferences.plist and NetworkInterfaces.plist + CFArrayRef sourceConfigurationFiles = NULL; // Path to the source configuration files which need to be migrated + CFStringRef sourceModel = NULL; + CFURLRef sourceNetworkInterfaceFile = NULL; // Source CFURLRef for preferences.plist and NetworkInterfaces.plist char sourceNetworkInterfaceFileStr[PATH_MAX]; CFStringRef sourceNetworkInterfaceFileString = NULL; // Source CFStringRef for preferences.plist and NetworkInterfaces.plist - SCPreferencesRef sourceNetworkInterfacePrefs = NULL; // Source SCPreferencesRef for preferences.plist and NetworkInterfaces.plist + SCPreferencesRef sourceNetworkInterfacePrefs = NULL; // Source SCPreferencesRef for preferences.plist and NetworkInterfaces.plist CFURLRef sourcePreferencesFile = NULL; char sourcePreferencesFileStr[PATH_MAX]; CFStringRef sourcePreferencesFileString = NULL; SCPreferencesRef sourcePrefs = NULL; - CFArrayRef targetConfigurationFiles = NULL; // Path to the target configuration files where migration will take place to + CFArrayRef targetConfigurationFiles = NULL; // Path to the target configuration files where migration will take place to Boolean targetConfigurationFilesPresent; - CFURLRef targetNetworkInterfaceFile = NULL; // Target CFURLRef for preferences.plist and NetworkInterfaces.plist + CFStringRef targetModel = NULL; + CFURLRef targetNetworkInterfaceFile = NULL; // Target CFURLRef for preferences.plist and NetworkInterfaces.plist char targetNetworkInterfaceFileStr[PATH_MAX]; CFStringRef targetNetworkInterfaceFileString = NULL; // Target CFStringRef for preferences.plist and NetworkInterfaces.plist - SCPreferencesRef targetNetworkInterfacePrefs = NULL; // Target SCPreferencesRef for preferences.plist and NetworkInterfaces.plist + SCPreferencesRef targetNetworkInterfacePrefs = NULL; // Target SCPreferencesRef for preferences.plist and NetworkInterfaces.plist CFURLRef targetPreferencesFile = NULL; char targetPreferencesFileStr[PATH_MAX]; CFStringRef targetPreferencesFileString = NULL; SCPreferencesRef targetPrefs = NULL; + Boolean isUpgradeScenario = FALSE; CFMutableDictionaryRef validityOptions = NULL; // Check if configuration files exist in sourceDir if (__SCNetworkConfigurationMigrateConfigurationFilesPresent(sourceDir, &sourceConfigurationFiles) == FALSE) { - SCLog(_sc_debug, LOG_NOTICE, CFSTR("_SCNetworkConfigurationMigrateConfiguration: sourceDir: (%@) doesn't contain configuration files"), sourceDir); + SC_log(LOG_INFO, "sourceDir: (%@) doesn't contain configuration files", sourceDir); goto done; } sourcePreferencesFile = CFArrayGetValueAtIndex(sourceConfigurationFiles, PREFERENCES_PLIST_INDEX); - if (CFURLGetFileSystemRepresentation(sourcePreferencesFile, TRUE, (UInt8*)sourcePreferencesFileStr, sizeof(sourcePreferencesFileStr)) == FALSE) { - SCLog(_sc_debug, LOG_NOTICE, CFSTR("_SCNetworkConfigurationMigrateConfiguration: Cannot get file system representation for url: %@"), sourcePreferencesFile); + if (!CFURLGetFileSystemRepresentation(sourcePreferencesFile, TRUE, (UInt8*)sourcePreferencesFileStr, sizeof(sourcePreferencesFileStr))) { + SC_log(LOG_NOTICE, "Cannot get file system representation for url: %@", sourcePreferencesFile); goto done; } sourceNetworkInterfaceFile = CFArrayGetValueAtIndex(sourceConfigurationFiles, NETWORK_INTERFACES_PLIST_INDEX); - if (CFURLGetFileSystemRepresentation(sourceNetworkInterfaceFile, TRUE, (UInt8*)sourceNetworkInterfaceFileStr, sizeof(sourceNetworkInterfaceFileStr)) == FALSE) { - SCLog(_sc_debug, LOG_NOTICE, CFSTR("_SCNetworkConfigurationMigrateConfiguration: Cannot get file system representation for url: %@"), sourceNetworkInterfaceFile); + if (!CFURLGetFileSystemRepresentation(sourceNetworkInterfaceFile, TRUE, (UInt8*)sourceNetworkInterfaceFileStr, sizeof(sourceNetworkInterfaceFileStr))) { + SC_log(LOG_NOTICE, "Cannot get file system representation for url: %@", sourceNetworkInterfaceFile); goto done; } @@ -3133,23 +3302,23 @@ _SCNetworkConfigurationMigrateConfiguration(CFURLRef sourceDir, CFURLRef targetD if ((sourcePrefs == NULL) || (sourceNetworkInterfacePrefs == NULL)) { goto done; } - + if ((targetConfigurationFilesPresent = __SCNetworkConfigurationMigrateConfigurationFilesPresent(targetDir, &targetConfigurationFiles)) == FALSE) { if (targetConfigurationFiles == NULL) { - SCLog(_sc_debug, LOG_NOTICE, CFSTR("_SCNetworkConfigurationMigrateConfiguration: targetConfigurationFiles is NULL")); + SC_log(LOG_DEBUG, "targetConfigurationFiles is NULL"); goto done; } - SCLog(_sc_debug, LOG_NOTICE, CFSTR("_SCNetworkConfigurationMigrateConfiguration: targetDir: (%@) doesn't contain configuration files ... Need to create default configuration"), targetDir); + SC_log(LOG_INFO, "targetDir: (%@) doesn't contain configuration files ... Need to create default configuration", targetDir); } - + targetPreferencesFile = CFArrayGetValueAtIndex(targetConfigurationFiles, PREFERENCES_PLIST_INDEX); - if (CFURLGetFileSystemRepresentation(targetPreferencesFile, TRUE, (UInt8*)targetPreferencesFileStr, sizeof(targetPreferencesFileStr)) == FALSE) { - SCLog(_sc_debug, LOG_NOTICE, CFSTR("_SCNetworkConfigurationMigrateConfiguration: Cannot get file system representation for url: %@"), targetPreferencesFile); + if (!CFURLGetFileSystemRepresentation(targetPreferencesFile, TRUE, (UInt8*)targetPreferencesFileStr, sizeof(targetPreferencesFileStr))) { + SC_log(LOG_NOTICE, "Cannot get file system representation for url: %@", targetPreferencesFile); goto done; } targetNetworkInterfaceFile = CFArrayGetValueAtIndex(targetConfigurationFiles, NETWORK_INTERFACES_PLIST_INDEX); - if (CFURLGetFileSystemRepresentation(targetNetworkInterfaceFile, TRUE, (UInt8*)targetNetworkInterfaceFileStr, sizeof(targetNetworkInterfaceFileStr)) == FALSE) { - SCLog(_sc_debug, LOG_NOTICE, CFSTR("_SCNetworkConfigurationMigrateConfiguration: Cannot get file system representation for url: %@"), targetNetworkInterfaceFile); + if (!CFURLGetFileSystemRepresentation(targetNetworkInterfaceFile, TRUE, (UInt8*)targetNetworkInterfaceFileStr, sizeof(targetNetworkInterfaceFileStr))) { + SC_log(LOG_NOTICE, "Cannot get file system representation for url: %@", targetNetworkInterfaceFile); goto done; } @@ -3166,10 +3335,10 @@ _SCNetworkConfigurationMigrateConfiguration(CFURLRef sourceDir, CFURLRef targetD else { targetPrefs = __SCNetworkCreateDefaultPref(targetPreferencesFileString); targetNetworkInterfacePrefs = __SCNetworkCreateDefaultNIPrefs(targetNetworkInterfaceFileString); - + if (targetPrefs == NULL || targetNetworkInterfacePrefs == NULL) { - SCLog(_sc_debug, LOG_NOTICE, CFSTR("_SCNetworkConfigurationMigrateConfiguration: Could not create default configuration.")); + SC_log(LOG_DEBUG, "Could not create default configuration"); goto done; } } @@ -3177,113 +3346,171 @@ _SCNetworkConfigurationMigrateConfiguration(CFURLRef sourceDir, CFURLRef targetD &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); CFDictionaryAddValue(validityOptions, kSCNetworkConfigurationRepair, kCFBooleanTrue); - - SCLog(_sc_debug, LOG_NOTICE, CFSTR("sourcePreferenceFileString: %@\n sourceNetworkInterfaceFileString:%@\n targetPreferencesFileString:%@\ntargetNetworkInterfaceFileString:%@"), sourcePreferencesFileString, sourceNetworkInterfaceFileString, - targetPreferencesFileString, targetNetworkInterfaceFileString); + + SC_log(LOG_DEBUG, "sourcePreferenceFileString: %@\n" + "sourceNetworkInterfaceFileString:%@\n" + "targetPreferencesFileString:%@\n" + "targetNetworkInterfaceFileString:%@", + sourcePreferencesFileString, + sourceNetworkInterfaceFileString, + targetPreferencesFileString, + targetNetworkInterfaceFileString); // Setting Bypass Interface to avoid looking at system interfaces __SCPreferencesSetLimitSCNetworkConfiguration(sourcePrefs, TRUE); __SCPreferencesSetLimitSCNetworkConfiguration(targetPrefs, TRUE); + sourceModel = SCPreferencesGetValue(sourcePrefs, MODEL); + targetModel = SCPreferencesGetValue(targetPrefs, MODEL); + + isUpgradeScenario = (isA_CFString(sourceModel) && isA_CFString(targetModel) && CFStringCompare(sourceModel, targetModel, 0) == kCFCompareEqualTo); + // Create services for builtin interfaces at source if they don't exist (void)_SCNetworkConfigurationCreateBuiltinInterfaceServices(sourcePrefs, sourceNetworkInterfacePrefs); // Checking validity of the source and destination preferences before continuing - if (_SCNetworkConfigurationCheckValidityUsingPreferences(sourcePrefs, + if (_SCNetworkConfigurationCheckValidityWithPreferences(sourcePrefs, sourceNetworkInterfacePrefs, validityOptions) == FALSE) { - SCLog(_sc_debug, LOG_NOTICE, CFSTR("_SCNetworkConfigurationMigrateConfiguration: Source configuration is not valid")); + SC_log(LOG_INFO, "Source configuration not valid"); goto skipServiceMigration; } // Only call this function if configuration files were not created by default if (targetConfigurationFilesPresent == TRUE) { // Create services for builtin interfaces at target if they don't exist (void)_SCNetworkConfigurationCreateBuiltinInterfaceServices(targetPrefs, targetNetworkInterfacePrefs); - if (_SCNetworkConfigurationCheckValidityUsingPreferences(targetPrefs, + if (_SCNetworkConfigurationCheckValidityWithPreferences(targetPrefs, targetNetworkInterfacePrefs, validityOptions) == FALSE) { - SCLog(_sc_debug, LOG_NOTICE, CFSTR("_SCNetworkConfigurationMigrateConfiguration: Target configuration is not valid")); + SC_log(LOG_INFO, "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); - builtinMapping = _SCNetworkConfigurationCopyBuiltinMapping(sourceNetworkInterfacePrefs, targetNetworkInterfacePrefs); - externalMapping = _SCNetworkConfigurationCopyExternalInterfaceMapping(sourceNetworkInterfacePrefs, targetNetworkInterfacePrefs); + // Content of target prefs + CFDictionaryRef targetPrefsContent = SCPreferencesPathGetValue(targetPrefs, CFSTR("/")); + CFDictionaryRef targetNIPrefsContent = SCPreferencesPathGetValue(targetNetworkInterfacePrefs, CFSTR("/")); - /* - TODO: - Now builtin and external interface mapping is complete, work needs to be done on updating the preferences.plist and NetworkInterface.plist. + // Backing up the target prefs into source prefs + SCPreferencesPathSetValue(upgradeSourcePrefs, CFSTR("/"), targetPrefsContent); + SCPreferencesPathSetValue(upgradeSourceNIPrefs, CFSTR("/"), targetNIPrefsContent); - Also, work needs to be done to check the validity of the data in preferences in source and target destinations, and after migration - */ + // Copying content from the source prefs + CFDictionaryRef sourcePrefsContent = SCPreferencesPathGetValue(sourcePrefs, CFSTR("/")); + CFDictionaryRef sourceNIPreferencesContent = SCPreferencesPathGetValue(sourceNetworkInterfacePrefs, CFSTR("/")); - newTargetNetworkInterfaceEntity = _SCNetworkMigrationCreateNetworkInterfaceArray(targetNetworkInterfacePrefs, externalMapping); - if (isA_CFArray(newTargetNetworkInterfaceEntity) == NULL) { - SCLog(_sc_debug, LOG_NOTICE, CFSTR("_SCNetworkConfigurationMigrateConfiguration: newTargetNetworkInterfaceEntity is NULL or not of correct type")); - goto done; - } - // Write new interface mapping to NetworkInterfaces.plist - if (__SCNetworkInterfaceSaveStoredWithPreferences(targetNetworkInterfacePrefs, newTargetNetworkInterfaceEntity) == FALSE) - { - SCLog(_sc_debug, LOG_NOTICE, CFSTR("_SCNetworkConfigurationMigrateConfiguration: SCNetworkInterfaceSaveStoreWithPreferences failed to update NetworkInterface.plist")); - goto done; - } - // Create BSD Name Mapping to facilitate mapping of services - bsdNameMapping = _SCNetworkMigrationCreateBSDNameMapping(builtinMapping, externalMapping); + // Setting the contents of the source prefs into the target prefs + SCPreferencesPathSetValue(targetPrefs, CFSTR("/"), sourcePrefsContent); + SCPreferencesPathSetValue(targetNetworkInterfacePrefs, CFSTR("/"), sourceNIPreferencesContent); - if (isA_CFDictionary(bsdNameMapping) == NULL) { - SCLog(_sc_debug, LOG_NOTICE, CFSTR("_SCNetworkConfigurationMigrateConfiguration: BSD Name Mapping is NULL")); - goto done; - } - SCLog(_sc_debug, LOG_NOTICE, CFSTR("BSD Name Mapping: %@"), bsdNameMapping); - serviceMapping = _SCNetworkMigrationCreateServiceMappingUsingBSDMapping(sourcePrefs, targetPrefs, bsdNameMapping); + // Getting the mapping of the non builtin interfaces between source and target + externalMapping = _SCNetworkConfigurationCopyExternalInterfaceMapping(upgradeSourceNIPrefs, targetNetworkInterfacePrefs); - if (isA_CFDictionary(serviceMapping) == NULL) { - SCLog(_sc_debug, LOG_NOTICE, CFSTR("_SCNetworkConfigurationMigrateConfiguration: Service Mapping is NULL")); - goto done; - } - SCLog(_sc_debug, LOG_NOTICE, CFSTR("Service Mapping: %@"), serviceMapping); + newTargetNetworkInterfaceEntity = _SCNetworkMigrationCreateNetworkInterfaceArray(targetNetworkInterfacePrefs, externalMapping, &foundNewInterface); + if (foundNewInterface) { + if (isA_CFArray(newTargetNetworkInterfaceEntity) == NULL) { + SC_log(LOG_INFO, "newTargetNetworkInterfaceEntity is NULL or not of correct type"); + goto done; + } + // Write new interface mapping to NetworkInterfaces.plist + if (__SCNetworkInterfaceSaveStoredWithPreferences(targetNetworkInterfacePrefs, newTargetNetworkInterfaceEntity) == FALSE) + { + SC_log(LOG_INFO, "SCNetworkInterfaceSaveStoreWithPreferences: failed to update NetworkInterfaces.plist"); + goto done; + } - setMapping = _SCNetworkMigrationCreateSetMapping(sourcePrefs, targetPrefs); - sourceServiceSetMapping = _SCNetworkMigrationCreateServiceSetMapping(sourcePrefs); - - // Perform the migration of services - if (_SCNetworkMigrationDoServiceMigration(sourcePrefs, targetPrefs, - serviceMapping, bsdNameMapping, - setMapping, sourceServiceSetMapping) == FALSE) { - SCLog(_sc_debug, LOG_NOTICE, CFSTR("_SCNetworkConfigurationMigrateConfiguration: SCNetworkMigrationDoServiceMigration failed to complete successfully")); - goto done; + // 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); + } + CFRelease(upgradeSourcePrefs); + CFRelease(upgradeSourceNIPrefs); } - + else { + builtinMapping = _SCNetworkConfigurationCopyBuiltinMapping(sourceNetworkInterfacePrefs, targetNetworkInterfacePrefs); + externalMapping = _SCNetworkConfigurationCopyExternalInterfaceMapping(sourceNetworkInterfacePrefs, targetNetworkInterfacePrefs); + + newTargetNetworkInterfaceEntity = _SCNetworkMigrationCreateNetworkInterfaceArray(targetNetworkInterfacePrefs, externalMapping, NULL); + if (isA_CFArray(newTargetNetworkInterfaceEntity) == NULL) { + SC_log(LOG_INFO, "newTargetNetworkInterfaceEntity is NULL or not of correct type"); + goto done; + } + // Write new interface mapping to NetworkInterfaces.plist + if (__SCNetworkInterfaceSaveStoredWithPreferences(targetNetworkInterfacePrefs, newTargetNetworkInterfaceEntity) == FALSE) + { + SC_log(LOG_INFO, "SCNetworkInterfaceSaveStoreWithPreferences: failed to update NetworkInterfaces.plist"); + goto done; + } + // 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 (isA_CFDictionary(serviceMapping) == NULL) { + SC_log(LOG_INFO, "Service mapping is NULL"); + goto done; + } + SC_log(LOG_NOTICE, "Service mapping: %@", serviceMapping); + + setMapping = _SCNetworkMigrationCreateSetMapping(sourcePrefs, targetPrefs); + sourceServiceSetMapping = _SCNetworkMigrationCreateServiceSetMapping(sourcePrefs); + + // Perform the migration of services + if (_SCNetworkMigrationDoServiceMigration(sourcePrefs, targetPrefs, + serviceMapping, bsdNameMapping, + setMapping, sourceServiceSetMapping) == FALSE) { + SC_log(LOG_INFO, "SCNetworkMigrationDoServiceMigration: failed to complete successfully"); + goto done; + } + #if !TARGET_OS_IPHONE - // Migrating Virtual Network Interface - if (_SCNetworkMigrationDoVirtualNetworkInterfaceMigration(sourcePrefs, sourceNetworkInterfacePrefs, - targetPrefs, targetNetworkInterfacePrefs, - bsdNameMapping, setMapping, sourceServiceSetMapping) == FALSE) { - SCLog(_sc_debug, LOG_NOTICE, CFSTR("_SCNetworkConfigurationMigrateConfiguration: _SCNetworkMigrationDoVirtualNetworkInterfaceMigration failed to complete successfully")); - } + // Migrating Virtual Network Interface + if (_SCNetworkMigrationDoVirtualNetworkInterfaceMigration(sourcePrefs, sourceNetworkInterfacePrefs, + targetPrefs, targetNetworkInterfacePrefs, + bsdNameMapping, setMapping, sourceServiceSetMapping) == FALSE) { + SC_log(LOG_INFO, "_SCNetworkMigrationDoVirtualNetworkInterfaceMigration: failed to complete successfully"); + } #endif - // Migrate Service Order - if (_SCNetworkMigrationDoServiceOrderMigration(sourcePrefs, targetPrefs, setMapping) == FALSE) { - SCLog(_sc_debug, LOG_NOTICE, CFSTR("_SCNetworkConfigurationMigrateConfiguration: _SCNetworkMigrationDoServiceOrderMigration failed to complete successfully")); + // Migrate Service Order + if (_SCNetworkMigrationDoServiceOrderMigration(sourcePrefs, targetPrefs, setMapping) == FALSE) { + SC_log(LOG_INFO, "_SCNetworkMigrationDoServiceOrderMigration: failed to complete successfully"); + } } - + skipServiceMigration: // Migrating System Information - if (_SCNetworkMigrationDoSystemMigration(sourcePrefs, targetPrefs) == FALSE) { - SCLog(_sc_debug, LOG_NOTICE, CFSTR("_SCNetworkConfigurationMigrateConfiguration: _SCNetworkMigrationDoSystemMigration failed to complete successfully")); + if (isUpgradeScenario == FALSE) { + if (_SCNetworkMigrationDoSystemMigration(sourcePrefs, targetPrefs) == FALSE) { + SC_log(LOG_INFO, "_SCNetworkMigrationDoSystemMigration: failed to complete successfully"); + } } - - if (_SCNetworkConfigurationCheckValidityUsingPreferences(targetPrefs, targetNetworkInterfacePrefs, NULL) == FALSE) { - SCLog(_sc_debug, LOG_NOTICE, CFSTR("_SCNetworkConfigurationMigrateConfiguration: Migrated configuration is not valid")); + if (_SCNetworkConfigurationCheckValidityWithPreferences(targetPrefs, targetNetworkInterfacePrefs, validityOptions) == FALSE) { + SC_log(LOG_INFO, "Migrated configuration not valid"); goto done; } if (SCPreferencesCommitChanges(targetPrefs) == FALSE) { - SCLog(TRUE, LOG_ERR, CFSTR("_SCNetworkConfigurationMigrateConfiguration: Error commiting targetPrefs, %s"), SCErrorString(SCError())); + SC_log(LOG_INFO, "SCPreferencesCommitChanges(target preferences.plist) failed: %s", SCErrorString(SCError())); goto done; } if (SCPreferencesCommitChanges(targetNetworkInterfacePrefs) == FALSE) { - SCLog(TRUE, LOG_ERR, CFSTR("_SCNetworkConfigurationMigrateConfiguration: Error commiting targetNetworkInterfacePrefs, %s"), SCErrorString(SCError())); + SC_log(LOG_INFO, "SCPreferencesCommitChanges(target NetworkInterfaces.plist) failed: %s", SCErrorString(SCError())); goto done; } migrationSuccess = TRUE; @@ -3531,64 +3758,64 @@ _SCNetworkMigrationAreConfigurationsIdentical (CFURLRef configurationURL, char networkInterfaceExpectedStr[PATH_MAX]; char prefsConfigStr[PATH_MAX]; char prefsExpectedStr[PATH_MAX]; - + if (configurationURL == NULL || expectedConfigurationURL == NULL) { return FALSE; } baseConfigURL = CFURLCreateWithFileSystemPathRelativeToBase(NULL, PREFS_DEFAULT_DIR_RELATIVE, kCFURLPOSIXPathStyle, TRUE, configurationURL); configPreferencesURL = CFURLCreateFromFileSystemRepresentationRelativeToBase(NULL, (const UInt8*) PREFS_DEFAULT_CONFIG_PLIST, sizeof(PREFS_DEFAULT_CONFIG_PLIST), FALSE, baseConfigURL); - - if (CFURLResourceIsReachable(configPreferencesURL, NULL) == FALSE) { - SCLog(_sc_debug, LOG_NOTICE, CFSTR("_SCNetworkMigrationAreConfigurationsIdentical: preferences.plist file is not present.")); + + if (CFURLResourceIsReachable(configPreferencesURL, NULL) == FALSE) { + SC_log(LOG_INFO, "No preferences.plist file"); goto done; - } - + } + configNetworkInterfacesURL = CFURLCreateFromFileSystemRepresentationRelativeToBase(NULL, (const UInt8*)NETWORK_INTERFACES_PREFS_PLIST, sizeof(NETWORK_INTERFACES_PREFS_PLIST), FALSE, baseConfigURL); - + if (CFURLResourceIsReachable(configNetworkInterfacesURL, NULL) == FALSE) { - SCLog(_sc_debug, LOG_NOTICE, CFSTR("_SCNetworkMigrationAreConfigurationsIdentical: NetworkInterfaces.plist file is not present.")); + SC_log(LOG_INFO, "No NetworkInterfaces.plist file"); goto done; } - - if (CFURLGetFileSystemRepresentation(configPreferencesURL, TRUE, (UInt8*)prefsConfigStr, sizeof(prefsConfigStr)) == FALSE) { - SCLog(_sc_debug, LOG_NOTICE, CFSTR("_SCNetworkMigrationAreConfigurationsIdentical: Could not extract preferences information")); + + if (!CFURLGetFileSystemRepresentation(configPreferencesURL, TRUE, (UInt8*)prefsConfigStr, sizeof(prefsConfigStr))) { + SC_log(LOG_NOTICE, "Cannot get file system representation for url: %@", configPreferencesURL); goto done; } - if (CFURLGetFileSystemRepresentation(configNetworkInterfacesURL, TRUE, (UInt8*)networkInterfaceConfigStr, sizeof(networkInterfaceConfigStr)) == FALSE) { - SCLog(_sc_debug, LOG_NOTICE, CFSTR("_SCNetworkMigrationAreConfigurationsIdentical: Could not extract network interfaces information")); + if (!CFURLGetFileSystemRepresentation(configNetworkInterfacesURL, TRUE, (UInt8*)networkInterfaceConfigStr, sizeof(networkInterfaceConfigStr))) { + SC_log(LOG_NOTICE, "Cannot get file system representation for url: %@", configNetworkInterfacesURL); goto done; } - + baseExpectedConfigURL = CFURLCreateWithFileSystemPathRelativeToBase(NULL, PREFS_DEFAULT_DIR_RELATIVE, kCFURLPOSIXPathStyle, TRUE, expectedConfigurationURL); expectedPreferencesURL = CFURLCreateFromFileSystemRepresentationRelativeToBase(NULL, (const UInt8*)PREFS_DEFAULT_CONFIG_PLIST, sizeof(PREFS_DEFAULT_CONFIG_PLIST), FALSE, baseExpectedConfigURL); - + if (CFURLResourceIsReachable(expectedPreferencesURL, NULL) == FALSE) { - SCLog(_sc_debug, LOG_NOTICE, CFSTR("_SCNetworkMigrationAreConfigurationsIdentical: preferences.plist file is not present in the expected configuration.")); + SC_log(LOG_INFO, "No expected preferences.plist file"); goto done; } - + expectedNetworkInterfaceURL = CFURLCreateFromFileSystemRepresentationRelativeToBase(NULL, (const UInt8*)NETWORK_INTERFACES_PREFS_PLIST, sizeof(NETWORK_INTERFACES_PREFS_PLIST), FALSE, baseExpectedConfigURL); - + if (CFURLResourceIsReachable(expectedNetworkInterfaceURL, NULL) == FALSE) { - SCLog(_sc_debug, LOG_NOTICE, CFSTR("_SCNetworkMigrationAreConfigurationsIdentical: NetworkInterfaces.plist file is not present in the expected configuration.")); + SC_log(LOG_INFO, "No expected NetworkInterfaces.plist file"); goto done; } - - if (CFURLGetFileSystemRepresentation(expectedPreferencesURL, TRUE, (UInt8*)prefsExpectedStr, sizeof(prefsExpectedStr)) == FALSE) { - SCLog(_sc_debug, LOG_NOTICE, CFSTR("_SCNetworkMigrationAreConfigurationsIdentical: Could not extract preferences information")); + + if (!CFURLGetFileSystemRepresentation(expectedPreferencesURL, TRUE, (UInt8*)prefsExpectedStr, sizeof(prefsExpectedStr))) { + SC_log(LOG_NOTICE, "Cannot get file system representation for url: %@", expectedPreferencesURL); goto done; } - if (CFURLGetFileSystemRepresentation(expectedNetworkInterfaceURL, TRUE, (UInt8*)networkInterfaceExpectedStr, sizeof(networkInterfaceExpectedStr)) == FALSE) { - SCLog(_sc_debug, LOG_NOTICE, CFSTR("_SCNetworkMigrationAreConfigurationsIdentical: Could not extract network interfaces information")); + if (!CFURLGetFileSystemRepresentation(expectedNetworkInterfaceURL, TRUE, (UInt8*)networkInterfaceExpectedStr, sizeof(networkInterfaceExpectedStr))) { + SC_log(LOG_NOTICE, "Cannot get file system representation for url: %@", expectedNetworkInterfaceURL); goto done; } - + prefsConfigString = CFStringCreateWithFormat(NULL, NULL, CFSTR("%s"), prefsConfigStr); networkInterfaceConfigString = CFStringCreateWithFormat(NULL, NULL, CFSTR("%s"), networkInterfaceConfigStr); prefsExpectedString = CFStringCreateWithFormat(NULL, NULL, CFSTR("%s"), prefsExpectedStr); networkInterfaceExpectedString = CFStringCreateWithFormat(NULL, NULL, CFSTR("%s"), networkInterfaceExpectedStr); - + configPref = SCPreferencesCreate(NULL, PLUGIN_ID, prefsConfigString); expectedConfigPref = SCPreferencesCreate(NULL, PLUGIN_ID, prefsExpectedString); configNetworkInterfacePref = SCPreferencesCreate(NULL, PLUGIN_ID, networkInterfaceConfigString); @@ -3598,7 +3825,7 @@ done: expectedConfigPref == NULL || configNetworkInterfacePref == NULL || expectedNetworkInterfacePref == NULL) { - SCLog(_sc_debug, LOG_NOTICE, CFSTR("_SCNetworkMigrationAreConfigurationsIdentical: One of the preferences is NULL")); + SC_log(LOG_INFO, "One of the preferences is NULL"); isIdentical = FALSE; } else { @@ -3652,23 +3879,23 @@ done: CFArrayRef _SCNetworkConfigurationCopyMigrationRemovePaths (CFArrayRef targetPaths, - CFURLRef targetDir) + CFURLRef targetDir) { CFURLRef affectedURL; char filePath[PATH_MAX]; CFURLRef targetFile; CFMutableArrayRef toBeRemoved = CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks); - + for (CFIndex idx = 0; idx < CFArrayGetCount(targetPaths); idx++) { affectedURL = CFArrayGetValueAtIndex(targetPaths, idx); - - if (CFURLGetFileSystemRepresentation(affectedURL, TRUE, (UInt8*)filePath, sizeof(filePath)) == FALSE) { - SCLog(_sc_debug, LOG_NOTICE, CFSTR("filesToBeRemoved: Could not get file system representation")); + + if (!CFURLGetFileSystemRepresentation(affectedURL, TRUE, (UInt8*)filePath, sizeof(filePath))) { + SC_log(LOG_NOTICE, "Cannot get file system representation for url: %@", affectedURL); continue; } targetFile = CFURLCreateFromFileSystemRepresentationRelativeToBase(NULL, (const UInt8*)filePath, strnlen(filePath, sizeof(filePath)), FALSE, targetDir); - + if (CFURLResourceIsReachable(targetFile, NULL) == FALSE) { CFArrayAppendValue(toBeRemoved, affectedURL); } diff --git a/SystemConfiguration.fproj/SCNetworkReachability.c b/SystemConfiguration.fproj/SCNetworkReachability.c index 5533c47..eb1dd24 100644 --- a/SystemConfiguration.fproj/SCNetworkReachability.c +++ b/SystemConfiguration.fproj/SCNetworkReachability.c @@ -44,14 +44,9 @@ #include #include #include -#include #include #include -#if !TARGET_OS_IPHONE -#include -#endif // !TARGET_OS_IPHONE - #include #include #include @@ -64,52 +59,30 @@ #include #include #include -#define KERNEL_PRIVATE -#include -#undef KERNEL_PRIVATE - -#ifndef s6_addr16 -#define s6_addr16 __u6_addr.__u6_addr16 -#endif +#include -#include "SCNetworkConnectionInternal.h" #include "SCNetworkReachabilityInternal.h" -#include -#include - #include - +#include #define DEBUG_REACHABILITY_TYPE_NAME "create w/name" -#define DEBUG_REACHABILITY_TYPE_NAME_CLONE " > clone" #define DEBUG_REACHABILITY_TYPE_NAME_OPTIONS " + options" #define DEBUG_REACHABILITY_TYPE_ADDRESS "create w/address" -#define DEBUG_REACHABILITY_TYPE_ADDRESS_CLONE " > clone" #define DEBUG_REACHABILITY_TYPE_ADDRESS_OPTIONS " + options" #define DEBUG_REACHABILITY_TYPE_ADDRESSPAIR "create w/address pair" -#define DEBUG_REACHABILITY_TYPE_ADDRESSPAIR_CLONE " > clone" #define DEBUG_REACHABILITY_TYPE_ADDRESSPAIR_OPTIONS " + options" #define DEBUG_REACHABILITY_TYPE_PTR "create w/ptr" -#define DEBUG_REACHABILITY_TYPE_PTR_CLONE " > clone" #define DEBUG_REACHABILITY_TYPE_PTR_OPTIONS " + options" -#define DNS_FLAGS_FORMAT "[%s%s%s%s%s]" -#define DNS_FLAGS_VALUES(t) t->dnsHaveV4 ? "4" : "", \ - t->dnsHaveV6 ? "6" : "", \ - t->dnsHavePTR ? "P" : "", \ - t->dnsHaveTimeout ? "T" : "", \ - t->dnsHaveError ? "E" : "" - - static pthread_mutexattr_t lock_attr; #define MUTEX_INIT(m) { \ @@ -133,36 +106,24 @@ static pthread_mutexattr_t lock_attr; } -#define SCNETWORKREACHABILITY_TRIGGER_KEY CFSTR("com.apple.SCNetworkReachability:FORCE-CHANGE") - - #define N_QUICK 64 +#define REACHABILITY_NETWORK_EXTENSION_AGENT_DOMAIN "NetworkExtension" +#define REACHABILITY_AGENT_DATA_KEY "data" + static CFStringRef __SCNetworkReachabilityCopyDescription (CFTypeRef cf); static void __SCNetworkReachabilityDeallocate (CFTypeRef cf); -static void reachPerform (void *info); -static Boolean reachUpdate (SCNetworkReachabilityRef target); - - -static void -__SCNetworkReachabilityHandleChanges (SCDynamicStoreRef store, - CFArrayRef changedKeys, - void *info); - -static Boolean -__SCNetworkReachabilityScheduleWithRunLoop (SCNetworkReachabilityRef target, - CFRunLoopRef runLoop, - CFStringRef runLoopMode, - dispatch_queue_t queue, - Boolean onDemand); - -static Boolean -__SCNetworkReachabilityUnscheduleFromRunLoop (SCNetworkReachabilityRef target, - CFRunLoopRef runLoop, - CFStringRef runLoopMode, - Boolean onDemand); +static SCNetworkReachabilityFlags +__SCNetworkReachabilityGetFlagsFromPath(nw_path_t path, + ReachabilityAddressType type, + nw_resolver_status_t resolverStatus, + nw_array_t resolvedEndpoints, + Boolean resolvedEndpointUseFlags, + SCNetworkReachabilityFlags resolvedEndpointFlags); +static Boolean __SCNetworkReachabilitySetDispatchQueue(SCNetworkReachabilityPrivateRef targetPrivate, + dispatch_queue_t queue); static CFTypeID __kSCNetworkReachabilityTypeID = _kCFRuntimeNotATypeID; @@ -181,5803 +142,1227 @@ static const CFRuntimeClass __SCNetworkReachabilityClass = { static pthread_once_t initialized = PTHREAD_ONCE_INIT; -static const ReachabilityInfo NOT_REACHABLE = { 0, 0, 0, { 0 }, FALSE }; -static const ReachabilityInfo NOT_REPORTED = { 0, 0xFFFFFFFF, 0, { 0 }, FALSE }; -static int rtm_seq = 0; - - -static const struct timeval TIME_ZERO = { 0, 0 }; - - -static int dnsCount = 0; -static int dnsGeneration = 0; -static DNSServiceRef dnsMain = NULL; -static CFMutableSetRef dnsUpdated = NULL; - -static Boolean D_serverBypass = FALSE; - - - -#if !TARGET_OS_IPHONE -/* - * Power capabilities (sleep/wake) - */ -#define POWER_CAPABILITIES_NETWORK ( kIOPMCapabilityCPU \ - | kIOPMCapabilityNetwork \ - | kIOPMCapabilityVideo) -static IOPMSystemPowerStateCapabilities power_capabilities = POWER_CAPABILITIES_NETWORK; -#endif // !TARGET_OS_IPHONE - - -/* - * host "something has changed" notifications - */ - -// Note: protected by _hn_target_queue() -static SCDynamicStoreRef hn_store = NULL; -static CFMutableSetRef hn_targets = NULL; - - -static dispatch_queue_t -_hn_changes_queue() -{ - static dispatch_once_t once; - static dispatch_queue_t q = NULL; - - dispatch_once(&once, ^{ - q = dispatch_queue_create("SCNetworkReachability.handleChanges", NULL); - }); - - return q; -} - static dispatch_queue_t -_hn_target_queue() +_callback_queue() { static dispatch_once_t once; static dispatch_queue_t q; dispatch_once(&once, ^{ - q = dispatch_queue_create("SCNetworkReachability.targetManagement", NULL); + q = dispatch_queue_create("SCNetworkReachability.callback", NULL); }); return q; } - -/* - * DNS configuration - */ - -typedef struct { - dns_config_t *config; - int refs; -} dns_configuration_t; - - -// Note: protected by "dns_lock" -static pthread_mutex_t dns_lock = PTHREAD_MUTEX_INITIALIZER; -static dns_configuration_t *dns_configuration = NULL; -static int dns_token; -static Boolean dns_token_valid = FALSE; - - - - -typedef enum { - dns_query_async, - dns_query_mdns, - dns_query_mdns_timeout, -} query_type; +#pragma mark - +#pragma mark SCNetworkReachability APIs -static void -__mark_operation_start(struct timeval *queryStart, - struct timeval *queryEnd) +static __inline__ CFTypeRef +isA_SCNetworkReachability(CFTypeRef obj) { - (void) gettimeofday(queryStart, NULL); - *queryEnd = TIME_ZERO; - - return; + return (isA_CFType(obj, SCNetworkReachabilityGetTypeID())); } - -static void -__mark_operation_end(SCNetworkReachabilityRef target, - Boolean found, - query_type query_type, - struct timeval *queryStart, - struct timeval *queryEnd) +CFStringRef +_SCNetworkReachabilityCopyTargetDescription(SCNetworkReachabilityRef target) { - struct timeval queryElapsed; + CFAllocatorRef allocator = CFGetAllocator(target); + CFMutableStringRef str; SCNetworkReachabilityPrivateRef targetPrivate = (SCNetworkReachabilityPrivateRef)target; - (void) gettimeofday(queryEnd, NULL); - - if (!_sc_debug && - (query_type != dns_query_mdns_timeout)) { - return; - } - - if (!timerisset(queryStart)) { - return; - } - - timersub(queryEnd, queryStart, &queryElapsed); - switch (query_type) { - - #define QUERY_TIME__FMT "%ld.%6.6d" - #define QUERY_TIME__DIV 1 - - case dns_query_async : - SCLog(TRUE, LOG_INFO, - CFSTR("%sasync DNS complete%s (query time = " QUERY_TIME__FMT ")"), - targetPrivate->log_prefix, - found ? "" : ", host not found", - queryElapsed.tv_sec, - queryElapsed.tv_usec / QUERY_TIME__DIV); + str = CFStringCreateMutable(allocator, 0); + switch (targetPrivate->type) { + case reachabilityTypeAddress : + case reachabilityTypeAddressPair : { + char buf[64]; + if (targetPrivate->localAddressEndpoint != NULL) { + _SC_sockaddr_to_string(nw_endpoint_get_address(targetPrivate->localAddressEndpoint), buf, sizeof(buf)); + CFStringAppendFormat(str, NULL, CFSTR("local address = %s"), + buf); + } + if (targetPrivate->remoteAddressEndpoint != NULL) { + _SC_sockaddr_to_string(nw_endpoint_get_address(targetPrivate->remoteAddressEndpoint), buf, sizeof(buf)); + CFStringAppendFormat(str, NULL, CFSTR("%s%saddress = %s"), + targetPrivate->localAddressEndpoint ? ", " : "", + (targetPrivate->type == reachabilityTypeAddressPair) ? "remote " : "", + buf); + } else { + CFStringAppendFormat(str, NULL, CFSTR("default path")); + } break; - case dns_query_mdns : - SCLog(TRUE, LOG_INFO, - CFSTR("%s[m]DNS query complete%s (query time = " QUERY_TIME__FMT "), " DNS_FLAGS_FORMAT), - targetPrivate->log_prefix, - found ? "" : ", host not found", - queryElapsed.tv_sec, - queryElapsed.tv_usec / QUERY_TIME__DIV, - DNS_FLAGS_VALUES(targetPrivate)); + } + case reachabilityTypeName : { + CFStringAppendFormat(str, NULL, CFSTR("name = %s"), nw_endpoint_get_hostname(targetPrivate->hostnameEndpoint)); break; - case dns_query_mdns_timeout : - SCLog(TRUE, LOG_ERR, - CFSTR("%s[m]DNS query timeout (query time = " QUERY_TIME__FMT "), " DNS_FLAGS_FORMAT), - targetPrivate->log_prefix, - queryElapsed.tv_sec, - queryElapsed.tv_usec / QUERY_TIME__DIV, - DNS_FLAGS_VALUES(targetPrivate)); + } + case reachabilityTypePTR : { + char buf[64]; + if (targetPrivate->remoteAddressEndpoint != NULL) { + _SC_sockaddr_to_string(nw_endpoint_get_address(targetPrivate->remoteAddressEndpoint), buf, sizeof(buf)); + CFStringAppendFormat(str, NULL, CFSTR("ptr = %s"), + buf); + } break; + } } - return; -} - - -static __inline__ Boolean -__reach_changed(ReachabilityInfo *r1, ReachabilityInfo *r2) -{ - if (r1->flags != r2->flags) { - // if the reachability flags changed - return TRUE; - } - - if (r1->if_index != r2->if_index) { - // if the target interface changed - return TRUE; - } - - if ((r1->sleeping != r2->sleeping) && !r2->sleeping) { - // if our sleep/wake status changed and if we - // are no longer sleeping - return TRUE; - } - - return FALSE; + return str; } -static __inline__ void -_reach_set(ReachabilityInfo *dst, - const ReachabilityInfo *src, - uint64_t cycle, - unsigned int requested_if_index, - const char *requested_if_name) +CFStringRef +_SCNetworkReachabilityCopyTargetFlags(SCNetworkReachabilityRef target) { - memcpy(dst, src, sizeof(ReachabilityInfo)); - dst->cycle = cycle; - - if (!(dst->flags & kSCNetworkReachabilityFlagsReachable) || - (dst->flags & kSCNetworkReachabilityFlagsConnectionRequired)) { - // if not reachable or connection required, return the - // requested if_index and if_name. - dst->if_index = requested_if_index; - if (requested_if_name != NULL) { - strlcpy(dst->if_name, requested_if_name, sizeof(dst->if_name)); - } else { - dst->if_name[0] = '\0'; - } - } + CFAllocatorRef allocator = CFGetAllocator(target); + CFStringRef str; + SCNetworkReachabilityPrivateRef targetPrivate = (SCNetworkReachabilityPrivateRef)target; - return; + str = CFStringCreateWithFormat(allocator, + NULL, + CFSTR("flags = 0x%08x, if_index = %u"), + __SCNetworkReachabilityGetFlagsFromPath(targetPrivate->lastPath, targetPrivate->type, targetPrivate->lastResolverStatus, targetPrivate->lastResolvedEndpoints, targetPrivate->lastResolvedEndpointHasFlags, targetPrivate->lastResolvedEndpointFlags), + targetPrivate->lastResolvedEndpointHasFlags ? targetPrivate->lastResolvedEndpointInterfaceIndex : nw_path_get_interface_index(targetPrivate->lastPath)); + return str; } -#pragma mark - -#pragma mark SCDynamicStore info - - -typedef struct { - SCDynamicStoreRef store; - CFStringRef entity; - CFDictionaryRef dict; - CFIndex n; - const void ** keys; - const void * keys_q[N_QUICK]; - const void ** values; - const void * values_q[N_QUICK]; -} ReachabilityStoreInfo, *ReachabilityStoreInfoRef; - - -static ReachabilityStoreInfo S_storeInfo = { 0 }; -static Boolean S_storeInfoActive = FALSE; - - -static dispatch_queue_t -_storeInfo_queue() +static CFStringRef +__SCNetworkReachabilityCopyDescription(CFTypeRef cf) { - static dispatch_once_t once; - static dispatch_queue_t q; + CFAllocatorRef allocator = CFGetAllocator(cf); + CFMutableStringRef result; + CFStringRef str; + SCNetworkReachabilityRef target = (SCNetworkReachabilityRef)cf; + SCNetworkReachabilityPrivateRef targetPrivate = (SCNetworkReachabilityPrivateRef)target; - dispatch_once(&once, ^{ - q = dispatch_queue_create("SCNetworkReachability.storeInfo", NULL); - }); + MUTEX_LOCK(&targetPrivate->lock); - return q; -} + result = CFStringCreateMutable(allocator, 0); + CFStringAppendFormat(result, NULL, CFSTR(" {"), cf, allocator); + // add target description + str = _SCNetworkReachabilityCopyTargetDescription(target); + CFStringAppend(result, str); + CFRelease(str); -static void -ReachabilityStoreInfo_copy(ReachabilityStoreInfoRef src, - ReachabilityStoreInfoRef dst) -{ - if (src->dict != NULL) { - dst->store = src->store; - CFRetain(dst->store); - - dst->dict = src->dict; - CFRetain(dst->dict); - - dst->n = src->n; - if (dst->n > 0) { - if (dst->n <= (CFIndex)(sizeof(dst->keys_q) / sizeof(CFTypeRef))) { - dst->keys = dst->keys_q; - dst->values = dst->values_q; + // add additional "name" info + if (isReachabilityTypeName(targetPrivate->type)) { + if (targetPrivate->resolver && targetPrivate->lastResolverStatus == nw_resolver_status_invalid) { + CFStringAppendFormat(result, NULL, CFSTR(" (DNS query active)")); + } else if (targetPrivate->lastResolverStatus != nw_resolver_status_invalid) { + CFStringAppendFormat(result, NULL, CFSTR(" (%s"), (targetPrivate->lastResolverStatus == nw_resolver_status_complete) ? "complete" : "in progress"); + if (nw_array_get_count(targetPrivate->lastResolvedEndpoints) > 0) { + nw_array_apply(targetPrivate->lastResolvedEndpoints, ^bool(size_t index, nw_object_t object) { + nw_endpoint_t endpoint = (nw_endpoint_t)object; + if (nw_endpoint_get_type(endpoint) == nw_endpoint_type_address) { + char buf[64]; + const struct sockaddr *sa = nw_endpoint_get_address(endpoint); + _SC_sockaddr_to_string(sa, buf, sizeof(buf)); + CFStringAppendFormat(result, NULL, CFSTR(", %s"), buf); + } else if (nw_endpoint_get_type(endpoint) == nw_endpoint_type_host) { + CFStringAppendFormat(result, NULL, CFSTR(", %s"), nw_endpoint_get_hostname(endpoint)); + } + return TRUE; + }); } else { - dst->keys = CFAllocatorAllocate(NULL, dst->n * sizeof(CFTypeRef), 0); - dst->values = CFAllocatorAllocate(NULL, dst->n * sizeof(CFTypeRef), 0); + CFStringAppendFormat(result, NULL, CFSTR(", no addresses")); } - memcpy(dst->keys, src->keys, dst->n * sizeof(CFTypeRef)); - memcpy(dst->values, src->values, dst->n * sizeof(CFTypeRef)); + CFStringAppendFormat(result, NULL, CFSTR(")")); } } - return; -} + if (targetPrivate->resolverBypass) { + CFStringAppendFormat(result, NULL, CFSTR(", !resolve")); + } + // add flags + if (targetPrivate->scheduled) { + str = _SCNetworkReachabilityCopyTargetFlags(target); + CFStringAppendFormat(result, NULL, CFSTR(", %@"), str); + CFRelease(str); + } -static void -ReachabilityStoreInfo_enable(Boolean enable) -{ - dispatch_sync(_storeInfo_queue(), ^{ - S_storeInfoActive = enable; - }); + CFStringAppendFormat(result, NULL, CFSTR("}")); - return; + MUTEX_UNLOCK(&targetPrivate->lock); + + return result; } static void -ReachabilityStoreInfo_free(ReachabilityStoreInfoRef store_info) +__SCNetworkReachabilityDeallocate(CFTypeRef cf) { - if ((store_info->n > 0) && (store_info->keys != store_info->keys_q)) { - CFAllocatorDeallocate(NULL, store_info->keys); - store_info->keys = NULL; + SCNetworkReachabilityRef target = (SCNetworkReachabilityRef)cf; + SCNetworkReachabilityPrivateRef targetPrivate = (SCNetworkReachabilityPrivateRef)target; - CFAllocatorDeallocate(NULL, store_info->values); - store_info->values = NULL; + if (_sc_debug && (_sc_log > 0)) { + SC_log(LOG_INFO, "%srelease", targetPrivate->log_prefix); } - store_info->n = 0; - if (store_info->dict != NULL) { - CFRelease(store_info->dict); - store_info->dict = NULL; + /* release resources */ + MUTEX_LOCK(&targetPrivate->lock); + targetPrivate->scheduled = FALSE; + + if (targetPrivate->hostnameEndpoint) { + network_release(targetPrivate->hostnameEndpoint); + targetPrivate->hostnameEndpoint = NULL; + } + if (targetPrivate->localAddressEndpoint) { + network_release(targetPrivate->localAddressEndpoint); + targetPrivate->localAddressEndpoint = NULL; + } + if (targetPrivate->remoteAddressEndpoint) { + network_release(targetPrivate->remoteAddressEndpoint); + targetPrivate->remoteAddressEndpoint = NULL; + } + if (targetPrivate->parameters) { + network_release(targetPrivate->parameters); + targetPrivate->parameters = NULL; + } + if (targetPrivate->lastPath) { + network_release(targetPrivate->lastPath); + targetPrivate->lastPath = NULL; + } + if (targetPrivate->lastPathParameters) { + network_release(targetPrivate->lastPathParameters); + targetPrivate->lastPathParameters = NULL; + } + if (targetPrivate->lastResolvedEndpoints) { + network_release(targetPrivate->lastResolvedEndpoints); + targetPrivate->lastResolvedEndpoints = NULL; } - if (store_info->store != NULL) { - CFRelease(store_info->store); - store_info->store = NULL; + if (targetPrivate->rlsContext.release != NULL) { + (*targetPrivate->rlsContext.release)(targetPrivate->rlsContext.info); } + MUTEX_UNLOCK(&targetPrivate->lock); + + pthread_mutex_destroy(&targetPrivate->lock); + return; } static void -ReachabilityStoreInfo_init(ReachabilityStoreInfoRef store_info) +__SCNetworkReachabilityInitialize(void) { - dispatch_sync(_storeInfo_queue(), ^{ - bzero(store_info, sizeof(ReachabilityStoreInfo)); + __kSCNetworkReachabilityTypeID = _CFRuntimeRegisterClass(&__SCNetworkReachabilityClass); - if (S_storeInfoActive && (S_storeInfo.dict != NULL)) { - ReachabilityStoreInfo_copy(&S_storeInfo, store_info); - } - }); + // provide a way to enable SCNetworkReachability logging without + // having to set _sc_debug=1. + if ((getenv("REACH_LOGGING") != NULL) || + (CFPreferencesGetAppBooleanValue(CFSTR("com.apple.SCNetworkReachability.debug"), + kCFPreferencesCurrentApplication, + NULL))) { + _sc_debug = TRUE; + } + + pthread_mutexattr_init(&lock_attr); + pthread_mutexattr_settype(&lock_attr, PTHREAD_MUTEX_ERRORCHECK); return; } - -static void -ReachabilityStoreInfo_save(ReachabilityStoreInfoRef store_info) +static SCNetworkReachabilityPrivateRef +__SCNetworkReachabilityCreatePrivate(CFAllocatorRef allocator) { - dispatch_sync(_storeInfo_queue(), ^{ - if ((store_info == NULL) || - !_SC_CFEqual(store_info->dict, S_storeInfo.dict)) { - // free any old info - ReachabilityStoreInfo_free(&S_storeInfo); - - // save new info - if (S_storeInfoActive && - (store_info != NULL) && - (store_info->dict != NULL)) { - ReachabilityStoreInfo_copy(store_info, &S_storeInfo); - } - } - }); + SCNetworkReachabilityPrivateRef targetPrivate; + uint32_t size; - return; -} + /* initialize runtime */ + pthread_once(&initialized, __SCNetworkReachabilityInitialize); + /* allocate target */ + size = sizeof(SCNetworkReachabilityPrivate) - sizeof(CFRuntimeBase); + targetPrivate = (SCNetworkReachabilityPrivateRef)_CFRuntimeCreateInstance(allocator, + __kSCNetworkReachabilityTypeID, + size, + NULL); + if (targetPrivate == NULL) { + return NULL; + } -static void -ReachabilityStoreInfo_keys(CFMutableArrayRef *fill_keys, CFMutableArrayRef *fill_patterns) -{ - CFStringRef key; - CFMutableArrayRef keys; - CFStringRef pattern; - CFMutableArrayRef patterns; - - keys = CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks); - patterns = CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks); - - // get info for IPv4 services - key = SCDynamicStoreKeyCreateNetworkGlobalEntity(NULL, - kSCDynamicStoreDomainState, - kSCEntNetIPv4); - CFArrayAppendValue(keys, key); - CFRelease(key); - pattern = SCDynamicStoreKeyCreateNetworkServiceEntity(NULL, - kSCDynamicStoreDomainSetup, - kSCCompAnyRegex, - kSCEntNetIPv4); - CFArrayAppendValue(patterns, pattern); - CFRelease(pattern); - pattern = SCDynamicStoreKeyCreateNetworkServiceEntity(NULL, - kSCDynamicStoreDomainState, - kSCCompAnyRegex, - kSCEntNetIPv4); - CFArrayAppendValue(patterns, pattern); - CFRelease(pattern); - - // get info for IPv6 services - key = SCDynamicStoreKeyCreateNetworkGlobalEntity(NULL, - kSCDynamicStoreDomainState, - kSCEntNetIPv6); - CFArrayAppendValue(keys, key); - CFRelease(key); - pattern = SCDynamicStoreKeyCreateNetworkServiceEntity(NULL, - kSCDynamicStoreDomainSetup, - kSCCompAnyRegex, - kSCEntNetIPv6); - CFArrayAppendValue(patterns, pattern); - CFRelease(pattern); - pattern = SCDynamicStoreKeyCreateNetworkServiceEntity(NULL, - kSCDynamicStoreDomainState, - kSCCompAnyRegex, - kSCEntNetIPv6); - CFArrayAppendValue(patterns, pattern); - CFRelease(pattern); - - // get info for PPP services - pattern = SCDynamicStoreKeyCreateNetworkServiceEntity(NULL, - kSCDynamicStoreDomainSetup, - kSCCompAnyRegex, - kSCEntNetPPP); - CFArrayAppendValue(patterns, pattern); - CFRelease(pattern); - pattern = SCDynamicStoreKeyCreateNetworkServiceEntity(NULL, - kSCDynamicStoreDomainState, - kSCCompAnyRegex, - kSCEntNetPPP); - CFArrayAppendValue(patterns, pattern); - CFRelease(pattern); - - // get info for VPN services - pattern = SCDynamicStoreKeyCreateNetworkServiceEntity(NULL, - kSCDynamicStoreDomainSetup, - kSCCompAnyRegex, - kSCEntNetVPN); - CFArrayAppendValue(patterns, pattern); - CFRelease(pattern); - pattern = SCDynamicStoreKeyCreateNetworkServiceEntity(NULL, - kSCDynamicStoreDomainState, - kSCCompAnyRegex, - kSCEntNetVPN); - CFArrayAppendValue(patterns, pattern); - CFRelease(pattern); - - // get info for IPSec services -// pattern = SCDynamicStoreKeyCreateNetworkServiceEntity(NULL, -// kSCDynamicStoreDomainSetup, -// kSCCompAnyRegex, -// kSCEntNetIPSec); -// CFArrayAppendValue(patterns, pattern); -// CFRelease(pattern); - pattern = SCDynamicStoreKeyCreateNetworkServiceEntity(NULL, - kSCDynamicStoreDomainState, - kSCCompAnyRegex, - kSCEntNetIPSec); - CFArrayAppendValue(patterns, pattern); - CFRelease(pattern); - - // get info to identify "available" services - pattern = SCDynamicStoreKeyCreateNetworkServiceEntity(NULL, - kSCDynamicStoreDomainSetup, - kSCCompAnyRegex, - kSCEntNetInterface); - CFArrayAppendValue(patterns, pattern); - CFRelease(pattern); - - - *fill_keys = keys; - *fill_patterns = patterns; - return; -} + bzero((void *)targetPrivate + sizeof(CFRuntimeBase), size); + MUTEX_INIT(&targetPrivate->lock); -static Boolean -ReachabilityStoreInfo_fill(ReachabilityStoreInfoRef store_info) -{ - CFMutableArrayRef keys; - CFMutableArrayRef patterns; - - // get the SCDynamicStore info - ReachabilityStoreInfo_keys(&keys, &patterns); - store_info->dict = SCDynamicStoreCopyMultiple(store_info->store, keys, patterns); - CFRelease(keys); - CFRelease(patterns); - if (store_info->dict == NULL) { - return FALSE; - } + targetPrivate->pathEvaluator = NULL; + targetPrivate->resolver = NULL; - // and extract the keys/values for post-processing - store_info->n = CFDictionaryGetCount(store_info->dict); - if (store_info->n > 0) { - if (store_info->n <= (CFIndex)(sizeof(store_info->keys_q) / sizeof(CFTypeRef))) { - store_info->keys = store_info->keys_q; - store_info->values = store_info->values_q; - } else { - store_info->keys = CFAllocatorAllocate(NULL, store_info->n * sizeof(CFTypeRef), 0); - store_info->values = CFAllocatorAllocate(NULL, store_info->n * sizeof(CFTypeRef), 0); - } - CFDictionaryGetKeysAndValues(store_info->dict, - store_info->keys, - store_info->values); + targetPrivate->log_prefix[0] = '\0'; + if (_sc_log > 0) { + snprintf(targetPrivate->log_prefix, + sizeof(targetPrivate->log_prefix), + "[%p] ", + targetPrivate); } - return TRUE; + return targetPrivate; } -static Boolean -ReachabilityStoreInfo_update(ReachabilityStoreInfoRef store_info, - SCDynamicStoreRef *storeP, - sa_family_t sa_family) -{ - __block Boolean ok = TRUE; - - switch (sa_family) { - case AF_UNSPEC : - store_info->entity = NULL; - break; - case AF_INET : - store_info->entity = kSCEntNetIPv4; - break; - case AF_INET6 : - store_info->entity = kSCEntNetIPv6; - break; - default : - return FALSE; - } - - if (store_info->dict != NULL) { - // if info already available - return TRUE; - } - - dispatch_sync(_storeInfo_queue(), ^{ - if (S_storeInfoActive && (S_storeInfo.dict != NULL)) { - // free any info - ReachabilityStoreInfo_free(store_info); - - // copy the shared/available info - ReachabilityStoreInfo_copy(&S_storeInfo, store_info); - } +static const struct sockaddr * +is_valid_address(const struct sockaddr *address) +{ + const struct sockaddr *valid = NULL; + static Boolean warned = FALSE; - if (store_info->store == NULL) { - store_info->store = (storeP != NULL) ? *storeP : NULL; - if (store_info->store != NULL) { - // keep a reference to the passed in SCDynamicStore - CFRetain(store_info->store); - } else { - store_info->store = SCDynamicStoreCreate(NULL, CFSTR("SCNetworkReachability"), NULL, NULL); - if (store_info->store == NULL) { - SCLog(TRUE, LOG_ERR, CFSTR("ReachabilityStoreInfo_update SCDynamicStoreCreate() failed")); - return; + if ((address != NULL) && + (address->sa_len <= sizeof(struct sockaddr_storage))) { + switch (address->sa_family) { + case AF_INET : + if (address->sa_len >= sizeof(struct sockaddr_in)) { + valid = address; + } else { + if (!warned) { + SC_log(LOG_NOTICE, "SCNetworkReachabilityCreateWithAddress[Pair] called with \"struct sockaddr *\" len %d < %zu", + address->sa_len, + sizeof(struct sockaddr_in)); + warned = TRUE; + } } - - if (storeP != NULL) { - // and pass back a reference - *storeP = store_info->store; - CFRetain(*storeP); + break; + case AF_INET6 : + if (address->sa_len >= sizeof(struct sockaddr_in6)) { + valid = address; + } else if (!warned) { + SC_log(LOG_NOTICE, "SCNetworkReachabilityCreateWithAddress[Pair] called with \"struct sockaddr *\" len %d < %zu", + address->sa_len, + sizeof(struct sockaddr_in6)); + warned = TRUE; + } + break; + default : + if (!warned) { + SC_log(LOG_NOTICE, "SCNetworkReachabilityCreateWithAddress[Pair] called with invalid address family %d", + address->sa_family); + warned = TRUE; } - } - } - - if (sa_family == AF_UNSPEC) { - // if the address family was not specified than - // all we wanted, for now, was to establish the - // SCDynamicStore session - return; - } - - if (store_info->dict != NULL) { - // or we have picked up the shared info - return; - } - - ok = ReachabilityStoreInfo_fill(store_info); - if (!ok) { - return; - } - - if (!_SC_CFEqual(store_info->dict, S_storeInfo.dict)) { - // free any old info - ReachabilityStoreInfo_free(&S_storeInfo); - - // save new info - if (S_storeInfoActive && - (store_info->dict != NULL)) { - ReachabilityStoreInfo_copy(store_info, &S_storeInfo); - } } - }); + } - return ok; + return valid; } +static bool +__SCNetworkReachabilityAddressIsEmpty(const struct sockaddr *address) +{ + if (address == NULL) { + return TRUE; + } -#pragma mark - -#pragma mark Reachability engine - + if (address->sa_family == AF_INET) { + return (((struct sockaddr_in *)(void *)address)->sin_addr.s_addr == 0); + } else if (address->sa_family == AF_INET6) { + return IN6_IS_ADDR_UNSPECIFIED(&((struct sockaddr_in6 *)(void *)address)->sin6_addr); + } else { + return FALSE; + } +} -#define ROUNDUP(a, size) \ - (((a) & ((size)-1)) ? (1 + ((a) | ((size)-1))) : (a)) +SCNetworkReachabilityRef +SCNetworkReachabilityCreateWithAddress(CFAllocatorRef allocator, + const struct sockaddr *address) +{ + SCNetworkReachabilityPrivateRef targetPrivate; -#define NEXT_SA(ap) (ap) = (struct sockaddr *) \ - ((caddr_t)(ap) + ((ap)->sa_len ? ROUNDUP((ap)->sa_len,\ - sizeof(uint32_t)) :\ - sizeof(uint32_t))) + address = is_valid_address(address); + if (address == NULL) { + _SCErrorSet(kSCStatusInvalidArgument); + return NULL; + } -static void -get_rtaddrs(int addrs, struct sockaddr *sa, struct sockaddr **rti_info) -{ - int i; - - for (i = 0; i < RTAX_MAX; i++) { - if (addrs & (1 << i)) { - rti_info[i] = sa; - NEXT_SA(sa); - } else - rti_info[i] = NULL; + targetPrivate = __SCNetworkReachabilityCreatePrivate(allocator); + if (targetPrivate == NULL) { + return NULL; } -} + targetPrivate->type = reachabilityTypeAddress; -#define BUFLEN (sizeof(struct rt_msghdr) + 512) /* 8 * sizeof(struct sockaddr_in6) = 192 */ + if (!__SCNetworkReachabilityAddressIsEmpty(address)) { + targetPrivate->remoteAddressEndpoint = nw_endpoint_create_address(address); + } + if (_sc_debug && (_sc_log > 0)) { + SC_log(LOG_INFO, "%s%s %@", + targetPrivate->log_prefix, + DEBUG_REACHABILITY_TYPE_ADDRESS, + targetPrivate); + } -typedef struct { - union { - char bytes[BUFLEN]; - struct rt_msghdr rtm; - } buf; - int error; - struct sockaddr *rti_info[RTAX_MAX]; - struct rt_msghdr *rtm; - struct sockaddr_dl *sdl; -} route_info, *route_info_p; + return (SCNetworkReachabilityRef)targetPrivate; +} -/* - * route_get() - * returns zero if route exists and data returned, EHOSTUNREACH - * if no route, or errno for any other error. - */ -static int -route_get(const struct sockaddr *address, - unsigned int if_index, - route_info *info) +static Boolean +is_same_address(const struct sockaddr *a, const struct sockaddr *b) { - int n; - int opt; - pid_t pid = getpid(); - int rsock; - struct sockaddr *sa; - int32_t seq = OSAtomicIncrement32Barrier(&rtm_seq); -#ifndef RTM_GET_SILENT -#warning Note: Using RTM_GET (and not RTM_GET_SILENT) - static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER; - int sosize = 48 * 1024; -#endif + const void *a_addr; + const void *b_addr; + size_t len; - bzero(info, sizeof(*info)); + if ((a == NULL) || + (b == NULL) || + (a->sa_family != b->sa_family) || + (a->sa_len != b->sa_len )) { + return FALSE; + } - info->rtm = &info->buf.rtm; - info->rtm->rtm_msglen = sizeof(struct rt_msghdr); - info->rtm->rtm_version = RTM_VERSION; -#ifdef RTM_GET_SILENT - info->rtm->rtm_type = RTM_GET_SILENT; -#else - info->rtm->rtm_type = RTM_GET; -#endif - info->rtm->rtm_flags = RTF_STATIC|RTF_UP|RTF_HOST|RTF_GATEWAY; - info->rtm->rtm_addrs = RTA_DST|RTA_IFP; /* Both destination and device */ - info->rtm->rtm_pid = pid; - info->rtm->rtm_seq = seq; + switch (a->sa_family) { + case AF_INET : { + struct sockaddr_in *a_sin = (struct sockaddr_in *)(void *)a; + struct sockaddr_in *b_sin = (struct sockaddr_in *)(void *)b; - if (if_index != 0) { - info->rtm->rtm_flags |= RTF_IFSCOPE; - info->rtm->rtm_index = if_index; - } + /* ALIGN: assuming a (and b) are aligned, then cast ok. */ + a_addr = &a_sin->sin_addr; + b_addr = &b_sin->sin_addr; + len = sizeof(struct in_addr); + break; + } + + case AF_INET6 : { + struct sockaddr_in6 *a_sin6 = (struct sockaddr_in6 *)(void *)a; + struct sockaddr_in6 *b_sin6 = (struct sockaddr_in6 *)(void *)b; - switch (address->sa_family) { - case AF_INET6: { - struct sockaddr_in6 *sin6; - - /* ALIGN: caller ensures that the address is aligned */ - sin6 = (struct sockaddr_in6 *)(void *)address; - if ((IN6_IS_ADDR_LINKLOCAL(&sin6->sin6_addr) || - IN6_IS_ADDR_MC_LINKLOCAL(&sin6->sin6_addr)) && - (sin6->sin6_scope_id != 0)) { - sin6->sin6_addr.s6_addr16[1] = htons(sin6->sin6_scope_id); - sin6->sin6_scope_id = 0; + if (a_sin6->sin6_scope_id != b_sin6->sin6_scope_id) { + return FALSE; } + + a_addr = &a_sin6->sin6_addr; + b_addr = &b_sin6->sin6_addr; + len = sizeof(struct in6_addr); break; } + + default : + a_addr = a; + b_addr = b; + len = a->sa_len; + break; } - sa = (struct sockaddr *) (info->rtm + 1); - bcopy(address, sa, address->sa_len); - n = ROUNDUP(sa->sa_len, sizeof(uint32_t)); - info->rtm->rtm_msglen += n; + return (bcmp(a_addr, b_addr, len) == 0); +} - info->sdl = (struct sockaddr_dl *) ((void *)sa + n); - info->sdl->sdl_family = AF_LINK; - info->sdl->sdl_len = sizeof (struct sockaddr_dl); - n = ROUNDUP(info->sdl->sdl_len, sizeof(uint32_t)); - info->rtm->rtm_msglen += n; -#ifndef RTM_GET_SILENT - pthread_mutex_lock(&lock); -#endif - rsock = socket(PF_ROUTE, SOCK_RAW, PF_ROUTE); - if (rsock == -1) { - int error = errno; +SCNetworkReachabilityRef +SCNetworkReachabilityCreateWithAddressPair(CFAllocatorRef allocator, + const struct sockaddr *localAddress, + const struct sockaddr *remoteAddress) +{ + SCNetworkReachabilityPrivateRef targetPrivate; -#ifndef RTM_GET_SILENT - pthread_mutex_unlock(&lock); -#endif - SCLog(TRUE, LOG_ERR, CFSTR("socket(PF_ROUTE) failed: %s"), strerror(error)); - return error; + if ((localAddress == NULL) && (remoteAddress == NULL)) { + _SCErrorSet(kSCStatusInvalidArgument); + return NULL; } - opt = 1; - if (ioctl(rsock, FIONBIO, &opt) < 0) { - int error = errno; - (void)close(rsock); -#ifndef RTM_GET_SILENT - pthread_mutex_unlock(&lock); -#endif - SCLog(TRUE, LOG_ERR, CFSTR("ioctl(FIONBIO) failed: %s"), strerror(error)); - return error; + if (localAddress != NULL) { + localAddress = is_valid_address(localAddress); + if (localAddress == NULL) { + _SCErrorSet(kSCStatusInvalidArgument); + return NULL; + } } -#ifndef RTM_GET_SILENT - if (setsockopt(rsock, SOL_SOCKET, SO_RCVBUF, &sosize, sizeof(sosize)) == -1) { - int error = errno; - - (void)close(rsock); - pthread_mutex_unlock(&lock); - SCLog(TRUE, LOG_ERR, CFSTR("setsockopt(SO_RCVBUF) failed: %s"), strerror(error)); - return error; + if (remoteAddress != NULL) { + remoteAddress = is_valid_address(remoteAddress); + if (remoteAddress == NULL) { + _SCErrorSet(kSCStatusInvalidArgument); + return NULL; + } } -#endif - if (write(rsock, &info->buf, info->rtm->rtm_msglen) == -1) { - int error = errno; - - (void)close(rsock); -#ifndef RTM_GET_SILENT - pthread_mutex_unlock(&lock); -#endif - if (error != ESRCH) { - SCLog(TRUE, LOG_ERR, CFSTR("write() failed: %s"), strerror(error)); - return error; - } - return EHOSTUNREACH; + targetPrivate = __SCNetworkReachabilityCreatePrivate(allocator); + if (targetPrivate == NULL) { + return NULL; } - /* - * Type, seq, pid identify our response. - * Routing sockets are broadcasters on input. - */ - while (TRUE) { - ssize_t n; + targetPrivate->type = reachabilityTypeAddressPair; - n = read(rsock, &info->buf, sizeof(info->buf)); - if (n == -1) { - int error = errno; + if (localAddress != NULL) { + targetPrivate->localAddressEndpoint = nw_endpoint_create_address(localAddress); + } - if (error == EINTR) { - continue; - } - (void)close(rsock); -#ifndef RTM_GET_SILENT - pthread_mutex_unlock(&lock); -#endif - SCLog(TRUE, LOG_ERR, - CFSTR("SCNetworkReachability: routing socket" - " read() failed: %s"), strerror(error)); - return error; - } - if ((info->rtm->rtm_type == RTM_GET) && - (info->rtm->rtm_seq == seq) && - (info->rtm->rtm_pid == pid)) { - break; + if (remoteAddress != NULL) { + if (is_same_address(localAddress, remoteAddress)) { + targetPrivate->remoteAddressEndpoint = network_retain(targetPrivate->localAddressEndpoint); + } else { + targetPrivate->remoteAddressEndpoint = nw_endpoint_create_address(remoteAddress); } } - (void)close(rsock); -#ifndef RTM_GET_SILENT - pthread_mutex_unlock(&lock); -#endif - - get_rtaddrs(info->rtm->rtm_addrs, sa, info->rti_info); + targetPrivate->parameters = nw_parameters_create(); + nw_parameters_set_local_address(targetPrivate->parameters, targetPrivate->localAddressEndpoint); -//#define LOG_RTADDRS -#ifdef LOG_RTADDRS - { - int i; + if (_sc_debug && (_sc_log > 0)) { + SC_log(LOG_INFO, "%s%s %@", + targetPrivate->log_prefix, + DEBUG_REACHABILITY_TYPE_ADDRESSPAIR, + targetPrivate); + } - SCLog(_sc_debug, LOG_DEBUG, CFSTR("rtm_flags = 0x%8.8x"), info->rtm->rtm_flags); + return (SCNetworkReachabilityRef)targetPrivate; +} - if ((info->rti_info[RTAX_NETMASK] != NULL) && (info->rti_info[RTAX_DST] != NULL)) { - info->rti_info[RTAX_NETMASK]->sa_family = info->rti_info[RTAX_DST]->sa_family; - } - for (i = 0; i < RTAX_MAX; i++) { - if (info->rti_info[i] != NULL) { - char addr[128]; +SCNetworkReachabilityRef +SCNetworkReachabilityCreateWithName(CFAllocatorRef allocator, + const char *nodename) +{ + union { + struct sockaddr sa; + struct sockaddr_in sin; + struct sockaddr_in6 sin6; + } addr; + size_t nodenameLen; + SCNetworkReachabilityPrivateRef targetPrivate; - _SC_sockaddr_to_string(info->rti_info[i], addr, sizeof(addr)); - SCLog(_sc_debug, LOG_DEBUG, CFSTR("%d: %s"), i, addr); - } - } + if (nodename == NULL) { + _SCErrorSet(kSCStatusInvalidArgument); + return NULL; } -#endif // LOG_RTADDRS - if ((info->rti_info[RTAX_IFP] == NULL) || - (info->rti_info[RTAX_IFP]->sa_family != AF_LINK)) { - /* no interface info */ - SCLog(TRUE, LOG_DEBUG, CFSTR("route_get() no interface info")); - return EINVAL; + nodenameLen = strlen(nodename); + if (nodenameLen == 0) { + _SCErrorSet(kSCStatusInvalidArgument); + return NULL; } - /* ALIGN: accessors are retrieving byte values, cast ok. */ - info->sdl = (struct sockaddr_dl *)(void *) info->rti_info[RTAX_IFP]; - if ((info->sdl->sdl_nlen == 0) || (info->sdl->sdl_nlen > IFNAMSIZ)) { - /* no interface name */ - return EHOSTUNREACH; + if (_SC_string_to_sockaddr(nodename, AF_UNSPEC, (void *)&addr, sizeof(addr)) != NULL) { + /* if this "nodename" is really an IP[v6] address in disguise */ + return SCNetworkReachabilityCreateWithAddress(allocator, &addr.sa); } - return 0; -} - + targetPrivate = __SCNetworkReachabilityCreatePrivate(allocator); + if (targetPrivate == NULL) { + return NULL; + } -static void -log_address(const char *str, - const struct sockaddr *sa, - unsigned int if_index, - const char *log_prefix) -{ - char addr[128]; - char if_name[IFNAMSIZ + 1]; + targetPrivate->type = reachabilityTypeName; - _SC_sockaddr_to_string(sa, addr, sizeof(addr)); + targetPrivate->hostnameEndpoint = nw_endpoint_create_host(nodename, "0"); - if ((if_index != 0) && - (if_indextoname(if_index, &if_name[1]) != NULL)) { - if_name[0] = '%'; - } else { - if_name[0] = '\0'; + if (_sc_debug && (_sc_log > 0)) { + SC_log(LOG_INFO, "%s%s %@", + targetPrivate->log_prefix, + DEBUG_REACHABILITY_TYPE_NAME, + targetPrivate); } - SCLog(TRUE, LOG_INFO, CFSTR("%s%s(%s%s)"), - log_prefix, - str, - addr, - if_name); - - return; + return (SCNetworkReachabilityRef)targetPrivate; } -static int -checkAddress_route(const struct sockaddr *address, - unsigned int if_index, - char *if_name, - struct ifreq *ifr, - ReachabilityInfo *reach_info, - route_info *info, - int *sc_status, - const char *log_prefix) +static SCNetworkReachabilityRef +__SCNetworkReachabilityCreateWithPTR(CFAllocatorRef allocator, + const struct sockaddr *ptrAddress) { - int isock = -1; - int ret = 0; - char *statusMessage = NULL; - struct sockaddr_in v4mapped; - - switch (address->sa_family) { - case AF_INET : - case AF_INET6 : - if (_sc_debug) { - log_address("checkAddress", address, if_index, log_prefix); - } - break; - default : - /* - * if no code for this address family (yet) - */ - SCLog(TRUE, LOG_INFO, - CFSTR("checkAddress(): unexpected address family %d"), - address->sa_family); - *sc_status = kSCStatusInvalidArgument; - ret = EPERM; - goto done; - } + SCNetworkReachabilityPrivateRef targetPrivate; - if (address->sa_family == AF_INET6) { - /* ALIGN: sin6_addr accessed aligned, cast ok. */ - struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)(void *)address; - - if (IN6_IS_ADDR_V4MAPPED(&sin6->sin6_addr)) { - bzero(&v4mapped, sizeof(v4mapped)); - v4mapped.sin_len = sizeof(v4mapped); - v4mapped.sin_family = AF_INET; - v4mapped.sin_port = sin6->sin6_port; - v4mapped.sin_addr.s_addr = sin6->sin6_addr.__u6_addr.__u6_addr32[3]; - address = (struct sockaddr *)&v4mapped; - } + ptrAddress = is_valid_address(ptrAddress); + if (ptrAddress == NULL) { + _SCErrorSet(kSCStatusInvalidArgument); + return NULL; } - ret = route_get(address, if_index, info); - switch (ret) { - case 0 : - break; - case EHOSTUNREACH : - // if no route - goto done; - default : - // if error - *sc_status = ret; - goto done; + targetPrivate = __SCNetworkReachabilityCreatePrivate(allocator); + if (targetPrivate == NULL) { + return NULL; } - /* get the interface flags */ - - isock = socket(AF_INET, SOCK_DGRAM, 0); - if (isock == -1) { - ret = errno; - SCLog(TRUE, LOG_ERR, CFSTR("socket() failed: %s"), strerror(errno)); - goto done; - } + targetPrivate->type = reachabilityTypePTR; - bzero(ifr, sizeof(*ifr)); - bcopy(info->sdl->sdl_data, ifr->ifr_name, info->sdl->sdl_nlen); + targetPrivate->remoteAddressEndpoint = nw_endpoint_create_address(ptrAddress); - if (ioctl(isock, SIOCGIFFLAGS, (char *)ifr) == -1) { - ret = errno; - SCLog(TRUE, LOG_ERR, CFSTR("ioctl(SIOCGIFFLAGS) failed: %s"), strerror(errno)); - goto done; - } + targetPrivate->parameters = nw_parameters_create(); + nw_parameters_set_resolve_ptr(targetPrivate->parameters, TRUE); - if (!(ifr->ifr_flags & IFF_UP)) { - ret = EHOSTUNREACH; - goto done; + if (_sc_debug && (_sc_log > 0)) { + SC_log(LOG_INFO, "%s%s %@", + targetPrivate->log_prefix, + DEBUG_REACHABILITY_TYPE_PTR, + targetPrivate); } - statusMessage = "isReachable"; - reach_info->flags |= kSCNetworkReachabilityFlagsReachable; - - if (info->rtm->rtm_flags & RTF_LOCAL) { - statusMessage = "isReachable (is a local address)"; - reach_info->flags |= kSCNetworkReachabilityFlagsIsLocalAddress; - } else if (ifr->ifr_flags & IFF_LOOPBACK) { - statusMessage = "isReachable (is loopback network)"; - reach_info->flags |= kSCNetworkReachabilityFlagsIsLocalAddress; - } else if ((info->rti_info[RTAX_IFA] != NULL) && - (info->rti_info[RTAX_IFA]->sa_family != AF_LINK)) { - void *addr1 = (void *)address; - void *addr2 = (void *)info->rti_info[RTAX_IFA]; - size_t len = address->sa_len; - - if ((address->sa_family != info->rti_info[RTAX_IFA]->sa_family) && - (address->sa_len != info->rti_info[RTAX_IFA]->sa_len)) { - SCLog(TRUE, LOG_NOTICE, - CFSTR("address family/length mismatch: %d/%d != %d/%d"), - address->sa_family, - address->sa_len, - info->rti_info[RTAX_IFA]->sa_family, - info->rti_info[RTAX_IFA]->sa_len); - goto done; - } + return (SCNetworkReachabilityRef)targetPrivate; +} - switch (address->sa_family) { - case AF_INET : - /* ALIGN: cast ok, because only bcmp is used. */ - addr1 = &((struct sockaddr_in *)(void *)address)->sin_addr; - addr2 = &((struct sockaddr_in *)(void *)info->rti_info[RTAX_IFA])->sin_addr; - len = sizeof(struct in_addr); - - /* - * check if 0.0.0.0 - */ - /* ALIGN: sin_addr should be aligned, cast ok. */ - if (((struct sockaddr_in *)(void *)address)->sin_addr.s_addr == 0) { - statusMessage = "isReachable (this host)"; - reach_info->flags |= kSCNetworkReachabilityFlagsIsLocalAddress; - } - break; - case AF_INET6 : - /* ALIGN: cast ok, because only bcmp is used. */ - addr1 = &((struct sockaddr_in6 *)(void *)address)->sin6_addr; - addr2 = &((struct sockaddr_in6 *)(void *)info->rti_info[RTAX_IFA])->sin6_addr; - len = sizeof(struct in6_addr); - break; - default : - break; - } - - if (bcmp(addr1, addr2, len) == 0) { - statusMessage = "isReachable (is interface address)"; - reach_info->flags |= kSCNetworkReachabilityFlagsIsLocalAddress; - } - } - - if (!(info->rtm->rtm_flags & RTF_GATEWAY) && - (info->rti_info[RTAX_GATEWAY] != NULL) && - (info->rti_info[RTAX_GATEWAY]->sa_family == AF_LINK) && - !(ifr->ifr_flags & IFF_POINTOPOINT)) { - reach_info->flags |= kSCNetworkReachabilityFlagsIsDirect; - } - - bzero(if_name, IFNAMSIZ); - bcopy(info->sdl->sdl_data, - if_name, - (info->sdl->sdl_nlen <= IFNAMSIZ) ? info->sdl->sdl_nlen : IFNAMSIZ); - - strlcpy(reach_info->if_name, if_name, sizeof(reach_info->if_name)); - reach_info->if_index = info->sdl->sdl_index; - - if (_sc_debug) { - SCLog(TRUE, LOG_INFO, CFSTR("%s status = %s"), log_prefix, statusMessage); - SCLog(TRUE, LOG_INFO, CFSTR("%s device = %s (%hu)"), log_prefix, if_name, info->sdl->sdl_index); - SCLog(TRUE, LOG_INFO, CFSTR("%s sdl_type = 0x%x"), log_prefix, info->sdl->sdl_type); - SCLog(TRUE, LOG_INFO, CFSTR("%s ifr_flags = 0x%04hx"), log_prefix, ifr->ifr_flags); - SCLog(TRUE, LOG_INFO, CFSTR("%s rtm_flags = 0x%08x"), log_prefix, info->rtm->rtm_flags); - } - - done : - if (isock != -1) (void)close(isock); - return ret; -} - - -static Boolean -checkAddress(ReachabilityStoreInfoRef store_info, - const struct sockaddr *address, - unsigned int if_index, - ReachabilityInfo *reach_info, - const char *log_prefix) -{ - route_info info; - struct ifreq ifr; - char if_name[IFNAMSIZ]; - nwi_ifstate_t ifstate; - nwi_state_t nwi_state; - int ret; - int sc_status = kSCStatusReachabilityUnknown; - - _reach_set(reach_info, &NOT_REACHABLE, reach_info->cycle, if_index, NULL); - - nwi_state = nwi_state_copy(); - - if (address != NULL) { - ret = checkAddress_route(address, - if_index, - if_name, - &ifr, - reach_info, - &info, - &sc_status, - log_prefix); - } else { - /* special case: check only for available paths off the system */ - ret = EHOSTUNREACH; - } - - if (ret == 0) { - const struct sockaddr *vpn_server_address; - - sc_status = kSCStatusOK; - - ifstate = nwi_state_get_ifstate(nwi_state, if_name); - if (ifstate == NULL) { - goto done; - } - - reach_info->flags |= nwi_ifstate_get_reachability_flags(ifstate); - - - vpn_server_address = nwi_ifstate_get_vpn_server(ifstate); - if (vpn_server_address != NULL) { - char dst_if_name[IFNAMSIZ]; - route_info dst_info; - - ret = route_get(vpn_server_address, 0, &dst_info); - if (ret != 0) { - goto done; - } - - bzero(&dst_if_name, sizeof(dst_if_name)); - bcopy(dst_info.sdl->sdl_data, - dst_if_name, - (dst_info.sdl->sdl_nlen <= IFNAMSIZ) ? dst_info.sdl->sdl_nlen : IFNAMSIZ); - if (bcmp(if_name, dst_if_name, sizeof(if_name)) != 0) { - nwi_ifstate_t ifstate; - - ifstate = nwi_state_get_ifstate(nwi_state, dst_if_name); - if (ifstate != NULL) { - reach_info->flags |= nwi_ifstate_get_reachability_flags(ifstate); - } - } - } - } else if (ret == EHOSTUNREACH) { - if (if_index == 0) { - int af; - - // if not "scoped" request - af = (address != NULL) ? address->sa_family : AF_UNSPEC; - reach_info->flags |= nwi_state_get_reachability_flags(nwi_state, af); - sc_status = kSCStatusOK; - } else { - // if "scoped" request - sc_status = kSCStatusNoKey; - } - } - - done: - - if (reach_info->flags == 0) { - SCLog(_sc_debug, LOG_INFO, CFSTR("%s cannot be reached"), log_prefix); - } - - if (nwi_state != NULL) { - nwi_state_release(nwi_state); - } - - if ((sc_status != kSCStatusOK) && (sc_status != kSCStatusNoKey)) { - _SCErrorSet(sc_status); - return FALSE; - } - - return TRUE; -} - - -#pragma mark - -#pragma mark SCNetworkReachability APIs - - -static __inline__ CFTypeRef -isA_SCNetworkReachability(CFTypeRef obj) -{ - return (isA_CFType(obj, SCNetworkReachabilityGetTypeID())); -} - - -static Boolean -addr_to_PTR_name(const struct sockaddr *sa, char *name, size_t name_len) -{ - int n; - - switch (sa->sa_family) { - case AF_INET : { - union { - in_addr_t s_addr; - unsigned char b[4]; - } rev; - /* ALIGN: assuming sa is aligned, then cast ok. */ - struct sockaddr_in *sin = (struct sockaddr_in *)(void *)sa; - - /* - * build "PTR" query name - * NNN.NNN.NNN.NNN.in-addr.arpa. - */ - rev.s_addr = sin->sin_addr.s_addr; - n = snprintf(name, name_len, "%u.%u.%u.%u.in-addr.arpa.", - rev.b[3], - rev.b[2], - rev.b[1], - rev.b[0]); - if ((n == -1) || (n >= name_len)) { - return FALSE; - } - - break; - } - - case AF_INET6 : { - int i; - int s = 0; - /* ALIGN: assume sa is aligned, cast ok. */ - struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)(void *)sa; - size_t x = name_len; - - /* - * build IPv6 "nibble" PTR query name (RFC 1886, RFC 3152) - * N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.ip6.arpa. - */ - for (i = sizeof(sin6->sin6_addr) - 1; i >= 0; i--) { - n = snprintf(&name[s], x, "%x.%x.", - ( sin6->sin6_addr.s6_addr[i] & 0xf), - ((sin6->sin6_addr.s6_addr[i] >> 4) & 0xf)); - if ((n == -1) || (n >= x)) { - return FALSE; - } - - s += n; - x -= n; - } - - n = snprintf(&name[s], x, "ip6.arpa."); - if ((n == -1) || (n >= x)) { - return FALSE; - } - - break; - } - - default : - return FALSE; - } - - return TRUE; -} - - -CFStringRef -_SCNetworkReachabilityCopyTargetDescription(SCNetworkReachabilityRef target) -{ - CFAllocatorRef allocator = CFGetAllocator(target); - CFMutableStringRef str; - SCNetworkReachabilityPrivateRef targetPrivate = (SCNetworkReachabilityPrivateRef)target; - - str = CFStringCreateMutable(allocator, 0); - switch (targetPrivate->type) { - case reachabilityTypeAddress : - case reachabilityTypeAddressPair : { - char buf[64]; - - if (targetPrivate->localAddress != NULL) { - _SC_sockaddr_to_string(targetPrivate->localAddress, buf, sizeof(buf)); - CFStringAppendFormat(str, NULL, CFSTR("local address = %s"), - buf); - } - - if (targetPrivate->remoteAddress != NULL) { - _SC_sockaddr_to_string(targetPrivate->remoteAddress, buf, sizeof(buf)); - CFStringAppendFormat(str, NULL, CFSTR("%s%saddress = %s"), - targetPrivate->localAddress ? ", " : "", - (targetPrivate->type == reachabilityTypeAddressPair) ? "remote " : "", - buf); - } - break; - } - case reachabilityTypeName : { - CFStringAppendFormat(str, NULL, CFSTR("name = %s"), targetPrivate->name); - break; - } - case reachabilityTypePTR : { - CFStringAppendFormat(str, NULL, CFSTR("ptr = %s"), targetPrivate->name); - break; - } - } - - return str; -} - - -CFStringRef -_SCNetworkReachabilityCopyTargetFlags(SCNetworkReachabilityRef target) -{ - CFAllocatorRef allocator = CFGetAllocator(target); - CFStringRef str; - SCNetworkReachabilityPrivateRef targetPrivate = (SCNetworkReachabilityPrivateRef)target; - - str = CFStringCreateWithFormat(allocator, - NULL, - CFSTR("flags = 0x%08x, if_index = %u%s"), - targetPrivate->info.flags, - targetPrivate->info.if_index, - targetPrivate->info.sleeping ? ", z" : ""); - return str; -} - - -static CFStringRef -__SCNetworkReachabilityCopyDescription(CFTypeRef cf) -{ - CFAllocatorRef allocator = CFGetAllocator(cf); - CFMutableStringRef result; - CFStringRef str; - SCNetworkReachabilityRef target = (SCNetworkReachabilityRef)cf; - SCNetworkReachabilityPrivateRef targetPrivate = (SCNetworkReachabilityPrivateRef)target; - - result = CFStringCreateMutable(allocator, 0); - CFStringAppendFormat(result, NULL, CFSTR(" {"), cf, allocator); - - // add target description - str = _SCNetworkReachabilityCopyTargetDescription(target); - CFStringAppend(result, str); - CFRelease(str); - - // add additional "name" info - if (isReachabilityTypeName(targetPrivate->type)) { - if (targetPrivate->dnsActive) { - CFStringAppendFormat(result, NULL, CFSTR(" (DNS query active)")); - } else if (targetPrivate->serverActive && - (targetPrivate->info.flags & kSCNetworkReachabilityFlagsFirstResolvePending)) { - CFStringAppendFormat(result, NULL, CFSTR(" (server query active)")); - } else if ((targetPrivate->resolvedAddresses != NULL) || (targetPrivate->resolvedError != NETDB_SUCCESS)) { - if (targetPrivate->resolvedAddresses != NULL) { - if (isA_CFArray(targetPrivate->resolvedAddresses)) { - CFIndex i; - CFIndex n = CFArrayGetCount(targetPrivate->resolvedAddresses); - - CFStringAppendFormat(result, NULL, CFSTR(" (")); - for (i = 0; i < n; i++) { - CFDataRef address; - - CFStringAppendFormat(result, NULL, CFSTR("%s"), - i > 0 ? ", " : ""); - - address = CFArrayGetValueAtIndex(targetPrivate->resolvedAddresses, i); - if (isA_CFData(address)) { - char buf[64]; - struct sockaddr *sa; - - sa = (struct sockaddr *)CFDataGetBytePtr(address); - _SC_sockaddr_to_string(sa, buf, sizeof(buf)); - CFStringAppendFormat(result, NULL, CFSTR("%s"), buf); - } else { - CFStringAppendFormat(result, NULL, CFSTR("%@"), address); - } - } - CFStringAppendFormat(result, NULL, CFSTR(")")); - } else if (CFEqual(targetPrivate->resolvedAddresses, kCFNull)) { - CFStringAppendFormat(result, NULL, CFSTR(" (%s)"), - gai_strerror(targetPrivate->resolvedError)); - } else { - CFStringAppendFormat(result, NULL, CFSTR(" (no addresses)")); - } - } else { - CFStringAppendFormat(result, NULL, CFSTR(" (%s)"), - gai_strerror(targetPrivate->resolvedError)); - } - } - if (targetPrivate->dnsFlags != 0) { - CFStringAppendFormat(result, NULL, CFSTR(", " DNS_FLAGS_FORMAT), - DNS_FLAGS_VALUES(targetPrivate)); - } - } - - if (targetPrivate->onDemandBypass) { - CFStringAppendFormat(result, NULL, CFSTR(", !ondemand")); - } - - - if (targetPrivate->resolverBypass) { - CFStringAppendFormat(result, NULL, CFSTR(", !resolve")); - } - - - // add flags - if (targetPrivate->scheduled) { - str = _SCNetworkReachabilityCopyTargetFlags(target); - CFStringAppendFormat(result, NULL, CFSTR(", %@"), str); - CFRelease(str); - } - - CFStringAppendFormat(result, NULL, CFSTR("}")); - - return result; -} - - -static void -__SCNetworkReachabilityDeallocate(CFTypeRef cf) -{ - SCNetworkReachabilityRef target = (SCNetworkReachabilityRef)cf; - SCNetworkReachabilityPrivateRef targetPrivate = (SCNetworkReachabilityPrivateRef)target; - - SCLog((_sc_debug && (_sc_log > 0)), LOG_INFO, CFSTR("%srelease"), - targetPrivate->log_prefix); - - /* disconnect from the reachability server */ - - if (targetPrivate->serverActive) { - __SCNetworkReachabilityServer_targetRemove(target); - } - - /* release resources */ - - pthread_mutex_destroy(&targetPrivate->lock); - - if (targetPrivate->name != NULL) - CFAllocatorDeallocate(NULL, (void *)targetPrivate->name); - - if (targetPrivate->resolvedAddresses != NULL) - CFRelease(targetPrivate->resolvedAddresses); - - if (targetPrivate->localAddress != NULL) { - if (targetPrivate->localAddress == targetPrivate->remoteAddress) { - targetPrivate->remoteAddress = NULL; - } - CFAllocatorDeallocate(NULL, (void *)targetPrivate->localAddress); - } - - if (targetPrivate->remoteAddress != NULL) - CFAllocatorDeallocate(NULL, (void *)targetPrivate->remoteAddress); - - if (targetPrivate->rlsContext.release != NULL) { - (*targetPrivate->rlsContext.release)(targetPrivate->rlsContext.info); - } - - if (targetPrivate->onDemandName != NULL) { - CFRelease(targetPrivate->onDemandName); - } - - if (targetPrivate->onDemandRemoteAddress != NULL) { - CFRelease(targetPrivate->onDemandRemoteAddress); - } - - if (targetPrivate->onDemandServer != NULL) { - CFRelease(targetPrivate->onDemandServer); - } - - if (targetPrivate->onDemandServiceID != NULL) { - CFRelease(targetPrivate->onDemandServiceID); - } - - if (targetPrivate->serverDigest != NULL) { - CFRelease(targetPrivate->serverDigest); - } - - if (targetPrivate->serverGroup != NULL) { - dispatch_release(targetPrivate->serverGroup); - } - - if (targetPrivate->serverQueue != NULL) { - dispatch_release(targetPrivate->serverQueue); - } - - if (targetPrivate->serverWatchers != NULL) { - CFRelease(targetPrivate->serverWatchers); - } - - if (targetPrivate->nePolicyResult) { - free(targetPrivate->nePolicyResult); - } - - return; -} - - -static void -__SCNetworkReachabilityInitialize(void) -{ - __kSCNetworkReachabilityTypeID = _CFRuntimeRegisterClass(&__SCNetworkReachabilityClass); - - // provide a way to enable SCNetworkReachability logging without - // having to set _sc_debug=1. - if ((getenv("REACH_LOGGING") != NULL) || - (CFPreferencesGetAppBooleanValue(CFSTR("com.apple.SCNetworkReachability.debug"), - kCFPreferencesCurrentApplication, - NULL))) { - _sc_debug = TRUE; - } - - // set per-process "bypass" of the SCNetworkReachability server - if (getenv("REACH_SERVER_BYPASS") != NULL) { - D_serverBypass = TRUE; - } - - - pthread_mutexattr_init(&lock_attr); - pthread_mutexattr_settype(&lock_attr, PTHREAD_MUTEX_ERRORCHECK); - - return; -} - - -__private_extern__ -dispatch_queue_t -__SCNetworkReachability_concurrent_queue() -{ - static dispatch_once_t once; - static dispatch_queue_t q; - - dispatch_once(&once, ^{ - q = dispatch_queue_create("SCNetworkReachability.concurrent", - DISPATCH_QUEUE_CONCURRENT); - }); - - return q; -} - - -/* - * __SCNetworkReachabilityUpdateConcurrent - * - * Calls reachUpdate() - * - caller must be holding a reference to the target - * - caller must *not* be holding the target lock - * - caller must be running on the __SCNetworkReachability_concurrent_queue() - */ -__private_extern__ -void -__SCNetworkReachabilityUpdateConcurrent(SCNetworkReachabilityRef target) -{ - Boolean changed; - unsigned int n; - dispatch_queue_t queue; - SCNetworkReachabilityPrivateRef targetPrivate = (SCNetworkReachabilityPrivateRef)target; - - changed = reachUpdate((void *)target); - if (!changed) { - return; - } - - n = _SC_ATOMIC_INC(&targetPrivate->pending); - if (n > 0) { - // if we already have a notification pending - return; - } - - MUTEX_LOCK(&targetPrivate->lock); - - queue = targetPrivate->dispatchQueue; - if (queue != NULL) { - dispatch_group_t group; - - dispatch_retain(queue); - - group = targetPrivate->dispatchGroup; - dispatch_group_enter(group); - - MUTEX_UNLOCK(&targetPrivate->lock); - - dispatch_sync(queue, ^{ - reachPerform((void *)target); - dispatch_group_leave(group); - }); - - dispatch_release(queue); - } else { - if (targetPrivate->rls != NULL) { - CFRunLoopSourceSignal(targetPrivate->rls); - _SC_signalRunLoop(target, targetPrivate->rls, targetPrivate->rlList); - } - - MUTEX_UNLOCK(&targetPrivate->lock); - } - - return; -} - - -/* - * __SCNetworkReachabilityUpdate - * - * Calls reachUpdate() [indirectly] - * - caller can be holding the target lock - * - caller can be running on any dispatch queue - */ -__private_extern__ -void -__SCNetworkReachabilityUpdate(SCNetworkReachabilityRef target) -{ - CFRetain(target); - dispatch_async(__SCNetworkReachability_concurrent_queue(), ^{ - __SCNetworkReachabilityUpdateConcurrent(target); - CFRelease(target); - }); - - return; -} - - -static SCNetworkReachabilityPrivateRef -__SCNetworkReachabilityCreatePrivate(CFAllocatorRef allocator) -{ - SCNetworkReachabilityPrivateRef targetPrivate; - uint32_t size; - - /* initialize runtime */ - pthread_once(&initialized, __SCNetworkReachabilityInitialize); - - /* allocate target */ - size = sizeof(SCNetworkReachabilityPrivate) - sizeof(CFRuntimeBase); - targetPrivate = (SCNetworkReachabilityPrivateRef)_CFRuntimeCreateInstance(allocator, - __kSCNetworkReachabilityTypeID, - size, - NULL); - if (targetPrivate == NULL) { - return NULL; - } - - bzero((void *)targetPrivate + sizeof(CFRuntimeBase), size); - - MUTEX_INIT(&targetPrivate->lock); - - targetPrivate->cycle = 1; - targetPrivate->last_notify = NOT_REPORTED; - targetPrivate->serverBypass = D_serverBypass; - - - - targetPrivate->log_prefix[0] = '\0'; - if (_sc_log > 0) { - snprintf(targetPrivate->log_prefix, - sizeof(targetPrivate->log_prefix), - "[%p] ", - targetPrivate); - } - - return targetPrivate; -} - - - - -static const struct sockaddr * -is_valid_address(const struct sockaddr *address) -{ - const struct sockaddr *valid = NULL; - static Boolean warned = FALSE; - - if ((address != NULL) && - (address->sa_len <= sizeof(struct sockaddr_storage))) { - switch (address->sa_family) { - case AF_INET : - if (address->sa_len >= sizeof(struct sockaddr_in)) { - valid = address; - } else { - if (!warned) { - SCLog(TRUE, LOG_ERR, - CFSTR("SCNetworkReachabilityCreateWithAddress[Pair] called with \"struct sockaddr *\" len %d < %zu"), - address->sa_len, - sizeof(struct sockaddr_in)); - warned = TRUE; - } - } - break; - case AF_INET6 : - if (address->sa_len >= sizeof(struct sockaddr_in6)) { - valid = address; - } else if (!warned) { - SCLog(TRUE, LOG_ERR, - CFSTR("SCNetworkReachabilityCreateWithAddress[Pair] called with \"struct sockaddr *\" len %d < %zu"), - address->sa_len, - sizeof(struct sockaddr_in6)); - warned = TRUE; - } - break; - default : - if (!warned) { - SCLog(TRUE, LOG_ERR, - CFSTR("SCNetworkReachabilityCreateWithAddress[Pair] called with invalid address family %d"), - address->sa_family); - warned = TRUE; - } - } - } - - return valid; -} - - - - - - -SCNetworkReachabilityRef -SCNetworkReachabilityCreateWithAddress(CFAllocatorRef allocator, - const struct sockaddr *address) -{ - SCNetworkReachabilityPrivateRef targetPrivate; - - address = is_valid_address(address); - if (address == NULL) { - _SCErrorSet(kSCStatusInvalidArgument); - return NULL; - } - - targetPrivate = __SCNetworkReachabilityCreatePrivate(allocator); - if (targetPrivate == NULL) { - return NULL; - } - - targetPrivate->type = reachabilityTypeAddress; - targetPrivate->remoteAddress = CFAllocatorAllocate(NULL, address->sa_len, 0); - bcopy(address, targetPrivate->remoteAddress, address->sa_len); - - - - SCLog((_sc_debug && (_sc_log > 0)), LOG_INFO, CFSTR("%s%s %@"), - targetPrivate->log_prefix, - DEBUG_REACHABILITY_TYPE_ADDRESS, - targetPrivate); - - return (SCNetworkReachabilityRef)targetPrivate; -} - - -static Boolean -is_same_address(const struct sockaddr *a, const struct sockaddr *b) -{ - const void *a_addr; - const void *b_addr; - size_t len; - - if ((a == NULL) || - (b == NULL) || - (a->sa_family != b->sa_family) || - (a->sa_len != b->sa_len )) { - return FALSE; - } - - switch (a->sa_family) { - case AF_INET : { - struct sockaddr_in *a_sin = (struct sockaddr_in *)(void *)a; - struct sockaddr_in *b_sin = (struct sockaddr_in *)(void *)b; - - /* ALIGN: assuming a (and b) are aligned, then cast ok. */ - a_addr = &a_sin->sin_addr; - b_addr = &b_sin->sin_addr; - len = sizeof(struct in_addr); - break; - } - - case AF_INET6 : { - struct sockaddr_in6 *a_sin6 = (struct sockaddr_in6 *)(void *)a; - struct sockaddr_in6 *b_sin6 = (struct sockaddr_in6 *)(void *)b; - - if (a_sin6->sin6_scope_id != b_sin6->sin6_scope_id) { - return FALSE; - } - - a_addr = &a_sin6->sin6_addr; - b_addr = &b_sin6->sin6_addr; - len = sizeof(struct in6_addr); - break; - } - - default : - a_addr = a; - b_addr = b; - len = a->sa_len; - break; - } - - return (bcmp(a_addr, b_addr, len) == 0); -} - - -SCNetworkReachabilityRef -SCNetworkReachabilityCreateWithAddressPair(CFAllocatorRef allocator, - const struct sockaddr *localAddress, - const struct sockaddr *remoteAddress) -{ - SCNetworkReachabilityPrivateRef targetPrivate; - - if ((localAddress == NULL) && (remoteAddress == NULL)) { - _SCErrorSet(kSCStatusInvalidArgument); - return NULL; - } - - if (localAddress != NULL) { - localAddress = is_valid_address(localAddress); - if (localAddress == NULL) { - _SCErrorSet(kSCStatusInvalidArgument); - return NULL; - } - } - - if (remoteAddress != NULL) { - remoteAddress = is_valid_address(remoteAddress); - if (remoteAddress == NULL) { - _SCErrorSet(kSCStatusInvalidArgument); - return NULL; - } - } - - targetPrivate = __SCNetworkReachabilityCreatePrivate(allocator); - if (targetPrivate == NULL) { - return NULL; - } - - targetPrivate->type = reachabilityTypeAddressPair; - - if (localAddress != NULL) { - targetPrivate->localAddress = CFAllocatorAllocate(NULL, localAddress->sa_len, 0); - bcopy(localAddress, targetPrivate->localAddress, localAddress->sa_len); - } - - if (remoteAddress != NULL) { - if (is_same_address(localAddress, remoteAddress)) { - targetPrivate->remoteAddress = targetPrivate->localAddress; - } else { - targetPrivate->remoteAddress = CFAllocatorAllocate(NULL, remoteAddress->sa_len, 0); - bcopy(remoteAddress, targetPrivate->remoteAddress, remoteAddress->sa_len); - } - } - - - - SCLog((_sc_debug && (_sc_log > 0)), LOG_INFO, CFSTR("%s%s %@"), - targetPrivate->log_prefix, - DEBUG_REACHABILITY_TYPE_ADDRESSPAIR, - targetPrivate); - - return (SCNetworkReachabilityRef)targetPrivate; -} - - -SCNetworkReachabilityRef -SCNetworkReachabilityCreateWithName(CFAllocatorRef allocator, - const char *nodename) -{ - union { - struct sockaddr sa; - struct sockaddr_in sin; - struct sockaddr_in6 sin6; - } addr; - size_t nodenameLen; - SCNetworkReachabilityPrivateRef targetPrivate; - - if (nodename == NULL) { - _SCErrorSet(kSCStatusInvalidArgument); - return NULL; - } - - nodenameLen = strlen(nodename); - if (nodenameLen == 0) { - _SCErrorSet(kSCStatusInvalidArgument); - return NULL; - } - - if (nodename[nodenameLen - 1] == '.') { - int dots; - size_t i; - - // trim trailing "."s - do { - --nodenameLen; - } while ((nodenameLen > 0) && (nodename[nodenameLen - 1] == '.')); - - if (nodenameLen == 0) { - // if only trailing "."s - _SCErrorSet(kSCStatusInvalidArgument); - return NULL; - } - - // count the remaining "."s - dots = 0; - for (i = 0; i < nodenameLen; i++) { - if (nodename[i] == '.') dots++; - } - - if (dots == 0) { - // if only a single-label, add back the FQDN "." - nodenameLen++; - } - } - - if (_SC_string_to_sockaddr(nodename, AF_UNSPEC, (void *)&addr, sizeof(addr)) != NULL) { - /* if this "nodename" is really an IP[v6] address in disguise */ - return SCNetworkReachabilityCreateWithAddress(allocator, &addr.sa); - } - - targetPrivate = __SCNetworkReachabilityCreatePrivate(allocator); - if (targetPrivate == NULL) { - return NULL; - } - - targetPrivate->type = reachabilityTypeName; - - targetPrivate->name = CFAllocatorAllocate(NULL, nodenameLen + 1, 0); - strlcpy((char *)targetPrivate->name, nodename, nodenameLen + 1); - - targetPrivate->needResolve = TRUE; - targetPrivate->info.flags |= kSCNetworkReachabilityFlagsFirstResolvePending; - targetPrivate->serverInfo.flags |= kSCNetworkReachabilityFlagsFirstResolvePending; - - { - /* make sure AppLayerVPN only is in client mode */ - CFDictionaryRef appLayerVPNProperties; - - appLayerVPNProperties = VPNAppLayerCopyCurrentAppProperties(); - if (appLayerVPNProperties != NULL) { - targetPrivate->serverBypassForVPN = TRUE; - targetPrivate->serverBypass = YES; - CFRelease(appLayerVPNProperties); - } - } - - SCLog((_sc_debug && (_sc_log > 0)), LOG_INFO, CFSTR("%s%s %@"), - targetPrivate->log_prefix, - DEBUG_REACHABILITY_TYPE_NAME, - targetPrivate); - - return (SCNetworkReachabilityRef)targetPrivate; -} - - -static SCNetworkReachabilityRef -__SCNetworkReachabilityCreateWithPtr(CFAllocatorRef allocator, - const char *ptrName, - const struct sockaddr *ptrAddress) -{ - SCNetworkReachabilityRef target; - SCNetworkReachabilityPrivateRef targetPrivate; - - target = SCNetworkReachabilityCreateWithName(NULL, ptrName); - if (target == NULL) { - return NULL; - } - - targetPrivate = (SCNetworkReachabilityPrivateRef)target; - - // change type - targetPrivate->type = reachabilityTypePTR; - - // and keep the address - targetPrivate->remoteAddress = CFAllocatorAllocate(NULL, ptrAddress->sa_len, 0); - bcopy(ptrAddress, targetPrivate->remoteAddress, ptrAddress->sa_len); - - return target; -} - - - - -SCNetworkReachabilityRef -SCNetworkReachabilityCreateWithOptions(CFAllocatorRef allocator, - CFDictionaryRef options) -{ - const struct sockaddr *addr_l = NULL; - const struct sockaddr *addr_p = NULL; - const struct sockaddr *addr_r = NULL; - CFDataRef data; - CFStringRef interface = NULL; - CFStringRef nodename; - CFBooleanRef onDemandBypass; - CFBooleanRef resolverBypass; - CFBooleanRef serverBypass; - SCNetworkReachabilityRef target; - SCNetworkReachabilityPrivateRef targetPrivate; - - if (!isA_CFDictionary(options)) { - _SCErrorSet(kSCStatusInvalidArgument); - return NULL; - } - - nodename = CFDictionaryGetValue(options, kSCNetworkReachabilityOptionNodeName); - if ((nodename != NULL) && - (!isA_CFString(nodename) || (CFStringGetLength(nodename) == 0))) { - _SCErrorSet(kSCStatusInvalidArgument); - return NULL; - } - data = CFDictionaryGetValue(options, kSCNetworkReachabilityOptionLocalAddress); - if (data != NULL) { - if (!isA_CFData(data) || (CFDataGetLength(data) < sizeof(struct sockaddr_in))) { - _SCErrorSet(kSCStatusInvalidArgument); - return NULL; - } - addr_l = (const struct sockaddr *)CFDataGetBytePtr(data); - } - data = CFDictionaryGetValue(options, kSCNetworkReachabilityOptionPTRAddress); - if (data != NULL) { - if (!isA_CFData(data) || (CFDataGetLength(data) < sizeof(struct sockaddr_in))) { - _SCErrorSet(kSCStatusInvalidArgument); - return NULL; - } - addr_p = (const struct sockaddr *)CFDataGetBytePtr(data); - } - data = CFDictionaryGetValue(options, kSCNetworkReachabilityOptionRemoteAddress); - if (data != NULL) { - if (!isA_CFData(data) || (CFDataGetLength(data) < sizeof(struct sockaddr_in))) { - _SCErrorSet(kSCStatusInvalidArgument); - return NULL; - } - addr_r = (const struct sockaddr *)CFDataGetBytePtr(data); - } - interface = CFDictionaryGetValue(options, kSCNetworkReachabilityOptionInterface); - if ((interface != NULL) && - (!isA_CFString(interface) || (CFStringGetLength(interface) == 0))) { - _SCErrorSet(kSCStatusInvalidArgument); - return NULL; - } - onDemandBypass = CFDictionaryGetValue(options, kSCNetworkReachabilityOptionConnectionOnDemandBypass); - if ((onDemandBypass != NULL) && !isA_CFBoolean(onDemandBypass)) { - _SCErrorSet(kSCStatusInvalidArgument); - return NULL; - } - resolverBypass = CFDictionaryGetValue(options, kSCNetworkReachabilityOptionResolverBypass); - if ((resolverBypass != NULL) && !isA_CFBoolean(resolverBypass)) { - _SCErrorSet(kSCStatusInvalidArgument); - return NULL; - } - - - serverBypass = CFDictionaryGetValue(options, kSCNetworkReachabilityOptionServerBypass); - if ((serverBypass != NULL) && !isA_CFBoolean(serverBypass)) { - _SCErrorSet(kSCStatusInvalidArgument); - return NULL; - } - - - if (nodename != NULL) { - const char *name; - - if ((addr_l != NULL) || (addr_r != NULL) || (addr_p != NULL)) { - // can't have both a nodename and an address - _SCErrorSet(kSCStatusInvalidArgument); - return NULL; - } - - name = _SC_cfstring_to_cstring(nodename, NULL, 0, kCFStringEncodingUTF8); - target = SCNetworkReachabilityCreateWithName(allocator, name); - CFAllocatorDeallocate(NULL, (void *)name); - } else if (addr_p != NULL) { - char name[MAXHOSTNAMELEN]; - - if ((addr_l != NULL) || // can't have PTR and target address - (addr_r != NULL) || // can't have PTR and target address - !addr_to_PTR_name(addr_p, name, sizeof(name))) { // can't convert PTR - _SCErrorSet(kSCStatusInvalidArgument); - return NULL; - } - - target = __SCNetworkReachabilityCreateWithPtr(NULL, name, addr_p); - } else { - if ((addr_l != NULL) && (addr_r != NULL)) { - target = SCNetworkReachabilityCreateWithAddressPair(NULL, addr_l, addr_r); - } else if (addr_r != NULL) { - target = SCNetworkReachabilityCreateWithAddress(NULL, addr_r); - } else if (addr_l != NULL) { - target = SCNetworkReachabilityCreateWithAddressPair(NULL, addr_l, NULL); - } else { - _SCErrorSet(kSCStatusInvalidArgument); - return NULL; - } - } - if (target == NULL) { - return NULL; - } - - targetPrivate = (SCNetworkReachabilityPrivateRef)target; - - if (interface != NULL) { - if ((_SC_cfstring_to_cstring(interface, - targetPrivate->if_name, - sizeof(targetPrivate->if_name), - kCFStringEncodingASCII) == NULL) || - ((targetPrivate->if_index = if_nametoindex(targetPrivate->if_name)) == 0)) { - CFRelease(targetPrivate); - _SCErrorSet(kSCStatusInvalidArgument); - return NULL; - } - } - - - if (onDemandBypass != NULL) { - targetPrivate->onDemandBypass = CFBooleanGetValue(onDemandBypass); - } - - if (resolverBypass != NULL) { - targetPrivate->resolverBypass = CFBooleanGetValue(resolverBypass); - } - - /* if by name, make sure client-only VPN types stay in client mode */ - if (serverBypass != NULL && targetPrivate->serverBypassForVPN == FALSE) { - targetPrivate->serverBypass = CFBooleanGetValue(serverBypass); - } - - - if (_sc_debug && (_sc_log > 0)) { - const char *opt = "???"; - - switch (targetPrivate->type) { - case reachabilityTypeAddress : - opt = DEBUG_REACHABILITY_TYPE_ADDRESS_OPTIONS; - break; - case reachabilityTypeAddressPair : - opt = DEBUG_REACHABILITY_TYPE_ADDRESSPAIR_OPTIONS; - break; - case reachabilityTypeName : - opt = DEBUG_REACHABILITY_TYPE_NAME_OPTIONS; - break; - case reachabilityTypePTR : - opt = DEBUG_REACHABILITY_TYPE_PTR_OPTIONS; - break; - } - - SCLog(TRUE, LOG_INFO, CFSTR("%s%s %@"), - targetPrivate->log_prefix, - opt, - targetPrivate); - } - - return (SCNetworkReachabilityRef)targetPrivate; -} - - -static SCNetworkReachabilityRef -__SCNetworkReachabilityCreateCopy(SCNetworkReachabilityRef target) -{ - SCNetworkReachabilityRef clone = NULL; - SCNetworkReachabilityPrivateRef clonePrivate; - SCNetworkReachabilityPrivateRef targetPrivate = (SCNetworkReachabilityPrivateRef)target; - - switch (targetPrivate->type) { - case reachabilityTypeAddress : - clone = SCNetworkReachabilityCreateWithAddress(NULL, - targetPrivate->remoteAddress); - break; - case reachabilityTypeAddressPair : - clone = SCNetworkReachabilityCreateWithAddressPair(NULL, - targetPrivate->localAddress, - targetPrivate->remoteAddress); - break; - case reachabilityTypeName : - clone = SCNetworkReachabilityCreateWithName(NULL, - targetPrivate->name); - break; - case reachabilityTypePTR : - clone = __SCNetworkReachabilityCreateWithPtr(NULL, - targetPrivate->name, - targetPrivate->remoteAddress); - break; - } - if (clone == NULL) { - return NULL; - } - - clonePrivate = (SCNetworkReachabilityPrivateRef)clone; - - clonePrivate->quiet = TRUE; - - clonePrivate->if_index = targetPrivate->if_index; - bcopy(targetPrivate->if_name, clonePrivate->if_name, sizeof(clonePrivate->if_name)); - - clonePrivate->onDemandBypass = targetPrivate->onDemandBypass; - - - clonePrivate->serverBypass = targetPrivate->serverBypass; - - clonePrivate->resolverBypass = targetPrivate->resolverBypass; - - - if (_sc_debug && (_sc_log > 0)) { - const char *opt = "???"; - - switch (clonePrivate->type) { - case reachabilityTypeAddress : - opt = DEBUG_REACHABILITY_TYPE_ADDRESS_CLONE; - break; - case reachabilityTypeAddressPair : - opt = DEBUG_REACHABILITY_TYPE_ADDRESSPAIR_CLONE; - break; - case reachabilityTypeName : - opt = DEBUG_REACHABILITY_TYPE_NAME_CLONE; - break; - case reachabilityTypePTR : - opt = DEBUG_REACHABILITY_TYPE_PTR_CLONE; - break; - } - - SCLog(TRUE, LOG_INFO, CFSTR("%s%s %p %@"), - clonePrivate->log_prefix, - opt, - targetPrivate, - clone); - } - - return clone; -} - - -CFTypeID -SCNetworkReachabilityGetTypeID(void) -{ - pthread_once(&initialized, __SCNetworkReachabilityInitialize); /* initialize runtime */ - return __kSCNetworkReachabilityTypeID; -} - - -CFArrayRef /* CFArray[CFData], where each CFData is a (struct sockaddr *) */ -SCNetworkReachabilityCopyResolvedAddress(SCNetworkReachabilityRef target, - int *error_num) -{ - SCNetworkReachabilityPrivateRef targetPrivate = (SCNetworkReachabilityPrivateRef)target; - - if (!isA_SCNetworkReachability(target)) { - _SCErrorSet(kSCStatusInvalidArgument); - return NULL; - } - - if (!isReachabilityTypeName(targetPrivate->type)) { - _SCErrorSet(kSCStatusInvalidArgument); - return NULL; - } - - if (error_num) { - *error_num = targetPrivate->resolvedError; - } - - if (targetPrivate->resolvedAddresses != NULL) { - if (isA_CFArray(targetPrivate->resolvedAddresses)) { - return CFRetain(targetPrivate->resolvedAddresses); - } else { - /* if status is known but no resolved addresses to return */ - _SCErrorSet(kSCStatusOK); - return NULL; - } - } - - _SCErrorSet(kSCStatusReachabilityUnknown); - return NULL; -} - - -static void -__SCNetworkReachabilitySetResolvedError(SCNetworkReachabilityRef target, - int32_t status) -{ - SCNetworkReachabilityPrivateRef targetPrivate = (SCNetworkReachabilityPrivateRef)target; - - MUTEX_ASSERT_HELD(&targetPrivate->lock); - - __mark_operation_end(target, - FALSE, // if successful query - dns_query_async, // async - &targetPrivate->dnsQueryStart, // start time - &targetPrivate->dnsQueryEnd); // end time - - if (targetPrivate->resolvedAddresses != NULL) { - CFRelease(targetPrivate->resolvedAddresses); - targetPrivate->resolvedAddresses = NULL; - } - - SCLog(_sc_debug, LOG_INFO, CFSTR("%scould not be resolved: %s"), - targetPrivate->log_prefix, - gai_strerror(status)); - - /* save the error associated with the attempt to resolve the name */ - targetPrivate->resolvedAddresses = CFRetain(kCFNull); - targetPrivate->resolvedError = status; - targetPrivate->needResolve = FALSE; - - return; -} - - -/* - * rankReachability() - * Not reachable == 0 - * Connection Required == 1 - * Reachable == 2 - */ -static int -rankReachability(SCNetworkReachabilityFlags flags) -{ - int rank = 0; - - if (flags & kSCNetworkReachabilityFlagsReachable) rank = 2; - if (flags & kSCNetworkReachabilityFlagsConnectionRequired) rank = 1; - return rank; -} - - -#pragma mark - -#pragma mark DNS name resolution - - -static void -update_resolver_reachability(ReachabilityStoreInfoRef store_info, - dns_resolver_t *resolver, - SCNetworkReachabilityFlags *flags, - Boolean *haveDNS, - uint32_t *resolver_if_index, - const char *log_prefix) -{ - if (resolver_if_index) *resolver_if_index = 0; - - if (resolver->n_nameserver > 0) { - *flags = (SCNetworkReachabilityFlags)resolver->reach_flags; - if (resolver_if_index != NULL) { - *resolver_if_index = resolver->if_index; - } - *haveDNS = TRUE; - } else { - *flags = kSCNetworkReachabilityFlagsReachable; - *haveDNS = FALSE; - } - - return; -} - - -static Boolean -check_matching_resolvers(ReachabilityStoreInfoRef store_info, - dns_config_t *dns_config, - const char *fqdn, - unsigned int if_index, - SCNetworkReachabilityFlags *flags, - Boolean *haveDNS, - uint32_t *resolver_if_index, - int *dns_config_index, - const char *log_prefix) -{ - int i; - Boolean matched = FALSE; - const char *name = fqdn; - int32_t n_resolvers; - dns_resolver_t **resolvers; - - if (if_index == 0) { - n_resolvers = dns_config->n_resolver; - resolvers = dns_config->resolver; - } else { - n_resolvers = dns_config->n_scoped_resolver; - resolvers = dns_config->scoped_resolver; - } - - /* In case we couldn't find a match, setting an index of -1 - and resolver_if_index 0 */ - if (dns_config_index != NULL) *dns_config_index = -1; - if (resolver_if_index != NULL) *resolver_if_index = 0; - - while (!matched && (name != NULL)) { - size_t len; - - /* - * check if the provided name (or sub-component) - * matches one of our resolver configurations. - */ - len = strlen(name); - for (i = 0; i < n_resolvers; i++) { - char *domain; - dns_resolver_t *resolver; - - resolver = resolvers[i]; - if ((if_index != 0) && (if_index != resolver->if_index)) { - continue; - } - - domain = resolver->domain; - if (domain != NULL && (len == strlen(domain))) { - if (strcasecmp(name, domain) == 0) { - /* - * if name matches domain - */ - matched = TRUE; - update_resolver_reachability(store_info, - resolver, - flags, - haveDNS, - resolver_if_index, - log_prefix); - if (dns_config_index != NULL) *dns_config_index = i; - break; - } - } - } - - if (!matched) { - /* - * we have not found a matching resolver, try - * a less qualified domain - */ - name = strchr(name, '.'); - if ((name != NULL) && (*name != '\0')) { - name++; - } else { - name = NULL; - } - } - } - - return matched; -} - - -static dns_resolver_t * -get_default_resolver(dns_config_t *dns_config, unsigned int if_index) -{ - int i; - int32_t n_resolvers; - dns_resolver_t *resolver = NULL; - dns_resolver_t **resolvers; - - if (if_index == 0) { - n_resolvers = dns_config->n_resolver; - resolvers = dns_config->resolver; - } else { - n_resolvers = dns_config->n_scoped_resolver; - resolvers = dns_config->scoped_resolver; - } - - for (i = 0; i < n_resolvers; i++) { - if ((if_index != 0) && (if_index != resolvers[i]->if_index)) { - continue; - } - - if (((if_index == 0) && (i == 0)) || - ((if_index != 0) && (resolver == NULL))) { - // if this is the first (aka default) resolver - resolver = resolvers[i]; - } else if ((resolvers[i]->domain == NULL) && - (resolvers[i]->search_order < resolver->search_order)) { - // if this is a default resolver with a lower search order - resolver = resolvers[i]; - } - } - - return resolver; -} - - -static dns_configuration_t * -dns_configuration_retain() -{ - dns_configuration_t *config; - - pthread_mutex_lock(&dns_lock); - - if (dns_configuration != NULL) { - Boolean refresh = TRUE; - - if (dns_token_valid) { - int check = 0; - uint32_t status; - - /* - * check if the global [DNS] configuration snapshot needs - * to be updated - */ - status = notify_check(dns_token, &check); - if (status != NOTIFY_STATUS_OK) { - SCLog(TRUE, LOG_INFO, CFSTR("notify_check() failed, status=%u"), status); - } else if (check == 0) { - // if the snapshot does not need to be refreshed - refresh = FALSE; - } - } - - if (refresh) { - if (dns_configuration->refs == 0) { - dns_configuration_free(dns_configuration->config); - CFAllocatorDeallocate(NULL, dns_configuration); - } - dns_configuration = NULL; - } - } - - if (dns_configuration == NULL) { - dns_config_t *new_config; - - new_config = dns_configuration_copy(); - if (new_config != NULL) { - dns_configuration = CFAllocatorAllocate(NULL, sizeof(dns_configuration_t), 0); - dns_configuration->config = new_config; - dns_configuration->refs = 0; - } - } - - if (dns_configuration != NULL) { - dns_configuration->refs++; - } - - config = dns_configuration; - pthread_mutex_unlock(&dns_lock); - return config; -} - - -static void -dns_configuration_release(dns_configuration_t *config) -{ - pthread_mutex_lock(&dns_lock); - - config->refs--; - if (config->refs == 0) { - if (!dns_token_valid && (config == dns_configuration)) { - dns_configuration = NULL; - } - - if (config != dns_configuration) { - dns_configuration_free(config->config); - CFAllocatorDeallocate(NULL, config); - } - } - - pthread_mutex_unlock(&dns_lock); - return; -} - - -static Boolean -dns_configuration_watch() -{ - int dns_check = 0; - const char *dns_key; - Boolean ok = FALSE; - uint32_t status; - - pthread_mutex_lock(&dns_lock); - - dns_key = dns_configuration_notify_key(); - if (dns_key == NULL) { - SCLog(TRUE, LOG_INFO, CFSTR("dns_configuration_notify_key() failed")); - goto done; - } - - status = notify_register_check(dns_key, &dns_token); - if (status == NOTIFY_STATUS_OK) { - dns_token_valid = TRUE; - } else { - SCLog(TRUE, LOG_INFO, CFSTR("notify_register_check() failed, status=%u"), status); - goto done; - } - - status = notify_check(dns_token, &dns_check); - if (status != NOTIFY_STATUS_OK) { - SCLog(TRUE, LOG_INFO, CFSTR("notify_check() failed, status=%u"), status); - (void)notify_cancel(dns_token); - dns_token_valid = FALSE; - goto done; - } - - ok = TRUE; - - done : - - pthread_mutex_unlock(&dns_lock); - return ok; -} - - -static void -dns_configuration_unwatch() -{ - pthread_mutex_lock(&dns_lock); - - (void)notify_cancel(dns_token); - dns_token_valid = FALSE; - - if ((dns_configuration != NULL) && (dns_configuration->refs == 0)) { - dns_configuration_free(dns_configuration->config); - CFAllocatorDeallocate(NULL, dns_configuration); - dns_configuration = NULL; - } - - pthread_mutex_unlock(&dns_lock); - return; -} - - -static void -_SC_R_updateResolverReachability(ReachabilityStoreInfoRef store_info, - SCNetworkReachabilityFlags *flags, - Boolean *haveDNS, - const char *nodename, - unsigned int if_index, - uint32_t *resolver_if_index, - int *dns_config_index, - const char *log_prefix - ) -{ - dns_resolver_t *default_resolver; - dns_configuration_t *dns; - Boolean found = FALSE; - char *fqdn = (char *)nodename; - int i; - Boolean isFQDN = FALSE; - size_t len; - const int ndots = 1; - Boolean useDefault = FALSE; - - if (resolver_if_index) *resolver_if_index = 0; - if (dns_config_index) *dns_config_index = -1; - - /* - * We first assume that all of the configured DNS servers - * are available. Since we don't know which name server will - * be consulted to resolve the specified nodename we need to - * check the availability of ALL name servers. We can only - * proceed if we know that our query can be answered. - */ - - *flags = kSCNetworkReachabilityFlagsReachable; - *haveDNS = FALSE; - - len = (nodename != NULL) ? strlen(nodename) : 0; - if (len == 0) { - // if no nodename, return not reachable - *flags = 0; - return; - } - - dns = dns_configuration_retain(); - if (dns == NULL) { - // if error - SCLog(_sc_debug, LOG_INFO, CFSTR("%sDNS: no configuration"), log_prefix); - goto done; - } - - default_resolver = get_default_resolver(dns->config, if_index); - if (default_resolver == NULL) { - // if no resolver configuration - SCLog(_sc_debug, LOG_INFO, CFSTR("%sDNS: no resolvers"), log_prefix); - goto done; - } - - if (fqdn[len - 1] == '.') { - isFQDN = TRUE; - - // trim trailing '.''s - while ((len > 0) && (fqdn[len-1] == '.')) { - if (fqdn == nodename) { - fqdn = strdup(nodename); - assert(fqdn != nodename); - } - fqdn[--len] = '\0'; - } - } - - /* - * check if the provided name matches a supplemental domain - */ - found = check_matching_resolvers(store_info, dns->config, fqdn, if_index, - flags, haveDNS, resolver_if_index, - dns_config_index, log_prefix); - - if (!found && !isFQDN) { - /* - * if we did not match a supplemental domain name and if the - * provided name has enough "."s then the first query will be - * directed to the default resolver. - */ - char *cp; - int dots; - - dots = 0; - for (cp = fqdn; *cp != '\0'; cp++) { - if (*cp == '.') dots++; - } - - /* Per KB: HT4845 */ - if (dots >= ndots) { - useDefault = TRUE; - } - } - - if (!found && !isFQDN && !useDefault && (dns->config->n_resolver > 1)) { - /* - * FQDN not specified, try matching w/search domains - */ - if (default_resolver->n_search > 0) { - for (i = 0; !found && (i < default_resolver->n_search); i++) { - int ret; - char *search_fqdn = NULL; - - ret = asprintf(&search_fqdn, "%s.%s", fqdn, default_resolver->search[i]); - if (ret == -1) { - continue; - } - - // try the provided name with the search domain appended - found = check_matching_resolvers(store_info, - dns->config, - search_fqdn, - if_index, - flags, - haveDNS, - resolver_if_index, - dns_config_index, - log_prefix); - free(search_fqdn); - } - } else if (default_resolver->domain != NULL) { - char *dp; - int domain_parts = 0; - - // count domain parts - for (dp = default_resolver->domain; *dp != '\0'; dp++) { - if (*dp == '.') { - domain_parts++; - } - } - - // remove trailing dots - for (dp--; (dp >= default_resolver->domain) && (*dp == '.'); dp--) { - *dp = '\0'; - domain_parts--; - } - - if (dp >= default_resolver->domain) { - // dots are separators, bump # of components - domain_parts++; - } - - dp = default_resolver->domain; - for (i = LOCALDOMAINPARTS; !found && (i <= (domain_parts - ndots)); i++) { - int ret; - char *search_fqdn = NULL; - - ret = asprintf(&search_fqdn, "%s.%s", fqdn, dp); - if (ret == -1) { - continue; - } - - // try the provided name with the [default] domain appended - found = check_matching_resolvers(store_info, - dns->config, - search_fqdn, - if_index, - flags, - haveDNS, - resolver_if_index, - dns_config_index, - log_prefix); - free(search_fqdn); - - // move to the next component of the [default] domain - dp = strchr(dp, '.') + 1; - } - } - } - - if (!found) { - // update the reachability of the default resolver - update_resolver_reachability(store_info, - default_resolver, - flags, - haveDNS, - resolver_if_index, - log_prefix); - if (dns_config_index != NULL) *dns_config_index = 0; - } - - done : - - if (fqdn != nodename) free(fqdn); - - if (dns != NULL) { - dns_configuration_release(dns); - } - - return; -} - - -Boolean -__SC_checkResolverReachabilityInternal(SCDynamicStoreRef *storeP, - SCNetworkReachabilityFlags *flags, - Boolean *haveDNS, - const char *nodename, - uint32_t *resolver_if_index, - int *dns_config_index) -{ - Boolean ok; - ReachabilityStoreInfo store_info; - - ReachabilityStoreInfo_init(&store_info); - ok = ReachabilityStoreInfo_update(&store_info, storeP, AF_UNSPEC); - if (!ok) { - goto done; - } - - _SC_R_updateResolverReachability(&store_info, - flags, - haveDNS, - nodename, - 0, - resolver_if_index, - dns_config_index, - ""); - - done : - - ReachabilityStoreInfo_free(&store_info); - return ok; -} - - -/* - * _SC_checkResolverReachabilityByAddress() - * - * Given an IP address, determine whether a reverse DNS query can be issued - * using the current network configuration. - */ -Boolean -_SC_checkResolverReachabilityByAddress(SCDynamicStoreRef *storeP, - SCNetworkReachabilityFlags *flags, - Boolean *haveDNS, - struct sockaddr *sa) -{ - Boolean ok; - char ptr_name[128]; - ReachabilityStoreInfo store_info; - - ReachabilityStoreInfo_init(&store_info); - ok = ReachabilityStoreInfo_update(&store_info, storeP, AF_UNSPEC); - if (!ok) { - goto done; - } - - /* - * Ideally, we would have an API that given a local IP - * address would return the DNS server(s) that would field - * a given PTR query. Fortunately, we do have an SPI which - * which will provide this information given a "name" so we - * take the address, convert it into the inverse query name, - * and find out which servers should be consulted. - */ - ok = addr_to_PTR_name(sa, ptr_name, sizeof(ptr_name)); - if (!ok) { - goto done; - } - - _SC_R_updateResolverReachability(&store_info, flags, haveDNS, ptr_name, 0, NULL, NULL, ""); - - done : - - ReachabilityStoreInfo_free(&store_info); - return ok; -} - - -#pragma mark - -#pragma mark DNSServiceGetAddrInfo support - - -/* - * DNS query handling - * - * Notes : - * - * 1. We have a "contract" with mDNSResponder that for EVERY network - * or DNS configuration change that should warrant our [re-]starting - * a query, mDNSResponder will acknowledge the latest DNS configuration. - * - * 2. IPMonitor also posts a notification AFTER every network or DNS - * configuration change. - * - * 3. We use IPMonitor's "trailing edge" as a signal to restart any - * by-name queries. - */ - - -// Note: protected by _hn_target_queue() -static int dns_refresh_token; -static Boolean dns_refresh_token_valid = FALSE; - - -/* - * dns_refresh_handler - * - * Called to notify/update all SCNetworkReachability by-name targets of - * a network/DNS change. The change should [re-]start a DNS query to - * resolve the name. - * - should be exec'd on the _hn_target_queue() - */ -static void -dns_refresh_handler() -{ - CFArrayRef changes; - CFStringRef key; - __block SCDynamicStoreRef store = NULL; - - dispatch_sync(_hn_target_queue(), ^{ - if (dns_refresh_token_valid && (hn_store != NULL)) { - store = CFRetain(hn_store); - } - }); - - if (store == NULL) { - return; - } - - key = SCDynamicStoreKeyCreateNetworkGlobalEntity(NULL, - kSCDynamicStoreDomainState, - kSCEntNetDNS); - changes = CFArrayCreate(NULL, (const void **)&key, 1, &kCFTypeArrayCallBacks); - __SCNetworkReachabilityHandleChanges(store, changes, NULL); - CFRelease(changes); - CFRelease(key); - - CFRelease(store); - return; -} - - -/* - * dns_refresh_enable - * - * Called to monitor for network/DNS changes that should restart a DNS query. - * - caller must be running on the _hn_target_queue() - */ -static Boolean -dns_refresh_enable(dispatch_queue_t q) -{ - uint32_t status; - - status = notify_register_dispatch(_SC_NOTIFY_NETWORK_CHANGE, - &dns_refresh_token, - q, - ^(int token){ - dns_refresh_handler(); - }); - if (status != NOTIFY_STATUS_OK) { - SCLog(TRUE, LOG_INFO, CFSTR("notify_register_dispatch() failed, status=%u"), status); - return FALSE; - } - - dns_refresh_token_valid = TRUE; - - return TRUE; -} - - -/* - * dns_refresh_disable - * - * Called to stop monitoring for network/DNS changes - * - caller must be running on the _hn_target_queue() - */ -static void -dns_refresh_disable() -{ - (void)notify_cancel(dns_refresh_token); - dns_refresh_token_valid = FALSE; - return; -} - - -#pragma mark - -#pragma mark [m]DNS Queries - - -static void -dequeueDNSQuery(SCNetworkReachabilityRef target); - - -static dispatch_queue_t -_dns_queue() -{ - static dispatch_once_t once; - static dispatch_queue_t q; - - dispatch_once(&once, ^{ - q = dispatch_queue_create("SCNetworkReachability.DNSService", NULL); - }); - - return q; -} - - -/* - * _dns_complete - */ -static __inline__ Boolean -_dns_complete(SCNetworkReachabilityRef target) -{ - SCNetworkReachabilityPrivateRef targetPrivate = (SCNetworkReachabilityPrivateRef)target; - - if ((targetPrivate->dnsHaveV4 && targetPrivate->dnsHaveV6) || - targetPrivate->dnsHavePTR || - targetPrivate->dnsHaveError || - targetPrivate->dnsHaveTimeout) { - return TRUE; - } - - return FALSE; -} - - -/* - * _dns_notify - * - * Called to push out a target's DNS changes - * - caller must be running on the _dns_queue() - */ -static void -_dns_notify(const void *value, void *context) -{ - SCNetworkReachabilityRef target = (SCNetworkReachabilityRef)value; - SCNetworkReachabilityPrivateRef targetPrivate = (SCNetworkReachabilityPrivateRef)target; - - MUTEX_LOCK(&targetPrivate->lock); - - if (_dns_complete(target)) { - __mark_operation_end(target, - (targetPrivate->resolvedError == NETDB_SUCCESS), // if successful query - dns_query_mdns, // [m]DNS query - &targetPrivate->dnsQueryStart, // start time - &targetPrivate->dnsQueryEnd); // end time - - // update target info - if (targetPrivate->resolvedAddresses != NULL) { - CFRelease(targetPrivate->resolvedAddresses); - } - targetPrivate->resolvedAddresses = targetPrivate->dnsAddresses; - targetPrivate->dnsAddresses = NULL; - - targetPrivate->resolvedError = targetPrivate->dnsError; - targetPrivate->dnsError = NETDB_SUCCESS; - - dequeueDNSQuery(target); - - targetPrivate->needResolve = FALSE; - - if (targetPrivate->scheduled) { - __SCNetworkReachabilityUpdate(target); - } - } - - MUTEX_UNLOCK(&targetPrivate->lock); - return; -} - - -typedef enum { - MARK_NONE, - MARK_ERROR, - MARK_TIMEOUT, - MARK_HAVE_V4, - MARK_HAVE_V6, - MARK_HAVE_PTR, -} _dns_mark_t; - - -/* - * _dns_mark - */ -static __inline__ void -_dns_mark(SCNetworkReachabilityRef target, _dns_mark_t mark) -{ - SCNetworkReachabilityPrivateRef targetPrivate = (SCNetworkReachabilityPrivateRef)target; - - switch (mark) { - case MARK_NONE : - break; - case MARK_ERROR : - targetPrivate->dnsHaveError = TRUE; - break; - case MARK_TIMEOUT : - targetPrivate->dnsHaveTimeout = TRUE; - break; - case MARK_HAVE_V4 : - targetPrivate->dnsHaveV4 = TRUE; - break; - case MARK_HAVE_V6 : - targetPrivate->dnsHaveV6 = TRUE; - break; - case MARK_HAVE_PTR : - targetPrivate->dnsHavePTR = TRUE; - break; - } - - return; -} - - -/* - * _dns_callback - * - * Called to process [m]DNS query updates - * - caller must be running on the _dns_queue() - */ -static void -_dns_callback(DNSServiceRef sdRef, - DNSServiceFlags flags, - DNSServiceErrorType errorCode, - _dns_mark_t dnsMark, - CFTypeRef dnsAddress, // CFData(struct sockaddr) or CFString(ptr_name) - void *context) -{ - int failures = 0; - Boolean restart = FALSE; - SCNetworkReachabilityRef target = (SCNetworkReachabilityRef)context; - SCNetworkReachabilityPrivateRef targetPrivate = (SCNetworkReachabilityPrivateRef)target; - - MUTEX_LOCK(&targetPrivate->lock); - - if (sdRef != targetPrivate->dnsTarget) { - // if this DNSServiceRef is no longer associated with the target - MUTEX_UNLOCK(&targetPrivate->lock); - return; - } - - switch (errorCode) { - case kDNSServiceErr_NoError : - if (dnsAddress != NULL) { - CFMutableArrayRef addresses; - CFIndex i; - - _dns_mark(target, dnsMark); - - if (targetPrivate->dnsAddresses != NULL) { - if (isA_CFArray(targetPrivate->dnsAddresses)) { - addresses = CFArrayCreateMutableCopy(NULL, 0, targetPrivate->dnsAddresses); - } else { - addresses = CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks); - } - - CFRelease(targetPrivate->dnsAddresses); - targetPrivate->dnsAddresses = NULL; - } else { - addresses = CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks); - } - - i = CFArrayGetFirstIndexOfValue(addresses, - CFRangeMake(0, CFArrayGetCount(addresses)), - dnsAddress); - if (flags & kDNSServiceFlagsAdd) { - // add address - if (i == kCFNotFound) { - CFArrayAppendValue(addresses, dnsAddress); - } -#ifdef HANDLE_RMV_REQUESTS - } else { - // remove address - if (i != kCFNotFound) { - CFArrayRemoveValueAtIndex(addresses, i); - } -#endif // HANDLE_RMV_REQUESTS - } - - if (CFArrayGetCount(addresses) > 0) { - targetPrivate->dnsAddresses = addresses; - targetPrivate->dnsError = NETDB_SUCCESS; - } else { - // if host not found - targetPrivate->dnsAddresses = CFRetain(kCFNull); - targetPrivate->dnsError = EAI_NONAME; - CFRelease(addresses); - } - - } - break; - case kDNSServiceErr_BadParam : - _dns_mark(target, MARK_ERROR); - - if (targetPrivate->dnsAddresses != NULL) { - CFRelease(targetPrivate->dnsAddresses); - } - targetPrivate->dnsAddresses = CFRetain(kCFNull); - targetPrivate->dnsError = EAI_NONAME; - break; - case kDNSServiceErr_NoSuchRecord : - _dns_mark(target, dnsMark); - - if (targetPrivate->dnsAddresses == NULL) { - targetPrivate->dnsAddresses = CFRetain(kCFNull); - targetPrivate->dnsError = EAI_NONAME; - } - break; - case kDNSServiceErr_Timeout : - _dns_mark(target, MARK_TIMEOUT); - - if (targetPrivate->dnsAddresses == NULL) { - targetPrivate->dnsAddresses = CFRetain(kCFNull); - targetPrivate->dnsError = EAI_NONAME; - } - break; - default : - SCLog(TRUE, LOG_ERR, - CFSTR("%sSCNetworkReachability _dns_callback w/error=%d (n=%d)"), - targetPrivate->log_prefix, - errorCode, - targetPrivate->dnsFailures + 1); - // fall through - case kDNSServiceErr_ServiceNotRunning : - _dns_mark(target, MARK_ERROR); - - // bump per-target failure count - failures = ++targetPrivate->dnsFailures; - - // Check to see if we've seen too many failures for this target - if (failures > 2) { - // if so, there's little point in retrying over - // and over again so let's just return an error - // and move on. - if (targetPrivate->dnsAddresses != NULL) { - CFRelease(targetPrivate->dnsAddresses); - } - targetPrivate->dnsAddresses = CFRetain(kCFNull); - targetPrivate->dnsError = EAI_NONAME; - } else if (targetPrivate->dnsGeneration == dnsGeneration) { - // if not, then "mDNSResponder" crashed or some - // other/unexpected error occurred. In this - // case, we'll try again with a clean slate and - // restart all requests. - if (dnsMain != NULL) { - DNSServiceRefDeallocate(dnsMain); - dnsMain = NULL; - dnsCount = 0; - dnsGeneration++; - restart = TRUE; - } - } - break; - } - - // update DNS failure count (and [re-]set to zero if we're OK) - targetPrivate->dnsFailures = failures; - - MUTEX_UNLOCK(&targetPrivate->lock); - - if (restart) { - SCLog(TRUE, LOG_DEBUG, - CFSTR("%sreconnecting SCNetworkReachability w/\"mDNSResponder\" (%d)"), - targetPrivate->log_prefix, - dnsGeneration); - - dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 500 * NSEC_PER_MSEC), - _hn_changes_queue(), - ^{ - dns_refresh_handler(); - }); - - // and flush the dnsUpdated queue as any DNS results we may have - // accumulated are no longer valid. - if (dnsUpdated != NULL) { - CFRelease(dnsUpdated); - dnsUpdated = NULL; - } - return; - } - - if (targetPrivate->dnsHaveTimeout) { - targetPrivate->dnsNoAddressesSinceLastTimeout = TRUE; - } else if (targetPrivate->dnsNoAddressesSinceLastTimeout && - isA_CFArray(targetPrivate->dnsAddresses) && - CFArrayGetCount(targetPrivate->dnsAddresses) > 0) - { - targetPrivate->dnsNoAddressesSinceLastTimeout = FALSE; - } - - // the "more coming" flag applies to DNSService callouts for any/all - // hosts that are being watched so we need to keep track of the targets - // we have updated. When we [finally] have the last callout then we - // push our notifications for all of the updated targets. - - if (dnsUpdated == NULL) { - dnsUpdated = CFSetCreateMutable(NULL, 0, &kCFTypeSetCallBacks); - } - CFSetAddValue(dnsUpdated, target); - - if (!(flags & kDNSServiceFlagsMoreComing)) { - CFSetApplyFunction(dnsUpdated, _dns_notify, NULL); - CFRelease(dnsUpdated); - dnsUpdated = NULL; - } - - return; -} - - -/* - * _dns_getaddrinfo_callback - * - * Called to process [m]DNS query updates - * - caller must be running on the _dns_queue() - */ -static void -_dns_getaddrinfo_callback(DNSServiceRef sdRef, - DNSServiceFlags flags, - uint32_t interfaceIndex, - DNSServiceErrorType errorCode, - const char *hostname, - const struct sockaddr *address, - uint32_t ttl, - void *context) -{ - CFDataRef dnsAddress = NULL; - _dns_mark_t dnsMark = MARK_NONE; - - if (address != NULL) { - switch (errorCode) { - case kDNSServiceErr_NoError : - dnsAddress = CFDataCreate(NULL, (void *)address, address->sa_len); - // ... and fall through - case kDNSServiceErr_NoSuchRecord : - switch (address->sa_family) { - case AF_INET : - dnsMark = MARK_HAVE_V4; - break; - case AF_INET6 : - dnsMark = MARK_HAVE_V6; - break; - } - break; - default : - break; - } - } - - _dns_callback(sdRef, flags, errorCode, dnsMark, dnsAddress, context); - - if (dnsAddress != NULL) { - CFRelease(dnsAddress); - } - - return; -} - - -static CFStringRef -_dns_copy_domain_name(const uint8_t *rdata, uint16_t rdlen) -{ - CFMutableStringRef domain; - const uint8_t *label; - uint8_t label_len; - - domain = CFStringCreateMutable(NULL, 0); - - label = rdata; - label_len = *(label++); - while (label_len != 0) { - while (label_len-- > 0) { - uint8_t byte = *label++; - - if ((byte == '.') || (byte == '\\')) { - // if escape needed - CFStringAppendFormat(domain, NULL, CFSTR("\\%c"), byte); - } else if (byte <= ' ') { - CFStringAppendFormat(domain, NULL, CFSTR("\\%c%c%c"), - '0' + (byte / 100), - '0' + ((byte / 10) % 10), - '0' + (byte % 10)); - } else { - CFStringAppendFormat(domain, NULL, CFSTR("%c"), byte); - } - } - - label_len = *(label++); - if (label_len != 0) { - CFStringAppendFormat(domain, NULL, CFSTR(".")); - } - } - - return domain; -} - - -static void -_dns_queryrecord_callback(DNSServiceRef sdRef, - DNSServiceFlags flags, - uint32_t interfaceIndex, - DNSServiceErrorType errorCode, - const char *fullname, - uint16_t rrtype, - uint16_t rrclass, - uint16_t rdlen, - const void *rdata, - uint32_t ttl, - void *context) -{ - _dns_mark_t dnsMark = MARK_NONE; - CFStringRef dnsPTRName = NULL; - SCNetworkReachabilityRef target = (SCNetworkReachabilityRef)context; - SCNetworkReachabilityPrivateRef targetPrivate = (SCNetworkReachabilityPrivateRef)target; - - // for now, we only support using DNSServiceQueryRecord for PTR queries - assert(targetPrivate->type == reachabilityTypePTR); - - if (rdata != NULL) { - switch (errorCode) { - case kDNSServiceErr_NoError : - if (rrtype == kDNSServiceType_PTR) { - dnsPTRName = _dns_copy_domain_name(rdata, rdlen); - } - // ... and fall through - case kDNSServiceErr_NoSuchRecord : - dnsMark = MARK_HAVE_PTR; - break; - default : - break; - } - } - - _dns_callback(sdRef, flags, errorCode, dnsMark, dnsPTRName, context); - - if (dnsPTRName != NULL) { - CFRelease(dnsPTRName); - } - - return; -} - - -static Boolean -enqueueDNSQuery(SCNetworkReachabilityRef target) -{ - SCNetworkReachabilityPrivateRef targetPrivate = (SCNetworkReachabilityPrivateRef)target; - - MUTEX_ASSERT_HELD(&targetPrivate->lock); - - // clear DNS flags, mark the query active - targetPrivate->dnsFlags = 0; - targetPrivate->dnsActive = TRUE; - - // track the DNS resolution time - __mark_operation_start(&targetPrivate->dnsQueryStart, &targetPrivate->dnsQueryEnd); - - CFRetain(target); - dispatch_async(_dns_queue(), ^{ - DNSServiceErrorType err; - const char *fcn = "???"; - DNSServiceRef sdRef = NULL; - - if (targetPrivate->dnsTarget != NULL) { - // if already running - CFRelease(target); - return; - } - - // if needed, start interacting with "mDNSResponder" - if (dnsMain == NULL) { - err = DNSServiceCreateConnection(&dnsMain); - if (err != kDNSServiceErr_NoError) { - SCLog(TRUE, LOG_ERR, - CFSTR("%sDNSServiceCreateConnection(&dnsMain) failed, error = %d"), - targetPrivate->log_prefix, - err); - goto done; - } - - err = DNSServiceSetDispatchQueue(dnsMain, _dns_queue()); - if (err != kDNSServiceErr_NoError) { - SCLog(TRUE, LOG_ERR, - CFSTR("%sDNSServiceSetDispatchQueue() failed, error = %d"), - targetPrivate->log_prefix, - err); - DNSServiceRefDeallocate(dnsMain); - dnsMain = NULL; - dnsGeneration++; - goto done; - } - } - - // start a query for this target - sdRef = dnsMain; - - switch (targetPrivate->type) { - case reachabilityTypeName : - fcn = "DNSServiceGetAddrInfo"; - err = DNSServiceGetAddrInfo(&sdRef, // sdRef - kDNSServiceFlagsReturnIntermediates // flags - | kDNSServiceFlagsShareConnection - | kDNSServiceFlagsSuppressUnusable - | kDNSServiceFlagsTimeout, - targetPrivate->if_index, // interfaceIndex - 0, // protocol - targetPrivate->name, // hostname - _dns_getaddrinfo_callback, // callback - (void *)target); // context - break; - case reachabilityTypePTR : - fcn = "DNSServiceQueryRecord"; - err = DNSServiceQueryRecord(&sdRef, // sdRef - kDNSServiceFlagsReturnIntermediates // flags - | kDNSServiceFlagsShareConnection - | kDNSServiceFlagsSuppressUnusable - | kDNSServiceFlagsTimeout, - targetPrivate->if_index, // interfaceIndex - targetPrivate->name, // fullname - kDNSServiceType_PTR, // rrtype - kDNSServiceClass_IN, // rrclass - _dns_queryrecord_callback, // callback - (void *)target); // context - break; - default : - err = kDNSServiceErr_Unknown; - break; - } - - switch (err) { - case kDNSServiceErr_NoError : - dnsCount++; - break; - - default : - SCLog(TRUE, LOG_ERR, - CFSTR("%s%s() failed, error = %d (%d)"), - targetPrivate->log_prefix, - fcn, - err, - dnsCount); - // fall through - - case kDNSServiceErr_BadParam : - if (dnsCount == 0) { - // if this was the first request - DNSServiceRefDeallocate(dnsMain); - dnsMain = NULL; - dnsGeneration++; - } - sdRef = NULL; - break; - } - - done : - - MUTEX_LOCK(&targetPrivate->lock); - - if (err == kDNSServiceErr_NoError) { - targetPrivate->dnsGeneration = dnsGeneration; - targetPrivate->dnsTarget = sdRef; - } else { - targetPrivate->dnsActive = FALSE; - - // queue up the returned error - dispatch_async(_dns_queue(), ^{ - _dns_callback(NULL, // sdRef - 0, // flags - err, // errorCode - MARK_ERROR, // dnsMark - NULL, // dnsAddress - (void *)target); // context - CFRelease(target); - }); - } - - MUTEX_UNLOCK(&targetPrivate->lock); - - return; - }); - - return TRUE; -} - - -static void -dequeueDNSQuery(SCNetworkReachabilityRef target) -{ - DNSServiceRef sdRef; - SCNetworkReachabilityPrivateRef targetPrivate = (SCNetworkReachabilityPrivateRef)target; - - MUTEX_ASSERT_HELD(&targetPrivate->lock); - - // terminate the [target] [m]DNS query - sdRef = targetPrivate->dnsTarget; - targetPrivate->dnsTarget = NULL; - - // mark the query NOT active - targetPrivate->dnsActive = FALSE; - - // don't do anything if the sdRef is not valid - if (sdRef != NULL) { - int generation; - - generation = targetPrivate->dnsGeneration; - dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 3LL * NSEC_PER_SEC), - _dns_queue(), - ^{ - if (generation == dnsGeneration) { - // if we're pointing to the same DNSService - // generation as the main/active session - // deallocate per-target query - DNSServiceRefDeallocate(sdRef); - dnsCount--; - if (dnsCount == 0) { - // if no more queries active - DNSServiceRefDeallocate(dnsMain); - dnsMain = NULL; - dnsGeneration++; - } - } - - CFRelease(target); - }); - } - - if (targetPrivate->dnsAddresses != NULL) { - CFRelease(targetPrivate->dnsAddresses); - targetPrivate->dnsAddresses = NULL; - } - targetPrivate->dnsError = NETDB_SUCCESS; - - return; -} - - -#pragma mark - -#pragma mark Synchronous DNS query support - - -#define SYNC_DNS_QUERY_TIMEOUT_NSEC 35 * NSEC_PER_SEC // 35s - - -static void -sync_DNS_query_callback(SCNetworkReachabilityRef clone, - SCNetworkReachabilityFlags cloneFlags, - void *info) -{ - dispatch_semaphore_t s = (dispatch_semaphore_t)info; - - dispatch_semaphore_signal(s); - return; -} - - -static void -sync_DNS_query(SCNetworkReachabilityRef target) -{ - SCNetworkReachabilityRef clone; - SCNetworkReachabilityPrivateRef clonePrivate; - SCNetworkReachabilityContext context = { 0, NULL, NULL, NULL, NULL }; - dispatch_queue_t q; - long ret; - dispatch_semaphore_t s; - SCNetworkReachabilityPrivateRef targetPrivate = (SCNetworkReachabilityPrivateRef)target; - - clone = __SCNetworkReachabilityCreateCopy(target); - if (clone == NULL) { - return; - } - clonePrivate = (SCNetworkReachabilityPrivateRef)clone; - - q = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0); - s = dispatch_semaphore_create(0); - - // start async query - context.info = (void *)s; - SCNetworkReachabilitySetCallback(clone, sync_DNS_query_callback, &context); - SCNetworkReachabilitySetDispatchQueue(clone, q); - - // wait for reply (or timeout) - ret = dispatch_semaphore_wait(s, dispatch_time(DISPATCH_TIME_NOW, - SYNC_DNS_QUERY_TIMEOUT_NSEC)); - if (ret != 0) { - dispatch_sync(_dns_queue(), ^{ - // mark as both a timeout *and* an error - _dns_mark(clone, MARK_TIMEOUT); - _dns_mark(clone, MARK_ERROR); - - __mark_operation_end(clone, - FALSE, // if successful query - dns_query_mdns_timeout, // [m]DNS query - &clonePrivate->dnsQueryStart, // start time - &clonePrivate->dnsQueryEnd); // end time - - MUTEX_LOCK(&clonePrivate->lock); - - // update target info with what's available - if (clonePrivate->resolvedAddresses != NULL) { - CFRelease(clonePrivate->resolvedAddresses); - clonePrivate->resolvedAddresses = NULL; - } - if ((clonePrivate->dnsAddresses != NULL) && - isA_CFArray(clonePrivate->dnsAddresses) && - (CFArrayGetCount(clonePrivate->dnsAddresses) > 0)) { - clonePrivate->resolvedAddresses = CFArrayCreateMutableCopy(NULL, - 0, - clonePrivate->dnsAddresses); - } - if (clonePrivate->resolvedAddresses != NULL) { - // if timeout w/partial results - clonePrivate->resolvedError = NETDB_SUCCESS; - } else { - // if timeout w/no results - clonePrivate->resolvedAddresses = CFRetain(kCFNull); - clonePrivate->resolvedError = EAI_NONAME; - } - - MUTEX_UNLOCK(&clonePrivate->lock); - }); - } - - // cancel request - SCNetworkReachabilitySetDispatchQueue(clone, NULL); - SCNetworkReachabilitySetCallback(clone, NULL, NULL); - - // transfer reply - if (clonePrivate->resolvedAddresses != NULL) CFRetain(clonePrivate->resolvedAddresses); - if (targetPrivate->resolvedAddresses != NULL) CFRelease(targetPrivate->resolvedAddresses); - targetPrivate->resolvedAddresses = clonePrivate->resolvedAddresses; - targetPrivate->resolvedError = clonePrivate->resolvedError; - targetPrivate->resolverFlags = clonePrivate->resolverFlags; - targetPrivate->cycle = clonePrivate->cycle; - targetPrivate->dnsFlags = clonePrivate->dnsFlags; - memcpy(&targetPrivate->info, &clonePrivate->info, sizeof(ReachabilityInfo)); - memcpy(&targetPrivate->last_notify, &clonePrivate->last_notify, sizeof(ReachabilityInfo)); - - CFRelease(clone); - dispatch_release(s); - - return; -} - - -#pragma mark - -#pragma mark Network Information support - - -// Note: protected by _hn_target_queue() -static int network_changed_token; -static Boolean network_changed_token_valid = FALSE; - - -/* - * nwi_refresh_handler - * - * Called to notify/update network changed events - * - should be exec'd on the _hn_changes_queue() - */ -static void -nwi_refresh_handler() -{ - CFArrayRef changes; - CFStringRef key; - __block SCDynamicStoreRef store = NULL; - - dispatch_sync(_hn_target_queue(), ^{ - if (network_changed_token_valid && (hn_store != NULL)) { - store = CFRetain(hn_store); - } - }); - - if (store == NULL) { - return; - } - - // Fake a network change. - key = SCDynamicStoreKeyCreateNetworkGlobalEntity(NULL, - kSCDynamicStoreDomainState, - kSCEntNetIPv4); - changes = CFArrayCreate(NULL, (const void **)&key, 1, &kCFTypeArrayCallBacks); - __SCNetworkReachabilityHandleChanges(store, changes, NULL); - CFRelease(changes); - CFRelease(key); - - CFRelease(store); - return; -} - - -/* - * nwi_refresh_enable - * - * Called to monitor for network changes. - * - caller must be running on the _hn_target_queue() - * - passed in queue should be _hn_changes_queue() - */ -static Boolean -nwi_refresh_enable(dispatch_queue_t q) -{ - uint32_t status; - - status = notify_register_dispatch(_SC_NOTIFY_NETWORK_CHANGE_NWI, // trailing nwi_state_get_notify_key() - &network_changed_token, - q, - ^(int token){ - nwi_refresh_handler(); - }); - if (status != NOTIFY_STATUS_OK) { - SCLog(TRUE, LOG_INFO, CFSTR("notify_register_dispatch() failed for network changes, status=%u"), status); - return FALSE; - } - - network_changed_token_valid = TRUE; - - return TRUE; -} - - -/* - * nwi_refresh_disable - * - * Called to stop monitoring for network changes - * - caller must be running on the _hn_target_queue() - */ -static void -nwi_refresh_disable() -{ - if (network_changed_token_valid) { - (void)notify_cancel(network_changed_token); - network_changed_token_valid = FALSE; - } - - return; -} - - -#pragma mark - -#pragma mark Sleep/wake support - - -#if !TARGET_OS_IPHONE - -// Note: protected by _hn_target_queue() -static IOPMConnection power_changed_connection = NULL; -static const CFStringRef power_changed_key = CFSTR("*** EARLY WAKE ***"); - - -/* - * power_refresh_handler - * - * Called to notify/update power capability changed events - * - should be exec'd on the _hn_changes_queue() - */ -static void -power_refresh_handler(void *param, - IOPMConnection connection, - IOPMConnectionMessageToken token, - IOPMSystemPowerStateCapabilities capabilities) -{ - Boolean change; - IOReturn ret; - __block SCDynamicStoreRef store = NULL; - - dispatch_sync(_hn_target_queue(), ^{ - if ((power_changed_connection != NULL) && (hn_store != NULL)) { - store = CFRetain(hn_store); - } - }); - - if (store == NULL) { - return; - } - - // check for [relevant] changes - change = ((power_capabilities ^ capabilities) & POWER_CAPABILITIES_NETWORK) != 0; - - // update capabilities - power_capabilities = capabilities; - - if (change) { - CFArrayRef changes; - - // fake a network change. - changes = CFArrayCreate(NULL, (const void **)&power_changed_key, 1, &kCFTypeArrayCallBacks); - __SCNetworkReachabilityHandleChanges(store, changes, NULL); - CFRelease(changes); - } - - ret = IOPMConnectionAcknowledgeEvent(connection, token); - if (ret != kIOReturnSuccess) { - SCLog(TRUE, LOG_ERR, CFSTR("IOPMConnectionAcknowledgeEvent failed, 0x%08x"), ret); - } - - CFRelease(store); - return; -} - - -/* - * power_refresh_enable - * - * Called to monitor power changes. - * - caller must be running on the _hn_target_queue() - * - passed in queue should be _hn_changes_queue() - */ -static Boolean -power_refresh_enable(dispatch_queue_t q) -{ - IOPMConnection connection = NULL; - IOReturn ret; - - ret = IOPMConnectionCreate(CFSTR("com.apple.SCNetworkReachability"), - kIOPMEarlyWakeNotification | kIOPMSleepWakeInterest, - &connection); - if (ret != kIOReturnSuccess) { - SCLog(TRUE, LOG_ERR, CFSTR("IOPMConnectionCreate failed, 0x%08x"), ret); - goto failed; - } - - ret = IOPMConnectionSetNotification(connection, NULL, power_refresh_handler); - if (ret != kIOReturnSuccess) { - SCLog(TRUE, LOG_ERR, CFSTR("IOPMConnectionSetNotification failed, 0x%08x"), ret); - goto failed; - } - - power_changed_connection = connection; - IOPMConnectionSetDispatchQueue(connection, q); - power_capabilities = IOPMConnectionGetSystemCapabilities(); - - return TRUE; - - failed: - - if (connection != NULL) { - IOPMConnectionRelease(connection); - } - - return FALSE; -} - - -static void -power_refresh_disable() -{ - if (power_changed_connection != NULL) { - IOPMConnectionSetDispatchQueue(power_changed_connection, NULL); - IOPMConnectionRelease(power_changed_connection); - power_changed_connection = NULL; - } - - return; -} - -#endif // !TARGET_OS_IPHONE - - - - - - -#pragma mark - -#pragma mark OnDemand - - -SCNetworkServiceRef -SCNetworkReachabilityCopyOnDemandService(SCNetworkReachabilityRef target, - CFDictionaryRef *userOptions) -{ - SCNetworkServiceRef service = NULL; - SCNetworkReachabilityPrivateRef targetPrivate = (SCNetworkReachabilityPrivateRef)target; - - if (!isA_SCNetworkReachability(target)) { - _SCErrorSet(kSCStatusInvalidArgument); - return NULL; - } - - if (targetPrivate->onDemandServiceID != NULL) { - service = _SCNetworkServiceCopyActive(NULL, targetPrivate->onDemandServiceID); - } - - if (userOptions != NULL) { - if (targetPrivate->onDemandName != NULL) { - *userOptions = CFDictionaryCreateMutable(NULL, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); - CFDictionarySetValue((CFMutableDictionaryRef)*userOptions, kSCNetworkConnectionSelectionOptionOnDemandHostName, targetPrivate->onDemandName); - } else { - *userOptions = NULL; - } - } - - return service; -} - - - - -static void -__SCNetworkReachabilityOnDemandCheckCallback(SCNetworkReachabilityRef onDemandServer, - SCNetworkReachabilityFlags onDemandFlags, - void *info) -{ - SCNetworkReachabilityRef target = (SCNetworkReachabilityRef)info; - SCNetworkReachabilityPrivateRef targetPrivate = (SCNetworkReachabilityPrivateRef)target; - - MUTEX_LOCK(&targetPrivate->lock); - - if (!targetPrivate->scheduled) { - // if not currently scheduled - MUTEX_UNLOCK(&targetPrivate->lock); - return; - } - - SCLog(_sc_debug, LOG_INFO, CFSTR("%sOnDemand \"server\" status changed (now 0x%08x)"), - targetPrivate->log_prefix, - onDemandFlags); - - if (targetPrivate->type == reachabilityTypeName) { - // make sure that we resolve the name again - targetPrivate->needResolve = TRUE; - } - - __SCNetworkReachabilityUpdate(target); - - MUTEX_UNLOCK(&targetPrivate->lock); - - return; -} - - -static Boolean -__SCNetworkReachabilityOnDemandCheck(ReachabilityStoreInfoRef store_info, - SCNetworkReachabilityRef target, - Boolean onDemandRetry, - SCNetworkReachabilityFlags *flags) -{ - SCNetworkConnectionRef connection = NULL; - SCNetworkConnectionType connectionType = kSCNetworkConnectionTypeUnknown; - Boolean isAppLayerVPN = FALSE; - Boolean isOnDemandService = FALSE; - Boolean ok = FALSE; - CFStringRef onDemandRemoteAddress = NULL; - CFStringRef onDemandServiceID = NULL; - SCNetworkConnectionStatus onDemandStatus = kSCNetworkConnectionInvalid; - CFMutableDictionaryRef selectOptions = NULL; - Boolean success = FALSE; - SCNetworkReachabilityPrivateRef targetPrivate = (SCNetworkReachabilityPrivateRef)target; - - MUTEX_ASSERT_HELD(&targetPrivate->lock); - - if (targetPrivate->onDemandName == NULL) { - targetPrivate->onDemandName = CFStringCreateWithCString(NULL, targetPrivate->name, kCFStringEncodingUTF8); - } - - /* - * check if an OnDemand VPN configuration matches the name. - */ - - connection = SCNetworkConnectionCreate(kCFAllocatorDefault, NULL, NULL); - if (connection == NULL) { - goto done; - } - - /* set select options */ - selectOptions = CFDictionaryCreateMutable(kCFAllocatorDefault, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); - if (selectOptions == NULL) { - goto done; - } - - CFDictionaryAddValue(selectOptions, kSCNetworkConnectionSelectionOptionOnDemandHostName, targetPrivate->onDemandName); - CFDictionaryAddValue(selectOptions, kSCNetworkConnectionSelectionOptionOnDemandRetry, onDemandRetry ? kCFBooleanTrue : kCFBooleanFalse); - CFDictionaryAddValue(selectOptions, kSCNetworkConnectionSelectionOptionNoUserPrefs, kCFBooleanTrue); - - /* select service. May be On Demand or App Layer VPN */ - if (!SCNetworkConnectionSelectServiceWithOptions(connection, selectOptions)) { - goto done; - } - - /* get reachability flags (of VPN server) */ - (void) SCNetworkConnectionGetReachabilityInfo(connection, flags, NULL); - - connectionType = SCNetworkConnectionGetType(connection); - if (connectionType == kSCNetworkConnectionTypeAppLayerVPN) { - isAppLayerVPN = TRUE; - } - - /* get on-demand info */ - onDemandServiceID = SCNetworkConnectionCopyServiceID(connection); - if (SCNetworkConnectionCopyOnDemandInfo(connection, &onDemandRemoteAddress, &onDemandStatus)) { - if (onDemandRemoteAddress != NULL) { - isOnDemandService = TRUE; - ok = TRUE; - } - } - - /* handle non-OnDemand App Layer VPN */ - if (isAppLayerVPN && !isOnDemandService) { - SCLog(_sc_debug, LOG_INFO, CFSTR("%s status * = 0x%08x (App Layer VPN)"), - targetPrivate->log_prefix, - *flags); - if (*flags & kSCNetworkReachabilityFlagsReachable) { - // if VPN "server" is reachable - - if (!(*flags & kSCNetworkReachabilityFlagsTransientConnection)) { - // start w/clean flags if not already layered on a transient network - *flags = kSCNetworkReachabilityFlagsReachable; - } - - *flags |= kSCNetworkReachabilityFlagsTransientConnection; - if (onDemandStatus != kSCNetworkConnectionConnected) { - *flags |= kSCNetworkReachabilityFlagsConnectionRequired; - } - - SCLog(_sc_debug, LOG_INFO, CFSTR("%s status = isReachable%s"), - (onDemandStatus != kSCNetworkConnectionConnected) - ? " (after App Layer connect)" : "", - targetPrivate->log_prefix); - } - - success = TRUE; - goto done; - } - - if (!_SC_CFEqual(targetPrivate->onDemandRemoteAddress, onDemandRemoteAddress) || - !_SC_CFEqual(targetPrivate->onDemandServiceID, onDemandServiceID)) { - if (targetPrivate->onDemandRemoteAddress != NULL) { - CFRelease(targetPrivate->onDemandRemoteAddress); - targetPrivate->onDemandRemoteAddress = NULL; - } - - if (targetPrivate->onDemandServer != NULL) { - SCNetworkReachabilitySetCallback(targetPrivate->onDemandServer, NULL, NULL); - if (targetPrivate->dispatchQueue != NULL) { - // unschedule - __SCNetworkReachabilityUnscheduleFromRunLoop(targetPrivate->onDemandServer, NULL, NULL, TRUE); - } else if (targetPrivate->rls != NULL) { - CFIndex i; - CFIndex n; - - // unschedule - n = CFArrayGetCount(targetPrivate->rlList); - for (i = 0; i < n; i += 3) { - CFRunLoopRef rl = (CFRunLoopRef)CFArrayGetValueAtIndex(targetPrivate->rlList, i+1); - CFStringRef rlMode = (CFStringRef) CFArrayGetValueAtIndex(targetPrivate->rlList, i+2); - - __SCNetworkReachabilityUnscheduleFromRunLoop(targetPrivate->onDemandServer, rl, rlMode, TRUE); - } - } - - CFRelease(targetPrivate->onDemandServer); - targetPrivate->onDemandServer = NULL; - } - - if (targetPrivate->onDemandServiceID != NULL) { - CFRelease(targetPrivate->onDemandServiceID); - targetPrivate->onDemandServiceID = NULL; - } - } - - if (ok) { - if (onDemandStatus != kSCNetworkConnectionConnected) { - /* - * if we have a VPN configuration matching the name *and* we need to - * bring the VPN up. Combine our flags with those of the VPN server. - */ - if (targetPrivate->onDemandServer == NULL) { - SCNetworkReachabilityPrivateRef demandPrivate; - CFMutableDictionaryRef options; - - options = CFDictionaryCreateMutable(NULL, - 0, - &kCFTypeDictionaryKeyCallBacks, - &kCFTypeDictionaryValueCallBacks); - CFDictionarySetValue(options, kSCNetworkReachabilityOptionNodeName, onDemandRemoteAddress); - CFDictionarySetValue(options, kSCNetworkReachabilityOptionConnectionOnDemandBypass, kCFBooleanTrue); - if (targetPrivate->serverBypass) { - CFDictionarySetValue(options, kSCNetworkReachabilityOptionServerBypass, kCFBooleanTrue); - } - targetPrivate->onDemandServer = SCNetworkReachabilityCreateWithOptions(NULL, options); - CFRelease(options); - - // indent OnDemand target - demandPrivate = (SCNetworkReachabilityPrivateRef)targetPrivate->onDemandServer; - strlcat(demandPrivate->log_prefix, ".... ", sizeof(demandPrivate->log_prefix)); - - if (targetPrivate->scheduled) { - SCNetworkReachabilityContext context = { 0, NULL, CFRetain, CFRelease, CFCopyDescription }; - - context.info = (void *)target; - SCNetworkReachabilitySetCallback(targetPrivate->onDemandServer, - __SCNetworkReachabilityOnDemandCheckCallback, - &context); - - // schedule server reachability to match that of the target - if (targetPrivate->dispatchQueue != NULL) { - __SCNetworkReachabilityScheduleWithRunLoop(targetPrivate->onDemandServer, NULL, NULL, targetPrivate->dispatchQueue, TRUE); - } else { - CFIndex i; - CFIndex n; - - n = CFArrayGetCount(targetPrivate->rlList); - for (i = 0; i < n; i += 3) { - CFRunLoopRef rl = (CFRunLoopRef)CFArrayGetValueAtIndex(targetPrivate->rlList, i+1); - CFStringRef rlMode = (CFStringRef) CFArrayGetValueAtIndex(targetPrivate->rlList, i+2); - - __SCNetworkReachabilityScheduleWithRunLoop(targetPrivate->onDemandServer, rl, rlMode, NULL, TRUE); - } - } - } - } - - SCLog(_sc_debug, LOG_INFO, CFSTR("%s status * = 0x%08x"), - targetPrivate->log_prefix, - *flags); - - - if ((*flags & kSCNetworkReachabilityFlagsReachable) && !(*flags & kSCNetworkReachabilityFlagsConnectionRequired)) { - // if VPN "server" is [still] reachable - - if (!(*flags & kSCNetworkReachabilityFlagsTransientConnection)) { - // start w/clean flags if not already layered on a transient network - *flags = kSCNetworkReachabilityFlagsReachable; - } - - *flags |= kSCNetworkReachabilityFlagsTransientConnection; - *flags |= kSCNetworkReachabilityFlagsConnectionRequired; - *flags |= kSCNetworkReachabilityFlagsConnectionOnDemand; - - // set 'InterventionRequired' if the OnDemand connection is paused - if (SCNetworkConnectionIsOnDemandSuspended(connection)) { - *flags |= kSCNetworkReachabilityFlagsInterventionRequired; - } - - if (_sc_debug) { - SCLog(TRUE, LOG_INFO, CFSTR("%s service * = %@"), - targetPrivate->log_prefix, - onDemandServiceID); - SCLog(TRUE, LOG_INFO, CFSTR("%s status = isReachable (after OnDemand connect)"), - targetPrivate->log_prefix); - } - - success = TRUE; - } - } - - if (onDemandRemoteAddress != NULL) { - if (targetPrivate->onDemandRemoteAddress == NULL) { - targetPrivate->onDemandRemoteAddress = CFRetain(onDemandRemoteAddress); - } - } - - if (onDemandServiceID != NULL) { - if (targetPrivate->onDemandServiceID == NULL) { - targetPrivate->onDemandServiceID = CFRetain(onDemandServiceID); - } - } - } - - done: - - if (onDemandServiceID != NULL) { - CFRelease(onDemandServiceID); - } - if (onDemandRemoteAddress != NULL) { - CFRelease(onDemandRemoteAddress); - } - if (connection != NULL) { - CFRelease(connection); - } - if (selectOptions != NULL) { - CFRelease(selectOptions); - } - return success; -} - - -/* - * OnDemand configuration handling - * - * Notes : - * - * 1. We have a "contract" with mDNSResponder that for EVERY network - * or DNS configuration change that should warrant our [re-]starting - * a query, mDNSResponder will acknowledge the latest DNS configuration. - * - * 2. IPMonitor also posts a notification AFTER every network or DNS - * configuration change. - * - * 3. We use IPMonitor's "trailing edge" as a signal to restart any - * by-name queries. - */ - - -// Note: protected by _hn_target_queue() -static int onDemand_refresh_token; -static Boolean onDemand_refresh_token_valid = FALSE; - - -/* - * onDemand_refresh_handler - * - * Called to notify/update all SCNetworkReachability targets of - * OnDemand changes. - * - should be exec'd on the _hn_changes_queue() - */ -static void -onDemand_refresh_handler() -{ - CFArrayRef changes; - CFStringRef key; - __block SCDynamicStoreRef store = NULL; - - dispatch_sync(_hn_target_queue(), ^{ - if (onDemand_refresh_token_valid && (hn_store != NULL)) { - store = CFRetain(hn_store); - } - }); - - if (store == NULL) { - return; - } - - key = SCDynamicStoreKeyCreateNetworkGlobalEntity(NULL, - kSCDynamicStoreDomainState, - kSCEntNetOnDemand); - changes = CFArrayCreate(NULL, (const void **)&key, 1, &kCFTypeArrayCallBacks); - __SCNetworkReachabilityHandleChanges(store, changes, NULL); - CFRelease(changes); - CFRelease(key); - - CFRelease(store); - return; -} - - -/* - * onDemand_refresh_enable - * - * Called to monitor for OnDemand changes. - * - caller must be running on the _hn_target_queue() - */ -static Boolean -onDemand_refresh_enable(dispatch_queue_t q) -{ - uint32_t status; - - status = notify_register_dispatch(kSCNETWORKCONNECTION_ONDEMAND_NOTIFY_KEY, - &onDemand_refresh_token, - q, - ^(int token){ - onDemand_refresh_handler(); - }); - if (status != NOTIFY_STATUS_OK) { - SCLog(TRUE, LOG_INFO, CFSTR("notify_register_dispatch() failed, status=%u"), status); - return FALSE; - } - - onDemand_refresh_token_valid = TRUE; - - return TRUE; -} - - -/* - * onDemand_refresh_disable - * - * Called to stop monitoring for OnDemand changes - * - caller must be running on the _hn_target_queue() - */ -static void -onDemand_refresh_disable() -{ - (void)notify_cancel(onDemand_refresh_token); - onDemand_refresh_token_valid = FALSE; - return; -} - - - - -#pragma mark - -#pragma mark Reachability Flags - - -static Boolean -__SCNetworkReachabilityGetFlags(ReachabilityStoreInfoRef store_info, - SCNetworkReachabilityRef target, - ReachabilityInfo *reach_info, - Boolean async) -{ - CFMutableArrayRef addresses = NULL; - SCNetworkReachabilityPrivateRef targetPrivate = (SCNetworkReachabilityPrivateRef)target; - ReachabilityInfo my_info = NOT_REACHABLE; - Boolean ok = TRUE; - - MUTEX_ASSERT_HELD(&targetPrivate->lock); - - _reach_set(reach_info, &NOT_REACHABLE, reach_info->cycle, targetPrivate->if_index, targetPrivate->if_name); - - if (!isA_SCNetworkReachability(target)) { - _SCErrorSet(kSCStatusInvalidArgument); - return FALSE; - } - -#if TARGET_OS_IPHONE - if (isReachabilityTypeName(targetPrivate->type) && - !async && - pthread_is_threaded_np() && - pthread_main_np()) { - SCLog(TRUE, LOG_WARNING, CFSTR("Warning: sync SCNetworkReachability (by-name) query on main thread")); - } -#endif // TARGET_OS_IPHONE - - if (!targetPrivate->serverBypass) { - if (!targetPrivate->serverActive) { - - ok = __SCNetworkReachabilityServer_targetAdd(target); - if (!ok) { - targetPrivate->serverBypass = TRUE; - } - } - - if (targetPrivate->serverActive) { - ok = __SCNetworkReachabilityServer_targetStatus(target); - if (!ok) { - SCLog(TRUE, LOG_DEBUG, - CFSTR("__SCNetworkReachabilityGetFlags _targetStatus() failed")); - _SCErrorSet(kSCStatusFailed); - goto done; - } - - targetPrivate->cycle = targetPrivate->serverInfo.cycle; - _reach_set(&my_info, - &targetPrivate->serverInfo, - targetPrivate->serverInfo.cycle, - targetPrivate->if_index, - targetPrivate->if_name); - goto done; - } - } - - - switch (targetPrivate->type) { - case reachabilityTypeAddress : - case reachabilityTypeAddressPair : { - /* - * Check "local" address - */ - if (targetPrivate->localAddress != NULL) { - /* - * Check "local" address - */ - ok = checkAddress(store_info, - targetPrivate->localAddress, - targetPrivate->if_index, - &my_info, - targetPrivate->log_prefix); - if (!ok) { - goto done2; /* not today */ - } - - if (!(my_info.flags & kSCNetworkReachabilityFlagsIsLocalAddress)) { - goto done2; /* not reachable, non-"local" address */ - } - } - - /* - * Check "remote" address - */ - if ((targetPrivate->remoteAddress != NULL) && - (targetPrivate->localAddress != targetPrivate->remoteAddress)) { - /* - * in cases where we have different "local" and "remote" addresses - * we need to re-initialize the to-be-returned flags. - */ - my_info = NOT_REACHABLE; - - /* - * Check "remote" address - */ - ok = checkAddress(store_info, - targetPrivate->remoteAddress, - targetPrivate->if_index, - &my_info, - targetPrivate->log_prefix); - if (!ok) { - goto done2; /* not today */ - } - } - - break; - - } - - case reachabilityTypeName : - case reachabilityTypePTR : { - int error; - int ns_dns_config = -1; - SCNetworkReachabilityFlags ns_flags = 0; - uint32_t ns_if_index = 0; - - addresses = (CFMutableArrayRef)SCNetworkReachabilityCopyResolvedAddress(target, &error); - if ((addresses != NULL) || (error != NETDB_SUCCESS)) { - /* if resolved or an error had been detected */ - if (!async) { - /* if not an async request */ - goto checkResolvedAddresses; - } else if (targetPrivate->dnsActive) { - /* if [m]DNS query active */ - goto checkResolvedAddresses; - } else if (!targetPrivate->needResolve) { - /* - * if this is an async request (i.e. someone is watching the reachability - * of this target), if no query active, and if no query is needed - */ - goto checkResolvedAddresses; - } - } - - if (!targetPrivate->onDemandBypass) { - Boolean onDemand; - SCNetworkReachabilityFlags onDemandFlags = 0; - - /* - * before we attempt our initial DNS query, check if there is - * an OnDemand configuration that we should be using. - */ - onDemand = __SCNetworkReachabilityOnDemandCheck(store_info, target, FALSE, &onDemandFlags); - if (onDemand) { - /* if OnDemand connection is needed */ - my_info.flags = onDemandFlags; - goto done; - } - } - - targetPrivate->dnsBlocked = FALSE; - - /* update the reachability of the DNS servers */ - _SC_R_updateResolverReachability(store_info, - &ns_flags, - &targetPrivate->haveDNS, - targetPrivate->name, - targetPrivate->if_index, - &ns_if_index, - &ns_dns_config, - targetPrivate->log_prefix); - - - // save resolver reachability flags - targetPrivate->resolverFlags = ns_flags; - - if (rankReachability(ns_flags) < 2) { - /* - * if DNS servers are not (or are no longer) reachable, set - * flags based on the availability of configured (but not - * active) services. - */ - - SCLog(_sc_debug, LOG_INFO, CFSTR("%sDNS server(s) not available"), - targetPrivate->log_prefix); - - if (!targetPrivate->dnsBlocked) { - ok = checkAddress(store_info, - NULL, - targetPrivate->if_index, - &my_info, - targetPrivate->log_prefix); - if (!ok) { - SCLog(_sc_debug, LOG_INFO, CFSTR("%sNo available networks"), - targetPrivate->log_prefix); - goto done2; - } - } else { - // if not checking "available" networks - my_info.flags = ns_flags; - my_info.if_index = ns_if_index; - } - - if (async && targetPrivate->scheduled) { - /* - * return "host not found", set flags appropriately, - * and schedule notification. - */ - __SCNetworkReachabilitySetResolvedError(target, EAI_NONAME); - my_info.flags |= (targetPrivate->info.flags & kSCNetworkReachabilityFlagsFirstResolvePending); - - SCLog(_sc_debug, LOG_INFO, CFSTR("%sno DNS servers are reachable"), - targetPrivate->log_prefix); - __SCNetworkReachabilityUpdate(target); - } - - break; - } - - if (targetPrivate->resolverBypass) { - if (targetPrivate->haveDNS) { - /* - * if we are not resolving the name, and if we have - * one or more DNS resolvers, then return flags that - * reflect the reachability of the resolvers (and - * not the actual name). - */ - my_info.flags = ns_flags; - my_info.if_index = ns_if_index; - } - break; - } - - if (async) { - /* for async requests we return the last known status */ - my_info = targetPrivate->info; - - if (targetPrivate->dnsActive) { - /* if [m]DNS query active */ - if (_sc_debug && !targetPrivate->quiet) { - SCLog(TRUE, LOG_INFO, - CFSTR("%swaiting for DNS reply"), - targetPrivate->log_prefix); - } - if ((addresses != NULL) || (error != NETDB_SUCCESS)) { - /* updated reachability based on the previous reply */ - goto checkResolvedAddresses; - } - break; - } - - SCLog(_sc_debug, LOG_INFO, - CFSTR("%sstart DNS query for name = %s"), - targetPrivate->log_prefix, - targetPrivate->name); - - /* - * initiate an DNS query w/DNSServiceGetAddrInfo - */ - enqueueDNSQuery(target); - break; - } - - SCLog(_sc_debug, LOG_INFO, - CFSTR("%scheckName(%s)"), - targetPrivate->log_prefix, - targetPrivate->name); - - /* - * OK, all of the DNS name servers are available. Let's - * resolve the nodename into an address. - */ - sync_DNS_query(target); - - if (!(targetPrivate->dnsHaveTimeout && targetPrivate->dnsHaveError)) { - // if target reach info is valid - memcpy(reach_info, &targetPrivate->info, sizeof(ReachabilityInfo)); - goto done2; - } - - if (addresses != NULL) CFRelease(addresses); - addresses = (CFMutableArrayRef)SCNetworkReachabilityCopyResolvedAddress(target, &error); - - checkResolvedAddresses : - - /* - * We first assume that the requested host is NOT available. - * Then, check each address for accessibility and return the - * best status available. - */ - my_info = NOT_REACHABLE; - - if ((targetPrivate->type == reachabilityTypeName) && isA_CFArray(addresses)) { - CFIndex i; - CFIndex n = CFArrayGetCount(addresses); - struct sockaddr *sa; - - for (i = 0; i < n; i++) { - ReachabilityInfo ns_info = NOT_REACHABLE; - - sa = (struct sockaddr *)CFDataGetBytePtr(CFArrayGetValueAtIndex(addresses, i)); - - ok = checkAddress(store_info, - sa, - targetPrivate->if_index, - &ns_info, - targetPrivate->log_prefix); - if (!ok) { - goto done2; /* not today */ - } - - if (rankReachability(ns_info.flags) > rankReachability(my_info.flags)) { - /* return the best case result */ - my_info = ns_info; - if (rankReachability(my_info.flags) == 2) { - /* can't get any better than REACHABLE */ - break; - } - } - } - - if (_sc_debug) { - for (i++; i < n; i++) { - sa = (struct sockaddr *)CFDataGetBytePtr(CFArrayGetValueAtIndex(addresses, i)); - log_address("skipAddress", - sa, - targetPrivate->if_index, - targetPrivate->log_prefix); - } - } - } else if ((targetPrivate->type == reachabilityTypePTR) && isA_CFArray(addresses)) { - CFIndex i; - CFIndex n = CFArrayGetCount(addresses); - - my_info = NOT_REACHABLE; - - for (i = 0; i < n; i++) { - if (i == 0) { - my_info.flags = kSCNetworkReachabilityFlagsReachable; - } - - if (_sc_debug) { - CFStringRef ptrName; - - ptrName = CFArrayGetValueAtIndex(addresses, i); - SCLog(TRUE, LOG_INFO, CFSTR("%sPTR name(%@)"), - targetPrivate->log_prefix, - ptrName); - } - } - } else { - if ((error == EAI_NONAME) -#if defined(EAI_NODATA) && (EAI_NODATA != EAI_NONAME) - || (error == EAI_NODATA) -#endif - ) { - /* - * the target host name could not be resolved - */ - if (!targetPrivate->onDemandBypass) { - Boolean onDemand; - SCNetworkReachabilityFlags onDemandFlags = 0; - - /* - * our initial DNS query failed, check again to see if there - * there is an OnDemand configuration that we should be using. - */ - onDemand = __SCNetworkReachabilityOnDemandCheck(store_info, target, TRUE, &onDemandFlags); - if (onDemand) { - /* if OnDemand connection is needed */ - my_info.flags = onDemandFlags; - goto done; - } - } - - - if (!targetPrivate->haveDNS) { - /* - * No DNS servers are defined. Set flags based on - * the availability of configured (but not active) - * services. - */ - ok = checkAddress(store_info, - NULL, - targetPrivate->if_index, - &my_info, - targetPrivate->log_prefix); - if (!ok) { - goto done2; /* not today */ - } - - if ((my_info.flags & kSCNetworkReachabilityFlagsReachable) && - (my_info.flags & kSCNetworkReachabilityFlagsConnectionRequired)) { - /* - * Since we might pick up a set of DNS servers when this connection - * is established, don't reply with a "HOST NOT FOUND" error just yet. - */ - break; - } - - /* Host not found, not reachable! */ - my_info = NOT_REACHABLE; - } - } - } - - break; - } - } - - done: - - - _reach_set(reach_info, &my_info, targetPrivate->cycle, targetPrivate->if_index, targetPrivate->if_name); - - done2 : - - if (addresses != NULL) CFRelease(addresses); - return ok; -} - -int -SCNetworkReachabilityGetInterfaceIndex(SCNetworkReachabilityRef target) +SCNetworkReachabilityRef +SCNetworkReachabilityCreateWithOptions(CFAllocatorRef allocator, + CFDictionaryRef options) { - int if_index = -1; - Boolean ok = TRUE; - ReachabilityStoreInfo store_info; - SCNetworkReachabilityPrivateRef targetPrivate = (SCNetworkReachabilityPrivateRef)target; + const struct sockaddr *addr_l = NULL; + const struct sockaddr *addr_p = NULL; + const struct sockaddr *addr_r = NULL; + CFDataRef data; + CFStringRef interface = NULL; + CFStringRef nodename; + CFBooleanRef resolverBypass; + SCNetworkReachabilityRef target; + SCNetworkReachabilityPrivateRef targetPrivate; + unsigned int if_index = 0; + char if_name[IFNAMSIZ]; - if (!isA_SCNetworkReachability(target)) { + if (!isA_CFDictionary(options)) { _SCErrorSet(kSCStatusInvalidArgument); - return if_index; - } - - ReachabilityStoreInfo_init(&store_info); - - MUTEX_LOCK(&targetPrivate->lock); - - if (targetPrivate->scheduled) { - // if being watched, return the last known (and what should be current) status - goto done; - } - - - ok = __SCNetworkReachabilityGetFlags(&store_info, target, &targetPrivate->info, FALSE); - - done : - - /* Only return the if_index if the connection is reachable not for reachable connection - * required etc ... */ - if (ok && rankReachability(targetPrivate->info.flags) == 2) { - if_index = targetPrivate->info.if_index; + return NULL; } - MUTEX_UNLOCK(&targetPrivate->lock); - ReachabilityStoreInfo_free(&store_info); - return if_index; -} - - -Boolean -SCNetworkReachabilityGetFlags(SCNetworkReachabilityRef target, - SCNetworkReachabilityFlags *flags) -{ - Boolean ok = TRUE; - ReachabilityStoreInfo store_info; - SCNetworkReachabilityPrivateRef targetPrivate = (SCNetworkReachabilityPrivateRef)target; - - if (!isA_SCNetworkReachability(target)) { + nodename = CFDictionaryGetValue(options, kSCNetworkReachabilityOptionNodeName); + if ((nodename != NULL) && + (!isA_CFString(nodename) || (CFStringGetLength(nodename) == 0))) { _SCErrorSet(kSCStatusInvalidArgument); - return FALSE; + return NULL; } - - ReachabilityStoreInfo_init(&store_info); - - MUTEX_LOCK(&targetPrivate->lock); - - if (targetPrivate->scheduled) { - // if being watched, return the last known (and what should be current) status - *flags = targetPrivate->info.flags & kSCNetworkReachabilityFlagsMask; - - if (isReachabilityTypeName(targetPrivate->type) && targetPrivate->dnsNoAddressesSinceLastTimeout) { - targetPrivate->needResolve = TRUE; - ReachabilityInfo tmp_reach_info = NOT_REACHABLE; - __SCNetworkReachabilityGetFlags(&store_info, target, &tmp_reach_info, TRUE); + data = CFDictionaryGetValue(options, kSCNetworkReachabilityOptionLocalAddress); + if (data != NULL) { + if (!isA_CFData(data) || (CFDataGetLength(data) < sizeof(struct sockaddr_in))) { + _SCErrorSet(kSCStatusInvalidArgument); + return NULL; } - - goto done; - } - - - ok = __SCNetworkReachabilityGetFlags(&store_info, target, &targetPrivate->info, FALSE); - if (_sc_debug) { - SCLog(TRUE, LOG_INFO, CFSTR("%s flags = 0x%08x"), targetPrivate->log_prefix, targetPrivate->info.flags); - } - - *flags = targetPrivate->info.flags & kSCNetworkReachabilityFlagsMask; - - done : - - MUTEX_UNLOCK(&targetPrivate->lock); - ReachabilityStoreInfo_free(&store_info); - return ok; -} - - -#pragma mark - -#pragma mark Notifications - - -/* - * __SCNetworkReachabilityHandleChanges - * - * Called to process network configuration changes and determine - * if a reachability notification is warranted. - * - should be exec'd on the _hn_changes_queue() - */ -static void -__SCNetworkReachabilityHandleChanges(SCDynamicStoreRef store, - CFArrayRef changedKeys, - void *info) -{ - Boolean dnsConfigChanged = FALSE; - CFIndex i; - Boolean forcedChange = FALSE; - CFStringRef key; - Boolean match; - CFIndex nChanges; - CFIndex nGlobals = 0; - CFIndex nTargets; - Boolean neChanged = FALSE; - Boolean networkConfigChanged = FALSE; - struct timeval now; - Boolean onDemandConfigChanged = FALSE; -#if !TARGET_OS_IPHONE - Boolean powerStatusChanged = FALSE; -#endif // !TARGET_OS_IPHONE - ReachabilityStoreInfo store_info; - const void * targets_q[N_QUICK]; - const void ** targets = targets_q; - __block CFSetRef watchers = NULL; - - nChanges = CFArrayGetCount(changedKeys); - if (nChanges == 0) { - /* if no changes */ - return; + addr_l = (const struct sockaddr *)CFDataGetBytePtr(data); } - - - dispatch_sync(_hn_target_queue(), ^{ - /* grab the currently watched targets */ - if (hn_targets != NULL) { - watchers = CFSetCreateCopy(NULL, hn_targets); + data = CFDictionaryGetValue(options, kSCNetworkReachabilityOptionPTRAddress); + if (data != NULL) { + if (!isA_CFData(data) || (CFDataGetLength(data) < sizeof(struct sockaddr_in))) { + _SCErrorSet(kSCStatusInvalidArgument); + return NULL; } - }); - - nTargets = (watchers != NULL) ? CFSetGetCount(watchers) : 0; - if (nTargets == 0) { - /* if no addresses being monitored */ - goto done; - } - - /* grab the current time */ - (void)gettimeofday(&now, NULL); - -#if !TARGET_OS_IPHONE - match = CFArrayContainsValue(changedKeys, CFRangeMake(0, nChanges), power_changed_key); - if (match) { - /* handle "early" wake notification */ - nGlobals++; - powerStatusChanged = TRUE; - } -#endif // !TARGET_OS_IPHONE - - key = SCDynamicStoreKeyCreateNetworkGlobalEntity(NULL, - kSCDynamicStoreDomainState, - kSCEntNetDNS); - match = CFArrayContainsValue(changedKeys, CFRangeMake(0, nChanges), key); - CFRelease(key); - if (match) { - nGlobals++; - dnsConfigChanged = TRUE; /* the DNS server(s) have changed */ + addr_p = (const struct sockaddr *)CFDataGetBytePtr(data); } - - key = SCDynamicStoreKeyCreateNetworkGlobalEntity(NULL, - kSCDynamicStoreDomainState, - kSCEntNetOnDemand); - match = CFArrayContainsValue(changedKeys, CFRangeMake(0, nChanges), key); - CFRelease(key); - if (match) { - nGlobals++; - onDemandConfigChanged = TRUE; /* the OnDemand configuration has changed */ - - // force OnDemand configuration refresh (if SC notification arrives before BSD notify) - __SCNetworkConnectionForceOnDemandConfigurationRefresh(); + data = CFDictionaryGetValue(options, kSCNetworkReachabilityOptionRemoteAddress); + if (data != NULL) { + if (!isA_CFData(data) || (CFDataGetLength(data) < sizeof(struct sockaddr_in))) { + _SCErrorSet(kSCStatusInvalidArgument); + return NULL; + } + addr_r = (const struct sockaddr *)CFDataGetBytePtr(data); } - - - - match = CFArrayContainsValue(changedKeys, CFRangeMake(0, nChanges), SCNETWORKREACHABILITY_TRIGGER_KEY); - if (match) { - nGlobals++; - forcedChange = TRUE; /* an SCDynamicStore driven "network" change */ + interface = CFDictionaryGetValue(options, kSCNetworkReachabilityOptionInterface); + if ((interface != NULL) && + (!isA_CFString(interface) || (CFStringGetLength(interface) == 0))) { + _SCErrorSet(kSCStatusInvalidArgument); + return NULL; } - - if (nChanges > nGlobals) { - networkConfigChanged = TRUE; + resolverBypass = CFDictionaryGetValue(options, kSCNetworkReachabilityOptionResolverBypass); + if ((resolverBypass != NULL) && !isA_CFBoolean(resolverBypass)) { + _SCErrorSet(kSCStatusInvalidArgument); + return NULL; } - if (_sc_debug) { - unsigned int changes = 0; - static const char *change_strings[] = { - // with no "power" status change - "", // 00000 - "network ", // 00001 - "DNS ", // 00010 - "network and DNS ", // 00011 - "OnDemand ", // 00100 - "network and OnDemand ", // 00101 - "DNS and OnDemand ", // 00110 - "network, DNS, and OnDemand ", // 00111 - "NE ", // 01000 - "network and NE ", // 01001 - "DNS and NE ", // 01010 - "network, DNS, and NE ", // 01011 - "OnDemand and NE ", // 01100 - "network, OnDemand, and NE ", // 01101 - "DNS, OnDemand, and NE ", // 01110 - "network, DNS, OnDemand, and NE ", // 01111 -#if !TARGET_OS_IPHONE - // with "power" status change - "power", // 10000 - "network and power ", // 10001 - "DNS and power ", // 10010 - "network, DNS, and power ", // 10011 - "OnDemand and power ", // 10100 - "network, OnDemand, and power ", // 10101 - "DNS, OnDemand, and power ", // 10110 - "network, DNS, OnDemand, and power ", // 10111 - "NE and power ", // 11000 - "network, NE, and power ", // 11001 - "DNS, NE, and power ", // 11010 - "network, DNS, NE, and power ", // 11011 - "OnDemand, NE, and power ", // 11100 - "network, OnDemand, NE, and power ", // 11101 - "DNS, OnDemand, NE, and power ", // 11110 - "network, DNS, OnDemand, NE, and power ", // 11111 -#endif // !TARGET_OS_IPHONE - }; - -#if !TARGET_OS_IPHONE - #define PWR 16 - if (powerStatusChanged) { - changes |= PWR; - } -#endif // !TARGET_OS_IPHONE - - #define NE 8 - if (neChanged) { - changes |= NE; - } + if (nodename != NULL) { + const char *name; - #define VOD 4 - if (onDemandConfigChanged) { - changes |= VOD; + if ((addr_l != NULL) || (addr_r != NULL) || (addr_p != NULL)) { + // can't have both a nodename and an address + _SCErrorSet(kSCStatusInvalidArgument); + return NULL; } - #define DNS 2 - if (dnsConfigChanged) { - changes |= DNS; + name = _SC_cfstring_to_cstring(nodename, NULL, 0, kCFStringEncodingUTF8); + target = SCNetworkReachabilityCreateWithName(allocator, name); + CFAllocatorDeallocate(NULL, (void *)name); + } else if (addr_p != NULL) { + if ((addr_l != NULL) || // can't have PTR and target address + (addr_r != NULL)) { + _SCErrorSet(kSCStatusInvalidArgument); + return NULL; } - #define NET 1 - if (networkConfigChanged) { - changes |= NET; + target = __SCNetworkReachabilityCreateWithPTR(NULL, addr_p); + } else { + if ((addr_l != NULL) && (addr_r != NULL)) { + target = SCNetworkReachabilityCreateWithAddressPair(NULL, addr_l, addr_r); + } else if (addr_r != NULL) { + target = SCNetworkReachabilityCreateWithAddress(NULL, addr_r); + } else if (addr_l != NULL) { + target = SCNetworkReachabilityCreateWithAddressPair(NULL, addr_l, NULL); + } else { + _SCErrorSet(kSCStatusInvalidArgument); + return NULL; } - - SCLog(TRUE, LOG_INFO, - CFSTR("process %s%s%sconfiguration change"), - forcedChange ? "[forced] " : "", - change_strings[changes]); + } + if (target == NULL) { + return NULL; } - ReachabilityStoreInfo_init(&store_info); - - if (nTargets > (CFIndex)(sizeof(targets_q) / sizeof(CFTypeRef))) - targets = CFAllocatorAllocate(NULL, nTargets * sizeof(CFTypeRef), 0); - CFSetGetValues(watchers, targets); - for (i = 0; i < nTargets; i++) { - Boolean dnsNeedsUpdate = FALSE; - SCNetworkReachabilityRef target = targets[i]; - SCNetworkReachabilityPrivateRef targetPrivate = (SCNetworkReachabilityPrivateRef)target; - - MUTEX_LOCK(&targetPrivate->lock); - - - if (dnsConfigChanged) { - targetPrivate->last_dns = now; - } - - if (networkConfigChanged) { - targetPrivate->last_network = now; - } - -#if !TARGET_OS_IPHONE - if (powerStatusChanged) { - targetPrivate->last_power = now; - } -#endif // !TARGET_OS_IPHONE - - if (isReachabilityTypeName(targetPrivate->type)) { - Boolean dnsChanged = (dnsConfigChanged | - dnsNeedsUpdate | - onDemandConfigChanged | - neChanged); - - if (!dnsChanged) { - /* - * if the DNS configuration didn't change we still need to - * check that the DNS servers are accessible. - */ - Boolean ns_blocked = FALSE; - int ns_dns_config = -1; - SCNetworkReachabilityFlags ns_flags = 0; - uint32_t ns_if_index = 0; - Boolean ok; - - /* update the reachability of the DNS servers */ - ok = ReachabilityStoreInfo_update(&store_info, &store, AF_UNSPEC); - if (ok) { - _SC_R_updateResolverReachability(&store_info, - &ns_flags, - &targetPrivate->haveDNS, - targetPrivate->name, - targetPrivate->if_index, - &ns_if_index, - &ns_dns_config, - targetPrivate->log_prefix); - } else { - ns_flags = kSCNetworkReachabilityFlagsReachable; - dnsChanged = TRUE; - } - - - if (rankReachability(ns_flags) < 2) { - /* - * if DNS servers are not (or are no longer) reachable, set - * flags based on the availability of configured (but not - * active) services. - */ - SCLog(_sc_debug, LOG_INFO, CFSTR("%sDNS server(s) not available"), - targetPrivate->log_prefix); - dnsChanged = TRUE; - } - - if ((targetPrivate->dnsBlocked != ns_blocked) || - (targetPrivate->resolverFlags != ns_flags)) { - // if the DNS blocked or resolver reachability changed - targetPrivate->dnsBlocked = ns_blocked; - targetPrivate->resolverFlags = ns_flags; - dnsChanged = TRUE; - } - } - - if (dnsChanged) { - if (targetPrivate->dnsActive) { - // if we have an outstanding [m]DNS query - SCLog(_sc_debug, LOG_INFO, - CFSTR("%scancel [m]DNS query for name = %s"), - targetPrivate->log_prefix, - targetPrivate->name); - dequeueDNSQuery(target); - } - - /* schedule request to resolve the name again */ - targetPrivate->needResolve = TRUE; - } - } - - if (forcedChange) { - targetPrivate->cycle++; - } + targetPrivate = (SCNetworkReachabilityPrivateRef)target; - if (targetPrivate->scheduled) { - __SCNetworkReachabilityUpdate(target); + if (interface != NULL) { + if ((_SC_cfstring_to_cstring(interface, + if_name, + sizeof(if_name), + kCFStringEncodingASCII) == NULL) || + ((if_index = if_nametoindex(if_name)) == 0)) { + CFRelease(targetPrivate); + _SCErrorSet(kSCStatusInvalidArgument); + return NULL; } - - MUTEX_UNLOCK(&targetPrivate->lock); } - if (targets != targets_q) CFAllocatorDeallocate(NULL, targets); - - ReachabilityStoreInfo_free(&store_info); - - done : - - if (watchers != NULL) CFRelease(watchers); - return; -} + if (targetPrivate->parameters == NULL) { + targetPrivate->parameters = nw_parameters_create(); + } -/* - * __SCNetworkReachabilityHandleStoreChanges - * - * Called to process SCDynamicStore network configuration changes. - * - should be exec'd on the _hn_changes_queue() - */ -static void -__SCNetworkReachabilityHandleStoreChanges(SCDynamicStoreRef store, - CFArrayRef changedKeys, - void *info) -{ - nwi_state_t nwi_state; + if (if_index != 0) { + nw_interface_t interfaceObject = nw_interface_create_with_index(if_index); + nw_parameters_require_interface(targetPrivate->parameters, interfaceObject); + network_release(interfaceObject); + } - if ((CFArrayGetCount(changedKeys) == 1) && - CFArrayContainsValue(changedKeys, CFRangeMake(0, 1), SCNETWORKREACHABILITY_TRIGGER_KEY)) { - goto update; + if (resolverBypass != NULL) { + targetPrivate->resolverBypass = CFBooleanGetValue(resolverBypass); } - /* "something" [else] changed, start fresh */ - ReachabilityStoreInfo_save(NULL); + if (_sc_debug && (_sc_log > 0)) { + const char *opt = "???"; + + switch (targetPrivate->type) { + case reachabilityTypeAddress : + opt = DEBUG_REACHABILITY_TYPE_ADDRESS_OPTIONS; + break; + case reachabilityTypeAddressPair : + opt = DEBUG_REACHABILITY_TYPE_ADDRESSPAIR_OPTIONS; + break; + case reachabilityTypeName : + opt = DEBUG_REACHABILITY_TYPE_NAME_OPTIONS; + break; + case reachabilityTypePTR : + opt = DEBUG_REACHABILITY_TYPE_PTR_OPTIONS; + break; + } - nwi_state = nwi_state_copy(); - if (nwi_state != NULL) { - // if we have some networking - nwi_state_release(nwi_state); - return; + SC_log(LOG_INFO, "%s%s %@", + targetPrivate->log_prefix, + opt, + targetPrivate); } - // if no networking, use the [SC] changes to add/update - // the kSCNetworkReachabilityFlagsConnectionRequired flag - - update : - - __SCNetworkReachabilityHandleChanges(store, changedKeys, info); - return; -} - - -#if !TARGET_OS_IPHONE - -static Boolean -darkWakeNotify(SCNetworkReachabilityRef target) -{ - return FALSE; + return (SCNetworkReachabilityRef)targetPrivate; } -static Boolean -systemIsAwake(IOPMSystemPowerStateCapabilities power_capabilities) +CFTypeID +SCNetworkReachabilityGetTypeID(void) { - if ((power_capabilities & POWER_CAPABILITIES_NETWORK) != POWER_CAPABILITIES_NETWORK) { - // if we're not fully awake (from a networking point of view). - return FALSE; - } - - return TRUE; + pthread_once(&initialized, __SCNetworkReachabilityInitialize); /* initialize runtime */ + return __kSCNetworkReachabilityTypeID; } -#endif // !TARGET_OS_IPHONE - -static void -reachPerform(void *info) +CFArrayRef /* CFArray[CFData], where each CFData is a (struct sockaddr *) */ +SCNetworkReachabilityCopyResolvedAddress(SCNetworkReachabilityRef target, + int *error_num) { - void *context_info; - void (*context_release)(const void *); - unsigned int n; - ReachabilityInfo reach_info; - SCNetworkReachabilityCallBack rlsFunction; - SCNetworkReachabilityRef target = (SCNetworkReachabilityRef)info; SCNetworkReachabilityPrivateRef targetPrivate = (SCNetworkReachabilityPrivateRef)target; - n = _SC_ATOMIC_ZERO(&targetPrivate->pending); - if (_sc_debug && (n > 1)) { - SCLog(TRUE, LOG_DEBUG, - CFSTR("%sdelivering SCNetworkReachability notifications (%u)"), - targetPrivate->log_prefix, - n); + if (!isA_SCNetworkReachability(target)) { + _SCErrorSet(kSCStatusInvalidArgument); + return NULL; } - MUTEX_LOCK(&targetPrivate->lock); - - if (!targetPrivate->scheduled) { - // if no longer scheduled - SCLog(_sc_debug, LOG_DEBUG, - CFSTR("%sskipping SCNetworkReachability callback, no longer scheduled"), - targetPrivate->log_prefix); - MUTEX_UNLOCK(&targetPrivate->lock); - return; + if (!isReachabilityTypeName(targetPrivate->type)) { + _SCErrorSet(kSCStatusInvalidArgument); + return NULL; } - // capture current state - memcpy(&reach_info, &targetPrivate->info, sizeof(ReachabilityInfo)); - - // callout - rlsFunction = targetPrivate->rlsFunction; - if (targetPrivate->rlsContext.retain != NULL) { - context_info = (void *)(*targetPrivate->rlsContext.retain)(targetPrivate->rlsContext.info); - context_release = targetPrivate->rlsContext.release; - } else { - context_info = targetPrivate->rlsContext.info; - context_release = NULL; + if (error_num) { + *error_num = 0; } - // update last notification info - _reach_set(&targetPrivate->last_notify, &reach_info, targetPrivate->cycle, targetPrivate->if_index, targetPrivate->if_name); - (void)gettimeofday(&targetPrivate->last_push, NULL); - - MUTEX_UNLOCK(&targetPrivate->lock); + MUTEX_LOCK(&targetPrivate->lock); - if (rlsFunction != NULL) { - (*rlsFunction)(target, - reach_info.flags & kSCNetworkReachabilityFlagsMask, - context_info); + if (nw_array_get_count(targetPrivate->lastResolvedEndpoints) > 0) { + CFMutableArrayRef array = CFArrayCreateMutable(kCFAllocatorDefault, 0, &kCFTypeArrayCallBacks); + if (array != NULL) { + nw_array_apply(targetPrivate->lastResolvedEndpoints, ^bool(size_t index, nw_object_t object) { + if (nw_endpoint_get_type((nw_endpoint_t)object) == nw_endpoint_type_address) { + const struct sockaddr *address = nw_endpoint_get_address((nw_endpoint_t)object); + if (address != NULL) { + CFDataRef addressData = CFDataCreate(kCFAllocatorDefault, (const uint8_t *)address, address->sa_len); + if (addressData != NULL) { + CFArrayAppendValue(array, addressData); + CFRelease(addressData); + } + } + } else if (nw_endpoint_get_type((nw_endpoint_t)object) == nw_endpoint_type_host) { + CFStringRef string = CFStringCreateWithCString(kCFAllocatorDefault, nw_endpoint_get_hostname((nw_endpoint_t)object), kCFStringEncodingASCII); + if (string != NULL) { + if (CFStringHasPrefix(string, CFSTR(".")) || CFStringHasSuffix(string, CFSTR("."))) { + CFMutableStringRef mutableString = CFStringCreateMutableCopy(kCFAllocatorDefault, 0, string); + if (mutableString != NULL) { + CFRelease(string); + string = mutableString; + CFStringTrim(mutableString, CFSTR(".")); + } + } + CFArrayAppendValue(array, string); + CFRelease(string); + } + } + return TRUE; + }); + MUTEX_UNLOCK(&targetPrivate->lock); + return array; + } } - if (context_release != NULL) { - (*context_release)(context_info); - } + MUTEX_UNLOCK(&targetPrivate->lock); - return; + _SCErrorSet(kSCStatusOK); + return NULL; } - /* - * reachUpdate - * - * - caller must *not* be holding the target lock - * - caller must be running on the __SCNetworkReachability_concurrent_queue() + * rankReachability() + * Not reachable == 0 + * Connection Required == 1 + * Reachable == 2 */ -static Boolean -reachUpdate(SCNetworkReachabilityRef target) +static int +rankReachability(SCNetworkReachabilityFlags flags) { - uint64_t cycle; - Boolean defer = FALSE; - Boolean forced; - Boolean ok; - ReachabilityInfo reach_info = NOT_REACHABLE; - ReachabilityStoreInfo store_info; - Boolean target_debug; - SCNetworkReachabilityPrivateRef targetPrivate = (SCNetworkReachabilityPrivateRef)target; - - target_debug = (_sc_debug && !targetPrivate->quiet); + int rank = 0; - if (target_debug) { - SCLog(TRUE, LOG_INFO, CFSTR("%schecking target reachability"), - targetPrivate->log_prefix); - } + if (flags & kSCNetworkReachabilityFlagsReachable) rank = 2; + if (flags & kSCNetworkReachabilityFlagsConnectionRequired) rank = 1; + return rank; +} +#pragma mark - +#pragma mark Reachability Flags - MUTEX_LOCK(&targetPrivate->lock); +static void +__SCNetworkReachabilityGetAgentVPNFlags(xpc_object_t dictionary, Boolean *vpn, Boolean *onDemand) +{ + const struct netagent *agent = NULL; + size_t length = 0; - if (!targetPrivate->scheduled) { - // if not currently scheduled - MUTEX_UNLOCK(&targetPrivate->lock); - return FALSE; + if (dictionary == NULL || vpn == NULL || onDemand == NULL) { + return; } - /* update reachability, notify if status changed */ - ReachabilityStoreInfo_init(&store_info); - ok = __SCNetworkReachabilityGetFlags(&store_info, target, &reach_info, TRUE); - ReachabilityStoreInfo_free(&store_info); - if (!ok) { - /* if reachability status not available */ - if (target_debug) { - SCLog(TRUE, LOG_INFO, CFSTR("%sflags not available"), - targetPrivate->log_prefix); - } - reach_info = NOT_REACHABLE; + *vpn = FALSE; + *onDemand = FALSE; + + agent = xpc_dictionary_get_data(dictionary, REACHABILITY_AGENT_DATA_KEY, &length); + if (agent == NULL || length < sizeof(struct netagent) || length != (sizeof(struct netagent) + agent->netagent_data_size)) { + return; } -#if !TARGET_OS_IPHONE - /* - * We want to defer the notification if this is a maintenance wake *and* - * the reachability flags that we would be reporting to the application - * are better than those that we last reported. - */ - if (!systemIsAwake(power_capabilities)) { - /* if this is a maintenace wake */ - reach_info.sleeping = TRUE; - - if (rankReachability(reach_info.flags) >= rankReachability(targetPrivate->info.flags)) { - /* - * don't report the change if the new reachability flags are - * the same or "better" - */ - defer = !darkWakeNotify(target); - } else if (!__reach_changed(&targetPrivate->last_notify, &reach_info)) { - /* - * if we have already posted this change - */ - defer = !darkWakeNotify(target); + if (strncmp(REACHABILITY_NETWORK_EXTENSION_AGENT_DOMAIN, agent->netagent_domain, NETAGENT_DOMAINSIZE) == 0) { + *vpn = TRUE; + if ((agent->netagent_flags & NETAGENT_FLAG_VOLUNTARY) && + !(agent->netagent_flags & NETAGENT_FLAG_ACTIVE)) { + *onDemand = TRUE; } } -#endif // !TARGET_OS_IPHONE - - cycle = targetPrivate->cycle; - forced = ((cycle != 0) && (targetPrivate->info.cycle != cycle)); - - /* - * (A) (B) (C) - * reach resolve - * changed forced pending - * ======= ======= ======= - * N N N No change - * N N Y No change - * N Y N Change (forced && !resolve pending) - * N Y Y No change (suppress forced w/resolve pending) - * Y N/A N/A Change - * Y N/A N/A Change - * Y N/A N/A Change - * Y N/A N/A Change - * - * Change == A || (B && !C) - * No Change == !(A || (B && !C)) - * No Change == !A && !(B && !C) - * No Change == !A && (!B || C) - * No Change == (!B || C) && !A - */ - if ((!forced || (reach_info.flags == kSCNetworkReachabilityFlagsFirstResolvePending)) - && !__reach_changed(&targetPrivate->info, &reach_info)) { - if (target_debug) { - if (targetPrivate->info.sleeping == reach_info.sleeping) { - SCLog(TRUE, LOG_INFO, - CFSTR("%sflags/interface match (now 0x%08x/%u%s)%s%s"), - targetPrivate->log_prefix, - reach_info.flags, - reach_info.if_index, - reach_info.sleeping ? ", z" : "", - defer ? ", deferred" : "", - forced ? ", forced" : ""); +} + +static SCNetworkReachabilityFlags +__SCNetworkReachabilityGetFlagsFromPath(nw_path_t path, + ReachabilityAddressType type, + nw_resolver_status_t resolverStatus, + nw_array_t resolvedEndpoints, + Boolean resolvedEndpointUseFlags, + SCNetworkReachabilityFlags resolvedEndpointFlags) +{ + __block SCNetworkReachabilityFlags flags = kSCNetworkReachabilityFlagsReachable; + if (path != NULL) { + nw_path_status_t status = nw_path_get_status(path); + if (status == nw_path_status_satisfied) { + __block bool checkDNSFlags = TRUE; + flags = kSCNetworkReachabilityFlagsReachable; +#if TARGET_OS_IPHONE && !TARGET_IPHONE_SIMULATOR + if (nw_path_uses_interface_type(path, nw_interface_type_cellular)) { + flags |= (kSCNetworkReachabilityFlagsTransientConnection | kSCNetworkReachabilityFlagsIsWWAN); + } +#endif + xpc_object_t agent_dictionary = nw_path_copy_netagent_dictionary(path); + if (agent_dictionary != NULL) { + if (xpc_dictionary_get_count(agent_dictionary) > 0) { + xpc_dictionary_apply(agent_dictionary, ^bool(__unused const char *key, xpc_object_t value) { + Boolean vpn = FALSE; + Boolean onDemand = FALSE; + __SCNetworkReachabilityGetAgentVPNFlags(value, &vpn, &onDemand); + if (vpn) { + // VPN flows are transient + flags |= kSCNetworkReachabilityFlagsTransientConnection; + } + if (onDemand && + type == reachabilityTypeName && + resolverStatus == nw_resolver_status_complete && + nw_array_get_count(resolvedEndpoints) == 0) { + // On Demand by hostname, when no address has been resolved + flags |= (kSCNetworkReachabilityFlagsConnectionRequired | kSCNetworkReachabilityFlagsConnectionOnDemand); + checkDNSFlags = FALSE; + } + return TRUE; + }); + + } + xpc_release(agent_dictionary); + } + if (isReachabilityTypeName(type)) { + if (checkDNSFlags) { + if (resolverStatus == nw_resolver_status_complete && + nw_array_get_count(resolvedEndpoints) == 0) { + // DNS didn't resolve, as a final answer for now. Not reachable! + flags = 0; + } else if (resolvedEndpointUseFlags) { + flags = resolvedEndpointFlags; + } + } } else { - SCLog(TRUE, LOG_INFO, - CFSTR("%sflags/interface equiv (was 0x%08x/%u%s, now 0x%08x/%u%s)%s%s"), - targetPrivate->log_prefix, - targetPrivate->info.flags, - targetPrivate->info.if_index, - targetPrivate->info.sleeping ? ", z" : "", - reach_info.flags, - reach_info.if_index, - reach_info.sleeping ? ", z" : "", - defer ? ", deferred" : "", - forced ? ", forced" : ""); + if (nw_path_is_direct(path)) { + flags |= kSCNetworkReachabilityFlagsIsDirect; + } + if (nw_path_is_local(path)) { + flags |= kSCNetworkReachabilityFlagsIsLocalAddress; + } + } + } else if (status == nw_path_status_unsatisfied) { + flags = 0; + } else if (status == nw_path_status_satisfiable) { + flags = (kSCNetworkReachabilityFlagsReachable | kSCNetworkReachabilityFlagsConnectionRequired | kSCNetworkReachabilityFlagsTransientConnection); + uuid_t vpn_uuid; + if (nw_path_get_vpn_config_id(path, &vpn_uuid)) { + flags |= kSCNetworkReachabilityFlagsConnectionOnDemand; + } +#if TARGET_OS_IPHONE && !TARGET_IPHONE_SIMULATOR + else if (nw_path_uses_interface_type(path, nw_interface_type_cellular)) { + flags |= (kSCNetworkReachabilityFlagsIsWWAN); } +#endif } - MUTEX_UNLOCK(&targetPrivate->lock); - return FALSE; - } - - if (target_debug) { - SCLog(TRUE, LOG_INFO, - CFSTR("%sflags/interface have changed (was 0x%08x/%u%s, now 0x%08x/%u%s)%s%s"), - targetPrivate->log_prefix, - targetPrivate->info.flags, - targetPrivate->info.if_index, - targetPrivate->info.sleeping ? ", z" : "", - reach_info.flags, - reach_info.if_index, - reach_info.sleeping ? ", z" : "", - defer ? ", deferred" : "", - forced ? ", forced" : ""); } + return (flags & kSCNetworkReachabilityFlagsMask); +} - /* update flags / interface */ - _reach_set(&targetPrivate->info, &reach_info, cycle, targetPrivate->if_index, targetPrivate->if_name); - - /* as needed, defer the notification */ - if (defer) { - MUTEX_UNLOCK(&targetPrivate->lock); - return FALSE; +static nw_endpoint_t +__SCNetworkReachabilityGetPrimaryEndpoint(SCNetworkReachabilityPrivateRef targetPrivate) +{ + if (targetPrivate->type == reachabilityTypeName) { + return targetPrivate->hostnameEndpoint; + } else if (targetPrivate->type == reachabilityTypeAddress || + targetPrivate->type == reachabilityTypeAddressPair || + targetPrivate->type == reachabilityTypePTR) { + return targetPrivate->remoteAddressEndpoint; } - - MUTEX_UNLOCK(&targetPrivate->lock); - - return TRUE; + return NULL; } - -Boolean -SCNetworkReachabilitySetCallback(SCNetworkReachabilityRef target, - SCNetworkReachabilityCallBack callout, - SCNetworkReachabilityContext *context) +int +SCNetworkReachabilityGetInterfaceIndex(SCNetworkReachabilityRef target) { - SCNetworkReachabilityPrivateRef targetPrivate = (SCNetworkReachabilityPrivateRef)target; + int if_index = -1; + Boolean ok = TRUE; + SCNetworkReachabilityPrivateRef targetPrivate = (SCNetworkReachabilityPrivateRef)target; + SCNetworkReachabilityFlags flags = 0; + + if (!isA_SCNetworkReachability(target)) { + _SCErrorSet(kSCStatusInvalidArgument); + return if_index; + } MUTEX_LOCK(&targetPrivate->lock); - if (targetPrivate->rlsContext.release != NULL) { - /* let go of the current context */ - (*targetPrivate->rlsContext.release)(targetPrivate->rlsContext.info); - } + flags = __SCNetworkReachabilityGetFlagsFromPath(targetPrivate->lastPath, targetPrivate->type, nw_resolver_status_invalid, NULL, targetPrivate->lastResolvedEndpointHasFlags, targetPrivate->lastResolvedEndpointFlags); - targetPrivate->rlsFunction = callout; - targetPrivate->rlsContext.info = NULL; - targetPrivate->rlsContext.retain = NULL; - targetPrivate->rlsContext.release = NULL; - targetPrivate->rlsContext.copyDescription = NULL; - if (context) { - bcopy(context, &targetPrivate->rlsContext, sizeof(SCNetworkReachabilityContext)); - if (context->retain != NULL) { - targetPrivate->rlsContext.info = (void *)(*context->retain)(context->info); + /* Only return the if_index if the connection is reachable not for reachable connection + * required etc ... */ + if (ok && rankReachability(flags) == 2) { + if (targetPrivate->lastResolvedEndpointHasFlags) { + if_index = targetPrivate->lastResolvedEndpointInterfaceIndex; + } else { + if_index = nw_path_get_interface_index(targetPrivate->lastPath); } } MUTEX_UNLOCK(&targetPrivate->lock); - - return TRUE; -} - - -static CFStringRef -reachRLSCopyDescription(const void *info) -{ - SCNetworkReachabilityRef target = (SCNetworkReachabilityRef)info; - - return CFStringCreateWithFormat(NULL, - NULL, - CFSTR(" {target = %p}"), - target); + return if_index; } - -static Boolean -__SCNetworkReachabilityScheduleWithRunLoop(SCNetworkReachabilityRef target, - CFRunLoopRef runLoop, - CFStringRef runLoopMode, - dispatch_queue_t queue, - Boolean onDemand) +Boolean +SCNetworkReachabilityGetFlags(SCNetworkReachabilityRef target, + SCNetworkReachabilityFlags *flags) { + Boolean ok = TRUE; SCNetworkReachabilityPrivateRef targetPrivate = (SCNetworkReachabilityPrivateRef)target; - Boolean init = FALSE; - __block Boolean ok = FALSE; - - MUTEX_LOCK(&targetPrivate->lock); - if ((targetPrivate->dispatchQueue != NULL) || // if we are already scheduled with a dispatch queue - ((queue != NULL) && targetPrivate->scheduled)) { // if we are already scheduled on a CFRunLoop + if (!isA_SCNetworkReachability(target)) { _SCErrorSet(kSCStatusInvalidArgument); - goto done; + return FALSE; } - if (!targetPrivate->serverBypass) { - if (!targetPrivate->serverActive) { - - ok = __SCNetworkReachabilityServer_targetAdd(target); - if (!ok) { - targetPrivate->serverBypass = TRUE; - } - } - - if (targetPrivate->serverActive) { - if (targetPrivate->scheduled) { - // if already scheduled - goto watch; - } - - ok = __SCNetworkReachabilityServer_targetSchedule(target); - if (!ok) { - SCLog(TRUE, LOG_DEBUG, - CFSTR("__SCNetworkReachabilityScheduleWithRunLoop _targetMonitor() failed")); - _SCErrorSet(kSCStatusFailed); - goto done; - } + MUTEX_LOCK(&targetPrivate->lock); - goto watch; - } + if (targetPrivate->scheduled) { + // if being watched, return the last known (and what should be current) status + *flags = __SCNetworkReachabilityGetFlagsFromPath(targetPrivate->lastPath, targetPrivate->type, targetPrivate->lastResolverStatus, targetPrivate->lastResolvedEndpoints, targetPrivate->lastResolvedEndpointHasFlags, targetPrivate->lastResolvedEndpointFlags); + // because we have synchronously captured the current status, we no longer + // need our by-name required callback + targetPrivate->sentFirstUpdate = TRUE; + goto done; } - /* schedule the SCNetworkReachability did-something-change handler */ - - dispatch_sync(_hn_target_queue(), ^{ - ok = FALSE; - - if (!onDemand && (hn_store == NULL)) { - CFMutableArrayRef keys; - CFMutableArrayRef patterns; - Boolean watch_dns_configuration = FALSE; - Boolean watch_dns_changes = FALSE; - Boolean watch_nwi = FALSE; - Boolean watch_onDemand_networking = FALSE; -#if !TARGET_OS_IPHONE - Boolean watch_power = FALSE; -#endif // !TARGET_OS_IPHONE - - hn_store = SCDynamicStoreCreate(NULL, - CFSTR("SCNetworkReachability"), - __SCNetworkReachabilityHandleStoreChanges, - NULL); - if (hn_store == NULL) { - SCLog(TRUE, LOG_ERR, CFSTR("SCDynamicStoreCreate() failed")); - return; - } - - ReachabilityStoreInfo_keys(&keys, &patterns); - CFArrayAppendValue(keys, SCNETWORKREACHABILITY_TRIGGER_KEY); // force posting reach change - ok = SCDynamicStoreSetNotificationKeys(hn_store, keys, patterns); - CFRelease(keys); - CFRelease(patterns); - if (!ok) { - SCLog(TRUE, LOG_ERR, CFSTR("SCDynamicStoreSetNotificationKeys() failed")); - CFRelease(hn_store); - hn_store = NULL; - return; - } - - ok = SCDynamicStoreSetDispatchQueue(hn_store, _hn_changes_queue()); - if (!ok) { - SCLog(TRUE, LOG_ERR, CFSTR("SCDynamicStoreSetDispatchQueue() failed")); - CFRelease(hn_store); - hn_store = NULL; - return; - } - - // watch for network information changes - watch_nwi = nwi_refresh_enable(_hn_changes_queue()); - if (!watch_nwi) { - goto fail; - } - // watch for DNS configuration (resolver reachability) changes - watch_dns_configuration = dns_configuration_watch(); - if (!watch_dns_configuration) { - goto fail; - } + // Not being watched, so run a one-shot path evaluator + // We don't care about DNS resolution in this case, since we only need to have the DNS resolution to support clients watching reachability to get updates + nw_path_evaluator_t pathEvaluator = nw_path_create_evaluator_for_endpoint(__SCNetworkReachabilityGetPrimaryEndpoint(targetPrivate), targetPrivate->parameters); + nw_path_t path = nw_path_evaluator_copy_path(pathEvaluator); + *flags = __SCNetworkReachabilityGetFlagsFromPath(path, 0, nw_resolver_status_invalid, NULL, FALSE, 0); + network_release(path); + network_release(pathEvaluator); - // watch for changes affecting DNS queries - watch_dns_changes = dns_refresh_enable(_hn_changes_queue()); - if (!watch_dns_changes) { - goto fail; - } + done : -#if !TARGET_OS_IPHONE - // watch for power capabilities (sleep/wake) changes - watch_power = power_refresh_enable(_hn_changes_queue()); - if (!watch_power) { - goto fail; - } -#endif // !TARGET_OS_IPHONE + MUTEX_UNLOCK(&targetPrivate->lock); + return ok; +} - // watch for OnDemand network changes - watch_onDemand_networking = onDemand_refresh_enable(_hn_changes_queue()); - if (!watch_onDemand_networking) { - goto fail; - } +#pragma mark - +#pragma mark Notifications +static void +reachPerformAndUnlock(SCNetworkReachabilityPrivateRef targetPrivate) +{ + os_activity_t activity_id; + void *context_info; + void (*context_release)(const void *); + SCNetworkReachabilityCallBack rlsFunction; + SCNetworkReachabilityFlags flags = 0; - hn_targets = CFSetCreateMutable(NULL, 0, &kCFTypeSetCallBacks); - ReachabilityStoreInfo_enable(TRUE); + activity_id = os_activity_start("processing SCNetworkReachability notification", + OS_ACTIVITY_FLAG_DEFAULT); - goto scheduled; + if (!targetPrivate->scheduled) { + // if no longer scheduled + SC_log(LOG_INFO, "%sskipping SCNetworkReachability callback, no longer scheduled", + targetPrivate->log_prefix); + MUTEX_UNLOCK(&targetPrivate->lock); + goto done; + } - fail : + // callout + rlsFunction = targetPrivate->rlsFunction; + if (targetPrivate->rlsContext.retain != NULL) { + context_info = (void *)(*targetPrivate->rlsContext.retain)(targetPrivate->rlsContext.info); + context_release = targetPrivate->rlsContext.release; + } else { + context_info = targetPrivate->rlsContext.info; + context_release = NULL; + } - ok = FALSE; + flags = __SCNetworkReachabilityGetFlagsFromPath(targetPrivate->lastPath, targetPrivate->type, targetPrivate->lastResolverStatus, targetPrivate->lastResolvedEndpoints, targetPrivate->lastResolvedEndpointHasFlags, targetPrivate->lastResolvedEndpointFlags); + MUTEX_UNLOCK(&targetPrivate->lock); + if (rlsFunction != NULL) { + (*rlsFunction)((SCNetworkReachabilityRef)targetPrivate, + flags, + context_info); + } - if (watch_onDemand_networking) { - onDemand_refresh_disable(); - } + if (context_release != NULL) { + (*context_release)(context_info); + } -#if !TARGET_OS_IPHONE - if (watch_power) { - power_refresh_disable(); - } -#endif // !TARGET_OS_IPHONE + done : - if (watch_dns_changes) { - dns_refresh_disable(); - } + os_activity_end(activity_id); - if (watch_dns_configuration) { - dns_configuration_unwatch(); - } + return; +} - if (watch_nwi) { - nwi_refresh_disable(); - } +static void +reachPerform(void *info) +{ + SCNetworkReachabilityPrivateRef targetPrivate = (SCNetworkReachabilityPrivateRef)info; - SCDynamicStoreSetDispatchQueue(hn_store, NULL); - CFRelease(hn_store); - hn_store = NULL; + MUTEX_LOCK(&targetPrivate->lock); + reachPerformAndUnlock(targetPrivate); - _SCErrorSet(kSCStatusFailed); +} - return; +static void +reachUpdateAndUnlock(SCNetworkReachabilityPrivateRef targetPrivate) +{ + targetPrivate->sentFirstUpdate = TRUE; + if (targetPrivate->rls != NULL) { + if (targetPrivate->rlList != NULL) { + CFRunLoopSourceSignal(targetPrivate->rls); + _SC_signalRunLoop(targetPrivate, targetPrivate->rls, targetPrivate->rlList); } + MUTEX_UNLOCK(&targetPrivate->lock); + } else { + reachPerformAndUnlock(targetPrivate); + } +} - scheduled : +Boolean +SCNetworkReachabilitySetCallback(SCNetworkReachabilityRef target, + SCNetworkReachabilityCallBack callout, + SCNetworkReachabilityContext *context) +{ + SCNetworkReachabilityPrivateRef targetPrivate = (SCNetworkReachabilityPrivateRef)target; - CFSetAddValue(hn_targets, target); + MUTEX_LOCK(&targetPrivate->lock); - ok = TRUE; - }); + if (targetPrivate->rlsContext.release != NULL) { + /* let go of the current context */ + (*targetPrivate->rlsContext.release)(targetPrivate->rlsContext.info); + } - if (!ok) { - goto done; + targetPrivate->rlsFunction = callout; + targetPrivate->rlsContext.info = NULL; + targetPrivate->rlsContext.retain = NULL; + targetPrivate->rlsContext.release = NULL; + targetPrivate->rlsContext.copyDescription = NULL; + if (context) { + bcopy(context, &targetPrivate->rlsContext, sizeof(SCNetworkReachabilityContext)); + if (context->retain != NULL) { + targetPrivate->rlsContext.info = (void *)(*context->retain)(context->info); + } } - watch : + MUTEX_UNLOCK(&targetPrivate->lock); - if (!targetPrivate->scheduled) { - CFRunLoopSourceContext context = { 0 // version - , (void *)target // info - , CFRetain // retain - , CFRelease // release - , reachRLSCopyDescription // copyDescription - , CFEqual // equal - , CFHash // hash - , NULL // schedule - , NULL // cancel - , reachPerform // perform - }; - - if (runLoop != NULL) { - targetPrivate->rls = CFRunLoopSourceCreate(NULL, 0, &context); - targetPrivate->rlList = CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks); - } + return TRUE; +} - if (isReachabilityTypeName(targetPrivate->type)) { - /* - * we're now scheduled so let's ensure that we - * are starting with a clean slate before we - * resolve the name - */ - if (targetPrivate->resolvedAddresses != NULL) { - CFRelease(targetPrivate->resolvedAddresses); - targetPrivate->resolvedAddresses = NULL; - } - targetPrivate->resolvedError = NETDB_SUCCESS; - targetPrivate->needResolve = TRUE; - _reach_set(&targetPrivate->info, - &NOT_REACHABLE, - targetPrivate->info.cycle, - targetPrivate->if_index, - targetPrivate->if_name); - targetPrivate->info.flags |= kSCNetworkReachabilityFlagsFirstResolvePending; - _reach_set(&targetPrivate->serverInfo, - &NOT_REACHABLE, - targetPrivate->serverInfo.cycle, - targetPrivate->if_index, - targetPrivate->if_name); - targetPrivate->serverInfo.flags |= kSCNetworkReachabilityFlagsFirstResolvePending; - } +static CFStringRef +reachRLSCopyDescription(const void *info) +{ + SCNetworkReachabilityRef target = (SCNetworkReachabilityRef)info; - targetPrivate->scheduled = TRUE; + return CFStringCreateWithFormat(NULL, + NULL, + CFSTR(" {target = %p}"), + target); +} - init = TRUE; +Boolean +SCNetworkReachabilityScheduleWithRunLoop(SCNetworkReachabilityRef target, + CFRunLoopRef runLoop, + CFStringRef runLoopMode) +{ + Boolean success = FALSE; + SCNetworkReachabilityPrivateRef targetPrivate = (SCNetworkReachabilityPrivateRef)target; + if (!isA_SCNetworkReachability(target) || (runLoop == NULL) || (runLoopMode == NULL)) { + _SCErrorSet(kSCStatusInvalidArgument); + return FALSE; } - if (queue != NULL) { - // retain dispatch queue - dispatch_retain(queue); - targetPrivate->dispatchQueue = queue; - - // - // We've taken a reference to the client's dispatch_queue and we - // want to hold on to that reference until we've processed any/all - // notifications. To facilitate this we create a group, dispatch - // any notification blocks to via that group, and when the caller - // has told us to stop the notifications (unschedule) we wait for - // the group to empty and use the group's finalizer to release - // our reference to the client's queue. - // - - // make sure that we have group to track any async requests - targetPrivate->dispatchGroup = dispatch_group_create(); - - // retain the target ... and release it when the group is released - CFRetain(target); - dispatch_set_context(targetPrivate->dispatchGroup, (void *)target); - dispatch_set_finalizer_f(targetPrivate->dispatchGroup, (dispatch_function_t)CFRelease); - } else { - if (!_SC_isScheduled(NULL, runLoop, runLoopMode, targetPrivate->rlList)) { - /* - * if we do not already have host notifications scheduled with - * this runLoop / runLoopMode - */ - CFRunLoopAddSource(runLoop, targetPrivate->rls, runLoopMode); - } + MUTEX_LOCK(&targetPrivate->lock); - _SC_schedule(target, runLoop, runLoopMode, targetPrivate->rlList); - } + if (targetPrivate->scheduled) { + if (targetPrivate->rls != NULL && targetPrivate->rlList != NULL) { + if (!_SC_isScheduled(NULL, runLoop, runLoopMode, targetPrivate->rlList)) { + /* + * if we do not already have host notifications scheduled with + * this runLoop / runLoopMode + */ + CFRunLoopAddSource(runLoop, targetPrivate->rls, runLoopMode); + } - if (init) { - ReachabilityInfo reach_info = NOT_REACHABLE; - ReachabilityStoreInfo store_info; + _SC_schedule(target, runLoop, runLoopMode, targetPrivate->rlList); - /* - * if we have yet to schedule SC notifications for this address - * - initialize current reachability status - */ - ReachabilityStoreInfo_init(&store_info); - if (__SCNetworkReachabilityGetFlags(&store_info, target, &reach_info, TRUE)) { - /* - * if reachability status available - * - set flags - * - schedule notification to report status via callback - */ - reach_info.flags |= (targetPrivate->info.flags & kSCNetworkReachabilityFlagsFirstResolvePending); - _reach_set(&targetPrivate->info, - &reach_info, - targetPrivate->cycle, - targetPrivate->if_index, - targetPrivate->if_name); - __SCNetworkReachabilityUpdate(target); + MUTEX_UNLOCK(&targetPrivate->lock); + return TRUE; } else { - /* if reachability status not available, async lookup started */ - _reach_set(&targetPrivate->info, - &NOT_REACHABLE, - targetPrivate->cycle, - targetPrivate->if_index, - targetPrivate->if_name); - _reach_set(&targetPrivate->serverInfo, - &NOT_REACHABLE, - targetPrivate->cycle, - targetPrivate->if_index, - targetPrivate->if_name); + MUTEX_UNLOCK(&targetPrivate->lock); + _SCErrorSet(kSCStatusInvalidArgument); + return FALSE; } - ReachabilityStoreInfo_free(&store_info); - } - - if (targetPrivate->onDemandServer != NULL) { - __SCNetworkReachabilityScheduleWithRunLoop(targetPrivate->onDemandServer, runLoop, runLoopMode, queue, TRUE); } - SCLog((_sc_debug && (_sc_log > 0)), LOG_INFO, CFSTR("%sscheduled"), - targetPrivate->log_prefix); + CFRunLoopSourceContext context = { + 0 // version + , (void *)target // info + , CFRetain // retain + , CFRelease // release + , reachRLSCopyDescription // copyDescription + , CFEqual // equal + , CFHash // hash + , NULL // schedule + , NULL // cancel + , reachPerform // perform + }; - ok = TRUE; + targetPrivate->rls = CFRunLoopSourceCreate(NULL, 0, &context); + targetPrivate->rlList = CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks); - done : + if (!_SC_isScheduled(NULL, runLoop, runLoopMode, targetPrivate->rlList)) { + /* + * if we do not already have host notifications scheduled with + * this runLoop / runLoopMode + */ + CFRunLoopAddSource(runLoop, targetPrivate->rls, runLoopMode); + } + + _SC_schedule(target, runLoop, runLoopMode, targetPrivate->rlList); + + success = __SCNetworkReachabilitySetDispatchQueue(targetPrivate, _callback_queue()); + if (!success) { + if (_SC_unschedule(target, runLoop, runLoopMode, targetPrivate->rlList, FALSE)) { + CFIndex n = CFArrayGetCount(targetPrivate->rlList); + if ((n == 0) || !_SC_isScheduled(NULL, runLoop, runLoopMode, targetPrivate->rlList)) { + // if target is no longer scheduled for this runLoop / runLoopMode + CFRunLoopRemoveSource(runLoop, targetPrivate->rls, runLoopMode); + if (n == 0) { + // if *all* notifications have been unscheduled + CFRelease(targetPrivate->rlList); + targetPrivate->rlList = NULL; + CFRunLoopSourceInvalidate(targetPrivate->rls); + CFRelease(targetPrivate->rls); + targetPrivate->rls = NULL; + } + } + } + } MUTEX_UNLOCK(&targetPrivate->lock); - return ok; + return success; } - -static Boolean -__SCNetworkReachabilityUnscheduleFromRunLoop(SCNetworkReachabilityRef target, - CFRunLoopRef runLoop, - CFStringRef runLoopMode, - Boolean onDemand) +Boolean +SCNetworkReachabilityUnscheduleFromRunLoop(SCNetworkReachabilityRef target, + CFRunLoopRef runLoop, + CFStringRef runLoopMode) { - dispatch_group_t drainGroup = NULL; - dispatch_queue_t drainQueue = NULL; - CFIndex n = 0; - Boolean ok = FALSE; + Boolean success = FALSE; + Boolean unscheduleDispatchQueue = FALSE; SCNetworkReachabilityPrivateRef targetPrivate = (SCNetworkReachabilityPrivateRef)target; - - // hold a reference while we unschedule - CFRetain(target); - - MUTEX_LOCK(&targetPrivate->lock); - - if (((runLoop == NULL) && (targetPrivate->dispatchQueue == NULL)) || // if we should be scheduled on a dispatch queue (but are not) - ((runLoop != NULL) && (targetPrivate->dispatchQueue != NULL))) { // if we should be scheduled on a CFRunLoop (but are not) + if (!isA_SCNetworkReachability(target) || (runLoop == NULL) || (runLoopMode == NULL)) { _SCErrorSet(kSCStatusInvalidArgument); - goto done; + return FALSE; } - if (!targetPrivate->scheduled) { - // if not currently scheduled + MUTEX_LOCK(&targetPrivate->lock); + + if (targetPrivate->rlList == NULL || targetPrivate->rls == NULL || !targetPrivate->scheduled) { + MUTEX_UNLOCK(&targetPrivate->lock); _SCErrorSet(kSCStatusInvalidArgument); - goto done; + return FALSE; } - // unschedule the target specific sources - if (targetPrivate->dispatchQueue != NULL) { - if (targetPrivate->onDemandServer != NULL) { - SCNetworkReachabilitySetCallback(targetPrivate->onDemandServer, NULL, NULL); - __SCNetworkReachabilityUnscheduleFromRunLoop(targetPrivate->onDemandServer, NULL, NULL, TRUE); - } - - // save dispatchQueue, release reference when we've queue'd blocks complete, allow re-scheduling - drainGroup = targetPrivate->dispatchGroup; - targetPrivate->dispatchGroup = NULL; - drainQueue = targetPrivate->dispatchQueue; - targetPrivate->dispatchQueue = NULL; - } else { - if (!_SC_unschedule(target, runLoop, runLoopMode, targetPrivate->rlList, FALSE)) { - // if not currently scheduled - _SCErrorSet(kSCStatusInvalidArgument); - goto done; - } - - if (targetPrivate->onDemandServer != NULL) { - __SCNetworkReachabilityUnscheduleFromRunLoop(targetPrivate->onDemandServer, runLoop, runLoopMode, TRUE); - } - - n = CFArrayGetCount(targetPrivate->rlList); + if (_SC_unschedule(target, runLoop, runLoopMode, targetPrivate->rlList, FALSE)) { + CFIndex n = CFArrayGetCount(targetPrivate->rlList); if ((n == 0) || !_SC_isScheduled(NULL, runLoop, runLoopMode, targetPrivate->rlList)) { // if target is no longer scheduled for this runLoop / runLoopMode CFRunLoopRemoveSource(runLoop, targetPrivate->rls, runLoopMode); - if (n == 0) { // if *all* notifications have been unscheduled - if (targetPrivate->onDemandServer != NULL) { - SCNetworkReachabilitySetCallback(targetPrivate->onDemandServer, NULL, NULL); - } + unscheduleDispatchQueue = TRUE; CFRelease(targetPrivate->rlList); targetPrivate->rlList = NULL; CFRunLoopSourceInvalidate(targetPrivate->rls); @@ -5987,147 +1372,282 @@ __SCNetworkReachabilityUnscheduleFromRunLoop(SCNetworkReachabilityRef target, } } - if (n == 0) { - // - // Cancel our request for server monitoring - // - if (targetPrivate->serverActive) { - ok = __SCNetworkReachabilityServer_targetUnschedule(target); - if (!ok) { - SCLog(TRUE, LOG_DEBUG, - CFSTR("__SCNetworkReachabilityUnscheduleFromRunLoop _targetMonitor() failed")); - _SCErrorSet(kSCStatusFailed); - } - } - - // if *all* notifications have been unscheduled - targetPrivate->scheduled = FALSE; + if (unscheduleDispatchQueue) { + success = __SCNetworkReachabilitySetDispatchQueue(targetPrivate, NULL); + } else { + success = TRUE; } + MUTEX_UNLOCK(&targetPrivate->lock); + return success; +} - if (targetPrivate->serverActive) { - goto unwatch; +static __inline__ void +__SCNetworkReachabilityCopyPathStatus(SCNetworkReachabilityPrivateRef targetPrivate, SCNetworkReachabilityFlags *flags, uint *ifIndex, size_t *endpointCount) +{ + if (flags) { + *flags = __SCNetworkReachabilityGetFlagsFromPath(targetPrivate->lastPath, targetPrivate->type, targetPrivate->lastResolverStatus, targetPrivate->lastResolvedEndpoints, targetPrivate->lastResolvedEndpointHasFlags, targetPrivate->lastResolvedEndpointFlags); } + if (ifIndex) { + *ifIndex = nw_path_get_interface_index(targetPrivate->lastPath); + } + if (endpointCount) { + *endpointCount = nw_array_get_count(targetPrivate->lastResolvedEndpoints); + } + return; +} - if (n == 0) { - if (targetPrivate->dnsActive) { - // if we have an active [m]DNS query - dequeueDNSQuery(target); - } - - dispatch_sync(_hn_target_queue(), ^{ - CFSetRemoveValue(hn_targets, target); +static __inline__ Boolean +__SCNetworkReachabilityShouldUpdateClient(SCNetworkReachabilityPrivateRef targetPrivate, SCNetworkReachabilityFlags oldFlags, uint oldIFIndex, size_t oldEndpointCount) +{ + SCNetworkReachabilityFlags newFlags = 0; + uint newIFIndex = 0; + size_t newEndpointCount = 0; + __SCNetworkReachabilityCopyPathStatus(targetPrivate, &newFlags, &newIFIndex, &newEndpointCount); + return (!targetPrivate->sentFirstUpdate || + oldFlags != newFlags || + oldIFIndex != newIFIndex || + oldEndpointCount != newEndpointCount); +} - if (onDemand) { - return; - } +static void +__SCNetworkReachabilityRestartResolver(SCNetworkReachabilityPrivateRef targetPrivate) +{ + if (targetPrivate && + !targetPrivate->resolverBypass && + isReachabilityTypeName(targetPrivate->type)) { + targetPrivate = (SCNetworkReachabilityPrivateRef)CFRetain(targetPrivate); + nw_resolver_cancel(targetPrivate->resolver); + nw_resolver_t resolver = nw_resolver_create_with_endpoint(__SCNetworkReachabilityGetPrimaryEndpoint(targetPrivate), targetPrivate->lastPathParameters ? targetPrivate->lastPathParameters : targetPrivate->parameters); + targetPrivate->resolver = resolver; + nw_resolver_set_cancel_handler(resolver, ^(void) { + MUTEX_LOCK(&targetPrivate->lock); + if (resolver == targetPrivate->resolver) { + targetPrivate->resolver = NULL; + } + network_release(resolver); + MUTEX_UNLOCK(&targetPrivate->lock); + CFRelease(targetPrivate); + }); + if (!nw_resolver_set_update_handler(resolver, targetPrivate->dispatchQueue, ^(nw_resolver_status_t status, nw_array_t resolved_endpoints) { + MUTEX_LOCK(&targetPrivate->lock); + if (targetPrivate->scheduled) { + SCNetworkReachabilityFlags oldFlags = 0; + uint oldIFIndex = 0; + size_t oldEndpointCount = 0; + __SCNetworkReachabilityCopyPathStatus(targetPrivate, &oldFlags, &oldIFIndex, &oldEndpointCount); + + targetPrivate->lastResolverStatus = status; + network_release(targetPrivate->lastResolvedEndpoints); + targetPrivate->lastResolvedEndpoints = network_retain(resolved_endpoints); + + // Run path evaluation on the resolved endpoints + __block Boolean hasFlags = FALSE; + targetPrivate->lastResolvedEndpointHasFlags = FALSE; + targetPrivate->lastResolvedEndpointFlags = 0; + targetPrivate->lastResolvedEndpointInterfaceIndex = 0; + nw_array_apply(targetPrivate->lastResolvedEndpoints, ^bool(size_t index, nw_object_t object) { + SCNetworkReachabilityFlags flags = 0; + uint interfaceIndex = 0; + nw_endpoint_t resolvedEndpoint = (nw_endpoint_t)object; + nw_path_evaluator_t pathEvaluator = nw_path_create_evaluator_for_endpoint(resolvedEndpoint, targetPrivate->lastPathParameters ? targetPrivate->lastPathParameters : targetPrivate->parameters); + nw_path_t path = nw_path_evaluator_copy_path(pathEvaluator); + if (path != NULL) { + flags = __SCNetworkReachabilityGetFlagsFromPath(path, 0, nw_resolver_status_invalid, NULL, FALSE, 0); + hasFlags = TRUE; + } + interfaceIndex = nw_path_get_interface_index(path); + network_release(path); + network_release(pathEvaluator); + + if (rankReachability(flags) > rankReachability(targetPrivate->lastResolvedEndpointFlags)) { + // Return the best case result + targetPrivate->lastResolvedEndpointFlags = flags; + targetPrivate->lastResolvedEndpointInterfaceIndex = interfaceIndex; + if (rankReachability(flags) == 2) { + // Can't get any better than REACHABLE + return FALSE; + } + } + return TRUE; + }); + targetPrivate->lastResolvedEndpointHasFlags = hasFlags; - if (CFSetGetCount(hn_targets) > 0) { - return; + if (__SCNetworkReachabilityShouldUpdateClient(targetPrivate, oldFlags, oldIFIndex, oldEndpointCount)) { + reachUpdateAndUnlock(targetPrivate); + } else { + MUTEX_UNLOCK(&targetPrivate->lock); + } + } else { + MUTEX_UNLOCK(&targetPrivate->lock); } + })) { + network_release(resolver); + targetPrivate->resolver = NULL; + CFRelease(targetPrivate); + } + } +} - // if we are no longer monitoring any targets - SCDynamicStoreSetDispatchQueue(hn_store, NULL); - CFRelease(hn_store); - hn_store = NULL; - CFRelease(hn_targets); - hn_targets = NULL; - - ReachabilityStoreInfo_enable(FALSE); - ReachabilityStoreInfo_save(NULL); - - /* - * until we start monitoring again, ensure that - * any resources associated with watching network - * and configuration changes have been released. - */ +static Boolean +__SCNetworkReachabilitySetDispatchQueue(SCNetworkReachabilityPrivateRef targetPrivate, + dispatch_queue_t queue) +{ + Boolean ok = FALSE; + if (queue != NULL) { + if ((targetPrivate->dispatchQueue != NULL) || // if we are already scheduled with a dispatch queue + ((queue != NULL) && targetPrivate->scheduled)) { // if we are already scheduled on a CFRunLoop + _SCErrorSet(kSCStatusInvalidArgument); + goto done; + } - // OnDemand configuration - onDemand_refresh_disable(); + // retain dispatch queue + dispatch_retain(queue); + nw_path_evaluator_cancel(targetPrivate->pathEvaluator); + nw_path_evaluator_t pathEvaluator = nw_path_create_evaluator_for_endpoint(__SCNetworkReachabilityGetPrimaryEndpoint(targetPrivate), targetPrivate->parameters); + targetPrivate->pathEvaluator = pathEvaluator; + targetPrivate->dispatchQueue = queue; + targetPrivate->scheduled = TRUE; + if (isReachabilityTypeName(targetPrivate->type)) { + // we must have at least one callback for by-name queries + targetPrivate->sentFirstUpdate = FALSE; + } else { + targetPrivate->sentFirstUpdate = TRUE; + } -#if !TARGET_OS_IPHONE - // sleep/wake & power capabilities - power_refresh_disable(); -#endif // !TARGET_OS_IPHONE + network_release(targetPrivate->lastPath); + targetPrivate->lastPath = nw_path_evaluator_copy_path(pathEvaluator); - // outstanding DNS queries - dns_refresh_disable(); + network_release(targetPrivate->lastPathParameters); + targetPrivate->lastPathParameters = nw_path_copy_derived_parameters(targetPrivate->lastPath); - // DNS configuration - dns_configuration_unwatch(); + targetPrivate->lastResolverStatus = nw_resolver_status_invalid; + network_release(targetPrivate->lastResolvedEndpoints); + targetPrivate->lastResolvedEndpoints = NULL; + __SCNetworkReachabilityRestartResolver(targetPrivate); - // nwi - nwi_refresh_disable(); + targetPrivate = (SCNetworkReachabilityPrivateRef)CFRetain(targetPrivate); + nw_path_evaluator_set_cancel_handler(pathEvaluator, ^(void) { + MUTEX_LOCK(&targetPrivate->lock); + if (pathEvaluator == targetPrivate->pathEvaluator) { + targetPrivate->pathEvaluator = NULL; + } + network_release(pathEvaluator); + MUTEX_UNLOCK(&targetPrivate->lock); + CFRelease(targetPrivate); }); - } - unwatch : - - SCLog((_sc_debug && (_sc_log > 0)), LOG_INFO, CFSTR("%sunscheduled"), - targetPrivate->log_prefix); + if (!nw_path_evaluator_set_update_handler(pathEvaluator, targetPrivate->dispatchQueue, ^(nw_path_t path) { + MUTEX_LOCK(&targetPrivate->lock); + if (targetPrivate->scheduled) { + SCNetworkReachabilityFlags oldFlags = 0; + uint oldIFIndex = 0; + size_t oldEndpointCount = 0; + __SCNetworkReachabilityCopyPathStatus(targetPrivate, &oldFlags, &oldIFIndex, &oldEndpointCount); + + network_release(targetPrivate->lastPath); + targetPrivate->lastPath = network_retain(path); + if (targetPrivate->lastResolverStatus == nw_resolver_status_complete) { + targetPrivate->lastResolverStatus = nw_resolver_status_invalid; + __SCNetworkReachabilityRestartResolver(targetPrivate); + } - ok = TRUE; + if (__SCNetworkReachabilityShouldUpdateClient(targetPrivate, oldFlags, oldIFIndex, oldEndpointCount)) { + reachUpdateAndUnlock(targetPrivate); + } else { + MUTEX_UNLOCK(&targetPrivate->lock); + } + } else { + MUTEX_UNLOCK(&targetPrivate->lock); + } + })) { + targetPrivate->pathEvaluator = NULL; + network_release(pathEvaluator); + CFRelease(targetPrivate); + } + } else { + if (targetPrivate->dispatchQueue == NULL) { // if we should be scheduled on a dispatch queue (but are not) + _SCErrorSet(kSCStatusInvalidArgument); + goto done; + } - done : + if (!targetPrivate->scheduled) { + // if not currently scheduled + _SCErrorSet(kSCStatusInvalidArgument); + goto done; + } - MUTEX_UNLOCK(&targetPrivate->lock); - if (drainGroup != NULL) { - dispatch_group_notify(drainGroup, __SCNetworkReachability_concurrent_queue(), ^{ - // release group/queue references - dispatch_release(drainQueue); - dispatch_release(drainGroup); // releases our target reference - }); + targetPrivate->scheduled = FALSE; + targetPrivate->sentFirstUpdate = FALSE; + nw_path_evaluator_cancel(targetPrivate->pathEvaluator); + targetPrivate->pathEvaluator = NULL; + network_release(targetPrivate->lastPath); + targetPrivate->lastPath = NULL; + network_release(targetPrivate->lastPathParameters); + targetPrivate->lastPathParameters = NULL; + network_release(targetPrivate->lastResolvedEndpoints); + targetPrivate->lastResolvedEndpoints = NULL; + nw_resolver_cancel(targetPrivate->resolver); + targetPrivate->resolver = NULL; + if (targetPrivate->dispatchQueue != NULL) { + dispatch_release(targetPrivate->dispatchQueue); + targetPrivate->dispatchQueue = NULL; + } } - - // release our reference - CFRelease(target); - + ok = TRUE; +done: return ok; } Boolean -SCNetworkReachabilityScheduleWithRunLoop(SCNetworkReachabilityRef target, - CFRunLoopRef runLoop, - CFStringRef runLoopMode) -{ - if (!isA_SCNetworkReachability(target) || (runLoop == NULL) || (runLoopMode == NULL)) { - _SCErrorSet(kSCStatusInvalidArgument); - return FALSE; - } - - return __SCNetworkReachabilityScheduleWithRunLoop(target, runLoop, runLoopMode, NULL, FALSE); -} - -Boolean -SCNetworkReachabilityUnscheduleFromRunLoop(SCNetworkReachabilityRef target, - CFRunLoopRef runLoop, - CFStringRef runLoopMode) +SCNetworkReachabilitySetDispatchQueue(SCNetworkReachabilityRef target, + dispatch_queue_t queue) { - if (!isA_SCNetworkReachability(target) || (runLoop == NULL) || (runLoopMode == NULL)) { + if (!isA_SCNetworkReachability(target)) { _SCErrorSet(kSCStatusInvalidArgument); return FALSE; } - return __SCNetworkReachabilityUnscheduleFromRunLoop(target, runLoop, runLoopMode, FALSE); + SCNetworkReachabilityPrivateRef targetPrivate = (SCNetworkReachabilityPrivateRef)target; + MUTEX_LOCK(&targetPrivate->lock); + Boolean success = __SCNetworkReachabilitySetDispatchQueue(targetPrivate, queue); + MUTEX_UNLOCK(&targetPrivate->lock); + return success; } +/* + * _SC_checkResolverReachabilityByAddress() + * + * Given an IP address, determine whether a reverse DNS query can be issued + * using the current network configuration. + */ Boolean -SCNetworkReachabilitySetDispatchQueue(SCNetworkReachabilityRef target, - dispatch_queue_t queue) +_SC_checkResolverReachabilityByAddress(SCDynamicStoreRef *storeP, + SCNetworkReachabilityFlags *flags, + Boolean *haveDNS, + struct sockaddr *sa) { - Boolean ok = FALSE; - - if (!isA_SCNetworkReachability(target)) { - _SCErrorSet(kSCStatusInvalidArgument); - return FALSE; - } - - if (queue != NULL) { - ok = __SCNetworkReachabilityScheduleWithRunLoop(target, NULL, NULL, queue, FALSE); + nw_path_evaluator_t evaluator = nw_path_create_default_evaluator(); + nw_path_t path = nw_path_evaluator_copy_path(evaluator); + if (nw_path_get_status(path) == nw_path_status_unsatisfied_network) { + if (flags) { + *flags = 0; + } + if (haveDNS) { + *haveDNS = FALSE; + } } else { - ok = __SCNetworkReachabilityUnscheduleFromRunLoop(target, NULL, NULL, FALSE); + if (flags) { + *flags = kSCNetworkReachabilityFlagsReachable; + } + if (haveDNS) { + *haveDNS = TRUE; + } } + network_release(evaluator); + network_release(path); - return ok; + return TRUE; } + diff --git a/SystemConfiguration.fproj/SCNetworkReachability.h b/SystemConfiguration.fproj/SCNetworkReachability.h index 14c56c7..7024fc1 100644 --- a/SystemConfiguration.fproj/SCNetworkReachability.h +++ b/SystemConfiguration.fproj/SCNetworkReachability.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2005, 2008-2010 Apple Inc. All rights reserved. + * Copyright (c) 2003-2005, 2008-2010, 2015 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -33,6 +33,9 @@ #include #include +CF_IMPLICIT_BRIDGING_ENABLED +CF_ASSUME_NONNULL_BEGIN + /*! @header SCNetworkReachability @discussion The SCNetworkReachability API allows an application to @@ -52,7 +55,7 @@ @typedef SCNetworkReachabilityRef @discussion This is the handle to a network address or name. */ -typedef const struct __SCNetworkReachability * SCNetworkReachabilityRef; +typedef const struct CF_BRIDGED_TYPE(id) __SCNetworkReachability * SCNetworkReachabilityRef; /*! @@ -74,10 +77,10 @@ typedef const struct __SCNetworkReachability * SCNetworkReachabilityRef; */ typedef struct { CFIndex version; - void * info; - const void *(*retain)(const void *info); - void (*release)(const void *info); - CFStringRef (*copyDescription)(const void *info); + void * __nullable info; + const void * __nonnull (* __nullable retain)(const void *info); + void (* __nullable release)(const void *info); + CFStringRef __nonnull (* __nullable copyDescription)(const void *info); } SCNetworkReachabilityContext; /*! @@ -144,7 +147,7 @@ typedef struct { be reached via an EDGE, GPRS, or other "cell" connection. #endif // TARGET_OS_IPHONE */ -enum { +typedef CF_OPTIONS(uint32_t, SCNetworkReachabilityFlags) { kSCNetworkReachabilityFlagsTransientConnection = 1<<0, kSCNetworkReachabilityFlagsReachable = 1<<1, kSCNetworkReachabilityFlagsConnectionRequired = 1<<2, @@ -159,7 +162,6 @@ enum { kSCNetworkReachabilityFlagsConnectionAutomatic = kSCNetworkReachabilityFlagsConnectionOnTraffic }; -typedef uint32_t SCNetworkReachabilityFlags; /*! @typedef SCNetworkReachabilityCallBack @@ -172,9 +174,9 @@ typedef uint32_t SCNetworkReachabilityFlags; @param info A C pointer to a user-specified block of data. */ typedef void (*SCNetworkReachabilityCallBack) ( - SCNetworkReachabilityRef target, - SCNetworkReachabilityFlags flags, - void *info + SCNetworkReachabilityRef target, + SCNetworkReachabilityFlags flags, + void * __nullable info ); __BEGIN_DECLS @@ -189,10 +191,10 @@ __BEGIN_DECLS You must release the returned value. */ -SCNetworkReachabilityRef +SCNetworkReachabilityRef __nullable SCNetworkReachabilityCreateWithAddress ( - CFAllocatorRef allocator, - const struct sockaddr *address + CFAllocatorRef __nullable allocator, + const struct sockaddr *address ) __OSX_AVAILABLE_STARTING(__MAC_10_3,__IPHONE_2_0); /*! @@ -208,11 +210,11 @@ SCNetworkReachabilityCreateWithAddress ( You must release the returned value. */ -SCNetworkReachabilityRef +SCNetworkReachabilityRef __nullable SCNetworkReachabilityCreateWithAddressPair ( - CFAllocatorRef allocator, - const struct sockaddr *localAddress, - const struct sockaddr *remoteAddress + CFAllocatorRef __nullable allocator, + const struct sockaddr * __nullable localAddress, + const struct sockaddr * __nullable remoteAddress ) __OSX_AVAILABLE_STARTING(__MAC_10_3,__IPHONE_2_0); /*! @@ -227,10 +229,10 @@ SCNetworkReachabilityCreateWithAddressPair ( You must release the returned value. */ -SCNetworkReachabilityRef +SCNetworkReachabilityRef __nullable SCNetworkReachabilityCreateWithName ( - CFAllocatorRef allocator, - const char *nodename + CFAllocatorRef __nullable allocator, + const char *nodename ) __OSX_AVAILABLE_STARTING(__MAC_10_3,__IPHONE_2_0); /*! @@ -275,9 +277,9 @@ SCNetworkReachabilityGetFlags ( */ Boolean SCNetworkReachabilitySetCallback ( - SCNetworkReachabilityRef target, - SCNetworkReachabilityCallBack callout, - SCNetworkReachabilityContext *context + SCNetworkReachabilityRef target, + SCNetworkReachabilityCallBack __nullable callout, + SCNetworkReachabilityContext * __nullable context ) __OSX_AVAILABLE_STARTING(__MAC_10_3,__IPHONE_2_0); /*! @@ -331,10 +333,13 @@ SCNetworkReachabilityUnscheduleFromRunLoop ( */ Boolean SCNetworkReachabilitySetDispatchQueue ( - SCNetworkReachabilityRef target, - dispatch_queue_t queue + SCNetworkReachabilityRef target, + dispatch_queue_t __nullable queue ) __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_4_0); __END_DECLS +CF_ASSUME_NONNULL_END +CF_IMPLICIT_BRIDGING_DISABLED + #endif /* _SCNETWORKREACHABILITY_H */ diff --git a/SystemConfiguration.fproj/SCNetworkReachabilityInternal.h b/SystemConfiguration.fproj/SCNetworkReachabilityInternal.h index 9c88fb6..f3ef568 100644 --- a/SystemConfiguration.fproj/SCNetworkReachabilityInternal.h +++ b/SystemConfiguration.fproj/SCNetworkReachabilityInternal.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2014 Apple Inc. All rights reserved. + * Copyright (c) 2003-2015 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -39,17 +39,11 @@ #include #include - - +#include #pragma mark - #pragma mark SCNetworkReachability - -#define kSCNetworkReachabilityFlagsFirstResolvePending (1<<31) - - - #define kSCNetworkReachabilityFlagsMask 0x00ffffff // top 8-bits reserved for implementation @@ -72,16 +66,6 @@ typedef enum { #define isReachabilityTypeAddress(type) (type < reachabilityTypeName) #define isReachabilityTypeName(type) (type >= reachabilityTypeName) - -typedef struct { - uint64_t cycle; - SCNetworkReachabilityFlags flags; - unsigned int if_index; - char if_name[IFNAMSIZ]; - Boolean sleeping; -} ReachabilityInfo; - - typedef struct { /* base CFType information */ @@ -90,194 +74,43 @@ typedef struct { /* lock */ pthread_mutex_t lock; - /* logging */ - Boolean quiet; - /* address type */ ReachabilityAddressType type; /* target host name */ - const char *name; - Boolean needResolve; - CFArrayRef resolvedAddresses; /* CFArray[CFData] or CFArray[CFString] */ - int resolvedError; - SCNetworkReachabilityFlags resolverFlags; - - /* [scoped routing] interface constraints */ - unsigned int if_index; - char if_name[IFNAMSIZ]; + nw_endpoint_t hostnameEndpoint; /* local & remote addresses */ - struct sockaddr *localAddress; - struct sockaddr *remoteAddress; - - /* current reachability flags */ - uint64_t cycle; - ReachabilityInfo info; - ReachabilityInfo last_notify; + nw_endpoint_t localAddressEndpoint; + nw_endpoint_t remoteAddressEndpoint; /* run loop source, callout, context, rl scheduling info */ Boolean scheduled; + Boolean sentFirstUpdate; CFRunLoopSourceRef rls; SCNetworkReachabilityCallBack rlsFunction; SCNetworkReachabilityContext rlsContext; CFMutableArrayRef rlList; - unsigned int pending; // 0 == no notifications queued, else # to be delivered - dispatch_group_t dispatchGroup; dispatch_queue_t dispatchQueue; // SCNetworkReachabilitySetDispatchQueue - /* [async] DNS query info */ - Boolean haveDNS; - struct timeval dnsQueryStart; - struct timeval dnsQueryEnd; - - /* [async] processing info */ - struct timeval last_dns; - struct timeval last_network; -#if !TARGET_OS_IPHONE - struct timeval last_power; -#endif // !TARGET_OS_IPHONE - struct timeval last_push; - - /* on demand info */ - Boolean onDemandBypass; - CFStringRef onDemandName; - CFStringRef onDemandRemoteAddress; - SCNetworkReachabilityRef onDemandServer; - CFStringRef onDemandServiceID; - - - union { - uint32_t dnsFlags; - struct { - Boolean dnsActive :1; // if DNSServiceGetAddrInfo active - - Boolean dnsHaveError :1; // error during query - Boolean dnsHaveV4 :1; // have IPv4 (A) reply - Boolean dnsHaveV6 :1; // have IPv6 (AAAA) reply - Boolean dnsHavePTR :1; // have PTR reply - Boolean dnsHaveTimeout:1; // no replies (A, AAAA, or PTR) - }; - }; - CFArrayRef dnsAddresses; // CFArray[CFData] - Boolean dnsBlocked; // if DNS query blocked - int dnsError; - int dnsFailures; // # of unexpected DNSServiceXXX errors - int dnsGeneration; - DNSServiceRef dnsTarget; - Boolean dnsNoAddressesSinceLastTimeout; - - /* SCNetworkReachability server "client" info */ - Boolean serverActive; - Boolean serverBypass; - Boolean serverScheduled; - ReachabilityInfo serverInfo; - - /* SCNetworkReachability server "server" info */ - CFDataRef serverDigest; - dispatch_group_t serverGroup; - Boolean serverInfoValid; - unsigned int serverSyncQueryActive; // 0 == no [sync] query active, else # waiting on group - dispatch_queue_t serverQueue; - unsigned int serverReferences; // how many [client] targets - CFMutableDictionaryRef serverWatchers; // [client_id/target_id] watchers - - Boolean useNEVPN; - uid_t uid; - void *nePolicyResult; - Boolean serverBypassForVPN; // if serverBypassForVPN, only use client mode - Boolean resolverBypass; // set this flag to bypass resolving the name - - /* logging */ char log_prefix[32]; -} SCNetworkReachabilityPrivate, *SCNetworkReachabilityPrivateRef; - - - -// ------------------------------------------------------------ - -#pragma mark - -#pragma mark [XPC] Reachability Server - - -#define REACH_SERVER_VERSION 20110323 - -#if !TARGET_IPHONE_SIMULATOR -#define REACH_SERVICE_NAME "com.apple.SystemConfiguration.SCNetworkReachability" -#else // !TARGET_IPHONE_SIMULATOR -#define REACH_SERVICE_NAME "com.apple.SystemConfiguration.SCNetworkReachability_sim" -#endif // !TARGET_IPHONE_SIMULATOR - -// ------------------------------------------------------------ - - -#pragma mark - -#pragma mark [XPC] Reachability Server (client->server request) - - -#define REACH_CLIENT_PROC_NAME "proc_name" // string -#define REACH_CLIENT_TARGET_ID "target_id" // uint64 - -#define REACH_REQUEST "request_op" // int64 - -enum { - REACH_REQUEST_CREATE = 0x0001, - REACH_REQUEST_REMOVE, - REACH_REQUEST_SCHEDULE, - REACH_REQUEST_STATUS, - REACH_REQUEST_UNSCHEDULE, - REACH_REQUEST_SNAPSHOT = 0x0101, -}; - -#define REACH_TARGET_NAME "name" // string - -#define REACH_TARGET_LOCAL_ADDR "local_address" // data (struct sockaddr) -#define REACH_TARGET_REMOTE_ADDR "remote_address" // data (struct sockaddr) - -#define REACH_TARGET_PTR_ADDR "ptr_address" // data (struct sockaddr) - -#define REACH_TARGET_IF_INDEX "if_index" // int64 -#define REACH_TARGET_IF_NAME "if_name" // string -#define REACH_TARGET_ONDEMAND_BYPASS "ondemand_bypass" // bool -#define REACH_TARGET_RESOLVER_BYPASS "resolver_bypass" // bool - - -#define REACH_REQUEST_REPLY "reply" // int64 -#define REACH_REQUEST_REPLY_DETAIL "reply_detail" // string - -enum { - REACH_REQUEST_REPLY_OK = 0x0000, - REACH_REQUEST_REPLY_FAILED, - REACH_REQUEST_REPLY_UNKNOWN, -}; - - -// ------------------------------------------------------------ - + nw_parameters_t parameters; + nw_path_evaluator_t pathEvaluator; + nw_path_t lastPath; + nw_parameters_t lastPathParameters; + nw_resolver_t resolver; + nw_resolver_status_t lastResolverStatus; + nw_array_t lastResolvedEndpoints; + Boolean lastResolvedEndpointHasFlags; + SCNetworkReachabilityFlags lastResolvedEndpointFlags; + uint lastResolvedEndpointInterfaceIndex; -#pragma mark - -#pragma mark [XPC] Reachability Server (server->client request) - - -#define MESSAGE_NOTIFY "notify_op" // int64 - -enum { - MESSAGE_REACHABILITY_STATUS = 0x1001, -}; - -#define REACH_STATUS_CYCLE "cycle" // uint64 -#define REACH_STATUS_DNS_FLAGS "dns_flags" // uint64 -#define REACH_STATUS_FLAGS "flags" // uint64 -#define REACH_STATUS_IF_INDEX "if_index" // uint64 -#define REACH_STATUS_IF_NAME "if_name" // data (char if_name[IFNAMSIZ]) -#define REACH_STATUS_RESOLVED_ADDRESSES "resolved_addresses" // array[data] -#define REACH_STATUS_RESOLVED_ERROR "resolved_error" // int64 -#define REACH_STATUS_SLEEPING "sleeping" // bool +} SCNetworkReachabilityPrivate, *SCNetworkReachabilityPrivateRef; // ------------------------------------------------------------ @@ -288,107 +121,78 @@ __BEGIN_DECLS CFStringRef _SCNetworkReachabilityCopyTargetDescription (SCNetworkReachabilityRef target); -CFStringRef -_SCNetworkReachabilityCopyTargetFlags (SCNetworkReachabilityRef target); - -void -__SCNetworkReachabilityUpdate (SCNetworkReachabilityRef target); - -void -__SCNetworkReachabilityUpdateConcurrent (SCNetworkReachabilityRef target); - -dispatch_queue_t -__SCNetworkReachability_concurrent_queue (void); - -#pragma mark - -#pragma mark [XPC] Reachability Server (client APIs) -Boolean -_SCNetworkReachabilityServer_snapshot (void); - -Boolean -__SCNetworkReachabilityServer_targetAdd (SCNetworkReachabilityRef target); - -void -__SCNetworkReachabilityServer_targetRemove (SCNetworkReachabilityRef target); - -Boolean -__SCNetworkReachabilityServer_targetSchedule (SCNetworkReachabilityRef target); - -Boolean -__SCNetworkReachabilityServer_targetStatus (SCNetworkReachabilityRef target); - -Boolean -__SCNetworkReachabilityServer_targetUnschedule (SCNetworkReachabilityRef target); - - -Boolean -__SC_checkResolverReachabilityInternal (SCDynamicStoreRef *storeP, - SCNetworkReachabilityFlags *flags, - Boolean *haveDNS, - const char *nodename, - uint32_t *resolver_if_index, - int *dns_config_index); - -static __inline__ void -__SCNetworkReachabilityPrintFlags(SCNetworkReachabilityFlags flags) +static __inline__ CFStringRef +__SCNetworkReachabilityCopyFlags(SCNetworkReachabilityFlags flags, CFStringRef prefix, Boolean debug) { - if (flags != 0) { - if (flags & kSCNetworkReachabilityFlagsReachable) { - SCPrint(TRUE, stdout, CFSTR("Reachable")); - flags &= ~kSCNetworkReachabilityFlagsReachable; - SCPrint(flags != 0, stdout, CFSTR(",")); - } - if (flags & kSCNetworkReachabilityFlagsTransientConnection) { - SCPrint(TRUE, stdout, CFSTR("Transient Connection")); - flags &= ~kSCNetworkReachabilityFlagsTransientConnection; - SCPrint(flags != 0, stdout, CFSTR(",")); - } - if (flags & kSCNetworkReachabilityFlagsConnectionRequired) { - SCPrint(TRUE, stdout, CFSTR("Connection Required")); - flags &= ~kSCNetworkReachabilityFlagsConnectionRequired; - SCPrint(flags != 0, stdout, CFSTR(",")); - } - if (flags & kSCNetworkReachabilityFlagsConnectionOnTraffic) { - SCPrint(TRUE, stdout, CFSTR("Automatic Connection On Traffic")); - flags &= ~kSCNetworkReachabilityFlagsConnectionOnTraffic; - SCPrint(flags != 0, stdout, CFSTR(",")); - } - if (flags & kSCNetworkReachabilityFlagsConnectionOnDemand) { - SCPrint(TRUE, stdout, CFSTR("Automatic Connection On Demand")); - flags &= ~kSCNetworkReachabilityFlagsConnectionOnDemand; - SCPrint(flags != 0, stdout, CFSTR(",")); - } - if (flags & kSCNetworkReachabilityFlagsInterventionRequired) { - SCPrint(TRUE, stdout, CFSTR("Intervention Required")); - flags &= ~kSCNetworkReachabilityFlagsInterventionRequired; - SCPrint(flags != 0, stdout, CFSTR(",")); - } - if (flags & kSCNetworkReachabilityFlagsIsLocalAddress) { - SCPrint(TRUE, stdout, CFSTR("Local Address")); - flags &= ~kSCNetworkReachabilityFlagsIsLocalAddress; - SCPrint(flags != 0, stdout, CFSTR(",")); - } - if (flags & kSCNetworkReachabilityFlagsIsDirect) { - SCPrint(TRUE, stdout, CFSTR("Directly Reachable Address")); - flags &= ~kSCNetworkReachabilityFlagsIsDirect; - SCPrint(flags != 0, stdout, CFSTR(",")); + CFMutableStringRef str = CFStringCreateMutable(NULL, 0); + + if (debug) { + if (prefix != NULL) { + CFStringAppend(str, prefix); } + + CFStringAppendFormat(str, NULL, CFSTR("0x%08x ("), flags); + } + + if (flags == 0) { + CFStringAppend(str, CFSTR("Not Reachable")); + } + if (flags & kSCNetworkReachabilityFlagsReachable) { + flags &= ~kSCNetworkReachabilityFlagsReachable; + CFStringAppendFormat(str, NULL, CFSTR("Reachable%s"), + flags != 0 ? ", " : ""); + } + if (flags & kSCNetworkReachabilityFlagsTransientConnection) { + flags &= ~kSCNetworkReachabilityFlagsTransientConnection; + CFStringAppendFormat(str, NULL, CFSTR("Transient Connection%s"), + flags != 0 ? ", " : ""); + } + if (flags & kSCNetworkReachabilityFlagsConnectionRequired) { + flags &= ~kSCNetworkReachabilityFlagsConnectionRequired; + CFStringAppendFormat(str, NULL, CFSTR("Connection Required%s"), + flags != 0 ? ", " : ""); + } + if (flags & kSCNetworkReachabilityFlagsConnectionOnTraffic) { + flags &= ~kSCNetworkReachabilityFlagsConnectionOnTraffic; + CFStringAppendFormat(str, NULL, CFSTR("Automatic Connection On Traffic%s"), + flags != 0 ? ", " : ""); + } + if (flags & kSCNetworkReachabilityFlagsConnectionOnDemand) { + flags &= ~kSCNetworkReachabilityFlagsConnectionOnDemand; + CFStringAppendFormat(str, NULL, CFSTR("Automatic Connection On Demand%s"), + flags != 0 ? ", " : ""); + } + if (flags & kSCNetworkReachabilityFlagsInterventionRequired) { + flags &= ~kSCNetworkReachabilityFlagsInterventionRequired; + CFStringAppendFormat(str, NULL, CFSTR("Intervention Required%s"), + flags != 0 ? ", " : ""); + } + if (flags & kSCNetworkReachabilityFlagsIsLocalAddress) { + flags &= ~kSCNetworkReachabilityFlagsIsLocalAddress; + CFStringAppendFormat(str, NULL, CFSTR("Local Address%s"), + flags != 0 ? ", " : ""); + } + if (flags & kSCNetworkReachabilityFlagsIsDirect) { + flags &= ~kSCNetworkReachabilityFlagsIsDirect; + CFStringAppendFormat(str, NULL, CFSTR("Directly Reachable Address%s"), + flags != 0 ? ", " : ""); + } #if TARGET_OS_IPHONE - if (flags & kSCNetworkReachabilityFlagsIsWWAN) { - SCPrint(TRUE, stdout, CFSTR("WWAN")); - flags &= ~kSCNetworkReachabilityFlagsIsWWAN; - SCPrint(flags != 0, stdout, CFSTR(",")); - } + if (flags & kSCNetworkReachabilityFlagsIsWWAN) { + flags &= ~kSCNetworkReachabilityFlagsIsWWAN; + CFStringAppendFormat(str, NULL, CFSTR("WWAN%s"), flags != 0 ? ", " : ""); + } #endif // TARGET_OS_IPHONE - if (flags != 0) { - SCPrint(TRUE, stdout, CFSTR("0x%08x"), flags); - } - } else { - SCPrint(TRUE, stdout, CFSTR("Not Reachable")); + if (flags != 0) { + CFStringAppendFormat(str, NULL, CFSTR("0x%08x"), flags); + } + + if (debug) { + CFStringAppend(str, CFSTR(")")); } - return; + return str; } diff --git a/SystemConfiguration.fproj/SCNetworkService.c b/SystemConfiguration.fproj/SCNetworkService.c index 489ee39..fe257c4 100644 --- a/SystemConfiguration.fproj/SCNetworkService.c +++ b/SystemConfiguration.fproj/SCNetworkService.c @@ -1,15 +1,15 @@ /* - * Copyright (c) 2004-2014 Apple Inc. All rights reserved. + * Copyright (c) 2004-2015 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ - * + * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. - * + * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, @@ -17,7 +17,7 @@ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. - * + * * @APPLE_LICENSE_HEADER_END@ */ @@ -458,21 +458,16 @@ SCNetworkServiceCopyAll(SCPreferencesRef prefs) SCNetworkServicePrivateRef servicePrivate; if (!isA_CFDictionary(vals[i])) { - SCLog(TRUE, - LOG_INFO, - CFSTR("SCNetworkServiceCopyAll(): error w/service \"%@\"\n"), - keys[i]); + SC_log(LOG_INFO, "error w/service \"%@\"", keys[i]); continue; } entity = CFDictionaryGetValue(vals[i], kSCEntNetInterface); if (!isA_CFDictionary(entity)) { // if no "interface" - SCLog(TRUE, - LOG_INFO, - CFSTR("SCNetworkServiceCopyAll(): no \"%@\" entity for service \"%@\"\n"), - kSCEntNetInterface, - keys[i]); + SC_log(LOG_INFO, "no \"%@\" entity for service \"%@\"", + kSCEntNetInterface, + keys[i]); continue; } @@ -903,9 +898,8 @@ SCNetworkServiceCreate(SCPreferencesRef prefs, SCNetworkInterfaceRef interface) } if (!__SCNetworkInterfaceSetConfiguration(interface, NULL, config, TRUE)) { - SCLog(TRUE, LOG_DEBUG, - CFSTR("SCNetworkService __SCNetworkInterfaceSetConfiguration failed(), interface=%@, type=NULL"), - interface); + SC_log(LOG_INFO, "__SCNetworkInterfaceSetConfiguration failed(), interface=%@, type=NULL", + interface); } CFRelease(config); } @@ -1084,7 +1078,7 @@ SCNetworkServiceGetName(SCNetworkServiceRef service) useSystemInterfaces = ((__SCPreferencesUsingDefaultPrefs(servicePrivate->prefs)) && (__SCPreferencesGetLimitSCNetworkConfiguration(servicePrivate->prefs) == FALSE)); - + if (isA_CFDictionary(entity)) { name = CFDictionaryGetValue(entity, kSCPropUserDefinedName); if (isA_CFString(name)) { @@ -2058,7 +2052,7 @@ copyInterfaceConfiguration(SCNetworkServiceRef oldService, SCNetworkServiceRef n if ((configuration != NULL) || (SCError() == kSCStatusOK)) { if (SCNetworkInterfaceSetConfiguration(newInterface, configuration) == FALSE) { - SCLog(_sc_debug, LOG_DEBUG, CFSTR("problem setting interface configuration")); + SC_log(LOG_INFO, "problem setting interface configuration"); } } @@ -2079,7 +2073,7 @@ copyInterfaceConfiguration(SCNetworkServiceRef oldService, SCNetworkServiceRef n if ((configuration != NULL) || (SCError() == kSCStatusOK)) { if (SCNetworkInterfaceSetExtendedConfiguration(newInterface, kSCEntNetIPSec, configuration) == FALSE) { - SCLog(_sc_debug, LOG_DEBUG, CFSTR("problem setting child interface configuration")); + SC_log(LOG_INFO, "problem setting child interface configuration"); } } } @@ -2128,8 +2122,9 @@ copyInterfaceConfiguration(SCNetworkServiceRef oldService, SCNetworkServiceRef n return; } -static void -addProtocolToService(SCNetworkServiceRef service, CFStringRef protocolType, CFDictionaryRef configuration, Boolean enabled) +__private_extern__ +void +__SCNetworkServiceAddProtocolToService(SCNetworkServiceRef service, CFStringRef protocolType, CFDictionaryRef configuration, Boolean enabled) { Boolean ok; SCNetworkProtocolRef protocol; @@ -2193,18 +2188,17 @@ __SCNetworkServiceMigrateNew(SCPreferencesRef prefs, newService = SCNetworkServiceCopy(prefs, serviceID); if (newService != NULL) { // Cannot add service if it already exists - SCLog(TRUE, LOG_DEBUG, CFSTR("__SCNetworkServiceMigrateNew: Cannot add service if it already exists.")); + SC_log(LOG_INFO, "Service already exists"); goto done; } oldInterface = SCNetworkServiceGetInterface(service); interfaceEntity = __SCNetworkInterfaceCopyInterfaceEntity(oldInterface); if (interfaceEntity == NULL) { - SCLog(TRUE, LOG_DEBUG, CFSTR("__SCNetworkServiceMigrateNew: interfaceEntity does not exist")); + SC_log(LOG_INFO, "No interface entity"); goto done; } interfaceEntityMutable = CFDictionaryCreateMutableCopy(NULL, 0, interfaceEntity); - CFRelease(interfaceEntity); if (isA_CFDictionary(bsdMapping) != NULL) { deviceName = CFDictionaryGetValue(interfaceEntityMutable, kSCPropNetInterfaceDeviceName); @@ -2238,28 +2232,27 @@ __SCNetworkServiceMigrateNew(SCPreferencesRef prefs, } } newService = SCNetworkServiceCreate(prefs, interface); - if (newService == NULL) { - SCLog(TRUE, LOG_DEBUG, CFSTR("__SCNetworkServiceMigrateNew: Could not create new service")); + SC_log(LOG_INFO, "SCNetworkServiceCreate() failed"); goto done; } enabled = SCNetworkServiceGetEnabled(service); SCNetworkServiceSetEnabled(newService, enabled); - + if (SCNetworkServiceEstablishDefaultConfiguration(newService) == FALSE) { SCNetworkServiceRemove(newService); - SCLog(TRUE, LOG_DEBUG, CFSTR("__SCNetworkServiceMigrateNew: SCNetworkServiceEstablishDefaultConfiguration failed")); + SC_log(LOG_INFO, "SCNetworkServiceEstablishDefaultConfiguration() failed"); goto done; } - + // Set service ID _SCNetworkServiceSetServiceID(newService, serviceID); userDefinedName = SCNetworkServiceGetName(service); if (userDefinedName != NULL && SCNetworkServiceSetName(newService, userDefinedName) == FALSE) { - SCLog(TRUE, LOG_DEBUG, CFSTR("__SCNetworkServiceMigrateNew: Could not set service name to %@"), userDefinedName); + SC_log(LOG_INFO, "SCNetworkServiceSetName(, %@) failed", userDefinedName); } // Determine which sets to add service @@ -2270,18 +2263,18 @@ __SCNetworkServiceMigrateNew(SCPreferencesRef prefs, for (CFIndex idx = 0; idx < CFArrayGetCount(setList); idx++) { oldSet = CFArrayGetValueAtIndex(setList, idx); newSet = CFDictionaryGetValue(setMapping, oldSet); - + if (newSet == NULL) { continue; } if (SCNetworkSetAddService(newSet, newService) == FALSE) { - SCLog(_sc_debug, LOG_DEBUG, CFSTR("__SCNetworkServiceMigrateNew: Could not add service to set: %@"), newSet); + SC_log(LOG_INFO, "SCNetworkSetAddService() failed"); continue; } } } } - + protocols = SCNetworkServiceCopyProtocols(service); if (protocols != NULL) { @@ -2290,7 +2283,7 @@ __SCNetworkServiceMigrateNew(SCPreferencesRef prefs, CFDictionaryRef configuration = SCNetworkProtocolGetConfiguration(protocol); CFStringRef protocolType = SCNetworkProtocolGetProtocolType(protocol); enabled = SCNetworkProtocolGetEnabled(protocol); - addProtocolToService(newService, protocolType, configuration, enabled); + __SCNetworkServiceAddProtocolToService(newService, protocolType, configuration, enabled); } CFRelease(protocols); } @@ -2302,6 +2295,9 @@ done: if (interface != NULL) { CFRelease(interface); } + if (interfaceEntity != NULL) { + CFRelease(interfaceEntity); + } if (interfaceEntityMutable != NULL) { CFRelease(interfaceEntityMutable); } @@ -2338,31 +2334,31 @@ __SCNetworkServiceCreate(SCPreferencesRef prefs, if (userDefinedName == NULL) { userDefinedName = __SCNetworkInterfaceGetUserDefinedName(interface); if (userDefinedName == NULL) { - SCLog(TRUE, LOG_DEBUG, CFSTR("__SCNetworkServiceCreate: userDefinedName is NULL")); + SC_log(LOG_INFO, "No userDefinedName"); goto done; } } service = SCNetworkServiceCreate(prefs, interface); if (service == NULL) { - SCLog(TRUE, LOG_DEBUG, CFSTR("__SCNetworkServiceCreate: Failed to create service: %s"), SCErrorString(SCError())); + SC_log(LOG_INFO, "SCNetworkServiceCreate() failed: %s", SCErrorString(SCError())); } else { ok = SCNetworkServiceSetName(service, userDefinedName); if (ok == FALSE) { - SCLog(TRUE, LOG_DEBUG, CFSTR("__SCNetworkServiceCreate: Failed to set name: %s"), SCErrorString(SCError())); + SC_log(LOG_INFO, "SCNetworkServiceSetName() failed: %s", SCErrorString(SCError())); SCNetworkServiceRemove(service); goto done; } ok = SCNetworkServiceEstablishDefaultConfiguration(service); if (ok == FALSE) { - SCLog(TRUE, LOG_DEBUG, CFSTR("__SCNetworkServiceCreate: Failed to establish default configuration: %s"), SCErrorString(SCError())); + SC_log(LOG_INFO, "SCNetworkServiceEstablishDefaultConfiguration() failed: %s", SCErrorString(SCError())); SCNetworkServiceRemove(service); goto done; } } currentSet = SCNetworkSetCopyCurrent(prefs); if (currentSet == NULL) { - SCLog(TRUE, LOG_DEBUG, CFSTR("__SCNetworkServiceCreate: Could not copy current set")); + SC_log(LOG_INFO, "No current set"); if (service != NULL) { SCNetworkServiceRemove(service); } @@ -2371,7 +2367,7 @@ __SCNetworkServiceCreate(SCPreferencesRef prefs, if (service != NULL) { ok = SCNetworkSetAddService(currentSet, service); if (ok == FALSE) { - SCLog(TRUE, LOG_DEBUG, CFSTR("__SCNetworkServiceCreate: Could not add service to the current set")); + SC_log(LOG_INFO, "Could not add service to the current set"); SCNetworkServiceRemove(service); goto done; } diff --git a/SystemConfiguration.fproj/SCNetworkSet.c b/SystemConfiguration.fproj/SCNetworkSet.c index d9576f6..3a2ff97 100644 --- a/SystemConfiguration.fproj/SCNetworkSet.c +++ b/SystemConfiguration.fproj/SCNetworkSet.c @@ -1,15 +1,15 @@ /* - * Copyright (c) 2004-2014 Apple Inc. All rights reserved. + * Copyright (c) 2004-2015 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ - * + * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. - * + * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, @@ -17,7 +17,7 @@ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. - * + * * @APPLE_LICENSE_HEADER_END@ */ @@ -361,8 +361,7 @@ ensure_unique_service_name(SCNetworkServiceRef service) } if (SCError() != kSCStatusKeyExists) { - SCLog(TRUE, LOG_DEBUG, - CFSTR("could not update service name for \"%@\": %s"), + SC_log(LOG_INFO, "could not update service name for \"%@\": %s", SCNetworkInterfaceGetLocalizedDisplayName(interface), SCErrorString(SCError())); break; @@ -370,8 +369,7 @@ ensure_unique_service_name(SCNetworkServiceRef service) newName = copy_next_name(name); if (newName == NULL) { - SCLog(TRUE, LOG_DEBUG, - CFSTR("could not create unique name for \"%@\": %s"), + SC_log(LOG_INFO, "could not create unique name for \"%@\": %s", SCNetworkInterfaceGetLocalizedDisplayName(interface), SCErrorString(SCError())); break; @@ -587,10 +585,7 @@ SCNetworkSetCopyAll(SCPreferencesRef prefs) SCNetworkSetPrivateRef setPrivate; if (!isA_CFDictionary(vals[i])) { - SCLog(TRUE, - LOG_INFO, - CFSTR("SCNetworkSetCopyAll(): error w/set \"%@\"\n"), - keys[i]); + SC_log(LOG_INFO, "error w/set \"%@\"", keys[i]); continue; } @@ -713,7 +708,7 @@ SCNetworkSetCopyCurrent(SCPreferencesRef prefs) // mark set as "old" (already established) setPrivate->established = TRUE; } else { - SCLog(TRUE, LOG_ERR, CFSTR("SCNetworkSetCopyCurrent(): preferences are non-conformant")); + SC_log(LOG_NOTICE, "SCNetworkSetCopyCurrent(): preferences are non-conformant"); } CFRelease(path); } @@ -767,11 +762,9 @@ SCNetworkSetCopyServices(SCNetworkSetRef set) link = SCPreferencesPathGetLink(setPrivate->prefs, path); CFRelease(path); if (link == NULL) { - SCLog(TRUE, - LOG_INFO, - CFSTR("SCNetworkSetCopyServices(): service \"%@\" for set \"%@\" is not a link\n"), - keys[i], - setPrivate->setID); + SC_log(LOG_INFO, "service \"%@\" for set \"%@\" is not a link", + keys[i], + setPrivate->setID); continue; // if the service is not a link } @@ -1560,10 +1553,9 @@ __SCNetworkSetEstablishDefaultConfigurationForInterfaces(SCNetworkSetRef set, CF ok = SCBridgeInterfaceSetMemberInterfaces(bridge, newMembers); CFRelease(newMembers); if (!ok) { - SCLog(TRUE, LOG_DEBUG, - CFSTR("could not update bridge with \"%@\": %s\n"), - SCNetworkInterfaceGetLocalizedDisplayName(interface), - SCErrorString(SCError())); + SC_log(LOG_INFO, "could not update bridge with \"%@\": %s", + SCNetworkInterfaceGetLocalizedDisplayName(interface), + SCErrorString(SCError())); CFRelease(bridge); continue; } @@ -1636,20 +1628,18 @@ __SCNetworkSetEstablishDefaultConfigurationForInterfaces(SCNetworkSetRef set, CF service = SCNetworkServiceCreate(setPrivate->prefs, interface); if (service == NULL) { - SCLog(TRUE, LOG_DEBUG, - CFSTR("could not create service for \"%@\": %s\n"), - SCNetworkInterfaceGetLocalizedDisplayName(interface), - SCErrorString(SCError())); + SC_log(LOG_INFO, "could not create service for \"%@\": %s", + SCNetworkInterfaceGetLocalizedDisplayName(interface), + SCErrorString(SCError())); ok = FALSE; goto nextInterface; } ok = SCNetworkServiceEstablishDefaultConfiguration(service); if (!ok) { - SCLog(TRUE, LOG_DEBUG, - CFSTR("could not estabish default configuration for \"%@\": %s\n"), - SCNetworkInterfaceGetLocalizedDisplayName(interface), - SCErrorString(SCError())); + SC_log(LOG_INFO, "could not estabish default configuration for \"%@\": %s", + SCNetworkInterfaceGetLocalizedDisplayName(interface), + SCErrorString(SCError())); SCNetworkServiceRemove(service); CFRelease(service); goto nextInterface; @@ -1657,10 +1647,9 @@ __SCNetworkSetEstablishDefaultConfigurationForInterfaces(SCNetworkSetRef set, CF ok = SCNetworkSetAddService(set, service); if (!ok) { - SCLog(TRUE, LOG_DEBUG, - CFSTR("could not add service for \"%@\": %s\n"), - SCNetworkInterfaceGetLocalizedDisplayName(interface), - SCErrorString(SCError())); + SC_log(LOG_INFO, "could not add service for \"%@\": %s", + SCNetworkInterfaceGetLocalizedDisplayName(interface), + SCErrorString(SCError())); SCNetworkServiceRemove(service); CFRelease(service); goto nextInterface; diff --git a/SystemConfiguration.fproj/SCNetworkSignature.c b/SystemConfiguration.fproj/SCNetworkSignature.c index 4e2541f..b5bebd6 100644 --- a/SystemConfiguration.fproj/SCNetworkSignature.c +++ b/SystemConfiguration.fproj/SCNetworkSignature.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2008, 2009, 2011-2014 Apple Inc. All rights reserved. + * Copyright (c) 2006, 2008, 2009, 2011-2015 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -413,7 +413,7 @@ SCNetworkSignatureCopyIdentifierForConnectedSocket(CFAllocatorRef alloc, CFDictionaryRef service_info = NULL; int status = kSCStatusFailed; - if (copyconninfo(sock_fd, CONNID_ANY, &info) != 0) { + if (copyconninfo(sock_fd, SAE_CONNID_ANY, &info) != 0) { status = kSCStatusInvalidArgument; goto done; } diff --git a/SystemConfiguration.fproj/SCP.c b/SystemConfiguration.fproj/SCP.c index bc55bb0..b48b1a2 100644 --- a/SystemConfiguration.fproj/SCP.c +++ b/SystemConfiguration.fproj/SCP.c @@ -1,15 +1,15 @@ /* - * Copyright (c) 2000, 2001, 2003-2005, 2007-2009, 2011, 2014 Apple Inc. All rights reserved. + * Copyright (c) 2000, 2001, 2003-2005, 2007-2009, 2011, 2014, 2015 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ - * + * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. - * + * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, @@ -17,7 +17,7 @@ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. - * + * * @APPLE_LICENSE_HEADER_END@ */ @@ -106,11 +106,11 @@ __SCPreferencesPath(CFAllocatorRef allocator, pathStr = _SC_cfstring_to_cstring(path, NULL, 0, kCFStringEncodingASCII); if (pathStr == NULL) { CFIndex pathLen; - + pathLen = CFStringGetMaximumSizeOfFileSystemRepresentation(path); - pathStr = CFAllocatorAllocate(NULL, pathLen, 0); + pathStr = CFAllocatorAllocate(NULL, pathLen, 0); if (CFStringGetFileSystemRepresentation(path, pathStr, pathLen) == FALSE) { - SCLog(_sc_verbose, LOG_DEBUG, CFSTR("could not convert path to C string")); + SC_log(LOG_INFO, "could not convert path to C string"); CFAllocatorDeallocate(NULL, pathStr); pathStr = NULL; } @@ -168,16 +168,16 @@ __SCPreferencesCreateNIPrefsFromPrefs(SCPreferencesRef prefs) SCPreferencesRef ni_prefs = NULL; SCPreferencesPrivateRef prefsPrivate = (SCPreferencesPrivateRef)prefs; char * prefsPath = __SCPreferencesPath(NULL, prefsPrivate->prefsID, FALSE); - - + + newPath = CFStringCreateMutable(NULL, 0); CFStringAppendFormat(newPath, NULL, CFSTR("%s"), prefsPath); - + CFStringFindAndReplace(newPath, PREFS_DEFAULT_CONFIG, NETWORK_INTERFACES_PREFS, CFRangeMake(0, CFStringGetLength(newPath)), kCFCompareBackwards); - + newURL = CFURLCreateWithFileSystemPath(NULL, newPath, kCFURLPOSIXPathStyle, FALSE); if (CFURLResourceIsReachable(newURL, NULL) == FALSE) { ni_prefs = __SCNetworkCreateDefaultNIPrefs(newPath); @@ -188,7 +188,7 @@ __SCPreferencesCreateNIPrefsFromPrefs(SCPreferencesRef prefs) CFAllocatorDeallocate(NULL, prefsPath); CFRelease(newPath); CFRelease(newURL); - + return ni_prefs; } diff --git a/SystemConfiguration.fproj/SCPApply.c b/SystemConfiguration.fproj/SCPApply.c index f913dc9..0c39499 100644 --- a/SystemConfiguration.fproj/SCPApply.c +++ b/SystemConfiguration.fproj/SCPApply.c @@ -1,15 +1,15 @@ /* - * Copyright (c) 2000, 2001, 2004-2006, 2010 Apple Inc. All rights reserved. + * Copyright (c) 2000, 2001, 2004-2006, 2010, 2015 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ - * + * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. - * + * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, @@ -17,7 +17,7 @@ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. - * + * * @APPLE_LICENSE_HEADER_END@ */ @@ -103,7 +103,7 @@ SCPreferencesApplyChanges(SCPreferencesRef prefs) wasLocked = prefsPrivate->locked; if (!wasLocked) { if (!SCPreferencesLock(prefs, TRUE)) { - SCLog(_sc_verbose, LOG_DEBUG, CFSTR("SCPreferencesApplyChanges SCPreferencesLock() failed")); + SC_log(LOG_INFO, "SCPreferencesLock() failed"); return FALSE; } } @@ -114,14 +114,10 @@ SCPreferencesApplyChanges(SCPreferencesRef prefs) } /* post notification */ - if (prefsPrivate->session == NULL) { - ok = TRUE; - } else { - ok = SCDynamicStoreNotifyValue(prefsPrivate->session, prefsPrivate->sessionKeyApply); - if (!ok) { - SCLog(_sc_verbose, LOG_DEBUG, CFSTR("SCPreferencesApplyChanges SCDynamicStoreNotifyValue() failed")); - _SCErrorSet(kSCStatusFailed); - } + ok = SCDynamicStoreNotifyValue(NULL, prefsPrivate->sessionKeyApply); + if (!ok) { + SC_log(LOG_INFO, "SCDynamicStoreNotifyValue() failed"); + _SCErrorSet(kSCStatusFailed); } done : diff --git a/SystemConfiguration.fproj/SCPCommit.c b/SystemConfiguration.fproj/SCPCommit.c index 15f5ef8..8a3107c 100644 --- a/SystemConfiguration.fproj/SCPCommit.c +++ b/SystemConfiguration.fproj/SCPCommit.c @@ -1,15 +1,15 @@ /* - * Copyright (c) 2000-2008, 2010-2013 Apple Inc. All rights reserved. + * Copyright (c) 2000-2008, 2010-2013, 2015 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ - * + * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. - * + * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, @@ -17,7 +17,7 @@ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. - * + * * @APPLE_LICENSE_HEADER_END@ */ @@ -61,10 +61,8 @@ __SCPreferencesCommitChanges_helper(SCPreferencesRef prefs) if (!ok) { status = kSCStatusFailed; if (_sc_verbose) { - SCLog(TRUE, LOG_ERR, - CFSTR("SCPreferencesCommitChanges(-->helper) CFPropertyListCreateData() failed")); - SCLog(TRUE, LOG_ERR, - CFSTR(" prefs = %s"), + SC_log(LOG_NOTICE, "_SCSerialize() failed"); + SC_log(LOG_NOTICE, " prefs = %s", prefsPrivate->newPath ? prefsPrivate->newPath : prefsPrivate->path); } goto error; @@ -158,7 +156,7 @@ SCPreferencesCommitChanges(SCPreferencesRef prefs) wasLocked = prefsPrivate->locked; if (!wasLocked) { if (!SCPreferencesLock(prefs, TRUE)) { - SCLog(_sc_verbose, LOG_ERR, CFSTR("SCPreferencesCommitChanges SCPreferencesLock() failed")); + SC_log(LOG_INFO, "SCPreferencesLock() failed"); return FALSE; } } @@ -210,7 +208,8 @@ SCPreferencesCommitChanges(SCPreferencesRef prefs) statBuf.st_uid = geteuid(); statBuf.st_gid = getegid(); } else { - SCLog(_sc_verbose, LOG_ERR, CFSTR("SCPreferencesCommitChanges stat() failed: %s"), strerror(errno)); + _SCErrorSet(errno); + SC_log(LOG_INFO, "stat() failed: %s", strerror(errno)); goto done; } } @@ -223,7 +222,7 @@ SCPreferencesCommitChanges(SCPreferencesRef prefs) fd = open(thePath, O_WRONLY|O_CREAT, statBuf.st_mode); if (fd == -1) { _SCErrorSet(errno); - SCLog(_sc_verbose, LOG_ERR, CFSTR("SCPreferencesCommitChanges open() failed: %s"), strerror(errno)); + SC_log(LOG_INFO, "open() failed: %s", strerror(errno)); CFAllocatorDeallocate(NULL, thePath); goto done; } @@ -244,16 +243,16 @@ SCPreferencesCommitChanges(SCPreferencesRef prefs) NULL); if (!newPrefs) { _SCErrorSet(kSCStatusFailed); - SCLog(_sc_verbose, LOG_ERR, CFSTR("SCPreferencesCommitChanges CFPropertyListCreateData() failed")); - SCLog(_sc_verbose, LOG_ERR, CFSTR(" prefs = %s"), path); + SC_log(LOG_INFO, "CFPropertyListCreateData() failed"); + SC_log(LOG_INFO, " prefs = %s", path); CFAllocatorDeallocate(NULL, thePath); (void) close(fd); goto done; } if (writen(fd, (const void *)CFDataGetBytePtr(newPrefs), CFDataGetLength(newPrefs)) == -1) { _SCErrorSet(errno); - SCLog(_sc_verbose, LOG_ERR, CFSTR("SCPreferencesCommitChanges write() failed: %s"), strerror(errno)); - SCLog(_sc_verbose, LOG_ERR, CFSTR(" path = %s"), thePath); + SC_log(LOG_INFO, "writen() failed: %s", strerror(errno)); + SC_log(LOG_INFO, " path = %s", thePath); (void) unlink(thePath); CFAllocatorDeallocate(NULL, thePath); (void) close(fd); @@ -264,8 +263,8 @@ SCPreferencesCommitChanges(SCPreferencesRef prefs) /* new preferences have been written */ if (close(fd) == -1) { _SCErrorSet(errno); - SCLog(_sc_verbose, LOG_ERR, CFSTR("SCPreferencesCommitChanges close() failed: %s"), strerror(errno)); - SCLog(_sc_verbose, LOG_ERR, CFSTR(" path = %s"), thePath); + SC_log(LOG_INFO, "close() failed: %s", strerror(errno)); + SC_log(LOG_INFO, " path = %s", thePath); (void) unlink(thePath); CFAllocatorDeallocate(NULL, thePath); CFRelease(newPrefs); @@ -276,8 +275,8 @@ SCPreferencesCommitChanges(SCPreferencesRef prefs) /* rename new->old */ if (rename(thePath, path) == -1) { _SCErrorSet(errno); - SCLog(_sc_verbose, LOG_ERR, CFSTR("SCPreferencesCommitChanges rename() failed: %s"), strerror(errno)); - SCLog(_sc_verbose, LOG_ERR, CFSTR(" path = %s --> %s"), thePath, path); + SC_log(LOG_INFO, "rename() failed: %s", strerror(errno)); + SC_log(LOG_INFO, " path = %s --> %s", thePath, path); CFAllocatorDeallocate(NULL, thePath); goto done; } @@ -295,8 +294,8 @@ SCPreferencesCommitChanges(SCPreferencesRef prefs) /* grab the new signature */ if (stat(path, &statBuf) == -1) { _SCErrorSet(errno); - SCLog(_sc_verbose, LOG_ERR, CFSTR("SCPreferencesCommitChanges stat() failed: %s"), strerror(errno)); - SCLog(_sc_verbose, LOG_ERR, CFSTR(" path = %s"), thePath); + SC_log(LOG_INFO, "stat() failed: %s", strerror(errno)); + SC_log(LOG_INFO, " path = %s", thePath); goto done; } } else { @@ -314,15 +313,11 @@ SCPreferencesCommitChanges(SCPreferencesRef prefs) committed : /* post notification */ - if (prefsPrivate->session == NULL) { - ok = TRUE; - } else { - ok = SCDynamicStoreNotifyValue(prefsPrivate->session, prefsPrivate->sessionKeyCommit); - if (!ok) { - SCLog(_sc_verbose, LOG_ERR, CFSTR("SCPreferencesCommitChanges SCDynamicStoreNotifyValue() failed")); - _SCErrorSet(kSCStatusFailed); - goto done; - } + ok = SCDynamicStoreNotifyValue(NULL, prefsPrivate->sessionKeyCommit); + if (!ok) { + SC_log(LOG_INFO, "SCDynamicStoreNotifyValue() failed"); + _SCErrorSet(kSCStatusFailed); + goto done; } prefsPrivate->changed = FALSE; diff --git a/SystemConfiguration.fproj/SCPLock.c b/SystemConfiguration.fproj/SCPLock.c index ba5201b..b0e69fd 100644 --- a/SystemConfiguration.fproj/SCPLock.c +++ b/SystemConfiguration.fproj/SCPLock.c @@ -1,15 +1,15 @@ /* - * Copyright (c) 2000-2010, 2013 Apple Inc. All rights reserved. + * Copyright (c) 2000-2010, 2013, 2015 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ - * + * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. - * + * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, @@ -17,7 +17,7 @@ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. - * + * * @APPLE_LICENSE_HEADER_END@ */ @@ -145,24 +145,18 @@ createParentDirectory(const char *path) (grpP != NULL)) { group = grpP->gr_gid; } else { - SCLog(TRUE, LOG_ERR, - CFSTR("SCPreferencesLock getgrnam_r() failed: %s"), - strerror(errno)); + SC_log(LOG_NOTICE, "getgrnam_r() failed: %s", strerror(errno)); group = 0; // wheel } } if (chown(dir, -1, group) == -1) { - SCLog(TRUE, LOG_ERR, - CFSTR("SCPreferencesLock chown() failed: %s"), - strerror(errno)); + SC_log(LOG_NOTICE, "chown() failed: %s", strerror(errno)); } // set [force] mode if (chmod(dir, mode) == -1) { - SCLog(TRUE, LOG_ERR, - CFSTR("SCPreferencesLock chmod() failed: %s"), - strerror(errno)); + SC_log(LOG_NOTICE, "chmod() failed: %s", strerror(errno)); } if ((slash == NULL) || (scan == dir)) { @@ -185,9 +179,7 @@ createParentDirectory(const char *path) slash = strchr(scan + 1, '/'); } - SCLog(TRUE, LOG_ERR, - CFSTR("SCPreferencesLock mkdir() failed: %s"), - strerror(errno)); + SC_log(LOG_NOTICE, "mkdir() failed: %s", strerror(errno)); return -1; } @@ -239,9 +231,7 @@ has_O_EXLOCK(SCPreferencesPrivateRef prefsPrivate) fd = open(prefsPrivate->lockPath, O_WRONLY|O_CREAT, 0644); if (fd == -1) { - SCLog(TRUE, LOG_ERR, - CFSTR("SCPreferencesLock open() failed: %s"), - strerror(errno)); + SC_log(LOG_NOTICE, "open() failed: %s", strerror(errno)); return FALSE; } @@ -249,9 +239,7 @@ has_O_EXLOCK(SCPreferencesPrivateRef prefsPrivate) unlink(prefsPrivate->lockPath); close(fd); if (ret == -1) { - SCLog(TRUE, LOG_ERR, - CFSTR("SCPreferencesLock fstatfs() failed: %s"), - strerror(errno)); + SC_log(LOG_NOTICE, "fstatfs() failed: %s", strerror(errno)); return FALSE; } @@ -265,9 +253,7 @@ has_O_EXLOCK(SCPreferencesPrivateRef prefsPrivate) sizeof(attrbuf), 0); // options if (ret == -1) { - SCLog(TRUE, LOG_ERR, - CFSTR("SCPreferencesLock getattrlist() failed: %s"), - strerror(errno)); + SC_log(LOG_NOTICE, "getattrlist() failed: %s", strerror(errno)); return FALSE; } @@ -281,12 +267,19 @@ has_O_EXLOCK(SCPreferencesPrivateRef prefsPrivate) static Boolean -lockWithSCDynamicStore(SCPreferencesPrivateRef prefsPrivate, Boolean wait) +lockWithSCDynamicStore(SCPreferencesRef prefs, Boolean wait) { - CFArrayRef changes; - Boolean locked = FALSE; - Boolean ok; - int sc_status = kSCStatusOK; + CFArrayRef changes; + Boolean locked = FALSE; + Boolean ok; + SCPreferencesPrivateRef prefsPrivate = (SCPreferencesPrivateRef)prefs; + int sc_status = kSCStatusOK; + + // add SCDynamicStore session (for lock monitoring) + ok = __SCPreferencesAddSession(prefs); + if (!ok) { + return FALSE; + } // add [lock] notification ok = SCDynamicStoreAddWatchedKey(prefsPrivate->session, @@ -294,7 +287,17 @@ lockWithSCDynamicStore(SCPreferencesPrivateRef prefsPrivate, Boolean wait) FALSE); if (!ok) { sc_status = SCError(); - SCLog(_sc_verbose, LOG_ERR, CFSTR("SCPreferencesLock SCDynamicStoreAddWatchedKey() failed")); + SC_log(LOG_INFO, "SCDynamicStoreAddWatchedKey() failed"); + } + + // add SCDynamicStore session (for the actual lock) + if (ok) { + prefsPrivate->sessionNoO_EXLOCK = SCDynamicStoreCreate(NULL, prefsPrivate->name, NULL, NULL); + if (prefsPrivate->sessionNoO_EXLOCK == NULL) { + sc_status = SCError(); + SC_log(LOG_INFO, "SCDynamicStoreCreate() failed"); + ok = FALSE; + } } while (ok) { @@ -302,7 +305,7 @@ lockWithSCDynamicStore(SCPreferencesPrivateRef prefsPrivate, Boolean wait) // Attempt to acquire the lock value = CFDateCreate(NULL, CFAbsoluteTimeGetCurrent()); - ok = SCDynamicStoreAddTemporaryValue(prefsPrivate->session, + ok = SCDynamicStoreAddTemporaryValue(prefsPrivate->sessionNoO_EXLOCK, prefsPrivate->sessionKeyLock, value); CFRelease(value); @@ -320,7 +323,7 @@ lockWithSCDynamicStore(SCPreferencesPrivateRef prefsPrivate, Boolean wait) ok = SCDynamicStoreNotifyWait(prefsPrivate->session); if (!ok) { sc_status = SCError(); - SCLog(_sc_verbose, LOG_ERR, CFSTR("SCPreferencesLock SCDynamicStoreNotifyWait() failed")); + SC_log(LOG_INFO, "SCDynamicStoreNotifyWait() failed"); break; } @@ -329,7 +332,7 @@ lockWithSCDynamicStore(SCPreferencesPrivateRef prefsPrivate, Boolean wait) if (changes != NULL) { CFRelease(changes); } else { - SCLog(_sc_verbose, LOG_ERR, CFSTR("SCPreferencesLock SCDynamicStoreCopyNotifiedKeys() failed")); + SC_log(LOG_INFO, "SCDynamicStoreCopyNotifiedKeys() failed"); break; } } @@ -345,9 +348,17 @@ lockWithSCDynamicStore(SCPreferencesPrivateRef prefsPrivate, Boolean wait) CFRelease(changes); } + __SCPreferencesRemoveSession(prefs); + + if (!locked && (prefsPrivate->sessionNoO_EXLOCK != NULL)) { + CFRelease(prefsPrivate->sessionNoO_EXLOCK); + prefsPrivate->sessionNoO_EXLOCK = NULL; + } + if (sc_status != kSCStatusOK) { _SCErrorSet(sc_status); } + return locked; } @@ -387,9 +398,7 @@ SCPreferencesLock(SCPreferencesRef prefs, Boolean wait) pthread_mutex_lock(&prefsPrivate->lock); - if (prefsPrivate->session == NULL) { - __SCPreferencesAddSession(prefs); - } + __SCPreferencesAddSessionKeys(prefs); if (prefsPrivate->lockPath == NULL) { char *path; @@ -406,7 +415,7 @@ SCPreferencesLock(SCPreferencesRef prefs, Boolean wait) retry : if (prefsPrivate->sessionKeyLock != NULL) { - if (lockWithSCDynamicStore(prefsPrivate, wait)) { + if (lockWithSCDynamicStore(prefs, wait)) { goto locked; } @@ -427,9 +436,8 @@ SCPreferencesLock(SCPreferencesRef prefs, Boolean wait) // create parent (/Library/Preferences/SystemConfiguration) ret = createParentDirectory(prefsPrivate->lockPath); if (ret == 0) { - SCLog(TRUE, LOG_NOTICE, - CFSTR("created directory for \"%s\""), - prefsPrivate->newPath ? prefsPrivate->newPath : prefsPrivate->path); + SC_log(LOG_INFO, "created directory for \"%s\"", + prefsPrivate->newPath ? prefsPrivate->newPath : prefsPrivate->path); goto retry; } else if (errno == EROFS) { goto locked; @@ -458,9 +466,7 @@ SCPreferencesLock(SCPreferencesRef prefs, Boolean wait) } sc_status = errno; - SCLog(TRUE, LOG_ERR, - CFSTR("SCPreferencesLock open() failed: %s"), - strerror(errno)); + SC_log(LOG_NOTICE, "open() failed: %s", strerror(errno)); goto error; } @@ -497,8 +503,7 @@ SCPreferencesLock(SCPreferencesRef prefs, Boolean wait) if (errno == ENOENT) { bzero(&statBuf, sizeof(statBuf)); } else { - SCLog(TRUE, LOG_DEBUG, - CFSTR("SCPreferencesLock stat() failed: %s"), + SC_log(LOG_INFO, "stat() failed: %s", strerror(errno)); goto stale; } diff --git a/SystemConfiguration.fproj/SCPOpen.c b/SystemConfiguration.fproj/SCPOpen.c index 89ccbf4..17e44aa 100644 --- a/SystemConfiguration.fproj/SCPOpen.c +++ b/SystemConfiguration.fproj/SCPOpen.c @@ -1,5 +1,5 @@ /* - * Copyright(c) 2000-2014 Apple Inc. All rights reserved. + * Copyright(c) 2000-2015 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -115,7 +115,9 @@ __SCPreferencesDeallocate(CFTypeRef cf) } if (prefsPrivate->lockPath) CFAllocatorDeallocate(NULL, prefsPrivate->lockPath); if (prefsPrivate->signature) CFRelease(prefsPrivate->signature); - if (prefsPrivate->session) CFRelease(prefsPrivate->session); + if (prefsPrivate->sessionNoO_EXLOCK != NULL) { + CFRelease(prefsPrivate->sessionNoO_EXLOCK); + } if (prefsPrivate->sessionKeyLock) CFRelease(prefsPrivate->sessionKeyLock); if (prefsPrivate->sessionKeyCommit) CFRelease(prefsPrivate->sessionKeyCommit); if (prefsPrivate->sessionKeyApply) CFRelease(prefsPrivate->sessionKeyApply); @@ -193,6 +195,8 @@ __SCPreferencesCreatePrivate(CFAllocatorRef allocator) prefsPrivate->lockPath = NULL; prefsPrivate->signature = NULL; prefsPrivate->session = NULL; + prefsPrivate->sessionNoO_EXLOCK = NULL; + prefsPrivate->sessionRefcnt = 0; prefsPrivate->sessionKeyLock = NULL; prefsPrivate->sessionKeyCommit = NULL; prefsPrivate->sessionKeyApply = NULL; @@ -211,7 +215,6 @@ __SCPreferencesCreatePrivate(CFAllocatorRef allocator) prefsPrivate->isRoot = (geteuid() == 0); prefsPrivate->limit_SCNetworkConfiguration = FALSE; prefsPrivate->authorizationData = NULL; - prefsPrivate->authorizationRequired = FALSE; prefsPrivate->helper_port = MACH_PORT_NULL; return prefsPrivate; @@ -467,11 +470,11 @@ __SCPreferencesCreate(CFAllocatorRef allocator, goto done; } - SCLog(_sc_verbose, LOG_DEBUG, CFSTR("__SCPreferencesCreate open() failed: %s"), strerror(errno)); + SC_log(LOG_INFO, "open() failed: %s", strerror(errno)); sc_status = kSCStatusAccessError; break; default : - SCLog(TRUE, LOG_ERR, CFSTR("__SCPreferencesCreate open() failed: %s"), strerror(errno)); + SC_log(LOG_INFO, "open() failed: %s", strerror(errno)); sc_status = kSCStatusFailed; break; } @@ -503,19 +506,15 @@ __SCPreferencesAccess(SCPreferencesRef prefs) return; } - if (!prefsPrivate->authorizationRequired) { - if (access(prefsPrivate->path, R_OK) == 0) { - fd = open(prefsPrivate->path, O_RDONLY, 0644); - } else { - fd = -1; - } + if (access(prefsPrivate->path, R_OK) == 0) { + fd = open(prefsPrivate->path, O_RDONLY, 0644); } else { - errno = EACCES; + fd = -1; } if (fd != -1) { // create signature if (fstat(fd, &statBuf) == -1) { - SCLog(TRUE, LOG_ERR, CFSTR("__SCPreferencesAccess fstat() failed: %s"), strerror(errno)); + SC_log(LOG_NOTICE, "fstat() failed: %s", strerror(errno)); bzero(&statBuf, sizeof(statBuf)); } } else { @@ -529,15 +528,14 @@ __SCPreferencesAccess(SCPreferencesRef prefs) if (__SCPreferencesAccess_helper(prefs)) { goto done; } else { - SCLog(TRUE, LOG_ERR, - CFSTR("__SCPreferencesAccess_helper() failed: %s"), - SCErrorString(SCError())); + SC_log(LOG_NOTICE, "__SCPreferencesAccess_helper() failed: %s", + SCErrorString(SCError())); } break; } // fall through default : - SCLog(TRUE, LOG_ERR, CFSTR("__SCPreferencesAccess open() failed: %s"), strerror(errno)); + SC_log(LOG_NOTICE, "open() failed: %s", strerror(errno)); break; } bzero(&statBuf, sizeof(statBuf)); @@ -558,7 +556,7 @@ __SCPreferencesAccess(SCPreferencesRef prefs) CFDataSetLength(xmlData, (CFIndex)statBuf.st_size); if (read(fd, (void *)CFDataGetBytePtr(xmlData), (CFIndex)statBuf.st_size) != (CFIndex)statBuf.st_size) { /* corrupt prefs file, start fresh */ - SCLog(_sc_verbose, LOG_DEBUG, CFSTR("__SCPreferencesAccess read(): could not load preference data.")); + SC_log(LOG_INFO, "read(): could not load preference data"); CFRelease(xmlData); xmlData = NULL; goto done; @@ -572,9 +570,7 @@ __SCPreferencesAccess(SCPreferencesRef prefs) if (dict == NULL) { /* corrupt prefs file, start fresh */ if (error != NULL) { - SCLog(TRUE, LOG_ERR, - CFSTR("__SCPreferencesAccess CFPropertyListCreateWithData(): %@"), - error); + SC_log(LOG_NOTICE, "CFPropertyListCreateWithData(): %@", error); CFRelease(error); } goto done; @@ -585,7 +581,7 @@ __SCPreferencesAccess(SCPreferencesRef prefs) */ if (!isA_CFDictionary(dict)) { /* corrupt prefs file, start fresh */ - SCLog(_sc_verbose, LOG_DEBUG, CFSTR("__SCPreferencesAccess CFGetTypeID(): not a dictionary.")); + SC_log(LOG_INFO, "CFGetTypeID(): not a dictionary"); CFRelease(dict); goto done; } @@ -604,7 +600,7 @@ __SCPreferencesAccess(SCPreferencesRef prefs) /* * new file, create empty preferences */ -// SCLog(_sc_verbose, LOG_DEBUG, CFSTR("__SCPreferencesAccess(): creating new preferences file.")); +// SC_log(LOG_INFO, "creating new preferences file"); prefsPrivate->prefs = CFDictionaryCreateMutable(allocator, 0, &kCFTypeDictionaryKeyCallBacks, @@ -684,7 +680,7 @@ SCPreferencesCreateWithOptions(CFAllocatorRef allocator, os_status = AuthorizationMakeExternalForm(authorization, &extForm); if (os_status != errAuthorizationSuccess) { - SCLog(TRUE, LOG_INFO, CFSTR("_SCHelperOpen AuthorizationMakeExternalForm() failed")); + SC_log(LOG_INFO, "AuthorizationMakeExternalForm() failed"); _SCErrorSet(kSCStatusInvalidArgument); CFRelease(authorizationDict); return NULL; @@ -810,39 +806,71 @@ prefsNotify(SCDynamicStoreRef store, CFArrayRef changedKeys, void *info) } +__private_extern__ void +__SCPreferencesAddSessionKeys(SCPreferencesRef prefs) +{ + SCPreferencesPrivateRef prefsPrivate = (SCPreferencesPrivateRef)prefs; + + /* create the session "commit" key */ + if (prefsPrivate->sessionKeyCommit == NULL) { + prefsPrivate->sessionKeyCommit = _SCPNotificationKey(NULL, + prefsPrivate->prefsID, + kSCPreferencesKeyCommit); + } + + /* create the session "apply" key */ + if (prefsPrivate->sessionKeyApply == NULL) { + prefsPrivate->sessionKeyApply = _SCPNotificationKey(NULL, + prefsPrivate->prefsID, + kSCPreferencesKeyApply); + } + + return; +} + + __private_extern__ Boolean __SCPreferencesAddSession(SCPreferencesRef prefs) { CFAllocatorRef allocator = CFGetAllocator(prefs); SCDynamicStoreContext context = { 0 , (void *)prefs - , NULL - , NULL - , NULL + , CFRetain + , CFRelease + , CFCopyDescription }; SCPreferencesPrivateRef prefsPrivate = (SCPreferencesPrivateRef)prefs; - /* establish a dynamic store session */ - prefsPrivate->session = SCDynamicStoreCreate(allocator, - prefsPrivate->name, - prefsNotify, - &context); - if (prefsPrivate->session == NULL) { - SCLog(_sc_verbose, LOG_INFO, CFSTR("__SCPreferencesAddSession SCDynamicStoreCreate() failed")); - return FALSE; + if (prefsPrivate->sessionRefcnt == 0) { + /* establish a dynamic store session */ + prefsPrivate->session = SCDynamicStoreCreate(allocator, + prefsPrivate->name, + prefsNotify, + &context); + if (prefsPrivate->session == NULL) { + SC_log(LOG_INFO, "SCDynamicStoreCreate() failed"); + return FALSE; + } } - /* create the session "commit" key */ - prefsPrivate->sessionKeyCommit = _SCPNotificationKey(NULL, - prefsPrivate->prefsID, - kSCPreferencesKeyCommit); + prefsPrivate->sessionRefcnt++; + return TRUE; +} - /* create the session "apply" key */ - prefsPrivate->sessionKeyApply = _SCPNotificationKey(NULL, - prefsPrivate->prefsID, - kSCPreferencesKeyApply); - return TRUE; +__private_extern__ void +__SCPreferencesRemoveSession(SCPreferencesRef prefs) +{ + SCPreferencesPrivateRef prefsPrivate = (SCPreferencesPrivateRef)prefs; + + if (prefsPrivate->sessionRefcnt > 0) { + if (--prefsPrivate->sessionRefcnt == 0) { + CFRelease(prefsPrivate->session); + prefsPrivate->session = NULL; + } + } + + return; } @@ -904,6 +932,7 @@ __SCPreferencesScheduleWithRunLoop(SCPreferencesRef prefs, if (!prefsPrivate->scheduled) { CFMutableArrayRef keys; + // add SCDynamicStore session (for notifications) ... and hold a 'prefs' reference if (prefsPrivate->session == NULL) { ok = __SCPreferencesAddSession(prefs); if (!ok) { @@ -911,7 +940,8 @@ __SCPreferencesScheduleWithRunLoop(SCPreferencesRef prefs, } } - CFRetain(prefs); // hold a reference to the prefs + // add SCDynamicStore "keys" + __SCPreferencesAddSessionKeys(prefs); keys = CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks); CFArrayAppendValue(keys, prefsPrivate->sessionKeyCommit); @@ -932,7 +962,7 @@ __SCPreferencesScheduleWithRunLoop(SCPreferencesRef prefs, if (!ok) { prefsPrivate->scheduled = FALSE; (void) SCDynamicStoreSetNotificationKeys(prefsPrivate->session, NULL, NULL); - CFRelease(prefs); + __SCPreferencesRemoveSession(prefs); goto done; } @@ -1026,8 +1056,8 @@ __SCPreferencesUnscheduleFromRunLoop(SCPreferencesRef prefs, CFRelease(changedKeys); } - // release our reference to the prefs - CFRelease(prefs); + // remove SCDynamicStore session, release 'prefs' reference + __SCPreferencesRemoveSession(prefs); } ok = TRUE; diff --git a/SystemConfiguration.fproj/SCPUnlock.c b/SystemConfiguration.fproj/SCPUnlock.c index d47c6c5..76da3a0 100644 --- a/SystemConfiguration.fproj/SCPUnlock.c +++ b/SystemConfiguration.fproj/SCPUnlock.c @@ -1,15 +1,15 @@ /* - * Copyright (c) 2000, 2001, 2004-2010, 2013 Apple Inc. All rights reserved. + * Copyright (c) 2000, 2001, 2004-2010, 2013, 2015 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ - * + * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. - * + * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, @@ -17,7 +17,7 @@ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. - * + * * @APPLE_LICENSE_HEADER_END@ */ @@ -141,9 +141,10 @@ SCPreferencesUnlock(SCPreferencesRef prefs) pthread_mutex_lock(&prefsPrivate->lock); - if (prefsPrivate->sessionKeyLock != NULL) { - SCDynamicStoreRemoveValue(prefsPrivate->session, - prefsPrivate->sessionKeyLock); + if (prefsPrivate->sessionNoO_EXLOCK != NULL) { + // Note: closing the session removes the temporary "lock" key + CFRelease(prefsPrivate->sessionNoO_EXLOCK); + prefsPrivate->sessionNoO_EXLOCK = NULL; } if (prefsPrivate->lockFD != -1) { diff --git a/SystemConfiguration.fproj/SCPreferences.h b/SystemConfiguration.fproj/SCPreferences.h index b31ba81..de07f28 100644 --- a/SystemConfiguration.fproj/SCPreferences.h +++ b/SystemConfiguration.fproj/SCPreferences.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2001, 2004, 2005, 2007-2010 Apple Inc. All rights reserved. + * Copyright (c) 2000, 2001, 2004, 2005, 2007-2010, 2015 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -40,6 +40,8 @@ typedef const struct AuthorizationOpaqueRef * AuthorizationRef; #endif // !TARGET_OS_IPHONE +CF_IMPLICIT_BRIDGING_ENABLED +CF_ASSUME_NONNULL_BEGIN /*! @header SCPreferences @@ -71,7 +73,7 @@ typedef const struct AuthorizationOpaqueRef * AuthorizationRef; @discussion This is the handle to an open preferences session for accessing system configuration preferences. */ -typedef const struct __SCPreferences * SCPreferencesRef; +typedef const struct CF_BRIDGED_TYPE(id) __SCPreferences * SCPreferencesRef; /*! @enum SCPreferencesNotification @@ -83,13 +85,11 @@ typedef const struct __SCPreferences * SCPreferencesRef; request has been made to apply the currently saved preferences to the active system configuration. */ -enum { +typedef CF_OPTIONS(uint32_t, SCPreferencesNotification) { kSCPreferencesNotificationCommit = 1<<0, // __OSX_AVAILABLE_STARTING(__MAC_10_4,__IPHONE_2_0/*SPI*/) kSCPreferencesNotificationApply = 1<<1 // __OSX_AVAILABLE_STARTING(__MAC_10_4,__IPHONE_2_0/*SPI*/) }; -typedef uint32_t SCPreferencesNotification; - /*! @typedef SCPreferencesContext Structure containing user-specified data and callbacks for SCPreferences. @@ -111,10 +111,10 @@ typedef uint32_t SCPreferencesNotification; */ typedef struct { CFIndex version; - void * info; - const void *(*retain)(const void *info); - void (*release)(const void *info); - CFStringRef (*copyDescription)(const void *info); + void * __nullable info; + const void * __nonnull (* __nullable retain)(const void *info); + void (* __nullable release)(const void *info); + CFStringRef __nonnull (* __nullable copyDescription)(const void *info); } SCPreferencesContext; /*! @@ -127,9 +127,9 @@ typedef struct { @param info A C pointer to a user-specified block of data. */ typedef void (*SCPreferencesCallBack) ( - SCPreferencesRef prefs, - SCPreferencesNotification notificationType, - void *info + SCPreferencesRef prefs, + SCPreferencesNotification notificationType, + void * __nullable info ); @@ -159,11 +159,11 @@ SCPreferencesGetTypeID (void) __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2 @result Returns a reference to the new SCPreferences. You must release the returned value. */ -SCPreferencesRef +SCPreferencesRef __nullable SCPreferencesCreate ( - CFAllocatorRef allocator, - CFStringRef name, - CFStringRef prefsID + CFAllocatorRef __nullable allocator, + CFStringRef name, + CFStringRef __nullable prefsID ) __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); @@ -187,12 +187,12 @@ SCPreferencesCreate ( @result Returns a reference to the new SCPreferences. You must release the returned value. */ -SCPreferencesRef +SCPreferencesRef __nullable SCPreferencesCreateWithAuthorization ( - CFAllocatorRef allocator, - CFStringRef name, - CFStringRef prefsID, - AuthorizationRef authorization + CFAllocatorRef __nullable allocator, + CFStringRef name, + CFStringRef __nullable prefsID, + AuthorizationRef __nullable authorization ) __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0/*SPI*/); /*! @@ -275,7 +275,7 @@ SCPreferencesUnlock ( @result Returns a CFDataRef that reflects the signature of the configuration preferences at the time of the call to the SCPreferencesCreate function. */ -CFDataRef +CFDataRef __nullable SCPreferencesGetSignature ( SCPreferencesRef prefs ) __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); @@ -287,7 +287,7 @@ SCPreferencesGetSignature ( @result Returns the list of keys. You must release the returned value. */ -CFArrayRef +CFArrayRef __nullable SCPreferencesCopyKeyList ( SCPreferencesRef prefs ) __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); @@ -306,7 +306,7 @@ SCPreferencesCopyKeyList ( @result Returns the value associated with the specified preference key; NULL if no value was located. */ -CFPropertyListRef +CFPropertyListRef __nullable SCPreferencesGetValue ( SCPreferencesRef prefs, CFStringRef key @@ -388,9 +388,9 @@ SCPreferencesRemoveValue ( */ Boolean SCPreferencesSetCallback ( - SCPreferencesRef prefs, - SCPreferencesCallBack callout, - SCPreferencesContext *context + SCPreferencesRef prefs, + SCPreferencesCallBack __nullable callout, + SCPreferencesContext * __nullable context ) __OSX_AVAILABLE_STARTING(__MAC_10_4,__IPHONE_2_0/*SPI*/); /*! @@ -444,8 +444,8 @@ SCPreferencesUnscheduleFromRunLoop ( */ Boolean SCPreferencesSetDispatchQueue ( - SCPreferencesRef prefs, - dispatch_queue_t queue + SCPreferencesRef prefs, + dispatch_queue_t __nullable queue ) __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_4_0/*SPI*/); /*! @@ -466,5 +466,8 @@ SCPreferencesSynchronize ( __END_DECLS +CF_ASSUME_NONNULL_END +CF_IMPLICIT_BRIDGING_DISABLED + #endif /* USE_SYSTEMCONFIGURATION_PRIVATE_HEADERS */ #endif /* _SCPREFERENCES_H */ diff --git a/SystemConfiguration.fproj/SCPreferencesInternal.h b/SystemConfiguration.fproj/SCPreferencesInternal.h index 78de1f8..608eb9e 100644 --- a/SystemConfiguration.fproj/SCPreferencesInternal.h +++ b/SystemConfiguration.fproj/SCPreferencesInternal.h @@ -1,15 +1,15 @@ /* - * Copyright (c) 2000, 2001, 2003-2005, 2007-2011, 2013, 2014 Apple Inc. All rights reserved. + * Copyright (c) 2000, 2001, 2003-2005, 2007-2011, 2013-2015 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ - * + * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. - * + * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, @@ -17,7 +17,7 @@ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. - * + * * @APPLE_LICENSE_HEADER_END@ */ @@ -79,6 +79,8 @@ typedef struct { /* configd session */ SCDynamicStoreRef session; + SCDynamicStoreRef sessionNoO_EXLOCK; + int sessionRefcnt; /* configd session keys */ CFStringRef sessionKeyLock; @@ -104,7 +106,6 @@ typedef struct { /* authorization, helper */ CFDataRef authorizationData; - Boolean authorizationRequired; mach_port_t helper_port; } SCPreferencesPrivate, *SCPreferencesPrivateRef; @@ -128,9 +129,15 @@ __SCPreferencesCreate_helper (SCPreferencesRef prefs); void __SCPreferencesAccess (SCPreferencesRef prefs); +void +__SCPreferencesAddSessionKeys (SCPreferencesRef prefs); + Boolean __SCPreferencesAddSession (SCPreferencesRef prefs); +void +__SCPreferencesRemoveSession (SCPreferencesRef prefs); + CF_RETURNS_RETAINED CFDataRef __SCPSignatureFromStatbuf (const struct stat *statBuf); diff --git a/SystemConfiguration.fproj/SCPreferencesPath.h b/SystemConfiguration.fproj/SCPreferencesPath.h index 221ac57..c219d2f 100644 --- a/SystemConfiguration.fproj/SCPreferencesPath.h +++ b/SystemConfiguration.fproj/SCPreferencesPath.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2001, 2004, 2005, 2008 Apple Inc. All rights reserved. + * Copyright (c) 2000, 2001, 2004, 2005, 2008, 2015 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -32,6 +32,8 @@ #include #include +CF_IMPLICIT_BRIDGING_ENABLED +CF_ASSUME_NONNULL_BEGIN /*! @header SCPreferencesPath @@ -90,7 +92,7 @@ __BEGIN_DECLS @result Returns a string representing the new (unique) child path; NULL if the specified path does not exist. */ -CFStringRef +CFStringRef __nullable SCPreferencesPathCreateUniqueChild ( SCPreferencesRef prefs, CFStringRef prefix @@ -105,7 +107,7 @@ SCPreferencesPathCreateUniqueChild ( @result Returns the dictionary associated with the specified path; NULL if the path does not exist. */ -CFDictionaryRef +CFDictionaryRef __nullable SCPreferencesPathGetValue ( SCPreferencesRef prefs, CFStringRef path @@ -120,7 +122,7 @@ SCPreferencesPathGetValue ( @result Returns the dictionary associated with the specified path; NULL if the path is not a link or does not exist. */ -CFStringRef +CFStringRef __nullable SCPreferencesPathGetLink ( SCPreferencesRef prefs, CFStringRef path @@ -174,5 +176,8 @@ SCPreferencesPathRemoveValue ( __END_DECLS +CF_ASSUME_NONNULL_END +CF_IMPLICIT_BRIDGING_DISABLED + #endif /* USE_SYSTEMCONFIGURATION_PRIVATE_HEADERS */ #endif /* _SCPREFERENCESPATH_H */ diff --git a/SystemConfiguration.fproj/SCPreferencesPathKey.c b/SystemConfiguration.fproj/SCPreferencesPathKey.c index 2667601..d1ffeb9 100644 --- a/SystemConfiguration.fproj/SCPreferencesPathKey.c +++ b/SystemConfiguration.fproj/SCPreferencesPathKey.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2004, 2005, 2010 Apple Inc. All rights reserved. + * Copyright (c) 2001, 2004, 2005, 2010, 2015 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -152,6 +152,16 @@ SCPreferencesPathKeyCreateSetNetworkInterfaceEntity(CFAllocatorRef allocator, /* * create "/Sets/set-id/Network/Interface/interface-name/entity" */ + if (entity == NULL) { + return CFStringCreateWithFormat(allocator, + NULL, + CFSTR("/%@/%@/%@/%@/%@"), + kSCPrefSets, + set, + kSCCompNetwork, + kSCCompInterface, + ifname); + } return CFStringCreateWithFormat(allocator, NULL, CFSTR("/%@/%@/%@/%@/%@/%@"), diff --git a/SystemConfiguration.fproj/SCPreferencesSetSpecific.h b/SystemConfiguration.fproj/SCPreferencesSetSpecific.h index b044efb..7c87bef 100644 --- a/SystemConfiguration.fproj/SCPreferencesSetSpecific.h +++ b/SystemConfiguration.fproj/SCPreferencesSetSpecific.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000-2002, 2004, 2005, 2008 Apple Inc. All rights reserved. + * Copyright (c) 2000-2002, 2004, 2005, 2008, 2015 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -32,6 +32,8 @@ #include #include +CF_IMPLICIT_BRIDGING_ENABLED +CF_ASSUME_NONNULL_BEGIN /*! @header SCPreferencesSetSpecific @@ -90,5 +92,8 @@ SCPreferencesSetLocalHostName ( __END_DECLS +CF_ASSUME_NONNULL_END +CF_IMPLICIT_BRIDGING_DISABLED + #endif /* USE_SYSTEMCONFIGURATION_PRIVATE_HEADERS */ #endif /* _SCPREFERENCESSETSPECIFIC_H */ diff --git a/SystemConfiguration.fproj/SCPrivate.h b/SystemConfiguration.fproj/SCPrivate.h index e68fac8..b336bcb 100644 --- a/SystemConfiguration.fproj/SCPrivate.h +++ b/SystemConfiguration.fproj/SCPrivate.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000-2014 Apple Inc. All rights reserved. + * Copyright (c) 2000-2015 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -30,6 +30,8 @@ #include #include #include +#include +#include #include #include @@ -68,8 +70,6 @@ #define _SC_SERVER_PROG "configd_sim" #endif // !TARGET_IPHONE_SIMULATOR -#define INSTALL_ENVIRONMENT "__OSINSTALL_ENVIRONMENT" -#define INSTALL_FACILITY "install" /* atomic operations */ #define _SC_ATOMIC_CMPXCHG(p, o, n) __sync_bool_compare_and_swap((p), (o), (n)) @@ -78,6 +78,13 @@ #define _SC_ATOMIC_ZERO(p) __sync_fetch_and_and((p), 0) // old_n = n; n = 0; return(old_n); +/* framework path */ +#if !TARGET_OS_WATCH +#define SYSTEMCONFIGURATION_FRAMEWORK_PATH "/System/Library/Frameworks/SystemConfiguration.framework" +#else +#define SYSTEMCONFIGURATION_FRAMEWORK_PATH "/System/Library/PrivateFrameworks/SystemConfiguration.framework" +#endif + /* framework variables */ extern int _sc_debug; /* non-zero if debugging enabled */ extern int _sc_verbose; /* non-zero if verbose logging enabled */ @@ -85,14 +92,10 @@ extern int _sc_log; /* 0 if SC messages should be written to stdout/stderr, 1 if SC messages should be logged w/asl(3), 2 if SC messages should be written to stdout/stderr AND logged */ -/* notify(3) keys */ -#if !TARGET_IPHONE_SIMULATOR -#define _SC_NOTIFY_PREFIX "com.apple.system.config" -#else // !TARGET_IPHONE_SIMULATOR -#define _SC_NOTIFY_PREFIX "com.apple.iOS_Simulator.config" -#endif // !TARGET_IPHONE_SIMULATOR +/* notify(3) keys */ +#define _SC_NOTIFY_PREFIX "com.apple.system.config" #define _SC_NOTIFY_NETWORK_CHANGE _SC_NOTIFY_PREFIX ".network_change" #define _SC_NOTIFY_NETWORK_CHANGE_DNS _SC_NOTIFY_NETWORK_CHANGE ".dns" #define _SC_NOTIFY_NETWORK_CHANGE_NWI _SC_NOTIFY_NETWORK_CHANGE ".nwi" @@ -167,7 +170,6 @@ extern int _sc_log; /* 0 if SC messages should be written to stdout/stderr, - /*! @group */ @@ -414,12 +416,12 @@ void SCLog (Boolean condition, CFStringRef formatString, ...) CF_FORMAT_FUNCTION(3, 4); -enum { - kSCLoggerFlagsNone = 0x0, + +typedef CF_ENUM(uint32_t, SCLoggerFlags) { + kSCLoggerFlagsNone = 0x0, kSCLoggerFlagsDefault = 0x1, - kSCLoggerFlagsFile = 0x2 + kSCLoggerFlagsFile = 0x2 }; -typedef uint32_t SCLoggerFlags; typedef struct SCLogger * SCLoggerRef; @@ -463,9 +465,6 @@ void SCLoggerVLog (SCLoggerRef logger, va_list args) __OSX_AVAILABLE_STARTING(__MAC_10_9,__IPHONE_7_0); -#ifdef USE_NEW_SCLOG -#define SCLOG(sclogger, level, __string, ...) SCLoggerLog(sclogger, level, CFSTR(__string), ## __VA_ARGS__) // temporary, remove once all "old" clients have migrated -#else /*! @function SCLOG @discussion Issue a log message. @@ -487,7 +486,18 @@ void SCLOG (asl_object_t asl, ...) CF_FORMAT_FUNCTION(4, 5); -#endif +/*! + @function SC_log + @discussion Issue a log message. + @param level The asl(3) logging priority. Passing the complement of a logging + priority (e.g. ~ASL_LEVEL_NOTICE) will result in log message lines + NOT being split by a "\n". + @param __string The format string + @result The specified message will be written to the unified logging system. + */ +#define SC_log(__level, __string, ...) \ + SCLog(TRUE, __level, CFSTR( __string ), ## __VA_ARGS__) + /*! @function SCPrint @@ -507,17 +517,27 @@ void SCPrint (Boolean condition, /*! @function SCTrace - @discussion Conditionally issue a debug message with a time stamp. - @param condition A boolean value indicating if the message should be written + @discussion Write a debug message with a time stamp. @param stream The output stream for the log message. @param formatString The format string @result The message will be written to the specified stream stream. */ -void SCTrace (Boolean condition, - FILE *stream, +void SCTrace (FILE *stream, CFStringRef formatString, - ...) CF_FORMAT_FUNCTION(3, 4); + ...) CF_FORMAT_FUNCTION(2, 3); + +/*! + @function SC_trace + @discussion Issue a debug message / write with a time stamp + @param stream The output stream for the log message. + @param formatString The format string + @result The message will be written to the specified stream + stream. + */ +#define SC_trace(__stream, __string, ...) \ + SCTrace(__stream, CFSTR( __string ), ## __VA_ARGS__) + /*! @function SCLoggerCreate @@ -595,10 +615,10 @@ SCNetworkProxiesCopyMatching (CFDictionaryRef globalConfiguration, kSCProxiesMatchExecutableUUID CFUUID If present, specifies the Mach-O UUID of the executable on whose behalf the match operation is being performed. If kSCProxiesMatchInterface is present then this option - is ignored. If not present, then the Mach-O UUID of - the current process is used. The Mach-O UUID is used - to match application-specific proxy configurations - (i.e., if per-app VPN rules are in effect). + is ignored. If not present, then the Mach-O UUID of + the current process is used. The Mach-O UUID is used + to match application-specific proxy configurations + (i.e., if per-app VPN rules are in effect). @result A CFArray containing the proxy configurations associated with the given options. */ CFArrayRef @@ -628,22 +648,11 @@ extern const CFStringRef kSCProxiesNoGlobal; CFDictionaryRef SCDynamicStoreCopyProxiesWithOptions(SCDynamicStoreRef store, CFDictionaryRef options) __OSX_AVAILABLE_STARTING(__MAC_10_9,__IPHONE_7_0/*SPI*/); + #pragma mark - #pragma mark Reachability -/*! - @function SCNetworkReachabilityCopyOnDemandService - @discussion For target hosts that require an OnDemand connection, returns - the SCNetworkService associated with the connection and user - options to use with SCNetworkConnectionStart. - @result The SCNetworkService for the target; NULL if there is - no associated OnDemand service. - */ -SCNetworkServiceRef -SCNetworkReachabilityCopyOnDemandService (SCNetworkReachabilityRef target, - CFDictionaryRef *userOptions); - /*! @function SCNetworkReachabilityCopyResolvedAddress @discussion Return the resolved addresses associated with the @@ -843,6 +852,9 @@ _SC_isAppleInternal() return (isInternal == 1); } +Boolean +_SC_isInstallEnvironment (void); + #define MODEL CFSTR("Model") CFStringRef diff --git a/SystemConfiguration.fproj/SCSchemaDefinitions.c b/SystemConfiguration.fproj/SCSchemaDefinitions.c index 02b3bf8..af94876 100644 --- a/SystemConfiguration.fproj/SCSchemaDefinitions.c +++ b/SystemConfiguration.fproj/SCSchemaDefinitions.c @@ -13,7 +13,9 @@ const CFStringRef kSCPropInterfaceName = CFSTR("Inte const CFStringRef kSCPropMACAddress = CFSTR("MACAddress"); const CFStringRef kSCPropUserDefinedName = CFSTR("UserDefinedName"); const CFStringRef kSCPropVersion = CFSTR("Version"); +const CFStringRef kSCPropNetIgnoreLinkStatus = CFSTR("IgnoreLinkStatus"); const CFStringRef kSCPropConfirmedInterfaceName = CFSTR("ConfirmedInterfaceName"); +const CFStringRef kSCPropDisableUntilNeeded = CFSTR("DisableUntilNeeded"); const CFStringRef kSCPrefCurrentSet = CFSTR("CurrentSet"); const CFStringRef kSCPrefNetworkServices = CFSTR("NetworkServices"); const CFStringRef kSCPrefSets = CFSTR("Sets"); @@ -77,7 +79,6 @@ const CFStringRef kSCEntNetVPN = CFSTR("VPN" const CFStringRef kSCPropNetOverridePrimary = CFSTR("OverridePrimary"); const CFStringRef kSCPropNetServiceOrder = CFSTR("ServiceOrder"); const CFStringRef kSCPropNetPPPOverridePrimary = CFSTR("PPPOverridePrimary"); -const CFStringRef kSCPropNetIgnoreLinkStatus = CFSTR("IgnoreLinkStatus"); const CFStringRef kSCPropNetInterfaces = CFSTR("Interfaces"); const CFStringRef kSCPropNetLocalHostName = CFSTR("LocalHostName"); const CFStringRef kSCPropNetAirPortAllowNetCreation = CFSTR("AllowNetCreation"); @@ -121,6 +122,7 @@ const CFStringRef kSCPropNetDNSServerTimeout = CFSTR("Serv const CFStringRef kSCPropNetDNSSortList = CFSTR("SortList"); const CFStringRef kSCPropNetDNSSupplementalMatchDomains = CFSTR("SupplementalMatchDomains"); const CFStringRef kSCPropNetDNSSupplementalMatchOrders = CFSTR("SupplementalMatchOrders"); +const CFStringRef kSCPropNetDNSConfirmedServiceID = CFSTR("ConfirmedServiceID"); const CFStringRef kSCPropNetDNSServiceIdentifier = CFSTR("ServiceIdentifier"); const CFStringRef kSCPropNetDNSSupplementalMatchDomainsNoSearch = CFSTR("SupplementalMatchDomainsNoSearch"); const CFStringRef kSCPropNetEthernetMediaSubType = CFSTR("MediaSubType"); @@ -374,6 +376,7 @@ const CFStringRef kSCPropNetProxiesBypassAllowed = CFSTR("Bypa const CFStringRef kSCPropNetProxiesFallBackAllowed = CFSTR("FallBackAllowed"); const CFStringRef kSCPropNetProxiesSupplementalMatchDomains = CFSTR("SupplementalMatchDomains"); const CFStringRef kSCPropNetProxiesSupplementalMatchOrders = CFSTR("SupplementalMatchOrders"); +const CFStringRef kSCPropNetProxiesServiceSpecific = CFSTR("ServiceSpecific"); const CFStringRef kSCPropNetProxiesScoped = CFSTR("__SCOPED__"); const CFStringRef kSCPropNetProxiesServices = CFSTR("__SERVICES__"); const CFStringRef kSCPropNetProxiesSupplemental = CFSTR("__SUPPLEMENTAL__"); diff --git a/SystemConfiguration.fproj/SCSchemaDefinitions.h b/SystemConfiguration.fproj/SCSchemaDefinitions.h index 17d5e29..cf992c3 100644 --- a/SystemConfiguration.fproj/SCSchemaDefinitions.h +++ b/SystemConfiguration.fproj/SCSchemaDefinitions.h @@ -1,15 +1,15 @@ /* - * Copyright (c) 2000-2014 Apple Inc. All rights reserved. + * Copyright (c) 2000-2015 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ - * + * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. - * + * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, @@ -17,7 +17,7 @@ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. - * + * * @APPLE_LICENSE_HEADER_END@ */ @@ -416,117 +416,64 @@ */ -/* - * Note: The MACOSX_DEPLOYMENT_TARGET environment variable should be used - * when building an application targeted for an earlier version of - * Mac OS X. Please reference Technical Note TN2064 for more details. - */ - -/* - * Note: For Cocoa/Obj-C/Foundation applications accessing these preference - * keys you may want to consider the following : - * - * #define SC_SCHEMA_DECLARATION(k,q) extern NSString * k; - * #import - */ - -/* - * Note: For CFM applications using these schema keys you may want to - * consider the following : - * - * #define SC_SCHEMA_DECLARATION(k,q) - * #define SC_SCHEMA_KV(k,v,t) lookup_SC_key( CFSTR( #k ) ) - * #include - * - * CFStringRef lookup_SC_key(CFStringRef key) - * { - * // this function should [dynamically, on-demand] load the - * // SystemConfiguration.framework, look up the provided key, - * // and return the associated value. - * } - */ - -/* - * Note: Earlier versions of this header file defined a "SCSTR" macro - * which helped to facilitate Obj-C development. Use of this macro - * has been deprecated (in Mac OS X 10.4) in favor of the newer - * "SC_SCHEMA_DECLARATION" and "SC_SCHEMA_KV" macros - */ - - #ifndef _SCSCHEMADEFINITIONS_H #ifdef USE_SYSTEMCONFIGURATION_PRIVATE_HEADERS #include #else /* USE_SYSTEMCONFIGURATION_PRIVATE_HEADERS */ #define _SCSCHEMADEFINITIONS_H -/* -------------------- Macro declarations -------------------- */ - #include #include +#include -/* - * Define a schema key/value/type tuple - */ -#ifndef SC_SCHEMA_KV - #define SC_SCHEMA_KV(k,v,t) k -#endif - -/* - * Provide an "extern" for the key/value - */ -#ifndef SC_SCHEMA_DECLARATION - #ifndef SCSTR - #include - #define SC_SCHEMA_DECLARATION(k,q) extern const CFStringRef k q; - #else - #import - #define SC_SCHEMA_DECLARATION(k,q) extern NSString * k q; - #endif -#endif -/* -------------------- HeaderDoc comments -------------------- */ - - -#if 0 /*! * @header SCSchemaDefinitions */ +#define __AVAILABILITY_INTERNAL__IPHONE_2_0_DEP__IPHONE_FUTURE __AVAILABILITY_INTERNAL__IPHONE_2_0/*SPI*/ + +CF_ASSUME_NONNULL_BEGIN + /*! @const kSCResvLink - @availability Introduced in Mac OS X 10.1. + @discussion Value is a CFString */ -extern const CFStringRef kSCResvLink; +extern const CFStringRef kSCResvLink __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); +#define kSCResvLink kSCResvLink /*! @const kSCResvInactive - @availability Introduced in Mac OS X 10.1. */ -extern const CFStringRef kSCResvInactive; +extern const CFStringRef kSCResvInactive __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); +#define kSCResvInactive kSCResvInactive /*! @const kSCPropInterfaceName - @availability Introduced in Mac OS X 10.1. + @discussion Value is a CFString */ -extern const CFStringRef kSCPropInterfaceName; +extern const CFStringRef kSCPropInterfaceName __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); +#define kSCPropInterfaceName kSCPropInterfaceName /*! @const kSCPropMACAddress - @availability Introduced in Mac OS X 10.1. + @discussion Value is a CFString */ -extern const CFStringRef kSCPropMACAddress; +extern const CFStringRef kSCPropMACAddress __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); +#define kSCPropMACAddress kSCPropMACAddress /*! @const kSCPropUserDefinedName - @availability Introduced in Mac OS X 10.1. + @discussion Value is a CFString */ -extern const CFStringRef kSCPropUserDefinedName; +extern const CFStringRef kSCPropUserDefinedName __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); +#define kSCPropUserDefinedName kSCPropUserDefinedName /*! @const kSCPropVersion - @availability Introduced in Mac OS X 10.1. + @discussion Value is a CFString */ -extern const CFStringRef kSCPropVersion; +extern const CFStringRef kSCPropVersion __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); +#define kSCPropVersion kSCPropVersion /*! @group Preference Keys @@ -534,27 +481,31 @@ extern const CFStringRef kSCPropVersion; /*! @const kSCPrefCurrentSet - @availability Introduced in Mac OS X 10.1. + @discussion Value is a CFString */ -extern const CFStringRef kSCPrefCurrentSet; +extern const CFStringRef kSCPrefCurrentSet __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); +#define kSCPrefCurrentSet kSCPrefCurrentSet /*! @const kSCPrefNetworkServices - @availability Introduced in Mac OS X 10.1. + @discussion Value is a CFDictionary */ -extern const CFStringRef kSCPrefNetworkServices; +extern const CFStringRef kSCPrefNetworkServices __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); +#define kSCPrefNetworkServices kSCPrefNetworkServices /*! @const kSCPrefSets - @availability Introduced in Mac OS X 10.1. + @discussion Value is a CFDictionary */ -extern const CFStringRef kSCPrefSets; +extern const CFStringRef kSCPrefSets __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); +#define kSCPrefSets kSCPrefSets /*! @const kSCPrefSystem - @availability Introduced in Mac OS X 10.1. + @discussion Value is a CFDictionary */ -extern const CFStringRef kSCPrefSystem; +extern const CFStringRef kSCPrefSystem __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); +#define kSCPrefSystem kSCPrefSystem /*! @group Component Keys @@ -562,51 +513,51 @@ extern const CFStringRef kSCPrefSystem; /*! @const kSCCompNetwork - @availability Introduced in Mac OS X 10.1. */ -extern const CFStringRef kSCCompNetwork; +extern const CFStringRef kSCCompNetwork __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); +#define kSCCompNetwork kSCCompNetwork /*! @const kSCCompService - @availability Introduced in Mac OS X 10.1. */ -extern const CFStringRef kSCCompService; +extern const CFStringRef kSCCompService __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); +#define kSCCompService kSCCompService /*! @const kSCCompGlobal - @availability Introduced in Mac OS X 10.1. */ -extern const CFStringRef kSCCompGlobal; +extern const CFStringRef kSCCompGlobal __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); +#define kSCCompGlobal kSCCompGlobal /*! @const kSCCompHostNames - @availability Introduced in Mac OS X 10.2. */ -extern const CFStringRef kSCCompHostNames; +extern const CFStringRef kSCCompHostNames __OSX_AVAILABLE_STARTING(__MAC_10_2,__IPHONE_2_0/*SPI*/); +#define kSCCompHostNames kSCCompHostNames /*! @const kSCCompInterface - @availability Introduced in Mac OS X 10.1. */ -extern const CFStringRef kSCCompInterface; +extern const CFStringRef kSCCompInterface __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); +#define kSCCompInterface kSCCompInterface /*! @const kSCCompSystem - @availability Introduced in Mac OS X 10.1. */ -extern const CFStringRef kSCCompSystem; +extern const CFStringRef kSCCompSystem __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); +#define kSCCompSystem kSCCompSystem /*! @const kSCCompUsers - @availability Introduced in Mac OS X 10.1. */ -extern const CFStringRef kSCCompUsers; +extern const CFStringRef kSCCompUsers __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); +#define kSCCompUsers kSCCompUsers /*! @const kSCCompAnyRegex - @availability Introduced in Mac OS X 10.1. */ -extern const CFStringRef kSCCompAnyRegex; +extern const CFStringRef kSCCompAnyRegex __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); +#define kSCCompAnyRegex kSCCompAnyRegex /*! @group Network Entity Keys @@ -614,129 +565,150 @@ extern const CFStringRef kSCCompAnyRegex; /*! @const kSCEntNetAirPort - @availability Introduced in Mac OS X 10.1. + @discussion Value is a CFDictionary */ -extern const CFStringRef kSCEntNetAirPort; +extern const CFStringRef kSCEntNetAirPort __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); +#define kSCEntNetAirPort kSCEntNetAirPort /*! @const kSCEntNetAppleTalk - @availability Introduced in Mac OS X 10.1, but later deprecated in Mac OS X 10.6. + @discussion Value is a CFDictionary */ -extern const CFStringRef kSCEntNetAppleTalk; +extern const CFStringRef kSCEntNetAppleTalk __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1,__MAC_10_6,__IPHONE_NA,__IPHONE_NA); +#define kSCEntNetAppleTalk kSCEntNetAppleTalk /*! @const kSCEntNetDHCP - @availability Introduced in Mac OS X 10.1. + @discussion Value is a CFDictionary */ -extern const CFStringRef kSCEntNetDHCP; +extern const CFStringRef kSCEntNetDHCP __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); +#define kSCEntNetDHCP kSCEntNetDHCP /*! @const kSCEntNetDNS - @availability Introduced in Mac OS X 10.1. + @discussion Value is a CFDictionary */ -extern const CFStringRef kSCEntNetDNS; +extern const CFStringRef kSCEntNetDNS __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); +#define kSCEntNetDNS kSCEntNetDNS /*! @const kSCEntNetEthernet - @availability Introduced in Mac OS X 10.1. + @discussion Value is a CFDictionary */ -extern const CFStringRef kSCEntNetEthernet; +extern const CFStringRef kSCEntNetEthernet __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); +#define kSCEntNetEthernet kSCEntNetEthernet /*! @const kSCEntNetFireWire - @availability Introduced in Mac OS X 10.3. + @discussion Value is a CFDictionary */ -extern const CFStringRef kSCEntNetFireWire; +extern const CFStringRef kSCEntNetFireWire __OSX_AVAILABLE_STARTING(__MAC_10_3,__IPHONE_2_0/*SPI*/); +#define kSCEntNetFireWire kSCEntNetFireWire /*! @const kSCEntNetInterface - @availability Introduced in Mac OS X 10.1. + @discussion Value is a CFDictionary */ -extern const CFStringRef kSCEntNetInterface; +extern const CFStringRef kSCEntNetInterface __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); +#define kSCEntNetInterface kSCEntNetInterface /*! @const kSCEntNetIPSec - @availability Introduced in Mac OS X 10.5. + @discussion Value is a CFDictionary */ -extern const CFStringRef kSCEntNetIPSec; +extern const CFStringRef kSCEntNetIPSec __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0/*SPI*/); +#define kSCEntNetIPSec kSCEntNetIPSec /*! @const kSCEntNetIPv4 - @availability Introduced in Mac OS X 10.1. + @discussion Value is a CFDictionary */ -extern const CFStringRef kSCEntNetIPv4; +extern const CFStringRef kSCEntNetIPv4 __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); +#define kSCEntNetIPv4 kSCEntNetIPv4 /*! @const kSCEntNetIPv6 - @availability Introduced in Mac OS X 10.1. + @discussion Value is a CFDictionary */ -extern const CFStringRef kSCEntNetIPv6; +extern const CFStringRef kSCEntNetIPv6 __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); +#define kSCEntNetIPv6 kSCEntNetIPv6 /*! @const kSCEntNetL2TP - @availability Introduced in Mac OS X 10.3. + @discussion Value is a CFDictionary */ -extern const CFStringRef kSCEntNetL2TP; +extern const CFStringRef kSCEntNetL2TP __OSX_AVAILABLE_STARTING(__MAC_10_3,__IPHONE_2_0/*SPI*/); +#define kSCEntNetL2TP kSCEntNetL2TP /*! @const kSCEntNetLink - @availability Introduced in Mac OS X 10.1. + @discussion Value is a CFDictionary */ -extern const CFStringRef kSCEntNetLink; +extern const CFStringRef kSCEntNetLink __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); +#define kSCEntNetLink kSCEntNetLink /*! @const kSCEntNetModem - @availability Introduced in Mac OS X 10.1. + @discussion Value is a CFDictionary */ -extern const CFStringRef kSCEntNetModem; +extern const CFStringRef kSCEntNetModem __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); +#define kSCEntNetModem kSCEntNetModem /*! @const kSCEntNetNetInfo - @availability Introduced in Mac OS X 10.1, but later deprecated in Mac OS X 10.5. + @discussion Value is a CFDictionary */ -extern const CFStringRef kSCEntNetNetInfo; +extern const CFStringRef kSCEntNetNetInfo __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1,__MAC_10_5,__IPHONE_NA,__IPHONE_NA); +#define kSCEntNetNetInfo kSCEntNetNetInfo /*! @const kSCEntNetPPP - @availability Introduced in Mac OS X 10.1. + @discussion Value is a CFDictionary */ -extern const CFStringRef kSCEntNetPPP; +extern const CFStringRef kSCEntNetPPP __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); +#define kSCEntNetPPP kSCEntNetPPP /*! @const kSCEntNetPPPoE - @availability Introduced in Mac OS X 10.1. + @discussion Value is a CFDictionary */ -extern const CFStringRef kSCEntNetPPPoE; +extern const CFStringRef kSCEntNetPPPoE __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); +#define kSCEntNetPPPoE kSCEntNetPPPoE /*! @const kSCEntNetPPPSerial - @availability Introduced in Mac OS X 10.3. + @discussion Value is a CFDictionary */ -extern const CFStringRef kSCEntNetPPPSerial; +extern const CFStringRef kSCEntNetPPPSerial __OSX_AVAILABLE_STARTING(__MAC_10_3,__IPHONE_2_0/*SPI*/); +#define kSCEntNetPPPSerial kSCEntNetPPPSerial /*! @const kSCEntNetPPTP - @availability Introduced in Mac OS X 10.3. + @discussion Value is a CFDictionary */ -extern const CFStringRef kSCEntNetPPTP; +extern const CFStringRef kSCEntNetPPTP __OSX_AVAILABLE_STARTING(__MAC_10_3,__IPHONE_2_0/*SPI*/); +#define kSCEntNetPPTP kSCEntNetPPTP /*! @const kSCEntNetProxies - @availability Introduced in Mac OS X 10.1. + @discussion Value is a CFDictionary */ -extern const CFStringRef kSCEntNetProxies; +extern const CFStringRef kSCEntNetProxies __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); +#define kSCEntNetProxies kSCEntNetProxies /*! @const kSCEntNetSMB - @availability Introduced in Mac OS X 10.5. + @discussion Value is a CFDictionary */ -extern const CFStringRef kSCEntNetSMB; +extern const CFStringRef kSCEntNetSMB __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0/*SPI*/); +#define kSCEntNetSMB kSCEntNetSMB /*! @const kSCEntNet6to4 - @availability Introduced in Mac OS X 10.3. + @discussion Value is a CFDictionary */ -extern const CFStringRef kSCEntNet6to4; +extern const CFStringRef kSCEntNet6to4 __OSX_AVAILABLE_STARTING(__MAC_10_3,__IPHONE_2_0/*SPI*/); +#define kSCEntNet6to4 kSCEntNet6to4 /*! @group kSCCompNetwork Properties @@ -744,21 +716,24 @@ extern const CFStringRef kSCEntNet6to4; /*! @const kSCPropNetOverridePrimary - @availability Introduced in Mac OS X 10.2. + @discussion Value is a CFNumber (0 or 1) */ -extern const CFStringRef kSCPropNetOverridePrimary; +extern const CFStringRef kSCPropNetOverridePrimary __OSX_AVAILABLE_STARTING(__MAC_10_2,__IPHONE_2_0/*SPI*/); +#define kSCPropNetOverridePrimary kSCPropNetOverridePrimary /*! @const kSCPropNetServiceOrder - @availability Introduced in Mac OS X 10.1. + @discussion Value is a CFArray[CFString] */ -extern const CFStringRef kSCPropNetServiceOrder; +extern const CFStringRef kSCPropNetServiceOrder __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); +#define kSCPropNetServiceOrder kSCPropNetServiceOrder /*! @const kSCPropNetPPPOverridePrimary - @availability Introduced in Mac OS X 10.1. + @discussion Value is a CFNumber (0 or 1) */ -extern const CFStringRef kSCPropNetPPPOverridePrimary; +extern const CFStringRef kSCPropNetPPPOverridePrimary __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); +#define kSCPropNetPPPOverridePrimary kSCPropNetPPPOverridePrimary /*! @group kSCCompNetworkInterface Properties @@ -766,9 +741,10 @@ extern const CFStringRef kSCPropNetPPPOverridePrimary; /*! @const kSCPropNetInterfaces - @availability Introduced in Mac OS X 10.2. + @discussion Value is a CFArray[CFString] */ -extern const CFStringRef kSCPropNetInterfaces; +extern const CFStringRef kSCPropNetInterfaces __OSX_AVAILABLE_STARTING(__MAC_10_2,__IPHONE_2_0/*SPI*/); +#define kSCPropNetInterfaces kSCPropNetInterfaces /*! @group kSCCompNetworkHostNames Properties @@ -776,9 +752,10 @@ extern const CFStringRef kSCPropNetInterfaces; /*! @const kSCPropNetLocalHostName - @availability Introduced in Mac OS X 10.2. + @discussion Value is a CFString */ -extern const CFStringRef kSCPropNetLocalHostName; +extern const CFStringRef kSCPropNetLocalHostName __OSX_AVAILABLE_STARTING(__MAC_10_2,__IPHONE_2_0/*SPI*/); +#define kSCPropNetLocalHostName kSCPropNetLocalHostName /*! @group kSCEntNetAirPort (Hardware) Entity Keys @@ -786,81 +763,88 @@ extern const CFStringRef kSCPropNetLocalHostName; /*! @const kSCPropNetAirPortAllowNetCreation - @availability Introduced in Mac OS X 10.2, but later deprecated in Mac OS X 10.9. + @discussion Value is a CFNumber (0 or 1) */ -extern const CFStringRef kSCPropNetAirPortAllowNetCreation; +extern const CFStringRef kSCPropNetAirPortAllowNetCreation __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_2,__MAC_10_9,__IPHONE_2_0/*SPI*/,__IPHONE_FUTURE/*SPI*/); +#define kSCPropNetAirPortAllowNetCreation kSCPropNetAirPortAllowNetCreation /*! @const kSCPropNetAirPortAuthPassword - @availability Introduced in Mac OS X 10.1, but later deprecated in Mac OS X 10.9. + @discussion Value is a CFData */ -extern const CFStringRef kSCPropNetAirPortAuthPassword; +extern const CFStringRef kSCPropNetAirPortAuthPassword __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1,__MAC_10_9,__IPHONE_2_0/*SPI*/,__IPHONE_FUTURE/*SPI*/); +#define kSCPropNetAirPortAuthPassword kSCPropNetAirPortAuthPassword /*! @const kSCPropNetAirPortAuthPasswordEncryption - @availability Introduced in Mac OS X 10.1, but later deprecated in Mac OS X 10.9. + @discussion Value is a CFString */ -extern const CFStringRef kSCPropNetAirPortAuthPasswordEncryption; +extern const CFStringRef kSCPropNetAirPortAuthPasswordEncryption __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1,__MAC_10_9,__IPHONE_2_0/*SPI*/,__IPHONE_FUTURE/*SPI*/); +#define kSCPropNetAirPortAuthPasswordEncryption kSCPropNetAirPortAuthPasswordEncryption /*! @const kSCPropNetAirPortJoinMode - @availability Introduced in Mac OS X 10.2, but later deprecated in Mac OS X 10.9. + @discussion Value is a CFString */ -extern const CFStringRef kSCPropNetAirPortJoinMode; +extern const CFStringRef kSCPropNetAirPortJoinMode __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_2,__MAC_10_9,__IPHONE_2_0/*SPI*/,__IPHONE_FUTURE/*SPI*/); +#define kSCPropNetAirPortJoinMode kSCPropNetAirPortJoinMode /*! @const kSCPropNetAirPortPowerEnabled - @availability Introduced in Mac OS X 10.1, but later deprecated in Mac OS X 10.9. + @discussion Value is a CFNumber (0 or 1) */ -extern const CFStringRef kSCPropNetAirPortPowerEnabled; +extern const CFStringRef kSCPropNetAirPortPowerEnabled __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1,__MAC_10_9,__IPHONE_2_0/*SPI*/,__IPHONE_FUTURE/*SPI*/); +#define kSCPropNetAirPortPowerEnabled kSCPropNetAirPortPowerEnabled /*! @const kSCPropNetAirPortPreferredNetwork - @availability Introduced in Mac OS X 10.1, but later deprecated in Mac OS X 10.9. + @discussion Value is a CFString */ -extern const CFStringRef kSCPropNetAirPortPreferredNetwork; +extern const CFStringRef kSCPropNetAirPortPreferredNetwork __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1,__MAC_10_9,__IPHONE_2_0/*SPI*/,__IPHONE_FUTURE/*SPI*/); +#define kSCPropNetAirPortPreferredNetwork kSCPropNetAirPortPreferredNetwork /*! @const kSCPropNetAirPortSavePasswords - @availability Introduced in Mac OS X 10.2, but later deprecated in Mac OS X 10.9. + @discussion Value is a CFNumber (0 or 1) */ -extern const CFStringRef kSCPropNetAirPortSavePasswords; +extern const CFStringRef kSCPropNetAirPortSavePasswords __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_2,__MAC_10_9,__IPHONE_2_0/*SPI*/,__IPHONE_FUTURE/*SPI*/); +#define kSCPropNetAirPortSavePasswords kSCPropNetAirPortSavePasswords /*! @const kSCValNetAirPortJoinModeAutomatic - @availability Introduced in Mac OS X 10.3, but later deprecated in Mac OS X 10.9. */ -extern const CFStringRef kSCValNetAirPortJoinModeAutomatic; +extern const CFStringRef kSCValNetAirPortJoinModeAutomatic __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_3,__MAC_10_9,__IPHONE_2_0/*SPI*/,__IPHONE_FUTURE/*SPI*/); +#define kSCValNetAirPortJoinModeAutomatic kSCValNetAirPortJoinModeAutomatic /*! @const kSCValNetAirPortJoinModePreferred - @availability Introduced in Mac OS X 10.2, but later deprecated in Mac OS X 10.9. */ -extern const CFStringRef kSCValNetAirPortJoinModePreferred; +extern const CFStringRef kSCValNetAirPortJoinModePreferred __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_2,__MAC_10_9,__IPHONE_2_0/*SPI*/,__IPHONE_FUTURE/*SPI*/); +#define kSCValNetAirPortJoinModePreferred kSCValNetAirPortJoinModePreferred /*! @const kSCValNetAirPortJoinModeRanked - @availability Introduced in Mac OS X 10.4, but later deprecated in Mac OS X 10.9. */ -extern const CFStringRef kSCValNetAirPortJoinModeRanked; +extern const CFStringRef kSCValNetAirPortJoinModeRanked __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4,__MAC_10_9,__IPHONE_2_0/*SPI*/,__IPHONE_FUTURE/*SPI*/); +#define kSCValNetAirPortJoinModeRanked kSCValNetAirPortJoinModeRanked /*! @const kSCValNetAirPortJoinModeRecent - @availability Introduced in Mac OS X 10.2, but later deprecated in Mac OS X 10.9. */ -extern const CFStringRef kSCValNetAirPortJoinModeRecent; +extern const CFStringRef kSCValNetAirPortJoinModeRecent __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_2,__MAC_10_9,__IPHONE_2_0/*SPI*/,__IPHONE_FUTURE/*SPI*/); +#define kSCValNetAirPortJoinModeRecent kSCValNetAirPortJoinModeRecent /*! @const kSCValNetAirPortJoinModeStrongest - @availability Introduced in Mac OS X 10.2, but later deprecated in Mac OS X 10.9. */ -extern const CFStringRef kSCValNetAirPortJoinModeStrongest; +extern const CFStringRef kSCValNetAirPortJoinModeStrongest __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_2,__MAC_10_9,__IPHONE_2_0/*SPI*/,__IPHONE_FUTURE/*SPI*/); +#define kSCValNetAirPortJoinModeStrongest kSCValNetAirPortJoinModeStrongest /*! @const kSCValNetAirPortAuthPasswordEncryptionKeychain - @availability Introduced in Mac OS X 10.3, but later deprecated in Mac OS X 10.9. */ -extern const CFStringRef kSCValNetAirPortAuthPasswordEncryptionKeychain; +extern const CFStringRef kSCValNetAirPortAuthPasswordEncryptionKeychain __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_3,__MAC_10_9,__IPHONE_2_0/*SPI*/,__IPHONE_FUTURE/*SPI*/); +#define kSCValNetAirPortAuthPasswordEncryptionKeychain kSCValNetAirPortAuthPasswordEncryptionKeychain /*! @group kSCEntNetAppleTalk Entity Keys @@ -868,75 +852,84 @@ extern const CFStringRef kSCValNetAirPortAuthPasswordEncryptionKeychain; /*! @const kSCPropNetAppleTalkComputerName - @availability Introduced in Mac OS X 10.1, but later deprecated in Mac OS X 10.6. + @discussion Value is a CFString */ -extern const CFStringRef kSCPropNetAppleTalkComputerName; +extern const CFStringRef kSCPropNetAppleTalkComputerName __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1,__MAC_10_6,__IPHONE_NA,__IPHONE_NA); +#define kSCPropNetAppleTalkComputerName kSCPropNetAppleTalkComputerName /*! @const kSCPropNetAppleTalkComputerNameEncoding - @availability Introduced in Mac OS X 10.1, but later deprecated in Mac OS X 10.6. + @discussion Value is a CFNumber */ -extern const CFStringRef kSCPropNetAppleTalkComputerNameEncoding; +extern const CFStringRef kSCPropNetAppleTalkComputerNameEncoding __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1,__MAC_10_6,__IPHONE_NA,__IPHONE_NA); +#define kSCPropNetAppleTalkComputerNameEncoding kSCPropNetAppleTalkComputerNameEncoding /*! @const kSCPropNetAppleTalkConfigMethod - @availability Introduced in Mac OS X 10.1, but later deprecated in Mac OS X 10.6. + @discussion Value is a CFString */ -extern const CFStringRef kSCPropNetAppleTalkConfigMethod; +extern const CFStringRef kSCPropNetAppleTalkConfigMethod __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1,__MAC_10_6,__IPHONE_NA,__IPHONE_NA); +#define kSCPropNetAppleTalkConfigMethod kSCPropNetAppleTalkConfigMethod /*! @const kSCPropNetAppleTalkDefaultZone - @availability Introduced in Mac OS X 10.1, but later deprecated in Mac OS X 10.6. + @discussion Value is a CFString */ -extern const CFStringRef kSCPropNetAppleTalkDefaultZone; +extern const CFStringRef kSCPropNetAppleTalkDefaultZone __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1,__MAC_10_6,__IPHONE_NA,__IPHONE_NA); +#define kSCPropNetAppleTalkDefaultZone kSCPropNetAppleTalkDefaultZone /*! @const kSCPropNetAppleTalkNetworkID - @availability Introduced in Mac OS X 10.1, but later deprecated in Mac OS X 10.6. + @discussion Value is a CFNumber */ -extern const CFStringRef kSCPropNetAppleTalkNetworkID; +extern const CFStringRef kSCPropNetAppleTalkNetworkID __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1,__MAC_10_6,__IPHONE_NA,__IPHONE_NA); +#define kSCPropNetAppleTalkNetworkID kSCPropNetAppleTalkNetworkID /*! @const kSCPropNetAppleTalkNetworkRange - @availability Introduced in Mac OS X 10.2, but later deprecated in Mac OS X 10.6. + @discussion Value is a CFArray[CFNumber] */ -extern const CFStringRef kSCPropNetAppleTalkNetworkRange; +extern const CFStringRef kSCPropNetAppleTalkNetworkRange __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_2,__MAC_10_6,__IPHONE_NA,__IPHONE_NA); +#define kSCPropNetAppleTalkNetworkRange kSCPropNetAppleTalkNetworkRange /*! @const kSCPropNetAppleTalkNodeID - @availability Introduced in Mac OS X 10.1, but later deprecated in Mac OS X 10.6. + @discussion Value is a CFNumber */ -extern const CFStringRef kSCPropNetAppleTalkNodeID; +extern const CFStringRef kSCPropNetAppleTalkNodeID __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1,__MAC_10_6,__IPHONE_NA,__IPHONE_NA); +#define kSCPropNetAppleTalkNodeID kSCPropNetAppleTalkNodeID /*! @const kSCPropNetAppleTalkSeedNetworkRange - @availability Introduced in Mac OS X 10.1, but later deprecated in Mac OS X 10.6. + @discussion Value is a CFArray[CFNumber] */ -extern const CFStringRef kSCPropNetAppleTalkSeedNetworkRange; +extern const CFStringRef kSCPropNetAppleTalkSeedNetworkRange __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1,__MAC_10_6,__IPHONE_NA,__IPHONE_NA); +#define kSCPropNetAppleTalkSeedNetworkRange kSCPropNetAppleTalkSeedNetworkRange /*! @const kSCPropNetAppleTalkSeedZones - @availability Introduced in Mac OS X 10.1, but later deprecated in Mac OS X 10.6. + @discussion Value is a CFArray[CFString] */ -extern const CFStringRef kSCPropNetAppleTalkSeedZones; +extern const CFStringRef kSCPropNetAppleTalkSeedZones __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1,__MAC_10_6,__IPHONE_NA,__IPHONE_NA); +#define kSCPropNetAppleTalkSeedZones kSCPropNetAppleTalkSeedZones /*! @const kSCValNetAppleTalkConfigMethodNode - @availability Introduced in Mac OS X 10.1, but later deprecated in Mac OS X 10.6. */ -extern const CFStringRef kSCValNetAppleTalkConfigMethodNode; +extern const CFStringRef kSCValNetAppleTalkConfigMethodNode __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1,__MAC_10_6,__IPHONE_NA,__IPHONE_NA); +#define kSCValNetAppleTalkConfigMethodNode kSCValNetAppleTalkConfigMethodNode /*! @const kSCValNetAppleTalkConfigMethodRouter - @availability Introduced in Mac OS X 10.1, but later deprecated in Mac OS X 10.6. */ -extern const CFStringRef kSCValNetAppleTalkConfigMethodRouter; +extern const CFStringRef kSCValNetAppleTalkConfigMethodRouter __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1,__MAC_10_6,__IPHONE_NA,__IPHONE_NA); +#define kSCValNetAppleTalkConfigMethodRouter kSCValNetAppleTalkConfigMethodRouter /*! @const kSCValNetAppleTalkConfigMethodSeedRouter - @availability Introduced in Mac OS X 10.1, but later deprecated in Mac OS X 10.6. */ -extern const CFStringRef kSCValNetAppleTalkConfigMethodSeedRouter; +extern const CFStringRef kSCValNetAppleTalkConfigMethodSeedRouter __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1,__MAC_10_6,__IPHONE_NA,__IPHONE_NA); +#define kSCValNetAppleTalkConfigMethodSeedRouter kSCValNetAppleTalkConfigMethodSeedRouter /*! @group kSCEntNetDNS Entity Keys @@ -944,63 +937,73 @@ extern const CFStringRef kSCValNetAppleTalkConfigMethodSeedRouter; /*! @const kSCPropNetDNSDomainName - @availability Introduced in Mac OS X 10.1. + @discussion Value is a CFString */ -extern const CFStringRef kSCPropNetDNSDomainName; +extern const CFStringRef kSCPropNetDNSDomainName __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); +#define kSCPropNetDNSDomainName kSCPropNetDNSDomainName /*! @const kSCPropNetDNSOptions - @availability Introduced in Mac OS X 10.4. + @discussion Value is a CFString */ -extern const CFStringRef kSCPropNetDNSOptions; +extern const CFStringRef kSCPropNetDNSOptions __OSX_AVAILABLE_STARTING(__MAC_10_4,__IPHONE_2_0/*SPI*/); +#define kSCPropNetDNSOptions kSCPropNetDNSOptions /*! @const kSCPropNetDNSSearchDomains - @availability Introduced in Mac OS X 10.1. + @discussion Value is a CFArray[CFString] */ -extern const CFStringRef kSCPropNetDNSSearchDomains; +extern const CFStringRef kSCPropNetDNSSearchDomains __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); +#define kSCPropNetDNSSearchDomains kSCPropNetDNSSearchDomains /*! @const kSCPropNetDNSSearchOrder - @availability Introduced in Mac OS X 10.4. + @discussion Value is a CFNumber */ -extern const CFStringRef kSCPropNetDNSSearchOrder; +extern const CFStringRef kSCPropNetDNSSearchOrder __OSX_AVAILABLE_STARTING(__MAC_10_4,__IPHONE_2_0/*SPI*/); +#define kSCPropNetDNSSearchOrder kSCPropNetDNSSearchOrder /*! @const kSCPropNetDNSServerAddresses - @availability Introduced in Mac OS X 10.1. + @discussion Value is a CFArray[CFString] */ -extern const CFStringRef kSCPropNetDNSServerAddresses; +extern const CFStringRef kSCPropNetDNSServerAddresses __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); +#define kSCPropNetDNSServerAddresses kSCPropNetDNSServerAddresses /*! @const kSCPropNetDNSServerPort - @availability Introduced in Mac OS X 10.4. + @discussion Value is a CFNumber */ -extern const CFStringRef kSCPropNetDNSServerPort; +extern const CFStringRef kSCPropNetDNSServerPort __OSX_AVAILABLE_STARTING(__MAC_10_4,__IPHONE_2_0/*SPI*/); +#define kSCPropNetDNSServerPort kSCPropNetDNSServerPort /*! @const kSCPropNetDNSServerTimeout - @availability Introduced in Mac OS X 10.4. + @discussion Value is a CFNumber */ -extern const CFStringRef kSCPropNetDNSServerTimeout; +extern const CFStringRef kSCPropNetDNSServerTimeout __OSX_AVAILABLE_STARTING(__MAC_10_4,__IPHONE_2_0/*SPI*/); +#define kSCPropNetDNSServerTimeout kSCPropNetDNSServerTimeout /*! @const kSCPropNetDNSSortList - @availability Introduced in Mac OS X 10.1. + @discussion Value is a CFArray[CFString] */ -extern const CFStringRef kSCPropNetDNSSortList; +extern const CFStringRef kSCPropNetDNSSortList __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); +#define kSCPropNetDNSSortList kSCPropNetDNSSortList /*! @const kSCPropNetDNSSupplementalMatchDomains - @availability Introduced in Mac OS X 10.4. + @discussion Value is a CFArray[CFString] */ -extern const CFStringRef kSCPropNetDNSSupplementalMatchDomains; +extern const CFStringRef kSCPropNetDNSSupplementalMatchDomains __OSX_AVAILABLE_STARTING(__MAC_10_4,__IPHONE_2_0/*SPI*/); +#define kSCPropNetDNSSupplementalMatchDomains kSCPropNetDNSSupplementalMatchDomains /*! @const kSCPropNetDNSSupplementalMatchOrders - @availability Introduced in Mac OS X 10.4. + @discussion Value is a CFArray[CFNumber] */ -extern const CFStringRef kSCPropNetDNSSupplementalMatchOrders; +extern const CFStringRef kSCPropNetDNSSupplementalMatchOrders __OSX_AVAILABLE_STARTING(__MAC_10_4,__IPHONE_2_0/*SPI*/); +#define kSCPropNetDNSSupplementalMatchOrders kSCPropNetDNSSupplementalMatchOrders /*! @group kSCEntNetEthernet (Hardware) Entity Keys @@ -1008,21 +1011,24 @@ extern const CFStringRef kSCPropNetDNSSupplementalMatchOrders; /*! @const kSCPropNetEthernetMediaSubType - @availability Introduced in Mac OS X 10.2. + @discussion Value is a CFString */ -extern const CFStringRef kSCPropNetEthernetMediaSubType; +extern const CFStringRef kSCPropNetEthernetMediaSubType __OSX_AVAILABLE_STARTING(__MAC_10_2,__IPHONE_2_0/*SPI*/); +#define kSCPropNetEthernetMediaSubType kSCPropNetEthernetMediaSubType /*! @const kSCPropNetEthernetMediaOptions - @availability Introduced in Mac OS X 10.2. + @discussion Value is a CFArray[CFString] */ -extern const CFStringRef kSCPropNetEthernetMediaOptions; +extern const CFStringRef kSCPropNetEthernetMediaOptions __OSX_AVAILABLE_STARTING(__MAC_10_2,__IPHONE_2_0/*SPI*/); +#define kSCPropNetEthernetMediaOptions kSCPropNetEthernetMediaOptions /*! @const kSCPropNetEthernetMTU - @availability Introduced in Mac OS X 10.2. + @discussion Value is a CFNumber */ -extern const CFStringRef kSCPropNetEthernetMTU; +extern const CFStringRef kSCPropNetEthernetMTU __OSX_AVAILABLE_STARTING(__MAC_10_2,__IPHONE_2_0/*SPI*/); +#define kSCPropNetEthernetMTU kSCPropNetEthernetMTU /*! @group kSCEntNetFireWire (Hardware) Entity Keys @@ -1034,87 +1040,92 @@ extern const CFStringRef kSCPropNetEthernetMTU; /*! @const kSCPropNetInterfaceDeviceName - @availability Introduced in Mac OS X 10.1. + @discussion Value is a CFString */ -extern const CFStringRef kSCPropNetInterfaceDeviceName; +extern const CFStringRef kSCPropNetInterfaceDeviceName __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); +#define kSCPropNetInterfaceDeviceName kSCPropNetInterfaceDeviceName /*! @const kSCPropNetInterfaceHardware - @availability Introduced in Mac OS X 10.1. + @discussion Value is a CFString */ -extern const CFStringRef kSCPropNetInterfaceHardware; +extern const CFStringRef kSCPropNetInterfaceHardware __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); +#define kSCPropNetInterfaceHardware kSCPropNetInterfaceHardware /*! @const kSCPropNetInterfaceType - @availability Introduced in Mac OS X 10.1. + @discussion Value is a CFString */ -extern const CFStringRef kSCPropNetInterfaceType; +extern const CFStringRef kSCPropNetInterfaceType __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); +#define kSCPropNetInterfaceType kSCPropNetInterfaceType /*! @const kSCPropNetInterfaceSubType - @availability Introduced in Mac OS X 10.1. + @discussion Value is a CFString */ -extern const CFStringRef kSCPropNetInterfaceSubType; +extern const CFStringRef kSCPropNetInterfaceSubType __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); +#define kSCPropNetInterfaceSubType kSCPropNetInterfaceSubType /*! @const kSCPropNetInterfaceSupportsModemOnHold - @availability Introduced in Mac OS X 10.2. + @discussion Value is a CFNumber (0 or 1) */ -extern const CFStringRef kSCPropNetInterfaceSupportsModemOnHold; +extern const CFStringRef kSCPropNetInterfaceSupportsModemOnHold __OSX_AVAILABLE_STARTING(__MAC_10_2,__IPHONE_2_0/*SPI*/); +#define kSCPropNetInterfaceSupportsModemOnHold kSCPropNetInterfaceSupportsModemOnHold /*! @const kSCValNetInterfaceTypeEthernet - @availability Introduced in Mac OS X 10.1. */ -extern const CFStringRef kSCValNetInterfaceTypeEthernet; +extern const CFStringRef kSCValNetInterfaceTypeEthernet __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); +#define kSCValNetInterfaceTypeEthernet kSCValNetInterfaceTypeEthernet /*! @const kSCValNetInterfaceTypeFireWire - @availability Introduced in Mac OS X 10.3. */ -extern const CFStringRef kSCValNetInterfaceTypeFireWire; +extern const CFStringRef kSCValNetInterfaceTypeFireWire __OSX_AVAILABLE_STARTING(__MAC_10_3,__IPHONE_2_0/*SPI*/); +#define kSCValNetInterfaceTypeFireWire kSCValNetInterfaceTypeFireWire /*! @const kSCValNetInterfaceTypePPP - @availability Introduced in Mac OS X 10.1. */ -extern const CFStringRef kSCValNetInterfaceTypePPP; +extern const CFStringRef kSCValNetInterfaceTypePPP __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); +#define kSCValNetInterfaceTypePPP kSCValNetInterfaceTypePPP /*! @const kSCValNetInterfaceType6to4 - @availability Introduced in Mac OS X 10.3. */ -extern const CFStringRef kSCValNetInterfaceType6to4; +extern const CFStringRef kSCValNetInterfaceType6to4 __OSX_AVAILABLE_STARTING(__MAC_10_3,__IPHONE_2_0/*SPI*/); +#define kSCValNetInterfaceType6to4 kSCValNetInterfaceType6to4 /*! @const kSCValNetInterfaceTypeIPSec - @availability Introduced in Mac OS X 10.6. */ -extern const CFStringRef kSCValNetInterfaceTypeIPSec; +extern const CFStringRef kSCValNetInterfaceTypeIPSec __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_2_0/*SPI*/); +#define kSCValNetInterfaceTypeIPSec kSCValNetInterfaceTypeIPSec /*! @const kSCValNetInterfaceSubTypePPPoE - @availability Introduced in Mac OS X 10.1. */ -extern const CFStringRef kSCValNetInterfaceSubTypePPPoE; +extern const CFStringRef kSCValNetInterfaceSubTypePPPoE __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); +#define kSCValNetInterfaceSubTypePPPoE kSCValNetInterfaceSubTypePPPoE /*! @const kSCValNetInterfaceSubTypePPPSerial - @availability Introduced in Mac OS X 10.1. */ -extern const CFStringRef kSCValNetInterfaceSubTypePPPSerial; +extern const CFStringRef kSCValNetInterfaceSubTypePPPSerial __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); +#define kSCValNetInterfaceSubTypePPPSerial kSCValNetInterfaceSubTypePPPSerial /*! @const kSCValNetInterfaceSubTypePPTP - @availability Introduced in Mac OS X 10.2. */ -extern const CFStringRef kSCValNetInterfaceSubTypePPTP; +extern const CFStringRef kSCValNetInterfaceSubTypePPTP __OSX_AVAILABLE_STARTING(__MAC_10_2,__IPHONE_2_0/*SPI*/); +#define kSCValNetInterfaceSubTypePPTP kSCValNetInterfaceSubTypePPTP /*! @const kSCValNetInterfaceSubTypeL2TP - @availability Introduced in Mac OS X 10.3. */ -extern const CFStringRef kSCValNetInterfaceSubTypeL2TP; +extern const CFStringRef kSCValNetInterfaceSubTypeL2TP __OSX_AVAILABLE_STARTING(__MAC_10_3,__IPHONE_2_0/*SPI*/); +#define kSCValNetInterfaceSubTypeL2TP kSCValNetInterfaceSubTypeL2TP /*! @group kSCEntNetIPSec Entity Keys @@ -1122,123 +1133,136 @@ extern const CFStringRef kSCValNetInterfaceSubTypeL2TP; /*! @const kSCPropNetIPSecAuthenticationMethod - @availability Introduced in Mac OS X 10.5. + @discussion Value is a CFString */ -extern const CFStringRef kSCPropNetIPSecAuthenticationMethod; +extern const CFStringRef kSCPropNetIPSecAuthenticationMethod __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0/*SPI*/); +#define kSCPropNetIPSecAuthenticationMethod kSCPropNetIPSecAuthenticationMethod /*! @const kSCPropNetIPSecLocalCertificate - @availability Introduced in Mac OS X 10.5. + @discussion Value is a CFData */ -extern const CFStringRef kSCPropNetIPSecLocalCertificate; +extern const CFStringRef kSCPropNetIPSecLocalCertificate __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0/*SPI*/); +#define kSCPropNetIPSecLocalCertificate kSCPropNetIPSecLocalCertificate /*! @const kSCPropNetIPSecLocalIdentifier - @availability Introduced in Mac OS X 10.5. + @discussion Value is a CFString */ -extern const CFStringRef kSCPropNetIPSecLocalIdentifier; +extern const CFStringRef kSCPropNetIPSecLocalIdentifier __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0/*SPI*/); +#define kSCPropNetIPSecLocalIdentifier kSCPropNetIPSecLocalIdentifier /*! @const kSCPropNetIPSecLocalIdentifierType - @availability Introduced in Mac OS X 10.5. + @discussion Value is a CFString */ -extern const CFStringRef kSCPropNetIPSecLocalIdentifierType; +extern const CFStringRef kSCPropNetIPSecLocalIdentifierType __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0/*SPI*/); +#define kSCPropNetIPSecLocalIdentifierType kSCPropNetIPSecLocalIdentifierType /*! @const kSCPropNetIPSecSharedSecret - @availability Introduced in Mac OS X 10.5. + @discussion Value is a CFString */ -extern const CFStringRef kSCPropNetIPSecSharedSecret; +extern const CFStringRef kSCPropNetIPSecSharedSecret __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0/*SPI*/); +#define kSCPropNetIPSecSharedSecret kSCPropNetIPSecSharedSecret /*! @const kSCPropNetIPSecSharedSecretEncryption - @availability Introduced in Mac OS X 10.5. + @discussion Value is a CFString */ -extern const CFStringRef kSCPropNetIPSecSharedSecretEncryption; +extern const CFStringRef kSCPropNetIPSecSharedSecretEncryption __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0/*SPI*/); +#define kSCPropNetIPSecSharedSecretEncryption kSCPropNetIPSecSharedSecretEncryption /*! @const kSCPropNetIPSecConnectTime - @availability Introduced in Mac OS X 10.6. + @discussion Value is a CFNumber */ -extern const CFStringRef kSCPropNetIPSecConnectTime; +extern const CFStringRef kSCPropNetIPSecConnectTime __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_2_0/*SPI*/); +#define kSCPropNetIPSecConnectTime kSCPropNetIPSecConnectTime /*! @const kSCPropNetIPSecRemoteAddress - @availability Introduced in Mac OS X 10.6. + @discussion Value is a CFString */ -extern const CFStringRef kSCPropNetIPSecRemoteAddress; +extern const CFStringRef kSCPropNetIPSecRemoteAddress __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_2_0/*SPI*/); +#define kSCPropNetIPSecRemoteAddress kSCPropNetIPSecRemoteAddress /*! @const kSCPropNetIPSecStatus - @availability Introduced in Mac OS X 10.6. + @discussion Value is a CFNumber */ -extern const CFStringRef kSCPropNetIPSecStatus; +extern const CFStringRef kSCPropNetIPSecStatus __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_2_0/*SPI*/); +#define kSCPropNetIPSecStatus kSCPropNetIPSecStatus /*! @const kSCPropNetIPSecXAuthEnabled - @availability Introduced in Mac OS X 10.6. + @discussion Value is a CFNumber (0 or 1) */ -extern const CFStringRef kSCPropNetIPSecXAuthEnabled; +extern const CFStringRef kSCPropNetIPSecXAuthEnabled __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_2_0/*SPI*/); +#define kSCPropNetIPSecXAuthEnabled kSCPropNetIPSecXAuthEnabled /*! @const kSCPropNetIPSecXAuthName - @availability Introduced in Mac OS X 10.6. + @discussion Value is a CFString */ -extern const CFStringRef kSCPropNetIPSecXAuthName; +extern const CFStringRef kSCPropNetIPSecXAuthName __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_2_0/*SPI*/); +#define kSCPropNetIPSecXAuthName kSCPropNetIPSecXAuthName /*! @const kSCPropNetIPSecXAuthPassword - @availability Introduced in Mac OS X 10.6. + @discussion Value is a CFString */ -extern const CFStringRef kSCPropNetIPSecXAuthPassword; +extern const CFStringRef kSCPropNetIPSecXAuthPassword __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_2_0/*SPI*/); +#define kSCPropNetIPSecXAuthPassword kSCPropNetIPSecXAuthPassword /*! @const kSCPropNetIPSecXAuthPasswordEncryption - @availability Introduced in Mac OS X 10.6. + @discussion Value is a CFString */ -extern const CFStringRef kSCPropNetIPSecXAuthPasswordEncryption; +extern const CFStringRef kSCPropNetIPSecXAuthPasswordEncryption __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_2_0/*SPI*/); +#define kSCPropNetIPSecXAuthPasswordEncryption kSCPropNetIPSecXAuthPasswordEncryption /*! @const kSCValNetIPSecAuthenticationMethodSharedSecret - @availability Introduced in Mac OS X 10.5. */ -extern const CFStringRef kSCValNetIPSecAuthenticationMethodSharedSecret; +extern const CFStringRef kSCValNetIPSecAuthenticationMethodSharedSecret __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0/*SPI*/); +#define kSCValNetIPSecAuthenticationMethodSharedSecret kSCValNetIPSecAuthenticationMethodSharedSecret /*! @const kSCValNetIPSecAuthenticationMethodCertificate - @availability Introduced in Mac OS X 10.5. */ -extern const CFStringRef kSCValNetIPSecAuthenticationMethodCertificate; +extern const CFStringRef kSCValNetIPSecAuthenticationMethodCertificate __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0/*SPI*/); +#define kSCValNetIPSecAuthenticationMethodCertificate kSCValNetIPSecAuthenticationMethodCertificate /*! @const kSCValNetIPSecAuthenticationMethodHybrid - @availability Introduced in Mac OS X 10.5. */ -extern const CFStringRef kSCValNetIPSecAuthenticationMethodHybrid; +extern const CFStringRef kSCValNetIPSecAuthenticationMethodHybrid __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0/*SPI*/); +#define kSCValNetIPSecAuthenticationMethodHybrid kSCValNetIPSecAuthenticationMethodHybrid /*! @const kSCValNetIPSecLocalIdentifierTypeKeyID - @availability Introduced in Mac OS X 10.5. */ -extern const CFStringRef kSCValNetIPSecLocalIdentifierTypeKeyID; +extern const CFStringRef kSCValNetIPSecLocalIdentifierTypeKeyID __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0/*SPI*/); +#define kSCValNetIPSecLocalIdentifierTypeKeyID kSCValNetIPSecLocalIdentifierTypeKeyID /*! @const kSCValNetIPSecSharedSecretEncryptionKeychain - @availability Introduced in Mac OS X 10.5. */ -extern const CFStringRef kSCValNetIPSecSharedSecretEncryptionKeychain; +extern const CFStringRef kSCValNetIPSecSharedSecretEncryptionKeychain __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0/*SPI*/); +#define kSCValNetIPSecSharedSecretEncryptionKeychain kSCValNetIPSecSharedSecretEncryptionKeychain /*! @const kSCValNetIPSecXAuthPasswordEncryptionKeychain - @availability Introduced in Mac OS X 10.6. */ -extern const CFStringRef kSCValNetIPSecXAuthPasswordEncryptionKeychain; +extern const CFStringRef kSCValNetIPSecXAuthPasswordEncryptionKeychain __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_2_0/*SPI*/); +#define kSCValNetIPSecXAuthPasswordEncryptionKeychain kSCValNetIPSecXAuthPasswordEncryptionKeychain /*! @const kSCValNetIPSecXAuthPasswordEncryptionPrompt - @availability Introduced in Mac OS X 10.6. */ -extern const CFStringRef kSCValNetIPSecXAuthPasswordEncryptionPrompt; +extern const CFStringRef kSCValNetIPSecXAuthPasswordEncryptionPrompt __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_3_0/*SPI*/); +#define kSCValNetIPSecXAuthPasswordEncryptionPrompt kSCValNetIPSecXAuthPasswordEncryptionPrompt /*! @group kSCEntNetIPv4 Entity Keys @@ -1246,87 +1270,94 @@ extern const CFStringRef kSCValNetIPSecXAuthPasswordEncryptionPrompt; /*! @const kSCPropNetIPv4Addresses - @availability Introduced in Mac OS X 10.1. + @discussion Value is a CFArray[CFString] */ -extern const CFStringRef kSCPropNetIPv4Addresses; +extern const CFStringRef kSCPropNetIPv4Addresses __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); +#define kSCPropNetIPv4Addresses kSCPropNetIPv4Addresses /*! @const kSCPropNetIPv4ConfigMethod - @availability Introduced in Mac OS X 10.1. + @discussion Value is a CFString */ -extern const CFStringRef kSCPropNetIPv4ConfigMethod; +extern const CFStringRef kSCPropNetIPv4ConfigMethod __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); +#define kSCPropNetIPv4ConfigMethod kSCPropNetIPv4ConfigMethod /*! @const kSCPropNetIPv4DHCPClientID - @availability Introduced in Mac OS X 10.1. + @discussion Value is a CFString */ -extern const CFStringRef kSCPropNetIPv4DHCPClientID; +extern const CFStringRef kSCPropNetIPv4DHCPClientID __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); +#define kSCPropNetIPv4DHCPClientID kSCPropNetIPv4DHCPClientID /*! @const kSCPropNetIPv4Router - @availability Introduced in Mac OS X 10.1. + @discussion Value is a CFString */ -extern const CFStringRef kSCPropNetIPv4Router; +extern const CFStringRef kSCPropNetIPv4Router __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); +#define kSCPropNetIPv4Router kSCPropNetIPv4Router /*! @const kSCPropNetIPv4SubnetMasks - @availability Introduced in Mac OS X 10.1. + @discussion Value is a CFArray[CFString] */ -extern const CFStringRef kSCPropNetIPv4SubnetMasks; +extern const CFStringRef kSCPropNetIPv4SubnetMasks __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); +#define kSCPropNetIPv4SubnetMasks kSCPropNetIPv4SubnetMasks /*! @const kSCPropNetIPv4DestAddresses - @availability Introduced in Mac OS X 10.1. + @discussion Value is a CFArray[CFString] */ -extern const CFStringRef kSCPropNetIPv4DestAddresses; +extern const CFStringRef kSCPropNetIPv4DestAddresses __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); +#define kSCPropNetIPv4DestAddresses kSCPropNetIPv4DestAddresses /*! @const kSCPropNetIPv4BroadcastAddresses - @availability Introduced in Mac OS X 10.1. + @discussion Value is a CFArray[CFString] */ -extern const CFStringRef kSCPropNetIPv4BroadcastAddresses; +extern const CFStringRef kSCPropNetIPv4BroadcastAddresses __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); +#define kSCPropNetIPv4BroadcastAddresses kSCPropNetIPv4BroadcastAddresses /*! @const kSCValNetIPv4ConfigMethodAutomatic - @availability Introduced in Mac OS X 10.6. */ -extern const CFStringRef kSCValNetIPv4ConfigMethodAutomatic; +extern const CFStringRef kSCValNetIPv4ConfigMethodAutomatic __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_2_0/*SPI*/); +#define kSCValNetIPv4ConfigMethodAutomatic kSCValNetIPv4ConfigMethodAutomatic /*! @const kSCValNetIPv4ConfigMethodBOOTP - @availability Introduced in Mac OS X 10.1. */ -extern const CFStringRef kSCValNetIPv4ConfigMethodBOOTP; +extern const CFStringRef kSCValNetIPv4ConfigMethodBOOTP __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); +#define kSCValNetIPv4ConfigMethodBOOTP kSCValNetIPv4ConfigMethodBOOTP /*! @const kSCValNetIPv4ConfigMethodDHCP - @availability Introduced in Mac OS X 10.1. */ -extern const CFStringRef kSCValNetIPv4ConfigMethodDHCP; +extern const CFStringRef kSCValNetIPv4ConfigMethodDHCP __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); +#define kSCValNetIPv4ConfigMethodDHCP kSCValNetIPv4ConfigMethodDHCP /*! @const kSCValNetIPv4ConfigMethodINFORM - @availability Introduced in Mac OS X 10.1. */ -extern const CFStringRef kSCValNetIPv4ConfigMethodINFORM; +extern const CFStringRef kSCValNetIPv4ConfigMethodINFORM __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); +#define kSCValNetIPv4ConfigMethodINFORM kSCValNetIPv4ConfigMethodINFORM /*! @const kSCValNetIPv4ConfigMethodLinkLocal - @availability Introduced in Mac OS X 10.2. */ -extern const CFStringRef kSCValNetIPv4ConfigMethodLinkLocal; +extern const CFStringRef kSCValNetIPv4ConfigMethodLinkLocal __OSX_AVAILABLE_STARTING(__MAC_10_2,__IPHONE_2_0/*SPI*/); +#define kSCValNetIPv4ConfigMethodLinkLocal kSCValNetIPv4ConfigMethodLinkLocal /*! @const kSCValNetIPv4ConfigMethodManual - @availability Introduced in Mac OS X 10.1. */ -extern const CFStringRef kSCValNetIPv4ConfigMethodManual; +extern const CFStringRef kSCValNetIPv4ConfigMethodManual __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); +#define kSCValNetIPv4ConfigMethodManual kSCValNetIPv4ConfigMethodManual /*! @const kSCValNetIPv4ConfigMethodPPP - @availability Introduced in Mac OS X 10.1. */ -extern const CFStringRef kSCValNetIPv4ConfigMethodPPP; +extern const CFStringRef kSCValNetIPv4ConfigMethodPPP __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); +#define kSCValNetIPv4ConfigMethodPPP kSCValNetIPv4ConfigMethodPPP /*! @group kSCEntNetIPv6 Entity Keys @@ -1334,69 +1365,75 @@ extern const CFStringRef kSCValNetIPv4ConfigMethodPPP; /*! @const kSCPropNetIPv6Addresses - @availability Introduced in Mac OS X 10.1. + @discussion Value is a CFArray[CFString] */ -extern const CFStringRef kSCPropNetIPv6Addresses; +extern const CFStringRef kSCPropNetIPv6Addresses __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); +#define kSCPropNetIPv6Addresses kSCPropNetIPv6Addresses /*! @const kSCPropNetIPv6ConfigMethod - @availability Introduced in Mac OS X 10.1. + @discussion Value is a CFString */ -extern const CFStringRef kSCPropNetIPv6ConfigMethod; +extern const CFStringRef kSCPropNetIPv6ConfigMethod __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); +#define kSCPropNetIPv6ConfigMethod kSCPropNetIPv6ConfigMethod /*! @const kSCPropNetIPv6DestAddresses - @availability Introduced in Mac OS X 10.3. + @discussion Value is a CFArray[CFString] */ -extern const CFStringRef kSCPropNetIPv6DestAddresses; +extern const CFStringRef kSCPropNetIPv6DestAddresses __OSX_AVAILABLE_STARTING(__MAC_10_3,__IPHONE_2_0/*SPI*/); +#define kSCPropNetIPv6DestAddresses kSCPropNetIPv6DestAddresses /*! @const kSCPropNetIPv6Flags - @availability Introduced in Mac OS X 10.3. + @discussion Value is a CFNumber */ -extern const CFStringRef kSCPropNetIPv6Flags; +extern const CFStringRef kSCPropNetIPv6Flags __OSX_AVAILABLE_STARTING(__MAC_10_3,__IPHONE_2_0/*SPI*/); +#define kSCPropNetIPv6Flags kSCPropNetIPv6Flags /*! @const kSCPropNetIPv6PrefixLength - @availability Introduced in Mac OS X 10.3. + @discussion Value is a CFArray[CFNumber] */ -extern const CFStringRef kSCPropNetIPv6PrefixLength; +extern const CFStringRef kSCPropNetIPv6PrefixLength __OSX_AVAILABLE_STARTING(__MAC_10_3,__IPHONE_2_0/*SPI*/); +#define kSCPropNetIPv6PrefixLength kSCPropNetIPv6PrefixLength /*! @const kSCPropNetIPv6Router - @availability Introduced in Mac OS X 10.3. + @discussion Value is a CFString */ -extern const CFStringRef kSCPropNetIPv6Router; +extern const CFStringRef kSCPropNetIPv6Router __OSX_AVAILABLE_STARTING(__MAC_10_3,__IPHONE_2_0/*SPI*/); +#define kSCPropNetIPv6Router kSCPropNetIPv6Router /*! @const kSCValNetIPv6ConfigMethodAutomatic - @availability Introduced in Mac OS X 10.3. */ -extern const CFStringRef kSCValNetIPv6ConfigMethodAutomatic; +extern const CFStringRef kSCValNetIPv6ConfigMethodAutomatic __OSX_AVAILABLE_STARTING(__MAC_10_3,__IPHONE_2_0/*SPI*/); +#define kSCValNetIPv6ConfigMethodAutomatic kSCValNetIPv6ConfigMethodAutomatic /*! @const kSCValNetIPv6ConfigMethodLinkLocal - @availability Introduced in Mac OS X 10.7. */ -extern const CFStringRef kSCValNetIPv6ConfigMethodLinkLocal; +extern const CFStringRef kSCValNetIPv6ConfigMethodLinkLocal __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_4_0/*SPI*/); +#define kSCValNetIPv6ConfigMethodLinkLocal kSCValNetIPv6ConfigMethodLinkLocal /*! @const kSCValNetIPv6ConfigMethodManual - @availability Introduced in Mac OS X 10.3. */ -extern const CFStringRef kSCValNetIPv6ConfigMethodManual; +extern const CFStringRef kSCValNetIPv6ConfigMethodManual __OSX_AVAILABLE_STARTING(__MAC_10_3,__IPHONE_2_0/*SPI*/); +#define kSCValNetIPv6ConfigMethodManual kSCValNetIPv6ConfigMethodManual /*! @const kSCValNetIPv6ConfigMethodRouterAdvertisement - @availability Introduced in Mac OS X 10.3. */ -extern const CFStringRef kSCValNetIPv6ConfigMethodRouterAdvertisement; +extern const CFStringRef kSCValNetIPv6ConfigMethodRouterAdvertisement __OSX_AVAILABLE_STARTING(__MAC_10_3,__IPHONE_2_0/*SPI*/); +#define kSCValNetIPv6ConfigMethodRouterAdvertisement kSCValNetIPv6ConfigMethodRouterAdvertisement /*! @const kSCValNetIPv6ConfigMethod6to4 - @availability Introduced in Mac OS X 10.3. */ -extern const CFStringRef kSCValNetIPv6ConfigMethod6to4; +extern const CFStringRef kSCValNetIPv6ConfigMethod6to4 __OSX_AVAILABLE_STARTING(__MAC_10_3,__IPHONE_2_0/*SPI*/); +#define kSCValNetIPv6ConfigMethod6to4 kSCValNetIPv6ConfigMethod6to4 /*! @group kSCEntNet6to4 Entity Keys @@ -1404,9 +1441,10 @@ extern const CFStringRef kSCValNetIPv6ConfigMethod6to4; /*! @const kSCPropNet6to4Relay - @availability Introduced in Mac OS X 10.3. + @discussion Value is a CFString */ -extern const CFStringRef kSCPropNet6to4Relay; +extern const CFStringRef kSCPropNet6to4Relay __OSX_AVAILABLE_STARTING(__MAC_10_3,__IPHONE_2_0/*SPI*/); +#define kSCPropNet6to4Relay kSCPropNet6to4Relay /*! @group kSCEntNetLink Entity Keys @@ -1414,15 +1452,17 @@ extern const CFStringRef kSCPropNet6to4Relay; /*! @const kSCPropNetLinkActive - @availability Introduced in Mac OS X 10.1. + @discussion Value is a CFBoolean */ -extern const CFStringRef kSCPropNetLinkActive; +extern const CFStringRef kSCPropNetLinkActive __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); +#define kSCPropNetLinkActive kSCPropNetLinkActive /*! @const kSCPropNetLinkDetaching - @availability Introduced in Mac OS X 10.2. + @discussion Value is a CFBoolean */ -extern const CFStringRef kSCPropNetLinkDetaching; +extern const CFStringRef kSCPropNetLinkDetaching __OSX_AVAILABLE_STARTING(__MAC_10_2,__IPHONE_2_0/*SPI*/); +#define kSCPropNetLinkDetaching kSCPropNetLinkDetaching /*! @group kSCEntNetModem (Hardware) Entity Keys @@ -1430,135 +1470,154 @@ extern const CFStringRef kSCPropNetLinkDetaching; /*! @const kSCPropNetModemAccessPointName - @availability Introduced in Mac OS X 10.5. + @discussion Value is a CFString */ -extern const CFStringRef kSCPropNetModemAccessPointName; +extern const CFStringRef kSCPropNetModemAccessPointName __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0/*SPI*/); +#define kSCPropNetModemAccessPointName kSCPropNetModemAccessPointName /*! @const kSCPropNetModemConnectionPersonality - @availability Introduced in Mac OS X 10.5. + @discussion Value is a CFString */ -extern const CFStringRef kSCPropNetModemConnectionPersonality; +extern const CFStringRef kSCPropNetModemConnectionPersonality __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0/*SPI*/); +#define kSCPropNetModemConnectionPersonality kSCPropNetModemConnectionPersonality /*! @const kSCPropNetModemConnectionScript - @availability Introduced in Mac OS X 10.1. + @discussion Value is a CFString */ -extern const CFStringRef kSCPropNetModemConnectionScript; +extern const CFStringRef kSCPropNetModemConnectionScript __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); +#define kSCPropNetModemConnectionScript kSCPropNetModemConnectionScript /*! @const kSCPropNetModemConnectSpeed - @availability Introduced in Mac OS X 10.2. + @discussion Value is a CFNumber */ -extern const CFStringRef kSCPropNetModemConnectSpeed; +extern const CFStringRef kSCPropNetModemConnectSpeed __OSX_AVAILABLE_STARTING(__MAC_10_2,__IPHONE_2_0/*SPI*/); +#define kSCPropNetModemConnectSpeed kSCPropNetModemConnectSpeed /*! @const kSCPropNetModemDataCompression - @availability Introduced in Mac OS X 10.1. + @discussion Value is a CFNumber (0 or 1) */ -extern const CFStringRef kSCPropNetModemDataCompression; +extern const CFStringRef kSCPropNetModemDataCompression __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); +#define kSCPropNetModemDataCompression kSCPropNetModemDataCompression /*! @const kSCPropNetModemDeviceContextID - @availability Introduced in Mac OS X 10.5. + @discussion Value is a CFString */ -extern const CFStringRef kSCPropNetModemDeviceContextID; +extern const CFStringRef kSCPropNetModemDeviceContextID __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0/*SPI*/); +#define kSCPropNetModemDeviceContextID kSCPropNetModemDeviceContextID /*! @const kSCPropNetModemDeviceModel - @availability Introduced in Mac OS X 10.5. + @discussion Value is a CFString */ -extern const CFStringRef kSCPropNetModemDeviceModel; +extern const CFStringRef kSCPropNetModemDeviceModel __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0/*SPI*/); +#define kSCPropNetModemDeviceModel kSCPropNetModemDeviceModel /*! @const kSCPropNetModemDeviceVendor - @availability Introduced in Mac OS X 10.5. + @discussion Value is a CFString */ -extern const CFStringRef kSCPropNetModemDeviceVendor; +extern const CFStringRef kSCPropNetModemDeviceVendor __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0/*SPI*/); +#define kSCPropNetModemDeviceVendor kSCPropNetModemDeviceVendor /*! @const kSCPropNetModemDialMode - @availability Introduced in Mac OS X 10.1. + @discussion Value is a CFString */ -extern const CFStringRef kSCPropNetModemDialMode; +extern const CFStringRef kSCPropNetModemDialMode __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); +#define kSCPropNetModemDialMode kSCPropNetModemDialMode /*! @const kSCPropNetModemErrorCorrection - @availability Introduced in Mac OS X 10.1. + @discussion Value is a CFNumber (0 or 1) */ -extern const CFStringRef kSCPropNetModemErrorCorrection; +extern const CFStringRef kSCPropNetModemErrorCorrection __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); +#define kSCPropNetModemErrorCorrection kSCPropNetModemErrorCorrection /*! @const kSCPropNetModemHoldCallWaitingAudibleAlert - @availability Introduced in Mac OS X 10.2. + @discussion Value is a CFNumber (0 or 1) */ -extern const CFStringRef kSCPropNetModemHoldCallWaitingAudibleAlert; +extern const CFStringRef kSCPropNetModemHoldCallWaitingAudibleAlert __OSX_AVAILABLE_STARTING(__MAC_10_2,__IPHONE_2_0/*SPI*/); +#define kSCPropNetModemHoldCallWaitingAudibleAlert kSCPropNetModemHoldCallWaitingAudibleAlert /*! @const kSCPropNetModemHoldDisconnectOnAnswer - @availability Introduced in Mac OS X 10.2. + @discussion Value is a CFNumber (0 or 1) */ -extern const CFStringRef kSCPropNetModemHoldDisconnectOnAnswer; +extern const CFStringRef kSCPropNetModemHoldDisconnectOnAnswer __OSX_AVAILABLE_STARTING(__MAC_10_2,__IPHONE_2_0/*SPI*/); +#define kSCPropNetModemHoldDisconnectOnAnswer kSCPropNetModemHoldDisconnectOnAnswer /*! @const kSCPropNetModemHoldEnabled - @availability Introduced in Mac OS X 10.2. + @discussion Value is a CFNumber (0 or 1) */ -extern const CFStringRef kSCPropNetModemHoldEnabled; +extern const CFStringRef kSCPropNetModemHoldEnabled __OSX_AVAILABLE_STARTING(__MAC_10_2,__IPHONE_2_0/*SPI*/); +#define kSCPropNetModemHoldEnabled kSCPropNetModemHoldEnabled /*! @const kSCPropNetModemHoldReminder - @availability Introduced in Mac OS X 10.2. + @discussion Value is a CFNumber (0 or 1) */ -extern const CFStringRef kSCPropNetModemHoldReminder; +extern const CFStringRef kSCPropNetModemHoldReminder __OSX_AVAILABLE_STARTING(__MAC_10_2,__IPHONE_2_0/*SPI*/); +#define kSCPropNetModemHoldReminder kSCPropNetModemHoldReminder /*! @const kSCPropNetModemHoldReminderTime - @availability Introduced in Mac OS X 10.2. + @discussion Value is a CFNumber */ -extern const CFStringRef kSCPropNetModemHoldReminderTime; +extern const CFStringRef kSCPropNetModemHoldReminderTime __OSX_AVAILABLE_STARTING(__MAC_10_2,__IPHONE_2_0/*SPI*/); +#define kSCPropNetModemHoldReminderTime kSCPropNetModemHoldReminderTime /*! @const kSCPropNetModemNote - @availability Introduced in Mac OS X 10.2. + @discussion Value is a CFString */ -extern const CFStringRef kSCPropNetModemNote; +extern const CFStringRef kSCPropNetModemNote __OSX_AVAILABLE_STARTING(__MAC_10_2,__IPHONE_2_0/*SPI*/); +#define kSCPropNetModemNote kSCPropNetModemNote /*! @const kSCPropNetModemPulseDial - @availability Introduced in Mac OS X 10.1. + @discussion Value is a CFNumber (0 or 1) */ -extern const CFStringRef kSCPropNetModemPulseDial; +extern const CFStringRef kSCPropNetModemPulseDial __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); +#define kSCPropNetModemPulseDial kSCPropNetModemPulseDial /*! @const kSCPropNetModemSpeaker - @availability Introduced in Mac OS X 10.1. + @discussion Value is a CFNumber (0 or 1) */ -extern const CFStringRef kSCPropNetModemSpeaker; +extern const CFStringRef kSCPropNetModemSpeaker __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); +#define kSCPropNetModemSpeaker kSCPropNetModemSpeaker /*! @const kSCPropNetModemSpeed - @availability Introduced in Mac OS X 10.1. + @discussion Value is a CFNumber */ -extern const CFStringRef kSCPropNetModemSpeed; +extern const CFStringRef kSCPropNetModemSpeed __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); +#define kSCPropNetModemSpeed kSCPropNetModemSpeed /*! @const kSCValNetModemDialModeIgnoreDialTone - @availability Introduced in Mac OS X 10.1. */ -extern const CFStringRef kSCValNetModemDialModeIgnoreDialTone; +extern const CFStringRef kSCValNetModemDialModeIgnoreDialTone __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); +#define kSCValNetModemDialModeIgnoreDialTone kSCValNetModemDialModeIgnoreDialTone /*! @const kSCValNetModemDialModeManual - @availability Introduced in Mac OS X 10.1. */ -extern const CFStringRef kSCValNetModemDialModeManual; +extern const CFStringRef kSCValNetModemDialModeManual __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); +#define kSCValNetModemDialModeManual kSCValNetModemDialModeManual /*! @const kSCValNetModemDialModeWaitForDialTone - @availability Introduced in Mac OS X 10.1. */ -extern const CFStringRef kSCValNetModemDialModeWaitForDialTone; +extern const CFStringRef kSCValNetModemDialModeWaitForDialTone __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); +#define kSCValNetModemDialModeWaitForDialTone kSCValNetModemDialModeWaitForDialTone /*! @group kSCEntNetNetInfo Entity Keys @@ -1566,51 +1625,55 @@ extern const CFStringRef kSCValNetModemDialModeWaitForDialTone; /*! @const kSCPropNetNetInfoBindingMethods - @availability Introduced in Mac OS X 10.1, but later deprecated in Mac OS X 10.5. + @discussion Value is a CFString */ -extern const CFStringRef kSCPropNetNetInfoBindingMethods; +extern const CFStringRef kSCPropNetNetInfoBindingMethods __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1,__MAC_10_5,__IPHONE_NA,__IPHONE_NA); +#define kSCPropNetNetInfoBindingMethods kSCPropNetNetInfoBindingMethods /*! @const kSCPropNetNetInfoServerAddresses - @availability Introduced in Mac OS X 10.1, but later deprecated in Mac OS X 10.5. + @discussion Value is a CFArray[CFString] */ -extern const CFStringRef kSCPropNetNetInfoServerAddresses; +extern const CFStringRef kSCPropNetNetInfoServerAddresses __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1,__MAC_10_5,__IPHONE_NA,__IPHONE_NA); +#define kSCPropNetNetInfoServerAddresses kSCPropNetNetInfoServerAddresses /*! @const kSCPropNetNetInfoServerTags - @availability Introduced in Mac OS X 10.1, but later deprecated in Mac OS X 10.5. + @discussion Value is a CFArray[CFString] */ -extern const CFStringRef kSCPropNetNetInfoServerTags; +extern const CFStringRef kSCPropNetNetInfoServerTags __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1,__MAC_10_5,__IPHONE_NA,__IPHONE_NA); +#define kSCPropNetNetInfoServerTags kSCPropNetNetInfoServerTags /*! @const kSCPropNetNetInfoBroadcastServerTag - @availability Introduced in Mac OS X 10.1, but later deprecated in Mac OS X 10.5. + @discussion Value is a CFString */ -extern const CFStringRef kSCPropNetNetInfoBroadcastServerTag; +extern const CFStringRef kSCPropNetNetInfoBroadcastServerTag __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1,__MAC_10_5,__IPHONE_NA,__IPHONE_NA); +#define kSCPropNetNetInfoBroadcastServerTag kSCPropNetNetInfoBroadcastServerTag /*! @const kSCValNetNetInfoBindingMethodsBroadcast - @availability Introduced in Mac OS X 10.1, but later deprecated in Mac OS X 10.5. */ -extern const CFStringRef kSCValNetNetInfoBindingMethodsBroadcast; +extern const CFStringRef kSCValNetNetInfoBindingMethodsBroadcast __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1,__MAC_10_5,__IPHONE_NA,__IPHONE_NA); +#define kSCValNetNetInfoBindingMethodsBroadcast kSCValNetNetInfoBindingMethodsBroadcast /*! @const kSCValNetNetInfoBindingMethodsDHCP - @availability Introduced in Mac OS X 10.1, but later deprecated in Mac OS X 10.5. */ -extern const CFStringRef kSCValNetNetInfoBindingMethodsDHCP; +extern const CFStringRef kSCValNetNetInfoBindingMethodsDHCP __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1,__MAC_10_5,__IPHONE_NA,__IPHONE_NA); +#define kSCValNetNetInfoBindingMethodsDHCP kSCValNetNetInfoBindingMethodsDHCP /*! @const kSCValNetNetInfoBindingMethodsManual - @availability Introduced in Mac OS X 10.1, but later deprecated in Mac OS X 10.5. */ -extern const CFStringRef kSCValNetNetInfoBindingMethodsManual; +extern const CFStringRef kSCValNetNetInfoBindingMethodsManual __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1,__MAC_10_5,__IPHONE_NA,__IPHONE_NA); +#define kSCValNetNetInfoBindingMethodsManual kSCValNetNetInfoBindingMethodsManual /*! @const kSCValNetNetInfoDefaultServerTag - @availability Introduced in Mac OS X 10.1, but later deprecated in Mac OS X 10.5. */ -extern const CFStringRef kSCValNetNetInfoDefaultServerTag; +extern const CFStringRef kSCValNetNetInfoDefaultServerTag __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1,__MAC_10_5,__IPHONE_NA,__IPHONE_NA); +#define kSCValNetNetInfoDefaultServerTag kSCValNetNetInfoDefaultServerTag /*! @group kSCEntNetPPP Entity Keys @@ -1618,351 +1681,407 @@ extern const CFStringRef kSCValNetNetInfoDefaultServerTag; /*! @const kSCPropNetPPPACSPEnabled - @availability Introduced in Mac OS X 10.3. + @discussion Value is a CFNumber (0 or 1) */ -extern const CFStringRef kSCPropNetPPPACSPEnabled; +extern const CFStringRef kSCPropNetPPPACSPEnabled __OSX_AVAILABLE_STARTING(__MAC_10_3,__IPHONE_2_0/*SPI*/); +#define kSCPropNetPPPACSPEnabled kSCPropNetPPPACSPEnabled /*! @const kSCPropNetPPPConnectTime - @availability Introduced in Mac OS X 10.2. + @discussion Value is a CFNumber */ -extern const CFStringRef kSCPropNetPPPConnectTime; +extern const CFStringRef kSCPropNetPPPConnectTime __OSX_AVAILABLE_STARTING(__MAC_10_2,__IPHONE_2_0/*SPI*/); +#define kSCPropNetPPPConnectTime kSCPropNetPPPConnectTime /*! @const kSCPropNetPPPDeviceLastCause - @availability Introduced in Mac OS X 10.2. + @discussion Value is a CFNumber */ -extern const CFStringRef kSCPropNetPPPDeviceLastCause; +extern const CFStringRef kSCPropNetPPPDeviceLastCause __OSX_AVAILABLE_STARTING(__MAC_10_2,__IPHONE_2_0/*SPI*/); +#define kSCPropNetPPPDeviceLastCause kSCPropNetPPPDeviceLastCause /*! @const kSCPropNetPPPDialOnDemand - @availability Introduced in Mac OS X 10.1. + @discussion Value is a CFNumber (0 or 1) */ -extern const CFStringRef kSCPropNetPPPDialOnDemand; +extern const CFStringRef kSCPropNetPPPDialOnDemand __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); +#define kSCPropNetPPPDialOnDemand kSCPropNetPPPDialOnDemand /*! @const kSCPropNetPPPDisconnectOnFastUserSwitch - @availability Introduced in Mac OS X 10.4. + @discussion Value is a CFNumber (0 or 1) */ -extern const CFStringRef kSCPropNetPPPDisconnectOnFastUserSwitch; +extern const CFStringRef kSCPropNetPPPDisconnectOnFastUserSwitch __OSX_AVAILABLE_STARTING(__MAC_10_4,__IPHONE_2_0/*SPI*/); +#define kSCPropNetPPPDisconnectOnFastUserSwitch kSCPropNetPPPDisconnectOnFastUserSwitch /*! @const kSCPropNetPPPDisconnectOnIdle - @availability Introduced in Mac OS X 10.1. + @discussion Value is a CFNumber (0 or 1) */ -extern const CFStringRef kSCPropNetPPPDisconnectOnIdle; +extern const CFStringRef kSCPropNetPPPDisconnectOnIdle __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); +#define kSCPropNetPPPDisconnectOnIdle kSCPropNetPPPDisconnectOnIdle /*! @const kSCPropNetPPPDisconnectOnIdleTimer - @availability Introduced in Mac OS X 10.1. + @discussion Value is a CFNumber */ -extern const CFStringRef kSCPropNetPPPDisconnectOnIdleTimer; +extern const CFStringRef kSCPropNetPPPDisconnectOnIdleTimer __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); +#define kSCPropNetPPPDisconnectOnIdleTimer kSCPropNetPPPDisconnectOnIdleTimer /*! @const kSCPropNetPPPDisconnectOnLogout - @availability Introduced in Mac OS X 10.1. + @discussion Value is a CFNumber (0 or 1) */ -extern const CFStringRef kSCPropNetPPPDisconnectOnLogout; +extern const CFStringRef kSCPropNetPPPDisconnectOnLogout __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); +#define kSCPropNetPPPDisconnectOnLogout kSCPropNetPPPDisconnectOnLogout /*! @const kSCPropNetPPPDisconnectOnSleep - @availability Introduced in Mac OS X 10.2. + @discussion Value is a CFNumber (0 or 1) */ -extern const CFStringRef kSCPropNetPPPDisconnectOnSleep; +extern const CFStringRef kSCPropNetPPPDisconnectOnSleep __OSX_AVAILABLE_STARTING(__MAC_10_2,__IPHONE_2_0/*SPI*/); +#define kSCPropNetPPPDisconnectOnSleep kSCPropNetPPPDisconnectOnSleep /*! @const kSCPropNetPPPDisconnectTime - @availability Introduced in Mac OS X 10.3. + @discussion Value is a CFNumber */ -extern const CFStringRef kSCPropNetPPPDisconnectTime; +extern const CFStringRef kSCPropNetPPPDisconnectTime __OSX_AVAILABLE_STARTING(__MAC_10_3,__IPHONE_2_0/*SPI*/); +#define kSCPropNetPPPDisconnectTime kSCPropNetPPPDisconnectTime /*! @const kSCPropNetPPPIdleReminderTimer - @availability Introduced in Mac OS X 10.1. + @discussion Value is a CFNumber */ -extern const CFStringRef kSCPropNetPPPIdleReminderTimer; +extern const CFStringRef kSCPropNetPPPIdleReminderTimer __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); +#define kSCPropNetPPPIdleReminderTimer kSCPropNetPPPIdleReminderTimer /*! @const kSCPropNetPPPIdleReminder - @availability Introduced in Mac OS X 10.1. + @discussion Value is a CFNumber (0 or 1) */ -extern const CFStringRef kSCPropNetPPPIdleReminder; +extern const CFStringRef kSCPropNetPPPIdleReminder __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); +#define kSCPropNetPPPIdleReminder kSCPropNetPPPIdleReminder /*! @const kSCPropNetPPPLastCause - @availability Introduced in Mac OS X 10.2. + @discussion Value is a CFNumber */ -extern const CFStringRef kSCPropNetPPPLastCause; +extern const CFStringRef kSCPropNetPPPLastCause __OSX_AVAILABLE_STARTING(__MAC_10_2,__IPHONE_2_0/*SPI*/); +#define kSCPropNetPPPLastCause kSCPropNetPPPLastCause /*! @const kSCPropNetPPPLogfile - @availability Introduced in Mac OS X 10.1. + @discussion Value is a CFString */ -extern const CFStringRef kSCPropNetPPPLogfile; +extern const CFStringRef kSCPropNetPPPLogfile __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); +#define kSCPropNetPPPLogfile kSCPropNetPPPLogfile /*! @const kSCPropNetPPPPlugins - @availability Introduced in Mac OS X 10.2. + @discussion Value is a CFArray[CFString] */ -extern const CFStringRef kSCPropNetPPPPlugins; +extern const CFStringRef kSCPropNetPPPPlugins __OSX_AVAILABLE_STARTING(__MAC_10_2,__IPHONE_2_0/*SPI*/); +#define kSCPropNetPPPPlugins kSCPropNetPPPPlugins /*! @const kSCPropNetPPPRetryConnectTime - @availability Introduced in Mac OS X 10.3. + @discussion Value is a CFNumber */ -extern const CFStringRef kSCPropNetPPPRetryConnectTime; +extern const CFStringRef kSCPropNetPPPRetryConnectTime __OSX_AVAILABLE_STARTING(__MAC_10_3,__IPHONE_2_0/*SPI*/); +#define kSCPropNetPPPRetryConnectTime kSCPropNetPPPRetryConnectTime /*! @const kSCPropNetPPPSessionTimer - @availability Introduced in Mac OS X 10.1. + @discussion Value is a CFNumber */ -extern const CFStringRef kSCPropNetPPPSessionTimer; +extern const CFStringRef kSCPropNetPPPSessionTimer __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); +#define kSCPropNetPPPSessionTimer kSCPropNetPPPSessionTimer /*! @const kSCPropNetPPPStatus - @availability Introduced in Mac OS X 10.2. + @discussion Value is a CFNumber */ -extern const CFStringRef kSCPropNetPPPStatus; +extern const CFStringRef kSCPropNetPPPStatus __OSX_AVAILABLE_STARTING(__MAC_10_2,__IPHONE_2_0/*SPI*/); +#define kSCPropNetPPPStatus kSCPropNetPPPStatus /*! @const kSCPropNetPPPUseSessionTimer - @availability Introduced in Mac OS X 10.2. + @discussion Value is a CFNumber (0 or 1) */ -extern const CFStringRef kSCPropNetPPPUseSessionTimer; +extern const CFStringRef kSCPropNetPPPUseSessionTimer __OSX_AVAILABLE_STARTING(__MAC_10_2,__IPHONE_2_0/*SPI*/); +#define kSCPropNetPPPUseSessionTimer kSCPropNetPPPUseSessionTimer /*! @const kSCPropNetPPPVerboseLogging - @availability Introduced in Mac OS X 10.1. + @discussion Value is a CFNumber (0 or 1) */ -extern const CFStringRef kSCPropNetPPPVerboseLogging; +extern const CFStringRef kSCPropNetPPPVerboseLogging __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); +#define kSCPropNetPPPVerboseLogging kSCPropNetPPPVerboseLogging /*! @const kSCPropNetPPPAuthEAPPlugins - @availability Introduced in Mac OS X 10.3. + @discussion Value is a CFArray[CFString] */ -extern const CFStringRef kSCPropNetPPPAuthEAPPlugins; +extern const CFStringRef kSCPropNetPPPAuthEAPPlugins __OSX_AVAILABLE_STARTING(__MAC_10_3,__IPHONE_2_0/*SPI*/); +#define kSCPropNetPPPAuthEAPPlugins kSCPropNetPPPAuthEAPPlugins /*! @const kSCPropNetPPPAuthName - @availability Introduced in Mac OS X 10.1. + @discussion Value is a CFString */ -extern const CFStringRef kSCPropNetPPPAuthName; +extern const CFStringRef kSCPropNetPPPAuthName __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); +#define kSCPropNetPPPAuthName kSCPropNetPPPAuthName /*! @const kSCPropNetPPPAuthPassword - @availability Introduced in Mac OS X 10.1. + @discussion Value is a CFString */ -extern const CFStringRef kSCPropNetPPPAuthPassword; +extern const CFStringRef kSCPropNetPPPAuthPassword __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); +#define kSCPropNetPPPAuthPassword kSCPropNetPPPAuthPassword /*! @const kSCPropNetPPPAuthPasswordEncryption - @availability Introduced in Mac OS X 10.1. + @discussion Value is a CFString */ -extern const CFStringRef kSCPropNetPPPAuthPasswordEncryption; +extern const CFStringRef kSCPropNetPPPAuthPasswordEncryption __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); +#define kSCPropNetPPPAuthPasswordEncryption kSCPropNetPPPAuthPasswordEncryption /*! @const kSCPropNetPPPAuthPrompt - @availability Introduced in Mac OS X 10.3. + @discussion Value is a CFString */ -extern const CFStringRef kSCPropNetPPPAuthPrompt; +extern const CFStringRef kSCPropNetPPPAuthPrompt __OSX_AVAILABLE_STARTING(__MAC_10_3,__IPHONE_2_0/*SPI*/); +#define kSCPropNetPPPAuthPrompt kSCPropNetPPPAuthPrompt /*! @const kSCPropNetPPPAuthProtocol - @availability Introduced in Mac OS X 10.1. + @discussion Value is a CFArray[CFString] */ -extern const CFStringRef kSCPropNetPPPAuthProtocol; +extern const CFStringRef kSCPropNetPPPAuthProtocol __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); +#define kSCPropNetPPPAuthProtocol kSCPropNetPPPAuthProtocol /*! @const kSCValNetPPPAuthPasswordEncryptionKeychain - @availability Introduced in Mac OS X 10.3. */ -extern const CFStringRef kSCValNetPPPAuthPasswordEncryptionKeychain; +extern const CFStringRef kSCValNetPPPAuthPasswordEncryptionKeychain __OSX_AVAILABLE_STARTING(__MAC_10_3,__IPHONE_2_0/*SPI*/); +#define kSCValNetPPPAuthPasswordEncryptionKeychain kSCValNetPPPAuthPasswordEncryptionKeychain /*! @const kSCValNetPPPAuthPasswordEncryptionToken - @availability Introduced in Mac OS X 10.5. */ -extern const CFStringRef kSCValNetPPPAuthPasswordEncryptionToken; +extern const CFStringRef kSCValNetPPPAuthPasswordEncryptionToken __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0/*SPI*/); +#define kSCValNetPPPAuthPasswordEncryptionToken kSCValNetPPPAuthPasswordEncryptionToken /*! @const kSCValNetPPPAuthPromptBefore - @availability Introduced in Mac OS X 10.3. + @discussion Value is a CFString */ -extern const CFStringRef kSCValNetPPPAuthPromptBefore; +extern const CFStringRef kSCValNetPPPAuthPromptBefore __OSX_AVAILABLE_STARTING(__MAC_10_3,__IPHONE_2_0/*SPI*/); +#define kSCValNetPPPAuthPromptBefore kSCValNetPPPAuthPromptBefore /*! @const kSCValNetPPPAuthPromptAfter - @availability Introduced in Mac OS X 10.3. + @discussion Value is a CFString */ -extern const CFStringRef kSCValNetPPPAuthPromptAfter; +extern const CFStringRef kSCValNetPPPAuthPromptAfter __OSX_AVAILABLE_STARTING(__MAC_10_3,__IPHONE_2_0/*SPI*/); +#define kSCValNetPPPAuthPromptAfter kSCValNetPPPAuthPromptAfter /*! @const kSCValNetPPPAuthProtocolCHAP - @availability Introduced in Mac OS X 10.1. + @discussion Value is a CFString */ -extern const CFStringRef kSCValNetPPPAuthProtocolCHAP; +extern const CFStringRef kSCValNetPPPAuthProtocolCHAP __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); +#define kSCValNetPPPAuthProtocolCHAP kSCValNetPPPAuthProtocolCHAP /*! @const kSCValNetPPPAuthProtocolEAP - @availability Introduced in Mac OS X 10.3. + @discussion Value is a CFString */ -extern const CFStringRef kSCValNetPPPAuthProtocolEAP; +extern const CFStringRef kSCValNetPPPAuthProtocolEAP __OSX_AVAILABLE_STARTING(__MAC_10_3,__IPHONE_2_0/*SPI*/); +#define kSCValNetPPPAuthProtocolEAP kSCValNetPPPAuthProtocolEAP /*! @const kSCValNetPPPAuthProtocolMSCHAP1 - @availability Introduced in Mac OS X 10.3. + @discussion Value is a CFString */ -extern const CFStringRef kSCValNetPPPAuthProtocolMSCHAP1; +extern const CFStringRef kSCValNetPPPAuthProtocolMSCHAP1 __OSX_AVAILABLE_STARTING(__MAC_10_3,__IPHONE_2_0/*SPI*/); +#define kSCValNetPPPAuthProtocolMSCHAP1 kSCValNetPPPAuthProtocolMSCHAP1 /*! @const kSCValNetPPPAuthProtocolMSCHAP2 - @availability Introduced in Mac OS X 10.3. + @discussion Value is a CFString */ -extern const CFStringRef kSCValNetPPPAuthProtocolMSCHAP2; +extern const CFStringRef kSCValNetPPPAuthProtocolMSCHAP2 __OSX_AVAILABLE_STARTING(__MAC_10_3,__IPHONE_2_0/*SPI*/); +#define kSCValNetPPPAuthProtocolMSCHAP2 kSCValNetPPPAuthProtocolMSCHAP2 /*! @const kSCValNetPPPAuthProtocolPAP - @availability Introduced in Mac OS X 10.1. + @discussion Value is a CFString */ -extern const CFStringRef kSCValNetPPPAuthProtocolPAP; +extern const CFStringRef kSCValNetPPPAuthProtocolPAP __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); +#define kSCValNetPPPAuthProtocolPAP kSCValNetPPPAuthProtocolPAP /*! @const kSCPropNetPPPCommAlternateRemoteAddress - @availability Introduced in Mac OS X 10.1. + @discussion Value is a CFString */ -extern const CFStringRef kSCPropNetPPPCommAlternateRemoteAddress; +extern const CFStringRef kSCPropNetPPPCommAlternateRemoteAddress __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); +#define kSCPropNetPPPCommAlternateRemoteAddress kSCPropNetPPPCommAlternateRemoteAddress /*! @const kSCPropNetPPPCommConnectDelay - @availability Introduced in Mac OS X 10.1. + @discussion Value is a CFNumber */ -extern const CFStringRef kSCPropNetPPPCommConnectDelay; +extern const CFStringRef kSCPropNetPPPCommConnectDelay __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); +#define kSCPropNetPPPCommConnectDelay kSCPropNetPPPCommConnectDelay /*! @const kSCPropNetPPPCommDisplayTerminalWindow - @availability Introduced in Mac OS X 10.1. + @discussion Value is a CFNumber (0 or 1) */ -extern const CFStringRef kSCPropNetPPPCommDisplayTerminalWindow; +extern const CFStringRef kSCPropNetPPPCommDisplayTerminalWindow __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); +#define kSCPropNetPPPCommDisplayTerminalWindow kSCPropNetPPPCommDisplayTerminalWindow /*! @const kSCPropNetPPPCommRedialCount - @availability Introduced in Mac OS X 10.1. + @discussion Value is a CFNumber */ -extern const CFStringRef kSCPropNetPPPCommRedialCount; +extern const CFStringRef kSCPropNetPPPCommRedialCount __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); +#define kSCPropNetPPPCommRedialCount kSCPropNetPPPCommRedialCount /*! @const kSCPropNetPPPCommRedialEnabled - @availability Introduced in Mac OS X 10.1. + @discussion Value is a CFNumber (0 or 1) */ -extern const CFStringRef kSCPropNetPPPCommRedialEnabled; +extern const CFStringRef kSCPropNetPPPCommRedialEnabled __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); +#define kSCPropNetPPPCommRedialEnabled kSCPropNetPPPCommRedialEnabled /*! @const kSCPropNetPPPCommRedialInterval - @availability Introduced in Mac OS X 10.1. + @discussion Value is a CFNumber */ -extern const CFStringRef kSCPropNetPPPCommRedialInterval; +extern const CFStringRef kSCPropNetPPPCommRedialInterval __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); +#define kSCPropNetPPPCommRedialInterval kSCPropNetPPPCommRedialInterval /*! @const kSCPropNetPPPCommRemoteAddress - @availability Introduced in Mac OS X 10.1. + @discussion Value is a CFString */ -extern const CFStringRef kSCPropNetPPPCommRemoteAddress; +extern const CFStringRef kSCPropNetPPPCommRemoteAddress __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); +#define kSCPropNetPPPCommRemoteAddress kSCPropNetPPPCommRemoteAddress /*! @const kSCPropNetPPPCommTerminalScript - @availability Introduced in Mac OS X 10.1. + @discussion Value is a CFString */ -extern const CFStringRef kSCPropNetPPPCommTerminalScript; +extern const CFStringRef kSCPropNetPPPCommTerminalScript __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); +#define kSCPropNetPPPCommTerminalScript kSCPropNetPPPCommTerminalScript /*! @const kSCPropNetPPPCommUseTerminalScript - @availability Introduced in Mac OS X 10.2. + @discussion Value is a CFNumber (0 or 1) */ -extern const CFStringRef kSCPropNetPPPCommUseTerminalScript; +extern const CFStringRef kSCPropNetPPPCommUseTerminalScript __OSX_AVAILABLE_STARTING(__MAC_10_2,__IPHONE_2_0/*SPI*/); +#define kSCPropNetPPPCommUseTerminalScript kSCPropNetPPPCommUseTerminalScript /*! @const kSCPropNetPPPCCPEnabled - @availability Introduced in Mac OS X 10.2. + @discussion Value is a CFNumber (0 or 1) */ -extern const CFStringRef kSCPropNetPPPCCPEnabled; +extern const CFStringRef kSCPropNetPPPCCPEnabled __OSX_AVAILABLE_STARTING(__MAC_10_2,__IPHONE_2_0/*SPI*/); +#define kSCPropNetPPPCCPEnabled kSCPropNetPPPCCPEnabled /*! @const kSCPropNetPPPCCPMPPE40Enabled - @availability Introduced in Mac OS X 10.4. + @discussion Value is a CFNumber (0 or 1) */ -extern const CFStringRef kSCPropNetPPPCCPMPPE40Enabled; +extern const CFStringRef kSCPropNetPPPCCPMPPE40Enabled __OSX_AVAILABLE_STARTING(__MAC_10_4,__IPHONE_2_0/*SPI*/); +#define kSCPropNetPPPCCPMPPE40Enabled kSCPropNetPPPCCPMPPE40Enabled /*! @const kSCPropNetPPPCCPMPPE128Enabled - @availability Introduced in Mac OS X 10.4. + @discussion Value is a CFNumber (0 or 1) */ -extern const CFStringRef kSCPropNetPPPCCPMPPE128Enabled; +extern const CFStringRef kSCPropNetPPPCCPMPPE128Enabled __OSX_AVAILABLE_STARTING(__MAC_10_4,__IPHONE_2_0/*SPI*/); +#define kSCPropNetPPPCCPMPPE128Enabled kSCPropNetPPPCCPMPPE128Enabled /*! @const kSCPropNetPPPIPCPCompressionVJ - @availability Introduced in Mac OS X 10.1. + @discussion Value is a CFNumber (0 or 1) */ -extern const CFStringRef kSCPropNetPPPIPCPCompressionVJ; +extern const CFStringRef kSCPropNetPPPIPCPCompressionVJ __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); +#define kSCPropNetPPPIPCPCompressionVJ kSCPropNetPPPIPCPCompressionVJ /*! @const kSCPropNetPPPIPCPUsePeerDNS - @availability Introduced in Mac OS X 10.4. + @discussion Value is a CFNumber (0 or 1) */ -extern const CFStringRef kSCPropNetPPPIPCPUsePeerDNS; +extern const CFStringRef kSCPropNetPPPIPCPUsePeerDNS __OSX_AVAILABLE_STARTING(__MAC_10_4,__IPHONE_2_0/*SPI*/); +#define kSCPropNetPPPIPCPUsePeerDNS kSCPropNetPPPIPCPUsePeerDNS /*! @const kSCPropNetPPPLCPEchoEnabled - @availability Introduced in Mac OS X 10.1. + @discussion Value is a CFNumber (0 or 1) */ -extern const CFStringRef kSCPropNetPPPLCPEchoEnabled; +extern const CFStringRef kSCPropNetPPPLCPEchoEnabled __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); +#define kSCPropNetPPPLCPEchoEnabled kSCPropNetPPPLCPEchoEnabled /*! @const kSCPropNetPPPLCPEchoFailure - @availability Introduced in Mac OS X 10.1. + @discussion Value is a CFNumber */ -extern const CFStringRef kSCPropNetPPPLCPEchoFailure; +extern const CFStringRef kSCPropNetPPPLCPEchoFailure __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); +#define kSCPropNetPPPLCPEchoFailure kSCPropNetPPPLCPEchoFailure /*! @const kSCPropNetPPPLCPEchoInterval - @availability Introduced in Mac OS X 10.1. + @discussion Value is a CFNumber */ -extern const CFStringRef kSCPropNetPPPLCPEchoInterval; +extern const CFStringRef kSCPropNetPPPLCPEchoInterval __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); +#define kSCPropNetPPPLCPEchoInterval kSCPropNetPPPLCPEchoInterval /*! @const kSCPropNetPPPLCPCompressionACField - @availability Introduced in Mac OS X 10.1. + @discussion Value is a CFNumber (0 or 1) */ -extern const CFStringRef kSCPropNetPPPLCPCompressionACField; +extern const CFStringRef kSCPropNetPPPLCPCompressionACField __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); +#define kSCPropNetPPPLCPCompressionACField kSCPropNetPPPLCPCompressionACField /*! @const kSCPropNetPPPLCPCompressionPField - @availability Introduced in Mac OS X 10.1. + @discussion Value is a CFNumber (0 or 1) */ -extern const CFStringRef kSCPropNetPPPLCPCompressionPField; +extern const CFStringRef kSCPropNetPPPLCPCompressionPField __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); +#define kSCPropNetPPPLCPCompressionPField kSCPropNetPPPLCPCompressionPField /*! @const kSCPropNetPPPLCPMRU - @availability Introduced in Mac OS X 10.1. + @discussion Value is a CFNumber */ -extern const CFStringRef kSCPropNetPPPLCPMRU; +extern const CFStringRef kSCPropNetPPPLCPMRU __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); +#define kSCPropNetPPPLCPMRU kSCPropNetPPPLCPMRU /*! @const kSCPropNetPPPLCPMTU - @availability Introduced in Mac OS X 10.1. + @discussion Value is a CFNumber */ -extern const CFStringRef kSCPropNetPPPLCPMTU; +extern const CFStringRef kSCPropNetPPPLCPMTU __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); +#define kSCPropNetPPPLCPMTU kSCPropNetPPPLCPMTU /*! @const kSCPropNetPPPLCPReceiveACCM - @availability Introduced in Mac OS X 10.1. + @discussion Value is a CFNumber */ -extern const CFStringRef kSCPropNetPPPLCPReceiveACCM; +extern const CFStringRef kSCPropNetPPPLCPReceiveACCM __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); +#define kSCPropNetPPPLCPReceiveACCM kSCPropNetPPPLCPReceiveACCM /*! @const kSCPropNetPPPLCPTransmitACCM - @availability Introduced in Mac OS X 10.1. + @discussion Value is a CFNumber */ -extern const CFStringRef kSCPropNetPPPLCPTransmitACCM; +extern const CFStringRef kSCPropNetPPPLCPTransmitACCM __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); +#define kSCPropNetPPPLCPTransmitACCM kSCPropNetPPPLCPTransmitACCM /*! @group kSCEntNetPPPoE Entity Keys @@ -1982,39 +2101,42 @@ extern const CFStringRef kSCPropNetPPPLCPTransmitACCM; /*! @const kSCPropNetL2TPIPSecSharedSecret - @availability Introduced in Mac OS X 10.3. + @discussion Value is a CFString */ -extern const CFStringRef kSCPropNetL2TPIPSecSharedSecret; +extern const CFStringRef kSCPropNetL2TPIPSecSharedSecret __OSX_AVAILABLE_STARTING(__MAC_10_3,__IPHONE_2_0/*SPI*/); +#define kSCPropNetL2TPIPSecSharedSecret kSCPropNetL2TPIPSecSharedSecret /*! @const kSCPropNetL2TPIPSecSharedSecretEncryption - @availability Introduced in Mac OS X 10.3. + @discussion Value is a CFString */ -extern const CFStringRef kSCPropNetL2TPIPSecSharedSecretEncryption; +extern const CFStringRef kSCPropNetL2TPIPSecSharedSecretEncryption __OSX_AVAILABLE_STARTING(__MAC_10_3,__IPHONE_2_0/*SPI*/); +#define kSCPropNetL2TPIPSecSharedSecretEncryption kSCPropNetL2TPIPSecSharedSecretEncryption /*! @const kSCPropNetL2TPTransport - @availability Introduced in Mac OS X 10.3. + @discussion Value is a CFString */ -extern const CFStringRef kSCPropNetL2TPTransport; +extern const CFStringRef kSCPropNetL2TPTransport __OSX_AVAILABLE_STARTING(__MAC_10_3,__IPHONE_2_0/*SPI*/); +#define kSCPropNetL2TPTransport kSCPropNetL2TPTransport /*! @const kSCValNetL2TPIPSecSharedSecretEncryptionKeychain - @availability Introduced in Mac OS X 10.3. */ -extern const CFStringRef kSCValNetL2TPIPSecSharedSecretEncryptionKeychain; +extern const CFStringRef kSCValNetL2TPIPSecSharedSecretEncryptionKeychain __OSX_AVAILABLE_STARTING(__MAC_10_3,__IPHONE_2_0/*SPI*/); +#define kSCValNetL2TPIPSecSharedSecretEncryptionKeychain kSCValNetL2TPIPSecSharedSecretEncryptionKeychain /*! @const kSCValNetL2TPTransportIP - @availability Introduced in Mac OS X 10.3. */ -extern const CFStringRef kSCValNetL2TPTransportIP; +extern const CFStringRef kSCValNetL2TPTransportIP __OSX_AVAILABLE_STARTING(__MAC_10_3,__IPHONE_2_0/*SPI*/); +#define kSCValNetL2TPTransportIP kSCValNetL2TPTransportIP /*! @const kSCValNetL2TPTransportIPSec - @availability Introduced in Mac OS X 10.3. */ -extern const CFStringRef kSCValNetL2TPTransportIPSec; +extern const CFStringRef kSCValNetL2TPTransportIPSec __OSX_AVAILABLE_STARTING(__MAC_10_3,__IPHONE_2_0/*SPI*/); +#define kSCValNetL2TPTransportIPSec kSCValNetL2TPTransportIPSec /*! @group kSCEntNetProxies Entity Keys @@ -2022,153 +2144,178 @@ extern const CFStringRef kSCValNetL2TPTransportIPSec; /*! @const kSCPropNetProxiesExceptionsList - @availability Introduced in Mac OS X 10.1. + @discussion Value is a CFArray[CFString] */ -extern const CFStringRef kSCPropNetProxiesExceptionsList; +extern const CFStringRef kSCPropNetProxiesExceptionsList __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); +#define kSCPropNetProxiesExceptionsList kSCPropNetProxiesExceptionsList /*! @const kSCPropNetProxiesExcludeSimpleHostnames - @availability Introduced in Mac OS X 10.4. + @discussion Value is a CFNumber (0 or 1) */ -extern const CFStringRef kSCPropNetProxiesExcludeSimpleHostnames; +extern const CFStringRef kSCPropNetProxiesExcludeSimpleHostnames __OSX_AVAILABLE_STARTING(__MAC_10_4,__IPHONE_2_0/*SPI*/); +#define kSCPropNetProxiesExcludeSimpleHostnames kSCPropNetProxiesExcludeSimpleHostnames /*! @const kSCPropNetProxiesFTPEnable - @availability Introduced in Mac OS X 10.1. + @discussion Value is a CFNumber (0 or 1) */ -extern const CFStringRef kSCPropNetProxiesFTPEnable; +extern const CFStringRef kSCPropNetProxiesFTPEnable __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); +#define kSCPropNetProxiesFTPEnable kSCPropNetProxiesFTPEnable /*! @const kSCPropNetProxiesFTPPassive - @availability Introduced in Mac OS X 10.1. + @discussion Value is a CFNumber (0 or 1) */ -extern const CFStringRef kSCPropNetProxiesFTPPassive; +extern const CFStringRef kSCPropNetProxiesFTPPassive __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); +#define kSCPropNetProxiesFTPPassive kSCPropNetProxiesFTPPassive /*! @const kSCPropNetProxiesFTPPort - @availability Introduced in Mac OS X 10.1. + @discussion Value is a CFNumber */ -extern const CFStringRef kSCPropNetProxiesFTPPort; +extern const CFStringRef kSCPropNetProxiesFTPPort __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); +#define kSCPropNetProxiesFTPPort kSCPropNetProxiesFTPPort /*! @const kSCPropNetProxiesFTPProxy - @availability Introduced in Mac OS X 10.1. + @discussion Value is a CFString */ -extern const CFStringRef kSCPropNetProxiesFTPProxy; +extern const CFStringRef kSCPropNetProxiesFTPProxy __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); +#define kSCPropNetProxiesFTPProxy kSCPropNetProxiesFTPProxy /*! @const kSCPropNetProxiesGopherEnable - @availability Introduced in Mac OS X 10.1. + @discussion Value is a CFNumber (0 or 1) */ -extern const CFStringRef kSCPropNetProxiesGopherEnable; +extern const CFStringRef kSCPropNetProxiesGopherEnable __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); +#define kSCPropNetProxiesGopherEnable kSCPropNetProxiesGopherEnable /*! @const kSCPropNetProxiesGopherPort - @availability Introduced in Mac OS X 10.1. + @discussion Value is a CFNumber */ -extern const CFStringRef kSCPropNetProxiesGopherPort; +extern const CFStringRef kSCPropNetProxiesGopherPort __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); +#define kSCPropNetProxiesGopherPort kSCPropNetProxiesGopherPort /*! @const kSCPropNetProxiesGopherProxy - @availability Introduced in Mac OS X 10.1. + @discussion Value is a CFString */ -extern const CFStringRef kSCPropNetProxiesGopherProxy; +extern const CFStringRef kSCPropNetProxiesGopherProxy __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); +#define kSCPropNetProxiesGopherProxy kSCPropNetProxiesGopherProxy /*! @const kSCPropNetProxiesHTTPEnable - @availability Introduced in Mac OS X 10.1. + @discussion Value is a CFNumber (0 or 1) */ -extern const CFStringRef kSCPropNetProxiesHTTPEnable; +extern const CFStringRef kSCPropNetProxiesHTTPEnable __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); +#define kSCPropNetProxiesHTTPEnable kSCPropNetProxiesHTTPEnable /*! @const kSCPropNetProxiesHTTPPort - @availability Introduced in Mac OS X 10.1. + @discussion Value is a CFNumber */ -extern const CFStringRef kSCPropNetProxiesHTTPPort; +extern const CFStringRef kSCPropNetProxiesHTTPPort __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); +#define kSCPropNetProxiesHTTPPort kSCPropNetProxiesHTTPPort /*! @const kSCPropNetProxiesHTTPProxy - @availability Introduced in Mac OS X 10.1. + @discussion Value is a CFString */ -extern const CFStringRef kSCPropNetProxiesHTTPProxy; +extern const CFStringRef kSCPropNetProxiesHTTPProxy __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); +#define kSCPropNetProxiesHTTPProxy kSCPropNetProxiesHTTPProxy /*! @const kSCPropNetProxiesHTTPSEnable - @availability Introduced in Mac OS X 10.1. + @discussion Value is a CFNumber (0 or 1) */ -extern const CFStringRef kSCPropNetProxiesHTTPSEnable; +extern const CFStringRef kSCPropNetProxiesHTTPSEnable __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); +#define kSCPropNetProxiesHTTPSEnable kSCPropNetProxiesHTTPSEnable /*! @const kSCPropNetProxiesHTTPSPort - @availability Introduced in Mac OS X 10.1. + @discussion Value is a CFNumber */ -extern const CFStringRef kSCPropNetProxiesHTTPSPort; +extern const CFStringRef kSCPropNetProxiesHTTPSPort __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); +#define kSCPropNetProxiesHTTPSPort kSCPropNetProxiesHTTPSPort /*! @const kSCPropNetProxiesHTTPSProxy - @availability Introduced in Mac OS X 10.1. + @discussion Value is a CFString */ -extern const CFStringRef kSCPropNetProxiesHTTPSProxy; +extern const CFStringRef kSCPropNetProxiesHTTPSProxy __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); +#define kSCPropNetProxiesHTTPSProxy kSCPropNetProxiesHTTPSProxy /*! @const kSCPropNetProxiesRTSPEnable - @availability Introduced in Mac OS X 10.1. + @discussion Value is a CFNumber (0 or 1) */ -extern const CFStringRef kSCPropNetProxiesRTSPEnable; +extern const CFStringRef kSCPropNetProxiesRTSPEnable __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); +#define kSCPropNetProxiesRTSPEnable kSCPropNetProxiesRTSPEnable /*! @const kSCPropNetProxiesRTSPPort - @availability Introduced in Mac OS X 10.1. + @discussion Value is a CFNumber */ -extern const CFStringRef kSCPropNetProxiesRTSPPort; +extern const CFStringRef kSCPropNetProxiesRTSPPort __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); +#define kSCPropNetProxiesRTSPPort kSCPropNetProxiesRTSPPort /*! @const kSCPropNetProxiesRTSPProxy - @availability Introduced in Mac OS X 10.1. + @discussion Value is a CFString */ -extern const CFStringRef kSCPropNetProxiesRTSPProxy; +extern const CFStringRef kSCPropNetProxiesRTSPProxy __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); +#define kSCPropNetProxiesRTSPProxy kSCPropNetProxiesRTSPProxy /*! @const kSCPropNetProxiesSOCKSEnable - @availability Introduced in Mac OS X 10.1. + @discussion Value is a CFNumber (0 or 1) */ -extern const CFStringRef kSCPropNetProxiesSOCKSEnable; +extern const CFStringRef kSCPropNetProxiesSOCKSEnable __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); +#define kSCPropNetProxiesSOCKSEnable kSCPropNetProxiesSOCKSEnable /*! @const kSCPropNetProxiesSOCKSPort - @availability Introduced in Mac OS X 10.1. + @discussion Value is a CFNumber */ -extern const CFStringRef kSCPropNetProxiesSOCKSPort; +extern const CFStringRef kSCPropNetProxiesSOCKSPort __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); +#define kSCPropNetProxiesSOCKSPort kSCPropNetProxiesSOCKSPort /*! @const kSCPropNetProxiesSOCKSProxy - @availability Introduced in Mac OS X 10.1. + @discussion Value is a CFString */ -extern const CFStringRef kSCPropNetProxiesSOCKSProxy; +extern const CFStringRef kSCPropNetProxiesSOCKSProxy __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); +#define kSCPropNetProxiesSOCKSProxy kSCPropNetProxiesSOCKSProxy /*! @const kSCPropNetProxiesProxyAutoConfigEnable - @availability Introduced in Mac OS X 10.4. + @discussion Value is a CFNumber (0 or 1) */ -extern const CFStringRef kSCPropNetProxiesProxyAutoConfigEnable; +extern const CFStringRef kSCPropNetProxiesProxyAutoConfigEnable __OSX_AVAILABLE_STARTING(__MAC_10_4,__IPHONE_2_0/*SPI*/); +#define kSCPropNetProxiesProxyAutoConfigEnable kSCPropNetProxiesProxyAutoConfigEnable /*! @const kSCPropNetProxiesProxyAutoConfigJavaScript - @availability Introduced in Mac OS X 10.7. + @discussion Value is a CFString */ -extern const CFStringRef kSCPropNetProxiesProxyAutoConfigJavaScript; +extern const CFStringRef kSCPropNetProxiesProxyAutoConfigJavaScript __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_4_0/*SPI*/); +#define kSCPropNetProxiesProxyAutoConfigJavaScript kSCPropNetProxiesProxyAutoConfigJavaScript /*! @const kSCPropNetProxiesProxyAutoConfigURLString - @availability Introduced in Mac OS X 10.4. + @discussion Value is a CFString */ -extern const CFStringRef kSCPropNetProxiesProxyAutoConfigURLString; +extern const CFStringRef kSCPropNetProxiesProxyAutoConfigURLString __OSX_AVAILABLE_STARTING(__MAC_10_4,__IPHONE_2_0/*SPI*/); +#define kSCPropNetProxiesProxyAutoConfigURLString kSCPropNetProxiesProxyAutoConfigURLString /*! @const kSCPropNetProxiesProxyAutoDiscoveryEnable - @availability Introduced in Mac OS X 10.4. + @discussion Value is a CFNumber (0 or 1) */ -extern const CFStringRef kSCPropNetProxiesProxyAutoDiscoveryEnable; +extern const CFStringRef kSCPropNetProxiesProxyAutoDiscoveryEnable __OSX_AVAILABLE_STARTING(__MAC_10_4,__IPHONE_2_0/*SPI*/); +#define kSCPropNetProxiesProxyAutoDiscoveryEnable kSCPropNetProxiesProxyAutoDiscoveryEnable /*! @group kSCEntNetSMB Entity Keys @@ -2176,57 +2323,62 @@ extern const CFStringRef kSCPropNetProxiesProxyAutoDiscoveryEnable; /*! @const kSCPropNetSMBNetBIOSName - @availability Introduced in Mac OS X 10.5. + @discussion Value is a CFString */ -extern const CFStringRef kSCPropNetSMBNetBIOSName; +extern const CFStringRef kSCPropNetSMBNetBIOSName __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0/*SPI*/); +#define kSCPropNetSMBNetBIOSName kSCPropNetSMBNetBIOSName /*! @const kSCPropNetSMBNetBIOSNodeType - @availability Introduced in Mac OS X 10.5. + @discussion Value is a CFString */ -extern const CFStringRef kSCPropNetSMBNetBIOSNodeType; +extern const CFStringRef kSCPropNetSMBNetBIOSNodeType __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0/*SPI*/); +#define kSCPropNetSMBNetBIOSNodeType kSCPropNetSMBNetBIOSNodeType /*! @const kSCPropNetSMBNetBIOSScope - @availability Introduced in Mac OS X 10.5, but later deprecated in Mac OS X 10.7. + @discussion Value is a CFString */ -extern const CFStringRef kSCPropNetSMBNetBIOSScope; +extern const CFStringRef kSCPropNetSMBNetBIOSScope __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_5,__MAC_10_7,__IPHONE_NA,__IPHONE_NA); +#define kSCPropNetSMBNetBIOSScope kSCPropNetSMBNetBIOSScope /*! @const kSCPropNetSMBWINSAddresses - @availability Introduced in Mac OS X 10.5. + @discussion Value is a CFArray[CFString] */ -extern const CFStringRef kSCPropNetSMBWINSAddresses; +extern const CFStringRef kSCPropNetSMBWINSAddresses __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0/*SPI*/); +#define kSCPropNetSMBWINSAddresses kSCPropNetSMBWINSAddresses /*! @const kSCPropNetSMBWorkgroup - @availability Introduced in Mac OS X 10.5. + @discussion Value is a CFString */ -extern const CFStringRef kSCPropNetSMBWorkgroup; +extern const CFStringRef kSCPropNetSMBWorkgroup __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0/*SPI*/); +#define kSCPropNetSMBWorkgroup kSCPropNetSMBWorkgroup /*! @const kSCValNetSMBNetBIOSNodeTypeBroadcast - @availability Introduced in Mac OS X 10.5. */ -extern const CFStringRef kSCValNetSMBNetBIOSNodeTypeBroadcast; +extern const CFStringRef kSCValNetSMBNetBIOSNodeTypeBroadcast __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0/*SPI*/); +#define kSCValNetSMBNetBIOSNodeTypeBroadcast kSCValNetSMBNetBIOSNodeTypeBroadcast /*! @const kSCValNetSMBNetBIOSNodeTypePeer - @availability Introduced in Mac OS X 10.5. */ -extern const CFStringRef kSCValNetSMBNetBIOSNodeTypePeer; +extern const CFStringRef kSCValNetSMBNetBIOSNodeTypePeer __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0/*SPI*/); +#define kSCValNetSMBNetBIOSNodeTypePeer kSCValNetSMBNetBIOSNodeTypePeer /*! @const kSCValNetSMBNetBIOSNodeTypeMixed - @availability Introduced in Mac OS X 10.5. */ -extern const CFStringRef kSCValNetSMBNetBIOSNodeTypeMixed; +extern const CFStringRef kSCValNetSMBNetBIOSNodeTypeMixed __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0/*SPI*/); +#define kSCValNetSMBNetBIOSNodeTypeMixed kSCValNetSMBNetBIOSNodeTypeMixed /*! @const kSCValNetSMBNetBIOSNodeTypeHybrid - @availability Introduced in Mac OS X 10.5. */ -extern const CFStringRef kSCValNetSMBNetBIOSNodeTypeHybrid; +extern const CFStringRef kSCValNetSMBNetBIOSNodeTypeHybrid __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0/*SPI*/); +#define kSCValNetSMBNetBIOSNodeTypeHybrid kSCValNetSMBNetBIOSNodeTypeHybrid /*! @group kSCCompUsers Entity Keys @@ -2234,9 +2386,9 @@ extern const CFStringRef kSCValNetSMBNetBIOSNodeTypeHybrid; /*! @const kSCEntUsersConsoleUser - @availability Introduced in Mac OS X 10.1. */ -extern const CFStringRef kSCEntUsersConsoleUser; +extern const CFStringRef kSCEntUsersConsoleUser __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); +#define kSCEntUsersConsoleUser kSCEntUsersConsoleUser /*! @group kSCCompSystem Properties @@ -2244,15 +2396,17 @@ extern const CFStringRef kSCEntUsersConsoleUser; /*! @const kSCPropSystemComputerName - @availability Introduced in Mac OS X 10.1. + @discussion Value is a CFString */ -extern const CFStringRef kSCPropSystemComputerName; +extern const CFStringRef kSCPropSystemComputerName __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); +#define kSCPropSystemComputerName kSCPropSystemComputerName /*! @const kSCPropSystemComputerNameEncoding - @availability Introduced in Mac OS X 10.1. + @discussion Value is a CFNumber */ -extern const CFStringRef kSCPropSystemComputerNameEncoding; +extern const CFStringRef kSCPropSystemComputerNameEncoding __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); +#define kSCPropSystemComputerNameEncoding kSCPropSystemComputerNameEncoding /*! @group SCDynamicStore "domain" prefixes @@ -2260,33 +2414,33 @@ extern const CFStringRef kSCPropSystemComputerNameEncoding; /*! @const kSCDynamicStoreDomainFile - @availability Introduced in Mac OS X 10.1. */ -extern const CFStringRef kSCDynamicStoreDomainFile; +extern const CFStringRef kSCDynamicStoreDomainFile __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); +#define kSCDynamicStoreDomainFile kSCDynamicStoreDomainFile /*! @const kSCDynamicStoreDomainPlugin - @availability Introduced in Mac OS X 10.1. */ -extern const CFStringRef kSCDynamicStoreDomainPlugin; +extern const CFStringRef kSCDynamicStoreDomainPlugin __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); +#define kSCDynamicStoreDomainPlugin kSCDynamicStoreDomainPlugin /*! @const kSCDynamicStoreDomainSetup - @availability Introduced in Mac OS X 10.1. */ -extern const CFStringRef kSCDynamicStoreDomainSetup; +extern const CFStringRef kSCDynamicStoreDomainSetup __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); +#define kSCDynamicStoreDomainSetup kSCDynamicStoreDomainSetup /*! @const kSCDynamicStoreDomainState - @availability Introduced in Mac OS X 10.1. */ -extern const CFStringRef kSCDynamicStoreDomainState; +extern const CFStringRef kSCDynamicStoreDomainState __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); +#define kSCDynamicStoreDomainState kSCDynamicStoreDomainState /*! @const kSCDynamicStoreDomainPrefs - @availability Introduced in Mac OS X 10.1. */ -extern const CFStringRef kSCDynamicStoreDomainPrefs; +extern const CFStringRef kSCDynamicStoreDomainPrefs __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); +#define kSCDynamicStoreDomainPrefs kSCDynamicStoreDomainPrefs /*! @group Preference ("location") Keys @@ -2294,15 +2448,16 @@ extern const CFStringRef kSCDynamicStoreDomainPrefs; /*! @const kSCDynamicStorePropSetupCurrentSet - @availability Introduced in Mac OS X 10.1. + @discussion Value is a CFString */ -extern const CFStringRef kSCDynamicStorePropSetupCurrentSet; +extern const CFStringRef kSCDynamicStorePropSetupCurrentSet __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); +#define kSCDynamicStorePropSetupCurrentSet kSCDynamicStorePropSetupCurrentSet /*! @const kSCDynamicStorePropSetupLastUpdated - @availability Introduced in Mac OS X 10.1. */ -extern const CFStringRef kSCDynamicStorePropSetupLastUpdated; +extern const CFStringRef kSCDynamicStorePropSetupLastUpdated __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); +#define kSCDynamicStorePropSetupLastUpdated kSCDynamicStorePropSetupLastUpdated /*! @group Common/shared Keys @@ -2310,1818 +2465,54 @@ extern const CFStringRef kSCDynamicStorePropSetupLastUpdated; /*! @const kSCDynamicStorePropNetInterfaces - @availability Introduced in Mac OS X 10.1. + @discussion Value is a CFArray[CFString] */ -extern const CFStringRef kSCDynamicStorePropNetInterfaces; +extern const CFStringRef kSCDynamicStorePropNetInterfaces __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); +#define kSCDynamicStorePropNetInterfaces kSCDynamicStorePropNetInterfaces /*! @const kSCDynamicStorePropNetPrimaryInterface - @availability Introduced in Mac OS X 10.1. + @discussion Value is a CFString */ -extern const CFStringRef kSCDynamicStorePropNetPrimaryInterface; +extern const CFStringRef kSCDynamicStorePropNetPrimaryInterface __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); +#define kSCDynamicStorePropNetPrimaryInterface kSCDynamicStorePropNetPrimaryInterface /*! @const kSCDynamicStorePropNetPrimaryService - @availability Introduced in Mac OS X 10.1. + @discussion Value is a CFString */ -extern const CFStringRef kSCDynamicStorePropNetPrimaryService; +extern const CFStringRef kSCDynamicStorePropNetPrimaryService __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); +#define kSCDynamicStorePropNetPrimaryService kSCDynamicStorePropNetPrimaryService /*! @const kSCDynamicStorePropNetServiceIDs - @availability Introduced in Mac OS X 10.1. + @discussion Value is a CFArray[CFString] */ -extern const CFStringRef kSCDynamicStorePropNetServiceIDs; +extern const CFStringRef kSCDynamicStorePropNetServiceIDs __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); +#define kSCDynamicStorePropNetServiceIDs kSCDynamicStorePropNetServiceIDs /*! @const kSCPropUsersConsoleUserName - @availability Introduced in Mac OS X 10.1, but later deprecated in Mac OS X 10.4. + @discussion Value is a CFString */ -extern const CFStringRef kSCPropUsersConsoleUserName; +extern const CFStringRef kSCPropUsersConsoleUserName __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1,__MAC_10_4,__IPHONE_NA,__IPHONE_NA); +#define kSCPropUsersConsoleUserName kSCPropUsersConsoleUserName /*! @const kSCPropUsersConsoleUserUID - @availability Introduced in Mac OS X 10.1, but later deprecated in Mac OS X 10.4. + @discussion Value is a CFNumber */ -extern const CFStringRef kSCPropUsersConsoleUserUID; +extern const CFStringRef kSCPropUsersConsoleUserUID __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1,__MAC_10_4,__IPHONE_NA,__IPHONE_NA); +#define kSCPropUsersConsoleUserUID kSCPropUsersConsoleUserUID /*! @const kSCPropUsersConsoleUserGID - @availability Introduced in Mac OS X 10.1, but later deprecated in Mac OS X 10.4. + @discussion Value is a CFNumber */ -extern const CFStringRef kSCPropUsersConsoleUserGID; - -#endif /* 0 */ - - -/* -------------------- Schema declarations -------------------- */ - -#define __AVAILABILITY_INTERNAL__IPHONE_2_0_DEP__IPHONE_FUTURE __AVAILABILITY_INTERNAL__IPHONE_2_0/*SPI*/ +extern const CFStringRef kSCPropUsersConsoleUserGID __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1,__MAC_10_4,__IPHONE_NA,__IPHONE_NA); +#define kSCPropUsersConsoleUserGID kSCPropUsersConsoleUserGID - SC_SCHEMA_DECLARATION(kSCResvLink, __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/)) - #define kSCResvLink \ - SC_SCHEMA_KV(kSCResvLink \ - ,"__LINK__" \ - ,CFString ) - - SC_SCHEMA_DECLARATION(kSCResvInactive, __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/)) - #define kSCResvInactive \ - SC_SCHEMA_KV(kSCResvInactive \ - ,"__INACTIVE__" \ - , ) - - SC_SCHEMA_DECLARATION(kSCPropInterfaceName, __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/)) - #define kSCPropInterfaceName \ - SC_SCHEMA_KV(kSCPropInterfaceName \ - ,"InterfaceName" \ - ,CFString ) - - SC_SCHEMA_DECLARATION(kSCPropMACAddress, __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/)) - #define kSCPropMACAddress \ - SC_SCHEMA_KV(kSCPropMACAddress \ - ,"MACAddress" \ - ,CFString ) - - SC_SCHEMA_DECLARATION(kSCPropUserDefinedName, __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/)) - #define kSCPropUserDefinedName \ - SC_SCHEMA_KV(kSCPropUserDefinedName \ - ,"UserDefinedName" \ - ,CFString ) - - SC_SCHEMA_DECLARATION(kSCPropVersion, __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/)) - #define kSCPropVersion \ - SC_SCHEMA_KV(kSCPropVersion \ - ,"Version" \ - ,CFString ) - - SC_SCHEMA_DECLARATION(kSCPrefCurrentSet, __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/)) - #define kSCPrefCurrentSet \ - SC_SCHEMA_KV(kSCPrefCurrentSet \ - ,"CurrentSet" \ - ,CFString ) - - SC_SCHEMA_DECLARATION(kSCPrefNetworkServices, __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/)) - #define kSCPrefNetworkServices \ - SC_SCHEMA_KV(kSCPrefNetworkServices \ - ,"NetworkServices" \ - ,CFDictionary ) - - SC_SCHEMA_DECLARATION(kSCPrefSets, __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/)) - #define kSCPrefSets \ - SC_SCHEMA_KV(kSCPrefSets \ - ,"Sets" \ - ,CFDictionary ) - - SC_SCHEMA_DECLARATION(kSCPrefSystem, __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/)) - #define kSCPrefSystem \ - SC_SCHEMA_KV(kSCPrefSystem \ - ,"System" \ - ,CFDictionary ) - - SC_SCHEMA_DECLARATION(kSCCompNetwork, __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/)) - #define kSCCompNetwork \ - SC_SCHEMA_KV(kSCCompNetwork \ - ,"Network" \ - , ) - - SC_SCHEMA_DECLARATION(kSCCompService, __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/)) - #define kSCCompService \ - SC_SCHEMA_KV(kSCCompService \ - ,"Service" \ - , ) - - SC_SCHEMA_DECLARATION(kSCCompGlobal, __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/)) - #define kSCCompGlobal \ - SC_SCHEMA_KV(kSCCompGlobal \ - ,"Global" \ - , ) - - SC_SCHEMA_DECLARATION(kSCCompHostNames, __OSX_AVAILABLE_STARTING(__MAC_10_2,__IPHONE_2_0/*SPI*/)) - #define kSCCompHostNames \ - SC_SCHEMA_KV(kSCCompHostNames \ - ,"HostNames" \ - , ) - - SC_SCHEMA_DECLARATION(kSCCompInterface, __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/)) - #define kSCCompInterface \ - SC_SCHEMA_KV(kSCCompInterface \ - ,"Interface" \ - , ) - - SC_SCHEMA_DECLARATION(kSCCompSystem, __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/)) - #define kSCCompSystem \ - SC_SCHEMA_KV(kSCCompSystem \ - ,"System" \ - , ) - - SC_SCHEMA_DECLARATION(kSCCompUsers, __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/)) - #define kSCCompUsers \ - SC_SCHEMA_KV(kSCCompUsers \ - ,"Users" \ - , ) - - SC_SCHEMA_DECLARATION(kSCCompAnyRegex, __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/)) - #define kSCCompAnyRegex \ - SC_SCHEMA_KV(kSCCompAnyRegex \ - ,"[^/]+" \ - , ) - - SC_SCHEMA_DECLARATION(kSCEntNetAirPort, __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/)) - #define kSCEntNetAirPort \ - SC_SCHEMA_KV(kSCEntNetAirPort \ - ,"AirPort" \ - ,CFDictionary ) - -#if !TARGET_OS_IPHONE - - SC_SCHEMA_DECLARATION(kSCEntNetAppleTalk, __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1,__MAC_10_6,__IPHONE_NA,__IPHONE_NA)) - #define kSCEntNetAppleTalk \ - SC_SCHEMA_KV(kSCEntNetAppleTalk \ - ,"AppleTalk" \ - ,CFDictionary ) - -#endif // !TARGET_OS_IPHONE - - SC_SCHEMA_DECLARATION(kSCEntNetDHCP, __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/)) - #define kSCEntNetDHCP \ - SC_SCHEMA_KV(kSCEntNetDHCP \ - ,"DHCP" \ - ,CFDictionary ) - - SC_SCHEMA_DECLARATION(kSCEntNetDNS, __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/)) - #define kSCEntNetDNS \ - SC_SCHEMA_KV(kSCEntNetDNS \ - ,"DNS" \ - ,CFDictionary ) - - SC_SCHEMA_DECLARATION(kSCEntNetEthernet, __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/)) - #define kSCEntNetEthernet \ - SC_SCHEMA_KV(kSCEntNetEthernet \ - ,"Ethernet" \ - ,CFDictionary ) - - SC_SCHEMA_DECLARATION(kSCEntNetFireWire, __OSX_AVAILABLE_STARTING(__MAC_10_3,__IPHONE_2_0/*SPI*/)) - #define kSCEntNetFireWire \ - SC_SCHEMA_KV(kSCEntNetFireWire \ - ,"FireWire" \ - ,CFDictionary ) - - SC_SCHEMA_DECLARATION(kSCEntNetInterface, __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/)) - #define kSCEntNetInterface \ - SC_SCHEMA_KV(kSCEntNetInterface \ - ,"Interface" \ - ,CFDictionary ) - - SC_SCHEMA_DECLARATION(kSCEntNetIPSec, __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0/*SPI*/)) - #define kSCEntNetIPSec \ - SC_SCHEMA_KV(kSCEntNetIPSec \ - ,"IPSec" \ - ,CFDictionary ) - - SC_SCHEMA_DECLARATION(kSCEntNetIPv4, __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/)) - #define kSCEntNetIPv4 \ - SC_SCHEMA_KV(kSCEntNetIPv4 \ - ,"IPv4" \ - ,CFDictionary ) - - SC_SCHEMA_DECLARATION(kSCEntNetIPv6, __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/)) - #define kSCEntNetIPv6 \ - SC_SCHEMA_KV(kSCEntNetIPv6 \ - ,"IPv6" \ - ,CFDictionary ) - - SC_SCHEMA_DECLARATION(kSCEntNetL2TP, __OSX_AVAILABLE_STARTING(__MAC_10_3,__IPHONE_2_0/*SPI*/)) - #define kSCEntNetL2TP \ - SC_SCHEMA_KV(kSCEntNetL2TP \ - ,"L2TP" \ - ,CFDictionary ) - - SC_SCHEMA_DECLARATION(kSCEntNetLink, __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/)) - #define kSCEntNetLink \ - SC_SCHEMA_KV(kSCEntNetLink \ - ,"Link" \ - ,CFDictionary ) - - SC_SCHEMA_DECLARATION(kSCEntNetModem, __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/)) - #define kSCEntNetModem \ - SC_SCHEMA_KV(kSCEntNetModem \ - ,"Modem" \ - ,CFDictionary ) - -#if !TARGET_OS_IPHONE - - SC_SCHEMA_DECLARATION(kSCEntNetNetInfo, __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1,__MAC_10_5,__IPHONE_NA,__IPHONE_NA)) - #define kSCEntNetNetInfo \ - SC_SCHEMA_KV(kSCEntNetNetInfo \ - ,"NetInfo" \ - ,CFDictionary ) - -#endif // !TARGET_OS_IPHONE - - SC_SCHEMA_DECLARATION(kSCEntNetPPP, __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/)) - #define kSCEntNetPPP \ - SC_SCHEMA_KV(kSCEntNetPPP \ - ,"PPP" \ - ,CFDictionary ) - - SC_SCHEMA_DECLARATION(kSCEntNetPPPoE, __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/)) - #define kSCEntNetPPPoE \ - SC_SCHEMA_KV(kSCEntNetPPPoE \ - ,"PPPoE" \ - ,CFDictionary ) - - SC_SCHEMA_DECLARATION(kSCEntNetPPPSerial, __OSX_AVAILABLE_STARTING(__MAC_10_3,__IPHONE_2_0/*SPI*/)) - #define kSCEntNetPPPSerial \ - SC_SCHEMA_KV(kSCEntNetPPPSerial \ - ,"PPPSerial" \ - ,CFDictionary ) - - SC_SCHEMA_DECLARATION(kSCEntNetPPTP, __OSX_AVAILABLE_STARTING(__MAC_10_3,__IPHONE_2_0/*SPI*/)) - #define kSCEntNetPPTP \ - SC_SCHEMA_KV(kSCEntNetPPTP \ - ,"PPTP" \ - ,CFDictionary ) - - SC_SCHEMA_DECLARATION(kSCEntNetProxies, __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/)) - #define kSCEntNetProxies \ - SC_SCHEMA_KV(kSCEntNetProxies \ - ,"Proxies" \ - ,CFDictionary ) - -#if !TARGET_OS_IPHONE - - SC_SCHEMA_DECLARATION(kSCEntNetSMB, __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0/*SPI*/)) - #define kSCEntNetSMB \ - SC_SCHEMA_KV(kSCEntNetSMB \ - ,"SMB" \ - ,CFDictionary ) - -#endif // !TARGET_OS_IPHONE - - SC_SCHEMA_DECLARATION(kSCEntNet6to4, __OSX_AVAILABLE_STARTING(__MAC_10_3,__IPHONE_2_0/*SPI*/)) - #define kSCEntNet6to4 \ - SC_SCHEMA_KV(kSCEntNet6to4 \ - ,"6to4" \ - ,CFDictionary ) - - SC_SCHEMA_DECLARATION(kSCPropNetOverridePrimary, __OSX_AVAILABLE_STARTING(__MAC_10_2,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetOverridePrimary \ - SC_SCHEMA_KV(kSCPropNetOverridePrimary \ - ,"OverridePrimary" \ - ,CFNumber (0 or 1) ) - - SC_SCHEMA_DECLARATION(kSCPropNetServiceOrder, __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetServiceOrder \ - SC_SCHEMA_KV(kSCPropNetServiceOrder \ - ,"ServiceOrder" \ - ,CFArray[CFString] ) - - SC_SCHEMA_DECLARATION(kSCPropNetPPPOverridePrimary, __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetPPPOverridePrimary \ - SC_SCHEMA_KV(kSCPropNetPPPOverridePrimary \ - ,"PPPOverridePrimary" \ - ,CFNumber (0 or 1) ) - - SC_SCHEMA_DECLARATION(kSCPropNetInterfaces, __OSX_AVAILABLE_STARTING(__MAC_10_2,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetInterfaces \ - SC_SCHEMA_KV(kSCPropNetInterfaces \ - ,"Interfaces" \ - ,CFArray[CFString] ) - - SC_SCHEMA_DECLARATION(kSCPropNetLocalHostName, __OSX_AVAILABLE_STARTING(__MAC_10_2,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetLocalHostName \ - SC_SCHEMA_KV(kSCPropNetLocalHostName \ - ,"LocalHostName" \ - ,CFString ) - - SC_SCHEMA_DECLARATION(kSCPropNetAirPortAllowNetCreation, __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_2,__MAC_10_9,__IPHONE_2_0/*SPI*/,__IPHONE_FUTURE/*SPI*/)) - #define kSCPropNetAirPortAllowNetCreation \ - SC_SCHEMA_KV(kSCPropNetAirPortAllowNetCreation \ - ,"AllowNetCreation" \ - ,CFNumber (0 or 1) ) - - SC_SCHEMA_DECLARATION(kSCPropNetAirPortAuthPassword, __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1,__MAC_10_9,__IPHONE_2_0/*SPI*/,__IPHONE_FUTURE/*SPI*/)) - #define kSCPropNetAirPortAuthPassword \ - SC_SCHEMA_KV(kSCPropNetAirPortAuthPassword \ - ,"AuthPassword" \ - ,CFData ) - - SC_SCHEMA_DECLARATION(kSCPropNetAirPortAuthPasswordEncryption, __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1,__MAC_10_9,__IPHONE_2_0/*SPI*/,__IPHONE_FUTURE/*SPI*/)) - #define kSCPropNetAirPortAuthPasswordEncryption \ - SC_SCHEMA_KV(kSCPropNetAirPortAuthPasswordEncryption \ - ,"AuthPasswordEncryption" \ - ,CFString ) - - SC_SCHEMA_DECLARATION(kSCPropNetAirPortJoinMode, __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_2,__MAC_10_9,__IPHONE_2_0/*SPI*/,__IPHONE_FUTURE/*SPI*/)) - #define kSCPropNetAirPortJoinMode \ - SC_SCHEMA_KV(kSCPropNetAirPortJoinMode \ - ,"JoinMode" \ - ,CFString ) - - SC_SCHEMA_DECLARATION(kSCPropNetAirPortPowerEnabled, __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1,__MAC_10_9,__IPHONE_2_0/*SPI*/,__IPHONE_FUTURE/*SPI*/)) - #define kSCPropNetAirPortPowerEnabled \ - SC_SCHEMA_KV(kSCPropNetAirPortPowerEnabled \ - ,"PowerEnabled" \ - ,CFNumber (0 or 1) ) - - SC_SCHEMA_DECLARATION(kSCPropNetAirPortPreferredNetwork, __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1,__MAC_10_9,__IPHONE_2_0/*SPI*/,__IPHONE_FUTURE/*SPI*/)) - #define kSCPropNetAirPortPreferredNetwork \ - SC_SCHEMA_KV(kSCPropNetAirPortPreferredNetwork \ - ,"PreferredNetwork" \ - ,CFString ) - - SC_SCHEMA_DECLARATION(kSCPropNetAirPortSavePasswords, __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_2,__MAC_10_9,__IPHONE_2_0/*SPI*/,__IPHONE_FUTURE/*SPI*/)) - #define kSCPropNetAirPortSavePasswords \ - SC_SCHEMA_KV(kSCPropNetAirPortSavePasswords \ - ,"SavePasswords" \ - ,CFNumber (0 or 1) ) - - SC_SCHEMA_DECLARATION(kSCValNetAirPortJoinModeAutomatic, __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_3,__MAC_10_9,__IPHONE_2_0/*SPI*/,__IPHONE_FUTURE/*SPI*/)) - #define kSCValNetAirPortJoinModeAutomatic \ - SC_SCHEMA_KV(kSCValNetAirPortJoinModeAutomatic \ - ,"Automatic" \ - , ) - - SC_SCHEMA_DECLARATION(kSCValNetAirPortJoinModePreferred, __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_2,__MAC_10_9,__IPHONE_2_0/*SPI*/,__IPHONE_FUTURE/*SPI*/)) - #define kSCValNetAirPortJoinModePreferred \ - SC_SCHEMA_KV(kSCValNetAirPortJoinModePreferred \ - ,"Preferred" \ - , ) - - SC_SCHEMA_DECLARATION(kSCValNetAirPortJoinModeRanked, __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4,__MAC_10_9,__IPHONE_2_0/*SPI*/,__IPHONE_FUTURE/*SPI*/)) - #define kSCValNetAirPortJoinModeRanked \ - SC_SCHEMA_KV(kSCValNetAirPortJoinModeRanked \ - ,"Ranked" \ - , ) - - SC_SCHEMA_DECLARATION(kSCValNetAirPortJoinModeRecent, __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_2,__MAC_10_9,__IPHONE_2_0/*SPI*/,__IPHONE_FUTURE/*SPI*/)) - #define kSCValNetAirPortJoinModeRecent \ - SC_SCHEMA_KV(kSCValNetAirPortJoinModeRecent \ - ,"Recent" \ - , ) - - SC_SCHEMA_DECLARATION(kSCValNetAirPortJoinModeStrongest, __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_2,__MAC_10_9,__IPHONE_2_0/*SPI*/,__IPHONE_FUTURE/*SPI*/)) - #define kSCValNetAirPortJoinModeStrongest \ - SC_SCHEMA_KV(kSCValNetAirPortJoinModeStrongest \ - ,"Strongest" \ - , ) - - SC_SCHEMA_DECLARATION(kSCValNetAirPortAuthPasswordEncryptionKeychain, __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_3,__MAC_10_9,__IPHONE_2_0/*SPI*/,__IPHONE_FUTURE/*SPI*/)) - #define kSCValNetAirPortAuthPasswordEncryptionKeychain \ - SC_SCHEMA_KV(kSCValNetAirPortAuthPasswordEncryptionKeychain \ - ,"Keychain" \ - , ) - -#if !TARGET_OS_IPHONE - - SC_SCHEMA_DECLARATION(kSCPropNetAppleTalkComputerName, __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1,__MAC_10_6,__IPHONE_NA,__IPHONE_NA)) - #define kSCPropNetAppleTalkComputerName \ - SC_SCHEMA_KV(kSCPropNetAppleTalkComputerName \ - ,"ComputerName" \ - ,CFString ) - - SC_SCHEMA_DECLARATION(kSCPropNetAppleTalkComputerNameEncoding, __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1,__MAC_10_6,__IPHONE_NA,__IPHONE_NA)) - #define kSCPropNetAppleTalkComputerNameEncoding \ - SC_SCHEMA_KV(kSCPropNetAppleTalkComputerNameEncoding \ - ,"ComputerNameEncoding" \ - ,CFNumber ) - - SC_SCHEMA_DECLARATION(kSCPropNetAppleTalkConfigMethod, __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1,__MAC_10_6,__IPHONE_NA,__IPHONE_NA)) - #define kSCPropNetAppleTalkConfigMethod \ - SC_SCHEMA_KV(kSCPropNetAppleTalkConfigMethod \ - ,"ConfigMethod" \ - ,CFString ) - - SC_SCHEMA_DECLARATION(kSCPropNetAppleTalkDefaultZone, __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1,__MAC_10_6,__IPHONE_NA,__IPHONE_NA)) - #define kSCPropNetAppleTalkDefaultZone \ - SC_SCHEMA_KV(kSCPropNetAppleTalkDefaultZone \ - ,"DefaultZone" \ - ,CFString ) - - SC_SCHEMA_DECLARATION(kSCPropNetAppleTalkNetworkID, __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1,__MAC_10_6,__IPHONE_NA,__IPHONE_NA)) - #define kSCPropNetAppleTalkNetworkID \ - SC_SCHEMA_KV(kSCPropNetAppleTalkNetworkID \ - ,"NetworkID" \ - ,CFNumber ) - - SC_SCHEMA_DECLARATION(kSCPropNetAppleTalkNetworkRange, __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_2,__MAC_10_6,__IPHONE_NA,__IPHONE_NA)) - #define kSCPropNetAppleTalkNetworkRange \ - SC_SCHEMA_KV(kSCPropNetAppleTalkNetworkRange \ - ,"NetworkRange" \ - ,CFArray[CFNumber] ) - - SC_SCHEMA_DECLARATION(kSCPropNetAppleTalkNodeID, __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1,__MAC_10_6,__IPHONE_NA,__IPHONE_NA)) - #define kSCPropNetAppleTalkNodeID \ - SC_SCHEMA_KV(kSCPropNetAppleTalkNodeID \ - ,"NodeID" \ - ,CFNumber ) - - SC_SCHEMA_DECLARATION(kSCPropNetAppleTalkSeedNetworkRange, __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1,__MAC_10_6,__IPHONE_NA,__IPHONE_NA)) - #define kSCPropNetAppleTalkSeedNetworkRange \ - SC_SCHEMA_KV(kSCPropNetAppleTalkSeedNetworkRange \ - ,"SeedNetworkRange" \ - ,CFArray[CFNumber] ) - - SC_SCHEMA_DECLARATION(kSCPropNetAppleTalkSeedZones, __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1,__MAC_10_6,__IPHONE_NA,__IPHONE_NA)) - #define kSCPropNetAppleTalkSeedZones \ - SC_SCHEMA_KV(kSCPropNetAppleTalkSeedZones \ - ,"SeedZones" \ - ,CFArray[CFString] ) - - SC_SCHEMA_DECLARATION(kSCValNetAppleTalkConfigMethodNode, __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1,__MAC_10_6,__IPHONE_NA,__IPHONE_NA)) - #define kSCValNetAppleTalkConfigMethodNode \ - SC_SCHEMA_KV(kSCValNetAppleTalkConfigMethodNode \ - ,"Node" \ - , ) - - SC_SCHEMA_DECLARATION(kSCValNetAppleTalkConfigMethodRouter, __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1,__MAC_10_6,__IPHONE_NA,__IPHONE_NA)) - #define kSCValNetAppleTalkConfigMethodRouter \ - SC_SCHEMA_KV(kSCValNetAppleTalkConfigMethodRouter \ - ,"Router" \ - , ) - - SC_SCHEMA_DECLARATION(kSCValNetAppleTalkConfigMethodSeedRouter, __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1,__MAC_10_6,__IPHONE_NA,__IPHONE_NA)) - #define kSCValNetAppleTalkConfigMethodSeedRouter \ - SC_SCHEMA_KV(kSCValNetAppleTalkConfigMethodSeedRouter \ - ,"SeedRouter" \ - , ) - -#endif // !TARGET_OS_IPHONE - - SC_SCHEMA_DECLARATION(kSCPropNetDNSDomainName, __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetDNSDomainName \ - SC_SCHEMA_KV(kSCPropNetDNSDomainName \ - ,"DomainName" \ - ,CFString ) - - SC_SCHEMA_DECLARATION(kSCPropNetDNSOptions, __OSX_AVAILABLE_STARTING(__MAC_10_4,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetDNSOptions \ - SC_SCHEMA_KV(kSCPropNetDNSOptions \ - ,"Options" \ - ,CFString ) - - SC_SCHEMA_DECLARATION(kSCPropNetDNSSearchDomains, __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetDNSSearchDomains \ - SC_SCHEMA_KV(kSCPropNetDNSSearchDomains \ - ,"SearchDomains" \ - ,CFArray[CFString] ) - - SC_SCHEMA_DECLARATION(kSCPropNetDNSSearchOrder, __OSX_AVAILABLE_STARTING(__MAC_10_4,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetDNSSearchOrder \ - SC_SCHEMA_KV(kSCPropNetDNSSearchOrder \ - ,"SearchOrder" \ - ,CFNumber ) - - SC_SCHEMA_DECLARATION(kSCPropNetDNSServerAddresses, __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetDNSServerAddresses \ - SC_SCHEMA_KV(kSCPropNetDNSServerAddresses \ - ,"ServerAddresses" \ - ,CFArray[CFString] ) - - SC_SCHEMA_DECLARATION(kSCPropNetDNSServerPort, __OSX_AVAILABLE_STARTING(__MAC_10_4,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetDNSServerPort \ - SC_SCHEMA_KV(kSCPropNetDNSServerPort \ - ,"ServerPort" \ - ,CFNumber ) - - SC_SCHEMA_DECLARATION(kSCPropNetDNSServerTimeout, __OSX_AVAILABLE_STARTING(__MAC_10_4,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetDNSServerTimeout \ - SC_SCHEMA_KV(kSCPropNetDNSServerTimeout \ - ,"ServerTimeout" \ - ,CFNumber ) - - SC_SCHEMA_DECLARATION(kSCPropNetDNSSortList, __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetDNSSortList \ - SC_SCHEMA_KV(kSCPropNetDNSSortList \ - ,"SortList" \ - ,CFArray[CFString] ) - - SC_SCHEMA_DECLARATION(kSCPropNetDNSSupplementalMatchDomains, __OSX_AVAILABLE_STARTING(__MAC_10_4,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetDNSSupplementalMatchDomains \ - SC_SCHEMA_KV(kSCPropNetDNSSupplementalMatchDomains \ - ,"SupplementalMatchDomains" \ - ,CFArray[CFString] ) - - SC_SCHEMA_DECLARATION(kSCPropNetDNSSupplementalMatchOrders, __OSX_AVAILABLE_STARTING(__MAC_10_4,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetDNSSupplementalMatchOrders \ - SC_SCHEMA_KV(kSCPropNetDNSSupplementalMatchOrders \ - ,"SupplementalMatchOrders" \ - ,CFArray[CFNumber] ) - - SC_SCHEMA_DECLARATION(kSCPropNetEthernetMediaSubType, __OSX_AVAILABLE_STARTING(__MAC_10_2,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetEthernetMediaSubType \ - SC_SCHEMA_KV(kSCPropNetEthernetMediaSubType \ - ,"MediaSubType" \ - ,CFString ) - - SC_SCHEMA_DECLARATION(kSCPropNetEthernetMediaOptions, __OSX_AVAILABLE_STARTING(__MAC_10_2,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetEthernetMediaOptions \ - SC_SCHEMA_KV(kSCPropNetEthernetMediaOptions \ - ,"MediaOptions" \ - ,CFArray[CFString] ) - - SC_SCHEMA_DECLARATION(kSCPropNetEthernetMTU, __OSX_AVAILABLE_STARTING(__MAC_10_2,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetEthernetMTU \ - SC_SCHEMA_KV(kSCPropNetEthernetMTU \ - ,"MTU" \ - ,CFNumber ) - - SC_SCHEMA_DECLARATION(kSCPropNetInterfaceDeviceName, __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetInterfaceDeviceName \ - SC_SCHEMA_KV(kSCPropNetInterfaceDeviceName \ - ,"DeviceName" \ - ,CFString ) - - SC_SCHEMA_DECLARATION(kSCPropNetInterfaceHardware, __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetInterfaceHardware \ - SC_SCHEMA_KV(kSCPropNetInterfaceHardware \ - ,"Hardware" \ - ,CFString ) - - SC_SCHEMA_DECLARATION(kSCPropNetInterfaceType, __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetInterfaceType \ - SC_SCHEMA_KV(kSCPropNetInterfaceType \ - ,"Type" \ - ,CFString ) - - SC_SCHEMA_DECLARATION(kSCPropNetInterfaceSubType, __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetInterfaceSubType \ - SC_SCHEMA_KV(kSCPropNetInterfaceSubType \ - ,"SubType" \ - ,CFString ) - - SC_SCHEMA_DECLARATION(kSCPropNetInterfaceSupportsModemOnHold, __OSX_AVAILABLE_STARTING(__MAC_10_2,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetInterfaceSupportsModemOnHold \ - SC_SCHEMA_KV(kSCPropNetInterfaceSupportsModemOnHold \ - ,"SupportsModemOnHold" \ - ,CFNumber (0 or 1) ) - - SC_SCHEMA_DECLARATION(kSCValNetInterfaceTypeEthernet, __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/)) - #define kSCValNetInterfaceTypeEthernet \ - SC_SCHEMA_KV(kSCValNetInterfaceTypeEthernet \ - ,"Ethernet" \ - , ) - - SC_SCHEMA_DECLARATION(kSCValNetInterfaceTypeFireWire, __OSX_AVAILABLE_STARTING(__MAC_10_3,__IPHONE_2_0/*SPI*/)) - #define kSCValNetInterfaceTypeFireWire \ - SC_SCHEMA_KV(kSCValNetInterfaceTypeFireWire \ - ,"FireWire" \ - , ) - - SC_SCHEMA_DECLARATION(kSCValNetInterfaceTypePPP, __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/)) - #define kSCValNetInterfaceTypePPP \ - SC_SCHEMA_KV(kSCValNetInterfaceTypePPP \ - ,"PPP" \ - , ) - - SC_SCHEMA_DECLARATION(kSCValNetInterfaceType6to4, __OSX_AVAILABLE_STARTING(__MAC_10_3,__IPHONE_2_0/*SPI*/)) - #define kSCValNetInterfaceType6to4 \ - SC_SCHEMA_KV(kSCValNetInterfaceType6to4 \ - ,"6to4" \ - , ) - - SC_SCHEMA_DECLARATION(kSCValNetInterfaceTypeIPSec, __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_2_0/*SPI*/)) - #define kSCValNetInterfaceTypeIPSec \ - SC_SCHEMA_KV(kSCValNetInterfaceTypeIPSec \ - ,"IPSec" \ - , ) - - SC_SCHEMA_DECLARATION(kSCValNetInterfaceSubTypePPPoE, __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/)) - #define kSCValNetInterfaceSubTypePPPoE \ - SC_SCHEMA_KV(kSCValNetInterfaceSubTypePPPoE \ - ,"PPPoE" \ - , ) - - SC_SCHEMA_DECLARATION(kSCValNetInterfaceSubTypePPPSerial, __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/)) - #define kSCValNetInterfaceSubTypePPPSerial \ - SC_SCHEMA_KV(kSCValNetInterfaceSubTypePPPSerial \ - ,"PPPSerial" \ - , ) - - SC_SCHEMA_DECLARATION(kSCValNetInterfaceSubTypePPTP, __OSX_AVAILABLE_STARTING(__MAC_10_2,__IPHONE_2_0/*SPI*/)) - #define kSCValNetInterfaceSubTypePPTP \ - SC_SCHEMA_KV(kSCValNetInterfaceSubTypePPTP \ - ,"PPTP" \ - , ) - - SC_SCHEMA_DECLARATION(kSCValNetInterfaceSubTypeL2TP, __OSX_AVAILABLE_STARTING(__MAC_10_3,__IPHONE_2_0/*SPI*/)) - #define kSCValNetInterfaceSubTypeL2TP \ - SC_SCHEMA_KV(kSCValNetInterfaceSubTypeL2TP \ - ,"L2TP" \ - , ) - - SC_SCHEMA_DECLARATION(kSCPropNetIPSecAuthenticationMethod, __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetIPSecAuthenticationMethod \ - SC_SCHEMA_KV(kSCPropNetIPSecAuthenticationMethod \ - ,"AuthenticationMethod" \ - ,CFString ) - - SC_SCHEMA_DECLARATION(kSCPropNetIPSecLocalCertificate, __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetIPSecLocalCertificate \ - SC_SCHEMA_KV(kSCPropNetIPSecLocalCertificate \ - ,"LocalCertificate" \ - ,CFData ) - - SC_SCHEMA_DECLARATION(kSCPropNetIPSecLocalIdentifier, __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetIPSecLocalIdentifier \ - SC_SCHEMA_KV(kSCPropNetIPSecLocalIdentifier \ - ,"LocalIdentifier" \ - ,CFString ) - - SC_SCHEMA_DECLARATION(kSCPropNetIPSecLocalIdentifierType, __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetIPSecLocalIdentifierType \ - SC_SCHEMA_KV(kSCPropNetIPSecLocalIdentifierType \ - ,"LocalIdentifierType" \ - ,CFString ) - - SC_SCHEMA_DECLARATION(kSCPropNetIPSecSharedSecret, __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetIPSecSharedSecret \ - SC_SCHEMA_KV(kSCPropNetIPSecSharedSecret \ - ,"SharedSecret" \ - ,CFString ) - - SC_SCHEMA_DECLARATION(kSCPropNetIPSecSharedSecretEncryption, __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetIPSecSharedSecretEncryption \ - SC_SCHEMA_KV(kSCPropNetIPSecSharedSecretEncryption \ - ,"SharedSecretEncryption" \ - ,CFString ) - - SC_SCHEMA_DECLARATION(kSCPropNetIPSecConnectTime, __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetIPSecConnectTime \ - SC_SCHEMA_KV(kSCPropNetIPSecConnectTime \ - ,"ConnectTime" \ - ,CFNumber ) - - SC_SCHEMA_DECLARATION(kSCPropNetIPSecRemoteAddress, __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetIPSecRemoteAddress \ - SC_SCHEMA_KV(kSCPropNetIPSecRemoteAddress \ - ,"RemoteAddress" \ - ,CFString ) - - SC_SCHEMA_DECLARATION(kSCPropNetIPSecStatus, __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetIPSecStatus \ - SC_SCHEMA_KV(kSCPropNetIPSecStatus \ - ,"Status" \ - ,CFNumber ) - - SC_SCHEMA_DECLARATION(kSCPropNetIPSecXAuthEnabled, __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetIPSecXAuthEnabled \ - SC_SCHEMA_KV(kSCPropNetIPSecXAuthEnabled \ - ,"XAuthEnabled" \ - ,CFNumber (0 or 1) ) - - SC_SCHEMA_DECLARATION(kSCPropNetIPSecXAuthName, __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetIPSecXAuthName \ - SC_SCHEMA_KV(kSCPropNetIPSecXAuthName \ - ,"XAuthName" \ - ,CFString ) - - SC_SCHEMA_DECLARATION(kSCPropNetIPSecXAuthPassword, __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetIPSecXAuthPassword \ - SC_SCHEMA_KV(kSCPropNetIPSecXAuthPassword \ - ,"XAuthPassword" \ - ,CFString ) - - SC_SCHEMA_DECLARATION(kSCPropNetIPSecXAuthPasswordEncryption, __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetIPSecXAuthPasswordEncryption \ - SC_SCHEMA_KV(kSCPropNetIPSecXAuthPasswordEncryption \ - ,"XAuthPasswordEncryption" \ - ,CFString ) - - SC_SCHEMA_DECLARATION(kSCValNetIPSecAuthenticationMethodSharedSecret, __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0/*SPI*/)) - #define kSCValNetIPSecAuthenticationMethodSharedSecret \ - SC_SCHEMA_KV(kSCValNetIPSecAuthenticationMethodSharedSecret \ - ,"SharedSecret" \ - , ) - - SC_SCHEMA_DECLARATION(kSCValNetIPSecAuthenticationMethodCertificate, __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0/*SPI*/)) - #define kSCValNetIPSecAuthenticationMethodCertificate \ - SC_SCHEMA_KV(kSCValNetIPSecAuthenticationMethodCertificate \ - ,"Certificate" \ - , ) - - SC_SCHEMA_DECLARATION(kSCValNetIPSecAuthenticationMethodHybrid, __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0/*SPI*/)) - #define kSCValNetIPSecAuthenticationMethodHybrid \ - SC_SCHEMA_KV(kSCValNetIPSecAuthenticationMethodHybrid \ - ,"Hybrid" \ - , ) - - SC_SCHEMA_DECLARATION(kSCValNetIPSecLocalIdentifierTypeKeyID, __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0/*SPI*/)) - #define kSCValNetIPSecLocalIdentifierTypeKeyID \ - SC_SCHEMA_KV(kSCValNetIPSecLocalIdentifierTypeKeyID \ - ,"KeyID" \ - , ) - - SC_SCHEMA_DECLARATION(kSCValNetIPSecSharedSecretEncryptionKeychain, __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0/*SPI*/)) - #define kSCValNetIPSecSharedSecretEncryptionKeychain \ - SC_SCHEMA_KV(kSCValNetIPSecSharedSecretEncryptionKeychain \ - ,"Keychain" \ - , ) - - SC_SCHEMA_DECLARATION(kSCValNetIPSecXAuthPasswordEncryptionKeychain, __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_2_0/*SPI*/)) - #define kSCValNetIPSecXAuthPasswordEncryptionKeychain \ - SC_SCHEMA_KV(kSCValNetIPSecXAuthPasswordEncryptionKeychain \ - ,"Keychain" \ - , ) - - SC_SCHEMA_DECLARATION(kSCValNetIPSecXAuthPasswordEncryptionPrompt, __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_3_0/*SPI*/)) - #define kSCValNetIPSecXAuthPasswordEncryptionPrompt \ - SC_SCHEMA_KV(kSCValNetIPSecXAuthPasswordEncryptionPrompt \ - ,"Prompt" \ - , ) - - SC_SCHEMA_DECLARATION(kSCPropNetIPv4Addresses, __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetIPv4Addresses \ - SC_SCHEMA_KV(kSCPropNetIPv4Addresses \ - ,"Addresses" \ - ,CFArray[CFString] ) - - SC_SCHEMA_DECLARATION(kSCPropNetIPv4ConfigMethod, __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetIPv4ConfigMethod \ - SC_SCHEMA_KV(kSCPropNetIPv4ConfigMethod \ - ,"ConfigMethod" \ - ,CFString ) - - SC_SCHEMA_DECLARATION(kSCPropNetIPv4DHCPClientID, __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetIPv4DHCPClientID \ - SC_SCHEMA_KV(kSCPropNetIPv4DHCPClientID \ - ,"DHCPClientID" \ - ,CFString ) - - SC_SCHEMA_DECLARATION(kSCPropNetIPv4Router, __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetIPv4Router \ - SC_SCHEMA_KV(kSCPropNetIPv4Router \ - ,"Router" \ - ,CFString ) - - SC_SCHEMA_DECLARATION(kSCPropNetIPv4SubnetMasks, __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetIPv4SubnetMasks \ - SC_SCHEMA_KV(kSCPropNetIPv4SubnetMasks \ - ,"SubnetMasks" \ - ,CFArray[CFString] ) - - SC_SCHEMA_DECLARATION(kSCPropNetIPv4DestAddresses, __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetIPv4DestAddresses \ - SC_SCHEMA_KV(kSCPropNetIPv4DestAddresses \ - ,"DestAddresses" \ - ,CFArray[CFString] ) - - SC_SCHEMA_DECLARATION(kSCPropNetIPv4BroadcastAddresses, __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetIPv4BroadcastAddresses \ - SC_SCHEMA_KV(kSCPropNetIPv4BroadcastAddresses \ - ,"BroadcastAddresses" \ - ,CFArray[CFString] ) - - SC_SCHEMA_DECLARATION(kSCValNetIPv4ConfigMethodAutomatic, __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_2_0/*SPI*/)) - #define kSCValNetIPv4ConfigMethodAutomatic \ - SC_SCHEMA_KV(kSCValNetIPv4ConfigMethodAutomatic \ - ,"Automatic" \ - , ) - - SC_SCHEMA_DECLARATION(kSCValNetIPv4ConfigMethodBOOTP, __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/)) - #define kSCValNetIPv4ConfigMethodBOOTP \ - SC_SCHEMA_KV(kSCValNetIPv4ConfigMethodBOOTP \ - ,"BOOTP" \ - , ) - - SC_SCHEMA_DECLARATION(kSCValNetIPv4ConfigMethodDHCP, __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/)) - #define kSCValNetIPv4ConfigMethodDHCP \ - SC_SCHEMA_KV(kSCValNetIPv4ConfigMethodDHCP \ - ,"DHCP" \ - , ) - - SC_SCHEMA_DECLARATION(kSCValNetIPv4ConfigMethodINFORM, __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/)) - #define kSCValNetIPv4ConfigMethodINFORM \ - SC_SCHEMA_KV(kSCValNetIPv4ConfigMethodINFORM \ - ,"INFORM" \ - , ) - - SC_SCHEMA_DECLARATION(kSCValNetIPv4ConfigMethodLinkLocal, __OSX_AVAILABLE_STARTING(__MAC_10_2,__IPHONE_2_0/*SPI*/)) - #define kSCValNetIPv4ConfigMethodLinkLocal \ - SC_SCHEMA_KV(kSCValNetIPv4ConfigMethodLinkLocal \ - ,"LinkLocal" \ - , ) - - SC_SCHEMA_DECLARATION(kSCValNetIPv4ConfigMethodManual, __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/)) - #define kSCValNetIPv4ConfigMethodManual \ - SC_SCHEMA_KV(kSCValNetIPv4ConfigMethodManual \ - ,"Manual" \ - , ) - - SC_SCHEMA_DECLARATION(kSCValNetIPv4ConfigMethodPPP, __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/)) - #define kSCValNetIPv4ConfigMethodPPP \ - SC_SCHEMA_KV(kSCValNetIPv4ConfigMethodPPP \ - ,"PPP" \ - , ) - - SC_SCHEMA_DECLARATION(kSCPropNetIPv6Addresses, __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetIPv6Addresses \ - SC_SCHEMA_KV(kSCPropNetIPv6Addresses \ - ,"Addresses" \ - ,CFArray[CFString] ) - - SC_SCHEMA_DECLARATION(kSCPropNetIPv6ConfigMethod, __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetIPv6ConfigMethod \ - SC_SCHEMA_KV(kSCPropNetIPv6ConfigMethod \ - ,"ConfigMethod" \ - ,CFString ) - - SC_SCHEMA_DECLARATION(kSCPropNetIPv6DestAddresses, __OSX_AVAILABLE_STARTING(__MAC_10_3,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetIPv6DestAddresses \ - SC_SCHEMA_KV(kSCPropNetIPv6DestAddresses \ - ,"DestAddresses" \ - ,CFArray[CFString] ) - - SC_SCHEMA_DECLARATION(kSCPropNetIPv6Flags, __OSX_AVAILABLE_STARTING(__MAC_10_3,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetIPv6Flags \ - SC_SCHEMA_KV(kSCPropNetIPv6Flags \ - ,"Flags" \ - ,CFNumber ) - - SC_SCHEMA_DECLARATION(kSCPropNetIPv6PrefixLength, __OSX_AVAILABLE_STARTING(__MAC_10_3,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetIPv6PrefixLength \ - SC_SCHEMA_KV(kSCPropNetIPv6PrefixLength \ - ,"PrefixLength" \ - ,CFArray[CFNumber] ) - - SC_SCHEMA_DECLARATION(kSCPropNetIPv6Router, __OSX_AVAILABLE_STARTING(__MAC_10_3,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetIPv6Router \ - SC_SCHEMA_KV(kSCPropNetIPv6Router \ - ,"Router" \ - ,CFString ) - - SC_SCHEMA_DECLARATION(kSCValNetIPv6ConfigMethodAutomatic, __OSX_AVAILABLE_STARTING(__MAC_10_3,__IPHONE_2_0/*SPI*/)) - #define kSCValNetIPv6ConfigMethodAutomatic \ - SC_SCHEMA_KV(kSCValNetIPv6ConfigMethodAutomatic \ - ,"Automatic" \ - , ) - - SC_SCHEMA_DECLARATION(kSCValNetIPv6ConfigMethodLinkLocal, __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_4_0/*SPI*/)) - #define kSCValNetIPv6ConfigMethodLinkLocal \ - SC_SCHEMA_KV(kSCValNetIPv6ConfigMethodLinkLocal \ - ,"LinkLocal" \ - , ) - - SC_SCHEMA_DECLARATION(kSCValNetIPv6ConfigMethodManual, __OSX_AVAILABLE_STARTING(__MAC_10_3,__IPHONE_2_0/*SPI*/)) - #define kSCValNetIPv6ConfigMethodManual \ - SC_SCHEMA_KV(kSCValNetIPv6ConfigMethodManual \ - ,"Manual" \ - , ) - - SC_SCHEMA_DECLARATION(kSCValNetIPv6ConfigMethodRouterAdvertisement, __OSX_AVAILABLE_STARTING(__MAC_10_3,__IPHONE_2_0/*SPI*/)) - #define kSCValNetIPv6ConfigMethodRouterAdvertisement \ - SC_SCHEMA_KV(kSCValNetIPv6ConfigMethodRouterAdvertisement \ - ,"RouterAdvertisement" \ - , ) - - SC_SCHEMA_DECLARATION(kSCValNetIPv6ConfigMethod6to4, __OSX_AVAILABLE_STARTING(__MAC_10_3,__IPHONE_2_0/*SPI*/)) - #define kSCValNetIPv6ConfigMethod6to4 \ - SC_SCHEMA_KV(kSCValNetIPv6ConfigMethod6to4 \ - ,"6to4" \ - , ) - - SC_SCHEMA_DECLARATION(kSCPropNet6to4Relay, __OSX_AVAILABLE_STARTING(__MAC_10_3,__IPHONE_2_0/*SPI*/)) - #define kSCPropNet6to4Relay \ - SC_SCHEMA_KV(kSCPropNet6to4Relay \ - ,"Relay" \ - ,CFString ) - - SC_SCHEMA_DECLARATION(kSCPropNetLinkActive, __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetLinkActive \ - SC_SCHEMA_KV(kSCPropNetLinkActive \ - ,"Active" \ - ,CFBoolean ) - - SC_SCHEMA_DECLARATION(kSCPropNetLinkDetaching, __OSX_AVAILABLE_STARTING(__MAC_10_2,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetLinkDetaching \ - SC_SCHEMA_KV(kSCPropNetLinkDetaching \ - ,"Detaching" \ - ,CFBoolean ) - - SC_SCHEMA_DECLARATION(kSCPropNetModemAccessPointName, __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetModemAccessPointName \ - SC_SCHEMA_KV(kSCPropNetModemAccessPointName \ - ,"AccessPointName" \ - ,CFString ) - - SC_SCHEMA_DECLARATION(kSCPropNetModemConnectionPersonality, __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetModemConnectionPersonality \ - SC_SCHEMA_KV(kSCPropNetModemConnectionPersonality \ - ,"ConnectionPersonality" \ - ,CFString ) - - SC_SCHEMA_DECLARATION(kSCPropNetModemConnectionScript, __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetModemConnectionScript \ - SC_SCHEMA_KV(kSCPropNetModemConnectionScript \ - ,"ConnectionScript" \ - ,CFString ) - - SC_SCHEMA_DECLARATION(kSCPropNetModemConnectSpeed, __OSX_AVAILABLE_STARTING(__MAC_10_2,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetModemConnectSpeed \ - SC_SCHEMA_KV(kSCPropNetModemConnectSpeed \ - ,"ConnectSpeed" \ - ,CFNumber ) - - SC_SCHEMA_DECLARATION(kSCPropNetModemDataCompression, __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetModemDataCompression \ - SC_SCHEMA_KV(kSCPropNetModemDataCompression \ - ,"DataCompression" \ - ,CFNumber (0 or 1) ) - - SC_SCHEMA_DECLARATION(kSCPropNetModemDeviceContextID, __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetModemDeviceContextID \ - SC_SCHEMA_KV(kSCPropNetModemDeviceContextID \ - ,"DeviceContextID" \ - ,CFString ) - - SC_SCHEMA_DECLARATION(kSCPropNetModemDeviceModel, __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetModemDeviceModel \ - SC_SCHEMA_KV(kSCPropNetModemDeviceModel \ - ,"DeviceModel" \ - ,CFString ) - - SC_SCHEMA_DECLARATION(kSCPropNetModemDeviceVendor, __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetModemDeviceVendor \ - SC_SCHEMA_KV(kSCPropNetModemDeviceVendor \ - ,"DeviceVendor" \ - ,CFString ) - - SC_SCHEMA_DECLARATION(kSCPropNetModemDialMode, __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetModemDialMode \ - SC_SCHEMA_KV(kSCPropNetModemDialMode \ - ,"DialMode" \ - ,CFString ) - - SC_SCHEMA_DECLARATION(kSCPropNetModemErrorCorrection, __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetModemErrorCorrection \ - SC_SCHEMA_KV(kSCPropNetModemErrorCorrection \ - ,"ErrorCorrection" \ - ,CFNumber (0 or 1) ) - - SC_SCHEMA_DECLARATION(kSCPropNetModemHoldCallWaitingAudibleAlert, __OSX_AVAILABLE_STARTING(__MAC_10_2,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetModemHoldCallWaitingAudibleAlert \ - SC_SCHEMA_KV(kSCPropNetModemHoldCallWaitingAudibleAlert \ - ,"HoldCallWaitingAudibleAlert" \ - ,CFNumber (0 or 1) ) - - SC_SCHEMA_DECLARATION(kSCPropNetModemHoldDisconnectOnAnswer, __OSX_AVAILABLE_STARTING(__MAC_10_2,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetModemHoldDisconnectOnAnswer \ - SC_SCHEMA_KV(kSCPropNetModemHoldDisconnectOnAnswer \ - ,"HoldDisconnectOnAnswer" \ - ,CFNumber (0 or 1) ) - - SC_SCHEMA_DECLARATION(kSCPropNetModemHoldEnabled, __OSX_AVAILABLE_STARTING(__MAC_10_2,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetModemHoldEnabled \ - SC_SCHEMA_KV(kSCPropNetModemHoldEnabled \ - ,"HoldEnabled" \ - ,CFNumber (0 or 1) ) - - SC_SCHEMA_DECLARATION(kSCPropNetModemHoldReminder, __OSX_AVAILABLE_STARTING(__MAC_10_2,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetModemHoldReminder \ - SC_SCHEMA_KV(kSCPropNetModemHoldReminder \ - ,"HoldReminder" \ - ,CFNumber (0 or 1) ) - - SC_SCHEMA_DECLARATION(kSCPropNetModemHoldReminderTime, __OSX_AVAILABLE_STARTING(__MAC_10_2,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetModemHoldReminderTime \ - SC_SCHEMA_KV(kSCPropNetModemHoldReminderTime \ - ,"HoldReminderTime" \ - ,CFNumber ) - - SC_SCHEMA_DECLARATION(kSCPropNetModemNote, __OSX_AVAILABLE_STARTING(__MAC_10_2,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetModemNote \ - SC_SCHEMA_KV(kSCPropNetModemNote \ - ,"Note" \ - ,CFString ) - - SC_SCHEMA_DECLARATION(kSCPropNetModemPulseDial, __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetModemPulseDial \ - SC_SCHEMA_KV(kSCPropNetModemPulseDial \ - ,"PulseDial" \ - ,CFNumber (0 or 1) ) - - SC_SCHEMA_DECLARATION(kSCPropNetModemSpeaker, __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetModemSpeaker \ - SC_SCHEMA_KV(kSCPropNetModemSpeaker \ - ,"Speaker" \ - ,CFNumber (0 or 1) ) - - SC_SCHEMA_DECLARATION(kSCPropNetModemSpeed, __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetModemSpeed \ - SC_SCHEMA_KV(kSCPropNetModemSpeed \ - ,"Speed" \ - ,CFNumber ) - - SC_SCHEMA_DECLARATION(kSCValNetModemDialModeIgnoreDialTone, __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/)) - #define kSCValNetModemDialModeIgnoreDialTone \ - SC_SCHEMA_KV(kSCValNetModemDialModeIgnoreDialTone \ - ,"IgnoreDialTone" \ - , ) - - SC_SCHEMA_DECLARATION(kSCValNetModemDialModeManual, __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/)) - #define kSCValNetModemDialModeManual \ - SC_SCHEMA_KV(kSCValNetModemDialModeManual \ - ,"Manual" \ - , ) - - SC_SCHEMA_DECLARATION(kSCValNetModemDialModeWaitForDialTone, __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/)) - #define kSCValNetModemDialModeWaitForDialTone \ - SC_SCHEMA_KV(kSCValNetModemDialModeWaitForDialTone \ - ,"WaitForDialTone" \ - , ) - -#if !TARGET_OS_IPHONE - - SC_SCHEMA_DECLARATION(kSCPropNetNetInfoBindingMethods, __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1,__MAC_10_5,__IPHONE_NA,__IPHONE_NA)) - #define kSCPropNetNetInfoBindingMethods \ - SC_SCHEMA_KV(kSCPropNetNetInfoBindingMethods \ - ,"BindingMethods" \ - ,CFString ) - - SC_SCHEMA_DECLARATION(kSCPropNetNetInfoServerAddresses, __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1,__MAC_10_5,__IPHONE_NA,__IPHONE_NA)) - #define kSCPropNetNetInfoServerAddresses \ - SC_SCHEMA_KV(kSCPropNetNetInfoServerAddresses \ - ,"ServerAddresses" \ - ,CFArray[CFString] ) - - SC_SCHEMA_DECLARATION(kSCPropNetNetInfoServerTags, __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1,__MAC_10_5,__IPHONE_NA,__IPHONE_NA)) - #define kSCPropNetNetInfoServerTags \ - SC_SCHEMA_KV(kSCPropNetNetInfoServerTags \ - ,"ServerTags" \ - ,CFArray[CFString] ) - - SC_SCHEMA_DECLARATION(kSCPropNetNetInfoBroadcastServerTag, __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1,__MAC_10_5,__IPHONE_NA,__IPHONE_NA)) - #define kSCPropNetNetInfoBroadcastServerTag \ - SC_SCHEMA_KV(kSCPropNetNetInfoBroadcastServerTag \ - ,"BroadcastServerTag" \ - ,CFString ) - - SC_SCHEMA_DECLARATION(kSCValNetNetInfoBindingMethodsBroadcast, __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1,__MAC_10_5,__IPHONE_NA,__IPHONE_NA)) - #define kSCValNetNetInfoBindingMethodsBroadcast \ - SC_SCHEMA_KV(kSCValNetNetInfoBindingMethodsBroadcast \ - ,"Broadcast" \ - , ) - - SC_SCHEMA_DECLARATION(kSCValNetNetInfoBindingMethodsDHCP, __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1,__MAC_10_5,__IPHONE_NA,__IPHONE_NA)) - #define kSCValNetNetInfoBindingMethodsDHCP \ - SC_SCHEMA_KV(kSCValNetNetInfoBindingMethodsDHCP \ - ,"DHCP" \ - , ) - - SC_SCHEMA_DECLARATION(kSCValNetNetInfoBindingMethodsManual, __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1,__MAC_10_5,__IPHONE_NA,__IPHONE_NA)) - #define kSCValNetNetInfoBindingMethodsManual \ - SC_SCHEMA_KV(kSCValNetNetInfoBindingMethodsManual \ - ,"Manual" \ - , ) - - SC_SCHEMA_DECLARATION(kSCValNetNetInfoDefaultServerTag, __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1,__MAC_10_5,__IPHONE_NA,__IPHONE_NA)) - #define kSCValNetNetInfoDefaultServerTag \ - SC_SCHEMA_KV(kSCValNetNetInfoDefaultServerTag \ - ,"network" \ - , ) - -#endif // !TARGET_OS_IPHONE - - SC_SCHEMA_DECLARATION(kSCPropNetPPPACSPEnabled, __OSX_AVAILABLE_STARTING(__MAC_10_3,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetPPPACSPEnabled \ - SC_SCHEMA_KV(kSCPropNetPPPACSPEnabled \ - ,"ACSPEnabled" \ - ,CFNumber (0 or 1) ) - - SC_SCHEMA_DECLARATION(kSCPropNetPPPConnectTime, __OSX_AVAILABLE_STARTING(__MAC_10_2,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetPPPConnectTime \ - SC_SCHEMA_KV(kSCPropNetPPPConnectTime \ - ,"ConnectTime" \ - ,CFNumber ) - - SC_SCHEMA_DECLARATION(kSCPropNetPPPDeviceLastCause, __OSX_AVAILABLE_STARTING(__MAC_10_2,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetPPPDeviceLastCause \ - SC_SCHEMA_KV(kSCPropNetPPPDeviceLastCause \ - ,"DeviceLastCause" \ - ,CFNumber ) - - SC_SCHEMA_DECLARATION(kSCPropNetPPPDialOnDemand, __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetPPPDialOnDemand \ - SC_SCHEMA_KV(kSCPropNetPPPDialOnDemand \ - ,"DialOnDemand" \ - ,CFNumber (0 or 1) ) - - SC_SCHEMA_DECLARATION(kSCPropNetPPPDisconnectOnFastUserSwitch, __OSX_AVAILABLE_STARTING(__MAC_10_4,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetPPPDisconnectOnFastUserSwitch \ - SC_SCHEMA_KV(kSCPropNetPPPDisconnectOnFastUserSwitch \ - ,"DisconnectOnFastUserSwitch" \ - ,CFNumber (0 or 1) ) - - SC_SCHEMA_DECLARATION(kSCPropNetPPPDisconnectOnIdle, __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetPPPDisconnectOnIdle \ - SC_SCHEMA_KV(kSCPropNetPPPDisconnectOnIdle \ - ,"DisconnectOnIdle" \ - ,CFNumber (0 or 1) ) - - SC_SCHEMA_DECLARATION(kSCPropNetPPPDisconnectOnIdleTimer, __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetPPPDisconnectOnIdleTimer \ - SC_SCHEMA_KV(kSCPropNetPPPDisconnectOnIdleTimer \ - ,"DisconnectOnIdleTimer" \ - ,CFNumber ) - - SC_SCHEMA_DECLARATION(kSCPropNetPPPDisconnectOnLogout, __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetPPPDisconnectOnLogout \ - SC_SCHEMA_KV(kSCPropNetPPPDisconnectOnLogout \ - ,"DisconnectOnLogout" \ - ,CFNumber (0 or 1) ) - - SC_SCHEMA_DECLARATION(kSCPropNetPPPDisconnectOnSleep, __OSX_AVAILABLE_STARTING(__MAC_10_2,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetPPPDisconnectOnSleep \ - SC_SCHEMA_KV(kSCPropNetPPPDisconnectOnSleep \ - ,"DisconnectOnSleep" \ - ,CFNumber (0 or 1) ) - - SC_SCHEMA_DECLARATION(kSCPropNetPPPDisconnectTime, __OSX_AVAILABLE_STARTING(__MAC_10_3,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetPPPDisconnectTime \ - SC_SCHEMA_KV(kSCPropNetPPPDisconnectTime \ - ,"DisconnectTime" \ - ,CFNumber ) - - SC_SCHEMA_DECLARATION(kSCPropNetPPPIdleReminderTimer, __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetPPPIdleReminderTimer \ - SC_SCHEMA_KV(kSCPropNetPPPIdleReminderTimer \ - ,"IdleReminderTimer" \ - ,CFNumber ) - - SC_SCHEMA_DECLARATION(kSCPropNetPPPIdleReminder, __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetPPPIdleReminder \ - SC_SCHEMA_KV(kSCPropNetPPPIdleReminder \ - ,"IdleReminder" \ - ,CFNumber (0 or 1) ) - - SC_SCHEMA_DECLARATION(kSCPropNetPPPLastCause, __OSX_AVAILABLE_STARTING(__MAC_10_2,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetPPPLastCause \ - SC_SCHEMA_KV(kSCPropNetPPPLastCause \ - ,"LastCause" \ - ,CFNumber ) - - SC_SCHEMA_DECLARATION(kSCPropNetPPPLogfile, __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetPPPLogfile \ - SC_SCHEMA_KV(kSCPropNetPPPLogfile \ - ,"Logfile" \ - ,CFString ) - - SC_SCHEMA_DECLARATION(kSCPropNetPPPPlugins, __OSX_AVAILABLE_STARTING(__MAC_10_2,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetPPPPlugins \ - SC_SCHEMA_KV(kSCPropNetPPPPlugins \ - ,"Plugins" \ - ,CFArray[CFString] ) - - SC_SCHEMA_DECLARATION(kSCPropNetPPPRetryConnectTime, __OSX_AVAILABLE_STARTING(__MAC_10_3,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetPPPRetryConnectTime \ - SC_SCHEMA_KV(kSCPropNetPPPRetryConnectTime \ - ,"RetryConnectTime" \ - ,CFNumber ) - - SC_SCHEMA_DECLARATION(kSCPropNetPPPSessionTimer, __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetPPPSessionTimer \ - SC_SCHEMA_KV(kSCPropNetPPPSessionTimer \ - ,"SessionTimer" \ - ,CFNumber ) - - SC_SCHEMA_DECLARATION(kSCPropNetPPPStatus, __OSX_AVAILABLE_STARTING(__MAC_10_2,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetPPPStatus \ - SC_SCHEMA_KV(kSCPropNetPPPStatus \ - ,"Status" \ - ,CFNumber ) - - SC_SCHEMA_DECLARATION(kSCPropNetPPPUseSessionTimer, __OSX_AVAILABLE_STARTING(__MAC_10_2,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetPPPUseSessionTimer \ - SC_SCHEMA_KV(kSCPropNetPPPUseSessionTimer \ - ,"UseSessionTimer" \ - ,CFNumber (0 or 1) ) - - SC_SCHEMA_DECLARATION(kSCPropNetPPPVerboseLogging, __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetPPPVerboseLogging \ - SC_SCHEMA_KV(kSCPropNetPPPVerboseLogging \ - ,"VerboseLogging" \ - ,CFNumber (0 or 1) ) - - SC_SCHEMA_DECLARATION(kSCPropNetPPPAuthEAPPlugins, __OSX_AVAILABLE_STARTING(__MAC_10_3,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetPPPAuthEAPPlugins \ - SC_SCHEMA_KV(kSCPropNetPPPAuthEAPPlugins \ - ,"AuthEAPPlugins" \ - ,CFArray[CFString] ) - - SC_SCHEMA_DECLARATION(kSCPropNetPPPAuthName, __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetPPPAuthName \ - SC_SCHEMA_KV(kSCPropNetPPPAuthName \ - ,"AuthName" \ - ,CFString ) - - SC_SCHEMA_DECLARATION(kSCPropNetPPPAuthPassword, __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetPPPAuthPassword \ - SC_SCHEMA_KV(kSCPropNetPPPAuthPassword \ - ,"AuthPassword" \ - ,CFString ) - - SC_SCHEMA_DECLARATION(kSCPropNetPPPAuthPasswordEncryption, __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetPPPAuthPasswordEncryption \ - SC_SCHEMA_KV(kSCPropNetPPPAuthPasswordEncryption \ - ,"AuthPasswordEncryption" \ - ,CFString ) - - SC_SCHEMA_DECLARATION(kSCPropNetPPPAuthPrompt, __OSX_AVAILABLE_STARTING(__MAC_10_3,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetPPPAuthPrompt \ - SC_SCHEMA_KV(kSCPropNetPPPAuthPrompt \ - ,"AuthPrompt" \ - ,CFString ) - - SC_SCHEMA_DECLARATION(kSCPropNetPPPAuthProtocol, __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetPPPAuthProtocol \ - SC_SCHEMA_KV(kSCPropNetPPPAuthProtocol \ - ,"AuthProtocol" \ - ,CFArray[CFString] ) - - SC_SCHEMA_DECLARATION(kSCValNetPPPAuthPasswordEncryptionKeychain, __OSX_AVAILABLE_STARTING(__MAC_10_3,__IPHONE_2_0/*SPI*/)) - #define kSCValNetPPPAuthPasswordEncryptionKeychain \ - SC_SCHEMA_KV(kSCValNetPPPAuthPasswordEncryptionKeychain \ - ,"Keychain" \ - , ) - - SC_SCHEMA_DECLARATION(kSCValNetPPPAuthPasswordEncryptionToken, __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0/*SPI*/)) - #define kSCValNetPPPAuthPasswordEncryptionToken \ - SC_SCHEMA_KV(kSCValNetPPPAuthPasswordEncryptionToken \ - ,"Token" \ - , ) - - SC_SCHEMA_DECLARATION(kSCValNetPPPAuthPromptBefore, __OSX_AVAILABLE_STARTING(__MAC_10_3,__IPHONE_2_0/*SPI*/)) - #define kSCValNetPPPAuthPromptBefore \ - SC_SCHEMA_KV(kSCValNetPPPAuthPromptBefore \ - ,"Before" \ - ,CFString ) - - SC_SCHEMA_DECLARATION(kSCValNetPPPAuthPromptAfter, __OSX_AVAILABLE_STARTING(__MAC_10_3,__IPHONE_2_0/*SPI*/)) - #define kSCValNetPPPAuthPromptAfter \ - SC_SCHEMA_KV(kSCValNetPPPAuthPromptAfter \ - ,"After" \ - ,CFString ) - - SC_SCHEMA_DECLARATION(kSCValNetPPPAuthProtocolCHAP, __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/)) - #define kSCValNetPPPAuthProtocolCHAP \ - SC_SCHEMA_KV(kSCValNetPPPAuthProtocolCHAP \ - ,"CHAP" \ - ,CFString ) - - SC_SCHEMA_DECLARATION(kSCValNetPPPAuthProtocolEAP, __OSX_AVAILABLE_STARTING(__MAC_10_3,__IPHONE_2_0/*SPI*/)) - #define kSCValNetPPPAuthProtocolEAP \ - SC_SCHEMA_KV(kSCValNetPPPAuthProtocolEAP \ - ,"EAP" \ - ,CFString ) - - SC_SCHEMA_DECLARATION(kSCValNetPPPAuthProtocolMSCHAP1, __OSX_AVAILABLE_STARTING(__MAC_10_3,__IPHONE_2_0/*SPI*/)) - #define kSCValNetPPPAuthProtocolMSCHAP1 \ - SC_SCHEMA_KV(kSCValNetPPPAuthProtocolMSCHAP1 \ - ,"MSCHAP1" \ - ,CFString ) - - SC_SCHEMA_DECLARATION(kSCValNetPPPAuthProtocolMSCHAP2, __OSX_AVAILABLE_STARTING(__MAC_10_3,__IPHONE_2_0/*SPI*/)) - #define kSCValNetPPPAuthProtocolMSCHAP2 \ - SC_SCHEMA_KV(kSCValNetPPPAuthProtocolMSCHAP2 \ - ,"MSCHAP2" \ - ,CFString ) - - SC_SCHEMA_DECLARATION(kSCValNetPPPAuthProtocolPAP, __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/)) - #define kSCValNetPPPAuthProtocolPAP \ - SC_SCHEMA_KV(kSCValNetPPPAuthProtocolPAP \ - ,"PAP" \ - ,CFString ) - - SC_SCHEMA_DECLARATION(kSCPropNetPPPCommAlternateRemoteAddress, __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetPPPCommAlternateRemoteAddress \ - SC_SCHEMA_KV(kSCPropNetPPPCommAlternateRemoteAddress \ - ,"CommAlternateRemoteAddress" \ - ,CFString ) - - SC_SCHEMA_DECLARATION(kSCPropNetPPPCommConnectDelay, __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetPPPCommConnectDelay \ - SC_SCHEMA_KV(kSCPropNetPPPCommConnectDelay \ - ,"CommConnectDelay" \ - ,CFNumber ) - - SC_SCHEMA_DECLARATION(kSCPropNetPPPCommDisplayTerminalWindow, __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetPPPCommDisplayTerminalWindow \ - SC_SCHEMA_KV(kSCPropNetPPPCommDisplayTerminalWindow \ - ,"CommDisplayTerminalWindow" \ - ,CFNumber (0 or 1) ) - - SC_SCHEMA_DECLARATION(kSCPropNetPPPCommRedialCount, __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetPPPCommRedialCount \ - SC_SCHEMA_KV(kSCPropNetPPPCommRedialCount \ - ,"CommRedialCount" \ - ,CFNumber ) - - SC_SCHEMA_DECLARATION(kSCPropNetPPPCommRedialEnabled, __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetPPPCommRedialEnabled \ - SC_SCHEMA_KV(kSCPropNetPPPCommRedialEnabled \ - ,"CommRedialEnabled" \ - ,CFNumber (0 or 1) ) - - SC_SCHEMA_DECLARATION(kSCPropNetPPPCommRedialInterval, __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetPPPCommRedialInterval \ - SC_SCHEMA_KV(kSCPropNetPPPCommRedialInterval \ - ,"CommRedialInterval" \ - ,CFNumber ) - - SC_SCHEMA_DECLARATION(kSCPropNetPPPCommRemoteAddress, __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetPPPCommRemoteAddress \ - SC_SCHEMA_KV(kSCPropNetPPPCommRemoteAddress \ - ,"CommRemoteAddress" \ - ,CFString ) - - SC_SCHEMA_DECLARATION(kSCPropNetPPPCommTerminalScript, __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetPPPCommTerminalScript \ - SC_SCHEMA_KV(kSCPropNetPPPCommTerminalScript \ - ,"CommTerminalScript" \ - ,CFString ) - - SC_SCHEMA_DECLARATION(kSCPropNetPPPCommUseTerminalScript, __OSX_AVAILABLE_STARTING(__MAC_10_2,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetPPPCommUseTerminalScript \ - SC_SCHEMA_KV(kSCPropNetPPPCommUseTerminalScript \ - ,"CommUseTerminalScript" \ - ,CFNumber (0 or 1) ) - - SC_SCHEMA_DECLARATION(kSCPropNetPPPCCPEnabled, __OSX_AVAILABLE_STARTING(__MAC_10_2,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetPPPCCPEnabled \ - SC_SCHEMA_KV(kSCPropNetPPPCCPEnabled \ - ,"CCPEnabled" \ - ,CFNumber (0 or 1) ) - - SC_SCHEMA_DECLARATION(kSCPropNetPPPCCPMPPE40Enabled, __OSX_AVAILABLE_STARTING(__MAC_10_4,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetPPPCCPMPPE40Enabled \ - SC_SCHEMA_KV(kSCPropNetPPPCCPMPPE40Enabled \ - ,"CCPMPPE40Enabled" \ - ,CFNumber (0 or 1) ) - - SC_SCHEMA_DECLARATION(kSCPropNetPPPCCPMPPE128Enabled, __OSX_AVAILABLE_STARTING(__MAC_10_4,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetPPPCCPMPPE128Enabled \ - SC_SCHEMA_KV(kSCPropNetPPPCCPMPPE128Enabled \ - ,"CCPMPPE128Enabled" \ - ,CFNumber (0 or 1) ) - - SC_SCHEMA_DECLARATION(kSCPropNetPPPIPCPCompressionVJ, __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetPPPIPCPCompressionVJ \ - SC_SCHEMA_KV(kSCPropNetPPPIPCPCompressionVJ \ - ,"IPCPCompressionVJ" \ - ,CFNumber (0 or 1) ) - - SC_SCHEMA_DECLARATION(kSCPropNetPPPIPCPUsePeerDNS, __OSX_AVAILABLE_STARTING(__MAC_10_4,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetPPPIPCPUsePeerDNS \ - SC_SCHEMA_KV(kSCPropNetPPPIPCPUsePeerDNS \ - ,"IPCPUsePeerDNS" \ - ,CFNumber (0 or 1) ) - - SC_SCHEMA_DECLARATION(kSCPropNetPPPLCPEchoEnabled, __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetPPPLCPEchoEnabled \ - SC_SCHEMA_KV(kSCPropNetPPPLCPEchoEnabled \ - ,"LCPEchoEnabled" \ - ,CFNumber (0 or 1) ) - - SC_SCHEMA_DECLARATION(kSCPropNetPPPLCPEchoFailure, __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetPPPLCPEchoFailure \ - SC_SCHEMA_KV(kSCPropNetPPPLCPEchoFailure \ - ,"LCPEchoFailure" \ - ,CFNumber ) - - SC_SCHEMA_DECLARATION(kSCPropNetPPPLCPEchoInterval, __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetPPPLCPEchoInterval \ - SC_SCHEMA_KV(kSCPropNetPPPLCPEchoInterval \ - ,"LCPEchoInterval" \ - ,CFNumber ) - - SC_SCHEMA_DECLARATION(kSCPropNetPPPLCPCompressionACField, __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetPPPLCPCompressionACField \ - SC_SCHEMA_KV(kSCPropNetPPPLCPCompressionACField \ - ,"LCPCompressionACField" \ - ,CFNumber (0 or 1) ) - - SC_SCHEMA_DECLARATION(kSCPropNetPPPLCPCompressionPField, __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetPPPLCPCompressionPField \ - SC_SCHEMA_KV(kSCPropNetPPPLCPCompressionPField \ - ,"LCPCompressionPField" \ - ,CFNumber (0 or 1) ) - - SC_SCHEMA_DECLARATION(kSCPropNetPPPLCPMRU, __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetPPPLCPMRU \ - SC_SCHEMA_KV(kSCPropNetPPPLCPMRU \ - ,"LCPMRU" \ - ,CFNumber ) - - SC_SCHEMA_DECLARATION(kSCPropNetPPPLCPMTU, __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetPPPLCPMTU \ - SC_SCHEMA_KV(kSCPropNetPPPLCPMTU \ - ,"LCPMTU" \ - ,CFNumber ) - - SC_SCHEMA_DECLARATION(kSCPropNetPPPLCPReceiveACCM, __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetPPPLCPReceiveACCM \ - SC_SCHEMA_KV(kSCPropNetPPPLCPReceiveACCM \ - ,"LCPReceiveACCM" \ - ,CFNumber ) - - SC_SCHEMA_DECLARATION(kSCPropNetPPPLCPTransmitACCM, __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetPPPLCPTransmitACCM \ - SC_SCHEMA_KV(kSCPropNetPPPLCPTransmitACCM \ - ,"LCPTransmitACCM" \ - ,CFNumber ) - - SC_SCHEMA_DECLARATION(kSCPropNetL2TPIPSecSharedSecret, __OSX_AVAILABLE_STARTING(__MAC_10_3,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetL2TPIPSecSharedSecret \ - SC_SCHEMA_KV(kSCPropNetL2TPIPSecSharedSecret \ - ,"IPSecSharedSecret" \ - ,CFString ) - - SC_SCHEMA_DECLARATION(kSCPropNetL2TPIPSecSharedSecretEncryption, __OSX_AVAILABLE_STARTING(__MAC_10_3,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetL2TPIPSecSharedSecretEncryption \ - SC_SCHEMA_KV(kSCPropNetL2TPIPSecSharedSecretEncryption \ - ,"IPSecSharedSecretEncryption" \ - ,CFString ) - - SC_SCHEMA_DECLARATION(kSCPropNetL2TPTransport, __OSX_AVAILABLE_STARTING(__MAC_10_3,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetL2TPTransport \ - SC_SCHEMA_KV(kSCPropNetL2TPTransport \ - ,"Transport" \ - ,CFString ) - - SC_SCHEMA_DECLARATION(kSCValNetL2TPIPSecSharedSecretEncryptionKeychain, __OSX_AVAILABLE_STARTING(__MAC_10_3,__IPHONE_2_0/*SPI*/)) - #define kSCValNetL2TPIPSecSharedSecretEncryptionKeychain \ - SC_SCHEMA_KV(kSCValNetL2TPIPSecSharedSecretEncryptionKeychain \ - ,"Keychain" \ - , ) - - SC_SCHEMA_DECLARATION(kSCValNetL2TPTransportIP, __OSX_AVAILABLE_STARTING(__MAC_10_3,__IPHONE_2_0/*SPI*/)) - #define kSCValNetL2TPTransportIP \ - SC_SCHEMA_KV(kSCValNetL2TPTransportIP \ - ,"IP" \ - , ) - - SC_SCHEMA_DECLARATION(kSCValNetL2TPTransportIPSec, __OSX_AVAILABLE_STARTING(__MAC_10_3,__IPHONE_2_0/*SPI*/)) - #define kSCValNetL2TPTransportIPSec \ - SC_SCHEMA_KV(kSCValNetL2TPTransportIPSec \ - ,"IPSec" \ - , ) - - SC_SCHEMA_DECLARATION(kSCPropNetProxiesExceptionsList, __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetProxiesExceptionsList \ - SC_SCHEMA_KV(kSCPropNetProxiesExceptionsList \ - ,"ExceptionsList" \ - ,CFArray[CFString] ) - - SC_SCHEMA_DECLARATION(kSCPropNetProxiesExcludeSimpleHostnames, __OSX_AVAILABLE_STARTING(__MAC_10_4,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetProxiesExcludeSimpleHostnames \ - SC_SCHEMA_KV(kSCPropNetProxiesExcludeSimpleHostnames \ - ,"ExcludeSimpleHostnames" \ - ,CFNumber (0 or 1) ) - - SC_SCHEMA_DECLARATION(kSCPropNetProxiesFTPEnable, __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetProxiesFTPEnable \ - SC_SCHEMA_KV(kSCPropNetProxiesFTPEnable \ - ,"FTPEnable" \ - ,CFNumber (0 or 1) ) - - SC_SCHEMA_DECLARATION(kSCPropNetProxiesFTPPassive, __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetProxiesFTPPassive \ - SC_SCHEMA_KV(kSCPropNetProxiesFTPPassive \ - ,"FTPPassive" \ - ,CFNumber (0 or 1) ) - - SC_SCHEMA_DECLARATION(kSCPropNetProxiesFTPPort, __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetProxiesFTPPort \ - SC_SCHEMA_KV(kSCPropNetProxiesFTPPort \ - ,"FTPPort" \ - ,CFNumber ) - - SC_SCHEMA_DECLARATION(kSCPropNetProxiesFTPProxy, __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetProxiesFTPProxy \ - SC_SCHEMA_KV(kSCPropNetProxiesFTPProxy \ - ,"FTPProxy" \ - ,CFString ) - - SC_SCHEMA_DECLARATION(kSCPropNetProxiesGopherEnable, __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetProxiesGopherEnable \ - SC_SCHEMA_KV(kSCPropNetProxiesGopherEnable \ - ,"GopherEnable" \ - ,CFNumber (0 or 1) ) - - SC_SCHEMA_DECLARATION(kSCPropNetProxiesGopherPort, __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetProxiesGopherPort \ - SC_SCHEMA_KV(kSCPropNetProxiesGopherPort \ - ,"GopherPort" \ - ,CFNumber ) - - SC_SCHEMA_DECLARATION(kSCPropNetProxiesGopherProxy, __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetProxiesGopherProxy \ - SC_SCHEMA_KV(kSCPropNetProxiesGopherProxy \ - ,"GopherProxy" \ - ,CFString ) - - SC_SCHEMA_DECLARATION(kSCPropNetProxiesHTTPEnable, __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetProxiesHTTPEnable \ - SC_SCHEMA_KV(kSCPropNetProxiesHTTPEnable \ - ,"HTTPEnable" \ - ,CFNumber (0 or 1) ) - - SC_SCHEMA_DECLARATION(kSCPropNetProxiesHTTPPort, __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetProxiesHTTPPort \ - SC_SCHEMA_KV(kSCPropNetProxiesHTTPPort \ - ,"HTTPPort" \ - ,CFNumber ) - - SC_SCHEMA_DECLARATION(kSCPropNetProxiesHTTPProxy, __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetProxiesHTTPProxy \ - SC_SCHEMA_KV(kSCPropNetProxiesHTTPProxy \ - ,"HTTPProxy" \ - ,CFString ) - - SC_SCHEMA_DECLARATION(kSCPropNetProxiesHTTPSEnable, __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetProxiesHTTPSEnable \ - SC_SCHEMA_KV(kSCPropNetProxiesHTTPSEnable \ - ,"HTTPSEnable" \ - ,CFNumber (0 or 1) ) - - SC_SCHEMA_DECLARATION(kSCPropNetProxiesHTTPSPort, __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetProxiesHTTPSPort \ - SC_SCHEMA_KV(kSCPropNetProxiesHTTPSPort \ - ,"HTTPSPort" \ - ,CFNumber ) - - SC_SCHEMA_DECLARATION(kSCPropNetProxiesHTTPSProxy, __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetProxiesHTTPSProxy \ - SC_SCHEMA_KV(kSCPropNetProxiesHTTPSProxy \ - ,"HTTPSProxy" \ - ,CFString ) - - SC_SCHEMA_DECLARATION(kSCPropNetProxiesRTSPEnable, __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetProxiesRTSPEnable \ - SC_SCHEMA_KV(kSCPropNetProxiesRTSPEnable \ - ,"RTSPEnable" \ - ,CFNumber (0 or 1) ) - - SC_SCHEMA_DECLARATION(kSCPropNetProxiesRTSPPort, __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetProxiesRTSPPort \ - SC_SCHEMA_KV(kSCPropNetProxiesRTSPPort \ - ,"RTSPPort" \ - ,CFNumber ) - - SC_SCHEMA_DECLARATION(kSCPropNetProxiesRTSPProxy, __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetProxiesRTSPProxy \ - SC_SCHEMA_KV(kSCPropNetProxiesRTSPProxy \ - ,"RTSPProxy" \ - ,CFString ) - - SC_SCHEMA_DECLARATION(kSCPropNetProxiesSOCKSEnable, __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetProxiesSOCKSEnable \ - SC_SCHEMA_KV(kSCPropNetProxiesSOCKSEnable \ - ,"SOCKSEnable" \ - ,CFNumber (0 or 1) ) - - SC_SCHEMA_DECLARATION(kSCPropNetProxiesSOCKSPort, __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetProxiesSOCKSPort \ - SC_SCHEMA_KV(kSCPropNetProxiesSOCKSPort \ - ,"SOCKSPort" \ - ,CFNumber ) - - SC_SCHEMA_DECLARATION(kSCPropNetProxiesSOCKSProxy, __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetProxiesSOCKSProxy \ - SC_SCHEMA_KV(kSCPropNetProxiesSOCKSProxy \ - ,"SOCKSProxy" \ - ,CFString ) - - SC_SCHEMA_DECLARATION(kSCPropNetProxiesProxyAutoConfigEnable, __OSX_AVAILABLE_STARTING(__MAC_10_4,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetProxiesProxyAutoConfigEnable \ - SC_SCHEMA_KV(kSCPropNetProxiesProxyAutoConfigEnable \ - ,"ProxyAutoConfigEnable" \ - ,CFNumber (0 or 1) ) - - SC_SCHEMA_DECLARATION(kSCPropNetProxiesProxyAutoConfigJavaScript, __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_4_0/*SPI*/)) - #define kSCPropNetProxiesProxyAutoConfigJavaScript \ - SC_SCHEMA_KV(kSCPropNetProxiesProxyAutoConfigJavaScript \ - ,"ProxyAutoConfigJavaScript" \ - ,CFString ) - - SC_SCHEMA_DECLARATION(kSCPropNetProxiesProxyAutoConfigURLString, __OSX_AVAILABLE_STARTING(__MAC_10_4,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetProxiesProxyAutoConfigURLString \ - SC_SCHEMA_KV(kSCPropNetProxiesProxyAutoConfigURLString \ - ,"ProxyAutoConfigURLString" \ - ,CFString ) - - SC_SCHEMA_DECLARATION(kSCPropNetProxiesProxyAutoDiscoveryEnable, __OSX_AVAILABLE_STARTING(__MAC_10_4,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetProxiesProxyAutoDiscoveryEnable \ - SC_SCHEMA_KV(kSCPropNetProxiesProxyAutoDiscoveryEnable \ - ,"ProxyAutoDiscoveryEnable" \ - ,CFNumber (0 or 1) ) - -#if !TARGET_OS_IPHONE - - SC_SCHEMA_DECLARATION(kSCPropNetSMBNetBIOSName, __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetSMBNetBIOSName \ - SC_SCHEMA_KV(kSCPropNetSMBNetBIOSName \ - ,"NetBIOSName" \ - ,CFString ) - - SC_SCHEMA_DECLARATION(kSCPropNetSMBNetBIOSNodeType, __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetSMBNetBIOSNodeType \ - SC_SCHEMA_KV(kSCPropNetSMBNetBIOSNodeType \ - ,"NetBIOSNodeType" \ - ,CFString ) - - SC_SCHEMA_DECLARATION(kSCPropNetSMBNetBIOSScope, __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_5,__MAC_10_7,__IPHONE_NA,__IPHONE_NA)) - #define kSCPropNetSMBNetBIOSScope \ - SC_SCHEMA_KV(kSCPropNetSMBNetBIOSScope \ - ,"NetBIOSScope" \ - ,CFString ) - - SC_SCHEMA_DECLARATION(kSCPropNetSMBWINSAddresses, __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetSMBWINSAddresses \ - SC_SCHEMA_KV(kSCPropNetSMBWINSAddresses \ - ,"WINSAddresses" \ - ,CFArray[CFString] ) - - SC_SCHEMA_DECLARATION(kSCPropNetSMBWorkgroup, __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetSMBWorkgroup \ - SC_SCHEMA_KV(kSCPropNetSMBWorkgroup \ - ,"Workgroup" \ - ,CFString ) - - SC_SCHEMA_DECLARATION(kSCValNetSMBNetBIOSNodeTypeBroadcast, __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0/*SPI*/)) - #define kSCValNetSMBNetBIOSNodeTypeBroadcast \ - SC_SCHEMA_KV(kSCValNetSMBNetBIOSNodeTypeBroadcast \ - ,"Broadcast" \ - , ) - - SC_SCHEMA_DECLARATION(kSCValNetSMBNetBIOSNodeTypePeer, __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0/*SPI*/)) - #define kSCValNetSMBNetBIOSNodeTypePeer \ - SC_SCHEMA_KV(kSCValNetSMBNetBIOSNodeTypePeer \ - ,"Peer" \ - , ) - - SC_SCHEMA_DECLARATION(kSCValNetSMBNetBIOSNodeTypeMixed, __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0/*SPI*/)) - #define kSCValNetSMBNetBIOSNodeTypeMixed \ - SC_SCHEMA_KV(kSCValNetSMBNetBIOSNodeTypeMixed \ - ,"Mixed" \ - , ) - - SC_SCHEMA_DECLARATION(kSCValNetSMBNetBIOSNodeTypeHybrid, __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0/*SPI*/)) - #define kSCValNetSMBNetBIOSNodeTypeHybrid \ - SC_SCHEMA_KV(kSCValNetSMBNetBIOSNodeTypeHybrid \ - ,"Hybrid" \ - , ) - -#endif // !TARGET_OS_IPHONE - -#if !TARGET_OS_IPHONE - - SC_SCHEMA_DECLARATION(kSCEntUsersConsoleUser, __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/)) - #define kSCEntUsersConsoleUser \ - SC_SCHEMA_KV(kSCEntUsersConsoleUser \ - ,"ConsoleUser" \ - , ) - -#endif // !TARGET_OS_IPHONE - - SC_SCHEMA_DECLARATION(kSCPropSystemComputerName, __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/)) - #define kSCPropSystemComputerName \ - SC_SCHEMA_KV(kSCPropSystemComputerName \ - ,"ComputerName" \ - ,CFString ) - - SC_SCHEMA_DECLARATION(kSCPropSystemComputerNameEncoding, __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/)) - #define kSCPropSystemComputerNameEncoding \ - SC_SCHEMA_KV(kSCPropSystemComputerNameEncoding \ - ,"ComputerNameEncoding" \ - ,CFNumber ) - - SC_SCHEMA_DECLARATION(kSCDynamicStoreDomainFile, __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/)) - #define kSCDynamicStoreDomainFile \ - SC_SCHEMA_KV(kSCDynamicStoreDomainFile \ - ,"File:" \ - , ) - - SC_SCHEMA_DECLARATION(kSCDynamicStoreDomainPlugin, __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/)) - #define kSCDynamicStoreDomainPlugin \ - SC_SCHEMA_KV(kSCDynamicStoreDomainPlugin \ - ,"Plugin:" \ - , ) - - SC_SCHEMA_DECLARATION(kSCDynamicStoreDomainSetup, __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/)) - #define kSCDynamicStoreDomainSetup \ - SC_SCHEMA_KV(kSCDynamicStoreDomainSetup \ - ,"Setup:" \ - , ) - - SC_SCHEMA_DECLARATION(kSCDynamicStoreDomainState, __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/)) - #define kSCDynamicStoreDomainState \ - SC_SCHEMA_KV(kSCDynamicStoreDomainState \ - ,"State:" \ - , ) - - SC_SCHEMA_DECLARATION(kSCDynamicStoreDomainPrefs, __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/)) - #define kSCDynamicStoreDomainPrefs \ - SC_SCHEMA_KV(kSCDynamicStoreDomainPrefs \ - ,"Prefs:" \ - , ) - - SC_SCHEMA_DECLARATION(kSCDynamicStorePropSetupCurrentSet, __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/)) - #define kSCDynamicStorePropSetupCurrentSet \ - SC_SCHEMA_KV(kSCDynamicStorePropSetupCurrentSet \ - ,"CurrentSet" \ - ,CFString ) - - SC_SCHEMA_DECLARATION(kSCDynamicStorePropSetupLastUpdated, __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/)) - #define kSCDynamicStorePropSetupLastUpdated \ - SC_SCHEMA_KV(kSCDynamicStorePropSetupLastUpdated \ - ,"LastUpdated" \ - , ) - - SC_SCHEMA_DECLARATION(kSCDynamicStorePropNetInterfaces, __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/)) - #define kSCDynamicStorePropNetInterfaces \ - SC_SCHEMA_KV(kSCDynamicStorePropNetInterfaces \ - ,"Interfaces" \ - ,CFArray[CFString] ) - - SC_SCHEMA_DECLARATION(kSCDynamicStorePropNetPrimaryInterface, __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/)) - #define kSCDynamicStorePropNetPrimaryInterface \ - SC_SCHEMA_KV(kSCDynamicStorePropNetPrimaryInterface \ - ,"PrimaryInterface" \ - ,CFString ) - - SC_SCHEMA_DECLARATION(kSCDynamicStorePropNetPrimaryService, __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/)) - #define kSCDynamicStorePropNetPrimaryService \ - SC_SCHEMA_KV(kSCDynamicStorePropNetPrimaryService \ - ,"PrimaryService" \ - ,CFString ) - - SC_SCHEMA_DECLARATION(kSCDynamicStorePropNetServiceIDs, __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/)) - #define kSCDynamicStorePropNetServiceIDs \ - SC_SCHEMA_KV(kSCDynamicStorePropNetServiceIDs \ - ,"ServiceIDs" \ - ,CFArray[CFString] ) - -#if !TARGET_OS_IPHONE - - SC_SCHEMA_DECLARATION(kSCPropUsersConsoleUserName, __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1,__MAC_10_4,__IPHONE_NA,__IPHONE_NA)) - #define kSCPropUsersConsoleUserName \ - SC_SCHEMA_KV(kSCPropUsersConsoleUserName \ - ,"Name" \ - ,CFString ) - - SC_SCHEMA_DECLARATION(kSCPropUsersConsoleUserUID, __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1,__MAC_10_4,__IPHONE_NA,__IPHONE_NA)) - #define kSCPropUsersConsoleUserUID \ - SC_SCHEMA_KV(kSCPropUsersConsoleUserUID \ - ,"UID" \ - ,CFNumber ) - - SC_SCHEMA_DECLARATION(kSCPropUsersConsoleUserGID, __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1,__MAC_10_4,__IPHONE_NA,__IPHONE_NA)) - #define kSCPropUsersConsoleUserGID \ - SC_SCHEMA_KV(kSCPropUsersConsoleUserGID \ - ,"GID" \ - ,CFNumber ) - -#endif // !TARGET_OS_IPHONE +CF_ASSUME_NONNULL_END #endif /* USE_SYSTEMCONFIGURATION_PRIVATE_HEADERS */ #endif /* _SCSCHEMADEFINITIONS_H */ diff --git a/SystemConfiguration.fproj/SCSchemaDefinitionsPrivate.h b/SystemConfiguration.fproj/SCSchemaDefinitionsPrivate.h index f42980a..5e08fdd 100644 --- a/SystemConfiguration.fproj/SCSchemaDefinitionsPrivate.h +++ b/SystemConfiguration.fproj/SCSchemaDefinitionsPrivate.h @@ -1,15 +1,15 @@ /* - * Copyright (c) 2000-2014 Apple Inc. All rights reserved. + * Copyright (c) 2000-2015 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ - * + * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. - * + * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, @@ -17,7 +17,7 @@ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. - * + * * @APPLE_LICENSE_HEADER_END@ */ @@ -29,7 +29,9 @@ /* * Generic Keys * + * kSCPropNetIgnoreLinkStatus "IgnoreLinkStatus" CFBoolean * kSCPropConfirmedInterfaceName "ConfirmedInterfaceName" CFString + * kSCPropDisableUntilNeeded "DisableUntilNeeded" CFNumber (0 or 1) * * Preference Keys * @@ -51,10 +53,6 @@ * kSCEntNetService "__SERVICE__" CFDictionary * kSCEntNetVPN "VPN" CFDictionary * - * kSCCompNetwork Properties - * - * kSCPropNetIgnoreLinkStatus "IgnoreLinkStatus" CFBoolean - * * kSCEntNetCommCenter Entity Keys * * kSCPropNetCommCenterAllowNetworkAccess "AllowNetworkAccess" CFNumber (0 or 1) @@ -62,6 +60,7 @@ * * kSCEntNetDNS Entity Keys * + * kSCPropNetDNSConfirmedServiceID "ConfirmedServiceID" CFString * kSCPropNetDNSServiceIdentifier "ServiceIdentifier" CFNumber * kSCPropNetDNSSupplementalMatchDomainsNoSearch "SupplementalMatchDomainsNoSearch" CFNumber (0 or 1) * @@ -171,6 +170,7 @@ * kSCPropNetProxiesFallBackAllowed "FallBackAllowed" CFNumber (0 or 1) * kSCPropNetProxiesSupplementalMatchDomains "SupplementalMatchDomains" CFArray[CFString] * kSCPropNetProxiesSupplementalMatchOrders "SupplementalMatchOrders" CFArray[CFNumber] + * kSCPropNetProxiesServiceSpecific "ServiceSpecific" CFNumber (0 or 1) * * kSCPropNetProxiesScoped "__SCOPED__" CFDictionary * kSCPropNetProxiesServices "__SERVICES__" CFDictionary @@ -298,23 +298,32 @@ #ifndef _SCSCHEMADEFINITIONSPRIVATE_H #define _SCSCHEMADEFINITIONSPRIVATE_H -/* -------------------- Macro declarations -------------------- */ - #include -/* -------------------- HeaderDoc comments -------------------- */ - - -#if 0 /*! * @header SCSchemaDefinitionsPrivate */ +/*! + @const kSCPropNetIgnoreLinkStatus + @discussion Value is a CFBoolean + */ +extern const CFStringRef kSCPropNetIgnoreLinkStatus __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0/*SPI*/); +#define kSCPropNetIgnoreLinkStatus kSCPropNetIgnoreLinkStatus + /*! @const kSCPropConfirmedInterfaceName - @availability Introduced in Mac OS X 10.10. + @discussion Value is a CFString + */ +extern const CFStringRef kSCPropConfirmedInterfaceName __OSX_AVAILABLE_STARTING(__MAC_10_10,__IPHONE_8_0/*SPI*/); +#define kSCPropConfirmedInterfaceName kSCPropConfirmedInterfaceName + +/*! + @const kSCPropDisableUntilNeeded + @discussion Value is a CFNumber (0 or 1) */ -extern const CFStringRef kSCPropConfirmedInterfaceName; +extern const CFStringRef kSCPropDisableUntilNeeded __OSX_AVAILABLE_STARTING(__MAC_10_11,__IPHONE_9_0/*SPI*/); +#define kSCPropDisableUntilNeeded kSCPropDisableUntilNeeded /*! @group Preference Keys @@ -322,9 +331,10 @@ extern const CFStringRef kSCPropConfirmedInterfaceName; /*! @const kSCPrefVirtualNetworkInterfaces - @availability Introduced in Mac OS X 10.5. + @discussion Value is a CFDictionary */ -extern const CFStringRef kSCPrefVirtualNetworkInterfaces; +extern const CFStringRef kSCPrefVirtualNetworkInterfaces __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0/*SPI*/); +#define kSCPrefVirtualNetworkInterfaces kSCPrefVirtualNetworkInterfaces /*! @group Network Entity Keys @@ -332,91 +342,92 @@ extern const CFStringRef kSCPrefVirtualNetworkInterfaces; /*! @const kSCEntNetActiveDuringSleepRequested - @availability Introduced in Mac OS X 10.10. + @discussion Value is a CFDictionary */ -extern const CFStringRef kSCEntNetActiveDuringSleepRequested; +extern const CFStringRef kSCEntNetActiveDuringSleepRequested __OSX_AVAILABLE_STARTING(__MAC_10_10,__IPHONE_7_0/*SPI*/); +#define kSCEntNetActiveDuringSleepRequested kSCEntNetActiveDuringSleepRequested /*! @const kSCEntNetActiveDuringSleepSupported - @availability Introduced in Mac OS X 10.10. + @discussion Value is a CFDictionary */ -extern const CFStringRef kSCEntNetActiveDuringSleepSupported; +extern const CFStringRef kSCEntNetActiveDuringSleepSupported __OSX_AVAILABLE_STARTING(__MAC_10_10,__IPHONE_7_0/*SPI*/); +#define kSCEntNetActiveDuringSleepSupported kSCEntNetActiveDuringSleepSupported /*! @const kSCEntNetAppLayer - @availability Introduced in Mac OS X 10.9. + @discussion Value is a CFDictionary */ -extern const CFStringRef kSCEntNetAppLayer; +extern const CFStringRef kSCEntNetAppLayer __OSX_AVAILABLE_STARTING(__MAC_10_9,__IPHONE_7_0/*SPI*/); +#define kSCEntNetAppLayer kSCEntNetAppLayer /*! @const kSCEntNetCommCenter - @availability Introduced in iPhone OS 2.0. + @discussion Value is a CFDictionary */ -extern const CFStringRef kSCEntNetCommCenter; +extern const CFStringRef kSCEntNetCommCenter __OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_2_0/*SPI*/); +#define kSCEntNetCommCenter kSCEntNetCommCenter /*! @const kSCEntNetEAPOL - @availability Introduced in Mac OS X 10.5. + @discussion Value is a CFDictionary */ -extern const CFStringRef kSCEntNetEAPOL; +extern const CFStringRef kSCEntNetEAPOL __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0/*SPI*/); +#define kSCEntNetEAPOL kSCEntNetEAPOL /*! @const kSCEntNetIPv4RouterARPFailure - @availability Introduced in Mac OS X 10.10. */ -extern const CFStringRef kSCEntNetIPv4RouterARPFailure; +extern const CFStringRef kSCEntNetIPv4RouterARPFailure __OSX_AVAILABLE_STARTING(__MAC_10_10,__IPHONE_8_0/*SPI*/); +#define kSCEntNetIPv4RouterARPFailure kSCEntNetIPv4RouterARPFailure /*! @const kSCEntNetIPv4RouterARPAlive - @availability Introduced in Mac OS X 10.10. */ -extern const CFStringRef kSCEntNetIPv4RouterARPAlive; +extern const CFStringRef kSCEntNetIPv4RouterARPAlive __OSX_AVAILABLE_STARTING(__MAC_10_10,__IPHONE_8_0/*SPI*/); +#define kSCEntNetIPv4RouterARPAlive kSCEntNetIPv4RouterARPAlive /*! @const kSCEntNetLinkIssues - @availability Introduced in Mac OS X 10.9. + @discussion Value is a CFDictionary */ -extern const CFStringRef kSCEntNetLinkIssues; +extern const CFStringRef kSCEntNetLinkIssues __OSX_AVAILABLE_STARTING(__MAC_10_9,__IPHONE_7_0/*SPI*/); +#define kSCEntNetLinkIssues kSCEntNetLinkIssues /*! @const kSCEntNetLinkQuality - @availability Introduced in Mac OS X 10.7. + @discussion Value is a CFDictionary */ -extern const CFStringRef kSCEntNetLinkQuality; +extern const CFStringRef kSCEntNetLinkQuality __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_5_0/*SPI*/); +#define kSCEntNetLinkQuality kSCEntNetLinkQuality /*! @const kSCEntNetLoopback - @availability Introduced in Mac OS X 10.7. + @discussion Value is a CFDictionary */ -extern const CFStringRef kSCEntNetLoopback; +extern const CFStringRef kSCEntNetLoopback __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_4_0/*SPI*/); +#define kSCEntNetLoopback kSCEntNetLoopback /*! @const kSCEntNetOnDemand - @availability Introduced in Mac OS X 10.6. + @discussion Value is a CFDictionary */ -extern const CFStringRef kSCEntNetOnDemand; +extern const CFStringRef kSCEntNetOnDemand __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_3_0/*SPI*/); +#define kSCEntNetOnDemand kSCEntNetOnDemand /*! @const kSCEntNetService - @availability Introduced in Mac OS X 10.6. + @discussion Value is a CFDictionary */ -extern const CFStringRef kSCEntNetService; +extern const CFStringRef kSCEntNetService __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_2_0/*SPI*/); +#define kSCEntNetService kSCEntNetService /*! @const kSCEntNetVPN - @availability Introduced in Mac OS X 10.7. - */ -extern const CFStringRef kSCEntNetVPN; - -/*! - @group kSCCompNetwork Properties - */ - -/*! - @const kSCPropNetIgnoreLinkStatus - @availability Introduced in Mac OS X 10.5. + @discussion Value is a CFDictionary */ -extern const CFStringRef kSCPropNetIgnoreLinkStatus; +extern const CFStringRef kSCEntNetVPN __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_4_0/*SPI*/); +#define kSCEntNetVPN kSCEntNetVPN /*! @group kSCEntNetCommCenter Entity Keys @@ -424,31 +435,42 @@ extern const CFStringRef kSCPropNetIgnoreLinkStatus; /*! @const kSCPropNetCommCenterAllowNetworkAccess - @availability Introduced in iPhone OS 2.0. + @discussion Value is a CFNumber (0 or 1) */ -extern const CFStringRef kSCPropNetCommCenterAllowNetworkAccess; +extern const CFStringRef kSCPropNetCommCenterAllowNetworkAccess __OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_2_0/*SPI*/); +#define kSCPropNetCommCenterAllowNetworkAccess kSCPropNetCommCenterAllowNetworkAccess /*! @const kSCPropNetCommCenterAvailable - @availability Introduced in iPhone OS 2.0. + @discussion Value is a CFNumber (0 or 1) */ -extern const CFStringRef kSCPropNetCommCenterAvailable; +extern const CFStringRef kSCPropNetCommCenterAvailable __OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_2_0/*SPI*/); +#define kSCPropNetCommCenterAvailable kSCPropNetCommCenterAvailable /*! @group kSCEntNetDNS Entity Keys */ +/*! + @const kSCPropNetDNSConfirmedServiceID + @discussion Value is a CFString + */ +extern const CFStringRef kSCPropNetDNSConfirmedServiceID __OSX_AVAILABLE_STARTING(__MAC_10_11,__IPHONE_9_0/*SPI*/); +#define kSCPropNetDNSConfirmedServiceID kSCPropNetDNSConfirmedServiceID + /*! @const kSCPropNetDNSServiceIdentifier - @availability Introduced in Mac OS X 10.9. + @discussion Value is a CFNumber */ -extern const CFStringRef kSCPropNetDNSServiceIdentifier; +extern const CFStringRef kSCPropNetDNSServiceIdentifier __OSX_AVAILABLE_STARTING(__MAC_10_9,__IPHONE_7_0/*SPI*/); +#define kSCPropNetDNSServiceIdentifier kSCPropNetDNSServiceIdentifier /*! @const kSCPropNetDNSSupplementalMatchDomainsNoSearch - @availability Introduced in Mac OS X 10.9. + @discussion Value is a CFNumber (0 or 1) */ -extern const CFStringRef kSCPropNetDNSSupplementalMatchDomainsNoSearch; +extern const CFStringRef kSCPropNetDNSSupplementalMatchDomainsNoSearch __OSX_AVAILABLE_STARTING(__MAC_10_9,__IPHONE_7_0/*SPI*/); +#define kSCPropNetDNSSupplementalMatchDomainsNoSearch kSCPropNetDNSSupplementalMatchDomainsNoSearch /*! @group kSCEntNetEthernet (Hardware) Entity Keys @@ -456,63 +478,73 @@ extern const CFStringRef kSCPropNetDNSSupplementalMatchDomainsNoSearch; /*! @const kSCPropNetEthernetCapabilityAV - @availability Introduced in Mac OS X 10.7. + @discussion Value is a CFNumber (0 or 1) */ -extern const CFStringRef kSCPropNetEthernetCapabilityAV; +extern const CFStringRef kSCPropNetEthernetCapabilityAV __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_5_0/*SPI*/); +#define kSCPropNetEthernetCapabilityAV kSCPropNetEthernetCapabilityAV /*! @const kSCPropNetEthernetCapabilityJUMBO_MTU - @availability Introduced in Mac OS X 10.7. + @discussion Value is a CFNumber (0 or 1) */ -extern const CFStringRef kSCPropNetEthernetCapabilityJUMBO_MTU; +extern const CFStringRef kSCPropNetEthernetCapabilityJUMBO_MTU __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_5_0/*SPI*/); +#define kSCPropNetEthernetCapabilityJUMBO_MTU kSCPropNetEthernetCapabilityJUMBO_MTU /*! @const kSCPropNetEthernetCapabilityLRO - @availability Introduced in Mac OS X 10.7. + @discussion Value is a CFNumber (0 or 1) */ -extern const CFStringRef kSCPropNetEthernetCapabilityLRO; +extern const CFStringRef kSCPropNetEthernetCapabilityLRO __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_5_0/*SPI*/); +#define kSCPropNetEthernetCapabilityLRO kSCPropNetEthernetCapabilityLRO /*! @const kSCPropNetEthernetCapabilityRXCSUM - @availability Introduced in Mac OS X 10.7. + @discussion Value is a CFNumber (0 or 1) */ -extern const CFStringRef kSCPropNetEthernetCapabilityRXCSUM; +extern const CFStringRef kSCPropNetEthernetCapabilityRXCSUM __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_5_0/*SPI*/); +#define kSCPropNetEthernetCapabilityRXCSUM kSCPropNetEthernetCapabilityRXCSUM /*! @const kSCPropNetEthernetCapabilityTSO - @availability Introduced in Mac OS X 10.7. + @discussion Value is a CFNumber (0 or 1) */ -extern const CFStringRef kSCPropNetEthernetCapabilityTSO; +extern const CFStringRef kSCPropNetEthernetCapabilityTSO __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_5_0/*SPI*/); +#define kSCPropNetEthernetCapabilityTSO kSCPropNetEthernetCapabilityTSO /*! @const kSCPropNetEthernetCapabilityTSO4 - @availability Introduced in Mac OS X 10.7. + @discussion Value is a CFNumber (0 or 1) */ -extern const CFStringRef kSCPropNetEthernetCapabilityTSO4; +extern const CFStringRef kSCPropNetEthernetCapabilityTSO4 __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_5_0/*SPI*/); +#define kSCPropNetEthernetCapabilityTSO4 kSCPropNetEthernetCapabilityTSO4 /*! @const kSCPropNetEthernetCapabilityTSO6 - @availability Introduced in Mac OS X 10.7. + @discussion Value is a CFNumber (0 or 1) */ -extern const CFStringRef kSCPropNetEthernetCapabilityTSO6; +extern const CFStringRef kSCPropNetEthernetCapabilityTSO6 __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_5_0/*SPI*/); +#define kSCPropNetEthernetCapabilityTSO6 kSCPropNetEthernetCapabilityTSO6 /*! @const kSCPropNetEthernetCapabilityTXCSUM - @availability Introduced in Mac OS X 10.7. + @discussion Value is a CFNumber (0 or 1) */ -extern const CFStringRef kSCPropNetEthernetCapabilityTXCSUM; +extern const CFStringRef kSCPropNetEthernetCapabilityTXCSUM __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_5_0/*SPI*/); +#define kSCPropNetEthernetCapabilityTXCSUM kSCPropNetEthernetCapabilityTXCSUM /*! @const kSCPropNetEthernetCapabilityVLAN_HWTAGGING - @availability Introduced in Mac OS X 10.7. + @discussion Value is a CFNumber (0 or 1) */ -extern const CFStringRef kSCPropNetEthernetCapabilityVLAN_HWTAGGING; +extern const CFStringRef kSCPropNetEthernetCapabilityVLAN_HWTAGGING __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_5_0/*SPI*/); +#define kSCPropNetEthernetCapabilityVLAN_HWTAGGING kSCPropNetEthernetCapabilityVLAN_HWTAGGING /*! @const kSCPropNetEthernetCapabilityVLAN_MTU - @availability Introduced in Mac OS X 10.7. + @discussion Value is a CFNumber (0 or 1) */ -extern const CFStringRef kSCPropNetEthernetCapabilityVLAN_MTU; +extern const CFStringRef kSCPropNetEthernetCapabilityVLAN_MTU __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_5_0/*SPI*/); +#define kSCPropNetEthernetCapabilityVLAN_MTU kSCPropNetEthernetCapabilityVLAN_MTU /*! @group kSCEntNetInterface Entity Keys @@ -520,33 +552,35 @@ extern const CFStringRef kSCPropNetEthernetCapabilityVLAN_MTU; /*! @const kSCValNetInterfaceTypeCellular - @availability Introduced in Mac OS X 10.10. */ -extern const CFStringRef kSCValNetInterfaceTypeCellular; +extern const CFStringRef kSCValNetInterfaceTypeCellular __OSX_AVAILABLE_STARTING(__MAC_10_10,__IPHONE_8_0/*SPI*/); +#define kSCValNetInterfaceTypeCellular kSCValNetInterfaceTypeCellular /*! @const kSCValNetInterfaceTypeLoopback - @availability Introduced in Mac OS X 10.7. */ -extern const CFStringRef kSCValNetInterfaceTypeLoopback; +extern const CFStringRef kSCValNetInterfaceTypeLoopback __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_4_0/*SPI*/); +#define kSCValNetInterfaceTypeLoopback kSCValNetInterfaceTypeLoopback /*! @const kSCValNetInterfaceTypeVPN - @availability Introduced in Mac OS X 10.7. */ -extern const CFStringRef kSCValNetInterfaceTypeVPN; +extern const CFStringRef kSCValNetInterfaceTypeVPN __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_4_0/*SPI*/); +#define kSCValNetInterfaceTypeVPN kSCValNetInterfaceTypeVPN /*! @const kSCPropNetIPSecDisconnectOnWake - @availability Introduced in Mac OS X 10.9. + @discussion Value is a CFNumber (0 or 1) */ -extern const CFStringRef kSCPropNetIPSecDisconnectOnWake; +extern const CFStringRef kSCPropNetIPSecDisconnectOnWake __OSX_AVAILABLE_STARTING(__MAC_10_9,__IPHONE_7_0/*SPI*/); +#define kSCPropNetIPSecDisconnectOnWake kSCPropNetIPSecDisconnectOnWake /*! @const kSCPropNetIPSecDisconnectOnWakeTimer - @availability Introduced in Mac OS X 10.9. + @discussion Value is a CFNumber */ -extern const CFStringRef kSCPropNetIPSecDisconnectOnWakeTimer; +extern const CFStringRef kSCPropNetIPSecDisconnectOnWakeTimer __OSX_AVAILABLE_STARTING(__MAC_10_9,__IPHONE_7_0/*SPI*/); +#define kSCPropNetIPSecDisconnectOnWakeTimer kSCPropNetIPSecDisconnectOnWakeTimer /*! @group kSCEntNetIPSec Entity Keys @@ -554,33 +588,38 @@ extern const CFStringRef kSCPropNetIPSecDisconnectOnWakeTimer; /*! @const kSCPropNetIPSecLastCause - @availability Introduced in Mac OS X 10.6. + @discussion Value is a CFNumber */ -extern const CFStringRef kSCPropNetIPSecLastCause; +extern const CFStringRef kSCPropNetIPSecLastCause __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_3_0/*SPI*/); +#define kSCPropNetIPSecLastCause kSCPropNetIPSecLastCause /*! @const kSCPropNetIPSecOnDemandEnabled - @availability Introduced in Mac OS X 10.6. + @discussion Value is a CFNumber (0 or 1) */ -extern const CFStringRef kSCPropNetIPSecOnDemandEnabled; +extern const CFStringRef kSCPropNetIPSecOnDemandEnabled __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_3_0/*SPI*/); +#define kSCPropNetIPSecOnDemandEnabled kSCPropNetIPSecOnDemandEnabled /*! @const kSCPropNetIPSecOnDemandMatchDomainsAlways - @availability Introduced in Mac OS X 10.6. + @discussion Value is a CFArray[CFString] */ -extern const CFStringRef kSCPropNetIPSecOnDemandMatchDomainsAlways; +extern const CFStringRef kSCPropNetIPSecOnDemandMatchDomainsAlways __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_3_0/*SPI*/); +#define kSCPropNetIPSecOnDemandMatchDomainsAlways kSCPropNetIPSecOnDemandMatchDomainsAlways /*! @const kSCPropNetIPSecOnDemandMatchDomainsOnRetry - @availability Introduced in Mac OS X 10.6. + @discussion Value is a CFArray[CFString] */ -extern const CFStringRef kSCPropNetIPSecOnDemandMatchDomainsOnRetry; +extern const CFStringRef kSCPropNetIPSecOnDemandMatchDomainsOnRetry __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_3_0/*SPI*/); +#define kSCPropNetIPSecOnDemandMatchDomainsOnRetry kSCPropNetIPSecOnDemandMatchDomainsOnRetry /*! @const kSCPropNetIPSecOnDemandMatchDomainsNever - @availability Introduced in Mac OS X 10.6. + @discussion Value is a CFArray[CFString] */ -extern const CFStringRef kSCPropNetIPSecOnDemandMatchDomainsNever; +extern const CFStringRef kSCPropNetIPSecOnDemandMatchDomainsNever __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_3_0/*SPI*/); +#define kSCPropNetIPSecOnDemandMatchDomainsNever kSCPropNetIPSecOnDemandMatchDomainsNever /*! @group kSCEntNetIPv4 Entity Keys @@ -588,63 +627,72 @@ extern const CFStringRef kSCPropNetIPSecOnDemandMatchDomainsNever; /*! @const kSCPropNetIPv4AdditionalRoutes - @availability Introduced in Mac OS X 10.10. + @discussion Value is a CFArray[CFDictionary] */ -extern const CFStringRef kSCPropNetIPv4AdditionalRoutes; +extern const CFStringRef kSCPropNetIPv4AdditionalRoutes __OSX_AVAILABLE_STARTING(__MAC_10_10,__IPHONE_8_0/*SPI*/); +#define kSCPropNetIPv4AdditionalRoutes kSCPropNetIPv4AdditionalRoutes /*! @const kSCPropNetIPv4ExcludedRoutes - @availability Introduced in Mac OS X 10.7. + @discussion Value is a CFArray[CFDictionary] */ -extern const CFStringRef kSCPropNetIPv4ExcludedRoutes; +extern const CFStringRef kSCPropNetIPv4ExcludedRoutes __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_4_0/*SPI*/); +#define kSCPropNetIPv4ExcludedRoutes kSCPropNetIPv4ExcludedRoutes /*! @const kSCPropNetIPv4IncludedRoutes - @availability Introduced in Mac OS X 10.7. + @discussion Value is a CFArray[CFDictionary] */ -extern const CFStringRef kSCPropNetIPv4IncludedRoutes; +extern const CFStringRef kSCPropNetIPv4IncludedRoutes __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_4_0/*SPI*/); +#define kSCPropNetIPv4IncludedRoutes kSCPropNetIPv4IncludedRoutes /*! @const kSCValNetIPv4ConfigMethodFailover - @availability Introduced in Mac OS X 10.5. */ -extern const CFStringRef kSCValNetIPv4ConfigMethodFailover; +extern const CFStringRef kSCValNetIPv4ConfigMethodFailover __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0/*SPI*/); +#define kSCValNetIPv4ConfigMethodFailover kSCValNetIPv4ConfigMethodFailover /*! @const kSCPropNetIPv4RouteDestinationAddress - @availability Introduced in Mac OS X 10.7. + @discussion Value is a CFString */ -extern const CFStringRef kSCPropNetIPv4RouteDestinationAddress; +extern const CFStringRef kSCPropNetIPv4RouteDestinationAddress __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_4_0/*SPI*/); +#define kSCPropNetIPv4RouteDestinationAddress kSCPropNetIPv4RouteDestinationAddress /*! @const kSCPropNetIPv4RouteSubnetMask - @availability Introduced in Mac OS X 10.7. + @discussion Value is a CFString */ -extern const CFStringRef kSCPropNetIPv4RouteSubnetMask; +extern const CFStringRef kSCPropNetIPv4RouteSubnetMask __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_4_0/*SPI*/); +#define kSCPropNetIPv4RouteSubnetMask kSCPropNetIPv4RouteSubnetMask /*! @const kSCPropNetIPv4RouteGatewayAddress - @availability Introduced in Mac OS X 10.7. + @discussion Value is a CFString */ -extern const CFStringRef kSCPropNetIPv4RouteGatewayAddress; +extern const CFStringRef kSCPropNetIPv4RouteGatewayAddress __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_4_0/*SPI*/); +#define kSCPropNetIPv4RouteGatewayAddress kSCPropNetIPv4RouteGatewayAddress /*! @const kSCPropNetIPv4RouteInterfaceName - @availability Introduced in Mac OS X 10.10. + @discussion Value is a CFString */ -extern const CFStringRef kSCPropNetIPv4RouteInterfaceName; +extern const CFStringRef kSCPropNetIPv4RouteInterfaceName __OSX_AVAILABLE_STARTING(__MAC_10_10,__IPHONE_8_0/*SPI*/); +#define kSCPropNetIPv4RouteInterfaceName kSCPropNetIPv4RouteInterfaceName /*! @const kSCPropNetIPv4ARPResolvedHardwareAddress - @availability Introduced in Mac OS X 10.7. + @discussion Value is a CFString */ -extern const CFStringRef kSCPropNetIPv4ARPResolvedHardwareAddress; +extern const CFStringRef kSCPropNetIPv4ARPResolvedHardwareAddress __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_5_0/*SPI*/); +#define kSCPropNetIPv4ARPResolvedHardwareAddress kSCPropNetIPv4ARPResolvedHardwareAddress /*! @const kSCPropNetIPv4ARPResolvedIPAddress - @availability Introduced in Mac OS X 10.7. + @discussion Value is a CFString */ -extern const CFStringRef kSCPropNetIPv4ARPResolvedIPAddress; +extern const CFStringRef kSCPropNetIPv4ARPResolvedIPAddress __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_5_0/*SPI*/); +#define kSCPropNetIPv4ARPResolvedIPAddress kSCPropNetIPv4ARPResolvedIPAddress /*! @group kSCEntNetIPv6 Entity Keys @@ -652,45 +700,52 @@ extern const CFStringRef kSCPropNetIPv4ARPResolvedIPAddress; /*! @const kSCPropNetIPv6AdditionalRoutes - @availability Introduced in Mac OS X 10.10. + @discussion Value is a CFArray[CFDictionary] */ -extern const CFStringRef kSCPropNetIPv6AdditionalRoutes; +extern const CFStringRef kSCPropNetIPv6AdditionalRoutes __OSX_AVAILABLE_STARTING(__MAC_10_10,__IPHONE_8_0/*SPI*/); +#define kSCPropNetIPv6AdditionalRoutes kSCPropNetIPv6AdditionalRoutes /*! @const kSCPropNetIPv6ExcludedRoutes - @availability Introduced in Mac OS X 10.7. + @discussion Value is a CFArray[CFDictionary] */ -extern const CFStringRef kSCPropNetIPv6ExcludedRoutes; +extern const CFStringRef kSCPropNetIPv6ExcludedRoutes __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_4_0/*SPI*/); +#define kSCPropNetIPv6ExcludedRoutes kSCPropNetIPv6ExcludedRoutes /*! @const kSCPropNetIPv6IncludedRoutes - @availability Introduced in Mac OS X 10.7. + @discussion Value is a CFArray[CFDictionary] */ -extern const CFStringRef kSCPropNetIPv6IncludedRoutes; +extern const CFStringRef kSCPropNetIPv6IncludedRoutes __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_4_0/*SPI*/); +#define kSCPropNetIPv6IncludedRoutes kSCPropNetIPv6IncludedRoutes /*! @const kSCPropNetIPv6RouteDestinationAddress - @availability Introduced in Mac OS X 10.7. + @discussion Value is a CFString */ -extern const CFStringRef kSCPropNetIPv6RouteDestinationAddress; +extern const CFStringRef kSCPropNetIPv6RouteDestinationAddress __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_4_0/*SPI*/); +#define kSCPropNetIPv6RouteDestinationAddress kSCPropNetIPv6RouteDestinationAddress /*! @const kSCPropNetIPv6RoutePrefixLength - @availability Introduced in Mac OS X 10.7. + @discussion Value is a CFNumber */ -extern const CFStringRef kSCPropNetIPv6RoutePrefixLength; +extern const CFStringRef kSCPropNetIPv6RoutePrefixLength __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_4_0/*SPI*/); +#define kSCPropNetIPv6RoutePrefixLength kSCPropNetIPv6RoutePrefixLength /*! @const kSCPropNetIPv6RouteGatewayAddress - @availability Introduced in Mac OS X 10.7. + @discussion Value is a CFString */ -extern const CFStringRef kSCPropNetIPv6RouteGatewayAddress; +extern const CFStringRef kSCPropNetIPv6RouteGatewayAddress __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_4_0/*SPI*/); +#define kSCPropNetIPv6RouteGatewayAddress kSCPropNetIPv6RouteGatewayAddress /*! @const kSCPropNetIPv6RouteInterfaceName - @availability Introduced in Mac OS X 10.10. + @discussion Value is a CFString */ -extern const CFStringRef kSCPropNetIPv6RouteInterfaceName; +extern const CFStringRef kSCPropNetIPv6RouteInterfaceName __OSX_AVAILABLE_STARTING(__MAC_10_10,__IPHONE_8_0/*SPI*/); +#define kSCPropNetIPv6RouteInterfaceName kSCPropNetIPv6RouteInterfaceName /*! @group kSCEntNetLink Entity Keys @@ -698,9 +753,10 @@ extern const CFStringRef kSCPropNetIPv6RouteInterfaceName; /*! @const kSCPropNetLinkExpensive - @availability Introduced in Mac OS X 10.10. + @discussion Value is a CFBoolean */ -extern const CFStringRef kSCPropNetLinkExpensive; +extern const CFStringRef kSCPropNetLinkExpensive __OSX_AVAILABLE_STARTING(__MAC_10_10,__IPHONE_8_0/*SPI*/); +#define kSCPropNetLinkExpensive kSCPropNetLinkExpensive /*! @group kSCEntNetLinkIssues Entity Keys @@ -708,21 +764,24 @@ extern const CFStringRef kSCPropNetLinkExpensive; /*! @const kSCPropNetLinkIssuesModuleID - @availability Introduced in Mac OS X 10.9. + @discussion Value is a CFData */ -extern const CFStringRef kSCPropNetLinkIssuesModuleID; +extern const CFStringRef kSCPropNetLinkIssuesModuleID __OSX_AVAILABLE_STARTING(__MAC_10_9,__IPHONE_7_0/*SPI*/); +#define kSCPropNetLinkIssuesModuleID kSCPropNetLinkIssuesModuleID /*! @const kSCPropNetLinkIssuesInfo - @availability Introduced in Mac OS X 10.9. + @discussion Value is a CFData */ -extern const CFStringRef kSCPropNetLinkIssuesInfo; +extern const CFStringRef kSCPropNetLinkIssuesInfo __OSX_AVAILABLE_STARTING(__MAC_10_9,__IPHONE_7_0/*SPI*/); +#define kSCPropNetLinkIssuesInfo kSCPropNetLinkIssuesInfo /*! @const kSCPropNetLinkIssuesTimeStamp - @availability Introduced in Mac OS X 10.9. + @discussion Value is a CFDate */ -extern const CFStringRef kSCPropNetLinkIssuesTimeStamp; +extern const CFStringRef kSCPropNetLinkIssuesTimeStamp __OSX_AVAILABLE_STARTING(__MAC_10_9,__IPHONE_7_0/*SPI*/); +#define kSCPropNetLinkIssuesTimeStamp kSCPropNetLinkIssuesTimeStamp /*! @group kSCEntNetLinkQuality Entity Keys @@ -730,21 +789,24 @@ extern const CFStringRef kSCPropNetLinkIssuesTimeStamp; /*! @const kSCPropNetLinkQuality - @availability Introduced in Mac OS X 10.7. + @discussion Value is a CFNumber */ -extern const CFStringRef kSCPropNetLinkQuality; +extern const CFStringRef kSCPropNetLinkQuality __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_5_0/*SPI*/); +#define kSCPropNetLinkQuality kSCPropNetLinkQuality /*! @const kSCPropNetPPPDisconnectOnWake - @availability Introduced in Mac OS X 10.9. + @discussion Value is a CFNumber (0 or 1) */ -extern const CFStringRef kSCPropNetPPPDisconnectOnWake; +extern const CFStringRef kSCPropNetPPPDisconnectOnWake __OSX_AVAILABLE_STARTING(__MAC_10_9,__IPHONE_7_0/*SPI*/); +#define kSCPropNetPPPDisconnectOnWake kSCPropNetPPPDisconnectOnWake /*! @const kSCPropNetPPPDisconnectOnWakeTimer - @availability Introduced in Mac OS X 10.9. + @discussion Value is a CFNumber */ -extern const CFStringRef kSCPropNetPPPDisconnectOnWakeTimer; +extern const CFStringRef kSCPropNetPPPDisconnectOnWakeTimer __OSX_AVAILABLE_STARTING(__MAC_10_9,__IPHONE_7_0/*SPI*/); +#define kSCPropNetPPPDisconnectOnWakeTimer kSCPropNetPPPDisconnectOnWakeTimer /*! @group kSCEntNetPPP Entity Keys @@ -752,87 +814,95 @@ extern const CFStringRef kSCPropNetPPPDisconnectOnWakeTimer; /*! @const kSCPropNetPPPOnDemandDomains - @availability Introduced in Mac OS X 10.5. + @discussion Value is a CFArray[CFString] */ -extern const CFStringRef kSCPropNetPPPOnDemandDomains; +extern const CFStringRef kSCPropNetPPPOnDemandDomains __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0/*SPI*/); +#define kSCPropNetPPPOnDemandDomains kSCPropNetPPPOnDemandDomains /*! @const kSCPropNetPPPOnDemandEnabled - @availability Introduced in Mac OS X 10.5. + @discussion Value is a CFNumber (0 or 1) */ -extern const CFStringRef kSCPropNetPPPOnDemandEnabled; +extern const CFStringRef kSCPropNetPPPOnDemandEnabled __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0/*SPI*/); +#define kSCPropNetPPPOnDemandEnabled kSCPropNetPPPOnDemandEnabled /*! @const kSCPropNetPPPOnDemandHostName - @availability Introduced in Mac OS X 10.5. + @discussion Value is a CFString */ -extern const CFStringRef kSCPropNetPPPOnDemandHostName; +extern const CFStringRef kSCPropNetPPPOnDemandHostName __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0/*SPI*/); +#define kSCPropNetPPPOnDemandHostName kSCPropNetPPPOnDemandHostName /*! @const kSCPropNetPPPOnDemandMatchDomainsAlways - @availability Introduced in Mac OS X 10.7. + @discussion Value is a CFArray[CFString] */ -extern const CFStringRef kSCPropNetPPPOnDemandMatchDomainsAlways; +extern const CFStringRef kSCPropNetPPPOnDemandMatchDomainsAlways __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_5_0/*SPI*/); +#define kSCPropNetPPPOnDemandMatchDomainsAlways kSCPropNetPPPOnDemandMatchDomainsAlways /*! @const kSCPropNetPPPOnDemandMatchDomainsOnRetry - @availability Introduced in Mac OS X 10.7. + @discussion Value is a CFArray[CFString] */ -extern const CFStringRef kSCPropNetPPPOnDemandMatchDomainsOnRetry; +extern const CFStringRef kSCPropNetPPPOnDemandMatchDomainsOnRetry __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_5_0/*SPI*/); +#define kSCPropNetPPPOnDemandMatchDomainsOnRetry kSCPropNetPPPOnDemandMatchDomainsOnRetry /*! @const kSCPropNetPPPOnDemandMatchDomainsNever - @availability Introduced in Mac OS X 10.7. + @discussion Value is a CFArray[CFString] */ -extern const CFStringRef kSCPropNetPPPOnDemandMatchDomainsNever; +extern const CFStringRef kSCPropNetPPPOnDemandMatchDomainsNever __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_5_0/*SPI*/); +#define kSCPropNetPPPOnDemandMatchDomainsNever kSCPropNetPPPOnDemandMatchDomainsNever /*! @const kSCPropNetPPPOnDemandMode - @availability Introduced in Mac OS X 10.5. + @discussion Value is a CFString */ -extern const CFStringRef kSCPropNetPPPOnDemandMode; +extern const CFStringRef kSCPropNetPPPOnDemandMode __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0/*SPI*/); +#define kSCPropNetPPPOnDemandMode kSCPropNetPPPOnDemandMode /*! @const kSCPropNetPPPOnDemandPriority - @availability Introduced in Mac OS X 10.5. + @discussion Value is a CFString */ -extern const CFStringRef kSCPropNetPPPOnDemandPriority; +extern const CFStringRef kSCPropNetPPPOnDemandPriority __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0/*SPI*/); +#define kSCPropNetPPPOnDemandPriority kSCPropNetPPPOnDemandPriority /*! @const kSCValNetPPPOnDemandModeAggressive - @availability Introduced in Mac OS X 10.5. */ -extern const CFStringRef kSCValNetPPPOnDemandModeAggressive; +extern const CFStringRef kSCValNetPPPOnDemandModeAggressive __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0/*SPI*/); +#define kSCValNetPPPOnDemandModeAggressive kSCValNetPPPOnDemandModeAggressive /*! @const kSCValNetPPPOnDemandModeConservative - @availability Introduced in Mac OS X 10.5. */ -extern const CFStringRef kSCValNetPPPOnDemandModeConservative; +extern const CFStringRef kSCValNetPPPOnDemandModeConservative __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0/*SPI*/); +#define kSCValNetPPPOnDemandModeConservative kSCValNetPPPOnDemandModeConservative /*! @const kSCValNetPPPOnDemandModeCompatible - @availability Introduced in Mac OS X 10.5. */ -extern const CFStringRef kSCValNetPPPOnDemandModeCompatible; +extern const CFStringRef kSCValNetPPPOnDemandModeCompatible __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0/*SPI*/); +#define kSCValNetPPPOnDemandModeCompatible kSCValNetPPPOnDemandModeCompatible /*! @const kSCValNetPPPOnDemandPriorityDefault - @availability Introduced in Mac OS X 10.5. */ -extern const CFStringRef kSCValNetPPPOnDemandPriorityDefault; +extern const CFStringRef kSCValNetPPPOnDemandPriorityDefault __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0/*SPI*/); +#define kSCValNetPPPOnDemandPriorityDefault kSCValNetPPPOnDemandPriorityDefault /*! @const kSCValNetPPPOnDemandPriorityHigh - @availability Introduced in Mac OS X 10.5. */ -extern const CFStringRef kSCValNetPPPOnDemandPriorityHigh; +extern const CFStringRef kSCValNetPPPOnDemandPriorityHigh __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0/*SPI*/); +#define kSCValNetPPPOnDemandPriorityHigh kSCValNetPPPOnDemandPriorityHigh /*! @const kSCValNetPPPOnDemandPriorityLow - @availability Introduced in Mac OS X 10.5. */ -extern const CFStringRef kSCValNetPPPOnDemandPriorityLow; +extern const CFStringRef kSCValNetPPPOnDemandPriorityLow __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0/*SPI*/); +#define kSCValNetPPPOnDemandPriorityLow kSCValNetPPPOnDemandPriorityLow /*! @group kSCEntNetProxies Entity Keys @@ -840,51 +910,66 @@ extern const CFStringRef kSCValNetPPPOnDemandPriorityLow; /*! @const kSCPropNetProxiesBypassAllowed - @availability Introduced in Mac OS X 10.9. + @discussion Value is a CFNumber (0 or 1) */ -extern const CFStringRef kSCPropNetProxiesBypassAllowed; +extern const CFStringRef kSCPropNetProxiesBypassAllowed __OSX_AVAILABLE_STARTING(__MAC_10_9,__IPHONE_7_0/*SPI*/); +#define kSCPropNetProxiesBypassAllowed kSCPropNetProxiesBypassAllowed /*! @const kSCPropNetProxiesFallBackAllowed - @availability Introduced in Mac OS X 10.9. + @discussion Value is a CFNumber (0 or 1) */ -extern const CFStringRef kSCPropNetProxiesFallBackAllowed; +extern const CFStringRef kSCPropNetProxiesFallBackAllowed __OSX_AVAILABLE_STARTING(__MAC_10_9,__IPHONE_6_0/*SPI*/); +#define kSCPropNetProxiesFallBackAllowed kSCPropNetProxiesFallBackAllowed /*! @const kSCPropNetProxiesSupplementalMatchDomains - @availability Introduced in Mac OS X 10.7. + @discussion Value is a CFArray[CFString] */ -extern const CFStringRef kSCPropNetProxiesSupplementalMatchDomains; +extern const CFStringRef kSCPropNetProxiesSupplementalMatchDomains __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_5_0/*SPI*/); +#define kSCPropNetProxiesSupplementalMatchDomains kSCPropNetProxiesSupplementalMatchDomains /*! @const kSCPropNetProxiesSupplementalMatchOrders - @availability Introduced in Mac OS X 10.7. + @discussion Value is a CFArray[CFNumber] + */ +extern const CFStringRef kSCPropNetProxiesSupplementalMatchOrders __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_5_0/*SPI*/); +#define kSCPropNetProxiesSupplementalMatchOrders kSCPropNetProxiesSupplementalMatchOrders + +/*! + @const kSCPropNetProxiesServiceSpecific + @discussion Value is a CFNumber (0 or 1) */ -extern const CFStringRef kSCPropNetProxiesSupplementalMatchOrders; +extern const CFStringRef kSCPropNetProxiesServiceSpecific __OSX_AVAILABLE_STARTING(__MAC_10_11,__IPHONE_9_0/*SPI*/); +#define kSCPropNetProxiesServiceSpecific kSCPropNetProxiesServiceSpecific /*! @const kSCPropNetProxiesScoped - @availability Introduced in Mac OS X 10.7. + @discussion Value is a CFDictionary */ -extern const CFStringRef kSCPropNetProxiesScoped; +extern const CFStringRef kSCPropNetProxiesScoped __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_5_0/*SPI*/); +#define kSCPropNetProxiesScoped kSCPropNetProxiesScoped /*! @const kSCPropNetProxiesServices - @availability Introduced in Mac OS X 10.9. + @discussion Value is a CFDictionary */ -extern const CFStringRef kSCPropNetProxiesServices; +extern const CFStringRef kSCPropNetProxiesServices __OSX_AVAILABLE_STARTING(__MAC_10_9,__IPHONE_7_0/*SPI*/); +#define kSCPropNetProxiesServices kSCPropNetProxiesServices /*! @const kSCPropNetProxiesSupplemental - @availability Introduced in Mac OS X 10.7. + @discussion Value is a CFArray[CFDictionary] */ -extern const CFStringRef kSCPropNetProxiesSupplemental; +extern const CFStringRef kSCPropNetProxiesSupplemental __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_5_0/*SPI*/); +#define kSCPropNetProxiesSupplemental kSCPropNetProxiesSupplemental /*! @const kSCPropNetProxiesSupplementalMatchDomain - @availability Introduced in Mac OS X 10.7. + @discussion Value is a CFString */ -extern const CFStringRef kSCPropNetProxiesSupplementalMatchDomain; +extern const CFStringRef kSCPropNetProxiesSupplementalMatchDomain __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_5_0/*SPI*/); +#define kSCPropNetProxiesSupplementalMatchDomain kSCPropNetProxiesSupplementalMatchDomain /*! @group kSCEntNetService Entity Keys @@ -892,39 +977,41 @@ extern const CFStringRef kSCPropNetProxiesSupplementalMatchDomain; /*! @const kSCPropNetServicePrimaryRank - @availability Introduced in Mac OS X 10.6. + @discussion Value is a CFString */ -extern const CFStringRef kSCPropNetServicePrimaryRank; +extern const CFStringRef kSCPropNetServicePrimaryRank __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_2_0/*SPI*/); +#define kSCPropNetServicePrimaryRank kSCPropNetServicePrimaryRank /*! @const kSCPropNetServiceUserDefinedName - @availability Introduced in Mac OS X 10.6. + @discussion Value is a CFString */ -extern const CFStringRef kSCPropNetServiceUserDefinedName; +extern const CFStringRef kSCPropNetServiceUserDefinedName __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_2_0/*SPI*/); +#define kSCPropNetServiceUserDefinedName kSCPropNetServiceUserDefinedName /*! @const kSCValNetServicePrimaryRankFirst - @availability Introduced in Mac OS X 10.6. */ -extern const CFStringRef kSCValNetServicePrimaryRankFirst; +extern const CFStringRef kSCValNetServicePrimaryRankFirst __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_2_0/*SPI*/); +#define kSCValNetServicePrimaryRankFirst kSCValNetServicePrimaryRankFirst /*! @const kSCValNetServicePrimaryRankLast - @availability Introduced in Mac OS X 10.6. */ -extern const CFStringRef kSCValNetServicePrimaryRankLast; +extern const CFStringRef kSCValNetServicePrimaryRankLast __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_2_0/*SPI*/); +#define kSCValNetServicePrimaryRankLast kSCValNetServicePrimaryRankLast /*! @const kSCValNetServicePrimaryRankNever - @availability Introduced in Mac OS X 10.6. */ -extern const CFStringRef kSCValNetServicePrimaryRankNever; +extern const CFStringRef kSCValNetServicePrimaryRankNever __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_2_0/*SPI*/); +#define kSCValNetServicePrimaryRankNever kSCValNetServicePrimaryRankNever /*! @const kSCValNetServicePrimaryRankScoped - @availability Introduced in Mac OS X 10.10. */ -extern const CFStringRef kSCValNetServicePrimaryRankScoped; +extern const CFStringRef kSCValNetServicePrimaryRankScoped __OSX_AVAILABLE_STARTING(__MAC_10_10,__IPHONE_8_0/*SPI*/); +#define kSCValNetServicePrimaryRankScoped kSCValNetServicePrimaryRankScoped /*! @group kSCEntNetVPN Entity Keys @@ -932,387 +1019,434 @@ extern const CFStringRef kSCValNetServicePrimaryRankScoped; /*! @const kSCPropNetVPNAppRules - @availability Introduced in Mac OS X 10.9. + @discussion Value is a CFArray[CFDictionary] */ -extern const CFStringRef kSCPropNetVPNAppRules; +extern const CFStringRef kSCPropNetVPNAppRules __OSX_AVAILABLE_STARTING(__MAC_10_9,__IPHONE_7_0/*SPI*/); +#define kSCPropNetVPNAppRules kSCPropNetVPNAppRules /*! @const kSCPropNetVPNAuthCredentialPassword - @availability Introduced in Mac OS X 10.9. + @discussion Value is a CFString */ -extern const CFStringRef kSCPropNetVPNAuthCredentialPassword; +extern const CFStringRef kSCPropNetVPNAuthCredentialPassword __OSX_AVAILABLE_STARTING(__MAC_10_9,__IPHONE_7_0/*SPI*/); +#define kSCPropNetVPNAuthCredentialPassword kSCPropNetVPNAuthCredentialPassword /*! @const kSCPropNetVPNAuthName - @availability Introduced in Mac OS X 10.7. + @discussion Value is a CFString */ -extern const CFStringRef kSCPropNetVPNAuthName; +extern const CFStringRef kSCPropNetVPNAuthName __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_4_0/*SPI*/); +#define kSCPropNetVPNAuthName kSCPropNetVPNAuthName /*! @const kSCPropNetVPNAuthPassword - @availability Introduced in Mac OS X 10.7. + @discussion Value is a CFString */ -extern const CFStringRef kSCPropNetVPNAuthPassword; +extern const CFStringRef kSCPropNetVPNAuthPassword __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_4_0/*SPI*/); +#define kSCPropNetVPNAuthPassword kSCPropNetVPNAuthPassword /*! @const kSCPropNetVPNAuthPasswordEncryption - @availability Introduced in Mac OS X 10.7. + @discussion Value is a CFString */ -extern const CFStringRef kSCPropNetVPNAuthPasswordEncryption; +extern const CFStringRef kSCPropNetVPNAuthPasswordEncryption __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_4_0/*SPI*/); +#define kSCPropNetVPNAuthPasswordEncryption kSCPropNetVPNAuthPasswordEncryption /*! @const kSCPropNetVPNAuthPasswordPluginType - @availability Introduced in Mac OS X 10.9. + @discussion Value is a CFString */ -extern const CFStringRef kSCPropNetVPNAuthPasswordPluginType; +extern const CFStringRef kSCPropNetVPNAuthPasswordPluginType __OSX_AVAILABLE_STARTING(__MAC_10_9,__IPHONE_7_0/*SPI*/); +#define kSCPropNetVPNAuthPasswordPluginType kSCPropNetVPNAuthPasswordPluginType /*! @const kSCPropNetVPNAuthenticationMethod - @availability Introduced in Mac OS X 10.7. + @discussion Value is a CFString */ -extern const CFStringRef kSCPropNetVPNAuthenticationMethod; +extern const CFStringRef kSCPropNetVPNAuthenticationMethod __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_4_0/*SPI*/); +#define kSCPropNetVPNAuthenticationMethod kSCPropNetVPNAuthenticationMethod /*! @const kSCPropNetVPNConnectTime - @availability Introduced in Mac OS X 10.7. + @discussion Value is a CFString */ -extern const CFStringRef kSCPropNetVPNConnectTime; +extern const CFStringRef kSCPropNetVPNConnectTime __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_4_0/*SPI*/); +#define kSCPropNetVPNConnectTime kSCPropNetVPNConnectTime /*! @const kSCPropNetVPNDisconnectOnFastUserSwitch - @availability Introduced in Mac OS X 10.7. + @discussion Value is a CFNumber (0 or 1) */ -extern const CFStringRef kSCPropNetVPNDisconnectOnFastUserSwitch; +extern const CFStringRef kSCPropNetVPNDisconnectOnFastUserSwitch __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_4_0/*SPI*/); +#define kSCPropNetVPNDisconnectOnFastUserSwitch kSCPropNetVPNDisconnectOnFastUserSwitch /*! @const kSCPropNetVPNDisconnectOnIdle - @availability Introduced in Mac OS X 10.7. + @discussion Value is a CFNumber (0 or 1) */ -extern const CFStringRef kSCPropNetVPNDisconnectOnIdle; +extern const CFStringRef kSCPropNetVPNDisconnectOnIdle __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_4_0/*SPI*/); +#define kSCPropNetVPNDisconnectOnIdle kSCPropNetVPNDisconnectOnIdle /*! @const kSCPropNetVPNDisconnectOnIdleTimer - @availability Introduced in Mac OS X 10.7. + @discussion Value is a CFNumber */ -extern const CFStringRef kSCPropNetVPNDisconnectOnIdleTimer; +extern const CFStringRef kSCPropNetVPNDisconnectOnIdleTimer __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_4_0/*SPI*/); +#define kSCPropNetVPNDisconnectOnIdleTimer kSCPropNetVPNDisconnectOnIdleTimer /*! @const kSCPropNetVPNDisconnectOnLogout - @availability Introduced in Mac OS X 10.7. + @discussion Value is a CFNumber (0 or 1) */ -extern const CFStringRef kSCPropNetVPNDisconnectOnLogout; +extern const CFStringRef kSCPropNetVPNDisconnectOnLogout __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_4_0/*SPI*/); +#define kSCPropNetVPNDisconnectOnLogout kSCPropNetVPNDisconnectOnLogout /*! @const kSCPropNetVPNDisconnectOnSleep - @availability Introduced in Mac OS X 10.7. + @discussion Value is a CFNumber (0 or 1) */ -extern const CFStringRef kSCPropNetVPNDisconnectOnSleep; +extern const CFStringRef kSCPropNetVPNDisconnectOnSleep __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_4_0/*SPI*/); +#define kSCPropNetVPNDisconnectOnSleep kSCPropNetVPNDisconnectOnSleep /*! @const kSCPropNetVPNDisconnectOnWake - @availability Introduced in Mac OS X 10.9. + @discussion Value is a CFNumber (0 or 1) */ -extern const CFStringRef kSCPropNetVPNDisconnectOnWake; +extern const CFStringRef kSCPropNetVPNDisconnectOnWake __OSX_AVAILABLE_STARTING(__MAC_10_9,__IPHONE_7_0/*SPI*/); +#define kSCPropNetVPNDisconnectOnWake kSCPropNetVPNDisconnectOnWake /*! @const kSCPropNetVPNDisconnectOnWakeTimer - @availability Introduced in Mac OS X 10.9. + @discussion Value is a CFNumber */ -extern const CFStringRef kSCPropNetVPNDisconnectOnWakeTimer; +extern const CFStringRef kSCPropNetVPNDisconnectOnWakeTimer __OSX_AVAILABLE_STARTING(__MAC_10_9,__IPHONE_7_0/*SPI*/); +#define kSCPropNetVPNDisconnectOnWakeTimer kSCPropNetVPNDisconnectOnWakeTimer /*! @const kSCPropNetVPNLocalCertificate - @availability Introduced in Mac OS X 10.7. + @discussion Value is a CFData */ -extern const CFStringRef kSCPropNetVPNLocalCertificate; +extern const CFStringRef kSCPropNetVPNLocalCertificate __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_4_0/*SPI*/); +#define kSCPropNetVPNLocalCertificate kSCPropNetVPNLocalCertificate /*! @const kSCPropNetVPNLogfile - @availability Introduced in Mac OS X 10.7. + @discussion Value is a CFString */ -extern const CFStringRef kSCPropNetVPNLogfile; +extern const CFStringRef kSCPropNetVPNLogfile __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_4_0/*SPI*/); +#define kSCPropNetVPNLogfile kSCPropNetVPNLogfile /*! @const kSCPropNetVPNMTU - @availability Introduced in Mac OS X 10.7. + @discussion Value is a CFNumber */ -extern const CFStringRef kSCPropNetVPNMTU; +extern const CFStringRef kSCPropNetVPNMTU __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_4_0/*SPI*/); +#define kSCPropNetVPNMTU kSCPropNetVPNMTU /*! @const kSCPropNetVPNOnDemandEnabled - @availability Introduced in Mac OS X 10.7. + @discussion Value is a CFNumber (0 or 1) */ -extern const CFStringRef kSCPropNetVPNOnDemandEnabled; +extern const CFStringRef kSCPropNetVPNOnDemandEnabled __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_4_0/*SPI*/); +#define kSCPropNetVPNOnDemandEnabled kSCPropNetVPNOnDemandEnabled /*! @const kSCPropNetVPNOnDemandMatchAppEnabled - @availability Introduced in Mac OS X 10.9. + @discussion Value is a CFBoolean */ -extern const CFStringRef kSCPropNetVPNOnDemandMatchAppEnabled; +extern const CFStringRef kSCPropNetVPNOnDemandMatchAppEnabled __OSX_AVAILABLE_STARTING(__MAC_10_9,__IPHONE_7_0/*SPI*/); +#define kSCPropNetVPNOnDemandMatchAppEnabled kSCPropNetVPNOnDemandMatchAppEnabled /*! @const kSCPropNetVPNOnDemandMatchDomainsAlways - @availability Introduced in Mac OS X 10.7. + @discussion Value is a CFArray[CFString] */ -extern const CFStringRef kSCPropNetVPNOnDemandMatchDomainsAlways; +extern const CFStringRef kSCPropNetVPNOnDemandMatchDomainsAlways __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_4_0/*SPI*/); +#define kSCPropNetVPNOnDemandMatchDomainsAlways kSCPropNetVPNOnDemandMatchDomainsAlways /*! @const kSCPropNetVPNOnDemandMatchDomainsOnRetry - @availability Introduced in Mac OS X 10.7. + @discussion Value is a CFArray[CFString] */ -extern const CFStringRef kSCPropNetVPNOnDemandMatchDomainsOnRetry; +extern const CFStringRef kSCPropNetVPNOnDemandMatchDomainsOnRetry __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_4_0/*SPI*/); +#define kSCPropNetVPNOnDemandMatchDomainsOnRetry kSCPropNetVPNOnDemandMatchDomainsOnRetry /*! @const kSCPropNetVPNOnDemandMatchDomainsNever - @availability Introduced in Mac OS X 10.7. + @discussion Value is a CFArray[CFString] */ -extern const CFStringRef kSCPropNetVPNOnDemandMatchDomainsNever; +extern const CFStringRef kSCPropNetVPNOnDemandMatchDomainsNever __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_4_0/*SPI*/); +#define kSCPropNetVPNOnDemandMatchDomainsNever kSCPropNetVPNOnDemandMatchDomainsNever /*! @const kSCPropNetVPNOnDemandRules - @availability Introduced in Mac OS X 10.8. + @discussion Value is a CFArray[CFDictionary] */ -extern const CFStringRef kSCPropNetVPNOnDemandRules; +extern const CFStringRef kSCPropNetVPNOnDemandRules __OSX_AVAILABLE_STARTING(__MAC_10_8,__IPHONE_6_0/*SPI*/); +#define kSCPropNetVPNOnDemandRules kSCPropNetVPNOnDemandRules /*! @const kSCPropNetVPNOnDemandSuspended - @availability Introduced in Mac OS X 10.9. + @discussion Value is a CFNumber */ -extern const CFStringRef kSCPropNetVPNOnDemandSuspended; +extern const CFStringRef kSCPropNetVPNOnDemandSuspended __OSX_AVAILABLE_STARTING(__MAC_10_9,__IPHONE_7_0/*SPI*/); +#define kSCPropNetVPNOnDemandSuspended kSCPropNetVPNOnDemandSuspended /*! @const kSCPropNetVPNPluginCapability - @availability Introduced in Mac OS X 10.9. + @discussion Value is a CFString */ -extern const CFStringRef kSCPropNetVPNPluginCapability; +extern const CFStringRef kSCPropNetVPNPluginCapability __OSX_AVAILABLE_STARTING(__MAC_10_9,__IPHONE_7_0/*SPI*/); +#define kSCPropNetVPNPluginCapability kSCPropNetVPNPluginCapability /*! @const kSCPropNetVPNRemoteAddress - @availability Introduced in Mac OS X 10.7. + @discussion Value is a CFString */ -extern const CFStringRef kSCPropNetVPNRemoteAddress; +extern const CFStringRef kSCPropNetVPNRemoteAddress __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_4_0/*SPI*/); +#define kSCPropNetVPNRemoteAddress kSCPropNetVPNRemoteAddress /*! @const kSCPropNetVPNStatus - @availability Introduced in Mac OS X 10.7. + @discussion Value is a CFNumber */ -extern const CFStringRef kSCPropNetVPNStatus; +extern const CFStringRef kSCPropNetVPNStatus __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_4_0/*SPI*/); +#define kSCPropNetVPNStatus kSCPropNetVPNStatus /*! @const kSCPropNetVPNVerboseLogging - @availability Introduced in Mac OS X 10.7. + @discussion Value is a CFNumber (0 or 1) */ -extern const CFStringRef kSCPropNetVPNVerboseLogging; +extern const CFStringRef kSCPropNetVPNVerboseLogging __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_4_0/*SPI*/); +#define kSCPropNetVPNVerboseLogging kSCPropNetVPNVerboseLogging /*! @const kSCValNetVPNAppRuleAccountIdentifierMatch - @availability Introduced in Mac OS X 10.9. + @discussion Value is a CFArray[CFString] */ -extern const CFStringRef kSCValNetVPNAppRuleAccountIdentifierMatch; +extern const CFStringRef kSCValNetVPNAppRuleAccountIdentifierMatch __OSX_AVAILABLE_STARTING(__MAC_10_9,__IPHONE_7_0/*SPI*/); +#define kSCValNetVPNAppRuleAccountIdentifierMatch kSCValNetVPNAppRuleAccountIdentifierMatch /*! @const kSCValNetVPNAppRuleDNSDomainMatch - @availability Introduced in Mac OS X 10.9. + @discussion Value is a CFArray[CFString] */ -extern const CFStringRef kSCValNetVPNAppRuleDNSDomainMatch; +extern const CFStringRef kSCValNetVPNAppRuleDNSDomainMatch __OSX_AVAILABLE_STARTING(__MAC_10_9,__IPHONE_7_0/*SPI*/); +#define kSCValNetVPNAppRuleDNSDomainMatch kSCValNetVPNAppRuleDNSDomainMatch /*! @const kSCValNetVPNAppRuleExecutableMatch - @availability Introduced in Mac OS X 10.9. + @discussion Value is a CFArray[CFDictionary] */ -extern const CFStringRef kSCValNetVPNAppRuleExecutableMatch; +extern const CFStringRef kSCValNetVPNAppRuleExecutableMatch __OSX_AVAILABLE_STARTING(__MAC_10_9,__IPHONE_7_0/*SPI*/); +#define kSCValNetVPNAppRuleExecutableMatch kSCValNetVPNAppRuleExecutableMatch /*! @const kSCValNetVPNAppRuleIdentifier - @availability Introduced in Mac OS X 10.9. + @discussion Value is a CFString */ -extern const CFStringRef kSCValNetVPNAppRuleIdentifier; +extern const CFStringRef kSCValNetVPNAppRuleIdentifier __OSX_AVAILABLE_STARTING(__MAC_10_9,__IPHONE_7_0/*SPI*/); +#define kSCValNetVPNAppRuleIdentifier kSCValNetVPNAppRuleIdentifier /*! @const kSCValNetVPNAppRuleExecutableDesignatedRequirement - @availability Introduced in Mac OS X 10.9. + @discussion Value is a CFString */ -extern const CFStringRef kSCValNetVPNAppRuleExecutableDesignatedRequirement; +extern const CFStringRef kSCValNetVPNAppRuleExecutableDesignatedRequirement __OSX_AVAILABLE_STARTING(__MAC_10_9,__IPHONE_7_0/*SPI*/); +#define kSCValNetVPNAppRuleExecutableDesignatedRequirement kSCValNetVPNAppRuleExecutableDesignatedRequirement /*! @const kSCValNetVPNAppRuleExecutableSigningIdentifier - @availability Introduced in Mac OS X 10.9. + @discussion Value is a CFString */ -extern const CFStringRef kSCValNetVPNAppRuleExecutableSigningIdentifier; +extern const CFStringRef kSCValNetVPNAppRuleExecutableSigningIdentifier __OSX_AVAILABLE_STARTING(__MAC_10_9,__IPHONE_7_0/*SPI*/); +#define kSCValNetVPNAppRuleExecutableSigningIdentifier kSCValNetVPNAppRuleExecutableSigningIdentifier /*! @const kSCValNetVPNAppRuleExecutableUUID - @availability Introduced in Mac OS X 10.9. + @discussion Value is a CFString */ -extern const CFStringRef kSCValNetVPNAppRuleExecutableUUID; +extern const CFStringRef kSCValNetVPNAppRuleExecutableUUID __OSX_AVAILABLE_STARTING(__MAC_10_9,__IPHONE_7_0/*SPI*/); +#define kSCValNetVPNAppRuleExecutableUUID kSCValNetVPNAppRuleExecutableUUID /*! @const kSCValNetVPNAuthenticationMethodPassword - @availability Introduced in Mac OS X 10.7. */ -extern const CFStringRef kSCValNetVPNAuthenticationMethodPassword; +extern const CFStringRef kSCValNetVPNAuthenticationMethodPassword __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_4_0/*SPI*/); +#define kSCValNetVPNAuthenticationMethodPassword kSCValNetVPNAuthenticationMethodPassword /*! @const kSCValNetVPNAuthenticationMethodCertificate - @availability Introduced in Mac OS X 10.7. */ -extern const CFStringRef kSCValNetVPNAuthenticationMethodCertificate; +extern const CFStringRef kSCValNetVPNAuthenticationMethodCertificate __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_4_0/*SPI*/); +#define kSCValNetVPNAuthenticationMethodCertificate kSCValNetVPNAuthenticationMethodCertificate /*! @const kSCValNetVPNAuthPasswordEncryptionExternal - @availability Introduced in Mac OS X 10.9. */ -extern const CFStringRef kSCValNetVPNAuthPasswordEncryptionExternal; +extern const CFStringRef kSCValNetVPNAuthPasswordEncryptionExternal __OSX_AVAILABLE_STARTING(__MAC_10_9,__IPHONE_7_0/*SPI*/); +#define kSCValNetVPNAuthPasswordEncryptionExternal kSCValNetVPNAuthPasswordEncryptionExternal /*! @const kSCValNetVPNAuthPasswordEncryptionKeychain - @availability Introduced in Mac OS X 10.7. */ -extern const CFStringRef kSCValNetVPNAuthPasswordEncryptionKeychain; +extern const CFStringRef kSCValNetVPNAuthPasswordEncryptionKeychain __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_4_0/*SPI*/); +#define kSCValNetVPNAuthPasswordEncryptionKeychain kSCValNetVPNAuthPasswordEncryptionKeychain /*! @const kSCValNetVPNAuthPasswordEncryptionPrompt - @availability Introduced in Mac OS X 10.7. */ -extern const CFStringRef kSCValNetVPNAuthPasswordEncryptionPrompt; +extern const CFStringRef kSCValNetVPNAuthPasswordEncryptionPrompt __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_4_0/*SPI*/); +#define kSCValNetVPNAuthPasswordEncryptionPrompt kSCValNetVPNAuthPasswordEncryptionPrompt /*! @const kSCPropNetVPNOnDemandRuleAction - @availability Introduced in Mac OS X 10.8. + @discussion Value is a CFString */ -extern const CFStringRef kSCPropNetVPNOnDemandRuleAction; +extern const CFStringRef kSCPropNetVPNOnDemandRuleAction __OSX_AVAILABLE_STARTING(__MAC_10_8,__IPHONE_6_0/*SPI*/); +#define kSCPropNetVPNOnDemandRuleAction kSCPropNetVPNOnDemandRuleAction /*! @const kSCPropNetVPNOnDemandRuleActionParameters - @availability Introduced in Mac OS X 10.9. + @discussion Value is a CFArray[CFDictionary] */ -extern const CFStringRef kSCPropNetVPNOnDemandRuleActionParameters; +extern const CFStringRef kSCPropNetVPNOnDemandRuleActionParameters __OSX_AVAILABLE_STARTING(__MAC_10_9,__IPHONE_7_0/*SPI*/); +#define kSCPropNetVPNOnDemandRuleActionParameters kSCPropNetVPNOnDemandRuleActionParameters /*! @const kSCPropNetVPNOnDemandRuleDNSDomainMatch - @availability Introduced in Mac OS X 10.8. + @discussion Value is a CFArray[CFString] */ -extern const CFStringRef kSCPropNetVPNOnDemandRuleDNSDomainMatch; +extern const CFStringRef kSCPropNetVPNOnDemandRuleDNSDomainMatch __OSX_AVAILABLE_STARTING(__MAC_10_8,__IPHONE_6_0/*SPI*/); +#define kSCPropNetVPNOnDemandRuleDNSDomainMatch kSCPropNetVPNOnDemandRuleDNSDomainMatch /*! @const kSCPropNetVPNOnDemandRuleDNSServerAddressMatch - @availability Introduced in Mac OS X 10.8. + @discussion Value is a CFArray[CFString] */ -extern const CFStringRef kSCPropNetVPNOnDemandRuleDNSServerAddressMatch; +extern const CFStringRef kSCPropNetVPNOnDemandRuleDNSServerAddressMatch __OSX_AVAILABLE_STARTING(__MAC_10_8,__IPHONE_6_0/*SPI*/); +#define kSCPropNetVPNOnDemandRuleDNSServerAddressMatch kSCPropNetVPNOnDemandRuleDNSServerAddressMatch /*! @const kSCPropNetVPNOnDemandRuleSSIDMatch - @availability Introduced in Mac OS X 10.9. + @discussion Value is a CFArray[CFString] */ -extern const CFStringRef kSCPropNetVPNOnDemandRuleSSIDMatch; +extern const CFStringRef kSCPropNetVPNOnDemandRuleSSIDMatch __OSX_AVAILABLE_STARTING(__MAC_10_9,__IPHONE_7_0/*SPI*/); +#define kSCPropNetVPNOnDemandRuleSSIDMatch kSCPropNetVPNOnDemandRuleSSIDMatch /*! @const kSCPropNetVPNOnDemandRuleInterfaceTypeMatch - @availability Introduced in Mac OS X 10.9. + @discussion Value is a CFString */ -extern const CFStringRef kSCPropNetVPNOnDemandRuleInterfaceTypeMatch; +extern const CFStringRef kSCPropNetVPNOnDemandRuleInterfaceTypeMatch __OSX_AVAILABLE_STARTING(__MAC_10_9,__IPHONE_7_0/*SPI*/); +#define kSCPropNetVPNOnDemandRuleInterfaceTypeMatch kSCPropNetVPNOnDemandRuleInterfaceTypeMatch /*! @const kSCPropNetVPNOnDemandRuleURLStringProbe - @availability Introduced in Mac OS X 10.8. + @discussion Value is a CFString */ -extern const CFStringRef kSCPropNetVPNOnDemandRuleURLStringProbe; +extern const CFStringRef kSCPropNetVPNOnDemandRuleURLStringProbe __OSX_AVAILABLE_STARTING(__MAC_10_8,__IPHONE_6_0/*SPI*/); +#define kSCPropNetVPNOnDemandRuleURLStringProbe kSCPropNetVPNOnDemandRuleURLStringProbe /*! @const kSCValNetVPNOnDemandRuleActionAllow - @availability Introduced in Mac OS X 10.8. */ -extern const CFStringRef kSCValNetVPNOnDemandRuleActionAllow; +extern const CFStringRef kSCValNetVPNOnDemandRuleActionAllow __OSX_AVAILABLE_STARTING(__MAC_10_8,__IPHONE_6_0/*SPI*/); +#define kSCValNetVPNOnDemandRuleActionAllow kSCValNetVPNOnDemandRuleActionAllow /*! @const kSCValNetVPNOnDemandRuleActionIgnore - @availability Introduced in Mac OS X 10.8. */ -extern const CFStringRef kSCValNetVPNOnDemandRuleActionIgnore; +extern const CFStringRef kSCValNetVPNOnDemandRuleActionIgnore __OSX_AVAILABLE_STARTING(__MAC_10_8,__IPHONE_6_0/*SPI*/); +#define kSCValNetVPNOnDemandRuleActionIgnore kSCValNetVPNOnDemandRuleActionIgnore /*! @const kSCValNetVPNOnDemandRuleActionConnect - @availability Introduced in Mac OS X 10.8. */ -extern const CFStringRef kSCValNetVPNOnDemandRuleActionConnect; +extern const CFStringRef kSCValNetVPNOnDemandRuleActionConnect __OSX_AVAILABLE_STARTING(__MAC_10_8,__IPHONE_6_0/*SPI*/); +#define kSCValNetVPNOnDemandRuleActionConnect kSCValNetVPNOnDemandRuleActionConnect /*! @const kSCValNetVPNOnDemandRuleActionDisconnect - @availability Introduced in Mac OS X 10.8. */ -extern const CFStringRef kSCValNetVPNOnDemandRuleActionDisconnect; +extern const CFStringRef kSCValNetVPNOnDemandRuleActionDisconnect __OSX_AVAILABLE_STARTING(__MAC_10_8,__IPHONE_6_0/*SPI*/); +#define kSCValNetVPNOnDemandRuleActionDisconnect kSCValNetVPNOnDemandRuleActionDisconnect /*! @const kSCValNetVPNOnDemandRuleActionEvaluateConnection - @availability Introduced in Mac OS X 10.9. */ -extern const CFStringRef kSCValNetVPNOnDemandRuleActionEvaluateConnection; +extern const CFStringRef kSCValNetVPNOnDemandRuleActionEvaluateConnection __OSX_AVAILABLE_STARTING(__MAC_10_9,__IPHONE_7_0/*SPI*/); +#define kSCValNetVPNOnDemandRuleActionEvaluateConnection kSCValNetVPNOnDemandRuleActionEvaluateConnection /*! @const kSCPropNetVPNOnDemandRuleActionParametersDomainAction - @availability Introduced in Mac OS X 10.9. + @discussion Value is a CFString */ -extern const CFStringRef kSCPropNetVPNOnDemandRuleActionParametersDomainAction; +extern const CFStringRef kSCPropNetVPNOnDemandRuleActionParametersDomainAction __OSX_AVAILABLE_STARTING(__MAC_10_9,__IPHONE_7_0/*SPI*/); +#define kSCPropNetVPNOnDemandRuleActionParametersDomainAction kSCPropNetVPNOnDemandRuleActionParametersDomainAction /*! @const kSCPropNetVPNOnDemandRuleActionParametersDomains - @availability Introduced in Mac OS X 10.9. + @discussion Value is a CFArray[CFString] */ -extern const CFStringRef kSCPropNetVPNOnDemandRuleActionParametersDomains; +extern const CFStringRef kSCPropNetVPNOnDemandRuleActionParametersDomains __OSX_AVAILABLE_STARTING(__MAC_10_9,__IPHONE_7_0/*SPI*/); +#define kSCPropNetVPNOnDemandRuleActionParametersDomains kSCPropNetVPNOnDemandRuleActionParametersDomains /*! @const kSCPropNetVPNOnDemandRuleActionParametersRequiredDNSServers - @availability Introduced in Mac OS X 10.9. + @discussion Value is a CFArray[CFString] */ -extern const CFStringRef kSCPropNetVPNOnDemandRuleActionParametersRequiredDNSServers; +extern const CFStringRef kSCPropNetVPNOnDemandRuleActionParametersRequiredDNSServers __OSX_AVAILABLE_STARTING(__MAC_10_9,__IPHONE_7_0/*SPI*/); +#define kSCPropNetVPNOnDemandRuleActionParametersRequiredDNSServers kSCPropNetVPNOnDemandRuleActionParametersRequiredDNSServers /*! @const kSCPropNetVPNOnDemandRuleActionParametersRequiredURLStringProbe - @availability Introduced in Mac OS X 10.9. + @discussion Value is a CFString */ -extern const CFStringRef kSCPropNetVPNOnDemandRuleActionParametersRequiredURLStringProbe; +extern const CFStringRef kSCPropNetVPNOnDemandRuleActionParametersRequiredURLStringProbe __OSX_AVAILABLE_STARTING(__MAC_10_9,__IPHONE_7_0/*SPI*/); +#define kSCPropNetVPNOnDemandRuleActionParametersRequiredURLStringProbe kSCPropNetVPNOnDemandRuleActionParametersRequiredURLStringProbe /*! @const kSCValNetVPNOnDemandRuleActionParametersDomainActionConnectIfNeeded - @availability Introduced in Mac OS X 10.9. */ -extern const CFStringRef kSCValNetVPNOnDemandRuleActionParametersDomainActionConnectIfNeeded; +extern const CFStringRef kSCValNetVPNOnDemandRuleActionParametersDomainActionConnectIfNeeded __OSX_AVAILABLE_STARTING(__MAC_10_9,__IPHONE_7_0/*SPI*/); +#define kSCValNetVPNOnDemandRuleActionParametersDomainActionConnectIfNeeded kSCValNetVPNOnDemandRuleActionParametersDomainActionConnectIfNeeded /*! @const kSCValNetVPNOnDemandRuleActionParametersDomainActionNeverConnect - @availability Introduced in Mac OS X 10.9. */ -extern const CFStringRef kSCValNetVPNOnDemandRuleActionParametersDomainActionNeverConnect; +extern const CFStringRef kSCValNetVPNOnDemandRuleActionParametersDomainActionNeverConnect __OSX_AVAILABLE_STARTING(__MAC_10_9,__IPHONE_7_0/*SPI*/); +#define kSCValNetVPNOnDemandRuleActionParametersDomainActionNeverConnect kSCValNetVPNOnDemandRuleActionParametersDomainActionNeverConnect /*! @const kSCValNetVPNOnDemandRuleInterfaceTypeMatchCellular - @availability Introduced in Mac OS X 10.9. */ -extern const CFStringRef kSCValNetVPNOnDemandRuleInterfaceTypeMatchCellular; +extern const CFStringRef kSCValNetVPNOnDemandRuleInterfaceTypeMatchCellular __OSX_AVAILABLE_STARTING(__MAC_10_9,__IPHONE_7_0/*SPI*/); +#define kSCValNetVPNOnDemandRuleInterfaceTypeMatchCellular kSCValNetVPNOnDemandRuleInterfaceTypeMatchCellular /*! @const kSCValNetVPNOnDemandRuleInterfaceTypeMatchEthernet - @availability Introduced in Mac OS X 10.9. */ -extern const CFStringRef kSCValNetVPNOnDemandRuleInterfaceTypeMatchEthernet; +extern const CFStringRef kSCValNetVPNOnDemandRuleInterfaceTypeMatchEthernet __OSX_AVAILABLE_STARTING(__MAC_10_9,__IPHONE_7_0/*SPI*/); +#define kSCValNetVPNOnDemandRuleInterfaceTypeMatchEthernet kSCValNetVPNOnDemandRuleInterfaceTypeMatchEthernet /*! @const kSCValNetVPNOnDemandRuleInterfaceTypeMatchWiFi - @availability Introduced in Mac OS X 10.9. */ -extern const CFStringRef kSCValNetVPNOnDemandRuleInterfaceTypeMatchWiFi; +extern const CFStringRef kSCValNetVPNOnDemandRuleInterfaceTypeMatchWiFi __OSX_AVAILABLE_STARTING(__MAC_10_9,__IPHONE_7_0/*SPI*/); +#define kSCValNetVPNOnDemandRuleInterfaceTypeMatchWiFi kSCValNetVPNOnDemandRuleInterfaceTypeMatchWiFi /*! @const kSCValNetVPNPluginCapabilityAuth - @availability Introduced in Mac OS X 10.9. */ -extern const CFStringRef kSCValNetVPNPluginCapabilityAuth; +extern const CFStringRef kSCValNetVPNPluginCapabilityAuth __OSX_AVAILABLE_STARTING(__MAC_10_9,__IPHONE_7_0/*SPI*/); +#define kSCValNetVPNPluginCapabilityAuth kSCValNetVPNPluginCapabilityAuth /*! @const kSCValNetVPNPluginCapabilityConnect - @availability Introduced in Mac OS X 10.9. */ -extern const CFStringRef kSCValNetVPNPluginCapabilityConnect; +extern const CFStringRef kSCValNetVPNPluginCapabilityConnect __OSX_AVAILABLE_STARTING(__MAC_10_9,__IPHONE_7_0/*SPI*/); +#define kSCValNetVPNPluginCapabilityConnect kSCValNetVPNPluginCapabilityConnect /*! @group kSCCompSystem Properties @@ -1320,15 +1454,17 @@ extern const CFStringRef kSCValNetVPNPluginCapabilityConnect; /*! @const kSCPropSystemComputerNameRegion - @availability Introduced in Mac OS X 10.5. + @discussion Value is a CFNumber */ -extern const CFStringRef kSCPropSystemComputerNameRegion; +extern const CFStringRef kSCPropSystemComputerNameRegion __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0/*SPI*/); +#define kSCPropSystemComputerNameRegion kSCPropSystemComputerNameRegion /*! @const kSCPropSystemHostName - @availability Introduced in Mac OS X 10.5. + @discussion Value is a CFString */ -extern const CFStringRef kSCPropSystemHostName; +extern const CFStringRef kSCPropSystemHostName __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0/*SPI*/); +#define kSCPropSystemHostName kSCPropSystemHostName /*! @group Virtual Network Interface Keys @@ -1336,1026 +1472,59 @@ extern const CFStringRef kSCPropSystemHostName; /*! @const kSCPropVirtualNetworkInterfacesBondInterfaces - @availability Introduced in Mac OS X 10.5. + @discussion Value is a CFArray[CFString] */ -extern const CFStringRef kSCPropVirtualNetworkInterfacesBondInterfaces; +extern const CFStringRef kSCPropVirtualNetworkInterfacesBondInterfaces __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0/*SPI*/); +#define kSCPropVirtualNetworkInterfacesBondInterfaces kSCPropVirtualNetworkInterfacesBondInterfaces /*! @const kSCPropVirtualNetworkInterfacesBondMode - @availability Introduced in Mac OS X 10.5. + @discussion Value is a CFNumber */ -extern const CFStringRef kSCPropVirtualNetworkInterfacesBondMode; +extern const CFStringRef kSCPropVirtualNetworkInterfacesBondMode __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0/*SPI*/); +#define kSCPropVirtualNetworkInterfacesBondMode kSCPropVirtualNetworkInterfacesBondMode /*! @const kSCPropVirtualNetworkInterfacesBondOptions - @availability Introduced in Mac OS X 10.5. + @discussion Value is a CFDictionary */ -extern const CFStringRef kSCPropVirtualNetworkInterfacesBondOptions; +extern const CFStringRef kSCPropVirtualNetworkInterfacesBondOptions __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0/*SPI*/); +#define kSCPropVirtualNetworkInterfacesBondOptions kSCPropVirtualNetworkInterfacesBondOptions /*! @const kSCPropVirtualNetworkInterfacesBridgeInterfaces - @availability Introduced in Mac OS X 10.7. + @discussion Value is a CFArray[CFString] */ -extern const CFStringRef kSCPropVirtualNetworkInterfacesBridgeInterfaces; +extern const CFStringRef kSCPropVirtualNetworkInterfacesBridgeInterfaces __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_4_0/*SPI*/); +#define kSCPropVirtualNetworkInterfacesBridgeInterfaces kSCPropVirtualNetworkInterfacesBridgeInterfaces /*! @const kSCPropVirtualNetworkInterfacesBridgeOptions - @availability Introduced in Mac OS X 10.7. + @discussion Value is a CFDictionary */ -extern const CFStringRef kSCPropVirtualNetworkInterfacesBridgeOptions; +extern const CFStringRef kSCPropVirtualNetworkInterfacesBridgeOptions __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_4_0/*SPI*/); +#define kSCPropVirtualNetworkInterfacesBridgeOptions kSCPropVirtualNetworkInterfacesBridgeOptions /*! @const kSCPropVirtualNetworkInterfacesVLANInterface - @availability Introduced in Mac OS X 10.5. + @discussion Value is a CFString */ -extern const CFStringRef kSCPropVirtualNetworkInterfacesVLANInterface; +extern const CFStringRef kSCPropVirtualNetworkInterfacesVLANInterface __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0/*SPI*/); +#define kSCPropVirtualNetworkInterfacesVLANInterface kSCPropVirtualNetworkInterfacesVLANInterface /*! @const kSCPropVirtualNetworkInterfacesVLANTag - @availability Introduced in Mac OS X 10.5. + @discussion Value is a CFNumber */ -extern const CFStringRef kSCPropVirtualNetworkInterfacesVLANTag; +extern const CFStringRef kSCPropVirtualNetworkInterfacesVLANTag __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0/*SPI*/); +#define kSCPropVirtualNetworkInterfacesVLANTag kSCPropVirtualNetworkInterfacesVLANTag /*! @const kSCPropVirtualNetworkInterfacesVLANOptions - @availability Introduced in Mac OS X 10.5. - */ -extern const CFStringRef kSCPropVirtualNetworkInterfacesVLANOptions; - -#endif /* 0 */ - - -/* -------------------- Schema declarations -------------------- */ - - - SC_SCHEMA_DECLARATION(kSCPropConfirmedInterfaceName, __OSX_AVAILABLE_STARTING(__MAC_10_10,__IPHONE_8_0/*SPI*/)) - #define kSCPropConfirmedInterfaceName \ - SC_SCHEMA_KV(kSCPropConfirmedInterfaceName \ - ,"ConfirmedInterfaceName" \ - ,CFString ) - - SC_SCHEMA_DECLARATION(kSCPrefVirtualNetworkInterfaces, __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0/*SPI*/)) - #define kSCPrefVirtualNetworkInterfaces \ - SC_SCHEMA_KV(kSCPrefVirtualNetworkInterfaces \ - ,"VirtualNetworkInterfaces" \ - ,CFDictionary ) - - SC_SCHEMA_DECLARATION(kSCEntNetActiveDuringSleepRequested, __OSX_AVAILABLE_STARTING(__MAC_10_10,__IPHONE_7_0/*SPI*/)) - #define kSCEntNetActiveDuringSleepRequested \ - SC_SCHEMA_KV(kSCEntNetActiveDuringSleepRequested \ - ,"ActiveDuringSleepRequested" \ - ,CFDictionary ) - - SC_SCHEMA_DECLARATION(kSCEntNetActiveDuringSleepSupported, __OSX_AVAILABLE_STARTING(__MAC_10_10,__IPHONE_7_0/*SPI*/)) - #define kSCEntNetActiveDuringSleepSupported \ - SC_SCHEMA_KV(kSCEntNetActiveDuringSleepSupported \ - ,"ActiveDuringSleepSupported" \ - ,CFDictionary ) - - SC_SCHEMA_DECLARATION(kSCEntNetAppLayer, __OSX_AVAILABLE_STARTING(__MAC_10_9,__IPHONE_7_0/*SPI*/)) - #define kSCEntNetAppLayer \ - SC_SCHEMA_KV(kSCEntNetAppLayer \ - ,"AppLayer" \ - ,CFDictionary ) - - - SC_SCHEMA_DECLARATION(kSCEntNetEAPOL, __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0/*SPI*/)) - #define kSCEntNetEAPOL \ - SC_SCHEMA_KV(kSCEntNetEAPOL \ - ,"EAPOL" \ - ,CFDictionary ) - - SC_SCHEMA_DECLARATION(kSCEntNetIPv4RouterARPFailure, __OSX_AVAILABLE_STARTING(__MAC_10_10,__IPHONE_8_0/*SPI*/)) - #define kSCEntNetIPv4RouterARPFailure \ - SC_SCHEMA_KV(kSCEntNetIPv4RouterARPFailure \ - ,"IPv4RouterARPFailure" \ - , ) - - SC_SCHEMA_DECLARATION(kSCEntNetIPv4RouterARPAlive, __OSX_AVAILABLE_STARTING(__MAC_10_10,__IPHONE_8_0/*SPI*/)) - #define kSCEntNetIPv4RouterARPAlive \ - SC_SCHEMA_KV(kSCEntNetIPv4RouterARPAlive \ - ,"IPv4RouterARPAlive" \ - , ) - - SC_SCHEMA_DECLARATION(kSCEntNetLinkIssues, __OSX_AVAILABLE_STARTING(__MAC_10_9,__IPHONE_7_0/*SPI*/)) - #define kSCEntNetLinkIssues \ - SC_SCHEMA_KV(kSCEntNetLinkIssues \ - ,"LinkIssues" \ - ,CFDictionary ) - - SC_SCHEMA_DECLARATION(kSCEntNetLinkQuality, __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_5_0/*SPI*/)) - #define kSCEntNetLinkQuality \ - SC_SCHEMA_KV(kSCEntNetLinkQuality \ - ,"LinkQuality" \ - ,CFDictionary ) - - SC_SCHEMA_DECLARATION(kSCEntNetLoopback, __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_4_0/*SPI*/)) - #define kSCEntNetLoopback \ - SC_SCHEMA_KV(kSCEntNetLoopback \ - ,"Loopback" \ - ,CFDictionary ) - - SC_SCHEMA_DECLARATION(kSCEntNetOnDemand, __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_3_0/*SPI*/)) - #define kSCEntNetOnDemand \ - SC_SCHEMA_KV(kSCEntNetOnDemand \ - ,"OnDemand" \ - ,CFDictionary ) - - SC_SCHEMA_DECLARATION(kSCEntNetService, __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_2_0/*SPI*/)) - #define kSCEntNetService \ - SC_SCHEMA_KV(kSCEntNetService \ - ,"__SERVICE__" \ - ,CFDictionary ) - - SC_SCHEMA_DECLARATION(kSCEntNetVPN, __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_4_0/*SPI*/)) - #define kSCEntNetVPN \ - SC_SCHEMA_KV(kSCEntNetVPN \ - ,"VPN" \ - ,CFDictionary ) - - SC_SCHEMA_DECLARATION(kSCPropNetIgnoreLinkStatus, __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetIgnoreLinkStatus \ - SC_SCHEMA_KV(kSCPropNetIgnoreLinkStatus \ - ,"IgnoreLinkStatus" \ - ,CFBoolean ) - - - SC_SCHEMA_DECLARATION(kSCPropNetDNSServiceIdentifier, __OSX_AVAILABLE_STARTING(__MAC_10_9,__IPHONE_7_0/*SPI*/)) - #define kSCPropNetDNSServiceIdentifier \ - SC_SCHEMA_KV(kSCPropNetDNSServiceIdentifier \ - ,"ServiceIdentifier" \ - ,CFNumber ) - - SC_SCHEMA_DECLARATION(kSCPropNetDNSSupplementalMatchDomainsNoSearch, __OSX_AVAILABLE_STARTING(__MAC_10_9,__IPHONE_7_0/*SPI*/)) - #define kSCPropNetDNSSupplementalMatchDomainsNoSearch \ - SC_SCHEMA_KV(kSCPropNetDNSSupplementalMatchDomainsNoSearch \ - ,"SupplementalMatchDomainsNoSearch" \ - ,CFNumber (0 or 1) ) - - SC_SCHEMA_DECLARATION(kSCPropNetEthernetCapabilityAV, __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_5_0/*SPI*/)) - #define kSCPropNetEthernetCapabilityAV \ - SC_SCHEMA_KV(kSCPropNetEthernetCapabilityAV \ - ,"AV" \ - ,CFNumber (0 or 1) ) - - SC_SCHEMA_DECLARATION(kSCPropNetEthernetCapabilityJUMBO_MTU, __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_5_0/*SPI*/)) - #define kSCPropNetEthernetCapabilityJUMBO_MTU \ - SC_SCHEMA_KV(kSCPropNetEthernetCapabilityJUMBO_MTU \ - ,"JUMBO_MTU" \ - ,CFNumber (0 or 1) ) - - SC_SCHEMA_DECLARATION(kSCPropNetEthernetCapabilityLRO, __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_5_0/*SPI*/)) - #define kSCPropNetEthernetCapabilityLRO \ - SC_SCHEMA_KV(kSCPropNetEthernetCapabilityLRO \ - ,"LRO" \ - ,CFNumber (0 or 1) ) - - SC_SCHEMA_DECLARATION(kSCPropNetEthernetCapabilityRXCSUM, __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_5_0/*SPI*/)) - #define kSCPropNetEthernetCapabilityRXCSUM \ - SC_SCHEMA_KV(kSCPropNetEthernetCapabilityRXCSUM \ - ,"RXCSUM" \ - ,CFNumber (0 or 1) ) - - SC_SCHEMA_DECLARATION(kSCPropNetEthernetCapabilityTSO, __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_5_0/*SPI*/)) - #define kSCPropNetEthernetCapabilityTSO \ - SC_SCHEMA_KV(kSCPropNetEthernetCapabilityTSO \ - ,"TSO" \ - ,CFNumber (0 or 1) ) - - SC_SCHEMA_DECLARATION(kSCPropNetEthernetCapabilityTSO4, __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_5_0/*SPI*/)) - #define kSCPropNetEthernetCapabilityTSO4 \ - SC_SCHEMA_KV(kSCPropNetEthernetCapabilityTSO4 \ - ,"TSO4" \ - ,CFNumber (0 or 1) ) - - SC_SCHEMA_DECLARATION(kSCPropNetEthernetCapabilityTSO6, __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_5_0/*SPI*/)) - #define kSCPropNetEthernetCapabilityTSO6 \ - SC_SCHEMA_KV(kSCPropNetEthernetCapabilityTSO6 \ - ,"TSO6" \ - ,CFNumber (0 or 1) ) - - SC_SCHEMA_DECLARATION(kSCPropNetEthernetCapabilityTXCSUM, __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_5_0/*SPI*/)) - #define kSCPropNetEthernetCapabilityTXCSUM \ - SC_SCHEMA_KV(kSCPropNetEthernetCapabilityTXCSUM \ - ,"TXCSUM" \ - ,CFNumber (0 or 1) ) - - SC_SCHEMA_DECLARATION(kSCPropNetEthernetCapabilityVLAN_HWTAGGING, __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_5_0/*SPI*/)) - #define kSCPropNetEthernetCapabilityVLAN_HWTAGGING \ - SC_SCHEMA_KV(kSCPropNetEthernetCapabilityVLAN_HWTAGGING \ - ,"VLAN_HWTAGGING" \ - ,CFNumber (0 or 1) ) - - SC_SCHEMA_DECLARATION(kSCPropNetEthernetCapabilityVLAN_MTU, __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_5_0/*SPI*/)) - #define kSCPropNetEthernetCapabilityVLAN_MTU \ - SC_SCHEMA_KV(kSCPropNetEthernetCapabilityVLAN_MTU \ - ,"VLAN_MTU" \ - ,CFNumber (0 or 1) ) - - - SC_SCHEMA_DECLARATION(kSCValNetInterfaceTypeLoopback, __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_4_0/*SPI*/)) - #define kSCValNetInterfaceTypeLoopback \ - SC_SCHEMA_KV(kSCValNetInterfaceTypeLoopback \ - ,"Loopback" \ - , ) - - SC_SCHEMA_DECLARATION(kSCValNetInterfaceTypeVPN, __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_4_0/*SPI*/)) - #define kSCValNetInterfaceTypeVPN \ - SC_SCHEMA_KV(kSCValNetInterfaceTypeVPN \ - ,"VPN" \ - , ) - - SC_SCHEMA_DECLARATION(kSCPropNetIPSecDisconnectOnWake, __OSX_AVAILABLE_STARTING(__MAC_10_9,__IPHONE_7_0/*SPI*/)) - #define kSCPropNetIPSecDisconnectOnWake \ - SC_SCHEMA_KV(kSCPropNetIPSecDisconnectOnWake \ - ,"DisconnectOnWake" \ - ,CFNumber (0 or 1) ) - - SC_SCHEMA_DECLARATION(kSCPropNetIPSecDisconnectOnWakeTimer, __OSX_AVAILABLE_STARTING(__MAC_10_9,__IPHONE_7_0/*SPI*/)) - #define kSCPropNetIPSecDisconnectOnWakeTimer \ - SC_SCHEMA_KV(kSCPropNetIPSecDisconnectOnWakeTimer \ - ,"DisconnectOnWakeTimer" \ - ,CFNumber ) - - SC_SCHEMA_DECLARATION(kSCPropNetIPSecLastCause, __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_3_0/*SPI*/)) - #define kSCPropNetIPSecLastCause \ - SC_SCHEMA_KV(kSCPropNetIPSecLastCause \ - ,"LastCause" \ - ,CFNumber ) - - SC_SCHEMA_DECLARATION(kSCPropNetIPSecOnDemandEnabled, __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_3_0/*SPI*/)) - #define kSCPropNetIPSecOnDemandEnabled \ - SC_SCHEMA_KV(kSCPropNetIPSecOnDemandEnabled \ - ,"OnDemandEnabled" \ - ,CFNumber (0 or 1) ) - - SC_SCHEMA_DECLARATION(kSCPropNetIPSecOnDemandMatchDomainsAlways, __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_3_0/*SPI*/)) - #define kSCPropNetIPSecOnDemandMatchDomainsAlways \ - SC_SCHEMA_KV(kSCPropNetIPSecOnDemandMatchDomainsAlways \ - ,"OnDemandMatchDomainsAlways" \ - ,CFArray[CFString] ) - - SC_SCHEMA_DECLARATION(kSCPropNetIPSecOnDemandMatchDomainsOnRetry, __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_3_0/*SPI*/)) - #define kSCPropNetIPSecOnDemandMatchDomainsOnRetry \ - SC_SCHEMA_KV(kSCPropNetIPSecOnDemandMatchDomainsOnRetry \ - ,"OnDemandMatchDomainsOnRetry" \ - ,CFArray[CFString] ) - - SC_SCHEMA_DECLARATION(kSCPropNetIPSecOnDemandMatchDomainsNever, __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_3_0/*SPI*/)) - #define kSCPropNetIPSecOnDemandMatchDomainsNever \ - SC_SCHEMA_KV(kSCPropNetIPSecOnDemandMatchDomainsNever \ - ,"OnDemandMatchDomainsNever" \ - ,CFArray[CFString] ) - - SC_SCHEMA_DECLARATION(kSCPropNetIPv4AdditionalRoutes, __OSX_AVAILABLE_STARTING(__MAC_10_10,__IPHONE_8_0/*SPI*/)) - #define kSCPropNetIPv4AdditionalRoutes \ - SC_SCHEMA_KV(kSCPropNetIPv4AdditionalRoutes \ - ,"AdditionalRoutes" \ - ,CFArray[CFDictionary] ) - - SC_SCHEMA_DECLARATION(kSCPropNetIPv4ExcludedRoutes, __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_4_0/*SPI*/)) - #define kSCPropNetIPv4ExcludedRoutes \ - SC_SCHEMA_KV(kSCPropNetIPv4ExcludedRoutes \ - ,"ExcludedRoutes" \ - ,CFArray[CFDictionary] ) - - SC_SCHEMA_DECLARATION(kSCPropNetIPv4IncludedRoutes, __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_4_0/*SPI*/)) - #define kSCPropNetIPv4IncludedRoutes \ - SC_SCHEMA_KV(kSCPropNetIPv4IncludedRoutes \ - ,"IncludedRoutes" \ - ,CFArray[CFDictionary] ) - - SC_SCHEMA_DECLARATION(kSCValNetIPv4ConfigMethodFailover, __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0/*SPI*/)) - #define kSCValNetIPv4ConfigMethodFailover \ - SC_SCHEMA_KV(kSCValNetIPv4ConfigMethodFailover \ - ,"Failover" \ - , ) - - SC_SCHEMA_DECLARATION(kSCPropNetIPv4RouteDestinationAddress, __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_4_0/*SPI*/)) - #define kSCPropNetIPv4RouteDestinationAddress \ - SC_SCHEMA_KV(kSCPropNetIPv4RouteDestinationAddress \ - ,"DestinationAddress" \ - ,CFString ) - - SC_SCHEMA_DECLARATION(kSCPropNetIPv4RouteSubnetMask, __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_4_0/*SPI*/)) - #define kSCPropNetIPv4RouteSubnetMask \ - SC_SCHEMA_KV(kSCPropNetIPv4RouteSubnetMask \ - ,"SubnetMask" \ - ,CFString ) - - SC_SCHEMA_DECLARATION(kSCPropNetIPv4RouteGatewayAddress, __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_4_0/*SPI*/)) - #define kSCPropNetIPv4RouteGatewayAddress \ - SC_SCHEMA_KV(kSCPropNetIPv4RouteGatewayAddress \ - ,"GatewayAddress" \ - ,CFString ) - - SC_SCHEMA_DECLARATION(kSCPropNetIPv4RouteInterfaceName, __OSX_AVAILABLE_STARTING(__MAC_10_10,__IPHONE_8_0/*SPI*/)) - #define kSCPropNetIPv4RouteInterfaceName \ - SC_SCHEMA_KV(kSCPropNetIPv4RouteInterfaceName \ - ,"InterfaceName" \ - ,CFString ) - - SC_SCHEMA_DECLARATION(kSCPropNetIPv4ARPResolvedHardwareAddress, __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_5_0/*SPI*/)) - #define kSCPropNetIPv4ARPResolvedHardwareAddress \ - SC_SCHEMA_KV(kSCPropNetIPv4ARPResolvedHardwareAddress \ - ,"ARPResolvedHardwareAddress" \ - ,CFString ) - - SC_SCHEMA_DECLARATION(kSCPropNetIPv4ARPResolvedIPAddress, __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_5_0/*SPI*/)) - #define kSCPropNetIPv4ARPResolvedIPAddress \ - SC_SCHEMA_KV(kSCPropNetIPv4ARPResolvedIPAddress \ - ,"ARPResolvedIPAddress" \ - ,CFString ) - - SC_SCHEMA_DECLARATION(kSCPropNetIPv6AdditionalRoutes, __OSX_AVAILABLE_STARTING(__MAC_10_10,__IPHONE_8_0/*SPI*/)) - #define kSCPropNetIPv6AdditionalRoutes \ - SC_SCHEMA_KV(kSCPropNetIPv6AdditionalRoutes \ - ,"AdditionalRoutes" \ - ,CFArray[CFDictionary] ) - - SC_SCHEMA_DECLARATION(kSCPropNetIPv6ExcludedRoutes, __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_4_0/*SPI*/)) - #define kSCPropNetIPv6ExcludedRoutes \ - SC_SCHEMA_KV(kSCPropNetIPv6ExcludedRoutes \ - ,"ExcludedRoutes" \ - ,CFArray[CFDictionary] ) - - SC_SCHEMA_DECLARATION(kSCPropNetIPv6IncludedRoutes, __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_4_0/*SPI*/)) - #define kSCPropNetIPv6IncludedRoutes \ - SC_SCHEMA_KV(kSCPropNetIPv6IncludedRoutes \ - ,"IncludedRoutes" \ - ,CFArray[CFDictionary] ) - - SC_SCHEMA_DECLARATION(kSCPropNetIPv6RouteDestinationAddress, __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_4_0/*SPI*/)) - #define kSCPropNetIPv6RouteDestinationAddress \ - SC_SCHEMA_KV(kSCPropNetIPv6RouteDestinationAddress \ - ,"DestinationAddress" \ - ,CFString ) - - SC_SCHEMA_DECLARATION(kSCPropNetIPv6RoutePrefixLength, __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_4_0/*SPI*/)) - #define kSCPropNetIPv6RoutePrefixLength \ - SC_SCHEMA_KV(kSCPropNetIPv6RoutePrefixLength \ - ,"PrefixLength" \ - ,CFNumber ) - - SC_SCHEMA_DECLARATION(kSCPropNetIPv6RouteGatewayAddress, __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_4_0/*SPI*/)) - #define kSCPropNetIPv6RouteGatewayAddress \ - SC_SCHEMA_KV(kSCPropNetIPv6RouteGatewayAddress \ - ,"GatewayAddress" \ - ,CFString ) - - SC_SCHEMA_DECLARATION(kSCPropNetIPv6RouteInterfaceName, __OSX_AVAILABLE_STARTING(__MAC_10_10,__IPHONE_8_0/*SPI*/)) - #define kSCPropNetIPv6RouteInterfaceName \ - SC_SCHEMA_KV(kSCPropNetIPv6RouteInterfaceName \ - ,"InterfaceName" \ - ,CFString ) - - SC_SCHEMA_DECLARATION(kSCPropNetLinkExpensive, __OSX_AVAILABLE_STARTING(__MAC_10_10,__IPHONE_8_0/*SPI*/)) - #define kSCPropNetLinkExpensive \ - SC_SCHEMA_KV(kSCPropNetLinkExpensive \ - ,"Expensive" \ - ,CFBoolean ) - - SC_SCHEMA_DECLARATION(kSCPropNetLinkIssuesModuleID, __OSX_AVAILABLE_STARTING(__MAC_10_9,__IPHONE_7_0/*SPI*/)) - #define kSCPropNetLinkIssuesModuleID \ - SC_SCHEMA_KV(kSCPropNetLinkIssuesModuleID \ - ,"ModuleID" \ - ,CFData ) - - SC_SCHEMA_DECLARATION(kSCPropNetLinkIssuesInfo, __OSX_AVAILABLE_STARTING(__MAC_10_9,__IPHONE_7_0/*SPI*/)) - #define kSCPropNetLinkIssuesInfo \ - SC_SCHEMA_KV(kSCPropNetLinkIssuesInfo \ - ,"Info" \ - ,CFData ) - - SC_SCHEMA_DECLARATION(kSCPropNetLinkIssuesTimeStamp, __OSX_AVAILABLE_STARTING(__MAC_10_9,__IPHONE_7_0/*SPI*/)) - #define kSCPropNetLinkIssuesTimeStamp \ - SC_SCHEMA_KV(kSCPropNetLinkIssuesTimeStamp \ - ,"TimeStamp" \ - ,CFDATE ) - - SC_SCHEMA_DECLARATION(kSCPropNetLinkQuality, __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_5_0/*SPI*/)) - #define kSCPropNetLinkQuality \ - SC_SCHEMA_KV(kSCPropNetLinkQuality \ - ,"LinkQuality" \ - ,CFNumber ) - - SC_SCHEMA_DECLARATION(kSCPropNetPPPDisconnectOnWake, __OSX_AVAILABLE_STARTING(__MAC_10_9,__IPHONE_7_0/*SPI*/)) - #define kSCPropNetPPPDisconnectOnWake \ - SC_SCHEMA_KV(kSCPropNetPPPDisconnectOnWake \ - ,"DisconnectOnWake" \ - ,CFNumber (0 or 1) ) - - SC_SCHEMA_DECLARATION(kSCPropNetPPPDisconnectOnWakeTimer, __OSX_AVAILABLE_STARTING(__MAC_10_9,__IPHONE_7_0/*SPI*/)) - #define kSCPropNetPPPDisconnectOnWakeTimer \ - SC_SCHEMA_KV(kSCPropNetPPPDisconnectOnWakeTimer \ - ,"DisconnectOnWakeTimer" \ - ,CFNumber ) - - SC_SCHEMA_DECLARATION(kSCPropNetPPPOnDemandDomains, __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetPPPOnDemandDomains \ - SC_SCHEMA_KV(kSCPropNetPPPOnDemandDomains \ - ,"OnDemandDomains" \ - ,CFArray[CFString] ) - - SC_SCHEMA_DECLARATION(kSCPropNetPPPOnDemandEnabled, __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetPPPOnDemandEnabled \ - SC_SCHEMA_KV(kSCPropNetPPPOnDemandEnabled \ - ,"OnDemandEnabled" \ - ,CFNumber (0 or 1) ) - - SC_SCHEMA_DECLARATION(kSCPropNetPPPOnDemandHostName, __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetPPPOnDemandHostName \ - SC_SCHEMA_KV(kSCPropNetPPPOnDemandHostName \ - ,"OnDemandHostName" \ - ,CFString ) - - SC_SCHEMA_DECLARATION(kSCPropNetPPPOnDemandMatchDomainsAlways, __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_5_0/*SPI*/)) - #define kSCPropNetPPPOnDemandMatchDomainsAlways \ - SC_SCHEMA_KV(kSCPropNetPPPOnDemandMatchDomainsAlways \ - ,"OnDemandMatchDomainsAlways" \ - ,CFArray[CFString] ) - - SC_SCHEMA_DECLARATION(kSCPropNetPPPOnDemandMatchDomainsOnRetry, __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_5_0/*SPI*/)) - #define kSCPropNetPPPOnDemandMatchDomainsOnRetry \ - SC_SCHEMA_KV(kSCPropNetPPPOnDemandMatchDomainsOnRetry \ - ,"OnDemandMatchDomainsOnRetry" \ - ,CFArray[CFString] ) - - SC_SCHEMA_DECLARATION(kSCPropNetPPPOnDemandMatchDomainsNever, __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_5_0/*SPI*/)) - #define kSCPropNetPPPOnDemandMatchDomainsNever \ - SC_SCHEMA_KV(kSCPropNetPPPOnDemandMatchDomainsNever \ - ,"OnDemandMatchDomainsNever" \ - ,CFArray[CFString] ) - - SC_SCHEMA_DECLARATION(kSCPropNetPPPOnDemandMode, __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetPPPOnDemandMode \ - SC_SCHEMA_KV(kSCPropNetPPPOnDemandMode \ - ,"OnDemandMode" \ - ,CFString ) - - SC_SCHEMA_DECLARATION(kSCPropNetPPPOnDemandPriority, __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetPPPOnDemandPriority \ - SC_SCHEMA_KV(kSCPropNetPPPOnDemandPriority \ - ,"OnDemandPriority" \ - ,CFString ) - - SC_SCHEMA_DECLARATION(kSCValNetPPPOnDemandModeAggressive, __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0/*SPI*/)) - #define kSCValNetPPPOnDemandModeAggressive \ - SC_SCHEMA_KV(kSCValNetPPPOnDemandModeAggressive \ - ,"Aggressive" \ - , ) - - SC_SCHEMA_DECLARATION(kSCValNetPPPOnDemandModeConservative, __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0/*SPI*/)) - #define kSCValNetPPPOnDemandModeConservative \ - SC_SCHEMA_KV(kSCValNetPPPOnDemandModeConservative \ - ,"Conservative" \ - , ) - - SC_SCHEMA_DECLARATION(kSCValNetPPPOnDemandModeCompatible, __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0/*SPI*/)) - #define kSCValNetPPPOnDemandModeCompatible \ - SC_SCHEMA_KV(kSCValNetPPPOnDemandModeCompatible \ - ,"Compatible" \ - , ) - - SC_SCHEMA_DECLARATION(kSCValNetPPPOnDemandPriorityDefault, __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0/*SPI*/)) - #define kSCValNetPPPOnDemandPriorityDefault \ - SC_SCHEMA_KV(kSCValNetPPPOnDemandPriorityDefault \ - ,"Default" \ - , ) - - SC_SCHEMA_DECLARATION(kSCValNetPPPOnDemandPriorityHigh, __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0/*SPI*/)) - #define kSCValNetPPPOnDemandPriorityHigh \ - SC_SCHEMA_KV(kSCValNetPPPOnDemandPriorityHigh \ - ,"High" \ - , ) - - SC_SCHEMA_DECLARATION(kSCValNetPPPOnDemandPriorityLow, __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0/*SPI*/)) - #define kSCValNetPPPOnDemandPriorityLow \ - SC_SCHEMA_KV(kSCValNetPPPOnDemandPriorityLow \ - ,"Low" \ - , ) - - SC_SCHEMA_DECLARATION(kSCPropNetProxiesBypassAllowed, __OSX_AVAILABLE_STARTING(__MAC_10_9,__IPHONE_7_0/*SPI*/)) - #define kSCPropNetProxiesBypassAllowed \ - SC_SCHEMA_KV(kSCPropNetProxiesBypassAllowed \ - ,"BypassAllowed" \ - ,CFNumber (0 or 1) ) - - SC_SCHEMA_DECLARATION(kSCPropNetProxiesFallBackAllowed, __OSX_AVAILABLE_STARTING(__MAC_10_9,__IPHONE_6_0/*SPI*/)) - #define kSCPropNetProxiesFallBackAllowed \ - SC_SCHEMA_KV(kSCPropNetProxiesFallBackAllowed \ - ,"FallBackAllowed" \ - ,CFNumber (0 or 1) ) - - SC_SCHEMA_DECLARATION(kSCPropNetProxiesSupplementalMatchDomains, __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_5_0/*SPI*/)) - #define kSCPropNetProxiesSupplementalMatchDomains \ - SC_SCHEMA_KV(kSCPropNetProxiesSupplementalMatchDomains \ - ,"SupplementalMatchDomains" \ - ,CFArray[CFString] ) - - SC_SCHEMA_DECLARATION(kSCPropNetProxiesSupplementalMatchOrders, __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_5_0/*SPI*/)) - #define kSCPropNetProxiesSupplementalMatchOrders \ - SC_SCHEMA_KV(kSCPropNetProxiesSupplementalMatchOrders \ - ,"SupplementalMatchOrders" \ - ,CFArray[CFNumber] ) - - SC_SCHEMA_DECLARATION(kSCPropNetProxiesScoped, __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_5_0/*SPI*/)) - #define kSCPropNetProxiesScoped \ - SC_SCHEMA_KV(kSCPropNetProxiesScoped \ - ,"__SCOPED__" \ - ,CFDictionary ) - - SC_SCHEMA_DECLARATION(kSCPropNetProxiesServices, __OSX_AVAILABLE_STARTING(__MAC_10_9,__IPHONE_7_0/*SPI*/)) - #define kSCPropNetProxiesServices \ - SC_SCHEMA_KV(kSCPropNetProxiesServices \ - ,"__SERVICES__" \ - ,CFDictionary ) - - SC_SCHEMA_DECLARATION(kSCPropNetProxiesSupplemental, __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_5_0/*SPI*/)) - #define kSCPropNetProxiesSupplemental \ - SC_SCHEMA_KV(kSCPropNetProxiesSupplemental \ - ,"__SUPPLEMENTAL__" \ - ,CFArray[CFDictionary] ) - - SC_SCHEMA_DECLARATION(kSCPropNetProxiesSupplementalMatchDomain, __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_5_0/*SPI*/)) - #define kSCPropNetProxiesSupplementalMatchDomain \ - SC_SCHEMA_KV(kSCPropNetProxiesSupplementalMatchDomain \ - ,"__MATCH_DOMAIN__" \ - ,CFString ) - - SC_SCHEMA_DECLARATION(kSCPropNetServicePrimaryRank, __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetServicePrimaryRank \ - SC_SCHEMA_KV(kSCPropNetServicePrimaryRank \ - ,"PrimaryRank" \ - ,CFString ) - - SC_SCHEMA_DECLARATION(kSCPropNetServiceUserDefinedName, __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_2_0/*SPI*/)) - #define kSCPropNetServiceUserDefinedName \ - SC_SCHEMA_KV(kSCPropNetServiceUserDefinedName \ - ,"UserDefinedName" \ - ,CFString ) - - SC_SCHEMA_DECLARATION(kSCValNetServicePrimaryRankFirst, __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_2_0/*SPI*/)) - #define kSCValNetServicePrimaryRankFirst \ - SC_SCHEMA_KV(kSCValNetServicePrimaryRankFirst \ - ,"First" \ - , ) - - SC_SCHEMA_DECLARATION(kSCValNetServicePrimaryRankLast, __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_2_0/*SPI*/)) - #define kSCValNetServicePrimaryRankLast \ - SC_SCHEMA_KV(kSCValNetServicePrimaryRankLast \ - ,"Last" \ - , ) - - SC_SCHEMA_DECLARATION(kSCValNetServicePrimaryRankNever, __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_2_0/*SPI*/)) - #define kSCValNetServicePrimaryRankNever \ - SC_SCHEMA_KV(kSCValNetServicePrimaryRankNever \ - ,"Never" \ - , ) - - SC_SCHEMA_DECLARATION(kSCValNetServicePrimaryRankScoped, __OSX_AVAILABLE_STARTING(__MAC_10_10,__IPHONE_8_0/*SPI*/)) - #define kSCValNetServicePrimaryRankScoped \ - SC_SCHEMA_KV(kSCValNetServicePrimaryRankScoped \ - ,"Scoped" \ - , ) - - SC_SCHEMA_DECLARATION(kSCPropNetVPNAppRules, __OSX_AVAILABLE_STARTING(__MAC_10_9,__IPHONE_7_0/*SPI*/)) - #define kSCPropNetVPNAppRules \ - SC_SCHEMA_KV(kSCPropNetVPNAppRules \ - ,"AppRules" \ - ,CFArray[CFDictionary] ) - - SC_SCHEMA_DECLARATION(kSCPropNetVPNAuthCredentialPassword, __OSX_AVAILABLE_STARTING(__MAC_10_9,__IPHONE_7_0/*SPI*/)) - #define kSCPropNetVPNAuthCredentialPassword \ - SC_SCHEMA_KV(kSCPropNetVPNAuthCredentialPassword \ - ,"AuthCredentialPassword" \ - ,CFString ) - - SC_SCHEMA_DECLARATION(kSCPropNetVPNAuthName, __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_4_0/*SPI*/)) - #define kSCPropNetVPNAuthName \ - SC_SCHEMA_KV(kSCPropNetVPNAuthName \ - ,"AuthName" \ - ,CFString ) - - SC_SCHEMA_DECLARATION(kSCPropNetVPNAuthPassword, __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_4_0/*SPI*/)) - #define kSCPropNetVPNAuthPassword \ - SC_SCHEMA_KV(kSCPropNetVPNAuthPassword \ - ,"AuthPassword" \ - ,CFString ) - - SC_SCHEMA_DECLARATION(kSCPropNetVPNAuthPasswordEncryption, __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_4_0/*SPI*/)) - #define kSCPropNetVPNAuthPasswordEncryption \ - SC_SCHEMA_KV(kSCPropNetVPNAuthPasswordEncryption \ - ,"AuthPasswordEncryption" \ - ,CFString ) - - SC_SCHEMA_DECLARATION(kSCPropNetVPNAuthPasswordPluginType, __OSX_AVAILABLE_STARTING(__MAC_10_9,__IPHONE_7_0/*SPI*/)) - #define kSCPropNetVPNAuthPasswordPluginType \ - SC_SCHEMA_KV(kSCPropNetVPNAuthPasswordPluginType \ - ,"AuthPasswordPluginType" \ - ,CFString ) - - SC_SCHEMA_DECLARATION(kSCPropNetVPNAuthenticationMethod, __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_4_0/*SPI*/)) - #define kSCPropNetVPNAuthenticationMethod \ - SC_SCHEMA_KV(kSCPropNetVPNAuthenticationMethod \ - ,"AuthenticationMethod" \ - ,CFString ) - - SC_SCHEMA_DECLARATION(kSCPropNetVPNConnectTime, __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_4_0/*SPI*/)) - #define kSCPropNetVPNConnectTime \ - SC_SCHEMA_KV(kSCPropNetVPNConnectTime \ - ,"ConnectTime" \ - ,CFString ) - - SC_SCHEMA_DECLARATION(kSCPropNetVPNDisconnectOnFastUserSwitch, __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_4_0/*SPI*/)) - #define kSCPropNetVPNDisconnectOnFastUserSwitch \ - SC_SCHEMA_KV(kSCPropNetVPNDisconnectOnFastUserSwitch \ - ,"DisconnectOnFastUserSwitch" \ - ,CFNumber (0 or 1) ) - - SC_SCHEMA_DECLARATION(kSCPropNetVPNDisconnectOnIdle, __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_4_0/*SPI*/)) - #define kSCPropNetVPNDisconnectOnIdle \ - SC_SCHEMA_KV(kSCPropNetVPNDisconnectOnIdle \ - ,"DisconnectOnIdle" \ - ,CFNumber (0 or 1) ) - - SC_SCHEMA_DECLARATION(kSCPropNetVPNDisconnectOnIdleTimer, __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_4_0/*SPI*/)) - #define kSCPropNetVPNDisconnectOnIdleTimer \ - SC_SCHEMA_KV(kSCPropNetVPNDisconnectOnIdleTimer \ - ,"DisconnectOnIdleTimer" \ - ,CFNumber ) - - SC_SCHEMA_DECLARATION(kSCPropNetVPNDisconnectOnLogout, __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_4_0/*SPI*/)) - #define kSCPropNetVPNDisconnectOnLogout \ - SC_SCHEMA_KV(kSCPropNetVPNDisconnectOnLogout \ - ,"DisconnectOnLogout" \ - ,CFNumber (0 or 1) ) - - SC_SCHEMA_DECLARATION(kSCPropNetVPNDisconnectOnSleep, __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_4_0/*SPI*/)) - #define kSCPropNetVPNDisconnectOnSleep \ - SC_SCHEMA_KV(kSCPropNetVPNDisconnectOnSleep \ - ,"DisconnectOnSleep" \ - ,CFNumber (0 or 1) ) - - SC_SCHEMA_DECLARATION(kSCPropNetVPNDisconnectOnWake, __OSX_AVAILABLE_STARTING(__MAC_10_9,__IPHONE_7_0/*SPI*/)) - #define kSCPropNetVPNDisconnectOnWake \ - SC_SCHEMA_KV(kSCPropNetVPNDisconnectOnWake \ - ,"DisconnectOnWake" \ - ,CFNumber (0 or 1) ) - - SC_SCHEMA_DECLARATION(kSCPropNetVPNDisconnectOnWakeTimer, __OSX_AVAILABLE_STARTING(__MAC_10_9,__IPHONE_7_0/*SPI*/)) - #define kSCPropNetVPNDisconnectOnWakeTimer \ - SC_SCHEMA_KV(kSCPropNetVPNDisconnectOnWakeTimer \ - ,"DisconnectOnWakeTimer" \ - ,CFNumber ) - - SC_SCHEMA_DECLARATION(kSCPropNetVPNLocalCertificate, __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_4_0/*SPI*/)) - #define kSCPropNetVPNLocalCertificate \ - SC_SCHEMA_KV(kSCPropNetVPNLocalCertificate \ - ,"LocalCertificate" \ - ,CFData ) - - SC_SCHEMA_DECLARATION(kSCPropNetVPNLogfile, __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_4_0/*SPI*/)) - #define kSCPropNetVPNLogfile \ - SC_SCHEMA_KV(kSCPropNetVPNLogfile \ - ,"Logfile" \ - ,CFString ) - - SC_SCHEMA_DECLARATION(kSCPropNetVPNMTU, __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_4_0/*SPI*/)) - #define kSCPropNetVPNMTU \ - SC_SCHEMA_KV(kSCPropNetVPNMTU \ - ,"MTU" \ - ,CFNumber ) - - SC_SCHEMA_DECLARATION(kSCPropNetVPNOnDemandEnabled, __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_4_0/*SPI*/)) - #define kSCPropNetVPNOnDemandEnabled \ - SC_SCHEMA_KV(kSCPropNetVPNOnDemandEnabled \ - ,"OnDemandEnabled" \ - ,CFNumber (0 or 1) ) - - SC_SCHEMA_DECLARATION(kSCPropNetVPNOnDemandMatchAppEnabled, __OSX_AVAILABLE_STARTING(__MAC_10_9,__IPHONE_7_0/*SPI*/)) - #define kSCPropNetVPNOnDemandMatchAppEnabled \ - SC_SCHEMA_KV(kSCPropNetVPNOnDemandMatchAppEnabled \ - ,"OnDemandMatchAppEnabled" \ - ,CFBoolean ) - - SC_SCHEMA_DECLARATION(kSCPropNetVPNOnDemandMatchDomainsAlways, __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_4_0/*SPI*/)) - #define kSCPropNetVPNOnDemandMatchDomainsAlways \ - SC_SCHEMA_KV(kSCPropNetVPNOnDemandMatchDomainsAlways \ - ,"OnDemandMatchDomainsAlways" \ - ,CFArray[CFString] ) - - SC_SCHEMA_DECLARATION(kSCPropNetVPNOnDemandMatchDomainsOnRetry, __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_4_0/*SPI*/)) - #define kSCPropNetVPNOnDemandMatchDomainsOnRetry \ - SC_SCHEMA_KV(kSCPropNetVPNOnDemandMatchDomainsOnRetry \ - ,"OnDemandMatchDomainsOnRetry" \ - ,CFArray[CFString] ) - - SC_SCHEMA_DECLARATION(kSCPropNetVPNOnDemandMatchDomainsNever, __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_4_0/*SPI*/)) - #define kSCPropNetVPNOnDemandMatchDomainsNever \ - SC_SCHEMA_KV(kSCPropNetVPNOnDemandMatchDomainsNever \ - ,"OnDemandMatchDomainsNever" \ - ,CFArray[CFString] ) - - SC_SCHEMA_DECLARATION(kSCPropNetVPNOnDemandRules, __OSX_AVAILABLE_STARTING(__MAC_10_8,__IPHONE_6_0/*SPI*/)) - #define kSCPropNetVPNOnDemandRules \ - SC_SCHEMA_KV(kSCPropNetVPNOnDemandRules \ - ,"OnDemandRules" \ - ,CFArray[CFDictionary] ) - - SC_SCHEMA_DECLARATION(kSCPropNetVPNOnDemandSuspended, __OSX_AVAILABLE_STARTING(__MAC_10_9,__IPHONE_7_0/*SPI*/)) - #define kSCPropNetVPNOnDemandSuspended \ - SC_SCHEMA_KV(kSCPropNetVPNOnDemandSuspended \ - ,"OnDemandSuspended" \ - ,CFNumber ) - - SC_SCHEMA_DECLARATION(kSCPropNetVPNPluginCapability, __OSX_AVAILABLE_STARTING(__MAC_10_9,__IPHONE_7_0/*SPI*/)) - #define kSCPropNetVPNPluginCapability \ - SC_SCHEMA_KV(kSCPropNetVPNPluginCapability \ - ,"PluginCapability" \ - ,CFString ) - - SC_SCHEMA_DECLARATION(kSCPropNetVPNRemoteAddress, __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_4_0/*SPI*/)) - #define kSCPropNetVPNRemoteAddress \ - SC_SCHEMA_KV(kSCPropNetVPNRemoteAddress \ - ,"RemoteAddress" \ - ,CFString ) - - SC_SCHEMA_DECLARATION(kSCPropNetVPNStatus, __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_4_0/*SPI*/)) - #define kSCPropNetVPNStatus \ - SC_SCHEMA_KV(kSCPropNetVPNStatus \ - ,"Status" \ - ,CFNumber ) - - SC_SCHEMA_DECLARATION(kSCPropNetVPNVerboseLogging, __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_4_0/*SPI*/)) - #define kSCPropNetVPNVerboseLogging \ - SC_SCHEMA_KV(kSCPropNetVPNVerboseLogging \ - ,"VerboseLogging" \ - ,CFNumber (0 or 1) ) - - SC_SCHEMA_DECLARATION(kSCValNetVPNAppRuleAccountIdentifierMatch, __OSX_AVAILABLE_STARTING(__MAC_10_9,__IPHONE_7_0/*SPI*/)) - #define kSCValNetVPNAppRuleAccountIdentifierMatch \ - SC_SCHEMA_KV(kSCValNetVPNAppRuleAccountIdentifierMatch \ - ,"AccountIdentifierMatch" \ - ,CFArray[CFString] ) - - SC_SCHEMA_DECLARATION(kSCValNetVPNAppRuleDNSDomainMatch, __OSX_AVAILABLE_STARTING(__MAC_10_9,__IPHONE_7_0/*SPI*/)) - #define kSCValNetVPNAppRuleDNSDomainMatch \ - SC_SCHEMA_KV(kSCValNetVPNAppRuleDNSDomainMatch \ - ,"DNSDomainMatch" \ - ,CFArray[CFString] ) - - SC_SCHEMA_DECLARATION(kSCValNetVPNAppRuleExecutableMatch, __OSX_AVAILABLE_STARTING(__MAC_10_9,__IPHONE_7_0/*SPI*/)) - #define kSCValNetVPNAppRuleExecutableMatch \ - SC_SCHEMA_KV(kSCValNetVPNAppRuleExecutableMatch \ - ,"ExecutableMatch" \ - ,CFArray[CFDictionary] ) - - SC_SCHEMA_DECLARATION(kSCValNetVPNAppRuleIdentifier, __OSX_AVAILABLE_STARTING(__MAC_10_9,__IPHONE_7_0/*SPI*/)) - #define kSCValNetVPNAppRuleIdentifier \ - SC_SCHEMA_KV(kSCValNetVPNAppRuleIdentifier \ - ,"Identifier" \ - ,CFString ) - - SC_SCHEMA_DECLARATION(kSCValNetVPNAppRuleExecutableDesignatedRequirement, __OSX_AVAILABLE_STARTING(__MAC_10_9,__IPHONE_7_0/*SPI*/)) - #define kSCValNetVPNAppRuleExecutableDesignatedRequirement \ - SC_SCHEMA_KV(kSCValNetVPNAppRuleExecutableDesignatedRequirement \ - ,"DesignatedRequirement" \ - ,CFString ) - - SC_SCHEMA_DECLARATION(kSCValNetVPNAppRuleExecutableSigningIdentifier, __OSX_AVAILABLE_STARTING(__MAC_10_9,__IPHONE_7_0/*SPI*/)) - #define kSCValNetVPNAppRuleExecutableSigningIdentifier \ - SC_SCHEMA_KV(kSCValNetVPNAppRuleExecutableSigningIdentifier \ - ,"SigningIdentifier" \ - ,CFString ) - - SC_SCHEMA_DECLARATION(kSCValNetVPNAppRuleExecutableUUID, __OSX_AVAILABLE_STARTING(__MAC_10_9,__IPHONE_7_0/*SPI*/)) - #define kSCValNetVPNAppRuleExecutableUUID \ - SC_SCHEMA_KV(kSCValNetVPNAppRuleExecutableUUID \ - ,"UUID" \ - ,CFString ) - - SC_SCHEMA_DECLARATION(kSCValNetVPNAuthenticationMethodPassword, __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_4_0/*SPI*/)) - #define kSCValNetVPNAuthenticationMethodPassword \ - SC_SCHEMA_KV(kSCValNetVPNAuthenticationMethodPassword \ - ,"Password" \ - , ) - - SC_SCHEMA_DECLARATION(kSCValNetVPNAuthenticationMethodCertificate, __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_4_0/*SPI*/)) - #define kSCValNetVPNAuthenticationMethodCertificate \ - SC_SCHEMA_KV(kSCValNetVPNAuthenticationMethodCertificate \ - ,"Certificate" \ - , ) - - SC_SCHEMA_DECLARATION(kSCValNetVPNAuthPasswordEncryptionExternal, __OSX_AVAILABLE_STARTING(__MAC_10_9,__IPHONE_7_0/*SPI*/)) - #define kSCValNetVPNAuthPasswordEncryptionExternal \ - SC_SCHEMA_KV(kSCValNetVPNAuthPasswordEncryptionExternal \ - ,"External" \ - , ) - - SC_SCHEMA_DECLARATION(kSCValNetVPNAuthPasswordEncryptionKeychain, __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_4_0/*SPI*/)) - #define kSCValNetVPNAuthPasswordEncryptionKeychain \ - SC_SCHEMA_KV(kSCValNetVPNAuthPasswordEncryptionKeychain \ - ,"Keychain" \ - , ) - - SC_SCHEMA_DECLARATION(kSCValNetVPNAuthPasswordEncryptionPrompt, __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_4_0/*SPI*/)) - #define kSCValNetVPNAuthPasswordEncryptionPrompt \ - SC_SCHEMA_KV(kSCValNetVPNAuthPasswordEncryptionPrompt \ - ,"Prompt" \ - , ) - - SC_SCHEMA_DECLARATION(kSCPropNetVPNOnDemandRuleAction, __OSX_AVAILABLE_STARTING(__MAC_10_8,__IPHONE_6_0/*SPI*/)) - #define kSCPropNetVPNOnDemandRuleAction \ - SC_SCHEMA_KV(kSCPropNetVPNOnDemandRuleAction \ - ,"Action" \ - ,CFString ) - - SC_SCHEMA_DECLARATION(kSCPropNetVPNOnDemandRuleActionParameters, __OSX_AVAILABLE_STARTING(__MAC_10_9,__IPHONE_7_0/*SPI*/)) - #define kSCPropNetVPNOnDemandRuleActionParameters \ - SC_SCHEMA_KV(kSCPropNetVPNOnDemandRuleActionParameters \ - ,"ActionParameters" \ - ,CFArray[CFDictionary] ) - - SC_SCHEMA_DECLARATION(kSCPropNetVPNOnDemandRuleDNSDomainMatch, __OSX_AVAILABLE_STARTING(__MAC_10_8,__IPHONE_6_0/*SPI*/)) - #define kSCPropNetVPNOnDemandRuleDNSDomainMatch \ - SC_SCHEMA_KV(kSCPropNetVPNOnDemandRuleDNSDomainMatch \ - ,"DNSDomainMatch" \ - ,CFArray[CFString] ) - - SC_SCHEMA_DECLARATION(kSCPropNetVPNOnDemandRuleDNSServerAddressMatch, __OSX_AVAILABLE_STARTING(__MAC_10_8,__IPHONE_6_0/*SPI*/)) - #define kSCPropNetVPNOnDemandRuleDNSServerAddressMatch \ - SC_SCHEMA_KV(kSCPropNetVPNOnDemandRuleDNSServerAddressMatch \ - ,"DNSServerAddressMatch" \ - ,CFArray[CFString] ) - - SC_SCHEMA_DECLARATION(kSCPropNetVPNOnDemandRuleSSIDMatch, __OSX_AVAILABLE_STARTING(__MAC_10_9,__IPHONE_7_0/*SPI*/)) - #define kSCPropNetVPNOnDemandRuleSSIDMatch \ - SC_SCHEMA_KV(kSCPropNetVPNOnDemandRuleSSIDMatch \ - ,"SSIDMatch" \ - ,CFArray[CFString] ) - - SC_SCHEMA_DECLARATION(kSCPropNetVPNOnDemandRuleInterfaceTypeMatch, __OSX_AVAILABLE_STARTING(__MAC_10_9,__IPHONE_7_0/*SPI*/)) - #define kSCPropNetVPNOnDemandRuleInterfaceTypeMatch \ - SC_SCHEMA_KV(kSCPropNetVPNOnDemandRuleInterfaceTypeMatch \ - ,"InterfaceTypeMatch" \ - ,CFString ) - - SC_SCHEMA_DECLARATION(kSCPropNetVPNOnDemandRuleURLStringProbe, __OSX_AVAILABLE_STARTING(__MAC_10_8,__IPHONE_6_0/*SPI*/)) - #define kSCPropNetVPNOnDemandRuleURLStringProbe \ - SC_SCHEMA_KV(kSCPropNetVPNOnDemandRuleURLStringProbe \ - ,"URLStringProbe" \ - ,CFString ) - - SC_SCHEMA_DECLARATION(kSCValNetVPNOnDemandRuleActionAllow, __OSX_AVAILABLE_STARTING(__MAC_10_8,__IPHONE_6_0/*SPI*/)) - #define kSCValNetVPNOnDemandRuleActionAllow \ - SC_SCHEMA_KV(kSCValNetVPNOnDemandRuleActionAllow \ - ,"Allow" \ - , ) - - SC_SCHEMA_DECLARATION(kSCValNetVPNOnDemandRuleActionIgnore, __OSX_AVAILABLE_STARTING(__MAC_10_8,__IPHONE_6_0/*SPI*/)) - #define kSCValNetVPNOnDemandRuleActionIgnore \ - SC_SCHEMA_KV(kSCValNetVPNOnDemandRuleActionIgnore \ - ,"Ignore" \ - , ) - - SC_SCHEMA_DECLARATION(kSCValNetVPNOnDemandRuleActionConnect, __OSX_AVAILABLE_STARTING(__MAC_10_8,__IPHONE_6_0/*SPI*/)) - #define kSCValNetVPNOnDemandRuleActionConnect \ - SC_SCHEMA_KV(kSCValNetVPNOnDemandRuleActionConnect \ - ,"Connect" \ - , ) - - SC_SCHEMA_DECLARATION(kSCValNetVPNOnDemandRuleActionDisconnect, __OSX_AVAILABLE_STARTING(__MAC_10_8,__IPHONE_6_0/*SPI*/)) - #define kSCValNetVPNOnDemandRuleActionDisconnect \ - SC_SCHEMA_KV(kSCValNetVPNOnDemandRuleActionDisconnect \ - ,"Disconnect" \ - , ) - - SC_SCHEMA_DECLARATION(kSCValNetVPNOnDemandRuleActionEvaluateConnection, __OSX_AVAILABLE_STARTING(__MAC_10_9,__IPHONE_7_0/*SPI*/)) - #define kSCValNetVPNOnDemandRuleActionEvaluateConnection \ - SC_SCHEMA_KV(kSCValNetVPNOnDemandRuleActionEvaluateConnection \ - ,"EvaluateConnection" \ - , ) - - SC_SCHEMA_DECLARATION(kSCPropNetVPNOnDemandRuleActionParametersDomainAction, __OSX_AVAILABLE_STARTING(__MAC_10_9,__IPHONE_7_0/*SPI*/)) - #define kSCPropNetVPNOnDemandRuleActionParametersDomainAction \ - SC_SCHEMA_KV(kSCPropNetVPNOnDemandRuleActionParametersDomainAction \ - ,"DomainAction" \ - ,CFString ) - - SC_SCHEMA_DECLARATION(kSCPropNetVPNOnDemandRuleActionParametersDomains, __OSX_AVAILABLE_STARTING(__MAC_10_9,__IPHONE_7_0/*SPI*/)) - #define kSCPropNetVPNOnDemandRuleActionParametersDomains \ - SC_SCHEMA_KV(kSCPropNetVPNOnDemandRuleActionParametersDomains \ - ,"Domains" \ - ,CFArray[CFString] ) - - SC_SCHEMA_DECLARATION(kSCPropNetVPNOnDemandRuleActionParametersRequiredDNSServers, __OSX_AVAILABLE_STARTING(__MAC_10_9,__IPHONE_7_0/*SPI*/)) - #define kSCPropNetVPNOnDemandRuleActionParametersRequiredDNSServers \ - SC_SCHEMA_KV(kSCPropNetVPNOnDemandRuleActionParametersRequiredDNSServers \ - ,"RequiredDNSServers" \ - ,CFArray[CFString] ) - - SC_SCHEMA_DECLARATION(kSCPropNetVPNOnDemandRuleActionParametersRequiredURLStringProbe, __OSX_AVAILABLE_STARTING(__MAC_10_9,__IPHONE_7_0/*SPI*/)) - #define kSCPropNetVPNOnDemandRuleActionParametersRequiredURLStringProbe \ - SC_SCHEMA_KV(kSCPropNetVPNOnDemandRuleActionParametersRequiredURLStringProbe \ - ,"RequiredURLStringProbe" \ - ,CFString ) - - SC_SCHEMA_DECLARATION(kSCValNetVPNOnDemandRuleActionParametersDomainActionConnectIfNeeded, __OSX_AVAILABLE_STARTING(__MAC_10_9,__IPHONE_7_0/*SPI*/)) - #define kSCValNetVPNOnDemandRuleActionParametersDomainActionConnectIfNeeded \ - SC_SCHEMA_KV(kSCValNetVPNOnDemandRuleActionParametersDomainActionConnectIfNeeded \ - ,"ConnectIfNeeded" \ - , ) - - SC_SCHEMA_DECLARATION(kSCValNetVPNOnDemandRuleActionParametersDomainActionNeverConnect, __OSX_AVAILABLE_STARTING(__MAC_10_9,__IPHONE_7_0/*SPI*/)) - #define kSCValNetVPNOnDemandRuleActionParametersDomainActionNeverConnect \ - SC_SCHEMA_KV(kSCValNetVPNOnDemandRuleActionParametersDomainActionNeverConnect \ - ,"NeverConnect" \ - , ) - - - SC_SCHEMA_DECLARATION(kSCValNetVPNOnDemandRuleInterfaceTypeMatchEthernet, __OSX_AVAILABLE_STARTING(__MAC_10_9,__IPHONE_7_0/*SPI*/)) - #define kSCValNetVPNOnDemandRuleInterfaceTypeMatchEthernet \ - SC_SCHEMA_KV(kSCValNetVPNOnDemandRuleInterfaceTypeMatchEthernet \ - ,"Ethernet" \ - , ) - - SC_SCHEMA_DECLARATION(kSCValNetVPNOnDemandRuleInterfaceTypeMatchWiFi, __OSX_AVAILABLE_STARTING(__MAC_10_9,__IPHONE_7_0/*SPI*/)) - #define kSCValNetVPNOnDemandRuleInterfaceTypeMatchWiFi \ - SC_SCHEMA_KV(kSCValNetVPNOnDemandRuleInterfaceTypeMatchWiFi \ - ,"WiFi" \ - , ) - - SC_SCHEMA_DECLARATION(kSCValNetVPNPluginCapabilityAuth, __OSX_AVAILABLE_STARTING(__MAC_10_9,__IPHONE_7_0/*SPI*/)) - #define kSCValNetVPNPluginCapabilityAuth \ - SC_SCHEMA_KV(kSCValNetVPNPluginCapabilityAuth \ - ,"Auth" \ - , ) - - SC_SCHEMA_DECLARATION(kSCValNetVPNPluginCapabilityConnect, __OSX_AVAILABLE_STARTING(__MAC_10_9,__IPHONE_7_0/*SPI*/)) - #define kSCValNetVPNPluginCapabilityConnect \ - SC_SCHEMA_KV(kSCValNetVPNPluginCapabilityConnect \ - ,"Connect" \ - , ) - - SC_SCHEMA_DECLARATION(kSCPropSystemComputerNameRegion, __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0/*SPI*/)) - #define kSCPropSystemComputerNameRegion \ - SC_SCHEMA_KV(kSCPropSystemComputerNameRegion \ - ,"ComputerNameRegion" \ - ,CFNumber ) - - SC_SCHEMA_DECLARATION(kSCPropSystemHostName, __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0/*SPI*/)) - #define kSCPropSystemHostName \ - SC_SCHEMA_KV(kSCPropSystemHostName \ - ,"HostName" \ - ,CFString ) - - SC_SCHEMA_DECLARATION(kSCPropVirtualNetworkInterfacesBondInterfaces, __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0/*SPI*/)) - #define kSCPropVirtualNetworkInterfacesBondInterfaces \ - SC_SCHEMA_KV(kSCPropVirtualNetworkInterfacesBondInterfaces \ - ,"Interfaces" \ - ,CFArray[CFString] ) - - SC_SCHEMA_DECLARATION(kSCPropVirtualNetworkInterfacesBondMode, __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0/*SPI*/)) - #define kSCPropVirtualNetworkInterfacesBondMode \ - SC_SCHEMA_KV(kSCPropVirtualNetworkInterfacesBondMode \ - ,"Mode" \ - ,CFNumber ) - - SC_SCHEMA_DECLARATION(kSCPropVirtualNetworkInterfacesBondOptions, __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0/*SPI*/)) - #define kSCPropVirtualNetworkInterfacesBondOptions \ - SC_SCHEMA_KV(kSCPropVirtualNetworkInterfacesBondOptions \ - ,"Options" \ - ,CFDictionary ) - - SC_SCHEMA_DECLARATION(kSCPropVirtualNetworkInterfacesBridgeInterfaces, __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_4_0/*SPI*/)) - #define kSCPropVirtualNetworkInterfacesBridgeInterfaces \ - SC_SCHEMA_KV(kSCPropVirtualNetworkInterfacesBridgeInterfaces \ - ,"Interfaces" \ - ,CFArray[CFString] ) - - SC_SCHEMA_DECLARATION(kSCPropVirtualNetworkInterfacesBridgeOptions, __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_4_0/*SPI*/)) - #define kSCPropVirtualNetworkInterfacesBridgeOptions \ - SC_SCHEMA_KV(kSCPropVirtualNetworkInterfacesBridgeOptions \ - ,"Options" \ - ,CFDictionary ) - - SC_SCHEMA_DECLARATION(kSCPropVirtualNetworkInterfacesVLANInterface, __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0/*SPI*/)) - #define kSCPropVirtualNetworkInterfacesVLANInterface \ - SC_SCHEMA_KV(kSCPropVirtualNetworkInterfacesVLANInterface \ - ,"Interface" \ - ,CFString ) - - SC_SCHEMA_DECLARATION(kSCPropVirtualNetworkInterfacesVLANTag, __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0/*SPI*/)) - #define kSCPropVirtualNetworkInterfacesVLANTag \ - SC_SCHEMA_KV(kSCPropVirtualNetworkInterfacesVLANTag \ - ,"Tag" \ - ,CFNumber ) - - SC_SCHEMA_DECLARATION(kSCPropVirtualNetworkInterfacesVLANOptions, __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0/*SPI*/)) - #define kSCPropVirtualNetworkInterfacesVLANOptions \ - SC_SCHEMA_KV(kSCPropVirtualNetworkInterfacesVLANOptions \ - ,"Options" \ - ,CFDictionary ) + @discussion Value is a CFDictionary + */ +extern const CFStringRef kSCPropVirtualNetworkInterfacesVLANOptions __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0/*SPI*/); +#define kSCPropVirtualNetworkInterfacesVLANOptions kSCPropVirtualNetworkInterfacesVLANOptions + #endif /* _SCSCHEMADEFINITIONSPRIVATE_H */ diff --git a/SystemConfiguration.fproj/SNHelper.c b/SystemConfiguration.fproj/SNHelper.c index 097232b..4049557 100644 --- a/SystemConfiguration.fproj/SNHelper.c +++ b/SystemConfiguration.fproj/SNHelper.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2014 Apple Inc. + * Copyright (c) 2013-2015 Apple Inc. * All rights reserved. */ #include @@ -18,9 +18,9 @@ create_connection(dispatch_queue_t queue) xpc_connection_set_event_handler(new_connection, ^(xpc_object_t message) { if (isa_xpc_error(message)) { - syslog(LOG_INFO, "Got an error on the snhelper connection"); + syslog(LOG_INFO, "Got an error on the SNHelper connection"); } else if (isa_xpc_dictionary(message)) { - syslog(LOG_INFO, "Got an unexpected message on the snhelper connection"); + syslog(LOG_INFO, "Got an unexpected message on the SNHelper connection"); } }); xpc_connection_resume(new_connection); diff --git a/SystemConfiguration.fproj/SystemConfiguration.h b/SystemConfiguration.fproj/SystemConfiguration.h index 9cb4bc2..70044ab 100644 --- a/SystemConfiguration.fproj/SystemConfiguration.h +++ b/SystemConfiguration.fproj/SystemConfiguration.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000-2004, 2006, 2008-2010, 2012 Apple Inc. All rights reserved. + * Copyright (c) 2000-2004, 2006, 2008-2010, 2012, 2015 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -136,6 +136,9 @@ enum { #include #include +CF_IMPLICIT_BRIDGING_ENABLED +CF_ASSUME_NONNULL_BEGIN + /*! @const kCFErrorDomainSystemConfiguration @discussion CFError domain associated with errors reported by @@ -172,4 +175,7 @@ const char * SCErrorString (int status) __OSX_AVAILABLE_STARTING(__MAC_10_1,_ __END_DECLS +CF_ASSUME_NONNULL_END +CF_IMPLICIT_BRIDGING_DISABLED + #endif /* _SYSTEMCONFIGURATION_H */ diff --git a/SystemConfiguration.fproj/VLANConfiguration.c b/SystemConfiguration.fproj/VLANConfiguration.c index badc2c7..8c37733 100644 --- a/SystemConfiguration.fproj/VLANConfiguration.c +++ b/SystemConfiguration.fproj/VLANConfiguration.c @@ -1,15 +1,15 @@ /* - * Copyright (c) 2003-2013 Apple Inc. All rights reserved. + * Copyright (c) 2003-2013, 2015 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ - * + * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. - * + * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, @@ -17,7 +17,7 @@ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. - * + * * @APPLE_LICENSE_HEADER_END@ */ @@ -64,7 +64,7 @@ inet_dgram_socket() s = socket(AF_INET, SOCK_DGRAM, 0); if (s == -1) { - SCLog(TRUE, LOG_ERR, CFSTR("socket() failed: %s"), strerror(errno)); + SC_log(LOG_ERR, "socket() failed: %s", strerror(errno)); } return s; @@ -221,7 +221,7 @@ SCVLANInterfaceCopyAll(SCPreferencesRef prefs) CFDictionaryRef dict; SCPreferencesRef ni_prefs; CFStringRef path; - + if ((prefs == NULL) || (__SCPreferencesUsingDefaultPrefs(prefs) == TRUE)) { ni_prefs = NULL; @@ -349,7 +349,7 @@ _SCVLANInterfaceCopyActive(void) CFMutableArrayRef vlans = NULL; if (getifaddrs(&ifap) == -1) { - SCLog(TRUE, LOG_ERR, CFSTR("getifaddrs() failed: %s"), strerror(errno)); + SC_log(LOG_NOTICE, "getifaddrs() failed: %s", strerror(errno)); _SCErrorSet(kSCStatusFailed); return NULL; } @@ -387,7 +387,7 @@ _SCVLANInterfaceCopyActive(void) ifr.ifr_data = (caddr_t)&vreq; if (ioctl(s, SIOCGIFVLAN, (caddr_t)&ifr) == -1) { - SCLog(TRUE, LOG_ERR, CFSTR("ioctl(SIOCGIFVLAN) failed: %s"), strerror(errno)); + SC_log(LOG_NOTICE, "ioctl(SIOCGIFVLAN) failed: %s", strerror(errno)); CFRelease(vlans); vlans = NULL; _SCErrorSet(kSCStatusFailed); @@ -443,7 +443,7 @@ SCVLANInterfaceCreate(SCPreferencesRef prefs, SCNetworkInterfaceRef physical, CF _SCErrorSet(kSCStatusInvalidArgument); return NULL; } - + if (!isA_SCNetworkInterface(physical)) { _SCErrorSet(kSCStatusInvalidArgument); return NULL; @@ -616,7 +616,7 @@ SCVLANInterfaceSetPhysicalInterfaceAndTag(SCVLANInterfaceRef vlan, SCNetworkInte SCNetworkInterfacePrivateRef interfacePrivate; Boolean ok = TRUE; SCPreferencesRef prefs; - + if (!isA_SCVLANInterface(vlan)) { _SCErrorSet(kSCStatusInvalidArgument); return FALSE; @@ -629,7 +629,7 @@ SCVLANInterfaceSetPhysicalInterfaceAndTag(SCVLANInterfaceRef vlan, SCNetworkInte interfacePrivate = (SCNetworkInterfacePrivateRef)physical; prefs = interfacePrivate->prefs; - + if (!interfacePrivate->supportsVLAN) { if (__SCPreferencesUsingDefaultPrefs(prefs) == FALSE) { interfacePrivate->supportsVLAN = TRUE; @@ -882,7 +882,7 @@ __vlan_set(int s, CFStringRef interface_if, CFStringRef physical_if, CFNumberRef // update physical interface and tag if (ioctl(s, SIOCSIFVLAN, (caddr_t)&ifr) == -1) { - SCLog(TRUE, LOG_ERR, CFSTR("ioctl(SIOCSIFVLAN) failed: %s"), strerror(errno)); + SC_log(LOG_NOTICE, "ioctl(SIOCSIFVLAN) failed: %s", strerror(errno)); _SCErrorSet(kSCStatusFailed); return FALSE; } @@ -915,7 +915,7 @@ __vlan_clear(int s, CFStringRef interface_if) // update physical interface and tag if (ioctl(s, SIOCSIFVLAN, (caddr_t)&ifr) == -1) { - SCLog(TRUE, LOG_ERR, CFSTR("ioctl(SIOCSIFVLAN) failed: %s"), strerror(errno)); + SC_log(LOG_NOTICE, "ioctl(SIOCSIFVLAN) failed: %s", strerror(errno)); _SCErrorSet(kSCStatusFailed); return FALSE; } diff --git a/SystemConfiguration.fproj/VPNAppLayer.c b/SystemConfiguration.fproj/VPNAppLayer.c index b6763c5..991a54e 100644 --- a/SystemConfiguration.fproj/VPNAppLayer.c +++ b/SystemConfiguration.fproj/VPNAppLayer.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012-2014 Apple Inc. + * Copyright (c) 2012-2015 Apple Inc. * All rights reserved. */ diff --git a/SystemConfiguration.fproj/VPNAppLayerPrivate.h b/SystemConfiguration.fproj/VPNAppLayerPrivate.h index b6763c5..991a54e 100644 --- a/SystemConfiguration.fproj/VPNAppLayerPrivate.h +++ b/SystemConfiguration.fproj/VPNAppLayerPrivate.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012-2014 Apple Inc. + * Copyright (c) 2012-2015 Apple Inc. * All rights reserved. */ diff --git a/SystemConfiguration.fproj/VPNConfiguration.c b/SystemConfiguration.fproj/VPNConfiguration.c index 834c983..d1a8d1a 100644 --- a/SystemConfiguration.fproj/VPNConfiguration.c +++ b/SystemConfiguration.fproj/VPNConfiguration.c @@ -1,4 +1,4 @@ /* - * Copyright (c) 2009-2014 Apple Inc. All rights reserved. + * Copyright (c) 2009-2015 Apple Inc. All rights reserved. */ diff --git a/SystemConfiguration.fproj/VPNFlow.c b/SystemConfiguration.fproj/VPNFlow.c index ea516fb..8033ce0 100644 --- a/SystemConfiguration.fproj/VPNFlow.c +++ b/SystemConfiguration.fproj/VPNFlow.c @@ -1,4 +1,4 @@ /* - * Copyright (c) 2012-2014 Apple Inc. All rights reserved. + * Copyright (c) 2012-2015 Apple Inc. All rights reserved. */ diff --git a/SystemConfiguration.fproj/VPNFlow.h b/SystemConfiguration.fproj/VPNFlow.h index d286c3d..8033ce0 100644 --- a/SystemConfiguration.fproj/VPNFlow.h +++ b/SystemConfiguration.fproj/VPNFlow.h @@ -1,4 +1,4 @@ /* - * Copyright (c) 2012-2013 Apple Inc. All rights reserved. + * Copyright (c) 2012-2015 Apple Inc. All rights reserved. */ diff --git a/SystemConfiguration.fproj/VPNFlowPrivate.h b/SystemConfiguration.fproj/VPNFlowPrivate.h deleted file mode 100644 index ea516fb..0000000 --- a/SystemConfiguration.fproj/VPNFlowPrivate.h +++ /dev/null @@ -1,4 +0,0 @@ -/* - * Copyright (c) 2012-2014 Apple Inc. All rights reserved. - */ - diff --git a/SystemConfiguration.fproj/VPNTunnelPrivate.h b/SystemConfiguration.fproj/VPNTunnelPrivate.h index 58acb55..f111c3e 100644 --- a/SystemConfiguration.fproj/VPNTunnelPrivate.h +++ b/SystemConfiguration.fproj/VPNTunnelPrivate.h @@ -1,4 +1,4 @@ /* - * Copyright (c) 2009-2013 Apple Inc. All rights reserved. + * Copyright (c) 2009-2013, 2015 Apple Inc. All rights reserved. */ diff --git a/SystemConfiguration.fproj/dy_framework.c b/SystemConfiguration.fproj/dy_framework.c index 8af8be9..9ec21fd 100644 --- a/SystemConfiguration.fproj/dy_framework.c +++ b/SystemConfiguration.fproj/dy_framework.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002-2008, 2010-2014 Apple Inc. All rights reserved. + * Copyright (c) 2002-2008, 2010-2015 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -34,6 +34,7 @@ #include #include +#include #include "dy_framework.h" @@ -631,4 +632,3 @@ _SecCertificateCreateWithData(CFAllocatorRef allocator, CFDataRef data) - diff --git a/SystemConfiguration.fproj/dy_framework.h b/SystemConfiguration.fproj/dy_framework.h index c37e1ca..d781b38 100644 --- a/SystemConfiguration.fproj/dy_framework.h +++ b/SystemConfiguration.fproj/dy_framework.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002-2008, 2010-2014 Apple Inc. All rights reserved. + * Copyright (c) 2002-2008, 2010-2015 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -404,7 +404,6 @@ _SecCertificateCreateWithData ( - __END_DECLS #endif // _DY_FRAMEWORK_H diff --git a/SystemConfiguration.fproj/genSCPreferences.c b/SystemConfiguration.fproj/genSCPreferences.c index 7689c0e..bf70d86 100644 --- a/SystemConfiguration.fproj/genSCPreferences.c +++ b/SystemConfiguration.fproj/genSCPreferences.c @@ -1,15 +1,15 @@ /* - * Copyright (c) 2000-2014 Apple Inc. All rights reserved. + * Copyright (c) 2000-2015 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ - * + * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. - * + * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, @@ -17,7 +17,7 @@ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. - * + * * @APPLE_LICENSE_HEADER_END@ */ @@ -31,6 +31,9 @@ /* * Modification History * + * 12 March 2015 Sushant Chavan (sushant_chavan@apple.com) + * - cleanup of SC_SCHEMA_DECLARATION and SC_SCHEMA_KV macros. + * * 4 March 2004 Allan Nathanson (ajn@apple.com) * - an alternate scheme to help facilitate access to the schema * definitions for cross-compilation to earlier releases AND @@ -59,17 +62,17 @@ char copyright_string[] = "/*\n" -" * Copyright (c) 2000-2014 Apple Inc. All rights reserved.\n" +" * Copyright (c) 2000-2015 Apple Inc. All rights reserved.\n" " *\n" " * @APPLE_LICENSE_HEADER_START@\n" -" * \n" +" *\n" " * This file contains Original Code and/or Modifications of Original Code\n" " * as defined in and that are subject to the Apple Public Source License\n" " * Version 2.0 (the 'License'). You may not use this file except in\n" " * compliance with the License. Please obtain a copy of the License at\n" " * http://www.opensource.apple.com/apsl/ and read it before using this\n" " * file.\n" -" * \n" +" *\n" " * The Original Code and all software distributed under the License are\n" " * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER\n" " * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,\n" @@ -77,7 +80,7 @@ char copyright_string[] = " * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.\n" " * Please see the License for the specific language governing rights and\n" " * limitations under the License.\n" -" * \n" +" *\n" " * @APPLE_LICENSE_HEADER_END@\n" " */\n"; @@ -116,6 +119,7 @@ typedef enum { SC_10_9_IPHONE_7_0_PRIVATE, SC_10_10_IPHONE_7_0_PRIVATE, SC_10_10_IPHONE_8_0_PRIVATE, + SC_10_11_IPHONE_9_0_PRIVATE, SC_IPHONE_2_0_PRIVATE, COMMENT_DEPRECATED, GROUP_DEPRECATED, @@ -230,6 +234,7 @@ typedef enum { #define DHCPCLIENTID "DHCPClientID" #define DIALMODE "DialMode" #define DIALONDEMAND "DialOnDemand" +#define DISABLEUNTILNEEDED "DisableUntilNeeded" #define DISCONNECT "Disconnect" #define DISCONNECTONANSWER "DisconnectOnAnswer" #define DISCONNECTONFASTUSERSWITCH "DisconnectOnFastUserSwitch" @@ -419,6 +424,7 @@ typedef enum { #define SERVERS "Servers" #define SERVICE "Service" #define SERVICES "Services" +#define SERVICEID "ServiceID" #define SERVICEIDS "ServiceIDs" #define SESSIONTIMER "SessionTimer" #define SETS "Sets" @@ -429,6 +435,7 @@ typedef enum { #define SOCKS "SOCKS" #define SORTLIST "SortList" #define SPEAKER "Speaker" +#define SPECIFIC "Specific" #define SPEED "Speed" #define SSID "SSID" #define STATE "State" @@ -502,7 +509,9 @@ static schemaDefinition names[] = { { COMMENT, "", NULL, NULL, NULL }, { GROUP_PRIVATE, NULL, "Generic Keys", NULL, NULL }, + { SC_10_5_PRIVATE, NETPROP, IGNORELINKSTATUS, NULL, CFBOOLEAN }, { SC_10_10_IPHONE_8_0_PRIVATE, PROP, CONFIRMED INTERFACENAME, NULL, CFSTRING }, + { SC_10_11_IPHONE_9_0_PRIVATE, PROP, DISABLEUNTILNEEDED, NULL, CFNUMBER_BOOL }, { COMMENT_PRIVATE, "", NULL, NULL, NULL }, @@ -574,7 +583,7 @@ static schemaDefinition names[] = { { SC_10_10_IPHONE_8_0_PRIVATE, NETENT, IPV4 ROUTER ARP FAILURE, NULL, NULL}, { SC_10_10_IPHONE_8_0_PRIVATE, NETENT, IPV4 ROUTER ARP ALIVE, NULL, NULL}, { SC_10_9_IPHONE_7_0_PRIVATE, NETENT, LINKISSUES, NULL, CFDICTIONARY}, - { SC_10_7_IPHONE_5_0_PRIVATE, NETENT, LINKQUALITY, NULL, CFDICTIONARY}, + { SC_10_7_IPHONE_5_0_PRIVATE, NETENT, LINKQUALITY, NULL, CFDICTIONARY}, { SC_10_7_IPHONE_4_0_PRIVATE, NETENT, LOOPBACK, NULL, CFDICTIONARY }, { SC_10_6_IPHONE_3_0_PRIVATE, NETENT, ONDEMAND, NULL, CFDICTIONARY }, { SC_10_6_IPHONE_2_0_PRIVATE, NETENT, SERVICE, "__SERVICE__", CFDICTIONARY }, @@ -588,11 +597,6 @@ static schemaDefinition names[] = { { SC_10_1, NETPROP, PPP OVERRIDEPRIMARY, NULL, CFNUMBER_BOOL }, { COMMENT, "", NULL, NULL, NULL }, - { GROUP_PRIVATE, NETPROP, KEY_PREFIX COMP NETWORK " Properties", NULL, NULL }, - - { SC_10_5_PRIVATE, NETPROP, IGNORELINKSTATUS, NULL, CFBOOLEAN }, - { COMMENT_PRIVATE, "", NULL, NULL, NULL }, - { GROUP, NETPROP INTERFACES, KEY_PREFIX COMP NETWORK INTERFACE " Properties", NULL, NULL }, { SC_10_2, NETPROP, INTERFACES, NULL, CFARRAY_CFSTRING }, @@ -661,6 +665,7 @@ static schemaDefinition names[] = { { GROUP_PRIVATE, NETPROP DNS, KEY_PREFIX NETENT DNS " Entity Keys", NULL, NULL }, + { SC_10_11_IPHONE_9_0_PRIVATE, NETPROP DNS, CONFIRMED SERVICEID, NULL, CFSTRING }, { SC_10_9_IPHONE_7_0_PRIVATE, NETPROP DNS, SERVICE IDENTIFIER, NULL, CFNUMBER }, { SC_10_9_IPHONE_7_0_PRIVATE, NETPROP DNS, SUPPLEMENTAL MATCH DOMAINS NO SEARCH, NULL, CFNUMBER_BOOL}, { COMMENT_PRIVATE, "", NULL, NULL, NULL }, @@ -856,7 +861,7 @@ static schemaDefinition names[] = { { GROUP_PRIVATE, NETPROP LINK, KEY_PREFIX NETENT LINK " Entity Keys", NULL, NULL }, { SC_10_10_IPHONE_8_0_PRIVATE, NETPROP LINK, EXPENSIVE, NULL, CFBOOLEAN }, { COMMENT_PRIVATE, "", NULL, NULL, NULL }, - + { GROUP_PRIVATE, NETPROP LINK, KEY_PREFIX NETENT LINKISSUES " Entity Keys", NULL, NULL }, { SC_10_9_IPHONE_7_0_PRIVATE, NETPROP LINKISSUES, MODULEID, NULL, CFDATA }, @@ -1087,6 +1092,7 @@ static schemaDefinition names[] = { { SC_10_9_IPHONE_6_0_PRIVATE, NETPROP PROXIES, FALLBACK ALLOWED, NULL, CFNUMBER_BOOL }, { SC_10_7_IPHONE_5_0_PRIVATE, NETPROP PROXIES, SUPPLEMENTAL MATCH DOMAINS, NULL, CFARRAY_CFSTRING}, { SC_10_7_IPHONE_5_0_PRIVATE, NETPROP PROXIES, SUPPLEMENTAL MATCH ORDERS, NULL, CFARRAY_CFNUMBER}, + { SC_10_11_IPHONE_9_0_PRIVATE, NETPROP PROXIES, SERVICE SPECIFIC, NULL, CFNUMBER_BOOL }, { COMMENT_PRIVATE, "", NULL, NULL, NULL }, { SC_10_7_IPHONE_5_0_PRIVATE, NETPROP PROXIES, SCOPED, "__SCOPED__", CFDICTIONARY}, { SC_10_9_IPHONE_7_0_PRIVATE, NETPROP PROXIES, SERVICES, "__SERVICES__", CFDICTIONARY}, @@ -1278,33 +1284,12 @@ static schemaDefinition names[] = { { END, NULL, NULL, NULL, NULL }, }; -static int maxkbuf = 0; -static char *maxkstr = NULL; -static int maxvbuf = 0; -static char *maxvstr = NULL; - -static __inline__ void -setmax(int *max, char **maxstr, char *str) -{ - int l; - - l = strlen(str); - if (l > *max) { - if (*maxstr) free(*maxstr); - *maxstr = strdup(str); - *max = l; - } - return; -} - enum { gen_header_e, gen_comments_e, gen_comments_private_e, gen_headerdoc_e, gen_headerdoc_private_e, - gen_hfile_e, - gen_hfile_private_e, gen_cfile_e, }; @@ -1344,205 +1329,107 @@ print_headerdoc(schemaDefinition *def) snprintf(kbuf, sizeof(kbuf), KEY_PREFIX "%s%s", def->prefix, def->key); - setmax(&maxkbuf, &maxkstr, kbuf); snprintf(vbuf, sizeof(vbuf), "\"%s\"", def->value ? def->value : def->key); - setmax(&maxvbuf, &maxvstr, vbuf); - printf("\n"); + printf("\n"); printf("/*!\n"); printf(" @const %s\n", kbuf); - switch (def->control) { - case SC_10_1: - printf(" @availability Introduced in Mac OS X 10.1.\n"); - break; - case SC_10_2: - printf(" @availability Introduced in Mac OS X 10.2.\n"); - break; - case SC_10_3: - printf(" @availability Introduced in Mac OS X 10.3.\n"); - break; - case SC_10_1_10_4: - printf(" @availability Introduced in Mac OS X 10.1, but later deprecated in Mac OS X 10.4.\n"); - break; - case SC_10_4: - printf(" @availability Introduced in Mac OS X 10.4.\n"); - break; - case SC_10_1_10_5: - printf(" @availability Introduced in Mac OS X 10.1, but later deprecated in Mac OS X 10.5.\n"); - break; - case SC_10_5: - printf(" @availability Introduced in Mac OS X 10.5.\n"); - break; - case SC_10_5_10_7: - printf(" @availability Introduced in Mac OS X 10.5, but later deprecated in Mac OS X 10.7.\n"); - break; - case SC_10_5_PRIVATE: - printf(" @availability Introduced in Mac OS X 10.5.\n"); - break; - case SC_10_1_10_6: - printf(" @availability Introduced in Mac OS X 10.1, but later deprecated in Mac OS X 10.6.\n"); - break; - case SC_10_2_10_6: - printf(" @availability Introduced in Mac OS X 10.2, but later deprecated in Mac OS X 10.6.\n"); - break; - case SC_10_1_10_9: - printf(" @availability Introduced in Mac OS X 10.1, but later deprecated in Mac OS X 10.9.\n"); - break; - case SC_10_2_10_9: - printf(" @availability Introduced in Mac OS X 10.2, but later deprecated in Mac OS X 10.9.\n"); - break; - case SC_10_3_10_9: - printf(" @availability Introduced in Mac OS X 10.3, but later deprecated in Mac OS X 10.9.\n"); - break; - case SC_10_4_10_9: - printf(" @availability Introduced in Mac OS X 10.4, but later deprecated in Mac OS X 10.9.\n"); - break; - case SC_10_6_IPHONE_2_0: - case SC_10_6_IPHONE_2_0_PRIVATE: - printf(" @availability Introduced in Mac OS X 10.6.\n"); - break; - case SC_10_6_IPHONE_3_0: - case SC_10_6_IPHONE_3_0_PRIVATE: - printf(" @availability Introduced in Mac OS X 10.6.\n"); - break; - case SC_10_7_IPHONE_4_0: - case SC_10_7_IPHONE_4_0_PRIVATE: - case SC_10_7_IPHONE_5_0_PRIVATE: - printf(" @availability Introduced in Mac OS X 10.7.\n"); - break; - case SC_10_8_IPHONE_6_0_PRIVATE: - printf(" @availability Introduced in Mac OS X 10.8.\n"); - break; - case SC_10_9_IPHONE_6_0_PRIVATE: - case SC_10_9_IPHONE_7_0_PRIVATE: - printf(" @availability Introduced in Mac OS X 10.9.\n"); - break; - case SC_10_10_IPHONE_7_0_PRIVATE: - case SC_10_10_IPHONE_8_0_PRIVATE: - printf(" @availability Introduced in Mac OS X 10.10.\n"); - break; - case SC_IPHONE_2_0_PRIVATE: - printf(" @availability Introduced in iPhone OS 2.0.\n"); - break; + if (def->type) { + printf(" @discussion Value is a %s\n", def->type); } printf(" */\n"); - printf("extern const CFStringRef %s;\n", kbuf); - - return; -} - -void -print_hfile(schemaDefinition *def) -{ - char kbuf[256]; - char vbuf[256]; - - snprintf(kbuf, sizeof(kbuf), KEY_PREFIX "%s%s", - def->prefix, def->key); - setmax(&maxkbuf, &maxkstr, kbuf); - - snprintf(vbuf, sizeof(vbuf), "\"%s\"", - def->value ? def->value : def->key); - setmax(&maxvbuf, &maxvstr, vbuf); - - printf("\n"); - + printf("extern const CFStringRef %-49s", kbuf); switch (def->control) { case SC_10_1: - printf(" " SC_SCHEMA_DECLARATION "(%s, __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/))\n", kbuf); + printf(" __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/);\n"); break; case SC_10_2: - printf(" " SC_SCHEMA_DECLARATION "(%s, __OSX_AVAILABLE_STARTING(__MAC_10_2,__IPHONE_2_0/*SPI*/))\n", kbuf); + printf(" __OSX_AVAILABLE_STARTING(__MAC_10_2,__IPHONE_2_0/*SPI*/);\n"); break; case SC_10_3: - printf(" " SC_SCHEMA_DECLARATION "(%s, __OSX_AVAILABLE_STARTING(__MAC_10_3,__IPHONE_2_0/*SPI*/))\n", kbuf); + printf(" __OSX_AVAILABLE_STARTING(__MAC_10_3,__IPHONE_2_0/*SPI*/);\n"); break; case SC_10_1_10_4: - printf(" " SC_SCHEMA_DECLARATION "(%s, __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1,__MAC_10_4,__IPHONE_NA,__IPHONE_NA))\n", kbuf); + printf(" __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1,__MAC_10_4,__IPHONE_NA,__IPHONE_NA);\n"); break; case SC_10_4: - printf(" " SC_SCHEMA_DECLARATION "(%s, __OSX_AVAILABLE_STARTING(__MAC_10_4,__IPHONE_2_0/*SPI*/))\n", kbuf); + printf(" __OSX_AVAILABLE_STARTING(__MAC_10_4,__IPHONE_2_0/*SPI*/);\n"); break; case SC_10_1_10_5: - printf(" " SC_SCHEMA_DECLARATION "(%s, __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1,__MAC_10_5,__IPHONE_NA,__IPHONE_NA))\n", kbuf); + printf(" __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1,__MAC_10_5,__IPHONE_NA,__IPHONE_NA);\n"); break; case SC_10_5: - printf(" " SC_SCHEMA_DECLARATION "(%s, __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0/*SPI*/))\n", kbuf); + printf(" __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0/*SPI*/);\n"); break; case SC_10_5_10_7: - printf(" " SC_SCHEMA_DECLARATION "(%s, __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_5,__MAC_10_7,__IPHONE_NA,__IPHONE_NA))\n", kbuf); + printf(" __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_5,__MAC_10_7,__IPHONE_NA,__IPHONE_NA);\n"); break; case SC_10_5_PRIVATE: - printf(" " SC_SCHEMA_DECLARATION "(%s, __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0/*SPI*/))\n", kbuf); + printf(" __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0/*SPI*/);\n"); break; case SC_10_1_10_6: - printf(" " SC_SCHEMA_DECLARATION "(%s, __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1,__MAC_10_6,__IPHONE_NA,__IPHONE_NA))\n", kbuf); + printf(" __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1,__MAC_10_6,__IPHONE_NA,__IPHONE_NA);\n"); break; case SC_10_2_10_6: - printf(" " SC_SCHEMA_DECLARATION "(%s, __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_2,__MAC_10_6,__IPHONE_NA,__IPHONE_NA))\n", kbuf); + printf(" __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_2,__MAC_10_6,__IPHONE_NA,__IPHONE_NA);\n"); break; case SC_10_1_10_9: - printf(" " SC_SCHEMA_DECLARATION "(%s, __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1,__MAC_10_9,__IPHONE_2_0/*SPI*/,__IPHONE_FUTURE/*SPI*/))\n", kbuf); + printf(" __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1,__MAC_10_9,__IPHONE_2_0/*SPI*/,__IPHONE_FUTURE/*SPI*/);\n"); break; case SC_10_2_10_9: - printf(" " SC_SCHEMA_DECLARATION "(%s, __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_2,__MAC_10_9,__IPHONE_2_0/*SPI*/,__IPHONE_FUTURE/*SPI*/))\n", kbuf); + printf(" __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_2,__MAC_10_9,__IPHONE_2_0/*SPI*/,__IPHONE_FUTURE/*SPI*/);\n"); break; case SC_10_3_10_9: - printf(" " SC_SCHEMA_DECLARATION "(%s, __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_3,__MAC_10_9,__IPHONE_2_0/*SPI*/,__IPHONE_FUTURE/*SPI*/))\n", kbuf); + printf(" __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_3,__MAC_10_9,__IPHONE_2_0/*SPI*/,__IPHONE_FUTURE/*SPI*/);\n"); break; case SC_10_4_10_9: - printf(" " SC_SCHEMA_DECLARATION "(%s, __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4,__MAC_10_9,__IPHONE_2_0/*SPI*/,__IPHONE_FUTURE/*SPI*/))\n", kbuf); + printf(" __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4,__MAC_10_9,__IPHONE_2_0/*SPI*/,__IPHONE_FUTURE/*SPI*/);\n"); break; case SC_10_6_IPHONE_2_0: case SC_10_6_IPHONE_2_0_PRIVATE: - printf(" " SC_SCHEMA_DECLARATION "(%s, __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_2_0/*SPI*/))\n", kbuf); + printf(" __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_2_0/*SPI*/);\n"); break; case SC_10_6_IPHONE_3_0: case SC_10_6_IPHONE_3_0_PRIVATE: - printf(" " SC_SCHEMA_DECLARATION "(%s, __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_3_0/*SPI*/))\n", kbuf); + printf(" __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_3_0/*SPI*/);\n"); break; case SC_10_7_IPHONE_4_0: case SC_10_7_IPHONE_4_0_PRIVATE: - printf(" " SC_SCHEMA_DECLARATION "(%s, __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_4_0/*SPI*/))\n", kbuf); + printf(" __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_4_0/*SPI*/);\n"); break; case SC_10_7_IPHONE_5_0_PRIVATE: - printf(" " SC_SCHEMA_DECLARATION "(%s, __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_5_0/*SPI*/))\n", kbuf); + printf(" __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_5_0/*SPI*/);\n"); break; case SC_10_8_IPHONE_6_0_PRIVATE: - printf(" " SC_SCHEMA_DECLARATION "(%s, __OSX_AVAILABLE_STARTING(__MAC_10_8,__IPHONE_6_0/*SPI*/))\n", kbuf); + printf(" __OSX_AVAILABLE_STARTING(__MAC_10_8,__IPHONE_6_0/*SPI*/);\n"); break; case SC_10_9_IPHONE_6_0_PRIVATE: - printf(" " SC_SCHEMA_DECLARATION "(%s, __OSX_AVAILABLE_STARTING(__MAC_10_9,__IPHONE_6_0/*SPI*/))\n", kbuf); + printf(" __OSX_AVAILABLE_STARTING(__MAC_10_9,__IPHONE_6_0/*SPI*/);\n"); break; case SC_10_9_IPHONE_7_0_PRIVATE: - printf(" " SC_SCHEMA_DECLARATION "(%s, __OSX_AVAILABLE_STARTING(__MAC_10_9,__IPHONE_7_0/*SPI*/))\n", kbuf); + printf(" __OSX_AVAILABLE_STARTING(__MAC_10_9,__IPHONE_7_0/*SPI*/);\n"); break; case SC_10_10_IPHONE_7_0_PRIVATE: - printf(" " SC_SCHEMA_DECLARATION "(%s, __OSX_AVAILABLE_STARTING(__MAC_10_10,__IPHONE_7_0/*SPI*/))\n", kbuf); + printf(" __OSX_AVAILABLE_STARTING(__MAC_10_10,__IPHONE_7_0/*SPI*/);\n"); break; case SC_10_10_IPHONE_8_0_PRIVATE: - printf(" " SC_SCHEMA_DECLARATION "(%s, __OSX_AVAILABLE_STARTING(__MAC_10_10,__IPHONE_8_0/*SPI*/))\n", kbuf); + printf(" __OSX_AVAILABLE_STARTING(__MAC_10_10,__IPHONE_8_0/*SPI*/);\n"); + break; + case SC_10_11_IPHONE_9_0_PRIVATE: + printf(" __OSX_AVAILABLE_STARTING(__MAC_10_11,__IPHONE_9_0/*SPI*/);\n"); break; case SC_IPHONE_2_0_PRIVATE: - printf(" " SC_SCHEMA_DECLARATION "(%s, __OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_2_0/*SPI*/))\n", kbuf); + printf(" __OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_2_0/*SPI*/);\n"); break; default: - printf(" " SC_SCHEMA_DECLARATION "(%s,)\n", kbuf); + printf("\n"); break; } - printf(" #define %-48s \\\n", - kbuf); - printf(" " SC_SCHEMA_KV "(%-48s \\\n", - kbuf); - printf(" ,%-48s \\\n", - vbuf); - printf(" ,%-48s )\n", - def->type ? def->type : ""); - + printf("#define %s %s\n", kbuf, kbuf); return; } @@ -1595,10 +1482,6 @@ dump_names(int type) case DEFINE: { switch (type) { - case gen_hfile_e: - printf("\n"); - print_define(&names[i]); - break; case gen_cfile_e: if ((strcmp(names[i].prefix, "#if") == 0) || (strcmp(names[i].prefix, "#ifdef") == 0) || @@ -1616,10 +1499,6 @@ dump_names(int type) case DEFINE_PRIVATE: { switch (type) { - case gen_hfile_private_e: - printf("\n"); - print_define(&names[i]); - break; case gen_cfile_e: if ((strcmp(names[i].prefix, "#if") == 0) || (strcmp(names[i].prefix, "#ifdef") == 0) || @@ -1712,6 +1591,7 @@ dump_names(int type) case SC_10_9_IPHONE_7_0_PRIVATE: case SC_10_10_IPHONE_7_0_PRIVATE: case SC_10_10_IPHONE_8_0_PRIVATE: + case SC_10_11_IPHONE_9_0_PRIVATE: case SC_IPHONE_2_0_PRIVATE: // don't report private definitions break; @@ -1742,6 +1622,7 @@ dump_names(int type) case SC_10_9_IPHONE_7_0_PRIVATE: case SC_10_10_IPHONE_7_0_PRIVATE: case SC_10_10_IPHONE_8_0_PRIVATE: + case SC_10_11_IPHONE_9_0_PRIVATE: case SC_IPHONE_2_0_PRIVATE: print_comment(&names[i]); break; @@ -1763,6 +1644,7 @@ dump_names(int type) case SC_10_9_IPHONE_7_0_PRIVATE: case SC_10_10_IPHONE_7_0_PRIVATE: case SC_10_10_IPHONE_8_0_PRIVATE: + case SC_10_11_IPHONE_9_0_PRIVATE: case SC_IPHONE_2_0_PRIVATE: // don't report private definitions break; @@ -1783,6 +1665,7 @@ dump_names(int type) case SC_10_9_IPHONE_7_0_PRIVATE: case SC_10_10_IPHONE_7_0_PRIVATE: case SC_10_10_IPHONE_8_0_PRIVATE: + case SC_10_11_IPHONE_9_0_PRIVATE: case SC_IPHONE_2_0_PRIVATE: print_headerdoc(&names[i]); break; @@ -1791,48 +1674,6 @@ dump_names(int type) break; } break; - - case gen_hfile_e: - switch (names[i].control) { - case SC_10_5_PRIVATE: - case SC_10_6_IPHONE_2_0_PRIVATE: - case SC_10_6_IPHONE_3_0_PRIVATE: - case SC_10_7_IPHONE_4_0_PRIVATE: - case SC_10_7_IPHONE_5_0_PRIVATE: - case SC_10_8_IPHONE_6_0_PRIVATE: - case SC_10_9_IPHONE_6_0_PRIVATE: - case SC_10_9_IPHONE_7_0_PRIVATE: - case SC_10_10_IPHONE_7_0_PRIVATE: - case SC_10_10_IPHONE_8_0_PRIVATE: - case SC_IPHONE_2_0_PRIVATE: - break; - // don't report private definitions - default: - print_hfile(&names[i]); - break; - } - break; - case gen_hfile_private_e: - switch (names[i].control) { - case SC_10_5_PRIVATE: - case SC_10_6_IPHONE_2_0_PRIVATE: - case SC_10_6_IPHONE_3_0_PRIVATE: - case SC_10_7_IPHONE_4_0_PRIVATE: - case SC_10_7_IPHONE_5_0_PRIVATE: - case SC_10_8_IPHONE_6_0_PRIVATE: - case SC_10_9_IPHONE_6_0_PRIVATE: - case SC_10_9_IPHONE_7_0_PRIVATE: - case SC_10_10_IPHONE_7_0_PRIVATE: - case SC_10_10_IPHONE_8_0_PRIVATE: - case SC_IPHONE_2_0_PRIVATE: - print_hfile(&names[i]); - break; - default: - // don't report public definitions - break; - } - break; - case gen_cfile_e: snprintf(kbuf, sizeof(kbuf), KEY_PREFIX "%s%s", names[i].prefix, names[i].key); @@ -1852,12 +1693,6 @@ dump_names(int type) } } done: - switch (type) { - case gen_hfile_e: - fprintf(stderr, "max key: length = %2d, string = %s\n", maxkbuf, maxkstr); - fprintf(stderr, "max val: length = %2d, string = %s\n", maxvbuf, maxvstr); - break; - } return; } @@ -1877,43 +1712,6 @@ main(int argc, char * argv[]) dump_names(gen_comments_e); printf(" */\n\n\n"); - printf("/*\n"); - printf(" * Note: The MACOSX_DEPLOYMENT_TARGET environment variable should be used\n"); - printf(" * when building an application targeted for an earlier version of\n"); - printf(" * Mac OS X. Please reference Technical Note TN2064 for more details.\n"); - printf(" */\n\n"); - - printf("/*\n"); - printf(" * Note: For Cocoa/Obj-C/Foundation applications accessing these preference\n"); - printf(" * keys you may want to consider the following :\n"); - printf(" *\n"); - printf(" * #define " SC_SCHEMA_DECLARATION "(k,q)\textern NSString * k;\n"); - printf(" * #import \n"); - printf(" */\n\n"); - - printf("/*\n"); - printf(" * Note: For CFM applications using these schema keys you may want to\n"); - printf(" * consider the following :\n"); - printf(" *\n"); - printf(" * #define " SC_SCHEMA_DECLARATION "(k,q)\n"); - printf(" * #define " SC_SCHEMA_KV "(k,v,t)\tlookup_SC_key( CFSTR( #k ) )\n"); - printf(" * #include \n"); - printf(" *\n"); - printf(" * CFStringRef lookup_SC_key(CFStringRef key)\n"); - printf(" * {\n"); - printf(" * // this function should [dynamically, on-demand] load the\n"); - printf(" * // SystemConfiguration.framework, look up the provided key,\n"); - printf(" * // and return the associated value.\n"); - printf(" * }\n"); - printf(" */\n\n"); - - printf("/*\n"); - printf(" * Note: Earlier versions of this header file defined a \"SCSTR\" macro\n"); - printf(" * which helped to facilitate Obj-C development. Use of this macro\n"); - printf(" * has been deprecated (in Mac OS X 10.4) in favor of the newer\n"); - printf(" * \"" SC_SCHEMA_DECLARATION "\" and \"" SC_SCHEMA_KV "\" macros\n"); - printf(" */\n\n\n"); - printf("#ifndef\t_SCSCHEMADEFINITIONS_H\n"); printf("#ifdef\tUSE_SYSTEMCONFIGURATION_PRIVATE_HEADERS\n"); printf("#include \n"); @@ -1921,46 +1719,24 @@ main(int argc, char * argv[]) printf("#define\t_SCSCHEMADEFINITIONS_H\n"); printf("\n"); - printf("/* -------------------- Macro declarations -------------------- */\n\n"); - printf("#include \n"); printf("#include \n"); + printf("#include \n"); printf("\n"); - printf("/*\n"); - printf(" * Define a schema key/value/type tuple\n"); - printf(" */\n"); - printf("#ifndef " SC_SCHEMA_KV "\n"); - printf(" #define " SC_SCHEMA_KV "(k,v,t)\tk\n"); - printf("#endif\n\n"); - - printf("/*\n"); - printf(" * Provide an \"extern\" for the key/value\n"); - printf(" */\n"); - printf("#ifndef " SC_SCHEMA_DECLARATION "\n"); - printf(" #ifndef SCSTR\n"); - printf(" #include \n"); - printf(" #define " SC_SCHEMA_DECLARATION "(k,q)\textern const CFStringRef k q;\n"); - printf(" #else\n"); - printf(" #import \n"); - printf(" #define " SC_SCHEMA_DECLARATION "(k,q)\textern NSString * k q;\n"); - printf(" #endif\n"); - printf("#endif\n"); - - printf("/* -------------------- HeaderDoc comments -------------------- */\n\n\n"); - printf("#if\t0\n"); printf("/*!\n"); printf(" *\t@header SCSchemaDefinitions\n"); - printf(" */\n"); - dump_names(gen_headerdoc_e); - printf("\n"); - printf("#endif\t/* 0 */\n\n\n"); + printf(" */\n\n"); - printf("/* -------------------- Schema declarations -------------------- */\n\n"); + printf("\n"); + printf("CF_ASSUME_NONNULL_BEGIN\n"); + + dump_names(gen_headerdoc_e); - dump_names(gen_hfile_e); printf("\n"); + printf("CF_ASSUME_NONNULL_END"); + printf("\n\n"); printf("#endif\t/* USE_SYSTEMCONFIGURATION_PRIVATE_HEADERS */\n"); printf("#endif\t/* _SCSCHEMADEFINITIONS_H */\n"); @@ -1977,22 +1753,13 @@ main(int argc, char * argv[]) printf("#define _SCSCHEMADEFINITIONSPRIVATE_H\n"); printf("\n"); - printf("/* -------------------- Macro declarations -------------------- */\n\n"); - printf("#include \n\n"); - printf("/* -------------------- HeaderDoc comments -------------------- */\n\n\n"); - printf("#if\t0\n"); printf("/*!\n"); printf(" *\t@header SCSchemaDefinitionsPrivate\n"); printf(" */\n"); dump_names(gen_headerdoc_private_e); - printf("\n"); - printf("#endif\t/* 0 */\n\n\n"); - - printf("/* -------------------- Schema declarations -------------------- */\n\n"); - dump_names(gen_hfile_private_e); - printf("\n"); + printf("\n\n"); printf("#endif\t/* _SCSCHEMADEFINITIONSPRIVATE_H */\n"); } diff --git a/SystemConfiguration.fproj/helper/SCHelper_client.c b/SystemConfiguration.fproj/helper/SCHelper_client.c index 7525dc1..fd7835a 100644 --- a/SystemConfiguration.fproj/helper/SCHelper_client.c +++ b/SystemConfiguration.fproj/helper/SCHelper_client.c @@ -1,15 +1,15 @@ /* - * Copyright (c) 2005-2008, 2010, 2011, 2013 Apple Inc. All rights reserved. + * Copyright (c) 2005-2008, 2010, 2011, 2013, 2015 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ - * + * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. - * + * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, @@ -17,7 +17,7 @@ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. - * + * * @APPLE_LICENSE_HEADER_END@ */ @@ -90,9 +90,8 @@ __SCHelperServerPort(kern_return_t *status) break; default : #ifdef DEBUG - SCLog(_sc_verbose, LOG_DEBUG, - CFSTR("__SCHelperServerPort bootstrap_look_up() failed: status=%s"), - bootstrap_strerror(*status)); + SC_log(LOG_INFO, "bootstrap_look_up() failed: status=%s", + bootstrap_strerror(*status)); #endif /* DEBUG */ break; } @@ -160,21 +159,20 @@ _SCHelperOpen(CFDataRef authorizationData, mach_port_t *helper_port) __MACH_PORT_DEBUG(TRUE, "*** _SCHelperOpen", *helper_port); if (*helper_port == MACH_PORT_NULL) { - SCLog(TRUE, LOG_ERR, - CFSTR("_SCHelperOpen: could not contact server: %s"), + SC_log(LOG_NOTICE, "could not contact \"" HELPER "\": %s", SCErrorString(status)); return FALSE; } ok = _SCHelperExec(*helper_port, SCHELPER_MSG_AUTH, authorizationData, &status, NULL); if (!ok) { - SCLog(TRUE, LOG_INFO, CFSTR("_SCHelperOpen: could not send authorization")); + SC_log(LOG_NOTICE, "could not send authorization"); goto error; } ok = (status == 0); if (!ok) { - SCLog(TRUE, LOG_INFO, CFSTR("could not start \"" HELPER "\", status = %u"), status); + SC_log(LOG_NOTICE, "could not start \"" HELPER "\", status = %u", status); goto error; } @@ -197,7 +195,7 @@ void _SCHelperClose(mach_port_t *helper_port) { if (!_SCHelperExec(*helper_port, SCHELPER_MSG_EXIT, NULL, NULL, NULL)) { - SCLog(TRUE, LOG_INFO, CFSTR("_SCHelperOpen: could not send exit request")); + SC_log(LOG_INFO, "could not send exit request"); } if (*helper_port != MACH_PORT_NULL) { @@ -269,7 +267,7 @@ _SCHelperExec(mach_port_t port, uint32_t msgID, CFDataRef data, uint32_t *status if (kr != MACH_SEND_INVALID_DEST) { // if we got an unexpected error - SCLog(TRUE, LOG_ERR, CFSTR("_SCHelperExec() failed: %s"), mach_error_string(kr)); + SC_log(LOG_NOTICE, "_SCHelperExec() failed: %s", mach_error_string(kr)); } _SCErrorSet(kr); @@ -290,7 +288,7 @@ _SCHelperExec(mach_port_t port, uint32_t msgID, CFDataRef data, uint32_t *status if (reply != NULL) { *reply = myData; } else if (myData != NULL) { - SCLog(TRUE, LOG_DEBUG, CFSTR("_SCHelperExec() data available with no place to go")); + SC_log(LOG_INFO, "data available with no place to go"); CFRelease(myData); } diff --git a/SystemConfiguration.fproj/helper/SCHelper_server.c b/SystemConfiguration.fproj/helper/SCHelper_server.c index 23ad5e0..28b7ece 100644 --- a/SystemConfiguration.fproj/helper/SCHelper_server.c +++ b/SystemConfiguration.fproj/helper/SCHelper_server.c @@ -1,15 +1,15 @@ /* - * Copyright (c) 2005-2014 Apple Inc. All rights reserved. + * Copyright (c) 2005-2015 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ - * + * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. - * + * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, @@ -17,7 +17,7 @@ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. - * + * * @APPLE_LICENSE_HEADER_END@ */ @@ -50,7 +50,7 @@ // -// entitlement used to control write access to a given "prefsID" +// entitlement used to control read (or write) access to a given "prefsID" // #define kSCReadEntitlementName CFSTR("com.apple.SystemConfiguration.SCPreferences-read-access") #define kSCWriteEntitlementName CFSTR("com.apple.SystemConfiguration.SCPreferences-write-access") @@ -165,8 +165,7 @@ __SCHelperSessionSetAuthorization(SCHelperSessionRef session, CFTypeRef authoriz status = AuthorizationFree(sessionPrivate->authorization, kAuthorizationFlagDefaults); // status = AuthorizationFree(sessionPrivate->authorization, kAuthorizationFlagDestroyRights); if (status != errAuthorizationSuccess) { - SCLog(TRUE, LOG_DEBUG, - CFSTR("AuthorizationFree() failed: status = %d"), + SC_log(LOG_DEBUG, "AuthorizationFree() failed: status = %d", (int)status); } } else { @@ -190,9 +189,8 @@ __SCHelperSessionSetAuthorization(SCHelperSessionRef session, CFTypeRef authoriz status = AuthorizationCreateFromExternalForm(&extForm, &sessionPrivate->authorization); if (status != errAuthorizationSuccess) { - SCLog(TRUE, LOG_ERR, - CFSTR("AuthorizationCreateFromExternalForm() failed: status = %d"), - (int)status); + SC_log(LOG_NOTICE, "AuthorizationCreateFromExternalForm() failed: status = %d", + (int)status); sessionPrivate->authorization = NULL; ok = FALSE; } @@ -285,16 +283,11 @@ __SCHelperSessionSetPreferences(SCHelperSessionRef session, SCPreferencesRef pre CFRetain(prefs); } if (sessionPrivate->prefs != NULL) { - SCLog(debug, LOG_DEBUG, - CFSTR("%p : close"), - session); + SC_log(LOG_INFO, "%p : close", session); CFRelease(sessionPrivate->prefs); } if (prefs != NULL) { - SCLog(debug, LOG_DEBUG, - CFSTR("%p : open, prefs = %@"), - session, - prefs); + SC_log(LOG_INFO, "%p : open, prefs = %@", session, prefs); } sessionPrivate->prefs = prefs; @@ -375,13 +368,12 @@ __SCHelperSessionLog(const void *value, void *context) if ((sessionPrivate->mp != NULL) && (sessionPrivate->prefs != NULL)) { SCPreferencesPrivateRef prefsPrivate = (SCPreferencesPrivateRef)sessionPrivate->prefs; - SCLog(TRUE, LOG_NOTICE, - CFSTR(" %p {port = %p, caller = %@, path = %s%s}"), - session, - (void *)(uintptr_t)CFMachPortGetPort(sessionPrivate->mp), - prefsPrivate->name, - prefsPrivate->newPath ? prefsPrivate->newPath : prefsPrivate->path, - prefsPrivate->locked ? ", locked" : ""); + SC_log(LOG_INFO, " %p {port = %p, caller = %@, path = %s%s}", + session, + (void *)(uintptr_t)CFMachPortGetPort(sessionPrivate->mp), + prefsPrivate->name, + prefsPrivate->newPath ? prefsPrivate->newPath : prefsPrivate->path, + prefsPrivate->locked ? ", locked" : ""); if ((sessionPrivate->backtraces != NULL) && (CFSetGetCount(sessionPrivate->backtraces) > 0)) { @@ -508,7 +500,7 @@ __SCHelperSessionCreate(CFAllocatorRef allocator) } if (pthread_mutex_init(&sessionPrivate->lock, NULL) != 0) { - SCLog(TRUE, LOG_ERR, CFSTR("pthread_mutex_init(): failure to initialize per session lock")); + SC_log(LOG_NOTICE, "pthread_mutex_init(): failure to initialize per session lock"); CFRelease(sessionPrivate); return NULL; } @@ -647,7 +639,7 @@ __SCHelperSessionLogBacktrace(const void *value, void *context) return; } - SCLog(TRUE, LOG_INFO, CFSTR("created backtrace log: %s"), path); + SC_log(LOG_INFO, "created backtrace log: %s", path); } SCPrint(TRUE, *logFile, CFSTR("%@\n"), backtrace); @@ -932,13 +924,13 @@ do_interface_refresh(SCHelperSessionRef session, void *info, CFDataRef data, uin if ((data != NULL) && !_SCUnserializeString(&ifName, data, NULL, 0)) { *status = kSCStatusInvalidArgument; - SCLog(TRUE, LOG_ERR, CFSTR("interface name not valid")); + SC_log(LOG_NOTICE, "interface name not valid"); return FALSE; } if (ifName == NULL) { *status = kSCStatusInvalidArgument; - SCLog(TRUE, LOG_ERR, CFSTR("interface name not valid")); + SC_log(LOG_NOTICE, "interface name not valid"); return FALSE; } @@ -946,14 +938,13 @@ do_interface_refresh(SCHelperSessionRef session, void *info, CFDataRef data, uin ok = _SCNetworkInterfaceForceConfigurationRefresh(ifName); if (!ok) { *status = SCError(); - SCLog(TRUE, LOG_ERR, - CFSTR("interface \"%@\" not refreshed: %s"), + SC_log(LOG_NOTICE, "interface \"%@\" not refreshed: %s", ifName, SCErrorString(*status)); } } else { *status = kSCStatusInvalidArgument; - SCLog(TRUE, LOG_ERR, CFSTR("interface name not valid")); + SC_log(LOG_NOTICE, "interface name not valid"); } CFRelease(ifName); @@ -985,12 +976,12 @@ do_prefs_Open(SCHelperSessionRef session, void *info, CFDataRef data, uint32_t * } if ((data != NULL) && !_SCUnserialize((CFPropertyListRef *)&prefsInfo, data, NULL, 0)) { - SCLog(TRUE, LOG_ERR, CFSTR("data not valid, %@"), data); + SC_log(LOG_NOTICE, "data not valid, %@", data); return FALSE; } if ((prefsInfo == NULL) || !isA_CFDictionary(prefsInfo)) { - SCLog(TRUE, LOG_ERR, CFSTR("info not valid")); + SC_log(LOG_NOTICE, "info not valid"); if (prefsInfo != NULL) CFRelease(prefsInfo); return FALSE; } @@ -1004,7 +995,7 @@ do_prefs_Open(SCHelperSessionRef session, void *info, CFDataRef data, uint32_t * CFStringHasSuffix(prefsID, CFSTR("/..")) || (CFStringFind(prefsID, CFSTR("/../"), 0).location != kCFNotFound)) { // if we're trying to escape from the preferences directory - SCLog(TRUE, LOG_ERR, CFSTR("prefsID (%@) not valid"), prefsID); + SC_log(LOG_NOTICE, "prefsID (%@) not valid", prefsID); CFRelease(prefsInfo); *status = kSCStatusInvalidArgument; return TRUE; @@ -1018,7 +1009,7 @@ do_prefs_Open(SCHelperSessionRef session, void *info, CFDataRef data, uint32_t * // get preferences session "name" name = CFDictionaryGetValue(prefsInfo, CFSTR("name")); if (!isA_CFString(name)) { - SCLog(TRUE, LOG_ERR, CFSTR("session \"name\" not valid")); + SC_log(LOG_NOTICE, "session \"name\" not valid"); CFRelease(prefsInfo); return FALSE; } @@ -1026,7 +1017,7 @@ do_prefs_Open(SCHelperSessionRef session, void *info, CFDataRef data, uint32_t * // get PID of caller pid = CFDictionaryGetValue(prefsInfo, CFSTR("PID")); if (!isA_CFNumber(pid)) { - SCLog(TRUE, LOG_ERR, CFSTR("PID not valid")); + SC_log(LOG_NOTICE, "PID not valid"); CFRelease(prefsInfo); return FALSE; } @@ -1034,7 +1025,7 @@ do_prefs_Open(SCHelperSessionRef session, void *info, CFDataRef data, uint32_t * // get process name of caller proc_name = CFDictionaryGetValue(prefsInfo, CFSTR("PROC_NAME")); if (!isA_CFString(proc_name)) { - SCLog(TRUE, LOG_ERR, CFSTR("process name not valid")); + SC_log(LOG_NOTICE, "process name not valid"); CFRelease(prefsInfo); return FALSE; } @@ -1174,12 +1165,16 @@ static Boolean do_prefs_Commit(SCHelperSessionRef session, void *info, CFDataRef data, uint32_t *status, CFDataRef *reply) { Boolean ok; - SCPreferencesRef prefs = __SCHelperSessionGetPreferences(session); - CFPropertyListRef prefsData = NULL; - SCPreferencesPrivateRef prefsPrivate = (SCPreferencesPrivateRef)prefs; + SCPreferencesRef prefs = __SCHelperSessionGetPreferences(session); + CFPropertyListRef prefsData = NULL; + SCPreferencesPrivateRef prefsPrivate = (SCPreferencesPrivateRef)prefs; + Boolean saveAccessed; + Boolean saveChanged; + CFMutableDictionaryRef savePrefs = NULL; + Boolean saveValid = FALSE; Boolean useSetFilter; Boolean useVPNFilter; - CFArrayRef vpnTypes = NULL; + CFArrayRef vpnTypes = NULL; if (prefs == NULL) { return FALSE; @@ -1293,20 +1288,39 @@ do_prefs_Commit(SCHelperSessionRef session, void *info, CFDataRef data, uint32_t } } - if (prefsPrivate->prefs != NULL) { - CFRelease(prefsPrivate->prefs); - } - prefsPrivate->prefs = CFDictionaryCreateMutableCopy(NULL, 0, prefsData); - prefsPrivate->accessed = TRUE; - prefsPrivate->changed = TRUE; + /* Take a backup of prefs, accessed bit, changed bit to + restore them IFF the commit fails. Pretend as if the + commit never happened! + */ + savePrefs = prefsPrivate->prefs; + saveAccessed = prefsPrivate->accessed; + saveChanged = prefsPrivate->changed; + + prefsPrivate->prefs = CFDictionaryCreateMutableCopy(NULL, 0, prefsData); + prefsPrivate->accessed = TRUE; + prefsPrivate->changed = TRUE; + saveValid = TRUE; commit : ok = SCPreferencesCommitChanges(prefs); if (ok) { + if (savePrefs != NULL) { + CFRelease(savePrefs); + } *reply = SCPreferencesGetSignature(prefs); CFRetain(*reply); } else { + /* Restore the backup we took earlier */ + if (saveValid) { + if (prefsPrivate->prefs != NULL) { + CFRelease(prefsPrivate->prefs); + } + + prefsPrivate->prefs = savePrefs; + prefsPrivate->accessed = saveAccessed; + prefsPrivate->changed = saveChanged; + } *status = SCError(); } @@ -1469,20 +1483,18 @@ copyEntitlement(SCHelperSessionRef session, CFStringRef entitlement) if (!CFEqual(domain, kCFErrorDomainMach) || ((code != kIOReturnInvalid) && (code != kIOReturnNotFound))) { // if unexpected error - SCLog(TRUE, LOG_ERR, - CFSTR("SecTaskCopyValueForEntitlement(,\"%@\",) failed, error = %@ : %@"), - entitlement, - error, - sessionName(session)); + SC_log(LOG_NOTICE, "SecTaskCopyValueForEntitlement(,\"%@\",) failed, error = %@ : %@", + entitlement, + error, + sessionName(session)); } CFRelease(error); } CFRelease(task); } else { - SCLog(TRUE, LOG_ERR, - CFSTR("SecTaskCreateWithAuditToken() failed: %@"), - sessionName(session)); + SC_log(LOG_NOTICE, "SecTaskCreateWithAuditToken() failed: %@", + sessionName(session)); } return value; @@ -1592,10 +1604,9 @@ checkEntitlement(SCHelperSessionRef session, CFStringRef prefsID, CFStringRef en hasEntitlement = TRUE; } } else { - SCLog(TRUE, LOG_ERR, - CFSTR("hasAuthorization() session=%@: entitlement=%@: not valid"), - sessionName(session), - entitlement_name); + SC_log(LOG_NOTICE, "hasAuthorization() session=%@: entitlement=%@: not valid", + sessionName(session), + entitlement_name); } CFRelease(entitlement); @@ -1665,9 +1676,8 @@ hasAuthorization(SCHelperSessionRef session, Boolean needWrite) flags, NULL); if (status != errAuthorizationSuccess) { - SCLog(TRUE, LOG_DEBUG, - CFSTR("AuthorizationCopyRights() failed: status = %d"), - (int)status); + SC_log(LOG_INFO, "AuthorizationCopyRights() failed: status = %d", + (int)status); return FALSE; } @@ -1690,10 +1700,9 @@ hasAuthorization(SCHelperSessionRef session, Boolean needWrite) if (sessionPrivate->callerWriteAccess == YES) { return TRUE; } else { - SCLog(TRUE, LOG_ERR, - CFSTR("SCPreferences write access to \"%@\" denied, no entitlement for \"%@\""), - prefsID, - sessionName(session)); + SC_log(LOG_NOTICE, "SCPreferences write access to \"%@\" denied, no entitlement for \"%@\"", + prefsID, + sessionName(session)); return FALSE; } } @@ -1710,10 +1719,9 @@ hasAuthorization(SCHelperSessionRef session, Boolean needWrite) return TRUE; } - SCLog(TRUE, LOG_ERR, - CFSTR("SCPreferences access to \"%@\" denied, no entitlement for \"%@\""), - prefsID, - sessionName(session)); + SC_log(LOG_NOTICE, "SCPreferences access to \"%@\" denied, no entitlement for \"%@\"", + prefsID, + sessionName(session)); return FALSE; } @@ -1793,9 +1801,9 @@ newHelper(void *arg) CFRunLoopAddSource(CFRunLoopGetCurrent(), rls, kCFRunLoopDefaultMode); CFRelease(rls); - SCLog(debug, LOG_DEBUG, CFSTR("%p : start"), session); + SC_log(LOG_INFO, "%p : start", session); CFRunLoopRun(); - SCLog(debug, LOG_DEBUG, CFSTR("%p : stop"), session); + SC_log(LOG_INFO, "%p : stop", session); } return NULL; @@ -1863,9 +1871,9 @@ notify_server(mach_msg_header_t *request, mach_msg_header_t *reply) break; } - SCLog(TRUE, LOG_ERR, CFSTR("HELP!, Received notification: port=%d, msgh_id=%d"), - Request->not_header.msgh_local_port, - Request->not_header.msgh_id); + SC_log(LOG_NOTICE, "HELP!, Received notification: port=%d, msgh_id=%d", + Request->not_header.msgh_local_port, + Request->not_header.msgh_id); Reply->NDR = NDR_record; Reply->RetCode = MIG_BAD_ID; @@ -1898,7 +1906,7 @@ helper_demux(mach_msg_header_t *request, mach_msg_header_t *reply) /* * unknown message ID, log and return an error. */ - SCLog(TRUE, LOG_ERR, CFSTR("helper_demux(): unknown message ID (%d) received"), request->msgh_id); + SC_log(LOG_NOTICE, "helper_demux(): unknown message ID (%d) received", request->msgh_id); reply->msgh_bits = MACH_MSGH_BITS(MACH_MSGH_BITS_REMOTE(request->msgh_bits), 0); reply->msgh_remote_port = request->msgh_remote_port; reply->msgh_size = sizeof(mig_reply_error_t); /* Minimal size */ @@ -1917,6 +1925,7 @@ helper_demux(mach_msg_header_t *request, mach_msg_header_t *reply) static void helperCallback(CFMachPortRef port, void *msg, CFIndex size, void *info) { + os_activity_t activity_id; mig_reply_error_t * bufRequest = msg; uint32_t bufReply_q[MACH_MSG_BUFFER_SIZE/sizeof(uint32_t)]; mig_reply_error_t * bufReply = (mig_reply_error_t *)bufReply_q; @@ -1924,15 +1933,17 @@ helperCallback(CFMachPortRef port, void *msg, CFIndex size, void *info) mach_msg_return_t mr; int options; + activity_id = os_activity_start("processing SCHelper request", + OS_ACTIVITY_FLAG_DEFAULT); + if (bufSize == 0) { // get max size for MiG reply buffers bufSize = _helper_subsystem.maxsize; // check if our on-the-stack reply buffer will be big enough if (bufSize > sizeof(bufReply_q)) { - SCLog(TRUE, LOG_NOTICE, - CFSTR("helperCallback(): buffer size should be increased > %d"), - _helper_subsystem.maxsize); + SC_log(LOG_NOTICE, "buffer size should be increased > %d", + _helper_subsystem.maxsize); } } @@ -2001,6 +2012,9 @@ helperCallback(CFMachPortRef port, void *msg, CFIndex size, void *info) if (bufReply != (mig_reply_error_t *)bufReply_q) CFAllocatorDeallocate(NULL, bufReply); + + os_activity_end(activity_id); + return; } @@ -2035,7 +2049,7 @@ _helperinit(mach_port_t server, session = __SCHelperSessionFindWithPort(server); if (session != NULL) { #ifdef DEBUG - SCLog(TRUE, LOG_DEBUG, CFSTR("_helperinit(): session is already open.")); + SC_log(LOG_DEBUG, "session is already open"); #endif /* DEBUG */ *status = kSCStatusFailed; /* you can't re-open an "open" session */ return KERN_SUCCESS; @@ -2046,11 +2060,9 @@ _helperinit(mach_port_t server, sessionPrivate = (SCHelperSessionPrivateRef)session; // create per-session port - kr = mach_port_allocate(mach_task_self(), - MACH_PORT_RIGHT_RECEIVE, - &sessionPrivate->port); + kr = mach_port_allocate(mach_task_self(), MACH_PORT_RIGHT_RECEIVE, &sessionPrivate->port); if (kr != KERN_SUCCESS) { - SCLog(TRUE, LOG_ERR, CFSTR("_helperinit(): mach_port_allocate() failed: %s"), mach_error_string(kr)); + SC_log(LOG_ERR, "mach_port_allocate() failed: %s", mach_error_string(kr)); *status = kr; goto done; } @@ -2083,7 +2095,7 @@ _helperinit(mach_port_t server, MACH_MSG_TYPE_MAKE_SEND_ONCE, &oldNotify); if (kr != KERN_SUCCESS) { - SCLog(TRUE, LOG_ERR, CFSTR("_helperinit() mach_port_request_notification() failed: %s"), mach_error_string(kr)); + SC_log(LOG_NOTICE, "mach_port_request_notification() failed: %s", mach_error_string(kr)); // clean up CFMachPort, mach port rights CFMachPortInvalidate(sessionPrivate->mp); @@ -2096,7 +2108,7 @@ _helperinit(mach_port_t server, } if (oldNotify != MACH_PORT_NULL) { - SCLog(TRUE, LOG_ERR, CFSTR("_helperinit(): oldNotify != MACH_PORT_NULL")); + SC_log(LOG_NOTICE, "oldNotify != MACH_PORT_NULL"); } // add send right (that will be passed back to the client) @@ -2177,23 +2189,21 @@ _helperexec(mach_port_t server, i = findCommand(msgID); if (i == -1) { - SCLog(TRUE, LOG_ERR, CFSTR("received unknown command : %u"), msgID); + SC_log(LOG_NOTICE, "received unknown command : %u", msgID); *status = kSCStatusInvalidArgument; goto done; } - SCLog(debug, LOG_DEBUG, - CFSTR("%p : processing command \"%s\"%s"), - session, - helpers[i].commandName, - (data != NULL) ? " w/data" : ""); + SC_log(LOG_INFO, "%p : processing command \"%s\"%s", + session, + helpers[i].commandName, + (data != NULL) ? " w/data" : ""); if (helpers[i].needsAuthorization && !hasAuthorization(session, helpers[i].needsWrite)) { - SCLog(debug, LOG_DEBUG, - CFSTR("%p : command \"%s\" : not authorized"), - session, - helpers[i].commandName); + SC_log(LOG_INFO, "%p : command \"%s\" : not authorized", + session, + helpers[i].commandName); *status = kSCStatusAccessError; } @@ -2207,11 +2217,10 @@ _helperexec(mach_port_t server, if ((*status != -1) || (reply != NULL)) { Boolean ok; - SCLog(debug, LOG_DEBUG, - CFSTR("%p : sending status %u%s"), - session, - *status, - (reply != NULL) ? " w/reply" : ""); + SC_log(LOG_INFO, "%p : sending status %u%s", + session, + *status, + (reply != NULL) ? " w/reply" : ""); /* serialize the data */ if (reply != NULL) { @@ -2260,9 +2269,8 @@ init_MiG(const char *service_name, int *n_listeners) kr = bootstrap_check_in(bootstrap_port, service_name, &service_port); if (kr != BOOTSTRAP_SUCCESS) { - SCLog(TRUE, LOG_ERR, - CFSTR("SCHelper: bootstrap_check_in() failed: %s"), - bootstrap_strerror(kr)); + SC_log(LOG_NOTICE, "bootstrap_check_in() failed: %s", + bootstrap_strerror(kr)); return 1; } @@ -2318,8 +2326,7 @@ main(int argc, char **argv) break; case '?': default : - SCLog(TRUE, LOG_ERR, - CFSTR("ignoring unknown or ambiguous command line option")); + SC_log(LOG_NOTICE, "ignoring unknown or ambiguous command line option"); break; } } @@ -2327,7 +2334,7 @@ main(int argc, char **argv) // argv += optind; if (geteuid() != 0) { - SCLog(TRUE, LOG_ERR, CFSTR("%s"), strerror(EACCES)); + SC_log(LOG_NOTICE, "%s", strerror(EACCES)); exit(EACCES); } @@ -2368,7 +2375,7 @@ main(int argc, char **argv) if (gen_reported != gen_current) { FILE *logFile = NULL; - SCLog(TRUE, LOG_NOTICE, CFSTR("active (but IDLE) sessions")); + SC_log(LOG_INFO, "active (but IDLE) sessions"); CFSetApplyFunction(sessions, __SCHelperSessionLog, (void *)&logFile); gen_reported = gen_current; diff --git a/SystemConfiguration.fproj/moh.c b/SystemConfiguration.fproj/moh.c index e4853aa..074f90a 100644 --- a/SystemConfiguration.fproj/moh.c +++ b/SystemConfiguration.fproj/moh.c @@ -1,15 +1,15 @@ /* - * Copyright (c) 2002, 2003, 2005, 2013, 2014 Apple Inc. All rights reserved. + * Copyright (c) 2002, 2003, 2005, 2013-2015 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ - * + * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. - * + * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, @@ -17,7 +17,7 @@ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. - * + * * @APPLE_LICENSE_HEADER_END@ */ @@ -149,20 +149,20 @@ MOHExec(int ref, // send the command n = writen(ref, &msg, sizeof(msg)); if (n == -1) { - SCLog(_sc_verbose, LOG_ERR, CFSTR("MOHExec writen() failed: %s"), strerror(errno)); + SC_log(LOG_INFO, "writen() failed: %s", strerror(errno)); return errno; } else if (n != sizeof(msg)) { - SCLog(_sc_verbose, LOG_ERR, CFSTR("MOHExec writen() failed: wrote=%ld"), n); + SC_log(LOG_INFO, "writen() failed: wrote=%ld", n); return -1; } if ((request != NULL) && (requestLen > 0)) { n = writen(ref, request, requestLen); if (n == -1) { - SCLog(_sc_verbose, LOG_ERR, CFSTR("MOHExec writen() failed: %s"), strerror(errno)); + SC_log(LOG_INFO, "writen() failed: %s", strerror(errno)); return errno; } else if (n != (ssize_t)requestLen) { - SCLog(_sc_verbose, LOG_ERR, CFSTR("MOHExec writen() failed: wrote=%ld"), n); + SC_log(LOG_INFO, "writen() failed: wrote=%ld", n); return -1; } } @@ -170,10 +170,10 @@ MOHExec(int ref, // always expect a reply n = readn(ref, &msg, sizeof(msg)); if (n == -1) { - SCLog(_sc_verbose, LOG_ERR, CFSTR("MOHExec readn() failed: error=%s"), strerror(errno)); + SC_log(LOG_INFO, "readn() failed: error=%s", strerror(errno)); return errno; } else if (n != sizeof(msg)) { - SCLog(_sc_verbose, LOG_ERR, CFSTR("MOHExec readn() failed: insufficent data, read=%ld"), n); + SC_log(LOG_INFO, "readn() failed: insufficent data, read=%ld", n); return -1; } @@ -183,11 +183,11 @@ MOHExec(int ref, // read reply n = readn(ref, buf, msg.m_len); if (n == -1) { - SCLog(_sc_verbose, LOG_ERR, CFSTR("MOHExec readn() failed: error=%s"), strerror(errno)); + SC_log(LOG_INFO, "readn() failed: error=%s", strerror(errno)); CFAllocatorDeallocate(NULL, buf); return errno; } else if (n != (ssize_t)msg.m_len) { - SCLog(_sc_verbose, LOG_ERR, CFSTR("MOHExec readn() failed: insufficent data, read=%ld"), n); + SC_log(LOG_INFO, "readn() failed: insufficent data, read=%ld", n); CFAllocatorDeallocate(NULL, buf); return -1; } diff --git a/SystemConfiguration.fproj/reachability/SCNetworkReachabilityServer_client.c b/SystemConfiguration.fproj/reachability/SCNetworkReachabilityServer_client.c deleted file mode 100644 index 41fc802..0000000 --- a/SystemConfiguration.fproj/reachability/SCNetworkReachabilityServer_client.c +++ /dev/null @@ -1,1218 +0,0 @@ -/* - * Copyright (c) 2011-2014 Apple Inc. All rights reserved. - * - * @APPLE_LICENSE_HEADER_START@ - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. - * - * The Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. - * - * @APPLE_LICENSE_HEADER_END@ - */ - -#include -#include -#include -#include "SCNetworkReachabilityInternal.h" - -#include -#include -#include - - -#pragma mark - -#pragma mark Globals - - -static Boolean serverAvailable = TRUE; - - -#pragma mark - -#pragma mark Support functions - - -static void -log_xpc_object(const char *msg, xpc_object_t obj) -{ - char *desc; - - desc = xpc_copy_description(obj); - SCLog(TRUE, LOG_DEBUG, CFSTR("%s = %s"), msg, desc); - free(desc); -} - - -#pragma mark - -#pragma mark Reachability [RBT] client support - - -typedef struct { - rb_node_t rbn; - SCNetworkReachabilityRef target; -} reach_request_t; - - -static int -_rbt_compare_transaction_nodes(void *context, const void *n1, const void *n2) -{ - uint64_t a = (uintptr_t)(((reach_request_t *)n1)->target); - uint64_t b = (uintptr_t)(((reach_request_t *)n2)->target); - - if (a == b) { - return 0; - } else if (a < b) { - return -1; - } else { - return 1; - } -} - - -static int -_rbt_compare_transaction_key(void *context, const void *n1, const void *key) -{ - uint64_t a = (uintptr_t)(((reach_request_t *)n1)->target); - uint64_t b = *(uint64_t *)key; - - if (a == b) { - return 0; - } else if (a < b) { - return -1; - } else { - return 1; - } -} - - -static rb_tree_t * -_reach_requests_rbt() -{ - static dispatch_once_t once; - static const rb_tree_ops_t ops = { - .rbto_compare_nodes = _rbt_compare_transaction_nodes, - .rbto_compare_key = _rbt_compare_transaction_key, - .rbto_node_offset = offsetof(reach_request_t, rbn), - .rbto_context = NULL - }; - static rb_tree_t rbt; - - dispatch_once(&once, ^{ - rb_tree_init(&rbt, &ops); - }); - - return &rbt; -} - - -static dispatch_queue_t -_reach_requests_rbt_queue() -{ - static dispatch_once_t once; - static dispatch_queue_t q; - - dispatch_once(&once, ^{ - q = dispatch_queue_create(REACH_SERVICE_NAME ".requests.rbt", NULL); - }); - - return q; -} - - -static reach_request_t * -_reach_request_create(SCNetworkReachabilityRef target) -{ - reach_request_t *request; - - request = calloc(1, sizeof(*request)); - request->target = CFRetain(target); - - return request; -} - - -static void -_reach_request_release(reach_request_t *request) -{ - SCNetworkReachabilityRef target = request->target; - - CFRelease(target); - free(request); - - return; -} - - -static void -_reach_request_add(SCNetworkReachabilityRef target) -{ - uint64_t target_id = (uintptr_t)target; - - dispatch_sync(_reach_requests_rbt_queue(), ^{ - rb_tree_t *rbt = _reach_requests_rbt(); - reach_request_t *request; - - request = rb_tree_find_node(rbt, &target_id); - if (request == NULL) { - request = _reach_request_create(target); - rb_tree_insert_node(rbt, request); - } - }); - - return; -} - - -static void -_reach_request_remove(SCNetworkReachabilityRef target) -{ - uint64_t target_id = (uintptr_t)target; - - dispatch_sync(_reach_requests_rbt_queue(), ^{ // FIXME ?? use dispatch_async? - rb_tree_t *rbt = _reach_requests_rbt(); - reach_request_t *request; - - request = rb_tree_find_node(rbt, &target_id); - if (request != NULL) { - rb_tree_remove_node(rbt, request); - _reach_request_release(request); - } - }); - - return; -} - - -static SCNetworkReachabilityRef -_reach_request_copy_target(uint64_t target_id) -{ - __block SCNetworkReachabilityRef target = NULL; - - dispatch_sync(_reach_requests_rbt_queue(), ^{ - rb_tree_t *rbt = _reach_requests_rbt(); - reach_request_t *request; - - request = rb_tree_find_node(rbt, &target_id); - if (request != NULL) { - target = request->target; - CFRetain(target); - } - }); - - return target; -} - - -#pragma mark - -#pragma mark Reachability [XPC] client support - - -static void -handle_reachability_status(SCNetworkReachabilityRef target, xpc_object_t dict) -{ - SCNetworkReachabilityPrivateRef targetPrivate = (SCNetworkReachabilityPrivateRef)target; - - if (_sc_debug) { - SCLog(TRUE, LOG_INFO, CFSTR("%sgot [async] notification"), - targetPrivate->log_prefix); -// log_xpc_object(" status", dict); - } - - __SCNetworkReachabilityUpdateConcurrent(target); - - return; -} - - -static void -handle_async_notification(SCNetworkReachabilityRef target, xpc_object_t dict) -{ - int64_t op; - SCNetworkReachabilityPrivateRef targetPrivate = (SCNetworkReachabilityPrivateRef)target; - - op = xpc_dictionary_get_int64(dict, MESSAGE_NOTIFY); - switch (op) { - case MESSAGE_REACHABILITY_STATUS : - handle_reachability_status(target, dict); - break; - default : - SCLog(TRUE, LOG_ERR, CFSTR("%sgot [async] unknown reply : %lld"), - targetPrivate->log_prefix, - op); - log_xpc_object(" reply", dict); - break; - } - - return; -} - - -static dispatch_queue_t -_reach_xpc_queue() -{ - static dispatch_once_t once; - static dispatch_queue_t q; - - dispatch_once(&once, ^{ - q = dispatch_queue_create(REACH_SERVICE_NAME ".xpc", NULL); - }); - - return q; -} - - -static void -_reach_connection_reconnect(xpc_connection_t connection); - - -static xpc_connection_t -_reach_connection_create() -{ - xpc_connection_t c; -#if !TARGET_IPHONE_SIMULATOR - const uint64_t flags = XPC_CONNECTION_MACH_SERVICE_PRIVILEGED; -#else // !TARGET_IPHONE_SIMULATOR - const uint64_t flags = 0; -#endif // !TARGET_IPHONE_SIMULATOR - const char *name; - dispatch_queue_t q = _reach_xpc_queue(); - - // create XPC connection - name = getenv("REACH_SERVER"); - if ((name == NULL) || (issetugid() != 0)) { - name = REACH_SERVICE_NAME; - } - - c = xpc_connection_create_mach_service(name, q, flags); - - xpc_connection_set_event_handler(c, ^(xpc_object_t xobj) { - xpc_type_t type; - - type = xpc_get_type(xobj); - if (type == XPC_TYPE_DICTIONARY) { - SCNetworkReachabilityRef target; - uint64_t target_id; - - target_id = xpc_dictionary_get_uint64(xobj, REACH_CLIENT_TARGET_ID); - if (target_id == 0) { - SCLog(TRUE, LOG_ERR, - CFSTR("reach client %p: async reply with no target [ID]"), - c); - log_xpc_object(" reply", xobj); - return; - } - - target = _reach_request_copy_target(target_id); - if (target == NULL) { -// SCLog(TRUE, LOG_ERR, -// CFSTR("received unexpected target [ID] from SCNetworkReachability server")); -// log_xpc_object(" reply", xobj); - return; - } - - xpc_retain(xobj); - dispatch_async(__SCNetworkReachability_concurrent_queue(), ^{ - handle_async_notification(target, xobj); - CFRelease(target); - xpc_release(xobj); - }); - - } else if (type == XPC_TYPE_ERROR) { - if (xobj == XPC_ERROR_CONNECTION_INVALID) { - SCLog(TRUE, LOG_ERR, - CFSTR("SCNetworkReachability server not available")); - serverAvailable = FALSE; - } else if (xobj == XPC_ERROR_CONNECTION_INTERRUPTED) { - SCLog(TRUE, LOG_DEBUG, - CFSTR("SCNetworkReachability server failure, reconnecting")); - _reach_connection_reconnect(c); - } else { - const char *desc; - - desc = xpc_dictionary_get_string(xobj, XPC_ERROR_KEY_DESCRIPTION); - SCLog(TRUE, LOG_ERR, - CFSTR("reach client %p: Connection error: %s"), - c, - desc); - } - - } else { - SCLog(TRUE, LOG_ERR, - CFSTR("reach client %p: unknown event type : %p"), - c, - type); - } - }); - xpc_connection_resume(c); - - return c; -} - - -static xpc_connection_t -_reach_connection() -{ - static xpc_connection_t c; - static dispatch_once_t once; - static dispatch_queue_t q; - - if (!serverAvailable) { - // if SCNetworkReachability [XPC] server not available - return NULL; - } - - dispatch_once(&once, ^{ - q = dispatch_queue_create(REACH_SERVICE_NAME ".connection", NULL); - }); - - dispatch_sync(q, ^{ - if (c == NULL) { - c = _reach_connection_create(); - } - }); - - return c; -} - - -typedef void (^reach_server_reply_handler_t)(xpc_object_t reply); - - -static void -add_proc_name(xpc_object_t reqdict) -{ - static const char *name = NULL; - static dispatch_once_t once; - - // add the process name - dispatch_once(&once, ^{ - name = getprogname(); - }); - xpc_dictionary_set_string(reqdict, REACH_CLIENT_PROC_NAME, name); - - return; -} - - -static void -_reach_server_target_reconnect(xpc_connection_t connection, SCNetworkReachabilityRef target, Boolean disconnect); - - -static Boolean -_reach_server_target_add(xpc_connection_t connection, SCNetworkReachabilityRef target) -{ - Boolean ok = FALSE; - xpc_object_t reply; - xpc_object_t reqdict; - Boolean retry = FALSE; - SCNetworkReachabilityPrivateRef targetPrivate = (SCNetworkReachabilityPrivateRef)target; - - // create message - reqdict = xpc_dictionary_create(NULL, NULL, 0); - - // set request - xpc_dictionary_set_int64(reqdict, REACH_REQUEST, REACH_REQUEST_CREATE); - - // add reachability target info - switch (targetPrivate->type) { - case reachabilityTypeName : - xpc_dictionary_set_string(reqdict, - REACH_TARGET_NAME, - targetPrivate->name); - break; - case reachabilityTypeAddress : - case reachabilityTypeAddressPair : - if (targetPrivate->localAddress != NULL) { - xpc_dictionary_set_data(reqdict, - REACH_TARGET_LOCAL_ADDR, - targetPrivate->localAddress, - targetPrivate->localAddress->sa_len); - } - if (targetPrivate->remoteAddress != NULL) { - xpc_dictionary_set_data(reqdict, - REACH_TARGET_REMOTE_ADDR, - targetPrivate->remoteAddress, - targetPrivate->remoteAddress->sa_len); - } - break; - case reachabilityTypePTR : - xpc_dictionary_set_data(reqdict, - REACH_TARGET_PTR_ADDR, - targetPrivate->remoteAddress, - targetPrivate->remoteAddress->sa_len); - break; - } - if (targetPrivate->if_index != 0) { - xpc_dictionary_set_int64(reqdict, - REACH_TARGET_IF_INDEX, - targetPrivate->if_index); - xpc_dictionary_set_string(reqdict, - REACH_TARGET_IF_NAME, - targetPrivate->if_name); - } - if (targetPrivate->onDemandBypass) { - xpc_dictionary_set_bool(reqdict, - REACH_TARGET_ONDEMAND_BYPASS, - TRUE); - } - if (targetPrivate->resolverBypass) { - xpc_dictionary_set_bool(reqdict, - REACH_TARGET_RESOLVER_BYPASS, - TRUE); - } - - - - // add the target [ID] - xpc_dictionary_set_uint64(reqdict, REACH_CLIENT_TARGET_ID, (uintptr_t)target); - - // add the process name (for debugging) - add_proc_name(reqdict); - - retry : - - // send request to the SCNetworkReachability server - reply = xpc_connection_send_message_with_reply_sync(connection, reqdict); - if (reply != NULL) { - xpc_type_t type; - - type = xpc_get_type(reply); - if (type == XPC_TYPE_DICTIONARY) { - int64_t status; - - status = xpc_dictionary_get_int64(reply, REACH_REQUEST_REPLY); - ok = (status == REACH_REQUEST_REPLY_OK); - } else if ((type == XPC_TYPE_ERROR) && (reply == XPC_ERROR_CONNECTION_INVALID)) { - SCLog(TRUE, LOG_ERR, - CFSTR("SCNetworkReachability server not available")); - serverAvailable = FALSE; - } else if ((type == XPC_TYPE_ERROR) && (reply == XPC_ERROR_CONNECTION_INTERRUPTED)) { - SCLog(TRUE, LOG_DEBUG, - CFSTR("reach target %p: SCNetworkReachability server failure, retrying"), - target); - retry = TRUE; - } else { - SCLog(TRUE, LOG_ERR, - CFSTR("reach target %p: _targetAdd with unexpected reply"), - target); - log_xpc_object(" reply", reply); - } - - xpc_release(reply); - } - - if (retry) { - retry = FALSE; - goto retry; - } - - xpc_release(reqdict); - return ok; -} - - -static Boolean -_reach_server_target_remove(xpc_connection_t connection, SCNetworkReachabilityRef target) -{ - Boolean ok = FALSE; - xpc_object_t reply; - xpc_object_t reqdict; - SCNetworkReachabilityPrivateRef targetPrivate = (SCNetworkReachabilityPrivateRef)target; - - // create message - reqdict = xpc_dictionary_create(NULL, NULL, 0); - - // set request - xpc_dictionary_set_int64(reqdict, REACH_REQUEST, REACH_REQUEST_REMOVE); - - // add the target [ID] - xpc_dictionary_set_uint64(reqdict, REACH_CLIENT_TARGET_ID, (uintptr_t)target); - - reply = xpc_connection_send_message_with_reply_sync(connection, reqdict); - if (reply != NULL) { - xpc_type_t type; - - type = xpc_get_type(reply); - if (type == XPC_TYPE_DICTIONARY) { - int64_t status; - - status = xpc_dictionary_get_int64(reply, REACH_REQUEST_REPLY); - switch (status) { - case REACH_REQUEST_REPLY_OK : - ok = TRUE; - break; - case REACH_REQUEST_REPLY_UNKNOWN : - // target not known by the server (most likely due to a - // SCNetworkReachability server failure), no need to - // remove. - ok = TRUE; - break; - default : { - SCLog(TRUE, LOG_ERR, CFSTR("%s target remove failed"), - targetPrivate->log_prefix); - log_xpc_object(" reply", reply); - } - } - } else if ((type == XPC_TYPE_ERROR) && (reply == XPC_ERROR_CONNECTION_INVALID)) { - SCLog(TRUE, LOG_ERR, - CFSTR("SCNetworkReachability server not available")); - serverAvailable = FALSE; - ok = TRUE; - } else if ((type == XPC_TYPE_ERROR) && (reply == XPC_ERROR_CONNECTION_INTERRUPTED)) { - SCLog(TRUE, LOG_DEBUG, - CFSTR("reach target %p: SCNetworkReachability server failure, no need to remove"), - target); - ok = TRUE; - } else { - SCLog(TRUE, LOG_ERR, - CFSTR("reach target %p: _targetRemove with unexpected reply"), - target); - log_xpc_object(" reply", reply); - } - - xpc_release(reply); - } - - xpc_release(reqdict); - return ok; -} - - -static Boolean -_reach_server_target_schedule(xpc_connection_t connection, SCNetworkReachabilityRef target) -{ - Boolean ok = FALSE; - xpc_object_t reply; - xpc_object_t reqdict; - Boolean retry = FALSE; - SCNetworkReachabilityPrivateRef targetPrivate = (SCNetworkReachabilityPrivateRef)target; - - // create message - reqdict = xpc_dictionary_create(NULL, NULL, 0); - - // set request - xpc_dictionary_set_int64(reqdict, REACH_REQUEST, REACH_REQUEST_SCHEDULE); - - // add the target [ID] - xpc_dictionary_set_uint64(reqdict, REACH_CLIENT_TARGET_ID, (uintptr_t)target); - - retry : - - reply = xpc_connection_send_message_with_reply_sync(connection, reqdict); - if (reply != NULL) { - xpc_type_t type; - - type = xpc_get_type(reply); - if (type == XPC_TYPE_DICTIONARY) { - int64_t status; - - status = xpc_dictionary_get_int64(reply, REACH_REQUEST_REPLY); - switch (status) { - case REACH_REQUEST_REPLY_OK : - ok = TRUE; - break; - case REACH_REQUEST_REPLY_UNKNOWN : - // target not known by the server (most likely due to a - // SCNetworkReachability server failure), re-establish - // and retry scheduling. - retry = TRUE; - break; - default : { - SCLog(TRUE, LOG_ERR, CFSTR("%s target schedule failed"), - targetPrivate->log_prefix); - log_xpc_object(" reply", reply); - } - } - - if (ok) { - CFRetain(target); - } - } else if ((type == XPC_TYPE_ERROR) && (reply == XPC_ERROR_CONNECTION_INVALID)) { - SCLog(TRUE, LOG_ERR, - CFSTR("SCNetworkReachability server not available")); - serverAvailable = FALSE; - } else if ((type == XPC_TYPE_ERROR) && (reply == XPC_ERROR_CONNECTION_INTERRUPTED)) { - SCLog(TRUE, LOG_DEBUG, - CFSTR("reach target %p: SCNetworkReachability server failure, retry schedule"), - target); - retry = TRUE; - } else { - SCLog(TRUE, LOG_ERR, - CFSTR("reach target %p: _targetSchedule with unexpected reply"), - target); - log_xpc_object(" reply", reply); - } - - xpc_release(reply); - } - - if (retry) { - // reconnect - _reach_server_target_reconnect(connection, target, FALSE); - - // and retry - retry = FALSE; - goto retry; - } - - xpc_release(reqdict); - return ok; -} - - -static void -_reach_reply_set_reachability(SCNetworkReachabilityRef target, - xpc_object_t reply) -{ - char *if_name; - size_t len = 0; - - SCNetworkReachabilityPrivateRef targetPrivate = (SCNetworkReachabilityPrivateRef)target; - - targetPrivate->serverInfo.cycle = xpc_dictionary_get_uint64(reply, - REACH_STATUS_CYCLE); - - targetPrivate->serverInfo.flags = (SCNetworkReachabilityFlags)xpc_dictionary_get_uint64(reply, - REACH_STATUS_FLAGS); - - targetPrivate->serverInfo.if_index = (unsigned int)xpc_dictionary_get_uint64(reply, - REACH_STATUS_IF_INDEX); - - bzero(&targetPrivate->serverInfo.if_name, sizeof(targetPrivate->serverInfo.if_name)); - if_name = (void *)xpc_dictionary_get_data(reply, - REACH_STATUS_IF_NAME, - &len); - if ((if_name != NULL) && (len > 0)) { - if (len > sizeof(targetPrivate->serverInfo.if_name)) { - len = sizeof(targetPrivate->serverInfo.if_name); - } - - bcopy(if_name, targetPrivate->serverInfo.if_name, len); - } - - targetPrivate->serverInfo.sleeping = xpc_dictionary_get_bool(reply, - REACH_STATUS_SLEEPING); - - if (isReachabilityTypeName(targetPrivate->type)) { - xpc_object_t addresses; - - if (targetPrivate->resolvedAddresses != NULL) { - CFRelease(targetPrivate->resolvedAddresses); - targetPrivate->resolvedAddresses = NULL; - } - - targetPrivate->resolvedError = (int)xpc_dictionary_get_int64(reply, - REACH_STATUS_RESOLVED_ERROR); - - addresses = xpc_dictionary_get_value(reply, REACH_STATUS_RESOLVED_ADDRESSES); - if ((addresses != NULL) && (xpc_get_type(addresses) != XPC_TYPE_ARRAY)) { - addresses = NULL; - } - - if ((targetPrivate->resolvedError == NETDB_SUCCESS) && (addresses != NULL)) { - int i; - size_t n; - CFMutableArrayRef newAddresses; - - newAddresses = CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks); - - n = xpc_array_get_count(addresses); - for (i = 0; i < n; i++) { - if (targetPrivate->type == reachabilityTypeName) { - struct sockaddr *sa; - size_t len; - CFDataRef newAddress; - - sa = (struct sockaddr *)xpc_array_get_data(addresses, i, &len); - newAddress = CFDataCreate(NULL, (const UInt8 *)sa, len); - CFArrayAppendValue(newAddresses, newAddress); - CFRelease(newAddress); - } else if (targetPrivate->type == reachabilityTypePTR) { - const char *str; - CFStringRef newName; - - str = xpc_array_get_string(addresses, i); - newName = CFStringCreateWithCString(NULL, str, kCFStringEncodingUTF8); - CFArrayAppendValue(newAddresses, newName); - CFRelease(newName); - } - } - - targetPrivate->resolvedAddresses = newAddresses; - } else { - /* save the error associated with the attempt to resolve the name */ - targetPrivate->resolvedAddresses = CFRetain(kCFNull); - } - - targetPrivate->dnsFlags = (uint32_t)xpc_dictionary_get_uint64(reply, - REACH_STATUS_DNS_FLAGS); - - targetPrivate->needResolve = FALSE; - } - - return; -} - - -static Boolean -_reach_server_target_status(xpc_connection_t connection, SCNetworkReachabilityRef target) -{ - Boolean ok = FALSE; - xpc_object_t reply; - xpc_object_t reqdict; - Boolean retry = FALSE; - SCNetworkReachabilityPrivateRef targetPrivate = (SCNetworkReachabilityPrivateRef)target; - - if (_sc_debug) { - CFStringRef str; - - str = _SCNetworkReachabilityCopyTargetDescription(target); - SCLog(TRUE, LOG_INFO, CFSTR("%scheckReachability(%@)"), - targetPrivate->log_prefix, - str); - CFRelease(str); - } - - // create message - reqdict = xpc_dictionary_create(NULL, NULL, 0); - - // set request - xpc_dictionary_set_int64(reqdict, REACH_REQUEST, REACH_REQUEST_STATUS); - - // add the target [ID] - xpc_dictionary_set_uint64(reqdict, REACH_CLIENT_TARGET_ID, (uintptr_t)target); - - retry : - - reply = xpc_connection_send_message_with_reply_sync(connection, reqdict); - if (reply != NULL) { - xpc_type_t type; - - type = xpc_get_type(reply); - if (type == XPC_TYPE_DICTIONARY) { - int64_t status; - - status = xpc_dictionary_get_int64(reply, REACH_REQUEST_REPLY); - switch (status) { - case REACH_REQUEST_REPLY_OK : - ok = TRUE; - break; - case REACH_REQUEST_REPLY_UNKNOWN : - // target not known by the server (most likely due to a - // SCNetworkReachability server failure), re-establish - // and retry status. - retry = TRUE; - break; - default : - SCLog(TRUE, LOG_INFO, CFSTR("%s target status failed"), - targetPrivate->log_prefix); - log_xpc_object(" reply", reply); - } - - if (ok) { - _reach_reply_set_reachability(target, reply); - - if (_sc_debug) { - SCLog(TRUE, LOG_INFO, CFSTR("%s flags = 0x%08x"), - targetPrivate->log_prefix, - targetPrivate->serverInfo.flags); - if (targetPrivate->serverInfo.if_index != 0) { - SCLog(TRUE, LOG_INFO, CFSTR("%s device = %s (%u%s)"), - targetPrivate->log_prefix, - targetPrivate->serverInfo.if_name, - targetPrivate->serverInfo.if_index, - targetPrivate->serverInfo.sleeping ? ", z" : ""); - } - if (targetPrivate->serverInfo.cycle != targetPrivate->cycle) { - SCLog(TRUE, LOG_INFO, CFSTR("%s forced"), - targetPrivate->log_prefix); - } - } - } - } else if ((type == XPC_TYPE_ERROR) && (reply == XPC_ERROR_CONNECTION_INVALID)) { - SCLog(TRUE, LOG_ERR, - CFSTR("SCNetworkReachability server not available")); - serverAvailable = FALSE; - ok = TRUE; - } else if ((type == XPC_TYPE_ERROR) && (reply == XPC_ERROR_CONNECTION_INTERRUPTED)) { - SCLog(TRUE, LOG_DEBUG, - CFSTR("reach target %p: SCNetworkReachability server failure, retry status"), - target); - retry = TRUE; - } else { - SCLog(TRUE, LOG_ERR, - CFSTR("reach target %p: _targetStatus with unexpected reply"), - target); - log_xpc_object(" reply", reply); - } - - xpc_release(reply); - } - - if (retry) { - // reconnect - _reach_server_target_reconnect(connection, target, FALSE); - - // and retry - retry = FALSE; - goto retry; - } - - xpc_release(reqdict); - return ok; -} - - -static Boolean -_reach_server_target_unschedule(xpc_connection_t connection, SCNetworkReachabilityRef target) -{ - Boolean ok = FALSE; - xpc_object_t reply; - xpc_object_t reqdict; - Boolean retry = FALSE; - SCNetworkReachabilityPrivateRef targetPrivate = (SCNetworkReachabilityPrivateRef)target; - - // create message - reqdict = xpc_dictionary_create(NULL, NULL, 0); - - // set request - xpc_dictionary_set_int64(reqdict, REACH_REQUEST, REACH_REQUEST_UNSCHEDULE); - - // add the target [ID] - xpc_dictionary_set_uint64(reqdict, REACH_CLIENT_TARGET_ID, (uintptr_t)target); - - reply = xpc_connection_send_message_with_reply_sync(connection, reqdict); - if (reply != NULL) { - xpc_type_t type; - - type = xpc_get_type(reply); - if (type == XPC_TYPE_DICTIONARY) { - int64_t status; - - status = xpc_dictionary_get_int64(reply, REACH_REQUEST_REPLY); - switch (status) { - case REACH_REQUEST_REPLY_OK : - ok = TRUE; - break; - case REACH_REQUEST_REPLY_UNKNOWN : - // target not known by the server (most likely due to a - // SCNetworkReachability server failure), re-establish - // but no need to unschedule. - retry = TRUE; - break; - default : - SCLog(TRUE, LOG_INFO, CFSTR("%s target unschedule failed"), - targetPrivate->log_prefix); - log_xpc_object(" reply", reply); - } - } else if ((type == XPC_TYPE_ERROR) && (reply == XPC_ERROR_CONNECTION_INVALID)) { - SCLog(TRUE, LOG_ERR, - CFSTR("SCNetworkReachability server not available")); - serverAvailable = FALSE; - ok = TRUE; - } else if ((type == XPC_TYPE_ERROR) && (reply == XPC_ERROR_CONNECTION_INTERRUPTED)) { - SCLog(TRUE, LOG_DEBUG, - CFSTR("reach target %p: SCNetworkReachability server failure, re-establish (but do not re-schedule)"), - target); - retry = TRUE; - } else { - SCLog(TRUE, LOG_ERR, - CFSTR("reach target %p: _targetUnschedule with unexpected reply"), - target); - log_xpc_object(" reply", reply); - } - - xpc_release(reply); - } - - if (retry) { - // reconnect - targetPrivate->serverScheduled = FALSE; - _reach_server_target_reconnect(connection, target, FALSE); - ok = TRUE; - } - - if (ok) { - CFRelease(target); - } - - xpc_release(reqdict); - return ok; -} - - -#pragma mark - -#pragma mark Reconnect - - -static void -_reach_server_target_reconnect(xpc_connection_t connection, SCNetworkReachabilityRef target, Boolean disconnect) -{ - Boolean ok; - SCNetworkReachabilityPrivateRef targetPrivate = (SCNetworkReachabilityPrivateRef)target; - - if (!targetPrivate->serverActive) { - // if target already removed - return; - } - - if (disconnect) { - // if we should first disconnect (unschedule, remove) - if (targetPrivate->serverScheduled) { - (void) _reach_server_target_unschedule(connection, target); - } - - (void) _reach_server_target_remove(connection, target); - } else { - // server has been restarted - targetPrivate->cycle = 0; - } - - // re-associate with server - ok = _reach_server_target_add(connection, target); - if (!ok) { - // if we could not add the target - return; - } - - if (!targetPrivate->serverScheduled) { - // if not scheduled - return; - } - - // ... and re-schedule with server - ok = _reach_server_target_schedule(connection, target); - if (!ok) { - // if we could not reschedule the target - return; - } - - // For addresses, update our status now. For names, queries will - // be updated with a callback - if (isReachabilityTypeAddress(targetPrivate->type)) { - __SCNetworkReachabilityUpdate(target); - } - - return; -} - - -static void -_reach_connection_reconnect(xpc_connection_t connection) -{ - dispatch_sync(_reach_requests_rbt_queue(), ^{ - rb_tree_t *rbt = _reach_requests_rbt(); - reach_request_t *request; - - RB_TREE_FOREACH(request, rbt) { - SCNetworkReachabilityRef target; - - xpc_retain(connection); - target = request->target; - CFRetain(target); - dispatch_async(__SCNetworkReachability_concurrent_queue(), ^{ - _reach_server_target_reconnect(connection, target, FALSE); - CFRelease(target); - xpc_release(connection); - }); - } - }); - - return; -} - - -#pragma mark - -#pragma mark SPI (exposed) - - -Boolean -_SCNetworkReachabilityServer_snapshot(void) -{ - xpc_connection_t c; - Boolean ok = FALSE; - xpc_object_t reply; - xpc_object_t reqdict; - - // initialize connection with SCNetworkReachability server - c = _reach_connection(); - if (c == NULL) { - return FALSE; - } - - // create message - reqdict = xpc_dictionary_create(NULL, NULL, 0); - - // set request - xpc_dictionary_set_int64(reqdict, REACH_REQUEST, REACH_REQUEST_SNAPSHOT); - - // add the process name (for debugging) - add_proc_name(reqdict); - - retry : - - // send request - reply = xpc_connection_send_message_with_reply_sync(c, reqdict); - if (reply != NULL) { - xpc_type_t type; - - type = xpc_get_type(reply); - if (type == XPC_TYPE_DICTIONARY) { - int64_t status; - - status = xpc_dictionary_get_int64(reply, REACH_REQUEST_REPLY); - ok = (status == REACH_REQUEST_REPLY_OK); - } else if ((type == XPC_TYPE_ERROR) && (reply == XPC_ERROR_CONNECTION_INVALID)) { - SCLog(TRUE, LOG_ERR, - CFSTR("SCNetworkReachability server not available")); - serverAvailable = FALSE; - } else if ((type == XPC_TYPE_ERROR) && (reply == XPC_ERROR_CONNECTION_INTERRUPTED)) { - SCLog(TRUE, LOG_DEBUG, - CFSTR("SCNetworkReachability server failure, retrying")); - xpc_release(reply); - goto retry; - } else { - SCLog(TRUE, LOG_ERR, - CFSTR("_snapshot with unexpected reply")); - log_xpc_object(" reply", reply); - } - - xpc_release(reply); - } - - xpc_release(reqdict); - return ok; -} - - -__private_extern__ -Boolean -__SCNetworkReachabilityServer_targetAdd(SCNetworkReachabilityRef target) -{ - xpc_connection_t c; - Boolean ok; - SCNetworkReachabilityPrivateRef targetPrivate = (SCNetworkReachabilityPrivateRef)target; - - c = _reach_connection(); - if (c == NULL) { - return FALSE; - } - - ok = _reach_server_target_add(c, target); - if (ok) { - _SC_ATOMIC_CMPXCHG(&targetPrivate->serverActive, FALSE, TRUE); - } - - return ok; -} - - -__private_extern__ -void -__SCNetworkReachabilityServer_targetRemove(SCNetworkReachabilityRef target) -{ - xpc_connection_t c; - Boolean ok; - SCNetworkReachabilityPrivateRef targetPrivate = (SCNetworkReachabilityPrivateRef)target; - - if (!targetPrivate->serverActive) { - // if not active - return; - } - - c = _reach_connection(); - if (c == NULL) { - return; - } - - ok = _reach_server_target_remove(c, target); - if (ok) { - _SC_ATOMIC_CMPXCHG(&targetPrivate->serverActive, TRUE, FALSE); - } - - return; -} - - -__private_extern__ -Boolean -__SCNetworkReachabilityServer_targetSchedule(SCNetworkReachabilityRef target) -{ - xpc_connection_t c; - Boolean ok; - SCNetworkReachabilityPrivateRef targetPrivate = (SCNetworkReachabilityPrivateRef)target; - - c = _reach_connection(); - if (c == NULL) { - return FALSE; - } - - _reach_request_add(target); - ok = _reach_server_target_schedule(c, target); - if (ok) { - _SC_ATOMIC_CMPXCHG(&targetPrivate->serverScheduled, FALSE, TRUE); - } else { - _reach_request_remove(target); - } - - return ok; -} - - -__private_extern__ -Boolean -__SCNetworkReachabilityServer_targetStatus(SCNetworkReachabilityRef target) -{ - xpc_connection_t c; - Boolean ok; - - c = _reach_connection(); - if (c == NULL) { - return FALSE; - } - - ok = _reach_server_target_status(c, target); - return ok; -} - - -__private_extern__ -Boolean -__SCNetworkReachabilityServer_targetUnschedule(SCNetworkReachabilityRef target) -{ - xpc_connection_t c; - Boolean ok; - SCNetworkReachabilityPrivateRef targetPrivate = (SCNetworkReachabilityPrivateRef)target; - - if (!targetPrivate->serverScheduled) { - // if not scheduled - return TRUE; - } - - c = _reach_connection(); - if (c == NULL) { - return FALSE; - } - - ok = _reach_server_target_unschedule(c, target); - if (ok) { - _SC_ATOMIC_CMPXCHG(&targetPrivate->serverScheduled, TRUE, FALSE); - _reach_request_remove(target); - } else { - // if unschedule failed - } - - return ok; -} - - diff --git a/SystemConfiguration.fproj/reachability/SCNetworkReachabilityServer_server.c b/SystemConfiguration.fproj/reachability/SCNetworkReachabilityServer_server.c deleted file mode 100644 index 50f090c..0000000 --- a/SystemConfiguration.fproj/reachability/SCNetworkReachabilityServer_server.c +++ /dev/null @@ -1,2125 +0,0 @@ -/* - * Copyright (c) 2011-2014 Apple Inc. All rights reserved. - * - * @APPLE_LICENSE_HEADER_START@ - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. - * - * The Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. - * - * @APPLE_LICENSE_HEADER_END@ - */ - -#include -#include -#include -#include "SCNetworkReachabilityInternal.h" - -#include -#include -#include -#include -#include -#include -#include -#include - - -#pragma mark - -#pragma mark Globals - - -/* - * S_debug - * A boolean that enables additional logging. - */ -static boolean_t S_debug = FALSE; - - -#pragma mark - -#pragma mark Support functions - - -static void -log_xpc_object(const char *msg, xpc_object_t obj) -{ - char *desc; - - desc = xpc_copy_description(obj); - SCLog(S_debug, LOG_INFO, CFSTR("%s = %s"), msg, desc); - free(desc); -} - - -static __inline__ void -my_CFDictionaryApplyFunction(CFDictionaryRef theDict, - CFDictionaryApplierFunction applier, - void *context) -{ - CFAllocatorRef myAllocator; - CFDictionaryRef myDict; - - myAllocator = CFGetAllocator(theDict); - myDict = CFDictionaryCreateCopy(myAllocator, theDict); - CFDictionaryApplyFunction(myDict, applier, context); - CFRelease(myDict); - return; -} - - -#pragma mark - -#pragma mark SCNetworkReachability target support - - -static CFMutableDictionaryRef reach_digest_map; - - -static dispatch_queue_t -_server_concurrent_queue() -{ - static dispatch_once_t once; - static dispatch_queue_t q; - - dispatch_once(&once, ^{ - q = dispatch_queue_create(REACH_SERVICE_NAME ".concurrent", - DISPATCH_QUEUE_CONCURRENT); - }); - - return q; -} - - -static dispatch_queue_t -_server_digest_queue() -{ - static dispatch_once_t once; - static dispatch_queue_t q; - - dispatch_once(&once, ^{ - q = dispatch_queue_create(REACH_SERVICE_NAME ".digest", NULL); - }); - - return q; -} - - -static dispatch_group_t -_target_group(SCNetworkReachabilityRef target) -{ - SCNetworkReachabilityPrivateRef targetPrivate = (SCNetworkReachabilityPrivateRef)target; - - return targetPrivate->serverGroup; -} - - -static dispatch_queue_t -_target_queue(SCNetworkReachabilityRef target) -{ - SCNetworkReachabilityPrivateRef targetPrivate = (SCNetworkReachabilityPrivateRef)target; - - return targetPrivate->serverQueue; -} - - -#pragma mark - - - -/* - * _target_reference_add - * - * Note: use dispatch_sync(_server_digest_queue(), ^{ ... }); - */ -static void -_target_reference_add(SCNetworkReachabilityRef target, CFDataRef digest, xpc_connection_t connection) -{ - SCNetworkReachabilityPrivateRef targetPrivate = (SCNetworkReachabilityPrivateRef)target; - - // take a reference to the target - CFRetain(target); - - // ensure that we have a dispatch group - if (targetPrivate->serverGroup == NULL) { - targetPrivate->serverGroup = dispatch_group_create(); - } - - // ensure that we have a dispatch queue - if (targetPrivate->serverQueue == NULL) { - char qname[256]; - - snprintf(qname, sizeof(qname), "com.apple.SCNetworkReachability.%p.server", target); - targetPrivate->serverQueue = dispatch_queue_create(qname, NULL); - } - - // bump the reference count - if (_SC_ATOMIC_INC(&targetPrivate->serverReferences) == 0) { - // and maintain a digest-->target mapping - targetPrivate->serverDigest = CFRetain(digest); - CFDictionarySetValue(reach_digest_map, digest, target); - } - - if (S_debug) { - CFStringRef str; - - str = _SCNetworkReachabilityCopyTargetDescription(target); - SCLog(TRUE, LOG_INFO, - CFSTR("<%p> target %p: reference added (%@, %d)"), - connection, - target, - str, - targetPrivate->serverReferences); - CFRelease(str); - } - - return; -} - - -/* - * _target_reference_remove - * - * Note: use dispatch_sync(_server_digest_queue(), ^{ ... }); - */ -static void -_target_reference_remove(SCNetworkReachabilityRef target, xpc_connection_t connection) -{ - SCNetworkReachabilityPrivateRef targetPrivate = (SCNetworkReachabilityPrivateRef)target; - - // drop the reference count - if (_SC_ATOMIC_DEC(&targetPrivate->serverReferences) == 0) { - /* - * if that was the last reference, we no longer need to - * keep the digest-->target mapping - */ - CFDictionaryRemoveValue(reach_digest_map, targetPrivate->serverDigest); - CFRelease(targetPrivate->serverDigest); - targetPrivate->serverDigest = NULL; - } - - if (S_debug) { - SCLog(TRUE, LOG_INFO, - CFSTR("<%p> target %p: reference removed (%d)"), - connection, - target, - targetPrivate->serverReferences); - } - - // release a reference to the target - CFRelease(target); - - return; -} - - -#pragma mark - - - -#define MUTEX_LOCK(m) { \ - int _lock_ = (pthread_mutex_lock(m) == 0); \ - assert(_lock_); \ -} - -#define MUTEX_UNLOCK(m) { \ - int _unlock_ = (pthread_mutex_unlock(m) == 0); \ - assert(_unlock_); \ -} - - -static void -_target_reply_add_reachability(SCNetworkReachabilityRef target, - xpc_object_t reply) -{ - SCNetworkReachabilityPrivateRef targetPrivate = (SCNetworkReachabilityPrivateRef)target; - - MUTEX_LOCK(&targetPrivate->lock); - - xpc_dictionary_set_uint64(reply, - REACH_STATUS_CYCLE, - targetPrivate->info.cycle); - xpc_dictionary_set_uint64(reply, - REACH_STATUS_FLAGS, - targetPrivate->info.flags); - xpc_dictionary_set_uint64(reply, - REACH_STATUS_IF_INDEX, - targetPrivate->info.if_index); - xpc_dictionary_set_data (reply, - REACH_STATUS_IF_NAME, - targetPrivate->info.if_name, - sizeof(targetPrivate->info.if_name)); - xpc_dictionary_set_bool (reply, - REACH_STATUS_SLEEPING, - targetPrivate->info.sleeping); - if (isReachabilityTypeName(targetPrivate->type)) { - if (isA_CFArray(targetPrivate->resolvedAddresses)) { - xpc_object_t addresses; - CFIndex i; - CFIndex n; - - addresses = xpc_array_create(NULL, 0); - - n = CFArrayGetCount(targetPrivate->resolvedAddresses); - for (i = 0; i < n; i++) { - if (targetPrivate->type == reachabilityTypeName) { - CFDataRef address; - - address = CFArrayGetValueAtIndex(targetPrivate->resolvedAddresses, i); - xpc_array_set_data(addresses, - XPC_ARRAY_APPEND, - CFDataGetBytePtr(address), - CFDataGetLength(address)); - } else if (targetPrivate->type == reachabilityTypePTR) { - CFStringRef name; - char str[MAXHOSTNAMELEN]; - - name = CFArrayGetValueAtIndex(targetPrivate->resolvedAddresses, i); - _SC_cfstring_to_cstring(name, str, sizeof(str), kCFStringEncodingUTF8); - xpc_array_set_string(addresses, XPC_ARRAY_APPEND, str); - } - } - - xpc_dictionary_set_value(reply, - REACH_STATUS_RESOLVED_ADDRESSES, - addresses); - xpc_release(addresses); - } - xpc_dictionary_set_int64(reply, - REACH_STATUS_RESOLVED_ERROR, - targetPrivate->resolvedError); - xpc_dictionary_set_uint64(reply, - REACH_STATUS_DNS_FLAGS, - targetPrivate->dnsFlags); - - } - - MUTEX_UNLOCK(&targetPrivate->lock); - - return; -} - - -#pragma mark - - - -typedef struct { - xpc_connection_t connection; - uint64_t target_id; -} reach_watcher_key_t; - -typedef struct { - unsigned int n_changes; -} reach_watcher_val_t; - - -static CFDataRef -_target_watcher_key_create(xpc_connection_t connection, - uint64_t target_id) -{ - CFDataRef key; - reach_watcher_key_t watcher_key; - - watcher_key.connection = connection; - watcher_key.target_id = target_id; - - key = CFDataCreate(NULL, (UInt8 *)&watcher_key, sizeof(watcher_key)); - return key; -} - - -static Boolean -_target_watcher_add(SCNetworkReachabilityRef target, - xpc_connection_t connection, - uint64_t target_id) -{ - __block Boolean ok = TRUE; - dispatch_queue_t q; - - q = _target_queue(target); - dispatch_sync(q, ^{ - CFDataRef key; - SCNetworkReachabilityPrivateRef targetPrivate = (SCNetworkReachabilityPrivateRef)target; - - if (targetPrivate->serverWatchers == NULL) { - ok = SCNetworkReachabilitySetDispatchQueue(target, q); - if (!ok) { - SCLog(TRUE, LOG_ERR, - CFSTR("<%p> target %p: _watcher_add SCNetworkReachabilitySetDispatchQueue() failed: %s"), - connection, - target, - SCErrorString(SCError())); - return; - } - - targetPrivate->serverWatchers = CFDictionaryCreateMutable(NULL, - 0, - &kCFTypeDictionaryKeyCallBacks, - &kCFTypeDictionaryValueCallBacks); - } - - xpc_retain(connection); - - key = _target_watcher_key_create(connection, target_id); - if (CFDictionaryContainsKey(targetPrivate->serverWatchers, key)) { - SCLog(TRUE, LOG_ERR, - CFSTR("<%p> target %p: watcher not added, c=0x%0llx, \"serverWatchers\" key exists"), - connection, - target, - target_id); - } else { - CFDataRef val; - static const reach_watcher_val_t watcher_val0 = { 0 }; - - val = CFDataCreate(NULL, (UInt8 *)&watcher_val0, sizeof(watcher_val0)); - CFDictionaryAddValue(targetPrivate->serverWatchers, key, val); - CFRelease(val); - - if (S_debug) { - SCLog(TRUE, LOG_INFO, - CFSTR("<%p> target %p: watcher added, c=0x%0llx, n=%ld"), - connection, - target, - target_id, - CFDictionaryGetCount(targetPrivate->serverWatchers)); - } - } - CFRelease(key); - }); - - return ok; -} - - -static Boolean -_target_watcher_checkin(SCNetworkReachabilityRef target, - xpc_connection_t connection, - uint64_t target_id) -{ - __block Boolean scheduled = FALSE; - - dispatch_sync(_target_queue(target), ^{ - CFDataRef key; - unsigned int n; - SCNetworkReachabilityPrivateRef targetPrivate = (SCNetworkReachabilityPrivateRef)target; - CFDataRef val; - reach_watcher_val_t *watcher_val; - - if (targetPrivate->serverWatchers == NULL) { - // if no watchers - return; - } - - key = _target_watcher_key_create(connection, target_id); - val = CFDictionaryGetValue(targetPrivate->serverWatchers, key); - CFRelease(key); - if (val == NULL) { - // if the target [for this client] was not scheduled - return; - } - - // indicate that the target was scheduled - scheduled = TRUE; - - /* - * and note that the reachability flags for this target have - * been picked up by the client - */ - /* ALIGN: CF aligns to at least >8 byte boundries */ - watcher_val = (reach_watcher_val_t *)(void *)CFDataGetBytePtr(val); - n = _SC_ATOMIC_ZERO(&watcher_val->n_changes); - if (S_debug && (n > 0)) { - SCLog(TRUE, LOG_INFO, - CFSTR("<%p> target %p: SCNetworkReachabilityGetFlags() after %d notification%s"), - connection, - target, - n, - (n == 1) ? "" : "s"); - } - }); - - return scheduled; -} - - -static Boolean -_target_watcher_remove(SCNetworkReachabilityRef target, - xpc_connection_t connection, - uint64_t target_id) -{ - __block Boolean ok = TRUE; - - dispatch_sync(_target_queue(target), ^{ - CFDataRef key; - CFIndex n; - SCNetworkReachabilityPrivateRef targetPrivate = (SCNetworkReachabilityPrivateRef)target; - - if (targetPrivate->serverWatchers == NULL) { - SCLog(TRUE, LOG_ERR, - CFSTR("<%p> target %p: watcher not removed, c=0x%0llx, no \"serverWatchers\""), - connection, - target, - target_id); - ok = FALSE; - return; - } - - key = _target_watcher_key_create(connection, target_id); - if (!CFDictionaryContainsKey(targetPrivate->serverWatchers, key)) { - SCLog(TRUE, LOG_ERR, - CFSTR("<%p> target %p: watcher not removed, c=0x%0llx, no \"serverWatchers\" key"), - connection, - target, - target_id); - CFRelease(key); - ok = FALSE; - return; - } - - CFDictionaryRemoveValue(targetPrivate->serverWatchers, key); - CFRelease(key); - - n = CFDictionaryGetCount(targetPrivate->serverWatchers); - - if (S_debug) { - SCLog(TRUE, LOG_INFO, - CFSTR("<%p> target %p: watcher removed, c=0x%0llx, n=%ld"), - connection, - target, // server - target_id, // client - n); - } - - if (n == 0) { - CFRelease(targetPrivate->serverWatchers); - targetPrivate->serverWatchers = NULL; - - ok = SCNetworkReachabilitySetDispatchQueue(target, NULL); - if (!ok) { - SCLog(TRUE, LOG_ERR, - CFSTR("<%p> target %p: _watcher_remove SCNetworkReachabilitySetDispatchQueue() failed: %s"), - connection, - target, - SCErrorString(SCError())); - return; - } - - // no more watchers, flags are no longer valid - if (_SC_ATOMIC_CMPXCHG(&targetPrivate->serverInfoValid, TRUE, FALSE)) { - if (S_debug) { - SCLog(TRUE, LOG_INFO, CFSTR("%s flags are no longer \"valid\""), - targetPrivate->log_prefix); - } - } - } - - xpc_release(connection); - }); - - return ok; -} - - -#pragma mark - -#pragma mark Reachability [RBT] client support - - -typedef struct { - rb_node_t rbn; - xpc_connection_t connection; - pid_t pid; - const char *proc_name; - CFMutableDictionaryRef targets; // target_id --> SCNetworkReachabilityRef -} reach_client_t; - - -static int -_rbt_compare_transaction_nodes(void *context, const void *n1, const void *n2) -{ - uint64_t a = (uintptr_t)((reach_client_t *)n1)->connection; - uint64_t b = (uintptr_t)((reach_client_t *)n2)->connection; - - if (a == b) { - return 0; - } else if (a < b) { - return -1; - } else { - return 1; - } -} - - -static int -_rbt_compare_transaction_key(void *context, const void *n1, const void *key) -{ - uint64_t a = (uintptr_t)((reach_client_t *)n1)->connection; - uint64_t b = *(uintptr_t *)key; - - if (a == b) { - return 0; - } else if (a < b) { - return -1; - } else { - return 1; - } -} - - -static rb_tree_t * -_reach_clients_rbt() -{ - static dispatch_once_t once; - static const rb_tree_ops_t ops = { - .rbto_compare_nodes = _rbt_compare_transaction_nodes, - .rbto_compare_key = _rbt_compare_transaction_key, - .rbto_node_offset = offsetof(reach_client_t, rbn), - .rbto_context = NULL - }; - static rb_tree_t rbt; - - dispatch_once(&once, ^{ - rb_tree_init(&rbt, &ops); - }); - - return &rbt; -} - - -static dispatch_queue_t -_reach_clients_rbt_queue() -{ - static dispatch_once_t once; - static dispatch_queue_t q; - - dispatch_once(&once, ^{ - q = dispatch_queue_create(REACH_SERVICE_NAME ".clients.rbt", NULL); - }); - - return q; -} - - -static reach_client_t * -_reach_client_create(xpc_connection_t connection) -{ - reach_client_t *client; - - client = calloc(1, sizeof(*client)); - client->connection = connection; - client->pid = xpc_connection_get_pid(connection); - client->proc_name = NULL; - client->targets = CFDictionaryCreateMutable(NULL, - 0, - &kCFTypeDictionaryKeyCallBacks, - &kCFTypeDictionaryValueCallBacks); - - return client; -} - - -static void -_reach_client_release(reach_client_t *client) -{ - if (client->proc_name != NULL) { - free((void *)client->proc_name); - } - CFRelease(client->targets); - free(client); - return; -} - - -static void -_reach_client_remove_target(const void *key, const void *value, void *context) -{ - xpc_connection_t connection = (xpc_connection_t)context; - SCNetworkReachabilityRef target = (SCNetworkReachabilityRef)value; - SCNetworkReachabilityPrivateRef targetPrivate = (SCNetworkReachabilityPrivateRef)target; - - // check if we have anyone watching this target - if (targetPrivate->serverWatchers != NULL) { - CFIndex n; - - n = CFDictionaryGetCount(targetPrivate->serverWatchers); - if (n > 0) { - CFIndex i; - CFDictionaryRef serverWatchers; - const void * watchers_q[32]; - const void ** watchers = watchers_q; - - serverWatchers = CFDictionaryCreateCopy(NULL, targetPrivate->serverWatchers); - - if (n > sizeof(watchers_q)/sizeof(watchers[0])) { - watchers = CFAllocatorAllocate(NULL, n * sizeof(CFDataRef), 0); - } - CFDictionaryGetKeysAndValues(serverWatchers, watchers, NULL); - - for (i = 0; i < n; i++) { - CFDataRef key; - reach_watcher_key_t *watcher_key; - - key = (CFDataRef)watchers[i]; - /* ALIGN: CF aligns to >8 byte boundries */ - watcher_key = (reach_watcher_key_t *)(void *)CFDataGetBytePtr(key); - if (watcher_key->connection == connection) { - // remove watcher references for THIS connection - _target_watcher_remove(target, - watcher_key->connection, - watcher_key->target_id); - } - } - - if (watchers != watchers_q) { - CFAllocatorDeallocate(NULL, watchers); - } - - CFRelease(serverWatchers); - } - } - - // remove our reference to this target - dispatch_sync(_server_digest_queue(), ^{ - _target_reference_remove(target, connection); - }); - - return; -} - - -static void -_reach_client_remove(xpc_connection_t connection) -{ - uint64_t connection_id = (uintptr_t)connection; - - dispatch_sync(_reach_clients_rbt_queue(), ^{ - reach_client_t *client; - rb_tree_t *rbt = _reach_clients_rbt(); - - client = rb_tree_find_node(rbt, &connection_id); - if (client != NULL) { - // remove any remaining target references (for this client) - my_CFDictionaryApplyFunction(client->targets, - _reach_client_remove_target, - (void *)connection); - - rb_tree_remove_node(rbt, client); - _reach_client_release(client); - } else { - SCLog(TRUE, LOG_ERR, - CFSTR("<%p> _reach_client_remove: unexpected client"), - connection); - } - }); - - return; -} - - -static __inline__ CFDataRef -_client_target_key_create(uint64_t target_id) -{ - CFDataRef target_key; - - target_key = CFDataCreate(NULL, (UInt8 *)&target_id, sizeof(target_id)); - return target_key; -} - - -static SCNetworkReachabilityRef -_client_target_copy(reach_client_t *client, uint64_t target_id) -{ - SCNetworkReachabilityRef target; - CFDataRef target_key; - - target_key = _client_target_key_create(target_id); - target = CFDictionaryGetValue(client->targets, target_key); - CFRelease(target_key); - - if (target != NULL) { - CFRetain(target); - } - - return target; -} - - -static Boolean -_client_target_set(reach_client_t *client, uint64_t target_id, SCNetworkReachabilityRef target) -{ - Boolean added; - CFDataRef target_key; - - target_key = _client_target_key_create(target_id); - added = !CFDictionaryContainsKey(client->targets, target_key); - if (added) { - CFDictionarySetValue(client->targets, target_key, target); - } - CFRelease(target_key); - - return added; -} - - -static void -_client_target_remove(reach_client_t *client, uint64_t target_id) -{ - CFDataRef target_key; - - target_key = _client_target_key_create(target_id); - CFDictionaryRemoveValue(client->targets, target_key); - CFRelease(target_key); - - return; -} - - -#pragma mark - -#pragma mark Reachability [XPC] server functions - - -static dispatch_queue_t -_reach_server_queue() -{ - static dispatch_once_t once; - static dispatch_queue_t q; - - dispatch_once(&once, ^{ - q = dispatch_queue_create(REACH_SERVICE_NAME, NULL); - }); - - return q; -} - - -/* - * _reach_changed - * - * Note: should be exec'd on the target queue - */ -static void -_reach_changed(SCNetworkReachabilityRef target, SCNetworkReachabilityFlags flags, void *info) -{ - CFIndex i; - CFIndex n; - SCNetworkReachabilityPrivateRef targetPrivate = (SCNetworkReachabilityPrivateRef)target; - const void * watcher_keys_q[32]; - const void ** watcher_keys = watcher_keys_q; - const void * watcher_vals_q[32]; - const void ** watcher_vals = watcher_vals_q; - - if (S_debug) { - SCLog(TRUE, LOG_INFO, - CFSTR("%sprocess reachability changed, flags = 0x%08x"), - targetPrivate->log_prefix, - flags); - } - - if (targetPrivate->serverWatchers == NULL) { - // if no watchers - return; - } - - n = CFDictionaryGetCount(targetPrivate->serverWatchers); - if (n == 0) { - // if no watchers - return; - } - - if (!isReachabilityTypeName(targetPrivate->type) || !targetPrivate->dnsNoAddressesSinceLastTimeout) { - /* - * Because we are actively watching for additional changes - * we mark the flags as "valid" - */ - if (_SC_ATOMIC_CMPXCHG(&targetPrivate->serverInfoValid, FALSE, TRUE)) { - if (S_debug) { - SCLog(TRUE, LOG_INFO, CFSTR("%s flags are now \"valid\""), - targetPrivate->log_prefix); - } - } - } - - // notify all of the watchers - if (n > sizeof(watcher_keys_q)/sizeof(watcher_keys[0])) { - watcher_keys = CFAllocatorAllocate(NULL, n * sizeof(CFDataRef), 0); - watcher_vals = CFAllocatorAllocate(NULL, n * sizeof(CFDataRef), 0); - } - - CFDictionaryGetKeysAndValues(targetPrivate->serverWatchers, - watcher_keys, - watcher_vals); - - for (i = 0; i < n; i++) { - xpc_connection_t connection; - CFDataRef key; - uint64_t target_id; - CFDataRef val; - reach_watcher_key_t *watcher_key; - reach_watcher_val_t *watcher_val; - - val = (CFDataRef)watcher_vals[i]; - /* ALIGN: CF aligns to >8 byte boundries */ - watcher_val = (reach_watcher_val_t *)(void *)CFDataGetBytePtr(val); - - if (_SC_ATOMIC_INC(&watcher_val->n_changes) > 0) { - // if we've already sent a notification - continue; - } - - key = (CFDataRef)watcher_keys[i]; - /* ALIGN: CF aligns to >8 byte boundries */ - watcher_key = (reach_watcher_key_t *)(void *)CFDataGetBytePtr(key); - - connection = xpc_retain(watcher_key->connection); - target_id = watcher_key->target_id; - dispatch_async(_reach_server_queue(), ^{ - xpc_object_t reply; - - // create our [async] notification - reply = xpc_dictionary_create(NULL, NULL, 0); - - // set notification - xpc_dictionary_set_int64(reply, - MESSAGE_NOTIFY, - MESSAGE_REACHABILITY_STATUS); - - // set target ID - xpc_dictionary_set_uint64(reply, - REACH_CLIENT_TARGET_ID, - target_id); - - log_xpc_object(" reply [async]", reply); - xpc_connection_send_message(connection, reply); - - xpc_release(reply); - xpc_release(connection); - }); - } - - if (n > sizeof(watcher_keys_q)/sizeof(watcher_keys[0])) { - CFAllocatorDeallocate(NULL, watcher_keys); - CFAllocatorDeallocate(NULL, watcher_vals); - } - - return; -} - - -static void -sanitize_address(const struct sockaddr *from, struct sockaddr *to) -{ - switch (from->sa_family) { - case AF_INET : { - /* ALIGN: cast okay, alignment not assumed. */ - struct sockaddr_in *from4 = (struct sockaddr_in *)(void *)from; - struct sockaddr_in *to4 = (struct sockaddr_in *)(void *)to; - - bzero(to4, sizeof(*to4)); - to4->sin_len = sizeof(*to4); - to4->sin_family = AF_INET; - bcopy(&from4->sin_addr, &to4->sin_addr, sizeof(to4->sin_addr)); - break; - } - - case AF_INET6 : { - /* ALIGN: cast okay, alignment not assumed. */ - struct sockaddr_in6 *from6 = (struct sockaddr_in6 *)(void *)from; - struct sockaddr_in6 *to6 = (struct sockaddr_in6 *)(void *)to; - - bzero(to6, sizeof(*to6)); - to6->sin6_len = sizeof(*to6); - to6->sin6_family = AF_INET6; - bcopy(&from6->sin6_addr, &to6->sin6_addr, sizeof(to6->sin6_addr)); - to6->sin6_scope_id = from6->sin6_scope_id; - break; - } - - default: - bcopy(from, to, from->sa_len); - break; - } - - return; -} - - -static void -target_add(reach_client_t *client, xpc_object_t request) -{ - const char *name; - const struct sockaddr *localAddress; - struct sockaddr_storage localAddress0; - const struct sockaddr *remoteAddress; - struct sockaddr_storage remoteAddress0; - const struct sockaddr *ptrAddress; - struct sockaddr_storage ptrAddress0; - int64_t if_index; - const char *if_name = NULL; - bool onDemandBypass = FALSE; - bool resolverBypass = FALSE; - uint64_t target_id; - uid_t uid = 0; - - - unsigned char bytes[CC_SHA1_DIGEST_LENGTH]; - CC_SHA1_CTX ctx; - CFDataRef digest = NULL; - size_t len; - xpc_connection_t remote; - xpc_object_t reply; - uint64_t status = REACH_REQUEST_REPLY_FAILED; - - Boolean added; - __block Boolean ok = TRUE; - __block SCNetworkReachabilityRef target = NULL; - - if (S_debug) { - SCLog(TRUE, LOG_INFO, - CFSTR("<%p> create reachability target"), - client->connection); -// log_xpc_object(" create", request); - } - - remote = xpc_dictionary_get_remote_connection(request); - reply = xpc_dictionary_create_reply(request); - if (reply == NULL) { - SCLog(TRUE, LOG_ERR, - CFSTR("<%p> target_add: xpc_dictionary_create_reply: failed"), - client->connection); - return; - } - - target_id = xpc_dictionary_get_uint64(request, REACH_CLIENT_TARGET_ID); - if (target_id == 0) { - xpc_dictionary_set_string(reply, - REACH_REQUEST_REPLY_DETAIL, - "no target ID"); - goto done; - } - - // create a "digest" of the [new] target - - CC_SHA1_Init(&ctx); - - name = xpc_dictionary_get_string(request, REACH_TARGET_NAME); - if (name != NULL) { - CC_SHA1_Update(&ctx, REACH_TARGET_NAME, sizeof(REACH_TARGET_NAME)); - CC_SHA1_Update(&ctx, name, (CC_LONG)strlen(name)); - } - - localAddress = xpc_dictionary_get_data(request, REACH_TARGET_LOCAL_ADDR, &len); - if (localAddress != NULL) { - if ((len == localAddress->sa_len) && (len <= sizeof(struct sockaddr_storage))) { - sanitize_address(localAddress, (struct sockaddr *)&localAddress0); - CC_SHA1_Update(&ctx, REACH_TARGET_LOCAL_ADDR, sizeof(REACH_TARGET_LOCAL_ADDR)); - CC_SHA1_Update(&ctx, &localAddress0, (CC_LONG)len); - } else { - xpc_dictionary_set_string(reply, - REACH_REQUEST_REPLY_DETAIL, - "local address: size error"); - goto done; - } - } - - remoteAddress = xpc_dictionary_get_data(request, REACH_TARGET_REMOTE_ADDR, &len); - if (remoteAddress != NULL) { - if ((len == remoteAddress->sa_len) && (len <= sizeof(struct sockaddr_storage))) { - sanitize_address(remoteAddress, (struct sockaddr *)&remoteAddress0); - CC_SHA1_Update(&ctx, REACH_TARGET_REMOTE_ADDR, sizeof(REACH_TARGET_REMOTE_ADDR)); - CC_SHA1_Update(&ctx, &remoteAddress0, (CC_LONG)len); - } else { - xpc_dictionary_set_string(reply, - REACH_REQUEST_REPLY_DETAIL, - "remote address: size error"); - goto done; - } - } - - ptrAddress = xpc_dictionary_get_data(request, REACH_TARGET_PTR_ADDR, &len); - if (ptrAddress != NULL) { - if ((len == ptrAddress->sa_len) && (len <= sizeof(struct sockaddr_storage))) { - sanitize_address(ptrAddress, (struct sockaddr *)&ptrAddress0); - CC_SHA1_Update(&ctx, REACH_TARGET_PTR_ADDR, sizeof(REACH_TARGET_PTR_ADDR)); - CC_SHA1_Update(&ctx, &ptrAddress0, (CC_LONG)len); - } else { - xpc_dictionary_set_string(reply, - REACH_REQUEST_REPLY_DETAIL, - "ptr address: size error"); - goto done; - } - } - - if_index = xpc_dictionary_get_int64(request, REACH_TARGET_IF_INDEX); - if (if_index != 0) { - if_name = xpc_dictionary_get_string(request, REACH_TARGET_IF_NAME); - if (if_name != NULL) { - CC_SHA1_Update(&ctx, REACH_TARGET_IF_NAME, sizeof(REACH_TARGET_IF_NAME)); - CC_SHA1_Update(&ctx, if_name, (CC_LONG)strlen(if_name)); - } - } - - - onDemandBypass = xpc_dictionary_get_bool(request, REACH_TARGET_ONDEMAND_BYPASS); - if (onDemandBypass) { - CC_SHA1_Update(&ctx, REACH_TARGET_ONDEMAND_BYPASS, sizeof(REACH_TARGET_ONDEMAND_BYPASS)); - CC_SHA1_Update(&ctx, &onDemandBypass, sizeof(onDemandBypass)); - } - - resolverBypass = xpc_dictionary_get_bool(request, REACH_TARGET_RESOLVER_BYPASS); - if (resolverBypass) { - CC_SHA1_Update(&ctx, REACH_TARGET_RESOLVER_BYPASS, sizeof(REACH_TARGET_RESOLVER_BYPASS)); - CC_SHA1_Update(&ctx, &resolverBypass, sizeof(resolverBypass)); - } - - // Grab UID from XPC connection - uid = xpc_connection_get_euid(remote); - CC_SHA1_Update(&ctx, &uid, sizeof(uid)); - - - CC_SHA1_Final(bytes, &ctx); - digest = CFDataCreate(NULL, bytes, sizeof(bytes)); - - /* - * Check to see if we already have a SCNetworkReachability object - * for this digest. If so, we'll share the existing target. If not, - * create a new [shared] target. - */ - dispatch_sync(_server_digest_queue(), ^{ - target = CFDictionaryGetValue(reach_digest_map, digest); - if (target != NULL) { - CFRetain(target); - } else { - CFDataRef data; - CFMutableDictionaryRef options; - CFStringRef str; - - options = CFDictionaryCreateMutable(NULL, - 0, - &kCFTypeDictionaryKeyCallBacks, - &kCFTypeDictionaryValueCallBacks); - if (name != NULL) { - str = CFStringCreateWithCString(NULL, name, kCFStringEncodingUTF8); - CFDictionarySetValue(options, kSCNetworkReachabilityOptionNodeName, str); - CFRelease(str); - } - if (localAddress != NULL) { - data = CFDataCreate(NULL, (const UInt8 *)&localAddress0, localAddress0.ss_len); - CFDictionarySetValue(options, kSCNetworkReachabilityOptionLocalAddress, data); - CFRelease(data); - } - if (remoteAddress != NULL) { - data = CFDataCreate(NULL, (const UInt8 *)&remoteAddress0, remoteAddress0.ss_len); - CFDictionarySetValue(options, kSCNetworkReachabilityOptionRemoteAddress, data); - CFRelease(data); - } - if (ptrAddress != NULL) { - data = CFDataCreate(NULL, (const UInt8 *)&ptrAddress0, ptrAddress0.ss_len); - CFDictionarySetValue(options, kSCNetworkReachabilityOptionPTRAddress, data); - CFRelease(data); - } - if (onDemandBypass) { - CFDictionarySetValue(options, - kSCNetworkReachabilityOptionConnectionOnDemandBypass, - kCFBooleanTrue); - } - if (resolverBypass) { - CFDictionarySetValue(options, - kSCNetworkReachabilityOptionResolverBypass, - kCFBooleanTrue); - } - CFDictionarySetValue(options, - kSCNetworkReachabilityOptionServerBypass, - kCFBooleanTrue); - target = SCNetworkReachabilityCreateWithOptions(NULL, options); - CFRelease(options); - if (target == NULL) { - xpc_dictionary_set_string(reply, - REACH_REQUEST_REPLY_DETAIL, - "SCNetworkReachabilityCreateWithOptions failed"); - ok = FALSE; - return; - } - - // Set the UID on the target - ((SCNetworkReachabilityPrivateRef)target)->uid = uid; - - // because the interface name may not (no longer) be valid we set - // this after we've created the SCNetworkReachability object - if ((if_index != 0) && (if_name != NULL)) { - SCNetworkReachabilityPrivateRef targetPrivate; - - targetPrivate = (SCNetworkReachabilityPrivateRef)target; - targetPrivate->if_index = (unsigned int)if_index; - strlcpy(targetPrivate->if_name, if_name, sizeof(targetPrivate->if_name)); - } - - - ok = SCNetworkReachabilitySetCallback(target, _reach_changed, NULL); - if (!ok) { - xpc_dictionary_set_string(reply, - REACH_REQUEST_REPLY_DETAIL, - "SCNetworkReachabilitySetCallback failed"); - CFRelease(target); - target = NULL; - return; - } - } - - // bump the number of references to this target - _target_reference_add(target, digest, client->connection); - }); - - if (!ok) { - goto done; - } - - /* - * add an association for the client's target_id to the [shared] - * SCNetworkReachability object. - */ - added = _client_target_set(client, target_id, target); - if (!added) { - // if we already had a reference to the target (e.g. reconnect) - dispatch_sync(_server_digest_queue(), ^{ - _target_reference_remove(target, client->connection); - }); - } - - status = REACH_REQUEST_REPLY_OK; - - done : - - xpc_dictionary_set_int64(reply, REACH_REQUEST_REPLY, status); -// log_xpc_object(" reply", reply); - xpc_connection_send_message(remote, reply); - xpc_release(reply); - - if (digest != NULL) CFRelease(digest); - if (target != NULL) CFRelease(target); - return; -} - - -static void -target_remove(reach_client_t *client, xpc_object_t request) -{ - xpc_connection_t remote; - xpc_object_t reply; - uint64_t status = REACH_REQUEST_REPLY_FAILED; - SCNetworkReachabilityRef target = NULL; - uint64_t target_id; - - if (S_debug) { - SCLog(TRUE, LOG_INFO, - CFSTR("<%p> remove reachability target"), - client->connection); -// log_xpc_object(" remove", request); - } - - remote = xpc_dictionary_get_remote_connection(request); - reply = xpc_dictionary_create_reply(request); - if (reply == NULL) { - SCLog(TRUE, LOG_ERR, - CFSTR("<%p> target_remove: xpc_dictionary_create_reply: failed"), - client->connection); - return; - } - - target_id = xpc_dictionary_get_uint64(request, REACH_CLIENT_TARGET_ID); - if (target_id == 0) { - xpc_dictionary_set_string(reply, - REACH_REQUEST_REPLY_DETAIL, - "no target ID"); - goto done; - } - - target = _client_target_copy(client, target_id); - if (target == NULL) { - xpc_dictionary_set_string(reply, - REACH_REQUEST_REPLY_DETAIL, - "no target"); - status = REACH_REQUEST_REPLY_UNKNOWN; - goto done; - } - - /* - * remove the association from the client's target_id to the [shared] - * SCNetworkReachability object. - */ - _client_target_remove(client, target_id); - - // drop the number of references to this target - dispatch_sync(_server_digest_queue(), ^{ - _target_reference_remove(target, client->connection); - }); - - status = REACH_REQUEST_REPLY_OK; - - done : - - xpc_dictionary_set_int64(reply, REACH_REQUEST_REPLY, status); -// log_xpc_object(" reply", reply); - xpc_connection_send_message(remote, reply); - xpc_release(reply); - - if (target != NULL) CFRelease(target); - return; -} - - -static void -target_schedule(reach_client_t *client, xpc_object_t request) -{ - Boolean ok; - xpc_connection_t remote; - xpc_object_t reply; - uint64_t status = REACH_REQUEST_REPLY_FAILED; - SCNetworkReachabilityRef target = NULL; - uint64_t target_id; - - if (S_debug) { - SCLog(TRUE, LOG_INFO, - CFSTR("<%p> schedule reachability target"), - client->connection); -// log_xpc_object(" schedule", request); - } - - remote = xpc_dictionary_get_remote_connection(request); - reply = xpc_dictionary_create_reply(request); - if (reply == NULL) { - SCLog(TRUE, LOG_ERR, - CFSTR("<%p> target_schedule: xpc_dictionary_create_reply: failed"), - client->connection); - return; - } - - target_id = xpc_dictionary_get_uint64(request, REACH_CLIENT_TARGET_ID); - if (target_id == 0) { - xpc_dictionary_set_string(reply, - REACH_REQUEST_REPLY_DETAIL, - "no target ID"); - goto done; - } - - target = _client_target_copy(client, target_id); - if (target == NULL) { - xpc_dictionary_set_string(reply, - REACH_REQUEST_REPLY_DETAIL, - "no target"); - status = REACH_REQUEST_REPLY_UNKNOWN; - goto done; - } - - // enable monitoring - ok = _target_watcher_add(target, client->connection, target_id); - if (!ok) { - xpc_dictionary_set_string(reply, - REACH_REQUEST_REPLY_DETAIL, - "could not add watcher"); - goto done; - } - - status = REACH_REQUEST_REPLY_OK; - - done : - - xpc_dictionary_set_int64(reply, REACH_REQUEST_REPLY, status); -// log_xpc_object(" reply", reply); - xpc_connection_send_message(remote, reply); - xpc_release(reply); - - if (target != NULL) CFRelease(target); - return; -} - - -static void -target_status(reach_client_t *client, xpc_object_t request) -{ - xpc_connection_t remote; - xpc_object_t reply; - __block Boolean reply_now = TRUE; - Boolean scheduled; - uint64_t status = REACH_REQUEST_REPLY_FAILED; - SCNetworkReachabilityRef target = NULL; - uint64_t target_id; - - if(S_debug) { - SCLog(TRUE, LOG_INFO, - CFSTR("<%p> get status of reachability target"), - client->connection); -// log_xpc_object(" status", request); - } - - remote = xpc_dictionary_get_remote_connection(request); - reply = xpc_dictionary_create_reply(request); - if (reply == NULL) { - SCLog(TRUE, LOG_ERR, - CFSTR("<%p> target_status: xpc_dictionary_create_reply: failed"), - client->connection); - return; - } - - target_id = xpc_dictionary_get_uint64(request, REACH_CLIENT_TARGET_ID); - if (target_id == 0) { - SCLog(TRUE, LOG_ERR, - CFSTR("<%p> target_status: no target"), - client->connection); - xpc_dictionary_set_string(reply, - REACH_REQUEST_REPLY_DETAIL, - "no target ID"); - goto done; - } - - target = _client_target_copy(client, target_id); - if (target == NULL) { - SCLog(TRUE, LOG_ERR, - CFSTR("<%p> target_status: no target (0x%0llx)"), - client->connection, - target_id); - xpc_dictionary_set_string(reply, - REACH_REQUEST_REPLY_DETAIL, - "no target"); - status = REACH_REQUEST_REPLY_UNKNOWN; - goto done; - } - - /* - * Check to see if the target [for this client] had been "scheduled". - * - * If so, also mark that we've picked up the current reachability - * flags and that any pending notifications have been processed. - */ - scheduled = _target_watcher_checkin(target, client->connection, target_id); - - /* - * return current reachability information to the caller - */ - dispatch_sync(_target_queue(target), ^{ - SCNetworkReachabilityPrivateRef targetPrivate = (SCNetworkReachabilityPrivateRef)target; - - if (scheduled) { - /* - * The client "scheduled" this target. As such, we - * know that this is an async query and that we only - * need to return the "last known" flags. - */ - _target_reply_add_reachability(target, reply); -// log_xpc_object(" reply [scheduled]", reply); - - /* - * ... and if it's not a "name" query then we can mark the - * flags as valid. - */ - if (!isReachabilityTypeName(targetPrivate->type)) { - if (_SC_ATOMIC_CMPXCHG(&targetPrivate->serverInfoValid, FALSE, TRUE)) { - if (S_debug) { - SCLog(TRUE, LOG_INFO, CFSTR("%s flags are now \"valid\"."), - targetPrivate->log_prefix); - } - } - } - - if (S_debug) { - CFStringRef str; - - str = _SCNetworkReachabilityCopyTargetFlags(target); - SCLog(TRUE, LOG_INFO, - CFSTR("<%p> reply [scheduled%s], %@"), - client->connection, - targetPrivate->serverInfoValid ? "/valid" : "", - str); - CFRelease(str); - } - } else { - /* - * The client has NOT "scheduled" this target. As - * such, we know that this is a sync query and that - * we must return "current" flags. - */ - if (targetPrivate->scheduled && targetPrivate->serverInfoValid) { - /* - * The server target has been "scheduled" and we - * have flags that are "current". - */ - _target_reply_add_reachability(target, reply); -// log_xpc_object(" reply [scheduled/valid]", reply); - - if (S_debug) { - CFStringRef str; - - str = _SCNetworkReachabilityCopyTargetFlags(target); - SCLog(TRUE, LOG_INFO, - CFSTR("<%p> reply [scheduled/valid], %@"), - client->connection, - str); - CFRelease(str); - } - } else { - dispatch_group_t group; - - /* - * The server target has NOT been "scheduled" or - * we do not have "current" flags. This means that - * we must query for the current information and - * return the flags to the client when they are - * available. - */ - - reply_now = FALSE; - - group = _target_group(target); - if (_SC_ATOMIC_INC(&targetPrivate->serverSyncQueryActive) == 0) { - CFRetain(target); - dispatch_group_async(group, _server_concurrent_queue(), ^{ - SCNetworkReachabilityFlags flags; - unsigned int n; - Boolean ok; - - // query for the flags - ok = SCNetworkReachabilityGetFlags(target, &flags); - flags = targetPrivate->info.flags; // get the "raw" flags - if (!ok) { - SCLog(TRUE, LOG_ERR, - CFSTR("SCNetworkReachabilityGetFlags() [sync query] failed" - "\n target = %@" - "\n status = %s"), - target, - SCErrorString(SCError())); - } - - /* - * if we have current flags, if the target has since been - * scheduled, and this is not a "name" query, then mark as - * valid. - */ - if (ok && - targetPrivate->scheduled && - !isReachabilityTypeName(targetPrivate->type)) { - if (_SC_ATOMIC_CMPXCHG(&targetPrivate->serverInfoValid, FALSE, TRUE)) { - if (S_debug) { - SCLog(TRUE, LOG_INFO, CFSTR("%s flags are now \"valid\"!"), - targetPrivate->log_prefix); - } - } - } - - // sync query complete - n = _SC_ATOMIC_ZERO(&targetPrivate->serverSyncQueryActive); - if (S_debug) { - SCLog(TRUE, LOG_INFO, - CFSTR("%sSCNetworkReachabilityGetFlags() [sync query] complete, n = %d"), - targetPrivate->log_prefix, - n); - } - - CFRelease(target); - }); - } - - CFRetain(target); - dispatch_group_notify(group, _target_queue(target), ^{ - // flags are now available - _target_reply_add_reachability(target, reply); - xpc_dictionary_set_int64(reply, REACH_REQUEST_REPLY, REACH_REQUEST_REPLY_OK); -// log_xpc_object(" reply [delayed]", reply); - - if (S_debug) { - CFStringRef str; - - str = _SCNetworkReachabilityCopyTargetFlags(target); - SCLog(TRUE, LOG_INFO, - CFSTR("<%p> reply [delayed], %@"), - client->connection, - str); - CFRelease(str); - } - - xpc_connection_send_message(remote, reply); - xpc_release(reply); - - CFRelease(target); - }); - } - } - }); - - status = REACH_REQUEST_REPLY_OK; - - done : - - if (reply_now) { - xpc_dictionary_set_int64(reply, REACH_REQUEST_REPLY, status); - - if (status != REACH_REQUEST_REPLY_OK) { -// log_xpc_object(" reply [!]", reply); - - if (S_debug) { - SCLog(TRUE, LOG_INFO, - CFSTR("<%p> reply [!]"), - client->connection); - } - } - - xpc_connection_send_message(remote, reply); - xpc_release(reply); - } else if (S_debug) { - CFStringRef str; - - str = _SCNetworkReachabilityCopyTargetFlags(target); - SCLog(TRUE, LOG_INFO, - CFSTR("<%p> no reply [yet], %@"), - client->connection, - str); - CFRelease(str); - } - - if (target != NULL) CFRelease(target); - return; -} - - -static void -target_unschedule(reach_client_t *client, xpc_object_t request) -{ - xpc_connection_t remote; - xpc_object_t reply; - uint64_t status = REACH_REQUEST_REPLY_FAILED; - SCNetworkReachabilityRef target = NULL; - uint64_t target_id; - - if (S_debug) { - SCLog(TRUE, LOG_INFO, - CFSTR("<%p> unschedule reachability target"), - client->connection); -// log_xpc_object(" unschedule", request); - } - - remote = xpc_dictionary_get_remote_connection(request); - reply = xpc_dictionary_create_reply(request); - if (reply == NULL) { - SCLog(TRUE, LOG_ERR, - CFSTR("<%p> target_unschedule: xpc_dictionary_create_reply: failed"), - client->connection); - return; - } - - target_id = xpc_dictionary_get_uint64(request, REACH_CLIENT_TARGET_ID); - if (target_id == 0) { - xpc_dictionary_set_string(reply, - REACH_REQUEST_REPLY_DETAIL, - "no target ID"); - goto done; - } - - target = _client_target_copy(client, target_id); - if (target == NULL) { - xpc_dictionary_set_string(reply, - REACH_REQUEST_REPLY_DETAIL, - "no target"); - status = REACH_REQUEST_REPLY_UNKNOWN; - goto done; - } - - // disable monitoring - _target_watcher_remove(target, client->connection, target_id); - - status = REACH_REQUEST_REPLY_OK; - - done : - - xpc_dictionary_set_int64(reply, REACH_REQUEST_REPLY, status); -// log_xpc_object(" reply", reply); - xpc_connection_send_message(remote, reply); - xpc_release(reply); - - if (target != NULL) CFRelease(target); - return; -} - - -#define SNAPSHOT_PATH_STATE _PATH_VARTMP "configd-reachability" - - -static void -_snapshot_digest_watcher(const void *key, const void *value, void *context) -{ - __block reach_client_t *client = NULL; - FILE *f = (FILE *)context; - static reach_client_t no_client = { - .pid = 0, - .proc_name = "?", - }; - reach_watcher_key_t *watcher_key; - reach_watcher_val_t *watcher_val; - - /* ALIGN: CF aligns to >8 byte boundries */ - watcher_key = (reach_watcher_key_t *)(void *)CFDataGetBytePtr(key); - watcher_val = (reach_watcher_val_t *)(void *)CFDataGetBytePtr(value); - - dispatch_sync(_reach_clients_rbt_queue(), ^{ - uint64_t connection_id = (uintptr_t)watcher_key->connection; - rb_tree_t *rbt = _reach_clients_rbt(); - - client = rb_tree_find_node(rbt, &connection_id); - if (client == NULL) { - client = &no_client; - } - }); - - SCPrint(TRUE, f, - CFSTR(" connection = %p, target(c) = 0x%0llx, command = %s, pid = %d, changes = %u\n"), - watcher_key->connection, - watcher_key->target_id, - client->proc_name, - client->pid, - watcher_val->n_changes); - - return; -} - - -static void -_snapshot_digest(const void *key, const void *value, void *context) -{ - FILE *f = (FILE *)context; - CFStringRef digest = (CFStringRef)key; - dispatch_queue_t q; - SCNetworkReachabilityRef target = (SCNetworkReachabilityRef)value; - SCNetworkReachabilityPrivateRef targetPrivate = (SCNetworkReachabilityPrivateRef)target; - - q = _target_queue(target); - dispatch_sync(q, ^{ - CFIndex nWatchers = 0; - - if (targetPrivate->serverWatchers != NULL) { - nWatchers = CFDictionaryGetCount(targetPrivate->serverWatchers); - } - - SCPrint(TRUE, f, CFSTR("\n digest : %@\n"), digest); - SCPrint(TRUE, f, CFSTR(" %@\n"), target); - SCPrint(TRUE, f, CFSTR(" valid = %s, async watchers = %ld, sync queries = %u, refs = %u\n"), - targetPrivate->serverInfoValid ? "Y" : "N", - nWatchers, - targetPrivate->serverSyncQueryActive, - targetPrivate->serverReferences); - - SCPrint(TRUE, f, CFSTR(" network %ld.%3.3d"), - targetPrivate->last_network.tv_sec, - targetPrivate->last_network.tv_usec / 1000); -#if !TARGET_OS_IPHONE - SCPrint(TRUE, f, CFSTR(", power %ld.%3.3d"), - targetPrivate->last_power.tv_sec, - targetPrivate->last_power.tv_usec / 1000); -#endif // !TARGET_OS_IPHONE - if (isReachabilityTypeName(targetPrivate->type)) { - SCPrint(TRUE, f, CFSTR(", DNS %ld.%3.3d"), - targetPrivate->last_dns.tv_sec, - targetPrivate->last_dns.tv_usec / 1000); - if (timerisset(&targetPrivate->dnsQueryEnd)) { - struct timeval dnsQueryElapsed; - - timersub(&targetPrivate->dnsQueryEnd, - &targetPrivate->dnsQueryStart, - &dnsQueryElapsed); - SCPrint(TRUE, f, CFSTR(" (query %ld.%3.3d / reply %ld.%3.3d)"), - targetPrivate->dnsQueryStart.tv_sec, - targetPrivate->dnsQueryStart.tv_usec / 1000, - dnsQueryElapsed.tv_sec, - dnsQueryElapsed.tv_usec / 1000); - } - } - if (timerisset(&targetPrivate->last_push)) { - SCPrint(TRUE, f, CFSTR(", last notify %ld.%3.3d"), - targetPrivate->last_push.tv_sec, - targetPrivate->last_push.tv_usec / 1000); - } - SCPrint(TRUE, f, CFSTR(", uid %d"), - targetPrivate->uid); - SCPrint(TRUE, f, CFSTR("\n")); - - if (nWatchers > 0) { - CFDictionaryApplyFunction(targetPrivate->serverWatchers, - _snapshot_digest_watcher, - f); - } - }); - - return; -} - - -static void -_snapshot_target(const void *key, const void *value, void *context) -{ - FILE *f = (FILE *)context; - SCNetworkReachabilityRef target = (SCNetworkReachabilityRef)value; - uint64_t target_id; - CFDataRef target_key = (CFDataRef)key; - - /* ALIGN: CF aligns > 8 byte boundries */ - target_id = *(uint64_t *)(void *)CFDataGetBytePtr(target_key); - - SCPrint(TRUE, f, - CFSTR(" target(c) = 0x%0llx, target(s) = %@\n"), - target_id, - target); - - return; -} - - -static void -_snapshot(reach_client_t *client, xpc_object_t request) -{ - uid_t euid; - FILE *f; - int fd; - Boolean ok = FALSE; - xpc_connection_t remote; - xpc_object_t reply; - - if (S_debug) { - SCLog(TRUE, LOG_INFO, - CFSTR("<%p> snapshot"), - client->connection); -// log_xpc_object(" create", request); - } - - remote = xpc_dictionary_get_remote_connection(request); - reply = xpc_dictionary_create_reply(request); - if (reply == NULL) { - SCLog(TRUE, LOG_ERR, - CFSTR("<%p> _snapshot: xpc_dictionary_create_reply: failed"), - client->connection); - return; - } - - euid = xpc_connection_get_euid(remote); - if (euid != 0) { - xpc_dictionary_set_string(reply, - REACH_REQUEST_REPLY_DETAIL, - "Permission denied."); - goto done; - } - - // Save a snapshot of the SCNetworkReachability server "state" - - (void) unlink(SNAPSHOT_PATH_STATE); - fd = open(SNAPSHOT_PATH_STATE, O_WRONLY|O_CREAT|O_TRUNC|O_EXCL, 0644); - if (fd == -1) { - xpc_dictionary_set_string(reply, - REACH_REQUEST_REPLY_DETAIL, - "open: failed"); - goto done; - } - f = fdopen(fd, "w"); - if (f == NULL) { - xpc_dictionary_set_string(reply, - REACH_REQUEST_REPLY_DETAIL, - "fdopen: failed"); - goto done; - } - - // provide connection/client info - - dispatch_sync(_reach_clients_rbt_queue(), ^{ - rb_tree_t *rbt = _reach_clients_rbt(); - - SCPrint(TRUE, f, CFSTR("Clients :\n")); - - if (rb_tree_count(rbt) > 0) { - reach_client_t *client; - - RB_TREE_FOREACH(client, rbt) { - SCPrint(TRUE, f, - CFSTR("\n connection = %p, client = %p, command = %s, pid = %d\n"), - client->connection, - client, - client->proc_name != NULL ? client->proc_name : "?", - client->pid); - my_CFDictionaryApplyFunction(client->targets, - _snapshot_target, - f); - } - } else { - SCPrint(TRUE, f, CFSTR(" None.\n")); - } - - SCPrint(TRUE, f, CFSTR("\n")); - }); - - // provide "digest" info - - SCPrint(TRUE, f, CFSTR("Digests :\n")); - dispatch_sync(_server_digest_queue(), ^{ - if (reach_digest_map != NULL) { - CFDictionaryApplyFunction(reach_digest_map, - _snapshot_digest, - f); - } - }); - - (void) fclose(f); - - ok = TRUE; - - done : - - xpc_dictionary_set_int64(reply, - REACH_REQUEST_REPLY, - ok ? REACH_REQUEST_REPLY_OK : REACH_REQUEST_REPLY_FAILED); -// log_xpc_object(" reply", reply); - xpc_connection_send_message(remote, reply); - xpc_release(reply); - - return; -} - - -static __inline__ void -_extract_client_info(reach_client_t *client, xpc_object_t request) -{ - // if available/needed, save the process name - if (client->proc_name == NULL) { - const char *proc_name; - - proc_name = xpc_dictionary_get_string(request, REACH_CLIENT_PROC_NAME); - if (proc_name != NULL) { - client->proc_name = strdup(proc_name); - } - } - - return; -} - - -static void -process_request(reach_client_t *client, xpc_object_t request) -{ - int64_t op; - - op = xpc_dictionary_get_int64(request, REACH_REQUEST); - switch (op) { - case REACH_REQUEST_CREATE : - _extract_client_info(client, request); - target_add(client, request); - break; - case REACH_REQUEST_REMOVE : - target_remove(client, request); - break; - case REACH_REQUEST_STATUS : - target_status(client, request); - break; - case REACH_REQUEST_SCHEDULE : - target_schedule(client, request); - break; - case REACH_REQUEST_UNSCHEDULE : - target_unschedule(client, request); - break; - case REACH_REQUEST_SNAPSHOT : - _extract_client_info(client, request); - _snapshot(client, request); - break; - default : - SCLog(TRUE, LOG_ERR, - CFSTR("<%p> unknown request : %lld"), - client->connection, - op); - break; - } - - return; -} - - -static void -process_new_connection(xpc_connection_t connection) -{ - reach_client_t *client; - - if (S_debug) { - SCLog(TRUE, LOG_INFO, CFSTR("<%p> new reach client, pid=%d"), - connection, - xpc_connection_get_pid(connection)); - } - - client = _reach_client_create(connection); - assert(client != NULL); - - dispatch_sync(_reach_clients_rbt_queue(), ^{ - rb_tree_t *rbt = _reach_clients_rbt(); - - rb_tree_insert_node(rbt, client); - }); - - xpc_connection_set_target_queue(connection, _reach_server_queue()); - - xpc_connection_set_event_handler(connection, ^(xpc_object_t xobj) { - xpc_type_t type; - - type = xpc_get_type(xobj); - if (type == XPC_TYPE_DICTIONARY) { - __block reach_client_t *client = NULL; - - dispatch_sync(_reach_clients_rbt_queue(), ^{ - uint64_t connection_id = (uintptr_t)connection; - rb_tree_t *rbt = _reach_clients_rbt(); - - client = rb_tree_find_node(rbt, &connection_id); - }); - - if (client != NULL) { - // process the request - process_request(client, xobj); - } else { - char *desc; - - SCLog(TRUE, LOG_ERR, - CFSTR("<%p:%d> unexpected SCNetworkReachability request"), - connection, - xpc_connection_get_pid(connection)); - - desc = xpc_copy_description(xobj); - SCLog(TRUE, LOG_ERR, - CFSTR(" request = %s"), - desc); - free(desc); - - xpc_connection_cancel(connection); - } - - } else if (type == XPC_TYPE_ERROR) { - const char *desc; - - desc = xpc_dictionary_get_string(xobj, XPC_ERROR_KEY_DESCRIPTION); - if (xobj == XPC_ERROR_CONNECTION_INVALID) { - if (S_debug) { - SCLog(TRUE, LOG_INFO, - CFSTR("<%p:%d> %s"), - connection, - xpc_connection_get_pid(connection), - desc); - } - - _reach_client_remove(connection); - - } else if (xobj == XPC_ERROR_CONNECTION_INTERRUPTED) { - SCLog(TRUE, LOG_ERR, - CFSTR("<%p:%d> %s"), - connection, - xpc_connection_get_pid(connection), - desc); - - } else { - SCLog(TRUE, LOG_ERR, - CFSTR("<%p:%d> Connection error: %p : %s"), - connection, - xpc_connection_get_pid(connection), - xobj, - desc); - } - - } else { - SCLog(TRUE, LOG_ERR, - CFSTR("<%p:%d> unknown event type : %p"), - connection, - xpc_connection_get_pid(connection), - type); - } - }); - - xpc_connection_resume(connection); - - return; -} - - -#pragma mark - -#pragma mark Reachability server "main" - - -__private_extern__ -void -load_SCNetworkReachability(CFBundleRef bundle, Boolean bundleVerbose) -{ - xpc_connection_t connection; - const char *name; - - S_debug = bundleVerbose; - - /* - * create a dictionary mapping SCNetworkReachability [CFData] digests - * to SCNetworkReachability objects. - */ - reach_digest_map = CFDictionaryCreateMutable(NULL, - 0, - &kCFTypeDictionaryKeyCallBacks, - &kCFTypeDictionaryValueCallBacks); - - // create XPC listener - name = getenv("REACH_SERVER"); - if (name == NULL) { - name = REACH_SERVICE_NAME; - } - connection = xpc_connection_create_mach_service(name, - _reach_server_queue(), - XPC_CONNECTION_MACH_SERVICE_LISTENER); - - xpc_connection_set_event_handler(connection, ^(xpc_object_t event) { - xpc_type_t type; - - type = xpc_get_type(event); - if (type == XPC_TYPE_CONNECTION) { - process_new_connection(event); - - } else if (type == XPC_TYPE_ERROR) { - const char *desc; - - desc = xpc_dictionary_get_string(event, XPC_ERROR_KEY_DESCRIPTION); - if (event == XPC_ERROR_CONNECTION_INVALID) { - SCLog(TRUE, LOG_ERR, CFSTR("reach server: %s"), desc); - xpc_release(connection); - } else if (event == XPC_ERROR_CONNECTION_INTERRUPTED) { - SCLog(TRUE, LOG_ERR, CFSTR("reach server: %s"), desc); - } else { - SCLog(TRUE, LOG_ERR, - CFSTR("reach server: Connection error: %p : %s"), - event, - desc); - } - - } else { - SCLog(TRUE, LOG_ERR, - CFSTR("reach server: unknown event type : %p"), - type); - } - }); - xpc_connection_resume(connection); - - return; -} - -#ifdef MAIN - -int -main(int argc, char **argv) -{ -// _sc_log = FALSE; - _sc_verbose = (argc > 1) ? TRUE : FALSE; - _sc_debug = TRUE; - - load_SCNetworkReachability(CFBundleGetMainBundle(), (argc > 1) ? TRUE : FALSE); - CFRunLoopRun(); - /* not reached */ - exit(0); - return 0; -} - -#endif /* MAIN */ diff --git a/SystemConfiguration.fproj/reachability/client.c b/SystemConfiguration.fproj/reachability/client.c deleted file mode 100644 index 85279fb..0000000 --- a/SystemConfiguration.fproj/reachability/client.c +++ /dev/null @@ -1,100 +0,0 @@ -#include -#include -#include -#include -#include -#include - -#include "SCNetworkReachabilityInternal.h" - -int -main(int argc, char **argv) -{ - Boolean ok; - SCNetworkReachabilityRef target1; - SCNetworkReachabilityRef target2; - SCNetworkReachabilityRef target3; - SCNetworkReachabilityRef target4; - SCNetworkReachabilityRef target5; - - _sc_log = FALSE; - _sc_debug = TRUE; // extra reachability logging - - target1 = SCNetworkReachabilityCreateWithName(NULL, "web.apple.com"); - ok = __SCNetworkReachabilityServer_targetAdd(target1); - if (!ok) { - SCLog(TRUE, LOG_ERR, CFSTR("No reachability server")); - exit(1); - } - - target2 = SCNetworkReachabilityCreateWithName(NULL, "www.comcast.net"); - __SCNetworkReachabilityServer_targetAdd(target2); - - target3 = SCNetworkReachabilityCreateWithName(NULL, "www.comcast.net"); - __SCNetworkReachabilityServer_targetAdd(target3); - - target4 = SCNetworkReachabilityCreateWithName(NULL, "www.nonexistenthost.com"); - __SCNetworkReachabilityServer_targetAdd(target4); - - target5 = SCNetworkReachabilityCreateWithName(NULL, "www.washingtonpost.com"); - __SCNetworkReachabilityServer_targetAdd(target5); - - __SCNetworkReachabilityServer_targetStatus(target1); - __SCNetworkReachabilityServer_targetStatus(target2); - __SCNetworkReachabilityServer_targetStatus(target3); - __SCNetworkReachabilityServer_targetStatus(target4); - - __SCNetworkReachabilityServer_targetMonitor(target1, TRUE); - __SCNetworkReachabilityServer_targetMonitor(target4, TRUE); - __SCNetworkReachabilityServer_targetMonitor(target5, TRUE); - - __SCNetworkReachabilityServer_targetStatus(target4); - __SCNetworkReachabilityServer_targetStatus(target3); - __SCNetworkReachabilityServer_targetStatus(target2); - __SCNetworkReachabilityServer_targetStatus(target1); - - sleep(2); - - __SCNetworkReachabilityServer_targetStatus(target1); - __SCNetworkReachabilityServer_targetStatus(target4); - __SCNetworkReachabilityServer_targetStatus(target1); - __SCNetworkReachabilityServer_targetStatus(target4); - - __SCNetworkReachabilityServer_targetMonitor(target1, FALSE); - - __SCNetworkReachabilityServer_targetStatus(target1); - __SCNetworkReachabilityServer_targetStatus(target4); - __SCNetworkReachabilityServer_targetStatus(target1); - __SCNetworkReachabilityServer_targetStatus(target4); - - __SCNetworkReachabilityServer_targetMonitor(target4, FALSE); - - __SCNetworkReachabilityServer_targetStatus(target1); - __SCNetworkReachabilityServer_targetStatus(target4); - -// SCLog(TRUE, LOG_DEBUG, CFSTR("starting CFRunLoop")); -// CFRunLoopRun(); -// SCLog(TRUE, LOG_DEBUG, CFSTR("CFRunLoop complete")); - - SCLog(TRUE, LOG_DEBUG, CFSTR("sleeping")); - sleep(60); - - __SCNetworkReachabilityServer_targetStatus(target5); - __SCNetworkReachabilityServer_targetRemove(target5); - CFRelease(target5); - - __SCNetworkReachabilityServer_targetRemove(target4); - CFRelease(target4); - - __SCNetworkReachabilityServer_targetRemove(target3); - CFRelease(target3); - -// __SCNetworkReachabilityServer_targetRemove(target2); -// CFRelease(target2); - -// __SCNetworkReachabilityServer_targetRemove(target1); -// CFRelease(target1); - - exit(0); -} - diff --git a/SystemConfiguration.fproj/reachability/server.c b/SystemConfiguration.fproj/reachability/server.c deleted file mode 100644 index 09e97c6..0000000 --- a/SystemConfiguration.fproj/reachability/server.c +++ /dev/null @@ -1,23 +0,0 @@ -#include -#include -#include -#include -#include -#include - -#include "SCNetworkReachabilityInternal.h" - -int -main(int argc, char **argv) -{ - _sc_log = FALSE; // no syslog - _sc_debug = TRUE; // extra reachability logging - - _SCNetworkReachabilityServer_start(); - - SCLog(TRUE, LOG_DEBUG, CFSTR("starting CFRunLoop")); - CFRunLoopRun(); - SCLog(TRUE, LOG_DEBUG, CFSTR("CFRunLoop complete")); - - exit(0); -} diff --git a/SystemConfiguration.fproj/scprefs_observer.c b/SystemConfiguration.fproj/scprefs_observer.c index 7ac2898..e4a9dec 100644 --- a/SystemConfiguration.fproj/scprefs_observer.c +++ b/SystemConfiguration.fproj/scprefs_observer.c @@ -1,15 +1,15 @@ /* - * Copyright (c) 2012, 2013 Apple Inc. All rights reserved. + * Copyright (c) 2012, 2013, 2015 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ - * + * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. - * + * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, @@ -17,7 +17,7 @@ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. - * + * * @APPLE_LICENSE_HEADER_END@ */ #include @@ -30,6 +30,17 @@ #include #include +#define MANAGED_PREFERENCES_PATH "/Library/Managed Preferences" +#if TARGET_OS_IPHONE +#define MOBILE_PREFERENCES_PATH "/var/mobile/Library/Preferences" +#endif // TARGET_OS_IPHONE + +#if !TARGET_OS_IPHONE +#define PREFS_OBSERVER_KEY "com.apple.MCX._managementStatusChangedForDomains" +#else // !TARGET_OS_IPHONE +#define PREFS_OBSERVER_KEY "com.apple.ManagedConfiguration.profileListChanged" +#endif // !TARGET_OS_IPHONE + #pragma mark - #pragma mark Utils @@ -109,17 +120,16 @@ struct _scprefs_observer_t { char file[0]; }; -#define MOBILE_PREFERENCES_PATH "/var/mobile/Library/Preferences" static const char * prefs_observer_get_prefs_path(scprefs_observer_t observer) { switch (observer->type) { #if !TARGET_OS_IPHONE case scprefs_observer_type_mcx: - return ("/Library/Managed Preferences"); + return MANAGED_PREFERENCES_PATH; #else // !TARGET_OS_IPHONE case scprefs_observer_type_global: - return ("/Library/Managed Preferences"); + return MANAGED_PREFERENCES_PATH; case scprefs_observer_type_profile: return MOBILE_PREFERENCES_PATH; #endif // !TARGET_OS_IPHONE @@ -153,9 +163,10 @@ has_changed(scprefs_observer_t observer) { observer->digest = digest; - SCLog(_sc_verbose, LOG_NOTICE, CFSTR("The following file: %s, %s \n"), - observer->file, (changed)?"has changed":"has not changed"); - return (changed); + SC_log(LOG_INFO, "preferences file: \"%s\", %s", + observer->file, + changed ? "has changed" : "has not changed"); + return changed; } static dispatch_queue_t @@ -182,7 +193,7 @@ prefs_observer_handle_notifications() { scprefs_observer_t observer; - SCLog(_sc_verbose, LOG_NOTICE, CFSTR("PrefsObserver Notification received \n")); + SC_log(LOG_INFO, "PrefsObserver notification received"); SLIST_FOREACH(observer, &head, next) { /* if the preferences plist has changed, @@ -193,7 +204,6 @@ prefs_observer_handle_notifications() } } -#define PREFS_OBSERVER_KEY "com.apple.ManagedConfiguration.profileListChanged" static void _prefs_observer_init() { @@ -247,8 +257,7 @@ _scprefs_observer_watch(_scprefs_observer_type type, const char *plist_name, }); elem = prefs_observer_priv_create(type, plist_name, queue, block); - SCLog(_sc_verbose, LOG_NOTICE, CFSTR("Created a new element to watch for %s \n"), - elem->file); + SC_log(LOG_INFO, "Created a new element to watch for %s", elem->file); dispatch_sync(prefs_observer_queue, ^{ /* Enqueue the request */ diff --git a/SystemConfiguration.fproj/update-headers b/SystemConfiguration.fproj/update-headers index c1c1104..05b247d 100755 --- a/SystemConfiguration.fproj/update-headers +++ b/SystemConfiguration.fproj/update-headers @@ -6,6 +6,8 @@ if (!$ENV{"INSTALL_DIR"} or !$ENV{"PUBLIC_HEADERS_FOLDER_PATH"} or !$ENV{"PRIVAT $DO_SPLIT = ($#ARGV >= 0 and $ARGV[0] eq "split"); +$USING_PRIVATE_SYSTEMCONFIGURATION_FRAMEWORK = $ENV{"USING_PRIVATE_SYSTEMCONFIGURATION_FRAMEWORK"} eq "YES"; + $API_BASE = $ENV{"INSTALL_DIR"} . "/" . $ENV{"PUBLIC_HEADERS_FOLDER_PATH"}; $SPI_BASE = $ENV{"INSTALL_DIR"} . "/" . $ENV{"PRIVATE_HEADERS_FOLDER_PATH"}; @@ -42,6 +44,19 @@ sub clean_SPI { return $spi_new; } +sub create_STUB { + my ($api_header) = @_; + my ($stub_new); + + $stub_new = " +#warning \"Please #include instead of this file directly.\" +#include +"; + $stub_new =~ s/PUBLIC.h/$api_header/g; + + return $stub_new; +} + # # Update .../PrivateHeaders # @@ -95,7 +110,9 @@ for (@headers) { close(API); $api_new = clean_API($api); - if ($api ne $api_new) { + next if ($api eq $api_new); # if no tweaks needed + + if (!$USING_PRIVATE_SYSTEMCONFIGURATION_FRAMEWORK) { printf "cleaning .../Headers/%s\n", $api_header; open(API, ">", $api_path); print API $api_new; @@ -121,6 +138,29 @@ for (@headers) { close(SPI); } } + } else { + $spi_new = clean_SPI($api); + if ($api_new ne $spi_new) { + if ((($stub_header) = ($api =~ /#ifdef\s+USE_SYSTEMCONFIGURATION_PRIVATE_HEADERS\s*.*?\n#include\s+\s*.*?\n/))) { + if ($api_header eq $stub_header) { + die "API & STUB header not unique: $api_header\n"; + } + } else { + die "Header missing #ifdef/#else/#endif: $api_header\n"; + } + + printf "updating .../Headers/%s\n", $api_header; + open(API, ">", $api_path); + print API $spi_new; + close(API); + + printf " adding .../PrivateHeaders/%s (stub)\n", $stub_header; + $stub_path = $SPI_BASE . "/" . $stub_header; + $stub_new = create_STUB($api_header); + open(STUB, ">", $stub_path); + print STUB $stub_new; + close(STUB); + } } } $/ = "\n"; diff --git a/common/reference_output.sh b/common/reference_output.sh new file mode 100644 index 0000000..b21ea5e --- /dev/null +++ b/common/reference_output.sh @@ -0,0 +1,87 @@ +#!/bin/sh + +tmpfile=/tmp/test_reference_output$$.txt + +cleanup() +{ + if [ -f "${tmpfile}" ]; then + echo removing "${tmpfile}" + rm -f "${tmpfile}" + fi + exit 1 +} + +trap cleanup 1 2 3 15 + +run_program() +{ + program="${1}" + filter="${2}" + if [ "${filter}" = "" ]; then + ${program} + else + ${program} | ${filter} + fi +} + +usage() +{ + echo "usage: $0 ( create | test ) [ ]" + exit 1 +} + +command="${1}" +program="${2}" +ref_file="${3}" +filter="${4}" + +if [ "${ref_file}" = "" ]; then + usage "${0}" +fi + +if [ "${program}" = "" ]; then + usage "${0}" +fi + +if [ ! -f "${program}" ]; then + echo "program '${program}' doesn't exit" + exit 1 +fi +if [ ! -x "${program}" ]; then + program="sh ${program}" +fi +# echo "The program is ${program}" + +if [ ! "${filter}" = "" ]; then + if [ ! -f "${filter}" ]; then + echo "filter '${filter}' doesn't exit" + exit 1 + fi + if [ ! -x "${filter}" ]; then + filter="sh ${filter}" + fi +# echo "The filter is ${filter}" +else + echo no filter +fi + +if [ "${command}" = "create" ]; then + run_program "${program}" "${filter}" > "${ref_file}" +elif [ "${command}" = "test" ]; then + if [ ! -f "${ref_file}" ]; then + echo "reference file '${ref_file}' doesn't exist" + exit 1 + fi + run_program "${program}" "${filter}" > "${tmpfile}" + cmp "${tmpfile}" "${ref_file}" + if [ ! $? -eq 0 ]; then + echo FAILURE + diff "${tmpfile}" "${ref_file}" + exit 1 + fi + echo SUCCESS +else + usage "${0}" +fi + +exit 0 diff --git a/configd.tproj/_SCD.c b/configd.tproj/_SCD.c index c54f4ba..8d30d47 100644 --- a/configd.tproj/_SCD.c +++ b/configd.tproj/_SCD.c @@ -1,15 +1,15 @@ /* - * Copyright (c) 2000, 2001, 2003-2005, 2009, 2011, 2012 Apple Inc. All rights reserved. + * Copyright (c) 2000, 2001, 2003-2005, 2009, 2011, 2012, 2015 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ - * + * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. - * + * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, @@ -17,7 +17,7 @@ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. - * + * * @APPLE_LICENSE_HEADER_END@ */ @@ -132,7 +132,7 @@ _addWatcher(CFNumberRef sessionNum, CFStringRef watchedKey) CFRelease(newDict); #ifdef DEBUG - SCLog(_configd_verbose, LOG_DEBUG, CFSTR(" _addWatcher: %@, %@"), sessionNum, watchedKey); + SC_log(LOG_DEBUG, " _addWatcher: %@, %@", sessionNum, watchedKey); #endif /* DEBUG */ return; @@ -160,7 +160,7 @@ _removeWatcher(CFNumberRef sessionNum, CFStringRef watchedKey) if ((dict == NULL) || (CFDictionaryContainsKey(dict, kSCDWatchers) == FALSE)) { /* key doesn't exist (isn't this really fatal?) */ #ifdef DEBUG - SCLog(_configd_verbose, LOG_DEBUG, CFSTR(" _removeWatcher: %@, %@, key not watched"), sessionNum, watchedKey); + SC_log(LOG_DEBUG, " _removeWatcher: %@, %@, key not watched", sessionNum, watchedKey); #endif /* DEBUG */ return; } @@ -182,7 +182,7 @@ _removeWatcher(CFNumberRef sessionNum, CFStringRef watchedKey) sessionNum); if (i == kCFNotFound) { #ifdef DEBUG - SCLog(_configd_verbose, LOG_DEBUG, CFSTR(" _removeWatcher: %@, %@, session not watching"), sessionNum, watchedKey); + SC_log(LOG_DEBUG, " _removeWatcher: %@, %@, session not watching", sessionNum, watchedKey); #endif /* DEBUG */ CFRelease(newDict); CFRelease(newWatchers); @@ -225,7 +225,7 @@ _removeWatcher(CFNumberRef sessionNum, CFStringRef watchedKey) CFRelease(newDict); #ifdef DEBUG - SCLog(_configd_verbose, LOG_DEBUG, CFSTR(" _removeWatcher: %@, %@"), sessionNum, watchedKey); + SC_log(LOG_DEBUG, " _removeWatcher: %@, %@", sessionNum, watchedKey); #endif /* DEBUG */ return; @@ -268,14 +268,11 @@ pushNotifications(FILE *_configd_trace) /* * Post notification as mach message */ - if (_configd_trace != NULL) { - SCTrace(TRUE, _configd_trace, - CFSTR("%s : %5d : port = %d, msgid = %d\n"), - "-->port", - storePrivate->server, - storePrivate->notifyPort, - storePrivate->notifyPortIdentifier); - } + SC_trace(_configd_trace, "%s : %5d : port = %d, msgid = %d\n", + "-->port", + storePrivate->server, + storePrivate->notifyPort, + storePrivate->notifyPortIdentifier); _SC_sendMachMessage(storePrivate->notifyPort, storePrivate->notifyPortIdentifier); } @@ -284,14 +281,11 @@ pushNotifications(FILE *_configd_trace) (storePrivate->notifyFile >= 0)) { ssize_t written; - if (_configd_trace != NULL) { - SCTrace(TRUE, _configd_trace, - CFSTR("%s : %5d : fd = %d, msgid = %d\n"), - "-->fd ", - storePrivate->server, - storePrivate->notifyFile, - storePrivate->notifyFileIdentifier); - } + SC_trace(_configd_trace, "%s : %5d : fd = %d, msgid = %d\n", + "-->fd ", + storePrivate->server, + storePrivate->notifyFile, + storePrivate->notifyFileIdentifier); written = write(storePrivate->notifyFile, &storePrivate->notifyFileIdentifier, @@ -299,21 +293,18 @@ pushNotifications(FILE *_configd_trace) if (written == -1) { if (errno == EWOULDBLOCK) { #ifdef DEBUG - SCLog(_configd_verbose, LOG_DEBUG, - CFSTR("sorry, only one outstanding notification per session.")); + SC_log(LOG_DEBUG, "sorry, only one outstanding notification per session"); #endif /* DEBUG */ } else { #ifdef DEBUG - SCLog(_configd_verbose, LOG_DEBUG, - CFSTR("could not send notification, write() failed: %s"), + SC_log(LOG_DEBUG, "could not send notification, write() failed: %s", strerror(errno)); #endif /* DEBUG */ storePrivate->notifyFile = -1; } } else if (written != sizeof(storePrivate->notifyFileIdentifier)) { #ifdef DEBUG - SCLog(_configd_verbose, LOG_DEBUG, - CFSTR("could not send notification, incomplete write()")); + SC_log(LOG_DEBUG, "could not send notification, incomplete write()"); #endif /* DEBUG */ storePrivate->notifyFile = -1; } @@ -328,23 +319,19 @@ pushNotifications(FILE *_configd_trace) */ status = pid_for_task(storePrivate->notifySignalTask, &pid); if (status == KERN_SUCCESS) { - if (_configd_trace != NULL) { - SCTrace(TRUE, _configd_trace, - CFSTR("%s : %5d : pid = %d, signal = sig%s (%d)\n"), - "-->sig ", - storePrivate->server, - pid, - sys_signame[storePrivate->notifySignal], - storePrivate->notifySignal); - } + SC_trace(_configd_trace, "%s : %5d : pid = %d, signal = sig%s (%d)\n", + "-->sig ", + storePrivate->server, + pid, + sys_signame[storePrivate->notifySignal], + storePrivate->notifySignal); if (kill(pid, storePrivate->notifySignal) != 0) { if (errno != ESRCH) { - SCLog(TRUE, LOG_ERR, - CFSTR("could not send sig%s to PID %d: %s"), - sys_signame[storePrivate->notifySignal], - pid, - strerror(errno)); + SC_log(LOG_NOTICE, "could not send sig%s to PID %d: %s", + sys_signame[storePrivate->notifySignal], + pid, + strerror(errno)); } } } else { @@ -353,10 +340,10 @@ pushNotifications(FILE *_configd_trace) __MACH_PORT_DEBUG(TRUE, "*** pushNotifications pid_for_task failed: releasing task", storePrivate->notifySignalTask); if (mach_port_type(mach_task_self(), storePrivate->notifySignalTask, &pt) == KERN_SUCCESS) { if ((pt & MACH_PORT_TYPE_DEAD_NAME) != 0) { - SCLog(TRUE, LOG_ERR, CFSTR("pushNotifications pid_for_task() failed: %s"), mach_error_string(status)); + SC_log(LOG_NOTICE, "pid_for_task() failed: %s", mach_error_string(status)); } } else { - SCLog(TRUE, LOG_ERR, CFSTR("pushNotifications mach_port_type() failed: %s"), mach_error_string(status)); + SC_log(LOG_NOTICE, "mach_port_type() failed: %s", mach_error_string(status)); } /* don't bother with any more attempts */ diff --git a/configd.tproj/_configadd.c b/configd.tproj/_configadd.c index 0f5b11e..0f84e88 100644 --- a/configd.tproj/_configadd.c +++ b/configd.tproj/_configadd.c @@ -1,15 +1,15 @@ /* - * Copyright (c) 2000, 2001, 2003, 2004, 2006, 2008, 2011, 2012, 2014 Apple Inc. All rights reserved. + * Copyright (c) 2000, 2001, 2003, 2004, 2006, 2008, 2011, 2012, 2014, 2015 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ - * + * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. - * + * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, @@ -17,7 +17,7 @@ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. - * + * * @APPLE_LICENSE_HEADER_END@ */ @@ -42,14 +42,11 @@ __SCDynamicStoreAddValue(SCDynamicStoreRef store, CFStringRef key, CFDataRef val SCDynamicStorePrivateRef storePrivate = (SCDynamicStorePrivateRef)store; CFDataRef tempValue; - if (_configd_trace) { - SCTrace(TRUE, _configd_trace, - CFSTR("%s%s : %5d : %@\n"), - "add ", - storePrivate->useSessionKeys ? "t " : " ", - storePrivate->server, - key); - } + SC_trace(_configd_trace, "%s%s : %5d : %@\n", + "add ", + storePrivate->useSessionKeys ? "t " : " ", + storePrivate->server, + key); /* * Ensure that this is a new key. @@ -68,7 +65,7 @@ __SCDynamicStoreAddValue(SCDynamicStoreRef store, CFStringRef key, CFDataRef val default : #ifdef DEBUG - SCLog(_configd_verbose, LOG_DEBUG, CFSTR("__SCDynamicStoreAddValue __SCDynamicStoreCopyValue(): %s"), SCErrorString(sc_status)); + SC_log(LOG_DEBUG, "__SCDynamicStoreCopyValue() failed: %s", SCErrorString(sc_status)); #endif /* DEBUG */ goto done; } diff --git a/configd.tproj/_configclose.c b/configd.tproj/_configclose.c index 61729e4..2b0fd7b 100644 --- a/configd.tproj/_configclose.c +++ b/configd.tproj/_configclose.c @@ -1,15 +1,15 @@ /* - * Copyright (c) 2000, 2001, 2003, 2004, 2006-2012 Apple Inc. All rights reserved. + * Copyright (c) 2000, 2001, 2003, 2004, 2006-2012, 2015 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ - * + * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. - * + * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, @@ -17,7 +17,7 @@ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. - * + * * @APPLE_LICENSE_HEADER_END@ */ @@ -101,11 +101,8 @@ __SCDynamicStoreClose(SCDynamicStoreRef *store) CFStringRef sessionKey; SCDynamicStorePrivateRef storePrivate = (SCDynamicStorePrivateRef)*store; - if (_configd_trace) { - SCTrace(TRUE, _configd_trace, - CFSTR("close : %5d\n"), - storePrivate->server); - } + SC_trace(_configd_trace, "close : %5d\n", + storePrivate->server); /* Remove all notification keys and patterns */ removeAllKeys(*store, FALSE); // keys diff --git a/configd.tproj/_configget.c b/configd.tproj/_configget.c index ec842f7..7b0335f 100644 --- a/configd.tproj/_configget.c +++ b/configd.tproj/_configget.c @@ -1,15 +1,15 @@ /* - * Copyright (c) 2000-2006, 2008, 2011, 2013, 2014 Apple Inc. All rights reserved. + * Copyright (c) 2000-2006, 2008, 2011, 2013-2015 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ - * + * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. - * + * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, @@ -17,7 +17,7 @@ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. - * + * * @APPLE_LICENSE_HEADER_END@ */ @@ -41,13 +41,10 @@ __SCDynamicStoreCopyValue(SCDynamicStoreRef store, CFStringRef key, CFDataRef *v SCDynamicStorePrivateRef storePrivate = (SCDynamicStorePrivateRef)store; CFDictionaryRef dict; - if (_configd_trace) { - SCTrace(TRUE, _configd_trace, - CFSTR("%s : %5d : %@\n"), - internal ? "*copy " : "copy ", - storePrivate->server, - key); - } + SC_trace(_configd_trace, "%s : %5d : %@\n", + internal ? "*copy " : "copy ", + storePrivate->server, + key); dict = CFDictionaryGetValue(storeData, key); if ((dict == NULL) || (CFDictionaryContainsKey(dict, kSCDData) == FALSE)) { @@ -187,13 +184,10 @@ __SCDynamicStoreCopyMultiple(SCDynamicStoreRef store, CFArrayRef keys, CFArrayRe SCDynamicStorePrivateRef storePrivate = (SCDynamicStorePrivateRef)store; addSpecific myContext; - if (_configd_trace) { - SCTrace(TRUE, _configd_trace, - CFSTR("copy m : %5d : %ld keys, %ld patterns\n"), - storePrivate->server, - keys ? CFArrayGetCount(keys) : 0, - patterns ? CFArrayGetCount(patterns) : 0); - } + SC_trace(_configd_trace, "copy m : %5d : %ld keys, %ld patterns\n", + storePrivate->server, + keys ? CFArrayGetCount(keys) : 0, + patterns ? CFArrayGetCount(patterns) : 0); myContext.store = store; myContext.dict = CFDictionaryCreateMutable(NULL, diff --git a/configd.tproj/_configlist.c b/configd.tproj/_configlist.c index 95f655c..355a4af 100644 --- a/configd.tproj/_configlist.c +++ b/configd.tproj/_configlist.c @@ -1,15 +1,15 @@ /* - * Copyright (c) 2000-2008, 2011, 2013 Apple Inc. All rights reserved. + * Copyright (c) 2000-2008, 2011, 2013, 2015 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ - * + * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. - * + * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, @@ -17,7 +17,7 @@ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. - * + * * @APPLE_LICENSE_HEADER_END@ */ @@ -43,9 +43,16 @@ __SCDynamicStoreCopyKeyList(SCDynamicStoreRef store, CFStringRef key, Boolean is { CFMutableArrayRef keyArray; CFIndex storeCnt; + SCDynamicStorePrivateRef storePrivate = (SCDynamicStorePrivateRef)store; CFStringRef storeStr; CFDictionaryRef storeValue; + SC_trace(_configd_trace, "%s : %5d : %s : %@\n", + "list ", + storePrivate->server, + isRegex ? "pattern" : "key", + key); + if (isRegex) { *subKeys = patternCopyMatches(key); return (*subKeys != NULL) ? kSCStatusOK : kSCStatusFailed; diff --git a/configd.tproj/_confignotify.c b/configd.tproj/_confignotify.c index ee85c5c..76cc73d 100644 --- a/configd.tproj/_confignotify.c +++ b/configd.tproj/_confignotify.c @@ -1,15 +1,15 @@ /* - * Copyright (c) 2000-2004, 2006, 2008, 2011, 2012 Apple Inc. All rights reserved. + * Copyright (c) 2000-2004, 2006, 2008, 2011, 2012, 2015 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ - * + * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. - * + * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, @@ -17,7 +17,7 @@ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. - * + * * @APPLE_LICENSE_HEADER_END@ */ @@ -41,13 +41,10 @@ __SCDynamicStoreNotifyValue(SCDynamicStoreRef store, CFStringRef key, Boolean in int sc_status = kSCStatusOK; CFDataRef value; - if (_configd_trace) { - SCTrace(TRUE, _configd_trace, - CFSTR("%s : %5d : %@\n"), - internal ? "*notify" : "notify ", - storePrivate->server, - key); - } + SC_trace(_configd_trace, "%s : %5d : %@\n", + internal ? "*notify" : "notify ", + storePrivate->server, + key); /* * Tickle the value in the dynamic store diff --git a/configd.tproj/_configopen.c b/configd.tproj/_configopen.c index 07a49f9..4d68d9b 100644 --- a/configd.tproj/_configopen.c +++ b/configd.tproj/_configopen.c @@ -1,15 +1,15 @@ /* - * Copyright (c) 2000-2009, 2011 Apple Inc. All rights reserved. + * Copyright (c) 2000-2009, 2011, 2015 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ - * + * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. - * + * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, @@ -17,7 +17,7 @@ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. - * + * * @APPLE_LICENSE_HEADER_END@ */ @@ -154,9 +154,7 @@ _configopen(mach_port_t server, */ mySession = addSession(server, openMPCopyDescription); if (mySession == NULL) { -#ifdef DEBUG - SCLog(TRUE, LOG_DEBUG, CFSTR("_configopen(): session is already open.")); -#endif /* DEBUG */ + SC_log(LOG_NOTICE, "session is already open"); *sc_status = kSCStatusFailed; /* you can't re-open an "open" session */ goto done; } @@ -173,12 +171,9 @@ _configopen(mach_port_t server, mySession->serverRunLoopSource, kCFRunLoopDefaultMode); - if (_configd_trace) { - SCTrace(TRUE, _configd_trace, - CFSTR("open : %5d : %@\n"), - *newServer, - name); - } + SC_trace(_configd_trace, "open : %5d : %@\n", + *newServer, + name); *sc_status = __SCDynamicStoreOpen(&mySession->store, name); storePrivate = (SCDynamicStorePrivateRef)mySession->store; @@ -205,7 +200,7 @@ _configopen(mach_port_t server, MACH_MSG_TYPE_MAKE_SEND_ONCE, &oldNotify); if (status != KERN_SUCCESS) { - SCLog(TRUE, LOG_ERR, CFSTR("_configopen() mach_port_request_notification() failed: %s"), mach_error_string(status)); + SC_log(LOG_NOTICE, "mach_port_request_notification() failed: %s", mach_error_string(status)); cleanupSession(*newServer); *newServer = MACH_PORT_NULL; *sc_status = kSCStatusFailed; @@ -214,7 +209,7 @@ _configopen(mach_port_t server, __MACH_PORT_DEBUG(TRUE, "*** _configopen (after mach_port_request_notification)", *newServer); if (oldNotify != MACH_PORT_NULL) { - SCLog(TRUE, LOG_ERR, CFSTR("_configopen(): oldNotify != MACH_PORT_NULL")); + SC_log(LOG_NOTICE, "oldNotify != MACH_PORT_NULL"); } /* diff --git a/configd.tproj/_configremove.c b/configd.tproj/_configremove.c index eb27106..2cffdeb 100644 --- a/configd.tproj/_configremove.c +++ b/configd.tproj/_configremove.c @@ -1,15 +1,15 @@ /* - * Copyright (c) 2000-2004, 2006, 2008, 2011, 2012 Apple Inc. All rights reserved. + * Copyright (c) 2000-2004, 2006, 2008, 2011, 2012, 2015 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ - * + * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. - * + * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, @@ -17,7 +17,7 @@ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. - * + * * @APPLE_LICENSE_HEADER_END@ */ @@ -44,13 +44,10 @@ __SCDynamicStoreRemoveValue(SCDynamicStoreRef store, CFStringRef key, Boolean in int sc_status = kSCStatusOK; CFStringRef sessionKey; - if (_configd_trace) { - SCTrace(TRUE, _configd_trace, - CFSTR("%s : %5d : %@\n"), - internal ? "*remove" : "remove ", - storePrivate->server, - key); - } + SC_trace(_configd_trace, "%s : %5d : %@\n", + internal ? "*remove" : "remove ", + storePrivate->server, + key); /* * Ensure that this key exists. diff --git a/configd.tproj/_configset.c b/configd.tproj/_configset.c index 9ab2725..16044ad 100644 --- a/configd.tproj/_configset.c +++ b/configd.tproj/_configset.c @@ -1,15 +1,15 @@ /* - * Copyright (c) 2000-2004, 2006, 2008, 2011, 2012, 2014 Apple Inc. All rights reserved. + * Copyright (c) 2000-2004, 2006, 2008, 2011, 2012, 2014, 2015 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ - * + * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. - * + * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, @@ -17,7 +17,7 @@ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. - * + * * @APPLE_LICENSE_HEADER_END@ */ @@ -49,14 +49,11 @@ __SCDynamicStoreSetValue(SCDynamicStoreRef store, CFStringRef key, CFDataRef val SCDynamicStorePrivateRef storePrivate = (SCDynamicStorePrivateRef)store; CFStringRef storeSessionKey; - if (_configd_trace) { - SCTrace(TRUE, _configd_trace, - CFSTR("%s%s : %5d : %@\n"), - internal ? "*set " : "set ", - storePrivate->useSessionKeys ? "t " : " ", - storePrivate->server, - key); - } + SC_trace(_configd_trace, "%s%s : %5d : %@\n", + internal ? "*set " : "set ", + storePrivate->useSessionKeys ? "t " : " ", + storePrivate->server, + key); /* * Grab the current (or establish a new) dictionary for this key. @@ -327,14 +324,11 @@ __SCDynamicStoreSetMultiple(SCDynamicStoreRef store, CFDictionaryRef keysToSet, int sc_status = kSCStatusOK; SCDynamicStorePrivateRef storePrivate = (SCDynamicStorePrivateRef)store; - if (_configd_trace) { - SCTrace(TRUE, _configd_trace, - CFSTR("set m : %5d : %ld set, %ld remove, %ld notify\n"), - storePrivate->server, - keysToSet ? CFDictionaryGetCount(keysToSet) : 0, - keysToRemove ? CFArrayGetCount (keysToRemove) : 0, - keysToNotify ? CFArrayGetCount (keysToNotify) : 0); - } + SC_trace(_configd_trace, "set m : %5d : %ld set, %ld remove, %ld notify\n", + storePrivate->server, + keysToSet ? CFDictionaryGetCount(keysToSet) : 0, + keysToRemove ? CFArrayGetCount (keysToRemove) : 0, + keysToNotify ? CFArrayGetCount (keysToNotify) : 0); /* * Set the new/updated keys diff --git a/configd.tproj/_notifyadd.c b/configd.tproj/_notifyadd.c index c486ce6..17506fb 100644 --- a/configd.tproj/_notifyadd.c +++ b/configd.tproj/_notifyadd.c @@ -1,15 +1,15 @@ /* - * Copyright (c) 2000-2004, 2006, 2008, 2010, 2011, 2014 Apple Inc. All rights reserved. + * Copyright (c) 2000-2004, 2006, 2008, 2010, 2011, 2014, 2015 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ - * + * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. - * + * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, @@ -17,7 +17,7 @@ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. - * + * * @APPLE_LICENSE_HEADER_END@ */ @@ -89,14 +89,11 @@ __SCDynamicStoreAddWatchedKey(SCDynamicStoreRef store, CFStringRef key, Boolean CFNumberRef sessionNum = NULL; SCDynamicStorePrivateRef storePrivate = (SCDynamicStorePrivateRef)store; - if (_configd_trace) { - SCTrace(TRUE, _configd_trace, - CFSTR("%s : %5d : %s : %@\n"), - internal ? "*watch+" : "watch+ ", - storePrivate->server, - isRegex ? "pattern" : "key", - key); - } + SC_trace(_configd_trace, "%s : %5d : %s : %@\n", + internal ? "*watch+" : "watch+ ", + storePrivate->server, + isRegex ? "pattern" : "key", + key); sessionNum = CFNumberCreate(NULL, kCFNumberIntType, &storePrivate->server); @@ -246,13 +243,10 @@ __SCDynamicStoreSetNotificationKeys(SCDynamicStoreRef store, CFArrayRef keys, CF updateKeysContext myContext; SCDynamicStorePrivateRef storePrivate = (SCDynamicStorePrivateRef)store; - if (_configd_trace) { - SCTrace(TRUE, _configd_trace, - CFSTR("watch : %5d : %ld keys, %ld patterns\n"), - storePrivate->server, - keys ? CFArrayGetCount(keys) : 0, - patterns ? CFArrayGetCount(patterns) : 0); - } + SC_trace(_configd_trace, "watch : %5d : %ld keys, %ld patterns\n", + storePrivate->server, + keys ? CFArrayGetCount(keys) : 0, + patterns ? CFArrayGetCount(patterns) : 0); myContext.store = store; myContext.sc_status = kSCStatusOK; diff --git a/configd.tproj/_notifyremove.c b/configd.tproj/_notifyremove.c index 9c894a5..f3269b8 100644 --- a/configd.tproj/_notifyremove.c +++ b/configd.tproj/_notifyremove.c @@ -1,15 +1,15 @@ /* - * Copyright (c) 2000-2004, 2006, 2008, 2010-2012 Apple Inc. All rights reserved. + * Copyright (c) 2000-2004, 2006, 2008, 2010-2012, 2015 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ - * + * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. - * + * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, @@ -17,7 +17,7 @@ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. - * + * * @APPLE_LICENSE_HEADER_END@ */ @@ -69,14 +69,11 @@ __SCDynamicStoreRemoveWatchedKey(SCDynamicStoreRef store, CFStringRef key, Boole CFNumberRef sessionNum; SCDynamicStorePrivateRef storePrivate = (SCDynamicStorePrivateRef)store; - if (_configd_trace) { - SCTrace(TRUE, _configd_trace, - CFSTR("%s : %5d : %s : %@\n"), - internal ? "*watch-" : "watch- ", - storePrivate->server, - isRegex ? "pattern" : "key", - key); - } + SC_trace(_configd_trace, "%s : %5d : %s : %@\n", + internal ? "*watch-" : "watch- ", + storePrivate->server, + isRegex ? "pattern" : "key", + key); /* * remove key from this sessions notifier list after checking that diff --git a/configd.tproj/_notifyviafd.c b/configd.tproj/_notifyviafd.c index f855c6b..e96132d 100644 --- a/configd.tproj/_notifyviafd.c +++ b/configd.tproj/_notifyviafd.c @@ -1,15 +1,15 @@ /* - * Copyright (c) 2000, 2001, 2003-2006, 2008-2011 Apple Inc. All rights reserved. + * Copyright (c) 2000, 2001, 2003-2006, 2008-2011, 2015 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ - * + * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. - * + * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, @@ -17,7 +17,7 @@ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. - * + * * @APPLE_LICENSE_HEADER_END@ */ @@ -59,7 +59,7 @@ __SCDynamicStoreNotifyFileDescriptor(SCDynamicStoreRef store, } if ((sock = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) { - SCLog(TRUE, LOG_NOTICE, CFSTR("__SCDynamicStoreNotifyFileDescriptor socket() failed: %s"), strerror(errno)); + SC_log(LOG_ERR, "socket() failed: %s", strerror(errno)); return kSCStatusFailed; } @@ -107,7 +107,7 @@ _notifyviafd(mach_port_t server, */ /* validate the UNIX domain socket path */ if (pathLen > (sizeof(un.sun_path) - 1)) { - SCLog(TRUE, LOG_NOTICE, CFSTR("_notifyviafd(): domain socket path length too long!")); + SC_log(LOG_INFO, "domain socket path length too long!"); (void) vm_deallocate(mach_task_self(), (vm_address_t)pathRef, pathLen); *sc_status = kSCStatusFailed; return KERN_SUCCESS; @@ -132,19 +132,19 @@ _notifyviafd(mach_port_t server, bzero(&statbuf, sizeof(statbuf)); if (stat(un.sun_path, &statbuf) == -1) { *sc_status = errno; - SCLog(TRUE, LOG_DEBUG, CFSTR("_notifyviafd stat() failed: %s"), strerror(errno)); + SC_log(LOG_INFO, "stat() failed: %s", strerror(errno)); return KERN_SUCCESS; } if (mySession->callerEUID != statbuf.st_uid) { *sc_status = kSCStatusAccessError; - SCLog(TRUE, LOG_DEBUG, CFSTR("_notifyviafd permissions error")); + SC_log(LOG_INFO, "permissions error [eUID]"); return KERN_SUCCESS; } } if (!hasPathAccess(mySession, un.sun_path)) { *sc_status = kSCStatusAccessError; - SCLog(TRUE, LOG_DEBUG, CFSTR("_notifyviafd permissions error")); + SC_log(LOG_INFO, "permissions error [path]"); return KERN_SUCCESS; } @@ -159,7 +159,7 @@ _notifyviafd(mach_port_t server, /* establish the connection, get ready for a read() */ if (connect(sock, (struct sockaddr *)&un, sizeof(un)) == -1) { *sc_status = errno; - SCLog(TRUE, LOG_DEBUG, CFSTR("_notifyviafd connect() failed: %s"), strerror(errno)); + SC_log(LOG_INFO, "connect() failed: %s", strerror(errno)); (void) close(sock); return KERN_SUCCESS; } @@ -167,7 +167,7 @@ _notifyviafd(mach_port_t server, bufSiz = sizeof(storePrivate->notifyFileIdentifier); if (setsockopt(sock, SOL_SOCKET, SO_SNDBUF, &bufSiz, sizeof(bufSiz)) == -1) { *sc_status = errno; - SCLog(TRUE, LOG_DEBUG, CFSTR("_notifyviafd setsockopt() failed: %s"), strerror(errno)); + SC_log(LOG_INFO, "setsockopt() failed: %s", strerror(errno)); (void) close(sock); return KERN_SUCCESS; } @@ -175,7 +175,7 @@ _notifyviafd(mach_port_t server, nbioYes = 1; if (ioctl(sock, FIONBIO, &nbioYes) == -1) { *sc_status = errno; - SCLog(TRUE, LOG_DEBUG, CFSTR("_notifyviafd ioctl(,FIONBIO,) failed: %s"), strerror(errno)); + SC_log(LOG_INFO, "ioctl(,FIONBIO,) failed: %s", strerror(errno)); (void) close(sock); return KERN_SUCCESS; } diff --git a/configd.tproj/_snapshot.c b/configd.tproj/_snapshot.c index be7b77b..b606be1 100644 --- a/configd.tproj/_snapshot.c +++ b/configd.tproj/_snapshot.c @@ -1,15 +1,15 @@ /* - * Copyright (c) 2000-2006, 2009-2011 Apple Inc. All rights reserved. + * Copyright (c) 2000-2006, 2009-2011, 2015 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ - * + * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. - * + * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, @@ -17,7 +17,7 @@ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. - * + * * @APPLE_LICENSE_HEADER_END@ */ @@ -159,7 +159,7 @@ __SCDynamicStoreSnapshot(SCDynamicStoreRef store) xmlData = CFPropertyListCreateData(NULL, expandedStoreData, kCFPropertyListXMLFormat_v1_0, 0, NULL); CFRelease(expandedStoreData); if (xmlData == NULL) { - SCLog(TRUE, LOG_ERR, CFSTR("__SCDynamicStoreSnapshot CFPropertyListCreateData() failed")); + SC_log(LOG_NOTICE, "CFPropertyListCreateData() failed"); close(fd); return kSCStatusFailed; } @@ -177,7 +177,7 @@ __SCDynamicStoreSnapshot(SCDynamicStoreRef store) xmlData = CFPropertyListCreateData(NULL, patternData, kCFPropertyListXMLFormat_v1_0, 0, NULL); if (xmlData == NULL) { - SCLog(TRUE, LOG_ERR, CFSTR("__SCDynamicStoreSnapshot CFPropertyListCreateData() failed")); + SC_log(LOG_NOTICE, "CFPropertyListCreateData() failed"); close(fd); return kSCStatusFailed; } @@ -195,7 +195,7 @@ __SCDynamicStoreSnapshot(SCDynamicStoreRef store) xmlData = CFPropertyListCreateData(NULL, sessionData, kCFPropertyListXMLFormat_v1_0, 0, NULL); if (xmlData == NULL) { - SCLog(TRUE, LOG_ERR, CFSTR("__SCDynamicStoreSnapshot CFPropertyListCreateData() failed")); + SC_log(LOG_NOTICE, "CFPropertyListCreateData() failed"); close(fd); return kSCStatusFailed; } diff --git a/configd.tproj/com.apple.configd.plist b/configd.tproj/com.apple.configd.plist index 983b4ff..b45f46c 100644 --- a/configd.tproj/com.apple.configd.plist +++ b/configd.tproj/com.apple.configd.plist @@ -21,5 +21,7 @@ Umask 18 + MinimalBootProfile + diff --git a/configd.tproj/configd.m b/configd.tproj/configd.m index c734112..d4dda37 100644 --- a/configd.tproj/configd.m +++ b/configd.tproj/configd.m @@ -1,15 +1,15 @@ /* - * Copyright (c) 2000-2011, 2013, 2014 Apple Inc. All rights reserved. + * Copyright (c) 2000-2011, 2013-2015 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ - * + * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. - * + * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, @@ -17,7 +17,7 @@ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. - * + * * @APPLE_LICENSE_HEADER_END@ */ @@ -197,7 +197,6 @@ init_fds() } } - SCTrace(TRUE, stdout, CFSTR("start\n")); return; } @@ -211,7 +210,7 @@ set_trace() fd = open("/var/log/configd.trace", O_WRONLY|O_APPEND, 0); if (fd != -1) { _configd_trace = fdopen(fd, "a"); - SCTrace(TRUE, _configd_trace, CFSTR("start\n")); + SC_trace(_configd_trace, "start\n"); } return; @@ -390,7 +389,7 @@ main(int argc, char * const argv[]) * daemonize ourself. */ if (fork_child() == -1) { - fprintf(stderr, "configd: fork() failed, %s\n", strerror(errno)); + fprintf(stderr, "configd: fork() failed: %s\n", strerror(errno)); exit (1); } @@ -407,7 +406,6 @@ main(int argc, char * const argv[]) if (!forceForeground || forcePlugin) { int facility = LOG_DAEMON; int logopt = LOG_CONS|LOG_NDELAY|LOG_PID; - struct stat statbuf; if (!is_launchd_job && !forcePlugin) { init_fds(); @@ -417,7 +415,7 @@ main(int argc, char * const argv[]) logopt |= LOG_CONS; } - if (stat("/etc/rc.cdrom", &statbuf) == 0) { + if (_SC_isInstallEnvironment()) { facility = LOG_INSTALL; } @@ -434,30 +432,22 @@ main(int argc, char * const argv[]) sigemptyset(&nact.sa_mask); nact.sa_flags = SA_RESTART; if (sigaction(SIGHUP, &nact, NULL) == -1) { - SCLog(_configd_verbose, LOG_ERR, - CFSTR("sigaction(SIGHUP, ...) failed: %s"), - strerror(errno)); + SC_log(LOG_ERR, "sigaction(SIGHUP, ...) failed: %s", strerror(errno)); } /* add signal handler to catch a SIGPIPE */ if (sigaction(SIGPIPE, &nact, NULL) == -1) { - SCLog(_configd_verbose, LOG_ERR, - CFSTR("sigaction(SIGPIPE, ...) failed: %s"), - strerror(errno)); + SC_log(LOG_ERR, "sigaction(SIGPIPE, ...) failed: %s", strerror(errno)); } /* add signal handler to catch a SIGTERM */ if (sigaction(SIGTERM, &nact, NULL) == -1) { - SCLog(_configd_verbose, LOG_ERR, - CFSTR("sigaction(SIGTERM, ...) failed: %s"), - strerror(errno)); + SC_log(LOG_ERR, "sigaction(SIGTERM, ...) failed: %s", strerror(errno)); } /* add signal handler to catch a SIGINT */ if (sigaction(SIGINT, &nact, NULL) == -1) { - SCLog(_configd_verbose, LOG_ERR, - CFSTR("sigaction(SIGINT, ...) failed: %s"), - strerror(errno)); + SC_log(LOG_ERR, "sigaction(SIGINT, ...) failed: %s", strerror(errno)); } /* create the "shutdown requested" notification port */ diff --git a/configd.tproj/configd_server.c b/configd.tproj/configd_server.c index bbbb9c1..182d629 100644 --- a/configd.tproj/configd_server.c +++ b/configd.tproj/configd_server.c @@ -1,15 +1,15 @@ /* - * Copyright (c) 2000-2011, 2013 Apple Inc. All rights reserved. + * Copyright (c) 2000-2011, 2013, 2015 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ - * + * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. - * + * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, @@ -17,7 +17,7 @@ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. - * + * * @APPLE_LICENSE_HEADER_END@ */ @@ -77,7 +77,7 @@ config_demux(mach_msg_header_t *request, mach_msg_header_t *reply) /* * unknown message ID, log and return an error. */ - SCLog(TRUE, LOG_ERR, CFSTR("config_demux(): unknown message ID (%d) received"), request->msgh_id); + SC_log(LOG_ERR, "unknown message ID (%d) received", request->msgh_id); reply->msgh_bits = MACH_MSGH_BITS(MACH_MSGH_BITS_REMOTE(request->msgh_bits), 0); reply->msgh_remote_port = request->msgh_remote_port; reply->msgh_size = sizeof(mig_reply_error_t); /* Minimal size */ @@ -97,6 +97,7 @@ __private_extern__ void configdCallback(CFMachPortRef port, void *msg, CFIndex size, void *info) { + os_activity_t activity_id; mig_reply_error_t * bufRequest = msg; uint32_t bufReply_q[MACH_MSG_BUFFER_SIZE/sizeof(uint32_t)]; mig_reply_error_t * bufReply = (mig_reply_error_t *)bufReply_q; @@ -104,15 +105,17 @@ configdCallback(CFMachPortRef port, void *msg, CFIndex size, void *info) mach_msg_return_t mr; int options; + activity_id = os_activity_start("processing SCDynamicStore request", + OS_ACTIVITY_FLAG_DEFAULT); + if (bufSize == 0) { // get max size for MiG reply buffers bufSize = _config_subsystem.maxsize; // check if our on-the-stack reply buffer will be big enough if (bufSize > sizeof(bufReply_q)) { - SCLog(TRUE, LOG_NOTICE, - CFSTR("configdCallback(): buffer size should be increased > %d"), - _config_subsystem.maxsize); + SC_log(LOG_NOTICE, "buffer size should be increased > %d", + _config_subsystem.maxsize); } } @@ -181,6 +184,9 @@ configdCallback(CFMachPortRef port, void *msg, CFIndex size, void *info) if (bufReply != (mig_reply_error_t *)bufReply_q) CFAllocatorDeallocate(NULL, bufReply); + + os_activity_end(activity_id); + return; } @@ -197,6 +203,7 @@ void server_init() { serverSessionRef mySession; + int ret; CFRunLoopSourceRef rls; char *service_name; mach_port_t service_port = MACH_PORT_NULL; @@ -215,17 +222,16 @@ server_init() break; case BOOTSTRAP_NOT_PRIVILEGED : /* if another instance of the server is starting */ - SCLog(TRUE, LOG_ERR, CFSTR("'%s' server already starting"), service_name); + SC_log(LOG_ERR, "'%s' server already starting", service_name); exit (EX_UNAVAILABLE); case BOOTSTRAP_SERVICE_ACTIVE : /* if another instance of the server is active */ - SCLog(TRUE, LOG_ERR, CFSTR("'%s' server already active"), service_name); + SC_log(LOG_ERR, "'%s' server already active", service_name); exit (EX_UNAVAILABLE); default : - SCLog(TRUE, LOG_ERR, - CFSTR("server_init bootstrap_check_in(..., '%s', ...) failed: %s"), - service_name, - bootstrap_strerror(status)); + SC_log(LOG_ERR, "server_init bootstrap_check_in(..., '%s', ...) failed: %s", + service_name, + bootstrap_strerror(status)); exit (EX_UNAVAILABLE); } @@ -241,6 +247,12 @@ server_init() CFRunLoopAddSource(CFRunLoopGetCurrent(), rls, kCFRunLoopDefaultMode); CFRelease(rls); + // bump thread QoS priority + ret = pthread_set_qos_class_self_np(QOS_CLASS_USER_INITIATED, 0); + if (ret != 0) { + SC_log(LOG_ERR, "pthread_set_qos_class_self_np() failed: %s", strerror(errno)); + } + return; } diff --git a/configd.tproj/entitlements-ios.plist b/configd.tproj/entitlements-ios.plist index a1438de..f04bc3a 100644 --- a/configd.tproj/entitlements-ios.plist +++ b/configd.tproj/entitlements-ios.plist @@ -8,8 +8,11 @@ com.apple.certificates com.apple.identities - com.apple.coretelephony.Identity.get - + com.apple.CommCenter.fine-grained + + spi + identity + com.apple.multitasking.unlimitedassertions com.apple.private.SCNetworkConnection-proxy-user @@ -23,6 +26,10 @@ com.apple.private.snhelper + com.apple.security.network.client + + com.apple.security.network.server + com.apple.springboard.launchapplications com.apple.wifi.manager-access diff --git a/configd.tproj/notify_server.c b/configd.tproj/notify_server.c index 7599238..ea03d32 100644 --- a/configd.tproj/notify_server.c +++ b/configd.tproj/notify_server.c @@ -1,15 +1,15 @@ /* - * Copyright (c) 2000-2004, 2007 Apple Inc. All rights reserved. + * Copyright (c) 2000-2004, 2007, 2015 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ - * + * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. - * + * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, @@ -17,7 +17,7 @@ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. - * + * * @APPLE_LICENSE_HEADER_END@ */ @@ -64,7 +64,7 @@ notify_server(mach_msg_header_t *request, mach_msg_header_t *reply) break; } - SCLog(_configd_verbose, LOG_DEBUG, CFSTR("HELP!, Received notification: port=%d, msgh_id=%d"), + SC_log(LOG_NOTICE, "HELP!, Received notification: port=%d, msgh_id=%d", Request->not_header.msgh_local_port, Request->not_header.msgh_id); diff --git a/configd.tproj/pattern.c b/configd.tproj/pattern.c index 87bcbb1..9090757 100644 --- a/configd.tproj/pattern.c +++ b/configd.tproj/pattern.c @@ -1,15 +1,15 @@ /* - * Copyright (c) 2003, 2004, 2006-2008, 2011, 2012 Apple Inc. All rights reserved. + * Copyright (c) 2003, 2004, 2006-2008, 2011, 2012, 2015 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ - * + * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. - * + * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, @@ -17,7 +17,7 @@ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. - * + * * @APPLE_LICENSE_HEADER_END@ */ @@ -82,7 +82,7 @@ keyMatchesPattern(CFStringRef key, CFDataRef pRegex) if (len > (CFIndex)sizeof(str_q)) str = CFAllocatorAllocate(NULL, len, 0); if (_SC_cfstring_to_cstring(key, str, len, kCFStringEncodingASCII) == NULL) { - SCLog(TRUE, LOG_DEBUG, CFSTR("keyMatchesPattern(): could not convert store key to C string")); + SC_log(LOG_INFO, "could not convert store key to C string"); goto done; } @@ -102,7 +102,7 @@ keyMatchesPattern(CFStringRef key, CFDataRef pRegex) char reErrBuf[256]; (void)regerror(reError, preg, reErrBuf, sizeof(reErrBuf)); - SCLog(TRUE, LOG_DEBUG, CFSTR("keyMatchesPattern regexec(): %s"), reErrBuf); + SC_log(LOG_INFO, "regexec() failed: %s", reErrBuf); break; } } @@ -148,7 +148,7 @@ patternCompile(CFStringRef pattern, CFDataRef pRegex, CFStringRef *error) char * str = str_q; if (CFStringGetLength(pattern) == 0) { - SCLog(TRUE, LOG_ERR, CFSTR("patternCompile(): empty string")); + SC_log(LOG_NOTICE, "empty regex pattern"); } if (!CFStringHasPrefix(pattern, CFSTR("^"))) { @@ -179,7 +179,7 @@ patternCompile(CFStringRef pattern, CFDataRef pRegex, CFStringRef *error) 0, &len); if (len_c <= 0) { - SCLog(TRUE, LOG_ERR, CFSTR("patternCompile(): could not get buffer length for \"%@\""), pattern); + SC_log(LOG_NOTICE, "could not get buffer length for \"%@\"", pattern); len = sizeof(str_q) - 1; } if (++len > (CFIndex)sizeof(str_q)) { @@ -203,14 +203,14 @@ patternCompile(CFStringRef pattern, CFDataRef pRegex, CFStringRef *error) (void)regerror(reError, preg, reErrBuf, sizeof(reErrBuf)); *error = CFStringCreateWithCString(NULL, reErrBuf, kCFStringEncodingASCII); #ifdef DEBUG - SCLog(_configd_verbose, LOG_DEBUG, CFSTR("patternCompile regcomp(%s) failed: %s"), str, reErrBuf); + SC_log(LOG_DEBUG, "regcomp(%s) failed: %s", str, reErrBuf); #endif /* DEBUG */ ok = FALSE; } } else { *error = CFRetain(CFSTR("could not convert pattern to regex string")); #ifdef DEBUG - SCLog(_configd_verbose, LOG_DEBUG, CFSTR("%@"), *error); + SC_log(LOG_DEBUG, "%@", *error); #endif /* DEBUG */ } @@ -475,7 +475,7 @@ addKeyForPattern(const void *key, void *val, void *context) if (len > (CFIndex)sizeof(str_q)) str = CFAllocatorAllocate(NULL, len, 0); if (_SC_cfstring_to_cstring(storeKey, str, len, kCFStringEncodingASCII) == NULL) { - SCLog(TRUE, LOG_DEBUG, CFSTR("addKeyForPattern(): could not convert store key to C string")); + SC_log(LOG_INFO, "could not convert store key to C string"); goto done; } @@ -516,7 +516,7 @@ addKeyForPattern(const void *key, void *val, void *context) char reErrBuf[256]; (void)regerror(reError, preg, reErrBuf, sizeof(reErrBuf)); - SCLog(TRUE, LOG_DEBUG, CFSTR("addKeyForPattern regexec(): %s"), reErrBuf); + SC_log(LOG_INFO, "%s", reErrBuf); break; } } diff --git a/configd.tproj/plugin_support.c b/configd.tproj/plugin_support.c index 9a130b9..75b3c52 100644 --- a/configd.tproj/plugin_support.c +++ b/configd.tproj/plugin_support.c @@ -1,15 +1,15 @@ /* - * Copyright (c) 2000-2014 Apple Inc. All rights reserved. + * Copyright (c) 2000-2015 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ - * + * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. - * + * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, @@ -17,7 +17,7 @@ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. - * + * * @APPLE_LICENSE_HEADER_END@ */ @@ -123,7 +123,6 @@ extern SCDynamicStoreBundleLoadFunction load_LinkConfiguration; extern SCDynamicStoreBundleLoadFunction load_PreferencesMonitor; extern SCDynamicStoreBundlePrimeFunction prime_PreferencesMonitor; #endif // !TARGET_IPHONE_SIMULATOR -extern SCDynamicStoreBundleLoadFunction load_SCNetworkReachability; typedef struct { @@ -173,13 +172,6 @@ static const builtin builtin_plugins[] = { NULL }, #endif // !TARGET_IPHONE_SIMULATOR - { - CFSTR("com.apple.SystemConfiguration.SCNetworkReachability"), - &load_SCNetworkReachability, - NULL, - NULL, - NULL - }, }; @@ -187,19 +179,53 @@ static const builtin builtin_plugins[] = { static void traceBundle(const char *op, CFBundleRef bundle) { - if (_configd_trace != NULL) { + if (bundle != NULL) { + CFStringRef bundleID = CFBundleGetIdentifier(bundle); + + SC_trace(_configd_trace, "bundle : %s %@\n", + op, + bundleID); + } else { + SC_trace(_configd_trace, "bundle : %s\n", + op); + } + + const char *path = getenv("LOG_CONFIGD_BUNDLE_USAGE"); + if (path != NULL) { + FILE *file; + int status; + char *top_command; + + file = fopen(path, "a"); + if (file == NULL) { + return; + } + + // let everything settle down before grabbing a snapshot + (void)sleep(2); + + SCPrint(TRUE, file, CFSTR("\n--------------------\n\n"), op); if (bundle != NULL) { CFStringRef bundleID = CFBundleGetIdentifier(bundle); - SCTrace(TRUE, _configd_trace, - CFSTR("bundle : %s %@\n"), - op, - bundleID); + SC_trace(file, "%s bundle \"%@\"\n\n", op, bundleID); } else { - SCTrace(TRUE, _configd_trace, - CFSTR("bundle : %s\n"), - op); + SC_trace(file, "%s\n\n", op); } + SCPrint(TRUE, file, CFSTR("%@\n\n"), CFRunLoopGetCurrent()); + fclose(file); + + if (asprintf(&top_command, "/usr/bin/top -o+pid -l 1 >> %s", path) == -1) { + return; + } + + status = system(top_command); + if ((status == -1) || + !WIFEXITED(status) || + (WEXITSTATUS(status) != 0)) { + SC_log(LOG_NOTICE, "system(\"%s\") failed", top_command); + } + free(top_command); } return; @@ -358,7 +384,7 @@ loadBundle(const void *value, void *context) { bundleID = CFBundleGetIdentifier(bundleInfo->bundle); if (bundleID == NULL) { // sorry, no bundles without a bundle identifier - SCLog(TRUE, LOG_NOTICE, CFSTR("skipped %@ (no bundle ID)"), bundleInfo->bundle); + SC_log(LOG_NOTICE, "skipped %@ (no bundle ID)", bundleInfo->bundle); return; } @@ -371,7 +397,7 @@ loadBundle(const void *value, void *context) { bundleInfo->forced // if "testing" plugin ); if (!bundleAllowed) { - SCLog(TRUE, LOG_WARNING, CFSTR("skipped %@ (not allowed)"), bundleID); + SC_log(LOG_INFO, "skipped %@ (not allowed)", bundleID); goto done; } @@ -381,13 +407,13 @@ loadBundle(const void *value, void *context) { ); if (bundleExclude) { // sorry, this bundle has been excluded - SCLog(TRUE, LOG_NOTICE, CFSTR("skipped %@ (excluded)"), bundleID); + SC_log(LOG_INFO, "skipped %@ (excluded)", bundleID); goto done; } if (!bundleInfo->enabled && !bundleInfo->forced) { // sorry, this bundle has not been enabled - SCLog(TRUE, LOG_INFO, CFSTR("skipped %@ (disabled)"), bundleID); + SC_log(LOG_INFO, "skipped %@ (disabled)", bundleID); goto done; } @@ -403,7 +429,7 @@ loadBundle(const void *value, void *context) { if (bundleInfo->builtin) { int i; - SCLog(TRUE, LOG_DEBUG, CFSTR("adding %@"), bundleID); + SC_log(LOG_INFO, "adding %@", bundleID); for (i = 0; i < sizeof(builtin_plugins)/sizeof(builtin_plugins[0]); i++) { if (CFEqual(bundleID, builtin_plugins[i].bundleID)) { @@ -419,13 +445,13 @@ loadBundle(const void *value, void *context) { (bundleInfo->start == NULL) && (bundleInfo->prime == NULL) && (bundleInfo->stop == NULL)) { - SCLog(TRUE, LOG_NOTICE, CFSTR("%@ add failed"), bundleID); + SC_log(LOG_NOTICE, "%@ add failed", bundleID); goto done; } } else { CFErrorRef error = NULL; - SCLog(TRUE, LOG_DEBUG, CFSTR("loading %@"), bundleID); + SC_log(LOG_INFO, "loading %@", bundleID); #ifdef DEBUG traceBundle("loading", bundleInfo->bundle); @@ -433,8 +459,8 @@ loadBundle(const void *value, void *context) { if (!CFBundleLoadExecutableAndReturnError(bundleInfo->bundle, &error)) { CFDictionaryRef user_info; - - SCLog(TRUE, LOG_NOTICE, CFSTR("%@ load failed"), bundleID); + + SC_log(LOG_NOTICE, "%@ load failed", bundleID); user_info = CFErrorCopyUserInfo(error); if (user_info != NULL) { CFStringRef link_error_string; @@ -442,7 +468,7 @@ loadBundle(const void *value, void *context) { link_error_string = CFDictionaryGetValue(user_info, CFSTR("NSDebugDescription")); if (link_error_string != NULL) { - SCLog(TRUE, LOG_NOTICE, CFSTR("%@"), link_error_string); + SC_log(LOG_NOTICE, "%@", link_error_string); } CFRelease(user_info); } @@ -577,7 +603,7 @@ stopComplete(void *info) CFStringRef bundleID = CFBundleGetIdentifier(bundle); CFRunLoopSourceRef stopRls; - SCLog(TRUE, LOG_DEBUG, CFSTR("** %@ complete (%f)"), bundleID, CFAbsoluteTimeGetCurrent()); + SC_log(LOG_INFO, "** %@ complete (%f)", bundleID, CFAbsoluteTimeGetCurrent()); stopRls = (CFRunLoopSourceRef)CFDictionaryGetValue(exiting, bundle); if (stopRls == NULL) { @@ -593,7 +619,7 @@ stopComplete(void *info) // if all of the plugins are happy status = server_shutdown(); - SCLog(TRUE, LOG_DEBUG, CFSTR("server shutdown complete (%f)"), CFAbsoluteTimeGetCurrent()); + SC_log(LOG_INFO, "server shutdown complete (%f)", CFAbsoluteTimeGetCurrent()); exit (status); } @@ -609,7 +635,7 @@ stopDelayed(CFRunLoopTimerRef timer, void *info) CFIndex n; int status; - SCLog(TRUE, LOG_ERR, CFSTR("server shutdown was delayed, unresponsive plugins:")); + SC_log(LOG_INFO, "server shutdown was delayed, unresponsive plugins:"); /* * we've asked our plugins to shutdown but someone @@ -624,7 +650,7 @@ stopDelayed(CFRunLoopTimerRef timer, void *info) bundle = (CFBundleRef)keys[i]; bundleID = CFBundleGetIdentifier(bundle); - SCLog(TRUE, LOG_ERR, CFSTR("** %@"), bundleID); + SC_log(LOG_NOTICE, "** %@", bundleID); } CFAllocatorDeallocate(NULL, keys); @@ -690,7 +716,7 @@ stopBundles() * function should signal the provided run loop source when it is "ready" * for the shut down to proceeed. */ - SCLog(_configd_verbose, LOG_DEBUG, CFSTR("calling bundle stop() functions")); + SC_log(LOG_DEBUG, "calling bundle stop() functions"); CFArrayApplyFunction(allBundles, CFRangeMake(0, CFArrayGetCount(allBundles)), stopBundle, @@ -701,7 +727,7 @@ stopBundles() // if all of the plugins are happy status = server_shutdown(); - SCLog(TRUE, LOG_DEBUG, CFSTR("server shutdown complete (%f)"), CFAbsoluteTimeGetCurrent()); + SC_log(LOG_INFO, "server shutdown complete (%f)", CFAbsoluteTimeGetCurrent()); exit (status); } else { CFRunLoopTimerRef timer; @@ -766,7 +792,7 @@ plugin_term(int *status) return TRUE; } - SCLog(TRUE, LOG_DEBUG, CFSTR("starting server shutdown (%f)"), CFAbsoluteTimeGetCurrent()); + SC_log(LOG_INFO, "starting server shutdown (%f)", CFAbsoluteTimeGetCurrent()); exiting = CFDictionaryCreateMutable(NULL, 0, @@ -880,7 +906,7 @@ sortBundles(CFMutableArrayRef orig) } if (inserted == FALSE) { - SCLog(TRUE, LOG_NOTICE, CFSTR("Bundles have circular dependency!!!")); + SC_log(LOG_NOTICE, "Bundles have circular dependency!!!"); break; } @@ -965,7 +991,7 @@ plugin_exec(void *arg) /* load any available bundle */ strlcat(path, BUNDLE_DIRECTORY, sizeof(path)); - SCLog(_configd_verbose, LOG_DEBUG, CFSTR("searching for bundles in \"%s\""), path); + SC_log(LOG_DEBUG, "searching for bundles in \"%s\"", path); url = CFURLCreateFromFileSystemRepresentation(NULL, (UInt8 *)path, strlen(path), @@ -1059,7 +1085,7 @@ plugin_exec(void *arg) /* * load each bundle. */ - SCLog(_configd_verbose, LOG_DEBUG, CFSTR("loading bundles")); + SC_log(LOG_DEBUG, "loading bundles"); CFArrayApplyFunction(allBundles, CFRangeMake(0, CFArrayGetCount(allBundles)), loadBundle, @@ -1076,7 +1102,7 @@ plugin_exec(void *arg) * data has changed will have an opportunity to install a * notification handler. */ - SCLog(_configd_verbose, LOG_DEBUG, CFSTR("calling bundle load() functions")); + SC_log(LOG_DEBUG, "calling bundle load() functions"); CFArrayApplyFunction(allBundles, CFRangeMake(0, CFArrayGetCount(allBundles)), callLoadFunction, @@ -1099,7 +1125,7 @@ plugin_exec(void *arg) * data has changed will have an opportunity to install a * notification handler. */ - SCLog(_configd_verbose, LOG_DEBUG, CFSTR("calling bundle start() functions")); + SC_log(LOG_DEBUG, "calling bundle start() functions"); CFArrayApplyFunction(allBundles, CFRangeMake(0, CFArrayGetCount(allBundles)), callStartFunction, @@ -1111,7 +1137,7 @@ plugin_exec(void *arg) * functions have been called. It should initialize any configuration * information and/or state in the store. */ - SCLog(_configd_verbose, LOG_DEBUG, CFSTR("calling bundle prime() functions")); + SC_log(LOG_DEBUG, "calling bundle prime() functions"); CFArrayApplyFunction(allBundles, CFRangeMake(0, CFArrayGetCount(allBundles)), callPrimeFunction, @@ -1145,14 +1171,14 @@ plugin_exec(void *arg) * needs to wait and/or block at any time it should do so only in its a * private thread. */ - SCLog(_configd_verbose, LOG_DEBUG, CFSTR("starting plugin CFRunLoop")); + SC_log(LOG_DEBUG, "starting plugin CFRunLoop"); plugin_runLoop = CFRunLoopGetCurrent(); pthread_setname_np("Main plugin thread"); CFRunLoopRun(); done : - SCLog(_configd_verbose, LOG_INFO, CFSTR("No more work for the \"configd\" plugins")); + SC_log(LOG_INFO, "No more work for the \"configd\" plugin thread"); plugin_runLoop = NULL; return NULL; } @@ -1165,14 +1191,14 @@ plugin_init() pthread_attr_t tattr; pthread_t tid; - SCLog(_configd_verbose, LOG_DEBUG, CFSTR("Starting thread for plug-ins...")); + SC_log(LOG_DEBUG, "Starting \"configd\" plugin thread"); pthread_attr_init(&tattr); pthread_attr_setscope(&tattr, PTHREAD_SCOPE_SYSTEM); pthread_attr_setdetachstate(&tattr, PTHREAD_CREATE_DETACHED); // pthread_attr_setstacksize(&tattr, 96 * 1024); // each thread gets a 96K stack pthread_create(&tid, &tattr, plugin_exec, NULL); pthread_attr_destroy(&tattr); - SCLog(_configd_verbose, LOG_DEBUG, CFSTR(" thread id=%p"), tid); + SC_log(LOG_DEBUG, " thread id=%p", tid); return; } diff --git a/configd.tproj/session.c b/configd.tproj/session.c index 60b824e..bd29b7b 100644 --- a/configd.tproj/session.c +++ b/configd.tproj/session.c @@ -1,15 +1,15 @@ /* - * Copyright (c) 2000, 2001, 2003-2005, 2007-2014 Apple Inc. All rights reserved. + * Copyright (c) 2000, 2001, 2003-2005, 2007-2015 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ - * + * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. - * + * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, @@ -17,7 +17,7 @@ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. - * + * * @APPLE_LICENSE_HEADER_END@ */ @@ -65,7 +65,7 @@ getSession(mach_port_t server) int i; if (server == MACH_PORT_NULL) { - SCLog(TRUE, LOG_ERR, CFSTR("Excuse me, why is getSession() being called with an invalid port?")); + SC_log(LOG_NOTICE, "Excuse me, why is getSession() being called with an invalid port?"); return NULL; } @@ -220,14 +220,14 @@ addSession(mach_port_t server, CFStringRef (*copyDescription)(const void *info)) if (kr != KERN_SUCCESS) { char *err = NULL; - SCLog(TRUE, LOG_ERR, CFSTR("addSession: could not allocate mach port: %s"), mach_error_string(kr)); + SC_log(LOG_NOTICE, "could not allocate mach port: %s", mach_error_string(kr)); if ((kr == KERN_NO_SPACE) || (kr == KERN_RESOURCE_SHORTAGE)) { sleep(1); goto retry_allocate; } - (void) asprintf(&err, "addSession: could not allocate mach port: %s", mach_error_string(kr)); - _SC_crash(err != NULL ? err : "addSession: could not allocate mach port", + (void) asprintf(&err, "Could not allocate mach port: %s", mach_error_string(kr)); + _SC_crash(err != NULL ? err : "Could not allocate new session (mach) port", NULL, NULL); if (err != NULL) free(err); @@ -263,7 +263,7 @@ addSession(mach_port_t server, CFStringRef (*copyDescription)(const void *info)) * only happen if someone stomped on OUR port (so let's leave * the port alone). */ - SCLog(TRUE, LOG_ERR, CFSTR("addSession mach_port_insert_right(): %s"), mach_error_string(kr)); + SC_log(LOG_NOTICE, "mach_port_insert_right() failed: %s", mach_error_string(kr)); free(newSession); return NULL; @@ -302,9 +302,7 @@ cleanupSession(mach_port_t server) * session entry still exists. */ - if (_configd_trace) { - SCTrace(TRUE, _configd_trace, CFSTR("cleanup : %5d\n"), server); - } + SC_trace(_configd_trace, "cleanup : %5d\n", server); /* * Close any open connections including cancelling any outstanding @@ -358,7 +356,7 @@ cleanupSession(mach_port_t server) } } - SCLog(TRUE, LOG_ERR, CFSTR("MACH_NOTIFY_NO_SENDERS w/no session, port = %d"), server); + SC_log(LOG_NOTICE, "MACH_NOTIFY_NO_SENDERS w/no session, port = %d", server); __MACH_PORT_DEBUG(TRUE, "*** cleanupSession w/no session", server); return; } @@ -462,20 +460,18 @@ copyEntitlement(serverSessionRef session, CFStringRef entitlement) if (!CFEqual(domain, kCFErrorDomainMach) || ((code != kIOReturnInvalid) && (code != kIOReturnNotFound))) { // if unexpected error - SCLog(TRUE, LOG_ERR, - CFSTR("SecTaskCopyValueForEntitlement(,\"%@\",) failed, error = %@ : %@"), - entitlement, - error, - sessionName(session)); + SC_log(LOG_NOTICE, "SecTaskCopyValueForEntitlement(,\"%@\",) failed, error = %@ : %@", + entitlement, + error, + sessionName(session)); } CFRelease(error); } CFRelease(task); } else { - SCLog(TRUE, LOG_ERR, - CFSTR("SecTaskCreateWithAuditToken() failed: %@"), - sessionName(session)); + SC_log(LOG_NOTICE, "SecTaskCreateWithAuditToken() failed: %@", + sessionName(session)); } return value; @@ -566,10 +562,9 @@ hasWriteAccess(serverSessionRef session, CFStringRef key) * general, this is unwise and we should at the * very least complain. */ - SCLog(TRUE, LOG_ERR, - CFSTR("*** Non-configd process (pid=%d) attempting to modify \"%@\" ***"), - pid, - key); + SC_log(LOG_NOTICE, "*** Non-configd process (pid=%d) attempting to modify \"%@\" ***", + pid, + key); } return TRUE; @@ -584,10 +579,9 @@ hasWriteAccess(serverSessionRef session, CFStringRef key) * something we should ever allow (regardless of * any entitlements). */ - SCLog(TRUE, LOG_ERR, - CFSTR("*** Non-root process (pid=%d) attempting to modify \"%@\" ***"), - sessionPid(session), - key); + SC_log(LOG_NOTICE, "*** Non-root process (pid=%d) attempting to modify \"%@\" ***", + sessionPid(session), + key); //return FALSE; // return FALSE when rdar://9811832 has beed fixed } @@ -654,7 +648,7 @@ hasPathAccess(serverSessionRef session, const char *path) char realPath[PATH_MAX]; if (realpath(path, realPath) == NULL) { - SCLog(TRUE, LOG_DEBUG, CFSTR("hasPathAccess realpath() failed: %s"), strerror(errno)); + SC_log(LOG_INFO, "realpath() failed: %s", strerror(errno)); return FALSE; } @@ -675,7 +669,7 @@ hasPathAccess(serverSessionRef session, const char *path) "file-write-data", // operation SANDBOX_FILTER_PATH | SANDBOX_CHECK_NO_REPORT, // sandbox_filter_type realPath) > 0) { // ... - SCLog(TRUE, LOG_DEBUG, CFSTR("hasPathAccess sandbox access denied: %s"), strerror(errno)); + SC_log(LOG_INFO, "sandbox access denied: %s", strerror(errno)); return FALSE; } diff --git a/configd.tproj/update-mach-services b/configd.tproj/update-mach-services index 5846173..94f15e4 100755 --- a/configd.tproj/update-mach-services +++ b/configd.tproj/update-mach-services @@ -1,6 +1,6 @@ #!/bin/sh -CONFIGD_LAUNCHD_PLIST=${INSTALL_DIR}/../../System/Library/LaunchDaemons/${1} +CONFIGD_LAUNCHD_PLIST=${INSTALL_ROOT}/System/Library/LaunchDaemons/${1} CONFIGD_PLUGINS=/tmp/plugins.$$ EMBEDDED_PROJECTS=/tmp/projects.$$ PLUGIN_MACHSERVICES=/tmp/plugin.$$ @@ -9,8 +9,8 @@ HAVE_CONFIGD_PLUGINS="MISSING" HAVE_IPCONFIGURATION="MISSING" cp /dev/null ${CONFIGD_PLUGINS} -if [ -d ${INSTALL_DIR}/../../System/Library/SystemConfiguration ]; then - (cd ${INSTALL_DIR}/../../System/Library/SystemConfiguration ; ls -1d *.bundle >> ${CONFIGD_PLUGINS} 2>/dev/null ) +if [ -d ${INSTALL_ROOT}/System/Library/SystemConfiguration ]; then + (cd ${INSTALL_ROOT}/System/Library/SystemConfiguration ; ls -1d *.bundle >> ${CONFIGD_PLUGINS} 2>/dev/null ) fi cp /dev/null ${EMBEDDED_PROJECTS} @@ -41,14 +41,14 @@ do PLUGIN_PLIST="" # if [ -z "${PLUGIN_PLIST}" ]; then - PLUGIN_INF=${INSTALL_DIR}/../../System/Library/SystemConfiguration/${PLUGIN}/Contents/Info.plist + PLUGIN_INF=${INSTALL_ROOT}/System/Library/SystemConfiguration/${PLUGIN}/Contents/Info.plist if [ -f ${PLUGIN_INF} ]; then PLUGIN_PLIST=${PLUGIN_INF} fi # fi if [ -z "${PLUGIN_PLIST}" ]; then - PLUGIN_INF=${INSTALL_DIR}/../../System/Library/SystemConfiguration/${PLUGIN}/Info.plist + PLUGIN_INF=${INSTALL_ROOT}/System/Library/SystemConfiguration/${PLUGIN}/Info.plist if [ -f ${PLUGIN_INF} ]; then PLUGIN_PLIST=${PLUGIN_INF} fi @@ -109,10 +109,10 @@ do if [ $? -eq 0 ]; then echo "Merging \"MachServices\" from: ${PLUGIN_INF}" /usr/libexec/PlistBuddy -c "Merge ${PLUGIN_MACHSERVICES} :MachServices" ${CONFIGD_LAUNCHD_PLIST} 2>/dev/null - if [ -n "${IPHONEOS_DEPLOYMENT_TARGET}" ]; then - /usr/bin/plutil -convert binary1 ${CONFIGD_LAUNCHD_PLIST} - else + if [ -n "${MACOSX_DEPLOYMENT_TARGET}" ]; then /usr/bin/plutil -convert xml1 ${CONFIGD_LAUNCHD_PLIST} + else + /usr/bin/plutil -convert binary1 ${CONFIGD_LAUNCHD_PLIST} fi fi @@ -128,16 +128,31 @@ done rm -f ${PLUGIN_MACHSERVICES} ${CONFIGD_PLUGINS} ${EMBEDDED_PROJECTS} +MISSING="" if [ "${HAVE_CONFIGD_PLUGINS}" != "OK" ]; then + MISSING="configd_plugins" +elif [ "${HAVE_IPCONFIGURATION}" != "OK" ]; then + case "${PLATFORM_NAME}" in + *simulator ) + ;; + * ) + MISSING="bootp" + ;; + esac +fi + +if [ -n "${MISSING}" ]; then echo "" echo "**************************************************************************************" - echo "* THE BUILD ENVIRONMENT IS MISSING THE ROOT FOR AN ESSENTIAL PROJECT (configd_plugins)" + echo "* THE BUILD ENVIRONMENT IS MISSING THE ROOT FOR AN ESSENTIAL PROJECT (${MISSING})" echo "**************************************************************************************" - exit 1 -elif [ "${HAVE_IPCONFIGURATION}" != "OK" -a "${PLATFORM_NAME}" != "iphonesimulator" ] ; then - echo "" - echo "****************************************************************************" - echo "* THE BUILD ENVIRONMENT IS MISSING THE ROOT FOR AN ESSENTIAL PROJECT (bootp)" - echo "****************************************************************************" - exit 1 + if [ -z "${RC_RELEASE}" ]; then + echo "* REMOVING CONFIGD's LAUNCHD .plist FROM INSTALL ROOT" + echo "**************************************************************************************" + rm -f ${CONFIGD_LAUNCHD_PLIST} + else + # if B&I or "buildit", configd's launchd .plist is required (and must be viable) + exit 1 + fi fi + diff --git a/configd.xcodeproj/project.pbxproj b/configd.xcodeproj/project.pbxproj index 41c044f..9d2744d 100644 --- a/configd.xcodeproj/project.pbxproj +++ b/configd.xcodeproj/project.pbxproj @@ -30,8 +30,6 @@ 15A5A2710D5B942D0087BDA0 /* PBXTargetDependency */, 15E1B06416EBAF2A00E5F06F /* PBXTargetDependency */, 15E1B06616EBAF2A00E5F06F /* PBXTargetDependency */, - 15AB752216EC005A00FAA8CE /* PBXTargetDependency */, - 15AB752416EC005A00FAA8CE /* PBXTargetDependency */, 15D3083016F3EAD000014F82 /* PBXTargetDependency */, 15D3083216F3EAD000014F82 /* PBXTargetDependency */, 15E1B03E16EBAB8A00E5F06F /* PBXTargetDependency */, @@ -103,11 +101,8 @@ 158317B70CFB8660006F62B9 /* PBXTargetDependency */, 157A854E0D56CA6F00B6F1A0 /* PBXTargetDependency */, 158317B50CFB8660006F62B9 /* PBXTargetDependency */, - 156CA4A80EF8550800C59A18 /* PBXTargetDependency */, 157A85520D56CA9E00B6F1A0 /* PBXTargetDependency */, 157A85540D56CACA00B6F1A0 /* PBXTargetDependency */, - 1528C00F135741C300691881 /* PBXTargetDependency */, - 1528C011135741C300691881 /* PBXTargetDependency */, ); name = "configd_plugins-Embedded"; productName = Plugins; @@ -139,11 +134,8 @@ 158AD9860754E72500124717 /* PBXTargetDependency */, 159D542A07528E85004F8947 /* PBXTargetDependency */, 158AD98C0754E72500124717 /* PBXTargetDependency */, - 1521405B0E9400BF00DACD2C /* PBXTargetDependency */, 159D542C07528E85004F8947 /* PBXTargetDependency */, 158AD98E0754E72500124717 /* PBXTargetDependency */, - 1528BFEC135731B800691881 /* PBXTargetDependency */, - 1528BFEE135731B800691881 /* PBXTargetDependency */, ); name = configd_plugins; productName = Plugins; @@ -219,9 +211,6 @@ 150D7E1E0D16DC6C00AF4BED /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1520A3DE0846B2DC0010B584 /* Security.framework */; }; 1520A3870846829A0010B584 /* CoreFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 15CB6A6F05C0722B0099E85F /* CoreFoundation.framework */; }; 1520A3DF0846B2DD0010B584 /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1520A3DE0846B2DC0010B584 /* Security.framework */; }; - 152140020E93EC6500DACD2C /* logger.c in Sources */ = {isa = PBXBuildFile; fileRef = 1531D3DB0E93E6DA00248432 /* logger.c */; }; - 1521400C0E93FFF500DACD2C /* CoreFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 15CB6A6F05C0722B0099E85F /* CoreFoundation.framework */; }; - 152140580E93FFFC00DACD2C /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1559C4440D349A4E0098FD59 /* SystemConfiguration.framework */; }; 1522FCFB0FA7FE4B00B24128 /* dnsinfo_flatfile.c in Sources */ = {isa = PBXBuildFile; fileRef = 1522FCE50FA7FD7000B24128 /* dnsinfo_flatfile.c */; }; 152439E518038E5B00D91708 /* ev_extra.h in Headers */ = {isa = PBXBuildFile; fileRef = 152439E318038E5B00D91708 /* ev_extra.h */; }; 152439E618038E5B00D91708 /* ev_extra.m in Sources */ = {isa = PBXBuildFile; fileRef = 152439E418038E5B00D91708 /* ev_extra.m */; }; @@ -233,10 +222,6 @@ 152691DC1129EEAD006BD2D5 /* BridgeConfiguration.c in Sources */ = {isa = PBXBuildFile; fileRef = 15FD7B3B101E439200C56621 /* BridgeConfiguration.c */; }; 152691DE1129EEC2006BD2D5 /* VLANConfiguration.c in Sources */ = {isa = PBXBuildFile; fileRef = 15CB69B605C0722B0099E85F /* VLANConfiguration.c */; }; 152691DF1129EEC8006BD2D5 /* VLANConfiguration.c in Sources */ = {isa = PBXBuildFile; fileRef = 15CB69B605C0722B0099E85F /* VLANConfiguration.c */; }; - 1528BFEF135733F500691881 /* SCNetworkReachabilityServer_server.c in Sources */ = {isa = PBXBuildFile; fileRef = 15C330BB134B92780028E36B /* SCNetworkReachabilityServer_server.c */; }; - 1528BFF313573FEE00691881 /* SCNetworkReachabilityServer_server.c in Sources */ = {isa = PBXBuildFile; fileRef = 15C330BB134B92780028E36B /* SCNetworkReachabilityServer_server.c */; }; - 1528C0171357465900691881 /* libSCNetworkReachability.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 1528BFF713573FEE00691881 /* libSCNetworkReachability.a */; }; - 1528C019135746BB00691881 /* libSCNetworkReachability.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 1528BFE21357305400691881 /* libSCNetworkReachability.a */; }; 152E0E7F10FE820E00E402F2 /* helper.defs in Sources */ = {isa = PBXBuildFile; fileRef = 152E0E7E10FE820E00E402F2 /* helper.defs */; settings = {ATTRIBUTES = (Server, ); }; }; 152E0E8010FE820E00E402F2 /* helper.defs in Sources */ = {isa = PBXBuildFile; fileRef = 152E0E7E10FE820E00E402F2 /* helper.defs */; settings = {ATTRIBUTES = (Server, ); }; }; 152E0E8910FE824000E402F2 /* helper_types.h in Headers */ = {isa = PBXBuildFile; fileRef = 152E0E8810FE824000E402F2 /* helper_types.h */; }; @@ -304,31 +289,27 @@ 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, ); }; }; - 156CA47B0EF853BB00C59A18 /* logger.c in Sources */ = {isa = PBXBuildFile; fileRef = 1531D3DB0E93E6DA00248432 /* logger.c */; }; - 156CA47D0EF853BB00C59A18 /* CoreFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 15CB6A6F05C0722B0099E85F /* CoreFoundation.framework */; }; - 156CA47E0EF853BB00C59A18 /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1559C4440D349A4E0098FD59 /* SystemConfiguration.framework */; }; - 156CA47F0EF853BB00C59A18 /* IOKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1543636A0752D03C00A8EC6C /* IOKit.framework */; }; 1572C4A90CFB55B400E2776E /* SCSchemaDefinitions.h in Headers */ = {isa = PBXBuildFile; fileRef = 150607DE075A00A300B147BA /* SCSchemaDefinitions.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 1572C4AA0CFB55B400E2776E /* SystemConfiguration.h in Headers */ = {isa = PBXBuildFile; fileRef = 15CB691305C0722B0099E85F /* SystemConfiguration.h */; settings = {ATTRIBUTES = (Public, Project, ); }; }; + 1572C4AA0CFB55B400E2776E /* SystemConfiguration.h in Headers */ = {isa = PBXBuildFile; fileRef = 15CB691305C0722B0099E85F /* SystemConfiguration.h */; settings = {ATTRIBUTES = (Project, Public, ); }; }; 1572C4AB0CFB55B400E2776E /* SCPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 15CB691505C0722B0099E85F /* SCPrivate.h */; settings = {ATTRIBUTES = (Private, Project, ); }; }; 1572C4AC0CFB55B400E2776E /* SCDPlugin.h in Headers */ = {isa = PBXBuildFile; fileRef = 15CB691705C0722B0099E85F /* SCDPlugin.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1572C4AD0CFB55B400E2776E /* SCDynamicStoreInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 15CB691B05C0722B0099E85F /* SCDynamicStoreInternal.h */; settings = {ATTRIBUTES = (Project, ); }; }; - 1572C4AE0CFB55B400E2776E /* SCDynamicStore.h in Headers */ = {isa = PBXBuildFile; fileRef = 15CB691D05C0722B0099E85F /* SCDynamicStore.h */; settings = {ATTRIBUTES = (Public, Project, ); }; }; + 1572C4AE0CFB55B400E2776E /* SCDynamicStore.h in Headers */ = {isa = PBXBuildFile; fileRef = 15CB691D05C0722B0099E85F /* SCDynamicStore.h */; settings = {ATTRIBUTES = (Project, Public, ); }; }; 1572C4AF0CFB55B400E2776E /* SCDynamicStorePrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 15CB691F05C0722B0099E85F /* SCDynamicStorePrivate.h */; settings = {ATTRIBUTES = (Private, Project, ); }; }; - 1572C4B00CFB55B400E2776E /* SCDynamicStoreKey.h in Headers */ = {isa = PBXBuildFile; fileRef = 15CB692105C0722B0099E85F /* SCDynamicStoreKey.h */; settings = {ATTRIBUTES = (Public, Project, ); }; }; - 1572C4B10CFB55B400E2776E /* SCDynamicStoreCopySpecific.h in Headers */ = {isa = PBXBuildFile; fileRef = 15CB692305C0722B0099E85F /* SCDynamicStoreCopySpecific.h */; settings = {ATTRIBUTES = (Public, Project, ); }; }; + 1572C4B00CFB55B400E2776E /* SCDynamicStoreKey.h in Headers */ = {isa = PBXBuildFile; fileRef = 15CB692105C0722B0099E85F /* SCDynamicStoreKey.h */; settings = {ATTRIBUTES = (Project, Public, ); }; }; + 1572C4B10CFB55B400E2776E /* SCDynamicStoreCopySpecific.h in Headers */ = {isa = PBXBuildFile; fileRef = 15CB692305C0722B0099E85F /* SCDynamicStoreCopySpecific.h */; settings = {ATTRIBUTES = (Project, Public, ); }; }; 1572C4B20CFB55B400E2776E /* SCDynamicStoreCopySpecificPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 15CB692505C0722B0099E85F /* SCDynamicStoreCopySpecificPrivate.h */; settings = {ATTRIBUTES = (Private, Project, ); }; }; 1572C4B30CFB55B400E2776E /* SCDynamicStoreSetSpecificPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 15CB692705C0722B0099E85F /* SCDynamicStoreSetSpecificPrivate.h */; settings = {ATTRIBUTES = (Private, Project, ); }; }; 1572C4B40CFB55B400E2776E /* SCPreferencesInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 15CB692905C0722B0099E85F /* SCPreferencesInternal.h */; settings = {ATTRIBUTES = (Project, ); }; }; - 1572C4B50CFB55B400E2776E /* SCPreferences.h in Headers */ = {isa = PBXBuildFile; fileRef = 15CB692B05C0722B0099E85F /* SCPreferences.h */; settings = {ATTRIBUTES = (Public, Project, ); }; }; + 1572C4B50CFB55B400E2776E /* SCPreferences.h in Headers */ = {isa = PBXBuildFile; fileRef = 15CB692B05C0722B0099E85F /* SCPreferences.h */; settings = {ATTRIBUTES = (Project, Public, ); }; }; 1572C4B60CFB55B400E2776E /* SCPreferencesPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 15CB692D05C0722B0099E85F /* SCPreferencesPrivate.h */; settings = {ATTRIBUTES = (Private, Project, ); }; }; - 1572C4B70CFB55B400E2776E /* SCPreferencesPath.h in Headers */ = {isa = PBXBuildFile; fileRef = 15CB692F05C0722B0099E85F /* SCPreferencesPath.h */; settings = {ATTRIBUTES = (Public, Project, ); }; }; - 1572C4B80CFB55B400E2776E /* SCPreferencesSetSpecific.h in Headers */ = {isa = PBXBuildFile; fileRef = 15CB693105C0722B0099E85F /* SCPreferencesSetSpecific.h */; settings = {ATTRIBUTES = (Public, Project, ); }; }; + 1572C4B70CFB55B400E2776E /* SCPreferencesPath.h in Headers */ = {isa = PBXBuildFile; fileRef = 15CB692F05C0722B0099E85F /* SCPreferencesPath.h */; settings = {ATTRIBUTES = (Project, Public, ); }; }; + 1572C4B80CFB55B400E2776E /* SCPreferencesSetSpecific.h in Headers */ = {isa = PBXBuildFile; fileRef = 15CB693105C0722B0099E85F /* SCPreferencesSetSpecific.h */; settings = {ATTRIBUTES = (Project, Public, ); }; }; 1572C4B90CFB55B400E2776E /* SCNetworkConfiguration.h in Headers */ = {isa = PBXBuildFile; fileRef = 15AD7A380670A85900BFE03C /* SCNetworkConfiguration.h */; settings = {ATTRIBUTES = (Public, ); }; }; 1572C4BA0CFB55B400E2776E /* SCNetworkConfigurationInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 15AD7A3A0670A85900BFE03C /* SCNetworkConfigurationInternal.h */; settings = {ATTRIBUTES = (); }; }; - 1572C4BB0CFB55B400E2776E /* SCNetwork.h in Headers */ = {isa = PBXBuildFile; fileRef = 15CB693305C0722B0099E85F /* SCNetwork.h */; settings = {ATTRIBUTES = (Public, Project, ); }; }; - 1572C4BC0CFB55B400E2776E /* SCNetworkConnection.h in Headers */ = {isa = PBXBuildFile; fileRef = 15CB693505C0722B0099E85F /* SCNetworkConnection.h */; settings = {ATTRIBUTES = (Public, Project, ); }; }; - 1572C4BD0CFB55B400E2776E /* SCNetworkReachability.h in Headers */ = {isa = PBXBuildFile; fileRef = 15CB693705C0722B0099E85F /* SCNetworkReachability.h */; settings = {ATTRIBUTES = (Public, Project, ); }; }; + 1572C4BB0CFB55B400E2776E /* SCNetwork.h in Headers */ = {isa = PBXBuildFile; fileRef = 15CB693305C0722B0099E85F /* SCNetwork.h */; settings = {ATTRIBUTES = (Project, Public, ); }; }; + 1572C4BC0CFB55B400E2776E /* SCNetworkConnection.h in Headers */ = {isa = PBXBuildFile; fileRef = 15CB693505C0722B0099E85F /* SCNetworkConnection.h */; settings = {ATTRIBUTES = (Project, Public, ); }; }; + 1572C4BD0CFB55B400E2776E /* SCNetworkReachability.h in Headers */ = {isa = PBXBuildFile; fileRef = 15CB693705C0722B0099E85F /* SCNetworkReachability.h */; settings = {ATTRIBUTES = (Project, Public, ); }; }; 1572C4BE0CFB55B400E2776E /* SCValidation.h in Headers */ = {isa = PBXBuildFile; fileRef = 15CB693905C0722B0099E85F /* SCValidation.h */; settings = {ATTRIBUTES = (Private, Project, ); }; }; 1572C4BF0CFB55B400E2776E /* DHCPClientPreferences.h in Headers */ = {isa = PBXBuildFile; fileRef = 15CB693D05C0722B0099E85F /* DHCPClientPreferences.h */; settings = {ATTRIBUTES = (Public, ); }; }; 1572C4C00CFB55B400E2776E /* SCDynamicStoreCopyDHCPInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = 15CB693F05C0722B0099E85F /* SCDynamicStoreCopyDHCPInfo.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -447,7 +428,6 @@ 15732A9716EA503200F3AC4C /* _snapshot.c in Sources */ = {isa = PBXBuildFile; fileRef = 15CB6A1605C0722B0099E85F /* _snapshot.c */; settings = {ATTRIBUTES = (); }; }; 15732A9816EA503200F3AC4C /* config.defs in Sources */ = {isa = PBXBuildFile; fileRef = 15CB69BE05C0722B0099E85F /* config.defs */; settings = {ATTRIBUTES = (Server, ); }; }; 15732A9916EA503200F3AC4C /* dnsinfo_server.c in Sources */ = {isa = PBXBuildFile; fileRef = 15B73F0D05FD1B670096477F /* dnsinfo_server.c */; }; - 15732A9A16EA503200F3AC4C /* SCNetworkReachabilityServer_server.c in Sources */ = {isa = PBXBuildFile; fileRef = 15C330BB134B92780028E36B /* SCNetworkReachabilityServer_server.c */; }; 15732A9C16EA503200F3AC4C /* CoreFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 15CB6A6F05C0722B0099E85F /* CoreFoundation.framework */; }; 15732A9D16EA503200F3AC4C /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1547072E0D1F70C80075C28D /* SystemConfiguration.framework */; }; 15732A9E16EA503200F3AC4C /* IOKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1543636A0752D03C00A8EC6C /* IOKit.framework */; }; @@ -600,7 +580,6 @@ 158E595E1107CAE40062081E /* helper.defs in Sources */ = {isa = PBXBuildFile; fileRef = 152E0E7E10FE820E00E402F2 /* helper.defs */; }; 158E595F1107CAE80062081E /* helper.defs in Sources */ = {isa = PBXBuildFile; fileRef = 152E0E7E10FE820E00E402F2 /* helper.defs */; }; 158E59611107CAF40062081E /* helper.defs in Sources */ = {isa = PBXBuildFile; fileRef = 152E0E7E10FE820E00E402F2 /* helper.defs */; }; - 15943D440E94081800B87535 /* IOKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1543636A0752D03C00A8EC6C /* IOKit.framework */; }; 1596A7B114EDB73D00798C39 /* libSystemConfiguration_server.c in Sources */ = {isa = PBXBuildFile; fileRef = 1596A7AF14EDB73D00798C39 /* libSystemConfiguration_server.c */; }; 1596A7B214EDB73D00798C39 /* libSystemConfiguration_server.c in Sources */ = {isa = PBXBuildFile; fileRef = 1596A7AF14EDB73D00798C39 /* libSystemConfiguration_server.c */; }; 1596A7B414EDB73D00798C39 /* libSystemConfiguration_server.h in Headers */ = {isa = PBXBuildFile; fileRef = 1596A7B014EDB73D00798C39 /* libSystemConfiguration_server.h */; }; @@ -680,26 +659,26 @@ 15A2972F0A13C08C009879B3 /* SCNetworkConnectionPrivate.c in Sources */ = {isa = PBXBuildFile; fileRef = 15A2972D0A13C08C009879B3 /* SCNetworkConnectionPrivate.c */; }; 15A297300A13C08C009879B3 /* SCNetworkConnectionPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 15A2972E0A13C08C009879B3 /* SCNetworkConnectionPrivate.h */; settings = {ATTRIBUTES = (Private, ); }; }; 15A5A1E70D5B94190087BDA0 /* SCSchemaDefinitions.h in Headers */ = {isa = PBXBuildFile; fileRef = 150607DE075A00A300B147BA /* SCSchemaDefinitions.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 15A5A1E80D5B94190087BDA0 /* SystemConfiguration.h in Headers */ = {isa = PBXBuildFile; fileRef = 15CB691305C0722B0099E85F /* SystemConfiguration.h */; settings = {ATTRIBUTES = (Public, Project, ); }; }; + 15A5A1E80D5B94190087BDA0 /* SystemConfiguration.h in Headers */ = {isa = PBXBuildFile; fileRef = 15CB691305C0722B0099E85F /* SystemConfiguration.h */; settings = {ATTRIBUTES = (Project, Public, ); }; }; 15A5A1E90D5B94190087BDA0 /* SCPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 15CB691505C0722B0099E85F /* SCPrivate.h */; settings = {ATTRIBUTES = (Private, Project, ); }; }; 15A5A1EA0D5B94190087BDA0 /* SCDPlugin.h in Headers */ = {isa = PBXBuildFile; fileRef = 15CB691705C0722B0099E85F /* SCDPlugin.h */; settings = {ATTRIBUTES = (Private, ); }; }; 15A5A1EB0D5B94190087BDA0 /* SCDynamicStoreInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 15CB691B05C0722B0099E85F /* SCDynamicStoreInternal.h */; settings = {ATTRIBUTES = (Project, ); }; }; - 15A5A1EC0D5B94190087BDA0 /* SCDynamicStore.h in Headers */ = {isa = PBXBuildFile; fileRef = 15CB691D05C0722B0099E85F /* SCDynamicStore.h */; settings = {ATTRIBUTES = (Public, Project, ); }; }; + 15A5A1EC0D5B94190087BDA0 /* SCDynamicStore.h in Headers */ = {isa = PBXBuildFile; fileRef = 15CB691D05C0722B0099E85F /* SCDynamicStore.h */; settings = {ATTRIBUTES = (Project, Public, ); }; }; 15A5A1ED0D5B94190087BDA0 /* SCDynamicStorePrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 15CB691F05C0722B0099E85F /* SCDynamicStorePrivate.h */; settings = {ATTRIBUTES = (Private, Project, ); }; }; - 15A5A1EE0D5B94190087BDA0 /* SCDynamicStoreKey.h in Headers */ = {isa = PBXBuildFile; fileRef = 15CB692105C0722B0099E85F /* SCDynamicStoreKey.h */; settings = {ATTRIBUTES = (Public, Project, ); }; }; - 15A5A1EF0D5B94190087BDA0 /* SCDynamicStoreCopySpecific.h in Headers */ = {isa = PBXBuildFile; fileRef = 15CB692305C0722B0099E85F /* SCDynamicStoreCopySpecific.h */; settings = {ATTRIBUTES = (Public, Project, ); }; }; + 15A5A1EE0D5B94190087BDA0 /* SCDynamicStoreKey.h in Headers */ = {isa = PBXBuildFile; fileRef = 15CB692105C0722B0099E85F /* SCDynamicStoreKey.h */; settings = {ATTRIBUTES = (Project, Public, ); }; }; + 15A5A1EF0D5B94190087BDA0 /* SCDynamicStoreCopySpecific.h in Headers */ = {isa = PBXBuildFile; fileRef = 15CB692305C0722B0099E85F /* SCDynamicStoreCopySpecific.h */; settings = {ATTRIBUTES = (Project, Public, ); }; }; 15A5A1F00D5B94190087BDA0 /* SCDynamicStoreCopySpecificPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 15CB692505C0722B0099E85F /* SCDynamicStoreCopySpecificPrivate.h */; settings = {ATTRIBUTES = (Private, Project, ); }; }; 15A5A1F10D5B94190087BDA0 /* SCDynamicStoreSetSpecificPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 15CB692705C0722B0099E85F /* SCDynamicStoreSetSpecificPrivate.h */; settings = {ATTRIBUTES = (Private, Project, ); }; }; 15A5A1F20D5B94190087BDA0 /* SCPreferencesInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 15CB692905C0722B0099E85F /* SCPreferencesInternal.h */; settings = {ATTRIBUTES = (Project, ); }; }; - 15A5A1F30D5B94190087BDA0 /* SCPreferences.h in Headers */ = {isa = PBXBuildFile; fileRef = 15CB692B05C0722B0099E85F /* SCPreferences.h */; settings = {ATTRIBUTES = (Public, Project, ); }; }; + 15A5A1F30D5B94190087BDA0 /* SCPreferences.h in Headers */ = {isa = PBXBuildFile; fileRef = 15CB692B05C0722B0099E85F /* SCPreferences.h */; settings = {ATTRIBUTES = (Project, Public, ); }; }; 15A5A1F40D5B94190087BDA0 /* SCPreferencesPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 15CB692D05C0722B0099E85F /* SCPreferencesPrivate.h */; settings = {ATTRIBUTES = (Private, Project, ); }; }; - 15A5A1F50D5B94190087BDA0 /* SCPreferencesPath.h in Headers */ = {isa = PBXBuildFile; fileRef = 15CB692F05C0722B0099E85F /* SCPreferencesPath.h */; settings = {ATTRIBUTES = (Public, Project, ); }; }; - 15A5A1F60D5B94190087BDA0 /* SCPreferencesSetSpecific.h in Headers */ = {isa = PBXBuildFile; fileRef = 15CB693105C0722B0099E85F /* SCPreferencesSetSpecific.h */; settings = {ATTRIBUTES = (Public, Project, ); }; }; + 15A5A1F50D5B94190087BDA0 /* SCPreferencesPath.h in Headers */ = {isa = PBXBuildFile; fileRef = 15CB692F05C0722B0099E85F /* SCPreferencesPath.h */; settings = {ATTRIBUTES = (Project, Public, ); }; }; + 15A5A1F60D5B94190087BDA0 /* SCPreferencesSetSpecific.h in Headers */ = {isa = PBXBuildFile; fileRef = 15CB693105C0722B0099E85F /* SCPreferencesSetSpecific.h */; settings = {ATTRIBUTES = (Project, Public, ); }; }; 15A5A1F70D5B94190087BDA0 /* SCNetworkConfiguration.h in Headers */ = {isa = PBXBuildFile; fileRef = 15AD7A380670A85900BFE03C /* SCNetworkConfiguration.h */; settings = {ATTRIBUTES = (Public, ); }; }; 15A5A1F80D5B94190087BDA0 /* SCNetworkConfigurationInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 15AD7A3A0670A85900BFE03C /* SCNetworkConfigurationInternal.h */; settings = {ATTRIBUTES = (); }; }; - 15A5A1F90D5B94190087BDA0 /* SCNetwork.h in Headers */ = {isa = PBXBuildFile; fileRef = 15CB693305C0722B0099E85F /* SCNetwork.h */; settings = {ATTRIBUTES = (Public, Project, ); }; }; - 15A5A1FA0D5B94190087BDA0 /* SCNetworkConnection.h in Headers */ = {isa = PBXBuildFile; fileRef = 15CB693505C0722B0099E85F /* SCNetworkConnection.h */; settings = {ATTRIBUTES = (Public, Project, ); }; }; - 15A5A1FB0D5B94190087BDA0 /* SCNetworkReachability.h in Headers */ = {isa = PBXBuildFile; fileRef = 15CB693705C0722B0099E85F /* SCNetworkReachability.h */; settings = {ATTRIBUTES = (Public, Project, ); }; }; + 15A5A1F90D5B94190087BDA0 /* SCNetwork.h in Headers */ = {isa = PBXBuildFile; fileRef = 15CB693305C0722B0099E85F /* SCNetwork.h */; settings = {ATTRIBUTES = (Project, Public, ); }; }; + 15A5A1FA0D5B94190087BDA0 /* SCNetworkConnection.h in Headers */ = {isa = PBXBuildFile; fileRef = 15CB693505C0722B0099E85F /* SCNetworkConnection.h */; settings = {ATTRIBUTES = (Project, Public, ); }; }; + 15A5A1FB0D5B94190087BDA0 /* SCNetworkReachability.h in Headers */ = {isa = PBXBuildFile; fileRef = 15CB693705C0722B0099E85F /* SCNetworkReachability.h */; settings = {ATTRIBUTES = (Project, Public, ); }; }; 15A5A1FC0D5B94190087BDA0 /* SCValidation.h in Headers */ = {isa = PBXBuildFile; fileRef = 15CB693905C0722B0099E85F /* SCValidation.h */; settings = {ATTRIBUTES = (Private, Project, ); }; }; 15A5A1FD0D5B94190087BDA0 /* DHCPClientPreferences.h in Headers */ = {isa = PBXBuildFile; fileRef = 15CB693D05C0722B0099E85F /* DHCPClientPreferences.h */; settings = {ATTRIBUTES = (Public, ); }; }; 15A5A1FE0D5B94190087BDA0 /* SCDynamicStoreCopyDHCPInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = 15CB693F05C0722B0099E85F /* SCDynamicStoreCopyDHCPInfo.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -789,17 +768,11 @@ 15AAA7F7108E310700C2A607 /* VPNTunnelPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 15AAA7F1108E310700C2A607 /* VPNTunnelPrivate.h */; settings = {ATTRIBUTES = (Private, ); }; }; 15AAA7F8108E310700C2A607 /* VPNTunnel.h in Headers */ = {isa = PBXBuildFile; fileRef = 15AAA7F2108E310700C2A607 /* VPNTunnel.h */; settings = {ATTRIBUTES = (Private, ); }; }; 15AAA7F9108E310700C2A607 /* VPNTunnel.c in Sources */ = {isa = PBXBuildFile; fileRef = 15AAA7F3108E310700C2A607 /* VPNTunnel.c */; }; - 15AB751516EBFF3400FAA8CE /* SCNetworkReachabilityServer_server.c in Sources */ = {isa = PBXBuildFile; fileRef = 15C330BB134B92780028E36B /* SCNetworkReachabilityServer_server.c */; }; 15AB752D16EC2AE900FAA8CE /* libIPMonitor_sim.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 15E1B05916EBAE3C00E5F06F /* libIPMonitor_sim.a */; }; - 15AB752E16EC2AE900FAA8CE /* libSCNetworkReachability_sim.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 15AB751916EBFF3400FAA8CE /* libSCNetworkReachability_sim.a */; }; 15BAA32307F0699A00D9EC95 /* libbsm.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 15BAA32207F0699A00D9EC95 /* libbsm.dylib */; }; - 15C330BC134B92780028E36B /* SCNetworkReachabilityServer_client.c in Sources */ = {isa = PBXBuildFile; fileRef = 15C330B7134B92780028E36B /* SCNetworkReachabilityServer_client.c */; }; - 15C330BD134B92780028E36B /* SCNetworkReachabilityServer_client.c in Sources */ = {isa = PBXBuildFile; fileRef = 15C330B7134B92780028E36B /* SCNetworkReachabilityServer_client.c */; }; - 15C330BE134B92780028E36B /* SCNetworkReachabilityServer_client.c in Sources */ = {isa = PBXBuildFile; fileRef = 15C330B7134B92780028E36B /* SCNetworkReachabilityServer_client.c */; }; 15C330D1134B95AA0028E36B /* SCNetworkReachabilityInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 15C330D0134B95AA0028E36B /* SCNetworkReachabilityInternal.h */; }; 15C330D2134B95AA0028E36B /* SCNetworkReachabilityInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 15C330D0134B95AA0028E36B /* SCNetworkReachabilityInternal.h */; }; 15C330D3134B95AA0028E36B /* SCNetworkReachabilityInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 15C330D0134B95AA0028E36B /* SCNetworkReachabilityInternal.h */; }; - 15C330E5134BD2AC0028E36B /* SCNetworkReachabilityServer_server.c in Sources */ = {isa = PBXBuildFile; fileRef = 15C330BB134B92780028E36B /* SCNetworkReachabilityServer_server.c */; }; 15C8C6BF170AAB4E005375CE /* cache.c in Sources */ = {isa = PBXBuildFile; fileRef = 159D53CA07528B36004F8947 /* cache.c */; }; 15C8C6C0170AAB4E005375CE /* cache.h in Headers */ = {isa = PBXBuildFile; fileRef = 159D53CB07528B36004F8947 /* cache.h */; }; 15D2E437167643460078F547 /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1520A3DE0846B2DC0010B584 /* Security.framework */; }; @@ -819,26 +792,26 @@ 15DAD5E1075913CE0084A6ED /* dnsinfo.h in Headers */ = {isa = PBXBuildFile; fileRef = 15B73F0905FD1B670096477F /* dnsinfo.h */; settings = {ATTRIBUTES = (Public, ); }; }; 15DAD5E2075913CE0084A6ED /* dnsinfo_private.h in Headers */ = {isa = PBXBuildFile; fileRef = 15B73F0C05FD1B670096477F /* dnsinfo_private.h */; }; 15DAD5E6075913CE0084A6ED /* dnsinfo_copy.c in Sources */ = {isa = PBXBuildFile; fileRef = 15B73F0805FD1B670096477F /* dnsinfo_copy.c */; }; - 15DAD64307591A1A0084A6ED /* SystemConfiguration.h in Headers */ = {isa = PBXBuildFile; fileRef = 15CB691305C0722B0099E85F /* SystemConfiguration.h */; settings = {ATTRIBUTES = (Public, Project, ); }; }; + 15DAD64307591A1A0084A6ED /* SystemConfiguration.h in Headers */ = {isa = PBXBuildFile; fileRef = 15CB691305C0722B0099E85F /* SystemConfiguration.h */; settings = {ATTRIBUTES = (Project, Public, ); }; }; 15DAD64407591A1A0084A6ED /* SCPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 15CB691505C0722B0099E85F /* SCPrivate.h */; settings = {ATTRIBUTES = (Private, Project, ); }; }; 15DAD64507591A1A0084A6ED /* SCDPlugin.h in Headers */ = {isa = PBXBuildFile; fileRef = 15CB691705C0722B0099E85F /* SCDPlugin.h */; settings = {ATTRIBUTES = (Private, ); }; }; 15DAD64607591A1A0084A6ED /* SCDynamicStoreInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 15CB691B05C0722B0099E85F /* SCDynamicStoreInternal.h */; settings = {ATTRIBUTES = (Project, ); }; }; - 15DAD64707591A1A0084A6ED /* SCDynamicStore.h in Headers */ = {isa = PBXBuildFile; fileRef = 15CB691D05C0722B0099E85F /* SCDynamicStore.h */; settings = {ATTRIBUTES = (Public, Project, ); }; }; + 15DAD64707591A1A0084A6ED /* SCDynamicStore.h in Headers */ = {isa = PBXBuildFile; fileRef = 15CB691D05C0722B0099E85F /* SCDynamicStore.h */; settings = {ATTRIBUTES = (Project, Public, ); }; }; 15DAD64807591A1A0084A6ED /* SCDynamicStorePrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 15CB691F05C0722B0099E85F /* SCDynamicStorePrivate.h */; settings = {ATTRIBUTES = (Private, Project, ); }; }; - 15DAD64907591A1A0084A6ED /* SCDynamicStoreKey.h in Headers */ = {isa = PBXBuildFile; fileRef = 15CB692105C0722B0099E85F /* SCDynamicStoreKey.h */; settings = {ATTRIBUTES = (Public, Project, ); }; }; - 15DAD64A07591A1A0084A6ED /* SCDynamicStoreCopySpecific.h in Headers */ = {isa = PBXBuildFile; fileRef = 15CB692305C0722B0099E85F /* SCDynamicStoreCopySpecific.h */; settings = {ATTRIBUTES = (Public, Project, ); }; }; + 15DAD64907591A1A0084A6ED /* SCDynamicStoreKey.h in Headers */ = {isa = PBXBuildFile; fileRef = 15CB692105C0722B0099E85F /* SCDynamicStoreKey.h */; settings = {ATTRIBUTES = (Project, Public, ); }; }; + 15DAD64A07591A1A0084A6ED /* SCDynamicStoreCopySpecific.h in Headers */ = {isa = PBXBuildFile; fileRef = 15CB692305C0722B0099E85F /* SCDynamicStoreCopySpecific.h */; settings = {ATTRIBUTES = (Project, Public, ); }; }; 15DAD64B07591A1A0084A6ED /* SCDynamicStoreCopySpecificPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 15CB692505C0722B0099E85F /* SCDynamicStoreCopySpecificPrivate.h */; settings = {ATTRIBUTES = (Private, Project, ); }; }; 15DAD64C07591A1A0084A6ED /* SCDynamicStoreSetSpecificPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 15CB692705C0722B0099E85F /* SCDynamicStoreSetSpecificPrivate.h */; settings = {ATTRIBUTES = (Private, Project, ); }; }; 15DAD64D07591A1A0084A6ED /* SCPreferencesInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 15CB692905C0722B0099E85F /* SCPreferencesInternal.h */; settings = {ATTRIBUTES = (Project, ); }; }; - 15DAD64E07591A1A0084A6ED /* SCPreferences.h in Headers */ = {isa = PBXBuildFile; fileRef = 15CB692B05C0722B0099E85F /* SCPreferences.h */; settings = {ATTRIBUTES = (Public, Project, ); }; }; + 15DAD64E07591A1A0084A6ED /* SCPreferences.h in Headers */ = {isa = PBXBuildFile; fileRef = 15CB692B05C0722B0099E85F /* SCPreferences.h */; settings = {ATTRIBUTES = (Project, Public, ); }; }; 15DAD64F07591A1A0084A6ED /* SCPreferencesPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 15CB692D05C0722B0099E85F /* SCPreferencesPrivate.h */; settings = {ATTRIBUTES = (Private, Project, ); }; }; - 15DAD65007591A1A0084A6ED /* SCPreferencesPath.h in Headers */ = {isa = PBXBuildFile; fileRef = 15CB692F05C0722B0099E85F /* SCPreferencesPath.h */; settings = {ATTRIBUTES = (Public, Project, ); }; }; - 15DAD65107591A1A0084A6ED /* SCPreferencesSetSpecific.h in Headers */ = {isa = PBXBuildFile; fileRef = 15CB693105C0722B0099E85F /* SCPreferencesSetSpecific.h */; settings = {ATTRIBUTES = (Public, Project, ); }; }; + 15DAD65007591A1A0084A6ED /* SCPreferencesPath.h in Headers */ = {isa = PBXBuildFile; fileRef = 15CB692F05C0722B0099E85F /* SCPreferencesPath.h */; settings = {ATTRIBUTES = (Project, Public, ); }; }; + 15DAD65107591A1A0084A6ED /* SCPreferencesSetSpecific.h in Headers */ = {isa = PBXBuildFile; fileRef = 15CB693105C0722B0099E85F /* SCPreferencesSetSpecific.h */; settings = {ATTRIBUTES = (Project, Public, ); }; }; 15DAD65207591A1A0084A6ED /* SCNetworkConfiguration.h in Headers */ = {isa = PBXBuildFile; fileRef = 15AD7A380670A85900BFE03C /* SCNetworkConfiguration.h */; settings = {ATTRIBUTES = (Public, ); }; }; 15DAD65307591A1A0084A6ED /* SCNetworkConfigurationInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 15AD7A3A0670A85900BFE03C /* SCNetworkConfigurationInternal.h */; settings = {ATTRIBUTES = (); }; }; - 15DAD65407591A1A0084A6ED /* SCNetwork.h in Headers */ = {isa = PBXBuildFile; fileRef = 15CB693305C0722B0099E85F /* SCNetwork.h */; settings = {ATTRIBUTES = (Public, Project, ); }; }; - 15DAD65507591A1A0084A6ED /* SCNetworkConnection.h in Headers */ = {isa = PBXBuildFile; fileRef = 15CB693505C0722B0099E85F /* SCNetworkConnection.h */; settings = {ATTRIBUTES = (Public, Project, ); }; }; - 15DAD65607591A1A0084A6ED /* SCNetworkReachability.h in Headers */ = {isa = PBXBuildFile; fileRef = 15CB693705C0722B0099E85F /* SCNetworkReachability.h */; settings = {ATTRIBUTES = (Public, Project, ); }; }; + 15DAD65407591A1A0084A6ED /* SCNetwork.h in Headers */ = {isa = PBXBuildFile; fileRef = 15CB693305C0722B0099E85F /* SCNetwork.h */; settings = {ATTRIBUTES = (Project, Public, ); }; }; + 15DAD65507591A1A0084A6ED /* SCNetworkConnection.h in Headers */ = {isa = PBXBuildFile; fileRef = 15CB693505C0722B0099E85F /* SCNetworkConnection.h */; settings = {ATTRIBUTES = (Project, Public, ); }; }; + 15DAD65607591A1A0084A6ED /* SCNetworkReachability.h in Headers */ = {isa = PBXBuildFile; fileRef = 15CB693705C0722B0099E85F /* SCNetworkReachability.h */; settings = {ATTRIBUTES = (Project, Public, ); }; }; 15DAD65707591A1A0084A6ED /* SCValidation.h in Headers */ = {isa = PBXBuildFile; fileRef = 15CB693905C0722B0099E85F /* SCValidation.h */; settings = {ATTRIBUTES = (Private, Project, ); }; }; 15DAD65807591A1A0084A6ED /* DHCPClientPreferences.h in Headers */ = {isa = PBXBuildFile; fileRef = 15CB693D05C0722B0099E85F /* DHCPClientPreferences.h */; settings = {ATTRIBUTES = (Public, ); }; }; 15DAD65907591A1A0084A6ED /* SCDynamicStoreCopyDHCPInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = 15CB693F05C0722B0099E85F /* SCDynamicStoreCopyDHCPInfo.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -935,11 +908,13 @@ 15FEE81F0CD03E75001312F9 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 15FEE8180CD03CBB001312F9 /* Localizable.strings */; }; 15FF5C370CDF776200EEC8AA /* com.apple.SCHelper.plist in CopyFiles */ = {isa = PBXBuildFile; fileRef = 15FF5C290CDF770500EEC8AA /* com.apple.SCHelper.plist */; }; 55A3DB9E183C2AD900ED3DB7 /* SCNetworkMigration.c in Sources */ = {isa = PBXBuildFile; fileRef = 55A3DB9D183C2A8200ED3DB7 /* SCNetworkMigration.c */; }; + 72499BA41AC9B7AB0090C49F /* get-network-info in Resources */ = {isa = PBXBuildFile; fileRef = 72499BA31AC9B7AB0090C49F /* get-network-info */; }; + 72499BA51AC9B7AB0090C49F /* get-network-info in Resources */ = {isa = PBXBuildFile; fileRef = 72499BA31AC9B7AB0090C49F /* get-network-info */; }; + 725E53D71A92D2C3009997E1 /* com.apple.networking.IPMonitor in com.apple.networking.IPMonitor */ = {isa = PBXBuildFile; fileRef = 725E53D51A92D2A5009997E1 /* com.apple.networking.IPMonitor */; }; 7264C144147319E7004FD76D /* CaptiveNetwork.c in Sources */ = {isa = PBXBuildFile; fileRef = 15A1FF3110597F17004C9CC9 /* CaptiveNetwork.c */; }; 7264C14614731A1F004FD76D /* CaptiveNetwork.h in Headers */ = {isa = PBXBuildFile; fileRef = 15A1FF3010597F17004C9CC9 /* CaptiveNetwork.h */; settings = {ATTRIBUTES = (Public, ); }; }; 727AF25419138699009AB153 /* VPNAppLayerPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = B0A88CA616397A1200A60B3A /* VPNAppLayerPrivate.h */; settings = {ATTRIBUTES = (Private, ); }; }; 727AF255191386A0009AB153 /* VPNFlow.h in Headers */ = {isa = PBXBuildFile; fileRef = C4CDB8111631933400819B44 /* VPNFlow.h */; settings = {ATTRIBUTES = (Private, ); }; }; - 727AF256191386CB009AB153 /* VPNFlowPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = C4CDB8121631933400819B44 /* VPNFlowPrivate.h */; settings = {ATTRIBUTES = (Private, ); }; }; 727AF257191386DA009AB153 /* VPNTunnel.h in Headers */ = {isa = PBXBuildFile; fileRef = 15AAA7F2108E310700C2A607 /* VPNTunnel.h */; settings = {ATTRIBUTES = (Private, ); }; }; 727AF258191386E3009AB153 /* VPNTunnelPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 15AAA7F1108E310700C2A607 /* VPNTunnelPrivate.h */; settings = {ATTRIBUTES = (Private, ); }; }; 727AF25919138E24009AB153 /* VPNTunnel.c in Sources */ = {isa = PBXBuildFile; fileRef = 15AAA7F3108E310700C2A607 /* VPNTunnel.c */; }; @@ -947,6 +922,8 @@ 72B43729113C7BFC00EBF1B6 /* nc.c in Sources */ = {isa = PBXBuildFile; fileRef = 72B43727113C7BFC00EBF1B6 /* nc.c */; }; 72B4372A113C7BFC00EBF1B6 /* nc.h in Headers */ = {isa = PBXBuildFile; fileRef = 72B43726113C7BFC00EBF1B6 /* nc.h */; }; 72B4372B113C7BFC00EBF1B6 /* nc.c in Sources */ = {isa = PBXBuildFile; fileRef = 72B43727113C7BFC00EBF1B6 /* nc.c */; }; + 72D3E6611AE6EA3A00DB4C69 /* main.swift in Sources */ = {isa = PBXBuildFile; fileRef = 72D3E6601AE6EA3A00DB4C69 /* main.swift */; }; + 72D3E66C1AE6EAF600DB4C69 /* test-objC.m in Sources */ = {isa = PBXBuildFile; fileRef = 72D3E66B1AE6EAF600DB4C69 /* test-objC.m */; }; B03FEFB616376D2800A1B88F /* VPNAppLayer.c in Sources */ = {isa = PBXBuildFile; fileRef = B03FEFB516376D2800A1B88F /* VPNAppLayer.c */; }; B03FEFB716376D2800A1B88F /* VPNAppLayer.c in Sources */ = {isa = PBXBuildFile; fileRef = B03FEFB516376D2800A1B88F /* VPNAppLayer.c */; }; B03FEFBA16382C0700A1B88F /* libbsm.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 15BAA32207F0699A00D9EC95 /* libbsm.dylib */; }; @@ -961,12 +938,11 @@ B0C9689E174426DD00889853 /* SNHelperPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = B0C967F717441F0E00889853 /* SNHelperPrivate.h */; settings = {ATTRIBUTES = (Private, ); }; }; B0FEF41A164406F400174B99 /* libbsm.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 15BAA32207F0699A00D9EC95 /* libbsm.dylib */; }; B0FEF41B1644089200174B99 /* VPNAppLayer.c in Sources */ = {isa = PBXBuildFile; fileRef = B03FEFB516376D2800A1B88F /* VPNAppLayer.c */; }; + C42633891A9E4991009F7AE4 /* VPNFlow.c in Sources */ = {isa = PBXBuildFile; fileRef = C4CDB8141631935700819B44 /* VPNFlow.c */; }; C4CDB8151631935700819B44 /* VPNFlow.c in Sources */ = {isa = PBXBuildFile; fileRef = C4CDB8141631935700819B44 /* VPNFlow.c */; }; C4CDB8161631935700819B44 /* VPNFlow.c in Sources */ = {isa = PBXBuildFile; fileRef = C4CDB8141631935700819B44 /* VPNFlow.c */; }; C4CDB8171631938000819B44 /* VPNFlow.h in Headers */ = {isa = PBXBuildFile; fileRef = C4CDB8111631933400819B44 /* VPNFlow.h */; settings = {ATTRIBUTES = (Private, ); }; }; - C4CDB8181631938400819B44 /* VPNFlowPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = C4CDB8121631933400819B44 /* VPNFlowPrivate.h */; settings = {ATTRIBUTES = (Private, ); }; }; C4CDB819163193AA00819B44 /* VPNFlow.h in Headers */ = {isa = PBXBuildFile; fileRef = C4CDB8111631933400819B44 /* VPNFlow.h */; settings = {ATTRIBUTES = (Private, ); }; }; - C4CDB81A163193AF00819B44 /* VPNFlowPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = C4CDB8121631933400819B44 /* VPNFlowPrivate.h */; settings = {ATTRIBUTES = (Private, ); }; }; C4F1848016237AFC00D97043 /* VPNService.c in Sources */ = {isa = PBXBuildFile; fileRef = C4F1847F16237AFC00D97043 /* VPNService.c */; }; C4F1848116237AFC00D97043 /* VPNService.c in Sources */ = {isa = PBXBuildFile; fileRef = C4F1847F16237AFC00D97043 /* VPNService.c */; }; C4F1848316237B1400D97043 /* VPNService.c in Sources */ = {isa = PBXBuildFile; fileRef = C4F1847F16237AFC00D97043 /* VPNService.c */; }; @@ -1027,41 +1003,6 @@ remoteGlobalIDString = 151FE2DD0D5B7046000D6DB1; remoteInfo = "configd_base-EmbeddedSimulator"; }; - 1521405A0E9400BF00DACD2C /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 15CB6A7705C0722B0099E85F /* Project object */; - proxyType = 1; - remoteGlobalIDString = 15213FF90E93E9F500DACD2C; - remoteInfo = Logger.bundle; - }; - 1528BFEB135731B800691881 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 15CB6A7705C0722B0099E85F /* Project object */; - proxyType = 1; - remoteGlobalIDString = 1528BFDB1357305400691881; - remoteInfo = SCNetworkReachability; - }; - 1528BFED135731B800691881 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 15CB6A7705C0722B0099E85F /* Project object */; - proxyType = 1; - remoteGlobalIDString = 1528BFE31357309700691881; - remoteInfo = SCNetworkReachability.bundle; - }; - 1528C00E135741C300691881 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 15CB6A7705C0722B0099E85F /* Project object */; - proxyType = 1; - remoteGlobalIDString = 1528BFF013573FEE00691881; - remoteInfo = "SCNetworkReachability-Embedded"; - }; - 1528C010135741C300691881 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 15CB6A7705C0722B0099E85F /* Project object */; - proxyType = 1; - remoteGlobalIDString = 1528BFF813573FF500691881; - remoteInfo = "SCNetworkReachability.bundle-Embedded"; - }; 1558480507550D470046C2E9 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 15CB6A7705C0722B0099E85F /* Project object */; @@ -1090,13 +1031,6 @@ remoteGlobalIDString = 155847FA07550D210046C2E9; remoteInfo = configd_executables; }; - 156CA4A70EF8550800C59A18 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 15CB6A7705C0722B0099E85F /* Project object */; - proxyType = 1; - remoteGlobalIDString = 156CA4790EF853BB00C59A18; - remoteInfo = "Logger.bundle-Embedded"; - }; 15732AE516EA6BCE00F3AC4C /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 15CB6A7705C0722B0099E85F /* Project object */; @@ -1335,20 +1269,6 @@ remoteGlobalIDString = 15A5A1E40D5B94190087BDA0; remoteInfo = "SystemConfiguration.framework-EmbeddedSimulator"; }; - 15AB752116EC005A00FAA8CE /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 15CB6A7705C0722B0099E85F /* Project object */; - proxyType = 1; - remoteGlobalIDString = 15AB751216EBFF3400FAA8CE; - remoteInfo = "SCNetworkReachability-EmbeddedSimulator"; - }; - 15AB752316EC005A00FAA8CE /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 15CB6A7705C0722B0099E85F /* Project object */; - proxyType = 1; - remoteGlobalIDString = 15AB751A16EBFF8A00FAA8CE; - remoteInfo = "SCNetworkReachability.bundle-EmbeddedSimulator"; - }; 15AB752916EC254D00FAA8CE /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 15CB6A7705C0722B0099E85F /* Project object */; @@ -1356,13 +1276,6 @@ remoteGlobalIDString = 15E1B04116EBAE3C00E5F06F; remoteInfo = "IPMonitor-EmbeddedSimulator"; }; - 15AB752B16EC254D00FAA8CE /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 15CB6A7705C0722B0099E85F /* Project object */; - proxyType = 1; - remoteGlobalIDString = 15AB751216EBFF3400FAA8CE; - remoteInfo = "SCNetworkReachability-EmbeddedSimulator"; - }; 15C64A210F684C4900D78394 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 15CB6A7705C0722B0099E85F /* Project object */; @@ -1461,6 +1374,20 @@ remoteGlobalIDString = 15FD13BF0D59485000F9409C; remoteInfo = "All-EmbeddedSimulator"; }; + 723050311AE6F292004AC149 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 15CB6A7705C0722B0099E85F /* Project object */; + proxyType = 1; + remoteGlobalIDString = 15DAD63F07591A1A0084A6ED; + remoteInfo = SystemConfiguration.framework; + }; + 723050331AE6F29D004AC149 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 15CB6A7705C0722B0099E85F /* Project object */; + proxyType = 1; + remoteGlobalIDString = 15DAD63F07591A1A0084A6ED; + remoteInfo = SystemConfiguration.framework; + }; D6DDAC3C147A24BC00A2E902 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 15CB6A7705C0722B0099E85F /* Project object */; @@ -1494,7 +1421,7 @@ 15732AA716EA503200F3AC4C /* CopyFiles */ = { isa = PBXCopyFilesBuildPhase; buildActionMask = 8; - dstPath = "$(INSTALL_PATH_PREFIX)/System/Library/LaunchDaemons"; + dstPath = /System/Library/LaunchDaemons; dstSubfolderSpec = 0; files = ( 15D3083B16F4E81C00014F82 /* com.apple.configd_sim.plist in CopyFiles */, @@ -1584,6 +1511,35 @@ ); runOnlyForDeploymentPostprocessing = 1; }; + 72AD314B1A843C1000D2226E /* com.apple.networking.IPMonitor */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 8; + dstPath = /private/etc/asl; + dstSubfolderSpec = 0; + files = ( + 725E53D71A92D2C3009997E1 /* com.apple.networking.IPMonitor in com.apple.networking.IPMonitor */, + ); + name = com.apple.networking.IPMonitor; + 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; + }; /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ @@ -1596,32 +1552,24 @@ 151F5D9A0CCE98E50093AC3B /* SCMonitor.plugin */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = SCMonitor.plugin; sourceTree = BUILT_PRODUCTS_DIR; }; 151F63EC09328A3C0096DCC9 /* genSCPreferences */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = genSCPreferences; sourceTree = BUILT_PRODUCTS_DIR; }; 1520A3DE0846B2DC0010B584 /* Security.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Security.framework; path = /System/Library/Frameworks/Security.framework; sourceTree = ""; }; - 15213FFA0E93E9F500DACD2C /* Logger.bundle */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = Logger.bundle; sourceTree = BUILT_PRODUCTS_DIR; }; 1521FC5C060F296A003B28F5 /* dnsinfo_create.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = dnsinfo_create.c; path = dnsinfo/dnsinfo_create.c; sourceTree = SOURCE_ROOT; }; 1522FCE50FA7FD7000B24128 /* dnsinfo_flatfile.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = dnsinfo_flatfile.c; path = dnsinfo/dnsinfo_flatfile.c; sourceTree = ""; }; 152439E318038E5B00D91708 /* ev_extra.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ev_extra.h; sourceTree = ""; }; 152439E418038E5B00D91708 /* ev_extra.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ev_extra.m; sourceTree = ""; }; 152439E7180399D800D91708 /* CoreWLAN.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreWLAN.framework; path = /System/Library/Frameworks/CoreWLAN.framework; sourceTree = ""; }; 152439EB180716ED00D91708 /* MobileWiFi.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MobileWiFi.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.Internal.sdk/System/Library/PrivateFrameworks/MobileWiFi.framework; sourceTree = DEVELOPER_DIR; }; - 1528BFE21357305400691881 /* libSCNetworkReachability.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libSCNetworkReachability.a; sourceTree = BUILT_PRODUCTS_DIR; }; - 1528BFE81357309800691881 /* SCNetworkReachability.bundle */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = SCNetworkReachability.bundle; sourceTree = BUILT_PRODUCTS_DIR; }; - 1528BFE91357312E00691881 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = Plugins/SCNetworkReachability/Info.plist; sourceTree = ""; }; - 1528BFF713573FEE00691881 /* libSCNetworkReachability.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libSCNetworkReachability.a; sourceTree = BUILT_PRODUCTS_DIR; }; - 1528BFFE13573FF500691881 /* SCNetworkReachability.bundle */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = SCNetworkReachability.bundle; sourceTree = BUILT_PRODUCTS_DIR; }; 152CEED0070CF6640050F23C /* libedit.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libedit.dylib; path = /usr/lib/libedit.2.dylib; sourceTree = ""; }; 152E0E7E10FE820E00E402F2 /* helper.defs */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.mig; name = helper.defs; path = SystemConfiguration.fproj/helper/helper.defs; sourceTree = ""; }; 152E0E8810FE824000E402F2 /* helper_types.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = helper_types.h; path = SystemConfiguration.fproj/helper/helper_types.h; sourceTree = ""; }; 152E68C00A2C89C70011FDA8 /* SCPreferencesKeychainPrivate.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = SCPreferencesKeychainPrivate.h; sourceTree = ""; }; 152E68C20A2C89E30011FDA8 /* SCPreferencesKeychainPrivate.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = SCPreferencesKeychainPrivate.c; sourceTree = ""; }; - 1531D3DA0E93E6DA00248432 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = Plugins/Logger/Info.plist; sourceTree = ""; }; - 1531D3DB0E93E6DA00248432 /* logger.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = logger.c; path = Plugins/Logger/logger.c; sourceTree = ""; }; 1532629006281C9D00B1C10C /* dnsinfo_create.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = dnsinfo_create.h; path = dnsinfo/dnsinfo_create.h; sourceTree = ""; }; 153338BA14BE7978004FCE22 /* libSystemConfiguration_client.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = libSystemConfiguration_client.c; path = libSystemConfiguration/libSystemConfiguration_client.c; sourceTree = ""; }; 153338BB14BE7978004FCE22 /* libSystemConfiguration_client.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = libSystemConfiguration_client.h; path = libSystemConfiguration/libSystemConfiguration_client.h; sourceTree = ""; }; 153393E20D34994100FE74E7 /* update-headers */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.perl; path = "update-headers"; sourceTree = ""; }; 153ACCA614E322D5005029A5 /* network_information_server.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; lineEnding = 0; name = network_information_server.c; path = nwi/network_information_server.c; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.c; }; 153ACCA714E322D5005029A5 /* network_information_server.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = network_information_server.h; path = nwi/network_information_server.h; sourceTree = ""; }; - 1540E3600987DA9500157C07 /* com.apple.configd.plist */ = {isa = PBXFileReference; explicitFileType = text.plist.xml; fileEncoding = 30; path = com.apple.configd.plist; sourceTree = ""; }; + 1540E3600987DA9500157C07 /* com.apple.configd.plist */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text.plist.xml; path = com.apple.configd.plist; sourceTree = ""; }; 1543636A0752D03C00A8EC6C /* IOKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = IOKit.framework; path = /System/Library/Frameworks/IOKit.framework; sourceTree = ""; }; 1547001D08455B98006787CE /* SCHelper */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = SCHelper; sourceTree = BUILT_PRODUCTS_DIR; }; 1547072E0D1F70C80075C28D /* SystemConfiguration.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SystemConfiguration.framework; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -1643,13 +1591,11 @@ 155D223A0AF13A7300D52ED0 /* smb-configuration.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = "smb-configuration.h"; sourceTree = ""; }; 1567333E0DD1FD6500145179 /* entitlements-ios.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "entitlements-ios.plist"; sourceTree = ""; }; 156BD6BB07E0DFA9008698FF /* SCPreferencesSetSpecificPrivate.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = SCPreferencesSetSpecificPrivate.h; sourceTree = ""; }; - 156CA4850EF853BB00C59A18 /* Logger.bundle */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = Logger.bundle; sourceTree = BUILT_PRODUCTS_DIR; }; - 156CA48D0EF853BB00C59A18 /* Info-Embedded.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; name = "Info-Embedded.plist"; path = "Plugins/Logger/Info-Embedded.plist"; sourceTree = ""; }; 1572C57E171CCF9500870549 /* pppcontroller_mach_defines.h */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.h; name = pppcontroller_mach_defines.h; path = usr/local/include/ppp/pppcontroller_mach_defines.h; sourceTree = SDKROOT; }; 1572EB7A0A506D3B00D02459 /* smb-configuration.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = "smb-configuration.c"; sourceTree = ""; }; 15732AAC16EA503300F3AC4C /* configd_sim */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = configd_sim; sourceTree = BUILT_PRODUCTS_DIR; }; 15732AD516EA511900F3AC4C /* scutil_sim */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = scutil_sim; sourceTree = BUILT_PRODUCTS_DIR; }; - 15732AE416EA6B6700F3AC4C /* libsystem_sim_configuration.dylib */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.dylib"; includeInIndex = 0; path = libsystem_sim_configuration.dylib; sourceTree = BUILT_PRODUCTS_DIR; }; + 15732AE416EA6B6700F3AC4C /* libsystem_configuration.dylib */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.dylib"; includeInIndex = 0; path = libsystem_configuration.dylib; sourceTree = BUILT_PRODUCTS_DIR; }; 157433EC0D4A8122002ACA73 /* scselect */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = scselect; sourceTree = BUILT_PRODUCTS_DIR; }; 1574341A0D4A8137002ACA73 /* scutil */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = scutil; sourceTree = BUILT_PRODUCTS_DIR; }; 1575FD2512CD15C60003D86E /* proxy-configuration.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = "proxy-configuration.c"; sourceTree = ""; }; @@ -1677,7 +1623,7 @@ 159D53AA07528B36004F8947 /* dns-configuration.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = "dns-configuration.c"; sourceTree = ""; }; 159D53AB07528B36004F8947 /* set-hostname.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = "set-hostname.c"; sourceTree = ""; }; 159D53AE07528B36004F8947 /* ifnamer.c */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.c; path = ifnamer.c; sourceTree = ""; }; - 159D53B007528B36004F8947 /* eventmon.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = eventmon.c; sourceTree = ""; }; + 159D53B007528B36004F8947 /* eventmon.c */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.c; path = eventmon.c; sourceTree = ""; }; 159D53B107528B36004F8947 /* ev_dlil.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = ev_dlil.c; sourceTree = ""; }; 159D53B207528B36004F8947 /* ev_dlil.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = ev_dlil.h; sourceTree = ""; }; 159D53B307528B36004F8947 /* ev_ipv4.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = ev_ipv4.c; sourceTree = ""; }; @@ -1706,8 +1652,6 @@ 15AAA7F1108E310700C2A607 /* VPNTunnelPrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VPNTunnelPrivate.h; sourceTree = ""; }; 15AAA7F2108E310700C2A607 /* VPNTunnel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VPNTunnel.h; sourceTree = ""; }; 15AAA7F3108E310700C2A607 /* VPNTunnel.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = VPNTunnel.c; sourceTree = ""; }; - 15AB751916EBFF3400FAA8CE /* libSCNetworkReachability_sim.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libSCNetworkReachability_sim.a; sourceTree = BUILT_PRODUCTS_DIR; }; - 15AB751F16EBFF8A00FAA8CE /* SCNetworkReachability.bundle */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = SCNetworkReachability.bundle; sourceTree = BUILT_PRODUCTS_DIR; }; 15AC2D8816C574FE00340E28 /* libcupolicy.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libcupolicy.dylib; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.Internal.sdk/usr/lib/libcupolicy.dylib; sourceTree = DEVELOPER_DIR; }; 15AD7A380670A85900BFE03C /* SCNetworkConfiguration.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = SCNetworkConfiguration.h; sourceTree = ""; }; 15AD7A390670A85900BFE03C /* SCNetworkConfigurationInternal.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = SCNetworkConfigurationInternal.c; sourceTree = ""; }; @@ -1723,8 +1667,6 @@ 15B73F0D05FD1B670096477F /* dnsinfo_server.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = dnsinfo_server.c; path = dnsinfo/dnsinfo_server.c; sourceTree = ""; }; 15B73F0E05FD1B670096477F /* dnsinfo_server.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = dnsinfo_server.h; path = dnsinfo/dnsinfo_server.h; sourceTree = ""; }; 15BAA32207F0699A00D9EC95 /* libbsm.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libbsm.dylib; path = /usr/lib/libbsm.dylib; sourceTree = ""; }; - 15C330B7134B92780028E36B /* SCNetworkReachabilityServer_client.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = SCNetworkReachabilityServer_client.c; path = reachability/SCNetworkReachabilityServer_client.c; sourceTree = ""; }; - 15C330BB134B92780028E36B /* SCNetworkReachabilityServer_server.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = SCNetworkReachabilityServer_server.c; path = reachability/SCNetworkReachabilityServer_server.c; sourceTree = ""; }; 15C330D0134B95AA0028E36B /* SCNetworkReachabilityInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SCNetworkReachabilityInternal.h; sourceTree = ""; }; 15CAEF381712690500367CE1 /* libcupolicy.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libcupolicy.dylib; path = Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator7.0.sdk/usr/local/lib/libcupolicy.dylib; sourceTree = DEVELOPER_DIR; }; 15CB691305C0722B0099E85F /* SystemConfiguration.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SystemConfiguration.h; sourceTree = ""; }; @@ -1875,11 +1817,9 @@ 15E1B06116EBAE7800E5F06F /* IPMonitor.bundle */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = IPMonitor.bundle; sourceTree = BUILT_PRODUCTS_DIR; }; 15FBB54B17D6834C0035D752 /* libCrashReporterClient.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libCrashReporterClient.a; path = /usr/local/lib/libCrashReporterClient.a; sourceTree = ""; }; 15FBB54E17D7899C0035D752 /* Info-EmbeddedSimulator.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "Info-EmbeddedSimulator.plist"; sourceTree = ""; }; - 15FBB54F17D789B50035D752 /* Info-EmbeddedSimulator.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = "Info-EmbeddedSimulator.plist"; path = "Plugins/SCNetworkReachability/Info-EmbeddedSimulator.plist"; sourceTree = ""; }; 15FBB55017D78A780035D752 /* update-mach-services */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = "update-mach-services"; sourceTree = ""; }; 15FC12F20CCEA4F00013872C /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = SCMonitor/Info.plist; sourceTree = ""; }; 15FC130A0CCEA59E0013872C /* monitor.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = monitor.c; path = SCMonitor/monitor.c; sourceTree = ""; }; - 15FD147B0D594FE700F9409C /* SimulatorSupport.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = SimulatorSupport.xcconfig; path = AppleInternal/XcodeConfig/SimulatorSupport.xcconfig; sourceTree = DEVELOPER_DIR; }; 15FD72970754DA2B001CC321 /* InterfaceNamer.bundle */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = InterfaceNamer.bundle; sourceTree = BUILT_PRODUCTS_DIR; }; 15FD72A50754DA4C001CC321 /* IPMonitor.bundle */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = IPMonitor.bundle; sourceTree = BUILT_PRODUCTS_DIR; }; 15FD72B50754DA69001CC321 /* LinkConfiguration.bundle */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = LinkConfiguration.bundle; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -1894,8 +1834,15 @@ 23C1E2B8062DD45900835B54 /* pppcontroller.defs */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.mig; name = pppcontroller.defs; path = SystemConfiguration.fproj/pppcontroller.defs; sourceTree = ""; }; 23C1E2BE062DD5DB00835B54 /* pppcontroller.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = pppcontroller.h; path = configd.build/SystemConfiguration.framework.build/DerivedSources/pppcontroller.h; sourceTree = BUILT_PRODUCTS_DIR; }; 55A3DB9D183C2A8200ED3DB7 /* SCNetworkMigration.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = SCNetworkMigration.c; sourceTree = ""; }; + 72499BA31AC9B7AB0090C49F /* get-network-info */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = "get-network-info"; sourceTree = SOURCE_ROOT; }; + 725E53D51A92D2A5009997E1 /* com.apple.networking.IPMonitor */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = com.apple.networking.IPMonitor; sourceTree = ""; }; 72B43726113C7BFC00EBF1B6 /* nc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = nc.h; sourceTree = ""; }; 72B43727113C7BFC00EBF1B6 /* nc.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = nc.c; sourceTree = ""; }; + 72D3E6591AE6E8A900DB4C69 /* Modules */ = {isa = PBXFileReference; lastKnownFileType = folder; name = Modules; path = SystemConfiguration.fproj/Modules; sourceTree = SOURCE_ROOT; }; + 72D3E65E1AE6EA3A00DB4C69 /* SCTest-Swift */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = "SCTest-Swift"; sourceTree = BUILT_PRODUCTS_DIR; }; + 72D3E6601AE6EA3A00DB4C69 /* main.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = main.swift; sourceTree = ""; }; + 72D3E6691AE6EAF600DB4C69 /* SCTest-ObjC */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = "SCTest-ObjC"; sourceTree = BUILT_PRODUCTS_DIR; }; + 72D3E66B1AE6EAF600DB4C69 /* test-objC.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "test-objC.m"; sourceTree = ""; }; 9EE943F306AF409B00772EB5 /* BondConfiguration.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = BondConfiguration.c; sourceTree = ""; }; B03FEFB516376D2800A1B88F /* VPNAppLayer.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = VPNAppLayer.c; sourceTree = ""; }; B084710E16385121006C92A3 /* SCNetworkConnectionInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SCNetworkConnectionInternal.h; sourceTree = ""; }; @@ -1903,7 +1850,6 @@ B0C967F717441F0E00889853 /* SNHelperPrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SNHelperPrivate.h; sourceTree = ""; }; B0C9689B174426C200889853 /* SNHelper.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = SNHelper.c; sourceTree = ""; }; C4CDB8111631933400819B44 /* VPNFlow.h */ = {isa = PBXFileReference; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = VPNFlow.h; sourceTree = ""; tabWidth = 4; }; - C4CDB8121631933400819B44 /* VPNFlowPrivate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = VPNFlowPrivate.h; sourceTree = ""; }; C4CDB8141631935700819B44 /* VPNFlow.c */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.c; path = VPNFlow.c; sourceTree = ""; tabWidth = 4; }; C4F1847F16237AFC00D97043 /* VPNService.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = VPNService.c; sourceTree = ""; }; D61AAEAD1522C99C0066B003 /* scprefs_observer.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = scprefs_observer.c; sourceTree = ""; }; @@ -1942,16 +1888,6 @@ ); runOnlyForDeploymentPostprocessing = 0; }; - 1521400B0E93FF8600DACD2C /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - 1521400C0E93FFF500DACD2C /* CoreFoundation.framework in Frameworks */, - 152140580E93FFFC00DACD2C /* SystemConfiguration.framework in Frameworks */, - 15943D440E94081800B87535 /* IOKit.framework in Frameworks */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; 1547001B08455B98006787CE /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; @@ -1982,16 +1918,6 @@ ); runOnlyForDeploymentPostprocessing = 0; }; - 156CA47C0EF853BB00C59A18 /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - 156CA47D0EF853BB00C59A18 /* CoreFoundation.framework in Frameworks */, - 156CA47E0EF853BB00C59A18 /* SystemConfiguration.framework in Frameworks */, - 156CA47F0EF853BB00C59A18 /* IOKit.framework in Frameworks */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; 1572C5230CFB55B400E2776E /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; @@ -2011,7 +1937,6 @@ 15732A9F16EA503200F3AC4C /* Security.framework in Frameworks */, 15732AA016EA503200F3AC4C /* libbsm.dylib in Frameworks */, 15AB752D16EC2AE900FAA8CE /* libIPMonitor_sim.a in Frameworks */, - 15AB752E16EC2AE900FAA8CE /* libSCNetworkReachability_sim.a in Frameworks */, 15D3083316F3EB0700014F82 /* libSimulatorSupport_sim.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; @@ -2074,7 +1999,6 @@ 158317540CFB80A1006F62B9 /* libIPMonitor.a in Frameworks */, 158317550CFB80A1006F62B9 /* libLinkConfiguration.a in Frameworks */, 158317570CFB80A1006F62B9 /* libPreferencesMonitor.a in Frameworks */, - 1528C0171357465900691881 /* libSCNetworkReachability.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -2104,7 +2028,6 @@ 159D54D107529FFF004F8947 /* libIPMonitor.a in Frameworks */, 159D54D207529FFF004F8947 /* libLinkConfiguration.a in Frameworks */, 159D54D307529FFF004F8947 /* libPreferencesMonitor.a in Frameworks */, - 1528C019135746BB00691881 /* libSCNetworkReachability.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -2134,6 +2057,20 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + 72D3E65B1AE6EA3900DB4C69 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 72D3E6661AE6EAF600DB4C69 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ @@ -2147,25 +2084,6 @@ name = SCMonitor; sourceTree = ""; }; - 1528BFDA13572FC200691881 /* SCNetworkReachability */ = { - isa = PBXGroup; - children = ( - 1528BFE91357312E00691881 /* Info.plist */, - 15FBB54F17D789B50035D752 /* Info-EmbeddedSimulator.plist */, - ); - name = SCNetworkReachability; - sourceTree = ""; - }; - 1531D3D90E93E6AA00248432 /* Logger */ = { - isa = PBXGroup; - children = ( - 1531D3DB0E93E6DA00248432 /* logger.c */, - 1531D3DA0E93E6DA00248432 /* Info.plist */, - 156CA48D0EF853BB00C59A18 /* Info-Embedded.plist */, - ); - name = Logger; - sourceTree = ""; - }; 154083530D5B824400E07907 /* MacOSX */ = { isa = PBXGroup; children = ( @@ -2212,11 +2130,8 @@ 1559C4520D349A4E0098FD59 /* KernelEventMonitor.bundle */, 157A852E0D56C91100B6F1A0 /* libLinkConfiguration.a */, 1559C4530D349A4E0098FD59 /* LinkConfiguration.bundle */, - 156CA4850EF853BB00C59A18 /* Logger.bundle */, 157A85440D56C96F00B6F1A0 /* libPreferencesMonitor.a */, 1559C4540D349A4E0098FD59 /* PreferencesMonitor.bundle */, - 1528BFF713573FEE00691881 /* libSCNetworkReachability.a */, - 1528BFFE13573FF500691881 /* SCNetworkReachability.bundle */, ); name = Plugins; sourceTree = ""; @@ -2315,11 +2230,8 @@ 15828AE70753B5F900AD4710 /* KernelEventMonitor.bundle */, 159D53F307528C79004F8947 /* libLinkConfiguration.a */, 15FD72B50754DA69001CC321 /* LinkConfiguration.bundle */, - 15213FFA0E93E9F500DACD2C /* Logger.bundle */, 159D53FA07528C95004F8947 /* libPreferencesMonitor.a */, 15FD72C90754DA7E001CC321 /* PreferencesMonitor.bundle */, - 1528BFE21357305400691881 /* libSCNetworkReachability.a */, - 1528BFE81357309800691881 /* SCNetworkReachability.bundle */, ); name = Plugins; sourceTree = ""; @@ -2342,9 +2254,7 @@ 159D53AC07528B36004F8947 /* InterfaceNamer */, 159D53AF07528B36004F8947 /* KernelEventMonitor */, 159D53C007528B36004F8947 /* LinkConfiguration */, - 1531D3D90E93E6AA00248432 /* Logger */, 159D53C207528B36004F8947 /* PreferencesMonitor */, - 1528BFDA13572FC200691881 /* SCNetworkReachability */, 15D3080E16F3E49F00014F82 /* SimulatorSupport */, ); name = Plugins; @@ -2353,6 +2263,7 @@ 159D53A607528B36004F8947 /* IPMonitor */ = { isa = PBXGroup; children = ( + 725E53D41A92D289009997E1 /* Simulator */, D6AEB89815AE4446009F2FAF /* ip_plugin.h */, 159D53A707528B36004F8947 /* ip_plugin.c */, 155D22380AF13A7300D52ED0 /* dns-configuration.h */, @@ -2454,6 +2365,7 @@ 1577253606EFBF3100D7B52B /* NetworkInterface.strings */, 15CFC229068B222F00123568 /* get-mobility-info */, 153393E20D34994100FE74E7 /* update-headers */, + 72499BA31AC9B7AB0090C49F /* get-network-info */, ); name = "Supporting Files"; sourceTree = ""; @@ -2481,8 +2393,6 @@ children = ( 15CB69A205C0722B0099E85F /* SCNetwork.c */, 15CB69A605C0722B0099E85F /* SCNetworkReachability.c */, - 15C330B7134B92780028E36B /* SCNetworkReachabilityServer_client.c */, - 15C330BB134B92780028E36B /* SCNetworkReachabilityServer_server.c */, ); name = Sources; sourceTree = ""; @@ -2640,10 +2550,10 @@ 15C330E0134B9C4C0028E36B /* Headers */ = { isa = PBXGroup; children = ( + 23C1E2BE062DD5DB00835B54 /* pppcontroller.h */, B084710E16385121006C92A3 /* SCNetworkConnectionInternal.h */, 15CB693505C0722B0099E85F /* SCNetworkConnection.h */, 15A2972E0A13C08C009879B3 /* SCNetworkConnectionPrivate.h */, - 23C1E2BE062DD5DB00835B54 /* pppcontroller.h */, ); name = Headers; sourceTree = ""; @@ -2676,7 +2586,6 @@ B0C967F717441F0E00889853 /* SNHelperPrivate.h */, B0A88CA616397A1200A60B3A /* VPNAppLayerPrivate.h */, C4CDB8111631933400819B44 /* VPNFlow.h */, - C4CDB8121631933400819B44 /* VPNFlowPrivate.h */, 159A7513107FEAA400A57EAB /* VPNPrivate.h */, 159A7515107FEAA400A57EAB /* VPNConfiguration.h */, 15AAA7F2108E310700C2A607 /* VPNTunnel.h */, @@ -2699,8 +2608,9 @@ 159D53A207528B06004F8947 /* Plugins */, F9B7AE5B1862116500C78D18 /* IPMonitorControl */, 15CB6A6E05C0722B0099E85F /* External Frameworks and Libraries */, + 72D3E65F1AE6EA3A00DB4C69 /* SCTest-Swift */, + 72D3E66A1AE6EAF600DB4C69 /* SCTest-ObjC */, 15CB690F05C0722B0099E85F /* Products */, - 15FD147B0D594FE700F9409C /* SimulatorSupport.xcconfig */, ); indentWidth = 8; name = configd; @@ -2711,6 +2621,7 @@ 15CB690705C0722A0099E85F /* SystemConfiguration */ = { isa = PBXGroup; children = ( + 72D3E6591AE6E8A900DB4C69 /* Modules */, 15C330D5134B99EF0028E36B /* SCDynamicStore */, 15C330D8134B9A730028E36B /* SCPreferences */, 1547002E084561B4006787CE /* SCHelper */, @@ -2735,13 +2646,13 @@ 154083890D5B82A900E07907 /* EmbeddedSimulator */, 15732AAC16EA503300F3AC4C /* configd_sim */, 15732AD516EA511900F3AC4C /* scutil_sim */, - 15732AE416EA6B6700F3AC4C /* libsystem_sim_configuration.dylib */, + 15732AE416EA6B6700F3AC4C /* libsystem_configuration.dylib */, 15E1B05916EBAE3C00E5F06F /* libIPMonitor_sim.a */, 15E1B06116EBAE7800E5F06F /* IPMonitor.bundle */, - 15AB751916EBFF3400FAA8CE /* libSCNetworkReachability_sim.a */, - 15AB751F16EBFF8A00FAA8CE /* SCNetworkReachability.bundle */, 15D3082716F3E4DA00014F82 /* libSimulatorSupport_sim.a */, 15D3082D16F3E4E100014F82 /* SimulatorSupport.bundle */, + 72D3E65E1AE6EA3A00DB4C69 /* SCTest-Swift */, + 72D3E6691AE6EAF600DB4C69 /* SCTest-ObjC */, ); name = Products; sourceTree = ""; @@ -3005,6 +2916,30 @@ name = "Supporting Files"; sourceTree = ""; }; + 725E53D41A92D289009997E1 /* Simulator */ = { + isa = PBXGroup; + children = ( + 725E53D51A92D2A5009997E1 /* com.apple.networking.IPMonitor */, + ); + path = Simulator; + sourceTree = ""; + }; + 72D3E65F1AE6EA3A00DB4C69 /* SCTest-Swift */ = { + isa = PBXGroup; + children = ( + 72D3E6601AE6EA3A00DB4C69 /* main.swift */, + ); + path = "SCTest-Swift"; + sourceTree = ""; + }; + 72D3E66A1AE6EAF600DB4C69 /* SCTest-ObjC */ = { + isa = PBXGroup; + children = ( + 72D3E66B1AE6EAF600DB4C69 /* test-objC.m */, + ); + path = "SCTest-ObjC"; + sourceTree = ""; + }; D6986A70136890B60091C931 /* NetworkInformation */ = { isa = PBXGroup; children = ( @@ -3052,20 +2987,6 @@ /* End PBXGroup section */ /* Begin PBXHeadersBuildPhase section */ - 1528BFDC1357305400691881 /* Headers */ = { - isa = PBXHeadersBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 1528BFF113573FEE00691881 /* Headers */ = { - isa = PBXHeadersBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; 1547001908455B98006787CE /* Headers */ = { isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; @@ -3107,6 +3028,9 @@ isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; files = ( + 1572C4CB0CFB55B400E2776E /* pppcontroller.h in Headers */, + 1572C4CA0CFB55B400E2776E /* pppcontroller_types.h in Headers */, + 1572C581171CD00E00870549 /* pppcontroller_mach_defines.h in Headers */, 1572C4A90CFB55B400E2776E /* SCSchemaDefinitions.h in Headers */, 1572C4AA0CFB55B400E2776E /* SystemConfiguration.h in Headers */, 1572C4AB0CFB55B400E2776E /* SCPrivate.h in Headers */, @@ -3134,12 +3058,9 @@ 1572C4C00CFB55B400E2776E /* SCDynamicStoreCopyDHCPInfo.h in Headers */, 1572C4C10CFB55B400E2776E /* moh_msg.h in Headers */, 1572C4C20CFB55B400E2776E /* moh.h in Headers */, - C4CDB81A163193AF00819B44 /* VPNFlowPrivate.h in Headers */, 1572C4C30CFB55B400E2776E /* DeviceOnHold.h in Headers */, 1572C4C50CFB55B400E2776E /* dy_framework.h in Headers */, 1572C4C70CFB55B400E2776E /* SCPreferencesPathKey.h in Headers */, - 1572C4CA0CFB55B400E2776E /* pppcontroller_types.h in Headers */, - 1572C581171CD00E00870549 /* pppcontroller_mach_defines.h in Headers */, 1572C4CE0CFB55B400E2776E /* SCPreferencesSetSpecificPrivate.h in Headers */, C4CDB819163193AA00819B44 /* VPNFlow.h in Headers */, 1572C4CF0CFB55B400E2776E /* SCPreferencesGetSpecificPrivate.h in Headers */, @@ -3163,7 +3084,6 @@ 15C330D2134B95AA0028E36B /* SCNetworkReachabilityInternal.h in Headers */, 15D8B22B1450D8450090CECF /* SCD.h in Headers */, B084711016385121006C92A3 /* SCNetworkConnectionInternal.h in Headers */, - 1572C4CB0CFB55B400E2776E /* pppcontroller.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -3396,8 +3316,10 @@ isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; files = ( + 15A5A2090D5B94190087BDA0 /* pppcontroller.h in Headers */, + 15A5A2080D5B94190087BDA0 /* pppcontroller_types.h in Headers */, + 1572C57F171CCFE200870549 /* pppcontroller_mach_defines.h in Headers */, 15A5A1E70D5B94190087BDA0 /* SCSchemaDefinitions.h in Headers */, - 727AF256191386CB009AB153 /* VPNFlowPrivate.h in Headers */, 15A5A1E80D5B94190087BDA0 /* SystemConfiguration.h in Headers */, 15A5A1E90D5B94190087BDA0 /* SCPrivate.h in Headers */, 15A5A1EA0D5B94190087BDA0 /* SCDPlugin.h in Headers */, @@ -3431,8 +3353,6 @@ 15A5A2050D5B94190087BDA0 /* SCPreferencesPathKey.h in Headers */, 15A5A2060D5B94190087BDA0 /* dnsinfo.h in Headers */, 15A5A2070D5B94190087BDA0 /* dnsinfo_private.h in Headers */, - 15A5A2080D5B94190087BDA0 /* pppcontroller_types.h in Headers */, - 1572C57F171CCFE200870549 /* pppcontroller_mach_defines.h in Headers */, 15A5A20C0D5B94190087BDA0 /* SCPreferencesSetSpecificPrivate.h in Headers */, 15A5A20D0D5B94190087BDA0 /* SCPreferencesGetSpecificPrivate.h in Headers */, 727AF255191386A0009AB153 /* VPNFlow.h in Headers */, @@ -3449,14 +3369,6 @@ 15C330D3134B95AA0028E36B /* SCNetworkReachabilityInternal.h in Headers */, 727AF25419138699009AB153 /* VPNAppLayerPrivate.h in Headers */, 15D8B22C1450D8450090CECF /* SCD.h in Headers */, - 15A5A2090D5B94190087BDA0 /* pppcontroller.h in Headers */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 15AB751316EBFF3400FAA8CE /* Headers */ = { - isa = PBXHeadersBuildPhase; - buildActionMask = 2147483647; - files = ( ); runOnlyForDeploymentPostprocessing = 0; }; @@ -3483,6 +3395,9 @@ isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; files = ( + 15DAD66507591A1A0084A6ED /* pppcontroller.h in Headers */, + 1572C580171CCFF000870549 /* pppcontroller_mach_defines.h in Headers */, + 15DAD66407591A1A0084A6ED /* pppcontroller_types.h in Headers */, 1506081A075A00A300B147BA /* SCSchemaDefinitions.h in Headers */, 15DAD64307591A1A0084A6ED /* SystemConfiguration.h in Headers */, 15DAD64407591A1A0084A6ED /* SCPrivate.h in Headers */, @@ -3515,11 +3430,8 @@ 15DAD65A07591A1A0084A6ED /* moh_msg.h in Headers */, 15DAD65B07591A1A0084A6ED /* moh.h in Headers */, 15DAD65C07591A1A0084A6ED /* DeviceOnHold.h in Headers */, - C4CDB8181631938400819B44 /* VPNFlowPrivate.h in Headers */, 15DAD65E07591A1A0084A6ED /* dy_framework.h in Headers */, 15DAD66107591A1A0084A6ED /* SCPreferencesPathKey.h in Headers */, - 15DAD66407591A1A0084A6ED /* pppcontroller_types.h in Headers */, - 1572C580171CCFF000870549 /* pppcontroller_mach_defines.h in Headers */, B0A88CA716397A1200A60B3A /* VPNAppLayerPrivate.h in Headers */, 156BD6BC07E0DFA9008698FF /* SCPreferencesSetSpecificPrivate.h in Headers */, 154CF3F407E1EA4D00D8302E /* SCPreferencesGetSpecificPrivate.h in Headers */, @@ -3539,7 +3451,6 @@ 15AAA7F7108E310700C2A607 /* VPNTunnelPrivate.h in Headers */, 15C330D1134B95AA0028E36B /* SCNetworkReachabilityInternal.h in Headers */, B084710F16385121006C92A3 /* SCNetworkConnectionInternal.h in Headers */, - 15DAD66507591A1A0084A6ED /* pppcontroller.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -3592,87 +3503,6 @@ productReference = 151F63EC09328A3C0096DCC9 /* genSCPreferences */; productType = "com.apple.product-type.tool"; }; - 15213FF90E93E9F500DACD2C /* Logger.bundle */ = { - isa = PBXNativeTarget; - buildConfigurationList = 15213FFF0E93E9F600DACD2C /* Build configuration list for PBXNativeTarget "Logger.bundle" */; - buildPhases = ( - 15213FF70E93E9F500DACD2C /* Sources */, - 1521400B0E93FF8600DACD2C /* Frameworks */, - 15213FF60E93E9F500DACD2C /* Resources */, - ); - buildRules = ( - ); - dependencies = ( - ); - name = Logger.bundle; - productName = Logger.bundle; - productReference = 15213FFA0E93E9F500DACD2C /* Logger.bundle */; - productType = "com.apple.product-type.bundle"; - }; - 1528BFDB1357305400691881 /* SCNetworkReachability */ = { - isa = PBXNativeTarget; - buildConfigurationList = 1528BFDF1357305400691881 /* Build configuration list for PBXNativeTarget "SCNetworkReachability" */; - buildPhases = ( - 1528BFDC1357305400691881 /* Headers */, - 1528BFDD1357305400691881 /* Sources */, - ); - buildRules = ( - ); - dependencies = ( - ); - name = SCNetworkReachability; - productName = PreferencesMonitor; - productReference = 1528BFE21357305400691881 /* libSCNetworkReachability.a */; - productType = "com.apple.product-type.library.static"; - }; - 1528BFE31357309700691881 /* SCNetworkReachability.bundle */ = { - isa = PBXNativeTarget; - buildConfigurationList = 1528BFE51357309700691881 /* Build configuration list for PBXNativeTarget "SCNetworkReachability.bundle" */; - buildPhases = ( - 1528BFE41357309700691881 /* Resources */, - ); - buildRules = ( - ); - dependencies = ( - ); - name = SCNetworkReachability.bundle; - productInstallPath = "$(USER_LIBRARY_DIR)/Bundles"; - productName = PreferencesMonitor.bundle; - productReference = 1528BFE81357309800691881 /* SCNetworkReachability.bundle */; - productType = "com.apple.product-type.bundle"; - }; - 1528BFF013573FEE00691881 /* SCNetworkReachability-Embedded */ = { - isa = PBXNativeTarget; - buildConfigurationList = 1528BFF413573FEE00691881 /* Build configuration list for PBXNativeTarget "SCNetworkReachability-Embedded" */; - buildPhases = ( - 1528BFF113573FEE00691881 /* Headers */, - 1528BFF213573FEE00691881 /* Sources */, - ); - buildRules = ( - ); - dependencies = ( - ); - name = "SCNetworkReachability-Embedded"; - productName = PreferencesMonitor; - productReference = 1528BFF713573FEE00691881 /* libSCNetworkReachability.a */; - productType = "com.apple.product-type.library.static"; - }; - 1528BFF813573FF500691881 /* SCNetworkReachability.bundle-Embedded */ = { - isa = PBXNativeTarget; - buildConfigurationList = 1528BFFB13573FF500691881 /* Build configuration list for PBXNativeTarget "SCNetworkReachability.bundle-Embedded" */; - buildPhases = ( - 1528BFF913573FF500691881 /* Resources */, - ); - buildRules = ( - ); - dependencies = ( - ); - name = "SCNetworkReachability.bundle-Embedded"; - productInstallPath = "$(USER_LIBRARY_DIR)/Bundles"; - productName = PreferencesMonitor.bundle; - productReference = 1528BFFE13573FF500691881 /* SCNetworkReachability.bundle */; - productType = "com.apple.product-type.bundle"; - }; 1547001808455B98006787CE /* SCHelper */ = { isa = PBXNativeTarget; buildConfigurationList = 156EB5E20905594A00EEF749 /* Build configuration list for PBXNativeTarget "SCHelper" */; @@ -3730,23 +3560,6 @@ productReference = 1558481D07550EC10046C2E9 /* scselect */; productType = "com.apple.product-type.tool"; }; - 156CA4790EF853BB00C59A18 /* Logger.bundle-Embedded */ = { - isa = PBXNativeTarget; - buildConfigurationList = 156CA4820EF853BB00C59A18 /* Build configuration list for PBXNativeTarget "Logger.bundle-Embedded" */; - buildPhases = ( - 156CA47A0EF853BB00C59A18 /* Sources */, - 156CA47C0EF853BB00C59A18 /* Frameworks */, - 156CA4810EF853BB00C59A18 /* Resources */, - ); - buildRules = ( - ); - dependencies = ( - ); - name = "Logger.bundle-Embedded"; - productName = Logger.bundle; - productReference = 156CA4850EF853BB00C59A18 /* Logger.bundle */; - productType = "com.apple.product-type.bundle"; - }; 1572C4A60CFB55B400E2776E /* SystemConfiguration.framework-Embedded */ = { isa = PBXNativeTarget; buildConfigurationList = 1572C5290CFB55B400E2776E /* Build configuration list for PBXNativeTarget "SystemConfiguration.framework-Embedded" */; @@ -3757,6 +3570,7 @@ 1572C4DE0CFB55B400E2776E /* Sources */, 1572C5230CFB55B400E2776E /* Frameworks */, 1572C5270CFB55B400E2776E /* get-mobility-info */, + 1510A7301B17E1AF00125A85 /* Add framework symlink (TEMPORARY) */, ); buildRules = ( ); @@ -3782,7 +3596,6 @@ ); dependencies = ( 15AB752A16EC254D00FAA8CE /* PBXTargetDependency */, - 15AB752C16EC254D00FAA8CE /* PBXTargetDependency */, 15D3083516F3EB2500014F82 /* PBXTargetDependency */, ); name = "configd-EmbeddedSimulator"; @@ -3824,7 +3637,7 @@ name = "libsystem_configuration-EmbeddedSimulator"; productInstallPath = /usr/local/lib/system; productName = DNSConfiguration; - productReference = 15732AE416EA6B6700F3AC4C /* libsystem_sim_configuration.dylib */; + productReference = 15732AE416EA6B6700F3AC4C /* libsystem_configuration.dylib */; productType = "com.apple.product-type.library.dynamic"; }; 157433DD0D4A8122002ACA73 /* scselect-Embedded */ = { @@ -4084,6 +3897,7 @@ 1583379D0CFB6B9E0033AB93 /* Sources */, 1583379F0CFB6B9E0033AB93 /* Frameworks */, 158337A40CFB6B9E0033AB93 /* CopyFiles */, + 1595B4B81B0C02FA0087944E /* Update SCHelper launchd .plist */, ); buildRules = ( ); @@ -4205,6 +4019,7 @@ 15A5A2180D5B94190087BDA0 /* Resources */, 15A5A21D0D5B94190087BDA0 /* Sources */, 15A5A2620D5B94190087BDA0 /* Frameworks */, + 1535FEDC1B0FDDCD00B2A3AD /* Add framework symlink (TEMPORARY) */, ); buildRules = ( ); @@ -4216,38 +4031,6 @@ productReference = 15A5A26A0D5B94190087BDA0 /* SystemConfiguration.framework */; productType = "com.apple.product-type.framework"; }; - 15AB751216EBFF3400FAA8CE /* SCNetworkReachability-EmbeddedSimulator */ = { - isa = PBXNativeTarget; - buildConfigurationList = 15AB751616EBFF3400FAA8CE /* Build configuration list for PBXNativeTarget "SCNetworkReachability-EmbeddedSimulator" */; - buildPhases = ( - 15AB751316EBFF3400FAA8CE /* Headers */, - 15AB751416EBFF3400FAA8CE /* Sources */, - ); - buildRules = ( - ); - dependencies = ( - ); - name = "SCNetworkReachability-EmbeddedSimulator"; - productName = PreferencesMonitor; - productReference = 15AB751916EBFF3400FAA8CE /* libSCNetworkReachability_sim.a */; - productType = "com.apple.product-type.library.static"; - }; - 15AB751A16EBFF8A00FAA8CE /* SCNetworkReachability.bundle-EmbeddedSimulator */ = { - isa = PBXNativeTarget; - buildConfigurationList = 15AB751C16EBFF8A00FAA8CE /* Build configuration list for PBXNativeTarget "SCNetworkReachability.bundle-EmbeddedSimulator" */; - buildPhases = ( - 15AB751B16EBFF8A00FAA8CE /* Resources */, - ); - buildRules = ( - ); - dependencies = ( - ); - name = "SCNetworkReachability.bundle-EmbeddedSimulator"; - productInstallPath = "$(USER_LIBRARY_DIR)/Bundles"; - productName = PreferencesMonitor.bundle; - productReference = 15AB751F16EBFF8A00FAA8CE /* SCNetworkReachability.bundle */; - productType = "com.apple.product-type.bundle"; - }; 15D3080F16F3E4DA00014F82 /* SimulatorSupport-EmbeddedSimulator */ = { isa = PBXNativeTarget; buildConfigurationList = 15D3082416F3E4DA00014F82 /* Build configuration list for PBXNativeTarget "SimulatorSupport-EmbeddedSimulator" */; @@ -4342,6 +4125,7 @@ buildConfigurationList = 15E1B05E16EBAE7800E5F06F /* Build configuration list for PBXNativeTarget "IPMonitor.bundle-EmbeddedSimulator" */; buildPhases = ( 15E1B05B16EBAE7800E5F06F /* Resources */, + 72AD314B1A843C1000D2226E /* com.apple.networking.IPMonitor */, ); buildRules = ( ); @@ -4418,21 +4202,65 @@ productReference = 15FD72C90754DA7E001CC321 /* PreferencesMonitor.bundle */; productType = "com.apple.product-type.bundle"; }; -/* End PBXNativeTarget section */ - -/* Begin PBXProject section */ - 15CB6A7705C0722B0099E85F /* Project object */ = { - isa = PBXProject; - attributes = { - LastUpgradeCheck = 0600; - }; - buildConfigurationList = 156EB63E0905594A00EEF749 /* Build configuration list for PBXProject "configd" */; - compatibilityVersion = "Xcode 3.2"; - developmentRegion = English; - hasScannedForEncodings = 1; - knownRegions = ( - English, - Japanese, + 72D3E65D1AE6EA3900DB4C69 /* SCTest-Swift */ = { + isa = PBXNativeTarget; + buildConfigurationList = 72D3E6621AE6EA3A00DB4C69 /* Build configuration list for PBXNativeTarget "SCTest-Swift" */; + buildPhases = ( + 72D3E65A1AE6EA3900DB4C69 /* Sources */, + 72D3E65B1AE6EA3900DB4C69 /* Frameworks */, + 72D3E65C1AE6EA3900DB4C69 /* CopyFiles */, + ); + buildRules = ( + ); + dependencies = ( + 723050321AE6F292004AC149 /* PBXTargetDependency */, + ); + name = "SCTest-Swift"; + productName = "SCTest-Swift"; + productReference = 72D3E65E1AE6EA3A00DB4C69 /* SCTest-Swift */; + productType = "com.apple.product-type.tool"; + }; + 72D3E6681AE6EAF600DB4C69 /* SCTest-ObjC */ = { + isa = PBXNativeTarget; + buildConfigurationList = 72D3E66D1AE6EAF600DB4C69 /* Build configuration list for PBXNativeTarget "SCTest-ObjC" */; + buildPhases = ( + 72D3E6651AE6EAF600DB4C69 /* Sources */, + 72D3E6661AE6EAF600DB4C69 /* Frameworks */, + 72D3E6671AE6EAF600DB4C69 /* CopyFiles */, + ); + buildRules = ( + ); + dependencies = ( + 723050341AE6F29D004AC149 /* PBXTargetDependency */, + ); + name = "SCTest-ObjC"; + productName = "SCTest-ObjC"; + productReference = 72D3E6691AE6EAF600DB4C69 /* SCTest-ObjC */; + productType = "com.apple.product-type.tool"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 15CB6A7705C0722B0099E85F /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 0700; + TargetAttributes = { + 72D3E65D1AE6EA3900DB4C69 = { + CreatedOnToolsVersion = 7.0; + }; + 72D3E6681AE6EAF600DB4C69 = { + CreatedOnToolsVersion = 7.0; + }; + }; + }; + buildConfigurationList = 156EB63E0905594A00EEF749 /* Build configuration list for PBXProject "configd" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = English; + hasScannedForEncodings = 1; + knownRegions = ( + English, + Japanese, French, German, ); @@ -4456,11 +4284,8 @@ 15828AE60753B5F900AD4710 /* KernelEventMonitor.bundle */, 159D53F207528C79004F8947 /* LinkConfiguration */, 15FD72B10754DA69001CC321 /* LinkConfiguration.bundle */, - 15213FF90E93E9F500DACD2C /* Logger.bundle */, 159D53F907528C95004F8947 /* PreferencesMonitor */, 15FD72C50754DA7E001CC321 /* PreferencesMonitor.bundle */, - 1528BFDB1357305400691881 /* SCNetworkReachability */, - 1528BFE31357309700691881 /* SCNetworkReachability.bundle */, 155847FA07550D210046C2E9 /* configd_executables */, 159D549F07529FFF004F8947 /* configd */, 1558481207550EC10046C2E9 /* scselect */, @@ -4481,11 +4306,8 @@ 158317900CFB85F7006F62B9 /* KernelEventMonitor.bundle-Embedded */, 157A85260D56C91100B6F1A0 /* LinkConfiguration-Embedded */, 158317980CFB860C006F62B9 /* LinkConfiguration.bundle-Embedded */, - 156CA4790EF853BB00C59A18 /* Logger.bundle-Embedded */, 157A853C0D56C96F00B6F1A0 /* PreferencesMonitor-Embedded */, 158317A80CFB8639006F62B9 /* PreferencesMonitor.bundle-Embedded */, - 1528BFF013573FEE00691881 /* SCNetworkReachability-Embedded */, - 1528BFF813573FF500691881 /* SCNetworkReachability.bundle-Embedded */, 158317040CFB7782006F62B9 /* configd_executables-Embedded */, 158317230CFB80A1006F62B9 /* configd-Embedded */, 157433DD0D4A8122002ACA73 /* scselect-Embedded */, @@ -4497,14 +4319,14 @@ 15A5A1E40D5B94190087BDA0 /* SystemConfiguration.framework-EmbeddedSimulator */, 15E1B04116EBAE3C00E5F06F /* IPMonitor-EmbeddedSimulator */, 15E1B05A16EBAE7800E5F06F /* IPMonitor.bundle-EmbeddedSimulator */, - 15AB751216EBFF3400FAA8CE /* SCNetworkReachability-EmbeddedSimulator */, - 15AB751A16EBFF8A00FAA8CE /* SCNetworkReachability.bundle-EmbeddedSimulator */, 15D3080F16F3E4DA00014F82 /* SimulatorSupport-EmbeddedSimulator */, 15D3082816F3E4E100014F82 /* SimulatorSupport.bundle-EmbeddedSimulator */, 15732A7616EA503200F3AC4C /* configd-EmbeddedSimulator */, 15732AAD16EA511900F3AC4C /* scutil-EmbeddedSimulator */, 151F63DA09328A3C0096DCC9 /* Schema */, 15E83104167F9AF600FD51EC /* EVERYTHING */, + 72D3E65D1AE6EA3900DB4C69 /* SCTest-Swift */, + 72D3E6681AE6EAF600DB4C69 /* SCTest-ObjC */, ); }; /* End PBXProject section */ @@ -4518,40 +4340,13 @@ ); runOnlyForDeploymentPostprocessing = 0; }; - 15213FF60E93E9F500DACD2C /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 1528BFE41357309700691881 /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 1528BFF913573FF500691881 /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 156CA4810EF853BB00C59A18 /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; 1572C4D90CFB55B400E2776E /* Resources */ = { isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( 1572C4DA0CFB55B400E2776E /* Localizable.strings in Resources */, 1572C4DB0CFB55B400E2776E /* NetworkInterface.strings in Resources */, + 72499BA51AC9B7AB0090C49F /* get-network-info in Resources */, 1572C4DC0CFB55B400E2776E /* NetworkConfiguration.plist in Resources */, 1572C4DD0CFB55B400E2776E /* get-mobility-info in Resources */, ); @@ -4609,13 +4404,6 @@ ); runOnlyForDeploymentPostprocessing = 0; }; - 15AB751B16EBFF8A00FAA8CE /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; 15D3082916F3E4E100014F82 /* Resources */ = { isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; @@ -4629,6 +4417,7 @@ files = ( 15A6F7C40A4B266D00B907EA /* Localizable.strings in Resources */, 15DAD66B07591A1A0084A6ED /* NetworkInterface.strings in Resources */, + 72499BA41AC9B7AB0090C49F /* get-network-info in Resources */, 15DAD66907591A1A0084A6ED /* NetworkConfiguration.plist in Resources */, 15DAD66A07591A1A0084A6ED /* get-mobility-info in Resources */, ); @@ -4672,6 +4461,21 @@ /* End PBXResourcesBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */ + 1510A7301B17E1AF00125A85 /* Add framework symlink (TEMPORARY) */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "Add framework symlink (TEMPORARY)"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "if [ \"${USING_PRIVATE_SYSTEMCONFIGURATION_FRAMEWORK}\" = \"YES\" ]; then\n mkdir -p ${INSTALL_ROOT}/System/Library/Frameworks\n cd ${INSTALL_ROOT}/System/Library/Frameworks\n rm -rf SystemConfiguration.framework\n ln -s ../PrivateFrameworks/SystemConfiguration.framework .\nfi"; + showEnvVarsInLog = 0; + }; 151F63DB09328A3C0096DCC9 /* ShellScript */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; @@ -4705,6 +4509,21 @@ shellScript = "if [ -x ${SCRIPT_INPUT_FILE_0} ]; then\n\t${SCRIPT_INPUT_FILE_0} split\nfi"; showEnvVarsInLog = 0; }; + 1535FEDC1B0FDDCD00B2A3AD /* Add framework symlink (TEMPORARY) */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "Add framework symlink (TEMPORARY)"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "if [ \"${USING_PRIVATE_SYSTEMCONFIGURATION_FRAMEWORK}\" = \"YES\" ]; then\n mkdir -p ${INSTALL_ROOT}/System/Library/Frameworks\n cd ${INSTALL_ROOT}/System/Library/Frameworks\n rm -rf SystemConfiguration.framework\n ln -s ../PrivateFrameworks/SystemConfiguration.framework .\nfi"; + showEnvVarsInLog = 0; + }; 1572C5270CFB55B400E2776E /* get-mobility-info */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 8; @@ -4720,6 +4539,21 @@ shellScript = "mkdir -p \"${DSTROOT}/usr/local/bin\"\nln -fs \"${INSTALL_PATH}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/get-mobility-info\" \"${DSTROOT}/usr/local/bin/\"\n"; showEnvVarsInLog = 0; }; + 1595B4B81B0C02FA0087944E /* Update SCHelper launchd .plist */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 8; + files = ( + ); + inputPaths = ( + ); + name = "Update SCHelper launchd .plist"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 1; + shellPath = /bin/sh; + shellScript = "SCHELPER_LAUNCHD_PLIST=\"${INSTALL_ROOT}/System/Library/LaunchDaemons/com.apple.SCHelper-embedded.plist\"\n\nif [ -e \"${SCHELPER_LAUNCHD_PLIST}\" ]; then\n /usr/bin/plutil -replace Program -string \"${INSTALL_PATH}/SCHelper\" \"${SCHELPER_LAUNCHD_PLIST}\"\n /usr/bin/plutil -convert binary1 \"${SCHELPER_LAUNCHD_PLIST}\"\nfi"; + showEnvVarsInLog = 0; + }; 15A5A2170D5B94190087BDA0 /* Update Headers */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; @@ -4798,7 +4632,6 @@ runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; shellScript = "if [ -x ${SCRIPT_INPUT_FILE_0} ]; then\n ${SCRIPT_INPUT_FILE_0} com.apple.configd.plist\nfi"; - showEnvVarsInLog = 0; }; 15FBB55117D78B670035D752 /* Update MachServices */ = { isa = PBXShellScriptBuildPhase; @@ -4843,30 +4676,6 @@ ); runOnlyForDeploymentPostprocessing = 0; }; - 15213FF70E93E9F500DACD2C /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 152140020E93EC6500DACD2C /* logger.c in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 1528BFDD1357305400691881 /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 1528BFEF135733F500691881 /* SCNetworkReachabilityServer_server.c in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 1528BFF213573FEE00691881 /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 1528BFF313573FEE00691881 /* SCNetworkReachabilityServer_server.c in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; 1547001A08455B98006787CE /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; @@ -4906,20 +4715,13 @@ ); runOnlyForDeploymentPostprocessing = 0; }; - 156CA47A0EF853BB00C59A18 /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 156CA47B0EF853BB00C59A18 /* logger.c in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; 1572C4DE0CFB55B400E2776E /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - F9347FF7187C796E003D4178 /* IPMonitorControl.c in Sources */, 1572C5140CFB55B400E2776E /* config.defs in Sources */, + 158E595F1107CAE80062081E /* helper.defs in Sources */, + 1572C5090CFB55B400E2776E /* pppcontroller.defs in Sources */, 1572C4DF0CFB55B400E2776E /* SCSchemaDefinitions.c in Sources */, 1572C4E00CFB55B400E2776E /* SCD.c in Sources */, 1572C4E10CFB55B400E2776E /* SCDKeys.c in Sources */, @@ -4958,7 +4760,6 @@ 1572C5060CFB55B400E2776E /* SCDHostName.c in Sources */, 1572C5070CFB55B400E2776E /* SCLocation.c in Sources */, 1572C5080CFB55B400E2776E /* SCNetwork.c in Sources */, - 1572C5090CFB55B400E2776E /* pppcontroller.defs in Sources */, 1572C50A0CFB55B400E2776E /* SCNetworkConnection.c in Sources */, 1572C50B0CFB55B400E2776E /* SCNetworkConnectionPrivate.c in Sources */, 1572C50C0CFB55B400E2776E /* SCNetworkReachability.c in Sources */, @@ -4982,14 +4783,13 @@ 159A751E107FEAA400A57EAB /* VPNPrivate.c in Sources */, 159A7520107FEAA400A57EAB /* VPNConfiguration.c in Sources */, 15AAA7F6108E310700C2A607 /* VPNTunnel.c in Sources */, - 158E595F1107CAE80062081E /* helper.defs in Sources */, 152691DB1129EEA6006BD2D5 /* BridgeConfiguration.c in Sources */, 152691DE1129EEC2006BD2D5 /* VLANConfiguration.c in Sources */, - 15C330BD134B92780028E36B /* SCNetworkReachabilityServer_client.c in Sources */, D61AAEB01522C99C0066B003 /* scprefs_observer.c in Sources */, C4F1848116237AFC00D97043 /* VPNService.c in Sources */, C4CDB8161631935700819B44 /* VPNFlow.c in Sources */, B03FEFB716376D2800A1B88F /* VPNAppLayer.c in Sources */, + F9347FF7187C796E003D4178 /* IPMonitorControl.c in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -4997,6 +4797,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + 15732A9816EA503200F3AC4C /* config.defs in Sources */, 15732A8016EA503200F3AC4C /* configd.m in Sources */, 15732A8116EA503200F3AC4C /* _SCD.c in Sources */, 15732A8216EA503200F3AC4C /* configd_server.c in Sources */, @@ -5021,9 +4822,7 @@ 15732A9516EA503200F3AC4C /* _notifyviasignal.c in Sources */, 15732A9616EA503200F3AC4C /* _notifycancel.c in Sources */, 15732A9716EA503200F3AC4C /* _snapshot.c in Sources */, - 15732A9816EA503200F3AC4C /* config.defs in Sources */, 15732A9916EA503200F3AC4C /* dnsinfo_server.c in Sources */, - 15732A9A16EA503200F3AC4C /* SCNetworkReachabilityServer_server.c in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -5159,6 +4958,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + 158317470CFB80A1006F62B9 /* config.defs in Sources */, 1583172D0CFB80A1006F62B9 /* configd.m in Sources */, 1583172E0CFB80A1006F62B9 /* _SCD.c in Sources */, 1583172F0CFB80A1006F62B9 /* configd_server.c in Sources */, @@ -5183,9 +4983,7 @@ 158317440CFB80A1006F62B9 /* _notifyviasignal.c in Sources */, 158317450CFB80A1006F62B9 /* _notifycancel.c in Sources */, 158317460CFB80A1006F62B9 /* _snapshot.c in Sources */, - 158317470CFB80A1006F62B9 /* config.defs in Sources */, 158317490CFB80A1006F62B9 /* dnsinfo_server.c in Sources */, - 15C330E5134BD2AC0028E36B /* SCNetworkReachabilityServer_server.c in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -5193,8 +4991,8 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 1583379E0CFB6B9E0033AB93 /* SCHelper_server.c in Sources */, 152E0E8010FE820E00E402F2 /* helper.defs in Sources */, + 1583379E0CFB6B9E0033AB93 /* SCHelper_server.c in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -5260,6 +5058,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + 159D54C607529FFF004F8947 /* config.defs in Sources */, 159D54AC07529FFF004F8947 /* configd.m in Sources */, 159D54AD07529FFF004F8947 /* _SCD.c in Sources */, 159D54AE07529FFF004F8947 /* configd_server.c in Sources */, @@ -5284,7 +5083,6 @@ 159D54C307529FFF004F8947 /* _notifyviasignal.c in Sources */, 159D54C407529FFF004F8947 /* _notifycancel.c in Sources */, 159D54C507529FFF004F8947 /* _snapshot.c in Sources */, - 159D54C607529FFF004F8947 /* config.defs in Sources */, 159D54C807529FFF004F8947 /* dnsinfo_server.c in Sources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -5293,6 +5091,9 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + 15A5A2530D5B94190087BDA0 /* config.defs in Sources */, + 158E59611107CAF40062081E /* helper.defs in Sources */, + 15A5A2480D5B94190087BDA0 /* pppcontroller.defs in Sources */, 15A5A21E0D5B94190087BDA0 /* SCSchemaDefinitions.c in Sources */, 15A5A21F0D5B94190087BDA0 /* SCD.c in Sources */, 15A5A2200D5B94190087BDA0 /* SCDKeys.c in Sources */, @@ -5330,7 +5131,6 @@ 15A5A2450D5B94190087BDA0 /* SCDHostName.c in Sources */, 15A5A2460D5B94190087BDA0 /* SCLocation.c in Sources */, 15A5A2470D5B94190087BDA0 /* SCNetwork.c in Sources */, - 15A5A2480D5B94190087BDA0 /* pppcontroller.defs in Sources */, 15A5A2490D5B94190087BDA0 /* SCNetworkConnection.c in Sources */, 15A5A24A0D5B94190087BDA0 /* SCNetworkConnectionPrivate.c in Sources */, 15A5A24B0D5B94190087BDA0 /* SCNetworkReachability.c in Sources */, @@ -5340,7 +5140,6 @@ 15A5A24F0D5B94190087BDA0 /* DeviceOnHold.c in Sources */, 15A5A2500D5B94190087BDA0 /* LinkConfiguration.c in Sources */, 15A5A2510D5B94190087BDA0 /* dy_framework.c in Sources */, - 15A5A2530D5B94190087BDA0 /* config.defs in Sources */, 15A5A2540D5B94190087BDA0 /* SCPreferencesPathKey.c in Sources */, 15A5A2580D5B94190087BDA0 /* SCNetworkConfigurationInternal.c in Sources */, 15A5A2590D5B94190087BDA0 /* SCNetworkInterface.c in Sources */, @@ -5354,10 +5153,9 @@ 15A1FF3510597F17004C9CC9 /* CaptiveNetwork.c in Sources */, 159A752C107FEAA400A57EAB /* VPNPrivate.c in Sources */, 159A752E107FEAA400A57EAB /* VPNConfiguration.c in Sources */, - 158E59611107CAF40062081E /* helper.defs in Sources */, 152691DC1129EEAD006BD2D5 /* BridgeConfiguration.c in Sources */, + C42633891A9E4991009F7AE4 /* VPNFlow.c in Sources */, 152691DF1129EEC8006BD2D5 /* VLANConfiguration.c in Sources */, - 15C330BE134B92780028E36B /* SCNetworkReachabilityServer_client.c in Sources */, D61AAEB21522C99C0066B003 /* scprefs_observer.c in Sources */, C4F1848316237B1400D97043 /* VPNService.c in Sources */, B0FEF41B1644089200174B99 /* VPNAppLayer.c in Sources */, @@ -5365,14 +5163,6 @@ ); runOnlyForDeploymentPostprocessing = 0; }; - 15AB751416EBFF3400FAA8CE /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 15AB751516EBFF3400FAA8CE /* SCNetworkReachabilityServer_server.c in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; 15D3081816F3E4DA00014F82 /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; @@ -5396,6 +5186,9 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + 15DAD6A007591A1A0084A6ED /* config.defs in Sources */, + 158E595E1107CAE40062081E /* helper.defs in Sources */, + 15DAD69607591A1A0084A6ED /* pppcontroller.defs in Sources */, 15060818075A00A300B147BA /* SCSchemaDefinitions.c in Sources */, 15DAD66D07591A1A0084A6ED /* SCD.c in Sources */, 15DAD66E07591A1A0084A6ED /* SCDKeys.c in Sources */, @@ -5437,7 +5230,6 @@ 15DAD69307591A1A0084A6ED /* SCDHostName.c in Sources */, 15DAD69407591A1A0084A6ED /* SCLocation.c in Sources */, 15DAD69507591A1A0084A6ED /* SCNetwork.c in Sources */, - 15DAD69607591A1A0084A6ED /* pppcontroller.defs in Sources */, 15DAD69707591A1A0084A6ED /* SCNetworkConnection.c in Sources */, 15A2972F0A13C08C009879B3 /* SCNetworkConnectionPrivate.c in Sources */, 15DAD69807591A1A0084A6ED /* SCNetworkReachability.c in Sources */, @@ -5448,7 +5240,6 @@ 15DAD69D07591A1A0084A6ED /* LinkConfiguration.c in Sources */, 15DAD69E07591A1A0084A6ED /* dy_framework.c in Sources */, 15DAD69F07591A1A0084A6ED /* VLANConfiguration.c in Sources */, - 15DAD6A007591A1A0084A6ED /* config.defs in Sources */, 15DAD6A207591A1A0084A6ED /* SCPreferencesPathKey.c in Sources */, 15DAD6A607591A1A0084A6ED /* SCNetworkConfigurationInternal.c in Sources */, 15DAD6A707591A1A0084A6ED /* SCNetworkInterface.c in Sources */, @@ -5464,8 +5255,6 @@ 159A7525107FEAA400A57EAB /* VPNPrivate.c in Sources */, 159A7527107FEAA400A57EAB /* VPNConfiguration.c in Sources */, 15AAA7F9108E310700C2A607 /* VPNTunnel.c in Sources */, - 158E595E1107CAE40062081E /* helper.defs in Sources */, - 15C330BC134B92780028E36B /* SCNetworkReachabilityServer_client.c in Sources */, D61AAEAE1522C99C0066B003 /* scprefs_observer.c in Sources */, C4F1848016237AFC00D97043 /* VPNService.c in Sources */, C4CDB8151631935700819B44 /* VPNFlow.c in Sources */, @@ -5490,6 +5279,22 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + 72D3E65A1AE6EA3900DB4C69 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 72D3E6611AE6EA3A00DB4C69 /* main.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 72D3E6651AE6EAF600DB4C69 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 72D3E66C1AE6EAF600DB4C69 /* test-objC.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; /* End PBXSourcesBuildPhase section */ /* Begin PBXTargetDependency section */ @@ -5503,31 +5308,6 @@ target = 151FE2DD0D5B7046000D6DB1 /* configd_base-EmbeddedSimulator */; targetProxy = 151FE3790D5B713C000D6DB1 /* PBXContainerItemProxy */; }; - 1521405B0E9400BF00DACD2C /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 15213FF90E93E9F500DACD2C /* Logger.bundle */; - targetProxy = 1521405A0E9400BF00DACD2C /* PBXContainerItemProxy */; - }; - 1528BFEC135731B800691881 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 1528BFDB1357305400691881 /* SCNetworkReachability */; - targetProxy = 1528BFEB135731B800691881 /* PBXContainerItemProxy */; - }; - 1528BFEE135731B800691881 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 1528BFE31357309700691881 /* SCNetworkReachability.bundle */; - targetProxy = 1528BFED135731B800691881 /* PBXContainerItemProxy */; - }; - 1528C00F135741C300691881 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 1528BFF013573FEE00691881 /* SCNetworkReachability-Embedded */; - targetProxy = 1528C00E135741C300691881 /* PBXContainerItemProxy */; - }; - 1528C011135741C300691881 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 1528BFF813573FF500691881 /* SCNetworkReachability.bundle-Embedded */; - targetProxy = 1528C010135741C300691881 /* PBXContainerItemProxy */; - }; 1558480607550D470046C2E9 /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = 159D549F07529FFF004F8947 /* configd */; @@ -5548,11 +5328,6 @@ target = 155847FA07550D210046C2E9 /* configd_executables */; targetProxy = 1558480E07550DD00046C2E9 /* PBXContainerItemProxy */; }; - 156CA4A80EF8550800C59A18 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 156CA4790EF853BB00C59A18 /* Logger.bundle-Embedded */; - targetProxy = 156CA4A70EF8550800C59A18 /* PBXContainerItemProxy */; - }; 15732AE616EA6BCE00F3AC4C /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = 15732AD616EA6B6700F3AC4C /* libsystem_configuration-EmbeddedSimulator */; @@ -5723,26 +5498,11 @@ target = 15A5A1E40D5B94190087BDA0 /* SystemConfiguration.framework-EmbeddedSimulator */; targetProxy = 15A5A2700D5B942D0087BDA0 /* PBXContainerItemProxy */; }; - 15AB752216EC005A00FAA8CE /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 15AB751216EBFF3400FAA8CE /* SCNetworkReachability-EmbeddedSimulator */; - targetProxy = 15AB752116EC005A00FAA8CE /* PBXContainerItemProxy */; - }; - 15AB752416EC005A00FAA8CE /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 15AB751A16EBFF8A00FAA8CE /* SCNetworkReachability.bundle-EmbeddedSimulator */; - targetProxy = 15AB752316EC005A00FAA8CE /* PBXContainerItemProxy */; - }; 15AB752A16EC254D00FAA8CE /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = 15E1B04116EBAE3C00E5F06F /* IPMonitor-EmbeddedSimulator */; targetProxy = 15AB752916EC254D00FAA8CE /* PBXContainerItemProxy */; }; - 15AB752C16EC254D00FAA8CE /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 15AB751216EBFF3400FAA8CE /* SCNetworkReachability-EmbeddedSimulator */; - targetProxy = 15AB752B16EC254D00FAA8CE /* PBXContainerItemProxy */; - }; 15C64A220F684C4900D78394 /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = 15DAD5DF075913CE0084A6ED /* libsystem_configuration */; @@ -5813,6 +5573,16 @@ target = 15FD13BF0D59485000F9409C /* All-EmbeddedSimulator */; targetProxy = 15E8310C167F9B1200FD51EC /* PBXContainerItemProxy */; }; + 723050321AE6F292004AC149 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 15DAD63F07591A1A0084A6ED /* SystemConfiguration.framework */; + targetProxy = 723050311AE6F292004AC149 /* PBXContainerItemProxy */; + }; + 723050341AE6F29D004AC149 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 15DAD63F07591A1A0084A6ED /* SystemConfiguration.framework */; + targetProxy = 723050331AE6F29D004AC149 /* PBXContainerItemProxy */; + }; D6DDAC3D147A24BC00A2E902 /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = 1547001808455B98006787CE /* SCHelper */; @@ -5851,14 +5621,16 @@ 151C1CC70CFB487000C5AFD6 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { - PRODUCT_NAME = "configd (Aggregate/Embedded)"; + PRODUCT_NAME = configdAggregateEmbedded; + SUPPORTED_PLATFORMS = iphoneos; }; name = Debug; }; 151C1CC80CFB487000C5AFD6 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { - PRODUCT_NAME = "configd (Aggregate/Embedded)"; + PRODUCT_NAME = configdAggregateEmbedded; + SUPPORTED_PLATFORMS = iphoneos; }; name = Release; }; @@ -5870,7 +5642,6 @@ DYLIB_CURRENT_VERSION = "$(RC_ProjectSourceVersion)"; FRAMEWORK_SEARCH_PATHS = "$(SYMROOT)"; INFOPLIST_FILE = SCMonitor/Info.plist; - INSTALL_MODE_FLAG = "a-w,a+rX"; INSTALL_PATH = /System/Library/UserEventPlugins; PRODUCT_NAME = SCMonitor; PROVISIONING_PROFILE = ""; @@ -5886,7 +5657,6 @@ DYLIB_CURRENT_VERSION = "$(RC_ProjectSourceVersion)"; FRAMEWORK_SEARCH_PATHS = "$(SYMROOT)"; INFOPLIST_FILE = SCMonitor/Info.plist; - INSTALL_MODE_FLAG = "a-w,a+rX"; INSTALL_PATH = /System/Library/UserEventPlugins; PRODUCT_NAME = SCMonitor; PROVISIONING_PROFILE = ""; @@ -5924,157 +5694,17 @@ }; 151FE2E50D5B7046000D6DB1 /* Debug */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 15FD147B0D594FE700F9409C /* SimulatorSupport.xcconfig */; buildSettings = { PRODUCT_NAME = "configd_base (EmbeddedSimulator)"; + SUPPORTED_PLATFORMS = iphonesimulator; }; name = Debug; }; 151FE2E60D5B7046000D6DB1 /* Release */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 15FD147B0D594FE700F9409C /* SimulatorSupport.xcconfig */; buildSettings = { PRODUCT_NAME = "configd_base (EmbeddedSimulator)"; - }; - name = Release; - }; - 15213FFC0E93E9F600DACD2C /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - INFOPLIST_FILE = Plugins/Logger/Info.plist; - INSTALL_MODE_FLAG = "a-w,a+rX"; - INSTALL_PATH = "$(SYSTEM_LIBRARY_DIR)/SystemConfiguration"; - PRODUCT_NAME = Logger; - }; - name = Debug; - }; - 15213FFD0E93E9F600DACD2C /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - INFOPLIST_FILE = Plugins/Logger/Info.plist; - INSTALL_MODE_FLAG = "a-w,a+rX"; - INSTALL_PATH = "$(SYSTEM_LIBRARY_DIR)/SystemConfiguration"; - PRODUCT_NAME = Logger; - }; - name = Release; - }; - 1528BFE01357305400691881 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - DEBUG_INFORMATION_FORMAT = dwarf; - INSTALL_MODE_FLAG = "a-w,a+rX"; - INSTALL_PATH = /usr/local/lib/SystemConfiguration; - LIBRARY_STYLE = STATIC; - PRODUCT_NAME = SCNetworkReachability; - STRIP_INSTALLED_PRODUCT = NO; - }; - name = Debug; - }; - 1528BFE11357305400691881 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - DEBUG_INFORMATION_FORMAT = dwarf; - INSTALL_MODE_FLAG = "a-w,a+rX"; - INSTALL_PATH = /usr/local/lib/SystemConfiguration; - LIBRARY_STYLE = STATIC; - PRODUCT_NAME = SCNetworkReachability; - STRIP_INSTALLED_PRODUCT = NO; - }; - name = Release; - }; - 1528BFE61357309700691881 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - INFOPLIST_FILE = Plugins/SCNetworkReachability/Info.plist; - INSTALL_MODE_FLAG = "a-w,a+rX"; - INSTALL_PATH = "$(SYSTEM_LIBRARY_DIR)/SystemConfiguration"; - PRODUCT_NAME = SCNetworkReachability; - }; - name = Debug; - }; - 1528BFE71357309700691881 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - INFOPLIST_FILE = Plugins/SCNetworkReachability/Info.plist; - INSTALL_MODE_FLAG = "a-w,a+rX"; - INSTALL_PATH = "$(SYSTEM_LIBRARY_DIR)/SystemConfiguration"; - PRODUCT_NAME = SCNetworkReachability; - }; - name = Release; - }; - 1528BFF513573FEE00691881 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - DEBUG_INFORMATION_FORMAT = dwarf; - INSTALL_MODE_FLAG = "a-w,a+rX"; - INSTALL_PATH = /usr/local/lib/SystemConfiguration; - LIBRARY_STYLE = STATIC; - PRODUCT_NAME = SCNetworkReachability; - SDKROOT = iphoneos.internal; - STRIP_INSTALLED_PRODUCT = NO; - SUPPORTED_PLATFORMS = iphoneos; - }; - name = Debug; - }; - 1528BFF613573FEE00691881 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - DEBUG_INFORMATION_FORMAT = dwarf; - INSTALL_MODE_FLAG = "a-w,a+rX"; - INSTALL_PATH = /usr/local/lib/SystemConfiguration; - LIBRARY_STYLE = STATIC; - PRODUCT_NAME = SCNetworkReachability; - SDKROOT = iphoneos.internal; - STRIP_INSTALLED_PRODUCT = NO; - SUPPORTED_PLATFORMS = iphoneos; - }; - name = Release; - }; - 1528BFFC13573FF500691881 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - INFOPLIST_FILE = Plugins/SCNetworkReachability/Info.plist; - INSTALL_MODE_FLAG = "a-w,a+rX"; - INSTALL_PATH = "$(SYSTEM_LIBRARY_DIR)/SystemConfiguration"; - PRODUCT_NAME = SCNetworkReachability; - SDKROOT = iphoneos.internal; - SUPPORTED_PLATFORMS = iphoneos; - }; - name = Debug; - }; - 1528BFFD13573FF500691881 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - INFOPLIST_FILE = Plugins/SCNetworkReachability/Info.plist; - INSTALL_MODE_FLAG = "a-w,a+rX"; - INSTALL_PATH = "$(SYSTEM_LIBRARY_DIR)/SystemConfiguration"; - PRODUCT_NAME = SCNetworkReachability; - SDKROOT = iphoneos.internal; - SUPPORTED_PLATFORMS = iphoneos; - }; - name = Release; - }; - 156CA4830EF853BB00C59A18 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - INFOPLIST_FILE = "Plugins/Logger/Info-Embedded.plist"; - INSTALL_MODE_FLAG = "a-w,a+rX"; - INSTALL_PATH = "$(SYSTEM_LIBRARY_DIR)/SystemConfiguration"; - PRODUCT_NAME = Logger; - SDKROOT = iphoneos.internal; - SUPPORTED_PLATFORMS = iphoneos; - }; - name = Debug; - }; - 156CA4840EF853BB00C59A18 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - INFOPLIST_FILE = "Plugins/Logger/Info-Embedded.plist"; - INSTALL_MODE_FLAG = "a-w,a+rX"; - INSTALL_PATH = "$(SYSTEM_LIBRARY_DIR)/SystemConfiguration"; - PRODUCT_NAME = Logger; - SDKROOT = iphoneos.internal; - SUPPORTED_PLATFORMS = iphoneos; + SUPPORTED_PLATFORMS = iphonesimulator; }; name = Release; }; @@ -6088,9 +5718,7 @@ ); GENERATE_PROFILING_CODE_profile = YES; INSTALLHDRS_COPY_PHASE = YES; - INSTALL_MODE_FLAG = "a-w,a+rX"; INSTALL_PATH = /usr/lib/system; - LD_DYLIB_INSTALL_NAME = /usr/lib/system/libsystem_configuration.dylib; LINK_WITH_STANDARD_LIBRARIES = NO; OTHER_CFLAGS_debug = "-O0"; OTHER_LDFLAGS = ( @@ -6102,11 +5730,11 @@ "-lsystem_asl", "-lsystem_blocks", "-lsystem_c", - "-lsystem_kernel", + "-lsystem$(INTERPOSITION_SIM_SUFFIX)_kernel", "-lsystem_malloc", "-lsystem_notify", - "-lsystem_platform", - "-lsystem_pthread", + "-lsystem$(INTERPOSITION_SIM_SUFFIX)_platform", + "-lsystem$(INTERPOSITION_SIM_SUFFIX)_pthread", "-lxpc", ); PRODUCT_NAME = libsystem_configuration; @@ -6126,9 +5754,7 @@ ); GENERATE_PROFILING_CODE_profile = YES; INSTALLHDRS_COPY_PHASE = YES; - INSTALL_MODE_FLAG = "a-w,a+rX"; INSTALL_PATH = /usr/lib/system; - LD_DYLIB_INSTALL_NAME = /usr/lib/system/libsystem_configuration.dylib; LINK_WITH_STANDARD_LIBRARIES = NO; OTHER_CFLAGS_debug = "-O0"; OTHER_CFLAGS_normal = ""; @@ -6142,11 +5768,11 @@ "-lsystem_asl", "-lsystem_blocks", "-lsystem_c", - "-lsystem_kernel", + "-lsystem$(INTERPOSITION_SIM_SUFFIX)_kernel", "-lsystem_malloc", "-lsystem_notify", - "-lsystem_platform", - "-lsystem_pthread", + "-lsystem$(INTERPOSITION_SIM_SUFFIX)_platform", + "-lsystem$(INTERPOSITION_SIM_SUFFIX)_pthread", "-lxpc", ); PRODUCT_NAME = libsystem_configuration; @@ -6159,6 +5785,7 @@ 156EB5DF0905594A00EEF749 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + DEFINES_MODULE = YES; FRAMEWORK_SEARCH_PATHS = ( "$(SDKROOT)$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks", "$(SDKROOT)$(SYSTEM_LIBRARY_DIR)/Frameworks/CoreServices.framework/Frameworks", @@ -6169,9 +5796,9 @@ ); INFOPLIST_FILE = SystemConfiguration.fproj/Info.plist; INSTALLHDRS_SCRIPT_PHASE = YES; - INSTALL_MODE_FLAG = "a-w,a+rX"; INSTALL_PATH = "$(SYSTEM_LIBRARY_DIR)/Frameworks"; LIBRARY_SEARCH_PATHS = "$(SYMROOT)"; + MODULEMAP_FILE = SystemConfiguration.fproj/Modules/sc_modules.modulemap; PRODUCT_NAME = SystemConfiguration; WRAPPER_EXTENSION = framework; }; @@ -6180,6 +5807,7 @@ 156EB5E00905594A00EEF749 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { + DEFINES_MODULE = YES; FRAMEWORK_SEARCH_PATHS = ( "$(SDKROOT)$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks", "$(SDKROOT)$(SYSTEM_LIBRARY_DIR)/Frameworks/CoreServices.framework/Frameworks", @@ -6190,9 +5818,9 @@ ); INFOPLIST_FILE = SystemConfiguration.fproj/Info.plist; INSTALLHDRS_SCRIPT_PHASE = YES; - INSTALL_MODE_FLAG = "a-w,a+rX"; INSTALL_PATH = "$(SYSTEM_LIBRARY_DIR)/Frameworks"; LIBRARY_SEARCH_PATHS = "$(SYMROOT)"; + MODULEMAP_FILE = SystemConfiguration.fproj/Modules/sc_modules.modulemap; PRODUCT_NAME = SystemConfiguration; SECTORDER_FLAGS = ( "-sectorder", @@ -6209,7 +5837,6 @@ buildSettings = { FRAMEWORK_SEARCH_PATHS = "$(SYMROOT)"; GCC_DYNAMIC_NO_PIC = NO; - INSTALL_MODE_FLAG = "a-w,a+rX"; INSTALL_PATH = "$(SYSTEM_LIBRARY_DIR)/Frameworks/SystemConfiguration.framework/Versions/A/Helpers"; PRODUCT_NAME = SCHelper; }; @@ -6220,7 +5847,6 @@ buildSettings = { FRAMEWORK_SEARCH_PATHS = "$(SYMROOT)"; GCC_DYNAMIC_NO_PIC = NO; - INSTALL_MODE_FLAG = "a-w,a+rX"; INSTALL_PATH = "$(SYSTEM_LIBRARY_DIR)/Frameworks/SystemConfiguration.framework/Versions/A/Helpers"; PRODUCT_NAME = SCHelper; }; @@ -6245,7 +5871,6 @@ buildSettings = { DEBUG_INFORMATION_FORMAT = dwarf; HEADER_SEARCH_PATHS = "$(SDKROOT)$(SYSTEM_LIBRARY_DIR)/Frameworks/System.framework/PrivateHeaders"; - INSTALL_MODE_FLAG = "a-w,a+rX"; INSTALL_PATH = /usr/local/lib/SystemConfiguration; LIBRARY_STYLE = STATIC; PRODUCT_NAME = IPMonitor; @@ -6258,7 +5883,6 @@ buildSettings = { DEBUG_INFORMATION_FORMAT = dwarf; HEADER_SEARCH_PATHS = "$(SDKROOT)$(SYSTEM_LIBRARY_DIR)/Frameworks/System.framework/PrivateHeaders"; - INSTALL_MODE_FLAG = "a-w,a+rX"; INSTALL_PATH = /usr/local/lib/SystemConfiguration; LIBRARY_STYLE = STATIC; PRODUCT_NAME = IPMonitor; @@ -6270,7 +5894,6 @@ isa = XCBuildConfiguration; buildSettings = { INFOPLIST_FILE = Plugins/IPMonitor/Info.plist; - INSTALL_MODE_FLAG = "a-w,a+rX"; INSTALL_PATH = "$(SYSTEM_LIBRARY_DIR)/SystemConfiguration"; PRODUCT_NAME = IPMonitor; }; @@ -6280,7 +5903,6 @@ isa = XCBuildConfiguration; buildSettings = { INFOPLIST_FILE = Plugins/IPMonitor/Info.plist; - INSTALL_MODE_FLAG = "a-w,a+rX"; INSTALL_PATH = "$(SYSTEM_LIBRARY_DIR)/SystemConfiguration"; PRODUCT_NAME = IPMonitor; }; @@ -6290,7 +5912,6 @@ isa = XCBuildConfiguration; buildSettings = { DEBUG_INFORMATION_FORMAT = dwarf; - INSTALL_MODE_FLAG = "a-w,a+rX"; INSTALL_PATH = /usr/local/lib/SystemConfiguration; LIBRARY_STYLE = STATIC; PRODUCT_NAME = InterfaceNamer; @@ -6302,7 +5923,6 @@ isa = XCBuildConfiguration; buildSettings = { DEBUG_INFORMATION_FORMAT = dwarf; - INSTALL_MODE_FLAG = "a-w,a+rX"; INSTALL_PATH = /usr/local/lib/SystemConfiguration; LIBRARY_STYLE = STATIC; PRODUCT_NAME = InterfaceNamer; @@ -6314,7 +5934,6 @@ isa = XCBuildConfiguration; buildSettings = { INFOPLIST_FILE = Plugins/InterfaceNamer/Info.plist; - INSTALL_MODE_FLAG = "a-w,a+rX"; INSTALL_PATH = "$(SYSTEM_LIBRARY_DIR)/SystemConfiguration"; PRODUCT_NAME = InterfaceNamer; }; @@ -6324,7 +5943,6 @@ isa = XCBuildConfiguration; buildSettings = { INFOPLIST_FILE = Plugins/InterfaceNamer/Info.plist; - INSTALL_MODE_FLAG = "a-w,a+rX"; INSTALL_PATH = "$(SYSTEM_LIBRARY_DIR)/SystemConfiguration"; PRODUCT_NAME = InterfaceNamer; }; @@ -6334,7 +5952,6 @@ isa = XCBuildConfiguration; buildSettings = { INFOPLIST_FILE = Plugins/KernelEventMonitor/Info.plist; - INSTALL_MODE_FLAG = "a-w,a+rX"; INSTALL_PATH = "$(SYSTEM_LIBRARY_DIR)/SystemConfiguration"; PRODUCT_NAME = KernelEventMonitor; }; @@ -6344,7 +5961,6 @@ isa = XCBuildConfiguration; buildSettings = { INFOPLIST_FILE = Plugins/KernelEventMonitor/Info.plist; - INSTALL_MODE_FLAG = "a-w,a+rX"; INSTALL_PATH = "$(SYSTEM_LIBRARY_DIR)/SystemConfiguration"; PRODUCT_NAME = KernelEventMonitor; }; @@ -6356,7 +5972,6 @@ DEBUG_INFORMATION_FORMAT = dwarf; FRAMEWORK_SEARCH_PATHS = "$(SDKROOT)$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks"; HEADER_SEARCH_PATHS = "$(SDKROOT)$(SYSTEM_LIBRARY_DIR)/Frameworks/System.framework/PrivateHeaders"; - INSTALL_MODE_FLAG = "a-w,a+rX"; INSTALL_PATH = /usr/local/lib/SystemConfiguration; LIBRARY_STYLE = STATIC; PRODUCT_NAME = KernelEventMonitor; @@ -6370,7 +5985,6 @@ DEBUG_INFORMATION_FORMAT = dwarf; FRAMEWORK_SEARCH_PATHS = "$(SDKROOT)$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks"; HEADER_SEARCH_PATHS = "$(SDKROOT)$(SYSTEM_LIBRARY_DIR)/Frameworks/System.framework/PrivateHeaders"; - INSTALL_MODE_FLAG = "a-w,a+rX"; INSTALL_PATH = /usr/local/lib/SystemConfiguration; LIBRARY_STYLE = STATIC; PRODUCT_NAME = KernelEventMonitor; @@ -6382,7 +5996,6 @@ isa = XCBuildConfiguration; buildSettings = { DEBUG_INFORMATION_FORMAT = dwarf; - INSTALL_MODE_FLAG = "a-w,a+rX"; INSTALL_PATH = /usr/local/lib/SystemConfiguration; LIBRARY_STYLE = STATIC; PRODUCT_NAME = LinkConfiguration; @@ -6394,7 +6007,6 @@ isa = XCBuildConfiguration; buildSettings = { DEBUG_INFORMATION_FORMAT = dwarf; - INSTALL_MODE_FLAG = "a-w,a+rX"; INSTALL_PATH = /usr/local/lib/SystemConfiguration; LIBRARY_STYLE = STATIC; PRODUCT_NAME = LinkConfiguration; @@ -6406,7 +6018,6 @@ isa = XCBuildConfiguration; buildSettings = { INFOPLIST_FILE = Plugins/LinkConfiguration/Info.plist; - INSTALL_MODE_FLAG = "a-w,a+rX"; INSTALL_PATH = "$(SYSTEM_LIBRARY_DIR)/SystemConfiguration"; PRODUCT_NAME = LinkConfiguration; }; @@ -6416,7 +6027,6 @@ isa = XCBuildConfiguration; buildSettings = { INFOPLIST_FILE = Plugins/LinkConfiguration/Info.plist; - INSTALL_MODE_FLAG = "a-w,a+rX"; INSTALL_PATH = "$(SYSTEM_LIBRARY_DIR)/SystemConfiguration"; PRODUCT_NAME = LinkConfiguration; }; @@ -6426,7 +6036,6 @@ isa = XCBuildConfiguration; buildSettings = { DEBUG_INFORMATION_FORMAT = dwarf; - INSTALL_MODE_FLAG = "a-w,a+rX"; INSTALL_PATH = /usr/local/lib/SystemConfiguration; LIBRARY_STYLE = STATIC; PRODUCT_NAME = PreferencesMonitor; @@ -6438,7 +6047,6 @@ isa = XCBuildConfiguration; buildSettings = { DEBUG_INFORMATION_FORMAT = dwarf; - INSTALL_MODE_FLAG = "a-w,a+rX"; INSTALL_PATH = /usr/local/lib/SystemConfiguration; LIBRARY_STYLE = STATIC; PRODUCT_NAME = PreferencesMonitor; @@ -6450,7 +6058,6 @@ isa = XCBuildConfiguration; buildSettings = { INFOPLIST_FILE = Plugins/PreferencesMonitor/Info.plist; - INSTALL_MODE_FLAG = "a-w,a+rX"; INSTALL_PATH = "$(SYSTEM_LIBRARY_DIR)/SystemConfiguration"; PRODUCT_NAME = PreferencesMonitor; }; @@ -6460,7 +6067,6 @@ isa = XCBuildConfiguration; buildSettings = { INFOPLIST_FILE = Plugins/PreferencesMonitor/Info.plist; - INSTALL_MODE_FLAG = "a-w,a+rX"; INSTALL_PATH = "$(SYSTEM_LIBRARY_DIR)/SystemConfiguration"; PRODUCT_NAME = PreferencesMonitor; }; @@ -6485,7 +6091,6 @@ buildSettings = { FRAMEWORK_SEARCH_PATHS = "$(SYMROOT)"; GCC_DYNAMIC_NO_PIC = NO; - INSTALL_MODE_FLAG = "a-w,a+rX"; INSTALL_PATH = /usr/libexec; LIBRARY_SEARCH_PATHS = ( "$(SYMROOT)", @@ -6500,7 +6105,6 @@ buildSettings = { FRAMEWORK_SEARCH_PATHS = "$(SYMROOT)"; GCC_DYNAMIC_NO_PIC = NO; - INSTALL_MODE_FLAG = "a-w,a+rX"; INSTALL_PATH = /usr/libexec; LIBRARY_SEARCH_PATHS = ( "$(SYMROOT)", @@ -6515,7 +6119,6 @@ buildSettings = { FRAMEWORK_SEARCH_PATHS = "$(SYMROOT)"; GCC_DYNAMIC_NO_PIC = NO; - INSTALL_MODE_FLAG = "a-w,a+rX"; INSTALL_PATH = /usr/sbin; PRODUCT_NAME = scselect; }; @@ -6526,7 +6129,6 @@ buildSettings = { FRAMEWORK_SEARCH_PATHS = "$(SYMROOT)"; GCC_DYNAMIC_NO_PIC = NO; - INSTALL_MODE_FLAG = "a-w,a+rX"; INSTALL_PATH = /usr/sbin; PRODUCT_NAME = scselect; }; @@ -6537,7 +6139,6 @@ buildSettings = { FRAMEWORK_SEARCH_PATHS = "$(SYMROOT)"; GCC_DYNAMIC_NO_PIC = NO; - INSTALL_MODE_FLAG = "a-w,a+rX"; INSTALL_PATH = /usr/sbin; LIBRARY_SEARCH_PATHS = ( "$(SYMROOT)", @@ -6552,7 +6153,6 @@ buildSettings = { FRAMEWORK_SEARCH_PATHS = "$(SYMROOT)"; GCC_DYNAMIC_NO_PIC = NO; - INSTALL_MODE_FLAG = "a-w,a+rX"; INSTALL_PATH = /usr/sbin; LIBRARY_SEARCH_PATHS = ( "$(SYMROOT)", @@ -6579,14 +6179,14 @@ 156EB6330905594A00EEF749 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { - PRODUCT_NAME = "configd (Aggregate)"; + PRODUCT_NAME = configdAggregate; }; name = Debug; }; 156EB6340905594A00EEF749 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { - PRODUCT_NAME = "configd (Aggregate)"; + PRODUCT_NAME = configdAggregate; }; name = Release; }; @@ -6603,15 +6203,17 @@ DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = "$(RC_ProjectSourceVersion)"; GCC_OPTIMIZATION_LEVEL = 0; - INSTALL_GROUP = wheel; - INSTALL_OWNER = root; INSTALL_PATH = /usr/sbin; + INTERPOSITION_SIM_SUFFIX = ""; + "INTERPOSITION_SIM_SUFFIX[sdk=iphonesimulator*]" = _sim; OTHER_CFLAGS = ( "-fconstant-cfstrings", "-fstack-protector-all", "-D_FORTIFY_SOURCE=2", ); RUN_CLANG_STATIC_ANALYZER = YES; + SDKROOT = macosx.internal; + SUPPORTED_PLATFORMS = macosx; VERSIONING_SYSTEM = "apple-generic"; WARNING_CFLAGS = ( "-Wall", @@ -6633,14 +6235,16 @@ DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = "$(RC_ProjectSourceVersion)"; - INSTALL_GROUP = wheel; - INSTALL_OWNER = root; INSTALL_PATH = /usr/sbin; + INTERPOSITION_SIM_SUFFIX = ""; + "INTERPOSITION_SIM_SUFFIX[sdk=iphonesimulator*]" = _sim; OTHER_CFLAGS = ( "-fconstant-cfstrings", "-fstack-protector-all", "-D_FORTIFY_SOURCE=2", ); + SDKROOT = macosx.internal; + SUPPORTED_PLATFORMS = macosx; VERSIONING_SYSTEM = "apple-generic"; WARNING_CFLAGS = ( "-Wall", @@ -6656,18 +6260,24 @@ 1572C52A0CFB55B400E2776E /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + DEFINES_MODULE = YES; HEADER_SEARCH_PATHS = ( "$(SDKROOT)$(SYSTEM_LIBRARY_DIR)/Frameworks/System.framework/PrivateHeaders", "$(SDKROOT)/usr/local/include/ppp", ); INFOPLIST_FILE = "SystemConfiguration.fproj/Info-Embedded.plist"; INSTALLHDRS_SCRIPT_PHASE = YES; - INSTALL_MODE_FLAG = "a-w,a+rX"; - INSTALL_PATH = "$(SYSTEM_LIBRARY_DIR)/Frameworks"; + "INSTALL_PATH[sdk=appletv*]" = "$(SYSTEM_LIBRARY_DIR)/Frameworks"; + "INSTALL_PATH[sdk=iphone*]" = "$(SYSTEM_LIBRARY_DIR)/Frameworks"; + "INSTALL_PATH[sdk=watch*]" = "$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks"; LIBRARY_SEARCH_PATHS = "$(SYMROOT)"; + MODULEMAP_FILE = SystemConfiguration.fproj/Modules/sc_modules.modulemap; PRODUCT_NAME = SystemConfiguration; SDKROOT = iphoneos.internal; SUPPORTED_PLATFORMS = iphoneos; + "USING_PRIVATE_SYSTEMCONFIGURATION_FRAMEWORK[sdk=appletv*]" = NO; + "USING_PRIVATE_SYSTEMCONFIGURATION_FRAMEWORK[sdk=iphone*]" = NO; + "USING_PRIVATE_SYSTEMCONFIGURATION_FRAMEWORK[sdk=watch*]" = YES; WRAPPER_EXTENSION = framework; }; name = Debug; @@ -6675,93 +6285,98 @@ 1572C52B0CFB55B400E2776E /* Release */ = { isa = XCBuildConfiguration; buildSettings = { + DEFINES_MODULE = YES; HEADER_SEARCH_PATHS = ( "$(SDKROOT)$(SYSTEM_LIBRARY_DIR)/Frameworks/System.framework/PrivateHeaders", "$(SDKROOT)/usr/local/include/ppp", ); INFOPLIST_FILE = "SystemConfiguration.fproj/Info-Embedded.plist"; INSTALLHDRS_SCRIPT_PHASE = YES; - INSTALL_MODE_FLAG = "a-w,a+rX"; - INSTALL_PATH = "$(SYSTEM_LIBRARY_DIR)/Frameworks"; + "INSTALL_PATH[sdk=appletv*]" = "$(SYSTEM_LIBRARY_DIR)/Frameworks"; + "INSTALL_PATH[sdk=iphone*]" = "$(SYSTEM_LIBRARY_DIR)/Frameworks"; + "INSTALL_PATH[sdk=watch*]" = "$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks"; LIBRARY_SEARCH_PATHS = "$(SYMROOT)"; + MODULEMAP_FILE = SystemConfiguration.fproj/Modules/sc_modules.modulemap; PRODUCT_NAME = SystemConfiguration; SDKROOT = iphoneos.internal; SUPPORTED_PLATFORMS = iphoneos; + "USING_PRIVATE_SYSTEMCONFIGURATION_FRAMEWORK[sdk=appletv*]" = NO; + "USING_PRIVATE_SYSTEMCONFIGURATION_FRAMEWORK[sdk=iphone*]" = NO; + "USING_PRIVATE_SYSTEMCONFIGURATION_FRAMEWORK[sdk=watch*]" = YES; WRAPPER_EXTENSION = framework; }; name = Release; }; 15732AAA16EA503200F3AC4C /* Debug */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 15FD147B0D594FE700F9409C /* SimulatorSupport.xcconfig */; buildSettings = { APPLY_RULES_IN_COPY_FILES = YES; FRAMEWORK_SEARCH_PATHS = "$(SYMROOT)"; - INSTALL_MODE_FLAG = "a-w,a+rX"; - INSTALL_PATH_ACTUAL = /usr/libexec; + INSTALL_PATH = /usr/libexec; LIBRARY_SEARCH_PATHS = ( "$(SYMROOT)", "$(SDKROOT)/usr/local/lib/SystemConfiguration", ); PRODUCT_NAME = configd_sim; + SDKROOT = iphoneos.internal; + SUPPORTED_PLATFORMS = iphonesimulator; }; name = Debug; }; 15732AAB16EA503200F3AC4C /* Release */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 15FD147B0D594FE700F9409C /* SimulatorSupport.xcconfig */; buildSettings = { APPLY_RULES_IN_COPY_FILES = YES; FRAMEWORK_SEARCH_PATHS = "$(SYMROOT)"; - INSTALL_MODE_FLAG = "a-w,a+rX"; - INSTALL_PATH_ACTUAL = /usr/libexec; + INSTALL_PATH = /usr/libexec; LIBRARY_SEARCH_PATHS = ( "$(SYMROOT)", "$(SDKROOT)/usr/local/lib/SystemConfiguration", ); PRODUCT_NAME = configd_sim; + SDKROOT = iphoneos.internal; + SUPPORTED_PLATFORMS = iphonesimulator; }; name = Release; }; 15732AD316EA511900F3AC4C /* Debug */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 15FD147B0D594FE700F9409C /* SimulatorSupport.xcconfig */; buildSettings = { FRAMEWORK_SEARCH_PATHS = ( "$(SYMROOT)", "$(SDKROOT)$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks", ); - INSTALL_MODE_FLAG = "a-w,a+rX"; - INSTALL_PATH_ACTUAL = /usr/local/bin; + INSTALL_PATH = /usr/local/bin; LIBRARY_SEARCH_PATHS = ( "$(SYMROOT)", "$(SDKROOT)/usr/local/lib/SystemConfiguration", ); PRODUCT_NAME = scutil_sim; + SDKROOT = iphoneos.internal; + SUPPORTED_PLATFORMS = iphonesimulator; }; name = Debug; }; 15732AD416EA511900F3AC4C /* Release */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 15FD147B0D594FE700F9409C /* SimulatorSupport.xcconfig */; buildSettings = { FRAMEWORK_SEARCH_PATHS = ( "$(SYMROOT)", "$(SDKROOT)$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks", ); - INSTALL_MODE_FLAG = "a-w,a+rX"; - INSTALL_PATH_ACTUAL = /usr/local/bin; + INSTALL_PATH = /usr/local/bin; LIBRARY_SEARCH_PATHS = ( "$(SYMROOT)", "$(SDKROOT)/usr/local/lib/SystemConfiguration", ); PRODUCT_NAME = scutil_sim; + SDKROOT = iphoneos.internal; + SUPPORTED_PLATFORMS = iphonesimulator; }; name = Release; }; 15732AE216EA6B6700F3AC4C /* Debug */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 15FD147B0D594FE700F9409C /* SimulatorSupport.xcconfig */; buildSettings = { BUILD_VARIANTS = ( normal, @@ -6771,9 +6386,7 @@ FRAMEWORK_SEARCH_PATHS = "$(inherited)"; GENERATE_PROFILING_CODE_profile = YES; INSTALLHDRS_COPY_PHASE = YES; - INSTALL_MODE_FLAG = "a-w,a+rX"; - INSTALL_PATH_ACTUAL = /usr/lib/system; - LD_DYLIB_INSTALL_NAME = /usr/lib/system/libsystem_sim_configuration.dylib; + INSTALL_PATH = /usr/lib/system; LIBRARY_SEARCH_PATHS = "$(SDKDIR)/usr/lib"; LINK_WITH_STANDARD_LIBRARIES = NO; OTHER_CFLAGS_debug = "-O0"; @@ -6782,26 +6395,32 @@ OTHER_LDFLAGS = ( "-Wl,-umbrella,System", "-L/usr/lib/system", - "-lcompiler_rt_sim", + "-lcompiler_rt", "-ldispatch", - "-ldyld_sim", - "-lsystem_sim_blocks", - "-lsystem_sim_c", + "-ldyld", + "-lsystem_asl", + "-lsystem_blocks", + "-lsystem_c", + "-lsystem$(INTERPOSITION_SIM_SUFFIX)_kernel", + "-lsystem_malloc", + "-lsystem_notify", + "-lsystem$(INTERPOSITION_SIM_SUFFIX)_platform", + "-lsystem$(INTERPOSITION_SIM_SUFFIX)_pthread", "-lxpc", - "-Wl,-upward-lSystem", ); - PRIVATE_HEADERS_FOLDER_PATH = "$(INSTALL_PATH_PREFIX)/usr/local/include"; - PRODUCT_NAME = libsystem_sim_configuration; - PUBLIC_HEADERS_FOLDER_PATH = "$(INSTALL_PATH_PREFIX)/usr/local/include"; + PRIVATE_HEADERS_FOLDER_PATH = /usr/local/include; + PRODUCT_NAME = libsystem_configuration; + PUBLIC_HEADERS_FOLDER_PATH = /usr/local/include; + SDKROOT = iphoneos.internal; STRIP_INSTALLED_PRODUCT_debug = NO; STRIP_INSTALLED_PRODUCT_normal = YES; STRIP_INSTALLED_PRODUCT_profile = NO; + SUPPORTED_PLATFORMS = iphonesimulator; }; name = Debug; }; 15732AE316EA6B6700F3AC4C /* Release */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 15FD147B0D594FE700F9409C /* SimulatorSupport.xcconfig */; buildSettings = { BUILD_VARIANTS = ( normal, @@ -6811,9 +6430,7 @@ FRAMEWORK_SEARCH_PATHS = "$(inherited)"; GENERATE_PROFILING_CODE_profile = YES; INSTALLHDRS_COPY_PHASE = YES; - INSTALL_MODE_FLAG = "a-w,a+rX"; - INSTALL_PATH_ACTUAL = /usr/lib/system; - LD_DYLIB_INSTALL_NAME = /usr/lib/system/libsystem_sim_configuration.dylib; + INSTALL_PATH = /usr/lib/system; LIBRARY_SEARCH_PATHS = "$(SDKDIR)/usr/lib"; LINK_WITH_STANDARD_LIBRARIES = NO; OTHER_CFLAGS_debug = "-O0"; @@ -6822,20 +6439,27 @@ OTHER_LDFLAGS = ( "-Wl,-umbrella,System", "-L/usr/lib/system", - "-lcompiler_rt_sim", + "-lcompiler_rt", "-ldispatch", - "-ldyld_sim", - "-lsystem_sim_blocks", - "-lsystem_sim_c", + "-ldyld", + "-lsystem_asl", + "-lsystem_blocks", + "-lsystem_c", + "-lsystem$(INTERPOSITION_SIM_SUFFIX)_kernel", + "-lsystem_malloc", + "-lsystem_notify", + "-lsystem$(INTERPOSITION_SIM_SUFFIX)_platform", + "-lsystem$(INTERPOSITION_SIM_SUFFIX)_pthread", "-lxpc", - "-Wl,-upward-lSystem", ); - PRIVATE_HEADERS_FOLDER_PATH = "$(INSTALL_PATH_PREFIX)/usr/local/include"; - PRODUCT_NAME = libsystem_sim_configuration; - PUBLIC_HEADERS_FOLDER_PATH = "$(INSTALL_PATH_PREFIX)/usr/local/include"; + PRIVATE_HEADERS_FOLDER_PATH = /usr/local/include; + PRODUCT_NAME = libsystem_configuration; + PUBLIC_HEADERS_FOLDER_PATH = /usr/local/include; + SDKROOT = iphoneos.internal; STRIP_INSTALLED_PRODUCT_debug = NO; STRIP_INSTALLED_PRODUCT_normal = YES; STRIP_INSTALLED_PRODUCT_profile = NO; + SUPPORTED_PLATFORMS = iphonesimulator; }; name = Release; }; @@ -6868,7 +6492,6 @@ "$(SYMROOT)", "$(SDKROOT)$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks", ); - INSTALL_MODE_FLAG = "a-w,a+rX"; INSTALL_PATH = /usr/sbin; LIBRARY_SEARCH_PATHS = ( "$(SYMROOT)", @@ -6887,7 +6510,6 @@ "$(SYMROOT)", "$(SDKROOT)$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks", ); - INSTALL_MODE_FLAG = "a-w,a+rX"; INSTALL_PATH = /usr/sbin; LIBRARY_SEARCH_PATHS = ( "$(SYMROOT)", @@ -6909,9 +6531,7 @@ ); GENERATE_PROFILING_CODE_profile = YES; INSTALLHDRS_COPY_PHASE = YES; - INSTALL_MODE_FLAG = "a-w,a+rX"; INSTALL_PATH = /usr/lib/system; - LD_DYLIB_INSTALL_NAME = /usr/lib/system/libsystem_configuration.dylib; LINK_WITH_STANDARD_LIBRARIES = NO; OTHER_CFLAGS_debug = "-O0"; OTHER_CFLAGS_normal = ""; @@ -6938,7 +6558,7 @@ STRIP_INSTALLED_PRODUCT_debug = NO; STRIP_INSTALLED_PRODUCT_normal = YES; STRIP_INSTALLED_PRODUCT_profile = NO; - SUPPORTED_PLATFORMS = iphoneos; + SUPPORTED_PLATFORMS = "iphoneos tvos watchos"; }; name = Debug; }; @@ -6952,9 +6572,7 @@ ); GENERATE_PROFILING_CODE_profile = YES; INSTALLHDRS_COPY_PHASE = YES; - INSTALL_MODE_FLAG = "a-w,a+rX"; INSTALL_PATH = /usr/lib/system; - LD_DYLIB_INSTALL_NAME = /usr/lib/system/libsystem_configuration.dylib; LINK_WITH_STANDARD_LIBRARIES = NO; OTHER_CFLAGS_debug = "-O0"; OTHER_CFLAGS_normal = ""; @@ -6981,7 +6599,7 @@ STRIP_INSTALLED_PRODUCT_debug = NO; STRIP_INSTALLED_PRODUCT_normal = YES; STRIP_INSTALLED_PRODUCT_profile = NO; - SUPPORTED_PLATFORMS = iphoneos; + SUPPORTED_PLATFORMS = "iphoneos tvos watchos"; }; name = Release; }; @@ -6990,7 +6608,6 @@ buildSettings = { DEBUG_INFORMATION_FORMAT = dwarf; HEADER_SEARCH_PATHS = "$(SDKROOT)$(SYSTEM_LIBRARY_DIR)/Frameworks/System.framework/PrivateHeaders"; - INSTALL_MODE_FLAG = "a-w,a+rX"; INSTALL_PATH = /usr/local/lib/SystemConfiguration; LIBRARY_STYLE = STATIC; PRODUCT_NAME = IPMonitor; @@ -7005,7 +6622,6 @@ buildSettings = { DEBUG_INFORMATION_FORMAT = dwarf; HEADER_SEARCH_PATHS = "$(SDKROOT)$(SYSTEM_LIBRARY_DIR)/Frameworks/System.framework/PrivateHeaders"; - INSTALL_MODE_FLAG = "a-w,a+rX"; INSTALL_PATH = /usr/local/lib/SystemConfiguration; LIBRARY_STYLE = STATIC; PRODUCT_NAME = IPMonitor; @@ -7019,7 +6635,6 @@ isa = XCBuildConfiguration; buildSettings = { DEBUG_INFORMATION_FORMAT = dwarf; - INSTALL_MODE_FLAG = "a-w,a+rX"; INSTALL_PATH = /usr/local/lib/SystemConfiguration; LIBRARY_STYLE = STATIC; PRODUCT_NAME = InterfaceNamer; @@ -7033,7 +6648,6 @@ isa = XCBuildConfiguration; buildSettings = { DEBUG_INFORMATION_FORMAT = dwarf; - INSTALL_MODE_FLAG = "a-w,a+rX"; INSTALL_PATH = /usr/local/lib/SystemConfiguration; LIBRARY_STYLE = STATIC; PRODUCT_NAME = InterfaceNamer; @@ -7048,7 +6662,6 @@ buildSettings = { DEBUG_INFORMATION_FORMAT = dwarf; HEADER_SEARCH_PATHS = "$(SDKROOT)$(SYSTEM_LIBRARY_DIR)/Frameworks/System.framework/PrivateHeaders"; - INSTALL_MODE_FLAG = "a-w,a+rX"; INSTALL_PATH = /usr/local/lib/SystemConfiguration; LIBRARY_STYLE = STATIC; PRODUCT_NAME = KernelEventMonitor; @@ -7063,7 +6676,6 @@ buildSettings = { DEBUG_INFORMATION_FORMAT = dwarf; HEADER_SEARCH_PATHS = "$(SDKROOT)$(SYSTEM_LIBRARY_DIR)/Frameworks/System.framework/PrivateHeaders"; - INSTALL_MODE_FLAG = "a-w,a+rX"; INSTALL_PATH = /usr/local/lib/SystemConfiguration; LIBRARY_STYLE = STATIC; PRODUCT_NAME = KernelEventMonitor; @@ -7077,7 +6689,6 @@ isa = XCBuildConfiguration; buildSettings = { DEBUG_INFORMATION_FORMAT = dwarf; - INSTALL_MODE_FLAG = "a-w,a+rX"; INSTALL_PATH = /usr/local/lib/SystemConfiguration; LIBRARY_STYLE = STATIC; PRODUCT_NAME = LinkConfiguration; @@ -7091,7 +6702,6 @@ isa = XCBuildConfiguration; buildSettings = { DEBUG_INFORMATION_FORMAT = dwarf; - INSTALL_MODE_FLAG = "a-w,a+rX"; INSTALL_PATH = /usr/local/lib/SystemConfiguration; LIBRARY_STYLE = STATIC; PRODUCT_NAME = LinkConfiguration; @@ -7105,7 +6715,6 @@ isa = XCBuildConfiguration; buildSettings = { DEBUG_INFORMATION_FORMAT = dwarf; - INSTALL_MODE_FLAG = "a-w,a+rX"; INSTALL_PATH = /usr/local/lib/SystemConfiguration; LIBRARY_STYLE = STATIC; PRODUCT_NAME = PreferencesMonitor; @@ -7119,7 +6728,6 @@ isa = XCBuildConfiguration; buildSettings = { DEBUG_INFORMATION_FORMAT = dwarf; - INSTALL_MODE_FLAG = "a-w,a+rX"; INSTALL_PATH = /usr/local/lib/SystemConfiguration; LIBRARY_STYLE = STATIC; PRODUCT_NAME = PreferencesMonitor; @@ -7131,19 +6739,19 @@ }; 157FDE3F164A075F0040D6A8 /* Debug */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 15FD147B0D594FE700F9409C /* SimulatorSupport.xcconfig */; buildSettings = { INSTALLHDRS_COPY_PHASE = YES; PRODUCT_NAME = "configd_libSystem (EmbeddedSimulator)"; + SUPPORTED_PLATFORMS = iphonesimulator; }; name = Debug; }; 157FDE40164A075F0040D6A8 /* Release */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 15FD147B0D594FE700F9409C /* SimulatorSupport.xcconfig */; buildSettings = { INSTALLHDRS_COPY_PHASE = YES; PRODUCT_NAME = "configd_libSystem (EmbeddedSimulator)"; + SUPPORTED_PLATFORMS = iphonesimulator; }; name = Release; }; @@ -7151,6 +6759,7 @@ isa = XCBuildConfiguration; buildSettings = { PRODUCT_NAME = "configd_base (Embedded)"; + SUPPORTED_PLATFORMS = iphoneos; }; name = Debug; }; @@ -7158,6 +6767,7 @@ isa = XCBuildConfiguration; buildSettings = { PRODUCT_NAME = "configd_base (Embedded)"; + SUPPORTED_PLATFORMS = iphoneos; }; name = Release; }; @@ -7165,6 +6775,7 @@ isa = XCBuildConfiguration; buildSettings = { PRODUCT_NAME = "configd_plugins (Embedded)"; + SUPPORTED_PLATFORMS = iphoneos; }; name = Debug; }; @@ -7172,6 +6783,7 @@ isa = XCBuildConfiguration; buildSettings = { PRODUCT_NAME = "configd_plugins (Embedded)"; + SUPPORTED_PLATFORMS = iphoneos; }; name = Release; }; @@ -7179,6 +6791,7 @@ isa = XCBuildConfiguration; buildSettings = { PRODUCT_NAME = "configd_executables (Embedded)"; + SUPPORTED_PLATFORMS = iphoneos; }; name = Debug; }; @@ -7186,6 +6799,7 @@ isa = XCBuildConfiguration; buildSettings = { PRODUCT_NAME = "configd_executables (Embedded)"; + SUPPORTED_PLATFORMS = iphoneos; }; name = Release; }; @@ -7199,7 +6813,6 @@ "$(SYMROOT)", "$(SDKROOT)$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks", ); - INSTALL_MODE_FLAG = "a-w,a+rX"; INSTALL_PATH = /usr/libexec; LIBRARY_SEARCH_PATHS = ( "$(SYMROOT)", @@ -7221,7 +6834,6 @@ "$(SYMROOT)", "$(SDKROOT)$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks", ); - INSTALL_MODE_FLAG = "a-w,a+rX"; INSTALL_PATH = /usr/libexec; LIBRARY_SEARCH_PATHS = ( "$(SYMROOT)", @@ -7237,7 +6849,6 @@ isa = XCBuildConfiguration; buildSettings = { INFOPLIST_FILE = Plugins/IPMonitor/Info.plist; - INSTALL_MODE_FLAG = "a-w,a+rX"; INSTALL_PATH = "$(SYSTEM_LIBRARY_DIR)/SystemConfiguration"; PRODUCT_NAME = IPMonitor; SDKROOT = iphoneos.internal; @@ -7249,7 +6860,6 @@ isa = XCBuildConfiguration; buildSettings = { INFOPLIST_FILE = Plugins/IPMonitor/Info.plist; - INSTALL_MODE_FLAG = "a-w,a+rX"; INSTALL_PATH = "$(SYSTEM_LIBRARY_DIR)/SystemConfiguration"; PRODUCT_NAME = IPMonitor; SDKROOT = iphoneos.internal; @@ -7261,7 +6871,6 @@ isa = XCBuildConfiguration; buildSettings = { INFOPLIST_FILE = Plugins/InterfaceNamer/Info.plist; - INSTALL_MODE_FLAG = "a-w,a+rX"; INSTALL_PATH = "$(SYSTEM_LIBRARY_DIR)/SystemConfiguration"; PRODUCT_NAME = InterfaceNamer; SDKROOT = iphoneos.internal; @@ -7273,7 +6882,6 @@ isa = XCBuildConfiguration; buildSettings = { INFOPLIST_FILE = Plugins/InterfaceNamer/Info.plist; - INSTALL_MODE_FLAG = "a-w,a+rX"; INSTALL_PATH = "$(SYSTEM_LIBRARY_DIR)/SystemConfiguration"; PRODUCT_NAME = InterfaceNamer; SDKROOT = iphoneos.internal; @@ -7285,7 +6893,6 @@ isa = XCBuildConfiguration; buildSettings = { INFOPLIST_FILE = Plugins/KernelEventMonitor/Info.plist; - INSTALL_MODE_FLAG = "a-w,a+rX"; INSTALL_PATH = "$(SYSTEM_LIBRARY_DIR)/SystemConfiguration"; PRODUCT_NAME = KernelEventMonitor; SDKROOT = iphoneos.internal; @@ -7297,7 +6904,6 @@ isa = XCBuildConfiguration; buildSettings = { INFOPLIST_FILE = Plugins/KernelEventMonitor/Info.plist; - INSTALL_MODE_FLAG = "a-w,a+rX"; INSTALL_PATH = "$(SYSTEM_LIBRARY_DIR)/SystemConfiguration"; PRODUCT_NAME = KernelEventMonitor; SDKROOT = iphoneos.internal; @@ -7309,7 +6915,6 @@ isa = XCBuildConfiguration; buildSettings = { INFOPLIST_FILE = Plugins/LinkConfiguration/Info.plist; - INSTALL_MODE_FLAG = "a-w,a+rX"; INSTALL_PATH = "$(SYSTEM_LIBRARY_DIR)/SystemConfiguration"; PRODUCT_NAME = LinkConfiguration; SDKROOT = iphoneos.internal; @@ -7321,7 +6926,6 @@ isa = XCBuildConfiguration; buildSettings = { INFOPLIST_FILE = Plugins/LinkConfiguration/Info.plist; - INSTALL_MODE_FLAG = "a-w,a+rX"; INSTALL_PATH = "$(SYSTEM_LIBRARY_DIR)/SystemConfiguration"; PRODUCT_NAME = LinkConfiguration; SDKROOT = iphoneos.internal; @@ -7333,7 +6937,6 @@ isa = XCBuildConfiguration; buildSettings = { INFOPLIST_FILE = Plugins/PreferencesMonitor/Info.plist; - INSTALL_MODE_FLAG = "a-w,a+rX"; INSTALL_PATH = "$(SYSTEM_LIBRARY_DIR)/SystemConfiguration"; PRODUCT_NAME = PreferencesMonitor; SDKROOT = iphoneos.internal; @@ -7345,7 +6948,6 @@ isa = XCBuildConfiguration; buildSettings = { INFOPLIST_FILE = Plugins/PreferencesMonitor/Info.plist; - INSTALL_MODE_FLAG = "a-w,a+rX"; INSTALL_PATH = "$(SYSTEM_LIBRARY_DIR)/SystemConfiguration"; PRODUCT_NAME = PreferencesMonitor; SDKROOT = iphoneos.internal; @@ -7358,8 +6960,9 @@ buildSettings = { APPLY_RULES_IN_COPY_FILES = YES; FRAMEWORK_SEARCH_PATHS = "$(SYMROOT)"; - INSTALL_MODE_FLAG = "a-w,a+rX"; - INSTALL_PATH = "$(SYSTEM_LIBRARY_DIR)/Frameworks/SystemConfiguration.framework"; + "INSTALL_PATH[sdk=appletv*]" = "$(SYSTEM_LIBRARY_DIR)/Frameworks/SystemConfiguration.framework"; + "INSTALL_PATH[sdk=iphone*]" = "$(SYSTEM_LIBRARY_DIR)/Frameworks/SystemConfiguration.framework"; + "INSTALL_PATH[sdk=watch*]" = "$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks/SystemConfiguration.framework"; PRODUCT_NAME = SCHelper; SDKROOT = iphoneos.internal; SUPPORTED_PLATFORMS = iphoneos; @@ -7371,8 +6974,9 @@ buildSettings = { APPLY_RULES_IN_COPY_FILES = YES; FRAMEWORK_SEARCH_PATHS = "$(SYMROOT)"; - INSTALL_MODE_FLAG = "a-w,a+rX"; - INSTALL_PATH = "$(SYSTEM_LIBRARY_DIR)/Frameworks/SystemConfiguration.framework"; + "INSTALL_PATH[sdk=appletv*]" = "$(SYSTEM_LIBRARY_DIR)/Frameworks/SystemConfiguration.framework"; + "INSTALL_PATH[sdk=iphone*]" = "$(SYSTEM_LIBRARY_DIR)/Frameworks/SystemConfiguration.framework"; + "INSTALL_PATH[sdk=watch*]" = "$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks/SystemConfiguration.framework"; PRODUCT_NAME = SCHelper; SDKROOT = iphoneos.internal; SUPPORTED_PLATFORMS = iphoneos; @@ -7381,98 +6985,62 @@ }; 15A5A2670D5B94190087BDA0 /* Debug */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 15FD147B0D594FE700F9409C /* SimulatorSupport.xcconfig */; buildSettings = { + DEFINES_MODULE = YES; HEADER_SEARCH_PATHS = ( "$(SDKROOT)$(SYSTEM_LIBRARY_DIR)/Frameworks/System.framework/PrivateHeaders", "$(SDKROOT)/usr/local/include/ppp", ); INFOPLIST_FILE = "SystemConfiguration.fproj/Info-Embedded.plist"; INSTALLHDRS_SCRIPT_PHASE = YES; - INSTALL_MODE_FLAG = "a-w,a+rX"; - INSTALL_PATH_ACTUAL = "$(SYSTEM_LIBRARY_DIR)/Frameworks"; + "INSTALL_PATH[sdk=appletv*]" = "$(SYSTEM_LIBRARY_DIR)/Frameworks"; + "INSTALL_PATH[sdk=iphone*]" = "$(SYSTEM_LIBRARY_DIR)/Frameworks"; + "INSTALL_PATH[sdk=watch*]" = "$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks"; LIBRARY_SEARCH_PATHS = "$(SYMROOT)"; + MODULEMAP_FILE = SystemConfiguration.fproj/Modules/sc_modules.modulemap; OTHER_CFLAGS = ( "-idirafter", "$(SYSTEM_LIBRARY_DIR)/Frameworks/System.framework/PrivateHeaders", ); PRODUCT_NAME = SystemConfiguration; + SDKROOT = iphoneos.internal; + SUPPORTED_PLATFORMS = iphonesimulator; + "USING_PRIVATE_SYSTEMCONFIGURATION_FRAMEWORK[sdk=appletv*]" = NO; + "USING_PRIVATE_SYSTEMCONFIGURATION_FRAMEWORK[sdk=iphone*]" = NO; + "USING_PRIVATE_SYSTEMCONFIGURATION_FRAMEWORK[sdk=watch*]" = YES; WRAPPER_EXTENSION = framework; }; name = Debug; }; 15A5A2680D5B94190087BDA0 /* Release */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 15FD147B0D594FE700F9409C /* SimulatorSupport.xcconfig */; buildSettings = { + DEFINES_MODULE = YES; HEADER_SEARCH_PATHS = ( "$(SDKROOT)$(SYSTEM_LIBRARY_DIR)/Frameworks/System.framework/PrivateHeaders", "$(SDKROOT)/usr/local/include/ppp", ); INFOPLIST_FILE = "SystemConfiguration.fproj/Info-Embedded.plist"; INSTALLHDRS_SCRIPT_PHASE = YES; - INSTALL_MODE_FLAG = "a-w,a+rX"; - INSTALL_PATH_ACTUAL = "$(SYSTEM_LIBRARY_DIR)/Frameworks"; + "INSTALL_PATH[sdk=appletv*]" = "$(SYSTEM_LIBRARY_DIR)/Frameworks"; + "INSTALL_PATH[sdk=iphone*]" = "$(SYSTEM_LIBRARY_DIR)/Frameworks"; + "INSTALL_PATH[sdk=watch*]" = "$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks"; LIBRARY_SEARCH_PATHS = "$(SYMROOT)"; + MODULEMAP_FILE = SystemConfiguration.fproj/Modules/sc_modules.modulemap; OTHER_CFLAGS = ( "-idirafter", "$(SYSTEM_LIBRARY_DIR)/Frameworks/System.framework/PrivateHeaders", ); PRODUCT_NAME = SystemConfiguration; + SDKROOT = iphoneos.internal; + SUPPORTED_PLATFORMS = iphonesimulator; + "USING_PRIVATE_SYSTEMCONFIGURATION_FRAMEWORK[sdk=appletv*]" = NO; + "USING_PRIVATE_SYSTEMCONFIGURATION_FRAMEWORK[sdk=iphone*]" = NO; + "USING_PRIVATE_SYSTEMCONFIGURATION_FRAMEWORK[sdk=watch*]" = YES; WRAPPER_EXTENSION = framework; }; name = Release; }; - 15AB751716EBFF3400FAA8CE /* Debug */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = 15FD147B0D594FE700F9409C /* SimulatorSupport.xcconfig */; - buildSettings = { - DEBUG_INFORMATION_FORMAT = dwarf; - INFOPLIST_FILE = "Plugins/SCNetworkReachability/Info-EmbeddedSimulator.plist"; - INSTALL_MODE_FLAG = "a-w,a+rX"; - INSTALL_PATH_ACTUAL = /usr/local/lib/SystemConfiguration; - LIBRARY_STYLE = STATIC; - PRODUCT_NAME = SCNetworkReachability_sim; - STRIP_INSTALLED_PRODUCT = NO; - }; - name = Debug; - }; - 15AB751816EBFF3400FAA8CE /* Release */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = 15FD147B0D594FE700F9409C /* SimulatorSupport.xcconfig */; - buildSettings = { - DEBUG_INFORMATION_FORMAT = dwarf; - INFOPLIST_FILE = "Plugins/SCNetworkReachability/Info-EmbeddedSimulator.plist"; - INSTALL_MODE_FLAG = "a-w,a+rX"; - INSTALL_PATH_ACTUAL = /usr/local/lib/SystemConfiguration; - LIBRARY_STYLE = STATIC; - PRODUCT_NAME = SCNetworkReachability_sim; - STRIP_INSTALLED_PRODUCT = NO; - }; - name = Release; - }; - 15AB751D16EBFF8A00FAA8CE /* Debug */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = 15FD147B0D594FE700F9409C /* SimulatorSupport.xcconfig */; - buildSettings = { - INFOPLIST_FILE = "Plugins/SCNetworkReachability/Info-EmbeddedSimulator.plist"; - INSTALL_MODE_FLAG = "a-w,a+rX"; - INSTALL_PATH_ACTUAL = /System/Library/SystemConfiguration; - PRODUCT_NAME = SCNetworkReachability; - }; - name = Debug; - }; - 15AB751E16EBFF8A00FAA8CE /* Release */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = 15FD147B0D594FE700F9409C /* SimulatorSupport.xcconfig */; - buildSettings = { - INFOPLIST_FILE = "Plugins/SCNetworkReachability/Info-EmbeddedSimulator.plist"; - INSTALL_MODE_FLAG = "a-w,a+rX"; - INSTALL_PATH_ACTUAL = /System/Library/SystemConfiguration; - PRODUCT_NAME = SCNetworkReachability; - }; - name = Release; - }; 15C64A1F0F684C3300D78394 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { @@ -7494,6 +7062,7 @@ buildSettings = { INSTALL_PATH = /usr/local/lib/system; PRODUCT_NAME = "configd_libSystem (Embedded)"; + SUPPORTED_PLATFORMS = iphoneos; }; name = Debug; }; @@ -7502,108 +7071,109 @@ buildSettings = { INSTALL_PATH = /usr/local/lib/system; PRODUCT_NAME = "configd_libSystem (Embedded)"; + SUPPORTED_PLATFORMS = iphoneos; }; name = Release; }; 15D3082516F3E4DA00014F82 /* Debug */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 15FD147B0D594FE700F9409C /* SimulatorSupport.xcconfig */; buildSettings = { DEBUG_INFORMATION_FORMAT = dwarf; HEADER_SEARCH_PATHS = "$(SDKROOT)$(SYSTEM_LIBRARY_DIR)/Frameworks/System.framework/PrivateHeaders"; - INSTALL_MODE_FLAG = "a-w,a+rX"; - INSTALL_PATH_ACTUAL = /usr/local/lib/SystemConfiguration; + INSTALL_PATH = /usr/local/lib/SystemConfiguration; LIBRARY_STYLE = STATIC; PRODUCT_NAME = SimulatorSupport_sim; + SDKROOT = iphoneos.internal; STRIP_INSTALLED_PRODUCT = NO; + SUPPORTED_PLATFORMS = iphonesimulator; }; name = Debug; }; 15D3082616F3E4DA00014F82 /* Release */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 15FD147B0D594FE700F9409C /* SimulatorSupport.xcconfig */; buildSettings = { DEBUG_INFORMATION_FORMAT = dwarf; HEADER_SEARCH_PATHS = "$(SDKROOT)$(SYSTEM_LIBRARY_DIR)/Frameworks/System.framework/PrivateHeaders"; - INSTALL_MODE_FLAG = "a-w,a+rX"; - INSTALL_PATH_ACTUAL = /usr/local/lib/SystemConfiguration; + INSTALL_PATH = /usr/local/lib/SystemConfiguration; LIBRARY_STYLE = STATIC; PRODUCT_NAME = SimulatorSupport_sim; + SDKROOT = iphoneos.internal; STRIP_INSTALLED_PRODUCT = NO; + SUPPORTED_PLATFORMS = iphonesimulator; }; name = Release; }; 15D3082B16F3E4E100014F82 /* Debug */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 15FD147B0D594FE700F9409C /* SimulatorSupport.xcconfig */; buildSettings = { INFOPLIST_FILE = Plugins/SimulatorSupport/Info.plist; - INSTALL_MODE_FLAG = "a-w,a+rX"; - INSTALL_PATH_ACTUAL = /System/Library/SystemConfiguration; + INSTALL_PATH = /System/Library/SystemConfiguration; PRODUCT_NAME = SimulatorSupport; + SDKROOT = iphoneos.internal; + SUPPORTED_PLATFORMS = iphonesimulator; }; name = Debug; }; 15D3082C16F3E4E100014F82 /* Release */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 15FD147B0D594FE700F9409C /* SimulatorSupport.xcconfig */; buildSettings = { INFOPLIST_FILE = Plugins/SimulatorSupport/Info.plist; - INSTALL_MODE_FLAG = "a-w,a+rX"; - INSTALL_PATH_ACTUAL = /System/Library/SystemConfiguration; + INSTALL_PATH = /System/Library/SystemConfiguration; PRODUCT_NAME = SimulatorSupport; + SDKROOT = iphoneos.internal; + SUPPORTED_PLATFORMS = iphonesimulator; }; name = Release; }; 15E1B05716EBAE3C00E5F06F /* Debug */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 15FD147B0D594FE700F9409C /* SimulatorSupport.xcconfig */; buildSettings = { DEBUG_INFORMATION_FORMAT = dwarf; HEADER_SEARCH_PATHS = "$(SDKROOT)$(SYSTEM_LIBRARY_DIR)/Frameworks/System.framework/PrivateHeaders"; INFOPLIST_FILE = "Plugins/IPMonitor/Info-EmbeddedSimulator.plist"; - INSTALL_MODE_FLAG = "a-w,a+rX"; - INSTALL_PATH_ACTUAL = /usr/local/lib/SystemConfiguration; + INSTALL_PATH = /usr/local/lib/SystemConfiguration; LIBRARY_STYLE = STATIC; PRODUCT_NAME = IPMonitor_sim; + SDKROOT = iphoneos.internal; STRIP_INSTALLED_PRODUCT = NO; + SUPPORTED_PLATFORMS = iphonesimulator; }; name = Debug; }; 15E1B05816EBAE3C00E5F06F /* Release */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 15FD147B0D594FE700F9409C /* SimulatorSupport.xcconfig */; buildSettings = { DEBUG_INFORMATION_FORMAT = dwarf; HEADER_SEARCH_PATHS = "$(SDKROOT)$(SYSTEM_LIBRARY_DIR)/Frameworks/System.framework/PrivateHeaders"; INFOPLIST_FILE = "Plugins/IPMonitor/Info-EmbeddedSimulator.plist"; - INSTALL_MODE_FLAG = "a-w,a+rX"; - INSTALL_PATH_ACTUAL = /usr/local/lib/SystemConfiguration; + INSTALL_PATH = /usr/local/lib/SystemConfiguration; LIBRARY_STYLE = STATIC; PRODUCT_NAME = IPMonitor_sim; + SDKROOT = iphoneos.internal; STRIP_INSTALLED_PRODUCT = NO; + SUPPORTED_PLATFORMS = iphonesimulator; }; name = Release; }; 15E1B05F16EBAE7800E5F06F /* Debug */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 15FD147B0D594FE700F9409C /* SimulatorSupport.xcconfig */; buildSettings = { INFOPLIST_FILE = "Plugins/IPMonitor/Info-EmbeddedSimulator.plist"; - INSTALL_MODE_FLAG = "a-w,a+rX"; - INSTALL_PATH_ACTUAL = /System/Library/SystemConfiguration; + INSTALL_PATH = /System/Library/SystemConfiguration; PRODUCT_NAME = IPMonitor; + SDKROOT = iphoneos.internal; + SUPPORTED_PLATFORMS = iphonesimulator; }; name = Debug; }; 15E1B06016EBAE7800E5F06F /* Release */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 15FD147B0D594FE700F9409C /* SimulatorSupport.xcconfig */; buildSettings = { INFOPLIST_FILE = "Plugins/IPMonitor/Info-EmbeddedSimulator.plist"; - INSTALL_MODE_FLAG = "a-w,a+rX"; - INSTALL_PATH_ACTUAL = /System/Library/SystemConfiguration; + INSTALL_PATH = /System/Library/SystemConfiguration; PRODUCT_NAME = IPMonitor; + SDKROOT = iphoneos.internal; + SUPPORTED_PLATFORMS = iphonesimulator; }; name = Release; }; @@ -7623,17 +7193,170 @@ }; 15FD13C70D59485000F9409C /* Debug */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 15FD147B0D594FE700F9409C /* SimulatorSupport.xcconfig */; buildSettings = { - PRODUCT_NAME = "configd (Aggregate/EmbeddedSimulator)"; + PRODUCT_NAME = configdAggregateEmbeddedSimulator; + SUPPORTED_PLATFORMS = iphonesimulator; }; name = Debug; }; 15FD13C80D59485000F9409C /* Release */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 15FD147B0D594FE700F9409C /* SimulatorSupport.xcconfig */; buildSettings = { - PRODUCT_NAME = "configd (Aggregate/EmbeddedSimulator)"; + PRODUCT_NAME = configdAggregateEmbeddedSimulator; + SUPPORTED_PLATFORMS = iphonesimulator; + }; + name = Release; + }; + 72D3E6631AE6EA3A00DB4C69 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_SYMBOLS_PRIVATE_EXTERN = NO; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.11; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = macosx; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + }; + name = Debug; + }; + 72D3E6641AE6EA3A00DB4C69 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.11; + MTL_ENABLE_DEBUG_INFO = NO; + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = macosx; + }; + name = Release; + }; + 72D3E66E1AE6EAF600DB4C69 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_SYMBOLS_PRIVATE_EXTERN = NO; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.11; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = macosx; + }; + name = Debug; + }; + 72D3E66F1AE6EAF600DB4C69 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.11; + MTL_ENABLE_DEBUG_INFO = NO; + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = macosx; }; name = Release; }; @@ -7676,60 +7399,6 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; - 15213FFF0E93E9F600DACD2C /* Build configuration list for PBXNativeTarget "Logger.bundle" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 15213FFC0E93E9F600DACD2C /* Debug */, - 15213FFD0E93E9F600DACD2C /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 1528BFDF1357305400691881 /* Build configuration list for PBXNativeTarget "SCNetworkReachability" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 1528BFE01357305400691881 /* Debug */, - 1528BFE11357305400691881 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 1528BFE51357309700691881 /* Build configuration list for PBXNativeTarget "SCNetworkReachability.bundle" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 1528BFE61357309700691881 /* Debug */, - 1528BFE71357309700691881 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 1528BFF413573FEE00691881 /* Build configuration list for PBXNativeTarget "SCNetworkReachability-Embedded" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 1528BFF513573FEE00691881 /* Debug */, - 1528BFF613573FEE00691881 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 1528BFFB13573FF500691881 /* Build configuration list for PBXNativeTarget "SCNetworkReachability.bundle-Embedded" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 1528BFFC13573FF500691881 /* Debug */, - 1528BFFD13573FF500691881 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 156CA4820EF853BB00C59A18 /* Build configuration list for PBXNativeTarget "Logger.bundle-Embedded" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 156CA4830EF853BB00C59A18 /* Debug */, - 156CA4840EF853BB00C59A18 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; 156EB5DA0905594A00EEF749 /* Build configuration list for PBXNativeTarget "libsystem_configuration" */ = { isa = XCConfigurationList; buildConfigurations = ( @@ -8135,24 +7804,6 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; - 15AB751616EBFF3400FAA8CE /* Build configuration list for PBXNativeTarget "SCNetworkReachability-EmbeddedSimulator" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 15AB751716EBFF3400FAA8CE /* Debug */, - 15AB751816EBFF3400FAA8CE /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 15AB751C16EBFF8A00FAA8CE /* Build configuration list for PBXNativeTarget "SCNetworkReachability.bundle-EmbeddedSimulator" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 15AB751D16EBFF8A00FAA8CE /* Debug */, - 15AB751E16EBFF8A00FAA8CE /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; 15C64A270F684C6B00D78394 /* Build configuration list for PBXAggregateTarget "configd_libSystem" */ = { isa = XCConfigurationList; buildConfigurations = ( @@ -8225,6 +7876,24 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; + 72D3E6621AE6EA3A00DB4C69 /* Build configuration list for PBXNativeTarget "SCTest-Swift" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 72D3E6631AE6EA3A00DB4C69 /* Debug */, + 72D3E6641AE6EA3A00DB4C69 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 72D3E66D1AE6EAF600DB4C69 /* Build configuration list for PBXNativeTarget "SCTest-ObjC" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 72D3E66E1AE6EAF600DB4C69 /* Debug */, + 72D3E66F1AE6EAF600DB4C69 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; /* End XCConfigurationList section */ }; rootObject = 15CB6A7705C0722B0099E85F /* Project object */; diff --git a/dnsinfo/dnsinfo.h b/dnsinfo/dnsinfo.h index 60be01a..d0239a9 100644 --- a/dnsinfo/dnsinfo.h +++ b/dnsinfo/dnsinfo.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004-2006, 2008, 2009, 2011-2013 Apple Inc. All rights reserved. + * Copyright (c) 2004-2006, 2008, 2009, 2011-2013, 2015 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -35,7 +35,7 @@ #include #include -#define DNSINFO_VERSION 20130402 +#define DNSINFO_VERSION 20140114 #define DEFAULT_SEARCH_ORDER 200000 /* search order for the "default" resolver domain name */ @@ -74,7 +74,8 @@ typedef struct { DNS_VAR(uint32_t, flags); DNS_VAR(uint32_t, reach_flags); /* SCNetworkReachabilityFlags */ DNS_VAR(uint32_t, service_identifier); - DNS_VAR(uint32_t, reserved[4]); + DNS_PTR(char *, cid); /* configuration identifer */ + DNS_VAR(uint32_t, reserved[2]); } dns_resolver_t; #pragma pack() diff --git a/dnsinfo/dnsinfo_copy.c b/dnsinfo/dnsinfo_copy.c index 81ef601..bd494f3 100644 --- a/dnsinfo/dnsinfo_copy.c +++ b/dnsinfo/dnsinfo_copy.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2006, 2008-2013 Apple Inc. All rights reserved. + * Copyright (c) 2004, 2006, 2008-2013, 2015 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -39,277 +39,7 @@ #include "libSystemConfiguration_client.h" #include "dnsinfo.h" #include "dnsinfo_private.h" - -typedef uint32_t getflags; - -static boolean_t -add_list(void **padding, uint32_t *n_padding, int32_t count, int32_t size, void **list) -{ - int32_t need; - - need = count * size; - if (need > *n_padding) { - return FALSE; - } - - *list = (need == 0) ? NULL : *padding; - *padding += need; - *n_padding -= need; - return TRUE; -} - - -#define DNS_CONFIG_BUF_MAX 1024*1024 - - -static dns_resolver_t * -expand_resolver(_dns_resolver_buf_t *buf, uint32_t n_buf, void **padding, uint32_t *n_padding) -{ - dns_attribute_t *attribute; - uint32_t n_attribute; - int32_t n_nameserver = 0; - int32_t n_search = 0; - int32_t n_sortaddr = 0; - dns_resolver_t *resolver = (dns_resolver_t *)&buf->resolver; - - if (n_buf < sizeof(_dns_resolver_buf_t)) { - goto error; - } - - // initialize domain - - resolver->domain = NULL; - - // initialize nameserver list - - resolver->n_nameserver = ntohl(resolver->n_nameserver); - if (!add_list(padding, - n_padding, - resolver->n_nameserver, - sizeof(DNS_PTR(struct sockaddr *, x)), - (void **)&resolver->nameserver)) { - goto error; - } - - // initialize port - - resolver->port = ntohs(resolver->port); - - // initialize search list - - resolver->n_search = ntohl(resolver->n_search); - if (!add_list(padding, - n_padding, - resolver->n_search, - sizeof(DNS_PTR(char *, x)), - (void **)&resolver->search)) { - goto error; - } - - // initialize sortaddr list - - resolver->n_sortaddr = ntohl(resolver->n_sortaddr); - if (!add_list(padding, - n_padding, - resolver->n_sortaddr, - sizeof(DNS_PTR(dns_sortaddr_t *, x)), - (void **)&resolver->sortaddr)) { - goto error; - } - - // initialize options - - resolver->options = NULL; - - // initialize timeout - - resolver->timeout = ntohl(resolver->timeout); - - // initialize search_order - - resolver->search_order = ntohl(resolver->search_order); - - // initialize if_index - - resolver->if_index = ntohl(resolver->if_index); - - // initialize service_identifier - - resolver->service_identifier = ntohl(resolver->service_identifier); - - // initialize flags - - resolver->flags = ntohl(resolver->flags); - - // initialize SCNetworkReachability flags - - resolver->reach_flags = ntohl(resolver->reach_flags); - - // process resolver buffer "attribute" data - - n_attribute = n_buf - sizeof(_dns_resolver_buf_t); - /* ALIGN: alignment not assumed, using accessors */ - attribute = (dns_attribute_t *)(void *)&buf->attribute[0]; - if (n_attribute != ntohl(buf->n_attribute)) { - goto error; - } - - while (n_attribute >= sizeof(dns_attribute_t)) { - uint32_t attribute_length = ntohl(attribute->length); - - switch (ntohl(attribute->type)) { - case RESOLVER_ATTRIBUTE_DOMAIN : - resolver->domain = (char *)&attribute->attribute[0]; - break; - - case RESOLVER_ATTRIBUTE_ADDRESS : - resolver->nameserver[n_nameserver++] = (struct sockaddr *)&attribute->attribute[0]; - break; - - case RESOLVER_ATTRIBUTE_SEARCH : - resolver->search[n_search++] = (char *)&attribute->attribute[0]; - break; - - case RESOLVER_ATTRIBUTE_SORTADDR : - resolver->sortaddr[n_sortaddr++] = (dns_sortaddr_t *)(void *)&attribute->attribute[0]; - break; - - case RESOLVER_ATTRIBUTE_OPTIONS : - resolver->options = (char *)&attribute->attribute[0]; - break; - - default : - break; - } - - attribute = (dns_attribute_t *)((void *)attribute + attribute_length); - n_attribute -= attribute_length; - } - - if ((n_nameserver != resolver->n_nameserver) || - (n_search != resolver->n_search ) || - (n_sortaddr != resolver->n_sortaddr )) { - goto error; - } - - return resolver; - - error : - - return NULL; -} - - -static dns_config_t * -expand_config(_dns_config_buf_t *buf) -{ - dns_attribute_t *attribute; - dns_config_t *config = (dns_config_t *)buf; - uint32_t n_attribute; - uint32_t n_padding; - int32_t n_resolver = 0; - int32_t n_scoped_resolver = 0; - int32_t n_service_specific_resolver = 0; - void *padding; - - // establish padding - - padding = &buf->attribute[ntohl(buf->n_attribute)]; - n_padding = ntohl(buf->n_padding); - - // initialize resolver lists - - config->n_resolver = ntohl(config->n_resolver); - if (!add_list(&padding, - &n_padding, - config->n_resolver, - sizeof(DNS_PTR(dns_resolver_t *, x)), - (void **)&config->resolver)) { - goto error; - } - - config->n_scoped_resolver = ntohl(config->n_scoped_resolver); - if (!add_list(&padding, - &n_padding, - config->n_scoped_resolver, - sizeof(DNS_PTR(dns_resolver_t *, x)), - (void **)&config->scoped_resolver)) { - goto error; - } - - config->n_service_specific_resolver = ntohl(config->n_service_specific_resolver); - if (!add_list(&padding, - &n_padding, - config->n_service_specific_resolver, - sizeof(DNS_PTR(dns_resolver_t *, x)), - (void **)&config->service_specific_resolver)) { - goto error; - } - - // process configuration buffer "attribute" data - - n_attribute = ntohl(buf->n_attribute); - attribute = (dns_attribute_t *)(void *)&buf->attribute[0]; - - while (n_attribute >= sizeof(dns_attribute_t)) { - uint32_t attribute_length = ntohl(attribute->length); - uint32_t attribute_type = ntohl(attribute->type); - - switch (attribute_type) { - case CONFIG_ATTRIBUTE_RESOLVER : - case CONFIG_ATTRIBUTE_SCOPED_RESOLVER : - case CONFIG_ATTRIBUTE_SERVICE_SPECIFIC_RESOLVER : { - dns_resolver_t *resolver; - - // expand resolver buffer - - resolver = expand_resolver((_dns_resolver_buf_t *)(void *)&attribute->attribute[0], - attribute_length - sizeof(dns_attribute_t), - &padding, - &n_padding); - if (resolver == NULL) { - goto error; - } - - // add resolver to config list - - if (attribute_type == CONFIG_ATTRIBUTE_RESOLVER) { - config->resolver[n_resolver++] = resolver; - } else if (attribute_type == CONFIG_ATTRIBUTE_SCOPED_RESOLVER) { - config->scoped_resolver[n_scoped_resolver++] = resolver; - } else if (attribute_type == CONFIG_ATTRIBUTE_SERVICE_SPECIFIC_RESOLVER) { - config->service_specific_resolver[n_service_specific_resolver++] = resolver; - } - - break; - } - - default : - break; - } - - attribute = (dns_attribute_t *)((void *)attribute + attribute_length); - n_attribute -= attribute_length; - } - - if (n_resolver != config->n_resolver) { - goto error; - } - - if (n_scoped_resolver != config->n_scoped_resolver) { - goto error; - } - - if (n_service_specific_resolver != config->n_service_specific_resolver) { - goto error; - } - - return config; - - error : - - return NULL; -} +#include "dnsinfo_internal.h" const char * @@ -317,11 +47,7 @@ dns_configuration_notify_key() { const char *key; -#if !TARGET_IPHONE_SIMULATOR key = "com.apple.system.SystemConfiguration.dns_configuration"; -#else // !TARGET_IPHONE_SIMULATOR - key = "com.apple.iOS_Simulator.SystemConfiguration.dns_configuration"; -#endif // !TARGET_IPHONE_SIMULATOR return key; } @@ -431,7 +157,7 @@ dns_configuration_copy() if (buf != NULL) { /* ALIGN: cast okay since _dns_config_buf_t is int aligned */ - config = expand_config((_dns_config_buf_t *)(void *)buf); + config = _dns_configuration_expand_config((_dns_config_buf_t *)(void *)buf); if (config == NULL) { free(buf); } diff --git a/dnsinfo/dnsinfo_create.c b/dnsinfo/dnsinfo_create.c index 5fe83ca..d528c07 100644 --- a/dnsinfo/dnsinfo_create.c +++ b/dnsinfo/dnsinfo_create.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004-2006, 2009, 2011-2013 Apple Inc. All rights reserved. + * Copyright (c) 2004-2006, 2009, 2011-2013, 2015 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -350,6 +350,15 @@ _dns_resolver_add_sortaddr(dns_create_resolver_t *_resolver, dns_sortaddr_t *sor } +__private_extern__ +void +_dns_resolver_set_configuration_identifier(dns_create_resolver_t *_resolver, const char *cid) +{ + _dns_resolver_add_attribute(_resolver, RESOLVER_ATTRIBUTE_CONFIGURATION_ID, (uint32_t)strlen(cid) + 1, (void *)cid); + return; +} + + __private_extern__ void _dns_resolver_set_domain(dns_create_resolver_t *_resolver, const char *domain) diff --git a/dnsinfo/dnsinfo_create.h b/dnsinfo/dnsinfo_create.h index decc575..d03b32e 100644 --- a/dnsinfo/dnsinfo_create.h +++ b/dnsinfo/dnsinfo_create.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004-2006, 2008, 2009, 2011-2013 Apple Inc. All rights reserved. + * Copyright (c) 2004-2006, 2008, 2009, 2011-2013, 2015 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -89,6 +89,11 @@ void _dns_resolver_add_sortaddr (dns_create_resolver_t *_resolver, dns_sortaddr_t *sortaddr) __OSX_AVAILABLE_STARTING(__MAC_10_4,__IPHONE_2_0); +void +_dns_resolver_set_configuration_identifier + (dns_create_resolver_t *_resolver, + const char *config_identifier) __OSX_AVAILABLE_STARTING(__MAC_10_11,__IPHONE_9_0); + void _dns_resolver_set_flags (dns_create_resolver_t *_resolver, uint32_t flags) __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_4_0); @@ -114,8 +119,9 @@ _dns_resolver_set_timeout (dns_create_resolver_t *_resolver, uint32_t timeout) __OSX_AVAILABLE_STARTING(__MAC_10_4,__IPHONE_2_0); void -_dns_resolver_set_service_identifier (dns_create_resolver_t *_resolver, - uint32_t service_identifier) __OSX_AVAILABLE_STARTING(__MAC_10_9,__IPHONE_7_0); +_dns_resolver_set_service_identifier + (dns_create_resolver_t *_resolver, + uint32_t service_identifier) __OSX_AVAILABLE_STARTING(__MAC_10_9,__IPHONE_7_0); void _dns_resolver_free (dns_create_resolver_t *_resolver) __OSX_AVAILABLE_STARTING(__MAC_10_4,__IPHONE_2_0); diff --git a/dnsinfo/dnsinfo_flatfile.c b/dnsinfo/dnsinfo_flatfile.c index a52be6b..bd4e449 100644 --- a/dnsinfo/dnsinfo_flatfile.c +++ b/dnsinfo/dnsinfo_flatfile.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2011, 2012, 2014 Apple Inc. All rights reserved. + * Copyright (c) 2009, 2011, 2012, 2014, 2015 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -587,7 +587,7 @@ main(int argc, char **argv) buf = malloc(n_config + n_padding); bcopy((void *)config_buf, buf, n_config); bzero(&buf[n_config], n_padding); - config = expand_config((_dns_config_buf_t *)buf); + config = _dns_configuration_expand_config((_dns_config_buf_t *)buf); return 0; } diff --git a/dnsinfo/dnsinfo_internal.h b/dnsinfo/dnsinfo_internal.h index a7dc643..3d695f1 100644 --- a/dnsinfo/dnsinfo_internal.h +++ b/dnsinfo/dnsinfo_internal.h @@ -1,15 +1,15 @@ /* - * Copyright (c) 2013 Apple Inc. All rights reserved. + * Copyright (c) 2013, 2015 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ - * + * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. - * + * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, @@ -17,7 +17,7 @@ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. - * + * * @APPLE_LICENSE_HEADER_END@ */ @@ -33,29 +33,341 @@ #include #include +#include "dnsinfo_private.h" + __BEGIN_DECLS + +#ifndef my_log +#define MY_LOG_DEFINED_LOCALLY +#define my_log(__level, fmt, ...) SC_log(__level, fmt, ## __VA_ARGS__) +#endif // !my_log + + +#define DNS_CONFIG_BUF_MAX 1024*1024 + + +/* + * claim space for a list [of pointers] from the expanded DNS configuration padding + */ +static __inline__ boolean_t +__dns_configuration_expand_add_list(void **padding, uint32_t *n_padding, int32_t count, int32_t size, void **list) +{ + int32_t need; + + need = count * size; + if (need > *n_padding) { + return FALSE; + } + + *list = (need == 0) ? NULL : *padding; + *padding += need; + *n_padding -= need; + return TRUE; +} + + +/* + * expand a DNS "resolver" from the provided buffer + */ +static __inline__ dns_resolver_t * +_dns_configuration_expand_resolver(_dns_resolver_buf_t *buf, uint32_t n_buf, void **padding, uint32_t *n_padding) +{ + dns_attribute_t *attribute; + uint32_t n_attribute; + int32_t n_nameserver = 0; + int32_t n_search = 0; + int32_t n_sortaddr = 0; + dns_resolver_t *resolver = (dns_resolver_t *)&buf->resolver; + + if (n_buf < sizeof(_dns_resolver_buf_t)) { + goto error; + } + + // initialize domain + + resolver->domain = NULL; + + // initialize nameserver list + + resolver->n_nameserver = ntohl(resolver->n_nameserver); + if (!__dns_configuration_expand_add_list(padding, + n_padding, + resolver->n_nameserver, + sizeof(DNS_PTR(struct sockaddr *, x)), + (void **)&resolver->nameserver)) { + goto error; + } + + // initialize port + + resolver->port = ntohs(resolver->port); + + // initialize search list + + resolver->n_search = ntohl(resolver->n_search); + if (!__dns_configuration_expand_add_list(padding, + n_padding, + resolver->n_search, + sizeof(DNS_PTR(char *, x)), + (void **)&resolver->search)) { + goto error; + } + + // initialize sortaddr list + + resolver->n_sortaddr = ntohl(resolver->n_sortaddr); + if (!__dns_configuration_expand_add_list(padding, + n_padding, + resolver->n_sortaddr, + sizeof(DNS_PTR(dns_sortaddr_t *, x)), + (void **)&resolver->sortaddr)) { + goto error; + } + + // initialize options + + resolver->options = NULL; + + // initialize timeout + + resolver->timeout = ntohl(resolver->timeout); + + // initialize search_order + + resolver->search_order = ntohl(resolver->search_order); + + // initialize if_index + + resolver->if_index = ntohl(resolver->if_index); + + // initialize service_identifier + + resolver->service_identifier = ntohl(resolver->service_identifier); + + // initialize flags + + resolver->flags = ntohl(resolver->flags); + + // initialize SCNetworkReachability flags + + resolver->reach_flags = ntohl(resolver->reach_flags); + + // process resolver buffer "attribute" data + + n_attribute = n_buf - sizeof(_dns_resolver_buf_t); + /* ALIGN: alignment not assumed, using accessors */ + attribute = (dns_attribute_t *)(void *)&buf->attribute[0]; + if (n_attribute != ntohl(buf->n_attribute)) { + goto error; + } + + while (n_attribute >= sizeof(dns_attribute_t)) { + uint32_t attribute_length = ntohl(attribute->length); + + switch (ntohl(attribute->type)) { + case RESOLVER_ATTRIBUTE_DOMAIN : + resolver->domain = (char *)&attribute->attribute[0]; + break; + + case RESOLVER_ATTRIBUTE_ADDRESS : + if (resolver->nameserver == NULL) { + goto error; + } + resolver->nameserver[n_nameserver++] = (struct sockaddr *)&attribute->attribute[0]; + break; + + case RESOLVER_ATTRIBUTE_SEARCH : + if (resolver->search == NULL) { + goto error; + } + resolver->search[n_search++] = (char *)&attribute->attribute[0]; + break; + + case RESOLVER_ATTRIBUTE_SORTADDR : + if (resolver->sortaddr == NULL) { + goto error; + } + resolver->sortaddr[n_sortaddr++] = (dns_sortaddr_t *)(void *)&attribute->attribute[0]; + break; + + case RESOLVER_ATTRIBUTE_OPTIONS : + resolver->options = (char *)&attribute->attribute[0]; + break; + + case RESOLVER_ATTRIBUTE_CONFIGURATION_ID : + resolver->cid = (char *)&attribute->attribute[0]; + break; + + default : + break; + } + + attribute = (dns_attribute_t *)((void *)attribute + attribute_length); + n_attribute -= attribute_length; + } + + if ((n_nameserver != resolver->n_nameserver) || + (n_search != resolver->n_search ) || + (n_sortaddr != resolver->n_sortaddr )) { + goto error; + } + + return resolver; + + error : + + return NULL; +} + + +/* + * expand a DNS "configuration" from the provided buffer + */ +static __inline__ dns_config_t * +_dns_configuration_expand_config(_dns_config_buf_t *buf) +{ + dns_attribute_t *attribute; + dns_config_t *config = (dns_config_t *)buf; + uint32_t n_attribute; + uint32_t n_padding; + int32_t n_resolver = 0; + int32_t n_scoped_resolver = 0; + int32_t n_service_specific_resolver = 0; + void *padding; + + // establish padding + + padding = &buf->attribute[ntohl(buf->n_attribute)]; + n_padding = ntohl(buf->n_padding); + + // initialize resolver lists + + config->n_resolver = ntohl(config->n_resolver); + if (!__dns_configuration_expand_add_list(&padding, + &n_padding, + config->n_resolver, + sizeof(DNS_PTR(dns_resolver_t *, x)), + (void **)&config->resolver)) { + goto error; + } + + config->n_scoped_resolver = ntohl(config->n_scoped_resolver); + if (!__dns_configuration_expand_add_list(&padding, + &n_padding, + config->n_scoped_resolver, + sizeof(DNS_PTR(dns_resolver_t *, x)), + (void **)&config->scoped_resolver)) { + goto error; + } + + config->n_service_specific_resolver = ntohl(config->n_service_specific_resolver); + if (!__dns_configuration_expand_add_list(&padding, + &n_padding, + config->n_service_specific_resolver, + sizeof(DNS_PTR(dns_resolver_t *, x)), + (void **)&config->service_specific_resolver)) { + goto error; + } + + // process configuration buffer "attribute" data + + n_attribute = ntohl(buf->n_attribute); + attribute = (dns_attribute_t *)(void *)&buf->attribute[0]; + + while (n_attribute >= sizeof(dns_attribute_t)) { + uint32_t attribute_length = ntohl(attribute->length); + uint32_t attribute_type = ntohl(attribute->type); + + switch (attribute_type) { + case CONFIG_ATTRIBUTE_RESOLVER : + case CONFIG_ATTRIBUTE_SCOPED_RESOLVER : + case CONFIG_ATTRIBUTE_SERVICE_SPECIFIC_RESOLVER : { + dns_resolver_t *resolver; + + // expand resolver buffer + + resolver = _dns_configuration_expand_resolver((_dns_resolver_buf_t *)(void *)&attribute->attribute[0], + attribute_length - sizeof(dns_attribute_t), + &padding, + &n_padding); + if (resolver == NULL) { + goto error; + } + + // add resolver to config list + + if (attribute_type == CONFIG_ATTRIBUTE_RESOLVER) { + if (config->resolver == NULL) { + goto error; + } + config->resolver[n_resolver++] = resolver; + } else if (attribute_type == CONFIG_ATTRIBUTE_SCOPED_RESOLVER) { + if (config->scoped_resolver == NULL) { + goto error; + } + config->scoped_resolver[n_scoped_resolver++] = resolver; + } else if (attribute_type == CONFIG_ATTRIBUTE_SERVICE_SPECIFIC_RESOLVER) { + if (config->service_specific_resolver == NULL) { + goto error; + } + config->service_specific_resolver[n_service_specific_resolver++] = resolver; + } + + break; + } + + default : + break; + } + + attribute = (dns_attribute_t *)((void *)attribute + attribute_length); + n_attribute -= attribute_length; + } + + if (n_resolver != config->n_resolver) { + goto error; + } + + if (n_scoped_resolver != config->n_scoped_resolver) { + goto error; + } + + if (n_service_specific_resolver != config->n_service_specific_resolver) { + goto error; + } + + return config; + + error : + + return NULL; +} + + static __inline__ void -_dns_resolver_print(dns_resolver_t *resolver, int index) +_dns_resolver_log(dns_resolver_t *resolver, int index, Boolean debug) { - int i; + int i; + uint32_t flags; + CFMutableStringRef str; - SCPrint(TRUE, stdout, CFSTR("\nresolver #%d\n"), index); + my_log(LOG_INFO, "\nresolver #%d", index); if (resolver->domain != NULL) { - SCPrint(TRUE, stdout, CFSTR(" domain : %s\n"), resolver->domain); + my_log(LOG_INFO, " domain : %s", resolver->domain); } for (i = 0; i < resolver->n_search; i++) { - SCPrint(TRUE, stdout, CFSTR(" search domain[%d] : %s\n"), i, resolver->search[i]); + my_log(LOG_INFO, " search domain[%d] : %s", i, resolver->search[i]); } for (i = 0; i < resolver->n_nameserver; i++) { char buf[128]; _SC_sockaddr_to_string(resolver->nameserver[i], buf, sizeof(buf)); - SCPrint(TRUE, stdout, CFSTR(" nameserver[%d] : %s\n"), i, buf); + my_log(LOG_INFO, " nameserver[%d] : %s", i, buf); } for (i = 0; i < resolver->n_sortaddr; i++) { @@ -64,19 +376,19 @@ _dns_resolver_print(dns_resolver_t *resolver, int index) (void)inet_ntop(AF_INET, &resolver->sortaddr[i]->address, abuf, sizeof(abuf)); (void)inet_ntop(AF_INET, &resolver->sortaddr[i]->mask, mbuf, sizeof(mbuf)); - SCPrint(TRUE, stdout, CFSTR(" sortaddr[%d] : %s/%s\n"), i, abuf, mbuf); + my_log(LOG_INFO, " sortaddr[%d] : %s/%s", i, abuf, mbuf); } if (resolver->options != NULL) { - SCPrint(TRUE, stdout, CFSTR(" options : %s\n"), resolver->options); + my_log(LOG_INFO, " options : %s", resolver->options); } if (resolver->port != 0) { - SCPrint(TRUE, stdout, CFSTR(" port : %hd\n"), resolver->port); + my_log(LOG_INFO, " port : %hd", resolver->port); } if (resolver->timeout != 0) { - SCPrint(TRUE, stdout, CFSTR(" timeout : %d\n"), resolver->timeout); + my_log(LOG_INFO, " timeout : %d", resolver->timeout); } if (resolver->if_index != 0) { @@ -84,60 +396,59 @@ _dns_resolver_print(dns_resolver_t *resolver, int index) char *if_name; if_name = if_indextoname(resolver->if_index, buf); - SCPrint(TRUE, stdout, CFSTR(" if_index : %d (%s)\n"), + my_log(LOG_INFO, " if_index : %d (%s)", resolver->if_index, (if_name != NULL) ? if_name : "?"); } if (resolver->service_identifier != 0) { - SCPrint(TRUE, stdout, CFSTR(" service_identifier : %d\n"), + my_log(LOG_INFO, " service_identifier : %d", resolver->service_identifier); } - if (resolver->flags != 0) { - uint32_t flags = resolver->flags; - - SCPrint(TRUE, stdout, CFSTR(" flags : ")); - SCPrint(_sc_debug, stdout, CFSTR("0x%08x ("), flags); - if (flags & DNS_RESOLVER_FLAGS_SCOPED) { - SCPrint(TRUE, stdout, CFSTR("Scoped")); - flags &= ~DNS_RESOLVER_FLAGS_SCOPED; - SCPrint(flags != 0, stdout, CFSTR(", ")); - } - if (flags & DNS_RESOLVER_FLAGS_SERVICE_SPECIFIC) { - SCPrint(TRUE, stdout, CFSTR("Service-specific")); - flags &= ~DNS_RESOLVER_FLAGS_SERVICE_SPECIFIC; - SCPrint(flags != 0, stdout, CFSTR(", ")); - } - if (flags & DNS_RESOLVER_FLAGS_REQUEST_A_RECORDS) { - SCPrint(TRUE, stdout, CFSTR("Request A records")); - flags &= ~DNS_RESOLVER_FLAGS_REQUEST_A_RECORDS; - SCPrint(flags != 0, stdout, CFSTR(", ")); - } - if (flags & DNS_RESOLVER_FLAGS_REQUEST_AAAA_RECORDS) { - SCPrint(TRUE, stdout, CFSTR("Request AAAA records")); - flags &= ~DNS_RESOLVER_FLAGS_REQUEST_AAAA_RECORDS; - SCPrint(flags != 0, stdout, CFSTR(", ")); - } - if (flags != 0) { - SCPrint(TRUE, stdout, CFSTR("0x%08x"), flags); - } - SCPrint(_sc_debug, stdout, CFSTR(")")); - SCPrint(TRUE, stdout, CFSTR("\n")); + flags = resolver->flags; + str = CFStringCreateMutable(NULL, 0); + CFStringAppend(str, CFSTR(" flags : ")); + if (debug) { + CFStringAppendFormat(str, NULL, CFSTR("0x%08x ("), flags); + } + if (flags & DNS_RESOLVER_FLAGS_SCOPED) { + flags &= ~DNS_RESOLVER_FLAGS_SCOPED; + CFStringAppendFormat(str, NULL, CFSTR("Scoped%s"), flags != 0 ? ", " : ""); + } + if (flags & DNS_RESOLVER_FLAGS_SERVICE_SPECIFIC) { + flags &= ~DNS_RESOLVER_FLAGS_SERVICE_SPECIFIC; + CFStringAppendFormat(str, NULL, CFSTR("Service-specific%s"), flags != 0 ? ", " : ""); + } + if (flags & DNS_RESOLVER_FLAGS_REQUEST_A_RECORDS) { + flags &= ~DNS_RESOLVER_FLAGS_REQUEST_A_RECORDS; + CFStringAppendFormat(str, NULL, CFSTR("Request A records%s"), flags != 0 ? ", " : ""); + } + if (flags & DNS_RESOLVER_FLAGS_REQUEST_AAAA_RECORDS) { + flags &= ~DNS_RESOLVER_FLAGS_REQUEST_AAAA_RECORDS; + CFStringAppendFormat(str, NULL, CFSTR("Request AAAA records%s"), flags != 0 ? ", " : ""); + } + if (flags != 0) { + CFStringAppendFormat(str, NULL, CFSTR("0x%08x"), flags); } + if (debug) { + CFStringAppend(str, CFSTR(")")); + } + my_log(LOG_INFO, "%@", str); + CFRelease(str); - if (resolver->reach_flags != 0) { - uint32_t flags = resolver->reach_flags; + str = (CFMutableStringRef)__SCNetworkReachabilityCopyFlags(resolver->reach_flags, + CFSTR(" reach : "), + debug); + my_log(LOG_INFO, "%@", str); + CFRelease(str); - SCPrint(TRUE, stdout, CFSTR(" reach : ")); - SCPrint(_sc_debug, stdout, CFSTR("0x%08x ("), flags); - __SCNetworkReachabilityPrintFlags(flags); - SCPrint(_sc_debug, stdout, CFSTR(")")); - SCPrint(TRUE, stdout, CFSTR("\n")); + if (resolver->search_order != 0) { + my_log(LOG_INFO, " order : %d", resolver->search_order); } - if (resolver->search_order != 0) { - SCPrint(TRUE, stdout, CFSTR(" order : %d\n"), resolver->search_order); + if (debug && (resolver->cid != NULL)) { + my_log(LOG_INFO, " config id: %s", resolver->cid); } return; @@ -145,41 +456,48 @@ _dns_resolver_print(dns_resolver_t *resolver, int index) static __inline__ void -_dns_configuration_print(dns_config_t *dns_config) +_dns_configuration_log(dns_config_t *dns_config, Boolean debug) { int i; - SCPrint(TRUE, stdout, CFSTR("DNS configuration\n")); + my_log(LOG_INFO, "DNS configuration"); for (i = 0; i < dns_config->n_resolver; i++) { dns_resolver_t *resolver = dns_config->resolver[i]; - _dns_resolver_print(resolver, i + 1); + _dns_resolver_log(resolver, i + 1, debug); } if ((dns_config->n_scoped_resolver > 0) && (dns_config->scoped_resolver != NULL)) { - SCPrint(TRUE, stdout, CFSTR("\nDNS configuration (for scoped queries)\n")); + my_log(LOG_INFO, "\nDNS configuration (for scoped queries)"); for (i = 0; i < dns_config->n_scoped_resolver; i++) { dns_resolver_t *resolver = dns_config->scoped_resolver[i]; - _dns_resolver_print(resolver, i + 1); + _dns_resolver_log(resolver, i + 1, debug); } } if ((dns_config->n_service_specific_resolver > 0) && (dns_config->service_specific_resolver != NULL)) { - SCPrint(TRUE, stdout, CFSTR("\nDNS configuration (for service-specific queries)\n")); + my_log(LOG_INFO, "\nDNS configuration (for service-specific queries)"); for (i = 0; i < dns_config->n_service_specific_resolver; i++) { dns_resolver_t *resolver = dns_config->service_specific_resolver[i]; - _dns_resolver_print(resolver, i + 1); + _dns_resolver_log(resolver, i + 1, debug); } } return; } + +#ifdef MY_LOG_DEFINED_LOCALLY +#undef my_log +#undef MY_LOG_DEFINED_LOCALLY +#endif // MY_LOG_DEFINED_LOCALLY + + __END_DECLS #endif /* !_S_DNSINFO_INTERNAL_H */ diff --git a/dnsinfo/dnsinfo_private.h b/dnsinfo/dnsinfo_private.h index d6e65b5..9c5168b 100644 --- a/dnsinfo/dnsinfo_private.h +++ b/dnsinfo/dnsinfo_private.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004-2006, 2008, 2009, 2012, 2013 Apple Inc. All rights reserved. + * Copyright (c) 2004-2006, 2008, 2009, 2012, 2013, 2015 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -172,6 +172,7 @@ enum { RESOLVER_ATTRIBUTE_SEARCH, RESOLVER_ATTRIBUTE_SORTADDR, RESOLVER_ATTRIBUTE_OPTIONS, + RESOLVER_ATTRIBUTE_CONFIGURATION_ID, }; diff --git a/dnsinfo/dnsinfo_server.c b/dnsinfo/dnsinfo_server.c index d006e7a..3e3b77d 100644 --- a/dnsinfo/dnsinfo_server.c +++ b/dnsinfo/dnsinfo_server.c @@ -1,15 +1,15 @@ /* - * Copyright (c) 2004-2008, 2011-2014 Apple Inc. All rights reserved. + * Copyright (c) 2004-2008, 2011-2015 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ - * + * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. - * + * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, @@ -17,7 +17,7 @@ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. - * + * * @APPLE_LICENSE_HEADER_END@ */ @@ -63,11 +63,9 @@ static libSC_info_server_t S_dns_info; /* - * S_debug - * A boolean that enables additional logging. + * S_logger + * Logging handle. */ -static Boolean S_debug_s; -static Boolean * S_debug = &S_debug_s; static SCLoggerRef S_logger = NULL; @@ -85,21 +83,6 @@ static _dns_sync_handler_t S_sync_handler = NULL; #pragma mark Support functions -#ifdef NOT_YET_NEEDED -static void -log_xpc_object(const char *msg, xpc_object_t obj) -{ - char *desc; - - desc = xpc_copy_description(obj); - if (*S_debug) { - SCLoggerLog(S_logger, LOG_DEBUG, CFSTR("%s = %s"), msg, desc); - } - free(desc); -} -#endif - - #pragma mark - #pragma mark DNS configuration server @@ -131,6 +114,7 @@ _dnsinfo_copy(xpc_connection_t connection, xpc_object_t request) { CFDataRef data; uint64_t generation; + const char *proc_name; xpc_connection_t remote; xpc_object_t reply; @@ -148,22 +132,18 @@ _dnsinfo_copy(xpc_connection_t connection, xpc_object_t request) connection, &generation); - if (*S_debug) { - const char *proc_name; - - // extract process name - proc_name = xpc_dictionary_get_string(request, DNSINFO_PROC_NAME); - if (proc_name == NULL) { - proc_name = "???"; - } - - SCLoggerLog(S_logger, LOG_DEBUG, CFSTR("<%p:%s[%d]> DNS configuration copy: %llu"), - connection, - proc_name, - xpc_connection_get_pid(connection), - generation); + // extract process name + proc_name = xpc_dictionary_get_string(request, DNSINFO_PROC_NAME); + if (proc_name == NULL) { + proc_name = "???"; } + SCLoggerLog(S_logger, LOG_DEBUG, CFSTR("<%p:%s[%d]> DNS configuration copy: %llu"), + connection, + proc_name, + xpc_connection_get_pid(connection), + generation); + // return the DNS configuration (if available) if (data != NULL) { xpc_dictionary_set_data(reply, @@ -196,16 +176,14 @@ _dnsinfo_acknowledge(xpc_connection_t connection, xpc_object_t request) generation = xpc_dictionary_get_uint64(request, DNSINFO_GENERATION); - if (*S_debug) { - SCLoggerLog(S_logger, LOG_DEBUG, CFSTR("<%p:%d> DNS configuration ack: %llu"), - connection, - xpc_connection_get_pid(connection), - generation); - } + SCLoggerLog(S_logger, LOG_DEBUG, CFSTR("<%p:%d> DNS configuration ack: %llu"), + connection, + xpc_connection_get_pid(connection), + generation); (void) _libSC_info_server_acknowledged(&S_dns_info, connection, generation); - // Note: all of the mDNSResponder ack's should result + // Note: all of the DNS service ack's should result // in a [new] network change being posted inSync = _libSC_info_server_in_sync(&S_dns_info); @@ -253,19 +231,21 @@ process_request(xpc_connection_t connection, xpc_object_t request) static void process_new_connection(xpc_connection_t c) { - if (*S_debug) { - SCLoggerLog(S_logger, LOG_DEBUG, CFSTR("<%p:%d> DNS configuration session: open"), - c, - xpc_connection_get_pid(c)); - } + SCLoggerLog(S_logger, LOG_DEBUG, CFSTR("<%p:%d> DNS configuration session: open"), + c, + xpc_connection_get_pid(c)); _libSC_info_server_open(&S_dns_info, c); xpc_connection_set_target_queue(c, _dnsinfo_server_queue()); xpc_connection_set_event_handler(c, ^(xpc_object_t xobj) { + os_activity_t activity_id; xpc_type_t type; + activity_id = os_activity_start("processing dnsinfo request", + OS_ACTIVITY_FLAG_DEFAULT); + type = xpc_get_type(xobj); if (type == XPC_TYPE_DICTIONARY) { // process the request @@ -278,11 +258,9 @@ process_new_connection(xpc_connection_t c) if (xobj == XPC_ERROR_CONNECTION_INVALID) { Boolean changed; - if (*S_debug) { - SCLoggerLog(S_logger, LOG_DEBUG, CFSTR("<%p:%d> DNS configuration session: close"), - c, - xpc_connection_get_pid(c)); - } + SCLoggerLog(S_logger, LOG_DEBUG, CFSTR("<%p:%d> DNS configuration session: close"), + c, + xpc_connection_get_pid(c)); changed = _libSC_info_server_close(&S_dns_info, c); if (changed) { @@ -316,6 +294,8 @@ process_new_connection(xpc_connection_t c) xpc_connection_get_pid(c), type); } + + os_activity_end(activity_id); }); xpc_connection_resume(c); @@ -332,13 +312,11 @@ __private_extern__ void load_DNSConfiguration(CFBundleRef bundle, SCLoggerRef logger, - Boolean *bundleVerbose, _dns_sync_handler_t syncHandler) { xpc_connection_t c; const char *name; - S_debug = bundleVerbose; S_logger = logger; /* @@ -362,8 +340,12 @@ load_DNSConfiguration(CFBundleRef bundle, XPC_CONNECTION_MACH_SERVICE_LISTENER); xpc_connection_set_event_handler(c, ^(xpc_object_t event) { + os_activity_t activity_id; xpc_type_t type; + activity_id = os_activity_start("processing dnsinfo connection", + OS_ACTIVITY_FLAG_DEFAULT); + type = xpc_get_type(event); if (type == XPC_TYPE_CONNECTION) { process_new_connection(event); @@ -390,6 +372,8 @@ load_DNSConfiguration(CFBundleRef bundle, type); } + + os_activity_end(activity_id); }); xpc_connection_resume(c); @@ -416,10 +400,9 @@ _dns_configuration_store(dns_create_config_t *_config) new_generation = config->config.generation; - if (*S_debug) { - SCLoggerLog(S_logger, LOG_DEBUG, CFSTR("DNS configuration updated: %llu"), - new_generation); - } + SCLoggerLog(S_logger, LOG_INFO, + CFSTR("DNS configuration updated: %llu"), + new_generation); bytes = (const UInt8 *)config; len = sizeof(_dns_config_buf_t) + ntohl(config->n_attribute); @@ -472,8 +455,7 @@ main(int argc, char **argv) _sc_debug = TRUE; load_DNSConfiguration(CFBundleGetMainBundle(), // bundle - NULL, //SCLogger - &verbose, // bundleVerbose + NULL, // SCLogger ^(Boolean inSync) { // sync handler SCLoggerLog(NULL, LOG_INFO, CFSTR("in sync: %s"), diff --git a/dnsinfo/dnsinfo_server.h b/dnsinfo/dnsinfo_server.h index 53b7779..3ec6f42 100644 --- a/dnsinfo/dnsinfo_server.h +++ b/dnsinfo/dnsinfo_server.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2005, 2009, 2011, 2012 Apple Inc. All rights reserved. + * Copyright (c) 2004, 2005, 2009, 2011, 2012, 2015 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -39,7 +39,6 @@ __BEGIN_DECLS void load_DNSConfiguration (CFBundleRef bundle, SCLoggerRef logger, - Boolean *bundleVerbose, _dns_sync_handler_t syncHandler); _Bool diff --git a/get-mobility-info b/get-mobility-info index 97d3855..f802b93 100755 --- a/get-mobility-info +++ b/get-mobility-info @@ -44,7 +44,7 @@ else TAIL_25000="/bin/cat" fi -OUT="mobility-info-`date +'%m.%d.%Y.%H%M%S'`" +OUT="mobility-info-`date +'%Y.%m.%d.%H%M%S'`" OUTDIR="/var/tmp" if [ -d ~/Desktop ]; then OUTDIR=~/Desktop @@ -82,39 +82,14 @@ echo "Please wait, collecting information and statistics" echo "" # -# Execute network reachability/DNS commands early +# get-network-info # -echo "#" > reachability-info -echo '# scutil -d -v -r www.apple.com "" no-server' >> reachability-info -echo "#" >> reachability-info -scutil -d -v -r www.apple.com "" no-server >> reachability-info 2>&1 - -echo "#" >> reachability-info -echo '# scutil -d -v -r 0.0.0.0 no-server' >> reachability-info -echo "#" >> reachability-info -scutil -d -v -r 0.0.0.0 no-server >> reachability-info 2>&1 - -if [ -x /usr/bin/dig -a -f /etc/resolv.conf ]; then - /usr/bin/dig -t any -c any www.apple.com > dig-results 2>/dev/null -fi - -# -# Signal "networkd" and "mDNSResponder" early to log their "state" info. This -# logging will continue while we execute a few other commands and should be -# complete by the time we collect the log content. -# -if [ -x /usr/bin/killall ]; then - # - # request networkd state - # - ${PRIV} /usr/bin/killall -INFO networkd 2>/dev/null - - # - # request mDNSResponder state - # - ${PRIV} /usr/bin/killall -INFO mDNSResponder 2>/dev/null - - sleep 1 +if [ -x /System/Library/Frameworks/SystemConfiguration.framework/Resources/get-network-info ]; then + /System/Library/Frameworks/SystemConfiguration.framework/Resources/get-network-info -s -c "${WORKDIR}" +elif [ -x /System/Library/Frameworks/SystemConfiguration.framework/get-network-info ]; then + /System/Library/Frameworks/SystemConfiguration.framework/get-network-info -s -c "${WORKDIR}" +elif [ -x /System/Library/PrivateFrameworks/SystemConfiguration.framework/get-network-info ]; then + /System/Library/PrivateFrameworks/SystemConfiguration.framework/get-network-info -s -c "${WORKDIR}" fi # @@ -124,37 +99,6 @@ if [ -x /bin/ps ]; then /bin/ps axlww > ps 2>&1 fi -# -# network interface configuration -# -if [ -x /sbin/ifconfig ]; then - /sbin/ifconfig -a -L -b -m -r -v -v > ifconfig 2>&1 - if [ $? -ne 0 ]; then - /sbin/ifconfig -a > ifconfig 2>&1 - fi -fi - -# -# network route configuration -# -if [ -x /usr/sbin/netstat ]; then - /usr/sbin/netstat -n -r -a -l > netstat 2>&1 -fi - -# -# DHCP configuration -# -if [ -x /sbin/ifconfig ]; then - for if in `/sbin/ifconfig -l` - do - case ${if} in - lo* ) ;; - en* ) ipconfig getpacket ${if} > ipconfig-${if} 2>&1 - ;; - esac - done -fi - # # AirPort info # @@ -205,13 +149,6 @@ if [ -x /usr/bin/pmset ]; then /usr/bin/pmset -g everything 2>/dev/null | ${TAIL_25000} >> pmset fi -# -# Host name -# -if [ -x /bin/hostname ]; then - /bin/hostname > hostname 2>&1 -fi - # # Host configuration # @@ -222,59 +159,15 @@ if [ -e /etc/hostconfig ]; then cat /etc/hostconfig > etc.hostconfig 2>&1 fi -# -# DNS configuration -# -scutil --dns > dns-configuration 2>&1 -if [ -e /etc/resolv.conf ]; then - cat /etc/resolv.conf > etc.resolv.conf 2>&1 -fi -if [ -e /var/run/resolv.conf ]; then - cat /var/run/resolv.conf > var.run.resolv.conf 2>&1 -fi -if [ -e /etc/resolver ]; then - tar -c -H /etc/resolver > etc.resolver.tar 2>/dev/null -fi - -# -# Proxy configuration -# -scutil -d -v --proxy > proxy-configuration 2>&1 - -# -# Network information -# -if [ -x /sbin/ifconfig ]; then - echo "#" > network-information - echo "# scutil --nwi" >> network-information - echo "#" >> network-information - scutil --nwi >> network-information 2>&1 - for if in `/sbin/ifconfig -l` - do - echo "" >> network-information - echo "#" >> network-information - echo "# scutil --nwi ${if}" >> network-information - echo "#" >> network-information - scutil --nwi ${if} >> network-information 2>&1 - done -fi - # # System / network preferences # for f in \ - /Library/Preferences/SystemConfiguration/NetworkInterfaces.plist \ /Library/Preferences/SystemConfiguration/com.apple.PowerManagement.plist \ /Library/Preferences/SystemConfiguration/com.apple.airport.preferences.plist \ - /Library/Preferences/SystemConfiguration/com.apple.nat.plist \ - /Library/Preferences/SystemConfiguration/com.apple.smb.server.plist \ /Library/Preferences/SystemConfiguration/com.apple.wifi.plist \ - /Library/Preferences/SystemConfiguration/preferences.plist \ /Library/Preferences/com.apple.alf.plist \ /Library/Preferences/com.apple.sharing.firewall.plist \ - /Library/Preferences/com.apple.networkextension.plist \ - /Library/Preferences/com.apple.networkextension.control.plist \ - /Library/Preferences/com.apple.networkextension.necp.plist \ /Library/Preferences/com.apple.wwand.plist \ do @@ -284,10 +177,17 @@ do fi done +# +# Install log +# +if [ -e /var/log/install.log ]; then + cat /var/log/install.log > install.log 2>&1 +fi + # # System / network preferences (from other volumes) # -/bin/ls /Volumes 2>/dev/null \ +mount -t hfs | grep "/Volumes/" | sed -e 's:^.* on /Volumes/::' -e 's: ([^(]*$::' \ | while read volume do V_PATH="/Volumes/${volume}" @@ -295,6 +195,7 @@ do # if the path is a symlink continue fi + for f in \ /Library/Preferences/SystemConfiguration/Networkinterfaces.plist \ /Library/Preferences/SystemConfiguration/preferences.plist \ @@ -319,26 +220,6 @@ elif [ -e /Library/Preferences/SystemConfiguration/bootpd.plist ]; then cat /Library/Preferences/SystemConfiguration/com.apple.named.proxy.conf > com.apple.named.proxy.conf 2>/dev/null fi -# -# configd's cache -# -${PRIV} scutil -p --snapshot -if [ -f /var/tmp/configd-store.plist ]; then - cat /var/tmp/configd-store.plist > configd-store.plist 2>&1 -fi -if [ -f /var/tmp/configd-pattern.plist ]; then - cat /var/tmp/configd-pattern.plist > configd-pattern.plist 2>&1 -fi -if [ -f /var/tmp/configd-session.plist ]; then - cat /var/tmp/configd-session.plist > configd-session.plist 2>&1 -fi -if [ -f /var/tmp/configd-state ]; then - cat /var/tmp/configd-state > configd-state 2>&1 -fi -if [ -f /var/tmp/configd-reachability ]; then - cat /var/tmp/configd-reachability > configd-reachability 2>&1 -fi - # # mounted filesystems # @@ -353,107 +234,6 @@ if [ -x /usr/sbin/kextstat ]; then /usr/sbin/kextstat > kextstat 2>&1 fi -# -# network statistics -# -/bin/echo -n "" > network-statistics - -if [ -x /usr/sbin/arp ]; then - echo "#" >> network-statistics - echo "# arp -n -a" >> network-statistics - echo "#" >> network-statistics - /usr/sbin/arp -n -a >> network-statistics 2>&1 -fi - -if [ -x /usr/sbin/netstat ]; then - echo "#" >> network-statistics - echo "# netstat -A -a -l -n" >> network-statistics - echo "#" >> network-statistics - /usr/sbin/netstat -A -a -l -n >> network-statistics 2>&1 - - echo "#" >> network-statistics - echo "# netstat -s" >> network-statistics - echo "#" >> network-statistics - /usr/sbin/netstat -s >> network-statistics 2>&1 - - echo "#" >> network-statistics - echo "# netstat -mmm" >> network-statistics - echo "#" >> network-statistics - /usr/sbin/netstat -mmm >> network-statistics 2>&1 - - echo "#" >> network-statistics - echo "# netstat -i -n -d" >> network-statistics - echo "#" >> network-statistics - /usr/sbin/netstat -i -n -d >> network-statistics 2>&1 - - echo "#" >> network-statistics - echo "# netstat -g -n -s" >> network-statistics - echo "#" >> network-statistics - /usr/sbin/netstat -g -n -s >> network-statistics 2>&1 - - echo "#" >> network-statistics - echo "# netstat -i -x R" >> network-statistics - echo "#" >> network-statistics - /usr/sbin/netstat -i -x R >> network-statistics 2>&1 - echo "#" >> network-statistics - - echo "# netstat -a -n -p mptcp" >> network-statistics - echo "#" >> network-statistics - /usr/sbin/netstat -a -n -p mptcp >> network-statistics 2>/dev/null - - echo "#" >> network-statistics - echo "# netstat -s -p mptcp" >> network-statistics - echo "#" >> network-statistics - /usr/sbin/netstat -s -p mptcp >> network-statistics 2>/dev/null - - if [ -x /sbin/ifconfig ]; then - for if in `/sbin/ifconfig -l` - do - `/sbin/ifconfig -v ${if} | grep -q TXSTART` - if [ $? -eq 0 ]; then - echo "#" >> network-statistics - echo "# netstat -qq -I ${if}" >> network-statistics - echo "#" >> network-statistics - /usr/sbin/netstat -qq -I ${if} >> network-statistics 2>&1 - fi - `/sbin/ifconfig -v ${if} | grep -q RXPOLL` - if [ $? -eq 0 ]; then - echo "#" >> network-statistics - echo "# netstat -Q -I ${if}" >> network-statistics - echo "#" >> network-statistics - /usr/sbin/netstat -Q -I ${if} >> network-statistics 2>&1 - fi - done - fi -fi - -if [ -x /usr/sbin/ndp ]; then - echo "#" >> network-statistics - echo "# ndp -n -a" >> network-statistics - echo "#" >> network-statistics - /usr/sbin/ndp -n -a >> network-statistics 2>&1 - - echo "#" >> network-statistics - echo "# ndp -n -p" >> network-statistics - echo "#" >> network-statistics - /usr/sbin/ndp -n -p >> network-statistics 2>&1 - - echo "#" >> network-statistics - echo "# ndp -n -r" >> network-statistics - echo "#" >> network-statistics - /usr/sbin/ndp -n -r >> network-statistics 2>&1 - - if [ -x /sbin/ifconfig ]; then - for if in `/sbin/ifconfig -l` - do - echo "#" >> network-statistics - echo "# ndp -i ${if}" >> network-statistics - echo "#" >> network-statistics - /usr/sbin/ndp -i ${if} >> network-statistics 2>&1 - done - fi -fi - if [ -x /sbin/pfctl ]; then echo "#" > pf echo "# pfctl -s all" >> pf @@ -485,7 +265,30 @@ fi # open files # if [ -x /usr/sbin/lsof ]; then - ${PRIV} /usr/sbin/lsof -n -P -T q > lsof 2>&1 + ${PRIV} /usr/sbin/lsof -n -O -P -T q > lsof 2>&1 & + LSOF_PID=$! + # Init a watchdog for lsof + ( + WAIT_TIME=5 + while [ $WAIT_TIME -gt 0 ] + do + ${PRIV} kill -0 ${LSOF_PID} 2>/dev/null + if [ $? -eq 0 ]; then + sleep 1 + # lsof is gathering data.. + WAIT_TIME=$((WAIT_TIME-1)) + continue + fi + + # lsof completed gathering data + break + done + + if [ $WAIT_TIME -eq 0 ]; then + # lsof timed out + ${PRIV} kill ${LSOF_PID} 2>/dev/null + fi + ) & fi # @@ -495,7 +298,7 @@ if [ -x /usr/local/bin/ddt ]; then /bin/echo -n "" > dispatch-info for BIN in \ configd \ - mDNSResponder \ + discoveryd \ do echo "#" >> dispatch-info @@ -515,49 +318,6 @@ if [ -x /usr/bin/odutil ]; then ${PRIV} /usr/bin/odutil show all >> od-info 2>&1 fi -# -# IPsec configuration -# -if [ -x /usr/sbin/setkey -a -x /usr/bin/perl ]; then - echo "#" > ipsec - echo "# setkey -D" >> ipsec - echo "#" >> ipsec - ${PRIV} /usr/sbin/setkey -D \ - | /usr/bin/perl -M'Digest::MD5 qw(md5_hex)' -l -n -e ' - if (/^(\s+[AE]:\s+\S+\s+)"?(.*)"?\s*$/) { - printf "%s[MD5:%s]%s\n", $1, md5_hex($2 . "\n"), $3; - } else { - printf "%s\n", $_; - } - ' >> ipsec - - echo "" >> ipsec - echo "#" >> ipsec - echo "# setkey -Pp -D" >> ipsec - echo "#" >> ipsec - ${PRIV} /usr/sbin/setkey -Pp -D >> ipsec - - for CF in /var/run/racoon/*.conf - do - if [ ! -r "${CF}" ]; then - continue - fi - - echo "" >> ipsec - echo "#" >> ipsec - echo "# ${CF}" >> ipsec - echo "#" >> ipsec - ${PRIV} cat ${CF} \ - | /usr/bin/perl -M'Digest::MD5 qw(md5_hex)' -l -n -e ' - if (/^(\s+shared_secret\s+use\s+)"?([^\s;"]+)"?(.*)/) { - printf "%s[MD5:%s]%s\n", $1, md5_hex($2 . "\n"), $3; - } else { - printf "%s\n", $_; - } - ' >> ipsec - done -fi - # # Kerberos configuration # @@ -660,14 +420,15 @@ report_binary_info() get_binary_info() { for BIN in \ - /usr/libexec/InternetSharing \ /usr/libexec/bootpd \ /usr/libexec/configd \ - /usr/libexec/misd \ + /usr/libexec/discoveryd \ /usr/sbin/awacsd \ /usr/sbin/mDNSResponder \ /usr/sbin/pppd \ /usr/sbin/racoon \ + /usr/libexec/misd \ + /usr/libexec/InternetSharing \ /System/Library/Frameworks/SystemConfiguration.framework/SystemConfiguration \ do @@ -775,7 +536,7 @@ if [ -x /usr/bin/what -a -x /usr/bin/sum -a -x /bin/ls ]; then fi # -# to give a chance for "networkd" and "mDNSResponder" to finish dumping their +# to give a chance for "networkd" and the DNS service to finish dumping their # state, the last thing we do is collect the logs # @@ -869,6 +630,8 @@ if [ -x /bin/ls ]; then awacsd \ bootpd \ configd \ + discoveryd \ + discoveryd_helper \ eapolclient \ mDNSResponder \ mDNSResponderHelper \ @@ -913,6 +676,11 @@ if [ -x /usr/local/bin/crstackshot ]; then /usr/local/bin/crstackshot 2>/dev/null fi +# +# wait for background activity (eg: lsof) +# +wait + # # collect everything into a single archive # diff --git a/get-network-info b/get-network-info new file mode 100755 index 0000000..4e23eb0 --- /dev/null +++ b/get-network-info @@ -0,0 +1,557 @@ +#!/bin/sh + +# +# Copyright © 2015 Apple Inc. +# +# get-network-info +# +# Collect network information. +# + +PATH=/bin:/usr/bin:/sbin:/usr/sbin + +# __SETUP_ROUTINES_BEGIN__ + +process_opts () { + + for i in $ARGS + do + case "$i" + in + -s) + COLLECT_SENSITIVE_INFO="Y" + shift;; + -c) + COLLECT_CONFIGURATION_FILES="Y" + shift;; + --) + shift;; + *) + REQUESTED_OUTDIR="${i}" + shift;; + esac + done + +} + +set_root () { + + PRIV="" + if [ ${EUID} -ne 0 ]; then + PRIV="sudo" + fi + +} + +# +# Setup +# +setup () { + + set_root + umask 077 + cd "${REQUESTED_OUTDIR}" + +} + +# __SETUP_ROUTINES_END__ + + +# __COMMAND_ROUTINES_BEGIN__ + +# note: the daemons dump to syslog so you need to wait a bit before +# capturing the logs. +collect_state_dump () { + + ${PRIV} /usr/bin/killall -INFO networkd 2>/dev/null + + sleep 1 & +} + +collect_state_dump_sensitive () { + + ${PRIV} /usr/bin/killall -INFO mDNSResponder 2>/dev/null + + sleep 1 & + +} + +# +# network interface configuration +# +run_ifconfig () { + + if [ ! -x /sbin/ifconfig ]; then + return + fi + + /sbin/ifconfig -a -L -b -m -r -v -v > ifconfig.txt 2>&1 + if [ $? -ne 0 ]; then + /sbin/ifconfig -a > ifconfig.txt 2>&1 + fi + +} + +# +# network route configuration and statistics +# +run_netstat () { + + if [ ! -x /usr/sbin/netstat ]; then + return + fi + + echo "#" > netstat.txt + echo "# netstat -n -r -a -l" >> netstat.txt + echo "#" >> netstat.txt + /usr/sbin/netstat -n -r -a -l >> netstat.txt 2>&1 + + echo "#" >> netstat.txt + echo "# netstat -A -a -l -n -v" >> netstat.txt + echo "#" >> netstat.txt + /usr/sbin/netstat -A -a -l -n -v >> netstat.txt 2>&1 + + echo "#" >> netstat.txt + echo "# netstat -s" >> netstat.txt + echo "#" >> netstat.txt + /usr/sbin/netstat -s >> netstat.txt 2>&1 + + echo "#" >> netstat.txt + echo "# netstat -mmm" >> netstat.txt + echo "#" >> netstat.txt + /usr/sbin/netstat -mmm >> netstat.txt 2>&1 + + echo "#" >> netstat.txt + echo "# netstat -i -n -d" >> netstat.txt + echo "#" >> netstat.txt + /usr/sbin/netstat -i -n -d >> netstat.txt 2>&1 + + echo "#" >> netstat.txt + echo "# netstat -i -x R" >> netstat.txt + echo "#" >> netstat.txt + /usr/sbin/netstat -i -x R >> netstat.txt 2>&1 + + echo "#" >> netstat.txt + echo "# netstat -a -n -p mptcp" >> netstat.txt + echo "#" >> netstat.txt + /usr/sbin/netstat -anp mptcp >> netstat.txt 2>&1 + + echo "#" >> netstat.txt + echo "# netstat -s -p mptcp" >> netstat.txt + echo "#" >> netstat.txt + /usr/sbin/netstat -s -p mptcp >> netstat.txt 2>&1 + + echo "#" >> netstat.txt + echo "# netstat -g -n -s" >> netstat.txt + echo "#" >> netstat.txt + /usr/sbin/netstat -g -n -s >> netstat.txt 2>&1 + + if [ -x /sbin/ifconfig ]; then + for if in ${IF_LIST} + do + IF_INFO=`/sbin/ifconfig -v ${if}` + `echo $IF_INFO | grep -q TXSTART` + if [ $? -eq 0 ]; then + echo "#" >> netstat.txt + echo "# netstat -qq -I ${if}" >> netstat.txt + echo "#" >> netstat.txt + /usr/sbin/netstat -qq -I ${if} >> netstat.txt 2>&1 + fi + `echo $IF_INFO | grep -q RXPOLL` + if [ $? -eq 0 ]; then + echo "#" >> netstat.txt + echo "# netstat -Q -I ${if}" >> netstat.txt + echo "#" >> netstat.txt + /usr/sbin/netstat -Q -I ${if} >> netstat.txt 2>&1 + fi + done + fi + +} + +run_ndp () { + + if [ ! -x /usr/sbin/ndp ]; then + return + fi + + echo "#" > ndp-info.txt + echo "# ndp -n -a" >> ndp-info.txt + echo "#" >> ndp-info.txt + /usr/sbin/ndp -n -a >> ndp-info.txt 2>&1 + + echo "#" >> ndp-info.txt + echo "# ndp -n -p" >> ndp-info.txt + echo "#" >> ndp-info.txt + /usr/sbin/ndp -n -p >> ndp-info.txt 2>&1 + + echo "#" >> ndp-info.txt + echo "# ndp -n -r" >> ndp-info.txt + echo "#" >> ndp-info.txt + /usr/sbin/ndp -n -r >> ndp-info.txt 2>&1 + + if [ -x /sbin/ifconfig ]; then + for if in ${IF_LIST} + do + echo "#" >> ndp-info.txt + echo "# ndp -i ${if}" >> ndp-info.txt + echo "#" >> ndp-info.txt + /usr/sbin/ndp -i ${if} >> ndp-info.txt 2>&1 + done + fi + +} + +run_arp () { + + if [ ! -x /usr/sbin/arp ]; then + return + fi + + echo "#" > arp-info.txt + echo "# arp -n -a" >> arp-info.txt + echo "#" >> arp-info.txt + /usr/sbin/arp -n -a >> arp-info.txt 2>&1 + +} + +# +# DHCP configuration +# +run_ipconfig () { + + if [ ! -x /usr/sbin/ipconfig ]; then + return + fi + + for if in ${IF_LIST} + do + case ${if} in + lo* ) ;; + *) + echo "#" >> ipconfig-info.txt + echo "# INTERFACE ${if}" >> ipconfig-info.txt + echo "#" >> ipconfig-info.txt + + echo "DHCPv4 information:" >> ipconfig-info.txt + + IPCONFIG_INFO=`/usr/sbin/ipconfig getpacket ${if}` + if [ "${IPCONFIG_INFO}" != "" ]; then + echo "${IPCONFIG_INFO}" >> ipconfig-info.txt + else + echo "not available" >> ipconfig-info.txt + fi + + echo"" >> ipconfig-info.txt + + echo "DHCPv6 information:" >> ipconfig-info.txt + + IPCONFIG_INFO=`/usr/sbin/ipconfig getv6packet ${if}` + if [ "${IPCONFIG_INFO}" != "" ]; then + echo "${IPCONFIG_INFO}" >> ipconfig-info.txt + else + echo "not available" >> ipconfig-info.txt + fi + + echo"" >> ipconfig-info.txt + ;; + esac + done + +} + +# +# IPsec configuration +# +run_setkey () { + + if [ ! -x /usr/sbin/setkey -o ! -x /usr/bin/perl ]; then + return + fi + + echo "#" > ipsec.txt + echo "# setkey -D" >> ipsec.txt + echo "#" >> ipsec.txt + ${PRIV} /usr/sbin/setkey -D \ + | /usr/bin/perl -l -n -e ' + if (/^(\s+[AE]:\s+\S+\s+)"?(.*)"?\s*$/) { + printf "%s[redacted]%s\n", $1, $3; + } else { + printf "%s\n", $_; + } + ' >> ipsec.txt + + echo "" >> ipsec.txt + echo "#" >> ipsec.txt + echo "# setkey -Pp -D" >> ipsec.txt + echo "#" >> ipsec.txt + ${PRIV} /usr/sbin/setkey -Pp -D >> ipsec.txt + + for CF in /var/run/racoon/*.conf + do + if [ ! -r "${CF}" ]; then + continue + fi + + echo "" >> ipsec.txt + echo "#" >> ipsec.txt + echo "# ${CF}" >> ipsec.txt + echo "#" >> ipsec.txt + ${PRIV} cat ${CF} \ + | /usr/bin/perl -l -n -e ' + if (/^(\s+shared_secret\s+use\s+)"?([^\s;"]+)"?(.*)/) { + printf "%s[redacted]%s\n", $1, $3; + } else { + printf "%s\n", $_; + } + ' >> ipsec.txt + done + +} + +# +# Network preferences +# +collect_configuration_files () { + + for f in \ + /Library/Preferences/com.apple.networkextension.plist \ + /Library/Preferences/com.apple.networkextension.control.plist \ + /Library/Preferences/com.apple.networkextension.necp.plist \ + /Library/Preferences/SystemConfiguration/com.apple.nat.plist \ + /Library/Preferences/SystemConfiguration/com.apple.RemoteAccessServers.plist \ + /Library/Preferences/SystemConfiguration/com.apple.smb.server.plist \ + /Library/Preferences/com.apple.mDNSResponder.plist \ + /Library/Preferences/SystemConfiguration/NetworkInterfaces.plist \ + /Library/Preferences/SystemConfiguration/preferences.plist \ + + do + if [ -e "${f}" ]; then + b="`basename ${f}`" + cat "${f}" > "${b}" 2>&1 + fi + done + + if [ -e /etc/resolv.conf ]; then + cat /etc/resolv.conf > etc-resolv-conf.txt 2>&1 + fi + if [ -e /var/run/resolv.conf ]; then + cat /var/run/resolv.conf > var-run-resolv-conf.txt 2>&1 + fi + if [ -e /etc/resolver ]; then + tar -c -H /etc/resolver > etc-resolver.tar 2>/dev/null + fi +} + +collect_vpn_logs () { + + for f in \ + /var/log/vpnd.log \ + /var/log/racoon.log \ + + do + if [ -e "${f}" ]; then + b="`basename ${f}`" + ${PRIV} cat "${f}" > "${b}".txt 2>&1 + fi + done +} + +# +# Network, DNS, Proxy, Reachability, Cache information +# +run_scutil () { + + if [ ! -x /usr/sbin/scutil ]; then + return + fi + + echo "#" > network-information.txt + echo "# scutil -d -v --nwi" >> network-information.txt + echo "#" >> network-information.txt + /usr/sbin/scutil -d -v --nwi >> network-information.txt 2>&1 + for if in ${IF_LIST} + do + echo "" >> network-information.txt + echo "#" >> network-information.txt + echo "# scutil --nwi ${if}" >> network-information.txt + echo "#" >> network-information.txt + scutil --nwi ${if} >> network-information.txt 2>&1 + done + + echo "#" > dns-configuration.txt + echo "# scutil -d -v --dns" >> dns-configuration.txt + echo "#" >> dns-configuration.txt + /usr/sbin/scutil -d -v --dns >> dns-configuration.txt 2>&1 + + echo "#" > proxy-configuration.txt + echo "# scutil -d -v --proxy" >> proxy-configuration.txt + echo "#" >> proxy-configuration.txt + /usr/sbin/scutil -d -v --proxy >> proxy-configuration.txt 2>&1 + + echo "#" > reachability-info.txt + echo '# scutil -d -v -r www.apple.com' >> reachability-info.txt + echo "#" >> reachability-info.txt + /usr/sbin/scutil -d -v -r www.apple.com >> reachability-info.txt 2>&1 + + echo "#" >> reachability-info.txt + echo '# scutil -d -v -r 0.0.0.0' >> reachability-info.txt + echo "#" >> reachability-info.txt + /usr/sbin/scutil -d -v -r 0.0.0.0 >> reachability-info.txt 2>&1 + + ${PRIV} /usr/sbin/scutil -p --snapshot + if [ -f /var/tmp/configd-store.plist ]; then + cat /var/tmp/configd-store.plist > configd-store.plist 2>&1 + fi + if [ -f /var/tmp/configd-pattern.plist ]; then + cat /var/tmp/configd-pattern.plist > configd-pattern.plist 2>&1 + fi + if [ -f /var/tmp/configd-session.plist ]; then + cat /var/tmp/configd-session.plist > configd-session.plist 2>&1 + fi + if [ -f /var/tmp/configd-state ]; then + cat /var/tmp/configd-state > configd-state 2>&1 + fi + +} + +run_route () { + + if [ ! -x /sbin/route ]; then + return + fi + + echo "#" > route-info.txt + echo '# route -n -v get www.apple.com' >> route-info.txt + echo "#" >> route-info.txt + /sbin/route -n -v get www.apple.com >> route-info.txt 2>&1 + + echo "#" >> route-info.txt + echo '# route -n -v get 0.0.0.0' >> route-info.txt + echo "#" >> route-info.txt + /sbin/route -n -v get 0.0.0.0 >> route-info.txt 2>&1 + +} + +run_dig () { + + if [ ! -x /usr/bin/dig -o ! -f /etc/resolv.conf ]; then + return + fi + + echo "#" > dig-info.txt + echo '# dig -t any -c any www.apple.com' >> dig-info.txt + echo "#" >> dig-info.txt + /usr/bin/dig +time=2 -t any -c any www.apple.com >> dig-info.txt 2>/dev/null + +} + +# +# Host name +# +run_hostname () { + + if [ ! -x /bin/hostname ]; then + return + fi + + /bin/hostname > hostname.txt 2>&1 + +} + +collect_sensitive_info () { + collect_state_dump_sensitive + run_ndp + run_arp +} + +collect_info () { + collect_state_dump + + if [ "${COLLECT_SENSITIVE_INFO}" == "Y" ]; then + collect_sensitive_info + fi + + run_scutil + run_dig + run_ifconfig + run_netstat + run_ipconfig + run_setkey + collect_vpn_logs + run_route + run_hostname + + if [ "${COLLECT_CONFIGURATION_FILES}" == "Y" ]; then + collect_configuration_files + fi +} + +# __COMMAND_ROUTINES_END__ + +# __HELPER_ROUTINES_BEGIN__ + +usage () { + + echo "Usage: get-network-info [-s] [-c] " + echo " -s collects sensitive information (ARP/NDP/mDNS cache)" + echo " -c collects system configuration files" + echo " path to directory where all the information will be collected" + +} + +is_outdir_valid () { + + if [ ! -d ${REQUESTED_OUTDIR} ] || + [ "${REQUESTED_OUTDIR}" = "" ]; then + usage + exit 1 + fi + + if [ ! -w ${REQUESTED_OUTDIR} ]; then + echo "${REQUESTED_OUTDIR} is write-protected" + exit 1 + fi +} + +# +# Collect most used command output to be used later +# +optimize () { + + if [ ! -x /sbin/ifconfig ]; then + return + fi + + IF_LIST=`/sbin/ifconfig -l` + +} + +init_globals () { + REQUESTED_OUTDIR="" + COLLECT_SENSITIVE_INFO="" + COLLECT_CONFIGURATION_FILES="" +} + +# __HELPER_ROUTINES_END__ + +# +# __MAIN__ +# +ARGS=`getopt sc $*` +if [ $? != 0 ]; then + usage + exit 1 +fi + +init_globals +process_opts +is_outdir_valid +setup +optimize +collect_info +wait + +#TO-DO: Add packet trace + +exit 0 diff --git a/libSystemConfiguration/libSystemConfiguration_client.c b/libSystemConfiguration/libSystemConfiguration_client.c index 5023329..531a3fd 100644 --- a/libSystemConfiguration/libSystemConfiguration_client.c +++ b/libSystemConfiguration/libSystemConfiguration_client.c @@ -1,15 +1,15 @@ /* - * Copyright (c) 2012, 2013 Apple Inc. All rights reserved. + * Copyright (c) 2012, 2013, 2015 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ - * + * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. - * + * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, @@ -17,7 +17,7 @@ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. - * + * * @APPLE_LICENSE_HEADER_END@ */ @@ -130,7 +130,6 @@ libSC_info_client_create(dispatch_queue_t q, xpc_connection_get_pid(c), desc); } - } else { asl_log(NULL, NULL, ASL_LEVEL_ERR, "%s: unknown event type : %p", diff --git a/libSystemConfiguration/libSystemConfiguration_server.c b/libSystemConfiguration/libSystemConfiguration_server.c index 0a5aca1..38cc44f 100644 --- a/libSystemConfiguration/libSystemConfiguration_server.c +++ b/libSystemConfiguration/libSystemConfiguration_server.c @@ -1,15 +1,15 @@ /* - * Copyright (c) 2012-2014 Apple Inc. All rights reserved. + * Copyright (c) 2012-2015 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ - * + * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. - * + * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, @@ -17,7 +17,7 @@ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. - * + * * @APPLE_LICENSE_HEADER_END@ */ @@ -41,17 +41,6 @@ #pragma mark Support functions -//__private_extern__ void -//log_xpc_object(const char *msg, xpc_object_t obj) -//{ -// char *desc; -// -// desc = xpc_copy_description(obj); -// asl_log(NULL, NULL, ASL_LEVEL_ERR, "%s = %s", msg, desc); -// free(desc); -//} - - #pragma mark - #pragma mark client connection trackng @@ -98,7 +87,7 @@ _handle_entitlement_check_failure(pid_t pid) if (!CFArrayContainsValue(pids, CFRangeMake(0, CFArrayGetCount(pids)), pidNumber)) { CFArrayAppendValue(pids, pidNumber); - SCLog(TRUE, LOG_ERR, CFSTR("DNS/nwi dropping ack w/no entitlement, pid = %d"), pid); + SC_log(LOG_INFO, "DNS/nwi dropping ack w/no entitlement, pid = %d", pid); if (!cleanupScheduled) { cleanupScheduled = TRUE; diff --git a/nwi/Makefile b/nwi/Makefile new file mode 100644 index 0000000..66d90a8 --- /dev/null +++ b/nwi/Makefile @@ -0,0 +1,40 @@ +ifeq ($(PLATFORM),iphoneos) +# iOS internal SDK +ARCHS=armv7 +endif + +ifeq ($(PLATFORM),) +PLATFORM=macosx +endif + +ifeq ($(PLATFORM),macosx) +# Mac OS X internal SDK +ARCHS=x86_64 +endif + +# Mac OS X or iOS internal SDK +SDK=$(PLATFORM).internal +SYSROOT=$(shell xcodebuild -version -sdk $(SDK) Path) +CC = xcrun -sdk $(SDK) cc +PF_INC = -F$(SYSROOT)/System/Library/PrivateFrameworks + +ARCH_FLAGS=$(foreach a,$(ARCHS),-arch $(a)) +EXTRA_CFLAGS= +TEST_INCLUDE=-I. -I../dnsinfo -I../libSystemConfiguration -I../SystemConfiguration.fproj -I$(SYSROOT)/System/Library/Frameworks/System.framework/PrivateHeaders + +REFERENCE_OUTPUT=../common/reference_output.sh + +clean: + rm -rf test_nwi *.o *.dSYM + +test_nwi:network_information.c network_information_priv.c ../libSystemConfiguration/libSystemConfiguration_client.c + $(CC) -DTEST_NWI $(PF_INC) $(ARCH_FLAGS) -isysroot $(SYSROOT) $(TEST_INCLUDE) $(EXTRA_CFLAGS) -Wall -O0 -g -o $@ $^ + +test_nwi_reference.txt: test_nwi + sh $(REFERENCE_OUTPUT) create test_nwi test_nwi_reference.txt /bin/cat + +test_nwi_test: test_nwi + sh $(REFERENCE_OUTPUT) test test_nwi test_nwi_reference.txt /bin/cat + +nwi:network_information.c network_information_priv.c ../libSystemConfiguration/libSystemConfiguration_client.c + $(CC) -DTEST_NWI_STATE $(PF_INC) $(ARCH_FLAGS) -isysroot $(SYSROOT) $(TEST_INCLUDE) $(EXTRA_CFLAGS) -Wall -O0 -g -o $@ $^ diff --git a/nwi/network_information.c b/nwi/network_information.c index 0db7366..51c584d 100644 --- a/nwi/network_information.c +++ b/nwi/network_information.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011-2014 Apple Inc. All rights reserved. + * Copyright (c) 2011-2015 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -81,43 +81,6 @@ _nwi_state_initialize(void) } } -static -void -_nwi_set_alias(nwi_state* state, nwi_ifstate* ifstate) -{ - nwi_ifstate* ifstate_alias; - int af = ifstate->af; - int af_alias; - - af_alias = (af == AF_INET)?AF_INET6:AF_INET; - - ifstate_alias = - nwi_state_get_ifstate_with_name(state, af_alias, - ifstate->ifname); - - if (ifstate_alias != NULL) { - ifstate_alias->af_alias = ifstate; - } - ifstate->af_alias = ifstate_alias; - return; -} - -static -void -_nwi_state_reset_alias(nwi_state_t state) { - int i; - - for (i = 0; i < state->ipv4_count; i++) { - state->nwi_ifstates[i].af_alias = NULL; - } - - for (i = state->ipv6_start; - i < state->ipv6_start + state->ipv6_count; i++) { - _nwi_set_alias(state, &state->nwi_ifstates[i]); - } -} - - #pragma mark - #pragma mark Network information [nwi] APIs @@ -135,11 +98,7 @@ _nwi_state_reset_alias(nwi_state_t state) { const char * nwi_state_get_notify_key() { -#if !TARGET_IPHONE_SIMULATOR return "com.apple.system.SystemConfiguration.nwi"; -#else // !TARGET_IPHONE_SIMULATOR - return "com.apple.iOS_Simulator.SystemConfiguration.nwi"; -#endif // !TARGET_IPHONE_SIMULATOR } #define ATOMIC_CMPXCHG(p, o, n) __sync_bool_compare_and_swap((p), (o), (n)) @@ -173,18 +132,16 @@ nwi_state_release(nwi_state_t state) } // release connection reference on 1-->0 transition - if (state->svr) { - dispatch_sync(__nwi_configuration_queue(), ^{ - if (--nwi_active == 0) { - // if last reference, drop connection - libSC_info_client_release(nwi_client); - nwi_client = NULL; - } - }); - } + dispatch_sync(__nwi_configuration_queue(), ^{ + if (--nwi_active == 0) { + // if last reference, drop connection + libSC_info_client_release(nwi_client); + nwi_client = NULL; + } + }); // release nwi_state - free(state); + nwi_state_free(state); return; } @@ -253,8 +210,14 @@ _nwi_state_copy_data() if (dataRef != NULL) { nwi_state = malloc(dataLen); bcopy((void *)dataRef, nwi_state, dataLen); - nwi_state->ref = 0; - nwi_state->svr = TRUE; + if (nwi_state->version != NWI_STATE_VERSION) { + /* make sure the version matches */ + nwi_state_free(nwi_state); + nwi_state = NULL; + } + else { + nwi_state->ref = 0; + } } xpc_release(reply); @@ -310,7 +273,6 @@ nwi_state_copy(void) if (G_nwi_state != NULL) { /* one reference for G_nwi_state */ nwi_state_retain(G_nwi_state); - _nwi_state_reset_alias(G_nwi_state); } } if (G_nwi_state != NULL) { @@ -399,8 +361,7 @@ nwi_ifstate_get_generation(nwi_ifstate_t ifstate) const char * nwi_ifstate_get_ifname(nwi_ifstate_t ifstate) { - return (ifstate != NULL?ifstate->ifname:NULL); - + return ((ifstate != NULL) ? ifstate->ifname : NULL); } static uint64_t @@ -418,9 +379,12 @@ flags_from_af(int af) nwi_ifstate_flags nwi_ifstate_get_flags(nwi_ifstate_t ifstate) { - nwi_ifstate_t alias = ifstate->af_alias; + nwi_ifstate_t alias = NULL; nwi_ifstate_flags flags = 0ULL; + if (ifstate->af_alias_offset != 0) { + alias = ifstate + ifstate->af_alias_offset; + } flags |= flags_from_af(ifstate->af); if ((ifstate->flags & NWI_IFSTATE_FLAGS_HAS_DNS) != 0) { flags |= NWI_IFSTATE_FLAGS_HAS_DNS; @@ -460,9 +424,12 @@ nwi_state_get_first_ifstate(nwi_state_t state, int af) } ifstate = nwi_state_get_ifstate_with_index(state, af, 0); + if (ifstate == NULL) { + return NULL; + } if ((ifstate->flags & NWI_IFSTATE_FLAGS_NOT_IN_LIST) != 0) { - ifstate = NULL; + ifstate = NULL; } return ifstate; @@ -497,31 +464,25 @@ nwi_state_get_ifstate(nwi_state_t state, const char * ifname) * Returns the next, lower priority nwi_ifstate_t after the specified * 'ifstate' for the protocol family 'af'. * - * Returns NULL when the end of the list is reached. + * Returns NULL when the end of the list is reached, or we reach an + * item that is not in the list. */ nwi_ifstate_t nwi_ifstate_get_next(nwi_ifstate_t ifstate, int af) { - nwi_ifstate_t alias, next; - - alias = - (af == ifstate->af)?ifstate:ifstate->af_alias; - - if (alias == NULL) { - return NULL; + ifstate = nwi_ifstate_get_alias(ifstate, af); + if (ifstate == NULL + || ((ifstate->flags + & (NWI_IFSTATE_FLAGS_NOT_IN_LIST + | NWI_IFSTATE_FLAGS_LAST_ITEM)) + != 0)) { + return (NULL); } - - /* We don't return interfaces marked rank never */ - if ((alias->flags & NWI_IFSTATE_FLAGS_NOT_IN_LIST) != 0) { - return NULL; - } - - next = ++alias; - - if ((next->flags & NWI_IFSTATE_FLAGS_NOT_IN_LIST) == 0) { - return next; + ifstate++; + if ((ifstate->flags & NWI_IFSTATE_FLAGS_NOT_IN_LIST) != 0) { + return (NULL); } - return NULL; + return (ifstate); } /* @@ -671,7 +632,7 @@ nwi_ifstate_get_signature(nwi_ifstate_t ifstate, int af, int * length) break; case AF_INET: case AF_INET6: - i_state = (ifstate->af == af) ? ifstate : ifstate->af_alias; + i_state = nwi_ifstate_get_alias(ifstate, af); break; default: break; @@ -695,12 +656,13 @@ _nwi_ifstate_is_in_list(nwi_ifstate_t ifstate, int af) { nwi_ifstate_t i_state; - i_state = (ifstate->af == af) ? ifstate : ifstate->af_alias; + i_state = nwi_ifstate_get_alias(ifstate, af); if (i_state == NULL) { return FALSE; } - if ((nwi_ifstate_get_flags(i_state) & NWI_IFSTATE_FLAGS_NOT_IN_LIST) == 0) { + if ((nwi_ifstate_get_flags(i_state) & NWI_IFSTATE_FLAGS_NOT_IN_LIST) + == 0) { return TRUE; } @@ -755,24 +717,320 @@ nwi_ifstate_get_dns_signature(nwi_ifstate_t ifstate, int * length) return signature; } +unsigned int +nwi_state_get_interface_names(nwi_state_t state, + const char * names[], + unsigned int names_count) +{ + int i; + nwi_ifindex_t * scan; + + if (names == NULL || names_count == 0) { + return (state->if_list_count); + } + for (i = 0, scan = nwi_state_if_list(state); + i < state->if_list_count; i++, scan++) { + names[i] = state->ifstate_list[*scan].ifname; + } + return (state->if_list_count); +} #pragma mark - #pragma mark Network information [nwi] test code -#ifdef MAIN +#ifdef TEST_NWI -int -main(int argc, char **argv) +#include + +typedef union { + const struct sockaddr * sa; + const struct sockaddr_in * sin; + const struct sockaddr_in6 * sin6; +} my_sockaddr_t; + +static const char * +my_sockaddr_ntop(const struct sockaddr * sa, char * buf, int buf_len) +{ + my_sockaddr_t addr; + const void * addr_ptr = NULL; + + addr.sa = sa; + switch (sa->sa_family) { + case AF_INET: + addr_ptr = &addr.sin->sin_addr; + break; + case AF_INET6: + addr_ptr = &addr.sin6->sin6_addr; + break; + default: + addr_ptr = NULL; + break; + } + if (addr_ptr == NULL) { + return (NULL); + } + return (inet_ntop(addr.sa->sa_family, addr_ptr, buf, buf_len)); +} + +static void +nwi_ifstate_print(nwi_ifstate_t ifstate) { - dns_config_t *config; + const char * addr_str; + void * address; + char addr_ntopbuf[INET6_ADDRSTRLEN]; + const char * diff_str; + char vpn_ntopbuf[INET6_ADDRSTRLEN]; + const struct sockaddr * vpn_addr; + const char * vpn_addr_str = NULL; + + address = nwi_ifstate_get_address(ifstate); + addr_str = inet_ntop(ifstate->af, address, + addr_ntopbuf, sizeof(addr_ntopbuf)); + vpn_addr = nwi_ifstate_get_vpn_server(ifstate); + if (vpn_addr != NULL) { + vpn_addr_str = my_sockaddr_ntop(vpn_addr, vpn_ntopbuf, + sizeof(vpn_ntopbuf)); + } + diff_str = nwi_ifstate_get_diff_str(ifstate); + printf("%s%s%s%s rank 0x%x iaddr %s%s%s reach_flags 0x%x\n", + ifstate->ifname, + diff_str, + (ifstate->flags & NWI_IFSTATE_FLAGS_HAS_DNS) != 0 + ? " dns" : "", + (ifstate->flags & NWI_IFSTATE_FLAGS_NOT_IN_LIST) != 0 + ? " never" : "", + ifstate->rank, + addr_str, + (vpn_addr_str != NULL) ? " vpn_server_addr: " : "", + (vpn_addr_str != NULL) ? vpn_addr_str : "", + ifstate->reach_flags); + return; +} - config = dns_configuration_copy(); - if (config != NULL) { - dns_configuration_free(&config); +static void +traverse_ifstates(nwi_state_t state) +{ + nwi_ifstate_t alias; + int i; + nwi_ifstate_t scan; + + scan = nwi_state_get_first_ifstate(state, AF_INET); + printf("IPv4 traverse list:\n"); + for (i = 0; scan != NULL; i++) { + printf("[%d] flags=0x%llx ", i, scan->flags); + nwi_ifstate_print(scan); + alias = nwi_ifstate_get_alias(scan, nwi_other_af(scan->af)); + scan = nwi_ifstate_get_next(scan, AF_INET); + if (alias != NULL) { + printf("\t alias is "); + nwi_ifstate_print(alias); + } + } + printf("IPv6 traverse list:\n"); + scan = nwi_state_get_first_ifstate(state, AF_INET6); + for (i = 0; scan != NULL; i++) { + printf("[%d] flags=0x%llx ", i, scan->flags); + alias = nwi_ifstate_get_alias(scan, nwi_other_af(scan->af)); + nwi_ifstate_print(scan); + scan = nwi_ifstate_get_next(scan, AF_INET6); + if (alias != NULL) { + printf("\t alias is "); + nwi_ifstate_print(alias); + } } +} + +static void +nwi_state_print_common(nwi_state_t state, bool diff) +{ + unsigned int count = 0; + int i; + nwi_ifstate_t scan; + + if (state == NULL) { + return; + } + printf("nwi_state = { " + "gen=%llu max_if=%u #v4=%u #v6=%u " + "reach_flags=(v4=0x%x, v6=0x%x) }\n", + state->generation_count, + state->max_if_count, + state->ipv4_count, + state->ipv6_count, + nwi_state_get_reachability_flags(state, AF_INET), + nwi_state_get_reachability_flags(state, AF_INET6)); + if (state->ipv4_count) { + printf("IPv4:\n"); + for (i = 0, scan = nwi_state_ifstate_list(state, AF_INET); + i < state->ipv4_count; i++, scan++) { + printf("[%d] ", i); + nwi_ifstate_print(scan); + } + } + if (state->ipv6_count) { + printf("IPv6:\n"); + for (i = 0, scan = nwi_state_ifstate_list(state, AF_INET6); + i < state->ipv6_count; i++, scan++) { + printf("[%d] ", i); + nwi_ifstate_print(scan); + } + } + if (!diff) { + count = nwi_state_get_interface_names(state, NULL, 0); + if (count > 0) { + const char * names[count]; + + count = nwi_state_get_interface_names(state, names, + count); + printf("%d interfaces%s", count, + (count != 0) ? ": " : ""); + for (i = 0; i < count; i++) { + printf("%s%s", (i == 0) ? "" : ", ", names[i]); + } + printf("\n"); + } + else { + printf("0 interfaces\n"); + } + traverse_ifstates(state); + } + printf("-----------------------------------\n"); + return; +} + +static void +nwi_state_print(nwi_state_t state) +{ + nwi_state_print_common(state, FALSE); +} + +static void +nwi_state_print_diff(nwi_state_t state) +{ + printf("DIFF\n"); + nwi_state_print_common(state, TRUE); +} + +static void +doit(void) +{ + struct in_addr addr = { 0 }; + struct in6_addr addr6; + nwi_ifstate_t ifstate; + nwi_state_t state; + nwi_state_t diff_state; + nwi_state_t new_state; + nwi_state_t old_state; + nwi_state_t old_state_copy; + + state = nwi_state_new(NULL, 0); + nwi_state_print(state); + state = nwi_state_new(NULL, 1); + nwi_state_print(state); + state = nwi_state_new(state, 2); + nwi_state_print(state); + state = nwi_state_new(state, 10); + nwi_state_print(state); + + bzero(&addr6, sizeof(addr6)); + /* populate old_state */ + old_state = nwi_state_new(NULL, 5); + for (int i = 0; i < 5; i++) { + char ifname[IFNAMSIZ]; + + snprintf(ifname, sizeof(ifname), "en%d", i); + addr.s_addr = htonl((i % 2) ? i : (i + 1)); + ifstate = nwi_state_add_ifstate(old_state, ifname, AF_INET, 0, + (i % 2) ? (i - 1) : (i + 1), + &addr, + NULL, + 0); + addr6.__u6_addr.__u6_addr32[0] = htonl(i); + ifstate = nwi_state_add_ifstate(old_state, ifname, AF_INET6, 0, + (i % 2) ? (10 - i) : i, + &addr6, + NULL, + 0); + } + nwi_state_finalize(old_state); + nwi_state_print(old_state); + + diff_state = nwi_state_diff(NULL, old_state); + nwi_state_print_diff(diff_state); + nwi_state_free(diff_state); + + /* remember the old state */ + old_state_copy = nwi_state_make_copy(old_state); + + /* create new state */ + new_state = nwi_state_new(old_state, 10); + nwi_state_print(new_state); + + for (int i = 0; i < 10; i++) { + char ifname[IFNAMSIZ]; + uint64_t flags; + + snprintf(ifname, sizeof(ifname), "en%d", i); + addr6.__u6_addr.__u6_addr32[0] = htonl(i); + flags = (i > 6) ? NWI_IFSTATE_FLAGS_NOT_IN_LIST : 0; + ifstate = nwi_state_add_ifstate(new_state, ifname, AF_INET6, + flags, + i, + &addr6, + NULL, + 0); + } + for (int i = 9; i >= 0; i--) { + char ifname[IFNAMSIZ]; + + snprintf(ifname, sizeof(ifname), "en%d", i); + addr.s_addr = htonl(i); + if (i != 3) { + ifstate = nwi_state_add_ifstate(new_state, + ifname, AF_INET, + 0, + i, + &addr, + NULL, + 0); + } + } + nwi_state_finalize(new_state); + nwi_state_print(new_state); + + diff_state = nwi_state_diff(old_state_copy, new_state); + nwi_state_print_diff(diff_state); + nwi_state_free(diff_state); + + diff_state = nwi_state_diff(new_state, old_state_copy); + nwi_state_print_diff(diff_state); + nwi_state_free(diff_state); + + nwi_state_free(old_state_copy); + nwi_state_free(new_state); + return; +} + +int +main() +{ + doit(); + exit(0); + return (0); +} + +#endif /* TEST_NWI */ + +#ifdef TEST_NWI_STATE + +int +main(int argc, char * argv[]) +{ + nwi_state_t state = nwi_state_copy(); exit(0); + return (0); } #endif diff --git a/nwi/network_information.h b/nwi/network_information.h index 7c364fc..acc2cf9 100644 --- a/nwi/network_information.h +++ b/nwi/network_information.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011-2013 Apple Inc. All rights reserved. + * Copyright (c) 2011-2015 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -177,9 +177,9 @@ _nwi_state_ack(nwi_state_t state, const char *bundle_id) __OSX_AVAILABLE_STARTING(__MAC_10_8, __IPHONE_6_0); /* - * nwi_state_get_reachability_flags - * - * returns the global reachability flags for a given address family. + * Function: nwi_state_get_reachability_flags + * Purpose: + * Returns the global reachability flags for a given address family. * If no address family is passed in, it returns the global reachability * flags for either families. * @@ -208,6 +208,32 @@ _nwi_state_ack(nwi_state_t state, const char *bundle_id) uint32_t nwi_state_get_reachability_flags(nwi_state_t nwi_state, int af); +/* + * Function: nwi_state_get_interface_names + * Purpose: + * Returns the list of network interface names that have connectivity. + * The list is sorted from highest priority to least, highest priority + * appearing at index 0. + * + * If 'names' is NULL or 'names_count' is zero, this function returns + * the number of elements that 'names' must contain to get the complete + * list of interface names. + * + * If 'names' is not NULL and 'names_count' is not zero, fills 'names' with + * the list of interface names not exceeding 'names_count'. Returns the + * number of elements that were actually populated. + * + * Notes: + * 1. The connectivity that an interface in this list provides may not be for + * general purpose use. + * 2. The string pointers remain valid only as long as 'state' remains + * valid. + */ +unsigned int +nwi_state_get_interface_names(nwi_state_t state, + const char * names[], + unsigned int names_count); + /* * nwi_ifstate_get_vpn_server * diff --git a/nwi/network_information_priv.c b/nwi/network_information_priv.c index 0edee36..361d8aa 100644 --- a/nwi/network_information_priv.c +++ b/nwi/network_information_priv.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011-2013 Apple Inc. All rights reserved. + * Copyright (c) 2011-2015 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -31,103 +31,220 @@ #include "network_information_priv.h" #include #include +#include -__private_extern__ -const sa_family_t nwi_af_list[] = {AF_INET, AF_INET6}; +#define NWI_IFSTATE_FLAGS(flags) \ + ((flags) & NWI_IFSTATE_FLAGS_MASK) + +#define NWI_IFSTATE_FLAGS_GET_DIFF(flags) \ + (((flags) & NWI_IFSTATE_FLAGS_DIFF_MASK) >> 8) + +#define NWI_IFSTATE_FLAGS_FROM_DIFF(diff) \ + (((diff) << 8) & NWI_IFSTATE_FLAGS_DIFF_MASK) -static __inline__ size_t -nwi_state_compute_size(unsigned int n) +#define NWI_IFSTATE_DIFF_UNCHANGED 0 +#define NWI_IFSTATE_DIFF_ADDED 1 +#define NWI_IFSTATE_DIFF_REMOVED 2 +#define NWI_IFSTATE_DIFF_CHANGED 3 +#define NWI_IFSTATE_DIFF_RANK_UP 4 +#define NWI_IFSTATE_DIFF_RANK_DOWN 5 + + +static void +nwi_state_fix_af_aliases(nwi_state_t state, uint32_t old_max_if_count) { - return (offsetof(nwi_state, nwi_ifstates[n])); + int64_t offset; + int i; + nwi_ifstate_t ifstate; + + offset = state->max_if_count - old_max_if_count; + if (offset < 0) { + syslog(LOG_ERR, "new count %d < old count %d", + state->max_if_count, old_max_if_count); + return; + } + /* iterate IPv4 list and add the offset to any entries with an alias */ + for (i = 0, ifstate = nwi_state_ifstate_list(state, AF_INET); + i < state->ipv4_count; + i++, ifstate++) { + if (ifstate->af_alias_offset != 0) { + /* IPv6 is higher in memory, alias is forward */ + ifstate->af_alias_offset += offset; + } + } + + /* iterate IPv6 list and add the offset to any entries with an alias */ + for (i = 0, ifstate = nwi_state_ifstate_list(state, AF_INET6); + i < state->ipv6_count; + i++, ifstate++) { + if (ifstate->af_alias_offset != 0) { + /* IPv6 is higher in memory, alias is backward */ + ifstate->af_alias_offset -= offset; + } + } + return; } + +static void +nwi_state_add_to_if_list(nwi_state_t state, nwi_ifstate_t ifstate) +{ + int i; + nwi_ifindex_t * scan; + + if ((ifstate->flags & NWI_IFSTATE_FLAGS_NOT_IN_IFLIST) != 0) { + /* doesn't get added to interface list */ + return; + } + if (state->if_list_count >= state->max_if_count) { + /* sanity check */ + return; + } + for (i = 0, scan = nwi_state_if_list(state); + i < state->if_list_count; + i++, scan++) { + nwi_ifstate_t this; + + this = state->ifstate_list + *scan; + if (strcmp(this->ifname, ifstate->ifname) == 0) { + /* it's already in the list */ + return; + } + } + /* add it to the end */ + *scan = (nwi_ifindex_t)(ifstate - state->ifstate_list); + state->if_list_count++; + return; +} + +static void +nwi_state_set_if_list(nwi_state_t state) +{ + nwi_ifstate_t scan_v4; + nwi_ifstate_t scan_v6; + int v4; + int v6; + + v4 = 0; + v6 = 0; + state->if_list_count = 0; + scan_v4 = nwi_state_get_ifstate_with_index(state, AF_INET, v4); + scan_v6 = nwi_state_get_ifstate_with_index(state, AF_INET6, v6); + while (scan_v4 != NULL || scan_v6 != NULL) { + bool add_v4 = FALSE; + + if (scan_v4 != NULL && scan_v6 != NULL) { + /* add the higher rank of v4 or v6 */ + if (scan_v4->rank <= scan_v6->rank) { + add_v4 = TRUE; + } + } + else if (scan_v4 != NULL) { + add_v4 = TRUE; + } + if (add_v4) { + /* add v4 interface */ + nwi_state_add_to_if_list(state, scan_v4); + v4++; + scan_v4 = nwi_state_get_ifstate_with_index(state, + AF_INET, + v4); + } + else { + /* add v6 interface, move to next item */ + nwi_state_add_to_if_list(state, scan_v6); + v6++; + scan_v6 = nwi_state_get_ifstate_with_index(state, + AF_INET6, + v6); + } + } + return; +} + __private_extern__ nwi_state_t -nwi_state_copy_priv(nwi_state_t src) +nwi_state_make_copy(nwi_state_t src) { - nwi_state_t dest = NULL; + nwi_state_t dest = NULL; + size_t size; if (src == NULL) { return dest; } - - dest = malloc(src->size); + size = nwi_state_size(src); + dest = malloc(size); if (dest != NULL) { - bcopy(src, dest, src->size); - - dest->ref = 1; - dest->svr = FALSE; + bcopy(src, dest, size); } return dest; } __private_extern__ nwi_state_t -nwi_state_new(nwi_state_t old_state, int elems) +nwi_state_new(nwi_state_t old_state, int max_if_count) { - nwi_state_t state = NULL; - uint32_t new_size; + size_t size; + nwi_state_t state = NULL; - if (old_state == NULL && elems == 0) { + if (old_state == NULL && max_if_count == 0) { return NULL; } - /* Need to insert a last node for each of the v4/v6 list */ - new_size = (elems != 0) - ? (uint32_t)(sizeof(nwi_state) + nwi_state_compute_size((elems+1) * 2)) - : 0; - /* Should we reallocate? */ if (old_state != NULL) { - if (old_state->size >= new_size) { + if (old_state->max_if_count >= max_if_count) { + /* if we're staying the same or shrinking, don't grow */ return (old_state); } } - - state = malloc(new_size); - bzero(state, new_size); - state->size = new_size; - - /* - * v4 list is stored 0 to elems, - * v6 list is stored elems + 1 to 2 * elems + 2 - */ - state->ipv6_start = elems + 1; + size = nwi_state_compute_size(max_if_count); + state = malloc(size); + bzero(state, size); + state->max_if_count = max_if_count; + state->version = NWI_STATE_VERSION; if (old_state != NULL) { state->ipv6_count = old_state->ipv6_count; if (state->ipv6_count > 0) { - bcopy((void*) &old_state->nwi_ifstates[old_state->ipv6_start], - (void*) &state->nwi_ifstates[state->ipv6_start], + bcopy((void *)&old_state->ifstate_list[old_state->max_if_count], + (void *)&state->ifstate_list[state->max_if_count], old_state->ipv6_count * sizeof(nwi_ifstate)); } state->ipv4_count = old_state->ipv4_count; if (state->ipv4_count > 0) { - bcopy((void*) old_state->nwi_ifstates, - (void*) state->nwi_ifstates, + bcopy((void *)old_state->ifstate_list, + (void *)state->ifstate_list, old_state->ipv4_count * sizeof(nwi_ifstate)); } - - free(old_state); + /* we grew the arrays so re-compute the offsets */ + nwi_state_fix_af_aliases(state, old_state->max_if_count); + nwi_state_set_if_list(state); + nwi_state_free(old_state); } else { state->ipv4_count = 0; state->ipv6_count = 0; } - nwi_state_set_last(state, AF_INET); - nwi_state_set_last(state, AF_INET6); - - state->ref = 1; - state->svr = FALSE; return state; } +__private_extern__ void +nwi_state_finalize(nwi_state_t state) +{ + if (state == NULL) { + return; + } + nwi_state_set_if_list(state); + return; +} + static __inline__ nwi_ifstate_t -nwi_ifstate_get_last(nwi_state_t state, int af, uint32_t** last) +nwi_state_get_last_ifstate(nwi_state_t state, int af, nwi_ifindex_t** last) { - uint32_t* count; + nwi_ifindex_t * count; int idx; assert(state != NULL); @@ -136,11 +253,11 @@ nwi_ifstate_get_last(nwi_state_t state, int af, uint32_t** last) : &state->ipv6_count; idx = (af == AF_INET) ? state->ipv4_count - : (state->ipv6_start + state->ipv6_count); + : (state->max_if_count + state->ipv6_count); *last = count; - return &state->nwi_ifstates[idx]; + return &state->ifstate_list[idx]; } __private_extern__ @@ -152,36 +269,72 @@ nwi_ifstate_set_signature(nwi_ifstate_t ifstate, uint8_t * signature) return; } -__private_extern__ -nwi_ifstate_t -nwi_insert_ifstate(nwi_state_t state, - const char * ifname, int af, - uint64_t flags, Rank rank, - void * ifa, - struct sockaddr * vpn_server_addr, - uint32_t reach_flags) +static void +nwi_state_add_ifstate_alias(nwi_state_t state, nwi_ifstate_t ifstate) +{ + nwi_ifstate_t alias; + + alias = nwi_state_get_ifstate_with_name(state, + nwi_other_af(ifstate->af), + ifstate->ifname); + if (alias == NULL) { + return; + } + ifstate->af_alias_offset = (nwi_ifindex_t)(alias - ifstate); + alias->af_alias_offset = (nwi_ifindex_t)(ifstate - alias); + return; +} + +__private_extern__ nwi_ifstate_t +nwi_state_add_ifstate(nwi_state_t state, + const char * ifname, int af, + uint64_t flags, Rank rank, + void * ifa, + struct sockaddr * vpn_server_addr, + uint32_t reach_flags) { nwi_ifstate_t ifstate; - /* Will only insert unique elements in the list */ + /* Will only add unique elements to the list */ ifstate = nwi_state_get_ifstate_with_name(state, af, ifname); /* Already present, just ignore it */ if (ifstate != NULL) { if (ifstate->rank < rank) { + /* always true because they are added in order */ return NULL; } } + else { + /* add to the end */ + nwi_ifindex_t count; + nwi_ifindex_t * count_p; + + /* make sure we aren't already full */ + ifstate = nwi_state_get_last_ifstate(state, af, &count_p); + count = *count_p; + if (count == state->max_if_count) { + /* should not happen */ + syslog(LOG_ERR, + "nwi_state_add_ifstate: full at count %d\n", + count); + return (NULL); + } + if (count > 0) { + /* previous ifstate is no longer last */ + nwi_ifstate_t prev = ifstate - 1; - if (ifstate == NULL) { - uint32_t *last; - - /* We need to append it as the last element */ - ifstate = nwi_ifstate_get_last(state, af, &last); + prev->flags &= ~NWI_IFSTATE_FLAGS_LAST_ITEM; + } bzero(ifstate, sizeof(*ifstate)); strlcpy(ifstate->ifname, ifname, sizeof(ifstate->ifname)); ifstate->af = af; - (*last)++; + /* this is the new last ifstate */ + ifstate->flags |= NWI_IFSTATE_FLAGS_LAST_ITEM; + (*count_p)++; + + /* add the alias */ + nwi_state_add_ifstate_alias(state, ifstate); } /* We need to update the address/rank/flag fields for the existing/new @@ -208,8 +361,8 @@ nwi_insert_ifstate(nwi_state_t state, ifstate->reach_flags = reach_flags; ifstate->rank = rank; - ifstate->flags = flags; - + ifstate->flags &= ~NWI_IFSTATE_FLAGS_MASK; + ifstate->flags |= NWI_IFSTATE_FLAGS(flags); return ifstate; } @@ -217,65 +370,75 @@ __private_extern__ void nwi_state_clear(nwi_state_t state, int af) { - uint32_t* count; - - count = (af == AF_INET) - ?&state->ipv4_count:&state->ipv6_count; - - *count = 0; - nwi_state_set_last(state, af); + if (af == AF_INET) { + state->ipv4_count = 0; + } + else { + state->ipv6_count = 0; + } return; } __private_extern__ -void -nwi_state_set_last(nwi_state_t state, int af) +void * +nwi_ifstate_get_address(nwi_ifstate_t ifstate) { - int last_elem_idx; - - if (state == NULL) { - return; - } - - /* The last element is an element with the flags set as - * NWI_IFSTATE_FLAGS_NOT_IN_LIST */ - last_elem_idx = (af == AF_INET) ? state->ipv4_count - : (state->ipv6_start + state->ipv6_count); - - state->nwi_ifstates[last_elem_idx].ifname[0] = '\0'; - state->nwi_ifstates[last_elem_idx].flags = NWI_IFSTATE_FLAGS_NOT_IN_LIST; + return (void *)&ifstate->iaddr; } -#define unchanged "" -#define added "+" -#define deleted "-" -#define changed "!" -#define rank_change "R" -__private_extern__ -void * -nwi_ifstate_get_address(nwi_ifstate_t ifstate) +static __inline__ uint8_t +nwi_ifstate_get_diff(nwi_ifstate_t ifstate) { - return (void *)&ifstate->iaddr; + return (NWI_IFSTATE_FLAGS_GET_DIFF(ifstate->flags)); } -__private_extern__ -const char * +__private_extern__ const char * nwi_ifstate_get_diff_str(nwi_ifstate_t ifstate) { - if (strcmp(ifstate->diff_str, rank_change) == 0) { - return changed; + const char * strings[] = { + "", + "+", + "-", + "!", + "/", + "\\" + }; + uint8_t diff; + + diff = nwi_ifstate_get_diff(ifstate); + if (diff < sizeof(strings) / sizeof(strings[0])) { + return (strings[diff]); } - return ifstate->diff_str; + return ("?"); } -static -inline -boolean_t +__private_extern__ nwi_ifstate_difference_t +nwi_ifstate_get_difference(nwi_ifstate_t diff_ifstate) +{ + nwi_ifstate_difference_t diff; + + switch (nwi_ifstate_get_diff(diff_ifstate)) { + case NWI_IFSTATE_DIFF_ADDED: + case NWI_IFSTATE_DIFF_CHANGED: + diff = knwi_ifstate_difference_changed; + break; + case NWI_IFSTATE_DIFF_REMOVED: + diff = knwi_ifstate_difference_removed; + break; + default: + diff = knwi_ifstate_difference_none; + break; + } + return (diff); +} + +static inline boolean_t nwi_ifstate_has_changed(nwi_ifstate_t ifstate1, nwi_ifstate_t ifstate2) { - if (ifstate1->flags != ifstate2->flags) { + if (NWI_IFSTATE_FLAGS(ifstate1->flags) + != NWI_IFSTATE_FLAGS(ifstate2->flags)) { return TRUE; } @@ -291,158 +454,152 @@ nwi_ifstate_has_changed(nwi_ifstate_t ifstate1, nwi_ifstate_t ifstate2) return FALSE; } -static -inline -nwi_ifstate_t -nwi_ifstate_append(nwi_state_t state, nwi_ifstate_t scan) +static inline nwi_ifstate_t +nwi_state_diff_append(nwi_state_t state, nwi_ifstate_t scan) { nwi_ifstate_t new_ifstate = NULL; - uint32_t *last; + nwi_ifindex_t * last; - new_ifstate = nwi_ifstate_get_last(state, scan->af, &last); + new_ifstate = nwi_state_get_last_ifstate(state, scan->af, &last); memcpy(new_ifstate, scan, sizeof(*scan)); (*last)++; return new_ifstate; } -static -inline -void -nwi_ifstate_set_diff_str(nwi_ifstate_t ifstate, const char *diff_str) +static inline void +nwi_ifstate_set_diff(nwi_ifstate_t ifstate, uint8_t diff) { - ifstate->diff_str = diff_str; + ifstate->flags &= ~NWI_IFSTATE_FLAGS_DIFF_MASK; + if (diff != NWI_IFSTATE_DIFF_UNCHANGED) { + ifstate->flags |= NWI_IFSTATE_FLAGS_FROM_DIFF(diff); + } } -static -void -nwi_ifstate_set_added_or_changed_str(nwi_state_t state, nwi_state_t old_state, nwi_ifstate_t ifstate) +static void +nwi_state_diff_add_change(nwi_state_t diff, nwi_state_t old, + nwi_ifstate_t ifstate) { - nwi_ifstate_t existing_ifstate, new_ifstate; - - existing_ifstate = nwi_state_get_ifstate_with_name(old_state, - ifstate->af, - nwi_ifstate_get_ifname(ifstate)); - - /* Add the element that is not in the store */ - new_ifstate = nwi_ifstate_append(state, ifstate); - - /* These are potentially "added" elements unless they are - * in the old list */ - nwi_ifstate_set_diff_str(new_ifstate, added); - - if (existing_ifstate != NULL) { - if (nwi_ifstate_has_changed(existing_ifstate, new_ifstate) == TRUE) { - nwi_ifstate_set_diff_str(new_ifstate, changed); - } else if (existing_ifstate->rank != new_ifstate->rank) { - nwi_ifstate_set_diff_str(new_ifstate, rank_change); + nwi_ifstate_t existing; + nwi_ifstate_t new; + + existing = nwi_state_get_ifstate_with_name(old, + ifstate->af, + nwi_ifstate_get_ifname(ifstate)); + new = nwi_state_diff_append(diff, ifstate); + if (existing != NULL) { + if (nwi_ifstate_has_changed(existing, new)) { + nwi_ifstate_set_diff(new, + NWI_IFSTATE_DIFF_CHANGED); + } else if (existing->rank < new->rank) { + nwi_ifstate_set_diff(new, + NWI_IFSTATE_DIFF_RANK_DOWN); + } else if (existing->rank > new->rank) { + nwi_ifstate_set_diff(new, + NWI_IFSTATE_DIFF_RANK_UP); } else { - nwi_ifstate_set_diff_str(new_ifstate, unchanged); + nwi_ifstate_set_diff(new, + NWI_IFSTATE_DIFF_UNCHANGED); } + } else { + nwi_ifstate_set_diff(new, NWI_IFSTATE_DIFF_ADDED); } return; } -static -void -nwi_ifstate_set_removed_str(nwi_state_t state, nwi_ifstate_t ifstate) +static void +nwi_state_diff_remove(nwi_state_t state, nwi_ifstate_t ifstate) { - nwi_ifstate_t existing_ifstate; + nwi_ifstate_t removed_ifstate; - existing_ifstate = nwi_state_get_ifstate_with_name(state, - ifstate->af, - nwi_ifstate_get_ifname(ifstate)); - - /* Any elements that has not been added means that they are removed */ - if (existing_ifstate == NULL) { - nwi_ifstate_t new_ifstate = nwi_ifstate_append(state, ifstate); - nwi_ifstate_set_diff_str(new_ifstate, deleted); + if (nwi_state_get_ifstate_with_name(state, + ifstate->af, + nwi_ifstate_get_ifname(ifstate)) + != NULL) { + /* there's still an ifstate */ + return; } + removed_ifstate = nwi_state_diff_append(state, ifstate); + nwi_ifstate_set_diff(removed_ifstate, NWI_IFSTATE_DIFF_REMOVED); return; } -static -void -nwi_state_merge_added(nwi_state_t state, nwi_state_t old_state, - nwi_state_t new_state) +static void +nwi_state_diff_populate(nwi_state_t diff, nwi_state_t old, nwi_state_t new) { int i; nwi_ifstate_t scan; - if (new_state == NULL) { - return; - } - - if (new_state->ipv4_count) { - for (i = 0, scan = new_state->nwi_ifstates; - i < new_state->ipv4_count; i++, scan++) { - nwi_ifstate_set_added_or_changed_str(state, old_state, scan); + if (new != NULL) { + /* check for adds/changes */ + if (new->ipv4_count) { + for (i = 0, scan = new->ifstate_list; + i < new->ipv4_count; i++, scan++) { + nwi_state_diff_add_change(diff, old, scan); + } + } + if (new->ipv6_count) { + scan = new->ifstate_list + new->max_if_count; + for (i = 0; + i < new->ipv6_count; i++, scan++) { + nwi_state_diff_add_change(diff, old, scan); + } } - nwi_state_set_last(state, AF_INET); } - - if (new_state->ipv6_count) { - for (i = 0, scan = new_state->nwi_ifstates + new_state->ipv6_start; - i < new_state->ipv6_count; i++, scan++) { - nwi_ifstate_set_added_or_changed_str(state, old_state, scan); + if (old != NULL) { + /* check for removes */ + if (old->ipv4_count) { + for (i = 0, scan = old->ifstate_list; + i < old->ipv4_count; i++, scan++) { + nwi_state_diff_remove(diff, scan); + } + } + if (old->ipv6_count) { + scan = old->ifstate_list + old->max_if_count; + for (i = 0; + i < old->ipv6_count; i++, scan++) { + nwi_state_diff_remove(diff, scan); + } } - nwi_state_set_last(state, AF_INET6); } return; } -void -nwi_state_merge_removed(nwi_state_t state, nwi_state_t old_state) +static int +nwi_state_max_af_count(nwi_state_t state) { - int i; - nwi_ifstate_t scan; - - if (old_state == NULL) { - return; - } - - if (old_state->ipv4_count) { - for (i = 0, scan = old_state->nwi_ifstates; - i < old_state->ipv4_count; i++, scan++) { - nwi_ifstate_set_removed_str(state, scan); - } - nwi_state_set_last(state, AF_INET); - } - - if (old_state->ipv6_count) { - for (i = 0, scan = old_state->nwi_ifstates + old_state->ipv6_start; - i < old_state->ipv6_count; i++, scan++) { - nwi_ifstate_set_removed_str(state, scan); - } - nwi_state_set_last(state, AF_INET6); + if (state->ipv4_count >= state->ipv6_count) { + return (state->ipv4_count); } - return; + return (state->ipv6_count); } -__private_extern__ -nwi_state_t -nwi_state_diff(nwi_state_t old_state, nwi_state_t new_state) +__private_extern__ nwi_state_t +nwi_state_diff(nwi_state_t old, nwi_state_t new) { nwi_state_t diff; int total_count = 0; - if (old_state != NULL) { - total_count = old_state->ipv4_count + old_state->ipv6_count; + /* + * Compute the worst case total number of elements we need: + * the max count of (IPv4, IPv6) in the old + * + the max count of (IPv4, IPv6) in the new + * Worst case assumes that the old and new share none of the + * same interfaces. + */ + if (old != NULL) { + total_count += nwi_state_max_af_count(old); } - - if (new_state != NULL) { - total_count += new_state->ipv4_count + new_state->ipv6_count; + if (new != NULL) { + total_count += nwi_state_max_af_count(new); } - if (total_count == 0) { return NULL; } diff = nwi_state_new(NULL, total_count); + nwi_state_diff_populate(diff, old, new); - nwi_state_merge_added(diff, old_state, new_state); - nwi_state_merge_removed(diff, old_state); - - /* Diff consists of a nwi_state_t with annotated diff_str's */ + /* diff consists of a nwi_state_t with diff flags on each ifstate */ return diff; } @@ -468,9 +625,7 @@ _nwi_ifstate_has_changed(nwi_state_t state, const char * ifname) ifname); if (ifstate != NULL - && ifstate->diff_str != NULL - && strcmp(ifstate->diff_str, unchanged) != 0 - && strcmp(ifstate->diff_str, rank_change) != 0) { + && nwi_ifstate_get_diff(ifstate) != NWI_IFSTATE_DIFF_UNCHANGED) { return (TRUE); } @@ -479,9 +634,7 @@ _nwi_ifstate_has_changed(nwi_state_t state, const char * ifname) ifname); if (ifstate != NULL - && ifstate->diff_str != NULL - && strcmp(ifstate->diff_str, unchanged) != 0 - && strcmp(ifstate->diff_str, rank_change) != 0) { + && nwi_ifstate_get_diff(ifstate) != NWI_IFSTATE_DIFF_UNCHANGED) { return (TRUE); } return (FALSE); @@ -502,51 +655,75 @@ _nwi_state_update_interface_generations(nwi_state_t old_state, nwi_state_t state /* cache the generation count */ generation_count = state->generation_count; - if (state->ipv4_count) { - for (i = 0, scan = state->nwi_ifstates; - i < state->ipv4_count; i++, scan++) { - if (_nwi_ifstate_has_changed(changes, scan->ifname) == TRUE) { - /* Update the interface generation count */ - _nwi_ifstate_set_generation(scan, generation_count); - } else { - nwi_ifstate_t old_ifstate; - - old_ifstate = nwi_state_get_ifstate_with_name(old_state, - AF_INET, - scan->ifname); - - /* Set the current generation count */ - _nwi_ifstate_set_generation(scan, - old_ifstate->if_generation_count); - } + for (i = 0, scan = nwi_state_ifstate_list(state, AF_INET); + i < state->ipv4_count; i++, scan++) { + if (_nwi_ifstate_has_changed(changes, scan->ifname) == TRUE) { + /* Update the interface generation count */ + _nwi_ifstate_set_generation(scan, generation_count); + } else { + nwi_ifstate_t old_ifstate; + + old_ifstate = nwi_state_get_ifstate_with_name(old_state, + AF_INET, + scan->ifname); + + /* Set the current generation count */ + _nwi_ifstate_set_generation(scan, + old_ifstate->if_generation_count); } } - - if (state->ipv6_count) { - for (i = 0, scan = state->nwi_ifstates + state->ipv6_start; - i < state->ipv6_count; i++, scan++) { - /* The generation count has been already updated in - * the ipv4 case, just skip it. */ - if (nwi_ifstate_get_generation(scan) == - generation_count) { - continue; - } - if (_nwi_ifstate_has_changed(changes, scan->ifname) == TRUE) { - /* update the interface generation count */ - _nwi_ifstate_set_generation(scan, generation_count); - } else { - nwi_ifstate_t old_ifstate; - - old_ifstate = nwi_state_get_ifstate_with_name(old_state, - AF_INET6, - scan->ifname); - assert(old_ifstate != NULL); - - /* Set the current generation count */ - _nwi_ifstate_set_generation(scan, - old_ifstate->if_generation_count); - } + for (i = 0, scan = nwi_state_ifstate_list(state, AF_INET6); + i < state->ipv6_count; i++, scan++) { + /* The generation count has been already updated in + * the ipv4 case, just skip it. */ + if (nwi_ifstate_get_generation(scan) == + generation_count) { + continue; + } + if (_nwi_ifstate_has_changed(changes, scan->ifname) == TRUE) { + /* update the interface generation count */ + _nwi_ifstate_set_generation(scan, generation_count); + } else { + nwi_ifstate_t old_ifstate; + + old_ifstate = nwi_state_get_ifstate_with_name(old_state, + AF_INET6, + scan->ifname); + assert(old_ifstate != NULL); + + /* Set the current generation count */ + _nwi_ifstate_set_generation(scan, + old_ifstate->if_generation_count); } } return; } + +__private_extern__ +void +_nwi_state_compute_sha1_hash(nwi_state_t state, + unsigned char hash[CC_SHA1_DIGEST_LENGTH]) +{ + if (state == NULL) { + bzero(hash, CC_SHA1_DIGEST_LENGTH); + } + else { + CC_SHA1_CTX ctx; + uint64_t generation_save; + + generation_save = state->generation_count; + + /* zero out the generation count before computing hash */ + state->generation_count = 0; + + /* compute hash */ + CC_SHA1_Init(&ctx); + CC_SHA1_Update(&ctx, state, (CC_LONG)nwi_state_size(state)); + CC_SHA1_Final(hash, &ctx); + + /* restore generation */ + state->generation_count = generation_save; + } + + return; +} diff --git a/nwi/network_information_priv.h b/nwi/network_information_priv.h index 5ea1ded..9bddc96 100644 --- a/nwi/network_information_priv.h +++ b/nwi/network_information_priv.h @@ -34,31 +34,42 @@ #include "network_information.h" -extern const sa_family_t nwi_af_list[2]; +#define NWI_IFSTATE_FLAGS_NOT_IN_LIST 0x0008 +#define NWI_IFSTATE_FLAGS_HAS_SIGNATURE 0x0010 +#define NWI_IFSTATE_FLAGS_NOT_IN_IFLIST 0x0020 -#define NWI_IFSTATE_FLAGS_NOT_IN_LIST 0x8 -#define NWI_IFSTATE_FLAGS_HAS_SIGNATURE 0x10 +/* + * NWI_IFSTATE_FLAGS_MASK + * - these are the bits that get preserved, all others are + * control (last item, diff) + */ +#define NWI_IFSTATE_FLAGS_MASK 0x00ff + + +#define NWI_IFSTATE_FLAGS_DIFF_MASK 0x0f00 +#define NWI_IFSTATE_FLAGS_LAST_ITEM 0x1000 + +typedef enum { + knwi_ifstate_difference_none = 0, + knwi_ifstate_difference_changed = 1, + knwi_ifstate_difference_removed = 2 +} nwi_ifstate_difference_t; -#define NWI_PTR(type, name) \ - union { \ - type name; \ - uint64_t _ ## name ## _p; \ - } typedef uint32_t Rank; +typedef int32_t nwi_ifindex_t; #pragma pack(4) typedef struct _nwi_ifstate { char ifname[IFNAMSIZ]; uint64_t flags; - NWI_PTR(nwi_ifstate_t, af_alias); + nwi_ifindex_t af_alias_offset; /* relative index to alias */ Rank rank; sa_family_t af; union { struct in_addr iaddr; struct in6_addr iaddr6; }; - NWI_PTR(const char *, diff_str); uint64_t if_generation_count; uint32_t reach_flags; union { @@ -69,70 +80,61 @@ typedef struct _nwi_ifstate { } nwi_ifstate; #pragma pack() -/* - * nwi_state - * - *+---------------------------------------------+ - *| generation_count | - *| | - *----------------------------------------------+ - *| size | - *| | - *|---------------------------------------------+ - *| ipv4_count | - *| | - *|---------------------------------------------+ - *| ipv6_count | - *| | - *|---------------------------------------------+ - *| ipv6_start |-------+ - *| | | - *|---------------------------------------------+ |ipv6_start stores the index of the start of the v6 list. - *| ref (reference count) | | - *| | | - *|---------------------------------------------+ | - *| svr (TRUE if copied from server) | | - *| | | - *|---------------------------------------------+ | - *| reach_flags_v4 | | - *| | | - *|---------------------------------------------+ | - *| reach_flags_v6 | | - *| | | - *|---------------------------------------------+ | - *| IPv4 nwi_ifstates | | - *| |<------|-------+ - *| ... | | | - *|---------------------------------------------+ | | - *| Sentinel nwi_ifstates | | | - *| flags =NWI_IFSTATE_FLAGS_RANK_NEVER) | | | af_alias points to the same ifstate in the - *| | | | opposite (v4 -> v6 and vice versa) af list. - *|---------------------------------------------+ | | - *| IPv6 nwi_ifstates |<------+ | - *| |<--------------+ - *| ... | - *|---------------------------------------------+ - *| Sentinel nwi_ifstates | - *| flags =NWI_IFSTATE_FLAGS_RANK_NEVER) | - *| | - *|---------------------------------------------+ - * - */ +#define NWI_STATE_VERSION ((uint32_t)0x20150214) + #pragma pack(4) typedef struct _nwi_state { - uint64_t generation_count; - uint32_t size; - uint32_t ipv4_count; - uint32_t ipv6_count; - uint32_t ipv6_start; - uint32_t ref; - _Bool svr; + uint32_t version; /* NWI_STATE_VERSION */ + nwi_ifindex_t max_if_count; /* available slots per protocol */ + nwi_ifindex_t ipv4_count; /* # of v4 ifstates in use */ + nwi_ifindex_t ipv6_count; /* # of v6 ifstates in use */ + nwi_ifindex_t if_list_count; /* # of if_list[] slots in use */ + uint32_t ref; /* reference count */ uint32_t reach_flags_v4; uint32_t reach_flags_v6; - nwi_ifstate nwi_ifstates[0]; + uint64_t generation_count; + nwi_ifstate ifstate_list[1];/* (max_if_count * 2) ifstates */ +/* nwi_ifindex_t if_list[0]; max_if_count indices */ } nwi_state; #pragma pack() +static __inline__ int +nwi_other_af(int af) +{ + return ((af == AF_INET) ? (AF_INET6) : (AF_INET)); +} + +static __inline__ size_t +nwi_state_compute_size(unsigned int max_if_count) +{ + size_t size; + + size = offsetof(nwi_state, ifstate_list[max_if_count * 2]) + + sizeof(nwi_ifindex_t) * max_if_count; + return (size); +} + +static __inline__ size_t +nwi_state_size(nwi_state_t state) +{ + return (nwi_state_compute_size(state->max_if_count)); +} + +static __inline__ nwi_ifstate_t +nwi_state_ifstate_list(nwi_state_t state, int af) +{ + if (af == AF_INET) { + return (state->ifstate_list); + } + return (state->ifstate_list + state->max_if_count); +} + +static __inline__ nwi_ifindex_t * +nwi_state_if_list(nwi_state_t state) +{ + return ((nwi_ifindex_t *)&state->ifstate_list[state->max_if_count * 2]); +} + static __inline__ int uint32_cmp(uint32_t a, uint32_t b) { @@ -171,6 +173,18 @@ nwi_state_get_ifstate_count(nwi_state_t state, int af) return (af == AF_INET)?state->ipv4_count:state->ipv6_count; } +static __inline__ nwi_ifstate_t +nwi_ifstate_get_alias(nwi_ifstate_t ifstate, int af) +{ + if (ifstate->af == af) { + return (ifstate); + } + if (ifstate->af_alias_offset == 0) { + return (NULL); + } + return (ifstate + ifstate->af_alias_offset); +} + /* * The ifstate list is sorted in order of decreasing priority, with the * highest priority element appearing at index zero. @@ -181,18 +195,17 @@ static __inline__ nwi_ifstate_t nwi_state_get_ifstate_with_index(nwi_state_t state, int af, int idx) { - nwi_ifstate_t nwi_ifstate = NULL; int i_idx = idx; - if (idx > nwi_state_get_ifstate_count(state, af)) { - return (nwi_ifstate); + if (idx >= nwi_state_get_ifstate_count(state, af)) { + return (NULL); } if (af == AF_INET6) { - i_idx = idx + state->ipv6_start; + i_idx = idx + state->max_if_count; } - return &state->nwi_ifstates[i_idx]; + return &state->ifstate_list[i_idx]; } /* @@ -213,7 +226,7 @@ nwi_state_get_ifstate_with_name(nwi_state_t state, nwi_ifstate_t ifstate = NULL; if (state == NULL) { - return ifstate; + return NULL; } count = (af == AF_INET) @@ -272,12 +285,22 @@ nwi_state_t nwi_state_new(nwi_state_t old_state, int elems); nwi_state_t -nwi_state_copy_priv(nwi_state_t old_state); +nwi_state_make_copy(nwi_state_t state); + +static __inline__ void +nwi_state_free(nwi_state_t state) +{ + free(state); + return; +} + +void +nwi_state_finalize(nwi_state_t state); nwi_ifstate_t -nwi_insert_ifstate(nwi_state_t state, const char* ifname, int af, - uint64_t flags, Rank rank, - void * ifa, struct sockaddr * vpn_server_addr, uint32_t reach_flags); +nwi_state_add_ifstate(nwi_state_t state, const char* ifname, int af, + uint64_t flags, Rank rank, + void * ifa, struct sockaddr * vpn_server_addr, uint32_t reach_flags); void nwi_ifstate_set_signature(nwi_ifstate_t ifstate, uint8_t * signature); @@ -285,9 +308,6 @@ nwi_ifstate_set_signature(nwi_ifstate_t ifstate, uint8_t * signature); void nwi_state_clear(nwi_state_t state, int af); -void -nwi_state_set_last(nwi_state_t state, int af); - nwi_state_t nwi_state_diff(nwi_state_t old_state, nwi_state_t new_state); @@ -297,10 +317,18 @@ nwi_ifstate_get_address(nwi_ifstate_t ifstate); const char * nwi_ifstate_get_diff_str(nwi_ifstate_t ifstate); +nwi_ifstate_difference_t +nwi_ifstate_get_difference(nwi_ifstate_t diff_ifstate); + void _nwi_state_update_interface_generations(nwi_state_t old_state, nwi_state_t state, nwi_state_t changes); void _nwi_state_force_refresh(); +void +_nwi_state_compute_sha1_hash(nwi_state_t state, + unsigned char hash[CC_SHA1_DIGEST_LENGTH]); + + #endif diff --git a/nwi/network_information_server.c b/nwi/network_information_server.c index 41bec2c..fd64af3 100644 --- a/nwi/network_information_server.c +++ b/nwi/network_information_server.c @@ -1,15 +1,15 @@ /* - * Copyright (c) 2012-2014 Apple Inc. All rights reserved. + * Copyright (c) 2012-2015 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ - * + * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. - * + * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, @@ -17,7 +17,7 @@ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. - * + * * @APPLE_LICENSE_HEADER_END@ */ @@ -56,10 +56,9 @@ static libSC_info_server_t S_nwi_info; /* - * S_debug - * A boolean that enables additional logging. + * S_logger + * Logging handle. */ -static Boolean *S_debug = NULL; static SCLoggerRef S_logger = NULL; @@ -77,21 +76,6 @@ static _nwi_sync_handler_t S_sync_handler = NULL; #pragma mark Support functions -#ifdef NOT_YET_NEEDED -static void -log_xpc_object(const char *msg, xpc_object_t obj) -{ - char *desc; - - desc = xpc_copy_description(obj); - if (*S_debug) { - SCLoggerLog(S_logger, LOG_DEBUG, "%s = %s", msg, desc); - } - free(desc); -} -#endif - - #pragma mark - #pragma mark Network information server "main" @@ -123,6 +107,7 @@ _nwi_state_copy(xpc_connection_t connection, xpc_object_t request) { CFDataRef data; uint64_t generation; + const char *proc_name; xpc_connection_t remote; xpc_object_t reply; @@ -138,22 +123,18 @@ _nwi_state_copy(xpc_connection_t connection, xpc_object_t request) // extract data and generation # data = _libSC_info_server_get_data(&S_nwi_info, connection, &generation); - if (*S_debug) { - const char *proc_name; - - // extract process name - proc_name = xpc_dictionary_get_string(request, NWI_PROC_NAME); - if (proc_name == NULL) { - proc_name = "???"; - } - - SCLoggerLog(S_logger, LOG_DEBUG, CFSTR("<%p:%s[%d]> Network information copy: %llu"), - connection, - proc_name, - xpc_connection_get_pid(connection), - generation); + // extract process name + proc_name = xpc_dictionary_get_string(request, NWI_PROC_NAME); + if (proc_name == NULL) { + proc_name = "???"; } + SCLoggerLog(S_logger, LOG_DEBUG, CFSTR("<%p:%s[%d]> Network information copy: %llu"), + connection, + proc_name, + xpc_connection_get_pid(connection), + generation); + // return the Network information (if available) if (data != NULL) { xpc_dictionary_set_data(reply, @@ -186,12 +167,10 @@ _nwi_state_acknowledge(xpc_connection_t connection, xpc_object_t request) generation = xpc_dictionary_get_uint64(request, NWI_GENERATION); - if (*S_debug) { - SCLoggerLog(S_logger, LOG_DEBUG, CFSTR("<%p:%d> Network information ack: %llu"), - connection, - xpc_connection_get_pid(connection), - generation); - } + SCLoggerLog(S_logger, LOG_DEBUG, CFSTR("<%p:%d> Network information ack: %llu"), + connection, + xpc_connection_get_pid(connection), + generation); _libSC_info_server_acknowledged(&S_nwi_info, connection, generation); changed = _libSC_info_server_acknowledged(&S_nwi_info, connection, generation); @@ -244,19 +223,21 @@ process_request(xpc_connection_t connection, xpc_object_t request) static void process_new_connection(xpc_connection_t c) { - if (*S_debug) { - SCLoggerLog(S_logger, LOG_DEBUG, CFSTR("<%p:%d> Network information session: open"), - c, - xpc_connection_get_pid(c)); - } + SCLoggerLog(S_logger, LOG_DEBUG, CFSTR("<%p:%d> Network information session: open"), + c, + xpc_connection_get_pid(c)); _libSC_info_server_open(&S_nwi_info, c); xpc_connection_set_target_queue(c, _nwi_state_server_queue()); xpc_connection_set_event_handler(c, ^(xpc_object_t xobj) { + os_activity_t activity_id; xpc_type_t type; + activity_id = os_activity_start("processing nwi request", + OS_ACTIVITY_FLAG_DEFAULT); + type = xpc_get_type(xobj); if (type == XPC_TYPE_DICTIONARY) { // process the request @@ -269,11 +250,9 @@ process_new_connection(xpc_connection_t c) if (xobj == XPC_ERROR_CONNECTION_INVALID) { Boolean changed; - if (*S_debug) { - SCLoggerLog(S_logger, LOG_DEBUG, CFSTR("<%p:%d> Network information session: close"), - c, - xpc_connection_get_pid(c)); - } + SCLoggerLog(S_logger, LOG_DEBUG, CFSTR("<%p:%d> Network information session: close"), + c, + xpc_connection_get_pid(c)); changed = _libSC_info_server_close(&S_nwi_info, c); if (changed) { @@ -307,6 +286,8 @@ process_new_connection(xpc_connection_t c) xpc_connection_get_pid(c), type); } + + os_activity_end(activity_id); }); xpc_connection_resume(c); @@ -323,13 +304,11 @@ __private_extern__ void load_NetworkInformation(CFBundleRef bundle, SCLoggerRef logger, - Boolean *bundleVerbose, _nwi_sync_handler_t syncHandler) { xpc_connection_t c; const char *name; - S_debug = bundleVerbose; S_logger = logger; /* @@ -353,8 +332,12 @@ load_NetworkInformation(CFBundleRef bundle, XPC_CONNECTION_MACH_SERVICE_LISTENER); xpc_connection_set_event_handler(c, ^(xpc_object_t event) { + os_activity_t activity_id; xpc_type_t type; + activity_id = os_activity_start("processing nwi connection", + OS_ACTIVITY_FLAG_DEFAULT); + type = xpc_get_type(event); if (type == XPC_TYPE_CONNECTION) { process_new_connection(event); @@ -381,6 +364,8 @@ load_NetworkInformation(CFBundleRef bundle, type); } + + os_activity_end(activity_id); }); xpc_connection_resume(c); @@ -391,40 +376,6 @@ SCLoggerLog(S_logger, LOG_DEBUG, CFSTR("XPC server \"%s\" started"), name); } -__private_extern__ -void -_nwi_state_signature(nwi_state *state, - unsigned char *signature, - size_t signature_len) -{ - bzero(signature, signature_len); - - if (state != NULL) { - CC_SHA1_CTX ctx; - uint64_t generation_save; - unsigned char *sha1; - unsigned char sha1_buf[CC_SHA1_DIGEST_LENGTH]; - - generation_save = state->generation_count; - state->generation_count = 0; - - sha1 = (signature_len >= CC_SHA1_DIGEST_LENGTH) ? signature : sha1_buf; - CC_SHA1_Init(&ctx); - CC_SHA1_Update(&ctx, - state, - state->size); - CC_SHA1_Final(sha1, &ctx); - if (sha1 != signature) { - bcopy(sha1, signature, signature_len); - } - - state->generation_count = generation_save; - } - - return; -} - - __private_extern__ _Bool _nwi_state_store(nwi_state *state) @@ -440,13 +391,11 @@ _nwi_state_store(nwi_state *state) new_generation = state->generation_count; - if (*S_debug) { - SCLoggerLog(S_logger, LOG_DEBUG, CFSTR("Network information updated: %llu"), - new_generation); - } + SCLoggerLog(S_logger, LOG_DEBUG, CFSTR("Network information updated: %llu"), + new_generation); bytes = (const UInt8 *)state; - len = state->size; + len = nwi_state_size(state); new_nwi_info = CFDataCreate(NULL, bytes, len); } @@ -496,11 +445,10 @@ main(int argc, char **argv) load_NetworkInformation(CFBundleGetMainBundle(), // bundle NULL, // SCLogger - &verbose, // bundleVerbose ^(Boolean inSync) { // sync handler SCLoggerLog(NULL, LOG_INFO, - CFSTR("in sync: %s"), - inSync ? "Yes" : "No"); + CFSTR("in sync: %s"), + inSync ? "Yes" : "No"); }); CFRunLoopRun(); /* not reached */ diff --git a/nwi/network_information_server.h b/nwi/network_information_server.h index bdd8b34..8f147a2 100644 --- a/nwi/network_information_server.h +++ b/nwi/network_information_server.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013 Apple Inc. All rights reserved. + * Copyright (c) 2012, 2013, 2015 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -37,7 +37,6 @@ __BEGIN_DECLS void load_NetworkInformation (CFBundleRef bundle, SCLoggerRef logger, - Boolean *bundleVerbose, _nwi_sync_handler_t syncHandler); void diff --git a/nwi/test_nwi_reference.txt b/nwi/test_nwi_reference.txt new file mode 100644 index 0000000..0d84141 --- /dev/null +++ b/nwi/test_nwi_reference.txt @@ -0,0 +1,215 @@ +nwi_state = { gen=0 max_if=1 #v4=0 #v6=0 reach_flags=(v4=0x0, v6=0x0) } +0 interfaces +IPv4 traverse list: +IPv6 traverse list: +----------------------------------- +nwi_state = { gen=0 max_if=2 #v4=0 #v6=0 reach_flags=(v4=0x0, v6=0x0) } +0 interfaces +IPv4 traverse list: +IPv6 traverse list: +----------------------------------- +nwi_state = { gen=0 max_if=10 #v4=0 #v6=0 reach_flags=(v4=0x0, v6=0x0) } +0 interfaces +IPv4 traverse list: +IPv6 traverse list: +----------------------------------- +nwi_state = { gen=0 max_if=5 #v4=5 #v6=5 reach_flags=(v4=0x0, v6=0x0) } +IPv4: +[0] en0 rank 0x1 iaddr 0.0.0.1 reach_flags 0x0 +[1] en1 rank 0x0 iaddr 0.0.0.1 reach_flags 0x0 +[2] en2 rank 0x3 iaddr 0.0.0.3 reach_flags 0x0 +[3] en3 rank 0x2 iaddr 0.0.0.3 reach_flags 0x0 +[4] en4 rank 0x5 iaddr 0.0.0.5 reach_flags 0x0 +IPv6: +[0] en0 rank 0x0 iaddr :: reach_flags 0x0 +[1] en1 rank 0x9 iaddr 0:1:: reach_flags 0x0 +[2] en2 rank 0x2 iaddr 0:2:: reach_flags 0x0 +[3] en3 rank 0x7 iaddr 0:3:: reach_flags 0x0 +[4] en4 rank 0x4 iaddr 0:4:: reach_flags 0x0 +5 interfaces: en0, en1, en2, en3, en4 +IPv4 traverse list: +[0] flags=0x0 en0 rank 0x1 iaddr 0.0.0.1 reach_flags 0x0 + alias is en0 rank 0x0 iaddr :: reach_flags 0x0 +[1] flags=0x0 en1 rank 0x0 iaddr 0.0.0.1 reach_flags 0x0 + alias is en1 rank 0x9 iaddr 0:1:: reach_flags 0x0 +[2] flags=0x0 en2 rank 0x3 iaddr 0.0.0.3 reach_flags 0x0 + alias is en2 rank 0x2 iaddr 0:2:: reach_flags 0x0 +[3] flags=0x0 en3 rank 0x2 iaddr 0.0.0.3 reach_flags 0x0 + alias is en3 rank 0x7 iaddr 0:3:: reach_flags 0x0 +[4] flags=0x1000 en4 rank 0x5 iaddr 0.0.0.5 reach_flags 0x0 + alias is en4 rank 0x4 iaddr 0:4:: reach_flags 0x0 +IPv6 traverse list: +[0] flags=0x0 en0 rank 0x0 iaddr :: reach_flags 0x0 + alias is en0 rank 0x1 iaddr 0.0.0.1 reach_flags 0x0 +[1] flags=0x0 en1 rank 0x9 iaddr 0:1:: reach_flags 0x0 + alias is en1 rank 0x0 iaddr 0.0.0.1 reach_flags 0x0 +[2] flags=0x0 en2 rank 0x2 iaddr 0:2:: reach_flags 0x0 + alias is en2 rank 0x3 iaddr 0.0.0.3 reach_flags 0x0 +[3] flags=0x0 en3 rank 0x7 iaddr 0:3:: reach_flags 0x0 + alias is en3 rank 0x2 iaddr 0.0.0.3 reach_flags 0x0 +[4] flags=0x1000 en4 rank 0x4 iaddr 0:4:: reach_flags 0x0 + alias is en4 rank 0x5 iaddr 0.0.0.5 reach_flags 0x0 +----------------------------------- +DIFF +nwi_state = { gen=0 max_if=5 #v4=5 #v6=5 reach_flags=(v4=0x0, v6=0x0) } +IPv4: +[0] en0+ rank 0x1 iaddr 0.0.0.1 reach_flags 0x0 +[1] en1+ rank 0x0 iaddr 0.0.0.1 reach_flags 0x0 +[2] en2+ rank 0x3 iaddr 0.0.0.3 reach_flags 0x0 +[3] en3+ rank 0x2 iaddr 0.0.0.3 reach_flags 0x0 +[4] en4+ rank 0x5 iaddr 0.0.0.5 reach_flags 0x0 +IPv6: +[0] en0+ rank 0x0 iaddr :: reach_flags 0x0 +[1] en1+ rank 0x9 iaddr 0:1:: reach_flags 0x0 +[2] en2+ rank 0x2 iaddr 0:2:: reach_flags 0x0 +[3] en3+ rank 0x7 iaddr 0:3:: reach_flags 0x0 +[4] en4+ rank 0x4 iaddr 0:4:: reach_flags 0x0 +----------------------------------- +nwi_state = { gen=0 max_if=10 #v4=5 #v6=5 reach_flags=(v4=0x0, v6=0x0) } +IPv4: +[0] en0 rank 0x1 iaddr 0.0.0.1 reach_flags 0x0 +[1] en1 rank 0x0 iaddr 0.0.0.1 reach_flags 0x0 +[2] en2 rank 0x3 iaddr 0.0.0.3 reach_flags 0x0 +[3] en3 rank 0x2 iaddr 0.0.0.3 reach_flags 0x0 +[4] en4 rank 0x5 iaddr 0.0.0.5 reach_flags 0x0 +IPv6: +[0] en0 rank 0x0 iaddr :: reach_flags 0x0 +[1] en1 rank 0x9 iaddr 0:1:: reach_flags 0x0 +[2] en2 rank 0x2 iaddr 0:2:: reach_flags 0x0 +[3] en3 rank 0x7 iaddr 0:3:: reach_flags 0x0 +[4] en4 rank 0x4 iaddr 0:4:: reach_flags 0x0 +5 interfaces: en0, en1, en2, en3, en4 +IPv4 traverse list: +[0] flags=0x0 en0 rank 0x1 iaddr 0.0.0.1 reach_flags 0x0 + alias is en0 rank 0x0 iaddr :: reach_flags 0x0 +[1] flags=0x0 en1 rank 0x0 iaddr 0.0.0.1 reach_flags 0x0 + alias is en1 rank 0x9 iaddr 0:1:: reach_flags 0x0 +[2] flags=0x0 en2 rank 0x3 iaddr 0.0.0.3 reach_flags 0x0 + alias is en2 rank 0x2 iaddr 0:2:: reach_flags 0x0 +[3] flags=0x0 en3 rank 0x2 iaddr 0.0.0.3 reach_flags 0x0 + alias is en3 rank 0x7 iaddr 0:3:: reach_flags 0x0 +[4] flags=0x1000 en4 rank 0x5 iaddr 0.0.0.5 reach_flags 0x0 + alias is en4 rank 0x4 iaddr 0:4:: reach_flags 0x0 +IPv6 traverse list: +[0] flags=0x0 en0 rank 0x0 iaddr :: reach_flags 0x0 + alias is en0 rank 0x1 iaddr 0.0.0.1 reach_flags 0x0 +[1] flags=0x0 en1 rank 0x9 iaddr 0:1:: reach_flags 0x0 + alias is en1 rank 0x0 iaddr 0.0.0.1 reach_flags 0x0 +[2] flags=0x0 en2 rank 0x2 iaddr 0:2:: reach_flags 0x0 + alias is en2 rank 0x3 iaddr 0.0.0.3 reach_flags 0x0 +[3] flags=0x0 en3 rank 0x7 iaddr 0:3:: reach_flags 0x0 + alias is en3 rank 0x2 iaddr 0.0.0.3 reach_flags 0x0 +[4] flags=0x1000 en4 rank 0x4 iaddr 0:4:: reach_flags 0x0 + alias is en4 rank 0x5 iaddr 0.0.0.5 reach_flags 0x0 +----------------------------------- +nwi_state = { gen=0 max_if=10 #v4=10 #v6=10 reach_flags=(v4=0x0, v6=0x0) } +IPv4: +[0] en0 rank 0x0 iaddr 0.0.0.0 reach_flags 0x0 +[1] en1 rank 0x0 iaddr 0.0.0.1 reach_flags 0x0 +[2] en2 rank 0x2 iaddr 0.0.0.2 reach_flags 0x0 +[3] en3 rank 0x2 iaddr 0.0.0.3 reach_flags 0x0 +[4] en4 rank 0x4 iaddr 0.0.0.4 reach_flags 0x0 +[5] en9 rank 0x9 iaddr 0.0.0.9 reach_flags 0x0 +[6] en8 rank 0x8 iaddr 0.0.0.8 reach_flags 0x0 +[7] en7 rank 0x7 iaddr 0.0.0.7 reach_flags 0x0 +[8] en6 rank 0x6 iaddr 0.0.0.6 reach_flags 0x0 +[9] en5 rank 0x5 iaddr 0.0.0.5 reach_flags 0x0 +IPv6: +[0] en0 rank 0x0 iaddr :: reach_flags 0x0 +[1] en1 rank 0x1 iaddr 0:1:: reach_flags 0x0 +[2] en2 rank 0x2 iaddr 0:2:: reach_flags 0x0 +[3] en3 rank 0x3 iaddr 0:3:: reach_flags 0x0 +[4] en4 rank 0x4 iaddr 0:4:: reach_flags 0x0 +[5] en5 rank 0x5 iaddr 0:5:: reach_flags 0x0 +[6] en6 rank 0x6 iaddr 0:6:: reach_flags 0x0 +[7] en7 never rank 0x7 iaddr 0:7:: reach_flags 0x0 +[8] en8 never rank 0x8 iaddr 0:8:: reach_flags 0x0 +[9] en9 never rank 0x9 iaddr 0:9:: reach_flags 0x0 +10 interfaces: en0, en1, en2, en3, en4, en5, en6, en7, en8, en9 +IPv4 traverse list: +[0] flags=0x0 en0 rank 0x0 iaddr 0.0.0.0 reach_flags 0x0 + alias is en0 rank 0x0 iaddr :: reach_flags 0x0 +[1] flags=0x0 en1 rank 0x0 iaddr 0.0.0.1 reach_flags 0x0 + alias is en1 rank 0x1 iaddr 0:1:: reach_flags 0x0 +[2] flags=0x0 en2 rank 0x2 iaddr 0.0.0.2 reach_flags 0x0 + alias is en2 rank 0x2 iaddr 0:2:: reach_flags 0x0 +[3] flags=0x0 en3 rank 0x2 iaddr 0.0.0.3 reach_flags 0x0 + alias is en3 rank 0x3 iaddr 0:3:: reach_flags 0x0 +[4] flags=0x0 en4 rank 0x4 iaddr 0.0.0.4 reach_flags 0x0 + alias is en4 rank 0x4 iaddr 0:4:: reach_flags 0x0 +[5] flags=0x0 en9 rank 0x9 iaddr 0.0.0.9 reach_flags 0x0 + alias is en9 never rank 0x9 iaddr 0:9:: reach_flags 0x0 +[6] flags=0x0 en8 rank 0x8 iaddr 0.0.0.8 reach_flags 0x0 + alias is en8 never rank 0x8 iaddr 0:8:: reach_flags 0x0 +[7] flags=0x0 en7 rank 0x7 iaddr 0.0.0.7 reach_flags 0x0 + alias is en7 never rank 0x7 iaddr 0:7:: reach_flags 0x0 +[8] flags=0x0 en6 rank 0x6 iaddr 0.0.0.6 reach_flags 0x0 + alias is en6 rank 0x6 iaddr 0:6:: reach_flags 0x0 +[9] flags=0x1000 en5 rank 0x5 iaddr 0.0.0.5 reach_flags 0x0 + alias is en5 rank 0x5 iaddr 0:5:: reach_flags 0x0 +IPv6 traverse list: +[0] flags=0x0 en0 rank 0x0 iaddr :: reach_flags 0x0 + alias is en0 rank 0x0 iaddr 0.0.0.0 reach_flags 0x0 +[1] flags=0x0 en1 rank 0x1 iaddr 0:1:: reach_flags 0x0 + alias is en1 rank 0x0 iaddr 0.0.0.1 reach_flags 0x0 +[2] flags=0x0 en2 rank 0x2 iaddr 0:2:: reach_flags 0x0 + alias is en2 rank 0x2 iaddr 0.0.0.2 reach_flags 0x0 +[3] flags=0x0 en3 rank 0x3 iaddr 0:3:: reach_flags 0x0 + alias is en3 rank 0x2 iaddr 0.0.0.3 reach_flags 0x0 +[4] flags=0x0 en4 rank 0x4 iaddr 0:4:: reach_flags 0x0 + alias is en4 rank 0x4 iaddr 0.0.0.4 reach_flags 0x0 +[5] flags=0x0 en5 rank 0x5 iaddr 0:5:: reach_flags 0x0 + alias is en5 rank 0x5 iaddr 0.0.0.5 reach_flags 0x0 +[6] flags=0x0 en6 rank 0x6 iaddr 0:6:: reach_flags 0x0 + alias is en6 rank 0x6 iaddr 0.0.0.6 reach_flags 0x0 +----------------------------------- +DIFF +nwi_state = { gen=0 max_if=15 #v4=10 #v6=10 reach_flags=(v4=0x0, v6=0x0) } +IPv4: +[0] en0! rank 0x0 iaddr 0.0.0.0 reach_flags 0x0 +[1] en1 rank 0x0 iaddr 0.0.0.1 reach_flags 0x0 +[2] en2! rank 0x2 iaddr 0.0.0.2 reach_flags 0x0 +[3] en3 rank 0x2 iaddr 0.0.0.3 reach_flags 0x0 +[4] en4! rank 0x4 iaddr 0.0.0.4 reach_flags 0x0 +[5] en9+ rank 0x9 iaddr 0.0.0.9 reach_flags 0x0 +[6] en8+ rank 0x8 iaddr 0.0.0.8 reach_flags 0x0 +[7] en7+ rank 0x7 iaddr 0.0.0.7 reach_flags 0x0 +[8] en6+ rank 0x6 iaddr 0.0.0.6 reach_flags 0x0 +[9] en5+ rank 0x5 iaddr 0.0.0.5 reach_flags 0x0 +IPv6: +[0] en0 rank 0x0 iaddr :: reach_flags 0x0 +[1] en1/ rank 0x1 iaddr 0:1:: reach_flags 0x0 +[2] en2 rank 0x2 iaddr 0:2:: reach_flags 0x0 +[3] en3/ rank 0x3 iaddr 0:3:: reach_flags 0x0 +[4] en4 rank 0x4 iaddr 0:4:: reach_flags 0x0 +[5] en5+ rank 0x5 iaddr 0:5:: reach_flags 0x0 +[6] en6+ rank 0x6 iaddr 0:6:: reach_flags 0x0 +[7] en7+ never rank 0x7 iaddr 0:7:: reach_flags 0x0 +[8] en8+ never rank 0x8 iaddr 0:8:: reach_flags 0x0 +[9] en9+ never rank 0x9 iaddr 0:9:: reach_flags 0x0 +----------------------------------- +DIFF +nwi_state = { gen=0 max_if=15 #v4=10 #v6=10 reach_flags=(v4=0x0, v6=0x0) } +IPv4: +[0] en0! rank 0x1 iaddr 0.0.0.1 reach_flags 0x0 +[1] en1 rank 0x0 iaddr 0.0.0.1 reach_flags 0x0 +[2] en2! rank 0x3 iaddr 0.0.0.3 reach_flags 0x0 +[3] en3 rank 0x2 iaddr 0.0.0.3 reach_flags 0x0 +[4] en4! rank 0x5 iaddr 0.0.0.5 reach_flags 0x0 +[5] en9- rank 0x9 iaddr 0.0.0.9 reach_flags 0x0 +[6] en8- rank 0x8 iaddr 0.0.0.8 reach_flags 0x0 +[7] en7- rank 0x7 iaddr 0.0.0.7 reach_flags 0x0 +[8] en6- rank 0x6 iaddr 0.0.0.6 reach_flags 0x0 +[9] en5- rank 0x5 iaddr 0.0.0.5 reach_flags 0x0 +IPv6: +[0] en0 rank 0x0 iaddr :: reach_flags 0x0 +[1] en1\ rank 0x9 iaddr 0:1:: reach_flags 0x0 +[2] en2 rank 0x2 iaddr 0:2:: reach_flags 0x0 +[3] en3\ rank 0x7 iaddr 0:3:: reach_flags 0x0 +[4] en4 rank 0x4 iaddr 0:4:: reach_flags 0x0 +[5] en5- rank 0x5 iaddr 0:5:: reach_flags 0x0 +[6] en6- rank 0x6 iaddr 0:6:: reach_flags 0x0 +[7] en7- never rank 0x7 iaddr 0:7:: reach_flags 0x0 +[8] en8- never rank 0x8 iaddr 0:8:: reach_flags 0x0 +[9] en9- never rank 0x9 iaddr 0:9:: reach_flags 0x0 +----------------------------------- diff --git a/scselect.tproj/scselect.c b/scselect.tproj/scselect.c index c04de5a..a84e808 100644 --- a/scselect.tproj/scselect.c +++ b/scselect.tproj/scselect.c @@ -1,15 +1,15 @@ /* - * Copyright (c) 2000-2009, 2011, 2012, 2014 Apple Inc. All rights reserved. + * Copyright (c) 2000-2009, 2011, 2012, 2014, 2015 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ - * + * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. - * + * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, @@ -17,7 +17,7 @@ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. - * + * * @APPLE_LICENSE_HEADER_END@ */ @@ -139,7 +139,7 @@ main(int argc, char **argv) range = CFStringFind(newSet, CFSTR("/"), 0); if (range.location != kCFNotFound) { - SCPrint(TRUE, stderr, CFSTR("Set \"%@\" not available\n."), newSet); + SCPrint(TRUE, stderr, CFSTR("Set \"%@\" not available\n"), newSet); exit (1); } } @@ -282,14 +282,7 @@ main(int argc, char **argv) CFRelease(current); current = CFStringCreateWithFormat(NULL, NULL, CFSTR("%@%@"), prefix, newSet); - if (!SCPreferencesSetValue(prefs, kSCPrefCurrentSet, current)) { - SCPrint(TRUE, stderr, - CFSTR("SCPreferencesSetValue(...,%@,%@) failed: %s\n"), - kSCPrefCurrentSet, - current, - SCErrorString(SCError())); - exit (1); - } + SCPreferencesSetValue(prefs, kSCPrefCurrentSet, current); if (!SCPreferencesCommitChanges(prefs)) { int sc_status = SCError(); diff --git a/scutil.tproj/nc.c b/scutil.tproj/nc.c index 668895a..be0952f 100644 --- a/scutil.tproj/nc.c +++ b/scutil.tproj/nc.c @@ -1,15 +1,15 @@ /* - * Copyright (c) 2010-2014 Apple Inc. All rights reserved. + * Copyright (c) 2010-2015 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ - * + * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. - * + * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, @@ -17,7 +17,7 @@ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. - * + * * @APPLE_LICENSE_HEADER_END@ */ @@ -919,12 +919,7 @@ nc_set_application_url(CFStringRef subtype, CFStringRef directory) do_prefs_init(); /* initialization */ do_prefs_open(1, &path); /* open prefs */ - if (!SCPreferencesSetValue(prefs, CFSTR("ApplicationURL"), directory_url_data)) { - SCPrint(TRUE, stderr, - CFSTR("SCPreferencesSetValue ApplicationURL failed, %s\n"), - SCErrorString(SCError())); - goto done; - } + SCPreferencesSetValue(prefs, CFSTR("ApplicationURL"), directory_url_data); _prefs_save(); @@ -1006,17 +1001,15 @@ nc_show(int argc, char **argv) exit(exit_code); } - serviceID = SCNetworkServiceGetServiceID(service); - - nc_get_service_type_and_subtype(service, &iftype, &ifsubtype); - - if (!CFEqual(iftype, kSCEntNetPPP) && - !CFEqual(iftype, kSCEntNetIPSec) && - !CFEqual(iftype, kSCEntNetVPN)) { + if (!_SCNetworkServiceIsVPN(service)) { SCPrint(TRUE, stderr, CFSTR("Not a connection oriented service: %@\n"), serviceID); goto done; } + serviceID = SCNetworkServiceGetServiceID(service); + + nc_get_service_type_and_subtype(service, &iftype, &ifsubtype); + type_entity_key = SCDynamicStoreKeyCreateNetworkServiceEntity(NULL, kSCDynamicStoreDomainSetup, serviceID, iftype); nc_print_VPN_service(service); diff --git a/scutil.tproj/prefs.c b/scutil.tproj/prefs.c index ec8677f..bd5c026 100644 --- a/scutil.tproj/prefs.c +++ b/scutil.tproj/prefs.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2008, 2011-2014 Apple Inc. All rights reserved. + * Copyright (c) 2003-2008, 2011-2015 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -972,6 +972,12 @@ do_prefs_remove(int argc, char **argv) return; } +static const char * +on_off_str(Boolean on) +{ + return (on ? "on" : "off"); +} + /* -------------------- */ #include "IPMonitorControlPrefs.h" @@ -985,7 +991,7 @@ do_log(char * log, int argc, char **argv) } if (argc == 0) { printf("IPMonitor log is %s\n", - IPMonitorControlPrefsIsVerbose() ? "on" : "off"); + on_off_str(IPMonitorControlPrefsIsVerbose())); } else { Boolean verbose = FALSE; @@ -997,13 +1003,13 @@ do_log(char * log, int argc, char **argv) verbose = FALSE; } else { - fprintf(stderr, "%s invalid, must be 'on' or 'off'\n", - argv[0]); - exit(1); + fprintf(stderr, "%s invalid, must be 'on' or 'off'\n", + argv[0]); + exit(1); } if (IPMonitorControlPrefsSetVerbose(verbose) == FALSE) { - fprintf(stderr, "failed to set preferences\n"); - exit(2); + fprintf(stderr, "failed to set preferences\n"); + exit(2); } } exit(0); @@ -1011,3 +1017,138 @@ do_log(char * log, int argc, char **argv) } +/* -------------------- */ + +static SCNetworkInterfaceRef +copy_configured_interface(SCPreferencesRef prefs, CFStringRef if_name) +{ + SCNetworkSetRef current_set = NULL; + CFIndex count; + CFIndex i; + SCNetworkInterfaceRef ret_if = NULL; + CFArrayRef services = NULL; + + if (prefs == NULL) { + goto done; + } + current_set = SCNetworkSetCopyCurrent(prefs); + if (current_set == NULL) { + goto done; + } + services = SCNetworkSetCopyServices(current_set); + if (services == NULL) { + goto done; + } + + count = CFArrayGetCount(services); + for (i = 0; i < count; i++) { + CFStringRef this_if_name; + SCNetworkInterfaceRef this_if; + SCNetworkServiceRef s; + + s = (SCNetworkServiceRef)CFArrayGetValueAtIndex(services, i); + if (SCNetworkServiceGetEnabled(s) == FALSE) { + /* skip disabled services */ + continue; + } + this_if = SCNetworkServiceGetInterface(s); + if (this_if == NULL) { + continue; + } + this_if_name = SCNetworkInterfaceGetBSDName(this_if); + if (this_if_name == NULL) { + continue; + } + if (CFEqual(this_if_name, if_name)) { + CFRetain(this_if); + ret_if = this_if; + break; + } + } + + done: + if (current_set != NULL) { + CFRelease(current_set); + } + if (services != NULL) { + CFRelease(services); + } + return (ret_if); +} + +static void +disable_until_needed_usage(void) +{ + fprintf(stderr, "usage: scutil --disable-until-needed [ on | off ]\n"); + return; +} + +#include + +__private_extern__ +void +do_disable_until_needed(int argc, char **argv) +{ + const char * if_name; + CFStringRef if_name_cf; + SCNetworkInterfaceRef net_if; + Boolean on = FALSE; + Boolean ok; + Boolean set_value; + + if (argc < 1 || argc > 2) { + disable_until_needed_usage(); + exit(1); + } + if_name = argv[0]; + if (argc == 1) { + set_value = FALSE; + } + else { + const char * on_off = argv[1]; + + set_value = TRUE; + if (strcasecmp(on_off, "on") == 0) { + on = TRUE; + } + else if (strcasecmp(on_off, "off") == 0) { + on = FALSE; + } + else { + disable_until_needed_usage(); + exit(1); + } + } + ok = _prefs_open(CFSTR("scutil --disable-until-needed"), NULL); + if (!ok) { + SCPrint(TRUE, + stdout, + CFSTR("Could not open prefs: %s\n"), + SCErrorString(SCError())); + exit(1); + } + if_name_cf = CFStringCreateWithCStringNoCopy(NULL, + if_name, + kCFStringEncodingASCII, + kCFAllocatorNull); + net_if = copy_configured_interface(prefs, if_name_cf); + if (net_if == NULL) { + fprintf(stderr, "%s is not configured\n", if_name); + exit(1); + } + if (set_value) { + if (SCNetworkInterfaceSetDisableUntilNeeded(net_if, on) == FALSE) { + fprintf(stderr, "failed to turn disable-until-needed %s\n", + on_off_str(on)); + exit(1); + } + _prefs_save(); + } + else { + on = SCNetworkInterfaceGetDisableUntilNeeded(net_if); + printf("%s disable-until-needed is %s\n", if_name, on_off_str(on)); + } + _prefs_close(); + exit(0); + return; +} diff --git a/scutil.tproj/prefs.h b/scutil.tproj/prefs.h index f1a3437..5df667f 100644 --- a/scutil.tproj/prefs.h +++ b/scutil.tproj/prefs.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2005-2007, 2012, 2013 Apple Inc. All rights reserved. + * Copyright (c) 2003, 2005-2007, 2012, 2013, 2015 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -69,6 +69,7 @@ void do_prefs_set (int argc, char **argv); void do_prefs_remove (int argc, char **argv); void do_log (char *pref, int argc, char **argv); +void do_disable_until_needed (int argc, char **argv); __END_DECLS #endif /* !_PREFS_H */ diff --git a/scutil.tproj/scutil.c b/scutil.tproj/scutil.c index a476ff9..ea5c8d7 100644 --- a/scutil.tproj/scutil.c +++ b/scutil.tproj/scutil.c @@ -110,6 +110,7 @@ static const struct option longopts[] = { { "password", required_argument, NULL, 0 }, { "secret", required_argument, NULL, 0 }, { "log", required_argument, NULL, 0 }, + { "disable-until-needed", no_argument, NULL, 0 }, { NULL, 0, NULL, 0 } }; @@ -391,6 +392,7 @@ prompt(EditLine *el) int main(int argc, char * const argv[]) { + Boolean disableUntilNeeded = FALSE; Boolean doDNS = FALSE; Boolean doNet = FALSE; Boolean doNWI = FALSE; @@ -483,6 +485,9 @@ main(int argc, char * const argv[]) } else if (strcmp(longopts[opti].name, "log") == 0) { log = optarg; xStore++; + } else if (strcmp(longopts[opti].name, "disable-until-needed") == 0) { + disableUntilNeeded = TRUE; + xStore++; } else if (strcmp(longopts[opti].name, "user") == 0) { username = CFStringCreateWithCString(NULL, optarg, kCFStringEncodingUTF8); } else if (strcmp(longopts[opti].name, "password") == 0) { @@ -607,6 +612,11 @@ main(int argc, char * const argv[]) /* NOT REACHED */ } + /* disableUntilNeeded */ + if (disableUntilNeeded) { + do_disable_until_needed(argc, (char * *)argv); + /* NOT REACHED */ + } /* network connection commands */ if (nc_cmd) { if (find_nc_cmd(nc_cmd) < 0) { diff --git a/scutil.tproj/tests.c b/scutil.tproj/tests.c index 20c2b00..a243962 100644 --- a/scutil.tproj/tests.c +++ b/scutil.tproj/tests.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2001, 2003-2014 Apple Inc. All rights reserved. + * Copyright (c) 2000, 2001, 2003-2015 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -48,9 +48,12 @@ #include #include +#define my_log(__level, fmt, ...) SCPrint(TRUE, stdout, CFSTR(fmt "\n"), ## __VA_ARGS__) + #include #include "dnsinfo_internal.h" #include +#include "network_information_priv.h" #include "SCNetworkReachabilityInternal.h" #include @@ -94,7 +97,6 @@ _setupReachabilityOptions(int argc, char **argv, const char *interface) continue; } - if (strcasecmp(argv[i], "no-connection-on-demand") == 0) { CFDictionarySetValue(options, kSCNetworkReachabilityOptionConnectionOnDemandBypass, @@ -424,6 +426,7 @@ _printReachability(SCNetworkReachabilityRef target) { SCNetworkReachabilityFlags flags; Boolean ok; + CFStringRef str; ok = SCNetworkReachabilityGetFlags(target, &flags); if (!ok) { @@ -431,16 +434,15 @@ _printReachability(SCNetworkReachabilityRef target) return; } - SCPrint(_sc_debug, stdout, CFSTR("flags = 0x%08x ("), flags); - __SCNetworkReachabilityPrintFlags(flags); - SCPrint(_sc_debug, stdout, CFSTR(")")); - SCPrint(TRUE, stdout, CFSTR("\n")); + str = __SCNetworkReachabilityCopyFlags(flags, CFSTR("flags = "), _sc_debug); + SCPrint(TRUE, stdout, CFSTR("%@\n"), str); + CFRelease(str); - if (resolver_bypass) { + if (resolver_bypass && _sc_debug) { int if_index; if_index = SCNetworkReachabilityGetInterfaceIndex(target); - SCPrint(_sc_debug, stdout, CFSTR("interface index = %d\n"), if_index); + SCPrint(TRUE, stdout, CFSTR("interface index = %d\n"), if_index); } return; @@ -468,6 +470,7 @@ do_checkReachability(int argc, char **argv) static void _printNWIFlags(nwi_ifstate_flags flags) { + flags &= NWI_IFSTATE_FLAGS_MASK; if (flags == 0) { return; } @@ -488,6 +491,21 @@ _printNWIFlags(nwi_ifstate_flags flags) flags &= ~NWI_IFSTATE_FLAGS_HAS_DNS; SCPrint(flags != 0, stdout, CFSTR(",")); } + if (flags & NWI_IFSTATE_FLAGS_NOT_IN_LIST) { + SCPrint(TRUE, stdout, CFSTR("NOT-IN-LIST")); + flags &= ~NWI_IFSTATE_FLAGS_NOT_IN_LIST; + SCPrint(flags != 0, stdout, CFSTR(",")); + } + if (flags & NWI_IFSTATE_FLAGS_HAS_SIGNATURE) { + SCPrint(TRUE, stdout, CFSTR("SIGNATURE")); + flags &= ~NWI_IFSTATE_FLAGS_HAS_SIGNATURE; + SCPrint(flags != 0, stdout, CFSTR(",")); + } + if (flags & NWI_IFSTATE_FLAGS_NOT_IN_IFLIST) { + SCPrint(TRUE, stdout, CFSTR("NOT-IN-IFLIST")); + flags &= ~NWI_IFSTATE_FLAGS_NOT_IN_IFLIST; + SCPrint(flags != 0, stdout, CFSTR(",")); + } if (flags != 0) { SCPrint(TRUE, stdout, CFSTR("%p"), (void *)flags); } @@ -500,21 +518,27 @@ _printNWIFlags(nwi_ifstate_flags flags) static void _printNWIInfo(nwi_ifstate_t ifstate) { - nwi_ifstate_flags ifstate_flags = nwi_ifstate_get_flags(ifstate); + nwi_ifstate_flags ifstate_flags; SCNetworkReachabilityFlags reach_flags = nwi_ifstate_get_reachability_flags(ifstate); const uint8_t *signature; int signature_length; + CFStringRef str; const struct sockaddr *vpn_addr = nwi_ifstate_get_vpn_server(ifstate); + ifstate_flags = nwi_ifstate_get_flags(ifstate); + if (_sc_debug) { + ifstate_flags |= ifstate->flags; + } + SCPrint(TRUE, stdout, CFSTR(" %7s : flags %p"), nwi_ifstate_get_ifname(ifstate), (void *)ifstate_flags); _printNWIFlags(ifstate_flags); - SCPrint(TRUE, stdout, CFSTR("\n reach 0x%08x ("), reach_flags); - __SCNetworkReachabilityPrintFlags(reach_flags); - SCPrint(TRUE, stdout, CFSTR(")")); + str = __SCNetworkReachabilityCopyFlags(reach_flags, CFSTR(" reach "), TRUE); + SCPrint(TRUE, stdout, CFSTR("\n%@"), str); + CFRelease(str); if (vpn_addr != NULL) { char vpn_ntopbuf[INET6_ADDRSTRLEN]; @@ -545,11 +569,13 @@ static void _printNWIReachInfo(nwi_state_t state, int af) { uint32_t reach_flags; + CFStringRef str; reach_flags = nwi_state_get_reachability_flags(state, af); - SCPrint(TRUE, stdout, CFSTR("\n REACH : flags 0x%08x ("), reach_flags); - __SCNetworkReachabilityPrintFlags(reach_flags); - SCPrint(TRUE, stdout, CFSTR(")\n")); + + str = __SCNetworkReachabilityCopyFlags(reach_flags, CFSTR(" REACH : flags "), TRUE); + SCPrint(TRUE, stdout, CFSTR("\n%@\n"), str); + CFRelease(str); return; } @@ -558,6 +584,7 @@ _printNWIReachInfo(nwi_state_t state, int af) static void do_printNWI(int argc, char **argv, nwi_state_t state) { + unsigned int count; nwi_ifstate_t ifstate; if (state == NULL) { @@ -568,7 +595,16 @@ do_printNWI(int argc, char **argv, nwi_state_t state) if (argc > 0) { ifstate = nwi_state_get_ifstate(state, argv[0]); if (ifstate != NULL) { + nwi_ifstate_t alias; + _printNWIInfo(ifstate); + + alias = nwi_ifstate_get_alias(ifstate, + ifstate->af == AF_INET ? AF_INET6 : AF_INET); + if (alias != NULL) { + SCPrint(TRUE, stdout, CFSTR("\n")); + _printNWIInfo(alias); + } } else { SCPrint(TRUE, stdout, CFSTR("No network information (for %s)\n"), argv[0]); } @@ -604,6 +640,21 @@ do_printNWI(int argc, char **argv, nwi_state_t state) } _printNWIReachInfo(state, AF_INET6); + count = nwi_state_get_interface_names(state, NULL, 0); + if (count > 0) { + const char * names[count]; + + count = nwi_state_get_interface_names(state, names, count); + if (count > 0) { + int i; + + printf("\nNetwork interfaces:"); + for (i = 0; i < count; i++) { + printf(" %s", names[i]); + } + printf("\n"); + } + } return; } @@ -663,7 +714,7 @@ do_watchNWI(int argc, char **argv) } }); if (status != NOTIFY_STATUS_OK) { - SCLog(TRUE, LOG_INFO, CFSTR("notify_register_dispatch() failed for nwi changes, status=%u"), status); + SC_log(LOG_INFO, "notify_register_dispatch() failed for nwi changes, status=%u", status); exit(1); } @@ -771,55 +822,17 @@ do_watchReachability(int argc, char **argv) static void do_printDNSConfiguration(int argc, char **argv, dns_config_t *dns_config) { - SCNetworkReachabilityRef target; + int _sc_log_save; if (dns_config == NULL) { SCPrint(TRUE, stdout, CFSTR("No DNS configuration available\n")); return; } - if (argc > 1) { - int dns_config_index = -1; - SCNetworkReachabilityFlags flags = 0; - Boolean haveDNS = FALSE; - Boolean ok = FALSE; - dns_resolver_t *resolver; - uint32_t resolver_if_index; - SCNetworkReachabilityPrivateRef targetPrivate; - - target = _setupReachability(argc, argv, NULL); - - targetPrivate = (SCNetworkReachabilityPrivateRef)target; - - if (targetPrivate->type != reachabilityTypeName) { - SCPrint(TRUE, stdout, CFSTR("\"%s\" is not a hostname.\n"), argv[0]); - exit(1); - } - - ok = __SC_checkResolverReachabilityInternal(&store, &flags, - &haveDNS, targetPrivate->name, - &resolver_if_index, &dns_config_index); - - if (!ok) { - SCPrint(TRUE, stdout, CFSTR("No DNS configuration available.\n" )); - return; - } - - SCPrint(TRUE, stdout, CFSTR("DNS configuration for %s\n"), - targetPrivate->name); - - if (targetPrivate->if_index == 0) { - resolver = dns_config->resolver[dns_config_index]; - } else { - resolver = dns_config->scoped_resolver[dns_config_index]; - } - - _dns_resolver_print(resolver, dns_config_index + 1); - - if (target != NULL) CFRelease(target); - } else { - _dns_configuration_print(dns_config); - } + _sc_log_save = _sc_log; + _sc_log = FALSE; + _dns_configuration_log(dns_config, _sc_debug); + _sc_log = _sc_log_save; if (_sc_debug) { SCPrint(TRUE, stdout, CFSTR("\ngeneration = %llu\n"), dns_config->generation); @@ -884,7 +897,7 @@ do_watchDNSConfiguration(int argc, char **argv) } }); if (status != NOTIFY_STATUS_OK) { - SCLog(TRUE, LOG_INFO, CFSTR("notify_register_dispatch() failed for DNS configuration changes, status=%u"), status); + SC_log(LOG_INFO, "notify_register_dispatch() failed for DNS configuration changes, status=%u", status); exit(1); } @@ -1026,8 +1039,6 @@ do_snapshot(int argc, char **argv) SCPrint(TRUE, stdout, CFSTR(" %s\n"), SCErrorString(SCError())); } - (void) _SCNetworkReachabilityServer_snapshot(); - return; } @@ -1243,7 +1254,7 @@ sleep(120); dns_configuration_free(dns_config); } - do_showDNSConfiguration(argc, argv); + do_showDNSConfiguration(argc, argv); exit(0); } -- 2.45.2