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

[nrf noup] zephyr: Fix AP de-authentication and disassociation #147

Merged
merged 1 commit into from
Jan 23, 2024
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
58 changes: 36 additions & 22 deletions src/drivers/driver_zephyr.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@
#define SCAN_TIMEOUT 35
#define GET_WIPHY_TIMEOUT 10

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);

void wpa_supplicant_event_wrapper(void *ctx,
enum wpa_event_type event,
union wpa_event_data *data)
Expand Down Expand Up @@ -1682,25 +1686,30 @@ int wpa_drv_zep_sta_deauth(void *priv, const u8 *own_addr, const u8 *addr, u16 r
struct zep_drv_if_ctx *if_ctx = priv;
const struct zep_wpa_supp_dev_ops *dev_ops;
int ret = -1;
struct ieee80211_mgmt mgmt;

if ((!priv) || (!addr)) {
wpa_printf(MSG_ERROR, "%s: Invalid params\n", __func__);
goto out;
}

dev_ops = if_ctx->dev_ctx->config;
if (!dev_ops->sta_deauth) {
wpa_printf(MSG_ERROR, "%s: sta_deauth op not supported\n",
__func__);
goto out;
}

ret = dev_ops->sta_deauth(if_ctx->dev_priv, own_addr, addr, reason_code);
if (ret) {
wpa_printf(MSG_ERROR, "%s: sta_deauth op failed: %d\n", __func__, ret);
goto out;
}

wpa_printf(MSG_DEBUG, "%s: addr %p reason_code %d\n",
__func__, addr, reason_code);

memset(&mgmt, 0, sizeof(mgmt));
mgmt.frame_control = IEEE80211_FC(WLAN_FC_TYPE_MGMT,
WLAN_FC_STYPE_DEAUTH);
memcpy(mgmt.da, addr, ETH_ALEN);
memcpy(mgmt.sa, own_addr, ETH_ALEN);
memcpy(mgmt.bssid, own_addr, ETH_ALEN);
mgmt.u.deauth.reason_code = host_to_le16(reason_code);

return wpa_drv_zep_send_mlme(priv, (u8 *) &mgmt,
IEEE80211_HDRLEN +
sizeof(mgmt.u.deauth), 0, if_ctx->freq, 0, 0,
0, 0);
out:
return ret;
}
Expand All @@ -1710,25 +1719,30 @@ int wpa_drv_zep_sta_disassoc(void *priv, const u8 *own_addr, const u8 *addr, u16
struct zep_drv_if_ctx *if_ctx = priv;
const struct zep_wpa_supp_dev_ops *dev_ops;
int ret = -1;
struct ieee80211_mgmt mgmt;

if ((!priv) || (!addr)) {
wpa_printf(MSG_ERROR, "%s: Invalid params\n", __func__);
goto out;
}

dev_ops = if_ctx->dev_ctx->config;
if (!dev_ops->sta_disassoc) {
wpa_printf(MSG_ERROR, "%s: sta_disassoc op not supported\n",
__func__);
goto out;
}

ret = dev_ops->sta_disassoc(if_ctx->dev_priv, own_addr, addr, reason_code);
if (ret) {
wpa_printf(MSG_ERROR, "%s: sta_disassoc op failed: %d\n", __func__, ret);
goto out;
}

wpa_printf(MSG_DEBUG, "%s: addr %p reason_code %d\n",
__func__, addr, reason_code);

memset(&mgmt, 0, sizeof(mgmt));
mgmt.frame_control = IEEE80211_FC(WLAN_FC_TYPE_MGMT,
WLAN_FC_STYPE_DISASSOC);
memcpy(mgmt.da, addr, ETH_ALEN);
memcpy(mgmt.sa, own_addr, ETH_ALEN);
memcpy(mgmt.bssid, own_addr, ETH_ALEN);
mgmt.u.disassoc.reason_code = host_to_le16(reason_code);

return wpa_drv_zep_send_mlme(priv, (u8 *) &mgmt,
IEEE80211_HDRLEN +
sizeof(mgmt.u.disassoc), 0, if_ctx->freq, 0, 0,
0, 0);
out:
return ret;
}
Expand Down
6 changes: 0 additions & 6 deletions src/drivers/driver_zephyr.h
Original file line number Diff line number Diff line change
Expand Up @@ -248,12 +248,6 @@ struct zep_wpa_supp_dev_ops {

int (*sta_clear_stats)(void *if_priv, const u8 *addr);

int (*sta_deauth)(void *if_priv, const u8 *own_addr, const u8 *addr,
int reason_code);

int (*sta_disassoc)(void *if_priv, const u8 *own_addr, const u8 *addr,
int reason_code);

int (*register_mgmt_frame)(void *if_priv, u16 frame_type,
size_t match_len, const u8 *match);
};
Expand Down
Loading