blob: b4ad3caef6087701875e37dbea7ae8846207027a [file] [log] [blame]
Dmitry Shmidt29333592017-01-09 12:27:11 -08001/*
2 * Operating classes
3 * Copyright(c) 2015 Intel Deutschland GmbH
4 * Contact Information:
5 * Intel Linux Wireless <ilw@linux.intel.com>
6 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
7 *
8 * This software may be distributed under the terms of the BSD license.
9 * See README for more details.
10 */
11
12#include "utils/includes.h"
13
14#include "utils/common.h"
15#include "common/ieee802_11_common.h"
16#include "wpa_supplicant_i.h"
Hai Shalomfdcde762020-04-02 11:19:20 -070017#include "bss.h"
Dmitry Shmidt29333592017-01-09 12:27:11 -080018
19
Hai Shalomc3565922019-10-28 11:58:20 -070020static enum chan_allowed allow_channel(struct hostapd_hw_modes *mode,
21 u8 op_class, u8 chan,
Dmitry Shmidt29333592017-01-09 12:27:11 -080022 unsigned int *flags)
23{
24 int i;
Hai Shalom60840252021-02-19 19:02:11 -080025 bool is_6ghz = op_class >= 131 && op_class <= 136;
Dmitry Shmidt29333592017-01-09 12:27:11 -080026
27 for (i = 0; i < mode->num_channels; i++) {
Hai Shalom60840252021-02-19 19:02:11 -080028 bool chan_is_6ghz;
Hai Shalomc3565922019-10-28 11:58:20 -070029
Kai Shic1745342020-09-09 11:31:57 -070030 chan_is_6ghz = mode->channels[i].freq >= 5935 &&
31 mode->channels[i].freq <= 7115;
Hai Shalomc3565922019-10-28 11:58:20 -070032 if (is_6ghz == chan_is_6ghz && mode->channels[i].chan == chan)
Dmitry Shmidt29333592017-01-09 12:27:11 -080033 break;
34 }
35
36 if (i == mode->num_channels ||
37 (mode->channels[i].flag & HOSTAPD_CHAN_DISABLED))
38 return NOT_ALLOWED;
39
40 if (flags)
41 *flags = mode->channels[i].flag;
42
43 if (mode->channels[i].flag & HOSTAPD_CHAN_NO_IR)
44 return NO_IR;
45
46 return ALLOWED;
47}
48
49
Hai Shalom60840252021-02-19 19:02:11 -080050static int get_center_80mhz(struct hostapd_hw_modes *mode, u8 channel,
51 const u8 *center_channels, size_t num_chan)
Dmitry Shmidt29333592017-01-09 12:27:11 -080052{
Dmitry Shmidt29333592017-01-09 12:27:11 -080053 size_t i;
54
55 if (mode->mode != HOSTAPD_MODE_IEEE80211A)
56 return 0;
57
Hai Shalom60840252021-02-19 19:02:11 -080058 for (i = 0; i < num_chan; i++) {
Dmitry Shmidt29333592017-01-09 12:27:11 -080059 /*
60 * In 80 MHz, the bandwidth "spans" 12 channels (e.g., 36-48),
61 * so the center channel is 6 channels away from the start/end.
62 */
63 if (channel >= center_channels[i] - 6 &&
64 channel <= center_channels[i] + 6)
65 return center_channels[i];
66 }
67
68 return 0;
69}
70
71
Hai Shalomc3565922019-10-28 11:58:20 -070072static enum chan_allowed verify_80mhz(struct hostapd_hw_modes *mode,
73 u8 op_class, u8 channel)
Dmitry Shmidt29333592017-01-09 12:27:11 -080074{
75 u8 center_chan;
76 unsigned int i;
77 unsigned int no_ir = 0;
Hai Shalom60840252021-02-19 19:02:11 -080078 const u8 *center_channels;
79 size_t num_chan;
80 const u8 center_channels_5ghz[] = { 42, 58, 106, 122, 138, 155, 171 };
81 const u8 center_channels_6ghz[] = { 7, 23, 39, 55, 71, 87, 103, 119,
82 135, 151, 167, 183, 199, 215 };
Dmitry Shmidt29333592017-01-09 12:27:11 -080083
Hai Shalom60840252021-02-19 19:02:11 -080084 if (is_6ghz_op_class(op_class)) {
85 center_channels = center_channels_6ghz;
86 num_chan = ARRAY_SIZE(center_channels_6ghz);
87 } else {
88 center_channels = center_channels_5ghz;
89 num_chan = ARRAY_SIZE(center_channels_5ghz);
90 }
91
92 center_chan = get_center_80mhz(mode, channel, center_channels,
93 num_chan);
Dmitry Shmidt29333592017-01-09 12:27:11 -080094 if (!center_chan)
95 return NOT_ALLOWED;
96
97 /* check all the channels are available */
98 for (i = 0; i < 4; i++) {
99 unsigned int flags;
100 u8 adj_chan = center_chan - 6 + i * 4;
101
Hai Shalomc3565922019-10-28 11:58:20 -0700102 if (allow_channel(mode, op_class, adj_chan, &flags) ==
103 NOT_ALLOWED)
Dmitry Shmidt29333592017-01-09 12:27:11 -0800104 return NOT_ALLOWED;
105
Sunil Raviaf8751c2023-03-29 11:35:17 -0700106 if (!(flags & HOSTAPD_CHAN_VHT_80MHZ_SUBCHANNEL))
Dmitry Shmidt29333592017-01-09 12:27:11 -0800107 return NOT_ALLOWED;
108
109 if (flags & HOSTAPD_CHAN_NO_IR)
110 no_ir = 1;
111 }
112
113 if (no_ir)
114 return NO_IR;
115
116 return ALLOWED;
117}
118
119
Hai Shalom60840252021-02-19 19:02:11 -0800120static int get_center_160mhz(struct hostapd_hw_modes *mode, u8 channel,
121 const u8 *center_channels, size_t num_chan)
Dmitry Shmidt29333592017-01-09 12:27:11 -0800122{
Dmitry Shmidt29333592017-01-09 12:27:11 -0800123 unsigned int i;
124
125 if (mode->mode != HOSTAPD_MODE_IEEE80211A)
126 return 0;
127
Hai Shalom60840252021-02-19 19:02:11 -0800128 for (i = 0; i < num_chan; i++) {
Dmitry Shmidt29333592017-01-09 12:27:11 -0800129 /*
130 * In 160 MHz, the bandwidth "spans" 28 channels (e.g., 36-64),
131 * so the center channel is 14 channels away from the start/end.
132 */
133 if (channel >= center_channels[i] - 14 &&
134 channel <= center_channels[i] + 14)
135 return center_channels[i];
136 }
137
138 return 0;
139}
140
141
142static enum chan_allowed verify_160mhz(struct hostapd_hw_modes *mode,
Hai Shalomc3565922019-10-28 11:58:20 -0700143 u8 op_class, u8 channel)
Dmitry Shmidt29333592017-01-09 12:27:11 -0800144{
145 u8 center_chan;
146 unsigned int i;
147 unsigned int no_ir = 0;
Hai Shalom60840252021-02-19 19:02:11 -0800148 const u8 *center_channels;
149 size_t num_chan;
150 const u8 center_channels_5ghz[] = { 50, 114, 163 };
151 const u8 center_channels_6ghz[] = { 15, 47, 79, 111, 143, 175, 207 };
Dmitry Shmidt29333592017-01-09 12:27:11 -0800152
Hai Shalom60840252021-02-19 19:02:11 -0800153 if (is_6ghz_op_class(op_class)) {
154 center_channels = center_channels_6ghz;
155 num_chan = ARRAY_SIZE(center_channels_6ghz);
156 } else {
157 center_channels = center_channels_5ghz;
158 num_chan = ARRAY_SIZE(center_channels_5ghz);
159 }
160
161 center_chan = get_center_160mhz(mode, channel, center_channels,
162 num_chan);
Dmitry Shmidt29333592017-01-09 12:27:11 -0800163 if (!center_chan)
164 return NOT_ALLOWED;
165
166 /* Check all the channels are available */
167 for (i = 0; i < 8; i++) {
168 unsigned int flags;
169 u8 adj_chan = center_chan - 14 + i * 4;
170
Hai Shalomc3565922019-10-28 11:58:20 -0700171 if (allow_channel(mode, op_class, adj_chan, &flags) ==
172 NOT_ALLOWED)
Dmitry Shmidt29333592017-01-09 12:27:11 -0800173 return NOT_ALLOWED;
174
Sunil Raviaf8751c2023-03-29 11:35:17 -0700175 if (!(flags & HOSTAPD_CHAN_VHT_80MHZ_SUBCHANNEL) ||
176 !(flags & HOSTAPD_CHAN_VHT_160MHZ_SUBCHANNEL))
Dmitry Shmidt29333592017-01-09 12:27:11 -0800177 return NOT_ALLOWED;
178
179 if (flags & HOSTAPD_CHAN_NO_IR)
180 no_ir = 1;
181 }
182
183 if (no_ir)
184 return NO_IR;
185
186 return ALLOWED;
187}
188
189
Hai Shalomc3565922019-10-28 11:58:20 -0700190enum chan_allowed verify_channel(struct hostapd_hw_modes *mode, u8 op_class,
191 u8 channel, u8 bw)
Dmitry Shmidt29333592017-01-09 12:27:11 -0800192{
193 unsigned int flag = 0;
194 enum chan_allowed res, res2;
195
Hai Shalomc3565922019-10-28 11:58:20 -0700196 res2 = res = allow_channel(mode, op_class, channel, &flag);
Hai Shalom60840252021-02-19 19:02:11 -0800197 if (bw == BW40MINUS || (bw == BW40 && (((channel - 1) / 4) % 2))) {
Dmitry Shmidt29333592017-01-09 12:27:11 -0800198 if (!(flag & HOSTAPD_CHAN_HT40MINUS))
199 return NOT_ALLOWED;
Hai Shalomc3565922019-10-28 11:58:20 -0700200 res2 = allow_channel(mode, op_class, channel - 4, NULL);
Hai Shaloma20dcd72022-02-04 13:43:00 -0800201 } else if (bw == BW40PLUS) {
Dmitry Shmidt29333592017-01-09 12:27:11 -0800202 if (!(flag & HOSTAPD_CHAN_HT40PLUS))
203 return NOT_ALLOWED;
Hai Shalomc3565922019-10-28 11:58:20 -0700204 res2 = allow_channel(mode, op_class, channel + 4, NULL);
Hai Shaloma20dcd72022-02-04 13:43:00 -0800205 } else if (is_6ghz_op_class(op_class) && bw == BW40) {
206 if (get_6ghz_sec_channel(channel) < 0)
207 res2 = allow_channel(mode, op_class, channel - 4, NULL);
208 else
209 res2 = allow_channel(mode, op_class, channel + 4, NULL);
Dmitry Shmidt29333592017-01-09 12:27:11 -0800210 } else if (bw == BW80) {
211 /*
212 * channel is a center channel and as such, not necessarily a
213 * valid 20 MHz channels. Override earlier allow_channel()
214 * result and use only the 80 MHz specific version.
215 */
Hai Shalomc3565922019-10-28 11:58:20 -0700216 res2 = res = verify_80mhz(mode, op_class, channel);
Dmitry Shmidt29333592017-01-09 12:27:11 -0800217 } else if (bw == BW160) {
218 /*
219 * channel is a center channel and as such, not necessarily a
220 * valid 20 MHz channels. Override earlier allow_channel()
221 * result and use only the 160 MHz specific version.
222 */
Hai Shalomc3565922019-10-28 11:58:20 -0700223 res2 = res = verify_160mhz(mode, op_class, channel);
Dmitry Shmidt29333592017-01-09 12:27:11 -0800224 } else if (bw == BW80P80) {
225 /*
226 * channel is a center channel and as such, not necessarily a
227 * valid 20 MHz channels. Override earlier allow_channel()
228 * result and use only the 80 MHz specific version.
229 */
Hai Shalomc3565922019-10-28 11:58:20 -0700230 res2 = res = verify_80mhz(mode, op_class, channel);
Dmitry Shmidt29333592017-01-09 12:27:11 -0800231 }
232
233 if (res == NOT_ALLOWED || res2 == NOT_ALLOWED)
234 return NOT_ALLOWED;
235
236 if (res == NO_IR || res2 == NO_IR)
237 return NO_IR;
238
239 return ALLOWED;
240}
241
242
243static int wpas_op_class_supported(struct wpa_supplicant *wpa_s,
Hai Shalom74f70d42019-02-11 14:42:39 -0800244 struct wpa_ssid *ssid,
Dmitry Shmidt29333592017-01-09 12:27:11 -0800245 const struct oper_class_map *op_class)
246{
247 int chan;
248 size_t i;
249 struct hostapd_hw_modes *mode;
250 int found;
Hai Shalom74f70d42019-02-11 14:42:39 -0800251 int z;
252 int freq2 = 0;
253 int freq5 = 0;
Dmitry Shmidt29333592017-01-09 12:27:11 -0800254
Hai Shalomfdcde762020-04-02 11:19:20 -0700255 mode = get_mode(wpa_s->hw.modes, wpa_s->hw.num_modes, op_class->mode,
256 is_6ghz_op_class(op_class->op_class));
Dmitry Shmidt29333592017-01-09 12:27:11 -0800257 if (!mode)
258 return 0;
259
Hai Shalom74f70d42019-02-11 14:42:39 -0800260 /* If we are configured to disable certain things, take that into
261 * account here. */
Hai Shalomc3565922019-10-28 11:58:20 -0700262 if (ssid && ssid->freq_list && ssid->freq_list[0]) {
Hai Shalom74f70d42019-02-11 14:42:39 -0800263 for (z = 0; ; z++) {
264 int f = ssid->freq_list[z];
265
266 if (f == 0)
267 break; /* end of list */
268 if (f > 4000 && f < 6000)
269 freq5 = 1;
270 else if (f > 2400 && f < 2500)
271 freq2 = 1;
272 }
273 } else {
274 /* No frequencies specified, can use anything hardware supports.
275 */
276 freq2 = freq5 = 1;
277 }
278
279 if (op_class->op_class >= 115 && op_class->op_class <= 130 && !freq5)
280 return 0;
281 if (op_class->op_class >= 81 && op_class->op_class <= 84 && !freq2)
282 return 0;
283
284#ifdef CONFIG_HT_OVERRIDES
Hai Shalomc3565922019-10-28 11:58:20 -0700285 if (ssid && ssid->disable_ht) {
Hai Shalom74f70d42019-02-11 14:42:39 -0800286 switch (op_class->op_class) {
287 case 83:
288 case 84:
289 case 104:
290 case 105:
291 case 116:
292 case 117:
293 case 119:
294 case 120:
295 case 122:
296 case 123:
297 case 126:
298 case 127:
299 case 128:
300 case 129:
301 case 130:
302 /* Disable >= 40 MHz channels if HT is disabled */
303 return 0;
304 }
305 }
306#endif /* CONFIG_HT_OVERRIDES */
307
308#ifdef CONFIG_VHT_OVERRIDES
Hai Shalomc3565922019-10-28 11:58:20 -0700309 if (ssid && ssid->disable_vht) {
Hai Shalom74f70d42019-02-11 14:42:39 -0800310 if (op_class->op_class >= 128 && op_class->op_class <= 130) {
311 /* Disable >= 80 MHz channels if VHT is disabled */
312 return 0;
313 }
314 }
315#endif /* CONFIG_VHT_OVERRIDES */
316
Dmitry Shmidt29333592017-01-09 12:27:11 -0800317 if (op_class->op_class == 128) {
Hai Shalom60840252021-02-19 19:02:11 -0800318 u8 channels[] = { 42, 58, 106, 122, 138, 155, 171 };
Dmitry Shmidt29333592017-01-09 12:27:11 -0800319
320 for (i = 0; i < ARRAY_SIZE(channels); i++) {
Hai Shalomc3565922019-10-28 11:58:20 -0700321 if (verify_channel(mode, op_class->op_class,
322 channels[i], op_class->bw) !=
Dmitry Shmidt29333592017-01-09 12:27:11 -0800323 NOT_ALLOWED)
324 return 1;
325 }
326
327 return 0;
328 }
329
330 if (op_class->op_class == 129) {
331 /* Check if either 160 MHz channels is allowed */
Hai Shalomc3565922019-10-28 11:58:20 -0700332 return verify_channel(mode, op_class->op_class, 50,
333 op_class->bw) != NOT_ALLOWED ||
334 verify_channel(mode, op_class->op_class, 114,
Hai Shalom60840252021-02-19 19:02:11 -0800335 op_class->bw) != NOT_ALLOWED ||
336 verify_channel(mode, op_class->op_class, 163,
Hai Shalomc3565922019-10-28 11:58:20 -0700337 op_class->bw) != NOT_ALLOWED;
Dmitry Shmidt29333592017-01-09 12:27:11 -0800338 }
339
340 if (op_class->op_class == 130) {
341 /* Need at least two non-contiguous 80 MHz segments */
342 found = 0;
343
Hai Shalomc3565922019-10-28 11:58:20 -0700344 if (verify_channel(mode, op_class->op_class, 42,
345 op_class->bw) != NOT_ALLOWED ||
346 verify_channel(mode, op_class->op_class, 58,
347 op_class->bw) != NOT_ALLOWED)
Dmitry Shmidt29333592017-01-09 12:27:11 -0800348 found++;
Hai Shalomc3565922019-10-28 11:58:20 -0700349 if (verify_channel(mode, op_class->op_class, 106,
350 op_class->bw) != NOT_ALLOWED ||
351 verify_channel(mode, op_class->op_class, 122,
352 op_class->bw) != NOT_ALLOWED ||
353 verify_channel(mode, op_class->op_class, 138,
Hai Shalom60840252021-02-19 19:02:11 -0800354 op_class->bw) != NOT_ALLOWED ||
355 verify_channel(mode, op_class->op_class, 155,
356 op_class->bw) != NOT_ALLOWED ||
357 verify_channel(mode, op_class->op_class, 171,
Hai Shalomc3565922019-10-28 11:58:20 -0700358 op_class->bw) != NOT_ALLOWED)
Dmitry Shmidt29333592017-01-09 12:27:11 -0800359 found++;
Hai Shalomc3565922019-10-28 11:58:20 -0700360 if (verify_channel(mode, op_class->op_class, 106,
361 op_class->bw) != NOT_ALLOWED &&
362 verify_channel(mode, op_class->op_class, 138,
363 op_class->bw) != NOT_ALLOWED)
Dmitry Shmidt29333592017-01-09 12:27:11 -0800364 found++;
Hai Shalom60840252021-02-19 19:02:11 -0800365 if (verify_channel(mode, op_class->op_class, 122,
366 op_class->bw) != NOT_ALLOWED &&
367 verify_channel(mode, op_class->op_class, 155,
368 op_class->bw) != NOT_ALLOWED)
369 found++;
370 if (verify_channel(mode, op_class->op_class, 138,
371 op_class->bw) != NOT_ALLOWED &&
372 verify_channel(mode, op_class->op_class, 171,
Hai Shalomc3565922019-10-28 11:58:20 -0700373 op_class->bw) != NOT_ALLOWED)
Dmitry Shmidt29333592017-01-09 12:27:11 -0800374 found++;
375
376 if (found >= 2)
377 return 1;
378
379 return 0;
380 }
381
Hai Shalom60840252021-02-19 19:02:11 -0800382 if (op_class->op_class == 135) {
383 /* Need at least two 80 MHz segments which do not fall under the
384 * same 160 MHz segment to support 80+80 in 6 GHz.
385 */
386 int first_seg = 0;
387 int curr_seg = 0;
388
389 for (chan = op_class->min_chan; chan <= op_class->max_chan;
390 chan += op_class->inc) {
391 curr_seg++;
392 if (verify_channel(mode, op_class->op_class, chan,
393 op_class->bw) != NOT_ALLOWED) {
394 if (!first_seg) {
395 first_seg = curr_seg;
396 continue;
397 }
398
399 /* Supported if at least two non-consecutive 80
400 * MHz segments allowed.
401 */
402 if ((curr_seg - first_seg) > 1)
403 return 1;
404
405 /* Supported even if the 80 MHz segments are
406 * consecutive when they do not fall under the
407 * same 160 MHz segment.
408 */
409 if ((first_seg % 2) == 0)
410 return 1;
411 }
412 }
413
414 return 0;
415 }
416
Dmitry Shmidt29333592017-01-09 12:27:11 -0800417 found = 0;
418 for (chan = op_class->min_chan; chan <= op_class->max_chan;
419 chan += op_class->inc) {
Hai Shalomc3565922019-10-28 11:58:20 -0700420 if (verify_channel(mode, op_class->op_class, chan,
421 op_class->bw) != NOT_ALLOWED) {
Dmitry Shmidt29333592017-01-09 12:27:11 -0800422 found = 1;
423 break;
424 }
425 }
426
427 return found;
428}
429
430
Hai Shalomfdcde762020-04-02 11:19:20 -0700431static int wpas_sta_secondary_channel_offset(struct wpa_bss *bss, u8 *current,
432 u8 *channel)
433{
434
Hai Shalom60840252021-02-19 19:02:11 -0800435 const u8 *ies;
436 u8 phy_type;
Hai Shalomfdcde762020-04-02 11:19:20 -0700437 size_t ies_len;
438
439 if (!bss)
440 return -1;
Hai Shalom60840252021-02-19 19:02:11 -0800441 ies = wpa_bss_ie_ptr(bss);
Hai Shalomfdcde762020-04-02 11:19:20 -0700442 ies_len = bss->ie_len ? bss->ie_len : bss->beacon_ie_len;
443 return wpas_get_op_chan_phy(bss->freq, ies, ies_len, current,
444 channel, &phy_type);
445}
446
447
Hai Shalom74f70d42019-02-11 14:42:39 -0800448size_t wpas_supp_op_class_ie(struct wpa_supplicant *wpa_s,
449 struct wpa_ssid *ssid,
Hai Shalomfdcde762020-04-02 11:19:20 -0700450 struct wpa_bss *bss, u8 *pos, size_t len)
Dmitry Shmidt29333592017-01-09 12:27:11 -0800451{
452 struct wpabuf *buf;
453 u8 op, current, chan;
454 u8 *ie_len;
455 size_t res;
456
457 /*
Hai Shalomfdcde762020-04-02 11:19:20 -0700458 * Determine the current operating class correct mode based on
459 * advertised BSS capabilities, if available. Fall back to a less
460 * accurate guess based on frequency if the needed IEs are not available
461 * or used.
Dmitry Shmidt29333592017-01-09 12:27:11 -0800462 */
Hai Shalomfdcde762020-04-02 11:19:20 -0700463 if (wpas_sta_secondary_channel_offset(bss, &current, &chan) < 0 &&
Sunil8cd6f4d2022-06-28 18:40:46 +0000464 ieee80211_freq_to_channel_ext(bss->freq, 0,
465 CONF_OPER_CHWIDTH_USE_HT, &current,
466 &chan) == NUM_HOSTAPD_MODES)
Dmitry Shmidt29333592017-01-09 12:27:11 -0800467 return 0;
468
469 /*
470 * Need 3 bytes for EID, length, and current operating class, plus
471 * 1 byte for every other supported operating class.
472 */
473 buf = wpabuf_alloc(global_op_class_size + 3);
474 if (!buf)
475 return 0;
476
477 wpabuf_put_u8(buf, WLAN_EID_SUPPORTED_OPERATING_CLASSES);
478 /* Will set the length later, putting a placeholder */
479 ie_len = wpabuf_put(buf, 1);
480 wpabuf_put_u8(buf, current);
481
482 for (op = 0; global_op_class[op].op_class; op++) {
Hai Shalom74f70d42019-02-11 14:42:39 -0800483 if (wpas_op_class_supported(wpa_s, ssid, &global_op_class[op]))
Dmitry Shmidt29333592017-01-09 12:27:11 -0800484 wpabuf_put_u8(buf, global_op_class[op].op_class);
485 }
486
487 *ie_len = wpabuf_len(buf) - 2;
Hai Shalom899fcc72020-10-19 14:38:18 -0700488 if (*ie_len < 2) {
489 wpa_printf(MSG_DEBUG,
490 "No supported operating classes IE to add");
491 res = 0;
492 } else if (wpabuf_len(buf) > len) {
Dmitry Shmidt29333592017-01-09 12:27:11 -0800493 wpa_printf(MSG_ERROR,
Hai Shalom899fcc72020-10-19 14:38:18 -0700494 "Supported operating classes IE exceeds maximum buffer length");
Dmitry Shmidt29333592017-01-09 12:27:11 -0800495 res = 0;
496 } else {
497 os_memcpy(pos, wpabuf_head(buf), wpabuf_len(buf));
498 res = wpabuf_len(buf);
499 wpa_hexdump_buf(MSG_DEBUG,
500 "Added supported operating classes IE", buf);
501 }
502
503 wpabuf_free(buf);
504 return res;
505}
Hai Shalomc3565922019-10-28 11:58:20 -0700506
507
508int * wpas_supp_op_classes(struct wpa_supplicant *wpa_s)
509{
510 int op;
511 unsigned int pos, max_num = 0;
512 int *classes;
513
514 for (op = 0; global_op_class[op].op_class; op++)
515 max_num++;
516 classes = os_zalloc((max_num + 1) * sizeof(int));
517 if (!classes)
518 return NULL;
519
520 for (op = 0, pos = 0; global_op_class[op].op_class; op++) {
521 if (wpas_op_class_supported(wpa_s, NULL, &global_op_class[op]))
522 classes[pos++] = global_op_class[op].op_class;
523 }
524
525 return classes;
526}