[openwrt/openwrt] hostapd: report radar detected events via ubus

LEDE Commits lede-commits at lists.infradead.org
Wed May 26 03:05:26 PDT 2021


nbd pushed a commit to openwrt/openwrt.git, branch master:
https://git.openwrt.org/753a91d1d122434a75e12d2e16568b6dba6bf034

commit 753a91d1d122434a75e12d2e16568b6dba6bf034
Author: Felix Fietkau <nbd at nbd.name>
AuthorDate: Tue May 18 16:08:59 2021 +0200

    hostapd: report radar detected events via ubus
    
    Events are reported on all BSS interfaces
    
    Signed-off-by: Felix Fietkau <nbd at nbd.name>
---
 .../services/hostapd/patches/600-ubus_support.patch | 11 +++++++++++
 package/network/services/hostapd/src/src/ap/ubus.c  | 21 +++++++++++++++++++++
 package/network/services/hostapd/src/src/ap/ubus.h  |  6 ++++++
 3 files changed, 38 insertions(+)

diff --git a/package/network/services/hostapd/patches/600-ubus_support.patch b/package/network/services/hostapd/patches/600-ubus_support.patch
index 0d1cb2c3e4..8d9d3eb7c1 100644
--- a/package/network/services/hostapd/patches/600-ubus_support.patch
+++ b/package/network/services/hostapd/patches/600-ubus_support.patch
@@ -462,3 +462,14 @@
  	return hostapd_vlan_if_remove(hapd, vlan->ifname);
  }
  
+--- a/src/ap/dfs.c
++++ b/src/ap/dfs.c
+@@ -1179,6 +1179,8 @@ int hostapd_dfs_radar_detected(struct ho
+ 		"freq=%d ht_enabled=%d chan_offset=%d chan_width=%d cf1=%d cf2=%d",
+ 		freq, ht_enabled, chan_offset, chan_width, cf1, cf2);
+ 
++	hostapd_ubus_notify_radar_detected(iface, freq, chan_width, cf1, cf2);
++
+ 	/* Proceed only if DFS is not offloaded to the driver */
+ 	if (iface->drv_flags & WPA_DRIVER_FLAGS_DFS_OFFLOAD)
+ 		return 0;
diff --git a/package/network/services/hostapd/src/src/ap/ubus.c b/package/network/services/hostapd/src/src/ap/ubus.c
index bfa44e2915..7cc2059fc1 100644
--- a/package/network/services/hostapd/src/src/ap/ubus.c
+++ b/package/network/services/hostapd/src/src/ap/ubus.c
@@ -1593,3 +1593,24 @@ void hostapd_ubus_notify_beacon_report(
 
 	ubus_notify(ctx, &hapd->ubus.obj, "beacon-report", b.head, -1);
 }
+
+void hostapd_ubus_notify_radar_detected(struct hostapd_iface *iface, int frequency,
+					int chan_width, int cf1, int cf2)
+{
+	struct hostapd_data *hapd;
+	int i;
+
+	if (!hapd->ubus.obj.has_subscribers)
+		return;
+
+	blob_buf_init(&b, 0);
+	blobmsg_add_u16(&b, "frequency", frequency);
+	blobmsg_add_u16(&b, "width", chan_width);
+	blobmsg_add_u16(&b, "center1", cf1);
+	blobmsg_add_u16(&b, "center2", cf2);
+
+	for (i = 0; i < iface->num_bss; i++) {
+		hapd = iface->bss[i];
+		ubus_notify(ctx, &hapd->ubus.obj, "radar-detected", b.head, -1);
+	}
+}
diff --git a/package/network/services/hostapd/src/src/ap/ubus.h b/package/network/services/hostapd/src/src/ap/ubus.h
index f746c86e4f..acdac74360 100644
--- a/package/network/services/hostapd/src/src/ap/ubus.h
+++ b/package/network/services/hostapd/src/src/ap/ubus.h
@@ -52,6 +52,8 @@ void hostapd_ubus_notify_beacon_report(struct hostapd_data *hapd,
 				       const u8 *addr, u8 token, u8 rep_mode,
 				       struct rrm_measurement_beacon_report *rep,
 				       size_t len);
+void hostapd_ubus_notify_radar_detected(struct hostapd_iface *iface, int frequency,
+					int chan_width, int cf1, int cf2);
 
 void hostapd_ubus_add(struct hapd_interfaces *interfaces);
 void hostapd_ubus_free(struct hapd_interfaces *interfaces);
@@ -100,6 +102,10 @@ static inline void hostapd_ubus_notify_beacon_report(struct hostapd_data *hapd,
 						     size_t len)
 {
 }
+static inline void hostapd_ubus_notify_radar_detected(struct hostapd_iface *iface, int frequency,
+						      int chan_width, int cf1, int cf2)
+{
+}
 
 static inline void hostapd_ubus_add(struct hapd_interfaces *interfaces)
 {



More information about the lede-commits mailing list