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
MFC after:	3 days
This commit is contained in:
Bjoern A. Zeeb
2024-09-27 17:47:30 +00:00
parent 3848dc4fe6
commit 0b325167f6
2 changed files with 351 additions and 341 deletions
@@ -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 */
@@ -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). */