wpa_cli command to get current BSS

Joel Cunningham joel.cunningham at me.com
Mon Dec 19 13:13:00 PST 2016


From b0ead703d1bd27934759689d95f54e417948cadf Mon Sep 17 00:00:00 2001
From: Joel Cunningham <joel.cunningham at me.com>
Date: Mon, 19 Dec 2016 14:22:53 -0600
Subject: [PATCH] WPA supplicant: add BSS CURRENT command

This commit extends the BSS commands to include "BSS CURRENT" as a way
to get the current BSS without having to walk the BSS list matching
against BSSID+SSID returned from the STATUS command

This returns the BSS stored in wpa_s->current_bss

Signed-off-by: Joel Cunningham <joel.cunningham at me.com>
---
 wpa_supplicant/ctrl_iface.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/wpa_supplicant/ctrl_iface.c b/wpa_supplicant/ctrl_iface.c
index 4439efb..bdd1f58 100644
--- a/wpa_supplicant/ctrl_iface.c
+++ b/wpa_supplicant/ctrl_iface.c
@@ -4561,6 +4561,8 @@ static int wpa_supplicant_ctrl_iface_bss(struct wpa_supplicant *wpa_s,
 				bss = dl_list_entry(next, struct wpa_bss,
 						    list_id);
 		}
+	} else if (os_strncmp(cmd, "CURRENT", 7) == 0) {
+		bss = wpa_s->current_bss;
 #ifdef CONFIG_P2P
 	} else if (os_strncmp(cmd, "p2p_dev_addr=", 13) == 0) {
 		if (hwaddr_aton(cmd + 13, bssid) == 0)
-- 
2.10.0

Joel

> On Dec 5, 2016, at 9:55 AM, Joel Cunningham <joel.cunningham at me.com> wrote:
> 
> 
> 
> 
> On Dec 05, 2016, at 07:54 AM, Jouni Malinen <j at w1.fi> wrote:
> 
>> 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 actually had some application code that was just looking at BSSID from STATUS and then calling "wpa_cli BSS" but this broke when connecting to a hidden SSID on Linux because there are two BSS entries for the BSSID in this case (one for the hidden SSID beacon and another for the probe response with actual SSID).  My application code needed to return the information from the probe response entry (containing real SSID) but depending on the order within the list, the hidden SSID beacon was sometimes returned
> 
>> 
>> 
>>> 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.
> 
> To me using a BSS CURRENT command would be a performance improvement and less application code to maintain.  My application that performs this lookup is called in response to UI wanting to show BSS connection information, so this logic is executed on a periodic basis.  I can work on putting a patch together.
> 
> Joel
> _______________________________________________
> Hostap mailing list
> Hostap at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/hostap




More information about the Hostap mailing list