wpa_cli command to get current BSS

Jouni Malinen j at w1.fi
Mon Dec 5 05:52:55 PST 2016

On Mon, Oct 17, 2016 at 05:46:07PM -0500, Joel Cunningham wrote:
> I need to get the current BSS entry information (when associated) from wpa_cli.  From studying the implementation of the BSS list and current wpa_cli commands, I’ve come up with scraping the BSSID and SSID from “wpa_cli STATUS” and then using “wpa_cli BSS FIRST” and “wpa_cli BSS NEXT-id“ to walk the BSS list until finding a BSSID and SSID match.  Is the current best practice?

BSSID is supposed to be unique, so "BSS <current BSSID from STATUS
output>" should really work for this in most cases, but if there are
multiple SSIDs using the same BSSID (i.e., sharing the same Beacon
frames), you might indeed need to iterate through the BSS entries. That
said, sharing the same Beacon frame would likely mean that most of the
BSS entry information would also be common between those two networks..

> I was thinking a simpler approach would be to do a lookup based on the BSS entry ID, but that’s not available in “wpa_cli STATUS”.  I see that WPA supplicant saves a pointer to the current BSS via wpa_s->current_bss.  Would it make sense to add a new BSS subcommand to output the BSS in wpa_s->current_bss?  Something like ‘wpa_cli BSS CURRENT”?

It would be only couple of lines of new code to support "BSS CURRENT",
so that should be fine to add if you have a use case that would benefit
from getting the exact BSS entry without having to iterate through full
table and do BSSID/SSID matching.

Jouni Malinen                                            PGP id EFC895FA

More information about the Hostap mailing list