diff options
author | 2016-01-13 09:35:45 +0000 | |
---|---|---|
committer | 2016-01-13 09:35:45 +0000 | |
commit | 5f44c6c8d0cfe3e3bb23bdeaaf4f269fb96fe1c2 (patch) | |
tree | 98895cfca2cbc0b4eb0262f2d43b93d6a5e19b66 | |
parent | Tell the iwn(4) firmware to retry failed Tx at 1Mbit/s instead of MCS 0. (diff) | |
download | wireguard-openbsd-5f44c6c8d0cfe3e3bb23bdeaaf4f269fb96fe1c2.tar.xz wireguard-openbsd-5f44c6c8d0cfe3e3bb23bdeaaf4f269fb96fe1c2.zip |
Make 'ifconfig $if mode' a valid subcommand that works independently of
the 'media' subcommand. Allow clearing the mode with 'ifconfig $if -mode'.
This makes commands such as 'ifconfig iwn0 mode 11a' work without having
to type all of 'ifconfig iwn0 media autoselect mode 11a'.
ok sthen@ deraadt@ jmc@
-rw-r--r-- | sbin/ifconfig/ifconfig.8 | 19 | ||||
-rw-r--r-- | sbin/ifconfig/ifconfig.c | 27 |
2 files changed, 37 insertions, 9 deletions
diff --git a/sbin/ifconfig/ifconfig.8 b/sbin/ifconfig/ifconfig.8 index 033dbe3abae..ee482037c4d 100644 --- a/sbin/ifconfig/ifconfig.8 +++ b/sbin/ifconfig/ifconfig.8 @@ -1,4 +1,4 @@ -.\" $OpenBSD: ifconfig.8,v 1.264 2015/12/06 12:50:05 tedu Exp $ +.\" $OpenBSD: ifconfig.8,v 1.265 2016/01/13 09:35:45 stsp 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: December 6 2015 $ +.Dd $Mdocdate: January 13 2016 $ .Dt IFCONFIG 8 .Os .Sh NAME @@ -373,16 +373,21 @@ The routing metric can be used by routing protocols. Higher metrics have the effect of making a route less favorable. .It Cm mode Ar mode If the driver for the interface supports the media selection system, -set the specified operating mode on the interface to the given +force the mode of the interface to the given .Ar mode . -For IEEE 802.11 wireless interfaces that support multiple operating modes, +For IEEE 802.11 wireless interfaces that support multiple modes, this directive is used to select between 802.11a .Pq Dq 11a , 802.11b .Pq Dq 11b , -and 802.11g -.Pq Dq 11g -operating modes. +802.11g +.Pq Dq 11g , +and 802.11n +.Pq Dq 11n +modes. +.It Fl mode +Select the mode automatically. +This is the default for IEEE 802.11 wireless interfaces. .It Cm mpls Enable Multiprotocol Label Switching (MPLS) on the interface, allowing it to send and receive MPLS traffic. diff --git a/sbin/ifconfig/ifconfig.c b/sbin/ifconfig/ifconfig.c index 6188665b0f0..e2e55aee124 100644 --- a/sbin/ifconfig/ifconfig.c +++ b/sbin/ifconfig/ifconfig.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ifconfig.c,v 1.314 2016/01/06 21:37:00 tedu Exp $ */ +/* $OpenBSD: ifconfig.c,v 1.315 2016/01/13 09:35:45 stsp Exp $ */ /* $NetBSD: ifconfig.c,v 1.40 1997/10/01 02:19:43 enami Exp $ */ /* @@ -193,6 +193,7 @@ void unsetkeepalive(const char *, int); void setmedia(const char *, int); void setmediaopt(const char *, int); void setmediamode(const char *, int); +void unsetmediamode(const char *, int); void clone_create(const char *, int); void clone_destroy(const char *, int); void unsetmediaopt(const char *, int); @@ -517,6 +518,7 @@ const struct cmd { { "mediaopt", NEXTARG, A_MEDIAOPTSET, setmediaopt }, { "-mediaopt", NEXTARG, A_MEDIAOPTCLR, unsetmediaopt }, { "mode", NEXTARG, A_MEDIAMODE, setmediamode }, + { "-mode", 0, A_MEDIAMODE, unsetmediamode }, { "instance", NEXTARG, A_MEDIAINST, setmediainst }, { "inst", NEXTARG, A_MEDIAINST, setmediainst }, { "lladdr", NEXTARG, 0, setiflladdr }, @@ -2367,7 +2369,7 @@ void process_media_commands(void) { - if ((actions & (A_MEDIA|A_MEDIAOPT)) == 0) { + if ((actions & (A_MEDIA|A_MEDIAOPT|A_MEDIAMODE)) == 0) { /* Nothing to do. */ return; } @@ -2454,6 +2456,27 @@ setmediamode(const char *val, int d) } void +unsetmediamode(const char *val, int d) +{ + uint64_t type, subtype, options, inst; + + init_current_media(); + + /* Can only issue `mode' once. */ + if (actions & A_MEDIAMODE) + errx(1, "only one `mode' command may be issued"); + + type = IFM_TYPE(media_current); + subtype = IFM_SUBTYPE(media_current); + options = IFM_OPTIONS(media_current); + inst = IFM_INST(media_current); + + media_current = IFM_MAKEWORD(type, subtype, options, inst) | + (IFM_AUTO << IFM_MSHIFT); + /* Media will be set after other processing is complete. */ +} + +void setmediaopt(const char *val, int d) { |