]> git.saurik.com Git - apple/configd.git/commitdiff
configd-1061.80.3.tar.gz macos-10153 v1061.80.3
authorApple <opensource@apple.com>
Thu, 30 Apr 2020 21:32:15 +0000 (21:32 +0000)
committerApple <opensource@apple.com>
Thu, 30 Apr 2020 21:32:15 +0000 (21:32 +0000)
Plugins/IPMonitor/Makefile
Plugins/IPMonitor/ip_plugin.c
Plugins/IPMonitor/routelist_output_filter.sh
Plugins/IPMonitor/serviceIDNumber.c [deleted file]
Plugins/IPMonitor/serviceIDNumber.h [deleted file]
Plugins/IPMonitor/test_ipv4_routelist_reference.txt
Plugins/IPMonitor/test_ipv6_routelist_reference.txt
configd.xcodeproj/project.pbxproj

index 1214754f8dc642b13d3a3a78b3ca37da7405ab6a..f8e861a598094fa7ad1cab695fa36afe748397a9 100644 (file)
@@ -83,9 +83,6 @@ IPMonitorControlPrefs.o: ../common/IPMonitorControlPrefs.h ../common/IPMonitorCo
 IPMonitorControlServer.o: ../../IPMonitorControl/IPMonitorControlServer.c
        $(CC) $(PF_INC) $(ARCH_FLAGS) -isysroot $(SYSROOT) ${TEST_INCLUDE} -Wall -O0 -g -c $^
 
-serviceIDNumber.o: serviceIDNumber.c
-       $(CC) $(PF_INC) $(ARCH_FLAGS) -isysroot $(SYSROOT) ${TEST_INCLUDE} -Wall -O0 -g -c $^
-
 # ----------
 
 ip_pluginX.o: Makefile ip_plugin.c
@@ -135,7 +132,7 @@ test_dns_order: test_dns_order.o IPMonitorControlPrefs.o agent-monitor.o configA
 test_ipv4_routelist.o: ip_plugin.c
        $(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 dns-configuration.o proxy-configuration.o set-hostname.o smb-configuration.o libSystemConfiguration_client.o libSystemConfiguration_server.o serviceIDNumber.o
+test_ipv4_routelist: test_ipv4_routelist.o IPMonitorControlPrefs.o dnsinfo_create.o dnsinfo_flatfile.o dnsinfo_server.o dns-configuration.o proxy-configuration.o set-hostname.o smb-configuration.o libSystemConfiguration_client.o libSystemConfiguration_server.o
        $(CC) $(PF_INC) $(ARCH_FLAGS) -isysroot $(SYSROOT) -Wall -O0 -g -o test_ipv4_routelist $^ ${EXTRA_CFLAGS} -lnetwork -framework SystemConfiguration -framework CoreFoundation -framework Foundation -framework Network -framework NetworkExtension
 
 test_ipv4_routelist_reference.txt: test_ipv4_routelist
@@ -152,7 +149,7 @@ test_ipv4_routelist_coverage: test_ipv4_routelist
 test_ipv6_routelist.o: ip_plugin.c
        $(CC) $(PF_INC) $(ARCH_FLAGS) -isysroot $(SYSROOT) -DTEST_IPV6_ROUTELIST=1 ${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 dns-configuration.o proxy-configuration.o set-hostname.o smb-configuration.o libSystemConfiguration_client.o libSystemConfiguration_server.o serviceIDNumber.o
+test_ipv6_routelist: test_ipv6_routelist.o IPMonitorControlPrefs.o dnsinfo_create.o dnsinfo_flatfile.o dnsinfo_server.o dns-configuration.o proxy-configuration.o set-hostname.o smb-configuration.o libSystemConfiguration_client.o libSystemConfiguration_server.o
        $(CC) $(PF_INC) $(ARCH_FLAGS) -isysroot $(SYSROOT) -Wall -O0 -g -o test_ipv6_routelist $^ ${EXTRA_CFLAGS} -lnetwork -framework SystemConfiguration -framework CoreFoundation -framework Foundation -framework Network -framework NetworkExtension
 
 test_ipv6_routelist_reference.txt: test_ipv6_routelist
@@ -174,15 +171,10 @@ IPMonitor: IPMonitor.o IPMonitorControlPrefs.o agent-monitor.o configAgent.o con
 
 # ----------
 
-serviceIDNumberTest: serviceIDNumber.c
-       $(CC) $(PF_INC) $(ARCH_FLAGS) -isysroot $(SYSROOT) -DTEST_SERVICEID_NUMBER=1 ${TEST_INCLUDE} ${EXTRA_CFLAGS} -Wall -O0 -g -o $@ $^ -framework SystemConfiguration -framework CoreFoundation
-
-# ----------
-
 nat64: nat64-configuration.c
        $(CC) -DTEST_NAT64_CONFIGURATION $(TEST_INCLUDE) $(PF_INC) $(ARCH_FLAGS) -isysroot $(SYSROOT) -lnetwork -framework CoreFoundation -framework SystemConfiguration -Wall -O0 -g -o $@ $^
 
 # ----------
 
 clean:
-       rm -rf *.dSYM *.o test_dns test_hostname test_proxy test_smb test_ipv4_routelist test_ipv6_routelist test_dns_order serviceIDNumberTest IPMonitor nat64
+       rm -rf *.dSYM *.o test_dns test_hostname test_proxy test_smb test_ipv4_routelist test_ipv6_routelist test_dns_order IPMonitor nat64
index 97d14d0493d6c5dbd0d29f96f8bb216926c415cd..027d7e3bc3bd6f3170b758d75632fc55efa7593b 100644 (file)
@@ -96,7 +96,6 @@
 #include <CommonCrypto/CommonDigest.h>
 
 #include "ip_plugin.h"
-#include "serviceIDNumber.h"
 
 #include <SystemConfiguration/SystemConfiguration.h>
 #include <SystemConfiguration/SCDynamicStoreCopyDHCPInfo.h>
 #include "network_state_information_logging.h"
 #include "network_information_server.h"
 #include <ppp/ppp_msg.h>
+
 #if    !TARGET_OS_SIMULATOR && !TEST_IPV4_ROUTELIST && !TEST_IPV6_ROUTELIST
 #include "set-hostname.h"
 #include "nat64-configuration.h"
@@ -407,16 +407,25 @@ typedef CF_ENUM(uint16_t, RouteFlags) {
 typedef CF_ENUM(uint16_t, ControlFlags) {
     kControlFlagsProcessed     = 0x0001,
     kControlFlagsAdded         = 0x0002,
+    kControlFlagsForce         = 0x0004,
 };
 
+#if    !TARGET_OS_SIMULATOR
+static inline ControlFlags
+ControlFlagsPreserve(ControlFlags flags)
+{
+    /* only preserve the "processed" and "added" flags */
+    return (flags & (kControlFlagsProcessed | kControlFlagsAdded));
+}
+#endif /* !TARGET_OS_SIMULATOR */
+
 #define ROUTE_COMMON                           \
     int                        prefix_length;          \
     IFIndex            ifindex;                \
     IFIndex            exclude_ifindex;        \
     Rank               rank;                   \
     RouteFlags         flags;                  \
-    ControlFlags       control_flags;          \
-    serviceIDNumber    sidn;
+    ControlFlags       control_flags;
 
 typedef struct {
     ROUTE_COMMON
@@ -1048,14 +1057,6 @@ my_CFDictionaryGetArray(CFDictionaryRef dict, CFStringRef key)
     return (isA_CFArray(CFDictionaryGetValue(dict, key)));
 }
 
-#if    !TARGET_OS_SIMULATOR
-
-typedef CF_ENUM(uint16_t, PLATDiscoveryOption) {
-    kPLATDiscoveryOptionStart,
-    kPLATDiscoveryOptionUpdate,
-    kPLATDiscoveryOptionCancel
-};
-
 static void
 my_CFSetAddValue(CFMutableSetRef * set_p, CFTypeRef value)
 {
@@ -1065,6 +1066,17 @@ my_CFSetAddValue(CFMutableSetRef * set_p, CFTypeRef value)
        CFSetAddValue(*set_p, value);
 }
 
+static Boolean
+my_CFSetContainsValue(CFSetRef set, CFTypeRef value)
+{
+    if (set == NULL) {
+       return (FALSE);
+    }
+    return (CFSetContainsValue(set, value));
+}
+
+#if    !TARGET_OS_SIMULATOR
+
 static void
 my_CFSetRemoveValue(CFMutableSetRef * set_p, CFTypeRef value)
 {
@@ -1077,14 +1089,11 @@ my_CFSetRemoveValue(CFMutableSetRef * set_p, CFTypeRef value)
     }
 }
 
-static Boolean
-my_CFSetContainsValue(CFSetRef set, CFTypeRef value)
-{
-    if (set == NULL) {
-       return (FALSE);
-    }
-    return (CFSetContainsValue(set, value));
-}
+typedef CF_ENUM(uint16_t, PLATDiscoveryOption) {
+    kPLATDiscoveryOptionStart,
+    kPLATDiscoveryOptionUpdate,
+    kPLATDiscoveryOptionCancel
+};
 
 // Note: must only accessed on __network_change_queue()
 static CFMutableSetRef         S_nat64_cancel_prefix_requests;
@@ -1578,7 +1587,8 @@ typedef enum {
 static RouteListRef
 RouteListAddRoute(RouteListInfoRef info,
                  RouteListRef routes, int init_size,
-                 RouteRef this_route, Rank this_rank)
+                 RouteRef this_route, Rank this_rank,
+                 boolean_t force)
 {
     CFIndex            i;
     RouteRef           first_scan = NULL;
@@ -1626,7 +1636,6 @@ RouteListAddRoute(RouteListInfoRef info,
            }
        }
        else if (cmp == 0) {
-           /* exact match */
            /* exact match */
            if (where != kCFNotFound
                && scan->ifindex == this_route->ifindex
@@ -1675,6 +1684,9 @@ RouteListAddRoute(RouteListInfoRef info,
                    ROUTELIST_DEBUG(kDebugFlag8, "Hit 5: preserved scope\n");
                    scan->flags |= kRouteFlagsIsScoped;
                }
+               if (force) {
+                   scan->control_flags |= kControlFlagsForce;
+               }
            }
            /* we're done */
            goto done;
@@ -1722,6 +1734,9 @@ RouteListAddRoute(RouteListInfoRef info,
     /* add/insert the new route */
     this_route = RouteListAddRouteAtIndex(info, routes, this_route, where);
     this_route->rank = this_rank;
+    if (force) {
+       this_route->control_flags |= kControlFlagsForce;
+    }
     flags = 0;
     if (RANK_ASSERTION_MASK(this_rank) == kRankAssertionNever) {
        flags |= kRouteFlagsIsScoped;
@@ -1758,7 +1773,8 @@ RouteListAddRoute(RouteListInfoRef info,
 static RouteListRef
 RouteListAddRouteList(RouteListInfoRef info,
                      RouteListRef routes, int init_size,
-                     RouteListRef service_routes, Rank rank)
+                     RouteListRef service_routes, Rank rank,
+                     boolean_t force)
 {
     int                i;
     RouteRef   scan;
@@ -1776,7 +1792,8 @@ RouteListAddRouteList(RouteListInfoRef info,
        else {
            this_rank = RANK_INDEX_MASK(rank) | RANK_ASSERTION_MASK(scan->rank);
        }
-       routes = RouteListAddRoute(info, routes, init_size, scan, this_rank);
+       routes = RouteListAddRoute(info, routes, init_size, scan, this_rank,
+                                  force);
     }
     return (routes);
 }
@@ -1827,6 +1844,11 @@ RouteAddFlagsToDescription(RouteRef r, CFMutableStringRef str)
        if ((r->flags & kRouteFlagsIsScoped) != 0) {
            CFStringAppend(str, CFSTR(" [SCOPED]"));
        }
+#ifndef TEST_ROUTELIST
+       if ((r->control_flags & kControlFlagsForce) != 0) {
+           CFStringAppend(str, CFSTR(" [force]"));
+       }
+#endif
     }
     return;
 }
@@ -1865,63 +1887,63 @@ RouteListLookup(RouteListInfoRef info,
                RouteLookupFlags lookup_flags)
 {
     RouteRef   best_match = NULL;
-    RouteRef   candidate;
     int                i;
+    RouteRef   scan;
 
-    for (i = 0, candidate = RouteListGetFirstRoute(info, routes);
+    for (i = 0, scan = RouteListGetFirstRoute(info, routes);
         i < routes->count;
-        i++, candidate = RouteGetNextRoute(info, candidate)) {
-       if (candidate->ifindex == 0 || candidate->exclude_ifindex != 0) {
+        i++, scan = RouteGetNextRoute(info, scan)) {
+       if (scan->ifindex == 0 || scan->exclude_ifindex != 0) {
            /* ignore exclude routes */
            continue;
        }
        if ((lookup_flags & kRouteLookupFlagsExcludeInterface) != 0) {
            /* exclude interfaces with the same interface index */
-           if (ifindex == candidate->ifindex) {
+           if (ifindex == scan->ifindex) {
                continue;
            }
        }
-       else if (ifindex != candidate->ifindex) {
+       else if (ifindex != scan->ifindex) {
            continue;
        }
-       if ((candidate->flags & kRouteFlagsHasGateway) != 0
+       if ((scan->flags & kRouteFlagsHasGateway) != 0
            && RouteAddressCompare(info,
-                                  (*info->route_gateway)(candidate),
+                                  (*info->route_gateway)(scan),
                                   address) == 0) {
            /* skip route whose gateway is the address we're looking for */
            continue;
        }
-       if ((candidate->flags & kRouteFlagsIsHost) != 0) {
+       if ((scan->flags & kRouteFlagsIsHost) != 0) {
            /* if host route and we're looking for an exact match */
            if (n_bits == info->all_bits_set
                && RouteAddressCompare(info,
-                                      (*info->route_destination)(candidate),
+                                      (*info->route_destination)(scan),
                                       address) == 0) {
                /* found exact match */
-               best_match = candidate;
+               best_match = scan;
                break;
            }
            /* skip it */
            continue;
        }
        /* verify that address is on the same subnet */
-       if ((*info->route_same_subnet)(candidate, address) == FALSE) {
+       if ((*info->route_same_subnet)(scan, address) == FALSE) {
            /* different subnet */
            continue;
        }
 
-       if (candidate->prefix_length == n_bits) {
+       if (scan->prefix_length == n_bits) {
            /* exact match */
-           best_match = candidate;
+           best_match = scan;
            break;
        }
-       if (candidate->prefix_length > n_bits) {
+       if (scan->prefix_length > n_bits) {
            /* matched too many bits */
            continue;
        }
        if (best_match == NULL
-           || candidate->prefix_length > best_match->prefix_length) {
-           best_match = candidate;
+           || scan->prefix_length > best_match->prefix_length) {
+           best_match = scan;
        }
     }
     return (best_match);
@@ -2092,9 +2114,16 @@ RouteListApply(RouteListInfoRef info,
                RouteRef        old_route = NULL;
 
                old_route = RouteListFindRoute(info, old_routes, scan);
-               if (old_route != NULL && scan->sidn == old_route->sidn) {
-                   /* preserve the control state in the new route */
-                   scan->control_flags = old_route->control_flags;
+               if (old_route != NULL) {
+                   if ((scan->control_flags & kControlFlagsForce) == 0) {
+                       /* preserve the control state in the new route */
+                       scan->control_flags
+                           = ControlFlagsPreserve(old_route->control_flags);
+                   }
+                   else {
+                       (*info->route_log)(LOG_NOTICE, (RouteRef)scan,
+                                          "Re-applying route");
+                   }
                }
            }
        }
@@ -2154,7 +2183,8 @@ RouteListFinalize(RouteListInfoRef info, RouteListRef routes)
                                (*info->route_destination)(scan),
                                scan->prefix_length, ifindex, flags);
        if (route == NULL) {
-           (*info->route_log)(LOG_NOTICE, (RouteRef)scan, "can't resolve excluded route");
+           (*info->route_log)(LOG_NOTICE, (RouteRef)scan,
+                              "can't resolve excluded route");
        }
        else {
            if ((S_IPMonitor_debug & kDebugFlag8) != 0) {
@@ -2220,11 +2250,6 @@ IPv4RouteCopyDescriptionWithString(IPv4RouteRef r, CFMutableStringRef str)
                             CFSTR(" Ifa " IP_FORMAT),
                             IP_LIST(&r->ifa));
     }
-#if !TEST_IPV4_ROUTELIST
-    CFStringAppendFormat(str, NULL,
-                        CFSTR(" <SID %ld>"),
-                        r->sidn);
-#endif
     RouteAddFlagsToDescription((RouteRef)r, str);
     return;
 }
@@ -2621,7 +2646,8 @@ IPv4RouteListAddRouteList(IPv4RouteListRef routes, int init_size,
     return ((IPv4RouteListRef)
            RouteListAddRouteList(&IPv4RouteListInfo,
                                  (RouteListRef)routes, init_size,
-                                 (RouteListRef)service_routes, rank));
+                                 (RouteListRef)service_routes, rank,
+                                 FALSE));
 }
 #endif /* TEST_IPV4_ROUTELIST */
 
@@ -2649,7 +2675,6 @@ typedef struct {
     IPv4RouteRef *     route_p;
     Rank               rank;
     const char *       descr;
-    serviceIDNumber    sidn;
 } AddIPv4RouteContext, * AddIPv4RouteContextRef;
 
 static void
@@ -2681,7 +2706,6 @@ AddIPv4Route(const void * value, void * context)
     }
     r->rank = ctx->rank;
     r->exclude_ifindex = ctx->exclude_ifindex;
-    r->sidn = ctx->sidn;
     if (ctx->ifindex != 0) {
        r->ifindex = ctx->ifindex;
        r->ifa = ctx->addr;
@@ -2759,8 +2783,7 @@ confirm_interface_name(CFDictionaryRef dict, CFStringRef ifname)
 static IPv4RouteListRef
 IPv4RouteListCreateWithDictionary(IPv4RouteListRef routes,
                                  CFDictionaryRef dict,
-                                 CFNumberRef rank_assertion,
-                                 serviceIDNumber sidn)
+                                 CFNumberRef rank_assertion)
 {
     boolean_t          add_broadcast_multicast = FALSE;
     boolean_t          add_default = FALSE;
@@ -2932,7 +2955,6 @@ IPv4RouteListCreateWithDictionary(IPv4RouteListRef routes,
     if (add_default) {
        /* add the default route */
        routes->flags |= kRouteListFlagsHasDefault;
-       r->sidn = sidn;
        r->ifindex = ifindex;
        r->ifa = addr;
        r->flags = flags;
@@ -2954,7 +2976,6 @@ IPv4RouteListCreateWithDictionary(IPv4RouteListRef routes,
        r->mask.s_addr = INADDR_BROADCAST;
        r->prefix_length = IPV4_ROUTE_ALL_BITS_SET;
        r->ifindex = ifindex;
-       r->sidn = sidn;
        r->ifa = addr;
        r->rank = rank;
        r++;
@@ -2967,7 +2988,6 @@ IPv4RouteListCreateWithDictionary(IPv4RouteListRef routes,
        r->mask.s_addr = htonl(IN_CLASSD_NET);
        r->prefix_length = PREFIX_LENGTH_IN_CLASSD;
        r->ifindex = ifindex;
-       r->sidn = sidn;
        r->ifa = addr;
        r->rank = rank;
        r++;
@@ -2980,7 +3000,6 @@ IPv4RouteListCreateWithDictionary(IPv4RouteListRef routes,
            r->flags |= kRouteFlagsIsNULL;
        }
        r->ifindex = ifindex;
-       r->sidn = sidn;
        r->gateway = addr;
        r->dest = subnet;
        r->mask = mask;
@@ -2996,7 +3015,6 @@ IPv4RouteListCreateWithDictionary(IPv4RouteListRef routes,
            r->flags |= kRouteFlagsIsNULL;
        }
        r->ifindex = ifindex;
-       r->sidn = sidn;
        r->gateway = addr;
        r->dest = router;
        r->mask.s_addr = INADDR_BROADCAST;
@@ -3019,7 +3037,6 @@ IPv4RouteListCreateWithDictionary(IPv4RouteListRef routes,
            context.ifindex = ifindex;
            context.addr = addr;
            context.descr = "AdditionalRoutes";
-           context.sidn = sidn;
            CFArrayApplyFunction(additional_routes,
                                 CFRangeMake(0, additional_routes_count),
                                 AddIPv4Route, &context);
@@ -3030,7 +3047,6 @@ IPv4RouteListCreateWithDictionary(IPv4RouteListRef routes,
            /* exclude this interface */
            context.ifindex = 0;
            context.exclude_ifindex = ifindex;
-           context.sidn = sidn;
            CFArrayApplyFunction(excluded_routes,
                                 CFRangeMake(0, excluded_routes_count),
                                 AddIPv4Route, &context);
@@ -3055,7 +3071,6 @@ IPv4RouteListCopyMulticastLoopback(void)
     r->mask.s_addr = htonl(IN_CLASSC_NET);
     r->prefix_length = PREFIX_LENGTH_IN_CLASSC;
     r->ifindex = lo0_ifindex();
-    r->sidn = kserviceIDNumberZero;
     return (routes);
 }
 #endif /* !TARGET_OS_SIMULATOR */
@@ -3150,11 +3165,6 @@ IPv6RouteCopyDescriptionWithString(IPv6RouteRef r, CFMutableStringRef str)
        CFStringAppend(str, CFSTR(" Ifa "));
        string_append_in6_addr(str, &r->ifa);
     }
-#if !TEST_IPV6_ROUTELIST
-    CFStringAppendFormat(str, NULL,
-                        CFSTR(" <SID %ld>"),
-                        r->sidn);
-#endif
     RouteAddFlagsToDescription((RouteRef)r, str);
     return;
 }
@@ -3248,7 +3258,6 @@ typedef struct {
     IPv6RouteRef *     route_p;
     Rank               rank;
     const char *       descr;
-    serviceIDNumber    sidn;
 } AddIPv6RouteContext, * AddIPv6RouteContextRef;
 
 static void
@@ -3277,7 +3286,6 @@ AddIPv6Route(const void * value, void * context)
     }
     r->rank = ctx->rank;
     r->exclude_ifindex = ctx->exclude_ifindex;
-    r->sidn = ctx->sidn;
     if (ctx->ifindex != 0) {
        r->ifindex = ctx->ifindex;
        r->ifa = *ctx->addr;
@@ -3336,8 +3344,7 @@ AddIPv6Route(const void * value, void * context)
 static IPv6RouteListRef
 IPv6RouteListCreateWithDictionary(IPv6RouteListRef routes,
                                  CFDictionaryRef dict,
-                                 CFNumberRef rank_assertion,
-                                 serviceIDNumber sidn)
+                                 CFNumberRef rank_assertion)
 {
     boolean_t          add_default = FALSE;
     boolean_t          add_prefix = FALSE;
@@ -3487,7 +3494,6 @@ IPv6RouteListCreateWithDictionary(IPv6RouteListRef routes,
        /* add the default route */
        routes->flags |= kRouteListFlagsHasDefault;
        r->ifindex = ifindex;
-       r->sidn = sidn;
        r->ifa = addr;
        r->flags = flags;
        if ((flags & kRouteFlagsHasGateway) != 0) {
@@ -3504,7 +3510,6 @@ IPv6RouteListCreateWithDictionary(IPv6RouteListRef routes,
 
     /* add IPv6LL route */
     r->ifindex = ifindex;
-    r->sidn = sidn;
     r->dest.s6_addr[0] = 0xfe;
     r->dest.s6_addr[1] = 0x80;
     r->prefix_length = 64;
@@ -3520,7 +3525,6 @@ IPv6RouteListCreateWithDictionary(IPv6RouteListRef routes,
            r->flags |= kRouteFlagsIsNULL;
        }
        r->ifindex = ifindex;
-       r->sidn = sidn;
        r->gateway = addr;
        r->dest = addr;
        in6_netaddr(&r->dest, prefix_length);
@@ -3543,7 +3547,6 @@ IPv6RouteListCreateWithDictionary(IPv6RouteListRef routes,
            context.ifindex = ifindex;
            context.addr = &addr;
            context.descr = "AdditionalRoutes";
-           context.sidn = sidn;
            CFArrayApplyFunction(additional_routes,
                                 CFRangeMake(0, additional_routes_count),
                                 AddIPv6Route, &context);
@@ -3555,7 +3558,6 @@ IPv6RouteListCreateWithDictionary(IPv6RouteListRef routes,
            context.ifindex = 0;
            context.exclude_ifindex = ifindex;
            context.addr = NULL;
-           context.sidn = sidn;
            CFArrayApplyFunction(excluded_routes,
                                 CFRangeMake(0, excluded_routes_count),
                                 AddIPv6Route, &context);
@@ -3773,7 +3775,8 @@ IPv6RouteListAddRouteList(IPv6RouteListRef routes, int init_size,
     return ((IPv6RouteListRef)
            RouteListAddRouteList(&IPv6RouteListInfo,
                                  (RouteListRef)routes, init_size,
-                                 (RouteListRef)service_routes, rank));
+                                 (RouteListRef)service_routes, rank,
+                                 FALSE));
 }
 #endif /* TEST_IPV6_ROUTELIST */
 
@@ -3807,42 +3810,45 @@ IPv6RouteListApply(IPv6RouteListRef old_routes, IPv6RouteListRef new_routes,
 #endif /* !TARGET_OS_SIMULATOR */
 
 /*
- * Function: parse_component
+ * Function: parseNetworkServiceString
  * Purpose:
- *   Given a string 'key' and a string prefix 'prefix',
- *   return the next component in the slash '/' separated
- *   key.
- *
- * Examples:
- * 1. key = "a/b/c" prefix = "a/"
- *    returns "b"
- * 2. key = "a/b/c" prefix = "a/b/"
- *    returns "c"
+ *   Parse either of the following two formats:
+ *     <domain>:/Network/Service/<serviceID>
+ *     <domain>:/Network/Service/<serviceID>/<protocol>
+ *   returning <serviceID>, and if available and required, <protocol>.
  */
 static CF_RETURNS_RETAINED CFStringRef
-parse_component(CFStringRef key, CFStringRef prefix)
+parseNetworkServiceString(CFStringRef str, CFStringRef *ret_protocol)
 {
-    CFMutableStringRef comp;
-    CFRange            range;
+    CFArrayRef components;
+    CFIndex    count;
+    CFStringRef protocol = NULL;
+    CFStringRef        serviceID = NULL;
 
-    if (!CFStringHasPrefix(key, prefix)) {
-       return (NULL);
-    }
-    comp = CFStringCreateMutableCopy(NULL, 0, key);
-    if (comp == NULL) {
-       return (NULL);
+    /*
+     * str = "<domain>:/Network/Service/<serviceID>"
+     *   OR
+     * str = "<domain>:/Network/Service/<serviceID>/<protocol>"
+     */
+    components = CFStringCreateArrayBySeparatingStrings(NULL, str, CFSTR("/"));
+    count = CFArrayGetCount(components);
+    if (count >= 4) {
+       /* we have a serviceID */
+       serviceID = CFArrayGetValueAtIndex(components, 3);
+       CFRetain(serviceID);
+       if (count >= 5 && ret_protocol != NULL) {
+           /* we have and want a protocol */
+           protocol = CFArrayGetValueAtIndex(components, 4);
+           CFRetain(protocol);
+       }
     }
-    CFStringDelete(comp, CFRangeMake(0, CFStringGetLength(prefix)));
-    range = CFStringFind(comp, CFSTR("/"), 0);
-    if (range.location == kCFNotFound) {
-       return (comp);
+    if (ret_protocol != NULL) {
+       *ret_protocol = protocol;
     }
-    range.length = CFStringGetLength(comp) - range.location;
-    CFStringDelete(comp, range);
-    return (comp);
+    my_CFRelease(&components);
+    return serviceID;
 }
 
-
 static boolean_t
 ipdict_is_routable(CFDictionaryRef entity_dict)
 {
@@ -3966,7 +3972,6 @@ static void
 log_service_entity(int level, CFStringRef serviceID, CFStringRef entity,
                   CFStringRef operation, CFTypeRef val)
 {
-    serviceIDNumber    service_number;
     CFMutableStringRef         this_val = NULL;
 
     if (val != NULL) {
@@ -4000,14 +4005,9 @@ log_service_entity(int level, CFStringRef serviceID, CFStringRef entity,
     if (val == NULL) {
        val = CFSTR("<none>");
     }
-    if (serviceIDNumberGetIfPresent(serviceID, &service_number)) {
-       my_log(level, "serviceID %@ <SID %ld> %@ %@ value = %@",
-              serviceID, service_number, operation, entity, val);
-    }
-    else {
-       my_log(level, "serviceID %@ %@ %@ value = %@",
-              serviceID, operation, entity, val);
-    }
+    my_log(level, "serviceID %@ %@ %@ value = %@",
+          serviceID, operation, entity, val);
+
     my_CFRelease(&this_val);
     return;
 }
@@ -4046,7 +4046,6 @@ service_dict_set(CFStringRef serviceID, CFStringRef entity,
     }
     if (CFDictionaryGetCount(service_dict) == 0) {
        CFDictionaryRemoveValue(S_service_state_dict, serviceID);
-       serviceIDNumberRemove(serviceID);
     }
     else {
        CFDictionarySetValue(S_service_state_dict, serviceID, service_dict);
@@ -4374,15 +4373,13 @@ pick_prop(CFMutableDictionaryRef        dict,
     routes->flags = 0;
 
 static CFDataRef
-IPv4RouteListDataCreate(CFDictionaryRef dict, CFNumberRef rank_assertion,
-                       serviceIDNumber sidn)
+IPv4RouteListDataCreate(CFDictionaryRef dict, CFNumberRef rank_assertion)
 {
     IPv4RouteListRef   r;
     CFDataRef          routes_data;
     IPV4_ROUTES_BUF_DECL(routes);
 
-    r = IPv4RouteListCreateWithDictionary(routes, dict, rank_assertion,
-                                         sidn);
+    r = IPv4RouteListCreateWithDictionary(routes, dict, rank_assertion);
     if (r != NULL) {
        routes_data = CFDataCreate(NULL,
                                   (const void *)r,
@@ -4402,7 +4399,7 @@ IPv4RouteListDataCreate(CFDictionaryRef dict, CFNumberRef rank_assertion,
             sizeof(uint32_t))                                          \
      / sizeof(uint32_t))
 
-#define IPV6_ROUTES_BUF_DECL(routes) \
+#define IPV6_ROUTES_BUF_DECL(routes)                                  \
     IPv6RouteListRef   routes;                                        \
     uint32_t           routes_buf[IPV6_ROUTES_ALIGN_BUF_SIZE_UINT32]; \
                                                                       \
@@ -4412,15 +4409,13 @@ IPv4RouteListDataCreate(CFDictionaryRef dict, CFNumberRef rank_assertion,
     routes->flags = 0;
 
 static CFDataRef
-IPv6RouteListDataCreate(CFDictionaryRef dict, CFNumberRef rank_assertion,
-                       serviceIDNumber sidn)
+IPv6RouteListDataCreate(CFDictionaryRef dict, CFNumberRef rank_assertion)
 {
     IPv6RouteListRef   r;
     CFDataRef          routes_data;
     IPV6_ROUTES_BUF_DECL(routes);
 
-    r = IPv6RouteListCreateWithDictionary(routes, dict, rank_assertion,
-                                         sidn);
+    r = IPv6RouteListCreateWithDictionary(routes, dict, rank_assertion);
     if (r != NULL) {
        routes_data = CFDataCreate(NULL,
                                   (const void *)r,
@@ -4438,15 +4433,13 @@ IPv6RouteListDataCreate(CFDictionaryRef dict, CFNumberRef rank_assertion,
 static CFDictionaryRef
 IPDictCreate(int af, _Nonnull CFDictionaryRef state_dict,
             CFDictionaryRef setup_dict,
-            CFNumberRef rank_assertion, CFStringRef serviceID)
+            CFNumberRef rank_assertion)
 {
     CFDictionaryRef            aggregated_dict = NULL;
     CFDictionaryRef            dict;
     CFMutableDictionaryRef     modified_dict = NULL;
     CFDataRef                  routes_data;
-    serviceIDNumber            sidn;
 
-    sidn = serviceIDNumberGet(serviceID);
     dict = state_dict;
     if (setup_dict != NULL) {
        /* look for keys in Setup: that override/merge with State: */
@@ -4511,11 +4504,11 @@ IPDictCreate(int af, _Nonnull CFDictionaryRef state_dict,
     }
     switch (af) {
     case AF_INET:
-       routes_data = IPv4RouteListDataCreate(dict, rank_assertion, sidn);
+       routes_data = IPv4RouteListDataCreate(dict, rank_assertion);
        break;
     default:
     case AF_INET6:
-       routes_data = IPv6RouteListDataCreate(dict, rank_assertion, sidn);
+       routes_data = IPv6RouteListDataCreate(dict, rank_assertion);
        break;
     }
     if (routes_data != NULL) {
@@ -4547,8 +4540,7 @@ get_ipv4_changes(CFStringRef serviceID, CFDictionaryRef state_dict,
            = CFDictionaryGetValue(service_options,
                                   kServiceOptionRankAssertion);
     }
-    dict = IPDictCreate(AF_INET, state_dict, setup_dict, rank_assertion,
-                       serviceID);
+    dict = IPDictCreate(AF_INET, state_dict, setup_dict, rank_assertion);
 
   done:
     changed = service_dict_set(serviceID, kSCEntNetIPv4, dict);
@@ -4584,8 +4576,7 @@ get_ipv6_changes(CFStringRef serviceID, CFDictionaryRef state_dict,
                                   kServiceOptionRankAssertion);
     }
 
-    dict = IPDictCreate(AF_INET6, state_dict, setup_dict, rank_assertion,
-                       serviceID);
+    dict = IPDictCreate(AF_INET6, state_dict, setup_dict, rank_assertion);
 
   done:
 
@@ -7231,7 +7222,8 @@ ElectionResultsGetPrimary(ElectionResultsRef results,
                          CandidateRef other_candidate,
                          nwi_state_t nwi_state, int af,
                          RouteListRef * ret_routes,
-                         CFDictionaryRef services_info)
+                         CFDictionaryRef services_info,
+                         CFSetRef ip_service_changes)
 {
     CandidateRef       primary = NULL;
     Boolean            primary_is_null = FALSE;
@@ -7294,14 +7286,17 @@ ElectionResultsGetPrimary(ElectionResultsRef results,
            service_dict = service_dict_get(scan->serviceID, entity_name);
            service_routes = ipdict_get_routelist(service_dict);
            if (service_routes != NULL) {
+               boolean_t       force;
                Rank            rank = scan->rank;
 
                if (skip) {
                    /* routes are RankNever to prevent becoming primary */
                    rank = RankMake(rank, kRankAssertionNever);
                }
+               force = my_CFSetContainsValue(ip_service_changes,
+                                             scan->serviceID);
                routes = RouteListAddRouteList(info, routes, initial_size,
-                                              service_routes, rank);
+                                              service_routes, rank, force);
                if ((service_routes->flags & kRouteListFlagsExcludeNWI) != 0) {
                    skip = TRUE;
                }
@@ -8177,6 +8172,8 @@ IPMonitorProcessChanges(SCDynamicStoreRef session, CFArrayRef changed_keys,
     boolean_t          dnsinfo_changed         = FALSE;
     boolean_t          global_ipv4_changed     = FALSE;
     boolean_t          global_ipv6_changed     = FALSE;
+    CFMutableSetRef    ipv4_service_changes    = NULL;
+    CFMutableSetRef    ipv6_service_changes    = NULL;
     keyChangeList      keys;
     CFIndex            n;
     boolean_t          nat64_changed           = FALSE;
@@ -8238,7 +8235,6 @@ IPMonitorProcessChanges(SCDynamicStoreRef session, CFArrayRef changed_keys,
     keyChangeListInit(&keys);
     service_changes = CFArrayCreateMutable(NULL, 0,
                                           &kCFTypeArrayCallBacks);
-
     for (CFIndex i = 0; i < count; i++) {
        CFStringRef     change;
 #if    !TARGET_OS_SIMULATOR && !TEST_IPV4_ROUTELIST && !TEST_IPV6_ROUTELIST
@@ -8264,18 +8260,30 @@ IPMonitorProcessChanges(SCDynamicStoreRef session, CFArrayRef changed_keys,
                reachability_changed = TRUE;
        }
        else if (CFStringHasPrefix(change, S_state_service_prefix)) {
+           CFStringRef protocol = NULL;
            CFStringRef serviceID;
 
-           serviceID = parse_component(change, S_state_service_prefix);
+           serviceID = parseNetworkServiceString(change, &protocol);
            if (serviceID != NULL) {
                my_CFArrayAppendUniqueValue(service_changes, serviceID);
+               if (protocol != NULL) {
+                   if (CFEqual(protocol, kSCEntNetIPv4)) {
+                       /* IPv4 service changed, remember that */
+                       my_CFSetAddValue(&ipv4_service_changes, serviceID);
+                   }
+                   else if (CFEqual(protocol, kSCEntNetIPv6)) {
+                       /* IPv6 service changed, remember that */
+                       my_CFSetAddValue(&ipv6_service_changes, serviceID);
+                   }
+               }
                CFRelease(serviceID);
            }
+           my_CFRelease(&protocol);
        }
        else if (CFStringHasPrefix(change, S_setup_service_prefix)) {
            CFStringRef serviceID;
 
-           serviceID = parse_component(change, S_setup_service_prefix);
+           serviceID = parseNetworkServiceString(change, NULL);
            if (serviceID != NULL) {
                my_CFArrayAppendUniqueValue(service_changes, serviceID);
                CFRelease(serviceID);
@@ -8326,7 +8334,10 @@ IPMonitorProcessChanges(SCDynamicStoreRef session, CFArrayRef changed_keys,
        }
     }
 
-    /* process protocol (v4, v6, rank, ...) and configuration (dns, proxies, smb, ...) changes */
+    /*
+     * process protocol (v4, v6, rank, ...) and
+     * configuration (dns, proxies, smb, ...) changes
+     */
     n = CFArrayGetCount(service_changes);
     for (CFIndex i = 0; i < n; i++) {
        uint32_t        changes;
@@ -8334,6 +8345,12 @@ IPMonitorProcessChanges(SCDynamicStoreRef session, CFArrayRef changed_keys,
 
        serviceID = CFArrayGetValueAtIndex(service_changes, i);
        changes = service_changed(services_info, serviceID);
+       if (my_CFSetContainsValue(ipv4_service_changes, serviceID)) {
+           changes |= (1 << kEntityTypeIPv4);
+       }
+       if (my_CFSetContainsValue(ipv6_service_changes, serviceID)) {
+           changes |= (1 << kEntityTypeIPv6);
+       }
        if ((changes & (1 << kEntityTypeServiceOptions)) != 0) {
            /* if __Service__ (e.g. PrimaryRank) changed */
            global_ipv4_changed = TRUE;
@@ -8422,7 +8439,8 @@ IPMonitorProcessChanges(SCDynamicStoreRef session, CFArrayRef changed_keys,
                                                      other_candidate,
                                                      S_nwi_state, AF_INET,
                                                      &new_routelist.common,
-                                                     services_info);
+                                                     services_info,
+                                                     ipv4_service_changes);
        new_primary = (primary_candidate != NULL)
            ? primary_candidate->serviceID : NULL;
        (void)set_new_primary(&S_primary_ipv4, new_primary, "IPv4");
@@ -8436,7 +8454,8 @@ IPMonitorProcessChanges(SCDynamicStoreRef session, CFArrayRef changed_keys,
                                                      other_candidate,
                                                      S_nwi_state, AF_INET6,
                                                      &new_routelist.common,
-                                                     services_info);
+                                                     services_info,
+                                                     ipv6_service_changes);
        new_primary = (primary_candidate != NULL)
            ? primary_candidate->serviceID : NULL;
        (void)set_new_primary(&S_primary_ipv6, new_primary, "IPv6");
@@ -8587,6 +8606,8 @@ IPMonitorProcessChanges(SCDynamicStoreRef session, CFArrayRef changed_keys,
     }
     my_CFRelease(&service_changes);
     my_CFRelease(&services_info);
+    my_CFRelease(&ipv4_service_changes);
+    my_CFRelease(&ipv6_service_changes);
 
     if (changes != 0) {
        network_change_msg = CFStringCreateMutable(NULL, 0);
@@ -8966,8 +8987,6 @@ ip_plugin_init()
     CFRunLoopAddSource(CFRunLoopGetCurrent(), rls, kCFRunLoopDefaultMode);
     CFRelease(rls);
 
-    serviceIDNumberInit();
-
     /* initialize dns configuration */
     (void)dns_configuration_set(NULL, NULL, NULL, NULL, NULL);
 #if    !TARGET_OS_IPHONE
@@ -9777,7 +9796,7 @@ make_IPv4RouteList_for_test(IPv4RouteListRef list,
                = CFNumberCreate(NULL, kCFNumberSInt32Type, &rank_assertion);
        }
     }
-    r = IPv4RouteListCreateWithDictionary(routes, dict, rank_assertion_cf, 0);
+    r = IPv4RouteListCreateWithDictionary(routes, dict, rank_assertion_cf);
     my_CFRelease(&rank_assertion_cf);
     if (r == NULL) {
        fprintf(stderr, "IPv4RouteListCreateWithDictionary failed\n");
@@ -10444,7 +10463,7 @@ make_IPv6RouteList_for_test(IPv6RouteListRef list,
                = CFNumberCreate(NULL, kCFNumberSInt32Type, &rank_assertion);
        }
     }
-    r = IPv6RouteListCreateWithDictionary(routes, dict, rank_assertion_cf, 0);
+    r = IPv6RouteListCreateWithDictionary(routes, dict, rank_assertion_cf);
     my_CFRelease(&rank_assertion_cf);
     if (r == NULL) {
        fprintf(stderr, "IPv6RouteListCreateWithDictionary failed\n");
index e53f71ca02e963bc64f3c3ebd3c694415fee6d84..7fc143938a8c0007fc071a08786611d36e8b2440 100644 (file)
@@ -12,5 +12,7 @@ sed -e 's/^\(Process:.*\[\)[0-9][0-9]*/\1XXXX/'                       \
     -e 's/^\(OS Version: \)\(.*$\)/\1XXXX/'                    \
     -e '/^Load Address:.*/d'                                   \
     -e '/^Launch Time:.*/d'                                    \
+    -e '/^Parent Process:.*/d'                                 \
+    -e '/^Analysis Tool Version:.*/d'                          \
     -e '/^Physical footprint:.*/d'                             \
     -e '/^Physical footprint (peak):.*/d'
diff --git a/Plugins/IPMonitor/serviceIDNumber.c b/Plugins/IPMonitor/serviceIDNumber.c
deleted file mode 100644 (file)
index 240748d..0000000
+++ /dev/null
@@ -1,241 +0,0 @@
-/*
- * Copyright (c) 2019 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@
- */
-
-/*
- * serviceID_number.c
- * - assigns numbers to serviceID strings
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-
-#include "serviceIDNumber.h"
-#include <CoreFoundation/CFDictionary.h>
-
-#if TEST_SERVICEID_NUMBER
-#include <SystemConfiguration/SCPrivate.h>
-#endif /* TEST_SERVICEID_NUMBER */
-
-
-/* dictionary to hold serviceIDNumber: key is the serviceID */
-static CFMutableDictionaryRef  S_serviceID_to_number_dict;
-
-/* dictionary to hold serviceID: key is the serviceIDNumber */
-static CFMutableDictionaryRef  S_number_to_serviceID_dict;
-
-static Boolean
-serviceIDNumberEqual(const void * ptr1, const void * ptr2)
-{
-       return (((serviceIDNumber)ptr1) == ((serviceIDNumber)ptr2));
-}
-
-static CFStringRef
-serviceIDNumberCopyDescription(const void * ptr)
-{
-       return CFStringCreateWithFormat(NULL, NULL, CFSTR("%ld"),
-                                       (serviceIDNumber)ptr);
-}
-
-static CFHashCode
-serviceIDNumberHash(const void * ptr) {
-       return (CFHashCode)((serviceIDNumber)ptr);
-}
-
-static const CFDictionaryValueCallBacks kserviceIDNumberValueCallBacks = {
-       0, NULL, NULL, serviceIDNumberCopyDescription, serviceIDNumberEqual
-};
-
-static const CFDictionaryKeyCallBacks kserviceIDNumberKeyCallBacks = {
-       0, NULL, NULL, serviceIDNumberCopyDescription, serviceIDNumberEqual,
-       serviceIDNumberHash
-};
-
-/**
- ** S_serviceID_numbers
- **/
-
-__private_extern__ Boolean
-serviceIDNumberGetIfPresent(CFStringRef serviceID, serviceIDNumber *sidn)
-{
-       Boolean                 has_number;
-       const void *            val;
-
-       has_number = CFDictionaryGetValueIfPresent(S_serviceID_to_number_dict,
-                                                  serviceID, &val);
-       if (has_number) {
-               *sidn = (serviceIDNumber)val;
-       }
-       return (has_number);
-}
-
-/*
- * Function: serviceIDNumberGet
- * Purpose:
- *   Return the currently assigned serviceIDNumber for the given serviceID.
- *   If one is already assigned, return that. If one isn't assigned, check
- *   the next integer value after 'current_sidn', but skip zero.
- *   If that number is assigned, pick the next one.
- */
-static serviceIDNumber S_current_sidn;
-
-__private_extern__ serviceIDNumber
-serviceIDNumberGet(CFStringRef serviceID)
-{
-       serviceIDNumber         sidn;
-
-       if (serviceIDNumberGetIfPresent(serviceID, &sidn)) {
-               return (sidn);
-       }
-       while (1) {
-               /* assign a number to the serviceID */
-               S_current_sidn++;
-               if (S_current_sidn == kserviceIDNumberZero) {
-                       /* skip zero */
-                       S_current_sidn++;
-               }
-               /* if it's in use, skip to the next value */
-               if (CFDictionaryContainsKey(S_number_to_serviceID_dict,
-                                           (const void *)S_current_sidn)) {
-                       continue;
-               }
-               /* it's not in use, use it */
-               sidn = S_current_sidn;
-               CFDictionarySetValue(S_serviceID_to_number_dict,
-                                    serviceID, (const void *)sidn);
-               CFDictionarySetValue(S_number_to_serviceID_dict,
-                                    (const void *)sidn, serviceID);
-               break;
-       }
-       return (sidn);
-}
-
-
-__private_extern__ void
-serviceIDNumberRemove(CFStringRef serviceID)
-{
-       const void *    val;
-
-       if (CFDictionaryGetValueIfPresent(S_serviceID_to_number_dict, serviceID,
-                                         &val)) {
-#if TEST_SERVICEID_NUMBER
-               SCPrint(TRUE, stdout, CFSTR("Removing %@ %ld\n"),
-                       serviceID, (serviceIDNumber)val);
-#endif
-               CFDictionaryRemoveValue(S_serviceID_to_number_dict, serviceID);
-               CFDictionaryRemoveValue(S_number_to_serviceID_dict, val);
-       }
-}
-
-__private_extern__ void
-serviceIDNumberInit(void)
-{
-       S_serviceID_to_number_dict
-               = CFDictionaryCreateMutable(NULL, 0,
-                                           &kCFTypeDictionaryKeyCallBacks,
-                                           &kserviceIDNumberValueCallBacks);
-       S_number_to_serviceID_dict
-               = CFDictionaryCreateMutable(NULL, 0,
-                                           &kserviceIDNumberKeyCallBacks,
-                                           &kCFTypeDictionaryValueCallBacks);
-}
-
-#if TEST_SERVICEID_NUMBER
-
-static CFStringRef
-my_CFUUIDStringCreate(CFAllocatorRef alloc)
-{
-       CFUUIDRef       uuid;
-       CFStringRef     uuid_str;
-
-       uuid = CFUUIDCreate(alloc);
-       uuid_str = CFUUIDCreateString(alloc, uuid);
-       CFRelease(uuid);
-       return (uuid_str);
-}
-
-int
-main()
-{
-#define N_LIST         10
-       CFStringRef     serviceID_list[N_LIST];
-
-       serviceIDNumberInit();
-       for (int i = 0; i < N_LIST; i++) {
-               CFStringRef     serviceID = my_CFUUIDStringCreate(NULL);
-               serviceIDNumber sidn;
-
-               /* force a collision */
-               S_current_sidn = -1;
-
-               sidn = serviceIDNumberGet(serviceID);
-               SCPrint(TRUE, stdout, CFSTR("%d: %@ %ld\n"),
-                       i, serviceID, sidn);
-               serviceID_list[i] = serviceID;
-
-       }
-       for (int i = 0; i < N_LIST; i++) {
-               CFStringRef     serviceID = serviceID_list[i];
-               serviceIDNumber sidn;
-
-               if (!serviceIDNumberGetIfPresent(serviceID, &sidn)) {
-                       SCPrint(TRUE, stderr, CFSTR("Failed to find %@\n"),
-                               serviceID);
-                       exit(1);
-               }
-               SCPrint(TRUE, stdout, CFSTR("%@ => %ld\n"), serviceID, sidn);
-       }
-       {
-               serviceIDNumber sidn;
-
-               if (serviceIDNumberGetIfPresent(CFSTR("blah"), &sidn)) {
-                       fprintf(stderr,
-                               "Shouldn't have been able to look that up\n");
-                       exit(1);
-               }
-       }
-
-       for (int i = 0; i < N_LIST / 2; i++) {
-               CFStringRef     serviceID = serviceID_list[i];
-               serviceIDNumber sidn;
-
-               serviceIDNumberRemove(serviceID);
-               if (serviceIDNumberGetIfPresent(serviceID, &sidn)) {
-                       SCPrint(TRUE, stderr,
-                               CFSTR("Found %@, but shouldn't have\n"),
-                               serviceID);
-                       exit(1);
-               }
-       }
-
-       for (int i = 0; i < N_LIST; i++) {
-               CFStringRef     serviceID = serviceID_list[i];
-               serviceIDNumber sidn;
-
-               sidn = serviceIDNumberGet(serviceID);
-               SCPrint(TRUE, stdout, CFSTR("%d: %@ %ld\n"),
-                       i, serviceID, sidn);
-       }
-       exit(0);
-}
-#endif /* TEST_SERVICEID_NUMBER */
diff --git a/Plugins/IPMonitor/serviceIDNumber.h b/Plugins/IPMonitor/serviceIDNumber.h
deleted file mode 100644 (file)
index 1d02021..0000000
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Copyright (c) 2019 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@
- */
-
-/*
- * serviceID_number.h
- * - assigns numbers to serviceID strings
- */
-
-#ifndef        _SERVICEID_NUMBER_H
-#define        _SERVICEID_NUMBER_H
-
-#include <CoreFoundation/CFString.h>
-#include <sys/types.h>
-
-/*
- * Type: serviceIDNumber
- * Purpose:
- *   A compact way to represent a serviceID that doesn't involve needing
- *   to worry about memory allocation or large comparisions.
- */
-typedef u_long         serviceIDNumber, *serviceIDNumberRef;
-
-/*
- * Const: kserviceIDNumberZero
- *
- * Purpose:
- *   The zero value for serviceIDNumber. It will never be returned,
- *   it is a reserved value.
- */
-#define kserviceIDNumberZero   (serviceIDNumber)(0)
-
-/*
- * Function: serviceIDNumberGetIfPresent
- *
- * Purpose:
- *   Returns TRUE and the serviceIDNumber for the given serviceID, if it
- *   is present, FALSE otherwise.
- */
-Boolean
-serviceIDNumberGetIfPresent(CFStringRef serviceID, serviceIDNumberRef sidn);
-
-/*
- * Function: serviceIDNumberGet
- *
- * Purpose:
- *   Returns a unique serviceIDNumber for the given serviceID.
- */
-serviceIDNumber
-serviceIDNumberGet(CFStringRef serviceID);
-
-/*
- * Function: serviceIDNumberRemove
- *
- * Purpose:
- *   Removes the assigned serviceIDNumber for the given serviceID.
- */
-void
-serviceIDNumberRemove(CFStringRef serviceID);
-
-
-/*
- * Function: serviceIDNumberInit
- *
- * Purpose:
- *   Initialize the serviceID number database.
- */
-void
-serviceIDNumberInit(void);
-
-#endif /* _SERVICEID_NUMBER_H */
index e0e92102dccf8836057de1967b91348f82e1dbdd..aa9f2430252ea4f9f49804839098b0a1306e6b32 100644 (file)
@@ -26175,13 +26175,10 @@ Process:         test_ipv4_routelist [XXXX]
 Path: XXXX
 Identifier:      test_ipv4_routelist
 Code Type:       X86-64
-Parent Process:  sh [XXXX]
 
 Date/Time:       XXXX
 OS Version: XXXX
 Report Version:  7
-Analysis Tool Version:  Xcode 11.0 (11M275m)
-
 
 leaks Report Version: 4.0
 Process XXXX 0 leaks for 0 total leaked bytes.
index 34fb3308fae35ce39f33f0d6c08ac4af0e6facf0..d5d5b9b6156a255ec439976abf53c7522f0dc8df 100644 (file)
@@ -1388,13 +1388,10 @@ Process:         test_ipv6_routelist [XXXX]
 Path: XXXX
 Identifier:      test_ipv6_routelist
 Code Type:       X86-64
-Parent Process:  sh [XXXX]
 
 Date/Time:       XXXX
 OS Version: XXXX
 Report Version:  7
-Analysis Tool Version:  Xcode 11.0 (11M275m)
-
 
 leaks Report Version: 4.0
 Process XXXX 0 leaks for 0 total leaked bytes.
index fd9a358dd8dd823af60af0e4736d8f6f471fc2c3..5cc8c6d17fab551dc9b9efd259bed94b49ecaf39 100644 (file)
                F95B8A460B03E09300993BA3 /* SCNetworkSignature.h in Headers */ = {isa = PBXBuildFile; fileRef = F95B8A440B03E09300993BA3 /* SCNetworkSignature.h */; settings = {ATTRIBUTES = (Private, ); }; };
                F95B8A470B03E09300993BA3 /* SCNetworkSignaturePrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = F95B8A450B03E09300993BA3 /* SCNetworkSignaturePrivate.h */; settings = {ATTRIBUTES = (Private, ); }; };
                F963401020FE8E6000F1E1F1 /* AwdMetadata-0x81-IPMonitor.bin in CopyFiles */ = {isa = PBXBuildFile; fileRef = F963400E20FE8E1D00F1E1F1 /* AwdMetadata-0x81-IPMonitor.bin */; };
-               F97289D322652D0600080596 /* serviceIDNumber.c in Sources */ = {isa = PBXBuildFile; fileRef = F97289D122652CE600080596 /* serviceIDNumber.c */; };
-               F97289D422652D0A00080596 /* serviceIDNumber.c in Sources */ = {isa = PBXBuildFile; fileRef = F97289D122652CE600080596 /* serviceIDNumber.c */; };
-               F97289D522652D0D00080596 /* serviceIDNumber.c in Sources */ = {isa = PBXBuildFile; fileRef = F97289D122652CE600080596 /* serviceIDNumber.c */; };
                F9A3781016A4847700C57CDC /* IPMonitorControlPrefs.c in Sources */ = {isa = PBXBuildFile; fileRef = F9A3780E16A4846E00C57CDC /* IPMonitorControlPrefs.c */; };
                F9A3781116A4849100C57CDC /* IPMonitorControlPrefs.c in Sources */ = {isa = PBXBuildFile; fileRef = F9A3780E16A4846E00C57CDC /* IPMonitorControlPrefs.c */; };
                F9B50FF316A4CBB200CA274E /* IPMonitorControlPrefs.c in Sources */ = {isa = PBXBuildFile; fileRef = F9A3780E16A4846E00C57CDC /* IPMonitorControlPrefs.c */; };
                F95B8A440B03E09300993BA3 /* SCNetworkSignature.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = SCNetworkSignature.h; sourceTree = "<group>"; };
                F95B8A450B03E09300993BA3 /* SCNetworkSignaturePrivate.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = SCNetworkSignaturePrivate.h; sourceTree = "<group>"; };
                F963400E20FE8E1D00F1E1F1 /* AwdMetadata-0x81-IPMonitor.bin */ = {isa = PBXFileReference; lastKnownFileType = archive.macbinary; path = "AwdMetadata-0x81-IPMonitor.bin"; sourceTree = "<group>"; };
-               F97289D122652CE600080596 /* serviceIDNumber.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = serviceIDNumber.c; sourceTree = "<group>"; };
-               F97289D222652CE600080596 /* serviceIDNumber.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = serviceIDNumber.h; sourceTree = "<group>"; };
                F9A3780E16A4846E00C57CDC /* IPMonitorControlPrefs.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = IPMonitorControlPrefs.c; sourceTree = "<group>"; };
                F9A3780F16A4846E00C57CDC /* IPMonitorControlPrefs.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = IPMonitorControlPrefs.h; sourceTree = "<group>"; };
                F9B7AE5C1862116500C78D18 /* IPMonitorControl.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = IPMonitorControl.c; sourceTree = "<group>"; };
                                15812A2D1EA5540B001CF384 /* nat64-configuration.c */,
                                1575FD2612CD15C60003D86E /* proxy-configuration.h */,
                                1575FD2512CD15C60003D86E /* proxy-configuration.c */,
-                               F97289D122652CE600080596 /* serviceIDNumber.c */,
-                               F97289D222652CE600080596 /* serviceIDNumber.h */,
                                155D22390AF13A7300D52ED0 /* set-hostname.h */,
                                159D53AB07528B36004F8947 /* set-hostname.c */,
                                155D223A0AF13A7300D52ED0 /* smb-configuration.h */,
                                155281020E3E4A0F00C54315 /* ip_plugin.c in Sources */,
                                E4F211D3137B0AB900BBB915 /* network_state_information_priv.c in Sources */,
                                153ACCA914E322D5005029A5 /* network_information_server.c in Sources */,
-                               F97289D322652D0600080596 /* serviceIDNumber.c in Sources */,
                                1575FD2712CD15C60003D86E /* proxy-configuration.c in Sources */,
                                157A84FC0D56C7E800B6F1A0 /* set-hostname.c in Sources */,
                                1501F76A1EA8019D006A71B0 /* nat64-configuration.c in Sources */,
                                F9B7AE6A186211D300C78D18 /* IPMonitorControlServer.c in Sources */,
                                F9D7305320E4211900521181 /* IPMonitorAWDReport.m in Sources */,
                                F9D7305220E4211900521181 /* AWDIPMonitorInterfaceAdvisoryReport.m in Sources */,
-                               F97289D422652D0A00080596 /* serviceIDNumber.c in Sources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
                                159FFD612110EA71009311DD /* dnsinfo_flatfile.c in Sources */,
                                15E1B04D16EBAE3C00E5F06F /* dnsinfo_server.c in Sources */,
                                15E1B04E16EBAE3C00E5F06F /* ip_plugin.c in Sources */,
-                               F97289D522652D0D00080596 /* serviceIDNumber.c in Sources */,
                                15E1B04F16EBAE3C00E5F06F /* network_state_information_priv.c in Sources */,
                                15E1B05016EBAE3C00E5F06F /* network_information_server.c in Sources */,
                                15E1B05116EBAE3C00E5F06F /* proxy-configuration.c in Sources */,