hostap: Add macro to wrap the interface monitoring code

Add macro to wrap the interface monitoring code and user can choose if
enable it.

Signed-off-by: Maochen Wang <maochen.wang@nxp.com>
This commit is contained in:
Maochen Wang 2024-05-22 13:56:35 +08:00 committed by Alberto Escolar
parent 1726aa4345
commit c116c9faf8
2 changed files with 14 additions and 7 deletions

View file

@ -187,6 +187,10 @@ config WIFI_NM_WPA_SUPPLICANT_CLI
bool "CLI support for wpa_supplicant"
default n
config WIFI_NM_WPA_SUPPLICANT_INF_MON
bool "Monitor the net mgmt event to add/del interface"
default y
config WIFI_NM_WPA_SUPPLICANT_BSS_MAX_IDLE_TIME
int "BSS max idle timeout in seconds"
range 0 64000

View file

@ -69,8 +69,9 @@ static const struct wifi_mgmt_ops mgmt_ops = {
DEFINE_WIFI_NM_INSTANCE(wifi_supplicant, &mgmt_ops);
#define WRITE_TIMEOUT 100 /* ms */
#ifdef CONFIG_WIFI_NM_WPA_SUPPLICANT_INF_MON
#define INTERFACE_EVENT_MASK (NET_EVENT_IF_ADMIN_UP | NET_EVENT_IF_ADMIN_DOWN)
#endif
struct supplicant_context {
struct wpa_global *supplicant;
struct net_mgmt_event_callback cb;
@ -143,6 +144,7 @@ out:
return ret;
}
#ifdef CONFIG_WIFI_NM_WPA_SUPPLICANT_INF_MON
static int send_event(const struct wpa_supplicant_event_msg *msg)
{
return zephyr_wifi_send_event(msg);
@ -158,7 +160,7 @@ static bool is_wanted_interface(struct net_if *iface)
return true;
}
#endif
struct wpa_supplicant *zephyr_get_handle_by_ifname(const char *ifname)
{
struct wpa_supplicant *wpa_s = NULL;
@ -250,7 +252,7 @@ static int add_interface(struct supplicant_context *ctx, struct net_if *iface)
out:
return ret;
}
#ifdef CONFIG_WIFI_NM_WPA_SUPPLICANT_INF_MON
static int del_interface(struct supplicant_context *ctx, struct net_if *iface)
{
struct wpa_supplicant_event_msg msg;
@ -347,7 +349,7 @@ out:
return ret;
}
#endif
static void iface_work_handler(struct k_work *work)
{
struct supplicant_context *ctx = CONTAINER_OF(work, struct supplicant_context,
@ -373,7 +375,7 @@ static void submit_iface_work(struct supplicant_context *ctx,
k_work_submit_to_queue(&ctx->iface_wq, &ctx->iface_work);
}
#ifdef CONFIG_WIFI_NM_WPA_SUPPLICANT_INF_MON
static void interface_handler(struct net_mgmt_event_callback *cb,
uint32_t mgmt_event, struct net_if *iface)
{
@ -402,6 +404,7 @@ static void interface_handler(struct net_mgmt_event_callback *cb,
return;
}
}
#endif
static void iface_cb(struct net_if *iface, void *user_data)
{
@ -429,11 +432,11 @@ static void iface_cb(struct net_if *iface, void *user_data)
static int setup_interface_monitoring(struct supplicant_context *ctx, struct net_if *iface)
{
ARG_UNUSED(iface);
#ifdef CONFIG_WIFI_NM_WPA_SUPPLICANT_INF_MON
net_mgmt_init_event_callback(&ctx->cb, interface_handler,
INTERFACE_EVENT_MASK);
net_mgmt_add_event_callback(&ctx->cb);
#endif
net_if_foreach(iface_cb, ctx);
return 0;