]> git.saurik.com Git - apple/network_cmds.git/commitdiff
network_cmds-596.100.2.tar.gz macos-10154 macos-10155 macos-10156 v596.100.2
authorApple <opensource@apple.com>
Wed, 11 Dec 2019 20:30:43 +0000 (20:30 +0000)
committerApple <opensource@apple.com>
Wed, 11 Dec 2019 20:30:43 +0000 (20:30 +0000)
ecnprobe/capture.c
ifconfig.tproj/ifbridge.c
netstat.tproj/if.c
network_cmds.xcodeproj/project.pbxproj

index 83cbf7865528820672522ccd20ec22417229c26e..32a8e0b18e2601f160b284f21bf6fb42af6d8ba3 100644 (file)
@@ -82,7 +82,17 @@ void CaptureInit(u_int32_t sourceIP, u_int16_t sourcePort,
   if (dev != NULL) {
     device = dev;
   } else {
-    device = pcap_lookupdev(errbuf);
+    pcap_if_t *devlist;
+    /*
+    * Find the list of interfaces, and pick
+     * the first interface.
+     */
+    if (pcap_findalldevs(&devlist, errbuf) >= 0 &&
+             devlist != NULL) {
+      device = strdup(devlist->name);
+      pcap_freealldevs(devlist);
+    }
+
     if (device == NULL) {
       fprintf(stderr, "Can't find capture device: %s\n", errbuf);
       exit(-1);
index 0b610ceafa18c00aba41f419d7c73fe9d29898f1..951c56bd4661c3a448bb0cef385aa56a1be8981a 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009-2014 Apple Inc. All rights reserved.
+ * Copyright (c) 2009-2019 Apple Inc. All rights reserved.
  *
  * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
  *
@@ -299,6 +299,56 @@ bridge_addresses(int s, const char *prefix)
        free(inbuf);
 }
 
+#define MAX_IPv6_STR_LEN       INET6_ADDRSTRLEN
+static void
+bridge_mac_nat(int s, const char *prefix)
+{
+       char *buf;
+       unsigned int count;
+       struct ether_addr ea;
+       unsigned int i;
+       struct ifbrmnelist mnl;
+       char *scan;
+
+       bzero(&mnl, sizeof(mnl));
+       if (do_cmd(s, BRDGGMACNATLIST, &mnl, sizeof(mnl), 0) < 0) {
+               /* err(1, "unable to get mac nat list"); */
+               return;
+       }
+       if (mnl.ifbml_len == 0) {
+               return;
+       }
+       printf("\tMAC NAT list:\n");
+       if (mnl.ifbml_elsize == 0) {
+               err(1, "kernel reported zero length element size");
+       }
+       if (mnl.ifbml_elsize < sizeof(struct ifbrmne)) {
+               err(1, "struct element size too small, kernel mismatch");
+       }
+       buf = malloc(mnl.ifbml_len);
+       if (buf == NULL) {
+               err(1, "unable to allocate mac nat list buffer");
+       }
+       mnl.ifbml_buf = buf;
+       if (do_cmd(s, BRDGGMACNATLIST, &mnl, sizeof(mnl), 0) < 0) {
+               err(1, "unable to get mac nat list");
+       }
+       count = mnl.ifbml_len / mnl.ifbml_elsize;
+       for (i = 0, scan = buf; i < count; i++, scan += mnl.ifbml_elsize) {
+               struct ifbrmne *ifbmne = (struct ifbrmne *)scan;
+               char ntopbuf[INET6_ADDRSTRLEN];
+
+               memcpy(ea.octet, ifbmne->ifbmne_mac,
+                   sizeof(ea.octet));
+               inet_ntop(ifbmne->ifbmne_af, &ifbmne->ifbmne_ip,
+                         ntopbuf, sizeof(ntopbuf));
+               printf("%s%s %s %s %lu\n",
+                      prefix, ifbmne->ifbmne_ifname, ntopbuf, ether_ntoa(&ea),
+                      (unsigned long)ifbmne->ifbmne_expire);
+       }
+       free(buf);
+}
+
 static void
 bridge_status(int s)
 {
@@ -349,6 +399,7 @@ bridge_status(int s)
        if (!all || verbose > 1) {
                printf("\tAddress cache:\n");
                bridge_addresses(s, "\t\t");
+               bridge_mac_nat(s, "\t\t");
        }
        return;
 
@@ -814,6 +865,20 @@ unsetbridge_hostfilter(const char *ifn, int d, int s, const struct afswtch *afp)
                err(1, "BRDGSHOSTFILTER");
 }
 
+static void
+setbridge_macnat(const char *val, int d, int s, const struct afswtch *afp)
+{
+
+       do_bridgeflag(s, val, IFBIF_MAC_NAT,  1);
+}
+
+static void
+unsetbridge_macnat(const char *val, int d, int s, const struct afswtch *afp)
+{
+
+       do_bridgeflag(s, val, IFBIF_MAC_NAT,  0);
+}
+
 static struct cmd bridge_cmds[] = {
        DEF_CMD_ARG("addm",             setbridge_add),
        DEF_CMD_ARG("deletem",          setbridge_delete),
@@ -865,6 +930,8 @@ static struct cmd bridge_cmds[] = {
 #endif
         DEF_CMD_ARG2("hostfilter",     setbridge_hostfilter),
         DEF_CMD_ARG("-hostfilter",     unsetbridge_hostfilter),
+       DEF_CMD_ARG("macnat",           setbridge_macnat),
+       DEF_CMD_ARG("-macnat",          unsetbridge_macnat),
 };
 static struct afswtch af_bridge = {
        .af_name        = "af_bridge",
index 0704c32130e75013ebe7ce2360d10f0c023864fd..7339bde800c0f3d0fedd350dfafd93b013a510fe 100644 (file)
@@ -2052,7 +2052,7 @@ loop:
            interface, sp->ifi_poll_on_req, sp->ifi_poll_on_err);
        printf("     [ poll off requests: %15u  errors: %27u ]\n",
            sp->ifi_poll_off_req, sp->ifi_poll_off_err);
-       printf("     [ polled packets: %18llu  per poll limit: %19lu ]\n",
+       printf("     [ polled packets: %18llu  per poll limit: %19u ]\n",
            sp->ifi_poll_packets, sp->ifi_poll_packets_limit);
        printf("     [ polled bytes: %20llu ]\n", sp->ifi_poll_bytes);
        printf("     [ poll interval: %14llu nsec ]\n",
@@ -2079,7 +2079,7 @@ loop:
            np->ifn_rx_mit_cfg_packets_lowat, np->ifn_rx_mit_cfg_packets_hiwat);
        printf("     [ cfg bytes lo/hi threshold:   %12u / %12u ]\n",
            np->ifn_rx_mit_cfg_bytes_lowat, np->ifn_rx_mit_cfg_bytes_hiwat);
-       printf("     [ cfg interval: %15llu nsec ]\n",
+       printf("     [ cfg interval: %15u nsec ]\n",
            np->ifn_rx_mit_cfg_interval);
        printf("     [ mit interval: %15llu nsec ]\n",
            np->ifn_rx_mit_interval);
index 17a6ae50bce3f34613c4d54b8e270585aa13ba02..567ed52f733c8cfb84ff106fb2084c64a1033c25 100755 (executable)
                724DABBC0EE8908A008900D0 /* com.apple.kdumpd.plist in CopyFiles */ = {isa = PBXBuildFile; fileRef = 7261206E0EE86F2D00AFED1B /* com.apple.kdumpd.plist */; };
                724DAC120EE89423008900D0 /* ndp.c in Sources */ = {isa = PBXBuildFile; fileRef = 726120870EE86F4000AFED1B /* ndp.c */; };
                724DAC3B0EE89555008900D0 /* ndp.8 in CopyFiles */ = {isa = PBXBuildFile; fileRef = 726120860EE86F4000AFED1B /* ndp.8 */; };
-               7255D4311E44036D008F4A32 /* libcrypto.35.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 7255D4301E44036D008F4A32 /* libcrypto.35.dylib */; };
-               7255D4331E44037F008F4A32 /* libssl.35.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 7255D4321E44037F008F4A32 /* libssl.35.dylib */; };
                726121310EE8711E00AFED1B /* arp.c in Sources */ = {isa = PBXBuildFile; fileRef = 7261204E0EE86EF900AFED1B /* arp.c */; };
                726121350EE8713800AFED1B /* arp.8 in CopyFiles */ = {isa = PBXBuildFile; fileRef = 7261204D0EE86EF900AFED1B /* arp.8 */; };
                7261215A0EE8883900AFED1B /* ifbond.c in Sources */ = {isa = PBXBuildFile; fileRef = 726120550EE86F0900AFED1B /* ifbond.c */; };
                        compilerSpec = com.apple.compilers.proxy.script;
                        filePatterns = "$(PROJECT_DIR)/spray.tproj/spray.x";
                        fileType = pattern.proxy;
+                       inputFiles = (
+                       );
                        isEditable = 1;
                        outputFiles = (
                                "$(DERIVED_FILES_DIR)/$(INPUT_FILE_BASE).h",
                        isa = PBXFrameworksBuildPhase;
                        buildActionMask = 2147483647;
                        files = (
-                               7255D4331E44037F008F4A32 /* libssl.35.dylib in Frameworks */,
-                               7255D4311E44036D008F4A32 /* libcrypto.35.dylib in Frameworks */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
                                GCC_WARN_ABOUT_DEPRECATED_FUNCTIONS = NO;
                                GCC_WARN_UNDECLARED_SELECTOR = YES;
                                GCC_WARN_UNUSED_FUNCTION = YES;
+                               HEADER_SEARCH_PATHS = /usr/local/libressl/include;
                                INSTALL_MODE_FLAG = 0555;
                                INSTALL_PATH = /usr/libexec;
+                               LIBRARY_SEARCH_PATHS = /usr/local/libressl/lib;
                                MTL_ENABLE_DEBUG_INFO = YES;
+                               OTHER_LDFLAGS = (
+                                       "-lssl",
+                                       "-lcrypto",
+                               );
                                PRODUCT_NAME = "$(TARGET_NAME)";
                                SDKROOT = macosx.internal;
                                SUPPORTED_PLATFORMS = macosx;
                                GCC_WARN_ABOUT_DEPRECATED_FUNCTIONS = NO;
                                GCC_WARN_UNDECLARED_SELECTOR = YES;
                                GCC_WARN_UNUSED_FUNCTION = YES;
+                               HEADER_SEARCH_PATHS = /usr/local/libressl/include;
                                INSTALL_MODE_FLAG = 0555;
                                INSTALL_PATH = /usr/libexec;
+                               LIBRARY_SEARCH_PATHS = /usr/local/libressl/lib;
                                MTL_ENABLE_DEBUG_INFO = NO;
+                               OTHER_LDFLAGS = (
+                                       "-lssl",
+                                       "-lcrypto",
+                               );
                                PRODUCT_NAME = "$(TARGET_NAME)";
                                SDKROOT = macosx.internal;
                                SUPPORTED_PLATFORMS = macosx;
                                GCC_WARN_ABOUT_DEPRECATED_FUNCTIONS = NO;
                                GCC_WARN_UNDECLARED_SELECTOR = YES;
                                GCC_WARN_UNUSED_FUNCTION = YES;
+                               HEADER_SEARCH_PATHS = /usr/local/libressl/include;
                                INSTALL_MODE_FLAG = 0555;
                                INSTALL_PATH = /usr/libexec;
+                               LIBRARY_SEARCH_PATHS = /usr/local/libressl/lib;
                                MTL_ENABLE_DEBUG_INFO = NO;
+                               OTHER_LDFLAGS = (
+                                       "-lssl",
+                                       "-lcrypto",
+                               );
                                PRODUCT_NAME = "$(TARGET_NAME)";
                                SDKROOT = macosx.internal;
                                SUPPORTED_PLATFORMS = macosx;