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
This commit is contained in:
Bjoern A. Zeeb 2023-03-21 21:25:28 +00:00
parent b5d43972e3
commit e091be417a

View file

@ -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 ");