From e07000e748e47cd67976d833dc8e9d53efa004eb Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Tue, 1 Feb 2022 19:03:09 +0200 Subject: [PATCH] nl80211: Partial support for radio_disable This is for testing purposes to allow a station mode associated to be dropped without sending the AP a Deauthentication frame. Signed-off-by: Jouni Malinen --- src/drivers/driver_nl80211.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c index aec179ac3..326382ccd 100644 --- a/src/drivers/driver_nl80211.c +++ b/src/drivers/driver_nl80211.c @@ -12095,6 +12095,7 @@ static int nl80211_dpp_listen(void *priv, bool enable) #ifdef CONFIG_TESTING_OPTIONS + static int testing_nl80211_register_frame(void *priv, u16 type, const u8 *match, size_t match_len, bool multicast) @@ -12108,6 +12109,33 @@ static int testing_nl80211_register_frame(void *priv, u16 type, return nl80211_register_frame(bss, handle, type, match, match_len, multicast); } + + +static int testing_nl80211_radio_disable(void *priv, int disabled) +{ + struct i802_bss *bss = priv; + struct wpa_driver_nl80211_data *drv = bss->drv; + + /* For now, this is supported only partially in station mode with + * SME-in-wpa_supplicant case where the NL80211_ATTR_LOCAL_STATE_CHANGE + * attribute can be used to avoid sending out the Deauthentication frame + * to the currently associated AP. */ + + if (!disabled) + return 0; + + if (!(drv->capa.flags & WPA_DRIVER_FLAGS_SME)) + return -1; + + if (!drv->associated) + return 0; + + return wpa_driver_nl80211_mlme(drv, drv->bssid, + NL80211_CMD_DEAUTHENTICATE, + WLAN_REASON_PREV_AUTH_NOT_VALID, 1, + drv->first_bss); +} + #endif /* CONFIG_TESTING_OPTIONS */ @@ -12251,5 +12279,6 @@ const struct wpa_driver_ops wpa_driver_nl80211_ops = { #endif /* CONFIG_DPP */ #ifdef CONFIG_TESTING_OPTIONS .register_frame = testing_nl80211_register_frame, + .radio_disable = testing_nl80211_radio_disable, #endif /* CONFIG_TESTING_OPTIONS */ }; -- 2.47.3