Skip to content

Fix/dpp wpa msg fail #85926

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 24, 2025
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
52 changes: 17 additions & 35 deletions modules/hostap/src/hapd_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -202,41 +202,6 @@ static int hostapd_global_init(struct hapd_interfaces *interfaces, const char *e
return 0;
}

const char *zephyr_hostap_msg_ifname_cb(void *ctx)
{
if (ctx == NULL) {
return NULL;
}

if ((*((int *)ctx)) == 0) {
struct wpa_supplicant *wpa_s = ctx;

return wpa_s->ifname;
}

struct hostapd_data *hapd = ctx;

if (hapd && hapd->conf) {
return hapd->conf->iface;
}

return NULL;
}

void zephyr_hostap_ctrl_iface_msg_cb(void *ctx, int level, enum wpa_msg_type type,
const char *txt, size_t len)
{
if (ctx == NULL) {
return;
}

if ((*((int *)ctx)) == 0) {
wpa_supplicant_msg_send(ctx, level, type, txt, len);
} else {
hostapd_msg_send(ctx, level, type, txt, len);
}
}

static int hostapd_driver_init(struct hostapd_iface *iface)
{
struct wpa_init_params params;
Expand Down Expand Up @@ -570,3 +535,20 @@ void zephyr_hostapd_init(struct hapd_interfaces *interfaces)
out:
return;
}

void zephyr_hostapd_msg(void *ctx, const char *txt, size_t len)
{
#ifdef CONFIG_WIFI_NM_WPA_SUPPLICANT_DPP
struct hostapd_data *hapd = (struct hostapd_data *)ctx;
#endif

if (!ctx || !txt) {
return;
}

#ifdef CONFIG_WIFI_NM_WPA_SUPPLICANT_DPP
if (strncmp(txt, "DPP", 3) == 0) {
hostapd_handle_dpp_event(hapd, (char *)txt, len);
}
#endif
}
8 changes: 1 addition & 7 deletions modules/hostap/src/hapd_main.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,8 @@
#define __HAPD_MAIN_H_

#include "common.h"
#include "wpa_debug_zephyr.h"

struct hostapd_iface *zephyr_get_hapd_handle_by_ifname(const char *ifname);
void wpa_supplicant_msg_send(void *ctx, int level, enum wpa_msg_type type, const char *txt,
size_t len);
void hostapd_msg_send(void *ctx, int level, enum wpa_msg_type type, const char *buf, size_t len);
const char *zephyr_hostap_msg_ifname_cb(void *ctx);
void zephyr_hostap_ctrl_iface_msg_cb(void *ctx, int level, enum wpa_msg_type type,
const char *txt, size_t len);
void zephyr_hostapd_init(struct hapd_interfaces *interfaces);
void zephyr_hostapd_msg(void *ctx, const char *txt, size_t len);
#endif /* __HAPD_MAIN_H_ */
78 changes: 75 additions & 3 deletions modules/hostap/src/supp_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,80 @@ static int get_iface_count(struct supplicant_context *ctx)
return count;
}

static void zephyr_wpa_supplicant_msg(void *ctx, const char *txt, size_t len)
{
struct wpa_supplicant *wpa_s = (struct wpa_supplicant *)ctx;

if (!ctx || !txt) {
return;
}

/* Only interested in CTRL-EVENTs */
if (strncmp(txt, "CTRL-EVENT", 10) == 0) {
if (strncmp(txt, "CTRL-EVENT-SIGNAL-CHANGE", 24) == 0) {
supplicant_send_wifi_mgmt_event(wpa_s->ifname,
NET_EVENT_WIFI_CMD_SIGNAL_CHANGE,
(void *)txt, len);
} else {
supplicant_send_wifi_mgmt_event(wpa_s->ifname,
NET_EVENT_WIFI_CMD_SUPPLICANT,
(void *)txt, len);
}
} else if (strncmp(txt, "RRM-NEIGHBOR-REP-RECEIVED", 25) == 0) {
supplicant_send_wifi_mgmt_event(wpa_s->ifname,
NET_EVENT_WIFI_CMD_NEIGHBOR_REP_RECEIVED,
(void *)txt, len);
}
}

static const char *zephyr_hostap_msg_ifname_cb(void *ctx)
{
if (ctx == NULL) {
return NULL;
}

#ifdef CONFIG_WIFI_NM_HOSTAPD_AP
if ((((struct wpa_supplicant *)ctx))->is_hostapd == 0) {
struct wpa_supplicant *wpa_s = ctx;

return wpa_s->ifname;
}

struct hostapd_data *hapd = ctx;

if (hapd && hapd->conf) {
return hapd->conf->iface;
}

return NULL;
#else
struct wpa_supplicant *wpa_s = ctx;

return wpa_s->ifname;
#endif
}

static void zephyr_hostap_ctrl_iface_msg_cb(void *ctx, int level, enum wpa_msg_type type,
const char *txt, size_t len)
{
ARG_UNUSED(level);
ARG_UNUSED(type);

if (ctx == NULL) {
return;
}

#ifdef CONFIG_WIFI_NM_HOSTAPD_AP
if ((((struct wpa_supplicant *)ctx))->is_hostapd == 0) {
zephyr_wpa_supplicant_msg(ctx, txt, len);
} else {
zephyr_hostapd_msg(ctx, txt, len);
}
#else
zephyr_wpa_supplicant_msg(ctx, txt, len);
#endif
}

static int add_interface(struct supplicant_context *ctx, struct net_if *iface)
{
struct wpa_supplicant *wpa_s;
Expand Down Expand Up @@ -288,9 +362,7 @@ static int add_interface(struct supplicant_context *ctx, struct net_if *iface)
supplicant_generate_state_event(ifname, NET_EVENT_SUPPLICANT_CMD_READY, 0);
}

#ifdef CONFIG_WIFI_NM_HOSTAPD_AP
wpa_msg_register_cb(zephyr_hostap_ctrl_iface_msg_cb);
#endif
ret = 0;

out:
Expand Down Expand Up @@ -628,8 +700,8 @@ static void handler(void)

#ifdef CONFIG_WIFI_NM_HOSTAPD_AP
zephyr_hostapd_init(&ctx->hostapd);
wpa_msg_register_ifname_cb(zephyr_hostap_msg_ifname_cb);
#endif
wpa_msg_register_ifname_cb(zephyr_hostap_msg_ifname_cb);

(void)wpa_supplicant_run(ctx->supplicant);

Expand Down
4 changes: 2 additions & 2 deletions subsys/net/lib/sockets/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -370,8 +370,8 @@ if NET_SOCKETPAIR_HEAP

config HEAP_MEM_POOL_ADD_SIZE_SOCKETPAIR
int
default 13696 if WIFI_NM_HOSTAPD_AP
default 9120 if WIFI_NM_WPA_SUPPLICANT
default 9136 if WIFI_NM_HOSTAPD_AP
default 6852 if WIFI_NM_WPA_SUPPLICANT
default 256

endif # NET_SOCKETPAIR_HEAP
Expand Down
2 changes: 1 addition & 1 deletion west.yml
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ manifest:
- hal
- name: hostap
path: modules/lib/hostap
revision: fb6452c246b441434172235b2070259945ca9d44
revision: 8412f4b23b6267ee6035d25515a23aaf243f6ad7
- name: liblc3
revision: 48bbd3eacd36e99a57317a0a4867002e0b09e183
path: modules/lib/liblc3
Expand Down
Loading