diff options
author | Christiano F. Haesbaert <haesbaert@cvs.openbsd.org> | 2011-11-02 02:03:48 +0000 |
---|---|---|
committer | Christiano F. Haesbaert <haesbaert@cvs.openbsd.org> | 2011-11-02 02:03:48 +0000 |
commit | aa90c31e9bb7b52921496766edc083f5cb15c6df (patch) | |
tree | dffdd51ee2dee45ab0d78a990a5aa9476b9a551b /sbin | |
parent | 502d09447316d90435e67ad00c1656165c581cc7 (diff) |
Expose if_capabilities to userland so that ifconfig can display the
device hardware features.
Tune ifconfig to show them with 'hwfeatures' argument.
While here, kill some old unused capabilities and respect 80 columns
in brconfig.h.
ok mcbride@, henning@, mpf@.
Diffstat (limited to 'sbin')
-rw-r--r-- | sbin/ifconfig/brconfig.h | 11 | ||||
-rw-r--r-- | sbin/ifconfig/ifconfig.8 | 6 | ||||
-rw-r--r-- | sbin/ifconfig/ifconfig.c | 33 |
3 files changed, 42 insertions, 8 deletions
diff --git a/sbin/ifconfig/brconfig.h b/sbin/ifconfig/brconfig.h index 8d3471686a6..81728b5012f 100644 --- a/sbin/ifconfig/brconfig.h +++ b/sbin/ifconfig/brconfig.h @@ -1,4 +1,4 @@ -/* $OpenBSD: brconfig.h,v 1.4 2011/03/13 15:31:41 stsp Exp $ */ +/* $OpenBSD: brconfig.h,v 1.5 2011/11/02 02:03:47 haesbaert Exp $ */ /* * Copyright (c) 2009 Claudio Jeker <claudio@openbsd.org> @@ -65,10 +65,11 @@ int is_bridge(char *); void bridge_status(void); int bridge_rule(int, char **, int); - -#define IFFBITS \ -"\024\1UP\2BROADCAST\3DEBUG\4LOOPBACK\5POINTOPOINT\6NOTRAILERS\7RUNNING\10NOARP\ -\11PROMISC\12ALLMULTI\13OACTIVE\14SIMPLEX\15LINK0\16LINK1\17LINK2\20MULTICAST\21TXREADY\22NOINET6\23INET6_PRIVACY\24MPLS\25WOL" +#define IFFBITS \ + "\024\1UP\2BROADCAST\3DEBUG\4LOOPBACK\5POINTOPOINT\6NOTRAILERS" \ + "\7RUNNING\10NOARP\11PROMISC\12ALLMULTI\13OACTIVE\14SIMPLEX" \ + "\15LINK0\16LINK1\17LINK2\20MULTICAST\21TXREADY\22NOINET6" \ + "\23INET6_PRIVACY\24MPLS\25WOL" void printb(char *, unsigned int, char *); diff --git a/sbin/ifconfig/ifconfig.8 b/sbin/ifconfig/ifconfig.8 index 751a788ab0b..b1975562589 100644 --- a/sbin/ifconfig/ifconfig.8 +++ b/sbin/ifconfig/ifconfig.8 @@ -1,4 +1,4 @@ -.\" $OpenBSD: ifconfig.8,v 1.220 2011/10/25 11:39:07 jmc Exp $ +.\" $OpenBSD: ifconfig.8,v 1.221 2011/11/02 02:03:47 haesbaert Exp $ .\" $NetBSD: ifconfig.8,v 1.11 1996/01/04 21:27:29 pk Exp $ .\" $FreeBSD: ifconfig.8,v 1.16 1998/02/01 07:03:29 steve Exp $ .\" @@ -31,7 +31,7 @@ .\" .\" @(#)ifconfig.8 8.4 (Berkeley) 6/1/94 .\" -.Dd $Mdocdate: October 25 2011 $ +.Dd $Mdocdate: November 2 2011 $ .Dt IFCONFIG 8 .Os .Sh NAME @@ -156,6 +156,8 @@ Disable the use of ARP. Specify the address to use to represent broadcasts to the network. The default broadcast address is the address with a host part of all 1's. +.It Cm hwfeatures +Display the interface hardware features. .It Cm create Create the specified network pseudo-device. At least the following devices can be created on demand: diff --git a/sbin/ifconfig/ifconfig.c b/sbin/ifconfig/ifconfig.c index 2bb408361f3..7030997542b 100644 --- a/sbin/ifconfig/ifconfig.c +++ b/sbin/ifconfig/ifconfig.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ifconfig.c,v 1.250 2011/09/19 20:29:10 henning Exp $ */ +/* $OpenBSD: ifconfig.c,v 1.251 2011/11/02 02:03:47 haesbaert Exp $ */ /* $NetBSD: ifconfig.c,v 1.40 1997/10/01 02:19:43 enami Exp $ */ /* @@ -105,6 +105,11 @@ #include "brconfig.h" #include "pbkdf2.h" +#define HWFEATURESBITS \ + "\024\1CSUM_IPv4\2CSUM_TCPv4\3CSUM_UDPv4\4IPSEC" \ + "\5VLAN_MTU\6VLAN_HWTAGGING\7IPCOMP\10CSUM_TCPv6" \ + "\11CSUM_UDPv6\12TCPv4_Rx\13UDPv4_Rx\20WOL" + struct ifreq ifr, ridreq; struct in_aliasreq in_addreq; #ifdef INET6 @@ -131,6 +136,7 @@ int Lflag = 1; #endif /* INET6 */ int showmediaflag; +int showcapsflag; int shownet80211chans; int shownet80211nodes; @@ -248,6 +254,7 @@ void setifipdst(const char *, int); void setifdesc(const char *, int); void unsetifdesc(const char *, int); int printgroup(char *, int); +void printifhwfeatures(const char *, int); #else void setignore(const char *, int); #endif @@ -334,6 +341,7 @@ const struct cmd { { "-autoconfprivacy", -IFXF_INET6_PRIVACY, 0, setifxflags }, #endif /*INET6*/ #ifndef SMALL + { "hwfeatures", NEXTARG0, 0, printifhwfeatures }, { "group", NEXTARG, 0, setifgroup }, { "-group", NEXTARG, 0, unsetifgroup }, { "trailers", -1, 0, notrailers }, @@ -2780,6 +2788,10 @@ status(int link, struct sockaddr_dl *sdl, int ls) if (mtu) printf(" mtu %lu", mtu); putchar('\n'); +#ifndef SMALL + if (showcapsflag) + printifhwfeatures(NULL, 1); +#endif if (sdl != NULL && sdl->sdl_alen && (sdl->sdl_type == IFT_ETHER || sdl->sdl_type == IFT_CARP)) (void)printf("\tlladdr %s\n", ether_ntoa( @@ -4697,6 +4709,25 @@ getifgroups(void) free(ifgr.ifgr_groups); } + +void +printifhwfeatures(const char *unused, int show) +{ + struct if_data ifrdat; + + if (!show) { + if (showcapsflag) + usage(1); + showcapsflag = 1; + return; + } + bzero(&ifrdat, sizeof(ifrdat)); + ifr.ifr_data = (caddr_t)&ifrdat; + if (ioctl(s, SIOCGIFDATA, (caddr_t)&ifr) == -1) + err(1, "SIOCGIFDATA"); + printb("\thwfeatures", (u_int)ifrdat.ifi_capabilities, HWFEATURESBITS); + putchar('\n'); +} #endif #ifdef INET6 |