From bbd3178af45b49c66ed50c2a4da7a26d93a73430 Mon Sep 17 00:00:00 2001 From: "Vinita S. Maloo" Date: Wed, 3 Jun 2020 20:54:04 +0530 Subject: [PATCH] MSCS: Add support to process MSCS Response frames Add support to receive and process MSCS Response frames from the AP and indicate the status to upper layers. Signed-off-by: Vinita S. Maloo --- src/common/wpa_ctrl.h | 2 ++ src/drivers/driver_nl80211.c | 4 ++++ wpa_supplicant/events.c | 7 +++++++ wpa_supplicant/robust_av.c | 23 +++++++++++++++++++++++ wpa_supplicant/wpa_supplicant_i.h | 3 +++ 5 files changed, 39 insertions(+) diff --git a/src/common/wpa_ctrl.h b/src/common/wpa_ctrl.h index f5199de9a..4e42c890f 100644 --- a/src/common/wpa_ctrl.h +++ b/src/common/wpa_ctrl.h @@ -126,6 +126,8 @@ extern "C" { #define WPA_EVENT_FREQ_CONFLICT "CTRL-EVENT-FREQ-CONFLICT " /** Frequency ranges that the driver recommends to avoid */ #define WPA_EVENT_AVOID_FREQ "CTRL-EVENT-AVOID-FREQ " +/** Result of MSCS setup */ +#define WPA_EVENT_MSCS_RESULT "CTRL-EVENT-MSCS-RESULT " /** WPS overlap detected in PBC mode */ #define WPS_EVENT_OVERLAP "WPS-OVERLAP-DETECTED " /** Available WPS AP with active PBC found in scan results */ diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c index 14179f79b..2ee34d11d 100644 --- a/src/drivers/driver_nl80211.c +++ b/src/drivers/driver_nl80211.c @@ -2451,6 +2451,10 @@ static int nl80211_mgmt_subscribe_non_ap(struct i802_bss *bss) (nl80211_register_action_frame(bss, (u8 *) "\x05\x02", 2) < 0)) ret = -1; + /* Robust AV MSCS Response */ + if (nl80211_register_action_frame(bss, (u8 *) "\x13\x05", 2) < 0) + ret = -1; + nl80211_mgmt_handle_register_eloop(bss); return ret; diff --git a/wpa_supplicant/events.c b/wpa_supplicant/events.c index bd1af8915..3b169dae4 100644 --- a/wpa_supplicant/events.c +++ b/wpa_supplicant/events.c @@ -4245,6 +4245,13 @@ static void wpas_event_rx_mgmt_action(struct wpa_supplicant *wpa_s, } #endif /* CONFIG_DPP */ + if (category == WLAN_ACTION_ROBUST_AV_STREAMING && + payload[0] == ROBUST_AV_MSCS_RESP) { + wpas_handle_robust_av_recv_action(wpa_s, mgmt->sa, + payload + 1, plen - 1); + return; + } + wpas_p2p_rx_action(wpa_s, mgmt->da, mgmt->sa, mgmt->bssid, category, payload, plen, freq); if (wpa_s->ifmsh) diff --git a/wpa_supplicant/robust_av.c b/wpa_supplicant/robust_av.c index 6bb4e3e95..f7e4100e5 100644 --- a/wpa_supplicant/robust_av.c +++ b/wpa_supplicant/robust_av.c @@ -96,3 +96,26 @@ int wpas_send_mscs_req(struct wpa_supplicant *wpa_s) wpabuf_free(buf); return ret; } + + +void wpas_handle_robust_av_recv_action(struct wpa_supplicant *wpa_s, + const u8 *src, const u8 *buf, size_t len) +{ + u8 dialog_token; + u16 status_code; + + if (len < 3) + return; + + dialog_token = *buf++; + if (dialog_token != wpa_s->robust_av.dialog_token) { + wpa_printf(MSG_INFO, + "MSCS: Drop received frame due to dialog token mismatch: received:%u expected:%u", + dialog_token, wpa_s->robust_av.dialog_token); + return; + } + + status_code = *buf; + wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_MSCS_RESULT "bssid=" MACSTR + " status_code=%u", MAC2STR(src), status_code); +} diff --git a/wpa_supplicant/wpa_supplicant_i.h b/wpa_supplicant/wpa_supplicant_i.h index 44f5f375a..9ed886ff5 100644 --- a/wpa_supplicant/wpa_supplicant_i.h +++ b/wpa_supplicant/wpa_supplicant_i.h @@ -1638,5 +1638,8 @@ void wpas_clear_driver_signal_override(struct wpa_supplicant *wpa_s); int wpas_send_mscs_req(struct wpa_supplicant *wpa_s); void wpas_populate_mscs_descriptor_ie(struct robust_av_data *robust_av, struct wpabuf *buf); +void wpas_handle_robust_av_recv_action(struct wpa_supplicant *wpa_s, + const u8 *src, const u8 *buf, + size_t len); #endif /* WPA_SUPPLICANT_I_H */