Skip to content
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

Fix/dpp wpa msg fail #85926

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
123 changes: 85 additions & 38 deletions modules/hostap/src/supp_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,6 @@ static struct hapd_global hglobal;
#define HOSTAPD_CLEANUP_INTERVAL 10
#endif /* HOSTAPD_CLEANUP_INTERVAL */

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

static int hostapd_periodic_call(struct hostapd_iface *iface, void *ctx)
{
hostapd_periodic_iface(iface);
Expand Down Expand Up @@ -294,6 +291,91 @@ 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);
}
}

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

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
}

static 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;
}
#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 ((*((int *)ctx)) == 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 @@ -1094,41 +1176,6 @@ static void zephyr_hostapd_init(struct supplicant_context *ctx)
out:
return;
}

static 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;
}

static 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);
}
}
#endif

static void handler(void)
Expand Down
3 changes: 0 additions & 3 deletions modules/hostap/src/supp_main.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,6 @@ struct wpa_supplicant *zephyr_get_handle_by_ifname(const char *ifname);
#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);
#endif

struct wpa_supplicant_event_msg {
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: 4957416a01c86579aebb333b43f1c23da0375835
revision: pull/78/head
- name: liblc3
revision: 48bbd3eacd36e99a57317a0a4867002e0b09e183
path: modules/lib/liblc3
Expand Down
Loading