aboutsummaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorAdrian Chadd <adrian@FreeBSD.org>2022-08-12 20:56:00 +0000
committerAdrian Chadd <adrian@FreeBSD.org>2022-08-14 16:48:06 +0000
commit2889cbe29e30cc03412e4727b4ad753950094c32 (patch)
tree17dbd6d83a47fa331aeec9ae2efbab86cfb04cf4 /sys
parent016aeb7ca0a54109b63b6379386c4cbb828c7da3 (diff)
downloadsrc-2889cbe29e30cc03412e4727b4ad753950094c32.tar.gz
src-2889cbe29e30cc03412e4727b4ad753950094c32.zip
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
Diffstat (limited to 'sys')
-rw-r--r--sys/net80211/ieee80211.h3
-rw-r--r--sys/net80211/ieee80211_adhoc.c4
-rw-r--r--sys/net80211/ieee80211_hostap.c4
-rw-r--r--sys/net80211/ieee80211_mesh.c2
-rw-r--r--sys/net80211/ieee80211_output.c2
-rw-r--r--sys/net80211/ieee80211_proto.c2
-rw-r--r--sys/net80211/ieee80211_sta.c4
-rw-r--r--sys/net80211/ieee80211_wds.c4
8 files changed, 14 insertions, 11 deletions
diff --git a/sys/net80211/ieee80211.h b/sys/net80211/ieee80211.h
index 715bb3da898e..1125810ee6ac 100644
--- a/sys/net80211/ieee80211.h
+++ b/sys/net80211/ieee80211.h
@@ -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 && \
diff --git a/sys/net80211/ieee80211_adhoc.c b/sys/net80211/ieee80211_adhoc.c
index 57e46dd5ad0b..6aa66db59cac 100644
--- a/sys/net80211/ieee80211_adhoc.c
+++ b/sys/net80211/ieee80211_adhoc.c
@@ -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 */
diff --git a/sys/net80211/ieee80211_hostap.c b/sys/net80211/ieee80211_hostap.c
index f3a85848fc84..17c1de6c2894 100644
--- a/sys/net80211/ieee80211_hostap.c
+++ b/sys/net80211/ieee80211_hostap.c
@@ -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
diff --git a/sys/net80211/ieee80211_mesh.c b/sys/net80211/ieee80211_mesh.c
index 8dcbfa918e3b..6d1f5a99fda5 100644
--- a/sys/net80211/ieee80211_mesh.c
+++ b/sys/net80211/ieee80211_mesh.c
@@ -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 */
diff --git a/sys/net80211/ieee80211_output.c b/sys/net80211/ieee80211_output.c
index 69d25d5b1ba2..17904672a72b 100644
--- a/sys/net80211/ieee80211_output.c
+++ b/sys/net80211/ieee80211_output.c
@@ -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;
diff --git a/sys/net80211/ieee80211_proto.c b/sys/net80211/ieee80211_proto.c
index 0e485590abd0..01da0c2a0768 100644
--- a/sys/net80211/ieee80211_proto.c
+++ b/sys/net80211/ieee80211_proto.c
@@ -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);
diff --git a/sys/net80211/ieee80211_sta.c b/sys/net80211/ieee80211_sta.c
index 9e103f6877c4..3bc6a2bdb3bb 100644
--- a/sys/net80211/ieee80211_sta.c
+++ b/sys/net80211/ieee80211_sta.c
@@ -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
diff --git a/sys/net80211/ieee80211_wds.c b/sys/net80211/ieee80211_wds.c
index 464e658797e6..debe89436d3d 100644
--- a/sys/net80211/ieee80211_wds.c
+++ b/sys/net80211/ieee80211_wds.c
@@ -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 */