forked from Wi-FiQuickTrack/Wi-FiQuickTrack-ControlAppC
-
Notifications
You must be signed in to change notification settings - Fork 0
/
indigo_api_callback_dut.c
3787 lines (3408 loc) · 134 KB
/
indigo_api_callback_dut.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/* Copyright (c) 2020 Wi-Fi Alliance */
/* Permission to use, copy, modify, and/or distribute this software for any */
/* purpose with or without fee is hereby granted, provided that the above */
/* copyright notice and this permission notice appear in all copies. */
/* THE SOFTWARE IS PROVIDED 'AS IS' AND THE AUTHOR DISCLAIMS ALL */
/* WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED */
/* WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL */
/* THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR */
/* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING */
/* FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF */
/* CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT */
/* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS */
/* SOFTWARE. */
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/stat.h>
#include <arpa/inet.h>
#include "indigo_api.h"
#include "vendor_specific.h"
#include "utils.h"
#include "wpa_ctrl.h"
#include "indigo_api_callback.h"
#include "hs2_profile.h"
static char pac_file_path[S_BUFFER_LEN] = {0};
struct interface_info* band_transmitter[16];
struct interface_info* band_first_wlan[16];
extern struct sockaddr_in *tool_addr;
int sta_configured = 0;
int sta_started = 0;
void register_apis() {
/* Basic */
register_api(API_GET_IP_ADDR, NULL, get_ip_addr_handler);
register_api(API_GET_MAC_ADDR, NULL, get_mac_addr_handler);
register_api(API_GET_CONTROL_APP_VERSION, NULL, get_control_app_handler);
register_api(API_START_LOOP_BACK_SERVER, NULL, start_loopback_server);
register_api(API_STOP_LOOP_BACK_SERVER, NULL, stop_loop_back_server_handler);
register_api(API_CREATE_NEW_INTERFACE_BRIDGE_NETWORK, NULL, create_bridge_network_handler);
register_api(API_ASSIGN_STATIC_IP, NULL, assign_static_ip_handler);
register_api(API_DEVICE_RESET, NULL, reset_device_handler);
register_api(API_START_DHCP, NULL, start_dhcp_handler);
register_api(API_STOP_DHCP, NULL, stop_dhcp_handler);
register_api(API_GET_WSC_PIN, NULL, get_wsc_pin_handler);
register_api(API_GET_WSC_CRED, NULL, get_wsc_cred_handler);
/* AP */
register_api(API_AP_START_UP, NULL, start_ap_handler);
register_api(API_AP_STOP, NULL, stop_ap_handler);
register_api(API_AP_CONFIGURE, NULL, configure_ap_handler);
register_api(API_AP_TRIGGER_CHANSWITCH, NULL, trigger_ap_channel_switch);
register_api(API_AP_SEND_DISCONNECT, NULL, send_ap_disconnect_handler);
register_api(API_AP_SET_PARAM , NULL, set_ap_parameter_handler);
register_api(API_AP_SEND_BTM_REQ, NULL, send_ap_btm_handler);
register_api(API_AP_START_WPS, NULL, start_wps_ap_handler);
register_api(API_AP_CONFIGURE_WSC, NULL, configure_ap_wsc_handler);
/* STA */
register_api(API_STA_ASSOCIATE, NULL, associate_sta_handler);
register_api(API_STA_CONFIGURE, NULL, configure_sta_handler);
register_api(API_STA_DISCONNECT, NULL, stop_sta_handler);
register_api(API_STA_SEND_DISCONNECT, NULL, send_sta_disconnect_handler);
register_api(API_STA_REASSOCIATE, NULL, send_sta_reconnect_handler);
register_api(API_STA_SET_PARAM, NULL, set_sta_parameter_handler);
register_api(API_STA_SEND_BTM_QUERY, NULL, send_sta_btm_query_handler);
register_api(API_STA_SEND_ANQP_QUERY, NULL, send_sta_anqp_query_handler);
register_api(API_STA_SCAN, NULL, sta_scan_handler);
register_api(API_STA_START_WPS, NULL, start_wps_sta_handler);
register_api(API_STA_HS2_ASSOCIATE, NULL, set_sta_hs2_associate_handler);
register_api(API_STA_ADD_CREDENTIAL, NULL, sta_add_credential_handler);
register_api(API_STA_INSTALL_PPSMO, NULL, set_sta_install_ppsmo_handler);
/* TODO: Add the handlers */
register_api(API_STA_SET_CHANNEL_WIDTH, NULL, NULL);
register_api(API_STA_POWER_SAVE, NULL, NULL);
register_api(API_P2P_START_UP, NULL, start_up_p2p_handler);
register_api(API_P2P_FIND, NULL, p2p_find_handler);
register_api(API_P2P_LISTEN, NULL, p2p_listen_handler);
register_api(API_P2P_ADD_GROUP, NULL, add_p2p_group_handler);
register_api(API_P2P_START_WPS, NULL, p2p_start_wps_handler);
register_api(API_P2P_CONNECT, NULL, p2p_connect_handler);
register_api(API_P2P_GET_INTENT_VALUE, NULL, get_p2p_intent_value_handler);
register_api(API_P2P_INVITE, NULL, p2p_invite_handler);
register_api(API_P2P_STOP_GROUP, NULL, stop_p2p_group_handler);
register_api(API_P2P_SET_SERV_DISC, NULL, set_p2p_serv_disc_handler);
register_api(API_P2P_SET_EXT_LISTEN, NULL, set_p2p_ext_listen_handler);
register_api(API_STA_ENABLE_WSC, NULL, enable_wsc_sta_handler);
}
static int get_control_app_handler(struct packet_wrapper *req, struct packet_wrapper *resp) {
char ipAddress[INET_ADDRSTRLEN];
char buffer[S_BUFFER_LEN];
#ifdef _VERSION_
snprintf(buffer, sizeof(buffer), "%s", _VERSION_);
#else
snprintf(buffer, sizeof(buffer), "%s", TLV_VALUE_APP_VERSION);
#endif
if (tool_addr) {
inet_ntop(AF_INET, &(tool_addr->sin_addr), ipAddress, INET_ADDRSTRLEN);
indigo_logger(LOG_LEVEL_DEBUG, "Tool Control IP address on DUT network path: %s", ipAddress);
}
fill_wrapper_message_hdr(resp, API_CMD_RESPONSE, req->hdr.seq);
fill_wrapper_tlv_byte(resp, TLV_STATUS, TLV_VALUE_STATUS_OK);
fill_wrapper_tlv_bytes(resp, TLV_MESSAGE, strlen(TLV_VALUE_OK), TLV_VALUE_OK);
fill_wrapper_tlv_bytes(resp, TLV_CONTROL_APP_VERSION, strlen(buffer), buffer);
return 0;
}
static int reset_device_handler(struct packet_wrapper *req, struct packet_wrapper *resp) {
int len, status = TLV_VALUE_STATUS_NOT_OK;
char *message = TLV_VALUE_RESET_NOT_OK;
char buffer[TLV_VALUE_SIZE];
char role[TLV_VALUE_SIZE], log_level[TLV_VALUE_SIZE], band[TLV_VALUE_SIZE];
struct tlv_hdr *tlv = NULL;
/* TLV: ROLE */
tlv = find_wrapper_tlv_by_id(req, TLV_ROLE);
memset(role, 0, sizeof(role));
if (tlv) {
memcpy(role, tlv->value, tlv->len);
} else {
goto done;
}
/* TLV: DEBUG_LEVEL */
tlv = find_wrapper_tlv_by_id(req, TLV_DEBUG_LEVEL);
memset(log_level, 0, sizeof(log_level));
if (tlv) {
memcpy(log_level, tlv->value, tlv->len);
}
/* TLV: TLV_BAND */
memset(band, 0, sizeof(band));
tlv = find_wrapper_tlv_by_id(req, TLV_BAND);
if (tlv) {
memcpy(band, tlv->value, tlv->len);
}
if (atoi(role) == DUT_TYPE_STAUT) {
/* stop the wpa_supplicant and release IP address */
memset(buffer, 0, sizeof(buffer));
sprintf(buffer, "killall %s 1>/dev/null 2>/dev/null", get_wpas_exec_file());
system(buffer);
sleep(1);
reset_interface_ip(get_wireless_interface());
if (strlen(log_level)) {
set_wpas_debug_level(get_debug_level(atoi(log_level)));
}
sta_configured = 0;
sta_started = 0;
} else if (atoi(role) == DUT_TYPE_APUT) {
/* stop the hostapd and release IP address */
memset(buffer, 0, sizeof(buffer));
sprintf(buffer, "killall %s 1>/dev/null 2>/dev/null", get_hapd_exec_file());
system(buffer);
sleep(1);
reset_interface_ip(get_wireless_interface());
if (strlen(log_level)) {
set_hostapd_debug_level(get_debug_level(atoi(log_level)));
}
reset_bridge(get_wlans_bridge());
/* reset interfaces info */
clear_interfaces_resource();
} else if (atoi(role) == DUT_TYPE_P2PUT) {
/* If TP is P2P client, GO can't stop before client removes group monitor if */
// sprintf(buffer, "killall %s 1>/dev/null 2>/dev/null", get_wpas_exec_file());
// reset_interface_ip(get_wireless_interface());
if (strlen(log_level)) {
set_wpas_debug_level(get_debug_level(atoi(log_level)));
}
}
if (strcmp(band, TLV_BAND_24GHZ) == 0) {
set_default_wireless_interface_info(BAND_24GHZ);
} else if (strcmp(band, TLV_BAND_5GHZ) == 0) {
set_default_wireless_interface_info(BAND_5GHZ);
} else if (strcmp(band, TLV_BAND_6GHZ) == 0) {
set_default_wireless_interface_info(BAND_6GHZ);
}
memset(band_transmitter, 0, sizeof(band_transmitter));
memset(band_first_wlan, 0, sizeof(band_first_wlan));
vendor_device_reset();
sleep(1);
status = TLV_VALUE_STATUS_OK;
message = TLV_VALUE_RESET_OK;
done:
fill_wrapper_message_hdr(resp, API_CMD_RESPONSE, req->hdr.seq);
fill_wrapper_tlv_byte(resp, TLV_STATUS, status);
fill_wrapper_tlv_bytes(resp, TLV_MESSAGE, strlen(message), message);
return 0;
}
// RESP: {<ResponseTLV.STATUS: 40961>: '0', <ResponseTLV.MESSAGE: 40960>: 'AP stop completed : Hostapd service is inactive.'}
static int stop_ap_handler(struct packet_wrapper *req, struct packet_wrapper *resp) {
int len = 0, reset = 0;
char buffer[S_BUFFER_LEN], reset_type[16];
char *parameter[] = {"pidof", get_hapd_exec_file(), NULL};
char *message = NULL;
struct tlv_hdr *tlv = NULL;
/* TLV: RESET_TYPE */
tlv = find_wrapper_tlv_by_id(req, TLV_RESET_TYPE);
memset(reset_type, 0, sizeof(reset_type));
if (tlv) {
memcpy(reset_type, tlv->value, tlv->len);
reset = atoi(reset_type);
indigo_logger(LOG_LEVEL_DEBUG, "Reset Type: %d", reset);
}
if (reset == RESET_TYPE_INIT) {
open_tc_app_log();
system("rm -rf /var/log/hostapd.log >/dev/null 2>/dev/null");
}
memset(buffer, 0, sizeof(buffer));
sprintf(buffer, "killall %s 1>/dev/null 2>/dev/null", get_hapd_exec_file());
system(buffer);
sleep(2);
#ifdef _OPENWRT_
#else
len = system("rfkill unblock wlan");
if (len) {
indigo_logger(LOG_LEVEL_DEBUG, "Failed to run rfkill unblock wlan");
}
sleep(1);
#endif
memset(buffer, 0, sizeof(buffer));
len = pipe_command(buffer, sizeof(buffer), "/bin/pidof", parameter);
if (len) {
message = TLV_VALUE_HOSTAPD_STOP_NOT_OK;
} else {
message = TLV_VALUE_HOSTAPD_STOP_OK;
}
/* reset interfaces info */
clear_interfaces_resource();
memset(band_transmitter, 0, sizeof(band_transmitter));
memset(band_first_wlan, 0, sizeof(band_first_wlan));
/* Test case teardown case */
if (reset == RESET_TYPE_TEARDOWN) {
close_tc_app_log();
}
fill_wrapper_message_hdr(resp, API_CMD_RESPONSE, req->hdr.seq);
fill_wrapper_tlv_byte(resp, TLV_STATUS, len == 0 ? TLV_VALUE_STATUS_OK : TLV_VALUE_STATUS_NOT_OK);
fill_wrapper_tlv_bytes(resp, TLV_MESSAGE, strlen(message), message);
return 0;
}
#ifdef _RESERVED_
/* The function is reserved for the defeault hostapd config */
#define HOSTAPD_DEFAULT_CONFIG_SSID "QuickTrack"
#define HOSTAPD_DEFAULT_CONFIG_CHANNEL "36"
#define HOSTAPD_DEFAULT_CONFIG_HW_MODE "a"
#define HOSTAPD_DEFAULT_CONFIG_WPA_PASSPHRASE "12345678"
#define HOSTAPD_DEFAULT_CONFIG_IEEE80211N "1"
#define HOSTAPD_DEFAULT_CONFIG_WPA "2"
#define HOSTAPD_DEFAULT_CONFIG_WPA_KEY_MGMT "WPA-PSK"
#define HOSTAPD_DEFAULT_CONFIG_RSN_PAIRWISE "CCMP"
static void append_hostapd_default_config(struct packet_wrapper *wrapper) {
if (find_wrapper_tlv_by_id(wrapper, TLV_SSID) == NULL) {
add_wrapper_tlv(wrapper, TLV_SSID, strlen(HOSTAPD_DEFAULT_CONFIG_SSID), HOSTAPD_DEFAULT_CONFIG_SSID);
}
if (find_wrapper_tlv_by_id(wrapper, TLV_CHANNEL) == NULL) {
add_wrapper_tlv(wrapper, TLV_CHANNEL, strlen(HOSTAPD_DEFAULT_CONFIG_CHANNEL), HOSTAPD_DEFAULT_CONFIG_CHANNEL);
}
if (find_wrapper_tlv_by_id(wrapper, TLV_HW_MODE) == NULL) {
add_wrapper_tlv(wrapper, TLV_HW_MODE, strlen(HOSTAPD_DEFAULT_CONFIG_HW_MODE), HOSTAPD_DEFAULT_CONFIG_HW_MODE);
}
if (find_wrapper_tlv_by_id(wrapper, TLV_WPA_PASSPHRASE) == NULL) {
add_wrapper_tlv(wrapper, TLV_WPA_PASSPHRASE, strlen(HOSTAPD_DEFAULT_CONFIG_WPA_PASSPHRASE), HOSTAPD_DEFAULT_CONFIG_WPA_PASSPHRASE);
}
if (find_wrapper_tlv_by_id(wrapper, TLV_IEEE80211_N) == NULL) {
add_wrapper_tlv(wrapper, TLV_IEEE80211_N, strlen(HOSTAPD_DEFAULT_CONFIG_IEEE80211N), HOSTAPD_DEFAULT_CONFIG_IEEE80211N);
}
if (find_wrapper_tlv_by_id(wrapper, TLV_WPA) == NULL) {
add_wrapper_tlv(wrapper, TLV_WPA, strlen(HOSTAPD_DEFAULT_CONFIG_WPA), HOSTAPD_DEFAULT_CONFIG_WPA);
}
if (find_wrapper_tlv_by_id(wrapper, TLV_WPA_KEY_MGMT) == NULL) {
add_wrapper_tlv(wrapper, TLV_WPA_KEY_MGMT, strlen(HOSTAPD_DEFAULT_CONFIG_WPA_KEY_MGMT), HOSTAPD_DEFAULT_CONFIG_WPA_KEY_MGMT);
}
if (find_wrapper_tlv_by_id(wrapper, TLV_RSN_PAIRWISE) == NULL) {
add_wrapper_tlv(wrapper, TLV_RSN_PAIRWISE, strlen(HOSTAPD_DEFAULT_CONFIG_RSN_PAIRWISE), HOSTAPD_DEFAULT_CONFIG_RSN_PAIRWISE);
}
}
#endif /* _RESERVED_ */
static int generate_hostapd_config(char *output, int output_size, struct packet_wrapper *wrapper, struct interface_info* wlanp) {
int has_sae = 0, has_wpa = 0, has_pmf = 0, has_owe = 0, has_transition = 0, has_sae_groups = 0;
int channel = 0, chwidth = 1, enable_ax = 0, chwidthset = 0, enable_muedca = 0, vht_chwidthset = 0;
int i, enable_ac = 0, enable_11h = 0, enable_hs20 = 0;
int enable_wps = 0, use_mbss = 0;
char buffer[S_BUFFER_LEN], cfg_item[2*BUFFER_LEN];
char band[64], value[16];
char country[16];
struct tlv_to_config_name* cfg = NULL;
struct tlv_hdr *tlv = NULL;
int is_6g_only = 0, unsol_pr_resp_interval = 0;
struct tlv_to_profile *profile = NULL;
int semicolon_list_size = sizeof(semicolon_list) / sizeof(struct tlv_to_config_name);
int hs20_icons_attached = 0;
int is_multiple_bssid = 0;
#if HOSTAPD_SUPPORT_MBSSID
if ((wlanp->mbssid_enable && !wlanp->transmitter) || (band_first_wlan[wlanp->band])) {
sprintf(output, "bss=%s\nctrl_interface=%s\n", wlanp->ifname, HAPD_CTRL_PATH_DEFAULT);
is_multiple_bssid = 1;
}
else
sprintf(output, "ctrl_interface=%s\nctrl_interface_group=0\ninterface=%s\n", HAPD_CTRL_PATH_DEFAULT, wlanp->ifname);
#else
sprintf(output, "ctrl_interface=%s\nctrl_interface_group=0\ninterface=%s\n", HAPD_CTRL_PATH_DEFAULT, wlanp->ifname);
#endif
#ifdef _RESERVED_
/* The function is reserved for the defeault hostapd config */
append_hostapd_default_config(wrapper);
#endif
memset(country, 0, sizeof(country));
/* QCA WTS image doesn't apply 11ax, mu_edca, country, 11d, 11h in hostapd */
for (i = 0; i < wrapper->tlv_num; i++) {
tlv = wrapper->tlv[i];
memset(buffer, 0, sizeof(buffer));
memset(cfg_item, 0, sizeof(cfg_item));
if (tlv->id == TLV_CHANNEL) {
memset(value, 0, sizeof(value));
memcpy(value, tlv->value, tlv->len);
channel = atoi(value);
if (is_multiple_bssid) {
/* channel will be configured on the first wlan */
continue;
}
}
if (tlv->id == TLV_HE_6G_ONLY) {
is_6g_only = 1;
continue;
}
if (tlv->id == TLV_BSS_IDENTIFIER) {
use_mbss = 1;
if (is_band_enabled(BAND_6GHZ) && !wlanp->mbssid_enable) {
strcat(output, "rnr=1\n");
}
continue;
}
/* This is used when hostapd will use multiple lines to
* configure multiple items in the same configuration parameter
* (use semicolon to separate multiple configurations) */
cfg = find_generic_tlv_config(tlv->id, semicolon_list, semicolon_list_size);
if (cfg) {
char *token = NULL, *delimit = ";";
memcpy(buffer, tlv->value, tlv->len);
token = strtok(buffer, delimit);
while(token != NULL) {
sprintf(cfg_item, "%s=%s\n", cfg->config_name, token);
strcat(output, cfg_item);
token = strtok(NULL, delimit);
}
continue;
}
if (tlv->id == TLV_HESSID && strstr(tlv->value, "self")) {
char mac_addr[64];
memset(mac_addr, 0, sizeof(mac_addr));
get_mac_address(mac_addr, sizeof(mac_addr), get_wireless_interface());
sprintf(cfg_item, "hessid=%s\n", mac_addr);
strcat(output, cfg_item);
continue;
}
/* profile config */
profile = find_tlv_hs2_profile(tlv->id);
if (profile) {
char *hs2_config = 0;
memcpy(buffer, tlv->value, tlv->len);
if (((tlv->id == TLV_OSU_PROVIDERS_LIST) || (tlv->id == TLV_OPERATOR_ICON_METADATA)) && (!hs20_icons_attached)) {
attach_hs20_icons(output);
hs20_icons_attached = 1;
}
if (atoi(buffer) > profile->size) {
indigo_logger(LOG_LEVEL_ERROR, "profile index out of bound!: %d, array_size:%d", atoi(buffer), profile->size);
} else {
hs2_config = (char *)profile->profile[atoi(buffer)];
}
sprintf(cfg_item, "%s", hs2_config);
strcat(output, cfg_item);
continue;
}
/* wps settings */
if (tlv->id == TLV_WPS_ENABLE) {
int j;
/* To get AP wps vendor info */
wps_setting *s = get_vendor_wps_settings(WPS_AP);
if (!s) {
indigo_logger(LOG_LEVEL_WARNING, "Failed to get APUT WPS settings");
continue;
}
enable_wps = 1;
memcpy(buffer, tlv->value, tlv->len);
if (atoi(buffer) == WPS_ENABLE_OOB) {
/* WPS OOB: Out-of-Box */
for (j = 0; j < AP_SETTING_NUM; j++) {
memset(cfg_item, 0, sizeof(cfg_item));
sprintf(cfg_item, "%s=%s\n", s[j].wkey, s[j].value);
strcat(output, cfg_item);
}
indigo_logger(LOG_LEVEL_INFO, "APUT Configure WPS: OOB.");
} else if (atoi(buffer) == WPS_ENABLE_NORMAL){
/* WPS Normal: Configure manually. */
for (j = 0; j < AP_SETTING_NUM; j++) {
memset(cfg_item, 0, sizeof(cfg_item));
/* set wps state */
if (atoi(s[j].attr) == atoi(WPS_OOB_ONLY)) {
if (!(memcmp(s[j].wkey, WPS_OOB_STATE, strlen(WPS_OOB_STATE)))) {
/* set wps state to Configured compulsorily */
sprintf(cfg_item, "%s=%s\n", s[j].wkey, WPS_OOB_CONFIGURED);
}
}
/* set wps common settings */
if (atoi(s[j].attr) == atoi(WPS_COMMON)) {
sprintf(cfg_item, "%s=%s\n", s[j].wkey, s[j].value);
}
strcat(output, cfg_item);
}
indigo_logger(LOG_LEVEL_INFO, "APUT Configure WPS: Manually Configured.");
} else {
indigo_logger(LOG_LEVEL_ERROR, "Unknown WPS TLV value: %d (TLV ID 0x%04x)", atoi(buffer), tlv->id);
}
continue;
}
/* wps er support. upnp */
if (tlv->id == TLV_WPS_ER_SUPPORT) {
memset(cfg_item, 0, sizeof(cfg_item));
sprintf(cfg_item, "upnp_iface=%s\n", wlanp->ifname);
strcat(output, cfg_item);
memset(cfg_item, 0, sizeof(cfg_item));
sprintf(cfg_item, "friendly_name=WPS Access Point\n");
strcat(output, cfg_item);
memset(cfg_item, 0, sizeof(cfg_item));
sprintf(cfg_item, "model_description=Wireless Access Point\n");
strcat(output, cfg_item);
continue;
}
cfg = find_tlv_config(tlv->id);
if (!cfg) {
indigo_logger(LOG_LEVEL_ERROR, "Unknown AP configuration name: TLV ID 0x%04x", tlv->id);
continue;
}
if (tlv->id == TLV_WPA_KEY_MGMT && strstr(tlv->value, "SAE") && strstr(tlv->value, "WPA-PSK")) {
has_transition = 1;
}
if (tlv->id == TLV_WPA_KEY_MGMT && strstr(tlv->value, "OWE")) {
has_owe = 1;
}
if (tlv->id == TLV_WPA_KEY_MGMT && strstr(tlv->value, "SAE")) {
has_sae = 1;
}
if (tlv->id == TLV_WPA && strstr(tlv->value, "2")) {
has_wpa = 1;
}
if (tlv->id == TLV_IEEE80211_W) {
has_pmf = 1;
}
if (tlv->id == TLV_HW_MODE) {
memset(band, 0, sizeof(band));
memcpy(band, tlv->value, tlv->len);
}
if (tlv->id == TLV_HE_OPER_CHWIDTH) {
memset(value, 0, sizeof(value));
memcpy(value, tlv->value, tlv->len);
chwidth = atoi(value);
chwidthset = 1;
#ifdef _WTS_OPENWRT_
continue;
#endif
}
if (tlv->id == TLV_VHT_OPER_CHWIDTH) {
memset(value, 0, sizeof(value));
memcpy(value, tlv->value, tlv->len);
chwidth = atoi(value);
vht_chwidthset = 1;
}
if (tlv->id == TLV_IEEE80211_AC && strstr(tlv->value, "1")) {
enable_ac = 1;
}
if (tlv->id == TLV_IEEE80211_AX && strstr(tlv->value, "1")) {
enable_ax = 1;
#ifdef _WTS_OPENWRT_
continue;
#endif
}
if (tlv->id == TLV_HE_MU_EDCA) {
#ifdef _WTS_OPENWRT_
continue;
#endif
enable_muedca = 1;
}
if (tlv->id == TLV_SAE_GROUPS) {
has_sae_groups = 1;
}
if (tlv->id == TLV_COUNTRY_CODE) {
memcpy(country, tlv->value, tlv->len);
#ifdef _WTS_OPENWRT_
continue;
#endif
}
if (tlv->id == TLV_IEEE80211_H) {
#ifdef _WTS_OPENWRT_
continue;
#endif
enable_11h = 1;
}
#ifdef _WTS_OPENWRT_
if (tlv->id == TLV_IEEE80211_D || tlv->id == TLV_HE_OPER_CENTR_FREQ)
continue;
#endif
if (tlv->id == TLV_HE_UNSOL_PR_RESP_CADENCE) {
memset(value, 0, sizeof(value));
memcpy(value, tlv->value, tlv->len);
unsol_pr_resp_interval = atoi(value);
}
if (tlv->id == TLV_HS20 && strstr(tlv->value, "1")) {
enable_hs20 = 1;
}
if (tlv->id == TLV_OWE_TRANSITION_BSS_IDENTIFIER) {
struct bss_identifier_info bss_info;
struct interface_info *wlan;
int bss_identifier;
char bss_identifier_str[8];
memset(&bss_info, 0, sizeof(bss_info));
memset(bss_identifier_str, 0, sizeof(bss_identifier_str));
memcpy(bss_identifier_str, tlv->value, tlv->len);
bss_identifier = atoi(bss_identifier_str);
parse_bss_identifier(bss_identifier, &bss_info);
wlan = get_wireless_interface_info(bss_info.band, bss_info.identifier);
if (NULL == wlan) {
wlan = assign_wireless_interface_info(&bss_info);
}
indigo_logger(LOG_LEVEL_DEBUG, "TLV_OWE_TRANSITION_BSS_IDENTIFIER: TLV_BSS_IDENTIFIER 0x%x identifier %d mapping ifname %s\n",
bss_identifier,
bss_info.identifier,
wlan ? wlan->ifname : "n/a"
);
if (wlan) {
memcpy(buffer, wlan->ifname, strlen(wlan->ifname));
sprintf(cfg_item, "%s=%s\n", cfg->config_name, buffer);
strcat(output, cfg_item);
if (has_owe) {
memset(cfg_item, 0, sizeof(cfg_item));
sprintf(cfg_item, "ignore_broadcast_ssid=1\n");
strcat(output, cfg_item);
}
}
} else {
memcpy(buffer, tlv->value, tlv->len);
sprintf(cfg_item, "%s=%s\n", cfg->config_name, buffer);
strcat(output, cfg_item);
}
}
/* add rf band according to TLV_BSS_IDENTIFIER/TLV_HW_MODE/TLV_WPS_ENABLE */
if (enable_wps) {
if (use_mbss) {
/* The wps test for mbss should always be dual concurrent. */
strcat(output, "wps_rf_bands=ag\n");
} else {
if (!strncmp(band, "a", 1)) {
strcat(output, "wps_rf_bands=a\n");
} else if (!strncmp(band, "g", 1)) {
strcat(output, "wps_rf_bands=g\n");
}
}
}
if (has_pmf == 0) {
if (has_transition) {
strcat(output, "ieee80211w=1\n");
} else if (has_sae && has_wpa) {
strcat(output, "ieee80211w=2\n");
} else if (has_owe) {
strcat(output, "ieee80211w=2\n");
} else if (has_wpa) {
strcat(output, "ieee80211w=1\n");
}
}
if (has_sae == 1) {
strcat(output, "sae_require_mfp=1\n");
}
#if HOSTAPD_SUPPORT_MBSSID
if (wlanp->mbssid_enable && wlanp->transmitter) {
strcat(output, "multiple_bssid=1\n");
}
#endif
// Note: if any new DUT configuration is added for sae_groups,
// then the following unconditional sae_groups addition should be
// changed to become conditional on there being no other sae_groups
// configuration
// e.g.:
// if RequestTLV.SAE_GROUPS not in tlv_values:
// field_name = tlv_hostapd_config_mapper.get(RequestTLV.SAE_GROUPS)
// hostapd_config += "\n" + field_name + "=15 16 17 18 19 20 21"
// Append the default SAE groups for SAE and no SAE groups TLV
if (has_sae && has_sae_groups == 0) {
strcat(output, "sae_groups=15 16 17 18 19 20 21\n");
}
// Channel width configuration
// Default: 20MHz in 2.4G(No configuration required) 80MHz(40MHz for 11N only) in 5G
if (enable_ac == 0 && enable_ax == 0)
chwidth = 0;
/* Add country IE if there is no country config */
if (strlen(country) == 0) {
strcat(output, "ieee80211d=1\n");
strcat(output, "country_code=US\n");
}
if (is_6g_only) {
if (chwidthset == 0) {
sprintf(buffer, "he_oper_chwidth=%d\n", chwidth);
strcat(output, buffer);
}
if (chwidth == 1)
strcat(output, "op_class=133\n");
else if (chwidth == 2)
strcat(output, "op_class=134\n");
sprintf(buffer, "he_oper_centr_freq_seg0_idx=%d\n", get_6g_center_freq_index(channel, chwidth));
strcat(output, buffer);
if (unsol_pr_resp_interval) {
sprintf(buffer, "unsol_bcast_probe_resp_interval=%d\n", unsol_pr_resp_interval);
strcat(output, buffer);
} else {
strcat(output, "fils_discovery_max_interval=20\n");
}
/* Enable bss_color IE */
strcat(output, "he_bss_color=19\n");
} else if (strstr(band, "a")) {
if (is_ht40plus_chan(channel))
strcat(output, "ht_capab=[HT40+]\n");
else if (is_ht40minus_chan(channel))
strcat(output, "ht_capab=[HT40-]\n");
else // Ch 165 and avoid hostapd configuration error
chwidth = 0;
if (chwidth > 0) {
int center_freq = get_center_freq_index(channel, chwidth);
#ifndef _WTS_OPENWRT_
if (chwidth == 2) {
/* 160M: Need to enable 11h for DFS */
strcat(output, "ieee80211h=1\n");
}
#endif
if (enable_ac) {
if (vht_chwidthset == 0) {
sprintf(buffer, "vht_oper_chwidth=%d\n", chwidth);
strcat(output, buffer);
}
sprintf(buffer, "vht_oper_centr_freq_seg0_idx=%d\n", center_freq);
strcat(output, buffer);
#ifndef _WTS_OPENWRT_
if (chwidth == 2) {
strcat(output, "vht_capab=[VHT160]\n");
}
#endif
}
if (enable_ax) {
#ifndef _WTS_OPENWRT_
if (chwidthset == 0) {
sprintf(buffer, "he_oper_chwidth=%d\n", chwidth);
strcat(output, buffer);
}
sprintf(buffer, "he_oper_centr_freq_seg0_idx=%d\n", center_freq);
strcat(output, buffer);
#endif
}
}
}
if (enable_muedca) {
strcat(output, "he_mu_edca_qos_info_queue_request=1\n");
strcat(output, "he_mu_edca_ac_be_aifsn=0\n");
strcat(output, "he_mu_edca_ac_be_ecwmin=15\n");
strcat(output, "he_mu_edca_ac_be_ecwmax=15\n");
strcat(output, "he_mu_edca_ac_be_timer=255\n");
strcat(output, "he_mu_edca_ac_bk_aifsn=0\n");
strcat(output, "he_mu_edca_ac_bk_aci=1\n");
strcat(output, "he_mu_edca_ac_bk_ecwmin=15\n");
strcat(output, "he_mu_edca_ac_bk_ecwmax=15\n");
strcat(output, "he_mu_edca_ac_bk_timer=255\n");
strcat(output, "he_mu_edca_ac_vi_ecwmin=15\n");
strcat(output, "he_mu_edca_ac_vi_ecwmax=15\n");
strcat(output, "he_mu_edca_ac_vi_aifsn=0\n");
strcat(output, "he_mu_edca_ac_vi_aci=2\n");
strcat(output, "he_mu_edca_ac_vi_timer=255\n");
strcat(output, "he_mu_edca_ac_vo_aifsn=0\n");
strcat(output, "he_mu_edca_ac_vo_aci=3\n");
strcat(output, "he_mu_edca_ac_vo_ecwmin=15\n");
strcat(output, "he_mu_edca_ac_vo_ecwmax=15\n");
strcat(output, "he_mu_edca_ac_vo_timer=255\n");
}
#if defined(_OPENWRT_) && !defined(_WTS_OPENWRT_)
/* Make sure AP include power constranit element even in non DFS channel */
if (enable_11h) {
strcat(output, "spectrum_mgmt_required=1\n");
strcat(output, "local_pwr_constraint=3\n");
}
#endif
if (enable_hs20) {
strcat(output, "hs20_release=3\n");
strcat(output, "manage_p2p=1\n");
strcat(output, "allow_cross_connection=0\n");
strcat(output, "bss_load_update_period=100\n");
strcat(output, "hs20_deauth_req_timeout=3\n");
}
/* vendor specific config, not via hostapd */
configure_ap_radio_params(band, country, channel, chwidth);
return strlen(output);
}
// RESP: {<ResponseTLV.STATUS: 40961>: '0', <ResponseTLV.MESSAGE: 40960>: 'DUT configured as AP : Configuration file created'}
static int configure_ap_handler(struct packet_wrapper *req, struct packet_wrapper *resp) {
int len = 0;
char buffer[L_BUFFER_LEN], ifname[S_BUFFER_LEN];
struct tlv_hdr *tlv;
char *message = "DUT configured as AP : Configuration file created";
int bss_identifier = 0, band;
struct interface_info* wlan = NULL;
char bss_identifier_str[16], hw_mode_str[8];
struct bss_identifier_info bss_info;
memset(buffer, 0, sizeof(buffer));
tlv = find_wrapper_tlv_by_id(req, TLV_BSS_IDENTIFIER);
memset(ifname, 0, sizeof(ifname));
memset(&bss_info, 0, sizeof(bss_info));
if (tlv) {
/* Multiple wlans configure must carry TLV_BSS_IDENTIFIER */
memset(bss_identifier_str, 0, sizeof(bss_identifier_str));
memcpy(bss_identifier_str, tlv->value, tlv->len);
bss_identifier = atoi(bss_identifier_str);
parse_bss_identifier(bss_identifier, &bss_info);
wlan = get_wireless_interface_info(bss_info.band, bss_info.identifier);
if (NULL == wlan) {
wlan = assign_wireless_interface_info(&bss_info);
}
if (wlan && bss_info.mbssid_enable) {
configure_ap_enable_mbssid();
if (bss_info.transmitter) {
band_transmitter[bss_info.band] = wlan;
}
}
indigo_logger(LOG_LEVEL_DEBUG, "TLV_BSS_IDENTIFIER 0x%x band %d multiple_bssid %d transmitter %d identifier %d\n",
bss_identifier,
bss_info.band,
bss_info.mbssid_enable,
bss_info.transmitter,
bss_info.identifier
);
} else {
/* Single wlan case */
tlv = find_wrapper_tlv_by_id(req, TLV_HW_MODE);
if (tlv)
{
memset(hw_mode_str, 0, sizeof(hw_mode_str));
memcpy(hw_mode_str, tlv->value, tlv->len);
if (find_wrapper_tlv_by_id(req, TLV_HE_6G_ONLY)) {
band = BAND_6GHZ;
} else if (!strncmp(hw_mode_str, "a", 1)) {
band = BAND_5GHZ;
} else {
band = BAND_24GHZ;
}
/* Single wlan use ID 1 */
bss_info.band = band;
bss_info.identifier = 1;
wlan = assign_wireless_interface_info(&bss_info);
}
}
if (wlan) {
indigo_logger(LOG_LEVEL_DEBUG, "ifname %s hostapd conf file %s\n",
wlan ? wlan->ifname : "n/a",
wlan ? wlan->hapd_conf_file: "n/a"
);
len = generate_hostapd_config(buffer, sizeof(buffer), req, wlan);
if (len)
{
#if HOSTAPD_SUPPORT_MBSSID
if (bss_info.mbssid_enable && !bss_info.transmitter) {
if (band_transmitter[bss_info.band]) {
indigo_logger(LOG_LEVEL_DEBUG, "Append bss conf to %s", band_transmitter[bss_info.band]->hapd_conf_file);
append_file(band_transmitter[bss_info.band]->hapd_conf_file, buffer, len);
}
memset(wlan->hapd_conf_file, 0, sizeof(wlan->hapd_conf_file));
}
else if (band_first_wlan[bss_info.band]) {
indigo_logger(LOG_LEVEL_DEBUG, "Append bss conf to %s", band_first_wlan[bss_info.band]->hapd_conf_file);
append_file(band_first_wlan[bss_info.band]->hapd_conf_file, buffer, len);
memset(wlan->hapd_conf_file, 0, sizeof(wlan->hapd_conf_file));
} else
#endif
write_file(wlan->hapd_conf_file, buffer, len);
}
if (!band_first_wlan[bss_info.band]) {
/* For the first configured ap */
band_first_wlan[bss_info.band] = wlan;
}
}
show_wireless_interface_info();
fill_wrapper_message_hdr(resp, API_CMD_RESPONSE, req->hdr.seq);
fill_wrapper_tlv_byte(resp, TLV_STATUS, len > 0 ? TLV_VALUE_STATUS_OK : TLV_VALUE_STATUS_NOT_OK);
fill_wrapper_tlv_bytes(resp, TLV_MESSAGE, strlen(message), message);
return 0;
}
#ifdef HOSTAPD_SUPPORT_MBSSID_WAR
extern int use_openwrt_wpad;
#endif
// RESP: {<ResponseTLV.STATUS: 40961>: '0', <ResponseTLV.MESSAGE: 40960>: 'AP is up : Hostapd service is active'}
static int start_ap_handler(struct packet_wrapper *req, struct packet_wrapper *resp) {
char *message = TLV_VALUE_HOSTAPD_START_OK;
char buffer[S_BUFFER_LEN];
int len;
int status = TLV_VALUE_STATUS_OK;
int swap_hostapd = 0;
#ifdef _WTS_OPENWRT_
openwrt_apply_radio_config();
// DFS wait again if set wlan params after hostapd starts
iterate_all_wlan_interfaces(start_ap_set_wlan_params);
#endif
memset(buffer, 0, sizeof(buffer));
sprintf(buffer, "%s -B -t -P /var/run/hostapd.pid -g %s %s -f /var/log/hostapd.log %s",
get_hapd_full_exec_path(),
get_hapd_global_ctrl_path(),
get_hostapd_debug_arguments(),
get_all_hapd_conf_files(&swap_hostapd));
len = system(buffer);
sleep(1);
/* Bring up VAPs with MBSSID disable using WFA hostapd */
if (swap_hostapd) {
#ifdef HOSTAPD_SUPPORT_MBSSID_WAR
indigo_logger(LOG_LEVEL_INFO, "Use WFA hostapd for MBSSID disable VAPs with RNR");
system("cp /overlay/hostapd /usr/sbin/hostapd");
use_openwrt_wpad = 0;
memset(buffer, 0, sizeof(buffer));
sprintf(buffer, "%s -B -t -P /var/run/hostapd_1.pid %s -f /var/log/hostapd_1.log %s",
get_hapd_full_exec_path(),
get_hostapd_debug_arguments(),
get_all_hapd_conf_files(&swap_hostapd));
len = system(buffer);
sleep(1);
#endif
}
#ifndef _WTS_OPENWRT_
iterate_all_wlan_interfaces(start_ap_set_wlan_params);
#endif
bridge_init(get_wlans_bridge());
fill_wrapper_message_hdr(resp, API_CMD_RESPONSE, req->hdr.seq);
fill_wrapper_tlv_byte(resp, TLV_STATUS, len == 0 ? TLV_VALUE_STATUS_OK : TLV_VALUE_STATUS_NOT_OK);
fill_wrapper_tlv_bytes(resp, TLV_MESSAGE, strlen(message), message);
return 0;
}
// RESP: {<ResponseTLV.STATUS: 40961>: '0', <ResponseTLV.MESSAGE: 40960>: 'Configure and start wsc ap successfully. (Configure and start)'}
static int configure_ap_wsc_handler(struct packet_wrapper *req, struct packet_wrapper *resp) {
int len_1 = -1, len_2 = 0, len_3 = -1;
char buffer[L_BUFFER_LEN], ifname[S_BUFFER_LEN];
struct tlv_hdr *tlv;
char *message = NULL;
int bss_identifier = 0, band;
struct interface_info* wlan = NULL;
char bss_identifier_str[16], hw_mode_str[8];
struct bss_identifier_info bss_info;
char *parameter[] = {"pidof", get_hapd_exec_file(), NULL};
int swap_hostapd = 0;
/* Stop hostapd [Begin] */
memset(buffer, 0, sizeof(buffer));
sprintf(buffer, "killall %s 1>/dev/null 2>/dev/null", get_hapd_exec_file());
system(buffer);
sleep(2);
#ifdef _OPENWRT_
#else
len_1 = system("rfkill unblock wlan");
if (len_1) {
indigo_logger(LOG_LEVEL_DEBUG, "Failed to run rfkill unblock wlan");
}
sleep(1);
#endif
memset(buffer, 0, sizeof(buffer));
len_1 = pipe_command(buffer, sizeof(buffer), "/bin/pidof", parameter);
if (len_1) {
message = TLV_VALUE_HOSTAPD_STOP_NOT_OK;
goto done;
}
/* Stop hostapd [End] */
/* Generate hostapd configuration file [Begin] */
memset(buffer, 0, sizeof(buffer));
tlv = find_wrapper_tlv_by_id(req, TLV_BSS_IDENTIFIER);
memset(ifname, 0, sizeof(ifname));
memset(&bss_info, 0, sizeof(bss_info));
if (tlv) {
/* Multiple wlans configure must carry TLV_BSS_IDENTIFIER */
memset(bss_identifier_str, 0, sizeof(bss_identifier_str));
memcpy(bss_identifier_str, tlv->value, tlv->len);
bss_identifier = atoi(bss_identifier_str);
parse_bss_identifier(bss_identifier, &bss_info);
wlan = get_wireless_interface_info(bss_info.band, bss_info.identifier);
if (NULL == wlan) {
wlan = assign_wireless_interface_info(&bss_info);
}
if (wlan && bss_info.mbssid_enable) {
configure_ap_enable_mbssid();
if (bss_info.transmitter) {
band_transmitter[bss_info.band] = wlan;
}
}
printf("TLV_BSS_IDENTIFIER 0x%x band %d multiple_bssid %d transmitter %d identifier %d\n",
bss_identifier,
bss_info.band,
bss_info.mbssid_enable,
bss_info.transmitter,
bss_info.identifier
);
} else {
/* Single wlan case */
/* reset interfaces info */
clear_interfaces_resource();
tlv = find_wrapper_tlv_by_id(req, TLV_HW_MODE);
if (tlv)
{
memset(hw_mode_str, 0, sizeof(hw_mode_str));
memcpy(hw_mode_str, tlv->value, tlv->len);
if (find_wrapper_tlv_by_id(req, TLV_HE_6G_ONLY)) {
band = BAND_6GHZ;
} else if (!strncmp(hw_mode_str, "a", 1)) {