blob: a0ad0c2ff5725ef04892695560494a25b838c378 [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
106 if ((i == 0 && !(flags & HOSTAPD_CHAN_VHT_10_70)) ||
107 (i == 1 && !(flags & HOSTAPD_CHAN_VHT_30_50)) ||
108 (i == 2 && !(flags & HOSTAPD_CHAN_VHT_50_30)) ||
109 (i == 3 && !(flags & HOSTAPD_CHAN_VHT_70_10)))
110 return NOT_ALLOWED;
111
112 if (flags & HOSTAPD_CHAN_NO_IR)
113 no_ir = 1;
114 }
115
116 if (no_ir)
117 return NO_IR;
118
119 return ALLOWED;
120}
121
122
Hai Shalom60840252021-02-19 19:02:11 -0800123static int get_center_160mhz(struct hostapd_hw_modes *mode, u8 channel,
124 const u8 *center_channels, size_t num_chan)
Dmitry Shmidt29333592017-01-09 12:27:11 -0800125{
Dmitry Shmidt29333592017-01-09 12:27:11 -0800126 unsigned int i;
127
128 if (mode->mode != HOSTAPD_MODE_IEEE80211A)
129 return 0;
130
Hai Shalom60840252021-02-19 19:02:11 -0800131 for (i = 0; i < num_chan; i++) {
Dmitry Shmidt29333592017-01-09 12:27:11 -0800132 /*
133 * In 160 MHz, the bandwidth "spans" 28 channels (e.g., 36-64),
134 * so the center channel is 14 channels away from the start/end.
135 */
136 if (channel >= center_channels[i] - 14 &&
137 channel <= center_channels[i] + 14)
138 return center_channels[i];
139 }
140
141 return 0;
142}
143
144
145static enum chan_allowed verify_160mhz(struct hostapd_hw_modes *mode,
Hai Shalomc3565922019-10-28 11:58:20 -0700146 u8 op_class, u8 channel)
Dmitry Shmidt29333592017-01-09 12:27:11 -0800147{
148 u8 center_chan;
149 unsigned int i;
150 unsigned int no_ir = 0;
Hai Shalom60840252021-02-19 19:02:11 -0800151 const u8 *center_channels;
152 size_t num_chan;
153 const u8 center_channels_5ghz[] = { 50, 114, 163 };
154 const u8 center_channels_6ghz[] = { 15, 47, 79, 111, 143, 175, 207 };
Dmitry Shmidt29333592017-01-09 12:27:11 -0800155
Hai Shalom60840252021-02-19 19:02:11 -0800156 if (is_6ghz_op_class(op_class)) {
157 center_channels = center_channels_6ghz;
158 num_chan = ARRAY_SIZE(center_channels_6ghz);
159 } else {
160 center_channels = center_channels_5ghz;
161 num_chan = ARRAY_SIZE(center_channels_5ghz);
162 }
163
164 center_chan = get_center_160mhz(mode, channel, center_channels,
165 num_chan);
Dmitry Shmidt29333592017-01-09 12:27:11 -0800166 if (!center_chan)
167 return NOT_ALLOWED;
168
169 /* Check all the channels are available */
170 for (i = 0; i < 8; i++) {
171 unsigned int flags;
172 u8 adj_chan = center_chan - 14 + i * 4;
173
Hai Shalomc3565922019-10-28 11:58:20 -0700174 if (allow_channel(mode, op_class, adj_chan, &flags) ==
175 NOT_ALLOWED)
Dmitry Shmidt29333592017-01-09 12:27:11 -0800176 return NOT_ALLOWED;
177
178 if ((i == 0 && !(flags & HOSTAPD_CHAN_VHT_10_150)) ||
179 (i == 1 && !(flags & HOSTAPD_CHAN_VHT_30_130)) ||
180 (i == 2 && !(flags & HOSTAPD_CHAN_VHT_50_110)) ||
181 (i == 3 && !(flags & HOSTAPD_CHAN_VHT_70_90)) ||
182 (i == 4 && !(flags & HOSTAPD_CHAN_VHT_90_70)) ||
183 (i == 5 && !(flags & HOSTAPD_CHAN_VHT_110_50)) ||
184 (i == 6 && !(flags & HOSTAPD_CHAN_VHT_130_30)) ||
185 (i == 7 && !(flags & HOSTAPD_CHAN_VHT_150_10)))
186 return NOT_ALLOWED;
187
188 if (flags & HOSTAPD_CHAN_NO_IR)
189 no_ir = 1;
190 }
191
192 if (no_ir)
193 return NO_IR;
194
195 return ALLOWED;
196}
197
198
Hai Shalomc3565922019-10-28 11:58:20 -0700199enum chan_allowed verify_channel(struct hostapd_hw_modes *mode, u8 op_class,
200 u8 channel, u8 bw)
Dmitry Shmidt29333592017-01-09 12:27:11 -0800201{
202 unsigned int flag = 0;
203 enum chan_allowed res, res2;
204
Hai Shalomc3565922019-10-28 11:58:20 -0700205 res2 = res = allow_channel(mode, op_class, channel, &flag);
Hai Shalom60840252021-02-19 19:02:11 -0800206 if (bw == BW40MINUS || (bw == BW40 && (((channel - 1) / 4) % 2))) {
Dmitry Shmidt29333592017-01-09 12:27:11 -0800207 if (!(flag & HOSTAPD_CHAN_HT40MINUS))
208 return NOT_ALLOWED;
Hai Shalomc3565922019-10-28 11:58:20 -0700209 res2 = allow_channel(mode, op_class, channel - 4, NULL);
Hai Shalom60840252021-02-19 19:02:11 -0800210 } else if (bw == BW40PLUS ||
211 (bw == BW40 && !(((channel - 1) / 4) % 2))) {
Dmitry Shmidt29333592017-01-09 12:27:11 -0800212 if (!(flag & HOSTAPD_CHAN_HT40PLUS))
213 return NOT_ALLOWED;
Hai Shalomc3565922019-10-28 11:58:20 -0700214 res2 = allow_channel(mode, op_class, channel + 4, NULL);
Dmitry Shmidt29333592017-01-09 12:27:11 -0800215 } else if (bw == BW80) {
216 /*
217 * channel is a center channel and as such, not necessarily a
218 * valid 20 MHz channels. Override earlier allow_channel()
219 * result and use only the 80 MHz specific version.
220 */
Hai Shalomc3565922019-10-28 11:58:20 -0700221 res2 = res = verify_80mhz(mode, op_class, channel);
Dmitry Shmidt29333592017-01-09 12:27:11 -0800222 } else if (bw == BW160) {
223 /*
224 * channel is a center channel and as such, not necessarily a
225 * valid 20 MHz channels. Override earlier allow_channel()
226 * result and use only the 160 MHz specific version.
227 */
Hai Shalomc3565922019-10-28 11:58:20 -0700228 res2 = res = verify_160mhz(mode, op_class, channel);
Dmitry Shmidt29333592017-01-09 12:27:11 -0800229 } else if (bw == BW80P80) {
230 /*
231 * channel is a center channel and as such, not necessarily a
232 * valid 20 MHz channels. Override earlier allow_channel()
233 * result and use only the 80 MHz specific version.
234 */
Hai Shalomc3565922019-10-28 11:58:20 -0700235 res2 = res = verify_80mhz(mode, op_class, channel);
Dmitry Shmidt29333592017-01-09 12:27:11 -0800236 }
237
238 if (res == NOT_ALLOWED || res2 == NOT_ALLOWED)
239 return NOT_ALLOWED;
240
241 if (res == NO_IR || res2 == NO_IR)
242 return NO_IR;
243
244 return ALLOWED;
245}
246
247
248static int wpas_op_class_supported(struct wpa_supplicant *wpa_s,
Hai Shalom74f70d42019-02-11 14:42:39 -0800249 struct wpa_ssid *ssid,
Dmitry Shmidt29333592017-01-09 12:27:11 -0800250 const struct oper_class_map *op_class)
251{
252 int chan;
253 size_t i;
254 struct hostapd_hw_modes *mode;
255 int found;
Hai Shalom74f70d42019-02-11 14:42:39 -0800256 int z;
257 int freq2 = 0;
258 int freq5 = 0;
Dmitry Shmidt29333592017-01-09 12:27:11 -0800259
Hai Shalomfdcde762020-04-02 11:19:20 -0700260 mode = get_mode(wpa_s->hw.modes, wpa_s->hw.num_modes, op_class->mode,
261 is_6ghz_op_class(op_class->op_class));
Dmitry Shmidt29333592017-01-09 12:27:11 -0800262 if (!mode)
263 return 0;
264
Hai Shalom74f70d42019-02-11 14:42:39 -0800265 /* If we are configured to disable certain things, take that into
266 * account here. */
Hai Shalomc3565922019-10-28 11:58:20 -0700267 if (ssid && ssid->freq_list && ssid->freq_list[0]) {
Hai Shalom74f70d42019-02-11 14:42:39 -0800268 for (z = 0; ; z++) {
269 int f = ssid->freq_list[z];
270
271 if (f == 0)
272 break; /* end of list */
273 if (f > 4000 && f < 6000)
274 freq5 = 1;
275 else if (f > 2400 && f < 2500)
276 freq2 = 1;
277 }
278 } else {
279 /* No frequencies specified, can use anything hardware supports.
280 */
281 freq2 = freq5 = 1;
282 }
283
284 if (op_class->op_class >= 115 && op_class->op_class <= 130 && !freq5)
285 return 0;
286 if (op_class->op_class >= 81 && op_class->op_class <= 84 && !freq2)
287 return 0;
288
289#ifdef CONFIG_HT_OVERRIDES
Hai Shalomc3565922019-10-28 11:58:20 -0700290 if (ssid && ssid->disable_ht) {
Hai Shalom74f70d42019-02-11 14:42:39 -0800291 switch (op_class->op_class) {
292 case 83:
293 case 84:
294 case 104:
295 case 105:
296 case 116:
297 case 117:
298 case 119:
299 case 120:
300 case 122:
301 case 123:
302 case 126:
303 case 127:
304 case 128:
305 case 129:
306 case 130:
307 /* Disable >= 40 MHz channels if HT is disabled */
308 return 0;
309 }
310 }
311#endif /* CONFIG_HT_OVERRIDES */
312
313#ifdef CONFIG_VHT_OVERRIDES
Hai Shalomc3565922019-10-28 11:58:20 -0700314 if (ssid && ssid->disable_vht) {
Hai Shalom74f70d42019-02-11 14:42:39 -0800315 if (op_class->op_class >= 128 && op_class->op_class <= 130) {
316 /* Disable >= 80 MHz channels if VHT is disabled */
317 return 0;
318 }
319 }
320#endif /* CONFIG_VHT_OVERRIDES */
321
Dmitry Shmidt29333592017-01-09 12:27:11 -0800322 if (op_class->op_class == 128) {
Hai Shalom60840252021-02-19 19:02:11 -0800323 u8 channels[] = { 42, 58, 106, 122, 138, 155, 171 };
Dmitry Shmidt29333592017-01-09 12:27:11 -0800324
325 for (i = 0; i < ARRAY_SIZE(channels); i++) {
Hai Shalomc3565922019-10-28 11:58:20 -0700326 if (verify_channel(mode, op_class->op_class,
327 channels[i], op_class->bw) !=
Dmitry Shmidt29333592017-01-09 12:27:11 -0800328 NOT_ALLOWED)
329 return 1;
330 }
331
332 return 0;
333 }
334
335 if (op_class->op_class == 129) {
336 /* Check if either 160 MHz channels is allowed */
Hai Shalomc3565922019-10-28 11:58:20 -0700337 return verify_channel(mode, op_class->op_class, 50,
338 op_class->bw) != NOT_ALLOWED ||
339 verify_channel(mode, op_class->op_class, 114,
Hai Shalom60840252021-02-19 19:02:11 -0800340 op_class->bw) != NOT_ALLOWED ||
341 verify_channel(mode, op_class->op_class, 163,
Hai Shalomc3565922019-10-28 11:58:20 -0700342 op_class->bw) != NOT_ALLOWED;
Dmitry Shmidt29333592017-01-09 12:27:11 -0800343 }
344
345 if (op_class->op_class == 130) {
346 /* Need at least two non-contiguous 80 MHz segments */
347 found = 0;
348
Hai Shalomc3565922019-10-28 11:58:20 -0700349 if (verify_channel(mode, op_class->op_class, 42,
350 op_class->bw) != NOT_ALLOWED ||
351 verify_channel(mode, op_class->op_class, 58,
352 op_class->bw) != NOT_ALLOWED)
Dmitry Shmidt29333592017-01-09 12:27:11 -0800353 found++;
Hai Shalomc3565922019-10-28 11:58:20 -0700354 if (verify_channel(mode, op_class->op_class, 106,
355 op_class->bw) != NOT_ALLOWED ||
356 verify_channel(mode, op_class->op_class, 122,
357 op_class->bw) != NOT_ALLOWED ||
358 verify_channel(mode, op_class->op_class, 138,
Hai Shalom60840252021-02-19 19:02:11 -0800359 op_class->bw) != NOT_ALLOWED ||
360 verify_channel(mode, op_class->op_class, 155,
361 op_class->bw) != NOT_ALLOWED ||
362 verify_channel(mode, op_class->op_class, 171,
Hai Shalomc3565922019-10-28 11:58:20 -0700363 op_class->bw) != NOT_ALLOWED)
Dmitry Shmidt29333592017-01-09 12:27:11 -0800364 found++;
Hai Shalomc3565922019-10-28 11:58:20 -0700365 if (verify_channel(mode, op_class->op_class, 106,
366 op_class->bw) != NOT_ALLOWED &&
367 verify_channel(mode, op_class->op_class, 138,
368 op_class->bw) != NOT_ALLOWED)
Dmitry Shmidt29333592017-01-09 12:27:11 -0800369 found++;
Hai Shalom60840252021-02-19 19:02:11 -0800370 if (verify_channel(mode, op_class->op_class, 122,
371 op_class->bw) != NOT_ALLOWED &&
372 verify_channel(mode, op_class->op_class, 155,
373 op_class->bw) != NOT_ALLOWED)
374 found++;
375 if (verify_channel(mode, op_class->op_class, 138,
376 op_class->bw) != NOT_ALLOWED &&
377 verify_channel(mode, op_class->op_class, 171,
Hai Shalomc3565922019-10-28 11:58:20 -0700378 op_class->bw) != NOT_ALLOWED)
Dmitry Shmidt29333592017-01-09 12:27:11 -0800379 found++;
380
381 if (found >= 2)
382 return 1;
383
384 return 0;
385 }
386
Hai Shalom60840252021-02-19 19:02:11 -0800387 if (op_class->op_class == 135) {
388 /* Need at least two 80 MHz segments which do not fall under the
389 * same 160 MHz segment to support 80+80 in 6 GHz.
390 */
391 int first_seg = 0;
392 int curr_seg = 0;
393
394 for (chan = op_class->min_chan; chan <= op_class->max_chan;
395 chan += op_class->inc) {
396 curr_seg++;
397 if (verify_channel(mode, op_class->op_class, chan,
398 op_class->bw) != NOT_ALLOWED) {
399 if (!first_seg) {
400 first_seg = curr_seg;
401 continue;
402 }
403
404 /* Supported if at least two non-consecutive 80
405 * MHz segments allowed.
406 */
407 if ((curr_seg - first_seg) > 1)
408 return 1;
409
410 /* Supported even if the 80 MHz segments are
411 * consecutive when they do not fall under the
412 * same 160 MHz segment.
413 */
414 if ((first_seg % 2) == 0)
415 return 1;
416 }
417 }
418
419 return 0;
420 }
421
Dmitry Shmidt29333592017-01-09 12:27:11 -0800422 found = 0;
423 for (chan = op_class->min_chan; chan <= op_class->max_chan;
424 chan += op_class->inc) {
Hai Shalomc3565922019-10-28 11:58:20 -0700425 if (verify_channel(mode, op_class->op_class, chan,
426 op_class->bw) != NOT_ALLOWED) {
Dmitry Shmidt29333592017-01-09 12:27:11 -0800427 found = 1;
428 break;
429 }
430 }
431
432 return found;
433}
434
435
Hai Shalomfdcde762020-04-02 11:19:20 -0700436static int wpas_sta_secondary_channel_offset(struct wpa_bss *bss, u8 *current,
437 u8 *channel)
438{
439
Hai Shalom60840252021-02-19 19:02:11 -0800440 const u8 *ies;
441 u8 phy_type;
Hai Shalomfdcde762020-04-02 11:19:20 -0700442 size_t ies_len;
443
444 if (!bss)
445 return -1;
Hai Shalom60840252021-02-19 19:02:11 -0800446 ies = wpa_bss_ie_ptr(bss);
Hai Shalomfdcde762020-04-02 11:19:20 -0700447 ies_len = bss->ie_len ? bss->ie_len : bss->beacon_ie_len;
448 return wpas_get_op_chan_phy(bss->freq, ies, ies_len, current,
449 channel, &phy_type);
450}
451
452
Hai Shalom74f70d42019-02-11 14:42:39 -0800453size_t wpas_supp_op_class_ie(struct wpa_supplicant *wpa_s,
454 struct wpa_ssid *ssid,
Hai Shalomfdcde762020-04-02 11:19:20 -0700455 struct wpa_bss *bss, u8 *pos, size_t len)
Dmitry Shmidt29333592017-01-09 12:27:11 -0800456{
457 struct wpabuf *buf;
458 u8 op, current, chan;
459 u8 *ie_len;
460 size_t res;
461
462 /*
Hai Shalomfdcde762020-04-02 11:19:20 -0700463 * Determine the current operating class correct mode based on
464 * advertised BSS capabilities, if available. Fall back to a less
465 * accurate guess based on frequency if the needed IEs are not available
466 * or used.
Dmitry Shmidt29333592017-01-09 12:27:11 -0800467 */
Hai Shalomfdcde762020-04-02 11:19:20 -0700468 if (wpas_sta_secondary_channel_offset(bss, &current, &chan) < 0 &&
469 ieee80211_freq_to_channel_ext(bss->freq, 0, CHANWIDTH_USE_HT,
Dmitry Shmidt29333592017-01-09 12:27:11 -0800470 &current, &chan) == NUM_HOSTAPD_MODES)
471 return 0;
472
473 /*
474 * Need 3 bytes for EID, length, and current operating class, plus
475 * 1 byte for every other supported operating class.
476 */
477 buf = wpabuf_alloc(global_op_class_size + 3);
478 if (!buf)
479 return 0;
480
481 wpabuf_put_u8(buf, WLAN_EID_SUPPORTED_OPERATING_CLASSES);
482 /* Will set the length later, putting a placeholder */
483 ie_len = wpabuf_put(buf, 1);
484 wpabuf_put_u8(buf, current);
485
486 for (op = 0; global_op_class[op].op_class; op++) {
Hai Shalom74f70d42019-02-11 14:42:39 -0800487 if (wpas_op_class_supported(wpa_s, ssid, &global_op_class[op]))
Dmitry Shmidt29333592017-01-09 12:27:11 -0800488 wpabuf_put_u8(buf, global_op_class[op].op_class);
489 }
490
491 *ie_len = wpabuf_len(buf) - 2;
Hai Shalom899fcc72020-10-19 14:38:18 -0700492 if (*ie_len < 2) {
493 wpa_printf(MSG_DEBUG,
494 "No supported operating classes IE to add");
495 res = 0;
496 } else if (wpabuf_len(buf) > len) {
Dmitry Shmidt29333592017-01-09 12:27:11 -0800497 wpa_printf(MSG_ERROR,
Hai Shalom899fcc72020-10-19 14:38:18 -0700498 "Supported operating classes IE exceeds maximum buffer length");
Dmitry Shmidt29333592017-01-09 12:27:11 -0800499 res = 0;
500 } else {
501 os_memcpy(pos, wpabuf_head(buf), wpabuf_len(buf));
502 res = wpabuf_len(buf);
503 wpa_hexdump_buf(MSG_DEBUG,
504 "Added supported operating classes IE", buf);
505 }
506
507 wpabuf_free(buf);
508 return res;
509}
Hai Shalomc3565922019-10-28 11:58:20 -0700510
511
512int * wpas_supp_op_classes(struct wpa_supplicant *wpa_s)
513{
514 int op;
515 unsigned int pos, max_num = 0;
516 int *classes;
517
518 for (op = 0; global_op_class[op].op_class; op++)
519 max_num++;
520 classes = os_zalloc((max_num + 1) * sizeof(int));
521 if (!classes)
522 return NULL;
523
524 for (op = 0, pos = 0; global_op_class[op].op_class; op++) {
525 if (wpas_op_class_supported(wpa_s, NULL, &global_op_class[op]))
526 classes[pos++] = global_op_class[op].op_class;
527 }
528
529 return classes;
530}