1
0
mirror of https://github.com/openbsd/src.git synced 2025-01-10 06:47:55 -08:00

fix 40 MHz channel validation checks for the 2.4 GHz channel range

Just like the 5 GHz channels, 2.4 GHz channels are spaced 5 MHz apart.
40 MHz wide channels hence span channels [N, N + 4] not [N, N + 1].
Adjust our secondary channel range checks accordingly.
This commit is contained in:
stsp 2023-10-22 12:01:36 +00:00
parent 918cd63c4b
commit 243d6ddeb6

View File

@ -1,4 +1,4 @@
/* $OpenBSD: ieee80211_node.c,v 1.197 2023/10/21 06:47:23 stsp Exp $ */ /* $OpenBSD: ieee80211_node.c,v 1.198 2023/10/22 12:01:36 stsp Exp $ */
/* $NetBSD: ieee80211_node.c,v 1.14 2004/05/09 09:18:47 dyoung Exp $ */ /* $NetBSD: ieee80211_node.c,v 1.14 2004/05/09 09:18:47 dyoung Exp $ */
/*- /*-
@ -2396,15 +2396,14 @@ int
ieee80211_40mhz_valid_secondary_above(uint8_t primary_chan) ieee80211_40mhz_valid_secondary_above(uint8_t primary_chan)
{ {
static const uint8_t valid_secondary_chan[] = { static const uint8_t valid_secondary_chan[] = {
2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 5, 6, 7, 8, 9, 10, 11, 12, 13,
40, 48, 56, 64, 104, 112, 120, 128, 136, 144, 153, 161 40, 48, 56, 64, 104, 112, 120, 128, 136, 144, 153, 161
}; };
uint8_t secondary_chan; uint8_t secondary_chan;
int i; int i;
if (primary_chan >= 1 && primary_chan <= 13) if ((primary_chan >= 1 && primary_chan <= 9) ||
secondary_chan = primary_chan + 1; (primary_chan >= 36 && primary_chan <= 157))
else if (primary_chan >= 36 && primary_chan <= 157)
secondary_chan = primary_chan + 4; secondary_chan = primary_chan + 4;
else else
return 0; return 0;
@ -2421,15 +2420,14 @@ int
ieee80211_40mhz_valid_secondary_below(uint8_t primary_chan) ieee80211_40mhz_valid_secondary_below(uint8_t primary_chan)
{ {
static const uint8_t valid_secondary_chan[] = { static const uint8_t valid_secondary_chan[] = {
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 1, 2, 3, 4, 5, 6, 7, 8, 9,
36, 44, 52, 60, 100, 108, 116, 124, 132, 140, 149, 157 36, 44, 52, 60, 100, 108, 116, 124, 132, 140, 149, 157
}; };
int8_t secondary_chan; int8_t secondary_chan;
int i; int i;
if (primary_chan >= 2 && primary_chan <= 14) if ((primary_chan >= 5 && primary_chan <= 13) ||
secondary_chan = primary_chan - 1; (primary_chan >= 40 && primary_chan <= 161))
else if (primary_chan >= 40 && primary_chan <= 161)
secondary_chan = primary_chan - 4; secondary_chan = primary_chan - 4;
else else
return 0; return 0;