net80211: add an IEEE80211_IS_PROTECTED() macro

Summary: This returns whether the given 802.11 frame has the protected bit set.

Test Plan:
* tested in AP/STA mode
* STA mode - local athp/ath10k driver
* AP mode - in tree ath driver

Subscribers: imp, melifaro, glebius
Reviewed by: bz
Approved by: bz

Differential Revision: https://reviews.freebsd.org/D36183
This commit is contained in:
Adrian Chadd 2022-08-12 13:56:00 -07:00
parent 016aeb7ca0
commit 2889cbe29e
8 changed files with 14 additions and 11 deletions

View File

@ -196,6 +196,9 @@ struct ieee80211_qosframe_addr4 {
#define IEEE80211_FC1_PROTECTED 0x40
#define IEEE80211_FC1_ORDER 0x80
#define IEEE80211_IS_PROTECTED(wh) \
((wh)->i_fc[1] & IEEE80211_FC1_PROTECTED)
#define IEEE80211_HAS_SEQ(type, subtype) \
((type) != IEEE80211_FC0_TYPE_CTL && \
!((type) == IEEE80211_FC0_TYPE_DATA && \

View File

@ -495,7 +495,7 @@ adhoc_input(struct ieee80211_node *ni, struct mbuf *m,
* crypto cipher modules used to do delayed update
* of replay sequence numbers.
*/
if (is_hw_decrypted || wh->i_fc[1] & IEEE80211_FC1_PROTECTED) {
if (is_hw_decrypted || IEEE80211_IS_PROTECTED(wh)) {
if ((vap->iv_flags & IEEE80211_F_PRIVACY) == 0) {
/*
* Discard encrypted frames when privacy is off.
@ -655,7 +655,7 @@ adhoc_input(struct ieee80211_node *ni, struct mbuf *m,
ether_sprintf(wh->i_addr2), rssi);
}
#endif
if (wh->i_fc[1] & IEEE80211_FC1_PROTECTED) {
if (IEEE80211_IS_PROTECTED(wh)) {
IEEE80211_DISCARD(vap, IEEE80211_MSG_INPUT,
wh, NULL, "%s", "WEP set but not permitted");
vap->iv_stats.is_rx_mgtdiscard++; /* XXX */

View File

@ -683,7 +683,7 @@ hostap_input(struct ieee80211_node *ni, struct mbuf *m,
* crypto cipher modules used to do delayed update
* of replay sequence numbers.
*/
if (is_hw_decrypted || wh->i_fc[1] & IEEE80211_FC1_PROTECTED) {
if (is_hw_decrypted || IEEE80211_IS_PROTECTED(wh)) {
if ((vap->iv_flags & IEEE80211_F_PRIVACY) == 0) {
/*
* Discard encrypted frames when privacy is off.
@ -849,7 +849,7 @@ hostap_input(struct ieee80211_node *ni, struct mbuf *m,
ether_sprintf(wh->i_addr2), rssi);
}
#endif
if (wh->i_fc[1] & IEEE80211_FC1_PROTECTED) {
if (IEEE80211_IS_PROTECTED(wh)) {
if (subtype != IEEE80211_FC0_SUBTYPE_AUTH) {
/*
* Only shared key auth frames with a challenge

View File

@ -1797,7 +1797,7 @@ mesh_input(struct ieee80211_node *ni, struct mbuf *m,
ether_sprintf(wh->i_addr2), rssi);
}
#endif
if (wh->i_fc[1] & IEEE80211_FC1_PROTECTED) {
if (IEEE80211_IS_PROTECTED(wh)) {
IEEE80211_DISCARD(vap, IEEE80211_MSG_INPUT,
wh, NULL, "%s", "WEP set but not permitted");
vap->iv_stats.is_rx_mgtdiscard++; /* XXX */

View File

@ -622,7 +622,7 @@ ieee80211_validate_frame(struct mbuf *m,
}
if ((params && (params->ibp_flags & IEEE80211_BPF_CRYPTO) != 0) ||
(wh->i_fc[1] & IEEE80211_FC1_PROTECTED) != 0) {
(IEEE80211_IS_PROTECTED(wh))) {
int subtype;
subtype = wh->i_fc[0] & IEEE80211_FC0_SUBTYPE_MASK;

View File

@ -602,7 +602,7 @@ ieee80211_dump_pkt(struct ieee80211com *ic,
printf(" QoS [TID %u%s]", qwh->i_qos[0] & IEEE80211_QOS_TID,
qwh->i_qos[0] & IEEE80211_QOS_ACKPOLICY ? " ACM" : "");
}
if (wh->i_fc[1] & IEEE80211_FC1_PROTECTED) {
if (IEEE80211_IS_PROTECTED(wh)) {
int off;
off = ieee80211_anyhdrspace(ic, wh);

View File

@ -767,7 +767,7 @@ sta_input(struct ieee80211_node *ni, struct mbuf *m,
* crypto cipher modules used to do delayed update
* of replay sequence numbers.
*/
if (is_hw_decrypted || wh->i_fc[1] & IEEE80211_FC1_PROTECTED) {
if (is_hw_decrypted || IEEE80211_IS_PROTECTED(wh)) {
if ((vap->iv_flags & IEEE80211_F_PRIVACY) == 0) {
/*
* Discard encrypted frames when privacy is off.
@ -939,7 +939,7 @@ sta_input(struct ieee80211_node *ni, struct mbuf *m,
* Again, having encrypted flag set check would be good, but
* then we have to also handle crypto_decap() like above.
*/
if (wh->i_fc[1] & IEEE80211_FC1_PROTECTED) {
if (IEEE80211_IS_PROTECTED(wh)) {
if (subtype != IEEE80211_FC0_SUBTYPE_AUTH) {
/*
* Only shared key auth frames with a challenge

View File

@ -556,7 +556,7 @@ wds_input(struct ieee80211_node *ni, struct mbuf *m,
* crypto cipher modules used to do delayed update
* of replay sequence numbers.
*/
if (is_hw_decrypted || wh->i_fc[1] & IEEE80211_FC1_PROTECTED) {
if (is_hw_decrypted || IEEE80211_IS_PROTECTED(wh)) {
if ((vap->iv_flags & IEEE80211_F_PRIVACY) == 0) {
/*
* Discard encrypted frames when privacy is off.
@ -712,7 +712,7 @@ wds_input(struct ieee80211_node *ni, struct mbuf *m,
ether_sprintf(wh->i_addr2), rssi);
}
#endif
if (wh->i_fc[1] & IEEE80211_FC1_PROTECTED) {
if (IEEE80211_IS_PROTECTED(wh)) {
IEEE80211_DISCARD(vap, IEEE80211_MSG_INPUT,
wh, NULL, "%s", "WEP set but not permitted");
vap->iv_stats.is_rx_mgtdiscard++; /* XXX */