Teach ifconfig about the new interface capability words.

This commit is contained in:
Jonathan Lemon 2001-09-18 17:43:30 +00:00
parent e20e8e6d84
commit f35b9d165f

View File

@ -179,7 +179,7 @@ c_func setip6vltime;
c_func2 setip6lifetime; c_func2 setip6lifetime;
#endif #endif
c_func setifipdst; c_func setifipdst;
c_func setifflags, setifmetric, setifmtu, setiflladdr; c_func setifflags, setifmetric, setifmtu, setiflladdr, setifcap;
c_func clone_destroy; c_func clone_destroy;
@ -274,6 +274,10 @@ struct cmd {
{ "nwkey", NEXTARG, set80211nwkey }, /* NetBSD */ { "nwkey", NEXTARG, set80211nwkey }, /* NetBSD */
{ "-nwkey", 0, set80211wep }, /* NetBSD */ { "-nwkey", 0, set80211wep }, /* NetBSD */
#endif #endif
{ "hwcsum", IFCAP_HWCSUM, setifcap },
{ "-hwcsum", -IFCAP_HWCSUM, setifcap },
{ "netcons", IFCAP_NETCONS, setifcap },
{ "-netcons", -IFCAP_NETCONS, setifcap },
{ "normal", -IFF_LINK0, setifflags }, { "normal", -IFF_LINK0, setifflags },
{ "compress", IFF_LINK0, setifflags }, { "compress", IFF_LINK0, setifflags },
{ "noicmp", IFF_LINK1, setifflags }, { "noicmp", IFF_LINK1, setifflags },
@ -1033,6 +1037,29 @@ setifflags(vname, value, s, afp)
Perror(vname); 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 void
setifmetric(val, dummy, s, afp) setifmetric(val, dummy, s, afp)
const char *val; const char *val;
@ -1088,6 +1115,9 @@ setiflladdr(val, dummy, s, afp)
"\10NOARP\11PROMISC\12ALLMULTI\13OACTIVE\14SIMPLEX\15LINK0\16LINK1\17LINK2" \ "\10NOARP\11PROMISC\12ALLMULTI\13OACTIVE\14SIMPLEX\15LINK0\16LINK1\17LINK2" \
"\20MULTICAST" "\20MULTICAST"
#define IFCAPBITS \
"\002\1hwcsum\2netcons"
/* /*
* Print the status of the interface. If an address family was * Print the status of the interface. If an address family was
* specified, show it and it only; otherwise, show them all. * specified, show it and it only; otherwise, show them all.
@ -1141,6 +1171,18 @@ status(afp, addrcount, sdl, ifm, ifam)
printf(" mtu %d", mtu); printf(" mtu %d", mtu);
putchar('\n'); 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); tunnel_status(s);
while (addrcount > 0) { while (addrcount > 0) {