From patchwork Tue Feb 7 00:07:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yi-Chia Hsieh X-Patchwork-Id: 1742106 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=v8RFNYVY; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=mediatek.com header.i=@mediatek.com header.a=rsa-sha256 header.s=dk header.b=rGqCu7vQ; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4PGCyz1f48z23yY for ; Tue, 14 Feb 2023 18:49:31 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:CC :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=e0ez4pZ6OUF7V/Hoak7CPWxsQb+abv3e/FepQDb+Pq0=; b=v8RFNYVYsVmdRc sXRwXPVb5aM1CisWXnvFkjiywNTiYL7bjJIhjP05UtWytAcDRiWWZAHesoba+sLHUCOJiN52EwJF7 Z3NfrIAniqNyB25NgUVyamKS4zbbWuJ6r66jAlSLHdZ5VzQuzlGZL+cpJxNg0b4yjDAjw26z1NBFm llXbwHouvuBcGwl1QIxQLQ6rFY2dRy5GnClwFqczBX4T/2wdiO9w5TXyvGja9TOHpLudmF6QmngDH tyHK7AI97ZGnB5AtmF/oM9QPJ82PIkHu2zklTE0CLtJsO2v5myPAB88ee78H6ptrLTr+72PVzldzq kvmv93LQV36/Uh4xul+Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pRq3M-000K4H-Q1; Tue, 14 Feb 2023 07:48:40 +0000 Received: from mailgw02.mediatek.com ([216.200.240.185]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pPBqB-00AGef-VI for hostap@lists.infradead.org; Tue, 07 Feb 2023 00:28:09 +0000 X-UUID: 477732b4a67e11eda08d4d6090ec5a5c-20230206 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:MIME-Version:Message-ID:Date:Subject:CC:To:From; bh=gIPvkJIPrynczNFhV6TB5mwy63zO8FCw1ktkak1AOn4=; b=rGqCu7vQaF8MrSnTdPe5G4sz7H88jtTJcxS5gbt0WMrbzXOXxP/MzqZRUdmXWZBB0p5mIkufQqwsE7ME93uTTZbIwaqfOA/pJJf3Uqbm0FCNVbm+C7rPy/0xO1vx5LpOd1GaUB/+8Tp50jla4mHg81xvf7rjCc3nysrfsASl+XA=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.19,REQID:dd178ff5-4fee-4888-aa26-31b5ca340ba8,IP:0,U RL:0,TC:0,Content:-20,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTIO N:release,TS:-20 X-CID-META: VersionHash:885ddb2,CLOUDID:104c178e-8530-4eff-9f77-222cf6e2895b,B ulkID:nil,BulkQuantity:0,Recheck:0,SF:102,TC:nil,Content:1,EDM:-3,IP:nil,U RL:0,File:nil,Bulk:nil,QS:nil,BEC:nil,COL:0,OSI:0,OSA:0,AV:0 X-CID-BVR: 0 X-UUID: 477732b4a67e11eda08d4d6090ec5a5c-20230206 Received: from mtkmbs11n1.mediatek.inc [(172.21.101.185)] by mailgw02.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 246887655; Mon, 06 Feb 2023 17:28:01 -0700 Received: from mtkmbs13n1.mediatek.inc (172.21.101.193) by mtkmbs13n1.mediatek.inc (172.21.101.193) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.792.15; Tue, 7 Feb 2023 08:07:58 +0800 Received: from mussdccf250.mussds.eus.mediatek.inc (10.73.250.250) by mtkmbs13n1.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.792.15 via Frontend Transport; Tue, 7 Feb 2023 08:07:56 +0800 From: Yi-Chia Hsieh To: Jouni Malinen CC: Felix Fietkau , Lorenzo Bianconi , Ryder Lee , Shayne Chen , Evelyn Tsai , Money Wang , , Yi-Chia Hsieh Subject: [PATCH] WNM: Support for BSS Color Collision and BSS Color In Use of WNM event report Date: Mon, 6 Feb 2023 16:07:56 -0800 Message-ID: <20230207000756.8358-1-yi-chia.hsieh@mediatek.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230206_162808_059132_75D0AD05 X-CRM114-Status: GOOD ( 12.65 ) X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Add support for WNM event report to handle BSS Color Collision and In Use event. Co-developed-by: Ryder Lee Signed-off-by: Yi-Chia Hsieh Signed-off-by: Ryder Lee --- src/ap/wnm_ap.c | 78 +++++++++++++++ [...] Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.0 UNPARSEABLE_RELAY Informational: message has unparseable relay lines X-Mailman-Approved-At: Mon, 13 Feb 2023 23:48:39 -0800 X-BeenThere: hostap@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Hostap" Errors-To: hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Add support for WNM event report to handle BSS Color Collision and In Use event. Co-developed-by: Ryder Lee Signed-off-by: Yi-Chia Hsieh Signed-off-by: Ryder Lee --- src/ap/wnm_ap.c | 78 ++++++++++++++++++++++++++++++++++++ src/common/ieee802_11_defs.h | 35 ++++++++++++++++ 2 files changed, 113 insertions(+) diff --git a/src/ap/wnm_ap.c b/src/ap/wnm_ap.c index 23a352c9b..92f7e56ae 100644 --- a/src/ap/wnm_ap.c +++ b/src/ap/wnm_ap.c @@ -643,6 +643,80 @@ static void ieee802_11_rx_wnm_coloc_intf_report(struct hostapd_data *hapd, } + +static const char *wnm_event_type2str(enum wnm_event_report_type wtype) +{ +#define W2S(wtype) case WNM_EVENT_TYPE_ ## wtype: return #wtype; + switch (wtype) { + W2S(TRANSITION) + W2S(RSNA) + W2S(P2P_LINK) + W2S(WNM_LOG) + W2S(BSS_COLOR_COLLISION) + W2S(BSS_COLOR_INUSE) + } + return "UNKNOWN"; +#undef W2S +} + + +static void ieee802_11_rx_wnm_event_report(struct hostapd_data *hapd, + const u8 *addr, const u8 *buf, + size_t len) +{ + struct sta_info *sta; + u8 dialog_token; + struct wnm_event_report_element *report_ie; + + if (len < 6) { + wpa_printf(MSG_DEBUG, "WNM: Ignore too short WNM Event Report frame from " + MACSTR, MAC2STR(addr)); + return; + } + + dialog_token = *buf++; + report_ie = (struct wnm_event_report_element *) buf; + + if (report_ie->eid != WLAN_EID_EVENT_REPORT) + return; + + if (report_ie->status != WNM_STATUS_SUCCESSFUL) + return; + + wpa_printf(MSG_DEBUG, "WNM: Received WNM Event Report frame from " + MACSTR " dialog_token=%u autonomous=%s type=%d (%s)", + MAC2STR(addr), dialog_token, (!report_ie->token) ? "true" : "false", + report_ie->type, wnm_event_type2str(report_ie->type)); + + wpa_hexdump(MSG_MSGDUMP, "WNM: Event Report", + buf, len); + + sta = ap_get_sta(hapd, addr); + if (!sta) { + wpa_printf(MSG_DEBUG, "Station " MACSTR + " not found for received WNM Event Report", + MAC2STR(addr)); + return; + } + + switch (report_ie->type) { + case WNM_EVENT_TYPE_BSS_COLOR_COLLISION: + hostapd_switch_color(hapd->iface->bss[0], + report_ie->u.bss_color_collision.color_bitmap); + return; + case WNM_EVENT_TYPE_BSS_COLOR_INUSE: + if (report_ie->u.bss_color_inuse.color > 0 && + report_ie->u.bss_color_inuse.color < 64) + hapd->color_collision_bitmap |= + (1ULL << report_ie->u.bss_color_inuse.color); + return; + default: + wpa_printf(MSG_DEBUG, "WNM Event Report type=%d(%s) not supported", + report_ie->type, wnm_event_type2str(report_ie->type)); + } +} + + int ieee802_11_rx_wnm_action_ap(struct hostapd_data *hapd, const struct ieee80211_mgmt *mgmt, size_t len) { @@ -658,6 +732,10 @@ int ieee802_11_rx_wnm_action_ap(struct hostapd_data *hapd, plen = len - IEEE80211_HDRLEN - 2; switch (action) { + case WNM_EVENT_REPORT: + ieee802_11_rx_wnm_event_report(hapd, mgmt->sa, payload, + plen); + return 0; case WNM_BSS_TRANS_MGMT_QUERY: ieee802_11_rx_bss_trans_mgmt_query(hapd, mgmt->sa, payload, plen); diff --git a/src/common/ieee802_11_defs.h b/src/common/ieee802_11_defs.h index 21b48ac52..edbe60393 100644 --- a/src/common/ieee802_11_defs.h +++ b/src/common/ieee802_11_defs.h @@ -1959,6 +1959,41 @@ enum wnm_notification_Type { WNM_NOTIF_TYPE_VENDOR_SPECIFIC = 221, }; +struct wnm_event_report_element { + u8 eid; /* WLAN_EID_EVENT_REPORT */ + u8 len; + u8 token; + u8 type; + u8 status; + union { + struct { + u8 tsf[8]; + u64 color_bitmap; + } STRUCT_PACKED bss_color_collision; + struct { + u8 tsf[8]; + u8 color; + } STRUCT_PACKED bss_color_inuse; + } u; +} STRUCT_PACKED; + +enum wnm_event_report_status { + WNM_STATUS_SUCCESSFUL = 0, + WNM_STATUS_REQ_FAILED = 1, + WNM_STATUS_REQ_REFUSED = 2, + WNM_STATUS_REQ_INCAPABLE = 3, + WNM_STATUS_FREQUENT_TRANSITION = 4, +}; + +enum wnm_event_report_type { + WNM_EVENT_TYPE_TRANSITION = 0, + WNM_EVENT_TYPE_RSNA = 1, + WNM_EVENT_TYPE_P2P_LINK = 2, + WNM_EVENT_TYPE_WNM_LOG = 3, + WNM_EVENT_TYPE_BSS_COLOR_COLLISION = 4, + WNM_EVENT_TYPE_BSS_COLOR_INUSE = 5, +}; + /* Channel Switch modes (802.11h) */ #define CHAN_SWITCH_MODE_ALLOW_TX 0 #define CHAN_SWITCH_MODE_BLOCK_TX 1