[PATCH 1/2] hostapd: Add an option to notify management frames on ctrl_iface

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



In some contexts (e.g. Multi-AP) it can be useful to have access to
some of the management frames in upper layers (e.g. to be able to
process the content of association requests externally).

Add 'notify_mgmt_frames'. When enabled, it will notify the ctrl_iface
when a management frame arrives using 'AP_MGMT_FRAME_RECEIVED'.

Note that to avoid completely flooding the ctrl_iface, not all
management frames are included (e.g. beacons are excluded).

Signed-off-by: Raphaël Mélotte <raphael.melotte@xxxxxxx>
---
 hostapd/config_file.c |  2 ++
 hostapd/hostapd.conf  |  4 ++++
 src/ap/ap_config.h    |  2 ++
 src/ap/ieee802_11.c   | 25 +++++++++++++++++++++++++
 src/common/wpa_ctrl.h |  3 +++
 5 files changed, 36 insertions(+)

diff --git a/hostapd/config_file.c b/hostapd/config_file.c
index ce32f3c04..4f80d61f7 100644
--- a/hostapd/config_file.c
+++ b/hostapd/config_file.c
@@ -4364,6 +4364,8 @@ static int hostapd_config_fill(struct hostapd_config *conf,
 		bss->multicast_to_unicast = atoi(pos);
 	} else if (os_strcmp(buf, "broadcast_deauth") == 0) {
 		bss->broadcast_deauth = atoi(pos);
+	} else if (os_strcmp(buf, "notify_mgmt_frames") == 0) {
+		conf->notify_mgmt_frames = atoi(pos);
 #ifdef CONFIG_DPP
 	} else if (os_strcmp(buf, "dpp_name") == 0) {
 		os_free(bss->dpp_name);
diff --git a/hostapd/hostapd.conf b/hostapd/hostapd.conf
index bf89fbcda..b078dd34c 100644
--- a/hostapd/hostapd.conf
+++ b/hostapd/hostapd.conf
@@ -571,6 +571,10 @@ wmm_ac_vo_acm=0
 # Default: 1 (enabled)
 #broadcast_deauth=1
 
+# Get notifications for management frames:
+# Default: 0 (disabled)
+#notify_mgmt_frames=0
+
 ##### IEEE 802.11n related configuration ######################################
 
 # ieee80211n: Whether IEEE 802.11n (HT) is enabled
diff --git a/src/ap/ap_config.h b/src/ap/ap_config.h
index bada04c3e..98f53e40b 100644
--- a/src/ap/ap_config.h
+++ b/src/ap/ap_config.h
@@ -1050,6 +1050,8 @@ struct hostapd_config {
 	unsigned int airtime_update_interval;
 #define AIRTIME_MODE_MAX (__AIRTIME_MODE_MAX - 1)
 #endif /* CONFIG_AIRTIME_POLICY */
+
+	u8 notify_mgmt_frames;
 };
 
 
diff --git a/src/ap/ieee802_11.c b/src/ap/ieee802_11.c
index de715a04c..4491a33cf 100644
--- a/src/ap/ieee802_11.c
+++ b/src/ap/ieee802_11.c
@@ -4882,6 +4882,28 @@ static int handle_action(struct hostapd_data *hapd,
 	return 1;
 }
 
+/**
+ * notify_mgmt_frame - notify of management frames on the control interface.
+ * @hapd: hostapd BSS data structure (the BSS to which the management frame was
+ * sent to)
+ * @buf: management frame data (starting from IEEE 802.11 header)
+ * @len: length of frame data in octets
+ *
+ * Notify the control interface of any management frame.
+ */
+static void notify_mgmt_frame(struct hostapd_data *hapd, const u8 *buf,
+			      size_t len)
+{
+
+	int hex_len = len * 2 + 1;
+	char *hex = os_malloc(hex_len);
+
+	if (hex) {
+		wpa_snprintf_hex(hex, hex_len, buf, len);
+		wpa_msg_ctrl(hapd->msg_ctx, MSG_INFO, AP_MGMT_FRAME_RECEIVED "buf=%s", hex);
+		os_free(hex);
+	}
+}
 
 /**
  * ieee802_11_mgmt - process incoming IEEE 802.11 management frames
@@ -4973,6 +4995,9 @@ int ieee802_11_mgmt(struct hostapd_data *hapd, const u8 *buf, size_t len,
 	if (hapd->iconf->track_sta_max_num)
 		sta_track_add(hapd->iface, mgmt->sa, ssi_signal);
 
+	if (hapd->iconf->notify_mgmt_frames)
+		notify_mgmt_frame(hapd, buf, len);
+
 	switch (stype) {
 	case WLAN_FC_STYPE_AUTH:
 		wpa_printf(MSG_DEBUG, "mgmt::auth");
diff --git a/src/common/wpa_ctrl.h b/src/common/wpa_ctrl.h
index acc2d6c4c..742b99b1a 100644
--- a/src/common/wpa_ctrl.h
+++ b/src/common/wpa_ctrl.h
@@ -404,6 +404,9 @@ extern "C" {
  * frame=<saqueryreq/saqueryresp> error=<error string> */
 #define OCV_FAILURE "OCV-FAILURE "
 
+/* Event triggered for received management frame */
+#define AP_MGMT_FRAME_RECEIVED "AP-MGMT-FRAME-RECEIVED "
+
 #ifndef BIT
 #define BIT(x) (1U << (x))
 #endif
-- 
2.28.0


_______________________________________________
Hostap mailing list
Hostap@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/hostap




[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux