[openwrt/openwrt] hostapd: ubus: add notification for BSS transition response

LEDE Commits lede-commits at lists.infradead.org
Sat Mar 19 17:34:51 PDT 2022


blocktrron pushed a commit to openwrt/openwrt.git, branch openwrt-21.02:
https://git.openwrt.org/53c60d4bfaa791d2e5fe5f4123cb0d6eadc7ec99

commit 53c60d4bfaa791d2e5fe5f4123cb0d6eadc7ec99
Author: David Bauer <mail at david-bauer.net>
AuthorDate: Wed Oct 21 20:50:01 2020 +0200

    hostapd: ubus: add notification for BSS transition response
    
    To allow steering daemons to be aware of the STA-decided transition
    target, publish WNM transition responses to ubus. This way, steerings
    daemons can learn about STA-chosen targets and send a better selection
    of transition candidates.
    
    Signed-off-by: David Bauer <mail at david-bauer.net>
    (cherry picked from commit a3de42e72ce349c14263737c5d6ec7b00397cf14)
---
 .../hostapd/patches/600-ubus_support.patch         | 30 ++++++++++++++++++++
 package/network/services/hostapd/src/src/ap/ubus.c | 33 ++++++++++++++++++++++
 package/network/services/hostapd/src/src/ap/ubus.h | 11 ++++++++
 3 files changed, 74 insertions(+)

diff --git a/package/network/services/hostapd/patches/600-ubus_support.patch b/package/network/services/hostapd/patches/600-ubus_support.patch
index 53f521e649..eaf1e420ad 100644
--- a/package/network/services/hostapd/patches/600-ubus_support.patch
+++ b/package/network/services/hostapd/patches/600-ubus_support.patch
@@ -424,3 +424,33 @@
  }
  
  
+--- a/src/ap/wnm_ap.c
++++ b/src/ap/wnm_ap.c
+@@ -463,7 +463,7 @@ static void ieee802_11_rx_bss_trans_mgmt
+ 					      size_t len)
+ {
+ 	u8 dialog_token, status_code, bss_termination_delay;
+-	const u8 *pos, *end;
++	const u8 *pos, *end, *target_bssid;
+ 	int enabled = hapd->conf->bss_transition;
+ 	struct sta_info *sta;
+ 
+@@ -510,6 +510,7 @@ static void ieee802_11_rx_bss_trans_mgmt
+ 			wpa_printf(MSG_DEBUG, "WNM: not enough room for Target BSSID field");
+ 			return;
+ 		}
++		target_bssid = pos;
+ 		sta->agreed_to_steer = 1;
+ 		eloop_cancel_timeout(ap_sta_reset_steer_flag_timer, hapd, sta);
+ 		eloop_register_timeout(2, 0, ap_sta_reset_steer_flag_timer,
+@@ -529,6 +530,10 @@ static void ieee802_11_rx_bss_trans_mgmt
+ 			MAC2STR(addr), status_code, bss_termination_delay);
+ 	}
+ 
++	hostapd_ubus_notify_bss_transition_response(hapd, sta->addr, dialog_token,
++						    status_code, bss_termination_delay,
++						    target_bssid, pos, end - pos);
++
+ 	wpa_hexdump(MSG_DEBUG, "WNM: BSS Transition Candidate List Entries",
+ 		    pos, end - pos);
+ }
diff --git a/package/network/services/hostapd/src/src/ap/ubus.c b/package/network/services/hostapd/src/src/ap/ubus.c
index a42ba83faf..d08a70802e 100644
--- a/package/network/services/hostapd/src/src/ap/ubus.c
+++ b/package/network/services/hostapd/src/src/ap/ubus.c
@@ -1627,3 +1627,36 @@ void hostapd_ubus_notify_beacon_report(
 
 	ubus_notify(ctx, &hapd->ubus.obj, "beacon-report", b.head, -1);
 }
+
+void hostapd_ubus_notify_bss_transition_response(
+	struct hostapd_data *hapd, const u8 *addr, u8 dialog_token, u8 status_code,
+	u8 bss_termination_delay, const u8 *target_bssid,
+	const u8 *candidate_list, u16 candidate_list_len)
+{
+#ifdef CONFIG_WNM_AP
+	char *cl_str;
+	u16 i;
+
+	if (!hapd->ubus.obj.has_subscribers)
+		return;
+
+	if (!addr)
+		return;
+
+	blob_buf_init(&b, 0);
+	blobmsg_add_macaddr(&b, "address", addr);
+	blobmsg_add_u8(&b, "dialog-token", dialog_token);
+	blobmsg_add_u8(&b, "status-code", status_code);
+	blobmsg_add_u8(&b, "bss-termination-delay", bss_termination_delay);
+	if (target_bssid)
+		blobmsg_add_macaddr(&b, "target-bssid", target_bssid);
+	if (candidate_list_len > 0) {
+		cl_str = blobmsg_alloc_string_buffer(&b, "candidate-list", candidate_list_len * 2 + 1);
+		for (i = 0; i < candidate_list_len; i++)
+			snprintf(&cl_str[i*2], 3, "%02X", candidate_list[i]);
+		blobmsg_add_string_buffer(&b);
+	}
+
+	ubus_notify(ctx, &hapd->ubus.obj, "bss-transition-response", b.head, -1);
+#endif
+}
diff --git a/package/network/services/hostapd/src/src/ap/ubus.h b/package/network/services/hostapd/src/src/ap/ubus.h
index e16017394f..8398d6bada 100644
--- a/package/network/services/hostapd/src/src/ap/ubus.h
+++ b/package/network/services/hostapd/src/src/ap/ubus.h
@@ -51,6 +51,10 @@ void hostapd_ubus_notify_beacon_report(struct hostapd_data *hapd,
 				       struct rrm_measurement_beacon_report *rep,
 				       size_t len);
 
+void hostapd_ubus_notify_bss_transition_response(
+	struct hostapd_data *hapd, const u8 *addr, u8 dialog_token, u8 status_code,
+	u8 bss_termination_delay, const u8 *target_bssid,
+	const u8 *candidate_list, u16 candidate_list_len);
 void hostapd_ubus_add(struct hapd_interfaces *interfaces);
 void hostapd_ubus_free(struct hapd_interfaces *interfaces);
 
@@ -91,6 +95,13 @@ static inline void hostapd_ubus_notify_beacon_report(struct hostapd_data *hapd,
 {
 }
 
+static inline void hostapd_ubus_notify_bss_transition_response(
+	struct hostapd_data *hapd, const u8 *addr, u8 dialog_token, u8 status_code,
+	u8 bss_termination_delay, const u8 *target_bssid,
+	const u8 *candidate_list, u16 candidate_list_len)
+{
+}
+
 static inline void hostapd_ubus_add(struct hapd_interfaces *interfaces)
 {
 }




More information about the lede-commits mailing list