Skip to content
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
209 changes: 158 additions & 51 deletions src/drivers/driver_zephyr.c
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,52 @@ void wpa_supplicant_event_wrapper(void *ctx,
data_tmp->unprot_disassoc.sa = sa;
os_memcpy(da, data->unprot_disassoc.da, ETH_ALEN);
data_tmp->unprot_disassoc.da = da;
} else if (event == EVENT_EXTERNAL_AUTH) {
union wpa_event_data *data_tmp = msg.data;
char *bssid = os_zalloc(ETH_ALEN);
char *ssid = NULL;
char *mld_addr = NULL;

if (data->external_auth.ssid_len) {
ssid = os_zalloc(data->external_auth.ssid_len);
}

if (data->external_auth.mld_addr) {
mld_addr = os_zalloc(ETH_ALEN);
}

if (!bssid || (data->external_auth.ssid_len && !ssid) ||
(data->external_auth.mld_addr && !mld_addr)) {
wpa_printf(MSG_ERROR,
"%s:%d event %u Failed to alloc ssid/bssid/mld_addr\n",
__func__, __LINE__, event);
os_free(mld_addr);
os_free(ssid);
os_free(bssid);
os_free(msg.data);
return;
}
os_memcpy(bssid, data->external_auth.bssid, ETH_ALEN);
data_tmp->external_auth.bssid = bssid;
if (data->external_auth.ssid_len) {
os_memcpy(ssid, data->external_auth.ssid,
data->external_auth.ssid_len);
}
data_tmp->external_auth.ssid = ssid;
if (mld_addr) {
os_memcpy(mld_addr,
data->external_auth.mld_addr,
ETH_ALEN);
data_tmp->external_auth.mld_addr = mld_addr;
} else {
data_tmp->external_auth.mld_addr = NULL;
}
data_tmp->external_auth.ssid_len =
data->external_auth.ssid_len;
data_tmp->external_auth.action =
data->external_auth.action;
data_tmp->external_auth.key_mgmt_suite =
data->external_auth.key_mgmt_suite;
}
}

Expand Down Expand Up @@ -500,6 +546,7 @@ void wpa_drv_zep_event_proc_scan_res(struct zep_drv_if_ctx *if_ctx,
}

struct wpa_scan_res *sr = os_zalloc(scan_res_len);

if (!sr) {
wpa_printf(MSG_ERROR, "%s: Failed to alloc scan results(%d bytes)", __func__, scan_res_len);
if_ctx->scan_res2->res = tmp;
Expand Down Expand Up @@ -703,6 +750,24 @@ static void wpa_drv_zep_event_proc_unprot_disassoc(struct zep_drv_if_ctx *if_ctx
event);
}

/**
* wpa_drv_zep_event_ext_auth_req - Forward the SAE external auth event to
* the supplicant.
*
* @if_ctx : Interface context
* @event : event data to be sent to supplicant
*
* This function notifies the supplicant to initiate an External
* Authentication process for a WPA3 SAE STA connection.
*/
void wpa_drv_zep_event_ext_auth_req(struct zep_drv_if_ctx *if_ctx,
union wpa_event_data *event)
{
wpa_supplicant_event_wrapper(if_ctx->supp_if_ctx,
EVENT_EXTERNAL_AUTH,
event);
}

struct phy_info_arg {
u16 *num_modes;
struct hostapd_hw_modes *modes;
Expand Down Expand Up @@ -1366,6 +1431,7 @@ static void *wpa_drv_zep_init(void *ctx,
callbk_fns.roc_complete = wpa_drv_zep_event_roc_complete;
callbk_fns.roc_cancel_complete = wpa_drv_zep_event_roc_cancel_complete;
callbk_fns.cookie_event = wpa_drv_zep_event_cookie_event;
callbk_fns.ext_auth_req = wpa_drv_zep_event_ext_auth_req;

if_ctx->dev_priv = dev_ops->init(if_ctx,
ifname,
Expand Down Expand Up @@ -2018,7 +2084,7 @@ static int _wpa_drv_zep_set_key(void *priv,
}


static int wpa_drv_zep_set_key(void* priv,
static int wpa_drv_zep_set_key(void *priv,
struct wpa_driver_set_key_params *params)
{
return _wpa_drv_zep_set_key(priv,
Expand Down Expand Up @@ -2353,6 +2419,79 @@ static int wpa_drv_zep_get_country(void *priv, char *alpha2)
return ret;
}

int wpa_drv_zep_send_mlme(void *priv, const u8 *data,
size_t data_len, int noack, unsigned int freq,
const u16 *csa_offs, size_t csa_offs_len,
int no_encrypt, unsigned int wait, int link_id)
{
struct zep_drv_if_ctx *if_ctx = priv;
const struct zep_wpa_supp_dev_ops *dev_ops;
int ret = -1;

/* Unused till Wi-Fi7 MLO is supported in Zephyr */
(void)link_id;

dev_ops = get_dev_ops(if_ctx->dev_ctx);

if (!dev_ops || !dev_ops->send_mlme) {
wpa_printf(MSG_ERROR, "%s: send_mlme op not supported",
__func__);
goto out;
}

if (freq == 0) {
freq = if_ctx->freq;
}

ret = dev_ops->send_mlme(if_ctx->dev_priv, data,
data_len, noack, freq, 0, 0, wait, 0);
if (ret) {
wpa_printf(MSG_ERROR, "%s: send_mlme op failed: %d",
__func__, ret);
goto out;
}
ret = 0;
out:
return ret;
}

/**
* wpa_drv_zep_send_external_auth_status - Send the SAE external auth status to
* the driver, if the zephyr driver ops is registered for this.
*
* @priv: Interface context
* @params : External auth status parameters
*
* This function send the external auth status to the driver.
*/
int wpa_drv_zep_send_external_auth_status(void *priv,
struct external_auth *params)
{
struct zep_drv_if_ctx *if_ctx = priv;
const struct zep_wpa_supp_dev_ops *dev_ops;
int ret = -1;

dev_ops = get_dev_ops(if_ctx->dev_ctx);

if (!dev_ops || !dev_ops->send_external_auth_status) {
wpa_printf(MSG_ERROR,
"%s: send_external_auth_status op not supported",
__func__);
goto out;
}

ret = dev_ops->send_external_auth_status(if_ctx->dev_priv, params);
if (ret) {
wpa_printf(MSG_ERROR,
"%s: send_external_auth_status op failed: %d",
__func__, ret);
goto out;
}
ret = 0;
out:
return ret;
}

#ifdef CONFIG_AP
#ifndef CONFIG_WIFI_NM_HOSTAPD_AP
static int register_mgmt_frames_ap(struct zep_drv_if_ctx *if_ctx)
Expand Down Expand Up @@ -2393,14 +2532,18 @@ static int register_mgmt_frames_ap(struct zep_drv_if_ctx *if_ctx)
}
}
#ifdef CONFIG_P2P
/* P2P Public Action */
if (wpa_drv_register_action_frame(if_ctx, (u8 *) "\x04\x09\x50\x6f\x9a\x09", 6) < 0) {
ret = -1;
}
/* P2P Action */
if (wpa_drv_register_action_frame(if_ctx, (u8 *) "\x7f\x50\x6f\x9a\x09", 5) < 0) {
ret = -1;
}
/* P2P Public Action */
if (wpa_drv_register_action_frame(if_ctx,
(u8 *) "\x04\x09\x50\x6f\x9a\x09",
6) < 0) {
ret = -1;
}
/* P2P Action */
if (wpa_drv_register_action_frame(if_ctx,
(u8 *) "\x7f\x50\x6f\x9a\x09",
5) < 0) {
ret = -1;
}
#endif /* CONFIG_P2P */

out:
Expand Down Expand Up @@ -2447,8 +2590,7 @@ static int wpa_drv_zep_set_ap(void *priv,
if (params->proberesp && params->proberesp_len) {
wpa_hexdump(MSG_EXCESSIVE, "proberesp (offload)", params->proberesp, params->proberesp_len);
}
switch (params->hide_ssid)
{
switch (params->hide_ssid) {
case NO_SSID_HIDING:
wpa_printf(MSG_EXCESSIVE, "hidden SSID not in use");
break;
Expand Down Expand Up @@ -2787,45 +2929,9 @@ int wpa_drv_zep_sta_remove(void *priv, const u8 *addr)
return ret;
}

int wpa_drv_zep_send_mlme(void *priv, const u8 *data, size_t data_len, int noack,
unsigned int freq, const u16 *csa_offs, size_t csa_offs_len, int no_encrypt,
unsigned int wait, int link_id)
{
struct zep_drv_if_ctx *if_ctx = priv;
const struct zep_wpa_supp_dev_ops *dev_ops;
int ret = -1;

/* Unused till Wi-Fi7 MLO is supported in Zephyr */
(void)link_id;

dev_ops = get_dev_ops(if_ctx->dev_ctx);
if (!dev_ops) {
wpa_printf(MSG_ERROR, "%s: get_dev_ops failed", __func__);
goto out;
}

if (!dev_ops->send_mlme) {
wpa_printf(MSG_ERROR, "%s: send_mlme op not supported",
__func__);
goto out;
}

if (freq == 0) {
freq = if_ctx->freq;
}

ret = dev_ops->send_mlme(if_ctx->dev_priv, data, data_len, noack, freq, 0, 0, wait, 0);
if (ret) {
wpa_printf(MSG_ERROR, "%s: send_mlme op failed: %d", __func__, ret);
goto out;
}
ret = 0;
out:
return ret;
}

int wpa_drv_hapd_send_eapol(void *priv, const u8 *addr, const u8 *data, size_t data_len,
int encrypt, const u8 *own_addr, u32 flags, int link_id)
int encrypt, const u8 *own_addr,
u32 flags, int link_id)
{
#ifdef CONFIG_WIFI_NM_HOSTAPD_AP
struct zep_drv_if_ctx *if_ctx = priv;
Expand Down Expand Up @@ -3024,7 +3130,7 @@ int wpa_drv_zep_probe_req_report(void *priv, int report)
}

if_ctx->probe_req_listen = true;
if(if_ctx->probe_req_set) {
if (if_ctx->probe_req_set) {
wpa_printf(MSG_DEBUG, "%s: Probe request already registered", __func__);
return 0;
}
Expand Down Expand Up @@ -3121,14 +3227,15 @@ const struct wpa_driver_ops wpa_driver_zep_ops = {
.get_conn_info = wpa_drv_zep_get_conn_info,
.set_country = wpa_drv_zep_set_country,
.get_country = wpa_drv_zep_get_country,
.send_mlme = wpa_drv_zep_send_mlme,
.send_external_auth_status = wpa_drv_zep_send_external_auth_status,
#ifdef CONFIG_AP
#ifdef CONFIG_WIFI_NM_HOSTAPD_AP
.hapd_init = wpa_drv_zep_hapd_init,
.hapd_deinit = wpa_drv_zep_hapd_deinit,
.do_acs = wpa_drv_zep_do_acs,
#endif
.hapd_send_eapol = wpa_drv_hapd_send_eapol,
.send_mlme = wpa_drv_zep_send_mlme,
.set_ap = wpa_drv_zep_set_ap,
.stop_ap = wpa_drv_zep_stop_ap,
.deinit_ap = wpa_drv_zep_deinit_ap,
Expand Down
5 changes: 5 additions & 0 deletions src/drivers/driver_zephyr.h
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,9 @@ struct zep_wpa_supp_dev_callbk_fns {
int freq, u64 cookie);

void (*cookie_event)(struct zep_drv_if_ctx *if_ctx, u64 host_cookie, u64 cookie);

void (*ext_auth_req)(struct zep_drv_if_ctx *if_ctx,
union wpa_event_data *event);
};

struct zep_hostapd_dev_callbk_fns
Expand Down Expand Up @@ -315,6 +318,8 @@ struct zep_wpa_supp_dev_ops {
int offchanok,
unsigned int wait_time,
int cookie);
int (*send_external_auth_status)(void *priv,
struct external_auth *params);
int (*get_wiphy)(void *if_priv);

int (*register_frame)(void *if_priv,
Expand Down