1 /* 2 * Sigma Control API DUT (station/AP) 3 * Copyright (c) 2010-2011, Atheros Communications, Inc. 4 * Copyright (c) 2011-2017, Qualcomm Atheros, Inc. 5 * Copyright (c) 2018-2019, The Linux Foundation 6 * All Rights Reserved. 7 * Licensed under the Clear BSD license. See README for more details. 8 */ 9 10 #include "sigma_dut.h" 11 #include <sys/stat.h> 12 #include <sys/wait.h> 13 #include <sys/utsname.h> 14 #include <sys/ioctl.h> 15 #ifdef __linux__ 16 #include <limits.h> 17 #include <dirent.h> 18 #include <string.h> 19 #include <sys/types.h> 20 #include <unistd.h> 21 #endif /* __linux__ */ 22 #ifdef __QNXNTO__ 23 #include <ifaddrs.h> 24 #include <net/if_dl.h> 25 #endif /* __QNXNTO__ */ 26 #include "wpa_ctrl.h" 27 #include "wpa_helpers.h" 28 #ifdef ANDROID 29 #include <hardware_legacy/wifi.h> 30 #include <grp.h> 31 #include <pwd.h> 32 #endif /* ANDROID */ 33 34 /* Temporary files for ap_send_addba_req */ 35 #define VI_QOS_TMP_FILE "/tmp/vi-qos.tmp" 36 #define VI_QOS_FILE "/tmp/vi-qos.txt" 37 #define VI_QOS_REFFILE "/etc/vi-qos.txt" 38 39 /* Configuration file name on Android */ 40 #ifndef ANDROID_CONFIG_FILE 41 #define ANDROID_CONFIG_FILE "/data/misc/wifi/hostapd.conf" 42 #endif /* ANDROID_CONFIG_FILE */ 43 /* Maximum length of the line in the configuration file */ 44 #define MAX_CONF_LINE_LEN (156) 45 46 #ifndef SIGMA_DUT_HOSTAPD_PID_FILE 47 #define SIGMA_DUT_HOSTAPD_PID_FILE "/tmp/sigma_dut-ap-hostapd.pid" 48 #endif /* SIGMA_DUT_HOSTAPD_PID_FILE */ 49 50 /* The following is taken from Hotspot 2.0 testplan Appendix B.1 */ 51 #define ANQP_VENUE_NAME_1 "02019c0002083d656e6757692d466920416c6c69616e63650a3239383920436f7070657220526f61640a53616e746120436c6172612c2043412039353035312c205553415b63686957692d4669e88194e79b9fe5ae9ee9aa8ce5aea40ae4ba8ce4b99de585abe4b99de5b9b4e5ba93e69f8fe8b7af0ae59ca3e5858be68b89e68b892c20e58aa0e588a9e7a68fe5b0bce4ba9a39353035312c20e7be8ee59bbd" 52 #define ANQP_VENUE_NAME_1_CHI "P\"\x63\x68\x69\x3a\x57\x69\x2d\x46\x69\xe8\x81\x94\xe7\x9b\x9f\xe5\xae\x9e\xe9\xaa\x8c\xe5\xae\xa4\\n\xe4\xba\x8c\xe4\xb9\x9d\xe5\x85\xab\xe4\xb9\x9d\xe5\xb9\xb4\xe5\xba\x93\xe6\x9f\x8f\xe8\xb7\xaf\\n\xe5\x9c\xa3\xe5\x85\x8b\xe6\x8b\x89\xe6\x8b\x89\x2c\x20\xe5\x8a\xa0\xe5\x88\xa9\xe7\xa6\x8f\xe5\xb0\xbc\xe4\xba\x9a\x39\x35\x30\x35\x31\x2c\x20\xe7\xbe\x8e\xe5\x9b\xbd\"" 53 #define ANQP_IP_ADDR_TYPE_1 "060101000c" 54 #define ANQP_HS20_OPERATOR_FRIENDLY_NAME_1 "dddd2700506f9a11030011656e6757692d466920416c6c69616e63650e63686957692d4669e88194e79b9f" 55 #define ANQP_HS20_WAN_METRICS_1 "dddd1300506f9a11040001c40900008001000000000000" 56 #define ANQP_HS20_CONNECTION_CAPABILITY_1 "dddd3200506f9a1105000100000006140001061600000650000106bb010106bb060006c4130011f4010111c413001194110132000001" 57 #define QOS_MAP_SET_1 "53,2,22,6,8,15,0,7,255,255,16,31,32,39,255,255,40,47,255,255" 58 #define QOS_MAP_SET_2 "8,15,0,7,255,255,16,31,32,39,255,255,40,47,48,63" 59 60 #define ADV_OF_CHARGE_1 \ 61 "bc01000000d200454e475553443c3f786d6c2076657273696f6e3d22312e30222065" \ 62 "6e636f64696e673d225554462d38223f3e3c506c616e20786d6c6e733d22687474703a2f2f77" \ 63 "77772e77692d66692e6f72672f73706563696669636174696f6e732f686f7473706f7432646f" \ 64 "74302f76312e302f616f637069223e3c4465736372697074696f6e3e57692d46692061636365" \ 65 "737320666f72203120686f75722c207768696c6520796f752077616974206174207468652067" \ 66 "6174652c2024302e39393c2f4465736372697074696f6e3e3c2f506c616e3ee3004652414341" \ 67 "443c3f786d6c2076657273696f6e3d22312e302220656e636f64696e673d225554462d38223f" \ 68 "3e3c506c616e20786d6c6e733d22687474703a2f2f7777772e77692d66692e6f72672f737065" \ 69 "63696669636174696f6e732f686f7473706f7432646f74302f76312e302f616f637069223e3c" \ 70 "4465736372697074696f6e3e416363c3a8732057692d46692070656e64616e74203120686575" \ 71 "72652c2070656e64616e742071756520766f757320617474656e64657a20c3a0206c6120706f" \ 72 "7274652c20302c393920243c2f4465736372697074696f6e3e3c2f506c616e3ea101010000c7" \ 73 "00454e475553443c3f786d6c2076657273696f6e3d22312e302220656e636f64696e673d2255" \ 74 "54462d38223f3e3c506c616e20786d6c6e733d22687474703a2f2f7777772e77692d66692e6f" \ 75 "72672f73706563696669636174696f6e732f686f7473706f7432646f74302f76312e302f616f" \ 76 "637069223e3c4465736372697074696f6e3e446f776e6c6f616420766964656f7320666f7220" \ 77 "796f757220666c696768742c2024322e393920666f7220313047423c2f446573637269707469" \ 78 "6f6e3e3c2f506c616e3ed3004652414341443c3f786d6c2076657273696f6e3d22312e302220" \ 79 "656e636f64696e673d225554462d38223f3e3c506c616e20786d6c6e733d22687474703a2f2f" \ 80 "7777772e77692d66692e6f72672f73706563696669636174696f6e732f686f7473706f743264" \ 81 "6f74302f76312e302f616f637069223e3c4465736372697074696f6e3e54c3a96cc3a9636861" \ 82 "7267657a2064657320766964c3a96f7320706f757220766f74726520766f6c2c20322c393920" \ 83 "2420706f757220313020476f3c2f4465736372697074696f6e3e3c2f506c616e3ee40003002b" \ 84 "736572766963652d70726f76696465722e636f6d3b66656465726174696f6e2e6578616d706c" \ 85 "652e636f6db400454e475553443c3f786d6c2076657273696f6e3d22312e302220656e636f64" \ 86 "696e673d225554462d38223f3e3c506c616e20786d6c6e733d22687474703a2f2f7777772e77" \ 87 "692d66692e6f72672f73706563696669636174696f6e732f686f7473706f7432646f74302f76" \ 88 "312e302f616f637069223e3c4465736372697074696f6e3e46726565207769746820796f7572" \ 89 "20737562736372697074696f6e213c2f4465736372697074696f6e3e3c2f506c616e3e" 90 91 #define SAE_PK_KEY_1 \ 92 "MHcCAQEEIDNNDttjdQmLVyr1DOrWiapbMt15LDn4hnMLIXrBLAN+oAoGCCqGSM49AwEHoUQDQgAENAv4e3IlpYkqQjc/9KM4O4Athh6iY25wlT8Gdg+EhR7yoMR03nHri6QaaLogXxTsa9qGyXj1K9G8DEOyHMQCbg==" 93 #define SAE_PK_KEY_2 \ 94 "MHcCAQEEIF4LGkE30VdIeJe1ZVOo3TmkvT9RKRx30+yOx/9nhQY9oAoGCCqGSM49AwEHoUQDQgAE3PNzZH4m41vT5q6W7p5Q6B9owz5MHLwCUnpK84YRTVDLKKZXOPYxSHRh/O5Kz0OnVeOq1QfjEZRhNH79XhHCQQ==" 95 #define SAE_PK_KEY_P256 \ 96 "MHcCAQEEIAJIGlfnteonDb7rQyP/SGQjwzrZAnfrXIm4280VWajYoAoGCCqGSM49AwEHoUQDQgAEeRkstKQV+FSAMqBayqFknn2nAQsdsh/MhdX6tiHOTAFin/sUMFRMyspPtIu7YvlKdsexhI0jPVhaYZn1jKWhZg==" 97 #define SAE_PK_KEY_P384 \ 98 "MIGkAgEBBDB7iMoR2se0sWriXYCEsiLd8WFEblxWlCqb5kD7JgZfQjjylGwqOgIE7JShOOjE0Z2gBwYFK4EEACKhZANiAATntlmb7rlUopsaA/w5Uhut9jLlcY2sJdT6IzCdQ8uzuxk9Fgh+dwS25pd+lWC91rQ7kyjfZRpoePhwQasnjGRAl6rH2VWI/XtI5Q9iFXbhEaWEdKzWjetd6B5OPWy/BQg=" 99 #define SAE_PK_KEY_P521 \ 100 "MIHcAgEBBEIBuNKSnOQY5ZVdBgWiXcL1Gr/W+VCw69nOte1gT4sqdVeV3grCl5HJxogVG2LFdtnEDLJrs0AtFoFN9nWnIuMu+ZWgBwYFK4EEACOhgYkDgYYABADuDQkFO2102xXwNnoGpBU+13kNuxZ/gwy8+G0UG75h6iiTqNWRaQIpSWgTmPNER7Ubb7etyXaoOTnsq4v4f9m8wgDt2LMZptHvUkHCq522rRK43ITmCayelbHWY1FhhAE1ETXRItSV8nLymjliEtjdfP45dsr25ySlkSaVCBNUFrAtfw==" 101 102 /* 103 * MTU for Ethernet need to take into account 8-byte SNAP header 104 * to be added when encapsulating Ethernet frame into 802.11. 105 */ 106 #ifndef IEEE80211_MAX_DATA_LEN_DMG 107 #define IEEE80211_MAX_DATA_LEN_DMG 7920 108 #endif /* IEEE80211_MAX_DATA_LEN_DMG */ 109 #ifndef IEEE80211_SNAP_LEN_DMG 110 #define IEEE80211_SNAP_LEN_DMG 8 111 #endif /* IEEE80211_SNAP_LEN_DMG */ 112 113 extern char *sigma_wpas_ctrl; 114 extern char *sigma_hapd_ctrl; 115 extern char *ap_inet_addr; 116 extern char *ap_inet_mask; 117 extern char *sigma_radio_ifname[]; 118 119 static int ath_ap_start_hostapd(struct sigma_dut *dut); 120 static void ath_ap_set_params(struct sigma_dut *dut); 121 static int kill_process(struct sigma_dut *dut, char *proc_name, 122 unsigned char is_proc_instance_one, int sig); 123 124 125 static int ap_ft_enabled(struct sigma_dut *dut) 126 { 127 return dut->ap_ft_oa == 1 || 128 dut->ap_ft_ds == VALUE_ENABLED || 129 dut->ap_key_mgmt == AP_WPA2_FT_EAP || 130 dut->ap_key_mgmt == AP_WPA2_FT_PSK || 131 dut->ap_key_mgmt == AP_WPA2_ENT_FT_EAP || 132 (dut->ap_akm_values & 133 ((1 << AKM_FT_EAP) | 134 (1 << AKM_FT_PSK) | 135 (1 << AKM_FT_SAE) | 136 (1 << AKM_FT_SUITE_B) | 137 (1 << AKM_FT_FILS_SHA256) | 138 (1 << AKM_FT_FILS_SHA384))); 139 } 140 141 142 static enum sigma_cmd_result cmd_ap_ca_version(struct sigma_dut *dut, 143 struct sigma_conn *conn, 144 struct sigma_cmd *cmd) 145 { 146 /* const char *name = get_param(cmd, "NAME"); */ 147 send_resp(dut, conn, SIGMA_COMPLETE, "version,1.0"); 148 return 0; 149 } 150 151 152 static void kill_hostapd_process_pid(struct sigma_dut *dut) 153 { 154 FILE *f; 155 int pid, res; 156 char path[100]; 157 int count; 158 159 f = fopen(SIGMA_DUT_HOSTAPD_PID_FILE, "r"); 160 if (!f) 161 return; 162 res = fscanf(f, "%d", &pid); 163 fclose(f); 164 if (res != 1) 165 return; 166 sigma_dut_print(dut, DUT_MSG_INFO, "Killing hostapd pid %d", pid); 167 kill(pid, SIGTERM); 168 snprintf(path, sizeof(path), "/proc/%d", pid); 169 for (count = 0; count < 20 && file_exists(path); count++) 170 usleep(100000); 171 } 172 173 174 int get_hwaddr(const char *ifname, unsigned char *hwaddr) 175 { 176 #ifndef __QNXNTO__ 177 struct ifreq ifr; 178 int s; 179 180 s = socket(AF_INET, SOCK_DGRAM, 0); 181 if (s < 0) 182 return -1; 183 memset(&ifr, 0, sizeof(ifr)); 184 strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name)); 185 if (ioctl(s, SIOCGIFHWADDR, &ifr) < 0) { 186 perror("ioctl"); 187 close(s); 188 return -1; 189 } 190 close(s); 191 memcpy(hwaddr, ifr.ifr_hwaddr.sa_data, 6); 192 #else /* __QNXNTO__ */ 193 struct ifaddrs *ifaddrshead = NULL; 194 int found = 0; 195 struct ifaddrs *temp_ifap = NULL; 196 struct sockaddr_dl *sdl = NULL; 197 198 if (getifaddrs(&ifaddrshead) != 0) { 199 perror("getifaddrs failed"); 200 return -1; 201 } 202 203 for (temp_ifap = ifaddrshead; ifaddrshead && !found; 204 ifaddrshead = ifaddrshead->ifa_next) { 205 if (ifaddrshead->ifa_addr->sa_family == AF_LINK && 206 strcmp(ifaddrshead->ifa_name, ifname) == 0) { 207 found = 1; 208 sdl = (struct sockaddr_dl *) ifaddrshead->ifa_addr; 209 if (sdl) 210 memcpy(hwaddr, LLADDR(sdl), sdl->sdl_alen); 211 } 212 } 213 214 if (temp_ifap) 215 freeifaddrs(temp_ifap); 216 217 if (!found) { 218 perror("Failed to get the interface"); 219 return -1; 220 } 221 #endif /* __QNXNTO__ */ 222 return 0; 223 } 224 225 226 static void ath_ap_set_group_id(struct sigma_dut *dut, const char *ifname, 227 const char *val) 228 { 229 char buf[60]; 230 231 snprintf(buf, sizeof(buf), "wifitool %s beeliner_fw_test 55 %d", 232 ifname, atoi(val)); 233 if (system(buf) != 0) { 234 sigma_dut_print(dut, DUT_MSG_ERROR, 235 "wifitool ap_group_id failed"); 236 } 237 } 238 239 240 void ath_set_cts_width(struct sigma_dut *dut, const char *ifname, 241 const char *val) 242 { 243 char buf[60]; 244 245 /* TODO: Enable support for other values */ 246 if (strcasecmp(val, "40") == 0) { 247 snprintf(buf, sizeof(buf), "wifitool %s beeliner_fw_test 54 1", 248 ifname); 249 if (system(buf) != 0) { 250 sigma_dut_print(dut, DUT_MSG_ERROR, 251 "wifitool cts_width failed"); 252 } 253 snprintf(buf, sizeof(buf), 254 "athdiag --set --address=0x10024 --val=0xd90b8a14"); 255 if (system(buf) != 0) { 256 sigma_dut_print(dut, DUT_MSG_ERROR, 257 "disabling phy restart failed"); 258 } 259 } else { 260 sigma_dut_print(dut, DUT_MSG_ERROR, "Unsupported CTS_WIDTH"); 261 } 262 } 263 264 265 void ath_config_dyn_bw_sig(struct sigma_dut *dut, const char *ifname, 266 const char *val) 267 { 268 char buf[60]; 269 270 if (strcasecmp(val, "enable") == 0) { 271 dut->ap_dyn_bw_sig = VALUE_ENABLED; 272 run_iwpriv(dut, ifname, "cwmenable 1"); 273 274 snprintf(buf, sizeof(buf), "wifitool %s beeliner_fw_test 96 1", 275 ifname); 276 if (system(buf) != 0) { 277 sigma_dut_print(dut, DUT_MSG_ERROR, 278 "disabling RTS from rate control logic failed"); 279 } 280 } else if (strcasecmp(val, "disable") == 0) { 281 dut->ap_dyn_bw_sig = VALUE_DISABLED; 282 run_iwpriv(dut, ifname, "cwmenable 0"); 283 } else { 284 sigma_dut_print(dut, DUT_MSG_ERROR, "Unsupported DYN_BW_SGL"); 285 } 286 } 287 288 289 static void wcn_config_ap_ldpc(struct sigma_dut *dut, const char *ifname) 290 { 291 if (dut->ap_ldpc == VALUE_NOT_SET) 292 return; 293 run_iwpriv(dut, ifname, "ldpc %d", dut->ap_ldpc != VALUE_DISABLED); 294 } 295 296 297 static void mac80211_config_rts_force(struct sigma_dut *dut, const char *ifname, 298 const char *val) 299 { 300 char buf[60]; 301 char fname[128], path[128], *pos; 302 ssize_t res; 303 304 res = snprintf(fname, sizeof(fname), "/sys/class/net/%s/phy80211", 305 ifname); 306 if (res < 0 || res >= sizeof(fname)) 307 return; 308 309 res = readlink(fname, path, sizeof(path)); 310 if (res < 0) 311 return; 312 313 if (res >= (int) sizeof(path)) 314 res = sizeof(path) - 1; 315 path[res] = '\0'; 316 317 pos = strrchr(path, '/'); 318 if (!pos) 319 pos = path; 320 else 321 pos++; 322 323 if (strcasecmp(val, "enable") == 0) { 324 dut->ap_sig_rts = VALUE_ENABLED; 325 res = snprintf(buf, sizeof(buf), "iw %s set rts 64", pos); 326 if (res < 0 || res >= sizeof(buf) || system(buf) != 0) { 327 sigma_dut_print(dut, DUT_MSG_ERROR, 328 "iw set rts 64 failed"); 329 } 330 } else if (strcasecmp(val, "disable") == 0) { 331 dut->ap_sig_rts = VALUE_DISABLED; 332 res = snprintf(buf, sizeof(buf), "iw %s set rts 2347", pos); 333 if (res < 0 || res >= sizeof(buf) || system(buf) != 0) { 334 sigma_dut_print(dut, DUT_MSG_ERROR, 335 "iw rts 2347 failed"); 336 } 337 } else { 338 sigma_dut_print(dut, DUT_MSG_ERROR, "Unsupported RTS_FORCE"); 339 } 340 341 } 342 343 344 static void ath_config_rts_force(struct sigma_dut *dut, const char *ifname, 345 const char *val) 346 { 347 char buf[60]; 348 349 if (strcasecmp(val, "enable") == 0) { 350 dut->ap_sig_rts = VALUE_ENABLED; 351 snprintf(buf, sizeof(buf), "iwconfig %s rts 64", ifname); 352 if (system(buf) != 0) { 353 sigma_dut_print(dut, DUT_MSG_ERROR, 354 "iwconfig rts 64 failed"); 355 } 356 snprintf(buf, sizeof(buf), "wifitool %s beeliner_fw_test 100 1", 357 ifname); 358 if (system(buf) != 0) { 359 sigma_dut_print(dut, DUT_MSG_ERROR, 360 "wifitool beeliner_fw_test 100 1 failed"); 361 } 362 } else if (strcasecmp(val, "disable") == 0) { 363 dut->ap_sig_rts = VALUE_DISABLED; 364 snprintf(buf, sizeof(buf), "iwconfig %s rts 2347", ifname); 365 if (system(buf) != 0) { 366 sigma_dut_print(dut, DUT_MSG_ERROR, 367 "iwconfig rts 2347 failed"); 368 } 369 } else { 370 sigma_dut_print(dut, DUT_MSG_ERROR, "Unsupported RTS_FORCE"); 371 } 372 } 373 374 375 static void ath_radio(struct sigma_dut *dut, const char *val) 376 { 377 if (strcasecmp(val, "on") == 0) { 378 if (dut->ap_interface_5g == 1) { 379 run_system(dut, "uci set wireless.wifi0.disabled=0"); 380 } else if (dut->ap_interface_2g == 1) { 381 run_system(dut, "uci set wireless.wifi1.disabled=0"); 382 } else { 383 run_system(dut, "uci set wireless.wifi0.disabled=0"); 384 run_system(dut, "uci set wireless.wifi1.disabled=0"); 385 } 386 run_system(dut, "uci commit"); 387 run_system(dut, "wifi down"); 388 run_system(dut, "wifi up"); 389 } else if (strcasecmp(val, "off") == 0) { 390 if (dut->ap_interface_5g == 1) { 391 run_system(dut, "uci set wireless.wifi0.disabled=1"); 392 } else if (dut->ap_interface_2g == 1) { 393 run_system(dut, "uci set wireless.wifi1.disabled=1"); 394 } else { 395 run_system(dut, "uci set wireless.wifi0.disabled=1"); 396 run_system(dut, "uci set wireless.wifi1.disabled=1"); 397 } 398 run_system(dut, "uci commit"); 399 run_system(dut, "wifi down"); 400 run_system(dut, "wifi up"); 401 } 402 } 403 404 405 static void deauth_disassoc(struct sigma_dut *dut, const char *ifname, 406 const char *val) 407 { 408 if (strcasecmp(val, "disable") == 0) 409 run_iwpriv(dut, ifname, "stealthdown 1"); 410 } 411 412 413 static void ath_set_txpower(struct sigma_dut *dut, const char *ifname, 414 const char *val) 415 { 416 char buf[60]; 417 418 if (strcasecmp(val, "high") == 0) 419 snprintf(buf, sizeof(buf), "iwconfig %s txpower 29", ifname); 420 else if (strcasecmp(val, "low") == 0) 421 snprintf(buf, sizeof(buf), "iwconfig %s txpower 1", ifname); 422 else 423 sigma_dut_print(dut, DUT_MSG_ERROR, "Unsupported txpower"); 424 425 if (system(buf) != 0) 426 sigma_dut_print(dut, DUT_MSG_ERROR, "setting txpower failed"); 427 } 428 429 430 static enum ap_mode get_mode(const char *str) 431 { 432 if (strcasecmp(str, "11a") == 0) 433 return AP_11a; 434 else if (strcasecmp(str, "11g") == 0) 435 return AP_11g; 436 else if (strcasecmp(str, "11b") == 0) 437 return AP_11b; 438 else if (strcasecmp(str, "11na") == 0) 439 return AP_11na; 440 else if (strcasecmp(str, "11ng") == 0) 441 return AP_11ng; 442 else if (strcasecmp(str, "11ac") == 0 || strcasecmp(str, "ac") == 0) 443 return AP_11ac; 444 else if (strcasecmp(str, "11ad") == 0) 445 return AP_11ad; 446 else if (strcasecmp(str, "11ax") == 0) 447 return AP_11ax; 448 else 449 return AP_inval; 450 } 451 452 453 static int run_hostapd_cli(struct sigma_dut *dut, char *buf) 454 { 455 char command[1000]; 456 const char *bin; 457 enum driver_type drv = get_driver_type(dut); 458 char *sigma_hapd_file = sigma_hapd_ctrl; 459 460 if (file_exists("hostapd_cli")) 461 bin = "./hostapd_cli"; 462 else if (file_exists("../../hostapd/hostapd_cli")) 463 bin = "../../hostapd/hostapd_cli"; 464 else 465 bin = "hostapd_cli"; 466 467 if (drv == DRIVER_OPENWRT && sigma_hapd_ctrl == NULL) { 468 sigma_hapd_file = "/var/run/hostapd-wifi0"; 469 470 if (sigma_radio_ifname[0] && 471 strcmp(sigma_radio_ifname[0], "wifi1") == 0) 472 sigma_hapd_file = "/var/run/hostapd-wifi1"; 473 else if (sigma_radio_ifname[0] && 474 strcmp(sigma_radio_ifname[0], "wifi2") == 0) 475 sigma_hapd_file = "/var/run/hostapd-wifi2"; 476 } 477 478 if (sigma_hapd_file) 479 snprintf(command, sizeof(command), "%s -p %s %s", 480 bin, sigma_hapd_file, buf); 481 else 482 snprintf(command, sizeof(command), "%s %s", bin, buf); 483 return run_system(dut, command); 484 } 485 486 487 static int ath_set_lci_config(struct sigma_dut *dut, const char *val, 488 struct sigma_cmd *cmd) 489 { 490 FILE *f; 491 int i; 492 493 f = fopen("/tmp/lci_cfg.txt", "w"); 494 if (!f) { 495 sigma_dut_print(dut, DUT_MSG_ERROR, 496 "Failed to open /tmp/lci_cfg.txt"); 497 return -1; 498 } 499 500 for (i = 2; i < cmd->count; i++) 501 fprintf(f, "%s = %s \n", cmd->params[i], cmd->values[i]); 502 fprintf(f, "\n"); 503 fclose(f); 504 505 return 0; 506 } 507 508 509 static void set_ap_country_code(struct sigma_dut *dut) 510 { 511 #if defined(ANDROID) || defined(LINUX_EMBEDDED) 512 char buf[256]; 513 514 if (dut->ap_countrycode[0]) { 515 snprintf(buf, sizeof(buf), "DRIVER COUNTRY %s", 516 dut->ap_countrycode); 517 if (wpa_command(get_station_ifname(dut), buf) < 0) 518 sigma_dut_print(dut, DUT_MSG_ERROR, 519 "Failed to set country code"); 520 else 521 sigma_dut_print(dut, DUT_MSG_INFO, 522 "Successfully set country code to %s", 523 dut->ap_countrycode); 524 } 525 #endif 526 } 527 528 529 static void set_vht_mcsmap_nss(struct sigma_dut *dut, int nss, int mcs) 530 { 531 switch (nss) { 532 case 1: 533 switch (mcs) { 534 case 7: 535 dut->ap_vhtmcs_map = 0xfffc; 536 break; 537 case 8: 538 dut->ap_vhtmcs_map = 0xfffd; 539 break; 540 case 9: 541 dut->ap_vhtmcs_map = 0xfffe; 542 break; 543 default: 544 dut->ap_vhtmcs_map = 0xfffe; 545 break; 546 } 547 break; 548 case 2: 549 switch (mcs) { 550 case 7: 551 dut->ap_vhtmcs_map = 0xfff0; 552 break; 553 case 8: 554 dut->ap_vhtmcs_map = 0xfff5; 555 break; 556 case 9: 557 dut->ap_vhtmcs_map = 0xfffa; 558 break; 559 default: 560 dut->ap_vhtmcs_map = 0xfffa; 561 break; 562 } 563 break; 564 case 3: 565 switch (mcs) { 566 case 7: 567 dut->ap_vhtmcs_map = 0xffc0; 568 break; 569 case 8: 570 dut->ap_vhtmcs_map = 0xffd5; 571 break; 572 case 9: 573 dut->ap_vhtmcs_map = 0xffea; 574 break; 575 default: 576 dut->ap_vhtmcs_map = 0xffea; 577 break; 578 } 579 default: 580 dut->ap_vhtmcs_map = 0xffea; 581 break; 582 } 583 } 584 585 586 /* Get 2*nss bitmask */ 587 /* We are trying to pack 2-bit MCS values per NSS in a 16-bit wide field. 588 * IEEE P802.11ax/D5.0, 9.4.2.247.4 supported HE-MCS And NSS Set field 589 * defines the following format for the 16 bit value. */ 590 591 #define HE_GET_MCS_NSS_PACK_MASK(nss) ((1 << ((nss) << 1)) - 1) 592 593 static void he_reset_mcs_values_for_unsupported_ss(uint8_t *mcsnssmap, 594 uint8_t nss) 595 { 596 uint8_t nssmask; 597 598 if (nss <= 4) { 599 nssmask = ~HE_GET_MCS_NSS_PACK_MASK(nss); 600 mcsnssmap[0] |= nssmask; 601 mcsnssmap[1] = 0xff; 602 } else if (nss > 4 && nss <= 8) { 603 nssmask = ~HE_GET_MCS_NSS_PACK_MASK(nss - 4); 604 mcsnssmap[0] &= 0xff; 605 mcsnssmap[1] |= nssmask; 606 } 607 } 608 609 610 static void get_he_mcs_nssmap(uint8_t *mcsnssmap, uint8_t nss, 611 uint8_t mcs) 612 { 613 switch (mcs) { 614 case 11: 615 mcsnssmap[0] = 0xaa; 616 mcsnssmap[1] = 0xaa; 617 break; 618 case 9: 619 mcsnssmap[0] = 0x55; 620 mcsnssmap[1] = 0x55; 621 break; 622 case 7: 623 mcsnssmap[0] = 0x0; 624 mcsnssmap[1] = 0x0; 625 break; 626 } 627 he_reset_mcs_values_for_unsupported_ss(mcsnssmap, nss); 628 } 629 630 631 static enum sigma_cmd_result cmd_ap_set_wireless(struct sigma_dut *dut, 632 struct sigma_conn *conn, 633 struct sigma_cmd *cmd) 634 { 635 /* const char *name = get_param(cmd, "NAME"); */ 636 /* const char *ifname = get_param(cmd, "INTERFACE"); */ 637 const char *val; 638 unsigned int wlan_tag = 1; 639 const char *ifname = get_main_ifname(dut); 640 char buf[128]; 641 642 /* Allow program to be overridden if specified in the ap_set_wireless 643 * to support some 60 GHz test scripts where the program may be 60 GHz 644 * or WPS. */ 645 val = get_param(cmd, "PROGRAM"); 646 if (val) 647 dut->program = sigma_program_to_enum(val); 648 649 val = get_param(cmd, "WLAN_TAG"); 650 if (val) { 651 wlan_tag = atoi(val); 652 if (wlan_tag < 1 || wlan_tag > 3) { 653 /* 654 * The only valid WLAN Tags as of now as per the latest 655 * WFA scripts are 1, 2, and 3. 656 */ 657 send_resp(dut, conn, SIGMA_INVALID, 658 "errorCode,Invalid WLAN_TAG"); 659 return STATUS_SENT; 660 } 661 } 662 663 val = get_param(cmd, "Interface"); 664 if (val) { 665 if (strcasecmp(val, "5G") == 0) 666 dut->ap_interface_5g = 1; 667 else 668 dut->ap_interface_2g = 1; 669 670 if (dut->ap_interface_5g && dut->ap_interface_2g) 671 dut->ap_is_dual = 1; 672 } 673 674 val = get_param(cmd, "CountryCode"); 675 if (val) { 676 if (strlen(val) > sizeof(dut->ap_countrycode) - 1) 677 return INVALID_SEND_STATUS; 678 snprintf(dut->ap_countrycode, sizeof(dut->ap_countrycode), 679 "%s", val); 680 681 /* 682 * Regdomain self-managed driver does not accept hostapd country 683 * code setting in all cases. Try to use wpa_supplicant DRIVER 684 * command first to set the driver to a specific country code 685 * before starting AP functionality. This is targeting cases 686 * where wpa_supplicant is running on the device as well for 687 * non-AP mode functionality. 688 */ 689 if (get_driver_type(dut) == DRIVER_LINUX_WCN) 690 set_ap_country_code(dut); 691 } 692 693 val = get_param(cmd, "regulatory_mode"); 694 if (val) { 695 if (strcasecmp(val, "11d") == 0 || strcasecmp(val, "11h") == 0) 696 dut->ap_regulatory_mode = AP_80211D_MODE_ENABLED; 697 } 698 699 val = get_param(cmd, "SSID"); 700 if (val) { 701 if (strlen(val) > sizeof(dut->ap_ssid) - 1) 702 return INVALID_SEND_STATUS; 703 704 if (wlan_tag == 1) { 705 /* 706 * If tag is not specified, it is deemed to be 1. 707 * Hence tag of 1 is a special case and the values 708 * corresponding to wlan-tag=1 are stored separately 709 * from the values corresponding tags 2 and 3. 710 * This approach minimises the changes to existing code 711 * since most of the sigma_dut code does not deal with 712 * WLAN-TAG CAPI variable. 713 */ 714 snprintf(dut->ap_ssid, 715 sizeof(dut->ap_ssid), "%s", val); 716 } else { 717 snprintf(dut->ap_tag_ssid[wlan_tag - 2], 718 sizeof(dut->ap_tag_ssid[wlan_tag - 2]), 719 "%s", val); 720 } 721 } 722 723 val = get_param(cmd, "CHANNEL"); 724 if (val) { 725 const char *pos; 726 dut->ap_channel = atoi(val); 727 pos = strchr(val, ';'); 728 if (pos) { 729 pos++; 730 dut->ap_channel_1 = atoi(pos); 731 } 732 } 733 734 /* Overwrite the AP channel with DFS channel if configured */ 735 val = get_param(cmd, "dfs_chan"); 736 if (val) { 737 dut->ap_channel = atoi(val); 738 } 739 740 val = get_param(cmd, "dfs_mode"); 741 if (val) { 742 if (strcasecmp(val, "Enable") == 0) 743 dut->ap_dfs_mode = AP_DFS_MODE_ENABLED; 744 else if (strcasecmp(val, "Disable") == 0) 745 dut->ap_dfs_mode = AP_DFS_MODE_DISABLED; 746 else 747 sigma_dut_print(dut, DUT_MSG_ERROR, 748 "Unsupported dfs_mode value: %s", val); 749 } 750 751 val = get_param(cmd, "MODE"); 752 if (val) { 753 char *str, *pos; 754 755 str = strdup(val); 756 if (str == NULL) 757 return INVALID_SEND_STATUS; 758 pos = strchr(str, ';'); 759 if (pos) 760 *pos++ = '\0'; 761 762 dut->ap_is_dual = 0; 763 dut->ap_mode = get_mode(str); 764 if (dut->ap_mode == AP_inval) { 765 send_resp(dut, conn, SIGMA_INVALID, 766 "errorCode,Unsupported MODE"); 767 free(str); 768 return STATUS_SENT; 769 } 770 if (dut->ap_mode == AP_11ac && dut->ap_80plus80 != 1) 771 dut->ap_chwidth = AP_80; 772 773 if (pos) { 774 dut->ap_mode_1 = get_mode(pos); 775 if (dut->ap_mode_1 == AP_inval) { 776 send_resp(dut, conn, SIGMA_INVALID, 777 "errorCode,Unsupported MODE"); 778 free(str); 779 return STATUS_SENT; 780 } 781 if (dut->ap_mode_1 == AP_11ac) 782 dut->ap_chwidth_1 = AP_80; 783 dut->ap_is_dual = 1; 784 } 785 786 free(str); 787 } else if (dut->ap_mode == AP_inval) { 788 if (dut->ap_channel <= 11) 789 dut->ap_mode = AP_11ng; 790 else if (dut->program == PROGRAM_VHT) 791 dut->ap_mode = AP_11ac; 792 else 793 dut->ap_mode = AP_11na; 794 } 795 796 /* Override the AP mode in case of 60 GHz */ 797 if (dut->program == PROGRAM_60GHZ) { 798 dut->ap_mode = AP_11ad; 799 /* Workaround to force channel 2 if not specified */ 800 if (!dut->ap_channel) 801 dut->ap_channel = 2; 802 } 803 804 switch (dut->ap_mode) { 805 case AP_11g: 806 case AP_11b: 807 case AP_11ng: 808 dut->use_5g = 0; 809 break; 810 case AP_11a: 811 case AP_11na: 812 case AP_11ac: 813 dut->use_5g = 1; 814 break; 815 case AP_11ax: 816 if (dut->ap_channel >= 1 && dut->ap_channel <= 14) 817 dut->use_5g = 0; 818 else if (dut->ap_channel >= 36 && dut->ap_channel <= 171) 819 dut->use_5g = 1; 820 break; 821 case AP_11ad: 822 case AP_inval: 823 break; 824 } 825 826 val = get_param(cmd, "WME"); 827 if (val) { 828 if (strcasecmp(val, "on") == 0) 829 dut->ap_wme = AP_WME_ON; 830 else if (strcasecmp(val, "off") == 0) 831 dut->ap_wme = AP_WME_OFF; 832 else 833 sigma_dut_print(dut, DUT_MSG_ERROR, 834 "Unsupported WME value: %s", val); 835 } 836 837 val = get_param(cmd, "WMMPS"); 838 if (val) { 839 if (strcasecmp(val, "on") == 0) 840 dut->ap_wmmps = AP_WMMPS_ON; 841 else if (strcasecmp(val, "off") == 0) 842 dut->ap_wmmps = AP_WMMPS_OFF; 843 else 844 sigma_dut_print(dut, DUT_MSG_ERROR, 845 "Unsupported WMMPS value: %s", val); 846 } 847 848 val = get_param(cmd, "RTS"); 849 if (val) 850 dut->ap_rts = atoi(val); 851 852 val = get_param(cmd, "FRGMNT"); 853 if (val) 854 dut->ap_frgmnt = atoi(val); 855 856 /* TODO: PWRSAVE */ 857 858 val = get_param(cmd, "BCNINT"); 859 if (val) 860 dut->ap_bcnint = atoi(val); 861 862 val = get_param(cmd, "RADIO"); 863 if (val) { 864 enum driver_type drv = get_driver_type(dut); 865 866 if (strcasecmp(val, "on") == 0) { 867 if (drv == DRIVER_OPENWRT) 868 ath_radio(dut, val); 869 if (drv == DRIVER_ATHEROS) 870 ath_ap_start_hostapd(dut); 871 else if (cmd_ap_config_commit(dut, conn, cmd) <= 0) 872 return STATUS_SENT; 873 } else if (strcasecmp(val, "off") == 0) { 874 if (drv == DRIVER_OPENWRT) { 875 ath_radio(dut, val); 876 } else if (dut->use_hostapd_pid_file) { 877 kill_hostapd_process_pid(dut); 878 } else if (kill_process(dut, "(hostapd)", 1, 879 SIGTERM) == 0 || 880 system("killall hostapd") == 0) { 881 sigma_dut_print(dut, DUT_MSG_INFO, 882 "Killed hostapd on radio,off"); 883 } 884 } else { 885 send_resp(dut, conn, SIGMA_INVALID, 886 "errorCode,Unsupported RADIO value"); 887 return STATUS_SENT; 888 } 889 } 890 891 val = get_param(cmd, "P2PMgmtBit"); 892 if (val) 893 dut->ap_p2p_mgmt = atoi(val); 894 895 /* TODO: ChannelUsage */ 896 897 /* TODO: 40_INTOLERANT */ 898 899 val = get_param(cmd, "ADDBA_REJECT"); 900 if (val) { 901 if (strcasecmp(val, "Enable") == 0) 902 dut->ap_addba_reject = VALUE_ENABLED; 903 else if (strcasecmp(val, "Disable") == 0) 904 dut->ap_addba_reject = VALUE_DISABLED; 905 } 906 907 val = get_param(cmd, "AMPDU"); 908 if (val) { 909 if (strcasecmp(val, "Enable") == 0) 910 dut->ap_ampdu = VALUE_ENABLED; 911 else if (strcasecmp(val, "Disable") == 0) 912 dut->ap_ampdu = VALUE_DISABLED; 913 } 914 915 val = get_param(cmd, "AMPDU_EXP"); 916 if (val) 917 dut->ap_ampdu_exp = atoi(val); 918 919 val = get_param(cmd, "AMSDU"); 920 if (val) { 921 if (strcasecmp(val, "Enable") == 0) 922 dut->ap_amsdu = VALUE_ENABLED; 923 else if (strcasecmp(val, "Disable") == 0) 924 dut->ap_amsdu = VALUE_DISABLED; 925 } 926 927 val = get_param(cmd, "NoAck"); 928 if (val) { 929 if (strcasecmp(val, "on") == 0) 930 dut->ap_noack = VALUE_ENABLED; 931 else if (strcasecmp(val, "off") == 0) 932 dut->ap_noack = VALUE_DISABLED; 933 } 934 935 /* TODO: GREENFIELD */ 936 /* TODO: MCS_32 */ 937 938 val = get_param(cmd, "OFFSET"); 939 if (val) { 940 if (strcasecmp(val, "Above") == 0) 941 dut->ap_chwidth_offset = SEC_CH_40ABOVE; 942 else if (strcasecmp(val, "Below") == 0) 943 dut->ap_chwidth_offset = SEC_CH_40BELOW; 944 } 945 946 val = get_param(cmd, "MCS_FIXEDRATE"); 947 if (val) { 948 dut->ap_fixed_rate = 1; 949 dut->ap_mcs = atoi(val); 950 } 951 952 val = get_param(cmd, "SPATIAL_RX_STREAM"); 953 if (val) { 954 if (strcasecmp(val, "1SS") == 0 || strcasecmp(val, "1") == 0) { 955 dut->ap_rx_streams = 1; 956 if (dut->device_type == AP_testbed) 957 dut->ap_vhtmcs_map = 0xfffc; 958 } else if (strcasecmp(val, "2SS") == 0 || 959 strcasecmp(val, "2") == 0) { 960 dut->ap_rx_streams = 2; 961 if (dut->device_type == AP_testbed) 962 dut->ap_vhtmcs_map = 0xfff0; 963 } else if (strcasecmp(val, "3SS") == 0 || 964 strcasecmp(val, "3") == 0) { 965 dut->ap_rx_streams = 3; 966 if (dut->device_type == AP_testbed) 967 dut->ap_vhtmcs_map = 0xffc0; 968 } else if (strcasecmp(val, "4SS") == 0 || 969 strcasecmp(val, "4") == 0) { 970 dut->ap_rx_streams = 4; 971 } 972 } 973 974 val = get_param(cmd, "SPATIAL_TX_STREAM"); 975 if (val) { 976 if (strcasecmp(val, "1SS") == 0 || 977 strcasecmp(val, "1") == 0) { 978 dut->ap_tx_streams = 1; 979 if (dut->device_type == AP_testbed) 980 dut->ap_vhtmcs_map = 0xfffc; 981 } else if (strcasecmp(val, "2SS") == 0 || 982 strcasecmp(val, "2") == 0) { 983 dut->ap_tx_streams = 2; 984 if (dut->device_type == AP_testbed) 985 dut->ap_vhtmcs_map = 0xfff0; 986 } else if (strcasecmp(val, "3SS") == 0 || 987 strcasecmp(val, "3") == 0) { 988 dut->ap_tx_streams = 3; 989 if (dut->device_type == AP_testbed) 990 dut->ap_vhtmcs_map = 0xffc0; 991 } else if (strcasecmp(val, "4SS") == 0 || 992 strcasecmp(val, "4") == 0) { 993 dut->ap_tx_streams = 4; 994 } 995 } 996 997 val = get_param(cmd, "BSS_max_idle"); 998 if (val) { 999 if (strncasecmp(val, "Enable", 7) == 0) { 1000 dut->wnm_bss_max_feature = VALUE_ENABLED; 1001 } else if (strncasecmp(val, "Disable", 8) == 0) { 1002 dut->wnm_bss_max_feature = VALUE_DISABLED; 1003 } else { 1004 send_resp(dut, conn, SIGMA_ERROR, 1005 "errorCode,Invalid value for BSS_max_Feature"); 1006 return STATUS_SENT; 1007 } 1008 } 1009 1010 val = get_param(cmd, "BSS_Idle_Protection_options"); 1011 if (val) { 1012 int protection = (int) strtol(val, (char **) NULL, 10); 1013 1014 if (protection != 1 && protection != 0) { 1015 send_resp(dut, conn, SIGMA_ERROR, 1016 "errorCode,Invalid value for BSS_Idle_Protection_options"); 1017 return STATUS_SENT; 1018 } 1019 dut->wnm_bss_max_protection = protection ? 1020 VALUE_ENABLED : VALUE_DISABLED; 1021 } 1022 1023 val = get_param(cmd, "BSS_max_Idle_period"); 1024 if (val) { 1025 long int idle_time = strtol(val, (char **) NULL, 10); 1026 1027 if (idle_time == LONG_MIN || idle_time == LONG_MAX) { 1028 send_resp(dut, conn, SIGMA_ERROR, 1029 "errorCode,Invalid value for BSS_max_Idle_period"); 1030 return STATUS_SENT; 1031 } 1032 dut->wnm_bss_max_idle_time = (int) idle_time; 1033 } 1034 1035 val = get_param(cmd, "PROXY_ARP"); 1036 if (val) 1037 dut->ap_proxy_arp = (int) strtol(val, (char **) NULL, 10); 1038 1039 val = get_param(cmd, "nss_mcs_cap"); 1040 if (val) { 1041 int nss, mcs; 1042 char token[20]; 1043 char *result = NULL; 1044 char *saveptr; 1045 1046 if (strlen(val) >= sizeof(token)) 1047 return INVALID_SEND_STATUS; 1048 strlcpy(token, val, sizeof(token)); 1049 result = strtok_r(token, ";", &saveptr); 1050 if (!result) { 1051 send_resp(dut, conn, SIGMA_ERROR, 1052 "errorCode,VHT NSS not specified"); 1053 return STATUS_SENT; 1054 } 1055 nss = atoi(result); 1056 result = strtok_r(NULL, ";", &saveptr); 1057 if (result == NULL) { 1058 send_resp(dut, conn, SIGMA_ERROR, 1059 "errorCode,VHTMCS not specified"); 1060 return STATUS_SENT; 1061 } 1062 result = strtok_r(result, "-", &saveptr); 1063 result = strtok_r(NULL, "-", &saveptr); 1064 if (!result) { 1065 send_resp(dut, conn, SIGMA_ERROR, 1066 "errorCode,VHT MCS not specified"); 1067 return STATUS_SENT; 1068 } 1069 mcs = atoi(result); 1070 if (dut->program == PROGRAM_HE) { 1071 uint16_t mcsnssmap = 0; 1072 1073 get_he_mcs_nssmap((uint8_t *) &mcsnssmap, nss, mcs); 1074 dut->he_mcsnssmap = (mcsnssmap << 16) | mcsnssmap; 1075 dut->he_ul_mcs = mcs; 1076 } else { 1077 set_vht_mcsmap_nss(dut, nss, mcs); 1078 } 1079 } 1080 1081 /* TODO: MPDU_MIN_START_SPACING */ 1082 /* TODO: RIFS_TEST */ 1083 /* TODO: SGI20 */ 1084 1085 val = get_param(cmd, "STBC_TX"); 1086 if (val) 1087 dut->ap_tx_stbc = atoi(val); 1088 1089 val = get_param(cmd, "WIDTH"); 1090 if (val) { 1091 if (strcasecmp(val, "20") == 0) 1092 dut->ap_chwidth = AP_20; 1093 else if (strcasecmp(val, "40") == 0) 1094 dut->ap_chwidth = AP_40; 1095 else if (strcasecmp(val, "80") == 0) 1096 dut->ap_chwidth = AP_80; 1097 else if (strcasecmp(val, "160") == 0) 1098 dut->ap_chwidth = AP_160; 1099 else if (strcasecmp(val, "80plus80") == 0) { 1100 dut->ap_80plus80 = 1; 1101 dut->ap_chwidth = AP_80_80; 1102 } else if (strcasecmp(val, "Auto") == 0) 1103 dut->ap_chwidth = AP_AUTO; 1104 else { 1105 send_resp(dut, conn, SIGMA_INVALID, 1106 "errorCode,Unsupported WIDTH"); 1107 return STATUS_SENT; 1108 } 1109 } 1110 1111 /* TODO: WIDTH_SCAN */ 1112 1113 val = get_param(cmd, "TDLSProhibit"); 1114 dut->ap_tdls_prohibit = val && strcasecmp(val, "Enabled") == 0; 1115 val = get_param(cmd, "TDLSChswitchProhibit"); 1116 dut->ap_tdls_prohibit_chswitch = 1117 val && strcasecmp(val, "Enabled") == 0; 1118 val = get_param(cmd, "HS2"); 1119 if (val && wlan_tag == 1) 1120 dut->ap_hs2 = atoi(val); 1121 val = get_param(cmd, "P2P_CROSS_CONNECT"); 1122 if (val) 1123 dut->ap_p2p_cross_connect = strcasecmp(val, "Enabled") == 0; 1124 1125 val = get_param(cmd, "FakePubKey"); 1126 dut->ap_fake_pkhash = val && atoi(val); 1127 1128 val = get_param(cmd, "vht_tkip"); 1129 dut->ap_allow_vht_tkip = val && strcasecmp(val, "Enable") == 0; 1130 val = get_param(cmd, "vht_wep"); 1131 dut->ap_allow_vht_wep = val && strcasecmp(val, "Enable") == 0; 1132 1133 val = get_param(cmd, "Protect_mode"); 1134 dut->ap_disable_protection = val && strcasecmp(val, "Disable") == 0; 1135 1136 val = get_param(cmd, "DYN_BW_SGNL"); 1137 if (val) { 1138 switch (get_driver_type(dut)) { 1139 case DRIVER_OPENWRT: 1140 switch (get_openwrt_driver_type()) { 1141 case OPENWRT_DRIVER_ATHEROS: 1142 ath_config_dyn_bw_sig(dut, ifname, val); 1143 break; 1144 default: 1145 send_resp(dut, conn, SIGMA_ERROR, 1146 "errorCode,Unsupported DYN_BW_SGNL with OpenWrt driver"); 1147 return STATUS_SENT; 1148 } 1149 break; 1150 case DRIVER_WCN: 1151 case DRIVER_LINUX_WCN: 1152 ath_config_dyn_bw_sig(dut, ifname, val); 1153 break; 1154 default: 1155 sigma_dut_print(dut, DUT_MSG_ERROR, 1156 "Unsupported DYN_BW_SGL with the current driver"); 1157 break; 1158 } 1159 } 1160 1161 val = get_param(cmd, "SGI80"); 1162 if (val) { 1163 if (strcasecmp(val, "enable") == 0) 1164 dut->ap_sgi80 = 1; 1165 else if (strcasecmp(val, "disable") == 0) 1166 dut->ap_sgi80 = 0; 1167 else { 1168 send_resp(dut, conn, SIGMA_INVALID, 1169 "errorCode,Unsupported SGI80"); 1170 return STATUS_SENT; 1171 } 1172 } 1173 1174 val = get_param(cmd, "LDPC"); 1175 if (val) { 1176 if (strcasecmp(val, "enable") == 0) 1177 dut->ap_ldpc = VALUE_ENABLED; 1178 else if (strcasecmp(val, "disable") == 0) 1179 dut->ap_ldpc = VALUE_DISABLED; 1180 else { 1181 send_resp(dut, conn, SIGMA_INVALID, 1182 "errorCode,Unsupported LDPC"); 1183 return STATUS_SENT; 1184 } 1185 switch (get_driver_type(dut)) { 1186 case DRIVER_WCN: 1187 case DRIVER_LINUX_WCN: 1188 wcn_config_ap_ldpc(dut, ifname); 1189 break; 1190 default: 1191 break; 1192 } 1193 } 1194 1195 val = get_param(cmd, "BW_SGNL"); 1196 if (val) { 1197 /* 1198 * With dynamic bandwidth signaling enabled we should see 1199 * RTS if the threshold is met. 1200 */ 1201 if (strcasecmp(val, "enable") == 0) { 1202 dut->ap_sig_rts = VALUE_ENABLED; 1203 } else if (strcasecmp(val, "disable") == 0) { 1204 dut->ap_sig_rts = VALUE_DISABLED; 1205 } else { 1206 send_resp(dut, conn, SIGMA_INVALID, 1207 "errorCode,Unsupported BW_SGNL"); 1208 return STATUS_SENT; 1209 } 1210 } 1211 1212 val = get_param(cmd, "RTS_FORCE"); 1213 if (val) { 1214 switch (get_driver_type(dut)) { 1215 case DRIVER_OPENWRT: 1216 switch (get_openwrt_driver_type()) { 1217 case OPENWRT_DRIVER_ATHEROS: 1218 ath_config_rts_force(dut, ifname, val); 1219 break; 1220 default: 1221 send_resp(dut, conn, SIGMA_ERROR, 1222 "errorCode,Unsupported RTS_FORCE with OpenWrt driver"); 1223 return STATUS_SENT; 1224 } 1225 break; 1226 case DRIVER_MAC80211: 1227 mac80211_config_rts_force(dut, ifname, val); 1228 break; 1229 default: 1230 sigma_dut_print(dut, DUT_MSG_ERROR, 1231 "Unsupported RTS_FORCE with the current driver"); 1232 break; 1233 } 1234 } 1235 1236 val = get_param(cmd, "Zero_crc"); 1237 if (val) { 1238 switch (get_driver_type(dut)) { 1239 case DRIVER_ATHEROS: 1240 ath_set_zero_crc(dut, val); 1241 break; 1242 case DRIVER_OPENWRT: 1243 switch (get_openwrt_driver_type()) { 1244 case OPENWRT_DRIVER_ATHEROS: 1245 ath_set_zero_crc(dut, val); 1246 break; 1247 default: 1248 send_resp(dut, conn, SIGMA_ERROR, 1249 "errorCode,Unsupported zero_crc with the current driver"); 1250 return STATUS_SENT; 1251 } 1252 break; 1253 default: 1254 send_resp(dut, conn, SIGMA_ERROR, 1255 "errorCode,Unsupported zero_crc with the current driver"); 1256 return STATUS_SENT; 1257 } 1258 } 1259 1260 val = get_param(cmd, "TxBF"); 1261 if (val) { 1262 dut->ap_txBF = strcasecmp(val, "enable") == 0; 1263 dut->he_sounding = VALUE_DISABLED; 1264 dut->he_set_sta_1x1 = VALUE_ENABLED; 1265 } 1266 1267 val = get_param(cmd, "MU_TxBF"); 1268 if (val) { 1269 if (strcasecmp(val, "enable") == 0) { 1270 dut->ap_txBF = 1; 1271 dut->ap_mu_txBF = 1; 1272 dut->he_sounding = VALUE_DISABLED; 1273 } else if (strcasecmp(val, "disable") == 0) { 1274 dut->ap_txBF = 0; 1275 dut->ap_mu_txBF = 0; 1276 } else { 1277 sigma_dut_print(dut, DUT_MSG_ERROR, 1278 "Unsupported MU_TxBF"); 1279 } 1280 } 1281 1282 /* UNSUPPORTED: tx_lgi_rate */ 1283 1284 val = get_param(cmd, "wpsnfc"); 1285 if (val) 1286 dut->ap_wpsnfc = atoi(val); 1287 1288 val = get_param(cmd, "GROUP_ID"); 1289 if (val) { 1290 switch (get_driver_type(dut)) { 1291 case DRIVER_OPENWRT: 1292 switch (get_openwrt_driver_type()) { 1293 case OPENWRT_DRIVER_ATHEROS: 1294 ath_ap_set_group_id(dut, ifname, val); 1295 break; 1296 default: 1297 send_resp(dut, conn, SIGMA_ERROR, 1298 "errorCode,Unsupported group_id with the current driver"); 1299 return STATUS_SENT; 1300 } 1301 break; 1302 default: 1303 send_resp(dut, conn, SIGMA_ERROR, 1304 "errorCode,Unsupported group_id with the current driver"); 1305 return STATUS_SENT; 1306 } 1307 } 1308 1309 val = get_param(cmd, "CTS_WIDTH"); 1310 if (val) { 1311 switch (get_driver_type(dut)) { 1312 case DRIVER_OPENWRT: 1313 switch (get_openwrt_driver_type()) { 1314 case OPENWRT_DRIVER_ATHEROS: 1315 ath_set_cts_width(dut, ifname, val); 1316 break; 1317 default: 1318 send_resp(dut, conn, SIGMA_ERROR, 1319 "errorCode,Unsupported cts_width with the current driver"); 1320 return STATUS_SENT; 1321 } 1322 break; 1323 default: 1324 send_resp(dut, conn, SIGMA_ERROR, 1325 "errorCode,Unsupported cts_width with the current driver"); 1326 return STATUS_SENT; 1327 } 1328 } 1329 1330 val = get_param(cmd, "MU_NDPA_FrameFormat"); 1331 if (val) 1332 dut->ap_ndpa_frame = atoi(val); 1333 1334 val = get_param(cmd, "interworking"); 1335 if (val && strcmp(val, "1") == 0) 1336 dut->ap_interworking = 1; 1337 1338 val = get_param(cmd, "GAS_CB_DELAY"); 1339 if (val) 1340 dut->ap_gas_cb_delay = atoi(val); 1341 1342 val = get_param(cmd, "LCI"); 1343 if (val) { 1344 if (strlen(val) > sizeof(dut->ap_val_lci) - 1) 1345 return INVALID_SEND_STATUS; 1346 dut->ap_lci = 1; 1347 snprintf(dut->ap_val_lci, sizeof(dut->ap_val_lci), "%s", val); 1348 ath_set_lci_config(dut, val, cmd); 1349 } 1350 1351 val = get_param(cmd, "InfoZ"); 1352 if (val) { 1353 if (strlen(val) > sizeof(dut->ap_infoz) - 1) 1354 return INVALID_SEND_STATUS; 1355 snprintf(dut->ap_infoz, sizeof(dut->ap_infoz), "%s", val); 1356 } 1357 1358 val = get_param(cmd, "LocCivicAddr"); 1359 if (val) { 1360 if (strlen(val) > sizeof(dut->ap_val_lcr) - 1) 1361 return INVALID_SEND_STATUS; 1362 dut->ap_lcr = 1; 1363 snprintf(dut->ap_val_lcr, sizeof(dut->ap_val_lcr), "%s", val); 1364 if (dut->ap_lci == 0) 1365 ath_set_lci_config(dut, val, cmd); 1366 } 1367 1368 val = get_param(cmd, "NeighAPBSSID"); 1369 if (val) { 1370 if (dut->ap_neighap < 3) { 1371 if (parse_mac_address( 1372 dut, val, 1373 dut->ap_val_neighap[dut->ap_neighap]) < 0) { 1374 send_resp(dut, conn, SIGMA_INVALID, 1375 "Failed to parse MAC address"); 1376 return STATUS_SENT; 1377 } 1378 dut->ap_neighap++; 1379 if (dut->ap_lci == 1) 1380 dut->ap_scan = 1; 1381 } 1382 } 1383 1384 val = get_param(cmd, "OpChannel"); 1385 if (val) { 1386 if (dut->ap_opchannel < 3) { 1387 dut->ap_val_opchannel[dut->ap_opchannel] = atoi(val); 1388 dut->ap_opchannel++; 1389 } 1390 } 1391 1392 val = get_param(cmd, "URI-FQDNdescriptor"); 1393 if (val) { 1394 if (strcasecmp(val, "HELD") == 0) { 1395 dut->ap_fqdn_held = 1; 1396 } else if (strcasecmp(val, "SUPL") == 0) { 1397 dut->ap_fqdn_supl = 1; 1398 } else { 1399 send_resp(dut, conn, SIGMA_INVALID, 1400 "errorCode,Unsupported URI-FQDNdescriptor"); 1401 return STATUS_SENT; 1402 } 1403 } 1404 1405 val = get_param(cmd, "Reg_Domain"); 1406 if (val) { 1407 if (strcasecmp(val, "Local") == 0) { 1408 dut->ap_reg_domain = REG_DOMAIN_LOCAL; 1409 } else if (strcasecmp(val, "Global") == 0) { 1410 dut->ap_reg_domain = REG_DOMAIN_GLOBAL; 1411 } else { 1412 send_resp(dut, conn, SIGMA_ERROR, 1413 "errorCode,Wrong value for Reg_Domain"); 1414 return STATUS_SENT; 1415 } 1416 } 1417 1418 val = get_param(cmd, "NAME"); 1419 if (val) { 1420 if (strcasecmp(val, "ap1mbo") == 0) 1421 dut->ap_name = 1; 1422 else if (strcasecmp(val, "ap2mbo") == 0) 1423 dut->ap_name = 2; 1424 else 1425 dut->ap_name = 0; 1426 } 1427 1428 val = get_param(cmd, "FT_OA"); 1429 if (val) { 1430 if (strcasecmp(val, "Enable") == 0) { 1431 dut->ap_ft_oa = 1; 1432 } else if (strcasecmp(val, "Disable") == 0) { 1433 dut->ap_ft_oa = 0; 1434 } else { 1435 send_resp(dut, conn, SIGMA_ERROR, 1436 "errorCode,Wrong value for FT_OA"); 1437 return STATUS_SENT; 1438 } 1439 } 1440 1441 val = get_param(cmd, "FT_DS"); 1442 if (val) { 1443 if (strcasecmp(val, "Enable") == 0) { 1444 dut->ap_ft_ds = VALUE_ENABLED; 1445 } else if (strcasecmp(val, "Disable") == 0) { 1446 dut->ap_ft_ds = VALUE_DISABLED; 1447 } else { 1448 send_resp(dut, conn, SIGMA_ERROR, 1449 "errorCode,Unsupported value for FT_DS"); 1450 return STATUS_SENT_ERROR; 1451 } 1452 } 1453 1454 val = get_param(cmd, "Cellular_Cap_Pref"); 1455 if (val) 1456 dut->ap_cell_cap_pref = atoi(val); 1457 1458 val = get_param(cmd, "DOMAIN"); 1459 if (val) { 1460 if (strlen(val) >= sizeof(dut->ap_mobility_domain)) { 1461 send_resp(dut, conn, SIGMA_ERROR, 1462 "errorCode,Too long DOMAIN"); 1463 return STATUS_SENT; 1464 } 1465 snprintf(dut->ap_mobility_domain, 1466 sizeof(dut->ap_mobility_domain), "%s", val); 1467 } 1468 1469 val = get_param(cmd, "ft_bss_list"); 1470 if (val) { 1471 char *mac_str; 1472 int i; 1473 char *saveptr; 1474 char *mac_list_str; 1475 1476 mac_list_str = strdup(val); 1477 if (!mac_list_str) 1478 return INVALID_SEND_STATUS; 1479 mac_str = strtok_r(mac_list_str, " ", &saveptr); 1480 for (i = 0; mac_str && i < MAX_FT_BSS_LIST; i++) { 1481 if (parse_mac_address(dut, mac_str, 1482 dut->ft_bss_mac_list[i]) < 0) { 1483 sigma_dut_print(dut, DUT_MSG_ERROR, 1484 "MAC Address not in proper format"); 1485 break; 1486 } 1487 dut->ft_bss_mac_cnt++; 1488 mac_str = strtok_r(NULL, " ", &saveptr); 1489 } 1490 sigma_dut_print(dut, DUT_MSG_DEBUG, 1491 "Storing the following FT BSS MAC List"); 1492 for (i = 0; i < dut->ft_bss_mac_cnt; i++) { 1493 sigma_dut_print(dut, DUT_MSG_DEBUG, 1494 "MAC[%d] %02x:%02x:%02x:%02x:%02x:%02x", 1495 i, 1496 dut->ft_bss_mac_list[i][0], 1497 dut->ft_bss_mac_list[i][1], 1498 dut->ft_bss_mac_list[i][2], 1499 dut->ft_bss_mac_list[i][3], 1500 dut->ft_bss_mac_list[i][4], 1501 dut->ft_bss_mac_list[i][5]); 1502 } 1503 free(mac_list_str); 1504 } 1505 1506 val = get_param(cmd, "OCESupport"); 1507 if (val) { 1508 if (strcasecmp(val, "enable") == 0) { 1509 dut->ap_oce = VALUE_ENABLED; 1510 } else if (strcasecmp(val, "disable") == 0) { 1511 dut->ap_oce = VALUE_DISABLED; 1512 dut->ap_filsdscv = VALUE_DISABLED; 1513 } else { 1514 send_resp(dut, conn, SIGMA_INVALID, 1515 "errorCode,Unsupported OCE"); 1516 return STATUS_SENT; 1517 } 1518 } 1519 1520 val = get_param(cmd, "FILSDscvInterval"); 1521 if (val) 1522 dut->ap_fils_dscv_int = atoi(val); 1523 1524 val = get_param(cmd, "BroadcastSSID"); 1525 if (val) { 1526 if (strcasecmp(val, "enable") == 0) { 1527 dut->ap_broadcast_ssid = VALUE_ENABLED; 1528 } else if (strcasecmp(val, "disable") == 0) { 1529 dut->ap_broadcast_ssid = VALUE_DISABLED; 1530 } else { 1531 send_resp(dut, conn, SIGMA_INVALID, 1532 "errorCode,Unsupported hidden SSID"); 1533 return STATUS_SENT; 1534 } 1535 } 1536 1537 val = get_param(cmd, "FILSDscv"); 1538 if (val) { 1539 if (strcasecmp(val, "enable") == 0) { 1540 dut->ap_filsdscv = VALUE_ENABLED; 1541 } else if (strcasecmp(val, "disable") == 0) { 1542 dut->ap_filsdscv = VALUE_DISABLED; 1543 } else { 1544 send_resp(dut, conn, SIGMA_INVALID, 1545 "errorCode,Unsupported FILSDscv"); 1546 return STATUS_SENT; 1547 } 1548 } 1549 1550 val = get_param(cmd, "FILSHLP"); 1551 if (val) { 1552 if (strcasecmp(val, "enable") == 0) { 1553 dut->ap_filshlp = VALUE_ENABLED; 1554 } else if (strcasecmp(val, "disable") == 0) { 1555 dut->ap_filshlp = VALUE_DISABLED; 1556 } else { 1557 send_resp(dut, conn, SIGMA_INVALID, 1558 "errorCode,Unsupported FILSHLP"); 1559 return STATUS_SENT; 1560 } 1561 } 1562 1563 val = get_param(cmd, "NAIRealm"); 1564 if (val) { 1565 dut->ap_nairealm_int = 1; 1566 if (strlen(val) > sizeof(dut->ap_nairealm) - 1) 1567 return INVALID_SEND_STATUS; 1568 snprintf(dut->ap_nairealm, sizeof(dut->ap_nairealm), "%s", val); 1569 } 1570 1571 val = get_param(cmd, "DeauthDisassocTx"); 1572 if (val) { 1573 if (strcasecmp(val, "disable") == 0) { 1574 deauth_disassoc(dut, ifname, val); 1575 } else { 1576 send_resp(dut, conn, SIGMA_INVALID, 1577 "errorCode,Unsupported DeauthDisassocTx"); 1578 return STATUS_SENT; 1579 } 1580 } 1581 1582 val = get_param(cmd, "RNR"); 1583 if (val) { 1584 if (strcasecmp(val, "enable") == 0) { 1585 dut->ap_rnr = VALUE_ENABLED; 1586 } else if (strcasecmp(val, "disable") == 0) { 1587 dut->ap_rnr = VALUE_DISABLED; 1588 } else { 1589 send_resp(dut, conn, SIGMA_INVALID, 1590 "errorCode,Unsupported RNR"); 1591 return STATUS_SENT; 1592 } 1593 } 1594 1595 val = get_param(cmd, "BLEChannelUtil"); 1596 if (val) 1597 dut->ap_blechanutil = atoi(val); 1598 1599 val = get_param(cmd, "BLEAvailAdminCap"); 1600 if (val) 1601 dut->ap_ble_admit_cap = atoi(val); 1602 1603 val = get_param(cmd, "DataPPDUDuration"); 1604 if (val) 1605 dut->ap_datappdudura = atoi(val); 1606 1607 val = get_param(cmd, "AirTimeFract"); 1608 if (val) 1609 dut->ap_airtimefract = atoi(val); 1610 1611 val = get_param(cmd, "dhcpServIPADDR"); 1612 if (val) { 1613 if (strlen(val) > sizeof(dut->ap_dhcpserv_ipaddr) - 1) 1614 return INVALID_SEND_STATUS; 1615 snprintf(dut->ap_dhcpserv_ipaddr, 1616 sizeof(dut->ap_dhcpserv_ipaddr), "%s", val); 1617 dut->ap_dhcp_stop = 1; 1618 } 1619 1620 val = get_param(cmd, "ESP_IE"); 1621 if (val) { 1622 if (strcasecmp(val, "enable") == 0) { 1623 dut->ap_esp = VALUE_ENABLED; 1624 } else if (strcasecmp(val, "disable") == 0) { 1625 dut->ap_esp = VALUE_DISABLED; 1626 } else { 1627 send_resp(dut, conn, SIGMA_INVALID, 1628 "errorCode,Unsupported ESP_IE"); 1629 return STATUS_SENT; 1630 } 1631 } 1632 1633 val = get_param(cmd, "BAWinSize"); 1634 if (val) 1635 dut->ap_bawinsize = atoi(val); 1636 1637 val = get_param(cmd, "BLEStaCount"); 1638 if (val) 1639 dut->ap_blestacnt = atoi(val); 1640 1641 val = get_param(cmd, "PPDUTxType"); 1642 if (val) { 1643 if (strcasecmp(val, "MU") == 0) { 1644 dut->ap_he_ppdu = PPDU_MU; 1645 } else if (strcasecmp(val, "HE-SU") == 0) { 1646 /* Do nothing */ 1647 } else if (strcasecmp(val, "SU") == 0) { 1648 /* Do nothing */ 1649 } else if (strcasecmp(val, "legacy") == 0) { 1650 /* Do nothing */ 1651 } else if (strcasecmp(val, "ER") == 0) { 1652 /* Do nothing */ 1653 } else if (strcasecmp(val, "TB") == 0) { 1654 /* Do nothing */ 1655 } else { 1656 send_resp(dut, conn, SIGMA_ERROR, 1657 "errorCode,Unsupported PPDUTxType"); 1658 return STATUS_SENT_ERROR; 1659 } 1660 } 1661 1662 val = get_param(cmd, "WscIEFragment"); 1663 if (val && strcasecmp(val, "enable") == 0) { 1664 sigma_dut_print(dut, DUT_MSG_DEBUG, 1665 "Enable WSC IE fragmentation"); 1666 dut->wsc_fragment = 1; 1667 } 1668 1669 val = get_param(cmd, "WpsVersion"); 1670 if (val) 1671 dut->wps_forced_version = get_wps_forced_version(dut, val); 1672 1673 val = get_param(cmd, "WscEAPFragment"); 1674 if (val && strcasecmp(val, "enable") == 0) 1675 dut->eap_fragment = 1; 1676 1677 val = get_param(cmd, "MSDUSize"); 1678 if (val) { 1679 int mtu; 1680 1681 dut->amsdu_size = atoi(val); 1682 if (dut->amsdu_size > IEEE80211_MAX_DATA_LEN_DMG || 1683 dut->amsdu_size < IEEE80211_SNAP_LEN_DMG) { 1684 sigma_dut_print(dut, DUT_MSG_ERROR, 1685 "MSDUSize %d is above max %d or below min %d", 1686 dut->amsdu_size, 1687 IEEE80211_MAX_DATA_LEN_DMG, 1688 IEEE80211_SNAP_LEN_DMG); 1689 dut->amsdu_size = 0; 1690 return ERROR_SEND_STATUS; 1691 } 1692 1693 mtu = dut->amsdu_size - IEEE80211_SNAP_LEN_DMG; 1694 sigma_dut_print(dut, DUT_MSG_DEBUG, 1695 "Setting amsdu_size to %d", mtu); 1696 snprintf(buf, sizeof(buf), "ifconfig %s mtu %d", 1697 get_station_ifname(dut), mtu); 1698 1699 if (system(buf) != 0) { 1700 sigma_dut_print(dut, DUT_MSG_ERROR, "Failed to set %s", 1701 buf); 1702 return ERROR_SEND_STATUS; 1703 } 1704 } 1705 1706 val = get_param(cmd, "BAckRcvBuf"); 1707 if (val) { 1708 dut->back_rcv_buf = atoi(val); 1709 if (dut->back_rcv_buf == 0) { 1710 sigma_dut_print(dut, DUT_MSG_ERROR, 1711 "Failed to convert %s or value is 0", 1712 val); 1713 return ERROR_SEND_STATUS; 1714 } 1715 1716 sigma_dut_print(dut, DUT_MSG_DEBUG, 1717 "Setting BAckRcvBuf to %s", val); 1718 } 1719 1720 val = get_param(cmd, "ExtSchIE"); 1721 if (val && !strcasecmp(val, "Enable")) { 1722 int num_allocs = MAX_ESE_ALLOCS; 1723 1724 if (sta_extract_60g_ese(dut, cmd, dut->ap_ese_allocs, 1725 &num_allocs)) { 1726 send_resp(dut, conn, SIGMA_INVALID, 1727 "errorCode,Invalid ExtSchIE"); 1728 return STATUS_SENT; 1729 } 1730 dut->ap_num_ese_allocs = num_allocs; 1731 } 1732 1733 if (is_60g_sigma_dut(dut)) { 1734 unsigned int abft_len = 1; /* default is one slot */ 1735 1736 val = get_param(cmd, "ABFTLRang"); 1737 if (val) { 1738 sigma_dut_print(dut, DUT_MSG_DEBUG, 1739 "ABFTLRang parameter %s", val); 1740 if (strcasecmp(val, "Gt1") == 0) 1741 abft_len = 2; /* 2 slots in this case */ 1742 } 1743 1744 if (sta_set_60g_abft_len(dut, conn, abft_len)) { 1745 send_resp(dut, conn, SIGMA_ERROR, 1746 "ErrorCode,Can't set ABFT length"); 1747 return STATUS_SENT; 1748 } 1749 } 1750 1751 val = get_param(cmd, "OFDMA"); 1752 if (val) { 1753 if (strcasecmp(val, "UL") == 0) { 1754 dut->ap_he_ulofdma = VALUE_ENABLED; 1755 } else if (strcasecmp(val, "DL") == 0) { 1756 dut->ap_he_dlofdma = VALUE_ENABLED; 1757 } else if (strcasecmp(val, "DL-20and80") == 0) { 1758 dut->ap_he_dlofdma = VALUE_ENABLED; 1759 } else { 1760 send_resp(dut, conn, SIGMA_ERROR, 1761 "errorCode,Unsupported OFDMA value"); 1762 return STATUS_SENT_ERROR; 1763 } 1764 } 1765 1766 val = get_param(cmd, "NumSoundDim"); 1767 if (val) 1768 dut->ap_numsounddim = atoi(val); 1769 1770 val = get_param(cmd, "BCC"); 1771 if (val) { 1772 if (strcasecmp(val, "enable") == 0) { 1773 dut->ap_bcc = VALUE_ENABLED; 1774 dut->ap_ldpc = VALUE_DISABLED; 1775 } else if (strcasecmp(val, "disable") == 0) { 1776 dut->ap_ldpc = VALUE_ENABLED; 1777 dut->ap_bcc = VALUE_DISABLED; 1778 } else { 1779 send_resp(dut, conn, SIGMA_ERROR, 1780 "errorCode,Unsupported BCC value"); 1781 return STATUS_SENT_ERROR; 1782 } 1783 switch (get_driver_type(dut)) { 1784 case DRIVER_WCN: 1785 case DRIVER_LINUX_WCN: 1786 wcn_config_ap_ldpc(dut, ifname); 1787 break; 1788 default: 1789 break; 1790 } 1791 } 1792 1793 val = get_param(cmd, "FrgmntSupport"); 1794 if (val) { 1795 if (strcasecmp(val, "enable") == 0) { 1796 dut->ap_he_frag = VALUE_ENABLED; 1797 } else if (strcasecmp(val, "disable") == 0) { 1798 dut->ap_he_frag = VALUE_DISABLED; 1799 } else { 1800 send_resp(dut, conn, SIGMA_ERROR, 1801 "errorCode,Unsupported FrgmntSupport value"); 1802 return STATUS_SENT_ERROR; 1803 } 1804 } 1805 1806 val = get_param(cmd, "ADDBAReq_BufSize"); 1807 if (val) { 1808 if (strcasecmp(val, "le64") == 0) { 1809 dut->ap_ba_bufsize = BA_BUFSIZE_64; 1810 } else if (strcasecmp(val, "gt64") == 0) { 1811 dut->ap_ba_bufsize = BA_BUFSIZE_256; 1812 } else { 1813 send_resp(dut, conn, SIGMA_ERROR, 1814 "errorCode,Unsupported ADDBAReq Buffer Size"); 1815 return STATUS_SENT_ERROR; 1816 } 1817 } 1818 1819 val = get_param(cmd, "ADDBAResp_BufSize"); 1820 if (val) { 1821 if (strcasecmp(val, "gt64") == 0) { 1822 dut->ap_ba_bufsize = BA_BUFSIZE_256; 1823 } else { 1824 send_resp(dut, conn, SIGMA_ERROR, 1825 "errorCode,Unsupported ADDBAResp Buffer Size"); 1826 return STATUS_SENT_ERROR; 1827 } 1828 } 1829 1830 val = get_param(cmd, "MU_EDCA"); 1831 if (val) { 1832 if (strcasecmp(val, "override") == 0) { 1833 dut->ap_mu_edca = VALUE_ENABLED; 1834 } else if (strcasecmp(val, "disable") == 0) { 1835 dut->ap_mu_edca = VALUE_DISABLED; 1836 } else { 1837 send_resp(dut, conn, SIGMA_ERROR, 1838 "errorCode,Unsupported mu_edca param value"); 1839 return STATUS_SENT_ERROR; 1840 } 1841 } 1842 1843 val = get_param(cmd, "MIMO"); 1844 if (val) { 1845 if (strcasecmp(val, "DL") == 0) { 1846 dut->ap_he_mimo = MIMO_DL; 1847 dut->he_sounding = VALUE_DISABLED; 1848 } else if (strcasecmp(val, "UL") == 0) { 1849 dut->ap_he_mimo = MIMO_UL; 1850 } else { 1851 send_resp(dut, conn, SIGMA_ERROR, 1852 "errorCode,Unsupported mimo param value"); 1853 return STATUS_SENT_ERROR; 1854 } 1855 } 1856 1857 val = get_param(cmd, "HE_TXOPDurRTSThr"); 1858 if (val) { 1859 if (strcasecmp(val, "enable") == 0) { 1860 dut->ap_he_rtsthrshld = VALUE_ENABLED; 1861 } else if (strcasecmp(val, "disable") == 0) { 1862 dut->ap_he_rtsthrshld = VALUE_DISABLED; 1863 } else { 1864 send_resp(dut, conn, SIGMA_ERROR, 1865 "errorCode,Unsupported HE_TXOPDurRTSThr value"); 1866 return STATUS_SENT_ERROR; 1867 } 1868 } 1869 1870 val = get_param(cmd, "MBSSID"); 1871 if (val) { 1872 if (strcasecmp(val, "enable") == 0) { 1873 dut->ap_mbssid = VALUE_ENABLED; 1874 } else if (strcasecmp(val, "disable") == 0) { 1875 dut->ap_mbssid = VALUE_DISABLED; 1876 } else { 1877 send_resp(dut, conn, SIGMA_ERROR, 1878 "errorCode,Unsupported MBSSID Value"); 1879 return STATUS_SENT_ERROR; 1880 } 1881 } 1882 1883 val = get_param(cmd, "TWT_RespSupport"); 1884 if (val) { 1885 if (strcasecmp(val, "enable") == 0) { 1886 dut->ap_twtresp = VALUE_ENABLED; 1887 } else if (strcasecmp(val, "disable") == 0) { 1888 dut->ap_twtresp = VALUE_DISABLED; 1889 } else { 1890 send_resp(dut, conn, SIGMA_ERROR, 1891 "errorCode,Unsupported TWT_RespSupport value"); 1892 return STATUS_SENT_ERROR; 1893 } 1894 } 1895 1896 val = get_param(cmd, "MinMPDUStartSpacing"); 1897 if (val) 1898 dut->he_mmss = atoi(val); 1899 1900 val = get_param(cmd, "SRCtrl_SRValue15Allowed"); 1901 if (val) 1902 dut->he_srctrl_allow = atoi(val); 1903 1904 val = get_param(cmd, "ocvc"); 1905 if (val) 1906 dut->ap_ocvc = atoi(val); 1907 1908 return SUCCESS_SEND_STATUS; 1909 } 1910 1911 1912 static void ath_inject_frame(struct sigma_dut *dut, const char *ifname, int tid) 1913 { 1914 char buf[256]; 1915 int tid_to_dscp[] = { 0x00, 0x20, 0x40, 0x60, 0x80, 0xa0, 0xc0, 0xe0 }; 1916 1917 if (tid < 0 || 1918 tid >= (int) (sizeof(tid_to_dscp) / sizeof(tid_to_dscp[0]))) { 1919 sigma_dut_print(dut, DUT_MSG_ERROR, "Unsupported TID: %d", tid); 1920 return; 1921 } 1922 1923 snprintf(buf, sizeof(buf), 1924 "wlanconfig %s list sta | grep : | cut -b 1-17 > %s", 1925 ifname, VI_QOS_TMP_FILE); 1926 if (system(buf) != 0) 1927 return; 1928 1929 snprintf(buf, sizeof(buf), 1930 "ifconfig %s | grep HWaddr | cut -b 39-56 >> %s", 1931 ifname, VI_QOS_TMP_FILE); 1932 if (system(buf) != 0) 1933 sigma_dut_print(dut, DUT_MSG_ERROR, "Retrieve HWaddr failed"); 1934 1935 snprintf(buf, sizeof(buf), "sed -n '3,$p' %s >> %s", 1936 VI_QOS_REFFILE, VI_QOS_TMP_FILE); 1937 if (system(buf) != 0) { 1938 sigma_dut_print(dut, DUT_MSG_ERROR, 1939 "Output redirection to VI_QOS_TMP_FILE failed"); 1940 } 1941 1942 snprintf(buf, sizeof(buf), "sed '5 c %x' %s > %s", 1943 tid_to_dscp[tid], VI_QOS_TMP_FILE, VI_QOS_FILE); 1944 if (system(buf) != 0) { 1945 sigma_dut_print(dut, DUT_MSG_ERROR, 1946 "Append TID to VI_QOS_FILE failed "); 1947 } 1948 1949 snprintf(buf, sizeof(buf), "ethinject %s %s", ifname, VI_QOS_FILE); 1950 if (system(buf) != 0) 1951 sigma_dut_print(dut, DUT_MSG_ERROR, "Ethinject frame failed"); 1952 } 1953 1954 1955 static int ath_ap_send_addba_req(struct sigma_dut *dut, struct sigma_conn *conn, 1956 struct sigma_cmd *cmd) 1957 { 1958 const char *val; 1959 const char *ifname; 1960 char buf[256]; 1961 int tid = 0; 1962 1963 ifname = get_main_ifname(dut); 1964 val = get_param(cmd, "TID"); 1965 if (val) { 1966 tid = atoi(val); 1967 if (tid) 1968 ath_inject_frame(dut, ifname, tid); 1969 } 1970 1971 /* NOTE: This is the command sequence on Peregrine for ADDBA */ 1972 run_iwpriv(dut, ifname, "setaddbaoper 1"); 1973 1974 snprintf(buf, sizeof(buf), "wifitool %s senddelba 1 %d 1 4", 1975 ifname, tid); 1976 if (system(buf) != 0) { 1977 sigma_dut_print(dut, DUT_MSG_ERROR, 1978 "wifitool senddelba failed"); 1979 } 1980 1981 snprintf(buf, sizeof(buf), "wifitool %s sendaddba 1 %d 64", 1982 ifname, tid); 1983 if (system(buf) != 0) { 1984 sigma_dut_print(dut, DUT_MSG_ERROR, 1985 "wifitool sendaddba failed"); 1986 } 1987 1988 return 1; 1989 } 1990 1991 1992 static int ath10k_debug_enable_addba_req(struct sigma_dut *dut, int tid, 1993 const char *sta_mac, 1994 const char *dir_path) 1995 { 1996 DIR *dir; 1997 struct dirent *entry; 1998 char buf[128], path[128]; 1999 int ret = 0, res; 2000 2001 dir = opendir(dir_path); 2002 if (!dir) 2003 return 0; 2004 2005 while ((entry = readdir(dir))) { 2006 ret = 1; 2007 2008 if (strcmp(entry->d_name, ".") == 0 || 2009 strcmp(entry->d_name, "..") == 0) 2010 continue; 2011 2012 res = snprintf(path, sizeof(path) - 1, "%s/%s", 2013 dir_path, entry->d_name); 2014 if (res < 0 || res >= sizeof(path)) 2015 continue; 2016 2017 if (strcmp(entry->d_name, sta_mac) == 0) { 2018 res = snprintf(buf, sizeof(buf), 2019 "echo 1 > %s/aggr_mode", path); 2020 if (res < 0 || res >= sizeof(buf) || system(buf) != 0) { 2021 sigma_dut_print(dut, DUT_MSG_ERROR, 2022 "Failed to set aggr mode for ath10k"); 2023 } 2024 2025 res = snprintf(buf, sizeof(buf), 2026 "echo %d 32 > %s/addba", tid, path); 2027 if (res < 0 || res >= sizeof(buf) || system(buf) != 0) { 2028 sigma_dut_print(dut, DUT_MSG_ERROR, 2029 "Failed to set addbareq for ath10k"); 2030 } 2031 2032 break; 2033 } 2034 2035 /* Recursively search subdirectories */ 2036 ath10k_debug_enable_addba_req(dut, tid, sta_mac, path); 2037 } 2038 2039 closedir(dir); 2040 2041 return ret; 2042 } 2043 2044 2045 static int ath10k_ap_send_addba_req(struct sigma_dut *dut, 2046 struct sigma_cmd *cmd) 2047 { 2048 const char *val; 2049 int tid = 0; 2050 2051 val = get_param(cmd, "TID"); 2052 if (val) 2053 tid = atoi(val); 2054 2055 val = get_param(cmd, "sta_mac_address"); 2056 if (!val) { 2057 sigma_dut_print(dut, DUT_MSG_ERROR, 2058 "Failed to parse station MAC address"); 2059 return 0; 2060 } 2061 2062 return ath10k_debug_enable_addba_req(dut, tid, val, 2063 "/sys/kernel/debug/ieee80211"); 2064 } 2065 2066 2067 static enum sigma_cmd_result cmd_ap_send_addba_req(struct sigma_dut *dut, 2068 struct sigma_conn *conn, 2069 struct sigma_cmd *cmd) 2070 { 2071 /* const char *name = get_param(cmd, "NAME"); */ 2072 /* const char *ifname = get_param(cmd, "INTERFACE"); */ 2073 struct stat s; 2074 2075 switch (get_driver_type(dut)) { 2076 case DRIVER_ATHEROS: 2077 return ath_ap_send_addba_req(dut, conn, cmd); 2078 #ifdef __linux__ 2079 case DRIVER_WIL6210: 2080 return send_addba_60g(dut, conn, cmd, "sta_mac_address"); 2081 #endif /* __linux__ */ 2082 case DRIVER_OPENWRT: 2083 switch (get_openwrt_driver_type()) { 2084 case OPENWRT_DRIVER_ATHEROS: 2085 return ath_ap_send_addba_req(dut, conn, cmd); 2086 default: 2087 send_resp(dut, conn, SIGMA_ERROR, 2088 "errorCode,ap_send_addba_req not supported with this driver"); 2089 return 0; 2090 } 2091 case DRIVER_WCN: 2092 case DRIVER_LINUX_WCN: 2093 /* AP automatically sends ADDBA request after association. */ 2094 sigma_dut_print(dut, DUT_MSG_INFO, 2095 "ap_send_addba_req command ignored"); 2096 return 1; 2097 case DRIVER_MAC80211: 2098 if (stat("/sys/module/ath10k_core", &s) == 0) 2099 return ath10k_ap_send_addba_req(dut, cmd); 2100 /* fall through */ 2101 default: 2102 send_resp(dut, conn, SIGMA_ERROR, 2103 "errorCode,ap_send_addba_req not supported with this driver"); 2104 return 0; 2105 } 2106 } 2107 2108 2109 static const char * get_sae_pk_key(const char *file_name) 2110 { 2111 if (strcasecmp(file_name, "saepk1.pem") == 0) 2112 return SAE_PK_KEY_1; 2113 if (strcasecmp(file_name, "saepk2.pem") == 0) 2114 return SAE_PK_KEY_2; 2115 if (strcasecmp(file_name, "saepkP256.pem") == 0) 2116 return SAE_PK_KEY_P256; 2117 if (strcasecmp(file_name, "saepkP384.pem") == 0) 2118 return SAE_PK_KEY_P384; 2119 if (strcasecmp(file_name, "saepkP521.pem") == 0) 2120 return SAE_PK_KEY_P521; 2121 return NULL; 2122 } 2123 2124 2125 static enum sigma_cmd_result cmd_ap_set_security(struct sigma_dut *dut, 2126 struct sigma_conn *conn, 2127 struct sigma_cmd *cmd) 2128 { 2129 /* const char *name = get_param(cmd, "NAME"); */ 2130 const char *val; 2131 unsigned int wlan_tag = 1; 2132 const char *security; 2133 2134 val = get_param(cmd, "WLAN_TAG"); 2135 if (val) 2136 wlan_tag = atoi(val); 2137 2138 security = get_param(cmd, "Security"); 2139 2140 if (wlan_tag > 1) { 2141 val = get_param(cmd, "KEYMGNT"); 2142 if (!val) 2143 val = get_param(cmd, "KeyMgmtType"); 2144 if (val) { 2145 if (strcasecmp(val, "NONE") == 0) { 2146 dut->ap_tag_key_mgmt[wlan_tag - 2] = AP2_OPEN; 2147 } else if (strcasecmp(val, "OSEN") == 0 && 2148 wlan_tag == 2) { 2149 /* 2150 * OSEN only supported on WLAN_TAG = 2 for now 2151 */ 2152 dut->ap_tag_key_mgmt[wlan_tag - 2] = AP2_OSEN; 2153 } else if (strcasecmp(val, "WPA2-PSK") == 0 || 2154 (security && 2155 strcasecmp(security, "PSK") == 0 && 2156 strcasecmp(val, "WPA2") == 0)) { 2157 dut->ap_tag_key_mgmt[wlan_tag - 2] = 2158 AP2_WPA2_PSK; 2159 } else if (strcasecmp(val, "OWE") == 0 && 2160 wlan_tag == 2) { 2161 dut->ap_tag_key_mgmt[wlan_tag - 2] = 2162 AP2_WPA2_OWE; 2163 } else { 2164 send_resp(dut, conn, SIGMA_INVALID, 2165 "errorCode,Unsupported KEYMGNT"); 2166 return 0; 2167 } 2168 return 1; 2169 } 2170 } 2171 2172 val = get_param(cmd, "KEYMGNT"); 2173 if (!val) 2174 val = get_param(cmd,"KeyMgmtType"); 2175 if (val) { 2176 if (strcasecmp(val, "WPA2-PSK") == 0 || 2177 (security && strcasecmp(security, "PSK") == 0 && 2178 strcasecmp(val, "WPA2") == 0)) { 2179 dut->ap_key_mgmt = AP_WPA2_PSK; 2180 dut->ap_cipher = AP_CCMP; 2181 } else if (strcasecmp(val, "WPA2-EAP") == 0 || 2182 strcasecmp(val, "WPA2-Ent") == 0) { 2183 dut->ap_key_mgmt = AP_WPA2_EAP; 2184 dut->ap_cipher = AP_CCMP; 2185 } else if (strcasecmp(val, "SuiteB") == 0) { 2186 dut->ap_key_mgmt = AP_SUITEB; 2187 dut->ap_cipher = AP_GCMP_256; 2188 dut->ap_pmf = AP_PMF_REQUIRED; 2189 } else if (strcasecmp(val, "WPA-PSK") == 0) { 2190 dut->ap_key_mgmt = AP_WPA_PSK; 2191 dut->ap_cipher = AP_TKIP; 2192 } else if (strcasecmp(val, "WPA-EAP") == 0 || 2193 strcasecmp(val, "WPA-Ent") == 0) { 2194 dut->ap_key_mgmt = AP_WPA_EAP; 2195 dut->ap_cipher = AP_TKIP; 2196 } else if (strcasecmp(val, "WPA2-Mixed") == 0) { 2197 dut->ap_key_mgmt = AP_WPA2_EAP_MIXED; 2198 dut->ap_cipher = AP_CCMP_TKIP; 2199 } else if (strcasecmp(val, "WPA2-PSK-Mixed") == 0) { 2200 dut->ap_key_mgmt = AP_WPA2_PSK_MIXED; 2201 dut->ap_cipher = AP_CCMP_TKIP; 2202 } else if (strcasecmp(val, "WPA2-SAE") == 0 || 2203 strcasecmp(val, "SAE") == 0) { 2204 dut->ap_key_mgmt = AP_WPA2_SAE; 2205 dut->ap_cipher = AP_CCMP; 2206 dut->ap_pmf = AP_PMF_REQUIRED; 2207 } else if (strcasecmp(val, "WPA2-PSK-SAE") == 0) { 2208 dut->ap_key_mgmt = AP_WPA2_PSK_SAE; 2209 dut->ap_cipher = AP_CCMP; 2210 dut->ap_pmf = AP_PMF_OPTIONAL; 2211 } else if (strcasecmp(val, "OWE") == 0) { 2212 dut->ap_key_mgmt = AP_WPA2_OWE; 2213 dut->ap_cipher = AP_CCMP; 2214 dut->ap_pmf = AP_PMF_REQUIRED; 2215 } else if (strcasecmp(val, "WPA2-ENT-OSEN") == 0) { 2216 dut->ap_key_mgmt = AP_WPA2_EAP_OSEN; 2217 dut->ap_cipher = AP_CCMP; 2218 dut->ap_pmf = AP_PMF_OPTIONAL; 2219 } else if (strcasecmp(val, "OSEN") == 0) { 2220 dut->ap_key_mgmt = AP_OSEN; 2221 dut->ap_cipher = AP_CCMP; 2222 } else if (strcasecmp(val, "FT-EAP") == 0) { 2223 dut->ap_key_mgmt = AP_WPA2_FT_EAP; 2224 dut->ap_cipher = AP_CCMP; 2225 dut->ap_pmf = AP_PMF_OPTIONAL; 2226 } else if (strcasecmp(val, "FT-PSK") == 0) { 2227 dut->ap_key_mgmt = AP_WPA2_FT_PSK; 2228 dut->ap_cipher = AP_CCMP; 2229 dut->ap_pmf = AP_PMF_OPTIONAL; 2230 } else if (strcasecmp(val, "WPA2-ENT-256") == 0) { 2231 dut->ap_key_mgmt = AP_WPA2_EAP_SHA256; 2232 dut->ap_cipher = AP_CCMP; 2233 dut->ap_pmf = AP_PMF_OPTIONAL; 2234 } else if (strcasecmp(val, "WPA2-PSK-256") == 0) { 2235 dut->ap_key_mgmt = AP_WPA2_PSK_SHA256; 2236 dut->ap_cipher = AP_CCMP; 2237 dut->ap_pmf = AP_PMF_OPTIONAL; 2238 } else if (strcasecmp(val, "WPA2-ENT-FT-EAP") == 0) { 2239 dut->ap_key_mgmt = AP_WPA2_ENT_FT_EAP; 2240 dut->ap_cipher = AP_CCMP; 2241 dut->ap_pmf = AP_PMF_OPTIONAL; 2242 } else if (strcasecmp(val, "NONE") == 0) { 2243 dut->ap_key_mgmt = AP_OPEN; 2244 dut->ap_cipher = AP_PLAIN; 2245 } else { 2246 send_resp(dut, conn, SIGMA_INVALID, 2247 "errorCode,Unsupported KEYMGNT"); 2248 return 0; 2249 } 2250 } 2251 2252 val = get_param(cmd, "ECGroupID"); 2253 if (val) { 2254 free(dut->ap_sae_groups); 2255 dut->ap_sae_groups = strdup(val); 2256 } 2257 2258 val = get_param(cmd, "AntiCloggingThreshold"); 2259 if (val) 2260 dut->sae_anti_clogging_threshold = atoi(val); 2261 2262 val = get_param(cmd, "Reflection"); 2263 if (val) 2264 dut->sae_reflection = strcasecmp(val, "SAE") == 0; 2265 2266 val = get_param(cmd, "InvalidSAEElement"); 2267 if (val) { 2268 free(dut->sae_commit_override); 2269 dut->sae_commit_override = strdup(val); 2270 } 2271 2272 val = get_param(cmd, "SAEPasswords"); 2273 if (val) { 2274 free(dut->ap_sae_passwords); 2275 dut->ap_sae_passwords = strdup(val); 2276 } 2277 2278 val = get_param(cmd, "SAE_Commit_StatusCode"); 2279 if (val) 2280 dut->ap_sae_commit_status = atoi(val); 2281 2282 val = get_param(cmd, "SAE_PK_Omit"); 2283 if (val) 2284 dut->ap_sae_pk_omit = get_enable_disable(val); 2285 2286 val = get_param(cmd, "SAE_Confirm_Immediate"); 2287 if (val) 2288 dut->sae_confirm_immediate = get_enable_disable(val); 2289 2290 val = get_param(cmd, "sae_pwe"); 2291 if (val) { 2292 if (strcasecmp(val, "h2e") == 0) { 2293 dut->sae_pwe = SAE_PWE_H2E; 2294 } else if (strcasecmp(val, "loop") == 0 || 2295 strcasecmp(val, "looping") == 0) { 2296 dut->sae_pwe = SAE_PWE_LOOP; 2297 } else { 2298 send_resp(dut, conn, SIGMA_ERROR, 2299 "errorCode,Unsupported sae_pwe value"); 2300 return STATUS_SENT_ERROR; 2301 } 2302 } 2303 2304 val = get_param(cmd, "sae_pk"); 2305 if (val) 2306 dut->ap_sae_pk = atoi(val); 2307 2308 val = get_param(cmd, "SAE_PK_KeyPair"); 2309 if (!val) 2310 val = get_param(cmd, "SAE_PK_KeyPairMism"); 2311 if (val) { 2312 free(dut->ap_sae_pk_keypair); 2313 dut->ap_sae_pk_keypair = NULL; 2314 2315 val = get_sae_pk_key(val); 2316 if (val) 2317 dut->ap_sae_pk_keypair = strdup(val); 2318 2319 if (!dut->ap_sae_pk_keypair) { 2320 send_resp(dut, conn, SIGMA_ERROR, 2321 "errorCode,Unknown SAE_PK_KeyPair value"); 2322 return STATUS_SENT_ERROR; 2323 } 2324 } 2325 2326 val = get_param(cmd, "SAE_PK_KeyPairSigOverride"); 2327 if (val) { 2328 free(dut->ap_sae_pk_keypair_sig); 2329 dut->ap_sae_pk_keypair_sig = NULL; 2330 2331 val = get_sae_pk_key(val); 2332 if (val) 2333 dut->ap_sae_pk_keypair_sig = strdup(val); 2334 2335 if (!dut->ap_sae_pk_keypair_sig) { 2336 send_resp(dut, conn, SIGMA_ERROR, 2337 "errorCode,Unknown SAE_PK_KeyPairSigOverride value"); 2338 return STATUS_SENT_ERROR; 2339 } 2340 } 2341 2342 val = get_param(cmd, "SAE_PK_Modifier"); 2343 if (!val) 2344 val = get_param(cmd, "SAE_PK_ModifierMism"); 2345 if (val) { 2346 free(dut->ap_sae_pk_modifier); 2347 dut->ap_sae_pk_modifier = strdup(val); 2348 } 2349 2350 val = get_param(cmd, "RSNXE_Content"); 2351 if (val) { 2352 if (strncasecmp(val, "EapolM3:", 8) != 0) { 2353 send_resp(dut, conn, SIGMA_ERROR, 2354 "errorCode,Unsupported RSNXE_Content value"); 2355 return STATUS_SENT_ERROR; 2356 } 2357 val += 8; 2358 free(dut->rsnxe_override_eapol); 2359 dut->rsnxe_override_eapol = strdup(val); 2360 } 2361 2362 val = get_param(cmd, "ENCRYPT"); 2363 if (!val) 2364 val = get_param(cmd, "EncpType"); 2365 if (val) { 2366 if (strcasecmp(val, "WEP") == 0) { 2367 dut->ap_cipher = AP_WEP; 2368 } else if (strcasecmp(val, "TKIP") == 0) { 2369 dut->ap_cipher = AP_TKIP; 2370 } else if (strcasecmp(val, "AES") == 0 || 2371 strcasecmp(val, "AES-CCMP") == 0) { 2372 dut->ap_cipher = AP_CCMP; 2373 } else if (strcasecmp(val, "AES-GCMP") == 0) { 2374 dut->ap_cipher = AP_GCMP_128; 2375 } else { 2376 send_resp(dut, conn, SIGMA_INVALID, 2377 "errorCode,Unsupported ENCRYPT"); 2378 return 0; 2379 } 2380 } 2381 2382 val = get_param(cmd, "PairwiseCipher"); 2383 if (val) { 2384 if (strcasecmp(val, "AES-GCMP-256") == 0) { 2385 dut->ap_cipher = AP_GCMP_256; 2386 } else if (strcasecmp(val, "AES-CCMP-256") == 0) { 2387 dut->ap_cipher = AP_CCMP_256; 2388 } else if (strcasecmp(val, "AES-GCMP-128") == 0) { 2389 dut->ap_cipher = AP_GCMP_128; 2390 } else if (strcasecmp(val, "AES-CCMP-128") == 0) { 2391 dut->ap_cipher = AP_CCMP; 2392 } else if (strcasecmp(val, "AES-CCMP-128 AES-GCMP-256") == 0 || 2393 strcasecmp(val, "AES-GCMP-256 AES-CCMP-128") == 0) { 2394 dut->ap_cipher = AP_CCMP_128_GCMP_256; 2395 } else { 2396 send_resp(dut, conn, SIGMA_INVALID, 2397 "errorCode,Unsupported PairwiseCipher"); 2398 return 0; 2399 } 2400 } 2401 2402 val = get_param(cmd, "GroupCipher"); 2403 if (val) { 2404 if (strcasecmp(val, "AES-GCMP-256") == 0) { 2405 dut->ap_group_cipher = AP_GCMP_256; 2406 } else if (strcasecmp(val, "AES-CCMP-256") == 0) { 2407 dut->ap_group_cipher = AP_CCMP_256; 2408 } else if (strcasecmp(val, "AES-GCMP-128") == 0) { 2409 dut->ap_group_cipher = AP_GCMP_128; 2410 } else if (strcasecmp(val, "AES-CCMP-128") == 0) { 2411 dut->ap_group_cipher = AP_CCMP; 2412 } else { 2413 send_resp(dut, conn, SIGMA_INVALID, 2414 "errorCode,Unsupported GroupCipher"); 2415 return 0; 2416 } 2417 } 2418 2419 val = get_param(cmd, "GroupMgntCipher"); 2420 if (val) { 2421 if (strcasecmp(val, "BIP-GMAC-256") == 0) { 2422 dut->ap_group_mgmt_cipher = AP_BIP_GMAC_256; 2423 } else if (strcasecmp(val, "BIP-CMAC-256") == 0) { 2424 dut->ap_group_mgmt_cipher = AP_BIP_CMAC_256; 2425 } else if (strcasecmp(val, "BIP-GMAC-128") == 0) { 2426 dut->ap_group_mgmt_cipher = AP_BIP_GMAC_128; 2427 } else if (strcasecmp(val, "BIP-CMAC-128") == 0) { 2428 dut->ap_group_mgmt_cipher = AP_BIP_CMAC_128; 2429 } else { 2430 send_resp(dut, conn, SIGMA_INVALID, 2431 "errorCode,Unsupported GroupMgntCipher"); 2432 return 0; 2433 } 2434 } 2435 2436 val = get_param(cmd, "WEPKEY"); 2437 if (val) { 2438 size_t len; 2439 if (dut->ap_cipher != AP_WEP) { 2440 send_resp(dut, conn, SIGMA_INVALID, 2441 "errorCode,Unexpected WEPKEY without WEP " 2442 "configuration"); 2443 return 0; 2444 } 2445 len = strlen(val); 2446 if (len != 10 && len != 26) { 2447 send_resp(dut, conn, SIGMA_INVALID, 2448 "errorCode,Unexpected WEPKEY length"); 2449 return 0; 2450 } 2451 snprintf(dut->ap_wepkey, sizeof(dut->ap_wepkey), "%s", val); 2452 } 2453 2454 val = get_param(cmd, "PSK"); 2455 if (!val) 2456 val = get_param(cmd, "passphrase"); 2457 if (val) { 2458 if (dut->ap_key_mgmt != AP_WPA2_SAE && 2459 (dut->ap_akm_values & (AKM_WPA_PSK | AKM_SAE)) != 2460 AKM_SAE && 2461 strlen(val) > 64) { 2462 sigma_dut_print(dut, DUT_MSG_ERROR, 2463 "Too long PSK/passphtase"); 2464 return -1; 2465 } 2466 if (strlen(val) > sizeof(dut->ap_passphrase) - 1) 2467 return -1; 2468 snprintf(dut->ap_passphrase, sizeof(dut->ap_passphrase), 2469 "%s", val); 2470 } 2471 2472 val = get_param(cmd, "PSKHEX"); 2473 if (val) { 2474 if (strlen(val) != 64) 2475 return -1; 2476 strlcpy(dut->ap_psk, val, sizeof(dut->ap_psk)); 2477 } 2478 2479 if (dut->program == PROGRAM_OCE && dut->dev_role == DEVROLE_STA_CFON) 2480 dut->ap_pmf = AP_PMF_OPTIONAL; 2481 2482 val = get_param(cmd, "PMF"); 2483 if (val) { 2484 if (strcasecmp(val, "Disabled") == 0) { 2485 dut->ap_pmf = AP_PMF_DISABLED; 2486 } else if (strcasecmp(val, "Optional") == 0) { 2487 dut->ap_pmf = AP_PMF_OPTIONAL; 2488 } else if (strcasecmp(val, "Required") == 0) { 2489 dut->ap_pmf = AP_PMF_REQUIRED; 2490 } else { 2491 send_resp(dut, conn, SIGMA_INVALID, 2492 "errorCode,Unsupported PMF"); 2493 return 0; 2494 } 2495 } 2496 2497 dut->ap_add_sha256 = 0; 2498 val = get_param(cmd, "SHA256AD"); 2499 if (val == NULL) 2500 val = get_param(cmd, "SHA256"); 2501 if (val) { 2502 if (strcasecmp(val, "Disabled") == 0) { 2503 } else if (strcasecmp(val, "Enabled") == 0) { 2504 dut->ap_add_sha256 = 1; 2505 } else { 2506 send_resp(dut, conn, SIGMA_INVALID, 2507 "errorCode,Unsupported SHA256"); 2508 return 0; 2509 } 2510 } 2511 2512 val = get_param(cmd, "PreAuthentication"); 2513 if (val) { 2514 if (strcasecmp(val, "disabled") == 0) { 2515 dut->ap_rsn_preauth = 0; 2516 } else if (strcasecmp(val, "enabled") == 0) { 2517 dut->ap_rsn_preauth = 1; 2518 } else { 2519 send_resp(dut, conn, SIGMA_INVALID, 2520 "errorCode,Unsupported PreAuthentication value"); 2521 return 0; 2522 } 2523 } 2524 2525 val = get_param(cmd, "AKMSuiteType"); 2526 if (val) { 2527 const char *in_pos = val; 2528 2529 dut->ap_akm_values = 0; 2530 while (*in_pos) { 2531 int akm = atoi(in_pos); 2532 2533 if (akm < 0 || akm >= 32) { 2534 send_resp(dut, conn, SIGMA_ERROR, 2535 "errorCode,Unsupported AKMSuiteType value"); 2536 return STATUS_SENT; 2537 } 2538 2539 dut->ap_akm_values |= 1 << akm; 2540 2541 in_pos = strchr(in_pos, ';'); 2542 if (!in_pos) 2543 break; 2544 while (*in_pos == ';') 2545 in_pos++; 2546 } 2547 dut->ap_akm = 1; 2548 if (dut->ap_akm_values & (1 << 14)) 2549 dut->ap_add_sha384 = 1; 2550 if (dut->ap_akm_values & (1 << 15)) 2551 dut->ap_add_sha384 = 1; 2552 } 2553 2554 if (dut->ap_key_mgmt == AP_OPEN && !dut->ap_akm_values) { 2555 dut->ap_hs2 = 0; 2556 dut->ap_pmf = AP_PMF_DISABLED; 2557 } 2558 2559 val = get_param(cmd, "PMKSACaching"); 2560 if (val) { 2561 dut->ap_pmksa = 1; 2562 if (strcasecmp(val, "disabled") == 0) { 2563 dut->ap_pmksa_caching = 1; 2564 } else if (strcasecmp(val, "enabled") == 0) { 2565 dut->ap_pmksa_caching = 0; 2566 } else { 2567 send_resp(dut, conn, SIGMA_INVALID, 2568 "errorCode,Unsupported PMKSACaching value"); 2569 return 0; 2570 } 2571 } 2572 2573 val = get_param(cmd, "BeaconProtection"); 2574 if (val) 2575 dut->ap_beacon_prot = atoi(val); 2576 2577 val = get_param(cmd, "Transition_Disable"); 2578 if (val) { 2579 if (atoi(val)) { 2580 val = get_param(cmd, "Transition_Disable_Index"); 2581 if (!val) { 2582 send_resp(dut, conn, SIGMA_INVALID, 2583 "errorCode,Transition_Disable without Transition_Disable_Index"); 2584 return STATUS_SENT; 2585 } 2586 dut->ap_transition_disable = 1 << atoi(val); 2587 } else { 2588 dut->ap_transition_disable = 0; 2589 } 2590 } 2591 2592 return 1; 2593 } 2594 2595 2596 int sta_cfon_set_wireless(struct sigma_dut *dut, struct sigma_conn *conn, 2597 struct sigma_cmd *cmd) 2598 { 2599 int status; 2600 2601 status = cmd_ap_set_wireless(dut, conn, cmd); 2602 if (status != 1) 2603 return status; 2604 status = cmd_ap_set_security(dut, conn, cmd); 2605 if (status != 1) 2606 return status; 2607 return cmd_ap_config_commit(dut, conn, cmd); 2608 } 2609 2610 2611 static enum sigma_cmd_result cmd_ap_set_radius(struct sigma_dut *dut, 2612 struct sigma_conn *conn, 2613 struct sigma_cmd *cmd) 2614 { 2615 /* const char *name = get_param(cmd, "NAME"); */ 2616 const char *val; 2617 unsigned int wlan_tag = 1, radius_port = 0; 2618 char *radius_ipaddr = NULL, *radius_password = NULL; 2619 2620 val = get_param(cmd, "WLAN_TAG"); 2621 if (val) { 2622 wlan_tag = atoi(val); 2623 if (wlan_tag != 1 && wlan_tag != 2) { 2624 send_resp(dut, conn, SIGMA_INVALID, 2625 "errorCode,Invalid WLAN_TAG"); 2626 return 0; 2627 } 2628 } 2629 2630 val = get_param(cmd, "PORT"); 2631 if (val) 2632 radius_port = atoi(val); 2633 2634 if (wlan_tag == 1) { 2635 if (radius_port) 2636 dut->ap_radius_port = radius_port; 2637 radius_ipaddr = dut->ap_radius_ipaddr; 2638 radius_password = dut->ap_radius_password; 2639 } else if (wlan_tag == 2) { 2640 if (radius_port) 2641 dut->ap2_radius_port = radius_port; 2642 radius_ipaddr = dut->ap2_radius_ipaddr; 2643 radius_password = dut->ap2_radius_password; 2644 } 2645 2646 val = get_param(cmd, "IPADDR"); 2647 if (val) { 2648 if (strlen(val) > sizeof(dut->ap_radius_ipaddr) - 1) 2649 return -1; 2650 snprintf(radius_ipaddr, sizeof(dut->ap_radius_ipaddr), 2651 "%s", val); 2652 } 2653 2654 val = get_param(cmd, "PASSWORD"); 2655 if (val) { 2656 if (strlen(val) > sizeof(dut->ap_radius_password) - 1) 2657 return -1; 2658 snprintf(radius_password, 2659 sizeof(dut->ap_radius_password), "%s", val); 2660 } 2661 2662 return 1; 2663 } 2664 2665 2666 static void owrt_ap_set_qcawifi(struct sigma_dut *dut, const char *key, 2667 const char *val) 2668 { 2669 if (!val) { 2670 run_system_wrapper(dut, "uci delete wireless.qcawifi.%s", key); 2671 return; 2672 } 2673 2674 run_system(dut, "uci set wireless.qcawifi=qcawifi"); 2675 run_system_wrapper(dut, "uci set wireless.qcawifi.%s=%s", key, val); 2676 } 2677 2678 2679 static void owrt_ap_set_radio(struct sigma_dut *dut, int id, 2680 const char *key, const char *val) 2681 { 2682 char buf[100]; 2683 2684 if (val == NULL) { 2685 snprintf(buf, sizeof(buf), 2686 "uci delete wireless.wifi%d.%s", id, key); 2687 run_system(dut, buf); 2688 return; 2689 } 2690 2691 snprintf(buf, sizeof(buf), "uci set wireless.wifi%d.%s=%s", 2692 id, key, val); 2693 run_system(dut, buf); 2694 } 2695 2696 2697 static void owrt_ap_set_list_radio(struct sigma_dut *dut, int id, 2698 const char *key, const char *val) 2699 { 2700 char buf[256]; 2701 2702 if (val == NULL) { 2703 snprintf(buf, sizeof(buf), 2704 "uci del_list wireless.wifi%d.%s", id, key); 2705 run_system(dut, buf); 2706 return; 2707 } 2708 2709 snprintf(buf, sizeof(buf), "uci add_list wireless.wifi%d.%s=%s", 2710 id, key, val); 2711 run_system(dut, buf); 2712 } 2713 2714 2715 static void owrt_ap_set_vap(struct sigma_dut *dut, int id, const char *key, 2716 const char *val) 2717 { 2718 char buf[256]; 2719 2720 if (val == NULL) { 2721 snprintf(buf, sizeof(buf), 2722 "uci delete wireless.@wifi-iface[%d].%s", id, key); 2723 run_system(dut, buf); 2724 return; 2725 } 2726 2727 snprintf(buf, sizeof(buf), "uci set wireless.@wifi-iface[%d].%s=%s", 2728 id, key, val); 2729 run_system(dut, buf); 2730 } 2731 2732 2733 static void owrt_ap_set_list_vap(struct sigma_dut *dut, int id, 2734 const char *key, const char *val) 2735 { 2736 char buf[1024]; 2737 2738 if (val == NULL) { 2739 snprintf(buf, sizeof(buf), 2740 "uci del_list wireless.@wifi-iface[%d].%s", id, key); 2741 run_system(dut, buf); 2742 return; 2743 } 2744 2745 snprintf(buf, sizeof(buf), 2746 "uci add_list wireless.@wifi-iface[%d].%s=%s", 2747 id, key, val); 2748 run_system(dut, buf); 2749 } 2750 2751 2752 static void owrt_ap_add_vap(struct sigma_dut *dut, int id, const char *key, 2753 const char *val) 2754 { 2755 char buf[256]; 2756 int res; 2757 2758 if (val == NULL) { 2759 res = snprintf(buf, sizeof(buf), 2760 "uci delete wireless.@wifi-iface[%d].%s", 2761 id, key); 2762 if (res >= 0 && res < sizeof(buf)) 2763 run_system(dut, buf); 2764 return; 2765 } 2766 2767 run_system(dut, "uci add wireless wifi-iface"); 2768 res = snprintf(buf, sizeof(buf), 2769 "uci set wireless.@wifi-iface[%d].%s=%s", 2770 id, key, val); 2771 if (res >= 0 && res < sizeof(buf)) 2772 run_system(dut, buf); 2773 snprintf(buf, sizeof(buf), "uci set wireless.@wifi-iface[%d].%s=%s", 2774 id, "network", "lan"); 2775 run_system(dut, buf); 2776 snprintf(buf, sizeof(buf), "uci set wireless.@wifi-iface[%d].%s=%s", 2777 id, "mode", "ap"); 2778 run_system(dut, buf); 2779 snprintf(buf, sizeof(buf), "uci set wireless.@wifi-iface[%d].%s=%s", 2780 id, "encryption", "none"); 2781 run_system(dut, buf); 2782 } 2783 2784 2785 #define OPENWRT_MAX_NUM_RADIOS (MAX_RADIO + 1) 2786 static int owrt_ap_config_radio(struct sigma_dut *dut) 2787 { 2788 int radio_id[MAX_RADIO] = { 0, 1, 2 }; 2789 int radio_count, radio_no; 2790 char buf[64]; 2791 2792 for (radio_count = 0; radio_count < OPENWRT_MAX_NUM_RADIOS; 2793 radio_count++) { 2794 snprintf(buf, sizeof(buf), "%s%d", "wifi", radio_count); 2795 for (radio_no = 0; radio_no < MAX_RADIO; radio_no++) { 2796 if (!sigma_radio_ifname[radio_no] || 2797 strcmp(sigma_radio_ifname[radio_no], buf) != 0) 2798 continue; 2799 owrt_ap_set_radio(dut, radio_count, "disabled", "0"); 2800 owrt_ap_set_vap(dut, radio_count, "device", buf); 2801 radio_id[radio_no] = radio_count; 2802 } 2803 } 2804 2805 /* Hardware mode (11a/b/g/n/ac) & HT mode selection */ 2806 switch (dut->ap_mode) { 2807 case AP_11g: 2808 owrt_ap_set_radio(dut, radio_id[0], "hwmode", "11g"); 2809 break; 2810 case AP_11b: 2811 owrt_ap_set_radio(dut, radio_id[0], "hwmode", "11b"); 2812 break; 2813 case AP_11ng: 2814 owrt_ap_set_radio(dut, radio_id[0], "hwmode", "11ng"); 2815 owrt_ap_set_radio(dut, radio_id[0], "htmode", "HT20"); 2816 break; 2817 case AP_11a: 2818 owrt_ap_set_radio(dut, radio_id[0], "hwmode", "11a"); 2819 break; 2820 case AP_11na: 2821 owrt_ap_set_radio(dut, radio_id[0], "hwmode", "11na"); 2822 owrt_ap_set_radio(dut, radio_id[0], "htmode", "HT20"); 2823 break; 2824 case AP_11ac: 2825 owrt_ap_set_radio(dut, radio_id[0], "hwmode", "11ac"); 2826 owrt_ap_set_radio(dut, radio_id[0], "htmode", "HT80"); 2827 break; 2828 case AP_11ax: 2829 if (dut->ap_channel >= 36) { 2830 owrt_ap_set_radio(dut, radio_id[0], "hwmode", "11axa"); 2831 owrt_ap_set_radio(dut, radio_id[0], "htmode", "HT80"); 2832 } else { 2833 owrt_ap_set_radio(dut, radio_id[0], "hwmode", "11axg"); 2834 owrt_ap_set_radio(dut, radio_id[0], "htmode", "HT20"); 2835 } 2836 break; 2837 case AP_inval: 2838 sigma_dut_print(dut, DUT_MSG_ERROR, 2839 "MODE NOT SPECIFIED!"); 2840 return -1; 2841 default: 2842 owrt_ap_set_radio(dut, radio_id[0], "hwmode", "11ng"); 2843 owrt_ap_set_radio(dut, radio_id[0], "htmode", "HT20"); 2844 break; 2845 } 2846 2847 if (dut->ap_is_dual) { 2848 /* Hardware mode (11a/b/g/n/ac) & HT mode selection */ 2849 switch (dut->ap_mode_1) { 2850 case AP_11g: 2851 owrt_ap_set_radio(dut, radio_id[1], "hwmode", "11g"); 2852 break; 2853 case AP_11b: 2854 owrt_ap_set_radio(dut, radio_id[1], "hwmode", "11b"); 2855 break; 2856 case AP_11ng: 2857 owrt_ap_set_radio(dut, radio_id[1], "hwmode", "11ng"); 2858 owrt_ap_set_radio(dut, radio_id[1], "htmode", "HT20"); 2859 break; 2860 case AP_11a: 2861 owrt_ap_set_radio(dut, radio_id[1], "hwmode", "11a"); 2862 break; 2863 case AP_11na: 2864 owrt_ap_set_radio(dut, radio_id[1], "hwmode", "11na"); 2865 owrt_ap_set_radio(dut, radio_id[1], "htmode", "HT20"); 2866 break; 2867 case AP_11ac: 2868 owrt_ap_set_radio(dut, radio_id[1], "hwmode", "11ac"); 2869 owrt_ap_set_radio(dut, radio_id[1], "htmode", "HT80"); 2870 break; 2871 case AP_11ax: 2872 if (dut->ap_channel >= 36) { 2873 owrt_ap_set_radio(dut, radio_id[1], 2874 "hwmode", "11axa"); 2875 owrt_ap_set_radio(dut, radio_id[1], 2876 "htmode", "HT80"); 2877 } else { 2878 owrt_ap_set_radio(dut, radio_id[1], 2879 "hwmode", "11axg"); 2880 owrt_ap_set_radio(dut, radio_id[1], 2881 "htmode", "HT20"); 2882 } 2883 break; 2884 case AP_inval: 2885 sigma_dut_print(dut, DUT_MSG_ERROR, 2886 "MODE NOT SPECIFIED!"); 2887 return -1; 2888 default: 2889 owrt_ap_set_radio(dut, radio_id[1], "hwmode", "11ng"); 2890 owrt_ap_set_radio(dut, radio_id[1], "htmode", "HT20"); 2891 break; 2892 } 2893 2894 } 2895 2896 /* Channel */ 2897 snprintf(buf, sizeof(buf), "%d", dut->ap_channel); 2898 owrt_ap_set_radio(dut, radio_id[0], "channel", buf); 2899 2900 switch (dut->ap_chwidth) { 2901 case AP_20: 2902 owrt_ap_set_radio(dut, radio_id[0], "htmode", "HT20"); 2903 break; 2904 case AP_40: 2905 owrt_ap_set_radio(dut, radio_id[0], "htmode", "HT40"); 2906 break; 2907 case AP_80: 2908 owrt_ap_set_radio(dut, radio_id[0], "htmode", "HT80"); 2909 break; 2910 case AP_160: 2911 owrt_ap_set_radio(dut, radio_id[0], "htmode", "HT160"); 2912 break; 2913 case AP_80_80: 2914 owrt_ap_set_radio(dut, radio_id[0], "htmode", "HT80_80"); 2915 break; 2916 case AP_AUTO: 2917 default: 2918 break; 2919 } 2920 2921 if (dut->ap_channel == 140 || dut->ap_channel == 144) { 2922 if (get_openwrt_driver_type() == OPENWRT_DRIVER_ATHEROS) 2923 owrt_ap_set_radio(dut, radio_id[0], "set_ch_144", "3"); 2924 } 2925 2926 if (dut->ap_is_dual) { 2927 snprintf(buf, sizeof(buf), "%d", dut->ap_channel_1); 2928 owrt_ap_set_radio(dut, radio_id[1], "channel", buf); 2929 } 2930 2931 /* Country Code */ 2932 if (dut->ap_reg_domain == REG_DOMAIN_GLOBAL) { 2933 const char *country; 2934 2935 country = dut->ap_countrycode[0] ? dut->ap_countrycode : "US"; 2936 snprintf(buf, sizeof(buf), "%s4", country); 2937 owrt_ap_set_radio(dut, radio_id[0], "country", buf); 2938 if (dut->ap_is_dual) 2939 owrt_ap_set_radio(dut, radio_id[1], "country", buf); 2940 } else if (dut->ap_countrycode[0]) { 2941 owrt_ap_set_radio(dut, radio_id[0], "country", 2942 dut->ap_countrycode); 2943 } 2944 2945 if (dut->ap_disable_protection == 1) { 2946 owrt_ap_set_list_radio(dut, radio_id[0], "aggr_burst", "'0 0'"); 2947 owrt_ap_set_list_radio(dut, radio_id[0], "aggr_burst", "'1 0'"); 2948 owrt_ap_set_list_radio(dut, radio_id[0], "aggr_burst", "'2 0'"); 2949 owrt_ap_set_list_radio(dut, radio_id[0], "aggr_burst", "'3 0'"); 2950 } 2951 2952 if (dut->ap_oce == VALUE_ENABLED && 2953 get_driver_type(dut) == DRIVER_OPENWRT) 2954 owrt_ap_set_radio(dut, radio_id[0], "bcnburst", "1"); 2955 2956 if (dut->ap_mbssid == VALUE_ENABLED) 2957 owrt_ap_set_qcawifi(dut, "mbss_ie_enable", "1"); 2958 2959 if (dut->program == PROGRAM_HE) { 2960 owrt_ap_set_radio(dut, radio_id[0], "he_bsscolor", "'1 1'"); 2961 if (dut->ap_is_dual) 2962 owrt_ap_set_radio(dut, radio_id[1], "he_bsscolor", 2963 "'2 1'"); 2964 owrt_ap_set_qcawifi(dut, "ap_bss_color_collision_detection", 2965 "1"); 2966 } 2967 2968 return 1; 2969 } 2970 2971 2972 static int owrt_ap_config_vap_hs2(struct sigma_dut *dut, int vap_id) 2973 { 2974 char buf[256]; 2975 2976 snprintf(buf, sizeof(buf), "%d", dut->ap_hs2); 2977 owrt_ap_set_vap(dut, vap_id, "hs20", buf); 2978 owrt_ap_set_vap(dut, vap_id, "qbssload", "1"); 2979 owrt_ap_set_vap(dut, vap_id, "hs20_deauth_req_timeout","3"); 2980 2981 owrt_ap_set_list_vap(dut, vap_id, "hs20_oper_friendly_name", 2982 "'eng:Wi-Fi Alliance'"); 2983 2984 owrt_ap_set_list_vap(dut, vap_id, "hs20_oper_friendly_name", 2985 "'chi:Wi-Fi\xe8\x81\x94\xe7\x9b\x9f'"); 2986 2987 if (dut->ap_wan_metrics == 1) 2988 owrt_ap_set_vap(dut, vap_id, "hs20_wan_metrics", 2989 "'01:2500:384:0:0:10'"); 2990 else if (dut->ap_wan_metrics == 1) 2991 owrt_ap_set_vap(dut, vap_id, "hs20_wan_metrics", 2992 "'01:1500:384:20:20:10'"); 2993 else if (dut->ap_wan_metrics == 2) 2994 owrt_ap_set_vap(dut, vap_id, "hs20_wan_metrics", 2995 "'01:1500:384:20:20:10'"); 2996 else if (dut->ap_wan_metrics == 3) 2997 owrt_ap_set_vap(dut, vap_id, "hs20_wan_metrics", 2998 "'01:2000:1000:20:20:10'"); 2999 else if (dut->ap_wan_metrics == 4) 3000 owrt_ap_set_vap(dut, vap_id, "hs20_wan_metrics", 3001 "'01:8000:1000:20:20:10'"); 3002 else if (dut->ap_wan_metrics == 5) 3003 owrt_ap_set_vap(dut, vap_id, "hs20_wan_metrics", 3004 "'01:9000:5000:20:20:10'"); 3005 3006 if (dut->ap_conn_capab == 1) { 3007 owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", "'1:0:0'"); 3008 owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", 3009 "'6:20:1'"); 3010 owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", 3011 "'6:22:0'"); 3012 owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", 3013 "'6:80:1'"); 3014 owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", 3015 "'6:443:1'"); 3016 owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", 3017 "'6:1723:0'"); 3018 owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", 3019 "'6:5060:0'"); 3020 owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", 3021 "'17:500:1'"); 3022 owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", 3023 "'17:5060:0'"); 3024 owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", 3025 "'17:4500:1'"); 3026 owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", 3027 "'50:0:1'"); 3028 } else if (dut->ap_conn_capab == 2) { 3029 owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", 3030 "'6:80:1'"); 3031 owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", 3032 "'6:443:1'"); 3033 owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", 3034 "'17:5060:1'"); 3035 owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", 3036 "'6:5060:1'"); 3037 } else if (dut->ap_conn_capab == 3) { 3038 owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", 3039 "'6:80:1'"); 3040 owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", 3041 "'6:443:1'"); 3042 } 3043 3044 if (dut->ap_oper_class == 1) 3045 snprintf(buf, sizeof(buf), "%s", "51"); 3046 else if (dut->ap_oper_class == 2) 3047 snprintf(buf, sizeof(buf), "%s", "73"); 3048 else if (dut->ap_oper_class == 3) 3049 snprintf(buf, sizeof(buf), "%s", "5173"); 3050 3051 if (dut->ap_oper_class) 3052 owrt_ap_set_vap(dut, vap_id, "hs20_operating_class", buf); 3053 3054 if (dut->ap_osu_provider_list) { 3055 char *osu_friendly_name = NULL; 3056 char *osu_icon = NULL; 3057 char *osu_ssid = NULL; 3058 char *osu_nai = NULL; 3059 char *osu_service_desc = NULL; 3060 char *hs20_icon_filename = NULL; 3061 char hs20_icon[150]; 3062 int osu_method; 3063 3064 hs20_icon_filename = "icon_red_zxx.png"; 3065 if (dut->ap_osu_icon_tag == 2) 3066 hs20_icon_filename = "wifi-abgn-logo_270x73.png"; 3067 snprintf(hs20_icon, sizeof(hs20_icon), 3068 "'128:61:zxx:image/png:icon_red_zxx.png:/etc/ath/%s'", 3069 hs20_icon_filename); 3070 osu_icon = "icon_red_zxx.png"; 3071 osu_ssid = "OSU"; 3072 osu_friendly_name = "'kor:SP 빨강 테스트 전용'"; 3073 osu_service_desc = "'kor:테스트 목적으로 무료 서비스'"; 3074 osu_method = (dut->ap_osu_method[0] == 0xFF) ? 1 : 3075 dut->ap_osu_method[0]; 3076 3077 if (strlen(dut->ap_osu_server_uri[0])) 3078 owrt_ap_set_list_vap(dut, vap_id, "osu_server_uri", 3079 dut->ap_osu_server_uri[0]); 3080 else 3081 owrt_ap_set_list_vap(dut, vap_id, "osu_server_uri", 3082 "'https://osu-server.r2-testbed.wi-fi.org/'"); 3083 switch (dut->ap_osu_provider_list) { 3084 case 1: 3085 case 101: 3086 owrt_ap_set_list_vap(dut, vap_id, "osu_friendly_name", 3087 "'eng:SP Red Test Only'"); 3088 owrt_ap_set_list_vap(dut, vap_id, "osu_service_desc", 3089 "'eng:Free service for test purpose'"); 3090 owrt_ap_set_list_vap(dut, vap_id, "hs20_icon", 3091 hs20_icon); 3092 3093 hs20_icon_filename = "icon_red_eng.png"; 3094 if (dut->ap_osu_icon_tag == 2) 3095 hs20_icon_filename = "wifi-abgn-logo_270x73.png"; 3096 3097 snprintf(hs20_icon, sizeof(hs20_icon), 3098 "'160:76:eng:image/png:icon_red_eng.png:/etc/ath/%s'", 3099 hs20_icon_filename); 3100 owrt_ap_set_list_vap(dut, vap_id, "osu_icon", 3101 "icon_red_eng.png"); 3102 break; 3103 case 2: 3104 case 102: 3105 owrt_ap_set_list_vap(dut, vap_id, "osu_friendly_name", 3106 "'eng:Wireless Broadband Alliance'"); 3107 owrt_ap_set_list_vap(dut, vap_id, "osu_service_desc", 3108 "'eng:Free service for test purpose'"); 3109 hs20_icon_filename = "icon_orange_zxx.png"; 3110 if (dut->ap_osu_icon_tag == 2) 3111 hs20_icon_filename = "wifi-abgn-logo_270x73.png"; 3112 3113 snprintf(hs20_icon, sizeof(hs20_icon), 3114 "'128:61:zxx:image/png:icon_orange_zxx.png:/etc/ath/%s'", 3115 hs20_icon_filename); 3116 osu_icon = "icon_orange_zxx.png"; 3117 osu_friendly_name = "'kor:와이어리스 브로드밴드 얼라이언스'"; 3118 break; 3119 case 3: 3120 case 103: 3121 osu_friendly_name = "'spa:SP Red Test Only'"; 3122 osu_service_desc = "'spa:Free service for test purpose'"; 3123 break; 3124 case 4: 3125 case 104: 3126 owrt_ap_set_list_vap(dut, vap_id, "osu_friendly_name", 3127 "'eng:SP Orange Test Only'"); 3128 owrt_ap_set_list_vap(dut, vap_id, "osu_service_desc", 3129 "'eng:Free service for test purpose'"); 3130 hs20_icon_filename = "icon_orange_eng.png"; 3131 if (dut->ap_osu_icon_tag == 2) 3132 hs20_icon_filename = "wifi-abgn-logo_270x73.png"; 3133 3134 snprintf(hs20_icon, sizeof(hs20_icon), 3135 "'160:76:eng:image/png:icon_orange_eng.png:/etc/ath/%s'", 3136 hs20_icon_filename); 3137 owrt_ap_set_list_vap(dut, vap_id, "hs20_icon", 3138 hs20_icon); 3139 osu_friendly_name = "'kor:SP 오렌지 테스트 전용'"; 3140 3141 hs20_icon_filename = "icon_orange_zxx.png"; 3142 if (dut->ap_osu_icon_tag == 2) 3143 hs20_icon_filename = "wifi-abgn-logo_270x73.png"; 3144 3145 snprintf(hs20_icon, sizeof(hs20_icon), 3146 "'128:61:zxx:image/png:icon_orange_zxx.png:/etc/ath/%s'", 3147 hs20_icon_filename); 3148 osu_icon = "icon_orange_zxx.png"; 3149 break; 3150 case 5: 3151 case 105: 3152 owrt_ap_set_list_vap(dut, vap_id, "osu_friendly_name", 3153 "'eng:SP Orange Test Only'"); 3154 owrt_ap_set_list_vap(dut, vap_id, "osu_service_desc", 3155 "'eng:Free service for test purpose'"); 3156 osu_friendly_name = "'kor:SP 오렌지 테스트 전용'"; 3157 3158 hs20_icon_filename = "icon_orange_zxx.png"; 3159 if (dut->ap_osu_icon_tag == 2) 3160 hs20_icon_filename = "wifi-abgn-logo_270x73.png"; 3161 3162 snprintf(hs20_icon, sizeof(hs20_icon), 3163 "'128:61:zxx:image/png:icon_orange_zxx.png:/etc/ath/%s'", 3164 hs20_icon_filename); 3165 osu_icon = "icon_orange_zxx.png"; 3166 break; 3167 case 6: 3168 case 106: 3169 owrt_ap_set_list_vap(dut, vap_id, "osu_friendly_name", 3170 "'eng:SP Green Test Only'"); 3171 owrt_ap_set_list_vap(dut, vap_id, "osu_friendly_name", 3172 "'kor:SP 초록 테스트 전용'"); 3173 3174 hs20_icon_filename = "icon_green_zxx.png"; 3175 if (dut->ap_osu_icon_tag == 2) 3176 hs20_icon_filename = "wifi-abgn-logo_270x73.png"; 3177 3178 snprintf(hs20_icon, sizeof(hs20_icon), 3179 "'128:61:zxx:image/png:icon_green_zxx.png:/etc/ath/%s'", 3180 hs20_icon_filename); 3181 owrt_ap_set_list_vap(dut, vap_id, "hs20_icon", 3182 hs20_icon); 3183 3184 owrt_ap_set_list_vap(dut, vap_id, "osu_icon", 3185 "'icon_green_zxx.png'"); 3186 osu_method = (dut->ap_osu_method[0] == 0xFF) ? 0 : 3187 dut->ap_osu_method[0]; 3188 3189 snprintf(buf, sizeof(buf), "%d", osu_method); 3190 owrt_ap_set_vap(dut, vap_id, "osu_method_list", buf); 3191 3192 if (strlen(dut->ap_osu_server_uri[1])) 3193 owrt_ap_set_list_vap(dut, vap_id, 3194 "osu_server_uri", 3195 dut->ap_osu_server_uri[1]); 3196 else 3197 owrt_ap_set_list_vap(dut, vap_id, 3198 "osu_server_uri", 3199 "'https://osu-server.r2-testbed.wi-fi.org/'"); 3200 3201 owrt_ap_set_list_vap(dut, vap_id, "osu_friendly_name", 3202 "'eng:SP Orange Test Only'"); 3203 3204 hs20_icon_filename = "icon_orange_zxx.png"; 3205 if (dut->ap_osu_icon_tag == 2) 3206 hs20_icon_filename = "wifi-abgn-logo_270x73.png"; 3207 3208 snprintf(hs20_icon, sizeof(hs20_icon), 3209 "'128:61:zxx:image/png:icon_orange_zxx.png:/etc/ath/%s'", 3210 hs20_icon_filename); 3211 3212 osu_icon = "icon_orange_zxx.png"; 3213 osu_friendly_name = "'kor:SP 오렌지 테스트 전용'"; 3214 osu_method = (dut->ap_osu_method[1] == 0xFF) ? 0 : 3215 dut->ap_osu_method[1]; 3216 osu_service_desc = NULL; 3217 break; 3218 case 7: 3219 case 107: 3220 owrt_ap_set_list_vap(dut, vap_id, "osu_friendly_name", 3221 "'eng:SP Green Test Only'"); 3222 owrt_ap_set_list_vap(dut, vap_id, "osu_service_desc", 3223 "'eng:Free service for test purpose'"); 3224 3225 hs20_icon_filename = "icon_green_eng.png"; 3226 if (dut->ap_osu_icon_tag == 2) 3227 hs20_icon_filename = "wifi-abgn-logo_270x73.png"; 3228 3229 snprintf(hs20_icon, sizeof(hs20_icon), 3230 "'160:76:eng:image/png:icon_green_eng.png:/etc/ath/%s'", 3231 hs20_icon_filename); 3232 owrt_ap_set_list_vap(dut, vap_id, "hs20_icon", 3233 hs20_icon); 3234 3235 owrt_ap_set_list_vap(dut, vap_id, "osu_icon", 3236 "'icon_green_eng.png'"); 3237 osu_friendly_name = "'kor:SP 초록 테스트 전용'"; 3238 3239 hs20_icon_filename = "icon_green_zxx.png"; 3240 if (dut->ap_osu_icon_tag == 2) 3241 hs20_icon_filename = "wifi-abgn-logo_270x73.png"; 3242 3243 snprintf(hs20_icon, sizeof(hs20_icon), 3244 "'128:61:zxx:image/png:icon_green_zxx.png:/etc/ath/%s'", 3245 hs20_icon_filename); 3246 osu_icon = "icon_green_zxx.png"; 3247 break; 3248 case 8: 3249 case 108: 3250 owrt_ap_set_list_vap(dut, vap_id, "osu_friendly_name", 3251 "'eng:SP Red Test Only'"); 3252 owrt_ap_set_list_vap(dut, vap_id, "osu_service_desc", 3253 "'eng:Free service for test purpose'"); 3254 osu_ssid = "OSU-Encrypted"; 3255 osu_nai = "'anonymous@hotspot.net'"; 3256 break; 3257 case 9: 3258 case 109: 3259 osu_ssid = "OSU-OSEN"; 3260 osu_nai = "'test-anonymous@wi-fi.org'"; 3261 osu_friendly_name = "'eng:SP Orange Test Only'"; 3262 hs20_icon_filename = "icon_orange_zxx.png"; 3263 if (dut->ap_osu_icon_tag == 2) 3264 hs20_icon_filename = "wifi-abgn-logo_270x73.png"; 3265 3266 snprintf(hs20_icon, sizeof(hs20_icon), 3267 "'128:61:zxx:image/png:icon_orange_zxx.png:/etc/ath/%s'", 3268 hs20_icon_filename); 3269 osu_icon = "icon_orange_zxx.png"; 3270 osu_method = (dut->ap_osu_method[0] == 0xFF) ? 1 : 3271 dut->ap_osu_method[0]; 3272 osu_service_desc = NULL; 3273 break; 3274 default: 3275 break; 3276 } 3277 3278 if (strlen(dut->ap_osu_ssid)) { 3279 if (dut->ap_tag_ssid[0][0] && 3280 strcmp(dut->ap_tag_ssid[0], 3281 dut->ap_osu_ssid) != 0 && 3282 strcmp(dut->ap_tag_ssid[0], osu_ssid) != 0) { 3283 sigma_dut_print(dut, DUT_MSG_ERROR, 3284 "OSU_SSID and WLAN_TAG2 SSID differ"); 3285 return -2; 3286 } 3287 3288 snprintf(buf, sizeof(buf), "'\"%s\"'", 3289 dut->ap_osu_ssid); 3290 } else { 3291 snprintf(buf, sizeof(buf), "'\"%s\"'", osu_ssid); 3292 } 3293 3294 owrt_ap_set_vap(dut, vap_id, "osu_ssid", buf); 3295 3296 3297 if (osu_friendly_name) 3298 owrt_ap_set_list_vap(dut, vap_id, "osu_friendly_name", 3299 osu_friendly_name); 3300 if (osu_service_desc) 3301 owrt_ap_set_list_vap(dut, vap_id, "osu_service_desc", 3302 osu_service_desc); 3303 if (osu_nai) 3304 owrt_ap_set_vap(dut, vap_id, "osu_nai", osu_nai); 3305 3306 owrt_ap_set_list_vap(dut, vap_id, "hs20_icon", hs20_icon); 3307 3308 if (osu_icon) 3309 owrt_ap_set_list_vap(dut, vap_id, "osu_icon", 3310 osu_icon); 3311 3312 if (dut->ap_osu_provider_list > 100) { 3313 owrt_ap_set_list_vap(dut, vap_id, "osu_method_list", 3314 "0"); 3315 } else { 3316 snprintf(buf, sizeof(buf), "%d", osu_method); 3317 owrt_ap_set_list_vap(dut, vap_id, "osu_method_list", 3318 buf); 3319 } 3320 } 3321 3322 return 0; 3323 } 3324 3325 3326 static int set_anqp_elem_value(struct sigma_dut *dut, const char *ifname, 3327 char *anqp_string, size_t str_size) 3328 { 3329 unsigned char bssid[ETH_ALEN]; 3330 unsigned char dummy_mac[] = { 0x00, 0x10, 0x20, 0x30, 0x40, 0x50 }; 3331 int preference = 0xff; 3332 3333 if (get_hwaddr(ifname, bssid) < 0) 3334 return -1; 3335 snprintf(anqp_string, str_size, 3336 "272:3410%02x%02x%02x%02x%02x%02xf70000007330000301%02x3410%02x%02x%02x%02x%02x%02xf70000007330000301%02x", 3337 bssid[0], bssid[1], bssid[2], bssid[3], bssid[4], bssid[5], 3338 preference, 3339 dummy_mac[0], dummy_mac[1], dummy_mac[2], 3340 dummy_mac[3], dummy_mac[4], dummy_mac[5], 3341 preference - 1); 3342 return 0; 3343 } 3344 3345 3346 const char * get_hostapd_ifname(struct sigma_dut *dut) 3347 { 3348 enum driver_type drv; 3349 3350 /* Use the configured hostapd ifname */ 3351 if (dut->hostapd_ifname && if_nametoindex(dut->hostapd_ifname) > 0) 3352 return dut->hostapd_ifname; 3353 3354 /* Use configured main ifname */ 3355 if (dut->main_ifname) { 3356 if (dut->use_5g && dut->main_ifname_5g && 3357 if_nametoindex(dut->main_ifname_5g) > 0) 3358 return dut->main_ifname_5g; 3359 if (!dut->use_5g && dut->main_ifname_2g && 3360 if_nametoindex(dut->main_ifname_2g) > 0) 3361 return dut->main_ifname_2g; 3362 if (if_nametoindex(dut->main_ifname) > 0) 3363 return dut->main_ifname; 3364 } 3365 3366 /* Return based on driver type (indirectly started hostapd) */ 3367 drv = get_driver_type(dut); 3368 if (drv == DRIVER_ATHEROS) { 3369 if (dut->use_5g && if_nametoindex("ath1") > 0) 3370 return "ath1"; 3371 return "ath0"; 3372 } 3373 3374 if (drv == DRIVER_OPENWRT) { 3375 if (sigma_radio_ifname[0] && 3376 strcmp(sigma_radio_ifname[0], "wifi2") == 0) 3377 return "ath2"; 3378 if (sigma_radio_ifname[0] && 3379 strcmp(sigma_radio_ifname[0], "wifi1") == 0) 3380 return "ath1"; 3381 return "ath0"; 3382 } 3383 3384 /* wlan1-is-likely-5-GHz design */ 3385 if (dut->use_5g && if_nametoindex("wlan1") > 0) 3386 return "wlan1"; 3387 3388 /* If nothing else matches, hope for the best and guess this is wlan0 */ 3389 return "wlan0"; 3390 } 3391 3392 3393 static void get_if_name(struct sigma_dut *dut, char *ifname_str, 3394 size_t str_size, int wlan_tag) 3395 { 3396 const char *ifname; 3397 enum driver_type drv; 3398 3399 ifname = get_hostapd_ifname(dut); 3400 drv = get_driver_type(dut); 3401 3402 if (drv == DRIVER_OPENWRT && wlan_tag > 1) { 3403 /* Handle tagged-ifname only on OPENWRT for now */ 3404 snprintf(ifname_str, str_size, "%s%d", ifname, wlan_tag - 1); 3405 } else if ((drv == DRIVER_MAC80211 || drv == DRIVER_LINUX_WCN) && 3406 wlan_tag == 2) { 3407 snprintf(ifname_str, str_size, "%s_1", ifname); 3408 } else { 3409 snprintf(ifname_str, str_size, "%s", ifname); 3410 } 3411 } 3412 3413 3414 static int sae_pw_id_used(struct sigma_dut *dut) 3415 { 3416 return dut->ap_sae_passwords && 3417 strchr(dut->ap_sae_passwords, ':'); 3418 } 3419 3420 3421 static int owrt_ap_config_vap(struct sigma_dut *dut) 3422 { 3423 char buf[256], *temp; 3424 int vap_id = 0, vap_count, i, j, res; 3425 const char *ifname; 3426 char ifname2[50]; 3427 3428 if (sigma_radio_ifname[0] && 3429 strcmp(sigma_radio_ifname[0], "wifi2") == 0) 3430 ifname = "ath2"; 3431 else if (sigma_radio_ifname[0] && 3432 strcmp(sigma_radio_ifname[0], "wifi1") == 0) 3433 ifname = "ath1"; 3434 else 3435 ifname = "ath0"; 3436 3437 for (vap_count = 0; vap_count < OPENWRT_MAX_NUM_RADIOS; vap_count++) { 3438 snprintf(buf, sizeof(buf), "wifi%d", vap_count); 3439 3440 for (vap_id = 0; vap_id < MAX_RADIO; vap_id++) { 3441 if (sigma_radio_ifname[vap_id] && 3442 strcmp(sigma_radio_ifname[vap_id], buf) == 0) 3443 break; 3444 } 3445 if (vap_id == MAX_RADIO) 3446 continue; 3447 3448 /* Single VAP configuration */ 3449 if (!dut->ap_is_dual) 3450 vap_id = vap_count; 3451 3452 for (j = 0; j < MAX_WLAN_TAGS - 1; j++) { 3453 /* 3454 * We keep a separate array of ap_tag_ssid and 3455 * ap_tag_key_mgmt for tags starting from WLAN_TAG=2. 3456 * So j=0 => WLAN_TAG = 2 3457 */ 3458 int wlan_tag = j + 2; 3459 3460 if (wlan_tag == 2 && dut->program == PROGRAM_WPA3 && 3461 (dut->ap_interface_5g || dut->ap_interface_2g)) { 3462 res = snprintf( 3463 dut->ap_tag_ssid[wlan_tag - 2], 3464 sizeof(dut->ap_tag_ssid[wlan_tag - 2]), 3465 "%s-owe", dut->ap_ssid); 3466 if (res < 0 || 3467 res >= sizeof(dut->ap_tag_ssid[wlan_tag - 3468 2])) 3469 dut->ap_tag_ssid[wlan_tag - 2][0] = 3470 '\0'; 3471 } 3472 3473 if (dut->ap_tag_ssid[j][0] == '\0') 3474 continue; 3475 3476 snprintf(buf, sizeof(buf), "%s%d", "wifi", vap_count); 3477 owrt_ap_add_vap(dut, vap_count + (wlan_tag - 1), 3478 "device", buf); 3479 /* SSID */ 3480 snprintf(buf, sizeof(buf), "\"%s\"", 3481 dut->ap_tag_ssid[j]); 3482 owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), 3483 "ssid", buf); 3484 3485 if (dut->ap_key_mgmt == AP_WPA2_OWE && 3486 dut->ap_tag_ssid[0][0] && 3487 dut->ap_tag_key_mgmt[0] == AP2_OPEN) { 3488 /* OWE transition mode */ 3489 snprintf(buf, sizeof(buf), "%s", ifname); 3490 owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), 3491 "owe_transition_ifname", buf); 3492 } 3493 3494 if (dut->ap_key_mgmt == AP_OPEN && 3495 dut->ap_tag_key_mgmt[0] == AP2_WPA2_OWE) { 3496 /* OWE transition mode */ 3497 snprintf(buf, sizeof(buf), "%s", ifname); 3498 owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), 3499 "owe_transition_ifname", buf); 3500 owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), 3501 "hidden", "1"); 3502 } 3503 3504 if (ap_ft_enabled(dut)) { 3505 unsigned char self_mac[ETH_ALEN]; 3506 char mac_str[20]; 3507 3508 owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), 3509 "mobility_domain", 3510 dut->ap_mobility_domain); 3511 owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), 3512 "ft_over_ds", 3513 dut->ap_ft_ds == VALUE_ENABLED ? 3514 "1" : "0"); 3515 owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), 3516 "ieee80211r", "1"); 3517 owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), 3518 "nasid", "nas1.example.com"); 3519 if (get_hwaddr(sigma_radio_ifname[0], 3520 self_mac) < 0) 3521 return -1; 3522 snprintf(mac_str, sizeof(mac_str), 3523 "%02x:%02x:%02x:%02x:%02x:%02x", 3524 self_mac[0], self_mac[1], self_mac[2], 3525 self_mac[3], self_mac[4], self_mac[5]); 3526 owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), 3527 "ap_macaddr", mac_str); 3528 snprintf(mac_str, sizeof(mac_str), 3529 "%02x%02x%02x%02x%02x%02x", 3530 self_mac[0], self_mac[1], self_mac[2], 3531 self_mac[3], self_mac[4], self_mac[5]); 3532 owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), 3533 "r1_key_holder", mac_str); 3534 owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), 3535 "ft_psk_generate_local", "1"); 3536 owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), 3537 "kh_key_hex", 3538 "000102030405060708090a0b0c0d0e0f"); 3539 snprintf(mac_str, sizeof(mac_str), 3540 "%02x:%02x:%02x:%02x:%02x:%02x", 3541 dut->ft_bss_mac_list[0][0], 3542 dut->ft_bss_mac_list[0][1], 3543 dut->ft_bss_mac_list[0][2], 3544 dut->ft_bss_mac_list[0][3], 3545 dut->ft_bss_mac_list[0][4], 3546 dut->ft_bss_mac_list[0][5]); 3547 owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), 3548 "ap2_macaddr", mac_str); 3549 owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), 3550 "ap2_r1_key_holder", mac_str); 3551 owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), 3552 "nasid2", "nas2.example.com"); 3553 } 3554 3555 if (dut->ap_tag_key_mgmt[j] == AP2_OSEN && 3556 wlan_tag == 2) { 3557 /* Only supported for WLAN_TAG=2 */ 3558 owrt_ap_set_vap(dut, vap_count + 1, "osen", 3559 "1"); 3560 snprintf(buf, sizeof(buf), "wpa2"); 3561 owrt_ap_set_vap(dut, vap_count + 1, 3562 "encryption", buf); 3563 snprintf(buf, sizeof(buf), "%s", 3564 dut->ap2_radius_ipaddr); 3565 owrt_ap_set_vap(dut, vap_count + 1, 3566 "auth_server", buf); 3567 snprintf(buf, sizeof(buf), "%d", 3568 dut->ap2_radius_port); 3569 owrt_ap_set_vap(dut, vap_count + 1, 3570 "auth_port", buf); 3571 snprintf(buf, sizeof(buf), "%s", 3572 dut->ap2_radius_password); 3573 owrt_ap_set_vap(dut, vap_count + 1, 3574 "auth_secret", buf); 3575 } else if (dut->ap_tag_key_mgmt[j] == AP2_WPA2_PSK) { 3576 owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), 3577 "encryption", "psk2+ccmp"); 3578 snprintf(buf, sizeof(buf), "\"%s\"", 3579 dut->ap_passphrase); 3580 owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), 3581 "key", buf); 3582 snprintf(buf, sizeof(buf), "%d", dut->ap_pmf); 3583 owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), 3584 "ieee80211w", buf); 3585 } else if (dut->ap_tag_key_mgmt[0] == AP2_WPA2_OWE) { 3586 owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), 3587 "owe", "1"); 3588 snprintf(buf, sizeof(buf), "ccmp"); 3589 owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), 3590 "encryption", buf); 3591 owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), 3592 "ieee80211w", "2"); 3593 if (dut->ap_sae_groups) { 3594 snprintf(buf, sizeof(buf), "\'%s\'", 3595 dut->ap_sae_groups); 3596 owrt_ap_set_list_vap(dut, vap_count + 3597 (wlan_tag - 1), 3598 "owe_groups", buf); 3599 if (dut->owe_ptk_workaround) 3600 owrt_ap_set_list_vap( 3601 dut, vap_count + 3602 (wlan_tag - 1), 3603 "owe_ptk_workaround", 3604 "1"); 3605 } 3606 } 3607 } 3608 3609 /* Now set anqp_elem and ft_oa for wlan_tag = 1 */ 3610 if (dut->program == PROGRAM_MBO && 3611 get_driver_type(dut) == DRIVER_OPENWRT) { 3612 unsigned char self_mac[ETH_ALEN]; 3613 char mac_str[20]; 3614 char anqp_string[200]; 3615 3616 if (set_anqp_elem_value(dut, sigma_radio_ifname[0], 3617 anqp_string, 3618 sizeof(anqp_string)) < 0) 3619 return -1; 3620 owrt_ap_set_list_vap(dut, vap_count, "anqp_elem", 3621 anqp_string); 3622 3623 if (ap_ft_enabled(dut)) { 3624 owrt_ap_set_vap(dut, vap_count, 3625 "mobility_domain", 3626 dut->ap_mobility_domain); 3627 owrt_ap_set_vap(dut, vap_count, 3628 "ft_over_ds", 3629 dut->ap_ft_ds == VALUE_ENABLED ? 3630 "1" : "0"); 3631 owrt_ap_set_vap(dut, vap_count, 3632 "ieee80211r", "1"); 3633 owrt_ap_set_vap(dut, vap_count, 3634 "nasid", "nas1.example.com"); 3635 get_hwaddr(sigma_radio_ifname[0], self_mac); 3636 snprintf(mac_str, sizeof(mac_str), 3637 "%02x:%02x:%02x:%02x:%02x:%02x", 3638 self_mac[0], self_mac[1], self_mac[2], 3639 self_mac[3], self_mac[4], self_mac[5]); 3640 owrt_ap_set_vap(dut, vap_count, 3641 "ap_macaddr", mac_str); 3642 snprintf(mac_str, sizeof(mac_str), 3643 "%02x%02x%02x%02x%02x%02x", 3644 self_mac[0], self_mac[1], self_mac[2], 3645 self_mac[3], self_mac[4], self_mac[5]); 3646 owrt_ap_set_vap(dut, vap_count, 3647 "r1_key_holder", mac_str); 3648 owrt_ap_set_vap(dut, vap_count, 3649 "ft_psk_generate_local", "1"); 3650 owrt_ap_set_vap(dut, vap_count, 3651 "kh_key_hex", 3652 "000102030405060708090a0b0c0d0e0f"); 3653 snprintf(mac_str, sizeof(mac_str), 3654 "%02x:%02x:%02x:%02x:%02x:%02x", 3655 dut->ft_bss_mac_list[0][0], 3656 dut->ft_bss_mac_list[0][1], 3657 dut->ft_bss_mac_list[0][2], 3658 dut->ft_bss_mac_list[0][3], 3659 dut->ft_bss_mac_list[0][4], 3660 dut->ft_bss_mac_list[0][5]); 3661 owrt_ap_set_vap(dut, vap_count, 3662 "ap2_macaddr", mac_str); 3663 owrt_ap_set_vap(dut, vap_count, 3664 "ap2_r1_key_holder", mac_str); 3665 owrt_ap_set_vap(dut, vap_count, 3666 "nasid2", "nas2.example.com"); 3667 } 3668 } 3669 3670 if (dut->ap_oce == VALUE_ENABLED && 3671 get_driver_type(dut) == DRIVER_OPENWRT) { 3672 owrt_ap_set_vap(dut, vap_id, "oce", "1"); 3673 owrt_ap_set_vap(dut, vap_id, "qbssload", "1"); 3674 owrt_ap_set_vap(dut, vap_id, "bpr_enable", "1"); 3675 3676 if (dut->ap_80plus80 == 1) 3677 owrt_ap_set_vap(dut, vap_id, "cfreq2", "5775"); 3678 3679 if (dut->ap_akm == 1) { 3680 owrt_ap_set_vap(dut, vap_id, "wpa_group_rekey", 3681 "3600"); 3682 owrt_ap_set_vap(dut, vap_id, "key", "12345678"); 3683 owrt_ap_set_vap(dut, vap_id, "ieee80211ai", 3684 "1"); 3685 owrt_ap_set_vap(dut, vap_id, "fils_cache_id", 3686 "1234"); 3687 owrt_ap_set_vap(dut, vap_id, 3688 "erp_send_reauth_start", "1"); 3689 } 3690 3691 if (dut->ap_filshlp == VALUE_ENABLED) { 3692 struct ifreq ifr; 3693 char *ifname; 3694 int s; 3695 struct sockaddr_in *ipaddr; 3696 3697 s = socket(AF_INET, SOCK_DGRAM, 0); 3698 if (s < 0) { 3699 sigma_dut_print(dut, DUT_MSG_ERROR, 3700 "Failed to open socket"); 3701 return -1; 3702 } 3703 ifr.ifr_addr.sa_family = AF_INET; 3704 3705 memset(&ifr, 0, sizeof(ifr)); 3706 ifname = "br-lan"; 3707 strlcpy(ifr.ifr_name, ifname, 3708 sizeof(ifr.ifr_name)); 3709 if (ioctl(s, SIOCGIFADDR, &ifr) < 0) { 3710 perror("ioctl"); 3711 close(s); 3712 return -1; 3713 } 3714 3715 ipaddr = (struct sockaddr_in*)&ifr.ifr_addr; 3716 snprintf(buf, sizeof(buf), "%s", 3717 inet_ntoa(ipaddr->sin_addr)); 3718 owrt_ap_set_vap(dut, vap_id, "own_ip_addr", 3719 buf); 3720 snprintf(buf, sizeof(buf), "%s", 3721 dut->ap_dhcpserv_ipaddr); 3722 owrt_ap_set_vap(dut, vap_id, "dhcp_server", 3723 buf); 3724 owrt_ap_set_vap(dut, vap_id, 3725 "dhcp_rapid_commit_proxy", "1"); 3726 owrt_ap_set_vap(dut, vap_id, 3727 "fils_hlp_wait_time", "300"); 3728 } 3729 3730 if (dut->ap_filsdscv == VALUE_ENABLED) { 3731 owrt_ap_set_vap(dut, vap_id, "ieee80211ai", 3732 "1"); 3733 owrt_ap_set_vap(dut, vap_id, "fils_fd_period", 3734 "20"); 3735 } 3736 } 3737 3738 if (dut->ap_filsdscv == VALUE_DISABLED) { 3739 owrt_ap_set_vap(dut, vap_id, "ieee80211ai", "0"); 3740 owrt_ap_set_vap(dut, vap_id, "fils_fd_period", "0"); 3741 } 3742 3743 if (dut->ap_oce == VALUE_DISABLED && 3744 get_driver_type(dut) == DRIVER_OPENWRT) { 3745 owrt_ap_set_vap(dut, vap_id, "oce", "0"); 3746 owrt_ap_set_vap(dut, vap_id, "qbssload", "0"); 3747 owrt_ap_set_vap(dut, vap_id, "bpr_enable", "0"); 3748 3749 if (dut->ap_filsdscv == VALUE_DISABLED) { 3750 owrt_ap_set_vap(dut, vap_id, "ieee80211ai", 3751 "0"); 3752 owrt_ap_set_vap(dut, vap_id, "fils_fd_period", 3753 "0"); 3754 } 3755 3756 if (dut->device_type == AP_testbed) 3757 owrt_ap_set_vap(dut, vap_id, "mbo", "1"); 3758 } 3759 3760 /* NAIRealm */ 3761 if (dut->ap_nairealm_int == 1) { 3762 snprintf(buf, sizeof(buf), "\"%s\"", dut->ap_nairealm); 3763 owrt_ap_set_vap(dut, vap_id, "fils_realm", buf); 3764 owrt_ap_set_vap(dut, vap_id, "erp_domain", buf); 3765 } 3766 3767 /* SSID */ 3768 snprintf(buf, sizeof(buf), "\"%s\"", dut->ap_ssid); 3769 owrt_ap_set_vap(dut, vap_count, "ssid", buf); 3770 3771 /* Encryption */ 3772 switch (dut->ap_key_mgmt) { 3773 case AP_OPEN: 3774 if (dut->ap_cipher == AP_WEP) { 3775 owrt_ap_set_vap(dut, vap_count, "encryption", 3776 "wep-mixed"); 3777 owrt_ap_set_vap(dut, vap_count, "key", 3778 dut->ap_wepkey); 3779 } else { 3780 owrt_ap_set_vap(dut, vap_count, "encryption", 3781 "none"); 3782 } 3783 if (dut->ap_key_mgmt == AP_OPEN && 3784 dut->ap_tag_key_mgmt[0] == AP2_WPA2_OWE) { 3785 /* OWE transition mode */ 3786 snprintf(ifname2, sizeof(ifname2), "%s1", 3787 ifname); 3788 owrt_ap_set_vap(dut, vap_count, 3789 "owe_transition_ifname", 3790 ifname2); 3791 } 3792 break; 3793 case AP_WPA2_PSK: 3794 case AP_WPA2_PSK_MIXED: 3795 case AP_WPA_PSK: 3796 case AP_WPA2_SAE: 3797 case AP_WPA2_PSK_SAE: 3798 if (dut->ap_key_mgmt == AP_WPA2_PSK || 3799 dut->ap_key_mgmt == AP_WPA2_PSK_SAE) { 3800 snprintf(buf, sizeof(buf), "psk2"); 3801 } else if (dut->ap_key_mgmt == AP_WPA2_PSK_MIXED) { 3802 snprintf(buf, sizeof(buf), "psk-mixed"); 3803 } else if (dut->ap_key_mgmt == AP_WPA2_SAE) { 3804 snprintf(buf, sizeof(buf), "ccmp"); 3805 } else { 3806 snprintf(buf, sizeof(buf), "psk"); 3807 } 3808 3809 if (dut->ap_key_mgmt != AP_WPA2_SAE) { 3810 if (dut->ap_cipher == AP_CCMP_TKIP) 3811 strlcat(buf, "+ccmp+tkip", sizeof(buf)); 3812 else if (dut->ap_cipher == AP_TKIP) 3813 strlcat(buf, "+tkip", sizeof(buf)); 3814 else if (dut->ap_cipher == AP_GCMP_128) 3815 strlcat(buf, "+gcmp", sizeof(buf)); 3816 else 3817 strlcat(buf, "+ccmp", sizeof(buf)); 3818 } 3819 3820 owrt_ap_set_vap(dut, vap_count, "encryption", buf); 3821 3822 if (!dut->ap_passphrase[0] && dut->ap_psk[0]) { 3823 snprintf(buf, sizeof(buf), "\"%s\"", 3824 dut->ap_psk); 3825 owrt_ap_set_vap(dut, vap_count, "key", buf); 3826 } else { 3827 snprintf(buf, sizeof(buf), "\"%s\"", 3828 dut->ap_passphrase); 3829 owrt_ap_set_vap(dut, vap_count, "key", buf); 3830 } 3831 3832 if (dut->ap_key_mgmt == AP_WPA2_SAE || 3833 dut->ap_key_mgmt == AP_WPA2_PSK_SAE) 3834 owrt_ap_set_vap(dut, vap_count, "sae", "1"); 3835 else 3836 owrt_ap_set_vap(dut, vap_count, "sae", "0"); 3837 3838 if (dut->ap_key_mgmt == AP_WPA2_SAE && dut->ap_sae_pk && 3839 dut->ap_sae_pk_keypair_sig) { 3840 snprintf(buf, sizeof(buf), "%s|pk=%s:%s:%s", 3841 dut->ap_passphrase, 3842 dut->ap_sae_pk_modifier, 3843 dut->ap_sae_pk_keypair, 3844 dut->ap_sae_pk_keypair_sig); 3845 owrt_ap_set_vap(dut, vap_count, "sae_password", 3846 buf); 3847 } else if (dut->ap_key_mgmt == AP_WPA2_SAE && 3848 dut->ap_sae_pk) { 3849 snprintf(buf, sizeof(buf), "%s|pk=%s:%s", 3850 dut->ap_passphrase, 3851 dut->ap_sae_pk_modifier, 3852 dut->ap_sae_pk_keypair); 3853 owrt_ap_set_vap(dut, vap_count, "sae_password", 3854 buf); 3855 } else if (dut->ap_key_mgmt == AP_WPA2_SAE) { 3856 snprintf(buf, sizeof(buf), "%s", 3857 dut->ap_passphrase); 3858 owrt_ap_set_vap(dut, vap_count, "sae_password", 3859 buf); 3860 } else { 3861 snprintf(buf, sizeof(buf), "%s", 3862 dut->ap_passphrase); 3863 owrt_ap_set_vap(dut, vap_count, 3864 "wpa_passphrase", buf); 3865 } 3866 break; 3867 case AP_WPA2_EAP: 3868 case AP_WPA2_EAP_MIXED: 3869 case AP_WPA_EAP: 3870 if (dut->ap_key_mgmt == AP_WPA2_EAP) { 3871 snprintf(buf, sizeof(buf), "wpa2"); 3872 } else if (dut->ap_key_mgmt == AP_WPA2_EAP_MIXED) { 3873 snprintf(buf, sizeof(buf), "wpa-mixed"); 3874 } else { 3875 snprintf(buf, sizeof(buf), "wpa"); 3876 } 3877 3878 if (dut->ap_cipher == AP_CCMP_TKIP) 3879 strlcat(buf, "+ccmp+tkip", sizeof(buf)); 3880 else if (dut->ap_cipher == AP_TKIP) 3881 strlcat(buf, "+tkip", sizeof(buf)); 3882 else 3883 strlcat(buf, "+ccmp", sizeof(buf)); 3884 3885 owrt_ap_set_vap(dut, vap_count, "encryption", buf); 3886 snprintf(buf, sizeof(buf), "%s", dut->ap_radius_ipaddr); 3887 owrt_ap_set_vap(dut, vap_count, "auth_server", buf); 3888 snprintf(buf, sizeof(buf), "%d", dut->ap_radius_port); 3889 owrt_ap_set_vap(dut, vap_count, "auth_port", buf); 3890 snprintf(buf, sizeof(buf), "%s", 3891 dut->ap_radius_password); 3892 owrt_ap_set_vap(dut, vap_count, "auth_secret", buf); 3893 break; 3894 case AP_WPA2_EAP_OSEN: 3895 case AP_OSEN: 3896 case AP_WPA2_FT_EAP: 3897 case AP_WPA2_FT_PSK: 3898 case AP_WPA2_EAP_SHA256: 3899 case AP_WPA2_PSK_SHA256: 3900 case AP_WPA2_ENT_FT_EAP: 3901 /* TODO */ 3902 break; 3903 case AP_SUITEB: 3904 owrt_ap_set_vap(dut, vap_count, "suite_b", "192"); 3905 snprintf(buf, sizeof(buf), "gcmp"); 3906 owrt_ap_set_vap(dut, vap_count, "encryption", buf); 3907 snprintf(buf, sizeof(buf), "%s", dut->ap_radius_ipaddr); 3908 owrt_ap_set_vap(dut, vap_count, "auth_server", buf); 3909 snprintf(buf, sizeof(buf), "%d", dut->ap_radius_port); 3910 owrt_ap_set_vap(dut, vap_count, "auth_port", buf); 3911 snprintf(buf, sizeof(buf), "%s", 3912 dut->ap_radius_password); 3913 owrt_ap_set_vap(dut, vap_count, "auth_secret", buf); 3914 snprintf(buf, sizeof(buf), "%d", 3915 dut->ap_group_mgmt_cipher); 3916 owrt_ap_set_vap(dut, vap_count, "group_mgmt_cipher", 3917 buf); 3918 break; 3919 case AP_WPA2_OWE: 3920 owrt_ap_set_vap(dut, vap_count, "owe", "1"); 3921 snprintf(buf, sizeof(buf), "ccmp"); 3922 owrt_ap_set_vap(dut, vap_count, "encryption", buf); 3923 if (dut->ap_sae_groups) { 3924 snprintf(buf, sizeof(buf), "\'%s\'", 3925 dut->ap_sae_groups); 3926 owrt_ap_set_list_vap(dut, vap_count, 3927 "owe_groups", buf); 3928 if (dut->owe_ptk_workaround) 3929 owrt_ap_set_list_vap( 3930 dut, vap_count, 3931 "owe_ptk_workaround", "1"); 3932 } 3933 3934 if (dut->ap_key_mgmt == AP_WPA2_OWE && 3935 dut->ap_tag_ssid[0][0] && 3936 dut->ap_tag_key_mgmt[0] == AP2_OPEN) { 3937 /* OWE transition mode */ 3938 snprintf(ifname2, sizeof(ifname2), "%s1", 3939 ifname); 3940 owrt_ap_set_vap(dut, vap_count, 3941 "owe_transition_ifname", 3942 ifname2); 3943 owrt_ap_set_vap(dut, vap_count, "hidden", "1"); 3944 } 3945 break; 3946 } 3947 3948 if (!dut->ap_is_dual) 3949 break; 3950 } 3951 3952 if (dut->ap_is_dual) 3953 return 1; 3954 3955 /* PMF */ 3956 snprintf(buf, sizeof(buf), "%d", dut->ap_pmf); 3957 owrt_ap_set_vap(dut, vap_id, "ieee80211w", buf); 3958 3959 /* Add SHA256 */ 3960 snprintf(buf, sizeof(buf), "%d", dut->ap_add_sha256); 3961 owrt_ap_set_vap(dut, vap_id, "add_sha256", buf); 3962 3963 /* Add SHA384 for akmsuitetype 15 */ 3964 if (dut->ap_akm == 1) { 3965 snprintf(buf, sizeof(buf), "%d", dut->ap_add_sha384); 3966 owrt_ap_set_vap(dut, vap_id, "add_sha384", buf); 3967 } 3968 3969 /* Enable RSN preauthentication, if asked to */ 3970 snprintf(buf, sizeof(buf), "%d", dut->ap_rsn_preauth); 3971 owrt_ap_set_vap(dut, vap_id, "rsn_preauth", buf); 3972 3973 /* Hotspot 2.0 */ 3974 if (dut->ap_hs2) { 3975 int ret; 3976 3977 ret = owrt_ap_config_vap_hs2(dut, vap_id); 3978 if (ret) 3979 return ret; 3980 } 3981 3982 /* Interworking */ 3983 if (dut->ap_interworking) { 3984 snprintf(buf, sizeof(buf), "%d", dut->ap_access_net_type); 3985 owrt_ap_set_vap(dut, vap_id, "access_network_type", buf); 3986 snprintf(buf, sizeof(buf), "%d", dut->ap_internet); 3987 owrt_ap_set_vap(dut, vap_id, "internet", buf); 3988 snprintf(buf, sizeof(buf), "%d", dut->ap_venue_group); 3989 owrt_ap_set_vap(dut, vap_id, "venue_group", buf); 3990 snprintf(buf, sizeof(buf), "%d", dut->ap_venue_type); 3991 owrt_ap_set_vap(dut, vap_id, "venue_type", buf); 3992 snprintf(buf, sizeof(buf), "%s", dut->ap_hessid); 3993 owrt_ap_set_vap(dut, vap_id, "hessid", buf); 3994 3995 if (dut->ap_gas_cb_delay > 0) { 3996 snprintf(buf, sizeof(buf), "%d", dut->ap_gas_cb_delay); 3997 owrt_ap_set_vap(dut, vap_id, "gas_comeback_delay", buf); 3998 } 3999 4000 if (dut->ap_roaming_cons[0]) { 4001 char *rcons, *temp_ptr; 4002 4003 rcons = strdup(dut->ap_roaming_cons); 4004 if (rcons == NULL) 4005 return -1; 4006 4007 temp_ptr = strchr(rcons, ';'); 4008 4009 if (temp_ptr) 4010 *temp_ptr++ = '\0'; 4011 4012 owrt_ap_set_list_vap(dut, vap_id, "roaming_consortium", 4013 rcons); 4014 4015 if (temp_ptr) 4016 owrt_ap_set_list_vap(dut, vap_id, 4017 "roaming_consortium", 4018 temp_ptr); 4019 4020 free(rcons); 4021 } 4022 } 4023 4024 if (dut->ap_venue_name) { 4025 owrt_ap_set_list_vap(dut, vap_id, "venue_name", 4026 "'P\"eng:Wi-Fi Alliance\\n2989 Copper Road\\nSanta Clara, CA 95051, USA\"'"); 4027 owrt_ap_set_list_vap(dut, vap_id, "venue_name", 4028 "\'"ANQP_VENUE_NAME_1_CHI"\'"); 4029 } 4030 4031 if (dut->ap_net_auth_type == 1) { 4032 owrt_ap_set_list_vap(dut, vap_id, "network_auth_type", 4033 "'00https://tandc-server.wi-fi.org'"); 4034 } else if (dut->ap_net_auth_type == 2) { 4035 owrt_ap_set_list_vap(dut, vap_id, "network_auth_type", "'01'"); 4036 } 4037 4038 if (dut->ap_nai_realm_list == 1) { 4039 owrt_ap_set_list_vap(dut, vap_id, "nai_realm", 4040 "'0,mail.example.com;cisco.com;wi-fi.org,21[2:4][5:7]'"); 4041 owrt_ap_set_list_vap(dut, vap_id, "nai_realm", 4042 "'0,wi-fi.org;example.com,13[5:6]'"); 4043 4044 } else if (dut->ap_nai_realm_list == 2) { 4045 owrt_ap_set_list_vap(dut, vap_id, "nai_realm", 4046 "'0,wi-fi.org,21[2:4][5:7]'"); 4047 } else if (dut->ap_nai_realm_list == 3) { 4048 owrt_ap_set_list_vap(dut, vap_id, "nai_realm", 4049 "'0,cisco.com;wi-fi.org,21[2:4][5:7]'"); 4050 owrt_ap_set_list_vap(dut, vap_id, "nai_realm", 4051 "'0,wi-fi.org;example.com,13[5:6]'"); 4052 } else if (dut->ap_nai_realm_list == 4) { 4053 owrt_ap_set_list_vap(dut, vap_id, "nai_realm", 4054 "'0,mail.example.com,21[2:4][5:7],13[5:6]'"); 4055 } else if (dut->ap_nai_realm_list == 5) { 4056 owrt_ap_set_list_vap(dut, vap_id, "nai_realm", 4057 "'0,wi-fi.org;ruckuswireless.com,21[2:4][5:7]'"); 4058 } else if (dut->ap_nai_realm_list == 6) { 4059 owrt_ap_set_list_vap(dut, vap_id, "nai_realm", 4060 "'0,wi-fi.org;mail.example.com,21[2:4][5:7]'"); 4061 } else if (dut->ap_nai_realm_list == 7) { 4062 owrt_ap_set_list_vap(dut, vap_id, "nai_realm", 4063 "'0,wi-fi.org,13[5:6]'"); 4064 owrt_ap_set_list_vap(dut, vap_id, "nai_realm", 4065 "'0,wi-fi.org,21[2:4][5:7]'"); 4066 } 4067 4068 if (dut->ap_domain_name_list[0]) 4069 owrt_ap_set_list_vap(dut, vap_id, "domain_name", 4070 dut->ap_domain_name_list); 4071 4072 if (dut->ap_ip_addr_type_avail) 4073 owrt_ap_set_vap(dut, vap_id, "ipaddr_type_availability", 4074 "'0c'"); 4075 4076 temp = buf; 4077 4078 *temp++ = '\''; 4079 4080 for (i = 0; dut->ap_plmn_mcc[i][0] && dut->ap_plmn_mnc[i][0]; i++) { 4081 if (i) 4082 *temp++ = ';'; 4083 4084 snprintf(temp, 4085 sizeof(dut->ap_plmn_mcc[i]) + 4086 sizeof(dut->ap_plmn_mnc[i]) + 1, 4087 "%s,%s", 4088 dut->ap_plmn_mcc[i], 4089 dut->ap_plmn_mnc[i]); 4090 4091 temp += strlen(dut->ap_plmn_mcc[i]) + 4092 strlen(dut->ap_plmn_mnc[i]) + 1; 4093 } 4094 4095 *temp++ = '\''; 4096 *temp++ = '\0'; 4097 4098 if (i) 4099 owrt_ap_set_vap(dut, vap_id, "anqp_3gpp_cell_net", buf); 4100 4101 if (dut->ap_qos_map_set == 1) 4102 owrt_ap_set_vap(dut, vap_id, "qos_map_set", QOS_MAP_SET_1); 4103 else if (dut->ap_qos_map_set == 2) 4104 owrt_ap_set_vap(dut, vap_id, "qos_map_set", QOS_MAP_SET_2); 4105 4106 /* Proxy-ARP */ 4107 snprintf(buf, sizeof(buf), "%d", dut->ap_proxy_arp); 4108 owrt_ap_set_vap(dut, vap_id, "proxyarp", buf); 4109 4110 /* DGAF */ 4111 snprintf(buf, sizeof(buf), "%d", dut->ap_dgaf_disable); 4112 /* parse to hostapd */ 4113 owrt_ap_set_vap(dut, vap_id, "disable_dgaf", buf); 4114 /* parse to wifi driver */ 4115 owrt_ap_set_vap(dut, vap_id, "dgaf_disable", buf); 4116 4117 /* HCBSSLoad */ 4118 if (dut->ap_bss_load) { 4119 unsigned int bssload = 0; 4120 4121 if (dut->ap_bss_load == 1) { 4122 /* STA count: 1, CU: 50, AAC: 65535 */ 4123 bssload = 0x0132ffff; 4124 } else if (dut->ap_bss_load == 2) { 4125 /* STA count: 1, CU: 200, AAC: 65535 */ 4126 bssload = 0x01c8ffff; 4127 } else if (dut->ap_bss_load == 3) { 4128 /* STA count: 1, CU: 75, AAC: 65535 */ 4129 bssload = 0x014bffff; 4130 } 4131 4132 snprintf(buf, sizeof(buf), "%d", bssload); 4133 owrt_ap_set_vap(dut, vap_id, "hcbssload", buf); 4134 } 4135 4136 /* L2TIF */ 4137 if (dut->ap_l2tif) 4138 owrt_ap_set_vap(dut, vap_id, "l2tif", "1"); 4139 4140 if (dut->ap_disable_protection == 1) 4141 owrt_ap_set_vap(dut, vap_id, "enablertscts", "0"); 4142 4143 if (dut->ap_txBF) { 4144 owrt_ap_set_vap(dut, vap_id, "vhtsubfee", "1"); 4145 owrt_ap_set_vap(dut, vap_id, "vhtsubfer", "1"); 4146 if (dut->program == PROGRAM_HE) { 4147 owrt_ap_set_vap(dut, vap_id, "he_subfer", "1"); 4148 owrt_ap_set_vap(dut, vap_id, "cwmenable", "0"); 4149 } 4150 } else { 4151 owrt_ap_set_vap(dut, vap_id, "vhtsubfee", "0"); 4152 owrt_ap_set_vap(dut, vap_id, "vhtsubfer", "0"); 4153 if (dut->program == PROGRAM_HE) 4154 owrt_ap_set_vap(dut, vap_id, "he_subfer", "0"); 4155 } 4156 4157 if (dut->ap_mu_txBF) { 4158 owrt_ap_set_vap(dut, vap_id, "vhtmubfer", "1"); 4159 if (dut->program == PROGRAM_HE) { 4160 owrt_ap_set_vap(dut, vap_id, "he_mubfer", "1"); 4161 owrt_ap_set_vap(dut, vap_id, "he_mubfee", "1"); 4162 } 4163 } else { 4164 owrt_ap_set_vap(dut, vap_id, "vhtmubfer", "0"); 4165 if (dut->program == PROGRAM_HE) { 4166 owrt_ap_set_vap(dut, vap_id, "he_mubfer", "0"); 4167 owrt_ap_set_vap(dut, vap_id, "he_mubfee", "0"); 4168 } 4169 } 4170 4171 if (dut->ap_tx_stbc) { 4172 /* STBC and beamforming are mutually exclusive features */ 4173 owrt_ap_set_vap(dut, vap_id, "implicitbf", "0"); 4174 } 4175 4176 /* enable dfsmode */ 4177 snprintf(buf, sizeof(buf), "%d", dut->ap_dfs_mode); 4178 owrt_ap_set_vap(dut, vap_id, "doth", buf); 4179 4180 if (dut->program == PROGRAM_LOC && dut->ap_interworking) { 4181 char anqpval[1024]; 4182 4183 owrt_ap_set_vap(dut, vap_id, "interworking", "1"); 4184 4185 if (dut->ap_lci == 1 && strlen(dut->ap_tag_ssid[0]) == 0) { 4186 snprintf(anqpval, sizeof(anqpval), 4187 "'265:0010%s%s060101'", 4188 dut->ap_val_lci, dut->ap_infoz); 4189 owrt_ap_set_list_vap(dut, vap_id, "anqp_elem", anqpval); 4190 } 4191 4192 if (dut->ap_lcr == 1) { 4193 snprintf(anqpval, sizeof(anqpval), 4194 "'266:0000b2555302ae%s'", 4195 dut->ap_val_lcr); 4196 owrt_ap_set_list_vap(dut, vap_id, "anqp_elem", anqpval); 4197 } 4198 4199 if (dut->ap_fqdn_held == 1 && dut->ap_fqdn_supl == 1) 4200 owrt_ap_set_list_vap(dut, vap_id, "anqp_elem", 4201 "'267:00110168656c642e6578616d706c652e636f6d0011027375706c2e6578616d706c652e636f6d'"); 4202 } 4203 4204 if (dut->program == PROGRAM_MBO) { 4205 owrt_ap_set_vap(dut, vap_id, "interworking", "1"); 4206 owrt_ap_set_vap(dut, vap_id, "mbo", "1"); 4207 owrt_ap_set_vap(dut, vap_id, "rrm", "1"); 4208 owrt_ap_set_vap(dut, vap_id, "mbo_cell_conn_pref", "1"); 4209 4210 owrt_ap_set_list_vap(dut, vap_id, "anqp_elem", 4211 "'272:34108cfdf0020df1f7000000733000030101'"); 4212 snprintf(buf, sizeof(buf), "%d", dut->ap_gas_cb_delay); 4213 owrt_ap_set_vap(dut, vap_id, "gas_comeback_delay", buf); 4214 } 4215 4216 if (ap_ft_enabled(dut)) { 4217 unsigned char self_mac[ETH_ALEN]; 4218 char mac_str[20]; 4219 4220 owrt_ap_set_vap(dut, vap_id, "ft_over_ds", 4221 dut->ap_ft_ds == VALUE_ENABLED ? "1" : "0"); 4222 owrt_ap_set_vap(dut, vap_id, "ieee80211r", "1"); 4223 if (get_hwaddr(sigma_radio_ifname[0], self_mac) < 0) 4224 return -1; 4225 snprintf(mac_str, sizeof(mac_str), 4226 "%02x:%02x:%02x:%02x:%02x:%02x", 4227 self_mac[0], self_mac[1], self_mac[2], 4228 self_mac[3], self_mac[4], self_mac[5]); 4229 owrt_ap_set_vap(dut, vap_id, "ap_macaddr", mac_str); 4230 snprintf(mac_str, sizeof(mac_str), 4231 "%02x:%02x:%02x:%02x:%02x:%02x", 4232 self_mac[0], self_mac[1], self_mac[2], 4233 self_mac[3], self_mac[4], self_mac[5]); 4234 owrt_ap_set_vap(dut, vap_id, "r1_key_holder", mac_str); 4235 owrt_ap_set_vap(dut, vap_id, "ft_psk_generate_local", "1"); 4236 owrt_ap_set_vap(dut, vap_id, "kh_key_hex", 4237 "000102030405060708090a0b0c0d0e0f"); 4238 snprintf(mac_str, sizeof(mac_str), 4239 "%02x:%02x:%02x:%02x:%02x:%02x", 4240 dut->ft_bss_mac_list[0][0], 4241 dut->ft_bss_mac_list[0][1], 4242 dut->ft_bss_mac_list[0][2], 4243 dut->ft_bss_mac_list[0][3], 4244 dut->ft_bss_mac_list[0][4], 4245 dut->ft_bss_mac_list[0][5]); 4246 owrt_ap_set_vap(dut, vap_id, "ap2_macaddr", mac_str); 4247 owrt_ap_set_vap(dut, vap_id, "mobility_domain", 4248 dut->ap_mobility_domain); 4249 owrt_ap_set_vap(dut, vap_id, "ap2_r1_key_holder", mac_str); 4250 } 4251 4252 if ((ap_ft_enabled(dut) && dut->ap_name == 0) || 4253 (ap_ft_enabled(dut) && dut->ap_name == 2)) { 4254 owrt_ap_set_vap(dut, vap_id, "nasid2", "nas2.example.com"); 4255 owrt_ap_set_vap(dut, vap_id, "nasid", "nas1.example.com"); 4256 } 4257 4258 if (ap_ft_enabled(dut) && dut->ap_name == 1) { 4259 owrt_ap_set_vap(dut, vap_id, "nasid2", "nas1.example.com"); 4260 owrt_ap_set_vap(dut, vap_id, "nasid", "nas2.example.com"); 4261 } 4262 4263 if (dut->ap_broadcast_ssid == VALUE_DISABLED) 4264 owrt_ap_set_vap(dut, vap_id, "hidden", "1"); 4265 4266 /* Enable/disable PMKSA caching, if asked to */ 4267 if (dut->ap_pmksa == 1) { 4268 snprintf(buf, sizeof(buf), "%d", dut->ap_pmksa_caching); 4269 owrt_ap_set_vap(dut, vap_id, "disable_pmksa_caching", buf); 4270 } 4271 4272 if (dut->ap_beacon_prot) 4273 owrt_ap_set_vap(dut, vap_id, "beacon_prot", "1"); 4274 4275 if (dut->ap_transition_disable) { 4276 snprintf(buf, sizeof(buf), "0x%02x", 4277 dut->ap_transition_disable); 4278 owrt_ap_set_vap(dut, vap_id, "transition_disable", buf); 4279 } 4280 4281 if (dut->rsne_override) { 4282 snprintf(buf, sizeof(buf), "%s", dut->rsne_override); 4283 owrt_ap_set_vap(dut, vap_count, "own_ie_override", buf); 4284 } 4285 4286 if (dut->rsnxe_override_eapol) 4287 owrt_ap_set_vap(dut, vap_count, "rsnxe_override_eapol", 4288 dut->rsnxe_override_eapol); 4289 4290 if (dut->sae_commit_override) { 4291 snprintf(buf, sizeof(buf), "%s", dut->sae_commit_override); 4292 owrt_ap_set_vap(dut, vap_count, "sae_commit_override", buf); 4293 } 4294 4295 if (dut->ap_sae_groups) { 4296 snprintf(buf, sizeof(buf), "\'%s\'", dut->ap_sae_groups); 4297 owrt_ap_set_list_vap(dut, vap_count, "sae_groups", buf); 4298 } 4299 4300 if (dut->sae_pwe != SAE_PWE_DEFAULT || dut->sae_h2e_default) { 4301 const char *sae_pwe = NULL; 4302 4303 if (dut->sae_pwe == SAE_PWE_LOOP && sae_pw_id_used(dut)) 4304 sae_pwe = "3"; 4305 else if (dut->sae_pwe == SAE_PWE_LOOP) 4306 sae_pwe = "0"; 4307 else if (dut->sae_pwe == SAE_PWE_H2E) 4308 sae_pwe = "1"; 4309 else if (dut->sae_h2e_default) 4310 sae_pwe = "2"; 4311 if (sae_pwe) 4312 owrt_ap_set_vap(dut, vap_count, "sae_pwe", sae_pwe); 4313 } 4314 4315 if (dut->sae_anti_clogging_threshold >= 0) { 4316 snprintf(buf, sizeof(buf), "%d", 4317 dut->sae_anti_clogging_threshold); 4318 owrt_ap_set_vap(dut, vap_count, "sae_anti_clogging_threshold", 4319 buf); 4320 } 4321 4322 if (dut->sae_reflection) 4323 owrt_ap_set_vap(dut, vap_count, "sae_reflection_attack", "1"); 4324 if (dut->ap_sae_commit_status >= 0) { 4325 snprintf(buf, sizeof(buf), "%d", dut->ap_sae_commit_status); 4326 owrt_ap_set_vap(dut, vap_count, "sae_commit_status", buf); 4327 } 4328 if (dut->ap_sae_pk_omit) 4329 owrt_ap_set_vap(dut, vap_count, "sae_pk_omit", "1"); 4330 if (dut->sae_confirm_immediate) 4331 owrt_ap_set_vap(dut, vap_count, "sae_confirm_immediate", "2"); 4332 4333 if (dut->ap_he_dlofdma == VALUE_ENABLED && dut->ap_he_ppdu == PPDU_MU) { 4334 dut->ap_txBF = 0; 4335 dut->ap_mu_txBF = 0; 4336 owrt_ap_set_vap(dut, vap_id, "vhtsubfer", "0"); 4337 owrt_ap_set_vap(dut, vap_id, "vhtsubfee", "0"); 4338 owrt_ap_set_vap(dut, vap_id, "he_subfer", "0"); 4339 } 4340 4341 if (dut->program == PROGRAM_HE && 4342 (dut->ap_txBF || dut->ap_he_ulofdma == VALUE_ENABLED || 4343 dut->ap_he_mimo == MIMO_DL)) { 4344 switch (dut->ap_chwidth) { 4345 case AP_20: 4346 owrt_ap_set_vap(dut, vap_id, "chwidth", "0"); 4347 break; 4348 case AP_40: 4349 owrt_ap_set_vap(dut, vap_id, "chwidth", "1"); 4350 break; 4351 case AP_80: 4352 owrt_ap_set_vap(dut, vap_id, "chwidth", "2"); 4353 break; 4354 case AP_160: 4355 owrt_ap_set_vap(dut, vap_id, "chwidth", "3"); 4356 break; 4357 case AP_80_80: 4358 owrt_ap_set_vap(dut, vap_id, "chwidth", "3"); 4359 break; 4360 case AP_AUTO: 4361 default: 4362 break; 4363 } 4364 } 4365 4366 if (dut->ap_ocvc == 1) 4367 owrt_ap_set_vap(dut, vap_count, "ocv", "1"); 4368 else if (dut->ap_ocvc == 0) 4369 owrt_ap_set_vap(dut, vap_count, "ocv", "0"); 4370 4371 return 1; 4372 } 4373 4374 4375 static int owrt_ap_config_vap_anqp(struct sigma_dut *dut) 4376 { 4377 char anqpval[1024]; 4378 unsigned char addr[6]; 4379 unsigned char addr2[6]; 4380 struct ifreq ifr; 4381 char *ifname; 4382 int s; 4383 int vap_id = 0; 4384 4385 s = socket(AF_INET, SOCK_DGRAM, 0); 4386 if (s < 0) { 4387 sigma_dut_print(dut, DUT_MSG_ERROR, "Failed to open socket"); 4388 return -1; 4389 } 4390 4391 memset(&ifr, 0, sizeof(ifr)); 4392 ifname = "ath0"; 4393 strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name)); 4394 if (ioctl(s, SIOCGIFHWADDR, &ifr) < 0) { 4395 perror("ioctl"); 4396 close(s); 4397 return -1; 4398 } 4399 memcpy(addr, ifr.ifr_hwaddr.sa_data, 6); 4400 4401 memset(&ifr, 0, sizeof(ifr)); 4402 ifname = "ath01"; 4403 strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name)); 4404 if (ioctl(s, SIOCGIFHWADDR, &ifr) < 0) { 4405 perror("ioctl"); 4406 close(s); 4407 return -1; 4408 } 4409 close(s); 4410 memcpy(addr2, ifr.ifr_hwaddr.sa_data, 6); 4411 4412 snprintf(anqpval, sizeof(anqpval), 4413 "'265:0010%s%s060101070d00%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x'", 4414 dut->ap_val_lci, dut->ap_infoz, 4415 addr[0], addr[1], addr[2], addr[3], addr[4], addr[5], 4416 addr2[0], addr2[1], addr2[2], addr2[3], addr2[4], addr2[5]); 4417 4418 owrt_ap_set_list_vap(dut, vap_id, "anqp_elem", anqpval); 4419 return 0; 4420 } 4421 4422 4423 static int owrt_ap_post_config_commit(struct sigma_dut *dut, 4424 struct sigma_conn *conn, 4425 struct sigma_cmd *cmd) 4426 { 4427 int ap_security = 0; 4428 int i; 4429 4430 for (i = 0; i < MAX_WLAN_TAGS - 1; i++) { 4431 if (dut->ap_tag_key_mgmt[i] != AP2_OPEN) 4432 ap_security = 1; 4433 } 4434 if (dut->ap_key_mgmt != AP_OPEN) 4435 ap_security = 1; 4436 if (ap_security) { 4437 /* allow some time for hostapd to start before returning 4438 * success */ 4439 usleep(500000); 4440 4441 if (run_hostapd_cli(dut, "ping") != 0) { 4442 send_resp(dut, conn, SIGMA_ERROR, 4443 "errorCode,Failed to talk to hostapd"); 4444 return 0; 4445 } 4446 } 4447 4448 if (get_openwrt_driver_type() == OPENWRT_DRIVER_ATHEROS) 4449 ath_ap_set_params(dut); 4450 4451 /* Send response */ 4452 return 1; 4453 } 4454 4455 4456 static int cmd_owrt_ap_config_commit(struct sigma_dut *dut, 4457 struct sigma_conn *conn, 4458 struct sigma_cmd *cmd) 4459 { 4460 if (dut->program == PROGRAM_DPP && 4461 get_driver_type(dut) == DRIVER_OPENWRT) { 4462 wpa_command(dut->hostapd_ifname, "DPP_BOOTSTRAP_REMOVE *"); 4463 wpa_command(dut->hostapd_ifname, "DPP_PKEX_REMOVE *"); 4464 } 4465 4466 /* Stop the AP */ 4467 run_system(dut, "wifi down"); 4468 4469 /* Reset the wireless configuration */ 4470 run_system(dut, "rm -rf /etc/config/wireless"); 4471 switch (get_openwrt_driver_type()) { 4472 case OPENWRT_DRIVER_ATHEROS: 4473 run_system(dut, "wifi detect qcawifi > /etc/config/wireless"); 4474 break; 4475 default: 4476 run_system(dut, "wifi detect > /etc/config/wireless"); 4477 break; 4478 } 4479 4480 /* Configure Radio & VAP, commit the config */ 4481 if (owrt_ap_config_radio(dut) < 0) 4482 return ERROR_SEND_STATUS; 4483 if (owrt_ap_config_vap(dut) < 0) 4484 return ERROR_SEND_STATUS; 4485 run_system(dut, "uci commit"); 4486 4487 /* Start AP */ 4488 run_system(dut, "wifi up"); 4489 if (dut->program != PROGRAM_MBO && 4490 dut->ap_lci == 1 && dut->ap_interworking && 4491 strlen(dut->ap_tag_ssid[0]) > 0) { 4492 /* 4493 * MBO has a different ANQP element value which is set in 4494 * owrt_ap_config_vap(). 4495 */ 4496 owrt_ap_config_vap_anqp(dut); 4497 run_system(dut, "uci commit"); 4498 run_system(dut, "wifi"); 4499 } 4500 4501 return owrt_ap_post_config_commit(dut, conn, cmd); 4502 } 4503 4504 4505 static void cmd_owrt_ap_hs2_reset(struct sigma_dut *dut) 4506 { 4507 unsigned char bssid[6]; 4508 char buf[100]; 4509 char *ifname, *radio_name; 4510 int vap_id = 0; 4511 4512 if (sigma_radio_ifname[0] && 4513 strcmp(sigma_radio_ifname[0], "wifi2") == 0) { 4514 ifname = "ath2"; 4515 radio_name = "wifi2"; 4516 vap_id = 2; 4517 } else if (sigma_radio_ifname[0] && 4518 strcmp(sigma_radio_ifname[0], "wifi1") == 0) { 4519 ifname = "ath1"; 4520 radio_name = "wifi1"; 4521 vap_id = 1; 4522 } else { 4523 ifname = "ath0"; 4524 radio_name = "wifi0"; 4525 vap_id = 0; 4526 } 4527 4528 if (!get_hwaddr(ifname, bssid)) { 4529 snprintf(buf, sizeof(buf), "%s", bssid); 4530 owrt_ap_set_vap(dut, vap_id, "hessid", buf); 4531 snprintf(dut->ap_hessid, sizeof(dut->ap_hessid), 4532 "%02x:%02x:%02x:%02x:%02x:%02x", 4533 bssid[0], bssid[1], bssid[2], bssid[3], 4534 bssid[4], bssid[5]); 4535 } else { 4536 if (!get_hwaddr(radio_name, bssid)) { 4537 snprintf(buf, sizeof(buf), "%s", dut->ap_hessid); 4538 owrt_ap_set_vap(dut, vap_id, "hessid", buf); 4539 snprintf(dut->ap_hessid, sizeof(dut->ap_hessid), 4540 "%02x:%02x:%02x:%02x:%02x:%02x", 4541 bssid[0], bssid[1], bssid[2], bssid[3], 4542 bssid[4], bssid[5]); 4543 } else { 4544 /* Select & enable/disable radios */ 4545 if (sigma_radio_ifname[0] && 4546 strcmp(sigma_radio_ifname[0], "wifi2") == 0) { 4547 /* We want to use wifi2 */ 4548 owrt_ap_set_radio(dut, 0, "disabled", "1"); 4549 owrt_ap_set_radio(dut, 1, "disabled", "1"); 4550 owrt_ap_set_radio(dut, 2, "disabled", "0"); 4551 owrt_ap_set_vap(dut, vap_id, "device", "wifi2"); 4552 } else if (sigma_radio_ifname[0] && 4553 strcmp(sigma_radio_ifname[0], "wifi1") == 0) { 4554 /* We want to use wifi1 */ 4555 owrt_ap_set_radio(dut, 0, "disabled", "1"); 4556 owrt_ap_set_radio(dut, 1, "disabled", "0"); 4557 owrt_ap_set_vap(dut, vap_id, "device", "wifi1"); 4558 } else { 4559 /* We want to use wifi0 */ 4560 owrt_ap_set_radio(dut, 0, "disabled", "0"); 4561 owrt_ap_set_radio(dut, 1, "disabled", "1"); 4562 owrt_ap_set_vap(dut, vap_id, "device", "wifi0"); 4563 } 4564 4565 run_system(dut, "uci commit"); 4566 run_system(dut, "wifi up"); 4567 4568 if (!get_hwaddr(radio_name, bssid)) { 4569 snprintf(buf, sizeof(buf), "%s", 4570 dut->ap_hessid); 4571 owrt_ap_set_vap(dut, vap_id, "hessid", buf); 4572 snprintf(dut->ap_hessid, sizeof(dut->ap_hessid), 4573 "%02x:%02x:%02x:%02x:%02x:%02x", 4574 bssid[0], bssid[1], bssid[2], bssid[3], 4575 bssid[4], bssid[5]); 4576 } 4577 } 4578 } 4579 } 4580 4581 4582 static enum sigma_cmd_result cmd_ap_reboot(struct sigma_dut *dut, 4583 struct sigma_conn *conn, 4584 struct sigma_cmd *cmd) 4585 { 4586 switch (get_driver_type(dut)) { 4587 case DRIVER_ATHEROS: 4588 run_system(dut, "apdown"); 4589 sleep(1); 4590 run_system(dut, "reboot"); 4591 break; 4592 case DRIVER_OPENWRT: 4593 run_system(dut, "wifi down"); 4594 sleep(1); 4595 run_system(dut, "reboot"); 4596 break; 4597 default: 4598 sigma_dut_print(dut, DUT_MSG_INFO, "Ignore ap_reboot command"); 4599 break; 4600 } 4601 4602 return 1; 4603 } 4604 4605 4606 int ascii2hexstr(const char *str, char *hex) 4607 { 4608 int i, length; 4609 4610 length = strlen(str); 4611 4612 for (i = 0; i < length; i++) 4613 snprintf(hex + i * 2, 3, "%X", str[i]); 4614 4615 hex[length * 2] = '\0'; 4616 return 1; 4617 } 4618 4619 4620 static int kill_process(struct sigma_dut *dut, char *proc_name, 4621 unsigned char is_proc_instance_one, int sig) 4622 { 4623 #ifdef __linux__ 4624 struct dirent *dp, *dp_in; 4625 const char *direc = "/proc/"; 4626 char buf[100]; 4627 DIR *dir = opendir(direc); 4628 DIR *dir_in; 4629 FILE *fp; 4630 char *pid, *temp; 4631 char *saveptr; 4632 int ret = -1, res; 4633 4634 if (dir == NULL) 4635 return ret; 4636 4637 while ((dp = readdir(dir)) != NULL) { 4638 if (dp->d_type != DT_DIR) 4639 continue; 4640 4641 res = snprintf(buf, sizeof(buf), "%s%s", direc, dp->d_name); 4642 if (res < 0 || res >= sizeof(buf)) 4643 continue; 4644 dir_in = opendir(buf); 4645 if (dir_in == NULL) 4646 continue; 4647 dp_in = readdir(dir_in); 4648 closedir(dir_in); 4649 if (dp_in == NULL) 4650 continue; 4651 res = snprintf(buf, sizeof(buf), "%s%s/stat", 4652 direc, dp->d_name); 4653 if (res < 0 || res >= sizeof(buf)) 4654 continue; 4655 fp = fopen(buf, "r"); 4656 if (fp == NULL) 4657 continue; 4658 if (fgets(buf, 100, fp) == NULL) 4659 buf[0] = '\0'; 4660 fclose(fp); 4661 pid = strtok_r(buf, " ", &saveptr); 4662 temp = strtok_r(NULL, " ", &saveptr); 4663 if (pid && temp && 4664 strncmp(temp, proc_name, strlen(proc_name)) == 0) { 4665 sigma_dut_print(dut, DUT_MSG_INFO, 4666 "killing %s process with PID %s", 4667 proc_name, pid); 4668 snprintf(buf, sizeof(buf), "kill -%d %d", sig, 4669 atoi(pid)); 4670 run_system(dut, buf); 4671 ret = 0; 4672 if (is_proc_instance_one) 4673 break; 4674 } 4675 } 4676 4677 closedir(dir); 4678 4679 return ret; 4680 #else /* __linux__ */ 4681 return -1; 4682 #endif /* __linux__ */ 4683 } 4684 4685 4686 static int run_ndc(struct sigma_dut *dut, char *buf) 4687 { 4688 sigma_dut_print(dut, DUT_MSG_INFO, "CMD NDC:: %s", buf); 4689 sleep(2); 4690 return run_system(dut, buf); 4691 } 4692 4693 4694 static int sigma_write_cfg(struct sigma_dut *dut, const char *pfile, 4695 const char *field, const char *value) 4696 { 4697 FILE *fcfg, *ftmp; 4698 char buf[MAX_CONF_LINE_LEN + 1]; 4699 int len, found = 0, res; 4700 4701 /* Open the configuration file */ 4702 fcfg = fopen(pfile, "r"); 4703 if (!fcfg) { 4704 sigma_dut_print(dut, DUT_MSG_ERROR, 4705 "Failed to open hostapd conf file"); 4706 return -1; 4707 } 4708 4709 snprintf(buf, sizeof(buf), "%s~", pfile); 4710 /* Open a temporary file */ 4711 ftmp = fopen(buf, "w+"); 4712 if (!ftmp) { 4713 fclose(fcfg); 4714 sigma_dut_print(dut, DUT_MSG_ERROR, 4715 "Failed to open temp buf"); 4716 return -1; 4717 } 4718 4719 /* Read the values from the configuration file */ 4720 len = strlen(field); 4721 while (fgets(buf, MAX_CONF_LINE_LEN, fcfg)) { 4722 char *pline = buf; 4723 4724 /* commented line */ 4725 if (buf[0] == '#') 4726 pline++; 4727 4728 /* Identify the configuration parameter to be updated */ 4729 if (!found && strncmp(pline, field, len) == 0 && 4730 pline[len] == '=') { 4731 snprintf(buf, sizeof(buf), "%s=%s\n", field, value); 4732 found = 1; 4733 sigma_dut_print(dut, DUT_MSG_INFO, 4734 "Updated hostapd conf file"); 4735 } 4736 4737 fprintf(ftmp, "%s", buf); 4738 } 4739 4740 if (!found) { 4741 /* Configuration line not found */ 4742 /* Add the new line at the end of file */ 4743 fprintf(ftmp, "%s=%s\n", field, value); 4744 sigma_dut_print(dut, DUT_MSG_INFO, 4745 "Adding a new line in hostapd conf file"); 4746 } 4747 4748 fclose(fcfg); 4749 fclose(ftmp); 4750 4751 snprintf(buf, sizeof(buf), "%s~", pfile); 4752 4753 /* Restore the updated configuration file */ 4754 res = rename(buf, pfile); 4755 4756 /* Remove the temporary file. Ignore the return value */ 4757 unlink(buf); 4758 4759 /* chmod is needed because open() may not set permissions properly 4760 * depending on the current umask */ 4761 if (chmod(pfile, 0660) < 0) { 4762 unlink(pfile); 4763 sigma_dut_print(dut, DUT_MSG_ERROR, 4764 "Error changing permissions"); 4765 return -1; 4766 } 4767 4768 if (res < 0) { 4769 sigma_dut_print(dut, DUT_MSG_ERROR, 4770 "Error restoring conf file"); 4771 return -1; 4772 } 4773 4774 return 0; 4775 } 4776 4777 4778 static int cmd_wcn_ap_config_commit(struct sigma_dut *dut, 4779 struct sigma_conn *conn, 4780 struct sigma_cmd *cmd) 4781 { 4782 char buf[100]; 4783 struct stat s; 4784 int num_tries = 0, ret; 4785 4786 if (kill_process(dut, "(netd)", 1, SIGKILL) == 0 || 4787 system("killall netd") == 0) { 4788 /* Avoid Error: Error connecting (Connection refused) 4789 * Wait some time to allow netd to reinitialize. 4790 */ 4791 usleep(1500000); 4792 } 4793 4794 while (num_tries < 10) { 4795 ret = run_ndc(dut, "ndc softap stopap"); 4796 num_tries++; 4797 if (WIFEXITED(ret)) 4798 ret = WEXITSTATUS(ret); 4799 /* On success, NDC exits with 0 */ 4800 if (ret == 0) 4801 break; 4802 sigma_dut_print(dut, DUT_MSG_INFO, 4803 "Try No. %d: ndc softap stopap failed, exit code %d", 4804 num_tries, ret); 4805 } 4806 4807 if (ret != 0) 4808 sigma_dut_print(dut, DUT_MSG_ERROR, 4809 "ndc softap stopap command failed for 10 times - giving up"); 4810 4811 #ifdef ANDROID 4812 /* Unload/Load driver to cleanup the state of the driver */ 4813 system("rmmod -f wlan"); 4814 usleep(500000); 4815 system("insmod /system/lib/modules/wlan.ko"); 4816 #else /* ANDROID */ 4817 run_ndc(dut, "ndc softap qccmd set enable_softap=0"); 4818 run_ndc(dut, "ndc softap qccmd set enable_softap=1"); 4819 #endif /* ANDROID */ 4820 4821 switch (dut->ap_mode) { 4822 case AP_11g: 4823 run_ndc(dut, "ndc softap qccmd set hw_mode=g-only"); 4824 break; 4825 case AP_11b: 4826 run_ndc(dut, "ndc softap qccmd set hw_mode=b-only"); 4827 break; 4828 case AP_11ng: 4829 run_ndc(dut, "ndc softap qccmd set hw_mode=n"); 4830 break; 4831 case AP_11a: 4832 run_ndc(dut, "ndc softap qccmd set hw_mode=a-only"); 4833 break; 4834 case AP_11na: 4835 run_ndc(dut, "ndc softap qccmd set hw_mode=n"); 4836 break; 4837 case AP_11ac: 4838 run_ndc(dut, "ndc softap qccmd set hw_mode=ac"); 4839 break; 4840 default: 4841 break; 4842 } 4843 4844 snprintf(buf, sizeof(buf), "ndc softap qccmd set channel=%d", 4845 dut->ap_channel); 4846 run_ndc(dut, buf); 4847 4848 /* 4849 * ndc doesn't support double quotes as SSID string, so re-write 4850 * hostapd configuration file to update SSID. 4851 */ 4852 if (dut->ap_ssid[0] != '\0') 4853 sigma_write_cfg(dut, ANDROID_CONFIG_FILE, "ssid", dut->ap_ssid); 4854 4855 switch (dut->ap_key_mgmt) { 4856 case AP_OPEN: 4857 if (dut->ap_cipher == AP_WEP) { 4858 run_ndc(dut, "ndc softap qccmd set security_mode=1"); 4859 snprintf(buf, sizeof(buf), 4860 "ndc softap qccmd set wep_key0=%s", 4861 dut->ap_wepkey); 4862 run_ndc(dut, buf); 4863 } else { 4864 run_ndc(dut, "ndc softap qccmd set security_mode=0"); 4865 } 4866 break; 4867 case AP_WPA2_PSK: 4868 case AP_WPA2_PSK_MIXED: 4869 case AP_WPA_PSK: 4870 if (dut->ap_key_mgmt == AP_WPA2_PSK) 4871 run_ndc(dut, "ndc softap qccmd set security_mode=3"); 4872 else if (dut->ap_key_mgmt == AP_WPA2_PSK_MIXED) 4873 run_ndc(dut, "ndc softap qccmd set security_mode=4"); 4874 else 4875 run_ndc(dut, "ndc softap qccmd set security_mode=2"); 4876 4877 /* 4878 * ndc doesn't support some special characters as passphrase, 4879 * so re-write hostapd configuration file to update Passphrase. 4880 */ 4881 if (dut->ap_passphrase[0] != '\0') 4882 sigma_write_cfg(dut, ANDROID_CONFIG_FILE, 4883 "wpa_passphrase", dut->ap_passphrase); 4884 4885 if (dut->ap_cipher == AP_CCMP_TKIP) 4886 run_ndc(dut, "ndc softap qccmd set wpa_pairwise=" 4887 "TKIP CCMP"); 4888 else if (dut->ap_cipher == AP_TKIP) 4889 run_ndc(dut, "ndc softap qccmd set wpa_pairwise=" 4890 "TKIP"); 4891 else 4892 run_ndc(dut, "ndc softap qccmd set wpa_pairwise=" 4893 "CCMP &"); 4894 break; 4895 case AP_WPA2_SAE: 4896 case AP_WPA2_PSK_SAE: 4897 case AP_WPA2_EAP: 4898 case AP_WPA2_EAP_MIXED: 4899 case AP_WPA_EAP: 4900 case AP_SUITEB: 4901 case AP_WPA2_OWE: 4902 case AP_WPA2_EAP_OSEN: 4903 case AP_OSEN: 4904 case AP_WPA2_FT_EAP: 4905 case AP_WPA2_FT_PSK: 4906 case AP_WPA2_EAP_SHA256: 4907 case AP_WPA2_PSK_SHA256: 4908 case AP_WPA2_ENT_FT_EAP: 4909 /* Not supported */ 4910 break; 4911 } 4912 4913 switch (dut->ap_pmf) { 4914 case AP_PMF_DISABLED: 4915 run_ndc(dut, "ndc softap qccmd set ieee80211w=0"); 4916 break; 4917 case AP_PMF_OPTIONAL: 4918 run_ndc(dut, "ndc softap qccmd set ieee80211w=1"); 4919 if (dut->ap_add_sha256) 4920 run_ndc(dut, "ndc softap qccmd set wpa_key_mgmt=WPA-PSK WPA-PSK-SHA256"); 4921 else 4922 run_ndc(dut, "ndc softap qccmd set wpa_key_mgmt=WPA-PSK"); 4923 break; 4924 case AP_PMF_REQUIRED: 4925 run_ndc(dut, "ndc softap qccmd set ieee80211w=2"); 4926 run_ndc(dut, "ndc softap qccmd set wpa_key_mgmt=WPA-PSK-SHA256"); 4927 break; 4928 } 4929 4930 if (dut->ap_countrycode[0]) { 4931 snprintf(buf, sizeof(buf), 4932 "ndc softap qccmd set country_code=%s", 4933 dut->ap_countrycode); 4934 run_ndc(dut, buf); 4935 } 4936 4937 if (dut->ap_regulatory_mode == AP_80211D_MODE_ENABLED) 4938 run_ndc(dut, "ndc softap qccmd set ieee80211d=1"); 4939 4940 if (dut->ap_dfs_mode == AP_DFS_MODE_ENABLED) 4941 run_ndc(dut, "ndc softap qccmd set ieee80211h=1"); 4942 4943 run_ndc(dut, "ndc softap startap"); 4944 4945 snprintf(buf, sizeof(buf), "%s%s", sigma_wpas_ctrl, 4946 get_main_ifname(dut)); 4947 num_tries = 0; 4948 while (num_tries < 10 && (ret = stat(buf, &s) != 0)) { 4949 run_ndc(dut, "ndc softap stopap"); 4950 run_ndc(dut, "ndc softap startap"); 4951 num_tries++; 4952 } 4953 4954 if (num_tries == 10) { 4955 sigma_dut_print(dut, DUT_MSG_INFO, "Tried 10 times with ctrl " 4956 "iface %s :: reboot the APDUT", buf); 4957 return ret; 4958 } 4959 4960 sigma_dut_print(dut, DUT_MSG_INFO, "setting ip addr %s mask %s", 4961 ap_inet_addr, ap_inet_mask); 4962 snprintf(buf, sizeof(buf), "ifconfig %s %s netmask %s up", 4963 get_main_ifname(dut), ap_inet_addr, ap_inet_mask); 4964 if (system(buf) != 0) { 4965 sigma_dut_print(dut, DUT_MSG_ERROR, 4966 "Failed to intialize the interface"); 4967 return -1; 4968 } 4969 4970 return 1; 4971 } 4972 4973 4974 static int append_hostapd_conf_hs2(struct sigma_dut *dut, FILE *f) 4975 { 4976 fprintf(f, "hs20=1\nhs20_deauth_req_timeout=3\n" 4977 "disable_dgaf=%d\n", dut->ap_dgaf_disable); 4978 4979 if (dut->ap_oper_name) { 4980 fprintf(f, "hs20_oper_friendly_name=eng:Wi-Fi Alliance\n"); 4981 fprintf(f, "hs20_oper_friendly_name=chi:Wi-Fi\xe8\x81\x94\xe7\x9b\x9f\n"); 4982 } 4983 4984 if (dut->ap_wan_metrics == 1) 4985 fprintf(f, "hs20_wan_metrics=01:2500:384:0:0:10\n"); 4986 else if (dut->ap_wan_metrics == 2) 4987 fprintf(f, "hs20_wan_metrics=01:1500:384:20:20:10\n"); 4988 else if (dut->ap_wan_metrics == 3) 4989 fprintf(f, "hs20_wan_metrics=01:2000:1000:20:20:10\n"); 4990 else if (dut->ap_wan_metrics == 4) 4991 fprintf(f, "hs20_wan_metrics=01:8000:1000:20:20:10\n"); 4992 else if (dut->ap_wan_metrics == 5) 4993 fprintf(f, "hs20_wan_metrics=01:9000:5000:20:20:10\n"); 4994 4995 if (dut->ap_conn_capab == 1) { 4996 fprintf(f, "hs20_conn_capab=1:0:0\n"); 4997 fprintf(f, "hs20_conn_capab=6:20:1\n"); 4998 fprintf(f, "hs20_conn_capab=6:22:0\n"); 4999 fprintf(f, "hs20_conn_capab=6:80:1\n"); 5000 fprintf(f, "hs20_conn_capab=6:443:1\n"); 5001 fprintf(f, "hs20_conn_capab=6:1723:0\n"); 5002 fprintf(f, "hs20_conn_capab=6:5060:0\n"); 5003 fprintf(f, "hs20_conn_capab=17:500:1\n"); 5004 fprintf(f, "hs20_conn_capab=17:5060:0\n"); 5005 fprintf(f, "hs20_conn_capab=17:4500:1\n"); 5006 fprintf(f, "hs20_conn_capab=50:0:1\n"); 5007 } else if (dut->ap_conn_capab == 2) { 5008 fprintf(f, "hs20_conn_capab=6:80:1\n"); 5009 fprintf(f, "hs20_conn_capab=6:443:1\n"); 5010 fprintf(f, "hs20_conn_capab=17:5060:1\n"); 5011 fprintf(f, "hs20_conn_capab=6:5060:1\n"); 5012 } else if (dut->ap_conn_capab == 3) { 5013 fprintf(f, "hs20_conn_capab=6:80:1\n"); 5014 fprintf(f, "hs20_conn_capab=6:443:1\n"); 5015 } else if (dut->ap_conn_capab == 4) { 5016 fprintf(f, "hs20_conn_capab=6:80:1\n"); 5017 fprintf(f, "hs20_conn_capab=6:443:1\n"); 5018 fprintf(f, "hs20_conn_capab=6:5060:1\n"); 5019 fprintf(f, "hs20_conn_capab=17:5060:1\n"); 5020 } 5021 5022 if (dut->ap_oper_class == 1) 5023 fprintf(f, "hs20_operating_class=51\n"); 5024 else if (dut->ap_oper_class == 2) 5025 fprintf(f, "hs20_operating_class=73\n"); 5026 else if (dut->ap_oper_class == 3) 5027 fprintf(f, "hs20_operating_class=5173\n"); 5028 5029 if (dut->ap_osu_provider_list) { 5030 char *osu_friendly_name = NULL; 5031 char *osu_icon = NULL; 5032 char *osu_ssid = NULL; 5033 char *osu_nai = NULL; 5034 char *osu_nai2 = NULL; 5035 char *osu_service_desc = NULL; 5036 char *hs20_icon_filename = NULL; 5037 char hs20_icon[150]; 5038 int osu_method; 5039 5040 hs20_icon_filename = "icon_red_zxx.png"; 5041 if (dut->ap_osu_icon_tag == 2) 5042 hs20_icon_filename = "wifi-abgn-logo_270x73.png"; 5043 snprintf(hs20_icon, sizeof(hs20_icon), 5044 "128:61:zxx:image/png:icon_red_zxx.png:/etc/ath/%s", 5045 hs20_icon_filename); 5046 osu_icon = "icon_red_zxx.png"; 5047 osu_ssid = "OSU"; 5048 osu_friendly_name = "kor:SP 빨강 테스트 전용"; 5049 osu_service_desc = "kor:테스트 목적으로 무료 서비스"; 5050 osu_method = (dut->ap_osu_method[0] == 0xFF) ? 1 : dut->ap_osu_method[0]; 5051 5052 if (strlen(dut->ap_osu_server_uri[0])) 5053 fprintf(f, "osu_server_uri=%s\n", dut->ap_osu_server_uri[0]); 5054 else 5055 fprintf(f, "osu_server_uri=https://osu-server.r2-testbed.wi-fi.org/\n"); 5056 5057 switch (dut->ap_osu_provider_list) { 5058 case 1: 5059 case 101: 5060 fprintf(f, "osu_friendly_name=eng:SP Red Test Only\n"); 5061 fprintf(f, "osu_service_desc=eng:Free service for test purpose\n"); 5062 hs20_icon_filename = "icon_red_eng.png"; 5063 if (dut->ap_osu_icon_tag == 2) 5064 hs20_icon_filename = "wifi-abgn-logo_270x73.png"; 5065 fprintf(f, "hs20_icon=160:76:eng:image/png:icon_red_eng.png:/etc/ath/%s\n", 5066 hs20_icon_filename); 5067 fprintf(f, "osu_icon=icon_red_eng.png\n"); 5068 break; 5069 case 2: 5070 case 102: 5071 fprintf(f, "osu_friendly_name=eng:Wireless Broadband Alliance\n"); 5072 fprintf(f, "osu_service_desc=eng:Free service for test purpose\n"); 5073 hs20_icon_filename = "icon_orange_zxx.png"; 5074 if (dut->ap_osu_icon_tag == 2) 5075 hs20_icon_filename = "wifi-abgn-logo_270x73.png"; 5076 snprintf(hs20_icon, sizeof(hs20_icon), 5077 "128:61:zxx:image/png:icon_orange_zxx.png:/etc/ath/%s", 5078 hs20_icon_filename); 5079 osu_icon = "icon_orange_zxx.png"; 5080 osu_friendly_name = "kor:와이어리스 브로드밴드 얼라이언스"; 5081 break; 5082 case 3: 5083 case 103: 5084 osu_friendly_name = "spa:SP Red Test Only"; 5085 osu_service_desc = "spa:Free service for test purpose"; 5086 break; 5087 case 4: 5088 case 104: 5089 fprintf(f, "osu_friendly_name=eng:SP Orange Test Only\n"); 5090 fprintf(f, "osu_service_desc=eng:Free service for test purpose\n"); 5091 hs20_icon_filename = "icon_orange_eng.png"; 5092 if (dut->ap_osu_icon_tag == 2) 5093 hs20_icon_filename = "wifi-abgn-logo_270x73.png"; 5094 fprintf(f, "hs20_icon=160:76:eng:image/png:icon_orange_eng.png:/etc/ath/%s\n", 5095 hs20_icon_filename); 5096 fprintf(f, "osu_icon=icon_orange_eng.png\n"); 5097 osu_friendly_name = "kor:SP 오렌지 테스트 전용"; 5098 5099 hs20_icon_filename = "icon_orange_zxx.png"; 5100 if (dut->ap_osu_icon_tag == 2) 5101 hs20_icon_filename = "wifi-abgn-logo_270x73.png"; 5102 snprintf(hs20_icon, sizeof(hs20_icon), 5103 "128:61:zxx:image/png:icon_orange_zxx.png:/etc/ath/%s", 5104 hs20_icon_filename); 5105 osu_icon = "icon_orange_zxx.png"; 5106 break; 5107 case 5: 5108 case 105: 5109 fprintf(f, "osu_friendly_name=eng:SP Orange Test Only\n"); 5110 fprintf(f, "osu_service_desc=eng:Free service for test purpose\n"); 5111 osu_friendly_name = "kor:SP 오렌지 테스트 전용"; 5112 hs20_icon_filename = "icon_orange_zxx.png"; 5113 if (dut->ap_osu_icon_tag == 2) 5114 hs20_icon_filename = "wifi-abgn-logo_270x73.png"; 5115 snprintf(hs20_icon, sizeof(hs20_icon), 5116 "128:61:zxx:image/png:icon_orange_zxx.png:/etc/ath/%s", 5117 hs20_icon_filename); 5118 osu_icon = "icon_orange_zxx.png"; 5119 break; 5120 case 6: 5121 case 106: 5122 fprintf(f, "osu_friendly_name=eng:SP Green Test Only\n"); 5123 fprintf(f, "osu_friendly_name=kor:SP 초록 테스트 전용\n"); 5124 hs20_icon_filename = "icon_green_zxx.png"; 5125 if (dut->ap_osu_icon_tag == 2) 5126 hs20_icon_filename = "wifi-abgn-logo_270x73.png"; 5127 fprintf(f, "hs20_icon=128:61:zxx:image/png:icon_green_zxx.png:/etc/ath/%s\n", 5128 hs20_icon_filename); 5129 fprintf(f, "osu_icon=icon_green_zxx.png\n"); 5130 osu_method = (dut->ap_osu_method[0] == 0xFF) ? 0 : dut->ap_osu_method[0]; 5131 fprintf(f, "osu_method_list=%d\n", osu_method); 5132 5133 if (strlen(dut->ap_osu_server_uri[1])) 5134 fprintf(f, "osu_server_uri=%s\n", dut->ap_osu_server_uri[1]); 5135 else 5136 fprintf(f, "osu_server_uri=https://osu-server.r2-testbed.wi-fi.org/\n"); 5137 fprintf(f, "osu_friendly_name=eng:SP Orange Test Only\n"); 5138 hs20_icon_filename = "icon_orange_zxx.png"; 5139 if (dut->ap_osu_icon_tag == 2) 5140 hs20_icon_filename = "wifi-abgn-logo_270x73.png"; 5141 snprintf(hs20_icon, sizeof(hs20_icon), 5142 "128:61:zxx:image/png:icon_orange_zxx.png:/etc/ath/%s", 5143 hs20_icon_filename); 5144 osu_icon = "icon_orange_zxx.png"; 5145 osu_friendly_name = "kor:SP 오렌지 테스트 전용"; 5146 osu_method = (dut->ap_osu_method[1] == 0xFF) ? 0 : dut->ap_osu_method[1]; 5147 osu_service_desc = NULL; 5148 break; 5149 case 7: 5150 case 107: 5151 fprintf(f, "osu_friendly_name=eng:SP Green Test Only\n"); 5152 fprintf(f, "osu_service_desc=eng:Free service for test purpose\n"); 5153 hs20_icon_filename = "icon_green_eng.png"; 5154 if (dut->ap_osu_icon_tag == 2) 5155 hs20_icon_filename = "wifi-abgn-logo_270x73.png"; 5156 fprintf(f, "hs20_icon=160:76:eng:image/png:icon_green_eng.png:/etc/ath/%s\n", 5157 hs20_icon_filename); 5158 fprintf(f, "osu_icon=icon_green_eng.png\n"); 5159 osu_friendly_name = "kor:SP 초록 테스트 전용"; 5160 5161 hs20_icon_filename = "icon_green_zxx.png"; 5162 if (dut->ap_osu_icon_tag == 2) 5163 hs20_icon_filename = "wifi-abgn-logo_270x73.png"; 5164 snprintf(hs20_icon, sizeof(hs20_icon), 5165 "128:61:zxx:image/png:icon_green_zxx.png:/etc/ath/%s", 5166 hs20_icon_filename); 5167 osu_icon = "icon_green_zxx.png"; 5168 break; 5169 case 8: 5170 case 108: 5171 fprintf(f, "osu_friendly_name=eng:SP Red Test Only\n"); 5172 fprintf(f, "osu_service_desc=eng:Free service for test purpose\n"); 5173 osu_ssid = "OSU-Encrypted"; 5174 osu_nai = "anonymous@hotspot.net"; 5175 break; 5176 case 9: 5177 case 109: 5178 osu_ssid = "OSU-OSEN"; 5179 osu_nai = "test-anonymous@wi-fi.org"; 5180 osu_friendly_name = "eng:SP Orange Test Only"; 5181 hs20_icon_filename = "icon_orange_zxx.png"; 5182 if (dut->ap_osu_icon_tag == 2) 5183 hs20_icon_filename = "wifi-abgn-logo_270x73.png"; 5184 snprintf(hs20_icon, sizeof(hs20_icon), 5185 "128:61:zxx:image/png:icon_orange_zxx.png:/etc/ath/%s", 5186 hs20_icon_filename); 5187 osu_icon = "icon_orange_zxx.png"; 5188 osu_method = (dut->ap_osu_method[0] == 0xFF) ? 1 : dut->ap_osu_method[0]; 5189 osu_service_desc = NULL; 5190 break; 5191 case 10: 5192 case 110: 5193 /* OSU Provider #1 */ 5194 fprintf(f, "osu_friendly_name=eng:SP Orange Test Only\n"); 5195 fprintf(f, "osu_friendly_name=kor:SP 오렌지 테스트 전용\n"); 5196 fprintf(f, "hs20_icon=128:61:zxx:image/png:icon_orange_zxx.png:/etc/ath/icon_orange_zxx.png\n"); 5197 fprintf(f, "osu_icon=icon_orange_zxx.png\n"); 5198 osu_method = (dut->ap_osu_method[0] == 0xFF) ? 5199 1 : dut->ap_osu_method[0]; 5200 fprintf(f, "osu_method_list=%d\n", osu_method); 5201 fprintf(f, "osu_nai=test-anonymous@wi-fi.org\n"); 5202 switch (dut->ap_osu_provider_nai_list) { 5203 case 3: 5204 fprintf(f, 5205 "osu_nai2=test-anonymous@wi-fi.org\n"); 5206 break; 5207 case 4: 5208 fprintf(f, "osu_nai2=random@hotspot.net\n"); 5209 break; 5210 } 5211 5212 /* OSU Provider #2 */ 5213 /* SP Red from defaults */ 5214 if (strlen(dut->ap_osu_server_uri[1])) 5215 fprintf(f, "osu_server_uri=%s\n", dut->ap_osu_server_uri[1]); 5216 else 5217 fprintf(f, "osu_server_uri=https://osu-server.r2-testbed.wi-fi.org/\n"); 5218 fprintf(f, "osu_friendly_name=eng:SP Red Test Only\n"); 5219 snprintf(hs20_icon, sizeof(hs20_icon), 5220 "128:61:zxx:image/png:icon_red_zxx.png:/etc/ath/icon_red_zxx.png"); 5221 osu_method = (dut->ap_osu_method[1] == 0xFF) ? 5222 1 : dut->ap_osu_method[1]; 5223 osu_service_desc = NULL; 5224 osu_nai = "anonymous@hotspot.net"; 5225 break; 5226 default: 5227 break; 5228 } 5229 5230 switch (dut->ap_osu_provider_nai_list) { 5231 case 1: 5232 osu_nai2 = "anonymous@hotspot.net"; 5233 break; 5234 case 2: 5235 osu_nai2 = "test-anonymous@wi-fi.org"; 5236 break; 5237 case 3: 5238 /* OSU Provider NAI #1 written above */ 5239 /* OSU Provider NAI #2 */ 5240 osu_nai2 = "anonymous@hotspot.net"; 5241 break; 5242 case 4: 5243 /* OSU Provider NAI #1 written above */ 5244 /* OSU Provider NAI #2 */ 5245 osu_nai2 = "anonymous@hotspot.net"; 5246 break; 5247 } 5248 5249 if (strlen(dut->ap_osu_ssid)) { 5250 if (dut->ap_tag_ssid[0][0] && 5251 strcmp(dut->ap_tag_ssid[0], dut->ap_osu_ssid) && 5252 strcmp(dut->ap_tag_ssid[0], osu_ssid)) { 5253 sigma_dut_print(dut, DUT_MSG_ERROR, 5254 "OSU_SSID and " 5255 "WLAN_TAG2 SSID differ"); 5256 return -2; 5257 } 5258 fprintf(f, "osu_ssid=\"%s\"\n", dut->ap_osu_ssid); 5259 } else 5260 fprintf(f, "osu_ssid=\"%s\"\n", osu_ssid); 5261 5262 5263 if (osu_friendly_name) 5264 fprintf(f, "osu_friendly_name=%s\n", osu_friendly_name); 5265 5266 if (osu_service_desc) 5267 fprintf(f, "osu_service_desc=%s\n", osu_service_desc); 5268 5269 if (osu_nai) 5270 fprintf(f, "osu_nai=%s\n", osu_nai); 5271 if (osu_nai2) 5272 fprintf(f, "osu_nai2=%s\n", osu_nai2); 5273 5274 fprintf(f, "hs20_icon=%s\n", hs20_icon); 5275 5276 if (osu_icon) 5277 fprintf(f, "osu_icon=%s\n", osu_icon); 5278 5279 if (dut->ap_osu_provider_list > 100) 5280 fprintf(f, "osu_method_list=0\n"); 5281 else 5282 fprintf(f, "osu_method_list=%d\n", osu_method); 5283 } 5284 5285 switch (dut->ap_venue_url) { 5286 case 1: 5287 fprintf(f, 5288 "venue_url=1:https://venue-server.r2m-testbed.wi-fi.org/floorplans/index.html\n" 5289 "venue_url=1:https://venue-server.r2m-testbed.wi-fi.org/directory/index.html\n"); 5290 break; 5291 case 2: 5292 fprintf(f, 5293 "venue_url=1:https://the-great-mall.r2m-testbed.wi-fi.org/floorplans/index.html\n" 5294 "venue_url=2:https://abercrombie.r2m-testbed.wi-fi.org/floorplans/index.html\n" 5295 "venue_url=3:https://adidas.r2m-testbed.wi-fi.org/floorplans/index.html\n" 5296 "venue_url=4:https://aeropostale.r2m-testbed.wi-fi.org/floorplans/index.html\n" 5297 "venue_url=5:https://agaci.r2m-testbed.wi-fi.org/floorplans/index.html\n" 5298 "venue_url=6:https://aldo-shoes.r2m-testbed.wi-fi.org/floorplans/index.html\n" 5299 "venue_url=7:https://american-eagle-outfitters.r2m-testbed.wi-fi.org/floorplans/index.html\n" 5300 "venue_url=8:https://anderson-bakery.r2m-testbed.wi-fi.org/floorplans/index.html\n" 5301 "venue_url=9:https://banana-republic-factory-store.r2m-testbed.wi-fi.org/floorplans/index.html\n" 5302 "venue_url=10:https://bed-bath-and-beyond.r2m-testbed.wi-fi.org/floorplans/index.html\n" 5303 ); 5304 break; 5305 } 5306 5307 switch (dut->ap_advice_of_charge) { 5308 case 1: 5309 fprintf(f, "anqp_elem=278:" ADV_OF_CHARGE_1 "\n"); 5310 break; 5311 } 5312 5313 switch (dut->ap_oper_icon_metadata) { 5314 case 1: 5315 fprintf(f, 5316 "hs20_icon=160:76:eng:image/png:icon_red_eng.png:/etc/ath/icon_red_eng.png\n" 5317 "operator_icon=icon_red_eng.png\n"); 5318 break; 5319 } 5320 5321 switch (dut->ap_tnc_file_name) { 5322 case 1: 5323 fprintf(f, "hs20_t_c_filename=tandc-id1-content.txt\n"); 5324 break; 5325 } 5326 5327 if (dut->ap_tnc_time_stamp) 5328 fprintf(f, "hs20_t_c_timestamp=%u\n", dut->ap_tnc_time_stamp); 5329 5330 return 0; 5331 } 5332 5333 5334 static void write_ap_roaming_cons(FILE *f, const char *list) 5335 { 5336 char *buf, *pos, *end; 5337 5338 if (list == NULL || list[0] == '\0') 5339 return; 5340 5341 buf = strdup(list); 5342 if (buf == NULL) 5343 return; 5344 5345 pos = buf; 5346 while (pos && *pos) { 5347 end = strchr(pos, ';'); 5348 if (end) 5349 *end++ = '\0'; 5350 fprintf(f, "roaming_consortium=%s\n", pos); 5351 pos = end; 5352 } 5353 5354 free(buf); 5355 } 5356 5357 5358 static int append_hostapd_conf_interworking(struct sigma_dut *dut, FILE *f) 5359 { 5360 int i; 5361 char buf[100], *temp; 5362 5363 if (dut->ap_gas_cb_delay > 0) 5364 fprintf(f, "gas_comeback_delay=%d\n", 5365 dut->ap_gas_cb_delay); 5366 5367 fprintf(f, "interworking=1\n" 5368 "access_network_type=%d\n" 5369 "internet=%d\n" 5370 "asra=0\n" 5371 "esr=0\n" 5372 "uesa=0\n" 5373 "venue_group=%d\n" 5374 "venue_type=%d\n", 5375 dut->ap_access_net_type, 5376 dut->ap_internet, 5377 dut->ap_venue_group, 5378 dut->ap_venue_type); 5379 if (dut->ap_hessid[0]) 5380 fprintf(f, "hessid=%s\n", dut->ap_hessid); 5381 5382 write_ap_roaming_cons(f, dut->ap_roaming_cons); 5383 5384 if (dut->ap_venue_name) { 5385 fprintf(f, "venue_name=P\"eng:Wi-Fi Alliance\\n2989 Copper Road\\nSanta Clara, CA 95051, USA\"\n"); 5386 fprintf(f, "venue_name=%s\n", ANQP_VENUE_NAME_1_CHI); 5387 } 5388 5389 if (dut->ap_net_auth_type == 1) 5390 fprintf(f, "network_auth_type=00https://tandc-server.wi-fi.org\n"); 5391 else if (dut->ap_net_auth_type == 2) 5392 fprintf(f, "network_auth_type=01\n"); 5393 5394 if (dut->ap_nai_realm_list == 1) { 5395 fprintf(f, "nai_realm=0,mail.example.com;cisco.com;wi-fi.org,21[2:4][5:7]\n"); 5396 fprintf(f, "nai_realm=0,wi-fi.org;example.com,13[5:6]\n"); 5397 } else if (dut->ap_nai_realm_list == 2) { 5398 fprintf(f, "nai_realm=0,wi-fi.org,21[2:4][5:7]\n"); 5399 } else if (dut->ap_nai_realm_list == 3) { 5400 fprintf(f, "nai_realm=0,cisco.com;wi-fi.org,21[2:4][5:7]\n"); 5401 fprintf(f, "nai_realm=0,wi-fi.org;example.com,13[5:6]\n"); 5402 } else if (dut->ap_nai_realm_list == 4) { 5403 fprintf(f, "nai_realm=0,mail.example.com,21[2:4][5:7],13[5:6]\n"); 5404 } else if (dut->ap_nai_realm_list == 5) { 5405 fprintf(f, "nai_realm=0,wi-fi.org;ruckuswireless.com,21[2:4][5:7]\n"); 5406 } else if (dut->ap_nai_realm_list == 6) { 5407 fprintf(f, "nai_realm=0,wi-fi.org;mail.example.com,21[2:4][5:7]\n"); 5408 } else if (dut->ap_nai_realm_list == 7) { 5409 fprintf(f, "nai_realm=0,wi-fi.org,13[5:6]\n"); 5410 fprintf(f, "nai_realm=0,wi-fi.org,21[2:4][5:7]\n"); 5411 } 5412 5413 if (dut->ap_domain_name_list[0]) { 5414 fprintf(f, "domain_name=%s\n", 5415 dut->ap_domain_name_list); 5416 } 5417 5418 if (dut->ap_ip_addr_type_avail == 1) { 5419 fprintf(f, "ipaddr_type_availability=0c\n"); 5420 } 5421 5422 temp = buf; 5423 for (i = 0; dut->ap_plmn_mcc[i][0] && dut->ap_plmn_mnc[i][0]; 5424 i++) { 5425 if (i) 5426 *temp++ = ';'; 5427 5428 snprintf(temp, 5429 sizeof(dut->ap_plmn_mcc[i]) + 5430 sizeof(dut->ap_plmn_mnc[i]) + 1, 5431 "%s,%s", 5432 dut->ap_plmn_mcc[i], 5433 dut->ap_plmn_mnc[i]); 5434 5435 temp += strlen(dut->ap_plmn_mcc[i]) + 5436 strlen(dut->ap_plmn_mnc[i]) + 1; 5437 } 5438 if (i) 5439 fprintf(f, "anqp_3gpp_cell_net=%s\n", buf); 5440 5441 if (dut->ap_qos_map_set == 1) 5442 fprintf(f, "qos_map_set=%s\n", QOS_MAP_SET_1); 5443 else if (dut->ap_qos_map_set == 2) 5444 fprintf(f, "qos_map_set=%s\n", QOS_MAP_SET_2); 5445 5446 return 0; 5447 } 5448 5449 5450 static int ath_ap_append_hostapd_conf(struct sigma_dut *dut) 5451 { 5452 FILE *f; 5453 5454 if (kill_process(dut, "(hostapd)", 1, SIGTERM) == 0 || 5455 system("killall hostapd") == 0) { 5456 int i; 5457 5458 /* Wait some time to allow hostapd to complete cleanup before 5459 * starting a new process */ 5460 for (i = 0; i < 10; i++) { 5461 usleep(500000); 5462 if (system("pidof hostapd") != 0) 5463 break; 5464 } 5465 } 5466 5467 f = fopen("/tmp/secath0", "a"); 5468 if (f == NULL) 5469 return -2; 5470 5471 if (dut->ap_hs2 && append_hostapd_conf_hs2(dut, f)) { 5472 fclose(f); 5473 return -2; 5474 } 5475 5476 if (dut->ap_interworking && append_hostapd_conf_interworking(dut, f)) { 5477 fclose(f); 5478 return -2; 5479 } 5480 5481 fflush(f); 5482 fclose(f); 5483 return ath_ap_start_hostapd(dut); 5484 } 5485 5486 5487 static int ath_ap_start_hostapd(struct sigma_dut *dut) 5488 { 5489 if (dut->ap_tag_key_mgmt[0] == AP2_OSEN) 5490 run_system(dut, "hostapd -B /tmp/secath0 /tmp/secath1 -e /etc/wpa2/entropy"); 5491 else 5492 run_system(dut, "hostapd -B /tmp/secath0 -e /etc/wpa2/entropy"); 5493 5494 return 0; 5495 } 5496 5497 5498 #define LE16(a) ((((a) & 0xff) << 8) | (((a) >> 8) & 0xff)) 5499 5500 static int cmd_ath_ap_anqpserver_start(struct sigma_dut *dut) 5501 { 5502 FILE *f; 5503 int nai_realm = 0, domain_name = 0, oper_name = 0, venue_name = 0, 5504 wan_metrics = 0, conn_cap = 0, ipaddr_avail = 0, cell_net = 0; 5505 char buf[100]; 5506 int i; 5507 5508 f = fopen("/root/anqpserver.conf", "w"); 5509 if (f == NULL) 5510 return -1; 5511 5512 if (dut->ap_nai_realm_list == 1) { 5513 nai_realm = 1; 5514 fprintf(f, "dyn_nai_home_realm=encoding=00realm=mail.example.com;eap_method=15auth_id=02auth_val=04auth_id=05auth_val=07encoding=00realm=cisco.com;eap_method=15auth_id=02auth_val=04auth_id=05auth_val=07encoding=00realm=wi-fi.org;eap_method=15auth_id=02auth_val=04auth_id=05auth_val=07encoding=00realm=example.com;eap_method=0Dauth_id=05auth_val=06encoding=00realm=wi-fi.org;eap_method=0Dauth_id=05auth_val=06\n"); 5515 } else if (dut->ap_nai_realm_list == 2) { 5516 nai_realm = 1; 5517 fprintf(f, "dyn_nai_home_realm=encoding=00realm=wi-fi.org;eap_method=0Dauth_id=05auth_val=06\n"); 5518 } else if (dut->ap_nai_realm_list == 3) { 5519 nai_realm = 1; 5520 fprintf(f, "dyn_nai_home_realm=encoding=00realm=cisco.com;eap_method=15auth_id=02auth_val=04auth_id=05auth_val=07encoding=00realm=wi-fi.org;eap_method=15auth_id=02auth_val=04auth_id=05auth_val=07encoding=00realm=example.com;eap_method=0Dauth_id=05auth_val=06encoding=00realm=wi-fi.org;eap_method=0Dauth_id=05auth_val=06\n"); 5521 } else if (dut->ap_nai_realm_list == 4) { 5522 nai_realm = 1; 5523 fprintf(f, "dyn_nai_home_realm=encoding=00realm=mail.example.com;eap_method=15auth_id=02auth_val=04auth_id=05auth_val=07encoding=00realm=mail.example.com;eap_method=0Dauth_id=05auth_val=06\n"); 5524 } else 5525 sigma_dut_print(dut, DUT_MSG_INFO, "not setting nai_realm"); 5526 5527 if (dut->ap_domain_name_list[0]) { 5528 char *next, *start, *dnbuf, *dn1, *anqp_dn; 5529 int len, dn_len_max; 5530 dnbuf = strdup(dut->ap_domain_name_list); 5531 if (dnbuf == NULL) { 5532 fclose(f); 5533 return 0; 5534 } 5535 5536 len = strlen(dnbuf); 5537 dn_len_max = 50 + len*2; 5538 anqp_dn = malloc(dn_len_max); 5539 if (anqp_dn == NULL) { 5540 free(dnbuf); 5541 fclose(f); 5542 return -1; 5543 } 5544 start = dnbuf; 5545 dn1 = anqp_dn; 5546 while (start && *start) { 5547 char *hexstr; 5548 5549 next = strchr(start, ','); 5550 if (next) 5551 *next++ = '\0'; 5552 5553 len = strlen(start); 5554 hexstr = malloc(len * 2 + 1); 5555 if (hexstr == NULL) { 5556 free(dnbuf); 5557 free(anqp_dn); 5558 fclose(f); 5559 return -1; 5560 } 5561 ascii2hexstr(start, hexstr); 5562 snprintf(dn1, dn_len_max, "%02x%s", len, hexstr); 5563 free(hexstr); 5564 dn1 += 2 + len * 2; 5565 dn_len_max -= 2 + len * 2; 5566 start = next; 5567 } 5568 free(dnbuf); 5569 if (dut->ap_gas_cb_delay) { 5570 fprintf(f, "dyn_domain_name=0c01%04x%s", 5571 LE16((unsigned int) strlen(anqp_dn)), anqp_dn); 5572 domain_name = 1; 5573 } else 5574 fprintf(f, "domain_name=0c01%04x%s", 5575 LE16((unsigned int) strlen(anqp_dn)), anqp_dn); 5576 free(anqp_dn); 5577 } else 5578 sigma_dut_print(dut, DUT_MSG_INFO, "not setting domain_name"); 5579 5580 sigma_dut_print(dut, DUT_MSG_INFO, "not setting roaming_consortium"); 5581 5582 if (dut->ap_oper_name) { 5583 if (dut->ap_gas_cb_delay) { 5584 fprintf(f, "dyn_oper_friendly_name=" 5585 ANQP_HS20_OPERATOR_FRIENDLY_NAME_1 "\n"); 5586 oper_name = 1; 5587 } else 5588 fprintf(f, "oper_friendly_name=" 5589 ANQP_HS20_OPERATOR_FRIENDLY_NAME_1 "\n"); 5590 } else 5591 sigma_dut_print(dut, DUT_MSG_INFO, "not setting oper_name"); 5592 5593 if (dut->ap_venue_name) { 5594 if (dut->ap_gas_cb_delay) { 5595 fprintf(f, "dyn_venue_name=" ANQP_VENUE_NAME_1 "\n"); 5596 venue_name = 1; 5597 } else 5598 fprintf(f, "venue_name=" ANQP_VENUE_NAME_1 "\n"); 5599 } else 5600 sigma_dut_print(dut, DUT_MSG_ERROR, "not setting venue_name"); 5601 5602 if (dut->ap_wan_metrics) { 5603 if (dut->ap_gas_cb_delay) { 5604 fprintf(f, "dyn_wan_metrics=" ANQP_HS20_WAN_METRICS_1 "\n"); 5605 wan_metrics = 1; 5606 } else 5607 fprintf(f, "wan_metrics=" ANQP_HS20_WAN_METRICS_1 5608 "\n"); 5609 } else 5610 sigma_dut_print(dut, DUT_MSG_ERROR, "not setting wan_metrics"); 5611 5612 if (dut->ap_conn_capab) { 5613 if (dut->ap_gas_cb_delay) { 5614 fprintf(f, "dyn_conn_capability=" 5615 ANQP_HS20_CONNECTION_CAPABILITY_1 "\n"); 5616 conn_cap = 1; 5617 } else 5618 fprintf(f, "conn_capability=" 5619 ANQP_HS20_CONNECTION_CAPABILITY_1 "\n"); 5620 } else 5621 sigma_dut_print(dut, DUT_MSG_ERROR, 5622 "not setting conn_capability"); 5623 5624 if (dut->ap_ip_addr_type_avail) { 5625 if (dut->ap_gas_cb_delay) { 5626 fprintf(f, "dyn_ipaddr_type=" ANQP_IP_ADDR_TYPE_1 5627 "\n"); 5628 ipaddr_avail = 1; 5629 } else 5630 fprintf(f, "ipaddr_type=" ANQP_IP_ADDR_TYPE_1 "\n"); 5631 } else 5632 sigma_dut_print(dut, DUT_MSG_ERROR, 5633 "not setting ipaddr_type_avail"); 5634 5635 for (i = 0; dut->ap_plmn_mcc[i][0] && dut->ap_plmn_mnc[i][0]; i++) { 5636 snprintf(buf + i * 6, sizeof(buf) - i * 6, "%c%c%c%c%c%c", 5637 dut->ap_plmn_mcc[i][1], 5638 dut->ap_plmn_mcc[i][0], 5639 dut->ap_plmn_mnc[i][2] == '\0' ? 5640 'f' : dut->ap_plmn_mnc[i][2], 5641 dut->ap_plmn_mcc[i][2], 5642 dut->ap_plmn_mnc[i][1], 5643 dut->ap_plmn_mnc[i][0]); 5644 } 5645 if (i) { 5646 uint16_t ie_len = (i * 3) + 5; 5647 if (dut->ap_gas_cb_delay) { 5648 fprintf(f, "dyn_cell_net=0801"); 5649 cell_net = 1; 5650 } else 5651 fprintf(f, "cell_net=0801"); 5652 fprintf(f, "%04x", LE16(ie_len)); 5653 fprintf(f, "00"); /* version */ 5654 fprintf(f, "%02x", (i * 3) + 3); /* user data hdr length */ 5655 fprintf(f, "00"); /* plmn list */ 5656 fprintf(f, "%02x", (i * 3) + 1); /* length of plmn list */ 5657 fprintf(f, "%02x", i); /* number of plmns */ 5658 fprintf(f, "%s\n", buf); /* plmns */ 5659 } else 5660 sigma_dut_print(dut, DUT_MSG_ERROR, 5661 "not setting 3gpp_cellular_network"); 5662 5663 if (nai_realm || domain_name || oper_name || venue_name || 5664 wan_metrics || conn_cap || ipaddr_avail || cell_net) { 5665 fprintf(f, "anqp_attach="); 5666 if (venue_name) 5667 fprintf(f, "00000104%4.4x", dut->ap_gas_cb_delay); 5668 if (nai_realm) 5669 fprintf(f, "00000107%4.4x", dut->ap_gas_cb_delay); 5670 if (cell_net) 5671 fprintf(f, "00000108%4.4x", dut->ap_gas_cb_delay); 5672 if (domain_name) 5673 fprintf(f, "0000010c%4.4x", dut->ap_gas_cb_delay); 5674 if (oper_name) 5675 fprintf(f, "00010003%4.4x", dut->ap_gas_cb_delay); 5676 if (wan_metrics) 5677 fprintf(f, "00010004%4.4x", dut->ap_gas_cb_delay); 5678 if (conn_cap) 5679 fprintf(f, "00010005%4.4x", dut->ap_gas_cb_delay); 5680 fprintf(f, "00010006%4.4x", dut->ap_gas_cb_delay); 5681 fprintf(f, "\n"); 5682 } 5683 5684 fclose(f); 5685 5686 run_system(dut, "anqpserver -i ath0 &"); 5687 if (!dut->ap_anqpserver_on) 5688 run_system(dut, "killall anqpserver"); 5689 5690 return 1; 5691 } 5692 5693 5694 static void cmd_ath_ap_radio_config(struct sigma_dut *dut) 5695 { 5696 char buf[100]; 5697 5698 run_system(dut, "cfg -a AP_STARTMODE=standard"); 5699 5700 if (sigma_radio_ifname[0] && 5701 strcmp(sigma_radio_ifname[0], "wifi1") == 0) { 5702 run_system(dut, "cfg -a AP_RADIO_ID=1"); 5703 switch (dut->ap_mode) { 5704 case AP_11g: 5705 run_system(dut, "cfg -a AP_CHMODE_2=11G"); 5706 break; 5707 case AP_11b: 5708 run_system(dut, "cfg -a AP_CHMODE_2=11B"); 5709 break; 5710 case AP_11ng: 5711 run_system(dut, "cfg -a AP_CHMODE_2=11NGHT20"); 5712 break; 5713 case AP_11a: 5714 run_system(dut, "cfg -a AP_CHMODE_2=11A"); 5715 break; 5716 case AP_11na: 5717 run_system(dut, "cfg -a AP_CHMODE_2=11NAHT20"); 5718 break; 5719 case AP_11ac: 5720 run_system(dut, "cfg -a AP_CHMODE_2=11ACVHT80"); 5721 break; 5722 default: 5723 run_system(dut, "cfg -a AP_CHMODE_2=11ACVHT80"); 5724 break; 5725 } 5726 5727 switch (dut->ap_rx_streams) { 5728 case 1: 5729 run_system(dut, "cfg -a RX_CHAINMASK_2=1"); 5730 break; 5731 case 2: 5732 run_system(dut, "cfg -a RX_CHAINMASK_2=3"); 5733 break; 5734 case 3: 5735 run_system(dut, "cfg -a RX_CHAINMASK_2=7"); 5736 break; 5737 } 5738 5739 switch (dut->ap_tx_streams) { 5740 case 1: 5741 run_system(dut, "cfg -a TX_CHAINMASK_2=1"); 5742 break; 5743 case 2: 5744 run_system(dut, "cfg -a TX_CHAINMASK_2=3"); 5745 break; 5746 case 3: 5747 run_system(dut, "cfg -a TX_CHAINMASK_2=7"); 5748 break; 5749 } 5750 5751 switch (dut->ap_chwidth) { 5752 case AP_20: 5753 run_system(dut, "cfg -a AP_CHMODE_2=11ACVHT20"); 5754 break; 5755 case AP_40: 5756 run_system(dut, "cfg -a AP_CHMODE_2=11ACVHT40"); 5757 break; 5758 case AP_80: 5759 run_system(dut, "cfg -a AP_CHMODE_2=11ACVHT80"); 5760 break; 5761 case AP_160: 5762 case AP_AUTO: 5763 default: 5764 run_system(dut, "cfg -a AP_CHMODE_2=11ACVHT80"); 5765 break; 5766 } 5767 5768 if (dut->ap_tx_stbc) { 5769 run_system(dut, "cfg -a TX_STBC_2=1"); 5770 } 5771 5772 snprintf(buf, sizeof(buf), "cfg -a AP_PRIMARY_CH_2=%d", 5773 dut->ap_channel); 5774 5775 if (dut->ap_is_dual) { 5776 switch (dut->ap_mode_1) { 5777 case AP_11g: 5778 run_system(dut, "cfg -a AP_CHMODE=11G"); 5779 break; 5780 case AP_11b: 5781 run_system(dut, "cfg -a AP_CHMODE=11B"); 5782 break; 5783 case AP_11ng: 5784 run_system(dut, "cfg -a AP_CHMODE=11NGHT20"); 5785 break; 5786 case AP_11a: 5787 run_system(dut, "cfg -a AP_CHMODE=11A"); 5788 break; 5789 case AP_11na: 5790 run_system(dut, "cfg -a AP_CHMODE=11NAHT20"); 5791 break; 5792 case AP_11ac: 5793 run_system(dut, "cfg -a AP_CHMODE=11ACVHT80"); 5794 break; 5795 default: 5796 run_system(dut, "cfg -a AP_CHMODE=11NGHT20"); 5797 break; 5798 } 5799 snprintf(buf, sizeof(buf), "cfg -a AP_PRIMARY_CH=%d", 5800 dut->ap_channel_1); 5801 } 5802 run_system(dut, buf); 5803 } else { 5804 run_system(dut, "cfg -a AP_RADIO_ID=0"); 5805 switch (dut->ap_mode) { 5806 case AP_11g: 5807 run_system(dut, "cfg -a AP_CHMODE=11G"); 5808 break; 5809 case AP_11b: 5810 run_system(dut, "cfg -a AP_CHMODE=11B"); 5811 break; 5812 case AP_11ng: 5813 run_system(dut, "cfg -a AP_CHMODE=11NGHT20"); 5814 break; 5815 case AP_11a: 5816 run_system(dut, "cfg -a AP_CHMODE=11A"); 5817 break; 5818 case AP_11na: 5819 run_system(dut, "cfg -a AP_CHMODE=11NAHT20"); 5820 break; 5821 case AP_11ac: 5822 run_system(dut, "cfg -a AP_CHMODE=11ACVHT80"); 5823 break; 5824 default: 5825 run_system(dut, "cfg -a AP_CHMODE=11NGHT20"); 5826 break; 5827 } 5828 snprintf(buf, sizeof(buf), "cfg -a AP_PRIMARY_CH=%d", 5829 dut->ap_channel); 5830 run_system(dut, buf); 5831 } 5832 5833 if (dut->ap_sgi80 == 1) { 5834 run_system(dut, "cfg -a SHORTGI=1"); 5835 run_system(dut, "cfg -a SHORTGI_2=1"); 5836 } else if (dut->ap_sgi80 == 0) { 5837 run_system(dut, "cfg -a SHORTGI=0"); 5838 run_system(dut, "cfg -a SHORTGI_2=0"); 5839 } 5840 5841 if (dut->ap_ldpc == VALUE_ENABLED) 5842 run_system(dut, "cfg -a LDPC=1"); 5843 else if (dut->ap_ldpc == VALUE_DISABLED) 5844 run_system(dut, "cfg -a LDPC=0"); 5845 } 5846 5847 5848 void ath_disable_txbf(struct sigma_dut *dut, const char *intf) 5849 { 5850 run_iwpriv(dut, intf, "vhtsubfee 0"); 5851 run_iwpriv(dut, intf, "vhtsubfer 0"); 5852 run_iwpriv(dut, intf, "vhtmubfee 0"); 5853 run_iwpriv(dut, intf, "vhtmubfer 0"); 5854 } 5855 5856 5857 static void ath_set_assoc_disallow(struct sigma_dut *dut, const char *ifname, 5858 const char *val) 5859 { 5860 if (strcasecmp(val, "enable") == 0) { 5861 run_iwpriv(dut, ifname, "mbo_asoc_dis 1"); 5862 } else if (strcasecmp(val, "disable") == 0) { 5863 run_iwpriv(dut, ifname, "mbo_asoc_dis 0"); 5864 } else { 5865 sigma_dut_print(dut, DUT_MSG_ERROR, 5866 "Unsupported assoc_disallow"); 5867 } 5868 } 5869 5870 5871 static void apply_mbo_pref_ap_list(struct sigma_dut *dut) 5872 { 5873 int i; 5874 int least_pref = 1 << 8; 5875 char ifname[20]; 5876 uint8_t self_mac[ETH_ALEN]; 5877 char buf[200]; 5878 int ap_ne_class, ap_ne_pref, ap_ne_op_ch; 5879 5880 get_if_name(dut, ifname, sizeof(ifname), 1); 5881 get_hwaddr(ifname, self_mac); 5882 5883 /* Clear off */ 5884 snprintf(buf, sizeof(buf), 5885 "wifitool %s setbssidpref 00:00:00:00:00:00 0 0 0", 5886 ifname); 5887 run_system(dut, buf); 5888 5889 /* Find the least preference number */ 5890 for (i = 0; i < dut->mbo_pref_ap_cnt; i++) { 5891 unsigned char *mac_addr = dut->mbo_pref_aps[i].mac_addr; 5892 5893 ap_ne_class = 1; 5894 ap_ne_pref = 255; 5895 ap_ne_op_ch = 1; 5896 if (dut->mbo_pref_aps[i].ap_ne_pref != -1) 5897 ap_ne_pref = dut->mbo_pref_aps[i].ap_ne_pref; 5898 if (dut->mbo_pref_aps[i].ap_ne_class != -1) 5899 ap_ne_class = dut->mbo_pref_aps[i].ap_ne_class; 5900 if (dut->mbo_pref_aps[i].ap_ne_op_ch != -1) 5901 ap_ne_op_ch = dut->mbo_pref_aps[i].ap_ne_op_ch; 5902 5903 if (ap_ne_pref < least_pref) 5904 least_pref = ap_ne_pref; 5905 snprintf(buf, sizeof(buf), 5906 "wifitool %s setbssidpref %02x:%02x:%02x:%02x:%02x:%02x %d %d %d", 5907 ifname, mac_addr[0], mac_addr[1], mac_addr[2], 5908 mac_addr[3], mac_addr[4], mac_addr[5], 5909 ap_ne_pref, ap_ne_class, ap_ne_op_ch); 5910 run_system(dut, buf); 5911 } 5912 5913 /* Now add the self AP Address */ 5914 if (dut->mbo_self_ap_tuple.ap_ne_class == -1) { 5915 if (dut->ap_channel <= 11) 5916 ap_ne_class = 81; 5917 else 5918 ap_ne_class = 115; 5919 } else { 5920 ap_ne_class = dut->mbo_self_ap_tuple.ap_ne_class; 5921 } 5922 5923 if (dut->mbo_self_ap_tuple.ap_ne_op_ch == -1) 5924 ap_ne_op_ch = dut->ap_channel; 5925 else 5926 ap_ne_op_ch = dut->mbo_self_ap_tuple.ap_ne_op_ch; 5927 5928 if (dut->mbo_self_ap_tuple.ap_ne_pref == -1) 5929 ap_ne_pref = least_pref - 1; 5930 else 5931 ap_ne_pref = dut->mbo_self_ap_tuple.ap_ne_pref; 5932 5933 snprintf(buf, sizeof(buf), 5934 "wifitool %s setbssidpref %02x:%02x:%02x:%02x:%02x:%02x %d %d %d", 5935 ifname, self_mac[0], self_mac[1], self_mac[2], 5936 self_mac[3], self_mac[4], self_mac[5], 5937 ap_ne_pref, 5938 ap_ne_class, 5939 ap_ne_op_ch); 5940 run_system(dut, buf); 5941 } 5942 5943 5944 static void mubrp_commands(struct sigma_dut *dut, const char *ifname) 5945 { 5946 run_iwpriv(dut, ifname, "he_subfer 1"); 5947 run_iwpriv(dut, ifname, "he_mubfer 1"); 5948 /* To enable MU_AX with MU_BRP trigger */ 5949 run_iwpriv(dut, ifname, "he_sounding_mode 13"); 5950 /* Sets g_force_1x1_peer to 1 which should be reset to zero for non MU 5951 * test cases */ 5952 run_system_wrapper(dut, "wifitool %s setUnitTestCmd 0x48 2 118 1", 5953 ifname); 5954 /* Disable DL OFDMA */ 5955 run_system_wrapper(dut, "wifitool %s setUnitTestCmd 0x47 2 11 0", 5956 ifname); 5957 } 5958 5959 5960 static void ath_ap_set_params(struct sigma_dut *dut) 5961 { 5962 const char *basedev = "wifi0"; 5963 const char *basedev_radio = "wifi1"; 5964 const char *ifname = get_main_ifname(dut); 5965 char *ifname_dual = NULL; 5966 int i; 5967 char buf[300]; 5968 unsigned int he_mcsnssmap = dut->he_mcsnssmap; 5969 5970 if (sigma_radio_ifname[0]) 5971 basedev = sigma_radio_ifname[0]; 5972 5973 if (dut->ap_is_dual == 1) { 5974 basedev = sigma_radio_ifname[0]; 5975 basedev_radio = sigma_radio_ifname[1]; 5976 if (sigma_radio_ifname[0] && 5977 strcmp(sigma_radio_ifname[0], "wifi0") == 0) { 5978 ifname = "ath0"; 5979 ifname_dual = "ath1"; 5980 } else { 5981 ifname = "ath1"; 5982 ifname_dual = "ath0"; 5983 } 5984 } 5985 5986 if (dut->ap_countrycode[0]) { 5987 run_iwpriv(dut, basedev, "setCountry %s", dut->ap_countrycode); 5988 sigma_dut_print(dut, DUT_MSG_INFO, "Set countrycode"); 5989 } 5990 5991 for (i = 0; i < NUM_AP_AC; i++) { 5992 if (dut->ap_qos[i].ac) { 5993 run_iwpriv(dut, ifname, "cwmin %d 0 %d", i, 5994 dut->ap_qos[i].cwmin); 5995 run_iwpriv(dut, ifname, "cwmax %d 0 %d", i, 5996 dut->ap_qos[i].cwmax); 5997 run_iwpriv(dut, ifname, "aifs %d 0 %d", i, 5998 dut->ap_qos[i].aifs); 5999 run_iwpriv(dut, ifname, "txoplimit %d 0 %d", i, 6000 dut->ap_qos[i].txop); 6001 run_iwpriv(dut, ifname, "acm %d 0 %d", i, 6002 dut->ap_qos[i].acm); 6003 } 6004 } 6005 6006 for (i = 0; i < NUM_AP_AC; i++) { 6007 if (dut->ap_sta_qos[i].ac) { 6008 run_iwpriv(dut, ifname, "cwmin %d 1 %d", i, 6009 dut->ap_sta_qos[i].cwmin); 6010 run_iwpriv(dut, ifname, "cwmax %d 1 %d", i, 6011 dut->ap_sta_qos[i].cwmax); 6012 run_iwpriv(dut, ifname, "aifs %d 1 %d", i, 6013 dut->ap_sta_qos[i].aifs); 6014 run_iwpriv(dut, ifname, "txoplimit %d 1 %d", i, 6015 dut->ap_sta_qos[i].txop); 6016 run_iwpriv(dut, ifname, "acm %d 1 %d", i, 6017 dut->ap_sta_qos[i].acm); 6018 } 6019 } 6020 6021 if (dut->ap_disable_protection == 1) { 6022 run_iwpriv(dut, ifname, "enablertscts 0"); 6023 sigma_dut_print(dut, DUT_MSG_INFO, "Disabled rtscts"); 6024 } 6025 6026 if (dut->ap_ldpc == VALUE_ENABLED) 6027 run_iwpriv(dut, ifname, "ldpc 3"); 6028 else if (dut->ap_ldpc == VALUE_DISABLED) 6029 run_iwpriv(dut, ifname, "ldpc 0"); 6030 6031 if (dut->ap_ampdu == VALUE_ENABLED) { 6032 run_iwpriv(dut, ifname, "ampdu 1"); 6033 } else if (dut->ap_ampdu == VALUE_DISABLED) { 6034 run_iwpriv(dut, ifname, "ampdu 0"); 6035 if (dut->program == PROGRAM_HE) { 6036 run_iwpriv(dut, ifname, "setaddbaoper 1"); 6037 run_system_wrapper(dut, "wifitool %s refusealladdbas 1", 6038 ifname); 6039 if (dut->ap_amsdu == VALUE_ENABLED) { 6040 /* disable the limit for A-MSDU */ 6041 run_system_wrapper(dut, 6042 "wifitool %s setUnitTestCmd 0x48 2 46 1", 6043 ifname); 6044 } 6045 } 6046 } 6047 6048 if (dut->ap_ampdu_exp) { 6049 if (dut->program == PROGRAM_VHT) { 6050 run_iwpriv(dut, ifname, "vhtmaxampdu %d", 6051 dut->ap_ampdu_exp); 6052 } else { 6053 /* 11N */ 6054 run_iwpriv(dut, ifname, "maxampdu %d", 6055 dut->ap_ampdu_exp); 6056 } 6057 } 6058 6059 if (dut->ap_noack == VALUE_ENABLED) { 6060 run_iwpriv(dut, ifname, "noackpolicy 0 0 1"); 6061 run_iwpriv(dut, ifname, "noackpolicy 1 0 1"); 6062 run_iwpriv(dut, ifname, "noackpolicy 2 0 1"); 6063 run_iwpriv(dut, ifname, "noackpolicy 3 0 1"); 6064 } else if (dut->ap_noack == VALUE_DISABLED) { 6065 run_iwpriv(dut, ifname, "noackpolicy 0 0 0"); 6066 run_iwpriv(dut, ifname, "noackpolicy 1 0 0"); 6067 run_iwpriv(dut, ifname, "noackpolicy 2 0 0"); 6068 run_iwpriv(dut, ifname, "noackpolicy 3 0 0"); 6069 } 6070 6071 if (dut->device_type == AP_testbed && dut->ap_vhtmcs_map) 6072 run_iwpriv(dut, ifname, "vht_mcsmap 0x%04x", 6073 dut->ap_vhtmcs_map); 6074 6075 if (dut->ap_amsdu == VALUE_ENABLED) 6076 run_iwpriv(dut, ifname, "amsdu 2"); 6077 else if (dut->ap_amsdu == VALUE_DISABLED) 6078 run_iwpriv(dut, ifname, "amsdu 1"); 6079 6080 if (dut->ap_rx_amsdu == VALUE_ENABLED) 6081 run_iwpriv(dut, basedev_radio, "rx_amsdu 1"); 6082 else if (dut->ap_rx_amsdu == VALUE_DISABLED) 6083 run_iwpriv(dut, basedev_radio, "rx_amsdu 0"); 6084 6085 /* Command sequence to generate single VHT AMSDU and MPDU */ 6086 if (dut->ap_addba_reject != VALUE_NOT_SET && 6087 dut->ap_ampdu == VALUE_DISABLED && 6088 dut->ap_amsdu == VALUE_ENABLED) { 6089 run_iwpriv(dut, ifname, "setaddbaoper 1"); 6090 6091 snprintf(buf, sizeof(buf), 6092 "wifitool %s senddelba 1 0 1 4", ifname); 6093 if (system(buf) != 0) { 6094 sigma_dut_print(dut, DUT_MSG_ERROR, 6095 "wifitool senddelba failed"); 6096 } 6097 6098 snprintf(buf, sizeof(buf), "wifitool %s sendsingleamsdu 1 0", 6099 ifname); 6100 if (system(buf) != 0) { 6101 sigma_dut_print(dut, DUT_MSG_ERROR, 6102 "wifitool sendsingleamsdu failed"); 6103 } 6104 6105 run_iwpriv(dut, ifname, "amsdu 10"); 6106 } 6107 6108 if (dut->ap_mode == AP_11ac) { 6109 int chwidth, nss; 6110 6111 switch (dut->ap_chwidth) { 6112 case AP_20: 6113 chwidth = 0; 6114 break; 6115 case AP_40: 6116 chwidth = 1; 6117 break; 6118 case AP_80: 6119 chwidth = 2; 6120 break; 6121 case AP_160: 6122 chwidth = 3; 6123 break; 6124 case AP_80_80: 6125 chwidth = 3; 6126 break; 6127 default: 6128 chwidth = 0; 6129 break; 6130 } 6131 6132 switch (dut->ap_tx_streams) { 6133 case 1: 6134 nss = 1; 6135 break; 6136 case 2: 6137 nss = 2; 6138 break; 6139 case 3: 6140 nss = 3; 6141 break; 6142 case 4: 6143 nss = 4; 6144 break; 6145 default: 6146 nss = 3; 6147 break; 6148 } 6149 6150 if (dut->ap_fixed_rate) { 6151 if (nss == 4) 6152 ath_disable_txbf(dut, ifname); 6153 6154 /* Set the nss */ 6155 run_iwpriv(dut, ifname, "nss %d", nss); 6156 6157 /* Set the channel width */ 6158 run_iwpriv(dut, ifname, "chwidth %d", chwidth); 6159 6160 /* Set the VHT MCS */ 6161 run_iwpriv(dut, ifname, "vhtmcs %d", dut->ap_mcs); 6162 } 6163 } 6164 6165 if (dut->ap_dyn_bw_sig == VALUE_ENABLED) 6166 run_iwpriv(dut, ifname, "cwmenable 1"); 6167 else if (dut->ap_dyn_bw_sig == VALUE_DISABLED) 6168 run_iwpriv(dut, ifname, "cwmenable 0"); 6169 6170 if (dut->ap_sig_rts == VALUE_ENABLED) { 6171 snprintf(buf, sizeof(buf), "iwconfig %s rts 64", ifname); 6172 if (system(buf) != 0) { 6173 sigma_dut_print(dut, DUT_MSG_ERROR, 6174 "iwconfig rts 64 failed"); 6175 } 6176 } else if (dut->ap_sig_rts == VALUE_DISABLED) { 6177 snprintf(buf, sizeof(buf), "iwconfig %s rts 2347", ifname); 6178 if (system(buf) != 0) { 6179 sigma_dut_print(dut, DUT_MSG_ERROR, 6180 "iwconfig rts 2347 failed"); 6181 } 6182 } 6183 6184 if (dut->ap_hs2) { 6185 run_iwpriv(dut, ifname, "qbssload 1"); 6186 sigma_dut_print(dut, DUT_MSG_INFO, "Enabled qbssload"); 6187 } 6188 6189 if (dut->ap_bss_load && dut->ap_bss_load != -1) { 6190 unsigned int bssload = 0; 6191 6192 if (dut->ap_bss_load == 1) { 6193 /* STA count: 1, CU: 50, AAC: 65535 */ 6194 bssload = 0x0132ffff; 6195 } else if (dut->ap_bss_load == 2) { 6196 /* STA count: 1, CU: 200, AAC: 65535 */ 6197 bssload = 0x01c8ffff; 6198 } else if (dut->ap_bss_load == 3) { 6199 /* STA count: 1, CU: 75, AAC: 65535 */ 6200 bssload = 0x014bffff; 6201 } 6202 6203 run_iwpriv(dut, ifname, "hcbssload %u", bssload); 6204 } else if (dut->ap_bss_load == 0) { 6205 run_iwpriv(dut, ifname, "qbssload 0"); 6206 sigma_dut_print(dut, DUT_MSG_INFO, "Disabled qbssload"); 6207 } 6208 6209 if (dut->ap_dgaf_disable) { 6210 run_iwpriv(dut, ifname, "dgaf_disable 1"); 6211 sigma_dut_print(dut, DUT_MSG_INFO, "Enabled dgaf_disable"); 6212 } 6213 6214 if (dut->ap_l2tif) { 6215 run_iwpriv(dut, ifname, "l2tif 1"); 6216 snprintf(buf, sizeof(buf), 6217 "echo 1 > /sys/class/net/br0/brif/ath0/hotspot_l2tif"); 6218 if (system(buf) != 0) 6219 sigma_dut_print(dut, DUT_MSG_ERROR, 6220 "l2tif br failed"); 6221 6222 snprintf(buf, sizeof(buf), 6223 "echo 1 > /sys/class/net/br0/brif/eth0/hotspot_wan"); 6224 if (system(buf) != 0) 6225 sigma_dut_print(dut, DUT_MSG_ERROR, 6226 "l2tif brif failed"); 6227 sigma_dut_print(dut, DUT_MSG_INFO, "Enabled l2tif"); 6228 } 6229 6230 if (dut->ap_ndpa_frame == 0) { 6231 snprintf(buf, sizeof(buf), 6232 "wifitool %s beeliner_fw_test 117 192", ifname); 6233 if (system(buf) != 0) { 6234 sigma_dut_print(dut, DUT_MSG_ERROR, 6235 "wifitool beeliner_fw_test 117 192 failed"); 6236 } 6237 snprintf(buf, sizeof(buf), 6238 "wifitool %s beeliner_fw_test 118 192", ifname); 6239 if (system(buf) != 0) { 6240 sigma_dut_print(dut, DUT_MSG_ERROR, 6241 "wifitool beeliner_fw_test 117 192 failed"); 6242 } 6243 } else if (dut->ap_ndpa_frame == 1) { 6244 /* Driver default - no changes needed */ 6245 } else if (dut->ap_ndpa_frame == 2) { 6246 snprintf(buf, sizeof(buf), 6247 "wifitool %s beeliner_fw_test 115 1", ifname); 6248 if (system(buf) != 0) { 6249 sigma_dut_print(dut, DUT_MSG_ERROR, 6250 "wifitool beeliner_fw_test 117 192 failed"); 6251 } 6252 snprintf(buf, sizeof(buf), 6253 "wifitool %s beeliner_fw_test 116 1", ifname); 6254 if (system(buf) != 0) { 6255 sigma_dut_print(dut, DUT_MSG_ERROR, 6256 "wifitool beeliner_fw_test 117 192 failed"); 6257 } 6258 } 6259 6260 if (dut->ap_rtt == 1) 6261 run_iwpriv(dut, ifname, "enable_rtt 1"); 6262 6263 if (dut->ap_lci == 1) 6264 run_iwpriv(dut, ifname, "enable_lci 1"); 6265 6266 if (dut->ap_lcr == 1) 6267 run_iwpriv(dut, ifname, "enable_lcr 1"); 6268 6269 if (dut->ap_rrm == 1) 6270 run_iwpriv(dut, ifname, "enable_rmm 1"); 6271 6272 if (dut->ap_lci == 1 || dut->ap_lcr == 1) { 6273 run_system(dut, "wpc -l /tmp/lci_cfg.txt"); 6274 } 6275 6276 if (dut->ap_neighap >= 1 && dut->ap_lci == 0) { 6277 FILE *f; 6278 6279 f = fopen("/tmp/nbr_report.txt", "w"); 6280 if (!f) { 6281 sigma_dut_print(dut, DUT_MSG_ERROR, 6282 "Failed to open /tmp/nbr_report.txt"); 6283 return; 6284 } 6285 6286 fprintf(f, 6287 "ap_1 = 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x00 0x3c 0x00 0x00 0x80 0x%x 0x09 0x06 0x03 0x02 0x2a 0x00\n", 6288 dut->ap_val_neighap[0][0], dut->ap_val_neighap[0][1], 6289 dut->ap_val_neighap[0][2], dut->ap_val_neighap[0][3], 6290 dut->ap_val_neighap[0][4], dut->ap_val_neighap[0][5], 6291 dut->ap_val_opchannel[0]); 6292 fclose(f); 6293 6294 f = fopen("/tmp/ftmrr.txt", "w"); 6295 if (!f) { 6296 sigma_dut_print(dut, DUT_MSG_ERROR, 6297 "Failed to open /tmp/ftmrr.txt"); 6298 return; 6299 } 6300 6301 fprintf(f, 6302 "ap_1 = 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x00 0x3c 0x00 0x00 0x80 0x%x 0x09 0x06 0x03 0x02 0x2a 0x00\n", 6303 dut->ap_val_neighap[0][0], dut->ap_val_neighap[0][1], 6304 dut->ap_val_neighap[0][2], dut->ap_val_neighap[0][3], 6305 dut->ap_val_neighap[0][4], dut->ap_val_neighap[0][5], 6306 dut->ap_val_opchannel[0]); 6307 fclose(f); 6308 } 6309 6310 if (dut->ap_neighap >= 2 && dut->ap_lci == 0) { 6311 FILE *f; 6312 6313 f = fopen("/tmp/nbr_report.txt", "a"); 6314 if (!f) { 6315 sigma_dut_print(dut, DUT_MSG_ERROR, 6316 "Failed to open /tmp/nbr_report.txt"); 6317 return; 6318 } 6319 fprintf(f, 6320 "ap_2 = 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x00 0x3c 0x00 0x00 0x80 0x%x 0x09 0x06 0x03 0x02 0x6a 0x00\n", 6321 dut->ap_val_neighap[1][0], dut->ap_val_neighap[1][1], 6322 dut->ap_val_neighap[1][2], dut->ap_val_neighap[1][3], 6323 dut->ap_val_neighap[1][4], dut->ap_val_neighap[1][5], 6324 dut->ap_val_opchannel[1]); 6325 fclose(f); 6326 6327 f = fopen("/tmp/ftmrr.txt", "a"); 6328 if (!f) { 6329 sigma_dut_print(dut, DUT_MSG_ERROR, 6330 "Failed to open /tmp/ftmrr.txt"); 6331 return; 6332 } 6333 fprintf(f, 6334 "ap_2 = 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x00 0x3c 0x00 0x00 0x80 0x%x 0x09 0x06 0x03 0x02 0x6a 0x00\n", 6335 dut->ap_val_neighap[1][0], dut->ap_val_neighap[1][1], 6336 dut->ap_val_neighap[1][2], dut->ap_val_neighap[1][3], 6337 dut->ap_val_neighap[1][4], dut->ap_val_neighap[1][5], 6338 dut->ap_val_opchannel[1]); 6339 fclose(f); 6340 } 6341 6342 if (dut->ap_neighap >= 3 && dut->ap_lci == 0) { 6343 FILE *f; 6344 6345 f = fopen("/tmp/nbr_report.txt", "a"); 6346 if (!f) { 6347 sigma_dut_print(dut, DUT_MSG_ERROR, 6348 "Failed to open /tmp/nbr_report.txt"); 6349 return; 6350 } 6351 6352 fprintf(f, 6353 "ap_3 = 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x00 0x3c 0x00 0x00 0x80 0x%x 0x09 0x06 0x03 0x02 0x9b 0x00\n", 6354 dut->ap_val_neighap[2][0], dut->ap_val_neighap[2][1], 6355 dut->ap_val_neighap[2][2], dut->ap_val_neighap[2][3], 6356 dut->ap_val_neighap[2][4], dut->ap_val_neighap[2][5], 6357 dut->ap_val_opchannel[2]); 6358 fclose(f); 6359 6360 f = fopen("/tmp/ftmrr.txt", "a"); 6361 if (!f) { 6362 sigma_dut_print(dut, DUT_MSG_ERROR, 6363 "Failed to open /tmp/ftmrr.txt"); 6364 return; 6365 } 6366 6367 fprintf(f, 6368 "ap_3 = 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x00 0x3c 0x00 0x00 0x80 0x%x 0x09 0x06 0x03 0x02 0x9b 0x00\n", 6369 dut->ap_val_neighap[2][0], dut->ap_val_neighap[2][1], 6370 dut->ap_val_neighap[2][2], dut->ap_val_neighap[2][3], 6371 dut->ap_val_neighap[2][4], dut->ap_val_neighap[2][5], 6372 dut->ap_val_opchannel[2]); 6373 fclose(f); 6374 } 6375 6376 if (dut->ap_neighap) { 6377 run_iwpriv(dut, ifname, "enable_rtt 1"); 6378 run_iwpriv(dut, ifname, "enable_lci 1"); 6379 run_iwpriv(dut, ifname, "enable_lcr 1"); 6380 run_iwpriv(dut, ifname, "enable_rrm 1"); 6381 } 6382 6383 if (dut->ap_scan == 1) { 6384 run_iwpriv(dut, ifname, "scanentryage 600"); 6385 snprintf(buf, sizeof(buf), "iwlist %s scan", ifname); 6386 run_system(dut, buf); 6387 } 6388 6389 if (dut->ap_set_bssidpref) { 6390 snprintf(buf, sizeof(buf), 6391 "wifitool %s setbssidpref 00:00:00:00:00:00 0 00 00", 6392 ifname); 6393 if (system(buf) != 0) { 6394 sigma_dut_print(dut, DUT_MSG_ERROR, 6395 "wifitool clear bssidpref failed"); 6396 } 6397 } 6398 6399 if (dut->wnm_bss_max_feature != VALUE_NOT_SET) { 6400 int feature_enable; 6401 6402 feature_enable = dut->wnm_bss_max_feature == VALUE_ENABLED; 6403 run_iwpriv(dut, ifname, "wnm %d", feature_enable); 6404 run_iwpriv(dut, ifname, "wnm_bss %d", feature_enable); 6405 if (feature_enable) { 6406 const char *extra = ""; 6407 6408 if (dut->wnm_bss_max_protection != VALUE_NOT_SET) { 6409 if (dut->wnm_bss_max_protection == 6410 VALUE_ENABLED) 6411 extra = " 1"; 6412 else 6413 extra = " 0"; 6414 } 6415 snprintf(buf, sizeof(buf), 6416 "wlanconfig %s wnm setbssmax %d%s", 6417 ifname, dut->wnm_bss_max_idle_time, extra); 6418 run_system(dut, buf); 6419 } 6420 } 6421 6422 if (dut->program == PROGRAM_MBO) { 6423 apply_mbo_pref_ap_list(dut); 6424 run_iwpriv(dut, ifname, "mbo_cel_pref %d", 6425 dut->ap_cell_cap_pref); 6426 run_iwpriv(dut, ifname, "mbocap 0x40"); 6427 ath_set_assoc_disallow(dut, ifname, "disable"); 6428 } 6429 6430 if (dut->ap_oce == VALUE_ENABLED) 6431 run_iwpriv(dut, ifname, "set_bpr_enable 1"); 6432 6433 if (dut->ap_oce == VALUE_ENABLED && dut->ap_channel <= 11) { 6434 run_iwpriv(dut, ifname, "prb_rate 5500"); 6435 run_iwpriv(dut, ifname, "set_bcn_rate 5500"); 6436 } 6437 6438 if (dut->ap_oce == VALUE_DISABLED) 6439 run_iwpriv(dut, ifname, "set_bpr_enable 0"); 6440 6441 if (dut->ap_oce == VALUE_DISABLED && dut->ap_channel <= 11) { 6442 run_iwpriv(dut, ifname, "mgmt_rate 1000"); 6443 run_iwpriv(dut, ifname, "set_bcn_rate 1000"); 6444 } 6445 6446 if (dut->ap_bcnint) 6447 run_iwpriv(dut, ifname, "bintval %d", dut->ap_bcnint); 6448 6449 if (dut->ap_filsdscv == VALUE_DISABLED) 6450 run_iwpriv(dut, ifname, "enable_fils 0 0"); 6451 6452 if (dut->ap_filshlp == VALUE_ENABLED) 6453 run_iwpriv(dut, ifname, "oce_hlp 1"); 6454 else if (dut->ap_filshlp == VALUE_DISABLED) 6455 run_iwpriv(dut, ifname, "oce_hlp 0"); 6456 6457 /* When RNR is enabled, also enable apchannelreport, background scan */ 6458 if (dut->ap_rnr == VALUE_ENABLED) { 6459 run_iwpriv(dut, ifname, "rnr 1"); 6460 run_iwpriv(dut, ifname, "rnr_tbtt 1"); 6461 run_iwpriv(dut, ifname, "apchanrpt 1"); 6462 run_iwpriv(dut, basedev, "acs_ctrlflags 0x4"); 6463 run_iwpriv(dut, basedev, "acs_scanintvl 60"); 6464 run_iwpriv(dut, basedev, "acs_bkscanen 1"); 6465 if (dut->ap_is_dual == 1) { 6466 run_iwpriv(dut, ifname_dual, "rnr 1"); 6467 run_iwpriv(dut, ifname_dual, "rnr_tbtt 1"); 6468 run_iwpriv(dut, ifname_dual, "apchanrpt 1"); 6469 run_iwpriv(dut, basedev_radio, "acs_ctrlflags 0x4"); 6470 run_iwpriv(dut, basedev_radio, "acs_scanintvl 60"); 6471 run_iwpriv(dut, basedev_radio, "acs_bkscanen 1"); 6472 } 6473 } 6474 6475 if (dut->ap_blechanutil || dut->ap_ble_admit_cap || dut->ap_blestacnt) { 6476 run_iwpriv(dut, ifname, "qbssload 0"); 6477 snprintf(buf, sizeof(buf), 6478 "wlanconfig %s addie ftype 0 len 7 data 0b05%02x%02x%02x%02x%02x ", 6479 ifname, dut->ap_blestacnt & 0xFF, 6480 dut->ap_blestacnt >> 8, dut->ap_blechanutil, 6481 dut->ap_ble_admit_cap & 0xFF, 6482 dut->ap_ble_admit_cap >> 8); 6483 run_system(dut, buf); 6484 snprintf(buf, sizeof(buf), 6485 "wlanconfig %s addie ftype 2 len 7 data 0b05%02x%02x%02x%02x%02x ", 6486 ifname, dut->ap_blestacnt & 0xFF, 6487 dut->ap_blestacnt >> 8, dut->ap_blechanutil, 6488 dut->ap_ble_admit_cap & 0xFF, 6489 dut->ap_ble_admit_cap >> 8); 6490 run_system(dut, buf); 6491 } 6492 6493 if (dut->ap_esp == VALUE_ENABLED) 6494 run_iwpriv(dut, basedev, "esp_period 5"); 6495 else if (dut->ap_esp == VALUE_DISABLED) 6496 run_iwpriv(dut, basedev, "esp_period 0"); 6497 6498 if (dut->ap_datappdudura) 6499 run_iwpriv(dut, basedev, "esp_ppdu_dur %d", 6500 dut->ap_datappdudura); 6501 6502 if (dut->ap_airtimefract) 6503 run_iwpriv(dut, basedev, "esp_airtime %d", 6504 dut->ap_airtimefract); 6505 6506 if (dut->ap_dhcp_stop) { 6507 snprintf(buf, sizeof(buf), "/etc/init.d/dnsmasq stop"); 6508 run_system(dut, buf); 6509 } 6510 6511 if (dut->ap_bawinsize) 6512 run_iwpriv(dut, basedev, "esp_ba_window %d", dut->ap_bawinsize); 6513 6514 if (dut->program == PROGRAM_DPP) { 6515 if (dut->ap_interface_2g == 1) { 6516 run_iwpriv(dut, ifname, "set_bcn_rate 5500"); 6517 run_iwpriv(dut, ifname, "prb_rate 5500"); 6518 run_iwpriv(dut, ifname, "mgmt_rate 5500"); 6519 } 6520 6521 run_iwpriv(dut, basedev, "set_rxfilter 0xffffffff"); 6522 dut->hostapd_running = 1; 6523 } 6524 6525 if (dut->program == PROGRAM_HE) { 6526 /* disable sending basic triggers */ 6527 run_system_wrapper(dut, 6528 "wifitool %s setUnitTestCmd 0x47 2 42 0", 6529 ifname); 6530 /* disable MU BAR */ 6531 run_system_wrapper(dut, 6532 "wifitool %s setUnitTestCmd 0x47 2 64 1", 6533 ifname); 6534 /* disable PSD Boost */ 6535 run_system_wrapper(dut, 6536 "wifitool %s setUnitTestCmd 0x48 2 142 1", 6537 ifname); 6538 /* Enable mix bw */ 6539 run_system_wrapper(dut, 6540 "wifitool %s setUnitTestCmd 0x47 2 141 1", 6541 ifname); 6542 /* Disable preferred AC */ 6543 run_system_wrapper(dut, 6544 "wifitool %s setUnitTestCmd 0x48 2 186 0", 6545 ifname); 6546 run_iwpriv(dut, basedev, "he_muedca_mode 0"); 6547 run_iwpriv(dut, ifname, "he_ul_ofdma 0"); 6548 run_iwpriv(dut, ifname, "he_dl_ofdma 0"); 6549 if (dut->he_set_sta_1x1 == VALUE_ENABLED) { 6550 /* sets g_force_1x1_peer to 1 */ 6551 run_system_wrapper(dut, 6552 "wifitool %s setUnitTestCmd 0x48 2 118 1", 6553 ifname); 6554 } 6555 if (dut->ap_txBF) { 6556 /* Enable SU_AX sounding */ 6557 run_iwpriv(dut, ifname, "he_sounding_mode 1"); 6558 /* Ignore TBTT for NDP */ 6559 run_system_wrapper(dut, 6560 "wifitool %s setUnitTestCmd 0x48 2 2 1", 6561 ifname); 6562 /* g_cv_query_enable=1, i.e., cv query enable */ 6563 run_system_wrapper(dut, 6564 "wifitool %s setUnitTestCmd 0x47 2 7 1", 6565 ifname); 6566 /* Override TPC calculations and set TxBF flag to True 6567 */ 6568 run_system_wrapper(dut, 6569 "wifitool %s setUnitTestCmd 0x47 2 47 1", 6570 ifname); 6571 } 6572 if (dut->device_type == AP_testbed) { 6573 run_iwpriv(dut, ifname, "tx_stbc 0"); 6574 run_iwpriv(dut, ifname, "he_txmcsmap 0x0"); 6575 run_iwpriv(dut, ifname, "he_rxmcsmap 0x0"); 6576 run_iwpriv(dut, ifname, "he_amsdu_in_ampdu_supp 0"); 6577 run_iwpriv(dut, ifname, "he_bfee_sts_supp 0 0"); 6578 run_iwpriv(dut, ifname, "he_4xltf_800nsgi_rx 0"); 6579 run_iwpriv(dut, ifname, "he_1xltf_800nsgi_rx 0"); 6580 run_iwpriv(dut, ifname, "he_max_nc 0"); 6581 run_iwpriv(dut, ifname, "he_bsr_supp 0"); 6582 run_iwpriv(dut, ifname, "rx_stbc 0"); 6583 if (dut->ap_he_dlofdma == VALUE_DISABLED) 6584 run_iwpriv(dut, ifname, "he_dlofdma 0"); 6585 if (dut->ap_channel <= 11) { 6586 dut->ap_bcc = VALUE_ENABLED; 6587 run_iwpriv(dut, ifname, "vht_11ng 0"); 6588 } 6589 if (!dut->ap_txBF) { 6590 run_iwpriv(dut, ifname, "he_subfer 0"); 6591 run_iwpriv(dut, ifname, "he_subfee 0"); 6592 } 6593 if (!dut->ap_mu_txBF) { 6594 run_iwpriv(dut, ifname, "he_mubfer 0"); 6595 run_iwpriv(dut, ifname, "he_mubfee 0"); 6596 } 6597 if (dut->ap_cipher == AP_WEP || 6598 dut->ap_cipher == AP_TKIP) 6599 run_iwpriv(dut, ifname, "htweptkip 1"); 6600 if (dut->ap_rx_streams || dut->ap_tx_streams) 6601 run_iwpriv(dut, ifname, "nss %d", 6602 dut->ap_rx_streams); 6603 } 6604 } 6605 6606 if (dut->ap_he_ulofdma == VALUE_ENABLED) { 6607 run_iwpriv(dut, ifname, "he_ul_ofdma 1"); 6608 run_iwpriv(dut, ifname, "he_mu_edca 1"); 6609 6610 /* Disable sounding for UL OFDMA */ 6611 run_system_wrapper(dut, "wifitool %s setUnitTestCmd 0x47 2 7 0", 6612 ifname); 6613 6614 if ((dut->ap_rx_streams || dut->ap_tx_streams) && 6615 dut->device_type == AP_testbed) { 6616 unsigned int txchainmask = 0x00; 6617 6618 switch (dut->ap_rx_streams) { 6619 case 1: 6620 txchainmask = 0x01; 6621 break; 6622 case 2: 6623 txchainmask = 0x03; 6624 break; 6625 case 3: 6626 txchainmask = 0x07; 6627 break; 6628 case 4: 6629 txchainmask = 0x0f; 6630 break; 6631 case 5: 6632 txchainmask = 0x1f; 6633 break; 6634 case 6: 6635 txchainmask = 0x3f; 6636 break; 6637 case 7: 6638 txchainmask = 0x7f; 6639 break; 6640 case 8: 6641 txchainmask = 0xff; 6642 break; 6643 } 6644 6645 run_iwpriv(dut, ifname, "he_ul_nss %d", 6646 dut->ap_rx_streams); 6647 run_iwpriv(dut, basedev, "txchainmask %d", txchainmask); 6648 run_iwpriv(dut, basedev, "rxchainmask %d", txchainmask); 6649 } 6650 6651 if (dut->ap_channel == 100 && dut->device_type == AP_testbed) 6652 run_system_wrapper(dut, "iwpriv %s inact 1000", ifname); 6653 6654 if (dut->he_ul_mcs) 6655 run_iwpriv(dut, ifname, "he_ul_mcs %d", dut->he_ul_mcs); 6656 6657 run_iwpriv(dut, ifname, "he_ul_ltf 3"); 6658 run_iwpriv(dut, ifname, "he_ul_shortgi 3"); 6659 run_iwpriv(dut, basedev, "he_ul_trig_int 2"); 6660 6661 /* Disable efficiency check for UL OFDMA. We do not send TBPPDU 6662 * for one user. With this command, we would send UL OFDMA even 6663 * for one user to allow testing to be done without requiring 6664 * more than one station. */ 6665 run_system_wrapper(dut, 6666 "wifitool %s setUnitTestCmd 0x47 2 131 0", 6667 ifname); 6668 /* Set random RU allocation */ 6669 run_system_wrapper(dut, "wifitool %s setUnitTestCmd 0x47 2 9 1", 6670 ifname); 6671 /* To set TBTT PPDU duration (us) */ 6672 run_system_wrapper(dut, 6673 "wifitool %s setUnitTestCmd 0x48 2 63 1908", 6674 ifname); 6675 } 6676 6677 if (dut->ap_he_dlofdma == VALUE_ENABLED) { 6678 run_iwpriv(dut, ifname, "he_dl_ofdma 1", ifname); 6679 6680 /* For fixed MCS */ 6681 novap_reset(dut, ifname, 0); 6682 run_iwpriv(dut, ifname, 6683 "cfg80211tool %s setratemask 3 0x80f80f80 0x0f80f80f 0xf80f80f8"); 6684 } 6685 6686 if (dut->ap_he_ppdu == PPDU_MU && dut->ap_he_dlofdma == VALUE_ENABLED) { 6687 /* Increase the min TX time limit for MU MIMO to disable MU MIMO 6688 * scheduling */ 6689 run_system_wrapper(dut, 6690 "wifitool %s setUnitTestCmd 0x47 2 11 1000000", 6691 ifname); 6692 /* Increase the max TX time limit for DL OFDMA to enable OFDMA 6693 * scheduling */ 6694 run_system_wrapper(dut, 6695 "wifitool %s setUnitTestCmd 0x47 2 17 1000000", 6696 ifname); 6697 /* Disable 'force SU schedule' to enable MU sch */ 6698 run_system_wrapper(dut, "wifitool %s setUnitTestCmd 0x47 2 8 0", 6699 ifname); 6700 /* Enable MU 11ax support in sch algo */ 6701 run_system_wrapper(dut, 6702 "wifitool %s setUnitTestCmd 0x47 2 29 0", 6703 ifname); 6704 /* Enable to sort RU allocation */ 6705 run_system_wrapper(dut, "wifitool %s setUnitTestCmd 0x4b 2 2 1", 6706 ifname); 6707 } 6708 6709 if (dut->ap_numsounddim) { 6710 unsigned int txchainmask = 0; 6711 6712 switch (dut->ap_numsounddim) { 6713 case 1: 6714 txchainmask = 0x01; 6715 break; 6716 case 2: 6717 txchainmask = 0x03; 6718 break; 6719 case 3: 6720 txchainmask = 0x07; 6721 break; 6722 case 4: 6723 txchainmask = 0x0f; 6724 break; 6725 case 5: 6726 txchainmask = 0x1f; 6727 break; 6728 case 6: 6729 txchainmask = 0x3f; 6730 break; 6731 case 7: 6732 txchainmask = 0x7f; 6733 break; 6734 case 8: 6735 txchainmask = 0xff; 6736 break; 6737 } 6738 run_iwpriv(dut, basedev, "txchainmask %d", txchainmask); 6739 } 6740 6741 if (dut->ap_numsounddim && dut->device_type == AP_testbed) { 6742 /* Sets g_force_1x1_peer to 1 which should be reset to zero 6743 * for non-MU test cases */ 6744 run_system_wrapper(dut, 6745 "wifitool %s setUnitTestCmd 0x48 2 118 1", 6746 ifname); 6747 if (dut->ap_mu_txBF) { 6748 /* Disable DL OFDMA */ 6749 run_system_wrapper(dut, 6750 "wifitool %s setUnitTestCmd 0x47 2 11 0", 6751 ifname); 6752 } 6753 } 6754 6755 if (dut->ap_bcc == VALUE_ENABLED) { 6756 run_iwpriv(dut, ifname, "mode 11AHE20"); 6757 run_iwpriv(dut, ifname, "nss 2"); 6758 run_iwpriv(dut, ifname, "he_txmcsmap 0x0"); 6759 run_iwpriv(dut, ifname, "he_rxmcsmap 0x0"); 6760 } 6761 6762 if (dut->ap_he_frag == VALUE_ENABLED) 6763 run_iwpriv(dut, ifname, "he_frag 1"); 6764 else if (dut->ap_he_frag == VALUE_DISABLED) 6765 run_iwpriv(dut, ifname, "he_frag 0"); 6766 6767 if (dut->ap_ba_bufsize != BA_BUFSIZE_NOT_SET) { 6768 if (dut->ap_ba_bufsize == BA_BUFSIZE_64) 6769 run_iwpriv(dut, ifname, "ba_bufsize 0"); 6770 else 6771 run_iwpriv(dut, ifname, "ba_bufsize 1"); 6772 } 6773 6774 if (dut->ap_mu_edca == VALUE_ENABLED) 6775 run_iwpriv(dut, ifname, "he_mu_edca 1"); 6776 6777 if (dut->ap_he_mimo == MIMO_DL) { 6778 mubrp_commands(dut, ifname); 6779 if (dut->device_type != AP_testbed) 6780 run_system_wrapper( 6781 dut, "wifitool %s setUnitTestCmd 0x48 2 100 2", 6782 ifname); 6783 } 6784 6785 if (dut->ap_he_mimo == MIMO_UL) 6786 run_iwpriv(dut, ifname, "he_mubfee 1"); 6787 6788 if (dut->ap_he_rtsthrshld == VALUE_ENABLED) 6789 run_iwpriv(dut, ifname, "he_rtsthrshld 512"); 6790 else if (dut->ap_he_rtsthrshld == VALUE_DISABLED) 6791 run_iwpriv(dut, ifname, "he_rtsthrshld 1024"); 6792 6793 if (dut->ap_mbssid == VALUE_ENABLED && 6794 (dut->ap_rx_streams || dut->ap_tx_streams) && 6795 dut->device_type == AP_testbed) { 6796 const char *ifname_1; 6797 6798 ifname_1= dut->ap_channel >= 36 ? "ath01" : "ath11"; 6799 6800 /* NSS is not set in Secondary VAP for MBSSID case, 6801 * hence it is explicitly set here. For primary VAP 6802 * NSS is set during AP configuration */ 6803 run_iwpriv(dut, ifname_1, "nss %d", dut->ap_rx_streams); 6804 } 6805 6806 if (dut->ap_twtresp == VALUE_ENABLED) 6807 run_iwpriv(dut, ifname, "twt_responder 1"); 6808 else if (dut->ap_twtresp == VALUE_DISABLED) 6809 run_iwpriv(dut, ifname, "twt_responder 0"); 6810 6811 if (dut->program == PROGRAM_HE && dut->ap_fixed_rate) { 6812 int nss = 0, mcs = 0; 6813 uint16_t mcsnssmap = 0; 6814 6815 /* MCS 7 is used - set only nss and he_mcs. 6816 * Do not set mcsnssmap unless MCS is 9 or 11. */ 6817 if (dut->ap_mcs >= 9) { 6818 if (dut->ap_mcs == 9) { 6819 if (dut->ap_tx_streams == 1) { 6820 nss = 1; 6821 mcs = dut->ap_mcs; 6822 } else if (dut->ap_tx_streams == 2) { 6823 nss = 2; 6824 mcs = dut->ap_mcs; 6825 } 6826 } else if (dut->ap_mcs == 11) { 6827 if (dut->ap_tx_streams == 1) { 6828 nss = 1; 6829 mcs = dut->ap_mcs; 6830 } else if (dut->ap_tx_streams == 2) { 6831 nss = 2; 6832 mcs = dut->ap_mcs; 6833 } 6834 } 6835 6836 get_he_mcs_nssmap((uint8_t *) &mcsnssmap, nss, mcs); 6837 he_mcsnssmap = (mcsnssmap << 16) | mcsnssmap; 6838 } 6839 6840 run_iwpriv(dut, ifname, "nss %d", dut->ap_tx_streams); 6841 run_iwpriv(dut, ifname, "he_mcs %d", dut->ap_mcs); 6842 } 6843 6844 if (he_mcsnssmap) { 6845 run_iwpriv(dut, ifname, "he_rxmcsmap %lu", he_mcsnssmap); 6846 run_iwpriv(dut, ifname, "he_txmcsmap %lu", he_mcsnssmap); 6847 } 6848 6849 if (dut->he_sounding == VALUE_ENABLED) 6850 run_system_wrapper(dut, "wifitool %s setUnitTestCmd 0x47 2 7 0", 6851 ifname); 6852 6853 if (dut->he_mmss) 6854 run_iwpriv(dut, ifname, "ampduden_ovrd %d", dut->he_mmss); 6855 6856 if (dut->he_srctrl_allow == 0) { 6857 /* This is a special testbed AP case to enable SR for protocol 6858 * testing when SRCtrl_SRValue15Allowed is specified. 6859 */ 6860 run_iwpriv(dut, ifname, "he_sr_enable 1"); 6861 } 6862 } 6863 6864 6865 static int cmd_ath_ap_config_commit(struct sigma_dut *dut, 6866 struct sigma_conn *conn, 6867 struct sigma_cmd *cmd) 6868 { 6869 /* const char *name = get_param(cmd, "NAME"); */ 6870 char buf[100]; 6871 struct stat s; 6872 const char *ifname = dut->ap_is_dual ? "ath1" : "ath0"; 6873 int res; 6874 6875 if (stat("/proc/athversion", &s) == 0) { 6876 sigma_dut_print(dut, DUT_MSG_INFO, "Run apdown"); 6877 run_system(dut, "apdown"); 6878 } 6879 6880 cmd_ath_ap_radio_config(dut); 6881 6882 snprintf(buf, sizeof(buf), "cfg -a 'AP_SSID=%s'", dut->ap_ssid); 6883 run_system(dut, buf); 6884 6885 switch (dut->ap_key_mgmt) { 6886 case AP_OPEN: 6887 if (dut->ap_cipher == AP_WEP) { 6888 run_system(dut, "cfg -a AP_SECMODE=WEP"); 6889 run_system(dut, "cfg -a AP_SECFILE=NONE"); 6890 /* shared auth mode not supported */ 6891 run_system(dut, "cfg -a AP_WEP_MODE_0=1"); 6892 run_system(dut, "cfg -a AP_WEP_MODE_1=1"); 6893 snprintf(buf, sizeof(buf), 6894 "cfg -a WEP_RADIO_NUM0_KEY_1=%s", 6895 dut->ap_wepkey); 6896 run_system(dut, buf); 6897 snprintf(buf, sizeof(buf), 6898 "cfg -a WEP_RADIO_NUM1_KEY_1=%s", 6899 dut->ap_wepkey); 6900 run_system(dut, buf); 6901 } else { 6902 run_system(dut, "cfg -a AP_SECMODE=None"); 6903 } 6904 break; 6905 case AP_WPA2_PSK: 6906 case AP_WPA2_PSK_MIXED: 6907 case AP_WPA_PSK: 6908 case AP_WPA2_SAE: 6909 case AP_WPA2_PSK_SAE: 6910 if (dut->ap_key_mgmt == AP_WPA2_PSK || 6911 dut->ap_key_mgmt == AP_WPA2_SAE || 6912 dut->ap_key_mgmt == AP_WPA2_PSK_SAE) 6913 run_system(dut, "cfg -a AP_WPA=2"); 6914 else if (dut->ap_key_mgmt == AP_WPA2_PSK_MIXED) 6915 run_system(dut, "cfg -a AP_WPA=3"); 6916 else 6917 run_system(dut, "cfg -a AP_WPA=1"); 6918 /* TODO: SAE configuration */ 6919 run_system(dut, "cfg -a AP_SECMODE=WPA"); 6920 run_system(dut, "cfg -a AP_SECFILE=PSK"); 6921 res = snprintf(buf, sizeof(buf), "cfg -a 'PSK_KEY=%s'", 6922 dut->ap_passphrase); 6923 if (res < 0 || res >= sizeof(buf)) 6924 return ERROR_SEND_STATUS; 6925 run_system(dut, buf); 6926 if (dut->ap_cipher == AP_CCMP_TKIP) 6927 run_system(dut, "cfg -a AP_CYPHER=\"CCMP TKIP\""); 6928 else if (dut->ap_cipher == AP_TKIP) 6929 run_system(dut, "cfg -a AP_CYPHER=TKIP"); 6930 else 6931 run_system(dut, "cfg -a AP_CYPHER=CCMP"); 6932 break; 6933 case AP_WPA2_EAP: 6934 case AP_WPA2_EAP_MIXED: 6935 case AP_WPA_EAP: 6936 if (dut->ap_key_mgmt == AP_WPA2_EAP) 6937 run_system(dut, "cfg -a AP_WPA=2"); 6938 else if (dut->ap_key_mgmt == AP_WPA2_EAP_MIXED) 6939 run_system(dut, "cfg -a AP_WPA=3"); 6940 else 6941 run_system(dut, "cfg -a AP_WPA=1"); 6942 run_system(dut, "cfg -a AP_SECMODE=WPA"); 6943 run_system(dut, "cfg -a AP_SECFILE=EAP"); 6944 if (dut->ap_cipher == AP_CCMP_TKIP) 6945 run_system(dut, "cfg -a AP_CYPHER=\"CCMP TKIP\""); 6946 else if (dut->ap_cipher == AP_TKIP) 6947 run_system(dut, "cfg -a AP_CYPHER=TKIP"); 6948 else 6949 run_system(dut, "cfg -a AP_CYPHER=CCMP"); 6950 snprintf(buf, sizeof(buf), "cfg -a AP_AUTH_SERVER=%s", 6951 dut->ap_radius_ipaddr); 6952 run_system(dut, buf); 6953 snprintf(buf, sizeof(buf), "cfg -a AP_AUTH_PORT=%d", 6954 dut->ap_radius_port); 6955 run_system(dut, buf); 6956 res = snprintf(buf, sizeof(buf), "cfg -a AP_AUTH_SECRET=%s", 6957 dut->ap_radius_password); 6958 if (res < 0 || res >= sizeof(buf)) 6959 return ERROR_SEND_STATUS; 6960 run_system(dut, buf); 6961 break; 6962 case AP_WPA2_EAP_OSEN: 6963 /* TODO */ 6964 sigma_dut_print(dut, DUT_MSG_ERROR, "EAP+OSEN not supported"); 6965 break; 6966 case AP_SUITEB: 6967 /* TODO */ 6968 sigma_dut_print(dut, DUT_MSG_ERROR, "SuiteB not supported"); 6969 break; 6970 case AP_WPA2_OWE: 6971 /* TODO */ 6972 sigma_dut_print(dut, DUT_MSG_ERROR, "OWE not supported"); 6973 break; 6974 case AP_WPA2_FT_EAP: 6975 case AP_WPA2_FT_PSK: 6976 case AP_WPA2_EAP_SHA256: 6977 case AP_WPA2_PSK_SHA256: 6978 case AP_WPA2_ENT_FT_EAP: 6979 case AP_OSEN: 6980 /* TODO */ 6981 send_resp(dut, conn, SIGMA_ERROR, 6982 "errorCode,Unsupported KeyMgnt value"); 6983 return 0; 6984 } 6985 6986 if (dut->ap_is_dual) { 6987 /* ath1 settings in case of dual */ 6988 snprintf(buf, sizeof(buf), "cfg -a 'AP_SSID_2=%s'", 6989 dut->ap_ssid); 6990 run_system(dut, buf); 6991 6992 switch (dut->ap_key_mgmt) { 6993 case AP_OPEN: 6994 if (dut->ap_cipher == AP_WEP) { 6995 run_system(dut, "cfg -a AP_SECMODE_2=WEP"); 6996 run_system(dut, "cfg -a AP_SECFILE_2=NONE"); 6997 /* shared auth mode not supported */ 6998 run_system(dut, "cfg -a AP_WEP_MODE_0=1"); 6999 run_system(dut, "cfg -a AP_WEP_MODE_1=1"); 7000 snprintf(buf, sizeof(buf), 7001 "cfg -a WEP_RADIO_NUM0_KEY_1=%s", 7002 dut->ap_wepkey); 7003 run_system(dut, buf); 7004 snprintf(buf, sizeof(buf), 7005 "cfg -a WEP_RADIO_NUM1_KEY_1=%s", 7006 dut->ap_wepkey); 7007 run_system(dut, buf); 7008 } else { 7009 run_system(dut, "cfg -a AP_SECMODE_2=None"); 7010 } 7011 break; 7012 case AP_WPA2_PSK: 7013 case AP_WPA2_PSK_MIXED: 7014 case AP_WPA_PSK: 7015 case AP_WPA2_SAE: 7016 case AP_WPA2_PSK_SAE: 7017 if (dut->ap_key_mgmt == AP_WPA2_PSK || 7018 dut->ap_key_mgmt == AP_WPA2_SAE || 7019 dut->ap_key_mgmt == AP_WPA2_PSK_SAE) 7020 run_system(dut, "cfg -a AP_WPA_2=2"); 7021 else if (dut->ap_key_mgmt == AP_WPA2_PSK_MIXED) 7022 run_system(dut, "cfg -a AP_WPA_2=3"); 7023 else 7024 run_system(dut, "cfg -a AP_WPA_2=1"); 7025 // run_system(dut, "cfg -a AP_WPA_2=2"); 7026 /* TODO: SAE configuration */ 7027 run_system(dut, "cfg -a AP_SECMODE_2=WPA"); 7028 run_system(dut, "cfg -a AP_SECFILE_2=PSK"); 7029 res = snprintf(buf, sizeof(buf), 7030 "cfg -a 'PSK_KEY_2=%s'", 7031 dut->ap_passphrase); 7032 if (res < 0 || res >= sizeof(buf)) 7033 return ERROR_SEND_STATUS; 7034 run_system(dut, buf); 7035 if (dut->ap_cipher == AP_CCMP_TKIP) 7036 run_system(dut, "cfg -a AP_CYPHER_2=\"CCMP TKIP\""); 7037 else if (dut->ap_cipher == AP_TKIP) 7038 run_system(dut, "cfg -a AP_CYPHER_2=TKIP"); 7039 else 7040 run_system(dut, "cfg -a AP_CYPHER_2=CCMP"); 7041 break; 7042 case AP_WPA2_EAP: 7043 case AP_WPA2_EAP_MIXED: 7044 case AP_WPA_EAP: 7045 if (dut->ap_key_mgmt == AP_WPA2_EAP) 7046 run_system(dut, "cfg -a AP_WPA_2=2"); 7047 else if (dut->ap_key_mgmt == AP_WPA2_EAP_MIXED) 7048 run_system(dut, "cfg -a AP_WPA_2=3"); 7049 else 7050 run_system(dut, "cfg -a AP_WPA_2=1"); 7051 run_system(dut, "cfg -a AP_SECMODE_2=WPA"); 7052 run_system(dut, "cfg -a AP_SECFILE_2=EAP"); 7053 if (dut->ap_cipher == AP_CCMP_TKIP) 7054 run_system(dut, "cfg -a AP_CYPHER_2=\"CCMP TKIP\""); 7055 else if (dut->ap_cipher == AP_TKIP) 7056 run_system(dut, "cfg -a AP_CYPHER_2=TKIP"); 7057 else 7058 run_system(dut, "cfg -a AP_CYPHER_2=CCMP"); 7059 7060 snprintf(buf, sizeof(buf), "cfg -a AP_AUTH_SERVER_2=%s", 7061 dut->ap_radius_ipaddr); 7062 run_system(dut, buf); 7063 snprintf(buf, sizeof(buf), "cfg -a AP_AUTH_PORT_2=%d", 7064 dut->ap_radius_port); 7065 run_system(dut, buf); 7066 res = snprintf(buf, sizeof(buf), 7067 "cfg -a AP_AUTH_SECRET_2=%s", 7068 dut->ap_radius_password); 7069 if (res < 0 || res >= sizeof(buf)) 7070 return ERROR_SEND_STATUS; 7071 run_system(dut, buf); 7072 break; 7073 case AP_WPA2_EAP_OSEN: 7074 /* TODO */ 7075 sigma_dut_print(dut, DUT_MSG_ERROR, 7076 "EAP+OSEN not supported"); 7077 break; 7078 case AP_SUITEB: 7079 /* TODO */ 7080 sigma_dut_print(dut, DUT_MSG_ERROR, 7081 "SuiteB not supported"); 7082 break; 7083 case AP_WPA2_OWE: 7084 /* TODO */ 7085 sigma_dut_print(dut, DUT_MSG_ERROR, 7086 "OWE not supported"); 7087 break; 7088 case AP_WPA2_FT_EAP: 7089 case AP_WPA2_FT_PSK: 7090 case AP_WPA2_EAP_SHA256: 7091 case AP_WPA2_PSK_SHA256: 7092 case AP_WPA2_ENT_FT_EAP: 7093 case AP_OSEN: 7094 /* TODO */ 7095 send_resp(dut, conn, SIGMA_ERROR, 7096 "errorCode,Unsupported KeyMgnt value"); 7097 return 0; 7098 } 7099 7100 /* wifi0 settings in case of dual */ 7101 run_system(dut, "cfg -a AP_RADIO_ID=0"); 7102 run_system(dut, "cfg -a AP_PRIMARY_CH=6"); 7103 run_system(dut, "cfg -a AP_STARTMODE=dual"); 7104 run_system(dut, "cfg -a AP_CHMODE=11NGHT40PLUS"); 7105 run_system(dut, "cfg -a TX_CHAINMASK=7"); 7106 run_system(dut, "cfg -a RX_CHAINMASK=7"); 7107 } 7108 7109 switch (dut->ap_pmf) { 7110 case AP_PMF_DISABLED: 7111 snprintf(buf, sizeof(buf), "cfg -a AP_PMF=0"); 7112 run_system(dut, buf); 7113 break; 7114 case AP_PMF_OPTIONAL: 7115 snprintf(buf, sizeof(buf), "cfg -a AP_PMF=1"); 7116 run_system(dut, buf); 7117 break; 7118 case AP_PMF_REQUIRED: 7119 snprintf(buf, sizeof(buf), "cfg -a AP_PMF=2"); 7120 run_system(dut, buf); 7121 break; 7122 } 7123 if (dut->ap_add_sha256) { 7124 snprintf(buf, sizeof(buf), "cfg -a AP_WPA_SHA256=1"); 7125 run_system(dut, buf); 7126 } else { 7127 snprintf(buf, sizeof(buf), "cfg -r AP_WPA_SHA256"); 7128 run_system(dut, buf); 7129 } 7130 7131 if (dut->ap_hs2) 7132 run_system(dut, "cfg -a AP_HOTSPOT=1"); 7133 else 7134 run_system(dut, "cfg -r AP_HOTSPOT"); 7135 7136 if (dut->ap_interworking) { 7137 snprintf(buf, sizeof(buf), "cfg -a AP_HOTSPOT_ANT=%d", 7138 dut->ap_access_net_type); 7139 run_system(dut, buf); 7140 snprintf(buf, sizeof(buf), "cfg -a AP_HOTSPOT_INTERNET=%d", 7141 dut->ap_internet); 7142 run_system(dut, buf); 7143 snprintf(buf, sizeof(buf), "cfg -a AP_HOTSPOT_VENUEGROUP=%d", 7144 dut->ap_venue_group); 7145 run_system(dut, buf); 7146 snprintf(buf, sizeof(buf), "cfg -a AP_HOTSPOT_VENUETYPE=%d", 7147 dut->ap_venue_type); 7148 run_system(dut, buf); 7149 snprintf(buf, sizeof(buf), "cfg -a AP_HOTSPOT_HESSID=%s", 7150 dut->ap_hessid); 7151 run_system(dut, buf); 7152 7153 if (dut->ap_roaming_cons[0]) { 7154 char *second, *rc; 7155 rc = strdup(dut->ap_roaming_cons); 7156 if (rc == NULL) 7157 return 0; 7158 7159 second = strchr(rc, ';'); 7160 if (second) 7161 *second++ = '\0'; 7162 7163 snprintf(buf, sizeof(buf), 7164 "cfg -a AP_HOTSPOT_ROAMINGCONSORTIUM=%s", rc); 7165 run_system(dut, buf); 7166 7167 if (second) { 7168 snprintf(buf, sizeof(buf), 7169 "cfg -a AP_HOTSPOT_ROAMINGCONSORTIUM2" 7170 "=%s", second); 7171 run_system(dut, buf); 7172 } 7173 free(rc); 7174 } else { 7175 run_system(dut, "cfg -r AP_HOTSPOT_ROAMINGCONSORTIUM"); 7176 run_system(dut, 7177 "cfg -r AP_HOTSPOT_ROAMINGCONSORTIUM2"); 7178 } 7179 } else { 7180 run_system(dut, "cfg -r AP_HOTSPOT_ANT"); 7181 run_system(dut, "cfg -r AP_HOTSPOT_INTERNET"); 7182 run_system(dut, "cfg -r AP_HOTSPOT_VENUEGROUP"); 7183 run_system(dut, "cfg -r AP_HOTSPOT_VENUETYPE"); 7184 run_system(dut, "cfg -r AP_HOTSPOT_HESSID"); 7185 run_system(dut, "cfg -r AP_HOTSPOT_ROAMINGCONSORTIUM"); 7186 run_system(dut, "cfg -r AP_HOTSPOT_ROAMINGCONSORTIUM2"); 7187 } 7188 7189 if (dut->ap_proxy_arp) 7190 run_system(dut, "cfg -a IEEE80211V_PROXYARP=1"); 7191 else 7192 run_system(dut, "cfg -a IEEE80211V_PROXYARP=0"); 7193 if (dut->ap_dgaf_disable) 7194 run_system(dut, "cfg -a AP_HOTSPOT_DISABLE_DGAF=1"); 7195 else 7196 run_system(dut, "cfg -r AP_HOTSPOT_DISABLE_DGAF"); 7197 7198 if (strlen(dut->ap_tag_ssid[0])) { 7199 snprintf(buf, sizeof(buf), 7200 "cfg -a AP_SSID_2=%s", dut->ap_tag_ssid[0]); 7201 run_system(dut, buf); 7202 7203 if (dut->ap_tag_key_mgmt[0] == AP2_OSEN) { 7204 run_system(dut, "cfg -a AP_SECMODE_2=WPA"); 7205 run_system(dut, "cfg -a AP_SECFILE_2=OSEN"); 7206 7207 res = snprintf(buf, sizeof(buf), 7208 "cfg -a AP_AUTH_SERVER_2=%s", 7209 dut->ap2_radius_ipaddr); 7210 if (res < 0 || res >= sizeof(buf)) 7211 return ERROR_SEND_STATUS; 7212 run_system(dut, buf); 7213 7214 res = snprintf(buf, sizeof(buf), 7215 "cfg -a AP_AUTH_PORT_2=%d", 7216 dut->ap2_radius_port); 7217 if (res < 0 || res >= sizeof(buf)) 7218 return ERROR_SEND_STATUS; 7219 run_system(dut, buf); 7220 7221 res = snprintf(buf, sizeof(buf), 7222 "cfg -a AP_AUTH_SECRET_2=%s", 7223 dut->ap2_radius_password); 7224 if (res < 0 || res >= sizeof(buf)) 7225 return ERROR_SEND_STATUS; 7226 run_system(dut, buf); 7227 } else { 7228 run_system(dut, "cfg -a AP_SECMODE_2=None"); 7229 run_system(dut, "cfg -r AP_AUTH_SERVER_2"); 7230 run_system(dut, "cfg -r AP_AUTH_PORT_2"); 7231 run_system(dut, "cfg -r AP_AUTH_SECRET_2"); 7232 } 7233 7234 run_system(dut, "cfg -a AP_STARTMODE=multi"); 7235 } 7236 7237 run_system(dut, "cfg -c"); 7238 7239 sigma_dut_print(dut, DUT_MSG_INFO, "Starting AP"); 7240 if (system("apup") != 0) { 7241 /* to be debugged why apup returns error 7242 send_resp(dut, conn, SIGMA_ERROR, 7243 "errorCode,apup failed"); 7244 return 0; 7245 */ 7246 } 7247 sigma_dut_print(dut, DUT_MSG_INFO, "AP started"); 7248 7249 if (dut->ap_key_mgmt != AP_OPEN) { 7250 int res; 7251 /* allow some time for hostapd to start before returning 7252 * success */ 7253 usleep(500000); 7254 if (run_hostapd_cli(dut, "ping") != 0) { 7255 send_resp(dut, conn, SIGMA_ERROR, 7256 "errorCode,Failed to talk to hostapd"); 7257 return 0; 7258 } 7259 7260 if (dut->ap_hs2 && !dut->ap_anqpserver) { 7261 /* the cfg app doesn't like ";" in the variables */ 7262 res = ath_ap_append_hostapd_conf(dut); 7263 if (res < 0) 7264 return res; 7265 7266 /* wait for hostapd to be ready */ 7267 usleep(500000); 7268 if (run_hostapd_cli(dut, "ping") != 0) { 7269 send_resp(dut, conn, SIGMA_ERROR, 7270 "errorCode,Failed to talk to " 7271 "hostapd"); 7272 return 0; 7273 } 7274 } 7275 } 7276 7277 ath_ap_set_params(dut); 7278 7279 if (dut->ap_anqpserver) 7280 return cmd_ath_ap_anqpserver_start(dut); 7281 7282 if (dut->ap2_proxy_arp) 7283 run_iwpriv(dut, ifname, "proxy_arp 1"); 7284 7285 if (dut->ap_allow_vht_wep || dut->ap_allow_vht_tkip) 7286 run_iwpriv(dut, ifname, "htweptkip 1"); 7287 7288 return 1; 7289 } 7290 7291 7292 static int set_ebtables_proxy_arp(struct sigma_dut *dut, const char *chain, 7293 const char *ifname) 7294 { 7295 char buf[200]; 7296 7297 if (!chain || !ifname) 7298 return -2; 7299 7300 snprintf(buf, sizeof(buf), "ebtables -P %s ACCEPT", chain); 7301 if (system(buf) != 0) { 7302 sigma_dut_print(dut, DUT_MSG_ERROR, 7303 "Failed to set ebtables rules, RULE-1, %s", 7304 chain); 7305 return -2; 7306 } 7307 7308 snprintf(buf, sizeof(buf), 7309 "ebtables -A %s -p ARP -d Broadcast -o %s -j DROP", 7310 chain, ifname); 7311 if (system(buf) != 0) { 7312 sigma_dut_print(dut, DUT_MSG_ERROR, 7313 "Failed to set ebtables rules, RULE-2, %s", 7314 chain); 7315 return -2; 7316 } 7317 7318 snprintf(buf, sizeof(buf), 7319 "ebtables -A %s -d Multicast -p IPv6 --ip6-protocol ipv6-icmp --ip6-icmp-type neighbor-solicitation -o %s -j DROP", 7320 chain, ifname); 7321 if (system(buf) != 0) { 7322 sigma_dut_print(dut, DUT_MSG_ERROR, 7323 "Failed to set ebtables rules, RULE-3, %s", 7324 chain); 7325 return -2; 7326 } 7327 7328 snprintf(buf, sizeof(buf), 7329 "ebtables -A %s -d Multicast -p IPv6 --ip6-protocol ipv6-icmp --ip6-icmp-type neighbor-advertisement -o %s -j DROP", 7330 chain, ifname); 7331 if (system(buf) != 0) { 7332 sigma_dut_print(dut, DUT_MSG_ERROR, 7333 "Failed to set ebtables rules, RULE-4, %s", 7334 chain); 7335 return -2; 7336 } 7337 7338 return 0; 7339 } 7340 7341 7342 static int set_ebtables_disable_dgaf(struct sigma_dut *dut, 7343 const char *chain, 7344 const char *ifname) 7345 { 7346 char buf[200]; 7347 7348 if (!chain || !ifname) 7349 return -2; 7350 7351 snprintf(buf, sizeof(buf), "ebtables -P %s ACCEPT", chain); 7352 if (system(buf) != 0) { 7353 sigma_dut_print(dut, DUT_MSG_ERROR, 7354 "Failed to set ebtables rules, RULE-5, %s", 7355 chain); 7356 return -2; 7357 } 7358 7359 snprintf(buf, sizeof(buf), 7360 "ebtables -A %s -p ARP -d Broadcast -o %s -j DROP", 7361 chain, ifname); 7362 if (system(buf) != 0) { 7363 sigma_dut_print(dut, DUT_MSG_ERROR, 7364 "Failed to set ebtables rules, RULE-6, %s", 7365 chain); 7366 return -2; 7367 } 7368 7369 snprintf(buf, sizeof(buf), 7370 "ebtables -A %s -p IPv4 -d Multicast -o %s -j DROP", 7371 chain, ifname); 7372 if (system(buf) != 0) { 7373 sigma_dut_print(dut, DUT_MSG_ERROR, 7374 "Failed to set ebtables rules, RULE-7, %s", 7375 chain); 7376 return -2; 7377 } 7378 7379 snprintf(buf, sizeof(buf), 7380 "ebtables -A %s -p IPv6 -d Multicast -o %s -j DROP", 7381 chain, ifname); 7382 if (system(buf) != 0) { 7383 sigma_dut_print(dut, DUT_MSG_ERROR, 7384 "Failed to set ebtables rules, RULE-8, %s", 7385 chain); 7386 return -2; 7387 } 7388 7389 return 0; 7390 } 7391 7392 7393 static void set_ebtables_forward_drop(struct sigma_dut *dut, 7394 const char *ifname, const char *ifname2) 7395 { 7396 char buf[128]; 7397 7398 snprintf(buf, sizeof(buf), "ebtables -A FORWARD -i %s -o %s -j DROP", 7399 ifname, ifname2); 7400 if (system(buf) != 0) 7401 sigma_dut_print(dut, DUT_MSG_ERROR, 7402 "Failed to set ebtables rule"); 7403 7404 snprintf(buf, sizeof(buf), "ebtables -A FORWARD -i %s -o %s -j DROP", 7405 ifname2, ifname); 7406 if (system(buf) != 0) 7407 sigma_dut_print(dut, DUT_MSG_ERROR, 7408 "Failed to set ebtables rule"); 7409 } 7410 7411 7412 static int check_channel(int channel) 7413 { 7414 int channel_list[] = { 36, 40, 44, 48, 52, 60, 64, 100, 104, 108, 112, 7415 116, 120, 124, 128, 132, 140, 144, 149, 153, 157, 7416 161, 165 }; 7417 int num_chan = sizeof(channel_list) / sizeof(int); 7418 int i; 7419 7420 for (i = 0; i < num_chan; i++) { 7421 if (channel == channel_list[i]) 7422 return i; 7423 } 7424 7425 return -1; 7426 } 7427 7428 7429 static int get_oper_centr_freq_seq_idx(int chwidth, int channel) 7430 { 7431 int ch_base; 7432 int period; 7433 7434 if (check_channel(channel) < 0) 7435 return -1; 7436 7437 if (channel >= 36 && channel <= 64) 7438 ch_base = 36; 7439 else if (channel >= 100 && channel <= 144) 7440 ch_base = 100; 7441 else 7442 ch_base = 149; 7443 7444 period = channel % ch_base * 5 / chwidth; 7445 return ch_base + period * chwidth / 5 + (chwidth - 20) / 10; 7446 } 7447 7448 7449 static int is_ht40plus_chan(int chan) 7450 { 7451 return chan == 36 || chan == 44 || chan == 52 || chan == 60 || 7452 chan == 100 || chan == 108 || chan == 116 || chan == 124 || 7453 chan == 132 || chan == 149 || chan == 157; 7454 } 7455 7456 7457 static int is_ht40minus_chan(int chan) 7458 { 7459 return chan == 40 || chan == 48 || chan == 56 || chan == 64 || 7460 chan == 104 || chan == 112 || chan == 120 || chan == 128 || 7461 chan == 136 || chan == 144 || chan == 153 || chan == 161; 7462 } 7463 7464 7465 static int get_5g_channel_freq(int chan) 7466 { 7467 return 5000 + chan * 5; 7468 } 7469 7470 7471 static const char * hostapd_cipher_name(enum ap_cipher cipher) 7472 { 7473 switch (cipher) { 7474 case AP_CCMP: 7475 return "CCMP"; 7476 case AP_TKIP: 7477 return "TKIP"; 7478 case AP_CCMP_TKIP: 7479 return "CCMP TKIP"; 7480 case AP_GCMP_256: 7481 return "GCMP-256"; 7482 case AP_GCMP_128: 7483 return "GCMP"; 7484 case AP_CCMP_256: 7485 return "CCMP-256"; 7486 case AP_CCMP_128_GCMP_256: 7487 return "CCMP GCMP-256"; 7488 default: 7489 return "UNKNOWN"; 7490 } 7491 } 7492 7493 7494 static const char * 7495 hostapd_group_mgmt_cipher_name(enum ap_group_mgmt_cipher cipher) 7496 { 7497 switch (cipher) { 7498 case AP_BIP_GMAC_256: 7499 return "BIP-GMAC-256"; 7500 case AP_BIP_CMAC_256: 7501 return "BIP-CMAC-256"; 7502 case AP_BIP_GMAC_128: 7503 return "BIP-GMAC-128"; 7504 case AP_BIP_CMAC_128: 7505 return "AES-128-CMAC"; 7506 default: 7507 return "UNKNOWN"; 7508 } 7509 } 7510 7511 7512 static int ap_set_60g_ese(struct sigma_dut *dut, int count, 7513 struct sigma_ese_alloc *allocs) 7514 { 7515 switch (get_driver_type(dut)) { 7516 #ifdef __linux__ 7517 case DRIVER_WIL6210: 7518 return wil6210_set_ese(dut, count, allocs); 7519 #endif /* __linux__ */ 7520 default: 7521 sigma_dut_print(dut, DUT_MSG_ERROR, 7522 "Unsupported ap_set_60g_ese with the current driver"); 7523 return -1; 7524 } 7525 } 7526 7527 7528 static int ap_set_force_mcs(struct sigma_dut *dut, int force, int mcs) 7529 { 7530 switch (get_driver_type(dut)) { 7531 #ifdef __linux__ 7532 case DRIVER_WIL6210: 7533 return wil6210_set_force_mcs(dut, force, mcs); 7534 #endif /* __linux__ */ 7535 default: 7536 sigma_dut_print(dut, DUT_MSG_ERROR, 7537 "Unsupported ap_set_force_mcs with the current driver"); 7538 return -1; 7539 } 7540 } 7541 7542 7543 static int write_hostapd_conf_password(struct sigma_dut *dut, FILE *f, int sae) 7544 { 7545 if (sae && dut->ap_sae_pk) { 7546 if (!dut->ap_sae_pk_modifier) { 7547 sigma_dut_print(dut, DUT_MSG_ERROR, 7548 "SAE-PK modifier not configured"); 7549 return -1; 7550 } 7551 if (!dut->ap_sae_pk_keypair) { 7552 sigma_dut_print(dut, DUT_MSG_ERROR, 7553 "SAE-PK keypair not configured"); 7554 return -1; 7555 } 7556 if (dut->ap_sae_pk_keypair_sig) 7557 fprintf(f, "sae_password=%s|pk=%s:%s:%s\n", 7558 dut->ap_passphrase, 7559 dut->ap_sae_pk_modifier, 7560 dut->ap_sae_pk_keypair, 7561 dut->ap_sae_pk_keypair_sig); 7562 else 7563 fprintf(f, "sae_password=%s|pk=%s:%s\n", 7564 dut->ap_passphrase, 7565 dut->ap_sae_pk_modifier, 7566 dut->ap_sae_pk_keypair); 7567 } else if (sae) { 7568 fprintf(f, "sae_password=%s\n", dut->ap_passphrase); 7569 } else if (!dut->ap_passphrase[0] && dut->ap_psk[0]) { 7570 fprintf(f, "wpa_psk=%s", dut->ap_psk); 7571 } else if (dut->ap_passphrase[0]) { 7572 fprintf(f, "wpa_passphrase=%s\n", dut->ap_passphrase); 7573 } 7574 7575 return 0; 7576 } 7577 7578 7579 enum sigma_cmd_result cmd_ap_config_commit(struct sigma_dut *dut, 7580 struct sigma_conn *conn, 7581 struct sigma_cmd *cmd) 7582 { 7583 /* const char *name = get_param(cmd, "NAME"); */ 7584 FILE *f; 7585 const char *ifname; 7586 char buf[500]; 7587 char path[100]; 7588 char ap_conf_path[100]; 7589 enum driver_type drv; 7590 const char *key_mgmt; 7591 #ifdef ANDROID 7592 struct group *gr; 7593 #endif /* ANDROID */ 7594 7595 drv = get_driver_type(dut); 7596 7597 if (dut->mode == SIGMA_MODE_STATION) { 7598 stop_sta_mode(dut); 7599 sleep(1); 7600 } 7601 7602 if (dut->mode == SIGMA_MODE_SNIFFER && dut->sniffer_ifname) { 7603 snprintf(buf, sizeof(buf), "ifconfig %s down", 7604 dut->sniffer_ifname); 7605 if (system(buf) != 0) { 7606 sigma_dut_print(dut, DUT_MSG_INFO, 7607 "Failed to run '%s'", buf); 7608 } 7609 snprintf(buf, sizeof(buf), "iw dev %s set type station", 7610 dut->sniffer_ifname); 7611 if (system(buf) != 0) { 7612 sigma_dut_print(dut, DUT_MSG_INFO, 7613 "Failed to run '%s'", buf); 7614 } 7615 } 7616 7617 dut->mode = SIGMA_MODE_AP; 7618 7619 if (drv == DRIVER_ATHEROS) 7620 return cmd_ath_ap_config_commit(dut, conn, cmd); 7621 if (drv == DRIVER_WCN) 7622 return cmd_wcn_ap_config_commit(dut, conn, cmd); 7623 if (drv == DRIVER_OPENWRT) 7624 return cmd_owrt_ap_config_commit(dut, conn, cmd); 7625 7626 concat_sigma_tmpdir(dut, "/sigma_dut-ap.conf", ap_conf_path, 7627 sizeof(ap_conf_path)); 7628 f = fopen(ap_conf_path, "w"); 7629 if (f == NULL) { 7630 sigma_dut_print(dut, DUT_MSG_ERROR, 7631 "%s: Failed to open sigma_dut-ap.conf", 7632 __func__); 7633 return -2; 7634 } 7635 7636 ifname = get_hostapd_ifname(dut); 7637 7638 switch (dut->ap_mode) { 7639 case AP_11g: 7640 case AP_11b: 7641 case AP_11ng: 7642 fprintf(f, "hw_mode=g\n"); 7643 break; 7644 case AP_11a: 7645 case AP_11na: 7646 case AP_11ac: 7647 fprintf(f, "hw_mode=a\n"); 7648 break; 7649 case AP_11ad: 7650 fprintf(f, "hw_mode=ad\n"); 7651 break; 7652 case AP_11ax: 7653 if (dut->use_5g) 7654 fprintf(f, "hw_mode=a\n"); 7655 else 7656 fprintf(f, "hw_mode=g\n"); 7657 break; 7658 default: 7659 fclose(f); 7660 return -1; 7661 } 7662 7663 if (drv == DRIVER_MAC80211 || drv == DRIVER_LINUX_WCN) 7664 fprintf(f, "driver=nl80211\n"); 7665 7666 if ((drv == DRIVER_MAC80211 || drv == DRIVER_QNXNTO || 7667 drv == DRIVER_LINUX_WCN) && 7668 (dut->ap_mode == AP_11ng || dut->ap_mode == AP_11na || 7669 (dut->ap_mode == AP_11ax && !dut->use_5g))) { 7670 int ht40plus = 0, ht40minus = 0, tx_stbc = 0; 7671 7672 fprintf(f, "ieee80211n=1\n"); 7673 if (dut->ap_mode == AP_11ax) 7674 fprintf(f, "ieee80211ax=1\n"); 7675 if (dut->ap_mode == AP_11ng && 7676 (dut->ap_chwidth == AP_40 || 7677 (dut->ap_chwidth == AP_AUTO && 7678 dut->default_11ng_ap_chwidth == AP_40))) { 7679 if (dut->ap_channel >= 1 && dut->ap_channel <= 7) 7680 ht40plus = 1; 7681 else if (dut->ap_channel >= 8 && dut->ap_channel <= 11) 7682 ht40minus = 1; 7683 fprintf(f, "obss_interval=300\n"); 7684 } 7685 7686 /* configure ht_capab based on channel width */ 7687 if (dut->ap_mode == AP_11na && 7688 (dut->ap_chwidth == AP_40 || 7689 (dut->ap_chwidth == AP_AUTO && 7690 dut->default_11na_ap_chwidth == AP_40))) { 7691 if (is_ht40plus_chan(dut->ap_channel)) 7692 ht40plus = 1; 7693 else if (is_ht40minus_chan(dut->ap_channel)) 7694 ht40minus = 1; 7695 } 7696 7697 if (dut->ap_tx_stbc) 7698 tx_stbc = 1; 7699 7700 /* Overwrite the ht_capab with offset value if configured */ 7701 if (dut->ap_chwidth == AP_40 && 7702 dut->ap_chwidth_offset == SEC_CH_40ABOVE) { 7703 ht40plus = 1; 7704 ht40minus = 0; 7705 } else if (dut->ap_chwidth == AP_40 && 7706 dut->ap_chwidth_offset == SEC_CH_40BELOW) { 7707 ht40minus = 1; 7708 ht40plus = 0; 7709 } 7710 7711 fprintf(f, "ht_capab=%s%s%s\n", 7712 ht40plus ? "[HT40+]" : "", 7713 ht40minus ? "[HT40-]" : "", 7714 tx_stbc ? "[TX-STBC]" : ""); 7715 } 7716 7717 if ((drv == DRIVER_MAC80211 || drv == DRIVER_QNXNTO || 7718 drv == DRIVER_LINUX_WCN) && 7719 (dut->ap_mode == AP_11ac || 7720 (dut->ap_mode == AP_11ax && dut->use_5g))) { 7721 int ht40plus = 0, ht40minus = 0; 7722 7723 fprintf(f, "ieee80211ac=1\n" 7724 "ieee80211n=1\n"); 7725 if (dut->ap_mode == AP_11ax) 7726 fprintf(f, "ieee80211ax=1\n"); 7727 7728 /* configure ht_capab based on channel width */ 7729 if (dut->ap_chwidth != AP_20) { 7730 if (is_ht40plus_chan(dut->ap_channel)) 7731 ht40plus = 1; 7732 else if (is_ht40minus_chan(dut->ap_channel)) 7733 ht40minus = 1; 7734 7735 fprintf(f, "ht_capab=%s%s\n", 7736 ht40plus ? "[HT40+]" : "", 7737 ht40minus ? "[HT40-]" : ""); 7738 } 7739 } 7740 7741 if ((drv == DRIVER_MAC80211 || drv == DRIVER_QNXNTO || 7742 drv == DRIVER_LINUX_WCN) && 7743 (dut->ap_mode == AP_11ac || dut->ap_mode == AP_11na)) { 7744 if (dut->ap_countrycode[0]) { 7745 fprintf(f, "country_code=%s\n", dut->ap_countrycode); 7746 fprintf(f, "ieee80211d=1\n"); 7747 fprintf(f, "ieee80211h=1\n"); 7748 } 7749 } 7750 7751 if (drv == DRIVER_LINUX_WCN && dut->ap_mode == AP_11ax) { 7752 if (dut->ap_txBF) { 7753 fprintf(f, "he_su_beamformer=1\n"); 7754 fprintf(f, "he_su_beamformee=1\n"); 7755 if (dut->ap_mu_txBF) 7756 fprintf(f, "he_mu_beamformer=1\n"); 7757 } else { 7758 fprintf(f, "he_su_beamformer=0\n"); 7759 fprintf(f, "he_su_beamformee=0\n"); 7760 fprintf(f, "he_mu_beamformer=0\n"); 7761 } 7762 } 7763 7764 fprintf(f, "interface=%s\n", ifname); 7765 if (dut->bridge) 7766 fprintf(f, "bridge=%s\n", dut->bridge); 7767 fprintf(f, "channel=%d\n", dut->ap_channel); 7768 7769 if (sigma_hapd_ctrl) 7770 fprintf(f, "ctrl_interface=%s\n", sigma_hapd_ctrl); 7771 else 7772 fprintf(f, "ctrl_interface=/var/run/hostapd\n"); 7773 7774 if (dut->ap_ssid[0]) 7775 fprintf(f, "ssid=%s\n", dut->ap_ssid); 7776 else 7777 fprintf(f, "ssid=QCA AP OOB\n"); 7778 if (dut->ap_bcnint) 7779 fprintf(f, "beacon_int=%d\n", dut->ap_bcnint); 7780 if (dut->ap_start_disabled) 7781 fprintf(f, "start_disabled=1\n"); 7782 7783 if (dut->ap_akm_values) { 7784 struct { 7785 int akm; 7786 const char *str; 7787 } akms[] = { 7788 { AKM_WPA_EAP, "WPA-EAP" }, 7789 { AKM_WPA_PSK, "WPA-PSK" }, 7790 { AKM_FT_EAP, "FT-EAP" }, 7791 { AKM_FT_PSK, "FT-PSK" }, 7792 { AKM_EAP_SHA256, "WPA-EAP-SHA256" }, 7793 { AKM_PSK_SHA256, "WPA-PSK-SHA256" }, 7794 { AKM_SAE, "SAE" }, 7795 { AKM_FT_SAE, "FT-SAE" }, 7796 { AKM_SUITE_B, "WPA-EAP-SUITE-B-192" }, 7797 { AKM_FT_SUITE_B, "FT-EAP-SHA384" }, 7798 { AKM_FILS_SHA256, "FILS-SHA256" }, 7799 { AKM_FILS_SHA384, "FILS-SHA384" }, 7800 { AKM_FT_FILS_SHA256, "FT-FILS-SHA256" }, 7801 { AKM_FT_FILS_SHA384, "FT-FILS-SHA384" }, 7802 }; 7803 int first = 1; 7804 unsigned int i; 7805 7806 fprintf(f, "wpa_key_mgmt="); 7807 for (i = 0; i < ARRAY_SIZE(akms); i++) { 7808 if (dut->ap_akm_values & (1 << akms[i].akm)) { 7809 fprintf(f, "%s%s", first ? "" : " ", 7810 akms[i].str); 7811 first = 0; 7812 } 7813 } 7814 fprintf(f, "\n"); 7815 /* TODO: mixed mode and WPAv1 only */ 7816 fprintf(f, "wpa=2\n"); 7817 fprintf(f, "wpa_pairwise=%s\n", 7818 hostapd_cipher_name(dut->ap_cipher)); 7819 if (dut->ap_group_cipher != AP_NO_GROUP_CIPHER_SET) 7820 fprintf(f, "group_cipher=%s\n", 7821 hostapd_cipher_name(dut->ap_group_cipher)); 7822 if (write_hostapd_conf_password( 7823 dut, f, 7824 (dut->ap_akm_values & 7825 ((1 << AKM_SAE) | (1 << AKM_FT_SAE))) && 7826 !(dut->ap_akm_values & 7827 ((1 << AKM_WPA_PSK) | (1 << AKM_FT_PSK))) && 7828 dut->ap_passphrase[0]) < 0) { 7829 fclose(f); 7830 return ERROR_SEND_STATUS; 7831 } 7832 if (dut->ap_akm_values & ((1 << AKM_WPA_EAP) | 7833 (1 << AKM_FT_EAP) | 7834 (1 << AKM_EAP_SHA256) | 7835 (1 << AKM_SUITE_B) | 7836 (1 << AKM_FT_SUITE_B) | 7837 (1 << AKM_FILS_SHA256) | 7838 (1 << AKM_FILS_SHA384) | 7839 (1 << AKM_FT_FILS_SHA256) | 7840 (1 << AKM_FT_FILS_SHA384))) { 7841 fprintf(f, "ieee8021x=1\n"); 7842 fprintf(f, "auth_server_addr=%s\n", 7843 dut->ap_radius_ipaddr); 7844 if (dut->ap_radius_port) 7845 fprintf(f, "auth_server_port=%d\n", 7846 dut->ap_radius_port); 7847 fprintf(f, "auth_server_shared_secret=%s\n", 7848 dut->ap_radius_password); 7849 } 7850 goto skip_key_mgmt; 7851 } 7852 7853 switch (dut->ap_key_mgmt) { 7854 case AP_OPEN: 7855 if (dut->ap_cipher == AP_WEP) 7856 fprintf(f, "wep_key0=%s\n", dut->ap_wepkey); 7857 break; 7858 case AP_WPA2_PSK: 7859 case AP_WPA2_PSK_MIXED: 7860 case AP_WPA_PSK: 7861 case AP_WPA2_SAE: 7862 case AP_WPA2_PSK_SAE: 7863 case AP_WPA2_PSK_SHA256: 7864 case AP_WPA2_FT_PSK: 7865 if (dut->ap_key_mgmt == AP_WPA2_PSK || 7866 dut->ap_key_mgmt == AP_WPA2_SAE || 7867 dut->ap_key_mgmt == AP_WPA2_PSK_SAE || 7868 dut->ap_key_mgmt == AP_WPA2_PSK_SHA256 || 7869 dut->ap_key_mgmt == AP_WPA2_FT_PSK) 7870 fprintf(f, "wpa=2\n"); 7871 else if (dut->ap_key_mgmt == AP_WPA2_PSK_MIXED) 7872 fprintf(f, "wpa=3\n"); 7873 else 7874 fprintf(f, "wpa=1\n"); 7875 if (dut->ap_key_mgmt == AP_WPA2_SAE) 7876 key_mgmt = "SAE"; 7877 else if (dut->ap_key_mgmt == AP_WPA2_PSK_SAE) 7878 key_mgmt = "WPA-PSK SAE"; 7879 else 7880 key_mgmt = "WPA-PSK"; 7881 switch (dut->ap_pmf) { 7882 case AP_PMF_DISABLED: 7883 fprintf(f, "wpa_key_mgmt=%s%s\n", key_mgmt, 7884 dut->ap_add_sha256 ? " WPA-PSK-SHA256" : ""); 7885 break; 7886 case AP_PMF_OPTIONAL: 7887 fprintf(f, "wpa_key_mgmt=%s%s\n", key_mgmt, 7888 dut->ap_add_sha256 ? " WPA-PSK-SHA256" : ""); 7889 break; 7890 case AP_PMF_REQUIRED: 7891 if (dut->ap_key_mgmt == AP_WPA2_SAE) 7892 key_mgmt = "SAE"; 7893 else if (dut->ap_key_mgmt == AP_WPA2_PSK_SAE) 7894 key_mgmt = "WPA-PSK-SHA256 SAE"; 7895 else 7896 key_mgmt = "WPA-PSK-SHA256"; 7897 fprintf(f, "wpa_key_mgmt=%s\n", key_mgmt); 7898 break; 7899 } 7900 if (dut->ap_key_mgmt == AP_WPA2_PSK_SHA256) 7901 fprintf(f, "wpa_key_mgmt=WPA-PSK-SHA256\n"); 7902 else if (dut->ap_key_mgmt == AP_WPA2_FT_PSK) 7903 fprintf(f, "wpa_key_mgmt=FT-PSK\n"); 7904 fprintf(f, "wpa_pairwise=%s\n", 7905 hostapd_cipher_name(dut->ap_cipher)); 7906 if (dut->ap_group_cipher != AP_NO_GROUP_CIPHER_SET) 7907 fprintf(f, "group_cipher=%s\n", 7908 hostapd_cipher_name(dut->ap_group_cipher)); 7909 if (write_hostapd_conf_password( 7910 dut, f, dut->ap_key_mgmt == AP_WPA2_SAE) < 0) { 7911 fclose(f); 7912 return ERROR_SEND_STATUS; 7913 } 7914 break; 7915 case AP_WPA2_EAP: 7916 case AP_WPA2_EAP_MIXED: 7917 case AP_WPA_EAP: 7918 case AP_WPA2_EAP_OSEN: 7919 case AP_WPA2_EAP_SHA256: 7920 case AP_WPA2_FT_EAP: 7921 case AP_WPA2_ENT_FT_EAP: 7922 fprintf(f, "ieee8021x=1\n"); 7923 if (dut->ap_key_mgmt == AP_WPA2_EAP || 7924 dut->ap_key_mgmt == AP_WPA2_EAP_OSEN || 7925 dut->ap_key_mgmt == AP_WPA2_EAP_SHA256 || 7926 dut->ap_key_mgmt == AP_WPA2_FT_EAP || 7927 dut->ap_key_mgmt == AP_WPA2_ENT_FT_EAP) 7928 fprintf(f, "wpa=2\n"); 7929 else if (dut->ap_key_mgmt == AP_WPA2_EAP_MIXED) 7930 fprintf(f, "wpa=3\n"); 7931 else 7932 fprintf(f, "wpa=1\n"); 7933 switch (dut->ap_pmf) { 7934 case AP_PMF_DISABLED: 7935 fprintf(f, "wpa_key_mgmt=WPA-EAP%s\n", 7936 dut->ap_add_sha256 ? " WPA-EAP-SHA256" : ""); 7937 break; 7938 case AP_PMF_OPTIONAL: 7939 fprintf(f, "wpa_key_mgmt=WPA-EAP%s%s\n", 7940 dut->ap_add_sha256 ? " WPA-EAP-SHA256" : "", 7941 dut->ap_key_mgmt == AP_WPA2_EAP_OSEN ? " OSEN" : 7942 ""); 7943 break; 7944 case AP_PMF_REQUIRED: 7945 fprintf(f, "wpa_key_mgmt=WPA-EAP-SHA256%s\n", 7946 dut->ap_key_mgmt == AP_WPA2_EAP_OSEN ? " OSEN" : 7947 ""); 7948 break; 7949 } 7950 if (dut->ap_key_mgmt == AP_WPA2_EAP_SHA256) 7951 fprintf(f, "wpa_key_mgmt=WPA-EAP-SHA256\n"); 7952 else if (dut->ap_key_mgmt == AP_WPA2_FT_EAP) 7953 fprintf(f, "wpa_key_mgmt=FT-EAP\n"); 7954 else if (dut->ap_key_mgmt == AP_WPA2_ENT_FT_EAP) 7955 fprintf(f, "wpa_key_mgmt=FT-EAP WPA-EAP\n"); 7956 fprintf(f, "wpa_pairwise=%s\n", 7957 hostapd_cipher_name(dut->ap_cipher)); 7958 if (dut->ap_group_cipher != AP_NO_GROUP_CIPHER_SET) 7959 fprintf(f, "group_cipher=%s\n", 7960 hostapd_cipher_name(dut->ap_group_cipher)); 7961 fprintf(f, "auth_server_addr=%s\n", dut->ap_radius_ipaddr); 7962 if (dut->ap_radius_port) 7963 fprintf(f, "auth_server_port=%d\n", 7964 dut->ap_radius_port); 7965 fprintf(f, "auth_server_shared_secret=%s\n", 7966 dut->ap_radius_password); 7967 if (dut->program == PROGRAM_HS2_R3) { 7968 fprintf(f, "radius_das_port=3799\n"); 7969 fprintf(f, "radius_das_client=0.0.0.0 %s\n", 7970 dut->ap_radius_password); 7971 fprintf(f, "radius_das_require_event_timestamp=1\n"); 7972 } 7973 break; 7974 case AP_SUITEB: 7975 fprintf(f, "ieee8021x=1\n"); 7976 fprintf(f, "wpa=2\n"); 7977 fprintf(f, "wpa_key_mgmt=WPA-EAP-SUITE-B-192\n"); 7978 fprintf(f, "wpa_pairwise=%s\n", 7979 hostapd_cipher_name(dut->ap_cipher)); 7980 if (dut->ap_group_cipher != AP_NO_GROUP_CIPHER_SET) 7981 fprintf(f, "group_cipher=%s\n", 7982 hostapd_cipher_name(dut->ap_group_cipher)); 7983 if (dut->ap_group_mgmt_cipher != AP_NO_GROUP_MGMT_CIPHER_SET) 7984 fprintf(f, "group_mgmt_cipher=%s\n", 7985 hostapd_group_mgmt_cipher_name( 7986 dut->ap_group_mgmt_cipher)); 7987 fprintf(f, "auth_server_addr=%s\n", dut->ap_radius_ipaddr); 7988 if (dut->ap_radius_port) 7989 fprintf(f, "auth_server_port=%d\n", 7990 dut->ap_radius_port); 7991 fprintf(f, "auth_server_shared_secret=%s\n", 7992 dut->ap_radius_password); 7993 break; 7994 case AP_WPA2_OWE: 7995 fprintf(f, "wpa=2\n"); 7996 fprintf(f, "wpa_key_mgmt=OWE\n"); 7997 fprintf(f, "rsn_pairwise=%s\n", 7998 hostapd_cipher_name(dut->ap_cipher)); 7999 if (dut->ap_sae_groups) { 8000 fprintf(f, "owe_groups=%s\n", dut->ap_sae_groups); 8001 if (dut->owe_ptk_workaround) 8002 fprintf(f, "owe_ptk_workaround=1\n"); 8003 } 8004 break; 8005 case AP_OSEN: 8006 fprintf(f, "osen=1\n"); 8007 fprintf(f, "disable_dgaf=1\n"); 8008 fprintf(f, "wpa_pairwise=%s\n", 8009 hostapd_cipher_name(dut->ap_cipher)); 8010 if (dut->ap_group_cipher != AP_NO_GROUP_CIPHER_SET) 8011 fprintf(f, "group_cipher=%s\n", 8012 hostapd_cipher_name(dut->ap_group_cipher)); 8013 fprintf(f, "auth_server_addr=%s\n", dut->ap_radius_ipaddr); 8014 if (dut->ap_radius_port) 8015 fprintf(f, "auth_server_port=%d\n", 8016 dut->ap_radius_port); 8017 fprintf(f, "auth_server_shared_secret=%s\n", 8018 dut->ap_radius_password); 8019 break; 8020 } 8021 skip_key_mgmt: 8022 8023 if (dut->ap_sae_passwords) { 8024 char *tmp, *pos, *end, *id; 8025 8026 tmp = strdup(dut->ap_sae_passwords); 8027 if (!tmp) { 8028 fclose(f); 8029 return ERROR_SEND_STATUS; 8030 } 8031 8032 pos = tmp; 8033 while (*pos) { 8034 end = strchr(pos, ';'); 8035 if (end) 8036 *end = '\0'; 8037 id = strchr(pos, ':'); 8038 if (id) 8039 *id++ = '\0'; 8040 8041 fprintf(f, "sae_password=%s%s%s\n", 8042 pos, id ? "|id=" : "", id ? id : ""); 8043 if (!end) 8044 break; 8045 pos = end + 1; 8046 } 8047 8048 free(tmp); 8049 } 8050 8051 if (dut->ap_rsn_preauth) 8052 fprintf(f, "rsn_preauth=1\n"); 8053 8054 if (dut->ap_pmksa && dut->ap_pmksa_caching) 8055 fprintf(f, "disable_pmksa_caching=1\n"); 8056 8057 if (dut->ap_beacon_prot) 8058 fprintf(f, "beacon_prot=1\n"); 8059 8060 if (dut->ap_transition_disable) 8061 fprintf(f, "transition_disable=0x%02x\n", 8062 dut->ap_transition_disable); 8063 8064 if (dut->ap_ocvc == 1 || dut->ap_ocvc == 0) 8065 fprintf(f, "ocv=%d\n", dut->ap_ocvc); 8066 8067 switch (dut->ap_pmf) { 8068 case AP_PMF_DISABLED: 8069 break; 8070 case AP_PMF_OPTIONAL: 8071 fprintf(f, "ieee80211w=1\n"); 8072 if (dut->ap_key_mgmt == AP_WPA2_PSK_SAE || 8073 (dut->ap_akm_values & (AKM_SAE | AKM_WPA_PSK)) == 8074 (AKM_SAE | AKM_WPA_PSK)) 8075 fprintf(f, "sae_require_mfp=1\n"); 8076 break; 8077 case AP_PMF_REQUIRED: 8078 fprintf(f, "ieee80211w=2\n"); 8079 break; 8080 } 8081 8082 if (dut->ap_pmf != AP_PMF_DISABLED && 8083 dut->ap_group_mgmt_cipher != AP_NO_GROUP_MGMT_CIPHER_SET) 8084 fprintf(f, "group_mgmt_cipher=%s\n", 8085 hostapd_group_mgmt_cipher_name( 8086 dut->ap_group_mgmt_cipher)); 8087 8088 if (ap_ft_enabled(dut)) { 8089 unsigned char own_addr[ETH_ALEN]; 8090 8091 fprintf(f, "mobility_domain=%s\n", dut->ap_mobility_domain); 8092 fprintf(f, "ft_over_ds=%d\n", dut->ap_ft_ds == VALUE_ENABLED); 8093 if (get_hwaddr(ifname, own_addr) < 0) { 8094 memset(own_addr, 0, ETH_ALEN); 8095 own_addr[0] = 0x02; 8096 } 8097 fprintf(f, 8098 "nas_identifier=%02x%02x%02x%02x%02x%02x.nas.example.com\n", 8099 own_addr[0], own_addr[1], own_addr[2], 8100 own_addr[3], own_addr[4], own_addr[5]); 8101 fprintf(f, "r1_key_holder=%02x%02x%02x%02x%02x%02x\n", 8102 own_addr[0], own_addr[1], own_addr[2], 8103 own_addr[3], own_addr[4], own_addr[5]); 8104 fprintf(f, "ft_psk_generate_local=1\n"); 8105 fprintf(f, "pmk_r1_push=0\n"); 8106 fprintf(f, 8107 "r0kh=ff:ff:ff:ff:ff:ff * 00112233445566778899aabbccddeeff00112233445566778899aabbccddeeff\n"); 8108 fprintf(f, 8109 "r1kh=00:00:00:00:00:00 00:00:00:00:00:00 00112233445566778899aabbccddeeff00112233445566778899aabbccddeeff\n"); 8110 } 8111 8112 if (dut->rsne_override) 8113 fprintf(f, "own_ie_override=%s\n", dut->rsne_override); 8114 if (dut->rsnxe_override_eapol) 8115 fprintf(f, "rsnxe_override_eapol=%s\n", 8116 dut->rsnxe_override_eapol); 8117 8118 if (dut->sae_commit_override) 8119 fprintf(f, "sae_commit_override=%s\n", 8120 dut->sae_commit_override); 8121 8122 if (dut->ap_sae_groups) 8123 fprintf(f, "sae_groups=%s\n", dut->ap_sae_groups); 8124 8125 if (dut->sae_pwe != SAE_PWE_DEFAULT || dut->sae_h2e_default) { 8126 const char *sae_pwe = NULL; 8127 8128 if (dut->sae_pwe == SAE_PWE_LOOP && sae_pw_id_used(dut)) 8129 sae_pwe = "3"; 8130 else if (dut->sae_pwe == SAE_PWE_LOOP) 8131 sae_pwe = "0"; 8132 else if (dut->sae_pwe == SAE_PWE_H2E) 8133 sae_pwe = "1"; 8134 else if (dut->sae_h2e_default) 8135 sae_pwe = "2"; 8136 if (sae_pwe) 8137 fprintf(f, "sae_pwe=%s\n", sae_pwe); 8138 } 8139 8140 if (dut->sae_anti_clogging_threshold >= 0) 8141 fprintf(f, "sae_anti_clogging_threshold=%d\n", 8142 dut->sae_anti_clogging_threshold); 8143 if (dut->sae_reflection) 8144 fprintf(f, "sae_reflection_attack=1\n"); 8145 if (dut->ap_sae_commit_status >= 0) 8146 fprintf(f, "sae_commit_status=%d\n", dut->ap_sae_commit_status); 8147 if (dut->ap_sae_pk_omit) 8148 fprintf(f, "sae_pk_omit=1\n"); 8149 if (dut->sae_confirm_immediate) 8150 fprintf(f, "sae_confirm_immediate=2\n"); 8151 8152 if (dut->ap_p2p_mgmt) 8153 fprintf(f, "manage_p2p=1\n"); 8154 8155 if (dut->ap_tdls_prohibit || dut->ap_l2tif) 8156 fprintf(f, "tdls_prohibit=1\n"); 8157 if (dut->ap_tdls_prohibit_chswitch || dut->ap_l2tif) 8158 fprintf(f, "tdls_prohibit_chan_switch=1\n"); 8159 if (dut->ap_p2p_cross_connect >= 0) { 8160 fprintf(f, "manage_p2p=1\n" 8161 "allow_cross_connection=%d\n", 8162 dut->ap_p2p_cross_connect); 8163 } 8164 8165 if (dut->ap_l2tif || dut->ap_proxy_arp || 8166 dut->ap_key_mgmt == AP_WPA2_EAP_OSEN) { 8167 if (!dut->bridge) { 8168 sigma_dut_print(dut, DUT_MSG_ERROR, 8169 "Bridge must be configured. Run with -b <brname>."); 8170 fclose(f); 8171 return -2; 8172 } 8173 fprintf(f, "ap_isolate=1\n"); 8174 } 8175 8176 if (dut->ap_proxy_arp) 8177 fprintf(f, "proxy_arp=1\n"); 8178 8179 if (dut->ap_wme) 8180 fprintf(f, "wmm_enabled=1\n"); 8181 8182 if (dut->ap_wmmps == AP_WMMPS_ON) 8183 fprintf(f, "uapsd_advertisement_enabled=1\n"); 8184 8185 if (dut->ap_hs2) { 8186 if (dut->ap_bss_load) { 8187 char *bss_load; 8188 8189 switch (dut->ap_bss_load) { 8190 case -1: 8191 bss_load = "bss_load_update_period=10"; 8192 break; 8193 case 1: 8194 /* STA count: 1, CU: 50, AAC: 65535 */ 8195 bss_load = "bss_load_test=1:50:65535"; 8196 break; 8197 case 2: 8198 /* STA count: 1, CU: 200, AAC: 65535 */ 8199 bss_load = "bss_load_test=1:200:65535"; 8200 break; 8201 case 3: 8202 /* STA count: 1, CU: 75, AAC: 65535 */ 8203 bss_load = "bss_load_test=1:75:65535"; 8204 break; 8205 default: 8206 bss_load = NULL; 8207 break; 8208 } 8209 8210 if (!bss_load) { 8211 fclose(f); 8212 return -2; 8213 } 8214 fprintf(f, "%s\n", bss_load); 8215 } 8216 8217 if (append_hostapd_conf_hs2(dut, f)) { 8218 fclose(f); 8219 return -2; 8220 } 8221 } 8222 8223 if (dut->ap_interworking && append_hostapd_conf_interworking(dut, f)) { 8224 fclose(f); 8225 return -2; 8226 } 8227 8228 if (dut->ap_hs2 && strlen(dut->ap_tag_ssid[0])) { 8229 unsigned char bssid[6]; 8230 char ifname2[50]; 8231 8232 if (get_hwaddr(ifname, bssid)) { 8233 fclose(f); 8234 return -2; 8235 } 8236 if (bssid[0] & 0x02) 8237 bssid[5] ^= 0x01; 8238 else 8239 bssid[0] |= 0x02; 8240 8241 snprintf(ifname2, sizeof(ifname2), "%s_1", ifname); 8242 fprintf(f, "bss=%s\n", ifname2); 8243 fprintf(f, "ssid=%s\n", dut->ap_tag_ssid[0]); 8244 if (dut->bridge) 8245 fprintf(f, "bridge=%s\n", dut->bridge); 8246 8247 if (drv == DRIVER_LINUX_WCN) 8248 fprintf(f, "use_driver_iface_addr=1\n"); 8249 else 8250 fprintf(f, "bssid=%02x:%02x:%02x:%02x:%02x:%02x\n", 8251 bssid[0], bssid[1], bssid[2], bssid[3], 8252 bssid[4], bssid[5]); 8253 8254 if (dut->ap_tag_key_mgmt[0] == AP2_OSEN) { 8255 fprintf(f, "osen=1\n"); 8256 /* Disable DGAF for OSEN BSS */ 8257 fprintf(f, "disable_dgaf=1\n"); 8258 fprintf(f, "ap_isolate=1\n"); 8259 if (strlen(dut->ap2_radius_ipaddr)) 8260 fprintf(f, "auth_server_addr=%s\n", 8261 dut->ap2_radius_ipaddr); 8262 if (dut->ap2_radius_port) 8263 fprintf(f, "auth_server_port=%d\n", 8264 dut->ap2_radius_port); 8265 if (strlen(dut->ap2_radius_password)) 8266 fprintf(f, "auth_server_shared_secret=%s\n", 8267 dut->ap2_radius_password); 8268 8269 set_ebtables_forward_drop(dut, ifname, ifname2); 8270 } else if (dut->ap2_osu) { 8271 fprintf(f, "ap_isolate=1\n"); 8272 set_ebtables_forward_drop(dut, ifname, ifname2); 8273 } 8274 8275 if (dut->ap2_proxy_arp) { 8276 if (!dut->bridge) { 8277 sigma_dut_print(dut, DUT_MSG_ERROR, 8278 "Bridge must be configured. Run with -b <brname>."); 8279 fclose(f); 8280 return -2; 8281 } 8282 fprintf(f, "ap_isolate=1\n"); 8283 fprintf(f, "proxy_arp=1\n"); 8284 8285 if (set_ebtables_proxy_arp(dut, "FORWARD", ifname2) || 8286 set_ebtables_proxy_arp(dut, "OUTPUT", ifname2)) { 8287 fclose(f); 8288 return -2; 8289 } 8290 8291 } 8292 } 8293 8294 if (dut->program == PROGRAM_WPS) { 8295 /* 60G WPS tests requires wps_state of 2 (configured) */ 8296 int wps_state = is_60g_sigma_dut(dut) ? 2 : 1; 8297 8298 fprintf(f, "eap_server=1\n" 8299 "wps_state=%d\n" 8300 "device_name=QCA AP\n" 8301 "manufacturer=QCA\n" 8302 "device_type=6-0050F204-1\n" 8303 "config_methods=label virtual_display %s" 8304 "virtual_push_button keypad%s\n" 8305 "ap_pin=12345670\n" 8306 "friendly_name=QCA Access Point\n" 8307 "upnp_iface=%s\n", 8308 wps_state, 8309 is_60g_sigma_dut(dut) ? "physical_display " : "", 8310 dut->ap_wpsnfc ? " nfc_interface ext_nfc_token" : "", 8311 dut->bridge ? dut->bridge : ifname); 8312 if (dut->wsc_fragment) { 8313 fprintf(f, "device_name=%s\n" 8314 "manufacturer=%s\n" 8315 "model_name=%s\n" 8316 "model_number=%s\n" 8317 "serial_number=%s\n", 8318 WPS_LONG_DEVICE_NAME, 8319 WPS_LONG_MANUFACTURER, 8320 WPS_LONG_MODEL_NAME, 8321 WPS_LONG_MODEL_NUMBER, 8322 WPS_LONG_SERIAL_NUMBER); 8323 } else { 8324 fprintf(f, "device_name=QCA AP\n" 8325 "manufacturer=QCA\n"); 8326 } 8327 if (dut->eap_fragment) 8328 fprintf(f, "fragment_size=128\n"); 8329 } 8330 8331 if (dut->ap_dpp_conf_addr && dut->ap_dpp_conf_pkhash) 8332 fprintf(f, "dpp_controller=ipaddr=%s pkhash=%s\n", 8333 dut->ap_dpp_conf_addr, dut->ap_dpp_conf_pkhash); 8334 8335 if (dut->ap_he_rtsthrshld == VALUE_ENABLED) 8336 fprintf(f, "he_rts_threshold=512\n"); 8337 else if (dut->ap_he_rtsthrshld == VALUE_DISABLED) 8338 fprintf(f, "he_rts_threshold=1024\n"); 8339 8340 if ((dut->program == PROGRAM_VHT) || 8341 (dut->program == PROGRAM_HE && dut->use_5g)) { 8342 int vht_oper_centr_freq_idx; 8343 8344 if (check_channel(dut->ap_channel) < 0) { 8345 send_resp(dut, conn, SIGMA_INVALID, 8346 "errorCode,Invalid channel"); 8347 fclose(f); 8348 return 0; 8349 } 8350 8351 switch (dut->ap_chwidth) { 8352 case AP_20: 8353 dut->ap_vht_chwidth = AP_20_40_VHT_OPER_CHWIDTH; 8354 vht_oper_centr_freq_idx = 8355 get_oper_centr_freq_seq_idx(20, 8356 dut->ap_channel); 8357 break; 8358 case AP_40: 8359 dut->ap_vht_chwidth = AP_20_40_VHT_OPER_CHWIDTH; 8360 vht_oper_centr_freq_idx = 8361 get_oper_centr_freq_seq_idx(40, 8362 dut->ap_channel); 8363 break; 8364 case AP_80: 8365 dut->ap_vht_chwidth = AP_80_VHT_OPER_CHWIDTH; 8366 vht_oper_centr_freq_idx = 8367 get_oper_centr_freq_seq_idx(80, 8368 dut->ap_channel); 8369 break; 8370 case AP_160: 8371 dut->ap_vht_chwidth = AP_160_VHT_OPER_CHWIDTH; 8372 vht_oper_centr_freq_idx = 8373 get_oper_centr_freq_seq_idx(160, 8374 dut->ap_channel); 8375 break; 8376 default: 8377 dut->ap_vht_chwidth = VHT_DEFAULT_OPER_CHWIDTH; 8378 vht_oper_centr_freq_idx = 8379 get_oper_centr_freq_seq_idx(80, 8380 dut->ap_channel); 8381 break; 8382 } 8383 fprintf(f, "vht_oper_centr_freq_seg0_idx=%d\n", 8384 vht_oper_centr_freq_idx); 8385 fprintf(f, "vht_oper_chwidth=%d\n", dut->ap_vht_chwidth); 8386 if (dut->ap_mode == AP_11ax) { 8387 fprintf(f, "he_oper_chwidth=%d\n", dut->ap_vht_chwidth); 8388 fprintf(f, "he_oper_centr_freq_seg0_idx=%d\n", 8389 vht_oper_centr_freq_idx); 8390 } 8391 8392 if (dut->ap_sgi80 || dut->ap_txBF || 8393 dut->ap_ldpc != VALUE_NOT_SET || 8394 dut->ap_tx_stbc || dut->ap_mu_txBF) { 8395 fprintf(f, "vht_capab=%s%s%s%s%s\n", 8396 dut->ap_sgi80 ? "[SHORT-GI-80]" : "", 8397 dut->ap_txBF ? 8398 "[SU-BEAMFORMER][SU-BEAMFORMEE][BF-ANTENNA-2][SOUNDING-DIMENSION-2]" : "", 8399 (dut->ap_ldpc == VALUE_ENABLED) ? 8400 "[RXLDPC]" : "", 8401 dut->ap_tx_stbc ? "[TX-STBC-2BY1]" : "", 8402 dut->ap_mu_txBF ? "[MU-BEAMFORMER]" : ""); 8403 } 8404 } 8405 8406 if (dut->ap_key_mgmt == AP_WPA2_OWE && dut->ap_tag_ssid[0][0] && 8407 dut->ap_tag_key_mgmt[0] == AP2_OPEN) { 8408 /* OWE transition mode */ 8409 unsigned char bssid[6]; 8410 char ifname2[50]; 8411 unsigned long val; 8412 FILE *f2; 8413 8414 snprintf(ifname2, sizeof(ifname2), "%s_1", ifname); 8415 8416 fprintf(f, "owe_transition_ifname=%s\n", ifname2); 8417 val = 0x12345678; /* default to something */ 8418 f2 = fopen("/dev/urandom", "r"); 8419 if (f2) { 8420 if (fread(&val, 1, sizeof(val), f2) != sizeof(val)) { 8421 sigma_dut_print(dut, DUT_MSG_ERROR, 8422 "Could not read /dev/urandom"); 8423 } 8424 fclose(f2); 8425 } 8426 fprintf(f, "ssid=owe-%lx\n", val); 8427 fprintf(f, "ignore_broadcast_ssid=1\n"); 8428 8429 if (get_hwaddr(ifname, bssid)) { 8430 fclose(f); 8431 return -2; 8432 } 8433 if (bssid[0] & 0x02) 8434 bssid[5] ^= 0x01; 8435 else 8436 bssid[0] |= 0x02; 8437 8438 fprintf(f, "bss=%s\n", ifname2); 8439 fprintf(f, "ssid=%s\n", dut->ap_ssid); 8440 if (dut->bridge) 8441 fprintf(f, "bridge=%s\n", dut->bridge); 8442 if (drv == DRIVER_LINUX_WCN) 8443 fprintf(f, "use_driver_iface_addr=1\n"); 8444 else 8445 fprintf(f, "bssid=%02x:%02x:%02x:%02x:%02x:%02x\n", 8446 bssid[0], bssid[1], bssid[2], bssid[3], 8447 bssid[4], bssid[5]); 8448 fprintf(f, "owe_transition_ifname=%s\n", ifname); 8449 } 8450 8451 if (dut->ap_key_mgmt == AP_OPEN && 8452 dut->ap_tag_key_mgmt[0] == AP2_WPA2_OWE) { 8453 /* OWE transition mode */ 8454 unsigned char bssid[6]; 8455 char ifname2[50]; 8456 unsigned long val; 8457 FILE *f2; 8458 8459 snprintf(ifname2, sizeof(ifname2), "%s_1", ifname); 8460 8461 fprintf(f, "owe_transition_ifname=%s\n", ifname2); 8462 fprintf(f, "ssid=%s\n", dut->ap_ssid); 8463 8464 if (get_hwaddr(ifname, bssid)) { 8465 fclose(f); 8466 return -2; 8467 } 8468 if (bssid[0] & 0x02) 8469 bssid[5] ^= 0x01; 8470 else 8471 bssid[0] |= 0x02; 8472 8473 fprintf(f, "bss=%s\n", ifname2); 8474 val = 0x12345678; /* default to something */ 8475 f2 = fopen("/dev/urandom", "r"); 8476 if (f2) { 8477 if (fread(&val, 1, sizeof(val), f2) != sizeof(val)) { 8478 sigma_dut_print(dut, DUT_MSG_ERROR, 8479 "Could not read /dev/urandom"); 8480 } 8481 fclose(f2); 8482 } 8483 fprintf(f, "ssid=owe-%lx\n", val); 8484 if (dut->bridge) 8485 fprintf(f, "bridge=%s\n", dut->bridge); 8486 if (drv == DRIVER_LINUX_WCN) 8487 fprintf(f, "use_driver_iface_addr=1\n"); 8488 else 8489 fprintf(f, "bssid=%02x:%02x:%02x:%02x:%02x:%02x\n", 8490 bssid[0], bssid[1], bssid[2], bssid[3], 8491 bssid[4], bssid[5]); 8492 fprintf(f, "owe_transition_ifname=%s\n", ifname); 8493 fprintf(f, "wpa=2\n"); 8494 fprintf(f, "wpa_key_mgmt=OWE\n"); 8495 fprintf(f, "rsn_pairwise=CCMP\n"); 8496 fprintf(f, "ieee80211w=2\n"); 8497 fprintf(f, "ignore_broadcast_ssid=1\n"); 8498 if (dut->ap_sae_groups) { 8499 fprintf(f, "owe_groups=%s\n", dut->ap_sae_groups); 8500 if (dut->owe_ptk_workaround) 8501 fprintf(f, "owe_ptk_workaround=1\n"); 8502 } 8503 } 8504 8505 if (dut->program == PROGRAM_OCE) { 8506 fprintf(f, "oce=%d\n", 8507 dut->dev_role == DEVROLE_STA_CFON ? 2 : 1); 8508 } 8509 fclose(f); 8510 if (dut->use_hostapd_pid_file) 8511 kill_hostapd_process_pid(dut); 8512 #ifdef __QNXNTO__ 8513 if (system("slay hostapd") == 0) 8514 #else /* __QNXNTO__ */ 8515 if (!dut->use_hostapd_pid_file && 8516 (kill_process(dut, "(hostapd)", 1, SIGTERM) == 0 || 8517 system("killall hostapd") == 0)) 8518 #endif /* __QNXNTO__ */ 8519 { 8520 int i; 8521 /* Wait some time to allow hostapd to complete cleanup before 8522 * starting a new process */ 8523 for (i = 0; i < 10; i++) { 8524 usleep(500000); 8525 #ifdef __QNXNTO__ 8526 if (system("pidin | grep hostapd") != 0) 8527 break; 8528 #else /* __QNXNTO__ */ 8529 if (system("pidof hostapd") != 0) 8530 break; 8531 #endif /* __QNXNTO__ */ 8532 } 8533 } 8534 dut->hostapd_running = 0; 8535 8536 #ifdef ANDROID 8537 /* Set proper conf file permissions so that hostapd process 8538 * can access it. 8539 */ 8540 if (chmod(ap_conf_path, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP) < 0) 8541 sigma_dut_print(dut, DUT_MSG_ERROR, 8542 "Error changing permissions"); 8543 8544 gr = getgrnam("wifi"); 8545 if (!gr || chown(ap_conf_path, -1, gr->gr_gid) < 0) 8546 sigma_dut_print(dut, DUT_MSG_ERROR, "Error changing groupid"); 8547 #endif /* ANDROID */ 8548 8549 f = fopen(ap_conf_path, "r"); 8550 if (f) { 8551 size_t len; 8552 8553 len = fread(buf, 1, sizeof(buf), f); 8554 fclose(f); 8555 if (len >= sizeof(buf)) 8556 len = sizeof(buf) - 1; 8557 buf[len] = '\0'; 8558 sigma_dut_print(dut, DUT_MSG_DEBUG, "hostapd debug log:\n%s", 8559 buf); 8560 } 8561 8562 if (drv == DRIVER_QNXNTO) { 8563 snprintf(buf, sizeof(buf), 8564 "hostapd -B %s%s%s %s%s %s/sigma_dut-ap.conf", 8565 dut->hostapd_debug_log ? "-dddKt " : "", 8566 (dut->hostapd_debug_log && dut->hostapd_debug_log[0]) ? 8567 "-f " : "", 8568 dut->hostapd_debug_log ? dut->hostapd_debug_log : "", 8569 dut->hostapd_entropy_log ? " -e" : "", 8570 dut->hostapd_entropy_log ? dut->hostapd_entropy_log : 8571 "", 8572 dut->sigma_tmpdir); 8573 } else { 8574 /* 8575 * It looks like a monitor interface can cause some issues for 8576 * beaconing, so remove it (if injection was used) before 8577 * starting hostapd. 8578 */ 8579 if (if_nametoindex("sigmadut") > 0 && 8580 system("iw dev sigmadut del") != 0) 8581 sigma_dut_print(dut, DUT_MSG_ERROR, "Failed to remove " 8582 "monitor interface"); 8583 8584 snprintf(path, sizeof(path), "%shostapd", 8585 file_exists("hostapd") ? "./" : ""); 8586 snprintf(buf, sizeof(buf), 8587 "%s -B%s%s%s%s%s%s %s/sigma_dut-ap.conf", 8588 dut->hostapd_bin ? dut->hostapd_bin : path, 8589 dut->hostapd_debug_log ? " -dddKt" : "", 8590 (dut->hostapd_debug_log && dut->hostapd_debug_log[0]) ? 8591 " -f " : "", 8592 dut->hostapd_debug_log ? dut->hostapd_debug_log : "", 8593 dut->hostapd_entropy_log ? " -e" : "", 8594 dut->hostapd_entropy_log ? dut->hostapd_entropy_log : 8595 "", 8596 dut->use_hostapd_pid_file ? 8597 " -P " SIGMA_DUT_HOSTAPD_PID_FILE : "", 8598 dut->sigma_tmpdir); 8599 } 8600 8601 sigma_dut_print(dut, DUT_MSG_DEBUG, "hostapd command: %s", buf); 8602 if (system(buf) != 0) { 8603 send_resp(dut, conn, SIGMA_ERROR, 8604 "errorCode,Failed to start hostapd"); 8605 return 0; 8606 } 8607 8608 /* allow some time for hostapd to start before returning success */ 8609 usleep(500000); 8610 if (run_hostapd_cli(dut, "ping") != 0) { 8611 send_resp(dut, conn, SIGMA_ERROR, 8612 "errorCode,Failed to talk to hostapd"); 8613 return 0; 8614 } 8615 8616 if (dut->ap_ba_bufsize != BA_BUFSIZE_NOT_SET) { 8617 int buf_size; 8618 8619 if (dut->ap_ba_bufsize == BA_BUFSIZE_256) 8620 buf_size = 256; 8621 else 8622 buf_size = 64; 8623 8624 if ((drv == DRIVER_WCN || drv == DRIVER_LINUX_WCN) && 8625 sta_set_addba_buf_size(dut, ifname, buf_size)) { 8626 send_resp(dut, conn, SIGMA_ERROR, 8627 "ErrorCode,set_addba_buf_size failed"); 8628 return STATUS_SENT_ERROR; 8629 } 8630 8631 sigma_dut_print(dut, DUT_MSG_INFO, 8632 "setting addba buf_size=%d", buf_size); 8633 } 8634 8635 if (drv == DRIVER_LINUX_WCN) { 8636 const char *ifname_ptr = ifname; 8637 8638 if ((dut->ap_key_mgmt == AP_OPEN && 8639 dut->ap_tag_key_mgmt[0] == AP2_WPA2_OWE) || 8640 (dut->ap_key_mgmt == AP_WPA2_OWE && 8641 dut->ap_tag_ssid[0][0] && 8642 dut->ap_tag_key_mgmt[0] == AP2_OPEN)) { 8643 /* OWE transition mode */ 8644 if (dut->bridge) 8645 ifname_ptr = dut->bridge; 8646 } 8647 8648 sigma_dut_print(dut, DUT_MSG_INFO, 8649 "setting ip addr %s mask %s ifname %s", 8650 ap_inet_addr, ap_inet_mask, ifname_ptr); 8651 snprintf(buf, sizeof(buf), "ifconfig %s %s netmask %s up", 8652 ifname_ptr, ap_inet_addr, ap_inet_mask); 8653 if (system(buf) != 0) { 8654 sigma_dut_print(dut, DUT_MSG_ERROR, 8655 "Failed to initialize the interface"); 8656 return -1; 8657 } 8658 } 8659 8660 /* Configure the driver with LDPC setting for AP mode as a new vdev is 8661 * created when hostapd is started. 8662 */ 8663 if (drv == DRIVER_WCN || drv == DRIVER_LINUX_WCN) 8664 wcn_config_ap_ldpc(dut, ifname); 8665 8666 if (dut->ap_l2tif) { 8667 snprintf(path, sizeof(path), 8668 "/sys/class/net/%s/brport/hairpin_mode", 8669 ifname); 8670 if (!file_exists(path)) { 8671 sigma_dut_print(dut, DUT_MSG_ERROR, 8672 "%s must be binded to the bridge for L2TIF", 8673 ifname); 8674 return -2; 8675 } 8676 8677 snprintf(buf, sizeof(buf), "echo 1 > %s", path); 8678 if (system(buf) != 0) { 8679 sigma_dut_print(dut, DUT_MSG_ERROR, 8680 "Failed to enable hairpin_mode for L2TIF"); 8681 return -2; 8682 } 8683 8684 snprintf(buf, sizeof(buf), "ebtables -P FORWARD ACCEPT"); 8685 if (system(buf) != 0) { 8686 sigma_dut_print(dut, DUT_MSG_ERROR, 8687 "Failed to set ebtables rules, RULE-9"); 8688 return -2; 8689 } 8690 8691 snprintf(buf, sizeof(buf), 8692 "ebtables -A FORWARD -p IPv4 --ip-proto icmp -i %s -j DROP", 8693 ifname); 8694 if (system(buf) != 0) { 8695 sigma_dut_print(dut, DUT_MSG_ERROR, 8696 "Failed to set ebtables rules, RULE-11"); 8697 return -2; 8698 } 8699 } 8700 8701 if (dut->ap_proxy_arp) { 8702 if (dut->ap_dgaf_disable) { 8703 if (set_ebtables_disable_dgaf(dut, "FORWARD", ifname) || 8704 set_ebtables_disable_dgaf(dut, "OUTPUT", ifname)) 8705 return -2; 8706 } else { 8707 if (set_ebtables_proxy_arp(dut, "FORWARD", ifname) || 8708 set_ebtables_proxy_arp(dut, "OUTPUT", ifname)) 8709 return -2; 8710 } 8711 8712 /* For 4.5-(c) */ 8713 snprintf(buf, sizeof(buf), 8714 "ebtables -A FORWARD -p ARP --arp-opcode 2 -i %s -j DROP", 8715 ifname); 8716 if (system(buf) != 0) { 8717 sigma_dut_print(dut, DUT_MSG_ERROR, 8718 "Failed to set ebtables rules, RULE-10"); 8719 return -2; 8720 } 8721 } 8722 8723 if (dut->ap_tdls_prohibit || dut->ap_l2tif) { 8724 /* Drop TDLS frames */ 8725 snprintf(buf, sizeof(buf), 8726 "ebtables -A FORWARD -p 0x890d -i %s -j DROP", ifname); 8727 if (system(buf) != 0) { 8728 sigma_dut_print(dut, DUT_MSG_ERROR, 8729 "Failed to set ebtables rules, RULE-13"); 8730 return -2; 8731 } 8732 } 8733 8734 if (dut->ap_fake_pkhash && 8735 run_hostapd_cli(dut, "set wps_corrupt_pkhash 1") != 0) { 8736 send_resp(dut, conn, SIGMA_ERROR, 8737 "errorCode,Could not enable FakePubKey"); 8738 return 0; 8739 } 8740 8741 if (dut->program == PROGRAM_60GHZ) { 8742 if (dut->ap_num_ese_allocs > 0) { 8743 /* wait extra time for AP to start */ 8744 sleep(2); 8745 if (ap_set_60g_ese(dut, dut->ap_num_ese_allocs, 8746 dut->ap_ese_allocs)) { 8747 send_resp(dut, conn, SIGMA_ERROR, 8748 "errorCode,Could not set ExtSch"); 8749 return 0; 8750 } 8751 } 8752 if (dut->ap_fixed_rate) { 8753 sigma_dut_print(dut, DUT_MSG_DEBUG, 8754 "forcing TX MCS index %d", 8755 dut->ap_mcs); 8756 if (ap_set_force_mcs(dut, 1, dut->ap_mcs)) { 8757 send_resp(dut, conn, SIGMA_ERROR, 8758 "errorCode,Could not force MCS"); 8759 return -2; 8760 } 8761 } 8762 } 8763 8764 if (dut->wps_forced_version) { 8765 snprintf(buf, sizeof(buf), "SET wps_version_number %d", 8766 dut->wps_forced_version); 8767 if (hapd_command(ifname, buf) < 0) { 8768 send_resp(dut, conn, SIGMA_ERROR, 8769 "errorCode,Fail to set wps_version_number"); 8770 return STATUS_SENT; 8771 } 8772 } 8773 8774 dut->hostapd_running = 1; 8775 return 1; 8776 } 8777 8778 8779 static int parse_qos_params(struct sigma_dut *dut, struct sigma_conn *conn, 8780 struct qos_params *qos, const char *cwmin, 8781 const char *cwmax, const char *aifs, 8782 const char *txop, const char *acm) 8783 { 8784 int val; 8785 8786 if (cwmin) { 8787 qos->ac = 1; 8788 val = atoi(cwmin); 8789 if (val < 0 || val > 15) { 8790 send_resp(dut, conn, SIGMA_INVALID, 8791 "errorCode,Invalid cwMin"); 8792 return 0; 8793 } 8794 qos->cwmin = val; 8795 } 8796 8797 if (cwmax) { 8798 qos->ac = 1; 8799 val = atoi(cwmax); 8800 if (val < 0 || val > 15) { 8801 send_resp(dut, conn, SIGMA_INVALID, 8802 "errorCode,Invalid cwMax"); 8803 return 0; 8804 } 8805 qos->cwmax = val; 8806 } 8807 8808 if (aifs) { 8809 qos->ac = 1; 8810 val = atoi(aifs); 8811 if (val < 1 || val > 255) { 8812 send_resp(dut, conn, SIGMA_INVALID, 8813 "errorCode,Invalid AIFS"); 8814 return 0; 8815 } 8816 qos->aifs = val; 8817 } 8818 8819 if (txop) { 8820 qos->ac = 1; 8821 val = atoi(txop); 8822 if (val < 0 || val > 0xffff) { 8823 send_resp(dut, conn, SIGMA_INVALID, 8824 "errorCode,Invalid txop"); 8825 return 0; 8826 } 8827 qos->txop = val * 32; 8828 } 8829 8830 if (acm) { 8831 qos->ac = 1; 8832 qos->acm = strcasecmp(acm, "on") == 0; 8833 } 8834 8835 return 1; 8836 } 8837 8838 8839 static enum sigma_cmd_result cmd_ap_set_apqos(struct sigma_dut *dut, 8840 struct sigma_conn *conn, 8841 struct sigma_cmd *cmd) 8842 { 8843 /* TXOP: The values provided here for VHT5G only */ 8844 if (!parse_qos_params(dut, conn, &dut->ap_qos[AP_AC_VO], 8845 get_param(cmd, "cwmin_VO"), 8846 get_param(cmd, "cwmax_VO"), 8847 get_param(cmd, "AIFS_VO"), 8848 get_param(cmd, "TXOP_VO"), 8849 get_param(cmd, "ACM_VO")) || 8850 !parse_qos_params(dut, conn, &dut->ap_qos[AP_AC_VI], 8851 get_param(cmd, "cwmin_VI"), 8852 get_param(cmd, "cwmax_VI"), 8853 get_param(cmd, "AIFS_VI"), 8854 get_param(cmd, "TXOP_VI"), 8855 get_param(cmd, "ACM_VI")) || 8856 !parse_qos_params(dut, conn, &dut->ap_qos[AP_AC_BE], 8857 get_param(cmd, "cwmin_BE"), 8858 get_param(cmd, "cwmax_BE"), 8859 get_param(cmd, "AIFS_BE"), 8860 get_param(cmd, "TXOP_BE"), 8861 get_param(cmd, "ACM_BE")) || 8862 !parse_qos_params(dut, conn, &dut->ap_qos[AP_AC_BK], 8863 get_param(cmd, "cwmin_BK"), 8864 get_param(cmd, "cwmax_BK"), 8865 get_param(cmd, "AIFS_BK"), 8866 get_param(cmd, "TXOP_BK"), 8867 get_param(cmd, "ACM_BK"))) 8868 return 0; 8869 8870 return 1; 8871 } 8872 8873 8874 static enum sigma_cmd_result cmd_ap_set_staqos(struct sigma_dut *dut, 8875 struct sigma_conn *conn, 8876 struct sigma_cmd *cmd) 8877 { 8878 if (!parse_qos_params(dut, conn, &dut->ap_sta_qos[AP_AC_VO], 8879 get_param(cmd, "cwmin_VO"), 8880 get_param(cmd, "cwmax_VO"), 8881 get_param(cmd, "AIFS_VO"), 8882 get_param(cmd, "TXOP_VO"), 8883 get_param(cmd, "ACM_VO")) || 8884 !parse_qos_params(dut, conn, &dut->ap_sta_qos[AP_AC_VI], 8885 get_param(cmd, "cwmin_VI"), 8886 get_param(cmd, "cwmax_VI"), 8887 get_param(cmd, "AIFS_VI"), 8888 get_param(cmd, "TXOP_VI"), 8889 get_param(cmd, "ACM_VI")) || 8890 !parse_qos_params(dut, conn, &dut->ap_sta_qos[AP_AC_BE], 8891 get_param(cmd, "cwmin_BE"), 8892 get_param(cmd, "cwmax_BE"), 8893 get_param(cmd, "AIFS_BE"), 8894 get_param(cmd, "TXOP_BE"), 8895 get_param(cmd, "ACM_BE")) || 8896 !parse_qos_params(dut, conn, &dut->ap_sta_qos[AP_AC_BK], 8897 get_param(cmd, "cwmin_BK"), 8898 get_param(cmd, "cwmax_BK"), 8899 get_param(cmd, "AIFS_BK"), 8900 get_param(cmd, "TXOP_BK"), 8901 get_param(cmd, "ACM_BK"))) 8902 return 0; 8903 8904 return 1; 8905 } 8906 8907 8908 static void cmd_ath_ap_hs2_reset(struct sigma_dut *dut) 8909 { 8910 unsigned char bssid[6]; 8911 char buf[100]; 8912 run_system(dut, "cfg -a AP_SSID=\"Hotspot 2.0\""); 8913 run_system(dut, "cfg -a AP_PRIMARY_CH=1"); 8914 run_system(dut, "cfg -a AP_SECMODE=WPA"); 8915 run_system(dut, "cfg -a AP_SECFILE=EAP"); 8916 run_system(dut, "cfg -a AP_WPA=2"); 8917 run_system(dut, "cfg -a AP_CYPHER=CCMP"); 8918 run_system(dut, "cfg -a AP_HOTSPOT=1"); 8919 run_system(dut, "cfg -a AP_HOTSPOT_ANT=2"); 8920 run_system(dut, "cfg -a AP_HOTSPOT_INTERNET=0"); 8921 run_system(dut, "cfg -a AP_HOTSPOT_VENUEGROUP=2"); 8922 run_system(dut, "cfg -a AP_HOTSPOT_VENUETYPE=8"); 8923 run_system(dut, "cfg -a AP_HOTSPOT_ROAMINGCONSORTIUM=506f9a"); 8924 run_system(dut, "cfg -a AP_HOTSPOT_ROAMINGCONSORTIUM2=001bc504bd"); 8925 if (!get_hwaddr("ath0", bssid)) { 8926 snprintf(buf, sizeof(buf), "cfg -a AP_HOTSPOT_HESSID=" 8927 "%02x:%02x:%02x:%02x:%02x:%02x", 8928 bssid[0], bssid[1], bssid[2], bssid[3], 8929 bssid[4], bssid[5]); 8930 run_system(dut, buf); 8931 snprintf(dut->ap_hessid, sizeof(dut->ap_hessid), 8932 "%02x:%02x:%02x:%02x:%02x:%02x", 8933 bssid[0], bssid[1], bssid[2], bssid[3], 8934 bssid[4], bssid[5]); 8935 } else { 8936 if (!get_hwaddr("wifi0", bssid)) { 8937 snprintf(buf, sizeof(buf), "cfg -a AP_HOTSPOT_HESSID=" 8938 "%02x:%02x:%02x:%02x:%02x:%02x", 8939 bssid[0], bssid[1], bssid[2], bssid[3], 8940 bssid[4], bssid[5]); 8941 run_system(dut, buf); 8942 snprintf(dut->ap_hessid, sizeof(dut->ap_hessid), 8943 "%02x:%02x:%02x:%02x:%02x:%02x", 8944 bssid[0], bssid[1], bssid[2], bssid[3], 8945 bssid[4], bssid[5]); 8946 } else { 8947 /* load the driver and try again */ 8948 run_system(dut, "/etc/rc.d/rc.wlan up"); 8949 8950 if (!get_hwaddr("wifi0", bssid)) { 8951 snprintf(buf, sizeof(buf), 8952 "cfg -a AP_HOTSPOT_HESSID=" 8953 "%02x:%02x:%02x:%02x:%02x:%02x", 8954 bssid[0], bssid[1], bssid[2], 8955 bssid[3], bssid[4], bssid[5]); 8956 run_system(dut, buf); 8957 snprintf(dut->ap_hessid, 8958 sizeof(dut->ap_hessid), 8959 "%02x:%02x:%02x:%02x:%02x:%02x", 8960 bssid[0], bssid[1], bssid[2], 8961 bssid[3], bssid[4], bssid[5]); 8962 } 8963 } 8964 } 8965 8966 run_system(dut, "cfg -r AP_SSID_2"); 8967 run_system(dut, "cfg -c"); 8968 /* run_system(dut, "cfg -s"); */ 8969 } 8970 8971 8972 static void ath_reset_vht_defaults(struct sigma_dut *dut) 8973 { 8974 run_system(dut, "cfg -x"); 8975 run_system(dut, "cfg -a AP_RADIO_ID=1"); 8976 run_system(dut, "cfg -a AP_PRIMARY_CH_2=36"); 8977 run_system(dut, "cfg -a AP_STARTMODE=standard"); 8978 run_system(dut, "cfg -a AP_CHMODE_2=11ACVHT80"); 8979 run_system(dut, "cfg -a TX_CHAINMASK_2=7"); 8980 run_system(dut, "cfg -a RX_CHAINMASK_2=7"); 8981 run_system(dut, "cfg -a ATH_countrycode=0x348"); 8982 /* NOTE: For Beeliner we have to turn off MU-MIMO */ 8983 if (system("rm /tmp/secath*") != 0) { 8984 sigma_dut_print(dut, DUT_MSG_ERROR, 8985 "Failed to remove secath file"); 8986 } 8987 } 8988 8989 8990 static enum sigma_cmd_result cmd_ap_reset_default(struct sigma_dut *dut, 8991 struct sigma_conn *conn, 8992 struct sigma_cmd *cmd) 8993 { 8994 const char *type, *program; 8995 enum driver_type drv; 8996 char buf[128]; 8997 int i; 8998 8999 for (i = 0; i < MAX_WLAN_TAGS - 1; i++) { 9000 /* 9001 * Reset all tagged SSIDs to NULL-string and all key management 9002 * to open. 9003 */ 9004 dut->ap_tag_ssid[i][0] = '\0'; 9005 dut->ap_tag_key_mgmt[i] = AP2_OPEN; 9006 } 9007 9008 drv = get_driver_type(dut); 9009 9010 program = get_param(cmd, "program"); 9011 if (!program) 9012 program = get_param(cmd, "prog"); 9013 dut->program = sigma_program_to_enum(program); 9014 dut->device_type = AP_unknown; 9015 type = get_param(cmd, "type"); 9016 if (type && strcasecmp(type, "Testbed") == 0) 9017 dut->device_type = AP_testbed; 9018 if (type && strcasecmp(type, "DUT") == 0) 9019 dut->device_type = AP_dut; 9020 9021 dut->ap_rts = 0; 9022 dut->ap_frgmnt = 0; 9023 dut->ap_bcnint = 0; 9024 dut->ap_key_mgmt = AP_OPEN; 9025 dut->ap_ssid[0] = '\0'; 9026 dut->ap_fake_pkhash = 0; 9027 memset(dut->ap_qos, 0, sizeof(dut->ap_qos)); 9028 memset(dut->ap_sta_qos, 0, sizeof(dut->ap_sta_qos)); 9029 dut->ap_addba_reject = VALUE_NOT_SET; 9030 dut->ap_noack = VALUE_NOT_SET; 9031 dut->ap_is_dual = 0; 9032 dut->ap_mode = AP_inval; 9033 dut->ap_mode_1 = AP_inval; 9034 9035 dut->ap_allow_vht_wep = 0; 9036 dut->ap_allow_vht_tkip = 0; 9037 dut->ap_disable_protection = 0; 9038 memset(dut->ap_countrycode, 0, sizeof(dut->ap_countrycode)); 9039 dut->ap_dyn_bw_sig = VALUE_NOT_SET; 9040 dut->ap_ldpc = VALUE_NOT_SET; 9041 dut->ap_sig_rts = VALUE_NOT_SET; 9042 dut->ap_rx_amsdu = VALUE_NOT_SET; 9043 dut->ap_txBF = 0; 9044 dut->ap_mu_txBF = 0; 9045 dut->ap_chwidth = AP_AUTO; 9046 9047 dut->ap_rsn_preauth = 0; 9048 dut->ap_wpsnfc = 0; 9049 dut->ap_bss_load = -1; 9050 dut->ap_p2p_cross_connect = -1; 9051 9052 dut->ap_regulatory_mode = AP_80211D_MODE_DISABLED; 9053 dut->ap_dfs_mode = AP_DFS_MODE_DISABLED; 9054 dut->ap_chwidth_offset = SEC_CH_NO; 9055 9056 dut->mbo_pref_ap_cnt = 0; 9057 dut->ft_bss_mac_cnt = 0; 9058 dut->ap_interface_5g = 0; 9059 dut->ap_interface_2g = 0; 9060 dut->ap_pmf = AP_PMF_DISABLED; 9061 9062 dut->wsc_fragment = 0; 9063 dut->eap_fragment = 0; 9064 dut->wps_forced_version = 0; 9065 9066 if (dut->program == PROGRAM_HT || dut->program == PROGRAM_VHT) { 9067 dut->ap_wme = AP_WME_ON; 9068 dut->ap_wmmps = AP_WMMPS_ON; 9069 } else { 9070 dut->ap_wme = AP_WME_OFF; 9071 dut->ap_wmmps = AP_WMMPS_OFF; 9072 } 9073 9074 dut->ap_venue_url = 0; 9075 dut->ap_advice_of_charge = 0; 9076 dut->ap_oper_icon_metadata = 0; 9077 dut->ap_tnc_file_name = 0; 9078 dut->ap_tnc_time_stamp = 0; 9079 9080 dut->ap_akm_values = 0; 9081 free(dut->ap_sae_passwords); 9082 dut->ap_sae_passwords = NULL; 9083 dut->ap_sae_pk = 0; 9084 free(dut->ap_sae_pk_modifier); 9085 dut->ap_sae_pk_modifier = NULL; 9086 free(dut->ap_sae_pk_keypair); 9087 dut->ap_sae_pk_keypair = NULL; 9088 free(dut->ap_sae_pk_keypair_sig); 9089 dut->ap_sae_pk_keypair_sig = NULL; 9090 9091 dut->ap_ocvc = -1; 9092 9093 if (dut->program == PROGRAM_HS2 || dut->program == PROGRAM_HS2_R2 || 9094 dut->program == PROGRAM_HS2_R3 || 9095 dut->program == PROGRAM_IOTLP) { 9096 int i; 9097 9098 if (drv == DRIVER_ATHEROS) 9099 cmd_ath_ap_hs2_reset(dut); 9100 else if (drv == DRIVER_OPENWRT) 9101 cmd_owrt_ap_hs2_reset(dut); 9102 9103 dut->ap_interworking = 1; 9104 dut->ap_access_net_type = 2; 9105 dut->ap_internet = 0; 9106 dut->ap_venue_group = 2; 9107 dut->ap_venue_type = 8; 9108 dut->ap_domain_name_list[0] = '\0'; 9109 dut->ap_hs2 = 1; 9110 snprintf(dut->ap_roaming_cons, sizeof(dut->ap_roaming_cons), 9111 "506f9a;001bc504bd"); 9112 dut->ap_l2tif = 0; 9113 dut->ap_proxy_arp = 0; 9114 if (dut->bridge) { 9115 char buf[50]; 9116 9117 snprintf(buf, sizeof(buf), "ip neigh flush dev %s", 9118 dut->bridge); 9119 if (system(buf) != 0) { 9120 sigma_dut_print(dut, DUT_MSG_DEBUG, 9121 "%s ip neigh table flushing failed", 9122 dut->bridge); 9123 } 9124 9125 snprintf(buf, sizeof(buf), "ebtables -F"); 9126 if (system(buf) != 0) { 9127 sigma_dut_print(dut, DUT_MSG_DEBUG, 9128 "%s ebtables flushing failed", 9129 dut->bridge); 9130 } 9131 } 9132 dut->ap_dgaf_disable = 0; 9133 dut->ap_p2p_cross_connect = 0; 9134 dut->ap_gas_cb_delay = 0; 9135 dut->ap_nai_realm_list = 0; 9136 dut->ap_oper_name = 0; 9137 dut->ap_venue_name = 0; 9138 for (i = 0; i < 10; i++) { 9139 dut->ap_plmn_mcc[i][0] = '\0'; 9140 dut->ap_plmn_mnc[i][0] = '\0'; 9141 } 9142 dut->ap_wan_metrics = 0; 9143 dut->ap_conn_capab = 0; 9144 dut->ap_ip_addr_type_avail = 0; 9145 dut->ap_net_auth_type = 0; 9146 dut->ap_oper_class = 0; 9147 dut->ap_pmf = 0; 9148 dut->ap_add_sha256 = 0; 9149 } 9150 9151 if (dut->program == PROGRAM_HS2_R2 || dut->program == PROGRAM_HS2_R3 || 9152 dut->program == PROGRAM_IOTLP) { 9153 int i; 9154 const char hessid[] = "50:6f:9a:00:11:22"; 9155 9156 memcpy(dut->ap_hessid, hessid, strlen(hessid) + 1); 9157 dut->ap_osu_ssid[0] = '\0'; 9158 dut->ap_pmf = 1; 9159 dut->ap_osu_provider_list = 0; 9160 dut->ap_osu_provider_nai_list = 0; 9161 for (i = 0; i < 10; i++) { 9162 dut->ap_osu_server_uri[i][0] = '\0'; 9163 dut->ap_osu_method[i] = 0xFF; 9164 } 9165 dut->ap_qos_map_set = 0; 9166 dut->ap_tag_key_mgmt[0] = AP2_OPEN; 9167 dut->ap2_proxy_arp = 0; 9168 dut->ap2_osu = 0; 9169 dut->ap_osu_icon_tag = 0; 9170 } 9171 9172 if (dut->program == PROGRAM_VHT) { 9173 /* Set up the defaults */ 9174 dut->use_5g = 1; 9175 dut->ap_mode = AP_11ac; 9176 dut->ap_channel = 36; 9177 dut->ap_ampdu = VALUE_NOT_SET; 9178 dut->ap_ndpa_frame = 1; 9179 if (dut->device_type == AP_testbed) { 9180 dut->ap_amsdu = VALUE_DISABLED; 9181 dut->ap_ldpc = VALUE_DISABLED; 9182 dut->ap_rx_amsdu = VALUE_DISABLED; 9183 dut->ap_sgi80 = 0; 9184 } else { 9185 dut->ap_amsdu = VALUE_ENABLED; 9186 /* 9187 * As LDPC is optional, don't enable this by default 9188 * for LINUX-WCN driver. The ap_set_wireless command 9189 * can be used to enable LDPC, when needed. 9190 */ 9191 if (drv != DRIVER_LINUX_WCN) 9192 dut->ap_ldpc = VALUE_ENABLED; 9193 dut->ap_rx_amsdu = VALUE_ENABLED; 9194 dut->ap_sgi80 = 1; 9195 } 9196 dut->ap_fixed_rate = 0; 9197 dut->ap_rx_streams = 3; 9198 dut->ap_tx_streams = 3; 9199 dut->ap_vhtmcs_map = 0; 9200 dut->ap_chwidth = AP_80; 9201 dut->ap_tx_stbc = 1; 9202 dut->ap_dyn_bw_sig = VALUE_ENABLED; 9203 if (get_openwrt_driver_type() == OPENWRT_DRIVER_ATHEROS) 9204 dut->ap_dfs_mode = AP_DFS_MODE_ENABLED; 9205 if (get_driver_type(dut) == DRIVER_ATHEROS) 9206 ath_reset_vht_defaults(dut); 9207 } 9208 9209 if (dut->program == PROGRAM_IOTLP) { 9210 dut->wnm_bss_max_feature = VALUE_DISABLED; 9211 dut->wnm_bss_max_idle_time = 0; 9212 dut->wnm_bss_max_protection = VALUE_NOT_SET; 9213 dut->ap_proxy_arp = 1; 9214 } else { 9215 /* 9216 * Do not touch the BSS-MAX Idle time feature 9217 * if the program is not IOTLP. 9218 */ 9219 dut->wnm_bss_max_feature = VALUE_NOT_SET; 9220 dut->wnm_bss_max_idle_time = 0; 9221 dut->wnm_bss_max_protection = VALUE_NOT_SET; 9222 } 9223 9224 if (dut->program == PROGRAM_LOC) { 9225 dut->ap_rrm = 1; 9226 dut->ap_rtt = 1; 9227 dut->ap_lci = 0; 9228 dut->ap_val_lci[0] = '\0'; 9229 dut->ap_infoz[0] = '\0'; 9230 dut->ap_lcr = 0; 9231 dut->ap_val_lcr[0] = '\0'; 9232 dut->ap_neighap = 0; 9233 dut->ap_opchannel = 0; 9234 dut->ap_scan = 0; 9235 dut->ap_fqdn_held = 0; 9236 dut->ap_fqdn_supl = 0; 9237 dut->ap_interworking = 0; 9238 dut->ap_gas_cb_delay = 0; 9239 dut->ap_msnt_type = 0; 9240 } 9241 dut->ap_ft_oa = 0; 9242 dut->ap_ft_ds = VALUE_NOT_SET; 9243 dut->ap_reg_domain = REG_DOMAIN_NOT_SET; 9244 dut->ap_mobility_domain[0] = '\0'; 9245 9246 if (dut->program == PROGRAM_MBO) { 9247 dut->ap_mbo = 1; 9248 dut->ap_interworking = 1; 9249 dut->ap_ne_class = 0; 9250 dut->ap_ne_op_ch = 0; 9251 dut->ap_set_bssidpref = 1; 9252 dut->ap_btmreq_disassoc_imnt = 0; 9253 dut->ap_btmreq_term_bit = 0; 9254 dut->ap_disassoc_timer = 0; 9255 dut->ap_btmreq_bss_term_dur = 0; 9256 dut->ap_channel = 36; 9257 dut->ap_chwidth = AP_20; 9258 dut->ap_cell_cap_pref = 0; 9259 dut->ap_gas_cb_delay = 0; 9260 dut->mbo_self_ap_tuple.ap_ne_class = -1; 9261 dut->mbo_self_ap_tuple.ap_ne_pref = -1; /* Not set */ 9262 dut->mbo_self_ap_tuple.ap_ne_op_ch = -1; 9263 dut->ap_btmreq_bss_term_tsf = 0; 9264 dut->ap_assoc_delay = 0; 9265 } 9266 9267 if (dut->program == PROGRAM_OCE) { 9268 if (dut->ap_dhcp_stop) 9269 run_system(dut, "/etc/init.d/dnsmasq start"); 9270 9271 dut->ap_dhcp_stop = 0; 9272 dut->ap_oce = VALUE_ENABLED; 9273 dut->ap_broadcast_ssid = VALUE_ENABLED; 9274 dut->ap_fils_dscv_int = 20; 9275 dut->ap_filsdscv = VALUE_ENABLED; 9276 dut->ap_filshlp = VALUE_DISABLED; 9277 dut->ap_rnr = VALUE_DISABLED; 9278 dut->ap_nairealm[0] = '\0'; 9279 dut->ap_nairealm_int = 0; 9280 dut->ap_blechanutil = 0; 9281 dut->ap_ble_admit_cap = 0; 9282 dut->ap_esp = VALUE_ENABLED; 9283 dut->ap_datappdudura = 0; 9284 dut->ap_airtimefract = 0; 9285 dut->ap_blestacnt = 0; 9286 dut->ap_ul_availcap = 0; 9287 dut->ap_dl_availcap = 0; 9288 dut->ap_akm = 0; 9289 dut->ap_add_sha256 = 0; 9290 dut->ap_add_sha384 = 0; 9291 dut->ap_80plus80 = 0; 9292 } 9293 9294 dut->ap_he_ppdu = PPDU_NOT_SET; 9295 dut->ap_he_ulofdma = VALUE_NOT_SET; 9296 dut->ap_numsounddim = 0; 9297 dut->ap_bcc = VALUE_DISABLED; 9298 dut->ap_mu_edca = VALUE_DISABLED; 9299 dut->ap_he_mimo = MIMO_NOT_SET; 9300 dut->ap_he_rtsthrshld = VALUE_NOT_SET; 9301 dut->ap_mbssid = VALUE_DISABLED; 9302 dut->ap_ampdu = VALUE_NOT_SET; 9303 dut->he_mcsnssmap = 0; 9304 dut->ap_fixed_rate = 0; 9305 dut->he_mmss = 0; 9306 dut->he_set_sta_1x1 = VALUE_DISABLED; 9307 dut->he_srctrl_allow = -1; 9308 if (dut->device_type == AP_testbed) { 9309 dut->ap_he_dlofdma = VALUE_DISABLED; 9310 dut->ap_he_frag = VALUE_DISABLED; 9311 dut->ap_twtresp = VALUE_DISABLED; 9312 dut->he_ul_mcs = 7; 9313 } else { 9314 dut->ap_he_dlofdma = VALUE_NOT_SET; 9315 dut->ap_he_frag = VALUE_NOT_SET; 9316 dut->ap_ba_bufsize = BA_BUFSIZE_NOT_SET; 9317 dut->ap_twtresp = VALUE_NOT_SET; 9318 dut->he_ul_mcs = 0; 9319 } 9320 9321 if (dut->program == PROGRAM_HE) { 9322 if (dut->device_type == AP_testbed) { 9323 dut->ap_ldpc = VALUE_DISABLED; 9324 dut->ap_ba_bufsize = BA_BUFSIZE_64; 9325 dut->ap_amsdu = VALUE_DISABLED; 9326 dut->ap_txBF = 0; 9327 dut->ap_mu_txBF = 0; 9328 dut->he_sounding = VALUE_DISABLED; 9329 } else { 9330 if (drv == DRIVER_WCN || drv == DRIVER_LINUX_WCN) { 9331 dut->ap_txBF = 0; 9332 dut->ap_mu_txBF = 0; 9333 } else { 9334 dut->ap_txBF = 1; 9335 dut->ap_mu_txBF = 1; 9336 } 9337 dut->he_sounding = VALUE_ENABLED; 9338 if (drv == DRIVER_LINUX_WCN) { 9339 dut->ap_ldpc = VALUE_ENABLED; 9340 wcn_config_ap_ldpc(dut, get_main_ifname(dut)); 9341 #ifdef NL80211_SUPPORT 9342 if (wcn_set_he_ltf(dut, get_main_ifname(dut), 9343 QCA_WLAN_HE_LTF_AUTO)) { 9344 sigma_dut_print(dut, DUT_MSG_ERROR, 9345 "Failed to set LTF in ap_reset_default"); 9346 } 9347 #endif /* NL80211_SUPPORT */ 9348 } 9349 } 9350 if (get_openwrt_driver_type() == OPENWRT_DRIVER_ATHEROS) 9351 dut->ap_dfs_mode = AP_DFS_MODE_ENABLED; 9352 } 9353 9354 dut->ap_oper_chn = 0; 9355 9356 dut->ap_pmksa = 0; 9357 dut->ap_pmksa_caching = 0; 9358 9359 free(dut->rsne_override); 9360 dut->rsne_override = NULL; 9361 free(dut->rsnxe_override_eapol); 9362 dut->rsnxe_override_eapol = NULL; 9363 9364 free(dut->sae_commit_override); 9365 dut->sae_commit_override = NULL; 9366 9367 free(dut->ap_sae_groups); 9368 dut->ap_sae_groups = NULL; 9369 9370 dut->sae_anti_clogging_threshold = -1; 9371 dut->sae_reflection = 0; 9372 dut->ap_sae_commit_status = -1; 9373 dut->ap_sae_pk_omit = 0; 9374 dut->sae_confirm_immediate = 0; 9375 dut->sae_pwe = SAE_PWE_DEFAULT; 9376 9377 dut->ap_cipher = AP_CCMP; 9378 dut->ap_group_cipher = AP_NO_GROUP_CIPHER_SET; 9379 dut->ap_group_mgmt_cipher = AP_NO_GROUP_MGMT_CIPHER_SET; 9380 dut->ap_passphrase[0] = '\0'; 9381 dut->ap_psk[0] = '\0'; 9382 dut->ap_beacon_prot = 0; 9383 dut->ap_transition_disable = 0; 9384 9385 dut->dpp_conf_id = -1; 9386 free(dut->ap_dpp_conf_addr); 9387 dut->ap_dpp_conf_addr = NULL; 9388 free(dut->ap_dpp_conf_pkhash); 9389 dut->ap_dpp_conf_pkhash = NULL; 9390 dut->ap_start_disabled = 0; 9391 9392 if (is_60g_sigma_dut(dut)) { 9393 dut->ap_mode = AP_11ad; 9394 dut->ap_channel = 2; 9395 dut->wps_disable = 0; /* WPS is enabled */ 9396 dut->ap_pmf = 0; 9397 dut->ap_num_ese_allocs = 0; 9398 dut->ap_fixed_rate = 0; 9399 9400 dut->dev_role = DEVROLE_AP; 9401 9402 sigma_dut_print(dut, DUT_MSG_DEBUG, 9403 "Setting msdu_size to MAX: 7912"); 9404 snprintf(buf, sizeof(buf), "ifconfig %s mtu 7912", 9405 get_main_ifname(dut)); 9406 9407 if (system(buf) != 0) { 9408 sigma_dut_print(dut, DUT_MSG_ERROR, "Failed to set %s", 9409 buf); 9410 return ERROR_SEND_STATUS; 9411 } 9412 9413 if (ap_set_force_mcs(dut, 0, 1)) { 9414 sigma_dut_print(dut, DUT_MSG_ERROR, 9415 "Failed to reset force MCS"); 9416 return ERROR_SEND_STATUS; 9417 } 9418 9419 if (set_ps(get_main_ifname(dut), dut, 1)) { 9420 sigma_dut_print(dut, DUT_MSG_ERROR, 9421 "Failed to enable power save"); 9422 return ERROR_SEND_STATUS; 9423 } 9424 } 9425 9426 if (dut->program == PROGRAM_WPS && 9427 get_driver_type(dut) == DRIVER_WIL6210) { 9428 /* 9429 * In 60 GHz WPS tests, we configure the AP OOB to 9430 * secure connection with a random passphrase. 9431 */ 9432 char r[16], passphrase[65]; 9433 9434 if (random_get_bytes(r, sizeof(r))) { 9435 sigma_dut_print(dut, DUT_MSG_ERROR, 9436 "Failed to get random bytes"); 9437 return ERROR_SEND_STATUS; 9438 } 9439 if (base64_encode(r, sizeof(r), 9440 passphrase, sizeof(passphrase))) { 9441 sigma_dut_print(dut, DUT_MSG_ERROR, 9442 "Failed to generate random passphrase"); 9443 return ERROR_SEND_STATUS; 9444 } 9445 9446 dut->ap_key_mgmt = AP_WPA2_PSK; 9447 dut->ap_cipher = AP_GCMP_128; 9448 strlcpy(dut->ap_passphrase, passphrase, 9449 sizeof(dut->ap_passphrase)); 9450 sigma_dut_print(dut, DUT_MSG_DEBUG, 9451 "60G WPS: configure secure AP with random passphrase"); 9452 } 9453 9454 dut->hostapd_running = 0; 9455 9456 if (get_openwrt_driver_type() == OPENWRT_DRIVER_ATHEROS) 9457 return 1; 9458 9459 if (dut->use_hostapd_pid_file) { 9460 kill_hostapd_process_pid(dut); 9461 } else if (kill_process(dut, "(hostapd)", 1, SIGTERM) == 0 || 9462 system("killall hostapd") == 0) { 9463 int i; 9464 /* Wait some time to allow hostapd to complete cleanup before 9465 * starting a new process */ 9466 for (i = 0; i < 10; i++) { 9467 usleep(500000); 9468 if (system("pidof hostapd") != 0) 9469 break; 9470 } 9471 } 9472 9473 if (if_nametoindex("sigmadut") > 0 && 9474 system("iw dev sigmadut del") != 0) 9475 sigma_dut_print(dut, DUT_MSG_ERROR, "Failed to remove " 9476 "monitor interface"); 9477 9478 return 1; 9479 } 9480 9481 9482 int sta_cfon_reset_default(struct sigma_dut *dut, struct sigma_conn *conn, 9483 struct sigma_cmd *cmd) 9484 { 9485 return cmd_ap_reset_default(dut, conn, cmd); 9486 } 9487 9488 9489 static enum sigma_cmd_result cmd_ap_get_info(struct sigma_dut *dut, 9490 struct sigma_conn *conn, 9491 struct sigma_cmd *cmd) 9492 { 9493 /* const char *name = get_param(cmd, "NAME"); */ 9494 struct stat s; 9495 char resp[200]; 9496 FILE *f; 9497 enum driver_type drv = get_driver_type(dut); 9498 int res; 9499 9500 switch (drv) { 9501 case DRIVER_ATHEROS: { 9502 /* Atheros AP */ 9503 struct utsname uts; 9504 char *version, athver[100]; 9505 9506 if (stat("/proc/athversion", &s) != 0) { 9507 if (system("/etc/rc.d/rc.wlan up") != 0) { 9508 } 9509 } 9510 9511 athver[0] = '\0'; 9512 f = fopen("/proc/athversion", "r"); 9513 if (f) { 9514 if (fgets(athver, sizeof(athver), f)) { 9515 char *pos = strchr(athver, '\n'); 9516 if (pos) 9517 *pos = '\0'; 9518 } 9519 fclose(f); 9520 } 9521 9522 if (uname(&uts) == 0) 9523 version = uts.release; 9524 else 9525 version = "Unknown"; 9526 9527 if (if_nametoindex("ath1") > 0) 9528 res = snprintf(resp, sizeof(resp), 9529 "interface,ath0_24G ath1_5G,agent,1.0,version,%s/drv:%s", 9530 version, athver); 9531 else 9532 res = snprintf(resp, sizeof(resp), 9533 "interface,ath0_24G,agent,1.0,version,%s/drv:%s", 9534 version, athver); 9535 if (res < 0 || res >= sizeof(resp)) 9536 send_resp(dut, conn, SIGMA_ERROR, NULL); 9537 else 9538 send_resp(dut, conn, SIGMA_COMPLETE, resp); 9539 return 0; 9540 } 9541 case DRIVER_LINUX_WCN: 9542 case DRIVER_MAC80211: { 9543 struct utsname uts; 9544 char *version; 9545 9546 if (uname(&uts) == 0) 9547 version = uts.release; 9548 else 9549 version = "Unknown"; 9550 9551 if (if_nametoindex("wlan1") > 0) 9552 snprintf(resp, sizeof(resp), "interface,wlan0_24G " 9553 "wlan1_5G,agent,1.0,version,%s", version); 9554 else 9555 snprintf(resp, sizeof(resp), "interface,wlan0_any," 9556 "agent,1.0,version,%s", version); 9557 9558 send_resp(dut, conn, SIGMA_COMPLETE, resp); 9559 return 0; 9560 } 9561 case DRIVER_QNXNTO: { 9562 struct utsname uts; 9563 char *version; 9564 9565 if (uname(&uts) == 0) 9566 version = uts.release; 9567 else 9568 version = "Unknown"; 9569 snprintf(resp, sizeof(resp), 9570 "interface,%s_any,agent,1.0,version,%s", 9571 dut->main_ifname ? get_main_ifname(dut) : "NA", 9572 version); 9573 send_resp(dut, conn, SIGMA_COMPLETE, resp); 9574 return 0; 9575 } 9576 case DRIVER_OPENWRT: { 9577 switch (get_openwrt_driver_type()) { 9578 case OPENWRT_DRIVER_ATHEROS: { 9579 struct utsname uts; 9580 char *version; 9581 9582 if (uname(&uts) == 0) 9583 version = uts.release; 9584 else 9585 version = "Unknown"; 9586 9587 if (if_nametoindex("ath1") > 0) 9588 snprintf(resp, sizeof(resp), 9589 "interface,ath0_5G ath1_24G,agent,1.0,version,%s", 9590 version); 9591 else 9592 snprintf(resp, sizeof(resp), 9593 "interface,ath0_any,agent,1.0,version,%s", 9594 version); 9595 9596 send_resp(dut, conn, SIGMA_COMPLETE, resp); 9597 return 0; 9598 } 9599 default: 9600 send_resp(dut, conn, SIGMA_ERROR, 9601 "errorCode,Unsupported openwrt driver"); 9602 return 0; 9603 } 9604 } 9605 default: 9606 send_resp(dut, conn, SIGMA_ERROR, 9607 "errorCode,Unsupported driver"); 9608 return 0; 9609 } 9610 } 9611 9612 9613 static enum sigma_cmd_result cmd_ap_deauth_sta(struct sigma_dut *dut, 9614 struct sigma_conn *conn, 9615 struct sigma_cmd *cmd) 9616 { 9617 /* const char *name = get_param(cmd, "NAME"); */ 9618 /* const char *ifname = get_param(cmd, "INTERFACE"); */ 9619 const char *val, *disconnect; 9620 char buf[100]; 9621 9622 val = get_param(cmd, "MinorCode"); 9623 if (val) { 9624 /* TODO: add support for P2P minor code */ 9625 send_resp(dut, conn, SIGMA_ERROR, "errorCode,MinorCode not " 9626 "yet supported"); 9627 return 0; 9628 } 9629 9630 val = get_param(cmd, "STA_MAC_ADDRESS"); 9631 if (val == NULL) 9632 return -1; 9633 disconnect = get_param(cmd, "disconnect"); 9634 if (disconnect && strcasecmp(disconnect, "silent") == 0) 9635 snprintf(buf, sizeof(buf), "deauth %s tx=0", val); 9636 else 9637 snprintf(buf, sizeof(buf), "deauth %s", val); 9638 if (run_hostapd_cli(dut, buf) != 0) 9639 return -2; 9640 9641 return 1; 9642 } 9643 9644 9645 #ifdef __linux__ 9646 int inject_frame(int s, const void *data, size_t len, int encrypt); 9647 int open_monitor(const char *ifname); 9648 #endif /* __linux__ */ 9649 9650 enum send_frame_type { 9651 DISASSOC, DEAUTH, SAQUERY 9652 }; 9653 enum send_frame_protection { 9654 CORRECT_KEY, INCORRECT_KEY, UNPROTECTED 9655 }; 9656 9657 9658 static int ap_inject_frame(struct sigma_dut *dut, struct sigma_conn *conn, 9659 enum send_frame_type frame, 9660 enum send_frame_protection protected, 9661 const char *sta_addr) 9662 { 9663 #ifdef __linux__ 9664 unsigned char buf[1000], *pos; 9665 int s, res; 9666 unsigned char addr_sta[6], addr_own[6]; 9667 char *ifname; 9668 char cbuf[100]; 9669 struct ifreq ifr; 9670 9671 if ((dut->ap_mode == AP_11a || dut->ap_mode == AP_11na || 9672 dut->ap_mode == AP_11ac) && 9673 if_nametoindex("wlan1") > 0) 9674 ifname = "wlan1"; 9675 else 9676 ifname = "wlan0"; 9677 9678 if (hwaddr_aton(sta_addr, addr_sta) < 0) 9679 return -1; 9680 9681 s = socket(AF_INET, SOCK_DGRAM, 0); 9682 if (s < 0) 9683 return -1; 9684 memset(&ifr, 0, sizeof(ifr)); 9685 strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name)); 9686 if (ioctl(s, SIOCGIFHWADDR, &ifr) < 0) { 9687 perror("ioctl"); 9688 close(s); 9689 return -1; 9690 } 9691 close(s); 9692 memcpy(addr_own, ifr.ifr_hwaddr.sa_data, 6); 9693 9694 if (if_nametoindex("sigmadut") == 0) { 9695 snprintf(cbuf, sizeof(cbuf), 9696 "iw dev %s interface add sigmadut type monitor", 9697 ifname); 9698 if (system(cbuf) != 0 || 9699 if_nametoindex("sigmadut") == 0) { 9700 sigma_dut_print(dut, DUT_MSG_ERROR, "Failed to add " 9701 "monitor interface with '%s'", cbuf); 9702 return -2; 9703 } 9704 } 9705 9706 if (system("ifconfig sigmadut up") != 0) { 9707 sigma_dut_print(dut, DUT_MSG_ERROR, "Failed to set " 9708 "monitor interface up"); 9709 return -2; 9710 } 9711 9712 pos = buf; 9713 9714 /* Frame Control */ 9715 switch (frame) { 9716 case DISASSOC: 9717 *pos++ = 0xa0; 9718 break; 9719 case DEAUTH: 9720 *pos++ = 0xc0; 9721 break; 9722 case SAQUERY: 9723 *pos++ = 0xd0; 9724 break; 9725 } 9726 9727 if (protected == INCORRECT_KEY) 9728 *pos++ = 0x40; /* Set Protected field to 1 */ 9729 else 9730 *pos++ = 0x00; 9731 9732 /* Duration */ 9733 *pos++ = 0x00; 9734 *pos++ = 0x00; 9735 9736 /* addr1 = DA (station) */ 9737 memcpy(pos, addr_sta, 6); 9738 pos += 6; 9739 /* addr2 = SA (own address) */ 9740 memcpy(pos, addr_own, 6); 9741 pos += 6; 9742 /* addr3 = BSSID (own address) */ 9743 memcpy(pos, addr_own, 6); 9744 pos += 6; 9745 9746 /* Seq# (to be filled by driver/mac80211) */ 9747 *pos++ = 0x00; 9748 *pos++ = 0x00; 9749 9750 if (protected == INCORRECT_KEY) { 9751 /* CCMP parameters */ 9752 memcpy(pos, "\x61\x01\x00\x20\x00\x10\x00\x00", 8); 9753 pos += 8; 9754 } 9755 9756 if (protected == INCORRECT_KEY) { 9757 switch (frame) { 9758 case DEAUTH: 9759 /* Reason code (encrypted) */ 9760 memcpy(pos, "\xa7\x39", 2); 9761 pos += 2; 9762 break; 9763 case DISASSOC: 9764 /* Reason code (encrypted) */ 9765 memcpy(pos, "\xa7\x39", 2); 9766 pos += 2; 9767 break; 9768 case SAQUERY: 9769 /* Category|Action|TransID (encrypted) */ 9770 memcpy(pos, "\x6f\xbd\xe9\x4d", 4); 9771 pos += 4; 9772 break; 9773 default: 9774 return -1; 9775 } 9776 9777 /* CCMP MIC */ 9778 memcpy(pos, "\xc8\xd8\x3b\x06\x5d\xb7\x25\x68", 8); 9779 pos += 8; 9780 } else { 9781 switch (frame) { 9782 case DEAUTH: 9783 /* reason code = 8 */ 9784 *pos++ = 0x08; 9785 *pos++ = 0x00; 9786 break; 9787 case DISASSOC: 9788 /* reason code = 8 */ 9789 *pos++ = 0x08; 9790 *pos++ = 0x00; 9791 break; 9792 case SAQUERY: 9793 /* Category - SA Query */ 9794 *pos++ = 0x08; 9795 /* SA query Action - Request */ 9796 *pos++ = 0x00; 9797 /* Transaction ID */ 9798 *pos++ = 0x12; 9799 *pos++ = 0x34; 9800 break; 9801 } 9802 } 9803 9804 s = open_monitor("sigmadut"); 9805 if (s < 0) { 9806 send_resp(dut, conn, SIGMA_ERROR, "errorCode,Failed to open " 9807 "monitor socket"); 9808 return 0; 9809 } 9810 9811 res = inject_frame(s, buf, pos - buf, protected == CORRECT_KEY); 9812 if (res < 0) { 9813 send_resp(dut, conn, SIGMA_ERROR, "errorCode,Failed to " 9814 "inject frame"); 9815 close(s); 9816 return 0; 9817 } 9818 if (res < pos - buf) { 9819 send_resp(dut, conn, SIGMA_ERROR, "errorCode,Only partial " 9820 "frame sent"); 9821 close(s); 9822 return 0; 9823 } 9824 9825 close(s); 9826 9827 return 1; 9828 #else /* __linux__ */ 9829 send_resp(dut, conn, SIGMA_ERROR, "errorCode,ap_send_frame not " 9830 "yet supported"); 9831 return 0; 9832 #endif /* __linux__ */ 9833 } 9834 9835 9836 int ap_send_frame_hs2(struct sigma_dut *dut, struct sigma_conn *conn, 9837 struct sigma_cmd *cmd) 9838 { 9839 const char *val, *dest; 9840 char buf[100]; 9841 9842 val = get_param(cmd, "FrameName"); 9843 if (val == NULL) 9844 return -1; 9845 9846 if (strcasecmp(val, "QoSMapConfigure") == 0) { 9847 dest = get_param(cmd, "Dest"); 9848 if (!dest) 9849 return -1; 9850 9851 val = get_param(cmd, "QoS_MAP_SET"); 9852 if (val) { 9853 dut->ap_qos_map_set = atoi(val); 9854 sigma_dut_print(dut, DUT_MSG_INFO, "ap_qos_map_set %d", 9855 dut->ap_qos_map_set); 9856 } 9857 9858 if (dut->ap_qos_map_set == 1) 9859 run_hostapd_cli(dut, "set_qos_map_set " QOS_MAP_SET_1); 9860 else if (dut->ap_qos_map_set == 2) 9861 run_hostapd_cli(dut, "set_qos_map_set " QOS_MAP_SET_2); 9862 9863 snprintf(buf, sizeof(buf), "send_qos_map_conf %s", dest); 9864 if (run_hostapd_cli(dut, buf) != 0) 9865 return -1; 9866 } 9867 9868 return 1; 9869 } 9870 9871 9872 static int ath_ap_send_frame_vht(struct sigma_dut *dut, struct sigma_conn *conn, 9873 struct sigma_cmd *cmd) 9874 { 9875 const char *val; 9876 const char *ifname; 9877 int chwidth, nss; 9878 9879 val = get_param(cmd, "FrameName"); 9880 if (!val || strcasecmp(val, "op_md_notif_frm") != 0) { 9881 send_resp(dut, conn, SIGMA_ERROR, 9882 "errorCode,Unsupported FrameName"); 9883 return 0; 9884 } 9885 9886 /* 9887 * Sequence of commands for Opmode notification on 9888 * Peregrine based products 9889 */ 9890 ifname = get_main_ifname(dut); 9891 9892 /* Disable STBC */ 9893 run_iwpriv(dut, ifname, "tx_stbc 0"); 9894 9895 /* Check whether optional arg channel width was passed */ 9896 val = get_param(cmd, "Channel_width"); 9897 if (val) { 9898 switch (atoi(val)) { 9899 case 20: 9900 chwidth = 0; 9901 break; 9902 case 40: 9903 chwidth = 1; 9904 break; 9905 case 80: 9906 chwidth = 2; 9907 break; 9908 case 160: 9909 chwidth = 3; 9910 break; 9911 default: 9912 chwidth = 2; 9913 break; 9914 } 9915 run_iwpriv(dut, ifname, "chwidth %d", chwidth); 9916 } 9917 9918 /* Check whether optional arg NSS was passed */ 9919 val = get_param(cmd, "NSS"); 9920 if (val) { 9921 /* Convert nss to chainmask */ 9922 switch (atoi(val)) { 9923 case 1: 9924 nss = 1; 9925 break; 9926 case 2: 9927 nss = 3; 9928 break; 9929 case 3: 9930 nss = 7; 9931 break; 9932 default: 9933 /* We do not support NSS > 3 */ 9934 nss = 3; 9935 break; 9936 } 9937 run_iwpriv(dut, ifname, "rxchainmask %d", nss); 9938 } 9939 9940 /* Send the opmode notification */ 9941 run_iwpriv(dut, ifname, "opmode_notify 1"); 9942 9943 return 1; 9944 } 9945 9946 9947 static int ath_ap_send_frame_loc(struct sigma_dut *dut, struct sigma_conn *conn, 9948 struct sigma_cmd *cmd) 9949 { 9950 const char *val; 9951 FILE *f; 9952 int rand_int = 0; 9953 9954 val = get_param(cmd, "MsntType"); 9955 if (val) { 9956 if (dut->ap_msnt_type == 0) 9957 dut->ap_msnt_type = atoi(val); 9958 9959 if (dut->ap_msnt_type != 5 && dut->ap_msnt_type != 2) { 9960 dut->ap_msnt_type = atoi(val); 9961 if (dut->ap_msnt_type == 1) { 9962 val = get_param(cmd, "RandInterval"); 9963 if (val) 9964 rand_int = atoi(val); 9965 f = fopen("/tmp/ftmrr.txt", "a"); 9966 if (!f) { 9967 sigma_dut_print(dut, DUT_MSG_ERROR, 9968 "Failed to open /tmp/ftmrr.txt"); 9969 return -1; 9970 } 9971 9972 fprintf(f, "sta_mac = %s\n", cmd->values[3]); 9973 fprintf(f, "meas_type = 0x10\nrand_inter = 0x%x\nmin_ap_count = 0x%s\ndialogtoken = 0x1\nnum_repetitions = 0x0\nmeas_token = 0xf\nmeas_req_mode = 0x00\n", 9974 rand_int, cmd->values[7]); 9975 fclose(f); 9976 dut->ap_msnt_type = 5; 9977 run_system(dut, "wpc -f /tmp/ftmrr.txt"); 9978 } 9979 } else if (dut->ap_msnt_type == 5) { 9980 run_system(dut, "wpc -f /tmp/ftmrr.txt"); 9981 } else if (dut->ap_msnt_type == 2) { 9982 f = fopen("/tmp/wru.txt", "w"); 9983 if (!f) { 9984 sigma_dut_print(dut, DUT_MSG_ERROR, 9985 "Failed to open /tmp/wru.txt"); 9986 return -1; 9987 } 9988 9989 fprintf(f, "sta_mac = %s\n", cmd->values[3]); 9990 fprintf(f, "meas_type = 0x08\ndialogtoken = 0x1\nnum_repetitions = 0x0\nmeas_token = 0x1\nmeas_req_mode = 0x00\nloc_subject = 0x01\n"); 9991 fclose(f); 9992 run_system(dut, "wpc -w /tmp/wru.txt"); 9993 } 9994 } 9995 return 1; 9996 } 9997 9998 9999 /* 10000 * The following functions parse_send_frame_params_int(), 10001 * parse_send_frame_params_str(), and parse_send_frame_params_mac() 10002 * are used by ath_ap_send_frame_bcn_rpt_req(). 10003 * Beacon Report Request is a frame used as part of the MBO program. 10004 * The command for sending beacon report has a lot of 10005 * arguments and having these functions reduces code size. 10006 * 10007 */ 10008 static int parse_send_frame_params_int(char *param, struct sigma_cmd *cmd, 10009 struct sigma_dut *dut, 10010 char *buf, size_t buf_size) 10011 { 10012 const char *str_val; 10013 int int_val; 10014 char temp[100]; 10015 10016 str_val = get_param(cmd, param); 10017 if (!str_val) { 10018 sigma_dut_print(dut, DUT_MSG_ERROR, "%s not given", param); 10019 return -1; 10020 } 10021 int_val = atoi(str_val); 10022 snprintf(temp, sizeof(temp), " %d", int_val); 10023 strlcat(buf, temp, buf_size); 10024 return 0; 10025 } 10026 10027 10028 static int parse_send_frame_params_str(char *param, struct sigma_cmd *cmd, 10029 struct sigma_dut *dut, 10030 char *buf, size_t buf_size) 10031 { 10032 const char *str_val; 10033 char temp[100]; 10034 10035 str_val = get_param(cmd, param); 10036 if (!str_val) { 10037 sigma_dut_print(dut, DUT_MSG_ERROR, "%s not given", param); 10038 return -1; 10039 } 10040 snprintf(temp, sizeof(temp), " %s", str_val); 10041 temp[sizeof(temp) - 1] = '\0'; 10042 strlcat(buf, temp, buf_size); 10043 return 0; 10044 } 10045 10046 10047 static int parse_send_frame_params_mac(char *param, struct sigma_cmd *cmd, 10048 struct sigma_dut *dut, 10049 char *buf, size_t buf_size) 10050 { 10051 const char *str_val; 10052 unsigned char mac[6]; 10053 char temp[100]; 10054 10055 str_val = get_param(cmd, param); 10056 if (!str_val) { 10057 sigma_dut_print(dut, DUT_MSG_ERROR, "%s not given", param); 10058 return -1; 10059 } 10060 10061 if (parse_mac_address(dut, str_val, mac) < 0) { 10062 sigma_dut_print(dut, DUT_MSG_ERROR, 10063 "MAC Address not in proper format"); 10064 return -1; 10065 } 10066 snprintf(temp, sizeof(temp), " %02x:%02x:%02x:%02x:%02x:%02x", 10067 mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]); 10068 strlcat(buf, temp, buf_size); 10069 return 0; 10070 } 10071 10072 10073 static void fill_1_or_0_based_on_presence(struct sigma_cmd *cmd, char *param, 10074 char *buf, size_t buf_size) 10075 { 10076 const char *str_val; 10077 char *value = " 1"; 10078 10079 str_val = get_param(cmd, param); 10080 if (!str_val || str_val[0] == '\0') 10081 value = " 0"; 10082 strlcat(buf, value, buf_size); 10083 10084 } 10085 10086 10087 /* 10088 * wifitool athN sendbcnrpt 10089 * <STA MAC - Plugs in from Dest_MAC> 10090 * <regclass - Plugs in from RegClass - int> 10091 * <channum - Plugs in from Channel PARAM of dev_send_frame - int> 10092 * <rand_ivl - Plugs in from RandInt - string> 10093 * <duration - Plugs in from MeaDur - integer> 10094 * <mode - Plugs in from MeaMode - string> 10095 * <req_ssid - Plugs in from SSID PARAM of dev_send_frame - string> 10096 * <rep_cond - Plugs in from RptCond - integer> 10097 * <rpt_detail - Plugs in from RptDet - integer> 10098 * <req_ie - Plugs in from ReqInfo PARAM of dev_send_frame - string> 10099 * <chanrpt_mode - Plugs in from APChanRpt - integer> 10100 * <specific_bssid - Plugs in from BSSID PARAM of dev_send_frame> 10101 * [AP channel numbers] 10102 */ 10103 static int ath_ap_send_frame_bcn_rpt_req(struct sigma_dut *dut, 10104 struct sigma_cmd *cmd, 10105 const char *ifname) 10106 { 10107 char buf[100]; 10108 int rpt_det; 10109 const char *str_val; 10110 const char *mea_mode; 10111 10112 snprintf(buf, sizeof(buf), "wifitool %s sendbcnrpt", ifname); 10113 10114 if (parse_send_frame_params_mac("Dest_MAC", cmd, dut, buf, sizeof(buf))) 10115 return -1; 10116 if (parse_send_frame_params_int("RegClass", cmd, dut, buf, sizeof(buf))) 10117 return -1; 10118 if (parse_send_frame_params_int("Channel", cmd, dut, buf, sizeof(buf))) 10119 return -1; 10120 if (parse_send_frame_params_str("RandInt", cmd, dut, buf, sizeof(buf))) 10121 return -1; 10122 if (parse_send_frame_params_int("MeaDur", cmd, dut, buf, sizeof(buf))) 10123 return -1; 10124 10125 str_val = get_param(cmd, "MeaMode"); 10126 if (!str_val) { 10127 sigma_dut_print(dut, DUT_MSG_ERROR, 10128 "MeaMode parameter not present in send bcn-rpt-req"); 10129 return -1; 10130 } 10131 if (strcasecmp(str_val, "passive") == 0) { 10132 mea_mode = " 0"; 10133 } else if (strcasecmp(str_val, "active") == 0) { 10134 mea_mode = " 1"; 10135 } else if (strcasecmp(str_val, "table") == 0) { 10136 mea_mode = " 2"; 10137 } else { 10138 sigma_dut_print(dut, DUT_MSG_ERROR, 10139 "MEA-MODE Value not correctly given"); 10140 return -1; 10141 } 10142 strlcat(buf, mea_mode, sizeof(buf)); 10143 10144 fill_1_or_0_based_on_presence(cmd, "SSID", buf, sizeof(buf)); 10145 10146 if (parse_send_frame_params_int("RptCond", cmd, dut, buf, sizeof(buf))) 10147 return -1; 10148 10149 if (parse_send_frame_params_int("RptDet", cmd, dut, buf, sizeof(buf))) 10150 return -1; 10151 str_val = get_param(cmd, "RptDet"); 10152 rpt_det = str_val ? atoi(str_val) : 0; 10153 10154 if (rpt_det) 10155 fill_1_or_0_based_on_presence(cmd, "ReqInfo", buf, sizeof(buf)); 10156 else 10157 strlcat(buf, " 0", sizeof(buf)); 10158 10159 if (rpt_det) 10160 fill_1_or_0_based_on_presence(cmd, "APChanRpt", buf, 10161 sizeof(buf)); 10162 else 10163 strlcat(buf, " 0", sizeof(buf)); 10164 10165 if (parse_send_frame_params_mac("BSSID", cmd, dut, buf, sizeof(buf))) 10166 return -1; 10167 10168 str_val = get_param(cmd, "APChanRpt"); 10169 if (str_val) { 10170 const char *pos; 10171 int ap_chanrpt; 10172 int ap_chanrpt_2 = 0; 10173 char chanrpt[100]; 10174 10175 ap_chanrpt = atoi(str_val); 10176 pos = strchr(str_val, '_'); 10177 if (pos) { 10178 pos++; 10179 ap_chanrpt_2 = atoi(pos); 10180 } 10181 if (ap_chanrpt) { 10182 snprintf(chanrpt, sizeof(chanrpt), " %d", ap_chanrpt); 10183 strlcat(buf, chanrpt, sizeof(buf)); 10184 } 10185 if (ap_chanrpt_2) { 10186 snprintf(chanrpt, sizeof(chanrpt), " %d", ap_chanrpt_2); 10187 strlcat(buf, chanrpt, sizeof(buf)); 10188 } 10189 } 10190 10191 run_system(dut, buf); 10192 return 0; 10193 } 10194 10195 10196 static void inform_and_sleep(struct sigma_dut *dut, int seconds) 10197 { 10198 sigma_dut_print(dut, DUT_MSG_DEBUG, "sleeping for %d seconds", seconds); 10199 sleep(seconds); 10200 sigma_dut_print(dut, DUT_MSG_DEBUG, "woke up after %d seconds", 10201 seconds); 10202 } 10203 10204 10205 static int ath_ap_send_frame_btm_req(struct sigma_dut *dut, 10206 struct sigma_cmd *cmd, const char *ifname) 10207 { 10208 unsigned char mac_addr[ETH_ALEN]; 10209 int disassoc_timer; 10210 char buf[100]; 10211 const char *val; 10212 int cand_list = 1; 10213 10214 val = get_param(cmd, "Dest_MAC"); 10215 if (!val || parse_mac_address(dut, val, mac_addr) < 0) { 10216 sigma_dut_print(dut, DUT_MSG_ERROR, 10217 "MAC Address not in proper format"); 10218 return -1; 10219 } 10220 10221 val = get_param(cmd, "Disassoc_Timer"); 10222 if (val) 10223 disassoc_timer = atoi(val); 10224 else 10225 disassoc_timer = dut->ap_disassoc_timer; 10226 if (disassoc_timer < 0) { 10227 sigma_dut_print(dut, DUT_MSG_ERROR, 10228 "Invalid Disassoc_Timer value %d", 10229 disassoc_timer); 10230 return -1; 10231 } 10232 10233 val = get_param(cmd, "Cand_List"); 10234 if (val && val[0]) 10235 cand_list = atoi(val); 10236 10237 val = get_param(cmd, "BTMQuery_Reason_Code"); 10238 if (val) 10239 run_iwpriv(dut, ifname, "mbo_trans_rs %s", val); 10240 10241 if (dut->ap_btmreq_disassoc_imnt && !dut->ap_assoc_delay) 10242 run_iwpriv(dut, ifname, "mbo_asoc_ret 1"); 10243 10244 snprintf(buf, sizeof(buf), 10245 "wifitool %s sendbstmreq %02x:%02x:%02x:%02x:%02x:%02x %d %d 15 %d %d %d %d", 10246 ifname, mac_addr[0], mac_addr[1], mac_addr[2], mac_addr[3], 10247 mac_addr[4], mac_addr[5], cand_list, disassoc_timer, 10248 dut->ap_btmreq_disassoc_imnt, 10249 dut->ap_btmreq_term_bit, 10250 dut->ap_btmreq_bss_term_tsf, 10251 dut->ap_btmreq_bss_term_dur); 10252 run_system(dut, buf); 10253 10254 if (dut->ap_btmreq_term_bit) { 10255 if (dut->ap_btmreq_bss_term_tsf >= 2) 10256 inform_and_sleep(dut, dut->ap_btmreq_bss_term_tsf - 2); 10257 run_iwpriv(dut, ifname, "kickmac %02x:%02x:%02x:%02x:%02x:%02x", 10258 mac_addr[0], mac_addr[1], mac_addr[2], 10259 mac_addr[3], mac_addr[4], mac_addr[5]); 10260 inform_and_sleep(dut, 2); 10261 run_system_wrapper(dut, "ifconfig %s down", ifname); 10262 inform_and_sleep(dut, 5); 10263 run_system_wrapper(dut, "ifconfig %s up", ifname); 10264 } else if (dut->ap_btmreq_disassoc_imnt) { 10265 inform_and_sleep(dut, (disassoc_timer / 1000) + 1); 10266 run_iwpriv(dut, ifname, "kickmac %02x:%02x:%02x:%02x:%02x:%02x", 10267 mac_addr[0], mac_addr[1], mac_addr[2], 10268 mac_addr[3], mac_addr[4], mac_addr[5]); 10269 } 10270 return 0; 10271 } 10272 10273 10274 static int ath_ap_send_frame_disassoc(struct sigma_dut *dut, 10275 struct sigma_cmd *cmd, const char *ifname) 10276 { 10277 unsigned char mac_addr[ETH_ALEN]; 10278 const char *val; 10279 10280 val = get_param(cmd, "Dest_MAC"); 10281 if (!val || parse_mac_address(dut, val, mac_addr) < 0) { 10282 sigma_dut_print(dut, DUT_MSG_ERROR, 10283 "MAC Address not in proper format"); 10284 return -1; 10285 } 10286 10287 run_iwpriv(dut, ifname, "kickmac %02x:%02x:%02x:%02x:%02x:%02x", 10288 mac_addr[0], mac_addr[1], mac_addr[2], 10289 mac_addr[3], mac_addr[4], mac_addr[5]); 10290 return 0; 10291 } 10292 10293 10294 static int ath_ap_send_frame_mbo(struct sigma_dut *dut, struct sigma_conn *conn, 10295 struct sigma_cmd *cmd) 10296 { 10297 const char *val; 10298 const char *ifname; 10299 10300 ifname = get_main_ifname(dut); 10301 10302 val = get_param(cmd, "FrameName"); 10303 if (!val) 10304 return -1; 10305 10306 if (strcasecmp(val, "BTMReq") == 0) 10307 ath_ap_send_frame_btm_req(dut, cmd, ifname); 10308 else if (strcasecmp(val, "BcnRptReq") == 0) 10309 ath_ap_send_frame_bcn_rpt_req(dut, cmd, ifname); 10310 else if (strcasecmp(val, "disassoc") == 0) 10311 ath_ap_send_frame_disassoc(dut, cmd, ifname); 10312 else 10313 return -1; 10314 10315 return 1; 10316 } 10317 10318 10319 static int ap_send_frame_vht(struct sigma_dut *dut, struct sigma_conn *conn, 10320 struct sigma_cmd *cmd) 10321 { 10322 switch (get_driver_type(dut)) { 10323 case DRIVER_ATHEROS: 10324 return ath_ap_send_frame_vht(dut, conn, cmd); 10325 break; 10326 case DRIVER_OPENWRT: 10327 switch (get_openwrt_driver_type()) { 10328 case OPENWRT_DRIVER_ATHEROS: 10329 return ath_ap_send_frame_vht(dut, conn, cmd); 10330 default: 10331 send_resp(dut, conn, SIGMA_ERROR, 10332 "errorCode,Unsupported ap_send_frame with the current openwrt driver"); 10333 return 0; 10334 } 10335 default: 10336 send_resp(dut, conn, SIGMA_ERROR, 10337 "errorCode,Unsupported ap_send_frame with the current driver"); 10338 return 0; 10339 } 10340 } 10341 10342 10343 static int ap_send_frame_loc(struct sigma_dut *dut, struct sigma_conn *conn, 10344 struct sigma_cmd *cmd) 10345 { 10346 switch (get_driver_type(dut)) { 10347 case DRIVER_ATHEROS: 10348 return ath_ap_send_frame_loc(dut, conn, cmd); 10349 case DRIVER_OPENWRT: 10350 switch (get_openwrt_driver_type()) { 10351 case OPENWRT_DRIVER_ATHEROS: 10352 return ath_ap_send_frame_loc(dut, conn, cmd); 10353 default: 10354 send_resp(dut, conn, SIGMA_ERROR, 10355 "errorCode,Unsupported ap_send_frame_loc with the current openwrt driver"); 10356 return 0; 10357 } 10358 default: 10359 send_resp(dut, conn, SIGMA_ERROR, 10360 "errorCode,Unsupported ap_send_frame_loc with the current driver"); 10361 return 0; 10362 } 10363 } 10364 10365 10366 static int ap_send_frame_mbo(struct sigma_dut *dut, struct sigma_conn *conn, 10367 struct sigma_cmd *cmd) 10368 { 10369 switch (get_driver_type(dut)) { 10370 case DRIVER_ATHEROS: 10371 return ath_ap_send_frame_mbo(dut, conn, cmd); 10372 case DRIVER_OPENWRT: 10373 switch (get_openwrt_driver_type()) { 10374 case OPENWRT_DRIVER_ATHEROS: 10375 return ath_ap_send_frame_mbo(dut, conn, cmd); 10376 default: 10377 send_resp(dut, conn, SIGMA_ERROR, 10378 "errorCode,Unsupported ap_send_frame with the current openwrt driver"); 10379 return 0; 10380 } 10381 default: 10382 send_resp(dut, conn, SIGMA_ERROR, 10383 "errorCode,Unsupported ap_send_frame with the current driver"); 10384 return 0; 10385 } 10386 } 10387 10388 10389 static int ap_send_frame_60g(struct sigma_dut *dut, 10390 struct sigma_conn *conn, 10391 struct sigma_cmd *cmd) 10392 { 10393 switch (get_driver_type(dut)) { 10394 #ifdef __linux__ 10395 case DRIVER_WIL6210: 10396 return wil6210_send_frame_60g(dut, conn, cmd); 10397 #endif /* __linux__ */ 10398 default: 10399 send_resp(dut, conn, SIGMA_ERROR, 10400 "errorCode,Unsupported sta_set_frame(60G) with the current driver"); 10401 return 0; 10402 } 10403 } 10404 10405 10406 enum sigma_cmd_result cmd_ap_send_frame(struct sigma_dut *dut, 10407 struct sigma_conn *conn, 10408 struct sigma_cmd *cmd) 10409 { 10410 /* const char *name = get_param(cmd, "NAME"); */ 10411 /* const char *ifname = get_param(cmd, "INTERFACE"); */ 10412 const char *val; 10413 enum send_frame_type frame; 10414 enum send_frame_protection protected; 10415 char buf[100]; 10416 10417 val = get_param(cmd, "Program"); 10418 if (val) { 10419 if (strcasecmp(val, "HS2") == 0 || 10420 strcasecmp(val, "HS2-R2") == 0 || 10421 strcasecmp(val, "IOTLP") == 0) 10422 return ap_send_frame_hs2(dut, conn, cmd); 10423 if (strcasecmp(val, "VHT") == 0) 10424 return ap_send_frame_vht(dut, conn, cmd); 10425 if (strcasecmp(val, "LOC") == 0) 10426 return ap_send_frame_loc(dut, conn, cmd); 10427 if (strcasecmp(val, "MBO") == 0) 10428 return ap_send_frame_mbo(dut, conn, cmd); 10429 if (strcasecmp(val, "60GHz") == 0) 10430 return ap_send_frame_60g(dut, conn, cmd); 10431 } 10432 10433 val = get_param(cmd, "PMFFrameType"); 10434 if (val == NULL) 10435 val = get_param(cmd, "FrameName"); 10436 if (val == NULL) 10437 val = get_param(cmd, "Type"); 10438 if (val == NULL) 10439 return -1; 10440 if (strcasecmp(val, "disassoc") == 0) 10441 frame = DISASSOC; 10442 else if (strcasecmp(val, "deauth") == 0) 10443 frame = DEAUTH; 10444 else if (strcasecmp(val, "saquery") == 0) 10445 frame = SAQUERY; 10446 else { 10447 send_resp(dut, conn, SIGMA_ERROR, "errorCode,Unsupported " 10448 "PMFFrameType"); 10449 return 0; 10450 } 10451 10452 val = get_param(cmd, "PMFProtected"); 10453 if (val == NULL) 10454 val = get_param(cmd, "Protected"); 10455 if (val == NULL) 10456 return -1; 10457 if (strcasecmp(val, "Correct-key") == 0 || 10458 strcasecmp(val, "CorrectKey") == 0) 10459 protected = CORRECT_KEY; 10460 else if (strcasecmp(val, "IncorrectKey") == 0) 10461 protected = INCORRECT_KEY; 10462 else if (strcasecmp(val, "Unprotected") == 0) 10463 protected = UNPROTECTED; 10464 else { 10465 send_resp(dut, conn, SIGMA_ERROR, "errorCode,Unsupported " 10466 "PMFProtected"); 10467 return 0; 10468 } 10469 10470 val = get_param(cmd, "stationID"); 10471 if (val == NULL) 10472 return -1; 10473 10474 if (protected == INCORRECT_KEY || 10475 (protected == UNPROTECTED && frame == SAQUERY)) 10476 return ap_inject_frame(dut, conn, frame, protected, val); 10477 10478 switch (frame) { 10479 case DISASSOC: 10480 snprintf(buf, sizeof(buf), "disassoc %s test=%d", 10481 val, protected == CORRECT_KEY); 10482 break; 10483 case DEAUTH: 10484 snprintf(buf, sizeof(buf), "deauth %s test=%d", 10485 val, protected == CORRECT_KEY); 10486 break; 10487 case SAQUERY: 10488 snprintf(buf, sizeof(buf), "sa_query %s", val); 10489 break; 10490 } 10491 10492 if (run_hostapd_cli(dut, buf) != 0) 10493 return -2; 10494 10495 return 1; 10496 } 10497 10498 10499 static enum sigma_cmd_result cmd_ap_get_mac_address(struct sigma_dut *dut, 10500 struct sigma_conn *conn, 10501 struct sigma_cmd *cmd) 10502 { 10503 #if defined( __linux__) 10504 /* const char *name = get_param(cmd, "NAME"); */ 10505 /* const char *ifname = get_param(cmd, "INTERFACE"); */ 10506 char resp[100]; 10507 unsigned char addr[6]; 10508 char ifname[50]; 10509 struct ifreq ifr; 10510 int s, wlan_tag = 1; 10511 const char *val; 10512 10513 val = get_param(cmd, "WLAN_TAG"); 10514 if (val) { 10515 wlan_tag = atoi(val); 10516 if (wlan_tag < 1 || wlan_tag > 3) { 10517 /* 10518 * The only valid WLAN Tags as of now as per the latest 10519 * WFA scripts are 1, 2, and 3. 10520 */ 10521 send_resp(dut, conn, SIGMA_ERROR, 10522 "errorCode,Unsupported WLAN_TAG"); 10523 return 0; 10524 } 10525 } 10526 10527 get_if_name(dut, ifname, sizeof(ifname), wlan_tag); 10528 10529 s = socket(AF_INET, SOCK_DGRAM, 0); 10530 if (s < 0) 10531 return -1; 10532 memset(&ifr, 0, sizeof(ifr)); 10533 strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name)); 10534 if (ioctl(s, SIOCGIFHWADDR, &ifr) < 0) { 10535 perror("ioctl"); 10536 close(s); 10537 snprintf(resp, sizeof(resp), 10538 "errorCode,Could not find interface %s", ifname); 10539 send_resp(dut, conn, SIGMA_ERROR, resp); 10540 return 0; 10541 } 10542 close(s); 10543 memcpy(addr, ifr.ifr_hwaddr.sa_data, 6); 10544 10545 snprintf(resp, sizeof(resp), "mac,%02x:%02x:%02x:%02x:%02x:%02x", 10546 addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]); 10547 send_resp(dut, conn, SIGMA_COMPLETE, resp); 10548 return 0; 10549 #elif defined( __QNXNTO__) 10550 char resp[50]; 10551 unsigned char addr[6]; 10552 10553 if (!dut->main_ifname) { 10554 send_resp(dut, conn, SIGMA_ERROR, "ifname is null"); 10555 return 0; 10556 } 10557 10558 if (get_hwaddr(get_main_ifname(dut), addr) != 0) { 10559 send_resp(dut, conn, SIGMA_ERROR, 10560 "errorCode,Failed to get address"); 10561 return 0; 10562 } 10563 snprintf(resp, sizeof(resp), "mac,%02x:%02x:%02x:%02x:%02x:%02x", 10564 addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]); 10565 send_resp(dut, conn, SIGMA_COMPLETE, resp); 10566 return 0; 10567 #else /* __linux__ */ 10568 send_resp(dut, conn, SIGMA_ERROR, "errorCode,ap_get_mac_address not " 10569 "yet supported"); 10570 return 0; 10571 #endif /* __linux__ */ 10572 } 10573 10574 10575 int sta_cfon_get_mac_address(struct sigma_dut *dut, struct sigma_conn *conn, 10576 struct sigma_cmd *cmd) 10577 { 10578 return cmd_ap_get_mac_address(dut, conn, cmd); 10579 } 10580 10581 10582 static enum sigma_cmd_result cmd_ap_set_pmf(struct sigma_dut *dut, 10583 struct sigma_conn *conn, 10584 struct sigma_cmd *cmd) 10585 { 10586 /* 10587 * Ignore the command since the parameters are already handled through 10588 * ap_set_security. 10589 */ 10590 10591 return 1; 10592 } 10593 10594 10595 static enum sigma_cmd_result cmd_ap_set_hs2(struct sigma_dut *dut, 10596 struct sigma_conn *conn, 10597 struct sigma_cmd *cmd) 10598 { 10599 /* const char *name = get_param(cmd, "NAME"); */ 10600 /* const char *ifname = get_param(cmd, "INTERFACE"); */ 10601 const char *val, *dest; 10602 char *pos, buf[100]; 10603 int i, wlan_tag = 1, res; 10604 10605 sigma_dut_print(dut, DUT_MSG_INFO, "ap_set_hs2: Processing the " 10606 "following parameters"); 10607 for (i = 0; i < cmd->count; i++) { 10608 sigma_dut_print(dut, DUT_MSG_INFO, "%s %s", cmd->params[i], 10609 (cmd->values[i] ? cmd->values[i] : "NULL")); 10610 } 10611 10612 val = get_param(cmd, "ICMPv4_ECHO"); 10613 if (val && atoi(val)) { 10614 snprintf(buf, sizeof(buf), "ebtables -F"); 10615 if (system(buf) != 0) { 10616 sigma_dut_print(dut, DUT_MSG_ERROR, 10617 "Failed to set ebtables rules, RULE-12"); 10618 } 10619 return 1; 10620 } 10621 10622 val = get_param(cmd, "WLAN_TAG"); 10623 if (val) { 10624 wlan_tag = atoi(val); 10625 if (wlan_tag != 1 && wlan_tag != 2) { 10626 send_resp(dut, conn, SIGMA_INVALID, 10627 "errorCode,Invalid WLAN_TAG"); 10628 return 0; 10629 } 10630 } 10631 10632 if (wlan_tag == 2) { 10633 val = get_param(cmd, "PROXY_ARP"); 10634 if (val) 10635 dut->ap2_proxy_arp = atoi(val); 10636 10637 val = get_param(cmd, "OSU"); 10638 if (val) 10639 dut->ap2_osu = atoi(val); 10640 return 1; 10641 } 10642 10643 dest = get_param(cmd, "STA_MAC"); 10644 if (dest) { 10645 /* This is a special/ugly way of using this command. 10646 * If "Dest" MAC is included, assume that this command 10647 * is being issued after ap_config_commit for dynamically 10648 * setting the QoS Map Set. 10649 */ 10650 val = get_param(cmd, "QoS_MAP_SET"); 10651 if (val) { 10652 dut->ap_qos_map_set = atoi(val); 10653 sigma_dut_print(dut, DUT_MSG_INFO, "ap_qos_map_set %d", 10654 dut->ap_qos_map_set); 10655 } 10656 10657 if (dut->ap_qos_map_set == 1) 10658 run_hostapd_cli(dut, "set_qos_map_set " QOS_MAP_SET_1); 10659 else if (dut->ap_qos_map_set == 2) 10660 run_hostapd_cli(dut, "set_qos_map_set " QOS_MAP_SET_2); 10661 10662 snprintf(buf, sizeof(buf), "send_qos_map_conf %s", dest); 10663 if (run_hostapd_cli(dut, buf) != 0) 10664 return -1; 10665 } 10666 10667 val = get_param(cmd, "DGAF_DISABLE"); 10668 if (val) 10669 dut->ap_dgaf_disable = atoi(val); 10670 10671 dut->ap_interworking = 1; 10672 10673 val = get_param(cmd, "INTERWORKING"); 10674 if (val == NULL) 10675 val = get_param(cmd, "INTERNETWORKING"); 10676 if (val != NULL && atoi(val) == 0) { 10677 dut->ap_interworking = 0; 10678 dut->ap_hs2 = 0; 10679 return 1; 10680 } 10681 10682 val = get_param(cmd, "ACCS_NET_TYPE"); 10683 if (val) { 10684 if (strcasecmp(val, "Chargeable_Public_Network") == 0 || 10685 strcasecmp(val, "Chargable_Public_Network") == 0 || 10686 strcasecmp(val, "Chargable Public Network") == 0) 10687 dut->ap_access_net_type = 2; 10688 else 10689 dut->ap_access_net_type = atoi(val); 10690 } 10691 10692 val = get_param(cmd, "INTERNET"); 10693 if (val) 10694 dut->ap_internet = atoi(val); 10695 10696 val = get_param(cmd, "VENUE_GRP"); 10697 if (val) { 10698 if (strcasecmp(val, "Business") == 0) 10699 dut->ap_venue_group = 2; 10700 else 10701 dut->ap_venue_group = atoi(val); 10702 sigma_dut_print(dut, DUT_MSG_INFO, "ap_venue_name %d", 10703 dut->ap_venue_name); 10704 } 10705 10706 val = get_param(cmd, "VENUE_TYPE"); 10707 if (val) { 10708 if (strcasecmp(val, "R&D") == 0) 10709 dut->ap_venue_type = 8; 10710 else 10711 dut->ap_venue_type = atoi(val); 10712 sigma_dut_print(dut, DUT_MSG_INFO, "ap_venue_type %d", 10713 dut->ap_venue_type); 10714 } 10715 10716 val = get_param(cmd, "HESSID"); 10717 if (val) { 10718 if (strlen(val) >= sizeof(dut->ap_hessid)) { 10719 send_resp(dut, conn, SIGMA_ERROR, 10720 "errorCode,Invalid HESSID"); 10721 return 0; 10722 } 10723 snprintf(dut->ap_hessid, sizeof(dut->ap_hessid), "%s", val); 10724 sigma_dut_print(dut, DUT_MSG_INFO, "ap_hessid %s", 10725 dut->ap_hessid); 10726 } 10727 10728 val = get_param(cmd, "ROAMING_CONS"); 10729 if (val) { 10730 if (strlen(val) >= sizeof(dut->ap_roaming_cons)) { 10731 send_resp(dut, conn, SIGMA_ERROR, 10732 "errorCode,Invalid ROAMING_CONS"); 10733 return 0; 10734 } 10735 if (strcasecmp(val, "Disabled") == 0) { 10736 dut->ap_roaming_cons[0] = '\0'; 10737 } else { 10738 snprintf(dut->ap_roaming_cons, 10739 sizeof(dut->ap_roaming_cons), "%s", val); 10740 } 10741 sigma_dut_print(dut, DUT_MSG_INFO, "ap_roaming_cons %s", 10742 dut->ap_roaming_cons); 10743 } 10744 10745 val = get_param(cmd, "ANQP"); 10746 if (val) 10747 dut->ap_anqpserver_on = atoi(val); 10748 10749 val = get_param(cmd, "NAI_REALM_LIST"); 10750 if (val) { 10751 dut->ap_nai_realm_list = atoi(val); 10752 sigma_dut_print(dut, DUT_MSG_INFO, "ap_nai_realm_list %d", 10753 dut->ap_nai_realm_list); 10754 } 10755 10756 val = get_param(cmd, "3GPP_INFO"); 10757 if (val) { 10758 /* What kind of encoding format is used?! */ 10759 send_resp(dut, conn, SIGMA_ERROR, "errorCode,3GPP_INFO " 10760 "not yet supported (contents not fully defined)"); 10761 return 0; 10762 } 10763 10764 val = get_param(cmd, "DOMAIN_LIST"); 10765 if (val) { 10766 if (strlen(val) >= sizeof(dut->ap_domain_name_list)) { 10767 send_resp(dut, conn, SIGMA_ERROR, "errorCode,Too long " 10768 "DOMAIN_LIST"); 10769 return 0; 10770 } 10771 snprintf(dut->ap_domain_name_list, 10772 sizeof(dut->ap_domain_name_list), "%s", val); 10773 pos = dut->ap_domain_name_list; 10774 while (*pos) { 10775 if (*pos == ';') 10776 *pos = ','; 10777 pos++; 10778 } 10779 sigma_dut_print(dut, DUT_MSG_INFO, "ap_domain_name_list %s", 10780 dut->ap_domain_name_list); 10781 } 10782 10783 val = get_param(cmd, "OPER_NAME"); 10784 if (val) { 10785 dut->ap_oper_name = atoi(val); 10786 sigma_dut_print(dut, DUT_MSG_INFO, "ap_oper_name %d", 10787 dut->ap_oper_name); 10788 } 10789 10790 val = get_param(cmd, "VENUE_NAME"); 10791 if (val) { 10792 dut->ap_venue_name = atoi(val); 10793 sigma_dut_print(dut, DUT_MSG_INFO, "ap_venue_name %d", 10794 dut->ap_venue_name); 10795 } 10796 10797 val = get_param(cmd, "GAS_CB_DELAY"); 10798 if (val) { 10799 dut->ap_gas_cb_delay = atoi(val); 10800 sigma_dut_print(dut, DUT_MSG_INFO, "ap_gas_cb_delay %d", 10801 dut->ap_gas_cb_delay); 10802 } 10803 10804 val = get_param(cmd, "MIH"); 10805 if (val && atoi(val) > 0) { 10806 send_resp(dut, conn, SIGMA_ERROR, "errorCode,MIH not " 10807 "supported"); 10808 return 0; 10809 } 10810 10811 val = get_param(cmd, "L2_TRAFFIC_INSPECT"); 10812 if (val) { 10813 dut->ap_l2tif = atoi(val); 10814 sigma_dut_print(dut, DUT_MSG_INFO, "ap_l2tif %d", 10815 dut->ap_l2tif); 10816 } 10817 10818 val = get_param(cmd, "BCST_UNCST"); 10819 if (val) { 10820 send_resp(dut, conn, SIGMA_ERROR, 10821 "errorCode,BCST_UNCST not yet supported"); 10822 return 0; 10823 } 10824 10825 val = get_param(cmd, "PLMN_MCC"); 10826 if (val) { 10827 char mcc[100], *start, *end; 10828 int i = 0; 10829 if (strlen(val) >= sizeof(mcc)) { 10830 send_resp(dut, conn, SIGMA_ERROR, 10831 "errorCode,PLMN_MCC too long"); 10832 return 0; 10833 } 10834 strlcpy(mcc, val, sizeof(mcc)); 10835 start = mcc; 10836 while ((end = strchr(start, ';'))) { 10837 /* process all except the last */ 10838 *end = '\0'; 10839 if (strlen(start) != 3) { 10840 send_resp(dut, conn, SIGMA_ERROR, 10841 "errorCode,Invalid PLMN_MCC"); 10842 return 0; 10843 } 10844 res = snprintf(dut->ap_plmn_mcc[i], 10845 sizeof(dut->ap_plmn_mcc[i]), "%s", 10846 start); 10847 if (res < 0 || res >= sizeof(dut->ap_plmn_mcc[i])) 10848 return ERROR_SEND_STATUS; 10849 sigma_dut_print(dut, DUT_MSG_INFO, "ap_plmn_mcc %s", 10850 dut->ap_plmn_mcc[i]); 10851 i++; 10852 start = end + 1; 10853 *end = ';'; 10854 } 10855 if (strlen(start) != 3) { 10856 send_resp(dut, conn, SIGMA_ERROR, 10857 "errorCode,Invalid PLMN_MCC"); 10858 return 0; 10859 } 10860 /* process last or only one */ 10861 res = snprintf(dut->ap_plmn_mcc[i], 10862 sizeof(dut->ap_plmn_mcc[i]), "%s", start); 10863 if (res < 0 || res >= sizeof(dut->ap_plmn_mcc[i])) 10864 return ERROR_SEND_STATUS; 10865 sigma_dut_print(dut, DUT_MSG_INFO, "ap_plmn_mcc %s", 10866 dut->ap_plmn_mcc[i]); 10867 } 10868 10869 val = get_param(cmd, "PLMN_MNC"); 10870 if (val) { 10871 char mnc[100], *start, *end; 10872 int i = 0; 10873 if (strlen(val) >= sizeof(mnc)) { 10874 send_resp(dut, conn, SIGMA_ERROR, 10875 "errorCode,PLMN_MNC too long"); 10876 return 0; 10877 } 10878 strlcpy(mnc, val, sizeof(mnc)); 10879 start = mnc; 10880 while ((end = strchr(start, ';'))) { 10881 *end = '\0'; 10882 if (strlen(start) != 2 && strlen(start) != 3) { 10883 send_resp(dut, conn, SIGMA_ERROR, 10884 "errorCode,Invalid PLMN_MNC"); 10885 return 0; 10886 } 10887 res = snprintf(dut->ap_plmn_mnc[i], 10888 sizeof(dut->ap_plmn_mnc[i]), "%s", 10889 start); 10890 if (res < 0 || res >= sizeof(dut->ap_plmn_mnc[i])) 10891 return ERROR_SEND_STATUS; 10892 sigma_dut_print(dut, DUT_MSG_INFO, "ap_plmn_mnc %s", 10893 dut->ap_plmn_mnc[i]); 10894 i++; 10895 start = end + 1; 10896 *end = ';'; 10897 } 10898 if (strlen(start) != 2 && strlen(start) != 3) { 10899 send_resp(dut, conn, SIGMA_ERROR, 10900 "errorCode,Invalid PLMN_MNC"); 10901 return 0; 10902 } 10903 res = snprintf(dut->ap_plmn_mnc[i], 10904 sizeof(dut->ap_plmn_mnc[i]), "%s", start); 10905 if (res < 0 || res >= sizeof(dut->ap_plmn_mnc[i])) 10906 return ERROR_SEND_STATUS; 10907 sigma_dut_print(dut, DUT_MSG_INFO, "ap_plmn_mnc %s", 10908 dut->ap_plmn_mnc[i]); 10909 } 10910 10911 val = get_param(cmd, "PROXY_ARP"); 10912 if (val) { 10913 dut->ap_proxy_arp = atoi(val); 10914 sigma_dut_print(dut, DUT_MSG_INFO, "ap_proxy_arp %d", 10915 dut->ap_proxy_arp); 10916 } 10917 10918 val = get_param(cmd, "WAN_METRICS"); 10919 if (val) { 10920 dut->ap_wan_metrics = atoi(val); 10921 sigma_dut_print(dut, DUT_MSG_INFO, "ap_wan_metrics %d", 10922 dut->ap_wan_metrics); 10923 } 10924 10925 val = get_param(cmd, "CONN_CAP"); 10926 if (val) { 10927 dut->ap_conn_capab = atoi(val); 10928 sigma_dut_print(dut, DUT_MSG_INFO, "ap_conn_capab %d", 10929 dut->ap_conn_capab); 10930 } 10931 10932 val = get_param(cmd, "IP_ADD_TYPE_AVAIL"); 10933 if (val) { 10934 dut->ap_ip_addr_type_avail = atoi(val); 10935 sigma_dut_print(dut, DUT_MSG_INFO, "ap_ip_addr_type_avail %d", 10936 dut->ap_ip_addr_type_avail); 10937 } 10938 10939 val = get_param(cmd, "NET_AUTH_TYPE"); 10940 if (val) { 10941 dut->ap_net_auth_type = atoi(val); 10942 sigma_dut_print(dut, DUT_MSG_INFO, "ap_net_auth_type %d", 10943 dut->ap_net_auth_type); 10944 } 10945 10946 val = get_param(cmd, "OP_CLASS"); 10947 if (val == NULL) 10948 val = get_param(cmd, "OPER_CLASS"); 10949 if (val) { 10950 dut->ap_oper_class = atoi(val); 10951 sigma_dut_print(dut, DUT_MSG_INFO, "ap_oper_class %d", 10952 dut->ap_oper_class); 10953 } 10954 10955 val = get_param(cmd, "OSU_PROVIDER_LIST"); 10956 if (val) { 10957 dut->ap_osu_provider_list = atoi(val); 10958 sigma_dut_print(dut, DUT_MSG_INFO, "ap_osu_provider_list %d", 10959 dut->ap_osu_provider_list); 10960 } 10961 10962 val = get_param(cmd, "OSU_PROVIDER_NAI_LIST"); 10963 if (val) { 10964 dut->ap_osu_provider_nai_list = atoi(val); 10965 sigma_dut_print(dut, DUT_MSG_INFO, 10966 "ap_osu_provider_nai_list %d", 10967 dut->ap_osu_provider_nai_list); 10968 } 10969 10970 val = get_param(cmd, "OSU_SERVER_URI"); 10971 if (val) { 10972 i = 0; 10973 do { 10974 int len; 10975 const char *uri = val; 10976 val = strchr(val, ' '); 10977 len = val ? (val++ - uri) : (int) strlen(uri); 10978 if (len > 0 && len < 256) { 10979 memcpy(dut->ap_osu_server_uri[i], uri, len); 10980 dut->ap_osu_server_uri[i][len] = '\0'; 10981 sigma_dut_print(dut, DUT_MSG_INFO, 10982 "ap_osu_server_uri[%d] %s", i, 10983 dut->ap_osu_server_uri[i]); 10984 } 10985 } while (val && ++i < 10); 10986 } 10987 10988 val = get_param(cmd, "OSU_METHOD"); 10989 if (val) { 10990 i = 0; 10991 do { 10992 int len; 10993 const char *method = val; 10994 val = strchr(val, ' '); 10995 len = val ? (val++ - method) : (int) strlen(method); 10996 if (len > 0) { 10997 if (strncasecmp(method, "SOAP", len) == 0) 10998 dut->ap_osu_method[i] = 1; 10999 else if (strncasecmp(method, "OMADM", len) == 0) 11000 dut->ap_osu_method[i] = 0; 11001 else 11002 return -2; 11003 } 11004 } while (val && ++i < 10); 11005 } 11006 11007 val = get_param(cmd, "OSU_SSID"); 11008 if (val) { 11009 if (strlen(val) > 0 && strlen(val) <= 32) { 11010 strlcpy(dut->ap_osu_ssid, val, 11011 sizeof(dut->ap_osu_ssid)); 11012 sigma_dut_print(dut, DUT_MSG_INFO, 11013 "ap_osu_ssid %s", 11014 dut->ap_osu_ssid); 11015 } 11016 } 11017 11018 val = get_param(cmd, "OSU_ICON_TAG"); 11019 if (val) 11020 dut->ap_osu_icon_tag = atoi(val); 11021 11022 val = get_param(cmd, "QoS_MAP_SET"); 11023 if (val) { 11024 dut->ap_qos_map_set = atoi(val); 11025 sigma_dut_print(dut, DUT_MSG_INFO, "ap_qos_map_set %d", 11026 dut->ap_qos_map_set); 11027 } 11028 11029 val = get_param(cmd, "BSS_LOAD"); 11030 if (val) { 11031 dut->ap_bss_load = atoi(val); 11032 sigma_dut_print(dut, DUT_MSG_INFO, "ap_bss_load %d", 11033 dut->ap_bss_load); 11034 } 11035 11036 val = get_param(cmd, "Venue_URL"); 11037 if (val) 11038 dut->ap_venue_url = atoi(val); 11039 11040 val = get_param(cmd, "Advice_of_Charge"); 11041 if (val) 11042 dut->ap_advice_of_charge = atoi(val); 11043 11044 val = get_param(cmd, "Operator_Icon_Metadata"); 11045 if (val) 11046 dut->ap_oper_icon_metadata = atoi(val); 11047 11048 val = get_param(cmd, "TnC_File_Name"); 11049 if (val) 11050 dut->ap_tnc_file_name = atoi(val); 11051 11052 val = get_param(cmd, "TnC_File_Time_Stamp"); 11053 if (val) 11054 dut->ap_tnc_time_stamp = strtol(val, NULL, 10); 11055 11056 return 1; 11057 } 11058 11059 11060 void nfc_status(struct sigma_dut *dut, const char *state, const char *oper) 11061 { 11062 char buf[100]; 11063 11064 if (!file_exists("nfc-status")) 11065 return; 11066 11067 snprintf(buf, sizeof(buf), "./nfc-status %s %s", state, oper); 11068 run_system(dut, buf); 11069 } 11070 11071 11072 static int run_nfc_command(struct sigma_dut *dut, const char *cmd, 11073 const char *info) 11074 { 11075 int res; 11076 11077 printf("\n\n\n=====[ NFC operation ]=========================\n\n"); 11078 printf("%s\n\n", info); 11079 11080 nfc_status(dut, "START", info); 11081 res = run_system(dut, cmd); 11082 nfc_status(dut, res ? "FAIL" : "SUCCESS", info); 11083 if (res) { 11084 sigma_dut_print(dut, DUT_MSG_INFO, "Failed to run '%s': %d", 11085 cmd, res); 11086 return res; 11087 } 11088 11089 return 0; 11090 } 11091 11092 11093 static int ap_nfc_write_config_token(struct sigma_dut *dut, 11094 struct sigma_conn *conn, 11095 struct sigma_cmd *cmd) 11096 { 11097 int res; 11098 char buf[300]; 11099 11100 run_system(dut, "killall wps-ap-nfc.py"); 11101 unlink("nfc-success"); 11102 snprintf(buf, sizeof(buf), 11103 "./wps-ap-nfc.py --no-wait %s%s --success nfc-success write-config", 11104 dut->summary_log ? "--summary " : "", 11105 dut->summary_log ? dut->summary_log : ""); 11106 res = run_nfc_command(dut, buf, 11107 "Touch NFC Tag to write WPS configuration token"); 11108 if (res || !file_exists("nfc-success")) { 11109 send_resp(dut, conn, SIGMA_ERROR, 11110 "ErrorCode,Failed to write tag"); 11111 return 0; 11112 } 11113 11114 return 1; 11115 } 11116 11117 11118 static int ap_nfc_wps_read_passwd(struct sigma_dut *dut, 11119 struct sigma_conn *conn, 11120 struct sigma_cmd *cmd) 11121 { 11122 int res; 11123 char buf[300]; 11124 11125 run_system(dut, "killall wps-ap-nfc.py"); 11126 11127 unlink("nfc-success"); 11128 snprintf(buf, sizeof(buf), 11129 "./wps-ap-nfc.py -1 --no-wait %s%s --success nfc-success", 11130 dut->summary_log ? "--summary " : "", 11131 dut->summary_log ? dut->summary_log : ""); 11132 res = run_nfc_command(dut, buf, "Touch NFC Tag to read it"); 11133 if (res || !file_exists("nfc-success")) { 11134 send_resp(dut, conn, SIGMA_ERROR, 11135 "ErrorCode,Failed to read tag"); 11136 return 0; 11137 } 11138 11139 return 1; 11140 } 11141 11142 11143 static int ap_nfc_write_password_token(struct sigma_dut *dut, 11144 struct sigma_conn *conn, 11145 struct sigma_cmd *cmd) 11146 { 11147 int res; 11148 char buf[300]; 11149 11150 run_system(dut, "killall wps-ap-nfc.py"); 11151 unlink("nfc-success"); 11152 snprintf(buf, sizeof(buf), 11153 "./wps-ap-nfc.py --no-wait %s%s --success nfc-success write-password", 11154 dut->summary_log ? "--summary " : "", 11155 dut->summary_log ? dut->summary_log : ""); 11156 res = run_nfc_command(dut, buf, 11157 "Touch NFC Tag to write WPS password token"); 11158 if (res || !file_exists("nfc-success")) { 11159 send_resp(dut, conn, SIGMA_ERROR, 11160 "ErrorCode,Failed to write tag"); 11161 return 0; 11162 } 11163 11164 if (run_hostapd_cli(dut, "wps_nfc_token enable") != 0) { 11165 send_resp(dut, conn, SIGMA_ERROR, 11166 "ErrorCode,Failed to enable NFC password token"); 11167 return 0; 11168 } 11169 11170 return 1; 11171 } 11172 11173 11174 static int ap_nfc_wps_connection_handover(struct sigma_dut *dut, 11175 struct sigma_conn *conn, 11176 struct sigma_cmd *cmd) 11177 { 11178 int res; 11179 char buf[300]; 11180 11181 run_system(dut, "killall wps-ap-nfc.py"); 11182 unlink("nfc-success"); 11183 snprintf(buf, sizeof(buf), 11184 "./wps-ap-nfc.py -1 --no-wait %s%s --success nfc-success", 11185 dut->summary_log ? "--summary " : "", 11186 dut->summary_log ? dut->summary_log : ""); 11187 res = run_nfc_command(dut, buf, 11188 "Touch NFC Device to respond to WPS connection handover"); 11189 if (res) { 11190 send_resp(dut, conn, SIGMA_ERROR, 11191 "ErrorCode,Failed to enable NFC for connection " 11192 "handover"); 11193 return 0; 11194 } 11195 if (!file_exists("nfc-success")) { 11196 send_resp(dut, conn, SIGMA_ERROR, 11197 "ErrorCode,Failed to complete NFC connection handover"); 11198 return 0; 11199 } 11200 11201 return 1; 11202 } 11203 11204 11205 static enum sigma_cmd_result cmd_ap_nfc_action(struct sigma_dut *dut, 11206 struct sigma_conn *conn, 11207 struct sigma_cmd *cmd) 11208 { 11209 /* const char *name = get_param(cmd, "Name"); */ 11210 /* const char *intf = get_param(cmd, "Interface"); */ 11211 const char *oper = get_param(cmd, "Operation"); 11212 11213 if (oper == NULL) 11214 return -1; 11215 11216 if (strcasecmp(oper, "WRITE_CONFIG") == 0) 11217 return ap_nfc_write_config_token(dut, conn, cmd); 11218 if (strcasecmp(oper, "WRITE_PASSWD") == 0) 11219 return ap_nfc_write_password_token(dut, conn, cmd); 11220 if (strcasecmp(oper, "WPS_READ_PASSWD") == 0) 11221 return ap_nfc_wps_read_passwd(dut, conn, cmd); 11222 if (strcasecmp(oper, "WPS_CONN_HNDOVR") == 0) 11223 return ap_nfc_wps_connection_handover(dut, conn, cmd); 11224 11225 send_resp(dut, conn, SIGMA_ERROR, "ErrorCode,Unsupported operation"); 11226 return 0; 11227 } 11228 11229 11230 static enum sigma_cmd_result cmd_ap_wps_read_pin(struct sigma_dut *dut, 11231 struct sigma_conn *conn, 11232 struct sigma_cmd *cmd) 11233 { 11234 char *pin = "12345670"; /* TODO: use random PIN */ 11235 char resp[100]; 11236 11237 snprintf(resp, sizeof(resp), "PIN,%s", pin); 11238 send_resp(dut, conn, SIGMA_COMPLETE, resp); 11239 11240 return 0; 11241 } 11242 11243 11244 static enum sigma_cmd_result cmd_ap_wps_enter_pin(struct sigma_dut *dut, 11245 struct sigma_conn *conn, 11246 struct sigma_cmd *cmd) 11247 { 11248 const char *pin = get_param(cmd, "PIN"); 11249 char wps_pin[11]; 11250 11251 if (!pin) 11252 return -1; 11253 11254 sigma_dut_print(dut, DUT_MSG_DEBUG, 11255 "Authorize a client to join with WPS PIN %s", pin); 11256 11257 strlcpy(wps_pin, pin, sizeof(wps_pin)); 11258 /* we need to tolerate extra '-' characters entered */ 11259 str_remove_chars(wps_pin, '-'); 11260 strlcpy(dut->wps_pin, wps_pin, sizeof(dut->wps_pin)); 11261 dut->wps_method = WFA_CS_WPS_PIN_KEYPAD; 11262 11263 return 1; 11264 } 11265 11266 11267 static enum sigma_cmd_result cmd_ap_wps_set_pbc(struct sigma_dut *dut, 11268 struct sigma_conn *conn, 11269 struct sigma_cmd *cmd) 11270 { 11271 sigma_dut_print(dut, DUT_MSG_DEBUG, 11272 "Selecting the push button configuration method"); 11273 11274 dut->wps_method = WFA_CS_WPS_PBC; 11275 11276 return 1; 11277 } 11278 11279 11280 int ap_wps_registration(struct sigma_dut *dut, struct sigma_conn *conn, 11281 struct sigma_cmd *cmd) 11282 { 11283 char buf[100], resp[256]; 11284 const char *intf = get_param(cmd, "interface"); 11285 const char *config_method = get_param(cmd, "WPSConfigMethod"); 11286 11287 if (config_method && strcasecmp(config_method, "PBC") == 0) 11288 dut->wps_method = WFA_CS_WPS_PBC; 11289 11290 if (!intf) 11291 intf = get_main_ifname(dut); 11292 11293 if (dut->wps_method == WFA_CS_WPS_NOT_READY) { 11294 send_resp(dut, conn, SIGMA_ERROR, 11295 "ErrorCode,WPS parameters not yet set"); 11296 return STATUS_SENT; 11297 } 11298 11299 if (dut->wps_method == WFA_CS_WPS_PBC) 11300 snprintf(buf, sizeof(buf), "WPS_PBC"); 11301 else /* WFA_CS_WPS_PIN_KEYPAD */ 11302 snprintf(buf, sizeof(buf), "WPS_PIN any %s", dut->wps_pin); 11303 11304 /* Run WPS command */ 11305 if (hapd_command(intf, buf) < 0) { 11306 /* command fails immediately if overlapped session detected */ 11307 snprintf(resp, sizeof(resp), "WpsState,OverlapSession"); 11308 send_resp(dut, conn, SIGMA_COMPLETE, resp); 11309 return STATUS_SENT; 11310 } 11311 11312 /* In AP mode return immediately and do not wait for WPS registration */ 11313 return SUCCESS_SEND_STATUS; 11314 } 11315 11316 11317 static enum sigma_cmd_result cmd_ap_get_parameter(struct sigma_dut *dut, 11318 struct sigma_conn *conn, 11319 struct sigma_cmd *cmd) 11320 { 11321 char value[256], resp[512]; 11322 const char *param = get_param(cmd, "parameter"); 11323 const char *ifname = get_param(cmd, "Interface"); 11324 const char *var; 11325 11326 if (!ifname) 11327 ifname = get_main_ifname(dut); 11328 11329 if (!param) { 11330 send_resp(dut, conn, SIGMA_ERROR, 11331 "ErrorCode,Parameter not specified"); 11332 return 0; 11333 } 11334 11335 if (strcasecmp(param, "SSID") == 0) { 11336 if (get_hapd_config(ifname, "ssid", value, sizeof(value))) { 11337 sigma_dut_print(dut, DUT_MSG_ERROR, 11338 "Failed to get SSID"); 11339 return -2; 11340 } 11341 snprintf(resp, sizeof(resp), "SSID,%s", value); 11342 } else if (strcasecmp(param, "PSK") == 0) { 11343 if (get_hapd_config(ifname, "passphrase", value, 11344 sizeof(value))) { 11345 sigma_dut_print(dut, DUT_MSG_ERROR, 11346 "Failed to get PSK"); 11347 return -2; 11348 } 11349 snprintf(resp, sizeof(resp), "PSK,%s", value); 11350 } else if (strcasecmp(param, "PMK") == 0) { 11351 var = get_param(cmd, "STA_MAC_Address"); 11352 if (!var) 11353 return INVALID_SEND_STATUS; 11354 snprintf(resp, sizeof(resp), "GET_PMK %s", var); 11355 if (hapd_command_resp(ifname, resp, &resp[4], 11356 sizeof(resp) - 4) < 0) { 11357 send_resp(dut, conn, SIGMA_ERROR, 11358 "ErrorCode,GET_PMK failed"); 11359 return STATUS_SENT_ERROR; 11360 } 11361 memcpy(resp, "PMK,", 4); 11362 } else { 11363 send_resp(dut, conn, SIGMA_ERROR, 11364 "ErrorCode,Unsupported parameter"); 11365 return 0; 11366 } 11367 11368 send_resp(dut, conn, SIGMA_COMPLETE, resp); 11369 return 0; 11370 } 11371 11372 11373 static int ath_vht_op_mode_notif(struct sigma_dut *dut, const char *ifname, 11374 const char *val) 11375 { 11376 char *token, *result; 11377 int nss = 0, chwidth = 0; 11378 char *saveptr; 11379 11380 /* 11381 * The following commands should be invoked to generate 11382 * VHT op mode notification 11383 */ 11384 11385 /* Extract the NSS info */ 11386 token = strdup(val); 11387 if (!token) 11388 return -1; 11389 result = strtok_r(token, ";", &saveptr); 11390 if (result) { 11391 int count = atoi(result); 11392 11393 /* We do not support NSS > 3 */ 11394 if (count < 0 || count > 3) { 11395 free(token); 11396 return -1; 11397 } 11398 11399 /* Convert nss to chainmask */ 11400 while (count--) 11401 nss = (nss << 1) | 1; 11402 11403 run_iwpriv(dut, ifname, "rxchainmask %d", nss); 11404 } 11405 11406 /* Extract the Channel width info */ 11407 result = strtok_r(NULL, ";", &saveptr); 11408 if (result) { 11409 switch (atoi(result)) { 11410 case 20: 11411 chwidth = 0; 11412 break; 11413 case 40: 11414 chwidth = 1; 11415 break; 11416 case 80: 11417 chwidth = 2; 11418 break; 11419 case 160: 11420 chwidth = 3; 11421 break; 11422 default: 11423 chwidth = 2; 11424 break; 11425 } 11426 run_iwpriv(dut, ifname, "chwidth %d", chwidth); 11427 } 11428 11429 /* Send the opmode notification */ 11430 run_iwpriv(dut, ifname, "opmode_notify 1"); 11431 free(token); 11432 11433 return 0; 11434 } 11435 11436 11437 static int ath_vht_nss_mcs(struct sigma_dut *dut, const char *ifname, 11438 const char *val) 11439 { 11440 /* String (nss_operating_mode; mcs_operating_mode) */ 11441 int nss, mcs; 11442 char *token, *result; 11443 char *saveptr; 11444 11445 token = strdup(val); 11446 if (!token) 11447 return -1; 11448 result = strtok_r(token, ";", &saveptr); 11449 if (!result) { 11450 sigma_dut_print(dut, DUT_MSG_ERROR, 11451 "VHT NSS not specified"); 11452 goto end; 11453 } 11454 if (strcasecmp(result, "def") != 0) { 11455 nss = atoi(result); 11456 11457 if (nss == 4) 11458 ath_disable_txbf(dut, ifname); 11459 11460 run_iwpriv(dut, ifname, "nss %d", nss); 11461 } else { 11462 if (dut->device_type == AP_testbed && dut->ap_sgi80 == 1) 11463 run_iwpriv(dut, ifname, "nss 1"); 11464 if (dut->device_type == AP_testbed && 11465 dut->program == PROGRAM_HE) { 11466 nss = dut->ap_tx_streams; 11467 run_iwpriv(dut, ifname, "nss %d", nss); 11468 } 11469 } 11470 11471 result = strtok_r(NULL, ";", &saveptr); 11472 if (!result) { 11473 sigma_dut_print(dut, DUT_MSG_ERROR, 11474 "VHT MCS not specified"); 11475 goto end; 11476 } 11477 if (strcasecmp(result, "def") == 0) { 11478 if (dut->device_type == AP_testbed && dut->ap_sgi80 == 1) 11479 run_iwpriv(dut, ifname, "vhtmcs 7"); 11480 else 11481 run_iwpriv(dut, ifname, "set11NRates 0"); 11482 if (dut->device_type == AP_testbed && 11483 dut->program == PROGRAM_HE) 11484 run_iwpriv(dut, ifname, "he_mcs 7"); 11485 } else { 11486 mcs = atoi(result); 11487 if (dut->program == PROGRAM_HE) 11488 run_iwpriv(dut, ifname, "he_mcs %d", mcs); 11489 else 11490 run_iwpriv(dut, ifname, "vhtmcs %d", mcs); 11491 } 11492 11493 end: 11494 free(token); 11495 return 0; 11496 } 11497 11498 11499 static int ath_vht_chnum_band(struct sigma_dut *dut, const char *ifname, 11500 const char *val) 11501 { 11502 char *token, *result; 11503 int channel = 36; 11504 int chwidth = 80; 11505 char *saveptr; 11506 11507 /* Extract the channel info */ 11508 token = strdup(val); 11509 if (!token) 11510 return -1; 11511 result = strtok_r(token, ";", &saveptr); 11512 if (result) 11513 channel = atoi(result); 11514 11515 /* Extract the channel width info */ 11516 result = strtok_r(NULL, ";", &saveptr); 11517 if (result) 11518 chwidth = atoi(result); 11519 11520 /* Issue the channel switch command */ 11521 run_iwpriv(dut, ifname, "doth_ch_chwidth %d 10 %d", channel, chwidth); 11522 11523 free(token); 11524 return 0; 11525 } 11526 11527 11528 static int ath_ndpa_stainfo_mac(struct sigma_dut *dut, const char *ifname, 11529 const char *val) 11530 { 11531 char buf[80]; 11532 unsigned char mac_addr[6]; 11533 11534 if (parse_mac_address(dut, val, mac_addr) < 0) 11535 return -1; 11536 11537 snprintf(buf, sizeof(buf), 11538 "wifitool %s beeliner_fw_test 92 0x%02x%02x%02x%02x", 11539 ifname, mac_addr[0], mac_addr[1], mac_addr[2], mac_addr[3]); 11540 run_system(dut, buf); 11541 11542 snprintf(buf, sizeof(buf), "wifitool %s beeliner_fw_test 93 0x%02x%02x", 11543 ifname, mac_addr[4], mac_addr[5]); 11544 run_system(dut, buf); 11545 11546 snprintf(buf, sizeof(buf), "wifitool %s beeliner_fw_test 94 1", ifname); 11547 run_system(dut, buf); 11548 11549 return 0; 11550 } 11551 11552 11553 void novap_reset(struct sigma_dut *dut, const char *ifname, int reset) 11554 { 11555 run_iwpriv(dut, ifname, "novap_reset %d", reset); 11556 } 11557 11558 11559 static struct mbo_pref_ap * mbo_find_nebor_ap_entry(struct sigma_dut *dut, 11560 const uint8_t *mac_addr) 11561 { 11562 int i; 11563 11564 for (i = 0; i < dut->mbo_pref_ap_cnt; i++) { 11565 if (memcmp(mac_addr, dut->mbo_pref_aps[i].mac_addr, 11566 ETH_ALEN) == 0) 11567 return &dut->mbo_pref_aps[i]; 11568 } 11569 return NULL; 11570 } 11571 11572 11573 static void mbo_add_nebor_entry(struct sigma_dut *dut, const uint8_t *mac_addr, 11574 int ap_ne_class, int ap_ne_op_ch, 11575 int ap_ne_pref) 11576 { 11577 struct mbo_pref_ap *entry; 11578 uint8_t self_mac[ETH_ALEN]; 11579 char ifname[50]; 11580 11581 get_if_name(dut, ifname, sizeof(ifname), 1); 11582 get_hwaddr(ifname, self_mac); 11583 11584 if (memcmp(mac_addr, self_mac, ETH_ALEN) == 0) 11585 entry = &dut->mbo_self_ap_tuple; 11586 else 11587 entry = mbo_find_nebor_ap_entry(dut, mac_addr); 11588 11589 if (!entry) { 11590 if (dut->mbo_pref_ap_cnt >= MBO_MAX_PREF_BSSIDS) { 11591 sigma_dut_print(dut, DUT_MSG_ERROR, 11592 "Nebor AP List is full. Not adding"); 11593 return; 11594 } 11595 entry = &dut->mbo_pref_aps[dut->mbo_pref_ap_cnt]; 11596 dut->mbo_pref_ap_cnt++; 11597 memcpy(entry->mac_addr, mac_addr, ETH_ALEN); 11598 entry->ap_ne_class = -1; 11599 entry->ap_ne_op_ch = -1; 11600 entry->ap_ne_pref = -1; 11601 } 11602 if (ap_ne_class != -1) 11603 entry->ap_ne_class = ap_ne_class; 11604 if (ap_ne_op_ch != -1) 11605 entry->ap_ne_op_ch = ap_ne_op_ch; 11606 if (ap_ne_pref != -1) 11607 entry->ap_ne_pref = ap_ne_pref; 11608 } 11609 11610 11611 static int ath_set_nebor_bssid(struct sigma_dut *dut, const char *ifname, 11612 struct sigma_cmd *cmd) 11613 { 11614 unsigned char mac_addr[ETH_ALEN]; 11615 const char *val; 11616 /* 11617 * -1 is invalid value for the following 11618 * to differentiate between unset and set values 11619 * -1 => implies not set by CAPI 11620 */ 11621 int ap_ne_class = -1, ap_ne_op_ch = -1, ap_ne_pref = -1; 11622 int list_offset = dut->mbo_pref_ap_cnt; 11623 11624 if (list_offset >= MBO_MAX_PREF_BSSIDS) { 11625 sigma_dut_print(dut, DUT_MSG_ERROR, 11626 "AP Pref Entry list is full"); 11627 return -1; 11628 } 11629 11630 val = get_param(cmd, "Nebor_Op_Class"); 11631 if (val) 11632 ap_ne_class = atoi(val); 11633 11634 val = get_param(cmd, "Nebor_Op_Ch"); 11635 if (val) 11636 ap_ne_op_ch = atoi(val); 11637 11638 val = get_param(cmd, "Nebor_Pref"); 11639 if (val) 11640 ap_ne_pref = atoi(val); 11641 11642 val = get_param(cmd, "Nebor_BSSID"); 11643 if (!val || parse_mac_address(dut, val, mac_addr) < 0) 11644 return -1; 11645 11646 mbo_add_nebor_entry(dut, mac_addr, ap_ne_class, ap_ne_op_ch, 11647 ap_ne_pref); 11648 apply_mbo_pref_ap_list(dut); 11649 return 0; 11650 } 11651 11652 11653 static enum sigma_cmd_result he_ltf(struct sigma_dut *dut, 11654 struct sigma_conn *conn, 11655 const char *ifname, const char *val) 11656 { 11657 const char *var; 11658 11659 if (dut->ap_he_ulofdma == VALUE_ENABLED) 11660 var = "he_ul_ltf"; 11661 else 11662 var = "he_ltf"; 11663 11664 if (strcmp(val, "6.4") == 0) { 11665 run_iwpriv(dut, ifname, "%s 2", var); 11666 } else if (strcmp(val, "12.8") == 0) { 11667 run_iwpriv(dut, ifname, "%s 3", var); 11668 } else if (strcmp(val, "3.2") == 0) { 11669 run_iwpriv(dut, ifname, "%s 1", var); 11670 } else { 11671 send_resp(dut, conn, SIGMA_ERROR, "errorCode,Unsupported LTF"); 11672 return STATUS_SENT_ERROR; 11673 } 11674 11675 return SUCCESS_SEND_STATUS; 11676 } 11677 11678 11679 static enum sigma_cmd_result he_shortgi(struct sigma_dut *dut, 11680 struct sigma_conn *conn, 11681 const char *ifname, 11682 const char *val) 11683 { 11684 const char *var; 11685 11686 if (dut->ap_he_ulofdma == VALUE_ENABLED) 11687 var = "he_ul_shortgi"; 11688 else 11689 var = "shortgi"; 11690 11691 if (strcmp(val, "0.8") == 0) { 11692 run_iwpriv(dut, ifname, "%s 0", var); 11693 } else if (strcmp(val, "1.6") == 0) { 11694 run_iwpriv(dut, ifname, "%s 2", var); 11695 } else if (strcmp(val, "3.2") == 0) { 11696 run_iwpriv(dut, ifname, "%s 3", var); 11697 } else { 11698 send_resp(dut, conn, SIGMA_ERROR, 11699 "errorCode,Unsupported shortGI"); 11700 return STATUS_SENT_ERROR; 11701 } 11702 11703 return SUCCESS_SEND_STATUS; 11704 } 11705 11706 11707 static enum sigma_cmd_result he_ar_gi_ltf_mask(struct sigma_dut *dut, 11708 struct sigma_conn *conn, 11709 const char *ifname, 11710 const char *val) 11711 { 11712 11713 uint32_t he_ar_gi_ltf; 11714 uint16_t he_ar_gi, he_ar_ltf; 11715 11716 if (strcmp(val, "0.4") == 0) { 11717 he_ar_gi = 0x01; 11718 } else if (strcmp(val, "0.8") == 0) { 11719 he_ar_gi = 0x02; 11720 } else if (strcmp(val, "1.6") == 0) { 11721 he_ar_gi = 0x04; 11722 } else if (strcmp(val, "3.2") == 0) { 11723 he_ar_gi = 0x08; 11724 } else { 11725 send_resp(dut, conn, SIGMA_ERROR, 11726 "errorCode,Unsupported shortGI"); 11727 return STATUS_SENT_ERROR; 11728 } 11729 11730 if (dut->ar_ltf && strcmp(dut->ar_ltf, "6.4") == 0) { 11731 he_ar_ltf = 0x02; 11732 } else if (dut->ar_ltf && strcmp(dut->ar_ltf, "12.8") == 0) { 11733 he_ar_ltf = 0x04; 11734 } else if (dut->ar_ltf && strcmp(dut->ar_ltf, "3.2") == 0) { 11735 he_ar_ltf = 0x01; 11736 } else { 11737 send_resp(dut, conn, SIGMA_ERROR, 11738 "errorCode,Unsupported LTF"); 11739 return STATUS_SENT_ERROR; 11740 } 11741 11742 he_ar_gi_ltf = (he_ar_gi << 8) | he_ar_ltf; 11743 run_iwpriv(dut, ifname, "he_ar_gi_ltf %lu", he_ar_gi_ltf); 11744 11745 return SUCCESS_SEND_STATUS; 11746 } 11747 11748 11749 static enum sigma_cmd_result he_rualloctones(struct sigma_dut *dut, 11750 struct sigma_conn *conn, 11751 const char *ifname, 11752 const char *val) 11753 { 11754 char *token, *result; 11755 int value; 11756 char *saveptr; 11757 int rualloc_type; 11758 enum sigma_cmd_result ret = SUCCESS_SEND_STATUS; 11759 11760 token = strdup(val); 11761 if (!token) 11762 return -1; 11763 result = strtok_r(token, ":", &saveptr); 11764 if (!result) { 11765 free(token); 11766 send_resp(dut, conn, SIGMA_ERROR, 11767 "errorCode,RUAllocTones not specified"); 11768 return STATUS_SENT_ERROR; 11769 } 11770 11771 /* 11772 * ru_allocation_type can take the values of: 11773 * 1 - DL OFDMA data RU allocation 11774 * 3 - UL OFDMA data RU allocation 11775 */ 11776 rualloc_type = dut->ap_he_ulofdma == VALUE_ENABLED ? 3 : 1; 11777 11778 11779 value = atoi(result); 11780 if (value == 106) { 11781 enum value_not_set_enabled_disabled ap_he_rualloc_106_80 = 11782 VALUE_NOT_SET; 11783 11784 result = strtok_r(NULL, ":", &saveptr); 11785 if (result) { 11786 result = strtok_r(NULL, ":", &saveptr); 11787 if (result) 11788 ap_he_rualloc_106_80 = VALUE_ENABLED; 11789 else 11790 ap_he_rualloc_106_80 = VALUE_DISABLED; 11791 } 11792 if (ap_he_rualloc_106_80 == VALUE_ENABLED) { 11793 run_system_wrapper(dut, 11794 "wifitool %s setUnitTestCmd 0x4b 9 %d 0 2 1 2 2 2 3 2", 11795 ifname, rualloc_type); 11796 } else { 11797 run_system_wrapper(dut, 11798 "wifitool %s setUnitTestCmd 0x4b 5 %d 0 2 1 2", 11799 ifname, rualloc_type); 11800 } 11801 } else if (value == 242) { 11802 run_system_wrapper( 11803 dut, 11804 "wifitool %s setUnitTestCmd 0x4b 9 %d 0 3 1 3 2 3 3 3", 11805 ifname, rualloc_type); 11806 } else if (value == 26) { 11807 run_system_wrapper( 11808 dut, 11809 "wifitool %s setUnitTestCmd 0x4b 9 %d 0 0 2 0 5 0 7 0", 11810 ifname, rualloc_type); 11811 } else if (value == 52) { 11812 run_system_wrapper( 11813 dut, 11814 "wifitool %s setUnitTestCmd 0x4b 9 %d 0 1 1 1 2 1 3 1", 11815 ifname, rualloc_type); 11816 } else if (value == 484) { 11817 run_system_wrapper( 11818 dut, 11819 "wifitool %s setUnitTestCmd 0x4b 5 %d 0 4 1 4", 11820 ifname, rualloc_type); 11821 } else if (value == 996) { 11822 run_system_wrapper(dut, 11823 "wifitool %s setUnitTestCmd 0x4b 3 %d 0 5", 11824 ifname, rualloc_type); 11825 } else { 11826 send_resp(dut, conn, SIGMA_ERROR, 11827 "errorCode,Unsupported RUAllocTones"); 11828 ret = STATUS_SENT_ERROR; 11829 } 11830 11831 free(token); 11832 return ret; 11833 } 11834 11835 11836 static void ath_set_trigger_type_0(struct sigma_dut *dut, const char *ifname) 11837 { 11838 /* TriggerType "0" for Basic trigger */ 11839 if (dut->ap_channel >= 36) { 11840 /* 1 and 2 here is interpreted to 5g and 2g (bitmasks) */ 11841 run_system_wrapper(dut, 11842 "wifitool %s setUnitTestCmd 0x47 2 42 1", 11843 ifname); 11844 } else { 11845 run_system_wrapper(dut, 11846 "wifitool %s setUnitTestCmd 0x47 2 42 2", 11847 ifname); 11848 } 11849 run_system_wrapper(dut, "wifitool %s setUnitTestCmd 0x47 2 43 6", 11850 ifname); 11851 } 11852 11853 11854 static void ath_set_trigger_type_1(struct sigma_dut *dut, const char *ifname) 11855 { 11856 /* TriggerType "1" for MU BRP */ 11857 run_system_wrapper(dut, "wifitool %s setUnitTestCmd 0x47 2 7 1", 11858 ifname); 11859 mubrp_commands(dut, ifname); 11860 } 11861 11862 11863 static void ath_set_trigger_type_2(struct sigma_dut *dut, const char *ifname) 11864 { 11865 /* TriggerType "2" for MU BAR */ 11866 if (dut->ap_channel >= 36) { 11867 /* RU allocation RU 242 - DL OFDMA data */ 11868 run_system_wrapper(dut, 11869 "wifitool %s setUnitTestCmd 0x4b 5 9 0 3 1 3 2 3 3 3", 11870 ifname); 11871 /* RU allocation RU 52 - UL BA */ 11872 run_system_wrapper(dut, 11873 "wifitool %s setUnitTestCmd 0x4b 5 9 0 2 1 2 2 2 3 2", 11874 ifname); 11875 } else { 11876 /* RU allocation RU 52 - DL ofdma data */ 11877 run_system_wrapper(dut, 11878 "wifitool %s setUnitTestCmd 0x4b 5 9 0 1 1 1 2 1 3 1", 11879 ifname); 11880 } 11881 /* Force TBPPDU duration to 400 us */ 11882 run_system_wrapper(dut, "wifitool %s setUnitTestCmd 0x48 2 63 400", 11883 ifname); 11884 /* 0 to enable MU BAR, 1 to enable SU BAR */ 11885 run_system_wrapper(dut, "wifitool %s setUnitTestCmd 0x47 2 49 0", 11886 ifname); 11887 /* MU BAR */ 11888 run_system_wrapper(dut, "wifitool %s setUnitTestCmd 0x47 2 64 0", 11889 ifname); 11890 } 11891 11892 11893 static void ath_set_trigger_type_3(struct sigma_dut *dut, const char *ifname) 11894 { 11895 /* TriggerType "3" for MU RTS */ 11896 /* Send MU RTS Trigger - '1' is to enable MU RTS */ 11897 run_system_wrapper(dut, "wifitool %s setUnitTestCmd 0x47 2 101 1", 11898 ifname); 11899 } 11900 11901 11902 static void ath_set_trigger_type_4(struct sigma_dut *dut, const char *ifname, 11903 const char *basedev) 11904 { 11905 /* TriggerType "4" for BSRP */ 11906 run_system_wrapper(dut, "cfg80211tool %s he_ul_trig_int 200", basedev); 11907 run_system_wrapper(dut, "wifitool %s setUnitTestCmd 0x48 2 63 1000", 11908 ifname); 11909 if (dut->ap_channel >= 36) { 11910 run_system_wrapper(dut, 11911 "wifitool %s setUnitTestCmd 0x47 2 42 1", 11912 ifname); 11913 } else { 11914 run_system_wrapper(dut, 11915 "wifitool %s setUnitTestCmd 0x47 2 42 2", 11916 ifname); 11917 } 11918 /* Send BSRP command */ 11919 run_system_wrapper(dut, "wifitool %s setUnitTestCmd 0x47 2 43 7", 11920 ifname); 11921 } 11922 11923 11924 static enum sigma_cmd_result ath_ap_set_rfeature(struct sigma_dut *dut, 11925 struct sigma_conn *conn, 11926 struct sigma_cmd *cmd) 11927 { 11928 const char *val; 11929 const char *ifname; 11930 enum sigma_cmd_result res; 11931 const char *basedev = "wifi0"; 11932 int trigtype; 11933 int he_ackpolicymac = 0; 11934 char *num_ss = NULL; 11935 char *nss[4] = { NULL, NULL, NULL, NULL }; 11936 char *aid[4] = { NULL, NULL, NULL, NULL }; 11937 char *aid_ss = NULL; 11938 int omctrl_rxnss = 0, omctrl_chwidth = 0; 11939 int param; 11940 unsigned char mac_addr[ETH_ALEN]; 11941 11942 memset(mac_addr, 0x00, ETH_ALEN); 11943 11944 ifname = get_main_ifname(dut); 11945 11946 if (sigma_radio_ifname[0]) 11947 basedev = sigma_radio_ifname[0]; 11948 11949 /* Disable vap reset between the commands */ 11950 novap_reset(dut, ifname, 1); 11951 11952 val = get_param(cmd, "Opt_md_notif_ie"); 11953 if (val && ath_vht_op_mode_notif(dut, ifname, val) < 0) 11954 return ERROR_SEND_STATUS; 11955 11956 /* TODO: Optional arguments */ 11957 11958 val = get_param(cmd, "nss_mcs_opt"); 11959 if (val && ath_vht_nss_mcs(dut, ifname, val) < 0) 11960 return ERROR_SEND_STATUS; 11961 11962 val = get_param(cmd, "chnum_band"); 11963 if (val && ath_vht_chnum_band(dut, ifname, val) < 0) 11964 return ERROR_SEND_STATUS; 11965 11966 val = get_param(cmd, "RTS_FORCE"); 11967 if (val) 11968 ath_config_rts_force(dut, ifname, val); 11969 11970 val = get_param(cmd, "DYN_BW_SGNL"); 11971 if (val) 11972 ath_config_dyn_bw_sig(dut, ifname, val); 11973 11974 val = get_param(cmd, "CTS_WIDTH"); 11975 if (val) 11976 ath_set_cts_width(dut, ifname, val); 11977 11978 val = get_param(cmd, "Ndpa_stainfo_mac"); 11979 if (val && ath_ndpa_stainfo_mac(dut, ifname, val) < 0) 11980 return ERROR_SEND_STATUS; 11981 11982 val = get_param(cmd, "txBandwidth"); 11983 if (val && ath_set_width(dut, conn, ifname, val) < 0) 11984 return ERROR_SEND_STATUS; 11985 11986 val = get_param(cmd, "Assoc_Disallow"); 11987 if (val) 11988 ath_set_assoc_disallow(dut, ifname, val); 11989 11990 11991 ath_set_nebor_bssid(dut, ifname, cmd); 11992 val = get_param(cmd, "BTMReq_DisAssoc_Imnt"); 11993 if (val) { 11994 dut->ap_btmreq_disassoc_imnt = atoi(val); 11995 dut->ap_disassoc_timer = 1000; 11996 } 11997 11998 val = get_param(cmd, "BTMReq_Term_Bit"); 11999 if (val) 12000 dut->ap_btmreq_term_bit = atoi(val); 12001 12002 val = get_param(cmd, "Assoc_Delay"); 12003 if (val) { 12004 dut->ap_assoc_delay = 1; 12005 run_iwpriv(dut, ifname, "mbo_asoc_ret %s", val); 12006 } 12007 12008 val = get_param(cmd, "Disassoc_Timer"); 12009 if (val) 12010 dut->ap_disassoc_timer = atoi(val); 12011 12012 val = get_param(cmd, "BSS_Term_Duration"); 12013 if (val) 12014 dut->ap_btmreq_bss_term_dur = atoi(val); 12015 12016 val = get_param(cmd, "BSS_Term_TSF"); 12017 if (val) 12018 dut->ap_btmreq_bss_term_tsf = atoi(val); 12019 12020 val = get_param(cmd, "TxPower"); 12021 if (val) 12022 ath_set_txpower(dut, ifname, val); 12023 12024 val = get_param(cmd, "DownlinkAvailCap"); 12025 if (val) 12026 dut->ap_dl_availcap = atoi(val); 12027 12028 val = get_param(cmd, "UplinkAvailCap"); 12029 if (val) { 12030 dut->ap_ul_availcap = atoi(val); 12031 run_iwpriv(dut, ifname, "oce_wan_mtr %d %d", 12032 dut->ap_dl_availcap, dut->ap_ul_availcap); 12033 } 12034 12035 val = get_param(cmd, "RSSIthreshold"); 12036 if (val) { 12037 int rssithreshold; 12038 12039 run_iwpriv(dut, ifname, "oce_asoc_rej 1"); 12040 rssithreshold = atoi(val); 12041 run_iwpriv(dut, ifname, "oce_asoc_rssi %d", rssithreshold); 12042 } 12043 12044 val = get_param(cmd, "RetryDelay"); 12045 if (val) { 12046 int retrydelay; 12047 12048 run_iwpriv(dut, ifname, "oce_asoc_rej 1"); 12049 retrydelay = atoi(val); 12050 run_iwpriv(dut, ifname, "oce_asoc_dly %d", retrydelay); 12051 } 12052 12053 val = get_param(cmd, "LTF"); 12054 if (val) { 12055 if (dut->ap_fixed_rate) { 12056 res = he_ltf(dut, conn, ifname, val); 12057 if (res != SUCCESS_SEND_STATUS) 12058 return res; 12059 } else { 12060 free(dut->ar_ltf); 12061 dut->ar_ltf = strdup(val); 12062 if (!dut->ar_ltf) 12063 return ERROR_SEND_STATUS; 12064 } 12065 } 12066 12067 val = get_param(cmd, "GI"); 12068 if (val) { 12069 if (dut->ap_fixed_rate) 12070 res = he_shortgi(dut, conn, ifname, val); 12071 else 12072 res = he_ar_gi_ltf_mask(dut, conn, ifname, val); 12073 if (res != SUCCESS_SEND_STATUS) 12074 return res; 12075 } 12076 12077 val = get_param(cmd, "RUAllocTones"); 12078 if (val) { 12079 res = he_rualloctones(dut, conn, ifname, val); 12080 if (res != SUCCESS_SEND_STATUS) 12081 return res; 12082 } 12083 12084 val = get_param(cmd, "MPDU_MU_SpacingFactor"); 12085 if (val) 12086 run_system_wrapper(dut, 12087 "wifitool %s setUnitTestCmd 0x48 2 119, %s", 12088 ifname, val); 12089 12090 val = get_param(cmd, "PPDUTxType"); 12091 if (val) { 12092 if (strcasecmp(val, "HE-SU") == 0) { 12093 /* Change PPDU format type to HE-SU MCS 1 */ 12094 run_system_wrapper(dut, 12095 "wifitool %s setUnitTestCmd 0x48 2 89 0x401", 12096 ifname); 12097 } else if (strcasecmp(val, "legacy") == 0) { 12098 /* Change PPDU format type to non-HT */ 12099 run_system_wrapper(dut, 12100 "wifitool %s setUnitTestCmd 0x48 2 89 3", 12101 ifname); 12102 } else { 12103 send_resp(dut, conn, SIGMA_ERROR, 12104 "errorCode,Unsupported PPDUTxType"); 12105 return STATUS_SENT_ERROR; 12106 } 12107 } 12108 12109 val = get_param(cmd, "TXOPDuration"); 12110 if (val) { 12111 if (strcasecmp(val, "UNSPECIFIED") == 0) { 12112 /* The hardware is hardcoded with 0x7f; do nothing */ 12113 } else { 12114 send_resp(dut, conn, SIGMA_ERROR, 12115 "errorCode,Unsupported TXOPDuration"); 12116 return STATUS_SENT_ERROR; 12117 } 12118 } 12119 12120 val = get_param(cmd, "Trig_Usrinfo_UL-MCS"); 12121 if (val) 12122 run_iwpriv(dut, ifname, "he_ul_mcs %d", atoi(val)); 12123 12124 val = get_param(cmd, "Trig_Usrinfo_UL-Target-RSSI"); 12125 if (val) { 12126 /* Set target RSSI to -55 dBm */ 12127 run_system_wrapper(dut, 12128 "wifitool %s setUnitTestCmd 0x4b 2 7 %d", 12129 ifname, atoi(val) - 110); 12130 } 12131 12132 val = get_param(cmd, "Trig_Interval"); 12133 if (val) 12134 run_iwpriv(dut, basedev, "he_ul_trig_int %d", atoi(val)); 12135 12136 val = get_param(cmd, "Trig_ComInfo_ULLength"); 12137 if (val) 12138 run_system_wrapper(dut, 12139 "wifitool %s setUnitTestCmd 0x48 2 141 %d", 12140 ifname, atoi(val)); 12141 12142 val = get_param(cmd, "DisableTriggerType"); 12143 if (val) { 12144 trigtype = atoi(val); 12145 switch (trigtype) { 12146 case 0: 12147 /* DisableTriggerType "0" for basic trigger */ 12148 run_system_wrapper(dut, 12149 "wifitool %s setUnitTestCmd 0x47 2 42 0", 12150 ifname); 12151 break; 12152 default: 12153 /* Nothing to be done for now */ 12154 break; 12155 } 12156 } 12157 12158 val = get_param(cmd, "Trigger_TxBF"); 12159 if (val) { 12160 if (strcasecmp(val, "enable") == 0) { 12161 run_iwpriv(dut, ifname, "he_sounding_mode 0x9"); 12162 } else if (strcasecmp(val, "disable") == 0) { 12163 run_iwpriv(dut, ifname, "he_sounding_mode 0x1"); 12164 } else { 12165 send_resp(dut, conn, SIGMA_ERROR, 12166 "errorCode,Unsupported trigger_txbf"); 12167 return STATUS_SENT_ERROR; 12168 } 12169 } 12170 12171 val = get_param(cmd, "Trig_UsrInfo_RUAlloc"); 12172 if (val) { 12173 res = he_rualloctones(dut, conn, ifname, val); 12174 if (res != SUCCESS_SEND_STATUS) 12175 return res; 12176 } 12177 12178 val = get_param(cmd, "TriggerCoding"); 12179 if (val) { 12180 if (strcasecmp(val, "BCC") == 0) { 12181 /* In case of LDPC enable this command can force BCC if 12182 * RU size <= 242 */ 12183 run_iwpriv(dut, ifname, "he_ul_ldpc 0"); 12184 } else if (strcasecmp(val, "LDPC") == 0) { 12185 novap_reset(dut, ifname, 0); 12186 run_iwpriv(dut, ifname, "he_ul_ldpc 1"); 12187 novap_reset(dut, ifname, 1); 12188 } else { 12189 send_resp(dut, conn, SIGMA_ERROR, 12190 "errorCode,Unsupported TriggerCoding"); 12191 return STATUS_SENT_ERROR; 12192 } 12193 } 12194 12195 val = get_param(cmd, "AckPolicy_MAC"); 12196 if (val) { 12197 if (parse_mac_address(dut, val, mac_addr) < 0) { 12198 send_resp(dut, conn, SIGMA_ERROR, 12199 "errorCode,MAC Address not in proper format"); 12200 return STATUS_SENT_ERROR; 12201 } 12202 he_ackpolicymac = 1; 12203 } 12204 12205 val = get_param(cmd, "AckPolicy"); 12206 if (val) { 12207 int ap_he_ackpolicy; 12208 12209 ap_he_ackpolicy = atoi(val); 12210 if (ap_he_ackpolicy == 0 && he_ackpolicymac) { 12211 /* Disable all-BAR ackpolicy for MU-MIMO */ 12212 run_system_wrapper(dut, 12213 "wifitool %s setUnitTestCmd 0x48 2 62 0", 12214 ifname); 12215 /* Disable all-BAR ackpolicy first */ 12216 run_system_wrapper(dut, 12217 "wifitool %s setUnitTestCmd 0x48 2 64 0", 12218 ifname); 12219 /* Set normal ack policy for the STA with the specified 12220 * MAC address in DL-TX case */ 12221 run_system_wrapper(dut, 12222 "wifitool %s setUnitTestCmd 0x4b 8 8 1 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x", 12223 ifname, mac_addr[0], mac_addr[1], 12224 mac_addr[2], mac_addr[3], 12225 mac_addr[4], mac_addr[5]); 12226 } else if (ap_he_ackpolicy == 3) { 12227 /* Enable all-BAR ackpolicy for MU-MIMO DL */ 12228 run_system_wrapper(dut, 12229 "wifitool %s setUnitTestCmd 0x48 2 62 1", 12230 ifname); 12231 /* Enable all-BAR ackpolicy */ 12232 run_system_wrapper(dut, 12233 "wifitool %s setUnitTestCmd 0x48 2 64 1", 12234 ifname); 12235 } else if (ap_he_ackpolicy == 4) { 12236 /* Enable htp-ack ackpolicy */ 12237 run_system_wrapper(dut, 12238 "wifitool %s setUnitTestCmd 0x47 2 99 1", 12239 ifname); 12240 } else { 12241 send_resp(dut, conn, SIGMA_ERROR, 12242 "errorCode,Invalid AckPolicy setting"); 12243 return STATUS_SENT_ERROR; 12244 } 12245 } 12246 12247 val = get_param(cmd, "Trig_ComInfo_GI-LTF"); 12248 if (val) { 12249 int trig_gi_ltf; 12250 12251 trig_gi_ltf = atoi(val); 12252 if (trig_gi_ltf == 0) { 12253 he_ltf(dut, conn, ifname, "3.2"); 12254 he_shortgi(dut, conn, ifname, "1.6"); 12255 } else if (trig_gi_ltf == 1) { 12256 he_ltf(dut, conn, ifname, "6.4"); 12257 he_shortgi(dut, conn, ifname, "1.6"); 12258 } else if (trig_gi_ltf == 2) { 12259 he_ltf(dut, conn, ifname, "12.8"); 12260 he_shortgi(dut, conn, ifname, "3.2"); 12261 } else { 12262 send_resp(dut, conn, SIGMA_ERROR, 12263 "errorCode,Unsupported Trig_ComInfo_GI-LTF"); 12264 return STATUS_SENT_ERROR; 12265 } 12266 } 12267 12268 val = get_param(cmd, "Trig_ComInfo_BW"); 12269 if (val) { 12270 int chwidth; 12271 12272 chwidth = atoi(val); 12273 /* Set the channel width */ 12274 run_iwpriv(dut, ifname, "chwidth %d", chwidth); 12275 } 12276 12277 val = get_param(cmd, "NumSS"); 12278 if (val) { 12279 int i = 0; 12280 char *numss_val; 12281 char *saveptr; 12282 12283 num_ss = strdup(val); 12284 if (!num_ss) 12285 return ERROR_SEND_STATUS; 12286 12287 numss_val = strtok_r(num_ss, " ", &saveptr); 12288 for (i = 0; numss_val && i < 4; i++) { 12289 nss[i] = numss_val; 12290 numss_val = strtok_r(NULL, " ", &saveptr); 12291 } 12292 } 12293 12294 val = get_param(cmd, "NumSS_MAC"); 12295 if (val) { 12296 char *sta_mac_str; 12297 char *saveptr; 12298 char *sta_mac_list_str; 12299 12300 sta_mac_list_str = strdup(val); 12301 if (!sta_mac_list_str) { 12302 free(num_ss); 12303 return ERROR_SEND_STATUS; 12304 } 12305 12306 sta_mac_str = strtok_r(sta_mac_list_str, " ", &saveptr); 12307 if (sta_mac_str && nss[0]) { 12308 run_system_wrapper(dut, 12309 "wifitool %s chmask_persta %s %s", 12310 ifname, sta_mac_str, nss[0]); 12311 } 12312 12313 sta_mac_str = strtok_r(NULL, " ", &saveptr); 12314 if (sta_mac_str && nss[1]) { 12315 run_system_wrapper(dut, 12316 "wifitool %s chmask_persta %s %s", 12317 ifname, sta_mac_str, nss[1]); 12318 } 12319 12320 sta_mac_str = strtok_r(NULL, " ", &saveptr); 12321 if (sta_mac_str && nss[2]) { 12322 run_system_wrapper(dut, 12323 "wifitool %s chmask_persta %s %s", 12324 ifname, sta_mac_str, nss[2]); 12325 } 12326 12327 sta_mac_str = strtok_r(NULL, " ", &saveptr); 12328 if (sta_mac_str && nss[3]) { 12329 run_system_wrapper(dut, 12330 "wifitool %s chmask_persta %s %s", 12331 ifname, sta_mac_str, nss[3]); 12332 } 12333 12334 free(sta_mac_list_str); 12335 } 12336 12337 free(num_ss); 12338 num_ss = NULL; 12339 12340 val = get_param(cmd, "AID"); 12341 if (val) { 12342 int i = 0; 12343 char *aid_val; 12344 char *saveptr; 12345 12346 aid_ss = strdup(val); 12347 if (!aid_ss) 12348 return ERROR_SEND_STATUS; 12349 12350 aid_val = strtok_r(aid_ss, " ", &saveptr); 12351 for (i = 0; aid_val && i < 4; i++) { 12352 aid[i] = aid_val; 12353 aid_val = strtok_r(NULL, " ", &saveptr); 12354 } 12355 } 12356 12357 val = get_param(cmd, "AddbaReq"); 12358 if (val) { 12359 if (strcasecmp(val, "enable") == 0) { 12360 run_iwpriv(dut, ifname, "setaddbaoper 1"); 12361 run_system_wrapper(dut, 12362 "wifitool %s sendaddba %s 0 64", 12363 ifname, aid[0]); 12364 } else { 12365 send_resp(dut, conn, SIGMA_ERROR, 12366 "errorCode,Unsupported AddbaReq value"); 12367 free(aid_ss); 12368 return STATUS_SENT_ERROR; 12369 } 12370 } 12371 12372 val = get_param(cmd, "AddbaResp"); 12373 if (val) { 12374 if (aid_ss && strcasecmp(val, "accepted") == 0) { 12375 int aid_1 = atoi(aid_ss); 12376 12377 if (aid_1 == 1) 12378 aid_1 = 2; 12379 else 12380 aid_1 = aid_1 - 1; 12381 12382 /* There is no mechanism in place to reject Add BA Req 12383 * from all STAs and selectively accept Add BA Req from 12384 * a specified STA. Instead, it can accept Add BA Req 12385 * from all STAs and selectively reject from specified 12386 * STAs. Make changes for the same using the below 12387 * commands. */ 12388 run_system_wrapper(dut, ifname, "setaddbaoper 1"); 12389 run_system_wrapper(dut, "wifitool %s refusealladdbas 0", 12390 ifname); 12391 run_system_wrapper(dut, 12392 "wifitool %s setaddbaresp %d 0 37", 12393 ifname, aid_1); 12394 } else { 12395 send_resp(dut, conn, SIGMA_ERROR, 12396 "errorCode,Unsupported Addbaresp value"); 12397 free(aid_ss); 12398 return STATUS_SENT_ERROR; 12399 } 12400 } 12401 12402 val = get_param(cmd, "Trig_UsrInfo_SSAlloc_RA-RU"); 12403 if (val) { 12404 char *ssalloc_str; 12405 char *saveptr; 12406 char *ssalloc_list_str; 12407 12408 ssalloc_list_str = strdup(val); 12409 if (!ssalloc_list_str) { 12410 free(aid_ss); 12411 return ERROR_SEND_STATUS; 12412 } 12413 12414 ssalloc_str = strtok_r(ssalloc_list_str, ":", &saveptr); 12415 if (ssalloc_str && aid[0]) { 12416 run_system_wrapper(dut, "wifitool %s peer_nss %s %s", 12417 ifname, aid[0], ssalloc_str); 12418 } 12419 12420 ssalloc_str = strtok_r(NULL, " ", &saveptr); 12421 if (ssalloc_str && aid[1]) { 12422 run_system_wrapper(dut, "wifitool %s peer_nss %s %s", 12423 ifname, aid[1], ssalloc_str); 12424 } 12425 12426 ssalloc_str = strtok_r(NULL, " ", &saveptr); 12427 if (ssalloc_str && aid[2]) { 12428 run_system_wrapper(dut, "wifitool %s peer_nss %s %s", 12429 ifname, aid[2], ssalloc_str); 12430 } 12431 12432 ssalloc_str = strtok_r(NULL, " ", &saveptr); 12433 if (ssalloc_str && aid[3]) { 12434 run_system_wrapper(dut, "wifitool %s peer_nss %s %s", 12435 ifname, aid[3], ssalloc_str); 12436 } 12437 12438 free(ssalloc_list_str); 12439 } 12440 12441 free(aid_ss); 12442 aid_ss = NULL; 12443 12444 val = get_param(cmd, "OMCtrl_RxNSS"); 12445 if (val) 12446 omctrl_rxnss = atoi(val); 12447 12448 val = get_param(cmd, "OMCtrl_ChnlWidth"); 12449 if (val) 12450 omctrl_chwidth = atoi(val); 12451 12452 val = get_param(cmd, "Client_mac"); 12453 if (val) { 12454 if (parse_mac_address(dut, val, mac_addr) < 0) { 12455 send_resp(dut, conn, SIGMA_ERROR, 12456 "errorCode,MAC Address not in proper format"); 12457 return STATUS_SENT_ERROR; 12458 } 12459 12460 /* setUnitTestCmd 13 7 1 mac3mac2mac1mac0 mac5mac4 <rx_nss> 12461 * <bw> <ulmu> <tx_nss> */ 12462 run_system_wrapper(dut, 12463 "wifitool %s setUnitTestCmd 13 7 1 0x%02x%02x%02x%02x 0x%02x%02x %d %d 1 %d", 12464 ifname, mac_addr[3], mac_addr[2], 12465 mac_addr[1], mac_addr[0], mac_addr[5], 12466 mac_addr[4], omctrl_rxnss, 12467 omctrl_chwidth, omctrl_rxnss); 12468 } 12469 12470 val = get_param(cmd, "TriggerType"); 12471 if (val) { 12472 trigtype = atoi(val); 12473 switch (trigtype) { 12474 case 0: 12475 ath_set_trigger_type_0(dut, ifname); 12476 break; 12477 case 1: 12478 ath_set_trigger_type_1(dut, ifname); 12479 break; 12480 case 2: 12481 ath_set_trigger_type_2(dut, ifname); 12482 break; 12483 case 3: 12484 ath_set_trigger_type_3(dut, ifname); 12485 break; 12486 case 4: 12487 ath_set_trigger_type_4(dut, ifname, basedev); 12488 break; 12489 default: 12490 send_resp(dut, conn, SIGMA_ERROR, 12491 "errorCode,TriggerType not supported"); 12492 return STATUS_SENT_ERROR; 12493 } 12494 } 12495 12496 val = get_param(cmd, "HE_TXOPDurRTSThr"); 12497 if (val) 12498 run_iwpriv(dut, ifname, "he_rtsthrshld %d", atoi(val)); 12499 12500 val = get_param(cmd, "NAV_Update"); 12501 if (val) { 12502 if (strcasecmp(val, "disable") == 0) { 12503 run_iwpriv(dut, basedev, "nav_config 1 0"); 12504 } else if (strcasecmp(val, "enable") == 0) { 12505 /* Do nothing */ 12506 } else { 12507 send_resp(dut, conn, SIGMA_ERROR, 12508 "errorCode,Unsupported NAV update"); 12509 return STATUS_SENT_ERROR; 12510 } 12511 } 12512 12513 /* Configure WMM Parameter Elements */ 12514 val = get_param(cmd, "STA_WMMPE_ECWmin_BE"); 12515 if (val) { 12516 param = atoi(val); 12517 run_iwpriv(dut, ifname, "cwmin %d 1 %d", AP_AC_BE, param); 12518 } 12519 12520 val = get_param(cmd, "STA_WMMPE_ECWmin_BK"); 12521 if (val) { 12522 param = atoi(val); 12523 run_iwpriv(dut, ifname, "cwmin %d 1 %d", AP_AC_BK, param); 12524 } 12525 12526 val = get_param(cmd, "STA_WMMPE_ECWmin_VI"); 12527 if (val) { 12528 param = atoi(val); 12529 run_iwpriv(dut, ifname, "cwmin %d 1 %d", AP_AC_VI, param); 12530 } 12531 12532 val = get_param(cmd, "STA_WMMPE_ECWmin_VO"); 12533 if (val) { 12534 param = atoi(val); 12535 run_iwpriv(dut, ifname, "cwmin %d 1 %d", AP_AC_VO, param); 12536 } 12537 12538 val = get_param(cmd, "STA_WMMPE_ECWmax_BE"); 12539 if (val) { 12540 param = atoi(val); 12541 run_iwpriv(dut, ifname, "cwmax %d 1 %d", AP_AC_BE, param); 12542 } 12543 12544 val = get_param(cmd, "STA_WMMPE_ECWmax_BK"); 12545 if (val) { 12546 param = atoi(val); 12547 run_iwpriv(dut, ifname, "cwmax %d 1 %d", AP_AC_BK, param); 12548 } 12549 12550 val = get_param(cmd, "STA_WMMPE_ECWmax_VI"); 12551 if (val) { 12552 param = atoi(val); 12553 run_iwpriv(dut, ifname, "cwmax %d 1 %d", AP_AC_VI, param); 12554 } 12555 12556 val = get_param(cmd, "STA_WMMPE_ECWmax_VO"); 12557 if (val) { 12558 param = atoi(val); 12559 run_iwpriv(dut, ifname, "cwmax %d 1 %d", AP_AC_VO, param); 12560 } 12561 12562 val = get_param(cmd, "STA_WMMPE_AIFSN_BE"); 12563 if (val) { 12564 param = atoi(val); 12565 run_iwpriv(dut, ifname, "aifs %d 1 %d", AP_AC_BE, param); 12566 } 12567 12568 val = get_param(cmd, "STA_WMMPE_AIFSN_BK"); 12569 if (val) { 12570 param = atoi(val); 12571 run_iwpriv(dut, ifname, "aifs %d 1 %d", AP_AC_BK, param); 12572 } 12573 12574 val = get_param(cmd, "STA_WMMPE_AIFSN_VI"); 12575 if (val) { 12576 param = atoi(val); 12577 run_iwpriv(dut, ifname, "aifs %d 1 %d", AP_AC_VI, param); 12578 } 12579 12580 val = get_param(cmd, "STA_WMMPE_AIFSN_VO"); 12581 if (val) { 12582 param = atoi(val); 12583 run_iwpriv(dut, ifname, "aifs %d 1 %d", AP_AC_VO, param); 12584 } 12585 12586 12587 val = get_param(cmd, "STA_WMMPE_TXOP_BE"); 12588 if (val) { 12589 param = atoi(val); 12590 run_iwpriv(dut, ifname, "txoplimit %d 1 %d", AP_AC_BE, param); 12591 } 12592 12593 val = get_param(cmd, "STA_WMMPE_TOXP_BK"); 12594 if (val) { 12595 param = atoi(val); 12596 run_iwpriv(dut, ifname, "txoplimit %d 1 %d", AP_AC_BK, param); 12597 } 12598 12599 val = get_param(cmd, "STA_WMMPE_TXOP_VI"); 12600 if (val) { 12601 param = atoi(val); 12602 run_iwpriv(dut, ifname, "txoplimit %d %d", AP_AC_VI, param); 12603 } 12604 12605 val = get_param(cmd, "STA_WMMPE_TXOP_VO"); 12606 if (val) { 12607 param = atoi(val); 12608 run_iwpriv(dut, ifname, "txoplimit %d 1 %d", AP_AC_VO, param); 12609 } 12610 12611 /* Configure MU EDCA */ 12612 val = get_param(cmd, "STA_MUEDCA_ECWmin_BE"); 12613 if (val) { 12614 param = atoi(val); 12615 run_iwpriv(dut, ifname, "muedca_ecwmin %d %d", AP_AC_BE, param); 12616 } 12617 12618 val = get_param(cmd, "STA_MUEDCA_ECWmin_BK"); 12619 if (val) { 12620 param = atoi(val); 12621 run_iwpriv(dut, ifname, "muedca_ecwmin %d %d", AP_AC_BK, param); 12622 } 12623 12624 val = get_param(cmd, "STA_MUEDCA_ECWmin_VI"); 12625 if (val) { 12626 param = atoi(val); 12627 run_iwpriv(dut, ifname, "muedca_ecwmin %d %d", AP_AC_VI, param); 12628 } 12629 12630 val = get_param(cmd, "STA_MUEDCA_ECWmin_VO"); 12631 if (val) { 12632 param = atoi(val); 12633 run_iwpriv(dut, ifname, "muedca_ecwmin %d %d", AP_AC_VO, param); 12634 } 12635 12636 val = get_param(cmd, "STA_MUEDCA_ECWmax_BE"); 12637 if (val) { 12638 param = atoi(val); 12639 run_iwpriv(dut, ifname, "muedca_ecwmax %d %d", AP_AC_BE, param); 12640 } 12641 12642 val = get_param(cmd, "STA_MUEDCA_ECWmax_BK"); 12643 if (val) { 12644 param = atoi(val); 12645 run_iwpriv(dut, ifname, "muedca_ecwmax %d %d", AP_AC_BK, param); 12646 } 12647 12648 val = get_param(cmd, "STA_MUEDCA_ECWmax_VI"); 12649 if (val) { 12650 param = atoi(val); 12651 run_iwpriv(dut, ifname, "muedca_ecwmax %d %d", AP_AC_VI, param); 12652 } 12653 12654 val = get_param(cmd, "STA_MUEDCA_ECWmax_VO"); 12655 if (val) { 12656 param = atoi(val); 12657 run_iwpriv(dut, ifname, "muedca_ecwmax %d %d", AP_AC_VO, param); 12658 } 12659 12660 val = get_param(cmd, "STA_MUEDCA_AIFSN_BE"); 12661 if (val) { 12662 param = atoi(val); 12663 run_iwpriv(dut, ifname, "muedca_aifsn %d %d", AP_AC_BE, param); 12664 } 12665 12666 val = get_param(cmd, "STA_MUEDCA_AIFSN_BK"); 12667 if (val) { 12668 param = atoi(val); 12669 run_iwpriv(dut, ifname, "muedca_aifsn %d %d", AP_AC_BK, param); 12670 } 12671 12672 val = get_param(cmd, "STA_MUEDCA_AIFSN_VI"); 12673 if (val) { 12674 param = atoi(val); 12675 run_iwpriv(dut, ifname, "muedca_aifsn %d %d", AP_AC_VI, param); 12676 } 12677 12678 val = get_param(cmd, "STA_MUEDCA_AIFSN_VO"); 12679 if (val) { 12680 param = atoi(val); 12681 run_iwpriv(dut, ifname, "muedca_aifsn %d %d", AP_AC_VO, param); 12682 } 12683 12684 val = get_param(cmd, "STA_MUEDCA_Timer_BE"); 12685 if (val) { 12686 param = atoi(val); 12687 run_iwpriv(dut, ifname, "muedca_timer %d %d", AP_AC_BE, param); 12688 } 12689 12690 val = get_param(cmd, "STA_MUEDCA_Timer_BK"); 12691 if (val) { 12692 param = atoi(val); 12693 run_iwpriv(dut, ifname, "muedca_timer %d %d", AP_AC_BK, param); 12694 } 12695 12696 val = get_param(cmd, "STA_MUEDCA_Timer_VI"); 12697 if (val) { 12698 param = atoi(val); 12699 run_iwpriv(dut, ifname, "muedca_timer %d %d", AP_AC_VI, param); 12700 } 12701 12702 val = get_param(cmd, "STA_MUEDCA_Timer_VO"); 12703 if (val) { 12704 param = atoi(val); 12705 run_iwpriv(dut, ifname, "muedca_timer %d %d", AP_AC_VO, param); 12706 } 12707 12708 return SUCCESS_SEND_STATUS; 12709 } 12710 12711 12712 static int wcn_vht_chnum_band(struct sigma_dut *dut, const char *ifname, 12713 const char *val) 12714 { 12715 char *token, *result; 12716 int channel = 36; 12717 char *saveptr; 12718 12719 /* Extract the channel info */ 12720 token = strdup(val); 12721 if (!token) 12722 return -1; 12723 result = strtok_r(token, ";", &saveptr); 12724 if (result) 12725 channel = atoi(result); 12726 12727 /* Issue the channel switch command */ 12728 run_iwpriv(dut, ifname, "setChanChange %d", channel); 12729 12730 free(token); 12731 return 0; 12732 } 12733 12734 12735 static enum sigma_cmd_result wcn_ap_set_rfeature(struct sigma_dut *dut, 12736 struct sigma_conn *conn, 12737 struct sigma_cmd *cmd) 12738 { 12739 const char *val; 12740 const char *ifname; 12741 12742 ifname = get_main_ifname(dut); 12743 12744 val = get_param(cmd, "chnum_band"); 12745 if (val && wcn_vht_chnum_band(dut, ifname, val) < 0) 12746 return ERROR_SEND_STATUS; 12747 12748 val = get_param(cmd, "txBandwidth"); 12749 if (val) { 12750 int old_ch_bw = dut->ap_chwidth; 12751 12752 if (strcasecmp(val, "Auto") == 0) { 12753 dut->ap_chwidth = 0; 12754 } else if (strcasecmp(val, "20") == 0) { 12755 dut->ap_chwidth = 0; 12756 } else if (strcasecmp(val, "40") == 0) { 12757 dut->ap_chwidth = 1; 12758 } else if (strcasecmp(val, "80") == 0) { 12759 dut->ap_chwidth = 2; 12760 } else if (strcasecmp(val, "160") == 0) { 12761 dut->ap_chwidth = 3; 12762 } else { 12763 send_resp(dut, conn, SIGMA_ERROR, 12764 "ErrorCode,WIDTH not supported"); 12765 return STATUS_SENT_ERROR; 12766 } 12767 if (old_ch_bw != dut->ap_chwidth) { 12768 if (cmd_ap_config_commit(dut, conn, cmd) <= 0) 12769 return STATUS_SENT_ERROR; 12770 } else { 12771 sigma_dut_print(dut, DUT_MSG_DEBUG, "No change in BW"); 12772 } 12773 } 12774 12775 val = get_param(cmd, "GI"); 12776 if (val) { 12777 int fix_rate_sgi; 12778 12779 if (strcmp(val, "0.8") == 0) { 12780 run_iwpriv(dut, ifname, "enable_short_gi 9"); 12781 fix_rate_sgi = 1; 12782 } else if (strcmp(val, "1.6") == 0) { 12783 run_iwpriv(dut, ifname, "enable_short_gi 10"); 12784 fix_rate_sgi = 2; 12785 } else if (strcmp(val, "3.2") == 0) { 12786 run_iwpriv(dut, ifname, "enable_short_gi 11"); 12787 fix_rate_sgi = 3; 12788 } else { 12789 send_resp(dut, conn, SIGMA_ERROR, 12790 "errorCode,GI value not supported"); 12791 return STATUS_SENT_ERROR; 12792 } 12793 run_iwpriv(dut, ifname, "enable_short_gi %d", fix_rate_sgi); 12794 } 12795 12796 val = get_param(cmd, "LTF"); 12797 if (val) { 12798 #ifdef NL80211_SUPPORT 12799 if (strcmp(val, "3.2") == 0) { 12800 wcn_set_he_ltf(dut, ifname, QCA_WLAN_HE_LTF_1X); 12801 } if (strcmp(val, "6.4") == 0) { 12802 wcn_set_he_ltf(dut, ifname, QCA_WLAN_HE_LTF_2X); 12803 } else if (strcmp(val, "12.8") == 0) { 12804 wcn_set_he_ltf(dut, ifname, QCA_WLAN_HE_LTF_4X); 12805 } else { 12806 send_resp(dut, conn, SIGMA_ERROR, 12807 "errorCode,LTF value not supported"); 12808 return STATUS_SENT; 12809 } 12810 #else /* NL80211_SUPPORT */ 12811 sigma_dut_print(dut, DUT_MSG_ERROR, 12812 "LTF cannot be set without NL80211_SUPPORT defined"); 12813 return ERROR_SEND_STATUS; 12814 #endif /* NL80211_SUPPORT */ 12815 } 12816 12817 return SUCCESS_SEND_STATUS; 12818 } 12819 12820 12821 static int mac80211_vht_chnum_band(struct sigma_dut *dut, const char *ifname, 12822 const char *val) 12823 { 12824 char *token, *result; 12825 int channel = 36, chwidth = 80, center_freq_idx, center_freq, 12826 channel_freq; 12827 char buf[100]; 12828 char *saveptr; 12829 int res; 12830 12831 /* Extract the channel info */ 12832 token = strdup(val); 12833 if (!token) 12834 return -1; 12835 result = strtok_r(token, ";", &saveptr); 12836 if (result) 12837 channel = atoi(result); 12838 12839 /* Extract the channel width info */ 12840 result = strtok_r(NULL, ";", &saveptr); 12841 if (result) 12842 chwidth = atoi(result); 12843 12844 center_freq_idx = get_oper_centr_freq_seq_idx(chwidth, channel); 12845 if (center_freq_idx < 0) { 12846 free(token); 12847 return -1; 12848 } 12849 12850 center_freq = get_5g_channel_freq(center_freq_idx); 12851 channel_freq = get_5g_channel_freq(channel); 12852 12853 /* Issue the channel switch command */ 12854 res = snprintf(buf, sizeof(buf), 12855 " -i %s chan_switch 10 %d sec_channel_offset=1 center_freq1=%d bandwidth=%d blocktx vht", 12856 ifname, channel_freq, center_freq, chwidth); 12857 if (res < 0 || res >= sizeof(buf) || run_hostapd_cli(dut, buf) != 0) { 12858 sigma_dut_print(dut, DUT_MSG_ERROR, 12859 "hostapd_cli chan_switch failed"); 12860 } 12861 12862 free(token); 12863 return 0; 12864 } 12865 12866 12867 static int mac80211_ap_set_rfeature(struct sigma_dut *dut, 12868 struct sigma_conn *conn, 12869 struct sigma_cmd *cmd) 12870 { 12871 const char *val; 12872 const char *ifname; 12873 12874 ifname = get_main_ifname(dut); 12875 12876 val = get_param(cmd, "RTS_FORCE"); 12877 if (val) 12878 mac80211_config_rts_force(dut, ifname, val); 12879 12880 val = get_param(cmd, "chnum_band"); 12881 if (val && mac80211_vht_chnum_band(dut, ifname, val) < 0) 12882 return -1; 12883 12884 return 1; 12885 } 12886 12887 12888 #ifdef __linux__ 12889 static int wil6210_ap_set_rfeature(struct sigma_dut *dut, 12890 struct sigma_conn *conn, 12891 struct sigma_cmd *cmd) 12892 { 12893 const char *val; 12894 12895 val = get_param(cmd, "ExtSchIE"); 12896 if (val && !strcasecmp(val, "Enable")) { 12897 struct sigma_ese_alloc allocs[MAX_ESE_ALLOCS]; 12898 int count = MAX_ESE_ALLOCS; 12899 12900 if (sta_extract_60g_ese(dut, cmd, allocs, &count)) 12901 return -1; 12902 if (wil6210_set_ese(dut, count, allocs)) 12903 return -1; 12904 return 1; 12905 } 12906 12907 send_resp(dut, conn, SIGMA_ERROR, 12908 "errorCode,Invalid ap_set_rfeature(60G)"); 12909 return 0; 12910 } 12911 #endif /* __linux__ */ 12912 12913 12914 static enum sigma_cmd_result cmd_ap_set_rfeature(struct sigma_dut *dut, 12915 struct sigma_conn *conn, 12916 struct sigma_cmd *cmd) 12917 { 12918 /* const char *name = get_param(cmd, "NAME"); */ 12919 /* const char *type = get_param(cmd, "Type"); */ 12920 const char *val, *oci_chan, *oci_frametype; 12921 char buf[100]; 12922 const char *ifname = get_hostapd_ifname(dut); 12923 12924 val = get_param(cmd, "ReassocResp_RSNXE_Used"); 12925 if (val) { 12926 if (atoi(val) == 0) 12927 snprintf(buf, sizeof(buf), "SET ft_rsnxe_used 2"); 12928 else 12929 snprintf(buf, sizeof(buf), "SET ft_rsnxe_used 1"); 12930 if (hapd_command(ifname, buf) < 0) { 12931 send_resp(dut, conn, SIGMA_ERROR, 12932 "ErrorCode,Failed to set ft_rsnxe_used"); 12933 return STATUS_SENT_ERROR; 12934 } 12935 } 12936 12937 oci_chan = get_param(cmd, "OCIChannel"); 12938 oci_frametype = get_param(cmd, "OCIFrameType"); 12939 if (oci_chan && oci_frametype) { 12940 unsigned int oci_freq = channel_to_freq(dut, atoi(oci_chan)); 12941 12942 if (!oci_freq) { 12943 send_resp(dut, conn, SIGMA_ERROR, 12944 "errorCode,Invalid OCIChannel number"); 12945 return STATUS_SENT_ERROR; 12946 } 12947 12948 if (strcasecmp(oci_frametype, "eapolM3") == 0) { 12949 snprintf(buf, sizeof(buf), 12950 "SET oci_freq_override_eapol_m3 %d", oci_freq); 12951 } else if (strcasecmp(oci_frametype, "eapolG1") == 0) { 12952 snprintf(buf, sizeof(buf), 12953 "SET oci_freq_override_eapol_g1 %d", oci_freq); 12954 } else if (strcasecmp(oci_frametype, "SAQueryReq") == 0) { 12955 snprintf(buf, sizeof(buf), 12956 "SET oci_freq_override_saquery_req %d", 12957 oci_freq); 12958 } else if (strcasecmp(oci_frametype, "SAQueryResp") == 0) { 12959 snprintf(buf, sizeof(buf), 12960 "SET oci_freq_override_saquery_resp %d", 12961 oci_freq); 12962 } else { 12963 send_resp(dut, conn, SIGMA_ERROR, 12964 "errorCode,Unsupported OCIFrameType"); 12965 return STATUS_SENT_ERROR; 12966 } 12967 if (hapd_command(ifname, buf) < 0) { 12968 send_resp(dut, conn, SIGMA_ERROR, 12969 "errorCode,Failed to set oci_freq_override"); 12970 return STATUS_SENT_ERROR; 12971 } 12972 return SUCCESS_SEND_STATUS; 12973 } 12974 12975 val = get_param(cmd, "Transition_Disable"); 12976 if (val) { 12977 if (atoi(val)) { 12978 val = get_param(cmd, "Transition_Disable_Index"); 12979 if (!val) { 12980 send_resp(dut, conn, SIGMA_INVALID, 12981 "errorCode,Transition_Disable without Transition_Disable_Index"); 12982 return STATUS_SENT; 12983 } 12984 dut->ap_transition_disable = 1 << atoi(val); 12985 } else { 12986 dut->ap_transition_disable = 0; 12987 } 12988 12989 snprintf(buf, sizeof(buf), "SET transition_disable 0x%02x", 12990 dut->ap_transition_disable); 12991 if (hapd_command(ifname, buf) < 0) { 12992 send_resp(dut, conn, SIGMA_ERROR, 12993 "errorCode,Failed to update transition mode disabled indication"); 12994 return STATUS_SENT_ERROR; 12995 } 12996 return SUCCESS_SEND_STATUS; 12997 } 12998 12999 switch (get_driver_type(dut)) { 13000 case DRIVER_ATHEROS: 13001 return ath_ap_set_rfeature(dut, conn, cmd); 13002 case DRIVER_OPENWRT: 13003 switch (get_openwrt_driver_type()) { 13004 case OPENWRT_DRIVER_ATHEROS: 13005 return ath_ap_set_rfeature(dut, conn, cmd); 13006 default: 13007 send_resp(dut, conn, SIGMA_ERROR, 13008 "errorCode,Unsupported ap_set_rfeature with the current openwrt driver"); 13009 return 0; 13010 } 13011 case DRIVER_LINUX_WCN: 13012 case DRIVER_WCN: 13013 return wcn_ap_set_rfeature(dut, conn, cmd); 13014 case DRIVER_MAC80211: 13015 return mac80211_ap_set_rfeature(dut, conn, cmd); 13016 #ifdef __linux__ 13017 case DRIVER_WIL6210: 13018 return wil6210_ap_set_rfeature(dut, conn, cmd); 13019 #endif /* __linux__ */ 13020 default: 13021 send_resp(dut, conn, SIGMA_ERROR, 13022 "errorCode,Unsupported ap_set_rfeature with the current driver"); 13023 return 0; 13024 } 13025 } 13026 13027 13028 static enum sigma_cmd_result cmd_accesspoint(struct sigma_dut *dut, 13029 struct sigma_conn *conn, 13030 struct sigma_cmd *cmd) 13031 { 13032 /* const char *name = get_param(cmd, "NAME"); */ 13033 return 1; 13034 } 13035 13036 13037 static enum sigma_cmd_result 13038 cmd_ap_preset_testparameters(struct sigma_dut *dut, struct sigma_conn *conn, 13039 struct sigma_cmd *cmd) 13040 { 13041 const char *val; 13042 13043 val = get_param(cmd, "Oper_Chn"); 13044 if (val) { 13045 dut->ap_oper_chn = 1; 13046 dut->ap_channel = atoi(val); 13047 } 13048 13049 val = get_param(cmd, "DPPConfiguratorAddress"); 13050 if (val) { 13051 free(dut->ap_dpp_conf_addr); 13052 dut->ap_dpp_conf_addr = strdup(val); 13053 } 13054 13055 val = get_param(cmd, "DPPConfiguratorPKHash"); 13056 if (val) { 13057 free(dut->ap_dpp_conf_pkhash); 13058 dut->ap_dpp_conf_pkhash = strdup(val); 13059 } 13060 13061 return 1; 13062 } 13063 13064 13065 void ap_register_cmds(void) 13066 { 13067 sigma_dut_reg_cmd("ap_ca_version", NULL, cmd_ap_ca_version); 13068 sigma_dut_reg_cmd("ap_set_wireless", NULL, cmd_ap_set_wireless); 13069 sigma_dut_reg_cmd("ap_send_addba_req", NULL, cmd_ap_send_addba_req); 13070 sigma_dut_reg_cmd("ap_set_11n_wireless", NULL, cmd_ap_set_wireless); 13071 sigma_dut_reg_cmd("ap_set_11n", NULL, cmd_ap_set_wireless); 13072 sigma_dut_reg_cmd("ap_set_11d", NULL, cmd_ap_set_wireless); 13073 sigma_dut_reg_cmd("ap_set_11h", NULL, cmd_ap_set_wireless); 13074 sigma_dut_reg_cmd("ap_set_security", NULL, cmd_ap_set_security); 13075 sigma_dut_reg_cmd("ap_set_apqos", NULL, cmd_ap_set_apqos); 13076 sigma_dut_reg_cmd("ap_set_staqos", NULL, cmd_ap_set_staqos); 13077 sigma_dut_reg_cmd("ap_set_radius", NULL, cmd_ap_set_radius); 13078 sigma_dut_reg_cmd("ap_reboot", NULL, cmd_ap_reboot); 13079 sigma_dut_reg_cmd("ap_config_commit", NULL, cmd_ap_config_commit); 13080 sigma_dut_reg_cmd("ap_reset_default", NULL, cmd_ap_reset_default); 13081 sigma_dut_reg_cmd("ap_get_info", NULL, cmd_ap_get_info); 13082 sigma_dut_reg_cmd("ap_deauth_sta", NULL, cmd_ap_deauth_sta); 13083 sigma_dut_reg_cmd("ap_send_frame", NULL, cmd_ap_send_frame); 13084 sigma_dut_reg_cmd("ap_get_mac_address", NULL, cmd_ap_get_mac_address); 13085 sigma_dut_reg_cmd("ap_set_pmf", NULL, cmd_ap_set_pmf); 13086 sigma_dut_reg_cmd("ap_set_hs2", NULL, cmd_ap_set_hs2); 13087 sigma_dut_reg_cmd("ap_set_rfeature", NULL, cmd_ap_set_rfeature); 13088 sigma_dut_reg_cmd("ap_nfc_action", NULL, cmd_ap_nfc_action); 13089 sigma_dut_reg_cmd("ap_wps_read_pin", NULL, cmd_ap_wps_read_pin); 13090 sigma_dut_reg_cmd("ap_wps_enter_pin", NULL, cmd_ap_wps_enter_pin); 13091 sigma_dut_reg_cmd("ap_wps_set_pbc", NULL, cmd_ap_wps_set_pbc); 13092 sigma_dut_reg_cmd("ap_get_parameter", NULL, cmd_ap_get_parameter); 13093 sigma_dut_reg_cmd("AccessPoint", NULL, cmd_accesspoint); 13094 sigma_dut_reg_cmd("ap_preset_testparameters", NULL, 13095 cmd_ap_preset_testparameters); 13096 } 13097