git: 42410c6d682c - main - ifconfig: make -vht work

From: Bjoern A. Zeeb <bz_at_FreeBSD.org>
Date: Tue, 07 Jan 2025 18:09:58 UTC
The branch main has been updated by bz:

URL: https://cgit.FreeBSD.org/src/commit/?id=42410c6d682c4e00ce6147f99b51a55f6f3fe075

commit 42410c6d682c4e00ce6147f99b51a55f6f3fe075
Author:     Bjoern A. Zeeb <bz@FreeBSD.org>
AuthorDate: 2025-01-04 16:58:49 +0000
Commit:     Bjoern A. Zeeb <bz@FreeBSD.org>
CommitDate: 2025-01-07 18:09:00 +0000

    ifconfig: make -vht work
    
    Also hide the other vht options on -vht and only show vht40/80/160/80p80
    when vht is enabled.
    
    While here fix some whitespace and comments.
    
    Sponsored by:   The FreeBSD Foundation
    MFC after:      3 days
    Reviewed by:    adrian, emaste
    Differential Revision: https://reviews.freebsd.org/D48326
---
 sbin/ifconfig/ifieee80211.c | 45 ++++++++++++++++++++++++---------------------
 1 file changed, 24 insertions(+), 21 deletions(-)

diff --git a/sbin/ifconfig/ifieee80211.c b/sbin/ifconfig/ifieee80211.c
index 77f7bdabb0b2..d4dcfdf63254 100644
--- a/sbin/ifconfig/ifieee80211.c
+++ b/sbin/ifconfig/ifieee80211.c
@@ -198,8 +198,10 @@ static int gottxparams = 0;
 static struct ieee80211_channel curchan;
 static int gotcurchan = 0;
 static struct ifmediareq *global_ifmr;
+
+/* HT */
 static int htconf = 0;
-static	int gothtconf = 0;
+static int gothtconf = 0;
 
 static void
 gethtconf(if_ctx *ctx)
@@ -213,7 +215,7 @@ gethtconf(if_ctx *ctx)
 
 /* VHT */
 static int vhtconf = 0;
-static	int gotvhtconf = 0;
+static int gotvhtconf = 0;
 
 static void
 getvhtconf(if_ctx *ctx)
@@ -5416,26 +5418,27 @@ end:
 
 	if (IEEE80211_IS_CHAN_VHT(c) || verbose) {
 		getvhtconf(ctx);
-		if (vhtconf & IEEE80211_FVHT_VHT)
+		if (vhtconf & IEEE80211_FVHT_VHT) {
 			LINE_CHECK("vht");
-		else
+
+			if (vhtconf & IEEE80211_FVHT_USEVHT40)
+				LINE_CHECK("vht40");
+			else
+				LINE_CHECK("-vht40");
+			if (vhtconf & IEEE80211_FVHT_USEVHT80)
+				LINE_CHECK("vht80");
+			else
+				LINE_CHECK("-vht80");
+			if (vhtconf & IEEE80211_FVHT_USEVHT160)
+				LINE_CHECK("vht160");
+			else
+				LINE_CHECK("-vht160");
+			if (vhtconf & IEEE80211_FVHT_USEVHT80P80)
+				LINE_CHECK("vht80p80");
+			else
+				LINE_CHECK("-vht80p80");
+		} else if (verbose)
 			LINE_CHECK("-vht");
-		if (vhtconf & IEEE80211_FVHT_USEVHT40)
-			LINE_CHECK("vht40");
-		else
-			LINE_CHECK("-vht40");
-		if (vhtconf & IEEE80211_FVHT_USEVHT80)
-			LINE_CHECK("vht80");
-		else
-			LINE_CHECK("-vht80");
-		if (vhtconf & IEEE80211_FVHT_USEVHT160)
-			LINE_CHECK("vht160");
-		else
-			LINE_CHECK("-vht160");
-		if (vhtconf & IEEE80211_FVHT_USEVHT80P80)
-			LINE_CHECK("vht80p80");
-		else
-			LINE_CHECK("-vht80p80");
 	}
 
 	if (get80211val(ctx, IEEE80211_IOC_WME, &wme) != -1) {
@@ -6029,7 +6032,7 @@ static struct cmd ieee80211_cmds[] = {
 	DEF_CMD("ht",		3,	set80211htconf),	/* NB: 20+40 */
 	DEF_CMD("-ht",		0,	set80211htconf),
 	DEF_CMD("vht",		IEEE80211_FVHT_VHT,		set80211vhtconf),
-	DEF_CMD("-vht",		0,				set80211vhtconf),
+	DEF_CMD("-vht",		-IEEE80211_FVHT_VHT,		set80211vhtconf),
 	DEF_CMD("vht40",	IEEE80211_FVHT_USEVHT40,	set80211vhtconf),
 	DEF_CMD("-vht40",	-IEEE80211_FVHT_USEVHT40,	set80211vhtconf),
 	DEF_CMD("vht80",	IEEE80211_FVHT_USEVHT80,	set80211vhtconf),