From f35b9d165f39f5a138d16c9ef2a664709b5c2c66 Mon Sep 17 00:00:00 2001 From: Jonathan Lemon Date: Tue, 18 Sep 2001 17:43:30 +0000 Subject: [PATCH] Teach ifconfig about the new interface capability words. --- sbin/ifconfig/ifconfig.c | 44 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/sbin/ifconfig/ifconfig.c b/sbin/ifconfig/ifconfig.c index f28ac44da384..f04d4f8a8f55 100644 --- a/sbin/ifconfig/ifconfig.c +++ b/sbin/ifconfig/ifconfig.c @@ -179,7 +179,7 @@ c_func setip6vltime; c_func2 setip6lifetime; #endif c_func setifipdst; -c_func setifflags, setifmetric, setifmtu, setiflladdr; +c_func setifflags, setifmetric, setifmtu, setiflladdr, setifcap; c_func clone_destroy; @@ -274,6 +274,10 @@ struct cmd { { "nwkey", NEXTARG, set80211nwkey }, /* NetBSD */ { "-nwkey", 0, set80211wep }, /* NetBSD */ #endif + { "hwcsum", IFCAP_HWCSUM, setifcap }, + { "-hwcsum", -IFCAP_HWCSUM, setifcap }, + { "netcons", IFCAP_NETCONS, setifcap }, + { "-netcons", -IFCAP_NETCONS, setifcap }, { "normal", -IFF_LINK0, setifflags }, { "compress", IFF_LINK0, setifflags }, { "noicmp", IFF_LINK1, setifflags }, @@ -1033,6 +1037,29 @@ setifflags(vname, value, s, afp) Perror(vname); } +void +setifcap(vname, value, s, afp) + const char *vname; + int value; + int s; + const struct afswtch *afp; +{ + + if (ioctl(s, SIOCGIFCAP, (caddr_t)&ifr) < 0) { + Perror("ioctl (SIOCGIFCAP)"); + exit(1); + } + flags = ifr.ifr_curcap; + if (value < 0) { + value = -value; + flags &= ~value; + } else + flags |= value; + ifr.ifr_reqcap = flags; + if (ioctl(s, SIOCSIFCAP, (caddr_t)&ifr) < 0) + Perror(vname); +} + void setifmetric(val, dummy, s, afp) const char *val; @@ -1088,6 +1115,9 @@ setiflladdr(val, dummy, s, afp) "\10NOARP\11PROMISC\12ALLMULTI\13OACTIVE\14SIMPLEX\15LINK0\16LINK1\17LINK2" \ "\20MULTICAST" +#define IFCAPBITS \ +"\002\1hwcsum\2netcons" + /* * Print the status of the interface. If an address family was * specified, show it and it only; otherwise, show them all. @@ -1141,6 +1171,18 @@ status(afp, addrcount, sdl, ifm, ifam) printf(" mtu %d", mtu); putchar('\n'); + if (ioctl(s, SIOCGIFCAP, (caddr_t)&ifr) == 0) { + if (ifr.ifr_curcap != 0) { + printb("\toptions", ifr.ifr_curcap, IFCAPBITS); + putchar('\n'); + } + if (supmedia && ifr.ifr_reqcap != 0) { + printf("\tcapability list:\n"); + printb("\t\t", ifr.ifr_reqcap, IFCAPBITS); + putchar('\n'); + } + } + tunnel_status(s); while (addrcount > 0) {