[PATCH] Introduce DUMP_BEACON command

Jouni Malinen j at w1.fi
Fri Dec 27 14:06:19 PST 2024


On Wed, Oct 09, 2024 at 10:15:02AM +0200, Marek Puzyniak wrote:
> Occasionally, external applications require information about AP
> configurations and capabilities.
> The optimal source for this is the beacon frame content. To support this need,
> a new raw command is being introduced: DUMP_BEACON.
> 
> Using wpa_cli or hostapd_cli to execute this command results in a hex
> dump of the beacon content.
> 
> hostapd_cli -i wlxxx raw DUMP_BEACON
> 80000000ffffffffffff...
> dd180050f2020101010003a4000027a4000042435e0062322f007f080000000000000040

Thanks, applied with cleanup and fixes.

> diff --git a/hostapd/ctrl_iface.c b/hostapd/ctrl_iface.c

> +static int hostapd_ctrl_iface_dump_beacon(struct hostapd_data *hapd,
> +					  char *buf, size_t buflen)

This needs to be within ifdef NEED_AP_MLME to avoid breaking builds.

> +	/* calculate required buffer size to store beacon hex dump */
> +	/* beacon ies, first part */
> +	mgmt = (struct ieee80211_mgmt*)beacon.head;
> +	ies_start = &mgmt->u.beacon.variable[0];
> +	ies_len = beacon.head_len - (ies_start - beacon.head);

There is not really any need for this complexity since beacon.head
contains the header and those IEs and can be printed as a single block.

> +	ret = wpa_snprintf_hex(pos, end - pos, beacon.head, beacon.head_len);
> +	pos += ret;

Which is actually done here..

> +	/* beacon ies, first part */
> +	ret = wpa_snprintf_hex(pos, end - pos, ies_start, ies_len);
> +	pos += ret;

And this would just print duplicated information..

> +	/* beacon extra ie */
> +	ret = wpa_snprintf_hex(pos, end - pos, beacon.beacon_ies, beacon.beacon_ies_len);
> +	pos += ret;

And this is also duplication of IEs.

> +	ret = os_snprintf(pos, end - pos, "\n");

There should not be extra \n at the end of control interface command
output other than cases involving multiple rows of information.

-- 
Jouni Malinen                                            PGP id EFC895FA



More information about the Hostap mailing list