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 | |
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@.
-rw-r--r-- | sbin/ifconfig/brconfig.h | 11 | ||||
-rw-r--r-- | sbin/ifconfig/ifconfig.8 | 6 | ||||
-rw-r--r-- | sbin/ifconfig/ifconfig.c | 33 | ||||
-rw-r--r-- | sys/net/if.h | 7 |
4 files changed, 45 insertions, 12 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 diff --git a/sys/net/if.h b/sys/net/if.h index fb521924cdb..ebef78c1268 100644 --- a/sys/net/if.h +++ b/sys/net/if.h @@ -1,4 +1,4 @@ -/* $OpenBSD: if.h,v 1.129 2011/10/07 17:10:08 henning Exp $ */ +/* $OpenBSD: if.h,v 1.130 2011/11/02 02:03:47 haesbaert Exp $ */ /* $NetBSD: if.h,v 1.23 1996/05/07 02:40:27 thorpej Exp $ */ /* @@ -142,6 +142,7 @@ struct if_data { u_int64_t ifi_omcasts; /* packets sent via multicast */ u_int64_t ifi_iqdrops; /* dropped on input, this interface */ u_int64_t ifi_noproto; /* destined for unsupported protocol */ + u_int32_t ifi_capabilities; /* interface capabilities */ struct timeval ifi_lastchange; /* last operational state change */ struct mclpool ifi_mclpool[MCLPOOLS]; @@ -264,7 +265,6 @@ struct ifnet { /* and the entries */ int if_xflags; /* extra softnet flags */ struct if_data if_data; /* stats and other data about if */ u_int32_t if_hardmtu; /* maximum MTU device supports */ - int if_capabilities; /* interface capabilities */ u_int if_rdomain; /* routing instance */ char if_description[IFDESCRSIZE]; /* interface description */ u_short if_rtlabelid; /* next route label */ @@ -311,6 +311,7 @@ struct ifnet { /* and the entries */ #define if_iqdrops if_data.ifi_iqdrops #define if_noproto if_data.ifi_noproto #define if_lastchange if_data.ifi_lastchange +#define if_capabilities if_data.ifi_capabilities #define IFF_UP 0x1 /* interface is up */ #define IFF_BROADCAST 0x2 /* broadcast address valid */ @@ -360,8 +361,6 @@ struct ifnet { /* and the entries */ #define IFCAP_IPCOMP 0x00000040 /* can do IPcomp */ #define IFCAP_CSUM_TCPv6 0x00000080 /* can do IPv6/TCP checksums */ #define IFCAP_CSUM_UDPv6 0x00000100 /* can do IPv6/UDP checksums */ -#define IFCAP_CSUM_TCPv4_Rx 0x00000200 /* can do IPv4/TCP (Rx only) */ -#define IFCAP_CSUM_UDPv4_Rx 0x00000400 /* can do IPv4/UDP (Rx only) */ #define IFCAP_WOL 0x00008000 /* can do wake on lan */ /* |