Do not require users to type 'media autoselect mode ...' if all
they want is to force a particular operating mode.
This allows 11n support to be disabled by typing short commands like:
ifconfig iwn0 mode 11a
ifconfig iwn0 mode 11g
ifconfig iwn0 mode 11b
The new -mode command restores the default behaviour (mode autoselect).
ok?
Index: ifconfig.8
===================================================================
RCS file: /cvs/src/sbin/ifconfig/ifconfig.8,v
retrieving revision 1.264
diff -u -p -r1.264 ifconfig.8
--- ifconfig.8 6 Dec 2015 12:50:05 -0000 1.264
+++ ifconfig.8 12 Jan 2016 11:59:16 -0000
@@ -373,16 +373,21 @@ The routing metric can be used by routin
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 operating mode of the interface to the given
.Ar mode .
For IEEE 802.11 wireless interfaces that support multiple operating modes,
this directive is used to select between 802.11a
.Pq Dq 11a ,
802.11b
.Pq Dq 11b ,
-and 802.11g
-.Pq Dq 11g
+802.11g
+.Pq Dq 11g,
+and 802.11n
+.Pq Dq 11n
operating modes.
+.It Fl mode
+Select the operating 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.
Index: ifconfig.c
===================================================================
RCS file: /cvs/src/sbin/ifconfig/ifconfig.c,v
retrieving revision 1.314
diff -u -p -r1.314 ifconfig.c
--- ifconfig.c 6 Jan 2016 21:37:00 -0000 1.314
+++ ifconfig.c 12 Jan 2016 11:40:26 -0000
@@ -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;
}
@@ -2450,6 +2452,26 @@ setmediamode(const char *val, int d)
if ((mode = get_media_mode(type, val)) == -1)
errx(1, "invalid media mode: %s", val);
media_current = IFM_MAKEWORD(type, subtype, options, inst) | mode;
+ /* Media will be set after other processing is complete. */
+}
+
+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;
/* Media will be set after other processing is complete. */
}