git: c8c12a517b31 - stable/14 - LinuxKPI: 802.11: move functions between header files
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 09 Oct 2024 23:13:49 UTC
The branch stable/14 has been updated by bz: URL: https://cgit.FreeBSD.org/src/commit/?id=c8c12a517b311b7159d6d31ee4c0c252b9469a4e commit c8c12a517b311b7159d6d31ee4c0c252b9469a4e Author: Bjoern A. Zeeb <bz@FreeBSD.org> AuthorDate: 2024-09-27 17:47:30 +0000 Commit: Bjoern A. Zeeb <bz@FreeBSD.org> CommitDate: 2024-10-09 19:18:58 +0000 LinuxKPI: 802.11: move functions between header files Move some ieee8022_{is,has,get}_... functions working on header fields from mac80211.h to ieee80211.h to avoid problems with #includes. No functional changes. Sponsored by: The FreeBSD Foundation (cherry picked from commit 0b325167f60def621536632460caf68e2fab4fb8) --- .../linuxkpi/common/include/linux/ieee80211.h | 351 +++++++++++++++++++++ sys/compat/linuxkpi/common/include/net/mac80211.h | 341 -------------------- 2 files changed, 351 insertions(+), 341 deletions(-) diff --git a/sys/compat/linuxkpi/common/include/linux/ieee80211.h b/sys/compat/linuxkpi/common/include/linux/ieee80211.h index 9a43a571d390..ce6a18f798d1 100644 --- a/sys/compat/linuxkpi/common/include/linux/ieee80211.h +++ b/sys/compat/linuxkpi/common/include/linux/ieee80211.h @@ -37,6 +37,14 @@ #include <linux/bitops.h> #include <linux/if_ether.h> +/* linux_80211.c */ +extern int linuxkpi_debug_80211; +#ifndef D80211_TODO +#define D80211_TODO 0x1 +#endif +#define TODO(...) if (linuxkpi_debug_80211 & D80211_TODO) \ + printf("%s:%d: XXX LKPI80211 TODO\n", __func__, __LINE__) + /* 9.4.2.55 Management MIC element (CMAC-256, GMAC-128, and GMAC-256). */ struct ieee80211_mmie_16 { @@ -853,4 +861,347 @@ ieee80211_is_trigger(__le16 fc) return (fc == v); } +static __inline bool +ieee80211_is_action(__le16 fc) +{ + __le16 v; + + fc &= htole16(IEEE80211_FC0_SUBTYPE_MASK | IEEE80211_FC0_TYPE_MASK); + v = htole16(IEEE80211_FC0_SUBTYPE_ACTION | IEEE80211_FC0_TYPE_MGT); + + return (fc == v); +} + +static __inline bool +ieee80211_is_probe_resp(__le16 fc) +{ + __le16 v; + + fc &= htole16(IEEE80211_FC0_SUBTYPE_MASK | IEEE80211_FC0_TYPE_MASK); + v = htole16(IEEE80211_FC0_SUBTYPE_PROBE_RESP | IEEE80211_FC0_TYPE_MGT); + + return (fc == v); +} + +static __inline bool +ieee80211_is_auth(__le16 fc) +{ + __le16 v; + + fc &= htole16(IEEE80211_FC0_SUBTYPE_MASK | IEEE80211_FC0_TYPE_MASK); + v = htole16(IEEE80211_FC0_SUBTYPE_AUTH | IEEE80211_FC0_TYPE_MGT); + + return (fc == v); +} + +static __inline bool +ieee80211_is_assoc_req(__le16 fc) +{ + __le16 v; + + fc &= htole16(IEEE80211_FC0_SUBTYPE_MASK | IEEE80211_FC0_TYPE_MASK); + v = htole16(IEEE80211_FC0_SUBTYPE_ASSOC_REQ | IEEE80211_FC0_TYPE_MGT); + + return (fc == v); +} + +static __inline bool +ieee80211_is_assoc_resp(__le16 fc) +{ + __le16 v; + + fc &= htole16(IEEE80211_FC0_SUBTYPE_MASK | IEEE80211_FC0_TYPE_MASK); + v = htole16(IEEE80211_FC0_SUBTYPE_ASSOC_RESP | IEEE80211_FC0_TYPE_MGT); + + return (fc == v); +} + +static __inline bool +ieee80211_is_reassoc_req(__le16 fc) +{ + __le16 v; + + fc &= htole16(IEEE80211_FC0_SUBTYPE_MASK | IEEE80211_FC0_TYPE_MASK); + v = htole16(IEEE80211_FC0_SUBTYPE_REASSOC_REQ | IEEE80211_FC0_TYPE_MGT); + + return (fc == v); +} + +static __inline bool +ieee80211_is_reassoc_resp(__le16 fc) +{ + __le16 v; + + fc &= htole16(IEEE80211_FC0_SUBTYPE_MASK | IEEE80211_FC0_TYPE_MASK); + v = htole16(IEEE80211_FC0_SUBTYPE_REASSOC_RESP | IEEE80211_FC0_TYPE_MGT); + + return (fc == v); +} + +static __inline bool +ieee80211_is_disassoc(__le16 fc) +{ + __le16 v; + + fc &= htole16(IEEE80211_FC0_SUBTYPE_MASK | IEEE80211_FC0_TYPE_MASK); + v = htole16(IEEE80211_FC0_SUBTYPE_DISASSOC | IEEE80211_FC0_TYPE_MGT); + + return (fc == v); +} + +static __inline bool +ieee80211_is_data_present(__le16 fc) +{ + __le16 v; + + /* If it is a data frame and NODATA is not present. */ + fc &= htole16(IEEE80211_FC0_TYPE_MASK | IEEE80211_FC0_SUBTYPE_NODATA); + v = htole16(IEEE80211_FC0_TYPE_DATA); + + return (fc == v); +} + +static __inline bool +ieee80211_is_deauth(__le16 fc) +{ + __le16 v; + + fc &= htole16(IEEE80211_FC0_SUBTYPE_MASK | IEEE80211_FC0_TYPE_MASK); + v = htole16(IEEE80211_FC0_SUBTYPE_DEAUTH | IEEE80211_FC0_TYPE_MGT); + + return (fc == v); +} + +static __inline bool +ieee80211_is_beacon(__le16 fc) +{ + __le16 v; + + /* + * For as much as I get it this comes in LE and unlike FreeBSD + * where we get the entire frame header and u8[], here we get the + * 9.2.4.1 Frame Control field only. Mask and compare. + */ + fc &= htole16(IEEE80211_FC0_SUBTYPE_MASK | IEEE80211_FC0_TYPE_MASK); + v = htole16(IEEE80211_FC0_SUBTYPE_BEACON | IEEE80211_FC0_TYPE_MGT); + + return (fc == v); +} + + +static __inline bool +ieee80211_is_probe_req(__le16 fc) +{ + __le16 v; + + fc &= htole16(IEEE80211_FC0_SUBTYPE_MASK | IEEE80211_FC0_TYPE_MASK); + v = htole16(IEEE80211_FC0_SUBTYPE_PROBE_REQ | IEEE80211_FC0_TYPE_MGT); + + return (fc == v); +} + +static __inline bool +ieee80211_has_protected(__le16 fc) +{ + + return (fc & htole16(IEEE80211_FC1_PROTECTED << 8)); +} + +static __inline bool +ieee80211_is_back_req(__le16 fc) +{ + __le16 v; + + fc &= htole16(IEEE80211_FC0_SUBTYPE_MASK | IEEE80211_FC0_TYPE_MASK); + v = htole16(IEEE80211_FC0_SUBTYPE_BAR | IEEE80211_FC0_TYPE_CTL); + + return (fc == v); +} + +static __inline bool +ieee80211_is_bufferable_mmpdu(struct sk_buff *skb) +{ + struct ieee80211_mgmt *mgmt; + __le16 fc; + + mgmt = (struct ieee80211_mgmt *)skb->data; + fc = mgmt->frame_control; + + /* 11.2.2 Bufferable MMPDUs, 80211-2020. */ + /* XXX we do not care about IBSS yet. */ + + if (!ieee80211_is_mgmt(fc)) + return (false); + if (ieee80211_is_action(fc)) /* XXX FTM? */ + return (true); /* XXX false? */ + if (ieee80211_is_disassoc(fc)) + return (true); + if (ieee80211_is_deauth(fc)) + return (true); + + TODO(); + + return (false); +} + +static __inline bool +ieee80211_is_nullfunc(__le16 fc) +{ + __le16 v; + + fc &= htole16(IEEE80211_FC0_SUBTYPE_MASK | IEEE80211_FC0_TYPE_MASK); + v = htole16(IEEE80211_FC0_SUBTYPE_NODATA | IEEE80211_FC0_TYPE_DATA); + + return (fc == v); +} + +static __inline bool +ieee80211_is_qos_nullfunc(__le16 fc) +{ + __le16 v; + + fc &= htole16(IEEE80211_FC0_SUBTYPE_MASK | IEEE80211_FC0_TYPE_MASK); + v = htole16(IEEE80211_FC0_SUBTYPE_QOS_NULL | IEEE80211_FC0_TYPE_DATA); + + return (fc == v); +} + +static __inline bool +ieee80211_is_any_nullfunc(__le16 fc) +{ + + return (ieee80211_is_nullfunc(fc) || ieee80211_is_qos_nullfunc(fc)); +} + +static inline bool +ieee80211_is_pspoll(__le16 fc) +{ + __le16 v; + + fc &= htole16(IEEE80211_FC0_SUBTYPE_MASK | IEEE80211_FC0_TYPE_MASK); + v = htole16(IEEE80211_FC0_SUBTYPE_PS_POLL | IEEE80211_FC0_TYPE_CTL); + + return (fc == v); +} + +static __inline bool +ieee80211_has_a4(__le16 fc) +{ + __le16 v; + + fc &= htole16((IEEE80211_FC1_DIR_TODS | IEEE80211_FC1_DIR_FROMDS) << 8); + v = htole16((IEEE80211_FC1_DIR_TODS | IEEE80211_FC1_DIR_FROMDS) << 8); + + return (fc == v); +} + +static __inline bool +ieee80211_has_order(__le16 fc) +{ + + return (fc & htole16(IEEE80211_FC1_ORDER << 8)); +} + +static __inline bool +ieee80211_has_retry(__le16 fc) +{ + + return (fc & htole16(IEEE80211_FC1_RETRY << 8)); +} + + +static __inline bool +ieee80211_has_fromds(__le16 fc) +{ + + return (fc & htole16(IEEE80211_FC1_DIR_FROMDS << 8)); +} + +static __inline bool +ieee80211_has_tods(__le16 fc) +{ + + return (fc & htole16(IEEE80211_FC1_DIR_TODS << 8)); +} + +static __inline uint8_t * +ieee80211_get_SA(struct ieee80211_hdr *hdr) +{ + + if (ieee80211_has_a4(hdr->frame_control)) + return (hdr->addr4); + if (ieee80211_has_fromds(hdr->frame_control)) + return (hdr->addr3); + return (hdr->addr2); +} + +static __inline uint8_t * +ieee80211_get_DA(struct ieee80211_hdr *hdr) +{ + + if (ieee80211_has_tods(hdr->frame_control)) + return (hdr->addr3); + return (hdr->addr1); +} + +static __inline bool +ieee80211_is_frag(struct ieee80211_hdr *hdr) +{ + TODO(); + return (false); +} + +static __inline bool +ieee80211_is_first_frag(__le16 fc) +{ + TODO(); + return (false); +} + +static __inline bool +ieee80211_is_robust_mgmt_frame(struct sk_buff *skb) +{ + TODO(); + return (false); +} + +static __inline bool +ieee80211_is_ftm(struct sk_buff *skb) +{ + TODO(); + return (false); +} + +static __inline bool +ieee80211_is_timing_measurement(struct sk_buff *skb) +{ + TODO(); + return (false); +} + +static __inline bool +ieee80211_has_pm(__le16 fc) +{ + TODO(); + return (false); +} + +static __inline bool +ieee80211_has_morefrags(__le16 fc) +{ + + fc &= htole16(IEEE80211_FC1_MORE_FRAG << 8); + return (fc != 0); +} + +static __inline u8 * +ieee80211_get_qos_ctl(struct ieee80211_hdr *hdr) +{ + if (ieee80211_has_a4(hdr->frame_control)) + return (u8 *)hdr + 30; + else + return (u8 *)hdr + 24; +} + + #endif /* _LINUXKPI_LINUX_IEEE80211_H */ diff --git a/sys/compat/linuxkpi/common/include/net/mac80211.h b/sys/compat/linuxkpi/common/include/net/mac80211.h index 29fb335a8db9..c3b07b68090a 100644 --- a/sys/compat/linuxkpi/common/include/net/mac80211.h +++ b/sys/compat/linuxkpi/common/include/net/mac80211.h @@ -1260,229 +1260,6 @@ ieee80211_hw_restart_disconnect(struct ieee80211_vif *vif) /* -------------------------------------------------------------------------- */ -static __inline bool -ieee80211_is_action(__le16 fc) -{ - __le16 v; - - fc &= htole16(IEEE80211_FC0_SUBTYPE_MASK | IEEE80211_FC0_TYPE_MASK); - v = htole16(IEEE80211_FC0_SUBTYPE_ACTION | IEEE80211_FC0_TYPE_MGT); - - return (fc == v); -} - -static __inline bool -ieee80211_is_probe_resp(__le16 fc) -{ - __le16 v; - - fc &= htole16(IEEE80211_FC0_SUBTYPE_MASK | IEEE80211_FC0_TYPE_MASK); - v = htole16(IEEE80211_FC0_SUBTYPE_PROBE_RESP | IEEE80211_FC0_TYPE_MGT); - - return (fc == v); -} - -static __inline bool -ieee80211_is_auth(__le16 fc) -{ - __le16 v; - - fc &= htole16(IEEE80211_FC0_SUBTYPE_MASK | IEEE80211_FC0_TYPE_MASK); - v = htole16(IEEE80211_FC0_SUBTYPE_AUTH | IEEE80211_FC0_TYPE_MGT); - - return (fc == v); -} - -static __inline bool -ieee80211_is_assoc_req(__le16 fc) -{ - __le16 v; - - fc &= htole16(IEEE80211_FC0_SUBTYPE_MASK | IEEE80211_FC0_TYPE_MASK); - v = htole16(IEEE80211_FC0_SUBTYPE_ASSOC_REQ | IEEE80211_FC0_TYPE_MGT); - - return (fc == v); -} - -static __inline bool -ieee80211_is_assoc_resp(__le16 fc) -{ - __le16 v; - - fc &= htole16(IEEE80211_FC0_SUBTYPE_MASK | IEEE80211_FC0_TYPE_MASK); - v = htole16(IEEE80211_FC0_SUBTYPE_ASSOC_RESP | IEEE80211_FC0_TYPE_MGT); - - return (fc == v); -} - -static __inline bool -ieee80211_is_reassoc_req(__le16 fc) -{ - __le16 v; - - fc &= htole16(IEEE80211_FC0_SUBTYPE_MASK | IEEE80211_FC0_TYPE_MASK); - v = htole16(IEEE80211_FC0_SUBTYPE_REASSOC_REQ | IEEE80211_FC0_TYPE_MGT); - - return (fc == v); -} - -static __inline bool -ieee80211_is_reassoc_resp(__le16 fc) -{ - __le16 v; - - fc &= htole16(IEEE80211_FC0_SUBTYPE_MASK | IEEE80211_FC0_TYPE_MASK); - v = htole16(IEEE80211_FC0_SUBTYPE_REASSOC_RESP | IEEE80211_FC0_TYPE_MGT); - - return (fc == v); -} - -static __inline bool -ieee80211_is_disassoc(__le16 fc) -{ - __le16 v; - - fc &= htole16(IEEE80211_FC0_SUBTYPE_MASK | IEEE80211_FC0_TYPE_MASK); - v = htole16(IEEE80211_FC0_SUBTYPE_DISASSOC | IEEE80211_FC0_TYPE_MGT); - - return (fc == v); -} - -static __inline bool -ieee80211_is_data_present(__le16 fc) -{ - __le16 v; - - /* If it is a data frame and NODATA is not present. */ - fc &= htole16(IEEE80211_FC0_TYPE_MASK | IEEE80211_FC0_SUBTYPE_NODATA); - v = htole16(IEEE80211_FC0_TYPE_DATA); - - return (fc == v); -} - -static __inline bool -ieee80211_is_deauth(__le16 fc) -{ - __le16 v; - - fc &= htole16(IEEE80211_FC0_SUBTYPE_MASK | IEEE80211_FC0_TYPE_MASK); - v = htole16(IEEE80211_FC0_SUBTYPE_DEAUTH | IEEE80211_FC0_TYPE_MGT); - - return (fc == v); -} - -static __inline bool -ieee80211_is_beacon(__le16 fc) -{ - __le16 v; - - /* - * For as much as I get it this comes in LE and unlike FreeBSD - * where we get the entire frame header and u8[], here we get the - * 9.2.4.1 Frame Control field only. Mask and compare. - */ - fc &= htole16(IEEE80211_FC0_SUBTYPE_MASK | IEEE80211_FC0_TYPE_MASK); - v = htole16(IEEE80211_FC0_SUBTYPE_BEACON | IEEE80211_FC0_TYPE_MGT); - - return (fc == v); -} - - -static __inline bool -ieee80211_is_probe_req(__le16 fc) -{ - __le16 v; - - fc &= htole16(IEEE80211_FC0_SUBTYPE_MASK | IEEE80211_FC0_TYPE_MASK); - v = htole16(IEEE80211_FC0_SUBTYPE_PROBE_REQ | IEEE80211_FC0_TYPE_MGT); - - return (fc == v); -} - -static __inline bool -ieee80211_has_protected(__le16 fc) -{ - - return (fc & htole16(IEEE80211_FC1_PROTECTED << 8)); -} - -static __inline bool -ieee80211_is_back_req(__le16 fc) -{ - __le16 v; - - fc &= htole16(IEEE80211_FC0_SUBTYPE_MASK | IEEE80211_FC0_TYPE_MASK); - v = htole16(IEEE80211_FC0_SUBTYPE_BAR | IEEE80211_FC0_TYPE_CTL); - - return (fc == v); -} - -static __inline bool -ieee80211_is_bufferable_mmpdu(struct sk_buff *skb) -{ - struct ieee80211_mgmt *mgmt; - __le16 fc; - - mgmt = (struct ieee80211_mgmt *)skb->data; - fc = mgmt->frame_control; - - /* 11.2.2 Bufferable MMPDUs, 80211-2020. */ - /* XXX we do not care about IBSS yet. */ - - if (!ieee80211_is_mgmt(fc)) - return (false); - if (ieee80211_is_action(fc)) /* XXX FTM? */ - return (true); /* XXX false? */ - if (ieee80211_is_disassoc(fc)) - return (true); - if (ieee80211_is_deauth(fc)) - return (true); - - TODO(); - - return (false); -} - -static __inline bool -ieee80211_is_nullfunc(__le16 fc) -{ - __le16 v; - - fc &= htole16(IEEE80211_FC0_SUBTYPE_MASK | IEEE80211_FC0_TYPE_MASK); - v = htole16(IEEE80211_FC0_SUBTYPE_NODATA | IEEE80211_FC0_TYPE_DATA); - - return (fc == v); -} - -static __inline bool -ieee80211_is_qos_nullfunc(__le16 fc) -{ - __le16 v; - - fc &= htole16(IEEE80211_FC0_SUBTYPE_MASK | IEEE80211_FC0_TYPE_MASK); - v = htole16(IEEE80211_FC0_SUBTYPE_QOS_NULL | IEEE80211_FC0_TYPE_DATA); - - return (fc == v); -} - -static __inline bool -ieee80211_is_any_nullfunc(__le16 fc) -{ - - return (ieee80211_is_nullfunc(fc) || ieee80211_is_qos_nullfunc(fc)); -} - -static inline bool -ieee80211_is_pspoll(__le16 fc) -{ - __le16 v; - - fc &= htole16(IEEE80211_FC0_SUBTYPE_MASK | IEEE80211_FC0_TYPE_MASK); - v = htole16(IEEE80211_FC0_SUBTYPE_PS_POLL | IEEE80211_FC0_TYPE_CTL); - - return (fc == v); -} - static __inline bool ieee80211_vif_is_mesh(struct ieee80211_vif *vif) { @@ -1490,124 +1267,6 @@ ieee80211_vif_is_mesh(struct ieee80211_vif *vif) return (false); } -static __inline bool -ieee80211_is_frag(struct ieee80211_hdr *hdr) -{ - TODO(); - return (false); -} - -static __inline bool -ieee80211_is_first_frag(__le16 fc) -{ - TODO(); - return (false); -} - -static __inline bool -ieee80211_is_robust_mgmt_frame(struct sk_buff *skb) -{ - TODO(); - return (false); -} - -static __inline bool -ieee80211_is_ftm(struct sk_buff *skb) -{ - TODO(); - return (false); -} - -static __inline bool -ieee80211_is_timing_measurement(struct sk_buff *skb) -{ - TODO(); - return (false); -} - -static __inline bool -ieee80211_has_pm(__le16 fc) -{ - TODO(); - return (false); -} - -static __inline bool -ieee80211_has_a4(__le16 fc) -{ - __le16 v; - - fc &= htole16((IEEE80211_FC1_DIR_TODS | IEEE80211_FC1_DIR_FROMDS) << 8); - v = htole16((IEEE80211_FC1_DIR_TODS | IEEE80211_FC1_DIR_FROMDS) << 8); - - return (fc == v); -} - -static __inline bool -ieee80211_has_order(__le16 fc) -{ - - return (fc & htole16(IEEE80211_FC1_ORDER << 8)); -} - -static __inline bool -ieee80211_has_retry(__le16 fc) -{ - - return (fc & htole16(IEEE80211_FC1_RETRY << 8)); -} - - -static __inline bool -ieee80211_has_fromds(__le16 fc) -{ - - return (fc & htole16(IEEE80211_FC1_DIR_FROMDS << 8)); -} - -static __inline bool -ieee80211_has_tods(__le16 fc) -{ - - return (fc & htole16(IEEE80211_FC1_DIR_TODS << 8)); -} - -static __inline uint8_t * -ieee80211_get_SA(struct ieee80211_hdr *hdr) -{ - - if (ieee80211_has_a4(hdr->frame_control)) - return (hdr->addr4); - if (ieee80211_has_fromds(hdr->frame_control)) - return (hdr->addr3); - return (hdr->addr2); -} - -static __inline uint8_t * -ieee80211_get_DA(struct ieee80211_hdr *hdr) -{ - - if (ieee80211_has_tods(hdr->frame_control)) - return (hdr->addr3); - return (hdr->addr1); -} - -static __inline bool -ieee80211_has_morefrags(__le16 fc) -{ - - fc &= htole16(IEEE80211_FC1_MORE_FRAG << 8); - return (fc != 0); -} - -static __inline u8 * -ieee80211_get_qos_ctl(struct ieee80211_hdr *hdr) -{ - if (ieee80211_has_a4(hdr->frame_control)) - return (u8 *)hdr + 30; - else - return (u8 *)hdr + 24; -} /* -------------------------------------------------------------------------- */ /* Receive functions (air/driver to mac80211/net80211). */