]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
hostapd: Add an option to notify management frames on ctrl_iface
authorRaphaël Mélotte <raphael.melotte@mind.be>
Mon, 30 Nov 2020 11:10:46 +0000 (12:10 +0100)
committerJouni Malinen <j@w1.fi>
Sat, 6 Feb 2021 11:56:18 +0000 (13:56 +0200)
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 the AP-MGMT-FRAME-RECEIVED event
message.

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

Signed-off-by: Raphaël Mélotte <raphael.melotte@mind.be>
hostapd/config_file.c
hostapd/hostapd.conf
src/ap/ap_config.h
src/ap/ieee802_11.c
src/common/wpa_ctrl.h

index cf0853bfdcc7fb75c6cb7673957318f825f0a6d6..093dc4f375f0c8be73ff18d0d66f3f1323a67ee5 100644 (file)
@@ -4368,6 +4368,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) {
+               bss->notify_mgmt_frames = atoi(pos);
 #ifdef CONFIG_DPP
        } else if (os_strcmp(buf, "dpp_name") == 0) {
                os_free(bss->dpp_name);
index 666c4e133625a19eb35bafc1c0e31dbfc2e49ad6..6666153a75262c586a1bed90516c8e2f1e724965 100644 (file)
@@ -571,6 +571,10 @@ wmm_ac_vo_acm=0
 # Default: 1 (enabled)
 #broadcast_deauth=1
 
+# Get notifications for received Management frames on control interface
+# Default: 0 (disabled)
+#notify_mgmt_frames=0
+
 ##### IEEE 802.11n related configuration ######################################
 
 # ieee80211n: Whether IEEE 802.11n (HT) is enabled
index fb153c40b26a9825e2fedc40c099e2490af5b8ec..abe58532e256eb7df0fafca18c8bdde356704d4c 100644 (file)
@@ -736,6 +736,8 @@ struct hostapd_bss_config {
 
        int broadcast_deauth;
 
+       int notify_mgmt_frames;
+
 #ifdef CONFIG_DPP
        char *dpp_name;
        char *dpp_mud_url;
index daf73efb043e6e7e13972637451e8ccd190596b3..595718f42313bb1ccd927b36263763b885d151b8 100644 (file)
@@ -6023,6 +6023,31 @@ static int handle_action(struct hostapd_data *hapd,
 }
 
 
+/**
+ * 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 the IEEE 802.11 header)
+ * @len: Length of frame data in octets
+ *
+ * Notify the control interface of any received 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
  * @hapd: hostapd BSS data structure (the BSS to which the management frame was
@@ -6113,6 +6138,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->conf->notify_mgmt_frames)
+               notify_mgmt_frame(hapd, buf, len);
+
        switch (stype) {
        case WLAN_FC_STYPE_AUTH:
                wpa_printf(MSG_DEBUG, "mgmt::auth");
index 0f4208518e4193b9efeed5abf5832134bdaab823..5688b6fdb1a04215a7c5e3226528cc2367f900db 100644 (file)
@@ -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