+static struct cmd basic_cmds[] = {
+ DEF_CMD("up", IFF_UP, setifflags),
+ DEF_CMD("down", -IFF_UP, setifflags),
+ DEF_CMD("arp", -IFF_NOARP, setifflags),
+ DEF_CMD("-arp", IFF_NOARP, setifflags),
+ DEF_CMD("debug", IFF_DEBUG, setifflags),
+ DEF_CMD("-debug", -IFF_DEBUG, setifflags),
+#ifdef IFF_PPROMISC
+ DEF_CMD("promisc", IFF_PPROMISC, setifflags),
+ DEF_CMD("-promisc", -IFF_PPROMISC, setifflags),
+#endif /* IFF_PPROMISC */
+ DEF_CMD("add", IFF_UP, notealias),
+ DEF_CMD("alias", IFF_UP, notealias),
+ DEF_CMD("-alias", -IFF_UP, notealias),
+ DEF_CMD("delete", -IFF_UP, notealias),
+ DEF_CMD("remove", -IFF_UP, notealias),
+#ifdef notdef
+#define EN_SWABIPS 0x1000
+ DEF_CMD("swabips", EN_SWABIPS, setifflags),
+ DEF_CMD("-swabips", -EN_SWABIPS, setifflags),
+#endif
+ DEF_CMD_ARG("netmask", setifnetmask),
+ DEF_CMD_ARG("metric", setifmetric),
+ DEF_CMD_ARG("broadcast", setifbroadaddr),
+ DEF_CMD_ARG("ipdst", setifipdst),
+ DEF_CMD_ARG2("tunnel", settunnel),
+ DEF_CMD("-tunnel", 0, deletetunnel),
+ DEF_CMD("deletetunnel", 0, deletetunnel),
+ DEF_CMD("link0", IFF_LINK0, setifflags),
+ DEF_CMD("-link0", -IFF_LINK0, setifflags),
+ DEF_CMD("link1", IFF_LINK1, setifflags),
+ DEF_CMD("-link1", -IFF_LINK1, setifflags),
+ DEF_CMD("link2", IFF_LINK2, setifflags),
+ DEF_CMD("-link2", -IFF_LINK2, setifflags),
+#ifdef IFF_MONITOR
+ DEF_CMD("monitor", IFF_MONITOR:, setifflags),
+ DEF_CMD("-monitor", -IFF_MONITOR, setifflags),
+#endif /* IFF_MONITOR */
+#ifdef IFF_STATICARP
+ DEF_CMD("staticarp", IFF_STATICARP, setifflags),
+ DEF_CMD("-staticarp", -IFF_STATICARP, setifflags),
+#endif /* IFF_STATICARP */
+#ifdef IFCAP_RXCSUM
+ DEF_CMD("rxcsum", IFCAP_RXCSUM, setifcap),
+ DEF_CMD("-rxcsum", -IFCAP_RXCSUM, setifcap),
+#endif /* IFCAP_RXCSUM */
+#ifdef IFCAP_TXCSUM
+ DEF_CMD("txcsum", IFCAP_TXCSUM, setifcap),
+ DEF_CMD("-txcsum", -IFCAP_TXCSUM, setifcap),
+#endif /* IFCAP_TXCSUM */
+#ifdef IFCAP_NETCONS
+ DEF_CMD("netcons", IFCAP_NETCONS, setifcap),
+ DEF_CMD("-netcons", -IFCAP_NETCONS, setifcap),
+#endif /* IFCAP_NETCONS */
+#ifdef IFCAP_POLLING
+ DEF_CMD("polling", IFCAP_POLLING, setifcap),
+ DEF_CMD("-polling", -IFCAP_POLLING, setifcap),
+#endif /* IFCAP_POLLING */
+#ifdef IFCAP_TSO
+ DEF_CMD("tso", IFCAP_TSO, setifcap),
+ DEF_CMD("-tso", -IFCAP_TSO, setifcap),
+#endif /* IFCAP_TSO */
+#ifdef IFCAP_LRO
+ DEF_CMD("lro", IFCAP_LRO, setifcap),
+ DEF_CMD("-lro", -IFCAP_LRO, setifcap),
+#endif /* IFCAP_LRO */
+#ifdef IFCAP_WOL
+ DEF_CMD("wol", IFCAP_WOL, setifcap),
+ DEF_CMD("-wol", -IFCAP_WOL, setifcap),
+#endif /* IFCAP_WOL */
+#ifdef IFCAP_WOL_UCAST
+ DEF_CMD("wol_ucast", IFCAP_WOL_UCAST, setifcap),
+ DEF_CMD("-wol_ucast", -IFCAP_WOL_UCAST, setifcap),
+#endif /* IFCAP_WOL_UCAST */
+#ifdef IFCAP_WOL_MCAST
+ DEF_CMD("wol_mcast", IFCAP_WOL_MCAST, setifcap),
+ DEF_CMD("-wol_mcast", -IFCAP_WOL_MCAST, setifcap),
+#endif /* IFCAP_WOL_MCAST */
+#ifdef IFCAP_WOL_MAGIC
+ DEF_CMD("wol_magic", IFCAP_WOL_MAGIC, setifcap),
+ DEF_CMD("-wol_magic", -IFCAP_WOL_MAGIC, setifcap),
+#endif /* IFCAP_WOL_MAGIC */
+ DEF_CMD("normal", -IFF_LINK0, setifflags),
+ DEF_CMD("compress", IFF_LINK0, setifflags),
+ DEF_CMD("noicmp", IFF_LINK1, setifflags),
+ DEF_CMD_ARG("mtu", setifmtu),
+#ifdef notdef
+ DEF_CMD_ARG("name", setifname),
+#endif /* notdef */
+#ifdef IFCAP_AV
+ DEF_CMD("av", IFCAP_AV, setifcap),
+ DEF_CMD("-av", -IFCAP_AV, setifcap),
+#endif /* IFCAP_AV */
+ DEF_CMD("router", 1, setrouter),
+ DEF_CMD("-router", 0, setrouter),
+ DEF_CMD_ARG("desc", setifdesc),
+ 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_ARG("ecn", setecnmode),
+};
+
+static __constructor void
+ifconfig_ctor(void)
+{
+#define N(a) (sizeof(a) / sizeof(a[0]))
+ int i;
+
+ for (i = 0; i < N(basic_cmds); i++)
+ cmd_register(&basic_cmds[i]);
+#undef N
+}
+
+static char *
+sched2str(unsigned int s)
+{
+ char *c;
+
+ switch (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;
+ default:
+ c = "UNKNOWN";
+ break;
+ }
+
+ return (c);
+}
+
+static char *
+tl2str(unsigned int s)
+{
+ char *c;
+
+ switch (s) {
+ case IFNET_THROTTLE_OFF:
+ c = "off";
+ break;
+ case IFNET_THROTTLE_OPPORTUNISTIC:
+ c = "opportunistic";
+ break;
+ default:
+ c = "unknown";
+ break;
+ }
+
+ return (c);
+}
+
+static char *
+ift2str(unsigned int t, unsigned int f, unsigned int sf)
+{
+ static char buf[256];
+ char *c = NULL;
+
+ switch (t) {
+ case IFT_ETHER:
+ switch (sf) {
+ case IFRTYPE_SUBFAMILY_USB:
+ c = "USB Ethernet";
+ break;
+ case IFRTYPE_SUBFAMILY_BLUETOOTH:
+ c = "Bluetooth PAN";
+ break;
+ case IFRTYPE_SUBFAMILY_WIFI:
+ c = "Wi-Fi";
+ break;
+ case IFRTYPE_SUBFAMILY_THUNDERBOLT:
+ c = "IP over Thunderbolt";
+ break;
+ case IFRTYPE_SUBFAMILY_ANY:
+ default:
+ c = "Ethernet";
+ break;
+ }
+ break;
+
+ case IFT_IEEE1394:
+ c = "IP over FireWire";
+ break;
+
+ case IFT_PKTAP:
+ c = "Packet capture";
+ break;
+
+ case IFT_CELLULAR:
+ c = "Cellular";
+ break;
+
+ case IFT_BRIDGE:
+ case IFT_PFLOG:
+ case IFT_PFSYNC:
+ case IFT_OTHER:
+ case IFT_PPP:
+ case IFT_LOOP:
+ case IFT_GIF:
+ case IFT_STF:
+ case IFT_L2VLAN:
+ case IFT_IEEE8023ADLAG:
+ default:
+ break;
+ }
+
+ if (verbose > 1) {
+ if (c == NULL) {
+ (void) snprintf(buf, sizeof (buf),
+ "0x%x family: %u subfamily: %u",
+ ifr.ifr_type.ift_type, ifr.ifr_type.ift_family,
+ ifr.ifr_type.ift_subfamily);
+ } else {
+ (void) snprintf(buf, sizeof (buf),
+ "%s (0x%x) family: %u subfamily: %u", c,
+ ifr.ifr_type.ift_type, ifr.ifr_type.ift_family,
+ ifr.ifr_type.ift_subfamily);
+ }
+ c = buf;
+ }
+
+ return (c);
+}