diff mbox series

[1/2] supported op class should take freq-list into account.

Message ID 1535137289-5425-1-git-send-email-greearb@candelatech.com
State Accepted
Headers show
Series [1/2] supported op class should take freq-list into account. | expand

Commit Message

Ben Greear Aug. 24, 2018, 7:01 p.m. UTC
From: Ben Greear <greearb@candelatech.com>

If a station is configured to scan only a subset of frequencies,
then the supported operating classes may need to be more limited
than what the hardware supports.

Signed-off-by: Ben Greear <greearb@candelatech.com>
---
 wpa_supplicant/op_classes.c | 31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)

Comments

Jouni Malinen Jan. 7, 2019, 11:48 p.m. UTC | #1
On Fri, Aug 24, 2018 at 12:01:28PM -0700, greearb@candelatech.com wrote:
> If a station is configured to scan only a subset of frequencies,
> then the supported operating classes may need to be more limited
> than what the hardware supports.

> diff --git a/wpa_supplicant/op_classes.c b/wpa_supplicant/op_classes.c
> @@ -214,11 +215,41 @@ static int wpas_op_class_supported(struct wpa_supplicant *wpa_s,

> +	/* If we are configured to disable certain things, then take that
> +	 * into account here.
> +	 */
> +	if (wpa_s->conf->freq_list && wpa_s->conf->freq_list[0]) {

This does look correct to me. wpa_s->conf->freq_list is a constraint on
which channels are scanned by default, i.e., it does not prevent
association on a not-listed channel. As such, I don't think this should
change the Supported Operating Classes element contents. However, there
is ssid->freq_list that is used to filter BSSs for association based on
the channel. This design seems to work fine with that (after being
rebased on top of the disable_ht/vht patch to get the ssid pointer
here), so I replaced wpa_s->conf with ssid here and applied this.

> +			if (f > 3000)
> +				freq5 = 1;
> +			else if (f < 3000)
> +				freq2 = 1;

With some changes on those ranges as well to avoid strange issues if < 1
GHz, 3.6 GHz, or 60 GHz (etc.) is used.
diff mbox series

Patch

diff --git a/wpa_supplicant/op_classes.c b/wpa_supplicant/op_classes.c
index d23b009..d886134 100644
--- a/wpa_supplicant/op_classes.c
+++ b/wpa_supplicant/op_classes.c
@@ -14,6 +14,7 @@ 
 #include "utils/common.h"
 #include "common/ieee802_11_common.h"
 #include "wpa_supplicant_i.h"
+#include "config.h"
 
 
 static enum chan_allowed allow_channel(struct hostapd_hw_modes *mode, u8 chan,
@@ -214,11 +215,41 @@  static int wpas_op_class_supported(struct wpa_supplicant *wpa_s,
 	size_t i;
 	struct hostapd_hw_modes *mode;
 	int found;
+	int z;
+	int freq2 = 0;
+	int freq5 = 0;
 
 	mode = get_mode(wpa_s->hw.modes, wpa_s->hw.num_modes, op_class->mode);
 	if (!mode)
 		return 0;
 
+	/* If we are configured to disable certain things, then take that
+	 * into account here.
+	 */
+	if (wpa_s->conf->freq_list && wpa_s->conf->freq_list[0]) {
+		z = 0;
+		while (1) {
+			int f = wpa_s->conf->freq_list[z];
+			if (f == 0)
+				break; /* end of list */
+			if (f > 3000)
+				freq5 = 1;
+			else if (f < 3000)
+				freq2 = 1;
+			z++;
+		}
+	}
+	else {
+		/* No frequencies specified, can use anything hardware supports */
+		freq2 = freq5 = 1;
+	}
+	if ((op_class->op_class >= 115) && (op_class->op_class <= 130) && (!freq5)) {
+		return 0;
+	}
+	if ((op_class->op_class <= 84) && (op_class->op_class >= 81) && (!freq2)) {
+		return 0;
+	}
+
 	if (op_class->op_class == 128) {
 		u8 channels[] = { 42, 58, 106, 122, 138, 155 };