Skip to content
This repository has been archived by the owner on Nov 14, 2024. It is now read-only.

Fix WPA supplicant internal events processing #139

Merged
merged 4 commits into from
Dec 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion wpa_supplicant/ctrl_iface_zephyr.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,6 @@ struct ctrl_iface_global_priv {
};

struct conn_msg {
char msg[MAX_CTRL_MSG_LEN];
int msg_len;
char msg[MAX_CTRL_MSG_LEN];
};
22 changes: 15 additions & 7 deletions wpa_supplicant/wpa_cli_zephyr.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,17 +114,25 @@ static void wpa_cli_close_connection(struct wpa_supplicant *wpa_s)
static void wpa_cli_recv_pending(struct wpa_ctrl *ctrl)
{
while (wpa_ctrl_pending(ctrl) > 0) {
char buf[MAX_CTRL_MSG_LEN];
size_t len = sizeof(buf) - 1;
char buf[sizeof(struct conn_msg)];
size_t len = sizeof(buf);

if (wpa_ctrl_recv(ctrl, buf, &len) == 0) {
buf[len] = '\0';
if (strlen(buf) > 0) {
struct conn_msg *msg = (struct conn_msg *)buf;

msg->msg[msg->msg_len] = '\0';
wpa_printf(MSG_DEBUG, "Received len: %d, msg_len:%d - %s->END\n",
len, msg->msg_len, msg->msg);
if (msg->msg_len >= MAX_CTRL_MSG_LEN) {
wpa_printf(MSG_INFO, "Too long message received.\n");
continue;
}

if (msg->msg_len > 0) {
/* Only interested in CTRL-EVENTs */
if (strncmp(buf, "CTRL-EVENT", 10) == 0) {
wpa_printf(MSG_DEBUG, "Received event: %s\n", buf);
if (strncmp(msg->msg, "CTRL-EVENT", 10) == 0) {
send_wifi_mgmt_event("wlan0", NET_EVENT_WPA_SUPP_CMD_INT_EVENT,
(void *)&buf[0], strlen(buf));
msg->msg, msg->msg_len);
}
}
} else {
Expand Down
Loading