[PATCH wireless-next v4 07/21] wifi: ieee80211: define API to check if frame is class 3

From: Pooventhiran G

Date: Fri Nov 06 2026 - 03:04:46 EST


IEEE Std 802.11-2024, subclause 11.3.3, classifies a list of frames as
class 3 and these frames are expected only if the STAs are at least
authenticated and associated. Define an API to check if a frame is class
3 according to these conditions. This can be used to filter frames in
both TX and RX. The API simply classifies the listed frames as class 3
and does not check if the STAs are in expected states.

Signed-off-by: Pooventhiran G <pooventhiran.g@xxxxxxxxxxxxxxxx>
---
include/linux/ieee80211.h | 43 +++++++++++++++++++++++++++++++++++++++++++
1 file changed, 43 insertions(+)

diff --git a/include/linux/ieee80211.h b/include/linux/ieee80211.h
index b2c90c4b262d..3754401f3435 100644
--- a/include/linux/ieee80211.h
+++ b/include/linux/ieee80211.h
@@ -2940,4 +2940,47 @@ struct ieee80211_cip_cap {
u8 v;
} __packed;

+/**
+ * ieee80211_is_class3 - check if this frame @skb is a class 3 frame
+ * @skb: frame to check
+ *
+ * This function checks the frame class simply based on the list defined in
+ * IEEE Std 802.11-2024, subclause 11.3.3. It does not verify whether the frame
+ * is unicast or related STA states.
+ *
+ * Return: %true if it is class3, %false otherwise
+ */
+static inline bool ieee80211_is_class3(struct sk_buff *skb)
+{
+ struct ieee80211_mgmt *mgmt = (void *)skb->data;
+ __le16 fc = mgmt->frame_control;
+ u8 category;
+
+ /* Data frames */
+ if (ieee80211_is_data(fc))
+ return true;
+
+ /* Management frames */
+ if (ieee80211_is_action(fc)) {
+ if (ieee80211_has_protected(fc))
+ return true;
+
+ if (skb->len < IEEE80211_MIN_ACTION_SIZE(category))
+ return false;
+ category = mgmt->u.action.category;
+
+ if (category != WLAN_CATEGORY_PUBLIC &&
+ category != WLAN_CATEGORY_SELF_PROTECTED &&
+ category != WLAN_CATEGORY_UNPROT_DMG)
+ return true;
+ }
+
+ /* Control frames */
+ if (ieee80211_is_back(fc) || ieee80211_is_back_req(fc) ||
+ ieee80211_is_pspoll(fc))
+ return true;
+
+ return false;
+}
+
#endif /* LINUX_IEEE80211_H */

--
2.34.1