1 /*
2 * Driver interaction with Linux nl80211/cfg80211 - Capabilities
3 * Copyright (c) 2002-2015, Jouni Malinen <j@w1.fi>
4 * Copyright (c) 2007, Johannes Berg <johannes@sipsolutions.net>
5 * Copyright (c) 2009-2010, Atheros Communications
6 *
7 * This software may be distributed under the terms of the BSD license.
8 * See README for more details.
9 */
10
11 #include "includes.h"
12 #include <netlink/genl/genl.h>
13
14 #include "utils/common.h"
15 #include "common/ieee802_11_common.h"
16 #include "common/wpa_common.h"
17 #include "common/qca-vendor.h"
18 #include "common/qca-vendor-attr.h"
19 #include "common/brcm_vendor.h"
20 #include "driver_nl80211.h"
21
22
protocol_feature_handler(struct nl_msg * msg,void * arg)23 static int protocol_feature_handler(struct nl_msg *msg, void *arg)
24 {
25 u32 *feat = arg;
26 struct nlattr *tb_msg[NL80211_ATTR_MAX + 1];
27 struct genlmsghdr *gnlh = nlmsg_data(nlmsg_hdr(msg));
28
29 nla_parse(tb_msg, NL80211_ATTR_MAX, genlmsg_attrdata(gnlh, 0),
30 genlmsg_attrlen(gnlh, 0), NULL);
31
32 if (tb_msg[NL80211_ATTR_PROTOCOL_FEATURES])
33 *feat = nla_get_u32(tb_msg[NL80211_ATTR_PROTOCOL_FEATURES]);
34
35 return NL_SKIP;
36 }
37
38
get_nl80211_protocol_features(struct wpa_driver_nl80211_data * drv)39 static u32 get_nl80211_protocol_features(struct wpa_driver_nl80211_data *drv)
40 {
41 u32 feat = 0;
42 struct nl_msg *msg;
43
44 msg = nlmsg_alloc();
45 if (!msg)
46 return 0;
47
48 if (!nl80211_cmd(drv, msg, 0, NL80211_CMD_GET_PROTOCOL_FEATURES)) {
49 nlmsg_free(msg);
50 return 0;
51 }
52
53 if (send_and_recv_msgs(drv, msg, protocol_feature_handler, &feat,
54 NULL, NULL) == 0)
55 return feat;
56
57 return 0;
58 }
59
60
61 struct wiphy_info_data {
62 struct wpa_driver_nl80211_data *drv;
63 struct wpa_driver_capa *capa;
64
65 unsigned int num_multichan_concurrent;
66
67 unsigned int error:1;
68 unsigned int device_ap_sme:1;
69 unsigned int poll_command_supported:1;
70 unsigned int data_tx_status:1;
71 unsigned int auth_supported:1;
72 unsigned int connect_supported:1;
73 unsigned int p2p_go_supported:1;
74 unsigned int p2p_client_supported:1;
75 unsigned int p2p_go_ctwindow_supported:1;
76 unsigned int p2p_concurrent:1;
77 unsigned int channel_switch_supported:1;
78 unsigned int set_qos_map_supported:1;
79 unsigned int have_low_prio_scan:1;
80 unsigned int wmm_ac_supported:1;
81 unsigned int mac_addr_rand_scan_supported:1;
82 unsigned int mac_addr_rand_sched_scan_supported:1;
83 unsigned int update_ft_ies_supported:1;
84 unsigned int has_key_mgmt:1;
85 unsigned int has_key_mgmt_iftype:1;
86 };
87
88
probe_resp_offload_support(int supp_protocols)89 static unsigned int probe_resp_offload_support(int supp_protocols)
90 {
91 unsigned int prot = 0;
92
93 if (supp_protocols & NL80211_PROBE_RESP_OFFLOAD_SUPPORT_WPS)
94 prot |= WPA_DRIVER_PROBE_RESP_OFFLOAD_WPS;
95 if (supp_protocols & NL80211_PROBE_RESP_OFFLOAD_SUPPORT_WPS2)
96 prot |= WPA_DRIVER_PROBE_RESP_OFFLOAD_WPS2;
97 if (supp_protocols & NL80211_PROBE_RESP_OFFLOAD_SUPPORT_P2P)
98 prot |= WPA_DRIVER_PROBE_RESP_OFFLOAD_P2P;
99 if (supp_protocols & NL80211_PROBE_RESP_OFFLOAD_SUPPORT_80211U)
100 prot |= WPA_DRIVER_PROBE_RESP_OFFLOAD_INTERWORKING;
101
102 return prot;
103 }
104
105
wiphy_info_supported_iftypes(struct wiphy_info_data * info,struct nlattr * tb)106 static void wiphy_info_supported_iftypes(struct wiphy_info_data *info,
107 struct nlattr *tb)
108 {
109 struct nlattr *nl_mode;
110 int i;
111
112 if (tb == NULL)
113 return;
114
115 nla_for_each_nested(nl_mode, tb, i) {
116 switch (nla_type(nl_mode)) {
117 case NL80211_IFTYPE_AP:
118 info->capa->flags |= WPA_DRIVER_FLAGS_AP;
119 break;
120 case NL80211_IFTYPE_MESH_POINT:
121 info->capa->flags |= WPA_DRIVER_FLAGS_MESH;
122 break;
123 case NL80211_IFTYPE_ADHOC:
124 info->capa->flags |= WPA_DRIVER_FLAGS_IBSS;
125 break;
126 case NL80211_IFTYPE_P2P_DEVICE:
127 info->capa->flags |=
128 WPA_DRIVER_FLAGS_DEDICATED_P2P_DEVICE;
129 break;
130 case NL80211_IFTYPE_P2P_GO:
131 info->p2p_go_supported = 1;
132 break;
133 case NL80211_IFTYPE_P2P_CLIENT:
134 info->p2p_client_supported = 1;
135 break;
136 }
137 }
138 }
139
140
wiphy_info_iface_comb_process(struct wiphy_info_data * info,struct nlattr * nl_combi)141 static int wiphy_info_iface_comb_process(struct wiphy_info_data *info,
142 struct nlattr *nl_combi)
143 {
144 struct nlattr *tb_comb[NUM_NL80211_IFACE_COMB];
145 struct nlattr *tb_limit[NUM_NL80211_IFACE_LIMIT];
146 struct nlattr *nl_limit, *nl_mode;
147 int err, rem_limit, rem_mode;
148 int combination_has_p2p = 0, combination_has_mgd = 0;
149 static struct nla_policy
150 iface_combination_policy[NUM_NL80211_IFACE_COMB] = {
151 [NL80211_IFACE_COMB_LIMITS] = { .type = NLA_NESTED },
152 [NL80211_IFACE_COMB_MAXNUM] = { .type = NLA_U32 },
153 [NL80211_IFACE_COMB_STA_AP_BI_MATCH] = { .type = NLA_FLAG },
154 [NL80211_IFACE_COMB_NUM_CHANNELS] = { .type = NLA_U32 },
155 [NL80211_IFACE_COMB_RADAR_DETECT_WIDTHS] = { .type = NLA_U32 },
156 },
157 iface_limit_policy[NUM_NL80211_IFACE_LIMIT] = {
158 [NL80211_IFACE_LIMIT_TYPES] = { .type = NLA_NESTED },
159 [NL80211_IFACE_LIMIT_MAX] = { .type = NLA_U32 },
160 };
161
162 err = nla_parse_nested(tb_comb, MAX_NL80211_IFACE_COMB,
163 nl_combi, iface_combination_policy);
164 if (err || !tb_comb[NL80211_IFACE_COMB_LIMITS] ||
165 !tb_comb[NL80211_IFACE_COMB_MAXNUM] ||
166 !tb_comb[NL80211_IFACE_COMB_NUM_CHANNELS])
167 return 0; /* broken combination */
168
169 if (tb_comb[NL80211_IFACE_COMB_RADAR_DETECT_WIDTHS])
170 info->capa->flags |= WPA_DRIVER_FLAGS_RADAR;
171
172 nla_for_each_nested(nl_limit, tb_comb[NL80211_IFACE_COMB_LIMITS],
173 rem_limit) {
174 err = nla_parse_nested(tb_limit, MAX_NL80211_IFACE_LIMIT,
175 nl_limit, iface_limit_policy);
176 if (err || !tb_limit[NL80211_IFACE_LIMIT_TYPES])
177 return 0; /* broken combination */
178
179 nla_for_each_nested(nl_mode,
180 tb_limit[NL80211_IFACE_LIMIT_TYPES],
181 rem_mode) {
182 int ift = nla_type(nl_mode);
183 if (ift == NL80211_IFTYPE_P2P_GO ||
184 ift == NL80211_IFTYPE_P2P_CLIENT)
185 combination_has_p2p = 1;
186 if (ift == NL80211_IFTYPE_STATION)
187 combination_has_mgd = 1;
188 }
189 if (combination_has_p2p && combination_has_mgd)
190 break;
191 }
192
193 if (combination_has_p2p && combination_has_mgd) {
194 unsigned int num_channels =
195 nla_get_u32(tb_comb[NL80211_IFACE_COMB_NUM_CHANNELS]);
196
197 info->p2p_concurrent = 1;
198 if (info->num_multichan_concurrent < num_channels)
199 info->num_multichan_concurrent = num_channels;
200 }
201
202 return 0;
203 }
204
205
wiphy_info_iface_comb(struct wiphy_info_data * info,struct nlattr * tb)206 static void wiphy_info_iface_comb(struct wiphy_info_data *info,
207 struct nlattr *tb)
208 {
209 struct nlattr *nl_combi;
210 int rem_combi;
211
212 if (tb == NULL)
213 return;
214
215 nla_for_each_nested(nl_combi, tb, rem_combi) {
216 if (wiphy_info_iface_comb_process(info, nl_combi) > 0)
217 break;
218 }
219 }
220
221
wiphy_info_supp_cmds(struct wiphy_info_data * info,struct nlattr * tb)222 static void wiphy_info_supp_cmds(struct wiphy_info_data *info,
223 struct nlattr *tb)
224 {
225 struct nlattr *nl_cmd;
226 int i;
227
228 if (tb == NULL)
229 return;
230
231 nla_for_each_nested(nl_cmd, tb, i) {
232 switch (nla_get_u32(nl_cmd)) {
233 case NL80211_CMD_AUTHENTICATE:
234 info->auth_supported = 1;
235 break;
236 case NL80211_CMD_CONNECT:
237 info->connect_supported = 1;
238 break;
239 case NL80211_CMD_START_SCHED_SCAN:
240 info->capa->sched_scan_supported = 1;
241 break;
242 case NL80211_CMD_PROBE_CLIENT:
243 info->poll_command_supported = 1;
244 break;
245 case NL80211_CMD_CHANNEL_SWITCH:
246 info->channel_switch_supported = 1;
247 break;
248 case NL80211_CMD_SET_QOS_MAP:
249 info->set_qos_map_supported = 1;
250 break;
251 case NL80211_CMD_UPDATE_FT_IES:
252 info->update_ft_ies_supported = 1;
253 break;
254 }
255 }
256 }
257
258
get_akm_suites_info(struct nlattr * tb)259 static unsigned int get_akm_suites_info(struct nlattr *tb)
260 {
261 int i, num;
262 unsigned int key_mgmt = 0;
263 u32 *akms;
264
265 if (!tb)
266 return 0;
267
268 num = nla_len(tb) / sizeof(u32);
269 akms = nla_data(tb);
270 for (i = 0; i < num; i++) {
271 switch (akms[i]) {
272 case RSN_AUTH_KEY_MGMT_UNSPEC_802_1X:
273 key_mgmt |= WPA_DRIVER_CAPA_KEY_MGMT_WPA |
274 WPA_DRIVER_CAPA_KEY_MGMT_WPA2;
275 break;
276 case RSN_AUTH_KEY_MGMT_PSK_OVER_802_1X:
277 key_mgmt |= WPA_DRIVER_CAPA_KEY_MGMT_WPA_PSK |
278 WPA_DRIVER_CAPA_KEY_MGMT_WPA2_PSK;
279 break;
280 case RSN_AUTH_KEY_MGMT_FT_802_1X:
281 key_mgmt |= WPA_DRIVER_CAPA_KEY_MGMT_FT;
282 break;
283 case RSN_AUTH_KEY_MGMT_FT_PSK:
284 key_mgmt |= WPA_DRIVER_CAPA_KEY_MGMT_FT_PSK;
285 break;
286 case RSN_AUTH_KEY_MGMT_802_1X_SHA256:
287 key_mgmt |= WPA_DRIVER_CAPA_KEY_MGMT_802_1X_SHA256;
288 break;
289 case RSN_AUTH_KEY_MGMT_PSK_SHA256:
290 key_mgmt |= WPA_DRIVER_CAPA_KEY_MGMT_PSK_SHA256;
291 break;
292 case RSN_AUTH_KEY_MGMT_TPK_HANDSHAKE:
293 key_mgmt |= WPA_DRIVER_CAPA_KEY_MGMT_TPK_HANDSHAKE;
294 break;
295 case RSN_AUTH_KEY_MGMT_FT_SAE:
296 key_mgmt |= WPA_DRIVER_CAPA_KEY_MGMT_FT_SAE;
297 break;
298 case RSN_AUTH_KEY_MGMT_FT_802_1X_SHA384:
299 key_mgmt |= WPA_DRIVER_CAPA_KEY_MGMT_FT_802_1X_SHA384;
300 break;
301 case RSN_AUTH_KEY_MGMT_CCKM:
302 key_mgmt |= WPA_DRIVER_CAPA_KEY_MGMT_CCKM;
303 break;
304 case RSN_AUTH_KEY_MGMT_OSEN:
305 key_mgmt |= WPA_DRIVER_CAPA_KEY_MGMT_OSEN;
306 break;
307 case RSN_AUTH_KEY_MGMT_802_1X_SUITE_B:
308 key_mgmt |= WPA_DRIVER_CAPA_KEY_MGMT_SUITE_B;
309 break;
310 case RSN_AUTH_KEY_MGMT_802_1X_SUITE_B_192:
311 key_mgmt |= WPA_DRIVER_CAPA_KEY_MGMT_SUITE_B_192;
312 break;
313 case RSN_AUTH_KEY_MGMT_OWE:
314 key_mgmt |= WPA_DRIVER_CAPA_KEY_MGMT_OWE;
315 break;
316 case RSN_AUTH_KEY_MGMT_DPP:
317 key_mgmt |= WPA_DRIVER_CAPA_KEY_MGMT_DPP;
318 break;
319 case RSN_AUTH_KEY_MGMT_FILS_SHA256:
320 key_mgmt |= WPA_DRIVER_CAPA_KEY_MGMT_FILS_SHA256;
321 break;
322 case RSN_AUTH_KEY_MGMT_FILS_SHA384:
323 key_mgmt |= WPA_DRIVER_CAPA_KEY_MGMT_FILS_SHA384;
324 break;
325 case RSN_AUTH_KEY_MGMT_FT_FILS_SHA256:
326 key_mgmt |= WPA_DRIVER_CAPA_KEY_MGMT_FT_FILS_SHA256;
327 break;
328 case RSN_AUTH_KEY_MGMT_FT_FILS_SHA384:
329 key_mgmt |= WPA_DRIVER_CAPA_KEY_MGMT_FT_FILS_SHA384;
330 break;
331 case RSN_AUTH_KEY_MGMT_SAE:
332 key_mgmt |= WPA_DRIVER_CAPA_KEY_MGMT_SAE;
333 break;
334 case RSN_AUTH_KEY_MGMT_SAE_EXT_KEY:
335 key_mgmt |= WPA_DRIVER_CAPA_KEY_MGMT_SAE_EXT_KEY;
336 break;
337 }
338 }
339
340 return key_mgmt;
341 }
342
343
get_iface_akm_suites_info(struct wiphy_info_data * info,struct nlattr * nl_akms)344 static void get_iface_akm_suites_info(struct wiphy_info_data *info,
345 struct nlattr *nl_akms)
346 {
347 struct nlattr *tb[NL80211_IFTYPE_AKM_ATTR_MAX + 1];
348 struct nlattr *nl_iftype;
349 unsigned int key_mgmt;
350 int i;
351
352 if (!nl_akms)
353 return;
354
355 nla_parse(tb, NL80211_IFTYPE_AKM_ATTR_MAX,
356 nla_data(nl_akms), nla_len(nl_akms), NULL);
357
358 if (!tb[NL80211_IFTYPE_AKM_ATTR_IFTYPES] ||
359 !tb[NL80211_IFTYPE_AKM_ATTR_SUITES])
360 return;
361
362 info->has_key_mgmt_iftype = 1;
363 key_mgmt = get_akm_suites_info(tb[NL80211_IFTYPE_AKM_ATTR_SUITES]);
364
365 nla_for_each_nested(nl_iftype, tb[NL80211_IFTYPE_AKM_ATTR_IFTYPES], i) {
366 switch (nla_type(nl_iftype)) {
367 case NL80211_IFTYPE_ADHOC:
368 info->drv->capa.key_mgmt_iftype[WPA_IF_IBSS] = key_mgmt;
369 break;
370 case NL80211_IFTYPE_STATION:
371 info->drv->capa.key_mgmt_iftype[WPA_IF_STATION] =
372 key_mgmt;
373 break;
374 case NL80211_IFTYPE_AP:
375 info->drv->capa.key_mgmt_iftype[WPA_IF_AP_BSS] =
376 key_mgmt;
377 break;
378 case NL80211_IFTYPE_AP_VLAN:
379 info->drv->capa.key_mgmt_iftype[WPA_IF_AP_VLAN] =
380 key_mgmt;
381 break;
382 case NL80211_IFTYPE_MESH_POINT:
383 info->drv->capa.key_mgmt_iftype[WPA_IF_MESH] = key_mgmt;
384 break;
385 case NL80211_IFTYPE_P2P_CLIENT:
386 info->drv->capa.key_mgmt_iftype[WPA_IF_P2P_CLIENT] =
387 key_mgmt;
388 break;
389 case NL80211_IFTYPE_P2P_GO:
390 info->drv->capa.key_mgmt_iftype[WPA_IF_P2P_GO] =
391 key_mgmt;
392 break;
393 case NL80211_IFTYPE_P2P_DEVICE:
394 info->drv->capa.key_mgmt_iftype[WPA_IF_P2P_DEVICE] =
395 key_mgmt;
396 break;
397 case NL80211_IFTYPE_NAN:
398 info->drv->capa.key_mgmt_iftype[WPA_IF_NAN] = key_mgmt;
399 break;
400 }
401 wpa_printf(MSG_DEBUG, "nl80211: %s supported key_mgmt 0x%x",
402 nl80211_iftype_str(nla_type(nl_iftype)),
403 key_mgmt);
404 }
405 }
406
407
wiphy_info_iftype_akm_suites(struct wiphy_info_data * info,struct nlattr * tb)408 static void wiphy_info_iftype_akm_suites(struct wiphy_info_data *info,
409 struct nlattr *tb)
410 {
411 struct nlattr *nl_if;
412 int rem_if;
413
414 if (!tb)
415 return;
416
417 nla_for_each_nested(nl_if, tb, rem_if)
418 get_iface_akm_suites_info(info, nl_if);
419 }
420
421
wiphy_info_akm_suites(struct wiphy_info_data * info,struct nlattr * tb)422 static void wiphy_info_akm_suites(struct wiphy_info_data *info,
423 struct nlattr *tb)
424 {
425 if (!tb)
426 return;
427
428 info->has_key_mgmt = 1;
429 info->capa->key_mgmt = get_akm_suites_info(tb);
430 wpa_printf(MSG_DEBUG, "nl80211: wiphy supported key_mgmt 0x%x",
431 info->capa->key_mgmt);
432 }
433
434
wiphy_info_cipher_suites(struct wiphy_info_data * info,struct nlattr * tb)435 static void wiphy_info_cipher_suites(struct wiphy_info_data *info,
436 struct nlattr *tb)
437 {
438 int i, num;
439 u32 *ciphers;
440
441 if (tb == NULL)
442 return;
443
444 num = nla_len(tb) / sizeof(u32);
445 ciphers = nla_data(tb);
446 for (i = 0; i < num; i++) {
447 u32 c = ciphers[i];
448
449 wpa_printf(MSG_EXCESSIVE, "nl80211: Supported cipher %02x-%02x-%02x:%d",
450 c >> 24, (c >> 16) & 0xff,
451 (c >> 8) & 0xff, c & 0xff);
452 switch (c) {
453 case RSN_CIPHER_SUITE_CCMP_256:
454 info->capa->enc |= WPA_DRIVER_CAPA_ENC_CCMP_256;
455 break;
456 case RSN_CIPHER_SUITE_GCMP_256:
457 info->capa->enc |= WPA_DRIVER_CAPA_ENC_GCMP_256;
458 break;
459 case RSN_CIPHER_SUITE_CCMP:
460 info->capa->enc |= WPA_DRIVER_CAPA_ENC_CCMP;
461 break;
462 case RSN_CIPHER_SUITE_GCMP:
463 info->capa->enc |= WPA_DRIVER_CAPA_ENC_GCMP;
464 break;
465 case RSN_CIPHER_SUITE_TKIP:
466 info->capa->enc |= WPA_DRIVER_CAPA_ENC_TKIP;
467 break;
468 case RSN_CIPHER_SUITE_WEP104:
469 info->capa->enc |= WPA_DRIVER_CAPA_ENC_WEP104;
470 break;
471 case RSN_CIPHER_SUITE_WEP40:
472 info->capa->enc |= WPA_DRIVER_CAPA_ENC_WEP40;
473 break;
474 case RSN_CIPHER_SUITE_AES_128_CMAC:
475 info->capa->enc |= WPA_DRIVER_CAPA_ENC_BIP;
476 break;
477 case RSN_CIPHER_SUITE_BIP_GMAC_128:
478 info->capa->enc |= WPA_DRIVER_CAPA_ENC_BIP_GMAC_128;
479 break;
480 case RSN_CIPHER_SUITE_BIP_GMAC_256:
481 info->capa->enc |= WPA_DRIVER_CAPA_ENC_BIP_GMAC_256;
482 break;
483 case RSN_CIPHER_SUITE_BIP_CMAC_256:
484 info->capa->enc |= WPA_DRIVER_CAPA_ENC_BIP_CMAC_256;
485 break;
486 case RSN_CIPHER_SUITE_NO_GROUP_ADDRESSED:
487 info->capa->enc |= WPA_DRIVER_CAPA_ENC_GTK_NOT_USED;
488 break;
489 }
490 }
491 }
492
493
wiphy_info_max_roc(struct wpa_driver_capa * capa,struct nlattr * tb)494 static void wiphy_info_max_roc(struct wpa_driver_capa *capa,
495 struct nlattr *tb)
496 {
497 if (tb)
498 capa->max_remain_on_chan = nla_get_u32(tb);
499 }
500
501
wiphy_info_tdls(struct wpa_driver_capa * capa,struct nlattr * tdls,struct nlattr * ext_setup)502 static void wiphy_info_tdls(struct wpa_driver_capa *capa, struct nlattr *tdls,
503 struct nlattr *ext_setup)
504 {
505 if (tdls == NULL)
506 return;
507
508 wpa_printf(MSG_EXCESSIVE, "nl80211: TDLS supported");
509 capa->flags |= WPA_DRIVER_FLAGS_TDLS_SUPPORT;
510
511 if (ext_setup) {
512 wpa_printf(MSG_DEBUG, "nl80211: TDLS external setup");
513 capa->flags |= WPA_DRIVER_FLAGS_TDLS_EXTERNAL_SETUP;
514 }
515 }
516
517
ext_feature_isset(const u8 * ext_features,int ext_features_len,enum nl80211_ext_feature_index ftidx)518 static int ext_feature_isset(const u8 *ext_features, int ext_features_len,
519 enum nl80211_ext_feature_index ftidx)
520 {
521 u8 ft_byte;
522
523 if ((int) ftidx / 8 >= ext_features_len)
524 return 0;
525
526 ft_byte = ext_features[ftidx / 8];
527 return (ft_byte & BIT(ftidx % 8)) != 0;
528 }
529
530
wiphy_info_ext_feature_flags(struct wiphy_info_data * info,struct nlattr * tb)531 static void wiphy_info_ext_feature_flags(struct wiphy_info_data *info,
532 struct nlattr *tb)
533 {
534 struct wpa_driver_capa *capa = info->capa;
535 u8 *ext_features;
536 int len;
537
538 if (tb == NULL)
539 return;
540
541 ext_features = nla_data(tb);
542 len = nla_len(tb);
543
544 if (ext_feature_isset(ext_features, len, NL80211_EXT_FEATURE_VHT_IBSS))
545 capa->flags |= WPA_DRIVER_FLAGS_VHT_IBSS;
546
547 if (ext_feature_isset(ext_features, len, NL80211_EXT_FEATURE_RRM))
548 capa->rrm_flags |= WPA_DRIVER_FLAGS_SUPPORT_RRM;
549
550 if (ext_feature_isset(ext_features, len, NL80211_EXT_FEATURE_FILS_STA))
551 capa->flags |= WPA_DRIVER_FLAGS_SUPPORT_FILS;
552
553 if (ext_feature_isset(ext_features, len,
554 NL80211_EXT_FEATURE_BEACON_RATE_LEGACY))
555 capa->flags |= WPA_DRIVER_FLAGS_BEACON_RATE_LEGACY;
556
557 if (ext_feature_isset(ext_features, len,
558 NL80211_EXT_FEATURE_BEACON_RATE_HT))
559 capa->flags |= WPA_DRIVER_FLAGS_BEACON_RATE_HT;
560
561 if (ext_feature_isset(ext_features, len,
562 NL80211_EXT_FEATURE_BEACON_RATE_VHT))
563 capa->flags |= WPA_DRIVER_FLAGS_BEACON_RATE_VHT;
564
565 if (ext_feature_isset(ext_features, len,
566 NL80211_EXT_FEATURE_BEACON_RATE_HE))
567 capa->flags2 |= WPA_DRIVER_FLAGS2_BEACON_RATE_HE;
568
569 if (ext_feature_isset(ext_features, len,
570 NL80211_EXT_FEATURE_SET_SCAN_DWELL))
571 capa->rrm_flags |= WPA_DRIVER_FLAGS_SUPPORT_SET_SCAN_DWELL;
572
573 if (ext_feature_isset(ext_features, len,
574 NL80211_EXT_FEATURE_SCAN_START_TIME) &&
575 ext_feature_isset(ext_features, len,
576 NL80211_EXT_FEATURE_BSS_PARENT_TSF) &&
577 ext_feature_isset(ext_features, len,
578 NL80211_EXT_FEATURE_SET_SCAN_DWELL))
579 capa->rrm_flags |= WPA_DRIVER_FLAGS_SUPPORT_BEACON_REPORT;
580 if (ext_feature_isset(ext_features, len,
581 NL80211_EXT_FEATURE_MGMT_TX_RANDOM_TA))
582 capa->flags |= WPA_DRIVER_FLAGS_MGMT_TX_RANDOM_TA;
583 if (ext_feature_isset(ext_features, len,
584 NL80211_EXT_FEATURE_MGMT_TX_RANDOM_TA_CONNECTED))
585 capa->flags |= WPA_DRIVER_FLAGS_MGMT_TX_RANDOM_TA_CONNECTED;
586 if (ext_feature_isset(ext_features, len,
587 NL80211_EXT_FEATURE_SCHED_SCAN_RELATIVE_RSSI))
588 capa->flags |= WPA_DRIVER_FLAGS_SCHED_SCAN_RELATIVE_RSSI;
589 if (ext_feature_isset(ext_features, len,
590 NL80211_EXT_FEATURE_FILS_SK_OFFLOAD))
591 capa->flags |= WPA_DRIVER_FLAGS_FILS_SK_OFFLOAD;
592
593 if (ext_feature_isset(ext_features, len,
594 NL80211_EXT_FEATURE_4WAY_HANDSHAKE_STA_PSK))
595 capa->flags |= WPA_DRIVER_FLAGS_4WAY_HANDSHAKE_PSK;
596 if (ext_feature_isset(ext_features, len,
597 NL80211_EXT_FEATURE_4WAY_HANDSHAKE_STA_1X))
598 capa->flags |= WPA_DRIVER_FLAGS_4WAY_HANDSHAKE_8021X;
599
600 if (ext_feature_isset(ext_features, len,
601 NL80211_EXT_FEATURE_MFP_OPTIONAL))
602 capa->flags |= WPA_DRIVER_FLAGS_MFP_OPTIONAL;
603
604 if (ext_feature_isset(ext_features, len,
605 NL80211_EXT_FEATURE_DFS_OFFLOAD))
606 capa->flags |= WPA_DRIVER_FLAGS_DFS_OFFLOAD;
607
608 #ifdef CONFIG_MBO
609 if (ext_feature_isset(ext_features, len,
610 NL80211_EXT_FEATURE_FILS_MAX_CHANNEL_TIME) &&
611 ext_feature_isset(ext_features, len,
612 NL80211_EXT_FEATURE_ACCEPT_BCAST_PROBE_RESP) &&
613 ext_feature_isset(ext_features, len,
614 NL80211_EXT_FEATURE_OCE_PROBE_REQ_HIGH_TX_RATE) &&
615 ext_feature_isset(
616 ext_features, len,
617 NL80211_EXT_FEATURE_OCE_PROBE_REQ_DEFERRAL_SUPPRESSION))
618 capa->flags |= WPA_DRIVER_FLAGS_OCE_STA;
619 #endif /* CONFIG_MBO */
620
621 if (ext_feature_isset(ext_features, len,
622 NL80211_EXT_FEATURE_ENABLE_FTM_RESPONDER))
623 capa->flags |= WPA_DRIVER_FLAGS_FTM_RESPONDER;
624
625 if (ext_feature_isset(ext_features, len,
626 NL80211_EXT_FEATURE_CONTROL_PORT_OVER_NL80211))
627 capa->flags |= WPA_DRIVER_FLAGS_CONTROL_PORT;
628 if (ext_feature_isset(ext_features, len,
629 NL80211_EXT_FEATURE_CONTROL_PORT_NO_PREAUTH))
630 capa->flags2 |= WPA_DRIVER_FLAGS2_CONTROL_PORT_RX;
631 if (ext_feature_isset(
632 ext_features, len,
633 NL80211_EXT_FEATURE_CONTROL_PORT_OVER_NL80211_TX_STATUS))
634 capa->flags2 |= WPA_DRIVER_FLAGS2_CONTROL_PORT_TX_STATUS;
635
636 if (ext_feature_isset(ext_features, len,
637 NL80211_EXT_FEATURE_VLAN_OFFLOAD))
638 capa->flags |= WPA_DRIVER_FLAGS_VLAN_OFFLOAD;
639
640 if (ext_feature_isset(ext_features, len,
641 NL80211_EXT_FEATURE_CAN_REPLACE_PTK0))
642 capa->flags |= WPA_DRIVER_FLAGS_SAFE_PTK0_REKEYS;
643
644 if (ext_feature_isset(ext_features, len,
645 NL80211_EXT_FEATURE_BEACON_PROTECTION))
646 capa->flags |= WPA_DRIVER_FLAGS_BEACON_PROTECTION;
647
648 if (ext_feature_isset(ext_features, len,
649 NL80211_EXT_FEATURE_EXT_KEY_ID))
650 capa->flags |= WPA_DRIVER_FLAGS_EXTENDED_KEY_ID;
651
652 if (ext_feature_isset(ext_features, len,
653 NL80211_EXT_FEATURE_MULTICAST_REGISTRATIONS))
654 info->drv->multicast_registrations = 1;
655
656 if (ext_feature_isset(ext_features, len,
657 NL80211_EXT_FEATURE_FILS_DISCOVERY))
658 info->drv->fils_discovery = 1;
659
660 if (ext_feature_isset(ext_features, len,
661 NL80211_EXT_FEATURE_UNSOL_BCAST_PROBE_RESP))
662 info->drv->unsol_bcast_probe_resp = 1;
663
664 if (ext_feature_isset(ext_features, len,
665 NL80211_EXT_FEATURE_BEACON_PROTECTION_CLIENT))
666 capa->flags2 |= WPA_DRIVER_FLAGS2_BEACON_PROTECTION_CLIENT;
667
668 if (ext_feature_isset(ext_features, len,
669 NL80211_EXT_FEATURE_OPERATING_CHANNEL_VALIDATION))
670 capa->flags2 |= WPA_DRIVER_FLAGS2_OCV;
671 }
672
673
wiphy_info_feature_flags(struct wiphy_info_data * info,struct nlattr * tb)674 static void wiphy_info_feature_flags(struct wiphy_info_data *info,
675 struct nlattr *tb)
676 {
677 u32 flags;
678 struct wpa_driver_capa *capa = info->capa;
679
680 if (tb == NULL)
681 return;
682
683 flags = nla_get_u32(tb);
684
685 if (flags & NL80211_FEATURE_SK_TX_STATUS)
686 info->data_tx_status = 1;
687
688 if (flags & NL80211_FEATURE_INACTIVITY_TIMER)
689 capa->flags |= WPA_DRIVER_FLAGS_INACTIVITY_TIMER;
690
691 if (flags & NL80211_FEATURE_SAE)
692 capa->flags |= WPA_DRIVER_FLAGS_SAE;
693
694 if (flags & NL80211_FEATURE_NEED_OBSS_SCAN)
695 capa->flags |= WPA_DRIVER_FLAGS_OBSS_SCAN;
696
697 if (flags & NL80211_FEATURE_AP_MODE_CHAN_WIDTH_CHANGE)
698 capa->flags |= WPA_DRIVER_FLAGS_HT_2040_COEX;
699
700 if (flags & NL80211_FEATURE_TDLS_CHANNEL_SWITCH) {
701 wpa_printf(MSG_DEBUG, "nl80211: TDLS channel switch");
702 capa->flags |= WPA_DRIVER_FLAGS_TDLS_CHANNEL_SWITCH;
703 }
704
705 if (flags & NL80211_FEATURE_P2P_GO_CTWIN)
706 info->p2p_go_ctwindow_supported = 1;
707
708 if (flags & NL80211_FEATURE_LOW_PRIORITY_SCAN)
709 info->have_low_prio_scan = 1;
710
711 if (flags & NL80211_FEATURE_SCAN_RANDOM_MAC_ADDR)
712 info->mac_addr_rand_scan_supported = 1;
713
714 if (flags & NL80211_FEATURE_SCHED_SCAN_RANDOM_MAC_ADDR)
715 info->mac_addr_rand_sched_scan_supported = 1;
716
717 if (flags & NL80211_FEATURE_SUPPORTS_WMM_ADMISSION)
718 info->wmm_ac_supported = 1;
719
720 if (flags & NL80211_FEATURE_DS_PARAM_SET_IE_IN_PROBES)
721 capa->rrm_flags |= WPA_DRIVER_FLAGS_DS_PARAM_SET_IE_IN_PROBES;
722
723 if (flags & NL80211_FEATURE_WFA_TPC_IE_IN_PROBES)
724 capa->rrm_flags |= WPA_DRIVER_FLAGS_WFA_TPC_IE_IN_PROBES;
725
726 if (flags & NL80211_FEATURE_QUIET)
727 capa->rrm_flags |= WPA_DRIVER_FLAGS_QUIET;
728
729 if (flags & NL80211_FEATURE_TX_POWER_INSERTION)
730 capa->rrm_flags |= WPA_DRIVER_FLAGS_TX_POWER_INSERTION;
731
732 if (flags & NL80211_FEATURE_HT_IBSS)
733 capa->flags |= WPA_DRIVER_FLAGS_HT_IBSS;
734
735 if (flags & NL80211_FEATURE_FULL_AP_CLIENT_STATE)
736 capa->flags |= WPA_DRIVER_FLAGS_FULL_AP_CLIENT_STATE;
737 }
738
739
wiphy_info_probe_resp_offload(struct wpa_driver_capa * capa,struct nlattr * tb)740 static void wiphy_info_probe_resp_offload(struct wpa_driver_capa *capa,
741 struct nlattr *tb)
742 {
743 u32 protocols;
744
745 if (tb == NULL)
746 return;
747
748 protocols = nla_get_u32(tb);
749 wpa_printf(MSG_EXCESSIVE, "nl80211: Supports Probe Response offload in AP "
750 "mode");
751 capa->flags |= WPA_DRIVER_FLAGS_PROBE_RESP_OFFLOAD;
752 capa->probe_resp_offloads = probe_resp_offload_support(protocols);
753 }
754
755
wiphy_info_wowlan_triggers(struct wpa_driver_capa * capa,struct nlattr * tb)756 static void wiphy_info_wowlan_triggers(struct wpa_driver_capa *capa,
757 struct nlattr *tb)
758 {
759 struct nlattr *triggers[MAX_NL80211_WOWLAN_TRIG + 1];
760
761 if (tb == NULL)
762 return;
763
764 if (nla_parse_nested(triggers, MAX_NL80211_WOWLAN_TRIG,
765 tb, NULL))
766 return;
767
768 if (triggers[NL80211_WOWLAN_TRIG_ANY])
769 capa->wowlan_triggers.any = 1;
770 if (triggers[NL80211_WOWLAN_TRIG_DISCONNECT])
771 capa->wowlan_triggers.disconnect = 1;
772 if (triggers[NL80211_WOWLAN_TRIG_MAGIC_PKT])
773 capa->wowlan_triggers.magic_pkt = 1;
774 if (triggers[NL80211_WOWLAN_TRIG_GTK_REKEY_FAILURE])
775 capa->wowlan_triggers.gtk_rekey_failure = 1;
776 if (triggers[NL80211_WOWLAN_TRIG_EAP_IDENT_REQUEST])
777 capa->wowlan_triggers.eap_identity_req = 1;
778 if (triggers[NL80211_WOWLAN_TRIG_4WAY_HANDSHAKE])
779 capa->wowlan_triggers.four_way_handshake = 1;
780 if (triggers[NL80211_WOWLAN_TRIG_RFKILL_RELEASE])
781 capa->wowlan_triggers.rfkill_release = 1;
782 }
783
784
wiphy_info_extended_capab(struct wpa_driver_nl80211_data * drv,struct nlattr * tb)785 static void wiphy_info_extended_capab(struct wpa_driver_nl80211_data *drv,
786 struct nlattr *tb)
787 {
788 int rem = 0, i;
789 struct nlattr *tb1[NL80211_ATTR_MAX + 1], *attr;
790
791 if (!tb || drv->num_iface_ext_capa == NL80211_IFTYPE_MAX)
792 return;
793
794 nla_for_each_nested(attr, tb, rem) {
795 unsigned int len;
796 struct drv_nl80211_ext_capa *capa;
797
798 nla_parse(tb1, NL80211_ATTR_MAX, nla_data(attr),
799 nla_len(attr), NULL);
800
801 if (!tb1[NL80211_ATTR_IFTYPE] ||
802 !tb1[NL80211_ATTR_EXT_CAPA] ||
803 !tb1[NL80211_ATTR_EXT_CAPA_MASK])
804 continue;
805
806 capa = &drv->iface_ext_capa[drv->num_iface_ext_capa];
807 capa->iftype = nla_get_u32(tb1[NL80211_ATTR_IFTYPE]);
808 wpa_printf(MSG_DEBUG,
809 "nl80211: Driver-advertised extended capabilities for interface type %s",
810 nl80211_iftype_str(capa->iftype));
811
812 len = nla_len(tb1[NL80211_ATTR_EXT_CAPA]);
813 capa->ext_capa = os_memdup(nla_data(tb1[NL80211_ATTR_EXT_CAPA]),
814 len);
815 if (!capa->ext_capa)
816 goto err;
817
818 capa->ext_capa_len = len;
819 wpa_hexdump(MSG_DEBUG, "nl80211: Extended capabilities",
820 capa->ext_capa, capa->ext_capa_len);
821
822 len = nla_len(tb1[NL80211_ATTR_EXT_CAPA_MASK]);
823 capa->ext_capa_mask =
824 os_memdup(nla_data(tb1[NL80211_ATTR_EXT_CAPA_MASK]),
825 len);
826 if (!capa->ext_capa_mask)
827 goto err;
828
829 wpa_hexdump(MSG_DEBUG, "nl80211: Extended capabilities mask",
830 capa->ext_capa_mask, capa->ext_capa_len);
831
832 drv->num_iface_ext_capa++;
833 if (drv->num_iface_ext_capa == NL80211_IFTYPE_MAX)
834 break;
835 }
836
837 return;
838
839 err:
840 /* Cleanup allocated memory on error */
841 for (i = 0; i < NL80211_IFTYPE_MAX; i++) {
842 os_free(drv->iface_ext_capa[i].ext_capa);
843 drv->iface_ext_capa[i].ext_capa = NULL;
844 os_free(drv->iface_ext_capa[i].ext_capa_mask);
845 drv->iface_ext_capa[i].ext_capa_mask = NULL;
846 drv->iface_ext_capa[i].ext_capa_len = 0;
847 }
848 drv->num_iface_ext_capa = 0;
849 }
850
851
wiphy_info_handler(struct nl_msg * msg,void * arg)852 static int wiphy_info_handler(struct nl_msg *msg, void *arg)
853 {
854 struct nlattr *tb[NL80211_ATTR_MAX + 1];
855 struct genlmsghdr *gnlh = nlmsg_data(nlmsg_hdr(msg));
856 struct wiphy_info_data *info = arg;
857 struct wpa_driver_capa *capa = info->capa;
858 struct wpa_driver_nl80211_data *drv = info->drv;
859
860 nla_parse(tb, NL80211_ATTR_MAX, genlmsg_attrdata(gnlh, 0),
861 genlmsg_attrlen(gnlh, 0), NULL);
862
863 if (tb[NL80211_ATTR_WIPHY])
864 drv->wiphy_idx = nla_get_u32(tb[NL80211_ATTR_WIPHY]);
865
866 if (tb[NL80211_ATTR_WIPHY_NAME])
867 os_strlcpy(drv->phyname,
868 nla_get_string(tb[NL80211_ATTR_WIPHY_NAME]),
869 sizeof(drv->phyname));
870 if (tb[NL80211_ATTR_MAX_NUM_SCAN_SSIDS])
871 capa->max_scan_ssids =
872 nla_get_u8(tb[NL80211_ATTR_MAX_NUM_SCAN_SSIDS]);
873
874 if (tb[NL80211_ATTR_MAX_NUM_SCHED_SCAN_SSIDS])
875 capa->max_sched_scan_ssids =
876 nla_get_u8(tb[NL80211_ATTR_MAX_NUM_SCHED_SCAN_SSIDS]);
877
878 if (tb[NL80211_ATTR_MAX_NUM_SCHED_SCAN_PLANS] &&
879 tb[NL80211_ATTR_MAX_SCAN_PLAN_INTERVAL] &&
880 tb[NL80211_ATTR_MAX_SCAN_PLAN_ITERATIONS]) {
881 capa->max_sched_scan_plans =
882 nla_get_u32(tb[NL80211_ATTR_MAX_NUM_SCHED_SCAN_PLANS]);
883
884 capa->max_sched_scan_plan_interval =
885 nla_get_u32(tb[NL80211_ATTR_MAX_SCAN_PLAN_INTERVAL]);
886
887 capa->max_sched_scan_plan_iterations =
888 nla_get_u32(tb[NL80211_ATTR_MAX_SCAN_PLAN_ITERATIONS]);
889 }
890
891 if (tb[NL80211_ATTR_MAX_MATCH_SETS])
892 capa->max_match_sets =
893 nla_get_u8(tb[NL80211_ATTR_MAX_MATCH_SETS]);
894
895 if (tb[NL80211_ATTR_MAC_ACL_MAX])
896 capa->max_acl_mac_addrs =
897 nla_get_u32(tb[NL80211_ATTR_MAC_ACL_MAX]);
898
899 wiphy_info_supported_iftypes(info, tb[NL80211_ATTR_SUPPORTED_IFTYPES]);
900 wiphy_info_iface_comb(info, tb[NL80211_ATTR_INTERFACE_COMBINATIONS]);
901 wiphy_info_supp_cmds(info, tb[NL80211_ATTR_SUPPORTED_COMMANDS]);
902 wiphy_info_cipher_suites(info, tb[NL80211_ATTR_CIPHER_SUITES]);
903 wiphy_info_akm_suites(info, tb[NL80211_ATTR_AKM_SUITES]);
904 wiphy_info_iftype_akm_suites(info, tb[NL80211_ATTR_IFTYPE_AKM_SUITES]);
905
906 if (tb[NL80211_ATTR_OFFCHANNEL_TX_OK]) {
907 wpa_printf(MSG_EXCESSIVE, "nl80211: Using driver-based "
908 "off-channel TX");
909 capa->flags |= WPA_DRIVER_FLAGS_OFFCHANNEL_TX;
910 }
911
912 if (tb[NL80211_ATTR_ROAM_SUPPORT]) {
913 wpa_printf(MSG_EXCESSIVE, "nl80211: Using driver-based roaming");
914 capa->flags |= WPA_DRIVER_FLAGS_BSS_SELECTION;
915 }
916
917 if (tb[NL80211_ATTR_DFS_OFFLOAD_SUPPORT]) {
918 wpa_printf(MSG_DEBUG, "nl80211: Using driver-based dfs offload");
919 capa->flags |= WPA_DRIVER_FLAGS_DFS_OFFLOAD;
920 }
921
922 wiphy_info_max_roc(capa,
923 tb[NL80211_ATTR_MAX_REMAIN_ON_CHANNEL_DURATION]);
924
925 if (tb[NL80211_ATTR_SUPPORT_AP_UAPSD])
926 capa->flags |= WPA_DRIVER_FLAGS_AP_UAPSD;
927
928 wiphy_info_tdls(capa, tb[NL80211_ATTR_TDLS_SUPPORT],
929 tb[NL80211_ATTR_TDLS_EXTERNAL_SETUP]);
930
931 if (tb[NL80211_ATTR_DEVICE_AP_SME])
932 info->device_ap_sme = 1;
933
934 wiphy_info_feature_flags(info, tb[NL80211_ATTR_FEATURE_FLAGS]);
935 wiphy_info_ext_feature_flags(info, tb[NL80211_ATTR_EXT_FEATURES]);
936 wiphy_info_probe_resp_offload(capa,
937 tb[NL80211_ATTR_PROBE_RESP_OFFLOAD]);
938
939 if (tb[NL80211_ATTR_EXT_CAPA] && tb[NL80211_ATTR_EXT_CAPA_MASK] &&
940 drv->extended_capa == NULL) {
941 drv->extended_capa =
942 os_malloc(nla_len(tb[NL80211_ATTR_EXT_CAPA]));
943 if (drv->extended_capa) {
944 os_memcpy(drv->extended_capa,
945 nla_data(tb[NL80211_ATTR_EXT_CAPA]),
946 nla_len(tb[NL80211_ATTR_EXT_CAPA]));
947 drv->extended_capa_len =
948 nla_len(tb[NL80211_ATTR_EXT_CAPA]);
949 wpa_hexdump(MSG_DEBUG,
950 "nl80211: Driver-advertised extended capabilities (default)",
951 drv->extended_capa, drv->extended_capa_len);
952 }
953 drv->extended_capa_mask =
954 os_malloc(nla_len(tb[NL80211_ATTR_EXT_CAPA_MASK]));
955 if (drv->extended_capa_mask) {
956 os_memcpy(drv->extended_capa_mask,
957 nla_data(tb[NL80211_ATTR_EXT_CAPA_MASK]),
958 nla_len(tb[NL80211_ATTR_EXT_CAPA_MASK]));
959 wpa_hexdump(MSG_DEBUG,
960 "nl80211: Driver-advertised extended capabilities mask (default)",
961 drv->extended_capa_mask,
962 drv->extended_capa_len);
963 } else {
964 os_free(drv->extended_capa);
965 drv->extended_capa = NULL;
966 drv->extended_capa_len = 0;
967 }
968 }
969
970 wiphy_info_extended_capab(drv, tb[NL80211_ATTR_IFTYPE_EXT_CAPA]);
971
972 if (tb[NL80211_ATTR_VENDOR_DATA]) {
973 struct nlattr *nl;
974 int rem;
975
976 nla_for_each_nested(nl, tb[NL80211_ATTR_VENDOR_DATA], rem) {
977 struct nl80211_vendor_cmd_info *vinfo;
978 if (nla_len(nl) != sizeof(*vinfo)) {
979 wpa_printf(MSG_DEBUG, "nl80211: Unexpected vendor data info");
980 continue;
981 }
982 vinfo = nla_data(nl);
983 if (vinfo->vendor_id == OUI_QCA) {
984 switch (vinfo->subcmd) {
985 case QCA_NL80211_VENDOR_SUBCMD_TEST:
986 drv->vendor_cmd_test_avail = 1;
987 break;
988 #ifdef CONFIG_DRIVER_NL80211_QCA
989 case QCA_NL80211_VENDOR_SUBCMD_ROAMING:
990 drv->roaming_vendor_cmd_avail = 1;
991 break;
992 case QCA_NL80211_VENDOR_SUBCMD_DFS_CAPABILITY:
993 drv->dfs_vendor_cmd_avail = 1;
994 break;
995 case QCA_NL80211_VENDOR_SUBCMD_GET_FEATURES:
996 drv->get_features_vendor_cmd_avail = 1;
997 break;
998 case QCA_NL80211_VENDOR_SUBCMD_GET_PREFERRED_FREQ_LIST:
999 drv->get_pref_freq_list = 1;
1000 break;
1001 case QCA_NL80211_VENDOR_SUBCMD_SET_PROBABLE_OPER_CHANNEL:
1002 drv->set_prob_oper_freq = 1;
1003 break;
1004 case QCA_NL80211_VENDOR_SUBCMD_DO_ACS:
1005 drv->capa.flags |=
1006 WPA_DRIVER_FLAGS_ACS_OFFLOAD;
1007 drv->qca_do_acs = 1;
1008 break;
1009 case QCA_NL80211_VENDOR_SUBCMD_SETBAND:
1010 drv->setband_vendor_cmd_avail = 1;
1011 break;
1012 case QCA_NL80211_VENDOR_SUBCMD_TRIGGER_SCAN:
1013 drv->scan_vendor_cmd_avail = 1;
1014 break;
1015 case QCA_NL80211_VENDOR_SUBCMD_SET_WIFI_CONFIGURATION:
1016 drv->set_wifi_conf_vendor_cmd_avail = 1;
1017 break;
1018 case QCA_NL80211_VENDOR_SUBCMD_FETCH_BSS_TRANSITION_STATUS:
1019 drv->fetch_bss_trans_status = 1;
1020 break;
1021 case QCA_NL80211_VENDOR_SUBCMD_ROAM:
1022 drv->roam_vendor_cmd_avail = 1;
1023 break;
1024 case QCA_NL80211_VENDOR_SUBCMD_ADD_STA_NODE:
1025 drv->add_sta_node_vendor_cmd_avail = 1;
1026 break;
1027 case QCA_NL80211_VENDOR_SUBCMD_GET_STA_INFO:
1028 drv->get_sta_info_vendor_cmd_avail = 1;
1029 break;
1030 #endif /* CONFIG_DRIVER_NL80211_QCA */
1031 }
1032 #ifdef CONFIG_DRIVER_NL80211_BRCM
1033 } else if (vinfo->vendor_id == OUI_BRCM) {
1034 switch (vinfo->subcmd) {
1035 case BRCM_VENDOR_SCMD_ACS:
1036 drv->capa.flags |=
1037 WPA_DRIVER_FLAGS_ACS_OFFLOAD;
1038 wpa_printf(MSG_DEBUG,
1039 "Enabled BRCM ACS");
1040 drv->brcm_do_acs = 1;
1041 break;
1042 }
1043 #endif /* CONFIG_DRIVER_NL80211_BRCM */
1044 }
1045
1046 wpa_printf(MSG_EXCESSIVE, "nl80211: Supported vendor command: vendor_id=0x%x subcmd=%u",
1047 vinfo->vendor_id, vinfo->subcmd);
1048 }
1049 }
1050
1051 if (tb[NL80211_ATTR_VENDOR_EVENTS]) {
1052 struct nlattr *nl;
1053 int rem;
1054
1055 nla_for_each_nested(nl, tb[NL80211_ATTR_VENDOR_EVENTS], rem) {
1056 struct nl80211_vendor_cmd_info *vinfo;
1057 if (nla_len(nl) != sizeof(*vinfo)) {
1058 wpa_printf(MSG_DEBUG, "nl80211: Unexpected vendor data info");
1059 continue;
1060 }
1061 vinfo = nla_data(nl);
1062 wpa_printf(MSG_EXCESSIVE, "nl80211: Supported vendor event: vendor_id=0x%x subcmd=%u",
1063 vinfo->vendor_id, vinfo->subcmd);
1064 }
1065 }
1066
1067 wiphy_info_wowlan_triggers(capa,
1068 tb[NL80211_ATTR_WOWLAN_TRIGGERS_SUPPORTED]);
1069
1070 if (tb[NL80211_ATTR_MAX_AP_ASSOC_STA])
1071 capa->max_stations =
1072 nla_get_u32(tb[NL80211_ATTR_MAX_AP_ASSOC_STA]);
1073
1074 if (tb[NL80211_ATTR_MAX_CSA_COUNTERS])
1075 capa->max_csa_counters =
1076 nla_get_u8(tb[NL80211_ATTR_MAX_CSA_COUNTERS]);
1077
1078 if (tb[NL80211_ATTR_WIPHY_SELF_MANAGED_REG])
1079 capa->flags |= WPA_DRIVER_FLAGS_SELF_MANAGED_REGULATORY;
1080
1081 return NL_SKIP;
1082 }
1083
1084
wpa_driver_nl80211_get_info(struct wpa_driver_nl80211_data * drv,struct wiphy_info_data * info)1085 static int wpa_driver_nl80211_get_info(struct wpa_driver_nl80211_data *drv,
1086 struct wiphy_info_data *info)
1087 {
1088 u32 feat;
1089 struct nl_msg *msg;
1090 int flags = 0;
1091
1092 os_memset(info, 0, sizeof(*info));
1093 info->capa = &drv->capa;
1094 info->drv = drv;
1095
1096 feat = get_nl80211_protocol_features(drv);
1097 if (feat & NL80211_PROTOCOL_FEATURE_SPLIT_WIPHY_DUMP)
1098 flags = NLM_F_DUMP;
1099 msg = nl80211_cmd_msg(drv->first_bss, flags, NL80211_CMD_GET_WIPHY);
1100 if (!msg || nla_put_flag(msg, NL80211_ATTR_SPLIT_WIPHY_DUMP)) {
1101 nlmsg_free(msg);
1102 return -1;
1103 }
1104
1105 if (send_and_recv_msgs(drv, msg, wiphy_info_handler, info, NULL, NULL))
1106 return -1;
1107
1108 if (info->auth_supported)
1109 drv->capa.flags |= WPA_DRIVER_FLAGS_SME;
1110 else if (!info->connect_supported) {
1111 wpa_printf(MSG_INFO, "nl80211: Driver does not support "
1112 "authentication/association or connect commands");
1113 info->error = 1;
1114 }
1115
1116 if (info->p2p_go_supported && info->p2p_client_supported)
1117 drv->capa.flags |= WPA_DRIVER_FLAGS_P2P_CAPABLE;
1118 if (info->p2p_concurrent) {
1119 wpa_printf(MSG_EXCESSIVE, "nl80211: Use separate P2P group "
1120 "interface (driver advertised support)");
1121 drv->capa.flags |= WPA_DRIVER_FLAGS_P2P_CONCURRENT;
1122 drv->capa.flags |= WPA_DRIVER_FLAGS_P2P_MGMT_AND_NON_P2P;
1123 }
1124 if (info->num_multichan_concurrent > 1) {
1125 wpa_printf(MSG_EXCESSIVE, "nl80211: Enable multi-channel "
1126 "concurrent (driver advertised support)");
1127 drv->capa.num_multichan_concurrent =
1128 info->num_multichan_concurrent;
1129 }
1130 if (drv->capa.flags & WPA_DRIVER_FLAGS_DEDICATED_P2P_DEVICE)
1131 {
1132 wpa_printf(MSG_EXCESSIVE, "nl80211: use P2P_DEVICE support");
1133 #ifdef CONFIG_DRIVER_NL80211_HISI
1134 drv->capa.flags &= (~WPA_DRIVER_FLAGS_DEDICATED_P2P_DEVICE);
1135 #endif /* CONFIG_DRIVER_NL80211_HISI*/
1136 }
1137 /* default to 5000 since early versions of mac80211 don't set it */
1138 if (!drv->capa.max_remain_on_chan)
1139 drv->capa.max_remain_on_chan = 5000;
1140
1141 drv->capa.wmm_ac_supported = info->wmm_ac_supported;
1142
1143 drv->capa.mac_addr_rand_sched_scan_supported =
1144 info->mac_addr_rand_sched_scan_supported;
1145 drv->capa.mac_addr_rand_scan_supported =
1146 info->mac_addr_rand_scan_supported;
1147
1148 if (info->channel_switch_supported) {
1149 drv->capa.flags |= WPA_DRIVER_FLAGS_AP_CSA;
1150 if (!drv->capa.max_csa_counters)
1151 drv->capa.max_csa_counters = 1;
1152 }
1153
1154 if (!drv->capa.max_sched_scan_plans) {
1155 drv->capa.max_sched_scan_plans = 1;
1156 drv->capa.max_sched_scan_plan_interval = UINT32_MAX;
1157 drv->capa.max_sched_scan_plan_iterations = 0;
1158 }
1159
1160 if (info->update_ft_ies_supported)
1161 drv->capa.flags |= WPA_DRIVER_FLAGS_UPDATE_FT_IES;
1162
1163 return 0;
1164 }
1165
1166
1167 #ifdef CONFIG_DRIVER_NL80211_QCA
1168
dfs_info_handler(struct nl_msg * msg,void * arg)1169 static int dfs_info_handler(struct nl_msg *msg, void *arg)
1170 {
1171 struct nlattr *tb[NL80211_ATTR_MAX + 1];
1172 struct genlmsghdr *gnlh = nlmsg_data(nlmsg_hdr(msg));
1173 int *dfs_capability_ptr = arg;
1174
1175 nla_parse(tb, NL80211_ATTR_MAX, genlmsg_attrdata(gnlh, 0),
1176 genlmsg_attrlen(gnlh, 0), NULL);
1177
1178 if (tb[NL80211_ATTR_VENDOR_DATA]) {
1179 struct nlattr *nl_vend = tb[NL80211_ATTR_VENDOR_DATA];
1180 struct nlattr *tb_vendor[QCA_WLAN_VENDOR_ATTR_MAX + 1];
1181
1182 nla_parse(tb_vendor, QCA_WLAN_VENDOR_ATTR_MAX,
1183 nla_data(nl_vend), nla_len(nl_vend), NULL);
1184
1185 if (tb_vendor[QCA_WLAN_VENDOR_ATTR_DFS]) {
1186 u32 val;
1187 val = nla_get_u32(tb_vendor[QCA_WLAN_VENDOR_ATTR_DFS]);
1188 wpa_printf(MSG_DEBUG, "nl80211: DFS offload capability: %u",
1189 val);
1190 *dfs_capability_ptr = val;
1191 }
1192 }
1193
1194 return NL_SKIP;
1195 }
1196
1197
qca_nl80211_check_dfs_capa(struct wpa_driver_nl80211_data * drv)1198 static void qca_nl80211_check_dfs_capa(struct wpa_driver_nl80211_data *drv)
1199 {
1200 struct nl_msg *msg;
1201 int dfs_capability = 0;
1202 int ret;
1203
1204 if (!drv->dfs_vendor_cmd_avail)
1205 return;
1206
1207 if (!(msg = nl80211_drv_msg(drv, 0, NL80211_CMD_VENDOR)) ||
1208 nla_put_u32(msg, NL80211_ATTR_VENDOR_ID, OUI_QCA) ||
1209 nla_put_u32(msg, NL80211_ATTR_VENDOR_SUBCMD,
1210 QCA_NL80211_VENDOR_SUBCMD_DFS_CAPABILITY)) {
1211 nlmsg_free(msg);
1212 return;
1213 }
1214
1215 ret = send_and_recv_msgs(drv, msg, dfs_info_handler, &dfs_capability,
1216 NULL, NULL);
1217 if (!ret && dfs_capability)
1218 drv->capa.flags |= WPA_DRIVER_FLAGS_DFS_OFFLOAD;
1219 }
1220
1221
1222 struct features_info {
1223 u8 *flags;
1224 size_t flags_len;
1225 struct wpa_driver_capa *capa;
1226 };
1227
1228
features_info_handler(struct nl_msg * msg,void * arg)1229 static int features_info_handler(struct nl_msg *msg, void *arg)
1230 {
1231 struct nlattr *tb[NL80211_ATTR_MAX + 1];
1232 struct genlmsghdr *gnlh = nlmsg_data(nlmsg_hdr(msg));
1233 struct features_info *info = arg;
1234 struct nlattr *nl_vend, *attr;
1235
1236 nla_parse(tb, NL80211_ATTR_MAX, genlmsg_attrdata(gnlh, 0),
1237 genlmsg_attrlen(gnlh, 0), NULL);
1238
1239 nl_vend = tb[NL80211_ATTR_VENDOR_DATA];
1240 if (nl_vend) {
1241 struct nlattr *tb_vendor[QCA_WLAN_VENDOR_ATTR_MAX + 1];
1242
1243 nla_parse(tb_vendor, QCA_WLAN_VENDOR_ATTR_MAX,
1244 nla_data(nl_vend), nla_len(nl_vend), NULL);
1245
1246 attr = tb_vendor[QCA_WLAN_VENDOR_ATTR_FEATURE_FLAGS];
1247 if (attr) {
1248 int len = nla_len(attr);
1249 info->flags = os_malloc(len);
1250 if (info->flags != NULL) {
1251 os_memcpy(info->flags, nla_data(attr), len);
1252 info->flags_len = len;
1253 }
1254 }
1255 attr = tb_vendor[QCA_WLAN_VENDOR_ATTR_CONCURRENCY_CAPA];
1256 if (attr)
1257 info->capa->conc_capab = nla_get_u32(attr);
1258
1259 attr = tb_vendor[
1260 QCA_WLAN_VENDOR_ATTR_MAX_CONCURRENT_CHANNELS_2_4_BAND];
1261 if (attr)
1262 info->capa->max_conc_chan_2_4 = nla_get_u32(attr);
1263
1264 attr = tb_vendor[
1265 QCA_WLAN_VENDOR_ATTR_MAX_CONCURRENT_CHANNELS_5_0_BAND];
1266 if (attr)
1267 info->capa->max_conc_chan_5_0 = nla_get_u32(attr);
1268 }
1269
1270 return NL_SKIP;
1271 }
1272
1273
check_feature(enum qca_wlan_vendor_features feature,struct features_info * info)1274 static int check_feature(enum qca_wlan_vendor_features feature,
1275 struct features_info *info)
1276 {
1277 size_t idx = feature / 8;
1278
1279 return (idx < info->flags_len) &&
1280 (info->flags[idx] & BIT(feature % 8));
1281 }
1282
1283
qca_nl80211_get_features(struct wpa_driver_nl80211_data * drv)1284 static void qca_nl80211_get_features(struct wpa_driver_nl80211_data *drv)
1285 {
1286 struct nl_msg *msg;
1287 struct features_info info;
1288 int ret;
1289
1290 if (!drv->get_features_vendor_cmd_avail)
1291 return;
1292
1293 if (!(msg = nl80211_drv_msg(drv, 0, NL80211_CMD_VENDOR)) ||
1294 nla_put_u32(msg, NL80211_ATTR_VENDOR_ID, OUI_QCA) ||
1295 nla_put_u32(msg, NL80211_ATTR_VENDOR_SUBCMD,
1296 QCA_NL80211_VENDOR_SUBCMD_GET_FEATURES)) {
1297 nlmsg_free(msg);
1298 return;
1299 }
1300
1301 os_memset(&info, 0, sizeof(info));
1302 info.capa = &drv->capa;
1303 ret = send_and_recv_msgs(drv, msg, features_info_handler, &info,
1304 NULL, NULL);
1305 if (ret || !info.flags)
1306 return;
1307
1308 if (check_feature(QCA_WLAN_VENDOR_FEATURE_KEY_MGMT_OFFLOAD, &info))
1309 drv->capa.flags |= WPA_DRIVER_FLAGS_KEY_MGMT_OFFLOAD;
1310
1311 if (check_feature(QCA_WLAN_VENDOR_FEATURE_SUPPORT_HW_MODE_ANY, &info))
1312 drv->capa.flags |= WPA_DRIVER_FLAGS_SUPPORT_HW_MODE_ANY;
1313
1314 if (check_feature(QCA_WLAN_VENDOR_FEATURE_OFFCHANNEL_SIMULTANEOUS,
1315 &info))
1316 drv->capa.flags |= WPA_DRIVER_FLAGS_OFFCHANNEL_SIMULTANEOUS;
1317 if (check_feature(QCA_WLAN_VENDOR_FEATURE_P2P_LISTEN_OFFLOAD, &info))
1318 drv->capa.flags |= WPA_DRIVER_FLAGS_P2P_LISTEN_OFFLOAD;
1319 if (check_feature(QCA_WLAN_VENDOR_FEATURE_OCE_STA, &info))
1320 drv->capa.flags |= WPA_DRIVER_FLAGS_OCE_STA;
1321 if (check_feature(QCA_WLAN_VENDOR_FEATURE_OCE_AP, &info))
1322 drv->capa.flags |= WPA_DRIVER_FLAGS_OCE_AP;
1323 if (check_feature(QCA_WLAN_VENDOR_FEATURE_OCE_STA_CFON, &info))
1324 drv->capa.flags |= WPA_DRIVER_FLAGS_OCE_STA_CFON;
1325 os_free(info.flags);
1326 }
1327
1328 #endif /* CONFIG_DRIVER_NL80211_QCA */
1329
1330
wpa_driver_nl80211_capa(struct wpa_driver_nl80211_data * drv)1331 int wpa_driver_nl80211_capa(struct wpa_driver_nl80211_data *drv)
1332 {
1333 struct wiphy_info_data info;
1334 int i;
1335
1336 if (wpa_driver_nl80211_get_info(drv, &info))
1337 return -1;
1338
1339 if (info.error)
1340 return -1;
1341
1342 drv->has_capability = 1;
1343 drv->has_driver_key_mgmt = info.has_key_mgmt | info.has_key_mgmt_iftype;
1344
1345 /* Fallback to hardcoded defaults if the driver does nott advertize any
1346 * AKM capabilities. */
1347 if (!drv->has_driver_key_mgmt) {
1348 drv->capa.key_mgmt = WPA_DRIVER_CAPA_KEY_MGMT_WPA |
1349 WPA_DRIVER_CAPA_KEY_MGMT_WPA_PSK |
1350 WPA_DRIVER_CAPA_KEY_MGMT_WPA2 |
1351 WPA_DRIVER_CAPA_KEY_MGMT_WPA2_PSK |
1352 WPA_DRIVER_CAPA_KEY_MGMT_SUITE_B |
1353 WPA_DRIVER_CAPA_KEY_MGMT_OWE |
1354 #ifdef CONFIG_WAPI
1355 WPA_DRIVER_CAPA_KEY_MGMT_WAPI_PSK |
1356 #endif
1357 WPA_DRIVER_CAPA_KEY_MGMT_DPP;
1358
1359 if (drv->capa.enc & (WPA_DRIVER_CAPA_ENC_CCMP_256 |
1360 WPA_DRIVER_CAPA_ENC_GCMP_256))
1361 drv->capa.key_mgmt |=
1362 WPA_DRIVER_CAPA_KEY_MGMT_SUITE_B_192;
1363
1364 if (drv->capa.flags & WPA_DRIVER_FLAGS_SME)
1365 drv->capa.key_mgmt |=
1366 WPA_DRIVER_CAPA_KEY_MGMT_FILS_SHA256 |
1367 WPA_DRIVER_CAPA_KEY_MGMT_FILS_SHA384 |
1368 WPA_DRIVER_CAPA_KEY_MGMT_FT_FILS_SHA256 |
1369 WPA_DRIVER_CAPA_KEY_MGMT_FT_FILS_SHA384 |
1370 WPA_DRIVER_CAPA_KEY_MGMT_SAE;
1371 else if (drv->capa.flags & WPA_DRIVER_FLAGS_FILS_SK_OFFLOAD)
1372 drv->capa.key_mgmt |=
1373 WPA_DRIVER_CAPA_KEY_MGMT_FILS_SHA256 |
1374 WPA_DRIVER_CAPA_KEY_MGMT_FILS_SHA384;
1375 }
1376
1377 if (!info.has_key_mgmt_iftype) {
1378 /* If the driver does not advertize per interface AKM
1379 * capabilities, consider all interfaces to support default AKMs
1380 * in key_mgmt. */
1381 for (i = 0; i < WPA_IF_MAX; i++)
1382 drv->capa.key_mgmt_iftype[i] = drv->capa.key_mgmt;
1383 } else if (info.has_key_mgmt_iftype && !info.has_key_mgmt) {
1384 /* If the driver advertizes only per interface supported AKMs
1385 * but does not advertize per wiphy AKM capabilities, consider
1386 * the default key_mgmt as a mask of per interface supported
1387 * AKMs. */
1388 drv->capa.key_mgmt = 0;
1389 for (i = 0; i < WPA_IF_MAX; i++)
1390 drv->capa.key_mgmt |= drv->capa.key_mgmt_iftype[i];
1391 } else if (info.has_key_mgmt_iftype && info.has_key_mgmt) {
1392 /* If the driver advertizes AKM capabilities both per wiphy and
1393 * per interface, consider the interfaces for which per
1394 * interface AKM capabilities were not received to support the
1395 * default key_mgmt capabilities.
1396 */
1397 for (i = 0; i < WPA_IF_MAX; i++)
1398 if (!drv->capa.key_mgmt_iftype[i])
1399 drv->capa.key_mgmt_iftype[i] =
1400 drv->capa.key_mgmt;
1401 }
1402
1403 drv->capa.auth = WPA_DRIVER_AUTH_OPEN |
1404 WPA_DRIVER_AUTH_SHARED |
1405 WPA_DRIVER_AUTH_LEAP;
1406
1407 drv->capa.flags |= WPA_DRIVER_FLAGS_VALID_ERROR_CODES;
1408 drv->capa.flags |= WPA_DRIVER_FLAGS_SET_KEYS_AFTER_ASSOC_DONE;
1409 drv->capa.flags |= WPA_DRIVER_FLAGS_EAPOL_TX_STATUS;
1410
1411 /*
1412 * As all cfg80211 drivers must support cases where the AP interface is
1413 * removed without the knowledge of wpa_supplicant/hostapd, e.g., in
1414 * case that the user space daemon has crashed, they must be able to
1415 * cleanup all stations and key entries in the AP tear down flow. Thus,
1416 * this flag can/should always be set for cfg80211 drivers.
1417 */
1418 drv->capa.flags |= WPA_DRIVER_FLAGS_AP_TEARDOWN_SUPPORT;
1419
1420 if (!info.device_ap_sme) {
1421 drv->capa.flags |= WPA_DRIVER_FLAGS_DEAUTH_TX_STATUS;
1422 drv->capa.flags2 |= WPA_DRIVER_FLAGS2_AP_SME;
1423
1424 /*
1425 * No AP SME is currently assumed to also indicate no AP MLME
1426 * in the driver/firmware.
1427 */
1428 drv->capa.flags |= WPA_DRIVER_FLAGS_AP_MLME;
1429 }
1430
1431 drv->device_ap_sme = info.device_ap_sme;
1432 drv->poll_command_supported = info.poll_command_supported;
1433 drv->data_tx_status = info.data_tx_status;
1434 drv->p2p_go_ctwindow_supported = info.p2p_go_ctwindow_supported;
1435 if (info.set_qos_map_supported)
1436 drv->capa.flags |= WPA_DRIVER_FLAGS_QOS_MAPPING;
1437 drv->have_low_prio_scan = info.have_low_prio_scan;
1438
1439 /*
1440 * If poll command and tx status are supported, mac80211 is new enough
1441 * to have everything we need to not need monitor interfaces.
1442 */
1443 drv->use_monitor = !info.device_ap_sme &&
1444 (!info.poll_command_supported || !info.data_tx_status);
1445
1446 /*
1447 * If we aren't going to use monitor interfaces, but the
1448 * driver doesn't support data TX status, we won't get TX
1449 * status for EAPOL frames.
1450 */
1451 if (!drv->use_monitor && !info.data_tx_status)
1452 drv->capa.flags &= ~WPA_DRIVER_FLAGS_EAPOL_TX_STATUS;
1453
1454 #ifdef CONFIG_DRIVER_NL80211_QCA
1455 if (!(info.capa->flags & WPA_DRIVER_FLAGS_DFS_OFFLOAD))
1456 qca_nl80211_check_dfs_capa(drv);
1457 qca_nl80211_get_features(drv);
1458
1459 /*
1460 * To enable offchannel simultaneous support in wpa_supplicant, the
1461 * underlying driver needs to support the same along with offchannel TX.
1462 * Offchannel TX support is needed since remain_on_channel and
1463 * action_tx use some common data structures and hence cannot be
1464 * scheduled simultaneously.
1465 */
1466 if (!(drv->capa.flags & WPA_DRIVER_FLAGS_OFFCHANNEL_TX))
1467 drv->capa.flags &= ~WPA_DRIVER_FLAGS_OFFCHANNEL_SIMULTANEOUS;
1468 #endif /* CONFIG_DRIVER_NL80211_QCA */
1469
1470 wpa_printf(MSG_DEBUG,
1471 "nl80211: key_mgmt=0x%x enc=0x%x auth=0x%x flags=0x%llx rrm_flags=0x%x probe_resp_offloads=0x%x max_stations=%u max_remain_on_chan=%u max_scan_ssids=%d",
1472 drv->capa.key_mgmt, drv->capa.enc, drv->capa.auth,
1473 (unsigned long long) drv->capa.flags, drv->capa.rrm_flags,
1474 drv->capa.probe_resp_offloads, drv->capa.max_stations,
1475 drv->capa.max_remain_on_chan, drv->capa.max_scan_ssids);
1476 return 0;
1477 }
1478
1479
1480 struct phy_info_arg {
1481 u16 *num_modes;
1482 struct hostapd_hw_modes *modes;
1483 int last_mode, last_chan_idx;
1484 int failed;
1485 u8 dfs_domain;
1486 };
1487
phy_info_ht_capa(struct hostapd_hw_modes * mode,struct nlattr * capa,struct nlattr * ampdu_factor,struct nlattr * ampdu_density,struct nlattr * mcs_set)1488 static void phy_info_ht_capa(struct hostapd_hw_modes *mode, struct nlattr *capa,
1489 struct nlattr *ampdu_factor,
1490 struct nlattr *ampdu_density,
1491 struct nlattr *mcs_set)
1492 {
1493 if (capa)
1494 mode->ht_capab = nla_get_u16(capa);
1495
1496 if (ampdu_factor)
1497 mode->a_mpdu_params |= nla_get_u8(ampdu_factor) & 0x03;
1498
1499 if (ampdu_density)
1500 mode->a_mpdu_params |= nla_get_u8(ampdu_density) << 2;
1501
1502 if (mcs_set && nla_len(mcs_set) >= 16) {
1503 u8 *mcs;
1504 mcs = nla_data(mcs_set);
1505 os_memcpy(mode->mcs_set, mcs, 16);
1506 }
1507 }
1508
1509
phy_info_vht_capa(struct hostapd_hw_modes * mode,struct nlattr * capa,struct nlattr * mcs_set)1510 static void phy_info_vht_capa(struct hostapd_hw_modes *mode,
1511 struct nlattr *capa,
1512 struct nlattr *mcs_set)
1513 {
1514 if (capa)
1515 mode->vht_capab = nla_get_u32(capa);
1516
1517 if (mcs_set && nla_len(mcs_set) >= 8) {
1518 u8 *mcs;
1519 mcs = nla_data(mcs_set);
1520 os_memcpy(mode->vht_mcs_set, mcs, 8);
1521 }
1522 }
1523
1524
phy_info_edmg_capa(struct hostapd_hw_modes * mode,struct nlattr * bw_config,struct nlattr * channels)1525 static int phy_info_edmg_capa(struct hostapd_hw_modes *mode,
1526 struct nlattr *bw_config,
1527 struct nlattr *channels)
1528 {
1529 if (!bw_config || !channels)
1530 return NL_OK;
1531
1532 mode->edmg.bw_config = nla_get_u8(bw_config);
1533 mode->edmg.channels = nla_get_u8(channels);
1534
1535 if (!mode->edmg.channels || !mode->edmg.bw_config)
1536 return NL_STOP;
1537
1538 return NL_OK;
1539 }
1540
1541
cw2ecw(unsigned int cw)1542 static int cw2ecw(unsigned int cw)
1543 {
1544 int bit;
1545
1546 if (cw == 0)
1547 return 0;
1548
1549 for (bit = 1; cw != 1; bit++)
1550 cw >>= 1;
1551
1552 return bit;
1553 }
1554
1555
phy_info_freq(struct hostapd_hw_modes * mode,struct hostapd_channel_data * chan,struct nlattr * tb_freq[])1556 static void phy_info_freq(struct hostapd_hw_modes *mode,
1557 struct hostapd_channel_data *chan,
1558 struct nlattr *tb_freq[])
1559 {
1560 u8 channel;
1561
1562 os_memset(chan, 0, sizeof(*chan));
1563 chan->freq = nla_get_u32(tb_freq[NL80211_FREQUENCY_ATTR_FREQ]);
1564 chan->flag = 0;
1565 chan->allowed_bw = ~0;
1566 chan->dfs_cac_ms = 0;
1567 if (ieee80211_freq_to_chan(chan->freq, &channel) != NUM_HOSTAPD_MODES)
1568 chan->chan = channel;
1569 else
1570 wpa_printf(MSG_DEBUG,
1571 "nl80211: No channel number found for frequency %u MHz",
1572 chan->freq);
1573
1574 if (tb_freq[NL80211_FREQUENCY_ATTR_DISABLED])
1575 chan->flag |= HOSTAPD_CHAN_DISABLED;
1576 if (tb_freq[NL80211_FREQUENCY_ATTR_NO_IR])
1577 chan->flag |= HOSTAPD_CHAN_NO_IR;
1578 if (tb_freq[NL80211_FREQUENCY_ATTR_RADAR])
1579 chan->flag |= HOSTAPD_CHAN_RADAR;
1580 if (tb_freq[NL80211_FREQUENCY_ATTR_INDOOR_ONLY])
1581 chan->flag |= HOSTAPD_CHAN_INDOOR_ONLY;
1582 if (tb_freq[NL80211_FREQUENCY_ATTR_GO_CONCURRENT])
1583 chan->flag |= HOSTAPD_CHAN_GO_CONCURRENT;
1584
1585 if (tb_freq[NL80211_FREQUENCY_ATTR_NO_10MHZ])
1586 chan->allowed_bw &= ~HOSTAPD_CHAN_WIDTH_10;
1587 if (tb_freq[NL80211_FREQUENCY_ATTR_NO_20MHZ])
1588 chan->allowed_bw &= ~HOSTAPD_CHAN_WIDTH_20;
1589 if (tb_freq[NL80211_FREQUENCY_ATTR_NO_HT40_PLUS])
1590 chan->allowed_bw &= ~HOSTAPD_CHAN_WIDTH_40P;
1591 if (tb_freq[NL80211_FREQUENCY_ATTR_NO_HT40_MINUS])
1592 chan->allowed_bw &= ~HOSTAPD_CHAN_WIDTH_40M;
1593 if (tb_freq[NL80211_FREQUENCY_ATTR_NO_80MHZ])
1594 chan->allowed_bw &= ~HOSTAPD_CHAN_WIDTH_80;
1595 if (tb_freq[NL80211_FREQUENCY_ATTR_NO_160MHZ])
1596 chan->allowed_bw &= ~HOSTAPD_CHAN_WIDTH_160;
1597
1598 if (tb_freq[NL80211_FREQUENCY_ATTR_DFS_STATE]) {
1599 enum nl80211_dfs_state state =
1600 nla_get_u32(tb_freq[NL80211_FREQUENCY_ATTR_DFS_STATE]);
1601
1602 switch (state) {
1603 case NL80211_DFS_USABLE:
1604 chan->flag |= HOSTAPD_CHAN_DFS_USABLE;
1605 break;
1606 case NL80211_DFS_AVAILABLE:
1607 chan->flag |= HOSTAPD_CHAN_DFS_AVAILABLE;
1608 break;
1609 case NL80211_DFS_UNAVAILABLE:
1610 chan->flag |= HOSTAPD_CHAN_DFS_UNAVAILABLE;
1611 break;
1612 }
1613 }
1614
1615 if (tb_freq[NL80211_FREQUENCY_ATTR_DFS_CAC_TIME]) {
1616 chan->dfs_cac_ms = nla_get_u32(
1617 tb_freq[NL80211_FREQUENCY_ATTR_DFS_CAC_TIME]);
1618 }
1619
1620 chan->wmm_rules_valid = 0;
1621 if (tb_freq[NL80211_FREQUENCY_ATTR_WMM]) {
1622 static struct nla_policy wmm_policy[NL80211_WMMR_MAX + 1] = {
1623 [NL80211_WMMR_CW_MIN] = { .type = NLA_U16 },
1624 [NL80211_WMMR_CW_MAX] = { .type = NLA_U16 },
1625 [NL80211_WMMR_AIFSN] = { .type = NLA_U8 },
1626 [NL80211_WMMR_TXOP] = { .type = NLA_U16 },
1627 };
1628 static const u8 wmm_map[4] = {
1629 [NL80211_AC_BE] = WMM_AC_BE,
1630 [NL80211_AC_BK] = WMM_AC_BK,
1631 [NL80211_AC_VI] = WMM_AC_VI,
1632 [NL80211_AC_VO] = WMM_AC_VO,
1633 };
1634 struct nlattr *nl_wmm;
1635 struct nlattr *tb_wmm[NL80211_WMMR_MAX + 1];
1636 int rem_wmm, ac, count = 0;
1637
1638 nla_for_each_nested(nl_wmm, tb_freq[NL80211_FREQUENCY_ATTR_WMM],
1639 rem_wmm) {
1640 if (nla_parse_nested(tb_wmm, NL80211_WMMR_MAX, nl_wmm,
1641 wmm_policy)) {
1642 wpa_printf(MSG_DEBUG,
1643 "nl80211: Failed to parse WMM rules attribute");
1644 return;
1645 }
1646 if (!tb_wmm[NL80211_WMMR_CW_MIN] ||
1647 !tb_wmm[NL80211_WMMR_CW_MAX] ||
1648 !tb_wmm[NL80211_WMMR_AIFSN] ||
1649 !tb_wmm[NL80211_WMMR_TXOP]) {
1650 wpa_printf(MSG_DEBUG,
1651 "nl80211: Channel is missing WMM rule attribute");
1652 return;
1653 }
1654 ac = nl_wmm->nla_type;
1655 if ((unsigned int) ac >= ARRAY_SIZE(wmm_map)) {
1656 wpa_printf(MSG_DEBUG,
1657 "nl80211: Invalid AC value %d", ac);
1658 return;
1659 }
1660
1661 ac = wmm_map[ac];
1662 chan->wmm_rules[ac].min_cwmin =
1663 cw2ecw(nla_get_u16(
1664 tb_wmm[NL80211_WMMR_CW_MIN]));
1665 chan->wmm_rules[ac].min_cwmax =
1666 cw2ecw(nla_get_u16(
1667 tb_wmm[NL80211_WMMR_CW_MAX]));
1668 chan->wmm_rules[ac].min_aifs =
1669 nla_get_u8(tb_wmm[NL80211_WMMR_AIFSN]);
1670 chan->wmm_rules[ac].max_txop =
1671 nla_get_u16(tb_wmm[NL80211_WMMR_TXOP]) / 32;
1672 count++;
1673 }
1674
1675 /* Set valid flag if all the AC rules are present */
1676 if (count == WMM_AC_NUM)
1677 chan->wmm_rules_valid = 1;
1678 }
1679 }
1680
1681
phy_info_freqs(struct phy_info_arg * phy_info,struct hostapd_hw_modes * mode,struct nlattr * tb)1682 static int phy_info_freqs(struct phy_info_arg *phy_info,
1683 struct hostapd_hw_modes *mode, struct nlattr *tb)
1684 {
1685 static struct nla_policy freq_policy[NL80211_FREQUENCY_ATTR_MAX + 1] = {
1686 [NL80211_FREQUENCY_ATTR_FREQ] = { .type = NLA_U32 },
1687 [NL80211_FREQUENCY_ATTR_DISABLED] = { .type = NLA_FLAG },
1688 [NL80211_FREQUENCY_ATTR_NO_IR] = { .type = NLA_FLAG },
1689 [NL80211_FREQUENCY_ATTR_RADAR] = { .type = NLA_FLAG },
1690 [NL80211_FREQUENCY_ATTR_MAX_TX_POWER] = { .type = NLA_U32 },
1691 [NL80211_FREQUENCY_ATTR_DFS_STATE] = { .type = NLA_U32 },
1692 [NL80211_FREQUENCY_ATTR_NO_10MHZ] = { .type = NLA_FLAG },
1693 [NL80211_FREQUENCY_ATTR_NO_20MHZ] = { .type = NLA_FLAG },
1694 [NL80211_FREQUENCY_ATTR_NO_HT40_PLUS] = { .type = NLA_FLAG },
1695 [NL80211_FREQUENCY_ATTR_NO_HT40_MINUS] = { .type = NLA_FLAG },
1696 [NL80211_FREQUENCY_ATTR_NO_80MHZ] = { .type = NLA_FLAG },
1697 [NL80211_FREQUENCY_ATTR_NO_160MHZ] = { .type = NLA_FLAG },
1698 };
1699 int new_channels = 0;
1700 struct hostapd_channel_data *channel;
1701 struct nlattr *tb_freq[NL80211_FREQUENCY_ATTR_MAX + 1];
1702 struct nlattr *nl_freq;
1703 int rem_freq, idx;
1704
1705 if (tb == NULL)
1706 return NL_OK;
1707
1708 nla_for_each_nested(nl_freq, tb, rem_freq) {
1709 nla_parse(tb_freq, NL80211_FREQUENCY_ATTR_MAX,
1710 nla_data(nl_freq), nla_len(nl_freq), freq_policy);
1711 if (!tb_freq[NL80211_FREQUENCY_ATTR_FREQ])
1712 continue;
1713 new_channels++;
1714 }
1715
1716 channel = os_realloc_array(mode->channels,
1717 mode->num_channels + new_channels,
1718 sizeof(struct hostapd_channel_data));
1719 if (!channel)
1720 return NL_STOP;
1721
1722 mode->channels = channel;
1723 mode->num_channels += new_channels;
1724
1725 idx = phy_info->last_chan_idx;
1726
1727 nla_for_each_nested(nl_freq, tb, rem_freq) {
1728 nla_parse(tb_freq, NL80211_FREQUENCY_ATTR_MAX,
1729 nla_data(nl_freq), nla_len(nl_freq), freq_policy);
1730 if (!tb_freq[NL80211_FREQUENCY_ATTR_FREQ])
1731 continue;
1732 phy_info_freq(mode, &mode->channels[idx], tb_freq);
1733 idx++;
1734 }
1735 phy_info->last_chan_idx = idx;
1736
1737 return NL_OK;
1738 }
1739
1740
phy_info_rates(struct hostapd_hw_modes * mode,struct nlattr * tb)1741 static int phy_info_rates(struct hostapd_hw_modes *mode, struct nlattr *tb)
1742 {
1743 static struct nla_policy rate_policy[NL80211_BITRATE_ATTR_MAX + 1] = {
1744 [NL80211_BITRATE_ATTR_RATE] = { .type = NLA_U32 },
1745 [NL80211_BITRATE_ATTR_2GHZ_SHORTPREAMBLE] =
1746 { .type = NLA_FLAG },
1747 };
1748 struct nlattr *tb_rate[NL80211_BITRATE_ATTR_MAX + 1];
1749 struct nlattr *nl_rate;
1750 int rem_rate, idx;
1751
1752 if (tb == NULL)
1753 return NL_OK;
1754
1755 nla_for_each_nested(nl_rate, tb, rem_rate) {
1756 nla_parse(tb_rate, NL80211_BITRATE_ATTR_MAX,
1757 nla_data(nl_rate), nla_len(nl_rate),
1758 rate_policy);
1759 if (!tb_rate[NL80211_BITRATE_ATTR_RATE])
1760 continue;
1761 mode->num_rates++;
1762 }
1763
1764 mode->rates = os_calloc(mode->num_rates, sizeof(int));
1765 if (!mode->rates)
1766 return NL_STOP;
1767
1768 idx = 0;
1769
1770 nla_for_each_nested(nl_rate, tb, rem_rate) {
1771 nla_parse(tb_rate, NL80211_BITRATE_ATTR_MAX,
1772 nla_data(nl_rate), nla_len(nl_rate),
1773 rate_policy);
1774 if (!tb_rate[NL80211_BITRATE_ATTR_RATE])
1775 continue;
1776 mode->rates[idx] = nla_get_u32(
1777 tb_rate[NL80211_BITRATE_ATTR_RATE]);
1778 idx++;
1779 }
1780
1781 return NL_OK;
1782 }
1783
1784
phy_info_iftype_copy(struct he_capabilities * he_capab,enum ieee80211_op_mode opmode,struct nlattr ** tb,struct nlattr ** tb_flags)1785 static void phy_info_iftype_copy(struct he_capabilities *he_capab,
1786 enum ieee80211_op_mode opmode,
1787 struct nlattr **tb, struct nlattr **tb_flags)
1788 {
1789 enum nl80211_iftype iftype;
1790 size_t len;
1791
1792 switch (opmode) {
1793 case IEEE80211_MODE_INFRA:
1794 iftype = NL80211_IFTYPE_STATION;
1795 break;
1796 case IEEE80211_MODE_IBSS:
1797 iftype = NL80211_IFTYPE_ADHOC;
1798 break;
1799 case IEEE80211_MODE_AP:
1800 iftype = NL80211_IFTYPE_AP;
1801 break;
1802 case IEEE80211_MODE_MESH:
1803 iftype = NL80211_IFTYPE_MESH_POINT;
1804 break;
1805 default:
1806 return;
1807 }
1808
1809 if (!nla_get_flag(tb_flags[iftype]))
1810 return;
1811
1812 he_capab->he_supported = 1;
1813
1814 if (tb[NL80211_BAND_IFTYPE_ATTR_HE_CAP_PHY]) {
1815 len = nla_len(tb[NL80211_BAND_IFTYPE_ATTR_HE_CAP_PHY]);
1816
1817 if (len > sizeof(he_capab->phy_cap))
1818 len = sizeof(he_capab->phy_cap);
1819 os_memcpy(he_capab->phy_cap,
1820 nla_data(tb[NL80211_BAND_IFTYPE_ATTR_HE_CAP_PHY]),
1821 len);
1822 }
1823
1824 if (tb[NL80211_BAND_IFTYPE_ATTR_HE_CAP_MAC]) {
1825 len = nla_len(tb[NL80211_BAND_IFTYPE_ATTR_HE_CAP_MAC]);
1826
1827 if (len > sizeof(he_capab->mac_cap))
1828 len = sizeof(he_capab->mac_cap);
1829 os_memcpy(he_capab->mac_cap,
1830 nla_data(tb[NL80211_BAND_IFTYPE_ATTR_HE_CAP_MAC]),
1831 len);
1832 }
1833
1834 if (tb[NL80211_BAND_IFTYPE_ATTR_HE_CAP_MCS_SET]) {
1835 len = nla_len(tb[NL80211_BAND_IFTYPE_ATTR_HE_CAP_MCS_SET]);
1836
1837 if (len > sizeof(he_capab->mcs))
1838 len = sizeof(he_capab->mcs);
1839 os_memcpy(he_capab->mcs,
1840 nla_data(tb[NL80211_BAND_IFTYPE_ATTR_HE_CAP_MCS_SET]),
1841 len);
1842 }
1843
1844 if (tb[NL80211_BAND_IFTYPE_ATTR_HE_CAP_PPE]) {
1845 len = nla_len(tb[NL80211_BAND_IFTYPE_ATTR_HE_CAP_PPE]);
1846
1847 if (len > sizeof(he_capab->ppet))
1848 len = sizeof(he_capab->ppet);
1849 os_memcpy(&he_capab->ppet,
1850 nla_data(tb[NL80211_BAND_IFTYPE_ATTR_HE_CAP_PPE]),
1851 len);
1852 }
1853
1854 if (tb[NL80211_BAND_IFTYPE_ATTR_HE_6GHZ_CAPA]) {
1855 u16 capa;
1856
1857 capa = nla_get_u16(tb[NL80211_BAND_IFTYPE_ATTR_HE_6GHZ_CAPA]);
1858 he_capab->he_6ghz_capa = le_to_host16(capa);
1859 }
1860 }
1861
1862
phy_info_iftype(struct hostapd_hw_modes * mode,struct nlattr * nl_iftype)1863 static int phy_info_iftype(struct hostapd_hw_modes *mode,
1864 struct nlattr *nl_iftype)
1865 {
1866 struct nlattr *tb[NL80211_BAND_IFTYPE_ATTR_MAX + 1];
1867 struct nlattr *tb_flags[NL80211_IFTYPE_MAX + 1];
1868 unsigned int i;
1869
1870 nla_parse(tb, NL80211_BAND_IFTYPE_ATTR_MAX,
1871 nla_data(nl_iftype), nla_len(nl_iftype), NULL);
1872
1873 if (!tb[NL80211_BAND_IFTYPE_ATTR_IFTYPES])
1874 return NL_STOP;
1875
1876 if (nla_parse_nested(tb_flags, NL80211_IFTYPE_MAX,
1877 tb[NL80211_BAND_IFTYPE_ATTR_IFTYPES], NULL))
1878 return NL_STOP;
1879
1880 for (i = 0; i < IEEE80211_MODE_NUM; i++)
1881 phy_info_iftype_copy(&mode->he_capab[i], i, tb, tb_flags);
1882
1883 return NL_OK;
1884 }
1885
1886
phy_info_band(struct phy_info_arg * phy_info,struct nlattr * nl_band)1887 static int phy_info_band(struct phy_info_arg *phy_info, struct nlattr *nl_band)
1888 {
1889 struct nlattr *tb_band[NL80211_BAND_ATTR_MAX + 1];
1890 struct hostapd_hw_modes *mode;
1891 int ret;
1892
1893 if (phy_info->last_mode != nl_band->nla_type) {
1894 mode = os_realloc_array(phy_info->modes,
1895 *phy_info->num_modes + 1,
1896 sizeof(*mode));
1897 if (!mode) {
1898 phy_info->failed = 1;
1899 return NL_STOP;
1900 }
1901 phy_info->modes = mode;
1902
1903 mode = &phy_info->modes[*(phy_info->num_modes)];
1904 os_memset(mode, 0, sizeof(*mode));
1905 mode->mode = NUM_HOSTAPD_MODES;
1906 mode->flags = HOSTAPD_MODE_FLAG_HT_INFO_KNOWN |
1907 HOSTAPD_MODE_FLAG_VHT_INFO_KNOWN;
1908
1909 /*
1910 * Unsupported VHT MCS stream is defined as value 3, so the VHT
1911 * MCS RX/TX map must be initialized with 0xffff to mark all 8
1912 * possible streams as unsupported. This will be overridden if
1913 * driver advertises VHT support.
1914 */
1915 mode->vht_mcs_set[0] = 0xff;
1916 mode->vht_mcs_set[1] = 0xff;
1917 mode->vht_mcs_set[4] = 0xff;
1918 mode->vht_mcs_set[5] = 0xff;
1919
1920 *(phy_info->num_modes) += 1;
1921 phy_info->last_mode = nl_band->nla_type;
1922 phy_info->last_chan_idx = 0;
1923 } else
1924 mode = &phy_info->modes[*(phy_info->num_modes) - 1];
1925
1926 nla_parse(tb_band, NL80211_BAND_ATTR_MAX, nla_data(nl_band),
1927 nla_len(nl_band), NULL);
1928
1929 phy_info_ht_capa(mode, tb_band[NL80211_BAND_ATTR_HT_CAPA],
1930 tb_band[NL80211_BAND_ATTR_HT_AMPDU_FACTOR],
1931 tb_band[NL80211_BAND_ATTR_HT_AMPDU_DENSITY],
1932 tb_band[NL80211_BAND_ATTR_HT_MCS_SET]);
1933 phy_info_vht_capa(mode, tb_band[NL80211_BAND_ATTR_VHT_CAPA],
1934 tb_band[NL80211_BAND_ATTR_VHT_MCS_SET]);
1935 ret = phy_info_edmg_capa(mode,
1936 tb_band[NL80211_BAND_ATTR_EDMG_BW_CONFIG],
1937 tb_band[NL80211_BAND_ATTR_EDMG_CHANNELS]);
1938 if (ret == NL_OK)
1939 ret = phy_info_freqs(phy_info, mode,
1940 tb_band[NL80211_BAND_ATTR_FREQS]);
1941 if (ret == NL_OK)
1942 ret = phy_info_rates(mode, tb_band[NL80211_BAND_ATTR_RATES]);
1943 if (ret != NL_OK) {
1944 phy_info->failed = 1;
1945 return ret;
1946 }
1947
1948 if (tb_band[NL80211_BAND_ATTR_IFTYPE_DATA]) {
1949 struct nlattr *nl_iftype;
1950 int rem_band;
1951
1952 nla_for_each_nested(nl_iftype,
1953 tb_band[NL80211_BAND_ATTR_IFTYPE_DATA],
1954 rem_band) {
1955 ret = phy_info_iftype(mode, nl_iftype);
1956 if (ret != NL_OK)
1957 return ret;
1958 }
1959 }
1960
1961 return NL_OK;
1962 }
1963
1964
phy_info_handler(struct nl_msg * msg,void * arg)1965 static int phy_info_handler(struct nl_msg *msg, void *arg)
1966 {
1967 struct nlattr *tb_msg[NL80211_ATTR_MAX + 1];
1968 struct genlmsghdr *gnlh = nlmsg_data(nlmsg_hdr(msg));
1969 struct phy_info_arg *phy_info = arg;
1970 struct nlattr *nl_band;
1971 int rem_band;
1972
1973 nla_parse(tb_msg, NL80211_ATTR_MAX, genlmsg_attrdata(gnlh, 0),
1974 genlmsg_attrlen(gnlh, 0), NULL);
1975
1976 if (!tb_msg[NL80211_ATTR_WIPHY_BANDS])
1977 return NL_SKIP;
1978
1979 nla_for_each_nested(nl_band, tb_msg[NL80211_ATTR_WIPHY_BANDS], rem_band)
1980 {
1981 int res = phy_info_band(phy_info, nl_band);
1982 if (res != NL_OK)
1983 return res;
1984 }
1985
1986 return NL_SKIP;
1987 }
1988
1989
1990 static struct hostapd_hw_modes *
wpa_driver_nl80211_postprocess_modes(struct hostapd_hw_modes * modes,u16 * num_modes)1991 wpa_driver_nl80211_postprocess_modes(struct hostapd_hw_modes *modes,
1992 u16 *num_modes)
1993 {
1994 u16 m;
1995 struct hostapd_hw_modes *mode11g = NULL, *nmodes, *mode;
1996 int i, mode11g_idx = -1;
1997
1998 /* heuristic to set up modes */
1999 for (m = 0; m < *num_modes; m++) {
2000 if (!modes[m].num_channels)
2001 continue;
2002 if (modes[m].channels[0].freq < 2000) {
2003 modes[m].num_channels = 0;
2004 continue;
2005 } else if (modes[m].channels[0].freq < 4000) {
2006 modes[m].mode = HOSTAPD_MODE_IEEE80211B;
2007 for (i = 0; i < modes[m].num_rates; i++) {
2008 if (modes[m].rates[i] > 200) {
2009 modes[m].mode = HOSTAPD_MODE_IEEE80211G;
2010 break;
2011 }
2012 }
2013 } else if (modes[m].channels[0].freq > 50000)
2014 modes[m].mode = HOSTAPD_MODE_IEEE80211AD;
2015 else
2016 modes[m].mode = HOSTAPD_MODE_IEEE80211A;
2017 }
2018
2019 /* Remove unsupported bands */
2020 m = 0;
2021 while (m < *num_modes) {
2022 if (modes[m].mode == NUM_HOSTAPD_MODES) {
2023 wpa_printf(MSG_DEBUG,
2024 "nl80211: Remove unsupported mode");
2025 os_free(modes[m].channels);
2026 os_free(modes[m].rates);
2027 if (m + 1 < *num_modes)
2028 os_memmove(&modes[m], &modes[m + 1],
2029 sizeof(struct hostapd_hw_modes) *
2030 (*num_modes - (m + 1)));
2031 (*num_modes)--;
2032 continue;
2033 }
2034 m++;
2035 }
2036
2037 /* If only 802.11g mode is included, use it to construct matching
2038 * 802.11b mode data. */
2039
2040 for (m = 0; m < *num_modes; m++) {
2041 if (modes[m].mode == HOSTAPD_MODE_IEEE80211B)
2042 return modes; /* 802.11b already included */
2043 if (modes[m].mode == HOSTAPD_MODE_IEEE80211G)
2044 mode11g_idx = m;
2045 }
2046
2047 if (mode11g_idx < 0)
2048 return modes; /* 2.4 GHz band not supported at all */
2049
2050 nmodes = os_realloc_array(modes, *num_modes + 1, sizeof(*nmodes));
2051 if (nmodes == NULL)
2052 return modes; /* Could not add 802.11b mode */
2053
2054 mode = &nmodes[*num_modes];
2055 os_memset(mode, 0, sizeof(*mode));
2056 (*num_modes)++;
2057 modes = nmodes;
2058
2059 mode->mode = HOSTAPD_MODE_IEEE80211B;
2060
2061 mode11g = &modes[mode11g_idx];
2062 mode->num_channels = mode11g->num_channels;
2063 mode->channels = os_memdup(mode11g->channels,
2064 mode11g->num_channels *
2065 sizeof(struct hostapd_channel_data));
2066 if (mode->channels == NULL) {
2067 (*num_modes)--;
2068 return modes; /* Could not add 802.11b mode */
2069 }
2070
2071 mode->num_rates = 0;
2072 mode->rates = os_malloc(4 * sizeof(int));
2073 if (mode->rates == NULL) {
2074 os_free(mode->channels);
2075 (*num_modes)--;
2076 return modes; /* Could not add 802.11b mode */
2077 }
2078
2079 for (i = 0; i < mode11g->num_rates; i++) {
2080 if (mode11g->rates[i] != 10 && mode11g->rates[i] != 20 &&
2081 mode11g->rates[i] != 55 && mode11g->rates[i] != 110)
2082 continue;
2083 mode->rates[mode->num_rates] = mode11g->rates[i];
2084 mode->num_rates++;
2085 if (mode->num_rates == 4)
2086 break;
2087 }
2088
2089 if (mode->num_rates == 0) {
2090 os_free(mode->channels);
2091 os_free(mode->rates);
2092 (*num_modes)--;
2093 return modes; /* No 802.11b rates */
2094 }
2095
2096 wpa_printf(MSG_EXCESSIVE, "nl80211: Added 802.11b mode based on 802.11g "
2097 "information");
2098
2099 return modes;
2100 }
2101
2102
nl80211_set_ht40_mode(struct hostapd_hw_modes * mode,int start,int end)2103 static void nl80211_set_ht40_mode(struct hostapd_hw_modes *mode, int start,
2104 int end)
2105 {
2106 int c;
2107
2108 for (c = 0; c < mode->num_channels; c++) {
2109 struct hostapd_channel_data *chan = &mode->channels[c];
2110 if (chan->freq - 10 >= start && chan->freq + 10 <= end)
2111 chan->flag |= HOSTAPD_CHAN_HT40;
2112 }
2113 }
2114
2115
nl80211_set_ht40_mode_sec(struct hostapd_hw_modes * mode,int start,int end)2116 static void nl80211_set_ht40_mode_sec(struct hostapd_hw_modes *mode, int start,
2117 int end)
2118 {
2119 int c;
2120
2121 for (c = 0; c < mode->num_channels; c++) {
2122 struct hostapd_channel_data *chan = &mode->channels[c];
2123 if (!(chan->flag & HOSTAPD_CHAN_HT40))
2124 continue;
2125 if (chan->freq - 30 >= start && chan->freq - 10 <= end)
2126 chan->flag |= HOSTAPD_CHAN_HT40MINUS;
2127 if (chan->freq + 10 >= start && chan->freq + 30 <= end)
2128 chan->flag |= HOSTAPD_CHAN_HT40PLUS;
2129 }
2130 }
2131
2132
nl80211_reg_rule_max_eirp(u32 start,u32 end,u32 max_eirp,struct phy_info_arg * results)2133 static void nl80211_reg_rule_max_eirp(u32 start, u32 end, u32 max_eirp,
2134 struct phy_info_arg *results)
2135 {
2136 u16 m;
2137
2138 for (m = 0; m < *results->num_modes; m++) {
2139 int c;
2140 struct hostapd_hw_modes *mode = &results->modes[m];
2141
2142 for (c = 0; c < mode->num_channels; c++) {
2143 struct hostapd_channel_data *chan = &mode->channels[c];
2144 if ((u32) chan->freq - 10 >= start &&
2145 (u32) chan->freq + 10 <= end)
2146 chan->max_tx_power = max_eirp;
2147 }
2148 }
2149 }
2150
2151
nl80211_reg_rule_ht40(u32 start,u32 end,struct phy_info_arg * results)2152 static void nl80211_reg_rule_ht40(u32 start, u32 end,
2153 struct phy_info_arg *results)
2154 {
2155 u16 m;
2156
2157 for (m = 0; m < *results->num_modes; m++) {
2158 if (!(results->modes[m].ht_capab &
2159 HT_CAP_INFO_SUPP_CHANNEL_WIDTH_SET))
2160 continue;
2161 nl80211_set_ht40_mode(&results->modes[m], start, end);
2162 }
2163 }
2164
2165
nl80211_reg_rule_sec(struct nlattr * tb[],struct phy_info_arg * results)2166 static void nl80211_reg_rule_sec(struct nlattr *tb[],
2167 struct phy_info_arg *results)
2168 {
2169 u32 start, end, max_bw;
2170 u16 m;
2171
2172 if (tb[NL80211_ATTR_FREQ_RANGE_START] == NULL ||
2173 tb[NL80211_ATTR_FREQ_RANGE_END] == NULL ||
2174 tb[NL80211_ATTR_FREQ_RANGE_MAX_BW] == NULL)
2175 return;
2176
2177 start = nla_get_u32(tb[NL80211_ATTR_FREQ_RANGE_START]) / 1000;
2178 end = nla_get_u32(tb[NL80211_ATTR_FREQ_RANGE_END]) / 1000;
2179 max_bw = nla_get_u32(tb[NL80211_ATTR_FREQ_RANGE_MAX_BW]) / 1000;
2180
2181 if (max_bw < 20)
2182 return;
2183
2184 for (m = 0; m < *results->num_modes; m++) {
2185 if (!(results->modes[m].ht_capab &
2186 HT_CAP_INFO_SUPP_CHANNEL_WIDTH_SET))
2187 continue;
2188 nl80211_set_ht40_mode_sec(&results->modes[m], start, end);
2189 }
2190 }
2191
2192
nl80211_set_vht_mode(struct hostapd_hw_modes * mode,int start,int end,int max_bw)2193 static void nl80211_set_vht_mode(struct hostapd_hw_modes *mode, int start,
2194 int end, int max_bw)
2195 {
2196 int c;
2197
2198 for (c = 0; c < mode->num_channels; c++) {
2199 struct hostapd_channel_data *chan = &mode->channels[c];
2200 if (chan->freq - 10 >= start && chan->freq + 70 <= end)
2201 chan->flag |= HOSTAPD_CHAN_VHT_10_70;
2202
2203 if (chan->freq - 30 >= start && chan->freq + 50 <= end)
2204 chan->flag |= HOSTAPD_CHAN_VHT_30_50;
2205
2206 if (chan->freq - 50 >= start && chan->freq + 30 <= end)
2207 chan->flag |= HOSTAPD_CHAN_VHT_50_30;
2208
2209 if (chan->freq - 70 >= start && chan->freq + 10 <= end)
2210 chan->flag |= HOSTAPD_CHAN_VHT_70_10;
2211
2212 if (max_bw >= 160) {
2213 if (chan->freq - 10 >= start && chan->freq + 150 <= end)
2214 chan->flag |= HOSTAPD_CHAN_VHT_10_150;
2215
2216 if (chan->freq - 30 >= start && chan->freq + 130 <= end)
2217 chan->flag |= HOSTAPD_CHAN_VHT_30_130;
2218
2219 if (chan->freq - 50 >= start && chan->freq + 110 <= end)
2220 chan->flag |= HOSTAPD_CHAN_VHT_50_110;
2221
2222 if (chan->freq - 70 >= start && chan->freq + 90 <= end)
2223 chan->flag |= HOSTAPD_CHAN_VHT_70_90;
2224
2225 if (chan->freq - 90 >= start && chan->freq + 70 <= end)
2226 chan->flag |= HOSTAPD_CHAN_VHT_90_70;
2227
2228 if (chan->freq - 110 >= start && chan->freq + 50 <= end)
2229 chan->flag |= HOSTAPD_CHAN_VHT_110_50;
2230
2231 if (chan->freq - 130 >= start && chan->freq + 30 <= end)
2232 chan->flag |= HOSTAPD_CHAN_VHT_130_30;
2233
2234 if (chan->freq - 150 >= start && chan->freq + 10 <= end)
2235 chan->flag |= HOSTAPD_CHAN_VHT_150_10;
2236 }
2237 }
2238 }
2239
2240
nl80211_reg_rule_vht(struct nlattr * tb[],struct phy_info_arg * results)2241 static void nl80211_reg_rule_vht(struct nlattr *tb[],
2242 struct phy_info_arg *results)
2243 {
2244 u32 start, end, max_bw;
2245 u16 m;
2246
2247 if (tb[NL80211_ATTR_FREQ_RANGE_START] == NULL ||
2248 tb[NL80211_ATTR_FREQ_RANGE_END] == NULL ||
2249 tb[NL80211_ATTR_FREQ_RANGE_MAX_BW] == NULL)
2250 return;
2251
2252 start = nla_get_u32(tb[NL80211_ATTR_FREQ_RANGE_START]) / 1000;
2253 end = nla_get_u32(tb[NL80211_ATTR_FREQ_RANGE_END]) / 1000;
2254 max_bw = nla_get_u32(tb[NL80211_ATTR_FREQ_RANGE_MAX_BW]) / 1000;
2255
2256 if (max_bw < 80)
2257 return;
2258
2259 for (m = 0; m < *results->num_modes; m++) {
2260 if (!(results->modes[m].ht_capab &
2261 HT_CAP_INFO_SUPP_CHANNEL_WIDTH_SET))
2262 continue;
2263 /* TODO: use a real VHT support indication */
2264 if (!results->modes[m].vht_capab)
2265 continue;
2266
2267 nl80211_set_vht_mode(&results->modes[m], start, end, max_bw);
2268 }
2269 }
2270
2271
nl80211_set_dfs_domain(enum nl80211_dfs_regions region,u8 * dfs_domain)2272 static void nl80211_set_dfs_domain(enum nl80211_dfs_regions region,
2273 u8 *dfs_domain)
2274 {
2275 if (region == NL80211_DFS_FCC)
2276 *dfs_domain = HOSTAPD_DFS_REGION_FCC;
2277 else if (region == NL80211_DFS_ETSI)
2278 *dfs_domain = HOSTAPD_DFS_REGION_ETSI;
2279 else if (region == NL80211_DFS_JP)
2280 *dfs_domain = HOSTAPD_DFS_REGION_JP;
2281 else
2282 *dfs_domain = 0;
2283 }
2284
2285
dfs_domain_name(enum nl80211_dfs_regions region)2286 static const char * dfs_domain_name(enum nl80211_dfs_regions region)
2287 {
2288 switch (region) {
2289 case NL80211_DFS_UNSET:
2290 return "DFS-UNSET";
2291 case NL80211_DFS_FCC:
2292 return "DFS-FCC";
2293 case NL80211_DFS_ETSI:
2294 return "DFS-ETSI";
2295 case NL80211_DFS_JP:
2296 return "DFS-JP";
2297 default:
2298 return "DFS-invalid";
2299 }
2300 }
2301
2302
nl80211_get_reg(struct nl_msg * msg,void * arg)2303 static int nl80211_get_reg(struct nl_msg *msg, void *arg)
2304 {
2305 struct phy_info_arg *results = arg;
2306 struct nlattr *tb_msg[NL80211_ATTR_MAX + 1];
2307 struct genlmsghdr *gnlh = nlmsg_data(nlmsg_hdr(msg));
2308 struct nlattr *nl_rule;
2309 struct nlattr *tb_rule[NL80211_FREQUENCY_ATTR_MAX + 1];
2310 int rem_rule;
2311 static struct nla_policy reg_policy[NL80211_FREQUENCY_ATTR_MAX + 1] = {
2312 [NL80211_ATTR_REG_RULE_FLAGS] = { .type = NLA_U32 },
2313 [NL80211_ATTR_FREQ_RANGE_START] = { .type = NLA_U32 },
2314 [NL80211_ATTR_FREQ_RANGE_END] = { .type = NLA_U32 },
2315 [NL80211_ATTR_FREQ_RANGE_MAX_BW] = { .type = NLA_U32 },
2316 [NL80211_ATTR_POWER_RULE_MAX_ANT_GAIN] = { .type = NLA_U32 },
2317 [NL80211_ATTR_POWER_RULE_MAX_EIRP] = { .type = NLA_U32 },
2318 };
2319
2320 nla_parse(tb_msg, NL80211_ATTR_MAX, genlmsg_attrdata(gnlh, 0),
2321 genlmsg_attrlen(gnlh, 0), NULL);
2322 if (!tb_msg[NL80211_ATTR_REG_ALPHA2] ||
2323 !tb_msg[NL80211_ATTR_REG_RULES]) {
2324 wpa_printf(MSG_DEBUG, "nl80211: No regulatory information "
2325 "available");
2326 return NL_SKIP;
2327 }
2328
2329 if (tb_msg[NL80211_ATTR_DFS_REGION]) {
2330 enum nl80211_dfs_regions dfs_domain;
2331 dfs_domain = nla_get_u8(tb_msg[NL80211_ATTR_DFS_REGION]);
2332 nl80211_set_dfs_domain(dfs_domain, &results->dfs_domain);
2333 wpa_printf(MSG_EXCESSIVE, "nl80211: Regulatory information - country=%s (%s)",
2334 (char *) nla_data(tb_msg[NL80211_ATTR_REG_ALPHA2]),
2335 dfs_domain_name(dfs_domain));
2336 } else {
2337 wpa_printf(MSG_EXCESSIVE, "nl80211: Regulatory information - country=%s",
2338 (char *) nla_data(tb_msg[NL80211_ATTR_REG_ALPHA2]));
2339 }
2340
2341 nla_for_each_nested(nl_rule, tb_msg[NL80211_ATTR_REG_RULES], rem_rule)
2342 {
2343 u32 start, end, max_eirp = 0, max_bw = 0, flags = 0;
2344 nla_parse(tb_rule, NL80211_FREQUENCY_ATTR_MAX,
2345 nla_data(nl_rule), nla_len(nl_rule), reg_policy);
2346 if (tb_rule[NL80211_ATTR_FREQ_RANGE_START] == NULL ||
2347 tb_rule[NL80211_ATTR_FREQ_RANGE_END] == NULL)
2348 continue;
2349 start = nla_get_u32(tb_rule[NL80211_ATTR_FREQ_RANGE_START]) / 1000;
2350 end = nla_get_u32(tb_rule[NL80211_ATTR_FREQ_RANGE_END]) / 1000;
2351 if (tb_rule[NL80211_ATTR_POWER_RULE_MAX_EIRP])
2352 max_eirp = nla_get_u32(tb_rule[NL80211_ATTR_POWER_RULE_MAX_EIRP]) / 100;
2353 if (tb_rule[NL80211_ATTR_FREQ_RANGE_MAX_BW])
2354 max_bw = nla_get_u32(tb_rule[NL80211_ATTR_FREQ_RANGE_MAX_BW]) / 1000;
2355 if (tb_rule[NL80211_ATTR_REG_RULE_FLAGS])
2356 flags = nla_get_u32(tb_rule[NL80211_ATTR_REG_RULE_FLAGS]);
2357
2358 wpa_printf(MSG_EXCESSIVE, "nl80211: %u-%u @ %u MHz %u mBm%s%s%s%s%s%s%s%s",
2359 start, end, max_bw, max_eirp,
2360 flags & NL80211_RRF_NO_OFDM ? " (no OFDM)" : "",
2361 flags & NL80211_RRF_NO_CCK ? " (no CCK)" : "",
2362 flags & NL80211_RRF_NO_INDOOR ? " (no indoor)" : "",
2363 flags & NL80211_RRF_NO_OUTDOOR ? " (no outdoor)" :
2364 "",
2365 flags & NL80211_RRF_DFS ? " (DFS)" : "",
2366 flags & NL80211_RRF_PTP_ONLY ? " (PTP only)" : "",
2367 flags & NL80211_RRF_PTMP_ONLY ? " (PTMP only)" : "",
2368 flags & NL80211_RRF_NO_IR ? " (no IR)" : "");
2369 if (max_bw >= 40)
2370 nl80211_reg_rule_ht40(start, end, results);
2371 if (tb_rule[NL80211_ATTR_POWER_RULE_MAX_EIRP])
2372 nl80211_reg_rule_max_eirp(start, end, max_eirp,
2373 results);
2374 }
2375
2376 nla_for_each_nested(nl_rule, tb_msg[NL80211_ATTR_REG_RULES], rem_rule)
2377 {
2378 nla_parse(tb_rule, NL80211_FREQUENCY_ATTR_MAX,
2379 nla_data(nl_rule), nla_len(nl_rule), reg_policy);
2380 nl80211_reg_rule_sec(tb_rule, results);
2381 }
2382
2383 nla_for_each_nested(nl_rule, tb_msg[NL80211_ATTR_REG_RULES], rem_rule)
2384 {
2385 nla_parse(tb_rule, NL80211_FREQUENCY_ATTR_MAX,
2386 nla_data(nl_rule), nla_len(nl_rule), reg_policy);
2387 nl80211_reg_rule_vht(tb_rule, results);
2388 }
2389
2390 return NL_SKIP;
2391 }
2392
2393
nl80211_set_regulatory_flags(struct wpa_driver_nl80211_data * drv,struct phy_info_arg * results)2394 static int nl80211_set_regulatory_flags(struct wpa_driver_nl80211_data *drv,
2395 struct phy_info_arg *results)
2396 {
2397 struct nl_msg *msg;
2398
2399 msg = nlmsg_alloc();
2400 if (!msg)
2401 return -ENOMEM;
2402
2403 nl80211_cmd(drv, msg, 0, NL80211_CMD_GET_REG);
2404 if (drv->capa.flags & WPA_DRIVER_FLAGS_SELF_MANAGED_REGULATORY) {
2405 if (nla_put_u32(msg, NL80211_ATTR_WIPHY, drv->wiphy_idx)) {
2406 nlmsg_free(msg);
2407 return -1;
2408 }
2409 }
2410
2411 return send_and_recv_msgs(drv, msg, nl80211_get_reg, results,
2412 NULL, NULL);
2413 }
2414
2415
modestr(enum hostapd_hw_mode mode)2416 static const char * modestr(enum hostapd_hw_mode mode)
2417 {
2418 switch (mode) {
2419 case HOSTAPD_MODE_IEEE80211B:
2420 return "802.11b";
2421 case HOSTAPD_MODE_IEEE80211G:
2422 return "802.11g";
2423 case HOSTAPD_MODE_IEEE80211A:
2424 return "802.11a";
2425 case HOSTAPD_MODE_IEEE80211AD:
2426 return "802.11ad";
2427 default:
2428 return "?";
2429 }
2430 }
2431
2432
nl80211_dump_chan_list(struct hostapd_hw_modes * modes,u16 num_modes)2433 static void nl80211_dump_chan_list(struct hostapd_hw_modes *modes,
2434 u16 num_modes)
2435 {
2436 int i;
2437
2438 if (!modes)
2439 return;
2440
2441 for (i = 0; i < num_modes; i++) {
2442 struct hostapd_hw_modes *mode = &modes[i];
2443 char str[200];
2444 char *pos = str;
2445 char *end = pos + sizeof(str);
2446 int j, res;
2447
2448 for (j = 0; j < mode->num_channels; j++) {
2449 struct hostapd_channel_data *chan = &mode->channels[j];
2450
2451 res = os_snprintf(pos, end - pos, " %d%s%s%s",
2452 chan->freq,
2453 (chan->flag & HOSTAPD_CHAN_DISABLED) ?
2454 "[DISABLED]" : "",
2455 (chan->flag & HOSTAPD_CHAN_NO_IR) ?
2456 "[NO_IR]" : "",
2457 (chan->flag & HOSTAPD_CHAN_RADAR) ?
2458 "[RADAR]" : "");
2459 if (os_snprintf_error(end - pos, res))
2460 break;
2461 pos += res;
2462 }
2463
2464 *pos = '\0';
2465 wpa_printf(MSG_DEBUG, "nl80211: Mode IEEE %s:%s",
2466 modestr(mode->mode), str);
2467 }
2468 }
2469
2470
2471 struct hostapd_hw_modes *
nl80211_get_hw_feature_data(void * priv,u16 * num_modes,u16 * flags,u8 * dfs_domain)2472 nl80211_get_hw_feature_data(void *priv, u16 *num_modes, u16 *flags,
2473 u8 *dfs_domain)
2474 {
2475 if (priv == NULL) {
2476 return NULL;
2477 }
2478 u32 feat;
2479 struct i802_bss *bss = priv;
2480 struct wpa_driver_nl80211_data *drv = bss->drv;
2481 int nl_flags = 0;
2482 struct nl_msg *msg;
2483 struct phy_info_arg result = {
2484 .num_modes = num_modes,
2485 .modes = NULL,
2486 .last_mode = -1,
2487 .failed = 0,
2488 .dfs_domain = 0,
2489 };
2490
2491 *num_modes = 0;
2492 *flags = 0;
2493 *dfs_domain = 0;
2494
2495 feat = get_nl80211_protocol_features(drv);
2496 if (feat & NL80211_PROTOCOL_FEATURE_SPLIT_WIPHY_DUMP)
2497 nl_flags = NLM_F_DUMP;
2498 if (!(msg = nl80211_cmd_msg(bss, nl_flags, NL80211_CMD_GET_WIPHY)) ||
2499 nla_put_flag(msg, NL80211_ATTR_SPLIT_WIPHY_DUMP)) {
2500 nlmsg_free(msg);
2501 return NULL;
2502 }
2503
2504 if (send_and_recv_msgs(drv, msg, phy_info_handler, &result,
2505 NULL, NULL) == 0) {
2506 struct hostapd_hw_modes *modes;
2507
2508 nl80211_set_regulatory_flags(drv, &result);
2509 if (result.failed) {
2510 int i;
2511
2512 for (i = 0; result.modes && i < *num_modes; i++) {
2513 os_free(result.modes[i].channels);
2514 os_free(result.modes[i].rates);
2515 }
2516 os_free(result.modes);
2517 *num_modes = 0;
2518 return NULL;
2519 }
2520
2521 *dfs_domain = result.dfs_domain;
2522
2523 modes = wpa_driver_nl80211_postprocess_modes(result.modes,
2524 num_modes);
2525 nl80211_dump_chan_list(modes, *num_modes);
2526 return modes;
2527 }
2528
2529 return NULL;
2530 }
2531