Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 23 Mar 2023 00:17:28 GMT
From:      "Bjoern A. Zeeb" <bz@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: e091be417add - main - ifconfig: ifieee80211: print bssid name
Message-ID:  <202303230017.32N0HSp2082180@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by bz:

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

commit e091be417add7e9130653462012a9ab2f4fb5269
Author:     Bjoern A. Zeeb <bz@FreeBSD.org>
AuthorDate: 2023-03-21 21:25:28 +0000
Commit:     Bjoern A. Zeeb <bz@FreeBSD.org>
CommitDate: 2023-03-23 00:15:15 +0000

    ifconfig: ifieee80211: print bssid name
    
    In certain setups (e.g., autonomous APs) it is extremly helpful to have
    a way to map the BSSIDs to names for both normal status output as well
    as the scan list.  This often allows a quicker overview than remembering
    (or manually looking up) BSSIDs.
    Call ether_ntohost() on the bssid and consult /etc/ethers
    and print "(name)" after the bssid for the status output and "(name)"
    at the end of the line after the IE list.
    
    MFC after:      10 days
    Reviewed by:    adrian, cy
    Differential Revision: https://reviews.freebsd.org/D39192
---
 sbin/ifconfig/ifieee80211.c | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/sbin/ifconfig/ifieee80211.c b/sbin/ifconfig/ifieee80211.c
index cb465a02b794..065a141da0f1 100644
--- a/sbin/ifconfig/ifieee80211.c
+++ b/sbin/ifconfig/ifieee80211.c
@@ -3716,6 +3716,17 @@ printmimo(const struct ieee80211_mimo_info *mi)
 	    mi->ch[3].noise[0]);
 }
 
+static void
+printbssidname(const struct ether_addr *n)
+{
+	char name[MAXHOSTNAMELEN + 1];
+
+	if (ether_ntohost(name, n) != 0)
+		return;
+
+	printf(" (%s)", name);
+}
+
 static void
 list_scan(int s)
 {
@@ -3767,6 +3778,7 @@ list_scan(int s)
 		);
 		printies(vp + sr->isr_ssid_len + sr->isr_meshid_len,
 		    sr->isr_ie_len, 24);
+		printbssidname((const struct ether_addr *)sr->isr_bssid);
 		printf("\n");
 		cp += sr->isr_len, len -= sr->isr_len;
 	} while (len >= sizeof(struct ieee80211req_scan_result));
@@ -4904,8 +4916,10 @@ ieee80211_status(int s)
 		printf(" channel UNDEF");
 
 	if (get80211(s, IEEE80211_IOC_BSSID, data, IEEE80211_ADDR_LEN) >= 0 &&
-	    (memcmp(data, zerobssid, sizeof(zerobssid)) != 0 || verbose))
+	    (memcmp(data, zerobssid, sizeof(zerobssid)) != 0 || verbose)) {
 		printf(" bssid %s", ether_ntoa((struct ether_addr *)data));
+		printbssidname((struct ether_addr *)data);
+	}
 
 	if (get80211len(s, IEEE80211_IOC_STATIONNAME, data, sizeof(data), &len) != -1) {
 		printf("\n\tstationname ");



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202303230017.32N0HSp2082180>