Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Sigma Control API DUT (station/AP) |
| 3 | * Copyright (c) 2010-2011, Atheros Communications, Inc. |
Jouni Malinen | 9d7e31d | 2017-12-22 18:55:04 +0200 | [diff] [blame] | 4 | * Copyright (c) 2011-2017, Qualcomm Atheros, Inc. |
Jouni Malinen | 1370122 | 2019-02-19 12:10:53 +0200 | [diff] [blame] | 5 | * Copyright (c) 2018-2019, The Linux Foundation |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 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__ |
Adil Saeed Musthafa | 33ea287 | 2017-04-10 23:13:24 -0700 | [diff] [blame] | 16 | #include <limits.h> |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 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__ */ |
Alexei Avshalom Lazar | 2712cc8 | 2018-12-23 16:29:14 +0200 | [diff] [blame] | 26 | #include "wpa_ctrl.h" |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 27 | #include "wpa_helpers.h" |
| 28 | #ifdef ANDROID |
| 29 | #include <hardware_legacy/wifi.h> |
Veerendranath Jakkam | d7e0008 | 2018-04-25 19:46:01 +0530 | [diff] [blame] | 30 | #include <grp.h> |
| 31 | #include <pwd.h> |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 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 | |
Jouni Malinen | d6bf1b4 | 2017-06-23 17:51:01 +0300 | [diff] [blame] | 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 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 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 | |
Jouni Malinen | f7ff42b | 2018-05-01 00:21:56 +0300 | [diff] [blame] | 60 | #define ADV_OF_CHARGE_1 \ |
Jouni Malinen | 3001b43 | 2018-05-03 18:18:15 +0300 | [diff] [blame] | 61 | "bc01000000d200454e475553443c3f786d6c2076657273696f6e3d22312e30222065" \ |
Jouni Malinen | f7ff42b | 2018-05-01 00:21:56 +0300 | [diff] [blame] | 62 | "6e636f64696e673d225554462d38223f3e3c506c616e20786d6c6e733d22687474703a2f2f77" \ |
| 63 | "77772e77692d66692e6f72672f73706563696669636174696f6e732f686f7473706f7432646f" \ |
| 64 | "74302f76312e302f616f637069223e3c4465736372697074696f6e3e57692d46692061636365" \ |
| 65 | "737320666f72203120686f75722c207768696c6520796f752077616974206174207468652067" \ |
Jouni Malinen | 3001b43 | 2018-05-03 18:18:15 +0300 | [diff] [blame] | 66 | "6174652c2024302e39393c2f4465736372697074696f6e3e3c2f506c616e3ee3004652414341" \ |
Jouni Malinen | f7ff42b | 2018-05-01 00:21:56 +0300 | [diff] [blame] | 67 | "443c3f786d6c2076657273696f6e3d22312e302220656e636f64696e673d225554462d38223f" \ |
| 68 | "3e3c506c616e20786d6c6e733d22687474703a2f2f7777772e77692d66692e6f72672f737065" \ |
| 69 | "63696669636174696f6e732f686f7473706f7432646f74302f76312e302f616f637069223e3c" \ |
Jouni Malinen | 3001b43 | 2018-05-03 18:18:15 +0300 | [diff] [blame] | 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" |
Jouni Malinen | f7ff42b | 2018-05-01 00:21:56 +0300 | [diff] [blame] | 90 | |
Alexei Avshalom Lazar | 79f5727 | 2018-12-23 17:22:47 +0200 | [diff] [blame] | 91 | /* |
| 92 | * MTU for Ethernet need to take into account 8-byte SNAP header |
| 93 | * to be added when encapsulating Ethernet frame into 802.11. |
| 94 | */ |
| 95 | #ifndef IEEE80211_MAX_DATA_LEN_DMG |
| 96 | #define IEEE80211_MAX_DATA_LEN_DMG 7920 |
| 97 | #endif /* IEEE80211_MAX_DATA_LEN_DMG */ |
| 98 | #ifndef IEEE80211_SNAP_LEN_DMG |
| 99 | #define IEEE80211_SNAP_LEN_DMG 8 |
| 100 | #endif /* IEEE80211_SNAP_LEN_DMG */ |
| 101 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 102 | extern char *sigma_wpas_ctrl; |
| 103 | extern char *sigma_hapd_ctrl; |
| 104 | extern char *ap_inet_addr; |
| 105 | extern char *ap_inet_mask; |
| 106 | extern char *sigma_radio_ifname[]; |
| 107 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 108 | static int ath_ap_start_hostapd(struct sigma_dut *dut); |
| 109 | static void ath_ap_set_params(struct sigma_dut *dut); |
| 110 | static int kill_process(struct sigma_dut *dut, char *proc_name, |
| 111 | unsigned char is_proc_instance_one, int sig); |
| 112 | |
| 113 | |
Jouni Malinen | 6be21c8 | 2018-08-01 18:47:24 +0300 | [diff] [blame] | 114 | static int ap_ft_enabled(struct sigma_dut *dut) |
| 115 | { |
| 116 | return dut->ap_ft_oa == 1 || |
Jouni Malinen | 9f94331 | 2019-08-19 23:49:16 +0300 | [diff] [blame] | 117 | dut->ap_ft_ds == VALUE_ENABLED || |
Jouni Malinen | 6be21c8 | 2018-08-01 18:47:24 +0300 | [diff] [blame] | 118 | dut->ap_key_mgmt == AP_WPA2_FT_EAP || |
| 119 | dut->ap_key_mgmt == AP_WPA2_FT_PSK || |
Jouni Malinen | da5f35b | 2019-03-26 00:25:53 +0200 | [diff] [blame] | 120 | dut->ap_key_mgmt == AP_WPA2_ENT_FT_EAP || |
| 121 | (dut->ap_akm_values & |
| 122 | ((1 << AKM_FT_EAP) | |
| 123 | (1 << AKM_FT_PSK) | |
| 124 | (1 << AKM_FT_SAE) | |
| 125 | (1 << AKM_FT_SUITE_B) | |
| 126 | (1 << AKM_FT_FILS_SHA256) | |
| 127 | (1 << AKM_FT_FILS_SHA384))); |
Jouni Malinen | 6be21c8 | 2018-08-01 18:47:24 +0300 | [diff] [blame] | 128 | } |
| 129 | |
| 130 | |
Jouni Malinen | f722271 | 2019-06-13 01:50:21 +0300 | [diff] [blame] | 131 | static enum sigma_cmd_result cmd_ap_ca_version(struct sigma_dut *dut, |
| 132 | struct sigma_conn *conn, |
| 133 | struct sigma_cmd *cmd) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 134 | { |
| 135 | /* const char *name = get_param(cmd, "NAME"); */ |
| 136 | send_resp(dut, conn, SIGMA_COMPLETE, "version,1.0"); |
| 137 | return 0; |
| 138 | } |
| 139 | |
| 140 | |
Jouni Malinen | d6bf1b4 | 2017-06-23 17:51:01 +0300 | [diff] [blame] | 141 | static void kill_hostapd_process_pid(struct sigma_dut *dut) |
| 142 | { |
| 143 | FILE *f; |
| 144 | int pid, res; |
| 145 | char path[100]; |
| 146 | int count; |
| 147 | |
| 148 | f = fopen(SIGMA_DUT_HOSTAPD_PID_FILE, "r"); |
| 149 | if (!f) |
| 150 | return; |
| 151 | res = fscanf(f, "%d", &pid); |
| 152 | fclose(f); |
| 153 | if (res != 1) |
| 154 | return; |
| 155 | sigma_dut_print(dut, DUT_MSG_INFO, "Killing hostapd pid %d", pid); |
| 156 | kill(pid, SIGTERM); |
| 157 | snprintf(path, sizeof(path), "/proc/%d", pid); |
| 158 | for (count = 0; count < 20 && file_exists(path); count++) |
| 159 | usleep(100000); |
| 160 | } |
| 161 | |
| 162 | |
Jouni Malinen | 2e6ccc2 | 2017-09-04 13:43:16 +0300 | [diff] [blame] | 163 | int get_hwaddr(const char *ifname, unsigned char *hwaddr) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 164 | { |
| 165 | #ifndef __QNXNTO__ |
| 166 | struct ifreq ifr; |
| 167 | int s; |
| 168 | |
| 169 | s = socket(AF_INET, SOCK_DGRAM, 0); |
| 170 | if (s < 0) |
| 171 | return -1; |
| 172 | memset(&ifr, 0, sizeof(ifr)); |
Peng Xu | b8fc5cc | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 173 | strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name)); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 174 | if (ioctl(s, SIOCGIFHWADDR, &ifr) < 0) { |
| 175 | perror("ioctl"); |
| 176 | close(s); |
| 177 | return -1; |
| 178 | } |
| 179 | close(s); |
| 180 | memcpy(hwaddr, ifr.ifr_hwaddr.sa_data, 6); |
| 181 | #else /* __QNXNTO__ */ |
| 182 | struct ifaddrs *ifaddrshead = NULL; |
| 183 | int found = 0; |
| 184 | struct ifaddrs *temp_ifap = NULL; |
| 185 | struct sockaddr_dl *sdl = NULL; |
| 186 | |
| 187 | if (getifaddrs(&ifaddrshead) != 0) { |
| 188 | perror("getifaddrs failed"); |
| 189 | return -1; |
| 190 | } |
| 191 | |
| 192 | for (temp_ifap = ifaddrshead; ifaddrshead && !found; |
| 193 | ifaddrshead = ifaddrshead->ifa_next) { |
| 194 | if (ifaddrshead->ifa_addr->sa_family == AF_LINK && |
| 195 | strcmp(ifaddrshead->ifa_name, ifname) == 0) { |
| 196 | found = 1; |
| 197 | sdl = (struct sockaddr_dl *) ifaddrshead->ifa_addr; |
| 198 | if (sdl) |
| 199 | memcpy(hwaddr, LLADDR(sdl), sdl->sdl_alen); |
| 200 | } |
| 201 | } |
| 202 | |
| 203 | if (temp_ifap) |
| 204 | freeifaddrs(temp_ifap); |
| 205 | |
| 206 | if (!found) { |
| 207 | perror("Failed to get the interface"); |
| 208 | return -1; |
| 209 | } |
| 210 | #endif /* __QNXNTO__ */ |
| 211 | return 0; |
| 212 | } |
| 213 | |
| 214 | |
| 215 | static void ath_ap_set_group_id(struct sigma_dut *dut, const char *ifname, |
| 216 | const char *val) |
| 217 | { |
| 218 | char buf[60]; |
| 219 | |
| 220 | snprintf(buf, sizeof(buf), "wifitool %s beeliner_fw_test 55 %d", |
| 221 | ifname, atoi(val)); |
| 222 | if (system(buf) != 0) { |
| 223 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 224 | "wifitool ap_group_id failed"); |
| 225 | } |
| 226 | } |
| 227 | |
| 228 | |
| 229 | void ath_set_cts_width(struct sigma_dut *dut, const char *ifname, |
| 230 | const char *val) |
| 231 | { |
| 232 | char buf[60]; |
| 233 | |
| 234 | /* TODO: Enable support for other values */ |
| 235 | if (strcasecmp(val, "40") == 0) { |
| 236 | snprintf(buf, sizeof(buf), "wifitool %s beeliner_fw_test 54 1", |
| 237 | ifname); |
| 238 | if (system(buf) != 0) { |
| 239 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 240 | "wifitool cts_width failed"); |
| 241 | } |
Priyadharshini Gowthaman | 818afef | 2015-11-09 13:28:15 -0800 | [diff] [blame] | 242 | snprintf(buf, sizeof(buf), |
| 243 | "athdiag --set --address=0x10024 --val=0xd90b8a14"); |
| 244 | if (system(buf) != 0) { |
| 245 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 246 | "disabling phy restart failed"); |
| 247 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 248 | } else { |
| 249 | sigma_dut_print(dut, DUT_MSG_ERROR, "Unsupported CTS_WIDTH"); |
| 250 | } |
| 251 | } |
| 252 | |
| 253 | |
Priyadharshini Gowthaman | 818afef | 2015-11-09 13:28:15 -0800 | [diff] [blame] | 254 | void ath_config_dyn_bw_sig(struct sigma_dut *dut, const char *ifname, |
| 255 | const char *val) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 256 | { |
| 257 | char buf[60]; |
| 258 | |
| 259 | if (strcasecmp(val, "enable") == 0) { |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 260 | dut->ap_dyn_bw_sig = VALUE_ENABLED; |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 261 | run_iwpriv(dut, ifname, "cwmenable 1"); |
| 262 | |
Priyadharshini Gowthaman | 818afef | 2015-11-09 13:28:15 -0800 | [diff] [blame] | 263 | snprintf(buf, sizeof(buf), "wifitool %s beeliner_fw_test 96 1", |
| 264 | ifname); |
| 265 | if (system(buf) != 0) { |
| 266 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 267 | "disabling RTS from rate control logic failed"); |
| 268 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 269 | } else if (strcasecmp(val, "disable") == 0) { |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 270 | dut->ap_dyn_bw_sig = VALUE_DISABLED; |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 271 | run_iwpriv(dut, ifname, "cwmenable 0"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 272 | } else { |
| 273 | sigma_dut_print(dut, DUT_MSG_ERROR, "Unsupported DYN_BW_SGL"); |
| 274 | } |
| 275 | } |
| 276 | |
| 277 | |
| 278 | static void ath_config_rts_force(struct sigma_dut *dut, const char *ifname, |
| 279 | const char *val) |
| 280 | { |
| 281 | char buf[60]; |
| 282 | |
| 283 | if (strcasecmp(val, "enable") == 0) { |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 284 | dut->ap_sig_rts = VALUE_ENABLED; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 285 | snprintf(buf, sizeof(buf), "iwconfig %s rts 64", ifname); |
| 286 | if (system(buf) != 0) { |
| 287 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 288 | "iwconfig rts 64 failed"); |
| 289 | } |
priyadharshini gowthaman | 270870e | 2015-12-09 10:10:23 -0800 | [diff] [blame] | 290 | snprintf(buf, sizeof(buf), "wifitool %s beeliner_fw_test 100 1", |
| 291 | ifname); |
| 292 | if (system(buf) != 0) { |
| 293 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 294 | "wifitool beeliner_fw_test 100 1 failed"); |
| 295 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 296 | } else if (strcasecmp(val, "disable") == 0) { |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 297 | dut->ap_sig_rts = VALUE_DISABLED; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 298 | snprintf(buf, sizeof(buf), "iwconfig %s rts 2347", ifname); |
| 299 | if (system(buf) != 0) { |
| 300 | sigma_dut_print(dut, DUT_MSG_ERROR, |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 301 | "iwconfig rts 2347 failed"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 302 | } |
| 303 | } else { |
| 304 | sigma_dut_print(dut, DUT_MSG_ERROR, "Unsupported RTS_FORCE"); |
| 305 | } |
| 306 | } |
| 307 | |
| 308 | |
priyadharshini gowthaman | 09d613e | 2017-12-20 11:43:44 -0800 | [diff] [blame] | 309 | static void ath_radio(struct sigma_dut *dut, const char *val) |
| 310 | { |
| 311 | if (strcasecmp(val, "on") == 0) { |
| 312 | if (dut->ap_interface_5g == 1) { |
| 313 | run_system(dut, "uci set wireless.wifi0.disabled=0"); |
| 314 | } else if (dut->ap_interface_2g == 1) { |
| 315 | run_system(dut, "uci set wireless.wifi1.disabled=0"); |
| 316 | } else { |
| 317 | run_system(dut, "uci set wireless.wifi0.disabled=0"); |
| 318 | run_system(dut, "uci set wireless.wifi1.disabled=0"); |
| 319 | } |
| 320 | run_system(dut, "uci commit"); |
| 321 | run_system(dut, "wifi down"); |
| 322 | run_system(dut, "wifi up"); |
| 323 | } else if (strcasecmp(val, "off") == 0) { |
| 324 | if (dut->ap_interface_5g == 1) { |
| 325 | run_system(dut, "uci set wireless.wifi0.disabled=1"); |
| 326 | } else if (dut->ap_interface_2g == 1) { |
| 327 | run_system(dut, "uci set wireless.wifi1.disabled=1"); |
| 328 | } else { |
| 329 | run_system(dut, "uci set wireless.wifi0.disabled=1"); |
| 330 | run_system(dut, "uci set wireless.wifi1.disabled=1"); |
| 331 | } |
| 332 | run_system(dut, "uci commit"); |
| 333 | run_system(dut, "wifi down"); |
| 334 | run_system(dut, "wifi up"); |
| 335 | } |
| 336 | } |
| 337 | |
| 338 | |
priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 339 | static void deauth_disassoc(struct sigma_dut *dut, const char *ifname, |
| 340 | const char *val) |
| 341 | { |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 342 | if (strcasecmp(val, "disable") == 0) |
| 343 | run_iwpriv(dut, ifname, "stealthdown 1"); |
priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 344 | } |
| 345 | |
| 346 | |
priyadharshini gowthaman | cb22e43 | 2017-12-28 15:23:31 -0800 | [diff] [blame] | 347 | static void ath_set_txpower(struct sigma_dut *dut, const char *ifname, |
| 348 | const char *val) |
| 349 | { |
| 350 | char buf[60]; |
| 351 | |
| 352 | if (strcasecmp(val, "high") == 0) |
| 353 | snprintf(buf, sizeof(buf), "iwconfig %s txpower 29", ifname); |
| 354 | else if (strcasecmp(val, "low") == 0) |
| 355 | snprintf(buf, sizeof(buf), "iwconfig %s txpower 1", ifname); |
| 356 | else |
| 357 | sigma_dut_print(dut, DUT_MSG_ERROR, "Unsupported txpower"); |
| 358 | |
| 359 | if (system(buf) != 0) |
| 360 | sigma_dut_print(dut, DUT_MSG_ERROR, "setting txpower failed"); |
| 361 | } |
| 362 | |
| 363 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 364 | static enum ap_mode get_mode(const char *str) |
| 365 | { |
| 366 | if (strcasecmp(str, "11a") == 0) |
| 367 | return AP_11a; |
| 368 | else if (strcasecmp(str, "11g") == 0) |
| 369 | return AP_11g; |
| 370 | else if (strcasecmp(str, "11b") == 0) |
| 371 | return AP_11b; |
| 372 | else if (strcasecmp(str, "11na") == 0) |
| 373 | return AP_11na; |
| 374 | else if (strcasecmp(str, "11ng") == 0) |
| 375 | return AP_11ng; |
| 376 | else if (strcasecmp(str, "11ac") == 0 || strcasecmp(str, "ac") == 0) |
| 377 | return AP_11ac; |
Alexei Avshalom Lazar | 2712cc8 | 2018-12-23 16:29:14 +0200 | [diff] [blame] | 378 | else if (strcasecmp(str, "11ad") == 0) |
| 379 | return AP_11ad; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 380 | else |
| 381 | return AP_inval; |
| 382 | } |
| 383 | |
| 384 | |
| 385 | static int run_hostapd_cli(struct sigma_dut *dut, char *buf) |
| 386 | { |
| 387 | char command[1000]; |
| 388 | const char *bin; |
Jouni Malinen | 016ae6c | 2019-11-04 17:00:01 +0200 | [diff] [blame] | 389 | enum driver_type drv = get_driver_type(dut); |
Adil Saeed Musthafa | 3dd6ca7 | 2017-05-15 12:45:18 -0700 | [diff] [blame] | 390 | char *sigma_hapd_file = sigma_hapd_ctrl; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 391 | |
| 392 | if (file_exists("hostapd_cli")) |
| 393 | bin = "./hostapd_cli"; |
Jouni Malinen | d6bf1b4 | 2017-06-23 17:51:01 +0300 | [diff] [blame] | 394 | else if (file_exists("../../hostapd/hostapd_cli")) |
| 395 | bin = "../../hostapd/hostapd_cli"; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 396 | else |
| 397 | bin = "hostapd_cli"; |
| 398 | |
| 399 | if (drv == DRIVER_OPENWRT && sigma_hapd_ctrl == NULL) { |
Adil Saeed Musthafa | 3dd6ca7 | 2017-05-15 12:45:18 -0700 | [diff] [blame] | 400 | sigma_hapd_file = "/var/run/hostapd-wifi0"; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 401 | |
| 402 | if (sigma_radio_ifname[0] && |
| 403 | strcmp(sigma_radio_ifname[0], "wifi1") == 0) |
Adil Saeed Musthafa | 3dd6ca7 | 2017-05-15 12:45:18 -0700 | [diff] [blame] | 404 | sigma_hapd_file = "/var/run/hostapd-wifi1"; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 405 | else if (sigma_radio_ifname[0] && |
| 406 | strcmp(sigma_radio_ifname[0], "wifi2") == 0) |
Adil Saeed Musthafa | 3dd6ca7 | 2017-05-15 12:45:18 -0700 | [diff] [blame] | 407 | sigma_hapd_file = "/var/run/hostapd-wifi2"; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 408 | } |
| 409 | |
Adil Saeed Musthafa | 3dd6ca7 | 2017-05-15 12:45:18 -0700 | [diff] [blame] | 410 | if (sigma_hapd_file) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 411 | snprintf(command, sizeof(command), "%s -p %s %s", |
Adil Saeed Musthafa | 3dd6ca7 | 2017-05-15 12:45:18 -0700 | [diff] [blame] | 412 | bin, sigma_hapd_file, buf); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 413 | else |
| 414 | snprintf(command, sizeof(command), "%s %s", bin, buf); |
| 415 | return run_system(dut, command); |
| 416 | } |
| 417 | |
| 418 | |
priyadharshini gowthaman | 8e26ff4 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 419 | static int ath_set_lci_config(struct sigma_dut *dut, const char *val, |
| 420 | struct sigma_cmd *cmd) |
| 421 | { |
| 422 | FILE *f; |
| 423 | int i; |
| 424 | |
| 425 | f = fopen("/tmp/lci_cfg.txt", "w"); |
| 426 | if (!f) { |
| 427 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 428 | "Failed to open /tmp/lci_cfg.txt"); |
| 429 | return -1; |
| 430 | } |
| 431 | |
| 432 | for (i = 2; i < cmd->count; i++) |
| 433 | fprintf(f, "%s = %s \n", cmd->params[i], cmd->values[i]); |
| 434 | fprintf(f, "\n"); |
| 435 | fclose(f); |
| 436 | |
| 437 | return 0; |
| 438 | } |
| 439 | |
| 440 | |
hangtian | 0060662 | 2019-04-19 11:15:48 +0800 | [diff] [blame] | 441 | static void set_ap_country_code(struct sigma_dut *dut) |
| 442 | { |
| 443 | #if defined(ANDROID) || defined(LINUX_EMBEDDED) |
| 444 | char buf[256]; |
| 445 | |
| 446 | if (dut->ap_countrycode[0]) { |
| 447 | snprintf(buf, sizeof(buf), "DRIVER COUNTRY %s", |
| 448 | dut->ap_countrycode); |
Jouni Malinen | 016ae6c | 2019-11-04 17:00:01 +0200 | [diff] [blame] | 449 | if (wpa_command(get_station_ifname(dut), buf) < 0) |
hangtian | 0060662 | 2019-04-19 11:15:48 +0800 | [diff] [blame] | 450 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 451 | "Failed to set country code"); |
| 452 | else |
| 453 | sigma_dut_print(dut, DUT_MSG_INFO, |
| 454 | "Successfully set country code to %s", |
| 455 | dut->ap_countrycode); |
| 456 | } |
| 457 | #endif |
| 458 | } |
| 459 | |
| 460 | |
Jouni Malinen | f722271 | 2019-06-13 01:50:21 +0300 | [diff] [blame] | 461 | static enum sigma_cmd_result cmd_ap_set_wireless(struct sigma_dut *dut, |
| 462 | struct sigma_conn *conn, |
| 463 | struct sigma_cmd *cmd) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 464 | { |
| 465 | /* const char *name = get_param(cmd, "NAME"); */ |
| 466 | /* const char *ifname = get_param(cmd, "INTERFACE"); */ |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 467 | const char *val; |
| 468 | unsigned int wlan_tag = 1; |
Jouni Malinen | 016ae6c | 2019-11-04 17:00:01 +0200 | [diff] [blame] | 469 | const char *ifname = get_main_ifname(dut); |
Alexei Avshalom Lazar | 79f5727 | 2018-12-23 17:22:47 +0200 | [diff] [blame] | 470 | char buf[128]; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 471 | |
Alexei Avshalom Lazar | 2712cc8 | 2018-12-23 16:29:14 +0200 | [diff] [blame] | 472 | /* Allow program to be overridden if specified in the ap_set_wireless |
| 473 | * to support some 60 GHz test scripts where the program may be 60 GHz |
| 474 | * or WPS. */ |
| 475 | val = get_param(cmd, "PROGRAM"); |
| 476 | if (val) |
| 477 | dut->program = sigma_program_to_enum(val); |
| 478 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 479 | val = get_param(cmd, "WLAN_TAG"); |
| 480 | if (val) { |
| 481 | wlan_tag = atoi(val); |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 482 | if (wlan_tag < 1 || wlan_tag > 3) { |
| 483 | /* |
| 484 | * The only valid WLAN Tags as of now as per the latest |
| 485 | * WFA scripts are 1, 2, and 3. |
| 486 | */ |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 487 | send_resp(dut, conn, SIGMA_INVALID, |
| 488 | "errorCode,Invalid WLAN_TAG"); |
Jouni Malinen | dccfd0c | 2019-10-30 12:05:59 +0200 | [diff] [blame] | 489 | return STATUS_SENT; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 490 | } |
| 491 | } |
| 492 | |
priyadharshini gowthaman | 09d613e | 2017-12-20 11:43:44 -0800 | [diff] [blame] | 493 | val = get_param(cmd, "Interface"); |
| 494 | if (val) { |
| 495 | if (strcasecmp(val, "5G") == 0) |
| 496 | dut->ap_interface_5g = 1; |
| 497 | else |
| 498 | dut->ap_interface_2g = 1; |
| 499 | |
| 500 | if (dut->ap_interface_5g && dut->ap_interface_2g) |
| 501 | dut->ap_is_dual = 1; |
| 502 | } |
| 503 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 504 | val = get_param(cmd, "CountryCode"); |
| 505 | if (val) { |
| 506 | if (strlen(val) > sizeof(dut->ap_countrycode) - 1) |
Jouni Malinen | dccfd0c | 2019-10-30 12:05:59 +0200 | [diff] [blame] | 507 | return INVALID_SEND_STATUS; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 508 | snprintf(dut->ap_countrycode, sizeof(dut->ap_countrycode), |
| 509 | "%s", val); |
hangtian | 0060662 | 2019-04-19 11:15:48 +0800 | [diff] [blame] | 510 | |
| 511 | /* |
| 512 | * Regdomain self-managed driver does not accept hostapd country |
| 513 | * code setting in all cases. Try to use wpa_supplicant DRIVER |
| 514 | * command first to set the driver to a specific country code |
| 515 | * before starting AP functionality. This is targeting cases |
| 516 | * where wpa_supplicant is running on the device as well for |
| 517 | * non-AP mode functionality. |
| 518 | */ |
Jouni Malinen | 016ae6c | 2019-11-04 17:00:01 +0200 | [diff] [blame] | 519 | if (get_driver_type(dut) == DRIVER_LINUX_WCN) |
hangtian | 0060662 | 2019-04-19 11:15:48 +0800 | [diff] [blame] | 520 | set_ap_country_code(dut); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 521 | } |
| 522 | |
Pradeep Reddy POTTETI | fba27db | 2015-11-20 16:42:22 +0530 | [diff] [blame] | 523 | val = get_param(cmd, "regulatory_mode"); |
| 524 | if (val) { |
| 525 | if (strcasecmp(val, "11d") == 0 || strcasecmp(val, "11h") == 0) |
| 526 | dut->ap_regulatory_mode = AP_80211D_MODE_ENABLED; |
| 527 | } |
| 528 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 529 | val = get_param(cmd, "SSID"); |
| 530 | if (val) { |
| 531 | if (strlen(val) > sizeof(dut->ap_ssid) - 1) |
Jouni Malinen | dccfd0c | 2019-10-30 12:05:59 +0200 | [diff] [blame] | 532 | return INVALID_SEND_STATUS; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 533 | |
| 534 | if (wlan_tag == 1) { |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 535 | /* |
| 536 | * If tag is not specified, it is deemed to be 1. |
| 537 | * Hence tag of 1 is a special case and the values |
| 538 | * corresponding to wlan-tag=1 are stored separately |
| 539 | * from the values corresponding tags 2 and 3. |
| 540 | * This approach minimises the changes to existing code |
| 541 | * since most of the sigma_dut code does not deal with |
| 542 | * WLAN-TAG CAPI variable. |
| 543 | */ |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 544 | snprintf(dut->ap_ssid, |
| 545 | sizeof(dut->ap_ssid), "%s", val); |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 546 | } else { |
| 547 | snprintf(dut->ap_tag_ssid[wlan_tag - 2], |
| 548 | sizeof(dut->ap_tag_ssid[wlan_tag - 2]), |
| 549 | "%s", val); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 550 | } |
| 551 | } |
| 552 | |
| 553 | val = get_param(cmd, "CHANNEL"); |
| 554 | if (val) { |
| 555 | const char *pos; |
| 556 | dut->ap_channel = atoi(val); |
| 557 | pos = strchr(val, ';'); |
| 558 | if (pos) { |
| 559 | pos++; |
| 560 | dut->ap_channel_1 = atoi(pos); |
| 561 | } |
| 562 | } |
| 563 | |
Pradeep Reddy POTTETI | fba27db | 2015-11-20 16:42:22 +0530 | [diff] [blame] | 564 | /* Overwrite the AP channel with DFS channel if configured */ |
| 565 | val = get_param(cmd, "dfs_chan"); |
| 566 | if (val) { |
| 567 | dut->ap_channel = atoi(val); |
| 568 | } |
| 569 | |
| 570 | val = get_param(cmd, "dfs_mode"); |
| 571 | if (val) { |
| 572 | if (strcasecmp(val, "Enable") == 0) |
| 573 | dut->ap_dfs_mode = AP_DFS_MODE_ENABLED; |
| 574 | else if (strcasecmp(val, "Disable") == 0) |
| 575 | dut->ap_dfs_mode = AP_DFS_MODE_DISABLED; |
| 576 | else |
| 577 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 578 | "Unsupported dfs_mode value: %s", val); |
| 579 | } |
| 580 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 581 | val = get_param(cmd, "MODE"); |
| 582 | if (val) { |
| 583 | char *str, *pos; |
| 584 | |
| 585 | str = strdup(val); |
| 586 | if (str == NULL) |
Jouni Malinen | dccfd0c | 2019-10-30 12:05:59 +0200 | [diff] [blame] | 587 | return INVALID_SEND_STATUS; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 588 | pos = strchr(str, ';'); |
| 589 | if (pos) |
| 590 | *pos++ = '\0'; |
| 591 | |
| 592 | dut->ap_is_dual = 0; |
| 593 | dut->ap_mode = get_mode(str); |
| 594 | if (dut->ap_mode == AP_inval) { |
| 595 | send_resp(dut, conn, SIGMA_INVALID, |
| 596 | "errorCode,Unsupported MODE"); |
| 597 | free(str); |
Jouni Malinen | dccfd0c | 2019-10-30 12:05:59 +0200 | [diff] [blame] | 598 | return STATUS_SENT; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 599 | } |
priyadharshini gowthaman | 63ab848 | 2017-12-28 15:32:55 -0800 | [diff] [blame] | 600 | if (dut->ap_mode == AP_11ac && dut->ap_80plus80 != 1) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 601 | dut->ap_chwidth = AP_80; |
| 602 | |
| 603 | if (pos) { |
| 604 | dut->ap_mode_1 = get_mode(pos); |
| 605 | if (dut->ap_mode_1 == AP_inval) { |
| 606 | send_resp(dut, conn, SIGMA_INVALID, |
| 607 | "errorCode,Unsupported MODE"); |
| 608 | free(str); |
Jouni Malinen | dccfd0c | 2019-10-30 12:05:59 +0200 | [diff] [blame] | 609 | return STATUS_SENT; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 610 | } |
| 611 | if (dut->ap_mode_1 == AP_11ac) |
| 612 | dut->ap_chwidth_1 = AP_80; |
| 613 | dut->ap_is_dual = 1; |
| 614 | } |
| 615 | |
| 616 | free(str); |
| 617 | } else if (dut->ap_mode == AP_inval) { |
| 618 | if (dut->ap_channel <= 11) |
| 619 | dut->ap_mode = AP_11ng; |
| 620 | else if (dut->program == PROGRAM_VHT) |
| 621 | dut->ap_mode = AP_11ac; |
| 622 | else |
| 623 | dut->ap_mode = AP_11na; |
| 624 | } |
| 625 | |
Alexei Avshalom Lazar | 2712cc8 | 2018-12-23 16:29:14 +0200 | [diff] [blame] | 626 | /* Override the AP mode in case of 60 GHz */ |
| 627 | if (dut->program == PROGRAM_60GHZ) { |
| 628 | dut->ap_mode = AP_11ad; |
| 629 | /* Workaround to force channel 2 if not specified */ |
| 630 | if (!dut->ap_channel) |
| 631 | dut->ap_channel = 2; |
| 632 | } |
| 633 | |
Pradeep Reddy POTTETI | 0d3db63 | 2016-03-11 15:21:11 +0530 | [diff] [blame] | 634 | val = get_param(cmd, "WME"); |
| 635 | if (val) { |
| 636 | if (strcasecmp(val, "on") == 0) |
| 637 | dut->ap_wme = AP_WME_ON; |
| 638 | else if (strcasecmp(val, "off") == 0) |
| 639 | dut->ap_wme = AP_WME_OFF; |
| 640 | else |
| 641 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 642 | "Unsupported WME value: %s", val); |
| 643 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 644 | |
Mohammed Shafi Shajakhan | 02e3b82 | 2017-02-23 04:15:02 +0530 | [diff] [blame] | 645 | val = get_param(cmd, "WMMPS"); |
| 646 | if (val) { |
| 647 | if (strcasecmp(val, "on") == 0) |
| 648 | dut->ap_wmmps = AP_WMMPS_ON; |
| 649 | else if (strcasecmp(val, "off") == 0) |
| 650 | dut->ap_wmmps = AP_WMMPS_OFF; |
| 651 | else |
| 652 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 653 | "Unsupported WMMPS value: %s", val); |
| 654 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 655 | |
| 656 | val = get_param(cmd, "RTS"); |
| 657 | if (val) |
| 658 | dut->ap_rts = atoi(val); |
| 659 | |
| 660 | val = get_param(cmd, "FRGMNT"); |
| 661 | if (val) |
| 662 | dut->ap_frgmnt = atoi(val); |
| 663 | |
| 664 | /* TODO: PWRSAVE */ |
| 665 | |
| 666 | val = get_param(cmd, "BCNINT"); |
| 667 | if (val) |
| 668 | dut->ap_bcnint = atoi(val); |
| 669 | |
| 670 | val = get_param(cmd, "RADIO"); |
| 671 | if (val) { |
Jouni Malinen | 016ae6c | 2019-11-04 17:00:01 +0200 | [diff] [blame] | 672 | enum driver_type drv = get_driver_type(dut); |
Mohammed Shafi Shajakhan | 94997f9 | 2017-01-09 21:31:09 +0530 | [diff] [blame] | 673 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 674 | if (strcasecmp(val, "on") == 0) { |
priyadharshini gowthaman | 09d613e | 2017-12-20 11:43:44 -0800 | [diff] [blame] | 675 | if (drv == DRIVER_OPENWRT) |
| 676 | ath_radio(dut, val); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 677 | if (drv == DRIVER_ATHEROS) |
| 678 | ath_ap_start_hostapd(dut); |
| 679 | else if (cmd_ap_config_commit(dut, conn, cmd) <= 0) |
Jouni Malinen | dccfd0c | 2019-10-30 12:05:59 +0200 | [diff] [blame] | 680 | return STATUS_SENT; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 681 | } else if (strcasecmp(val, "off") == 0) { |
Mohammed Shafi Shajakhan | 94997f9 | 2017-01-09 21:31:09 +0530 | [diff] [blame] | 682 | if (drv == DRIVER_OPENWRT) { |
priyadharshini gowthaman | 09d613e | 2017-12-20 11:43:44 -0800 | [diff] [blame] | 683 | ath_radio(dut, val); |
Jouni Malinen | d6bf1b4 | 2017-06-23 17:51:01 +0300 | [diff] [blame] | 684 | } else if (dut->use_hostapd_pid_file) { |
| 685 | kill_hostapd_process_pid(dut); |
Mohammed Shafi Shajakhan | 94997f9 | 2017-01-09 21:31:09 +0530 | [diff] [blame] | 686 | } else if (kill_process(dut, "(hostapd)", 1, |
| 687 | SIGTERM) == 0 || |
| 688 | system("killall hostapd") == 0) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 689 | sigma_dut_print(dut, DUT_MSG_INFO, |
| 690 | "Killed hostapd on radio,off"); |
| 691 | } |
| 692 | } else { |
| 693 | send_resp(dut, conn, SIGMA_INVALID, |
| 694 | "errorCode,Unsupported RADIO value"); |
Jouni Malinen | dccfd0c | 2019-10-30 12:05:59 +0200 | [diff] [blame] | 695 | return STATUS_SENT; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 696 | } |
| 697 | } |
| 698 | |
| 699 | val = get_param(cmd, "P2PMgmtBit"); |
| 700 | if (val) |
| 701 | dut->ap_p2p_mgmt = atoi(val); |
| 702 | |
| 703 | /* TODO: ChannelUsage */ |
| 704 | |
| 705 | /* TODO: 40_INTOLERANT */ |
| 706 | |
| 707 | val = get_param(cmd, "ADDBA_REJECT"); |
| 708 | if (val) { |
| 709 | if (strcasecmp(val, "Enable") == 0) |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 710 | dut->ap_addba_reject = VALUE_ENABLED; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 711 | else if (strcasecmp(val, "Disable") == 0) |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 712 | dut->ap_addba_reject = VALUE_DISABLED; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 713 | } |
| 714 | |
| 715 | val = get_param(cmd, "AMPDU"); |
| 716 | if (val) { |
| 717 | if (strcasecmp(val, "Enable") == 0) |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 718 | dut->ap_ampdu = VALUE_ENABLED; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 719 | else if (strcasecmp(val, "Disable") == 0) |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 720 | dut->ap_ampdu = VALUE_DISABLED; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 721 | } |
| 722 | |
| 723 | val = get_param(cmd, "AMPDU_EXP"); |
| 724 | if (val) |
| 725 | dut->ap_ampdu_exp = atoi(val); |
| 726 | |
| 727 | val = get_param(cmd, "AMSDU"); |
| 728 | if (val) { |
| 729 | if (strcasecmp(val, "Enable") == 0) |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 730 | dut->ap_amsdu = VALUE_ENABLED; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 731 | else if (strcasecmp(val, "Disable") == 0) |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 732 | dut->ap_amsdu = VALUE_DISABLED; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 733 | } |
| 734 | |
| 735 | val = get_param(cmd, "NoAck"); |
| 736 | if (val) { |
| 737 | if (strcasecmp(val, "on") == 0) |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 738 | dut->ap_noack = VALUE_ENABLED; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 739 | else if (strcasecmp(val, "off") == 0) |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 740 | dut->ap_noack = VALUE_DISABLED; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 741 | } |
| 742 | |
| 743 | /* TODO: GREENFIELD */ |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 744 | /* TODO: MCS_32 */ |
| 745 | |
Pradeep Reddy Potteti | 4b0cdee | 2017-03-15 12:37:33 +0530 | [diff] [blame] | 746 | val = get_param(cmd, "OFFSET"); |
| 747 | if (val) { |
| 748 | if (strcasecmp(val, "Above") == 0) |
| 749 | dut->ap_chwidth_offset = SEC_CH_40ABOVE; |
| 750 | else if (strcasecmp(val, "Below") == 0) |
| 751 | dut->ap_chwidth_offset = SEC_CH_40BELOW; |
| 752 | } |
| 753 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 754 | val = get_param(cmd, "MCS_FIXEDRATE"); |
| 755 | if (val) { |
| 756 | dut->ap_fixed_rate = 1; |
| 757 | dut->ap_mcs = atoi(val); |
| 758 | } |
| 759 | |
| 760 | val = get_param(cmd, "SPATIAL_RX_STREAM"); |
| 761 | if (val) { |
| 762 | if (strcasecmp(val, "1SS") == 0 || strcasecmp(val, "1") == 0) { |
| 763 | dut->ap_rx_streams = 1; |
| 764 | if (dut->device_type == AP_testbed) |
| 765 | dut->ap_vhtmcs_map = 0xfffc; |
| 766 | } else if (strcasecmp(val, "2SS") == 0 || |
| 767 | strcasecmp(val, "2") == 0) { |
| 768 | dut->ap_rx_streams = 2; |
| 769 | if (dut->device_type == AP_testbed) |
| 770 | dut->ap_vhtmcs_map = 0xfff0; |
| 771 | } else if (strcasecmp(val, "3SS") == 0 || |
| 772 | strcasecmp(val, "3") == 0) { |
| 773 | dut->ap_rx_streams = 3; |
| 774 | if (dut->device_type == AP_testbed) |
| 775 | dut->ap_vhtmcs_map = 0xffc0; |
| 776 | } else if (strcasecmp(val, "4SS") == 0 || |
| 777 | strcasecmp(val, "4") == 0) { |
| 778 | dut->ap_rx_streams = 4; |
| 779 | } |
| 780 | } |
| 781 | |
| 782 | val = get_param(cmd, "SPATIAL_TX_STREAM"); |
| 783 | if (val) { |
| 784 | if (strcasecmp(val, "1SS") == 0 || |
| 785 | strcasecmp(val, "1") == 0) { |
| 786 | dut->ap_tx_streams = 1; |
| 787 | if (dut->device_type == AP_testbed) |
| 788 | dut->ap_vhtmcs_map = 0xfffc; |
| 789 | } else if (strcasecmp(val, "2SS") == 0 || |
| 790 | strcasecmp(val, "2") == 0) { |
| 791 | dut->ap_tx_streams = 2; |
| 792 | if (dut->device_type == AP_testbed) |
| 793 | dut->ap_vhtmcs_map = 0xfff0; |
| 794 | } else if (strcasecmp(val, "3SS") == 0 || |
| 795 | strcasecmp(val, "3") == 0) { |
| 796 | dut->ap_tx_streams = 3; |
| 797 | if (dut->device_type == AP_testbed) |
| 798 | dut->ap_vhtmcs_map = 0xffc0; |
| 799 | } else if (strcasecmp(val, "4SS") == 0 || |
| 800 | strcasecmp(val, "4") == 0) { |
| 801 | dut->ap_tx_streams = 4; |
| 802 | } |
| 803 | } |
| 804 | |
Adil Saeed Musthafa | 33ea287 | 2017-04-10 23:13:24 -0700 | [diff] [blame] | 805 | val = get_param(cmd, "BSS_max_idle"); |
| 806 | if (val) { |
| 807 | if (strncasecmp(val, "Enable", 7) == 0) { |
| 808 | dut->wnm_bss_max_feature = VALUE_ENABLED; |
| 809 | } else if (strncasecmp(val, "Disable", 8) == 0) { |
| 810 | dut->wnm_bss_max_feature = VALUE_DISABLED; |
| 811 | } else { |
| 812 | send_resp(dut, conn, SIGMA_ERROR, |
| 813 | "errorCode,Invalid value for BSS_max_Feature"); |
Jouni Malinen | dccfd0c | 2019-10-30 12:05:59 +0200 | [diff] [blame] | 814 | return STATUS_SENT; |
Adil Saeed Musthafa | 33ea287 | 2017-04-10 23:13:24 -0700 | [diff] [blame] | 815 | } |
| 816 | } |
| 817 | |
| 818 | val = get_param(cmd, "BSS_Idle_Protection_options"); |
| 819 | if (val) { |
| 820 | int protection = (int) strtol(val, (char **) NULL, 10); |
| 821 | |
| 822 | if (protection != 1 && protection != 0) { |
| 823 | send_resp(dut, conn, SIGMA_ERROR, |
| 824 | "errorCode,Invalid value for BSS_Idle_Protection_options"); |
Jouni Malinen | dccfd0c | 2019-10-30 12:05:59 +0200 | [diff] [blame] | 825 | return STATUS_SENT; |
Adil Saeed Musthafa | 33ea287 | 2017-04-10 23:13:24 -0700 | [diff] [blame] | 826 | } |
| 827 | dut->wnm_bss_max_protection = protection ? |
| 828 | VALUE_ENABLED : VALUE_DISABLED; |
| 829 | } |
| 830 | |
| 831 | val = get_param(cmd, "BSS_max_Idle_period"); |
| 832 | if (val) { |
Jouni Malinen | 544edf0 | 2019-02-25 19:02:33 +0200 | [diff] [blame] | 833 | long int idle_time = strtol(val, (char **) NULL, 10); |
Adil Saeed Musthafa | 33ea287 | 2017-04-10 23:13:24 -0700 | [diff] [blame] | 834 | |
| 835 | if (idle_time == LONG_MIN || idle_time == LONG_MAX) { |
| 836 | send_resp(dut, conn, SIGMA_ERROR, |
| 837 | "errorCode,Invalid value for BSS_max_Idle_period"); |
Jouni Malinen | dccfd0c | 2019-10-30 12:05:59 +0200 | [diff] [blame] | 838 | return STATUS_SENT; |
Adil Saeed Musthafa | 33ea287 | 2017-04-10 23:13:24 -0700 | [diff] [blame] | 839 | } |
Jouni Malinen | 544edf0 | 2019-02-25 19:02:33 +0200 | [diff] [blame] | 840 | dut->wnm_bss_max_idle_time = (int) idle_time; |
Adil Saeed Musthafa | 33ea287 | 2017-04-10 23:13:24 -0700 | [diff] [blame] | 841 | } |
| 842 | |
| 843 | val = get_param(cmd, "PROXY_ARP"); |
| 844 | if (val) |
| 845 | dut->ap_proxy_arp = (int) strtol(val, (char **) NULL, 10); |
| 846 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 847 | val = get_param(cmd, "nss_mcs_cap"); |
| 848 | if (val) { |
| 849 | int nss, mcs; |
| 850 | char token[20]; |
| 851 | char *result = NULL; |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 852 | char *saveptr; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 853 | |
| 854 | if (strlen(val) >= sizeof(token)) |
Jouni Malinen | dccfd0c | 2019-10-30 12:05:59 +0200 | [diff] [blame] | 855 | return INVALID_SEND_STATUS; |
Jouni Malinen | 947fdf6 | 2017-05-14 22:29:32 +0300 | [diff] [blame] | 856 | strlcpy(token, val, sizeof(token)); |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 857 | result = strtok_r(token, ";", &saveptr); |
Pradeep Reddy POTTETI | 41b8c54 | 2016-06-15 16:09:46 +0530 | [diff] [blame] | 858 | if (!result) { |
Jouni Malinen | 9aa4b37 | 2019-10-30 12:08:15 +0200 | [diff] [blame] | 859 | send_resp(dut, conn, SIGMA_ERROR, |
| 860 | "errorCode,VHT NSS not specified"); |
| 861 | return STATUS_SENT; |
Pradeep Reddy POTTETI | 41b8c54 | 2016-06-15 16:09:46 +0530 | [diff] [blame] | 862 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 863 | nss = atoi(result); |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 864 | result = strtok_r(NULL, ";", &saveptr); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 865 | if (result == NULL) { |
Jouni Malinen | 9aa4b37 | 2019-10-30 12:08:15 +0200 | [diff] [blame] | 866 | send_resp(dut, conn, SIGMA_ERROR, |
| 867 | "errorCode,VHTMCS not specified"); |
| 868 | return STATUS_SENT; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 869 | } |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 870 | result = strtok_r(result, "-", &saveptr); |
| 871 | result = strtok_r(NULL, "-", &saveptr); |
Pradeep Reddy POTTETI | 41b8c54 | 2016-06-15 16:09:46 +0530 | [diff] [blame] | 872 | if (!result) { |
Jouni Malinen | 9aa4b37 | 2019-10-30 12:08:15 +0200 | [diff] [blame] | 873 | send_resp(dut, conn, SIGMA_ERROR, |
| 874 | "errorCode,VHT MCS not specified"); |
| 875 | return STATUS_SENT; |
Pradeep Reddy POTTETI | 41b8c54 | 2016-06-15 16:09:46 +0530 | [diff] [blame] | 876 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 877 | mcs = atoi(result); |
| 878 | switch (nss) { |
| 879 | case 1: |
| 880 | switch (mcs) { |
| 881 | case 7: |
| 882 | dut->ap_vhtmcs_map = 0xfffc; |
| 883 | break; |
| 884 | case 8: |
| 885 | dut->ap_vhtmcs_map = 0xfffd; |
| 886 | break; |
| 887 | case 9: |
| 888 | dut->ap_vhtmcs_map = 0xfffe; |
| 889 | break; |
| 890 | default: |
| 891 | dut->ap_vhtmcs_map = 0xfffe; |
| 892 | break; |
| 893 | } |
| 894 | break; |
| 895 | case 2: |
| 896 | switch (mcs) { |
| 897 | case 7: |
| 898 | dut->ap_vhtmcs_map = 0xfff0; |
| 899 | break; |
| 900 | case 8: |
| 901 | dut->ap_vhtmcs_map = 0xfff5; |
| 902 | break; |
| 903 | case 9: |
| 904 | dut->ap_vhtmcs_map = 0xfffa; |
| 905 | break; |
| 906 | default: |
| 907 | dut->ap_vhtmcs_map = 0xfffa; |
| 908 | break; |
| 909 | } |
| 910 | break; |
| 911 | case 3: |
| 912 | switch (mcs) { |
| 913 | case 7: |
| 914 | dut->ap_vhtmcs_map = 0xffc0; |
| 915 | break; |
| 916 | case 8: |
| 917 | dut->ap_vhtmcs_map = 0xffd5; |
| 918 | break; |
| 919 | case 9: |
| 920 | dut->ap_vhtmcs_map = 0xffea; |
| 921 | break; |
| 922 | default: |
| 923 | dut->ap_vhtmcs_map = 0xffea; |
| 924 | break; |
| 925 | } |
| 926 | break; |
| 927 | default: |
| 928 | dut->ap_vhtmcs_map = 0xffea; |
| 929 | break; |
| 930 | } |
| 931 | } |
| 932 | |
| 933 | /* TODO: MPDU_MIN_START_SPACING */ |
| 934 | /* TODO: RIFS_TEST */ |
| 935 | /* TODO: SGI20 */ |
| 936 | |
| 937 | val = get_param(cmd, "STBC_TX"); |
| 938 | if (val) |
| 939 | dut->ap_tx_stbc = atoi(val); |
| 940 | |
| 941 | val = get_param(cmd, "WIDTH"); |
| 942 | if (val) { |
| 943 | if (strcasecmp(val, "20") == 0) |
| 944 | dut->ap_chwidth = AP_20; |
| 945 | else if (strcasecmp(val, "40") == 0) |
| 946 | dut->ap_chwidth = AP_40; |
| 947 | else if (strcasecmp(val, "80") == 0) |
| 948 | dut->ap_chwidth = AP_80; |
| 949 | else if (strcasecmp(val, "160") == 0) |
| 950 | dut->ap_chwidth = AP_160; |
priyadharshini gowthaman | 63ab848 | 2017-12-28 15:32:55 -0800 | [diff] [blame] | 951 | else if (strcasecmp(val, "80plus80") == 0) { |
| 952 | dut->ap_80plus80 = 1; |
| 953 | dut->ap_chwidth = AP_80_80; |
| 954 | } else if (strcasecmp(val, "Auto") == 0) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 955 | dut->ap_chwidth = AP_AUTO; |
| 956 | else { |
| 957 | send_resp(dut, conn, SIGMA_INVALID, |
| 958 | "errorCode,Unsupported WIDTH"); |
Jouni Malinen | dccfd0c | 2019-10-30 12:05:59 +0200 | [diff] [blame] | 959 | return STATUS_SENT; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 960 | } |
| 961 | } |
| 962 | |
| 963 | /* TODO: WIDTH_SCAN */ |
| 964 | |
| 965 | val = get_param(cmd, "TDLSProhibit"); |
| 966 | dut->ap_tdls_prohibit = val && strcasecmp(val, "Enabled") == 0; |
| 967 | val = get_param(cmd, "TDLSChswitchProhibit"); |
| 968 | dut->ap_tdls_prohibit_chswitch = |
| 969 | val && strcasecmp(val, "Enabled") == 0; |
| 970 | val = get_param(cmd, "HS2"); |
| 971 | if (val && wlan_tag == 1) |
| 972 | dut->ap_hs2 = atoi(val); |
| 973 | val = get_param(cmd, "P2P_CROSS_CONNECT"); |
| 974 | if (val) |
| 975 | dut->ap_p2p_cross_connect = strcasecmp(val, "Enabled") == 0; |
| 976 | |
| 977 | val = get_param(cmd, "FakePubKey"); |
| 978 | dut->ap_fake_pkhash = val && atoi(val); |
| 979 | |
| 980 | val = get_param(cmd, "vht_tkip"); |
| 981 | dut->ap_allow_vht_tkip = val && strcasecmp(val, "Enable") == 0; |
| 982 | val = get_param(cmd, "vht_wep"); |
| 983 | dut->ap_allow_vht_wep = val && strcasecmp(val, "Enable") == 0; |
| 984 | |
| 985 | val = get_param(cmd, "Protect_mode"); |
| 986 | dut->ap_disable_protection = val && strcasecmp(val, "Disable") == 0; |
| 987 | |
| 988 | val = get_param(cmd, "DYN_BW_SGNL"); |
| 989 | if (val) { |
Jouni Malinen | 016ae6c | 2019-11-04 17:00:01 +0200 | [diff] [blame] | 990 | switch (get_driver_type(dut)) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 991 | case DRIVER_OPENWRT: |
| 992 | switch (get_openwrt_driver_type()) { |
| 993 | case OPENWRT_DRIVER_ATHEROS: |
| 994 | ath_config_dyn_bw_sig(dut, ifname, val); |
| 995 | break; |
| 996 | default: |
| 997 | send_resp(dut, conn, SIGMA_ERROR, |
| 998 | "errorCode,Unsupported DYN_BW_SGNL with OpenWrt driver"); |
Jouni Malinen | dccfd0c | 2019-10-30 12:05:59 +0200 | [diff] [blame] | 999 | return STATUS_SENT; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1000 | } |
| 1001 | break; |
Nirav Shah | 8ad8d74 | 2017-10-17 10:49:11 +0530 | [diff] [blame] | 1002 | case DRIVER_WCN: |
| 1003 | case DRIVER_LINUX_WCN: |
| 1004 | ath_config_dyn_bw_sig(dut, ifname, val); |
| 1005 | break; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1006 | default: |
| 1007 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 1008 | "Unsupported DYN_BW_SGL with the current driver"); |
| 1009 | break; |
| 1010 | } |
| 1011 | } |
| 1012 | |
| 1013 | val = get_param(cmd, "SGI80"); |
| 1014 | if (val) { |
| 1015 | if (strcasecmp(val, "enable") == 0) |
| 1016 | dut->ap_sgi80 = 1; |
| 1017 | else if (strcasecmp(val, "disable") == 0) |
| 1018 | dut->ap_sgi80 = 0; |
| 1019 | else { |
| 1020 | send_resp(dut, conn, SIGMA_INVALID, |
| 1021 | "errorCode,Unsupported SGI80"); |
Jouni Malinen | dccfd0c | 2019-10-30 12:05:59 +0200 | [diff] [blame] | 1022 | return STATUS_SENT; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1023 | } |
| 1024 | } |
| 1025 | |
| 1026 | val = get_param(cmd, "LDPC"); |
| 1027 | if (val) { |
| 1028 | if (strcasecmp(val, "enable") == 0) |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 1029 | dut->ap_ldpc = VALUE_ENABLED; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1030 | else if (strcasecmp(val, "disable") == 0) |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 1031 | dut->ap_ldpc = VALUE_DISABLED; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1032 | else { |
| 1033 | send_resp(dut, conn, SIGMA_INVALID, |
| 1034 | "errorCode,Unsupported LDPC"); |
Jouni Malinen | dccfd0c | 2019-10-30 12:05:59 +0200 | [diff] [blame] | 1035 | return STATUS_SENT; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1036 | } |
| 1037 | } |
| 1038 | |
| 1039 | val = get_param(cmd, "BW_SGNL"); |
| 1040 | if (val) { |
| 1041 | /* |
| 1042 | * With dynamic bandwidth signaling enabled we should see |
| 1043 | * RTS if the threshold is met. |
| 1044 | */ |
| 1045 | if (strcasecmp(val, "enable") == 0) { |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 1046 | dut->ap_sig_rts = VALUE_ENABLED; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1047 | } else if (strcasecmp(val, "disable") == 0) { |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 1048 | dut->ap_sig_rts = VALUE_DISABLED; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1049 | } else { |
| 1050 | send_resp(dut, conn, SIGMA_INVALID, |
| 1051 | "errorCode,Unsupported BW_SGNL"); |
Jouni Malinen | dccfd0c | 2019-10-30 12:05:59 +0200 | [diff] [blame] | 1052 | return STATUS_SENT; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1053 | } |
| 1054 | } |
| 1055 | |
| 1056 | val = get_param(cmd, "RTS_FORCE"); |
| 1057 | if (val) { |
Jouni Malinen | 016ae6c | 2019-11-04 17:00:01 +0200 | [diff] [blame] | 1058 | switch (get_driver_type(dut)) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1059 | case DRIVER_OPENWRT: |
| 1060 | switch (get_openwrt_driver_type()) { |
| 1061 | case OPENWRT_DRIVER_ATHEROS: |
| 1062 | ath_config_rts_force(dut, ifname, val); |
| 1063 | break; |
| 1064 | default: |
| 1065 | send_resp(dut, conn, SIGMA_ERROR, |
| 1066 | "errorCode,Unsupported RTS_FORCE with OpenWrt driver"); |
Jouni Malinen | dccfd0c | 2019-10-30 12:05:59 +0200 | [diff] [blame] | 1067 | return STATUS_SENT; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1068 | } |
| 1069 | break; |
| 1070 | default: |
| 1071 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 1072 | "Unsupported RTS_FORCE with the current driver"); |
| 1073 | break; |
| 1074 | } |
| 1075 | } |
| 1076 | |
| 1077 | val = get_param(cmd, "Zero_crc"); |
| 1078 | if (val) { |
Jouni Malinen | 016ae6c | 2019-11-04 17:00:01 +0200 | [diff] [blame] | 1079 | switch (get_driver_type(dut)) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1080 | case DRIVER_ATHEROS: |
| 1081 | ath_set_zero_crc(dut, val); |
| 1082 | break; |
| 1083 | case DRIVER_OPENWRT: |
| 1084 | switch (get_openwrt_driver_type()) { |
| 1085 | case OPENWRT_DRIVER_ATHEROS: |
| 1086 | ath_set_zero_crc(dut, val); |
| 1087 | break; |
| 1088 | default: |
| 1089 | send_resp(dut, conn, SIGMA_ERROR, |
| 1090 | "errorCode,Unsupported zero_crc with the current driver"); |
Jouni Malinen | dccfd0c | 2019-10-30 12:05:59 +0200 | [diff] [blame] | 1091 | return STATUS_SENT; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1092 | } |
| 1093 | break; |
| 1094 | default: |
| 1095 | send_resp(dut, conn, SIGMA_ERROR, |
| 1096 | "errorCode,Unsupported zero_crc with the current driver"); |
Jouni Malinen | dccfd0c | 2019-10-30 12:05:59 +0200 | [diff] [blame] | 1097 | return STATUS_SENT; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1098 | } |
| 1099 | } |
| 1100 | |
| 1101 | val = get_param(cmd, "TxBF"); |
| 1102 | if (val) |
| 1103 | dut->ap_txBF = strcasecmp(val, "enable") == 0; |
| 1104 | |
| 1105 | val = get_param(cmd, "MU_TxBF"); |
Manikanta Pubbisetty | 210f7c8 | 2017-02-14 12:33:54 +0530 | [diff] [blame] | 1106 | if (val) { |
| 1107 | if (strcasecmp(val, "enable") == 0) { |
| 1108 | dut->ap_txBF = 1; |
| 1109 | dut->ap_mu_txBF = 1; |
| 1110 | } else if (strcasecmp(val, "disable") == 0) { |
| 1111 | dut->ap_txBF = 0; |
| 1112 | dut->ap_mu_txBF = 0; |
| 1113 | } else { |
| 1114 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 1115 | "Unsupported MU_TxBF"); |
| 1116 | } |
| 1117 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1118 | |
| 1119 | /* UNSUPPORTED: tx_lgi_rate */ |
| 1120 | |
| 1121 | val = get_param(cmd, "wpsnfc"); |
| 1122 | if (val) |
| 1123 | dut->ap_wpsnfc = atoi(val); |
| 1124 | |
| 1125 | val = get_param(cmd, "GROUP_ID"); |
| 1126 | if (val) { |
Jouni Malinen | 016ae6c | 2019-11-04 17:00:01 +0200 | [diff] [blame] | 1127 | switch (get_driver_type(dut)) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1128 | case DRIVER_OPENWRT: |
| 1129 | switch (get_openwrt_driver_type()) { |
| 1130 | case OPENWRT_DRIVER_ATHEROS: |
| 1131 | ath_ap_set_group_id(dut, ifname, val); |
| 1132 | break; |
| 1133 | default: |
| 1134 | send_resp(dut, conn, SIGMA_ERROR, |
| 1135 | "errorCode,Unsupported group_id with the current driver"); |
Jouni Malinen | dccfd0c | 2019-10-30 12:05:59 +0200 | [diff] [blame] | 1136 | return STATUS_SENT; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1137 | } |
| 1138 | break; |
| 1139 | default: |
| 1140 | send_resp(dut, conn, SIGMA_ERROR, |
| 1141 | "errorCode,Unsupported group_id with the current driver"); |
Jouni Malinen | dccfd0c | 2019-10-30 12:05:59 +0200 | [diff] [blame] | 1142 | return STATUS_SENT; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1143 | } |
| 1144 | } |
| 1145 | |
| 1146 | val = get_param(cmd, "CTS_WIDTH"); |
| 1147 | if (val) { |
Jouni Malinen | 016ae6c | 2019-11-04 17:00:01 +0200 | [diff] [blame] | 1148 | switch (get_driver_type(dut)) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1149 | case DRIVER_OPENWRT: |
| 1150 | switch (get_openwrt_driver_type()) { |
| 1151 | case OPENWRT_DRIVER_ATHEROS: |
| 1152 | ath_set_cts_width(dut, ifname, val); |
| 1153 | break; |
| 1154 | default: |
| 1155 | send_resp(dut, conn, SIGMA_ERROR, |
| 1156 | "errorCode,Unsupported cts_width with the current driver"); |
Jouni Malinen | dccfd0c | 2019-10-30 12:05:59 +0200 | [diff] [blame] | 1157 | return STATUS_SENT; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1158 | } |
| 1159 | break; |
| 1160 | default: |
| 1161 | send_resp(dut, conn, SIGMA_ERROR, |
| 1162 | "errorCode,Unsupported cts_width with the current driver"); |
Jouni Malinen | dccfd0c | 2019-10-30 12:05:59 +0200 | [diff] [blame] | 1163 | return STATUS_SENT; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1164 | } |
| 1165 | } |
| 1166 | |
priyadharshini gowthaman | 264d544 | 2016-02-25 15:52:22 -0800 | [diff] [blame] | 1167 | val = get_param(cmd, "MU_NDPA_FrameFormat"); |
| 1168 | if (val) |
| 1169 | dut->ap_ndpa_frame = atoi(val); |
| 1170 | |
priyadharshini gowthaman | c52fff8 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 1171 | val = get_param(cmd, "interworking"); |
| 1172 | if (val && strcmp(val, "1") == 0) |
| 1173 | dut->ap_interworking = 1; |
| 1174 | |
| 1175 | val = get_param(cmd, "GAS_CB_DELAY"); |
| 1176 | if (val) |
| 1177 | dut->ap_gas_cb_delay = atoi(val); |
| 1178 | |
priyadharshini gowthaman | 8e26ff4 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 1179 | val = get_param(cmd, "LCI"); |
| 1180 | if (val) { |
| 1181 | if (strlen(val) > sizeof(dut->ap_val_lci) - 1) |
Jouni Malinen | dccfd0c | 2019-10-30 12:05:59 +0200 | [diff] [blame] | 1182 | return INVALID_SEND_STATUS; |
priyadharshini gowthaman | 8e26ff4 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 1183 | dut->ap_lci = 1; |
| 1184 | snprintf(dut->ap_val_lci, sizeof(dut->ap_val_lci), "%s", val); |
| 1185 | ath_set_lci_config(dut, val, cmd); |
| 1186 | } |
| 1187 | |
priyadharshini gowthaman | c2357bd | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 1188 | val = get_param(cmd, "InfoZ"); |
| 1189 | if (val) { |
| 1190 | if (strlen(val) > sizeof(dut->ap_infoz) - 1) |
Jouni Malinen | dccfd0c | 2019-10-30 12:05:59 +0200 | [diff] [blame] | 1191 | return INVALID_SEND_STATUS; |
priyadharshini gowthaman | c2357bd | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 1192 | snprintf(dut->ap_infoz, sizeof(dut->ap_infoz), "%s", val); |
| 1193 | } |
| 1194 | |
priyadharshini gowthaman | 8e26ff4 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 1195 | val = get_param(cmd, "LocCivicAddr"); |
| 1196 | if (val) { |
| 1197 | if (strlen(val) > sizeof(dut->ap_val_lcr) - 1) |
Jouni Malinen | dccfd0c | 2019-10-30 12:05:59 +0200 | [diff] [blame] | 1198 | return INVALID_SEND_STATUS; |
priyadharshini gowthaman | 8e26ff4 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 1199 | dut->ap_lcr = 1; |
| 1200 | snprintf(dut->ap_val_lcr, sizeof(dut->ap_val_lcr), "%s", val); |
| 1201 | if (dut->ap_lci == 0) |
| 1202 | ath_set_lci_config(dut, val, cmd); |
| 1203 | } |
| 1204 | |
| 1205 | val = get_param(cmd, "NeighAPBSSID"); |
| 1206 | if (val) { |
| 1207 | if (dut->ap_neighap < 3) { |
| 1208 | if (parse_mac_address( |
| 1209 | dut, val, |
| 1210 | dut->ap_val_neighap[dut->ap_neighap]) < 0) { |
| 1211 | send_resp(dut, conn, SIGMA_INVALID, |
| 1212 | "Failed to parse MAC address"); |
Jouni Malinen | dccfd0c | 2019-10-30 12:05:59 +0200 | [diff] [blame] | 1213 | return STATUS_SENT; |
priyadharshini gowthaman | 8e26ff4 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 1214 | } |
| 1215 | dut->ap_neighap++; |
| 1216 | if (dut->ap_lci == 1) |
| 1217 | dut->ap_scan = 1; |
| 1218 | } |
| 1219 | } |
| 1220 | |
| 1221 | val = get_param(cmd, "OpChannel"); |
| 1222 | if (val) { |
| 1223 | if (dut->ap_opchannel < 3) { |
| 1224 | dut->ap_val_opchannel[dut->ap_opchannel] = atoi(val); |
| 1225 | dut->ap_opchannel++; |
| 1226 | } |
| 1227 | } |
| 1228 | |
priyadharshini gowthaman | c2357bd | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 1229 | val = get_param(cmd, "URI-FQDNdescriptor"); |
| 1230 | if (val) { |
| 1231 | if (strcasecmp(val, "HELD") == 0) { |
| 1232 | dut->ap_fqdn_held = 1; |
| 1233 | } else if (strcasecmp(val, "SUPL") == 0) { |
| 1234 | dut->ap_fqdn_supl = 1; |
| 1235 | } else { |
| 1236 | send_resp(dut, conn, SIGMA_INVALID, |
| 1237 | "errorCode,Unsupported URI-FQDNdescriptor"); |
Jouni Malinen | dccfd0c | 2019-10-30 12:05:59 +0200 | [diff] [blame] | 1238 | return STATUS_SENT; |
priyadharshini gowthaman | c2357bd | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 1239 | } |
| 1240 | } |
| 1241 | |
Adil Saeed Musthafa | 604c826 | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 1242 | val = get_param(cmd, "Reg_Domain"); |
| 1243 | if (val) { |
| 1244 | if (strcasecmp(val, "Local") == 0) { |
| 1245 | dut->ap_reg_domain = REG_DOMAIN_LOCAL; |
| 1246 | } else if (strcasecmp(val, "Global") == 0) { |
| 1247 | dut->ap_reg_domain = REG_DOMAIN_GLOBAL; |
| 1248 | } else { |
| 1249 | send_resp(dut, conn, SIGMA_ERROR, |
| 1250 | "errorCode,Wrong value for Reg_Domain"); |
Jouni Malinen | dccfd0c | 2019-10-30 12:05:59 +0200 | [diff] [blame] | 1251 | return STATUS_SENT; |
Adil Saeed Musthafa | 604c826 | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 1252 | } |
| 1253 | } |
| 1254 | |
Adil Saeed Musthafa | 4ec61bd | 2017-04-10 23:13:41 -0700 | [diff] [blame] | 1255 | val = get_param(cmd, "NAME"); |
| 1256 | if (val) { |
| 1257 | if (strcasecmp(val, "ap1mbo") == 0) |
| 1258 | dut->ap_name = 1; |
| 1259 | else if (strcasecmp(val, "ap2mbo") == 0) |
| 1260 | dut->ap_name = 2; |
| 1261 | else |
| 1262 | dut->ap_name = 0; |
| 1263 | } |
| 1264 | |
| 1265 | val = get_param(cmd, "FT_OA"); |
| 1266 | if (val) { |
| 1267 | if (strcasecmp(val, "Enable") == 0) { |
| 1268 | dut->ap_ft_oa = 1; |
| 1269 | } else if (strcasecmp(val, "Disable") == 0) { |
| 1270 | dut->ap_ft_oa = 0; |
| 1271 | } else { |
| 1272 | send_resp(dut, conn, SIGMA_ERROR, |
| 1273 | "errorCode,Wrong value for FT_OA"); |
Jouni Malinen | dccfd0c | 2019-10-30 12:05:59 +0200 | [diff] [blame] | 1274 | return STATUS_SENT; |
Adil Saeed Musthafa | 4ec61bd | 2017-04-10 23:13:41 -0700 | [diff] [blame] | 1275 | } |
| 1276 | } |
| 1277 | |
Jouni Malinen | 9f94331 | 2019-08-19 23:49:16 +0300 | [diff] [blame] | 1278 | val = get_param(cmd, "FT_DS"); |
| 1279 | if (val) { |
| 1280 | if (strcasecmp(val, "Enable") == 0) { |
| 1281 | dut->ap_ft_ds = VALUE_ENABLED; |
| 1282 | } else if (strcasecmp(val, "Disable") == 0) { |
| 1283 | dut->ap_ft_ds = VALUE_DISABLED; |
| 1284 | } else { |
| 1285 | send_resp(dut, conn, SIGMA_ERROR, |
| 1286 | "errorCode,Unsupported value for FT_DS"); |
| 1287 | return STATUS_SENT_ERROR; |
| 1288 | } |
| 1289 | } |
| 1290 | |
Adil Saeed Musthafa | 023108a | 2017-04-10 23:13:37 -0700 | [diff] [blame] | 1291 | val = get_param(cmd, "Cellular_Cap_Pref"); |
| 1292 | if (val) |
| 1293 | dut->ap_cell_cap_pref = atoi(val); |
| 1294 | |
Adil Saeed Musthafa | cf752fa | 2017-04-10 23:13:32 -0700 | [diff] [blame] | 1295 | val = get_param(cmd, "DOMAIN"); |
| 1296 | if (val) { |
| 1297 | if (strlen(val) >= sizeof(dut->ap_mobility_domain)) { |
| 1298 | send_resp(dut, conn, SIGMA_ERROR, |
| 1299 | "errorCode,Too long DOMAIN"); |
Jouni Malinen | dccfd0c | 2019-10-30 12:05:59 +0200 | [diff] [blame] | 1300 | return STATUS_SENT; |
Adil Saeed Musthafa | cf752fa | 2017-04-10 23:13:32 -0700 | [diff] [blame] | 1301 | } |
| 1302 | snprintf(dut->ap_mobility_domain, |
| 1303 | sizeof(dut->ap_mobility_domain), "%s", val); |
| 1304 | } |
| 1305 | |
Adil Saeed Musthafa | 4ec61bd | 2017-04-10 23:13:41 -0700 | [diff] [blame] | 1306 | val = get_param(cmd, "ft_bss_list"); |
| 1307 | if (val) { |
| 1308 | char *mac_str; |
| 1309 | int i; |
| 1310 | char *saveptr; |
| 1311 | char *mac_list_str; |
| 1312 | |
| 1313 | mac_list_str = strdup(val); |
| 1314 | if (!mac_list_str) |
Jouni Malinen | dccfd0c | 2019-10-30 12:05:59 +0200 | [diff] [blame] | 1315 | return INVALID_SEND_STATUS; |
Adil Saeed Musthafa | 4ec61bd | 2017-04-10 23:13:41 -0700 | [diff] [blame] | 1316 | mac_str = strtok_r(mac_list_str, " ", &saveptr); |
| 1317 | for (i = 0; mac_str && i < MAX_FT_BSS_LIST; i++) { |
| 1318 | if (parse_mac_address(dut, mac_str, |
| 1319 | dut->ft_bss_mac_list[i]) < 0) { |
| 1320 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 1321 | "MAC Address not in proper format"); |
| 1322 | break; |
| 1323 | } |
| 1324 | dut->ft_bss_mac_cnt++; |
| 1325 | mac_str = strtok_r(NULL, " ", &saveptr); |
| 1326 | } |
| 1327 | sigma_dut_print(dut, DUT_MSG_DEBUG, |
| 1328 | "Storing the following FT BSS MAC List"); |
| 1329 | for (i = 0; i < dut->ft_bss_mac_cnt; i++) { |
| 1330 | sigma_dut_print(dut, DUT_MSG_DEBUG, |
| 1331 | "MAC[%d] %02x:%02x:%02x:%02x:%02x:%02x", |
| 1332 | i, |
| 1333 | dut->ft_bss_mac_list[i][0], |
| 1334 | dut->ft_bss_mac_list[i][1], |
| 1335 | dut->ft_bss_mac_list[i][2], |
| 1336 | dut->ft_bss_mac_list[i][3], |
| 1337 | dut->ft_bss_mac_list[i][4], |
| 1338 | dut->ft_bss_mac_list[i][5]); |
| 1339 | } |
| 1340 | free(mac_list_str); |
| 1341 | } |
| 1342 | |
priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 1343 | val = get_param(cmd, "OCESupport"); |
| 1344 | if (val) { |
| 1345 | if (strcasecmp(val, "enable") == 0) { |
| 1346 | dut->ap_oce = VALUE_ENABLED; |
| 1347 | } else if (strcasecmp(val, "disable") == 0) { |
| 1348 | dut->ap_oce = VALUE_DISABLED; |
| 1349 | dut->ap_filsdscv = VALUE_DISABLED; |
| 1350 | } else { |
| 1351 | send_resp(dut, conn, SIGMA_INVALID, |
| 1352 | "errorCode,Unsupported OCE"); |
Jouni Malinen | dccfd0c | 2019-10-30 12:05:59 +0200 | [diff] [blame] | 1353 | return STATUS_SENT; |
priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 1354 | } |
| 1355 | } |
| 1356 | |
| 1357 | val = get_param(cmd, "FILSDscvInterval"); |
| 1358 | if (val) |
| 1359 | dut->ap_fils_dscv_int = atoi(val); |
| 1360 | |
| 1361 | val = get_param(cmd, "BroadcastSSID"); |
| 1362 | if (val) { |
| 1363 | if (strcasecmp(val, "enable") == 0) { |
| 1364 | dut->ap_broadcast_ssid = VALUE_ENABLED; |
| 1365 | } else if (strcasecmp(val, "disable") == 0) { |
| 1366 | dut->ap_broadcast_ssid = VALUE_DISABLED; |
| 1367 | } else { |
| 1368 | send_resp(dut, conn, SIGMA_INVALID, |
| 1369 | "errorCode,Unsupported hidden SSID"); |
Jouni Malinen | dccfd0c | 2019-10-30 12:05:59 +0200 | [diff] [blame] | 1370 | return STATUS_SENT; |
priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 1371 | } |
| 1372 | } |
| 1373 | |
| 1374 | val = get_param(cmd, "FILSDscv"); |
| 1375 | if (val) { |
| 1376 | if (strcasecmp(val, "enable") == 0) { |
| 1377 | dut->ap_filsdscv = VALUE_ENABLED; |
| 1378 | } else if (strcasecmp(val, "disable") == 0) { |
| 1379 | dut->ap_filsdscv = VALUE_DISABLED; |
| 1380 | } else { |
| 1381 | send_resp(dut, conn, SIGMA_INVALID, |
| 1382 | "errorCode,Unsupported FILSDscv"); |
Jouni Malinen | dccfd0c | 2019-10-30 12:05:59 +0200 | [diff] [blame] | 1383 | return STATUS_SENT; |
priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 1384 | } |
| 1385 | } |
| 1386 | |
| 1387 | val = get_param(cmd, "FILSHLP"); |
| 1388 | if (val) { |
| 1389 | if (strcasecmp(val, "enable") == 0) { |
| 1390 | dut->ap_filshlp = VALUE_ENABLED; |
| 1391 | } else if (strcasecmp(val, "disable") == 0) { |
| 1392 | dut->ap_filshlp = VALUE_DISABLED; |
| 1393 | } else { |
| 1394 | send_resp(dut, conn, SIGMA_INVALID, |
| 1395 | "errorCode,Unsupported FILSHLP"); |
Jouni Malinen | dccfd0c | 2019-10-30 12:05:59 +0200 | [diff] [blame] | 1396 | return STATUS_SENT; |
priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 1397 | } |
| 1398 | } |
| 1399 | |
| 1400 | val = get_param(cmd, "NAIRealm"); |
| 1401 | if (val) { |
| 1402 | dut->ap_nairealm_int = 1; |
| 1403 | if (strlen(val) > sizeof(dut->ap_nairealm) - 1) |
Jouni Malinen | dccfd0c | 2019-10-30 12:05:59 +0200 | [diff] [blame] | 1404 | return INVALID_SEND_STATUS; |
priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 1405 | snprintf(dut->ap_nairealm, sizeof(dut->ap_nairealm), "%s", val); |
| 1406 | } |
| 1407 | |
| 1408 | val = get_param(cmd, "DeauthDisassocTx"); |
| 1409 | if (val) { |
| 1410 | if (strcasecmp(val, "disable") == 0) { |
| 1411 | deauth_disassoc(dut, ifname, val); |
| 1412 | } else { |
| 1413 | send_resp(dut, conn, SIGMA_INVALID, |
| 1414 | "errorCode,Unsupported DeauthDisassocTx"); |
Jouni Malinen | dccfd0c | 2019-10-30 12:05:59 +0200 | [diff] [blame] | 1415 | return STATUS_SENT; |
priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 1416 | } |
| 1417 | } |
| 1418 | |
| 1419 | val = get_param(cmd, "RNR"); |
| 1420 | if (val) { |
| 1421 | if (strcasecmp(val, "enable") == 0) { |
| 1422 | dut->ap_rnr = VALUE_ENABLED; |
| 1423 | } else if (strcasecmp(val, "disable") == 0) { |
| 1424 | dut->ap_rnr = VALUE_DISABLED; |
| 1425 | } else { |
| 1426 | send_resp(dut, conn, SIGMA_INVALID, |
| 1427 | "errorCode,Unsupported RNR"); |
Jouni Malinen | dccfd0c | 2019-10-30 12:05:59 +0200 | [diff] [blame] | 1428 | return STATUS_SENT; |
priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 1429 | } |
| 1430 | } |
| 1431 | |
| 1432 | val = get_param(cmd, "BLEChannelUtil"); |
| 1433 | if (val) |
| 1434 | dut->ap_blechanutil = atoi(val); |
| 1435 | |
| 1436 | val = get_param(cmd, "BLEAvailAdminCap"); |
| 1437 | if (val) |
| 1438 | dut->ap_ble_admit_cap = atoi(val); |
| 1439 | |
| 1440 | val = get_param(cmd, "DataPPDUDuration"); |
| 1441 | if (val) |
| 1442 | dut->ap_datappdudura = atoi(val); |
| 1443 | |
| 1444 | val = get_param(cmd, "AirTimeFract"); |
| 1445 | if (val) |
| 1446 | dut->ap_airtimefract = atoi(val); |
| 1447 | |
| 1448 | val = get_param(cmd, "dhcpServIPADDR"); |
| 1449 | if (val) { |
| 1450 | if (strlen(val) > sizeof(dut->ap_dhcpserv_ipaddr) - 1) |
Jouni Malinen | dccfd0c | 2019-10-30 12:05:59 +0200 | [diff] [blame] | 1451 | return INVALID_SEND_STATUS; |
priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 1452 | snprintf(dut->ap_dhcpserv_ipaddr, |
| 1453 | sizeof(dut->ap_dhcpserv_ipaddr), "%s", val); |
| 1454 | dut->ap_dhcp_stop = 1; |
| 1455 | } |
| 1456 | |
| 1457 | val = get_param(cmd, "ESP_IE"); |
| 1458 | if (val) { |
| 1459 | if (strcasecmp(val, "enable") == 0) { |
| 1460 | dut->ap_esp = VALUE_ENABLED; |
| 1461 | } else if (strcasecmp(val, "disable") == 0) { |
| 1462 | dut->ap_esp = VALUE_DISABLED; |
| 1463 | } else { |
| 1464 | send_resp(dut, conn, SIGMA_INVALID, |
| 1465 | "errorCode,Unsupported ESP_IE"); |
Jouni Malinen | dccfd0c | 2019-10-30 12:05:59 +0200 | [diff] [blame] | 1466 | return STATUS_SENT; |
priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 1467 | } |
| 1468 | } |
| 1469 | |
| 1470 | val = get_param(cmd, "BAWinSize"); |
| 1471 | if (val) |
| 1472 | dut->ap_bawinsize = atoi(val); |
| 1473 | |
| 1474 | val = get_param(cmd, "BLEStaCount"); |
| 1475 | if (val) |
| 1476 | dut->ap_blestacnt = atoi(val); |
| 1477 | |
priyadharshini gowthaman | 350f191 | 2018-06-04 13:09:12 -0700 | [diff] [blame] | 1478 | val = get_param(cmd, "PPDUTxType"); |
| 1479 | if (val) { |
| 1480 | if (strcasecmp(val, "MU") == 0) { |
| 1481 | dut->ap_he_ppdu = PPDU_MU; |
Priyadharshini Gowthaman | fe60c50 | 2019-08-14 13:00:34 -0700 | [diff] [blame] | 1482 | } else if (strcasecmp(val, "HE-SU") == 0) { |
| 1483 | /* Do nothing */ |
| 1484 | } else if (strcasecmp(val, "SU") == 0) { |
| 1485 | /* Do nothing */ |
| 1486 | } else if (strcasecmp(val, "legacy") == 0) { |
| 1487 | /* Do nothing */ |
| 1488 | } else if (strcasecmp(val, "ER") == 0) { |
| 1489 | /* Do nothing */ |
| 1490 | } else if (strcasecmp(val, "TB") == 0) { |
| 1491 | /* Do nothing */ |
priyadharshini gowthaman | 350f191 | 2018-06-04 13:09:12 -0700 | [diff] [blame] | 1492 | } else { |
Priyadharshini Gowthaman | fe60c50 | 2019-08-14 13:00:34 -0700 | [diff] [blame] | 1493 | send_resp(dut, conn, SIGMA_ERROR, |
priyadharshini gowthaman | 350f191 | 2018-06-04 13:09:12 -0700 | [diff] [blame] | 1494 | "errorCode,Unsupported PPDUTxType"); |
Priyadharshini Gowthaman | fe60c50 | 2019-08-14 13:00:34 -0700 | [diff] [blame] | 1495 | return STATUS_SENT_ERROR; |
priyadharshini gowthaman | 350f191 | 2018-06-04 13:09:12 -0700 | [diff] [blame] | 1496 | } |
| 1497 | } |
| 1498 | |
Alexei Avshalom Lazar | 33f700c | 2018-12-18 16:00:39 +0200 | [diff] [blame] | 1499 | val = get_param(cmd, "WscIEFragment"); |
| 1500 | if (val && strcasecmp(val, "enable") == 0) { |
| 1501 | sigma_dut_print(dut, DUT_MSG_DEBUG, |
| 1502 | "Enable WSC IE fragmentation"); |
| 1503 | dut->wsc_fragment = 1; |
| 1504 | } |
| 1505 | |
Alexei Avshalom Lazar | 744ae8a | 2019-01-31 17:26:46 +0200 | [diff] [blame] | 1506 | val = get_param(cmd, "WpsVersion"); |
| 1507 | if (val) |
| 1508 | dut->wps_forced_version = get_wps_forced_version(dut, val); |
| 1509 | |
Alexei Avshalom Lazar | 2eccf4d | 2019-01-31 10:03:59 +0200 | [diff] [blame] | 1510 | val = get_param(cmd, "WscEAPFragment"); |
| 1511 | if (val && strcasecmp(val, "enable") == 0) |
| 1512 | dut->eap_fragment = 1; |
| 1513 | |
Alexei Avshalom Lazar | 79f5727 | 2018-12-23 17:22:47 +0200 | [diff] [blame] | 1514 | val = get_param(cmd, "MSDUSize"); |
| 1515 | if (val) { |
| 1516 | int mtu; |
| 1517 | |
| 1518 | dut->amsdu_size = atoi(val); |
| 1519 | if (dut->amsdu_size > IEEE80211_MAX_DATA_LEN_DMG || |
| 1520 | dut->amsdu_size < IEEE80211_SNAP_LEN_DMG) { |
| 1521 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 1522 | "MSDUSize %d is above max %d or below min %d", |
| 1523 | dut->amsdu_size, |
| 1524 | IEEE80211_MAX_DATA_LEN_DMG, |
| 1525 | IEEE80211_SNAP_LEN_DMG); |
| 1526 | dut->amsdu_size = 0; |
Jouni Malinen | 0e29cf2 | 2019-02-19 01:13:21 +0200 | [diff] [blame] | 1527 | return ERROR_SEND_STATUS; |
Alexei Avshalom Lazar | 79f5727 | 2018-12-23 17:22:47 +0200 | [diff] [blame] | 1528 | } |
| 1529 | |
| 1530 | mtu = dut->amsdu_size - IEEE80211_SNAP_LEN_DMG; |
| 1531 | sigma_dut_print(dut, DUT_MSG_DEBUG, |
| 1532 | "Setting amsdu_size to %d", mtu); |
| 1533 | snprintf(buf, sizeof(buf), "ifconfig %s mtu %d", |
Jouni Malinen | 016ae6c | 2019-11-04 17:00:01 +0200 | [diff] [blame] | 1534 | get_station_ifname(dut), mtu); |
Alexei Avshalom Lazar | 79f5727 | 2018-12-23 17:22:47 +0200 | [diff] [blame] | 1535 | |
| 1536 | if (system(buf) != 0) { |
| 1537 | sigma_dut_print(dut, DUT_MSG_ERROR, "Failed to set %s", |
| 1538 | buf); |
Jouni Malinen | 0e29cf2 | 2019-02-19 01:13:21 +0200 | [diff] [blame] | 1539 | return ERROR_SEND_STATUS; |
Alexei Avshalom Lazar | 79f5727 | 2018-12-23 17:22:47 +0200 | [diff] [blame] | 1540 | } |
| 1541 | } |
| 1542 | |
Alexei Avshalom Lazar | 0e239a9 | 2018-12-23 17:27:50 +0200 | [diff] [blame] | 1543 | val = get_param(cmd, "BAckRcvBuf"); |
| 1544 | if (val) { |
| 1545 | dut->back_rcv_buf = atoi(val); |
| 1546 | if (dut->back_rcv_buf == 0) { |
| 1547 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 1548 | "Failed to convert %s or value is 0", |
| 1549 | val); |
Jouni Malinen | 0e29cf2 | 2019-02-19 01:13:21 +0200 | [diff] [blame] | 1550 | return ERROR_SEND_STATUS; |
Alexei Avshalom Lazar | 0e239a9 | 2018-12-23 17:27:50 +0200 | [diff] [blame] | 1551 | } |
| 1552 | |
| 1553 | sigma_dut_print(dut, DUT_MSG_DEBUG, |
| 1554 | "Setting BAckRcvBuf to %s", val); |
| 1555 | } |
| 1556 | |
Alexei Avshalom Lazar | bc180dc | 2018-12-18 16:01:14 +0200 | [diff] [blame] | 1557 | val = get_param(cmd, "ExtSchIE"); |
| 1558 | if (val && !strcasecmp(val, "Enable")) { |
| 1559 | int num_allocs = MAX_ESE_ALLOCS; |
| 1560 | |
| 1561 | if (sta_extract_60g_ese(dut, cmd, dut->ap_ese_allocs, |
| 1562 | &num_allocs)) { |
| 1563 | send_resp(dut, conn, SIGMA_INVALID, |
| 1564 | "errorCode,Invalid ExtSchIE"); |
Jouni Malinen | dccfd0c | 2019-10-30 12:05:59 +0200 | [diff] [blame] | 1565 | return STATUS_SENT; |
Alexei Avshalom Lazar | bc180dc | 2018-12-18 16:01:14 +0200 | [diff] [blame] | 1566 | } |
| 1567 | dut->ap_num_ese_allocs = num_allocs; |
| 1568 | } |
| 1569 | |
Alexei Avshalom Lazar | 49498b8 | 2019-01-31 15:16:32 +0200 | [diff] [blame] | 1570 | if (is_60g_sigma_dut(dut)) { |
| 1571 | unsigned int abft_len = 1; /* default is one slot */ |
| 1572 | |
| 1573 | val = get_param(cmd, "ABFTLRang"); |
| 1574 | if (val) { |
| 1575 | sigma_dut_print(dut, DUT_MSG_DEBUG, |
| 1576 | "ABFTLRang parameter %s", val); |
| 1577 | if (strcasecmp(val, "Gt1") == 0) |
| 1578 | abft_len = 2; /* 2 slots in this case */ |
| 1579 | } |
| 1580 | |
| 1581 | if (sta_set_60g_abft_len(dut, conn, abft_len)) { |
| 1582 | send_resp(dut, conn, SIGMA_ERROR, |
| 1583 | "ErrorCode,Can't set ABFT length"); |
| 1584 | return STATUS_SENT; |
| 1585 | } |
| 1586 | } |
| 1587 | |
Priyadharshini Gowthaman | c067edf | 2019-06-20 11:23:27 -0700 | [diff] [blame] | 1588 | val = get_param(cmd, "OFDMA"); |
| 1589 | if (val) { |
| 1590 | if (strcasecmp(val, "UL") == 0) { |
| 1591 | dut->ap_he_ulofdma = VALUE_ENABLED; |
Priyadharshini Gowthaman | fe60c50 | 2019-08-14 13:00:34 -0700 | [diff] [blame] | 1592 | } else if (strcasecmp(val, "DL") == 0) { |
| 1593 | dut->ap_he_dlofdma = VALUE_ENABLED; |
| 1594 | } else if (strcasecmp(val, "DL-20and80") == 0) { |
| 1595 | dut->ap_he_dlofdma = VALUE_ENABLED; |
Priyadharshini Gowthaman | c067edf | 2019-06-20 11:23:27 -0700 | [diff] [blame] | 1596 | } else { |
| 1597 | send_resp(dut, conn, SIGMA_ERROR, |
| 1598 | "errorCode,Unsupported OFDMA value"); |
| 1599 | return STATUS_SENT_ERROR; |
| 1600 | } |
| 1601 | } |
| 1602 | |
Priyadharshini Gowthaman | bc94889 | 2019-09-10 14:22:49 -0700 | [diff] [blame] | 1603 | val = get_param(cmd, "NumSoundDim"); |
| 1604 | if (val) |
| 1605 | dut->ap_numsounddim = atoi(val); |
| 1606 | |
Priyadharshini Gowthaman | 670b323 | 2019-09-10 16:09:19 -0700 | [diff] [blame] | 1607 | val = get_param(cmd, "BCC"); |
| 1608 | if (val) { |
| 1609 | if (strcasecmp(val, "enable") == 0) { |
| 1610 | dut->ap_bcc = VALUE_ENABLED; |
| 1611 | dut->ap_ldpc = VALUE_DISABLED; |
| 1612 | } else if (strcasecmp(val, "disable") == 0) { |
| 1613 | dut->ap_ldpc = VALUE_ENABLED; |
| 1614 | dut->ap_bcc = VALUE_DISABLED; |
| 1615 | } else { |
| 1616 | send_resp(dut, conn, SIGMA_ERROR, |
| 1617 | "errorCode,Unsupported BCC value"); |
| 1618 | return STATUS_SENT_ERROR; |
| 1619 | } |
| 1620 | } |
| 1621 | |
Priyadharshini Gowthaman | 6bc4c1e | 2019-09-10 16:24:51 -0700 | [diff] [blame] | 1622 | val = get_param(cmd, "FrgmntSupport"); |
| 1623 | if (val) { |
| 1624 | if (strcasecmp(val, "enable") == 0) { |
| 1625 | dut->ap_he_frag = VALUE_ENABLED; |
| 1626 | } else if (strcasecmp(val, "disable") == 0) { |
| 1627 | dut->ap_he_frag = VALUE_DISABLED; |
| 1628 | } else { |
| 1629 | send_resp(dut, conn, SIGMA_ERROR, |
| 1630 | "errorCode,Unsupported FrgmntSupport value"); |
| 1631 | return STATUS_SENT_ERROR; |
| 1632 | } |
| 1633 | } |
| 1634 | |
Priyadharshini Gowthaman | 1a686bd | 2019-09-19 14:41:40 -0700 | [diff] [blame] | 1635 | val = get_param(cmd, "ADDBAReq_BufSize"); |
| 1636 | if (val) { |
| 1637 | if (strcasecmp(val, "le64") == 0) { |
| 1638 | dut->ap_ba_bufsize = BA_BUFSIZE_64; |
| 1639 | } else if (strcasecmp(val, "gt64") == 0) { |
| 1640 | dut->ap_ba_bufsize = BA_BUFSIZE_256; |
| 1641 | } else { |
| 1642 | send_resp(dut, conn, SIGMA_ERROR, |
| 1643 | "errorCode,Unsupported ADDBAReq Buffer Size"); |
| 1644 | return STATUS_SENT_ERROR; |
| 1645 | } |
| 1646 | } |
| 1647 | |
| 1648 | val = get_param(cmd, "ADDBAResp_BufSize"); |
| 1649 | if (val) { |
| 1650 | if (strcasecmp(val, "gt64") == 0) { |
| 1651 | dut->ap_ba_bufsize = BA_BUFSIZE_256; |
| 1652 | } else { |
| 1653 | send_resp(dut, conn, SIGMA_ERROR, |
| 1654 | "errorCode,Unsupported ADDBAResp Buffer Size"); |
| 1655 | return STATUS_SENT_ERROR; |
| 1656 | } |
| 1657 | } |
| 1658 | |
Priyadharshini Gowthaman | 21895a5 | 2019-10-07 16:56:16 -0700 | [diff] [blame] | 1659 | val = get_param(cmd, "MU_EDCA"); |
| 1660 | if (val) { |
| 1661 | if (strcasecmp(val, "override") == 0) { |
| 1662 | dut->ap_mu_edca = VALUE_ENABLED; |
| 1663 | } else if (strcasecmp(val, "disable") == 0) { |
| 1664 | dut->ap_mu_edca = VALUE_DISABLED; |
| 1665 | } else { |
| 1666 | send_resp(dut, conn, SIGMA_ERROR, |
| 1667 | "errorCode,Unsupported mu_edca param value"); |
| 1668 | return STATUS_SENT_ERROR; |
| 1669 | } |
| 1670 | } |
| 1671 | |
Priyadharshini Gowthaman | dee79e2 | 2019-10-07 16:56:27 -0700 | [diff] [blame] | 1672 | val = get_param(cmd, "MIMO"); |
| 1673 | if (val) { |
| 1674 | if (strcasecmp(val, "DL") == 0) { |
| 1675 | dut->ap_he_mimo = MIMO_DL; |
| 1676 | } else if (strcasecmp(val, "UL") == 0) { |
| 1677 | dut->ap_he_mimo = MIMO_UL; |
| 1678 | } else { |
| 1679 | send_resp(dut, conn, SIGMA_ERROR, |
| 1680 | "errorCode,Unsupported mimo param value"); |
| 1681 | return STATUS_SENT_ERROR; |
| 1682 | } |
| 1683 | } |
| 1684 | |
Priyadharshini Gowthaman | 43d6b41 | 2019-10-07 16:56:37 -0700 | [diff] [blame] | 1685 | val = get_param(cmd, "HE_TXOPDurRTSThr"); |
| 1686 | if (val) { |
| 1687 | if (strcasecmp(val, "enable") == 0) { |
| 1688 | dut->ap_he_rtsthrshld = VALUE_ENABLED; |
| 1689 | } else if (strcasecmp(val, "disable") == 0) { |
| 1690 | dut->ap_he_rtsthrshld = VALUE_DISABLED; |
| 1691 | } else { |
| 1692 | send_resp(dut, conn, SIGMA_ERROR, |
| 1693 | "errorCode,Unsupported HE_TXOPDurRTSThr value"); |
| 1694 | return STATUS_SENT_ERROR; |
| 1695 | } |
| 1696 | } |
| 1697 | |
Priyadharshini Gowthaman | 8018c98 | 2019-10-31 15:14:37 -0700 | [diff] [blame] | 1698 | val = get_param(cmd, "MBSSID"); |
| 1699 | if (val) { |
| 1700 | if (strcasecmp(val, "enable") == 0) { |
| 1701 | dut->ap_mbssid = VALUE_ENABLED; |
| 1702 | } else if (strcasecmp(val, "disable") == 0) { |
| 1703 | dut->ap_mbssid = VALUE_DISABLED; |
| 1704 | } else { |
| 1705 | send_resp(dut, conn, SIGMA_ERROR, |
| 1706 | "errorCode,Unsupported MBSSID Value"); |
| 1707 | return STATUS_SENT_ERROR; |
| 1708 | } |
| 1709 | } |
| 1710 | |
Priyadharshini Gowthaman | ae0a605 | 2019-11-01 15:26:38 -0700 | [diff] [blame] | 1711 | val = get_param(cmd, "TWT_RespSupport"); |
| 1712 | if (val) { |
| 1713 | if (strcasecmp(val, "enable") == 0) { |
| 1714 | dut->ap_twtresp = VALUE_ENABLED; |
| 1715 | } else if (strcasecmp(val, "disable") == 0) { |
| 1716 | dut->ap_twtresp = VALUE_DISABLED; |
| 1717 | } else { |
| 1718 | send_resp(dut, conn, SIGMA_ERROR, |
| 1719 | "errorCode,Unsupported TWT_RespSupport value"); |
| 1720 | return STATUS_SENT_ERROR; |
| 1721 | } |
| 1722 | } |
| 1723 | |
Jouni Malinen | dccfd0c | 2019-10-30 12:05:59 +0200 | [diff] [blame] | 1724 | return SUCCESS_SEND_STATUS; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1725 | } |
| 1726 | |
| 1727 | |
| 1728 | static void ath_inject_frame(struct sigma_dut *dut, const char *ifname, int tid) |
| 1729 | { |
| 1730 | char buf[256]; |
| 1731 | int tid_to_dscp[] = { 0x00, 0x20, 0x40, 0x60, 0x80, 0xa0, 0xc0, 0xe0 }; |
| 1732 | |
Pradeep Reddy POTTETI | d31d132 | 2016-10-13 17:22:03 +0530 | [diff] [blame] | 1733 | if (tid < 0 || |
| 1734 | tid >= (int) (sizeof(tid_to_dscp) / sizeof(tid_to_dscp[0]))) { |
| 1735 | sigma_dut_print(dut, DUT_MSG_ERROR, "Unsupported TID: %d", tid); |
| 1736 | return; |
| 1737 | } |
| 1738 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1739 | snprintf(buf, sizeof(buf), |
| 1740 | "wlanconfig %s list sta | grep : | cut -b 1-17 > %s", |
| 1741 | ifname, VI_QOS_TMP_FILE); |
| 1742 | if (system(buf) != 0) |
| 1743 | return; |
| 1744 | |
| 1745 | snprintf(buf, sizeof(buf), |
| 1746 | "ifconfig %s | grep HWaddr | cut -b 39-56 >> %s", |
| 1747 | ifname, VI_QOS_TMP_FILE); |
| 1748 | if (system(buf) != 0) |
| 1749 | sigma_dut_print(dut, DUT_MSG_ERROR, "Retrieve HWaddr failed"); |
| 1750 | |
| 1751 | snprintf(buf, sizeof(buf), "sed -n '3,$p' %s >> %s", |
| 1752 | VI_QOS_REFFILE, VI_QOS_TMP_FILE); |
| 1753 | if (system(buf) != 0) { |
| 1754 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 1755 | "Output redirection to VI_QOS_TMP_FILE failed"); |
| 1756 | } |
| 1757 | |
| 1758 | snprintf(buf, sizeof(buf), "sed '5 c %x' %s > %s", |
| 1759 | tid_to_dscp[tid], VI_QOS_TMP_FILE, VI_QOS_FILE); |
| 1760 | if (system(buf) != 0) { |
| 1761 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 1762 | "Append TID to VI_QOS_FILE failed "); |
| 1763 | } |
| 1764 | |
| 1765 | snprintf(buf, sizeof(buf), "ethinject %s %s", ifname, VI_QOS_FILE); |
| 1766 | if (system(buf) != 0) |
| 1767 | sigma_dut_print(dut, DUT_MSG_ERROR, "Ethinject frame failed"); |
| 1768 | } |
| 1769 | |
| 1770 | |
| 1771 | static int ath_ap_send_addba_req(struct sigma_dut *dut, struct sigma_conn *conn, |
| 1772 | struct sigma_cmd *cmd) |
| 1773 | { |
| 1774 | const char *val; |
Jouni Malinen | 016ae6c | 2019-11-04 17:00:01 +0200 | [diff] [blame] | 1775 | const char *ifname; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1776 | char buf[256]; |
| 1777 | int tid = 0; |
| 1778 | |
Jouni Malinen | 016ae6c | 2019-11-04 17:00:01 +0200 | [diff] [blame] | 1779 | ifname = get_main_ifname(dut); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1780 | val = get_param(cmd, "TID"); |
| 1781 | if (val) { |
| 1782 | tid = atoi(val); |
| 1783 | if (tid) |
| 1784 | ath_inject_frame(dut, ifname, tid); |
| 1785 | } |
| 1786 | |
| 1787 | /* NOTE: This is the command sequence on Peregrine for ADDBA */ |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 1788 | run_iwpriv(dut, ifname, "setaddbaoper 1"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1789 | |
| 1790 | snprintf(buf, sizeof(buf), "wifitool %s senddelba 1 %d 1 4", |
| 1791 | ifname, tid); |
| 1792 | if (system(buf) != 0) { |
| 1793 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 1794 | "wifitool senddelba failed"); |
| 1795 | } |
| 1796 | |
| 1797 | snprintf(buf, sizeof(buf), "wifitool %s sendaddba 1 %d 64", |
| 1798 | ifname, tid); |
| 1799 | if (system(buf) != 0) { |
| 1800 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 1801 | "wifitool sendaddba failed"); |
| 1802 | } |
| 1803 | |
| 1804 | return 1; |
| 1805 | } |
| 1806 | |
| 1807 | |
Mohammed Shafi Shajakhan | a0535d4 | 2016-06-17 11:55:00 +0530 | [diff] [blame] | 1808 | static int ath10k_debug_enable_addba_req(struct sigma_dut *dut, int tid, |
| 1809 | const char *sta_mac, |
| 1810 | const char *dir_path) |
| 1811 | { |
| 1812 | DIR *dir; |
| 1813 | struct dirent *entry; |
| 1814 | char buf[128], path[128]; |
Jouni Malinen | 3aa7286 | 2019-05-29 23:14:51 +0300 | [diff] [blame] | 1815 | int ret = 0, res; |
Mohammed Shafi Shajakhan | a0535d4 | 2016-06-17 11:55:00 +0530 | [diff] [blame] | 1816 | |
| 1817 | dir = opendir(dir_path); |
| 1818 | if (!dir) |
| 1819 | return 0; |
| 1820 | |
| 1821 | while ((entry = readdir(dir))) { |
| 1822 | ret = 1; |
| 1823 | |
| 1824 | if (strcmp(entry->d_name, ".") == 0 || |
| 1825 | strcmp(entry->d_name, "..") == 0) |
| 1826 | continue; |
| 1827 | |
Jouni Malinen | 3aa7286 | 2019-05-29 23:14:51 +0300 | [diff] [blame] | 1828 | res = snprintf(path, sizeof(path) - 1, "%s/%s", |
| 1829 | dir_path, entry->d_name); |
| 1830 | if (res < 0 || res >= sizeof(path)) |
| 1831 | continue; |
Mohammed Shafi Shajakhan | a0535d4 | 2016-06-17 11:55:00 +0530 | [diff] [blame] | 1832 | |
| 1833 | if (strcmp(entry->d_name, sta_mac) == 0) { |
Jouni Malinen | 3aa7286 | 2019-05-29 23:14:51 +0300 | [diff] [blame] | 1834 | res = snprintf(buf, sizeof(buf), |
| 1835 | "echo 1 > %s/aggr_mode", path); |
| 1836 | if (res < 0 || res >= sizeof(buf) || system(buf) != 0) { |
Mohammed Shafi Shajakhan | a0535d4 | 2016-06-17 11:55:00 +0530 | [diff] [blame] | 1837 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 1838 | "Failed to set aggr mode for ath10k"); |
| 1839 | } |
| 1840 | |
Jouni Malinen | 3aa7286 | 2019-05-29 23:14:51 +0300 | [diff] [blame] | 1841 | res = snprintf(buf, sizeof(buf), |
| 1842 | "echo %d 32 > %s/addba", tid, path); |
| 1843 | if (res < 0 || res >= sizeof(buf) || system(buf) != 0) { |
Mohammed Shafi Shajakhan | a0535d4 | 2016-06-17 11:55:00 +0530 | [diff] [blame] | 1844 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 1845 | "Failed to set addbareq for ath10k"); |
| 1846 | } |
| 1847 | |
| 1848 | break; |
| 1849 | } |
| 1850 | |
| 1851 | /* Recursively search subdirectories */ |
| 1852 | ath10k_debug_enable_addba_req(dut, tid, sta_mac, path); |
| 1853 | } |
| 1854 | |
| 1855 | closedir(dir); |
| 1856 | |
| 1857 | return ret; |
| 1858 | } |
| 1859 | |
| 1860 | |
| 1861 | static int ath10k_ap_send_addba_req(struct sigma_dut *dut, |
| 1862 | struct sigma_cmd *cmd) |
| 1863 | { |
| 1864 | const char *val; |
| 1865 | int tid = 0; |
| 1866 | |
| 1867 | val = get_param(cmd, "TID"); |
| 1868 | if (val) |
| 1869 | tid = atoi(val); |
| 1870 | |
| 1871 | val = get_param(cmd, "sta_mac_address"); |
| 1872 | if (!val) { |
| 1873 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 1874 | "Failed to parse station MAC address"); |
| 1875 | return 0; |
| 1876 | } |
| 1877 | |
| 1878 | return ath10k_debug_enable_addba_req(dut, tid, val, |
| 1879 | "/sys/kernel/debug/ieee80211"); |
| 1880 | } |
| 1881 | |
| 1882 | |
Jouni Malinen | f722271 | 2019-06-13 01:50:21 +0300 | [diff] [blame] | 1883 | static enum sigma_cmd_result cmd_ap_send_addba_req(struct sigma_dut *dut, |
| 1884 | struct sigma_conn *conn, |
| 1885 | struct sigma_cmd *cmd) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1886 | { |
| 1887 | /* const char *name = get_param(cmd, "NAME"); */ |
| 1888 | /* const char *ifname = get_param(cmd, "INTERFACE"); */ |
Mohammed Shafi Shajakhan | a0535d4 | 2016-06-17 11:55:00 +0530 | [diff] [blame] | 1889 | struct stat s; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1890 | |
Jouni Malinen | 016ae6c | 2019-11-04 17:00:01 +0200 | [diff] [blame] | 1891 | switch (get_driver_type(dut)) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1892 | case DRIVER_ATHEROS: |
| 1893 | return ath_ap_send_addba_req(dut, conn, cmd); |
Alexei Avshalom Lazar | 79fa3fe | 2018-12-24 15:43:33 +0200 | [diff] [blame] | 1894 | #ifdef __linux__ |
| 1895 | case DRIVER_WIL6210: |
| 1896 | return send_addba_60g(dut, conn, cmd, "sta_mac_address"); |
| 1897 | #endif /* __linux__ */ |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1898 | case DRIVER_OPENWRT: |
| 1899 | switch (get_openwrt_driver_type()) { |
| 1900 | case OPENWRT_DRIVER_ATHEROS: |
| 1901 | return ath_ap_send_addba_req(dut, conn, cmd); |
| 1902 | default: |
| 1903 | send_resp(dut, conn, SIGMA_ERROR, |
| 1904 | "errorCode,ap_send_addba_req not supported with this driver"); |
| 1905 | return 0; |
| 1906 | } |
Pradeep Reddy POTTETI | fdb0491 | 2016-08-02 14:16:24 +0530 | [diff] [blame] | 1907 | case DRIVER_WCN: |
| 1908 | case DRIVER_LINUX_WCN: |
| 1909 | /* AP automatically sends ADDBA request after association. */ |
| 1910 | sigma_dut_print(dut, DUT_MSG_INFO, |
| 1911 | "ap_send_addba_req command ignored"); |
| 1912 | return 1; |
Mohammed Shafi Shajakhan | a0535d4 | 2016-06-17 11:55:00 +0530 | [diff] [blame] | 1913 | case DRIVER_MAC80211: |
| 1914 | if (stat("/sys/module/ath10k_core", &s) == 0) |
| 1915 | return ath10k_ap_send_addba_req(dut, cmd); |
| 1916 | /* fall through */ |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1917 | default: |
| 1918 | send_resp(dut, conn, SIGMA_ERROR, |
| 1919 | "errorCode,ap_send_addba_req not supported with this driver"); |
| 1920 | return 0; |
| 1921 | } |
| 1922 | } |
| 1923 | |
| 1924 | |
Jouni Malinen | f722271 | 2019-06-13 01:50:21 +0300 | [diff] [blame] | 1925 | static enum sigma_cmd_result cmd_ap_set_security(struct sigma_dut *dut, |
| 1926 | struct sigma_conn *conn, |
| 1927 | struct sigma_cmd *cmd) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1928 | { |
| 1929 | /* const char *name = get_param(cmd, "NAME"); */ |
| 1930 | const char *val; |
| 1931 | unsigned int wlan_tag = 1; |
Ankita Bajaj | 0d212e8 | 2017-11-27 15:54:57 +0530 | [diff] [blame] | 1932 | const char *security; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1933 | |
| 1934 | val = get_param(cmd, "WLAN_TAG"); |
| 1935 | if (val) |
| 1936 | wlan_tag = atoi(val); |
| 1937 | |
Ankita Bajaj | 0d212e8 | 2017-11-27 15:54:57 +0530 | [diff] [blame] | 1938 | security = get_param(cmd, "Security"); |
| 1939 | |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 1940 | if (wlan_tag > 1) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1941 | val = get_param(cmd, "KEYMGNT"); |
Ankita Bajaj | 0d212e8 | 2017-11-27 15:54:57 +0530 | [diff] [blame] | 1942 | if (!val) |
| 1943 | val = get_param(cmd, "KeyMgmtType"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1944 | if (val) { |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 1945 | if (strcasecmp(val, "NONE") == 0) { |
| 1946 | dut->ap_tag_key_mgmt[wlan_tag - 2] = AP2_OPEN; |
| 1947 | } else if (strcasecmp(val, "OSEN") == 0 && |
| 1948 | wlan_tag == 2) { |
| 1949 | /* |
| 1950 | * OSEN only supported on WLAN_TAG = 2 for now |
| 1951 | */ |
| 1952 | dut->ap_tag_key_mgmt[wlan_tag - 2] = AP2_OSEN; |
Ankita Bajaj | 0d212e8 | 2017-11-27 15:54:57 +0530 | [diff] [blame] | 1953 | } else if (strcasecmp(val, "WPA2-PSK") == 0 || |
| 1954 | (security && |
| 1955 | strcasecmp(security, "PSK") == 0 && |
| 1956 | strcasecmp(val, "WPA2") == 0)) { |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 1957 | dut->ap_tag_key_mgmt[wlan_tag - 2] = |
| 1958 | AP2_WPA2_PSK; |
Jouni Malinen | 353ba8b | 2018-01-10 17:04:12 +0200 | [diff] [blame] | 1959 | } else if (strcasecmp(val, "OWE") == 0 && |
| 1960 | wlan_tag == 2) { |
| 1961 | dut->ap_tag_key_mgmt[wlan_tag - 2] = |
| 1962 | AP2_WPA2_OWE; |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 1963 | } else { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1964 | send_resp(dut, conn, SIGMA_INVALID, |
| 1965 | "errorCode,Unsupported KEYMGNT"); |
| 1966 | return 0; |
| 1967 | } |
| 1968 | return 1; |
| 1969 | } |
| 1970 | } |
| 1971 | |
| 1972 | val = get_param(cmd, "KEYMGNT"); |
Ankita Bajaj | 0d212e8 | 2017-11-27 15:54:57 +0530 | [diff] [blame] | 1973 | if (!val) |
| 1974 | val = get_param(cmd,"KeyMgmtType"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1975 | if (val) { |
Ankita Bajaj | 0d212e8 | 2017-11-27 15:54:57 +0530 | [diff] [blame] | 1976 | if (strcasecmp(val, "WPA2-PSK") == 0 || |
| 1977 | (security && strcasecmp(security, "PSK") == 0 && |
| 1978 | strcasecmp(val, "WPA2") == 0)) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1979 | dut->ap_key_mgmt = AP_WPA2_PSK; |
| 1980 | dut->ap_cipher = AP_CCMP; |
| 1981 | } else if (strcasecmp(val, "WPA2-EAP") == 0 || |
| 1982 | strcasecmp(val, "WPA2-Ent") == 0) { |
| 1983 | dut->ap_key_mgmt = AP_WPA2_EAP; |
| 1984 | dut->ap_cipher = AP_CCMP; |
Jouni Malinen | ad395a2 | 2017-09-01 21:13:46 +0300 | [diff] [blame] | 1985 | } else if (strcasecmp(val, "SuiteB") == 0) { |
| 1986 | dut->ap_key_mgmt = AP_SUITEB; |
| 1987 | dut->ap_cipher = AP_GCMP_256; |
Jouni Malinen | d75e4d8 | 2018-01-11 20:21:15 +0200 | [diff] [blame] | 1988 | dut->ap_pmf = AP_PMF_REQUIRED; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1989 | } else if (strcasecmp(val, "WPA-PSK") == 0) { |
| 1990 | dut->ap_key_mgmt = AP_WPA_PSK; |
| 1991 | dut->ap_cipher = AP_TKIP; |
| 1992 | } else if (strcasecmp(val, "WPA-EAP") == 0 || |
| 1993 | strcasecmp(val, "WPA-Ent") == 0) { |
| 1994 | dut->ap_key_mgmt = AP_WPA_EAP; |
| 1995 | dut->ap_cipher = AP_TKIP; |
| 1996 | } else if (strcasecmp(val, "WPA2-Mixed") == 0) { |
| 1997 | dut->ap_key_mgmt = AP_WPA2_EAP_MIXED; |
| 1998 | dut->ap_cipher = AP_CCMP_TKIP; |
| 1999 | } else if (strcasecmp(val, "WPA2-PSK-Mixed") == 0) { |
| 2000 | dut->ap_key_mgmt = AP_WPA2_PSK_MIXED; |
| 2001 | dut->ap_cipher = AP_CCMP_TKIP; |
Jouni Malinen | 794a7a3 | 2018-01-10 16:39:34 +0200 | [diff] [blame] | 2002 | } else if (strcasecmp(val, "WPA2-SAE") == 0 || |
| 2003 | strcasecmp(val, "SAE") == 0) { |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 2004 | dut->ap_key_mgmt = AP_WPA2_SAE; |
| 2005 | dut->ap_cipher = AP_CCMP; |
Jouni Malinen | 1287cd7 | 2018-01-04 17:08:01 +0200 | [diff] [blame] | 2006 | dut->ap_pmf = AP_PMF_REQUIRED; |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 2007 | } else if (strcasecmp(val, "WPA2-PSK-SAE") == 0) { |
| 2008 | dut->ap_key_mgmt = AP_WPA2_PSK_SAE; |
| 2009 | dut->ap_cipher = AP_CCMP; |
Jouni Malinen | 1287cd7 | 2018-01-04 17:08:01 +0200 | [diff] [blame] | 2010 | dut->ap_pmf = AP_PMF_OPTIONAL; |
Jouni Malinen | 147b3c3 | 2017-10-09 16:51:54 +0300 | [diff] [blame] | 2011 | } else if (strcasecmp(val, "OWE") == 0) { |
| 2012 | dut->ap_key_mgmt = AP_WPA2_OWE; |
| 2013 | dut->ap_cipher = AP_CCMP; |
Jouni Malinen | 1287cd7 | 2018-01-04 17:08:01 +0200 | [diff] [blame] | 2014 | dut->ap_pmf = AP_PMF_REQUIRED; |
Jouni Malinen | 4cf699f | 2018-06-19 00:46:27 +0300 | [diff] [blame] | 2015 | } else if (strcasecmp(val, "WPA2-ENT-OSEN") == 0) { |
| 2016 | dut->ap_key_mgmt = AP_WPA2_EAP_OSEN; |
| 2017 | dut->ap_cipher = AP_CCMP; |
| 2018 | dut->ap_pmf = AP_PMF_OPTIONAL; |
Jouni Malinen | c2b9121 | 2018-09-12 02:26:39 +0300 | [diff] [blame] | 2019 | } else if (strcasecmp(val, "OSEN") == 0) { |
| 2020 | dut->ap_key_mgmt = AP_OSEN; |
| 2021 | dut->ap_cipher = AP_CCMP; |
Jouni Malinen | 6be21c8 | 2018-08-01 18:47:24 +0300 | [diff] [blame] | 2022 | } else if (strcasecmp(val, "FT-EAP") == 0) { |
| 2023 | dut->ap_key_mgmt = AP_WPA2_FT_EAP; |
| 2024 | dut->ap_cipher = AP_CCMP; |
| 2025 | dut->ap_pmf = AP_PMF_OPTIONAL; |
| 2026 | } else if (strcasecmp(val, "FT-PSK") == 0) { |
| 2027 | dut->ap_key_mgmt = AP_WPA2_FT_PSK; |
| 2028 | dut->ap_cipher = AP_CCMP; |
| 2029 | dut->ap_pmf = AP_PMF_OPTIONAL; |
| 2030 | } else if (strcasecmp(val, "WPA2-ENT-256") == 0) { |
| 2031 | dut->ap_key_mgmt = AP_WPA2_EAP_SHA256; |
| 2032 | dut->ap_cipher = AP_CCMP; |
| 2033 | dut->ap_pmf = AP_PMF_OPTIONAL; |
| 2034 | } else if (strcasecmp(val, "WPA2-PSK-256") == 0) { |
| 2035 | dut->ap_key_mgmt = AP_WPA2_PSK_SHA256; |
| 2036 | dut->ap_cipher = AP_CCMP; |
| 2037 | dut->ap_pmf = AP_PMF_OPTIONAL; |
| 2038 | } else if (strcasecmp(val, "WPA2-ENT-FT-EAP") == 0) { |
| 2039 | dut->ap_key_mgmt = AP_WPA2_ENT_FT_EAP; |
| 2040 | dut->ap_cipher = AP_CCMP; |
| 2041 | dut->ap_pmf = AP_PMF_OPTIONAL; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2042 | } else if (strcasecmp(val, "NONE") == 0) { |
| 2043 | dut->ap_key_mgmt = AP_OPEN; |
| 2044 | dut->ap_cipher = AP_PLAIN; |
| 2045 | } else { |
| 2046 | send_resp(dut, conn, SIGMA_INVALID, |
| 2047 | "errorCode,Unsupported KEYMGNT"); |
| 2048 | return 0; |
| 2049 | } |
| 2050 | } |
| 2051 | |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 2052 | val = get_param(cmd, "ECGroupID"); |
| 2053 | if (val) { |
Jouni Malinen | ed670f4 | 2017-08-31 01:39:28 +0300 | [diff] [blame] | 2054 | free(dut->ap_sae_groups); |
| 2055 | dut->ap_sae_groups = strdup(val); |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 2056 | } |
| 2057 | |
Jouni Malinen | 2f524ce | 2017-08-31 01:43:29 +0300 | [diff] [blame] | 2058 | val = get_param(cmd, "AntiCloggingThreshold"); |
| 2059 | if (val) |
| 2060 | dut->sae_anti_clogging_threshold = atoi(val); |
| 2061 | |
Jouni Malinen | b347db0 | 2017-09-02 01:36:03 +0300 | [diff] [blame] | 2062 | val = get_param(cmd, "Reflection"); |
| 2063 | if (val) |
| 2064 | dut->sae_reflection = strcasecmp(val, "SAE") == 0; |
| 2065 | |
Jouni Malinen | 6814313 | 2017-09-02 02:34:08 +0300 | [diff] [blame] | 2066 | val = get_param(cmd, "InvalidSAEElement"); |
| 2067 | if (val) { |
| 2068 | free(dut->sae_commit_override); |
| 2069 | dut->sae_commit_override = strdup(val); |
| 2070 | } |
| 2071 | |
Jouni Malinen | 09550de | 2019-03-26 00:24:11 +0200 | [diff] [blame] | 2072 | val = get_param(cmd, "SAEPasswords"); |
| 2073 | if (val) { |
| 2074 | free(dut->ap_sae_passwords); |
| 2075 | dut->ap_sae_passwords = strdup(val); |
| 2076 | } |
| 2077 | |
Jouni Malinen | 3c740ab | 2019-10-10 15:55:11 +0300 | [diff] [blame] | 2078 | val = get_param(cmd, "SAE_Confirm_Immediate"); |
| 2079 | if (val) |
| 2080 | dut->sae_confirm_immediate = get_enable_disable(val); |
| 2081 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2082 | val = get_param(cmd, "ENCRYPT"); |
Ankita Bajaj | 0d212e8 | 2017-11-27 15:54:57 +0530 | [diff] [blame] | 2083 | if (!val) |
| 2084 | val = get_param(cmd, "EncpType"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2085 | if (val) { |
| 2086 | if (strcasecmp(val, "WEP") == 0) { |
| 2087 | dut->ap_cipher = AP_WEP; |
| 2088 | } else if (strcasecmp(val, "TKIP") == 0) { |
| 2089 | dut->ap_cipher = AP_TKIP; |
| 2090 | } else if (strcasecmp(val, "AES") == 0 || |
| 2091 | strcasecmp(val, "AES-CCMP") == 0) { |
| 2092 | dut->ap_cipher = AP_CCMP; |
Jouni Malinen | 3d633da | 2017-09-14 22:19:21 +0300 | [diff] [blame] | 2093 | } else if (strcasecmp(val, "AES-GCMP") == 0) { |
| 2094 | dut->ap_cipher = AP_GCMP_128; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2095 | } else { |
| 2096 | send_resp(dut, conn, SIGMA_INVALID, |
| 2097 | "errorCode,Unsupported ENCRYPT"); |
| 2098 | return 0; |
| 2099 | } |
| 2100 | } |
| 2101 | |
Jouni Malinen | 3d633da | 2017-09-14 22:19:21 +0300 | [diff] [blame] | 2102 | val = get_param(cmd, "PairwiseCipher"); |
| 2103 | if (val) { |
| 2104 | if (strcasecmp(val, "AES-GCMP-256") == 0) { |
| 2105 | dut->ap_cipher = AP_GCMP_256; |
| 2106 | } else if (strcasecmp(val, "AES-CCMP-256") == 0) { |
| 2107 | dut->ap_cipher = AP_CCMP_256; |
| 2108 | } else if (strcasecmp(val, "AES-GCMP-128") == 0) { |
| 2109 | dut->ap_cipher = AP_GCMP_128; |
| 2110 | } else if (strcasecmp(val, "AES-CCMP-128") == 0) { |
| 2111 | dut->ap_cipher = AP_CCMP; |
Jouni Malinen | d538c78 | 2017-11-17 12:13:04 +0200 | [diff] [blame] | 2112 | } else if (strcasecmp(val, "AES-CCMP-128 AES-GCMP-256") == 0 || |
| 2113 | strcasecmp(val, "AES-GCMP-256 AES-CCMP-128") == 0) { |
| 2114 | dut->ap_cipher = AP_CCMP_128_GCMP_256; |
Jouni Malinen | 3d633da | 2017-09-14 22:19:21 +0300 | [diff] [blame] | 2115 | } else { |
| 2116 | send_resp(dut, conn, SIGMA_INVALID, |
| 2117 | "errorCode,Unsupported PairwiseCipher"); |
| 2118 | return 0; |
| 2119 | } |
| 2120 | } |
| 2121 | |
Jouni Malinen | 2ba2449 | 2017-11-17 12:43:59 +0200 | [diff] [blame] | 2122 | val = get_param(cmd, "GroupCipher"); |
| 2123 | if (val) { |
| 2124 | if (strcasecmp(val, "AES-GCMP-256") == 0) { |
| 2125 | dut->ap_group_cipher = AP_GCMP_256; |
| 2126 | } else if (strcasecmp(val, "AES-CCMP-256") == 0) { |
| 2127 | dut->ap_group_cipher = AP_CCMP_256; |
| 2128 | } else if (strcasecmp(val, "AES-GCMP-128") == 0) { |
| 2129 | dut->ap_group_cipher = AP_GCMP_128; |
| 2130 | } else if (strcasecmp(val, "AES-CCMP-128") == 0) { |
| 2131 | dut->ap_group_cipher = AP_CCMP; |
| 2132 | } else { |
| 2133 | send_resp(dut, conn, SIGMA_INVALID, |
| 2134 | "errorCode,Unsupported GroupCipher"); |
| 2135 | return 0; |
| 2136 | } |
| 2137 | } |
| 2138 | |
Jouni Malinen | 3d633da | 2017-09-14 22:19:21 +0300 | [diff] [blame] | 2139 | val = get_param(cmd, "GroupMgntCipher"); |
| 2140 | if (val) { |
| 2141 | if (strcasecmp(val, "BIP-GMAC-256") == 0) { |
| 2142 | dut->ap_group_mgmt_cipher = AP_BIP_GMAC_256; |
| 2143 | } else if (strcasecmp(val, "BIP-CMAC-256") == 0) { |
| 2144 | dut->ap_group_mgmt_cipher = AP_BIP_CMAC_256; |
| 2145 | } else if (strcasecmp(val, "BIP-GMAC-128") == 0) { |
| 2146 | dut->ap_group_mgmt_cipher = AP_BIP_GMAC_128; |
| 2147 | } else if (strcasecmp(val, "BIP-CMAC-128") == 0) { |
| 2148 | dut->ap_group_mgmt_cipher = AP_BIP_CMAC_128; |
| 2149 | } else { |
| 2150 | send_resp(dut, conn, SIGMA_INVALID, |
| 2151 | "errorCode,Unsupported GroupMgntCipher"); |
| 2152 | return 0; |
| 2153 | } |
| 2154 | } |
| 2155 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2156 | val = get_param(cmd, "WEPKEY"); |
| 2157 | if (val) { |
| 2158 | size_t len; |
| 2159 | if (dut->ap_cipher != AP_WEP) { |
| 2160 | send_resp(dut, conn, SIGMA_INVALID, |
| 2161 | "errorCode,Unexpected WEPKEY without WEP " |
| 2162 | "configuration"); |
| 2163 | return 0; |
| 2164 | } |
| 2165 | len = strlen(val); |
| 2166 | if (len != 10 && len != 26) { |
| 2167 | send_resp(dut, conn, SIGMA_INVALID, |
| 2168 | "errorCode,Unexpected WEPKEY length"); |
| 2169 | return 0; |
| 2170 | } |
| 2171 | snprintf(dut->ap_wepkey, sizeof(dut->ap_wepkey), "%s", val); |
| 2172 | } |
| 2173 | |
| 2174 | val = get_param(cmd, "PSK"); |
Ankita Bajaj | 0d212e8 | 2017-11-27 15:54:57 +0530 | [diff] [blame] | 2175 | if (!val) |
| 2176 | val = get_param(cmd, "passphrase"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2177 | if (val) { |
Jouni Malinen | da5f35b | 2019-03-26 00:25:53 +0200 | [diff] [blame] | 2178 | if (dut->ap_key_mgmt != AP_WPA2_SAE && |
| 2179 | (dut->ap_akm_values & (AKM_WPA_PSK | AKM_SAE)) != |
| 2180 | AKM_SAE && |
| 2181 | strlen(val) > 64) { |
| 2182 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 2183 | "Too long PSK/passphtase"); |
Jouni Malinen | 2126f42 | 2017-10-11 23:24:33 +0300 | [diff] [blame] | 2184 | return -1; |
Jouni Malinen | da5f35b | 2019-03-26 00:25:53 +0200 | [diff] [blame] | 2185 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2186 | if (strlen(val) > sizeof(dut->ap_passphrase) - 1) |
| 2187 | return -1; |
| 2188 | snprintf(dut->ap_passphrase, sizeof(dut->ap_passphrase), |
| 2189 | "%s", val); |
| 2190 | } |
| 2191 | |
Jouni Malinen | 6337062 | 2017-11-18 17:47:13 +0200 | [diff] [blame] | 2192 | val = get_param(cmd, "PSKHEX"); |
| 2193 | if (val) { |
| 2194 | if (strlen(val) != 64) |
| 2195 | return -1; |
| 2196 | strlcpy(dut->ap_psk, val, sizeof(dut->ap_psk)); |
| 2197 | } |
| 2198 | |
Ankita Bajaj | 0d212e8 | 2017-11-27 15:54:57 +0530 | [diff] [blame] | 2199 | if (dut->program == PROGRAM_OCE && dut->dev_role == DEVROLE_STA_CFON) |
| 2200 | dut->ap_pmf = AP_PMF_OPTIONAL; |
| 2201 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2202 | val = get_param(cmd, "PMF"); |
| 2203 | if (val) { |
| 2204 | if (strcasecmp(val, "Disabled") == 0) { |
| 2205 | dut->ap_pmf = AP_PMF_DISABLED; |
| 2206 | } else if (strcasecmp(val, "Optional") == 0) { |
| 2207 | dut->ap_pmf = AP_PMF_OPTIONAL; |
| 2208 | } else if (strcasecmp(val, "Required") == 0) { |
| 2209 | dut->ap_pmf = AP_PMF_REQUIRED; |
| 2210 | } else { |
| 2211 | send_resp(dut, conn, SIGMA_INVALID, |
| 2212 | "errorCode,Unsupported PMF"); |
| 2213 | return 0; |
| 2214 | } |
| 2215 | } |
| 2216 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2217 | dut->ap_add_sha256 = 0; |
| 2218 | val = get_param(cmd, "SHA256AD"); |
| 2219 | if (val == NULL) |
| 2220 | val = get_param(cmd, "SHA256"); |
| 2221 | if (val) { |
| 2222 | if (strcasecmp(val, "Disabled") == 0) { |
| 2223 | } else if (strcasecmp(val, "Enabled") == 0) { |
| 2224 | dut->ap_add_sha256 = 1; |
| 2225 | } else { |
| 2226 | send_resp(dut, conn, SIGMA_INVALID, |
Jouni Malinen | a7fa620 | 2019-03-26 00:22:10 +0200 | [diff] [blame] | 2227 | "errorCode,Unsupported SHA256"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2228 | return 0; |
| 2229 | } |
| 2230 | } |
| 2231 | |
Sarvepalli, Rajesh Babu | 24dc7e4 | 2016-03-18 21:27:26 +0530 | [diff] [blame] | 2232 | val = get_param(cmd, "PreAuthentication"); |
| 2233 | if (val) { |
| 2234 | if (strcasecmp(val, "disabled") == 0) { |
| 2235 | dut->ap_rsn_preauth = 0; |
| 2236 | } else if (strcasecmp(val, "enabled") == 0) { |
| 2237 | dut->ap_rsn_preauth = 1; |
| 2238 | } else { |
| 2239 | send_resp(dut, conn, SIGMA_INVALID, |
| 2240 | "errorCode,Unsupported PreAuthentication value"); |
| 2241 | return 0; |
| 2242 | } |
| 2243 | } |
| 2244 | |
priyadharshini gowthaman | de81f39 | 2017-12-28 15:28:49 -0800 | [diff] [blame] | 2245 | val = get_param(cmd, "AKMSuiteType"); |
| 2246 | if (val) { |
Jouni Malinen | da5f35b | 2019-03-26 00:25:53 +0200 | [diff] [blame] | 2247 | const char *in_pos = val; |
priyadharshini gowthaman | de81f39 | 2017-12-28 15:28:49 -0800 | [diff] [blame] | 2248 | |
Jouni Malinen | da5f35b | 2019-03-26 00:25:53 +0200 | [diff] [blame] | 2249 | dut->ap_akm_values = 0; |
| 2250 | while (*in_pos) { |
| 2251 | int akm = atoi(in_pos); |
| 2252 | |
| 2253 | if (akm < 0 || akm >= 32) { |
| 2254 | send_resp(dut, conn, SIGMA_ERROR, |
| 2255 | "errorCode,Unsupported AKMSuiteType value"); |
| 2256 | return STATUS_SENT; |
| 2257 | } |
| 2258 | |
| 2259 | dut->ap_akm_values |= 1 << akm; |
| 2260 | |
| 2261 | in_pos = strchr(in_pos, ';'); |
| 2262 | if (!in_pos) |
| 2263 | break; |
| 2264 | while (*in_pos == ';') |
| 2265 | in_pos++; |
priyadharshini gowthaman | de81f39 | 2017-12-28 15:28:49 -0800 | [diff] [blame] | 2266 | } |
Jouni Malinen | da5f35b | 2019-03-26 00:25:53 +0200 | [diff] [blame] | 2267 | dut->ap_akm = 1; |
| 2268 | if (dut->ap_akm_values & (1 << 14)) |
| 2269 | dut->ap_add_sha384 = 1; |
| 2270 | if (dut->ap_akm_values & (1 << 15)) |
| 2271 | dut->ap_add_sha384 = 1; |
| 2272 | } |
| 2273 | |
| 2274 | if (dut->ap_key_mgmt == AP_OPEN && !dut->ap_akm_values) { |
| 2275 | dut->ap_hs2 = 0; |
| 2276 | dut->ap_pmf = AP_PMF_DISABLED; |
priyadharshini gowthaman | de81f39 | 2017-12-28 15:28:49 -0800 | [diff] [blame] | 2277 | } |
| 2278 | |
| 2279 | val = get_param(cmd, "PMKSACaching"); |
| 2280 | if (val) { |
| 2281 | dut->ap_pmksa = 1; |
| 2282 | if (strcasecmp(val, "disabled") == 0) { |
| 2283 | dut->ap_pmksa_caching = 1; |
| 2284 | } else if (strcasecmp(val, "enabled") == 0) { |
| 2285 | dut->ap_pmksa_caching = 0; |
| 2286 | } else { |
| 2287 | send_resp(dut, conn, SIGMA_INVALID, |
| 2288 | "errorCode,Unsupported PMKSACaching value"); |
| 2289 | return 0; |
| 2290 | } |
| 2291 | } |
| 2292 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2293 | return 1; |
| 2294 | } |
| 2295 | |
| 2296 | |
Ankita Bajaj | 0d5825b | 2017-10-25 16:20:17 +0530 | [diff] [blame] | 2297 | int sta_cfon_set_wireless(struct sigma_dut *dut, struct sigma_conn *conn, |
| 2298 | struct sigma_cmd *cmd) |
| 2299 | { |
| 2300 | int status; |
| 2301 | |
| 2302 | status = cmd_ap_set_wireless(dut, conn, cmd); |
| 2303 | if (status != 1) |
| 2304 | return status; |
Ankita Bajaj | 0d212e8 | 2017-11-27 15:54:57 +0530 | [diff] [blame] | 2305 | status = cmd_ap_set_security(dut, conn, cmd); |
| 2306 | if (status != 1) |
| 2307 | return status; |
Ankita Bajaj | 0d5825b | 2017-10-25 16:20:17 +0530 | [diff] [blame] | 2308 | return cmd_ap_config_commit(dut, conn, cmd); |
| 2309 | } |
| 2310 | |
| 2311 | |
Jouni Malinen | f722271 | 2019-06-13 01:50:21 +0300 | [diff] [blame] | 2312 | static enum sigma_cmd_result cmd_ap_set_radius(struct sigma_dut *dut, |
| 2313 | struct sigma_conn *conn, |
| 2314 | struct sigma_cmd *cmd) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2315 | { |
| 2316 | /* const char *name = get_param(cmd, "NAME"); */ |
| 2317 | const char *val; |
| 2318 | unsigned int wlan_tag = 1, radius_port = 0; |
| 2319 | char *radius_ipaddr = NULL, *radius_password = NULL; |
| 2320 | |
| 2321 | val = get_param(cmd, "WLAN_TAG"); |
| 2322 | if (val) { |
| 2323 | wlan_tag = atoi(val); |
| 2324 | if (wlan_tag != 1 && wlan_tag != 2) { |
| 2325 | send_resp(dut, conn, SIGMA_INVALID, |
| 2326 | "errorCode,Invalid WLAN_TAG"); |
| 2327 | return 0; |
| 2328 | } |
| 2329 | } |
| 2330 | |
| 2331 | val = get_param(cmd, "PORT"); |
| 2332 | if (val) |
| 2333 | radius_port = atoi(val); |
| 2334 | |
| 2335 | if (wlan_tag == 1) { |
| 2336 | if (radius_port) |
| 2337 | dut->ap_radius_port = radius_port; |
| 2338 | radius_ipaddr = dut->ap_radius_ipaddr; |
| 2339 | radius_password = dut->ap_radius_password; |
| 2340 | } else if (wlan_tag == 2) { |
| 2341 | if (radius_port) |
| 2342 | dut->ap2_radius_port = radius_port; |
| 2343 | radius_ipaddr = dut->ap2_radius_ipaddr; |
| 2344 | radius_password = dut->ap2_radius_password; |
| 2345 | } |
| 2346 | |
| 2347 | val = get_param(cmd, "IPADDR"); |
| 2348 | if (val) { |
| 2349 | if (strlen(val) > sizeof(dut->ap_radius_ipaddr) - 1) |
| 2350 | return -1; |
| 2351 | snprintf(radius_ipaddr, sizeof(dut->ap_radius_ipaddr), |
| 2352 | "%s", val); |
| 2353 | } |
| 2354 | |
| 2355 | val = get_param(cmd, "PASSWORD"); |
| 2356 | if (val) { |
| 2357 | if (strlen(val) > sizeof(dut->ap_radius_password) - 1) |
| 2358 | return -1; |
| 2359 | snprintf(radius_password, |
| 2360 | sizeof(dut->ap_radius_password), "%s", val); |
| 2361 | } |
| 2362 | |
| 2363 | return 1; |
| 2364 | } |
| 2365 | |
| 2366 | |
Priyadharshini Gowthaman | 8018c98 | 2019-10-31 15:14:37 -0700 | [diff] [blame] | 2367 | static void owrt_ap_set_qcawifi(struct sigma_dut *dut, const char *key, |
| 2368 | const char *val) |
| 2369 | { |
| 2370 | if (!val) { |
| 2371 | run_system_wrapper(dut, "uci delete wireless.qcawifi.%s", key); |
| 2372 | return; |
| 2373 | } |
| 2374 | |
| 2375 | run_system(dut, "uci set wireless.qcawifi=qcawifi"); |
| 2376 | run_system_wrapper(dut, "uci set wireless.qcawifi.%s=%s", key, val); |
| 2377 | } |
| 2378 | |
| 2379 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2380 | static void owrt_ap_set_radio(struct sigma_dut *dut, int id, |
| 2381 | const char *key, const char *val) |
| 2382 | { |
| 2383 | char buf[100]; |
| 2384 | |
| 2385 | if (val == NULL) { |
| 2386 | snprintf(buf, sizeof(buf), |
| 2387 | "uci delete wireless.wifi%d.%s", id, key); |
| 2388 | run_system(dut, buf); |
| 2389 | return; |
| 2390 | } |
| 2391 | |
| 2392 | snprintf(buf, sizeof(buf), "uci set wireless.wifi%d.%s=%s", |
| 2393 | id, key, val); |
| 2394 | run_system(dut, buf); |
| 2395 | } |
| 2396 | |
| 2397 | |
| 2398 | static void owrt_ap_set_list_radio(struct sigma_dut *dut, int id, |
| 2399 | const char *key, const char *val) |
| 2400 | { |
| 2401 | char buf[256]; |
| 2402 | |
| 2403 | if (val == NULL) { |
| 2404 | snprintf(buf, sizeof(buf), |
| 2405 | "uci del_list wireless.wifi%d.%s", id, key); |
| 2406 | run_system(dut, buf); |
| 2407 | return; |
| 2408 | } |
| 2409 | |
| 2410 | snprintf(buf, sizeof(buf), "uci add_list wireless.wifi%d.%s=%s", |
| 2411 | id, key, val); |
| 2412 | run_system(dut, buf); |
| 2413 | } |
| 2414 | |
| 2415 | |
| 2416 | static void owrt_ap_set_vap(struct sigma_dut *dut, int id, const char *key, |
| 2417 | const char *val) |
| 2418 | { |
| 2419 | char buf[256]; |
| 2420 | |
| 2421 | if (val == NULL) { |
| 2422 | snprintf(buf, sizeof(buf), |
| 2423 | "uci delete wireless.@wifi-iface[%d].%s", id, key); |
| 2424 | run_system(dut, buf); |
| 2425 | return; |
| 2426 | } |
| 2427 | |
| 2428 | snprintf(buf, sizeof(buf), "uci set wireless.@wifi-iface[%d].%s=%s", |
| 2429 | id, key, val); |
| 2430 | run_system(dut, buf); |
| 2431 | } |
| 2432 | |
| 2433 | |
| 2434 | static void owrt_ap_set_list_vap(struct sigma_dut *dut, int id, |
| 2435 | const char *key, const char *val) |
| 2436 | { |
priyadharshini gowthaman | 2323d0a | 2016-09-02 15:48:02 -0700 | [diff] [blame] | 2437 | char buf[1024]; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2438 | |
| 2439 | if (val == NULL) { |
| 2440 | snprintf(buf, sizeof(buf), |
| 2441 | "uci del_list wireless.@wifi-iface[%d].%s", id, key); |
| 2442 | run_system(dut, buf); |
| 2443 | return; |
| 2444 | } |
| 2445 | |
| 2446 | snprintf(buf, sizeof(buf), |
| 2447 | "uci add_list wireless.@wifi-iface[%d].%s=%s", |
| 2448 | id, key, val); |
| 2449 | run_system(dut, buf); |
| 2450 | } |
| 2451 | |
| 2452 | |
| 2453 | static void owrt_ap_add_vap(struct sigma_dut *dut, int id, const char *key, |
| 2454 | const char *val) |
| 2455 | { |
| 2456 | char buf[256]; |
Jouni Malinen | 3aa7286 | 2019-05-29 23:14:51 +0300 | [diff] [blame] | 2457 | int res; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2458 | |
| 2459 | if (val == NULL) { |
Jouni Malinen | 3aa7286 | 2019-05-29 23:14:51 +0300 | [diff] [blame] | 2460 | res = snprintf(buf, sizeof(buf), |
| 2461 | "uci delete wireless.@wifi-iface[%d].%s", |
| 2462 | id, key); |
| 2463 | if (res >= 0 && res < sizeof(buf)) |
| 2464 | run_system(dut, buf); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2465 | return; |
| 2466 | } |
| 2467 | |
Jouni Malinen | 3aa7286 | 2019-05-29 23:14:51 +0300 | [diff] [blame] | 2468 | run_system(dut, "uci add wireless wifi-iface"); |
| 2469 | res = snprintf(buf, sizeof(buf), |
| 2470 | "uci set wireless.@wifi-iface[%d].%s=%s", |
| 2471 | id, key, val); |
| 2472 | if (res >= 0 && res < sizeof(buf)) |
| 2473 | run_system(dut, buf); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2474 | snprintf(buf, sizeof(buf), "uci set wireless.@wifi-iface[%d].%s=%s", |
| 2475 | id, "network", "lan"); |
| 2476 | run_system(dut, buf); |
| 2477 | snprintf(buf, sizeof(buf), "uci set wireless.@wifi-iface[%d].%s=%s", |
| 2478 | id, "mode", "ap"); |
| 2479 | run_system(dut, buf); |
| 2480 | snprintf(buf, sizeof(buf), "uci set wireless.@wifi-iface[%d].%s=%s", |
| 2481 | id, "encryption", "none"); |
| 2482 | run_system(dut, buf); |
| 2483 | } |
| 2484 | |
| 2485 | |
Alejandro Vasquez | 363f558 | 2018-07-17 11:25:05 -0700 | [diff] [blame] | 2486 | #define OPENWRT_MAX_NUM_RADIOS (MAX_RADIO + 1) |
Priyadharshini Gowthaman | 8018c98 | 2019-10-31 15:14:37 -0700 | [diff] [blame] | 2487 | static int owrt_ap_config_radio(struct sigma_dut *dut) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2488 | { |
Alejandro Vasquez | 363f558 | 2018-07-17 11:25:05 -0700 | [diff] [blame] | 2489 | int radio_id[MAX_RADIO] = { 0, 1, 2 }; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2490 | int radio_count, radio_no; |
| 2491 | char buf[64]; |
| 2492 | |
| 2493 | for (radio_count = 0; radio_count < OPENWRT_MAX_NUM_RADIOS; |
| 2494 | radio_count++) { |
| 2495 | snprintf(buf, sizeof(buf), "%s%d", "wifi", radio_count); |
| 2496 | for (radio_no = 0; radio_no < MAX_RADIO; radio_no++) { |
| 2497 | if (!sigma_radio_ifname[radio_no] || |
| 2498 | strcmp(sigma_radio_ifname[radio_no], buf) != 0) |
| 2499 | continue; |
| 2500 | owrt_ap_set_radio(dut, radio_count, "disabled", "0"); |
| 2501 | owrt_ap_set_vap(dut, radio_count, "device", buf); |
| 2502 | radio_id[radio_no] = radio_count; |
| 2503 | } |
| 2504 | } |
| 2505 | |
| 2506 | /* Hardware mode (11a/b/g/n/ac) & HT mode selection */ |
| 2507 | switch (dut->ap_mode) { |
| 2508 | case AP_11g: |
| 2509 | owrt_ap_set_radio(dut, radio_id[0], "hwmode", "11g"); |
| 2510 | break; |
| 2511 | case AP_11b: |
| 2512 | owrt_ap_set_radio(dut, radio_id[0], "hwmode", "11b"); |
| 2513 | break; |
| 2514 | case AP_11ng: |
| 2515 | owrt_ap_set_radio(dut, radio_id[0], "hwmode", "11ng"); |
| 2516 | owrt_ap_set_radio(dut, radio_id[0], "htmode", "HT20"); |
| 2517 | break; |
| 2518 | case AP_11a: |
| 2519 | owrt_ap_set_radio(dut, radio_id[0], "hwmode", "11a"); |
| 2520 | break; |
| 2521 | case AP_11na: |
| 2522 | owrt_ap_set_radio(dut, radio_id[0], "hwmode", "11na"); |
| 2523 | owrt_ap_set_radio(dut, radio_id[0], "htmode", "HT20"); |
| 2524 | break; |
| 2525 | case AP_11ac: |
| 2526 | owrt_ap_set_radio(dut, radio_id[0], "hwmode", "11ac"); |
| 2527 | owrt_ap_set_radio(dut, radio_id[0], "htmode", "HT80"); |
| 2528 | break; |
| 2529 | case AP_inval: |
| 2530 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 2531 | "MODE NOT SPECIFIED!"); |
Priyadharshini Gowthaman | 8018c98 | 2019-10-31 15:14:37 -0700 | [diff] [blame] | 2532 | return -1; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2533 | default: |
| 2534 | owrt_ap_set_radio(dut, radio_id[0], "hwmode", "11ng"); |
| 2535 | owrt_ap_set_radio(dut, radio_id[0], "htmode", "HT20"); |
| 2536 | break; |
| 2537 | } |
| 2538 | |
| 2539 | if (dut->ap_is_dual) { |
| 2540 | /* Hardware mode (11a/b/g/n/ac) & HT mode selection */ |
| 2541 | switch (dut->ap_mode_1) { |
| 2542 | case AP_11g: |
| 2543 | owrt_ap_set_radio(dut, radio_id[1], "hwmode", "11g"); |
| 2544 | break; |
| 2545 | case AP_11b: |
| 2546 | owrt_ap_set_radio(dut, radio_id[1], "hwmode", "11b"); |
| 2547 | break; |
| 2548 | case AP_11ng: |
| 2549 | owrt_ap_set_radio(dut, radio_id[1], "hwmode", "11ng"); |
| 2550 | owrt_ap_set_radio(dut, radio_id[1], "htmode", "HT20"); |
| 2551 | break; |
| 2552 | case AP_11a: |
| 2553 | owrt_ap_set_radio(dut, radio_id[1], "hwmode", "11a"); |
| 2554 | break; |
| 2555 | case AP_11na: |
| 2556 | owrt_ap_set_radio(dut, radio_id[1], "hwmode", "11na"); |
| 2557 | owrt_ap_set_radio(dut, radio_id[1], "htmode", "HT20"); |
| 2558 | break; |
| 2559 | case AP_11ac: |
| 2560 | owrt_ap_set_radio(dut, radio_id[1], "hwmode", "11ac"); |
| 2561 | owrt_ap_set_radio(dut, radio_id[1], "htmode", "HT80"); |
| 2562 | break; |
| 2563 | case AP_inval: |
| 2564 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 2565 | "MODE NOT SPECIFIED!"); |
Priyadharshini Gowthaman | 8018c98 | 2019-10-31 15:14:37 -0700 | [diff] [blame] | 2566 | return -1; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2567 | default: |
| 2568 | owrt_ap_set_radio(dut, radio_id[1], "hwmode", "11ng"); |
| 2569 | owrt_ap_set_radio(dut, radio_id[1], "htmode", "HT20"); |
| 2570 | break; |
| 2571 | } |
| 2572 | |
| 2573 | } |
| 2574 | |
| 2575 | /* Channel */ |
| 2576 | snprintf(buf, sizeof(buf), "%d", dut->ap_channel); |
| 2577 | owrt_ap_set_radio(dut, radio_id[0], "channel", buf); |
| 2578 | |
| 2579 | switch (dut->ap_chwidth) { |
| 2580 | case AP_20: |
| 2581 | owrt_ap_set_radio(dut, radio_id[0], "htmode", "HT20"); |
| 2582 | break; |
| 2583 | case AP_40: |
| 2584 | owrt_ap_set_radio(dut, radio_id[0], "htmode", "HT40"); |
| 2585 | break; |
| 2586 | case AP_80: |
| 2587 | owrt_ap_set_radio(dut, radio_id[0], "htmode", "HT80"); |
| 2588 | break; |
| 2589 | case AP_160: |
| 2590 | owrt_ap_set_radio(dut, radio_id[0], "htmode", "HT160"); |
| 2591 | break; |
priyadharshini gowthaman | 63ab848 | 2017-12-28 15:32:55 -0800 | [diff] [blame] | 2592 | case AP_80_80: |
| 2593 | owrt_ap_set_radio(dut, radio_id[0], "htmode", "HT80_80"); |
| 2594 | break; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2595 | case AP_AUTO: |
| 2596 | default: |
| 2597 | break; |
| 2598 | } |
| 2599 | |
| 2600 | if (dut->ap_channel == 140 || dut->ap_channel == 144) { |
| 2601 | if (get_openwrt_driver_type() == OPENWRT_DRIVER_ATHEROS) |
| 2602 | owrt_ap_set_radio(dut, radio_id[0], "set_ch_144", "3"); |
| 2603 | } |
| 2604 | |
| 2605 | if (dut->ap_is_dual) { |
| 2606 | snprintf(buf, sizeof(buf), "%d", dut->ap_channel_1); |
| 2607 | owrt_ap_set_radio(dut, radio_id[1], "channel", buf); |
| 2608 | } |
| 2609 | |
Adil Saeed Musthafa | 604c826 | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 2610 | /* Country Code */ |
| 2611 | if (dut->ap_reg_domain == REG_DOMAIN_GLOBAL) { |
| 2612 | const char *country; |
| 2613 | |
| 2614 | country = dut->ap_countrycode[0] ? dut->ap_countrycode : "US"; |
| 2615 | snprintf(buf, sizeof(buf), "%s4", country); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2616 | owrt_ap_set_radio(dut, radio_id[0], "country", buf); |
priyadharshini gowthaman | 27406b0 | 2017-12-28 15:35:45 -0800 | [diff] [blame] | 2617 | if (dut->ap_is_dual) |
| 2618 | owrt_ap_set_radio(dut, radio_id[1], "country", buf); |
Adil Saeed Musthafa | 604c826 | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 2619 | } else if (dut->ap_countrycode[0]) { |
| 2620 | owrt_ap_set_radio(dut, radio_id[0], "country", |
| 2621 | dut->ap_countrycode); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2622 | } |
| 2623 | |
| 2624 | if (dut->ap_disable_protection == 1) { |
| 2625 | owrt_ap_set_list_radio(dut, radio_id[0], "aggr_burst", "'0 0'"); |
| 2626 | owrt_ap_set_list_radio(dut, radio_id[0], "aggr_burst", "'1 0'"); |
| 2627 | owrt_ap_set_list_radio(dut, radio_id[0], "aggr_burst", "'2 0'"); |
| 2628 | owrt_ap_set_list_radio(dut, radio_id[0], "aggr_burst", "'3 0'"); |
| 2629 | } |
priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 2630 | |
| 2631 | if (dut->ap_oce == VALUE_ENABLED && |
Jouni Malinen | 016ae6c | 2019-11-04 17:00:01 +0200 | [diff] [blame] | 2632 | get_driver_type(dut) == DRIVER_OPENWRT) |
priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 2633 | owrt_ap_set_radio(dut, radio_id[0], "bcnburst", "1"); |
Priyadharshini Gowthaman | 8018c98 | 2019-10-31 15:14:37 -0700 | [diff] [blame] | 2634 | |
| 2635 | if (dut->ap_mbssid == VALUE_ENABLED) |
| 2636 | owrt_ap_set_qcawifi(dut, "mbss_ie_enable", "1"); |
| 2637 | |
| 2638 | return 1; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2639 | } |
| 2640 | |
| 2641 | |
| 2642 | static int owrt_ap_config_vap_hs2(struct sigma_dut *dut, int vap_id) |
| 2643 | { |
| 2644 | char buf[256]; |
| 2645 | |
| 2646 | snprintf(buf, sizeof(buf), "%d", dut->ap_hs2); |
| 2647 | owrt_ap_set_vap(dut, vap_id, "hs20", buf); |
| 2648 | owrt_ap_set_vap(dut, vap_id, "qbssload", "1"); |
| 2649 | owrt_ap_set_vap(dut, vap_id, "hs20_deauth_req_timeout","3"); |
| 2650 | |
| 2651 | owrt_ap_set_list_vap(dut, vap_id, "hs20_oper_friendly_name", |
| 2652 | "'eng:Wi-Fi Alliance'"); |
| 2653 | |
| 2654 | owrt_ap_set_list_vap(dut, vap_id, "hs20_oper_friendly_name", |
| 2655 | "'chi:Wi-Fi\xe8\x81\x94\xe7\x9b\x9f'"); |
| 2656 | |
| 2657 | if (dut->ap_wan_metrics == 1) |
| 2658 | owrt_ap_set_vap(dut, vap_id, "hs20_wan_metrics", |
| 2659 | "'01:2500:384:0:0:10'"); |
| 2660 | else if (dut->ap_wan_metrics == 1) |
| 2661 | owrt_ap_set_vap(dut, vap_id, "hs20_wan_metrics", |
| 2662 | "'01:1500:384:20:20:10'"); |
| 2663 | else if (dut->ap_wan_metrics == 2) |
| 2664 | owrt_ap_set_vap(dut, vap_id, "hs20_wan_metrics", |
| 2665 | "'01:1500:384:20:20:10'"); |
| 2666 | else if (dut->ap_wan_metrics == 3) |
| 2667 | owrt_ap_set_vap(dut, vap_id, "hs20_wan_metrics", |
| 2668 | "'01:2000:1000:20:20:10'"); |
| 2669 | else if (dut->ap_wan_metrics == 4) |
| 2670 | owrt_ap_set_vap(dut, vap_id, "hs20_wan_metrics", |
| 2671 | "'01:8000:1000:20:20:10'"); |
| 2672 | else if (dut->ap_wan_metrics == 5) |
| 2673 | owrt_ap_set_vap(dut, vap_id, "hs20_wan_metrics", |
| 2674 | "'01:9000:5000:20:20:10'"); |
| 2675 | |
| 2676 | if (dut->ap_conn_capab == 1) { |
| 2677 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", "'1:0:0'"); |
| 2678 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", |
| 2679 | "'6:20:1'"); |
| 2680 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", |
| 2681 | "'6:22:0'"); |
| 2682 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", |
| 2683 | "'6:80:1'"); |
| 2684 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", |
| 2685 | "'6:443:1'"); |
| 2686 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", |
| 2687 | "'6:1723:0'"); |
| 2688 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", |
| 2689 | "'6:5060:0'"); |
| 2690 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", |
| 2691 | "'17:500:1'"); |
| 2692 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", |
| 2693 | "'17:5060:0'"); |
| 2694 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", |
| 2695 | "'17:4500:1'"); |
| 2696 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", |
| 2697 | "'50:0:1'"); |
| 2698 | } else if (dut->ap_conn_capab == 2) { |
| 2699 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", |
| 2700 | "'6:80:1'"); |
| 2701 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", |
| 2702 | "'6:443:1'"); |
| 2703 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", |
| 2704 | "'17:5060:1'"); |
| 2705 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", |
| 2706 | "'6:5060:1'"); |
| 2707 | } else if (dut->ap_conn_capab == 3) { |
| 2708 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", |
| 2709 | "'6:80:1'"); |
| 2710 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", |
| 2711 | "'6:443:1'"); |
| 2712 | } |
| 2713 | |
| 2714 | if (dut->ap_oper_class == 1) |
| 2715 | snprintf(buf, sizeof(buf), "%s", "51"); |
| 2716 | else if (dut->ap_oper_class == 2) |
| 2717 | snprintf(buf, sizeof(buf), "%s", "73"); |
| 2718 | else if (dut->ap_oper_class == 3) |
| 2719 | snprintf(buf, sizeof(buf), "%s", "5173"); |
| 2720 | |
| 2721 | if (dut->ap_oper_class) |
| 2722 | owrt_ap_set_vap(dut, vap_id, "hs20_operating_class", buf); |
| 2723 | |
| 2724 | if (dut->ap_osu_provider_list) { |
| 2725 | char *osu_friendly_name = NULL; |
| 2726 | char *osu_icon = NULL; |
| 2727 | char *osu_ssid = NULL; |
| 2728 | char *osu_nai = NULL; |
| 2729 | char *osu_service_desc = NULL; |
| 2730 | char *hs20_icon_filename = NULL; |
| 2731 | char hs20_icon[150]; |
| 2732 | int osu_method; |
| 2733 | |
| 2734 | hs20_icon_filename = "icon_red_zxx.png"; |
| 2735 | if (dut->ap_osu_icon_tag == 2) |
| 2736 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 2737 | snprintf(hs20_icon, sizeof(hs20_icon), |
| 2738 | "'128:61:zxx:image/png:icon_red_zxx.png:/etc/ath/%s'", |
| 2739 | hs20_icon_filename); |
| 2740 | osu_icon = "icon_red_zxx.png"; |
| 2741 | osu_ssid = "OSU"; |
| 2742 | osu_friendly_name = "'kor:SP 빨강 테스트 전용'"; |
| 2743 | osu_service_desc = "'kor:테스트 목적으로 무료 서비스'"; |
| 2744 | osu_method = (dut->ap_osu_method[0] == 0xFF) ? 1 : |
| 2745 | dut->ap_osu_method[0]; |
| 2746 | |
| 2747 | if (strlen(dut->ap_osu_server_uri[0])) |
| 2748 | owrt_ap_set_list_vap(dut, vap_id, "osu_server_uri", |
| 2749 | dut->ap_osu_server_uri[0]); |
| 2750 | else |
| 2751 | owrt_ap_set_list_vap(dut, vap_id, "osu_server_uri", |
| 2752 | "'https://osu-server.r2-testbed.wi-fi.org/'"); |
| 2753 | switch (dut->ap_osu_provider_list) { |
| 2754 | case 1: |
| 2755 | case 101: |
| 2756 | owrt_ap_set_list_vap(dut, vap_id, "osu_friendly_name", |
| 2757 | "'eng:SP Red Test Only'"); |
| 2758 | owrt_ap_set_list_vap(dut, vap_id, "osu_service_desc", |
| 2759 | "'eng:Free service for test purpose'"); |
| 2760 | owrt_ap_set_list_vap(dut, vap_id, "hs20_icon", |
| 2761 | hs20_icon); |
| 2762 | |
| 2763 | hs20_icon_filename = "icon_red_eng.png"; |
| 2764 | if (dut->ap_osu_icon_tag == 2) |
| 2765 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 2766 | |
| 2767 | snprintf(hs20_icon, sizeof(hs20_icon), |
| 2768 | "'160:76:eng:image/png:icon_red_eng.png:/etc/ath/%s'", |
| 2769 | hs20_icon_filename); |
| 2770 | owrt_ap_set_list_vap(dut, vap_id, "osu_icon", |
| 2771 | "icon_red_eng.png"); |
| 2772 | break; |
| 2773 | case 2: |
| 2774 | case 102: |
| 2775 | owrt_ap_set_list_vap(dut, vap_id, "osu_friendly_name", |
| 2776 | "'eng:Wireless Broadband Alliance'"); |
| 2777 | owrt_ap_set_list_vap(dut, vap_id, "osu_service_desc", |
| 2778 | "'eng:Free service for test purpose'"); |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2779 | hs20_icon_filename = "icon_orange_zxx.png"; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2780 | if (dut->ap_osu_icon_tag == 2) |
| 2781 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 2782 | |
| 2783 | snprintf(hs20_icon, sizeof(hs20_icon), |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2784 | "'128:61:zxx:image/png:icon_orange_zxx.png:/etc/ath/%s'", |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2785 | hs20_icon_filename); |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2786 | osu_icon = "icon_orange_zxx.png"; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2787 | osu_friendly_name = "'kor:와이어리스 브로드밴드 얼라이언스'"; |
| 2788 | break; |
| 2789 | case 3: |
| 2790 | case 103: |
Jouni Malinen | 02502de | 2018-10-15 17:19:33 +0300 | [diff] [blame] | 2791 | osu_friendly_name = "'spa:SP Red Test Only'"; |
| 2792 | osu_service_desc = "'spa:Free service for test purpose'"; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2793 | break; |
| 2794 | case 4: |
| 2795 | case 104: |
| 2796 | owrt_ap_set_list_vap(dut, vap_id, "osu_friendly_name", |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2797 | "'eng:SP Orange Test Only'"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2798 | owrt_ap_set_list_vap(dut, vap_id, "osu_service_desc", |
| 2799 | "'eng:Free service for test purpose'"); |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2800 | hs20_icon_filename = "icon_orange_eng.png"; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2801 | if (dut->ap_osu_icon_tag == 2) |
| 2802 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 2803 | |
| 2804 | snprintf(hs20_icon, sizeof(hs20_icon), |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2805 | "'160:76:eng:image/png:icon_orange_eng.png:/etc/ath/%s'", |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2806 | hs20_icon_filename); |
| 2807 | owrt_ap_set_list_vap(dut, vap_id, "hs20_icon", |
| 2808 | hs20_icon); |
Jouni Malinen | fd45ad5 | 2018-10-15 17:06:18 +0300 | [diff] [blame] | 2809 | osu_friendly_name = "'kor:SP 오렌지 테스트 전용'"; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2810 | |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2811 | hs20_icon_filename = "icon_orange_zxx.png"; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2812 | if (dut->ap_osu_icon_tag == 2) |
| 2813 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 2814 | |
| 2815 | snprintf(hs20_icon, sizeof(hs20_icon), |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2816 | "'128:61:zxx:image/png:icon_orange_zxx.png:/etc/ath/%s'", |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2817 | hs20_icon_filename); |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2818 | osu_icon = "icon_orange_zxx.png"; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2819 | break; |
| 2820 | case 5: |
| 2821 | case 105: |
| 2822 | owrt_ap_set_list_vap(dut, vap_id, "osu_friendly_name", |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2823 | "'eng:SP Orange Test Only'"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2824 | owrt_ap_set_list_vap(dut, vap_id, "osu_service_desc", |
| 2825 | "'eng:Free service for test purpose'"); |
Jouni Malinen | fd45ad5 | 2018-10-15 17:06:18 +0300 | [diff] [blame] | 2826 | osu_friendly_name = "'kor:SP 오렌지 테스트 전용'"; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2827 | |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2828 | hs20_icon_filename = "icon_orange_zxx.png"; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2829 | if (dut->ap_osu_icon_tag == 2) |
| 2830 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 2831 | |
| 2832 | snprintf(hs20_icon, sizeof(hs20_icon), |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2833 | "'128:61:zxx:image/png:icon_orange_zxx.png:/etc/ath/%s'", |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2834 | hs20_icon_filename); |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2835 | osu_icon = "icon_orange_zxx.png"; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2836 | break; |
| 2837 | case 6: |
| 2838 | case 106: |
| 2839 | owrt_ap_set_list_vap(dut, vap_id, "osu_friendly_name", |
| 2840 | "'eng:SP Green Test Only'"); |
| 2841 | owrt_ap_set_list_vap(dut, vap_id, "osu_friendly_name", |
| 2842 | "'kor:SP 초록 테스트 전용'"); |
| 2843 | |
| 2844 | hs20_icon_filename = "icon_green_zxx.png"; |
| 2845 | if (dut->ap_osu_icon_tag == 2) |
| 2846 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 2847 | |
| 2848 | snprintf(hs20_icon, sizeof(hs20_icon), |
| 2849 | "'128:61:zxx:image/png:icon_green_zxx.png:/etc/ath/%s'", |
| 2850 | hs20_icon_filename); |
| 2851 | owrt_ap_set_list_vap(dut, vap_id, "hs20_icon", |
| 2852 | hs20_icon); |
| 2853 | |
| 2854 | owrt_ap_set_list_vap(dut, vap_id, "osu_icon", |
| 2855 | "'icon_green_zxx.png'"); |
| 2856 | osu_method = (dut->ap_osu_method[0] == 0xFF) ? 0 : |
| 2857 | dut->ap_osu_method[0]; |
| 2858 | |
| 2859 | snprintf(buf, sizeof(buf), "%d", osu_method); |
| 2860 | owrt_ap_set_vap(dut, vap_id, "osu_method_list", buf); |
| 2861 | |
| 2862 | if (strlen(dut->ap_osu_server_uri[1])) |
| 2863 | owrt_ap_set_list_vap(dut, vap_id, |
| 2864 | "osu_server_uri", |
| 2865 | dut->ap_osu_server_uri[1]); |
| 2866 | else |
| 2867 | owrt_ap_set_list_vap(dut, vap_id, |
| 2868 | "osu_server_uri", |
| 2869 | "'https://osu-server.r2-testbed.wi-fi.org/'"); |
| 2870 | |
| 2871 | owrt_ap_set_list_vap(dut, vap_id, "osu_friendly_name", |
| 2872 | "'eng:SP Orange Test Only'"); |
| 2873 | |
| 2874 | hs20_icon_filename = "icon_orange_zxx.png"; |
| 2875 | if (dut->ap_osu_icon_tag == 2) |
| 2876 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 2877 | |
| 2878 | snprintf(hs20_icon, sizeof(hs20_icon), |
| 2879 | "'128:61:zxx:image/png:icon_orange_zxx.png:/etc/ath/%s'", |
| 2880 | hs20_icon_filename); |
| 2881 | |
| 2882 | osu_icon = "icon_orange_zxx.png"; |
| 2883 | osu_friendly_name = "'kor:SP 오렌지 테스트 전용'"; |
| 2884 | osu_method = (dut->ap_osu_method[1] == 0xFF) ? 0 : |
| 2885 | dut->ap_osu_method[1]; |
| 2886 | osu_service_desc = NULL; |
| 2887 | break; |
| 2888 | case 7: |
| 2889 | case 107: |
| 2890 | owrt_ap_set_list_vap(dut, vap_id, "osu_friendly_name", |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2891 | "'eng:SP Green Test Only'"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2892 | owrt_ap_set_list_vap(dut, vap_id, "osu_service_desc", |
| 2893 | "'eng:Free service for test purpose'"); |
| 2894 | |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2895 | hs20_icon_filename = "icon_green_eng.png"; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2896 | if (dut->ap_osu_icon_tag == 2) |
| 2897 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 2898 | |
| 2899 | snprintf(hs20_icon, sizeof(hs20_icon), |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2900 | "'160:76:eng:image/png:icon_green_eng.png:/etc/ath/%s'", |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2901 | hs20_icon_filename); |
| 2902 | owrt_ap_set_list_vap(dut, vap_id, "hs20_icon", |
| 2903 | hs20_icon); |
| 2904 | |
| 2905 | owrt_ap_set_list_vap(dut, vap_id, "osu_icon", |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2906 | "'icon_green_eng.png'"); |
Jouni Malinen | fd45ad5 | 2018-10-15 17:06:18 +0300 | [diff] [blame] | 2907 | osu_friendly_name = "'kor:SP 초록 테스트 전용'"; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2908 | |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2909 | hs20_icon_filename = "icon_green_zxx.png"; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2910 | if (dut->ap_osu_icon_tag == 2) |
| 2911 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 2912 | |
| 2913 | snprintf(hs20_icon, sizeof(hs20_icon), |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2914 | "'128:61:zxx:image/png:icon_green_zxx.png:/etc/ath/%s'", |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2915 | hs20_icon_filename); |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2916 | osu_icon = "icon_green_zxx.png"; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2917 | break; |
| 2918 | case 8: |
| 2919 | case 108: |
| 2920 | owrt_ap_set_list_vap(dut, vap_id, "osu_friendly_name", |
| 2921 | "'eng:SP Red Test Only'"); |
| 2922 | owrt_ap_set_list_vap(dut, vap_id, "osu_service_desc", |
| 2923 | "'eng:Free service for test purpose'"); |
| 2924 | osu_ssid = "OSU-Encrypted"; |
| 2925 | osu_nai = "'anonymous@hotspot.net'"; |
| 2926 | break; |
| 2927 | case 9: |
| 2928 | case 109: |
| 2929 | osu_ssid = "OSU-OSEN"; |
| 2930 | osu_nai = "'test-anonymous@wi-fi.org'"; |
| 2931 | osu_friendly_name = "'eng:SP Orange Test Only'"; |
| 2932 | hs20_icon_filename = "icon_orange_zxx.png"; |
| 2933 | if (dut->ap_osu_icon_tag == 2) |
| 2934 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 2935 | |
| 2936 | snprintf(hs20_icon, sizeof(hs20_icon), |
| 2937 | "'128:61:zxx:image/png:icon_orange_zxx.png:/etc/ath/%s'", |
| 2938 | hs20_icon_filename); |
| 2939 | osu_icon = "icon_orange_zxx.png"; |
| 2940 | osu_method = (dut->ap_osu_method[0] == 0xFF) ? 1 : |
| 2941 | dut->ap_osu_method[0]; |
| 2942 | osu_service_desc = NULL; |
| 2943 | break; |
| 2944 | default: |
| 2945 | break; |
| 2946 | } |
| 2947 | |
| 2948 | if (strlen(dut->ap_osu_ssid)) { |
Jouni Malinen | e6ac6a0 | 2018-09-11 02:40:17 +0300 | [diff] [blame] | 2949 | if (dut->ap_tag_ssid[0][0] && |
| 2950 | strcmp(dut->ap_tag_ssid[0], |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 2951 | dut->ap_osu_ssid) != 0 && |
| 2952 | strcmp(dut->ap_tag_ssid[0], osu_ssid) != 0) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2953 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 2954 | "OSU_SSID and WLAN_TAG2 SSID differ"); |
| 2955 | return -2; |
| 2956 | } |
| 2957 | |
| 2958 | snprintf(buf, sizeof(buf), "'\"%s\"'", |
| 2959 | dut->ap_osu_ssid); |
| 2960 | } else { |
| 2961 | snprintf(buf, sizeof(buf), "'\"%s\"'", osu_ssid); |
| 2962 | } |
| 2963 | |
| 2964 | owrt_ap_set_vap(dut, vap_id, "osu_ssid", buf); |
| 2965 | |
| 2966 | |
| 2967 | if (osu_friendly_name) |
| 2968 | owrt_ap_set_list_vap(dut, vap_id, "osu_friendly_name", |
| 2969 | osu_friendly_name); |
| 2970 | if (osu_service_desc) |
| 2971 | owrt_ap_set_list_vap(dut, vap_id, "osu_service_desc", |
| 2972 | osu_service_desc); |
| 2973 | if (osu_nai) |
| 2974 | owrt_ap_set_vap(dut, vap_id, "osu_nai", osu_nai); |
| 2975 | |
| 2976 | owrt_ap_set_list_vap(dut, vap_id, "hs20_icon", hs20_icon); |
| 2977 | |
| 2978 | if (osu_icon) |
| 2979 | owrt_ap_set_list_vap(dut, vap_id, "osu_icon", |
| 2980 | osu_icon); |
| 2981 | |
| 2982 | if (dut->ap_osu_provider_list > 100) { |
| 2983 | owrt_ap_set_list_vap(dut, vap_id, "osu_method_list", |
| 2984 | "0"); |
| 2985 | } else { |
| 2986 | snprintf(buf, sizeof(buf), "%d", osu_method); |
| 2987 | owrt_ap_set_list_vap(dut, vap_id, "osu_method_list", |
| 2988 | buf); |
| 2989 | } |
| 2990 | } |
| 2991 | |
| 2992 | return 0; |
| 2993 | } |
| 2994 | |
| 2995 | |
Jouni Malinen | 1370122 | 2019-02-19 12:10:53 +0200 | [diff] [blame] | 2996 | static int set_anqp_elem_value(struct sigma_dut *dut, const char *ifname, |
| 2997 | char *anqp_string, size_t str_size) |
Adil Saeed Musthafa | a8d7484 | 2017-04-10 23:13:39 -0700 | [diff] [blame] | 2998 | { |
| 2999 | unsigned char bssid[ETH_ALEN]; |
| 3000 | unsigned char dummy_mac[] = { 0x00, 0x10, 0x20, 0x30, 0x40, 0x50 }; |
| 3001 | int preference = 0xff; |
| 3002 | |
Jouni Malinen | 1370122 | 2019-02-19 12:10:53 +0200 | [diff] [blame] | 3003 | if (get_hwaddr(ifname, bssid) < 0) |
| 3004 | return -1; |
Adil Saeed Musthafa | a8d7484 | 2017-04-10 23:13:39 -0700 | [diff] [blame] | 3005 | snprintf(anqp_string, str_size, |
| 3006 | "272:3410%02x%02x%02x%02x%02x%02xf70000007330000301%02x3410%02x%02x%02x%02x%02x%02xf70000007330000301%02x", |
| 3007 | bssid[0], bssid[1], bssid[2], bssid[3], bssid[4], bssid[5], |
| 3008 | preference, |
| 3009 | dummy_mac[0], dummy_mac[1], dummy_mac[2], |
| 3010 | dummy_mac[3], dummy_mac[4], dummy_mac[5], |
| 3011 | preference - 1); |
Jouni Malinen | 1370122 | 2019-02-19 12:10:53 +0200 | [diff] [blame] | 3012 | return 0; |
Adil Saeed Musthafa | a8d7484 | 2017-04-10 23:13:39 -0700 | [diff] [blame] | 3013 | } |
| 3014 | |
| 3015 | |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 3016 | static void get_if_name(struct sigma_dut *dut, char *ifname_str, |
| 3017 | size_t str_size, int wlan_tag) |
| 3018 | { |
Jouni Malinen | f898464 | 2017-10-12 00:02:37 +0300 | [diff] [blame] | 3019 | const char *ifname; |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 3020 | enum driver_type drv; |
| 3021 | |
Jouni Malinen | 016ae6c | 2019-11-04 17:00:01 +0200 | [diff] [blame] | 3022 | drv = get_driver_type(dut); |
Jouni Malinen | f898464 | 2017-10-12 00:02:37 +0300 | [diff] [blame] | 3023 | if (dut->hostapd_ifname && if_nametoindex(dut->hostapd_ifname) > 0) { |
| 3024 | ifname = dut->hostapd_ifname; |
| 3025 | } else if (drv == DRIVER_ATHEROS) { |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 3026 | if ((dut->ap_mode == AP_11a || dut->ap_mode == AP_11na || |
| 3027 | dut->ap_mode == AP_11ac) && |
| 3028 | if_nametoindex("ath1") > 0) |
| 3029 | ifname = "ath1"; |
| 3030 | else |
| 3031 | ifname = "ath0"; |
| 3032 | } else if (drv == DRIVER_OPENWRT) { |
| 3033 | if (sigma_radio_ifname[0] && |
| 3034 | strcmp(sigma_radio_ifname[0], "wifi2") == 0) |
| 3035 | ifname = "ath2"; |
| 3036 | else if (sigma_radio_ifname[0] && |
| 3037 | strcmp(sigma_radio_ifname[0], "wifi1") == 0) |
| 3038 | ifname = "ath1"; |
| 3039 | else |
| 3040 | ifname = "ath0"; |
Alexei Avshalom Lazar | 2712cc8 | 2018-12-23 16:29:14 +0200 | [diff] [blame] | 3041 | } else if (drv == DRIVER_WIL6210) { |
Jouni Malinen | 016ae6c | 2019-11-04 17:00:01 +0200 | [diff] [blame] | 3042 | ifname = get_main_ifname(dut); |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 3043 | } else { |
| 3044 | if ((dut->ap_mode == AP_11a || dut->ap_mode == AP_11na || |
| 3045 | dut->ap_mode == AP_11ac) && |
| 3046 | if_nametoindex("wlan1") > 0) |
| 3047 | ifname = "wlan1"; |
| 3048 | else |
| 3049 | ifname = "wlan0"; |
| 3050 | } |
| 3051 | |
| 3052 | if (drv == DRIVER_OPENWRT && wlan_tag > 1) { |
| 3053 | /* Handle tagged-ifname only on OPENWRT for now */ |
| 3054 | snprintf(ifname_str, str_size, "%s%d", ifname, wlan_tag - 1); |
Liangwei Dong | 8357289 | 2019-01-10 13:51:48 +0800 | [diff] [blame] | 3055 | } else if ((drv == DRIVER_MAC80211 || drv == DRIVER_LINUX_WCN) && |
| 3056 | wlan_tag == 2) { |
Jouni Malinen | f898464 | 2017-10-12 00:02:37 +0300 | [diff] [blame] | 3057 | snprintf(ifname_str, str_size, "%s_1", ifname); |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 3058 | } else { |
| 3059 | snprintf(ifname_str, str_size, "%s", ifname); |
| 3060 | } |
| 3061 | } |
| 3062 | |
| 3063 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3064 | static int owrt_ap_config_vap(struct sigma_dut *dut) |
| 3065 | { |
| 3066 | char buf[256], *temp; |
Jouni Malinen | 3aa7286 | 2019-05-29 23:14:51 +0300 | [diff] [blame] | 3067 | int vap_id = 0, vap_count, i, j, res; |
priyadharshini gowthaman | 0454706 | 2018-01-15 11:59:55 -0800 | [diff] [blame] | 3068 | const char *ifname; |
| 3069 | char ifname2[50]; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3070 | |
priyadharshini gowthaman | 7356126 | 2018-02-20 13:24:59 -0800 | [diff] [blame] | 3071 | if (sigma_radio_ifname[0] && |
| 3072 | strcmp(sigma_radio_ifname[0], "wifi2") == 0) |
| 3073 | ifname = "ath2"; |
| 3074 | else if (sigma_radio_ifname[0] && |
| 3075 | strcmp(sigma_radio_ifname[0], "wifi1") == 0) |
| 3076 | ifname = "ath1"; |
| 3077 | else |
| 3078 | ifname = "ath0"; |
| 3079 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3080 | for (vap_count = 0; vap_count < OPENWRT_MAX_NUM_RADIOS; vap_count++) { |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 3081 | snprintf(buf, sizeof(buf), "wifi%d", vap_count); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3082 | |
| 3083 | for (vap_id = 0; vap_id < MAX_RADIO; vap_id++) { |
| 3084 | if (sigma_radio_ifname[vap_id] && |
| 3085 | strcmp(sigma_radio_ifname[vap_id], buf) == 0) |
| 3086 | break; |
| 3087 | } |
| 3088 | if (vap_id == MAX_RADIO) |
| 3089 | continue; |
| 3090 | |
| 3091 | /* Single VAP configuration */ |
| 3092 | if (!dut->ap_is_dual) |
| 3093 | vap_id = vap_count; |
| 3094 | |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 3095 | for (j = 0; j < MAX_WLAN_TAGS - 1; j++) { |
| 3096 | /* |
| 3097 | * We keep a separate array of ap_tag_ssid and |
| 3098 | * ap_tag_key_mgmt for tags starting from WLAN_TAG=2. |
| 3099 | * So j=0 => WLAN_TAG = 2 |
| 3100 | */ |
| 3101 | int wlan_tag = j + 2; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3102 | |
priyadharshini gowthaman | 0e209fc | 2018-01-26 15:15:37 -0800 | [diff] [blame] | 3103 | if (wlan_tag == 2 && dut->program == PROGRAM_WPA3 && |
| 3104 | (dut->ap_interface_5g || dut->ap_interface_2g)) { |
Jouni Malinen | 3aa7286 | 2019-05-29 23:14:51 +0300 | [diff] [blame] | 3105 | res = snprintf( |
| 3106 | dut->ap_tag_ssid[wlan_tag - 2], |
| 3107 | sizeof(dut->ap_tag_ssid[wlan_tag - 2]), |
| 3108 | "%s-owe", dut->ap_ssid); |
| 3109 | if (res < 0 || |
| 3110 | res >= sizeof(dut->ap_tag_ssid[wlan_tag - |
| 3111 | 2])) |
| 3112 | dut->ap_tag_ssid[wlan_tag - 2][0] = |
| 3113 | '\0'; |
priyadharshini gowthaman | 0e209fc | 2018-01-26 15:15:37 -0800 | [diff] [blame] | 3114 | } |
| 3115 | |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 3116 | if (dut->ap_tag_ssid[j][0] == '\0') |
| 3117 | continue; |
| 3118 | |
| 3119 | snprintf(buf, sizeof(buf), "%s%d", "wifi", vap_count); |
| 3120 | owrt_ap_add_vap(dut, vap_count + (wlan_tag - 1), |
| 3121 | "device", buf); |
| 3122 | /* SSID */ |
| 3123 | snprintf(buf, sizeof(buf), "\"%s\"", |
| 3124 | dut->ap_tag_ssid[j]); |
| 3125 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), |
| 3126 | "ssid", buf); |
| 3127 | |
priyadharshini gowthaman | 0454706 | 2018-01-15 11:59:55 -0800 | [diff] [blame] | 3128 | if (dut->ap_key_mgmt == AP_WPA2_OWE && |
| 3129 | dut->ap_tag_ssid[0][0] && |
| 3130 | dut->ap_tag_key_mgmt[0] == AP2_OPEN) { |
| 3131 | /* OWE transition mode */ |
| 3132 | snprintf(buf, sizeof(buf), "%s", ifname); |
| 3133 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), |
| 3134 | "owe_transition_ifname", buf); |
| 3135 | } |
| 3136 | |
| 3137 | if (dut->ap_key_mgmt == AP_OPEN && |
| 3138 | dut->ap_tag_key_mgmt[0] == AP2_WPA2_OWE) { |
| 3139 | /* OWE transition mode */ |
| 3140 | snprintf(buf, sizeof(buf), "%s", ifname); |
| 3141 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), |
| 3142 | "owe_transition_ifname", buf); |
| 3143 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), |
| 3144 | "hidden", "1"); |
| 3145 | } |
| 3146 | |
Jouni Malinen | 6be21c8 | 2018-08-01 18:47:24 +0300 | [diff] [blame] | 3147 | if (ap_ft_enabled(dut)) { |
priyadharshini gowthaman | 47189f5 | 2017-12-28 12:37:46 -0800 | [diff] [blame] | 3148 | unsigned char self_mac[ETH_ALEN]; |
| 3149 | char mac_str[20]; |
| 3150 | |
| 3151 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), |
| 3152 | "mobility_domain", |
| 3153 | dut->ap_mobility_domain); |
| 3154 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), |
Jouni Malinen | 9f94331 | 2019-08-19 23:49:16 +0300 | [diff] [blame] | 3155 | "ft_over_ds", |
| 3156 | dut->ap_ft_ds == VALUE_ENABLED ? |
| 3157 | "1" : "0"); |
priyadharshini gowthaman | 47189f5 | 2017-12-28 12:37:46 -0800 | [diff] [blame] | 3158 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), |
| 3159 | "ieee80211r", "1"); |
| 3160 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), |
| 3161 | "nasid", "nas1.example.com"); |
Jouni Malinen | 1370122 | 2019-02-19 12:10:53 +0200 | [diff] [blame] | 3162 | if (get_hwaddr(sigma_radio_ifname[0], |
| 3163 | self_mac) < 0) |
| 3164 | return -1; |
priyadharshini gowthaman | 47189f5 | 2017-12-28 12:37:46 -0800 | [diff] [blame] | 3165 | snprintf(mac_str, sizeof(mac_str), |
| 3166 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 3167 | self_mac[0], self_mac[1], self_mac[2], |
| 3168 | self_mac[3], self_mac[4], self_mac[5]); |
| 3169 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), |
| 3170 | "ap_macaddr", mac_str); |
| 3171 | snprintf(mac_str, sizeof(mac_str), |
| 3172 | "%02x%02x%02x%02x%02x%02x", |
| 3173 | self_mac[0], self_mac[1], self_mac[2], |
| 3174 | self_mac[3], self_mac[4], self_mac[5]); |
| 3175 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), |
| 3176 | "r1_key_holder", mac_str); |
| 3177 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), |
| 3178 | "ft_psk_generate_local", "1"); |
| 3179 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), |
| 3180 | "kh_key_hex", |
| 3181 | "000102030405060708090a0b0c0d0e0f"); |
| 3182 | snprintf(mac_str, sizeof(mac_str), |
| 3183 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 3184 | dut->ft_bss_mac_list[0][0], |
| 3185 | dut->ft_bss_mac_list[0][1], |
| 3186 | dut->ft_bss_mac_list[0][2], |
| 3187 | dut->ft_bss_mac_list[0][3], |
| 3188 | dut->ft_bss_mac_list[0][4], |
| 3189 | dut->ft_bss_mac_list[0][5]); |
| 3190 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), |
| 3191 | "ap2_macaddr", mac_str); |
| 3192 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), |
| 3193 | "ap2_r1_key_holder", mac_str); |
| 3194 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), |
| 3195 | "nasid2", "nas2.example.com"); |
| 3196 | } |
| 3197 | |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 3198 | if (dut->ap_tag_key_mgmt[j] == AP2_OSEN && |
| 3199 | wlan_tag == 2) { |
| 3200 | /* Only supported for WLAN_TAG=2 */ |
| 3201 | owrt_ap_set_vap(dut, vap_count + 1, "osen", |
| 3202 | "1"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3203 | snprintf(buf, sizeof(buf), "wpa2"); |
| 3204 | owrt_ap_set_vap(dut, vap_count + 1, |
| 3205 | "encryption", buf); |
| 3206 | snprintf(buf, sizeof(buf), "%s", |
| 3207 | dut->ap2_radius_ipaddr); |
| 3208 | owrt_ap_set_vap(dut, vap_count + 1, |
| 3209 | "auth_server", buf); |
| 3210 | snprintf(buf, sizeof(buf), "%d", |
| 3211 | dut->ap2_radius_port); |
| 3212 | owrt_ap_set_vap(dut, vap_count + 1, |
| 3213 | "auth_port", buf); |
| 3214 | snprintf(buf, sizeof(buf), "%s", |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 3215 | dut->ap2_radius_password); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3216 | owrt_ap_set_vap(dut, vap_count + 1, |
| 3217 | "auth_secret", buf); |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 3218 | } else if (dut->ap_tag_key_mgmt[j] == AP2_WPA2_PSK) { |
| 3219 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), |
| 3220 | "encryption", "psk2+ccmp"); |
| 3221 | snprintf(buf, sizeof(buf), "\"%s\"", |
| 3222 | dut->ap_passphrase); |
| 3223 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), |
| 3224 | "key", buf); |
| 3225 | snprintf(buf, sizeof(buf), "%d", dut->ap_pmf); |
priyadharshini gowthaman | 47189f5 | 2017-12-28 12:37:46 -0800 | [diff] [blame] | 3226 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 3227 | "ieee80211w", buf); |
priyadharshini gowthaman | 0454706 | 2018-01-15 11:59:55 -0800 | [diff] [blame] | 3228 | } else if (dut->ap_tag_key_mgmt[0] == AP2_WPA2_OWE) { |
| 3229 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), |
| 3230 | "owe", "1"); |
| 3231 | snprintf(buf, sizeof(buf), "ccmp"); |
| 3232 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), |
| 3233 | "encryption", buf); |
| 3234 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), |
| 3235 | "ieee80211w", "2"); |
| 3236 | if (dut->ap_sae_groups) { |
| 3237 | snprintf(buf, sizeof(buf), "\'%s\'", |
| 3238 | dut->ap_sae_groups); |
priyadharshini gowthaman | b59bfe4 | 2018-08-30 15:14:08 -0700 | [diff] [blame] | 3239 | owrt_ap_set_list_vap(dut, vap_count + |
| 3240 | (wlan_tag - 1), |
| 3241 | "owe_groups", buf); |
priyadharshini gowthaman | 0454706 | 2018-01-15 11:59:55 -0800 | [diff] [blame] | 3242 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3243 | } |
| 3244 | } |
| 3245 | |
priyadharshini gowthaman | 47189f5 | 2017-12-28 12:37:46 -0800 | [diff] [blame] | 3246 | /* Now set anqp_elem and ft_oa for wlan_tag = 1 */ |
Adil Saeed Musthafa | a8d7484 | 2017-04-10 23:13:39 -0700 | [diff] [blame] | 3247 | if (dut->program == PROGRAM_MBO && |
Jouni Malinen | 016ae6c | 2019-11-04 17:00:01 +0200 | [diff] [blame] | 3248 | get_driver_type(dut) == DRIVER_OPENWRT) { |
priyadharshini gowthaman | 47189f5 | 2017-12-28 12:37:46 -0800 | [diff] [blame] | 3249 | unsigned char self_mac[ETH_ALEN]; |
| 3250 | char mac_str[20]; |
Adil Saeed Musthafa | a8d7484 | 2017-04-10 23:13:39 -0700 | [diff] [blame] | 3251 | char anqp_string[200]; |
| 3252 | |
Jouni Malinen | 1370122 | 2019-02-19 12:10:53 +0200 | [diff] [blame] | 3253 | if (set_anqp_elem_value(dut, sigma_radio_ifname[0], |
| 3254 | anqp_string, |
| 3255 | sizeof(anqp_string)) < 0) |
| 3256 | return -1; |
Adil Saeed Musthafa | a8d7484 | 2017-04-10 23:13:39 -0700 | [diff] [blame] | 3257 | owrt_ap_set_list_vap(dut, vap_count, "anqp_elem", |
| 3258 | anqp_string); |
priyadharshini gowthaman | 47189f5 | 2017-12-28 12:37:46 -0800 | [diff] [blame] | 3259 | |
Jouni Malinen | 6be21c8 | 2018-08-01 18:47:24 +0300 | [diff] [blame] | 3260 | if (ap_ft_enabled(dut)) { |
priyadharshini gowthaman | 47189f5 | 2017-12-28 12:37:46 -0800 | [diff] [blame] | 3261 | owrt_ap_set_vap(dut, vap_count, |
| 3262 | "mobility_domain", |
| 3263 | dut->ap_mobility_domain); |
| 3264 | owrt_ap_set_vap(dut, vap_count, |
Jouni Malinen | 9f94331 | 2019-08-19 23:49:16 +0300 | [diff] [blame] | 3265 | "ft_over_ds", |
| 3266 | dut->ap_ft_ds == VALUE_ENABLED ? |
| 3267 | "1" : "0"); |
priyadharshini gowthaman | 47189f5 | 2017-12-28 12:37:46 -0800 | [diff] [blame] | 3268 | owrt_ap_set_vap(dut, vap_count, |
| 3269 | "ieee80211r", "1"); |
| 3270 | owrt_ap_set_vap(dut, vap_count, |
| 3271 | "nasid", "nas1.example.com"); |
| 3272 | get_hwaddr(sigma_radio_ifname[0], self_mac); |
| 3273 | snprintf(mac_str, sizeof(mac_str), |
| 3274 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 3275 | self_mac[0], self_mac[1], self_mac[2], |
| 3276 | self_mac[3], self_mac[4], self_mac[5]); |
| 3277 | owrt_ap_set_vap(dut, vap_count, |
| 3278 | "ap_macaddr", mac_str); |
| 3279 | snprintf(mac_str, sizeof(mac_str), |
| 3280 | "%02x%02x%02x%02x%02x%02x", |
| 3281 | self_mac[0], self_mac[1], self_mac[2], |
| 3282 | self_mac[3], self_mac[4], self_mac[5]); |
| 3283 | owrt_ap_set_vap(dut, vap_count, |
| 3284 | "r1_key_holder", mac_str); |
| 3285 | owrt_ap_set_vap(dut, vap_count, |
| 3286 | "ft_psk_generate_local", "1"); |
| 3287 | owrt_ap_set_vap(dut, vap_count, |
| 3288 | "kh_key_hex", |
| 3289 | "000102030405060708090a0b0c0d0e0f"); |
| 3290 | snprintf(mac_str, sizeof(mac_str), |
| 3291 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 3292 | dut->ft_bss_mac_list[0][0], |
| 3293 | dut->ft_bss_mac_list[0][1], |
| 3294 | dut->ft_bss_mac_list[0][2], |
| 3295 | dut->ft_bss_mac_list[0][3], |
| 3296 | dut->ft_bss_mac_list[0][4], |
| 3297 | dut->ft_bss_mac_list[0][5]); |
| 3298 | owrt_ap_set_vap(dut, vap_count, |
| 3299 | "ap2_macaddr", mac_str); |
| 3300 | owrt_ap_set_vap(dut, vap_count, |
| 3301 | "ap2_r1_key_holder", mac_str); |
| 3302 | owrt_ap_set_vap(dut, vap_count, |
| 3303 | "nasid2", "nas2.example.com"); |
| 3304 | } |
Adil Saeed Musthafa | a8d7484 | 2017-04-10 23:13:39 -0700 | [diff] [blame] | 3305 | } |
| 3306 | |
priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 3307 | if (dut->ap_oce == VALUE_ENABLED && |
Jouni Malinen | 016ae6c | 2019-11-04 17:00:01 +0200 | [diff] [blame] | 3308 | get_driver_type(dut) == DRIVER_OPENWRT) { |
priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 3309 | owrt_ap_set_vap(dut, vap_id, "oce", "1"); |
| 3310 | owrt_ap_set_vap(dut, vap_id, "qbssload", "1"); |
| 3311 | owrt_ap_set_vap(dut, vap_id, "bpr_enable", "1"); |
| 3312 | |
priyadharshini gowthaman | 63ab848 | 2017-12-28 15:32:55 -0800 | [diff] [blame] | 3313 | if (dut->ap_80plus80 == 1) |
| 3314 | owrt_ap_set_vap(dut, vap_id, "cfreq2", "5775"); |
| 3315 | |
priyadharshini gowthaman | de81f39 | 2017-12-28 15:28:49 -0800 | [diff] [blame] | 3316 | if (dut->ap_akm == 1) { |
| 3317 | owrt_ap_set_vap(dut, vap_id, "wpa_group_rekey", |
| 3318 | "3600"); |
| 3319 | owrt_ap_set_vap(dut, vap_id, "key", "12345678"); |
| 3320 | owrt_ap_set_vap(dut, vap_id, "ieee80211ai", |
| 3321 | "1"); |
| 3322 | owrt_ap_set_vap(dut, vap_id, "fils_cache_id", |
| 3323 | "1234"); |
| 3324 | owrt_ap_set_vap(dut, vap_id, |
| 3325 | "erp_send_reauth_start", "1"); |
| 3326 | } |
| 3327 | |
priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 3328 | if (dut->ap_filshlp == VALUE_ENABLED) { |
| 3329 | struct ifreq ifr; |
| 3330 | char *ifname; |
| 3331 | int s; |
| 3332 | struct sockaddr_in *ipaddr; |
| 3333 | |
| 3334 | s = socket(AF_INET, SOCK_DGRAM, 0); |
| 3335 | if (s < 0) { |
| 3336 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 3337 | "Failed to open socket"); |
| 3338 | return -1; |
| 3339 | } |
| 3340 | ifr.ifr_addr.sa_family = AF_INET; |
| 3341 | |
| 3342 | memset(&ifr, 0, sizeof(ifr)); |
| 3343 | ifname = "br-lan"; |
| 3344 | strlcpy(ifr.ifr_name, ifname, |
| 3345 | sizeof(ifr.ifr_name)); |
| 3346 | if (ioctl(s, SIOCGIFADDR, &ifr) < 0) { |
| 3347 | perror("ioctl"); |
| 3348 | close(s); |
| 3349 | return -1; |
| 3350 | } |
| 3351 | |
| 3352 | ipaddr = (struct sockaddr_in*)&ifr.ifr_addr; |
| 3353 | snprintf(buf, sizeof(buf), "%s", |
| 3354 | inet_ntoa(ipaddr->sin_addr)); |
| 3355 | owrt_ap_set_vap(dut, vap_id, "own_ip_addr", |
| 3356 | buf); |
| 3357 | snprintf(buf, sizeof(buf), "%s", |
| 3358 | dut->ap_dhcpserv_ipaddr); |
| 3359 | owrt_ap_set_vap(dut, vap_id, "dhcp_server", |
| 3360 | buf); |
| 3361 | owrt_ap_set_vap(dut, vap_id, |
| 3362 | "dhcp_rapid_commit_proxy", "1"); |
| 3363 | owrt_ap_set_vap(dut, vap_id, |
| 3364 | "fils_hlp_wait_time", "300"); |
| 3365 | } |
| 3366 | |
| 3367 | if (dut->ap_filsdscv == VALUE_ENABLED) { |
| 3368 | owrt_ap_set_vap(dut, vap_id, "ieee80211ai", |
| 3369 | "1"); |
| 3370 | owrt_ap_set_vap(dut, vap_id, "fils_fd_period", |
| 3371 | "20"); |
| 3372 | } |
| 3373 | } |
| 3374 | |
| 3375 | if (dut->ap_filsdscv == VALUE_DISABLED) { |
| 3376 | owrt_ap_set_vap(dut, vap_id, "ieee80211ai", "0"); |
| 3377 | owrt_ap_set_vap(dut, vap_id, "fils_fd_period", "0"); |
| 3378 | } |
| 3379 | |
| 3380 | if (dut->ap_oce == VALUE_DISABLED && |
Jouni Malinen | 016ae6c | 2019-11-04 17:00:01 +0200 | [diff] [blame] | 3381 | get_driver_type(dut) == DRIVER_OPENWRT) { |
priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 3382 | owrt_ap_set_vap(dut, vap_id, "oce", "0"); |
| 3383 | owrt_ap_set_vap(dut, vap_id, "qbssload", "0"); |
| 3384 | owrt_ap_set_vap(dut, vap_id, "bpr_enable", "0"); |
| 3385 | |
| 3386 | if (dut->ap_filsdscv == VALUE_DISABLED) { |
| 3387 | owrt_ap_set_vap(dut, vap_id, "ieee80211ai", |
| 3388 | "0"); |
| 3389 | owrt_ap_set_vap(dut, vap_id, "fils_fd_period", |
| 3390 | "0"); |
| 3391 | } |
| 3392 | |
| 3393 | if (dut->device_type == AP_testbed) |
| 3394 | owrt_ap_set_vap(dut, vap_id, "mbo", "1"); |
| 3395 | } |
| 3396 | |
| 3397 | /* NAIRealm */ |
| 3398 | if (dut->ap_nairealm_int == 1) { |
| 3399 | snprintf(buf, sizeof(buf), "\"%s\"", dut->ap_nairealm); |
| 3400 | owrt_ap_set_vap(dut, vap_id, "fils_realm", buf); |
| 3401 | owrt_ap_set_vap(dut, vap_id, "erp_domain", buf); |
| 3402 | } |
| 3403 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3404 | /* SSID */ |
| 3405 | snprintf(buf, sizeof(buf), "\"%s\"", dut->ap_ssid); |
| 3406 | owrt_ap_set_vap(dut, vap_count, "ssid", buf); |
| 3407 | |
| 3408 | /* Encryption */ |
| 3409 | switch (dut->ap_key_mgmt) { |
| 3410 | case AP_OPEN: |
| 3411 | if (dut->ap_cipher == AP_WEP) { |
| 3412 | owrt_ap_set_vap(dut, vap_count, "encryption", |
| 3413 | "wep-mixed"); |
| 3414 | owrt_ap_set_vap(dut, vap_count, "key", |
| 3415 | dut->ap_wepkey); |
| 3416 | } else { |
| 3417 | owrt_ap_set_vap(dut, vap_count, "encryption", |
| 3418 | "none"); |
| 3419 | } |
priyadharshini gowthaman | 0454706 | 2018-01-15 11:59:55 -0800 | [diff] [blame] | 3420 | if (dut->ap_key_mgmt == AP_OPEN && |
| 3421 | dut->ap_tag_key_mgmt[0] == AP2_WPA2_OWE) { |
| 3422 | /* OWE transition mode */ |
| 3423 | snprintf(ifname2, sizeof(ifname2), "%s1", |
| 3424 | ifname); |
| 3425 | owrt_ap_set_vap(dut, vap_count, |
| 3426 | "owe_transition_ifname", |
| 3427 | ifname2); |
| 3428 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3429 | break; |
| 3430 | case AP_WPA2_PSK: |
| 3431 | case AP_WPA2_PSK_MIXED: |
| 3432 | case AP_WPA_PSK: |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 3433 | case AP_WPA2_SAE: |
| 3434 | case AP_WPA2_PSK_SAE: |
priyadharshini gowthaman | cce6ca0 | 2018-01-15 11:12:45 -0800 | [diff] [blame] | 3435 | if (dut->ap_key_mgmt == AP_WPA2_PSK || |
| 3436 | dut->ap_key_mgmt == AP_WPA2_PSK_SAE) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3437 | snprintf(buf, sizeof(buf), "psk2"); |
| 3438 | } else if (dut->ap_key_mgmt == AP_WPA2_PSK_MIXED) { |
| 3439 | snprintf(buf, sizeof(buf), "psk-mixed"); |
priyadharshini gowthaman | cce6ca0 | 2018-01-15 11:12:45 -0800 | [diff] [blame] | 3440 | } else if (dut->ap_key_mgmt == AP_WPA2_SAE) { |
| 3441 | snprintf(buf, sizeof(buf), "ccmp"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3442 | } else { |
| 3443 | snprintf(buf, sizeof(buf), "psk"); |
| 3444 | } |
| 3445 | |
priyadharshini gowthaman | cce6ca0 | 2018-01-15 11:12:45 -0800 | [diff] [blame] | 3446 | if (dut->ap_key_mgmt != AP_WPA2_SAE) { |
| 3447 | if (dut->ap_cipher == AP_CCMP_TKIP) |
| 3448 | strlcat(buf, "+ccmp+tkip", sizeof(buf)); |
| 3449 | else if (dut->ap_cipher == AP_TKIP) |
| 3450 | strlcat(buf, "+tkip", sizeof(buf)); |
Alexei Avshalom Lazar | 2712cc8 | 2018-12-23 16:29:14 +0200 | [diff] [blame] | 3451 | else if (dut->ap_cipher == AP_GCMP_128) |
| 3452 | strlcat(buf, "+gcmp", sizeof(buf)); |
priyadharshini gowthaman | cce6ca0 | 2018-01-15 11:12:45 -0800 | [diff] [blame] | 3453 | else |
| 3454 | strlcat(buf, "+ccmp", sizeof(buf)); |
| 3455 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3456 | |
| 3457 | owrt_ap_set_vap(dut, vap_count, "encryption", buf); |
priyadharshini gowthaman | cce6ca0 | 2018-01-15 11:12:45 -0800 | [diff] [blame] | 3458 | |
| 3459 | if (!dut->ap_passphrase[0] && dut->ap_psk[0]) { |
| 3460 | snprintf(buf, sizeof(buf), "\"%s\"", |
| 3461 | dut->ap_psk); |
| 3462 | owrt_ap_set_vap(dut, vap_count, "key", buf); |
| 3463 | } else { |
| 3464 | snprintf(buf, sizeof(buf), "\"%s\"", |
| 3465 | dut->ap_passphrase); |
| 3466 | owrt_ap_set_vap(dut, vap_count, "key", buf); |
| 3467 | } |
| 3468 | |
| 3469 | if (dut->ap_key_mgmt == AP_WPA2_SAE || |
| 3470 | dut->ap_key_mgmt == AP_WPA2_PSK_SAE) |
| 3471 | owrt_ap_set_vap(dut, vap_count, "sae", "1"); |
| 3472 | else |
| 3473 | owrt_ap_set_vap(dut, vap_count, "sae", "0"); |
| 3474 | |
| 3475 | if (dut->ap_key_mgmt == AP_WPA2_SAE) { |
| 3476 | snprintf(buf, sizeof(buf), "%s", |
| 3477 | dut->ap_passphrase); |
| 3478 | owrt_ap_set_vap(dut, vap_count, "sae_password", |
| 3479 | buf); |
| 3480 | } else { |
| 3481 | snprintf(buf, sizeof(buf), "%s", |
| 3482 | dut->ap_passphrase); |
| 3483 | owrt_ap_set_vap(dut, vap_count, |
| 3484 | "wpa_passphrase", buf); |
| 3485 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3486 | break; |
| 3487 | case AP_WPA2_EAP: |
| 3488 | case AP_WPA2_EAP_MIXED: |
| 3489 | case AP_WPA_EAP: |
| 3490 | if (dut->ap_key_mgmt == AP_WPA2_EAP) { |
| 3491 | snprintf(buf, sizeof(buf), "wpa2"); |
| 3492 | } else if (dut->ap_key_mgmt == AP_WPA2_EAP_MIXED) { |
| 3493 | snprintf(buf, sizeof(buf), "wpa-mixed"); |
| 3494 | } else { |
| 3495 | snprintf(buf, sizeof(buf), "wpa"); |
| 3496 | } |
| 3497 | |
Peng Xu | 591be45 | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 3498 | if (dut->ap_cipher == AP_CCMP_TKIP) |
| 3499 | strlcat(buf, "+ccmp+tkip", sizeof(buf)); |
| 3500 | else if (dut->ap_cipher == AP_TKIP) |
| 3501 | strlcat(buf, "+tkip", sizeof(buf)); |
| 3502 | else |
| 3503 | strlcat(buf, "+ccmp", sizeof(buf)); |
| 3504 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3505 | owrt_ap_set_vap(dut, vap_count, "encryption", buf); |
| 3506 | snprintf(buf, sizeof(buf), "%s", dut->ap_radius_ipaddr); |
| 3507 | owrt_ap_set_vap(dut, vap_count, "auth_server", buf); |
| 3508 | snprintf(buf, sizeof(buf), "%d", dut->ap_radius_port); |
| 3509 | owrt_ap_set_vap(dut, vap_count, "auth_port", buf); |
| 3510 | snprintf(buf, sizeof(buf), "%s", |
| 3511 | dut->ap_radius_password); |
| 3512 | owrt_ap_set_vap(dut, vap_count, "auth_secret", buf); |
| 3513 | break; |
Jouni Malinen | 4cf699f | 2018-06-19 00:46:27 +0300 | [diff] [blame] | 3514 | case AP_WPA2_EAP_OSEN: |
Jouni Malinen | c2b9121 | 2018-09-12 02:26:39 +0300 | [diff] [blame] | 3515 | case AP_OSEN: |
Jouni Malinen | 6be21c8 | 2018-08-01 18:47:24 +0300 | [diff] [blame] | 3516 | case AP_WPA2_FT_EAP: |
| 3517 | case AP_WPA2_FT_PSK: |
| 3518 | case AP_WPA2_EAP_SHA256: |
| 3519 | case AP_WPA2_PSK_SHA256: |
| 3520 | case AP_WPA2_ENT_FT_EAP: |
Jouni Malinen | 4cf699f | 2018-06-19 00:46:27 +0300 | [diff] [blame] | 3521 | /* TODO */ |
| 3522 | break; |
Jouni Malinen | ad395a2 | 2017-09-01 21:13:46 +0300 | [diff] [blame] | 3523 | case AP_SUITEB: |
priyadharshini gowthaman | 2136bd5 | 2018-01-15 11:28:55 -0800 | [diff] [blame] | 3524 | owrt_ap_set_vap(dut, vap_count, "suite_b", "192"); |
| 3525 | snprintf(buf, sizeof(buf), "gcmp"); |
| 3526 | owrt_ap_set_vap(dut, vap_count, "encryption", buf); |
| 3527 | snprintf(buf, sizeof(buf), "%s", dut->ap_radius_ipaddr); |
| 3528 | owrt_ap_set_vap(dut, vap_count, "auth_server", buf); |
| 3529 | snprintf(buf, sizeof(buf), "%d", dut->ap_radius_port); |
| 3530 | owrt_ap_set_vap(dut, vap_count, "auth_port", buf); |
| 3531 | snprintf(buf, sizeof(buf), "%s", |
| 3532 | dut->ap_radius_password); |
| 3533 | owrt_ap_set_vap(dut, vap_count, "auth_secret", buf); |
| 3534 | snprintf(buf, sizeof(buf), "%d", |
| 3535 | dut->ap_group_mgmt_cipher); |
| 3536 | owrt_ap_set_vap(dut, vap_count, "group_mgmt_cipher", |
| 3537 | buf); |
Jouni Malinen | ad395a2 | 2017-09-01 21:13:46 +0300 | [diff] [blame] | 3538 | break; |
Jouni Malinen | 147b3c3 | 2017-10-09 16:51:54 +0300 | [diff] [blame] | 3539 | case AP_WPA2_OWE: |
priyadharshini gowthaman | 0454706 | 2018-01-15 11:59:55 -0800 | [diff] [blame] | 3540 | owrt_ap_set_vap(dut, vap_count, "owe", "1"); |
| 3541 | snprintf(buf, sizeof(buf), "ccmp"); |
| 3542 | owrt_ap_set_vap(dut, vap_count, "encryption", buf); |
| 3543 | if (dut->ap_sae_groups) { |
| 3544 | snprintf(buf, sizeof(buf), "\'%s\'", |
| 3545 | dut->ap_sae_groups); |
priyadharshini gowthaman | b59bfe4 | 2018-08-30 15:14:08 -0700 | [diff] [blame] | 3546 | owrt_ap_set_list_vap(dut, vap_count, |
| 3547 | "owe_groups", buf); |
priyadharshini gowthaman | 0454706 | 2018-01-15 11:59:55 -0800 | [diff] [blame] | 3548 | } |
| 3549 | |
| 3550 | if (dut->ap_key_mgmt == AP_WPA2_OWE && |
| 3551 | dut->ap_tag_ssid[0][0] && |
| 3552 | dut->ap_tag_key_mgmt[0] == AP2_OPEN) { |
| 3553 | /* OWE transition mode */ |
| 3554 | snprintf(ifname2, sizeof(ifname2), "%s1", |
| 3555 | ifname); |
| 3556 | owrt_ap_set_vap(dut, vap_count, |
| 3557 | "owe_transition_ifname", |
| 3558 | ifname2); |
| 3559 | owrt_ap_set_vap(dut, vap_count, "hidden", "1"); |
| 3560 | } |
Jouni Malinen | 147b3c3 | 2017-10-09 16:51:54 +0300 | [diff] [blame] | 3561 | break; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3562 | } |
| 3563 | |
| 3564 | if (!dut->ap_is_dual) |
| 3565 | break; |
| 3566 | } |
| 3567 | |
| 3568 | if (dut->ap_is_dual) |
| 3569 | return 1; |
| 3570 | |
| 3571 | /* PMF */ |
| 3572 | snprintf(buf, sizeof(buf), "%d", dut->ap_pmf); |
| 3573 | owrt_ap_set_vap(dut, vap_id, "ieee80211w", buf); |
| 3574 | |
| 3575 | /* Add SHA256 */ |
| 3576 | snprintf(buf, sizeof(buf), "%d", dut->ap_add_sha256); |
| 3577 | owrt_ap_set_vap(dut, vap_id, "add_sha256", buf); |
| 3578 | |
priyadharshini gowthaman | de81f39 | 2017-12-28 15:28:49 -0800 | [diff] [blame] | 3579 | /* Add SHA384 for akmsuitetype 15 */ |
| 3580 | if (dut->ap_akm == 1) { |
| 3581 | snprintf(buf, sizeof(buf), "%d", dut->ap_add_sha384); |
| 3582 | owrt_ap_set_vap(dut, vap_id, "add_sha384", buf); |
| 3583 | } |
| 3584 | |
Sarvepalli, Rajesh Babu | 24dc7e4 | 2016-03-18 21:27:26 +0530 | [diff] [blame] | 3585 | /* Enable RSN preauthentication, if asked to */ |
| 3586 | snprintf(buf, sizeof(buf), "%d", dut->ap_rsn_preauth); |
| 3587 | owrt_ap_set_vap(dut, vap_id, "rsn_preauth", buf); |
| 3588 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3589 | /* Hotspot 2.0 */ |
| 3590 | if (dut->ap_hs2) { |
| 3591 | int ret; |
| 3592 | |
| 3593 | ret = owrt_ap_config_vap_hs2(dut, vap_id); |
| 3594 | if (ret) |
| 3595 | return ret; |
| 3596 | } |
| 3597 | |
| 3598 | /* Interworking */ |
| 3599 | if (dut->ap_interworking) { |
| 3600 | snprintf(buf, sizeof(buf), "%d", dut->ap_access_net_type); |
| 3601 | owrt_ap_set_vap(dut, vap_id, "access_network_type", buf); |
| 3602 | snprintf(buf, sizeof(buf), "%d", dut->ap_internet); |
| 3603 | owrt_ap_set_vap(dut, vap_id, "internet", buf); |
| 3604 | snprintf(buf, sizeof(buf), "%d", dut->ap_venue_group); |
| 3605 | owrt_ap_set_vap(dut, vap_id, "venue_group", buf); |
| 3606 | snprintf(buf, sizeof(buf), "%d", dut->ap_venue_type); |
| 3607 | owrt_ap_set_vap(dut, vap_id, "venue_type", buf); |
| 3608 | snprintf(buf, sizeof(buf), "%s", dut->ap_hessid); |
| 3609 | owrt_ap_set_vap(dut, vap_id, "hessid", buf); |
| 3610 | |
| 3611 | if (dut->ap_gas_cb_delay > 0) { |
| 3612 | snprintf(buf, sizeof(buf), "%d", dut->ap_gas_cb_delay); |
| 3613 | owrt_ap_set_vap(dut, vap_id, "gas_comeback_delay", buf); |
| 3614 | } |
| 3615 | |
| 3616 | if (dut->ap_roaming_cons[0]) { |
| 3617 | char *rcons, *temp_ptr; |
| 3618 | |
| 3619 | rcons = strdup(dut->ap_roaming_cons); |
| 3620 | if (rcons == NULL) |
Jouni Malinen | 1370122 | 2019-02-19 12:10:53 +0200 | [diff] [blame] | 3621 | return -1; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3622 | |
| 3623 | temp_ptr = strchr(rcons, ';'); |
| 3624 | |
| 3625 | if (temp_ptr) |
| 3626 | *temp_ptr++ = '\0'; |
| 3627 | |
| 3628 | owrt_ap_set_list_vap(dut, vap_id, "roaming_consortium", |
| 3629 | rcons); |
| 3630 | |
| 3631 | if (temp_ptr) |
| 3632 | owrt_ap_set_list_vap(dut, vap_id, |
| 3633 | "roaming_consortium", |
| 3634 | temp_ptr); |
| 3635 | |
| 3636 | free(rcons); |
| 3637 | } |
| 3638 | } |
| 3639 | |
| 3640 | if (dut->ap_venue_name) { |
| 3641 | owrt_ap_set_list_vap(dut, vap_id, "venue_name", |
| 3642 | "'P\"eng:Wi-Fi Alliance\\n2989 Copper Road\\nSanta Clara, CA 95051, USA\"'"); |
| 3643 | owrt_ap_set_list_vap(dut, vap_id, "venue_name", |
| 3644 | "\'"ANQP_VENUE_NAME_1_CHI"\'"); |
| 3645 | } |
| 3646 | |
| 3647 | if (dut->ap_net_auth_type == 1) { |
priyadharshini gowthaman | 9b8a8c3 | 2018-08-31 10:49:24 -0700 | [diff] [blame] | 3648 | owrt_ap_set_list_vap(dut, vap_id, "network_auth_type", |
| 3649 | "'00https://tandc-server.wi-fi.org'"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3650 | } else if (dut->ap_net_auth_type == 2) { |
priyadharshini gowthaman | 9b8a8c3 | 2018-08-31 10:49:24 -0700 | [diff] [blame] | 3651 | owrt_ap_set_list_vap(dut, vap_id, "network_auth_type", "'01'"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3652 | } |
| 3653 | |
| 3654 | if (dut->ap_nai_realm_list == 1) { |
| 3655 | owrt_ap_set_list_vap(dut, vap_id, "nai_realm", |
| 3656 | "'0,mail.example.com;cisco.com;wi-fi.org,21[2:4][5:7]'"); |
| 3657 | owrt_ap_set_list_vap(dut, vap_id, "nai_realm", |
| 3658 | "'0,wi-fi.org;example.com,13[5:6]'"); |
| 3659 | |
| 3660 | } else if (dut->ap_nai_realm_list == 2) { |
| 3661 | owrt_ap_set_list_vap(dut, vap_id, "nai_realm", |
| 3662 | "'0,wi-fi.org,21[2:4][5:7]'"); |
| 3663 | } else if (dut->ap_nai_realm_list == 3) { |
| 3664 | owrt_ap_set_list_vap(dut, vap_id, "nai_realm", |
| 3665 | "'0,cisco.com;wi-fi.org,21[2:4][5:7]'"); |
| 3666 | owrt_ap_set_list_vap(dut, vap_id, "nai_realm", |
| 3667 | "'0,wi-fi.org;example.com,13[5:6]'"); |
| 3668 | } else if (dut->ap_nai_realm_list == 4) { |
| 3669 | owrt_ap_set_list_vap(dut, vap_id, "nai_realm", |
| 3670 | "'0,mail.example.com,21[2:4][5:7],13[5:6]'"); |
| 3671 | } else if (dut->ap_nai_realm_list == 5) { |
| 3672 | owrt_ap_set_list_vap(dut, vap_id, "nai_realm", |
| 3673 | "'0,wi-fi.org;ruckuswireless.com,21[2:4][5:7]'"); |
| 3674 | } else if (dut->ap_nai_realm_list == 6) { |
| 3675 | owrt_ap_set_list_vap(dut, vap_id, "nai_realm", |
| 3676 | "'0,wi-fi.org;mail.example.com,21[2:4][5:7]'"); |
| 3677 | } else if (dut->ap_nai_realm_list == 7) { |
| 3678 | owrt_ap_set_list_vap(dut, vap_id, "nai_realm", |
| 3679 | "'0,wi-fi.org,13[5:6]'"); |
| 3680 | owrt_ap_set_list_vap(dut, vap_id, "nai_realm", |
| 3681 | "'0,wi-fi.org,21[2:4][5:7]'"); |
| 3682 | } |
| 3683 | |
| 3684 | if (dut->ap_domain_name_list[0]) |
| 3685 | owrt_ap_set_list_vap(dut, vap_id, "domain_name", |
| 3686 | dut->ap_domain_name_list); |
| 3687 | |
| 3688 | if (dut->ap_ip_addr_type_avail) |
| 3689 | owrt_ap_set_vap(dut, vap_id, "ipaddr_type_availability", |
| 3690 | "'0c'"); |
| 3691 | |
| 3692 | temp = buf; |
| 3693 | |
| 3694 | *temp++ = '\''; |
| 3695 | |
| 3696 | for (i = 0; dut->ap_plmn_mcc[i][0] && dut->ap_plmn_mnc[i][0]; i++) { |
| 3697 | if (i) |
| 3698 | *temp++ = ';'; |
| 3699 | |
| 3700 | snprintf(temp, |
| 3701 | sizeof(dut->ap_plmn_mcc[i]) + |
| 3702 | sizeof(dut->ap_plmn_mnc[i]) + 1, |
| 3703 | "%s,%s", |
| 3704 | dut->ap_plmn_mcc[i], |
| 3705 | dut->ap_plmn_mnc[i]); |
| 3706 | |
| 3707 | temp += strlen(dut->ap_plmn_mcc[i]) + |
| 3708 | strlen(dut->ap_plmn_mnc[i]) + 1; |
| 3709 | } |
| 3710 | |
| 3711 | *temp++ = '\''; |
| 3712 | *temp++ = '\0'; |
| 3713 | |
| 3714 | if (i) |
| 3715 | owrt_ap_set_vap(dut, vap_id, "anqp_3gpp_cell_net", buf); |
| 3716 | |
| 3717 | if (dut->ap_qos_map_set == 1) |
| 3718 | owrt_ap_set_vap(dut, vap_id, "qos_map_set", QOS_MAP_SET_1); |
| 3719 | else if (dut->ap_qos_map_set == 2) |
| 3720 | owrt_ap_set_vap(dut, vap_id, "qos_map_set", QOS_MAP_SET_2); |
| 3721 | |
| 3722 | /* Proxy-ARP */ |
| 3723 | snprintf(buf, sizeof(buf), "%d", dut->ap_proxy_arp); |
| 3724 | owrt_ap_set_vap(dut, vap_id, "proxyarp", buf); |
| 3725 | |
| 3726 | /* DGAF */ |
| 3727 | snprintf(buf, sizeof(buf), "%d", dut->ap_dgaf_disable); |
| 3728 | /* parse to hostapd */ |
| 3729 | owrt_ap_set_vap(dut, vap_id, "disable_dgaf", buf); |
| 3730 | /* parse to wifi driver */ |
| 3731 | owrt_ap_set_vap(dut, vap_id, "dgaf_disable", buf); |
| 3732 | |
| 3733 | /* HCBSSLoad */ |
| 3734 | if (dut->ap_bss_load) { |
| 3735 | unsigned int bssload = 0; |
| 3736 | |
| 3737 | if (dut->ap_bss_load == 1) { |
| 3738 | /* STA count: 1, CU: 50, AAC: 65535 */ |
| 3739 | bssload = 0x0132ffff; |
| 3740 | } else if (dut->ap_bss_load == 2) { |
| 3741 | /* STA count: 1, CU: 200, AAC: 65535 */ |
| 3742 | bssload = 0x01c8ffff; |
| 3743 | } else if (dut->ap_bss_load == 3) { |
| 3744 | /* STA count: 1, CU: 75, AAC: 65535 */ |
| 3745 | bssload = 0x014bffff; |
| 3746 | } |
| 3747 | |
| 3748 | snprintf(buf, sizeof(buf), "%d", bssload); |
| 3749 | owrt_ap_set_vap(dut, vap_id, "hcbssload", buf); |
| 3750 | } |
| 3751 | |
| 3752 | /* L2TIF */ |
| 3753 | if (dut->ap_l2tif) |
| 3754 | owrt_ap_set_vap(dut, vap_id, "l2tif", "1"); |
| 3755 | |
| 3756 | if (dut->ap_disable_protection == 1) |
| 3757 | owrt_ap_set_vap(dut, vap_id, "enablertscts", "0"); |
| 3758 | |
Sunil Dutt | 77b213d | 2017-09-14 18:24:40 +0300 | [diff] [blame] | 3759 | if (dut->ap_txBF) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3760 | owrt_ap_set_vap(dut, vap_id, "vhtsubfee", "1"); |
| 3761 | owrt_ap_set_vap(dut, vap_id, "vhtsubfer", "1"); |
| 3762 | } |
| 3763 | |
Mohammed Shafi Shajakhan | 061af00 | 2016-06-02 20:10:54 +0530 | [diff] [blame] | 3764 | if (dut->ap_mu_txBF) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3765 | owrt_ap_set_vap(dut, vap_id, "vhtmubfer", "1"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3766 | |
Vasanthakumar Pandurangan | 2b5431d | 2016-01-12 15:52:48 +0530 | [diff] [blame] | 3767 | if (dut->ap_tx_stbc) { |
| 3768 | /* STBC and beamforming are mutually exclusive features */ |
| 3769 | owrt_ap_set_vap(dut, vap_id, "implicitbf", "0"); |
| 3770 | } |
| 3771 | |
Priyadharshini Gowthaman | 8fb1504 | 2015-11-25 18:27:41 +0530 | [diff] [blame] | 3772 | /* enable dfsmode */ |
| 3773 | snprintf(buf, sizeof(buf), "%d", dut->ap_dfs_mode); |
| 3774 | owrt_ap_set_vap(dut, vap_id, "doth", buf); |
| 3775 | |
priyadharshini gowthaman | 2323d0a | 2016-09-02 15:48:02 -0700 | [diff] [blame] | 3776 | if (dut->program == PROGRAM_LOC && dut->ap_interworking) { |
| 3777 | char anqpval[1024]; |
| 3778 | |
| 3779 | owrt_ap_set_vap(dut, vap_id, "interworking", "1"); |
| 3780 | |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 3781 | if (dut->ap_lci == 1 && strlen(dut->ap_tag_ssid[0]) == 0) { |
Pradeep Reddy Potteti | b48012a | 2016-11-28 16:58:54 +0530 | [diff] [blame] | 3782 | snprintf(anqpval, sizeof(anqpval), |
| 3783 | "'265:0010%s%s060101'", |
priyadharshini gowthaman | 2323d0a | 2016-09-02 15:48:02 -0700 | [diff] [blame] | 3784 | dut->ap_val_lci, dut->ap_infoz); |
| 3785 | owrt_ap_set_list_vap(dut, vap_id, "anqp_elem", anqpval); |
| 3786 | } |
| 3787 | |
| 3788 | if (dut->ap_lcr == 1) { |
Pradeep Reddy Potteti | b48012a | 2016-11-28 16:58:54 +0530 | [diff] [blame] | 3789 | snprintf(anqpval, sizeof(anqpval), |
| 3790 | "'266:0000b2555302ae%s'", |
priyadharshini gowthaman | 2323d0a | 2016-09-02 15:48:02 -0700 | [diff] [blame] | 3791 | dut->ap_val_lcr); |
| 3792 | owrt_ap_set_list_vap(dut, vap_id, "anqp_elem", anqpval); |
| 3793 | } |
| 3794 | |
| 3795 | if (dut->ap_fqdn_held == 1 && dut->ap_fqdn_supl == 1) |
| 3796 | owrt_ap_set_list_vap(dut, vap_id, "anqp_elem", |
| 3797 | "'267:00110168656c642e6578616d706c652e636f6d0011027375706c2e6578616d706c652e636f6d'"); |
| 3798 | } |
| 3799 | |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 3800 | if (dut->program == PROGRAM_MBO) { |
| 3801 | owrt_ap_set_vap(dut, vap_id, "interworking", "1"); |
| 3802 | owrt_ap_set_vap(dut, vap_id, "mbo", "1"); |
| 3803 | owrt_ap_set_vap(dut, vap_id, "rrm", "1"); |
Adil Saeed Musthafa | 65160c0 | 2017-04-10 23:13:38 -0700 | [diff] [blame] | 3804 | owrt_ap_set_vap(dut, vap_id, "mbo_cell_conn_pref", "1"); |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 3805 | |
| 3806 | owrt_ap_set_list_vap(dut, vap_id, "anqp_elem", |
| 3807 | "'272:34108cfdf0020df1f7000000733000030101'"); |
Adil Saeed Musthafa | ed5faae | 2017-04-10 23:13:36 -0700 | [diff] [blame] | 3808 | snprintf(buf, sizeof(buf), "%d", dut->ap_gas_cb_delay); |
| 3809 | owrt_ap_set_vap(dut, vap_id, "gas_comeback_delay", buf); |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 3810 | } |
| 3811 | |
Jouni Malinen | 6be21c8 | 2018-08-01 18:47:24 +0300 | [diff] [blame] | 3812 | if (ap_ft_enabled(dut)) { |
Adil Saeed Musthafa | 4ec61bd | 2017-04-10 23:13:41 -0700 | [diff] [blame] | 3813 | unsigned char self_mac[ETH_ALEN]; |
| 3814 | char mac_str[20]; |
| 3815 | |
Jouni Malinen | 9f94331 | 2019-08-19 23:49:16 +0300 | [diff] [blame] | 3816 | owrt_ap_set_vap(dut, vap_id, "ft_over_ds", |
| 3817 | dut->ap_ft_ds == VALUE_ENABLED ? "1" : "0"); |
Adil Saeed Musthafa | 4ec61bd | 2017-04-10 23:13:41 -0700 | [diff] [blame] | 3818 | owrt_ap_set_vap(dut, vap_id, "ieee80211r", "1"); |
Jouni Malinen | 1370122 | 2019-02-19 12:10:53 +0200 | [diff] [blame] | 3819 | if (get_hwaddr(sigma_radio_ifname[0], self_mac) < 0) |
| 3820 | return -1; |
Adil Saeed Musthafa | 4ec61bd | 2017-04-10 23:13:41 -0700 | [diff] [blame] | 3821 | snprintf(mac_str, sizeof(mac_str), |
| 3822 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 3823 | self_mac[0], self_mac[1], self_mac[2], |
| 3824 | self_mac[3], self_mac[4], self_mac[5]); |
| 3825 | owrt_ap_set_vap(dut, vap_id, "ap_macaddr", mac_str); |
priyadharshini gowthaman | 47189f5 | 2017-12-28 12:37:46 -0800 | [diff] [blame] | 3826 | snprintf(mac_str, sizeof(mac_str), |
| 3827 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 3828 | self_mac[0], self_mac[1], self_mac[2], |
| 3829 | self_mac[3], self_mac[4], self_mac[5]); |
| 3830 | owrt_ap_set_vap(dut, vap_id, "r1_key_holder", mac_str); |
Adil Saeed Musthafa | 4ec61bd | 2017-04-10 23:13:41 -0700 | [diff] [blame] | 3831 | owrt_ap_set_vap(dut, vap_id, "ft_psk_generate_local", "1"); |
| 3832 | owrt_ap_set_vap(dut, vap_id, "kh_key_hex", |
| 3833 | "000102030405060708090a0b0c0d0e0f"); |
| 3834 | snprintf(mac_str, sizeof(mac_str), |
| 3835 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 3836 | dut->ft_bss_mac_list[0][0], |
| 3837 | dut->ft_bss_mac_list[0][1], |
| 3838 | dut->ft_bss_mac_list[0][2], |
| 3839 | dut->ft_bss_mac_list[0][3], |
| 3840 | dut->ft_bss_mac_list[0][4], |
| 3841 | dut->ft_bss_mac_list[0][5]); |
| 3842 | owrt_ap_set_vap(dut, vap_id, "ap2_macaddr", mac_str); |
priyadharshini gowthaman | 47189f5 | 2017-12-28 12:37:46 -0800 | [diff] [blame] | 3843 | owrt_ap_set_vap(dut, vap_id, "mobility_domain", |
| 3844 | dut->ap_mobility_domain); |
| 3845 | owrt_ap_set_vap(dut, vap_id, "ap2_r1_key_holder", mac_str); |
Adil Saeed Musthafa | 4ec61bd | 2017-04-10 23:13:41 -0700 | [diff] [blame] | 3846 | } |
| 3847 | |
Jouni Malinen | 6be21c8 | 2018-08-01 18:47:24 +0300 | [diff] [blame] | 3848 | if ((ap_ft_enabled(dut) && dut->ap_name == 0) || |
| 3849 | (ap_ft_enabled(dut) && dut->ap_name == 2)) { |
Adil Saeed Musthafa | 4ec61bd | 2017-04-10 23:13:41 -0700 | [diff] [blame] | 3850 | owrt_ap_set_vap(dut, vap_id, "nasid2", "nas2.example.com"); |
| 3851 | owrt_ap_set_vap(dut, vap_id, "nasid", "nas1.example.com"); |
Adil Saeed Musthafa | 4ec61bd | 2017-04-10 23:13:41 -0700 | [diff] [blame] | 3852 | } |
| 3853 | |
Jouni Malinen | 6be21c8 | 2018-08-01 18:47:24 +0300 | [diff] [blame] | 3854 | if (ap_ft_enabled(dut) && dut->ap_name == 1) { |
Adil Saeed Musthafa | 4ec61bd | 2017-04-10 23:13:41 -0700 | [diff] [blame] | 3855 | owrt_ap_set_vap(dut, vap_id, "nasid2", "nas1.example.com"); |
| 3856 | owrt_ap_set_vap(dut, vap_id, "nasid", "nas2.example.com"); |
Adil Saeed Musthafa | 4ec61bd | 2017-04-10 23:13:41 -0700 | [diff] [blame] | 3857 | } |
| 3858 | |
priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 3859 | if (dut->ap_broadcast_ssid == VALUE_DISABLED) |
| 3860 | owrt_ap_set_vap(dut, vap_id, "hidden", "1"); |
| 3861 | |
priyadharshini gowthaman | de81f39 | 2017-12-28 15:28:49 -0800 | [diff] [blame] | 3862 | /* Enable/disable PMKSA caching, if asked to */ |
| 3863 | if (dut->ap_pmksa == 1) { |
| 3864 | snprintf(buf, sizeof(buf), "%d", dut->ap_pmksa_caching); |
| 3865 | owrt_ap_set_vap(dut, vap_id, "disable_pmksa_caching", buf); |
| 3866 | } |
| 3867 | |
priyadharshini gowthaman | cce6ca0 | 2018-01-15 11:12:45 -0800 | [diff] [blame] | 3868 | if (dut->rsne_override) { |
| 3869 | snprintf(buf, sizeof(buf), "%s", dut->rsne_override); |
| 3870 | owrt_ap_set_vap(dut, vap_count, "own_ie_override", buf); |
| 3871 | } |
| 3872 | |
| 3873 | if (dut->sae_commit_override) { |
| 3874 | snprintf(buf, sizeof(buf), "%s", dut->sae_commit_override); |
| 3875 | owrt_ap_set_vap(dut, vap_count, "sae_commit_override", buf); |
| 3876 | } |
| 3877 | |
| 3878 | if (dut->ap_sae_groups) { |
| 3879 | snprintf(buf, sizeof(buf), "\'%s\'", dut->ap_sae_groups); |
priyadharshini gowthaman | b59bfe4 | 2018-08-30 15:14:08 -0700 | [diff] [blame] | 3880 | owrt_ap_set_list_vap(dut, vap_count, "sae_groups", buf); |
priyadharshini gowthaman | cce6ca0 | 2018-01-15 11:12:45 -0800 | [diff] [blame] | 3881 | } |
| 3882 | |
| 3883 | if (dut->sae_anti_clogging_threshold >= 0) { |
| 3884 | snprintf(buf, sizeof(buf), "%d", |
| 3885 | dut->sae_anti_clogging_threshold); |
| 3886 | owrt_ap_set_vap(dut, vap_count, "sae_anti_clogging_threshold", |
| 3887 | buf); |
| 3888 | } |
| 3889 | |
| 3890 | if (dut->sae_reflection) |
| 3891 | owrt_ap_set_vap(dut, vap_count, "sae_reflection_attack", "1"); |
Jouni Malinen | 3c740ab | 2019-10-10 15:55:11 +0300 | [diff] [blame] | 3892 | if (dut->sae_confirm_immediate) |
| 3893 | owrt_ap_set_vap(dut, vap_count, "sae_confirm_immediate", "1"); |
priyadharshini gowthaman | cce6ca0 | 2018-01-15 11:12:45 -0800 | [diff] [blame] | 3894 | |
Priyadharshini Gowthaman | fe60c50 | 2019-08-14 13:00:34 -0700 | [diff] [blame] | 3895 | if (dut->program == PROGRAM_HE && |
| 3896 | (dut->ap_txBF || dut->ap_he_ulofdma == VALUE_ENABLED)) { |
| 3897 | switch (dut->ap_chwidth) { |
| 3898 | case AP_20: |
| 3899 | owrt_ap_set_vap(dut, vap_id, "chwidth", "0"); |
| 3900 | break; |
| 3901 | case AP_40: |
| 3902 | owrt_ap_set_vap(dut, vap_id, "chwidth", "1"); |
| 3903 | break; |
| 3904 | case AP_80: |
| 3905 | owrt_ap_set_vap(dut, vap_id, "chwidth", "2"); |
| 3906 | break; |
| 3907 | case AP_160: |
| 3908 | owrt_ap_set_vap(dut, vap_id, "chwidth", "3"); |
| 3909 | break; |
| 3910 | case AP_80_80: |
| 3911 | owrt_ap_set_vap(dut, vap_id, "chwidth", "3"); |
| 3912 | break; |
| 3913 | case AP_AUTO: |
| 3914 | break; |
| 3915 | } |
| 3916 | } |
| 3917 | |
| 3918 | if (dut->ap_he_dlofdma == VALUE_ENABLED && dut->ap_he_ppdu == PPDU_MU) { |
| 3919 | dut->ap_txBF = 0; |
| 3920 | dut->ap_mu_txBF = 0; |
| 3921 | owrt_ap_set_vap(dut, vap_id, "vhtsubfer", "0"); |
| 3922 | owrt_ap_set_vap(dut, vap_id, "vhtsubfee", "0"); |
| 3923 | owrt_ap_set_vap(dut, vap_id, "he_subfer", "0"); |
| 3924 | } |
| 3925 | |
Priyadharshini Gowthaman | dee79e2 | 2019-10-07 16:56:27 -0700 | [diff] [blame] | 3926 | if (dut->program == PROGRAM_HE && |
| 3927 | (dut->ap_txBF || dut->ap_he_ulofdma == VALUE_ENABLED || |
| 3928 | dut->ap_he_mimo == MIMO_DL)) { |
| 3929 | switch (dut->ap_chwidth) { |
| 3930 | case AP_20: |
| 3931 | owrt_ap_set_vap(dut, vap_id, "chwidth", "0"); |
| 3932 | break; |
| 3933 | case AP_40: |
| 3934 | owrt_ap_set_vap(dut, vap_id, "chwidth", "1"); |
| 3935 | break; |
| 3936 | case AP_80: |
| 3937 | owrt_ap_set_vap(dut, vap_id, "chwidth", "2"); |
| 3938 | break; |
| 3939 | case AP_160: |
| 3940 | owrt_ap_set_vap(dut, vap_id, "chwidth", "3"); |
| 3941 | break; |
| 3942 | case AP_80_80: |
| 3943 | owrt_ap_set_vap(dut, vap_id, "chwidth", "3"); |
| 3944 | break; |
| 3945 | case AP_AUTO: |
| 3946 | default: |
| 3947 | break; |
| 3948 | } |
| 3949 | } |
| 3950 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3951 | return 1; |
| 3952 | } |
| 3953 | |
| 3954 | |
priyadharshini gowthaman | 2500f20 | 2016-10-13 17:13:55 -0700 | [diff] [blame] | 3955 | static int owrt_ap_config_vap_anqp(struct sigma_dut *dut) |
| 3956 | { |
| 3957 | char anqpval[1024]; |
| 3958 | unsigned char addr[6]; |
| 3959 | unsigned char addr2[6]; |
| 3960 | struct ifreq ifr; |
| 3961 | char *ifname; |
| 3962 | int s; |
| 3963 | int vap_id = 0; |
| 3964 | |
| 3965 | s = socket(AF_INET, SOCK_DGRAM, 0); |
| 3966 | if (s < 0) { |
| 3967 | sigma_dut_print(dut, DUT_MSG_ERROR, "Failed to open socket"); |
| 3968 | return -1; |
| 3969 | } |
| 3970 | |
| 3971 | memset(&ifr, 0, sizeof(ifr)); |
| 3972 | ifname = "ath0"; |
Peng Xu | b8fc5cc | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 3973 | strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name)); |
priyadharshini gowthaman | 2500f20 | 2016-10-13 17:13:55 -0700 | [diff] [blame] | 3974 | if (ioctl(s, SIOCGIFHWADDR, &ifr) < 0) { |
| 3975 | perror("ioctl"); |
| 3976 | close(s); |
| 3977 | return -1; |
| 3978 | } |
| 3979 | memcpy(addr, ifr.ifr_hwaddr.sa_data, 6); |
| 3980 | |
| 3981 | memset(&ifr, 0, sizeof(ifr)); |
| 3982 | ifname = "ath01"; |
Peng Xu | b8fc5cc | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 3983 | strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name)); |
priyadharshini gowthaman | 2500f20 | 2016-10-13 17:13:55 -0700 | [diff] [blame] | 3984 | if (ioctl(s, SIOCGIFHWADDR, &ifr) < 0) { |
| 3985 | perror("ioctl"); |
| 3986 | close(s); |
| 3987 | return -1; |
| 3988 | } |
| 3989 | close(s); |
| 3990 | memcpy(addr2, ifr.ifr_hwaddr.sa_data, 6); |
| 3991 | |
| 3992 | snprintf(anqpval, sizeof(anqpval), |
| 3993 | "'265:0010%s%s060101070d00%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x'", |
| 3994 | dut->ap_val_lci, dut->ap_infoz, |
| 3995 | addr[0], addr[1], addr[2], addr[3], addr[4], addr[5], |
| 3996 | addr2[0], addr2[1], addr2[2], addr2[3], addr2[4], addr2[5]); |
| 3997 | |
| 3998 | owrt_ap_set_list_vap(dut, vap_id, "anqp_elem", anqpval); |
| 3999 | return 0; |
| 4000 | } |
| 4001 | |
| 4002 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4003 | static int owrt_ap_post_config_commit(struct sigma_dut *dut, |
| 4004 | struct sigma_conn *conn, |
| 4005 | struct sigma_cmd *cmd) |
| 4006 | { |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 4007 | int ap_security = 0; |
| 4008 | int i; |
| 4009 | |
| 4010 | for (i = 0; i < MAX_WLAN_TAGS - 1; i++) { |
| 4011 | if (dut->ap_tag_key_mgmt[i] != AP2_OPEN) |
| 4012 | ap_security = 1; |
| 4013 | } |
| 4014 | if (dut->ap_key_mgmt != AP_OPEN) |
| 4015 | ap_security = 1; |
| 4016 | if (ap_security) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4017 | /* allow some time for hostapd to start before returning |
| 4018 | * success */ |
| 4019 | usleep(500000); |
| 4020 | |
| 4021 | if (run_hostapd_cli(dut, "ping") != 0) { |
| 4022 | send_resp(dut, conn, SIGMA_ERROR, |
| 4023 | "errorCode,Failed to talk to hostapd"); |
| 4024 | return 0; |
| 4025 | } |
| 4026 | } |
| 4027 | |
| 4028 | if (get_openwrt_driver_type() == OPENWRT_DRIVER_ATHEROS) |
| 4029 | ath_ap_set_params(dut); |
| 4030 | |
| 4031 | /* Send response */ |
| 4032 | return 1; |
| 4033 | } |
| 4034 | |
| 4035 | |
| 4036 | static int cmd_owrt_ap_config_commit(struct sigma_dut *dut, |
| 4037 | struct sigma_conn *conn, |
| 4038 | struct sigma_cmd *cmd) |
| 4039 | { |
priyadharshini gowthaman | b4de196 | 2018-01-15 12:21:04 -0800 | [diff] [blame] | 4040 | if (dut->program == PROGRAM_DPP && |
Jouni Malinen | 016ae6c | 2019-11-04 17:00:01 +0200 | [diff] [blame] | 4041 | get_driver_type(dut) == DRIVER_OPENWRT) { |
priyadharshini gowthaman | b4de196 | 2018-01-15 12:21:04 -0800 | [diff] [blame] | 4042 | wpa_command(dut->hostapd_ifname, "DPP_BOOTSTRAP_REMOVE *"); |
| 4043 | wpa_command(dut->hostapd_ifname, "DPP_PKEX_REMOVE *"); |
| 4044 | } |
| 4045 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4046 | /* Stop the AP */ |
| 4047 | run_system(dut, "wifi down"); |
| 4048 | |
| 4049 | /* Reset the wireless configuration */ |
Mohammed Shafi Shajakhan | f789f82 | 2016-04-07 18:53:16 +0530 | [diff] [blame] | 4050 | run_system(dut, "rm -rf /etc/config/wireless"); |
| 4051 | switch (get_openwrt_driver_type()) { |
| 4052 | case OPENWRT_DRIVER_ATHEROS: |
| 4053 | run_system(dut, "wifi detect qcawifi > /etc/config/wireless"); |
| 4054 | break; |
| 4055 | default: |
| 4056 | run_system(dut, "wifi detect > /etc/config/wireless"); |
| 4057 | break; |
| 4058 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4059 | |
| 4060 | /* Configure Radio & VAP, commit the config */ |
Priyadharshini Gowthaman | 8018c98 | 2019-10-31 15:14:37 -0700 | [diff] [blame] | 4061 | if (owrt_ap_config_radio(dut) < 0) |
| 4062 | return ERROR_SEND_STATUS; |
Jouni Malinen | 1370122 | 2019-02-19 12:10:53 +0200 | [diff] [blame] | 4063 | if (owrt_ap_config_vap(dut) < 0) |
| 4064 | return ERROR_SEND_STATUS; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4065 | run_system(dut, "uci commit"); |
| 4066 | |
| 4067 | /* Start AP */ |
| 4068 | run_system(dut, "wifi up"); |
Adil Saeed Musthafa | a8d7484 | 2017-04-10 23:13:39 -0700 | [diff] [blame] | 4069 | if (dut->program != PROGRAM_MBO && |
| 4070 | dut->ap_lci == 1 && dut->ap_interworking && |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 4071 | strlen(dut->ap_tag_ssid[0]) > 0) { |
Adil Saeed Musthafa | a8d7484 | 2017-04-10 23:13:39 -0700 | [diff] [blame] | 4072 | /* |
| 4073 | * MBO has a different ANQP element value which is set in |
| 4074 | * owrt_ap_config_vap(). |
| 4075 | */ |
priyadharshini gowthaman | 2500f20 | 2016-10-13 17:13:55 -0700 | [diff] [blame] | 4076 | owrt_ap_config_vap_anqp(dut); |
| 4077 | run_system(dut, "uci commit"); |
| 4078 | run_system(dut, "wifi"); |
| 4079 | } |
| 4080 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4081 | return owrt_ap_post_config_commit(dut, conn, cmd); |
| 4082 | } |
| 4083 | |
| 4084 | |
| 4085 | static void cmd_owrt_ap_hs2_reset(struct sigma_dut *dut) |
| 4086 | { |
| 4087 | unsigned char bssid[6]; |
| 4088 | char buf[100]; |
| 4089 | char *ifname, *radio_name; |
| 4090 | int vap_id = 0; |
| 4091 | |
| 4092 | if (sigma_radio_ifname[0] && |
| 4093 | strcmp(sigma_radio_ifname[0], "wifi2") == 0) { |
| 4094 | ifname = "ath2"; |
| 4095 | radio_name = "wifi2"; |
| 4096 | vap_id = 2; |
| 4097 | } else if (sigma_radio_ifname[0] && |
| 4098 | strcmp(sigma_radio_ifname[0], "wifi1") == 0) { |
| 4099 | ifname = "ath1"; |
| 4100 | radio_name = "wifi1"; |
| 4101 | vap_id = 1; |
| 4102 | } else { |
| 4103 | ifname = "ath0"; |
| 4104 | radio_name = "wifi0"; |
| 4105 | vap_id = 0; |
| 4106 | } |
| 4107 | |
| 4108 | if (!get_hwaddr(ifname, bssid)) { |
| 4109 | snprintf(buf, sizeof(buf), "%s", bssid); |
| 4110 | owrt_ap_set_vap(dut, vap_id, "hessid", buf); |
| 4111 | snprintf(dut->ap_hessid, sizeof(dut->ap_hessid), |
| 4112 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 4113 | bssid[0], bssid[1], bssid[2], bssid[3], |
| 4114 | bssid[4], bssid[5]); |
| 4115 | } else { |
| 4116 | if (!get_hwaddr(radio_name, bssid)) { |
| 4117 | snprintf(buf, sizeof(buf), "%s", dut->ap_hessid); |
| 4118 | owrt_ap_set_vap(dut, vap_id, "hessid", buf); |
| 4119 | snprintf(dut->ap_hessid, sizeof(dut->ap_hessid), |
| 4120 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 4121 | bssid[0], bssid[1], bssid[2], bssid[3], |
| 4122 | bssid[4], bssid[5]); |
| 4123 | } else { |
| 4124 | /* Select & enable/disable radios */ |
| 4125 | if (sigma_radio_ifname[0] && |
| 4126 | strcmp(sigma_radio_ifname[0], "wifi2") == 0) { |
| 4127 | /* We want to use wifi2 */ |
| 4128 | owrt_ap_set_radio(dut, 0, "disabled", "1"); |
| 4129 | owrt_ap_set_radio(dut, 1, "disabled", "1"); |
| 4130 | owrt_ap_set_radio(dut, 2, "disabled", "0"); |
| 4131 | owrt_ap_set_vap(dut, vap_id, "device", "wifi2"); |
| 4132 | } else if (sigma_radio_ifname[0] && |
| 4133 | strcmp(sigma_radio_ifname[0], "wifi1") == 0) { |
| 4134 | /* We want to use wifi1 */ |
| 4135 | owrt_ap_set_radio(dut, 0, "disabled", "1"); |
| 4136 | owrt_ap_set_radio(dut, 1, "disabled", "0"); |
| 4137 | owrt_ap_set_vap(dut, vap_id, "device", "wifi1"); |
| 4138 | } else { |
| 4139 | /* We want to use wifi0 */ |
| 4140 | owrt_ap_set_radio(dut, 0, "disabled", "0"); |
| 4141 | owrt_ap_set_radio(dut, 1, "disabled", "1"); |
| 4142 | owrt_ap_set_vap(dut, vap_id, "device", "wifi0"); |
| 4143 | } |
| 4144 | |
| 4145 | run_system(dut, "uci commit"); |
| 4146 | run_system(dut, "wifi up"); |
| 4147 | |
| 4148 | if (!get_hwaddr(radio_name, bssid)) { |
| 4149 | snprintf(buf, sizeof(buf), "%s", |
| 4150 | dut->ap_hessid); |
| 4151 | owrt_ap_set_vap(dut, vap_id, "hessid", buf); |
| 4152 | snprintf(dut->ap_hessid, sizeof(dut->ap_hessid), |
| 4153 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 4154 | bssid[0], bssid[1], bssid[2], bssid[3], |
| 4155 | bssid[4], bssid[5]); |
| 4156 | } |
| 4157 | } |
| 4158 | } |
| 4159 | } |
| 4160 | |
| 4161 | |
Jouni Malinen | f722271 | 2019-06-13 01:50:21 +0300 | [diff] [blame] | 4162 | static enum sigma_cmd_result cmd_ap_reboot(struct sigma_dut *dut, |
| 4163 | struct sigma_conn *conn, |
| 4164 | struct sigma_cmd *cmd) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4165 | { |
Jouni Malinen | 016ae6c | 2019-11-04 17:00:01 +0200 | [diff] [blame] | 4166 | switch (get_driver_type(dut)) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4167 | case DRIVER_ATHEROS: |
| 4168 | run_system(dut, "apdown"); |
| 4169 | sleep(1); |
| 4170 | run_system(dut, "reboot"); |
| 4171 | break; |
| 4172 | case DRIVER_OPENWRT: |
| 4173 | run_system(dut, "wifi down"); |
| 4174 | sleep(1); |
| 4175 | run_system(dut, "reboot"); |
| 4176 | break; |
| 4177 | default: |
| 4178 | sigma_dut_print(dut, DUT_MSG_INFO, "Ignore ap_reboot command"); |
| 4179 | break; |
| 4180 | } |
| 4181 | |
| 4182 | return 1; |
| 4183 | } |
| 4184 | |
| 4185 | |
| 4186 | int ascii2hexstr(const char *str, char *hex) |
| 4187 | { |
| 4188 | int i, length; |
| 4189 | |
| 4190 | length = strlen(str); |
| 4191 | |
| 4192 | for (i = 0; i < length; i++) |
| 4193 | snprintf(hex + i * 2, 3, "%X", str[i]); |
| 4194 | |
| 4195 | hex[length * 2] = '\0'; |
| 4196 | return 1; |
| 4197 | } |
| 4198 | |
| 4199 | |
| 4200 | static int kill_process(struct sigma_dut *dut, char *proc_name, |
| 4201 | unsigned char is_proc_instance_one, int sig) |
| 4202 | { |
| 4203 | #ifdef __linux__ |
| 4204 | struct dirent *dp, *dp_in; |
| 4205 | const char *direc = "/proc/"; |
| 4206 | char buf[100]; |
| 4207 | DIR *dir = opendir(direc); |
| 4208 | DIR *dir_in; |
| 4209 | FILE *fp; |
| 4210 | char *pid, *temp; |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 4211 | char *saveptr; |
Jouni Malinen | 3aa7286 | 2019-05-29 23:14:51 +0300 | [diff] [blame] | 4212 | int ret = -1, res; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4213 | |
| 4214 | if (dir == NULL) |
Pradeep Reddy Potteti | d068e64 | 2017-02-17 20:03:12 +0530 | [diff] [blame] | 4215 | return ret; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4216 | |
| 4217 | while ((dp = readdir(dir)) != NULL) { |
| 4218 | if (dp->d_type != DT_DIR) |
| 4219 | continue; |
| 4220 | |
Jouni Malinen | 3aa7286 | 2019-05-29 23:14:51 +0300 | [diff] [blame] | 4221 | res = snprintf(buf, sizeof(buf), "%s%s", direc, dp->d_name); |
| 4222 | if (res < 0 || res >= sizeof(buf)) |
| 4223 | continue; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4224 | dir_in = opendir(buf); |
| 4225 | if (dir_in == NULL) |
| 4226 | continue; |
| 4227 | dp_in = readdir(dir_in); |
| 4228 | closedir(dir_in); |
| 4229 | if (dp_in == NULL) |
| 4230 | continue; |
Jouni Malinen | 3aa7286 | 2019-05-29 23:14:51 +0300 | [diff] [blame] | 4231 | res = snprintf(buf, sizeof(buf), "%s%s/stat", |
| 4232 | direc, dp->d_name); |
| 4233 | if (res < 0 || res >= sizeof(buf)) |
| 4234 | continue; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4235 | fp = fopen(buf, "r"); |
| 4236 | if (fp == NULL) |
| 4237 | continue; |
| 4238 | if (fgets(buf, 100, fp) == NULL) |
| 4239 | buf[0] = '\0'; |
| 4240 | fclose(fp); |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 4241 | pid = strtok_r(buf, " ", &saveptr); |
| 4242 | temp = strtok_r(NULL, " ", &saveptr); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4243 | if (pid && temp && |
| 4244 | strncmp(temp, proc_name, strlen(proc_name)) == 0) { |
| 4245 | sigma_dut_print(dut, DUT_MSG_INFO, |
| 4246 | "killing %s process with PID %s", |
| 4247 | proc_name, pid); |
| 4248 | snprintf(buf, sizeof(buf), "kill -%d %d", sig, |
| 4249 | atoi(pid)); |
| 4250 | run_system(dut, buf); |
Pradeep Reddy Potteti | d068e64 | 2017-02-17 20:03:12 +0530 | [diff] [blame] | 4251 | ret = 0; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4252 | if (is_proc_instance_one) |
| 4253 | break; |
| 4254 | } |
| 4255 | } |
| 4256 | |
| 4257 | closedir(dir); |
| 4258 | |
Pradeep Reddy Potteti | d068e64 | 2017-02-17 20:03:12 +0530 | [diff] [blame] | 4259 | return ret; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4260 | #else /* __linux__ */ |
| 4261 | return -1; |
| 4262 | #endif /* __linux__ */ |
| 4263 | } |
| 4264 | |
| 4265 | |
| 4266 | static int run_ndc(struct sigma_dut *dut, char *buf) |
| 4267 | { |
| 4268 | sigma_dut_print(dut, DUT_MSG_INFO, "CMD NDC:: %s", buf); |
| 4269 | sleep(2); |
| 4270 | return run_system(dut, buf); |
| 4271 | } |
| 4272 | |
| 4273 | |
| 4274 | static int sigma_write_cfg(struct sigma_dut *dut, const char *pfile, |
| 4275 | const char *field, const char *value) |
| 4276 | { |
| 4277 | FILE *fcfg, *ftmp; |
| 4278 | char buf[MAX_CONF_LINE_LEN + 1]; |
| 4279 | int len, found = 0, res; |
| 4280 | |
| 4281 | /* Open the configuration file */ |
| 4282 | fcfg = fopen(pfile, "r"); |
| 4283 | if (!fcfg) { |
| 4284 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4285 | "Failed to open hostapd conf file"); |
| 4286 | return -1; |
| 4287 | } |
| 4288 | |
| 4289 | snprintf(buf, sizeof(buf), "%s~", pfile); |
| 4290 | /* Open a temporary file */ |
| 4291 | ftmp = fopen(buf, "w+"); |
| 4292 | if (!ftmp) { |
| 4293 | fclose(fcfg); |
| 4294 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4295 | "Failed to open temp buf"); |
| 4296 | return -1; |
| 4297 | } |
| 4298 | |
| 4299 | /* Read the values from the configuration file */ |
| 4300 | len = strlen(field); |
| 4301 | while (fgets(buf, MAX_CONF_LINE_LEN, fcfg)) { |
| 4302 | char *pline = buf; |
| 4303 | |
| 4304 | /* commented line */ |
| 4305 | if (buf[0] == '#') |
| 4306 | pline++; |
| 4307 | |
| 4308 | /* Identify the configuration parameter to be updated */ |
| 4309 | if (!found && strncmp(pline, field, len) == 0 && |
| 4310 | pline[len] == '=') { |
| 4311 | snprintf(buf, sizeof(buf), "%s=%s\n", field, value); |
| 4312 | found = 1; |
| 4313 | sigma_dut_print(dut, DUT_MSG_INFO, |
| 4314 | "Updated hostapd conf file"); |
| 4315 | } |
| 4316 | |
| 4317 | fprintf(ftmp, "%s", buf); |
| 4318 | } |
| 4319 | |
| 4320 | if (!found) { |
| 4321 | /* Configuration line not found */ |
| 4322 | /* Add the new line at the end of file */ |
| 4323 | fprintf(ftmp, "%s=%s\n", field, value); |
| 4324 | sigma_dut_print(dut, DUT_MSG_INFO, |
| 4325 | "Adding a new line in hostapd conf file"); |
| 4326 | } |
| 4327 | |
| 4328 | fclose(fcfg); |
| 4329 | fclose(ftmp); |
| 4330 | |
| 4331 | snprintf(buf, sizeof(buf), "%s~", pfile); |
| 4332 | |
| 4333 | /* Restore the updated configuration file */ |
| 4334 | res = rename(buf, pfile); |
| 4335 | |
| 4336 | /* Remove the temporary file. Ignore the return value */ |
| 4337 | unlink(buf); |
| 4338 | |
| 4339 | /* chmod is needed because open() may not set permissions properly |
| 4340 | * depending on the current umask */ |
| 4341 | if (chmod(pfile, 0660) < 0) { |
| 4342 | unlink(pfile); |
| 4343 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4344 | "Error changing permissions"); |
| 4345 | return -1; |
| 4346 | } |
| 4347 | |
| 4348 | if (res < 0) { |
| 4349 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4350 | "Error restoring conf file"); |
| 4351 | return -1; |
| 4352 | } |
| 4353 | |
| 4354 | return 0; |
| 4355 | } |
| 4356 | |
| 4357 | |
| 4358 | static int cmd_wcn_ap_config_commit(struct sigma_dut *dut, |
| 4359 | struct sigma_conn *conn, |
| 4360 | struct sigma_cmd *cmd) |
| 4361 | { |
| 4362 | char buf[100]; |
| 4363 | struct stat s; |
| 4364 | int num_tries = 0, ret; |
| 4365 | |
Pradeep Reddy Potteti | d068e64 | 2017-02-17 20:03:12 +0530 | [diff] [blame] | 4366 | if (kill_process(dut, "(netd)", 1, SIGKILL) == 0 || |
| 4367 | system("killall netd") == 0) { |
| 4368 | /* Avoid Error: Error connecting (Connection refused) |
| 4369 | * Wait some time to allow netd to reinitialize. |
| 4370 | */ |
| 4371 | usleep(1500000); |
| 4372 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4373 | |
| 4374 | while (num_tries < 10) { |
| 4375 | ret = run_ndc(dut, "ndc softap stopap"); |
| 4376 | num_tries++; |
| 4377 | if (WIFEXITED(ret)) |
| 4378 | ret = WEXITSTATUS(ret); |
| 4379 | /* On success, NDC exits with 0 */ |
| 4380 | if (ret == 0) |
| 4381 | break; |
| 4382 | sigma_dut_print(dut, DUT_MSG_INFO, |
| 4383 | "Try No. %d: ndc softap stopap failed, exit code %d", |
| 4384 | num_tries, ret); |
| 4385 | } |
| 4386 | |
| 4387 | if (ret != 0) |
| 4388 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4389 | "ndc softap stopap command failed for 10 times - giving up"); |
| 4390 | |
| 4391 | #ifdef ANDROID |
| 4392 | /* Unload/Load driver to cleanup the state of the driver */ |
Ajit Vaishya | 14d1f9a | 2017-09-04 23:24:25 +0530 | [diff] [blame] | 4393 | system("rmmod -f wlan"); |
| 4394 | usleep(500000); |
| 4395 | system("insmod /system/lib/modules/wlan.ko"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4396 | #else /* ANDROID */ |
| 4397 | run_ndc(dut, "ndc softap qccmd set enable_softap=0"); |
| 4398 | run_ndc(dut, "ndc softap qccmd set enable_softap=1"); |
| 4399 | #endif /* ANDROID */ |
| 4400 | |
| 4401 | switch (dut->ap_mode) { |
| 4402 | case AP_11g: |
| 4403 | run_ndc(dut, "ndc softap qccmd set hw_mode=g-only"); |
| 4404 | break; |
| 4405 | case AP_11b: |
| 4406 | run_ndc(dut, "ndc softap qccmd set hw_mode=b-only"); |
| 4407 | break; |
| 4408 | case AP_11ng: |
| 4409 | run_ndc(dut, "ndc softap qccmd set hw_mode=n"); |
| 4410 | break; |
| 4411 | case AP_11a: |
| 4412 | run_ndc(dut, "ndc softap qccmd set hw_mode=a-only"); |
| 4413 | break; |
| 4414 | case AP_11na: |
| 4415 | run_ndc(dut, "ndc softap qccmd set hw_mode=n"); |
| 4416 | break; |
| 4417 | case AP_11ac: |
| 4418 | run_ndc(dut, "ndc softap qccmd set hw_mode=ac"); |
| 4419 | break; |
| 4420 | default: |
| 4421 | break; |
| 4422 | } |
| 4423 | |
| 4424 | snprintf(buf, sizeof(buf), "ndc softap qccmd set channel=%d", |
| 4425 | dut->ap_channel); |
| 4426 | run_ndc(dut, buf); |
| 4427 | |
| 4428 | /* |
| 4429 | * ndc doesn't support double quotes as SSID string, so re-write |
| 4430 | * hostapd configuration file to update SSID. |
| 4431 | */ |
| 4432 | if (dut->ap_ssid[0] != '\0') |
| 4433 | sigma_write_cfg(dut, ANDROID_CONFIG_FILE, "ssid", dut->ap_ssid); |
| 4434 | |
| 4435 | switch (dut->ap_key_mgmt) { |
| 4436 | case AP_OPEN: |
| 4437 | if (dut->ap_cipher == AP_WEP) { |
| 4438 | run_ndc(dut, "ndc softap qccmd set security_mode=1"); |
| 4439 | snprintf(buf, sizeof(buf), |
| 4440 | "ndc softap qccmd set wep_key0=%s", |
| 4441 | dut->ap_wepkey); |
| 4442 | run_ndc(dut, buf); |
| 4443 | } else { |
| 4444 | run_ndc(dut, "ndc softap qccmd set security_mode=0"); |
| 4445 | } |
| 4446 | break; |
| 4447 | case AP_WPA2_PSK: |
| 4448 | case AP_WPA2_PSK_MIXED: |
| 4449 | case AP_WPA_PSK: |
| 4450 | if (dut->ap_key_mgmt == AP_WPA2_PSK) |
| 4451 | run_ndc(dut, "ndc softap qccmd set security_mode=3"); |
| 4452 | else if (dut->ap_key_mgmt == AP_WPA2_PSK_MIXED) |
| 4453 | run_ndc(dut, "ndc softap qccmd set security_mode=4"); |
| 4454 | else |
| 4455 | run_ndc(dut, "ndc softap qccmd set security_mode=2"); |
| 4456 | |
| 4457 | /* |
| 4458 | * ndc doesn't support some special characters as passphrase, |
| 4459 | * so re-write hostapd configuration file to update Passphrase. |
| 4460 | */ |
| 4461 | if (dut->ap_passphrase[0] != '\0') |
| 4462 | sigma_write_cfg(dut, ANDROID_CONFIG_FILE, |
| 4463 | "wpa_passphrase", dut->ap_passphrase); |
| 4464 | |
| 4465 | if (dut->ap_cipher == AP_CCMP_TKIP) |
| 4466 | run_ndc(dut, "ndc softap qccmd set wpa_pairwise=" |
| 4467 | "TKIP CCMP"); |
| 4468 | else if (dut->ap_cipher == AP_TKIP) |
| 4469 | run_ndc(dut, "ndc softap qccmd set wpa_pairwise=" |
| 4470 | "TKIP"); |
| 4471 | else |
| 4472 | run_ndc(dut, "ndc softap qccmd set wpa_pairwise=" |
| 4473 | "CCMP &"); |
| 4474 | break; |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 4475 | case AP_WPA2_SAE: |
| 4476 | case AP_WPA2_PSK_SAE: |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4477 | case AP_WPA2_EAP: |
| 4478 | case AP_WPA2_EAP_MIXED: |
| 4479 | case AP_WPA_EAP: |
Jouni Malinen | ad395a2 | 2017-09-01 21:13:46 +0300 | [diff] [blame] | 4480 | case AP_SUITEB: |
Jouni Malinen | 147b3c3 | 2017-10-09 16:51:54 +0300 | [diff] [blame] | 4481 | case AP_WPA2_OWE: |
Jouni Malinen | 4cf699f | 2018-06-19 00:46:27 +0300 | [diff] [blame] | 4482 | case AP_WPA2_EAP_OSEN: |
Jouni Malinen | c2b9121 | 2018-09-12 02:26:39 +0300 | [diff] [blame] | 4483 | case AP_OSEN: |
Jouni Malinen | 6be21c8 | 2018-08-01 18:47:24 +0300 | [diff] [blame] | 4484 | case AP_WPA2_FT_EAP: |
| 4485 | case AP_WPA2_FT_PSK: |
| 4486 | case AP_WPA2_EAP_SHA256: |
| 4487 | case AP_WPA2_PSK_SHA256: |
| 4488 | case AP_WPA2_ENT_FT_EAP: |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4489 | /* Not supported */ |
| 4490 | break; |
| 4491 | } |
| 4492 | |
| 4493 | switch (dut->ap_pmf) { |
| 4494 | case AP_PMF_DISABLED: |
| 4495 | run_ndc(dut, "ndc softap qccmd set ieee80211w=0"); |
| 4496 | break; |
| 4497 | case AP_PMF_OPTIONAL: |
| 4498 | run_ndc(dut, "ndc softap qccmd set ieee80211w=1"); |
| 4499 | if (dut->ap_add_sha256) |
| 4500 | run_ndc(dut, "ndc softap qccmd set wpa_key_mgmt=WPA-PSK WPA-PSK-SHA256"); |
| 4501 | else |
| 4502 | run_ndc(dut, "ndc softap qccmd set wpa_key_mgmt=WPA-PSK"); |
| 4503 | break; |
| 4504 | case AP_PMF_REQUIRED: |
| 4505 | run_ndc(dut, "ndc softap qccmd set ieee80211w=2"); |
| 4506 | run_ndc(dut, "ndc softap qccmd set wpa_key_mgmt=WPA-PSK-SHA256"); |
| 4507 | break; |
| 4508 | } |
| 4509 | |
| 4510 | if (dut->ap_countrycode[0]) { |
| 4511 | snprintf(buf, sizeof(buf), |
| 4512 | "ndc softap qccmd set country_code=%s", |
| 4513 | dut->ap_countrycode); |
| 4514 | run_ndc(dut, buf); |
| 4515 | } |
| 4516 | |
Pradeep Reddy POTTETI | fba27db | 2015-11-20 16:42:22 +0530 | [diff] [blame] | 4517 | if (dut->ap_regulatory_mode == AP_80211D_MODE_ENABLED) |
| 4518 | run_ndc(dut, "ndc softap qccmd set ieee80211d=1"); |
| 4519 | |
| 4520 | if (dut->ap_dfs_mode == AP_DFS_MODE_ENABLED) |
| 4521 | run_ndc(dut, "ndc softap qccmd set ieee80211h=1"); |
| 4522 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4523 | run_ndc(dut, "ndc softap startap"); |
| 4524 | |
Jouni Malinen | 5ea3092 | 2019-11-04 17:39:25 +0200 | [diff] [blame] | 4525 | snprintf(buf, sizeof(buf), "%s%s", sigma_wpas_ctrl, |
| 4526 | get_main_ifname(dut)); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4527 | num_tries = 0; |
| 4528 | while (num_tries < 10 && (ret = stat(buf, &s) != 0)) { |
| 4529 | run_ndc(dut, "ndc softap stopap"); |
| 4530 | run_ndc(dut, "ndc softap startap"); |
| 4531 | num_tries++; |
| 4532 | } |
| 4533 | |
| 4534 | if (num_tries == 10) { |
| 4535 | sigma_dut_print(dut, DUT_MSG_INFO, "Tried 10 times with ctrl " |
| 4536 | "iface %s :: reboot the APDUT", buf); |
| 4537 | return ret; |
| 4538 | } |
| 4539 | |
| 4540 | sigma_dut_print(dut, DUT_MSG_INFO, "setting ip addr %s mask %s", |
| 4541 | ap_inet_addr, ap_inet_mask); |
| 4542 | snprintf(buf, sizeof(buf), "ifconfig %s %s netmask %s up", |
Jouni Malinen | 5ea3092 | 2019-11-04 17:39:25 +0200 | [diff] [blame] | 4543 | get_main_ifname(dut), ap_inet_addr, ap_inet_mask); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4544 | if (system(buf) != 0) { |
| 4545 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4546 | "Failed to intialize the interface"); |
| 4547 | return -1; |
| 4548 | } |
| 4549 | |
| 4550 | return 1; |
| 4551 | } |
| 4552 | |
| 4553 | |
| 4554 | static int append_hostapd_conf_hs2(struct sigma_dut *dut, FILE *f) |
| 4555 | { |
| 4556 | fprintf(f, "hs20=1\nhs20_deauth_req_timeout=3\n" |
| 4557 | "disable_dgaf=%d\n", dut->ap_dgaf_disable); |
| 4558 | |
| 4559 | if (dut->ap_oper_name) { |
| 4560 | fprintf(f, "hs20_oper_friendly_name=eng:Wi-Fi Alliance\n"); |
| 4561 | fprintf(f, "hs20_oper_friendly_name=chi:Wi-Fi\xe8\x81\x94\xe7\x9b\x9f\n"); |
| 4562 | } |
| 4563 | |
| 4564 | if (dut->ap_wan_metrics == 1) |
| 4565 | fprintf(f, "hs20_wan_metrics=01:2500:384:0:0:10\n"); |
| 4566 | else if (dut->ap_wan_metrics == 2) |
| 4567 | fprintf(f, "hs20_wan_metrics=01:1500:384:20:20:10\n"); |
| 4568 | else if (dut->ap_wan_metrics == 3) |
| 4569 | fprintf(f, "hs20_wan_metrics=01:2000:1000:20:20:10\n"); |
| 4570 | else if (dut->ap_wan_metrics == 4) |
| 4571 | fprintf(f, "hs20_wan_metrics=01:8000:1000:20:20:10\n"); |
| 4572 | else if (dut->ap_wan_metrics == 5) |
| 4573 | fprintf(f, "hs20_wan_metrics=01:9000:5000:20:20:10\n"); |
| 4574 | |
| 4575 | if (dut->ap_conn_capab == 1) { |
| 4576 | fprintf(f, "hs20_conn_capab=1:0:0\n"); |
| 4577 | fprintf(f, "hs20_conn_capab=6:20:1\n"); |
| 4578 | fprintf(f, "hs20_conn_capab=6:22:0\n"); |
| 4579 | fprintf(f, "hs20_conn_capab=6:80:1\n"); |
| 4580 | fprintf(f, "hs20_conn_capab=6:443:1\n"); |
| 4581 | fprintf(f, "hs20_conn_capab=6:1723:0\n"); |
| 4582 | fprintf(f, "hs20_conn_capab=6:5060:0\n"); |
| 4583 | fprintf(f, "hs20_conn_capab=17:500:1\n"); |
| 4584 | fprintf(f, "hs20_conn_capab=17:5060:0\n"); |
| 4585 | fprintf(f, "hs20_conn_capab=17:4500:1\n"); |
| 4586 | fprintf(f, "hs20_conn_capab=50:0:1\n"); |
| 4587 | } else if (dut->ap_conn_capab == 2) { |
| 4588 | fprintf(f, "hs20_conn_capab=6:80:1\n"); |
| 4589 | fprintf(f, "hs20_conn_capab=6:443:1\n"); |
| 4590 | fprintf(f, "hs20_conn_capab=17:5060:1\n"); |
| 4591 | fprintf(f, "hs20_conn_capab=6:5060:1\n"); |
| 4592 | } else if (dut->ap_conn_capab == 3) { |
| 4593 | fprintf(f, "hs20_conn_capab=6:80:1\n"); |
| 4594 | fprintf(f, "hs20_conn_capab=6:443:1\n"); |
| 4595 | } else if (dut->ap_conn_capab == 4) { |
| 4596 | fprintf(f, "hs20_conn_capab=6:80:1\n"); |
| 4597 | fprintf(f, "hs20_conn_capab=6:443:1\n"); |
| 4598 | fprintf(f, "hs20_conn_capab=6:5060:1\n"); |
| 4599 | fprintf(f, "hs20_conn_capab=17:5060:1\n"); |
| 4600 | } |
| 4601 | |
| 4602 | if (dut->ap_oper_class == 1) |
| 4603 | fprintf(f, "hs20_operating_class=51\n"); |
| 4604 | else if (dut->ap_oper_class == 2) |
| 4605 | fprintf(f, "hs20_operating_class=73\n"); |
| 4606 | else if (dut->ap_oper_class == 3) |
| 4607 | fprintf(f, "hs20_operating_class=5173\n"); |
| 4608 | |
| 4609 | if (dut->ap_osu_provider_list) { |
| 4610 | char *osu_friendly_name = NULL; |
| 4611 | char *osu_icon = NULL; |
| 4612 | char *osu_ssid = NULL; |
| 4613 | char *osu_nai = NULL; |
Jouni Malinen | 93a837f | 2018-11-01 17:09:22 +0200 | [diff] [blame] | 4614 | char *osu_nai2 = NULL; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4615 | char *osu_service_desc = NULL; |
| 4616 | char *hs20_icon_filename = NULL; |
| 4617 | char hs20_icon[150]; |
| 4618 | int osu_method; |
| 4619 | |
| 4620 | hs20_icon_filename = "icon_red_zxx.png"; |
| 4621 | if (dut->ap_osu_icon_tag == 2) |
| 4622 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 4623 | snprintf(hs20_icon, sizeof(hs20_icon), |
| 4624 | "128:61:zxx:image/png:icon_red_zxx.png:/etc/ath/%s", |
| 4625 | hs20_icon_filename); |
| 4626 | osu_icon = "icon_red_zxx.png"; |
| 4627 | osu_ssid = "OSU"; |
| 4628 | osu_friendly_name = "kor:SP 빨강 테스트 전용"; |
| 4629 | osu_service_desc = "kor:테스트 목적으로 무료 서비스"; |
| 4630 | osu_method = (dut->ap_osu_method[0] == 0xFF) ? 1 : dut->ap_osu_method[0]; |
| 4631 | |
| 4632 | if (strlen(dut->ap_osu_server_uri[0])) |
| 4633 | fprintf(f, "osu_server_uri=%s\n", dut->ap_osu_server_uri[0]); |
| 4634 | else |
| 4635 | fprintf(f, "osu_server_uri=https://osu-server.r2-testbed.wi-fi.org/\n"); |
| 4636 | |
| 4637 | switch (dut->ap_osu_provider_list) { |
| 4638 | case 1: |
| 4639 | case 101: |
| 4640 | fprintf(f, "osu_friendly_name=eng:SP Red Test Only\n"); |
| 4641 | fprintf(f, "osu_service_desc=eng:Free service for test purpose\n"); |
| 4642 | hs20_icon_filename = "icon_red_eng.png"; |
| 4643 | if (dut->ap_osu_icon_tag == 2) |
| 4644 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 4645 | fprintf(f, "hs20_icon=160:76:eng:image/png:icon_red_eng.png:/etc/ath/%s\n", |
| 4646 | hs20_icon_filename); |
| 4647 | fprintf(f, "osu_icon=icon_red_eng.png\n"); |
| 4648 | break; |
| 4649 | case 2: |
| 4650 | case 102: |
| 4651 | fprintf(f, "osu_friendly_name=eng:Wireless Broadband Alliance\n"); |
| 4652 | fprintf(f, "osu_service_desc=eng:Free service for test purpose\n"); |
| 4653 | hs20_icon_filename = "icon_orange_zxx.png"; |
| 4654 | if (dut->ap_osu_icon_tag == 2) |
| 4655 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 4656 | snprintf(hs20_icon, sizeof(hs20_icon), |
| 4657 | "128:61:zxx:image/png:icon_orange_zxx.png:/etc/ath/%s", |
| 4658 | hs20_icon_filename); |
| 4659 | osu_icon = "icon_orange_zxx.png"; |
| 4660 | osu_friendly_name = "kor:와이어리스 브로드밴드 얼라이언스"; |
| 4661 | break; |
| 4662 | case 3: |
| 4663 | case 103: |
| 4664 | osu_friendly_name = "spa:SP Red Test Only"; |
| 4665 | osu_service_desc = "spa:Free service for test purpose"; |
| 4666 | break; |
| 4667 | case 4: |
| 4668 | case 104: |
| 4669 | fprintf(f, "osu_friendly_name=eng:SP Orange Test Only\n"); |
| 4670 | fprintf(f, "osu_service_desc=eng:Free service for test purpose\n"); |
| 4671 | hs20_icon_filename = "icon_orange_eng.png"; |
| 4672 | if (dut->ap_osu_icon_tag == 2) |
| 4673 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 4674 | fprintf(f, "hs20_icon=160:76:eng:image/png:icon_orange_eng.png:/etc/ath/%s\n", |
| 4675 | hs20_icon_filename); |
| 4676 | fprintf(f, "osu_icon=icon_orange_eng.png\n"); |
| 4677 | osu_friendly_name = "kor:SP 오렌지 테스트 전용"; |
| 4678 | |
| 4679 | hs20_icon_filename = "icon_orange_zxx.png"; |
| 4680 | if (dut->ap_osu_icon_tag == 2) |
| 4681 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 4682 | snprintf(hs20_icon, sizeof(hs20_icon), |
| 4683 | "128:61:zxx:image/png:icon_orange_zxx.png:/etc/ath/%s", |
| 4684 | hs20_icon_filename); |
| 4685 | osu_icon = "icon_orange_zxx.png"; |
| 4686 | break; |
| 4687 | case 5: |
| 4688 | case 105: |
| 4689 | fprintf(f, "osu_friendly_name=eng:SP Orange Test Only\n"); |
| 4690 | fprintf(f, "osu_service_desc=eng:Free service for test purpose\n"); |
| 4691 | osu_friendly_name = "kor:SP 오렌지 테스트 전용"; |
| 4692 | hs20_icon_filename = "icon_orange_zxx.png"; |
| 4693 | if (dut->ap_osu_icon_tag == 2) |
| 4694 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 4695 | snprintf(hs20_icon, sizeof(hs20_icon), |
| 4696 | "128:61:zxx:image/png:icon_orange_zxx.png:/etc/ath/%s", |
| 4697 | hs20_icon_filename); |
| 4698 | osu_icon = "icon_orange_zxx.png"; |
| 4699 | break; |
| 4700 | case 6: |
| 4701 | case 106: |
| 4702 | fprintf(f, "osu_friendly_name=eng:SP Green Test Only\n"); |
| 4703 | fprintf(f, "osu_friendly_name=kor:SP 초록 테스트 전용\n"); |
| 4704 | hs20_icon_filename = "icon_green_zxx.png"; |
| 4705 | if (dut->ap_osu_icon_tag == 2) |
| 4706 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 4707 | fprintf(f, "hs20_icon=128:61:zxx:image/png:icon_green_zxx.png:/etc/ath/%s\n", |
| 4708 | hs20_icon_filename); |
| 4709 | fprintf(f, "osu_icon=icon_green_zxx.png\n"); |
| 4710 | osu_method = (dut->ap_osu_method[0] == 0xFF) ? 0 : dut->ap_osu_method[0]; |
| 4711 | fprintf(f, "osu_method_list=%d\n", osu_method); |
| 4712 | |
| 4713 | if (strlen(dut->ap_osu_server_uri[1])) |
| 4714 | fprintf(f, "osu_server_uri=%s\n", dut->ap_osu_server_uri[1]); |
| 4715 | else |
| 4716 | fprintf(f, "osu_server_uri=https://osu-server.r2-testbed.wi-fi.org/\n"); |
| 4717 | fprintf(f, "osu_friendly_name=eng:SP Orange Test Only\n"); |
| 4718 | hs20_icon_filename = "icon_orange_zxx.png"; |
| 4719 | if (dut->ap_osu_icon_tag == 2) |
| 4720 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 4721 | snprintf(hs20_icon, sizeof(hs20_icon), |
| 4722 | "128:61:zxx:image/png:icon_orange_zxx.png:/etc/ath/%s", |
| 4723 | hs20_icon_filename); |
| 4724 | osu_icon = "icon_orange_zxx.png"; |
| 4725 | osu_friendly_name = "kor:SP 오렌지 테스트 전용"; |
| 4726 | osu_method = (dut->ap_osu_method[1] == 0xFF) ? 0 : dut->ap_osu_method[1]; |
| 4727 | osu_service_desc = NULL; |
| 4728 | break; |
| 4729 | case 7: |
| 4730 | case 107: |
| 4731 | fprintf(f, "osu_friendly_name=eng:SP Green Test Only\n"); |
| 4732 | fprintf(f, "osu_service_desc=eng:Free service for test purpose\n"); |
| 4733 | hs20_icon_filename = "icon_green_eng.png"; |
| 4734 | if (dut->ap_osu_icon_tag == 2) |
| 4735 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 4736 | fprintf(f, "hs20_icon=160:76:eng:image/png:icon_green_eng.png:/etc/ath/%s\n", |
| 4737 | hs20_icon_filename); |
| 4738 | fprintf(f, "osu_icon=icon_green_eng.png\n"); |
| 4739 | osu_friendly_name = "kor:SP 초록 테스트 전용"; |
| 4740 | |
| 4741 | hs20_icon_filename = "icon_green_zxx.png"; |
| 4742 | if (dut->ap_osu_icon_tag == 2) |
| 4743 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 4744 | snprintf(hs20_icon, sizeof(hs20_icon), |
| 4745 | "128:61:zxx:image/png:icon_green_zxx.png:/etc/ath/%s", |
| 4746 | hs20_icon_filename); |
| 4747 | osu_icon = "icon_green_zxx.png"; |
| 4748 | break; |
| 4749 | case 8: |
| 4750 | case 108: |
| 4751 | fprintf(f, "osu_friendly_name=eng:SP Red Test Only\n"); |
| 4752 | fprintf(f, "osu_service_desc=eng:Free service for test purpose\n"); |
| 4753 | osu_ssid = "OSU-Encrypted"; |
| 4754 | osu_nai = "anonymous@hotspot.net"; |
| 4755 | break; |
| 4756 | case 9: |
| 4757 | case 109: |
| 4758 | osu_ssid = "OSU-OSEN"; |
| 4759 | osu_nai = "test-anonymous@wi-fi.org"; |
| 4760 | osu_friendly_name = "eng:SP Orange Test Only"; |
| 4761 | hs20_icon_filename = "icon_orange_zxx.png"; |
| 4762 | if (dut->ap_osu_icon_tag == 2) |
| 4763 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 4764 | snprintf(hs20_icon, sizeof(hs20_icon), |
| 4765 | "128:61:zxx:image/png:icon_orange_zxx.png:/etc/ath/%s", |
| 4766 | hs20_icon_filename); |
| 4767 | osu_icon = "icon_orange_zxx.png"; |
| 4768 | osu_method = (dut->ap_osu_method[0] == 0xFF) ? 1 : dut->ap_osu_method[0]; |
| 4769 | osu_service_desc = NULL; |
| 4770 | break; |
Jouni Malinen | 93a837f | 2018-11-01 17:09:22 +0200 | [diff] [blame] | 4771 | case 10: |
| 4772 | case 110: |
| 4773 | /* OSU Provider #1 */ |
| 4774 | fprintf(f, "osu_friendly_name=eng:SP Orange Test Only\n"); |
| 4775 | fprintf(f, "osu_friendly_name=kor:SP 오렌지 테스트 전용\n"); |
| 4776 | fprintf(f, "hs20_icon=128:61:zxx:image/png:icon_orange_zxx.png:/etc/ath/icon_orange_zxx.png\n"); |
| 4777 | fprintf(f, "osu_icon=icon_orange_zxx.png\n"); |
| 4778 | osu_method = (dut->ap_osu_method[0] == 0xFF) ? |
| 4779 | 1 : dut->ap_osu_method[0]; |
| 4780 | fprintf(f, "osu_method_list=%d\n", osu_method); |
| 4781 | fprintf(f, "osu_nai=test-anonymous@wi-fi.org\n"); |
| 4782 | switch (dut->ap_osu_provider_nai_list) { |
| 4783 | case 3: |
| 4784 | fprintf(f, |
| 4785 | "osu_nai2=test-anonymous@wi-fi.org\n"); |
| 4786 | break; |
| 4787 | case 4: |
| 4788 | fprintf(f, "osu_nai2=random@hotspot.net\n"); |
| 4789 | break; |
| 4790 | } |
| 4791 | |
| 4792 | /* OSU Provider #2 */ |
| 4793 | /* SP Red from defaults */ |
| 4794 | if (strlen(dut->ap_osu_server_uri[1])) |
| 4795 | fprintf(f, "osu_server_uri=%s\n", dut->ap_osu_server_uri[1]); |
| 4796 | else |
| 4797 | fprintf(f, "osu_server_uri=https://osu-server.r2-testbed.wi-fi.org/\n"); |
| 4798 | fprintf(f, "osu_friendly_name=eng:SP Red Test Only\n"); |
| 4799 | snprintf(hs20_icon, sizeof(hs20_icon), |
| 4800 | "128:61:zxx:image/png:icon_red_zxx.png:/etc/ath/icon_red_zxx.png"); |
| 4801 | osu_method = (dut->ap_osu_method[1] == 0xFF) ? |
| 4802 | 1 : dut->ap_osu_method[1]; |
| 4803 | osu_service_desc = NULL; |
| 4804 | osu_nai = "anonymous@hotspot.net"; |
| 4805 | break; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4806 | default: |
| 4807 | break; |
| 4808 | } |
| 4809 | |
Jouni Malinen | 93a837f | 2018-11-01 17:09:22 +0200 | [diff] [blame] | 4810 | switch (dut->ap_osu_provider_nai_list) { |
| 4811 | case 1: |
| 4812 | osu_nai2 = "anonymous@hotspot.net"; |
| 4813 | break; |
| 4814 | case 2: |
| 4815 | osu_nai2 = "test-anonymous@wi-fi.org"; |
| 4816 | break; |
| 4817 | case 3: |
| 4818 | /* OSU Provider NAI #1 written above */ |
| 4819 | /* OSU Provider NAI #2 */ |
| 4820 | osu_nai2 = "anonymous@hotspot.net"; |
| 4821 | break; |
| 4822 | case 4: |
| 4823 | /* OSU Provider NAI #1 written above */ |
| 4824 | /* OSU Provider NAI #2 */ |
| 4825 | osu_nai2 = "anonymous@hotspot.net"; |
| 4826 | break; |
| 4827 | } |
| 4828 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4829 | if (strlen(dut->ap_osu_ssid)) { |
Jouni Malinen | e6ac6a0 | 2018-09-11 02:40:17 +0300 | [diff] [blame] | 4830 | if (dut->ap_tag_ssid[0][0] && |
| 4831 | strcmp(dut->ap_tag_ssid[0], dut->ap_osu_ssid) && |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 4832 | strcmp(dut->ap_tag_ssid[0], osu_ssid)) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4833 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4834 | "OSU_SSID and " |
| 4835 | "WLAN_TAG2 SSID differ"); |
| 4836 | return -2; |
| 4837 | } |
| 4838 | fprintf(f, "osu_ssid=\"%s\"\n", dut->ap_osu_ssid); |
| 4839 | } else |
| 4840 | fprintf(f, "osu_ssid=\"%s\"\n", osu_ssid); |
| 4841 | |
| 4842 | |
| 4843 | if (osu_friendly_name) |
| 4844 | fprintf(f, "osu_friendly_name=%s\n", osu_friendly_name); |
| 4845 | |
| 4846 | if (osu_service_desc) |
| 4847 | fprintf(f, "osu_service_desc=%s\n", osu_service_desc); |
| 4848 | |
| 4849 | if (osu_nai) |
| 4850 | fprintf(f, "osu_nai=%s\n", osu_nai); |
Jouni Malinen | 93a837f | 2018-11-01 17:09:22 +0200 | [diff] [blame] | 4851 | if (osu_nai2) |
| 4852 | fprintf(f, "osu_nai2=%s\n", osu_nai2); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4853 | |
| 4854 | fprintf(f, "hs20_icon=%s\n", hs20_icon); |
| 4855 | |
| 4856 | if (osu_icon) |
| 4857 | fprintf(f, "osu_icon=%s\n", osu_icon); |
| 4858 | |
| 4859 | if (dut->ap_osu_provider_list > 100) |
| 4860 | fprintf(f, "osu_method_list=0\n"); |
| 4861 | else |
| 4862 | fprintf(f, "osu_method_list=%d\n", osu_method); |
| 4863 | } |
| 4864 | |
Jouni Malinen | 54a89b0 | 2018-05-01 00:16:26 +0300 | [diff] [blame] | 4865 | switch (dut->ap_venue_url) { |
| 4866 | case 1: |
| 4867 | fprintf(f, |
| 4868 | "venue_url=1:https://venue-server.r2m-testbed.wi-fi.org/floorplans/index.html\n" |
| 4869 | "venue_url=1:https://venue-server.r2m-testbed.wi-fi.org/directory/index.html\n"); |
| 4870 | break; |
| 4871 | case 2: |
| 4872 | fprintf(f, |
| 4873 | "venue_url=1:https://the-great-mall.r2m-testbed.wi-fi.org/floorplans/index.html\n" |
| 4874 | "venue_url=2:https://abercrombie.r2m-testbed.wi-fi.org/floorplans/index.html\n" |
| 4875 | "venue_url=3:https://adidas.r2m-testbed.wi-fi.org/floorplans/index.html\n" |
| 4876 | "venue_url=4:https://aeropostale.r2m-testbed.wi-fi.org/floorplans/index.html\n" |
| 4877 | "venue_url=5:https://agaci.r2m-testbed.wi-fi.org/floorplans/index.html\n" |
| 4878 | "venue_url=6:https://aldo-shoes.r2m-testbed.wi-fi.org/floorplans/index.html\n" |
| 4879 | "venue_url=7:https://american-eagle-outfitters.r2m-testbed.wi-fi.org/floorplans/index.html\n" |
| 4880 | "venue_url=8:https://anderson-bakery.r2m-testbed.wi-fi.org/floorplans/index.html\n" |
| 4881 | "venue_url=9:https://banana-republic-factory-store.r2m-testbed.wi-fi.org/floorplans/index.html\n" |
| 4882 | "venue_url=10:https://bed-bath-and-beyond.r2m-testbed.wi-fi.org/floorplans/index.html\n" |
| 4883 | ); |
| 4884 | break; |
| 4885 | } |
| 4886 | |
Jouni Malinen | f7ff42b | 2018-05-01 00:21:56 +0300 | [diff] [blame] | 4887 | switch (dut->ap_advice_of_charge) { |
| 4888 | case 1: |
| 4889 | fprintf(f, "anqp_elem=278:" ADV_OF_CHARGE_1 "\n"); |
| 4890 | break; |
| 4891 | } |
| 4892 | |
Jouni Malinen | ac10453 | 2018-05-01 00:27:37 +0300 | [diff] [blame] | 4893 | switch (dut->ap_oper_icon_metadata) { |
| 4894 | case 1: |
| 4895 | fprintf(f, |
| 4896 | "hs20_icon=160:76:eng:image/png:icon_red_eng.png:/etc/ath/icon_red_eng.png\n" |
| 4897 | "operator_icon=icon_red_eng.png\n"); |
| 4898 | break; |
| 4899 | } |
| 4900 | |
Jouni Malinen | ac36714 | 2018-05-01 00:32:24 +0300 | [diff] [blame] | 4901 | switch (dut->ap_tnc_file_name) { |
| 4902 | case 1: |
| 4903 | fprintf(f, "hs20_t_c_filename=tandc-id1-content.txt\n"); |
| 4904 | break; |
| 4905 | } |
| 4906 | |
| 4907 | if (dut->ap_tnc_time_stamp) |
| 4908 | fprintf(f, "hs20_t_c_timestamp=%u\n", dut->ap_tnc_time_stamp); |
| 4909 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4910 | return 0; |
| 4911 | } |
| 4912 | |
| 4913 | |
| 4914 | static void write_ap_roaming_cons(FILE *f, const char *list) |
| 4915 | { |
| 4916 | char *buf, *pos, *end; |
| 4917 | |
| 4918 | if (list == NULL || list[0] == '\0') |
| 4919 | return; |
| 4920 | |
| 4921 | buf = strdup(list); |
| 4922 | if (buf == NULL) |
| 4923 | return; |
| 4924 | |
| 4925 | pos = buf; |
| 4926 | while (pos && *pos) { |
| 4927 | end = strchr(pos, ';'); |
| 4928 | if (end) |
| 4929 | *end++ = '\0'; |
| 4930 | fprintf(f, "roaming_consortium=%s\n", pos); |
| 4931 | pos = end; |
| 4932 | } |
| 4933 | |
| 4934 | free(buf); |
| 4935 | } |
| 4936 | |
| 4937 | |
| 4938 | static int append_hostapd_conf_interworking(struct sigma_dut *dut, FILE *f) |
| 4939 | { |
| 4940 | int i; |
| 4941 | char buf[100], *temp; |
| 4942 | |
| 4943 | if (dut->ap_gas_cb_delay > 0) |
| 4944 | fprintf(f, "gas_comeback_delay=%d\n", |
| 4945 | dut->ap_gas_cb_delay); |
| 4946 | |
| 4947 | fprintf(f, "interworking=1\n" |
| 4948 | "access_network_type=%d\n" |
| 4949 | "internet=%d\n" |
| 4950 | "asra=0\n" |
| 4951 | "esr=0\n" |
| 4952 | "uesa=0\n" |
| 4953 | "venue_group=%d\n" |
| 4954 | "venue_type=%d\n", |
| 4955 | dut->ap_access_net_type, |
| 4956 | dut->ap_internet, |
| 4957 | dut->ap_venue_group, |
| 4958 | dut->ap_venue_type); |
| 4959 | if (dut->ap_hessid[0]) |
| 4960 | fprintf(f, "hessid=%s\n", dut->ap_hessid); |
| 4961 | |
| 4962 | write_ap_roaming_cons(f, dut->ap_roaming_cons); |
| 4963 | |
| 4964 | if (dut->ap_venue_name) { |
| 4965 | fprintf(f, "venue_name=P\"eng:Wi-Fi Alliance\\n2989 Copper Road\\nSanta Clara, CA 95051, USA\"\n"); |
| 4966 | fprintf(f, "venue_name=%s\n", ANQP_VENUE_NAME_1_CHI); |
| 4967 | } |
| 4968 | |
| 4969 | if (dut->ap_net_auth_type == 1) |
| 4970 | fprintf(f, "network_auth_type=00https://tandc-server.wi-fi.org\n"); |
| 4971 | else if (dut->ap_net_auth_type == 2) |
| 4972 | fprintf(f, "network_auth_type=01\n"); |
| 4973 | |
| 4974 | if (dut->ap_nai_realm_list == 1) { |
| 4975 | fprintf(f, "nai_realm=0,mail.example.com;cisco.com;wi-fi.org,21[2:4][5:7]\n"); |
| 4976 | fprintf(f, "nai_realm=0,wi-fi.org;example.com,13[5:6]\n"); |
| 4977 | } else if (dut->ap_nai_realm_list == 2) { |
| 4978 | fprintf(f, "nai_realm=0,wi-fi.org,21[2:4][5:7]\n"); |
| 4979 | } else if (dut->ap_nai_realm_list == 3) { |
| 4980 | fprintf(f, "nai_realm=0,cisco.com;wi-fi.org,21[2:4][5:7]\n"); |
| 4981 | fprintf(f, "nai_realm=0,wi-fi.org;example.com,13[5:6]\n"); |
| 4982 | } else if (dut->ap_nai_realm_list == 4) { |
| 4983 | fprintf(f, "nai_realm=0,mail.example.com,21[2:4][5:7],13[5:6]\n"); |
| 4984 | } else if (dut->ap_nai_realm_list == 5) { |
| 4985 | fprintf(f, "nai_realm=0,wi-fi.org;ruckuswireless.com,21[2:4][5:7]\n"); |
| 4986 | } else if (dut->ap_nai_realm_list == 6) { |
| 4987 | fprintf(f, "nai_realm=0,wi-fi.org;mail.example.com,21[2:4][5:7]\n"); |
| 4988 | } else if (dut->ap_nai_realm_list == 7) { |
| 4989 | fprintf(f, "nai_realm=0,wi-fi.org,13[5:6]\n"); |
| 4990 | fprintf(f, "nai_realm=0,wi-fi.org,21[2:4][5:7]\n"); |
| 4991 | } |
| 4992 | |
| 4993 | if (dut->ap_domain_name_list[0]) { |
| 4994 | fprintf(f, "domain_name=%s\n", |
| 4995 | dut->ap_domain_name_list); |
| 4996 | } |
| 4997 | |
| 4998 | if (dut->ap_ip_addr_type_avail == 1) { |
| 4999 | fprintf(f, "ipaddr_type_availability=0c\n"); |
| 5000 | } |
| 5001 | |
| 5002 | temp = buf; |
| 5003 | for (i = 0; dut->ap_plmn_mcc[i][0] && dut->ap_plmn_mnc[i][0]; |
| 5004 | i++) { |
| 5005 | if (i) |
| 5006 | *temp++ = ';'; |
| 5007 | |
| 5008 | snprintf(temp, |
| 5009 | sizeof(dut->ap_plmn_mcc[i]) + |
| 5010 | sizeof(dut->ap_plmn_mnc[i]) + 1, |
| 5011 | "%s,%s", |
| 5012 | dut->ap_plmn_mcc[i], |
| 5013 | dut->ap_plmn_mnc[i]); |
| 5014 | |
| 5015 | temp += strlen(dut->ap_plmn_mcc[i]) + |
| 5016 | strlen(dut->ap_plmn_mnc[i]) + 1; |
| 5017 | } |
| 5018 | if (i) |
| 5019 | fprintf(f, "anqp_3gpp_cell_net=%s\n", buf); |
| 5020 | |
| 5021 | if (dut->ap_qos_map_set == 1) |
| 5022 | fprintf(f, "qos_map_set=%s\n", QOS_MAP_SET_1); |
| 5023 | else if (dut->ap_qos_map_set == 2) |
| 5024 | fprintf(f, "qos_map_set=%s\n", QOS_MAP_SET_2); |
| 5025 | |
| 5026 | return 0; |
| 5027 | } |
| 5028 | |
| 5029 | |
| 5030 | static int ath_ap_append_hostapd_conf(struct sigma_dut *dut) |
| 5031 | { |
| 5032 | FILE *f; |
| 5033 | |
| 5034 | if (kill_process(dut, "(hostapd)", 1, SIGTERM) == 0 || |
| 5035 | system("killall hostapd") == 0) { |
| 5036 | int i; |
| 5037 | |
| 5038 | /* Wait some time to allow hostapd to complete cleanup before |
| 5039 | * starting a new process */ |
| 5040 | for (i = 0; i < 10; i++) { |
| 5041 | usleep(500000); |
| 5042 | if (system("pidof hostapd") != 0) |
| 5043 | break; |
| 5044 | } |
| 5045 | } |
| 5046 | |
| 5047 | f = fopen("/tmp/secath0", "a"); |
| 5048 | if (f == NULL) |
| 5049 | return -2; |
| 5050 | |
| 5051 | if (dut->ap_hs2 && append_hostapd_conf_hs2(dut, f)) { |
| 5052 | fclose(f); |
| 5053 | return -2; |
| 5054 | } |
| 5055 | |
| 5056 | if (dut->ap_interworking && append_hostapd_conf_interworking(dut, f)) { |
| 5057 | fclose(f); |
| 5058 | return -2; |
| 5059 | } |
| 5060 | |
| 5061 | fflush(f); |
| 5062 | fclose(f); |
| 5063 | return ath_ap_start_hostapd(dut); |
| 5064 | } |
| 5065 | |
| 5066 | |
| 5067 | static int ath_ap_start_hostapd(struct sigma_dut *dut) |
| 5068 | { |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 5069 | if (dut->ap_tag_key_mgmt[0] == AP2_OSEN) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5070 | run_system(dut, "hostapd -B /tmp/secath0 /tmp/secath1 -e /etc/wpa2/entropy"); |
| 5071 | else |
| 5072 | run_system(dut, "hostapd -B /tmp/secath0 -e /etc/wpa2/entropy"); |
| 5073 | |
| 5074 | return 0; |
| 5075 | } |
| 5076 | |
| 5077 | |
| 5078 | #define LE16(a) ((((a) & 0xff) << 8) | (((a) >> 8) & 0xff)) |
| 5079 | |
| 5080 | static int cmd_ath_ap_anqpserver_start(struct sigma_dut *dut) |
| 5081 | { |
| 5082 | FILE *f; |
| 5083 | int nai_realm = 0, domain_name = 0, oper_name = 0, venue_name = 0, |
| 5084 | wan_metrics = 0, conn_cap = 0, ipaddr_avail = 0, cell_net = 0; |
| 5085 | char buf[100]; |
| 5086 | int i; |
| 5087 | |
| 5088 | f = fopen("/root/anqpserver.conf", "w"); |
| 5089 | if (f == NULL) |
| 5090 | return -1; |
| 5091 | |
| 5092 | if (dut->ap_nai_realm_list == 1) { |
| 5093 | nai_realm = 1; |
| 5094 | 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"); |
| 5095 | } else if (dut->ap_nai_realm_list == 2) { |
| 5096 | nai_realm = 1; |
| 5097 | fprintf(f, "dyn_nai_home_realm=encoding=00realm=wi-fi.org;eap_method=0Dauth_id=05auth_val=06\n"); |
| 5098 | } else if (dut->ap_nai_realm_list == 3) { |
| 5099 | nai_realm = 1; |
| 5100 | 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"); |
| 5101 | } else if (dut->ap_nai_realm_list == 4) { |
| 5102 | nai_realm = 1; |
| 5103 | 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"); |
| 5104 | } else |
| 5105 | sigma_dut_print(dut, DUT_MSG_INFO, "not setting nai_realm"); |
| 5106 | |
| 5107 | if (dut->ap_domain_name_list[0]) { |
| 5108 | char *next, *start, *dnbuf, *dn1, *anqp_dn; |
| 5109 | int len, dn_len_max; |
| 5110 | dnbuf = strdup(dut->ap_domain_name_list); |
Pradeep Reddy POTTETI | 673d85c | 2016-07-26 19:08:07 +0530 | [diff] [blame] | 5111 | if (dnbuf == NULL) { |
| 5112 | fclose(f); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5113 | return 0; |
Pradeep Reddy POTTETI | 673d85c | 2016-07-26 19:08:07 +0530 | [diff] [blame] | 5114 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5115 | |
| 5116 | len = strlen(dnbuf); |
| 5117 | dn_len_max = 50 + len*2; |
| 5118 | anqp_dn = malloc(dn_len_max); |
| 5119 | if (anqp_dn == NULL) { |
| 5120 | free(dnbuf); |
Pradeep Reddy POTTETI | 673d85c | 2016-07-26 19:08:07 +0530 | [diff] [blame] | 5121 | fclose(f); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5122 | return -1; |
| 5123 | } |
| 5124 | start = dnbuf; |
| 5125 | dn1 = anqp_dn; |
| 5126 | while (start && *start) { |
| 5127 | char *hexstr; |
| 5128 | |
| 5129 | next = strchr(start, ','); |
| 5130 | if (next) |
| 5131 | *next++ = '\0'; |
| 5132 | |
| 5133 | len = strlen(start); |
vamsi krishna | 2e88130 | 2016-05-25 15:02:39 +0530 | [diff] [blame] | 5134 | hexstr = malloc(len * 2 + 1); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5135 | if (hexstr == NULL) { |
| 5136 | free(dnbuf); |
| 5137 | free(anqp_dn); |
Pradeep Reddy POTTETI | 673d85c | 2016-07-26 19:08:07 +0530 | [diff] [blame] | 5138 | fclose(f); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5139 | return -1; |
| 5140 | } |
| 5141 | ascii2hexstr(start, hexstr); |
| 5142 | snprintf(dn1, dn_len_max, "%02x%s", len, hexstr); |
| 5143 | free(hexstr); |
| 5144 | dn1 += 2 + len * 2; |
| 5145 | dn_len_max -= 2 + len * 2; |
| 5146 | start = next; |
| 5147 | } |
| 5148 | free(dnbuf); |
| 5149 | if (dut->ap_gas_cb_delay) { |
| 5150 | fprintf(f, "dyn_domain_name=0c01%04x%s", |
| 5151 | LE16((unsigned int) strlen(anqp_dn)), anqp_dn); |
| 5152 | domain_name = 1; |
| 5153 | } else |
| 5154 | fprintf(f, "domain_name=0c01%04x%s", |
| 5155 | LE16((unsigned int) strlen(anqp_dn)), anqp_dn); |
| 5156 | free(anqp_dn); |
| 5157 | } else |
| 5158 | sigma_dut_print(dut, DUT_MSG_INFO, "not setting domain_name"); |
| 5159 | |
| 5160 | sigma_dut_print(dut, DUT_MSG_INFO, "not setting roaming_consortium"); |
| 5161 | |
| 5162 | if (dut->ap_oper_name) { |
| 5163 | if (dut->ap_gas_cb_delay) { |
| 5164 | fprintf(f, "dyn_oper_friendly_name=" |
| 5165 | ANQP_HS20_OPERATOR_FRIENDLY_NAME_1 "\n"); |
| 5166 | oper_name = 1; |
| 5167 | } else |
| 5168 | fprintf(f, "oper_friendly_name=" |
| 5169 | ANQP_HS20_OPERATOR_FRIENDLY_NAME_1 "\n"); |
| 5170 | } else |
| 5171 | sigma_dut_print(dut, DUT_MSG_INFO, "not setting oper_name"); |
| 5172 | |
| 5173 | if (dut->ap_venue_name) { |
| 5174 | if (dut->ap_gas_cb_delay) { |
| 5175 | fprintf(f, "dyn_venue_name=" ANQP_VENUE_NAME_1 "\n"); |
| 5176 | venue_name = 1; |
| 5177 | } else |
| 5178 | fprintf(f, "venue_name=" ANQP_VENUE_NAME_1 "\n"); |
| 5179 | } else |
| 5180 | sigma_dut_print(dut, DUT_MSG_ERROR, "not setting venue_name"); |
| 5181 | |
| 5182 | if (dut->ap_wan_metrics) { |
| 5183 | if (dut->ap_gas_cb_delay) { |
| 5184 | fprintf(f, "dyn_wan_metrics=" ANQP_HS20_WAN_METRICS_1 "\n"); |
| 5185 | wan_metrics = 1; |
| 5186 | } else |
| 5187 | fprintf(f, "wan_metrics=" ANQP_HS20_WAN_METRICS_1 |
| 5188 | "\n"); |
| 5189 | } else |
| 5190 | sigma_dut_print(dut, DUT_MSG_ERROR, "not setting wan_metrics"); |
| 5191 | |
| 5192 | if (dut->ap_conn_capab) { |
| 5193 | if (dut->ap_gas_cb_delay) { |
| 5194 | fprintf(f, "dyn_conn_capability=" |
| 5195 | ANQP_HS20_CONNECTION_CAPABILITY_1 "\n"); |
| 5196 | conn_cap = 1; |
| 5197 | } else |
| 5198 | fprintf(f, "conn_capability=" |
| 5199 | ANQP_HS20_CONNECTION_CAPABILITY_1 "\n"); |
| 5200 | } else |
| 5201 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5202 | "not setting conn_capability"); |
| 5203 | |
| 5204 | if (dut->ap_ip_addr_type_avail) { |
| 5205 | if (dut->ap_gas_cb_delay) { |
| 5206 | fprintf(f, "dyn_ipaddr_type=" ANQP_IP_ADDR_TYPE_1 |
| 5207 | "\n"); |
| 5208 | ipaddr_avail = 1; |
| 5209 | } else |
| 5210 | fprintf(f, "ipaddr_type=" ANQP_IP_ADDR_TYPE_1 "\n"); |
| 5211 | } else |
| 5212 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5213 | "not setting ipaddr_type_avail"); |
| 5214 | |
| 5215 | for (i = 0; dut->ap_plmn_mcc[i][0] && dut->ap_plmn_mnc[i][0]; i++) { |
| 5216 | snprintf(buf + i * 6, sizeof(buf) - i * 6, "%c%c%c%c%c%c", |
| 5217 | dut->ap_plmn_mcc[i][1], |
| 5218 | dut->ap_plmn_mcc[i][0], |
| 5219 | dut->ap_plmn_mnc[i][2] == '\0' ? |
| 5220 | 'f' : dut->ap_plmn_mnc[i][2], |
| 5221 | dut->ap_plmn_mcc[i][2], |
| 5222 | dut->ap_plmn_mnc[i][1], |
| 5223 | dut->ap_plmn_mnc[i][0]); |
| 5224 | } |
| 5225 | if (i) { |
| 5226 | uint16_t ie_len = (i * 3) + 5; |
| 5227 | if (dut->ap_gas_cb_delay) { |
| 5228 | fprintf(f, "dyn_cell_net=0801"); |
| 5229 | cell_net = 1; |
| 5230 | } else |
| 5231 | fprintf(f, "cell_net=0801"); |
| 5232 | fprintf(f, "%04x", LE16(ie_len)); |
| 5233 | fprintf(f, "00"); /* version */ |
| 5234 | fprintf(f, "%02x", (i * 3) + 3); /* user data hdr length */ |
| 5235 | fprintf(f, "00"); /* plmn list */ |
| 5236 | fprintf(f, "%02x", (i * 3) + 1); /* length of plmn list */ |
| 5237 | fprintf(f, "%02x", i); /* number of plmns */ |
| 5238 | fprintf(f, "%s\n", buf); /* plmns */ |
| 5239 | } else |
| 5240 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5241 | "not setting 3gpp_cellular_network"); |
| 5242 | |
| 5243 | if (nai_realm || domain_name || oper_name || venue_name || |
| 5244 | wan_metrics || conn_cap || ipaddr_avail || cell_net) { |
| 5245 | fprintf(f, "anqp_attach="); |
| 5246 | if (venue_name) |
| 5247 | fprintf(f, "00000104%4.4x", dut->ap_gas_cb_delay); |
| 5248 | if (nai_realm) |
| 5249 | fprintf(f, "00000107%4.4x", dut->ap_gas_cb_delay); |
| 5250 | if (cell_net) |
| 5251 | fprintf(f, "00000108%4.4x", dut->ap_gas_cb_delay); |
| 5252 | if (domain_name) |
| 5253 | fprintf(f, "0000010c%4.4x", dut->ap_gas_cb_delay); |
| 5254 | if (oper_name) |
| 5255 | fprintf(f, "00010003%4.4x", dut->ap_gas_cb_delay); |
| 5256 | if (wan_metrics) |
| 5257 | fprintf(f, "00010004%4.4x", dut->ap_gas_cb_delay); |
| 5258 | if (conn_cap) |
| 5259 | fprintf(f, "00010005%4.4x", dut->ap_gas_cb_delay); |
| 5260 | fprintf(f, "00010006%4.4x", dut->ap_gas_cb_delay); |
| 5261 | fprintf(f, "\n"); |
| 5262 | } |
| 5263 | |
| 5264 | fclose(f); |
| 5265 | |
| 5266 | run_system(dut, "anqpserver -i ath0 &"); |
| 5267 | if (!dut->ap_anqpserver_on) |
| 5268 | run_system(dut, "killall anqpserver"); |
| 5269 | |
| 5270 | return 1; |
| 5271 | } |
| 5272 | |
| 5273 | |
| 5274 | static void cmd_ath_ap_radio_config(struct sigma_dut *dut) |
| 5275 | { |
| 5276 | char buf[100]; |
| 5277 | |
| 5278 | run_system(dut, "cfg -a AP_STARTMODE=standard"); |
| 5279 | |
| 5280 | if (sigma_radio_ifname[0] && |
| 5281 | strcmp(sigma_radio_ifname[0], "wifi1") == 0) { |
| 5282 | run_system(dut, "cfg -a AP_RADIO_ID=1"); |
| 5283 | switch (dut->ap_mode) { |
| 5284 | case AP_11g: |
| 5285 | run_system(dut, "cfg -a AP_CHMODE_2=11G"); |
| 5286 | break; |
| 5287 | case AP_11b: |
| 5288 | run_system(dut, "cfg -a AP_CHMODE_2=11B"); |
| 5289 | break; |
| 5290 | case AP_11ng: |
| 5291 | run_system(dut, "cfg -a AP_CHMODE_2=11NGHT20"); |
| 5292 | break; |
| 5293 | case AP_11a: |
| 5294 | run_system(dut, "cfg -a AP_CHMODE_2=11A"); |
| 5295 | break; |
| 5296 | case AP_11na: |
| 5297 | run_system(dut, "cfg -a AP_CHMODE_2=11NAHT20"); |
| 5298 | break; |
| 5299 | case AP_11ac: |
| 5300 | run_system(dut, "cfg -a AP_CHMODE_2=11ACVHT80"); |
| 5301 | break; |
| 5302 | default: |
| 5303 | run_system(dut, "cfg -a AP_CHMODE_2=11ACVHT80"); |
| 5304 | break; |
| 5305 | } |
| 5306 | |
| 5307 | switch (dut->ap_rx_streams) { |
| 5308 | case 1: |
| 5309 | run_system(dut, "cfg -a RX_CHAINMASK_2=1"); |
| 5310 | break; |
| 5311 | case 2: |
| 5312 | run_system(dut, "cfg -a RX_CHAINMASK_2=3"); |
| 5313 | break; |
| 5314 | case 3: |
| 5315 | run_system(dut, "cfg -a RX_CHAINMASK_2=7"); |
| 5316 | break; |
| 5317 | } |
| 5318 | |
| 5319 | switch (dut->ap_tx_streams) { |
| 5320 | case 1: |
| 5321 | run_system(dut, "cfg -a TX_CHAINMASK_2=1"); |
| 5322 | break; |
| 5323 | case 2: |
| 5324 | run_system(dut, "cfg -a TX_CHAINMASK_2=3"); |
| 5325 | break; |
| 5326 | case 3: |
| 5327 | run_system(dut, "cfg -a TX_CHAINMASK_2=7"); |
| 5328 | break; |
| 5329 | } |
| 5330 | |
| 5331 | switch (dut->ap_chwidth) { |
| 5332 | case AP_20: |
| 5333 | run_system(dut, "cfg -a AP_CHMODE_2=11ACVHT20"); |
| 5334 | break; |
| 5335 | case AP_40: |
| 5336 | run_system(dut, "cfg -a AP_CHMODE_2=11ACVHT40"); |
| 5337 | break; |
| 5338 | case AP_80: |
| 5339 | run_system(dut, "cfg -a AP_CHMODE_2=11ACVHT80"); |
| 5340 | break; |
| 5341 | case AP_160: |
| 5342 | case AP_AUTO: |
| 5343 | default: |
| 5344 | run_system(dut, "cfg -a AP_CHMODE_2=11ACVHT80"); |
| 5345 | break; |
| 5346 | } |
| 5347 | |
| 5348 | if (dut->ap_tx_stbc) { |
| 5349 | run_system(dut, "cfg -a TX_STBC_2=1"); |
| 5350 | } |
| 5351 | |
| 5352 | snprintf(buf, sizeof(buf), "cfg -a AP_PRIMARY_CH_2=%d", |
| 5353 | dut->ap_channel); |
| 5354 | |
| 5355 | if (dut->ap_is_dual) { |
| 5356 | switch (dut->ap_mode_1) { |
| 5357 | case AP_11g: |
| 5358 | run_system(dut, "cfg -a AP_CHMODE=11G"); |
| 5359 | break; |
| 5360 | case AP_11b: |
| 5361 | run_system(dut, "cfg -a AP_CHMODE=11B"); |
| 5362 | break; |
| 5363 | case AP_11ng: |
| 5364 | run_system(dut, "cfg -a AP_CHMODE=11NGHT20"); |
| 5365 | break; |
| 5366 | case AP_11a: |
| 5367 | run_system(dut, "cfg -a AP_CHMODE=11A"); |
| 5368 | break; |
| 5369 | case AP_11na: |
| 5370 | run_system(dut, "cfg -a AP_CHMODE=11NAHT20"); |
| 5371 | break; |
| 5372 | case AP_11ac: |
| 5373 | run_system(dut, "cfg -a AP_CHMODE=11ACVHT80"); |
| 5374 | break; |
| 5375 | default: |
| 5376 | run_system(dut, "cfg -a AP_CHMODE=11NGHT20"); |
| 5377 | break; |
| 5378 | } |
| 5379 | snprintf(buf, sizeof(buf), "cfg -a AP_PRIMARY_CH=%d", |
| 5380 | dut->ap_channel_1); |
| 5381 | } |
| 5382 | run_system(dut, buf); |
| 5383 | } else { |
| 5384 | run_system(dut, "cfg -a AP_RADIO_ID=0"); |
| 5385 | switch (dut->ap_mode) { |
| 5386 | case AP_11g: |
| 5387 | run_system(dut, "cfg -a AP_CHMODE=11G"); |
| 5388 | break; |
| 5389 | case AP_11b: |
| 5390 | run_system(dut, "cfg -a AP_CHMODE=11B"); |
| 5391 | break; |
| 5392 | case AP_11ng: |
| 5393 | run_system(dut, "cfg -a AP_CHMODE=11NGHT20"); |
| 5394 | break; |
| 5395 | case AP_11a: |
| 5396 | run_system(dut, "cfg -a AP_CHMODE=11A"); |
| 5397 | break; |
| 5398 | case AP_11na: |
| 5399 | run_system(dut, "cfg -a AP_CHMODE=11NAHT20"); |
| 5400 | break; |
| 5401 | case AP_11ac: |
| 5402 | run_system(dut, "cfg -a AP_CHMODE=11ACVHT80"); |
| 5403 | break; |
| 5404 | default: |
| 5405 | run_system(dut, "cfg -a AP_CHMODE=11NGHT20"); |
| 5406 | break; |
| 5407 | } |
| 5408 | snprintf(buf, sizeof(buf), "cfg -a AP_PRIMARY_CH=%d", |
| 5409 | dut->ap_channel); |
| 5410 | run_system(dut, buf); |
| 5411 | } |
| 5412 | |
| 5413 | if (dut->ap_sgi80 == 1) { |
| 5414 | run_system(dut, "cfg -a SHORTGI=1"); |
| 5415 | run_system(dut, "cfg -a SHORTGI_2=1"); |
| 5416 | } else if (dut->ap_sgi80 == 0) { |
| 5417 | run_system(dut, "cfg -a SHORTGI=0"); |
| 5418 | run_system(dut, "cfg -a SHORTGI_2=0"); |
| 5419 | } |
| 5420 | |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 5421 | if (dut->ap_ldpc == VALUE_ENABLED) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5422 | run_system(dut, "cfg -a LDPC=1"); |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 5423 | else if (dut->ap_ldpc == VALUE_DISABLED) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5424 | run_system(dut, "cfg -a LDPC=0"); |
| 5425 | } |
| 5426 | |
| 5427 | |
| 5428 | void ath_disable_txbf(struct sigma_dut *dut, const char *intf) |
| 5429 | { |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 5430 | run_iwpriv(dut, intf, "vhtsubfee 0"); |
| 5431 | run_iwpriv(dut, intf, "vhtsubfer 0"); |
| 5432 | run_iwpriv(dut, intf, "vhtmubfee 0"); |
| 5433 | run_iwpriv(dut, intf, "vhtmubfer 0"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5434 | } |
| 5435 | |
| 5436 | |
Adil Saeed Musthafa | 05ec744 | 2017-04-10 23:13:35 -0700 | [diff] [blame] | 5437 | static void ath_set_assoc_disallow(struct sigma_dut *dut, const char *ifname, |
| 5438 | const char *val) |
| 5439 | { |
| 5440 | if (strcasecmp(val, "enable") == 0) { |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 5441 | run_iwpriv(dut, ifname, "mbo_asoc_dis 1"); |
Adil Saeed Musthafa | 05ec744 | 2017-04-10 23:13:35 -0700 | [diff] [blame] | 5442 | } else if (strcasecmp(val, "disable") == 0) { |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 5443 | run_iwpriv(dut, ifname, "mbo_asoc_dis 0"); |
Adil Saeed Musthafa | 05ec744 | 2017-04-10 23:13:35 -0700 | [diff] [blame] | 5444 | } else { |
| 5445 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5446 | "Unsupported assoc_disallow"); |
| 5447 | } |
| 5448 | } |
| 5449 | |
| 5450 | |
Adil Saeed Musthafa | 6906372 | 2017-04-10 23:13:40 -0700 | [diff] [blame] | 5451 | static void apply_mbo_pref_ap_list(struct sigma_dut *dut) |
| 5452 | { |
| 5453 | int i; |
| 5454 | int least_pref = 1 << 8; |
| 5455 | char ifname[20]; |
| 5456 | uint8_t self_mac[ETH_ALEN]; |
| 5457 | char buf[200]; |
| 5458 | int ap_ne_class, ap_ne_pref, ap_ne_op_ch; |
| 5459 | |
| 5460 | get_if_name(dut, ifname, sizeof(ifname), 1); |
| 5461 | get_hwaddr(ifname, self_mac); |
| 5462 | |
| 5463 | /* Clear off */ |
| 5464 | snprintf(buf, sizeof(buf), |
| 5465 | "wifitool %s setbssidpref 00:00:00:00:00:00 0 0 0", |
| 5466 | ifname); |
| 5467 | run_system(dut, buf); |
| 5468 | |
| 5469 | /* Find the least preference number */ |
| 5470 | for (i = 0; i < dut->mbo_pref_ap_cnt; i++) { |
| 5471 | unsigned char *mac_addr = dut->mbo_pref_aps[i].mac_addr; |
| 5472 | |
| 5473 | ap_ne_class = 1; |
| 5474 | ap_ne_pref = 255; |
| 5475 | ap_ne_op_ch = 1; |
| 5476 | if (dut->mbo_pref_aps[i].ap_ne_pref != -1) |
| 5477 | ap_ne_pref = dut->mbo_pref_aps[i].ap_ne_pref; |
| 5478 | if (dut->mbo_pref_aps[i].ap_ne_class != -1) |
| 5479 | ap_ne_class = dut->mbo_pref_aps[i].ap_ne_class; |
| 5480 | if (dut->mbo_pref_aps[i].ap_ne_op_ch != -1) |
| 5481 | ap_ne_op_ch = dut->mbo_pref_aps[i].ap_ne_op_ch; |
| 5482 | |
| 5483 | if (ap_ne_pref < least_pref) |
| 5484 | least_pref = ap_ne_pref; |
| 5485 | snprintf(buf, sizeof(buf), |
| 5486 | "wifitool %s setbssidpref %02x:%02x:%02x:%02x:%02x:%02x %d %d %d", |
| 5487 | ifname, mac_addr[0], mac_addr[1], mac_addr[2], |
| 5488 | mac_addr[3], mac_addr[4], mac_addr[5], |
| 5489 | ap_ne_pref, ap_ne_class, ap_ne_op_ch); |
| 5490 | run_system(dut, buf); |
| 5491 | } |
| 5492 | |
| 5493 | /* Now add the self AP Address */ |
| 5494 | if (dut->mbo_self_ap_tuple.ap_ne_class == -1) { |
| 5495 | if (dut->ap_channel <= 11) |
| 5496 | ap_ne_class = 81; |
| 5497 | else |
| 5498 | ap_ne_class = 115; |
| 5499 | } else { |
| 5500 | ap_ne_class = dut->mbo_self_ap_tuple.ap_ne_class; |
| 5501 | } |
| 5502 | |
| 5503 | if (dut->mbo_self_ap_tuple.ap_ne_op_ch == -1) |
| 5504 | ap_ne_op_ch = dut->ap_channel; |
| 5505 | else |
| 5506 | ap_ne_op_ch = dut->mbo_self_ap_tuple.ap_ne_op_ch; |
| 5507 | |
| 5508 | if (dut->mbo_self_ap_tuple.ap_ne_pref == -1) |
| 5509 | ap_ne_pref = least_pref - 1; |
| 5510 | else |
| 5511 | ap_ne_pref = dut->mbo_self_ap_tuple.ap_ne_pref; |
| 5512 | |
| 5513 | snprintf(buf, sizeof(buf), |
| 5514 | "wifitool %s setbssidpref %02x:%02x:%02x:%02x:%02x:%02x %d %d %d", |
| 5515 | ifname, self_mac[0], self_mac[1], self_mac[2], |
| 5516 | self_mac[3], self_mac[4], self_mac[5], |
| 5517 | ap_ne_pref, |
| 5518 | ap_ne_class, |
| 5519 | ap_ne_op_ch); |
| 5520 | run_system(dut, buf); |
| 5521 | } |
| 5522 | |
| 5523 | |
Priyadharshini Gowthaman | 7e43870 | 2019-08-09 12:05:05 -0700 | [diff] [blame] | 5524 | static void mubrp_commands(struct sigma_dut *dut, const char *ifname) |
| 5525 | { |
| 5526 | run_iwpriv(dut, ifname, "he_subfer 1"); |
| 5527 | run_iwpriv(dut, ifname, "he_mubfer 1"); |
| 5528 | /* To enable MU_AX with MU_BRP trigger */ |
| 5529 | run_iwpriv(dut, ifname, "he_sounding_mode 13"); |
| 5530 | /* Sets g_force_1x1_peer to 1 which should be reset to zero for non MU |
| 5531 | * test cases */ |
| 5532 | run_system_wrapper(dut, "wifitool %s setUnitTestCmd 0x48 2 118 1", |
| 5533 | ifname); |
| 5534 | /* Disable DL OFDMA */ |
| 5535 | run_system_wrapper(dut, "wifitool %s setUnitTestCmd 0x47 2 11 0", |
| 5536 | ifname); |
| 5537 | } |
| 5538 | |
| 5539 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5540 | static void ath_ap_set_params(struct sigma_dut *dut) |
| 5541 | { |
priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 5542 | const char *basedev = "wifi0"; |
| 5543 | const char *basedev_radio = "wifi1"; |
Jouni Malinen | 016ae6c | 2019-11-04 17:00:01 +0200 | [diff] [blame] | 5544 | const char *ifname = get_main_ifname(dut); |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 5545 | char *ifname_dual = NULL; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5546 | int i; |
priyadharshini gowthaman | 8e26ff4 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 5547 | char buf[300]; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5548 | |
priyadharshini gowthaman | e161746 | 2017-04-25 12:03:59 -0700 | [diff] [blame] | 5549 | if (sigma_radio_ifname[0]) |
| 5550 | basedev = sigma_radio_ifname[0]; |
| 5551 | |
priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 5552 | if (dut->ap_is_dual == 1) { |
| 5553 | basedev = sigma_radio_ifname[0]; |
| 5554 | basedev_radio = sigma_radio_ifname[1]; |
| 5555 | if (sigma_radio_ifname[0] && |
| 5556 | strcmp(sigma_radio_ifname[0], "wifi0") == 0) { |
| 5557 | ifname = "ath0"; |
| 5558 | ifname_dual = "ath1"; |
| 5559 | } else { |
| 5560 | ifname = "ath1"; |
| 5561 | ifname_dual = "ath0"; |
| 5562 | } |
| 5563 | } |
| 5564 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5565 | if (dut->ap_countrycode[0]) { |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 5566 | run_iwpriv(dut, basedev, "setCountry %s", dut->ap_countrycode); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5567 | sigma_dut_print(dut, DUT_MSG_INFO, "Set countrycode"); |
| 5568 | } |
| 5569 | |
| 5570 | for (i = 0; i < NUM_AP_AC; i++) { |
| 5571 | if (dut->ap_qos[i].ac) { |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 5572 | run_iwpriv(dut, ifname, "cwmin %d 0 %d", i, |
| 5573 | dut->ap_qos[i].cwmin); |
| 5574 | run_iwpriv(dut, ifname, "cwmax %d 0 %d", i, |
| 5575 | dut->ap_qos[i].cwmax); |
| 5576 | run_iwpriv(dut, ifname, "aifs %d 0 %d", i, |
| 5577 | dut->ap_qos[i].aifs); |
| 5578 | run_iwpriv(dut, ifname, "txoplimit %d 0 %d", i, |
| 5579 | dut->ap_qos[i].txop); |
| 5580 | run_iwpriv(dut, ifname, "acm %d 0 %d", i, |
| 5581 | dut->ap_qos[i].acm); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5582 | } |
| 5583 | } |
| 5584 | |
| 5585 | for (i = 0; i < NUM_AP_AC; i++) { |
| 5586 | if (dut->ap_sta_qos[i].ac) { |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 5587 | run_iwpriv(dut, ifname, "cwmin %d 1 %d", i, |
| 5588 | dut->ap_sta_qos[i].cwmin); |
| 5589 | run_iwpriv(dut, ifname, "cwmax %d 1 %d", i, |
| 5590 | dut->ap_sta_qos[i].cwmax); |
| 5591 | run_iwpriv(dut, ifname, "aifs %d 1 %d", i, |
| 5592 | dut->ap_sta_qos[i].aifs); |
| 5593 | run_iwpriv(dut, ifname, "txoplimit %d 1 %d", i, |
| 5594 | dut->ap_sta_qos[i].txop); |
| 5595 | run_iwpriv(dut, ifname, "acm %d 1 %d", i, |
| 5596 | dut->ap_sta_qos[i].acm); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5597 | } |
| 5598 | } |
| 5599 | |
| 5600 | if (dut->ap_disable_protection == 1) { |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 5601 | run_iwpriv(dut, ifname, "enablertscts 0"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5602 | sigma_dut_print(dut, DUT_MSG_INFO, "Disabled rtscts"); |
| 5603 | } |
| 5604 | |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 5605 | if (dut->ap_ldpc == VALUE_ENABLED) |
| 5606 | run_iwpriv(dut, ifname, "ldpc 3"); |
| 5607 | else if (dut->ap_ldpc == VALUE_DISABLED) |
| 5608 | run_iwpriv(dut, ifname, "ldpc 0"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5609 | |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 5610 | if (dut->ap_ampdu == VALUE_ENABLED) |
| 5611 | run_iwpriv(dut, ifname, "ampdu 1"); |
| 5612 | else if (dut->ap_ampdu == VALUE_DISABLED) |
| 5613 | run_iwpriv(dut, ifname, "ampdu 0"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5614 | |
| 5615 | if (dut->ap_ampdu_exp) { |
| 5616 | if (dut->program == PROGRAM_VHT) { |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 5617 | run_iwpriv(dut, ifname, "vhtmaxampdu %d", |
| 5618 | dut->ap_ampdu_exp); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5619 | } else { |
| 5620 | /* 11N */ |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 5621 | run_iwpriv(dut, ifname, "maxampdu %d", |
| 5622 | dut->ap_ampdu_exp); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5623 | } |
| 5624 | } |
| 5625 | |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 5626 | if (dut->ap_noack == VALUE_ENABLED) { |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 5627 | run_iwpriv(dut, ifname, "noackpolicy 0 0 1"); |
| 5628 | run_iwpriv(dut, ifname, "noackpolicy 1 0 1"); |
| 5629 | run_iwpriv(dut, ifname, "noackpolicy 2 0 1"); |
| 5630 | run_iwpriv(dut, ifname, "noackpolicy 3 0 1"); |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 5631 | } else if (dut->ap_noack == VALUE_DISABLED) { |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 5632 | run_iwpriv(dut, ifname, "noackpolicy 0 0 0"); |
| 5633 | run_iwpriv(dut, ifname, "noackpolicy 1 0 0"); |
| 5634 | run_iwpriv(dut, ifname, "noackpolicy 2 0 0"); |
| 5635 | run_iwpriv(dut, ifname, "noackpolicy 3 0 0"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5636 | } |
| 5637 | |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 5638 | if (dut->device_type == AP_testbed && dut->ap_vhtmcs_map) |
| 5639 | run_iwpriv(dut, ifname, "vht_mcsmap 0x%04x", |
| 5640 | dut->ap_vhtmcs_map); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5641 | |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 5642 | if (dut->ap_amsdu == VALUE_ENABLED) |
| 5643 | run_iwpriv(dut, ifname, "amsdu 2"); |
| 5644 | else if (dut->ap_amsdu == VALUE_DISABLED) |
| 5645 | run_iwpriv(dut, ifname, "amsdu 1"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5646 | |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 5647 | if (dut->ap_rx_amsdu == VALUE_ENABLED) |
| 5648 | run_iwpriv(dut, basedev_radio, "rx_amsdu 1"); |
| 5649 | else if (dut->ap_rx_amsdu == VALUE_DISABLED) |
| 5650 | run_iwpriv(dut, basedev_radio, "rx_amsdu 0"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5651 | |
| 5652 | /* Command sequence to generate single VHT AMSDU and MPDU */ |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 5653 | if (dut->ap_addba_reject != VALUE_NOT_SET && |
| 5654 | dut->ap_ampdu == VALUE_DISABLED && |
| 5655 | dut->ap_amsdu == VALUE_ENABLED) { |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 5656 | run_iwpriv(dut, ifname, "setaddbaoper 1"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5657 | |
| 5658 | snprintf(buf, sizeof(buf), |
| 5659 | "wifitool %s senddelba 1 0 1 4", ifname); |
| 5660 | if (system(buf) != 0) { |
| 5661 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5662 | "wifitool senddelba failed"); |
| 5663 | } |
| 5664 | |
| 5665 | snprintf(buf, sizeof(buf), "wifitool %s sendsingleamsdu 1 0", |
| 5666 | ifname); |
| 5667 | if (system(buf) != 0) { |
| 5668 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5669 | "wifitool sendsingleamsdu failed"); |
| 5670 | } |
| 5671 | |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 5672 | run_iwpriv(dut, ifname, "amsdu 10"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5673 | } |
| 5674 | |
| 5675 | if (dut->ap_mode == AP_11ac) { |
| 5676 | int chwidth, nss; |
| 5677 | |
| 5678 | switch (dut->ap_chwidth) { |
| 5679 | case AP_20: |
| 5680 | chwidth = 0; |
| 5681 | break; |
| 5682 | case AP_40: |
| 5683 | chwidth = 1; |
| 5684 | break; |
| 5685 | case AP_80: |
| 5686 | chwidth = 2; |
| 5687 | break; |
| 5688 | case AP_160: |
| 5689 | chwidth = 3; |
| 5690 | break; |
priyadharshini gowthaman | 63ab848 | 2017-12-28 15:32:55 -0800 | [diff] [blame] | 5691 | case AP_80_80: |
| 5692 | chwidth = 3; |
| 5693 | break; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5694 | default: |
| 5695 | chwidth = 0; |
| 5696 | break; |
| 5697 | } |
| 5698 | |
| 5699 | switch (dut->ap_tx_streams) { |
| 5700 | case 1: |
| 5701 | nss = 1; |
| 5702 | break; |
| 5703 | case 2: |
| 5704 | nss = 2; |
| 5705 | break; |
| 5706 | case 3: |
| 5707 | nss = 3; |
| 5708 | break; |
| 5709 | case 4: |
| 5710 | nss = 4; |
| 5711 | break; |
| 5712 | default: |
| 5713 | nss = 3; |
| 5714 | break; |
| 5715 | } |
| 5716 | |
| 5717 | if (dut->ap_fixed_rate) { |
| 5718 | if (nss == 4) |
| 5719 | ath_disable_txbf(dut, ifname); |
| 5720 | |
| 5721 | /* Set the nss */ |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 5722 | run_iwpriv(dut, ifname, "nss %d", nss); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5723 | |
| 5724 | /* Set the channel width */ |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 5725 | run_iwpriv(dut, ifname, "chwidth %d", chwidth); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5726 | |
| 5727 | /* Set the VHT MCS */ |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 5728 | run_iwpriv(dut, ifname, "vhtmcs %d", dut->ap_mcs); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5729 | } |
| 5730 | } |
| 5731 | |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 5732 | if (dut->ap_dyn_bw_sig == VALUE_ENABLED) |
| 5733 | run_iwpriv(dut, ifname, "cwmenable 1"); |
| 5734 | else if (dut->ap_dyn_bw_sig == VALUE_DISABLED) |
| 5735 | run_iwpriv(dut, ifname, "cwmenable 0"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5736 | |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 5737 | if (dut->ap_sig_rts == VALUE_ENABLED) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5738 | snprintf(buf, sizeof(buf), "iwconfig %s rts 64", ifname); |
| 5739 | if (system(buf) != 0) { |
| 5740 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5741 | "iwconfig rts 64 failed"); |
| 5742 | } |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 5743 | } else if (dut->ap_sig_rts == VALUE_DISABLED) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5744 | snprintf(buf, sizeof(buf), "iwconfig %s rts 2347", ifname); |
| 5745 | if (system(buf) != 0) { |
| 5746 | sigma_dut_print(dut, DUT_MSG_ERROR, |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 5747 | "iwconfig rts 2347 failed"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5748 | } |
| 5749 | } |
| 5750 | |
| 5751 | if (dut->ap_hs2) { |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 5752 | run_iwpriv(dut, ifname, "qbssload 1"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5753 | sigma_dut_print(dut, DUT_MSG_INFO, "Enabled qbssload"); |
| 5754 | } |
| 5755 | |
| 5756 | if (dut->ap_bss_load && dut->ap_bss_load != -1) { |
| 5757 | unsigned int bssload = 0; |
| 5758 | |
| 5759 | if (dut->ap_bss_load == 1) { |
| 5760 | /* STA count: 1, CU: 50, AAC: 65535 */ |
| 5761 | bssload = 0x0132ffff; |
| 5762 | } else if (dut->ap_bss_load == 2) { |
| 5763 | /* STA count: 1, CU: 200, AAC: 65535 */ |
| 5764 | bssload = 0x01c8ffff; |
| 5765 | } else if (dut->ap_bss_load == 3) { |
| 5766 | /* STA count: 1, CU: 75, AAC: 65535 */ |
| 5767 | bssload = 0x014bffff; |
| 5768 | } |
| 5769 | |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 5770 | run_iwpriv(dut, ifname, "hcbssload %u", bssload); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5771 | } else if (dut->ap_bss_load == 0) { |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 5772 | run_iwpriv(dut, ifname, "qbssload 0"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5773 | sigma_dut_print(dut, DUT_MSG_INFO, "Disabled qbssload"); |
| 5774 | } |
| 5775 | |
| 5776 | if (dut->ap_dgaf_disable) { |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 5777 | run_iwpriv(dut, ifname, "dgaf_disable 1"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5778 | sigma_dut_print(dut, DUT_MSG_INFO, "Enabled dgaf_disable"); |
| 5779 | } |
| 5780 | |
| 5781 | if (dut->ap_l2tif) { |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 5782 | run_iwpriv(dut, ifname, "l2tif 1"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5783 | snprintf(buf, sizeof(buf), |
| 5784 | "echo 1 > /sys/class/net/br0/brif/ath0/hotspot_l2tif"); |
| 5785 | if (system(buf) != 0) |
| 5786 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5787 | "l2tif br failed"); |
| 5788 | |
| 5789 | snprintf(buf, sizeof(buf), |
| 5790 | "echo 1 > /sys/class/net/br0/brif/eth0/hotspot_wan"); |
| 5791 | if (system(buf) != 0) |
| 5792 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5793 | "l2tif brif failed"); |
| 5794 | sigma_dut_print(dut, DUT_MSG_INFO, "Enabled l2tif"); |
| 5795 | } |
priyadharshini gowthaman | 264d544 | 2016-02-25 15:52:22 -0800 | [diff] [blame] | 5796 | |
| 5797 | if (dut->ap_ndpa_frame == 0) { |
| 5798 | snprintf(buf, sizeof(buf), |
| 5799 | "wifitool %s beeliner_fw_test 117 192", ifname); |
| 5800 | if (system(buf) != 0) { |
| 5801 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5802 | "wifitool beeliner_fw_test 117 192 failed"); |
| 5803 | } |
| 5804 | snprintf(buf, sizeof(buf), |
| 5805 | "wifitool %s beeliner_fw_test 118 192", ifname); |
| 5806 | if (system(buf) != 0) { |
| 5807 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5808 | "wifitool beeliner_fw_test 117 192 failed"); |
| 5809 | } |
| 5810 | } else if (dut->ap_ndpa_frame == 1) { |
| 5811 | /* Driver default - no changes needed */ |
| 5812 | } else if (dut->ap_ndpa_frame == 2) { |
| 5813 | snprintf(buf, sizeof(buf), |
| 5814 | "wifitool %s beeliner_fw_test 115 1", ifname); |
| 5815 | if (system(buf) != 0) { |
| 5816 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5817 | "wifitool beeliner_fw_test 117 192 failed"); |
| 5818 | } |
| 5819 | snprintf(buf, sizeof(buf), |
| 5820 | "wifitool %s beeliner_fw_test 116 1", ifname); |
| 5821 | if (system(buf) != 0) { |
| 5822 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5823 | "wifitool beeliner_fw_test 117 192 failed"); |
| 5824 | } |
| 5825 | } |
priyadharshini gowthaman | 8e26ff4 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 5826 | |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 5827 | if (dut->ap_rtt == 1) |
| 5828 | run_iwpriv(dut, ifname, "enable_rtt 1"); |
priyadharshini gowthaman | 8e26ff4 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 5829 | |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 5830 | if (dut->ap_lci == 1) |
| 5831 | run_iwpriv(dut, ifname, "enable_lci 1"); |
priyadharshini gowthaman | 8e26ff4 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 5832 | |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 5833 | if (dut->ap_lcr == 1) |
| 5834 | run_iwpriv(dut, ifname, "enable_lcr 1"); |
priyadharshini gowthaman | 8e26ff4 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 5835 | |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 5836 | if (dut->ap_rrm == 1) |
| 5837 | run_iwpriv(dut, ifname, "enable_rmm 1"); |
priyadharshini gowthaman | 8e26ff4 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 5838 | |
| 5839 | if (dut->ap_lci == 1 || dut->ap_lcr == 1) { |
| 5840 | run_system(dut, "wpc -l /tmp/lci_cfg.txt"); |
| 5841 | } |
| 5842 | |
| 5843 | if (dut->ap_neighap >= 1 && dut->ap_lci == 0) { |
| 5844 | FILE *f; |
| 5845 | |
| 5846 | f = fopen("/tmp/nbr_report.txt", "w"); |
| 5847 | if (!f) { |
| 5848 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5849 | "Failed to open /tmp/nbr_report.txt"); |
| 5850 | return; |
| 5851 | } |
| 5852 | |
| 5853 | fprintf(f, |
| 5854 | "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", |
| 5855 | dut->ap_val_neighap[0][0], dut->ap_val_neighap[0][1], |
| 5856 | dut->ap_val_neighap[0][2], dut->ap_val_neighap[0][3], |
| 5857 | dut->ap_val_neighap[0][4], dut->ap_val_neighap[0][5], |
| 5858 | dut->ap_val_opchannel[0]); |
| 5859 | fclose(f); |
| 5860 | |
| 5861 | f = fopen("/tmp/ftmrr.txt", "w"); |
| 5862 | if (!f) { |
| 5863 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5864 | "Failed to open /tmp/ftmrr.txt"); |
| 5865 | return; |
| 5866 | } |
| 5867 | |
| 5868 | fprintf(f, |
| 5869 | "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", |
| 5870 | dut->ap_val_neighap[0][0], dut->ap_val_neighap[0][1], |
| 5871 | dut->ap_val_neighap[0][2], dut->ap_val_neighap[0][3], |
| 5872 | dut->ap_val_neighap[0][4], dut->ap_val_neighap[0][5], |
| 5873 | dut->ap_val_opchannel[0]); |
| 5874 | fclose(f); |
| 5875 | } |
| 5876 | |
| 5877 | if (dut->ap_neighap >= 2 && dut->ap_lci == 0) { |
| 5878 | FILE *f; |
| 5879 | |
| 5880 | f = fopen("/tmp/nbr_report.txt", "a"); |
| 5881 | if (!f) { |
| 5882 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5883 | "Failed to open /tmp/nbr_report.txt"); |
| 5884 | return; |
| 5885 | } |
| 5886 | fprintf(f, |
| 5887 | "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", |
| 5888 | dut->ap_val_neighap[1][0], dut->ap_val_neighap[1][1], |
| 5889 | dut->ap_val_neighap[1][2], dut->ap_val_neighap[1][3], |
| 5890 | dut->ap_val_neighap[1][4], dut->ap_val_neighap[1][5], |
| 5891 | dut->ap_val_opchannel[1]); |
| 5892 | fclose(f); |
| 5893 | |
| 5894 | f = fopen("/tmp/ftmrr.txt", "a"); |
| 5895 | if (!f) { |
| 5896 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5897 | "Failed to open /tmp/ftmrr.txt"); |
| 5898 | return; |
| 5899 | } |
| 5900 | fprintf(f, |
| 5901 | "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", |
| 5902 | dut->ap_val_neighap[1][0], dut->ap_val_neighap[1][1], |
| 5903 | dut->ap_val_neighap[1][2], dut->ap_val_neighap[1][3], |
| 5904 | dut->ap_val_neighap[1][4], dut->ap_val_neighap[1][5], |
| 5905 | dut->ap_val_opchannel[1]); |
| 5906 | fclose(f); |
| 5907 | } |
| 5908 | |
| 5909 | if (dut->ap_neighap >= 3 && dut->ap_lci == 0) { |
| 5910 | FILE *f; |
| 5911 | |
| 5912 | f = fopen("/tmp/nbr_report.txt", "a"); |
| 5913 | if (!f) { |
| 5914 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5915 | "Failed to open /tmp/nbr_report.txt"); |
| 5916 | return; |
| 5917 | } |
| 5918 | |
| 5919 | fprintf(f, |
| 5920 | "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", |
| 5921 | dut->ap_val_neighap[2][0], dut->ap_val_neighap[2][1], |
| 5922 | dut->ap_val_neighap[2][2], dut->ap_val_neighap[2][3], |
| 5923 | dut->ap_val_neighap[2][4], dut->ap_val_neighap[2][5], |
| 5924 | dut->ap_val_opchannel[2]); |
| 5925 | fclose(f); |
| 5926 | |
| 5927 | f = fopen("/tmp/ftmrr.txt", "a"); |
| 5928 | if (!f) { |
| 5929 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5930 | "Failed to open /tmp/ftmrr.txt"); |
| 5931 | return; |
| 5932 | } |
| 5933 | |
| 5934 | fprintf(f, |
| 5935 | "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", |
| 5936 | dut->ap_val_neighap[2][0], dut->ap_val_neighap[2][1], |
| 5937 | dut->ap_val_neighap[2][2], dut->ap_val_neighap[2][3], |
| 5938 | dut->ap_val_neighap[2][4], dut->ap_val_neighap[2][5], |
| 5939 | dut->ap_val_opchannel[2]); |
| 5940 | fclose(f); |
| 5941 | } |
| 5942 | |
| 5943 | if (dut->ap_neighap) { |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 5944 | run_iwpriv(dut, ifname, "enable_rtt 1"); |
| 5945 | run_iwpriv(dut, ifname, "enable_lci 1"); |
| 5946 | run_iwpriv(dut, ifname, "enable_lcr 1"); |
| 5947 | run_iwpriv(dut, ifname, "enable_rrm 1"); |
priyadharshini gowthaman | 8e26ff4 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 5948 | } |
| 5949 | |
| 5950 | if (dut->ap_scan == 1) { |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 5951 | run_iwpriv(dut, ifname, "scanentryage 600"); |
priyadharshini gowthaman | 8e26ff4 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 5952 | snprintf(buf, sizeof(buf), "iwlist %s scan", ifname); |
| 5953 | run_system(dut, buf); |
| 5954 | } |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 5955 | |
| 5956 | if (dut->ap_set_bssidpref) { |
| 5957 | snprintf(buf, sizeof(buf), |
| 5958 | "wifitool %s setbssidpref 00:00:00:00:00:00 0 00 00", |
| 5959 | ifname); |
| 5960 | if (system(buf) != 0) { |
| 5961 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5962 | "wifitool clear bssidpref failed"); |
| 5963 | } |
| 5964 | } |
Adil Saeed Musthafa | 33ea287 | 2017-04-10 23:13:24 -0700 | [diff] [blame] | 5965 | |
| 5966 | if (dut->wnm_bss_max_feature != VALUE_NOT_SET) { |
| 5967 | int feature_enable; |
| 5968 | |
| 5969 | feature_enable = dut->wnm_bss_max_feature == VALUE_ENABLED; |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 5970 | run_iwpriv(dut, ifname, "wnm %d", feature_enable); |
| 5971 | run_iwpriv(dut, ifname, "wnm_bss %d", feature_enable); |
Adil Saeed Musthafa | 33ea287 | 2017-04-10 23:13:24 -0700 | [diff] [blame] | 5972 | if (feature_enable) { |
| 5973 | const char *extra = ""; |
| 5974 | |
| 5975 | if (dut->wnm_bss_max_protection != VALUE_NOT_SET) { |
| 5976 | if (dut->wnm_bss_max_protection == |
| 5977 | VALUE_ENABLED) |
| 5978 | extra = " 1"; |
| 5979 | else |
| 5980 | extra = " 0"; |
| 5981 | } |
| 5982 | snprintf(buf, sizeof(buf), |
| 5983 | "wlanconfig %s wnm setbssmax %d%s", |
| 5984 | ifname, dut->wnm_bss_max_idle_time, extra); |
| 5985 | run_system(dut, buf); |
| 5986 | } |
| 5987 | } |
Adil Saeed Musthafa | 05ec744 | 2017-04-10 23:13:35 -0700 | [diff] [blame] | 5988 | |
Adil Saeed Musthafa | 023108a | 2017-04-10 23:13:37 -0700 | [diff] [blame] | 5989 | if (dut->program == PROGRAM_MBO) { |
Adil Saeed Musthafa | 6906372 | 2017-04-10 23:13:40 -0700 | [diff] [blame] | 5990 | apply_mbo_pref_ap_list(dut); |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 5991 | run_iwpriv(dut, ifname, "mbo_cel_pref %d", |
| 5992 | dut->ap_cell_cap_pref); |
| 5993 | run_iwpriv(dut, ifname, "mbocap 0x40"); |
Adil Saeed Musthafa | 05ec744 | 2017-04-10 23:13:35 -0700 | [diff] [blame] | 5994 | ath_set_assoc_disallow(dut, ifname, "disable"); |
Adil Saeed Musthafa | 023108a | 2017-04-10 23:13:37 -0700 | [diff] [blame] | 5995 | } |
priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 5996 | |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 5997 | if (dut->ap_oce == VALUE_ENABLED) |
| 5998 | run_iwpriv(dut, ifname, "set_bpr_enable 1"); |
priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 5999 | |
| 6000 | if (dut->ap_oce == VALUE_ENABLED && dut->ap_channel <= 11) { |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 6001 | run_iwpriv(dut, ifname, "prb_rate 5500"); |
| 6002 | run_iwpriv(dut, ifname, "set_bcn_rate 5500"); |
priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 6003 | } |
| 6004 | |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 6005 | if (dut->ap_oce == VALUE_DISABLED) |
| 6006 | run_iwpriv(dut, ifname, "set_bpr_enable 0"); |
priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 6007 | |
| 6008 | if (dut->ap_oce == VALUE_DISABLED && dut->ap_channel <= 11) { |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 6009 | run_iwpriv(dut, ifname, "mgmt_rate 1000"); |
| 6010 | run_iwpriv(dut, ifname, "set_bcn_rate 1000"); |
priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 6011 | } |
| 6012 | |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 6013 | if (dut->ap_bcnint) |
| 6014 | run_iwpriv(dut, ifname, "bintval %d", dut->ap_bcnint); |
priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 6015 | |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 6016 | if (dut->ap_filsdscv == VALUE_DISABLED) |
| 6017 | run_iwpriv(dut, ifname, "enable_fils 0 0"); |
priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 6018 | |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 6019 | if (dut->ap_filshlp == VALUE_ENABLED) |
| 6020 | run_iwpriv(dut, ifname, "oce_hlp 1"); |
| 6021 | else if (dut->ap_filshlp == VALUE_DISABLED) |
| 6022 | run_iwpriv(dut, ifname, "oce_hlp 0"); |
priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 6023 | |
| 6024 | /* When RNR is enabled, also enable apchannelreport, background scan */ |
| 6025 | if (dut->ap_rnr == VALUE_ENABLED) { |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 6026 | run_iwpriv(dut, ifname, "rnr 1"); |
| 6027 | run_iwpriv(dut, ifname, "rnr_tbtt 1"); |
| 6028 | run_iwpriv(dut, ifname, "apchanrpt 1"); |
| 6029 | run_iwpriv(dut, basedev, "acs_ctrlflags 0x4"); |
| 6030 | run_iwpriv(dut, basedev, "acs_scanintvl 60"); |
| 6031 | run_iwpriv(dut, basedev, "acs_bkscanen 1"); |
priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 6032 | if (dut->ap_is_dual == 1) { |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 6033 | run_iwpriv(dut, ifname_dual, "rnr 1"); |
| 6034 | run_iwpriv(dut, ifname_dual, "rnr_tbtt 1"); |
| 6035 | run_iwpriv(dut, ifname_dual, "apchanrpt 1"); |
| 6036 | run_iwpriv(dut, basedev_radio, "acs_ctrlflags 0x4"); |
| 6037 | run_iwpriv(dut, basedev_radio, "acs_scanintvl 60"); |
| 6038 | run_iwpriv(dut, basedev_radio, "acs_bkscanen 1"); |
priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 6039 | } |
| 6040 | } |
| 6041 | |
| 6042 | if (dut->ap_blechanutil || dut->ap_ble_admit_cap || dut->ap_blestacnt) { |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 6043 | run_iwpriv(dut, ifname, "qbssload 0"); |
priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 6044 | snprintf(buf, sizeof(buf), |
| 6045 | "wlanconfig %s addie ftype 0 len 7 data 0b05%02x%02x%02x%02x%02x ", |
| 6046 | ifname, dut->ap_blestacnt & 0xFF, |
| 6047 | dut->ap_blestacnt >> 8, dut->ap_blechanutil, |
| 6048 | dut->ap_ble_admit_cap & 0xFF, |
| 6049 | dut->ap_ble_admit_cap >> 8); |
| 6050 | run_system(dut, buf); |
| 6051 | snprintf(buf, sizeof(buf), |
| 6052 | "wlanconfig %s addie ftype 2 len 7 data 0b05%02x%02x%02x%02x%02x ", |
| 6053 | ifname, dut->ap_blestacnt & 0xFF, |
| 6054 | dut->ap_blestacnt >> 8, dut->ap_blechanutil, |
| 6055 | dut->ap_ble_admit_cap & 0xFF, |
| 6056 | dut->ap_ble_admit_cap >> 8); |
| 6057 | run_system(dut, buf); |
| 6058 | } |
| 6059 | |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 6060 | if (dut->ap_esp == VALUE_ENABLED) |
| 6061 | run_iwpriv(dut, basedev, "esp_period 5"); |
| 6062 | else if (dut->ap_esp == VALUE_DISABLED) |
| 6063 | run_iwpriv(dut, basedev, "esp_period 0"); |
priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 6064 | |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 6065 | if (dut->ap_datappdudura) |
| 6066 | run_iwpriv(dut, basedev, "esp_ppdu_dur %d", |
| 6067 | dut->ap_datappdudura); |
priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 6068 | |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 6069 | if (dut->ap_airtimefract) |
| 6070 | run_iwpriv(dut, basedev, "esp_airtime %d", |
| 6071 | dut->ap_airtimefract); |
priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 6072 | |
| 6073 | if (dut->ap_dhcp_stop) { |
| 6074 | snprintf(buf, sizeof(buf), "/etc/init.d/dnsmasq stop"); |
| 6075 | run_system(dut, buf); |
| 6076 | } |
| 6077 | |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 6078 | if (dut->ap_bawinsize) |
| 6079 | run_iwpriv(dut, basedev, "esp_ba_window %d", dut->ap_bawinsize); |
priyadharshini gowthaman | b4de196 | 2018-01-15 12:21:04 -0800 | [diff] [blame] | 6080 | |
| 6081 | if (dut->program == PROGRAM_DPP) { |
| 6082 | if (dut->ap_interface_2g == 1) { |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 6083 | run_iwpriv(dut, ifname, "set_bcn_rate 5500"); |
| 6084 | run_iwpriv(dut, ifname, "prb_rate 5500"); |
| 6085 | run_iwpriv(dut, ifname, "mgmt_rate 5500"); |
priyadharshini gowthaman | b4de196 | 2018-01-15 12:21:04 -0800 | [diff] [blame] | 6086 | } |
| 6087 | |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 6088 | run_iwpriv(dut, basedev, "set_rxfilter 0xffffffff"); |
priyadharshini gowthaman | b4de196 | 2018-01-15 12:21:04 -0800 | [diff] [blame] | 6089 | dut->hostapd_running = 1; |
| 6090 | } |
priyadharshini gowthaman | 350f191 | 2018-06-04 13:09:12 -0700 | [diff] [blame] | 6091 | |
Priyadharshini Gowthaman | fe60c50 | 2019-08-14 13:00:34 -0700 | [diff] [blame] | 6092 | if (dut->ap_he_ulofdma == VALUE_ENABLED) { |
| 6093 | run_iwpriv(dut, ifname, "he_ul_ofdma 1"); |
| 6094 | run_iwpriv(dut, ifname, "he_mu_edca 1"); |
| 6095 | |
| 6096 | /* Disable sounding for UL OFDMA */ |
| 6097 | run_system_wrapper(dut, "wifitool %s setUnitTestCmd 0x47 2 7 0", |
priyadharshini gowthaman | 350f191 | 2018-06-04 13:09:12 -0700 | [diff] [blame] | 6098 | ifname); |
Priyadharshini Gowthaman | fe60c50 | 2019-08-14 13:00:34 -0700 | [diff] [blame] | 6099 | |
| 6100 | if ((dut->ap_rx_streams || dut->ap_tx_streams) && |
| 6101 | dut->device_type == AP_testbed) { |
| 6102 | unsigned int txchainmask = 0x00; |
| 6103 | |
| 6104 | switch (dut->ap_rx_streams) { |
| 6105 | case 1: |
| 6106 | txchainmask = 0x01; |
| 6107 | break; |
| 6108 | case 2: |
| 6109 | txchainmask = 0x03; |
| 6110 | break; |
| 6111 | case 3: |
| 6112 | txchainmask = 0x07; |
| 6113 | break; |
| 6114 | case 4: |
| 6115 | txchainmask = 0x0f; |
| 6116 | break; |
| 6117 | case 5: |
| 6118 | txchainmask = 0x1f; |
| 6119 | break; |
| 6120 | case 6: |
| 6121 | txchainmask = 0x3f; |
| 6122 | break; |
| 6123 | case 7: |
| 6124 | txchainmask = 0x7f; |
| 6125 | break; |
| 6126 | case 8: |
| 6127 | txchainmask = 0xff; |
| 6128 | break; |
| 6129 | } |
| 6130 | |
| 6131 | run_iwpriv(dut, ifname, "he_ul_nss %d", |
| 6132 | dut->ap_rx_streams); |
| 6133 | run_iwpriv(dut, basedev, "txchainmask %d", txchainmask); |
| 6134 | run_iwpriv(dut, basedev, "rxchainmask %d", txchainmask); |
| 6135 | } |
| 6136 | |
| 6137 | if (dut->ap_channel == 100 && dut->device_type == AP_testbed) |
| 6138 | run_system_wrapper(dut, "iwpriv %s inact 1000", ifname); |
| 6139 | |
| 6140 | run_iwpriv(dut, ifname, "he_ul_ltf 3"); |
| 6141 | run_iwpriv(dut, ifname, "he_ul_shortgi 3"); |
| 6142 | run_iwpriv(dut, basedev, "he_ul_trig_int 2"); |
| 6143 | |
| 6144 | /* Set random RU allocation */ |
| 6145 | run_system_wrapper(dut, "wifitool %s setUnitTestCmd 0x47 2 9 1", |
| 6146 | ifname); |
| 6147 | /* To set TBTT PPDU duration (us) */ |
| 6148 | run_system_wrapper(dut, |
| 6149 | "wifitool %s setUnitTestCmd 0x48 2 63 1908", |
| 6150 | ifname); |
| 6151 | } |
| 6152 | |
| 6153 | if (dut->program == PROGRAM_HE && dut->device_type == AP_testbed && |
| 6154 | dut->ap_he_dlofdma == VALUE_DISABLED) |
| 6155 | run_iwpriv(dut, ifname, "he_dl_ofdma 0"); |
| 6156 | |
| 6157 | if (dut->ap_he_dlofdma == VALUE_ENABLED) { |
| 6158 | run_iwpriv(dut, ifname, "he_dl_ofdma 1", ifname); |
| 6159 | |
| 6160 | /* For fixed MCS */ |
| 6161 | novap_reset(dut, ifname, 0); |
| 6162 | run_iwpriv(dut, ifname, |
| 6163 | "cfg80211tool %s setratemask 3 0x80f80f80 0x0f80f80f 0xf80f80f8"); |
| 6164 | } |
| 6165 | |
| 6166 | if (dut->ap_he_ppdu == PPDU_MU && dut->ap_he_dlofdma == VALUE_ENABLED) { |
| 6167 | /* Increase the min TX time limit for MU MIMO to disable MU MIMO |
| 6168 | * scheduling */ |
| 6169 | run_system_wrapper(dut, |
| 6170 | "wifitool %s setUnitTestCmd 0x47 2 11 1000000", |
| 6171 | ifname); |
| 6172 | /* Increase the max TX time limit for DL OFDMA to enable OFDMA |
| 6173 | * scheduling */ |
| 6174 | run_system_wrapper(dut, |
| 6175 | "wifitool %s setUnitTestCmd 0x47 2 17 1000000", |
| 6176 | ifname); |
| 6177 | /* Disable 'force SU schedule' to enable MU sch */ |
| 6178 | run_system_wrapper(dut, "wifitool %s setUnitTestCmd 0x47 2 8 0", |
| 6179 | ifname); |
| 6180 | /* Enable MU 11ax support in sch algo */ |
priyadharshini gowthaman | 350f191 | 2018-06-04 13:09:12 -0700 | [diff] [blame] | 6181 | run_system_wrapper(dut, |
| 6182 | "wifitool %s setUnitTestCmd 0x47 2 29 0", |
| 6183 | ifname); |
Priyadharshini Gowthaman | fe60c50 | 2019-08-14 13:00:34 -0700 | [diff] [blame] | 6184 | /* Enable to sort RU allocation */ |
| 6185 | run_system_wrapper(dut, "wifitool %s setUnitTestCmd 0x4b 2 2 1", |
| 6186 | ifname); |
priyadharshini gowthaman | 350f191 | 2018-06-04 13:09:12 -0700 | [diff] [blame] | 6187 | } |
Priyadharshini Gowthaman | bc94889 | 2019-09-10 14:22:49 -0700 | [diff] [blame] | 6188 | |
| 6189 | if (dut->ap_numsounddim) { |
| 6190 | unsigned int txchainmask = 0; |
| 6191 | |
| 6192 | switch (dut->ap_numsounddim) { |
| 6193 | case 1: |
| 6194 | txchainmask = 0x01; |
| 6195 | break; |
| 6196 | case 2: |
| 6197 | txchainmask = 0x03; |
| 6198 | break; |
| 6199 | case 3: |
| 6200 | txchainmask = 0x07; |
| 6201 | break; |
| 6202 | case 4: |
| 6203 | txchainmask = 0x0f; |
| 6204 | break; |
| 6205 | case 5: |
| 6206 | txchainmask = 0x1f; |
| 6207 | break; |
| 6208 | case 6: |
| 6209 | txchainmask = 0x3f; |
| 6210 | break; |
| 6211 | case 7: |
| 6212 | txchainmask = 0x7f; |
| 6213 | break; |
| 6214 | case 8: |
| 6215 | txchainmask = 0xff; |
| 6216 | break; |
| 6217 | } |
| 6218 | run_iwpriv(dut, basedev, "txchainmask %d", txchainmask); |
| 6219 | } |
| 6220 | |
| 6221 | if (dut->ap_numsounddim && dut->device_type == AP_testbed) { |
| 6222 | /* Sets g_force_1x1_peer to 1 which should be reset to zero |
| 6223 | * for non-MU test cases */ |
| 6224 | run_system_wrapper(dut, |
| 6225 | "wifitool %s setUnitTestCmd 0x48 2 118 1", |
| 6226 | ifname); |
| 6227 | if (dut->ap_mu_txBF) { |
| 6228 | /* Disable DL OFDMA */ |
| 6229 | run_system_wrapper(dut, |
| 6230 | "wifitool %s setUnitTestCmd 0x47 2 11 0", |
| 6231 | ifname); |
| 6232 | } |
| 6233 | } |
Priyadharshini Gowthaman | 670b323 | 2019-09-10 16:09:19 -0700 | [diff] [blame] | 6234 | |
| 6235 | if (dut->ap_channel <= 11 && dut->program == PROGRAM_HE && |
| 6236 | dut->device_type == AP_testbed) { |
| 6237 | dut->ap_bcc = VALUE_ENABLED; |
| 6238 | run_iwpriv(dut, ifname, "vht_11ng 0"); |
| 6239 | } |
| 6240 | |
| 6241 | if (dut->ap_bcc == VALUE_ENABLED) { |
| 6242 | run_iwpriv(dut, ifname, "mode 11AHE20"); |
| 6243 | run_iwpriv(dut, ifname, "nss 2"); |
| 6244 | run_iwpriv(dut, ifname, "he_txmcsmap 0x0"); |
| 6245 | run_iwpriv(dut, ifname, "he_rxmcsmap 0x0"); |
| 6246 | } |
Priyadharshini Gowthaman | 6bc4c1e | 2019-09-10 16:24:51 -0700 | [diff] [blame] | 6247 | |
| 6248 | if (dut->ap_he_frag == VALUE_ENABLED) |
| 6249 | run_iwpriv(dut, ifname, "he_frag 1"); |
| 6250 | else if (dut->ap_he_frag == VALUE_DISABLED) |
| 6251 | run_iwpriv(dut, ifname, "he_frag 0"); |
Priyadharshini Gowthaman | 1a686bd | 2019-09-19 14:41:40 -0700 | [diff] [blame] | 6252 | |
| 6253 | if (dut->ap_ba_bufsize != BA_BUFSIZE_NOT_SET) { |
| 6254 | if (dut->ap_ba_bufsize == BA_BUFSIZE_64) |
| 6255 | run_iwpriv(dut, ifname, "ba_bufsize 0"); |
| 6256 | else |
| 6257 | run_iwpriv(dut, ifname, "ba_bufsize 1"); |
| 6258 | } |
Priyadharshini Gowthaman | 21895a5 | 2019-10-07 16:56:16 -0700 | [diff] [blame] | 6259 | |
| 6260 | if (dut->ap_mu_edca == VALUE_ENABLED) |
| 6261 | run_iwpriv(dut, ifname, "he_mu_edca 1"); |
Priyadharshini Gowthaman | dee79e2 | 2019-10-07 16:56:27 -0700 | [diff] [blame] | 6262 | |
| 6263 | if (dut->ap_he_mimo == MIMO_DL) { |
| 6264 | mubrp_commands(dut, ifname); |
| 6265 | if (dut->device_type != AP_testbed) |
| 6266 | run_system_wrapper( |
| 6267 | dut, "wifitool %s setUnitTestCmd 0x48 2 100 2", |
| 6268 | ifname); |
| 6269 | } |
| 6270 | |
| 6271 | if (dut->ap_he_mimo == MIMO_UL) |
| 6272 | run_iwpriv(dut, ifname, "he_mubfee 1"); |
Priyadharshini Gowthaman | 43d6b41 | 2019-10-07 16:56:37 -0700 | [diff] [blame] | 6273 | |
| 6274 | if (dut->ap_he_rtsthrshld == VALUE_ENABLED) |
| 6275 | run_iwpriv(dut, ifname, "he_rtsthrshld 512"); |
| 6276 | else if (dut->ap_he_rtsthrshld == VALUE_DISABLED) |
| 6277 | run_iwpriv(dut, ifname, "he_rtsthrshld 1024"); |
Priyadharshini Gowthaman | 8018c98 | 2019-10-31 15:14:37 -0700 | [diff] [blame] | 6278 | |
| 6279 | if (dut->ap_mbssid == VALUE_ENABLED && |
| 6280 | (dut->ap_rx_streams || dut->ap_tx_streams) && |
| 6281 | dut->device_type == AP_testbed) { |
| 6282 | const char *ifname_1; |
| 6283 | |
| 6284 | ifname_1= dut->ap_channel >= 36 ? "ath01" : "ath11"; |
| 6285 | |
| 6286 | /* NSS is not set in Secondary VAP for MBSSID case, |
| 6287 | * hence it is explicitly set here. For primary VAP |
| 6288 | * NSS is set during AP configuration */ |
| 6289 | run_iwpriv(dut, ifname_1, "nss %d", dut->ap_rx_streams); |
| 6290 | } |
Priyadharshini Gowthaman | ae0a605 | 2019-11-01 15:26:38 -0700 | [diff] [blame] | 6291 | |
| 6292 | if (dut->ap_twtresp == VALUE_ENABLED) |
| 6293 | run_iwpriv(dut, ifname, "twt_responder 1"); |
| 6294 | else if (dut->ap_twtresp == VALUE_DISABLED) |
| 6295 | run_iwpriv(dut, ifname, "twt_responder 0"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6296 | } |
| 6297 | |
| 6298 | |
| 6299 | static int cmd_ath_ap_config_commit(struct sigma_dut *dut, |
| 6300 | struct sigma_conn *conn, |
| 6301 | struct sigma_cmd *cmd) |
| 6302 | { |
| 6303 | /* const char *name = get_param(cmd, "NAME"); */ |
| 6304 | char buf[100]; |
| 6305 | struct stat s; |
| 6306 | const char *ifname = dut->ap_is_dual ? "ath1" : "ath0"; |
Jouni Malinen | 3aa7286 | 2019-05-29 23:14:51 +0300 | [diff] [blame] | 6307 | int res; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6308 | |
| 6309 | if (stat("/proc/athversion", &s) == 0) { |
| 6310 | sigma_dut_print(dut, DUT_MSG_INFO, "Run apdown"); |
| 6311 | run_system(dut, "apdown"); |
| 6312 | } |
| 6313 | |
| 6314 | cmd_ath_ap_radio_config(dut); |
| 6315 | |
| 6316 | snprintf(buf, sizeof(buf), "cfg -a 'AP_SSID=%s'", dut->ap_ssid); |
| 6317 | run_system(dut, buf); |
| 6318 | |
| 6319 | switch (dut->ap_key_mgmt) { |
| 6320 | case AP_OPEN: |
| 6321 | if (dut->ap_cipher == AP_WEP) { |
| 6322 | run_system(dut, "cfg -a AP_SECMODE=WEP"); |
| 6323 | run_system(dut, "cfg -a AP_SECFILE=NONE"); |
| 6324 | /* shared auth mode not supported */ |
| 6325 | run_system(dut, "cfg -a AP_WEP_MODE_0=1"); |
| 6326 | run_system(dut, "cfg -a AP_WEP_MODE_1=1"); |
| 6327 | snprintf(buf, sizeof(buf), |
| 6328 | "cfg -a WEP_RADIO_NUM0_KEY_1=%s", |
| 6329 | dut->ap_wepkey); |
| 6330 | run_system(dut, buf); |
| 6331 | snprintf(buf, sizeof(buf), |
| 6332 | "cfg -a WEP_RADIO_NUM1_KEY_1=%s", |
| 6333 | dut->ap_wepkey); |
| 6334 | run_system(dut, buf); |
| 6335 | } else { |
| 6336 | run_system(dut, "cfg -a AP_SECMODE=None"); |
| 6337 | } |
| 6338 | break; |
| 6339 | case AP_WPA2_PSK: |
| 6340 | case AP_WPA2_PSK_MIXED: |
| 6341 | case AP_WPA_PSK: |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 6342 | case AP_WPA2_SAE: |
| 6343 | case AP_WPA2_PSK_SAE: |
| 6344 | if (dut->ap_key_mgmt == AP_WPA2_PSK || |
| 6345 | dut->ap_key_mgmt == AP_WPA2_SAE || |
| 6346 | dut->ap_key_mgmt == AP_WPA2_PSK_SAE) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6347 | run_system(dut, "cfg -a AP_WPA=2"); |
| 6348 | else if (dut->ap_key_mgmt == AP_WPA2_PSK_MIXED) |
| 6349 | run_system(dut, "cfg -a AP_WPA=3"); |
| 6350 | else |
| 6351 | run_system(dut, "cfg -a AP_WPA=1"); |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 6352 | /* TODO: SAE configuration */ |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6353 | run_system(dut, "cfg -a AP_SECMODE=WPA"); |
| 6354 | run_system(dut, "cfg -a AP_SECFILE=PSK"); |
Jouni Malinen | 3aa7286 | 2019-05-29 23:14:51 +0300 | [diff] [blame] | 6355 | res = snprintf(buf, sizeof(buf), "cfg -a 'PSK_KEY=%s'", |
| 6356 | dut->ap_passphrase); |
| 6357 | if (res < 0 || res >= sizeof(buf)) |
| 6358 | return ERROR_SEND_STATUS; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6359 | run_system(dut, buf); |
| 6360 | if (dut->ap_cipher == AP_CCMP_TKIP) |
| 6361 | run_system(dut, "cfg -a AP_CYPHER=\"CCMP TKIP\""); |
| 6362 | else if (dut->ap_cipher == AP_TKIP) |
| 6363 | run_system(dut, "cfg -a AP_CYPHER=TKIP"); |
| 6364 | else |
| 6365 | run_system(dut, "cfg -a AP_CYPHER=CCMP"); |
| 6366 | break; |
| 6367 | case AP_WPA2_EAP: |
| 6368 | case AP_WPA2_EAP_MIXED: |
| 6369 | case AP_WPA_EAP: |
| 6370 | if (dut->ap_key_mgmt == AP_WPA2_EAP) |
| 6371 | run_system(dut, "cfg -a AP_WPA=2"); |
| 6372 | else if (dut->ap_key_mgmt == AP_WPA2_EAP_MIXED) |
| 6373 | run_system(dut, "cfg -a AP_WPA=3"); |
| 6374 | else |
| 6375 | run_system(dut, "cfg -a AP_WPA=1"); |
| 6376 | run_system(dut, "cfg -a AP_SECMODE=WPA"); |
| 6377 | run_system(dut, "cfg -a AP_SECFILE=EAP"); |
| 6378 | if (dut->ap_cipher == AP_CCMP_TKIP) |
| 6379 | run_system(dut, "cfg -a AP_CYPHER=\"CCMP TKIP\""); |
| 6380 | else if (dut->ap_cipher == AP_TKIP) |
| 6381 | run_system(dut, "cfg -a AP_CYPHER=TKIP"); |
| 6382 | else |
| 6383 | run_system(dut, "cfg -a AP_CYPHER=CCMP"); |
| 6384 | snprintf(buf, sizeof(buf), "cfg -a AP_AUTH_SERVER=%s", |
| 6385 | dut->ap_radius_ipaddr); |
| 6386 | run_system(dut, buf); |
| 6387 | snprintf(buf, sizeof(buf), "cfg -a AP_AUTH_PORT=%d", |
| 6388 | dut->ap_radius_port); |
| 6389 | run_system(dut, buf); |
Jouni Malinen | 3aa7286 | 2019-05-29 23:14:51 +0300 | [diff] [blame] | 6390 | res = snprintf(buf, sizeof(buf), "cfg -a AP_AUTH_SECRET=%s", |
| 6391 | dut->ap_radius_password); |
| 6392 | if (res < 0 || res >= sizeof(buf)) |
| 6393 | return ERROR_SEND_STATUS; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6394 | run_system(dut, buf); |
| 6395 | break; |
Jouni Malinen | 4cf699f | 2018-06-19 00:46:27 +0300 | [diff] [blame] | 6396 | case AP_WPA2_EAP_OSEN: |
| 6397 | /* TODO */ |
| 6398 | sigma_dut_print(dut, DUT_MSG_ERROR, "EAP+OSEN not supported"); |
| 6399 | break; |
Jouni Malinen | ad395a2 | 2017-09-01 21:13:46 +0300 | [diff] [blame] | 6400 | case AP_SUITEB: |
| 6401 | /* TODO */ |
| 6402 | sigma_dut_print(dut, DUT_MSG_ERROR, "SuiteB not supported"); |
| 6403 | break; |
Jouni Malinen | 147b3c3 | 2017-10-09 16:51:54 +0300 | [diff] [blame] | 6404 | case AP_WPA2_OWE: |
| 6405 | /* TODO */ |
| 6406 | sigma_dut_print(dut, DUT_MSG_ERROR, "OWE not supported"); |
| 6407 | break; |
Jouni Malinen | 6be21c8 | 2018-08-01 18:47:24 +0300 | [diff] [blame] | 6408 | case AP_WPA2_FT_EAP: |
| 6409 | case AP_WPA2_FT_PSK: |
| 6410 | case AP_WPA2_EAP_SHA256: |
| 6411 | case AP_WPA2_PSK_SHA256: |
| 6412 | case AP_WPA2_ENT_FT_EAP: |
Jouni Malinen | c2b9121 | 2018-09-12 02:26:39 +0300 | [diff] [blame] | 6413 | case AP_OSEN: |
Jouni Malinen | 6be21c8 | 2018-08-01 18:47:24 +0300 | [diff] [blame] | 6414 | /* TODO */ |
| 6415 | send_resp(dut, conn, SIGMA_ERROR, |
| 6416 | "errorCode,Unsupported KeyMgnt value"); |
| 6417 | return 0; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6418 | } |
| 6419 | |
| 6420 | if (dut->ap_is_dual) { |
| 6421 | /* ath1 settings in case of dual */ |
| 6422 | snprintf(buf, sizeof(buf), "cfg -a 'AP_SSID_2=%s'", |
| 6423 | dut->ap_ssid); |
| 6424 | run_system(dut, buf); |
| 6425 | |
| 6426 | switch (dut->ap_key_mgmt) { |
| 6427 | case AP_OPEN: |
| 6428 | if (dut->ap_cipher == AP_WEP) { |
| 6429 | run_system(dut, "cfg -a AP_SECMODE_2=WEP"); |
| 6430 | run_system(dut, "cfg -a AP_SECFILE_2=NONE"); |
| 6431 | /* shared auth mode not supported */ |
| 6432 | run_system(dut, "cfg -a AP_WEP_MODE_0=1"); |
| 6433 | run_system(dut, "cfg -a AP_WEP_MODE_1=1"); |
| 6434 | snprintf(buf, sizeof(buf), |
| 6435 | "cfg -a WEP_RADIO_NUM0_KEY_1=%s", |
| 6436 | dut->ap_wepkey); |
| 6437 | run_system(dut, buf); |
| 6438 | snprintf(buf, sizeof(buf), |
| 6439 | "cfg -a WEP_RADIO_NUM1_KEY_1=%s", |
| 6440 | dut->ap_wepkey); |
| 6441 | run_system(dut, buf); |
| 6442 | } else { |
| 6443 | run_system(dut, "cfg -a AP_SECMODE_2=None"); |
| 6444 | } |
| 6445 | break; |
| 6446 | case AP_WPA2_PSK: |
| 6447 | case AP_WPA2_PSK_MIXED: |
| 6448 | case AP_WPA_PSK: |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 6449 | case AP_WPA2_SAE: |
| 6450 | case AP_WPA2_PSK_SAE: |
| 6451 | if (dut->ap_key_mgmt == AP_WPA2_PSK || |
| 6452 | dut->ap_key_mgmt == AP_WPA2_SAE || |
| 6453 | dut->ap_key_mgmt == AP_WPA2_PSK_SAE) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6454 | run_system(dut, "cfg -a AP_WPA_2=2"); |
| 6455 | else if (dut->ap_key_mgmt == AP_WPA2_PSK_MIXED) |
| 6456 | run_system(dut, "cfg -a AP_WPA_2=3"); |
| 6457 | else |
| 6458 | run_system(dut, "cfg -a AP_WPA_2=1"); |
| 6459 | // run_system(dut, "cfg -a AP_WPA_2=2"); |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 6460 | /* TODO: SAE configuration */ |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6461 | run_system(dut, "cfg -a AP_SECMODE_2=WPA"); |
| 6462 | run_system(dut, "cfg -a AP_SECFILE_2=PSK"); |
Jouni Malinen | 3aa7286 | 2019-05-29 23:14:51 +0300 | [diff] [blame] | 6463 | res = snprintf(buf, sizeof(buf), |
| 6464 | "cfg -a 'PSK_KEY_2=%s'", |
| 6465 | dut->ap_passphrase); |
| 6466 | if (res < 0 || res >= sizeof(buf)) |
| 6467 | return ERROR_SEND_STATUS; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6468 | run_system(dut, buf); |
| 6469 | if (dut->ap_cipher == AP_CCMP_TKIP) |
| 6470 | run_system(dut, "cfg -a AP_CYPHER_2=\"CCMP TKIP\""); |
| 6471 | else if (dut->ap_cipher == AP_TKIP) |
| 6472 | run_system(dut, "cfg -a AP_CYPHER_2=TKIP"); |
| 6473 | else |
| 6474 | run_system(dut, "cfg -a AP_CYPHER_2=CCMP"); |
| 6475 | break; |
| 6476 | case AP_WPA2_EAP: |
| 6477 | case AP_WPA2_EAP_MIXED: |
| 6478 | case AP_WPA_EAP: |
| 6479 | if (dut->ap_key_mgmt == AP_WPA2_EAP) |
| 6480 | run_system(dut, "cfg -a AP_WPA_2=2"); |
| 6481 | else if (dut->ap_key_mgmt == AP_WPA2_EAP_MIXED) |
| 6482 | run_system(dut, "cfg -a AP_WPA_2=3"); |
| 6483 | else |
| 6484 | run_system(dut, "cfg -a AP_WPA_2=1"); |
| 6485 | run_system(dut, "cfg -a AP_SECMODE_2=WPA"); |
| 6486 | run_system(dut, "cfg -a AP_SECFILE_2=EAP"); |
| 6487 | if (dut->ap_cipher == AP_CCMP_TKIP) |
| 6488 | run_system(dut, "cfg -a AP_CYPHER_2=\"CCMP TKIP\""); |
| 6489 | else if (dut->ap_cipher == AP_TKIP) |
| 6490 | run_system(dut, "cfg -a AP_CYPHER_2=TKIP"); |
| 6491 | else |
| 6492 | run_system(dut, "cfg -a AP_CYPHER_2=CCMP"); |
| 6493 | |
| 6494 | snprintf(buf, sizeof(buf), "cfg -a AP_AUTH_SERVER_2=%s", |
| 6495 | dut->ap_radius_ipaddr); |
| 6496 | run_system(dut, buf); |
| 6497 | snprintf(buf, sizeof(buf), "cfg -a AP_AUTH_PORT_2=%d", |
| 6498 | dut->ap_radius_port); |
| 6499 | run_system(dut, buf); |
Jouni Malinen | 3aa7286 | 2019-05-29 23:14:51 +0300 | [diff] [blame] | 6500 | res = snprintf(buf, sizeof(buf), |
| 6501 | "cfg -a AP_AUTH_SECRET_2=%s", |
| 6502 | dut->ap_radius_password); |
| 6503 | if (res < 0 || res >= sizeof(buf)) |
| 6504 | return ERROR_SEND_STATUS; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6505 | run_system(dut, buf); |
| 6506 | break; |
Jouni Malinen | 4cf699f | 2018-06-19 00:46:27 +0300 | [diff] [blame] | 6507 | case AP_WPA2_EAP_OSEN: |
| 6508 | /* TODO */ |
| 6509 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 6510 | "EAP+OSEN not supported"); |
| 6511 | break; |
Jouni Malinen | ad395a2 | 2017-09-01 21:13:46 +0300 | [diff] [blame] | 6512 | case AP_SUITEB: |
| 6513 | /* TODO */ |
| 6514 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 6515 | "SuiteB not supported"); |
| 6516 | break; |
Jouni Malinen | 147b3c3 | 2017-10-09 16:51:54 +0300 | [diff] [blame] | 6517 | case AP_WPA2_OWE: |
| 6518 | /* TODO */ |
| 6519 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 6520 | "OWE not supported"); |
| 6521 | break; |
Jouni Malinen | 6be21c8 | 2018-08-01 18:47:24 +0300 | [diff] [blame] | 6522 | case AP_WPA2_FT_EAP: |
| 6523 | case AP_WPA2_FT_PSK: |
| 6524 | case AP_WPA2_EAP_SHA256: |
| 6525 | case AP_WPA2_PSK_SHA256: |
| 6526 | case AP_WPA2_ENT_FT_EAP: |
Jouni Malinen | c2b9121 | 2018-09-12 02:26:39 +0300 | [diff] [blame] | 6527 | case AP_OSEN: |
Jouni Malinen | 6be21c8 | 2018-08-01 18:47:24 +0300 | [diff] [blame] | 6528 | /* TODO */ |
| 6529 | send_resp(dut, conn, SIGMA_ERROR, |
| 6530 | "errorCode,Unsupported KeyMgnt value"); |
| 6531 | return 0; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6532 | } |
| 6533 | |
| 6534 | /* wifi0 settings in case of dual */ |
| 6535 | run_system(dut, "cfg -a AP_RADIO_ID=0"); |
| 6536 | run_system(dut, "cfg -a AP_PRIMARY_CH=6"); |
| 6537 | run_system(dut, "cfg -a AP_STARTMODE=dual"); |
| 6538 | run_system(dut, "cfg -a AP_CHMODE=11NGHT40PLUS"); |
| 6539 | run_system(dut, "cfg -a TX_CHAINMASK=7"); |
| 6540 | run_system(dut, "cfg -a RX_CHAINMASK=7"); |
| 6541 | } |
| 6542 | |
| 6543 | switch (dut->ap_pmf) { |
| 6544 | case AP_PMF_DISABLED: |
| 6545 | snprintf(buf, sizeof(buf), "cfg -a AP_PMF=0"); |
| 6546 | run_system(dut, buf); |
| 6547 | break; |
| 6548 | case AP_PMF_OPTIONAL: |
| 6549 | snprintf(buf, sizeof(buf), "cfg -a AP_PMF=1"); |
| 6550 | run_system(dut, buf); |
| 6551 | break; |
| 6552 | case AP_PMF_REQUIRED: |
| 6553 | snprintf(buf, sizeof(buf), "cfg -a AP_PMF=2"); |
| 6554 | run_system(dut, buf); |
| 6555 | break; |
| 6556 | } |
| 6557 | if (dut->ap_add_sha256) { |
| 6558 | snprintf(buf, sizeof(buf), "cfg -a AP_WPA_SHA256=1"); |
| 6559 | run_system(dut, buf); |
| 6560 | } else { |
| 6561 | snprintf(buf, sizeof(buf), "cfg -r AP_WPA_SHA256"); |
| 6562 | run_system(dut, buf); |
| 6563 | } |
| 6564 | |
| 6565 | if (dut->ap_hs2) |
| 6566 | run_system(dut, "cfg -a AP_HOTSPOT=1"); |
| 6567 | else |
| 6568 | run_system(dut, "cfg -r AP_HOTSPOT"); |
| 6569 | |
| 6570 | if (dut->ap_interworking) { |
| 6571 | snprintf(buf, sizeof(buf), "cfg -a AP_HOTSPOT_ANT=%d", |
| 6572 | dut->ap_access_net_type); |
| 6573 | run_system(dut, buf); |
| 6574 | snprintf(buf, sizeof(buf), "cfg -a AP_HOTSPOT_INTERNET=%d", |
| 6575 | dut->ap_internet); |
| 6576 | run_system(dut, buf); |
| 6577 | snprintf(buf, sizeof(buf), "cfg -a AP_HOTSPOT_VENUEGROUP=%d", |
| 6578 | dut->ap_venue_group); |
| 6579 | run_system(dut, buf); |
| 6580 | snprintf(buf, sizeof(buf), "cfg -a AP_HOTSPOT_VENUETYPE=%d", |
| 6581 | dut->ap_venue_type); |
| 6582 | run_system(dut, buf); |
| 6583 | snprintf(buf, sizeof(buf), "cfg -a AP_HOTSPOT_HESSID=%s", |
| 6584 | dut->ap_hessid); |
| 6585 | run_system(dut, buf); |
| 6586 | |
| 6587 | if (dut->ap_roaming_cons[0]) { |
| 6588 | char *second, *rc; |
| 6589 | rc = strdup(dut->ap_roaming_cons); |
| 6590 | if (rc == NULL) |
| 6591 | return 0; |
| 6592 | |
| 6593 | second = strchr(rc, ';'); |
| 6594 | if (second) |
| 6595 | *second++ = '\0'; |
| 6596 | |
| 6597 | snprintf(buf, sizeof(buf), |
| 6598 | "cfg -a AP_HOTSPOT_ROAMINGCONSORTIUM=%s", rc); |
| 6599 | run_system(dut, buf); |
| 6600 | |
| 6601 | if (second) { |
| 6602 | snprintf(buf, sizeof(buf), |
| 6603 | "cfg -a AP_HOTSPOT_ROAMINGCONSORTIUM2" |
| 6604 | "=%s", second); |
| 6605 | run_system(dut, buf); |
| 6606 | } |
| 6607 | free(rc); |
| 6608 | } else { |
| 6609 | run_system(dut, "cfg -r AP_HOTSPOT_ROAMINGCONSORTIUM"); |
| 6610 | run_system(dut, |
| 6611 | "cfg -r AP_HOTSPOT_ROAMINGCONSORTIUM2"); |
| 6612 | } |
| 6613 | } else { |
| 6614 | run_system(dut, "cfg -r AP_HOTSPOT_ANT"); |
| 6615 | run_system(dut, "cfg -r AP_HOTSPOT_INTERNET"); |
| 6616 | run_system(dut, "cfg -r AP_HOTSPOT_VENUEGROUP"); |
| 6617 | run_system(dut, "cfg -r AP_HOTSPOT_VENUETYPE"); |
| 6618 | run_system(dut, "cfg -r AP_HOTSPOT_HESSID"); |
| 6619 | run_system(dut, "cfg -r AP_HOTSPOT_ROAMINGCONSORTIUM"); |
| 6620 | run_system(dut, "cfg -r AP_HOTSPOT_ROAMINGCONSORTIUM2"); |
| 6621 | } |
| 6622 | |
| 6623 | if (dut->ap_proxy_arp) |
| 6624 | run_system(dut, "cfg -a IEEE80211V_PROXYARP=1"); |
| 6625 | else |
| 6626 | run_system(dut, "cfg -a IEEE80211V_PROXYARP=0"); |
| 6627 | if (dut->ap_dgaf_disable) |
| 6628 | run_system(dut, "cfg -a AP_HOTSPOT_DISABLE_DGAF=1"); |
| 6629 | else |
| 6630 | run_system(dut, "cfg -r AP_HOTSPOT_DISABLE_DGAF"); |
| 6631 | |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 6632 | if (strlen(dut->ap_tag_ssid[0])) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6633 | snprintf(buf, sizeof(buf), |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 6634 | "cfg -a AP_SSID_2=%s", dut->ap_tag_ssid[0]); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6635 | run_system(dut, buf); |
| 6636 | |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 6637 | if (dut->ap_tag_key_mgmt[0] == AP2_OSEN) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6638 | run_system(dut, "cfg -a AP_SECMODE_2=WPA"); |
| 6639 | run_system(dut, "cfg -a AP_SECFILE_2=OSEN"); |
| 6640 | |
Jouni Malinen | 3aa7286 | 2019-05-29 23:14:51 +0300 | [diff] [blame] | 6641 | res = snprintf(buf, sizeof(buf), |
| 6642 | "cfg -a AP_AUTH_SERVER_2=%s", |
| 6643 | dut->ap2_radius_ipaddr); |
| 6644 | if (res < 0 || res >= sizeof(buf)) |
| 6645 | return ERROR_SEND_STATUS; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6646 | run_system(dut, buf); |
| 6647 | |
Jouni Malinen | 3aa7286 | 2019-05-29 23:14:51 +0300 | [diff] [blame] | 6648 | res = snprintf(buf, sizeof(buf), |
| 6649 | "cfg -a AP_AUTH_PORT_2=%d", |
| 6650 | dut->ap2_radius_port); |
| 6651 | if (res < 0 || res >= sizeof(buf)) |
| 6652 | return ERROR_SEND_STATUS; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6653 | run_system(dut, buf); |
| 6654 | |
Jouni Malinen | 3aa7286 | 2019-05-29 23:14:51 +0300 | [diff] [blame] | 6655 | res = snprintf(buf, sizeof(buf), |
| 6656 | "cfg -a AP_AUTH_SECRET_2=%s", |
| 6657 | dut->ap2_radius_password); |
| 6658 | if (res < 0 || res >= sizeof(buf)) |
| 6659 | return ERROR_SEND_STATUS; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6660 | run_system(dut, buf); |
| 6661 | } else { |
| 6662 | run_system(dut, "cfg -a AP_SECMODE_2=None"); |
| 6663 | run_system(dut, "cfg -r AP_AUTH_SERVER_2"); |
| 6664 | run_system(dut, "cfg -r AP_AUTH_PORT_2"); |
| 6665 | run_system(dut, "cfg -r AP_AUTH_SECRET_2"); |
| 6666 | } |
| 6667 | |
| 6668 | run_system(dut, "cfg -a AP_STARTMODE=multi"); |
| 6669 | } |
| 6670 | |
| 6671 | run_system(dut, "cfg -c"); |
| 6672 | |
| 6673 | sigma_dut_print(dut, DUT_MSG_INFO, "Starting AP"); |
| 6674 | if (system("apup") != 0) { |
| 6675 | /* to be debugged why apup returns error |
| 6676 | send_resp(dut, conn, SIGMA_ERROR, |
| 6677 | "errorCode,apup failed"); |
| 6678 | return 0; |
| 6679 | */ |
| 6680 | } |
| 6681 | sigma_dut_print(dut, DUT_MSG_INFO, "AP started"); |
| 6682 | |
| 6683 | if (dut->ap_key_mgmt != AP_OPEN) { |
| 6684 | int res; |
| 6685 | /* allow some time for hostapd to start before returning |
| 6686 | * success */ |
| 6687 | usleep(500000); |
| 6688 | if (run_hostapd_cli(dut, "ping") != 0) { |
| 6689 | send_resp(dut, conn, SIGMA_ERROR, |
| 6690 | "errorCode,Failed to talk to hostapd"); |
| 6691 | return 0; |
| 6692 | } |
| 6693 | |
| 6694 | if (dut->ap_hs2 && !dut->ap_anqpserver) { |
| 6695 | /* the cfg app doesn't like ";" in the variables */ |
| 6696 | res = ath_ap_append_hostapd_conf(dut); |
| 6697 | if (res < 0) |
| 6698 | return res; |
| 6699 | |
| 6700 | /* wait for hostapd to be ready */ |
| 6701 | usleep(500000); |
| 6702 | if (run_hostapd_cli(dut, "ping") != 0) { |
| 6703 | send_resp(dut, conn, SIGMA_ERROR, |
| 6704 | "errorCode,Failed to talk to " |
| 6705 | "hostapd"); |
| 6706 | return 0; |
| 6707 | } |
| 6708 | } |
| 6709 | } |
| 6710 | |
| 6711 | ath_ap_set_params(dut); |
| 6712 | |
| 6713 | if (dut->ap_anqpserver) |
| 6714 | return cmd_ath_ap_anqpserver_start(dut); |
| 6715 | |
| 6716 | if (dut->ap2_proxy_arp) |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 6717 | run_iwpriv(dut, ifname, "proxy_arp 1"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6718 | |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 6719 | if (dut->ap_allow_vht_wep || dut->ap_allow_vht_tkip) |
| 6720 | run_iwpriv(dut, ifname, "htweptkip 1"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6721 | |
| 6722 | return 1; |
| 6723 | } |
| 6724 | |
| 6725 | |
| 6726 | static int set_ebtables_proxy_arp(struct sigma_dut *dut, const char *chain, |
| 6727 | const char *ifname) |
| 6728 | { |
| 6729 | char buf[200]; |
| 6730 | |
| 6731 | if (!chain || !ifname) |
| 6732 | return -2; |
| 6733 | |
| 6734 | snprintf(buf, sizeof(buf), "ebtables -P %s ACCEPT", chain); |
| 6735 | if (system(buf) != 0) { |
| 6736 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 6737 | "Failed to set ebtables rules, RULE-1, %s", |
| 6738 | chain); |
| 6739 | return -2; |
| 6740 | } |
| 6741 | |
| 6742 | snprintf(buf, sizeof(buf), |
| 6743 | "ebtables -A %s -p ARP -d Broadcast -o %s -j DROP", |
| 6744 | chain, ifname); |
| 6745 | if (system(buf) != 0) { |
| 6746 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 6747 | "Failed to set ebtables rules, RULE-2, %s", |
| 6748 | chain); |
| 6749 | return -2; |
| 6750 | } |
| 6751 | |
| 6752 | snprintf(buf, sizeof(buf), |
| 6753 | "ebtables -A %s -d Multicast -p IPv6 --ip6-protocol ipv6-icmp --ip6-icmp-type neighbor-solicitation -o %s -j DROP", |
| 6754 | chain, ifname); |
| 6755 | if (system(buf) != 0) { |
| 6756 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 6757 | "Failed to set ebtables rules, RULE-3, %s", |
| 6758 | chain); |
| 6759 | return -2; |
| 6760 | } |
| 6761 | |
| 6762 | snprintf(buf, sizeof(buf), |
| 6763 | "ebtables -A %s -d Multicast -p IPv6 --ip6-protocol ipv6-icmp --ip6-icmp-type neighbor-advertisement -o %s -j DROP", |
| 6764 | chain, ifname); |
| 6765 | if (system(buf) != 0) { |
| 6766 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 6767 | "Failed to set ebtables rules, RULE-4, %s", |
| 6768 | chain); |
| 6769 | return -2; |
| 6770 | } |
| 6771 | |
| 6772 | return 0; |
| 6773 | } |
| 6774 | |
| 6775 | |
| 6776 | static int set_ebtables_disable_dgaf(struct sigma_dut *dut, |
| 6777 | const char *chain, |
| 6778 | const char *ifname) |
| 6779 | { |
| 6780 | char buf[200]; |
| 6781 | |
| 6782 | if (!chain || !ifname) |
| 6783 | return -2; |
| 6784 | |
| 6785 | snprintf(buf, sizeof(buf), "ebtables -P %s ACCEPT", chain); |
| 6786 | if (system(buf) != 0) { |
| 6787 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 6788 | "Failed to set ebtables rules, RULE-5, %s", |
| 6789 | chain); |
| 6790 | return -2; |
| 6791 | } |
| 6792 | |
| 6793 | snprintf(buf, sizeof(buf), |
| 6794 | "ebtables -A %s -p ARP -d Broadcast -o %s -j DROP", |
| 6795 | chain, ifname); |
| 6796 | if (system(buf) != 0) { |
| 6797 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 6798 | "Failed to set ebtables rules, RULE-6, %s", |
| 6799 | chain); |
| 6800 | return -2; |
| 6801 | } |
| 6802 | |
| 6803 | snprintf(buf, sizeof(buf), |
| 6804 | "ebtables -A %s -p IPv4 -d Multicast -o %s -j DROP", |
| 6805 | chain, ifname); |
| 6806 | if (system(buf) != 0) { |
| 6807 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 6808 | "Failed to set ebtables rules, RULE-7, %s", |
| 6809 | chain); |
| 6810 | return -2; |
| 6811 | } |
| 6812 | |
| 6813 | snprintf(buf, sizeof(buf), |
| 6814 | "ebtables -A %s -p IPv6 -d Multicast -o %s -j DROP", |
| 6815 | chain, ifname); |
| 6816 | if (system(buf) != 0) { |
| 6817 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 6818 | "Failed to set ebtables rules, RULE-8, %s", |
| 6819 | chain); |
| 6820 | return -2; |
| 6821 | } |
| 6822 | |
| 6823 | return 0; |
| 6824 | } |
| 6825 | |
| 6826 | |
Jouni Malinen | dbbc2c4 | 2018-11-14 23:55:41 +0200 | [diff] [blame] | 6827 | static void set_ebtables_forward_drop(struct sigma_dut *dut, |
| 6828 | const char *ifname, const char *ifname2) |
| 6829 | { |
| 6830 | char buf[128]; |
| 6831 | |
| 6832 | snprintf(buf, sizeof(buf), "ebtables -A FORWARD -i %s -o %s -j DROP", |
| 6833 | ifname, ifname2); |
| 6834 | if (system(buf) != 0) |
| 6835 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 6836 | "Failed to set ebtables rule"); |
| 6837 | |
| 6838 | snprintf(buf, sizeof(buf), "ebtables -A FORWARD -i %s -o %s -j DROP", |
| 6839 | ifname2, ifname); |
| 6840 | if (system(buf) != 0) |
| 6841 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 6842 | "Failed to set ebtables rule"); |
| 6843 | } |
| 6844 | |
| 6845 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6846 | static int check_channel(int channel) |
| 6847 | { |
| 6848 | int channel_list[] = { 36, 40, 44, 48, 52, 60, 64, 100, 104, 108, 112, |
| 6849 | 116, 120, 124, 128, 132, 140, 144, 149, 153, 157, |
| 6850 | 161, 165 }; |
| 6851 | int num_chan = sizeof(channel_list) / sizeof(int); |
| 6852 | int i; |
| 6853 | |
| 6854 | for (i = 0; i < num_chan; i++) { |
| 6855 | if (channel == channel_list[i]) |
| 6856 | return i; |
| 6857 | } |
| 6858 | |
| 6859 | return -1; |
| 6860 | } |
| 6861 | |
| 6862 | |
| 6863 | static int get_oper_centr_freq_seq_idx(int chwidth, int channel) |
| 6864 | { |
| 6865 | int ch_base; |
| 6866 | int period; |
| 6867 | |
| 6868 | if (check_channel(channel) < 0) |
| 6869 | return -1; |
| 6870 | |
| 6871 | if (channel >= 36 && channel <= 64) |
| 6872 | ch_base = 36; |
| 6873 | else if (channel >= 100 && channel <= 144) |
| 6874 | ch_base = 100; |
| 6875 | else |
| 6876 | ch_base = 149; |
| 6877 | |
| 6878 | period = channel % ch_base * 5 / chwidth; |
| 6879 | return ch_base + period * chwidth / 5 + (chwidth - 20) / 10; |
| 6880 | } |
| 6881 | |
| 6882 | |
| 6883 | static int is_ht40plus_chan(int chan) |
| 6884 | { |
| 6885 | return chan == 36 || chan == 44 || chan == 52 || chan == 60 || |
| 6886 | chan == 100 || chan == 108 || chan == 116 || chan == 124 || |
| 6887 | chan == 132 || chan == 149 || chan == 157; |
| 6888 | } |
| 6889 | |
| 6890 | |
| 6891 | static int is_ht40minus_chan(int chan) |
| 6892 | { |
| 6893 | return chan == 40 || chan == 48 || chan == 56 || chan == 64 || |
| 6894 | chan == 104 || chan == 112 || chan == 120 || chan == 128 || |
| 6895 | chan == 136 || chan == 153 || chan == 161; |
| 6896 | } |
| 6897 | |
| 6898 | |
Mohammed Shafi Shajakhan | b53d8f9 | 2017-02-28 09:05:15 +0530 | [diff] [blame] | 6899 | static int get_5g_channel_freq(int chan) |
| 6900 | { |
| 6901 | return 5000 + chan * 5; |
| 6902 | } |
| 6903 | |
| 6904 | |
Jouni Malinen | 3d633da | 2017-09-14 22:19:21 +0300 | [diff] [blame] | 6905 | static const char * hostapd_cipher_name(enum ap_cipher cipher) |
| 6906 | { |
| 6907 | switch (cipher) { |
| 6908 | case AP_CCMP: |
| 6909 | return "CCMP"; |
| 6910 | case AP_TKIP: |
| 6911 | return "TKIP"; |
| 6912 | case AP_CCMP_TKIP: |
| 6913 | return "CCMP TKIP"; |
| 6914 | case AP_GCMP_256: |
| 6915 | return "GCMP-256"; |
| 6916 | case AP_GCMP_128: |
| 6917 | return "GCMP"; |
| 6918 | case AP_CCMP_256: |
| 6919 | return "CCMP-256"; |
Jouni Malinen | d538c78 | 2017-11-17 12:13:04 +0200 | [diff] [blame] | 6920 | case AP_CCMP_128_GCMP_256: |
| 6921 | return "CCMP GCMP-256"; |
Jouni Malinen | 3d633da | 2017-09-14 22:19:21 +0300 | [diff] [blame] | 6922 | default: |
| 6923 | return "UNKNOWN"; |
| 6924 | } |
| 6925 | } |
| 6926 | |
| 6927 | |
| 6928 | static const char * |
| 6929 | hostapd_group_mgmt_cipher_name(enum ap_group_mgmt_cipher cipher) |
| 6930 | { |
| 6931 | switch (cipher) { |
| 6932 | case AP_BIP_GMAC_256: |
Jouni Malinen | 57887a2 | 2017-10-10 20:43:25 +0300 | [diff] [blame] | 6933 | return "BIP-GMAC-256"; |
Jouni Malinen | 3d633da | 2017-09-14 22:19:21 +0300 | [diff] [blame] | 6934 | case AP_BIP_CMAC_256: |
| 6935 | return "BIP-CMAC-256"; |
| 6936 | case AP_BIP_GMAC_128: |
| 6937 | return "BIP-GMAC-128"; |
| 6938 | case AP_BIP_CMAC_128: |
| 6939 | return "AES-128-CMAC"; |
| 6940 | default: |
| 6941 | return "UNKNOWN"; |
| 6942 | } |
| 6943 | } |
| 6944 | |
| 6945 | |
Alexei Avshalom Lazar | bc180dc | 2018-12-18 16:01:14 +0200 | [diff] [blame] | 6946 | static int ap_set_60g_ese(struct sigma_dut *dut, int count, |
| 6947 | struct sigma_ese_alloc *allocs) |
| 6948 | { |
Jouni Malinen | 016ae6c | 2019-11-04 17:00:01 +0200 | [diff] [blame] | 6949 | switch (get_driver_type(dut)) { |
Alexei Avshalom Lazar | bc180dc | 2018-12-18 16:01:14 +0200 | [diff] [blame] | 6950 | #ifdef __linux__ |
| 6951 | case DRIVER_WIL6210: |
| 6952 | return wil6210_set_ese(dut, count, allocs); |
| 6953 | #endif /* __linux__ */ |
| 6954 | default: |
| 6955 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 6956 | "Unsupported ap_set_60g_ese with the current driver"); |
| 6957 | return -1; |
| 6958 | } |
| 6959 | } |
| 6960 | |
| 6961 | |
Alexei Avshalom Lazar | aad97b0 | 2018-12-18 16:01:23 +0200 | [diff] [blame] | 6962 | static int ap_set_force_mcs(struct sigma_dut *dut, int force, int mcs) |
| 6963 | { |
Jouni Malinen | 016ae6c | 2019-11-04 17:00:01 +0200 | [diff] [blame] | 6964 | switch (get_driver_type(dut)) { |
Alexei Avshalom Lazar | aad97b0 | 2018-12-18 16:01:23 +0200 | [diff] [blame] | 6965 | #ifdef __linux__ |
| 6966 | case DRIVER_WIL6210: |
| 6967 | return wil6210_set_force_mcs(dut, force, mcs); |
| 6968 | #endif /* __linux__ */ |
| 6969 | default: |
| 6970 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 6971 | "Unsupported ap_set_force_mcs with the current driver"); |
| 6972 | return -1; |
| 6973 | } |
| 6974 | } |
| 6975 | |
| 6976 | |
Jouni Malinen | f722271 | 2019-06-13 01:50:21 +0300 | [diff] [blame] | 6977 | enum sigma_cmd_result cmd_ap_config_commit(struct sigma_dut *dut, |
| 6978 | struct sigma_conn *conn, |
| 6979 | struct sigma_cmd *cmd) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6980 | { |
| 6981 | /* const char *name = get_param(cmd, "NAME"); */ |
| 6982 | FILE *f; |
| 6983 | const char *ifname; |
| 6984 | char buf[500]; |
| 6985 | char path[100]; |
| 6986 | enum driver_type drv; |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 6987 | const char *key_mgmt; |
Srinivas Dasari | a1deeaa | 2018-06-18 22:54:04 +0530 | [diff] [blame] | 6988 | #ifdef ANDROID |
| 6989 | struct group *gr; |
| 6990 | #endif /* ANDROID */ |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6991 | |
Jouni Malinen | 016ae6c | 2019-11-04 17:00:01 +0200 | [diff] [blame] | 6992 | drv = get_driver_type(dut); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6993 | |
| 6994 | if (dut->mode == SIGMA_MODE_STATION) { |
| 6995 | stop_sta_mode(dut); |
| 6996 | sleep(1); |
| 6997 | } |
| 6998 | |
| 6999 | if (dut->mode == SIGMA_MODE_SNIFFER && dut->sniffer_ifname) { |
| 7000 | snprintf(buf, sizeof(buf), "ifconfig %s down", |
| 7001 | dut->sniffer_ifname); |
| 7002 | if (system(buf) != 0) { |
| 7003 | sigma_dut_print(dut, DUT_MSG_INFO, |
| 7004 | "Failed to run '%s'", buf); |
| 7005 | } |
| 7006 | snprintf(buf, sizeof(buf), "iw dev %s set type station", |
| 7007 | dut->sniffer_ifname); |
| 7008 | if (system(buf) != 0) { |
| 7009 | sigma_dut_print(dut, DUT_MSG_INFO, |
| 7010 | "Failed to run '%s'", buf); |
| 7011 | } |
| 7012 | } |
| 7013 | |
| 7014 | dut->mode = SIGMA_MODE_AP; |
| 7015 | |
| 7016 | if (drv == DRIVER_ATHEROS) |
| 7017 | return cmd_ath_ap_config_commit(dut, conn, cmd); |
| 7018 | if (drv == DRIVER_WCN) |
| 7019 | return cmd_wcn_ap_config_commit(dut, conn, cmd); |
| 7020 | if (drv == DRIVER_OPENWRT) |
| 7021 | return cmd_owrt_ap_config_commit(dut, conn, cmd); |
| 7022 | |
| 7023 | f = fopen(SIGMA_TMPDIR "/sigma_dut-ap.conf", "w"); |
| 7024 | if (f == NULL) { |
| 7025 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 7026 | "%s: Failed to open sigma_dut-ap.conf", |
| 7027 | __func__); |
| 7028 | return -2; |
| 7029 | } |
| 7030 | switch (dut->ap_mode) { |
| 7031 | case AP_11g: |
| 7032 | case AP_11b: |
| 7033 | case AP_11ng: |
Pradeep Reddy Potteti | 08eaeba | 2017-06-14 12:43:19 +0530 | [diff] [blame] | 7034 | ifname = (drv == DRIVER_MAC80211) ? "wlan0" : "ath0"; |
| 7035 | if ((drv == DRIVER_QNXNTO || drv == DRIVER_LINUX_WCN) && |
Jouni Malinen | d209548 | 2019-11-04 17:10:43 +0200 | [diff] [blame] | 7036 | dut->main_ifname) |
Jouni Malinen | 5ea3092 | 2019-11-04 17:39:25 +0200 | [diff] [blame] | 7037 | ifname = get_main_ifname(dut); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7038 | fprintf(f, "hw_mode=g\n"); |
| 7039 | break; |
| 7040 | case AP_11a: |
| 7041 | case AP_11na: |
| 7042 | case AP_11ac: |
Pradeep Reddy Potteti | 08eaeba | 2017-06-14 12:43:19 +0530 | [diff] [blame] | 7043 | if (drv == DRIVER_QNXNTO || drv == DRIVER_LINUX_WCN) { |
Jouni Malinen | d209548 | 2019-11-04 17:10:43 +0200 | [diff] [blame] | 7044 | if (dut->main_ifname) |
Jouni Malinen | 5ea3092 | 2019-11-04 17:39:25 +0200 | [diff] [blame] | 7045 | ifname = get_main_ifname(dut); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7046 | else |
| 7047 | ifname = "wlan0"; |
Pradeep Reddy Potteti | 08eaeba | 2017-06-14 12:43:19 +0530 | [diff] [blame] | 7048 | } else if (drv == DRIVER_MAC80211) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7049 | if (if_nametoindex("wlan1") > 0) |
| 7050 | ifname = "wlan1"; |
| 7051 | else |
| 7052 | ifname = "wlan0"; |
| 7053 | } else { |
Jouni Malinen | 016ae6c | 2019-11-04 17:00:01 +0200 | [diff] [blame] | 7054 | ifname = get_main_ifname(dut); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7055 | } |
| 7056 | fprintf(f, "hw_mode=a\n"); |
| 7057 | break; |
Alexei Avshalom Lazar | 2712cc8 | 2018-12-23 16:29:14 +0200 | [diff] [blame] | 7058 | case AP_11ad: |
Jouni Malinen | 016ae6c | 2019-11-04 17:00:01 +0200 | [diff] [blame] | 7059 | ifname = get_main_ifname(dut); |
Alexei Avshalom Lazar | 2712cc8 | 2018-12-23 16:29:14 +0200 | [diff] [blame] | 7060 | fprintf(f, "hw_mode=ad\n"); |
| 7061 | break; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7062 | default: |
| 7063 | fclose(f); |
| 7064 | return -1; |
| 7065 | } |
Jouni Malinen | d6bf1b4 | 2017-06-23 17:51:01 +0300 | [diff] [blame] | 7066 | if (dut->hostapd_ifname) |
| 7067 | ifname = dut->hostapd_ifname; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7068 | |
Sreelakshmi Konamki | b692f10 | 2016-04-26 19:47:00 +0530 | [diff] [blame] | 7069 | if (drv == DRIVER_MAC80211 || drv == DRIVER_LINUX_WCN) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7070 | fprintf(f, "driver=nl80211\n"); |
| 7071 | |
Sreelakshmi Konamki | b692f10 | 2016-04-26 19:47:00 +0530 | [diff] [blame] | 7072 | if ((drv == DRIVER_MAC80211 || drv == DRIVER_QNXNTO || |
| 7073 | drv == DRIVER_LINUX_WCN) && |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7074 | (dut->ap_mode == AP_11ng || dut->ap_mode == AP_11na)) { |
Tamizh chelvam | 431c600 | 2017-03-07 17:07:16 +0530 | [diff] [blame] | 7075 | int ht40plus = 0, ht40minus = 0, tx_stbc = 0; |
| 7076 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7077 | fprintf(f, "ieee80211n=1\n"); |
Pradeep Reddy Potteti | bf8af29 | 2017-02-15 15:28:39 +0530 | [diff] [blame] | 7078 | if (dut->ap_mode == AP_11ng && |
| 7079 | (dut->ap_chwidth == AP_40 || |
| 7080 | (dut->ap_chwidth == AP_AUTO && |
| 7081 | dut->default_11ng_ap_chwidth == AP_40))) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7082 | if (dut->ap_channel >= 1 && dut->ap_channel <= 7) |
Tamizh chelvam | 431c600 | 2017-03-07 17:07:16 +0530 | [diff] [blame] | 7083 | ht40plus = 1; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7084 | else if (dut->ap_channel >= 8 && dut->ap_channel <= 11) |
Tamizh chelvam | 431c600 | 2017-03-07 17:07:16 +0530 | [diff] [blame] | 7085 | ht40minus = 1; |
| 7086 | fprintf(f, "obss_interval=300\n"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7087 | } |
| 7088 | |
| 7089 | /* configure ht_capab based on channel width */ |
| 7090 | if (dut->ap_mode == AP_11na && |
| 7091 | (dut->ap_chwidth == AP_40 || |
| 7092 | (dut->ap_chwidth == AP_AUTO && |
Pradeep Reddy Potteti | bf8af29 | 2017-02-15 15:28:39 +0530 | [diff] [blame] | 7093 | dut->default_11na_ap_chwidth == AP_40))) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7094 | if (is_ht40plus_chan(dut->ap_channel)) |
Tamizh chelvam | 431c600 | 2017-03-07 17:07:16 +0530 | [diff] [blame] | 7095 | ht40plus = 1; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7096 | else if (is_ht40minus_chan(dut->ap_channel)) |
Tamizh chelvam | 431c600 | 2017-03-07 17:07:16 +0530 | [diff] [blame] | 7097 | ht40minus = 1; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7098 | } |
Mohammed Shafi Shajakhan | 31d8a15 | 2016-06-02 20:10:55 +0530 | [diff] [blame] | 7099 | |
| 7100 | if (dut->ap_tx_stbc) |
Tamizh chelvam | 431c600 | 2017-03-07 17:07:16 +0530 | [diff] [blame] | 7101 | tx_stbc = 1; |
Mohammed Shafi Shajakhan | 31d8a15 | 2016-06-02 20:10:55 +0530 | [diff] [blame] | 7102 | |
Pradeep Reddy Potteti | 4b0cdee | 2017-03-15 12:37:33 +0530 | [diff] [blame] | 7103 | /* Overwrite the ht_capab with offset value if configured */ |
| 7104 | if (dut->ap_chwidth == AP_40 && |
| 7105 | dut->ap_chwidth_offset == SEC_CH_40ABOVE) { |
| 7106 | ht40plus = 1; |
| 7107 | ht40minus = 0; |
| 7108 | } else if (dut->ap_chwidth == AP_40 && |
| 7109 | dut->ap_chwidth_offset == SEC_CH_40BELOW) { |
| 7110 | ht40minus = 1; |
| 7111 | ht40plus = 0; |
| 7112 | } |
| 7113 | |
Tamizh chelvam | 431c600 | 2017-03-07 17:07:16 +0530 | [diff] [blame] | 7114 | fprintf(f, "ht_capab=%s%s%s\n", |
| 7115 | ht40plus ? "[HT40+]" : "", |
| 7116 | ht40minus ? "[HT40-]" : "", |
| 7117 | tx_stbc ? "[TX-STBC]" : ""); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7118 | } |
| 7119 | |
Sreelakshmi Konamki | b692f10 | 2016-04-26 19:47:00 +0530 | [diff] [blame] | 7120 | if ((drv == DRIVER_MAC80211 || drv == DRIVER_QNXNTO || |
| 7121 | drv == DRIVER_LINUX_WCN) && |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7122 | dut->ap_mode == AP_11ac) { |
Hu Wang | 2939210 | 2019-07-03 15:41:12 +0800 | [diff] [blame] | 7123 | int ht40plus = 0, ht40minus = 0; |
| 7124 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7125 | fprintf(f, "ieee80211ac=1\n" |
Hu Wang | 2939210 | 2019-07-03 15:41:12 +0800 | [diff] [blame] | 7126 | "ieee80211n=1\n"); |
| 7127 | |
| 7128 | /* configure ht_capab based on channel width */ |
| 7129 | if (dut->ap_chwidth != AP_20) { |
| 7130 | if (is_ht40plus_chan(dut->ap_channel)) |
| 7131 | ht40plus = 1; |
| 7132 | else if (is_ht40minus_chan(dut->ap_channel)) |
| 7133 | ht40minus = 1; |
| 7134 | |
| 7135 | fprintf(f, "ht_capab=%s%s\n", |
| 7136 | ht40plus ? "[HT40+]" : "", |
| 7137 | ht40minus ? "[HT40-]" : ""); |
| 7138 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7139 | } |
| 7140 | |
Sreelakshmi Konamki | b692f10 | 2016-04-26 19:47:00 +0530 | [diff] [blame] | 7141 | if ((drv == DRIVER_MAC80211 || drv == DRIVER_QNXNTO || |
| 7142 | drv == DRIVER_LINUX_WCN) && |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7143 | (dut->ap_mode == AP_11ac || dut->ap_mode == AP_11na)) { |
| 7144 | if (dut->ap_countrycode[0]) { |
| 7145 | fprintf(f, "country_code=%s\n", dut->ap_countrycode); |
| 7146 | fprintf(f, "ieee80211d=1\n"); |
| 7147 | fprintf(f, "ieee80211h=1\n"); |
| 7148 | } |
| 7149 | } |
| 7150 | |
| 7151 | fprintf(f, "interface=%s\n", ifname); |
| 7152 | if (dut->bridge) |
| 7153 | fprintf(f, "bridge=%s\n", dut->bridge); |
| 7154 | fprintf(f, "channel=%d\n", dut->ap_channel); |
| 7155 | |
| 7156 | if (sigma_hapd_ctrl) |
| 7157 | fprintf(f, "ctrl_interface=%s\n", sigma_hapd_ctrl); |
| 7158 | else |
| 7159 | fprintf(f, "ctrl_interface=/var/run/hostapd\n"); |
| 7160 | |
| 7161 | if (dut->ap_ssid[0]) |
| 7162 | fprintf(f, "ssid=%s\n", dut->ap_ssid); |
| 7163 | else |
| 7164 | fprintf(f, "ssid=QCA AP OOB\n"); |
| 7165 | if (dut->ap_bcnint) |
| 7166 | fprintf(f, "beacon_int=%d\n", dut->ap_bcnint); |
| 7167 | |
Jouni Malinen | da5f35b | 2019-03-26 00:25:53 +0200 | [diff] [blame] | 7168 | if (dut->ap_akm_values) { |
| 7169 | struct { |
| 7170 | int akm; |
| 7171 | const char *str; |
| 7172 | } akms[] = { |
| 7173 | { AKM_WPA_EAP, "WPA-EAP" }, |
| 7174 | { AKM_WPA_PSK, "WPA-PSK" }, |
| 7175 | { AKM_FT_EAP, "FT-EAP" }, |
| 7176 | { AKM_FT_PSK, "FT-PSK" }, |
| 7177 | { AKM_EAP_SHA256, "WPA-EAP-SHA256" }, |
| 7178 | { AKM_PSK_SHA256, "WPA-PSK-SHA256" }, |
| 7179 | { AKM_SAE, "SAE" }, |
| 7180 | { AKM_FT_SAE, "FT-SAE" }, |
| 7181 | { AKM_SUITE_B, "WPA-EAP-SUITE-B-192" }, |
| 7182 | { AKM_FT_SUITE_B, "FT-EAP-SHA384" }, |
| 7183 | { AKM_FILS_SHA256, "FILS-SHA256" }, |
| 7184 | { AKM_FILS_SHA384, "FILS-SHA384" }, |
| 7185 | { AKM_FT_FILS_SHA256, "FT-FILS-SHA256" }, |
| 7186 | { AKM_FT_FILS_SHA384, "FT-FILS-SHA384" }, |
| 7187 | }; |
Jouni Malinen | 8400c08 | 2019-04-26 13:26:07 +0300 | [diff] [blame] | 7188 | int first = 1; |
| 7189 | unsigned int i; |
Jouni Malinen | da5f35b | 2019-03-26 00:25:53 +0200 | [diff] [blame] | 7190 | |
| 7191 | fprintf(f, "wpa_key_mgmt="); |
| 7192 | for (i = 0; i < ARRAY_SIZE(akms); i++) { |
| 7193 | if (dut->ap_akm_values & (1 << akms[i].akm)) { |
| 7194 | fprintf(f, "%s%s", first ? "" : " ", |
| 7195 | akms[i].str); |
| 7196 | first = 0; |
| 7197 | } |
| 7198 | } |
| 7199 | fprintf(f, "\n"); |
| 7200 | /* TODO: mixed mode and WPAv1 only */ |
| 7201 | fprintf(f, "wpa=2\n"); |
| 7202 | fprintf(f, "wpa_pairwise=%s\n", |
| 7203 | hostapd_cipher_name(dut->ap_cipher)); |
| 7204 | if (dut->ap_group_cipher != AP_NO_GROUP_CIPHER_SET) |
| 7205 | fprintf(f, "group_cipher=%s\n", |
| 7206 | hostapd_cipher_name(dut->ap_group_cipher)); |
Jouni Malinen | 3e25541 | 2019-03-28 22:04:08 +0200 | [diff] [blame] | 7207 | if ((dut->ap_akm_values & |
| 7208 | ((1 << AKM_SAE) | (1 << AKM_FT_SAE))) && |
| 7209 | !(dut->ap_akm_values & |
| 7210 | ((1 << AKM_WPA_PSK) | (1 << AKM_FT_PSK))) && |
Jouni Malinen | da5f35b | 2019-03-26 00:25:53 +0200 | [diff] [blame] | 7211 | dut->ap_passphrase[0]) |
| 7212 | fprintf(f, "sae_password=%s\n", dut->ap_passphrase); |
| 7213 | else if (!dut->ap_passphrase[0] && dut->ap_psk[0]) |
| 7214 | fprintf(f, "wpa_psk=%s", dut->ap_psk); |
| 7215 | else if (dut->ap_passphrase[0]) |
| 7216 | fprintf(f, "wpa_passphrase=%s\n", dut->ap_passphrase); |
Jouni Malinen | 10ed9e7 | 2019-03-28 03:00:11 +0200 | [diff] [blame] | 7217 | if (dut->ap_akm_values & ((1 << AKM_WPA_EAP) | |
Jouni Malinen | e5393c3 | 2019-06-20 01:34:34 +0300 | [diff] [blame] | 7218 | (1 << AKM_FT_EAP) | |
Jouni Malinen | 10ed9e7 | 2019-03-28 03:00:11 +0200 | [diff] [blame] | 7219 | (1 << AKM_EAP_SHA256) | |
| 7220 | (1 << AKM_SUITE_B) | |
| 7221 | (1 << AKM_FT_SUITE_B) | |
| 7222 | (1 << AKM_FILS_SHA256) | |
| 7223 | (1 << AKM_FILS_SHA384) | |
| 7224 | (1 << AKM_FT_FILS_SHA256) | |
| 7225 | (1 << AKM_FT_FILS_SHA384))) { |
| 7226 | fprintf(f, "ieee8021x=1\n"); |
| 7227 | fprintf(f, "auth_server_addr=%s\n", |
| 7228 | dut->ap_radius_ipaddr); |
| 7229 | if (dut->ap_radius_port) |
| 7230 | fprintf(f, "auth_server_port=%d\n", |
| 7231 | dut->ap_radius_port); |
| 7232 | fprintf(f, "auth_server_shared_secret=%s\n", |
| 7233 | dut->ap_radius_password); |
| 7234 | } |
Jouni Malinen | da5f35b | 2019-03-26 00:25:53 +0200 | [diff] [blame] | 7235 | goto skip_key_mgmt; |
| 7236 | } |
| 7237 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7238 | switch (dut->ap_key_mgmt) { |
| 7239 | case AP_OPEN: |
| 7240 | if (dut->ap_cipher == AP_WEP) |
| 7241 | fprintf(f, "wep_key0=%s\n", dut->ap_wepkey); |
| 7242 | break; |
| 7243 | case AP_WPA2_PSK: |
| 7244 | case AP_WPA2_PSK_MIXED: |
| 7245 | case AP_WPA_PSK: |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 7246 | case AP_WPA2_SAE: |
| 7247 | case AP_WPA2_PSK_SAE: |
Jouni Malinen | 6be21c8 | 2018-08-01 18:47:24 +0300 | [diff] [blame] | 7248 | case AP_WPA2_PSK_SHA256: |
| 7249 | case AP_WPA2_FT_PSK: |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 7250 | if (dut->ap_key_mgmt == AP_WPA2_PSK || |
| 7251 | dut->ap_key_mgmt == AP_WPA2_SAE || |
Jouni Malinen | 6be21c8 | 2018-08-01 18:47:24 +0300 | [diff] [blame] | 7252 | dut->ap_key_mgmt == AP_WPA2_PSK_SAE || |
| 7253 | dut->ap_key_mgmt == AP_WPA2_PSK_SHA256 || |
| 7254 | dut->ap_key_mgmt == AP_WPA2_FT_PSK) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7255 | fprintf(f, "wpa=2\n"); |
| 7256 | else if (dut->ap_key_mgmt == AP_WPA2_PSK_MIXED) |
| 7257 | fprintf(f, "wpa=3\n"); |
| 7258 | else |
| 7259 | fprintf(f, "wpa=1\n"); |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 7260 | if (dut->ap_key_mgmt == AP_WPA2_SAE) |
| 7261 | key_mgmt = "SAE"; |
| 7262 | else if (dut->ap_key_mgmt == AP_WPA2_PSK_SAE) |
| 7263 | key_mgmt = "WPA-PSK SAE"; |
| 7264 | else |
| 7265 | key_mgmt = "WPA-PSK"; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7266 | switch (dut->ap_pmf) { |
| 7267 | case AP_PMF_DISABLED: |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 7268 | fprintf(f, "wpa_key_mgmt=%s%s\n", key_mgmt, |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7269 | dut->ap_add_sha256 ? " WPA-PSK-SHA256" : ""); |
| 7270 | break; |
| 7271 | case AP_PMF_OPTIONAL: |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 7272 | fprintf(f, "wpa_key_mgmt=%s%s\n", key_mgmt, |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7273 | dut->ap_add_sha256 ? " WPA-PSK-SHA256" : ""); |
| 7274 | break; |
| 7275 | case AP_PMF_REQUIRED: |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 7276 | if (dut->ap_key_mgmt == AP_WPA2_SAE) |
| 7277 | key_mgmt = "SAE"; |
| 7278 | else if (dut->ap_key_mgmt == AP_WPA2_PSK_SAE) |
| 7279 | key_mgmt = "WPA-PSK-SHA256 SAE"; |
| 7280 | else |
| 7281 | key_mgmt = "WPA-PSK-SHA256"; |
| 7282 | fprintf(f, "wpa_key_mgmt=%s\n", key_mgmt); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7283 | break; |
| 7284 | } |
Jouni Malinen | 6be21c8 | 2018-08-01 18:47:24 +0300 | [diff] [blame] | 7285 | if (dut->ap_key_mgmt == AP_WPA2_PSK_SHA256) |
| 7286 | fprintf(f, "wpa_key_mgmt=WPA-PSK-SHA256\n"); |
| 7287 | else if (dut->ap_key_mgmt == AP_WPA2_FT_PSK) |
| 7288 | fprintf(f, "wpa_key_mgmt=FT-PSK\n"); |
Jouni Malinen | 2ba2449 | 2017-11-17 12:43:59 +0200 | [diff] [blame] | 7289 | fprintf(f, "wpa_pairwise=%s\n", |
| 7290 | hostapd_cipher_name(dut->ap_cipher)); |
| 7291 | if (dut->ap_group_cipher != AP_NO_GROUP_CIPHER_SET) |
| 7292 | fprintf(f, "group_cipher=%s\n", |
| 7293 | hostapd_cipher_name(dut->ap_group_cipher)); |
Jouni Malinen | 2126f42 | 2017-10-11 23:24:33 +0300 | [diff] [blame] | 7294 | if (dut->ap_key_mgmt == AP_WPA2_SAE) |
| 7295 | fprintf(f, "sae_password=%s\n", dut->ap_passphrase); |
Jouni Malinen | 6337062 | 2017-11-18 17:47:13 +0200 | [diff] [blame] | 7296 | else if (!dut->ap_passphrase[0] && dut->ap_psk[0]) |
| 7297 | fprintf(f, "wpa_psk=%s", dut->ap_psk); |
Jouni Malinen | 2126f42 | 2017-10-11 23:24:33 +0300 | [diff] [blame] | 7298 | else |
| 7299 | fprintf(f, "wpa_passphrase=%s\n", dut->ap_passphrase); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7300 | break; |
| 7301 | case AP_WPA2_EAP: |
| 7302 | case AP_WPA2_EAP_MIXED: |
| 7303 | case AP_WPA_EAP: |
Jouni Malinen | 4cf699f | 2018-06-19 00:46:27 +0300 | [diff] [blame] | 7304 | case AP_WPA2_EAP_OSEN: |
Jouni Malinen | 6be21c8 | 2018-08-01 18:47:24 +0300 | [diff] [blame] | 7305 | case AP_WPA2_EAP_SHA256: |
| 7306 | case AP_WPA2_FT_EAP: |
| 7307 | case AP_WPA2_ENT_FT_EAP: |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7308 | fprintf(f, "ieee8021x=1\n"); |
Jouni Malinen | 4cf699f | 2018-06-19 00:46:27 +0300 | [diff] [blame] | 7309 | if (dut->ap_key_mgmt == AP_WPA2_EAP || |
Jouni Malinen | 6be21c8 | 2018-08-01 18:47:24 +0300 | [diff] [blame] | 7310 | dut->ap_key_mgmt == AP_WPA2_EAP_OSEN || |
| 7311 | dut->ap_key_mgmt == AP_WPA2_EAP_SHA256 || |
| 7312 | dut->ap_key_mgmt == AP_WPA2_FT_EAP || |
| 7313 | dut->ap_key_mgmt == AP_WPA2_ENT_FT_EAP) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7314 | fprintf(f, "wpa=2\n"); |
| 7315 | else if (dut->ap_key_mgmt == AP_WPA2_EAP_MIXED) |
| 7316 | fprintf(f, "wpa=3\n"); |
| 7317 | else |
| 7318 | fprintf(f, "wpa=1\n"); |
| 7319 | switch (dut->ap_pmf) { |
| 7320 | case AP_PMF_DISABLED: |
| 7321 | fprintf(f, "wpa_key_mgmt=WPA-EAP%s\n", |
| 7322 | dut->ap_add_sha256 ? " WPA-EAP-SHA256" : ""); |
| 7323 | break; |
| 7324 | case AP_PMF_OPTIONAL: |
Jouni Malinen | 4cf699f | 2018-06-19 00:46:27 +0300 | [diff] [blame] | 7325 | fprintf(f, "wpa_key_mgmt=WPA-EAP%s%s\n", |
| 7326 | dut->ap_add_sha256 ? " WPA-EAP-SHA256" : "", |
| 7327 | dut->ap_key_mgmt == AP_WPA2_EAP_OSEN ? " OSEN" : |
| 7328 | ""); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7329 | break; |
| 7330 | case AP_PMF_REQUIRED: |
Jouni Malinen | 4cf699f | 2018-06-19 00:46:27 +0300 | [diff] [blame] | 7331 | fprintf(f, "wpa_key_mgmt=WPA-EAP-SHA256%s\n", |
| 7332 | dut->ap_key_mgmt == AP_WPA2_EAP_OSEN ? " OSEN" : |
| 7333 | ""); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7334 | break; |
| 7335 | } |
Jouni Malinen | 6be21c8 | 2018-08-01 18:47:24 +0300 | [diff] [blame] | 7336 | if (dut->ap_key_mgmt == AP_WPA2_EAP_SHA256) |
| 7337 | fprintf(f, "wpa_key_mgmt=WPA-EAP-SHA256\n"); |
| 7338 | else if (dut->ap_key_mgmt == AP_WPA2_FT_EAP) |
| 7339 | fprintf(f, "wpa_key_mgmt=FT-EAP\n"); |
| 7340 | else if (dut->ap_key_mgmt == AP_WPA2_ENT_FT_EAP) |
| 7341 | fprintf(f, "wpa_key_mgmt=FT-EAP WPA-EAP\n"); |
Jouni Malinen | 2ba2449 | 2017-11-17 12:43:59 +0200 | [diff] [blame] | 7342 | fprintf(f, "wpa_pairwise=%s\n", |
| 7343 | hostapd_cipher_name(dut->ap_cipher)); |
| 7344 | if (dut->ap_group_cipher != AP_NO_GROUP_CIPHER_SET) |
| 7345 | fprintf(f, "group_cipher=%s\n", |
| 7346 | hostapd_cipher_name(dut->ap_group_cipher)); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7347 | fprintf(f, "auth_server_addr=%s\n", dut->ap_radius_ipaddr); |
| 7348 | if (dut->ap_radius_port) |
| 7349 | fprintf(f, "auth_server_port=%d\n", |
| 7350 | dut->ap_radius_port); |
| 7351 | fprintf(f, "auth_server_shared_secret=%s\n", |
| 7352 | dut->ap_radius_password); |
Jouni Malinen | 1a2bc99 | 2018-06-22 11:50:59 +0300 | [diff] [blame] | 7353 | if (dut->program == PROGRAM_HS2_R3) { |
| 7354 | fprintf(f, "radius_das_port=3799\n"); |
| 7355 | fprintf(f, "radius_das_client=0.0.0.0 %s\n", |
| 7356 | dut->ap_radius_password); |
| 7357 | fprintf(f, "radius_das_require_event_timestamp=1\n"); |
| 7358 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7359 | break; |
Jouni Malinen | ad395a2 | 2017-09-01 21:13:46 +0300 | [diff] [blame] | 7360 | case AP_SUITEB: |
| 7361 | fprintf(f, "ieee8021x=1\n"); |
| 7362 | fprintf(f, "wpa=2\n"); |
| 7363 | fprintf(f, "wpa_key_mgmt=WPA-EAP-SUITE-B-192\n"); |
Jouni Malinen | 3d633da | 2017-09-14 22:19:21 +0300 | [diff] [blame] | 7364 | fprintf(f, "wpa_pairwise=%s\n", |
| 7365 | hostapd_cipher_name(dut->ap_cipher)); |
Jouni Malinen | 2ba2449 | 2017-11-17 12:43:59 +0200 | [diff] [blame] | 7366 | if (dut->ap_group_cipher != AP_NO_GROUP_CIPHER_SET) |
| 7367 | fprintf(f, "group_cipher=%s\n", |
| 7368 | hostapd_cipher_name(dut->ap_group_cipher)); |
Jouni Malinen | 3d633da | 2017-09-14 22:19:21 +0300 | [diff] [blame] | 7369 | if (dut->ap_group_mgmt_cipher != AP_NO_GROUP_MGMT_CIPHER_SET) |
| 7370 | fprintf(f, "group_mgmt_cipher=%s\n", |
| 7371 | hostapd_group_mgmt_cipher_name( |
| 7372 | dut->ap_group_mgmt_cipher)); |
Jouni Malinen | ad395a2 | 2017-09-01 21:13:46 +0300 | [diff] [blame] | 7373 | fprintf(f, "auth_server_addr=%s\n", dut->ap_radius_ipaddr); |
| 7374 | if (dut->ap_radius_port) |
| 7375 | fprintf(f, "auth_server_port=%d\n", |
| 7376 | dut->ap_radius_port); |
| 7377 | fprintf(f, "auth_server_shared_secret=%s\n", |
| 7378 | dut->ap_radius_password); |
| 7379 | break; |
Jouni Malinen | 147b3c3 | 2017-10-09 16:51:54 +0300 | [diff] [blame] | 7380 | case AP_WPA2_OWE: |
| 7381 | fprintf(f, "wpa=2\n"); |
| 7382 | fprintf(f, "wpa_key_mgmt=OWE\n"); |
| 7383 | fprintf(f, "rsn_pairwise=%s\n", |
| 7384 | hostapd_cipher_name(dut->ap_cipher)); |
Jouni Malinen | 72461d4 | 2017-10-10 19:20:45 +0300 | [diff] [blame] | 7385 | if (dut->ap_sae_groups) |
| 7386 | fprintf(f, "owe_groups=%s\n", dut->ap_sae_groups); |
Jouni Malinen | 147b3c3 | 2017-10-09 16:51:54 +0300 | [diff] [blame] | 7387 | break; |
Jouni Malinen | c2b9121 | 2018-09-12 02:26:39 +0300 | [diff] [blame] | 7388 | case AP_OSEN: |
| 7389 | fprintf(f, "osen=1\n"); |
| 7390 | fprintf(f, "disable_dgaf=1\n"); |
| 7391 | fprintf(f, "wpa_pairwise=%s\n", |
| 7392 | hostapd_cipher_name(dut->ap_cipher)); |
| 7393 | if (dut->ap_group_cipher != AP_NO_GROUP_CIPHER_SET) |
| 7394 | fprintf(f, "group_cipher=%s\n", |
| 7395 | hostapd_cipher_name(dut->ap_group_cipher)); |
| 7396 | fprintf(f, "auth_server_addr=%s\n", dut->ap_radius_ipaddr); |
| 7397 | if (dut->ap_radius_port) |
| 7398 | fprintf(f, "auth_server_port=%d\n", |
| 7399 | dut->ap_radius_port); |
| 7400 | fprintf(f, "auth_server_shared_secret=%s\n", |
| 7401 | dut->ap_radius_password); |
| 7402 | break; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7403 | } |
Jouni Malinen | da5f35b | 2019-03-26 00:25:53 +0200 | [diff] [blame] | 7404 | skip_key_mgmt: |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7405 | |
Jouni Malinen | 09550de | 2019-03-26 00:24:11 +0200 | [diff] [blame] | 7406 | if (dut->ap_sae_passwords) { |
| 7407 | char *tmp, *pos, *end, *id; |
| 7408 | |
| 7409 | tmp = strdup(dut->ap_sae_passwords); |
| 7410 | if (!tmp) { |
| 7411 | fclose(f); |
| 7412 | return ERROR_SEND_STATUS; |
| 7413 | } |
| 7414 | |
| 7415 | pos = tmp; |
| 7416 | while (*pos) { |
| 7417 | end = strchr(pos, ';'); |
| 7418 | if (end) |
| 7419 | *end = '\0'; |
| 7420 | id = strchr(pos, ':'); |
| 7421 | if (id) |
| 7422 | *id++ = '\0'; |
| 7423 | |
| 7424 | fprintf(f, "sae_password=%s%s%s\n", |
| 7425 | pos, id ? "|id=" : "", id ? id : ""); |
| 7426 | if (!end) |
| 7427 | break; |
| 7428 | pos = end + 1; |
| 7429 | } |
| 7430 | |
| 7431 | free(tmp); |
| 7432 | } |
| 7433 | |
Anilkumar Kolli | f0fd599 | 2017-02-23 12:54:01 +0530 | [diff] [blame] | 7434 | if (dut->ap_rsn_preauth) |
| 7435 | fprintf(f, "rsn_preauth=1\n"); |
| 7436 | |
Jouni Malinen | b75c532 | 2019-06-14 01:47:43 +0300 | [diff] [blame] | 7437 | if (dut->ap_pmksa && dut->ap_pmksa_caching) |
| 7438 | fprintf(f, "disable_pmksa_caching=1\n"); |
| 7439 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7440 | switch (dut->ap_pmf) { |
| 7441 | case AP_PMF_DISABLED: |
| 7442 | break; |
| 7443 | case AP_PMF_OPTIONAL: |
| 7444 | fprintf(f, "ieee80211w=1\n"); |
Jouni Malinen | da5f35b | 2019-03-26 00:25:53 +0200 | [diff] [blame] | 7445 | if (dut->ap_key_mgmt == AP_WPA2_PSK_SAE || |
| 7446 | (dut->ap_akm_values & (AKM_SAE | AKM_WPA_PSK)) == |
| 7447 | (AKM_SAE | AKM_WPA_PSK)) |
Jouni Malinen | 1287cd7 | 2018-01-04 17:08:01 +0200 | [diff] [blame] | 7448 | fprintf(f, "sae_require_mfp=1\n"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7449 | break; |
| 7450 | case AP_PMF_REQUIRED: |
| 7451 | fprintf(f, "ieee80211w=2\n"); |
| 7452 | break; |
| 7453 | } |
| 7454 | |
Jouni Malinen | 10ed9e7 | 2019-03-28 03:00:11 +0200 | [diff] [blame] | 7455 | if (dut->ap_pmf != AP_PMF_DISABLED && |
| 7456 | dut->ap_group_mgmt_cipher != AP_NO_GROUP_MGMT_CIPHER_SET) |
| 7457 | fprintf(f, "group_mgmt_cipher=%s\n", |
| 7458 | hostapd_group_mgmt_cipher_name( |
| 7459 | dut->ap_group_mgmt_cipher)); |
| 7460 | |
Jouni Malinen | 6be21c8 | 2018-08-01 18:47:24 +0300 | [diff] [blame] | 7461 | if (ap_ft_enabled(dut)) { |
| 7462 | unsigned char own_addr[ETH_ALEN]; |
| 7463 | |
| 7464 | fprintf(f, "mobility_domain=%s\n", dut->ap_mobility_domain); |
Jouni Malinen | 9f94331 | 2019-08-19 23:49:16 +0300 | [diff] [blame] | 7465 | fprintf(f, "ft_over_ds=%d\n", dut->ap_ft_ds == VALUE_ENABLED); |
Jouni Malinen | 6be21c8 | 2018-08-01 18:47:24 +0300 | [diff] [blame] | 7466 | if (get_hwaddr(ifname, own_addr) < 0) { |
| 7467 | memset(own_addr, 0, ETH_ALEN); |
| 7468 | own_addr[0] = 0x02; |
| 7469 | } |
Jouni Malinen | c967446 | 2019-03-26 02:40:19 +0200 | [diff] [blame] | 7470 | fprintf(f, |
| 7471 | "nas_identifier=%02x%02x%02x%02x%02x%02x.nas.example.com\n", |
| 7472 | own_addr[0], own_addr[1], own_addr[2], |
| 7473 | own_addr[3], own_addr[4], own_addr[5]); |
Jouni Malinen | 6be21c8 | 2018-08-01 18:47:24 +0300 | [diff] [blame] | 7474 | fprintf(f, "r1_key_holder=%02x%02x%02x%02x%02x%02x\n", |
| 7475 | own_addr[0], own_addr[1], own_addr[2], |
| 7476 | own_addr[3], own_addr[4], own_addr[5]); |
| 7477 | fprintf(f, "ft_psk_generate_local=1\n"); |
| 7478 | fprintf(f, "pmk_r1_push=0\n"); |
| 7479 | fprintf(f, |
Jouni Malinen | 69222a6 | 2019-03-26 01:56:20 +0200 | [diff] [blame] | 7480 | "r0kh=ff:ff:ff:ff:ff:ff * 00112233445566778899aabbccddeeff00112233445566778899aabbccddeeff\n"); |
Jouni Malinen | 6be21c8 | 2018-08-01 18:47:24 +0300 | [diff] [blame] | 7481 | fprintf(f, |
Jouni Malinen | 69222a6 | 2019-03-26 01:56:20 +0200 | [diff] [blame] | 7482 | "r1kh=00:00:00:00:00:00 00:00:00:00:00:00 00112233445566778899aabbccddeeff00112233445566778899aabbccddeeff\n"); |
Jouni Malinen | 6be21c8 | 2018-08-01 18:47:24 +0300 | [diff] [blame] | 7483 | } |
| 7484 | |
Jouni Malinen | 3c367e8 | 2017-06-23 17:01:47 +0300 | [diff] [blame] | 7485 | if (dut->rsne_override) |
| 7486 | fprintf(f, "own_ie_override=%s\n", dut->rsne_override); |
| 7487 | |
Jouni Malinen | 6814313 | 2017-09-02 02:34:08 +0300 | [diff] [blame] | 7488 | if (dut->sae_commit_override) |
| 7489 | fprintf(f, "sae_commit_override=%s\n", |
| 7490 | dut->sae_commit_override); |
| 7491 | |
Jouni Malinen | ed670f4 | 2017-08-31 01:39:28 +0300 | [diff] [blame] | 7492 | if (dut->ap_sae_groups) |
| 7493 | fprintf(f, "sae_groups=%s\n", dut->ap_sae_groups); |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 7494 | |
Jouni Malinen | 2f524ce | 2017-08-31 01:43:29 +0300 | [diff] [blame] | 7495 | if (dut->sae_anti_clogging_threshold >= 0) |
| 7496 | fprintf(f, "sae_anti_clogging_threshold=%d\n", |
| 7497 | dut->sae_anti_clogging_threshold); |
Jouni Malinen | b347db0 | 2017-09-02 01:36:03 +0300 | [diff] [blame] | 7498 | if (dut->sae_reflection) |
| 7499 | fprintf(f, "sae_reflection_attack=1\n"); |
Jouni Malinen | 3c740ab | 2019-10-10 15:55:11 +0300 | [diff] [blame] | 7500 | if (dut->sae_confirm_immediate) |
| 7501 | fprintf(f, "sae_confirm_immediate=1\n"); |
Jouni Malinen | 2f524ce | 2017-08-31 01:43:29 +0300 | [diff] [blame] | 7502 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7503 | if (dut->ap_p2p_mgmt) |
| 7504 | fprintf(f, "manage_p2p=1\n"); |
| 7505 | |
| 7506 | if (dut->ap_tdls_prohibit || dut->ap_l2tif) |
| 7507 | fprintf(f, "tdls_prohibit=1\n"); |
| 7508 | if (dut->ap_tdls_prohibit_chswitch || dut->ap_l2tif) |
| 7509 | fprintf(f, "tdls_prohibit_chan_switch=1\n"); |
| 7510 | if (dut->ap_p2p_cross_connect >= 0) { |
| 7511 | fprintf(f, "manage_p2p=1\n" |
| 7512 | "allow_cross_connection=%d\n", |
| 7513 | dut->ap_p2p_cross_connect); |
| 7514 | } |
| 7515 | |
Jouni Malinen | 4d479c9 | 2018-11-06 00:43:36 +0200 | [diff] [blame] | 7516 | if (dut->ap_l2tif || dut->ap_proxy_arp || |
| 7517 | dut->ap_key_mgmt == AP_WPA2_EAP_OSEN) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7518 | if (!dut->bridge) { |
| 7519 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 7520 | "Bridge must be configured. Run with -b <brname>."); |
| 7521 | fclose(f); |
| 7522 | return -2; |
| 7523 | } |
| 7524 | fprintf(f, "ap_isolate=1\n"); |
| 7525 | } |
| 7526 | |
| 7527 | if (dut->ap_proxy_arp) |
| 7528 | fprintf(f, "proxy_arp=1\n"); |
| 7529 | |
Pradeep Reddy POTTETI | 0d3db63 | 2016-03-11 15:21:11 +0530 | [diff] [blame] | 7530 | if (dut->ap_wme) |
| 7531 | fprintf(f, "wmm_enabled=1\n"); |
| 7532 | |
Mohammed Shafi Shajakhan | 02e3b82 | 2017-02-23 04:15:02 +0530 | [diff] [blame] | 7533 | if (dut->ap_wmmps == AP_WMMPS_ON) |
| 7534 | fprintf(f, "uapsd_advertisement_enabled=1\n"); |
| 7535 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7536 | if (dut->ap_hs2) { |
| 7537 | if (dut->ap_bss_load) { |
| 7538 | char *bss_load; |
| 7539 | |
| 7540 | switch (dut->ap_bss_load) { |
| 7541 | case -1: |
| 7542 | bss_load = "bss_load_update_period=10"; |
| 7543 | break; |
| 7544 | case 1: |
| 7545 | /* STA count: 1, CU: 50, AAC: 65535 */ |
| 7546 | bss_load = "bss_load_test=1:50:65535"; |
| 7547 | break; |
| 7548 | case 2: |
| 7549 | /* STA count: 1, CU: 200, AAC: 65535 */ |
| 7550 | bss_load = "bss_load_test=1:200:65535"; |
| 7551 | break; |
| 7552 | case 3: |
| 7553 | /* STA count: 1, CU: 75, AAC: 65535 */ |
| 7554 | bss_load = "bss_load_test=1:75:65535"; |
| 7555 | break; |
| 7556 | default: |
| 7557 | bss_load = NULL; |
| 7558 | break; |
| 7559 | } |
| 7560 | |
| 7561 | if (!bss_load) { |
| 7562 | fclose(f); |
| 7563 | return -2; |
| 7564 | } |
| 7565 | fprintf(f, "%s\n", bss_load); |
| 7566 | } |
| 7567 | |
| 7568 | if (append_hostapd_conf_hs2(dut, f)) { |
| 7569 | fclose(f); |
| 7570 | return -2; |
| 7571 | } |
| 7572 | } |
| 7573 | |
| 7574 | if (dut->ap_interworking && append_hostapd_conf_interworking(dut, f)) { |
| 7575 | fclose(f); |
| 7576 | return -2; |
| 7577 | } |
| 7578 | |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 7579 | if (dut->ap_hs2 && strlen(dut->ap_tag_ssid[0])) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7580 | unsigned char bssid[6]; |
| 7581 | char ifname2[50]; |
| 7582 | |
Pradeep Reddy POTTETI | 673d85c | 2016-07-26 19:08:07 +0530 | [diff] [blame] | 7583 | if (get_hwaddr(ifname, bssid)) { |
| 7584 | fclose(f); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7585 | return -2; |
Pradeep Reddy POTTETI | 673d85c | 2016-07-26 19:08:07 +0530 | [diff] [blame] | 7586 | } |
Jouni Malinen | b37f0bc | 2018-05-03 18:29:55 +0300 | [diff] [blame] | 7587 | if (bssid[0] & 0x02) |
| 7588 | bssid[5] ^= 0x01; |
| 7589 | else |
| 7590 | bssid[0] |= 0x02; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7591 | |
| 7592 | snprintf(ifname2, sizeof(ifname2), "%s_1", ifname); |
Jouni Malinen | 10b47b2 | 2018-06-07 23:28:07 +0300 | [diff] [blame] | 7593 | fprintf(f, "bss=%s\n", ifname2); |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 7594 | fprintf(f, "ssid=%s\n", dut->ap_tag_ssid[0]); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7595 | if (dut->bridge) |
| 7596 | fprintf(f, "bridge=%s\n", dut->bridge); |
Liangwei Dong | 911cb14 | 2019-01-10 14:35:55 +0800 | [diff] [blame] | 7597 | |
| 7598 | if (drv == DRIVER_LINUX_WCN) |
| 7599 | fprintf(f, "use_driver_iface_addr=1\n"); |
| 7600 | else |
| 7601 | fprintf(f, "bssid=%02x:%02x:%02x:%02x:%02x:%02x\n", |
| 7602 | bssid[0], bssid[1], bssid[2], bssid[3], |
| 7603 | bssid[4], bssid[5]); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7604 | |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 7605 | if (dut->ap_tag_key_mgmt[0] == AP2_OSEN) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7606 | fprintf(f, "osen=1\n"); |
Sriram R | 61f5d95 | 2018-06-07 17:47:07 +0530 | [diff] [blame] | 7607 | /* Disable DGAF for OSEN BSS */ |
| 7608 | fprintf(f, "disable_dgaf=1\n"); |
Jouni Malinen | dbbc2c4 | 2018-11-14 23:55:41 +0200 | [diff] [blame] | 7609 | fprintf(f, "ap_isolate=1\n"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7610 | if (strlen(dut->ap2_radius_ipaddr)) |
| 7611 | fprintf(f, "auth_server_addr=%s\n", |
| 7612 | dut->ap2_radius_ipaddr); |
| 7613 | if (dut->ap2_radius_port) |
| 7614 | fprintf(f, "auth_server_port=%d\n", |
| 7615 | dut->ap2_radius_port); |
| 7616 | if (strlen(dut->ap2_radius_password)) |
| 7617 | fprintf(f, "auth_server_shared_secret=%s\n", |
| 7618 | dut->ap2_radius_password); |
Jouni Malinen | dbbc2c4 | 2018-11-14 23:55:41 +0200 | [diff] [blame] | 7619 | |
| 7620 | set_ebtables_forward_drop(dut, ifname, ifname2); |
| 7621 | } else if (dut->ap2_osu) { |
| 7622 | fprintf(f, "ap_isolate=1\n"); |
| 7623 | set_ebtables_forward_drop(dut, ifname, ifname2); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7624 | } |
| 7625 | |
| 7626 | if (dut->ap2_proxy_arp) { |
| 7627 | if (!dut->bridge) { |
| 7628 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 7629 | "Bridge must be configured. Run with -b <brname>."); |
| 7630 | fclose(f); |
| 7631 | return -2; |
| 7632 | } |
| 7633 | fprintf(f, "ap_isolate=1\n"); |
| 7634 | fprintf(f, "proxy_arp=1\n"); |
| 7635 | |
| 7636 | if (set_ebtables_proxy_arp(dut, "FORWARD", ifname2) || |
| 7637 | set_ebtables_proxy_arp(dut, "OUTPUT", ifname2)) { |
| 7638 | fclose(f); |
| 7639 | return -2; |
| 7640 | } |
| 7641 | |
| 7642 | } |
| 7643 | } |
| 7644 | |
| 7645 | if (dut->program == PROGRAM_WPS) { |
Alexei Avshalom Lazar | d303e47 | 2018-12-23 16:49:49 +0200 | [diff] [blame] | 7646 | /* 60G WPS tests requires wps_state of 2 (configured) */ |
| 7647 | int wps_state = is_60g_sigma_dut(dut) ? 2 : 1; |
| 7648 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7649 | fprintf(f, "eap_server=1\n" |
Alexei Avshalom Lazar | d303e47 | 2018-12-23 16:49:49 +0200 | [diff] [blame] | 7650 | "wps_state=%d\n" |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7651 | "device_name=QCA AP\n" |
| 7652 | "manufacturer=QCA\n" |
| 7653 | "device_type=6-0050F204-1\n" |
Alexei Avshalom Lazar | d303e47 | 2018-12-23 16:49:49 +0200 | [diff] [blame] | 7654 | "config_methods=label virtual_display %s" |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7655 | "virtual_push_button keypad%s\n" |
| 7656 | "ap_pin=12345670\n" |
| 7657 | "friendly_name=QCA Access Point\n" |
| 7658 | "upnp_iface=%s\n", |
Alexei Avshalom Lazar | d303e47 | 2018-12-23 16:49:49 +0200 | [diff] [blame] | 7659 | wps_state, |
| 7660 | is_60g_sigma_dut(dut) ? "physical_display " : "", |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7661 | dut->ap_wpsnfc ? " nfc_interface ext_nfc_token" : "", |
| 7662 | dut->bridge ? dut->bridge : ifname); |
Alexei Avshalom Lazar | 33f700c | 2018-12-18 16:00:39 +0200 | [diff] [blame] | 7663 | if (dut->wsc_fragment) { |
| 7664 | fprintf(f, "device_name=%s\n" |
| 7665 | "manufacturer=%s\n" |
| 7666 | "model_name=%s\n" |
| 7667 | "model_number=%s\n" |
| 7668 | "serial_number=%s\n", |
| 7669 | WPS_LONG_DEVICE_NAME, |
| 7670 | WPS_LONG_MANUFACTURER, |
| 7671 | WPS_LONG_MODEL_NAME, |
| 7672 | WPS_LONG_MODEL_NUMBER, |
| 7673 | WPS_LONG_SERIAL_NUMBER); |
| 7674 | } else { |
| 7675 | fprintf(f, "device_name=QCA AP\n" |
| 7676 | "manufacturer=QCA\n"); |
| 7677 | } |
Alexei Avshalom Lazar | 2eccf4d | 2019-01-31 10:03:59 +0200 | [diff] [blame] | 7678 | if (dut->eap_fragment) |
| 7679 | fprintf(f, "fragment_size=128\n"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7680 | } |
| 7681 | |
Jouni Malinen | ba4f2d4 | 2019-10-04 16:13:41 +0300 | [diff] [blame] | 7682 | if (dut->ap_dpp_conf_addr && dut->ap_dpp_conf_pkhash) |
| 7683 | fprintf(f, "dpp_controller=ipaddr=%s pkhash=%s\n", |
| 7684 | dut->ap_dpp_conf_addr, dut->ap_dpp_conf_pkhash); |
| 7685 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7686 | if (dut->program == PROGRAM_VHT) { |
| 7687 | int vht_oper_centr_freq_idx; |
| 7688 | |
| 7689 | if (check_channel(dut->ap_channel) < 0) { |
| 7690 | send_resp(dut, conn, SIGMA_INVALID, |
| 7691 | "errorCode,Invalid channel"); |
Pradeep Reddy POTTETI | 673d85c | 2016-07-26 19:08:07 +0530 | [diff] [blame] | 7692 | fclose(f); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7693 | return 0; |
| 7694 | } |
| 7695 | |
| 7696 | switch (dut->ap_chwidth) { |
| 7697 | case AP_20: |
| 7698 | dut->ap_vht_chwidth = AP_20_40_VHT_OPER_CHWIDTH; |
| 7699 | vht_oper_centr_freq_idx = |
| 7700 | get_oper_centr_freq_seq_idx(20, |
| 7701 | dut->ap_channel); |
| 7702 | break; |
| 7703 | case AP_40: |
| 7704 | dut->ap_vht_chwidth = AP_20_40_VHT_OPER_CHWIDTH; |
| 7705 | vht_oper_centr_freq_idx = |
| 7706 | get_oper_centr_freq_seq_idx(40, |
| 7707 | dut->ap_channel); |
| 7708 | break; |
| 7709 | case AP_80: |
| 7710 | dut->ap_vht_chwidth = AP_80_VHT_OPER_CHWIDTH; |
| 7711 | vht_oper_centr_freq_idx = |
| 7712 | get_oper_centr_freq_seq_idx(80, |
| 7713 | dut->ap_channel); |
| 7714 | break; |
| 7715 | case AP_160: |
| 7716 | dut->ap_vht_chwidth = AP_160_VHT_OPER_CHWIDTH; |
| 7717 | vht_oper_centr_freq_idx = |
| 7718 | get_oper_centr_freq_seq_idx(160, |
| 7719 | dut->ap_channel); |
| 7720 | break; |
| 7721 | default: |
| 7722 | dut->ap_vht_chwidth = VHT_DEFAULT_OPER_CHWIDTH; |
| 7723 | vht_oper_centr_freq_idx = |
| 7724 | get_oper_centr_freq_seq_idx(80, |
| 7725 | dut->ap_channel); |
| 7726 | break; |
| 7727 | } |
| 7728 | fprintf(f, "vht_oper_centr_freq_seg0_idx=%d\n", |
| 7729 | vht_oper_centr_freq_idx); |
| 7730 | fprintf(f, "vht_oper_chwidth=%d\n", dut->ap_vht_chwidth); |
| 7731 | |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 7732 | if (dut->ap_sgi80 || dut->ap_txBF || |
| 7733 | dut->ap_ldpc != VALUE_NOT_SET || |
Mohammed Shafi Shajakhan | f3e68d9 | 2016-06-02 20:10:57 +0530 | [diff] [blame] | 7734 | dut->ap_tx_stbc || dut->ap_mu_txBF) { |
| 7735 | fprintf(f, "vht_capab=%s%s%s%s%s\n", |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7736 | dut->ap_sgi80 ? "[SHORT-GI-80]" : "", |
Mohammed Shafi Shajakhan | c039ce3 | 2016-06-02 20:10:58 +0530 | [diff] [blame] | 7737 | dut->ap_txBF ? |
Tamizh chelvam | 8312f6d | 2016-06-02 20:10:59 +0530 | [diff] [blame] | 7738 | "[SU-BEAMFORMER][SU-BEAMFORMEE][BF-ANTENNA-2][SOUNDING-DIMENSION-2]" : "", |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 7739 | (dut->ap_ldpc == VALUE_ENABLED) ? |
| 7740 | "[RXLDPC]" : "", |
Mohammed Shafi Shajakhan | f3e68d9 | 2016-06-02 20:10:57 +0530 | [diff] [blame] | 7741 | dut->ap_tx_stbc ? "[TX-STBC-2BY1]" : "", |
| 7742 | dut->ap_mu_txBF ? "[MU-BEAMFORMER]" : ""); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7743 | } |
| 7744 | } |
| 7745 | |
Jouni Malinen | 6d1d739 | 2017-10-10 20:35:29 +0300 | [diff] [blame] | 7746 | if (dut->ap_key_mgmt == AP_WPA2_OWE && dut->ap_tag_ssid[0][0] && |
| 7747 | dut->ap_tag_key_mgmt[0] == AP2_OPEN) { |
| 7748 | /* OWE transition mode */ |
| 7749 | unsigned char bssid[6]; |
| 7750 | char ifname2[50]; |
| 7751 | unsigned long val; |
| 7752 | FILE *f2; |
| 7753 | |
| 7754 | snprintf(ifname2, sizeof(ifname2), "%s_1", ifname); |
| 7755 | |
| 7756 | fprintf(f, "owe_transition_ifname=%s\n", ifname2); |
| 7757 | val = 0x12345678; /* default to something */ |
| 7758 | f2 = fopen("/dev/urandom", "r"); |
| 7759 | if (f2) { |
| 7760 | if (fread(&val, 1, sizeof(val), f2) != sizeof(val)) { |
| 7761 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 7762 | "Could not read /dev/urandom"); |
| 7763 | } |
| 7764 | fclose(f2); |
| 7765 | } |
| 7766 | fprintf(f, "ssid=owe-%lx\n", val); |
Liangwei Dong | d3b87da | 2019-01-09 20:10:20 +0800 | [diff] [blame] | 7767 | fprintf(f, "ignore_broadcast_ssid=1\n"); |
Jouni Malinen | 6d1d739 | 2017-10-10 20:35:29 +0300 | [diff] [blame] | 7768 | |
| 7769 | if (get_hwaddr(ifname, bssid)) { |
| 7770 | fclose(f); |
| 7771 | return -2; |
| 7772 | } |
| 7773 | if (bssid[0] & 0x02) |
| 7774 | bssid[5] ^= 0x01; |
| 7775 | else |
| 7776 | bssid[0] |= 0x02; |
| 7777 | |
| 7778 | fprintf(f, "bss=%s\n", ifname2); |
| 7779 | fprintf(f, "ssid=%s\n", dut->ap_ssid); |
| 7780 | if (dut->bridge) |
| 7781 | fprintf(f, "bridge=%s\n", dut->bridge); |
Liangwei Dong | 911cb14 | 2019-01-10 14:35:55 +0800 | [diff] [blame] | 7782 | if (drv == DRIVER_LINUX_WCN) |
| 7783 | fprintf(f, "use_driver_iface_addr=1\n"); |
| 7784 | else |
| 7785 | fprintf(f, "bssid=%02x:%02x:%02x:%02x:%02x:%02x\n", |
| 7786 | bssid[0], bssid[1], bssid[2], bssid[3], |
| 7787 | bssid[4], bssid[5]); |
Jouni Malinen | 6d1d739 | 2017-10-10 20:35:29 +0300 | [diff] [blame] | 7788 | fprintf(f, "owe_transition_ifname=%s\n", ifname); |
| 7789 | } |
| 7790 | |
Jouni Malinen | 353ba8b | 2018-01-10 17:04:12 +0200 | [diff] [blame] | 7791 | if (dut->ap_key_mgmt == AP_OPEN && |
| 7792 | dut->ap_tag_key_mgmt[0] == AP2_WPA2_OWE) { |
| 7793 | /* OWE transition mode */ |
| 7794 | unsigned char bssid[6]; |
| 7795 | char ifname2[50]; |
| 7796 | unsigned long val; |
| 7797 | FILE *f2; |
| 7798 | |
| 7799 | snprintf(ifname2, sizeof(ifname2), "%s_1", ifname); |
| 7800 | |
| 7801 | fprintf(f, "owe_transition_ifname=%s\n", ifname2); |
| 7802 | fprintf(f, "ssid=%s\n", dut->ap_ssid); |
| 7803 | |
| 7804 | if (get_hwaddr(ifname, bssid)) { |
| 7805 | fclose(f); |
| 7806 | return -2; |
| 7807 | } |
| 7808 | if (bssid[0] & 0x02) |
| 7809 | bssid[5] ^= 0x01; |
| 7810 | else |
| 7811 | bssid[0] |= 0x02; |
| 7812 | |
| 7813 | fprintf(f, "bss=%s\n", ifname2); |
| 7814 | val = 0x12345678; /* default to something */ |
| 7815 | f2 = fopen("/dev/urandom", "r"); |
| 7816 | if (f2) { |
| 7817 | if (fread(&val, 1, sizeof(val), f2) != sizeof(val)) { |
| 7818 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 7819 | "Could not read /dev/urandom"); |
| 7820 | } |
| 7821 | fclose(f2); |
| 7822 | } |
| 7823 | fprintf(f, "ssid=owe-%lx\n", val); |
| 7824 | if (dut->bridge) |
| 7825 | fprintf(f, "bridge=%s\n", dut->bridge); |
Liangwei Dong | 911cb14 | 2019-01-10 14:35:55 +0800 | [diff] [blame] | 7826 | if (drv == DRIVER_LINUX_WCN) |
| 7827 | fprintf(f, "use_driver_iface_addr=1\n"); |
| 7828 | else |
| 7829 | fprintf(f, "bssid=%02x:%02x:%02x:%02x:%02x:%02x\n", |
| 7830 | bssid[0], bssid[1], bssid[2], bssid[3], |
| 7831 | bssid[4], bssid[5]); |
Jouni Malinen | 353ba8b | 2018-01-10 17:04:12 +0200 | [diff] [blame] | 7832 | fprintf(f, "owe_transition_ifname=%s\n", ifname); |
| 7833 | fprintf(f, "wpa=2\n"); |
| 7834 | fprintf(f, "wpa_key_mgmt=OWE\n"); |
| 7835 | fprintf(f, "rsn_pairwise=CCMP\n"); |
| 7836 | fprintf(f, "ieee80211w=2\n"); |
Liangwei Dong | d3b87da | 2019-01-09 20:10:20 +0800 | [diff] [blame] | 7837 | fprintf(f, "ignore_broadcast_ssid=1\n"); |
Jouni Malinen | 353ba8b | 2018-01-10 17:04:12 +0200 | [diff] [blame] | 7838 | if (dut->ap_sae_groups) |
| 7839 | fprintf(f, "owe_groups=%s\n", dut->ap_sae_groups); |
| 7840 | } |
| 7841 | |
Ankita Bajaj | 0d5825b | 2017-10-25 16:20:17 +0530 | [diff] [blame] | 7842 | if (dut->program == PROGRAM_OCE) { |
| 7843 | fprintf(f, "oce=%d\n", |
| 7844 | dut->dev_role == DEVROLE_STA_CFON ? 2 : 1); |
| 7845 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7846 | fclose(f); |
Jouni Malinen | d6bf1b4 | 2017-06-23 17:51:01 +0300 | [diff] [blame] | 7847 | if (dut->use_hostapd_pid_file) |
| 7848 | kill_hostapd_process_pid(dut); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7849 | #ifdef __QNXNTO__ |
| 7850 | if (system("slay hostapd") == 0) |
| 7851 | #else /* __QNXNTO__ */ |
Jouni Malinen | d6bf1b4 | 2017-06-23 17:51:01 +0300 | [diff] [blame] | 7852 | if (!dut->use_hostapd_pid_file && |
| 7853 | (kill_process(dut, "(hostapd)", 1, SIGTERM) == 0 || |
| 7854 | system("killall hostapd") == 0)) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7855 | #endif /* __QNXNTO__ */ |
| 7856 | { |
| 7857 | int i; |
| 7858 | /* Wait some time to allow hostapd to complete cleanup before |
| 7859 | * starting a new process */ |
| 7860 | for (i = 0; i < 10; i++) { |
| 7861 | usleep(500000); |
| 7862 | #ifdef __QNXNTO__ |
| 7863 | if (system("pidin | grep hostapd") != 0) |
| 7864 | break; |
| 7865 | #else /* __QNXNTO__ */ |
| 7866 | if (system("pidof hostapd") != 0) |
| 7867 | break; |
| 7868 | #endif /* __QNXNTO__ */ |
| 7869 | } |
| 7870 | } |
Jouni Malinen | d86e582 | 2017-08-29 03:55:32 +0300 | [diff] [blame] | 7871 | dut->hostapd_running = 0; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7872 | |
Pradeep Reddy POTTETI | a076c30 | 2016-05-16 13:36:07 +0530 | [diff] [blame] | 7873 | #ifdef ANDROID |
| 7874 | /* Set proper conf file permissions so that hostapd process |
| 7875 | * can access it. |
| 7876 | */ |
| 7877 | if (chmod(SIGMA_TMPDIR "/sigma_dut-ap.conf", |
| 7878 | S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP) < 0) |
| 7879 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 7880 | "Error changing permissions"); |
| 7881 | |
Srinivas Dasari | a1deeaa | 2018-06-18 22:54:04 +0530 | [diff] [blame] | 7882 | gr = getgrnam("wifi"); |
| 7883 | if (!gr || |
| 7884 | chown(SIGMA_TMPDIR "/sigma_dut-ap.conf", -1, gr->gr_gid) < 0) |
Pradeep Reddy POTTETI | a076c30 | 2016-05-16 13:36:07 +0530 | [diff] [blame] | 7885 | sigma_dut_print(dut, DUT_MSG_ERROR, "Error changing groupid"); |
| 7886 | #endif /* ANDROID */ |
| 7887 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7888 | if (drv == DRIVER_QNXNTO) { |
| 7889 | snprintf(buf, sizeof(buf), |
Pradeep Reddy POTTETI | bf4a974 | 2016-02-04 12:32:30 +0530 | [diff] [blame] | 7890 | "hostapd -B %s%s %s%s" SIGMA_TMPDIR |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7891 | "/sigma_dut-ap.conf", |
| 7892 | dut->hostapd_debug_log ? "-ddKt -f " : "", |
| 7893 | dut->hostapd_debug_log ? dut->hostapd_debug_log : "", |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7894 | dut->hostapd_entropy_log ? " -e" : "", |
| 7895 | dut->hostapd_entropy_log ? dut->hostapd_entropy_log : |
| 7896 | ""); |
| 7897 | } else { |
| 7898 | /* |
| 7899 | * It looks like a monitor interface can cause some issues for |
| 7900 | * beaconing, so remove it (if injection was used) before |
| 7901 | * starting hostapd. |
| 7902 | */ |
| 7903 | if (if_nametoindex("sigmadut") > 0 && |
| 7904 | system("iw dev sigmadut del") != 0) |
| 7905 | sigma_dut_print(dut, DUT_MSG_ERROR, "Failed to remove " |
| 7906 | "monitor interface"); |
| 7907 | |
Jouni Malinen | d6bf1b4 | 2017-06-23 17:51:01 +0300 | [diff] [blame] | 7908 | snprintf(path, sizeof(path), "%shostapd", |
| 7909 | file_exists("hostapd") ? "./" : ""); |
| 7910 | snprintf(buf, sizeof(buf), "%s -B%s%s%s%s%s " SIGMA_TMPDIR |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7911 | "/sigma_dut-ap.conf", |
Jouni Malinen | d6bf1b4 | 2017-06-23 17:51:01 +0300 | [diff] [blame] | 7912 | dut->hostapd_bin ? dut->hostapd_bin : path, |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7913 | dut->hostapd_debug_log ? " -ddKt -f" : "", |
| 7914 | dut->hostapd_debug_log ? dut->hostapd_debug_log : "", |
| 7915 | dut->hostapd_entropy_log ? " -e" : "", |
| 7916 | dut->hostapd_entropy_log ? dut->hostapd_entropy_log : |
Jouni Malinen | d6bf1b4 | 2017-06-23 17:51:01 +0300 | [diff] [blame] | 7917 | "", |
| 7918 | dut->use_hostapd_pid_file ? |
| 7919 | " -P " SIGMA_DUT_HOSTAPD_PID_FILE : ""); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7920 | } |
| 7921 | |
Jouni Malinen | d6bf1b4 | 2017-06-23 17:51:01 +0300 | [diff] [blame] | 7922 | sigma_dut_print(dut, DUT_MSG_DEBUG, "hostapd command: %s", buf); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7923 | if (system(buf) != 0) { |
| 7924 | send_resp(dut, conn, SIGMA_ERROR, |
| 7925 | "errorCode,Failed to start hostapd"); |
| 7926 | return 0; |
| 7927 | } |
| 7928 | |
| 7929 | /* allow some time for hostapd to start before returning success */ |
| 7930 | usleep(500000); |
| 7931 | if (run_hostapd_cli(dut, "ping") != 0) { |
| 7932 | send_resp(dut, conn, SIGMA_ERROR, |
| 7933 | "errorCode,Failed to talk to hostapd"); |
| 7934 | return 0; |
| 7935 | } |
| 7936 | |
Pradeep Reddy Potteti | 923a9b3 | 2017-06-14 12:18:59 +0530 | [diff] [blame] | 7937 | if (drv == DRIVER_LINUX_WCN) { |
Hu Wang | f5cb900 | 2019-08-21 14:18:57 +0800 | [diff] [blame] | 7938 | const char *ifname_ptr = ifname; |
| 7939 | |
| 7940 | if ((dut->ap_key_mgmt == AP_OPEN && |
| 7941 | dut->ap_tag_key_mgmt[0] == AP2_WPA2_OWE) || |
| 7942 | (dut->ap_key_mgmt == AP_WPA2_OWE && |
| 7943 | dut->ap_tag_ssid[0][0] && |
| 7944 | dut->ap_tag_key_mgmt[0] == AP2_OPEN)) { |
| 7945 | /* OWE transition mode */ |
| 7946 | if (dut->bridge) |
| 7947 | ifname_ptr = dut->bridge; |
| 7948 | } |
| 7949 | |
| 7950 | sigma_dut_print(dut, DUT_MSG_INFO, |
| 7951 | "setting ip addr %s mask %s ifname %s", |
| 7952 | ap_inet_addr, ap_inet_mask, ifname_ptr); |
Pradeep Reddy Potteti | 923a9b3 | 2017-06-14 12:18:59 +0530 | [diff] [blame] | 7953 | snprintf(buf, sizeof(buf), "ifconfig %s %s netmask %s up", |
Hu Wang | f5cb900 | 2019-08-21 14:18:57 +0800 | [diff] [blame] | 7954 | ifname_ptr, ap_inet_addr, ap_inet_mask); |
Pradeep Reddy Potteti | 923a9b3 | 2017-06-14 12:18:59 +0530 | [diff] [blame] | 7955 | if (system(buf) != 0) { |
| 7956 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 7957 | "Failed to initialize the interface"); |
| 7958 | return -1; |
| 7959 | } |
| 7960 | } |
| 7961 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7962 | if (dut->ap_l2tif) { |
| 7963 | snprintf(path, sizeof(path), |
| 7964 | "/sys/class/net/%s/brport/hairpin_mode", |
| 7965 | ifname); |
| 7966 | if (!file_exists(path)) { |
| 7967 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 7968 | "%s must be binded to the bridge for L2TIF", |
| 7969 | ifname); |
| 7970 | return -2; |
| 7971 | } |
| 7972 | |
| 7973 | snprintf(buf, sizeof(buf), "echo 1 > %s", path); |
| 7974 | if (system(buf) != 0) { |
| 7975 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 7976 | "Failed to enable hairpin_mode for L2TIF"); |
| 7977 | return -2; |
| 7978 | } |
| 7979 | |
| 7980 | snprintf(buf, sizeof(buf), "ebtables -P FORWARD ACCEPT"); |
| 7981 | if (system(buf) != 0) { |
| 7982 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 7983 | "Failed to set ebtables rules, RULE-9"); |
| 7984 | return -2; |
| 7985 | } |
| 7986 | |
| 7987 | snprintf(buf, sizeof(buf), |
| 7988 | "ebtables -A FORWARD -p IPv4 --ip-proto icmp -i %s -j DROP", |
| 7989 | ifname); |
| 7990 | if (system(buf) != 0) { |
| 7991 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 7992 | "Failed to set ebtables rules, RULE-11"); |
| 7993 | return -2; |
| 7994 | } |
| 7995 | } |
| 7996 | |
| 7997 | if (dut->ap_proxy_arp) { |
| 7998 | if (dut->ap_dgaf_disable) { |
| 7999 | if (set_ebtables_disable_dgaf(dut, "FORWARD", ifname) || |
| 8000 | set_ebtables_disable_dgaf(dut, "OUTPUT", ifname)) |
| 8001 | return -2; |
| 8002 | } else { |
| 8003 | if (set_ebtables_proxy_arp(dut, "FORWARD", ifname) || |
| 8004 | set_ebtables_proxy_arp(dut, "OUTPUT", ifname)) |
| 8005 | return -2; |
| 8006 | } |
| 8007 | |
| 8008 | /* For 4.5-(c) */ |
| 8009 | snprintf(buf, sizeof(buf), |
| 8010 | "ebtables -A FORWARD -p ARP --arp-opcode 2 -i %s -j DROP", |
| 8011 | ifname); |
| 8012 | if (system(buf) != 0) { |
| 8013 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 8014 | "Failed to set ebtables rules, RULE-10"); |
| 8015 | return -2; |
| 8016 | } |
| 8017 | } |
| 8018 | |
| 8019 | if (dut->ap_tdls_prohibit || dut->ap_l2tif) { |
| 8020 | /* Drop TDLS frames */ |
| 8021 | snprintf(buf, sizeof(buf), |
| 8022 | "ebtables -A FORWARD -p 0x890d -i %s -j DROP", ifname); |
| 8023 | if (system(buf) != 0) { |
| 8024 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 8025 | "Failed to set ebtables rules, RULE-13"); |
| 8026 | return -2; |
| 8027 | } |
| 8028 | } |
| 8029 | |
| 8030 | if (dut->ap_fake_pkhash && |
| 8031 | run_hostapd_cli(dut, "set wps_corrupt_pkhash 1") != 0) { |
| 8032 | send_resp(dut, conn, SIGMA_ERROR, |
| 8033 | "errorCode,Could not enable FakePubKey"); |
| 8034 | return 0; |
| 8035 | } |
| 8036 | |
Alexei Avshalom Lazar | bc180dc | 2018-12-18 16:01:14 +0200 | [diff] [blame] | 8037 | if (dut->program == PROGRAM_60GHZ && dut->ap_num_ese_allocs > 0) { |
| 8038 | /* wait extra time for AP to start */ |
| 8039 | sleep(2); |
| 8040 | if (ap_set_60g_ese(dut, dut->ap_num_ese_allocs, |
| 8041 | dut->ap_ese_allocs)) { |
| 8042 | send_resp(dut, conn, SIGMA_ERROR, |
| 8043 | "errorCode,Could not set ExtSch"); |
| 8044 | return 0; |
| 8045 | } |
Alexei Avshalom Lazar | aad97b0 | 2018-12-18 16:01:23 +0200 | [diff] [blame] | 8046 | if (dut->ap_fixed_rate) { |
| 8047 | sigma_dut_print(dut, DUT_MSG_DEBUG, |
| 8048 | "forcing TX MCS index %d", |
| 8049 | dut->ap_mcs); |
| 8050 | if (ap_set_force_mcs(dut, 1, dut->ap_mcs)) { |
| 8051 | send_resp(dut, conn, SIGMA_ERROR, |
| 8052 | "errorCode,Could not force MCS"); |
| 8053 | return -2; |
| 8054 | } |
| 8055 | } |
Alexei Avshalom Lazar | bc180dc | 2018-12-18 16:01:14 +0200 | [diff] [blame] | 8056 | } |
| 8057 | |
Alexei Avshalom Lazar | 744ae8a | 2019-01-31 17:26:46 +0200 | [diff] [blame] | 8058 | if (dut->wps_forced_version) { |
| 8059 | snprintf(buf, sizeof(buf), "SET wps_version_number %d", |
| 8060 | dut->wps_forced_version); |
| 8061 | if (hapd_command(ifname, buf) < 0) { |
| 8062 | send_resp(dut, conn, SIGMA_ERROR, |
| 8063 | "errorCode,Fail to set wps_version_number"); |
| 8064 | return STATUS_SENT; |
| 8065 | } |
| 8066 | } |
| 8067 | |
Jouni Malinen | d86e582 | 2017-08-29 03:55:32 +0300 | [diff] [blame] | 8068 | dut->hostapd_running = 1; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8069 | return 1; |
| 8070 | } |
| 8071 | |
| 8072 | |
Pradeep Reddy POTTETI | eff4611 | 2016-10-13 17:22:03 +0530 | [diff] [blame] | 8073 | static int parse_qos_params(struct sigma_dut *dut, struct sigma_conn *conn, |
| 8074 | struct qos_params *qos, const char *cwmin, |
| 8075 | const char *cwmax, const char *aifs, |
| 8076 | const char *txop, const char *acm) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8077 | { |
Pradeep Reddy POTTETI | eff4611 | 2016-10-13 17:22:03 +0530 | [diff] [blame] | 8078 | int val; |
| 8079 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8080 | if (cwmin) { |
| 8081 | qos->ac = 1; |
Pradeep Reddy POTTETI | eff4611 | 2016-10-13 17:22:03 +0530 | [diff] [blame] | 8082 | val = atoi(cwmin); |
| 8083 | if (val < 0 || val > 15) { |
| 8084 | send_resp(dut, conn, SIGMA_INVALID, |
| 8085 | "errorCode,Invalid cwMin"); |
| 8086 | return 0; |
| 8087 | } |
| 8088 | qos->cwmin = val; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8089 | } |
| 8090 | |
| 8091 | if (cwmax) { |
| 8092 | qos->ac = 1; |
Pradeep Reddy POTTETI | eff4611 | 2016-10-13 17:22:03 +0530 | [diff] [blame] | 8093 | val = atoi(cwmax); |
| 8094 | if (val < 0 || val > 15) { |
| 8095 | send_resp(dut, conn, SIGMA_INVALID, |
| 8096 | "errorCode,Invalid cwMax"); |
| 8097 | return 0; |
| 8098 | } |
| 8099 | qos->cwmax = val; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8100 | } |
| 8101 | |
| 8102 | if (aifs) { |
| 8103 | qos->ac = 1; |
Pradeep Reddy POTTETI | eff4611 | 2016-10-13 17:22:03 +0530 | [diff] [blame] | 8104 | val = atoi(aifs); |
| 8105 | if (val < 1 || val > 255) { |
| 8106 | send_resp(dut, conn, SIGMA_INVALID, |
| 8107 | "errorCode,Invalid AIFS"); |
| 8108 | return 0; |
| 8109 | } |
| 8110 | qos->aifs = val; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8111 | } |
| 8112 | |
| 8113 | if (txop) { |
| 8114 | qos->ac = 1; |
Pradeep Reddy POTTETI | eff4611 | 2016-10-13 17:22:03 +0530 | [diff] [blame] | 8115 | val = atoi(txop); |
| 8116 | if (val < 0 || val > 0xffff) { |
| 8117 | send_resp(dut, conn, SIGMA_INVALID, |
| 8118 | "errorCode,Invalid txop"); |
| 8119 | return 0; |
| 8120 | } |
| 8121 | qos->txop = val * 32; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8122 | } |
| 8123 | |
| 8124 | if (acm) { |
| 8125 | qos->ac = 1; |
| 8126 | qos->acm = strcasecmp(acm, "on") == 0; |
| 8127 | } |
Pradeep Reddy POTTETI | eff4611 | 2016-10-13 17:22:03 +0530 | [diff] [blame] | 8128 | |
| 8129 | return 1; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8130 | } |
| 8131 | |
| 8132 | |
Jouni Malinen | f722271 | 2019-06-13 01:50:21 +0300 | [diff] [blame] | 8133 | static enum sigma_cmd_result cmd_ap_set_apqos(struct sigma_dut *dut, |
| 8134 | struct sigma_conn *conn, |
| 8135 | struct sigma_cmd *cmd) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8136 | { |
| 8137 | /* TXOP: The values provided here for VHT5G only */ |
Pradeep Reddy POTTETI | eff4611 | 2016-10-13 17:22:03 +0530 | [diff] [blame] | 8138 | if (!parse_qos_params(dut, conn, &dut->ap_qos[AP_AC_VO], |
| 8139 | get_param(cmd, "cwmin_VO"), |
| 8140 | get_param(cmd, "cwmax_VO"), |
| 8141 | get_param(cmd, "AIFS_VO"), |
| 8142 | get_param(cmd, "TXOP_VO"), |
| 8143 | get_param(cmd, "ACM_VO")) || |
| 8144 | !parse_qos_params(dut, conn, &dut->ap_qos[AP_AC_VI], |
| 8145 | get_param(cmd, "cwmin_VI"), |
| 8146 | get_param(cmd, "cwmax_VI"), |
| 8147 | get_param(cmd, "AIFS_VI"), |
| 8148 | get_param(cmd, "TXOP_VI"), |
| 8149 | get_param(cmd, "ACM_VI")) || |
| 8150 | !parse_qos_params(dut, conn, &dut->ap_qos[AP_AC_BE], |
| 8151 | get_param(cmd, "cwmin_BE"), |
| 8152 | get_param(cmd, "cwmax_BE"), |
| 8153 | get_param(cmd, "AIFS_BE"), |
| 8154 | get_param(cmd, "TXOP_BE"), |
| 8155 | get_param(cmd, "ACM_BE")) || |
| 8156 | !parse_qos_params(dut, conn, &dut->ap_qos[AP_AC_BK], |
| 8157 | get_param(cmd, "cwmin_BK"), |
| 8158 | get_param(cmd, "cwmax_BK"), |
| 8159 | get_param(cmd, "AIFS_BK"), |
| 8160 | get_param(cmd, "TXOP_BK"), |
| 8161 | get_param(cmd, "ACM_BK"))) |
| 8162 | return 0; |
| 8163 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8164 | return 1; |
| 8165 | } |
| 8166 | |
| 8167 | |
Jouni Malinen | f722271 | 2019-06-13 01:50:21 +0300 | [diff] [blame] | 8168 | static enum sigma_cmd_result cmd_ap_set_staqos(struct sigma_dut *dut, |
| 8169 | struct sigma_conn *conn, |
| 8170 | struct sigma_cmd *cmd) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8171 | { |
Pradeep Reddy POTTETI | eff4611 | 2016-10-13 17:22:03 +0530 | [diff] [blame] | 8172 | if (!parse_qos_params(dut, conn, &dut->ap_sta_qos[AP_AC_VO], |
| 8173 | get_param(cmd, "cwmin_VO"), |
| 8174 | get_param(cmd, "cwmax_VO"), |
| 8175 | get_param(cmd, "AIFS_VO"), |
| 8176 | get_param(cmd, "TXOP_VO"), |
| 8177 | get_param(cmd, "ACM_VO")) || |
| 8178 | !parse_qos_params(dut, conn, &dut->ap_sta_qos[AP_AC_VI], |
| 8179 | get_param(cmd, "cwmin_VI"), |
| 8180 | get_param(cmd, "cwmax_VI"), |
| 8181 | get_param(cmd, "AIFS_VI"), |
| 8182 | get_param(cmd, "TXOP_VI"), |
| 8183 | get_param(cmd, "ACM_VI")) || |
| 8184 | !parse_qos_params(dut, conn, &dut->ap_sta_qos[AP_AC_BE], |
| 8185 | get_param(cmd, "cwmin_BE"), |
| 8186 | get_param(cmd, "cwmax_BE"), |
| 8187 | get_param(cmd, "AIFS_BE"), |
| 8188 | get_param(cmd, "TXOP_BE"), |
| 8189 | get_param(cmd, "ACM_BE")) || |
| 8190 | !parse_qos_params(dut, conn, &dut->ap_sta_qos[AP_AC_BK], |
| 8191 | get_param(cmd, "cwmin_BK"), |
| 8192 | get_param(cmd, "cwmax_BK"), |
| 8193 | get_param(cmd, "AIFS_BK"), |
| 8194 | get_param(cmd, "TXOP_BK"), |
| 8195 | get_param(cmd, "ACM_BK"))) |
| 8196 | return 0; |
| 8197 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8198 | return 1; |
| 8199 | } |
| 8200 | |
| 8201 | |
| 8202 | static void cmd_ath_ap_hs2_reset(struct sigma_dut *dut) |
| 8203 | { |
| 8204 | unsigned char bssid[6]; |
| 8205 | char buf[100]; |
| 8206 | run_system(dut, "cfg -a AP_SSID=\"Hotspot 2.0\""); |
| 8207 | run_system(dut, "cfg -a AP_PRIMARY_CH=1"); |
| 8208 | run_system(dut, "cfg -a AP_SECMODE=WPA"); |
| 8209 | run_system(dut, "cfg -a AP_SECFILE=EAP"); |
| 8210 | run_system(dut, "cfg -a AP_WPA=2"); |
| 8211 | run_system(dut, "cfg -a AP_CYPHER=CCMP"); |
| 8212 | run_system(dut, "cfg -a AP_HOTSPOT=1"); |
| 8213 | run_system(dut, "cfg -a AP_HOTSPOT_ANT=2"); |
| 8214 | run_system(dut, "cfg -a AP_HOTSPOT_INTERNET=0"); |
| 8215 | run_system(dut, "cfg -a AP_HOTSPOT_VENUEGROUP=2"); |
| 8216 | run_system(dut, "cfg -a AP_HOTSPOT_VENUETYPE=8"); |
| 8217 | run_system(dut, "cfg -a AP_HOTSPOT_ROAMINGCONSORTIUM=506f9a"); |
| 8218 | run_system(dut, "cfg -a AP_HOTSPOT_ROAMINGCONSORTIUM2=001bc504bd"); |
| 8219 | if (!get_hwaddr("ath0", bssid)) { |
| 8220 | snprintf(buf, sizeof(buf), "cfg -a AP_HOTSPOT_HESSID=" |
| 8221 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 8222 | bssid[0], bssid[1], bssid[2], bssid[3], |
| 8223 | bssid[4], bssid[5]); |
| 8224 | run_system(dut, buf); |
| 8225 | snprintf(dut->ap_hessid, sizeof(dut->ap_hessid), |
| 8226 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 8227 | bssid[0], bssid[1], bssid[2], bssid[3], |
| 8228 | bssid[4], bssid[5]); |
| 8229 | } else { |
| 8230 | if (!get_hwaddr("wifi0", bssid)) { |
| 8231 | snprintf(buf, sizeof(buf), "cfg -a AP_HOTSPOT_HESSID=" |
| 8232 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 8233 | bssid[0], bssid[1], bssid[2], bssid[3], |
| 8234 | bssid[4], bssid[5]); |
| 8235 | run_system(dut, buf); |
| 8236 | snprintf(dut->ap_hessid, sizeof(dut->ap_hessid), |
| 8237 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 8238 | bssid[0], bssid[1], bssid[2], bssid[3], |
| 8239 | bssid[4], bssid[5]); |
| 8240 | } else { |
| 8241 | /* load the driver and try again */ |
| 8242 | run_system(dut, "/etc/rc.d/rc.wlan up"); |
| 8243 | |
| 8244 | if (!get_hwaddr("wifi0", bssid)) { |
| 8245 | snprintf(buf, sizeof(buf), |
| 8246 | "cfg -a AP_HOTSPOT_HESSID=" |
| 8247 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 8248 | bssid[0], bssid[1], bssid[2], |
| 8249 | bssid[3], bssid[4], bssid[5]); |
| 8250 | run_system(dut, buf); |
| 8251 | snprintf(dut->ap_hessid, |
| 8252 | sizeof(dut->ap_hessid), |
| 8253 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 8254 | bssid[0], bssid[1], bssid[2], |
| 8255 | bssid[3], bssid[4], bssid[5]); |
| 8256 | } |
| 8257 | } |
| 8258 | } |
| 8259 | |
| 8260 | run_system(dut, "cfg -r AP_SSID_2"); |
| 8261 | run_system(dut, "cfg -c"); |
| 8262 | /* run_system(dut, "cfg -s"); */ |
| 8263 | } |
| 8264 | |
| 8265 | |
| 8266 | static void ath_reset_vht_defaults(struct sigma_dut *dut) |
| 8267 | { |
| 8268 | run_system(dut, "cfg -x"); |
| 8269 | run_system(dut, "cfg -a AP_RADIO_ID=1"); |
| 8270 | run_system(dut, "cfg -a AP_PRIMARY_CH_2=36"); |
| 8271 | run_system(dut, "cfg -a AP_STARTMODE=standard"); |
| 8272 | run_system(dut, "cfg -a AP_CHMODE_2=11ACVHT80"); |
| 8273 | run_system(dut, "cfg -a TX_CHAINMASK_2=7"); |
| 8274 | run_system(dut, "cfg -a RX_CHAINMASK_2=7"); |
| 8275 | run_system(dut, "cfg -a ATH_countrycode=0x348"); |
| 8276 | /* NOTE: For Beeliner we have to turn off MU-MIMO */ |
| 8277 | if (system("rm /tmp/secath*") != 0) { |
| 8278 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 8279 | "Failed to remove secath file"); |
| 8280 | } |
| 8281 | } |
| 8282 | |
| 8283 | |
Jouni Malinen | f722271 | 2019-06-13 01:50:21 +0300 | [diff] [blame] | 8284 | static enum sigma_cmd_result cmd_ap_reset_default(struct sigma_dut *dut, |
| 8285 | struct sigma_conn *conn, |
| 8286 | struct sigma_cmd *cmd) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8287 | { |
Ankita Bajaj | 0d5825b | 2017-10-25 16:20:17 +0530 | [diff] [blame] | 8288 | const char *type, *program; |
Pradeep Reddy POTTETI | 83b8067 | 2016-09-02 13:01:44 +0530 | [diff] [blame] | 8289 | enum driver_type drv; |
Alexei Avshalom Lazar | 2712cc8 | 2018-12-23 16:29:14 +0200 | [diff] [blame] | 8290 | char buf[128]; |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 8291 | int i; |
| 8292 | |
| 8293 | for (i = 0; i < MAX_WLAN_TAGS - 1; i++) { |
| 8294 | /* |
| 8295 | * Reset all tagged SSIDs to NULL-string and all key management |
| 8296 | * to open. |
| 8297 | */ |
| 8298 | dut->ap_tag_ssid[i][0] = '\0'; |
| 8299 | dut->ap_tag_key_mgmt[i] = AP2_OPEN; |
| 8300 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8301 | |
Jouni Malinen | 016ae6c | 2019-11-04 17:00:01 +0200 | [diff] [blame] | 8302 | drv = get_driver_type(dut); |
Ankita Bajaj | 0d5825b | 2017-10-25 16:20:17 +0530 | [diff] [blame] | 8303 | |
| 8304 | program = get_param(cmd, "program"); |
| 8305 | if (!program) |
| 8306 | program = get_param(cmd, "prog"); |
| 8307 | dut->program = sigma_program_to_enum(program); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8308 | dut->device_type = AP_unknown; |
| 8309 | type = get_param(cmd, "type"); |
| 8310 | if (type && strcasecmp(type, "Testbed") == 0) |
| 8311 | dut->device_type = AP_testbed; |
| 8312 | if (type && strcasecmp(type, "DUT") == 0) |
| 8313 | dut->device_type = AP_dut; |
| 8314 | |
| 8315 | dut->ap_rts = 0; |
| 8316 | dut->ap_frgmnt = 0; |
| 8317 | dut->ap_bcnint = 0; |
| 8318 | dut->ap_key_mgmt = AP_OPEN; |
| 8319 | dut->ap_ssid[0] = '\0'; |
| 8320 | dut->ap_fake_pkhash = 0; |
| 8321 | memset(dut->ap_qos, 0, sizeof(dut->ap_qos)); |
| 8322 | memset(dut->ap_sta_qos, 0, sizeof(dut->ap_sta_qos)); |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 8323 | dut->ap_addba_reject = VALUE_NOT_SET; |
| 8324 | dut->ap_noack = VALUE_NOT_SET; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8325 | dut->ap_is_dual = 0; |
| 8326 | dut->ap_mode = AP_inval; |
| 8327 | dut->ap_mode_1 = AP_inval; |
| 8328 | |
| 8329 | dut->ap_allow_vht_wep = 0; |
| 8330 | dut->ap_allow_vht_tkip = 0; |
| 8331 | dut->ap_disable_protection = 0; |
| 8332 | memset(dut->ap_countrycode, 0, sizeof(dut->ap_countrycode)); |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 8333 | dut->ap_dyn_bw_sig = VALUE_NOT_SET; |
| 8334 | dut->ap_ldpc = VALUE_NOT_SET; |
| 8335 | dut->ap_sig_rts = VALUE_NOT_SET; |
| 8336 | dut->ap_rx_amsdu = VALUE_NOT_SET; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8337 | dut->ap_txBF = 0; |
Mohammed Shafi Shajakhan | 495fdb2 | 2016-06-02 20:10:56 +0530 | [diff] [blame] | 8338 | dut->ap_mu_txBF = 0; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8339 | dut->ap_chwidth = AP_AUTO; |
| 8340 | |
Sarvepalli, Rajesh Babu | 24dc7e4 | 2016-03-18 21:27:26 +0530 | [diff] [blame] | 8341 | dut->ap_rsn_preauth = 0; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8342 | dut->ap_wpsnfc = 0; |
| 8343 | dut->ap_bss_load = -1; |
| 8344 | dut->ap_p2p_cross_connect = -1; |
| 8345 | |
Pradeep Reddy POTTETI | fba27db | 2015-11-20 16:42:22 +0530 | [diff] [blame] | 8346 | dut->ap_regulatory_mode = AP_80211D_MODE_DISABLED; |
| 8347 | dut->ap_dfs_mode = AP_DFS_MODE_DISABLED; |
Pradeep Reddy Potteti | 4b0cdee | 2017-03-15 12:37:33 +0530 | [diff] [blame] | 8348 | dut->ap_chwidth_offset = SEC_CH_NO; |
Pradeep Reddy POTTETI | fba27db | 2015-11-20 16:42:22 +0530 | [diff] [blame] | 8349 | |
Adil Saeed Musthafa | 6906372 | 2017-04-10 23:13:40 -0700 | [diff] [blame] | 8350 | dut->mbo_pref_ap_cnt = 0; |
Adil Saeed Musthafa | 4ec61bd | 2017-04-10 23:13:41 -0700 | [diff] [blame] | 8351 | dut->ft_bss_mac_cnt = 0; |
priyadharshini gowthaman | 09d613e | 2017-12-20 11:43:44 -0800 | [diff] [blame] | 8352 | dut->ap_interface_5g = 0; |
| 8353 | dut->ap_interface_2g = 0; |
priyadharshini gowthaman | a3fe8c6 | 2018-01-26 15:19:41 -0800 | [diff] [blame] | 8354 | dut->ap_pmf = AP_PMF_DISABLED; |
Adil Saeed Musthafa | 6906372 | 2017-04-10 23:13:40 -0700 | [diff] [blame] | 8355 | |
Alexei Avshalom Lazar | 33f700c | 2018-12-18 16:00:39 +0200 | [diff] [blame] | 8356 | dut->wsc_fragment = 0; |
Alexei Avshalom Lazar | 2eccf4d | 2019-01-31 10:03:59 +0200 | [diff] [blame] | 8357 | dut->eap_fragment = 0; |
Alexei Avshalom Lazar | 744ae8a | 2019-01-31 17:26:46 +0200 | [diff] [blame] | 8358 | dut->wps_forced_version = 0; |
Alexei Avshalom Lazar | 33f700c | 2018-12-18 16:00:39 +0200 | [diff] [blame] | 8359 | |
Mohammed Shafi Shajakhan | 02e3b82 | 2017-02-23 04:15:02 +0530 | [diff] [blame] | 8360 | if (dut->program == PROGRAM_HT || dut->program == PROGRAM_VHT) { |
Pradeep Reddy POTTETI | 0d3db63 | 2016-03-11 15:21:11 +0530 | [diff] [blame] | 8361 | dut->ap_wme = AP_WME_ON; |
Mohammed Shafi Shajakhan | 02e3b82 | 2017-02-23 04:15:02 +0530 | [diff] [blame] | 8362 | dut->ap_wmmps = AP_WMMPS_ON; |
| 8363 | } else { |
Pradeep Reddy POTTETI | 0d3db63 | 2016-03-11 15:21:11 +0530 | [diff] [blame] | 8364 | dut->ap_wme = AP_WME_OFF; |
Mohammed Shafi Shajakhan | 02e3b82 | 2017-02-23 04:15:02 +0530 | [diff] [blame] | 8365 | dut->ap_wmmps = AP_WMMPS_OFF; |
| 8366 | } |
Pradeep Reddy POTTETI | 0d3db63 | 2016-03-11 15:21:11 +0530 | [diff] [blame] | 8367 | |
Jouni Malinen | 54a89b0 | 2018-05-01 00:16:26 +0300 | [diff] [blame] | 8368 | dut->ap_venue_url = 0; |
Jouni Malinen | f7ff42b | 2018-05-01 00:21:56 +0300 | [diff] [blame] | 8369 | dut->ap_advice_of_charge = 0; |
Jouni Malinen | ac10453 | 2018-05-01 00:27:37 +0300 | [diff] [blame] | 8370 | dut->ap_oper_icon_metadata = 0; |
Jouni Malinen | ac36714 | 2018-05-01 00:32:24 +0300 | [diff] [blame] | 8371 | dut->ap_tnc_file_name = 0; |
| 8372 | dut->ap_tnc_time_stamp = 0; |
Jouni Malinen | 54a89b0 | 2018-05-01 00:16:26 +0300 | [diff] [blame] | 8373 | |
Jouni Malinen | da5f35b | 2019-03-26 00:25:53 +0200 | [diff] [blame] | 8374 | dut->ap_akm_values = 0; |
Jouni Malinen | 09550de | 2019-03-26 00:24:11 +0200 | [diff] [blame] | 8375 | free(dut->ap_sae_passwords); |
| 8376 | dut->ap_sae_passwords = NULL; |
| 8377 | |
Adil Saeed Musthafa | 33ea287 | 2017-04-10 23:13:24 -0700 | [diff] [blame] | 8378 | if (dut->program == PROGRAM_HS2 || dut->program == PROGRAM_HS2_R2 || |
Jouni Malinen | ba63045 | 2018-06-22 11:49:59 +0300 | [diff] [blame] | 8379 | dut->program == PROGRAM_HS2_R3 || |
Adil Saeed Musthafa | 33ea287 | 2017-04-10 23:13:24 -0700 | [diff] [blame] | 8380 | dut->program == PROGRAM_IOTLP) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8381 | int i; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8382 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8383 | if (drv == DRIVER_ATHEROS) |
| 8384 | cmd_ath_ap_hs2_reset(dut); |
| 8385 | else if (drv == DRIVER_OPENWRT) |
| 8386 | cmd_owrt_ap_hs2_reset(dut); |
| 8387 | |
| 8388 | dut->ap_interworking = 1; |
| 8389 | dut->ap_access_net_type = 2; |
| 8390 | dut->ap_internet = 0; |
| 8391 | dut->ap_venue_group = 2; |
| 8392 | dut->ap_venue_type = 8; |
| 8393 | dut->ap_domain_name_list[0] = '\0'; |
| 8394 | dut->ap_hs2 = 1; |
| 8395 | snprintf(dut->ap_roaming_cons, sizeof(dut->ap_roaming_cons), |
| 8396 | "506f9a;001bc504bd"); |
| 8397 | dut->ap_l2tif = 0; |
| 8398 | dut->ap_proxy_arp = 0; |
| 8399 | if (dut->bridge) { |
| 8400 | char buf[50]; |
| 8401 | |
| 8402 | snprintf(buf, sizeof(buf), "ip neigh flush dev %s", |
| 8403 | dut->bridge); |
| 8404 | if (system(buf) != 0) { |
| 8405 | sigma_dut_print(dut, DUT_MSG_DEBUG, |
| 8406 | "%s ip neigh table flushing failed", |
| 8407 | dut->bridge); |
| 8408 | } |
| 8409 | |
| 8410 | snprintf(buf, sizeof(buf), "ebtables -F"); |
| 8411 | if (system(buf) != 0) { |
| 8412 | sigma_dut_print(dut, DUT_MSG_DEBUG, |
| 8413 | "%s ebtables flushing failed", |
| 8414 | dut->bridge); |
| 8415 | } |
| 8416 | } |
| 8417 | dut->ap_dgaf_disable = 0; |
| 8418 | dut->ap_p2p_cross_connect = 0; |
| 8419 | dut->ap_gas_cb_delay = 0; |
| 8420 | dut->ap_nai_realm_list = 0; |
| 8421 | dut->ap_oper_name = 0; |
| 8422 | dut->ap_venue_name = 0; |
| 8423 | for (i = 0; i < 10; i++) { |
| 8424 | dut->ap_plmn_mcc[i][0] = '\0'; |
| 8425 | dut->ap_plmn_mnc[i][0] = '\0'; |
| 8426 | } |
| 8427 | dut->ap_wan_metrics = 0; |
| 8428 | dut->ap_conn_capab = 0; |
| 8429 | dut->ap_ip_addr_type_avail = 0; |
| 8430 | dut->ap_net_auth_type = 0; |
| 8431 | dut->ap_oper_class = 0; |
| 8432 | dut->ap_pmf = 0; |
| 8433 | dut->ap_add_sha256 = 0; |
| 8434 | } |
| 8435 | |
Jouni Malinen | ba63045 | 2018-06-22 11:49:59 +0300 | [diff] [blame] | 8436 | if (dut->program == PROGRAM_HS2_R2 || dut->program == PROGRAM_HS2_R3 || |
| 8437 | dut->program == PROGRAM_IOTLP) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8438 | int i; |
| 8439 | const char hessid[] = "50:6f:9a:00:11:22"; |
| 8440 | |
| 8441 | memcpy(dut->ap_hessid, hessid, strlen(hessid) + 1); |
| 8442 | dut->ap_osu_ssid[0] = '\0'; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8443 | dut->ap_pmf = 1; |
| 8444 | dut->ap_osu_provider_list = 0; |
Jouni Malinen | 93a837f | 2018-11-01 17:09:22 +0200 | [diff] [blame] | 8445 | dut->ap_osu_provider_nai_list = 0; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8446 | for (i = 0; i < 10; i++) { |
| 8447 | dut->ap_osu_server_uri[i][0] = '\0'; |
| 8448 | dut->ap_osu_method[i] = 0xFF; |
| 8449 | } |
| 8450 | dut->ap_qos_map_set = 0; |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 8451 | dut->ap_tag_key_mgmt[0] = AP2_OPEN; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8452 | dut->ap2_proxy_arp = 0; |
Jouni Malinen | dbbc2c4 | 2018-11-14 23:55:41 +0200 | [diff] [blame] | 8453 | dut->ap2_osu = 0; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8454 | dut->ap_osu_icon_tag = 0; |
| 8455 | } |
| 8456 | |
| 8457 | if (dut->program == PROGRAM_VHT) { |
| 8458 | /* Set up the defaults */ |
| 8459 | dut->ap_mode = AP_11ac; |
| 8460 | dut->ap_channel = 36; |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 8461 | dut->ap_ampdu = VALUE_NOT_SET; |
priyadharshini gowthaman | 264d544 | 2016-02-25 15:52:22 -0800 | [diff] [blame] | 8462 | dut->ap_ndpa_frame = 1; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8463 | if (dut->device_type == AP_testbed) { |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 8464 | dut->ap_amsdu = VALUE_DISABLED; |
| 8465 | dut->ap_ldpc = VALUE_DISABLED; |
| 8466 | dut->ap_rx_amsdu = VALUE_DISABLED; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8467 | dut->ap_sgi80 = 0; |
| 8468 | } else { |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 8469 | dut->ap_amsdu = VALUE_ENABLED; |
Pradeep Reddy POTTETI | 83b8067 | 2016-09-02 13:01:44 +0530 | [diff] [blame] | 8470 | /* |
| 8471 | * As LDPC is optional, don't enable this by default |
| 8472 | * for LINUX-WCN driver. The ap_set_wireless command |
| 8473 | * can be used to enable LDPC, when needed. |
| 8474 | */ |
| 8475 | if (drv != DRIVER_LINUX_WCN) |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 8476 | dut->ap_ldpc = VALUE_ENABLED; |
| 8477 | dut->ap_rx_amsdu = VALUE_ENABLED; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8478 | dut->ap_sgi80 = 1; |
| 8479 | } |
| 8480 | dut->ap_fixed_rate = 0; |
| 8481 | dut->ap_rx_streams = 3; |
| 8482 | dut->ap_tx_streams = 3; |
| 8483 | dut->ap_vhtmcs_map = 0; |
| 8484 | dut->ap_chwidth = AP_80; |
| 8485 | dut->ap_tx_stbc = 1; |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 8486 | dut->ap_dyn_bw_sig = VALUE_ENABLED; |
Mohammed Shafi Shajakhan | bae7230 | 2016-03-02 11:56:23 +0530 | [diff] [blame] | 8487 | if (get_openwrt_driver_type() == OPENWRT_DRIVER_ATHEROS) |
| 8488 | dut->ap_dfs_mode = AP_DFS_MODE_ENABLED; |
Jouni Malinen | 016ae6c | 2019-11-04 17:00:01 +0200 | [diff] [blame] | 8489 | if (get_driver_type(dut) == DRIVER_ATHEROS) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8490 | ath_reset_vht_defaults(dut); |
| 8491 | } |
| 8492 | |
Adil Saeed Musthafa | 33ea287 | 2017-04-10 23:13:24 -0700 | [diff] [blame] | 8493 | if (dut->program == PROGRAM_IOTLP) { |
| 8494 | dut->wnm_bss_max_feature = VALUE_DISABLED; |
| 8495 | dut->wnm_bss_max_idle_time = 0; |
| 8496 | dut->wnm_bss_max_protection = VALUE_NOT_SET; |
| 8497 | dut->ap_proxy_arp = 1; |
| 8498 | } else { |
| 8499 | /* |
| 8500 | * Do not touch the BSS-MAX Idle time feature |
| 8501 | * if the program is not IOTLP. |
| 8502 | */ |
| 8503 | dut->wnm_bss_max_feature = VALUE_NOT_SET; |
| 8504 | dut->wnm_bss_max_idle_time = 0; |
| 8505 | dut->wnm_bss_max_protection = VALUE_NOT_SET; |
| 8506 | } |
| 8507 | |
priyadharshini gowthaman | a27b5b6 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 8508 | if (dut->program == PROGRAM_LOC) { |
priyadharshini gowthaman | 8e26ff4 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 8509 | dut->ap_rrm = 1; |
| 8510 | dut->ap_rtt = 1; |
| 8511 | dut->ap_lci = 0; |
| 8512 | dut->ap_val_lci[0] = '\0'; |
priyadharshini gowthaman | c2357bd | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 8513 | dut->ap_infoz[0] = '\0'; |
priyadharshini gowthaman | 8e26ff4 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 8514 | dut->ap_lcr = 0; |
| 8515 | dut->ap_val_lcr[0] = '\0'; |
| 8516 | dut->ap_neighap = 0; |
| 8517 | dut->ap_opchannel = 0; |
| 8518 | dut->ap_scan = 0; |
priyadharshini gowthaman | c2357bd | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 8519 | dut->ap_fqdn_held = 0; |
| 8520 | dut->ap_fqdn_supl = 0; |
priyadharshini gowthaman | c52fff8 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 8521 | dut->ap_interworking = 0; |
| 8522 | dut->ap_gas_cb_delay = 0; |
priyadharshini gowthaman | a27b5b6 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 8523 | dut->ap_msnt_type = 0; |
| 8524 | } |
Adil Saeed Musthafa | 4ec61bd | 2017-04-10 23:13:41 -0700 | [diff] [blame] | 8525 | dut->ap_ft_oa = 0; |
Jouni Malinen | 9f94331 | 2019-08-19 23:49:16 +0300 | [diff] [blame] | 8526 | dut->ap_ft_ds = VALUE_NOT_SET; |
Adil Saeed Musthafa | 604c826 | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 8527 | dut->ap_reg_domain = REG_DOMAIN_NOT_SET; |
Adil Saeed Musthafa | cf752fa | 2017-04-10 23:13:32 -0700 | [diff] [blame] | 8528 | dut->ap_mobility_domain[0] = '\0'; |
priyadharshini gowthaman | a27b5b6 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 8529 | |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 8530 | if (dut->program == PROGRAM_MBO) { |
| 8531 | dut->ap_mbo = 1; |
| 8532 | dut->ap_interworking = 1; |
| 8533 | dut->ap_ne_class = 0; |
| 8534 | dut->ap_ne_op_ch = 0; |
| 8535 | dut->ap_set_bssidpref = 1; |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 8536 | dut->ap_btmreq_disassoc_imnt = 0; |
| 8537 | dut->ap_btmreq_term_bit = 0; |
| 8538 | dut->ap_disassoc_timer = 0; |
| 8539 | dut->ap_btmreq_bss_term_dur = 0; |
Adil Saeed Musthafa | 16d9e63 | 2017-04-10 23:13:38 -0700 | [diff] [blame] | 8540 | dut->ap_channel = 36; |
| 8541 | dut->ap_chwidth = AP_20; |
Adil Saeed Musthafa | 023108a | 2017-04-10 23:13:37 -0700 | [diff] [blame] | 8542 | dut->ap_cell_cap_pref = 0; |
Adil Saeed Musthafa | ed5faae | 2017-04-10 23:13:36 -0700 | [diff] [blame] | 8543 | dut->ap_gas_cb_delay = 0; |
Adil Saeed Musthafa | 6906372 | 2017-04-10 23:13:40 -0700 | [diff] [blame] | 8544 | dut->mbo_self_ap_tuple.ap_ne_class = -1; |
| 8545 | dut->mbo_self_ap_tuple.ap_ne_pref = -1; /* Not set */ |
| 8546 | dut->mbo_self_ap_tuple.ap_ne_op_ch = -1; |
priyadharshini gowthaman | 94062b5 | 2017-12-20 12:33:34 -0800 | [diff] [blame] | 8547 | dut->ap_btmreq_bss_term_tsf = 0; |
priyadharshini gowthaman | 776562e | 2017-12-20 12:33:34 -0800 | [diff] [blame] | 8548 | dut->ap_assoc_delay = 0; |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 8549 | } |
| 8550 | |
priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 8551 | if (dut->program == PROGRAM_OCE) { |
| 8552 | if (dut->ap_dhcp_stop) |
| 8553 | run_system(dut, "/etc/init.d/dnsmasq start"); |
| 8554 | |
| 8555 | dut->ap_dhcp_stop = 0; |
| 8556 | dut->ap_oce = VALUE_ENABLED; |
| 8557 | dut->ap_broadcast_ssid = VALUE_ENABLED; |
| 8558 | dut->ap_fils_dscv_int = 20; |
| 8559 | dut->ap_filsdscv = VALUE_ENABLED; |
| 8560 | dut->ap_filshlp = VALUE_DISABLED; |
| 8561 | dut->ap_rnr = VALUE_DISABLED; |
| 8562 | dut->ap_nairealm[0] = '\0'; |
| 8563 | dut->ap_nairealm_int = 0; |
| 8564 | dut->ap_blechanutil = 0; |
| 8565 | dut->ap_ble_admit_cap = 0; |
| 8566 | dut->ap_esp = VALUE_ENABLED; |
| 8567 | dut->ap_datappdudura = 0; |
| 8568 | dut->ap_airtimefract = 0; |
| 8569 | dut->ap_blestacnt = 0; |
priyadharshini gowthaman | cb22e43 | 2017-12-28 15:23:31 -0800 | [diff] [blame] | 8570 | dut->ap_ul_availcap = 0; |
| 8571 | dut->ap_dl_availcap = 0; |
priyadharshini gowthaman | de81f39 | 2017-12-28 15:28:49 -0800 | [diff] [blame] | 8572 | dut->ap_akm = 0; |
| 8573 | dut->ap_add_sha256 = 0; |
| 8574 | dut->ap_add_sha384 = 0; |
priyadharshini gowthaman | 63ab848 | 2017-12-28 15:32:55 -0800 | [diff] [blame] | 8575 | dut->ap_80plus80 = 0; |
priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 8576 | } |
| 8577 | |
priyadharshini gowthaman | 350f191 | 2018-06-04 13:09:12 -0700 | [diff] [blame] | 8578 | dut->ap_he_ppdu = PPDU_NOT_SET; |
Priyadharshini Gowthaman | fe60c50 | 2019-08-14 13:00:34 -0700 | [diff] [blame] | 8579 | dut->ap_he_ulofdma = VALUE_NOT_SET; |
Priyadharshini Gowthaman | bc94889 | 2019-09-10 14:22:49 -0700 | [diff] [blame] | 8580 | dut->ap_numsounddim = 0; |
Priyadharshini Gowthaman | 670b323 | 2019-09-10 16:09:19 -0700 | [diff] [blame] | 8581 | dut->ap_bcc = VALUE_DISABLED; |
Priyadharshini Gowthaman | 21895a5 | 2019-10-07 16:56:16 -0700 | [diff] [blame] | 8582 | dut->ap_mu_edca = VALUE_DISABLED; |
Priyadharshini Gowthaman | dee79e2 | 2019-10-07 16:56:27 -0700 | [diff] [blame] | 8583 | dut->ap_he_mimo = MIMO_NOT_SET; |
Priyadharshini Gowthaman | 43d6b41 | 2019-10-07 16:56:37 -0700 | [diff] [blame] | 8584 | dut->ap_he_rtsthrshld = VALUE_NOT_SET; |
Priyadharshini Gowthaman | 8018c98 | 2019-10-31 15:14:37 -0700 | [diff] [blame] | 8585 | dut->ap_mbssid = VALUE_DISABLED; |
Priyadharshini Gowthaman | 6bc4c1e | 2019-09-10 16:24:51 -0700 | [diff] [blame] | 8586 | if (dut->device_type == AP_testbed) { |
Priyadharshini Gowthaman | fe60c50 | 2019-08-14 13:00:34 -0700 | [diff] [blame] | 8587 | dut->ap_he_dlofdma = VALUE_DISABLED; |
Priyadharshini Gowthaman | 6bc4c1e | 2019-09-10 16:24:51 -0700 | [diff] [blame] | 8588 | dut->ap_he_frag = VALUE_DISABLED; |
Priyadharshini Gowthaman | ae0a605 | 2019-11-01 15:26:38 -0700 | [diff] [blame] | 8589 | dut->ap_twtresp = VALUE_DISABLED; |
Priyadharshini Gowthaman | 6bc4c1e | 2019-09-10 16:24:51 -0700 | [diff] [blame] | 8590 | } else { |
Priyadharshini Gowthaman | fe60c50 | 2019-08-14 13:00:34 -0700 | [diff] [blame] | 8591 | dut->ap_he_dlofdma = VALUE_NOT_SET; |
Priyadharshini Gowthaman | 6bc4c1e | 2019-09-10 16:24:51 -0700 | [diff] [blame] | 8592 | dut->ap_he_frag = VALUE_NOT_SET; |
Priyadharshini Gowthaman | 1a686bd | 2019-09-19 14:41:40 -0700 | [diff] [blame] | 8593 | dut->ap_ba_bufsize = BA_BUFSIZE_NOT_SET; |
Priyadharshini Gowthaman | ae0a605 | 2019-11-01 15:26:38 -0700 | [diff] [blame] | 8594 | dut->ap_twtresp = VALUE_NOT_SET; |
Priyadharshini Gowthaman | 6bc4c1e | 2019-09-10 16:24:51 -0700 | [diff] [blame] | 8595 | } |
priyadharshini gowthaman | 350f191 | 2018-06-04 13:09:12 -0700 | [diff] [blame] | 8596 | |
Priyadharshini Gowthaman | 670b323 | 2019-09-10 16:09:19 -0700 | [diff] [blame] | 8597 | if (dut->program == PROGRAM_HE) { |
Priyadharshini Gowthaman | 1a686bd | 2019-09-19 14:41:40 -0700 | [diff] [blame] | 8598 | if (dut->device_type == AP_testbed) { |
Priyadharshini Gowthaman | 670b323 | 2019-09-10 16:09:19 -0700 | [diff] [blame] | 8599 | dut->ap_ldpc = VALUE_DISABLED; |
Priyadharshini Gowthaman | 1a686bd | 2019-09-19 14:41:40 -0700 | [diff] [blame] | 8600 | dut->ap_ba_bufsize = BA_BUFSIZE_64; |
| 8601 | } |
Priyadharshini Gowthaman | 670b323 | 2019-09-10 16:09:19 -0700 | [diff] [blame] | 8602 | } |
| 8603 | |
priyadharshini gowthaman | 9149afc | 2018-01-15 13:40:18 -0800 | [diff] [blame] | 8604 | dut->ap_oper_chn = 0; |
| 8605 | |
Jouni Malinen | b75c532 | 2019-06-14 01:47:43 +0300 | [diff] [blame] | 8606 | dut->ap_pmksa = 0; |
| 8607 | dut->ap_pmksa_caching = 0; |
| 8608 | |
Jouni Malinen | 3c367e8 | 2017-06-23 17:01:47 +0300 | [diff] [blame] | 8609 | free(dut->rsne_override); |
| 8610 | dut->rsne_override = NULL; |
| 8611 | |
Jouni Malinen | 6814313 | 2017-09-02 02:34:08 +0300 | [diff] [blame] | 8612 | free(dut->sae_commit_override); |
| 8613 | dut->sae_commit_override = NULL; |
| 8614 | |
Jouni Malinen | ed670f4 | 2017-08-31 01:39:28 +0300 | [diff] [blame] | 8615 | free(dut->ap_sae_groups); |
| 8616 | dut->ap_sae_groups = NULL; |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 8617 | |
Jouni Malinen | 2f524ce | 2017-08-31 01:43:29 +0300 | [diff] [blame] | 8618 | dut->sae_anti_clogging_threshold = -1; |
Jouni Malinen | b347db0 | 2017-09-02 01:36:03 +0300 | [diff] [blame] | 8619 | dut->sae_reflection = 0; |
Jouni Malinen | 3c740ab | 2019-10-10 15:55:11 +0300 | [diff] [blame] | 8620 | dut->sae_confirm_immediate = 0; |
Jouni Malinen | 2f524ce | 2017-08-31 01:43:29 +0300 | [diff] [blame] | 8621 | |
Jouni Malinen | 3d633da | 2017-09-14 22:19:21 +0300 | [diff] [blame] | 8622 | dut->ap_cipher = AP_CCMP; |
Jouni Malinen | 2ba2449 | 2017-11-17 12:43:59 +0200 | [diff] [blame] | 8623 | dut->ap_group_cipher = AP_NO_GROUP_CIPHER_SET; |
Jouni Malinen | 3d633da | 2017-09-14 22:19:21 +0300 | [diff] [blame] | 8624 | dut->ap_group_mgmt_cipher = AP_NO_GROUP_MGMT_CIPHER_SET; |
Jouni Malinen | 6337062 | 2017-11-18 17:47:13 +0200 | [diff] [blame] | 8625 | dut->ap_passphrase[0] = '\0'; |
| 8626 | dut->ap_psk[0] = '\0'; |
Jouni Malinen | 3d633da | 2017-09-14 22:19:21 +0300 | [diff] [blame] | 8627 | |
Jouni Malinen | d86e582 | 2017-08-29 03:55:32 +0300 | [diff] [blame] | 8628 | dut->dpp_conf_id = -1; |
Jouni Malinen | ba4f2d4 | 2019-10-04 16:13:41 +0300 | [diff] [blame] | 8629 | free(dut->ap_dpp_conf_addr); |
| 8630 | dut->ap_dpp_conf_addr = NULL; |
| 8631 | free(dut->ap_dpp_conf_pkhash); |
| 8632 | dut->ap_dpp_conf_pkhash = NULL; |
Jouni Malinen | d86e582 | 2017-08-29 03:55:32 +0300 | [diff] [blame] | 8633 | |
Alexei Avshalom Lazar | eee9ab0 | 2018-12-24 16:27:48 +0200 | [diff] [blame] | 8634 | if (is_60g_sigma_dut(dut)) { |
Alexei Avshalom Lazar | 2712cc8 | 2018-12-23 16:29:14 +0200 | [diff] [blame] | 8635 | dut->ap_mode = AP_11ad; |
| 8636 | dut->ap_channel = 2; |
Alexei Avshalom Lazar | eee9ab0 | 2018-12-24 16:27:48 +0200 | [diff] [blame] | 8637 | dut->wps_disable = 0; /* WPS is enabled */ |
Alexei Avshalom Lazar | 2712cc8 | 2018-12-23 16:29:14 +0200 | [diff] [blame] | 8638 | dut->ap_pmf = 0; |
Alexei Avshalom Lazar | bc180dc | 2018-12-18 16:01:14 +0200 | [diff] [blame] | 8639 | dut->ap_num_ese_allocs = 0; |
Alexei Avshalom Lazar | 2712cc8 | 2018-12-23 16:29:14 +0200 | [diff] [blame] | 8640 | dut->ap_fixed_rate = 0; |
| 8641 | |
| 8642 | dut->dev_role = DEVROLE_AP; |
| 8643 | |
| 8644 | sigma_dut_print(dut, DUT_MSG_DEBUG, |
| 8645 | "Setting msdu_size to MAX: 7912"); |
| 8646 | snprintf(buf, sizeof(buf), "ifconfig %s mtu 7912", |
Jouni Malinen | 016ae6c | 2019-11-04 17:00:01 +0200 | [diff] [blame] | 8647 | get_main_ifname(dut)); |
Alexei Avshalom Lazar | 2712cc8 | 2018-12-23 16:29:14 +0200 | [diff] [blame] | 8648 | |
| 8649 | if (system(buf) != 0) { |
| 8650 | sigma_dut_print(dut, DUT_MSG_ERROR, "Failed to set %s", |
| 8651 | buf); |
Jouni Malinen | 0e29cf2 | 2019-02-19 01:13:21 +0200 | [diff] [blame] | 8652 | return ERROR_SEND_STATUS; |
Alexei Avshalom Lazar | 2712cc8 | 2018-12-23 16:29:14 +0200 | [diff] [blame] | 8653 | } |
| 8654 | |
Alexei Avshalom Lazar | aad97b0 | 2018-12-18 16:01:23 +0200 | [diff] [blame] | 8655 | if (ap_set_force_mcs(dut, 0, 1)) { |
| 8656 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 8657 | "Failed to reset force MCS"); |
Jouni Malinen | 0e29cf2 | 2019-02-19 01:13:21 +0200 | [diff] [blame] | 8658 | return ERROR_SEND_STATUS; |
Alexei Avshalom Lazar | aad97b0 | 2018-12-18 16:01:23 +0200 | [diff] [blame] | 8659 | } |
| 8660 | |
Jouni Malinen | 016ae6c | 2019-11-04 17:00:01 +0200 | [diff] [blame] | 8661 | if (set_ps(get_main_ifname(dut), dut, 1)) { |
Alexei Avshalom Lazar | 2712cc8 | 2018-12-23 16:29:14 +0200 | [diff] [blame] | 8662 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 8663 | "Failed to enable power save"); |
Jouni Malinen | 0e29cf2 | 2019-02-19 01:13:21 +0200 | [diff] [blame] | 8664 | return ERROR_SEND_STATUS; |
Alexei Avshalom Lazar | 2712cc8 | 2018-12-23 16:29:14 +0200 | [diff] [blame] | 8665 | } |
| 8666 | } |
| 8667 | |
Alexei Avshalom Lazar | b6d25d5 | 2019-02-04 14:08:44 +0200 | [diff] [blame] | 8668 | if (dut->program == PROGRAM_WPS && |
Jouni Malinen | 016ae6c | 2019-11-04 17:00:01 +0200 | [diff] [blame] | 8669 | get_driver_type(dut) == DRIVER_WIL6210) { |
Alexei Avshalom Lazar | b6d25d5 | 2019-02-04 14:08:44 +0200 | [diff] [blame] | 8670 | /* |
| 8671 | * In 60 GHz WPS tests, we configure the AP OOB to |
| 8672 | * secure connection with a random passphrase. |
| 8673 | */ |
| 8674 | char r[16], passphrase[65]; |
| 8675 | |
| 8676 | if (random_get_bytes(r, sizeof(r))) { |
| 8677 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 8678 | "Failed to get random bytes"); |
| 8679 | return ERROR_SEND_STATUS; |
| 8680 | } |
| 8681 | if (base64_encode(r, sizeof(r), |
| 8682 | passphrase, sizeof(passphrase))) { |
| 8683 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 8684 | "Failed to generate random passphrase"); |
| 8685 | return ERROR_SEND_STATUS; |
| 8686 | } |
| 8687 | |
| 8688 | dut->ap_key_mgmt = AP_WPA2_PSK; |
| 8689 | dut->ap_cipher = AP_GCMP_128; |
| 8690 | strlcpy(dut->ap_passphrase, passphrase, |
| 8691 | sizeof(dut->ap_passphrase)); |
| 8692 | sigma_dut_print(dut, DUT_MSG_DEBUG, |
| 8693 | "60G WPS: configure secure AP with random passphrase"); |
| 8694 | } |
| 8695 | |
Jouni Malinen | d86e582 | 2017-08-29 03:55:32 +0300 | [diff] [blame] | 8696 | dut->hostapd_running = 0; |
priyadharshini gowthaman | 9947fd3 | 2018-01-26 15:19:41 -0800 | [diff] [blame] | 8697 | |
| 8698 | if (get_openwrt_driver_type() == OPENWRT_DRIVER_ATHEROS) |
| 8699 | return 1; |
| 8700 | |
Jouni Malinen | d6bf1b4 | 2017-06-23 17:51:01 +0300 | [diff] [blame] | 8701 | if (dut->use_hostapd_pid_file) { |
| 8702 | kill_hostapd_process_pid(dut); |
| 8703 | } else if (kill_process(dut, "(hostapd)", 1, SIGTERM) == 0 || |
| 8704 | system("killall hostapd") == 0) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8705 | int i; |
| 8706 | /* Wait some time to allow hostapd to complete cleanup before |
| 8707 | * starting a new process */ |
| 8708 | for (i = 0; i < 10; i++) { |
| 8709 | usleep(500000); |
| 8710 | if (system("pidof hostapd") != 0) |
| 8711 | break; |
| 8712 | } |
| 8713 | } |
| 8714 | |
| 8715 | if (if_nametoindex("sigmadut") > 0 && |
| 8716 | system("iw dev sigmadut del") != 0) |
| 8717 | sigma_dut_print(dut, DUT_MSG_ERROR, "Failed to remove " |
| 8718 | "monitor interface"); |
| 8719 | |
| 8720 | return 1; |
| 8721 | } |
| 8722 | |
| 8723 | |
Ankita Bajaj | 0d5825b | 2017-10-25 16:20:17 +0530 | [diff] [blame] | 8724 | int sta_cfon_reset_default(struct sigma_dut *dut, struct sigma_conn *conn, |
| 8725 | struct sigma_cmd *cmd) |
| 8726 | { |
| 8727 | return cmd_ap_reset_default(dut, conn, cmd); |
| 8728 | } |
| 8729 | |
| 8730 | |
Jouni Malinen | f722271 | 2019-06-13 01:50:21 +0300 | [diff] [blame] | 8731 | static enum sigma_cmd_result cmd_ap_get_info(struct sigma_dut *dut, |
| 8732 | struct sigma_conn *conn, |
| 8733 | struct sigma_cmd *cmd) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8734 | { |
| 8735 | /* const char *name = get_param(cmd, "NAME"); */ |
| 8736 | struct stat s; |
| 8737 | char resp[200]; |
| 8738 | FILE *f; |
Jouni Malinen | 016ae6c | 2019-11-04 17:00:01 +0200 | [diff] [blame] | 8739 | enum driver_type drv = get_driver_type(dut); |
Jouni Malinen | 3aa7286 | 2019-05-29 23:14:51 +0300 | [diff] [blame] | 8740 | int res; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8741 | |
| 8742 | switch (drv) { |
| 8743 | case DRIVER_ATHEROS: { |
| 8744 | /* Atheros AP */ |
| 8745 | struct utsname uts; |
| 8746 | char *version, athver[100]; |
| 8747 | |
| 8748 | if (stat("/proc/athversion", &s) != 0) { |
| 8749 | if (system("/etc/rc.d/rc.wlan up") != 0) { |
| 8750 | } |
| 8751 | } |
| 8752 | |
| 8753 | athver[0] = '\0'; |
| 8754 | f = fopen("/proc/athversion", "r"); |
| 8755 | if (f) { |
| 8756 | if (fgets(athver, sizeof(athver), f)) { |
| 8757 | char *pos = strchr(athver, '\n'); |
| 8758 | if (pos) |
| 8759 | *pos = '\0'; |
| 8760 | } |
| 8761 | fclose(f); |
| 8762 | } |
| 8763 | |
| 8764 | if (uname(&uts) == 0) |
| 8765 | version = uts.release; |
| 8766 | else |
| 8767 | version = "Unknown"; |
| 8768 | |
| 8769 | if (if_nametoindex("ath1") > 0) |
Jouni Malinen | 3aa7286 | 2019-05-29 23:14:51 +0300 | [diff] [blame] | 8770 | res = snprintf(resp, sizeof(resp), |
| 8771 | "interface,ath0_24G ath1_5G,agent,1.0,version,%s/drv:%s", |
| 8772 | version, athver); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8773 | else |
Jouni Malinen | 3aa7286 | 2019-05-29 23:14:51 +0300 | [diff] [blame] | 8774 | res = snprintf(resp, sizeof(resp), |
| 8775 | "interface,ath0_24G,agent,1.0,version,%s/drv:%s", |
| 8776 | version, athver); |
| 8777 | if (res < 0 || res >= sizeof(resp)) |
| 8778 | send_resp(dut, conn, SIGMA_ERROR, NULL); |
| 8779 | else |
| 8780 | send_resp(dut, conn, SIGMA_COMPLETE, resp); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8781 | return 0; |
| 8782 | } |
Sreelakshmi Konamki | b692f10 | 2016-04-26 19:47:00 +0530 | [diff] [blame] | 8783 | case DRIVER_LINUX_WCN: |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8784 | case DRIVER_MAC80211: { |
| 8785 | struct utsname uts; |
| 8786 | char *version; |
| 8787 | |
| 8788 | if (uname(&uts) == 0) |
| 8789 | version = uts.release; |
| 8790 | else |
| 8791 | version = "Unknown"; |
| 8792 | |
| 8793 | if (if_nametoindex("wlan1") > 0) |
| 8794 | snprintf(resp, sizeof(resp), "interface,wlan0_24G " |
| 8795 | "wlan1_5G,agent,1.0,version,%s", version); |
| 8796 | else |
| 8797 | snprintf(resp, sizeof(resp), "interface,wlan0_any," |
| 8798 | "agent,1.0,version,%s", version); |
| 8799 | |
| 8800 | send_resp(dut, conn, SIGMA_COMPLETE, resp); |
| 8801 | return 0; |
| 8802 | } |
| 8803 | case DRIVER_QNXNTO: { |
| 8804 | struct utsname uts; |
| 8805 | char *version; |
| 8806 | |
| 8807 | if (uname(&uts) == 0) |
| 8808 | version = uts.release; |
| 8809 | else |
| 8810 | version = "Unknown"; |
| 8811 | snprintf(resp, sizeof(resp), |
| 8812 | "interface,%s_any,agent,1.0,version,%s", |
Jouni Malinen | 5ea3092 | 2019-11-04 17:39:25 +0200 | [diff] [blame] | 8813 | dut->main_ifname ? get_main_ifname(dut) : "NA", |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8814 | version); |
| 8815 | send_resp(dut, conn, SIGMA_COMPLETE, resp); |
| 8816 | return 0; |
| 8817 | } |
| 8818 | case DRIVER_OPENWRT: { |
| 8819 | switch (get_openwrt_driver_type()) { |
| 8820 | case OPENWRT_DRIVER_ATHEROS: { |
| 8821 | struct utsname uts; |
| 8822 | char *version; |
| 8823 | |
| 8824 | if (uname(&uts) == 0) |
| 8825 | version = uts.release; |
| 8826 | else |
| 8827 | version = "Unknown"; |
| 8828 | |
| 8829 | if (if_nametoindex("ath1") > 0) |
| 8830 | snprintf(resp, sizeof(resp), |
| 8831 | "interface,ath0_5G ath1_24G,agent,1.0,version,%s", |
| 8832 | version); |
| 8833 | else |
| 8834 | snprintf(resp, sizeof(resp), |
| 8835 | "interface,ath0_any,agent,1.0,version,%s", |
| 8836 | version); |
| 8837 | |
| 8838 | send_resp(dut, conn, SIGMA_COMPLETE, resp); |
| 8839 | return 0; |
| 8840 | } |
| 8841 | default: |
| 8842 | send_resp(dut, conn, SIGMA_ERROR, |
| 8843 | "errorCode,Unsupported openwrt driver"); |
| 8844 | return 0; |
| 8845 | } |
| 8846 | } |
| 8847 | default: |
| 8848 | send_resp(dut, conn, SIGMA_ERROR, |
| 8849 | "errorCode,Unsupported driver"); |
| 8850 | return 0; |
| 8851 | } |
| 8852 | } |
| 8853 | |
| 8854 | |
Jouni Malinen | f722271 | 2019-06-13 01:50:21 +0300 | [diff] [blame] | 8855 | static enum sigma_cmd_result cmd_ap_deauth_sta(struct sigma_dut *dut, |
| 8856 | struct sigma_conn *conn, |
| 8857 | struct sigma_cmd *cmd) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8858 | { |
| 8859 | /* const char *name = get_param(cmd, "NAME"); */ |
| 8860 | /* const char *ifname = get_param(cmd, "INTERFACE"); */ |
Jouni Malinen | 0ac588d | 2019-11-06 18:57:01 +0200 | [diff] [blame^] | 8861 | const char *val, *disconnect; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8862 | char buf[100]; |
| 8863 | |
| 8864 | val = get_param(cmd, "MinorCode"); |
| 8865 | if (val) { |
| 8866 | /* TODO: add support for P2P minor code */ |
| 8867 | send_resp(dut, conn, SIGMA_ERROR, "errorCode,MinorCode not " |
| 8868 | "yet supported"); |
| 8869 | return 0; |
| 8870 | } |
| 8871 | |
| 8872 | val = get_param(cmd, "STA_MAC_ADDRESS"); |
| 8873 | if (val == NULL) |
| 8874 | return -1; |
Jouni Malinen | 0ac588d | 2019-11-06 18:57:01 +0200 | [diff] [blame^] | 8875 | disconnect = get_param(cmd, "disconnect"); |
| 8876 | if (disconnect && strcasecmp(disconnect, "silent") == 0) |
| 8877 | snprintf(buf, sizeof(buf), "deauth %s tx=0", val); |
| 8878 | else |
| 8879 | snprintf(buf, sizeof(buf), "deauth %s", val); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8880 | if (run_hostapd_cli(dut, buf) != 0) |
| 8881 | return -2; |
| 8882 | |
| 8883 | return 1; |
| 8884 | } |
| 8885 | |
| 8886 | |
| 8887 | #ifdef __linux__ |
| 8888 | int inject_frame(int s, const void *data, size_t len, int encrypt); |
| 8889 | int open_monitor(const char *ifname); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8890 | #endif /* __linux__ */ |
| 8891 | |
| 8892 | enum send_frame_type { |
| 8893 | DISASSOC, DEAUTH, SAQUERY |
| 8894 | }; |
| 8895 | enum send_frame_protection { |
| 8896 | CORRECT_KEY, INCORRECT_KEY, UNPROTECTED |
| 8897 | }; |
| 8898 | |
| 8899 | |
| 8900 | static int ap_inject_frame(struct sigma_dut *dut, struct sigma_conn *conn, |
| 8901 | enum send_frame_type frame, |
| 8902 | enum send_frame_protection protected, |
| 8903 | const char *sta_addr) |
| 8904 | { |
| 8905 | #ifdef __linux__ |
| 8906 | unsigned char buf[1000], *pos; |
| 8907 | int s, res; |
| 8908 | unsigned char addr_sta[6], addr_own[6]; |
| 8909 | char *ifname; |
| 8910 | char cbuf[100]; |
| 8911 | struct ifreq ifr; |
| 8912 | |
| 8913 | if ((dut->ap_mode == AP_11a || dut->ap_mode == AP_11na || |
| 8914 | dut->ap_mode == AP_11ac) && |
| 8915 | if_nametoindex("wlan1") > 0) |
| 8916 | ifname = "wlan1"; |
| 8917 | else |
| 8918 | ifname = "wlan0"; |
| 8919 | |
| 8920 | if (hwaddr_aton(sta_addr, addr_sta) < 0) |
| 8921 | return -1; |
| 8922 | |
| 8923 | s = socket(AF_INET, SOCK_DGRAM, 0); |
| 8924 | if (s < 0) |
| 8925 | return -1; |
| 8926 | memset(&ifr, 0, sizeof(ifr)); |
Peng Xu | b8fc5cc | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 8927 | strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name)); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8928 | if (ioctl(s, SIOCGIFHWADDR, &ifr) < 0) { |
| 8929 | perror("ioctl"); |
| 8930 | close(s); |
| 8931 | return -1; |
| 8932 | } |
| 8933 | close(s); |
| 8934 | memcpy(addr_own, ifr.ifr_hwaddr.sa_data, 6); |
| 8935 | |
| 8936 | if (if_nametoindex("sigmadut") == 0) { |
| 8937 | snprintf(cbuf, sizeof(cbuf), |
| 8938 | "iw dev %s interface add sigmadut type monitor", |
| 8939 | ifname); |
| 8940 | if (system(cbuf) != 0 || |
| 8941 | if_nametoindex("sigmadut") == 0) { |
| 8942 | sigma_dut_print(dut, DUT_MSG_ERROR, "Failed to add " |
| 8943 | "monitor interface with '%s'", cbuf); |
| 8944 | return -2; |
| 8945 | } |
| 8946 | } |
| 8947 | |
| 8948 | if (system("ifconfig sigmadut up") != 0) { |
| 8949 | sigma_dut_print(dut, DUT_MSG_ERROR, "Failed to set " |
| 8950 | "monitor interface up"); |
| 8951 | return -2; |
| 8952 | } |
| 8953 | |
| 8954 | pos = buf; |
| 8955 | |
| 8956 | /* Frame Control */ |
| 8957 | switch (frame) { |
| 8958 | case DISASSOC: |
| 8959 | *pos++ = 0xa0; |
| 8960 | break; |
| 8961 | case DEAUTH: |
| 8962 | *pos++ = 0xc0; |
| 8963 | break; |
| 8964 | case SAQUERY: |
| 8965 | *pos++ = 0xd0; |
| 8966 | break; |
| 8967 | } |
| 8968 | |
| 8969 | if (protected == INCORRECT_KEY) |
| 8970 | *pos++ = 0x40; /* Set Protected field to 1 */ |
| 8971 | else |
| 8972 | *pos++ = 0x00; |
| 8973 | |
| 8974 | /* Duration */ |
| 8975 | *pos++ = 0x00; |
| 8976 | *pos++ = 0x00; |
| 8977 | |
| 8978 | /* addr1 = DA (station) */ |
| 8979 | memcpy(pos, addr_sta, 6); |
| 8980 | pos += 6; |
| 8981 | /* addr2 = SA (own address) */ |
| 8982 | memcpy(pos, addr_own, 6); |
| 8983 | pos += 6; |
| 8984 | /* addr3 = BSSID (own address) */ |
| 8985 | memcpy(pos, addr_own, 6); |
| 8986 | pos += 6; |
| 8987 | |
| 8988 | /* Seq# (to be filled by driver/mac80211) */ |
| 8989 | *pos++ = 0x00; |
| 8990 | *pos++ = 0x00; |
| 8991 | |
| 8992 | if (protected == INCORRECT_KEY) { |
| 8993 | /* CCMP parameters */ |
| 8994 | memcpy(pos, "\x61\x01\x00\x20\x00\x10\x00\x00", 8); |
| 8995 | pos += 8; |
| 8996 | } |
| 8997 | |
| 8998 | if (protected == INCORRECT_KEY) { |
| 8999 | switch (frame) { |
| 9000 | case DEAUTH: |
| 9001 | /* Reason code (encrypted) */ |
| 9002 | memcpy(pos, "\xa7\x39", 2); |
| 9003 | pos += 2; |
| 9004 | break; |
| 9005 | case DISASSOC: |
| 9006 | /* Reason code (encrypted) */ |
| 9007 | memcpy(pos, "\xa7\x39", 2); |
| 9008 | pos += 2; |
| 9009 | break; |
| 9010 | case SAQUERY: |
| 9011 | /* Category|Action|TransID (encrypted) */ |
| 9012 | memcpy(pos, "\x6f\xbd\xe9\x4d", 4); |
| 9013 | pos += 4; |
| 9014 | break; |
| 9015 | default: |
| 9016 | return -1; |
| 9017 | } |
| 9018 | |
| 9019 | /* CCMP MIC */ |
| 9020 | memcpy(pos, "\xc8\xd8\x3b\x06\x5d\xb7\x25\x68", 8); |
| 9021 | pos += 8; |
| 9022 | } else { |
| 9023 | switch (frame) { |
| 9024 | case DEAUTH: |
| 9025 | /* reason code = 8 */ |
| 9026 | *pos++ = 0x08; |
| 9027 | *pos++ = 0x00; |
| 9028 | break; |
| 9029 | case DISASSOC: |
| 9030 | /* reason code = 8 */ |
| 9031 | *pos++ = 0x08; |
| 9032 | *pos++ = 0x00; |
| 9033 | break; |
| 9034 | case SAQUERY: |
| 9035 | /* Category - SA Query */ |
| 9036 | *pos++ = 0x08; |
| 9037 | /* SA query Action - Request */ |
| 9038 | *pos++ = 0x00; |
| 9039 | /* Transaction ID */ |
| 9040 | *pos++ = 0x12; |
| 9041 | *pos++ = 0x34; |
| 9042 | break; |
| 9043 | } |
| 9044 | } |
| 9045 | |
| 9046 | s = open_monitor("sigmadut"); |
| 9047 | if (s < 0) { |
| 9048 | send_resp(dut, conn, SIGMA_ERROR, "errorCode,Failed to open " |
| 9049 | "monitor socket"); |
| 9050 | return 0; |
| 9051 | } |
| 9052 | |
| 9053 | res = inject_frame(s, buf, pos - buf, protected == CORRECT_KEY); |
| 9054 | if (res < 0) { |
| 9055 | send_resp(dut, conn, SIGMA_ERROR, "errorCode,Failed to " |
| 9056 | "inject frame"); |
Pradeep Reddy POTTETI | 673d85c | 2016-07-26 19:08:07 +0530 | [diff] [blame] | 9057 | close(s); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9058 | return 0; |
| 9059 | } |
| 9060 | if (res < pos - buf) { |
| 9061 | send_resp(dut, conn, SIGMA_ERROR, "errorCode,Only partial " |
| 9062 | "frame sent"); |
Pradeep Reddy POTTETI | 673d85c | 2016-07-26 19:08:07 +0530 | [diff] [blame] | 9063 | close(s); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9064 | return 0; |
| 9065 | } |
| 9066 | |
| 9067 | close(s); |
| 9068 | |
| 9069 | return 1; |
| 9070 | #else /* __linux__ */ |
| 9071 | send_resp(dut, conn, SIGMA_ERROR, "errorCode,ap_send_frame not " |
| 9072 | "yet supported"); |
| 9073 | return 0; |
| 9074 | #endif /* __linux__ */ |
| 9075 | } |
| 9076 | |
| 9077 | |
| 9078 | int ap_send_frame_hs2(struct sigma_dut *dut, struct sigma_conn *conn, |
| 9079 | struct sigma_cmd *cmd) |
| 9080 | { |
| 9081 | const char *val, *dest; |
| 9082 | char buf[100]; |
| 9083 | |
| 9084 | val = get_param(cmd, "FrameName"); |
| 9085 | if (val == NULL) |
| 9086 | return -1; |
| 9087 | |
| 9088 | if (strcasecmp(val, "QoSMapConfigure") == 0) { |
| 9089 | dest = get_param(cmd, "Dest"); |
| 9090 | if (!dest) |
| 9091 | return -1; |
| 9092 | |
| 9093 | val = get_param(cmd, "QoS_MAP_SET"); |
| 9094 | if (val) { |
| 9095 | dut->ap_qos_map_set = atoi(val); |
| 9096 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_qos_map_set %d", |
| 9097 | dut->ap_qos_map_set); |
| 9098 | } |
| 9099 | |
| 9100 | if (dut->ap_qos_map_set == 1) |
| 9101 | run_hostapd_cli(dut, "set_qos_map_set " QOS_MAP_SET_1); |
| 9102 | else if (dut->ap_qos_map_set == 2) |
| 9103 | run_hostapd_cli(dut, "set_qos_map_set " QOS_MAP_SET_2); |
| 9104 | |
| 9105 | snprintf(buf, sizeof(buf), "send_qos_map_conf %s", dest); |
| 9106 | if (run_hostapd_cli(dut, buf) != 0) |
| 9107 | return -1; |
| 9108 | } |
| 9109 | |
| 9110 | return 1; |
| 9111 | } |
| 9112 | |
| 9113 | |
| 9114 | static int ath_ap_send_frame_vht(struct sigma_dut *dut, struct sigma_conn *conn, |
| 9115 | struct sigma_cmd *cmd) |
| 9116 | { |
| 9117 | const char *val; |
Jouni Malinen | 016ae6c | 2019-11-04 17:00:01 +0200 | [diff] [blame] | 9118 | const char *ifname; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9119 | int chwidth, nss; |
| 9120 | |
| 9121 | val = get_param(cmd, "FrameName"); |
| 9122 | if (!val || strcasecmp(val, "op_md_notif_frm") != 0) { |
| 9123 | send_resp(dut, conn, SIGMA_ERROR, |
| 9124 | "errorCode,Unsupported FrameName"); |
| 9125 | return 0; |
| 9126 | } |
| 9127 | |
| 9128 | /* |
| 9129 | * Sequence of commands for Opmode notification on |
| 9130 | * Peregrine based products |
| 9131 | */ |
Jouni Malinen | 016ae6c | 2019-11-04 17:00:01 +0200 | [diff] [blame] | 9132 | ifname = get_main_ifname(dut); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9133 | |
| 9134 | /* Disable STBC */ |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 9135 | run_iwpriv(dut, ifname, "tx_stbc 0"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9136 | |
| 9137 | /* Check whether optional arg channel width was passed */ |
| 9138 | val = get_param(cmd, "Channel_width"); |
| 9139 | if (val) { |
| 9140 | switch (atoi(val)) { |
| 9141 | case 20: |
| 9142 | chwidth = 0; |
| 9143 | break; |
| 9144 | case 40: |
| 9145 | chwidth = 1; |
| 9146 | break; |
| 9147 | case 80: |
| 9148 | chwidth = 2; |
| 9149 | break; |
| 9150 | case 160: |
| 9151 | chwidth = 3; |
| 9152 | break; |
| 9153 | default: |
| 9154 | chwidth = 2; |
| 9155 | break; |
| 9156 | } |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 9157 | run_iwpriv(dut, ifname, "chwidth %d", chwidth); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9158 | } |
| 9159 | |
| 9160 | /* Check whether optional arg NSS was passed */ |
| 9161 | val = get_param(cmd, "NSS"); |
| 9162 | if (val) { |
| 9163 | /* Convert nss to chainmask */ |
| 9164 | switch (atoi(val)) { |
| 9165 | case 1: |
| 9166 | nss = 1; |
| 9167 | break; |
| 9168 | case 2: |
| 9169 | nss = 3; |
| 9170 | break; |
| 9171 | case 3: |
| 9172 | nss = 7; |
| 9173 | break; |
| 9174 | default: |
| 9175 | /* We do not support NSS > 3 */ |
| 9176 | nss = 3; |
| 9177 | break; |
| 9178 | } |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 9179 | run_iwpriv(dut, ifname, "rxchainmask %d", nss); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9180 | } |
| 9181 | |
| 9182 | /* Send the opmode notification */ |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 9183 | run_iwpriv(dut, ifname, "opmode_notify 1"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9184 | |
| 9185 | return 1; |
| 9186 | } |
| 9187 | |
| 9188 | |
priyadharshini gowthaman | a27b5b6 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 9189 | static int ath_ap_send_frame_loc(struct sigma_dut *dut, struct sigma_conn *conn, |
| 9190 | struct sigma_cmd *cmd) |
| 9191 | { |
| 9192 | const char *val; |
| 9193 | FILE *f; |
priyadharshini gowthaman | a61badd | 2016-08-16 13:37:27 -0700 | [diff] [blame] | 9194 | int rand_int = 0; |
priyadharshini gowthaman | a27b5b6 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 9195 | |
| 9196 | val = get_param(cmd, "MsntType"); |
| 9197 | if (val) { |
| 9198 | if (dut->ap_msnt_type == 0) |
| 9199 | dut->ap_msnt_type = atoi(val); |
| 9200 | |
| 9201 | if (dut->ap_msnt_type != 5 && dut->ap_msnt_type != 2) { |
| 9202 | dut->ap_msnt_type = atoi(val); |
| 9203 | if (dut->ap_msnt_type == 1) { |
priyadharshini gowthaman | a61badd | 2016-08-16 13:37:27 -0700 | [diff] [blame] | 9204 | val = get_param(cmd, "RandInterval"); |
| 9205 | if (val) |
| 9206 | rand_int = atoi(val); |
priyadharshini gowthaman | a27b5b6 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 9207 | f = fopen("/tmp/ftmrr.txt", "a"); |
| 9208 | if (!f) { |
| 9209 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 9210 | "Failed to open /tmp/ftmrr.txt"); |
| 9211 | return -1; |
| 9212 | } |
| 9213 | |
| 9214 | fprintf(f, "sta_mac = %s\n", cmd->values[3]); |
priyadharshini gowthaman | a61badd | 2016-08-16 13:37:27 -0700 | [diff] [blame] | 9215 | 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", |
| 9216 | rand_int, cmd->values[7]); |
priyadharshini gowthaman | a27b5b6 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 9217 | fclose(f); |
| 9218 | dut->ap_msnt_type = 5; |
| 9219 | run_system(dut, "wpc -f /tmp/ftmrr.txt"); |
| 9220 | } |
| 9221 | } else if (dut->ap_msnt_type == 5) { |
| 9222 | run_system(dut, "wpc -f /tmp/ftmrr.txt"); |
| 9223 | } else if (dut->ap_msnt_type == 2) { |
| 9224 | f = fopen("/tmp/wru.txt", "w"); |
| 9225 | if (!f) { |
| 9226 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 9227 | "Failed to open /tmp/wru.txt"); |
| 9228 | return -1; |
| 9229 | } |
| 9230 | |
| 9231 | fprintf(f, "sta_mac = %s\n", cmd->values[3]); |
| 9232 | fprintf(f, "meas_type = 0x08\ndialogtoken = 0x1\nnum_repetitions = 0x0\nmeas_token = 0x1\nmeas_req_mode = 0x00\nloc_subject = 0x01\n"); |
| 9233 | fclose(f); |
| 9234 | run_system(dut, "wpc -w /tmp/wru.txt"); |
| 9235 | } |
| 9236 | } |
| 9237 | return 1; |
| 9238 | } |
| 9239 | |
| 9240 | |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 9241 | /* |
| 9242 | * The following functions parse_send_frame_params_int(), |
| 9243 | * parse_send_frame_params_str(), and parse_send_frame_params_mac() |
| 9244 | * are used by ath_ap_send_frame_bcn_rpt_req(). |
| 9245 | * Beacon Report Request is a frame used as part of the MBO program. |
| 9246 | * The command for sending beacon report has a lot of |
| 9247 | * arguments and having these functions reduces code size. |
| 9248 | * |
| 9249 | */ |
| 9250 | static int parse_send_frame_params_int(char *param, struct sigma_cmd *cmd, |
| 9251 | struct sigma_dut *dut, |
| 9252 | char *buf, size_t buf_size) |
| 9253 | { |
| 9254 | const char *str_val; |
| 9255 | int int_val; |
| 9256 | char temp[100]; |
| 9257 | |
| 9258 | str_val = get_param(cmd, param); |
| 9259 | if (!str_val) { |
| 9260 | sigma_dut_print(dut, DUT_MSG_ERROR, "%s not given", param); |
| 9261 | return -1; |
| 9262 | } |
| 9263 | int_val = atoi(str_val); |
| 9264 | snprintf(temp, sizeof(temp), " %d", int_val); |
Peng Xu | 591be45 | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 9265 | strlcat(buf, temp, buf_size); |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 9266 | return 0; |
| 9267 | } |
| 9268 | |
| 9269 | |
| 9270 | static int parse_send_frame_params_str(char *param, struct sigma_cmd *cmd, |
| 9271 | struct sigma_dut *dut, |
| 9272 | char *buf, size_t buf_size) |
| 9273 | { |
| 9274 | const char *str_val; |
| 9275 | char temp[100]; |
| 9276 | |
| 9277 | str_val = get_param(cmd, param); |
| 9278 | if (!str_val) { |
| 9279 | sigma_dut_print(dut, DUT_MSG_ERROR, "%s not given", param); |
| 9280 | return -1; |
| 9281 | } |
| 9282 | snprintf(temp, sizeof(temp), " %s", str_val); |
| 9283 | temp[sizeof(temp) - 1] = '\0'; |
Peng Xu | 591be45 | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 9284 | strlcat(buf, temp, buf_size); |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 9285 | return 0; |
| 9286 | } |
| 9287 | |
| 9288 | |
| 9289 | static int parse_send_frame_params_mac(char *param, struct sigma_cmd *cmd, |
| 9290 | struct sigma_dut *dut, |
| 9291 | char *buf, size_t buf_size) |
| 9292 | { |
| 9293 | const char *str_val; |
| 9294 | unsigned char mac[6]; |
| 9295 | char temp[100]; |
| 9296 | |
| 9297 | str_val = get_param(cmd, param); |
| 9298 | if (!str_val) { |
| 9299 | sigma_dut_print(dut, DUT_MSG_ERROR, "%s not given", param); |
| 9300 | return -1; |
| 9301 | } |
| 9302 | |
| 9303 | if (parse_mac_address(dut, str_val, mac) < 0) { |
| 9304 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 9305 | "MAC Address not in proper format"); |
| 9306 | return -1; |
| 9307 | } |
| 9308 | snprintf(temp, sizeof(temp), " %02x:%02x:%02x:%02x:%02x:%02x", |
| 9309 | mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]); |
Peng Xu | 591be45 | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 9310 | strlcat(buf, temp, buf_size); |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 9311 | return 0; |
| 9312 | } |
| 9313 | |
| 9314 | |
| 9315 | static void fill_1_or_0_based_on_presence(struct sigma_cmd *cmd, char *param, |
| 9316 | char *buf, size_t buf_size) |
| 9317 | { |
| 9318 | const char *str_val; |
| 9319 | char *value = " 1"; |
| 9320 | |
| 9321 | str_val = get_param(cmd, param); |
| 9322 | if (!str_val || str_val[0] == '\0') |
| 9323 | value = " 0"; |
Peng Xu | 591be45 | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 9324 | strlcat(buf, value, buf_size); |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 9325 | |
| 9326 | } |
| 9327 | |
| 9328 | |
| 9329 | /* |
| 9330 | * wifitool athN sendbcnrpt |
| 9331 | * <STA MAC - Plugs in from Dest_MAC> |
| 9332 | * <regclass - Plugs in from RegClass - int> |
| 9333 | * <channum - Plugs in from Channel PARAM of dev_send_frame - int> |
| 9334 | * <rand_ivl - Plugs in from RandInt - string> |
| 9335 | * <duration - Plugs in from MeaDur - integer> |
| 9336 | * <mode - Plugs in from MeaMode - string> |
| 9337 | * <req_ssid - Plugs in from SSID PARAM of dev_send_frame - string> |
| 9338 | * <rep_cond - Plugs in from RptCond - integer> |
| 9339 | * <rpt_detail - Plugs in from RptDet - integer> |
| 9340 | * <req_ie - Plugs in from ReqInfo PARAM of dev_send_frame - string> |
| 9341 | * <chanrpt_mode - Plugs in from APChanRpt - integer> |
| 9342 | * <specific_bssid - Plugs in from BSSID PARAM of dev_send_frame> |
| 9343 | * [AP channel numbers] |
| 9344 | */ |
| 9345 | static int ath_ap_send_frame_bcn_rpt_req(struct sigma_dut *dut, |
| 9346 | struct sigma_cmd *cmd, |
| 9347 | const char *ifname) |
| 9348 | { |
| 9349 | char buf[100]; |
| 9350 | int rpt_det; |
| 9351 | const char *str_val; |
| 9352 | const char *mea_mode; |
| 9353 | |
| 9354 | snprintf(buf, sizeof(buf), "wifitool %s sendbcnrpt", ifname); |
| 9355 | |
| 9356 | if (parse_send_frame_params_mac("Dest_MAC", cmd, dut, buf, sizeof(buf))) |
| 9357 | return -1; |
| 9358 | if (parse_send_frame_params_int("RegClass", cmd, dut, buf, sizeof(buf))) |
| 9359 | return -1; |
| 9360 | if (parse_send_frame_params_int("Channel", cmd, dut, buf, sizeof(buf))) |
| 9361 | return -1; |
| 9362 | if (parse_send_frame_params_str("RandInt", cmd, dut, buf, sizeof(buf))) |
| 9363 | return -1; |
| 9364 | if (parse_send_frame_params_int("MeaDur", cmd, dut, buf, sizeof(buf))) |
| 9365 | return -1; |
| 9366 | |
| 9367 | str_val = get_param(cmd, "MeaMode"); |
| 9368 | if (!str_val) { |
| 9369 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 9370 | "MeaMode parameter not present in send bcn-rpt-req"); |
| 9371 | return -1; |
| 9372 | } |
| 9373 | if (strcasecmp(str_val, "passive") == 0) { |
| 9374 | mea_mode = " 0"; |
| 9375 | } else if (strcasecmp(str_val, "active") == 0) { |
| 9376 | mea_mode = " 1"; |
| 9377 | } else if (strcasecmp(str_val, "table") == 0) { |
| 9378 | mea_mode = " 2"; |
| 9379 | } else { |
| 9380 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 9381 | "MEA-MODE Value not correctly given"); |
| 9382 | return -1; |
| 9383 | } |
Peng Xu | 591be45 | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 9384 | strlcat(buf, mea_mode, sizeof(buf)); |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 9385 | |
| 9386 | fill_1_or_0_based_on_presence(cmd, "SSID", buf, sizeof(buf)); |
| 9387 | |
| 9388 | if (parse_send_frame_params_int("RptCond", cmd, dut, buf, sizeof(buf))) |
| 9389 | return -1; |
| 9390 | |
| 9391 | if (parse_send_frame_params_int("RptDet", cmd, dut, buf, sizeof(buf))) |
| 9392 | return -1; |
| 9393 | str_val = get_param(cmd, "RptDet"); |
| 9394 | rpt_det = str_val ? atoi(str_val) : 0; |
| 9395 | |
| 9396 | if (rpt_det) |
| 9397 | fill_1_or_0_based_on_presence(cmd, "ReqInfo", buf, sizeof(buf)); |
| 9398 | else |
Peng Xu | 591be45 | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 9399 | strlcat(buf, " 0", sizeof(buf)); |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 9400 | |
| 9401 | if (rpt_det) |
| 9402 | fill_1_or_0_based_on_presence(cmd, "APChanRpt", buf, |
| 9403 | sizeof(buf)); |
| 9404 | else |
Peng Xu | 591be45 | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 9405 | strlcat(buf, " 0", sizeof(buf)); |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 9406 | |
| 9407 | if (parse_send_frame_params_mac("BSSID", cmd, dut, buf, sizeof(buf))) |
| 9408 | return -1; |
| 9409 | |
priyadharshini gowthaman | 2a4d20e | 2017-12-28 13:01:34 -0800 | [diff] [blame] | 9410 | str_val = get_param(cmd, "APChanRpt"); |
| 9411 | if (str_val) { |
| 9412 | const char *pos; |
| 9413 | int ap_chanrpt; |
| 9414 | int ap_chanrpt_2 = 0; |
| 9415 | char chanrpt[100]; |
| 9416 | |
| 9417 | ap_chanrpt = atoi(str_val); |
| 9418 | pos = strchr(str_val, '_'); |
| 9419 | if (pos) { |
| 9420 | pos++; |
| 9421 | ap_chanrpt_2 = atoi(pos); |
| 9422 | } |
| 9423 | if (ap_chanrpt) { |
| 9424 | snprintf(chanrpt, sizeof(chanrpt), " %d", ap_chanrpt); |
| 9425 | strlcat(buf, chanrpt, sizeof(buf)); |
| 9426 | } |
| 9427 | if (ap_chanrpt_2) { |
| 9428 | snprintf(chanrpt, sizeof(chanrpt), " %d", ap_chanrpt_2); |
| 9429 | strlcat(buf, chanrpt, sizeof(buf)); |
| 9430 | } |
| 9431 | } |
| 9432 | |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 9433 | run_system(dut, buf); |
| 9434 | return 0; |
| 9435 | } |
| 9436 | |
| 9437 | |
| 9438 | static void inform_and_sleep(struct sigma_dut *dut, int seconds) |
| 9439 | { |
| 9440 | sigma_dut_print(dut, DUT_MSG_DEBUG, "sleeping for %d seconds", seconds); |
| 9441 | sleep(seconds); |
| 9442 | sigma_dut_print(dut, DUT_MSG_DEBUG, "woke up after %d seconds", |
| 9443 | seconds); |
| 9444 | } |
| 9445 | |
| 9446 | |
| 9447 | static int ath_ap_send_frame_btm_req(struct sigma_dut *dut, |
| 9448 | struct sigma_cmd *cmd, const char *ifname) |
| 9449 | { |
| 9450 | unsigned char mac_addr[ETH_ALEN]; |
| 9451 | int disassoc_timer; |
| 9452 | char buf[100]; |
| 9453 | const char *val; |
| 9454 | int cand_list = 1; |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 9455 | |
| 9456 | val = get_param(cmd, "Dest_MAC"); |
| 9457 | if (!val || parse_mac_address(dut, val, mac_addr) < 0) { |
| 9458 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 9459 | "MAC Address not in proper format"); |
| 9460 | return -1; |
| 9461 | } |
| 9462 | |
| 9463 | val = get_param(cmd, "Disassoc_Timer"); |
| 9464 | if (val) |
| 9465 | disassoc_timer = atoi(val); |
| 9466 | else |
| 9467 | disassoc_timer = dut->ap_disassoc_timer; |
Jouni Malinen | 032aeab | 2018-01-04 12:30:46 +0200 | [diff] [blame] | 9468 | if (disassoc_timer < 0) { |
| 9469 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 9470 | "Invalid Disassoc_Timer value %d", |
| 9471 | disassoc_timer); |
| 9472 | return -1; |
| 9473 | } |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 9474 | |
| 9475 | val = get_param(cmd, "Cand_List"); |
| 9476 | if (val && val[0]) |
| 9477 | cand_list = atoi(val); |
| 9478 | |
| 9479 | val = get_param(cmd, "BTMQuery_Reason_Code"); |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 9480 | if (val) |
| 9481 | run_iwpriv(dut, ifname, "mbo_trans_rs %s", val); |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 9482 | |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 9483 | if (dut->ap_btmreq_disassoc_imnt && !dut->ap_assoc_delay) |
| 9484 | run_iwpriv(dut, ifname, "mbo_asoc_ret 1"); |
priyadharshini gowthaman | 776562e | 2017-12-20 12:33:34 -0800 | [diff] [blame] | 9485 | |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 9486 | snprintf(buf, sizeof(buf), |
priyadharshini gowthaman | 776562e | 2017-12-20 12:33:34 -0800 | [diff] [blame] | 9487 | "wifitool %s sendbstmreq %02x:%02x:%02x:%02x:%02x:%02x %d %d 15 %d %d %d %d", |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 9488 | ifname, mac_addr[0], mac_addr[1], mac_addr[2], mac_addr[3], |
| 9489 | mac_addr[4], mac_addr[5], cand_list, disassoc_timer, |
| 9490 | dut->ap_btmreq_disassoc_imnt, |
| 9491 | dut->ap_btmreq_term_bit, |
priyadharshini gowthaman | 94062b5 | 2017-12-20 12:33:34 -0800 | [diff] [blame] | 9492 | dut->ap_btmreq_bss_term_tsf, |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 9493 | dut->ap_btmreq_bss_term_dur); |
| 9494 | run_system(dut, buf); |
| 9495 | |
| 9496 | if (dut->ap_btmreq_term_bit) { |
priyadharshini gowthaman | 94062b5 | 2017-12-20 12:33:34 -0800 | [diff] [blame] | 9497 | if (dut->ap_btmreq_bss_term_tsf >= 2) |
| 9498 | inform_and_sleep(dut, dut->ap_btmreq_bss_term_tsf - 2); |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 9499 | run_iwpriv(dut, ifname, "kickmac %02x:%02x:%02x:%02x:%02x:%02x", |
| 9500 | mac_addr[0], mac_addr[1], mac_addr[2], |
| 9501 | mac_addr[3], mac_addr[4], mac_addr[5]); |
priyadharshini gowthaman | 776562e | 2017-12-20 12:33:34 -0800 | [diff] [blame] | 9502 | inform_and_sleep(dut, 2); |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 9503 | run_system_wrapper(dut, "ifconfig %s down", ifname); |
priyadharshini gowthaman | 776562e | 2017-12-20 12:33:34 -0800 | [diff] [blame] | 9504 | inform_and_sleep(dut, 5); |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 9505 | run_system_wrapper(dut, "ifconfig %s up", ifname); |
| 9506 | } else if (dut->ap_btmreq_disassoc_imnt) { |
| 9507 | inform_and_sleep(dut, (disassoc_timer / 1000) + 1); |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 9508 | run_iwpriv(dut, ifname, "kickmac %02x:%02x:%02x:%02x:%02x:%02x", |
| 9509 | mac_addr[0], mac_addr[1], mac_addr[2], |
| 9510 | mac_addr[3], mac_addr[4], mac_addr[5]); |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 9511 | } |
| 9512 | return 0; |
| 9513 | } |
| 9514 | |
| 9515 | |
priyadharshini gowthaman | 2a4d20e | 2017-12-28 13:01:34 -0800 | [diff] [blame] | 9516 | static int ath_ap_send_frame_disassoc(struct sigma_dut *dut, |
| 9517 | struct sigma_cmd *cmd, const char *ifname) |
| 9518 | { |
| 9519 | unsigned char mac_addr[ETH_ALEN]; |
| 9520 | const char *val; |
| 9521 | |
| 9522 | val = get_param(cmd, "Dest_MAC"); |
| 9523 | if (!val || parse_mac_address(dut, val, mac_addr) < 0) { |
| 9524 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 9525 | "MAC Address not in proper format"); |
| 9526 | return -1; |
| 9527 | } |
| 9528 | |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 9529 | run_iwpriv(dut, ifname, "kickmac %02x:%02x:%02x:%02x:%02x:%02x", |
| 9530 | mac_addr[0], mac_addr[1], mac_addr[2], |
| 9531 | mac_addr[3], mac_addr[4], mac_addr[5]); |
priyadharshini gowthaman | 2a4d20e | 2017-12-28 13:01:34 -0800 | [diff] [blame] | 9532 | return 0; |
| 9533 | } |
| 9534 | |
| 9535 | |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 9536 | static int ath_ap_send_frame_mbo(struct sigma_dut *dut, struct sigma_conn *conn, |
| 9537 | struct sigma_cmd *cmd) |
| 9538 | { |
| 9539 | const char *val; |
Jouni Malinen | 016ae6c | 2019-11-04 17:00:01 +0200 | [diff] [blame] | 9540 | const char *ifname; |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 9541 | |
Jouni Malinen | 016ae6c | 2019-11-04 17:00:01 +0200 | [diff] [blame] | 9542 | ifname = get_main_ifname(dut); |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 9543 | |
| 9544 | val = get_param(cmd, "FrameName"); |
| 9545 | if (!val) |
| 9546 | return -1; |
| 9547 | |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 9548 | if (strcasecmp(val, "BTMReq") == 0) |
| 9549 | ath_ap_send_frame_btm_req(dut, cmd, ifname); |
| 9550 | else if (strcasecmp(val, "BcnRptReq") == 0) |
| 9551 | ath_ap_send_frame_bcn_rpt_req(dut, cmd, ifname); |
priyadharshini gowthaman | 2a4d20e | 2017-12-28 13:01:34 -0800 | [diff] [blame] | 9552 | else if (strcasecmp(val, "disassoc") == 0) |
| 9553 | ath_ap_send_frame_disassoc(dut, cmd, ifname); |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 9554 | else |
| 9555 | return -1; |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 9556 | |
| 9557 | return 1; |
| 9558 | } |
| 9559 | |
| 9560 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9561 | static int ap_send_frame_vht(struct sigma_dut *dut, struct sigma_conn *conn, |
| 9562 | struct sigma_cmd *cmd) |
| 9563 | { |
Jouni Malinen | 016ae6c | 2019-11-04 17:00:01 +0200 | [diff] [blame] | 9564 | switch (get_driver_type(dut)) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9565 | case DRIVER_ATHEROS: |
| 9566 | return ath_ap_send_frame_vht(dut, conn, cmd); |
| 9567 | break; |
| 9568 | case DRIVER_OPENWRT: |
| 9569 | switch (get_openwrt_driver_type()) { |
| 9570 | case OPENWRT_DRIVER_ATHEROS: |
| 9571 | return ath_ap_send_frame_vht(dut, conn, cmd); |
| 9572 | default: |
| 9573 | send_resp(dut, conn, SIGMA_ERROR, |
| 9574 | "errorCode,Unsupported ap_send_frame with the current openwrt driver"); |
| 9575 | return 0; |
| 9576 | } |
| 9577 | default: |
| 9578 | send_resp(dut, conn, SIGMA_ERROR, |
| 9579 | "errorCode,Unsupported ap_send_frame with the current driver"); |
| 9580 | return 0; |
| 9581 | } |
| 9582 | } |
| 9583 | |
| 9584 | |
priyadharshini gowthaman | a27b5b6 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 9585 | static int ap_send_frame_loc(struct sigma_dut *dut, struct sigma_conn *conn, |
| 9586 | struct sigma_cmd *cmd) |
| 9587 | { |
Jouni Malinen | 016ae6c | 2019-11-04 17:00:01 +0200 | [diff] [blame] | 9588 | switch (get_driver_type(dut)) { |
priyadharshini gowthaman | a27b5b6 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 9589 | case DRIVER_ATHEROS: |
| 9590 | return ath_ap_send_frame_loc(dut, conn, cmd); |
| 9591 | case DRIVER_OPENWRT: |
| 9592 | switch (get_openwrt_driver_type()) { |
| 9593 | case OPENWRT_DRIVER_ATHEROS: |
| 9594 | return ath_ap_send_frame_loc(dut, conn, cmd); |
| 9595 | default: |
| 9596 | send_resp(dut, conn, SIGMA_ERROR, |
| 9597 | "errorCode,Unsupported ap_send_frame_loc with the current openwrt driver"); |
| 9598 | return 0; |
| 9599 | } |
| 9600 | default: |
| 9601 | send_resp(dut, conn, SIGMA_ERROR, |
| 9602 | "errorCode,Unsupported ap_send_frame_loc with the current driver"); |
| 9603 | return 0; |
| 9604 | } |
| 9605 | } |
| 9606 | |
| 9607 | |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 9608 | static int ap_send_frame_mbo(struct sigma_dut *dut, struct sigma_conn *conn, |
| 9609 | struct sigma_cmd *cmd) |
| 9610 | { |
Jouni Malinen | 016ae6c | 2019-11-04 17:00:01 +0200 | [diff] [blame] | 9611 | switch (get_driver_type(dut)) { |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 9612 | case DRIVER_ATHEROS: |
| 9613 | return ath_ap_send_frame_mbo(dut, conn, cmd); |
| 9614 | case DRIVER_OPENWRT: |
| 9615 | switch (get_openwrt_driver_type()) { |
| 9616 | case OPENWRT_DRIVER_ATHEROS: |
| 9617 | return ath_ap_send_frame_mbo(dut, conn, cmd); |
| 9618 | default: |
| 9619 | send_resp(dut, conn, SIGMA_ERROR, |
| 9620 | "errorCode,Unsupported ap_send_frame with the current openwrt driver"); |
| 9621 | return 0; |
| 9622 | } |
| 9623 | default: |
| 9624 | send_resp(dut, conn, SIGMA_ERROR, |
| 9625 | "errorCode,Unsupported ap_send_frame with the current driver"); |
| 9626 | return 0; |
| 9627 | } |
| 9628 | } |
| 9629 | |
| 9630 | |
Lior David | 0fe101e | 2017-03-09 16:09:50 +0200 | [diff] [blame] | 9631 | static int ap_send_frame_60g(struct sigma_dut *dut, |
| 9632 | struct sigma_conn *conn, |
| 9633 | struct sigma_cmd *cmd) |
| 9634 | { |
Jouni Malinen | 016ae6c | 2019-11-04 17:00:01 +0200 | [diff] [blame] | 9635 | switch (get_driver_type(dut)) { |
Lior David | 0fe101e | 2017-03-09 16:09:50 +0200 | [diff] [blame] | 9636 | #ifdef __linux__ |
| 9637 | case DRIVER_WIL6210: |
| 9638 | return wil6210_send_frame_60g(dut, conn, cmd); |
| 9639 | #endif /* __linux__ */ |
| 9640 | default: |
| 9641 | send_resp(dut, conn, SIGMA_ERROR, |
| 9642 | "errorCode,Unsupported sta_set_frame(60G) with the current driver"); |
| 9643 | return 0; |
| 9644 | } |
| 9645 | } |
| 9646 | |
| 9647 | |
Jouni Malinen | f722271 | 2019-06-13 01:50:21 +0300 | [diff] [blame] | 9648 | enum sigma_cmd_result cmd_ap_send_frame(struct sigma_dut *dut, |
| 9649 | struct sigma_conn *conn, |
| 9650 | struct sigma_cmd *cmd) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9651 | { |
| 9652 | /* const char *name = get_param(cmd, "NAME"); */ |
| 9653 | /* const char *ifname = get_param(cmd, "INTERFACE"); */ |
| 9654 | const char *val; |
| 9655 | enum send_frame_type frame; |
| 9656 | enum send_frame_protection protected; |
| 9657 | char buf[100]; |
| 9658 | |
| 9659 | val = get_param(cmd, "Program"); |
| 9660 | if (val) { |
| 9661 | if (strcasecmp(val, "HS2") == 0 || |
Adil Saeed Musthafa | 33ea287 | 2017-04-10 23:13:24 -0700 | [diff] [blame] | 9662 | strcasecmp(val, "HS2-R2") == 0 || |
| 9663 | strcasecmp(val, "IOTLP") == 0) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9664 | return ap_send_frame_hs2(dut, conn, cmd); |
| 9665 | if (strcasecmp(val, "VHT") == 0) |
| 9666 | return ap_send_frame_vht(dut, conn, cmd); |
priyadharshini gowthaman | a27b5b6 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 9667 | if (strcasecmp(val, "LOC") == 0) |
| 9668 | return ap_send_frame_loc(dut, conn, cmd); |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 9669 | if (strcasecmp(val, "MBO") == 0) |
| 9670 | return ap_send_frame_mbo(dut, conn, cmd); |
Lior David | 0fe101e | 2017-03-09 16:09:50 +0200 | [diff] [blame] | 9671 | if (strcasecmp(val, "60GHz") == 0) |
| 9672 | return ap_send_frame_60g(dut, conn, cmd); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9673 | } |
| 9674 | |
| 9675 | val = get_param(cmd, "PMFFrameType"); |
| 9676 | if (val == NULL) |
| 9677 | val = get_param(cmd, "FrameName"); |
| 9678 | if (val == NULL) |
| 9679 | val = get_param(cmd, "Type"); |
| 9680 | if (val == NULL) |
| 9681 | return -1; |
| 9682 | if (strcasecmp(val, "disassoc") == 0) |
| 9683 | frame = DISASSOC; |
| 9684 | else if (strcasecmp(val, "deauth") == 0) |
| 9685 | frame = DEAUTH; |
| 9686 | else if (strcasecmp(val, "saquery") == 0) |
| 9687 | frame = SAQUERY; |
| 9688 | else { |
| 9689 | send_resp(dut, conn, SIGMA_ERROR, "errorCode,Unsupported " |
| 9690 | "PMFFrameType"); |
| 9691 | return 0; |
| 9692 | } |
| 9693 | |
| 9694 | val = get_param(cmd, "PMFProtected"); |
| 9695 | if (val == NULL) |
| 9696 | val = get_param(cmd, "Protected"); |
| 9697 | if (val == NULL) |
| 9698 | return -1; |
| 9699 | if (strcasecmp(val, "Correct-key") == 0 || |
| 9700 | strcasecmp(val, "CorrectKey") == 0) |
| 9701 | protected = CORRECT_KEY; |
| 9702 | else if (strcasecmp(val, "IncorrectKey") == 0) |
| 9703 | protected = INCORRECT_KEY; |
| 9704 | else if (strcasecmp(val, "Unprotected") == 0) |
| 9705 | protected = UNPROTECTED; |
| 9706 | else { |
| 9707 | send_resp(dut, conn, SIGMA_ERROR, "errorCode,Unsupported " |
| 9708 | "PMFProtected"); |
| 9709 | return 0; |
| 9710 | } |
| 9711 | |
| 9712 | val = get_param(cmd, "stationID"); |
| 9713 | if (val == NULL) |
| 9714 | return -1; |
| 9715 | |
| 9716 | if (protected == INCORRECT_KEY || |
| 9717 | (protected == UNPROTECTED && frame == SAQUERY)) |
| 9718 | return ap_inject_frame(dut, conn, frame, protected, val); |
| 9719 | |
| 9720 | switch (frame) { |
| 9721 | case DISASSOC: |
| 9722 | snprintf(buf, sizeof(buf), "disassoc %s test=%d", |
| 9723 | val, protected == CORRECT_KEY); |
| 9724 | break; |
| 9725 | case DEAUTH: |
| 9726 | snprintf(buf, sizeof(buf), "deauth %s test=%d", |
| 9727 | val, protected == CORRECT_KEY); |
| 9728 | break; |
| 9729 | case SAQUERY: |
| 9730 | snprintf(buf, sizeof(buf), "sa_query %s", val); |
| 9731 | break; |
| 9732 | } |
| 9733 | |
| 9734 | if (run_hostapd_cli(dut, buf) != 0) |
| 9735 | return -2; |
| 9736 | |
| 9737 | return 1; |
| 9738 | } |
| 9739 | |
| 9740 | |
Jouni Malinen | f722271 | 2019-06-13 01:50:21 +0300 | [diff] [blame] | 9741 | static enum sigma_cmd_result cmd_ap_get_mac_address(struct sigma_dut *dut, |
| 9742 | struct sigma_conn *conn, |
| 9743 | struct sigma_cmd *cmd) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9744 | { |
| 9745 | #if defined( __linux__) |
| 9746 | /* const char *name = get_param(cmd, "NAME"); */ |
| 9747 | /* const char *ifname = get_param(cmd, "INTERFACE"); */ |
Jouni Malinen | f898464 | 2017-10-12 00:02:37 +0300 | [diff] [blame] | 9748 | char resp[100]; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9749 | unsigned char addr[6]; |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 9750 | char ifname[50]; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9751 | struct ifreq ifr; |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 9752 | int s, wlan_tag = 1; |
| 9753 | const char *val; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9754 | |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 9755 | val = get_param(cmd, "WLAN_TAG"); |
| 9756 | if (val) { |
| 9757 | wlan_tag = atoi(val); |
| 9758 | if (wlan_tag < 1 || wlan_tag > 3) { |
| 9759 | /* |
| 9760 | * The only valid WLAN Tags as of now as per the latest |
| 9761 | * WFA scripts are 1, 2, and 3. |
| 9762 | */ |
Jouni Malinen | f898464 | 2017-10-12 00:02:37 +0300 | [diff] [blame] | 9763 | send_resp(dut, conn, SIGMA_ERROR, |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 9764 | "errorCode,Unsupported WLAN_TAG"); |
| 9765 | return 0; |
| 9766 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9767 | } |
| 9768 | |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 9769 | get_if_name(dut, ifname, sizeof(ifname), wlan_tag); |
| 9770 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9771 | s = socket(AF_INET, SOCK_DGRAM, 0); |
| 9772 | if (s < 0) |
| 9773 | return -1; |
| 9774 | memset(&ifr, 0, sizeof(ifr)); |
Peng Xu | b8fc5cc | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 9775 | strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name)); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9776 | if (ioctl(s, SIOCGIFHWADDR, &ifr) < 0) { |
| 9777 | perror("ioctl"); |
| 9778 | close(s); |
Jouni Malinen | f898464 | 2017-10-12 00:02:37 +0300 | [diff] [blame] | 9779 | snprintf(resp, sizeof(resp), |
| 9780 | "errorCode,Could not find interface %s", ifname); |
| 9781 | send_resp(dut, conn, SIGMA_ERROR, resp); |
| 9782 | return 0; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9783 | } |
| 9784 | close(s); |
| 9785 | memcpy(addr, ifr.ifr_hwaddr.sa_data, 6); |
| 9786 | |
| 9787 | snprintf(resp, sizeof(resp), "mac,%02x:%02x:%02x:%02x:%02x:%02x", |
| 9788 | addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]); |
| 9789 | send_resp(dut, conn, SIGMA_COMPLETE, resp); |
| 9790 | return 0; |
| 9791 | #elif defined( __QNXNTO__) |
| 9792 | char resp[50]; |
| 9793 | unsigned char addr[6]; |
| 9794 | |
Jouni Malinen | d209548 | 2019-11-04 17:10:43 +0200 | [diff] [blame] | 9795 | if (!dut->main_ifname) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9796 | send_resp(dut, conn, SIGMA_ERROR, "ifname is null"); |
| 9797 | return 0; |
| 9798 | } |
| 9799 | |
Jouni Malinen | 5ea3092 | 2019-11-04 17:39:25 +0200 | [diff] [blame] | 9800 | if (get_hwaddr(get_main_ifname(dut), addr) != 0) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9801 | send_resp(dut, conn, SIGMA_ERROR, |
| 9802 | "errorCode,Failed to get address"); |
| 9803 | return 0; |
| 9804 | } |
| 9805 | snprintf(resp, sizeof(resp), "mac,%02x:%02x:%02x:%02x:%02x:%02x", |
| 9806 | addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]); |
| 9807 | send_resp(dut, conn, SIGMA_COMPLETE, resp); |
| 9808 | return 0; |
| 9809 | #else /* __linux__ */ |
| 9810 | send_resp(dut, conn, SIGMA_ERROR, "errorCode,ap_get_mac_address not " |
| 9811 | "yet supported"); |
| 9812 | return 0; |
| 9813 | #endif /* __linux__ */ |
| 9814 | } |
| 9815 | |
| 9816 | |
Ankita Bajaj | 0d5825b | 2017-10-25 16:20:17 +0530 | [diff] [blame] | 9817 | int sta_cfon_get_mac_address(struct sigma_dut *dut, struct sigma_conn *conn, |
| 9818 | struct sigma_cmd *cmd) |
| 9819 | { |
| 9820 | return cmd_ap_get_mac_address(dut, conn, cmd); |
| 9821 | } |
| 9822 | |
| 9823 | |
Jouni Malinen | f722271 | 2019-06-13 01:50:21 +0300 | [diff] [blame] | 9824 | static enum sigma_cmd_result cmd_ap_set_pmf(struct sigma_dut *dut, |
| 9825 | struct sigma_conn *conn, |
| 9826 | struct sigma_cmd *cmd) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9827 | { |
| 9828 | /* |
| 9829 | * Ignore the command since the parameters are already handled through |
| 9830 | * ap_set_security. |
| 9831 | */ |
| 9832 | |
| 9833 | return 1; |
| 9834 | } |
| 9835 | |
| 9836 | |
Jouni Malinen | f722271 | 2019-06-13 01:50:21 +0300 | [diff] [blame] | 9837 | static enum sigma_cmd_result cmd_ap_set_hs2(struct sigma_dut *dut, |
| 9838 | struct sigma_conn *conn, |
| 9839 | struct sigma_cmd *cmd) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9840 | { |
| 9841 | /* const char *name = get_param(cmd, "NAME"); */ |
| 9842 | /* const char *ifname = get_param(cmd, "INTERFACE"); */ |
| 9843 | const char *val, *dest; |
| 9844 | char *pos, buf[100]; |
| 9845 | int i, wlan_tag = 1; |
| 9846 | |
| 9847 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_set_hs2: Processing the " |
| 9848 | "following parameters"); |
| 9849 | for (i = 0; i < cmd->count; i++) { |
| 9850 | sigma_dut_print(dut, DUT_MSG_INFO, "%s %s", cmd->params[i], |
| 9851 | (cmd->values[i] ? cmd->values[i] : "NULL")); |
| 9852 | } |
| 9853 | |
| 9854 | val = get_param(cmd, "ICMPv4_ECHO"); |
| 9855 | if (val && atoi(val)) { |
| 9856 | snprintf(buf, sizeof(buf), "ebtables -F"); |
| 9857 | if (system(buf) != 0) { |
| 9858 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 9859 | "Failed to set ebtables rules, RULE-12"); |
| 9860 | } |
| 9861 | return 1; |
| 9862 | } |
| 9863 | |
| 9864 | val = get_param(cmd, "WLAN_TAG"); |
| 9865 | if (val) { |
| 9866 | wlan_tag = atoi(val); |
| 9867 | if (wlan_tag != 1 && wlan_tag != 2) { |
| 9868 | send_resp(dut, conn, SIGMA_INVALID, |
| 9869 | "errorCode,Invalid WLAN_TAG"); |
| 9870 | return 0; |
| 9871 | } |
| 9872 | } |
| 9873 | |
| 9874 | if (wlan_tag == 2) { |
| 9875 | val = get_param(cmd, "PROXY_ARP"); |
| 9876 | if (val) |
| 9877 | dut->ap2_proxy_arp = atoi(val); |
Jouni Malinen | dbbc2c4 | 2018-11-14 23:55:41 +0200 | [diff] [blame] | 9878 | |
| 9879 | val = get_param(cmd, "OSU"); |
| 9880 | if (val) |
| 9881 | dut->ap2_osu = atoi(val); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9882 | return 1; |
| 9883 | } |
| 9884 | |
| 9885 | dest = get_param(cmd, "STA_MAC"); |
| 9886 | if (dest) { |
| 9887 | /* This is a special/ugly way of using this command. |
| 9888 | * If "Dest" MAC is included, assume that this command |
| 9889 | * is being issued after ap_config_commit for dynamically |
| 9890 | * setting the QoS Map Set. |
| 9891 | */ |
| 9892 | val = get_param(cmd, "QoS_MAP_SET"); |
| 9893 | if (val) { |
| 9894 | dut->ap_qos_map_set = atoi(val); |
| 9895 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_qos_map_set %d", |
| 9896 | dut->ap_qos_map_set); |
| 9897 | } |
| 9898 | |
| 9899 | if (dut->ap_qos_map_set == 1) |
| 9900 | run_hostapd_cli(dut, "set_qos_map_set " QOS_MAP_SET_1); |
| 9901 | else if (dut->ap_qos_map_set == 2) |
| 9902 | run_hostapd_cli(dut, "set_qos_map_set " QOS_MAP_SET_2); |
| 9903 | |
| 9904 | snprintf(buf, sizeof(buf), "send_qos_map_conf %s", dest); |
| 9905 | if (run_hostapd_cli(dut, buf) != 0) |
| 9906 | return -1; |
| 9907 | } |
| 9908 | |
| 9909 | val = get_param(cmd, "DGAF_DISABLE"); |
| 9910 | if (val) |
| 9911 | dut->ap_dgaf_disable = atoi(val); |
| 9912 | |
| 9913 | dut->ap_interworking = 1; |
| 9914 | |
| 9915 | val = get_param(cmd, "INTERWORKING"); |
| 9916 | if (val == NULL) |
| 9917 | val = get_param(cmd, "INTERNETWORKING"); |
| 9918 | if (val != NULL && atoi(val) == 0) { |
| 9919 | dut->ap_interworking = 0; |
| 9920 | dut->ap_hs2 = 0; |
| 9921 | return 1; |
| 9922 | } |
| 9923 | |
| 9924 | val = get_param(cmd, "ACCS_NET_TYPE"); |
| 9925 | if (val) { |
| 9926 | if (strcasecmp(val, "Chargeable_Public_Network") == 0 || |
| 9927 | strcasecmp(val, "Chargable_Public_Network") == 0 || |
| 9928 | strcasecmp(val, "Chargable Public Network") == 0) |
| 9929 | dut->ap_access_net_type = 2; |
| 9930 | else |
| 9931 | dut->ap_access_net_type = atoi(val); |
| 9932 | } |
| 9933 | |
| 9934 | val = get_param(cmd, "INTERNET"); |
| 9935 | if (val) |
| 9936 | dut->ap_internet = atoi(val); |
| 9937 | |
| 9938 | val = get_param(cmd, "VENUE_GRP"); |
| 9939 | if (val) { |
| 9940 | if (strcasecmp(val, "Business") == 0) |
| 9941 | dut->ap_venue_group = 2; |
| 9942 | else |
| 9943 | dut->ap_venue_group = atoi(val); |
| 9944 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_venue_name %d", |
| 9945 | dut->ap_venue_name); |
| 9946 | } |
| 9947 | |
| 9948 | val = get_param(cmd, "VENUE_TYPE"); |
| 9949 | if (val) { |
| 9950 | if (strcasecmp(val, "R&D") == 0) |
| 9951 | dut->ap_venue_type = 8; |
| 9952 | else |
| 9953 | dut->ap_venue_type = atoi(val); |
| 9954 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_venue_type %d", |
| 9955 | dut->ap_venue_type); |
| 9956 | } |
| 9957 | |
| 9958 | val = get_param(cmd, "HESSID"); |
| 9959 | if (val) { |
| 9960 | if (strlen(val) >= sizeof(dut->ap_hessid)) { |
| 9961 | send_resp(dut, conn, SIGMA_ERROR, |
| 9962 | "errorCode,Invalid HESSID"); |
| 9963 | return 0; |
| 9964 | } |
| 9965 | snprintf(dut->ap_hessid, sizeof(dut->ap_hessid), "%s", val); |
| 9966 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_hessid %s", |
| 9967 | dut->ap_hessid); |
| 9968 | } |
| 9969 | |
| 9970 | val = get_param(cmd, "ROAMING_CONS"); |
| 9971 | if (val) { |
| 9972 | if (strlen(val) >= sizeof(dut->ap_roaming_cons)) { |
| 9973 | send_resp(dut, conn, SIGMA_ERROR, |
| 9974 | "errorCode,Invalid ROAMING_CONS"); |
| 9975 | return 0; |
| 9976 | } |
| 9977 | if (strcasecmp(val, "Disabled") == 0) { |
| 9978 | dut->ap_roaming_cons[0] = '\0'; |
| 9979 | } else { |
| 9980 | snprintf(dut->ap_roaming_cons, |
| 9981 | sizeof(dut->ap_roaming_cons), "%s", val); |
| 9982 | } |
| 9983 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_roaming_cons %s", |
| 9984 | dut->ap_roaming_cons); |
| 9985 | } |
| 9986 | |
| 9987 | val = get_param(cmd, "ANQP"); |
| 9988 | if (val) |
| 9989 | dut->ap_anqpserver_on = atoi(val); |
| 9990 | |
| 9991 | val = get_param(cmd, "NAI_REALM_LIST"); |
| 9992 | if (val) { |
| 9993 | dut->ap_nai_realm_list = atoi(val); |
| 9994 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_nai_realm_list %d", |
| 9995 | dut->ap_nai_realm_list); |
| 9996 | } |
| 9997 | |
| 9998 | val = get_param(cmd, "3GPP_INFO"); |
| 9999 | if (val) { |
| 10000 | /* What kind of encoding format is used?! */ |
| 10001 | send_resp(dut, conn, SIGMA_ERROR, "errorCode,3GPP_INFO " |
| 10002 | "not yet supported (contents not fully defined)"); |
| 10003 | return 0; |
| 10004 | } |
| 10005 | |
| 10006 | val = get_param(cmd, "DOMAIN_LIST"); |
| 10007 | if (val) { |
| 10008 | if (strlen(val) >= sizeof(dut->ap_domain_name_list)) { |
| 10009 | send_resp(dut, conn, SIGMA_ERROR, "errorCode,Too long " |
| 10010 | "DOMAIN_LIST"); |
| 10011 | return 0; |
| 10012 | } |
| 10013 | snprintf(dut->ap_domain_name_list, |
| 10014 | sizeof(dut->ap_domain_name_list), "%s", val); |
| 10015 | pos = dut->ap_domain_name_list; |
| 10016 | while (*pos) { |
| 10017 | if (*pos == ';') |
| 10018 | *pos = ','; |
| 10019 | pos++; |
| 10020 | } |
| 10021 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_domain_name_list %s", |
| 10022 | dut->ap_domain_name_list); |
| 10023 | } |
| 10024 | |
| 10025 | val = get_param(cmd, "OPER_NAME"); |
| 10026 | if (val) { |
| 10027 | dut->ap_oper_name = atoi(val); |
| 10028 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_oper_name %d", |
| 10029 | dut->ap_oper_name); |
| 10030 | } |
| 10031 | |
| 10032 | val = get_param(cmd, "VENUE_NAME"); |
| 10033 | if (val) { |
| 10034 | dut->ap_venue_name = atoi(val); |
| 10035 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_venue_name %d", |
| 10036 | dut->ap_venue_name); |
| 10037 | } |
| 10038 | |
| 10039 | val = get_param(cmd, "GAS_CB_DELAY"); |
| 10040 | if (val) { |
| 10041 | dut->ap_gas_cb_delay = atoi(val); |
| 10042 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_gas_cb_delay %d", |
| 10043 | dut->ap_gas_cb_delay); |
| 10044 | } |
| 10045 | |
| 10046 | val = get_param(cmd, "MIH"); |
| 10047 | if (val && atoi(val) > 0) { |
| 10048 | send_resp(dut, conn, SIGMA_ERROR, "errorCode,MIH not " |
| 10049 | "supported"); |
| 10050 | return 0; |
| 10051 | } |
| 10052 | |
| 10053 | val = get_param(cmd, "L2_TRAFFIC_INSPECT"); |
| 10054 | if (val) { |
| 10055 | dut->ap_l2tif = atoi(val); |
| 10056 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_l2tif %d", |
| 10057 | dut->ap_l2tif); |
| 10058 | } |
| 10059 | |
| 10060 | val = get_param(cmd, "BCST_UNCST"); |
| 10061 | if (val) { |
| 10062 | send_resp(dut, conn, SIGMA_ERROR, |
| 10063 | "errorCode,BCST_UNCST not yet supported"); |
| 10064 | return 0; |
| 10065 | } |
| 10066 | |
| 10067 | val = get_param(cmd, "PLMN_MCC"); |
| 10068 | if (val) { |
| 10069 | char mcc[100], *start, *end; |
| 10070 | int i = 0; |
| 10071 | if (strlen(val) >= sizeof(mcc)) { |
| 10072 | send_resp(dut, conn, SIGMA_ERROR, |
| 10073 | "errorCode,PLMN_MCC too long"); |
| 10074 | return 0; |
| 10075 | } |
Peng Xu | b8fc5cc | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 10076 | strlcpy(mcc, val, sizeof(mcc)); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 10077 | start = mcc; |
| 10078 | while ((end = strchr(start, ';'))) { |
| 10079 | /* process all except the last */ |
| 10080 | *end = '\0'; |
| 10081 | if (strlen(start) != 3) { |
| 10082 | send_resp(dut, conn, SIGMA_ERROR, |
| 10083 | "errorCode,Invalid PLMN_MCC"); |
| 10084 | return 0; |
| 10085 | } |
| 10086 | snprintf(dut->ap_plmn_mcc[i], |
| 10087 | sizeof(dut->ap_plmn_mcc[i]), "%s", start); |
| 10088 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_plmn_mcc %s", |
| 10089 | dut->ap_plmn_mcc[i]); |
| 10090 | i++; |
| 10091 | start = end + 1; |
| 10092 | *end = ';'; |
| 10093 | } |
| 10094 | if (strlen(start) != 3) { |
| 10095 | send_resp(dut, conn, SIGMA_ERROR, |
| 10096 | "errorCode,Invalid PLMN_MCC"); |
| 10097 | return 0; |
| 10098 | } |
| 10099 | /* process last or only one */ |
| 10100 | snprintf(dut->ap_plmn_mcc[i], |
| 10101 | sizeof(dut->ap_plmn_mcc[i]), "%s", start); |
| 10102 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_plmn_mcc %s", |
| 10103 | dut->ap_plmn_mcc[i]); |
| 10104 | } |
| 10105 | |
| 10106 | val = get_param(cmd, "PLMN_MNC"); |
| 10107 | if (val) { |
| 10108 | char mnc[100], *start, *end; |
| 10109 | int i = 0; |
| 10110 | if (strlen(val) >= sizeof(mnc)) { |
| 10111 | send_resp(dut, conn, SIGMA_ERROR, |
| 10112 | "errorCode,PLMN_MNC too long"); |
| 10113 | return 0; |
| 10114 | } |
Peng Xu | b8fc5cc | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 10115 | strlcpy(mnc, val, sizeof(mnc)); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 10116 | start = mnc; |
| 10117 | while ((end = strchr(start, ';'))) { |
| 10118 | *end = '\0'; |
| 10119 | if (strlen(start) != 2 && strlen(start) != 3) { |
| 10120 | send_resp(dut, conn, SIGMA_ERROR, |
| 10121 | "errorCode,Invalid PLMN_MNC"); |
| 10122 | return 0; |
| 10123 | } |
| 10124 | snprintf(dut->ap_plmn_mnc[i], |
| 10125 | sizeof(dut->ap_plmn_mnc[i]), "%s", start); |
| 10126 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_plmn_mnc %s", |
| 10127 | dut->ap_plmn_mnc[i]); |
| 10128 | i++; |
| 10129 | start = end + 1; |
| 10130 | *end = ';'; |
| 10131 | } |
| 10132 | if (strlen(start) != 2 && strlen(start) != 3) { |
| 10133 | send_resp(dut, conn, SIGMA_ERROR, |
| 10134 | "errorCode,Invalid PLMN_MNC"); |
| 10135 | return 0; |
| 10136 | } |
| 10137 | snprintf(dut->ap_plmn_mnc[i], |
| 10138 | sizeof(dut->ap_plmn_mnc[i]), "%s", start); |
| 10139 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_plmn_mnc %s", |
| 10140 | dut->ap_plmn_mnc[i]); |
| 10141 | } |
| 10142 | |
| 10143 | val = get_param(cmd, "PROXY_ARP"); |
| 10144 | if (val) { |
| 10145 | dut->ap_proxy_arp = atoi(val); |
| 10146 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_proxy_arp %d", |
| 10147 | dut->ap_proxy_arp); |
| 10148 | } |
| 10149 | |
| 10150 | val = get_param(cmd, "WAN_METRICS"); |
| 10151 | if (val) { |
| 10152 | dut->ap_wan_metrics = atoi(val); |
| 10153 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_wan_metrics %d", |
| 10154 | dut->ap_wan_metrics); |
| 10155 | } |
| 10156 | |
| 10157 | val = get_param(cmd, "CONN_CAP"); |
| 10158 | if (val) { |
| 10159 | dut->ap_conn_capab = atoi(val); |
| 10160 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_conn_capab %d", |
| 10161 | dut->ap_conn_capab); |
| 10162 | } |
| 10163 | |
| 10164 | val = get_param(cmd, "IP_ADD_TYPE_AVAIL"); |
| 10165 | if (val) { |
| 10166 | dut->ap_ip_addr_type_avail = atoi(val); |
| 10167 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_ip_addr_type_avail %d", |
| 10168 | dut->ap_ip_addr_type_avail); |
| 10169 | } |
| 10170 | |
| 10171 | val = get_param(cmd, "NET_AUTH_TYPE"); |
| 10172 | if (val) { |
| 10173 | dut->ap_net_auth_type = atoi(val); |
| 10174 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_net_auth_type %d", |
| 10175 | dut->ap_net_auth_type); |
| 10176 | } |
| 10177 | |
| 10178 | val = get_param(cmd, "OP_CLASS"); |
| 10179 | if (val == NULL) |
| 10180 | val = get_param(cmd, "OPER_CLASS"); |
| 10181 | if (val) { |
| 10182 | dut->ap_oper_class = atoi(val); |
| 10183 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_oper_class %d", |
| 10184 | dut->ap_oper_class); |
| 10185 | } |
| 10186 | |
| 10187 | val = get_param(cmd, "OSU_PROVIDER_LIST"); |
| 10188 | if (val) { |
| 10189 | dut->ap_osu_provider_list = atoi(val); |
| 10190 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_osu_provider_list %d", |
| 10191 | dut->ap_osu_provider_list); |
| 10192 | } |
| 10193 | |
Jouni Malinen | 93a837f | 2018-11-01 17:09:22 +0200 | [diff] [blame] | 10194 | val = get_param(cmd, "OSU_PROVIDER_NAI_LIST"); |
| 10195 | if (val) { |
| 10196 | dut->ap_osu_provider_nai_list = atoi(val); |
| 10197 | sigma_dut_print(dut, DUT_MSG_INFO, |
| 10198 | "ap_osu_provider_nai_list %d", |
| 10199 | dut->ap_osu_provider_nai_list); |
| 10200 | } |
| 10201 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 10202 | val = get_param(cmd, "OSU_SERVER_URI"); |
| 10203 | if (val) { |
| 10204 | i = 0; |
| 10205 | do { |
| 10206 | int len; |
| 10207 | const char *uri = val; |
| 10208 | val = strchr(val, ' '); |
| 10209 | len = val ? (val++ - uri) : (int) strlen(uri); |
| 10210 | if (len > 0 && len < 256) { |
| 10211 | memcpy(dut->ap_osu_server_uri[i], uri, len); |
| 10212 | dut->ap_osu_server_uri[i][len] = '\0'; |
| 10213 | sigma_dut_print(dut, DUT_MSG_INFO, |
| 10214 | "ap_osu_server_uri[%d] %s", i, |
| 10215 | dut->ap_osu_server_uri[i]); |
| 10216 | } |
| 10217 | } while (val && ++i < 10); |
| 10218 | } |
| 10219 | |
| 10220 | val = get_param(cmd, "OSU_METHOD"); |
| 10221 | if (val) { |
| 10222 | i = 0; |
| 10223 | do { |
| 10224 | int len; |
| 10225 | const char *method = val; |
| 10226 | val = strchr(val, ' '); |
| 10227 | len = val ? (val++ - method) : (int) strlen(method); |
| 10228 | if (len > 0) { |
| 10229 | if (strncasecmp(method, "SOAP", len) == 0) |
| 10230 | dut->ap_osu_method[i] = 1; |
| 10231 | else if (strncasecmp(method, "OMADM", len) == 0) |
| 10232 | dut->ap_osu_method[i] = 0; |
| 10233 | else |
| 10234 | return -2; |
| 10235 | } |
| 10236 | } while (val && ++i < 10); |
| 10237 | } |
| 10238 | |
| 10239 | val = get_param(cmd, "OSU_SSID"); |
| 10240 | if (val) { |
| 10241 | if (strlen(val) > 0 && strlen(val) <= 32) { |
Peng Xu | b8fc5cc | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 10242 | strlcpy(dut->ap_osu_ssid, val, |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 10243 | sizeof(dut->ap_osu_ssid)); |
| 10244 | sigma_dut_print(dut, DUT_MSG_INFO, |
| 10245 | "ap_osu_ssid %s", |
| 10246 | dut->ap_osu_ssid); |
| 10247 | } |
| 10248 | } |
| 10249 | |
| 10250 | val = get_param(cmd, "OSU_ICON_TAG"); |
| 10251 | if (val) |
| 10252 | dut->ap_osu_icon_tag = atoi(val); |
| 10253 | |
| 10254 | val = get_param(cmd, "QoS_MAP_SET"); |
| 10255 | if (val) { |
| 10256 | dut->ap_qos_map_set = atoi(val); |
| 10257 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_qos_map_set %d", |
| 10258 | dut->ap_qos_map_set); |
| 10259 | } |
| 10260 | |
| 10261 | val = get_param(cmd, "BSS_LOAD"); |
| 10262 | if (val) { |
| 10263 | dut->ap_bss_load = atoi(val); |
| 10264 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_bss_load %d", |
| 10265 | dut->ap_bss_load); |
| 10266 | } |
| 10267 | |
Jouni Malinen | 54a89b0 | 2018-05-01 00:16:26 +0300 | [diff] [blame] | 10268 | val = get_param(cmd, "Venue_URL"); |
| 10269 | if (val) |
| 10270 | dut->ap_venue_url = atoi(val); |
| 10271 | |
Jouni Malinen | f7ff42b | 2018-05-01 00:21:56 +0300 | [diff] [blame] | 10272 | val = get_param(cmd, "Advice_of_Charge"); |
| 10273 | if (val) |
| 10274 | dut->ap_advice_of_charge = atoi(val); |
| 10275 | |
Jouni Malinen | ac10453 | 2018-05-01 00:27:37 +0300 | [diff] [blame] | 10276 | val = get_param(cmd, "Operator_Icon_Metadata"); |
| 10277 | if (val) |
| 10278 | dut->ap_oper_icon_metadata = atoi(val); |
| 10279 | |
Jouni Malinen | ac36714 | 2018-05-01 00:32:24 +0300 | [diff] [blame] | 10280 | val = get_param(cmd, "TnC_File_Name"); |
| 10281 | if (val) |
| 10282 | dut->ap_tnc_file_name = atoi(val); |
| 10283 | |
| 10284 | val = get_param(cmd, "TnC_File_Time_Stamp"); |
| 10285 | if (val) |
| 10286 | dut->ap_tnc_time_stamp = strtol(val, NULL, 10); |
| 10287 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 10288 | return 1; |
| 10289 | } |
| 10290 | |
| 10291 | |
| 10292 | void nfc_status(struct sigma_dut *dut, const char *state, const char *oper) |
| 10293 | { |
| 10294 | char buf[100]; |
| 10295 | |
| 10296 | if (!file_exists("nfc-status")) |
| 10297 | return; |
| 10298 | |
| 10299 | snprintf(buf, sizeof(buf), "./nfc-status %s %s", state, oper); |
| 10300 | run_system(dut, buf); |
| 10301 | } |
| 10302 | |
| 10303 | |
| 10304 | static int run_nfc_command(struct sigma_dut *dut, const char *cmd, |
| 10305 | const char *info) |
| 10306 | { |
| 10307 | int res; |
| 10308 | |
| 10309 | printf("\n\n\n=====[ NFC operation ]=========================\n\n"); |
| 10310 | printf("%s\n\n", info); |
| 10311 | |
| 10312 | nfc_status(dut, "START", info); |
| 10313 | res = run_system(dut, cmd); |
| 10314 | nfc_status(dut, res ? "FAIL" : "SUCCESS", info); |
| 10315 | if (res) { |
| 10316 | sigma_dut_print(dut, DUT_MSG_INFO, "Failed to run '%s': %d", |
| 10317 | cmd, res); |
| 10318 | return res; |
| 10319 | } |
| 10320 | |
| 10321 | return 0; |
| 10322 | } |
| 10323 | |
| 10324 | |
| 10325 | static int ap_nfc_write_config_token(struct sigma_dut *dut, |
| 10326 | struct sigma_conn *conn, |
| 10327 | struct sigma_cmd *cmd) |
| 10328 | { |
| 10329 | int res; |
| 10330 | char buf[300]; |
| 10331 | |
| 10332 | run_system(dut, "killall wps-ap-nfc.py"); |
| 10333 | unlink("nfc-success"); |
| 10334 | snprintf(buf, sizeof(buf), |
| 10335 | "./wps-ap-nfc.py --no-wait %s%s --success nfc-success write-config", |
| 10336 | dut->summary_log ? "--summary " : "", |
| 10337 | dut->summary_log ? dut->summary_log : ""); |
| 10338 | res = run_nfc_command(dut, buf, |
| 10339 | "Touch NFC Tag to write WPS configuration token"); |
| 10340 | if (res || !file_exists("nfc-success")) { |
| 10341 | send_resp(dut, conn, SIGMA_ERROR, |
| 10342 | "ErrorCode,Failed to write tag"); |
| 10343 | return 0; |
| 10344 | } |
| 10345 | |
| 10346 | return 1; |
| 10347 | } |
| 10348 | |
| 10349 | |
| 10350 | static int ap_nfc_wps_read_passwd(struct sigma_dut *dut, |
| 10351 | struct sigma_conn *conn, |
| 10352 | struct sigma_cmd *cmd) |
| 10353 | { |
| 10354 | int res; |
| 10355 | char buf[300]; |
| 10356 | |
| 10357 | run_system(dut, "killall wps-ap-nfc.py"); |
| 10358 | |
| 10359 | unlink("nfc-success"); |
| 10360 | snprintf(buf, sizeof(buf), |
| 10361 | "./wps-ap-nfc.py -1 --no-wait %s%s --success nfc-success", |
| 10362 | dut->summary_log ? "--summary " : "", |
| 10363 | dut->summary_log ? dut->summary_log : ""); |
| 10364 | res = run_nfc_command(dut, buf, "Touch NFC Tag to read it"); |
| 10365 | if (res || !file_exists("nfc-success")) { |
| 10366 | send_resp(dut, conn, SIGMA_ERROR, |
| 10367 | "ErrorCode,Failed to read tag"); |
| 10368 | return 0; |
| 10369 | } |
| 10370 | |
| 10371 | return 1; |
| 10372 | } |
| 10373 | |
| 10374 | |
| 10375 | static int ap_nfc_write_password_token(struct sigma_dut *dut, |
| 10376 | struct sigma_conn *conn, |
| 10377 | struct sigma_cmd *cmd) |
| 10378 | { |
| 10379 | int res; |
| 10380 | char buf[300]; |
| 10381 | |
| 10382 | run_system(dut, "killall wps-ap-nfc.py"); |
| 10383 | unlink("nfc-success"); |
| 10384 | snprintf(buf, sizeof(buf), |
| 10385 | "./wps-ap-nfc.py --no-wait %s%s --success nfc-success write-password", |
| 10386 | dut->summary_log ? "--summary " : "", |
| 10387 | dut->summary_log ? dut->summary_log : ""); |
| 10388 | res = run_nfc_command(dut, buf, |
| 10389 | "Touch NFC Tag to write WPS password token"); |
| 10390 | if (res || !file_exists("nfc-success")) { |
| 10391 | send_resp(dut, conn, SIGMA_ERROR, |
| 10392 | "ErrorCode,Failed to write tag"); |
| 10393 | return 0; |
| 10394 | } |
| 10395 | |
| 10396 | if (run_hostapd_cli(dut, "wps_nfc_token enable") != 0) { |
| 10397 | send_resp(dut, conn, SIGMA_ERROR, |
| 10398 | "ErrorCode,Failed to enable NFC password token"); |
| 10399 | return 0; |
| 10400 | } |
| 10401 | |
| 10402 | return 1; |
| 10403 | } |
| 10404 | |
| 10405 | |
| 10406 | static int ap_nfc_wps_connection_handover(struct sigma_dut *dut, |
| 10407 | struct sigma_conn *conn, |
| 10408 | struct sigma_cmd *cmd) |
| 10409 | { |
| 10410 | int res; |
| 10411 | char buf[300]; |
| 10412 | |
| 10413 | run_system(dut, "killall wps-ap-nfc.py"); |
| 10414 | unlink("nfc-success"); |
| 10415 | snprintf(buf, sizeof(buf), |
| 10416 | "./wps-ap-nfc.py -1 --no-wait %s%s --success nfc-success", |
| 10417 | dut->summary_log ? "--summary " : "", |
| 10418 | dut->summary_log ? dut->summary_log : ""); |
| 10419 | res = run_nfc_command(dut, buf, |
| 10420 | "Touch NFC Device to respond to WPS connection handover"); |
| 10421 | if (res) { |
| 10422 | send_resp(dut, conn, SIGMA_ERROR, |
| 10423 | "ErrorCode,Failed to enable NFC for connection " |
| 10424 | "handover"); |
| 10425 | return 0; |
| 10426 | } |
| 10427 | if (!file_exists("nfc-success")) { |
| 10428 | send_resp(dut, conn, SIGMA_ERROR, |
| 10429 | "ErrorCode,Failed to complete NFC connection handover"); |
| 10430 | return 0; |
| 10431 | } |
| 10432 | |
| 10433 | return 1; |
| 10434 | } |
| 10435 | |
| 10436 | |
Jouni Malinen | f722271 | 2019-06-13 01:50:21 +0300 | [diff] [blame] | 10437 | static enum sigma_cmd_result cmd_ap_nfc_action(struct sigma_dut *dut, |
| 10438 | struct sigma_conn *conn, |
| 10439 | struct sigma_cmd *cmd) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 10440 | { |
| 10441 | /* const char *name = get_param(cmd, "Name"); */ |
| 10442 | /* const char *intf = get_param(cmd, "Interface"); */ |
| 10443 | const char *oper = get_param(cmd, "Operation"); |
| 10444 | |
| 10445 | if (oper == NULL) |
| 10446 | return -1; |
| 10447 | |
| 10448 | if (strcasecmp(oper, "WRITE_CONFIG") == 0) |
| 10449 | return ap_nfc_write_config_token(dut, conn, cmd); |
| 10450 | if (strcasecmp(oper, "WRITE_PASSWD") == 0) |
| 10451 | return ap_nfc_write_password_token(dut, conn, cmd); |
| 10452 | if (strcasecmp(oper, "WPS_READ_PASSWD") == 0) |
| 10453 | return ap_nfc_wps_read_passwd(dut, conn, cmd); |
| 10454 | if (strcasecmp(oper, "WPS_CONN_HNDOVR") == 0) |
| 10455 | return ap_nfc_wps_connection_handover(dut, conn, cmd); |
| 10456 | |
| 10457 | send_resp(dut, conn, SIGMA_ERROR, "ErrorCode,Unsupported operation"); |
| 10458 | return 0; |
| 10459 | } |
| 10460 | |
| 10461 | |
Jouni Malinen | f722271 | 2019-06-13 01:50:21 +0300 | [diff] [blame] | 10462 | static enum sigma_cmd_result cmd_ap_wps_read_pin(struct sigma_dut *dut, |
| 10463 | struct sigma_conn *conn, |
| 10464 | struct sigma_cmd *cmd) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 10465 | { |
| 10466 | char *pin = "12345670"; /* TODO: use random PIN */ |
| 10467 | char resp[100]; |
| 10468 | |
| 10469 | snprintf(resp, sizeof(resp), "PIN,%s", pin); |
| 10470 | send_resp(dut, conn, SIGMA_COMPLETE, resp); |
| 10471 | |
| 10472 | return 0; |
| 10473 | } |
| 10474 | |
| 10475 | |
Jouni Malinen | f722271 | 2019-06-13 01:50:21 +0300 | [diff] [blame] | 10476 | static enum sigma_cmd_result cmd_ap_wps_enter_pin(struct sigma_dut *dut, |
| 10477 | struct sigma_conn *conn, |
| 10478 | struct sigma_cmd *cmd) |
Alexei Avshalom Lazar | 6427969 | 2018-12-23 16:49:49 +0200 | [diff] [blame] | 10479 | { |
| 10480 | const char *pin = get_param(cmd, "PIN"); |
| 10481 | char wps_pin[11]; |
| 10482 | |
| 10483 | if (!pin) |
| 10484 | return -1; |
| 10485 | |
| 10486 | sigma_dut_print(dut, DUT_MSG_DEBUG, |
| 10487 | "Authorize a client to join with WPS PIN %s", pin); |
| 10488 | |
| 10489 | strlcpy(wps_pin, pin, sizeof(wps_pin)); |
| 10490 | /* we need to tolerate extra '-' characters entered */ |
| 10491 | str_remove_chars(wps_pin, '-'); |
| 10492 | strlcpy(dut->wps_pin, wps_pin, sizeof(dut->wps_pin)); |
| 10493 | dut->wps_method = WFA_CS_WPS_PIN_KEYPAD; |
| 10494 | |
| 10495 | return 1; |
| 10496 | } |
| 10497 | |
| 10498 | |
Jouni Malinen | f722271 | 2019-06-13 01:50:21 +0300 | [diff] [blame] | 10499 | static enum sigma_cmd_result cmd_ap_wps_set_pbc(struct sigma_dut *dut, |
| 10500 | struct sigma_conn *conn, |
| 10501 | struct sigma_cmd *cmd) |
Alexei Avshalom Lazar | 6427969 | 2018-12-23 16:49:49 +0200 | [diff] [blame] | 10502 | { |
| 10503 | sigma_dut_print(dut, DUT_MSG_DEBUG, |
| 10504 | "Selecting the push button configuration method"); |
| 10505 | |
| 10506 | dut->wps_method = WFA_CS_WPS_PBC; |
| 10507 | |
| 10508 | return 1; |
| 10509 | } |
| 10510 | |
| 10511 | |
Alexei Avshalom Lazar | 043230b | 2019-02-04 14:11:24 +0200 | [diff] [blame] | 10512 | int ap_wps_registration(struct sigma_dut *dut, struct sigma_conn *conn, |
| 10513 | struct sigma_cmd *cmd) |
| 10514 | { |
| 10515 | char buf[100], resp[256]; |
| 10516 | const char *intf = get_param(cmd, "interface"); |
| 10517 | const char *config_method = get_param(cmd, "WPSConfigMethod"); |
| 10518 | |
| 10519 | if (config_method && strcasecmp(config_method, "PBC") == 0) |
| 10520 | dut->wps_method = WFA_CS_WPS_PBC; |
| 10521 | |
| 10522 | if (!intf) |
Jouni Malinen | 016ae6c | 2019-11-04 17:00:01 +0200 | [diff] [blame] | 10523 | intf = get_main_ifname(dut); |
Alexei Avshalom Lazar | 043230b | 2019-02-04 14:11:24 +0200 | [diff] [blame] | 10524 | |
| 10525 | if (dut->wps_method == WFA_CS_WPS_NOT_READY) { |
| 10526 | send_resp(dut, conn, SIGMA_ERROR, |
| 10527 | "ErrorCode,WPS parameters not yet set"); |
| 10528 | return STATUS_SENT; |
| 10529 | } |
| 10530 | |
| 10531 | if (dut->wps_method == WFA_CS_WPS_PBC) |
| 10532 | snprintf(buf, sizeof(buf), "WPS_PBC"); |
| 10533 | else /* WFA_CS_WPS_PIN_KEYPAD */ |
| 10534 | snprintf(buf, sizeof(buf), "WPS_PIN any %s", dut->wps_pin); |
| 10535 | |
| 10536 | /* Run WPS command */ |
| 10537 | if (hapd_command(intf, buf) < 0) { |
| 10538 | /* command fails immediately if overlapped session detected */ |
| 10539 | snprintf(resp, sizeof(resp), "WpsState,OverlapSession"); |
| 10540 | send_resp(dut, conn, SIGMA_COMPLETE, resp); |
| 10541 | return STATUS_SENT; |
| 10542 | } |
| 10543 | |
| 10544 | /* In AP mode return immediately and do not wait for WPS registration */ |
| 10545 | return SUCCESS_SEND_STATUS; |
| 10546 | } |
| 10547 | |
| 10548 | |
Jouni Malinen | f722271 | 2019-06-13 01:50:21 +0300 | [diff] [blame] | 10549 | static enum sigma_cmd_result cmd_ap_get_parameter(struct sigma_dut *dut, |
| 10550 | struct sigma_conn *conn, |
| 10551 | struct sigma_cmd *cmd) |
Alexei Avshalom Lazar | 0c1d82d | 2018-12-23 17:02:42 +0200 | [diff] [blame] | 10552 | { |
| 10553 | char value[256], resp[512]; |
| 10554 | const char *param = get_param(cmd, "parameter"); |
| 10555 | const char *ifname = get_param(cmd, "Interface"); |
| 10556 | |
| 10557 | if (!ifname) |
Jouni Malinen | 016ae6c | 2019-11-04 17:00:01 +0200 | [diff] [blame] | 10558 | ifname = get_main_ifname(dut); |
Alexei Avshalom Lazar | 0c1d82d | 2018-12-23 17:02:42 +0200 | [diff] [blame] | 10559 | |
| 10560 | if (!param) { |
| 10561 | send_resp(dut, conn, SIGMA_ERROR, |
| 10562 | "ErrorCode,Parameter not specified"); |
| 10563 | return 0; |
| 10564 | } |
| 10565 | |
| 10566 | if (strcasecmp(param, "SSID") == 0) { |
| 10567 | if (get_hapd_config(ifname, "ssid", value, sizeof(value))) { |
| 10568 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 10569 | "Failed to get SSID"); |
| 10570 | return -2; |
| 10571 | } |
| 10572 | snprintf(resp, sizeof(resp), "SSID,%s", value); |
| 10573 | } else if (strcasecmp(param, "PSK") == 0) { |
| 10574 | if (get_hapd_config(ifname, "passphrase", value, |
| 10575 | sizeof(value))) { |
| 10576 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 10577 | "Failed to get PSK"); |
| 10578 | return -2; |
| 10579 | } |
| 10580 | snprintf(resp, sizeof(resp), "PSK,%s", value); |
| 10581 | } else { |
| 10582 | send_resp(dut, conn, SIGMA_ERROR, |
| 10583 | "ErrorCode,Unsupported parameter"); |
| 10584 | return 0; |
| 10585 | } |
| 10586 | |
| 10587 | send_resp(dut, conn, SIGMA_COMPLETE, resp); |
| 10588 | return 0; |
| 10589 | } |
| 10590 | |
| 10591 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 10592 | static int ath_vht_op_mode_notif(struct sigma_dut *dut, const char *ifname, |
| 10593 | const char *val) |
| 10594 | { |
| 10595 | char *token, *result; |
| 10596 | int nss = 0, chwidth = 0; |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 10597 | char *saveptr; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 10598 | |
| 10599 | /* |
| 10600 | * The following commands should be invoked to generate |
| 10601 | * VHT op mode notification |
| 10602 | */ |
| 10603 | |
| 10604 | /* Extract the NSS info */ |
| 10605 | token = strdup(val); |
| 10606 | if (!token) |
| 10607 | return -1; |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 10608 | result = strtok_r(token, ";", &saveptr); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 10609 | if (result) { |
| 10610 | int count = atoi(result); |
| 10611 | |
| 10612 | /* We do not support NSS > 3 */ |
| 10613 | if (count < 0 || count > 3) { |
| 10614 | free(token); |
| 10615 | return -1; |
| 10616 | } |
| 10617 | |
| 10618 | /* Convert nss to chainmask */ |
| 10619 | while (count--) |
| 10620 | nss = (nss << 1) | 1; |
| 10621 | |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 10622 | run_iwpriv(dut, ifname, "rxchainmask %d", nss); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 10623 | } |
| 10624 | |
| 10625 | /* Extract the Channel width info */ |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 10626 | result = strtok_r(NULL, ";", &saveptr); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 10627 | if (result) { |
| 10628 | switch (atoi(result)) { |
| 10629 | case 20: |
| 10630 | chwidth = 0; |
| 10631 | break; |
| 10632 | case 40: |
| 10633 | chwidth = 1; |
| 10634 | break; |
| 10635 | case 80: |
| 10636 | chwidth = 2; |
| 10637 | break; |
| 10638 | case 160: |
| 10639 | chwidth = 3; |
| 10640 | break; |
| 10641 | default: |
| 10642 | chwidth = 2; |
| 10643 | break; |
| 10644 | } |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 10645 | run_iwpriv(dut, ifname, "chwidth %d", chwidth); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 10646 | } |
| 10647 | |
| 10648 | /* Send the opmode notification */ |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 10649 | run_iwpriv(dut, ifname, "opmode_notify 1"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 10650 | free(token); |
| 10651 | |
| 10652 | return 0; |
| 10653 | } |
| 10654 | |
| 10655 | |
| 10656 | static int ath_vht_nss_mcs(struct sigma_dut *dut, const char *ifname, |
| 10657 | const char *val) |
| 10658 | { |
| 10659 | /* String (nss_operating_mode; mcs_operating_mode) */ |
| 10660 | int nss, mcs; |
| 10661 | char *token, *result; |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 10662 | char *saveptr; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 10663 | |
| 10664 | token = strdup(val); |
| 10665 | if (!token) |
| 10666 | return -1; |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 10667 | result = strtok_r(token, ";", &saveptr); |
Pradeep Reddy POTTETI | 41b8c54 | 2016-06-15 16:09:46 +0530 | [diff] [blame] | 10668 | if (!result) { |
| 10669 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 10670 | "VHT NSS not specified"); |
| 10671 | goto end; |
| 10672 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 10673 | if (strcasecmp(result, "def") != 0) { |
| 10674 | nss = atoi(result); |
| 10675 | |
| 10676 | if (nss == 4) |
| 10677 | ath_disable_txbf(dut, ifname); |
| 10678 | |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 10679 | run_iwpriv(dut, ifname, "nss %d", nss); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 10680 | } else { |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 10681 | if (dut->device_type == AP_testbed && dut->ap_sgi80 == 1) |
| 10682 | run_iwpriv(dut, ifname, "nss 1"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 10683 | } |
| 10684 | |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 10685 | result = strtok_r(NULL, ";", &saveptr); |
Pradeep Reddy POTTETI | 41b8c54 | 2016-06-15 16:09:46 +0530 | [diff] [blame] | 10686 | if (!result) { |
| 10687 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 10688 | "VHT MCS not specified"); |
| 10689 | goto end; |
| 10690 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 10691 | if (strcasecmp(result, "def") == 0) { |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 10692 | if (dut->device_type == AP_testbed && dut->ap_sgi80 == 1) |
| 10693 | run_iwpriv(dut, ifname, "vhtmcs 7"); |
| 10694 | else |
| 10695 | run_iwpriv(dut, ifname, "set11NRates 0"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 10696 | } else { |
| 10697 | mcs = atoi(result); |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 10698 | run_iwpriv(dut, ifname, "vhtmcs %d", mcs); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 10699 | } |
| 10700 | |
Pradeep Reddy POTTETI | 41b8c54 | 2016-06-15 16:09:46 +0530 | [diff] [blame] | 10701 | end: |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 10702 | free(token); |
| 10703 | return 0; |
| 10704 | } |
| 10705 | |
| 10706 | |
| 10707 | static int ath_vht_chnum_band(struct sigma_dut *dut, const char *ifname, |
| 10708 | const char *val) |
| 10709 | { |
| 10710 | char *token, *result; |
| 10711 | int channel = 36; |
| 10712 | int chwidth = 80; |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 10713 | char *saveptr; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 10714 | |
| 10715 | /* Extract the channel info */ |
| 10716 | token = strdup(val); |
| 10717 | if (!token) |
| 10718 | return -1; |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 10719 | result = strtok_r(token, ";", &saveptr); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 10720 | if (result) |
| 10721 | channel = atoi(result); |
| 10722 | |
| 10723 | /* Extract the channel width info */ |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 10724 | result = strtok_r(NULL, ";", &saveptr); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 10725 | if (result) |
| 10726 | chwidth = atoi(result); |
| 10727 | |
| 10728 | /* Issue the channel switch command */ |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 10729 | run_iwpriv(dut, ifname, "doth_ch_chwidth %d 10 %d", channel, chwidth); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 10730 | |
| 10731 | free(token); |
| 10732 | return 0; |
| 10733 | } |
| 10734 | |
| 10735 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 10736 | static int ath_ndpa_stainfo_mac(struct sigma_dut *dut, const char *ifname, |
| 10737 | const char *val) |
| 10738 | { |
| 10739 | char buf[80]; |
| 10740 | unsigned char mac_addr[6]; |
| 10741 | |
| 10742 | if (parse_mac_address(dut, val, mac_addr) < 0) |
| 10743 | return -1; |
| 10744 | |
| 10745 | snprintf(buf, sizeof(buf), |
| 10746 | "wifitool %s beeliner_fw_test 92 0x%02x%02x%02x%02x", |
| 10747 | ifname, mac_addr[0], mac_addr[1], mac_addr[2], mac_addr[3]); |
| 10748 | run_system(dut, buf); |
| 10749 | |
| 10750 | snprintf(buf, sizeof(buf), "wifitool %s beeliner_fw_test 93 0x%02x%02x", |
| 10751 | ifname, mac_addr[4], mac_addr[5]); |
| 10752 | run_system(dut, buf); |
| 10753 | |
| 10754 | snprintf(buf, sizeof(buf), "wifitool %s beeliner_fw_test 94 1", ifname); |
| 10755 | run_system(dut, buf); |
| 10756 | |
| 10757 | return 0; |
| 10758 | } |
| 10759 | |
| 10760 | |
Priyadharshini Gowthaman | 8c5b9a4 | 2019-07-31 14:38:48 -0700 | [diff] [blame] | 10761 | void novap_reset(struct sigma_dut *dut, const char *ifname, int reset) |
Priyadharshini Gowthaman | 39beafa | 2015-11-09 14:11:25 -0800 | [diff] [blame] | 10762 | { |
Priyadharshini Gowthaman | 8c5b9a4 | 2019-07-31 14:38:48 -0700 | [diff] [blame] | 10763 | run_iwpriv(dut, ifname, "novap_reset %d", reset); |
Priyadharshini Gowthaman | 39beafa | 2015-11-09 14:11:25 -0800 | [diff] [blame] | 10764 | } |
| 10765 | |
| 10766 | |
Jouni Malinen | b433543 | 2019-06-13 02:23:57 +0300 | [diff] [blame] | 10767 | static struct mbo_pref_ap * mbo_find_nebor_ap_entry(struct sigma_dut *dut, |
| 10768 | const uint8_t *mac_addr) |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 10769 | { |
Adil Saeed Musthafa | 6906372 | 2017-04-10 23:13:40 -0700 | [diff] [blame] | 10770 | int i; |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 10771 | |
Adil Saeed Musthafa | 6906372 | 2017-04-10 23:13:40 -0700 | [diff] [blame] | 10772 | for (i = 0; i < dut->mbo_pref_ap_cnt; i++) { |
| 10773 | if (memcmp(mac_addr, dut->mbo_pref_aps[i].mac_addr, |
| 10774 | ETH_ALEN) == 0) |
| 10775 | return &dut->mbo_pref_aps[i]; |
| 10776 | } |
| 10777 | return NULL; |
| 10778 | } |
| 10779 | |
| 10780 | |
| 10781 | static void mbo_add_nebor_entry(struct sigma_dut *dut, const uint8_t *mac_addr, |
| 10782 | int ap_ne_class, int ap_ne_op_ch, |
| 10783 | int ap_ne_pref) |
| 10784 | { |
| 10785 | struct mbo_pref_ap *entry; |
| 10786 | uint8_t self_mac[ETH_ALEN]; |
| 10787 | char ifname[50]; |
| 10788 | |
| 10789 | get_if_name(dut, ifname, sizeof(ifname), 1); |
| 10790 | get_hwaddr(ifname, self_mac); |
| 10791 | |
| 10792 | if (memcmp(mac_addr, self_mac, ETH_ALEN) == 0) |
| 10793 | entry = &dut->mbo_self_ap_tuple; |
| 10794 | else |
| 10795 | entry = mbo_find_nebor_ap_entry(dut, mac_addr); |
| 10796 | |
| 10797 | if (!entry) { |
| 10798 | if (dut->mbo_pref_ap_cnt >= MBO_MAX_PREF_BSSIDS) { |
| 10799 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 10800 | "Nebor AP List is full. Not adding"); |
| 10801 | return; |
| 10802 | } |
| 10803 | entry = &dut->mbo_pref_aps[dut->mbo_pref_ap_cnt]; |
| 10804 | dut->mbo_pref_ap_cnt++; |
| 10805 | memcpy(entry->mac_addr, mac_addr, ETH_ALEN); |
| 10806 | entry->ap_ne_class = -1; |
| 10807 | entry->ap_ne_op_ch = -1; |
| 10808 | entry->ap_ne_pref = -1; |
| 10809 | } |
| 10810 | if (ap_ne_class != -1) |
| 10811 | entry->ap_ne_class = ap_ne_class; |
| 10812 | if (ap_ne_op_ch != -1) |
| 10813 | entry->ap_ne_op_ch = ap_ne_op_ch; |
| 10814 | if (ap_ne_pref != -1) |
| 10815 | entry->ap_ne_pref = ap_ne_pref; |
| 10816 | } |
| 10817 | |
| 10818 | |
| 10819 | static int ath_set_nebor_bssid(struct sigma_dut *dut, const char *ifname, |
| 10820 | struct sigma_cmd *cmd) |
| 10821 | { |
| 10822 | unsigned char mac_addr[ETH_ALEN]; |
| 10823 | const char *val; |
| 10824 | /* |
| 10825 | * -1 is invalid value for the following |
| 10826 | * to differentiate between unset and set values |
| 10827 | * -1 => implies not set by CAPI |
| 10828 | */ |
| 10829 | int ap_ne_class = -1, ap_ne_op_ch = -1, ap_ne_pref = -1; |
| 10830 | int list_offset = dut->mbo_pref_ap_cnt; |
| 10831 | |
| 10832 | if (list_offset >= MBO_MAX_PREF_BSSIDS) { |
| 10833 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 10834 | "AP Pref Entry list is full"); |
| 10835 | return -1; |
| 10836 | } |
| 10837 | |
| 10838 | val = get_param(cmd, "Nebor_Op_Class"); |
| 10839 | if (val) |
| 10840 | ap_ne_class = atoi(val); |
| 10841 | |
| 10842 | val = get_param(cmd, "Nebor_Op_Ch"); |
| 10843 | if (val) |
| 10844 | ap_ne_op_ch = atoi(val); |
| 10845 | |
| 10846 | val = get_param(cmd, "Nebor_Pref"); |
| 10847 | if (val) |
| 10848 | ap_ne_pref = atoi(val); |
| 10849 | |
| 10850 | val = get_param(cmd, "Nebor_BSSID"); |
| 10851 | if (!val || parse_mac_address(dut, val, mac_addr) < 0) |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 10852 | return -1; |
| 10853 | |
Adil Saeed Musthafa | 6906372 | 2017-04-10 23:13:40 -0700 | [diff] [blame] | 10854 | mbo_add_nebor_entry(dut, mac_addr, ap_ne_class, ap_ne_op_ch, |
| 10855 | ap_ne_pref); |
| 10856 | apply_mbo_pref_ap_list(dut); |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 10857 | return 0; |
| 10858 | } |
| 10859 | |
| 10860 | |
Priyadharshini Gowthaman | c067edf | 2019-06-20 11:23:27 -0700 | [diff] [blame] | 10861 | static enum sigma_cmd_result he_ltf(struct sigma_dut *dut, |
| 10862 | struct sigma_conn *conn, |
| 10863 | const char *ifname, const char *val) |
| 10864 | { |
| 10865 | const char *var; |
| 10866 | |
| 10867 | if (dut->ap_he_ulofdma == VALUE_ENABLED) |
| 10868 | var = "he_ul_ltf"; |
| 10869 | else |
| 10870 | var = "he_ltf"; |
| 10871 | |
| 10872 | if (strcmp(val, "6.4") == 0) { |
| 10873 | run_iwpriv(dut, ifname, "%s 2", var); |
| 10874 | } else if (strcmp(val, "12.8") == 0) { |
| 10875 | run_iwpriv(dut, ifname, "%s 3", var); |
| 10876 | } else if (strcmp(val, "3.2") == 0) { |
| 10877 | run_iwpriv(dut, ifname, "%s 1", var); |
| 10878 | } else { |
| 10879 | send_resp(dut, conn, SIGMA_ERROR, "errorCode,Unsupported LTF"); |
| 10880 | return STATUS_SENT_ERROR; |
| 10881 | } |
| 10882 | |
| 10883 | return SUCCESS_SEND_STATUS; |
| 10884 | } |
| 10885 | |
| 10886 | |
Priyadharshini Gowthaman | cc6ff5a | 2019-06-20 11:23:52 -0700 | [diff] [blame] | 10887 | static enum sigma_cmd_result he_shortgi(struct sigma_dut *dut, |
| 10888 | struct sigma_conn *conn, |
| 10889 | const char *ifname, |
| 10890 | const char *val) |
| 10891 | { |
| 10892 | const char *var; |
| 10893 | |
| 10894 | if (dut->ap_he_ulofdma == VALUE_ENABLED) |
| 10895 | var = "he_ul_shortgi"; |
| 10896 | else |
| 10897 | var = "shortgi"; |
| 10898 | |
| 10899 | if (strcmp(val, "0.8") == 0) { |
| 10900 | run_iwpriv(dut, ifname, "%s 0", var); |
| 10901 | } else if (strcmp(val, "1.6") == 0) { |
| 10902 | run_iwpriv(dut, ifname, "%s 2", var); |
| 10903 | } else if (strcmp(val, "3.2") == 0) { |
| 10904 | run_iwpriv(dut, ifname, "%s 3", var); |
| 10905 | } else { |
| 10906 | send_resp(dut, conn, SIGMA_ERROR, |
| 10907 | "errorCode,Unsupported shortGI"); |
| 10908 | return STATUS_SENT_ERROR; |
| 10909 | } |
| 10910 | |
| 10911 | return SUCCESS_SEND_STATUS; |
| 10912 | } |
| 10913 | |
| 10914 | |
| 10915 | static enum sigma_cmd_result he_ar_gi_ltf_mask(struct sigma_dut *dut, |
| 10916 | struct sigma_conn *conn, |
| 10917 | const char *ifname, |
| 10918 | const char *val) |
| 10919 | { |
| 10920 | |
| 10921 | uint32_t he_ar_gi_ltf; |
| 10922 | uint16_t he_ar_gi, he_ar_ltf; |
| 10923 | |
| 10924 | if (strcmp(val, "0.4") == 0) { |
| 10925 | he_ar_gi = 0x01; |
| 10926 | } else if (strcmp(val, "0.8") == 0) { |
| 10927 | he_ar_gi = 0x02; |
| 10928 | } else if (strcmp(val, "1.6") == 0) { |
| 10929 | he_ar_gi = 0x04; |
| 10930 | } else if (strcmp(val, "3.2") == 0) { |
| 10931 | he_ar_gi = 0x08; |
| 10932 | } else { |
| 10933 | send_resp(dut, conn, SIGMA_ERROR, |
| 10934 | "errorCode,Unsupported shortGI"); |
| 10935 | return STATUS_SENT_ERROR; |
| 10936 | } |
| 10937 | |
| 10938 | if (dut->ar_ltf && strcmp(dut->ar_ltf, "6.4") == 0) { |
| 10939 | he_ar_ltf = 0x02; |
| 10940 | } else if (dut->ar_ltf && strcmp(dut->ar_ltf, "12.8") == 0) { |
| 10941 | he_ar_ltf = 0x04; |
| 10942 | } else if (dut->ar_ltf && strcmp(dut->ar_ltf, "3.2") == 0) { |
| 10943 | he_ar_ltf = 0x01; |
| 10944 | } else { |
| 10945 | send_resp(dut, conn, SIGMA_ERROR, |
| 10946 | "errorCode,Unsupported LTF"); |
| 10947 | return STATUS_SENT_ERROR; |
| 10948 | } |
| 10949 | |
| 10950 | he_ar_gi_ltf = (he_ar_gi << 8) | he_ar_ltf; |
| 10951 | run_iwpriv(dut, ifname, "he_ar_gi_ltf %lu", he_ar_gi_ltf); |
| 10952 | |
| 10953 | return SUCCESS_SEND_STATUS; |
| 10954 | } |
| 10955 | |
| 10956 | |
Priyadharshini Gowthaman | 9e7d831 | 2019-06-20 11:24:03 -0700 | [diff] [blame] | 10957 | static enum sigma_cmd_result he_rualloctones(struct sigma_dut *dut, |
| 10958 | struct sigma_conn *conn, |
| 10959 | const char *ifname, |
| 10960 | const char *val) |
| 10961 | { |
| 10962 | char *token, *result; |
| 10963 | int value; |
| 10964 | char *saveptr; |
| 10965 | int rualloc_type; |
| 10966 | enum sigma_cmd_result ret = SUCCESS_SEND_STATUS; |
| 10967 | |
| 10968 | token = strdup(val); |
| 10969 | if (!token) |
| 10970 | return -1; |
| 10971 | result = strtok_r(token, ":", &saveptr); |
| 10972 | if (!result) { |
| 10973 | free(token); |
| 10974 | send_resp(dut, conn, SIGMA_ERROR, |
| 10975 | "errorCode,RUAllocTones not specified"); |
| 10976 | return STATUS_SENT_ERROR; |
| 10977 | } |
| 10978 | |
| 10979 | /* |
| 10980 | * ru_allocation_type can take the values of: |
| 10981 | * 1 - DL OFDMA data RU allocation |
| 10982 | * 3 - UL OFDMA data RU allocation |
| 10983 | */ |
| 10984 | rualloc_type = dut->ap_he_ulofdma == VALUE_ENABLED ? 3 : 1; |
| 10985 | |
| 10986 | |
| 10987 | value = atoi(result); |
| 10988 | if (value == 106) { |
| 10989 | enum value_not_set_enabled_disabled ap_he_rualloc_106_80 = |
| 10990 | VALUE_NOT_SET; |
| 10991 | |
| 10992 | result = strtok_r(NULL, ":", &saveptr); |
| 10993 | if (result) { |
| 10994 | result = strtok_r(NULL, ":", &saveptr); |
| 10995 | if (result) |
| 10996 | ap_he_rualloc_106_80 = VALUE_ENABLED; |
| 10997 | else |
| 10998 | ap_he_rualloc_106_80 = VALUE_DISABLED; |
| 10999 | } |
| 11000 | if (ap_he_rualloc_106_80 == VALUE_ENABLED) { |
| 11001 | run_system_wrapper(dut, |
| 11002 | "wifitool %s setUnitTestCmd 0x4b 9 %d 0 2 1 2 2 2 3 2", |
| 11003 | ifname, rualloc_type); |
| 11004 | } else { |
| 11005 | run_system_wrapper(dut, |
| 11006 | "wifitool %s setUnitTestCmd 0x4b 5 %d 0 2 1 2", |
| 11007 | ifname, rualloc_type); |
| 11008 | } |
| 11009 | } else if (value == 242) { |
| 11010 | run_system_wrapper( |
| 11011 | dut, |
| 11012 | "wifitool %s setUnitTestCmd 0x4b 9 %d 0 3 1 3 2 3 3 3", |
| 11013 | ifname, rualloc_type); |
| 11014 | } else if (value == 26) { |
| 11015 | run_system_wrapper( |
| 11016 | dut, |
| 11017 | "wifitool %s setUnitTestCmd 0x4b 9 %d 0 0 2 0 5 0 7 0", |
| 11018 | ifname, rualloc_type); |
| 11019 | } else if (value == 52) { |
| 11020 | run_system_wrapper( |
| 11021 | dut, |
| 11022 | "wifitool %s setUnitTestCmd 0x4b 9 %d 0 1 1 1 2 1 3 1", |
| 11023 | ifname, rualloc_type); |
| 11024 | } else if (value == 484) { |
| 11025 | run_system_wrapper( |
| 11026 | dut, |
| 11027 | "wifitool %s setUnitTestCmd 0x4b 5 %d 0 4 1 4", |
| 11028 | ifname, rualloc_type); |
| 11029 | } else if (value == 996) { |
| 11030 | run_system_wrapper(dut, |
| 11031 | "wifitool %s setUnitTestCmd 0x4b 3 %d 0 5", |
| 11032 | ifname, rualloc_type); |
| 11033 | } else { |
| 11034 | send_resp(dut, conn, SIGMA_ERROR, |
| 11035 | "errorCode,Unsupported RUAllocTones"); |
| 11036 | ret = STATUS_SENT_ERROR; |
| 11037 | } |
| 11038 | |
| 11039 | free(token); |
| 11040 | return ret; |
| 11041 | } |
| 11042 | |
| 11043 | |
Priyadharshini Gowthaman | 7e43870 | 2019-08-09 12:05:05 -0700 | [diff] [blame] | 11044 | static void ath_set_trigger_type_0(struct sigma_dut *dut, const char *ifname) |
| 11045 | { |
| 11046 | /* TriggerType "0" for Basic trigger */ |
| 11047 | if (dut->ap_channel >= 36) { |
| 11048 | /* 1 and 2 here is interpreted to 5g and 2g (bitmasks) */ |
| 11049 | run_system_wrapper(dut, |
| 11050 | "wifitool %s setUnitTestCmd 0x47 2 42 1", |
| 11051 | ifname); |
| 11052 | } else { |
| 11053 | run_system_wrapper(dut, |
| 11054 | "wifitool %s setUnitTestCmd 0x47 2 42 2", |
| 11055 | ifname); |
| 11056 | } |
| 11057 | run_system_wrapper(dut, "wifitool %s setUnitTestCmd 0x47 2 43 6", |
| 11058 | ifname); |
| 11059 | } |
| 11060 | |
| 11061 | |
| 11062 | static void ath_set_trigger_type_1(struct sigma_dut *dut, const char *ifname) |
| 11063 | { |
| 11064 | /* TriggerType "1" for MU BRP */ |
| 11065 | run_system_wrapper(dut, "wifitool %s setUnitTestCmd 0x47 2 7 1", |
| 11066 | ifname); |
| 11067 | mubrp_commands(dut, ifname); |
| 11068 | } |
| 11069 | |
| 11070 | |
| 11071 | static void ath_set_trigger_type_2(struct sigma_dut *dut, const char *ifname) |
| 11072 | { |
| 11073 | /* TriggerType "2" for MU BAR */ |
| 11074 | if (dut->ap_channel >= 36) { |
| 11075 | /* RU allocation RU 242 - DL OFDMA data */ |
| 11076 | run_system_wrapper(dut, |
| 11077 | "wifitool %s setUnitTestCmd 0x4b 5 9 0 3 1 3 2 3 3 3", |
| 11078 | ifname); |
| 11079 | /* RU allocation RU 52 - UL BA */ |
| 11080 | run_system_wrapper(dut, |
| 11081 | "wifitool %s setUnitTestCmd 0x4b 5 9 0 2 1 2 2 2 3 2", |
| 11082 | ifname); |
| 11083 | } else { |
| 11084 | /* RU allocation RU 52 - DL ofdma data */ |
| 11085 | run_system_wrapper(dut, |
| 11086 | "wifitool %s setUnitTestCmd 0x4b 5 9 0 1 1 1 2 1 3 1", |
| 11087 | ifname); |
| 11088 | } |
| 11089 | /* Force TBPPDU duration to 400 us */ |
| 11090 | run_system_wrapper(dut, "wifitool %s setUnitTestCmd 0x48 2 63 400", |
| 11091 | ifname); |
| 11092 | /* 0 to enable MU BAR, 1 to enable SU BAR */ |
| 11093 | run_system_wrapper(dut, "wifitool %s setUnitTestCmd 0x47 2 49 0", |
| 11094 | ifname); |
| 11095 | /* MU BAR */ |
| 11096 | run_system_wrapper(dut, "wifitool %s setUnitTestCmd 0x47 2 64 0", |
| 11097 | ifname); |
| 11098 | } |
| 11099 | |
| 11100 | |
| 11101 | static void ath_set_trigger_type_3(struct sigma_dut *dut, const char *ifname) |
| 11102 | { |
| 11103 | /* TriggerType "3" for MU RTS */ |
| 11104 | /* Send MU RTS Trigger - '1' is to enable MU RTS */ |
| 11105 | run_system_wrapper(dut, "wifitool %s setUnitTestCmd 0x47 2 101 1", |
| 11106 | ifname); |
| 11107 | } |
| 11108 | |
| 11109 | |
| 11110 | static void ath_set_trigger_type_4(struct sigma_dut *dut, const char *ifname, |
| 11111 | const char *basedev) |
| 11112 | { |
| 11113 | /* TriggerType "4" for BSRP */ |
| 11114 | run_system_wrapper(dut, "cfg80211tool %s he_ul_trig_int 200", basedev); |
| 11115 | run_system_wrapper(dut, "wifitool %s setUnitTestCmd 0x48 2 63 1000", |
| 11116 | ifname); |
| 11117 | if (dut->ap_channel >= 36) { |
| 11118 | run_system_wrapper(dut, |
| 11119 | "wifitool %s setUnitTestCmd 0x47 2 42 1", |
| 11120 | ifname); |
| 11121 | } else { |
| 11122 | run_system_wrapper(dut, |
| 11123 | "wifitool %s setUnitTestCmd 0x47 2 42 2", |
| 11124 | ifname); |
| 11125 | } |
| 11126 | /* Send BSRP command */ |
| 11127 | run_system_wrapper(dut, "wifitool %s setUnitTestCmd 0x47 2 43 7", |
| 11128 | ifname); |
| 11129 | } |
| 11130 | |
| 11131 | |
Jouni Malinen | 6076ffc | 2019-08-08 18:18:02 +0300 | [diff] [blame] | 11132 | static enum sigma_cmd_result ath_ap_set_rfeature(struct sigma_dut *dut, |
| 11133 | struct sigma_conn *conn, |
| 11134 | struct sigma_cmd *cmd) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 11135 | { |
| 11136 | const char *val; |
Jouni Malinen | 016ae6c | 2019-11-04 17:00:01 +0200 | [diff] [blame] | 11137 | const char *ifname; |
Priyadharshini Gowthaman | c067edf | 2019-06-20 11:23:27 -0700 | [diff] [blame] | 11138 | enum sigma_cmd_result res; |
Priyadharshini Gowthaman | f8c032d | 2019-07-31 14:38:02 -0700 | [diff] [blame] | 11139 | const char *basedev = "wifi0"; |
Priyadharshini Gowthaman | 2f8c317 | 2019-07-31 14:38:12 -0700 | [diff] [blame] | 11140 | int trigtype; |
Priyadharshini Gowthaman | 51c0fec | 2019-08-09 12:04:05 -0700 | [diff] [blame] | 11141 | int he_ackpolicymac = 0; |
Priyadharshini Gowthaman | e87e2c9 | 2019-08-09 12:04:31 -0700 | [diff] [blame] | 11142 | char *num_ss = NULL; |
| 11143 | char *nss[4] = { NULL, NULL, NULL, NULL }; |
Priyadharshini Gowthaman | dca0c54 | 2019-08-09 12:04:42 -0700 | [diff] [blame] | 11144 | char *aid[4] = { NULL, NULL, NULL, NULL }; |
| 11145 | char *aid_ss = NULL; |
Priyadharshini Gowthaman | 2da1ecc | 2019-08-09 12:04:54 -0700 | [diff] [blame] | 11146 | int omctrl_rxnss = 0, omctrl_chwidth = 0; |
Priyadharshini Gowthaman | 872fb29 | 2019-08-09 12:05:27 -0700 | [diff] [blame] | 11147 | int param; |
Priyadharshini Gowthaman | 51c0fec | 2019-08-09 12:04:05 -0700 | [diff] [blame] | 11148 | unsigned char mac_addr[ETH_ALEN]; |
| 11149 | |
| 11150 | memset(mac_addr, 0x00, ETH_ALEN); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 11151 | |
Jouni Malinen | 016ae6c | 2019-11-04 17:00:01 +0200 | [diff] [blame] | 11152 | ifname = get_main_ifname(dut); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 11153 | |
Priyadharshini Gowthaman | f8c032d | 2019-07-31 14:38:02 -0700 | [diff] [blame] | 11154 | if (sigma_radio_ifname[0]) |
| 11155 | basedev = sigma_radio_ifname[0]; |
| 11156 | |
Priyadharshini Gowthaman | 39beafa | 2015-11-09 14:11:25 -0800 | [diff] [blame] | 11157 | /* Disable vap reset between the commands */ |
Priyadharshini Gowthaman | 8c5b9a4 | 2019-07-31 14:38:48 -0700 | [diff] [blame] | 11158 | novap_reset(dut, ifname, 1); |
Priyadharshini Gowthaman | 39beafa | 2015-11-09 14:11:25 -0800 | [diff] [blame] | 11159 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 11160 | val = get_param(cmd, "Opt_md_notif_ie"); |
| 11161 | if (val && ath_vht_op_mode_notif(dut, ifname, val) < 0) |
Jouni Malinen | 6076ffc | 2019-08-08 18:18:02 +0300 | [diff] [blame] | 11162 | return ERROR_SEND_STATUS; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 11163 | |
| 11164 | /* TODO: Optional arguments */ |
| 11165 | |
| 11166 | val = get_param(cmd, "nss_mcs_opt"); |
| 11167 | if (val && ath_vht_nss_mcs(dut, ifname, val) < 0) |
Jouni Malinen | 6076ffc | 2019-08-08 18:18:02 +0300 | [diff] [blame] | 11168 | return ERROR_SEND_STATUS; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 11169 | |
| 11170 | val = get_param(cmd, "chnum_band"); |
| 11171 | if (val && ath_vht_chnum_band(dut, ifname, val) < 0) |
Jouni Malinen | 6076ffc | 2019-08-08 18:18:02 +0300 | [diff] [blame] | 11172 | return ERROR_SEND_STATUS; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 11173 | |
| 11174 | val = get_param(cmd, "RTS_FORCE"); |
| 11175 | if (val) |
| 11176 | ath_config_rts_force(dut, ifname, val); |
| 11177 | |
| 11178 | val = get_param(cmd, "DYN_BW_SGNL"); |
| 11179 | if (val) |
| 11180 | ath_config_dyn_bw_sig(dut, ifname, val); |
| 11181 | |
| 11182 | val = get_param(cmd, "CTS_WIDTH"); |
| 11183 | if (val) |
| 11184 | ath_set_cts_width(dut, ifname, val); |
| 11185 | |
| 11186 | val = get_param(cmd, "Ndpa_stainfo_mac"); |
| 11187 | if (val && ath_ndpa_stainfo_mac(dut, ifname, val) < 0) |
Jouni Malinen | 6076ffc | 2019-08-08 18:18:02 +0300 | [diff] [blame] | 11188 | return ERROR_SEND_STATUS; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 11189 | |
| 11190 | val = get_param(cmd, "txBandwidth"); |
| 11191 | if (val && ath_set_width(dut, conn, ifname, val) < 0) |
Jouni Malinen | 6076ffc | 2019-08-08 18:18:02 +0300 | [diff] [blame] | 11192 | return ERROR_SEND_STATUS; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 11193 | |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 11194 | val = get_param(cmd, "Assoc_Disallow"); |
| 11195 | if (val) |
| 11196 | ath_set_assoc_disallow(dut, ifname, val); |
| 11197 | |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 11198 | |
Adil Saeed Musthafa | 6906372 | 2017-04-10 23:13:40 -0700 | [diff] [blame] | 11199 | ath_set_nebor_bssid(dut, ifname, cmd); |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 11200 | val = get_param(cmd, "BTMReq_DisAssoc_Imnt"); |
priyadharshini gowthaman | 776562e | 2017-12-20 12:33:34 -0800 | [diff] [blame] | 11201 | if (val) { |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 11202 | dut->ap_btmreq_disassoc_imnt = atoi(val); |
priyadharshini gowthaman | 776562e | 2017-12-20 12:33:34 -0800 | [diff] [blame] | 11203 | dut->ap_disassoc_timer = 1000; |
| 11204 | } |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 11205 | |
| 11206 | val = get_param(cmd, "BTMReq_Term_Bit"); |
| 11207 | if (val) |
| 11208 | dut->ap_btmreq_term_bit = atoi(val); |
| 11209 | |
Adil Saeed Musthafa | 48c5ab9 | 2017-04-10 23:13:35 -0700 | [diff] [blame] | 11210 | val = get_param(cmd, "Assoc_Delay"); |
priyadharshini gowthaman | 776562e | 2017-12-20 12:33:34 -0800 | [diff] [blame] | 11211 | if (val) { |
| 11212 | dut->ap_assoc_delay = 1; |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 11213 | run_iwpriv(dut, ifname, "mbo_asoc_ret %s", val); |
priyadharshini gowthaman | 776562e | 2017-12-20 12:33:34 -0800 | [diff] [blame] | 11214 | } |
Adil Saeed Musthafa | 48c5ab9 | 2017-04-10 23:13:35 -0700 | [diff] [blame] | 11215 | |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 11216 | val = get_param(cmd, "Disassoc_Timer"); |
| 11217 | if (val) |
| 11218 | dut->ap_disassoc_timer = atoi(val); |
| 11219 | |
| 11220 | val = get_param(cmd, "BSS_Term_Duration"); |
| 11221 | if (val) |
| 11222 | dut->ap_btmreq_bss_term_dur = atoi(val); |
| 11223 | |
priyadharshini gowthaman | 94062b5 | 2017-12-20 12:33:34 -0800 | [diff] [blame] | 11224 | val = get_param(cmd, "BSS_Term_TSF"); |
| 11225 | if (val) |
| 11226 | dut->ap_btmreq_bss_term_tsf = atoi(val); |
| 11227 | |
priyadharshini gowthaman | cb22e43 | 2017-12-28 15:23:31 -0800 | [diff] [blame] | 11228 | val = get_param(cmd, "TxPower"); |
| 11229 | if (val) |
| 11230 | ath_set_txpower(dut, ifname, val); |
| 11231 | |
| 11232 | val = get_param(cmd, "DownlinkAvailCap"); |
| 11233 | if (val) |
| 11234 | dut->ap_dl_availcap = atoi(val); |
| 11235 | |
| 11236 | val = get_param(cmd, "UplinkAvailCap"); |
| 11237 | if (val) { |
| 11238 | dut->ap_ul_availcap = atoi(val); |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 11239 | run_iwpriv(dut, ifname, "oce_wan_mtr %d %d", |
| 11240 | dut->ap_dl_availcap, dut->ap_ul_availcap); |
priyadharshini gowthaman | cb22e43 | 2017-12-28 15:23:31 -0800 | [diff] [blame] | 11241 | } |
| 11242 | |
| 11243 | val = get_param(cmd, "RSSIthreshold"); |
| 11244 | if (val) { |
| 11245 | int rssithreshold; |
| 11246 | |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 11247 | run_iwpriv(dut, ifname, "oce_asoc_rej 1"); |
priyadharshini gowthaman | cb22e43 | 2017-12-28 15:23:31 -0800 | [diff] [blame] | 11248 | rssithreshold = atoi(val); |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 11249 | run_iwpriv(dut, ifname, "oce_asoc_rssi %d", rssithreshold); |
priyadharshini gowthaman | cb22e43 | 2017-12-28 15:23:31 -0800 | [diff] [blame] | 11250 | } |
| 11251 | |
| 11252 | val = get_param(cmd, "RetryDelay"); |
| 11253 | if (val) { |
| 11254 | int retrydelay; |
| 11255 | |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 11256 | run_iwpriv(dut, ifname, "oce_asoc_rej 1"); |
priyadharshini gowthaman | cb22e43 | 2017-12-28 15:23:31 -0800 | [diff] [blame] | 11257 | retrydelay = atoi(val); |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 11258 | run_iwpriv(dut, ifname, "oce_asoc_dly %d", retrydelay); |
priyadharshini gowthaman | cb22e43 | 2017-12-28 15:23:31 -0800 | [diff] [blame] | 11259 | } |
| 11260 | |
Priyadharshini Gowthaman | c067edf | 2019-06-20 11:23:27 -0700 | [diff] [blame] | 11261 | val = get_param(cmd, "LTF"); |
| 11262 | if (val) { |
| 11263 | if (dut->ap_fixed_rate) { |
| 11264 | res = he_ltf(dut, conn, ifname, val); |
| 11265 | if (res != SUCCESS_SEND_STATUS) |
| 11266 | return res; |
| 11267 | } else { |
| 11268 | free(dut->ar_ltf); |
| 11269 | dut->ar_ltf = strdup(val); |
| 11270 | if (!dut->ar_ltf) |
Jouni Malinen | 6076ffc | 2019-08-08 18:18:02 +0300 | [diff] [blame] | 11271 | return ERROR_SEND_STATUS; |
Priyadharshini Gowthaman | c067edf | 2019-06-20 11:23:27 -0700 | [diff] [blame] | 11272 | } |
| 11273 | } |
| 11274 | |
Priyadharshini Gowthaman | cc6ff5a | 2019-06-20 11:23:52 -0700 | [diff] [blame] | 11275 | val = get_param(cmd, "GI"); |
| 11276 | if (val) { |
| 11277 | if (dut->ap_fixed_rate) |
| 11278 | res = he_shortgi(dut, conn, ifname, val); |
| 11279 | else |
| 11280 | res = he_ar_gi_ltf_mask(dut, conn, ifname, val); |
| 11281 | if (res != SUCCESS_SEND_STATUS) |
| 11282 | return res; |
| 11283 | } |
| 11284 | |
Priyadharshini Gowthaman | 9e7d831 | 2019-06-20 11:24:03 -0700 | [diff] [blame] | 11285 | val = get_param(cmd, "RUAllocTones"); |
| 11286 | if (val) { |
| 11287 | res = he_rualloctones(dut, conn, ifname, val); |
| 11288 | if (res != SUCCESS_SEND_STATUS) |
| 11289 | return res; |
| 11290 | } |
| 11291 | |
Priyadharshini Gowthaman | 803fd66 | 2019-07-31 14:37:49 -0700 | [diff] [blame] | 11292 | val = get_param(cmd, "MPDU_MU_SpacingFactor"); |
| 11293 | if (val) |
| 11294 | run_system_wrapper(dut, |
| 11295 | "wifitool %s setUnitTestCmd 0x48 2 119, %s", |
| 11296 | ifname, val); |
| 11297 | |
| 11298 | val = get_param(cmd, "PPDUTxType"); |
| 11299 | if (val) { |
| 11300 | if (strcasecmp(val, "HE-SU") == 0) { |
| 11301 | /* Change PPDU format type to HE-SU MCS 1 */ |
| 11302 | run_system_wrapper(dut, |
| 11303 | "wifitool %s setUnitTestCmd 0x48 2 89 0x401", |
| 11304 | ifname); |
| 11305 | } else if (strcasecmp(val, "legacy") == 0) { |
| 11306 | /* Change PPDU format type to non-HT */ |
| 11307 | run_system_wrapper(dut, |
| 11308 | "wifitool %s setUnitTestCmd 0x48 2 89 3", |
| 11309 | ifname); |
| 11310 | } else { |
| 11311 | send_resp(dut, conn, SIGMA_ERROR, |
| 11312 | "errorCode,Unsupported PPDUTxType"); |
| 11313 | return STATUS_SENT_ERROR; |
| 11314 | } |
| 11315 | } |
| 11316 | |
| 11317 | val = get_param(cmd, "TXOPDuration"); |
| 11318 | if (val) { |
| 11319 | if (strcasecmp(val, "UNSPECIFIED") == 0) { |
| 11320 | /* The hardware is hardcoded with 0x7f; do nothing */ |
| 11321 | } else { |
| 11322 | send_resp(dut, conn, SIGMA_ERROR, |
| 11323 | "errorCode,Unsupported TXOPDuration"); |
| 11324 | return STATUS_SENT_ERROR; |
| 11325 | } |
| 11326 | } |
| 11327 | |
Priyadharshini Gowthaman | f8c032d | 2019-07-31 14:38:02 -0700 | [diff] [blame] | 11328 | val = get_param(cmd, "Trig_Usrinfo_UL-MCS"); |
| 11329 | if (val) |
| 11330 | run_iwpriv(dut, ifname, "he_ul_mcs %d", atoi(val)); |
| 11331 | |
| 11332 | val = get_param(cmd, "Trig_Usrinfo_UL-Target-RSSI"); |
| 11333 | if (val) { |
| 11334 | /* Set target RSSI to -55 dBm */ |
| 11335 | run_system_wrapper(dut, |
| 11336 | "wifitool %s setUnitTestCmd 0x4b 2 7 %d", |
| 11337 | ifname, atoi(val) - 110); |
| 11338 | } |
| 11339 | |
| 11340 | val = get_param(cmd, "Trig_Interval"); |
| 11341 | if (val) |
| 11342 | run_iwpriv(dut, basedev, "he_ul_trig_int %d", atoi(val)); |
| 11343 | |
| 11344 | val = get_param(cmd, "Trig_ComInfo_ULLength"); |
| 11345 | if (val) |
| 11346 | run_system_wrapper(dut, |
| 11347 | "wifitool %s setUnitTestCmd 0x48 2 141 %d", |
| 11348 | ifname, atoi(val)); |
| 11349 | |
Priyadharshini Gowthaman | 2f8c317 | 2019-07-31 14:38:12 -0700 | [diff] [blame] | 11350 | val = get_param(cmd, "DisableTriggerType"); |
| 11351 | if (val) { |
| 11352 | trigtype = atoi(val); |
| 11353 | switch (trigtype) { |
| 11354 | case 0: |
| 11355 | /* DisableTriggerType "0" for basic trigger */ |
| 11356 | run_system_wrapper(dut, |
| 11357 | "wifitool %s setUnitTestCmd 0x47 2 42 0", |
| 11358 | ifname); |
| 11359 | break; |
| 11360 | default: |
| 11361 | /* Nothing to be done for now */ |
| 11362 | break; |
| 11363 | } |
| 11364 | } |
| 11365 | |
| 11366 | val = get_param(cmd, "Trigger_TxBF"); |
| 11367 | if (val) { |
| 11368 | if (strcasecmp(val, "enable") == 0) { |
| 11369 | run_iwpriv(dut, ifname, "he_sounding_mode 0x9"); |
| 11370 | } else if (strcasecmp(val, "disable") == 0) { |
| 11371 | run_iwpriv(dut, ifname, "he_sounding_mode 0x1"); |
| 11372 | } else { |
| 11373 | send_resp(dut, conn, SIGMA_ERROR, |
| 11374 | "errorCode,Unsupported trigger_txbf"); |
| 11375 | return STATUS_SENT_ERROR; |
| 11376 | } |
| 11377 | } |
| 11378 | |
Priyadharshini Gowthaman | 7b94f08 | 2019-07-31 14:38:25 -0700 | [diff] [blame] | 11379 | val = get_param(cmd, "Trig_UsrInfo_RUAlloc"); |
| 11380 | if (val) { |
| 11381 | res = he_rualloctones(dut, conn, ifname, val); |
| 11382 | if (res != SUCCESS_SEND_STATUS) |
| 11383 | return res; |
| 11384 | } |
| 11385 | |
Priyadharshini Gowthaman | 8701fac | 2019-07-31 14:38:48 -0700 | [diff] [blame] | 11386 | val = get_param(cmd, "TriggerCoding"); |
| 11387 | if (val) { |
| 11388 | if (strcasecmp(val, "BCC") == 0) { |
| 11389 | /* In case of LDPC enable this command can force BCC if |
| 11390 | * RU size <= 242 */ |
| 11391 | run_iwpriv(dut, ifname, "he_ul_ldpc 0"); |
| 11392 | } else if (strcasecmp(val, "LDPC") == 0) { |
| 11393 | novap_reset(dut, ifname, 0); |
| 11394 | run_iwpriv(dut, ifname, "he_ul_ldpc 1"); |
| 11395 | novap_reset(dut, ifname, 1); |
| 11396 | } else { |
| 11397 | send_resp(dut, conn, SIGMA_ERROR, |
| 11398 | "errorCode,Unsupported TriggerCoding"); |
| 11399 | return STATUS_SENT_ERROR; |
| 11400 | } |
| 11401 | } |
| 11402 | |
Priyadharshini Gowthaman | 51c0fec | 2019-08-09 12:04:05 -0700 | [diff] [blame] | 11403 | val = get_param(cmd, "AckPolicy_MAC"); |
| 11404 | if (val) { |
| 11405 | if (parse_mac_address(dut, val, mac_addr) < 0) { |
| 11406 | send_resp(dut, conn, SIGMA_ERROR, |
| 11407 | "errorCode,MAC Address not in proper format"); |
| 11408 | return STATUS_SENT_ERROR; |
| 11409 | } |
| 11410 | he_ackpolicymac = 1; |
| 11411 | } |
| 11412 | |
| 11413 | val = get_param(cmd, "AckPolicy"); |
| 11414 | if (val) { |
| 11415 | int ap_he_ackpolicy; |
| 11416 | |
| 11417 | ap_he_ackpolicy = atoi(val); |
| 11418 | if (ap_he_ackpolicy == 0 && he_ackpolicymac) { |
| 11419 | /* Disable all-BAR ackpolicy for MU-MIMO */ |
| 11420 | run_system_wrapper(dut, |
| 11421 | "wifitool %s setUnitTestCmd 0x48 2 62 0", |
| 11422 | ifname); |
| 11423 | /* Disable all-BAR ackpolicy first */ |
| 11424 | run_system_wrapper(dut, |
| 11425 | "wifitool %s setUnitTestCmd 0x48 2 64 0", |
| 11426 | ifname); |
| 11427 | /* Set normal ack policy for the STA with the specified |
| 11428 | * MAC address in DL-TX case */ |
| 11429 | run_system_wrapper(dut, |
| 11430 | "wifitool %s setUnitTestCmd 0x4b 8 8 1 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x", |
| 11431 | ifname, mac_addr[0], mac_addr[1], |
| 11432 | mac_addr[2], mac_addr[3], |
| 11433 | mac_addr[4], mac_addr[5]); |
| 11434 | } else if (ap_he_ackpolicy == 3) { |
| 11435 | /* Enable all-BAR ackpolicy for MU-MIMO DL */ |
| 11436 | run_system_wrapper(dut, |
| 11437 | "wifitool %s setUnitTestCmd 0x48 2 62 1", |
| 11438 | ifname); |
| 11439 | /* Enable all-BAR ackpolicy */ |
| 11440 | run_system_wrapper(dut, |
| 11441 | "wifitool %s setUnitTestCmd 0x48 2 64 1", |
| 11442 | ifname); |
| 11443 | } else if (ap_he_ackpolicy == 4) { |
| 11444 | /* Enable htp-ack ackpolicy */ |
| 11445 | run_system_wrapper(dut, |
| 11446 | "wifitool %s setUnitTestCmd 0x47 2 99 1", |
| 11447 | ifname); |
| 11448 | } else { |
| 11449 | send_resp(dut, conn, SIGMA_ERROR, |
| 11450 | "errorCode,Invalid AckPolicy setting"); |
| 11451 | return STATUS_SENT_ERROR; |
| 11452 | } |
| 11453 | } |
| 11454 | |
Priyadharshini Gowthaman | c9a88c7 | 2019-08-09 12:04:17 -0700 | [diff] [blame] | 11455 | val = get_param(cmd, "Trig_ComInfo_GI-LTF"); |
| 11456 | if (val) { |
| 11457 | int trig_gi_ltf; |
| 11458 | |
| 11459 | trig_gi_ltf = atoi(val); |
| 11460 | if (trig_gi_ltf == 0) { |
| 11461 | he_ltf(dut, conn, ifname, "3.2"); |
| 11462 | he_shortgi(dut, conn, ifname, "1.6"); |
| 11463 | } else if (trig_gi_ltf == 1) { |
| 11464 | he_ltf(dut, conn, ifname, "6.4"); |
| 11465 | he_shortgi(dut, conn, ifname, "1.6"); |
| 11466 | } else if (trig_gi_ltf == 2) { |
| 11467 | he_ltf(dut, conn, ifname, "12.8"); |
| 11468 | he_shortgi(dut, conn, ifname, "3.2"); |
| 11469 | } else { |
| 11470 | send_resp(dut, conn, SIGMA_ERROR, |
| 11471 | "errorCode,Unsupported Trig_ComInfo_GI-LTF"); |
| 11472 | return STATUS_SENT_ERROR; |
| 11473 | } |
| 11474 | } |
| 11475 | |
| 11476 | val = get_param(cmd, "Trig_ComInfo_BW"); |
| 11477 | if (val) { |
| 11478 | int chwidth; |
| 11479 | |
| 11480 | chwidth = atoi(val); |
| 11481 | /* Set the channel width */ |
| 11482 | run_iwpriv(dut, ifname, "chwidth %d", chwidth); |
| 11483 | } |
| 11484 | |
Priyadharshini Gowthaman | e87e2c9 | 2019-08-09 12:04:31 -0700 | [diff] [blame] | 11485 | val = get_param(cmd, "NumSS"); |
| 11486 | if (val) { |
| 11487 | int i = 0; |
| 11488 | char *numss_val; |
| 11489 | char *saveptr; |
| 11490 | |
| 11491 | num_ss = strdup(val); |
| 11492 | if (!num_ss) |
| 11493 | return ERROR_SEND_STATUS; |
| 11494 | |
| 11495 | numss_val = strtok_r(num_ss, " ", &saveptr); |
| 11496 | for (i = 0; numss_val && i < 4; i++) { |
| 11497 | nss[i] = numss_val; |
| 11498 | numss_val = strtok_r(NULL, " ", &saveptr); |
| 11499 | } |
| 11500 | } |
| 11501 | |
| 11502 | val = get_param(cmd, "NumSS_MAC"); |
| 11503 | if (val) { |
| 11504 | char *sta_mac_str; |
| 11505 | char *saveptr; |
| 11506 | char *sta_mac_list_str; |
| 11507 | |
| 11508 | sta_mac_list_str = strdup(val); |
| 11509 | if (!sta_mac_list_str) { |
| 11510 | free(num_ss); |
| 11511 | return ERROR_SEND_STATUS; |
| 11512 | } |
| 11513 | |
| 11514 | sta_mac_str = strtok_r(sta_mac_list_str, " ", &saveptr); |
| 11515 | if (sta_mac_str && nss[0]) { |
| 11516 | run_system_wrapper(dut, |
| 11517 | "wifitool %s chmask_persta %s %s", |
| 11518 | ifname, sta_mac_str, nss[0]); |
| 11519 | } |
| 11520 | |
| 11521 | sta_mac_str = strtok_r(NULL, " ", &saveptr); |
| 11522 | if (sta_mac_str && nss[1]) { |
| 11523 | run_system_wrapper(dut, |
| 11524 | "wifitool %s chmask_persta %s %s", |
| 11525 | ifname, sta_mac_str, nss[1]); |
| 11526 | } |
| 11527 | |
| 11528 | sta_mac_str = strtok_r(NULL, " ", &saveptr); |
| 11529 | if (sta_mac_str && nss[2]) { |
| 11530 | run_system_wrapper(dut, |
| 11531 | "wifitool %s chmask_persta %s %s", |
| 11532 | ifname, sta_mac_str, nss[2]); |
| 11533 | } |
| 11534 | |
| 11535 | sta_mac_str = strtok_r(NULL, " ", &saveptr); |
| 11536 | if (sta_mac_str && nss[3]) { |
| 11537 | run_system_wrapper(dut, |
| 11538 | "wifitool %s chmask_persta %s %s", |
| 11539 | ifname, sta_mac_str, nss[3]); |
| 11540 | } |
| 11541 | |
| 11542 | free(sta_mac_list_str); |
| 11543 | } |
| 11544 | |
| 11545 | free(num_ss); |
| 11546 | num_ss = NULL; |
| 11547 | |
Priyadharshini Gowthaman | dca0c54 | 2019-08-09 12:04:42 -0700 | [diff] [blame] | 11548 | val = get_param(cmd, "AID"); |
| 11549 | if (val) { |
| 11550 | int i = 0; |
| 11551 | char *aid_val; |
| 11552 | char *saveptr; |
| 11553 | |
| 11554 | aid_ss = strdup(val); |
| 11555 | if (!aid_ss) |
| 11556 | return ERROR_SEND_STATUS; |
| 11557 | |
| 11558 | aid_val = strtok_r(aid_ss, " ", &saveptr); |
| 11559 | for (i = 0; aid_val && i < 4; i++) { |
| 11560 | aid[i] = aid_val; |
| 11561 | aid_val = strtok_r(NULL, " ", &saveptr); |
| 11562 | } |
| 11563 | } |
| 11564 | |
| 11565 | val = get_param(cmd, "AddbaReq"); |
| 11566 | if (val) { |
| 11567 | if (strcasecmp(val, "enable") == 0) { |
| 11568 | run_iwpriv(dut, ifname, "setaddbaoper 1"); |
| 11569 | run_system_wrapper(dut, |
| 11570 | "wifitool %s sendaddba %s 0 64", |
| 11571 | ifname, aid[0]); |
| 11572 | } else { |
| 11573 | send_resp(dut, conn, SIGMA_ERROR, |
| 11574 | "errorCode,Unsupported AddbaReq value"); |
| 11575 | free(aid_ss); |
| 11576 | return STATUS_SENT_ERROR; |
| 11577 | } |
| 11578 | } |
| 11579 | |
| 11580 | val = get_param(cmd, "AddbaResp"); |
| 11581 | if (val) { |
| 11582 | if (aid_ss && strcasecmp(val, "accepted") == 0) { |
| 11583 | int aid_1 = atoi(aid_ss); |
| 11584 | |
| 11585 | if (aid_1 == 1) |
| 11586 | aid_1 = 2; |
| 11587 | else |
| 11588 | aid_1 = aid_1 - 1; |
| 11589 | |
| 11590 | /* There is no mechanism in place to reject Add BA Req |
| 11591 | * from all STAs and selectively accept Add BA Req from |
| 11592 | * a specified STA. Instead, it can accept Add BA Req |
| 11593 | * from all STAs and selectively reject from specified |
| 11594 | * STAs. Make changes for the same using the below |
| 11595 | * commands. */ |
| 11596 | run_system_wrapper(dut, ifname, "setaddbaoper 1"); |
| 11597 | run_system_wrapper(dut, "wifitool %s refusealladdbas 0", |
| 11598 | ifname); |
| 11599 | run_system_wrapper(dut, |
| 11600 | "wifitool %s setaddbaresp %d 0 37", |
| 11601 | ifname, aid_1); |
| 11602 | } else { |
| 11603 | send_resp(dut, conn, SIGMA_ERROR, |
| 11604 | "errorCode,Unsupported Addbaresp value"); |
| 11605 | free(aid_ss); |
| 11606 | return STATUS_SENT_ERROR; |
| 11607 | } |
| 11608 | } |
| 11609 | |
| 11610 | val = get_param(cmd, "Trig_UsrInfo_SSAlloc_RA-RU"); |
| 11611 | if (val) { |
| 11612 | char *ssalloc_str; |
| 11613 | char *saveptr; |
| 11614 | char *ssalloc_list_str; |
| 11615 | |
| 11616 | ssalloc_list_str = strdup(val); |
| 11617 | if (!ssalloc_list_str) { |
| 11618 | free(aid_ss); |
| 11619 | return ERROR_SEND_STATUS; |
| 11620 | } |
| 11621 | |
| 11622 | ssalloc_str = strtok_r(ssalloc_list_str, ":", &saveptr); |
| 11623 | if (ssalloc_str && aid[0]) { |
| 11624 | run_system_wrapper(dut, "wifitool %s peer_nss %s %s", |
| 11625 | ifname, aid[0], ssalloc_str); |
| 11626 | } |
| 11627 | |
| 11628 | ssalloc_str = strtok_r(NULL, " ", &saveptr); |
| 11629 | if (ssalloc_str && aid[1]) { |
| 11630 | run_system_wrapper(dut, "wifitool %s peer_nss %s %s", |
| 11631 | ifname, aid[1], ssalloc_str); |
| 11632 | } |
| 11633 | |
| 11634 | ssalloc_str = strtok_r(NULL, " ", &saveptr); |
| 11635 | if (ssalloc_str && aid[2]) { |
| 11636 | run_system_wrapper(dut, "wifitool %s peer_nss %s %s", |
| 11637 | ifname, aid[2], ssalloc_str); |
| 11638 | } |
| 11639 | |
| 11640 | ssalloc_str = strtok_r(NULL, " ", &saveptr); |
| 11641 | if (ssalloc_str && aid[3]) { |
| 11642 | run_system_wrapper(dut, "wifitool %s peer_nss %s %s", |
| 11643 | ifname, aid[3], ssalloc_str); |
| 11644 | } |
| 11645 | |
| 11646 | free(ssalloc_list_str); |
| 11647 | } |
| 11648 | |
| 11649 | free(aid_ss); |
| 11650 | aid_ss = NULL; |
| 11651 | |
Priyadharshini Gowthaman | 2da1ecc | 2019-08-09 12:04:54 -0700 | [diff] [blame] | 11652 | val = get_param(cmd, "OMCtrl_RxNSS"); |
| 11653 | if (val) |
| 11654 | omctrl_rxnss = atoi(val); |
| 11655 | |
| 11656 | val = get_param(cmd, "OMCtrl_ChnlWidth"); |
| 11657 | if (val) |
| 11658 | omctrl_chwidth = atoi(val); |
| 11659 | |
| 11660 | val = get_param(cmd, "Client_mac"); |
| 11661 | if (val) { |
| 11662 | if (parse_mac_address(dut, val, mac_addr) < 0) { |
| 11663 | send_resp(dut, conn, SIGMA_ERROR, |
| 11664 | "errorCode,MAC Address not in proper format"); |
| 11665 | return STATUS_SENT_ERROR; |
| 11666 | } |
| 11667 | |
| 11668 | /* setUnitTestCmd 13 7 1 mac3mac2mac1mac0 mac5mac4 <rx_nss> |
| 11669 | * <bw> <ulmu> <tx_nss> */ |
| 11670 | run_system_wrapper(dut, |
| 11671 | "wifitool %s setUnitTestCmd 13 7 1 0x%02x%02x%02x%02x 0x%02x%02x %d %d 1 %d", |
| 11672 | ifname, mac_addr[3], mac_addr[2], |
| 11673 | mac_addr[1], mac_addr[0], mac_addr[5], |
| 11674 | mac_addr[4], omctrl_rxnss, |
| 11675 | omctrl_chwidth, omctrl_rxnss); |
| 11676 | } |
| 11677 | |
Priyadharshini Gowthaman | 7e43870 | 2019-08-09 12:05:05 -0700 | [diff] [blame] | 11678 | val = get_param(cmd, "TriggerType"); |
| 11679 | if (val) { |
| 11680 | trigtype = atoi(val); |
| 11681 | switch (trigtype) { |
| 11682 | case 0: |
| 11683 | ath_set_trigger_type_0(dut, ifname); |
| 11684 | break; |
| 11685 | case 1: |
| 11686 | ath_set_trigger_type_1(dut, ifname); |
| 11687 | break; |
| 11688 | case 2: |
| 11689 | ath_set_trigger_type_2(dut, ifname); |
| 11690 | break; |
| 11691 | case 3: |
| 11692 | ath_set_trigger_type_3(dut, ifname); |
| 11693 | break; |
| 11694 | case 4: |
| 11695 | ath_set_trigger_type_4(dut, ifname, basedev); |
| 11696 | break; |
| 11697 | default: |
| 11698 | send_resp(dut, conn, SIGMA_ERROR, |
| 11699 | "errorCode,TriggerType not supported"); |
| 11700 | return STATUS_SENT_ERROR; |
| 11701 | } |
| 11702 | } |
| 11703 | |
Priyadharshini Gowthaman | c352d82 | 2019-08-09 12:05:16 -0700 | [diff] [blame] | 11704 | val = get_param(cmd, "HE_TXOPDurRTSThr"); |
| 11705 | if (val) |
| 11706 | run_iwpriv(dut, ifname, "he_rtsthrshld %d", atoi(val)); |
| 11707 | |
| 11708 | val = get_param(cmd, "NAV_Update"); |
| 11709 | if (val) { |
| 11710 | if (strcasecmp(val, "disable") == 0) { |
| 11711 | run_iwpriv(dut, basedev, "nav_config 1 0"); |
| 11712 | } else if (strcasecmp(val, "enable") == 0) { |
| 11713 | /* Do nothing */ |
| 11714 | } else { |
| 11715 | send_resp(dut, conn, SIGMA_ERROR, |
| 11716 | "errorCode,Unsupported NAV update"); |
| 11717 | return STATUS_SENT_ERROR; |
| 11718 | } |
| 11719 | } |
| 11720 | |
Priyadharshini Gowthaman | 872fb29 | 2019-08-09 12:05:27 -0700 | [diff] [blame] | 11721 | /* Configure WMM Parameter Elements */ |
| 11722 | val = get_param(cmd, "STA_WMMPE_ECWmin_BE"); |
| 11723 | if (val) { |
| 11724 | param = atoi(val); |
| 11725 | run_iwpriv(dut, ifname, "cwmin %d 1 %d", AP_AC_BE, param); |
| 11726 | } |
| 11727 | |
| 11728 | val = get_param(cmd, "STA_WMMPE_ECWmin_BK"); |
| 11729 | if (val) { |
| 11730 | param = atoi(val); |
| 11731 | run_iwpriv(dut, ifname, "cwmin %d 1 %d", AP_AC_BK, param); |
| 11732 | } |
| 11733 | |
| 11734 | val = get_param(cmd, "STA_WMMPE_ECWmin_VI"); |
| 11735 | if (val) { |
| 11736 | param = atoi(val); |
| 11737 | run_iwpriv(dut, ifname, "cwmin %d 1 %d", AP_AC_VI, param); |
| 11738 | } |
| 11739 | |
| 11740 | val = get_param(cmd, "STA_WMMPE_ECWmin_VO"); |
| 11741 | if (val) { |
| 11742 | param = atoi(val); |
| 11743 | run_iwpriv(dut, ifname, "cwmin %d 1 %d", AP_AC_VO, param); |
| 11744 | } |
| 11745 | |
| 11746 | val = get_param(cmd, "STA_WMMPE_ECWmax_BE"); |
| 11747 | if (val) { |
| 11748 | param = atoi(val); |
| 11749 | run_iwpriv(dut, ifname, "cwmax %d 1 %d", AP_AC_BE, param); |
| 11750 | } |
| 11751 | |
| 11752 | val = get_param(cmd, "STA_WMMPE_ECWmax_BK"); |
| 11753 | if (val) { |
| 11754 | param = atoi(val); |
| 11755 | run_iwpriv(dut, ifname, "cwmax %d 1 %d", AP_AC_BK, param); |
| 11756 | } |
| 11757 | |
| 11758 | val = get_param(cmd, "STA_WMMPE_ECWmax_VI"); |
| 11759 | if (val) { |
| 11760 | param = atoi(val); |
| 11761 | run_iwpriv(dut, ifname, "cwmax %d 1 %d", AP_AC_VI, param); |
| 11762 | } |
| 11763 | |
| 11764 | val = get_param(cmd, "STA_WMMPE_ECWmax_VO"); |
| 11765 | if (val) { |
| 11766 | param = atoi(val); |
| 11767 | run_iwpriv(dut, ifname, "cwmax %d 1 %d", AP_AC_VO, param); |
| 11768 | } |
| 11769 | |
| 11770 | val = get_param(cmd, "STA_WMMPE_AIFSN_BE"); |
| 11771 | if (val) { |
| 11772 | param = atoi(val); |
| 11773 | run_iwpriv(dut, ifname, "aifs %d 1 %d", AP_AC_BE, param); |
| 11774 | } |
| 11775 | |
| 11776 | val = get_param(cmd, "STA_WMMPE_AIFSN_BK"); |
| 11777 | if (val) { |
| 11778 | param = atoi(val); |
| 11779 | run_iwpriv(dut, ifname, "aifs %d 1 %d", AP_AC_BK, param); |
| 11780 | } |
| 11781 | |
| 11782 | val = get_param(cmd, "STA_WMMPE_AIFSN_VI"); |
| 11783 | if (val) { |
| 11784 | param = atoi(val); |
| 11785 | run_iwpriv(dut, ifname, "aifs %d 1 %d", AP_AC_VI, param); |
| 11786 | } |
| 11787 | |
| 11788 | val = get_param(cmd, "STA_WMMPE_AIFSN_VO"); |
| 11789 | if (val) { |
| 11790 | param = atoi(val); |
| 11791 | run_iwpriv(dut, ifname, "aifs %d 1 %d", AP_AC_VO, param); |
| 11792 | } |
| 11793 | |
| 11794 | |
| 11795 | val = get_param(cmd, "STA_WMMPE_TXOP_BE"); |
| 11796 | if (val) { |
| 11797 | param = atoi(val); |
| 11798 | run_iwpriv(dut, ifname, "txoplimit %d 1 %d", AP_AC_BE, param); |
| 11799 | } |
| 11800 | |
| 11801 | val = get_param(cmd, "STA_WMMPE_TOXP_BK"); |
| 11802 | if (val) { |
| 11803 | param = atoi(val); |
| 11804 | run_iwpriv(dut, ifname, "txoplimit %d 1 %d", AP_AC_BK, param); |
| 11805 | } |
| 11806 | |
| 11807 | val = get_param(cmd, "STA_WMMPE_TXOP_VI"); |
| 11808 | if (val) { |
| 11809 | param = atoi(val); |
| 11810 | run_iwpriv(dut, ifname, "txoplimit %d %d", AP_AC_VI, param); |
| 11811 | } |
| 11812 | |
| 11813 | val = get_param(cmd, "STA_WMMPE_TXOP_VO"); |
| 11814 | if (val) { |
| 11815 | param = atoi(val); |
| 11816 | run_iwpriv(dut, ifname, "txoplimit %d 1 %d", AP_AC_VO, param); |
| 11817 | } |
| 11818 | |
Priyadharshini Gowthaman | c46b7e4 | 2019-08-09 12:05:37 -0700 | [diff] [blame] | 11819 | /* Configure MU EDCA */ |
| 11820 | val = get_param(cmd, "STA_MUEDCA_ECWmin_BE"); |
| 11821 | if (val) { |
| 11822 | param = atoi(val); |
| 11823 | run_iwpriv(dut, ifname, "muedca_ecwmin %d %d", AP_AC_BE, param); |
| 11824 | } |
| 11825 | |
| 11826 | val = get_param(cmd, "STA_MUEDCA_ECWmin_BK"); |
| 11827 | if (val) { |
| 11828 | param = atoi(val); |
| 11829 | run_iwpriv(dut, ifname, "muedca_ecwmin %d %d", AP_AC_BK, param); |
| 11830 | } |
| 11831 | |
| 11832 | val = get_param(cmd, "STA_MUEDCA_ECWmin_VI"); |
| 11833 | if (val) { |
| 11834 | param = atoi(val); |
| 11835 | run_iwpriv(dut, ifname, "muedca_ecwmin %d %d", AP_AC_VI, param); |
| 11836 | } |
| 11837 | |
| 11838 | val = get_param(cmd, "STA_MUEDCA_ECWmin_VO"); |
| 11839 | if (val) { |
| 11840 | param = atoi(val); |
| 11841 | run_iwpriv(dut, ifname, "muedca_ecwmin %d %d", AP_AC_VO, param); |
| 11842 | } |
| 11843 | |
| 11844 | val = get_param(cmd, "STA_MUEDCA_ECWmax_BE"); |
| 11845 | if (val) { |
| 11846 | param = atoi(val); |
| 11847 | run_iwpriv(dut, ifname, "muedca_ecwmax %d %d", AP_AC_BE, param); |
| 11848 | } |
| 11849 | |
| 11850 | val = get_param(cmd, "STA_MUEDCA_ECWmax_BK"); |
| 11851 | if (val) { |
| 11852 | param = atoi(val); |
| 11853 | run_iwpriv(dut, ifname, "muedca_ecwmax %d %d", AP_AC_BK, param); |
| 11854 | } |
| 11855 | |
| 11856 | val = get_param(cmd, "STA_MUEDCA_ECWmax_VI"); |
| 11857 | if (val) { |
| 11858 | param = atoi(val); |
| 11859 | run_iwpriv(dut, ifname, "muedca_ecwmax %d %d", AP_AC_VI, param); |
| 11860 | } |
| 11861 | |
| 11862 | val = get_param(cmd, "STA_MUEDCA_ECWmax_VO"); |
| 11863 | if (val) { |
| 11864 | param = atoi(val); |
| 11865 | run_iwpriv(dut, ifname, "muedca_ecwmax %d %d", AP_AC_VO, param); |
| 11866 | } |
| 11867 | |
| 11868 | val = get_param(cmd, "STA_MUEDCA_AIFSN_BE"); |
| 11869 | if (val) { |
| 11870 | param = atoi(val); |
| 11871 | run_iwpriv(dut, ifname, "muedca_aifsn %d %d", AP_AC_BE, param); |
| 11872 | } |
| 11873 | |
| 11874 | val = get_param(cmd, "STA_MUEDCA_AIFSN_BK"); |
| 11875 | if (val) { |
| 11876 | param = atoi(val); |
| 11877 | run_iwpriv(dut, ifname, "muedca_aifsn %d %d", AP_AC_BK, param); |
| 11878 | } |
| 11879 | |
| 11880 | val = get_param(cmd, "STA_MUEDCA_AIFSN_VI"); |
| 11881 | if (val) { |
| 11882 | param = atoi(val); |
| 11883 | run_iwpriv(dut, ifname, "muedca_aifsn %d %d", AP_AC_VI, param); |
| 11884 | } |
| 11885 | |
| 11886 | val = get_param(cmd, "STA_MUEDCA_AIFSN_VO"); |
| 11887 | if (val) { |
| 11888 | param = atoi(val); |
| 11889 | run_iwpriv(dut, ifname, "muedca_aifsn %d %d", AP_AC_VO, param); |
| 11890 | } |
| 11891 | |
| 11892 | val = get_param(cmd, "STA_MUEDCA_Timer_BE"); |
| 11893 | if (val) { |
| 11894 | param = atoi(val); |
| 11895 | run_iwpriv(dut, ifname, "muedca_timer %d %d", AP_AC_BE, param); |
| 11896 | } |
| 11897 | |
| 11898 | val = get_param(cmd, "STA_MUEDCA_Timer_BK"); |
| 11899 | if (val) { |
| 11900 | param = atoi(val); |
| 11901 | run_iwpriv(dut, ifname, "muedca_timer %d %d", AP_AC_BK, param); |
| 11902 | } |
| 11903 | |
| 11904 | val = get_param(cmd, "STA_MUEDCA_Timer_VI"); |
| 11905 | if (val) { |
| 11906 | param = atoi(val); |
| 11907 | run_iwpriv(dut, ifname, "muedca_timer %d %d", AP_AC_VI, param); |
| 11908 | } |
| 11909 | |
| 11910 | val = get_param(cmd, "STA_MUEDCA_Timer_VO"); |
| 11911 | if (val) { |
| 11912 | param = atoi(val); |
| 11913 | run_iwpriv(dut, ifname, "muedca_timer %d %d", AP_AC_VO, param); |
| 11914 | } |
| 11915 | |
Jouni Malinen | 6076ffc | 2019-08-08 18:18:02 +0300 | [diff] [blame] | 11916 | return SUCCESS_SEND_STATUS; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 11917 | } |
| 11918 | |
| 11919 | |
Pradeep Reddy POTTETI | 88fd82c | 2016-03-14 12:20:18 +0530 | [diff] [blame] | 11920 | static int wcn_vht_chnum_band(struct sigma_dut *dut, const char *ifname, |
| 11921 | const char *val) |
| 11922 | { |
| 11923 | char *token, *result; |
| 11924 | int channel = 36; |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 11925 | char *saveptr; |
Pradeep Reddy POTTETI | 88fd82c | 2016-03-14 12:20:18 +0530 | [diff] [blame] | 11926 | |
| 11927 | /* Extract the channel info */ |
| 11928 | token = strdup(val); |
| 11929 | if (!token) |
| 11930 | return -1; |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 11931 | result = strtok_r(token, ";", &saveptr); |
Pradeep Reddy POTTETI | 88fd82c | 2016-03-14 12:20:18 +0530 | [diff] [blame] | 11932 | if (result) |
| 11933 | channel = atoi(result); |
| 11934 | |
| 11935 | /* Issue the channel switch command */ |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 11936 | run_iwpriv(dut, ifname, "setChanChange %d", channel); |
Pradeep Reddy POTTETI | 88fd82c | 2016-03-14 12:20:18 +0530 | [diff] [blame] | 11937 | |
| 11938 | free(token); |
| 11939 | return 0; |
| 11940 | } |
| 11941 | |
| 11942 | |
| 11943 | static int wcn_ap_set_rfeature(struct sigma_dut *dut, struct sigma_conn *conn, |
| 11944 | struct sigma_cmd *cmd) |
| 11945 | { |
| 11946 | const char *val; |
Jouni Malinen | 016ae6c | 2019-11-04 17:00:01 +0200 | [diff] [blame] | 11947 | const char *ifname; |
Pradeep Reddy POTTETI | 88fd82c | 2016-03-14 12:20:18 +0530 | [diff] [blame] | 11948 | |
Jouni Malinen | 016ae6c | 2019-11-04 17:00:01 +0200 | [diff] [blame] | 11949 | ifname = get_main_ifname(dut); |
Pradeep Reddy POTTETI | 88fd82c | 2016-03-14 12:20:18 +0530 | [diff] [blame] | 11950 | |
| 11951 | val = get_param(cmd, "chnum_band"); |
| 11952 | if (val && wcn_vht_chnum_band(dut, ifname, val) < 0) |
| 11953 | return -1; |
| 11954 | |
| 11955 | return 1; |
| 11956 | } |
| 11957 | |
| 11958 | |
Mohammed Shafi Shajakhan | b53d8f9 | 2017-02-28 09:05:15 +0530 | [diff] [blame] | 11959 | static int mac80211_vht_chnum_band(struct sigma_dut *dut, const char *ifname, |
| 11960 | const char *val) |
| 11961 | { |
| 11962 | char *token, *result; |
| 11963 | int channel = 36, chwidth = 80, center_freq_idx, center_freq, |
| 11964 | channel_freq; |
| 11965 | char buf[100]; |
| 11966 | char *saveptr; |
Jouni Malinen | 3aa7286 | 2019-05-29 23:14:51 +0300 | [diff] [blame] | 11967 | int res; |
Mohammed Shafi Shajakhan | b53d8f9 | 2017-02-28 09:05:15 +0530 | [diff] [blame] | 11968 | |
| 11969 | /* Extract the channel info */ |
| 11970 | token = strdup(val); |
| 11971 | if (!token) |
| 11972 | return -1; |
| 11973 | result = strtok_r(token, ";", &saveptr); |
| 11974 | if (result) |
| 11975 | channel = atoi(result); |
| 11976 | |
| 11977 | /* Extract the channel width info */ |
| 11978 | result = strtok_r(NULL, ";", &saveptr); |
| 11979 | if (result) |
| 11980 | chwidth = atoi(result); |
| 11981 | |
| 11982 | center_freq_idx = get_oper_centr_freq_seq_idx(chwidth, channel); |
| 11983 | if (center_freq_idx < 0) { |
| 11984 | free(token); |
| 11985 | return -1; |
| 11986 | } |
| 11987 | |
| 11988 | center_freq = get_5g_channel_freq(center_freq_idx); |
| 11989 | channel_freq = get_5g_channel_freq(channel); |
| 11990 | |
| 11991 | /* Issue the channel switch command */ |
Jouni Malinen | 3aa7286 | 2019-05-29 23:14:51 +0300 | [diff] [blame] | 11992 | res = snprintf(buf, sizeof(buf), |
| 11993 | " -i %s chan_switch 10 %d sec_channel_offset=1 center_freq1=%d bandwidth=%d blocktx vht", |
| 11994 | ifname, channel_freq, center_freq, chwidth); |
| 11995 | if (res < 0 || res >= sizeof(buf) || run_hostapd_cli(dut, buf) != 0) { |
Mohammed Shafi Shajakhan | b53d8f9 | 2017-02-28 09:05:15 +0530 | [diff] [blame] | 11996 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 11997 | "hostapd_cli chan_switch failed"); |
| 11998 | } |
| 11999 | |
| 12000 | free(token); |
| 12001 | return 0; |
| 12002 | } |
| 12003 | |
| 12004 | |
| 12005 | static int mac80211_ap_set_rfeature(struct sigma_dut *dut, |
| 12006 | struct sigma_conn *conn, |
| 12007 | struct sigma_cmd *cmd) |
| 12008 | { |
| 12009 | const char *val; |
Jouni Malinen | 016ae6c | 2019-11-04 17:00:01 +0200 | [diff] [blame] | 12010 | const char *ifname; |
Mohammed Shafi Shajakhan | b53d8f9 | 2017-02-28 09:05:15 +0530 | [diff] [blame] | 12011 | |
Jouni Malinen | 016ae6c | 2019-11-04 17:00:01 +0200 | [diff] [blame] | 12012 | ifname = get_main_ifname(dut); |
Mohammed Shafi Shajakhan | b53d8f9 | 2017-02-28 09:05:15 +0530 | [diff] [blame] | 12013 | val = get_param(cmd, "chnum_band"); |
| 12014 | if (val && mac80211_vht_chnum_band(dut, ifname, val) < 0) |
| 12015 | return -1; |
| 12016 | |
| 12017 | return 1; |
| 12018 | } |
| 12019 | |
| 12020 | |
Alexei Avshalom Lazar | bc180dc | 2018-12-18 16:01:14 +0200 | [diff] [blame] | 12021 | #ifdef __linux__ |
| 12022 | static int wil6210_ap_set_rfeature(struct sigma_dut *dut, |
| 12023 | struct sigma_conn *conn, |
| 12024 | struct sigma_cmd *cmd) |
| 12025 | { |
| 12026 | const char *val; |
| 12027 | |
| 12028 | val = get_param(cmd, "ExtSchIE"); |
| 12029 | if (val && !strcasecmp(val, "Enable")) { |
| 12030 | struct sigma_ese_alloc allocs[MAX_ESE_ALLOCS]; |
| 12031 | int count = MAX_ESE_ALLOCS; |
| 12032 | |
| 12033 | if (sta_extract_60g_ese(dut, cmd, allocs, &count)) |
| 12034 | return -1; |
| 12035 | if (wil6210_set_ese(dut, count, allocs)) |
| 12036 | return -1; |
| 12037 | return 1; |
| 12038 | } |
| 12039 | |
| 12040 | send_resp(dut, conn, SIGMA_ERROR, |
| 12041 | "errorCode,Invalid ap_set_rfeature(60G)"); |
| 12042 | return 0; |
| 12043 | } |
| 12044 | #endif /* __linux__ */ |
| 12045 | |
| 12046 | |
Jouni Malinen | f722271 | 2019-06-13 01:50:21 +0300 | [diff] [blame] | 12047 | static enum sigma_cmd_result cmd_ap_set_rfeature(struct sigma_dut *dut, |
| 12048 | struct sigma_conn *conn, |
| 12049 | struct sigma_cmd *cmd) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 12050 | { |
| 12051 | /* const char *name = get_param(cmd, "NAME"); */ |
| 12052 | /* const char *type = get_param(cmd, "Type"); */ |
| 12053 | |
Jouni Malinen | 016ae6c | 2019-11-04 17:00:01 +0200 | [diff] [blame] | 12054 | switch (get_driver_type(dut)) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 12055 | case DRIVER_ATHEROS: |
| 12056 | return ath_ap_set_rfeature(dut, conn, cmd); |
| 12057 | case DRIVER_OPENWRT: |
| 12058 | switch (get_openwrt_driver_type()) { |
| 12059 | case OPENWRT_DRIVER_ATHEROS: |
| 12060 | return ath_ap_set_rfeature(dut, conn, cmd); |
| 12061 | default: |
| 12062 | send_resp(dut, conn, SIGMA_ERROR, |
| 12063 | "errorCode,Unsupported ap_set_rfeature with the current openwrt driver"); |
| 12064 | return 0; |
| 12065 | } |
Sreelakshmi Konamki | 0e4fcf9 | 2016-04-26 19:55:01 +0530 | [diff] [blame] | 12066 | case DRIVER_LINUX_WCN: |
Pradeep Reddy POTTETI | 88fd82c | 2016-03-14 12:20:18 +0530 | [diff] [blame] | 12067 | case DRIVER_WCN: |
| 12068 | return wcn_ap_set_rfeature(dut, conn, cmd); |
Mohammed Shafi Shajakhan | b53d8f9 | 2017-02-28 09:05:15 +0530 | [diff] [blame] | 12069 | case DRIVER_MAC80211: |
| 12070 | return mac80211_ap_set_rfeature(dut, conn, cmd); |
Alexei Avshalom Lazar | bc180dc | 2018-12-18 16:01:14 +0200 | [diff] [blame] | 12071 | #ifdef __linux__ |
| 12072 | case DRIVER_WIL6210: |
| 12073 | return wil6210_ap_set_rfeature(dut, conn, cmd); |
| 12074 | #endif /* __linux__ */ |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 12075 | default: |
| 12076 | send_resp(dut, conn, SIGMA_ERROR, |
| 12077 | "errorCode,Unsupported ap_set_rfeature with the current driver"); |
| 12078 | return 0; |
| 12079 | } |
| 12080 | } |
| 12081 | |
| 12082 | |
Jouni Malinen | f722271 | 2019-06-13 01:50:21 +0300 | [diff] [blame] | 12083 | static enum sigma_cmd_result cmd_accesspoint(struct sigma_dut *dut, |
| 12084 | struct sigma_conn *conn, |
| 12085 | struct sigma_cmd *cmd) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 12086 | { |
| 12087 | /* const char *name = get_param(cmd, "NAME"); */ |
| 12088 | return 1; |
| 12089 | } |
| 12090 | |
| 12091 | |
Jouni Malinen | f722271 | 2019-06-13 01:50:21 +0300 | [diff] [blame] | 12092 | static enum sigma_cmd_result |
| 12093 | cmd_ap_preset_testparameters(struct sigma_dut *dut, struct sigma_conn *conn, |
| 12094 | struct sigma_cmd *cmd) |
priyadharshini gowthaman | 9149afc | 2018-01-15 13:40:18 -0800 | [diff] [blame] | 12095 | { |
| 12096 | const char *val; |
| 12097 | |
| 12098 | val = get_param(cmd, "Oper_Chn"); |
| 12099 | if (val) { |
| 12100 | dut->ap_oper_chn = 1; |
| 12101 | dut->ap_channel = atoi(val); |
| 12102 | } |
| 12103 | |
Jouni Malinen | ba4f2d4 | 2019-10-04 16:13:41 +0300 | [diff] [blame] | 12104 | val = get_param(cmd, "DPPConfiguratorAddress"); |
| 12105 | if (val) { |
| 12106 | free(dut->ap_dpp_conf_addr); |
| 12107 | dut->ap_dpp_conf_addr = strdup(val); |
| 12108 | } |
| 12109 | |
| 12110 | val = get_param(cmd, "DPPConfiguratorPKHash"); |
| 12111 | if (val) { |
| 12112 | free(dut->ap_dpp_conf_pkhash); |
| 12113 | dut->ap_dpp_conf_pkhash = strdup(val); |
| 12114 | } |
| 12115 | |
priyadharshini gowthaman | 9149afc | 2018-01-15 13:40:18 -0800 | [diff] [blame] | 12116 | return 1; |
| 12117 | } |
| 12118 | |
| 12119 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 12120 | void ap_register_cmds(void) |
| 12121 | { |
| 12122 | sigma_dut_reg_cmd("ap_ca_version", NULL, cmd_ap_ca_version); |
| 12123 | sigma_dut_reg_cmd("ap_set_wireless", NULL, cmd_ap_set_wireless); |
| 12124 | sigma_dut_reg_cmd("ap_send_addba_req", NULL, cmd_ap_send_addba_req); |
| 12125 | sigma_dut_reg_cmd("ap_set_11n_wireless", NULL, cmd_ap_set_wireless); |
| 12126 | sigma_dut_reg_cmd("ap_set_11n", NULL, cmd_ap_set_wireless); |
| 12127 | sigma_dut_reg_cmd("ap_set_11d", NULL, cmd_ap_set_wireless); |
Pradeep Reddy POTTETI | fba27db | 2015-11-20 16:42:22 +0530 | [diff] [blame] | 12128 | sigma_dut_reg_cmd("ap_set_11h", NULL, cmd_ap_set_wireless); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 12129 | sigma_dut_reg_cmd("ap_set_security", NULL, cmd_ap_set_security); |
| 12130 | sigma_dut_reg_cmd("ap_set_apqos", NULL, cmd_ap_set_apqos); |
| 12131 | sigma_dut_reg_cmd("ap_set_staqos", NULL, cmd_ap_set_staqos); |
| 12132 | sigma_dut_reg_cmd("ap_set_radius", NULL, cmd_ap_set_radius); |
| 12133 | sigma_dut_reg_cmd("ap_reboot", NULL, cmd_ap_reboot); |
| 12134 | sigma_dut_reg_cmd("ap_config_commit", NULL, cmd_ap_config_commit); |
| 12135 | sigma_dut_reg_cmd("ap_reset_default", NULL, cmd_ap_reset_default); |
| 12136 | sigma_dut_reg_cmd("ap_get_info", NULL, cmd_ap_get_info); |
| 12137 | sigma_dut_reg_cmd("ap_deauth_sta", NULL, cmd_ap_deauth_sta); |
| 12138 | sigma_dut_reg_cmd("ap_send_frame", NULL, cmd_ap_send_frame); |
| 12139 | sigma_dut_reg_cmd("ap_get_mac_address", NULL, cmd_ap_get_mac_address); |
| 12140 | sigma_dut_reg_cmd("ap_set_pmf", NULL, cmd_ap_set_pmf); |
| 12141 | sigma_dut_reg_cmd("ap_set_hs2", NULL, cmd_ap_set_hs2); |
| 12142 | sigma_dut_reg_cmd("ap_set_rfeature", NULL, cmd_ap_set_rfeature); |
| 12143 | sigma_dut_reg_cmd("ap_nfc_action", NULL, cmd_ap_nfc_action); |
| 12144 | sigma_dut_reg_cmd("ap_wps_read_pin", NULL, cmd_ap_wps_read_pin); |
Alexei Avshalom Lazar | 6427969 | 2018-12-23 16:49:49 +0200 | [diff] [blame] | 12145 | sigma_dut_reg_cmd("ap_wps_enter_pin", NULL, cmd_ap_wps_enter_pin); |
| 12146 | sigma_dut_reg_cmd("ap_wps_set_pbc", NULL, cmd_ap_wps_set_pbc); |
Alexei Avshalom Lazar | 0c1d82d | 2018-12-23 17:02:42 +0200 | [diff] [blame] | 12147 | sigma_dut_reg_cmd("ap_get_parameter", NULL, cmd_ap_get_parameter); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 12148 | sigma_dut_reg_cmd("AccessPoint", NULL, cmd_accesspoint); |
priyadharshini gowthaman | 9149afc | 2018-01-15 13:40:18 -0800 | [diff] [blame] | 12149 | sigma_dut_reg_cmd("ap_preset_testparameters", NULL, |
| 12150 | cmd_ap_preset_testparameters); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 12151 | } |