]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
Introduce DUMP_BEACON command
authorMarek Puzyniak <marek.puzyniak@gmail.com>
Wed, 9 Oct 2024 08:15:02 +0000 (10:15 +0200)
committerJouni Malinen <j@w1.fi>
Fri, 27 Dec 2024 18:28:26 +0000 (20:28 +0200)
Occasionally, external applications require information about AP
configurations and capabilities. One potentially useful source for this
is the Beacon frame content. To support this need, introduce a new
control interface command: DUMP_BEACON. This return a hexdump of the
Beacon frame template, i.e., IEEE 802.11 frame header and frame body
with the TIM element missing since it is added by the driver and some of
the fields like the Timestamp field left to all zeros since they will be
filled in by the driver/hardware.

This can be fetched with hostapd_cli:

hostapd_cli -i wlxxx raw DUMP_BEACON
80000000ffffffffffff...
7f080400000200000040dd180050f2020101010003a4000027a4000042435e0062322f00

Signed-off-by: Marek Puzyniak <marek.puzyniak@holisticon.pl>
hostapd/ctrl_iface.c
src/ap/hostapd.c
src/ap/hostapd.h

index 50704a675df3d111cf7417a242168e6114597268..e282faaccfebaac1982113973e6a49c66787531b 100644 (file)
@@ -3206,6 +3206,7 @@ static int hostapd_ctrl_iface_log_level(struct hostapd_data *hapd, char *cmd,
 
 
 #ifdef NEED_AP_MLME
+
 static int hostapd_ctrl_iface_track_sta_list(struct hostapd_data *hapd,
                                             char *buf, size_t buflen)
 {
@@ -3239,6 +3240,35 @@ static int hostapd_ctrl_iface_track_sta_list(struct hostapd_data *hapd,
 
        return pos - buf;
 }
+
+
+static int hostapd_ctrl_iface_dump_beacon(struct hostapd_data *hapd,
+                                         char *buf, size_t buflen)
+{
+       struct beacon_data beacon;
+       char *pos, *end;
+       int ret;
+
+       if (hostapd_build_beacon_data(hapd, &beacon) < 0)
+               return -1;
+
+       if (2 * (beacon.head_len + beacon.tail_len) > buflen)
+               return -1;
+
+       pos = buf;
+       end = buf + buflen;
+
+       ret = wpa_snprintf_hex(pos, end - pos, beacon.head, beacon.head_len);
+       pos += ret;
+
+       ret = wpa_snprintf_hex(pos, end - pos, beacon.tail, beacon.tail_len);
+       pos += ret;
+
+       free_beacon_data(&beacon);
+
+       return pos - buf;
+}
+
 #endif /* NEED_AP_MLME */
 
 
@@ -4343,6 +4373,9 @@ static int hostapd_ctrl_iface_receive_process(struct hostapd_data *hapd,
        } else if (os_strcmp(buf, "TRACK_STA_LIST") == 0) {
                reply_len = hostapd_ctrl_iface_track_sta_list(
                        hapd, reply, reply_size);
+       } else if (os_strcmp(buf, "DUMP_BEACON") == 0) {
+               reply_len = hostapd_ctrl_iface_dump_beacon(hapd, reply,
+                                                          reply_size);
 #endif /* NEED_AP_MLME */
        } else if (os_strcmp(buf, "PMKSA") == 0) {
                reply_len = hostapd_ctrl_iface_pmksa_list(hapd, reply,
index a850eaf2b0836d638a139216672a42161429b6d5..06e837afcfa2bef07f08cef5718e0faeedc33d3b 100644 (file)
@@ -4227,8 +4227,8 @@ void free_beacon_data(struct beacon_data *beacon)
 }
 
 
-static int hostapd_build_beacon_data(struct hostapd_data *hapd,
-                                    struct beacon_data *beacon)
+int hostapd_build_beacon_data(struct hostapd_data *hapd,
+                             struct beacon_data *beacon)
 {
        struct wpabuf *beacon_extra, *proberesp_extra, *assocresp_extra;
        struct wpa_driver_ap_params params;
index 8edfc827c8cf7bc6bca11d607aec9852b581d2fd..0cb5e14a1ebd564a0201f5d91b4905ddfc13989d 100644 (file)
@@ -862,6 +862,8 @@ int hostapd_mld_remove_link(struct hostapd_data *hapd);
 u8 hostapd_get_active_links(struct hostapd_data *hapd);
 struct hostapd_data * hostapd_mld_get_first_bss(struct hostapd_data *hapd);
 
+int hostapd_build_beacon_data(struct hostapd_data *hapd,
+                             struct beacon_data *beacon);
 void free_beacon_data(struct beacon_data *beacon);
 int hostapd_fill_cca_settings(struct hostapd_data *hapd,
                              struct cca_settings *settings);