]> git.saurik.com Git - apple/network_cmds.git/blobdiff - ifconfig.tproj/ifconfig.c
network_cmds-543.260.3.tar.gz
[apple/network_cmds.git] / ifconfig.tproj / ifconfig.c
index ecc5fd4dbd8f1acbd5586a7234d2f1ff0e98dc12..cb6a239c4de004844feab760d3e9321b812ab245 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009-2013 Apple Inc. All rights reserved.
+ * Copyright (c) 2009-2018 Apple Inc. All rights reserved.
  *
  * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
  *
  * SUCH DAMAGE.
  */
 
+#include <sys/cdefs.h>
+
 #ifndef lint
-static const char copyright[] =
+__unused static const char copyright[] =
 "@(#) Copyright (c) 1983, 1993\n\
        The Regents of the University of California.  All rights reserved.\n";
 #endif /* not lint */
 
-#ifndef lint
-#if 0
-static char sccsid[] = "@(#)ifconfig.c 8.2 (Berkeley) 2/16/94";
-#endif
-static const char rcsid[] =
-  "$FreeBSD: src/sbin/ifconfig/ifconfig.c,v 1.134.2.2.2.1 2008/11/25 02:59:29 kensmith Exp $";
-#endif /* not lint */
-
 #include <sys/param.h>
 #include <sys/ioctl.h>
 #include <sys/socket.h>
@@ -87,6 +81,7 @@ static const char rcsid[] =
 #include <net/if_mib.h>
 #include <net/route.h>
 #include <net/pktsched/pktsched.h>
+#include <net/network_agent.h>
 
 /* IP */
 #include <netinet/in.h>
@@ -103,6 +98,8 @@ static const char rcsid[] =
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
+#include <sysexits.h>
+#include <syslog.h>
 
 #include "ifconfig.h"
 
@@ -141,6 +138,8 @@ static char *bytes_to_str(unsigned long long bytes);
 static char *bps_to_str(unsigned long long rate);
 static char *ns_to_str(unsigned long long nsec);
 static void tunnel_status(int s);
+static void clat46_addr(int s, char *name);
+static void nat64_status(int s, char *name);
 static void usage(void);
 static char *sched2str(unsigned int s);
 static char *tl2str(unsigned int s);
@@ -257,13 +256,9 @@ main(int argc, char *argv[])
        argc -= optind;
        argv += optind;
 
-       /* -l cannot be used with -a or -q or -r or -m or -b */
+       /* -l cannot be used with -a or -q or -m or -b */
        if (namesonly &&
-#ifdef TARGET_OS_EMBEDDED
-        (all || supmedia || bond_details))
-#else /* TARGET_OS_EMBEDDED */
-           (all || supmedia || showrtref || bond_details))
-#endif /* !TARGET_OS_EMBEDDED */
+           (all || supmedia || bond_details))
                usage();
 
        /* nonsense.. */
@@ -280,7 +275,6 @@ main(int argc, char *argv[])
                        usage();
 
                ifname = NULL;
-               ifindex = 0;
                if (argc == 1) {
                        afp = af_getbyname(*argv);
                        if (afp == NULL)
@@ -772,7 +766,6 @@ setifflags(const char *vname, int value, int s, const struct afswtch *afp)
                Perror(vname);
 }
 
-#ifdef SIOCGIFCAP
 void
 setifcap(const char *vname, int value, int s, const struct afswtch *afp)
 {
@@ -793,7 +786,6 @@ setifcap(const char *vname, int value, int s, const struct afswtch *afp)
        if (ioctl(s, SIOCSIFCAP, (caddr_t)&ifr) < 0)
                Perror(vname);
 }
-#endif
 
 static void
 setifmetric(const char *val, int dummy __unused, int s, 
@@ -950,6 +942,33 @@ setthrottle(const char *val, int dummy __unused, int s,
        }
 }
 
+static void
+setdisableoutput(const char *val, int dummy __unused, int s,
+    const struct afswtch *afp)
+{
+       struct ifreq ifr;
+       char *cp;
+       errno = 0;
+       bzero(&ifr, sizeof (ifr));
+       strncpy(ifr.ifr_name, name, sizeof (ifr.ifr_name));
+
+       ifr.ifr_ifru.ifru_disable_output = strtold(val, &cp);
+       if (val == cp || errno != 0) {
+               warn("Invalid value '%s'", val);
+               return;
+       }
+
+       if (ioctl(s, SIOCSIFDISABLEOUTPUT, &ifr) < 0 && errno != ENXIO) {
+               warn("ioctl set disable output");
+       } else if (errno == ENXIO) {
+               printf("output thread can not be disabled on %s\n", name);
+       } else {
+               printf("output %s on %s\n",
+                   ((ifr.ifr_ifru.ifru_disable_output == 0) ? "enabled" : "disabled"),
+                   name);
+       }
+}
+
 static void
 setlog(const char *val, int dummy __unused, int s,
     const struct afswtch *afp)
@@ -971,20 +990,234 @@ setlog(const char *val, int dummy __unused, int s,
                warn("ioctl (set logging parameters)");
 }
 
+void
+setcl2k(const char *vname, int value, int s, const struct afswtch *afp)
+{
+       strncpy(ifr.ifr_name, name, sizeof(ifr.ifr_name));
+       ifr.ifr_ifru.ifru_2kcl = value;
+       
+       if (ioctl(s, SIOCSIF2KCL, (caddr_t)&ifr) < 0)
+               Perror(vname);
+}
+
+void
+setexpensive(const char *vname, int value, int s, const struct afswtch *afp)
+{
+       strncpy(ifr.ifr_name, name, sizeof(ifr.ifr_name));
+       ifr.ifr_ifru.ifru_expensive = value;
+       
+       if (ioctl(s, SIOCSIFEXPENSIVE, (caddr_t)&ifr) < 0)
+               Perror(vname);
+}
+
+void
+settimestamp(const char *vname, int value, int s, const struct afswtch *afp)
+{
+       strncpy(ifr.ifr_name, name, sizeof(ifr.ifr_name));
+       
+       if (value == 0) {
+               if (ioctl(s, SIOCSIFTIMESTAMPDISABLE, (caddr_t)&ifr) < 0)
+                       Perror(vname);
+       } else {
+               if (ioctl(s, SIOCSIFTIMESTAMPENABLE, (caddr_t)&ifr) < 0)
+                       Perror(vname);
+       }
+}
+
+void
+setecnmode(const char *val, int dummy __unused, int s,
+    const struct afswtch *afp)
+{
+       char *cp;
+
+       if (strcmp(val, "default") == 0)
+               ifr.ifr_ifru.ifru_ecn_mode = IFRTYPE_ECN_DEFAULT;
+       else if (strcmp(val, "enable") == 0)
+               ifr.ifr_ifru.ifru_ecn_mode = IFRTYPE_ECN_ENABLE;
+       else if (strcmp(val, "disable") == 0)
+               ifr.ifr_ifru.ifru_ecn_mode = IFRTYPE_ECN_DISABLE;
+       else {
+               ifr.ifr_ifru.ifru_ecn_mode = strtold(val, &cp);
+               if (val == cp || errno != 0) {
+                       warn("Invalid ECN mode value '%s'", val);
+                       return;
+               }
+       }
+       
+       strncpy(ifr.ifr_name, name, sizeof(ifr.ifr_name));
+       
+       if (ioctl(s, SIOCSECNMODE, (caddr_t)&ifr) < 0)
+               Perror("ioctl(SIOCSECNMODE)");
+}
+
+void
+setprobeconnectivity(const char *vname, int value, int s, const struct afswtch *afp)
+{
+       strlcpy(ifr.ifr_name, name, sizeof(ifr.ifr_name));
+       ifr.ifr_ifru.ifru_probe_connectivity = value;
+
+       if (ioctl(s, SIOCSIFPROBECONNECTIVITY, (caddr_t)&ifr) < 0)
+               Perror(vname);
+}
+
+#if defined(SIOCSQOSMARKINGMODE) && defined(SIOCSQOSMARKINGENABLED)
+
+void
+setqosmarking(const char *cmd, const char *arg, int s, const struct afswtch *afp)
+{
+       u_long ioc;
+
+#if (DEBUG | DEVELOPMENT)
+       printf("%s(%s, %s)\n", __func__, cmd, arg);
+#endif /* (DEBUG | DEVELOPMENT) */
+       
+       strncpy(ifr.ifr_name, name, sizeof(ifr.ifr_name));
+       
+       if (strcmp(cmd, "mode") == 0) {
+               ioc = SIOCSQOSMARKINGMODE;
+               
+               if (strcmp(arg, "fastlane") == 0)
+                       ifr.ifr_qosmarking_mode = IFRTYPE_QOSMARKING_FASTLANE;
+               else if (strcasecmp(arg, "none") == 0 || strcasecmp(arg, "off") == 0)
+                       ifr.ifr_qosmarking_mode = IFRTYPE_QOSMARKING_MODE_NONE;
+               else
+                       err(EX_USAGE, "bad value for qosmarking mode: %s", arg);
+       } else if (strcmp(cmd, "enabled") == 0) {
+               ioc = SIOCSQOSMARKINGENABLED;
+               if (strcmp(arg, "1") == 0 || strcasecmp(arg, "on") == 0||
+                   strcasecmp(arg, "yes") == 0 || strcasecmp(arg, "true") == 0)
+                       ifr.ifr_qosmarking_enabled = 1;
+               else if (strcmp(arg, "0") == 0 || strcasecmp(arg, "off") == 0||
+                        strcasecmp(arg, "no") == 0 || strcasecmp(arg, "false") == 0)
+                       ifr.ifr_qosmarking_enabled = 0;
+               else
+                       err(EX_USAGE, "bad value for qosmarking enabled: %s", arg);
+       } else {
+               err(EX_USAGE, "qosmarking takes mode or enabled");
+       }
+       
+       if (ioctl(s, ioc, (caddr_t)&ifr) < 0)
+               err(EX_OSERR, "ioctl(%s, %s)", cmd, arg);
+}
+
+void
+setfastlane(const char *cmd, const char *arg, int s, const struct afswtch *afp)
+{
+       strncpy(ifr.ifr_name, name, sizeof(ifr.ifr_name));
+       
+       warnx("### fastlane is obsolete, use qosmarking ###");
+       
+       if (strcmp(cmd, "capable") == 0) {
+               if (strcmp(arg, "1") == 0 || strcasecmp(arg, "on") == 0||
+                   strcasecmp(arg, "yes") == 0 || strcasecmp(arg, "true") == 0)
+                       setqosmarking("mode", "fastlane", s, afp);
+               else if (strcmp(arg, "0") == 0 || strcasecmp(arg, "off") == 0||
+                        strcasecmp(arg, "no") == 0 || strcasecmp(arg, "false") == 0)
+                       setqosmarking("mode", "off", s, afp);
+               else
+                       err(EX_USAGE, "bad value for fastlane %s", cmd);
+       } else if (strcmp(cmd, "enable") == 0) {
+               if (strcmp(arg, "1") == 0 || strcasecmp(arg, "on") == 0||
+                   strcasecmp(arg, "yes") == 0 || strcasecmp(arg, "true") == 0)
+                       setqosmarking("enabled", "1", s, afp);
+               else if (strcmp(arg, "0") == 0 || strcasecmp(arg, "off") == 0||
+                        strcasecmp(arg, "no") == 0 || strcasecmp(arg, "false") == 0)
+                       setqosmarking("enabled", "0", s, afp);
+               else
+                       err(EX_USAGE, "bad value for fastlane %s", cmd);
+       } else {
+               err(EX_USAGE, "fastlane takes capable or enable");
+       }
+}
+
+#else /* defined(SIOCSQOSMARKINGMODE) && defined(SIOCSQOSMARKINGENABLED) */
+
+void
+setfastlane(const char *cmd, const char *arg, int s, const struct afswtch *afp)
+{
+       int value;
+       u_long ioc;
+       
+       strncpy(ifr.ifr_name, name, sizeof(ifr.ifr_name));
+       
+       if (strcmp(cmd, "capable") == 0)
+               ioc = SIOCSFASTLANECAPABLE;
+       else if (strcmp(cmd, "enable") == 0)
+               ioc = SIOCSFASTLEENABLED;
+       else
+               err(EX_USAGE, "fastlane takes capable or enabled");
+       
+       if (strcmp(arg, "1") == 0 || strcasecmp(arg, "on") == 0||
+           strcasecmp(arg, "yes") == 0 || strcasecmp(arg, "true") == 0)
+               value = 1;
+       else if (strcmp(arg, "0") == 0 || strcasecmp(arg, "off") == 0||
+                strcasecmp(arg, "no") == 0 || strcasecmp(arg, "false") == 0)
+               value = 0;
+       else
+               err(EX_USAGE, "bad value for fastlane %s", cmd);
+       
+       if (ioc == SIOCSFASTLANECAPABLE)
+               ifr.ifr_fastlane_capable = value;
+       else
+               ifr.ifr_fastlane_enabled = value;
+       
+       if (ioctl(s, ioc, (caddr_t)&ifr) < 0)
+               err(EX_OSERR, "ioctl(%s, %s)", cmd, arg);
+}
+
+
+void
+setqosmarking(const char *cmd, const char *arg, int s, const struct afswtch *afp)
+{
+       if (strcmp(cmd, "mode") == 0) {
+               if (strcmp(arg, "fastlane") == 0)
+                       setfastlane("capable", "on", s, afp);
+               else if (strcmp(arg, "none") == 0)
+                       setfastlane("capable", "off", s, afp);
+               else
+                       err(EX_USAGE, "bad value for qosmarking mode: %s", arg);
+       } else if (strcmp(cmd, "enabled") == 0) {
+               if (strcmp(arg, "1") == 0 || strcasecmp(arg, "on") == 0||
+                   strcasecmp(arg, "yes") == 0 || strcasecmp(arg, "true") == 0)
+                       setfastlane("enable", "on", s, afp);
+               else if (strcmp(arg, "0") == 0 || strcasecmp(arg, "off") == 0||
+                        strcasecmp(arg, "no") == 0 || strcasecmp(arg, "false") == 0)
+                       setfastlane("enable", "off", s, afp);
+               else
+                       err(EX_USAGE, "bad value for qosmarking enabled: %s", arg);
+       } else {
+               err(EX_USAGE, "qosmarking takes mode or enabled");
+       }
+}
+
+#endif /* defined(SIOCSQOSMARKINGMODE) && defined(SIOCSQOSMARKINGENABLED) */
+
+void
+setlowpowermode(const char *vname, int value, int s, const struct afswtch *afp)
+{
+       strlcpy(ifr.ifr_name, name, sizeof(ifr.ifr_name));
+       ifr.ifr_low_power_mode = !!value;
+
+       if (ioctl(s, SIOCSIFLOWPOWER, (caddr_t)&ifr) < 0)
+               Perror(vname);
+}
+
 #define        IFFBITS \
 "\020\1UP\2BROADCAST\3DEBUG\4LOOPBACK\5POINTOPOINT\6SMART\7RUNNING" \
 "\10NOARP\11PROMISC\12ALLMULTI\13OACTIVE\14SIMPLEX\15LINK0\16LINK1\17LINK2" \
 "\20MULTICAST"
 
 #define        IFEFBITS \
-"\020\1AUTOCONFIGURING\6IPV6_DISABLED\7ACCEPT_RTADV\10TXSTART\11RXPOLL" \
-"\12VLAN\13BOND\14ARPLL\15NOWINDOWSCALE\16NOAUTOIPV6LL\20ROUTER4\21ROUTER6" \
-"\22LOCALNET_PRIVATE\23ND6ALT\24RESTRICTED_RECV\25AWDL\26NOACKPRI\35SENDLIST" \
-"\36DIRECTLINK"
+"\020\1AUTOCONFIGURING\4PROBE_CONNECTIVITY\5FASTLN_CAP\6IPV6_DISABLED\7ACCEPT_RTADV\10TXSTART\11RXPOLL" \
+"\12VLAN\13BOND\14ARPLL\15CLAT46\16NOAUTOIPV6LL\17EXPENSIVE\20ROUTER4" \
+"\21ROUTER6\22LOCALNET_PRIVATE\23ND6ALT\24RESTRICTED_RECV\25AWDL\26NOACKPRI" \
+"\27AWDL_RESTRICTED\30CL2K\31ECN_ENABLE\32ECN_DISABLE\33CHANNEL_DRV\34CA" \
+"\35SENDLIST\36DIRECTLINK\37FASTLN_ON\40UPDOWNCHANGE"
 
 #define        IFCAPBITS \
 "\020\1RXCSUM\2TXCSUM\3VLAN_MTU\4VLAN_HWTAGGING\5JUMBO_MTU" \
-"\6TSO4\7TSO6\10LRO\11AV\12TXSTATUS"
+"\6TSO4\7TSO6\10LRO\11AV\12TXSTATUS\13CHANNEL_IO\14HW_TIMESTAMP\15SW_TIMESTAMP" \
+"\16PARTIAL_CSUM\17ZEROINVERT_CSUM"
 
 #define        IFRLOGF_BITS \
 "\020\1DLIL\21FAMILY\31DRIVER\35FIRMWARE"
@@ -1006,7 +1239,8 @@ status(const struct afswtch *afp, const struct sockaddr_dl *sdl,
        struct ifmibdata_supplemental ifmsupp;
        size_t miblen = sizeof(struct ifmibdata_supplemental);
        u_int64_t eflags = 0;
-
+       int curcap = 0;
+       
        if (afp == NULL) {
                allfamilies = 1;
                afp = af_getbyname("inet");
@@ -1029,11 +1263,11 @@ status(const struct afswtch *afp, const struct sockaddr_dl *sdl,
                printf(" mtu %d", ifr.ifr_mtu);
        if (showrtref && ioctl(s, SIOCGIFGETRTREFCNT, &ifr) != -1)
                printf(" rtref %d", ifr.ifr_route_refcnt);
-    if (verbose) {
-        unsigned int ifindex = if_nametoindex(ifa->ifa_name);
-        if (ifindex != 0)
-            printf(" index %u", ifindex);
-    }
+       if (verbose) {
+               unsigned int ifindex = if_nametoindex(ifa->ifa_name);
+               if (ifindex != 0)
+                       printf(" index %u", ifindex);
+       }
        putchar('\n');
 
        if (verbose && ioctl(s, SIOCGIFEFLAGS, (caddr_t)&ifr) != -1 &&
@@ -1042,9 +1276,9 @@ status(const struct afswtch *afp, const struct sockaddr_dl *sdl,
                putchar('\n');
        }
 
-#ifdef SIOCGIFCAP      
        if (ioctl(s, SIOCGIFCAP, (caddr_t)&ifr) == 0) {
                if (ifr.ifr_curcap != 0) {
+                       curcap = ifr.ifr_curcap;
                        printb("\toptions", ifr.ifr_curcap, IFCAPBITS);
                        putchar('\n');
                }
@@ -1053,7 +1287,6 @@ status(const struct afswtch *afp, const struct sockaddr_dl *sdl,
                        putchar('\n');
                }
        }
-#endif
        
        tunnel_status(s);
 
@@ -1070,6 +1303,13 @@ status(const struct afswtch *afp, const struct sockaddr_dl *sdl,
                } else if (afp->af_af == ift->ifa_addr->sa_family)
                        afp->af_status(s, ift);
        }
+
+/* Print CLAT46 address */
+       clat46_addr(s, name);
+
+/* Print NAT64 prefix */
+       nat64_status(s, name);
+
 #if 0
        if (allfamilies || afp->af_af == AF_LINK) {
                const struct afswtch *lafp;
@@ -1107,16 +1347,49 @@ status(const struct afswtch *afp, const struct sockaddr_dl *sdl,
                        printf("\ttype: %s\n", c);
        }
 
+       if (verbose > 0) {
+               struct if_agentidsreq ifar;
+               memset(&ifar, 0, sizeof(ifar));
+
+               strlcpy(ifar.ifar_name, name, sizeof(ifar.ifar_name));
+
+               if (ioctl(s, SIOCGIFAGENTIDS, &ifar) != -1) {
+                       if (ifar.ifar_count != 0) {
+                               ifar.ifar_uuids = calloc(ifar.ifar_count, sizeof(uuid_t));
+                               if (ifar.ifar_uuids != NULL) {
+                                       if (ioctl(s, SIOCGIFAGENTIDS, &ifar) != 1) {
+                                               for (int agent_i = 0; agent_i < ifar.ifar_count; agent_i++) {
+                                                       struct netagent_req nar;
+                                                       memset(&nar, 0, sizeof(nar));
+
+                                                       uuid_copy(nar.netagent_uuid, ifar.ifar_uuids[agent_i]);
+
+                                                       if (ioctl(s, SIOCGIFAGENTDATA, &nar) != 1) {
+                                                               printf("\tagent domain:%s type:%s flags:0x%x desc:\"%s\"\n",
+                                                                          nar.netagent_domain, nar.netagent_type,
+                                                                          nar.netagent_flags, nar.netagent_desc);
+                                                       }
+                                               }
+                                       }
+                                       free(ifar.ifar_uuids);
+                               }
+                       }
+               }
+       }
+
        if (ioctl(s, SIOCGIFLINKQUALITYMETRIC, &ifr) != -1) {
                int lqm = ifr.ifr_link_quality_metric;
                if (verbose > 1) {
                        printf("\tlink quality: %d ", lqm);
-                       if (lqm == IFNET_LQM_THRESH_OFF) {
+                       if (lqm == IFNET_LQM_THRESH_OFF)
                                printf("(off)");
-                       } else if (lqm == IFNET_LQM_THRESH_UNKNOWN) {
+                       else if (lqm == IFNET_LQM_THRESH_UNKNOWN)
                                printf("(unknown)");
-                       } else if (lqm > IFNET_LQM_THRESH_UNKNOWN &&
-                           lqm <= IFNET_LQM_THRESH_POOR)
+                       else if (lqm > IFNET_LQM_THRESH_UNKNOWN &&
+                                lqm <= IFNET_LQM_THRESH_BAD)
+                               printf("(bad)");
+                       else if (lqm > IFNET_LQM_THRESH_UNKNOWN &&
+                                lqm <= IFNET_LQM_THRESH_POOR)
                                printf("(poor)");
                        else if (lqm > IFNET_LQM_THRESH_POOR &&
                            lqm <= IFNET_LQM_THRESH_GOOD)
@@ -1126,10 +1399,11 @@ status(const struct afswtch *afp, const struct sockaddr_dl *sdl,
                        printf("\n");
                } else if (lqm > IFNET_LQM_THRESH_UNKNOWN) {
                        printf("\tlink quality: %d ", lqm);
-                       if (lqm <= IFNET_LQM_THRESH_POOR)
+                       if (lqm <= IFNET_LQM_THRESH_BAD)
+                               printf("(bad)");
+                       else if (lqm <= IFNET_LQM_THRESH_POOR)
                                printf("(poor)");
-                       else if (lqm > IFNET_LQM_THRESH_POOR &&
-                           lqm <= IFNET_LQM_THRESH_GOOD)
+                       else if (lqm <= IFNET_LQM_THRESH_GOOD)
                                printf("(good)");
                        else
                                printf("(?)");
@@ -1137,6 +1411,59 @@ status(const struct afswtch *afp, const struct sockaddr_dl *sdl,
                }
        }
 
+       if (verbose > 0) {
+               if (ioctl(s, SIOCGIFINTERFACESTATE, &ifr) != -1) {
+                       printf("\tstate");
+                       if (ifr.ifr_interface_state.valid_bitmask &
+                           IF_INTERFACE_STATE_RRC_STATE_VALID) {
+                               uint8_t rrc_state = ifr.ifr_interface_state.rrc_state;
+                               
+                               printf(" rrc: %u ", rrc_state);
+                               if (rrc_state == IF_INTERFACE_STATE_RRC_STATE_CONNECTED)
+                                       printf("(connected)");
+                               else if (rrc_state == IF_INTERFACE_STATE_RRC_STATE_IDLE)
+                                       printf("(idle)");
+                               else
+                                       printf("(?)");
+                       }
+                       if (ifr.ifr_interface_state.valid_bitmask &
+                           IF_INTERFACE_STATE_INTERFACE_AVAILABILITY_VALID) {
+                               uint8_t ifavail = ifr.ifr_interface_state.interface_availability;
+                               
+                               printf(" availability: %u ", ifavail);
+                               if (ifavail == IF_INTERFACE_STATE_INTERFACE_AVAILABLE)
+                                       printf("(true)");
+                               else if (ifavail == IF_INTERFACE_STATE_INTERFACE_UNAVAILABLE)
+                                       printf("(false)");
+                               else
+                                       printf("(?)");
+                       } else {
+                               printf(" availability: (not valid)");
+                       }
+                       if (verbose > 1 &&
+                           ifr.ifr_interface_state.valid_bitmask &
+                           IF_INTERFACE_STATE_LQM_STATE_VALID) {
+                               int8_t lqm = ifr.ifr_interface_state.lqm_state;
+                               
+                               printf(" lqm: %d", lqm);
+                               
+                               if (lqm == IFNET_LQM_THRESH_OFF)
+                                       printf("(off)");
+                               else if (lqm == IFNET_LQM_THRESH_UNKNOWN)
+                                       printf("(unknown)");
+                               else if (lqm == IFNET_LQM_THRESH_BAD)
+                                       printf("(bad)");
+                               else if (lqm == IFNET_LQM_THRESH_POOR)
+                                       printf("(poor)");
+                               else if (lqm == IFNET_LQM_THRESH_GOOD)
+                                       printf("(good)");
+                               else
+                                       printf("(?)");
+                       }
+               }
+               printf("\n");
+       }
+       
        bzero(&iflpr, sizeof (iflpr));
        strncpy(iflpr.iflpr_name, name, sizeof (iflpr.iflpr_name));
        if (ioctl(s, SIOCGIFLINKPARAMS, &iflpr) != -1) {
@@ -1277,6 +1604,46 @@ status(const struct afswtch *afp, const struct sockaddr_dl *sdl,
                        printf("\teffective interface: %s\n", delegatedif);
        }
 
+       if (ioctl(s, SIOCGSTARTDELAY, &ifr) != -1) {
+               if (ifr.ifr_start_delay_qlen > 0 &&
+                   ifr.ifr_start_delay_timeout > 0) {
+                       printf("\ttxstart qlen: %u packets "
+                           "timeout: %u microseconds\n",
+                           ifr.ifr_start_delay_qlen,
+                           ifr.ifr_start_delay_timeout/1000);
+               }
+       }
+#if defined(IFCAP_HW_TIMESTAMP) && defined(IFCAP_SW_TIMESTAMP)
+       if ((curcap & (IFCAP_HW_TIMESTAMP | IFCAP_SW_TIMESTAMP)) &&
+           ioctl(s, SIOCGIFTIMESTAMPENABLED, &ifr) != -1) {
+               printf("\ttimestamp: %s\n",
+                      (ifr.ifr_intval != 0) ? "enabled" : "disabled");
+       }
+#endif
+#if defined(SIOCGQOSMARKINGENABLED) && defined(SIOCGQOSMARKINGMODE)
+       if (ioctl(s, SIOCGQOSMARKINGENABLED, &ifr) != -1) {
+               printf("\tqosmarking enabled: %s mode: ",
+                      ifr.ifr_qosmarking_enabled ? "yes" : "no");
+               if (ioctl(s, SIOCGQOSMARKINGMODE, &ifr) != -1) {
+                       switch (ifr.ifr_qosmarking_mode) {
+                               case IFRTYPE_QOSMARKING_FASTLANE:
+                                       printf("fastlane\n");
+                                       break;
+                               case IFRTYPE_QOSMARKING_MODE_NONE:
+                                       printf("none\n");
+                                       break;
+                               default:
+                                       printf("unknown (%u)\n", ifr.ifr_qosmarking_mode);
+                                       break;
+                       }
+               }
+       }
+#endif /* defined(SIOCGQOSMARKINGENABLED) && defined(SIOCGQOSMARKINGMODE) */
+
+       if (verbose > 0 && ioctl(s, SIOCGIFLOWPOWER, &ifr) != -1) {
+               printf("\tlow power mode: %s\n",
+                      (ifr.ifr_low_power_mode != 0) ? "enabled" : "disabled");
+       }
 done:
        close(s);
        return;
@@ -1375,6 +1742,51 @@ tunnel_status(int s)
        af_all_tunnel_status(s);
 }
 
+static void
+clat46_addr(int s, char * if_name)
+{
+       struct if_clat46req ifr;
+       char buf[MAXHOSTNAMELEN];
+
+       bzero(&ifr, sizeof (ifr));
+       strlcpy(ifr.ifclat46_name, if_name, sizeof(ifr.ifclat46_name));
+
+       if (ioctl(s, SIOCGIFCLAT46ADDR, &ifr) < 0) {
+               if (errno != ENOENT)
+                       syslog(LOG_WARNING, "ioctl (SIOCGIFCLAT46ADDR): %d", errno);
+               return;
+       }
+
+       if (inet_ntop(AF_INET6, &ifr.ifclat46_addr.v6_address, buf, sizeof(buf)) != NULL)
+               printf("\tinet6 %s prefixlen %d clat46\n",
+                       buf, ifr.ifclat46_addr.v6_prefixlen);
+}
+
+static void
+nat64_status(int s, char * if_name)
+{
+       int i;
+       struct if_nat64req ifr;
+       char buf[MAXHOSTNAMELEN];
+
+       bzero(&ifr, sizeof(ifr));
+       strlcpy(ifr.ifnat64_name, if_name, sizeof(ifr.ifnat64_name));
+
+       if (ioctl(s, SIOCGIFNAT64PREFIX, &ifr) < 0) {
+               if (errno != ENOENT)
+                       syslog(LOG_WARNING, "ioctl(SIOCGIFNAT64PREFIX): %d", errno);
+               return;
+       }
+
+       for (i = 0; i < NAT64_MAX_NUM_PREFIXES; i++) {
+               if (ifr.ifnat64_prefixes[i].prefix_len > 0) {
+                       inet_ntop(AF_INET6, &ifr.ifnat64_prefixes[i].ipv6_prefix, buf, sizeof(buf));
+                       printf("\tnat64 prefix %s prefixlen %d\n",
+                           buf, ifr.ifnat64_prefixes[i].prefix_len << 3);
+               }
+       }
+}
+
 void
 Perror(const char *cmd)
 {
@@ -1576,6 +1988,20 @@ static struct cmd basic_cmds[] = {
        DEF_CMD_ARG("tbr",                      settbr),
        DEF_CMD_ARG("throttle",                 setthrottle),
        DEF_CMD_ARG("log",                      setlog),
+       DEF_CMD("cl2k", 1,                      setcl2k),
+       DEF_CMD("-cl2k",        0,              setcl2k),
+       DEF_CMD("expensive",    1,              setexpensive),
+       DEF_CMD("-expensive",   0,              setexpensive),
+       DEF_CMD("timestamp",    1,              settimestamp),
+       DEF_CMD("-timestamp",   0,              settimestamp),
+       DEF_CMD_ARG("ecn",                      setecnmode),
+       DEF_CMD_ARG2("fastlane",                setfastlane),
+       DEF_CMD_ARG2("qosmarking",              setqosmarking),
+       DEF_CMD_ARG("disable_output",           setdisableoutput),
+       DEF_CMD("probe_connectivity",   1,              setprobeconnectivity),
+       DEF_CMD("-probe_connectivity",  0,              setprobeconnectivity),
+       DEF_CMD("lowpowermode", 1,              setlowpowermode),
+       DEF_CMD("-lowpowermode",        0,      setlowpowermode),
 };
 
 static __constructor void
@@ -1598,24 +2024,15 @@ sched2str(unsigned int s)
        case PKTSCHEDT_NONE:
                c = "NONE";
                break;
-       case PKTSCHEDT_CBQ:
-               c = "CBQ";
-               break;
-       case PKTSCHEDT_HFSC:
-               c = "HFSC";
-               break;
-       case PKTSCHEDT_PRIQ:
-               c = "PRIQ";
-               break;
-       case PKTSCHEDT_FAIRQ:
-               c = "FAIRQ";
-               break;
        case PKTSCHEDT_TCQ:
                c = "TCQ";
                break;
        case PKTSCHEDT_QFQ:
                c = "QFQ";
                break;
+       case PKTSCHEDT_FQ_CODEL:
+               c = "FQ_CODEL";
+               break;
        default:
                c = "UNKNOWN";
                break;