What's the correct way to read a STATUS response from the hostapd control interface?
Jeremy Fleischman
jeremyfleischman at gmail.com
Mon Aug 4 17:59:49 PDT 2025
I'm a user of the wifi-presence openwrt package. It talks to hostapd
over the control socket to know when people connect/disconnect from a
given access point.
My home networks recently grew to the point where the hostapd response
to the STATUS message is larger than 1024 bytes, which causes
wifi-presense to fail to parse the response. I filed a bug with
details here: https://github.com/awilliams/wifi-presence/issues/30.
What I don't understand is how to fix this bug. wifi-presence can
increase its buffer size, but it seems to me that a better
implementation would loop and keep reading until it gets to the end of
hostapd's response. However, I haven't been able to find a mechanism
in the protocol that allows a client to know if it has read a full
response. I'd expect protocols like this to have a "content length"
header, or a special delimiter that indicates the end of a response.
I've read through the source code of the example program
(hostapd/hostapd_cli.c), which hardcodes a buffer length of 4096 in
_wpa_ctrl_command:
static int _wpa_ctrl_command(struct wpa_ctrl *ctrl, const char *cmd, int print)
{
char buf[4096];
What's the correct way to handle this?
Thanks,
Jeremy
More information about the Hostap
mailing list