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 | |
Tamizh chelvam | 638fb47 | 2019-08-15 14:00:31 +0530 | [diff] [blame] | 278 | static void mac80211_config_rts_force(struct sigma_dut *dut, const char *ifname, |
| 279 | const char *val) |
| 280 | { |
| 281 | char buf[60]; |
| 282 | char fname[128], path[128], *pos; |
| 283 | ssize_t res; |
| 284 | |
| 285 | res = snprintf(fname, sizeof(fname), "/sys/class/net/%s/phy80211", |
| 286 | ifname); |
| 287 | if (res < 0 || res >= sizeof(fname)) |
| 288 | return; |
| 289 | |
| 290 | res = readlink(fname, path, sizeof(path)); |
| 291 | if (res < 0) |
| 292 | return; |
| 293 | |
| 294 | if (res >= (int) sizeof(path)) |
| 295 | res = sizeof(path) - 1; |
| 296 | path[res] = '\0'; |
| 297 | |
| 298 | pos = strrchr(path, '/'); |
| 299 | if (!pos) |
| 300 | pos = path; |
| 301 | else |
| 302 | pos++; |
| 303 | |
| 304 | if (strcasecmp(val, "enable") == 0) { |
| 305 | dut->ap_sig_rts = VALUE_ENABLED; |
| 306 | snprintf(buf, sizeof(buf), "iw %s set rts 64", pos); |
| 307 | if (system(buf) != 0) { |
| 308 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 309 | "iw set rts 64 failed"); |
| 310 | } |
| 311 | } else if (strcasecmp(val, "disable") == 0) { |
| 312 | dut->ap_sig_rts = VALUE_DISABLED; |
| 313 | snprintf(buf, sizeof(buf), "iw %s set rts 2347", pos); |
| 314 | if (system(buf) != 0) { |
| 315 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 316 | "iw rts 2347 failed"); |
| 317 | } |
| 318 | } else { |
| 319 | sigma_dut_print(dut, DUT_MSG_ERROR, "Unsupported RTS_FORCE"); |
| 320 | } |
| 321 | |
| 322 | } |
| 323 | |
| 324 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 325 | static void ath_config_rts_force(struct sigma_dut *dut, const char *ifname, |
| 326 | const char *val) |
| 327 | { |
| 328 | char buf[60]; |
| 329 | |
| 330 | if (strcasecmp(val, "enable") == 0) { |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 331 | dut->ap_sig_rts = VALUE_ENABLED; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 332 | snprintf(buf, sizeof(buf), "iwconfig %s rts 64", ifname); |
| 333 | if (system(buf) != 0) { |
| 334 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 335 | "iwconfig rts 64 failed"); |
| 336 | } |
priyadharshini gowthaman | 270870e | 2015-12-09 10:10:23 -0800 | [diff] [blame] | 337 | snprintf(buf, sizeof(buf), "wifitool %s beeliner_fw_test 100 1", |
| 338 | ifname); |
| 339 | if (system(buf) != 0) { |
| 340 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 341 | "wifitool beeliner_fw_test 100 1 failed"); |
| 342 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 343 | } else if (strcasecmp(val, "disable") == 0) { |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 344 | dut->ap_sig_rts = VALUE_DISABLED; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 345 | snprintf(buf, sizeof(buf), "iwconfig %s rts 2347", ifname); |
| 346 | if (system(buf) != 0) { |
| 347 | sigma_dut_print(dut, DUT_MSG_ERROR, |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 348 | "iwconfig rts 2347 failed"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 349 | } |
| 350 | } else { |
| 351 | sigma_dut_print(dut, DUT_MSG_ERROR, "Unsupported RTS_FORCE"); |
| 352 | } |
| 353 | } |
| 354 | |
| 355 | |
priyadharshini gowthaman | 09d613e | 2017-12-20 11:43:44 -0800 | [diff] [blame] | 356 | static void ath_radio(struct sigma_dut *dut, const char *val) |
| 357 | { |
| 358 | if (strcasecmp(val, "on") == 0) { |
| 359 | if (dut->ap_interface_5g == 1) { |
| 360 | run_system(dut, "uci set wireless.wifi0.disabled=0"); |
| 361 | } else if (dut->ap_interface_2g == 1) { |
| 362 | run_system(dut, "uci set wireless.wifi1.disabled=0"); |
| 363 | } else { |
| 364 | run_system(dut, "uci set wireless.wifi0.disabled=0"); |
| 365 | run_system(dut, "uci set wireless.wifi1.disabled=0"); |
| 366 | } |
| 367 | run_system(dut, "uci commit"); |
| 368 | run_system(dut, "wifi down"); |
| 369 | run_system(dut, "wifi up"); |
| 370 | } else if (strcasecmp(val, "off") == 0) { |
| 371 | if (dut->ap_interface_5g == 1) { |
| 372 | run_system(dut, "uci set wireless.wifi0.disabled=1"); |
| 373 | } else if (dut->ap_interface_2g == 1) { |
| 374 | run_system(dut, "uci set wireless.wifi1.disabled=1"); |
| 375 | } else { |
| 376 | run_system(dut, "uci set wireless.wifi0.disabled=1"); |
| 377 | run_system(dut, "uci set wireless.wifi1.disabled=1"); |
| 378 | } |
| 379 | run_system(dut, "uci commit"); |
| 380 | run_system(dut, "wifi down"); |
| 381 | run_system(dut, "wifi up"); |
| 382 | } |
| 383 | } |
| 384 | |
| 385 | |
priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 386 | static void deauth_disassoc(struct sigma_dut *dut, const char *ifname, |
| 387 | const char *val) |
| 388 | { |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 389 | if (strcasecmp(val, "disable") == 0) |
| 390 | run_iwpriv(dut, ifname, "stealthdown 1"); |
priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 391 | } |
| 392 | |
| 393 | |
priyadharshini gowthaman | cb22e43 | 2017-12-28 15:23:31 -0800 | [diff] [blame] | 394 | static void ath_set_txpower(struct sigma_dut *dut, const char *ifname, |
| 395 | const char *val) |
| 396 | { |
| 397 | char buf[60]; |
| 398 | |
| 399 | if (strcasecmp(val, "high") == 0) |
| 400 | snprintf(buf, sizeof(buf), "iwconfig %s txpower 29", ifname); |
| 401 | else if (strcasecmp(val, "low") == 0) |
| 402 | snprintf(buf, sizeof(buf), "iwconfig %s txpower 1", ifname); |
| 403 | else |
| 404 | sigma_dut_print(dut, DUT_MSG_ERROR, "Unsupported txpower"); |
| 405 | |
| 406 | if (system(buf) != 0) |
| 407 | sigma_dut_print(dut, DUT_MSG_ERROR, "setting txpower failed"); |
| 408 | } |
| 409 | |
| 410 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 411 | static enum ap_mode get_mode(const char *str) |
| 412 | { |
| 413 | if (strcasecmp(str, "11a") == 0) |
| 414 | return AP_11a; |
| 415 | else if (strcasecmp(str, "11g") == 0) |
| 416 | return AP_11g; |
| 417 | else if (strcasecmp(str, "11b") == 0) |
| 418 | return AP_11b; |
| 419 | else if (strcasecmp(str, "11na") == 0) |
| 420 | return AP_11na; |
| 421 | else if (strcasecmp(str, "11ng") == 0) |
| 422 | return AP_11ng; |
| 423 | else if (strcasecmp(str, "11ac") == 0 || strcasecmp(str, "ac") == 0) |
| 424 | return AP_11ac; |
Alexei Avshalom Lazar | 2712cc8 | 2018-12-23 16:29:14 +0200 | [diff] [blame] | 425 | else if (strcasecmp(str, "11ad") == 0) |
| 426 | return AP_11ad; |
Priyadharshini Gowthaman | 4401cee | 2019-11-21 14:38:33 -0800 | [diff] [blame] | 427 | else if (strcasecmp(str, "11ax") == 0) |
| 428 | return AP_11ax; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 429 | else |
| 430 | return AP_inval; |
| 431 | } |
| 432 | |
| 433 | |
| 434 | static int run_hostapd_cli(struct sigma_dut *dut, char *buf) |
| 435 | { |
| 436 | char command[1000]; |
| 437 | const char *bin; |
Jouni Malinen | 016ae6c | 2019-11-04 17:00:01 +0200 | [diff] [blame] | 438 | enum driver_type drv = get_driver_type(dut); |
Adil Saeed Musthafa | 3dd6ca7 | 2017-05-15 12:45:18 -0700 | [diff] [blame] | 439 | char *sigma_hapd_file = sigma_hapd_ctrl; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 440 | |
| 441 | if (file_exists("hostapd_cli")) |
| 442 | bin = "./hostapd_cli"; |
Jouni Malinen | d6bf1b4 | 2017-06-23 17:51:01 +0300 | [diff] [blame] | 443 | else if (file_exists("../../hostapd/hostapd_cli")) |
| 444 | bin = "../../hostapd/hostapd_cli"; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 445 | else |
| 446 | bin = "hostapd_cli"; |
| 447 | |
| 448 | if (drv == DRIVER_OPENWRT && sigma_hapd_ctrl == NULL) { |
Adil Saeed Musthafa | 3dd6ca7 | 2017-05-15 12:45:18 -0700 | [diff] [blame] | 449 | sigma_hapd_file = "/var/run/hostapd-wifi0"; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 450 | |
| 451 | if (sigma_radio_ifname[0] && |
| 452 | strcmp(sigma_radio_ifname[0], "wifi1") == 0) |
Adil Saeed Musthafa | 3dd6ca7 | 2017-05-15 12:45:18 -0700 | [diff] [blame] | 453 | sigma_hapd_file = "/var/run/hostapd-wifi1"; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 454 | else if (sigma_radio_ifname[0] && |
| 455 | strcmp(sigma_radio_ifname[0], "wifi2") == 0) |
Adil Saeed Musthafa | 3dd6ca7 | 2017-05-15 12:45:18 -0700 | [diff] [blame] | 456 | sigma_hapd_file = "/var/run/hostapd-wifi2"; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 457 | } |
| 458 | |
Adil Saeed Musthafa | 3dd6ca7 | 2017-05-15 12:45:18 -0700 | [diff] [blame] | 459 | if (sigma_hapd_file) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 460 | snprintf(command, sizeof(command), "%s -p %s %s", |
Adil Saeed Musthafa | 3dd6ca7 | 2017-05-15 12:45:18 -0700 | [diff] [blame] | 461 | bin, sigma_hapd_file, buf); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 462 | else |
| 463 | snprintf(command, sizeof(command), "%s %s", bin, buf); |
| 464 | return run_system(dut, command); |
| 465 | } |
| 466 | |
| 467 | |
priyadharshini gowthaman | 8e26ff4 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 468 | static int ath_set_lci_config(struct sigma_dut *dut, const char *val, |
| 469 | struct sigma_cmd *cmd) |
| 470 | { |
| 471 | FILE *f; |
| 472 | int i; |
| 473 | |
| 474 | f = fopen("/tmp/lci_cfg.txt", "w"); |
| 475 | if (!f) { |
| 476 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 477 | "Failed to open /tmp/lci_cfg.txt"); |
| 478 | return -1; |
| 479 | } |
| 480 | |
| 481 | for (i = 2; i < cmd->count; i++) |
| 482 | fprintf(f, "%s = %s \n", cmd->params[i], cmd->values[i]); |
| 483 | fprintf(f, "\n"); |
| 484 | fclose(f); |
| 485 | |
| 486 | return 0; |
| 487 | } |
| 488 | |
| 489 | |
hangtian | 0060662 | 2019-04-19 11:15:48 +0800 | [diff] [blame] | 490 | static void set_ap_country_code(struct sigma_dut *dut) |
| 491 | { |
| 492 | #if defined(ANDROID) || defined(LINUX_EMBEDDED) |
| 493 | char buf[256]; |
| 494 | |
| 495 | if (dut->ap_countrycode[0]) { |
| 496 | snprintf(buf, sizeof(buf), "DRIVER COUNTRY %s", |
| 497 | dut->ap_countrycode); |
Jouni Malinen | 016ae6c | 2019-11-04 17:00:01 +0200 | [diff] [blame] | 498 | if (wpa_command(get_station_ifname(dut), buf) < 0) |
hangtian | 0060662 | 2019-04-19 11:15:48 +0800 | [diff] [blame] | 499 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 500 | "Failed to set country code"); |
| 501 | else |
| 502 | sigma_dut_print(dut, DUT_MSG_INFO, |
| 503 | "Successfully set country code to %s", |
| 504 | dut->ap_countrycode); |
| 505 | } |
| 506 | #endif |
| 507 | } |
| 508 | |
| 509 | |
Priyadharshini Gowthaman | e661f3b | 2019-11-13 16:24:29 -0800 | [diff] [blame] | 510 | static void set_vht_mcsmap_nss(struct sigma_dut *dut, int nss, int mcs) |
| 511 | { |
| 512 | switch (nss) { |
| 513 | case 1: |
| 514 | switch (mcs) { |
| 515 | case 7: |
| 516 | dut->ap_vhtmcs_map = 0xfffc; |
| 517 | break; |
| 518 | case 8: |
| 519 | dut->ap_vhtmcs_map = 0xfffd; |
| 520 | break; |
| 521 | case 9: |
| 522 | dut->ap_vhtmcs_map = 0xfffe; |
| 523 | break; |
| 524 | default: |
| 525 | dut->ap_vhtmcs_map = 0xfffe; |
| 526 | break; |
| 527 | } |
| 528 | break; |
| 529 | case 2: |
| 530 | switch (mcs) { |
| 531 | case 7: |
| 532 | dut->ap_vhtmcs_map = 0xfff0; |
| 533 | break; |
| 534 | case 8: |
| 535 | dut->ap_vhtmcs_map = 0xfff5; |
| 536 | break; |
| 537 | case 9: |
| 538 | dut->ap_vhtmcs_map = 0xfffa; |
| 539 | break; |
| 540 | default: |
| 541 | dut->ap_vhtmcs_map = 0xfffa; |
| 542 | break; |
| 543 | } |
| 544 | break; |
| 545 | case 3: |
| 546 | switch (mcs) { |
| 547 | case 7: |
| 548 | dut->ap_vhtmcs_map = 0xffc0; |
| 549 | break; |
| 550 | case 8: |
| 551 | dut->ap_vhtmcs_map = 0xffd5; |
| 552 | break; |
| 553 | case 9: |
| 554 | dut->ap_vhtmcs_map = 0xffea; |
| 555 | break; |
| 556 | default: |
| 557 | dut->ap_vhtmcs_map = 0xffea; |
| 558 | break; |
| 559 | } |
| 560 | default: |
| 561 | dut->ap_vhtmcs_map = 0xffea; |
| 562 | break; |
| 563 | } |
| 564 | } |
| 565 | |
| 566 | |
Priyadharshini Gowthaman | 78ee2ef | 2019-11-15 16:08:28 -0800 | [diff] [blame] | 567 | /* Get 2*nss bitmask */ |
| 568 | /* We are trying to pack 2-bit MCS values per NSS in a 16-bit wide field. |
| 569 | * IEEE P802.11ax/D5.0, 9.4.2.247.4 supported HE-MCS And NSS Set field |
| 570 | * defines the following format for the 16 bit value. */ |
| 571 | |
| 572 | #define HE_GET_MCS_NSS_PACK_MASK(nss) ((1 << ((nss) << 1)) - 1) |
| 573 | |
| 574 | static void he_reset_mcs_values_for_unsupported_ss(uint8_t *mcsnssmap, |
| 575 | uint8_t nss) |
| 576 | { |
| 577 | uint8_t nssmask; |
| 578 | |
| 579 | if (nss <= 4) { |
| 580 | nssmask = ~HE_GET_MCS_NSS_PACK_MASK(nss); |
| 581 | mcsnssmap[0] |= nssmask; |
| 582 | mcsnssmap[1] = 0xff; |
| 583 | } else if (nss > 4 && nss <= 8) { |
| 584 | nssmask = ~HE_GET_MCS_NSS_PACK_MASK(nss - 4); |
| 585 | mcsnssmap[0] &= 0xff; |
| 586 | mcsnssmap[1] |= nssmask; |
| 587 | } |
| 588 | } |
| 589 | |
| 590 | |
| 591 | static void get_he_mcs_nssmap(uint8_t *mcsnssmap, uint8_t nss, |
| 592 | uint8_t mcs) |
| 593 | { |
| 594 | switch (mcs) { |
| 595 | case 11: |
| 596 | mcsnssmap[0] = 0xaa; |
| 597 | mcsnssmap[1] = 0xaa; |
| 598 | break; |
| 599 | case 9: |
| 600 | mcsnssmap[0] = 0x55; |
| 601 | mcsnssmap[1] = 0x55; |
| 602 | break; |
| 603 | case 7: |
| 604 | mcsnssmap[0] = 0x0; |
| 605 | mcsnssmap[1] = 0x0; |
| 606 | break; |
| 607 | } |
| 608 | he_reset_mcs_values_for_unsupported_ss(mcsnssmap, nss); |
| 609 | } |
| 610 | |
| 611 | |
Jouni Malinen | f722271 | 2019-06-13 01:50:21 +0300 | [diff] [blame] | 612 | static enum sigma_cmd_result cmd_ap_set_wireless(struct sigma_dut *dut, |
| 613 | struct sigma_conn *conn, |
| 614 | struct sigma_cmd *cmd) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 615 | { |
| 616 | /* const char *name = get_param(cmd, "NAME"); */ |
| 617 | /* const char *ifname = get_param(cmd, "INTERFACE"); */ |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 618 | const char *val; |
| 619 | unsigned int wlan_tag = 1; |
Jouni Malinen | 016ae6c | 2019-11-04 17:00:01 +0200 | [diff] [blame] | 620 | const char *ifname = get_main_ifname(dut); |
Alexei Avshalom Lazar | 79f5727 | 2018-12-23 17:22:47 +0200 | [diff] [blame] | 621 | char buf[128]; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 622 | |
Alexei Avshalom Lazar | 2712cc8 | 2018-12-23 16:29:14 +0200 | [diff] [blame] | 623 | /* Allow program to be overridden if specified in the ap_set_wireless |
| 624 | * to support some 60 GHz test scripts where the program may be 60 GHz |
| 625 | * or WPS. */ |
| 626 | val = get_param(cmd, "PROGRAM"); |
| 627 | if (val) |
| 628 | dut->program = sigma_program_to_enum(val); |
| 629 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 630 | val = get_param(cmd, "WLAN_TAG"); |
| 631 | if (val) { |
| 632 | wlan_tag = atoi(val); |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 633 | if (wlan_tag < 1 || wlan_tag > 3) { |
| 634 | /* |
| 635 | * The only valid WLAN Tags as of now as per the latest |
| 636 | * WFA scripts are 1, 2, and 3. |
| 637 | */ |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 638 | send_resp(dut, conn, SIGMA_INVALID, |
| 639 | "errorCode,Invalid WLAN_TAG"); |
Jouni Malinen | dccfd0c | 2019-10-30 12:05:59 +0200 | [diff] [blame] | 640 | return STATUS_SENT; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 641 | } |
| 642 | } |
| 643 | |
priyadharshini gowthaman | 09d613e | 2017-12-20 11:43:44 -0800 | [diff] [blame] | 644 | val = get_param(cmd, "Interface"); |
| 645 | if (val) { |
| 646 | if (strcasecmp(val, "5G") == 0) |
| 647 | dut->ap_interface_5g = 1; |
| 648 | else |
| 649 | dut->ap_interface_2g = 1; |
| 650 | |
| 651 | if (dut->ap_interface_5g && dut->ap_interface_2g) |
| 652 | dut->ap_is_dual = 1; |
| 653 | } |
| 654 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 655 | val = get_param(cmd, "CountryCode"); |
| 656 | if (val) { |
| 657 | if (strlen(val) > sizeof(dut->ap_countrycode) - 1) |
Jouni Malinen | dccfd0c | 2019-10-30 12:05:59 +0200 | [diff] [blame] | 658 | return INVALID_SEND_STATUS; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 659 | snprintf(dut->ap_countrycode, sizeof(dut->ap_countrycode), |
| 660 | "%s", val); |
hangtian | 0060662 | 2019-04-19 11:15:48 +0800 | [diff] [blame] | 661 | |
| 662 | /* |
| 663 | * Regdomain self-managed driver does not accept hostapd country |
| 664 | * code setting in all cases. Try to use wpa_supplicant DRIVER |
| 665 | * command first to set the driver to a specific country code |
| 666 | * before starting AP functionality. This is targeting cases |
| 667 | * where wpa_supplicant is running on the device as well for |
| 668 | * non-AP mode functionality. |
| 669 | */ |
Jouni Malinen | 016ae6c | 2019-11-04 17:00:01 +0200 | [diff] [blame] | 670 | if (get_driver_type(dut) == DRIVER_LINUX_WCN) |
hangtian | 0060662 | 2019-04-19 11:15:48 +0800 | [diff] [blame] | 671 | set_ap_country_code(dut); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 672 | } |
| 673 | |
Pradeep Reddy POTTETI | fba27db | 2015-11-20 16:42:22 +0530 | [diff] [blame] | 674 | val = get_param(cmd, "regulatory_mode"); |
| 675 | if (val) { |
| 676 | if (strcasecmp(val, "11d") == 0 || strcasecmp(val, "11h") == 0) |
| 677 | dut->ap_regulatory_mode = AP_80211D_MODE_ENABLED; |
| 678 | } |
| 679 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 680 | val = get_param(cmd, "SSID"); |
| 681 | if (val) { |
| 682 | if (strlen(val) > sizeof(dut->ap_ssid) - 1) |
Jouni Malinen | dccfd0c | 2019-10-30 12:05:59 +0200 | [diff] [blame] | 683 | return INVALID_SEND_STATUS; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 684 | |
| 685 | if (wlan_tag == 1) { |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 686 | /* |
| 687 | * If tag is not specified, it is deemed to be 1. |
| 688 | * Hence tag of 1 is a special case and the values |
| 689 | * corresponding to wlan-tag=1 are stored separately |
| 690 | * from the values corresponding tags 2 and 3. |
| 691 | * This approach minimises the changes to existing code |
| 692 | * since most of the sigma_dut code does not deal with |
| 693 | * WLAN-TAG CAPI variable. |
| 694 | */ |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 695 | snprintf(dut->ap_ssid, |
| 696 | sizeof(dut->ap_ssid), "%s", val); |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 697 | } else { |
| 698 | snprintf(dut->ap_tag_ssid[wlan_tag - 2], |
| 699 | sizeof(dut->ap_tag_ssid[wlan_tag - 2]), |
| 700 | "%s", val); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 701 | } |
| 702 | } |
| 703 | |
| 704 | val = get_param(cmd, "CHANNEL"); |
| 705 | if (val) { |
| 706 | const char *pos; |
| 707 | dut->ap_channel = atoi(val); |
| 708 | pos = strchr(val, ';'); |
| 709 | if (pos) { |
| 710 | pos++; |
| 711 | dut->ap_channel_1 = atoi(pos); |
| 712 | } |
| 713 | } |
| 714 | |
Pradeep Reddy POTTETI | fba27db | 2015-11-20 16:42:22 +0530 | [diff] [blame] | 715 | /* Overwrite the AP channel with DFS channel if configured */ |
| 716 | val = get_param(cmd, "dfs_chan"); |
| 717 | if (val) { |
| 718 | dut->ap_channel = atoi(val); |
| 719 | } |
| 720 | |
| 721 | val = get_param(cmd, "dfs_mode"); |
| 722 | if (val) { |
| 723 | if (strcasecmp(val, "Enable") == 0) |
| 724 | dut->ap_dfs_mode = AP_DFS_MODE_ENABLED; |
| 725 | else if (strcasecmp(val, "Disable") == 0) |
| 726 | dut->ap_dfs_mode = AP_DFS_MODE_DISABLED; |
| 727 | else |
| 728 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 729 | "Unsupported dfs_mode value: %s", val); |
| 730 | } |
| 731 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 732 | val = get_param(cmd, "MODE"); |
| 733 | if (val) { |
| 734 | char *str, *pos; |
| 735 | |
| 736 | str = strdup(val); |
| 737 | if (str == NULL) |
Jouni Malinen | dccfd0c | 2019-10-30 12:05:59 +0200 | [diff] [blame] | 738 | return INVALID_SEND_STATUS; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 739 | pos = strchr(str, ';'); |
| 740 | if (pos) |
| 741 | *pos++ = '\0'; |
| 742 | |
| 743 | dut->ap_is_dual = 0; |
| 744 | dut->ap_mode = get_mode(str); |
| 745 | if (dut->ap_mode == AP_inval) { |
| 746 | send_resp(dut, conn, SIGMA_INVALID, |
| 747 | "errorCode,Unsupported MODE"); |
| 748 | free(str); |
Jouni Malinen | dccfd0c | 2019-10-30 12:05:59 +0200 | [diff] [blame] | 749 | return STATUS_SENT; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 750 | } |
priyadharshini gowthaman | 63ab848 | 2017-12-28 15:32:55 -0800 | [diff] [blame] | 751 | if (dut->ap_mode == AP_11ac && dut->ap_80plus80 != 1) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 752 | dut->ap_chwidth = AP_80; |
| 753 | |
| 754 | if (pos) { |
| 755 | dut->ap_mode_1 = get_mode(pos); |
| 756 | if (dut->ap_mode_1 == AP_inval) { |
| 757 | send_resp(dut, conn, SIGMA_INVALID, |
| 758 | "errorCode,Unsupported MODE"); |
| 759 | free(str); |
Jouni Malinen | dccfd0c | 2019-10-30 12:05:59 +0200 | [diff] [blame] | 760 | return STATUS_SENT; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 761 | } |
| 762 | if (dut->ap_mode_1 == AP_11ac) |
| 763 | dut->ap_chwidth_1 = AP_80; |
| 764 | dut->ap_is_dual = 1; |
| 765 | } |
| 766 | |
| 767 | free(str); |
| 768 | } else if (dut->ap_mode == AP_inval) { |
| 769 | if (dut->ap_channel <= 11) |
| 770 | dut->ap_mode = AP_11ng; |
| 771 | else if (dut->program == PROGRAM_VHT) |
| 772 | dut->ap_mode = AP_11ac; |
| 773 | else |
| 774 | dut->ap_mode = AP_11na; |
| 775 | } |
| 776 | |
Alexei Avshalom Lazar | 2712cc8 | 2018-12-23 16:29:14 +0200 | [diff] [blame] | 777 | /* Override the AP mode in case of 60 GHz */ |
| 778 | if (dut->program == PROGRAM_60GHZ) { |
| 779 | dut->ap_mode = AP_11ad; |
| 780 | /* Workaround to force channel 2 if not specified */ |
| 781 | if (!dut->ap_channel) |
| 782 | dut->ap_channel = 2; |
| 783 | } |
| 784 | |
Jouni Malinen | 0053547 | 2019-11-06 19:43:35 +0200 | [diff] [blame] | 785 | switch (dut->ap_mode) { |
| 786 | case AP_11g: |
| 787 | case AP_11b: |
| 788 | case AP_11ng: |
| 789 | dut->use_5g = 0; |
| 790 | break; |
| 791 | case AP_11a: |
| 792 | case AP_11na: |
| 793 | case AP_11ac: |
| 794 | dut->use_5g = 1; |
| 795 | break; |
Priyadharshini Gowthaman | 4401cee | 2019-11-21 14:38:33 -0800 | [diff] [blame] | 796 | case AP_11ax: |
| 797 | if (dut->ap_channel >= 1 && dut->ap_channel <= 14) |
| 798 | dut->use_5g = 0; |
| 799 | else if (dut->ap_channel >= 36 && dut->ap_channel <= 171) |
| 800 | dut->use_5g = 1; |
| 801 | break; |
Jouni Malinen | 0053547 | 2019-11-06 19:43:35 +0200 | [diff] [blame] | 802 | case AP_11ad: |
| 803 | case AP_inval: |
| 804 | break; |
| 805 | } |
| 806 | |
Pradeep Reddy POTTETI | 0d3db63 | 2016-03-11 15:21:11 +0530 | [diff] [blame] | 807 | val = get_param(cmd, "WME"); |
| 808 | if (val) { |
| 809 | if (strcasecmp(val, "on") == 0) |
| 810 | dut->ap_wme = AP_WME_ON; |
| 811 | else if (strcasecmp(val, "off") == 0) |
| 812 | dut->ap_wme = AP_WME_OFF; |
| 813 | else |
| 814 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 815 | "Unsupported WME value: %s", val); |
| 816 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 817 | |
Mohammed Shafi Shajakhan | 02e3b82 | 2017-02-23 04:15:02 +0530 | [diff] [blame] | 818 | val = get_param(cmd, "WMMPS"); |
| 819 | if (val) { |
| 820 | if (strcasecmp(val, "on") == 0) |
| 821 | dut->ap_wmmps = AP_WMMPS_ON; |
| 822 | else if (strcasecmp(val, "off") == 0) |
| 823 | dut->ap_wmmps = AP_WMMPS_OFF; |
| 824 | else |
| 825 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 826 | "Unsupported WMMPS value: %s", val); |
| 827 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 828 | |
| 829 | val = get_param(cmd, "RTS"); |
| 830 | if (val) |
| 831 | dut->ap_rts = atoi(val); |
| 832 | |
| 833 | val = get_param(cmd, "FRGMNT"); |
| 834 | if (val) |
| 835 | dut->ap_frgmnt = atoi(val); |
| 836 | |
| 837 | /* TODO: PWRSAVE */ |
| 838 | |
| 839 | val = get_param(cmd, "BCNINT"); |
| 840 | if (val) |
| 841 | dut->ap_bcnint = atoi(val); |
| 842 | |
| 843 | val = get_param(cmd, "RADIO"); |
| 844 | if (val) { |
Jouni Malinen | 016ae6c | 2019-11-04 17:00:01 +0200 | [diff] [blame] | 845 | enum driver_type drv = get_driver_type(dut); |
Mohammed Shafi Shajakhan | 94997f9 | 2017-01-09 21:31:09 +0530 | [diff] [blame] | 846 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 847 | if (strcasecmp(val, "on") == 0) { |
priyadharshini gowthaman | 09d613e | 2017-12-20 11:43:44 -0800 | [diff] [blame] | 848 | if (drv == DRIVER_OPENWRT) |
| 849 | ath_radio(dut, val); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 850 | if (drv == DRIVER_ATHEROS) |
| 851 | ath_ap_start_hostapd(dut); |
| 852 | else if (cmd_ap_config_commit(dut, conn, cmd) <= 0) |
Jouni Malinen | dccfd0c | 2019-10-30 12:05:59 +0200 | [diff] [blame] | 853 | return STATUS_SENT; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 854 | } else if (strcasecmp(val, "off") == 0) { |
Mohammed Shafi Shajakhan | 94997f9 | 2017-01-09 21:31:09 +0530 | [diff] [blame] | 855 | if (drv == DRIVER_OPENWRT) { |
priyadharshini gowthaman | 09d613e | 2017-12-20 11:43:44 -0800 | [diff] [blame] | 856 | ath_radio(dut, val); |
Jouni Malinen | d6bf1b4 | 2017-06-23 17:51:01 +0300 | [diff] [blame] | 857 | } else if (dut->use_hostapd_pid_file) { |
| 858 | kill_hostapd_process_pid(dut); |
Mohammed Shafi Shajakhan | 94997f9 | 2017-01-09 21:31:09 +0530 | [diff] [blame] | 859 | } else if (kill_process(dut, "(hostapd)", 1, |
| 860 | SIGTERM) == 0 || |
| 861 | system("killall hostapd") == 0) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 862 | sigma_dut_print(dut, DUT_MSG_INFO, |
| 863 | "Killed hostapd on radio,off"); |
| 864 | } |
| 865 | } else { |
| 866 | send_resp(dut, conn, SIGMA_INVALID, |
| 867 | "errorCode,Unsupported RADIO value"); |
Jouni Malinen | dccfd0c | 2019-10-30 12:05:59 +0200 | [diff] [blame] | 868 | return STATUS_SENT; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 869 | } |
| 870 | } |
| 871 | |
| 872 | val = get_param(cmd, "P2PMgmtBit"); |
| 873 | if (val) |
| 874 | dut->ap_p2p_mgmt = atoi(val); |
| 875 | |
| 876 | /* TODO: ChannelUsage */ |
| 877 | |
| 878 | /* TODO: 40_INTOLERANT */ |
| 879 | |
| 880 | val = get_param(cmd, "ADDBA_REJECT"); |
| 881 | if (val) { |
| 882 | if (strcasecmp(val, "Enable") == 0) |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 883 | dut->ap_addba_reject = VALUE_ENABLED; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 884 | else if (strcasecmp(val, "Disable") == 0) |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 885 | dut->ap_addba_reject = VALUE_DISABLED; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 886 | } |
| 887 | |
| 888 | val = get_param(cmd, "AMPDU"); |
| 889 | if (val) { |
| 890 | if (strcasecmp(val, "Enable") == 0) |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 891 | dut->ap_ampdu = VALUE_ENABLED; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 892 | else if (strcasecmp(val, "Disable") == 0) |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 893 | dut->ap_ampdu = VALUE_DISABLED; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 894 | } |
| 895 | |
| 896 | val = get_param(cmd, "AMPDU_EXP"); |
| 897 | if (val) |
| 898 | dut->ap_ampdu_exp = atoi(val); |
| 899 | |
| 900 | val = get_param(cmd, "AMSDU"); |
| 901 | if (val) { |
| 902 | if (strcasecmp(val, "Enable") == 0) |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 903 | dut->ap_amsdu = VALUE_ENABLED; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 904 | else if (strcasecmp(val, "Disable") == 0) |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 905 | dut->ap_amsdu = VALUE_DISABLED; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 906 | } |
| 907 | |
| 908 | val = get_param(cmd, "NoAck"); |
| 909 | if (val) { |
| 910 | if (strcasecmp(val, "on") == 0) |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 911 | dut->ap_noack = VALUE_ENABLED; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 912 | else if (strcasecmp(val, "off") == 0) |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 913 | dut->ap_noack = VALUE_DISABLED; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 914 | } |
| 915 | |
| 916 | /* TODO: GREENFIELD */ |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 917 | /* TODO: MCS_32 */ |
| 918 | |
Pradeep Reddy Potteti | 4b0cdee | 2017-03-15 12:37:33 +0530 | [diff] [blame] | 919 | val = get_param(cmd, "OFFSET"); |
| 920 | if (val) { |
| 921 | if (strcasecmp(val, "Above") == 0) |
| 922 | dut->ap_chwidth_offset = SEC_CH_40ABOVE; |
| 923 | else if (strcasecmp(val, "Below") == 0) |
| 924 | dut->ap_chwidth_offset = SEC_CH_40BELOW; |
| 925 | } |
| 926 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 927 | val = get_param(cmd, "MCS_FIXEDRATE"); |
| 928 | if (val) { |
| 929 | dut->ap_fixed_rate = 1; |
| 930 | dut->ap_mcs = atoi(val); |
| 931 | } |
| 932 | |
| 933 | val = get_param(cmd, "SPATIAL_RX_STREAM"); |
| 934 | if (val) { |
| 935 | if (strcasecmp(val, "1SS") == 0 || strcasecmp(val, "1") == 0) { |
| 936 | dut->ap_rx_streams = 1; |
| 937 | if (dut->device_type == AP_testbed) |
| 938 | dut->ap_vhtmcs_map = 0xfffc; |
| 939 | } else if (strcasecmp(val, "2SS") == 0 || |
| 940 | strcasecmp(val, "2") == 0) { |
| 941 | dut->ap_rx_streams = 2; |
| 942 | if (dut->device_type == AP_testbed) |
| 943 | dut->ap_vhtmcs_map = 0xfff0; |
| 944 | } else if (strcasecmp(val, "3SS") == 0 || |
| 945 | strcasecmp(val, "3") == 0) { |
| 946 | dut->ap_rx_streams = 3; |
| 947 | if (dut->device_type == AP_testbed) |
| 948 | dut->ap_vhtmcs_map = 0xffc0; |
| 949 | } else if (strcasecmp(val, "4SS") == 0 || |
| 950 | strcasecmp(val, "4") == 0) { |
| 951 | dut->ap_rx_streams = 4; |
| 952 | } |
| 953 | } |
| 954 | |
| 955 | val = get_param(cmd, "SPATIAL_TX_STREAM"); |
| 956 | if (val) { |
| 957 | if (strcasecmp(val, "1SS") == 0 || |
| 958 | strcasecmp(val, "1") == 0) { |
| 959 | dut->ap_tx_streams = 1; |
| 960 | if (dut->device_type == AP_testbed) |
| 961 | dut->ap_vhtmcs_map = 0xfffc; |
| 962 | } else if (strcasecmp(val, "2SS") == 0 || |
| 963 | strcasecmp(val, "2") == 0) { |
| 964 | dut->ap_tx_streams = 2; |
| 965 | if (dut->device_type == AP_testbed) |
| 966 | dut->ap_vhtmcs_map = 0xfff0; |
| 967 | } else if (strcasecmp(val, "3SS") == 0 || |
| 968 | strcasecmp(val, "3") == 0) { |
| 969 | dut->ap_tx_streams = 3; |
| 970 | if (dut->device_type == AP_testbed) |
| 971 | dut->ap_vhtmcs_map = 0xffc0; |
| 972 | } else if (strcasecmp(val, "4SS") == 0 || |
| 973 | strcasecmp(val, "4") == 0) { |
| 974 | dut->ap_tx_streams = 4; |
| 975 | } |
| 976 | } |
| 977 | |
Adil Saeed Musthafa | 33ea287 | 2017-04-10 23:13:24 -0700 | [diff] [blame] | 978 | val = get_param(cmd, "BSS_max_idle"); |
| 979 | if (val) { |
| 980 | if (strncasecmp(val, "Enable", 7) == 0) { |
| 981 | dut->wnm_bss_max_feature = VALUE_ENABLED; |
| 982 | } else if (strncasecmp(val, "Disable", 8) == 0) { |
| 983 | dut->wnm_bss_max_feature = VALUE_DISABLED; |
| 984 | } else { |
| 985 | send_resp(dut, conn, SIGMA_ERROR, |
| 986 | "errorCode,Invalid value for BSS_max_Feature"); |
Jouni Malinen | dccfd0c | 2019-10-30 12:05:59 +0200 | [diff] [blame] | 987 | return STATUS_SENT; |
Adil Saeed Musthafa | 33ea287 | 2017-04-10 23:13:24 -0700 | [diff] [blame] | 988 | } |
| 989 | } |
| 990 | |
| 991 | val = get_param(cmd, "BSS_Idle_Protection_options"); |
| 992 | if (val) { |
| 993 | int protection = (int) strtol(val, (char **) NULL, 10); |
| 994 | |
| 995 | if (protection != 1 && protection != 0) { |
| 996 | send_resp(dut, conn, SIGMA_ERROR, |
| 997 | "errorCode,Invalid value for BSS_Idle_Protection_options"); |
Jouni Malinen | dccfd0c | 2019-10-30 12:05:59 +0200 | [diff] [blame] | 998 | return STATUS_SENT; |
Adil Saeed Musthafa | 33ea287 | 2017-04-10 23:13:24 -0700 | [diff] [blame] | 999 | } |
| 1000 | dut->wnm_bss_max_protection = protection ? |
| 1001 | VALUE_ENABLED : VALUE_DISABLED; |
| 1002 | } |
| 1003 | |
| 1004 | val = get_param(cmd, "BSS_max_Idle_period"); |
| 1005 | if (val) { |
Jouni Malinen | 544edf0 | 2019-02-25 19:02:33 +0200 | [diff] [blame] | 1006 | long int idle_time = strtol(val, (char **) NULL, 10); |
Adil Saeed Musthafa | 33ea287 | 2017-04-10 23:13:24 -0700 | [diff] [blame] | 1007 | |
| 1008 | if (idle_time == LONG_MIN || idle_time == LONG_MAX) { |
| 1009 | send_resp(dut, conn, SIGMA_ERROR, |
| 1010 | "errorCode,Invalid value for BSS_max_Idle_period"); |
Jouni Malinen | dccfd0c | 2019-10-30 12:05:59 +0200 | [diff] [blame] | 1011 | return STATUS_SENT; |
Adil Saeed Musthafa | 33ea287 | 2017-04-10 23:13:24 -0700 | [diff] [blame] | 1012 | } |
Jouni Malinen | 544edf0 | 2019-02-25 19:02:33 +0200 | [diff] [blame] | 1013 | dut->wnm_bss_max_idle_time = (int) idle_time; |
Adil Saeed Musthafa | 33ea287 | 2017-04-10 23:13:24 -0700 | [diff] [blame] | 1014 | } |
| 1015 | |
| 1016 | val = get_param(cmd, "PROXY_ARP"); |
| 1017 | if (val) |
| 1018 | dut->ap_proxy_arp = (int) strtol(val, (char **) NULL, 10); |
| 1019 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1020 | val = get_param(cmd, "nss_mcs_cap"); |
| 1021 | if (val) { |
| 1022 | int nss, mcs; |
| 1023 | char token[20]; |
| 1024 | char *result = NULL; |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 1025 | char *saveptr; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1026 | |
| 1027 | if (strlen(val) >= sizeof(token)) |
Jouni Malinen | dccfd0c | 2019-10-30 12:05:59 +0200 | [diff] [blame] | 1028 | return INVALID_SEND_STATUS; |
Jouni Malinen | 947fdf6 | 2017-05-14 22:29:32 +0300 | [diff] [blame] | 1029 | strlcpy(token, val, sizeof(token)); |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 1030 | result = strtok_r(token, ";", &saveptr); |
Pradeep Reddy POTTETI | 41b8c54 | 2016-06-15 16:09:46 +0530 | [diff] [blame] | 1031 | if (!result) { |
Jouni Malinen | 9aa4b37 | 2019-10-30 12:08:15 +0200 | [diff] [blame] | 1032 | send_resp(dut, conn, SIGMA_ERROR, |
| 1033 | "errorCode,VHT NSS not specified"); |
| 1034 | return STATUS_SENT; |
Pradeep Reddy POTTETI | 41b8c54 | 2016-06-15 16:09:46 +0530 | [diff] [blame] | 1035 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1036 | nss = atoi(result); |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 1037 | result = strtok_r(NULL, ";", &saveptr); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1038 | if (result == NULL) { |
Jouni Malinen | 9aa4b37 | 2019-10-30 12:08:15 +0200 | [diff] [blame] | 1039 | send_resp(dut, conn, SIGMA_ERROR, |
| 1040 | "errorCode,VHTMCS not specified"); |
| 1041 | return STATUS_SENT; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1042 | } |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 1043 | result = strtok_r(result, "-", &saveptr); |
| 1044 | result = strtok_r(NULL, "-", &saveptr); |
Pradeep Reddy POTTETI | 41b8c54 | 2016-06-15 16:09:46 +0530 | [diff] [blame] | 1045 | if (!result) { |
Jouni Malinen | 9aa4b37 | 2019-10-30 12:08:15 +0200 | [diff] [blame] | 1046 | send_resp(dut, conn, SIGMA_ERROR, |
| 1047 | "errorCode,VHT MCS not specified"); |
| 1048 | return STATUS_SENT; |
Pradeep Reddy POTTETI | 41b8c54 | 2016-06-15 16:09:46 +0530 | [diff] [blame] | 1049 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1050 | mcs = atoi(result); |
Priyadharshini Gowthaman | 78ee2ef | 2019-11-15 16:08:28 -0800 | [diff] [blame] | 1051 | if (dut->program == PROGRAM_HE) { |
| 1052 | uint16_t mcsnssmap = 0; |
| 1053 | |
| 1054 | get_he_mcs_nssmap((uint8_t *) &mcsnssmap, nss, mcs); |
| 1055 | dut->he_mcsnssmap = (mcsnssmap << 16) | mcsnssmap; |
| 1056 | dut->he_ul_mcs = mcs; |
| 1057 | } else { |
| 1058 | set_vht_mcsmap_nss(dut, nss, mcs); |
| 1059 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1060 | } |
| 1061 | |
| 1062 | /* TODO: MPDU_MIN_START_SPACING */ |
| 1063 | /* TODO: RIFS_TEST */ |
| 1064 | /* TODO: SGI20 */ |
| 1065 | |
| 1066 | val = get_param(cmd, "STBC_TX"); |
| 1067 | if (val) |
| 1068 | dut->ap_tx_stbc = atoi(val); |
| 1069 | |
| 1070 | val = get_param(cmd, "WIDTH"); |
| 1071 | if (val) { |
| 1072 | if (strcasecmp(val, "20") == 0) |
| 1073 | dut->ap_chwidth = AP_20; |
| 1074 | else if (strcasecmp(val, "40") == 0) |
| 1075 | dut->ap_chwidth = AP_40; |
| 1076 | else if (strcasecmp(val, "80") == 0) |
| 1077 | dut->ap_chwidth = AP_80; |
| 1078 | else if (strcasecmp(val, "160") == 0) |
| 1079 | dut->ap_chwidth = AP_160; |
priyadharshini gowthaman | 63ab848 | 2017-12-28 15:32:55 -0800 | [diff] [blame] | 1080 | else if (strcasecmp(val, "80plus80") == 0) { |
| 1081 | dut->ap_80plus80 = 1; |
| 1082 | dut->ap_chwidth = AP_80_80; |
| 1083 | } else if (strcasecmp(val, "Auto") == 0) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1084 | dut->ap_chwidth = AP_AUTO; |
| 1085 | else { |
| 1086 | send_resp(dut, conn, SIGMA_INVALID, |
| 1087 | "errorCode,Unsupported WIDTH"); |
Jouni Malinen | dccfd0c | 2019-10-30 12:05:59 +0200 | [diff] [blame] | 1088 | return STATUS_SENT; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1089 | } |
| 1090 | } |
| 1091 | |
| 1092 | /* TODO: WIDTH_SCAN */ |
| 1093 | |
| 1094 | val = get_param(cmd, "TDLSProhibit"); |
| 1095 | dut->ap_tdls_prohibit = val && strcasecmp(val, "Enabled") == 0; |
| 1096 | val = get_param(cmd, "TDLSChswitchProhibit"); |
| 1097 | dut->ap_tdls_prohibit_chswitch = |
| 1098 | val && strcasecmp(val, "Enabled") == 0; |
| 1099 | val = get_param(cmd, "HS2"); |
| 1100 | if (val && wlan_tag == 1) |
| 1101 | dut->ap_hs2 = atoi(val); |
| 1102 | val = get_param(cmd, "P2P_CROSS_CONNECT"); |
| 1103 | if (val) |
| 1104 | dut->ap_p2p_cross_connect = strcasecmp(val, "Enabled") == 0; |
| 1105 | |
| 1106 | val = get_param(cmd, "FakePubKey"); |
| 1107 | dut->ap_fake_pkhash = val && atoi(val); |
| 1108 | |
| 1109 | val = get_param(cmd, "vht_tkip"); |
| 1110 | dut->ap_allow_vht_tkip = val && strcasecmp(val, "Enable") == 0; |
| 1111 | val = get_param(cmd, "vht_wep"); |
| 1112 | dut->ap_allow_vht_wep = val && strcasecmp(val, "Enable") == 0; |
| 1113 | |
| 1114 | val = get_param(cmd, "Protect_mode"); |
| 1115 | dut->ap_disable_protection = val && strcasecmp(val, "Disable") == 0; |
| 1116 | |
| 1117 | val = get_param(cmd, "DYN_BW_SGNL"); |
| 1118 | if (val) { |
Jouni Malinen | 016ae6c | 2019-11-04 17:00:01 +0200 | [diff] [blame] | 1119 | switch (get_driver_type(dut)) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1120 | case DRIVER_OPENWRT: |
| 1121 | switch (get_openwrt_driver_type()) { |
| 1122 | case OPENWRT_DRIVER_ATHEROS: |
| 1123 | ath_config_dyn_bw_sig(dut, ifname, val); |
| 1124 | break; |
| 1125 | default: |
| 1126 | send_resp(dut, conn, SIGMA_ERROR, |
| 1127 | "errorCode,Unsupported DYN_BW_SGNL with OpenWrt driver"); |
Jouni Malinen | dccfd0c | 2019-10-30 12:05:59 +0200 | [diff] [blame] | 1128 | return STATUS_SENT; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1129 | } |
| 1130 | break; |
Nirav Shah | 8ad8d74 | 2017-10-17 10:49:11 +0530 | [diff] [blame] | 1131 | case DRIVER_WCN: |
| 1132 | case DRIVER_LINUX_WCN: |
| 1133 | ath_config_dyn_bw_sig(dut, ifname, val); |
| 1134 | break; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1135 | default: |
| 1136 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 1137 | "Unsupported DYN_BW_SGL with the current driver"); |
| 1138 | break; |
| 1139 | } |
| 1140 | } |
| 1141 | |
| 1142 | val = get_param(cmd, "SGI80"); |
| 1143 | if (val) { |
| 1144 | if (strcasecmp(val, "enable") == 0) |
| 1145 | dut->ap_sgi80 = 1; |
| 1146 | else if (strcasecmp(val, "disable") == 0) |
| 1147 | dut->ap_sgi80 = 0; |
| 1148 | else { |
| 1149 | send_resp(dut, conn, SIGMA_INVALID, |
| 1150 | "errorCode,Unsupported SGI80"); |
Jouni Malinen | dccfd0c | 2019-10-30 12:05:59 +0200 | [diff] [blame] | 1151 | return STATUS_SENT; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1152 | } |
| 1153 | } |
| 1154 | |
| 1155 | val = get_param(cmd, "LDPC"); |
| 1156 | if (val) { |
| 1157 | if (strcasecmp(val, "enable") == 0) |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 1158 | dut->ap_ldpc = VALUE_ENABLED; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1159 | else if (strcasecmp(val, "disable") == 0) |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 1160 | dut->ap_ldpc = VALUE_DISABLED; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1161 | else { |
| 1162 | send_resp(dut, conn, SIGMA_INVALID, |
| 1163 | "errorCode,Unsupported LDPC"); |
Jouni Malinen | dccfd0c | 2019-10-30 12:05:59 +0200 | [diff] [blame] | 1164 | return STATUS_SENT; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1165 | } |
| 1166 | } |
| 1167 | |
| 1168 | val = get_param(cmd, "BW_SGNL"); |
| 1169 | if (val) { |
| 1170 | /* |
| 1171 | * With dynamic bandwidth signaling enabled we should see |
| 1172 | * RTS if the threshold is met. |
| 1173 | */ |
| 1174 | if (strcasecmp(val, "enable") == 0) { |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 1175 | dut->ap_sig_rts = VALUE_ENABLED; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1176 | } else if (strcasecmp(val, "disable") == 0) { |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 1177 | dut->ap_sig_rts = VALUE_DISABLED; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1178 | } else { |
| 1179 | send_resp(dut, conn, SIGMA_INVALID, |
| 1180 | "errorCode,Unsupported BW_SGNL"); |
Jouni Malinen | dccfd0c | 2019-10-30 12:05:59 +0200 | [diff] [blame] | 1181 | return STATUS_SENT; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1182 | } |
| 1183 | } |
| 1184 | |
| 1185 | val = get_param(cmd, "RTS_FORCE"); |
| 1186 | if (val) { |
Jouni Malinen | 016ae6c | 2019-11-04 17:00:01 +0200 | [diff] [blame] | 1187 | switch (get_driver_type(dut)) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1188 | case DRIVER_OPENWRT: |
| 1189 | switch (get_openwrt_driver_type()) { |
| 1190 | case OPENWRT_DRIVER_ATHEROS: |
| 1191 | ath_config_rts_force(dut, ifname, val); |
| 1192 | break; |
| 1193 | default: |
| 1194 | send_resp(dut, conn, SIGMA_ERROR, |
| 1195 | "errorCode,Unsupported RTS_FORCE with OpenWrt driver"); |
Jouni Malinen | dccfd0c | 2019-10-30 12:05:59 +0200 | [diff] [blame] | 1196 | return STATUS_SENT; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1197 | } |
| 1198 | break; |
Tamizh chelvam | 638fb47 | 2019-08-15 14:00:31 +0530 | [diff] [blame] | 1199 | case DRIVER_MAC80211: |
| 1200 | mac80211_config_rts_force(dut, ifname, val); |
| 1201 | break; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1202 | default: |
| 1203 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 1204 | "Unsupported RTS_FORCE with the current driver"); |
| 1205 | break; |
| 1206 | } |
| 1207 | } |
| 1208 | |
| 1209 | val = get_param(cmd, "Zero_crc"); |
| 1210 | if (val) { |
Jouni Malinen | 016ae6c | 2019-11-04 17:00:01 +0200 | [diff] [blame] | 1211 | switch (get_driver_type(dut)) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1212 | case DRIVER_ATHEROS: |
| 1213 | ath_set_zero_crc(dut, val); |
| 1214 | break; |
| 1215 | case DRIVER_OPENWRT: |
| 1216 | switch (get_openwrt_driver_type()) { |
| 1217 | case OPENWRT_DRIVER_ATHEROS: |
| 1218 | ath_set_zero_crc(dut, val); |
| 1219 | break; |
| 1220 | default: |
| 1221 | send_resp(dut, conn, SIGMA_ERROR, |
| 1222 | "errorCode,Unsupported zero_crc with the current driver"); |
Jouni Malinen | dccfd0c | 2019-10-30 12:05:59 +0200 | [diff] [blame] | 1223 | return STATUS_SENT; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1224 | } |
| 1225 | break; |
| 1226 | default: |
| 1227 | send_resp(dut, conn, SIGMA_ERROR, |
| 1228 | "errorCode,Unsupported zero_crc with the current driver"); |
Jouni Malinen | dccfd0c | 2019-10-30 12:05:59 +0200 | [diff] [blame] | 1229 | return STATUS_SENT; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1230 | } |
| 1231 | } |
| 1232 | |
| 1233 | val = get_param(cmd, "TxBF"); |
Priyadharshini Gowthaman | 96d542e | 2019-11-21 14:25:21 -0800 | [diff] [blame] | 1234 | if (val) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1235 | dut->ap_txBF = strcasecmp(val, "enable") == 0; |
Priyadharshini Gowthaman | 96d542e | 2019-11-21 14:25:21 -0800 | [diff] [blame] | 1236 | dut->he_sounding = VALUE_DISABLED; |
Priyadharshini Gowthaman | 9b7dbe1 | 2019-12-04 12:17:32 -0800 | [diff] [blame] | 1237 | dut->he_set_sta_1x1 = VALUE_ENABLED; |
Priyadharshini Gowthaman | 96d542e | 2019-11-21 14:25:21 -0800 | [diff] [blame] | 1238 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1239 | |
| 1240 | val = get_param(cmd, "MU_TxBF"); |
Manikanta Pubbisetty | 210f7c8 | 2017-02-14 12:33:54 +0530 | [diff] [blame] | 1241 | if (val) { |
| 1242 | if (strcasecmp(val, "enable") == 0) { |
| 1243 | dut->ap_txBF = 1; |
| 1244 | dut->ap_mu_txBF = 1; |
Priyadharshini Gowthaman | 96d542e | 2019-11-21 14:25:21 -0800 | [diff] [blame] | 1245 | dut->he_sounding = VALUE_DISABLED; |
Manikanta Pubbisetty | 210f7c8 | 2017-02-14 12:33:54 +0530 | [diff] [blame] | 1246 | } else if (strcasecmp(val, "disable") == 0) { |
| 1247 | dut->ap_txBF = 0; |
| 1248 | dut->ap_mu_txBF = 0; |
| 1249 | } else { |
| 1250 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 1251 | "Unsupported MU_TxBF"); |
| 1252 | } |
| 1253 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1254 | |
| 1255 | /* UNSUPPORTED: tx_lgi_rate */ |
| 1256 | |
| 1257 | val = get_param(cmd, "wpsnfc"); |
| 1258 | if (val) |
| 1259 | dut->ap_wpsnfc = atoi(val); |
| 1260 | |
| 1261 | val = get_param(cmd, "GROUP_ID"); |
| 1262 | if (val) { |
Jouni Malinen | 016ae6c | 2019-11-04 17:00:01 +0200 | [diff] [blame] | 1263 | switch (get_driver_type(dut)) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1264 | case DRIVER_OPENWRT: |
| 1265 | switch (get_openwrt_driver_type()) { |
| 1266 | case OPENWRT_DRIVER_ATHEROS: |
| 1267 | ath_ap_set_group_id(dut, ifname, val); |
| 1268 | break; |
| 1269 | default: |
| 1270 | send_resp(dut, conn, SIGMA_ERROR, |
| 1271 | "errorCode,Unsupported group_id with the current driver"); |
Jouni Malinen | dccfd0c | 2019-10-30 12:05:59 +0200 | [diff] [blame] | 1272 | return STATUS_SENT; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1273 | } |
| 1274 | break; |
| 1275 | default: |
| 1276 | send_resp(dut, conn, SIGMA_ERROR, |
| 1277 | "errorCode,Unsupported group_id with the current driver"); |
Jouni Malinen | dccfd0c | 2019-10-30 12:05:59 +0200 | [diff] [blame] | 1278 | return STATUS_SENT; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1279 | } |
| 1280 | } |
| 1281 | |
| 1282 | val = get_param(cmd, "CTS_WIDTH"); |
| 1283 | if (val) { |
Jouni Malinen | 016ae6c | 2019-11-04 17:00:01 +0200 | [diff] [blame] | 1284 | switch (get_driver_type(dut)) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1285 | case DRIVER_OPENWRT: |
| 1286 | switch (get_openwrt_driver_type()) { |
| 1287 | case OPENWRT_DRIVER_ATHEROS: |
| 1288 | ath_set_cts_width(dut, ifname, val); |
| 1289 | break; |
| 1290 | default: |
| 1291 | send_resp(dut, conn, SIGMA_ERROR, |
| 1292 | "errorCode,Unsupported cts_width with the current driver"); |
Jouni Malinen | dccfd0c | 2019-10-30 12:05:59 +0200 | [diff] [blame] | 1293 | return STATUS_SENT; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1294 | } |
| 1295 | break; |
| 1296 | default: |
| 1297 | send_resp(dut, conn, SIGMA_ERROR, |
| 1298 | "errorCode,Unsupported cts_width with the current driver"); |
Jouni Malinen | dccfd0c | 2019-10-30 12:05:59 +0200 | [diff] [blame] | 1299 | return STATUS_SENT; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1300 | } |
| 1301 | } |
| 1302 | |
priyadharshini gowthaman | 264d544 | 2016-02-25 15:52:22 -0800 | [diff] [blame] | 1303 | val = get_param(cmd, "MU_NDPA_FrameFormat"); |
| 1304 | if (val) |
| 1305 | dut->ap_ndpa_frame = atoi(val); |
| 1306 | |
priyadharshini gowthaman | c52fff8 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 1307 | val = get_param(cmd, "interworking"); |
| 1308 | if (val && strcmp(val, "1") == 0) |
| 1309 | dut->ap_interworking = 1; |
| 1310 | |
| 1311 | val = get_param(cmd, "GAS_CB_DELAY"); |
| 1312 | if (val) |
| 1313 | dut->ap_gas_cb_delay = atoi(val); |
| 1314 | |
priyadharshini gowthaman | 8e26ff4 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 1315 | val = get_param(cmd, "LCI"); |
| 1316 | if (val) { |
| 1317 | if (strlen(val) > sizeof(dut->ap_val_lci) - 1) |
Jouni Malinen | dccfd0c | 2019-10-30 12:05:59 +0200 | [diff] [blame] | 1318 | return INVALID_SEND_STATUS; |
priyadharshini gowthaman | 8e26ff4 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 1319 | dut->ap_lci = 1; |
| 1320 | snprintf(dut->ap_val_lci, sizeof(dut->ap_val_lci), "%s", val); |
| 1321 | ath_set_lci_config(dut, val, cmd); |
| 1322 | } |
| 1323 | |
priyadharshini gowthaman | c2357bd | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 1324 | val = get_param(cmd, "InfoZ"); |
| 1325 | if (val) { |
| 1326 | if (strlen(val) > sizeof(dut->ap_infoz) - 1) |
Jouni Malinen | dccfd0c | 2019-10-30 12:05:59 +0200 | [diff] [blame] | 1327 | return INVALID_SEND_STATUS; |
priyadharshini gowthaman | c2357bd | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 1328 | snprintf(dut->ap_infoz, sizeof(dut->ap_infoz), "%s", val); |
| 1329 | } |
| 1330 | |
priyadharshini gowthaman | 8e26ff4 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 1331 | val = get_param(cmd, "LocCivicAddr"); |
| 1332 | if (val) { |
| 1333 | if (strlen(val) > sizeof(dut->ap_val_lcr) - 1) |
Jouni Malinen | dccfd0c | 2019-10-30 12:05:59 +0200 | [diff] [blame] | 1334 | return INVALID_SEND_STATUS; |
priyadharshini gowthaman | 8e26ff4 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 1335 | dut->ap_lcr = 1; |
| 1336 | snprintf(dut->ap_val_lcr, sizeof(dut->ap_val_lcr), "%s", val); |
| 1337 | if (dut->ap_lci == 0) |
| 1338 | ath_set_lci_config(dut, val, cmd); |
| 1339 | } |
| 1340 | |
| 1341 | val = get_param(cmd, "NeighAPBSSID"); |
| 1342 | if (val) { |
| 1343 | if (dut->ap_neighap < 3) { |
| 1344 | if (parse_mac_address( |
| 1345 | dut, val, |
| 1346 | dut->ap_val_neighap[dut->ap_neighap]) < 0) { |
| 1347 | send_resp(dut, conn, SIGMA_INVALID, |
| 1348 | "Failed to parse MAC address"); |
Jouni Malinen | dccfd0c | 2019-10-30 12:05:59 +0200 | [diff] [blame] | 1349 | return STATUS_SENT; |
priyadharshini gowthaman | 8e26ff4 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 1350 | } |
| 1351 | dut->ap_neighap++; |
| 1352 | if (dut->ap_lci == 1) |
| 1353 | dut->ap_scan = 1; |
| 1354 | } |
| 1355 | } |
| 1356 | |
| 1357 | val = get_param(cmd, "OpChannel"); |
| 1358 | if (val) { |
| 1359 | if (dut->ap_opchannel < 3) { |
| 1360 | dut->ap_val_opchannel[dut->ap_opchannel] = atoi(val); |
| 1361 | dut->ap_opchannel++; |
| 1362 | } |
| 1363 | } |
| 1364 | |
priyadharshini gowthaman | c2357bd | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 1365 | val = get_param(cmd, "URI-FQDNdescriptor"); |
| 1366 | if (val) { |
| 1367 | if (strcasecmp(val, "HELD") == 0) { |
| 1368 | dut->ap_fqdn_held = 1; |
| 1369 | } else if (strcasecmp(val, "SUPL") == 0) { |
| 1370 | dut->ap_fqdn_supl = 1; |
| 1371 | } else { |
| 1372 | send_resp(dut, conn, SIGMA_INVALID, |
| 1373 | "errorCode,Unsupported URI-FQDNdescriptor"); |
Jouni Malinen | dccfd0c | 2019-10-30 12:05:59 +0200 | [diff] [blame] | 1374 | return STATUS_SENT; |
priyadharshini gowthaman | c2357bd | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 1375 | } |
| 1376 | } |
| 1377 | |
Adil Saeed Musthafa | 604c826 | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 1378 | val = get_param(cmd, "Reg_Domain"); |
| 1379 | if (val) { |
| 1380 | if (strcasecmp(val, "Local") == 0) { |
| 1381 | dut->ap_reg_domain = REG_DOMAIN_LOCAL; |
| 1382 | } else if (strcasecmp(val, "Global") == 0) { |
| 1383 | dut->ap_reg_domain = REG_DOMAIN_GLOBAL; |
| 1384 | } else { |
| 1385 | send_resp(dut, conn, SIGMA_ERROR, |
| 1386 | "errorCode,Wrong value for Reg_Domain"); |
Jouni Malinen | dccfd0c | 2019-10-30 12:05:59 +0200 | [diff] [blame] | 1387 | return STATUS_SENT; |
Adil Saeed Musthafa | 604c826 | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 1388 | } |
| 1389 | } |
| 1390 | |
Adil Saeed Musthafa | 4ec61bd | 2017-04-10 23:13:41 -0700 | [diff] [blame] | 1391 | val = get_param(cmd, "NAME"); |
| 1392 | if (val) { |
| 1393 | if (strcasecmp(val, "ap1mbo") == 0) |
| 1394 | dut->ap_name = 1; |
| 1395 | else if (strcasecmp(val, "ap2mbo") == 0) |
| 1396 | dut->ap_name = 2; |
| 1397 | else |
| 1398 | dut->ap_name = 0; |
| 1399 | } |
| 1400 | |
| 1401 | val = get_param(cmd, "FT_OA"); |
| 1402 | if (val) { |
| 1403 | if (strcasecmp(val, "Enable") == 0) { |
| 1404 | dut->ap_ft_oa = 1; |
| 1405 | } else if (strcasecmp(val, "Disable") == 0) { |
| 1406 | dut->ap_ft_oa = 0; |
| 1407 | } else { |
| 1408 | send_resp(dut, conn, SIGMA_ERROR, |
| 1409 | "errorCode,Wrong value for FT_OA"); |
Jouni Malinen | dccfd0c | 2019-10-30 12:05:59 +0200 | [diff] [blame] | 1410 | return STATUS_SENT; |
Adil Saeed Musthafa | 4ec61bd | 2017-04-10 23:13:41 -0700 | [diff] [blame] | 1411 | } |
| 1412 | } |
| 1413 | |
Jouni Malinen | 9f94331 | 2019-08-19 23:49:16 +0300 | [diff] [blame] | 1414 | val = get_param(cmd, "FT_DS"); |
| 1415 | if (val) { |
| 1416 | if (strcasecmp(val, "Enable") == 0) { |
| 1417 | dut->ap_ft_ds = VALUE_ENABLED; |
| 1418 | } else if (strcasecmp(val, "Disable") == 0) { |
| 1419 | dut->ap_ft_ds = VALUE_DISABLED; |
| 1420 | } else { |
| 1421 | send_resp(dut, conn, SIGMA_ERROR, |
| 1422 | "errorCode,Unsupported value for FT_DS"); |
| 1423 | return STATUS_SENT_ERROR; |
| 1424 | } |
| 1425 | } |
| 1426 | |
Adil Saeed Musthafa | 023108a | 2017-04-10 23:13:37 -0700 | [diff] [blame] | 1427 | val = get_param(cmd, "Cellular_Cap_Pref"); |
| 1428 | if (val) |
| 1429 | dut->ap_cell_cap_pref = atoi(val); |
| 1430 | |
Adil Saeed Musthafa | cf752fa | 2017-04-10 23:13:32 -0700 | [diff] [blame] | 1431 | val = get_param(cmd, "DOMAIN"); |
| 1432 | if (val) { |
| 1433 | if (strlen(val) >= sizeof(dut->ap_mobility_domain)) { |
| 1434 | send_resp(dut, conn, SIGMA_ERROR, |
| 1435 | "errorCode,Too long DOMAIN"); |
Jouni Malinen | dccfd0c | 2019-10-30 12:05:59 +0200 | [diff] [blame] | 1436 | return STATUS_SENT; |
Adil Saeed Musthafa | cf752fa | 2017-04-10 23:13:32 -0700 | [diff] [blame] | 1437 | } |
| 1438 | snprintf(dut->ap_mobility_domain, |
| 1439 | sizeof(dut->ap_mobility_domain), "%s", val); |
| 1440 | } |
| 1441 | |
Adil Saeed Musthafa | 4ec61bd | 2017-04-10 23:13:41 -0700 | [diff] [blame] | 1442 | val = get_param(cmd, "ft_bss_list"); |
| 1443 | if (val) { |
| 1444 | char *mac_str; |
| 1445 | int i; |
| 1446 | char *saveptr; |
| 1447 | char *mac_list_str; |
| 1448 | |
| 1449 | mac_list_str = strdup(val); |
| 1450 | if (!mac_list_str) |
Jouni Malinen | dccfd0c | 2019-10-30 12:05:59 +0200 | [diff] [blame] | 1451 | return INVALID_SEND_STATUS; |
Adil Saeed Musthafa | 4ec61bd | 2017-04-10 23:13:41 -0700 | [diff] [blame] | 1452 | mac_str = strtok_r(mac_list_str, " ", &saveptr); |
| 1453 | for (i = 0; mac_str && i < MAX_FT_BSS_LIST; i++) { |
| 1454 | if (parse_mac_address(dut, mac_str, |
| 1455 | dut->ft_bss_mac_list[i]) < 0) { |
| 1456 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 1457 | "MAC Address not in proper format"); |
| 1458 | break; |
| 1459 | } |
| 1460 | dut->ft_bss_mac_cnt++; |
| 1461 | mac_str = strtok_r(NULL, " ", &saveptr); |
| 1462 | } |
| 1463 | sigma_dut_print(dut, DUT_MSG_DEBUG, |
| 1464 | "Storing the following FT BSS MAC List"); |
| 1465 | for (i = 0; i < dut->ft_bss_mac_cnt; i++) { |
| 1466 | sigma_dut_print(dut, DUT_MSG_DEBUG, |
| 1467 | "MAC[%d] %02x:%02x:%02x:%02x:%02x:%02x", |
| 1468 | i, |
| 1469 | dut->ft_bss_mac_list[i][0], |
| 1470 | dut->ft_bss_mac_list[i][1], |
| 1471 | dut->ft_bss_mac_list[i][2], |
| 1472 | dut->ft_bss_mac_list[i][3], |
| 1473 | dut->ft_bss_mac_list[i][4], |
| 1474 | dut->ft_bss_mac_list[i][5]); |
| 1475 | } |
| 1476 | free(mac_list_str); |
| 1477 | } |
| 1478 | |
priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 1479 | val = get_param(cmd, "OCESupport"); |
| 1480 | if (val) { |
| 1481 | if (strcasecmp(val, "enable") == 0) { |
| 1482 | dut->ap_oce = VALUE_ENABLED; |
| 1483 | } else if (strcasecmp(val, "disable") == 0) { |
| 1484 | dut->ap_oce = VALUE_DISABLED; |
| 1485 | dut->ap_filsdscv = VALUE_DISABLED; |
| 1486 | } else { |
| 1487 | send_resp(dut, conn, SIGMA_INVALID, |
| 1488 | "errorCode,Unsupported OCE"); |
Jouni Malinen | dccfd0c | 2019-10-30 12:05:59 +0200 | [diff] [blame] | 1489 | return STATUS_SENT; |
priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 1490 | } |
| 1491 | } |
| 1492 | |
| 1493 | val = get_param(cmd, "FILSDscvInterval"); |
| 1494 | if (val) |
| 1495 | dut->ap_fils_dscv_int = atoi(val); |
| 1496 | |
| 1497 | val = get_param(cmd, "BroadcastSSID"); |
| 1498 | if (val) { |
| 1499 | if (strcasecmp(val, "enable") == 0) { |
| 1500 | dut->ap_broadcast_ssid = VALUE_ENABLED; |
| 1501 | } else if (strcasecmp(val, "disable") == 0) { |
| 1502 | dut->ap_broadcast_ssid = VALUE_DISABLED; |
| 1503 | } else { |
| 1504 | send_resp(dut, conn, SIGMA_INVALID, |
| 1505 | "errorCode,Unsupported hidden SSID"); |
Jouni Malinen | dccfd0c | 2019-10-30 12:05:59 +0200 | [diff] [blame] | 1506 | return STATUS_SENT; |
priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 1507 | } |
| 1508 | } |
| 1509 | |
| 1510 | val = get_param(cmd, "FILSDscv"); |
| 1511 | if (val) { |
| 1512 | if (strcasecmp(val, "enable") == 0) { |
| 1513 | dut->ap_filsdscv = VALUE_ENABLED; |
| 1514 | } else if (strcasecmp(val, "disable") == 0) { |
| 1515 | dut->ap_filsdscv = VALUE_DISABLED; |
| 1516 | } else { |
| 1517 | send_resp(dut, conn, SIGMA_INVALID, |
| 1518 | "errorCode,Unsupported FILSDscv"); |
Jouni Malinen | dccfd0c | 2019-10-30 12:05:59 +0200 | [diff] [blame] | 1519 | return STATUS_SENT; |
priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 1520 | } |
| 1521 | } |
| 1522 | |
| 1523 | val = get_param(cmd, "FILSHLP"); |
| 1524 | if (val) { |
| 1525 | if (strcasecmp(val, "enable") == 0) { |
| 1526 | dut->ap_filshlp = VALUE_ENABLED; |
| 1527 | } else if (strcasecmp(val, "disable") == 0) { |
| 1528 | dut->ap_filshlp = VALUE_DISABLED; |
| 1529 | } else { |
| 1530 | send_resp(dut, conn, SIGMA_INVALID, |
| 1531 | "errorCode,Unsupported FILSHLP"); |
Jouni Malinen | dccfd0c | 2019-10-30 12:05:59 +0200 | [diff] [blame] | 1532 | return STATUS_SENT; |
priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 1533 | } |
| 1534 | } |
| 1535 | |
| 1536 | val = get_param(cmd, "NAIRealm"); |
| 1537 | if (val) { |
| 1538 | dut->ap_nairealm_int = 1; |
| 1539 | if (strlen(val) > sizeof(dut->ap_nairealm) - 1) |
Jouni Malinen | dccfd0c | 2019-10-30 12:05:59 +0200 | [diff] [blame] | 1540 | return INVALID_SEND_STATUS; |
priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 1541 | snprintf(dut->ap_nairealm, sizeof(dut->ap_nairealm), "%s", val); |
| 1542 | } |
| 1543 | |
| 1544 | val = get_param(cmd, "DeauthDisassocTx"); |
| 1545 | if (val) { |
| 1546 | if (strcasecmp(val, "disable") == 0) { |
| 1547 | deauth_disassoc(dut, ifname, val); |
| 1548 | } else { |
| 1549 | send_resp(dut, conn, SIGMA_INVALID, |
| 1550 | "errorCode,Unsupported DeauthDisassocTx"); |
Jouni Malinen | dccfd0c | 2019-10-30 12:05:59 +0200 | [diff] [blame] | 1551 | return STATUS_SENT; |
priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 1552 | } |
| 1553 | } |
| 1554 | |
| 1555 | val = get_param(cmd, "RNR"); |
| 1556 | if (val) { |
| 1557 | if (strcasecmp(val, "enable") == 0) { |
| 1558 | dut->ap_rnr = VALUE_ENABLED; |
| 1559 | } else if (strcasecmp(val, "disable") == 0) { |
| 1560 | dut->ap_rnr = VALUE_DISABLED; |
| 1561 | } else { |
| 1562 | send_resp(dut, conn, SIGMA_INVALID, |
| 1563 | "errorCode,Unsupported RNR"); |
Jouni Malinen | dccfd0c | 2019-10-30 12:05:59 +0200 | [diff] [blame] | 1564 | return STATUS_SENT; |
priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 1565 | } |
| 1566 | } |
| 1567 | |
| 1568 | val = get_param(cmd, "BLEChannelUtil"); |
| 1569 | if (val) |
| 1570 | dut->ap_blechanutil = atoi(val); |
| 1571 | |
| 1572 | val = get_param(cmd, "BLEAvailAdminCap"); |
| 1573 | if (val) |
| 1574 | dut->ap_ble_admit_cap = atoi(val); |
| 1575 | |
| 1576 | val = get_param(cmd, "DataPPDUDuration"); |
| 1577 | if (val) |
| 1578 | dut->ap_datappdudura = atoi(val); |
| 1579 | |
| 1580 | val = get_param(cmd, "AirTimeFract"); |
| 1581 | if (val) |
| 1582 | dut->ap_airtimefract = atoi(val); |
| 1583 | |
| 1584 | val = get_param(cmd, "dhcpServIPADDR"); |
| 1585 | if (val) { |
| 1586 | if (strlen(val) > sizeof(dut->ap_dhcpserv_ipaddr) - 1) |
Jouni Malinen | dccfd0c | 2019-10-30 12:05:59 +0200 | [diff] [blame] | 1587 | return INVALID_SEND_STATUS; |
priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 1588 | snprintf(dut->ap_dhcpserv_ipaddr, |
| 1589 | sizeof(dut->ap_dhcpserv_ipaddr), "%s", val); |
| 1590 | dut->ap_dhcp_stop = 1; |
| 1591 | } |
| 1592 | |
| 1593 | val = get_param(cmd, "ESP_IE"); |
| 1594 | if (val) { |
| 1595 | if (strcasecmp(val, "enable") == 0) { |
| 1596 | dut->ap_esp = VALUE_ENABLED; |
| 1597 | } else if (strcasecmp(val, "disable") == 0) { |
| 1598 | dut->ap_esp = VALUE_DISABLED; |
| 1599 | } else { |
| 1600 | send_resp(dut, conn, SIGMA_INVALID, |
| 1601 | "errorCode,Unsupported ESP_IE"); |
Jouni Malinen | dccfd0c | 2019-10-30 12:05:59 +0200 | [diff] [blame] | 1602 | return STATUS_SENT; |
priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 1603 | } |
| 1604 | } |
| 1605 | |
| 1606 | val = get_param(cmd, "BAWinSize"); |
| 1607 | if (val) |
| 1608 | dut->ap_bawinsize = atoi(val); |
| 1609 | |
| 1610 | val = get_param(cmd, "BLEStaCount"); |
| 1611 | if (val) |
| 1612 | dut->ap_blestacnt = atoi(val); |
| 1613 | |
priyadharshini gowthaman | 350f191 | 2018-06-04 13:09:12 -0700 | [diff] [blame] | 1614 | val = get_param(cmd, "PPDUTxType"); |
| 1615 | if (val) { |
| 1616 | if (strcasecmp(val, "MU") == 0) { |
| 1617 | dut->ap_he_ppdu = PPDU_MU; |
Priyadharshini Gowthaman | fe60c50 | 2019-08-14 13:00:34 -0700 | [diff] [blame] | 1618 | } else if (strcasecmp(val, "HE-SU") == 0) { |
| 1619 | /* Do nothing */ |
| 1620 | } else if (strcasecmp(val, "SU") == 0) { |
| 1621 | /* Do nothing */ |
| 1622 | } else if (strcasecmp(val, "legacy") == 0) { |
| 1623 | /* Do nothing */ |
| 1624 | } else if (strcasecmp(val, "ER") == 0) { |
| 1625 | /* Do nothing */ |
| 1626 | } else if (strcasecmp(val, "TB") == 0) { |
| 1627 | /* Do nothing */ |
priyadharshini gowthaman | 350f191 | 2018-06-04 13:09:12 -0700 | [diff] [blame] | 1628 | } else { |
Priyadharshini Gowthaman | fe60c50 | 2019-08-14 13:00:34 -0700 | [diff] [blame] | 1629 | send_resp(dut, conn, SIGMA_ERROR, |
priyadharshini gowthaman | 350f191 | 2018-06-04 13:09:12 -0700 | [diff] [blame] | 1630 | "errorCode,Unsupported PPDUTxType"); |
Priyadharshini Gowthaman | fe60c50 | 2019-08-14 13:00:34 -0700 | [diff] [blame] | 1631 | return STATUS_SENT_ERROR; |
priyadharshini gowthaman | 350f191 | 2018-06-04 13:09:12 -0700 | [diff] [blame] | 1632 | } |
| 1633 | } |
| 1634 | |
Alexei Avshalom Lazar | 33f700c | 2018-12-18 16:00:39 +0200 | [diff] [blame] | 1635 | val = get_param(cmd, "WscIEFragment"); |
| 1636 | if (val && strcasecmp(val, "enable") == 0) { |
| 1637 | sigma_dut_print(dut, DUT_MSG_DEBUG, |
| 1638 | "Enable WSC IE fragmentation"); |
| 1639 | dut->wsc_fragment = 1; |
| 1640 | } |
| 1641 | |
Alexei Avshalom Lazar | 744ae8a | 2019-01-31 17:26:46 +0200 | [diff] [blame] | 1642 | val = get_param(cmd, "WpsVersion"); |
| 1643 | if (val) |
| 1644 | dut->wps_forced_version = get_wps_forced_version(dut, val); |
| 1645 | |
Alexei Avshalom Lazar | 2eccf4d | 2019-01-31 10:03:59 +0200 | [diff] [blame] | 1646 | val = get_param(cmd, "WscEAPFragment"); |
| 1647 | if (val && strcasecmp(val, "enable") == 0) |
| 1648 | dut->eap_fragment = 1; |
| 1649 | |
Alexei Avshalom Lazar | 79f5727 | 2018-12-23 17:22:47 +0200 | [diff] [blame] | 1650 | val = get_param(cmd, "MSDUSize"); |
| 1651 | if (val) { |
| 1652 | int mtu; |
| 1653 | |
| 1654 | dut->amsdu_size = atoi(val); |
| 1655 | if (dut->amsdu_size > IEEE80211_MAX_DATA_LEN_DMG || |
| 1656 | dut->amsdu_size < IEEE80211_SNAP_LEN_DMG) { |
| 1657 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 1658 | "MSDUSize %d is above max %d or below min %d", |
| 1659 | dut->amsdu_size, |
| 1660 | IEEE80211_MAX_DATA_LEN_DMG, |
| 1661 | IEEE80211_SNAP_LEN_DMG); |
| 1662 | dut->amsdu_size = 0; |
Jouni Malinen | 0e29cf2 | 2019-02-19 01:13:21 +0200 | [diff] [blame] | 1663 | return ERROR_SEND_STATUS; |
Alexei Avshalom Lazar | 79f5727 | 2018-12-23 17:22:47 +0200 | [diff] [blame] | 1664 | } |
| 1665 | |
| 1666 | mtu = dut->amsdu_size - IEEE80211_SNAP_LEN_DMG; |
| 1667 | sigma_dut_print(dut, DUT_MSG_DEBUG, |
| 1668 | "Setting amsdu_size to %d", mtu); |
| 1669 | snprintf(buf, sizeof(buf), "ifconfig %s mtu %d", |
Jouni Malinen | 016ae6c | 2019-11-04 17:00:01 +0200 | [diff] [blame] | 1670 | get_station_ifname(dut), mtu); |
Alexei Avshalom Lazar | 79f5727 | 2018-12-23 17:22:47 +0200 | [diff] [blame] | 1671 | |
| 1672 | if (system(buf) != 0) { |
| 1673 | sigma_dut_print(dut, DUT_MSG_ERROR, "Failed to set %s", |
| 1674 | buf); |
Jouni Malinen | 0e29cf2 | 2019-02-19 01:13:21 +0200 | [diff] [blame] | 1675 | return ERROR_SEND_STATUS; |
Alexei Avshalom Lazar | 79f5727 | 2018-12-23 17:22:47 +0200 | [diff] [blame] | 1676 | } |
| 1677 | } |
| 1678 | |
Alexei Avshalom Lazar | 0e239a9 | 2018-12-23 17:27:50 +0200 | [diff] [blame] | 1679 | val = get_param(cmd, "BAckRcvBuf"); |
| 1680 | if (val) { |
| 1681 | dut->back_rcv_buf = atoi(val); |
| 1682 | if (dut->back_rcv_buf == 0) { |
| 1683 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 1684 | "Failed to convert %s or value is 0", |
| 1685 | val); |
Jouni Malinen | 0e29cf2 | 2019-02-19 01:13:21 +0200 | [diff] [blame] | 1686 | return ERROR_SEND_STATUS; |
Alexei Avshalom Lazar | 0e239a9 | 2018-12-23 17:27:50 +0200 | [diff] [blame] | 1687 | } |
| 1688 | |
| 1689 | sigma_dut_print(dut, DUT_MSG_DEBUG, |
| 1690 | "Setting BAckRcvBuf to %s", val); |
| 1691 | } |
| 1692 | |
Alexei Avshalom Lazar | bc180dc | 2018-12-18 16:01:14 +0200 | [diff] [blame] | 1693 | val = get_param(cmd, "ExtSchIE"); |
| 1694 | if (val && !strcasecmp(val, "Enable")) { |
| 1695 | int num_allocs = MAX_ESE_ALLOCS; |
| 1696 | |
| 1697 | if (sta_extract_60g_ese(dut, cmd, dut->ap_ese_allocs, |
| 1698 | &num_allocs)) { |
| 1699 | send_resp(dut, conn, SIGMA_INVALID, |
| 1700 | "errorCode,Invalid ExtSchIE"); |
Jouni Malinen | dccfd0c | 2019-10-30 12:05:59 +0200 | [diff] [blame] | 1701 | return STATUS_SENT; |
Alexei Avshalom Lazar | bc180dc | 2018-12-18 16:01:14 +0200 | [diff] [blame] | 1702 | } |
| 1703 | dut->ap_num_ese_allocs = num_allocs; |
| 1704 | } |
| 1705 | |
Alexei Avshalom Lazar | 49498b8 | 2019-01-31 15:16:32 +0200 | [diff] [blame] | 1706 | if (is_60g_sigma_dut(dut)) { |
| 1707 | unsigned int abft_len = 1; /* default is one slot */ |
| 1708 | |
| 1709 | val = get_param(cmd, "ABFTLRang"); |
| 1710 | if (val) { |
| 1711 | sigma_dut_print(dut, DUT_MSG_DEBUG, |
| 1712 | "ABFTLRang parameter %s", val); |
| 1713 | if (strcasecmp(val, "Gt1") == 0) |
| 1714 | abft_len = 2; /* 2 slots in this case */ |
| 1715 | } |
| 1716 | |
| 1717 | if (sta_set_60g_abft_len(dut, conn, abft_len)) { |
| 1718 | send_resp(dut, conn, SIGMA_ERROR, |
| 1719 | "ErrorCode,Can't set ABFT length"); |
| 1720 | return STATUS_SENT; |
| 1721 | } |
| 1722 | } |
| 1723 | |
Priyadharshini Gowthaman | c067edf | 2019-06-20 11:23:27 -0700 | [diff] [blame] | 1724 | val = get_param(cmd, "OFDMA"); |
| 1725 | if (val) { |
| 1726 | if (strcasecmp(val, "UL") == 0) { |
| 1727 | dut->ap_he_ulofdma = VALUE_ENABLED; |
Priyadharshini Gowthaman | fe60c50 | 2019-08-14 13:00:34 -0700 | [diff] [blame] | 1728 | } else if (strcasecmp(val, "DL") == 0) { |
| 1729 | dut->ap_he_dlofdma = VALUE_ENABLED; |
| 1730 | } else if (strcasecmp(val, "DL-20and80") == 0) { |
| 1731 | dut->ap_he_dlofdma = VALUE_ENABLED; |
Priyadharshini Gowthaman | c067edf | 2019-06-20 11:23:27 -0700 | [diff] [blame] | 1732 | } else { |
| 1733 | send_resp(dut, conn, SIGMA_ERROR, |
| 1734 | "errorCode,Unsupported OFDMA value"); |
| 1735 | return STATUS_SENT_ERROR; |
| 1736 | } |
| 1737 | } |
| 1738 | |
Priyadharshini Gowthaman | bc94889 | 2019-09-10 14:22:49 -0700 | [diff] [blame] | 1739 | val = get_param(cmd, "NumSoundDim"); |
| 1740 | if (val) |
| 1741 | dut->ap_numsounddim = atoi(val); |
| 1742 | |
Priyadharshini Gowthaman | 670b323 | 2019-09-10 16:09:19 -0700 | [diff] [blame] | 1743 | val = get_param(cmd, "BCC"); |
| 1744 | if (val) { |
| 1745 | if (strcasecmp(val, "enable") == 0) { |
| 1746 | dut->ap_bcc = VALUE_ENABLED; |
| 1747 | dut->ap_ldpc = VALUE_DISABLED; |
| 1748 | } else if (strcasecmp(val, "disable") == 0) { |
| 1749 | dut->ap_ldpc = VALUE_ENABLED; |
| 1750 | dut->ap_bcc = VALUE_DISABLED; |
| 1751 | } else { |
| 1752 | send_resp(dut, conn, SIGMA_ERROR, |
| 1753 | "errorCode,Unsupported BCC value"); |
| 1754 | return STATUS_SENT_ERROR; |
| 1755 | } |
| 1756 | } |
| 1757 | |
Priyadharshini Gowthaman | 6bc4c1e | 2019-09-10 16:24:51 -0700 | [diff] [blame] | 1758 | val = get_param(cmd, "FrgmntSupport"); |
| 1759 | if (val) { |
| 1760 | if (strcasecmp(val, "enable") == 0) { |
| 1761 | dut->ap_he_frag = VALUE_ENABLED; |
| 1762 | } else if (strcasecmp(val, "disable") == 0) { |
| 1763 | dut->ap_he_frag = VALUE_DISABLED; |
| 1764 | } else { |
| 1765 | send_resp(dut, conn, SIGMA_ERROR, |
| 1766 | "errorCode,Unsupported FrgmntSupport value"); |
| 1767 | return STATUS_SENT_ERROR; |
| 1768 | } |
| 1769 | } |
| 1770 | |
Priyadharshini Gowthaman | 1a686bd | 2019-09-19 14:41:40 -0700 | [diff] [blame] | 1771 | val = get_param(cmd, "ADDBAReq_BufSize"); |
| 1772 | if (val) { |
| 1773 | if (strcasecmp(val, "le64") == 0) { |
| 1774 | dut->ap_ba_bufsize = BA_BUFSIZE_64; |
| 1775 | } else if (strcasecmp(val, "gt64") == 0) { |
| 1776 | dut->ap_ba_bufsize = BA_BUFSIZE_256; |
| 1777 | } else { |
| 1778 | send_resp(dut, conn, SIGMA_ERROR, |
| 1779 | "errorCode,Unsupported ADDBAReq Buffer Size"); |
| 1780 | return STATUS_SENT_ERROR; |
| 1781 | } |
| 1782 | } |
| 1783 | |
| 1784 | val = get_param(cmd, "ADDBAResp_BufSize"); |
| 1785 | if (val) { |
| 1786 | if (strcasecmp(val, "gt64") == 0) { |
| 1787 | dut->ap_ba_bufsize = BA_BUFSIZE_256; |
| 1788 | } else { |
| 1789 | send_resp(dut, conn, SIGMA_ERROR, |
| 1790 | "errorCode,Unsupported ADDBAResp Buffer Size"); |
| 1791 | return STATUS_SENT_ERROR; |
| 1792 | } |
| 1793 | } |
| 1794 | |
Priyadharshini Gowthaman | 21895a5 | 2019-10-07 16:56:16 -0700 | [diff] [blame] | 1795 | val = get_param(cmd, "MU_EDCA"); |
| 1796 | if (val) { |
| 1797 | if (strcasecmp(val, "override") == 0) { |
| 1798 | dut->ap_mu_edca = VALUE_ENABLED; |
| 1799 | } else if (strcasecmp(val, "disable") == 0) { |
| 1800 | dut->ap_mu_edca = VALUE_DISABLED; |
| 1801 | } else { |
| 1802 | send_resp(dut, conn, SIGMA_ERROR, |
| 1803 | "errorCode,Unsupported mu_edca param value"); |
| 1804 | return STATUS_SENT_ERROR; |
| 1805 | } |
| 1806 | } |
| 1807 | |
Priyadharshini Gowthaman | dee79e2 | 2019-10-07 16:56:27 -0700 | [diff] [blame] | 1808 | val = get_param(cmd, "MIMO"); |
| 1809 | if (val) { |
| 1810 | if (strcasecmp(val, "DL") == 0) { |
| 1811 | dut->ap_he_mimo = MIMO_DL; |
Priyadharshini Gowthaman | 96d542e | 2019-11-21 14:25:21 -0800 | [diff] [blame] | 1812 | dut->he_sounding = VALUE_DISABLED; |
Priyadharshini Gowthaman | dee79e2 | 2019-10-07 16:56:27 -0700 | [diff] [blame] | 1813 | } else if (strcasecmp(val, "UL") == 0) { |
| 1814 | dut->ap_he_mimo = MIMO_UL; |
| 1815 | } else { |
| 1816 | send_resp(dut, conn, SIGMA_ERROR, |
| 1817 | "errorCode,Unsupported mimo param value"); |
| 1818 | return STATUS_SENT_ERROR; |
| 1819 | } |
| 1820 | } |
| 1821 | |
Priyadharshini Gowthaman | 43d6b41 | 2019-10-07 16:56:37 -0700 | [diff] [blame] | 1822 | val = get_param(cmd, "HE_TXOPDurRTSThr"); |
| 1823 | if (val) { |
| 1824 | if (strcasecmp(val, "enable") == 0) { |
| 1825 | dut->ap_he_rtsthrshld = VALUE_ENABLED; |
| 1826 | } else if (strcasecmp(val, "disable") == 0) { |
| 1827 | dut->ap_he_rtsthrshld = VALUE_DISABLED; |
| 1828 | } else { |
| 1829 | send_resp(dut, conn, SIGMA_ERROR, |
| 1830 | "errorCode,Unsupported HE_TXOPDurRTSThr value"); |
| 1831 | return STATUS_SENT_ERROR; |
| 1832 | } |
| 1833 | } |
| 1834 | |
Priyadharshini Gowthaman | 8018c98 | 2019-10-31 15:14:37 -0700 | [diff] [blame] | 1835 | val = get_param(cmd, "MBSSID"); |
| 1836 | if (val) { |
| 1837 | if (strcasecmp(val, "enable") == 0) { |
| 1838 | dut->ap_mbssid = VALUE_ENABLED; |
| 1839 | } else if (strcasecmp(val, "disable") == 0) { |
| 1840 | dut->ap_mbssid = VALUE_DISABLED; |
| 1841 | } else { |
| 1842 | send_resp(dut, conn, SIGMA_ERROR, |
| 1843 | "errorCode,Unsupported MBSSID Value"); |
| 1844 | return STATUS_SENT_ERROR; |
| 1845 | } |
| 1846 | } |
| 1847 | |
Priyadharshini Gowthaman | ae0a605 | 2019-11-01 15:26:38 -0700 | [diff] [blame] | 1848 | val = get_param(cmd, "TWT_RespSupport"); |
| 1849 | if (val) { |
| 1850 | if (strcasecmp(val, "enable") == 0) { |
| 1851 | dut->ap_twtresp = VALUE_ENABLED; |
| 1852 | } else if (strcasecmp(val, "disable") == 0) { |
| 1853 | dut->ap_twtresp = VALUE_DISABLED; |
| 1854 | } else { |
| 1855 | send_resp(dut, conn, SIGMA_ERROR, |
| 1856 | "errorCode,Unsupported TWT_RespSupport value"); |
| 1857 | return STATUS_SENT_ERROR; |
| 1858 | } |
| 1859 | } |
| 1860 | |
Priyadharshini Gowthaman | 21f7440 | 2019-11-25 15:39:09 -0800 | [diff] [blame] | 1861 | val = get_param(cmd, "MinMPDUStartSpacing"); |
| 1862 | if (val) |
| 1863 | dut->he_mmss = atoi(val); |
| 1864 | |
Jouni Malinen | dccfd0c | 2019-10-30 12:05:59 +0200 | [diff] [blame] | 1865 | return SUCCESS_SEND_STATUS; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1866 | } |
| 1867 | |
| 1868 | |
| 1869 | static void ath_inject_frame(struct sigma_dut *dut, const char *ifname, int tid) |
| 1870 | { |
| 1871 | char buf[256]; |
| 1872 | int tid_to_dscp[] = { 0x00, 0x20, 0x40, 0x60, 0x80, 0xa0, 0xc0, 0xe0 }; |
| 1873 | |
Pradeep Reddy POTTETI | d31d132 | 2016-10-13 17:22:03 +0530 | [diff] [blame] | 1874 | if (tid < 0 || |
| 1875 | tid >= (int) (sizeof(tid_to_dscp) / sizeof(tid_to_dscp[0]))) { |
| 1876 | sigma_dut_print(dut, DUT_MSG_ERROR, "Unsupported TID: %d", tid); |
| 1877 | return; |
| 1878 | } |
| 1879 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1880 | snprintf(buf, sizeof(buf), |
| 1881 | "wlanconfig %s list sta | grep : | cut -b 1-17 > %s", |
| 1882 | ifname, VI_QOS_TMP_FILE); |
| 1883 | if (system(buf) != 0) |
| 1884 | return; |
| 1885 | |
| 1886 | snprintf(buf, sizeof(buf), |
| 1887 | "ifconfig %s | grep HWaddr | cut -b 39-56 >> %s", |
| 1888 | ifname, VI_QOS_TMP_FILE); |
| 1889 | if (system(buf) != 0) |
| 1890 | sigma_dut_print(dut, DUT_MSG_ERROR, "Retrieve HWaddr failed"); |
| 1891 | |
| 1892 | snprintf(buf, sizeof(buf), "sed -n '3,$p' %s >> %s", |
| 1893 | VI_QOS_REFFILE, VI_QOS_TMP_FILE); |
| 1894 | if (system(buf) != 0) { |
| 1895 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 1896 | "Output redirection to VI_QOS_TMP_FILE failed"); |
| 1897 | } |
| 1898 | |
| 1899 | snprintf(buf, sizeof(buf), "sed '5 c %x' %s > %s", |
| 1900 | tid_to_dscp[tid], VI_QOS_TMP_FILE, VI_QOS_FILE); |
| 1901 | if (system(buf) != 0) { |
| 1902 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 1903 | "Append TID to VI_QOS_FILE failed "); |
| 1904 | } |
| 1905 | |
| 1906 | snprintf(buf, sizeof(buf), "ethinject %s %s", ifname, VI_QOS_FILE); |
| 1907 | if (system(buf) != 0) |
| 1908 | sigma_dut_print(dut, DUT_MSG_ERROR, "Ethinject frame failed"); |
| 1909 | } |
| 1910 | |
| 1911 | |
| 1912 | static int ath_ap_send_addba_req(struct sigma_dut *dut, struct sigma_conn *conn, |
| 1913 | struct sigma_cmd *cmd) |
| 1914 | { |
| 1915 | const char *val; |
Jouni Malinen | 016ae6c | 2019-11-04 17:00:01 +0200 | [diff] [blame] | 1916 | const char *ifname; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1917 | char buf[256]; |
| 1918 | int tid = 0; |
| 1919 | |
Jouni Malinen | 016ae6c | 2019-11-04 17:00:01 +0200 | [diff] [blame] | 1920 | ifname = get_main_ifname(dut); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1921 | val = get_param(cmd, "TID"); |
| 1922 | if (val) { |
| 1923 | tid = atoi(val); |
| 1924 | if (tid) |
| 1925 | ath_inject_frame(dut, ifname, tid); |
| 1926 | } |
| 1927 | |
| 1928 | /* NOTE: This is the command sequence on Peregrine for ADDBA */ |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 1929 | run_iwpriv(dut, ifname, "setaddbaoper 1"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1930 | |
| 1931 | snprintf(buf, sizeof(buf), "wifitool %s senddelba 1 %d 1 4", |
| 1932 | ifname, tid); |
| 1933 | if (system(buf) != 0) { |
| 1934 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 1935 | "wifitool senddelba failed"); |
| 1936 | } |
| 1937 | |
| 1938 | snprintf(buf, sizeof(buf), "wifitool %s sendaddba 1 %d 64", |
| 1939 | ifname, tid); |
| 1940 | if (system(buf) != 0) { |
| 1941 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 1942 | "wifitool sendaddba failed"); |
| 1943 | } |
| 1944 | |
| 1945 | return 1; |
| 1946 | } |
| 1947 | |
| 1948 | |
Mohammed Shafi Shajakhan | a0535d4 | 2016-06-17 11:55:00 +0530 | [diff] [blame] | 1949 | static int ath10k_debug_enable_addba_req(struct sigma_dut *dut, int tid, |
| 1950 | const char *sta_mac, |
| 1951 | const char *dir_path) |
| 1952 | { |
| 1953 | DIR *dir; |
| 1954 | struct dirent *entry; |
| 1955 | char buf[128], path[128]; |
Jouni Malinen | 3aa7286 | 2019-05-29 23:14:51 +0300 | [diff] [blame] | 1956 | int ret = 0, res; |
Mohammed Shafi Shajakhan | a0535d4 | 2016-06-17 11:55:00 +0530 | [diff] [blame] | 1957 | |
| 1958 | dir = opendir(dir_path); |
| 1959 | if (!dir) |
| 1960 | return 0; |
| 1961 | |
| 1962 | while ((entry = readdir(dir))) { |
| 1963 | ret = 1; |
| 1964 | |
| 1965 | if (strcmp(entry->d_name, ".") == 0 || |
| 1966 | strcmp(entry->d_name, "..") == 0) |
| 1967 | continue; |
| 1968 | |
Jouni Malinen | 3aa7286 | 2019-05-29 23:14:51 +0300 | [diff] [blame] | 1969 | res = snprintf(path, sizeof(path) - 1, "%s/%s", |
| 1970 | dir_path, entry->d_name); |
| 1971 | if (res < 0 || res >= sizeof(path)) |
| 1972 | continue; |
Mohammed Shafi Shajakhan | a0535d4 | 2016-06-17 11:55:00 +0530 | [diff] [blame] | 1973 | |
| 1974 | if (strcmp(entry->d_name, sta_mac) == 0) { |
Jouni Malinen | 3aa7286 | 2019-05-29 23:14:51 +0300 | [diff] [blame] | 1975 | res = snprintf(buf, sizeof(buf), |
| 1976 | "echo 1 > %s/aggr_mode", path); |
| 1977 | if (res < 0 || res >= sizeof(buf) || system(buf) != 0) { |
Mohammed Shafi Shajakhan | a0535d4 | 2016-06-17 11:55:00 +0530 | [diff] [blame] | 1978 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 1979 | "Failed to set aggr mode for ath10k"); |
| 1980 | } |
| 1981 | |
Jouni Malinen | 3aa7286 | 2019-05-29 23:14:51 +0300 | [diff] [blame] | 1982 | res = snprintf(buf, sizeof(buf), |
| 1983 | "echo %d 32 > %s/addba", tid, path); |
| 1984 | if (res < 0 || res >= sizeof(buf) || system(buf) != 0) { |
Mohammed Shafi Shajakhan | a0535d4 | 2016-06-17 11:55:00 +0530 | [diff] [blame] | 1985 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 1986 | "Failed to set addbareq for ath10k"); |
| 1987 | } |
| 1988 | |
| 1989 | break; |
| 1990 | } |
| 1991 | |
| 1992 | /* Recursively search subdirectories */ |
| 1993 | ath10k_debug_enable_addba_req(dut, tid, sta_mac, path); |
| 1994 | } |
| 1995 | |
| 1996 | closedir(dir); |
| 1997 | |
| 1998 | return ret; |
| 1999 | } |
| 2000 | |
| 2001 | |
| 2002 | static int ath10k_ap_send_addba_req(struct sigma_dut *dut, |
| 2003 | struct sigma_cmd *cmd) |
| 2004 | { |
| 2005 | const char *val; |
| 2006 | int tid = 0; |
| 2007 | |
| 2008 | val = get_param(cmd, "TID"); |
| 2009 | if (val) |
| 2010 | tid = atoi(val); |
| 2011 | |
| 2012 | val = get_param(cmd, "sta_mac_address"); |
| 2013 | if (!val) { |
| 2014 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 2015 | "Failed to parse station MAC address"); |
| 2016 | return 0; |
| 2017 | } |
| 2018 | |
| 2019 | return ath10k_debug_enable_addba_req(dut, tid, val, |
| 2020 | "/sys/kernel/debug/ieee80211"); |
| 2021 | } |
| 2022 | |
| 2023 | |
Jouni Malinen | f722271 | 2019-06-13 01:50:21 +0300 | [diff] [blame] | 2024 | static enum sigma_cmd_result cmd_ap_send_addba_req(struct sigma_dut *dut, |
| 2025 | struct sigma_conn *conn, |
| 2026 | struct sigma_cmd *cmd) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2027 | { |
| 2028 | /* const char *name = get_param(cmd, "NAME"); */ |
| 2029 | /* const char *ifname = get_param(cmd, "INTERFACE"); */ |
Mohammed Shafi Shajakhan | a0535d4 | 2016-06-17 11:55:00 +0530 | [diff] [blame] | 2030 | struct stat s; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2031 | |
Jouni Malinen | 016ae6c | 2019-11-04 17:00:01 +0200 | [diff] [blame] | 2032 | switch (get_driver_type(dut)) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2033 | case DRIVER_ATHEROS: |
| 2034 | return ath_ap_send_addba_req(dut, conn, cmd); |
Alexei Avshalom Lazar | 79fa3fe | 2018-12-24 15:43:33 +0200 | [diff] [blame] | 2035 | #ifdef __linux__ |
| 2036 | case DRIVER_WIL6210: |
| 2037 | return send_addba_60g(dut, conn, cmd, "sta_mac_address"); |
| 2038 | #endif /* __linux__ */ |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2039 | case DRIVER_OPENWRT: |
| 2040 | switch (get_openwrt_driver_type()) { |
| 2041 | case OPENWRT_DRIVER_ATHEROS: |
| 2042 | return ath_ap_send_addba_req(dut, conn, cmd); |
| 2043 | default: |
| 2044 | send_resp(dut, conn, SIGMA_ERROR, |
| 2045 | "errorCode,ap_send_addba_req not supported with this driver"); |
| 2046 | return 0; |
| 2047 | } |
Pradeep Reddy POTTETI | fdb0491 | 2016-08-02 14:16:24 +0530 | [diff] [blame] | 2048 | case DRIVER_WCN: |
| 2049 | case DRIVER_LINUX_WCN: |
| 2050 | /* AP automatically sends ADDBA request after association. */ |
| 2051 | sigma_dut_print(dut, DUT_MSG_INFO, |
| 2052 | "ap_send_addba_req command ignored"); |
| 2053 | return 1; |
Mohammed Shafi Shajakhan | a0535d4 | 2016-06-17 11:55:00 +0530 | [diff] [blame] | 2054 | case DRIVER_MAC80211: |
| 2055 | if (stat("/sys/module/ath10k_core", &s) == 0) |
| 2056 | return ath10k_ap_send_addba_req(dut, cmd); |
| 2057 | /* fall through */ |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2058 | default: |
| 2059 | send_resp(dut, conn, SIGMA_ERROR, |
| 2060 | "errorCode,ap_send_addba_req not supported with this driver"); |
| 2061 | return 0; |
| 2062 | } |
| 2063 | } |
| 2064 | |
| 2065 | |
Jouni Malinen | f722271 | 2019-06-13 01:50:21 +0300 | [diff] [blame] | 2066 | static enum sigma_cmd_result cmd_ap_set_security(struct sigma_dut *dut, |
| 2067 | struct sigma_conn *conn, |
| 2068 | struct sigma_cmd *cmd) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2069 | { |
| 2070 | /* const char *name = get_param(cmd, "NAME"); */ |
| 2071 | const char *val; |
| 2072 | unsigned int wlan_tag = 1; |
Ankita Bajaj | 0d212e8 | 2017-11-27 15:54:57 +0530 | [diff] [blame] | 2073 | const char *security; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2074 | |
| 2075 | val = get_param(cmd, "WLAN_TAG"); |
| 2076 | if (val) |
| 2077 | wlan_tag = atoi(val); |
| 2078 | |
Ankita Bajaj | 0d212e8 | 2017-11-27 15:54:57 +0530 | [diff] [blame] | 2079 | security = get_param(cmd, "Security"); |
| 2080 | |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 2081 | if (wlan_tag > 1) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2082 | val = get_param(cmd, "KEYMGNT"); |
Ankita Bajaj | 0d212e8 | 2017-11-27 15:54:57 +0530 | [diff] [blame] | 2083 | if (!val) |
| 2084 | val = get_param(cmd, "KeyMgmtType"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2085 | if (val) { |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 2086 | if (strcasecmp(val, "NONE") == 0) { |
| 2087 | dut->ap_tag_key_mgmt[wlan_tag - 2] = AP2_OPEN; |
| 2088 | } else if (strcasecmp(val, "OSEN") == 0 && |
| 2089 | wlan_tag == 2) { |
| 2090 | /* |
| 2091 | * OSEN only supported on WLAN_TAG = 2 for now |
| 2092 | */ |
| 2093 | dut->ap_tag_key_mgmt[wlan_tag - 2] = AP2_OSEN; |
Ankita Bajaj | 0d212e8 | 2017-11-27 15:54:57 +0530 | [diff] [blame] | 2094 | } else if (strcasecmp(val, "WPA2-PSK") == 0 || |
| 2095 | (security && |
| 2096 | strcasecmp(security, "PSK") == 0 && |
| 2097 | strcasecmp(val, "WPA2") == 0)) { |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 2098 | dut->ap_tag_key_mgmt[wlan_tag - 2] = |
| 2099 | AP2_WPA2_PSK; |
Jouni Malinen | 353ba8b | 2018-01-10 17:04:12 +0200 | [diff] [blame] | 2100 | } else if (strcasecmp(val, "OWE") == 0 && |
| 2101 | wlan_tag == 2) { |
| 2102 | dut->ap_tag_key_mgmt[wlan_tag - 2] = |
| 2103 | AP2_WPA2_OWE; |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 2104 | } else { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2105 | send_resp(dut, conn, SIGMA_INVALID, |
| 2106 | "errorCode,Unsupported KEYMGNT"); |
| 2107 | return 0; |
| 2108 | } |
| 2109 | return 1; |
| 2110 | } |
| 2111 | } |
| 2112 | |
| 2113 | val = get_param(cmd, "KEYMGNT"); |
Ankita Bajaj | 0d212e8 | 2017-11-27 15:54:57 +0530 | [diff] [blame] | 2114 | if (!val) |
| 2115 | val = get_param(cmd,"KeyMgmtType"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2116 | if (val) { |
Ankita Bajaj | 0d212e8 | 2017-11-27 15:54:57 +0530 | [diff] [blame] | 2117 | if (strcasecmp(val, "WPA2-PSK") == 0 || |
| 2118 | (security && strcasecmp(security, "PSK") == 0 && |
| 2119 | strcasecmp(val, "WPA2") == 0)) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2120 | dut->ap_key_mgmt = AP_WPA2_PSK; |
| 2121 | dut->ap_cipher = AP_CCMP; |
| 2122 | } else if (strcasecmp(val, "WPA2-EAP") == 0 || |
| 2123 | strcasecmp(val, "WPA2-Ent") == 0) { |
| 2124 | dut->ap_key_mgmt = AP_WPA2_EAP; |
| 2125 | dut->ap_cipher = AP_CCMP; |
Jouni Malinen | ad395a2 | 2017-09-01 21:13:46 +0300 | [diff] [blame] | 2126 | } else if (strcasecmp(val, "SuiteB") == 0) { |
| 2127 | dut->ap_key_mgmt = AP_SUITEB; |
| 2128 | dut->ap_cipher = AP_GCMP_256; |
Jouni Malinen | d75e4d8 | 2018-01-11 20:21:15 +0200 | [diff] [blame] | 2129 | dut->ap_pmf = AP_PMF_REQUIRED; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2130 | } else if (strcasecmp(val, "WPA-PSK") == 0) { |
| 2131 | dut->ap_key_mgmt = AP_WPA_PSK; |
| 2132 | dut->ap_cipher = AP_TKIP; |
| 2133 | } else if (strcasecmp(val, "WPA-EAP") == 0 || |
| 2134 | strcasecmp(val, "WPA-Ent") == 0) { |
| 2135 | dut->ap_key_mgmt = AP_WPA_EAP; |
| 2136 | dut->ap_cipher = AP_TKIP; |
| 2137 | } else if (strcasecmp(val, "WPA2-Mixed") == 0) { |
| 2138 | dut->ap_key_mgmt = AP_WPA2_EAP_MIXED; |
| 2139 | dut->ap_cipher = AP_CCMP_TKIP; |
| 2140 | } else if (strcasecmp(val, "WPA2-PSK-Mixed") == 0) { |
| 2141 | dut->ap_key_mgmt = AP_WPA2_PSK_MIXED; |
| 2142 | dut->ap_cipher = AP_CCMP_TKIP; |
Jouni Malinen | 794a7a3 | 2018-01-10 16:39:34 +0200 | [diff] [blame] | 2143 | } else if (strcasecmp(val, "WPA2-SAE") == 0 || |
| 2144 | strcasecmp(val, "SAE") == 0) { |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 2145 | dut->ap_key_mgmt = AP_WPA2_SAE; |
| 2146 | dut->ap_cipher = AP_CCMP; |
Jouni Malinen | 1287cd7 | 2018-01-04 17:08:01 +0200 | [diff] [blame] | 2147 | dut->ap_pmf = AP_PMF_REQUIRED; |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 2148 | } else if (strcasecmp(val, "WPA2-PSK-SAE") == 0) { |
| 2149 | dut->ap_key_mgmt = AP_WPA2_PSK_SAE; |
| 2150 | dut->ap_cipher = AP_CCMP; |
Jouni Malinen | 1287cd7 | 2018-01-04 17:08:01 +0200 | [diff] [blame] | 2151 | dut->ap_pmf = AP_PMF_OPTIONAL; |
Jouni Malinen | 147b3c3 | 2017-10-09 16:51:54 +0300 | [diff] [blame] | 2152 | } else if (strcasecmp(val, "OWE") == 0) { |
| 2153 | dut->ap_key_mgmt = AP_WPA2_OWE; |
| 2154 | dut->ap_cipher = AP_CCMP; |
Jouni Malinen | 1287cd7 | 2018-01-04 17:08:01 +0200 | [diff] [blame] | 2155 | dut->ap_pmf = AP_PMF_REQUIRED; |
Jouni Malinen | 4cf699f | 2018-06-19 00:46:27 +0300 | [diff] [blame] | 2156 | } else if (strcasecmp(val, "WPA2-ENT-OSEN") == 0) { |
| 2157 | dut->ap_key_mgmt = AP_WPA2_EAP_OSEN; |
| 2158 | dut->ap_cipher = AP_CCMP; |
| 2159 | dut->ap_pmf = AP_PMF_OPTIONAL; |
Jouni Malinen | c2b9121 | 2018-09-12 02:26:39 +0300 | [diff] [blame] | 2160 | } else if (strcasecmp(val, "OSEN") == 0) { |
| 2161 | dut->ap_key_mgmt = AP_OSEN; |
| 2162 | dut->ap_cipher = AP_CCMP; |
Jouni Malinen | 6be21c8 | 2018-08-01 18:47:24 +0300 | [diff] [blame] | 2163 | } else if (strcasecmp(val, "FT-EAP") == 0) { |
| 2164 | dut->ap_key_mgmt = AP_WPA2_FT_EAP; |
| 2165 | dut->ap_cipher = AP_CCMP; |
| 2166 | dut->ap_pmf = AP_PMF_OPTIONAL; |
| 2167 | } else if (strcasecmp(val, "FT-PSK") == 0) { |
| 2168 | dut->ap_key_mgmt = AP_WPA2_FT_PSK; |
| 2169 | dut->ap_cipher = AP_CCMP; |
| 2170 | dut->ap_pmf = AP_PMF_OPTIONAL; |
| 2171 | } else if (strcasecmp(val, "WPA2-ENT-256") == 0) { |
| 2172 | dut->ap_key_mgmt = AP_WPA2_EAP_SHA256; |
| 2173 | dut->ap_cipher = AP_CCMP; |
| 2174 | dut->ap_pmf = AP_PMF_OPTIONAL; |
| 2175 | } else if (strcasecmp(val, "WPA2-PSK-256") == 0) { |
| 2176 | dut->ap_key_mgmt = AP_WPA2_PSK_SHA256; |
| 2177 | dut->ap_cipher = AP_CCMP; |
| 2178 | dut->ap_pmf = AP_PMF_OPTIONAL; |
| 2179 | } else if (strcasecmp(val, "WPA2-ENT-FT-EAP") == 0) { |
| 2180 | dut->ap_key_mgmt = AP_WPA2_ENT_FT_EAP; |
| 2181 | dut->ap_cipher = AP_CCMP; |
| 2182 | dut->ap_pmf = AP_PMF_OPTIONAL; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2183 | } else if (strcasecmp(val, "NONE") == 0) { |
| 2184 | dut->ap_key_mgmt = AP_OPEN; |
| 2185 | dut->ap_cipher = AP_PLAIN; |
| 2186 | } else { |
| 2187 | send_resp(dut, conn, SIGMA_INVALID, |
| 2188 | "errorCode,Unsupported KEYMGNT"); |
| 2189 | return 0; |
| 2190 | } |
| 2191 | } |
| 2192 | |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 2193 | val = get_param(cmd, "ECGroupID"); |
| 2194 | if (val) { |
Jouni Malinen | ed670f4 | 2017-08-31 01:39:28 +0300 | [diff] [blame] | 2195 | free(dut->ap_sae_groups); |
| 2196 | dut->ap_sae_groups = strdup(val); |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 2197 | } |
| 2198 | |
Jouni Malinen | 2f524ce | 2017-08-31 01:43:29 +0300 | [diff] [blame] | 2199 | val = get_param(cmd, "AntiCloggingThreshold"); |
| 2200 | if (val) |
| 2201 | dut->sae_anti_clogging_threshold = atoi(val); |
| 2202 | |
Jouni Malinen | b347db0 | 2017-09-02 01:36:03 +0300 | [diff] [blame] | 2203 | val = get_param(cmd, "Reflection"); |
| 2204 | if (val) |
| 2205 | dut->sae_reflection = strcasecmp(val, "SAE") == 0; |
| 2206 | |
Jouni Malinen | 6814313 | 2017-09-02 02:34:08 +0300 | [diff] [blame] | 2207 | val = get_param(cmd, "InvalidSAEElement"); |
| 2208 | if (val) { |
| 2209 | free(dut->sae_commit_override); |
| 2210 | dut->sae_commit_override = strdup(val); |
| 2211 | } |
| 2212 | |
Jouni Malinen | 09550de | 2019-03-26 00:24:11 +0200 | [diff] [blame] | 2213 | val = get_param(cmd, "SAEPasswords"); |
| 2214 | if (val) { |
| 2215 | free(dut->ap_sae_passwords); |
| 2216 | dut->ap_sae_passwords = strdup(val); |
| 2217 | } |
| 2218 | |
Jouni Malinen | 3c740ab | 2019-10-10 15:55:11 +0300 | [diff] [blame] | 2219 | val = get_param(cmd, "SAE_Confirm_Immediate"); |
| 2220 | if (val) |
| 2221 | dut->sae_confirm_immediate = get_enable_disable(val); |
| 2222 | |
Jouni Malinen | 11e5521 | 2019-11-22 21:46:59 +0200 | [diff] [blame] | 2223 | val = get_param(cmd, "sae_pwe"); |
| 2224 | if (val) { |
| 2225 | if (strcasecmp(val, "h2e") == 0) { |
| 2226 | dut->sae_pwe = SAE_PWE_H2E; |
Jouni Malinen | 7244a41 | 2019-12-07 11:54:10 +0200 | [diff] [blame] | 2227 | } else if (strcasecmp(val, "loop") == 0 || |
| 2228 | strcasecmp(val, "looping") == 0) { |
Jouni Malinen | 11e5521 | 2019-11-22 21:46:59 +0200 | [diff] [blame] | 2229 | dut->sae_pwe = SAE_PWE_LOOP; |
| 2230 | } else { |
| 2231 | send_resp(dut, conn, SIGMA_ERROR, |
| 2232 | "errorCode,Unsupported sae_pwe value"); |
| 2233 | return STATUS_SENT_ERROR; |
| 2234 | } |
| 2235 | } |
| 2236 | |
Jouni Malinen | 7960e3a | 2019-12-07 17:04:35 +0200 | [diff] [blame] | 2237 | val = get_param(cmd, "RSNXE_Content"); |
| 2238 | if (val) { |
| 2239 | if (strncasecmp(val, "EapolM3:", 8) != 0) { |
| 2240 | send_resp(dut, conn, SIGMA_ERROR, |
| 2241 | "errorCode,Unsupported RSNXE_Content value"); |
| 2242 | return STATUS_SENT_ERROR; |
| 2243 | } |
| 2244 | val += 8; |
| 2245 | free(dut->rsnxe_override_eapol); |
| 2246 | dut->rsnxe_override_eapol = strdup(val); |
| 2247 | } |
| 2248 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2249 | val = get_param(cmd, "ENCRYPT"); |
Ankita Bajaj | 0d212e8 | 2017-11-27 15:54:57 +0530 | [diff] [blame] | 2250 | if (!val) |
| 2251 | val = get_param(cmd, "EncpType"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2252 | if (val) { |
| 2253 | if (strcasecmp(val, "WEP") == 0) { |
| 2254 | dut->ap_cipher = AP_WEP; |
| 2255 | } else if (strcasecmp(val, "TKIP") == 0) { |
| 2256 | dut->ap_cipher = AP_TKIP; |
| 2257 | } else if (strcasecmp(val, "AES") == 0 || |
| 2258 | strcasecmp(val, "AES-CCMP") == 0) { |
| 2259 | dut->ap_cipher = AP_CCMP; |
Jouni Malinen | 3d633da | 2017-09-14 22:19:21 +0300 | [diff] [blame] | 2260 | } else if (strcasecmp(val, "AES-GCMP") == 0) { |
| 2261 | dut->ap_cipher = AP_GCMP_128; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2262 | } else { |
| 2263 | send_resp(dut, conn, SIGMA_INVALID, |
| 2264 | "errorCode,Unsupported ENCRYPT"); |
| 2265 | return 0; |
| 2266 | } |
| 2267 | } |
| 2268 | |
Jouni Malinen | 3d633da | 2017-09-14 22:19:21 +0300 | [diff] [blame] | 2269 | val = get_param(cmd, "PairwiseCipher"); |
| 2270 | if (val) { |
| 2271 | if (strcasecmp(val, "AES-GCMP-256") == 0) { |
| 2272 | dut->ap_cipher = AP_GCMP_256; |
| 2273 | } else if (strcasecmp(val, "AES-CCMP-256") == 0) { |
| 2274 | dut->ap_cipher = AP_CCMP_256; |
| 2275 | } else if (strcasecmp(val, "AES-GCMP-128") == 0) { |
| 2276 | dut->ap_cipher = AP_GCMP_128; |
| 2277 | } else if (strcasecmp(val, "AES-CCMP-128") == 0) { |
| 2278 | dut->ap_cipher = AP_CCMP; |
Jouni Malinen | d538c78 | 2017-11-17 12:13:04 +0200 | [diff] [blame] | 2279 | } else if (strcasecmp(val, "AES-CCMP-128 AES-GCMP-256") == 0 || |
| 2280 | strcasecmp(val, "AES-GCMP-256 AES-CCMP-128") == 0) { |
| 2281 | dut->ap_cipher = AP_CCMP_128_GCMP_256; |
Jouni Malinen | 3d633da | 2017-09-14 22:19:21 +0300 | [diff] [blame] | 2282 | } else { |
| 2283 | send_resp(dut, conn, SIGMA_INVALID, |
| 2284 | "errorCode,Unsupported PairwiseCipher"); |
| 2285 | return 0; |
| 2286 | } |
| 2287 | } |
| 2288 | |
Jouni Malinen | 2ba2449 | 2017-11-17 12:43:59 +0200 | [diff] [blame] | 2289 | val = get_param(cmd, "GroupCipher"); |
| 2290 | if (val) { |
| 2291 | if (strcasecmp(val, "AES-GCMP-256") == 0) { |
| 2292 | dut->ap_group_cipher = AP_GCMP_256; |
| 2293 | } else if (strcasecmp(val, "AES-CCMP-256") == 0) { |
| 2294 | dut->ap_group_cipher = AP_CCMP_256; |
| 2295 | } else if (strcasecmp(val, "AES-GCMP-128") == 0) { |
| 2296 | dut->ap_group_cipher = AP_GCMP_128; |
| 2297 | } else if (strcasecmp(val, "AES-CCMP-128") == 0) { |
| 2298 | dut->ap_group_cipher = AP_CCMP; |
| 2299 | } else { |
| 2300 | send_resp(dut, conn, SIGMA_INVALID, |
| 2301 | "errorCode,Unsupported GroupCipher"); |
| 2302 | return 0; |
| 2303 | } |
| 2304 | } |
| 2305 | |
Jouni Malinen | 3d633da | 2017-09-14 22:19:21 +0300 | [diff] [blame] | 2306 | val = get_param(cmd, "GroupMgntCipher"); |
| 2307 | if (val) { |
| 2308 | if (strcasecmp(val, "BIP-GMAC-256") == 0) { |
| 2309 | dut->ap_group_mgmt_cipher = AP_BIP_GMAC_256; |
| 2310 | } else if (strcasecmp(val, "BIP-CMAC-256") == 0) { |
| 2311 | dut->ap_group_mgmt_cipher = AP_BIP_CMAC_256; |
| 2312 | } else if (strcasecmp(val, "BIP-GMAC-128") == 0) { |
| 2313 | dut->ap_group_mgmt_cipher = AP_BIP_GMAC_128; |
| 2314 | } else if (strcasecmp(val, "BIP-CMAC-128") == 0) { |
| 2315 | dut->ap_group_mgmt_cipher = AP_BIP_CMAC_128; |
| 2316 | } else { |
| 2317 | send_resp(dut, conn, SIGMA_INVALID, |
| 2318 | "errorCode,Unsupported GroupMgntCipher"); |
| 2319 | return 0; |
| 2320 | } |
| 2321 | } |
| 2322 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2323 | val = get_param(cmd, "WEPKEY"); |
| 2324 | if (val) { |
| 2325 | size_t len; |
| 2326 | if (dut->ap_cipher != AP_WEP) { |
| 2327 | send_resp(dut, conn, SIGMA_INVALID, |
| 2328 | "errorCode,Unexpected WEPKEY without WEP " |
| 2329 | "configuration"); |
| 2330 | return 0; |
| 2331 | } |
| 2332 | len = strlen(val); |
| 2333 | if (len != 10 && len != 26) { |
| 2334 | send_resp(dut, conn, SIGMA_INVALID, |
| 2335 | "errorCode,Unexpected WEPKEY length"); |
| 2336 | return 0; |
| 2337 | } |
| 2338 | snprintf(dut->ap_wepkey, sizeof(dut->ap_wepkey), "%s", val); |
| 2339 | } |
| 2340 | |
| 2341 | val = get_param(cmd, "PSK"); |
Ankita Bajaj | 0d212e8 | 2017-11-27 15:54:57 +0530 | [diff] [blame] | 2342 | if (!val) |
| 2343 | val = get_param(cmd, "passphrase"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2344 | if (val) { |
Jouni Malinen | da5f35b | 2019-03-26 00:25:53 +0200 | [diff] [blame] | 2345 | if (dut->ap_key_mgmt != AP_WPA2_SAE && |
| 2346 | (dut->ap_akm_values & (AKM_WPA_PSK | AKM_SAE)) != |
| 2347 | AKM_SAE && |
| 2348 | strlen(val) > 64) { |
| 2349 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 2350 | "Too long PSK/passphtase"); |
Jouni Malinen | 2126f42 | 2017-10-11 23:24:33 +0300 | [diff] [blame] | 2351 | return -1; |
Jouni Malinen | da5f35b | 2019-03-26 00:25:53 +0200 | [diff] [blame] | 2352 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2353 | if (strlen(val) > sizeof(dut->ap_passphrase) - 1) |
| 2354 | return -1; |
| 2355 | snprintf(dut->ap_passphrase, sizeof(dut->ap_passphrase), |
| 2356 | "%s", val); |
| 2357 | } |
| 2358 | |
Jouni Malinen | 6337062 | 2017-11-18 17:47:13 +0200 | [diff] [blame] | 2359 | val = get_param(cmd, "PSKHEX"); |
| 2360 | if (val) { |
| 2361 | if (strlen(val) != 64) |
| 2362 | return -1; |
| 2363 | strlcpy(dut->ap_psk, val, sizeof(dut->ap_psk)); |
| 2364 | } |
| 2365 | |
Ankita Bajaj | 0d212e8 | 2017-11-27 15:54:57 +0530 | [diff] [blame] | 2366 | if (dut->program == PROGRAM_OCE && dut->dev_role == DEVROLE_STA_CFON) |
| 2367 | dut->ap_pmf = AP_PMF_OPTIONAL; |
| 2368 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2369 | val = get_param(cmd, "PMF"); |
| 2370 | if (val) { |
| 2371 | if (strcasecmp(val, "Disabled") == 0) { |
| 2372 | dut->ap_pmf = AP_PMF_DISABLED; |
| 2373 | } else if (strcasecmp(val, "Optional") == 0) { |
| 2374 | dut->ap_pmf = AP_PMF_OPTIONAL; |
| 2375 | } else if (strcasecmp(val, "Required") == 0) { |
| 2376 | dut->ap_pmf = AP_PMF_REQUIRED; |
| 2377 | } else { |
| 2378 | send_resp(dut, conn, SIGMA_INVALID, |
| 2379 | "errorCode,Unsupported PMF"); |
| 2380 | return 0; |
| 2381 | } |
| 2382 | } |
| 2383 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2384 | dut->ap_add_sha256 = 0; |
| 2385 | val = get_param(cmd, "SHA256AD"); |
| 2386 | if (val == NULL) |
| 2387 | val = get_param(cmd, "SHA256"); |
| 2388 | if (val) { |
| 2389 | if (strcasecmp(val, "Disabled") == 0) { |
| 2390 | } else if (strcasecmp(val, "Enabled") == 0) { |
| 2391 | dut->ap_add_sha256 = 1; |
| 2392 | } else { |
| 2393 | send_resp(dut, conn, SIGMA_INVALID, |
Jouni Malinen | a7fa620 | 2019-03-26 00:22:10 +0200 | [diff] [blame] | 2394 | "errorCode,Unsupported SHA256"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2395 | return 0; |
| 2396 | } |
| 2397 | } |
| 2398 | |
Sarvepalli, Rajesh Babu | 24dc7e4 | 2016-03-18 21:27:26 +0530 | [diff] [blame] | 2399 | val = get_param(cmd, "PreAuthentication"); |
| 2400 | if (val) { |
| 2401 | if (strcasecmp(val, "disabled") == 0) { |
| 2402 | dut->ap_rsn_preauth = 0; |
| 2403 | } else if (strcasecmp(val, "enabled") == 0) { |
| 2404 | dut->ap_rsn_preauth = 1; |
| 2405 | } else { |
| 2406 | send_resp(dut, conn, SIGMA_INVALID, |
| 2407 | "errorCode,Unsupported PreAuthentication value"); |
| 2408 | return 0; |
| 2409 | } |
| 2410 | } |
| 2411 | |
priyadharshini gowthaman | de81f39 | 2017-12-28 15:28:49 -0800 | [diff] [blame] | 2412 | val = get_param(cmd, "AKMSuiteType"); |
| 2413 | if (val) { |
Jouni Malinen | da5f35b | 2019-03-26 00:25:53 +0200 | [diff] [blame] | 2414 | const char *in_pos = val; |
priyadharshini gowthaman | de81f39 | 2017-12-28 15:28:49 -0800 | [diff] [blame] | 2415 | |
Jouni Malinen | da5f35b | 2019-03-26 00:25:53 +0200 | [diff] [blame] | 2416 | dut->ap_akm_values = 0; |
| 2417 | while (*in_pos) { |
| 2418 | int akm = atoi(in_pos); |
| 2419 | |
| 2420 | if (akm < 0 || akm >= 32) { |
| 2421 | send_resp(dut, conn, SIGMA_ERROR, |
| 2422 | "errorCode,Unsupported AKMSuiteType value"); |
| 2423 | return STATUS_SENT; |
| 2424 | } |
| 2425 | |
| 2426 | dut->ap_akm_values |= 1 << akm; |
| 2427 | |
| 2428 | in_pos = strchr(in_pos, ';'); |
| 2429 | if (!in_pos) |
| 2430 | break; |
| 2431 | while (*in_pos == ';') |
| 2432 | in_pos++; |
priyadharshini gowthaman | de81f39 | 2017-12-28 15:28:49 -0800 | [diff] [blame] | 2433 | } |
Jouni Malinen | da5f35b | 2019-03-26 00:25:53 +0200 | [diff] [blame] | 2434 | dut->ap_akm = 1; |
| 2435 | if (dut->ap_akm_values & (1 << 14)) |
| 2436 | dut->ap_add_sha384 = 1; |
| 2437 | if (dut->ap_akm_values & (1 << 15)) |
| 2438 | dut->ap_add_sha384 = 1; |
| 2439 | } |
| 2440 | |
| 2441 | if (dut->ap_key_mgmt == AP_OPEN && !dut->ap_akm_values) { |
| 2442 | dut->ap_hs2 = 0; |
| 2443 | dut->ap_pmf = AP_PMF_DISABLED; |
priyadharshini gowthaman | de81f39 | 2017-12-28 15:28:49 -0800 | [diff] [blame] | 2444 | } |
| 2445 | |
| 2446 | val = get_param(cmd, "PMKSACaching"); |
| 2447 | if (val) { |
| 2448 | dut->ap_pmksa = 1; |
| 2449 | if (strcasecmp(val, "disabled") == 0) { |
| 2450 | dut->ap_pmksa_caching = 1; |
| 2451 | } else if (strcasecmp(val, "enabled") == 0) { |
| 2452 | dut->ap_pmksa_caching = 0; |
| 2453 | } else { |
| 2454 | send_resp(dut, conn, SIGMA_INVALID, |
| 2455 | "errorCode,Unsupported PMKSACaching value"); |
| 2456 | return 0; |
| 2457 | } |
| 2458 | } |
| 2459 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2460 | return 1; |
| 2461 | } |
| 2462 | |
| 2463 | |
Ankita Bajaj | 0d5825b | 2017-10-25 16:20:17 +0530 | [diff] [blame] | 2464 | int sta_cfon_set_wireless(struct sigma_dut *dut, struct sigma_conn *conn, |
| 2465 | struct sigma_cmd *cmd) |
| 2466 | { |
| 2467 | int status; |
| 2468 | |
| 2469 | status = cmd_ap_set_wireless(dut, conn, cmd); |
| 2470 | if (status != 1) |
| 2471 | return status; |
Ankita Bajaj | 0d212e8 | 2017-11-27 15:54:57 +0530 | [diff] [blame] | 2472 | status = cmd_ap_set_security(dut, conn, cmd); |
| 2473 | if (status != 1) |
| 2474 | return status; |
Ankita Bajaj | 0d5825b | 2017-10-25 16:20:17 +0530 | [diff] [blame] | 2475 | return cmd_ap_config_commit(dut, conn, cmd); |
| 2476 | } |
| 2477 | |
| 2478 | |
Jouni Malinen | f722271 | 2019-06-13 01:50:21 +0300 | [diff] [blame] | 2479 | static enum sigma_cmd_result cmd_ap_set_radius(struct sigma_dut *dut, |
| 2480 | struct sigma_conn *conn, |
| 2481 | struct sigma_cmd *cmd) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2482 | { |
| 2483 | /* const char *name = get_param(cmd, "NAME"); */ |
| 2484 | const char *val; |
| 2485 | unsigned int wlan_tag = 1, radius_port = 0; |
| 2486 | char *radius_ipaddr = NULL, *radius_password = NULL; |
| 2487 | |
| 2488 | val = get_param(cmd, "WLAN_TAG"); |
| 2489 | if (val) { |
| 2490 | wlan_tag = atoi(val); |
| 2491 | if (wlan_tag != 1 && wlan_tag != 2) { |
| 2492 | send_resp(dut, conn, SIGMA_INVALID, |
| 2493 | "errorCode,Invalid WLAN_TAG"); |
| 2494 | return 0; |
| 2495 | } |
| 2496 | } |
| 2497 | |
| 2498 | val = get_param(cmd, "PORT"); |
| 2499 | if (val) |
| 2500 | radius_port = atoi(val); |
| 2501 | |
| 2502 | if (wlan_tag == 1) { |
| 2503 | if (radius_port) |
| 2504 | dut->ap_radius_port = radius_port; |
| 2505 | radius_ipaddr = dut->ap_radius_ipaddr; |
| 2506 | radius_password = dut->ap_radius_password; |
| 2507 | } else if (wlan_tag == 2) { |
| 2508 | if (radius_port) |
| 2509 | dut->ap2_radius_port = radius_port; |
| 2510 | radius_ipaddr = dut->ap2_radius_ipaddr; |
| 2511 | radius_password = dut->ap2_radius_password; |
| 2512 | } |
| 2513 | |
| 2514 | val = get_param(cmd, "IPADDR"); |
| 2515 | if (val) { |
| 2516 | if (strlen(val) > sizeof(dut->ap_radius_ipaddr) - 1) |
| 2517 | return -1; |
| 2518 | snprintf(radius_ipaddr, sizeof(dut->ap_radius_ipaddr), |
| 2519 | "%s", val); |
| 2520 | } |
| 2521 | |
| 2522 | val = get_param(cmd, "PASSWORD"); |
| 2523 | if (val) { |
| 2524 | if (strlen(val) > sizeof(dut->ap_radius_password) - 1) |
| 2525 | return -1; |
| 2526 | snprintf(radius_password, |
| 2527 | sizeof(dut->ap_radius_password), "%s", val); |
| 2528 | } |
| 2529 | |
| 2530 | return 1; |
| 2531 | } |
| 2532 | |
| 2533 | |
Priyadharshini Gowthaman | 8018c98 | 2019-10-31 15:14:37 -0700 | [diff] [blame] | 2534 | static void owrt_ap_set_qcawifi(struct sigma_dut *dut, const char *key, |
| 2535 | const char *val) |
| 2536 | { |
| 2537 | if (!val) { |
| 2538 | run_system_wrapper(dut, "uci delete wireless.qcawifi.%s", key); |
| 2539 | return; |
| 2540 | } |
| 2541 | |
| 2542 | run_system(dut, "uci set wireless.qcawifi=qcawifi"); |
| 2543 | run_system_wrapper(dut, "uci set wireless.qcawifi.%s=%s", key, val); |
| 2544 | } |
| 2545 | |
| 2546 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2547 | static void owrt_ap_set_radio(struct sigma_dut *dut, int id, |
| 2548 | const char *key, const char *val) |
| 2549 | { |
| 2550 | char buf[100]; |
| 2551 | |
| 2552 | if (val == NULL) { |
| 2553 | snprintf(buf, sizeof(buf), |
| 2554 | "uci delete wireless.wifi%d.%s", id, key); |
| 2555 | run_system(dut, buf); |
| 2556 | return; |
| 2557 | } |
| 2558 | |
| 2559 | snprintf(buf, sizeof(buf), "uci set wireless.wifi%d.%s=%s", |
| 2560 | id, key, val); |
| 2561 | run_system(dut, buf); |
| 2562 | } |
| 2563 | |
| 2564 | |
| 2565 | static void owrt_ap_set_list_radio(struct sigma_dut *dut, int id, |
| 2566 | const char *key, const char *val) |
| 2567 | { |
| 2568 | char buf[256]; |
| 2569 | |
| 2570 | if (val == NULL) { |
| 2571 | snprintf(buf, sizeof(buf), |
| 2572 | "uci del_list wireless.wifi%d.%s", id, key); |
| 2573 | run_system(dut, buf); |
| 2574 | return; |
| 2575 | } |
| 2576 | |
| 2577 | snprintf(buf, sizeof(buf), "uci add_list wireless.wifi%d.%s=%s", |
| 2578 | id, key, val); |
| 2579 | run_system(dut, buf); |
| 2580 | } |
| 2581 | |
| 2582 | |
| 2583 | static void owrt_ap_set_vap(struct sigma_dut *dut, int id, const char *key, |
| 2584 | const char *val) |
| 2585 | { |
| 2586 | char buf[256]; |
| 2587 | |
| 2588 | if (val == NULL) { |
| 2589 | snprintf(buf, sizeof(buf), |
| 2590 | "uci delete wireless.@wifi-iface[%d].%s", id, key); |
| 2591 | run_system(dut, buf); |
| 2592 | return; |
| 2593 | } |
| 2594 | |
| 2595 | snprintf(buf, sizeof(buf), "uci set wireless.@wifi-iface[%d].%s=%s", |
| 2596 | id, key, val); |
| 2597 | run_system(dut, buf); |
| 2598 | } |
| 2599 | |
| 2600 | |
| 2601 | static void owrt_ap_set_list_vap(struct sigma_dut *dut, int id, |
| 2602 | const char *key, const char *val) |
| 2603 | { |
priyadharshini gowthaman | 2323d0a | 2016-09-02 15:48:02 -0700 | [diff] [blame] | 2604 | char buf[1024]; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2605 | |
| 2606 | if (val == NULL) { |
| 2607 | snprintf(buf, sizeof(buf), |
| 2608 | "uci del_list wireless.@wifi-iface[%d].%s", id, key); |
| 2609 | run_system(dut, buf); |
| 2610 | return; |
| 2611 | } |
| 2612 | |
| 2613 | snprintf(buf, sizeof(buf), |
| 2614 | "uci add_list wireless.@wifi-iface[%d].%s=%s", |
| 2615 | id, key, val); |
| 2616 | run_system(dut, buf); |
| 2617 | } |
| 2618 | |
| 2619 | |
| 2620 | static void owrt_ap_add_vap(struct sigma_dut *dut, int id, const char *key, |
| 2621 | const char *val) |
| 2622 | { |
| 2623 | char buf[256]; |
Jouni Malinen | 3aa7286 | 2019-05-29 23:14:51 +0300 | [diff] [blame] | 2624 | int res; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2625 | |
| 2626 | if (val == NULL) { |
Jouni Malinen | 3aa7286 | 2019-05-29 23:14:51 +0300 | [diff] [blame] | 2627 | res = snprintf(buf, sizeof(buf), |
| 2628 | "uci delete wireless.@wifi-iface[%d].%s", |
| 2629 | id, key); |
| 2630 | if (res >= 0 && res < sizeof(buf)) |
| 2631 | run_system(dut, buf); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2632 | return; |
| 2633 | } |
| 2634 | |
Jouni Malinen | 3aa7286 | 2019-05-29 23:14:51 +0300 | [diff] [blame] | 2635 | run_system(dut, "uci add wireless wifi-iface"); |
| 2636 | res = snprintf(buf, sizeof(buf), |
| 2637 | "uci set wireless.@wifi-iface[%d].%s=%s", |
| 2638 | id, key, val); |
| 2639 | if (res >= 0 && res < sizeof(buf)) |
| 2640 | run_system(dut, buf); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2641 | snprintf(buf, sizeof(buf), "uci set wireless.@wifi-iface[%d].%s=%s", |
| 2642 | id, "network", "lan"); |
| 2643 | run_system(dut, buf); |
| 2644 | snprintf(buf, sizeof(buf), "uci set wireless.@wifi-iface[%d].%s=%s", |
| 2645 | id, "mode", "ap"); |
| 2646 | run_system(dut, buf); |
| 2647 | snprintf(buf, sizeof(buf), "uci set wireless.@wifi-iface[%d].%s=%s", |
| 2648 | id, "encryption", "none"); |
| 2649 | run_system(dut, buf); |
| 2650 | } |
| 2651 | |
| 2652 | |
Alejandro Vasquez | 363f558 | 2018-07-17 11:25:05 -0700 | [diff] [blame] | 2653 | #define OPENWRT_MAX_NUM_RADIOS (MAX_RADIO + 1) |
Priyadharshini Gowthaman | 8018c98 | 2019-10-31 15:14:37 -0700 | [diff] [blame] | 2654 | static int owrt_ap_config_radio(struct sigma_dut *dut) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2655 | { |
Alejandro Vasquez | 363f558 | 2018-07-17 11:25:05 -0700 | [diff] [blame] | 2656 | int radio_id[MAX_RADIO] = { 0, 1, 2 }; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2657 | int radio_count, radio_no; |
| 2658 | char buf[64]; |
| 2659 | |
| 2660 | for (radio_count = 0; radio_count < OPENWRT_MAX_NUM_RADIOS; |
| 2661 | radio_count++) { |
| 2662 | snprintf(buf, sizeof(buf), "%s%d", "wifi", radio_count); |
| 2663 | for (radio_no = 0; radio_no < MAX_RADIO; radio_no++) { |
| 2664 | if (!sigma_radio_ifname[radio_no] || |
| 2665 | strcmp(sigma_radio_ifname[radio_no], buf) != 0) |
| 2666 | continue; |
| 2667 | owrt_ap_set_radio(dut, radio_count, "disabled", "0"); |
| 2668 | owrt_ap_set_vap(dut, radio_count, "device", buf); |
| 2669 | radio_id[radio_no] = radio_count; |
| 2670 | } |
| 2671 | } |
| 2672 | |
| 2673 | /* Hardware mode (11a/b/g/n/ac) & HT mode selection */ |
| 2674 | switch (dut->ap_mode) { |
| 2675 | case AP_11g: |
| 2676 | owrt_ap_set_radio(dut, radio_id[0], "hwmode", "11g"); |
| 2677 | break; |
| 2678 | case AP_11b: |
| 2679 | owrt_ap_set_radio(dut, radio_id[0], "hwmode", "11b"); |
| 2680 | break; |
| 2681 | case AP_11ng: |
| 2682 | owrt_ap_set_radio(dut, radio_id[0], "hwmode", "11ng"); |
| 2683 | owrt_ap_set_radio(dut, radio_id[0], "htmode", "HT20"); |
| 2684 | break; |
| 2685 | case AP_11a: |
| 2686 | owrt_ap_set_radio(dut, radio_id[0], "hwmode", "11a"); |
| 2687 | break; |
| 2688 | case AP_11na: |
| 2689 | owrt_ap_set_radio(dut, radio_id[0], "hwmode", "11na"); |
| 2690 | owrt_ap_set_radio(dut, radio_id[0], "htmode", "HT20"); |
| 2691 | break; |
| 2692 | case AP_11ac: |
| 2693 | owrt_ap_set_radio(dut, radio_id[0], "hwmode", "11ac"); |
| 2694 | owrt_ap_set_radio(dut, radio_id[0], "htmode", "HT80"); |
| 2695 | break; |
Priyadharshini Gowthaman | 4401cee | 2019-11-21 14:38:33 -0800 | [diff] [blame] | 2696 | case AP_11ax: |
| 2697 | if (dut->ap_channel >= 36) { |
| 2698 | owrt_ap_set_radio(dut, radio_id[0], "hwmode", "11axa"); |
| 2699 | owrt_ap_set_radio(dut, radio_id[0], "htmode", "HT80"); |
| 2700 | } else { |
| 2701 | owrt_ap_set_radio(dut, radio_id[0], "hwmode", "11axg"); |
| 2702 | owrt_ap_set_radio(dut, radio_id[0], "htmode", "HT20"); |
| 2703 | } |
| 2704 | break; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2705 | case AP_inval: |
| 2706 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 2707 | "MODE NOT SPECIFIED!"); |
Priyadharshini Gowthaman | 8018c98 | 2019-10-31 15:14:37 -0700 | [diff] [blame] | 2708 | return -1; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2709 | default: |
| 2710 | owrt_ap_set_radio(dut, radio_id[0], "hwmode", "11ng"); |
| 2711 | owrt_ap_set_radio(dut, radio_id[0], "htmode", "HT20"); |
| 2712 | break; |
| 2713 | } |
| 2714 | |
| 2715 | if (dut->ap_is_dual) { |
| 2716 | /* Hardware mode (11a/b/g/n/ac) & HT mode selection */ |
| 2717 | switch (dut->ap_mode_1) { |
| 2718 | case AP_11g: |
| 2719 | owrt_ap_set_radio(dut, radio_id[1], "hwmode", "11g"); |
| 2720 | break; |
| 2721 | case AP_11b: |
| 2722 | owrt_ap_set_radio(dut, radio_id[1], "hwmode", "11b"); |
| 2723 | break; |
| 2724 | case AP_11ng: |
| 2725 | owrt_ap_set_radio(dut, radio_id[1], "hwmode", "11ng"); |
| 2726 | owrt_ap_set_radio(dut, radio_id[1], "htmode", "HT20"); |
| 2727 | break; |
| 2728 | case AP_11a: |
| 2729 | owrt_ap_set_radio(dut, radio_id[1], "hwmode", "11a"); |
| 2730 | break; |
| 2731 | case AP_11na: |
| 2732 | owrt_ap_set_radio(dut, radio_id[1], "hwmode", "11na"); |
| 2733 | owrt_ap_set_radio(dut, radio_id[1], "htmode", "HT20"); |
| 2734 | break; |
| 2735 | case AP_11ac: |
| 2736 | owrt_ap_set_radio(dut, radio_id[1], "hwmode", "11ac"); |
| 2737 | owrt_ap_set_radio(dut, radio_id[1], "htmode", "HT80"); |
| 2738 | break; |
Priyadharshini Gowthaman | 4401cee | 2019-11-21 14:38:33 -0800 | [diff] [blame] | 2739 | case AP_11ax: |
| 2740 | if (dut->ap_channel >= 36) { |
| 2741 | owrt_ap_set_radio(dut, radio_id[1], |
| 2742 | "hwmode", "11axa"); |
| 2743 | owrt_ap_set_radio(dut, radio_id[1], |
| 2744 | "htmode", "HT80"); |
| 2745 | } else { |
| 2746 | owrt_ap_set_radio(dut, radio_id[1], |
| 2747 | "hwmode", "11axg"); |
| 2748 | owrt_ap_set_radio(dut, radio_id[1], |
| 2749 | "htmode", "HT20"); |
| 2750 | } |
| 2751 | break; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2752 | case AP_inval: |
| 2753 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 2754 | "MODE NOT SPECIFIED!"); |
Priyadharshini Gowthaman | 8018c98 | 2019-10-31 15:14:37 -0700 | [diff] [blame] | 2755 | return -1; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2756 | default: |
| 2757 | owrt_ap_set_radio(dut, radio_id[1], "hwmode", "11ng"); |
| 2758 | owrt_ap_set_radio(dut, radio_id[1], "htmode", "HT20"); |
| 2759 | break; |
| 2760 | } |
| 2761 | |
| 2762 | } |
| 2763 | |
| 2764 | /* Channel */ |
| 2765 | snprintf(buf, sizeof(buf), "%d", dut->ap_channel); |
| 2766 | owrt_ap_set_radio(dut, radio_id[0], "channel", buf); |
| 2767 | |
| 2768 | switch (dut->ap_chwidth) { |
| 2769 | case AP_20: |
| 2770 | owrt_ap_set_radio(dut, radio_id[0], "htmode", "HT20"); |
| 2771 | break; |
| 2772 | case AP_40: |
| 2773 | owrt_ap_set_radio(dut, radio_id[0], "htmode", "HT40"); |
| 2774 | break; |
| 2775 | case AP_80: |
| 2776 | owrt_ap_set_radio(dut, radio_id[0], "htmode", "HT80"); |
| 2777 | break; |
| 2778 | case AP_160: |
| 2779 | owrt_ap_set_radio(dut, radio_id[0], "htmode", "HT160"); |
| 2780 | break; |
priyadharshini gowthaman | 63ab848 | 2017-12-28 15:32:55 -0800 | [diff] [blame] | 2781 | case AP_80_80: |
| 2782 | owrt_ap_set_radio(dut, radio_id[0], "htmode", "HT80_80"); |
| 2783 | break; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2784 | case AP_AUTO: |
| 2785 | default: |
| 2786 | break; |
| 2787 | } |
| 2788 | |
| 2789 | if (dut->ap_channel == 140 || dut->ap_channel == 144) { |
| 2790 | if (get_openwrt_driver_type() == OPENWRT_DRIVER_ATHEROS) |
| 2791 | owrt_ap_set_radio(dut, radio_id[0], "set_ch_144", "3"); |
| 2792 | } |
| 2793 | |
| 2794 | if (dut->ap_is_dual) { |
| 2795 | snprintf(buf, sizeof(buf), "%d", dut->ap_channel_1); |
| 2796 | owrt_ap_set_radio(dut, radio_id[1], "channel", buf); |
| 2797 | } |
| 2798 | |
Adil Saeed Musthafa | 604c826 | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 2799 | /* Country Code */ |
| 2800 | if (dut->ap_reg_domain == REG_DOMAIN_GLOBAL) { |
| 2801 | const char *country; |
| 2802 | |
| 2803 | country = dut->ap_countrycode[0] ? dut->ap_countrycode : "US"; |
| 2804 | snprintf(buf, sizeof(buf), "%s4", country); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2805 | owrt_ap_set_radio(dut, radio_id[0], "country", buf); |
priyadharshini gowthaman | 27406b0 | 2017-12-28 15:35:45 -0800 | [diff] [blame] | 2806 | if (dut->ap_is_dual) |
| 2807 | owrt_ap_set_radio(dut, radio_id[1], "country", buf); |
Adil Saeed Musthafa | 604c826 | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 2808 | } else if (dut->ap_countrycode[0]) { |
| 2809 | owrt_ap_set_radio(dut, radio_id[0], "country", |
| 2810 | dut->ap_countrycode); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2811 | } |
| 2812 | |
| 2813 | if (dut->ap_disable_protection == 1) { |
| 2814 | owrt_ap_set_list_radio(dut, radio_id[0], "aggr_burst", "'0 0'"); |
| 2815 | owrt_ap_set_list_radio(dut, radio_id[0], "aggr_burst", "'1 0'"); |
| 2816 | owrt_ap_set_list_radio(dut, radio_id[0], "aggr_burst", "'2 0'"); |
| 2817 | owrt_ap_set_list_radio(dut, radio_id[0], "aggr_burst", "'3 0'"); |
| 2818 | } |
priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 2819 | |
| 2820 | if (dut->ap_oce == VALUE_ENABLED && |
Jouni Malinen | 016ae6c | 2019-11-04 17:00:01 +0200 | [diff] [blame] | 2821 | get_driver_type(dut) == DRIVER_OPENWRT) |
priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 2822 | owrt_ap_set_radio(dut, radio_id[0], "bcnburst", "1"); |
Priyadharshini Gowthaman | 8018c98 | 2019-10-31 15:14:37 -0700 | [diff] [blame] | 2823 | |
| 2824 | if (dut->ap_mbssid == VALUE_ENABLED) |
| 2825 | owrt_ap_set_qcawifi(dut, "mbss_ie_enable", "1"); |
| 2826 | |
Priyadharshini Gowthaman | b8c9358 | 2019-11-13 15:31:46 -0800 | [diff] [blame] | 2827 | if (dut->program == PROGRAM_HE) { |
| 2828 | owrt_ap_set_radio(dut, radio_id[0], "he_bsscolor", "'1 1'"); |
| 2829 | if (dut->ap_is_dual) |
| 2830 | owrt_ap_set_radio(dut, radio_id[1], "he_bsscolor", |
| 2831 | "'2 1'"); |
Priyadharshini Gowthaman | 7d07cd0 | 2019-11-22 14:26:02 -0800 | [diff] [blame] | 2832 | owrt_ap_set_qcawifi(dut, "ap_bss_color_collision_detection", |
| 2833 | "1"); |
Priyadharshini Gowthaman | b8c9358 | 2019-11-13 15:31:46 -0800 | [diff] [blame] | 2834 | } |
| 2835 | |
Priyadharshini Gowthaman | 8018c98 | 2019-10-31 15:14:37 -0700 | [diff] [blame] | 2836 | return 1; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2837 | } |
| 2838 | |
| 2839 | |
| 2840 | static int owrt_ap_config_vap_hs2(struct sigma_dut *dut, int vap_id) |
| 2841 | { |
| 2842 | char buf[256]; |
| 2843 | |
| 2844 | snprintf(buf, sizeof(buf), "%d", dut->ap_hs2); |
| 2845 | owrt_ap_set_vap(dut, vap_id, "hs20", buf); |
| 2846 | owrt_ap_set_vap(dut, vap_id, "qbssload", "1"); |
| 2847 | owrt_ap_set_vap(dut, vap_id, "hs20_deauth_req_timeout","3"); |
| 2848 | |
| 2849 | owrt_ap_set_list_vap(dut, vap_id, "hs20_oper_friendly_name", |
| 2850 | "'eng:Wi-Fi Alliance'"); |
| 2851 | |
| 2852 | owrt_ap_set_list_vap(dut, vap_id, "hs20_oper_friendly_name", |
| 2853 | "'chi:Wi-Fi\xe8\x81\x94\xe7\x9b\x9f'"); |
| 2854 | |
| 2855 | if (dut->ap_wan_metrics == 1) |
| 2856 | owrt_ap_set_vap(dut, vap_id, "hs20_wan_metrics", |
| 2857 | "'01:2500:384:0:0:10'"); |
| 2858 | else if (dut->ap_wan_metrics == 1) |
| 2859 | owrt_ap_set_vap(dut, vap_id, "hs20_wan_metrics", |
| 2860 | "'01:1500:384:20:20:10'"); |
| 2861 | else if (dut->ap_wan_metrics == 2) |
| 2862 | owrt_ap_set_vap(dut, vap_id, "hs20_wan_metrics", |
| 2863 | "'01:1500:384:20:20:10'"); |
| 2864 | else if (dut->ap_wan_metrics == 3) |
| 2865 | owrt_ap_set_vap(dut, vap_id, "hs20_wan_metrics", |
| 2866 | "'01:2000:1000:20:20:10'"); |
| 2867 | else if (dut->ap_wan_metrics == 4) |
| 2868 | owrt_ap_set_vap(dut, vap_id, "hs20_wan_metrics", |
| 2869 | "'01:8000:1000:20:20:10'"); |
| 2870 | else if (dut->ap_wan_metrics == 5) |
| 2871 | owrt_ap_set_vap(dut, vap_id, "hs20_wan_metrics", |
| 2872 | "'01:9000:5000:20:20:10'"); |
| 2873 | |
| 2874 | if (dut->ap_conn_capab == 1) { |
| 2875 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", "'1:0:0'"); |
| 2876 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", |
| 2877 | "'6:20:1'"); |
| 2878 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", |
| 2879 | "'6:22:0'"); |
| 2880 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", |
| 2881 | "'6:80:1'"); |
| 2882 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", |
| 2883 | "'6:443:1'"); |
| 2884 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", |
| 2885 | "'6:1723:0'"); |
| 2886 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", |
| 2887 | "'6:5060:0'"); |
| 2888 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", |
| 2889 | "'17:500:1'"); |
| 2890 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", |
| 2891 | "'17:5060:0'"); |
| 2892 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", |
| 2893 | "'17:4500:1'"); |
| 2894 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", |
| 2895 | "'50:0:1'"); |
| 2896 | } else if (dut->ap_conn_capab == 2) { |
| 2897 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", |
| 2898 | "'6:80:1'"); |
| 2899 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", |
| 2900 | "'6:443:1'"); |
| 2901 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", |
| 2902 | "'17:5060:1'"); |
| 2903 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", |
| 2904 | "'6:5060:1'"); |
| 2905 | } else if (dut->ap_conn_capab == 3) { |
| 2906 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", |
| 2907 | "'6:80:1'"); |
| 2908 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", |
| 2909 | "'6:443:1'"); |
| 2910 | } |
| 2911 | |
| 2912 | if (dut->ap_oper_class == 1) |
| 2913 | snprintf(buf, sizeof(buf), "%s", "51"); |
| 2914 | else if (dut->ap_oper_class == 2) |
| 2915 | snprintf(buf, sizeof(buf), "%s", "73"); |
| 2916 | else if (dut->ap_oper_class == 3) |
| 2917 | snprintf(buf, sizeof(buf), "%s", "5173"); |
| 2918 | |
| 2919 | if (dut->ap_oper_class) |
| 2920 | owrt_ap_set_vap(dut, vap_id, "hs20_operating_class", buf); |
| 2921 | |
| 2922 | if (dut->ap_osu_provider_list) { |
| 2923 | char *osu_friendly_name = NULL; |
| 2924 | char *osu_icon = NULL; |
| 2925 | char *osu_ssid = NULL; |
| 2926 | char *osu_nai = NULL; |
| 2927 | char *osu_service_desc = NULL; |
| 2928 | char *hs20_icon_filename = NULL; |
| 2929 | char hs20_icon[150]; |
| 2930 | int osu_method; |
| 2931 | |
| 2932 | hs20_icon_filename = "icon_red_zxx.png"; |
| 2933 | if (dut->ap_osu_icon_tag == 2) |
| 2934 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 2935 | snprintf(hs20_icon, sizeof(hs20_icon), |
| 2936 | "'128:61:zxx:image/png:icon_red_zxx.png:/etc/ath/%s'", |
| 2937 | hs20_icon_filename); |
| 2938 | osu_icon = "icon_red_zxx.png"; |
| 2939 | osu_ssid = "OSU"; |
| 2940 | osu_friendly_name = "'kor:SP 빨강 테스트 전용'"; |
| 2941 | osu_service_desc = "'kor:테스트 목적으로 무료 서비스'"; |
| 2942 | osu_method = (dut->ap_osu_method[0] == 0xFF) ? 1 : |
| 2943 | dut->ap_osu_method[0]; |
| 2944 | |
| 2945 | if (strlen(dut->ap_osu_server_uri[0])) |
| 2946 | owrt_ap_set_list_vap(dut, vap_id, "osu_server_uri", |
| 2947 | dut->ap_osu_server_uri[0]); |
| 2948 | else |
| 2949 | owrt_ap_set_list_vap(dut, vap_id, "osu_server_uri", |
| 2950 | "'https://osu-server.r2-testbed.wi-fi.org/'"); |
| 2951 | switch (dut->ap_osu_provider_list) { |
| 2952 | case 1: |
| 2953 | case 101: |
| 2954 | owrt_ap_set_list_vap(dut, vap_id, "osu_friendly_name", |
| 2955 | "'eng:SP Red Test Only'"); |
| 2956 | owrt_ap_set_list_vap(dut, vap_id, "osu_service_desc", |
| 2957 | "'eng:Free service for test purpose'"); |
| 2958 | owrt_ap_set_list_vap(dut, vap_id, "hs20_icon", |
| 2959 | hs20_icon); |
| 2960 | |
| 2961 | hs20_icon_filename = "icon_red_eng.png"; |
| 2962 | if (dut->ap_osu_icon_tag == 2) |
| 2963 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 2964 | |
| 2965 | snprintf(hs20_icon, sizeof(hs20_icon), |
| 2966 | "'160:76:eng:image/png:icon_red_eng.png:/etc/ath/%s'", |
| 2967 | hs20_icon_filename); |
| 2968 | owrt_ap_set_list_vap(dut, vap_id, "osu_icon", |
| 2969 | "icon_red_eng.png"); |
| 2970 | break; |
| 2971 | case 2: |
| 2972 | case 102: |
| 2973 | owrt_ap_set_list_vap(dut, vap_id, "osu_friendly_name", |
| 2974 | "'eng:Wireless Broadband Alliance'"); |
| 2975 | owrt_ap_set_list_vap(dut, vap_id, "osu_service_desc", |
| 2976 | "'eng:Free service for test purpose'"); |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2977 | hs20_icon_filename = "icon_orange_zxx.png"; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2978 | if (dut->ap_osu_icon_tag == 2) |
| 2979 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 2980 | |
| 2981 | snprintf(hs20_icon, sizeof(hs20_icon), |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2982 | "'128:61:zxx:image/png:icon_orange_zxx.png:/etc/ath/%s'", |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2983 | hs20_icon_filename); |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2984 | osu_icon = "icon_orange_zxx.png"; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2985 | osu_friendly_name = "'kor:와이어리스 브로드밴드 얼라이언스'"; |
| 2986 | break; |
| 2987 | case 3: |
| 2988 | case 103: |
Jouni Malinen | 02502de | 2018-10-15 17:19:33 +0300 | [diff] [blame] | 2989 | osu_friendly_name = "'spa:SP Red Test Only'"; |
| 2990 | osu_service_desc = "'spa:Free service for test purpose'"; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2991 | break; |
| 2992 | case 4: |
| 2993 | case 104: |
| 2994 | owrt_ap_set_list_vap(dut, vap_id, "osu_friendly_name", |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2995 | "'eng:SP Orange Test Only'"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2996 | owrt_ap_set_list_vap(dut, vap_id, "osu_service_desc", |
| 2997 | "'eng:Free service for test purpose'"); |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2998 | hs20_icon_filename = "icon_orange_eng.png"; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2999 | if (dut->ap_osu_icon_tag == 2) |
| 3000 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 3001 | |
| 3002 | snprintf(hs20_icon, sizeof(hs20_icon), |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 3003 | "'160:76:eng:image/png:icon_orange_eng.png:/etc/ath/%s'", |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3004 | hs20_icon_filename); |
| 3005 | owrt_ap_set_list_vap(dut, vap_id, "hs20_icon", |
| 3006 | hs20_icon); |
Jouni Malinen | fd45ad5 | 2018-10-15 17:06:18 +0300 | [diff] [blame] | 3007 | osu_friendly_name = "'kor:SP 오렌지 테스트 전용'"; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3008 | |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 3009 | hs20_icon_filename = "icon_orange_zxx.png"; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3010 | if (dut->ap_osu_icon_tag == 2) |
| 3011 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 3012 | |
| 3013 | snprintf(hs20_icon, sizeof(hs20_icon), |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 3014 | "'128:61:zxx:image/png:icon_orange_zxx.png:/etc/ath/%s'", |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3015 | hs20_icon_filename); |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 3016 | osu_icon = "icon_orange_zxx.png"; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3017 | break; |
| 3018 | case 5: |
| 3019 | case 105: |
| 3020 | owrt_ap_set_list_vap(dut, vap_id, "osu_friendly_name", |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 3021 | "'eng:SP Orange Test Only'"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3022 | owrt_ap_set_list_vap(dut, vap_id, "osu_service_desc", |
| 3023 | "'eng:Free service for test purpose'"); |
Jouni Malinen | fd45ad5 | 2018-10-15 17:06:18 +0300 | [diff] [blame] | 3024 | osu_friendly_name = "'kor:SP 오렌지 테스트 전용'"; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3025 | |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 3026 | hs20_icon_filename = "icon_orange_zxx.png"; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3027 | if (dut->ap_osu_icon_tag == 2) |
| 3028 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 3029 | |
| 3030 | snprintf(hs20_icon, sizeof(hs20_icon), |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 3031 | "'128:61:zxx:image/png:icon_orange_zxx.png:/etc/ath/%s'", |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3032 | hs20_icon_filename); |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 3033 | osu_icon = "icon_orange_zxx.png"; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3034 | break; |
| 3035 | case 6: |
| 3036 | case 106: |
| 3037 | owrt_ap_set_list_vap(dut, vap_id, "osu_friendly_name", |
| 3038 | "'eng:SP Green Test Only'"); |
| 3039 | owrt_ap_set_list_vap(dut, vap_id, "osu_friendly_name", |
| 3040 | "'kor:SP 초록 테스트 전용'"); |
| 3041 | |
| 3042 | hs20_icon_filename = "icon_green_zxx.png"; |
| 3043 | if (dut->ap_osu_icon_tag == 2) |
| 3044 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 3045 | |
| 3046 | snprintf(hs20_icon, sizeof(hs20_icon), |
| 3047 | "'128:61:zxx:image/png:icon_green_zxx.png:/etc/ath/%s'", |
| 3048 | hs20_icon_filename); |
| 3049 | owrt_ap_set_list_vap(dut, vap_id, "hs20_icon", |
| 3050 | hs20_icon); |
| 3051 | |
| 3052 | owrt_ap_set_list_vap(dut, vap_id, "osu_icon", |
| 3053 | "'icon_green_zxx.png'"); |
| 3054 | osu_method = (dut->ap_osu_method[0] == 0xFF) ? 0 : |
| 3055 | dut->ap_osu_method[0]; |
| 3056 | |
| 3057 | snprintf(buf, sizeof(buf), "%d", osu_method); |
| 3058 | owrt_ap_set_vap(dut, vap_id, "osu_method_list", buf); |
| 3059 | |
| 3060 | if (strlen(dut->ap_osu_server_uri[1])) |
| 3061 | owrt_ap_set_list_vap(dut, vap_id, |
| 3062 | "osu_server_uri", |
| 3063 | dut->ap_osu_server_uri[1]); |
| 3064 | else |
| 3065 | owrt_ap_set_list_vap(dut, vap_id, |
| 3066 | "osu_server_uri", |
| 3067 | "'https://osu-server.r2-testbed.wi-fi.org/'"); |
| 3068 | |
| 3069 | owrt_ap_set_list_vap(dut, vap_id, "osu_friendly_name", |
| 3070 | "'eng:SP Orange Test Only'"); |
| 3071 | |
| 3072 | hs20_icon_filename = "icon_orange_zxx.png"; |
| 3073 | if (dut->ap_osu_icon_tag == 2) |
| 3074 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 3075 | |
| 3076 | snprintf(hs20_icon, sizeof(hs20_icon), |
| 3077 | "'128:61:zxx:image/png:icon_orange_zxx.png:/etc/ath/%s'", |
| 3078 | hs20_icon_filename); |
| 3079 | |
| 3080 | osu_icon = "icon_orange_zxx.png"; |
| 3081 | osu_friendly_name = "'kor:SP 오렌지 테스트 전용'"; |
| 3082 | osu_method = (dut->ap_osu_method[1] == 0xFF) ? 0 : |
| 3083 | dut->ap_osu_method[1]; |
| 3084 | osu_service_desc = NULL; |
| 3085 | break; |
| 3086 | case 7: |
| 3087 | case 107: |
| 3088 | owrt_ap_set_list_vap(dut, vap_id, "osu_friendly_name", |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 3089 | "'eng:SP Green Test Only'"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3090 | owrt_ap_set_list_vap(dut, vap_id, "osu_service_desc", |
| 3091 | "'eng:Free service for test purpose'"); |
| 3092 | |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 3093 | hs20_icon_filename = "icon_green_eng.png"; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3094 | if (dut->ap_osu_icon_tag == 2) |
| 3095 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 3096 | |
| 3097 | snprintf(hs20_icon, sizeof(hs20_icon), |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 3098 | "'160:76:eng:image/png:icon_green_eng.png:/etc/ath/%s'", |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3099 | hs20_icon_filename); |
| 3100 | owrt_ap_set_list_vap(dut, vap_id, "hs20_icon", |
| 3101 | hs20_icon); |
| 3102 | |
| 3103 | owrt_ap_set_list_vap(dut, vap_id, "osu_icon", |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 3104 | "'icon_green_eng.png'"); |
Jouni Malinen | fd45ad5 | 2018-10-15 17:06:18 +0300 | [diff] [blame] | 3105 | osu_friendly_name = "'kor:SP 초록 테스트 전용'"; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3106 | |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 3107 | hs20_icon_filename = "icon_green_zxx.png"; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3108 | if (dut->ap_osu_icon_tag == 2) |
| 3109 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 3110 | |
| 3111 | snprintf(hs20_icon, sizeof(hs20_icon), |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 3112 | "'128:61:zxx:image/png:icon_green_zxx.png:/etc/ath/%s'", |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3113 | hs20_icon_filename); |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 3114 | osu_icon = "icon_green_zxx.png"; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3115 | break; |
| 3116 | case 8: |
| 3117 | case 108: |
| 3118 | owrt_ap_set_list_vap(dut, vap_id, "osu_friendly_name", |
| 3119 | "'eng:SP Red Test Only'"); |
| 3120 | owrt_ap_set_list_vap(dut, vap_id, "osu_service_desc", |
| 3121 | "'eng:Free service for test purpose'"); |
| 3122 | osu_ssid = "OSU-Encrypted"; |
| 3123 | osu_nai = "'anonymous@hotspot.net'"; |
| 3124 | break; |
| 3125 | case 9: |
| 3126 | case 109: |
| 3127 | osu_ssid = "OSU-OSEN"; |
| 3128 | osu_nai = "'test-anonymous@wi-fi.org'"; |
| 3129 | osu_friendly_name = "'eng:SP Orange Test Only'"; |
| 3130 | hs20_icon_filename = "icon_orange_zxx.png"; |
| 3131 | if (dut->ap_osu_icon_tag == 2) |
| 3132 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 3133 | |
| 3134 | snprintf(hs20_icon, sizeof(hs20_icon), |
| 3135 | "'128:61:zxx:image/png:icon_orange_zxx.png:/etc/ath/%s'", |
| 3136 | hs20_icon_filename); |
| 3137 | osu_icon = "icon_orange_zxx.png"; |
| 3138 | osu_method = (dut->ap_osu_method[0] == 0xFF) ? 1 : |
| 3139 | dut->ap_osu_method[0]; |
| 3140 | osu_service_desc = NULL; |
| 3141 | break; |
| 3142 | default: |
| 3143 | break; |
| 3144 | } |
| 3145 | |
| 3146 | if (strlen(dut->ap_osu_ssid)) { |
Jouni Malinen | e6ac6a0 | 2018-09-11 02:40:17 +0300 | [diff] [blame] | 3147 | if (dut->ap_tag_ssid[0][0] && |
| 3148 | strcmp(dut->ap_tag_ssid[0], |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 3149 | dut->ap_osu_ssid) != 0 && |
| 3150 | strcmp(dut->ap_tag_ssid[0], osu_ssid) != 0) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3151 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 3152 | "OSU_SSID and WLAN_TAG2 SSID differ"); |
| 3153 | return -2; |
| 3154 | } |
| 3155 | |
| 3156 | snprintf(buf, sizeof(buf), "'\"%s\"'", |
| 3157 | dut->ap_osu_ssid); |
| 3158 | } else { |
| 3159 | snprintf(buf, sizeof(buf), "'\"%s\"'", osu_ssid); |
| 3160 | } |
| 3161 | |
| 3162 | owrt_ap_set_vap(dut, vap_id, "osu_ssid", buf); |
| 3163 | |
| 3164 | |
| 3165 | if (osu_friendly_name) |
| 3166 | owrt_ap_set_list_vap(dut, vap_id, "osu_friendly_name", |
| 3167 | osu_friendly_name); |
| 3168 | if (osu_service_desc) |
| 3169 | owrt_ap_set_list_vap(dut, vap_id, "osu_service_desc", |
| 3170 | osu_service_desc); |
| 3171 | if (osu_nai) |
| 3172 | owrt_ap_set_vap(dut, vap_id, "osu_nai", osu_nai); |
| 3173 | |
| 3174 | owrt_ap_set_list_vap(dut, vap_id, "hs20_icon", hs20_icon); |
| 3175 | |
| 3176 | if (osu_icon) |
| 3177 | owrt_ap_set_list_vap(dut, vap_id, "osu_icon", |
| 3178 | osu_icon); |
| 3179 | |
| 3180 | if (dut->ap_osu_provider_list > 100) { |
| 3181 | owrt_ap_set_list_vap(dut, vap_id, "osu_method_list", |
| 3182 | "0"); |
| 3183 | } else { |
| 3184 | snprintf(buf, sizeof(buf), "%d", osu_method); |
| 3185 | owrt_ap_set_list_vap(dut, vap_id, "osu_method_list", |
| 3186 | buf); |
| 3187 | } |
| 3188 | } |
| 3189 | |
| 3190 | return 0; |
| 3191 | } |
| 3192 | |
| 3193 | |
Jouni Malinen | 1370122 | 2019-02-19 12:10:53 +0200 | [diff] [blame] | 3194 | static int set_anqp_elem_value(struct sigma_dut *dut, const char *ifname, |
| 3195 | char *anqp_string, size_t str_size) |
Adil Saeed Musthafa | a8d7484 | 2017-04-10 23:13:39 -0700 | [diff] [blame] | 3196 | { |
| 3197 | unsigned char bssid[ETH_ALEN]; |
| 3198 | unsigned char dummy_mac[] = { 0x00, 0x10, 0x20, 0x30, 0x40, 0x50 }; |
| 3199 | int preference = 0xff; |
| 3200 | |
Jouni Malinen | 1370122 | 2019-02-19 12:10:53 +0200 | [diff] [blame] | 3201 | if (get_hwaddr(ifname, bssid) < 0) |
| 3202 | return -1; |
Adil Saeed Musthafa | a8d7484 | 2017-04-10 23:13:39 -0700 | [diff] [blame] | 3203 | snprintf(anqp_string, str_size, |
| 3204 | "272:3410%02x%02x%02x%02x%02x%02xf70000007330000301%02x3410%02x%02x%02x%02x%02x%02xf70000007330000301%02x", |
| 3205 | bssid[0], bssid[1], bssid[2], bssid[3], bssid[4], bssid[5], |
| 3206 | preference, |
| 3207 | dummy_mac[0], dummy_mac[1], dummy_mac[2], |
| 3208 | dummy_mac[3], dummy_mac[4], dummy_mac[5], |
| 3209 | preference - 1); |
Jouni Malinen | 1370122 | 2019-02-19 12:10:53 +0200 | [diff] [blame] | 3210 | return 0; |
Adil Saeed Musthafa | a8d7484 | 2017-04-10 23:13:39 -0700 | [diff] [blame] | 3211 | } |
| 3212 | |
| 3213 | |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 3214 | static void get_if_name(struct sigma_dut *dut, char *ifname_str, |
| 3215 | size_t str_size, int wlan_tag) |
| 3216 | { |
Jouni Malinen | f898464 | 2017-10-12 00:02:37 +0300 | [diff] [blame] | 3217 | const char *ifname; |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 3218 | enum driver_type drv; |
| 3219 | |
Jouni Malinen | 016ae6c | 2019-11-04 17:00:01 +0200 | [diff] [blame] | 3220 | drv = get_driver_type(dut); |
Jouni Malinen | f898464 | 2017-10-12 00:02:37 +0300 | [diff] [blame] | 3221 | if (dut->hostapd_ifname && if_nametoindex(dut->hostapd_ifname) > 0) { |
| 3222 | ifname = dut->hostapd_ifname; |
| 3223 | } else if (drv == DRIVER_ATHEROS) { |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 3224 | if ((dut->ap_mode == AP_11a || dut->ap_mode == AP_11na || |
| 3225 | dut->ap_mode == AP_11ac) && |
| 3226 | if_nametoindex("ath1") > 0) |
| 3227 | ifname = "ath1"; |
| 3228 | else |
| 3229 | ifname = "ath0"; |
| 3230 | } else if (drv == DRIVER_OPENWRT) { |
| 3231 | if (sigma_radio_ifname[0] && |
| 3232 | strcmp(sigma_radio_ifname[0], "wifi2") == 0) |
| 3233 | ifname = "ath2"; |
| 3234 | else if (sigma_radio_ifname[0] && |
| 3235 | strcmp(sigma_radio_ifname[0], "wifi1") == 0) |
| 3236 | ifname = "ath1"; |
| 3237 | else |
| 3238 | ifname = "ath0"; |
Alexei Avshalom Lazar | 2712cc8 | 2018-12-23 16:29:14 +0200 | [diff] [blame] | 3239 | } else if (drv == DRIVER_WIL6210) { |
Jouni Malinen | 016ae6c | 2019-11-04 17:00:01 +0200 | [diff] [blame] | 3240 | ifname = get_main_ifname(dut); |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 3241 | } else { |
| 3242 | if ((dut->ap_mode == AP_11a || dut->ap_mode == AP_11na || |
| 3243 | dut->ap_mode == AP_11ac) && |
| 3244 | if_nametoindex("wlan1") > 0) |
| 3245 | ifname = "wlan1"; |
| 3246 | else |
| 3247 | ifname = "wlan0"; |
| 3248 | } |
| 3249 | |
| 3250 | if (drv == DRIVER_OPENWRT && wlan_tag > 1) { |
| 3251 | /* Handle tagged-ifname only on OPENWRT for now */ |
| 3252 | snprintf(ifname_str, str_size, "%s%d", ifname, wlan_tag - 1); |
Liangwei Dong | 8357289 | 2019-01-10 13:51:48 +0800 | [diff] [blame] | 3253 | } else if ((drv == DRIVER_MAC80211 || drv == DRIVER_LINUX_WCN) && |
| 3254 | wlan_tag == 2) { |
Jouni Malinen | f898464 | 2017-10-12 00:02:37 +0300 | [diff] [blame] | 3255 | snprintf(ifname_str, str_size, "%s_1", ifname); |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 3256 | } else { |
| 3257 | snprintf(ifname_str, str_size, "%s", ifname); |
| 3258 | } |
| 3259 | } |
| 3260 | |
| 3261 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3262 | static int owrt_ap_config_vap(struct sigma_dut *dut) |
| 3263 | { |
| 3264 | char buf[256], *temp; |
Jouni Malinen | 3aa7286 | 2019-05-29 23:14:51 +0300 | [diff] [blame] | 3265 | int vap_id = 0, vap_count, i, j, res; |
priyadharshini gowthaman | 0454706 | 2018-01-15 11:59:55 -0800 | [diff] [blame] | 3266 | const char *ifname; |
| 3267 | char ifname2[50]; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3268 | |
priyadharshini gowthaman | 7356126 | 2018-02-20 13:24:59 -0800 | [diff] [blame] | 3269 | if (sigma_radio_ifname[0] && |
| 3270 | strcmp(sigma_radio_ifname[0], "wifi2") == 0) |
| 3271 | ifname = "ath2"; |
| 3272 | else if (sigma_radio_ifname[0] && |
| 3273 | strcmp(sigma_radio_ifname[0], "wifi1") == 0) |
| 3274 | ifname = "ath1"; |
| 3275 | else |
| 3276 | ifname = "ath0"; |
| 3277 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3278 | 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] | 3279 | snprintf(buf, sizeof(buf), "wifi%d", vap_count); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3280 | |
| 3281 | for (vap_id = 0; vap_id < MAX_RADIO; vap_id++) { |
| 3282 | if (sigma_radio_ifname[vap_id] && |
| 3283 | strcmp(sigma_radio_ifname[vap_id], buf) == 0) |
| 3284 | break; |
| 3285 | } |
| 3286 | if (vap_id == MAX_RADIO) |
| 3287 | continue; |
| 3288 | |
| 3289 | /* Single VAP configuration */ |
| 3290 | if (!dut->ap_is_dual) |
| 3291 | vap_id = vap_count; |
| 3292 | |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 3293 | for (j = 0; j < MAX_WLAN_TAGS - 1; j++) { |
| 3294 | /* |
| 3295 | * We keep a separate array of ap_tag_ssid and |
| 3296 | * ap_tag_key_mgmt for tags starting from WLAN_TAG=2. |
| 3297 | * So j=0 => WLAN_TAG = 2 |
| 3298 | */ |
| 3299 | int wlan_tag = j + 2; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3300 | |
priyadharshini gowthaman | 0e209fc | 2018-01-26 15:15:37 -0800 | [diff] [blame] | 3301 | if (wlan_tag == 2 && dut->program == PROGRAM_WPA3 && |
| 3302 | (dut->ap_interface_5g || dut->ap_interface_2g)) { |
Jouni Malinen | 3aa7286 | 2019-05-29 23:14:51 +0300 | [diff] [blame] | 3303 | res = snprintf( |
| 3304 | dut->ap_tag_ssid[wlan_tag - 2], |
| 3305 | sizeof(dut->ap_tag_ssid[wlan_tag - 2]), |
| 3306 | "%s-owe", dut->ap_ssid); |
| 3307 | if (res < 0 || |
| 3308 | res >= sizeof(dut->ap_tag_ssid[wlan_tag - |
| 3309 | 2])) |
| 3310 | dut->ap_tag_ssid[wlan_tag - 2][0] = |
| 3311 | '\0'; |
priyadharshini gowthaman | 0e209fc | 2018-01-26 15:15:37 -0800 | [diff] [blame] | 3312 | } |
| 3313 | |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 3314 | if (dut->ap_tag_ssid[j][0] == '\0') |
| 3315 | continue; |
| 3316 | |
| 3317 | snprintf(buf, sizeof(buf), "%s%d", "wifi", vap_count); |
| 3318 | owrt_ap_add_vap(dut, vap_count + (wlan_tag - 1), |
| 3319 | "device", buf); |
| 3320 | /* SSID */ |
| 3321 | snprintf(buf, sizeof(buf), "\"%s\"", |
| 3322 | dut->ap_tag_ssid[j]); |
| 3323 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), |
| 3324 | "ssid", buf); |
| 3325 | |
priyadharshini gowthaman | 0454706 | 2018-01-15 11:59:55 -0800 | [diff] [blame] | 3326 | if (dut->ap_key_mgmt == AP_WPA2_OWE && |
| 3327 | dut->ap_tag_ssid[0][0] && |
| 3328 | dut->ap_tag_key_mgmt[0] == AP2_OPEN) { |
| 3329 | /* OWE transition mode */ |
| 3330 | snprintf(buf, sizeof(buf), "%s", ifname); |
| 3331 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), |
| 3332 | "owe_transition_ifname", buf); |
| 3333 | } |
| 3334 | |
| 3335 | if (dut->ap_key_mgmt == AP_OPEN && |
| 3336 | dut->ap_tag_key_mgmt[0] == AP2_WPA2_OWE) { |
| 3337 | /* OWE transition mode */ |
| 3338 | snprintf(buf, sizeof(buf), "%s", ifname); |
| 3339 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), |
| 3340 | "owe_transition_ifname", buf); |
| 3341 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), |
| 3342 | "hidden", "1"); |
| 3343 | } |
| 3344 | |
Jouni Malinen | 6be21c8 | 2018-08-01 18:47:24 +0300 | [diff] [blame] | 3345 | if (ap_ft_enabled(dut)) { |
priyadharshini gowthaman | 47189f5 | 2017-12-28 12:37:46 -0800 | [diff] [blame] | 3346 | unsigned char self_mac[ETH_ALEN]; |
| 3347 | char mac_str[20]; |
| 3348 | |
| 3349 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), |
| 3350 | "mobility_domain", |
| 3351 | dut->ap_mobility_domain); |
| 3352 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), |
Jouni Malinen | 9f94331 | 2019-08-19 23:49:16 +0300 | [diff] [blame] | 3353 | "ft_over_ds", |
| 3354 | dut->ap_ft_ds == VALUE_ENABLED ? |
| 3355 | "1" : "0"); |
priyadharshini gowthaman | 47189f5 | 2017-12-28 12:37:46 -0800 | [diff] [blame] | 3356 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), |
| 3357 | "ieee80211r", "1"); |
| 3358 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), |
| 3359 | "nasid", "nas1.example.com"); |
Jouni Malinen | 1370122 | 2019-02-19 12:10:53 +0200 | [diff] [blame] | 3360 | if (get_hwaddr(sigma_radio_ifname[0], |
| 3361 | self_mac) < 0) |
| 3362 | return -1; |
priyadharshini gowthaman | 47189f5 | 2017-12-28 12:37:46 -0800 | [diff] [blame] | 3363 | snprintf(mac_str, sizeof(mac_str), |
| 3364 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 3365 | self_mac[0], self_mac[1], self_mac[2], |
| 3366 | self_mac[3], self_mac[4], self_mac[5]); |
| 3367 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), |
| 3368 | "ap_macaddr", mac_str); |
| 3369 | snprintf(mac_str, sizeof(mac_str), |
| 3370 | "%02x%02x%02x%02x%02x%02x", |
| 3371 | self_mac[0], self_mac[1], self_mac[2], |
| 3372 | self_mac[3], self_mac[4], self_mac[5]); |
| 3373 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), |
| 3374 | "r1_key_holder", mac_str); |
| 3375 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), |
| 3376 | "ft_psk_generate_local", "1"); |
| 3377 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), |
| 3378 | "kh_key_hex", |
| 3379 | "000102030405060708090a0b0c0d0e0f"); |
| 3380 | snprintf(mac_str, sizeof(mac_str), |
| 3381 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 3382 | dut->ft_bss_mac_list[0][0], |
| 3383 | dut->ft_bss_mac_list[0][1], |
| 3384 | dut->ft_bss_mac_list[0][2], |
| 3385 | dut->ft_bss_mac_list[0][3], |
| 3386 | dut->ft_bss_mac_list[0][4], |
| 3387 | dut->ft_bss_mac_list[0][5]); |
| 3388 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), |
| 3389 | "ap2_macaddr", mac_str); |
| 3390 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), |
| 3391 | "ap2_r1_key_holder", mac_str); |
| 3392 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), |
| 3393 | "nasid2", "nas2.example.com"); |
| 3394 | } |
| 3395 | |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 3396 | if (dut->ap_tag_key_mgmt[j] == AP2_OSEN && |
| 3397 | wlan_tag == 2) { |
| 3398 | /* Only supported for WLAN_TAG=2 */ |
| 3399 | owrt_ap_set_vap(dut, vap_count + 1, "osen", |
| 3400 | "1"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3401 | snprintf(buf, sizeof(buf), "wpa2"); |
| 3402 | owrt_ap_set_vap(dut, vap_count + 1, |
| 3403 | "encryption", buf); |
| 3404 | snprintf(buf, sizeof(buf), "%s", |
| 3405 | dut->ap2_radius_ipaddr); |
| 3406 | owrt_ap_set_vap(dut, vap_count + 1, |
| 3407 | "auth_server", buf); |
| 3408 | snprintf(buf, sizeof(buf), "%d", |
| 3409 | dut->ap2_radius_port); |
| 3410 | owrt_ap_set_vap(dut, vap_count + 1, |
| 3411 | "auth_port", buf); |
| 3412 | snprintf(buf, sizeof(buf), "%s", |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 3413 | dut->ap2_radius_password); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3414 | owrt_ap_set_vap(dut, vap_count + 1, |
| 3415 | "auth_secret", buf); |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 3416 | } else if (dut->ap_tag_key_mgmt[j] == AP2_WPA2_PSK) { |
| 3417 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), |
| 3418 | "encryption", "psk2+ccmp"); |
| 3419 | snprintf(buf, sizeof(buf), "\"%s\"", |
| 3420 | dut->ap_passphrase); |
| 3421 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), |
| 3422 | "key", buf); |
| 3423 | snprintf(buf, sizeof(buf), "%d", dut->ap_pmf); |
priyadharshini gowthaman | 47189f5 | 2017-12-28 12:37:46 -0800 | [diff] [blame] | 3424 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 3425 | "ieee80211w", buf); |
priyadharshini gowthaman | 0454706 | 2018-01-15 11:59:55 -0800 | [diff] [blame] | 3426 | } else if (dut->ap_tag_key_mgmt[0] == AP2_WPA2_OWE) { |
| 3427 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), |
| 3428 | "owe", "1"); |
| 3429 | snprintf(buf, sizeof(buf), "ccmp"); |
| 3430 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), |
| 3431 | "encryption", buf); |
| 3432 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), |
| 3433 | "ieee80211w", "2"); |
| 3434 | if (dut->ap_sae_groups) { |
| 3435 | snprintf(buf, sizeof(buf), "\'%s\'", |
| 3436 | dut->ap_sae_groups); |
priyadharshini gowthaman | b59bfe4 | 2018-08-30 15:14:08 -0700 | [diff] [blame] | 3437 | owrt_ap_set_list_vap(dut, vap_count + |
| 3438 | (wlan_tag - 1), |
| 3439 | "owe_groups", buf); |
priyadharshini gowthaman | 0454706 | 2018-01-15 11:59:55 -0800 | [diff] [blame] | 3440 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3441 | } |
| 3442 | } |
| 3443 | |
priyadharshini gowthaman | 47189f5 | 2017-12-28 12:37:46 -0800 | [diff] [blame] | 3444 | /* Now set anqp_elem and ft_oa for wlan_tag = 1 */ |
Adil Saeed Musthafa | a8d7484 | 2017-04-10 23:13:39 -0700 | [diff] [blame] | 3445 | if (dut->program == PROGRAM_MBO && |
Jouni Malinen | 016ae6c | 2019-11-04 17:00:01 +0200 | [diff] [blame] | 3446 | get_driver_type(dut) == DRIVER_OPENWRT) { |
priyadharshini gowthaman | 47189f5 | 2017-12-28 12:37:46 -0800 | [diff] [blame] | 3447 | unsigned char self_mac[ETH_ALEN]; |
| 3448 | char mac_str[20]; |
Adil Saeed Musthafa | a8d7484 | 2017-04-10 23:13:39 -0700 | [diff] [blame] | 3449 | char anqp_string[200]; |
| 3450 | |
Jouni Malinen | 1370122 | 2019-02-19 12:10:53 +0200 | [diff] [blame] | 3451 | if (set_anqp_elem_value(dut, sigma_radio_ifname[0], |
| 3452 | anqp_string, |
| 3453 | sizeof(anqp_string)) < 0) |
| 3454 | return -1; |
Adil Saeed Musthafa | a8d7484 | 2017-04-10 23:13:39 -0700 | [diff] [blame] | 3455 | owrt_ap_set_list_vap(dut, vap_count, "anqp_elem", |
| 3456 | anqp_string); |
priyadharshini gowthaman | 47189f5 | 2017-12-28 12:37:46 -0800 | [diff] [blame] | 3457 | |
Jouni Malinen | 6be21c8 | 2018-08-01 18:47:24 +0300 | [diff] [blame] | 3458 | if (ap_ft_enabled(dut)) { |
priyadharshini gowthaman | 47189f5 | 2017-12-28 12:37:46 -0800 | [diff] [blame] | 3459 | owrt_ap_set_vap(dut, vap_count, |
| 3460 | "mobility_domain", |
| 3461 | dut->ap_mobility_domain); |
| 3462 | owrt_ap_set_vap(dut, vap_count, |
Jouni Malinen | 9f94331 | 2019-08-19 23:49:16 +0300 | [diff] [blame] | 3463 | "ft_over_ds", |
| 3464 | dut->ap_ft_ds == VALUE_ENABLED ? |
| 3465 | "1" : "0"); |
priyadharshini gowthaman | 47189f5 | 2017-12-28 12:37:46 -0800 | [diff] [blame] | 3466 | owrt_ap_set_vap(dut, vap_count, |
| 3467 | "ieee80211r", "1"); |
| 3468 | owrt_ap_set_vap(dut, vap_count, |
| 3469 | "nasid", "nas1.example.com"); |
| 3470 | get_hwaddr(sigma_radio_ifname[0], self_mac); |
| 3471 | snprintf(mac_str, sizeof(mac_str), |
| 3472 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 3473 | self_mac[0], self_mac[1], self_mac[2], |
| 3474 | self_mac[3], self_mac[4], self_mac[5]); |
| 3475 | owrt_ap_set_vap(dut, vap_count, |
| 3476 | "ap_macaddr", mac_str); |
| 3477 | snprintf(mac_str, sizeof(mac_str), |
| 3478 | "%02x%02x%02x%02x%02x%02x", |
| 3479 | self_mac[0], self_mac[1], self_mac[2], |
| 3480 | self_mac[3], self_mac[4], self_mac[5]); |
| 3481 | owrt_ap_set_vap(dut, vap_count, |
| 3482 | "r1_key_holder", mac_str); |
| 3483 | owrt_ap_set_vap(dut, vap_count, |
| 3484 | "ft_psk_generate_local", "1"); |
| 3485 | owrt_ap_set_vap(dut, vap_count, |
| 3486 | "kh_key_hex", |
| 3487 | "000102030405060708090a0b0c0d0e0f"); |
| 3488 | snprintf(mac_str, sizeof(mac_str), |
| 3489 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 3490 | dut->ft_bss_mac_list[0][0], |
| 3491 | dut->ft_bss_mac_list[0][1], |
| 3492 | dut->ft_bss_mac_list[0][2], |
| 3493 | dut->ft_bss_mac_list[0][3], |
| 3494 | dut->ft_bss_mac_list[0][4], |
| 3495 | dut->ft_bss_mac_list[0][5]); |
| 3496 | owrt_ap_set_vap(dut, vap_count, |
| 3497 | "ap2_macaddr", mac_str); |
| 3498 | owrt_ap_set_vap(dut, vap_count, |
| 3499 | "ap2_r1_key_holder", mac_str); |
| 3500 | owrt_ap_set_vap(dut, vap_count, |
| 3501 | "nasid2", "nas2.example.com"); |
| 3502 | } |
Adil Saeed Musthafa | a8d7484 | 2017-04-10 23:13:39 -0700 | [diff] [blame] | 3503 | } |
| 3504 | |
priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 3505 | if (dut->ap_oce == VALUE_ENABLED && |
Jouni Malinen | 016ae6c | 2019-11-04 17:00:01 +0200 | [diff] [blame] | 3506 | get_driver_type(dut) == DRIVER_OPENWRT) { |
priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 3507 | owrt_ap_set_vap(dut, vap_id, "oce", "1"); |
| 3508 | owrt_ap_set_vap(dut, vap_id, "qbssload", "1"); |
| 3509 | owrt_ap_set_vap(dut, vap_id, "bpr_enable", "1"); |
| 3510 | |
priyadharshini gowthaman | 63ab848 | 2017-12-28 15:32:55 -0800 | [diff] [blame] | 3511 | if (dut->ap_80plus80 == 1) |
| 3512 | owrt_ap_set_vap(dut, vap_id, "cfreq2", "5775"); |
| 3513 | |
priyadharshini gowthaman | de81f39 | 2017-12-28 15:28:49 -0800 | [diff] [blame] | 3514 | if (dut->ap_akm == 1) { |
| 3515 | owrt_ap_set_vap(dut, vap_id, "wpa_group_rekey", |
| 3516 | "3600"); |
| 3517 | owrt_ap_set_vap(dut, vap_id, "key", "12345678"); |
| 3518 | owrt_ap_set_vap(dut, vap_id, "ieee80211ai", |
| 3519 | "1"); |
| 3520 | owrt_ap_set_vap(dut, vap_id, "fils_cache_id", |
| 3521 | "1234"); |
| 3522 | owrt_ap_set_vap(dut, vap_id, |
| 3523 | "erp_send_reauth_start", "1"); |
| 3524 | } |
| 3525 | |
priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 3526 | if (dut->ap_filshlp == VALUE_ENABLED) { |
| 3527 | struct ifreq ifr; |
| 3528 | char *ifname; |
| 3529 | int s; |
| 3530 | struct sockaddr_in *ipaddr; |
| 3531 | |
| 3532 | s = socket(AF_INET, SOCK_DGRAM, 0); |
| 3533 | if (s < 0) { |
| 3534 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 3535 | "Failed to open socket"); |
| 3536 | return -1; |
| 3537 | } |
| 3538 | ifr.ifr_addr.sa_family = AF_INET; |
| 3539 | |
| 3540 | memset(&ifr, 0, sizeof(ifr)); |
| 3541 | ifname = "br-lan"; |
| 3542 | strlcpy(ifr.ifr_name, ifname, |
| 3543 | sizeof(ifr.ifr_name)); |
| 3544 | if (ioctl(s, SIOCGIFADDR, &ifr) < 0) { |
| 3545 | perror("ioctl"); |
| 3546 | close(s); |
| 3547 | return -1; |
| 3548 | } |
| 3549 | |
| 3550 | ipaddr = (struct sockaddr_in*)&ifr.ifr_addr; |
| 3551 | snprintf(buf, sizeof(buf), "%s", |
| 3552 | inet_ntoa(ipaddr->sin_addr)); |
| 3553 | owrt_ap_set_vap(dut, vap_id, "own_ip_addr", |
| 3554 | buf); |
| 3555 | snprintf(buf, sizeof(buf), "%s", |
| 3556 | dut->ap_dhcpserv_ipaddr); |
| 3557 | owrt_ap_set_vap(dut, vap_id, "dhcp_server", |
| 3558 | buf); |
| 3559 | owrt_ap_set_vap(dut, vap_id, |
| 3560 | "dhcp_rapid_commit_proxy", "1"); |
| 3561 | owrt_ap_set_vap(dut, vap_id, |
| 3562 | "fils_hlp_wait_time", "300"); |
| 3563 | } |
| 3564 | |
| 3565 | if (dut->ap_filsdscv == VALUE_ENABLED) { |
| 3566 | owrt_ap_set_vap(dut, vap_id, "ieee80211ai", |
| 3567 | "1"); |
| 3568 | owrt_ap_set_vap(dut, vap_id, "fils_fd_period", |
| 3569 | "20"); |
| 3570 | } |
| 3571 | } |
| 3572 | |
| 3573 | if (dut->ap_filsdscv == VALUE_DISABLED) { |
| 3574 | owrt_ap_set_vap(dut, vap_id, "ieee80211ai", "0"); |
| 3575 | owrt_ap_set_vap(dut, vap_id, "fils_fd_period", "0"); |
| 3576 | } |
| 3577 | |
| 3578 | if (dut->ap_oce == VALUE_DISABLED && |
Jouni Malinen | 016ae6c | 2019-11-04 17:00:01 +0200 | [diff] [blame] | 3579 | get_driver_type(dut) == DRIVER_OPENWRT) { |
priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 3580 | owrt_ap_set_vap(dut, vap_id, "oce", "0"); |
| 3581 | owrt_ap_set_vap(dut, vap_id, "qbssload", "0"); |
| 3582 | owrt_ap_set_vap(dut, vap_id, "bpr_enable", "0"); |
| 3583 | |
| 3584 | if (dut->ap_filsdscv == VALUE_DISABLED) { |
| 3585 | owrt_ap_set_vap(dut, vap_id, "ieee80211ai", |
| 3586 | "0"); |
| 3587 | owrt_ap_set_vap(dut, vap_id, "fils_fd_period", |
| 3588 | "0"); |
| 3589 | } |
| 3590 | |
| 3591 | if (dut->device_type == AP_testbed) |
| 3592 | owrt_ap_set_vap(dut, vap_id, "mbo", "1"); |
| 3593 | } |
| 3594 | |
| 3595 | /* NAIRealm */ |
| 3596 | if (dut->ap_nairealm_int == 1) { |
| 3597 | snprintf(buf, sizeof(buf), "\"%s\"", dut->ap_nairealm); |
| 3598 | owrt_ap_set_vap(dut, vap_id, "fils_realm", buf); |
| 3599 | owrt_ap_set_vap(dut, vap_id, "erp_domain", buf); |
| 3600 | } |
| 3601 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3602 | /* SSID */ |
| 3603 | snprintf(buf, sizeof(buf), "\"%s\"", dut->ap_ssid); |
| 3604 | owrt_ap_set_vap(dut, vap_count, "ssid", buf); |
| 3605 | |
| 3606 | /* Encryption */ |
| 3607 | switch (dut->ap_key_mgmt) { |
| 3608 | case AP_OPEN: |
| 3609 | if (dut->ap_cipher == AP_WEP) { |
| 3610 | owrt_ap_set_vap(dut, vap_count, "encryption", |
| 3611 | "wep-mixed"); |
| 3612 | owrt_ap_set_vap(dut, vap_count, "key", |
| 3613 | dut->ap_wepkey); |
| 3614 | } else { |
| 3615 | owrt_ap_set_vap(dut, vap_count, "encryption", |
| 3616 | "none"); |
| 3617 | } |
priyadharshini gowthaman | 0454706 | 2018-01-15 11:59:55 -0800 | [diff] [blame] | 3618 | if (dut->ap_key_mgmt == AP_OPEN && |
| 3619 | dut->ap_tag_key_mgmt[0] == AP2_WPA2_OWE) { |
| 3620 | /* OWE transition mode */ |
| 3621 | snprintf(ifname2, sizeof(ifname2), "%s1", |
| 3622 | ifname); |
| 3623 | owrt_ap_set_vap(dut, vap_count, |
| 3624 | "owe_transition_ifname", |
| 3625 | ifname2); |
| 3626 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3627 | break; |
| 3628 | case AP_WPA2_PSK: |
| 3629 | case AP_WPA2_PSK_MIXED: |
| 3630 | case AP_WPA_PSK: |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 3631 | case AP_WPA2_SAE: |
| 3632 | case AP_WPA2_PSK_SAE: |
priyadharshini gowthaman | cce6ca0 | 2018-01-15 11:12:45 -0800 | [diff] [blame] | 3633 | if (dut->ap_key_mgmt == AP_WPA2_PSK || |
| 3634 | dut->ap_key_mgmt == AP_WPA2_PSK_SAE) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3635 | snprintf(buf, sizeof(buf), "psk2"); |
| 3636 | } else if (dut->ap_key_mgmt == AP_WPA2_PSK_MIXED) { |
| 3637 | snprintf(buf, sizeof(buf), "psk-mixed"); |
priyadharshini gowthaman | cce6ca0 | 2018-01-15 11:12:45 -0800 | [diff] [blame] | 3638 | } else if (dut->ap_key_mgmt == AP_WPA2_SAE) { |
| 3639 | snprintf(buf, sizeof(buf), "ccmp"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3640 | } else { |
| 3641 | snprintf(buf, sizeof(buf), "psk"); |
| 3642 | } |
| 3643 | |
priyadharshini gowthaman | cce6ca0 | 2018-01-15 11:12:45 -0800 | [diff] [blame] | 3644 | if (dut->ap_key_mgmt != AP_WPA2_SAE) { |
| 3645 | if (dut->ap_cipher == AP_CCMP_TKIP) |
| 3646 | strlcat(buf, "+ccmp+tkip", sizeof(buf)); |
| 3647 | else if (dut->ap_cipher == AP_TKIP) |
| 3648 | strlcat(buf, "+tkip", sizeof(buf)); |
Alexei Avshalom Lazar | 2712cc8 | 2018-12-23 16:29:14 +0200 | [diff] [blame] | 3649 | else if (dut->ap_cipher == AP_GCMP_128) |
| 3650 | strlcat(buf, "+gcmp", sizeof(buf)); |
priyadharshini gowthaman | cce6ca0 | 2018-01-15 11:12:45 -0800 | [diff] [blame] | 3651 | else |
| 3652 | strlcat(buf, "+ccmp", sizeof(buf)); |
| 3653 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3654 | |
| 3655 | owrt_ap_set_vap(dut, vap_count, "encryption", buf); |
priyadharshini gowthaman | cce6ca0 | 2018-01-15 11:12:45 -0800 | [diff] [blame] | 3656 | |
| 3657 | if (!dut->ap_passphrase[0] && dut->ap_psk[0]) { |
| 3658 | snprintf(buf, sizeof(buf), "\"%s\"", |
| 3659 | dut->ap_psk); |
| 3660 | owrt_ap_set_vap(dut, vap_count, "key", buf); |
| 3661 | } else { |
| 3662 | snprintf(buf, sizeof(buf), "\"%s\"", |
| 3663 | dut->ap_passphrase); |
| 3664 | owrt_ap_set_vap(dut, vap_count, "key", buf); |
| 3665 | } |
| 3666 | |
| 3667 | if (dut->ap_key_mgmt == AP_WPA2_SAE || |
| 3668 | dut->ap_key_mgmt == AP_WPA2_PSK_SAE) |
| 3669 | owrt_ap_set_vap(dut, vap_count, "sae", "1"); |
| 3670 | else |
| 3671 | owrt_ap_set_vap(dut, vap_count, "sae", "0"); |
| 3672 | |
| 3673 | if (dut->ap_key_mgmt == AP_WPA2_SAE) { |
| 3674 | snprintf(buf, sizeof(buf), "%s", |
| 3675 | dut->ap_passphrase); |
| 3676 | owrt_ap_set_vap(dut, vap_count, "sae_password", |
| 3677 | buf); |
| 3678 | } else { |
| 3679 | snprintf(buf, sizeof(buf), "%s", |
| 3680 | dut->ap_passphrase); |
| 3681 | owrt_ap_set_vap(dut, vap_count, |
| 3682 | "wpa_passphrase", buf); |
| 3683 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3684 | break; |
| 3685 | case AP_WPA2_EAP: |
| 3686 | case AP_WPA2_EAP_MIXED: |
| 3687 | case AP_WPA_EAP: |
| 3688 | if (dut->ap_key_mgmt == AP_WPA2_EAP) { |
| 3689 | snprintf(buf, sizeof(buf), "wpa2"); |
| 3690 | } else if (dut->ap_key_mgmt == AP_WPA2_EAP_MIXED) { |
| 3691 | snprintf(buf, sizeof(buf), "wpa-mixed"); |
| 3692 | } else { |
| 3693 | snprintf(buf, sizeof(buf), "wpa"); |
| 3694 | } |
| 3695 | |
Peng Xu | 591be45 | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 3696 | if (dut->ap_cipher == AP_CCMP_TKIP) |
| 3697 | strlcat(buf, "+ccmp+tkip", sizeof(buf)); |
| 3698 | else if (dut->ap_cipher == AP_TKIP) |
| 3699 | strlcat(buf, "+tkip", sizeof(buf)); |
| 3700 | else |
| 3701 | strlcat(buf, "+ccmp", sizeof(buf)); |
| 3702 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3703 | owrt_ap_set_vap(dut, vap_count, "encryption", buf); |
| 3704 | snprintf(buf, sizeof(buf), "%s", dut->ap_radius_ipaddr); |
| 3705 | owrt_ap_set_vap(dut, vap_count, "auth_server", buf); |
| 3706 | snprintf(buf, sizeof(buf), "%d", dut->ap_radius_port); |
| 3707 | owrt_ap_set_vap(dut, vap_count, "auth_port", buf); |
| 3708 | snprintf(buf, sizeof(buf), "%s", |
| 3709 | dut->ap_radius_password); |
| 3710 | owrt_ap_set_vap(dut, vap_count, "auth_secret", buf); |
| 3711 | break; |
Jouni Malinen | 4cf699f | 2018-06-19 00:46:27 +0300 | [diff] [blame] | 3712 | case AP_WPA2_EAP_OSEN: |
Jouni Malinen | c2b9121 | 2018-09-12 02:26:39 +0300 | [diff] [blame] | 3713 | case AP_OSEN: |
Jouni Malinen | 6be21c8 | 2018-08-01 18:47:24 +0300 | [diff] [blame] | 3714 | case AP_WPA2_FT_EAP: |
| 3715 | case AP_WPA2_FT_PSK: |
| 3716 | case AP_WPA2_EAP_SHA256: |
| 3717 | case AP_WPA2_PSK_SHA256: |
| 3718 | case AP_WPA2_ENT_FT_EAP: |
Jouni Malinen | 4cf699f | 2018-06-19 00:46:27 +0300 | [diff] [blame] | 3719 | /* TODO */ |
| 3720 | break; |
Jouni Malinen | ad395a2 | 2017-09-01 21:13:46 +0300 | [diff] [blame] | 3721 | case AP_SUITEB: |
priyadharshini gowthaman | 2136bd5 | 2018-01-15 11:28:55 -0800 | [diff] [blame] | 3722 | owrt_ap_set_vap(dut, vap_count, "suite_b", "192"); |
| 3723 | snprintf(buf, sizeof(buf), "gcmp"); |
| 3724 | owrt_ap_set_vap(dut, vap_count, "encryption", buf); |
| 3725 | snprintf(buf, sizeof(buf), "%s", dut->ap_radius_ipaddr); |
| 3726 | owrt_ap_set_vap(dut, vap_count, "auth_server", buf); |
| 3727 | snprintf(buf, sizeof(buf), "%d", dut->ap_radius_port); |
| 3728 | owrt_ap_set_vap(dut, vap_count, "auth_port", buf); |
| 3729 | snprintf(buf, sizeof(buf), "%s", |
| 3730 | dut->ap_radius_password); |
| 3731 | owrt_ap_set_vap(dut, vap_count, "auth_secret", buf); |
| 3732 | snprintf(buf, sizeof(buf), "%d", |
| 3733 | dut->ap_group_mgmt_cipher); |
| 3734 | owrt_ap_set_vap(dut, vap_count, "group_mgmt_cipher", |
| 3735 | buf); |
Jouni Malinen | ad395a2 | 2017-09-01 21:13:46 +0300 | [diff] [blame] | 3736 | break; |
Jouni Malinen | 147b3c3 | 2017-10-09 16:51:54 +0300 | [diff] [blame] | 3737 | case AP_WPA2_OWE: |
priyadharshini gowthaman | 0454706 | 2018-01-15 11:59:55 -0800 | [diff] [blame] | 3738 | owrt_ap_set_vap(dut, vap_count, "owe", "1"); |
| 3739 | snprintf(buf, sizeof(buf), "ccmp"); |
| 3740 | owrt_ap_set_vap(dut, vap_count, "encryption", buf); |
| 3741 | if (dut->ap_sae_groups) { |
| 3742 | snprintf(buf, sizeof(buf), "\'%s\'", |
| 3743 | dut->ap_sae_groups); |
priyadharshini gowthaman | b59bfe4 | 2018-08-30 15:14:08 -0700 | [diff] [blame] | 3744 | owrt_ap_set_list_vap(dut, vap_count, |
| 3745 | "owe_groups", buf); |
priyadharshini gowthaman | 0454706 | 2018-01-15 11:59:55 -0800 | [diff] [blame] | 3746 | } |
| 3747 | |
| 3748 | if (dut->ap_key_mgmt == AP_WPA2_OWE && |
| 3749 | dut->ap_tag_ssid[0][0] && |
| 3750 | dut->ap_tag_key_mgmt[0] == AP2_OPEN) { |
| 3751 | /* OWE transition mode */ |
| 3752 | snprintf(ifname2, sizeof(ifname2), "%s1", |
| 3753 | ifname); |
| 3754 | owrt_ap_set_vap(dut, vap_count, |
| 3755 | "owe_transition_ifname", |
| 3756 | ifname2); |
| 3757 | owrt_ap_set_vap(dut, vap_count, "hidden", "1"); |
| 3758 | } |
Jouni Malinen | 147b3c3 | 2017-10-09 16:51:54 +0300 | [diff] [blame] | 3759 | break; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3760 | } |
| 3761 | |
| 3762 | if (!dut->ap_is_dual) |
| 3763 | break; |
| 3764 | } |
| 3765 | |
| 3766 | if (dut->ap_is_dual) |
| 3767 | return 1; |
| 3768 | |
| 3769 | /* PMF */ |
| 3770 | snprintf(buf, sizeof(buf), "%d", dut->ap_pmf); |
| 3771 | owrt_ap_set_vap(dut, vap_id, "ieee80211w", buf); |
| 3772 | |
| 3773 | /* Add SHA256 */ |
| 3774 | snprintf(buf, sizeof(buf), "%d", dut->ap_add_sha256); |
| 3775 | owrt_ap_set_vap(dut, vap_id, "add_sha256", buf); |
| 3776 | |
priyadharshini gowthaman | de81f39 | 2017-12-28 15:28:49 -0800 | [diff] [blame] | 3777 | /* Add SHA384 for akmsuitetype 15 */ |
| 3778 | if (dut->ap_akm == 1) { |
| 3779 | snprintf(buf, sizeof(buf), "%d", dut->ap_add_sha384); |
| 3780 | owrt_ap_set_vap(dut, vap_id, "add_sha384", buf); |
| 3781 | } |
| 3782 | |
Sarvepalli, Rajesh Babu | 24dc7e4 | 2016-03-18 21:27:26 +0530 | [diff] [blame] | 3783 | /* Enable RSN preauthentication, if asked to */ |
| 3784 | snprintf(buf, sizeof(buf), "%d", dut->ap_rsn_preauth); |
| 3785 | owrt_ap_set_vap(dut, vap_id, "rsn_preauth", buf); |
| 3786 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3787 | /* Hotspot 2.0 */ |
| 3788 | if (dut->ap_hs2) { |
| 3789 | int ret; |
| 3790 | |
| 3791 | ret = owrt_ap_config_vap_hs2(dut, vap_id); |
| 3792 | if (ret) |
| 3793 | return ret; |
| 3794 | } |
| 3795 | |
| 3796 | /* Interworking */ |
| 3797 | if (dut->ap_interworking) { |
| 3798 | snprintf(buf, sizeof(buf), "%d", dut->ap_access_net_type); |
| 3799 | owrt_ap_set_vap(dut, vap_id, "access_network_type", buf); |
| 3800 | snprintf(buf, sizeof(buf), "%d", dut->ap_internet); |
| 3801 | owrt_ap_set_vap(dut, vap_id, "internet", buf); |
| 3802 | snprintf(buf, sizeof(buf), "%d", dut->ap_venue_group); |
| 3803 | owrt_ap_set_vap(dut, vap_id, "venue_group", buf); |
| 3804 | snprintf(buf, sizeof(buf), "%d", dut->ap_venue_type); |
| 3805 | owrt_ap_set_vap(dut, vap_id, "venue_type", buf); |
| 3806 | snprintf(buf, sizeof(buf), "%s", dut->ap_hessid); |
| 3807 | owrt_ap_set_vap(dut, vap_id, "hessid", buf); |
| 3808 | |
| 3809 | if (dut->ap_gas_cb_delay > 0) { |
| 3810 | snprintf(buf, sizeof(buf), "%d", dut->ap_gas_cb_delay); |
| 3811 | owrt_ap_set_vap(dut, vap_id, "gas_comeback_delay", buf); |
| 3812 | } |
| 3813 | |
| 3814 | if (dut->ap_roaming_cons[0]) { |
| 3815 | char *rcons, *temp_ptr; |
| 3816 | |
| 3817 | rcons = strdup(dut->ap_roaming_cons); |
| 3818 | if (rcons == NULL) |
Jouni Malinen | 1370122 | 2019-02-19 12:10:53 +0200 | [diff] [blame] | 3819 | return -1; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3820 | |
| 3821 | temp_ptr = strchr(rcons, ';'); |
| 3822 | |
| 3823 | if (temp_ptr) |
| 3824 | *temp_ptr++ = '\0'; |
| 3825 | |
| 3826 | owrt_ap_set_list_vap(dut, vap_id, "roaming_consortium", |
| 3827 | rcons); |
| 3828 | |
| 3829 | if (temp_ptr) |
| 3830 | owrt_ap_set_list_vap(dut, vap_id, |
| 3831 | "roaming_consortium", |
| 3832 | temp_ptr); |
| 3833 | |
| 3834 | free(rcons); |
| 3835 | } |
| 3836 | } |
| 3837 | |
| 3838 | if (dut->ap_venue_name) { |
| 3839 | owrt_ap_set_list_vap(dut, vap_id, "venue_name", |
| 3840 | "'P\"eng:Wi-Fi Alliance\\n2989 Copper Road\\nSanta Clara, CA 95051, USA\"'"); |
| 3841 | owrt_ap_set_list_vap(dut, vap_id, "venue_name", |
| 3842 | "\'"ANQP_VENUE_NAME_1_CHI"\'"); |
| 3843 | } |
| 3844 | |
| 3845 | if (dut->ap_net_auth_type == 1) { |
priyadharshini gowthaman | 9b8a8c3 | 2018-08-31 10:49:24 -0700 | [diff] [blame] | 3846 | owrt_ap_set_list_vap(dut, vap_id, "network_auth_type", |
| 3847 | "'00https://tandc-server.wi-fi.org'"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3848 | } else if (dut->ap_net_auth_type == 2) { |
priyadharshini gowthaman | 9b8a8c3 | 2018-08-31 10:49:24 -0700 | [diff] [blame] | 3849 | owrt_ap_set_list_vap(dut, vap_id, "network_auth_type", "'01'"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3850 | } |
| 3851 | |
| 3852 | if (dut->ap_nai_realm_list == 1) { |
| 3853 | owrt_ap_set_list_vap(dut, vap_id, "nai_realm", |
| 3854 | "'0,mail.example.com;cisco.com;wi-fi.org,21[2:4][5:7]'"); |
| 3855 | owrt_ap_set_list_vap(dut, vap_id, "nai_realm", |
| 3856 | "'0,wi-fi.org;example.com,13[5:6]'"); |
| 3857 | |
| 3858 | } else if (dut->ap_nai_realm_list == 2) { |
| 3859 | owrt_ap_set_list_vap(dut, vap_id, "nai_realm", |
| 3860 | "'0,wi-fi.org,21[2:4][5:7]'"); |
| 3861 | } else if (dut->ap_nai_realm_list == 3) { |
| 3862 | owrt_ap_set_list_vap(dut, vap_id, "nai_realm", |
| 3863 | "'0,cisco.com;wi-fi.org,21[2:4][5:7]'"); |
| 3864 | owrt_ap_set_list_vap(dut, vap_id, "nai_realm", |
| 3865 | "'0,wi-fi.org;example.com,13[5:6]'"); |
| 3866 | } else if (dut->ap_nai_realm_list == 4) { |
| 3867 | owrt_ap_set_list_vap(dut, vap_id, "nai_realm", |
| 3868 | "'0,mail.example.com,21[2:4][5:7],13[5:6]'"); |
| 3869 | } else if (dut->ap_nai_realm_list == 5) { |
| 3870 | owrt_ap_set_list_vap(dut, vap_id, "nai_realm", |
| 3871 | "'0,wi-fi.org;ruckuswireless.com,21[2:4][5:7]'"); |
| 3872 | } else if (dut->ap_nai_realm_list == 6) { |
| 3873 | owrt_ap_set_list_vap(dut, vap_id, "nai_realm", |
| 3874 | "'0,wi-fi.org;mail.example.com,21[2:4][5:7]'"); |
| 3875 | } else if (dut->ap_nai_realm_list == 7) { |
| 3876 | owrt_ap_set_list_vap(dut, vap_id, "nai_realm", |
| 3877 | "'0,wi-fi.org,13[5:6]'"); |
| 3878 | owrt_ap_set_list_vap(dut, vap_id, "nai_realm", |
| 3879 | "'0,wi-fi.org,21[2:4][5:7]'"); |
| 3880 | } |
| 3881 | |
| 3882 | if (dut->ap_domain_name_list[0]) |
| 3883 | owrt_ap_set_list_vap(dut, vap_id, "domain_name", |
| 3884 | dut->ap_domain_name_list); |
| 3885 | |
| 3886 | if (dut->ap_ip_addr_type_avail) |
| 3887 | owrt_ap_set_vap(dut, vap_id, "ipaddr_type_availability", |
| 3888 | "'0c'"); |
| 3889 | |
| 3890 | temp = buf; |
| 3891 | |
| 3892 | *temp++ = '\''; |
| 3893 | |
| 3894 | for (i = 0; dut->ap_plmn_mcc[i][0] && dut->ap_plmn_mnc[i][0]; i++) { |
| 3895 | if (i) |
| 3896 | *temp++ = ';'; |
| 3897 | |
| 3898 | snprintf(temp, |
| 3899 | sizeof(dut->ap_plmn_mcc[i]) + |
| 3900 | sizeof(dut->ap_plmn_mnc[i]) + 1, |
| 3901 | "%s,%s", |
| 3902 | dut->ap_plmn_mcc[i], |
| 3903 | dut->ap_plmn_mnc[i]); |
| 3904 | |
| 3905 | temp += strlen(dut->ap_plmn_mcc[i]) + |
| 3906 | strlen(dut->ap_plmn_mnc[i]) + 1; |
| 3907 | } |
| 3908 | |
| 3909 | *temp++ = '\''; |
| 3910 | *temp++ = '\0'; |
| 3911 | |
| 3912 | if (i) |
| 3913 | owrt_ap_set_vap(dut, vap_id, "anqp_3gpp_cell_net", buf); |
| 3914 | |
| 3915 | if (dut->ap_qos_map_set == 1) |
| 3916 | owrt_ap_set_vap(dut, vap_id, "qos_map_set", QOS_MAP_SET_1); |
| 3917 | else if (dut->ap_qos_map_set == 2) |
| 3918 | owrt_ap_set_vap(dut, vap_id, "qos_map_set", QOS_MAP_SET_2); |
| 3919 | |
| 3920 | /* Proxy-ARP */ |
| 3921 | snprintf(buf, sizeof(buf), "%d", dut->ap_proxy_arp); |
| 3922 | owrt_ap_set_vap(dut, vap_id, "proxyarp", buf); |
| 3923 | |
| 3924 | /* DGAF */ |
| 3925 | snprintf(buf, sizeof(buf), "%d", dut->ap_dgaf_disable); |
| 3926 | /* parse to hostapd */ |
| 3927 | owrt_ap_set_vap(dut, vap_id, "disable_dgaf", buf); |
| 3928 | /* parse to wifi driver */ |
| 3929 | owrt_ap_set_vap(dut, vap_id, "dgaf_disable", buf); |
| 3930 | |
| 3931 | /* HCBSSLoad */ |
| 3932 | if (dut->ap_bss_load) { |
| 3933 | unsigned int bssload = 0; |
| 3934 | |
| 3935 | if (dut->ap_bss_load == 1) { |
| 3936 | /* STA count: 1, CU: 50, AAC: 65535 */ |
| 3937 | bssload = 0x0132ffff; |
| 3938 | } else if (dut->ap_bss_load == 2) { |
| 3939 | /* STA count: 1, CU: 200, AAC: 65535 */ |
| 3940 | bssload = 0x01c8ffff; |
| 3941 | } else if (dut->ap_bss_load == 3) { |
| 3942 | /* STA count: 1, CU: 75, AAC: 65535 */ |
| 3943 | bssload = 0x014bffff; |
| 3944 | } |
| 3945 | |
| 3946 | snprintf(buf, sizeof(buf), "%d", bssload); |
| 3947 | owrt_ap_set_vap(dut, vap_id, "hcbssload", buf); |
| 3948 | } |
| 3949 | |
| 3950 | /* L2TIF */ |
| 3951 | if (dut->ap_l2tif) |
| 3952 | owrt_ap_set_vap(dut, vap_id, "l2tif", "1"); |
| 3953 | |
| 3954 | if (dut->ap_disable_protection == 1) |
| 3955 | owrt_ap_set_vap(dut, vap_id, "enablertscts", "0"); |
| 3956 | |
Sunil Dutt | 77b213d | 2017-09-14 18:24:40 +0300 | [diff] [blame] | 3957 | if (dut->ap_txBF) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3958 | owrt_ap_set_vap(dut, vap_id, "vhtsubfee", "1"); |
| 3959 | owrt_ap_set_vap(dut, vap_id, "vhtsubfer", "1"); |
Priyadharshini Gowthaman | e216dc5 | 2019-11-08 14:22:16 -0800 | [diff] [blame] | 3960 | if (dut->program == PROGRAM_HE) { |
| 3961 | owrt_ap_set_vap(dut, vap_id, "he_subfer", "1"); |
| 3962 | owrt_ap_set_vap(dut, vap_id, "cwmenable", "0"); |
| 3963 | } |
| 3964 | } else { |
| 3965 | owrt_ap_set_vap(dut, vap_id, "vhtsubfee", "0"); |
| 3966 | owrt_ap_set_vap(dut, vap_id, "vhtsubfer", "0"); |
| 3967 | if (dut->program == PROGRAM_HE) |
| 3968 | owrt_ap_set_vap(dut, vap_id, "he_subfer", "0"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3969 | } |
| 3970 | |
Priyadharshini Gowthaman | e216dc5 | 2019-11-08 14:22:16 -0800 | [diff] [blame] | 3971 | if (dut->ap_mu_txBF) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3972 | owrt_ap_set_vap(dut, vap_id, "vhtmubfer", "1"); |
Priyadharshini Gowthaman | e216dc5 | 2019-11-08 14:22:16 -0800 | [diff] [blame] | 3973 | if (dut->program == PROGRAM_HE) { |
| 3974 | owrt_ap_set_vap(dut, vap_id, "he_mubfer", "1"); |
| 3975 | owrt_ap_set_vap(dut, vap_id, "he_mubfee", "1"); |
| 3976 | } |
| 3977 | } else { |
| 3978 | owrt_ap_set_vap(dut, vap_id, "vhtmubfer", "0"); |
| 3979 | if (dut->program == PROGRAM_HE) { |
| 3980 | owrt_ap_set_vap(dut, vap_id, "he_mubfer", "0"); |
| 3981 | owrt_ap_set_vap(dut, vap_id, "he_mubfee", "0"); |
| 3982 | } |
| 3983 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3984 | |
Vasanthakumar Pandurangan | 2b5431d | 2016-01-12 15:52:48 +0530 | [diff] [blame] | 3985 | if (dut->ap_tx_stbc) { |
| 3986 | /* STBC and beamforming are mutually exclusive features */ |
| 3987 | owrt_ap_set_vap(dut, vap_id, "implicitbf", "0"); |
| 3988 | } |
| 3989 | |
Priyadharshini Gowthaman | 8fb1504 | 2015-11-25 18:27:41 +0530 | [diff] [blame] | 3990 | /* enable dfsmode */ |
| 3991 | snprintf(buf, sizeof(buf), "%d", dut->ap_dfs_mode); |
| 3992 | owrt_ap_set_vap(dut, vap_id, "doth", buf); |
| 3993 | |
priyadharshini gowthaman | 2323d0a | 2016-09-02 15:48:02 -0700 | [diff] [blame] | 3994 | if (dut->program == PROGRAM_LOC && dut->ap_interworking) { |
| 3995 | char anqpval[1024]; |
| 3996 | |
| 3997 | owrt_ap_set_vap(dut, vap_id, "interworking", "1"); |
| 3998 | |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 3999 | 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] | 4000 | snprintf(anqpval, sizeof(anqpval), |
| 4001 | "'265:0010%s%s060101'", |
priyadharshini gowthaman | 2323d0a | 2016-09-02 15:48:02 -0700 | [diff] [blame] | 4002 | dut->ap_val_lci, dut->ap_infoz); |
| 4003 | owrt_ap_set_list_vap(dut, vap_id, "anqp_elem", anqpval); |
| 4004 | } |
| 4005 | |
| 4006 | if (dut->ap_lcr == 1) { |
Pradeep Reddy Potteti | b48012a | 2016-11-28 16:58:54 +0530 | [diff] [blame] | 4007 | snprintf(anqpval, sizeof(anqpval), |
| 4008 | "'266:0000b2555302ae%s'", |
priyadharshini gowthaman | 2323d0a | 2016-09-02 15:48:02 -0700 | [diff] [blame] | 4009 | dut->ap_val_lcr); |
| 4010 | owrt_ap_set_list_vap(dut, vap_id, "anqp_elem", anqpval); |
| 4011 | } |
| 4012 | |
| 4013 | if (dut->ap_fqdn_held == 1 && dut->ap_fqdn_supl == 1) |
| 4014 | owrt_ap_set_list_vap(dut, vap_id, "anqp_elem", |
| 4015 | "'267:00110168656c642e6578616d706c652e636f6d0011027375706c2e6578616d706c652e636f6d'"); |
| 4016 | } |
| 4017 | |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 4018 | if (dut->program == PROGRAM_MBO) { |
| 4019 | owrt_ap_set_vap(dut, vap_id, "interworking", "1"); |
| 4020 | owrt_ap_set_vap(dut, vap_id, "mbo", "1"); |
| 4021 | owrt_ap_set_vap(dut, vap_id, "rrm", "1"); |
Adil Saeed Musthafa | 65160c0 | 2017-04-10 23:13:38 -0700 | [diff] [blame] | 4022 | owrt_ap_set_vap(dut, vap_id, "mbo_cell_conn_pref", "1"); |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 4023 | |
| 4024 | owrt_ap_set_list_vap(dut, vap_id, "anqp_elem", |
| 4025 | "'272:34108cfdf0020df1f7000000733000030101'"); |
Adil Saeed Musthafa | ed5faae | 2017-04-10 23:13:36 -0700 | [diff] [blame] | 4026 | snprintf(buf, sizeof(buf), "%d", dut->ap_gas_cb_delay); |
| 4027 | owrt_ap_set_vap(dut, vap_id, "gas_comeback_delay", buf); |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 4028 | } |
| 4029 | |
Jouni Malinen | 6be21c8 | 2018-08-01 18:47:24 +0300 | [diff] [blame] | 4030 | if (ap_ft_enabled(dut)) { |
Adil Saeed Musthafa | 4ec61bd | 2017-04-10 23:13:41 -0700 | [diff] [blame] | 4031 | unsigned char self_mac[ETH_ALEN]; |
| 4032 | char mac_str[20]; |
| 4033 | |
Jouni Malinen | 9f94331 | 2019-08-19 23:49:16 +0300 | [diff] [blame] | 4034 | owrt_ap_set_vap(dut, vap_id, "ft_over_ds", |
| 4035 | dut->ap_ft_ds == VALUE_ENABLED ? "1" : "0"); |
Adil Saeed Musthafa | 4ec61bd | 2017-04-10 23:13:41 -0700 | [diff] [blame] | 4036 | owrt_ap_set_vap(dut, vap_id, "ieee80211r", "1"); |
Jouni Malinen | 1370122 | 2019-02-19 12:10:53 +0200 | [diff] [blame] | 4037 | if (get_hwaddr(sigma_radio_ifname[0], self_mac) < 0) |
| 4038 | return -1; |
Adil Saeed Musthafa | 4ec61bd | 2017-04-10 23:13:41 -0700 | [diff] [blame] | 4039 | snprintf(mac_str, sizeof(mac_str), |
| 4040 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 4041 | self_mac[0], self_mac[1], self_mac[2], |
| 4042 | self_mac[3], self_mac[4], self_mac[5]); |
| 4043 | owrt_ap_set_vap(dut, vap_id, "ap_macaddr", mac_str); |
priyadharshini gowthaman | 47189f5 | 2017-12-28 12:37:46 -0800 | [diff] [blame] | 4044 | snprintf(mac_str, sizeof(mac_str), |
| 4045 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 4046 | self_mac[0], self_mac[1], self_mac[2], |
| 4047 | self_mac[3], self_mac[4], self_mac[5]); |
| 4048 | 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] | 4049 | owrt_ap_set_vap(dut, vap_id, "ft_psk_generate_local", "1"); |
| 4050 | owrt_ap_set_vap(dut, vap_id, "kh_key_hex", |
| 4051 | "000102030405060708090a0b0c0d0e0f"); |
| 4052 | snprintf(mac_str, sizeof(mac_str), |
| 4053 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 4054 | dut->ft_bss_mac_list[0][0], |
| 4055 | dut->ft_bss_mac_list[0][1], |
| 4056 | dut->ft_bss_mac_list[0][2], |
| 4057 | dut->ft_bss_mac_list[0][3], |
| 4058 | dut->ft_bss_mac_list[0][4], |
| 4059 | dut->ft_bss_mac_list[0][5]); |
| 4060 | owrt_ap_set_vap(dut, vap_id, "ap2_macaddr", mac_str); |
priyadharshini gowthaman | 47189f5 | 2017-12-28 12:37:46 -0800 | [diff] [blame] | 4061 | owrt_ap_set_vap(dut, vap_id, "mobility_domain", |
| 4062 | dut->ap_mobility_domain); |
| 4063 | 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] | 4064 | } |
| 4065 | |
Jouni Malinen | 6be21c8 | 2018-08-01 18:47:24 +0300 | [diff] [blame] | 4066 | if ((ap_ft_enabled(dut) && dut->ap_name == 0) || |
| 4067 | (ap_ft_enabled(dut) && dut->ap_name == 2)) { |
Adil Saeed Musthafa | 4ec61bd | 2017-04-10 23:13:41 -0700 | [diff] [blame] | 4068 | owrt_ap_set_vap(dut, vap_id, "nasid2", "nas2.example.com"); |
| 4069 | owrt_ap_set_vap(dut, vap_id, "nasid", "nas1.example.com"); |
Adil Saeed Musthafa | 4ec61bd | 2017-04-10 23:13:41 -0700 | [diff] [blame] | 4070 | } |
| 4071 | |
Jouni Malinen | 6be21c8 | 2018-08-01 18:47:24 +0300 | [diff] [blame] | 4072 | if (ap_ft_enabled(dut) && dut->ap_name == 1) { |
Adil Saeed Musthafa | 4ec61bd | 2017-04-10 23:13:41 -0700 | [diff] [blame] | 4073 | owrt_ap_set_vap(dut, vap_id, "nasid2", "nas1.example.com"); |
| 4074 | owrt_ap_set_vap(dut, vap_id, "nasid", "nas2.example.com"); |
Adil Saeed Musthafa | 4ec61bd | 2017-04-10 23:13:41 -0700 | [diff] [blame] | 4075 | } |
| 4076 | |
priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 4077 | if (dut->ap_broadcast_ssid == VALUE_DISABLED) |
| 4078 | owrt_ap_set_vap(dut, vap_id, "hidden", "1"); |
| 4079 | |
priyadharshini gowthaman | de81f39 | 2017-12-28 15:28:49 -0800 | [diff] [blame] | 4080 | /* Enable/disable PMKSA caching, if asked to */ |
| 4081 | if (dut->ap_pmksa == 1) { |
| 4082 | snprintf(buf, sizeof(buf), "%d", dut->ap_pmksa_caching); |
| 4083 | owrt_ap_set_vap(dut, vap_id, "disable_pmksa_caching", buf); |
| 4084 | } |
| 4085 | |
priyadharshini gowthaman | cce6ca0 | 2018-01-15 11:12:45 -0800 | [diff] [blame] | 4086 | if (dut->rsne_override) { |
| 4087 | snprintf(buf, sizeof(buf), "%s", dut->rsne_override); |
| 4088 | owrt_ap_set_vap(dut, vap_count, "own_ie_override", buf); |
| 4089 | } |
| 4090 | |
Jouni Malinen | 7960e3a | 2019-12-07 17:04:35 +0200 | [diff] [blame] | 4091 | if (dut->rsnxe_override_eapol) |
| 4092 | owrt_ap_set_vap(dut, vap_count, "rsnxe_override_eapol", |
| 4093 | dut->rsnxe_override_eapol); |
| 4094 | |
priyadharshini gowthaman | cce6ca0 | 2018-01-15 11:12:45 -0800 | [diff] [blame] | 4095 | if (dut->sae_commit_override) { |
| 4096 | snprintf(buf, sizeof(buf), "%s", dut->sae_commit_override); |
| 4097 | owrt_ap_set_vap(dut, vap_count, "sae_commit_override", buf); |
| 4098 | } |
| 4099 | |
| 4100 | if (dut->ap_sae_groups) { |
| 4101 | snprintf(buf, sizeof(buf), "\'%s\'", dut->ap_sae_groups); |
priyadharshini gowthaman | b59bfe4 | 2018-08-30 15:14:08 -0700 | [diff] [blame] | 4102 | owrt_ap_set_list_vap(dut, vap_count, "sae_groups", buf); |
priyadharshini gowthaman | cce6ca0 | 2018-01-15 11:12:45 -0800 | [diff] [blame] | 4103 | } |
| 4104 | |
Jouni Malinen | 11e5521 | 2019-11-22 21:46:59 +0200 | [diff] [blame] | 4105 | if (dut->sae_pwe != SAE_PWE_DEFAULT || dut->sae_h2e_default) { |
| 4106 | const char *sae_pwe = NULL; |
| 4107 | |
| 4108 | if (dut->sae_pwe == SAE_PWE_LOOP) |
| 4109 | sae_pwe = "0"; |
| 4110 | else if (dut->sae_pwe == SAE_PWE_H2E) |
| 4111 | sae_pwe = "1"; |
| 4112 | else if (dut->sae_h2e_default) |
| 4113 | sae_pwe = "2"; |
| 4114 | if (sae_pwe) |
| 4115 | owrt_ap_set_vap(dut, vap_count, "sae_pwe", sae_pwe); |
| 4116 | } |
| 4117 | |
priyadharshini gowthaman | cce6ca0 | 2018-01-15 11:12:45 -0800 | [diff] [blame] | 4118 | if (dut->sae_anti_clogging_threshold >= 0) { |
| 4119 | snprintf(buf, sizeof(buf), "%d", |
| 4120 | dut->sae_anti_clogging_threshold); |
| 4121 | owrt_ap_set_vap(dut, vap_count, "sae_anti_clogging_threshold", |
| 4122 | buf); |
| 4123 | } |
| 4124 | |
| 4125 | if (dut->sae_reflection) |
| 4126 | owrt_ap_set_vap(dut, vap_count, "sae_reflection_attack", "1"); |
Jouni Malinen | 3c740ab | 2019-10-10 15:55:11 +0300 | [diff] [blame] | 4127 | if (dut->sae_confirm_immediate) |
| 4128 | owrt_ap_set_vap(dut, vap_count, "sae_confirm_immediate", "1"); |
priyadharshini gowthaman | cce6ca0 | 2018-01-15 11:12:45 -0800 | [diff] [blame] | 4129 | |
Priyadharshini Gowthaman | fe60c50 | 2019-08-14 13:00:34 -0700 | [diff] [blame] | 4130 | if (dut->ap_he_dlofdma == VALUE_ENABLED && dut->ap_he_ppdu == PPDU_MU) { |
| 4131 | dut->ap_txBF = 0; |
| 4132 | dut->ap_mu_txBF = 0; |
| 4133 | owrt_ap_set_vap(dut, vap_id, "vhtsubfer", "0"); |
| 4134 | owrt_ap_set_vap(dut, vap_id, "vhtsubfee", "0"); |
| 4135 | owrt_ap_set_vap(dut, vap_id, "he_subfer", "0"); |
| 4136 | } |
| 4137 | |
Priyadharshini Gowthaman | dee79e2 | 2019-10-07 16:56:27 -0700 | [diff] [blame] | 4138 | if (dut->program == PROGRAM_HE && |
| 4139 | (dut->ap_txBF || dut->ap_he_ulofdma == VALUE_ENABLED || |
| 4140 | dut->ap_he_mimo == MIMO_DL)) { |
| 4141 | switch (dut->ap_chwidth) { |
| 4142 | case AP_20: |
| 4143 | owrt_ap_set_vap(dut, vap_id, "chwidth", "0"); |
| 4144 | break; |
| 4145 | case AP_40: |
| 4146 | owrt_ap_set_vap(dut, vap_id, "chwidth", "1"); |
| 4147 | break; |
| 4148 | case AP_80: |
| 4149 | owrt_ap_set_vap(dut, vap_id, "chwidth", "2"); |
| 4150 | break; |
| 4151 | case AP_160: |
| 4152 | owrt_ap_set_vap(dut, vap_id, "chwidth", "3"); |
| 4153 | break; |
| 4154 | case AP_80_80: |
| 4155 | owrt_ap_set_vap(dut, vap_id, "chwidth", "3"); |
| 4156 | break; |
| 4157 | case AP_AUTO: |
| 4158 | default: |
| 4159 | break; |
| 4160 | } |
| 4161 | } |
| 4162 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4163 | return 1; |
| 4164 | } |
| 4165 | |
| 4166 | |
priyadharshini gowthaman | 2500f20 | 2016-10-13 17:13:55 -0700 | [diff] [blame] | 4167 | static int owrt_ap_config_vap_anqp(struct sigma_dut *dut) |
| 4168 | { |
| 4169 | char anqpval[1024]; |
| 4170 | unsigned char addr[6]; |
| 4171 | unsigned char addr2[6]; |
| 4172 | struct ifreq ifr; |
| 4173 | char *ifname; |
| 4174 | int s; |
| 4175 | int vap_id = 0; |
| 4176 | |
| 4177 | s = socket(AF_INET, SOCK_DGRAM, 0); |
| 4178 | if (s < 0) { |
| 4179 | sigma_dut_print(dut, DUT_MSG_ERROR, "Failed to open socket"); |
| 4180 | return -1; |
| 4181 | } |
| 4182 | |
| 4183 | memset(&ifr, 0, sizeof(ifr)); |
| 4184 | ifname = "ath0"; |
Peng Xu | b8fc5cc | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 4185 | strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name)); |
priyadharshini gowthaman | 2500f20 | 2016-10-13 17:13:55 -0700 | [diff] [blame] | 4186 | if (ioctl(s, SIOCGIFHWADDR, &ifr) < 0) { |
| 4187 | perror("ioctl"); |
| 4188 | close(s); |
| 4189 | return -1; |
| 4190 | } |
| 4191 | memcpy(addr, ifr.ifr_hwaddr.sa_data, 6); |
| 4192 | |
| 4193 | memset(&ifr, 0, sizeof(ifr)); |
| 4194 | ifname = "ath01"; |
Peng Xu | b8fc5cc | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 4195 | strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name)); |
priyadharshini gowthaman | 2500f20 | 2016-10-13 17:13:55 -0700 | [diff] [blame] | 4196 | if (ioctl(s, SIOCGIFHWADDR, &ifr) < 0) { |
| 4197 | perror("ioctl"); |
| 4198 | close(s); |
| 4199 | return -1; |
| 4200 | } |
| 4201 | close(s); |
| 4202 | memcpy(addr2, ifr.ifr_hwaddr.sa_data, 6); |
| 4203 | |
| 4204 | snprintf(anqpval, sizeof(anqpval), |
| 4205 | "'265:0010%s%s060101070d00%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x'", |
| 4206 | dut->ap_val_lci, dut->ap_infoz, |
| 4207 | addr[0], addr[1], addr[2], addr[3], addr[4], addr[5], |
| 4208 | addr2[0], addr2[1], addr2[2], addr2[3], addr2[4], addr2[5]); |
| 4209 | |
| 4210 | owrt_ap_set_list_vap(dut, vap_id, "anqp_elem", anqpval); |
| 4211 | return 0; |
| 4212 | } |
| 4213 | |
| 4214 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4215 | static int owrt_ap_post_config_commit(struct sigma_dut *dut, |
| 4216 | struct sigma_conn *conn, |
| 4217 | struct sigma_cmd *cmd) |
| 4218 | { |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 4219 | int ap_security = 0; |
| 4220 | int i; |
| 4221 | |
| 4222 | for (i = 0; i < MAX_WLAN_TAGS - 1; i++) { |
| 4223 | if (dut->ap_tag_key_mgmt[i] != AP2_OPEN) |
| 4224 | ap_security = 1; |
| 4225 | } |
| 4226 | if (dut->ap_key_mgmt != AP_OPEN) |
| 4227 | ap_security = 1; |
| 4228 | if (ap_security) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4229 | /* allow some time for hostapd to start before returning |
| 4230 | * success */ |
| 4231 | usleep(500000); |
| 4232 | |
| 4233 | if (run_hostapd_cli(dut, "ping") != 0) { |
| 4234 | send_resp(dut, conn, SIGMA_ERROR, |
| 4235 | "errorCode,Failed to talk to hostapd"); |
| 4236 | return 0; |
| 4237 | } |
| 4238 | } |
| 4239 | |
| 4240 | if (get_openwrt_driver_type() == OPENWRT_DRIVER_ATHEROS) |
| 4241 | ath_ap_set_params(dut); |
| 4242 | |
| 4243 | /* Send response */ |
| 4244 | return 1; |
| 4245 | } |
| 4246 | |
| 4247 | |
| 4248 | static int cmd_owrt_ap_config_commit(struct sigma_dut *dut, |
| 4249 | struct sigma_conn *conn, |
| 4250 | struct sigma_cmd *cmd) |
| 4251 | { |
priyadharshini gowthaman | b4de196 | 2018-01-15 12:21:04 -0800 | [diff] [blame] | 4252 | if (dut->program == PROGRAM_DPP && |
Jouni Malinen | 016ae6c | 2019-11-04 17:00:01 +0200 | [diff] [blame] | 4253 | get_driver_type(dut) == DRIVER_OPENWRT) { |
priyadharshini gowthaman | b4de196 | 2018-01-15 12:21:04 -0800 | [diff] [blame] | 4254 | wpa_command(dut->hostapd_ifname, "DPP_BOOTSTRAP_REMOVE *"); |
| 4255 | wpa_command(dut->hostapd_ifname, "DPP_PKEX_REMOVE *"); |
| 4256 | } |
| 4257 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4258 | /* Stop the AP */ |
| 4259 | run_system(dut, "wifi down"); |
| 4260 | |
| 4261 | /* Reset the wireless configuration */ |
Mohammed Shafi Shajakhan | f789f82 | 2016-04-07 18:53:16 +0530 | [diff] [blame] | 4262 | run_system(dut, "rm -rf /etc/config/wireless"); |
| 4263 | switch (get_openwrt_driver_type()) { |
| 4264 | case OPENWRT_DRIVER_ATHEROS: |
| 4265 | run_system(dut, "wifi detect qcawifi > /etc/config/wireless"); |
| 4266 | break; |
| 4267 | default: |
| 4268 | run_system(dut, "wifi detect > /etc/config/wireless"); |
| 4269 | break; |
| 4270 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4271 | |
| 4272 | /* Configure Radio & VAP, commit the config */ |
Priyadharshini Gowthaman | 8018c98 | 2019-10-31 15:14:37 -0700 | [diff] [blame] | 4273 | if (owrt_ap_config_radio(dut) < 0) |
| 4274 | return ERROR_SEND_STATUS; |
Jouni Malinen | 1370122 | 2019-02-19 12:10:53 +0200 | [diff] [blame] | 4275 | if (owrt_ap_config_vap(dut) < 0) |
| 4276 | return ERROR_SEND_STATUS; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4277 | run_system(dut, "uci commit"); |
| 4278 | |
| 4279 | /* Start AP */ |
| 4280 | run_system(dut, "wifi up"); |
Adil Saeed Musthafa | a8d7484 | 2017-04-10 23:13:39 -0700 | [diff] [blame] | 4281 | if (dut->program != PROGRAM_MBO && |
| 4282 | dut->ap_lci == 1 && dut->ap_interworking && |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 4283 | strlen(dut->ap_tag_ssid[0]) > 0) { |
Adil Saeed Musthafa | a8d7484 | 2017-04-10 23:13:39 -0700 | [diff] [blame] | 4284 | /* |
| 4285 | * MBO has a different ANQP element value which is set in |
| 4286 | * owrt_ap_config_vap(). |
| 4287 | */ |
priyadharshini gowthaman | 2500f20 | 2016-10-13 17:13:55 -0700 | [diff] [blame] | 4288 | owrt_ap_config_vap_anqp(dut); |
| 4289 | run_system(dut, "uci commit"); |
| 4290 | run_system(dut, "wifi"); |
| 4291 | } |
| 4292 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4293 | return owrt_ap_post_config_commit(dut, conn, cmd); |
| 4294 | } |
| 4295 | |
| 4296 | |
| 4297 | static void cmd_owrt_ap_hs2_reset(struct sigma_dut *dut) |
| 4298 | { |
| 4299 | unsigned char bssid[6]; |
| 4300 | char buf[100]; |
| 4301 | char *ifname, *radio_name; |
| 4302 | int vap_id = 0; |
| 4303 | |
| 4304 | if (sigma_radio_ifname[0] && |
| 4305 | strcmp(sigma_radio_ifname[0], "wifi2") == 0) { |
| 4306 | ifname = "ath2"; |
| 4307 | radio_name = "wifi2"; |
| 4308 | vap_id = 2; |
| 4309 | } else if (sigma_radio_ifname[0] && |
| 4310 | strcmp(sigma_radio_ifname[0], "wifi1") == 0) { |
| 4311 | ifname = "ath1"; |
| 4312 | radio_name = "wifi1"; |
| 4313 | vap_id = 1; |
| 4314 | } else { |
| 4315 | ifname = "ath0"; |
| 4316 | radio_name = "wifi0"; |
| 4317 | vap_id = 0; |
| 4318 | } |
| 4319 | |
| 4320 | if (!get_hwaddr(ifname, bssid)) { |
| 4321 | snprintf(buf, sizeof(buf), "%s", bssid); |
| 4322 | owrt_ap_set_vap(dut, vap_id, "hessid", buf); |
| 4323 | snprintf(dut->ap_hessid, sizeof(dut->ap_hessid), |
| 4324 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 4325 | bssid[0], bssid[1], bssid[2], bssid[3], |
| 4326 | bssid[4], bssid[5]); |
| 4327 | } else { |
| 4328 | if (!get_hwaddr(radio_name, bssid)) { |
| 4329 | snprintf(buf, sizeof(buf), "%s", dut->ap_hessid); |
| 4330 | owrt_ap_set_vap(dut, vap_id, "hessid", buf); |
| 4331 | snprintf(dut->ap_hessid, sizeof(dut->ap_hessid), |
| 4332 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 4333 | bssid[0], bssid[1], bssid[2], bssid[3], |
| 4334 | bssid[4], bssid[5]); |
| 4335 | } else { |
| 4336 | /* Select & enable/disable radios */ |
| 4337 | if (sigma_radio_ifname[0] && |
| 4338 | strcmp(sigma_radio_ifname[0], "wifi2") == 0) { |
| 4339 | /* We want to use wifi2 */ |
| 4340 | owrt_ap_set_radio(dut, 0, "disabled", "1"); |
| 4341 | owrt_ap_set_radio(dut, 1, "disabled", "1"); |
| 4342 | owrt_ap_set_radio(dut, 2, "disabled", "0"); |
| 4343 | owrt_ap_set_vap(dut, vap_id, "device", "wifi2"); |
| 4344 | } else if (sigma_radio_ifname[0] && |
| 4345 | strcmp(sigma_radio_ifname[0], "wifi1") == 0) { |
| 4346 | /* We want to use wifi1 */ |
| 4347 | owrt_ap_set_radio(dut, 0, "disabled", "1"); |
| 4348 | owrt_ap_set_radio(dut, 1, "disabled", "0"); |
| 4349 | owrt_ap_set_vap(dut, vap_id, "device", "wifi1"); |
| 4350 | } else { |
| 4351 | /* We want to use wifi0 */ |
| 4352 | owrt_ap_set_radio(dut, 0, "disabled", "0"); |
| 4353 | owrt_ap_set_radio(dut, 1, "disabled", "1"); |
| 4354 | owrt_ap_set_vap(dut, vap_id, "device", "wifi0"); |
| 4355 | } |
| 4356 | |
| 4357 | run_system(dut, "uci commit"); |
| 4358 | run_system(dut, "wifi up"); |
| 4359 | |
| 4360 | if (!get_hwaddr(radio_name, bssid)) { |
| 4361 | snprintf(buf, sizeof(buf), "%s", |
| 4362 | dut->ap_hessid); |
| 4363 | owrt_ap_set_vap(dut, vap_id, "hessid", buf); |
| 4364 | snprintf(dut->ap_hessid, sizeof(dut->ap_hessid), |
| 4365 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 4366 | bssid[0], bssid[1], bssid[2], bssid[3], |
| 4367 | bssid[4], bssid[5]); |
| 4368 | } |
| 4369 | } |
| 4370 | } |
| 4371 | } |
| 4372 | |
| 4373 | |
Jouni Malinen | f722271 | 2019-06-13 01:50:21 +0300 | [diff] [blame] | 4374 | static enum sigma_cmd_result cmd_ap_reboot(struct sigma_dut *dut, |
| 4375 | struct sigma_conn *conn, |
| 4376 | struct sigma_cmd *cmd) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4377 | { |
Jouni Malinen | 016ae6c | 2019-11-04 17:00:01 +0200 | [diff] [blame] | 4378 | switch (get_driver_type(dut)) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4379 | case DRIVER_ATHEROS: |
| 4380 | run_system(dut, "apdown"); |
| 4381 | sleep(1); |
| 4382 | run_system(dut, "reboot"); |
| 4383 | break; |
| 4384 | case DRIVER_OPENWRT: |
| 4385 | run_system(dut, "wifi down"); |
| 4386 | sleep(1); |
| 4387 | run_system(dut, "reboot"); |
| 4388 | break; |
| 4389 | default: |
| 4390 | sigma_dut_print(dut, DUT_MSG_INFO, "Ignore ap_reboot command"); |
| 4391 | break; |
| 4392 | } |
| 4393 | |
| 4394 | return 1; |
| 4395 | } |
| 4396 | |
| 4397 | |
| 4398 | int ascii2hexstr(const char *str, char *hex) |
| 4399 | { |
| 4400 | int i, length; |
| 4401 | |
| 4402 | length = strlen(str); |
| 4403 | |
| 4404 | for (i = 0; i < length; i++) |
| 4405 | snprintf(hex + i * 2, 3, "%X", str[i]); |
| 4406 | |
| 4407 | hex[length * 2] = '\0'; |
| 4408 | return 1; |
| 4409 | } |
| 4410 | |
| 4411 | |
| 4412 | static int kill_process(struct sigma_dut *dut, char *proc_name, |
| 4413 | unsigned char is_proc_instance_one, int sig) |
| 4414 | { |
| 4415 | #ifdef __linux__ |
| 4416 | struct dirent *dp, *dp_in; |
| 4417 | const char *direc = "/proc/"; |
| 4418 | char buf[100]; |
| 4419 | DIR *dir = opendir(direc); |
| 4420 | DIR *dir_in; |
| 4421 | FILE *fp; |
| 4422 | char *pid, *temp; |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 4423 | char *saveptr; |
Jouni Malinen | 3aa7286 | 2019-05-29 23:14:51 +0300 | [diff] [blame] | 4424 | int ret = -1, res; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4425 | |
| 4426 | if (dir == NULL) |
Pradeep Reddy Potteti | d068e64 | 2017-02-17 20:03:12 +0530 | [diff] [blame] | 4427 | return ret; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4428 | |
| 4429 | while ((dp = readdir(dir)) != NULL) { |
| 4430 | if (dp->d_type != DT_DIR) |
| 4431 | continue; |
| 4432 | |
Jouni Malinen | 3aa7286 | 2019-05-29 23:14:51 +0300 | [diff] [blame] | 4433 | res = snprintf(buf, sizeof(buf), "%s%s", direc, dp->d_name); |
| 4434 | if (res < 0 || res >= sizeof(buf)) |
| 4435 | continue; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4436 | dir_in = opendir(buf); |
| 4437 | if (dir_in == NULL) |
| 4438 | continue; |
| 4439 | dp_in = readdir(dir_in); |
| 4440 | closedir(dir_in); |
| 4441 | if (dp_in == NULL) |
| 4442 | continue; |
Jouni Malinen | 3aa7286 | 2019-05-29 23:14:51 +0300 | [diff] [blame] | 4443 | res = snprintf(buf, sizeof(buf), "%s%s/stat", |
| 4444 | direc, dp->d_name); |
| 4445 | if (res < 0 || res >= sizeof(buf)) |
| 4446 | continue; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4447 | fp = fopen(buf, "r"); |
| 4448 | if (fp == NULL) |
| 4449 | continue; |
| 4450 | if (fgets(buf, 100, fp) == NULL) |
| 4451 | buf[0] = '\0'; |
| 4452 | fclose(fp); |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 4453 | pid = strtok_r(buf, " ", &saveptr); |
| 4454 | temp = strtok_r(NULL, " ", &saveptr); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4455 | if (pid && temp && |
| 4456 | strncmp(temp, proc_name, strlen(proc_name)) == 0) { |
| 4457 | sigma_dut_print(dut, DUT_MSG_INFO, |
| 4458 | "killing %s process with PID %s", |
| 4459 | proc_name, pid); |
| 4460 | snprintf(buf, sizeof(buf), "kill -%d %d", sig, |
| 4461 | atoi(pid)); |
| 4462 | run_system(dut, buf); |
Pradeep Reddy Potteti | d068e64 | 2017-02-17 20:03:12 +0530 | [diff] [blame] | 4463 | ret = 0; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4464 | if (is_proc_instance_one) |
| 4465 | break; |
| 4466 | } |
| 4467 | } |
| 4468 | |
| 4469 | closedir(dir); |
| 4470 | |
Pradeep Reddy Potteti | d068e64 | 2017-02-17 20:03:12 +0530 | [diff] [blame] | 4471 | return ret; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4472 | #else /* __linux__ */ |
| 4473 | return -1; |
| 4474 | #endif /* __linux__ */ |
| 4475 | } |
| 4476 | |
| 4477 | |
| 4478 | static int run_ndc(struct sigma_dut *dut, char *buf) |
| 4479 | { |
| 4480 | sigma_dut_print(dut, DUT_MSG_INFO, "CMD NDC:: %s", buf); |
| 4481 | sleep(2); |
| 4482 | return run_system(dut, buf); |
| 4483 | } |
| 4484 | |
| 4485 | |
| 4486 | static int sigma_write_cfg(struct sigma_dut *dut, const char *pfile, |
| 4487 | const char *field, const char *value) |
| 4488 | { |
| 4489 | FILE *fcfg, *ftmp; |
| 4490 | char buf[MAX_CONF_LINE_LEN + 1]; |
| 4491 | int len, found = 0, res; |
| 4492 | |
| 4493 | /* Open the configuration file */ |
| 4494 | fcfg = fopen(pfile, "r"); |
| 4495 | if (!fcfg) { |
| 4496 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4497 | "Failed to open hostapd conf file"); |
| 4498 | return -1; |
| 4499 | } |
| 4500 | |
| 4501 | snprintf(buf, sizeof(buf), "%s~", pfile); |
| 4502 | /* Open a temporary file */ |
| 4503 | ftmp = fopen(buf, "w+"); |
| 4504 | if (!ftmp) { |
| 4505 | fclose(fcfg); |
| 4506 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4507 | "Failed to open temp buf"); |
| 4508 | return -1; |
| 4509 | } |
| 4510 | |
| 4511 | /* Read the values from the configuration file */ |
| 4512 | len = strlen(field); |
| 4513 | while (fgets(buf, MAX_CONF_LINE_LEN, fcfg)) { |
| 4514 | char *pline = buf; |
| 4515 | |
| 4516 | /* commented line */ |
| 4517 | if (buf[0] == '#') |
| 4518 | pline++; |
| 4519 | |
| 4520 | /* Identify the configuration parameter to be updated */ |
| 4521 | if (!found && strncmp(pline, field, len) == 0 && |
| 4522 | pline[len] == '=') { |
| 4523 | snprintf(buf, sizeof(buf), "%s=%s\n", field, value); |
| 4524 | found = 1; |
| 4525 | sigma_dut_print(dut, DUT_MSG_INFO, |
| 4526 | "Updated hostapd conf file"); |
| 4527 | } |
| 4528 | |
| 4529 | fprintf(ftmp, "%s", buf); |
| 4530 | } |
| 4531 | |
| 4532 | if (!found) { |
| 4533 | /* Configuration line not found */ |
| 4534 | /* Add the new line at the end of file */ |
| 4535 | fprintf(ftmp, "%s=%s\n", field, value); |
| 4536 | sigma_dut_print(dut, DUT_MSG_INFO, |
| 4537 | "Adding a new line in hostapd conf file"); |
| 4538 | } |
| 4539 | |
| 4540 | fclose(fcfg); |
| 4541 | fclose(ftmp); |
| 4542 | |
| 4543 | snprintf(buf, sizeof(buf), "%s~", pfile); |
| 4544 | |
| 4545 | /* Restore the updated configuration file */ |
| 4546 | res = rename(buf, pfile); |
| 4547 | |
| 4548 | /* Remove the temporary file. Ignore the return value */ |
| 4549 | unlink(buf); |
| 4550 | |
| 4551 | /* chmod is needed because open() may not set permissions properly |
| 4552 | * depending on the current umask */ |
| 4553 | if (chmod(pfile, 0660) < 0) { |
| 4554 | unlink(pfile); |
| 4555 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4556 | "Error changing permissions"); |
| 4557 | return -1; |
| 4558 | } |
| 4559 | |
| 4560 | if (res < 0) { |
| 4561 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4562 | "Error restoring conf file"); |
| 4563 | return -1; |
| 4564 | } |
| 4565 | |
| 4566 | return 0; |
| 4567 | } |
| 4568 | |
| 4569 | |
| 4570 | static int cmd_wcn_ap_config_commit(struct sigma_dut *dut, |
| 4571 | struct sigma_conn *conn, |
| 4572 | struct sigma_cmd *cmd) |
| 4573 | { |
| 4574 | char buf[100]; |
| 4575 | struct stat s; |
| 4576 | int num_tries = 0, ret; |
| 4577 | |
Pradeep Reddy Potteti | d068e64 | 2017-02-17 20:03:12 +0530 | [diff] [blame] | 4578 | if (kill_process(dut, "(netd)", 1, SIGKILL) == 0 || |
| 4579 | system("killall netd") == 0) { |
| 4580 | /* Avoid Error: Error connecting (Connection refused) |
| 4581 | * Wait some time to allow netd to reinitialize. |
| 4582 | */ |
| 4583 | usleep(1500000); |
| 4584 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4585 | |
| 4586 | while (num_tries < 10) { |
| 4587 | ret = run_ndc(dut, "ndc softap stopap"); |
| 4588 | num_tries++; |
| 4589 | if (WIFEXITED(ret)) |
| 4590 | ret = WEXITSTATUS(ret); |
| 4591 | /* On success, NDC exits with 0 */ |
| 4592 | if (ret == 0) |
| 4593 | break; |
| 4594 | sigma_dut_print(dut, DUT_MSG_INFO, |
| 4595 | "Try No. %d: ndc softap stopap failed, exit code %d", |
| 4596 | num_tries, ret); |
| 4597 | } |
| 4598 | |
| 4599 | if (ret != 0) |
| 4600 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4601 | "ndc softap stopap command failed for 10 times - giving up"); |
| 4602 | |
| 4603 | #ifdef ANDROID |
| 4604 | /* Unload/Load driver to cleanup the state of the driver */ |
Ajit Vaishya | 14d1f9a | 2017-09-04 23:24:25 +0530 | [diff] [blame] | 4605 | system("rmmod -f wlan"); |
| 4606 | usleep(500000); |
| 4607 | system("insmod /system/lib/modules/wlan.ko"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4608 | #else /* ANDROID */ |
| 4609 | run_ndc(dut, "ndc softap qccmd set enable_softap=0"); |
| 4610 | run_ndc(dut, "ndc softap qccmd set enable_softap=1"); |
| 4611 | #endif /* ANDROID */ |
| 4612 | |
| 4613 | switch (dut->ap_mode) { |
| 4614 | case AP_11g: |
| 4615 | run_ndc(dut, "ndc softap qccmd set hw_mode=g-only"); |
| 4616 | break; |
| 4617 | case AP_11b: |
| 4618 | run_ndc(dut, "ndc softap qccmd set hw_mode=b-only"); |
| 4619 | break; |
| 4620 | case AP_11ng: |
| 4621 | run_ndc(dut, "ndc softap qccmd set hw_mode=n"); |
| 4622 | break; |
| 4623 | case AP_11a: |
| 4624 | run_ndc(dut, "ndc softap qccmd set hw_mode=a-only"); |
| 4625 | break; |
| 4626 | case AP_11na: |
| 4627 | run_ndc(dut, "ndc softap qccmd set hw_mode=n"); |
| 4628 | break; |
| 4629 | case AP_11ac: |
| 4630 | run_ndc(dut, "ndc softap qccmd set hw_mode=ac"); |
| 4631 | break; |
| 4632 | default: |
| 4633 | break; |
| 4634 | } |
| 4635 | |
| 4636 | snprintf(buf, sizeof(buf), "ndc softap qccmd set channel=%d", |
| 4637 | dut->ap_channel); |
| 4638 | run_ndc(dut, buf); |
| 4639 | |
| 4640 | /* |
| 4641 | * ndc doesn't support double quotes as SSID string, so re-write |
| 4642 | * hostapd configuration file to update SSID. |
| 4643 | */ |
| 4644 | if (dut->ap_ssid[0] != '\0') |
| 4645 | sigma_write_cfg(dut, ANDROID_CONFIG_FILE, "ssid", dut->ap_ssid); |
| 4646 | |
| 4647 | switch (dut->ap_key_mgmt) { |
| 4648 | case AP_OPEN: |
| 4649 | if (dut->ap_cipher == AP_WEP) { |
| 4650 | run_ndc(dut, "ndc softap qccmd set security_mode=1"); |
| 4651 | snprintf(buf, sizeof(buf), |
| 4652 | "ndc softap qccmd set wep_key0=%s", |
| 4653 | dut->ap_wepkey); |
| 4654 | run_ndc(dut, buf); |
| 4655 | } else { |
| 4656 | run_ndc(dut, "ndc softap qccmd set security_mode=0"); |
| 4657 | } |
| 4658 | break; |
| 4659 | case AP_WPA2_PSK: |
| 4660 | case AP_WPA2_PSK_MIXED: |
| 4661 | case AP_WPA_PSK: |
| 4662 | if (dut->ap_key_mgmt == AP_WPA2_PSK) |
| 4663 | run_ndc(dut, "ndc softap qccmd set security_mode=3"); |
| 4664 | else if (dut->ap_key_mgmt == AP_WPA2_PSK_MIXED) |
| 4665 | run_ndc(dut, "ndc softap qccmd set security_mode=4"); |
| 4666 | else |
| 4667 | run_ndc(dut, "ndc softap qccmd set security_mode=2"); |
| 4668 | |
| 4669 | /* |
| 4670 | * ndc doesn't support some special characters as passphrase, |
| 4671 | * so re-write hostapd configuration file to update Passphrase. |
| 4672 | */ |
| 4673 | if (dut->ap_passphrase[0] != '\0') |
| 4674 | sigma_write_cfg(dut, ANDROID_CONFIG_FILE, |
| 4675 | "wpa_passphrase", dut->ap_passphrase); |
| 4676 | |
| 4677 | if (dut->ap_cipher == AP_CCMP_TKIP) |
| 4678 | run_ndc(dut, "ndc softap qccmd set wpa_pairwise=" |
| 4679 | "TKIP CCMP"); |
| 4680 | else if (dut->ap_cipher == AP_TKIP) |
| 4681 | run_ndc(dut, "ndc softap qccmd set wpa_pairwise=" |
| 4682 | "TKIP"); |
| 4683 | else |
| 4684 | run_ndc(dut, "ndc softap qccmd set wpa_pairwise=" |
| 4685 | "CCMP &"); |
| 4686 | break; |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 4687 | case AP_WPA2_SAE: |
| 4688 | case AP_WPA2_PSK_SAE: |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4689 | case AP_WPA2_EAP: |
| 4690 | case AP_WPA2_EAP_MIXED: |
| 4691 | case AP_WPA_EAP: |
Jouni Malinen | ad395a2 | 2017-09-01 21:13:46 +0300 | [diff] [blame] | 4692 | case AP_SUITEB: |
Jouni Malinen | 147b3c3 | 2017-10-09 16:51:54 +0300 | [diff] [blame] | 4693 | case AP_WPA2_OWE: |
Jouni Malinen | 4cf699f | 2018-06-19 00:46:27 +0300 | [diff] [blame] | 4694 | case AP_WPA2_EAP_OSEN: |
Jouni Malinen | c2b9121 | 2018-09-12 02:26:39 +0300 | [diff] [blame] | 4695 | case AP_OSEN: |
Jouni Malinen | 6be21c8 | 2018-08-01 18:47:24 +0300 | [diff] [blame] | 4696 | case AP_WPA2_FT_EAP: |
| 4697 | case AP_WPA2_FT_PSK: |
| 4698 | case AP_WPA2_EAP_SHA256: |
| 4699 | case AP_WPA2_PSK_SHA256: |
| 4700 | case AP_WPA2_ENT_FT_EAP: |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4701 | /* Not supported */ |
| 4702 | break; |
| 4703 | } |
| 4704 | |
| 4705 | switch (dut->ap_pmf) { |
| 4706 | case AP_PMF_DISABLED: |
| 4707 | run_ndc(dut, "ndc softap qccmd set ieee80211w=0"); |
| 4708 | break; |
| 4709 | case AP_PMF_OPTIONAL: |
| 4710 | run_ndc(dut, "ndc softap qccmd set ieee80211w=1"); |
| 4711 | if (dut->ap_add_sha256) |
| 4712 | run_ndc(dut, "ndc softap qccmd set wpa_key_mgmt=WPA-PSK WPA-PSK-SHA256"); |
| 4713 | else |
| 4714 | run_ndc(dut, "ndc softap qccmd set wpa_key_mgmt=WPA-PSK"); |
| 4715 | break; |
| 4716 | case AP_PMF_REQUIRED: |
| 4717 | run_ndc(dut, "ndc softap qccmd set ieee80211w=2"); |
| 4718 | run_ndc(dut, "ndc softap qccmd set wpa_key_mgmt=WPA-PSK-SHA256"); |
| 4719 | break; |
| 4720 | } |
| 4721 | |
| 4722 | if (dut->ap_countrycode[0]) { |
| 4723 | snprintf(buf, sizeof(buf), |
| 4724 | "ndc softap qccmd set country_code=%s", |
| 4725 | dut->ap_countrycode); |
| 4726 | run_ndc(dut, buf); |
| 4727 | } |
| 4728 | |
Pradeep Reddy POTTETI | fba27db | 2015-11-20 16:42:22 +0530 | [diff] [blame] | 4729 | if (dut->ap_regulatory_mode == AP_80211D_MODE_ENABLED) |
| 4730 | run_ndc(dut, "ndc softap qccmd set ieee80211d=1"); |
| 4731 | |
| 4732 | if (dut->ap_dfs_mode == AP_DFS_MODE_ENABLED) |
| 4733 | run_ndc(dut, "ndc softap qccmd set ieee80211h=1"); |
| 4734 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4735 | run_ndc(dut, "ndc softap startap"); |
| 4736 | |
Jouni Malinen | 5ea3092 | 2019-11-04 17:39:25 +0200 | [diff] [blame] | 4737 | snprintf(buf, sizeof(buf), "%s%s", sigma_wpas_ctrl, |
| 4738 | get_main_ifname(dut)); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4739 | num_tries = 0; |
| 4740 | while (num_tries < 10 && (ret = stat(buf, &s) != 0)) { |
| 4741 | run_ndc(dut, "ndc softap stopap"); |
| 4742 | run_ndc(dut, "ndc softap startap"); |
| 4743 | num_tries++; |
| 4744 | } |
| 4745 | |
| 4746 | if (num_tries == 10) { |
| 4747 | sigma_dut_print(dut, DUT_MSG_INFO, "Tried 10 times with ctrl " |
| 4748 | "iface %s :: reboot the APDUT", buf); |
| 4749 | return ret; |
| 4750 | } |
| 4751 | |
| 4752 | sigma_dut_print(dut, DUT_MSG_INFO, "setting ip addr %s mask %s", |
| 4753 | ap_inet_addr, ap_inet_mask); |
| 4754 | snprintf(buf, sizeof(buf), "ifconfig %s %s netmask %s up", |
Jouni Malinen | 5ea3092 | 2019-11-04 17:39:25 +0200 | [diff] [blame] | 4755 | get_main_ifname(dut), ap_inet_addr, ap_inet_mask); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4756 | if (system(buf) != 0) { |
| 4757 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4758 | "Failed to intialize the interface"); |
| 4759 | return -1; |
| 4760 | } |
| 4761 | |
| 4762 | return 1; |
| 4763 | } |
| 4764 | |
| 4765 | |
| 4766 | static int append_hostapd_conf_hs2(struct sigma_dut *dut, FILE *f) |
| 4767 | { |
| 4768 | fprintf(f, "hs20=1\nhs20_deauth_req_timeout=3\n" |
| 4769 | "disable_dgaf=%d\n", dut->ap_dgaf_disable); |
| 4770 | |
| 4771 | if (dut->ap_oper_name) { |
| 4772 | fprintf(f, "hs20_oper_friendly_name=eng:Wi-Fi Alliance\n"); |
| 4773 | fprintf(f, "hs20_oper_friendly_name=chi:Wi-Fi\xe8\x81\x94\xe7\x9b\x9f\n"); |
| 4774 | } |
| 4775 | |
| 4776 | if (dut->ap_wan_metrics == 1) |
| 4777 | fprintf(f, "hs20_wan_metrics=01:2500:384:0:0:10\n"); |
| 4778 | else if (dut->ap_wan_metrics == 2) |
| 4779 | fprintf(f, "hs20_wan_metrics=01:1500:384:20:20:10\n"); |
| 4780 | else if (dut->ap_wan_metrics == 3) |
| 4781 | fprintf(f, "hs20_wan_metrics=01:2000:1000:20:20:10\n"); |
| 4782 | else if (dut->ap_wan_metrics == 4) |
| 4783 | fprintf(f, "hs20_wan_metrics=01:8000:1000:20:20:10\n"); |
| 4784 | else if (dut->ap_wan_metrics == 5) |
| 4785 | fprintf(f, "hs20_wan_metrics=01:9000:5000:20:20:10\n"); |
| 4786 | |
| 4787 | if (dut->ap_conn_capab == 1) { |
| 4788 | fprintf(f, "hs20_conn_capab=1:0:0\n"); |
| 4789 | fprintf(f, "hs20_conn_capab=6:20:1\n"); |
| 4790 | fprintf(f, "hs20_conn_capab=6:22:0\n"); |
| 4791 | fprintf(f, "hs20_conn_capab=6:80:1\n"); |
| 4792 | fprintf(f, "hs20_conn_capab=6:443:1\n"); |
| 4793 | fprintf(f, "hs20_conn_capab=6:1723:0\n"); |
| 4794 | fprintf(f, "hs20_conn_capab=6:5060:0\n"); |
| 4795 | fprintf(f, "hs20_conn_capab=17:500:1\n"); |
| 4796 | fprintf(f, "hs20_conn_capab=17:5060:0\n"); |
| 4797 | fprintf(f, "hs20_conn_capab=17:4500:1\n"); |
| 4798 | fprintf(f, "hs20_conn_capab=50:0:1\n"); |
| 4799 | } else if (dut->ap_conn_capab == 2) { |
| 4800 | fprintf(f, "hs20_conn_capab=6:80:1\n"); |
| 4801 | fprintf(f, "hs20_conn_capab=6:443:1\n"); |
| 4802 | fprintf(f, "hs20_conn_capab=17:5060:1\n"); |
| 4803 | fprintf(f, "hs20_conn_capab=6:5060:1\n"); |
| 4804 | } else if (dut->ap_conn_capab == 3) { |
| 4805 | fprintf(f, "hs20_conn_capab=6:80:1\n"); |
| 4806 | fprintf(f, "hs20_conn_capab=6:443:1\n"); |
| 4807 | } else if (dut->ap_conn_capab == 4) { |
| 4808 | fprintf(f, "hs20_conn_capab=6:80:1\n"); |
| 4809 | fprintf(f, "hs20_conn_capab=6:443:1\n"); |
| 4810 | fprintf(f, "hs20_conn_capab=6:5060:1\n"); |
| 4811 | fprintf(f, "hs20_conn_capab=17:5060:1\n"); |
| 4812 | } |
| 4813 | |
| 4814 | if (dut->ap_oper_class == 1) |
| 4815 | fprintf(f, "hs20_operating_class=51\n"); |
| 4816 | else if (dut->ap_oper_class == 2) |
| 4817 | fprintf(f, "hs20_operating_class=73\n"); |
| 4818 | else if (dut->ap_oper_class == 3) |
| 4819 | fprintf(f, "hs20_operating_class=5173\n"); |
| 4820 | |
| 4821 | if (dut->ap_osu_provider_list) { |
| 4822 | char *osu_friendly_name = NULL; |
| 4823 | char *osu_icon = NULL; |
| 4824 | char *osu_ssid = NULL; |
| 4825 | char *osu_nai = NULL; |
Jouni Malinen | 93a837f | 2018-11-01 17:09:22 +0200 | [diff] [blame] | 4826 | char *osu_nai2 = NULL; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4827 | char *osu_service_desc = NULL; |
| 4828 | char *hs20_icon_filename = NULL; |
| 4829 | char hs20_icon[150]; |
| 4830 | int osu_method; |
| 4831 | |
| 4832 | hs20_icon_filename = "icon_red_zxx.png"; |
| 4833 | if (dut->ap_osu_icon_tag == 2) |
| 4834 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 4835 | snprintf(hs20_icon, sizeof(hs20_icon), |
| 4836 | "128:61:zxx:image/png:icon_red_zxx.png:/etc/ath/%s", |
| 4837 | hs20_icon_filename); |
| 4838 | osu_icon = "icon_red_zxx.png"; |
| 4839 | osu_ssid = "OSU"; |
| 4840 | osu_friendly_name = "kor:SP 빨강 테스트 전용"; |
| 4841 | osu_service_desc = "kor:테스트 목적으로 무료 서비스"; |
| 4842 | osu_method = (dut->ap_osu_method[0] == 0xFF) ? 1 : dut->ap_osu_method[0]; |
| 4843 | |
| 4844 | if (strlen(dut->ap_osu_server_uri[0])) |
| 4845 | fprintf(f, "osu_server_uri=%s\n", dut->ap_osu_server_uri[0]); |
| 4846 | else |
| 4847 | fprintf(f, "osu_server_uri=https://osu-server.r2-testbed.wi-fi.org/\n"); |
| 4848 | |
| 4849 | switch (dut->ap_osu_provider_list) { |
| 4850 | case 1: |
| 4851 | case 101: |
| 4852 | fprintf(f, "osu_friendly_name=eng:SP Red Test Only\n"); |
| 4853 | fprintf(f, "osu_service_desc=eng:Free service for test purpose\n"); |
| 4854 | hs20_icon_filename = "icon_red_eng.png"; |
| 4855 | if (dut->ap_osu_icon_tag == 2) |
| 4856 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 4857 | fprintf(f, "hs20_icon=160:76:eng:image/png:icon_red_eng.png:/etc/ath/%s\n", |
| 4858 | hs20_icon_filename); |
| 4859 | fprintf(f, "osu_icon=icon_red_eng.png\n"); |
| 4860 | break; |
| 4861 | case 2: |
| 4862 | case 102: |
| 4863 | fprintf(f, "osu_friendly_name=eng:Wireless Broadband Alliance\n"); |
| 4864 | fprintf(f, "osu_service_desc=eng:Free service for test purpose\n"); |
| 4865 | hs20_icon_filename = "icon_orange_zxx.png"; |
| 4866 | if (dut->ap_osu_icon_tag == 2) |
| 4867 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 4868 | snprintf(hs20_icon, sizeof(hs20_icon), |
| 4869 | "128:61:zxx:image/png:icon_orange_zxx.png:/etc/ath/%s", |
| 4870 | hs20_icon_filename); |
| 4871 | osu_icon = "icon_orange_zxx.png"; |
| 4872 | osu_friendly_name = "kor:와이어리스 브로드밴드 얼라이언스"; |
| 4873 | break; |
| 4874 | case 3: |
| 4875 | case 103: |
| 4876 | osu_friendly_name = "spa:SP Red Test Only"; |
| 4877 | osu_service_desc = "spa:Free service for test purpose"; |
| 4878 | break; |
| 4879 | case 4: |
| 4880 | case 104: |
| 4881 | fprintf(f, "osu_friendly_name=eng:SP Orange Test Only\n"); |
| 4882 | fprintf(f, "osu_service_desc=eng:Free service for test purpose\n"); |
| 4883 | hs20_icon_filename = "icon_orange_eng.png"; |
| 4884 | if (dut->ap_osu_icon_tag == 2) |
| 4885 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 4886 | fprintf(f, "hs20_icon=160:76:eng:image/png:icon_orange_eng.png:/etc/ath/%s\n", |
| 4887 | hs20_icon_filename); |
| 4888 | fprintf(f, "osu_icon=icon_orange_eng.png\n"); |
| 4889 | osu_friendly_name = "kor:SP 오렌지 테스트 전용"; |
| 4890 | |
| 4891 | hs20_icon_filename = "icon_orange_zxx.png"; |
| 4892 | if (dut->ap_osu_icon_tag == 2) |
| 4893 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 4894 | snprintf(hs20_icon, sizeof(hs20_icon), |
| 4895 | "128:61:zxx:image/png:icon_orange_zxx.png:/etc/ath/%s", |
| 4896 | hs20_icon_filename); |
| 4897 | osu_icon = "icon_orange_zxx.png"; |
| 4898 | break; |
| 4899 | case 5: |
| 4900 | case 105: |
| 4901 | fprintf(f, "osu_friendly_name=eng:SP Orange Test Only\n"); |
| 4902 | fprintf(f, "osu_service_desc=eng:Free service for test purpose\n"); |
| 4903 | osu_friendly_name = "kor:SP 오렌지 테스트 전용"; |
| 4904 | hs20_icon_filename = "icon_orange_zxx.png"; |
| 4905 | if (dut->ap_osu_icon_tag == 2) |
| 4906 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 4907 | snprintf(hs20_icon, sizeof(hs20_icon), |
| 4908 | "128:61:zxx:image/png:icon_orange_zxx.png:/etc/ath/%s", |
| 4909 | hs20_icon_filename); |
| 4910 | osu_icon = "icon_orange_zxx.png"; |
| 4911 | break; |
| 4912 | case 6: |
| 4913 | case 106: |
| 4914 | fprintf(f, "osu_friendly_name=eng:SP Green Test Only\n"); |
| 4915 | fprintf(f, "osu_friendly_name=kor:SP 초록 테스트 전용\n"); |
| 4916 | hs20_icon_filename = "icon_green_zxx.png"; |
| 4917 | if (dut->ap_osu_icon_tag == 2) |
| 4918 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 4919 | fprintf(f, "hs20_icon=128:61:zxx:image/png:icon_green_zxx.png:/etc/ath/%s\n", |
| 4920 | hs20_icon_filename); |
| 4921 | fprintf(f, "osu_icon=icon_green_zxx.png\n"); |
| 4922 | osu_method = (dut->ap_osu_method[0] == 0xFF) ? 0 : dut->ap_osu_method[0]; |
| 4923 | fprintf(f, "osu_method_list=%d\n", osu_method); |
| 4924 | |
| 4925 | if (strlen(dut->ap_osu_server_uri[1])) |
| 4926 | fprintf(f, "osu_server_uri=%s\n", dut->ap_osu_server_uri[1]); |
| 4927 | else |
| 4928 | fprintf(f, "osu_server_uri=https://osu-server.r2-testbed.wi-fi.org/\n"); |
| 4929 | fprintf(f, "osu_friendly_name=eng:SP Orange Test Only\n"); |
| 4930 | hs20_icon_filename = "icon_orange_zxx.png"; |
| 4931 | if (dut->ap_osu_icon_tag == 2) |
| 4932 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 4933 | snprintf(hs20_icon, sizeof(hs20_icon), |
| 4934 | "128:61:zxx:image/png:icon_orange_zxx.png:/etc/ath/%s", |
| 4935 | hs20_icon_filename); |
| 4936 | osu_icon = "icon_orange_zxx.png"; |
| 4937 | osu_friendly_name = "kor:SP 오렌지 테스트 전용"; |
| 4938 | osu_method = (dut->ap_osu_method[1] == 0xFF) ? 0 : dut->ap_osu_method[1]; |
| 4939 | osu_service_desc = NULL; |
| 4940 | break; |
| 4941 | case 7: |
| 4942 | case 107: |
| 4943 | fprintf(f, "osu_friendly_name=eng:SP Green Test Only\n"); |
| 4944 | fprintf(f, "osu_service_desc=eng:Free service for test purpose\n"); |
| 4945 | hs20_icon_filename = "icon_green_eng.png"; |
| 4946 | if (dut->ap_osu_icon_tag == 2) |
| 4947 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 4948 | fprintf(f, "hs20_icon=160:76:eng:image/png:icon_green_eng.png:/etc/ath/%s\n", |
| 4949 | hs20_icon_filename); |
| 4950 | fprintf(f, "osu_icon=icon_green_eng.png\n"); |
| 4951 | osu_friendly_name = "kor:SP 초록 테스트 전용"; |
| 4952 | |
| 4953 | hs20_icon_filename = "icon_green_zxx.png"; |
| 4954 | if (dut->ap_osu_icon_tag == 2) |
| 4955 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 4956 | snprintf(hs20_icon, sizeof(hs20_icon), |
| 4957 | "128:61:zxx:image/png:icon_green_zxx.png:/etc/ath/%s", |
| 4958 | hs20_icon_filename); |
| 4959 | osu_icon = "icon_green_zxx.png"; |
| 4960 | break; |
| 4961 | case 8: |
| 4962 | case 108: |
| 4963 | fprintf(f, "osu_friendly_name=eng:SP Red Test Only\n"); |
| 4964 | fprintf(f, "osu_service_desc=eng:Free service for test purpose\n"); |
| 4965 | osu_ssid = "OSU-Encrypted"; |
| 4966 | osu_nai = "anonymous@hotspot.net"; |
| 4967 | break; |
| 4968 | case 9: |
| 4969 | case 109: |
| 4970 | osu_ssid = "OSU-OSEN"; |
| 4971 | osu_nai = "test-anonymous@wi-fi.org"; |
| 4972 | osu_friendly_name = "eng:SP Orange Test Only"; |
| 4973 | hs20_icon_filename = "icon_orange_zxx.png"; |
| 4974 | if (dut->ap_osu_icon_tag == 2) |
| 4975 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 4976 | snprintf(hs20_icon, sizeof(hs20_icon), |
| 4977 | "128:61:zxx:image/png:icon_orange_zxx.png:/etc/ath/%s", |
| 4978 | hs20_icon_filename); |
| 4979 | osu_icon = "icon_orange_zxx.png"; |
| 4980 | osu_method = (dut->ap_osu_method[0] == 0xFF) ? 1 : dut->ap_osu_method[0]; |
| 4981 | osu_service_desc = NULL; |
| 4982 | break; |
Jouni Malinen | 93a837f | 2018-11-01 17:09:22 +0200 | [diff] [blame] | 4983 | case 10: |
| 4984 | case 110: |
| 4985 | /* OSU Provider #1 */ |
| 4986 | fprintf(f, "osu_friendly_name=eng:SP Orange Test Only\n"); |
| 4987 | fprintf(f, "osu_friendly_name=kor:SP 오렌지 테스트 전용\n"); |
| 4988 | fprintf(f, "hs20_icon=128:61:zxx:image/png:icon_orange_zxx.png:/etc/ath/icon_orange_zxx.png\n"); |
| 4989 | fprintf(f, "osu_icon=icon_orange_zxx.png\n"); |
| 4990 | osu_method = (dut->ap_osu_method[0] == 0xFF) ? |
| 4991 | 1 : dut->ap_osu_method[0]; |
| 4992 | fprintf(f, "osu_method_list=%d\n", osu_method); |
| 4993 | fprintf(f, "osu_nai=test-anonymous@wi-fi.org\n"); |
| 4994 | switch (dut->ap_osu_provider_nai_list) { |
| 4995 | case 3: |
| 4996 | fprintf(f, |
| 4997 | "osu_nai2=test-anonymous@wi-fi.org\n"); |
| 4998 | break; |
| 4999 | case 4: |
| 5000 | fprintf(f, "osu_nai2=random@hotspot.net\n"); |
| 5001 | break; |
| 5002 | } |
| 5003 | |
| 5004 | /* OSU Provider #2 */ |
| 5005 | /* SP Red from defaults */ |
| 5006 | if (strlen(dut->ap_osu_server_uri[1])) |
| 5007 | fprintf(f, "osu_server_uri=%s\n", dut->ap_osu_server_uri[1]); |
| 5008 | else |
| 5009 | fprintf(f, "osu_server_uri=https://osu-server.r2-testbed.wi-fi.org/\n"); |
| 5010 | fprintf(f, "osu_friendly_name=eng:SP Red Test Only\n"); |
| 5011 | snprintf(hs20_icon, sizeof(hs20_icon), |
| 5012 | "128:61:zxx:image/png:icon_red_zxx.png:/etc/ath/icon_red_zxx.png"); |
| 5013 | osu_method = (dut->ap_osu_method[1] == 0xFF) ? |
| 5014 | 1 : dut->ap_osu_method[1]; |
| 5015 | osu_service_desc = NULL; |
| 5016 | osu_nai = "anonymous@hotspot.net"; |
| 5017 | break; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5018 | default: |
| 5019 | break; |
| 5020 | } |
| 5021 | |
Jouni Malinen | 93a837f | 2018-11-01 17:09:22 +0200 | [diff] [blame] | 5022 | switch (dut->ap_osu_provider_nai_list) { |
| 5023 | case 1: |
| 5024 | osu_nai2 = "anonymous@hotspot.net"; |
| 5025 | break; |
| 5026 | case 2: |
| 5027 | osu_nai2 = "test-anonymous@wi-fi.org"; |
| 5028 | break; |
| 5029 | case 3: |
| 5030 | /* OSU Provider NAI #1 written above */ |
| 5031 | /* OSU Provider NAI #2 */ |
| 5032 | osu_nai2 = "anonymous@hotspot.net"; |
| 5033 | break; |
| 5034 | case 4: |
| 5035 | /* OSU Provider NAI #1 written above */ |
| 5036 | /* OSU Provider NAI #2 */ |
| 5037 | osu_nai2 = "anonymous@hotspot.net"; |
| 5038 | break; |
| 5039 | } |
| 5040 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5041 | if (strlen(dut->ap_osu_ssid)) { |
Jouni Malinen | e6ac6a0 | 2018-09-11 02:40:17 +0300 | [diff] [blame] | 5042 | if (dut->ap_tag_ssid[0][0] && |
| 5043 | strcmp(dut->ap_tag_ssid[0], dut->ap_osu_ssid) && |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 5044 | strcmp(dut->ap_tag_ssid[0], osu_ssid)) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5045 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5046 | "OSU_SSID and " |
| 5047 | "WLAN_TAG2 SSID differ"); |
| 5048 | return -2; |
| 5049 | } |
| 5050 | fprintf(f, "osu_ssid=\"%s\"\n", dut->ap_osu_ssid); |
| 5051 | } else |
| 5052 | fprintf(f, "osu_ssid=\"%s\"\n", osu_ssid); |
| 5053 | |
| 5054 | |
| 5055 | if (osu_friendly_name) |
| 5056 | fprintf(f, "osu_friendly_name=%s\n", osu_friendly_name); |
| 5057 | |
| 5058 | if (osu_service_desc) |
| 5059 | fprintf(f, "osu_service_desc=%s\n", osu_service_desc); |
| 5060 | |
| 5061 | if (osu_nai) |
| 5062 | fprintf(f, "osu_nai=%s\n", osu_nai); |
Jouni Malinen | 93a837f | 2018-11-01 17:09:22 +0200 | [diff] [blame] | 5063 | if (osu_nai2) |
| 5064 | fprintf(f, "osu_nai2=%s\n", osu_nai2); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5065 | |
| 5066 | fprintf(f, "hs20_icon=%s\n", hs20_icon); |
| 5067 | |
| 5068 | if (osu_icon) |
| 5069 | fprintf(f, "osu_icon=%s\n", osu_icon); |
| 5070 | |
| 5071 | if (dut->ap_osu_provider_list > 100) |
| 5072 | fprintf(f, "osu_method_list=0\n"); |
| 5073 | else |
| 5074 | fprintf(f, "osu_method_list=%d\n", osu_method); |
| 5075 | } |
| 5076 | |
Jouni Malinen | 54a89b0 | 2018-05-01 00:16:26 +0300 | [diff] [blame] | 5077 | switch (dut->ap_venue_url) { |
| 5078 | case 1: |
| 5079 | fprintf(f, |
| 5080 | "venue_url=1:https://venue-server.r2m-testbed.wi-fi.org/floorplans/index.html\n" |
| 5081 | "venue_url=1:https://venue-server.r2m-testbed.wi-fi.org/directory/index.html\n"); |
| 5082 | break; |
| 5083 | case 2: |
| 5084 | fprintf(f, |
| 5085 | "venue_url=1:https://the-great-mall.r2m-testbed.wi-fi.org/floorplans/index.html\n" |
| 5086 | "venue_url=2:https://abercrombie.r2m-testbed.wi-fi.org/floorplans/index.html\n" |
| 5087 | "venue_url=3:https://adidas.r2m-testbed.wi-fi.org/floorplans/index.html\n" |
| 5088 | "venue_url=4:https://aeropostale.r2m-testbed.wi-fi.org/floorplans/index.html\n" |
| 5089 | "venue_url=5:https://agaci.r2m-testbed.wi-fi.org/floorplans/index.html\n" |
| 5090 | "venue_url=6:https://aldo-shoes.r2m-testbed.wi-fi.org/floorplans/index.html\n" |
| 5091 | "venue_url=7:https://american-eagle-outfitters.r2m-testbed.wi-fi.org/floorplans/index.html\n" |
| 5092 | "venue_url=8:https://anderson-bakery.r2m-testbed.wi-fi.org/floorplans/index.html\n" |
| 5093 | "venue_url=9:https://banana-republic-factory-store.r2m-testbed.wi-fi.org/floorplans/index.html\n" |
| 5094 | "venue_url=10:https://bed-bath-and-beyond.r2m-testbed.wi-fi.org/floorplans/index.html\n" |
| 5095 | ); |
| 5096 | break; |
| 5097 | } |
| 5098 | |
Jouni Malinen | f7ff42b | 2018-05-01 00:21:56 +0300 | [diff] [blame] | 5099 | switch (dut->ap_advice_of_charge) { |
| 5100 | case 1: |
| 5101 | fprintf(f, "anqp_elem=278:" ADV_OF_CHARGE_1 "\n"); |
| 5102 | break; |
| 5103 | } |
| 5104 | |
Jouni Malinen | ac10453 | 2018-05-01 00:27:37 +0300 | [diff] [blame] | 5105 | switch (dut->ap_oper_icon_metadata) { |
| 5106 | case 1: |
| 5107 | fprintf(f, |
| 5108 | "hs20_icon=160:76:eng:image/png:icon_red_eng.png:/etc/ath/icon_red_eng.png\n" |
| 5109 | "operator_icon=icon_red_eng.png\n"); |
| 5110 | break; |
| 5111 | } |
| 5112 | |
Jouni Malinen | ac36714 | 2018-05-01 00:32:24 +0300 | [diff] [blame] | 5113 | switch (dut->ap_tnc_file_name) { |
| 5114 | case 1: |
| 5115 | fprintf(f, "hs20_t_c_filename=tandc-id1-content.txt\n"); |
| 5116 | break; |
| 5117 | } |
| 5118 | |
| 5119 | if (dut->ap_tnc_time_stamp) |
| 5120 | fprintf(f, "hs20_t_c_timestamp=%u\n", dut->ap_tnc_time_stamp); |
| 5121 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5122 | return 0; |
| 5123 | } |
| 5124 | |
| 5125 | |
| 5126 | static void write_ap_roaming_cons(FILE *f, const char *list) |
| 5127 | { |
| 5128 | char *buf, *pos, *end; |
| 5129 | |
| 5130 | if (list == NULL || list[0] == '\0') |
| 5131 | return; |
| 5132 | |
| 5133 | buf = strdup(list); |
| 5134 | if (buf == NULL) |
| 5135 | return; |
| 5136 | |
| 5137 | pos = buf; |
| 5138 | while (pos && *pos) { |
| 5139 | end = strchr(pos, ';'); |
| 5140 | if (end) |
| 5141 | *end++ = '\0'; |
| 5142 | fprintf(f, "roaming_consortium=%s\n", pos); |
| 5143 | pos = end; |
| 5144 | } |
| 5145 | |
| 5146 | free(buf); |
| 5147 | } |
| 5148 | |
| 5149 | |
| 5150 | static int append_hostapd_conf_interworking(struct sigma_dut *dut, FILE *f) |
| 5151 | { |
| 5152 | int i; |
| 5153 | char buf[100], *temp; |
| 5154 | |
| 5155 | if (dut->ap_gas_cb_delay > 0) |
| 5156 | fprintf(f, "gas_comeback_delay=%d\n", |
| 5157 | dut->ap_gas_cb_delay); |
| 5158 | |
| 5159 | fprintf(f, "interworking=1\n" |
| 5160 | "access_network_type=%d\n" |
| 5161 | "internet=%d\n" |
| 5162 | "asra=0\n" |
| 5163 | "esr=0\n" |
| 5164 | "uesa=0\n" |
| 5165 | "venue_group=%d\n" |
| 5166 | "venue_type=%d\n", |
| 5167 | dut->ap_access_net_type, |
| 5168 | dut->ap_internet, |
| 5169 | dut->ap_venue_group, |
| 5170 | dut->ap_venue_type); |
| 5171 | if (dut->ap_hessid[0]) |
| 5172 | fprintf(f, "hessid=%s\n", dut->ap_hessid); |
| 5173 | |
| 5174 | write_ap_roaming_cons(f, dut->ap_roaming_cons); |
| 5175 | |
| 5176 | if (dut->ap_venue_name) { |
| 5177 | fprintf(f, "venue_name=P\"eng:Wi-Fi Alliance\\n2989 Copper Road\\nSanta Clara, CA 95051, USA\"\n"); |
| 5178 | fprintf(f, "venue_name=%s\n", ANQP_VENUE_NAME_1_CHI); |
| 5179 | } |
| 5180 | |
| 5181 | if (dut->ap_net_auth_type == 1) |
| 5182 | fprintf(f, "network_auth_type=00https://tandc-server.wi-fi.org\n"); |
| 5183 | else if (dut->ap_net_auth_type == 2) |
| 5184 | fprintf(f, "network_auth_type=01\n"); |
| 5185 | |
| 5186 | if (dut->ap_nai_realm_list == 1) { |
| 5187 | fprintf(f, "nai_realm=0,mail.example.com;cisco.com;wi-fi.org,21[2:4][5:7]\n"); |
| 5188 | fprintf(f, "nai_realm=0,wi-fi.org;example.com,13[5:6]\n"); |
| 5189 | } else if (dut->ap_nai_realm_list == 2) { |
| 5190 | fprintf(f, "nai_realm=0,wi-fi.org,21[2:4][5:7]\n"); |
| 5191 | } else if (dut->ap_nai_realm_list == 3) { |
| 5192 | fprintf(f, "nai_realm=0,cisco.com;wi-fi.org,21[2:4][5:7]\n"); |
| 5193 | fprintf(f, "nai_realm=0,wi-fi.org;example.com,13[5:6]\n"); |
| 5194 | } else if (dut->ap_nai_realm_list == 4) { |
| 5195 | fprintf(f, "nai_realm=0,mail.example.com,21[2:4][5:7],13[5:6]\n"); |
| 5196 | } else if (dut->ap_nai_realm_list == 5) { |
| 5197 | fprintf(f, "nai_realm=0,wi-fi.org;ruckuswireless.com,21[2:4][5:7]\n"); |
| 5198 | } else if (dut->ap_nai_realm_list == 6) { |
| 5199 | fprintf(f, "nai_realm=0,wi-fi.org;mail.example.com,21[2:4][5:7]\n"); |
| 5200 | } else if (dut->ap_nai_realm_list == 7) { |
| 5201 | fprintf(f, "nai_realm=0,wi-fi.org,13[5:6]\n"); |
| 5202 | fprintf(f, "nai_realm=0,wi-fi.org,21[2:4][5:7]\n"); |
| 5203 | } |
| 5204 | |
| 5205 | if (dut->ap_domain_name_list[0]) { |
| 5206 | fprintf(f, "domain_name=%s\n", |
| 5207 | dut->ap_domain_name_list); |
| 5208 | } |
| 5209 | |
| 5210 | if (dut->ap_ip_addr_type_avail == 1) { |
| 5211 | fprintf(f, "ipaddr_type_availability=0c\n"); |
| 5212 | } |
| 5213 | |
| 5214 | temp = buf; |
| 5215 | for (i = 0; dut->ap_plmn_mcc[i][0] && dut->ap_plmn_mnc[i][0]; |
| 5216 | i++) { |
| 5217 | if (i) |
| 5218 | *temp++ = ';'; |
| 5219 | |
| 5220 | snprintf(temp, |
| 5221 | sizeof(dut->ap_plmn_mcc[i]) + |
| 5222 | sizeof(dut->ap_plmn_mnc[i]) + 1, |
| 5223 | "%s,%s", |
| 5224 | dut->ap_plmn_mcc[i], |
| 5225 | dut->ap_plmn_mnc[i]); |
| 5226 | |
| 5227 | temp += strlen(dut->ap_plmn_mcc[i]) + |
| 5228 | strlen(dut->ap_plmn_mnc[i]) + 1; |
| 5229 | } |
| 5230 | if (i) |
| 5231 | fprintf(f, "anqp_3gpp_cell_net=%s\n", buf); |
| 5232 | |
| 5233 | if (dut->ap_qos_map_set == 1) |
| 5234 | fprintf(f, "qos_map_set=%s\n", QOS_MAP_SET_1); |
| 5235 | else if (dut->ap_qos_map_set == 2) |
| 5236 | fprintf(f, "qos_map_set=%s\n", QOS_MAP_SET_2); |
| 5237 | |
| 5238 | return 0; |
| 5239 | } |
| 5240 | |
| 5241 | |
| 5242 | static int ath_ap_append_hostapd_conf(struct sigma_dut *dut) |
| 5243 | { |
| 5244 | FILE *f; |
| 5245 | |
| 5246 | if (kill_process(dut, "(hostapd)", 1, SIGTERM) == 0 || |
| 5247 | system("killall hostapd") == 0) { |
| 5248 | int i; |
| 5249 | |
| 5250 | /* Wait some time to allow hostapd to complete cleanup before |
| 5251 | * starting a new process */ |
| 5252 | for (i = 0; i < 10; i++) { |
| 5253 | usleep(500000); |
| 5254 | if (system("pidof hostapd") != 0) |
| 5255 | break; |
| 5256 | } |
| 5257 | } |
| 5258 | |
| 5259 | f = fopen("/tmp/secath0", "a"); |
| 5260 | if (f == NULL) |
| 5261 | return -2; |
| 5262 | |
| 5263 | if (dut->ap_hs2 && append_hostapd_conf_hs2(dut, f)) { |
| 5264 | fclose(f); |
| 5265 | return -2; |
| 5266 | } |
| 5267 | |
| 5268 | if (dut->ap_interworking && append_hostapd_conf_interworking(dut, f)) { |
| 5269 | fclose(f); |
| 5270 | return -2; |
| 5271 | } |
| 5272 | |
| 5273 | fflush(f); |
| 5274 | fclose(f); |
| 5275 | return ath_ap_start_hostapd(dut); |
| 5276 | } |
| 5277 | |
| 5278 | |
| 5279 | static int ath_ap_start_hostapd(struct sigma_dut *dut) |
| 5280 | { |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 5281 | if (dut->ap_tag_key_mgmt[0] == AP2_OSEN) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5282 | run_system(dut, "hostapd -B /tmp/secath0 /tmp/secath1 -e /etc/wpa2/entropy"); |
| 5283 | else |
| 5284 | run_system(dut, "hostapd -B /tmp/secath0 -e /etc/wpa2/entropy"); |
| 5285 | |
| 5286 | return 0; |
| 5287 | } |
| 5288 | |
| 5289 | |
| 5290 | #define LE16(a) ((((a) & 0xff) << 8) | (((a) >> 8) & 0xff)) |
| 5291 | |
| 5292 | static int cmd_ath_ap_anqpserver_start(struct sigma_dut *dut) |
| 5293 | { |
| 5294 | FILE *f; |
| 5295 | int nai_realm = 0, domain_name = 0, oper_name = 0, venue_name = 0, |
| 5296 | wan_metrics = 0, conn_cap = 0, ipaddr_avail = 0, cell_net = 0; |
| 5297 | char buf[100]; |
| 5298 | int i; |
| 5299 | |
| 5300 | f = fopen("/root/anqpserver.conf", "w"); |
| 5301 | if (f == NULL) |
| 5302 | return -1; |
| 5303 | |
| 5304 | if (dut->ap_nai_realm_list == 1) { |
| 5305 | nai_realm = 1; |
| 5306 | 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"); |
| 5307 | } else if (dut->ap_nai_realm_list == 2) { |
| 5308 | nai_realm = 1; |
| 5309 | fprintf(f, "dyn_nai_home_realm=encoding=00realm=wi-fi.org;eap_method=0Dauth_id=05auth_val=06\n"); |
| 5310 | } else if (dut->ap_nai_realm_list == 3) { |
| 5311 | nai_realm = 1; |
| 5312 | 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"); |
| 5313 | } else if (dut->ap_nai_realm_list == 4) { |
| 5314 | nai_realm = 1; |
| 5315 | 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"); |
| 5316 | } else |
| 5317 | sigma_dut_print(dut, DUT_MSG_INFO, "not setting nai_realm"); |
| 5318 | |
| 5319 | if (dut->ap_domain_name_list[0]) { |
| 5320 | char *next, *start, *dnbuf, *dn1, *anqp_dn; |
| 5321 | int len, dn_len_max; |
| 5322 | dnbuf = strdup(dut->ap_domain_name_list); |
Pradeep Reddy POTTETI | 673d85c | 2016-07-26 19:08:07 +0530 | [diff] [blame] | 5323 | if (dnbuf == NULL) { |
| 5324 | fclose(f); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5325 | return 0; |
Pradeep Reddy POTTETI | 673d85c | 2016-07-26 19:08:07 +0530 | [diff] [blame] | 5326 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5327 | |
| 5328 | len = strlen(dnbuf); |
| 5329 | dn_len_max = 50 + len*2; |
| 5330 | anqp_dn = malloc(dn_len_max); |
| 5331 | if (anqp_dn == NULL) { |
| 5332 | free(dnbuf); |
Pradeep Reddy POTTETI | 673d85c | 2016-07-26 19:08:07 +0530 | [diff] [blame] | 5333 | fclose(f); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5334 | return -1; |
| 5335 | } |
| 5336 | start = dnbuf; |
| 5337 | dn1 = anqp_dn; |
| 5338 | while (start && *start) { |
| 5339 | char *hexstr; |
| 5340 | |
| 5341 | next = strchr(start, ','); |
| 5342 | if (next) |
| 5343 | *next++ = '\0'; |
| 5344 | |
| 5345 | len = strlen(start); |
vamsi krishna | 2e88130 | 2016-05-25 15:02:39 +0530 | [diff] [blame] | 5346 | hexstr = malloc(len * 2 + 1); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5347 | if (hexstr == NULL) { |
| 5348 | free(dnbuf); |
| 5349 | free(anqp_dn); |
Pradeep Reddy POTTETI | 673d85c | 2016-07-26 19:08:07 +0530 | [diff] [blame] | 5350 | fclose(f); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5351 | return -1; |
| 5352 | } |
| 5353 | ascii2hexstr(start, hexstr); |
| 5354 | snprintf(dn1, dn_len_max, "%02x%s", len, hexstr); |
| 5355 | free(hexstr); |
| 5356 | dn1 += 2 + len * 2; |
| 5357 | dn_len_max -= 2 + len * 2; |
| 5358 | start = next; |
| 5359 | } |
| 5360 | free(dnbuf); |
| 5361 | if (dut->ap_gas_cb_delay) { |
| 5362 | fprintf(f, "dyn_domain_name=0c01%04x%s", |
| 5363 | LE16((unsigned int) strlen(anqp_dn)), anqp_dn); |
| 5364 | domain_name = 1; |
| 5365 | } else |
| 5366 | fprintf(f, "domain_name=0c01%04x%s", |
| 5367 | LE16((unsigned int) strlen(anqp_dn)), anqp_dn); |
| 5368 | free(anqp_dn); |
| 5369 | } else |
| 5370 | sigma_dut_print(dut, DUT_MSG_INFO, "not setting domain_name"); |
| 5371 | |
| 5372 | sigma_dut_print(dut, DUT_MSG_INFO, "not setting roaming_consortium"); |
| 5373 | |
| 5374 | if (dut->ap_oper_name) { |
| 5375 | if (dut->ap_gas_cb_delay) { |
| 5376 | fprintf(f, "dyn_oper_friendly_name=" |
| 5377 | ANQP_HS20_OPERATOR_FRIENDLY_NAME_1 "\n"); |
| 5378 | oper_name = 1; |
| 5379 | } else |
| 5380 | fprintf(f, "oper_friendly_name=" |
| 5381 | ANQP_HS20_OPERATOR_FRIENDLY_NAME_1 "\n"); |
| 5382 | } else |
| 5383 | sigma_dut_print(dut, DUT_MSG_INFO, "not setting oper_name"); |
| 5384 | |
| 5385 | if (dut->ap_venue_name) { |
| 5386 | if (dut->ap_gas_cb_delay) { |
| 5387 | fprintf(f, "dyn_venue_name=" ANQP_VENUE_NAME_1 "\n"); |
| 5388 | venue_name = 1; |
| 5389 | } else |
| 5390 | fprintf(f, "venue_name=" ANQP_VENUE_NAME_1 "\n"); |
| 5391 | } else |
| 5392 | sigma_dut_print(dut, DUT_MSG_ERROR, "not setting venue_name"); |
| 5393 | |
| 5394 | if (dut->ap_wan_metrics) { |
| 5395 | if (dut->ap_gas_cb_delay) { |
| 5396 | fprintf(f, "dyn_wan_metrics=" ANQP_HS20_WAN_METRICS_1 "\n"); |
| 5397 | wan_metrics = 1; |
| 5398 | } else |
| 5399 | fprintf(f, "wan_metrics=" ANQP_HS20_WAN_METRICS_1 |
| 5400 | "\n"); |
| 5401 | } else |
| 5402 | sigma_dut_print(dut, DUT_MSG_ERROR, "not setting wan_metrics"); |
| 5403 | |
| 5404 | if (dut->ap_conn_capab) { |
| 5405 | if (dut->ap_gas_cb_delay) { |
| 5406 | fprintf(f, "dyn_conn_capability=" |
| 5407 | ANQP_HS20_CONNECTION_CAPABILITY_1 "\n"); |
| 5408 | conn_cap = 1; |
| 5409 | } else |
| 5410 | fprintf(f, "conn_capability=" |
| 5411 | ANQP_HS20_CONNECTION_CAPABILITY_1 "\n"); |
| 5412 | } else |
| 5413 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5414 | "not setting conn_capability"); |
| 5415 | |
| 5416 | if (dut->ap_ip_addr_type_avail) { |
| 5417 | if (dut->ap_gas_cb_delay) { |
| 5418 | fprintf(f, "dyn_ipaddr_type=" ANQP_IP_ADDR_TYPE_1 |
| 5419 | "\n"); |
| 5420 | ipaddr_avail = 1; |
| 5421 | } else |
| 5422 | fprintf(f, "ipaddr_type=" ANQP_IP_ADDR_TYPE_1 "\n"); |
| 5423 | } else |
| 5424 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5425 | "not setting ipaddr_type_avail"); |
| 5426 | |
| 5427 | for (i = 0; dut->ap_plmn_mcc[i][0] && dut->ap_plmn_mnc[i][0]; i++) { |
| 5428 | snprintf(buf + i * 6, sizeof(buf) - i * 6, "%c%c%c%c%c%c", |
| 5429 | dut->ap_plmn_mcc[i][1], |
| 5430 | dut->ap_plmn_mcc[i][0], |
| 5431 | dut->ap_plmn_mnc[i][2] == '\0' ? |
| 5432 | 'f' : dut->ap_plmn_mnc[i][2], |
| 5433 | dut->ap_plmn_mcc[i][2], |
| 5434 | dut->ap_plmn_mnc[i][1], |
| 5435 | dut->ap_plmn_mnc[i][0]); |
| 5436 | } |
| 5437 | if (i) { |
| 5438 | uint16_t ie_len = (i * 3) + 5; |
| 5439 | if (dut->ap_gas_cb_delay) { |
| 5440 | fprintf(f, "dyn_cell_net=0801"); |
| 5441 | cell_net = 1; |
| 5442 | } else |
| 5443 | fprintf(f, "cell_net=0801"); |
| 5444 | fprintf(f, "%04x", LE16(ie_len)); |
| 5445 | fprintf(f, "00"); /* version */ |
| 5446 | fprintf(f, "%02x", (i * 3) + 3); /* user data hdr length */ |
| 5447 | fprintf(f, "00"); /* plmn list */ |
| 5448 | fprintf(f, "%02x", (i * 3) + 1); /* length of plmn list */ |
| 5449 | fprintf(f, "%02x", i); /* number of plmns */ |
| 5450 | fprintf(f, "%s\n", buf); /* plmns */ |
| 5451 | } else |
| 5452 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5453 | "not setting 3gpp_cellular_network"); |
| 5454 | |
| 5455 | if (nai_realm || domain_name || oper_name || venue_name || |
| 5456 | wan_metrics || conn_cap || ipaddr_avail || cell_net) { |
| 5457 | fprintf(f, "anqp_attach="); |
| 5458 | if (venue_name) |
| 5459 | fprintf(f, "00000104%4.4x", dut->ap_gas_cb_delay); |
| 5460 | if (nai_realm) |
| 5461 | fprintf(f, "00000107%4.4x", dut->ap_gas_cb_delay); |
| 5462 | if (cell_net) |
| 5463 | fprintf(f, "00000108%4.4x", dut->ap_gas_cb_delay); |
| 5464 | if (domain_name) |
| 5465 | fprintf(f, "0000010c%4.4x", dut->ap_gas_cb_delay); |
| 5466 | if (oper_name) |
| 5467 | fprintf(f, "00010003%4.4x", dut->ap_gas_cb_delay); |
| 5468 | if (wan_metrics) |
| 5469 | fprintf(f, "00010004%4.4x", dut->ap_gas_cb_delay); |
| 5470 | if (conn_cap) |
| 5471 | fprintf(f, "00010005%4.4x", dut->ap_gas_cb_delay); |
| 5472 | fprintf(f, "00010006%4.4x", dut->ap_gas_cb_delay); |
| 5473 | fprintf(f, "\n"); |
| 5474 | } |
| 5475 | |
| 5476 | fclose(f); |
| 5477 | |
| 5478 | run_system(dut, "anqpserver -i ath0 &"); |
| 5479 | if (!dut->ap_anqpserver_on) |
| 5480 | run_system(dut, "killall anqpserver"); |
| 5481 | |
| 5482 | return 1; |
| 5483 | } |
| 5484 | |
| 5485 | |
| 5486 | static void cmd_ath_ap_radio_config(struct sigma_dut *dut) |
| 5487 | { |
| 5488 | char buf[100]; |
| 5489 | |
| 5490 | run_system(dut, "cfg -a AP_STARTMODE=standard"); |
| 5491 | |
| 5492 | if (sigma_radio_ifname[0] && |
| 5493 | strcmp(sigma_radio_ifname[0], "wifi1") == 0) { |
| 5494 | run_system(dut, "cfg -a AP_RADIO_ID=1"); |
| 5495 | switch (dut->ap_mode) { |
| 5496 | case AP_11g: |
| 5497 | run_system(dut, "cfg -a AP_CHMODE_2=11G"); |
| 5498 | break; |
| 5499 | case AP_11b: |
| 5500 | run_system(dut, "cfg -a AP_CHMODE_2=11B"); |
| 5501 | break; |
| 5502 | case AP_11ng: |
| 5503 | run_system(dut, "cfg -a AP_CHMODE_2=11NGHT20"); |
| 5504 | break; |
| 5505 | case AP_11a: |
| 5506 | run_system(dut, "cfg -a AP_CHMODE_2=11A"); |
| 5507 | break; |
| 5508 | case AP_11na: |
| 5509 | run_system(dut, "cfg -a AP_CHMODE_2=11NAHT20"); |
| 5510 | break; |
| 5511 | case AP_11ac: |
| 5512 | run_system(dut, "cfg -a AP_CHMODE_2=11ACVHT80"); |
| 5513 | break; |
| 5514 | default: |
| 5515 | run_system(dut, "cfg -a AP_CHMODE_2=11ACVHT80"); |
| 5516 | break; |
| 5517 | } |
| 5518 | |
| 5519 | switch (dut->ap_rx_streams) { |
| 5520 | case 1: |
| 5521 | run_system(dut, "cfg -a RX_CHAINMASK_2=1"); |
| 5522 | break; |
| 5523 | case 2: |
| 5524 | run_system(dut, "cfg -a RX_CHAINMASK_2=3"); |
| 5525 | break; |
| 5526 | case 3: |
| 5527 | run_system(dut, "cfg -a RX_CHAINMASK_2=7"); |
| 5528 | break; |
| 5529 | } |
| 5530 | |
| 5531 | switch (dut->ap_tx_streams) { |
| 5532 | case 1: |
| 5533 | run_system(dut, "cfg -a TX_CHAINMASK_2=1"); |
| 5534 | break; |
| 5535 | case 2: |
| 5536 | run_system(dut, "cfg -a TX_CHAINMASK_2=3"); |
| 5537 | break; |
| 5538 | case 3: |
| 5539 | run_system(dut, "cfg -a TX_CHAINMASK_2=7"); |
| 5540 | break; |
| 5541 | } |
| 5542 | |
| 5543 | switch (dut->ap_chwidth) { |
| 5544 | case AP_20: |
| 5545 | run_system(dut, "cfg -a AP_CHMODE_2=11ACVHT20"); |
| 5546 | break; |
| 5547 | case AP_40: |
| 5548 | run_system(dut, "cfg -a AP_CHMODE_2=11ACVHT40"); |
| 5549 | break; |
| 5550 | case AP_80: |
| 5551 | run_system(dut, "cfg -a AP_CHMODE_2=11ACVHT80"); |
| 5552 | break; |
| 5553 | case AP_160: |
| 5554 | case AP_AUTO: |
| 5555 | default: |
| 5556 | run_system(dut, "cfg -a AP_CHMODE_2=11ACVHT80"); |
| 5557 | break; |
| 5558 | } |
| 5559 | |
| 5560 | if (dut->ap_tx_stbc) { |
| 5561 | run_system(dut, "cfg -a TX_STBC_2=1"); |
| 5562 | } |
| 5563 | |
| 5564 | snprintf(buf, sizeof(buf), "cfg -a AP_PRIMARY_CH_2=%d", |
| 5565 | dut->ap_channel); |
| 5566 | |
| 5567 | if (dut->ap_is_dual) { |
| 5568 | switch (dut->ap_mode_1) { |
| 5569 | case AP_11g: |
| 5570 | run_system(dut, "cfg -a AP_CHMODE=11G"); |
| 5571 | break; |
| 5572 | case AP_11b: |
| 5573 | run_system(dut, "cfg -a AP_CHMODE=11B"); |
| 5574 | break; |
| 5575 | case AP_11ng: |
| 5576 | run_system(dut, "cfg -a AP_CHMODE=11NGHT20"); |
| 5577 | break; |
| 5578 | case AP_11a: |
| 5579 | run_system(dut, "cfg -a AP_CHMODE=11A"); |
| 5580 | break; |
| 5581 | case AP_11na: |
| 5582 | run_system(dut, "cfg -a AP_CHMODE=11NAHT20"); |
| 5583 | break; |
| 5584 | case AP_11ac: |
| 5585 | run_system(dut, "cfg -a AP_CHMODE=11ACVHT80"); |
| 5586 | break; |
| 5587 | default: |
| 5588 | run_system(dut, "cfg -a AP_CHMODE=11NGHT20"); |
| 5589 | break; |
| 5590 | } |
| 5591 | snprintf(buf, sizeof(buf), "cfg -a AP_PRIMARY_CH=%d", |
| 5592 | dut->ap_channel_1); |
| 5593 | } |
| 5594 | run_system(dut, buf); |
| 5595 | } else { |
| 5596 | run_system(dut, "cfg -a AP_RADIO_ID=0"); |
| 5597 | switch (dut->ap_mode) { |
| 5598 | case AP_11g: |
| 5599 | run_system(dut, "cfg -a AP_CHMODE=11G"); |
| 5600 | break; |
| 5601 | case AP_11b: |
| 5602 | run_system(dut, "cfg -a AP_CHMODE=11B"); |
| 5603 | break; |
| 5604 | case AP_11ng: |
| 5605 | run_system(dut, "cfg -a AP_CHMODE=11NGHT20"); |
| 5606 | break; |
| 5607 | case AP_11a: |
| 5608 | run_system(dut, "cfg -a AP_CHMODE=11A"); |
| 5609 | break; |
| 5610 | case AP_11na: |
| 5611 | run_system(dut, "cfg -a AP_CHMODE=11NAHT20"); |
| 5612 | break; |
| 5613 | case AP_11ac: |
| 5614 | run_system(dut, "cfg -a AP_CHMODE=11ACVHT80"); |
| 5615 | break; |
| 5616 | default: |
| 5617 | run_system(dut, "cfg -a AP_CHMODE=11NGHT20"); |
| 5618 | break; |
| 5619 | } |
| 5620 | snprintf(buf, sizeof(buf), "cfg -a AP_PRIMARY_CH=%d", |
| 5621 | dut->ap_channel); |
| 5622 | run_system(dut, buf); |
| 5623 | } |
| 5624 | |
| 5625 | if (dut->ap_sgi80 == 1) { |
| 5626 | run_system(dut, "cfg -a SHORTGI=1"); |
| 5627 | run_system(dut, "cfg -a SHORTGI_2=1"); |
| 5628 | } else if (dut->ap_sgi80 == 0) { |
| 5629 | run_system(dut, "cfg -a SHORTGI=0"); |
| 5630 | run_system(dut, "cfg -a SHORTGI_2=0"); |
| 5631 | } |
| 5632 | |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 5633 | if (dut->ap_ldpc == VALUE_ENABLED) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5634 | run_system(dut, "cfg -a LDPC=1"); |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 5635 | else if (dut->ap_ldpc == VALUE_DISABLED) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5636 | run_system(dut, "cfg -a LDPC=0"); |
| 5637 | } |
| 5638 | |
| 5639 | |
| 5640 | void ath_disable_txbf(struct sigma_dut *dut, const char *intf) |
| 5641 | { |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 5642 | run_iwpriv(dut, intf, "vhtsubfee 0"); |
| 5643 | run_iwpriv(dut, intf, "vhtsubfer 0"); |
| 5644 | run_iwpriv(dut, intf, "vhtmubfee 0"); |
| 5645 | run_iwpriv(dut, intf, "vhtmubfer 0"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5646 | } |
| 5647 | |
| 5648 | |
Adil Saeed Musthafa | 05ec744 | 2017-04-10 23:13:35 -0700 | [diff] [blame] | 5649 | static void ath_set_assoc_disallow(struct sigma_dut *dut, const char *ifname, |
| 5650 | const char *val) |
| 5651 | { |
| 5652 | if (strcasecmp(val, "enable") == 0) { |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 5653 | run_iwpriv(dut, ifname, "mbo_asoc_dis 1"); |
Adil Saeed Musthafa | 05ec744 | 2017-04-10 23:13:35 -0700 | [diff] [blame] | 5654 | } else if (strcasecmp(val, "disable") == 0) { |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 5655 | run_iwpriv(dut, ifname, "mbo_asoc_dis 0"); |
Adil Saeed Musthafa | 05ec744 | 2017-04-10 23:13:35 -0700 | [diff] [blame] | 5656 | } else { |
| 5657 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5658 | "Unsupported assoc_disallow"); |
| 5659 | } |
| 5660 | } |
| 5661 | |
| 5662 | |
Adil Saeed Musthafa | 6906372 | 2017-04-10 23:13:40 -0700 | [diff] [blame] | 5663 | static void apply_mbo_pref_ap_list(struct sigma_dut *dut) |
| 5664 | { |
| 5665 | int i; |
| 5666 | int least_pref = 1 << 8; |
| 5667 | char ifname[20]; |
| 5668 | uint8_t self_mac[ETH_ALEN]; |
| 5669 | char buf[200]; |
| 5670 | int ap_ne_class, ap_ne_pref, ap_ne_op_ch; |
| 5671 | |
| 5672 | get_if_name(dut, ifname, sizeof(ifname), 1); |
| 5673 | get_hwaddr(ifname, self_mac); |
| 5674 | |
| 5675 | /* Clear off */ |
| 5676 | snprintf(buf, sizeof(buf), |
| 5677 | "wifitool %s setbssidpref 00:00:00:00:00:00 0 0 0", |
| 5678 | ifname); |
| 5679 | run_system(dut, buf); |
| 5680 | |
| 5681 | /* Find the least preference number */ |
| 5682 | for (i = 0; i < dut->mbo_pref_ap_cnt; i++) { |
| 5683 | unsigned char *mac_addr = dut->mbo_pref_aps[i].mac_addr; |
| 5684 | |
| 5685 | ap_ne_class = 1; |
| 5686 | ap_ne_pref = 255; |
| 5687 | ap_ne_op_ch = 1; |
| 5688 | if (dut->mbo_pref_aps[i].ap_ne_pref != -1) |
| 5689 | ap_ne_pref = dut->mbo_pref_aps[i].ap_ne_pref; |
| 5690 | if (dut->mbo_pref_aps[i].ap_ne_class != -1) |
| 5691 | ap_ne_class = dut->mbo_pref_aps[i].ap_ne_class; |
| 5692 | if (dut->mbo_pref_aps[i].ap_ne_op_ch != -1) |
| 5693 | ap_ne_op_ch = dut->mbo_pref_aps[i].ap_ne_op_ch; |
| 5694 | |
| 5695 | if (ap_ne_pref < least_pref) |
| 5696 | least_pref = ap_ne_pref; |
| 5697 | snprintf(buf, sizeof(buf), |
| 5698 | "wifitool %s setbssidpref %02x:%02x:%02x:%02x:%02x:%02x %d %d %d", |
| 5699 | ifname, mac_addr[0], mac_addr[1], mac_addr[2], |
| 5700 | mac_addr[3], mac_addr[4], mac_addr[5], |
| 5701 | ap_ne_pref, ap_ne_class, ap_ne_op_ch); |
| 5702 | run_system(dut, buf); |
| 5703 | } |
| 5704 | |
| 5705 | /* Now add the self AP Address */ |
| 5706 | if (dut->mbo_self_ap_tuple.ap_ne_class == -1) { |
| 5707 | if (dut->ap_channel <= 11) |
| 5708 | ap_ne_class = 81; |
| 5709 | else |
| 5710 | ap_ne_class = 115; |
| 5711 | } else { |
| 5712 | ap_ne_class = dut->mbo_self_ap_tuple.ap_ne_class; |
| 5713 | } |
| 5714 | |
| 5715 | if (dut->mbo_self_ap_tuple.ap_ne_op_ch == -1) |
| 5716 | ap_ne_op_ch = dut->ap_channel; |
| 5717 | else |
| 5718 | ap_ne_op_ch = dut->mbo_self_ap_tuple.ap_ne_op_ch; |
| 5719 | |
| 5720 | if (dut->mbo_self_ap_tuple.ap_ne_pref == -1) |
| 5721 | ap_ne_pref = least_pref - 1; |
| 5722 | else |
| 5723 | ap_ne_pref = dut->mbo_self_ap_tuple.ap_ne_pref; |
| 5724 | |
| 5725 | snprintf(buf, sizeof(buf), |
| 5726 | "wifitool %s setbssidpref %02x:%02x:%02x:%02x:%02x:%02x %d %d %d", |
| 5727 | ifname, self_mac[0], self_mac[1], self_mac[2], |
| 5728 | self_mac[3], self_mac[4], self_mac[5], |
| 5729 | ap_ne_pref, |
| 5730 | ap_ne_class, |
| 5731 | ap_ne_op_ch); |
| 5732 | run_system(dut, buf); |
| 5733 | } |
| 5734 | |
| 5735 | |
Priyadharshini Gowthaman | 7e43870 | 2019-08-09 12:05:05 -0700 | [diff] [blame] | 5736 | static void mubrp_commands(struct sigma_dut *dut, const char *ifname) |
| 5737 | { |
| 5738 | run_iwpriv(dut, ifname, "he_subfer 1"); |
| 5739 | run_iwpriv(dut, ifname, "he_mubfer 1"); |
| 5740 | /* To enable MU_AX with MU_BRP trigger */ |
| 5741 | run_iwpriv(dut, ifname, "he_sounding_mode 13"); |
| 5742 | /* Sets g_force_1x1_peer to 1 which should be reset to zero for non MU |
| 5743 | * test cases */ |
| 5744 | run_system_wrapper(dut, "wifitool %s setUnitTestCmd 0x48 2 118 1", |
| 5745 | ifname); |
| 5746 | /* Disable DL OFDMA */ |
| 5747 | run_system_wrapper(dut, "wifitool %s setUnitTestCmd 0x47 2 11 0", |
| 5748 | ifname); |
| 5749 | } |
| 5750 | |
| 5751 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5752 | static void ath_ap_set_params(struct sigma_dut *dut) |
| 5753 | { |
priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 5754 | const char *basedev = "wifi0"; |
| 5755 | const char *basedev_radio = "wifi1"; |
Jouni Malinen | 016ae6c | 2019-11-04 17:00:01 +0200 | [diff] [blame] | 5756 | const char *ifname = get_main_ifname(dut); |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 5757 | char *ifname_dual = NULL; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5758 | int i; |
priyadharshini gowthaman | 8e26ff4 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 5759 | char buf[300]; |
Priyadharshini Gowthaman | 78ee2ef | 2019-11-15 16:08:28 -0800 | [diff] [blame] | 5760 | unsigned int he_mcsnssmap = dut->he_mcsnssmap; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5761 | |
priyadharshini gowthaman | e161746 | 2017-04-25 12:03:59 -0700 | [diff] [blame] | 5762 | if (sigma_radio_ifname[0]) |
| 5763 | basedev = sigma_radio_ifname[0]; |
| 5764 | |
priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 5765 | if (dut->ap_is_dual == 1) { |
| 5766 | basedev = sigma_radio_ifname[0]; |
| 5767 | basedev_radio = sigma_radio_ifname[1]; |
| 5768 | if (sigma_radio_ifname[0] && |
| 5769 | strcmp(sigma_radio_ifname[0], "wifi0") == 0) { |
| 5770 | ifname = "ath0"; |
| 5771 | ifname_dual = "ath1"; |
| 5772 | } else { |
| 5773 | ifname = "ath1"; |
| 5774 | ifname_dual = "ath0"; |
| 5775 | } |
| 5776 | } |
| 5777 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5778 | if (dut->ap_countrycode[0]) { |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 5779 | run_iwpriv(dut, basedev, "setCountry %s", dut->ap_countrycode); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5780 | sigma_dut_print(dut, DUT_MSG_INFO, "Set countrycode"); |
| 5781 | } |
| 5782 | |
| 5783 | for (i = 0; i < NUM_AP_AC; i++) { |
| 5784 | if (dut->ap_qos[i].ac) { |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 5785 | run_iwpriv(dut, ifname, "cwmin %d 0 %d", i, |
| 5786 | dut->ap_qos[i].cwmin); |
| 5787 | run_iwpriv(dut, ifname, "cwmax %d 0 %d", i, |
| 5788 | dut->ap_qos[i].cwmax); |
| 5789 | run_iwpriv(dut, ifname, "aifs %d 0 %d", i, |
| 5790 | dut->ap_qos[i].aifs); |
| 5791 | run_iwpriv(dut, ifname, "txoplimit %d 0 %d", i, |
| 5792 | dut->ap_qos[i].txop); |
| 5793 | run_iwpriv(dut, ifname, "acm %d 0 %d", i, |
| 5794 | dut->ap_qos[i].acm); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5795 | } |
| 5796 | } |
| 5797 | |
| 5798 | for (i = 0; i < NUM_AP_AC; i++) { |
| 5799 | if (dut->ap_sta_qos[i].ac) { |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 5800 | run_iwpriv(dut, ifname, "cwmin %d 1 %d", i, |
| 5801 | dut->ap_sta_qos[i].cwmin); |
| 5802 | run_iwpriv(dut, ifname, "cwmax %d 1 %d", i, |
| 5803 | dut->ap_sta_qos[i].cwmax); |
| 5804 | run_iwpriv(dut, ifname, "aifs %d 1 %d", i, |
| 5805 | dut->ap_sta_qos[i].aifs); |
| 5806 | run_iwpriv(dut, ifname, "txoplimit %d 1 %d", i, |
| 5807 | dut->ap_sta_qos[i].txop); |
| 5808 | run_iwpriv(dut, ifname, "acm %d 1 %d", i, |
| 5809 | dut->ap_sta_qos[i].acm); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5810 | } |
| 5811 | } |
| 5812 | |
| 5813 | if (dut->ap_disable_protection == 1) { |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 5814 | run_iwpriv(dut, ifname, "enablertscts 0"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5815 | sigma_dut_print(dut, DUT_MSG_INFO, "Disabled rtscts"); |
| 5816 | } |
| 5817 | |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 5818 | if (dut->ap_ldpc == VALUE_ENABLED) |
| 5819 | run_iwpriv(dut, ifname, "ldpc 3"); |
| 5820 | else if (dut->ap_ldpc == VALUE_DISABLED) |
| 5821 | run_iwpriv(dut, ifname, "ldpc 0"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5822 | |
Priyadharshini Gowthaman | b58b51b | 2019-11-04 14:02:51 -0800 | [diff] [blame] | 5823 | if (dut->ap_ampdu == VALUE_ENABLED) { |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 5824 | run_iwpriv(dut, ifname, "ampdu 1"); |
Priyadharshini Gowthaman | b58b51b | 2019-11-04 14:02:51 -0800 | [diff] [blame] | 5825 | } else if (dut->ap_ampdu == VALUE_DISABLED) { |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 5826 | run_iwpriv(dut, ifname, "ampdu 0"); |
Priyadharshini Gowthaman | b58b51b | 2019-11-04 14:02:51 -0800 | [diff] [blame] | 5827 | if (dut->program == PROGRAM_HE) { |
| 5828 | run_iwpriv(dut, ifname, "setaddbaoper 1"); |
| 5829 | run_system_wrapper(dut, "wifitool %s refusealladdbas 1", |
| 5830 | ifname); |
| 5831 | if (dut->ap_amsdu == VALUE_ENABLED) { |
| 5832 | /* disable the limit for A-MSDU */ |
| 5833 | run_system_wrapper(dut, |
| 5834 | "wifitool %s setUnitTestCmd 0x48 2 46 1", |
| 5835 | ifname); |
| 5836 | } |
| 5837 | } |
| 5838 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5839 | |
| 5840 | if (dut->ap_ampdu_exp) { |
| 5841 | if (dut->program == PROGRAM_VHT) { |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 5842 | run_iwpriv(dut, ifname, "vhtmaxampdu %d", |
| 5843 | dut->ap_ampdu_exp); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5844 | } else { |
| 5845 | /* 11N */ |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 5846 | run_iwpriv(dut, ifname, "maxampdu %d", |
| 5847 | dut->ap_ampdu_exp); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5848 | } |
| 5849 | } |
| 5850 | |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 5851 | if (dut->ap_noack == VALUE_ENABLED) { |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 5852 | run_iwpriv(dut, ifname, "noackpolicy 0 0 1"); |
| 5853 | run_iwpriv(dut, ifname, "noackpolicy 1 0 1"); |
| 5854 | run_iwpriv(dut, ifname, "noackpolicy 2 0 1"); |
| 5855 | run_iwpriv(dut, ifname, "noackpolicy 3 0 1"); |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 5856 | } else if (dut->ap_noack == VALUE_DISABLED) { |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 5857 | run_iwpriv(dut, ifname, "noackpolicy 0 0 0"); |
| 5858 | run_iwpriv(dut, ifname, "noackpolicy 1 0 0"); |
| 5859 | run_iwpriv(dut, ifname, "noackpolicy 2 0 0"); |
| 5860 | run_iwpriv(dut, ifname, "noackpolicy 3 0 0"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5861 | } |
| 5862 | |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 5863 | if (dut->device_type == AP_testbed && dut->ap_vhtmcs_map) |
| 5864 | run_iwpriv(dut, ifname, "vht_mcsmap 0x%04x", |
| 5865 | dut->ap_vhtmcs_map); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5866 | |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 5867 | if (dut->ap_amsdu == VALUE_ENABLED) |
| 5868 | run_iwpriv(dut, ifname, "amsdu 2"); |
| 5869 | else if (dut->ap_amsdu == VALUE_DISABLED) |
| 5870 | run_iwpriv(dut, ifname, "amsdu 1"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5871 | |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 5872 | if (dut->ap_rx_amsdu == VALUE_ENABLED) |
| 5873 | run_iwpriv(dut, basedev_radio, "rx_amsdu 1"); |
| 5874 | else if (dut->ap_rx_amsdu == VALUE_DISABLED) |
| 5875 | run_iwpriv(dut, basedev_radio, "rx_amsdu 0"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5876 | |
| 5877 | /* Command sequence to generate single VHT AMSDU and MPDU */ |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 5878 | if (dut->ap_addba_reject != VALUE_NOT_SET && |
| 5879 | dut->ap_ampdu == VALUE_DISABLED && |
| 5880 | dut->ap_amsdu == VALUE_ENABLED) { |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 5881 | run_iwpriv(dut, ifname, "setaddbaoper 1"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5882 | |
| 5883 | snprintf(buf, sizeof(buf), |
| 5884 | "wifitool %s senddelba 1 0 1 4", ifname); |
| 5885 | if (system(buf) != 0) { |
| 5886 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5887 | "wifitool senddelba failed"); |
| 5888 | } |
| 5889 | |
| 5890 | snprintf(buf, sizeof(buf), "wifitool %s sendsingleamsdu 1 0", |
| 5891 | ifname); |
| 5892 | if (system(buf) != 0) { |
| 5893 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5894 | "wifitool sendsingleamsdu failed"); |
| 5895 | } |
| 5896 | |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 5897 | run_iwpriv(dut, ifname, "amsdu 10"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5898 | } |
| 5899 | |
| 5900 | if (dut->ap_mode == AP_11ac) { |
| 5901 | int chwidth, nss; |
| 5902 | |
| 5903 | switch (dut->ap_chwidth) { |
| 5904 | case AP_20: |
| 5905 | chwidth = 0; |
| 5906 | break; |
| 5907 | case AP_40: |
| 5908 | chwidth = 1; |
| 5909 | break; |
| 5910 | case AP_80: |
| 5911 | chwidth = 2; |
| 5912 | break; |
| 5913 | case AP_160: |
| 5914 | chwidth = 3; |
| 5915 | break; |
priyadharshini gowthaman | 63ab848 | 2017-12-28 15:32:55 -0800 | [diff] [blame] | 5916 | case AP_80_80: |
| 5917 | chwidth = 3; |
| 5918 | break; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5919 | default: |
| 5920 | chwidth = 0; |
| 5921 | break; |
| 5922 | } |
| 5923 | |
| 5924 | switch (dut->ap_tx_streams) { |
| 5925 | case 1: |
| 5926 | nss = 1; |
| 5927 | break; |
| 5928 | case 2: |
| 5929 | nss = 2; |
| 5930 | break; |
| 5931 | case 3: |
| 5932 | nss = 3; |
| 5933 | break; |
| 5934 | case 4: |
| 5935 | nss = 4; |
| 5936 | break; |
| 5937 | default: |
| 5938 | nss = 3; |
| 5939 | break; |
| 5940 | } |
| 5941 | |
| 5942 | if (dut->ap_fixed_rate) { |
| 5943 | if (nss == 4) |
| 5944 | ath_disable_txbf(dut, ifname); |
| 5945 | |
| 5946 | /* Set the nss */ |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 5947 | run_iwpriv(dut, ifname, "nss %d", nss); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5948 | |
| 5949 | /* Set the channel width */ |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 5950 | run_iwpriv(dut, ifname, "chwidth %d", chwidth); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5951 | |
| 5952 | /* Set the VHT MCS */ |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 5953 | run_iwpriv(dut, ifname, "vhtmcs %d", dut->ap_mcs); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5954 | } |
| 5955 | } |
| 5956 | |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 5957 | if (dut->ap_dyn_bw_sig == VALUE_ENABLED) |
| 5958 | run_iwpriv(dut, ifname, "cwmenable 1"); |
| 5959 | else if (dut->ap_dyn_bw_sig == VALUE_DISABLED) |
| 5960 | run_iwpriv(dut, ifname, "cwmenable 0"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5961 | |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 5962 | if (dut->ap_sig_rts == VALUE_ENABLED) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5963 | snprintf(buf, sizeof(buf), "iwconfig %s rts 64", ifname); |
| 5964 | if (system(buf) != 0) { |
| 5965 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5966 | "iwconfig rts 64 failed"); |
| 5967 | } |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 5968 | } else if (dut->ap_sig_rts == VALUE_DISABLED) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5969 | snprintf(buf, sizeof(buf), "iwconfig %s rts 2347", ifname); |
| 5970 | if (system(buf) != 0) { |
| 5971 | sigma_dut_print(dut, DUT_MSG_ERROR, |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 5972 | "iwconfig rts 2347 failed"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5973 | } |
| 5974 | } |
| 5975 | |
| 5976 | if (dut->ap_hs2) { |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 5977 | run_iwpriv(dut, ifname, "qbssload 1"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5978 | sigma_dut_print(dut, DUT_MSG_INFO, "Enabled qbssload"); |
| 5979 | } |
| 5980 | |
| 5981 | if (dut->ap_bss_load && dut->ap_bss_load != -1) { |
| 5982 | unsigned int bssload = 0; |
| 5983 | |
| 5984 | if (dut->ap_bss_load == 1) { |
| 5985 | /* STA count: 1, CU: 50, AAC: 65535 */ |
| 5986 | bssload = 0x0132ffff; |
| 5987 | } else if (dut->ap_bss_load == 2) { |
| 5988 | /* STA count: 1, CU: 200, AAC: 65535 */ |
| 5989 | bssload = 0x01c8ffff; |
| 5990 | } else if (dut->ap_bss_load == 3) { |
| 5991 | /* STA count: 1, CU: 75, AAC: 65535 */ |
| 5992 | bssload = 0x014bffff; |
| 5993 | } |
| 5994 | |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 5995 | run_iwpriv(dut, ifname, "hcbssload %u", bssload); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5996 | } else if (dut->ap_bss_load == 0) { |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 5997 | run_iwpriv(dut, ifname, "qbssload 0"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5998 | sigma_dut_print(dut, DUT_MSG_INFO, "Disabled qbssload"); |
| 5999 | } |
| 6000 | |
| 6001 | if (dut->ap_dgaf_disable) { |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 6002 | run_iwpriv(dut, ifname, "dgaf_disable 1"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6003 | sigma_dut_print(dut, DUT_MSG_INFO, "Enabled dgaf_disable"); |
| 6004 | } |
| 6005 | |
| 6006 | if (dut->ap_l2tif) { |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 6007 | run_iwpriv(dut, ifname, "l2tif 1"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6008 | snprintf(buf, sizeof(buf), |
| 6009 | "echo 1 > /sys/class/net/br0/brif/ath0/hotspot_l2tif"); |
| 6010 | if (system(buf) != 0) |
| 6011 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 6012 | "l2tif br failed"); |
| 6013 | |
| 6014 | snprintf(buf, sizeof(buf), |
| 6015 | "echo 1 > /sys/class/net/br0/brif/eth0/hotspot_wan"); |
| 6016 | if (system(buf) != 0) |
| 6017 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 6018 | "l2tif brif failed"); |
| 6019 | sigma_dut_print(dut, DUT_MSG_INFO, "Enabled l2tif"); |
| 6020 | } |
priyadharshini gowthaman | 264d544 | 2016-02-25 15:52:22 -0800 | [diff] [blame] | 6021 | |
| 6022 | if (dut->ap_ndpa_frame == 0) { |
| 6023 | snprintf(buf, sizeof(buf), |
| 6024 | "wifitool %s beeliner_fw_test 117 192", ifname); |
| 6025 | if (system(buf) != 0) { |
| 6026 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 6027 | "wifitool beeliner_fw_test 117 192 failed"); |
| 6028 | } |
| 6029 | snprintf(buf, sizeof(buf), |
| 6030 | "wifitool %s beeliner_fw_test 118 192", ifname); |
| 6031 | if (system(buf) != 0) { |
| 6032 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 6033 | "wifitool beeliner_fw_test 117 192 failed"); |
| 6034 | } |
| 6035 | } else if (dut->ap_ndpa_frame == 1) { |
| 6036 | /* Driver default - no changes needed */ |
| 6037 | } else if (dut->ap_ndpa_frame == 2) { |
| 6038 | snprintf(buf, sizeof(buf), |
| 6039 | "wifitool %s beeliner_fw_test 115 1", ifname); |
| 6040 | if (system(buf) != 0) { |
| 6041 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 6042 | "wifitool beeliner_fw_test 117 192 failed"); |
| 6043 | } |
| 6044 | snprintf(buf, sizeof(buf), |
| 6045 | "wifitool %s beeliner_fw_test 116 1", ifname); |
| 6046 | if (system(buf) != 0) { |
| 6047 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 6048 | "wifitool beeliner_fw_test 117 192 failed"); |
| 6049 | } |
| 6050 | } |
priyadharshini gowthaman | 8e26ff4 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 6051 | |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 6052 | if (dut->ap_rtt == 1) |
| 6053 | run_iwpriv(dut, ifname, "enable_rtt 1"); |
priyadharshini gowthaman | 8e26ff4 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 6054 | |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 6055 | if (dut->ap_lci == 1) |
| 6056 | run_iwpriv(dut, ifname, "enable_lci 1"); |
priyadharshini gowthaman | 8e26ff4 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 6057 | |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 6058 | if (dut->ap_lcr == 1) |
| 6059 | run_iwpriv(dut, ifname, "enable_lcr 1"); |
priyadharshini gowthaman | 8e26ff4 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 6060 | |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 6061 | if (dut->ap_rrm == 1) |
| 6062 | run_iwpriv(dut, ifname, "enable_rmm 1"); |
priyadharshini gowthaman | 8e26ff4 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 6063 | |
| 6064 | if (dut->ap_lci == 1 || dut->ap_lcr == 1) { |
| 6065 | run_system(dut, "wpc -l /tmp/lci_cfg.txt"); |
| 6066 | } |
| 6067 | |
| 6068 | if (dut->ap_neighap >= 1 && dut->ap_lci == 0) { |
| 6069 | FILE *f; |
| 6070 | |
| 6071 | f = fopen("/tmp/nbr_report.txt", "w"); |
| 6072 | if (!f) { |
| 6073 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 6074 | "Failed to open /tmp/nbr_report.txt"); |
| 6075 | return; |
| 6076 | } |
| 6077 | |
| 6078 | fprintf(f, |
| 6079 | "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", |
| 6080 | dut->ap_val_neighap[0][0], dut->ap_val_neighap[0][1], |
| 6081 | dut->ap_val_neighap[0][2], dut->ap_val_neighap[0][3], |
| 6082 | dut->ap_val_neighap[0][4], dut->ap_val_neighap[0][5], |
| 6083 | dut->ap_val_opchannel[0]); |
| 6084 | fclose(f); |
| 6085 | |
| 6086 | f = fopen("/tmp/ftmrr.txt", "w"); |
| 6087 | if (!f) { |
| 6088 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 6089 | "Failed to open /tmp/ftmrr.txt"); |
| 6090 | return; |
| 6091 | } |
| 6092 | |
| 6093 | fprintf(f, |
| 6094 | "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", |
| 6095 | dut->ap_val_neighap[0][0], dut->ap_val_neighap[0][1], |
| 6096 | dut->ap_val_neighap[0][2], dut->ap_val_neighap[0][3], |
| 6097 | dut->ap_val_neighap[0][4], dut->ap_val_neighap[0][5], |
| 6098 | dut->ap_val_opchannel[0]); |
| 6099 | fclose(f); |
| 6100 | } |
| 6101 | |
| 6102 | if (dut->ap_neighap >= 2 && dut->ap_lci == 0) { |
| 6103 | FILE *f; |
| 6104 | |
| 6105 | f = fopen("/tmp/nbr_report.txt", "a"); |
| 6106 | if (!f) { |
| 6107 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 6108 | "Failed to open /tmp/nbr_report.txt"); |
| 6109 | return; |
| 6110 | } |
| 6111 | fprintf(f, |
| 6112 | "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", |
| 6113 | dut->ap_val_neighap[1][0], dut->ap_val_neighap[1][1], |
| 6114 | dut->ap_val_neighap[1][2], dut->ap_val_neighap[1][3], |
| 6115 | dut->ap_val_neighap[1][4], dut->ap_val_neighap[1][5], |
| 6116 | dut->ap_val_opchannel[1]); |
| 6117 | fclose(f); |
| 6118 | |
| 6119 | f = fopen("/tmp/ftmrr.txt", "a"); |
| 6120 | if (!f) { |
| 6121 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 6122 | "Failed to open /tmp/ftmrr.txt"); |
| 6123 | return; |
| 6124 | } |
| 6125 | fprintf(f, |
| 6126 | "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", |
| 6127 | dut->ap_val_neighap[1][0], dut->ap_val_neighap[1][1], |
| 6128 | dut->ap_val_neighap[1][2], dut->ap_val_neighap[1][3], |
| 6129 | dut->ap_val_neighap[1][4], dut->ap_val_neighap[1][5], |
| 6130 | dut->ap_val_opchannel[1]); |
| 6131 | fclose(f); |
| 6132 | } |
| 6133 | |
| 6134 | if (dut->ap_neighap >= 3 && dut->ap_lci == 0) { |
| 6135 | FILE *f; |
| 6136 | |
| 6137 | f = fopen("/tmp/nbr_report.txt", "a"); |
| 6138 | if (!f) { |
| 6139 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 6140 | "Failed to open /tmp/nbr_report.txt"); |
| 6141 | return; |
| 6142 | } |
| 6143 | |
| 6144 | fprintf(f, |
| 6145 | "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", |
| 6146 | dut->ap_val_neighap[2][0], dut->ap_val_neighap[2][1], |
| 6147 | dut->ap_val_neighap[2][2], dut->ap_val_neighap[2][3], |
| 6148 | dut->ap_val_neighap[2][4], dut->ap_val_neighap[2][5], |
| 6149 | dut->ap_val_opchannel[2]); |
| 6150 | fclose(f); |
| 6151 | |
| 6152 | f = fopen("/tmp/ftmrr.txt", "a"); |
| 6153 | if (!f) { |
| 6154 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 6155 | "Failed to open /tmp/ftmrr.txt"); |
| 6156 | return; |
| 6157 | } |
| 6158 | |
| 6159 | fprintf(f, |
| 6160 | "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", |
| 6161 | dut->ap_val_neighap[2][0], dut->ap_val_neighap[2][1], |
| 6162 | dut->ap_val_neighap[2][2], dut->ap_val_neighap[2][3], |
| 6163 | dut->ap_val_neighap[2][4], dut->ap_val_neighap[2][5], |
| 6164 | dut->ap_val_opchannel[2]); |
| 6165 | fclose(f); |
| 6166 | } |
| 6167 | |
| 6168 | if (dut->ap_neighap) { |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 6169 | run_iwpriv(dut, ifname, "enable_rtt 1"); |
| 6170 | run_iwpriv(dut, ifname, "enable_lci 1"); |
| 6171 | run_iwpriv(dut, ifname, "enable_lcr 1"); |
| 6172 | run_iwpriv(dut, ifname, "enable_rrm 1"); |
priyadharshini gowthaman | 8e26ff4 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 6173 | } |
| 6174 | |
| 6175 | if (dut->ap_scan == 1) { |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 6176 | run_iwpriv(dut, ifname, "scanentryage 600"); |
priyadharshini gowthaman | 8e26ff4 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 6177 | snprintf(buf, sizeof(buf), "iwlist %s scan", ifname); |
| 6178 | run_system(dut, buf); |
| 6179 | } |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 6180 | |
| 6181 | if (dut->ap_set_bssidpref) { |
| 6182 | snprintf(buf, sizeof(buf), |
| 6183 | "wifitool %s setbssidpref 00:00:00:00:00:00 0 00 00", |
| 6184 | ifname); |
| 6185 | if (system(buf) != 0) { |
| 6186 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 6187 | "wifitool clear bssidpref failed"); |
| 6188 | } |
| 6189 | } |
Adil Saeed Musthafa | 33ea287 | 2017-04-10 23:13:24 -0700 | [diff] [blame] | 6190 | |
| 6191 | if (dut->wnm_bss_max_feature != VALUE_NOT_SET) { |
| 6192 | int feature_enable; |
| 6193 | |
| 6194 | feature_enable = dut->wnm_bss_max_feature == VALUE_ENABLED; |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 6195 | run_iwpriv(dut, ifname, "wnm %d", feature_enable); |
| 6196 | run_iwpriv(dut, ifname, "wnm_bss %d", feature_enable); |
Adil Saeed Musthafa | 33ea287 | 2017-04-10 23:13:24 -0700 | [diff] [blame] | 6197 | if (feature_enable) { |
| 6198 | const char *extra = ""; |
| 6199 | |
| 6200 | if (dut->wnm_bss_max_protection != VALUE_NOT_SET) { |
| 6201 | if (dut->wnm_bss_max_protection == |
| 6202 | VALUE_ENABLED) |
| 6203 | extra = " 1"; |
| 6204 | else |
| 6205 | extra = " 0"; |
| 6206 | } |
| 6207 | snprintf(buf, sizeof(buf), |
| 6208 | "wlanconfig %s wnm setbssmax %d%s", |
| 6209 | ifname, dut->wnm_bss_max_idle_time, extra); |
| 6210 | run_system(dut, buf); |
| 6211 | } |
| 6212 | } |
Adil Saeed Musthafa | 05ec744 | 2017-04-10 23:13:35 -0700 | [diff] [blame] | 6213 | |
Adil Saeed Musthafa | 023108a | 2017-04-10 23:13:37 -0700 | [diff] [blame] | 6214 | if (dut->program == PROGRAM_MBO) { |
Adil Saeed Musthafa | 6906372 | 2017-04-10 23:13:40 -0700 | [diff] [blame] | 6215 | apply_mbo_pref_ap_list(dut); |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 6216 | run_iwpriv(dut, ifname, "mbo_cel_pref %d", |
| 6217 | dut->ap_cell_cap_pref); |
| 6218 | run_iwpriv(dut, ifname, "mbocap 0x40"); |
Adil Saeed Musthafa | 05ec744 | 2017-04-10 23:13:35 -0700 | [diff] [blame] | 6219 | ath_set_assoc_disallow(dut, ifname, "disable"); |
Adil Saeed Musthafa | 023108a | 2017-04-10 23:13:37 -0700 | [diff] [blame] | 6220 | } |
priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 6221 | |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 6222 | if (dut->ap_oce == VALUE_ENABLED) |
| 6223 | run_iwpriv(dut, ifname, "set_bpr_enable 1"); |
priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 6224 | |
| 6225 | if (dut->ap_oce == VALUE_ENABLED && dut->ap_channel <= 11) { |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 6226 | run_iwpriv(dut, ifname, "prb_rate 5500"); |
| 6227 | run_iwpriv(dut, ifname, "set_bcn_rate 5500"); |
priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 6228 | } |
| 6229 | |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 6230 | if (dut->ap_oce == VALUE_DISABLED) |
| 6231 | run_iwpriv(dut, ifname, "set_bpr_enable 0"); |
priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 6232 | |
| 6233 | if (dut->ap_oce == VALUE_DISABLED && dut->ap_channel <= 11) { |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 6234 | run_iwpriv(dut, ifname, "mgmt_rate 1000"); |
| 6235 | run_iwpriv(dut, ifname, "set_bcn_rate 1000"); |
priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 6236 | } |
| 6237 | |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 6238 | if (dut->ap_bcnint) |
| 6239 | run_iwpriv(dut, ifname, "bintval %d", dut->ap_bcnint); |
priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 6240 | |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 6241 | if (dut->ap_filsdscv == VALUE_DISABLED) |
| 6242 | run_iwpriv(dut, ifname, "enable_fils 0 0"); |
priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 6243 | |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 6244 | if (dut->ap_filshlp == VALUE_ENABLED) |
| 6245 | run_iwpriv(dut, ifname, "oce_hlp 1"); |
| 6246 | else if (dut->ap_filshlp == VALUE_DISABLED) |
| 6247 | run_iwpriv(dut, ifname, "oce_hlp 0"); |
priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 6248 | |
| 6249 | /* When RNR is enabled, also enable apchannelreport, background scan */ |
| 6250 | if (dut->ap_rnr == VALUE_ENABLED) { |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 6251 | run_iwpriv(dut, ifname, "rnr 1"); |
| 6252 | run_iwpriv(dut, ifname, "rnr_tbtt 1"); |
| 6253 | run_iwpriv(dut, ifname, "apchanrpt 1"); |
| 6254 | run_iwpriv(dut, basedev, "acs_ctrlflags 0x4"); |
| 6255 | run_iwpriv(dut, basedev, "acs_scanintvl 60"); |
| 6256 | run_iwpriv(dut, basedev, "acs_bkscanen 1"); |
priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 6257 | if (dut->ap_is_dual == 1) { |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 6258 | run_iwpriv(dut, ifname_dual, "rnr 1"); |
| 6259 | run_iwpriv(dut, ifname_dual, "rnr_tbtt 1"); |
| 6260 | run_iwpriv(dut, ifname_dual, "apchanrpt 1"); |
| 6261 | run_iwpriv(dut, basedev_radio, "acs_ctrlflags 0x4"); |
| 6262 | run_iwpriv(dut, basedev_radio, "acs_scanintvl 60"); |
| 6263 | run_iwpriv(dut, basedev_radio, "acs_bkscanen 1"); |
priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 6264 | } |
| 6265 | } |
| 6266 | |
| 6267 | if (dut->ap_blechanutil || dut->ap_ble_admit_cap || dut->ap_blestacnt) { |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 6268 | run_iwpriv(dut, ifname, "qbssload 0"); |
priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 6269 | snprintf(buf, sizeof(buf), |
| 6270 | "wlanconfig %s addie ftype 0 len 7 data 0b05%02x%02x%02x%02x%02x ", |
| 6271 | ifname, dut->ap_blestacnt & 0xFF, |
| 6272 | dut->ap_blestacnt >> 8, dut->ap_blechanutil, |
| 6273 | dut->ap_ble_admit_cap & 0xFF, |
| 6274 | dut->ap_ble_admit_cap >> 8); |
| 6275 | run_system(dut, buf); |
| 6276 | snprintf(buf, sizeof(buf), |
| 6277 | "wlanconfig %s addie ftype 2 len 7 data 0b05%02x%02x%02x%02x%02x ", |
| 6278 | ifname, dut->ap_blestacnt & 0xFF, |
| 6279 | dut->ap_blestacnt >> 8, dut->ap_blechanutil, |
| 6280 | dut->ap_ble_admit_cap & 0xFF, |
| 6281 | dut->ap_ble_admit_cap >> 8); |
| 6282 | run_system(dut, buf); |
| 6283 | } |
| 6284 | |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 6285 | if (dut->ap_esp == VALUE_ENABLED) |
| 6286 | run_iwpriv(dut, basedev, "esp_period 5"); |
| 6287 | else if (dut->ap_esp == VALUE_DISABLED) |
| 6288 | run_iwpriv(dut, basedev, "esp_period 0"); |
priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 6289 | |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 6290 | if (dut->ap_datappdudura) |
| 6291 | run_iwpriv(dut, basedev, "esp_ppdu_dur %d", |
| 6292 | dut->ap_datappdudura); |
priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 6293 | |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 6294 | if (dut->ap_airtimefract) |
| 6295 | run_iwpriv(dut, basedev, "esp_airtime %d", |
| 6296 | dut->ap_airtimefract); |
priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 6297 | |
| 6298 | if (dut->ap_dhcp_stop) { |
| 6299 | snprintf(buf, sizeof(buf), "/etc/init.d/dnsmasq stop"); |
| 6300 | run_system(dut, buf); |
| 6301 | } |
| 6302 | |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 6303 | if (dut->ap_bawinsize) |
| 6304 | run_iwpriv(dut, basedev, "esp_ba_window %d", dut->ap_bawinsize); |
priyadharshini gowthaman | b4de196 | 2018-01-15 12:21:04 -0800 | [diff] [blame] | 6305 | |
| 6306 | if (dut->program == PROGRAM_DPP) { |
| 6307 | if (dut->ap_interface_2g == 1) { |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 6308 | run_iwpriv(dut, ifname, "set_bcn_rate 5500"); |
| 6309 | run_iwpriv(dut, ifname, "prb_rate 5500"); |
| 6310 | run_iwpriv(dut, ifname, "mgmt_rate 5500"); |
priyadharshini gowthaman | b4de196 | 2018-01-15 12:21:04 -0800 | [diff] [blame] | 6311 | } |
| 6312 | |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 6313 | run_iwpriv(dut, basedev, "set_rxfilter 0xffffffff"); |
priyadharshini gowthaman | b4de196 | 2018-01-15 12:21:04 -0800 | [diff] [blame] | 6314 | dut->hostapd_running = 1; |
| 6315 | } |
priyadharshini gowthaman | 350f191 | 2018-06-04 13:09:12 -0700 | [diff] [blame] | 6316 | |
Priyadharshini Gowthaman | b8fe053 | 2019-11-21 16:15:38 -0800 | [diff] [blame] | 6317 | if (dut->program == PROGRAM_HE) { |
| 6318 | /* disable sending basic triggers */ |
| 6319 | run_system_wrapper(dut, |
| 6320 | "wifitool %s setUnitTestCmd 0x47 2 42 0", |
| 6321 | ifname); |
| 6322 | /* disable MU BAR */ |
| 6323 | run_system_wrapper(dut, |
| 6324 | "wifitool %s setUnitTestCmd 0x47 2 64 1", |
| 6325 | ifname); |
| 6326 | /* disable PSD Boost */ |
| 6327 | run_system_wrapper(dut, |
| 6328 | "wifitool %s setUnitTestCmd 0x48 2 142 1", |
| 6329 | ifname); |
| 6330 | /* Enable mix bw */ |
| 6331 | run_system_wrapper(dut, |
| 6332 | "wifitool %s setUnitTestCmd 0x47 2 141 1", |
| 6333 | ifname); |
| 6334 | /* Disable preferred AC */ |
| 6335 | run_system_wrapper(dut, |
| 6336 | "wifitool %s setUnitTestCmd 0x48 2 186 0", |
| 6337 | ifname); |
| 6338 | run_iwpriv(dut, basedev, "he_muedca_mode 0"); |
| 6339 | run_iwpriv(dut, ifname, "he_ul_ofdma 0"); |
| 6340 | run_iwpriv(dut, ifname, "he_dl_ofdma 0"); |
Priyadharshini Gowthaman | 9b7dbe1 | 2019-12-04 12:17:32 -0800 | [diff] [blame] | 6341 | if (dut->he_set_sta_1x1 == VALUE_ENABLED) { |
| 6342 | /* sets g_force_1x1_peer to 1 */ |
| 6343 | run_system_wrapper(dut, |
| 6344 | "wifitool %s setUnitTestCmd 0x48 2 118 1", |
| 6345 | ifname); |
| 6346 | } |
Priyadharshini Gowthaman | d8d5f58 | 2019-11-25 15:39:43 -0800 | [diff] [blame] | 6347 | if (dut->ap_txBF) { |
| 6348 | /* Enable SU_AX sounding */ |
| 6349 | run_iwpriv(dut, ifname, "he_sounding_mode 1"); |
| 6350 | /* Ignore TBTT for NDP */ |
| 6351 | run_system_wrapper(dut, |
| 6352 | "wifitool %s setUnitTestCmd 0x48 2 2 1", |
| 6353 | ifname); |
| 6354 | /* g_cv_query_enable=1, i.e., cv query enable */ |
| 6355 | run_system_wrapper(dut, |
| 6356 | "wifitool %s setUnitTestCmd 0x47 2 7 1", |
| 6357 | ifname); |
| 6358 | /* Override TPC calculations and set TxBF flag to True |
| 6359 | */ |
| 6360 | run_system_wrapper(dut, |
| 6361 | "wifitool %s setUnitTestCmd 0x47 2 47 1", |
| 6362 | ifname); |
| 6363 | } |
Priyadharshini Gowthaman | b8fe053 | 2019-11-21 16:15:38 -0800 | [diff] [blame] | 6364 | if (dut->device_type == AP_testbed) { |
| 6365 | run_iwpriv(dut, ifname, "tx_stbc 0"); |
| 6366 | run_iwpriv(dut, ifname, "he_txmcsmap 0x0"); |
| 6367 | run_iwpriv(dut, ifname, "he_rxmcsmap 0x0"); |
| 6368 | run_iwpriv(dut, ifname, "he_amsdu_in_ampdu_supp 0"); |
| 6369 | run_iwpriv(dut, ifname, "he_bfee_sts_supp 0 0"); |
| 6370 | run_iwpriv(dut, ifname, "he_4xltf_800nsgi_rx 0"); |
| 6371 | run_iwpriv(dut, ifname, "he_1xltf_800nsgi_rx 0"); |
| 6372 | run_iwpriv(dut, ifname, "he_max_nc 0"); |
| 6373 | run_iwpriv(dut, ifname, "he_bsr_supp 0"); |
| 6374 | run_iwpriv(dut, ifname, "rx_stbc 0"); |
| 6375 | if (dut->ap_he_dlofdma == VALUE_DISABLED) |
| 6376 | run_iwpriv(dut, ifname, "he_dlofdma 0"); |
| 6377 | if (dut->ap_channel <= 11) { |
| 6378 | dut->ap_bcc = VALUE_ENABLED; |
| 6379 | run_iwpriv(dut, ifname, "vht_11ng 0"); |
| 6380 | } |
| 6381 | if (!dut->ap_txBF) { |
| 6382 | run_iwpriv(dut, ifname, "he_subfer 0"); |
| 6383 | run_iwpriv(dut, ifname, "he_subfee 0"); |
| 6384 | } |
| 6385 | if (!dut->ap_mu_txBF) { |
| 6386 | run_iwpriv(dut, ifname, "he_mubfer 0"); |
| 6387 | run_iwpriv(dut, ifname, "he_mubfee 0"); |
| 6388 | } |
Priyadharshini Gowthaman | e9d0bfc | 2019-11-22 14:26:12 -0800 | [diff] [blame] | 6389 | if (dut->ap_cipher == AP_WEP || |
| 6390 | dut->ap_cipher == AP_TKIP) |
| 6391 | run_iwpriv(dut, ifname, "htweptkip 1"); |
Priyadharshini Gowthaman | 2e0731b | 2019-11-25 15:38:58 -0800 | [diff] [blame] | 6392 | if (dut->ap_rx_streams || dut->ap_tx_streams) |
| 6393 | run_iwpriv(dut, ifname, "nss %d", |
| 6394 | dut->ap_rx_streams); |
Priyadharshini Gowthaman | b8fe053 | 2019-11-21 16:15:38 -0800 | [diff] [blame] | 6395 | } |
| 6396 | } |
| 6397 | |
Priyadharshini Gowthaman | fe60c50 | 2019-08-14 13:00:34 -0700 | [diff] [blame] | 6398 | if (dut->ap_he_ulofdma == VALUE_ENABLED) { |
| 6399 | run_iwpriv(dut, ifname, "he_ul_ofdma 1"); |
| 6400 | run_iwpriv(dut, ifname, "he_mu_edca 1"); |
| 6401 | |
| 6402 | /* Disable sounding for UL OFDMA */ |
| 6403 | run_system_wrapper(dut, "wifitool %s setUnitTestCmd 0x47 2 7 0", |
priyadharshini gowthaman | 350f191 | 2018-06-04 13:09:12 -0700 | [diff] [blame] | 6404 | ifname); |
Priyadharshini Gowthaman | fe60c50 | 2019-08-14 13:00:34 -0700 | [diff] [blame] | 6405 | |
| 6406 | if ((dut->ap_rx_streams || dut->ap_tx_streams) && |
| 6407 | dut->device_type == AP_testbed) { |
| 6408 | unsigned int txchainmask = 0x00; |
| 6409 | |
| 6410 | switch (dut->ap_rx_streams) { |
| 6411 | case 1: |
| 6412 | txchainmask = 0x01; |
| 6413 | break; |
| 6414 | case 2: |
| 6415 | txchainmask = 0x03; |
| 6416 | break; |
| 6417 | case 3: |
| 6418 | txchainmask = 0x07; |
| 6419 | break; |
| 6420 | case 4: |
| 6421 | txchainmask = 0x0f; |
| 6422 | break; |
| 6423 | case 5: |
| 6424 | txchainmask = 0x1f; |
| 6425 | break; |
| 6426 | case 6: |
| 6427 | txchainmask = 0x3f; |
| 6428 | break; |
| 6429 | case 7: |
| 6430 | txchainmask = 0x7f; |
| 6431 | break; |
| 6432 | case 8: |
| 6433 | txchainmask = 0xff; |
| 6434 | break; |
| 6435 | } |
| 6436 | |
| 6437 | run_iwpriv(dut, ifname, "he_ul_nss %d", |
| 6438 | dut->ap_rx_streams); |
| 6439 | run_iwpriv(dut, basedev, "txchainmask %d", txchainmask); |
| 6440 | run_iwpriv(dut, basedev, "rxchainmask %d", txchainmask); |
| 6441 | } |
| 6442 | |
| 6443 | if (dut->ap_channel == 100 && dut->device_type == AP_testbed) |
| 6444 | run_system_wrapper(dut, "iwpriv %s inact 1000", ifname); |
| 6445 | |
Priyadharshini Gowthaman | 78ee2ef | 2019-11-15 16:08:28 -0800 | [diff] [blame] | 6446 | if (dut->he_ul_mcs) |
| 6447 | run_iwpriv(dut, ifname, "he_ul_mcs %d", dut->he_ul_mcs); |
| 6448 | |
Priyadharshini Gowthaman | fe60c50 | 2019-08-14 13:00:34 -0700 | [diff] [blame] | 6449 | run_iwpriv(dut, ifname, "he_ul_ltf 3"); |
| 6450 | run_iwpriv(dut, ifname, "he_ul_shortgi 3"); |
| 6451 | run_iwpriv(dut, basedev, "he_ul_trig_int 2"); |
| 6452 | |
Priyadharshini Gowthaman | a17e6d8 | 2019-12-12 14:31:09 -0800 | [diff] [blame^] | 6453 | /* Disable efficiency check for UL OFDMA. We do not send TBPPDU |
| 6454 | * for one user. With this command, we would send UL OFDMA even |
| 6455 | * for one user to allow testing to be done without requiring |
| 6456 | * more than one station. */ |
| 6457 | run_system_wrapper(dut, |
| 6458 | "wifitool %s setUnitTestCmd 0x47 2 131 0", |
| 6459 | ifname); |
Priyadharshini Gowthaman | fe60c50 | 2019-08-14 13:00:34 -0700 | [diff] [blame] | 6460 | /* Set random RU allocation */ |
| 6461 | run_system_wrapper(dut, "wifitool %s setUnitTestCmd 0x47 2 9 1", |
| 6462 | ifname); |
| 6463 | /* To set TBTT PPDU duration (us) */ |
| 6464 | run_system_wrapper(dut, |
| 6465 | "wifitool %s setUnitTestCmd 0x48 2 63 1908", |
| 6466 | ifname); |
| 6467 | } |
| 6468 | |
Priyadharshini Gowthaman | fe60c50 | 2019-08-14 13:00:34 -0700 | [diff] [blame] | 6469 | if (dut->ap_he_dlofdma == VALUE_ENABLED) { |
| 6470 | run_iwpriv(dut, ifname, "he_dl_ofdma 1", ifname); |
| 6471 | |
| 6472 | /* For fixed MCS */ |
| 6473 | novap_reset(dut, ifname, 0); |
| 6474 | run_iwpriv(dut, ifname, |
| 6475 | "cfg80211tool %s setratemask 3 0x80f80f80 0x0f80f80f 0xf80f80f8"); |
| 6476 | } |
| 6477 | |
| 6478 | if (dut->ap_he_ppdu == PPDU_MU && dut->ap_he_dlofdma == VALUE_ENABLED) { |
| 6479 | /* Increase the min TX time limit for MU MIMO to disable MU MIMO |
| 6480 | * scheduling */ |
| 6481 | run_system_wrapper(dut, |
| 6482 | "wifitool %s setUnitTestCmd 0x47 2 11 1000000", |
| 6483 | ifname); |
| 6484 | /* Increase the max TX time limit for DL OFDMA to enable OFDMA |
| 6485 | * scheduling */ |
| 6486 | run_system_wrapper(dut, |
| 6487 | "wifitool %s setUnitTestCmd 0x47 2 17 1000000", |
| 6488 | ifname); |
| 6489 | /* Disable 'force SU schedule' to enable MU sch */ |
| 6490 | run_system_wrapper(dut, "wifitool %s setUnitTestCmd 0x47 2 8 0", |
| 6491 | ifname); |
| 6492 | /* Enable MU 11ax support in sch algo */ |
priyadharshini gowthaman | 350f191 | 2018-06-04 13:09:12 -0700 | [diff] [blame] | 6493 | run_system_wrapper(dut, |
| 6494 | "wifitool %s setUnitTestCmd 0x47 2 29 0", |
| 6495 | ifname); |
Priyadharshini Gowthaman | fe60c50 | 2019-08-14 13:00:34 -0700 | [diff] [blame] | 6496 | /* Enable to sort RU allocation */ |
| 6497 | run_system_wrapper(dut, "wifitool %s setUnitTestCmd 0x4b 2 2 1", |
| 6498 | ifname); |
priyadharshini gowthaman | 350f191 | 2018-06-04 13:09:12 -0700 | [diff] [blame] | 6499 | } |
Priyadharshini Gowthaman | bc94889 | 2019-09-10 14:22:49 -0700 | [diff] [blame] | 6500 | |
| 6501 | if (dut->ap_numsounddim) { |
| 6502 | unsigned int txchainmask = 0; |
| 6503 | |
| 6504 | switch (dut->ap_numsounddim) { |
| 6505 | case 1: |
| 6506 | txchainmask = 0x01; |
| 6507 | break; |
| 6508 | case 2: |
| 6509 | txchainmask = 0x03; |
| 6510 | break; |
| 6511 | case 3: |
| 6512 | txchainmask = 0x07; |
| 6513 | break; |
| 6514 | case 4: |
| 6515 | txchainmask = 0x0f; |
| 6516 | break; |
| 6517 | case 5: |
| 6518 | txchainmask = 0x1f; |
| 6519 | break; |
| 6520 | case 6: |
| 6521 | txchainmask = 0x3f; |
| 6522 | break; |
| 6523 | case 7: |
| 6524 | txchainmask = 0x7f; |
| 6525 | break; |
| 6526 | case 8: |
| 6527 | txchainmask = 0xff; |
| 6528 | break; |
| 6529 | } |
| 6530 | run_iwpriv(dut, basedev, "txchainmask %d", txchainmask); |
| 6531 | } |
| 6532 | |
| 6533 | if (dut->ap_numsounddim && dut->device_type == AP_testbed) { |
| 6534 | /* Sets g_force_1x1_peer to 1 which should be reset to zero |
| 6535 | * for non-MU test cases */ |
| 6536 | run_system_wrapper(dut, |
| 6537 | "wifitool %s setUnitTestCmd 0x48 2 118 1", |
| 6538 | ifname); |
| 6539 | if (dut->ap_mu_txBF) { |
| 6540 | /* Disable DL OFDMA */ |
| 6541 | run_system_wrapper(dut, |
| 6542 | "wifitool %s setUnitTestCmd 0x47 2 11 0", |
| 6543 | ifname); |
| 6544 | } |
| 6545 | } |
Priyadharshini Gowthaman | 670b323 | 2019-09-10 16:09:19 -0700 | [diff] [blame] | 6546 | |
Priyadharshini Gowthaman | 670b323 | 2019-09-10 16:09:19 -0700 | [diff] [blame] | 6547 | if (dut->ap_bcc == VALUE_ENABLED) { |
| 6548 | run_iwpriv(dut, ifname, "mode 11AHE20"); |
| 6549 | run_iwpriv(dut, ifname, "nss 2"); |
| 6550 | run_iwpriv(dut, ifname, "he_txmcsmap 0x0"); |
| 6551 | run_iwpriv(dut, ifname, "he_rxmcsmap 0x0"); |
| 6552 | } |
Priyadharshini Gowthaman | 6bc4c1e | 2019-09-10 16:24:51 -0700 | [diff] [blame] | 6553 | |
| 6554 | if (dut->ap_he_frag == VALUE_ENABLED) |
| 6555 | run_iwpriv(dut, ifname, "he_frag 1"); |
| 6556 | else if (dut->ap_he_frag == VALUE_DISABLED) |
| 6557 | run_iwpriv(dut, ifname, "he_frag 0"); |
Priyadharshini Gowthaman | 1a686bd | 2019-09-19 14:41:40 -0700 | [diff] [blame] | 6558 | |
| 6559 | if (dut->ap_ba_bufsize != BA_BUFSIZE_NOT_SET) { |
| 6560 | if (dut->ap_ba_bufsize == BA_BUFSIZE_64) |
| 6561 | run_iwpriv(dut, ifname, "ba_bufsize 0"); |
| 6562 | else |
| 6563 | run_iwpriv(dut, ifname, "ba_bufsize 1"); |
| 6564 | } |
Priyadharshini Gowthaman | 21895a5 | 2019-10-07 16:56:16 -0700 | [diff] [blame] | 6565 | |
| 6566 | if (dut->ap_mu_edca == VALUE_ENABLED) |
| 6567 | run_iwpriv(dut, ifname, "he_mu_edca 1"); |
Priyadharshini Gowthaman | dee79e2 | 2019-10-07 16:56:27 -0700 | [diff] [blame] | 6568 | |
| 6569 | if (dut->ap_he_mimo == MIMO_DL) { |
| 6570 | mubrp_commands(dut, ifname); |
| 6571 | if (dut->device_type != AP_testbed) |
| 6572 | run_system_wrapper( |
| 6573 | dut, "wifitool %s setUnitTestCmd 0x48 2 100 2", |
| 6574 | ifname); |
| 6575 | } |
| 6576 | |
| 6577 | if (dut->ap_he_mimo == MIMO_UL) |
| 6578 | run_iwpriv(dut, ifname, "he_mubfee 1"); |
Priyadharshini Gowthaman | 43d6b41 | 2019-10-07 16:56:37 -0700 | [diff] [blame] | 6579 | |
| 6580 | if (dut->ap_he_rtsthrshld == VALUE_ENABLED) |
| 6581 | run_iwpriv(dut, ifname, "he_rtsthrshld 512"); |
| 6582 | else if (dut->ap_he_rtsthrshld == VALUE_DISABLED) |
| 6583 | run_iwpriv(dut, ifname, "he_rtsthrshld 1024"); |
Priyadharshini Gowthaman | 8018c98 | 2019-10-31 15:14:37 -0700 | [diff] [blame] | 6584 | |
| 6585 | if (dut->ap_mbssid == VALUE_ENABLED && |
| 6586 | (dut->ap_rx_streams || dut->ap_tx_streams) && |
| 6587 | dut->device_type == AP_testbed) { |
| 6588 | const char *ifname_1; |
| 6589 | |
| 6590 | ifname_1= dut->ap_channel >= 36 ? "ath01" : "ath11"; |
| 6591 | |
| 6592 | /* NSS is not set in Secondary VAP for MBSSID case, |
| 6593 | * hence it is explicitly set here. For primary VAP |
| 6594 | * NSS is set during AP configuration */ |
| 6595 | run_iwpriv(dut, ifname_1, "nss %d", dut->ap_rx_streams); |
| 6596 | } |
Priyadharshini Gowthaman | ae0a605 | 2019-11-01 15:26:38 -0700 | [diff] [blame] | 6597 | |
| 6598 | if (dut->ap_twtresp == VALUE_ENABLED) |
| 6599 | run_iwpriv(dut, ifname, "twt_responder 1"); |
| 6600 | else if (dut->ap_twtresp == VALUE_DISABLED) |
| 6601 | run_iwpriv(dut, ifname, "twt_responder 0"); |
Priyadharshini Gowthaman | 78ee2ef | 2019-11-15 16:08:28 -0800 | [diff] [blame] | 6602 | |
| 6603 | if (dut->program == PROGRAM_HE && dut->ap_fixed_rate) { |
| 6604 | int nss = 0, mcs = 0; |
| 6605 | uint16_t mcsnssmap = 0; |
| 6606 | |
| 6607 | /* MCS 7 is used - set only nss and he_mcs. |
| 6608 | * Do not set mcsnssmap unless MCS is 9 or 11. */ |
| 6609 | if (dut->ap_mcs >= 9) { |
| 6610 | if (dut->ap_mcs == 9) { |
| 6611 | if (dut->ap_tx_streams == 1) { |
| 6612 | nss = 1; |
| 6613 | mcs = dut->ap_mcs; |
| 6614 | } else if (dut->ap_tx_streams == 2) { |
| 6615 | nss = 2; |
| 6616 | mcs = dut->ap_mcs; |
| 6617 | } |
| 6618 | } else if (dut->ap_mcs == 11) { |
| 6619 | if (dut->ap_tx_streams == 1) { |
| 6620 | nss = 1; |
| 6621 | mcs = dut->ap_mcs; |
| 6622 | } else if (dut->ap_tx_streams == 2) { |
| 6623 | nss = 2; |
| 6624 | mcs = dut->ap_mcs; |
| 6625 | } |
| 6626 | } |
| 6627 | |
| 6628 | get_he_mcs_nssmap((uint8_t *) &mcsnssmap, nss, mcs); |
| 6629 | he_mcsnssmap = (mcsnssmap << 16) | mcsnssmap; |
| 6630 | } |
| 6631 | |
| 6632 | run_iwpriv(dut, ifname, "nss %d", dut->ap_tx_streams); |
| 6633 | run_iwpriv(dut, ifname, "he_mcs %d", dut->ap_mcs); |
| 6634 | } |
| 6635 | |
| 6636 | if (he_mcsnssmap) { |
| 6637 | run_iwpriv(dut, ifname, "he_rxmcsmap %lu", he_mcsnssmap); |
| 6638 | run_iwpriv(dut, ifname, "he_txmcsmap %lu", he_mcsnssmap); |
| 6639 | } |
Priyadharshini Gowthaman | 96d542e | 2019-11-21 14:25:21 -0800 | [diff] [blame] | 6640 | |
| 6641 | if (dut->he_sounding == VALUE_ENABLED) |
| 6642 | run_system_wrapper(dut, "wifitool %s setUnitTestCmd 0x47 2 7 0", |
| 6643 | ifname); |
Priyadharshini Gowthaman | 21f7440 | 2019-11-25 15:39:09 -0800 | [diff] [blame] | 6644 | |
| 6645 | if (dut->he_mmss) |
| 6646 | run_iwpriv(dut, ifname, "ampduden_ovrd %d", dut->he_mmss); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6647 | } |
| 6648 | |
| 6649 | |
| 6650 | static int cmd_ath_ap_config_commit(struct sigma_dut *dut, |
| 6651 | struct sigma_conn *conn, |
| 6652 | struct sigma_cmd *cmd) |
| 6653 | { |
| 6654 | /* const char *name = get_param(cmd, "NAME"); */ |
| 6655 | char buf[100]; |
| 6656 | struct stat s; |
| 6657 | const char *ifname = dut->ap_is_dual ? "ath1" : "ath0"; |
Jouni Malinen | 3aa7286 | 2019-05-29 23:14:51 +0300 | [diff] [blame] | 6658 | int res; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6659 | |
| 6660 | if (stat("/proc/athversion", &s) == 0) { |
| 6661 | sigma_dut_print(dut, DUT_MSG_INFO, "Run apdown"); |
| 6662 | run_system(dut, "apdown"); |
| 6663 | } |
| 6664 | |
| 6665 | cmd_ath_ap_radio_config(dut); |
| 6666 | |
| 6667 | snprintf(buf, sizeof(buf), "cfg -a 'AP_SSID=%s'", dut->ap_ssid); |
| 6668 | run_system(dut, buf); |
| 6669 | |
| 6670 | switch (dut->ap_key_mgmt) { |
| 6671 | case AP_OPEN: |
| 6672 | if (dut->ap_cipher == AP_WEP) { |
| 6673 | run_system(dut, "cfg -a AP_SECMODE=WEP"); |
| 6674 | run_system(dut, "cfg -a AP_SECFILE=NONE"); |
| 6675 | /* shared auth mode not supported */ |
| 6676 | run_system(dut, "cfg -a AP_WEP_MODE_0=1"); |
| 6677 | run_system(dut, "cfg -a AP_WEP_MODE_1=1"); |
| 6678 | snprintf(buf, sizeof(buf), |
| 6679 | "cfg -a WEP_RADIO_NUM0_KEY_1=%s", |
| 6680 | dut->ap_wepkey); |
| 6681 | run_system(dut, buf); |
| 6682 | snprintf(buf, sizeof(buf), |
| 6683 | "cfg -a WEP_RADIO_NUM1_KEY_1=%s", |
| 6684 | dut->ap_wepkey); |
| 6685 | run_system(dut, buf); |
| 6686 | } else { |
| 6687 | run_system(dut, "cfg -a AP_SECMODE=None"); |
| 6688 | } |
| 6689 | break; |
| 6690 | case AP_WPA2_PSK: |
| 6691 | case AP_WPA2_PSK_MIXED: |
| 6692 | case AP_WPA_PSK: |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 6693 | case AP_WPA2_SAE: |
| 6694 | case AP_WPA2_PSK_SAE: |
| 6695 | if (dut->ap_key_mgmt == AP_WPA2_PSK || |
| 6696 | dut->ap_key_mgmt == AP_WPA2_SAE || |
| 6697 | dut->ap_key_mgmt == AP_WPA2_PSK_SAE) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6698 | run_system(dut, "cfg -a AP_WPA=2"); |
| 6699 | else if (dut->ap_key_mgmt == AP_WPA2_PSK_MIXED) |
| 6700 | run_system(dut, "cfg -a AP_WPA=3"); |
| 6701 | else |
| 6702 | run_system(dut, "cfg -a AP_WPA=1"); |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 6703 | /* TODO: SAE configuration */ |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6704 | run_system(dut, "cfg -a AP_SECMODE=WPA"); |
| 6705 | run_system(dut, "cfg -a AP_SECFILE=PSK"); |
Jouni Malinen | 3aa7286 | 2019-05-29 23:14:51 +0300 | [diff] [blame] | 6706 | res = snprintf(buf, sizeof(buf), "cfg -a 'PSK_KEY=%s'", |
| 6707 | dut->ap_passphrase); |
| 6708 | if (res < 0 || res >= sizeof(buf)) |
| 6709 | return ERROR_SEND_STATUS; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6710 | run_system(dut, buf); |
| 6711 | if (dut->ap_cipher == AP_CCMP_TKIP) |
| 6712 | run_system(dut, "cfg -a AP_CYPHER=\"CCMP TKIP\""); |
| 6713 | else if (dut->ap_cipher == AP_TKIP) |
| 6714 | run_system(dut, "cfg -a AP_CYPHER=TKIP"); |
| 6715 | else |
| 6716 | run_system(dut, "cfg -a AP_CYPHER=CCMP"); |
| 6717 | break; |
| 6718 | case AP_WPA2_EAP: |
| 6719 | case AP_WPA2_EAP_MIXED: |
| 6720 | case AP_WPA_EAP: |
| 6721 | if (dut->ap_key_mgmt == AP_WPA2_EAP) |
| 6722 | run_system(dut, "cfg -a AP_WPA=2"); |
| 6723 | else if (dut->ap_key_mgmt == AP_WPA2_EAP_MIXED) |
| 6724 | run_system(dut, "cfg -a AP_WPA=3"); |
| 6725 | else |
| 6726 | run_system(dut, "cfg -a AP_WPA=1"); |
| 6727 | run_system(dut, "cfg -a AP_SECMODE=WPA"); |
| 6728 | run_system(dut, "cfg -a AP_SECFILE=EAP"); |
| 6729 | if (dut->ap_cipher == AP_CCMP_TKIP) |
| 6730 | run_system(dut, "cfg -a AP_CYPHER=\"CCMP TKIP\""); |
| 6731 | else if (dut->ap_cipher == AP_TKIP) |
| 6732 | run_system(dut, "cfg -a AP_CYPHER=TKIP"); |
| 6733 | else |
| 6734 | run_system(dut, "cfg -a AP_CYPHER=CCMP"); |
| 6735 | snprintf(buf, sizeof(buf), "cfg -a AP_AUTH_SERVER=%s", |
| 6736 | dut->ap_radius_ipaddr); |
| 6737 | run_system(dut, buf); |
| 6738 | snprintf(buf, sizeof(buf), "cfg -a AP_AUTH_PORT=%d", |
| 6739 | dut->ap_radius_port); |
| 6740 | run_system(dut, buf); |
Jouni Malinen | 3aa7286 | 2019-05-29 23:14:51 +0300 | [diff] [blame] | 6741 | res = snprintf(buf, sizeof(buf), "cfg -a AP_AUTH_SECRET=%s", |
| 6742 | dut->ap_radius_password); |
| 6743 | if (res < 0 || res >= sizeof(buf)) |
| 6744 | return ERROR_SEND_STATUS; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6745 | run_system(dut, buf); |
| 6746 | break; |
Jouni Malinen | 4cf699f | 2018-06-19 00:46:27 +0300 | [diff] [blame] | 6747 | case AP_WPA2_EAP_OSEN: |
| 6748 | /* TODO */ |
| 6749 | sigma_dut_print(dut, DUT_MSG_ERROR, "EAP+OSEN not supported"); |
| 6750 | break; |
Jouni Malinen | ad395a2 | 2017-09-01 21:13:46 +0300 | [diff] [blame] | 6751 | case AP_SUITEB: |
| 6752 | /* TODO */ |
| 6753 | sigma_dut_print(dut, DUT_MSG_ERROR, "SuiteB not supported"); |
| 6754 | break; |
Jouni Malinen | 147b3c3 | 2017-10-09 16:51:54 +0300 | [diff] [blame] | 6755 | case AP_WPA2_OWE: |
| 6756 | /* TODO */ |
| 6757 | sigma_dut_print(dut, DUT_MSG_ERROR, "OWE not supported"); |
| 6758 | break; |
Jouni Malinen | 6be21c8 | 2018-08-01 18:47:24 +0300 | [diff] [blame] | 6759 | case AP_WPA2_FT_EAP: |
| 6760 | case AP_WPA2_FT_PSK: |
| 6761 | case AP_WPA2_EAP_SHA256: |
| 6762 | case AP_WPA2_PSK_SHA256: |
| 6763 | case AP_WPA2_ENT_FT_EAP: |
Jouni Malinen | c2b9121 | 2018-09-12 02:26:39 +0300 | [diff] [blame] | 6764 | case AP_OSEN: |
Jouni Malinen | 6be21c8 | 2018-08-01 18:47:24 +0300 | [diff] [blame] | 6765 | /* TODO */ |
| 6766 | send_resp(dut, conn, SIGMA_ERROR, |
| 6767 | "errorCode,Unsupported KeyMgnt value"); |
| 6768 | return 0; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6769 | } |
| 6770 | |
| 6771 | if (dut->ap_is_dual) { |
| 6772 | /* ath1 settings in case of dual */ |
| 6773 | snprintf(buf, sizeof(buf), "cfg -a 'AP_SSID_2=%s'", |
| 6774 | dut->ap_ssid); |
| 6775 | run_system(dut, buf); |
| 6776 | |
| 6777 | switch (dut->ap_key_mgmt) { |
| 6778 | case AP_OPEN: |
| 6779 | if (dut->ap_cipher == AP_WEP) { |
| 6780 | run_system(dut, "cfg -a AP_SECMODE_2=WEP"); |
| 6781 | run_system(dut, "cfg -a AP_SECFILE_2=NONE"); |
| 6782 | /* shared auth mode not supported */ |
| 6783 | run_system(dut, "cfg -a AP_WEP_MODE_0=1"); |
| 6784 | run_system(dut, "cfg -a AP_WEP_MODE_1=1"); |
| 6785 | snprintf(buf, sizeof(buf), |
| 6786 | "cfg -a WEP_RADIO_NUM0_KEY_1=%s", |
| 6787 | dut->ap_wepkey); |
| 6788 | run_system(dut, buf); |
| 6789 | snprintf(buf, sizeof(buf), |
| 6790 | "cfg -a WEP_RADIO_NUM1_KEY_1=%s", |
| 6791 | dut->ap_wepkey); |
| 6792 | run_system(dut, buf); |
| 6793 | } else { |
| 6794 | run_system(dut, "cfg -a AP_SECMODE_2=None"); |
| 6795 | } |
| 6796 | break; |
| 6797 | case AP_WPA2_PSK: |
| 6798 | case AP_WPA2_PSK_MIXED: |
| 6799 | case AP_WPA_PSK: |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 6800 | case AP_WPA2_SAE: |
| 6801 | case AP_WPA2_PSK_SAE: |
| 6802 | if (dut->ap_key_mgmt == AP_WPA2_PSK || |
| 6803 | dut->ap_key_mgmt == AP_WPA2_SAE || |
| 6804 | dut->ap_key_mgmt == AP_WPA2_PSK_SAE) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6805 | run_system(dut, "cfg -a AP_WPA_2=2"); |
| 6806 | else if (dut->ap_key_mgmt == AP_WPA2_PSK_MIXED) |
| 6807 | run_system(dut, "cfg -a AP_WPA_2=3"); |
| 6808 | else |
| 6809 | run_system(dut, "cfg -a AP_WPA_2=1"); |
| 6810 | // run_system(dut, "cfg -a AP_WPA_2=2"); |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 6811 | /* TODO: SAE configuration */ |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6812 | run_system(dut, "cfg -a AP_SECMODE_2=WPA"); |
| 6813 | run_system(dut, "cfg -a AP_SECFILE_2=PSK"); |
Jouni Malinen | 3aa7286 | 2019-05-29 23:14:51 +0300 | [diff] [blame] | 6814 | res = snprintf(buf, sizeof(buf), |
| 6815 | "cfg -a 'PSK_KEY_2=%s'", |
| 6816 | dut->ap_passphrase); |
| 6817 | if (res < 0 || res >= sizeof(buf)) |
| 6818 | return ERROR_SEND_STATUS; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6819 | run_system(dut, buf); |
| 6820 | if (dut->ap_cipher == AP_CCMP_TKIP) |
| 6821 | run_system(dut, "cfg -a AP_CYPHER_2=\"CCMP TKIP\""); |
| 6822 | else if (dut->ap_cipher == AP_TKIP) |
| 6823 | run_system(dut, "cfg -a AP_CYPHER_2=TKIP"); |
| 6824 | else |
| 6825 | run_system(dut, "cfg -a AP_CYPHER_2=CCMP"); |
| 6826 | break; |
| 6827 | case AP_WPA2_EAP: |
| 6828 | case AP_WPA2_EAP_MIXED: |
| 6829 | case AP_WPA_EAP: |
| 6830 | if (dut->ap_key_mgmt == AP_WPA2_EAP) |
| 6831 | run_system(dut, "cfg -a AP_WPA_2=2"); |
| 6832 | else if (dut->ap_key_mgmt == AP_WPA2_EAP_MIXED) |
| 6833 | run_system(dut, "cfg -a AP_WPA_2=3"); |
| 6834 | else |
| 6835 | run_system(dut, "cfg -a AP_WPA_2=1"); |
| 6836 | run_system(dut, "cfg -a AP_SECMODE_2=WPA"); |
| 6837 | run_system(dut, "cfg -a AP_SECFILE_2=EAP"); |
| 6838 | if (dut->ap_cipher == AP_CCMP_TKIP) |
| 6839 | run_system(dut, "cfg -a AP_CYPHER_2=\"CCMP TKIP\""); |
| 6840 | else if (dut->ap_cipher == AP_TKIP) |
| 6841 | run_system(dut, "cfg -a AP_CYPHER_2=TKIP"); |
| 6842 | else |
| 6843 | run_system(dut, "cfg -a AP_CYPHER_2=CCMP"); |
| 6844 | |
| 6845 | snprintf(buf, sizeof(buf), "cfg -a AP_AUTH_SERVER_2=%s", |
| 6846 | dut->ap_radius_ipaddr); |
| 6847 | run_system(dut, buf); |
| 6848 | snprintf(buf, sizeof(buf), "cfg -a AP_AUTH_PORT_2=%d", |
| 6849 | dut->ap_radius_port); |
| 6850 | run_system(dut, buf); |
Jouni Malinen | 3aa7286 | 2019-05-29 23:14:51 +0300 | [diff] [blame] | 6851 | res = snprintf(buf, sizeof(buf), |
| 6852 | "cfg -a AP_AUTH_SECRET_2=%s", |
| 6853 | dut->ap_radius_password); |
| 6854 | if (res < 0 || res >= sizeof(buf)) |
| 6855 | return ERROR_SEND_STATUS; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6856 | run_system(dut, buf); |
| 6857 | break; |
Jouni Malinen | 4cf699f | 2018-06-19 00:46:27 +0300 | [diff] [blame] | 6858 | case AP_WPA2_EAP_OSEN: |
| 6859 | /* TODO */ |
| 6860 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 6861 | "EAP+OSEN not supported"); |
| 6862 | break; |
Jouni Malinen | ad395a2 | 2017-09-01 21:13:46 +0300 | [diff] [blame] | 6863 | case AP_SUITEB: |
| 6864 | /* TODO */ |
| 6865 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 6866 | "SuiteB not supported"); |
| 6867 | break; |
Jouni Malinen | 147b3c3 | 2017-10-09 16:51:54 +0300 | [diff] [blame] | 6868 | case AP_WPA2_OWE: |
| 6869 | /* TODO */ |
| 6870 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 6871 | "OWE not supported"); |
| 6872 | break; |
Jouni Malinen | 6be21c8 | 2018-08-01 18:47:24 +0300 | [diff] [blame] | 6873 | case AP_WPA2_FT_EAP: |
| 6874 | case AP_WPA2_FT_PSK: |
| 6875 | case AP_WPA2_EAP_SHA256: |
| 6876 | case AP_WPA2_PSK_SHA256: |
| 6877 | case AP_WPA2_ENT_FT_EAP: |
Jouni Malinen | c2b9121 | 2018-09-12 02:26:39 +0300 | [diff] [blame] | 6878 | case AP_OSEN: |
Jouni Malinen | 6be21c8 | 2018-08-01 18:47:24 +0300 | [diff] [blame] | 6879 | /* TODO */ |
| 6880 | send_resp(dut, conn, SIGMA_ERROR, |
| 6881 | "errorCode,Unsupported KeyMgnt value"); |
| 6882 | return 0; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6883 | } |
| 6884 | |
| 6885 | /* wifi0 settings in case of dual */ |
| 6886 | run_system(dut, "cfg -a AP_RADIO_ID=0"); |
| 6887 | run_system(dut, "cfg -a AP_PRIMARY_CH=6"); |
| 6888 | run_system(dut, "cfg -a AP_STARTMODE=dual"); |
| 6889 | run_system(dut, "cfg -a AP_CHMODE=11NGHT40PLUS"); |
| 6890 | run_system(dut, "cfg -a TX_CHAINMASK=7"); |
| 6891 | run_system(dut, "cfg -a RX_CHAINMASK=7"); |
| 6892 | } |
| 6893 | |
| 6894 | switch (dut->ap_pmf) { |
| 6895 | case AP_PMF_DISABLED: |
| 6896 | snprintf(buf, sizeof(buf), "cfg -a AP_PMF=0"); |
| 6897 | run_system(dut, buf); |
| 6898 | break; |
| 6899 | case AP_PMF_OPTIONAL: |
| 6900 | snprintf(buf, sizeof(buf), "cfg -a AP_PMF=1"); |
| 6901 | run_system(dut, buf); |
| 6902 | break; |
| 6903 | case AP_PMF_REQUIRED: |
| 6904 | snprintf(buf, sizeof(buf), "cfg -a AP_PMF=2"); |
| 6905 | run_system(dut, buf); |
| 6906 | break; |
| 6907 | } |
| 6908 | if (dut->ap_add_sha256) { |
| 6909 | snprintf(buf, sizeof(buf), "cfg -a AP_WPA_SHA256=1"); |
| 6910 | run_system(dut, buf); |
| 6911 | } else { |
| 6912 | snprintf(buf, sizeof(buf), "cfg -r AP_WPA_SHA256"); |
| 6913 | run_system(dut, buf); |
| 6914 | } |
| 6915 | |
| 6916 | if (dut->ap_hs2) |
| 6917 | run_system(dut, "cfg -a AP_HOTSPOT=1"); |
| 6918 | else |
| 6919 | run_system(dut, "cfg -r AP_HOTSPOT"); |
| 6920 | |
| 6921 | if (dut->ap_interworking) { |
| 6922 | snprintf(buf, sizeof(buf), "cfg -a AP_HOTSPOT_ANT=%d", |
| 6923 | dut->ap_access_net_type); |
| 6924 | run_system(dut, buf); |
| 6925 | snprintf(buf, sizeof(buf), "cfg -a AP_HOTSPOT_INTERNET=%d", |
| 6926 | dut->ap_internet); |
| 6927 | run_system(dut, buf); |
| 6928 | snprintf(buf, sizeof(buf), "cfg -a AP_HOTSPOT_VENUEGROUP=%d", |
| 6929 | dut->ap_venue_group); |
| 6930 | run_system(dut, buf); |
| 6931 | snprintf(buf, sizeof(buf), "cfg -a AP_HOTSPOT_VENUETYPE=%d", |
| 6932 | dut->ap_venue_type); |
| 6933 | run_system(dut, buf); |
| 6934 | snprintf(buf, sizeof(buf), "cfg -a AP_HOTSPOT_HESSID=%s", |
| 6935 | dut->ap_hessid); |
| 6936 | run_system(dut, buf); |
| 6937 | |
| 6938 | if (dut->ap_roaming_cons[0]) { |
| 6939 | char *second, *rc; |
| 6940 | rc = strdup(dut->ap_roaming_cons); |
| 6941 | if (rc == NULL) |
| 6942 | return 0; |
| 6943 | |
| 6944 | second = strchr(rc, ';'); |
| 6945 | if (second) |
| 6946 | *second++ = '\0'; |
| 6947 | |
| 6948 | snprintf(buf, sizeof(buf), |
| 6949 | "cfg -a AP_HOTSPOT_ROAMINGCONSORTIUM=%s", rc); |
| 6950 | run_system(dut, buf); |
| 6951 | |
| 6952 | if (second) { |
| 6953 | snprintf(buf, sizeof(buf), |
| 6954 | "cfg -a AP_HOTSPOT_ROAMINGCONSORTIUM2" |
| 6955 | "=%s", second); |
| 6956 | run_system(dut, buf); |
| 6957 | } |
| 6958 | free(rc); |
| 6959 | } else { |
| 6960 | run_system(dut, "cfg -r AP_HOTSPOT_ROAMINGCONSORTIUM"); |
| 6961 | run_system(dut, |
| 6962 | "cfg -r AP_HOTSPOT_ROAMINGCONSORTIUM2"); |
| 6963 | } |
| 6964 | } else { |
| 6965 | run_system(dut, "cfg -r AP_HOTSPOT_ANT"); |
| 6966 | run_system(dut, "cfg -r AP_HOTSPOT_INTERNET"); |
| 6967 | run_system(dut, "cfg -r AP_HOTSPOT_VENUEGROUP"); |
| 6968 | run_system(dut, "cfg -r AP_HOTSPOT_VENUETYPE"); |
| 6969 | run_system(dut, "cfg -r AP_HOTSPOT_HESSID"); |
| 6970 | run_system(dut, "cfg -r AP_HOTSPOT_ROAMINGCONSORTIUM"); |
| 6971 | run_system(dut, "cfg -r AP_HOTSPOT_ROAMINGCONSORTIUM2"); |
| 6972 | } |
| 6973 | |
| 6974 | if (dut->ap_proxy_arp) |
| 6975 | run_system(dut, "cfg -a IEEE80211V_PROXYARP=1"); |
| 6976 | else |
| 6977 | run_system(dut, "cfg -a IEEE80211V_PROXYARP=0"); |
| 6978 | if (dut->ap_dgaf_disable) |
| 6979 | run_system(dut, "cfg -a AP_HOTSPOT_DISABLE_DGAF=1"); |
| 6980 | else |
| 6981 | run_system(dut, "cfg -r AP_HOTSPOT_DISABLE_DGAF"); |
| 6982 | |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 6983 | if (strlen(dut->ap_tag_ssid[0])) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6984 | snprintf(buf, sizeof(buf), |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 6985 | "cfg -a AP_SSID_2=%s", dut->ap_tag_ssid[0]); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6986 | run_system(dut, buf); |
| 6987 | |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 6988 | if (dut->ap_tag_key_mgmt[0] == AP2_OSEN) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6989 | run_system(dut, "cfg -a AP_SECMODE_2=WPA"); |
| 6990 | run_system(dut, "cfg -a AP_SECFILE_2=OSEN"); |
| 6991 | |
Jouni Malinen | 3aa7286 | 2019-05-29 23:14:51 +0300 | [diff] [blame] | 6992 | res = snprintf(buf, sizeof(buf), |
| 6993 | "cfg -a AP_AUTH_SERVER_2=%s", |
| 6994 | dut->ap2_radius_ipaddr); |
| 6995 | if (res < 0 || res >= sizeof(buf)) |
| 6996 | return ERROR_SEND_STATUS; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6997 | run_system(dut, buf); |
| 6998 | |
Jouni Malinen | 3aa7286 | 2019-05-29 23:14:51 +0300 | [diff] [blame] | 6999 | res = snprintf(buf, sizeof(buf), |
| 7000 | "cfg -a AP_AUTH_PORT_2=%d", |
| 7001 | dut->ap2_radius_port); |
| 7002 | if (res < 0 || res >= sizeof(buf)) |
| 7003 | return ERROR_SEND_STATUS; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7004 | run_system(dut, buf); |
| 7005 | |
Jouni Malinen | 3aa7286 | 2019-05-29 23:14:51 +0300 | [diff] [blame] | 7006 | res = snprintf(buf, sizeof(buf), |
| 7007 | "cfg -a AP_AUTH_SECRET_2=%s", |
| 7008 | dut->ap2_radius_password); |
| 7009 | if (res < 0 || res >= sizeof(buf)) |
| 7010 | return ERROR_SEND_STATUS; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7011 | run_system(dut, buf); |
| 7012 | } else { |
| 7013 | run_system(dut, "cfg -a AP_SECMODE_2=None"); |
| 7014 | run_system(dut, "cfg -r AP_AUTH_SERVER_2"); |
| 7015 | run_system(dut, "cfg -r AP_AUTH_PORT_2"); |
| 7016 | run_system(dut, "cfg -r AP_AUTH_SECRET_2"); |
| 7017 | } |
| 7018 | |
| 7019 | run_system(dut, "cfg -a AP_STARTMODE=multi"); |
| 7020 | } |
| 7021 | |
| 7022 | run_system(dut, "cfg -c"); |
| 7023 | |
| 7024 | sigma_dut_print(dut, DUT_MSG_INFO, "Starting AP"); |
| 7025 | if (system("apup") != 0) { |
| 7026 | /* to be debugged why apup returns error |
| 7027 | send_resp(dut, conn, SIGMA_ERROR, |
| 7028 | "errorCode,apup failed"); |
| 7029 | return 0; |
| 7030 | */ |
| 7031 | } |
| 7032 | sigma_dut_print(dut, DUT_MSG_INFO, "AP started"); |
| 7033 | |
| 7034 | if (dut->ap_key_mgmt != AP_OPEN) { |
| 7035 | int res; |
| 7036 | /* allow some time for hostapd to start before returning |
| 7037 | * success */ |
| 7038 | usleep(500000); |
| 7039 | if (run_hostapd_cli(dut, "ping") != 0) { |
| 7040 | send_resp(dut, conn, SIGMA_ERROR, |
| 7041 | "errorCode,Failed to talk to hostapd"); |
| 7042 | return 0; |
| 7043 | } |
| 7044 | |
| 7045 | if (dut->ap_hs2 && !dut->ap_anqpserver) { |
| 7046 | /* the cfg app doesn't like ";" in the variables */ |
| 7047 | res = ath_ap_append_hostapd_conf(dut); |
| 7048 | if (res < 0) |
| 7049 | return res; |
| 7050 | |
| 7051 | /* wait for hostapd to be ready */ |
| 7052 | usleep(500000); |
| 7053 | if (run_hostapd_cli(dut, "ping") != 0) { |
| 7054 | send_resp(dut, conn, SIGMA_ERROR, |
| 7055 | "errorCode,Failed to talk to " |
| 7056 | "hostapd"); |
| 7057 | return 0; |
| 7058 | } |
| 7059 | } |
| 7060 | } |
| 7061 | |
| 7062 | ath_ap_set_params(dut); |
| 7063 | |
| 7064 | if (dut->ap_anqpserver) |
| 7065 | return cmd_ath_ap_anqpserver_start(dut); |
| 7066 | |
| 7067 | if (dut->ap2_proxy_arp) |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 7068 | run_iwpriv(dut, ifname, "proxy_arp 1"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7069 | |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 7070 | if (dut->ap_allow_vht_wep || dut->ap_allow_vht_tkip) |
| 7071 | run_iwpriv(dut, ifname, "htweptkip 1"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7072 | |
| 7073 | return 1; |
| 7074 | } |
| 7075 | |
| 7076 | |
| 7077 | static int set_ebtables_proxy_arp(struct sigma_dut *dut, const char *chain, |
| 7078 | const char *ifname) |
| 7079 | { |
| 7080 | char buf[200]; |
| 7081 | |
| 7082 | if (!chain || !ifname) |
| 7083 | return -2; |
| 7084 | |
| 7085 | snprintf(buf, sizeof(buf), "ebtables -P %s ACCEPT", chain); |
| 7086 | if (system(buf) != 0) { |
| 7087 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 7088 | "Failed to set ebtables rules, RULE-1, %s", |
| 7089 | chain); |
| 7090 | return -2; |
| 7091 | } |
| 7092 | |
| 7093 | snprintf(buf, sizeof(buf), |
| 7094 | "ebtables -A %s -p ARP -d Broadcast -o %s -j DROP", |
| 7095 | chain, ifname); |
| 7096 | if (system(buf) != 0) { |
| 7097 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 7098 | "Failed to set ebtables rules, RULE-2, %s", |
| 7099 | chain); |
| 7100 | return -2; |
| 7101 | } |
| 7102 | |
| 7103 | snprintf(buf, sizeof(buf), |
| 7104 | "ebtables -A %s -d Multicast -p IPv6 --ip6-protocol ipv6-icmp --ip6-icmp-type neighbor-solicitation -o %s -j DROP", |
| 7105 | chain, ifname); |
| 7106 | if (system(buf) != 0) { |
| 7107 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 7108 | "Failed to set ebtables rules, RULE-3, %s", |
| 7109 | chain); |
| 7110 | return -2; |
| 7111 | } |
| 7112 | |
| 7113 | snprintf(buf, sizeof(buf), |
| 7114 | "ebtables -A %s -d Multicast -p IPv6 --ip6-protocol ipv6-icmp --ip6-icmp-type neighbor-advertisement -o %s -j DROP", |
| 7115 | chain, ifname); |
| 7116 | if (system(buf) != 0) { |
| 7117 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 7118 | "Failed to set ebtables rules, RULE-4, %s", |
| 7119 | chain); |
| 7120 | return -2; |
| 7121 | } |
| 7122 | |
| 7123 | return 0; |
| 7124 | } |
| 7125 | |
| 7126 | |
| 7127 | static int set_ebtables_disable_dgaf(struct sigma_dut *dut, |
| 7128 | const char *chain, |
| 7129 | const char *ifname) |
| 7130 | { |
| 7131 | char buf[200]; |
| 7132 | |
| 7133 | if (!chain || !ifname) |
| 7134 | return -2; |
| 7135 | |
| 7136 | snprintf(buf, sizeof(buf), "ebtables -P %s ACCEPT", chain); |
| 7137 | if (system(buf) != 0) { |
| 7138 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 7139 | "Failed to set ebtables rules, RULE-5, %s", |
| 7140 | chain); |
| 7141 | return -2; |
| 7142 | } |
| 7143 | |
| 7144 | snprintf(buf, sizeof(buf), |
| 7145 | "ebtables -A %s -p ARP -d Broadcast -o %s -j DROP", |
| 7146 | chain, ifname); |
| 7147 | if (system(buf) != 0) { |
| 7148 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 7149 | "Failed to set ebtables rules, RULE-6, %s", |
| 7150 | chain); |
| 7151 | return -2; |
| 7152 | } |
| 7153 | |
| 7154 | snprintf(buf, sizeof(buf), |
| 7155 | "ebtables -A %s -p IPv4 -d Multicast -o %s -j DROP", |
| 7156 | chain, ifname); |
| 7157 | if (system(buf) != 0) { |
| 7158 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 7159 | "Failed to set ebtables rules, RULE-7, %s", |
| 7160 | chain); |
| 7161 | return -2; |
| 7162 | } |
| 7163 | |
| 7164 | snprintf(buf, sizeof(buf), |
| 7165 | "ebtables -A %s -p IPv6 -d Multicast -o %s -j DROP", |
| 7166 | chain, ifname); |
| 7167 | if (system(buf) != 0) { |
| 7168 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 7169 | "Failed to set ebtables rules, RULE-8, %s", |
| 7170 | chain); |
| 7171 | return -2; |
| 7172 | } |
| 7173 | |
| 7174 | return 0; |
| 7175 | } |
| 7176 | |
| 7177 | |
Jouni Malinen | dbbc2c4 | 2018-11-14 23:55:41 +0200 | [diff] [blame] | 7178 | static void set_ebtables_forward_drop(struct sigma_dut *dut, |
| 7179 | const char *ifname, const char *ifname2) |
| 7180 | { |
| 7181 | char buf[128]; |
| 7182 | |
| 7183 | snprintf(buf, sizeof(buf), "ebtables -A FORWARD -i %s -o %s -j DROP", |
| 7184 | ifname, ifname2); |
| 7185 | if (system(buf) != 0) |
| 7186 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 7187 | "Failed to set ebtables rule"); |
| 7188 | |
| 7189 | snprintf(buf, sizeof(buf), "ebtables -A FORWARD -i %s -o %s -j DROP", |
| 7190 | ifname2, ifname); |
| 7191 | if (system(buf) != 0) |
| 7192 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 7193 | "Failed to set ebtables rule"); |
| 7194 | } |
| 7195 | |
| 7196 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7197 | static int check_channel(int channel) |
| 7198 | { |
| 7199 | int channel_list[] = { 36, 40, 44, 48, 52, 60, 64, 100, 104, 108, 112, |
| 7200 | 116, 120, 124, 128, 132, 140, 144, 149, 153, 157, |
| 7201 | 161, 165 }; |
| 7202 | int num_chan = sizeof(channel_list) / sizeof(int); |
| 7203 | int i; |
| 7204 | |
| 7205 | for (i = 0; i < num_chan; i++) { |
| 7206 | if (channel == channel_list[i]) |
| 7207 | return i; |
| 7208 | } |
| 7209 | |
| 7210 | return -1; |
| 7211 | } |
| 7212 | |
| 7213 | |
| 7214 | static int get_oper_centr_freq_seq_idx(int chwidth, int channel) |
| 7215 | { |
| 7216 | int ch_base; |
| 7217 | int period; |
| 7218 | |
| 7219 | if (check_channel(channel) < 0) |
| 7220 | return -1; |
| 7221 | |
| 7222 | if (channel >= 36 && channel <= 64) |
| 7223 | ch_base = 36; |
| 7224 | else if (channel >= 100 && channel <= 144) |
| 7225 | ch_base = 100; |
| 7226 | else |
| 7227 | ch_base = 149; |
| 7228 | |
| 7229 | period = channel % ch_base * 5 / chwidth; |
| 7230 | return ch_base + period * chwidth / 5 + (chwidth - 20) / 10; |
| 7231 | } |
| 7232 | |
| 7233 | |
| 7234 | static int is_ht40plus_chan(int chan) |
| 7235 | { |
| 7236 | return chan == 36 || chan == 44 || chan == 52 || chan == 60 || |
| 7237 | chan == 100 || chan == 108 || chan == 116 || chan == 124 || |
| 7238 | chan == 132 || chan == 149 || chan == 157; |
| 7239 | } |
| 7240 | |
| 7241 | |
| 7242 | static int is_ht40minus_chan(int chan) |
| 7243 | { |
| 7244 | return chan == 40 || chan == 48 || chan == 56 || chan == 64 || |
| 7245 | chan == 104 || chan == 112 || chan == 120 || chan == 128 || |
| 7246 | chan == 136 || chan == 153 || chan == 161; |
| 7247 | } |
| 7248 | |
| 7249 | |
Mohammed Shafi Shajakhan | b53d8f9 | 2017-02-28 09:05:15 +0530 | [diff] [blame] | 7250 | static int get_5g_channel_freq(int chan) |
| 7251 | { |
| 7252 | return 5000 + chan * 5; |
| 7253 | } |
| 7254 | |
| 7255 | |
Jouni Malinen | 3d633da | 2017-09-14 22:19:21 +0300 | [diff] [blame] | 7256 | static const char * hostapd_cipher_name(enum ap_cipher cipher) |
| 7257 | { |
| 7258 | switch (cipher) { |
| 7259 | case AP_CCMP: |
| 7260 | return "CCMP"; |
| 7261 | case AP_TKIP: |
| 7262 | return "TKIP"; |
| 7263 | case AP_CCMP_TKIP: |
| 7264 | return "CCMP TKIP"; |
| 7265 | case AP_GCMP_256: |
| 7266 | return "GCMP-256"; |
| 7267 | case AP_GCMP_128: |
| 7268 | return "GCMP"; |
| 7269 | case AP_CCMP_256: |
| 7270 | return "CCMP-256"; |
Jouni Malinen | d538c78 | 2017-11-17 12:13:04 +0200 | [diff] [blame] | 7271 | case AP_CCMP_128_GCMP_256: |
| 7272 | return "CCMP GCMP-256"; |
Jouni Malinen | 3d633da | 2017-09-14 22:19:21 +0300 | [diff] [blame] | 7273 | default: |
| 7274 | return "UNKNOWN"; |
| 7275 | } |
| 7276 | } |
| 7277 | |
| 7278 | |
| 7279 | static const char * |
| 7280 | hostapd_group_mgmt_cipher_name(enum ap_group_mgmt_cipher cipher) |
| 7281 | { |
| 7282 | switch (cipher) { |
| 7283 | case AP_BIP_GMAC_256: |
Jouni Malinen | 57887a2 | 2017-10-10 20:43:25 +0300 | [diff] [blame] | 7284 | return "BIP-GMAC-256"; |
Jouni Malinen | 3d633da | 2017-09-14 22:19:21 +0300 | [diff] [blame] | 7285 | case AP_BIP_CMAC_256: |
| 7286 | return "BIP-CMAC-256"; |
| 7287 | case AP_BIP_GMAC_128: |
| 7288 | return "BIP-GMAC-128"; |
| 7289 | case AP_BIP_CMAC_128: |
| 7290 | return "AES-128-CMAC"; |
| 7291 | default: |
| 7292 | return "UNKNOWN"; |
| 7293 | } |
| 7294 | } |
| 7295 | |
| 7296 | |
Alexei Avshalom Lazar | bc180dc | 2018-12-18 16:01:14 +0200 | [diff] [blame] | 7297 | static int ap_set_60g_ese(struct sigma_dut *dut, int count, |
| 7298 | struct sigma_ese_alloc *allocs) |
| 7299 | { |
Jouni Malinen | 016ae6c | 2019-11-04 17:00:01 +0200 | [diff] [blame] | 7300 | switch (get_driver_type(dut)) { |
Alexei Avshalom Lazar | bc180dc | 2018-12-18 16:01:14 +0200 | [diff] [blame] | 7301 | #ifdef __linux__ |
| 7302 | case DRIVER_WIL6210: |
| 7303 | return wil6210_set_ese(dut, count, allocs); |
| 7304 | #endif /* __linux__ */ |
| 7305 | default: |
| 7306 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 7307 | "Unsupported ap_set_60g_ese with the current driver"); |
| 7308 | return -1; |
| 7309 | } |
| 7310 | } |
| 7311 | |
| 7312 | |
Alexei Avshalom Lazar | aad97b0 | 2018-12-18 16:01:23 +0200 | [diff] [blame] | 7313 | static int ap_set_force_mcs(struct sigma_dut *dut, int force, int mcs) |
| 7314 | { |
Jouni Malinen | 016ae6c | 2019-11-04 17:00:01 +0200 | [diff] [blame] | 7315 | switch (get_driver_type(dut)) { |
Alexei Avshalom Lazar | aad97b0 | 2018-12-18 16:01:23 +0200 | [diff] [blame] | 7316 | #ifdef __linux__ |
| 7317 | case DRIVER_WIL6210: |
| 7318 | return wil6210_set_force_mcs(dut, force, mcs); |
| 7319 | #endif /* __linux__ */ |
| 7320 | default: |
| 7321 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 7322 | "Unsupported ap_set_force_mcs with the current driver"); |
| 7323 | return -1; |
| 7324 | } |
| 7325 | } |
| 7326 | |
| 7327 | |
Jouni Malinen | f722271 | 2019-06-13 01:50:21 +0300 | [diff] [blame] | 7328 | enum sigma_cmd_result cmd_ap_config_commit(struct sigma_dut *dut, |
| 7329 | struct sigma_conn *conn, |
| 7330 | struct sigma_cmd *cmd) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7331 | { |
| 7332 | /* const char *name = get_param(cmd, "NAME"); */ |
| 7333 | FILE *f; |
| 7334 | const char *ifname; |
| 7335 | char buf[500]; |
| 7336 | char path[100]; |
| 7337 | enum driver_type drv; |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 7338 | const char *key_mgmt; |
Srinivas Dasari | a1deeaa | 2018-06-18 22:54:04 +0530 | [diff] [blame] | 7339 | #ifdef ANDROID |
| 7340 | struct group *gr; |
| 7341 | #endif /* ANDROID */ |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7342 | |
Jouni Malinen | 016ae6c | 2019-11-04 17:00:01 +0200 | [diff] [blame] | 7343 | drv = get_driver_type(dut); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7344 | |
| 7345 | if (dut->mode == SIGMA_MODE_STATION) { |
| 7346 | stop_sta_mode(dut); |
| 7347 | sleep(1); |
| 7348 | } |
| 7349 | |
| 7350 | if (dut->mode == SIGMA_MODE_SNIFFER && dut->sniffer_ifname) { |
| 7351 | snprintf(buf, sizeof(buf), "ifconfig %s down", |
| 7352 | dut->sniffer_ifname); |
| 7353 | if (system(buf) != 0) { |
| 7354 | sigma_dut_print(dut, DUT_MSG_INFO, |
| 7355 | "Failed to run '%s'", buf); |
| 7356 | } |
| 7357 | snprintf(buf, sizeof(buf), "iw dev %s set type station", |
| 7358 | dut->sniffer_ifname); |
| 7359 | if (system(buf) != 0) { |
| 7360 | sigma_dut_print(dut, DUT_MSG_INFO, |
| 7361 | "Failed to run '%s'", buf); |
| 7362 | } |
| 7363 | } |
| 7364 | |
| 7365 | dut->mode = SIGMA_MODE_AP; |
| 7366 | |
| 7367 | if (drv == DRIVER_ATHEROS) |
| 7368 | return cmd_ath_ap_config_commit(dut, conn, cmd); |
| 7369 | if (drv == DRIVER_WCN) |
| 7370 | return cmd_wcn_ap_config_commit(dut, conn, cmd); |
| 7371 | if (drv == DRIVER_OPENWRT) |
| 7372 | return cmd_owrt_ap_config_commit(dut, conn, cmd); |
| 7373 | |
| 7374 | f = fopen(SIGMA_TMPDIR "/sigma_dut-ap.conf", "w"); |
| 7375 | if (f == NULL) { |
| 7376 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 7377 | "%s: Failed to open sigma_dut-ap.conf", |
| 7378 | __func__); |
| 7379 | return -2; |
| 7380 | } |
| 7381 | switch (dut->ap_mode) { |
| 7382 | case AP_11g: |
| 7383 | case AP_11b: |
| 7384 | case AP_11ng: |
Pradeep Reddy Potteti | 08eaeba | 2017-06-14 12:43:19 +0530 | [diff] [blame] | 7385 | ifname = (drv == DRIVER_MAC80211) ? "wlan0" : "ath0"; |
| 7386 | if ((drv == DRIVER_QNXNTO || drv == DRIVER_LINUX_WCN) && |
Jouni Malinen | d209548 | 2019-11-04 17:10:43 +0200 | [diff] [blame] | 7387 | dut->main_ifname) |
Jouni Malinen | 5ea3092 | 2019-11-04 17:39:25 +0200 | [diff] [blame] | 7388 | ifname = get_main_ifname(dut); |
Jouni Malinen | 8564746 | 2019-11-06 19:38:50 +0200 | [diff] [blame] | 7389 | if (dut->main_ifname_2g) |
| 7390 | ifname = dut->main_ifname_2g; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7391 | fprintf(f, "hw_mode=g\n"); |
| 7392 | break; |
| 7393 | case AP_11a: |
| 7394 | case AP_11na: |
| 7395 | case AP_11ac: |
Jouni Malinen | 8564746 | 2019-11-06 19:38:50 +0200 | [diff] [blame] | 7396 | if (dut->main_ifname_5g) { |
| 7397 | ifname = dut->main_ifname_5g; |
| 7398 | } else if (drv == DRIVER_QNXNTO || drv == DRIVER_LINUX_WCN) { |
Jouni Malinen | d209548 | 2019-11-04 17:10:43 +0200 | [diff] [blame] | 7399 | if (dut->main_ifname) |
Jouni Malinen | 5ea3092 | 2019-11-04 17:39:25 +0200 | [diff] [blame] | 7400 | ifname = get_main_ifname(dut); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7401 | else |
| 7402 | ifname = "wlan0"; |
Pradeep Reddy Potteti | 08eaeba | 2017-06-14 12:43:19 +0530 | [diff] [blame] | 7403 | } else if (drv == DRIVER_MAC80211) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7404 | if (if_nametoindex("wlan1") > 0) |
| 7405 | ifname = "wlan1"; |
| 7406 | else |
| 7407 | ifname = "wlan0"; |
| 7408 | } else { |
Jouni Malinen | 016ae6c | 2019-11-04 17:00:01 +0200 | [diff] [blame] | 7409 | ifname = get_main_ifname(dut); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7410 | } |
| 7411 | fprintf(f, "hw_mode=a\n"); |
| 7412 | break; |
Alexei Avshalom Lazar | 2712cc8 | 2018-12-23 16:29:14 +0200 | [diff] [blame] | 7413 | case AP_11ad: |
Jouni Malinen | 016ae6c | 2019-11-04 17:00:01 +0200 | [diff] [blame] | 7414 | ifname = get_main_ifname(dut); |
Alexei Avshalom Lazar | 2712cc8 | 2018-12-23 16:29:14 +0200 | [diff] [blame] | 7415 | fprintf(f, "hw_mode=ad\n"); |
| 7416 | break; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7417 | default: |
| 7418 | fclose(f); |
| 7419 | return -1; |
| 7420 | } |
Jouni Malinen | d6bf1b4 | 2017-06-23 17:51:01 +0300 | [diff] [blame] | 7421 | if (dut->hostapd_ifname) |
| 7422 | ifname = dut->hostapd_ifname; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7423 | |
Sreelakshmi Konamki | b692f10 | 2016-04-26 19:47:00 +0530 | [diff] [blame] | 7424 | if (drv == DRIVER_MAC80211 || drv == DRIVER_LINUX_WCN) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7425 | fprintf(f, "driver=nl80211\n"); |
| 7426 | |
Sreelakshmi Konamki | b692f10 | 2016-04-26 19:47:00 +0530 | [diff] [blame] | 7427 | if ((drv == DRIVER_MAC80211 || drv == DRIVER_QNXNTO || |
| 7428 | drv == DRIVER_LINUX_WCN) && |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7429 | (dut->ap_mode == AP_11ng || dut->ap_mode == AP_11na)) { |
Tamizh chelvam | 431c600 | 2017-03-07 17:07:16 +0530 | [diff] [blame] | 7430 | int ht40plus = 0, ht40minus = 0, tx_stbc = 0; |
| 7431 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7432 | fprintf(f, "ieee80211n=1\n"); |
Pradeep Reddy Potteti | bf8af29 | 2017-02-15 15:28:39 +0530 | [diff] [blame] | 7433 | if (dut->ap_mode == AP_11ng && |
| 7434 | (dut->ap_chwidth == AP_40 || |
| 7435 | (dut->ap_chwidth == AP_AUTO && |
| 7436 | dut->default_11ng_ap_chwidth == AP_40))) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7437 | if (dut->ap_channel >= 1 && dut->ap_channel <= 7) |
Tamizh chelvam | 431c600 | 2017-03-07 17:07:16 +0530 | [diff] [blame] | 7438 | ht40plus = 1; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7439 | else if (dut->ap_channel >= 8 && dut->ap_channel <= 11) |
Tamizh chelvam | 431c600 | 2017-03-07 17:07:16 +0530 | [diff] [blame] | 7440 | ht40minus = 1; |
| 7441 | fprintf(f, "obss_interval=300\n"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7442 | } |
| 7443 | |
| 7444 | /* configure ht_capab based on channel width */ |
| 7445 | if (dut->ap_mode == AP_11na && |
| 7446 | (dut->ap_chwidth == AP_40 || |
| 7447 | (dut->ap_chwidth == AP_AUTO && |
Pradeep Reddy Potteti | bf8af29 | 2017-02-15 15:28:39 +0530 | [diff] [blame] | 7448 | dut->default_11na_ap_chwidth == AP_40))) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7449 | if (is_ht40plus_chan(dut->ap_channel)) |
Tamizh chelvam | 431c600 | 2017-03-07 17:07:16 +0530 | [diff] [blame] | 7450 | ht40plus = 1; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7451 | else if (is_ht40minus_chan(dut->ap_channel)) |
Tamizh chelvam | 431c600 | 2017-03-07 17:07:16 +0530 | [diff] [blame] | 7452 | ht40minus = 1; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7453 | } |
Mohammed Shafi Shajakhan | 31d8a15 | 2016-06-02 20:10:55 +0530 | [diff] [blame] | 7454 | |
| 7455 | if (dut->ap_tx_stbc) |
Tamizh chelvam | 431c600 | 2017-03-07 17:07:16 +0530 | [diff] [blame] | 7456 | tx_stbc = 1; |
Mohammed Shafi Shajakhan | 31d8a15 | 2016-06-02 20:10:55 +0530 | [diff] [blame] | 7457 | |
Pradeep Reddy Potteti | 4b0cdee | 2017-03-15 12:37:33 +0530 | [diff] [blame] | 7458 | /* Overwrite the ht_capab with offset value if configured */ |
| 7459 | if (dut->ap_chwidth == AP_40 && |
| 7460 | dut->ap_chwidth_offset == SEC_CH_40ABOVE) { |
| 7461 | ht40plus = 1; |
| 7462 | ht40minus = 0; |
| 7463 | } else if (dut->ap_chwidth == AP_40 && |
| 7464 | dut->ap_chwidth_offset == SEC_CH_40BELOW) { |
| 7465 | ht40minus = 1; |
| 7466 | ht40plus = 0; |
| 7467 | } |
| 7468 | |
Tamizh chelvam | 431c600 | 2017-03-07 17:07:16 +0530 | [diff] [blame] | 7469 | fprintf(f, "ht_capab=%s%s%s\n", |
| 7470 | ht40plus ? "[HT40+]" : "", |
| 7471 | ht40minus ? "[HT40-]" : "", |
| 7472 | tx_stbc ? "[TX-STBC]" : ""); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7473 | } |
| 7474 | |
Sreelakshmi Konamki | b692f10 | 2016-04-26 19:47:00 +0530 | [diff] [blame] | 7475 | if ((drv == DRIVER_MAC80211 || drv == DRIVER_QNXNTO || |
| 7476 | drv == DRIVER_LINUX_WCN) && |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7477 | dut->ap_mode == AP_11ac) { |
Hu Wang | 2939210 | 2019-07-03 15:41:12 +0800 | [diff] [blame] | 7478 | int ht40plus = 0, ht40minus = 0; |
| 7479 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7480 | fprintf(f, "ieee80211ac=1\n" |
Hu Wang | 2939210 | 2019-07-03 15:41:12 +0800 | [diff] [blame] | 7481 | "ieee80211n=1\n"); |
| 7482 | |
| 7483 | /* configure ht_capab based on channel width */ |
| 7484 | if (dut->ap_chwidth != AP_20) { |
| 7485 | if (is_ht40plus_chan(dut->ap_channel)) |
| 7486 | ht40plus = 1; |
| 7487 | else if (is_ht40minus_chan(dut->ap_channel)) |
| 7488 | ht40minus = 1; |
| 7489 | |
| 7490 | fprintf(f, "ht_capab=%s%s\n", |
| 7491 | ht40plus ? "[HT40+]" : "", |
| 7492 | ht40minus ? "[HT40-]" : ""); |
| 7493 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7494 | } |
| 7495 | |
Sreelakshmi Konamki | b692f10 | 2016-04-26 19:47:00 +0530 | [diff] [blame] | 7496 | if ((drv == DRIVER_MAC80211 || drv == DRIVER_QNXNTO || |
| 7497 | drv == DRIVER_LINUX_WCN) && |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7498 | (dut->ap_mode == AP_11ac || dut->ap_mode == AP_11na)) { |
| 7499 | if (dut->ap_countrycode[0]) { |
| 7500 | fprintf(f, "country_code=%s\n", dut->ap_countrycode); |
| 7501 | fprintf(f, "ieee80211d=1\n"); |
| 7502 | fprintf(f, "ieee80211h=1\n"); |
| 7503 | } |
| 7504 | } |
| 7505 | |
| 7506 | fprintf(f, "interface=%s\n", ifname); |
| 7507 | if (dut->bridge) |
| 7508 | fprintf(f, "bridge=%s\n", dut->bridge); |
| 7509 | fprintf(f, "channel=%d\n", dut->ap_channel); |
| 7510 | |
| 7511 | if (sigma_hapd_ctrl) |
| 7512 | fprintf(f, "ctrl_interface=%s\n", sigma_hapd_ctrl); |
| 7513 | else |
| 7514 | fprintf(f, "ctrl_interface=/var/run/hostapd\n"); |
| 7515 | |
| 7516 | if (dut->ap_ssid[0]) |
| 7517 | fprintf(f, "ssid=%s\n", dut->ap_ssid); |
| 7518 | else |
| 7519 | fprintf(f, "ssid=QCA AP OOB\n"); |
| 7520 | if (dut->ap_bcnint) |
| 7521 | fprintf(f, "beacon_int=%d\n", dut->ap_bcnint); |
| 7522 | |
Jouni Malinen | da5f35b | 2019-03-26 00:25:53 +0200 | [diff] [blame] | 7523 | if (dut->ap_akm_values) { |
| 7524 | struct { |
| 7525 | int akm; |
| 7526 | const char *str; |
| 7527 | } akms[] = { |
| 7528 | { AKM_WPA_EAP, "WPA-EAP" }, |
| 7529 | { AKM_WPA_PSK, "WPA-PSK" }, |
| 7530 | { AKM_FT_EAP, "FT-EAP" }, |
| 7531 | { AKM_FT_PSK, "FT-PSK" }, |
| 7532 | { AKM_EAP_SHA256, "WPA-EAP-SHA256" }, |
| 7533 | { AKM_PSK_SHA256, "WPA-PSK-SHA256" }, |
| 7534 | { AKM_SAE, "SAE" }, |
| 7535 | { AKM_FT_SAE, "FT-SAE" }, |
| 7536 | { AKM_SUITE_B, "WPA-EAP-SUITE-B-192" }, |
| 7537 | { AKM_FT_SUITE_B, "FT-EAP-SHA384" }, |
| 7538 | { AKM_FILS_SHA256, "FILS-SHA256" }, |
| 7539 | { AKM_FILS_SHA384, "FILS-SHA384" }, |
| 7540 | { AKM_FT_FILS_SHA256, "FT-FILS-SHA256" }, |
| 7541 | { AKM_FT_FILS_SHA384, "FT-FILS-SHA384" }, |
| 7542 | }; |
Jouni Malinen | 8400c08 | 2019-04-26 13:26:07 +0300 | [diff] [blame] | 7543 | int first = 1; |
| 7544 | unsigned int i; |
Jouni Malinen | da5f35b | 2019-03-26 00:25:53 +0200 | [diff] [blame] | 7545 | |
| 7546 | fprintf(f, "wpa_key_mgmt="); |
| 7547 | for (i = 0; i < ARRAY_SIZE(akms); i++) { |
| 7548 | if (dut->ap_akm_values & (1 << akms[i].akm)) { |
| 7549 | fprintf(f, "%s%s", first ? "" : " ", |
| 7550 | akms[i].str); |
| 7551 | first = 0; |
| 7552 | } |
| 7553 | } |
| 7554 | fprintf(f, "\n"); |
| 7555 | /* TODO: mixed mode and WPAv1 only */ |
| 7556 | fprintf(f, "wpa=2\n"); |
| 7557 | fprintf(f, "wpa_pairwise=%s\n", |
| 7558 | hostapd_cipher_name(dut->ap_cipher)); |
| 7559 | if (dut->ap_group_cipher != AP_NO_GROUP_CIPHER_SET) |
| 7560 | fprintf(f, "group_cipher=%s\n", |
| 7561 | hostapd_cipher_name(dut->ap_group_cipher)); |
Jouni Malinen | 3e25541 | 2019-03-28 22:04:08 +0200 | [diff] [blame] | 7562 | if ((dut->ap_akm_values & |
| 7563 | ((1 << AKM_SAE) | (1 << AKM_FT_SAE))) && |
| 7564 | !(dut->ap_akm_values & |
| 7565 | ((1 << AKM_WPA_PSK) | (1 << AKM_FT_PSK))) && |
Jouni Malinen | da5f35b | 2019-03-26 00:25:53 +0200 | [diff] [blame] | 7566 | dut->ap_passphrase[0]) |
| 7567 | fprintf(f, "sae_password=%s\n", dut->ap_passphrase); |
| 7568 | else if (!dut->ap_passphrase[0] && dut->ap_psk[0]) |
| 7569 | fprintf(f, "wpa_psk=%s", dut->ap_psk); |
| 7570 | else if (dut->ap_passphrase[0]) |
| 7571 | fprintf(f, "wpa_passphrase=%s\n", dut->ap_passphrase); |
Jouni Malinen | 10ed9e7 | 2019-03-28 03:00:11 +0200 | [diff] [blame] | 7572 | if (dut->ap_akm_values & ((1 << AKM_WPA_EAP) | |
Jouni Malinen | e5393c3 | 2019-06-20 01:34:34 +0300 | [diff] [blame] | 7573 | (1 << AKM_FT_EAP) | |
Jouni Malinen | 10ed9e7 | 2019-03-28 03:00:11 +0200 | [diff] [blame] | 7574 | (1 << AKM_EAP_SHA256) | |
| 7575 | (1 << AKM_SUITE_B) | |
| 7576 | (1 << AKM_FT_SUITE_B) | |
| 7577 | (1 << AKM_FILS_SHA256) | |
| 7578 | (1 << AKM_FILS_SHA384) | |
| 7579 | (1 << AKM_FT_FILS_SHA256) | |
| 7580 | (1 << AKM_FT_FILS_SHA384))) { |
| 7581 | fprintf(f, "ieee8021x=1\n"); |
| 7582 | fprintf(f, "auth_server_addr=%s\n", |
| 7583 | dut->ap_radius_ipaddr); |
| 7584 | if (dut->ap_radius_port) |
| 7585 | fprintf(f, "auth_server_port=%d\n", |
| 7586 | dut->ap_radius_port); |
| 7587 | fprintf(f, "auth_server_shared_secret=%s\n", |
| 7588 | dut->ap_radius_password); |
| 7589 | } |
Jouni Malinen | da5f35b | 2019-03-26 00:25:53 +0200 | [diff] [blame] | 7590 | goto skip_key_mgmt; |
| 7591 | } |
| 7592 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7593 | switch (dut->ap_key_mgmt) { |
| 7594 | case AP_OPEN: |
| 7595 | if (dut->ap_cipher == AP_WEP) |
| 7596 | fprintf(f, "wep_key0=%s\n", dut->ap_wepkey); |
| 7597 | break; |
| 7598 | case AP_WPA2_PSK: |
| 7599 | case AP_WPA2_PSK_MIXED: |
| 7600 | case AP_WPA_PSK: |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 7601 | case AP_WPA2_SAE: |
| 7602 | case AP_WPA2_PSK_SAE: |
Jouni Malinen | 6be21c8 | 2018-08-01 18:47:24 +0300 | [diff] [blame] | 7603 | case AP_WPA2_PSK_SHA256: |
| 7604 | case AP_WPA2_FT_PSK: |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 7605 | if (dut->ap_key_mgmt == AP_WPA2_PSK || |
| 7606 | dut->ap_key_mgmt == AP_WPA2_SAE || |
Jouni Malinen | 6be21c8 | 2018-08-01 18:47:24 +0300 | [diff] [blame] | 7607 | dut->ap_key_mgmt == AP_WPA2_PSK_SAE || |
| 7608 | dut->ap_key_mgmt == AP_WPA2_PSK_SHA256 || |
| 7609 | dut->ap_key_mgmt == AP_WPA2_FT_PSK) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7610 | fprintf(f, "wpa=2\n"); |
| 7611 | else if (dut->ap_key_mgmt == AP_WPA2_PSK_MIXED) |
| 7612 | fprintf(f, "wpa=3\n"); |
| 7613 | else |
| 7614 | fprintf(f, "wpa=1\n"); |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 7615 | if (dut->ap_key_mgmt == AP_WPA2_SAE) |
| 7616 | key_mgmt = "SAE"; |
| 7617 | else if (dut->ap_key_mgmt == AP_WPA2_PSK_SAE) |
| 7618 | key_mgmt = "WPA-PSK SAE"; |
| 7619 | else |
| 7620 | key_mgmt = "WPA-PSK"; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7621 | switch (dut->ap_pmf) { |
| 7622 | case AP_PMF_DISABLED: |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 7623 | fprintf(f, "wpa_key_mgmt=%s%s\n", key_mgmt, |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7624 | dut->ap_add_sha256 ? " WPA-PSK-SHA256" : ""); |
| 7625 | break; |
| 7626 | case AP_PMF_OPTIONAL: |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 7627 | fprintf(f, "wpa_key_mgmt=%s%s\n", key_mgmt, |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7628 | dut->ap_add_sha256 ? " WPA-PSK-SHA256" : ""); |
| 7629 | break; |
| 7630 | case AP_PMF_REQUIRED: |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 7631 | if (dut->ap_key_mgmt == AP_WPA2_SAE) |
| 7632 | key_mgmt = "SAE"; |
| 7633 | else if (dut->ap_key_mgmt == AP_WPA2_PSK_SAE) |
| 7634 | key_mgmt = "WPA-PSK-SHA256 SAE"; |
| 7635 | else |
| 7636 | key_mgmt = "WPA-PSK-SHA256"; |
| 7637 | fprintf(f, "wpa_key_mgmt=%s\n", key_mgmt); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7638 | break; |
| 7639 | } |
Jouni Malinen | 6be21c8 | 2018-08-01 18:47:24 +0300 | [diff] [blame] | 7640 | if (dut->ap_key_mgmt == AP_WPA2_PSK_SHA256) |
| 7641 | fprintf(f, "wpa_key_mgmt=WPA-PSK-SHA256\n"); |
| 7642 | else if (dut->ap_key_mgmt == AP_WPA2_FT_PSK) |
| 7643 | fprintf(f, "wpa_key_mgmt=FT-PSK\n"); |
Jouni Malinen | 2ba2449 | 2017-11-17 12:43:59 +0200 | [diff] [blame] | 7644 | fprintf(f, "wpa_pairwise=%s\n", |
| 7645 | hostapd_cipher_name(dut->ap_cipher)); |
| 7646 | if (dut->ap_group_cipher != AP_NO_GROUP_CIPHER_SET) |
| 7647 | fprintf(f, "group_cipher=%s\n", |
| 7648 | hostapd_cipher_name(dut->ap_group_cipher)); |
Jouni Malinen | 2126f42 | 2017-10-11 23:24:33 +0300 | [diff] [blame] | 7649 | if (dut->ap_key_mgmt == AP_WPA2_SAE) |
| 7650 | fprintf(f, "sae_password=%s\n", dut->ap_passphrase); |
Jouni Malinen | 6337062 | 2017-11-18 17:47:13 +0200 | [diff] [blame] | 7651 | else if (!dut->ap_passphrase[0] && dut->ap_psk[0]) |
| 7652 | fprintf(f, "wpa_psk=%s", dut->ap_psk); |
Jouni Malinen | 2126f42 | 2017-10-11 23:24:33 +0300 | [diff] [blame] | 7653 | else |
| 7654 | fprintf(f, "wpa_passphrase=%s\n", dut->ap_passphrase); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7655 | break; |
| 7656 | case AP_WPA2_EAP: |
| 7657 | case AP_WPA2_EAP_MIXED: |
| 7658 | case AP_WPA_EAP: |
Jouni Malinen | 4cf699f | 2018-06-19 00:46:27 +0300 | [diff] [blame] | 7659 | case AP_WPA2_EAP_OSEN: |
Jouni Malinen | 6be21c8 | 2018-08-01 18:47:24 +0300 | [diff] [blame] | 7660 | case AP_WPA2_EAP_SHA256: |
| 7661 | case AP_WPA2_FT_EAP: |
| 7662 | case AP_WPA2_ENT_FT_EAP: |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7663 | fprintf(f, "ieee8021x=1\n"); |
Jouni Malinen | 4cf699f | 2018-06-19 00:46:27 +0300 | [diff] [blame] | 7664 | if (dut->ap_key_mgmt == AP_WPA2_EAP || |
Jouni Malinen | 6be21c8 | 2018-08-01 18:47:24 +0300 | [diff] [blame] | 7665 | dut->ap_key_mgmt == AP_WPA2_EAP_OSEN || |
| 7666 | dut->ap_key_mgmt == AP_WPA2_EAP_SHA256 || |
| 7667 | dut->ap_key_mgmt == AP_WPA2_FT_EAP || |
| 7668 | dut->ap_key_mgmt == AP_WPA2_ENT_FT_EAP) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7669 | fprintf(f, "wpa=2\n"); |
| 7670 | else if (dut->ap_key_mgmt == AP_WPA2_EAP_MIXED) |
| 7671 | fprintf(f, "wpa=3\n"); |
| 7672 | else |
| 7673 | fprintf(f, "wpa=1\n"); |
| 7674 | switch (dut->ap_pmf) { |
| 7675 | case AP_PMF_DISABLED: |
| 7676 | fprintf(f, "wpa_key_mgmt=WPA-EAP%s\n", |
| 7677 | dut->ap_add_sha256 ? " WPA-EAP-SHA256" : ""); |
| 7678 | break; |
| 7679 | case AP_PMF_OPTIONAL: |
Jouni Malinen | 4cf699f | 2018-06-19 00:46:27 +0300 | [diff] [blame] | 7680 | fprintf(f, "wpa_key_mgmt=WPA-EAP%s%s\n", |
| 7681 | dut->ap_add_sha256 ? " WPA-EAP-SHA256" : "", |
| 7682 | dut->ap_key_mgmt == AP_WPA2_EAP_OSEN ? " OSEN" : |
| 7683 | ""); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7684 | break; |
| 7685 | case AP_PMF_REQUIRED: |
Jouni Malinen | 4cf699f | 2018-06-19 00:46:27 +0300 | [diff] [blame] | 7686 | fprintf(f, "wpa_key_mgmt=WPA-EAP-SHA256%s\n", |
| 7687 | dut->ap_key_mgmt == AP_WPA2_EAP_OSEN ? " OSEN" : |
| 7688 | ""); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7689 | break; |
| 7690 | } |
Jouni Malinen | 6be21c8 | 2018-08-01 18:47:24 +0300 | [diff] [blame] | 7691 | if (dut->ap_key_mgmt == AP_WPA2_EAP_SHA256) |
| 7692 | fprintf(f, "wpa_key_mgmt=WPA-EAP-SHA256\n"); |
| 7693 | else if (dut->ap_key_mgmt == AP_WPA2_FT_EAP) |
| 7694 | fprintf(f, "wpa_key_mgmt=FT-EAP\n"); |
| 7695 | else if (dut->ap_key_mgmt == AP_WPA2_ENT_FT_EAP) |
| 7696 | fprintf(f, "wpa_key_mgmt=FT-EAP WPA-EAP\n"); |
Jouni Malinen | 2ba2449 | 2017-11-17 12:43:59 +0200 | [diff] [blame] | 7697 | fprintf(f, "wpa_pairwise=%s\n", |
| 7698 | hostapd_cipher_name(dut->ap_cipher)); |
| 7699 | if (dut->ap_group_cipher != AP_NO_GROUP_CIPHER_SET) |
| 7700 | fprintf(f, "group_cipher=%s\n", |
| 7701 | hostapd_cipher_name(dut->ap_group_cipher)); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7702 | fprintf(f, "auth_server_addr=%s\n", dut->ap_radius_ipaddr); |
| 7703 | if (dut->ap_radius_port) |
| 7704 | fprintf(f, "auth_server_port=%d\n", |
| 7705 | dut->ap_radius_port); |
| 7706 | fprintf(f, "auth_server_shared_secret=%s\n", |
| 7707 | dut->ap_radius_password); |
Jouni Malinen | 1a2bc99 | 2018-06-22 11:50:59 +0300 | [diff] [blame] | 7708 | if (dut->program == PROGRAM_HS2_R3) { |
| 7709 | fprintf(f, "radius_das_port=3799\n"); |
| 7710 | fprintf(f, "radius_das_client=0.0.0.0 %s\n", |
| 7711 | dut->ap_radius_password); |
| 7712 | fprintf(f, "radius_das_require_event_timestamp=1\n"); |
| 7713 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7714 | break; |
Jouni Malinen | ad395a2 | 2017-09-01 21:13:46 +0300 | [diff] [blame] | 7715 | case AP_SUITEB: |
| 7716 | fprintf(f, "ieee8021x=1\n"); |
| 7717 | fprintf(f, "wpa=2\n"); |
| 7718 | fprintf(f, "wpa_key_mgmt=WPA-EAP-SUITE-B-192\n"); |
Jouni Malinen | 3d633da | 2017-09-14 22:19:21 +0300 | [diff] [blame] | 7719 | fprintf(f, "wpa_pairwise=%s\n", |
| 7720 | hostapd_cipher_name(dut->ap_cipher)); |
Jouni Malinen | 2ba2449 | 2017-11-17 12:43:59 +0200 | [diff] [blame] | 7721 | if (dut->ap_group_cipher != AP_NO_GROUP_CIPHER_SET) |
| 7722 | fprintf(f, "group_cipher=%s\n", |
| 7723 | hostapd_cipher_name(dut->ap_group_cipher)); |
Jouni Malinen | 3d633da | 2017-09-14 22:19:21 +0300 | [diff] [blame] | 7724 | if (dut->ap_group_mgmt_cipher != AP_NO_GROUP_MGMT_CIPHER_SET) |
| 7725 | fprintf(f, "group_mgmt_cipher=%s\n", |
| 7726 | hostapd_group_mgmt_cipher_name( |
| 7727 | dut->ap_group_mgmt_cipher)); |
Jouni Malinen | ad395a2 | 2017-09-01 21:13:46 +0300 | [diff] [blame] | 7728 | fprintf(f, "auth_server_addr=%s\n", dut->ap_radius_ipaddr); |
| 7729 | if (dut->ap_radius_port) |
| 7730 | fprintf(f, "auth_server_port=%d\n", |
| 7731 | dut->ap_radius_port); |
| 7732 | fprintf(f, "auth_server_shared_secret=%s\n", |
| 7733 | dut->ap_radius_password); |
| 7734 | break; |
Jouni Malinen | 147b3c3 | 2017-10-09 16:51:54 +0300 | [diff] [blame] | 7735 | case AP_WPA2_OWE: |
| 7736 | fprintf(f, "wpa=2\n"); |
| 7737 | fprintf(f, "wpa_key_mgmt=OWE\n"); |
| 7738 | fprintf(f, "rsn_pairwise=%s\n", |
| 7739 | hostapd_cipher_name(dut->ap_cipher)); |
Jouni Malinen | 72461d4 | 2017-10-10 19:20:45 +0300 | [diff] [blame] | 7740 | if (dut->ap_sae_groups) |
| 7741 | fprintf(f, "owe_groups=%s\n", dut->ap_sae_groups); |
Jouni Malinen | 147b3c3 | 2017-10-09 16:51:54 +0300 | [diff] [blame] | 7742 | break; |
Jouni Malinen | c2b9121 | 2018-09-12 02:26:39 +0300 | [diff] [blame] | 7743 | case AP_OSEN: |
| 7744 | fprintf(f, "osen=1\n"); |
| 7745 | fprintf(f, "disable_dgaf=1\n"); |
| 7746 | fprintf(f, "wpa_pairwise=%s\n", |
| 7747 | hostapd_cipher_name(dut->ap_cipher)); |
| 7748 | if (dut->ap_group_cipher != AP_NO_GROUP_CIPHER_SET) |
| 7749 | fprintf(f, "group_cipher=%s\n", |
| 7750 | hostapd_cipher_name(dut->ap_group_cipher)); |
| 7751 | fprintf(f, "auth_server_addr=%s\n", dut->ap_radius_ipaddr); |
| 7752 | if (dut->ap_radius_port) |
| 7753 | fprintf(f, "auth_server_port=%d\n", |
| 7754 | dut->ap_radius_port); |
| 7755 | fprintf(f, "auth_server_shared_secret=%s\n", |
| 7756 | dut->ap_radius_password); |
| 7757 | break; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7758 | } |
Jouni Malinen | da5f35b | 2019-03-26 00:25:53 +0200 | [diff] [blame] | 7759 | skip_key_mgmt: |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7760 | |
Jouni Malinen | 09550de | 2019-03-26 00:24:11 +0200 | [diff] [blame] | 7761 | if (dut->ap_sae_passwords) { |
| 7762 | char *tmp, *pos, *end, *id; |
| 7763 | |
| 7764 | tmp = strdup(dut->ap_sae_passwords); |
| 7765 | if (!tmp) { |
| 7766 | fclose(f); |
| 7767 | return ERROR_SEND_STATUS; |
| 7768 | } |
| 7769 | |
| 7770 | pos = tmp; |
| 7771 | while (*pos) { |
| 7772 | end = strchr(pos, ';'); |
| 7773 | if (end) |
| 7774 | *end = '\0'; |
| 7775 | id = strchr(pos, ':'); |
| 7776 | if (id) |
| 7777 | *id++ = '\0'; |
| 7778 | |
| 7779 | fprintf(f, "sae_password=%s%s%s\n", |
| 7780 | pos, id ? "|id=" : "", id ? id : ""); |
| 7781 | if (!end) |
| 7782 | break; |
| 7783 | pos = end + 1; |
| 7784 | } |
| 7785 | |
| 7786 | free(tmp); |
| 7787 | } |
| 7788 | |
Anilkumar Kolli | f0fd599 | 2017-02-23 12:54:01 +0530 | [diff] [blame] | 7789 | if (dut->ap_rsn_preauth) |
| 7790 | fprintf(f, "rsn_preauth=1\n"); |
| 7791 | |
Jouni Malinen | b75c532 | 2019-06-14 01:47:43 +0300 | [diff] [blame] | 7792 | if (dut->ap_pmksa && dut->ap_pmksa_caching) |
| 7793 | fprintf(f, "disable_pmksa_caching=1\n"); |
| 7794 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7795 | switch (dut->ap_pmf) { |
| 7796 | case AP_PMF_DISABLED: |
| 7797 | break; |
| 7798 | case AP_PMF_OPTIONAL: |
| 7799 | fprintf(f, "ieee80211w=1\n"); |
Jouni Malinen | da5f35b | 2019-03-26 00:25:53 +0200 | [diff] [blame] | 7800 | if (dut->ap_key_mgmt == AP_WPA2_PSK_SAE || |
| 7801 | (dut->ap_akm_values & (AKM_SAE | AKM_WPA_PSK)) == |
| 7802 | (AKM_SAE | AKM_WPA_PSK)) |
Jouni Malinen | 1287cd7 | 2018-01-04 17:08:01 +0200 | [diff] [blame] | 7803 | fprintf(f, "sae_require_mfp=1\n"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7804 | break; |
| 7805 | case AP_PMF_REQUIRED: |
| 7806 | fprintf(f, "ieee80211w=2\n"); |
| 7807 | break; |
| 7808 | } |
| 7809 | |
Jouni Malinen | 10ed9e7 | 2019-03-28 03:00:11 +0200 | [diff] [blame] | 7810 | if (dut->ap_pmf != AP_PMF_DISABLED && |
| 7811 | dut->ap_group_mgmt_cipher != AP_NO_GROUP_MGMT_CIPHER_SET) |
| 7812 | fprintf(f, "group_mgmt_cipher=%s\n", |
| 7813 | hostapd_group_mgmt_cipher_name( |
| 7814 | dut->ap_group_mgmt_cipher)); |
| 7815 | |
Jouni Malinen | 6be21c8 | 2018-08-01 18:47:24 +0300 | [diff] [blame] | 7816 | if (ap_ft_enabled(dut)) { |
| 7817 | unsigned char own_addr[ETH_ALEN]; |
| 7818 | |
| 7819 | fprintf(f, "mobility_domain=%s\n", dut->ap_mobility_domain); |
Jouni Malinen | 9f94331 | 2019-08-19 23:49:16 +0300 | [diff] [blame] | 7820 | 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] | 7821 | if (get_hwaddr(ifname, own_addr) < 0) { |
| 7822 | memset(own_addr, 0, ETH_ALEN); |
| 7823 | own_addr[0] = 0x02; |
| 7824 | } |
Jouni Malinen | c967446 | 2019-03-26 02:40:19 +0200 | [diff] [blame] | 7825 | fprintf(f, |
| 7826 | "nas_identifier=%02x%02x%02x%02x%02x%02x.nas.example.com\n", |
| 7827 | own_addr[0], own_addr[1], own_addr[2], |
| 7828 | own_addr[3], own_addr[4], own_addr[5]); |
Jouni Malinen | 6be21c8 | 2018-08-01 18:47:24 +0300 | [diff] [blame] | 7829 | fprintf(f, "r1_key_holder=%02x%02x%02x%02x%02x%02x\n", |
| 7830 | own_addr[0], own_addr[1], own_addr[2], |
| 7831 | own_addr[3], own_addr[4], own_addr[5]); |
| 7832 | fprintf(f, "ft_psk_generate_local=1\n"); |
| 7833 | fprintf(f, "pmk_r1_push=0\n"); |
| 7834 | fprintf(f, |
Jouni Malinen | 69222a6 | 2019-03-26 01:56:20 +0200 | [diff] [blame] | 7835 | "r0kh=ff:ff:ff:ff:ff:ff * 00112233445566778899aabbccddeeff00112233445566778899aabbccddeeff\n"); |
Jouni Malinen | 6be21c8 | 2018-08-01 18:47:24 +0300 | [diff] [blame] | 7836 | fprintf(f, |
Jouni Malinen | 69222a6 | 2019-03-26 01:56:20 +0200 | [diff] [blame] | 7837 | "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] | 7838 | } |
| 7839 | |
Jouni Malinen | 3c367e8 | 2017-06-23 17:01:47 +0300 | [diff] [blame] | 7840 | if (dut->rsne_override) |
| 7841 | fprintf(f, "own_ie_override=%s\n", dut->rsne_override); |
Jouni Malinen | 7960e3a | 2019-12-07 17:04:35 +0200 | [diff] [blame] | 7842 | if (dut->rsnxe_override_eapol) |
| 7843 | fprintf(f, "rsnxe_override_eapol=%s\n", |
| 7844 | dut->rsnxe_override_eapol); |
Jouni Malinen | 3c367e8 | 2017-06-23 17:01:47 +0300 | [diff] [blame] | 7845 | |
Jouni Malinen | 6814313 | 2017-09-02 02:34:08 +0300 | [diff] [blame] | 7846 | if (dut->sae_commit_override) |
| 7847 | fprintf(f, "sae_commit_override=%s\n", |
| 7848 | dut->sae_commit_override); |
| 7849 | |
Jouni Malinen | ed670f4 | 2017-08-31 01:39:28 +0300 | [diff] [blame] | 7850 | if (dut->ap_sae_groups) |
| 7851 | fprintf(f, "sae_groups=%s\n", dut->ap_sae_groups); |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 7852 | |
Jouni Malinen | 11e5521 | 2019-11-22 21:46:59 +0200 | [diff] [blame] | 7853 | if (dut->sae_pwe != SAE_PWE_DEFAULT || dut->sae_h2e_default) { |
| 7854 | const char *sae_pwe = NULL; |
| 7855 | |
| 7856 | if (dut->sae_pwe == SAE_PWE_LOOP) |
| 7857 | sae_pwe = "0"; |
| 7858 | else if (dut->sae_pwe == SAE_PWE_H2E) |
| 7859 | sae_pwe = "1"; |
| 7860 | else if (dut->sae_h2e_default) |
| 7861 | sae_pwe = "2"; |
| 7862 | if (sae_pwe) |
| 7863 | fprintf(f, "sae_pwe=%s", sae_pwe); |
| 7864 | } |
| 7865 | |
Jouni Malinen | 2f524ce | 2017-08-31 01:43:29 +0300 | [diff] [blame] | 7866 | if (dut->sae_anti_clogging_threshold >= 0) |
| 7867 | fprintf(f, "sae_anti_clogging_threshold=%d\n", |
| 7868 | dut->sae_anti_clogging_threshold); |
Jouni Malinen | b347db0 | 2017-09-02 01:36:03 +0300 | [diff] [blame] | 7869 | if (dut->sae_reflection) |
| 7870 | fprintf(f, "sae_reflection_attack=1\n"); |
Jouni Malinen | 3c740ab | 2019-10-10 15:55:11 +0300 | [diff] [blame] | 7871 | if (dut->sae_confirm_immediate) |
| 7872 | fprintf(f, "sae_confirm_immediate=1\n"); |
Jouni Malinen | 2f524ce | 2017-08-31 01:43:29 +0300 | [diff] [blame] | 7873 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7874 | if (dut->ap_p2p_mgmt) |
| 7875 | fprintf(f, "manage_p2p=1\n"); |
| 7876 | |
| 7877 | if (dut->ap_tdls_prohibit || dut->ap_l2tif) |
| 7878 | fprintf(f, "tdls_prohibit=1\n"); |
| 7879 | if (dut->ap_tdls_prohibit_chswitch || dut->ap_l2tif) |
| 7880 | fprintf(f, "tdls_prohibit_chan_switch=1\n"); |
| 7881 | if (dut->ap_p2p_cross_connect >= 0) { |
| 7882 | fprintf(f, "manage_p2p=1\n" |
| 7883 | "allow_cross_connection=%d\n", |
| 7884 | dut->ap_p2p_cross_connect); |
| 7885 | } |
| 7886 | |
Jouni Malinen | 4d479c9 | 2018-11-06 00:43:36 +0200 | [diff] [blame] | 7887 | if (dut->ap_l2tif || dut->ap_proxy_arp || |
| 7888 | dut->ap_key_mgmt == AP_WPA2_EAP_OSEN) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7889 | if (!dut->bridge) { |
| 7890 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 7891 | "Bridge must be configured. Run with -b <brname>."); |
| 7892 | fclose(f); |
| 7893 | return -2; |
| 7894 | } |
| 7895 | fprintf(f, "ap_isolate=1\n"); |
| 7896 | } |
| 7897 | |
| 7898 | if (dut->ap_proxy_arp) |
| 7899 | fprintf(f, "proxy_arp=1\n"); |
| 7900 | |
Pradeep Reddy POTTETI | 0d3db63 | 2016-03-11 15:21:11 +0530 | [diff] [blame] | 7901 | if (dut->ap_wme) |
| 7902 | fprintf(f, "wmm_enabled=1\n"); |
| 7903 | |
Mohammed Shafi Shajakhan | 02e3b82 | 2017-02-23 04:15:02 +0530 | [diff] [blame] | 7904 | if (dut->ap_wmmps == AP_WMMPS_ON) |
| 7905 | fprintf(f, "uapsd_advertisement_enabled=1\n"); |
| 7906 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7907 | if (dut->ap_hs2) { |
| 7908 | if (dut->ap_bss_load) { |
| 7909 | char *bss_load; |
| 7910 | |
| 7911 | switch (dut->ap_bss_load) { |
| 7912 | case -1: |
| 7913 | bss_load = "bss_load_update_period=10"; |
| 7914 | break; |
| 7915 | case 1: |
| 7916 | /* STA count: 1, CU: 50, AAC: 65535 */ |
| 7917 | bss_load = "bss_load_test=1:50:65535"; |
| 7918 | break; |
| 7919 | case 2: |
| 7920 | /* STA count: 1, CU: 200, AAC: 65535 */ |
| 7921 | bss_load = "bss_load_test=1:200:65535"; |
| 7922 | break; |
| 7923 | case 3: |
| 7924 | /* STA count: 1, CU: 75, AAC: 65535 */ |
| 7925 | bss_load = "bss_load_test=1:75:65535"; |
| 7926 | break; |
| 7927 | default: |
| 7928 | bss_load = NULL; |
| 7929 | break; |
| 7930 | } |
| 7931 | |
| 7932 | if (!bss_load) { |
| 7933 | fclose(f); |
| 7934 | return -2; |
| 7935 | } |
| 7936 | fprintf(f, "%s\n", bss_load); |
| 7937 | } |
| 7938 | |
| 7939 | if (append_hostapd_conf_hs2(dut, f)) { |
| 7940 | fclose(f); |
| 7941 | return -2; |
| 7942 | } |
| 7943 | } |
| 7944 | |
| 7945 | if (dut->ap_interworking && append_hostapd_conf_interworking(dut, f)) { |
| 7946 | fclose(f); |
| 7947 | return -2; |
| 7948 | } |
| 7949 | |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 7950 | if (dut->ap_hs2 && strlen(dut->ap_tag_ssid[0])) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7951 | unsigned char bssid[6]; |
| 7952 | char ifname2[50]; |
| 7953 | |
Pradeep Reddy POTTETI | 673d85c | 2016-07-26 19:08:07 +0530 | [diff] [blame] | 7954 | if (get_hwaddr(ifname, bssid)) { |
| 7955 | fclose(f); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7956 | return -2; |
Pradeep Reddy POTTETI | 673d85c | 2016-07-26 19:08:07 +0530 | [diff] [blame] | 7957 | } |
Jouni Malinen | b37f0bc | 2018-05-03 18:29:55 +0300 | [diff] [blame] | 7958 | if (bssid[0] & 0x02) |
| 7959 | bssid[5] ^= 0x01; |
| 7960 | else |
| 7961 | bssid[0] |= 0x02; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7962 | |
| 7963 | snprintf(ifname2, sizeof(ifname2), "%s_1", ifname); |
Jouni Malinen | 10b47b2 | 2018-06-07 23:28:07 +0300 | [diff] [blame] | 7964 | fprintf(f, "bss=%s\n", ifname2); |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 7965 | fprintf(f, "ssid=%s\n", dut->ap_tag_ssid[0]); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7966 | if (dut->bridge) |
| 7967 | fprintf(f, "bridge=%s\n", dut->bridge); |
Liangwei Dong | 911cb14 | 2019-01-10 14:35:55 +0800 | [diff] [blame] | 7968 | |
| 7969 | if (drv == DRIVER_LINUX_WCN) |
| 7970 | fprintf(f, "use_driver_iface_addr=1\n"); |
| 7971 | else |
| 7972 | fprintf(f, "bssid=%02x:%02x:%02x:%02x:%02x:%02x\n", |
| 7973 | bssid[0], bssid[1], bssid[2], bssid[3], |
| 7974 | bssid[4], bssid[5]); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7975 | |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 7976 | if (dut->ap_tag_key_mgmt[0] == AP2_OSEN) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7977 | fprintf(f, "osen=1\n"); |
Sriram R | 61f5d95 | 2018-06-07 17:47:07 +0530 | [diff] [blame] | 7978 | /* Disable DGAF for OSEN BSS */ |
| 7979 | fprintf(f, "disable_dgaf=1\n"); |
Jouni Malinen | dbbc2c4 | 2018-11-14 23:55:41 +0200 | [diff] [blame] | 7980 | fprintf(f, "ap_isolate=1\n"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7981 | if (strlen(dut->ap2_radius_ipaddr)) |
| 7982 | fprintf(f, "auth_server_addr=%s\n", |
| 7983 | dut->ap2_radius_ipaddr); |
| 7984 | if (dut->ap2_radius_port) |
| 7985 | fprintf(f, "auth_server_port=%d\n", |
| 7986 | dut->ap2_radius_port); |
| 7987 | if (strlen(dut->ap2_radius_password)) |
| 7988 | fprintf(f, "auth_server_shared_secret=%s\n", |
| 7989 | dut->ap2_radius_password); |
Jouni Malinen | dbbc2c4 | 2018-11-14 23:55:41 +0200 | [diff] [blame] | 7990 | |
| 7991 | set_ebtables_forward_drop(dut, ifname, ifname2); |
| 7992 | } else if (dut->ap2_osu) { |
| 7993 | fprintf(f, "ap_isolate=1\n"); |
| 7994 | set_ebtables_forward_drop(dut, ifname, ifname2); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7995 | } |
| 7996 | |
| 7997 | if (dut->ap2_proxy_arp) { |
| 7998 | if (!dut->bridge) { |
| 7999 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 8000 | "Bridge must be configured. Run with -b <brname>."); |
| 8001 | fclose(f); |
| 8002 | return -2; |
| 8003 | } |
| 8004 | fprintf(f, "ap_isolate=1\n"); |
| 8005 | fprintf(f, "proxy_arp=1\n"); |
| 8006 | |
| 8007 | if (set_ebtables_proxy_arp(dut, "FORWARD", ifname2) || |
| 8008 | set_ebtables_proxy_arp(dut, "OUTPUT", ifname2)) { |
| 8009 | fclose(f); |
| 8010 | return -2; |
| 8011 | } |
| 8012 | |
| 8013 | } |
| 8014 | } |
| 8015 | |
| 8016 | if (dut->program == PROGRAM_WPS) { |
Alexei Avshalom Lazar | d303e47 | 2018-12-23 16:49:49 +0200 | [diff] [blame] | 8017 | /* 60G WPS tests requires wps_state of 2 (configured) */ |
| 8018 | int wps_state = is_60g_sigma_dut(dut) ? 2 : 1; |
| 8019 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8020 | fprintf(f, "eap_server=1\n" |
Alexei Avshalom Lazar | d303e47 | 2018-12-23 16:49:49 +0200 | [diff] [blame] | 8021 | "wps_state=%d\n" |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8022 | "device_name=QCA AP\n" |
| 8023 | "manufacturer=QCA\n" |
| 8024 | "device_type=6-0050F204-1\n" |
Alexei Avshalom Lazar | d303e47 | 2018-12-23 16:49:49 +0200 | [diff] [blame] | 8025 | "config_methods=label virtual_display %s" |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8026 | "virtual_push_button keypad%s\n" |
| 8027 | "ap_pin=12345670\n" |
| 8028 | "friendly_name=QCA Access Point\n" |
| 8029 | "upnp_iface=%s\n", |
Alexei Avshalom Lazar | d303e47 | 2018-12-23 16:49:49 +0200 | [diff] [blame] | 8030 | wps_state, |
| 8031 | is_60g_sigma_dut(dut) ? "physical_display " : "", |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8032 | dut->ap_wpsnfc ? " nfc_interface ext_nfc_token" : "", |
| 8033 | dut->bridge ? dut->bridge : ifname); |
Alexei Avshalom Lazar | 33f700c | 2018-12-18 16:00:39 +0200 | [diff] [blame] | 8034 | if (dut->wsc_fragment) { |
| 8035 | fprintf(f, "device_name=%s\n" |
| 8036 | "manufacturer=%s\n" |
| 8037 | "model_name=%s\n" |
| 8038 | "model_number=%s\n" |
| 8039 | "serial_number=%s\n", |
| 8040 | WPS_LONG_DEVICE_NAME, |
| 8041 | WPS_LONG_MANUFACTURER, |
| 8042 | WPS_LONG_MODEL_NAME, |
| 8043 | WPS_LONG_MODEL_NUMBER, |
| 8044 | WPS_LONG_SERIAL_NUMBER); |
| 8045 | } else { |
| 8046 | fprintf(f, "device_name=QCA AP\n" |
| 8047 | "manufacturer=QCA\n"); |
| 8048 | } |
Alexei Avshalom Lazar | 2eccf4d | 2019-01-31 10:03:59 +0200 | [diff] [blame] | 8049 | if (dut->eap_fragment) |
| 8050 | fprintf(f, "fragment_size=128\n"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8051 | } |
| 8052 | |
Jouni Malinen | ba4f2d4 | 2019-10-04 16:13:41 +0300 | [diff] [blame] | 8053 | if (dut->ap_dpp_conf_addr && dut->ap_dpp_conf_pkhash) |
| 8054 | fprintf(f, "dpp_controller=ipaddr=%s pkhash=%s\n", |
| 8055 | dut->ap_dpp_conf_addr, dut->ap_dpp_conf_pkhash); |
| 8056 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8057 | if (dut->program == PROGRAM_VHT) { |
| 8058 | int vht_oper_centr_freq_idx; |
| 8059 | |
| 8060 | if (check_channel(dut->ap_channel) < 0) { |
| 8061 | send_resp(dut, conn, SIGMA_INVALID, |
| 8062 | "errorCode,Invalid channel"); |
Pradeep Reddy POTTETI | 673d85c | 2016-07-26 19:08:07 +0530 | [diff] [blame] | 8063 | fclose(f); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8064 | return 0; |
| 8065 | } |
| 8066 | |
| 8067 | switch (dut->ap_chwidth) { |
| 8068 | case AP_20: |
| 8069 | dut->ap_vht_chwidth = AP_20_40_VHT_OPER_CHWIDTH; |
| 8070 | vht_oper_centr_freq_idx = |
| 8071 | get_oper_centr_freq_seq_idx(20, |
| 8072 | dut->ap_channel); |
| 8073 | break; |
| 8074 | case AP_40: |
| 8075 | dut->ap_vht_chwidth = AP_20_40_VHT_OPER_CHWIDTH; |
| 8076 | vht_oper_centr_freq_idx = |
| 8077 | get_oper_centr_freq_seq_idx(40, |
| 8078 | dut->ap_channel); |
| 8079 | break; |
| 8080 | case AP_80: |
| 8081 | dut->ap_vht_chwidth = AP_80_VHT_OPER_CHWIDTH; |
| 8082 | vht_oper_centr_freq_idx = |
| 8083 | get_oper_centr_freq_seq_idx(80, |
| 8084 | dut->ap_channel); |
| 8085 | break; |
| 8086 | case AP_160: |
| 8087 | dut->ap_vht_chwidth = AP_160_VHT_OPER_CHWIDTH; |
| 8088 | vht_oper_centr_freq_idx = |
| 8089 | get_oper_centr_freq_seq_idx(160, |
| 8090 | dut->ap_channel); |
| 8091 | break; |
| 8092 | default: |
| 8093 | dut->ap_vht_chwidth = VHT_DEFAULT_OPER_CHWIDTH; |
| 8094 | vht_oper_centr_freq_idx = |
| 8095 | get_oper_centr_freq_seq_idx(80, |
| 8096 | dut->ap_channel); |
| 8097 | break; |
| 8098 | } |
| 8099 | fprintf(f, "vht_oper_centr_freq_seg0_idx=%d\n", |
| 8100 | vht_oper_centr_freq_idx); |
| 8101 | fprintf(f, "vht_oper_chwidth=%d\n", dut->ap_vht_chwidth); |
| 8102 | |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 8103 | if (dut->ap_sgi80 || dut->ap_txBF || |
| 8104 | dut->ap_ldpc != VALUE_NOT_SET || |
Mohammed Shafi Shajakhan | f3e68d9 | 2016-06-02 20:10:57 +0530 | [diff] [blame] | 8105 | dut->ap_tx_stbc || dut->ap_mu_txBF) { |
| 8106 | fprintf(f, "vht_capab=%s%s%s%s%s\n", |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8107 | dut->ap_sgi80 ? "[SHORT-GI-80]" : "", |
Mohammed Shafi Shajakhan | c039ce3 | 2016-06-02 20:10:58 +0530 | [diff] [blame] | 8108 | dut->ap_txBF ? |
Tamizh chelvam | 8312f6d | 2016-06-02 20:10:59 +0530 | [diff] [blame] | 8109 | "[SU-BEAMFORMER][SU-BEAMFORMEE][BF-ANTENNA-2][SOUNDING-DIMENSION-2]" : "", |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 8110 | (dut->ap_ldpc == VALUE_ENABLED) ? |
| 8111 | "[RXLDPC]" : "", |
Mohammed Shafi Shajakhan | f3e68d9 | 2016-06-02 20:10:57 +0530 | [diff] [blame] | 8112 | dut->ap_tx_stbc ? "[TX-STBC-2BY1]" : "", |
| 8113 | dut->ap_mu_txBF ? "[MU-BEAMFORMER]" : ""); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8114 | } |
| 8115 | } |
| 8116 | |
Jouni Malinen | 6d1d739 | 2017-10-10 20:35:29 +0300 | [diff] [blame] | 8117 | if (dut->ap_key_mgmt == AP_WPA2_OWE && dut->ap_tag_ssid[0][0] && |
| 8118 | dut->ap_tag_key_mgmt[0] == AP2_OPEN) { |
| 8119 | /* OWE transition mode */ |
| 8120 | unsigned char bssid[6]; |
| 8121 | char ifname2[50]; |
| 8122 | unsigned long val; |
| 8123 | FILE *f2; |
| 8124 | |
| 8125 | snprintf(ifname2, sizeof(ifname2), "%s_1", ifname); |
| 8126 | |
| 8127 | fprintf(f, "owe_transition_ifname=%s\n", ifname2); |
| 8128 | val = 0x12345678; /* default to something */ |
| 8129 | f2 = fopen("/dev/urandom", "r"); |
| 8130 | if (f2) { |
| 8131 | if (fread(&val, 1, sizeof(val), f2) != sizeof(val)) { |
| 8132 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 8133 | "Could not read /dev/urandom"); |
| 8134 | } |
| 8135 | fclose(f2); |
| 8136 | } |
| 8137 | fprintf(f, "ssid=owe-%lx\n", val); |
Liangwei Dong | d3b87da | 2019-01-09 20:10:20 +0800 | [diff] [blame] | 8138 | fprintf(f, "ignore_broadcast_ssid=1\n"); |
Jouni Malinen | 6d1d739 | 2017-10-10 20:35:29 +0300 | [diff] [blame] | 8139 | |
| 8140 | if (get_hwaddr(ifname, bssid)) { |
| 8141 | fclose(f); |
| 8142 | return -2; |
| 8143 | } |
| 8144 | if (bssid[0] & 0x02) |
| 8145 | bssid[5] ^= 0x01; |
| 8146 | else |
| 8147 | bssid[0] |= 0x02; |
| 8148 | |
| 8149 | fprintf(f, "bss=%s\n", ifname2); |
| 8150 | fprintf(f, "ssid=%s\n", dut->ap_ssid); |
| 8151 | if (dut->bridge) |
| 8152 | fprintf(f, "bridge=%s\n", dut->bridge); |
Liangwei Dong | 911cb14 | 2019-01-10 14:35:55 +0800 | [diff] [blame] | 8153 | if (drv == DRIVER_LINUX_WCN) |
| 8154 | fprintf(f, "use_driver_iface_addr=1\n"); |
| 8155 | else |
| 8156 | fprintf(f, "bssid=%02x:%02x:%02x:%02x:%02x:%02x\n", |
| 8157 | bssid[0], bssid[1], bssid[2], bssid[3], |
| 8158 | bssid[4], bssid[5]); |
Jouni Malinen | 6d1d739 | 2017-10-10 20:35:29 +0300 | [diff] [blame] | 8159 | fprintf(f, "owe_transition_ifname=%s\n", ifname); |
| 8160 | } |
| 8161 | |
Jouni Malinen | 353ba8b | 2018-01-10 17:04:12 +0200 | [diff] [blame] | 8162 | if (dut->ap_key_mgmt == AP_OPEN && |
| 8163 | dut->ap_tag_key_mgmt[0] == AP2_WPA2_OWE) { |
| 8164 | /* OWE transition mode */ |
| 8165 | unsigned char bssid[6]; |
| 8166 | char ifname2[50]; |
| 8167 | unsigned long val; |
| 8168 | FILE *f2; |
| 8169 | |
| 8170 | snprintf(ifname2, sizeof(ifname2), "%s_1", ifname); |
| 8171 | |
| 8172 | fprintf(f, "owe_transition_ifname=%s\n", ifname2); |
| 8173 | fprintf(f, "ssid=%s\n", dut->ap_ssid); |
| 8174 | |
| 8175 | if (get_hwaddr(ifname, bssid)) { |
| 8176 | fclose(f); |
| 8177 | return -2; |
| 8178 | } |
| 8179 | if (bssid[0] & 0x02) |
| 8180 | bssid[5] ^= 0x01; |
| 8181 | else |
| 8182 | bssid[0] |= 0x02; |
| 8183 | |
| 8184 | fprintf(f, "bss=%s\n", ifname2); |
| 8185 | val = 0x12345678; /* default to something */ |
| 8186 | f2 = fopen("/dev/urandom", "r"); |
| 8187 | if (f2) { |
| 8188 | if (fread(&val, 1, sizeof(val), f2) != sizeof(val)) { |
| 8189 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 8190 | "Could not read /dev/urandom"); |
| 8191 | } |
| 8192 | fclose(f2); |
| 8193 | } |
| 8194 | fprintf(f, "ssid=owe-%lx\n", val); |
| 8195 | if (dut->bridge) |
| 8196 | fprintf(f, "bridge=%s\n", dut->bridge); |
Liangwei Dong | 911cb14 | 2019-01-10 14:35:55 +0800 | [diff] [blame] | 8197 | if (drv == DRIVER_LINUX_WCN) |
| 8198 | fprintf(f, "use_driver_iface_addr=1\n"); |
| 8199 | else |
| 8200 | fprintf(f, "bssid=%02x:%02x:%02x:%02x:%02x:%02x\n", |
| 8201 | bssid[0], bssid[1], bssid[2], bssid[3], |
| 8202 | bssid[4], bssid[5]); |
Jouni Malinen | 353ba8b | 2018-01-10 17:04:12 +0200 | [diff] [blame] | 8203 | fprintf(f, "owe_transition_ifname=%s\n", ifname); |
| 8204 | fprintf(f, "wpa=2\n"); |
| 8205 | fprintf(f, "wpa_key_mgmt=OWE\n"); |
| 8206 | fprintf(f, "rsn_pairwise=CCMP\n"); |
| 8207 | fprintf(f, "ieee80211w=2\n"); |
Liangwei Dong | d3b87da | 2019-01-09 20:10:20 +0800 | [diff] [blame] | 8208 | fprintf(f, "ignore_broadcast_ssid=1\n"); |
Jouni Malinen | 353ba8b | 2018-01-10 17:04:12 +0200 | [diff] [blame] | 8209 | if (dut->ap_sae_groups) |
| 8210 | fprintf(f, "owe_groups=%s\n", dut->ap_sae_groups); |
| 8211 | } |
| 8212 | |
Ankita Bajaj | 0d5825b | 2017-10-25 16:20:17 +0530 | [diff] [blame] | 8213 | if (dut->program == PROGRAM_OCE) { |
| 8214 | fprintf(f, "oce=%d\n", |
| 8215 | dut->dev_role == DEVROLE_STA_CFON ? 2 : 1); |
| 8216 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8217 | fclose(f); |
Jouni Malinen | d6bf1b4 | 2017-06-23 17:51:01 +0300 | [diff] [blame] | 8218 | if (dut->use_hostapd_pid_file) |
| 8219 | kill_hostapd_process_pid(dut); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8220 | #ifdef __QNXNTO__ |
| 8221 | if (system("slay hostapd") == 0) |
| 8222 | #else /* __QNXNTO__ */ |
Jouni Malinen | d6bf1b4 | 2017-06-23 17:51:01 +0300 | [diff] [blame] | 8223 | if (!dut->use_hostapd_pid_file && |
| 8224 | (kill_process(dut, "(hostapd)", 1, SIGTERM) == 0 || |
| 8225 | system("killall hostapd") == 0)) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8226 | #endif /* __QNXNTO__ */ |
| 8227 | { |
| 8228 | int i; |
| 8229 | /* Wait some time to allow hostapd to complete cleanup before |
| 8230 | * starting a new process */ |
| 8231 | for (i = 0; i < 10; i++) { |
| 8232 | usleep(500000); |
| 8233 | #ifdef __QNXNTO__ |
| 8234 | if (system("pidin | grep hostapd") != 0) |
| 8235 | break; |
| 8236 | #else /* __QNXNTO__ */ |
| 8237 | if (system("pidof hostapd") != 0) |
| 8238 | break; |
| 8239 | #endif /* __QNXNTO__ */ |
| 8240 | } |
| 8241 | } |
Jouni Malinen | d86e582 | 2017-08-29 03:55:32 +0300 | [diff] [blame] | 8242 | dut->hostapd_running = 0; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8243 | |
Pradeep Reddy POTTETI | a076c30 | 2016-05-16 13:36:07 +0530 | [diff] [blame] | 8244 | #ifdef ANDROID |
| 8245 | /* Set proper conf file permissions so that hostapd process |
| 8246 | * can access it. |
| 8247 | */ |
| 8248 | if (chmod(SIGMA_TMPDIR "/sigma_dut-ap.conf", |
| 8249 | S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP) < 0) |
| 8250 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 8251 | "Error changing permissions"); |
| 8252 | |
Srinivas Dasari | a1deeaa | 2018-06-18 22:54:04 +0530 | [diff] [blame] | 8253 | gr = getgrnam("wifi"); |
| 8254 | if (!gr || |
| 8255 | 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] | 8256 | sigma_dut_print(dut, DUT_MSG_ERROR, "Error changing groupid"); |
| 8257 | #endif /* ANDROID */ |
| 8258 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8259 | if (drv == DRIVER_QNXNTO) { |
| 8260 | snprintf(buf, sizeof(buf), |
Pradeep Reddy POTTETI | bf4a974 | 2016-02-04 12:32:30 +0530 | [diff] [blame] | 8261 | "hostapd -B %s%s %s%s" SIGMA_TMPDIR |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8262 | "/sigma_dut-ap.conf", |
| 8263 | dut->hostapd_debug_log ? "-ddKt -f " : "", |
| 8264 | dut->hostapd_debug_log ? dut->hostapd_debug_log : "", |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8265 | dut->hostapd_entropy_log ? " -e" : "", |
| 8266 | dut->hostapd_entropy_log ? dut->hostapd_entropy_log : |
| 8267 | ""); |
| 8268 | } else { |
| 8269 | /* |
| 8270 | * It looks like a monitor interface can cause some issues for |
| 8271 | * beaconing, so remove it (if injection was used) before |
| 8272 | * starting hostapd. |
| 8273 | */ |
| 8274 | if (if_nametoindex("sigmadut") > 0 && |
| 8275 | system("iw dev sigmadut del") != 0) |
| 8276 | sigma_dut_print(dut, DUT_MSG_ERROR, "Failed to remove " |
| 8277 | "monitor interface"); |
| 8278 | |
Jouni Malinen | d6bf1b4 | 2017-06-23 17:51:01 +0300 | [diff] [blame] | 8279 | snprintf(path, sizeof(path), "%shostapd", |
| 8280 | file_exists("hostapd") ? "./" : ""); |
| 8281 | 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] | 8282 | "/sigma_dut-ap.conf", |
Jouni Malinen | d6bf1b4 | 2017-06-23 17:51:01 +0300 | [diff] [blame] | 8283 | dut->hostapd_bin ? dut->hostapd_bin : path, |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8284 | dut->hostapd_debug_log ? " -ddKt -f" : "", |
| 8285 | dut->hostapd_debug_log ? dut->hostapd_debug_log : "", |
| 8286 | dut->hostapd_entropy_log ? " -e" : "", |
| 8287 | dut->hostapd_entropy_log ? dut->hostapd_entropy_log : |
Jouni Malinen | d6bf1b4 | 2017-06-23 17:51:01 +0300 | [diff] [blame] | 8288 | "", |
| 8289 | dut->use_hostapd_pid_file ? |
| 8290 | " -P " SIGMA_DUT_HOSTAPD_PID_FILE : ""); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8291 | } |
| 8292 | |
Jouni Malinen | d6bf1b4 | 2017-06-23 17:51:01 +0300 | [diff] [blame] | 8293 | sigma_dut_print(dut, DUT_MSG_DEBUG, "hostapd command: %s", buf); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8294 | if (system(buf) != 0) { |
| 8295 | send_resp(dut, conn, SIGMA_ERROR, |
| 8296 | "errorCode,Failed to start hostapd"); |
| 8297 | return 0; |
| 8298 | } |
| 8299 | |
| 8300 | /* allow some time for hostapd to start before returning success */ |
| 8301 | usleep(500000); |
| 8302 | if (run_hostapd_cli(dut, "ping") != 0) { |
| 8303 | send_resp(dut, conn, SIGMA_ERROR, |
| 8304 | "errorCode,Failed to talk to hostapd"); |
| 8305 | return 0; |
| 8306 | } |
| 8307 | |
Pradeep Reddy Potteti | 923a9b3 | 2017-06-14 12:18:59 +0530 | [diff] [blame] | 8308 | if (drv == DRIVER_LINUX_WCN) { |
Hu Wang | f5cb900 | 2019-08-21 14:18:57 +0800 | [diff] [blame] | 8309 | const char *ifname_ptr = ifname; |
| 8310 | |
| 8311 | if ((dut->ap_key_mgmt == AP_OPEN && |
| 8312 | dut->ap_tag_key_mgmt[0] == AP2_WPA2_OWE) || |
| 8313 | (dut->ap_key_mgmt == AP_WPA2_OWE && |
| 8314 | dut->ap_tag_ssid[0][0] && |
| 8315 | dut->ap_tag_key_mgmt[0] == AP2_OPEN)) { |
| 8316 | /* OWE transition mode */ |
| 8317 | if (dut->bridge) |
| 8318 | ifname_ptr = dut->bridge; |
| 8319 | } |
| 8320 | |
| 8321 | sigma_dut_print(dut, DUT_MSG_INFO, |
| 8322 | "setting ip addr %s mask %s ifname %s", |
| 8323 | ap_inet_addr, ap_inet_mask, ifname_ptr); |
Pradeep Reddy Potteti | 923a9b3 | 2017-06-14 12:18:59 +0530 | [diff] [blame] | 8324 | snprintf(buf, sizeof(buf), "ifconfig %s %s netmask %s up", |
Hu Wang | f5cb900 | 2019-08-21 14:18:57 +0800 | [diff] [blame] | 8325 | ifname_ptr, ap_inet_addr, ap_inet_mask); |
Pradeep Reddy Potteti | 923a9b3 | 2017-06-14 12:18:59 +0530 | [diff] [blame] | 8326 | if (system(buf) != 0) { |
| 8327 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 8328 | "Failed to initialize the interface"); |
| 8329 | return -1; |
| 8330 | } |
| 8331 | } |
| 8332 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8333 | if (dut->ap_l2tif) { |
| 8334 | snprintf(path, sizeof(path), |
| 8335 | "/sys/class/net/%s/brport/hairpin_mode", |
| 8336 | ifname); |
| 8337 | if (!file_exists(path)) { |
| 8338 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 8339 | "%s must be binded to the bridge for L2TIF", |
| 8340 | ifname); |
| 8341 | return -2; |
| 8342 | } |
| 8343 | |
| 8344 | snprintf(buf, sizeof(buf), "echo 1 > %s", path); |
| 8345 | if (system(buf) != 0) { |
| 8346 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 8347 | "Failed to enable hairpin_mode for L2TIF"); |
| 8348 | return -2; |
| 8349 | } |
| 8350 | |
| 8351 | snprintf(buf, sizeof(buf), "ebtables -P FORWARD ACCEPT"); |
| 8352 | if (system(buf) != 0) { |
| 8353 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 8354 | "Failed to set ebtables rules, RULE-9"); |
| 8355 | return -2; |
| 8356 | } |
| 8357 | |
| 8358 | snprintf(buf, sizeof(buf), |
| 8359 | "ebtables -A FORWARD -p IPv4 --ip-proto icmp -i %s -j DROP", |
| 8360 | ifname); |
| 8361 | if (system(buf) != 0) { |
| 8362 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 8363 | "Failed to set ebtables rules, RULE-11"); |
| 8364 | return -2; |
| 8365 | } |
| 8366 | } |
| 8367 | |
| 8368 | if (dut->ap_proxy_arp) { |
| 8369 | if (dut->ap_dgaf_disable) { |
| 8370 | if (set_ebtables_disable_dgaf(dut, "FORWARD", ifname) || |
| 8371 | set_ebtables_disable_dgaf(dut, "OUTPUT", ifname)) |
| 8372 | return -2; |
| 8373 | } else { |
| 8374 | if (set_ebtables_proxy_arp(dut, "FORWARD", ifname) || |
| 8375 | set_ebtables_proxy_arp(dut, "OUTPUT", ifname)) |
| 8376 | return -2; |
| 8377 | } |
| 8378 | |
| 8379 | /* For 4.5-(c) */ |
| 8380 | snprintf(buf, sizeof(buf), |
| 8381 | "ebtables -A FORWARD -p ARP --arp-opcode 2 -i %s -j DROP", |
| 8382 | ifname); |
| 8383 | if (system(buf) != 0) { |
| 8384 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 8385 | "Failed to set ebtables rules, RULE-10"); |
| 8386 | return -2; |
| 8387 | } |
| 8388 | } |
| 8389 | |
| 8390 | if (dut->ap_tdls_prohibit || dut->ap_l2tif) { |
| 8391 | /* Drop TDLS frames */ |
| 8392 | snprintf(buf, sizeof(buf), |
| 8393 | "ebtables -A FORWARD -p 0x890d -i %s -j DROP", ifname); |
| 8394 | if (system(buf) != 0) { |
| 8395 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 8396 | "Failed to set ebtables rules, RULE-13"); |
| 8397 | return -2; |
| 8398 | } |
| 8399 | } |
| 8400 | |
| 8401 | if (dut->ap_fake_pkhash && |
| 8402 | run_hostapd_cli(dut, "set wps_corrupt_pkhash 1") != 0) { |
| 8403 | send_resp(dut, conn, SIGMA_ERROR, |
| 8404 | "errorCode,Could not enable FakePubKey"); |
| 8405 | return 0; |
| 8406 | } |
| 8407 | |
Alexei Avshalom Lazar | bc180dc | 2018-12-18 16:01:14 +0200 | [diff] [blame] | 8408 | if (dut->program == PROGRAM_60GHZ && dut->ap_num_ese_allocs > 0) { |
| 8409 | /* wait extra time for AP to start */ |
| 8410 | sleep(2); |
| 8411 | if (ap_set_60g_ese(dut, dut->ap_num_ese_allocs, |
| 8412 | dut->ap_ese_allocs)) { |
| 8413 | send_resp(dut, conn, SIGMA_ERROR, |
| 8414 | "errorCode,Could not set ExtSch"); |
| 8415 | return 0; |
| 8416 | } |
Alexei Avshalom Lazar | aad97b0 | 2018-12-18 16:01:23 +0200 | [diff] [blame] | 8417 | if (dut->ap_fixed_rate) { |
| 8418 | sigma_dut_print(dut, DUT_MSG_DEBUG, |
| 8419 | "forcing TX MCS index %d", |
| 8420 | dut->ap_mcs); |
| 8421 | if (ap_set_force_mcs(dut, 1, dut->ap_mcs)) { |
| 8422 | send_resp(dut, conn, SIGMA_ERROR, |
| 8423 | "errorCode,Could not force MCS"); |
| 8424 | return -2; |
| 8425 | } |
| 8426 | } |
Alexei Avshalom Lazar | bc180dc | 2018-12-18 16:01:14 +0200 | [diff] [blame] | 8427 | } |
| 8428 | |
Alexei Avshalom Lazar | 744ae8a | 2019-01-31 17:26:46 +0200 | [diff] [blame] | 8429 | if (dut->wps_forced_version) { |
| 8430 | snprintf(buf, sizeof(buf), "SET wps_version_number %d", |
| 8431 | dut->wps_forced_version); |
| 8432 | if (hapd_command(ifname, buf) < 0) { |
| 8433 | send_resp(dut, conn, SIGMA_ERROR, |
| 8434 | "errorCode,Fail to set wps_version_number"); |
| 8435 | return STATUS_SENT; |
| 8436 | } |
| 8437 | } |
| 8438 | |
Jouni Malinen | d86e582 | 2017-08-29 03:55:32 +0300 | [diff] [blame] | 8439 | dut->hostapd_running = 1; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8440 | return 1; |
| 8441 | } |
| 8442 | |
| 8443 | |
Pradeep Reddy POTTETI | eff4611 | 2016-10-13 17:22:03 +0530 | [diff] [blame] | 8444 | static int parse_qos_params(struct sigma_dut *dut, struct sigma_conn *conn, |
| 8445 | struct qos_params *qos, const char *cwmin, |
| 8446 | const char *cwmax, const char *aifs, |
| 8447 | const char *txop, const char *acm) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8448 | { |
Pradeep Reddy POTTETI | eff4611 | 2016-10-13 17:22:03 +0530 | [diff] [blame] | 8449 | int val; |
| 8450 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8451 | if (cwmin) { |
| 8452 | qos->ac = 1; |
Pradeep Reddy POTTETI | eff4611 | 2016-10-13 17:22:03 +0530 | [diff] [blame] | 8453 | val = atoi(cwmin); |
| 8454 | if (val < 0 || val > 15) { |
| 8455 | send_resp(dut, conn, SIGMA_INVALID, |
| 8456 | "errorCode,Invalid cwMin"); |
| 8457 | return 0; |
| 8458 | } |
| 8459 | qos->cwmin = val; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8460 | } |
| 8461 | |
| 8462 | if (cwmax) { |
| 8463 | qos->ac = 1; |
Pradeep Reddy POTTETI | eff4611 | 2016-10-13 17:22:03 +0530 | [diff] [blame] | 8464 | val = atoi(cwmax); |
| 8465 | if (val < 0 || val > 15) { |
| 8466 | send_resp(dut, conn, SIGMA_INVALID, |
| 8467 | "errorCode,Invalid cwMax"); |
| 8468 | return 0; |
| 8469 | } |
| 8470 | qos->cwmax = val; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8471 | } |
| 8472 | |
| 8473 | if (aifs) { |
| 8474 | qos->ac = 1; |
Pradeep Reddy POTTETI | eff4611 | 2016-10-13 17:22:03 +0530 | [diff] [blame] | 8475 | val = atoi(aifs); |
| 8476 | if (val < 1 || val > 255) { |
| 8477 | send_resp(dut, conn, SIGMA_INVALID, |
| 8478 | "errorCode,Invalid AIFS"); |
| 8479 | return 0; |
| 8480 | } |
| 8481 | qos->aifs = val; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8482 | } |
| 8483 | |
| 8484 | if (txop) { |
| 8485 | qos->ac = 1; |
Pradeep Reddy POTTETI | eff4611 | 2016-10-13 17:22:03 +0530 | [diff] [blame] | 8486 | val = atoi(txop); |
| 8487 | if (val < 0 || val > 0xffff) { |
| 8488 | send_resp(dut, conn, SIGMA_INVALID, |
| 8489 | "errorCode,Invalid txop"); |
| 8490 | return 0; |
| 8491 | } |
| 8492 | qos->txop = val * 32; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8493 | } |
| 8494 | |
| 8495 | if (acm) { |
| 8496 | qos->ac = 1; |
| 8497 | qos->acm = strcasecmp(acm, "on") == 0; |
| 8498 | } |
Pradeep Reddy POTTETI | eff4611 | 2016-10-13 17:22:03 +0530 | [diff] [blame] | 8499 | |
| 8500 | return 1; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8501 | } |
| 8502 | |
| 8503 | |
Jouni Malinen | f722271 | 2019-06-13 01:50:21 +0300 | [diff] [blame] | 8504 | static enum sigma_cmd_result cmd_ap_set_apqos(struct sigma_dut *dut, |
| 8505 | struct sigma_conn *conn, |
| 8506 | struct sigma_cmd *cmd) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8507 | { |
| 8508 | /* TXOP: The values provided here for VHT5G only */ |
Pradeep Reddy POTTETI | eff4611 | 2016-10-13 17:22:03 +0530 | [diff] [blame] | 8509 | if (!parse_qos_params(dut, conn, &dut->ap_qos[AP_AC_VO], |
| 8510 | get_param(cmd, "cwmin_VO"), |
| 8511 | get_param(cmd, "cwmax_VO"), |
| 8512 | get_param(cmd, "AIFS_VO"), |
| 8513 | get_param(cmd, "TXOP_VO"), |
| 8514 | get_param(cmd, "ACM_VO")) || |
| 8515 | !parse_qos_params(dut, conn, &dut->ap_qos[AP_AC_VI], |
| 8516 | get_param(cmd, "cwmin_VI"), |
| 8517 | get_param(cmd, "cwmax_VI"), |
| 8518 | get_param(cmd, "AIFS_VI"), |
| 8519 | get_param(cmd, "TXOP_VI"), |
| 8520 | get_param(cmd, "ACM_VI")) || |
| 8521 | !parse_qos_params(dut, conn, &dut->ap_qos[AP_AC_BE], |
| 8522 | get_param(cmd, "cwmin_BE"), |
| 8523 | get_param(cmd, "cwmax_BE"), |
| 8524 | get_param(cmd, "AIFS_BE"), |
| 8525 | get_param(cmd, "TXOP_BE"), |
| 8526 | get_param(cmd, "ACM_BE")) || |
| 8527 | !parse_qos_params(dut, conn, &dut->ap_qos[AP_AC_BK], |
| 8528 | get_param(cmd, "cwmin_BK"), |
| 8529 | get_param(cmd, "cwmax_BK"), |
| 8530 | get_param(cmd, "AIFS_BK"), |
| 8531 | get_param(cmd, "TXOP_BK"), |
| 8532 | get_param(cmd, "ACM_BK"))) |
| 8533 | return 0; |
| 8534 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8535 | return 1; |
| 8536 | } |
| 8537 | |
| 8538 | |
Jouni Malinen | f722271 | 2019-06-13 01:50:21 +0300 | [diff] [blame] | 8539 | static enum sigma_cmd_result cmd_ap_set_staqos(struct sigma_dut *dut, |
| 8540 | struct sigma_conn *conn, |
| 8541 | struct sigma_cmd *cmd) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8542 | { |
Pradeep Reddy POTTETI | eff4611 | 2016-10-13 17:22:03 +0530 | [diff] [blame] | 8543 | if (!parse_qos_params(dut, conn, &dut->ap_sta_qos[AP_AC_VO], |
| 8544 | get_param(cmd, "cwmin_VO"), |
| 8545 | get_param(cmd, "cwmax_VO"), |
| 8546 | get_param(cmd, "AIFS_VO"), |
| 8547 | get_param(cmd, "TXOP_VO"), |
| 8548 | get_param(cmd, "ACM_VO")) || |
| 8549 | !parse_qos_params(dut, conn, &dut->ap_sta_qos[AP_AC_VI], |
| 8550 | get_param(cmd, "cwmin_VI"), |
| 8551 | get_param(cmd, "cwmax_VI"), |
| 8552 | get_param(cmd, "AIFS_VI"), |
| 8553 | get_param(cmd, "TXOP_VI"), |
| 8554 | get_param(cmd, "ACM_VI")) || |
| 8555 | !parse_qos_params(dut, conn, &dut->ap_sta_qos[AP_AC_BE], |
| 8556 | get_param(cmd, "cwmin_BE"), |
| 8557 | get_param(cmd, "cwmax_BE"), |
| 8558 | get_param(cmd, "AIFS_BE"), |
| 8559 | get_param(cmd, "TXOP_BE"), |
| 8560 | get_param(cmd, "ACM_BE")) || |
| 8561 | !parse_qos_params(dut, conn, &dut->ap_sta_qos[AP_AC_BK], |
| 8562 | get_param(cmd, "cwmin_BK"), |
| 8563 | get_param(cmd, "cwmax_BK"), |
| 8564 | get_param(cmd, "AIFS_BK"), |
| 8565 | get_param(cmd, "TXOP_BK"), |
| 8566 | get_param(cmd, "ACM_BK"))) |
| 8567 | return 0; |
| 8568 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8569 | return 1; |
| 8570 | } |
| 8571 | |
| 8572 | |
| 8573 | static void cmd_ath_ap_hs2_reset(struct sigma_dut *dut) |
| 8574 | { |
| 8575 | unsigned char bssid[6]; |
| 8576 | char buf[100]; |
| 8577 | run_system(dut, "cfg -a AP_SSID=\"Hotspot 2.0\""); |
| 8578 | run_system(dut, "cfg -a AP_PRIMARY_CH=1"); |
| 8579 | run_system(dut, "cfg -a AP_SECMODE=WPA"); |
| 8580 | run_system(dut, "cfg -a AP_SECFILE=EAP"); |
| 8581 | run_system(dut, "cfg -a AP_WPA=2"); |
| 8582 | run_system(dut, "cfg -a AP_CYPHER=CCMP"); |
| 8583 | run_system(dut, "cfg -a AP_HOTSPOT=1"); |
| 8584 | run_system(dut, "cfg -a AP_HOTSPOT_ANT=2"); |
| 8585 | run_system(dut, "cfg -a AP_HOTSPOT_INTERNET=0"); |
| 8586 | run_system(dut, "cfg -a AP_HOTSPOT_VENUEGROUP=2"); |
| 8587 | run_system(dut, "cfg -a AP_HOTSPOT_VENUETYPE=8"); |
| 8588 | run_system(dut, "cfg -a AP_HOTSPOT_ROAMINGCONSORTIUM=506f9a"); |
| 8589 | run_system(dut, "cfg -a AP_HOTSPOT_ROAMINGCONSORTIUM2=001bc504bd"); |
| 8590 | if (!get_hwaddr("ath0", bssid)) { |
| 8591 | snprintf(buf, sizeof(buf), "cfg -a AP_HOTSPOT_HESSID=" |
| 8592 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 8593 | bssid[0], bssid[1], bssid[2], bssid[3], |
| 8594 | bssid[4], bssid[5]); |
| 8595 | run_system(dut, buf); |
| 8596 | snprintf(dut->ap_hessid, sizeof(dut->ap_hessid), |
| 8597 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 8598 | bssid[0], bssid[1], bssid[2], bssid[3], |
| 8599 | bssid[4], bssid[5]); |
| 8600 | } else { |
| 8601 | if (!get_hwaddr("wifi0", bssid)) { |
| 8602 | snprintf(buf, sizeof(buf), "cfg -a AP_HOTSPOT_HESSID=" |
| 8603 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 8604 | bssid[0], bssid[1], bssid[2], bssid[3], |
| 8605 | bssid[4], bssid[5]); |
| 8606 | run_system(dut, buf); |
| 8607 | snprintf(dut->ap_hessid, sizeof(dut->ap_hessid), |
| 8608 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 8609 | bssid[0], bssid[1], bssid[2], bssid[3], |
| 8610 | bssid[4], bssid[5]); |
| 8611 | } else { |
| 8612 | /* load the driver and try again */ |
| 8613 | run_system(dut, "/etc/rc.d/rc.wlan up"); |
| 8614 | |
| 8615 | if (!get_hwaddr("wifi0", bssid)) { |
| 8616 | snprintf(buf, sizeof(buf), |
| 8617 | "cfg -a AP_HOTSPOT_HESSID=" |
| 8618 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 8619 | bssid[0], bssid[1], bssid[2], |
| 8620 | bssid[3], bssid[4], bssid[5]); |
| 8621 | run_system(dut, buf); |
| 8622 | snprintf(dut->ap_hessid, |
| 8623 | sizeof(dut->ap_hessid), |
| 8624 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 8625 | bssid[0], bssid[1], bssid[2], |
| 8626 | bssid[3], bssid[4], bssid[5]); |
| 8627 | } |
| 8628 | } |
| 8629 | } |
| 8630 | |
| 8631 | run_system(dut, "cfg -r AP_SSID_2"); |
| 8632 | run_system(dut, "cfg -c"); |
| 8633 | /* run_system(dut, "cfg -s"); */ |
| 8634 | } |
| 8635 | |
| 8636 | |
| 8637 | static void ath_reset_vht_defaults(struct sigma_dut *dut) |
| 8638 | { |
| 8639 | run_system(dut, "cfg -x"); |
| 8640 | run_system(dut, "cfg -a AP_RADIO_ID=1"); |
| 8641 | run_system(dut, "cfg -a AP_PRIMARY_CH_2=36"); |
| 8642 | run_system(dut, "cfg -a AP_STARTMODE=standard"); |
| 8643 | run_system(dut, "cfg -a AP_CHMODE_2=11ACVHT80"); |
| 8644 | run_system(dut, "cfg -a TX_CHAINMASK_2=7"); |
| 8645 | run_system(dut, "cfg -a RX_CHAINMASK_2=7"); |
| 8646 | run_system(dut, "cfg -a ATH_countrycode=0x348"); |
| 8647 | /* NOTE: For Beeliner we have to turn off MU-MIMO */ |
| 8648 | if (system("rm /tmp/secath*") != 0) { |
| 8649 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 8650 | "Failed to remove secath file"); |
| 8651 | } |
| 8652 | } |
| 8653 | |
| 8654 | |
Jouni Malinen | f722271 | 2019-06-13 01:50:21 +0300 | [diff] [blame] | 8655 | static enum sigma_cmd_result cmd_ap_reset_default(struct sigma_dut *dut, |
| 8656 | struct sigma_conn *conn, |
| 8657 | struct sigma_cmd *cmd) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8658 | { |
Ankita Bajaj | 0d5825b | 2017-10-25 16:20:17 +0530 | [diff] [blame] | 8659 | const char *type, *program; |
Pradeep Reddy POTTETI | 83b8067 | 2016-09-02 13:01:44 +0530 | [diff] [blame] | 8660 | enum driver_type drv; |
Alexei Avshalom Lazar | 2712cc8 | 2018-12-23 16:29:14 +0200 | [diff] [blame] | 8661 | char buf[128]; |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 8662 | int i; |
| 8663 | |
| 8664 | for (i = 0; i < MAX_WLAN_TAGS - 1; i++) { |
| 8665 | /* |
| 8666 | * Reset all tagged SSIDs to NULL-string and all key management |
| 8667 | * to open. |
| 8668 | */ |
| 8669 | dut->ap_tag_ssid[i][0] = '\0'; |
| 8670 | dut->ap_tag_key_mgmt[i] = AP2_OPEN; |
| 8671 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8672 | |
Jouni Malinen | 016ae6c | 2019-11-04 17:00:01 +0200 | [diff] [blame] | 8673 | drv = get_driver_type(dut); |
Ankita Bajaj | 0d5825b | 2017-10-25 16:20:17 +0530 | [diff] [blame] | 8674 | |
| 8675 | program = get_param(cmd, "program"); |
| 8676 | if (!program) |
| 8677 | program = get_param(cmd, "prog"); |
| 8678 | dut->program = sigma_program_to_enum(program); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8679 | dut->device_type = AP_unknown; |
| 8680 | type = get_param(cmd, "type"); |
| 8681 | if (type && strcasecmp(type, "Testbed") == 0) |
| 8682 | dut->device_type = AP_testbed; |
| 8683 | if (type && strcasecmp(type, "DUT") == 0) |
| 8684 | dut->device_type = AP_dut; |
| 8685 | |
| 8686 | dut->ap_rts = 0; |
| 8687 | dut->ap_frgmnt = 0; |
| 8688 | dut->ap_bcnint = 0; |
| 8689 | dut->ap_key_mgmt = AP_OPEN; |
| 8690 | dut->ap_ssid[0] = '\0'; |
| 8691 | dut->ap_fake_pkhash = 0; |
| 8692 | memset(dut->ap_qos, 0, sizeof(dut->ap_qos)); |
| 8693 | memset(dut->ap_sta_qos, 0, sizeof(dut->ap_sta_qos)); |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 8694 | dut->ap_addba_reject = VALUE_NOT_SET; |
| 8695 | dut->ap_noack = VALUE_NOT_SET; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8696 | dut->ap_is_dual = 0; |
| 8697 | dut->ap_mode = AP_inval; |
| 8698 | dut->ap_mode_1 = AP_inval; |
| 8699 | |
| 8700 | dut->ap_allow_vht_wep = 0; |
| 8701 | dut->ap_allow_vht_tkip = 0; |
| 8702 | dut->ap_disable_protection = 0; |
| 8703 | memset(dut->ap_countrycode, 0, sizeof(dut->ap_countrycode)); |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 8704 | dut->ap_dyn_bw_sig = VALUE_NOT_SET; |
| 8705 | dut->ap_ldpc = VALUE_NOT_SET; |
| 8706 | dut->ap_sig_rts = VALUE_NOT_SET; |
| 8707 | dut->ap_rx_amsdu = VALUE_NOT_SET; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8708 | dut->ap_txBF = 0; |
Mohammed Shafi Shajakhan | 495fdb2 | 2016-06-02 20:10:56 +0530 | [diff] [blame] | 8709 | dut->ap_mu_txBF = 0; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8710 | dut->ap_chwidth = AP_AUTO; |
| 8711 | |
Sarvepalli, Rajesh Babu | 24dc7e4 | 2016-03-18 21:27:26 +0530 | [diff] [blame] | 8712 | dut->ap_rsn_preauth = 0; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8713 | dut->ap_wpsnfc = 0; |
| 8714 | dut->ap_bss_load = -1; |
| 8715 | dut->ap_p2p_cross_connect = -1; |
| 8716 | |
Pradeep Reddy POTTETI | fba27db | 2015-11-20 16:42:22 +0530 | [diff] [blame] | 8717 | dut->ap_regulatory_mode = AP_80211D_MODE_DISABLED; |
| 8718 | dut->ap_dfs_mode = AP_DFS_MODE_DISABLED; |
Pradeep Reddy Potteti | 4b0cdee | 2017-03-15 12:37:33 +0530 | [diff] [blame] | 8719 | dut->ap_chwidth_offset = SEC_CH_NO; |
Pradeep Reddy POTTETI | fba27db | 2015-11-20 16:42:22 +0530 | [diff] [blame] | 8720 | |
Adil Saeed Musthafa | 6906372 | 2017-04-10 23:13:40 -0700 | [diff] [blame] | 8721 | dut->mbo_pref_ap_cnt = 0; |
Adil Saeed Musthafa | 4ec61bd | 2017-04-10 23:13:41 -0700 | [diff] [blame] | 8722 | dut->ft_bss_mac_cnt = 0; |
priyadharshini gowthaman | 09d613e | 2017-12-20 11:43:44 -0800 | [diff] [blame] | 8723 | dut->ap_interface_5g = 0; |
| 8724 | dut->ap_interface_2g = 0; |
priyadharshini gowthaman | a3fe8c6 | 2018-01-26 15:19:41 -0800 | [diff] [blame] | 8725 | dut->ap_pmf = AP_PMF_DISABLED; |
Adil Saeed Musthafa | 6906372 | 2017-04-10 23:13:40 -0700 | [diff] [blame] | 8726 | |
Alexei Avshalom Lazar | 33f700c | 2018-12-18 16:00:39 +0200 | [diff] [blame] | 8727 | dut->wsc_fragment = 0; |
Alexei Avshalom Lazar | 2eccf4d | 2019-01-31 10:03:59 +0200 | [diff] [blame] | 8728 | dut->eap_fragment = 0; |
Alexei Avshalom Lazar | 744ae8a | 2019-01-31 17:26:46 +0200 | [diff] [blame] | 8729 | dut->wps_forced_version = 0; |
Alexei Avshalom Lazar | 33f700c | 2018-12-18 16:00:39 +0200 | [diff] [blame] | 8730 | |
Mohammed Shafi Shajakhan | 02e3b82 | 2017-02-23 04:15:02 +0530 | [diff] [blame] | 8731 | if (dut->program == PROGRAM_HT || dut->program == PROGRAM_VHT) { |
Pradeep Reddy POTTETI | 0d3db63 | 2016-03-11 15:21:11 +0530 | [diff] [blame] | 8732 | dut->ap_wme = AP_WME_ON; |
Mohammed Shafi Shajakhan | 02e3b82 | 2017-02-23 04:15:02 +0530 | [diff] [blame] | 8733 | dut->ap_wmmps = AP_WMMPS_ON; |
| 8734 | } else { |
Pradeep Reddy POTTETI | 0d3db63 | 2016-03-11 15:21:11 +0530 | [diff] [blame] | 8735 | dut->ap_wme = AP_WME_OFF; |
Mohammed Shafi Shajakhan | 02e3b82 | 2017-02-23 04:15:02 +0530 | [diff] [blame] | 8736 | dut->ap_wmmps = AP_WMMPS_OFF; |
| 8737 | } |
Pradeep Reddy POTTETI | 0d3db63 | 2016-03-11 15:21:11 +0530 | [diff] [blame] | 8738 | |
Jouni Malinen | 54a89b0 | 2018-05-01 00:16:26 +0300 | [diff] [blame] | 8739 | dut->ap_venue_url = 0; |
Jouni Malinen | f7ff42b | 2018-05-01 00:21:56 +0300 | [diff] [blame] | 8740 | dut->ap_advice_of_charge = 0; |
Jouni Malinen | ac10453 | 2018-05-01 00:27:37 +0300 | [diff] [blame] | 8741 | dut->ap_oper_icon_metadata = 0; |
Jouni Malinen | ac36714 | 2018-05-01 00:32:24 +0300 | [diff] [blame] | 8742 | dut->ap_tnc_file_name = 0; |
| 8743 | dut->ap_tnc_time_stamp = 0; |
Jouni Malinen | 54a89b0 | 2018-05-01 00:16:26 +0300 | [diff] [blame] | 8744 | |
Jouni Malinen | da5f35b | 2019-03-26 00:25:53 +0200 | [diff] [blame] | 8745 | dut->ap_akm_values = 0; |
Jouni Malinen | 09550de | 2019-03-26 00:24:11 +0200 | [diff] [blame] | 8746 | free(dut->ap_sae_passwords); |
| 8747 | dut->ap_sae_passwords = NULL; |
| 8748 | |
Adil Saeed Musthafa | 33ea287 | 2017-04-10 23:13:24 -0700 | [diff] [blame] | 8749 | if (dut->program == PROGRAM_HS2 || dut->program == PROGRAM_HS2_R2 || |
Jouni Malinen | ba63045 | 2018-06-22 11:49:59 +0300 | [diff] [blame] | 8750 | dut->program == PROGRAM_HS2_R3 || |
Adil Saeed Musthafa | 33ea287 | 2017-04-10 23:13:24 -0700 | [diff] [blame] | 8751 | dut->program == PROGRAM_IOTLP) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8752 | int i; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8753 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8754 | if (drv == DRIVER_ATHEROS) |
| 8755 | cmd_ath_ap_hs2_reset(dut); |
| 8756 | else if (drv == DRIVER_OPENWRT) |
| 8757 | cmd_owrt_ap_hs2_reset(dut); |
| 8758 | |
| 8759 | dut->ap_interworking = 1; |
| 8760 | dut->ap_access_net_type = 2; |
| 8761 | dut->ap_internet = 0; |
| 8762 | dut->ap_venue_group = 2; |
| 8763 | dut->ap_venue_type = 8; |
| 8764 | dut->ap_domain_name_list[0] = '\0'; |
| 8765 | dut->ap_hs2 = 1; |
| 8766 | snprintf(dut->ap_roaming_cons, sizeof(dut->ap_roaming_cons), |
| 8767 | "506f9a;001bc504bd"); |
| 8768 | dut->ap_l2tif = 0; |
| 8769 | dut->ap_proxy_arp = 0; |
| 8770 | if (dut->bridge) { |
| 8771 | char buf[50]; |
| 8772 | |
| 8773 | snprintf(buf, sizeof(buf), "ip neigh flush dev %s", |
| 8774 | dut->bridge); |
| 8775 | if (system(buf) != 0) { |
| 8776 | sigma_dut_print(dut, DUT_MSG_DEBUG, |
| 8777 | "%s ip neigh table flushing failed", |
| 8778 | dut->bridge); |
| 8779 | } |
| 8780 | |
| 8781 | snprintf(buf, sizeof(buf), "ebtables -F"); |
| 8782 | if (system(buf) != 0) { |
| 8783 | sigma_dut_print(dut, DUT_MSG_DEBUG, |
| 8784 | "%s ebtables flushing failed", |
| 8785 | dut->bridge); |
| 8786 | } |
| 8787 | } |
| 8788 | dut->ap_dgaf_disable = 0; |
| 8789 | dut->ap_p2p_cross_connect = 0; |
| 8790 | dut->ap_gas_cb_delay = 0; |
| 8791 | dut->ap_nai_realm_list = 0; |
| 8792 | dut->ap_oper_name = 0; |
| 8793 | dut->ap_venue_name = 0; |
| 8794 | for (i = 0; i < 10; i++) { |
| 8795 | dut->ap_plmn_mcc[i][0] = '\0'; |
| 8796 | dut->ap_plmn_mnc[i][0] = '\0'; |
| 8797 | } |
| 8798 | dut->ap_wan_metrics = 0; |
| 8799 | dut->ap_conn_capab = 0; |
| 8800 | dut->ap_ip_addr_type_avail = 0; |
| 8801 | dut->ap_net_auth_type = 0; |
| 8802 | dut->ap_oper_class = 0; |
| 8803 | dut->ap_pmf = 0; |
| 8804 | dut->ap_add_sha256 = 0; |
| 8805 | } |
| 8806 | |
Jouni Malinen | ba63045 | 2018-06-22 11:49:59 +0300 | [diff] [blame] | 8807 | if (dut->program == PROGRAM_HS2_R2 || dut->program == PROGRAM_HS2_R3 || |
| 8808 | dut->program == PROGRAM_IOTLP) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8809 | int i; |
| 8810 | const char hessid[] = "50:6f:9a:00:11:22"; |
| 8811 | |
| 8812 | memcpy(dut->ap_hessid, hessid, strlen(hessid) + 1); |
| 8813 | dut->ap_osu_ssid[0] = '\0'; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8814 | dut->ap_pmf = 1; |
| 8815 | dut->ap_osu_provider_list = 0; |
Jouni Malinen | 93a837f | 2018-11-01 17:09:22 +0200 | [diff] [blame] | 8816 | dut->ap_osu_provider_nai_list = 0; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8817 | for (i = 0; i < 10; i++) { |
| 8818 | dut->ap_osu_server_uri[i][0] = '\0'; |
| 8819 | dut->ap_osu_method[i] = 0xFF; |
| 8820 | } |
| 8821 | dut->ap_qos_map_set = 0; |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 8822 | dut->ap_tag_key_mgmt[0] = AP2_OPEN; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8823 | dut->ap2_proxy_arp = 0; |
Jouni Malinen | dbbc2c4 | 2018-11-14 23:55:41 +0200 | [diff] [blame] | 8824 | dut->ap2_osu = 0; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8825 | dut->ap_osu_icon_tag = 0; |
| 8826 | } |
| 8827 | |
| 8828 | if (dut->program == PROGRAM_VHT) { |
| 8829 | /* Set up the defaults */ |
Jouni Malinen | 0053547 | 2019-11-06 19:43:35 +0200 | [diff] [blame] | 8830 | dut->use_5g = 1; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8831 | dut->ap_mode = AP_11ac; |
| 8832 | dut->ap_channel = 36; |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 8833 | dut->ap_ampdu = VALUE_NOT_SET; |
priyadharshini gowthaman | 264d544 | 2016-02-25 15:52:22 -0800 | [diff] [blame] | 8834 | dut->ap_ndpa_frame = 1; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8835 | if (dut->device_type == AP_testbed) { |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 8836 | dut->ap_amsdu = VALUE_DISABLED; |
| 8837 | dut->ap_ldpc = VALUE_DISABLED; |
| 8838 | dut->ap_rx_amsdu = VALUE_DISABLED; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8839 | dut->ap_sgi80 = 0; |
| 8840 | } else { |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 8841 | dut->ap_amsdu = VALUE_ENABLED; |
Pradeep Reddy POTTETI | 83b8067 | 2016-09-02 13:01:44 +0530 | [diff] [blame] | 8842 | /* |
| 8843 | * As LDPC is optional, don't enable this by default |
| 8844 | * for LINUX-WCN driver. The ap_set_wireless command |
| 8845 | * can be used to enable LDPC, when needed. |
| 8846 | */ |
| 8847 | if (drv != DRIVER_LINUX_WCN) |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 8848 | dut->ap_ldpc = VALUE_ENABLED; |
| 8849 | dut->ap_rx_amsdu = VALUE_ENABLED; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8850 | dut->ap_sgi80 = 1; |
| 8851 | } |
| 8852 | dut->ap_fixed_rate = 0; |
| 8853 | dut->ap_rx_streams = 3; |
| 8854 | dut->ap_tx_streams = 3; |
| 8855 | dut->ap_vhtmcs_map = 0; |
| 8856 | dut->ap_chwidth = AP_80; |
| 8857 | dut->ap_tx_stbc = 1; |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 8858 | dut->ap_dyn_bw_sig = VALUE_ENABLED; |
Mohammed Shafi Shajakhan | bae7230 | 2016-03-02 11:56:23 +0530 | [diff] [blame] | 8859 | if (get_openwrt_driver_type() == OPENWRT_DRIVER_ATHEROS) |
| 8860 | dut->ap_dfs_mode = AP_DFS_MODE_ENABLED; |
Jouni Malinen | 016ae6c | 2019-11-04 17:00:01 +0200 | [diff] [blame] | 8861 | if (get_driver_type(dut) == DRIVER_ATHEROS) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8862 | ath_reset_vht_defaults(dut); |
| 8863 | } |
| 8864 | |
Adil Saeed Musthafa | 33ea287 | 2017-04-10 23:13:24 -0700 | [diff] [blame] | 8865 | if (dut->program == PROGRAM_IOTLP) { |
| 8866 | dut->wnm_bss_max_feature = VALUE_DISABLED; |
| 8867 | dut->wnm_bss_max_idle_time = 0; |
| 8868 | dut->wnm_bss_max_protection = VALUE_NOT_SET; |
| 8869 | dut->ap_proxy_arp = 1; |
| 8870 | } else { |
| 8871 | /* |
| 8872 | * Do not touch the BSS-MAX Idle time feature |
| 8873 | * if the program is not IOTLP. |
| 8874 | */ |
| 8875 | dut->wnm_bss_max_feature = VALUE_NOT_SET; |
| 8876 | dut->wnm_bss_max_idle_time = 0; |
| 8877 | dut->wnm_bss_max_protection = VALUE_NOT_SET; |
| 8878 | } |
| 8879 | |
priyadharshini gowthaman | a27b5b6 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 8880 | if (dut->program == PROGRAM_LOC) { |
priyadharshini gowthaman | 8e26ff4 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 8881 | dut->ap_rrm = 1; |
| 8882 | dut->ap_rtt = 1; |
| 8883 | dut->ap_lci = 0; |
| 8884 | dut->ap_val_lci[0] = '\0'; |
priyadharshini gowthaman | c2357bd | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 8885 | dut->ap_infoz[0] = '\0'; |
priyadharshini gowthaman | 8e26ff4 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 8886 | dut->ap_lcr = 0; |
| 8887 | dut->ap_val_lcr[0] = '\0'; |
| 8888 | dut->ap_neighap = 0; |
| 8889 | dut->ap_opchannel = 0; |
| 8890 | dut->ap_scan = 0; |
priyadharshini gowthaman | c2357bd | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 8891 | dut->ap_fqdn_held = 0; |
| 8892 | dut->ap_fqdn_supl = 0; |
priyadharshini gowthaman | c52fff8 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 8893 | dut->ap_interworking = 0; |
| 8894 | dut->ap_gas_cb_delay = 0; |
priyadharshini gowthaman | a27b5b6 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 8895 | dut->ap_msnt_type = 0; |
| 8896 | } |
Adil Saeed Musthafa | 4ec61bd | 2017-04-10 23:13:41 -0700 | [diff] [blame] | 8897 | dut->ap_ft_oa = 0; |
Jouni Malinen | 9f94331 | 2019-08-19 23:49:16 +0300 | [diff] [blame] | 8898 | dut->ap_ft_ds = VALUE_NOT_SET; |
Adil Saeed Musthafa | 604c826 | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 8899 | dut->ap_reg_domain = REG_DOMAIN_NOT_SET; |
Adil Saeed Musthafa | cf752fa | 2017-04-10 23:13:32 -0700 | [diff] [blame] | 8900 | dut->ap_mobility_domain[0] = '\0'; |
priyadharshini gowthaman | a27b5b6 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 8901 | |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 8902 | if (dut->program == PROGRAM_MBO) { |
| 8903 | dut->ap_mbo = 1; |
| 8904 | dut->ap_interworking = 1; |
| 8905 | dut->ap_ne_class = 0; |
| 8906 | dut->ap_ne_op_ch = 0; |
| 8907 | dut->ap_set_bssidpref = 1; |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 8908 | dut->ap_btmreq_disassoc_imnt = 0; |
| 8909 | dut->ap_btmreq_term_bit = 0; |
| 8910 | dut->ap_disassoc_timer = 0; |
| 8911 | dut->ap_btmreq_bss_term_dur = 0; |
Adil Saeed Musthafa | 16d9e63 | 2017-04-10 23:13:38 -0700 | [diff] [blame] | 8912 | dut->ap_channel = 36; |
| 8913 | dut->ap_chwidth = AP_20; |
Adil Saeed Musthafa | 023108a | 2017-04-10 23:13:37 -0700 | [diff] [blame] | 8914 | dut->ap_cell_cap_pref = 0; |
Adil Saeed Musthafa | ed5faae | 2017-04-10 23:13:36 -0700 | [diff] [blame] | 8915 | dut->ap_gas_cb_delay = 0; |
Adil Saeed Musthafa | 6906372 | 2017-04-10 23:13:40 -0700 | [diff] [blame] | 8916 | dut->mbo_self_ap_tuple.ap_ne_class = -1; |
| 8917 | dut->mbo_self_ap_tuple.ap_ne_pref = -1; /* Not set */ |
| 8918 | dut->mbo_self_ap_tuple.ap_ne_op_ch = -1; |
priyadharshini gowthaman | 94062b5 | 2017-12-20 12:33:34 -0800 | [diff] [blame] | 8919 | dut->ap_btmreq_bss_term_tsf = 0; |
priyadharshini gowthaman | 776562e | 2017-12-20 12:33:34 -0800 | [diff] [blame] | 8920 | dut->ap_assoc_delay = 0; |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 8921 | } |
| 8922 | |
priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 8923 | if (dut->program == PROGRAM_OCE) { |
| 8924 | if (dut->ap_dhcp_stop) |
| 8925 | run_system(dut, "/etc/init.d/dnsmasq start"); |
| 8926 | |
| 8927 | dut->ap_dhcp_stop = 0; |
| 8928 | dut->ap_oce = VALUE_ENABLED; |
| 8929 | dut->ap_broadcast_ssid = VALUE_ENABLED; |
| 8930 | dut->ap_fils_dscv_int = 20; |
| 8931 | dut->ap_filsdscv = VALUE_ENABLED; |
| 8932 | dut->ap_filshlp = VALUE_DISABLED; |
| 8933 | dut->ap_rnr = VALUE_DISABLED; |
| 8934 | dut->ap_nairealm[0] = '\0'; |
| 8935 | dut->ap_nairealm_int = 0; |
| 8936 | dut->ap_blechanutil = 0; |
| 8937 | dut->ap_ble_admit_cap = 0; |
| 8938 | dut->ap_esp = VALUE_ENABLED; |
| 8939 | dut->ap_datappdudura = 0; |
| 8940 | dut->ap_airtimefract = 0; |
| 8941 | dut->ap_blestacnt = 0; |
priyadharshini gowthaman | cb22e43 | 2017-12-28 15:23:31 -0800 | [diff] [blame] | 8942 | dut->ap_ul_availcap = 0; |
| 8943 | dut->ap_dl_availcap = 0; |
priyadharshini gowthaman | de81f39 | 2017-12-28 15:28:49 -0800 | [diff] [blame] | 8944 | dut->ap_akm = 0; |
| 8945 | dut->ap_add_sha256 = 0; |
| 8946 | dut->ap_add_sha384 = 0; |
priyadharshini gowthaman | 63ab848 | 2017-12-28 15:32:55 -0800 | [diff] [blame] | 8947 | dut->ap_80plus80 = 0; |
priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 8948 | } |
| 8949 | |
priyadharshini gowthaman | 350f191 | 2018-06-04 13:09:12 -0700 | [diff] [blame] | 8950 | dut->ap_he_ppdu = PPDU_NOT_SET; |
Priyadharshini Gowthaman | fe60c50 | 2019-08-14 13:00:34 -0700 | [diff] [blame] | 8951 | dut->ap_he_ulofdma = VALUE_NOT_SET; |
Priyadharshini Gowthaman | bc94889 | 2019-09-10 14:22:49 -0700 | [diff] [blame] | 8952 | dut->ap_numsounddim = 0; |
Priyadharshini Gowthaman | 670b323 | 2019-09-10 16:09:19 -0700 | [diff] [blame] | 8953 | dut->ap_bcc = VALUE_DISABLED; |
Priyadharshini Gowthaman | 21895a5 | 2019-10-07 16:56:16 -0700 | [diff] [blame] | 8954 | dut->ap_mu_edca = VALUE_DISABLED; |
Priyadharshini Gowthaman | dee79e2 | 2019-10-07 16:56:27 -0700 | [diff] [blame] | 8955 | dut->ap_he_mimo = MIMO_NOT_SET; |
Priyadharshini Gowthaman | 43d6b41 | 2019-10-07 16:56:37 -0700 | [diff] [blame] | 8956 | dut->ap_he_rtsthrshld = VALUE_NOT_SET; |
Priyadharshini Gowthaman | 8018c98 | 2019-10-31 15:14:37 -0700 | [diff] [blame] | 8957 | dut->ap_mbssid = VALUE_DISABLED; |
Priyadharshini Gowthaman | b58b51b | 2019-11-04 14:02:51 -0800 | [diff] [blame] | 8958 | dut->ap_ampdu = VALUE_NOT_SET; |
Priyadharshini Gowthaman | 78ee2ef | 2019-11-15 16:08:28 -0800 | [diff] [blame] | 8959 | dut->he_mcsnssmap = 0; |
| 8960 | dut->ap_fixed_rate = 0; |
Priyadharshini Gowthaman | 21f7440 | 2019-11-25 15:39:09 -0800 | [diff] [blame] | 8961 | dut->he_mmss = 0; |
Priyadharshini Gowthaman | 9b7dbe1 | 2019-12-04 12:17:32 -0800 | [diff] [blame] | 8962 | dut->he_set_sta_1x1 = VALUE_DISABLED; |
Priyadharshini Gowthaman | 6bc4c1e | 2019-09-10 16:24:51 -0700 | [diff] [blame] | 8963 | if (dut->device_type == AP_testbed) { |
Priyadharshini Gowthaman | fe60c50 | 2019-08-14 13:00:34 -0700 | [diff] [blame] | 8964 | dut->ap_he_dlofdma = VALUE_DISABLED; |
Priyadharshini Gowthaman | 6bc4c1e | 2019-09-10 16:24:51 -0700 | [diff] [blame] | 8965 | dut->ap_he_frag = VALUE_DISABLED; |
Priyadharshini Gowthaman | ae0a605 | 2019-11-01 15:26:38 -0700 | [diff] [blame] | 8966 | dut->ap_twtresp = VALUE_DISABLED; |
Priyadharshini Gowthaman | 78ee2ef | 2019-11-15 16:08:28 -0800 | [diff] [blame] | 8967 | dut->he_ul_mcs = 7; |
Priyadharshini Gowthaman | 6bc4c1e | 2019-09-10 16:24:51 -0700 | [diff] [blame] | 8968 | } else { |
Priyadharshini Gowthaman | fe60c50 | 2019-08-14 13:00:34 -0700 | [diff] [blame] | 8969 | dut->ap_he_dlofdma = VALUE_NOT_SET; |
Priyadharshini Gowthaman | 6bc4c1e | 2019-09-10 16:24:51 -0700 | [diff] [blame] | 8970 | dut->ap_he_frag = VALUE_NOT_SET; |
Priyadharshini Gowthaman | 1a686bd | 2019-09-19 14:41:40 -0700 | [diff] [blame] | 8971 | dut->ap_ba_bufsize = BA_BUFSIZE_NOT_SET; |
Priyadharshini Gowthaman | ae0a605 | 2019-11-01 15:26:38 -0700 | [diff] [blame] | 8972 | dut->ap_twtresp = VALUE_NOT_SET; |
Priyadharshini Gowthaman | 78ee2ef | 2019-11-15 16:08:28 -0800 | [diff] [blame] | 8973 | dut->he_ul_mcs = 0; |
Priyadharshini Gowthaman | 6bc4c1e | 2019-09-10 16:24:51 -0700 | [diff] [blame] | 8974 | } |
priyadharshini gowthaman | 350f191 | 2018-06-04 13:09:12 -0700 | [diff] [blame] | 8975 | |
Priyadharshini Gowthaman | 670b323 | 2019-09-10 16:09:19 -0700 | [diff] [blame] | 8976 | if (dut->program == PROGRAM_HE) { |
Priyadharshini Gowthaman | 1a686bd | 2019-09-19 14:41:40 -0700 | [diff] [blame] | 8977 | if (dut->device_type == AP_testbed) { |
Priyadharshini Gowthaman | 670b323 | 2019-09-10 16:09:19 -0700 | [diff] [blame] | 8978 | dut->ap_ldpc = VALUE_DISABLED; |
Priyadharshini Gowthaman | 1a686bd | 2019-09-19 14:41:40 -0700 | [diff] [blame] | 8979 | dut->ap_ba_bufsize = BA_BUFSIZE_64; |
Priyadharshini Gowthaman | b58b51b | 2019-11-04 14:02:51 -0800 | [diff] [blame] | 8980 | dut->ap_amsdu = VALUE_DISABLED; |
Priyadharshini Gowthaman | e216dc5 | 2019-11-08 14:22:16 -0800 | [diff] [blame] | 8981 | dut->ap_txBF = 0; |
| 8982 | dut->ap_mu_txBF = 0; |
Priyadharshini Gowthaman | 96d542e | 2019-11-21 14:25:21 -0800 | [diff] [blame] | 8983 | dut->he_sounding = VALUE_DISABLED; |
Priyadharshini Gowthaman | e216dc5 | 2019-11-08 14:22:16 -0800 | [diff] [blame] | 8984 | } else { |
| 8985 | dut->ap_txBF = 1; |
| 8986 | dut->ap_mu_txBF = 1; |
Priyadharshini Gowthaman | 96d542e | 2019-11-21 14:25:21 -0800 | [diff] [blame] | 8987 | dut->he_sounding = VALUE_ENABLED; |
Priyadharshini Gowthaman | 1a686bd | 2019-09-19 14:41:40 -0700 | [diff] [blame] | 8988 | } |
Priyadharshini Gowthaman | 115c79d | 2019-11-13 15:23:08 -0800 | [diff] [blame] | 8989 | if (get_openwrt_driver_type() == OPENWRT_DRIVER_ATHEROS) |
| 8990 | dut->ap_dfs_mode = AP_DFS_MODE_ENABLED; |
Priyadharshini Gowthaman | 670b323 | 2019-09-10 16:09:19 -0700 | [diff] [blame] | 8991 | } |
| 8992 | |
priyadharshini gowthaman | 9149afc | 2018-01-15 13:40:18 -0800 | [diff] [blame] | 8993 | dut->ap_oper_chn = 0; |
| 8994 | |
Jouni Malinen | b75c532 | 2019-06-14 01:47:43 +0300 | [diff] [blame] | 8995 | dut->ap_pmksa = 0; |
| 8996 | dut->ap_pmksa_caching = 0; |
| 8997 | |
Jouni Malinen | 3c367e8 | 2017-06-23 17:01:47 +0300 | [diff] [blame] | 8998 | free(dut->rsne_override); |
| 8999 | dut->rsne_override = NULL; |
Jouni Malinen | 7960e3a | 2019-12-07 17:04:35 +0200 | [diff] [blame] | 9000 | free(dut->rsnxe_override_eapol); |
| 9001 | dut->rsnxe_override_eapol = NULL; |
Jouni Malinen | 3c367e8 | 2017-06-23 17:01:47 +0300 | [diff] [blame] | 9002 | |
Jouni Malinen | 6814313 | 2017-09-02 02:34:08 +0300 | [diff] [blame] | 9003 | free(dut->sae_commit_override); |
| 9004 | dut->sae_commit_override = NULL; |
| 9005 | |
Jouni Malinen | ed670f4 | 2017-08-31 01:39:28 +0300 | [diff] [blame] | 9006 | free(dut->ap_sae_groups); |
| 9007 | dut->ap_sae_groups = NULL; |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 9008 | |
Jouni Malinen | 2f524ce | 2017-08-31 01:43:29 +0300 | [diff] [blame] | 9009 | dut->sae_anti_clogging_threshold = -1; |
Jouni Malinen | b347db0 | 2017-09-02 01:36:03 +0300 | [diff] [blame] | 9010 | dut->sae_reflection = 0; |
Jouni Malinen | 3c740ab | 2019-10-10 15:55:11 +0300 | [diff] [blame] | 9011 | dut->sae_confirm_immediate = 0; |
Jouni Malinen | 11e5521 | 2019-11-22 21:46:59 +0200 | [diff] [blame] | 9012 | dut->sae_pwe = SAE_PWE_DEFAULT; |
Jouni Malinen | 2f524ce | 2017-08-31 01:43:29 +0300 | [diff] [blame] | 9013 | |
Jouni Malinen | 3d633da | 2017-09-14 22:19:21 +0300 | [diff] [blame] | 9014 | dut->ap_cipher = AP_CCMP; |
Jouni Malinen | 2ba2449 | 2017-11-17 12:43:59 +0200 | [diff] [blame] | 9015 | dut->ap_group_cipher = AP_NO_GROUP_CIPHER_SET; |
Jouni Malinen | 3d633da | 2017-09-14 22:19:21 +0300 | [diff] [blame] | 9016 | dut->ap_group_mgmt_cipher = AP_NO_GROUP_MGMT_CIPHER_SET; |
Jouni Malinen | 6337062 | 2017-11-18 17:47:13 +0200 | [diff] [blame] | 9017 | dut->ap_passphrase[0] = '\0'; |
| 9018 | dut->ap_psk[0] = '\0'; |
Jouni Malinen | 3d633da | 2017-09-14 22:19:21 +0300 | [diff] [blame] | 9019 | |
Jouni Malinen | d86e582 | 2017-08-29 03:55:32 +0300 | [diff] [blame] | 9020 | dut->dpp_conf_id = -1; |
Jouni Malinen | ba4f2d4 | 2019-10-04 16:13:41 +0300 | [diff] [blame] | 9021 | free(dut->ap_dpp_conf_addr); |
| 9022 | dut->ap_dpp_conf_addr = NULL; |
| 9023 | free(dut->ap_dpp_conf_pkhash); |
| 9024 | dut->ap_dpp_conf_pkhash = NULL; |
Jouni Malinen | d86e582 | 2017-08-29 03:55:32 +0300 | [diff] [blame] | 9025 | |
Alexei Avshalom Lazar | eee9ab0 | 2018-12-24 16:27:48 +0200 | [diff] [blame] | 9026 | if (is_60g_sigma_dut(dut)) { |
Alexei Avshalom Lazar | 2712cc8 | 2018-12-23 16:29:14 +0200 | [diff] [blame] | 9027 | dut->ap_mode = AP_11ad; |
| 9028 | dut->ap_channel = 2; |
Alexei Avshalom Lazar | eee9ab0 | 2018-12-24 16:27:48 +0200 | [diff] [blame] | 9029 | dut->wps_disable = 0; /* WPS is enabled */ |
Alexei Avshalom Lazar | 2712cc8 | 2018-12-23 16:29:14 +0200 | [diff] [blame] | 9030 | dut->ap_pmf = 0; |
Alexei Avshalom Lazar | bc180dc | 2018-12-18 16:01:14 +0200 | [diff] [blame] | 9031 | dut->ap_num_ese_allocs = 0; |
Alexei Avshalom Lazar | 2712cc8 | 2018-12-23 16:29:14 +0200 | [diff] [blame] | 9032 | dut->ap_fixed_rate = 0; |
| 9033 | |
| 9034 | dut->dev_role = DEVROLE_AP; |
| 9035 | |
| 9036 | sigma_dut_print(dut, DUT_MSG_DEBUG, |
| 9037 | "Setting msdu_size to MAX: 7912"); |
| 9038 | snprintf(buf, sizeof(buf), "ifconfig %s mtu 7912", |
Jouni Malinen | 016ae6c | 2019-11-04 17:00:01 +0200 | [diff] [blame] | 9039 | get_main_ifname(dut)); |
Alexei Avshalom Lazar | 2712cc8 | 2018-12-23 16:29:14 +0200 | [diff] [blame] | 9040 | |
| 9041 | if (system(buf) != 0) { |
| 9042 | sigma_dut_print(dut, DUT_MSG_ERROR, "Failed to set %s", |
| 9043 | buf); |
Jouni Malinen | 0e29cf2 | 2019-02-19 01:13:21 +0200 | [diff] [blame] | 9044 | return ERROR_SEND_STATUS; |
Alexei Avshalom Lazar | 2712cc8 | 2018-12-23 16:29:14 +0200 | [diff] [blame] | 9045 | } |
| 9046 | |
Alexei Avshalom Lazar | aad97b0 | 2018-12-18 16:01:23 +0200 | [diff] [blame] | 9047 | if (ap_set_force_mcs(dut, 0, 1)) { |
| 9048 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 9049 | "Failed to reset force MCS"); |
Jouni Malinen | 0e29cf2 | 2019-02-19 01:13:21 +0200 | [diff] [blame] | 9050 | return ERROR_SEND_STATUS; |
Alexei Avshalom Lazar | aad97b0 | 2018-12-18 16:01:23 +0200 | [diff] [blame] | 9051 | } |
| 9052 | |
Jouni Malinen | 016ae6c | 2019-11-04 17:00:01 +0200 | [diff] [blame] | 9053 | if (set_ps(get_main_ifname(dut), dut, 1)) { |
Alexei Avshalom Lazar | 2712cc8 | 2018-12-23 16:29:14 +0200 | [diff] [blame] | 9054 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 9055 | "Failed to enable power save"); |
Jouni Malinen | 0e29cf2 | 2019-02-19 01:13:21 +0200 | [diff] [blame] | 9056 | return ERROR_SEND_STATUS; |
Alexei Avshalom Lazar | 2712cc8 | 2018-12-23 16:29:14 +0200 | [diff] [blame] | 9057 | } |
| 9058 | } |
| 9059 | |
Alexei Avshalom Lazar | b6d25d5 | 2019-02-04 14:08:44 +0200 | [diff] [blame] | 9060 | if (dut->program == PROGRAM_WPS && |
Jouni Malinen | 016ae6c | 2019-11-04 17:00:01 +0200 | [diff] [blame] | 9061 | get_driver_type(dut) == DRIVER_WIL6210) { |
Alexei Avshalom Lazar | b6d25d5 | 2019-02-04 14:08:44 +0200 | [diff] [blame] | 9062 | /* |
| 9063 | * In 60 GHz WPS tests, we configure the AP OOB to |
| 9064 | * secure connection with a random passphrase. |
| 9065 | */ |
| 9066 | char r[16], passphrase[65]; |
| 9067 | |
| 9068 | if (random_get_bytes(r, sizeof(r))) { |
| 9069 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 9070 | "Failed to get random bytes"); |
| 9071 | return ERROR_SEND_STATUS; |
| 9072 | } |
| 9073 | if (base64_encode(r, sizeof(r), |
| 9074 | passphrase, sizeof(passphrase))) { |
| 9075 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 9076 | "Failed to generate random passphrase"); |
| 9077 | return ERROR_SEND_STATUS; |
| 9078 | } |
| 9079 | |
| 9080 | dut->ap_key_mgmt = AP_WPA2_PSK; |
| 9081 | dut->ap_cipher = AP_GCMP_128; |
| 9082 | strlcpy(dut->ap_passphrase, passphrase, |
| 9083 | sizeof(dut->ap_passphrase)); |
| 9084 | sigma_dut_print(dut, DUT_MSG_DEBUG, |
| 9085 | "60G WPS: configure secure AP with random passphrase"); |
| 9086 | } |
| 9087 | |
Jouni Malinen | d86e582 | 2017-08-29 03:55:32 +0300 | [diff] [blame] | 9088 | dut->hostapd_running = 0; |
priyadharshini gowthaman | 9947fd3 | 2018-01-26 15:19:41 -0800 | [diff] [blame] | 9089 | |
| 9090 | if (get_openwrt_driver_type() == OPENWRT_DRIVER_ATHEROS) |
| 9091 | return 1; |
| 9092 | |
Jouni Malinen | d6bf1b4 | 2017-06-23 17:51:01 +0300 | [diff] [blame] | 9093 | if (dut->use_hostapd_pid_file) { |
| 9094 | kill_hostapd_process_pid(dut); |
| 9095 | } else if (kill_process(dut, "(hostapd)", 1, SIGTERM) == 0 || |
| 9096 | system("killall hostapd") == 0) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9097 | int i; |
| 9098 | /* Wait some time to allow hostapd to complete cleanup before |
| 9099 | * starting a new process */ |
| 9100 | for (i = 0; i < 10; i++) { |
| 9101 | usleep(500000); |
| 9102 | if (system("pidof hostapd") != 0) |
| 9103 | break; |
| 9104 | } |
| 9105 | } |
| 9106 | |
| 9107 | if (if_nametoindex("sigmadut") > 0 && |
| 9108 | system("iw dev sigmadut del") != 0) |
| 9109 | sigma_dut_print(dut, DUT_MSG_ERROR, "Failed to remove " |
| 9110 | "monitor interface"); |
| 9111 | |
| 9112 | return 1; |
| 9113 | } |
| 9114 | |
| 9115 | |
Ankita Bajaj | 0d5825b | 2017-10-25 16:20:17 +0530 | [diff] [blame] | 9116 | int sta_cfon_reset_default(struct sigma_dut *dut, struct sigma_conn *conn, |
| 9117 | struct sigma_cmd *cmd) |
| 9118 | { |
| 9119 | return cmd_ap_reset_default(dut, conn, cmd); |
| 9120 | } |
| 9121 | |
| 9122 | |
Jouni Malinen | f722271 | 2019-06-13 01:50:21 +0300 | [diff] [blame] | 9123 | static enum sigma_cmd_result cmd_ap_get_info(struct sigma_dut *dut, |
| 9124 | struct sigma_conn *conn, |
| 9125 | struct sigma_cmd *cmd) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9126 | { |
| 9127 | /* const char *name = get_param(cmd, "NAME"); */ |
| 9128 | struct stat s; |
| 9129 | char resp[200]; |
| 9130 | FILE *f; |
Jouni Malinen | 016ae6c | 2019-11-04 17:00:01 +0200 | [diff] [blame] | 9131 | enum driver_type drv = get_driver_type(dut); |
Jouni Malinen | 3aa7286 | 2019-05-29 23:14:51 +0300 | [diff] [blame] | 9132 | int res; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9133 | |
| 9134 | switch (drv) { |
| 9135 | case DRIVER_ATHEROS: { |
| 9136 | /* Atheros AP */ |
| 9137 | struct utsname uts; |
| 9138 | char *version, athver[100]; |
| 9139 | |
| 9140 | if (stat("/proc/athversion", &s) != 0) { |
| 9141 | if (system("/etc/rc.d/rc.wlan up") != 0) { |
| 9142 | } |
| 9143 | } |
| 9144 | |
| 9145 | athver[0] = '\0'; |
| 9146 | f = fopen("/proc/athversion", "r"); |
| 9147 | if (f) { |
| 9148 | if (fgets(athver, sizeof(athver), f)) { |
| 9149 | char *pos = strchr(athver, '\n'); |
| 9150 | if (pos) |
| 9151 | *pos = '\0'; |
| 9152 | } |
| 9153 | fclose(f); |
| 9154 | } |
| 9155 | |
| 9156 | if (uname(&uts) == 0) |
| 9157 | version = uts.release; |
| 9158 | else |
| 9159 | version = "Unknown"; |
| 9160 | |
| 9161 | if (if_nametoindex("ath1") > 0) |
Jouni Malinen | 3aa7286 | 2019-05-29 23:14:51 +0300 | [diff] [blame] | 9162 | res = snprintf(resp, sizeof(resp), |
| 9163 | "interface,ath0_24G ath1_5G,agent,1.0,version,%s/drv:%s", |
| 9164 | version, athver); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9165 | else |
Jouni Malinen | 3aa7286 | 2019-05-29 23:14:51 +0300 | [diff] [blame] | 9166 | res = snprintf(resp, sizeof(resp), |
| 9167 | "interface,ath0_24G,agent,1.0,version,%s/drv:%s", |
| 9168 | version, athver); |
| 9169 | if (res < 0 || res >= sizeof(resp)) |
| 9170 | send_resp(dut, conn, SIGMA_ERROR, NULL); |
| 9171 | else |
| 9172 | send_resp(dut, conn, SIGMA_COMPLETE, resp); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9173 | return 0; |
| 9174 | } |
Sreelakshmi Konamki | b692f10 | 2016-04-26 19:47:00 +0530 | [diff] [blame] | 9175 | case DRIVER_LINUX_WCN: |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9176 | case DRIVER_MAC80211: { |
| 9177 | struct utsname uts; |
| 9178 | char *version; |
| 9179 | |
| 9180 | if (uname(&uts) == 0) |
| 9181 | version = uts.release; |
| 9182 | else |
| 9183 | version = "Unknown"; |
| 9184 | |
| 9185 | if (if_nametoindex("wlan1") > 0) |
| 9186 | snprintf(resp, sizeof(resp), "interface,wlan0_24G " |
| 9187 | "wlan1_5G,agent,1.0,version,%s", version); |
| 9188 | else |
| 9189 | snprintf(resp, sizeof(resp), "interface,wlan0_any," |
| 9190 | "agent,1.0,version,%s", version); |
| 9191 | |
| 9192 | send_resp(dut, conn, SIGMA_COMPLETE, resp); |
| 9193 | return 0; |
| 9194 | } |
| 9195 | case DRIVER_QNXNTO: { |
| 9196 | struct utsname uts; |
| 9197 | char *version; |
| 9198 | |
| 9199 | if (uname(&uts) == 0) |
| 9200 | version = uts.release; |
| 9201 | else |
| 9202 | version = "Unknown"; |
| 9203 | snprintf(resp, sizeof(resp), |
| 9204 | "interface,%s_any,agent,1.0,version,%s", |
Jouni Malinen | 5ea3092 | 2019-11-04 17:39:25 +0200 | [diff] [blame] | 9205 | dut->main_ifname ? get_main_ifname(dut) : "NA", |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9206 | version); |
| 9207 | send_resp(dut, conn, SIGMA_COMPLETE, resp); |
| 9208 | return 0; |
| 9209 | } |
| 9210 | case DRIVER_OPENWRT: { |
| 9211 | switch (get_openwrt_driver_type()) { |
| 9212 | case OPENWRT_DRIVER_ATHEROS: { |
| 9213 | struct utsname uts; |
| 9214 | char *version; |
| 9215 | |
| 9216 | if (uname(&uts) == 0) |
| 9217 | version = uts.release; |
| 9218 | else |
| 9219 | version = "Unknown"; |
| 9220 | |
| 9221 | if (if_nametoindex("ath1") > 0) |
| 9222 | snprintf(resp, sizeof(resp), |
| 9223 | "interface,ath0_5G ath1_24G,agent,1.0,version,%s", |
| 9224 | version); |
| 9225 | else |
| 9226 | snprintf(resp, sizeof(resp), |
| 9227 | "interface,ath0_any,agent,1.0,version,%s", |
| 9228 | version); |
| 9229 | |
| 9230 | send_resp(dut, conn, SIGMA_COMPLETE, resp); |
| 9231 | return 0; |
| 9232 | } |
| 9233 | default: |
| 9234 | send_resp(dut, conn, SIGMA_ERROR, |
| 9235 | "errorCode,Unsupported openwrt driver"); |
| 9236 | return 0; |
| 9237 | } |
| 9238 | } |
| 9239 | default: |
| 9240 | send_resp(dut, conn, SIGMA_ERROR, |
| 9241 | "errorCode,Unsupported driver"); |
| 9242 | return 0; |
| 9243 | } |
| 9244 | } |
| 9245 | |
| 9246 | |
Jouni Malinen | f722271 | 2019-06-13 01:50:21 +0300 | [diff] [blame] | 9247 | static enum sigma_cmd_result cmd_ap_deauth_sta(struct sigma_dut *dut, |
| 9248 | struct sigma_conn *conn, |
| 9249 | struct sigma_cmd *cmd) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9250 | { |
| 9251 | /* const char *name = get_param(cmd, "NAME"); */ |
| 9252 | /* const char *ifname = get_param(cmd, "INTERFACE"); */ |
Jouni Malinen | 0ac588d | 2019-11-06 18:57:01 +0200 | [diff] [blame] | 9253 | const char *val, *disconnect; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9254 | char buf[100]; |
| 9255 | |
| 9256 | val = get_param(cmd, "MinorCode"); |
| 9257 | if (val) { |
| 9258 | /* TODO: add support for P2P minor code */ |
| 9259 | send_resp(dut, conn, SIGMA_ERROR, "errorCode,MinorCode not " |
| 9260 | "yet supported"); |
| 9261 | return 0; |
| 9262 | } |
| 9263 | |
| 9264 | val = get_param(cmd, "STA_MAC_ADDRESS"); |
| 9265 | if (val == NULL) |
| 9266 | return -1; |
Jouni Malinen | 0ac588d | 2019-11-06 18:57:01 +0200 | [diff] [blame] | 9267 | disconnect = get_param(cmd, "disconnect"); |
| 9268 | if (disconnect && strcasecmp(disconnect, "silent") == 0) |
| 9269 | snprintf(buf, sizeof(buf), "deauth %s tx=0", val); |
| 9270 | else |
| 9271 | snprintf(buf, sizeof(buf), "deauth %s", val); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9272 | if (run_hostapd_cli(dut, buf) != 0) |
| 9273 | return -2; |
| 9274 | |
| 9275 | return 1; |
| 9276 | } |
| 9277 | |
| 9278 | |
| 9279 | #ifdef __linux__ |
| 9280 | int inject_frame(int s, const void *data, size_t len, int encrypt); |
| 9281 | int open_monitor(const char *ifname); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9282 | #endif /* __linux__ */ |
| 9283 | |
| 9284 | enum send_frame_type { |
| 9285 | DISASSOC, DEAUTH, SAQUERY |
| 9286 | }; |
| 9287 | enum send_frame_protection { |
| 9288 | CORRECT_KEY, INCORRECT_KEY, UNPROTECTED |
| 9289 | }; |
| 9290 | |
| 9291 | |
| 9292 | static int ap_inject_frame(struct sigma_dut *dut, struct sigma_conn *conn, |
| 9293 | enum send_frame_type frame, |
| 9294 | enum send_frame_protection protected, |
| 9295 | const char *sta_addr) |
| 9296 | { |
| 9297 | #ifdef __linux__ |
| 9298 | unsigned char buf[1000], *pos; |
| 9299 | int s, res; |
| 9300 | unsigned char addr_sta[6], addr_own[6]; |
| 9301 | char *ifname; |
| 9302 | char cbuf[100]; |
| 9303 | struct ifreq ifr; |
| 9304 | |
| 9305 | if ((dut->ap_mode == AP_11a || dut->ap_mode == AP_11na || |
| 9306 | dut->ap_mode == AP_11ac) && |
| 9307 | if_nametoindex("wlan1") > 0) |
| 9308 | ifname = "wlan1"; |
| 9309 | else |
| 9310 | ifname = "wlan0"; |
| 9311 | |
| 9312 | if (hwaddr_aton(sta_addr, addr_sta) < 0) |
| 9313 | return -1; |
| 9314 | |
| 9315 | s = socket(AF_INET, SOCK_DGRAM, 0); |
| 9316 | if (s < 0) |
| 9317 | return -1; |
| 9318 | memset(&ifr, 0, sizeof(ifr)); |
Peng Xu | b8fc5cc | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 9319 | strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name)); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9320 | if (ioctl(s, SIOCGIFHWADDR, &ifr) < 0) { |
| 9321 | perror("ioctl"); |
| 9322 | close(s); |
| 9323 | return -1; |
| 9324 | } |
| 9325 | close(s); |
| 9326 | memcpy(addr_own, ifr.ifr_hwaddr.sa_data, 6); |
| 9327 | |
| 9328 | if (if_nametoindex("sigmadut") == 0) { |
| 9329 | snprintf(cbuf, sizeof(cbuf), |
| 9330 | "iw dev %s interface add sigmadut type monitor", |
| 9331 | ifname); |
| 9332 | if (system(cbuf) != 0 || |
| 9333 | if_nametoindex("sigmadut") == 0) { |
| 9334 | sigma_dut_print(dut, DUT_MSG_ERROR, "Failed to add " |
| 9335 | "monitor interface with '%s'", cbuf); |
| 9336 | return -2; |
| 9337 | } |
| 9338 | } |
| 9339 | |
| 9340 | if (system("ifconfig sigmadut up") != 0) { |
| 9341 | sigma_dut_print(dut, DUT_MSG_ERROR, "Failed to set " |
| 9342 | "monitor interface up"); |
| 9343 | return -2; |
| 9344 | } |
| 9345 | |
| 9346 | pos = buf; |
| 9347 | |
| 9348 | /* Frame Control */ |
| 9349 | switch (frame) { |
| 9350 | case DISASSOC: |
| 9351 | *pos++ = 0xa0; |
| 9352 | break; |
| 9353 | case DEAUTH: |
| 9354 | *pos++ = 0xc0; |
| 9355 | break; |
| 9356 | case SAQUERY: |
| 9357 | *pos++ = 0xd0; |
| 9358 | break; |
| 9359 | } |
| 9360 | |
| 9361 | if (protected == INCORRECT_KEY) |
| 9362 | *pos++ = 0x40; /* Set Protected field to 1 */ |
| 9363 | else |
| 9364 | *pos++ = 0x00; |
| 9365 | |
| 9366 | /* Duration */ |
| 9367 | *pos++ = 0x00; |
| 9368 | *pos++ = 0x00; |
| 9369 | |
| 9370 | /* addr1 = DA (station) */ |
| 9371 | memcpy(pos, addr_sta, 6); |
| 9372 | pos += 6; |
| 9373 | /* addr2 = SA (own address) */ |
| 9374 | memcpy(pos, addr_own, 6); |
| 9375 | pos += 6; |
| 9376 | /* addr3 = BSSID (own address) */ |
| 9377 | memcpy(pos, addr_own, 6); |
| 9378 | pos += 6; |
| 9379 | |
| 9380 | /* Seq# (to be filled by driver/mac80211) */ |
| 9381 | *pos++ = 0x00; |
| 9382 | *pos++ = 0x00; |
| 9383 | |
| 9384 | if (protected == INCORRECT_KEY) { |
| 9385 | /* CCMP parameters */ |
| 9386 | memcpy(pos, "\x61\x01\x00\x20\x00\x10\x00\x00", 8); |
| 9387 | pos += 8; |
| 9388 | } |
| 9389 | |
| 9390 | if (protected == INCORRECT_KEY) { |
| 9391 | switch (frame) { |
| 9392 | case DEAUTH: |
| 9393 | /* Reason code (encrypted) */ |
| 9394 | memcpy(pos, "\xa7\x39", 2); |
| 9395 | pos += 2; |
| 9396 | break; |
| 9397 | case DISASSOC: |
| 9398 | /* Reason code (encrypted) */ |
| 9399 | memcpy(pos, "\xa7\x39", 2); |
| 9400 | pos += 2; |
| 9401 | break; |
| 9402 | case SAQUERY: |
| 9403 | /* Category|Action|TransID (encrypted) */ |
| 9404 | memcpy(pos, "\x6f\xbd\xe9\x4d", 4); |
| 9405 | pos += 4; |
| 9406 | break; |
| 9407 | default: |
| 9408 | return -1; |
| 9409 | } |
| 9410 | |
| 9411 | /* CCMP MIC */ |
| 9412 | memcpy(pos, "\xc8\xd8\x3b\x06\x5d\xb7\x25\x68", 8); |
| 9413 | pos += 8; |
| 9414 | } else { |
| 9415 | switch (frame) { |
| 9416 | case DEAUTH: |
| 9417 | /* reason code = 8 */ |
| 9418 | *pos++ = 0x08; |
| 9419 | *pos++ = 0x00; |
| 9420 | break; |
| 9421 | case DISASSOC: |
| 9422 | /* reason code = 8 */ |
| 9423 | *pos++ = 0x08; |
| 9424 | *pos++ = 0x00; |
| 9425 | break; |
| 9426 | case SAQUERY: |
| 9427 | /* Category - SA Query */ |
| 9428 | *pos++ = 0x08; |
| 9429 | /* SA query Action - Request */ |
| 9430 | *pos++ = 0x00; |
| 9431 | /* Transaction ID */ |
| 9432 | *pos++ = 0x12; |
| 9433 | *pos++ = 0x34; |
| 9434 | break; |
| 9435 | } |
| 9436 | } |
| 9437 | |
| 9438 | s = open_monitor("sigmadut"); |
| 9439 | if (s < 0) { |
| 9440 | send_resp(dut, conn, SIGMA_ERROR, "errorCode,Failed to open " |
| 9441 | "monitor socket"); |
| 9442 | return 0; |
| 9443 | } |
| 9444 | |
| 9445 | res = inject_frame(s, buf, pos - buf, protected == CORRECT_KEY); |
| 9446 | if (res < 0) { |
| 9447 | send_resp(dut, conn, SIGMA_ERROR, "errorCode,Failed to " |
| 9448 | "inject frame"); |
Pradeep Reddy POTTETI | 673d85c | 2016-07-26 19:08:07 +0530 | [diff] [blame] | 9449 | close(s); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9450 | return 0; |
| 9451 | } |
| 9452 | if (res < pos - buf) { |
| 9453 | send_resp(dut, conn, SIGMA_ERROR, "errorCode,Only partial " |
| 9454 | "frame sent"); |
Pradeep Reddy POTTETI | 673d85c | 2016-07-26 19:08:07 +0530 | [diff] [blame] | 9455 | close(s); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9456 | return 0; |
| 9457 | } |
| 9458 | |
| 9459 | close(s); |
| 9460 | |
| 9461 | return 1; |
| 9462 | #else /* __linux__ */ |
| 9463 | send_resp(dut, conn, SIGMA_ERROR, "errorCode,ap_send_frame not " |
| 9464 | "yet supported"); |
| 9465 | return 0; |
| 9466 | #endif /* __linux__ */ |
| 9467 | } |
| 9468 | |
| 9469 | |
| 9470 | int ap_send_frame_hs2(struct sigma_dut *dut, struct sigma_conn *conn, |
| 9471 | struct sigma_cmd *cmd) |
| 9472 | { |
| 9473 | const char *val, *dest; |
| 9474 | char buf[100]; |
| 9475 | |
| 9476 | val = get_param(cmd, "FrameName"); |
| 9477 | if (val == NULL) |
| 9478 | return -1; |
| 9479 | |
| 9480 | if (strcasecmp(val, "QoSMapConfigure") == 0) { |
| 9481 | dest = get_param(cmd, "Dest"); |
| 9482 | if (!dest) |
| 9483 | return -1; |
| 9484 | |
| 9485 | val = get_param(cmd, "QoS_MAP_SET"); |
| 9486 | if (val) { |
| 9487 | dut->ap_qos_map_set = atoi(val); |
| 9488 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_qos_map_set %d", |
| 9489 | dut->ap_qos_map_set); |
| 9490 | } |
| 9491 | |
| 9492 | if (dut->ap_qos_map_set == 1) |
| 9493 | run_hostapd_cli(dut, "set_qos_map_set " QOS_MAP_SET_1); |
| 9494 | else if (dut->ap_qos_map_set == 2) |
| 9495 | run_hostapd_cli(dut, "set_qos_map_set " QOS_MAP_SET_2); |
| 9496 | |
| 9497 | snprintf(buf, sizeof(buf), "send_qos_map_conf %s", dest); |
| 9498 | if (run_hostapd_cli(dut, buf) != 0) |
| 9499 | return -1; |
| 9500 | } |
| 9501 | |
| 9502 | return 1; |
| 9503 | } |
| 9504 | |
| 9505 | |
| 9506 | static int ath_ap_send_frame_vht(struct sigma_dut *dut, struct sigma_conn *conn, |
| 9507 | struct sigma_cmd *cmd) |
| 9508 | { |
| 9509 | const char *val; |
Jouni Malinen | 016ae6c | 2019-11-04 17:00:01 +0200 | [diff] [blame] | 9510 | const char *ifname; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9511 | int chwidth, nss; |
| 9512 | |
| 9513 | val = get_param(cmd, "FrameName"); |
| 9514 | if (!val || strcasecmp(val, "op_md_notif_frm") != 0) { |
| 9515 | send_resp(dut, conn, SIGMA_ERROR, |
| 9516 | "errorCode,Unsupported FrameName"); |
| 9517 | return 0; |
| 9518 | } |
| 9519 | |
| 9520 | /* |
| 9521 | * Sequence of commands for Opmode notification on |
| 9522 | * Peregrine based products |
| 9523 | */ |
Jouni Malinen | 016ae6c | 2019-11-04 17:00:01 +0200 | [diff] [blame] | 9524 | ifname = get_main_ifname(dut); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9525 | |
| 9526 | /* Disable STBC */ |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 9527 | run_iwpriv(dut, ifname, "tx_stbc 0"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9528 | |
| 9529 | /* Check whether optional arg channel width was passed */ |
| 9530 | val = get_param(cmd, "Channel_width"); |
| 9531 | if (val) { |
| 9532 | switch (atoi(val)) { |
| 9533 | case 20: |
| 9534 | chwidth = 0; |
| 9535 | break; |
| 9536 | case 40: |
| 9537 | chwidth = 1; |
| 9538 | break; |
| 9539 | case 80: |
| 9540 | chwidth = 2; |
| 9541 | break; |
| 9542 | case 160: |
| 9543 | chwidth = 3; |
| 9544 | break; |
| 9545 | default: |
| 9546 | chwidth = 2; |
| 9547 | break; |
| 9548 | } |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 9549 | run_iwpriv(dut, ifname, "chwidth %d", chwidth); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9550 | } |
| 9551 | |
| 9552 | /* Check whether optional arg NSS was passed */ |
| 9553 | val = get_param(cmd, "NSS"); |
| 9554 | if (val) { |
| 9555 | /* Convert nss to chainmask */ |
| 9556 | switch (atoi(val)) { |
| 9557 | case 1: |
| 9558 | nss = 1; |
| 9559 | break; |
| 9560 | case 2: |
| 9561 | nss = 3; |
| 9562 | break; |
| 9563 | case 3: |
| 9564 | nss = 7; |
| 9565 | break; |
| 9566 | default: |
| 9567 | /* We do not support NSS > 3 */ |
| 9568 | nss = 3; |
| 9569 | break; |
| 9570 | } |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 9571 | run_iwpriv(dut, ifname, "rxchainmask %d", nss); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9572 | } |
| 9573 | |
| 9574 | /* Send the opmode notification */ |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 9575 | run_iwpriv(dut, ifname, "opmode_notify 1"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9576 | |
| 9577 | return 1; |
| 9578 | } |
| 9579 | |
| 9580 | |
priyadharshini gowthaman | a27b5b6 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 9581 | static int ath_ap_send_frame_loc(struct sigma_dut *dut, struct sigma_conn *conn, |
| 9582 | struct sigma_cmd *cmd) |
| 9583 | { |
| 9584 | const char *val; |
| 9585 | FILE *f; |
priyadharshini gowthaman | a61badd | 2016-08-16 13:37:27 -0700 | [diff] [blame] | 9586 | int rand_int = 0; |
priyadharshini gowthaman | a27b5b6 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 9587 | |
| 9588 | val = get_param(cmd, "MsntType"); |
| 9589 | if (val) { |
| 9590 | if (dut->ap_msnt_type == 0) |
| 9591 | dut->ap_msnt_type = atoi(val); |
| 9592 | |
| 9593 | if (dut->ap_msnt_type != 5 && dut->ap_msnt_type != 2) { |
| 9594 | dut->ap_msnt_type = atoi(val); |
| 9595 | if (dut->ap_msnt_type == 1) { |
priyadharshini gowthaman | a61badd | 2016-08-16 13:37:27 -0700 | [diff] [blame] | 9596 | val = get_param(cmd, "RandInterval"); |
| 9597 | if (val) |
| 9598 | rand_int = atoi(val); |
priyadharshini gowthaman | a27b5b6 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 9599 | f = fopen("/tmp/ftmrr.txt", "a"); |
| 9600 | if (!f) { |
| 9601 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 9602 | "Failed to open /tmp/ftmrr.txt"); |
| 9603 | return -1; |
| 9604 | } |
| 9605 | |
| 9606 | fprintf(f, "sta_mac = %s\n", cmd->values[3]); |
priyadharshini gowthaman | a61badd | 2016-08-16 13:37:27 -0700 | [diff] [blame] | 9607 | 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", |
| 9608 | rand_int, cmd->values[7]); |
priyadharshini gowthaman | a27b5b6 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 9609 | fclose(f); |
| 9610 | dut->ap_msnt_type = 5; |
| 9611 | run_system(dut, "wpc -f /tmp/ftmrr.txt"); |
| 9612 | } |
| 9613 | } else if (dut->ap_msnt_type == 5) { |
| 9614 | run_system(dut, "wpc -f /tmp/ftmrr.txt"); |
| 9615 | } else if (dut->ap_msnt_type == 2) { |
| 9616 | f = fopen("/tmp/wru.txt", "w"); |
| 9617 | if (!f) { |
| 9618 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 9619 | "Failed to open /tmp/wru.txt"); |
| 9620 | return -1; |
| 9621 | } |
| 9622 | |
| 9623 | fprintf(f, "sta_mac = %s\n", cmd->values[3]); |
| 9624 | fprintf(f, "meas_type = 0x08\ndialogtoken = 0x1\nnum_repetitions = 0x0\nmeas_token = 0x1\nmeas_req_mode = 0x00\nloc_subject = 0x01\n"); |
| 9625 | fclose(f); |
| 9626 | run_system(dut, "wpc -w /tmp/wru.txt"); |
| 9627 | } |
| 9628 | } |
| 9629 | return 1; |
| 9630 | } |
| 9631 | |
| 9632 | |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 9633 | /* |
| 9634 | * The following functions parse_send_frame_params_int(), |
| 9635 | * parse_send_frame_params_str(), and parse_send_frame_params_mac() |
| 9636 | * are used by ath_ap_send_frame_bcn_rpt_req(). |
| 9637 | * Beacon Report Request is a frame used as part of the MBO program. |
| 9638 | * The command for sending beacon report has a lot of |
| 9639 | * arguments and having these functions reduces code size. |
| 9640 | * |
| 9641 | */ |
| 9642 | static int parse_send_frame_params_int(char *param, struct sigma_cmd *cmd, |
| 9643 | struct sigma_dut *dut, |
| 9644 | char *buf, size_t buf_size) |
| 9645 | { |
| 9646 | const char *str_val; |
| 9647 | int int_val; |
| 9648 | char temp[100]; |
| 9649 | |
| 9650 | str_val = get_param(cmd, param); |
| 9651 | if (!str_val) { |
| 9652 | sigma_dut_print(dut, DUT_MSG_ERROR, "%s not given", param); |
| 9653 | return -1; |
| 9654 | } |
| 9655 | int_val = atoi(str_val); |
| 9656 | snprintf(temp, sizeof(temp), " %d", int_val); |
Peng Xu | 591be45 | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 9657 | strlcat(buf, temp, buf_size); |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 9658 | return 0; |
| 9659 | } |
| 9660 | |
| 9661 | |
| 9662 | static int parse_send_frame_params_str(char *param, struct sigma_cmd *cmd, |
| 9663 | struct sigma_dut *dut, |
| 9664 | char *buf, size_t buf_size) |
| 9665 | { |
| 9666 | const char *str_val; |
| 9667 | char temp[100]; |
| 9668 | |
| 9669 | str_val = get_param(cmd, param); |
| 9670 | if (!str_val) { |
| 9671 | sigma_dut_print(dut, DUT_MSG_ERROR, "%s not given", param); |
| 9672 | return -1; |
| 9673 | } |
| 9674 | snprintf(temp, sizeof(temp), " %s", str_val); |
| 9675 | temp[sizeof(temp) - 1] = '\0'; |
Peng Xu | 591be45 | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 9676 | strlcat(buf, temp, buf_size); |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 9677 | return 0; |
| 9678 | } |
| 9679 | |
| 9680 | |
| 9681 | static int parse_send_frame_params_mac(char *param, struct sigma_cmd *cmd, |
| 9682 | struct sigma_dut *dut, |
| 9683 | char *buf, size_t buf_size) |
| 9684 | { |
| 9685 | const char *str_val; |
| 9686 | unsigned char mac[6]; |
| 9687 | char temp[100]; |
| 9688 | |
| 9689 | str_val = get_param(cmd, param); |
| 9690 | if (!str_val) { |
| 9691 | sigma_dut_print(dut, DUT_MSG_ERROR, "%s not given", param); |
| 9692 | return -1; |
| 9693 | } |
| 9694 | |
| 9695 | if (parse_mac_address(dut, str_val, mac) < 0) { |
| 9696 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 9697 | "MAC Address not in proper format"); |
| 9698 | return -1; |
| 9699 | } |
| 9700 | snprintf(temp, sizeof(temp), " %02x:%02x:%02x:%02x:%02x:%02x", |
| 9701 | mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]); |
Peng Xu | 591be45 | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 9702 | strlcat(buf, temp, buf_size); |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 9703 | return 0; |
| 9704 | } |
| 9705 | |
| 9706 | |
| 9707 | static void fill_1_or_0_based_on_presence(struct sigma_cmd *cmd, char *param, |
| 9708 | char *buf, size_t buf_size) |
| 9709 | { |
| 9710 | const char *str_val; |
| 9711 | char *value = " 1"; |
| 9712 | |
| 9713 | str_val = get_param(cmd, param); |
| 9714 | if (!str_val || str_val[0] == '\0') |
| 9715 | value = " 0"; |
Peng Xu | 591be45 | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 9716 | strlcat(buf, value, buf_size); |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 9717 | |
| 9718 | } |
| 9719 | |
| 9720 | |
| 9721 | /* |
| 9722 | * wifitool athN sendbcnrpt |
| 9723 | * <STA MAC - Plugs in from Dest_MAC> |
| 9724 | * <regclass - Plugs in from RegClass - int> |
| 9725 | * <channum - Plugs in from Channel PARAM of dev_send_frame - int> |
| 9726 | * <rand_ivl - Plugs in from RandInt - string> |
| 9727 | * <duration - Plugs in from MeaDur - integer> |
| 9728 | * <mode - Plugs in from MeaMode - string> |
| 9729 | * <req_ssid - Plugs in from SSID PARAM of dev_send_frame - string> |
| 9730 | * <rep_cond - Plugs in from RptCond - integer> |
| 9731 | * <rpt_detail - Plugs in from RptDet - integer> |
| 9732 | * <req_ie - Plugs in from ReqInfo PARAM of dev_send_frame - string> |
| 9733 | * <chanrpt_mode - Plugs in from APChanRpt - integer> |
| 9734 | * <specific_bssid - Plugs in from BSSID PARAM of dev_send_frame> |
| 9735 | * [AP channel numbers] |
| 9736 | */ |
| 9737 | static int ath_ap_send_frame_bcn_rpt_req(struct sigma_dut *dut, |
| 9738 | struct sigma_cmd *cmd, |
| 9739 | const char *ifname) |
| 9740 | { |
| 9741 | char buf[100]; |
| 9742 | int rpt_det; |
| 9743 | const char *str_val; |
| 9744 | const char *mea_mode; |
| 9745 | |
| 9746 | snprintf(buf, sizeof(buf), "wifitool %s sendbcnrpt", ifname); |
| 9747 | |
| 9748 | if (parse_send_frame_params_mac("Dest_MAC", cmd, dut, buf, sizeof(buf))) |
| 9749 | return -1; |
| 9750 | if (parse_send_frame_params_int("RegClass", cmd, dut, buf, sizeof(buf))) |
| 9751 | return -1; |
| 9752 | if (parse_send_frame_params_int("Channel", cmd, dut, buf, sizeof(buf))) |
| 9753 | return -1; |
| 9754 | if (parse_send_frame_params_str("RandInt", cmd, dut, buf, sizeof(buf))) |
| 9755 | return -1; |
| 9756 | if (parse_send_frame_params_int("MeaDur", cmd, dut, buf, sizeof(buf))) |
| 9757 | return -1; |
| 9758 | |
| 9759 | str_val = get_param(cmd, "MeaMode"); |
| 9760 | if (!str_val) { |
| 9761 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 9762 | "MeaMode parameter not present in send bcn-rpt-req"); |
| 9763 | return -1; |
| 9764 | } |
| 9765 | if (strcasecmp(str_val, "passive") == 0) { |
| 9766 | mea_mode = " 0"; |
| 9767 | } else if (strcasecmp(str_val, "active") == 0) { |
| 9768 | mea_mode = " 1"; |
| 9769 | } else if (strcasecmp(str_val, "table") == 0) { |
| 9770 | mea_mode = " 2"; |
| 9771 | } else { |
| 9772 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 9773 | "MEA-MODE Value not correctly given"); |
| 9774 | return -1; |
| 9775 | } |
Peng Xu | 591be45 | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 9776 | strlcat(buf, mea_mode, sizeof(buf)); |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 9777 | |
| 9778 | fill_1_or_0_based_on_presence(cmd, "SSID", buf, sizeof(buf)); |
| 9779 | |
| 9780 | if (parse_send_frame_params_int("RptCond", cmd, dut, buf, sizeof(buf))) |
| 9781 | return -1; |
| 9782 | |
| 9783 | if (parse_send_frame_params_int("RptDet", cmd, dut, buf, sizeof(buf))) |
| 9784 | return -1; |
| 9785 | str_val = get_param(cmd, "RptDet"); |
| 9786 | rpt_det = str_val ? atoi(str_val) : 0; |
| 9787 | |
| 9788 | if (rpt_det) |
| 9789 | fill_1_or_0_based_on_presence(cmd, "ReqInfo", buf, sizeof(buf)); |
| 9790 | else |
Peng Xu | 591be45 | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 9791 | strlcat(buf, " 0", sizeof(buf)); |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 9792 | |
| 9793 | if (rpt_det) |
| 9794 | fill_1_or_0_based_on_presence(cmd, "APChanRpt", buf, |
| 9795 | sizeof(buf)); |
| 9796 | else |
Peng Xu | 591be45 | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 9797 | strlcat(buf, " 0", sizeof(buf)); |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 9798 | |
| 9799 | if (parse_send_frame_params_mac("BSSID", cmd, dut, buf, sizeof(buf))) |
| 9800 | return -1; |
| 9801 | |
priyadharshini gowthaman | 2a4d20e | 2017-12-28 13:01:34 -0800 | [diff] [blame] | 9802 | str_val = get_param(cmd, "APChanRpt"); |
| 9803 | if (str_val) { |
| 9804 | const char *pos; |
| 9805 | int ap_chanrpt; |
| 9806 | int ap_chanrpt_2 = 0; |
| 9807 | char chanrpt[100]; |
| 9808 | |
| 9809 | ap_chanrpt = atoi(str_val); |
| 9810 | pos = strchr(str_val, '_'); |
| 9811 | if (pos) { |
| 9812 | pos++; |
| 9813 | ap_chanrpt_2 = atoi(pos); |
| 9814 | } |
| 9815 | if (ap_chanrpt) { |
| 9816 | snprintf(chanrpt, sizeof(chanrpt), " %d", ap_chanrpt); |
| 9817 | strlcat(buf, chanrpt, sizeof(buf)); |
| 9818 | } |
| 9819 | if (ap_chanrpt_2) { |
| 9820 | snprintf(chanrpt, sizeof(chanrpt), " %d", ap_chanrpt_2); |
| 9821 | strlcat(buf, chanrpt, sizeof(buf)); |
| 9822 | } |
| 9823 | } |
| 9824 | |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 9825 | run_system(dut, buf); |
| 9826 | return 0; |
| 9827 | } |
| 9828 | |
| 9829 | |
| 9830 | static void inform_and_sleep(struct sigma_dut *dut, int seconds) |
| 9831 | { |
| 9832 | sigma_dut_print(dut, DUT_MSG_DEBUG, "sleeping for %d seconds", seconds); |
| 9833 | sleep(seconds); |
| 9834 | sigma_dut_print(dut, DUT_MSG_DEBUG, "woke up after %d seconds", |
| 9835 | seconds); |
| 9836 | } |
| 9837 | |
| 9838 | |
| 9839 | static int ath_ap_send_frame_btm_req(struct sigma_dut *dut, |
| 9840 | struct sigma_cmd *cmd, const char *ifname) |
| 9841 | { |
| 9842 | unsigned char mac_addr[ETH_ALEN]; |
| 9843 | int disassoc_timer; |
| 9844 | char buf[100]; |
| 9845 | const char *val; |
| 9846 | int cand_list = 1; |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 9847 | |
| 9848 | val = get_param(cmd, "Dest_MAC"); |
| 9849 | if (!val || parse_mac_address(dut, val, mac_addr) < 0) { |
| 9850 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 9851 | "MAC Address not in proper format"); |
| 9852 | return -1; |
| 9853 | } |
| 9854 | |
| 9855 | val = get_param(cmd, "Disassoc_Timer"); |
| 9856 | if (val) |
| 9857 | disassoc_timer = atoi(val); |
| 9858 | else |
| 9859 | disassoc_timer = dut->ap_disassoc_timer; |
Jouni Malinen | 032aeab | 2018-01-04 12:30:46 +0200 | [diff] [blame] | 9860 | if (disassoc_timer < 0) { |
| 9861 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 9862 | "Invalid Disassoc_Timer value %d", |
| 9863 | disassoc_timer); |
| 9864 | return -1; |
| 9865 | } |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 9866 | |
| 9867 | val = get_param(cmd, "Cand_List"); |
| 9868 | if (val && val[0]) |
| 9869 | cand_list = atoi(val); |
| 9870 | |
| 9871 | val = get_param(cmd, "BTMQuery_Reason_Code"); |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 9872 | if (val) |
| 9873 | run_iwpriv(dut, ifname, "mbo_trans_rs %s", val); |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 9874 | |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 9875 | if (dut->ap_btmreq_disassoc_imnt && !dut->ap_assoc_delay) |
| 9876 | run_iwpriv(dut, ifname, "mbo_asoc_ret 1"); |
priyadharshini gowthaman | 776562e | 2017-12-20 12:33:34 -0800 | [diff] [blame] | 9877 | |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 9878 | snprintf(buf, sizeof(buf), |
priyadharshini gowthaman | 776562e | 2017-12-20 12:33:34 -0800 | [diff] [blame] | 9879 | "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] | 9880 | ifname, mac_addr[0], mac_addr[1], mac_addr[2], mac_addr[3], |
| 9881 | mac_addr[4], mac_addr[5], cand_list, disassoc_timer, |
| 9882 | dut->ap_btmreq_disassoc_imnt, |
| 9883 | dut->ap_btmreq_term_bit, |
priyadharshini gowthaman | 94062b5 | 2017-12-20 12:33:34 -0800 | [diff] [blame] | 9884 | dut->ap_btmreq_bss_term_tsf, |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 9885 | dut->ap_btmreq_bss_term_dur); |
| 9886 | run_system(dut, buf); |
| 9887 | |
| 9888 | if (dut->ap_btmreq_term_bit) { |
priyadharshini gowthaman | 94062b5 | 2017-12-20 12:33:34 -0800 | [diff] [blame] | 9889 | if (dut->ap_btmreq_bss_term_tsf >= 2) |
| 9890 | inform_and_sleep(dut, dut->ap_btmreq_bss_term_tsf - 2); |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 9891 | run_iwpriv(dut, ifname, "kickmac %02x:%02x:%02x:%02x:%02x:%02x", |
| 9892 | mac_addr[0], mac_addr[1], mac_addr[2], |
| 9893 | mac_addr[3], mac_addr[4], mac_addr[5]); |
priyadharshini gowthaman | 776562e | 2017-12-20 12:33:34 -0800 | [diff] [blame] | 9894 | inform_and_sleep(dut, 2); |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 9895 | run_system_wrapper(dut, "ifconfig %s down", ifname); |
priyadharshini gowthaman | 776562e | 2017-12-20 12:33:34 -0800 | [diff] [blame] | 9896 | inform_and_sleep(dut, 5); |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 9897 | run_system_wrapper(dut, "ifconfig %s up", ifname); |
| 9898 | } else if (dut->ap_btmreq_disassoc_imnt) { |
| 9899 | inform_and_sleep(dut, (disassoc_timer / 1000) + 1); |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 9900 | run_iwpriv(dut, ifname, "kickmac %02x:%02x:%02x:%02x:%02x:%02x", |
| 9901 | mac_addr[0], mac_addr[1], mac_addr[2], |
| 9902 | mac_addr[3], mac_addr[4], mac_addr[5]); |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 9903 | } |
| 9904 | return 0; |
| 9905 | } |
| 9906 | |
| 9907 | |
priyadharshini gowthaman | 2a4d20e | 2017-12-28 13:01:34 -0800 | [diff] [blame] | 9908 | static int ath_ap_send_frame_disassoc(struct sigma_dut *dut, |
| 9909 | struct sigma_cmd *cmd, const char *ifname) |
| 9910 | { |
| 9911 | unsigned char mac_addr[ETH_ALEN]; |
| 9912 | const char *val; |
| 9913 | |
| 9914 | val = get_param(cmd, "Dest_MAC"); |
| 9915 | if (!val || parse_mac_address(dut, val, mac_addr) < 0) { |
| 9916 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 9917 | "MAC Address not in proper format"); |
| 9918 | return -1; |
| 9919 | } |
| 9920 | |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 9921 | run_iwpriv(dut, ifname, "kickmac %02x:%02x:%02x:%02x:%02x:%02x", |
| 9922 | mac_addr[0], mac_addr[1], mac_addr[2], |
| 9923 | mac_addr[3], mac_addr[4], mac_addr[5]); |
priyadharshini gowthaman | 2a4d20e | 2017-12-28 13:01:34 -0800 | [diff] [blame] | 9924 | return 0; |
| 9925 | } |
| 9926 | |
| 9927 | |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 9928 | static int ath_ap_send_frame_mbo(struct sigma_dut *dut, struct sigma_conn *conn, |
| 9929 | struct sigma_cmd *cmd) |
| 9930 | { |
| 9931 | const char *val; |
Jouni Malinen | 016ae6c | 2019-11-04 17:00:01 +0200 | [diff] [blame] | 9932 | const char *ifname; |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 9933 | |
Jouni Malinen | 016ae6c | 2019-11-04 17:00:01 +0200 | [diff] [blame] | 9934 | ifname = get_main_ifname(dut); |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 9935 | |
| 9936 | val = get_param(cmd, "FrameName"); |
| 9937 | if (!val) |
| 9938 | return -1; |
| 9939 | |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 9940 | if (strcasecmp(val, "BTMReq") == 0) |
| 9941 | ath_ap_send_frame_btm_req(dut, cmd, ifname); |
| 9942 | else if (strcasecmp(val, "BcnRptReq") == 0) |
| 9943 | ath_ap_send_frame_bcn_rpt_req(dut, cmd, ifname); |
priyadharshini gowthaman | 2a4d20e | 2017-12-28 13:01:34 -0800 | [diff] [blame] | 9944 | else if (strcasecmp(val, "disassoc") == 0) |
| 9945 | ath_ap_send_frame_disassoc(dut, cmd, ifname); |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 9946 | else |
| 9947 | return -1; |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 9948 | |
| 9949 | return 1; |
| 9950 | } |
| 9951 | |
| 9952 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9953 | static int ap_send_frame_vht(struct sigma_dut *dut, struct sigma_conn *conn, |
| 9954 | struct sigma_cmd *cmd) |
| 9955 | { |
Jouni Malinen | 016ae6c | 2019-11-04 17:00:01 +0200 | [diff] [blame] | 9956 | switch (get_driver_type(dut)) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9957 | case DRIVER_ATHEROS: |
| 9958 | return ath_ap_send_frame_vht(dut, conn, cmd); |
| 9959 | break; |
| 9960 | case DRIVER_OPENWRT: |
| 9961 | switch (get_openwrt_driver_type()) { |
| 9962 | case OPENWRT_DRIVER_ATHEROS: |
| 9963 | return ath_ap_send_frame_vht(dut, conn, cmd); |
| 9964 | default: |
| 9965 | send_resp(dut, conn, SIGMA_ERROR, |
| 9966 | "errorCode,Unsupported ap_send_frame with the current openwrt driver"); |
| 9967 | return 0; |
| 9968 | } |
| 9969 | default: |
| 9970 | send_resp(dut, conn, SIGMA_ERROR, |
| 9971 | "errorCode,Unsupported ap_send_frame with the current driver"); |
| 9972 | return 0; |
| 9973 | } |
| 9974 | } |
| 9975 | |
| 9976 | |
priyadharshini gowthaman | a27b5b6 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 9977 | static int ap_send_frame_loc(struct sigma_dut *dut, struct sigma_conn *conn, |
| 9978 | struct sigma_cmd *cmd) |
| 9979 | { |
Jouni Malinen | 016ae6c | 2019-11-04 17:00:01 +0200 | [diff] [blame] | 9980 | switch (get_driver_type(dut)) { |
priyadharshini gowthaman | a27b5b6 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 9981 | case DRIVER_ATHEROS: |
| 9982 | return ath_ap_send_frame_loc(dut, conn, cmd); |
| 9983 | case DRIVER_OPENWRT: |
| 9984 | switch (get_openwrt_driver_type()) { |
| 9985 | case OPENWRT_DRIVER_ATHEROS: |
| 9986 | return ath_ap_send_frame_loc(dut, conn, cmd); |
| 9987 | default: |
| 9988 | send_resp(dut, conn, SIGMA_ERROR, |
| 9989 | "errorCode,Unsupported ap_send_frame_loc with the current openwrt driver"); |
| 9990 | return 0; |
| 9991 | } |
| 9992 | default: |
| 9993 | send_resp(dut, conn, SIGMA_ERROR, |
| 9994 | "errorCode,Unsupported ap_send_frame_loc with the current driver"); |
| 9995 | return 0; |
| 9996 | } |
| 9997 | } |
| 9998 | |
| 9999 | |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 10000 | static int ap_send_frame_mbo(struct sigma_dut *dut, struct sigma_conn *conn, |
| 10001 | struct sigma_cmd *cmd) |
| 10002 | { |
Jouni Malinen | 016ae6c | 2019-11-04 17:00:01 +0200 | [diff] [blame] | 10003 | switch (get_driver_type(dut)) { |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 10004 | case DRIVER_ATHEROS: |
| 10005 | return ath_ap_send_frame_mbo(dut, conn, cmd); |
| 10006 | case DRIVER_OPENWRT: |
| 10007 | switch (get_openwrt_driver_type()) { |
| 10008 | case OPENWRT_DRIVER_ATHEROS: |
| 10009 | return ath_ap_send_frame_mbo(dut, conn, cmd); |
| 10010 | default: |
| 10011 | send_resp(dut, conn, SIGMA_ERROR, |
| 10012 | "errorCode,Unsupported ap_send_frame with the current openwrt driver"); |
| 10013 | return 0; |
| 10014 | } |
| 10015 | default: |
| 10016 | send_resp(dut, conn, SIGMA_ERROR, |
| 10017 | "errorCode,Unsupported ap_send_frame with the current driver"); |
| 10018 | return 0; |
| 10019 | } |
| 10020 | } |
| 10021 | |
| 10022 | |
Lior David | 0fe101e | 2017-03-09 16:09:50 +0200 | [diff] [blame] | 10023 | static int ap_send_frame_60g(struct sigma_dut *dut, |
| 10024 | struct sigma_conn *conn, |
| 10025 | struct sigma_cmd *cmd) |
| 10026 | { |
Jouni Malinen | 016ae6c | 2019-11-04 17:00:01 +0200 | [diff] [blame] | 10027 | switch (get_driver_type(dut)) { |
Lior David | 0fe101e | 2017-03-09 16:09:50 +0200 | [diff] [blame] | 10028 | #ifdef __linux__ |
| 10029 | case DRIVER_WIL6210: |
| 10030 | return wil6210_send_frame_60g(dut, conn, cmd); |
| 10031 | #endif /* __linux__ */ |
| 10032 | default: |
| 10033 | send_resp(dut, conn, SIGMA_ERROR, |
| 10034 | "errorCode,Unsupported sta_set_frame(60G) with the current driver"); |
| 10035 | return 0; |
| 10036 | } |
| 10037 | } |
| 10038 | |
| 10039 | |
Jouni Malinen | f722271 | 2019-06-13 01:50:21 +0300 | [diff] [blame] | 10040 | enum sigma_cmd_result cmd_ap_send_frame(struct sigma_dut *dut, |
| 10041 | struct sigma_conn *conn, |
| 10042 | struct sigma_cmd *cmd) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 10043 | { |
| 10044 | /* const char *name = get_param(cmd, "NAME"); */ |
| 10045 | /* const char *ifname = get_param(cmd, "INTERFACE"); */ |
| 10046 | const char *val; |
| 10047 | enum send_frame_type frame; |
| 10048 | enum send_frame_protection protected; |
| 10049 | char buf[100]; |
| 10050 | |
| 10051 | val = get_param(cmd, "Program"); |
| 10052 | if (val) { |
| 10053 | if (strcasecmp(val, "HS2") == 0 || |
Adil Saeed Musthafa | 33ea287 | 2017-04-10 23:13:24 -0700 | [diff] [blame] | 10054 | strcasecmp(val, "HS2-R2") == 0 || |
| 10055 | strcasecmp(val, "IOTLP") == 0) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 10056 | return ap_send_frame_hs2(dut, conn, cmd); |
| 10057 | if (strcasecmp(val, "VHT") == 0) |
| 10058 | return ap_send_frame_vht(dut, conn, cmd); |
priyadharshini gowthaman | a27b5b6 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 10059 | if (strcasecmp(val, "LOC") == 0) |
| 10060 | return ap_send_frame_loc(dut, conn, cmd); |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 10061 | if (strcasecmp(val, "MBO") == 0) |
| 10062 | return ap_send_frame_mbo(dut, conn, cmd); |
Lior David | 0fe101e | 2017-03-09 16:09:50 +0200 | [diff] [blame] | 10063 | if (strcasecmp(val, "60GHz") == 0) |
| 10064 | return ap_send_frame_60g(dut, conn, cmd); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 10065 | } |
| 10066 | |
| 10067 | val = get_param(cmd, "PMFFrameType"); |
| 10068 | if (val == NULL) |
| 10069 | val = get_param(cmd, "FrameName"); |
| 10070 | if (val == NULL) |
| 10071 | val = get_param(cmd, "Type"); |
| 10072 | if (val == NULL) |
| 10073 | return -1; |
| 10074 | if (strcasecmp(val, "disassoc") == 0) |
| 10075 | frame = DISASSOC; |
| 10076 | else if (strcasecmp(val, "deauth") == 0) |
| 10077 | frame = DEAUTH; |
| 10078 | else if (strcasecmp(val, "saquery") == 0) |
| 10079 | frame = SAQUERY; |
| 10080 | else { |
| 10081 | send_resp(dut, conn, SIGMA_ERROR, "errorCode,Unsupported " |
| 10082 | "PMFFrameType"); |
| 10083 | return 0; |
| 10084 | } |
| 10085 | |
| 10086 | val = get_param(cmd, "PMFProtected"); |
| 10087 | if (val == NULL) |
| 10088 | val = get_param(cmd, "Protected"); |
| 10089 | if (val == NULL) |
| 10090 | return -1; |
| 10091 | if (strcasecmp(val, "Correct-key") == 0 || |
| 10092 | strcasecmp(val, "CorrectKey") == 0) |
| 10093 | protected = CORRECT_KEY; |
| 10094 | else if (strcasecmp(val, "IncorrectKey") == 0) |
| 10095 | protected = INCORRECT_KEY; |
| 10096 | else if (strcasecmp(val, "Unprotected") == 0) |
| 10097 | protected = UNPROTECTED; |
| 10098 | else { |
| 10099 | send_resp(dut, conn, SIGMA_ERROR, "errorCode,Unsupported " |
| 10100 | "PMFProtected"); |
| 10101 | return 0; |
| 10102 | } |
| 10103 | |
| 10104 | val = get_param(cmd, "stationID"); |
| 10105 | if (val == NULL) |
| 10106 | return -1; |
| 10107 | |
| 10108 | if (protected == INCORRECT_KEY || |
| 10109 | (protected == UNPROTECTED && frame == SAQUERY)) |
| 10110 | return ap_inject_frame(dut, conn, frame, protected, val); |
| 10111 | |
| 10112 | switch (frame) { |
| 10113 | case DISASSOC: |
| 10114 | snprintf(buf, sizeof(buf), "disassoc %s test=%d", |
| 10115 | val, protected == CORRECT_KEY); |
| 10116 | break; |
| 10117 | case DEAUTH: |
| 10118 | snprintf(buf, sizeof(buf), "deauth %s test=%d", |
| 10119 | val, protected == CORRECT_KEY); |
| 10120 | break; |
| 10121 | case SAQUERY: |
| 10122 | snprintf(buf, sizeof(buf), "sa_query %s", val); |
| 10123 | break; |
| 10124 | } |
| 10125 | |
| 10126 | if (run_hostapd_cli(dut, buf) != 0) |
| 10127 | return -2; |
| 10128 | |
| 10129 | return 1; |
| 10130 | } |
| 10131 | |
| 10132 | |
Jouni Malinen | f722271 | 2019-06-13 01:50:21 +0300 | [diff] [blame] | 10133 | static enum sigma_cmd_result cmd_ap_get_mac_address(struct sigma_dut *dut, |
| 10134 | struct sigma_conn *conn, |
| 10135 | struct sigma_cmd *cmd) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 10136 | { |
| 10137 | #if defined( __linux__) |
| 10138 | /* const char *name = get_param(cmd, "NAME"); */ |
| 10139 | /* const char *ifname = get_param(cmd, "INTERFACE"); */ |
Jouni Malinen | f898464 | 2017-10-12 00:02:37 +0300 | [diff] [blame] | 10140 | char resp[100]; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 10141 | unsigned char addr[6]; |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 10142 | char ifname[50]; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 10143 | struct ifreq ifr; |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 10144 | int s, wlan_tag = 1; |
| 10145 | const char *val; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 10146 | |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 10147 | val = get_param(cmd, "WLAN_TAG"); |
| 10148 | if (val) { |
| 10149 | wlan_tag = atoi(val); |
| 10150 | if (wlan_tag < 1 || wlan_tag > 3) { |
| 10151 | /* |
| 10152 | * The only valid WLAN Tags as of now as per the latest |
| 10153 | * WFA scripts are 1, 2, and 3. |
| 10154 | */ |
Jouni Malinen | f898464 | 2017-10-12 00:02:37 +0300 | [diff] [blame] | 10155 | send_resp(dut, conn, SIGMA_ERROR, |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 10156 | "errorCode,Unsupported WLAN_TAG"); |
| 10157 | return 0; |
| 10158 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 10159 | } |
| 10160 | |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 10161 | get_if_name(dut, ifname, sizeof(ifname), wlan_tag); |
| 10162 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 10163 | s = socket(AF_INET, SOCK_DGRAM, 0); |
| 10164 | if (s < 0) |
| 10165 | return -1; |
| 10166 | memset(&ifr, 0, sizeof(ifr)); |
Peng Xu | b8fc5cc | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 10167 | strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name)); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 10168 | if (ioctl(s, SIOCGIFHWADDR, &ifr) < 0) { |
| 10169 | perror("ioctl"); |
| 10170 | close(s); |
Jouni Malinen | f898464 | 2017-10-12 00:02:37 +0300 | [diff] [blame] | 10171 | snprintf(resp, sizeof(resp), |
| 10172 | "errorCode,Could not find interface %s", ifname); |
| 10173 | send_resp(dut, conn, SIGMA_ERROR, resp); |
| 10174 | return 0; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 10175 | } |
| 10176 | close(s); |
| 10177 | memcpy(addr, ifr.ifr_hwaddr.sa_data, 6); |
| 10178 | |
| 10179 | snprintf(resp, sizeof(resp), "mac,%02x:%02x:%02x:%02x:%02x:%02x", |
| 10180 | addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]); |
| 10181 | send_resp(dut, conn, SIGMA_COMPLETE, resp); |
| 10182 | return 0; |
| 10183 | #elif defined( __QNXNTO__) |
| 10184 | char resp[50]; |
| 10185 | unsigned char addr[6]; |
| 10186 | |
Jouni Malinen | d209548 | 2019-11-04 17:10:43 +0200 | [diff] [blame] | 10187 | if (!dut->main_ifname) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 10188 | send_resp(dut, conn, SIGMA_ERROR, "ifname is null"); |
| 10189 | return 0; |
| 10190 | } |
| 10191 | |
Jouni Malinen | 5ea3092 | 2019-11-04 17:39:25 +0200 | [diff] [blame] | 10192 | if (get_hwaddr(get_main_ifname(dut), addr) != 0) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 10193 | send_resp(dut, conn, SIGMA_ERROR, |
| 10194 | "errorCode,Failed to get address"); |
| 10195 | return 0; |
| 10196 | } |
| 10197 | snprintf(resp, sizeof(resp), "mac,%02x:%02x:%02x:%02x:%02x:%02x", |
| 10198 | addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]); |
| 10199 | send_resp(dut, conn, SIGMA_COMPLETE, resp); |
| 10200 | return 0; |
| 10201 | #else /* __linux__ */ |
| 10202 | send_resp(dut, conn, SIGMA_ERROR, "errorCode,ap_get_mac_address not " |
| 10203 | "yet supported"); |
| 10204 | return 0; |
| 10205 | #endif /* __linux__ */ |
| 10206 | } |
| 10207 | |
| 10208 | |
Ankita Bajaj | 0d5825b | 2017-10-25 16:20:17 +0530 | [diff] [blame] | 10209 | int sta_cfon_get_mac_address(struct sigma_dut *dut, struct sigma_conn *conn, |
| 10210 | struct sigma_cmd *cmd) |
| 10211 | { |
| 10212 | return cmd_ap_get_mac_address(dut, conn, cmd); |
| 10213 | } |
| 10214 | |
| 10215 | |
Jouni Malinen | f722271 | 2019-06-13 01:50:21 +0300 | [diff] [blame] | 10216 | static enum sigma_cmd_result cmd_ap_set_pmf(struct sigma_dut *dut, |
| 10217 | struct sigma_conn *conn, |
| 10218 | struct sigma_cmd *cmd) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 10219 | { |
| 10220 | /* |
| 10221 | * Ignore the command since the parameters are already handled through |
| 10222 | * ap_set_security. |
| 10223 | */ |
| 10224 | |
| 10225 | return 1; |
| 10226 | } |
| 10227 | |
| 10228 | |
Jouni Malinen | f722271 | 2019-06-13 01:50:21 +0300 | [diff] [blame] | 10229 | static enum sigma_cmd_result cmd_ap_set_hs2(struct sigma_dut *dut, |
| 10230 | struct sigma_conn *conn, |
| 10231 | struct sigma_cmd *cmd) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 10232 | { |
| 10233 | /* const char *name = get_param(cmd, "NAME"); */ |
| 10234 | /* const char *ifname = get_param(cmd, "INTERFACE"); */ |
| 10235 | const char *val, *dest; |
| 10236 | char *pos, buf[100]; |
| 10237 | int i, wlan_tag = 1; |
| 10238 | |
| 10239 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_set_hs2: Processing the " |
| 10240 | "following parameters"); |
| 10241 | for (i = 0; i < cmd->count; i++) { |
| 10242 | sigma_dut_print(dut, DUT_MSG_INFO, "%s %s", cmd->params[i], |
| 10243 | (cmd->values[i] ? cmd->values[i] : "NULL")); |
| 10244 | } |
| 10245 | |
| 10246 | val = get_param(cmd, "ICMPv4_ECHO"); |
| 10247 | if (val && atoi(val)) { |
| 10248 | snprintf(buf, sizeof(buf), "ebtables -F"); |
| 10249 | if (system(buf) != 0) { |
| 10250 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 10251 | "Failed to set ebtables rules, RULE-12"); |
| 10252 | } |
| 10253 | return 1; |
| 10254 | } |
| 10255 | |
| 10256 | val = get_param(cmd, "WLAN_TAG"); |
| 10257 | if (val) { |
| 10258 | wlan_tag = atoi(val); |
| 10259 | if (wlan_tag != 1 && wlan_tag != 2) { |
| 10260 | send_resp(dut, conn, SIGMA_INVALID, |
| 10261 | "errorCode,Invalid WLAN_TAG"); |
| 10262 | return 0; |
| 10263 | } |
| 10264 | } |
| 10265 | |
| 10266 | if (wlan_tag == 2) { |
| 10267 | val = get_param(cmd, "PROXY_ARP"); |
| 10268 | if (val) |
| 10269 | dut->ap2_proxy_arp = atoi(val); |
Jouni Malinen | dbbc2c4 | 2018-11-14 23:55:41 +0200 | [diff] [blame] | 10270 | |
| 10271 | val = get_param(cmd, "OSU"); |
| 10272 | if (val) |
| 10273 | dut->ap2_osu = atoi(val); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 10274 | return 1; |
| 10275 | } |
| 10276 | |
| 10277 | dest = get_param(cmd, "STA_MAC"); |
| 10278 | if (dest) { |
| 10279 | /* This is a special/ugly way of using this command. |
| 10280 | * If "Dest" MAC is included, assume that this command |
| 10281 | * is being issued after ap_config_commit for dynamically |
| 10282 | * setting the QoS Map Set. |
| 10283 | */ |
| 10284 | val = get_param(cmd, "QoS_MAP_SET"); |
| 10285 | if (val) { |
| 10286 | dut->ap_qos_map_set = atoi(val); |
| 10287 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_qos_map_set %d", |
| 10288 | dut->ap_qos_map_set); |
| 10289 | } |
| 10290 | |
| 10291 | if (dut->ap_qos_map_set == 1) |
| 10292 | run_hostapd_cli(dut, "set_qos_map_set " QOS_MAP_SET_1); |
| 10293 | else if (dut->ap_qos_map_set == 2) |
| 10294 | run_hostapd_cli(dut, "set_qos_map_set " QOS_MAP_SET_2); |
| 10295 | |
| 10296 | snprintf(buf, sizeof(buf), "send_qos_map_conf %s", dest); |
| 10297 | if (run_hostapd_cli(dut, buf) != 0) |
| 10298 | return -1; |
| 10299 | } |
| 10300 | |
| 10301 | val = get_param(cmd, "DGAF_DISABLE"); |
| 10302 | if (val) |
| 10303 | dut->ap_dgaf_disable = atoi(val); |
| 10304 | |
| 10305 | dut->ap_interworking = 1; |
| 10306 | |
| 10307 | val = get_param(cmd, "INTERWORKING"); |
| 10308 | if (val == NULL) |
| 10309 | val = get_param(cmd, "INTERNETWORKING"); |
| 10310 | if (val != NULL && atoi(val) == 0) { |
| 10311 | dut->ap_interworking = 0; |
| 10312 | dut->ap_hs2 = 0; |
| 10313 | return 1; |
| 10314 | } |
| 10315 | |
| 10316 | val = get_param(cmd, "ACCS_NET_TYPE"); |
| 10317 | if (val) { |
| 10318 | if (strcasecmp(val, "Chargeable_Public_Network") == 0 || |
| 10319 | strcasecmp(val, "Chargable_Public_Network") == 0 || |
| 10320 | strcasecmp(val, "Chargable Public Network") == 0) |
| 10321 | dut->ap_access_net_type = 2; |
| 10322 | else |
| 10323 | dut->ap_access_net_type = atoi(val); |
| 10324 | } |
| 10325 | |
| 10326 | val = get_param(cmd, "INTERNET"); |
| 10327 | if (val) |
| 10328 | dut->ap_internet = atoi(val); |
| 10329 | |
| 10330 | val = get_param(cmd, "VENUE_GRP"); |
| 10331 | if (val) { |
| 10332 | if (strcasecmp(val, "Business") == 0) |
| 10333 | dut->ap_venue_group = 2; |
| 10334 | else |
| 10335 | dut->ap_venue_group = atoi(val); |
| 10336 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_venue_name %d", |
| 10337 | dut->ap_venue_name); |
| 10338 | } |
| 10339 | |
| 10340 | val = get_param(cmd, "VENUE_TYPE"); |
| 10341 | if (val) { |
| 10342 | if (strcasecmp(val, "R&D") == 0) |
| 10343 | dut->ap_venue_type = 8; |
| 10344 | else |
| 10345 | dut->ap_venue_type = atoi(val); |
| 10346 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_venue_type %d", |
| 10347 | dut->ap_venue_type); |
| 10348 | } |
| 10349 | |
| 10350 | val = get_param(cmd, "HESSID"); |
| 10351 | if (val) { |
| 10352 | if (strlen(val) >= sizeof(dut->ap_hessid)) { |
| 10353 | send_resp(dut, conn, SIGMA_ERROR, |
| 10354 | "errorCode,Invalid HESSID"); |
| 10355 | return 0; |
| 10356 | } |
| 10357 | snprintf(dut->ap_hessid, sizeof(dut->ap_hessid), "%s", val); |
| 10358 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_hessid %s", |
| 10359 | dut->ap_hessid); |
| 10360 | } |
| 10361 | |
| 10362 | val = get_param(cmd, "ROAMING_CONS"); |
| 10363 | if (val) { |
| 10364 | if (strlen(val) >= sizeof(dut->ap_roaming_cons)) { |
| 10365 | send_resp(dut, conn, SIGMA_ERROR, |
| 10366 | "errorCode,Invalid ROAMING_CONS"); |
| 10367 | return 0; |
| 10368 | } |
| 10369 | if (strcasecmp(val, "Disabled") == 0) { |
| 10370 | dut->ap_roaming_cons[0] = '\0'; |
| 10371 | } else { |
| 10372 | snprintf(dut->ap_roaming_cons, |
| 10373 | sizeof(dut->ap_roaming_cons), "%s", val); |
| 10374 | } |
| 10375 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_roaming_cons %s", |
| 10376 | dut->ap_roaming_cons); |
| 10377 | } |
| 10378 | |
| 10379 | val = get_param(cmd, "ANQP"); |
| 10380 | if (val) |
| 10381 | dut->ap_anqpserver_on = atoi(val); |
| 10382 | |
| 10383 | val = get_param(cmd, "NAI_REALM_LIST"); |
| 10384 | if (val) { |
| 10385 | dut->ap_nai_realm_list = atoi(val); |
| 10386 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_nai_realm_list %d", |
| 10387 | dut->ap_nai_realm_list); |
| 10388 | } |
| 10389 | |
| 10390 | val = get_param(cmd, "3GPP_INFO"); |
| 10391 | if (val) { |
| 10392 | /* What kind of encoding format is used?! */ |
| 10393 | send_resp(dut, conn, SIGMA_ERROR, "errorCode,3GPP_INFO " |
| 10394 | "not yet supported (contents not fully defined)"); |
| 10395 | return 0; |
| 10396 | } |
| 10397 | |
| 10398 | val = get_param(cmd, "DOMAIN_LIST"); |
| 10399 | if (val) { |
| 10400 | if (strlen(val) >= sizeof(dut->ap_domain_name_list)) { |
| 10401 | send_resp(dut, conn, SIGMA_ERROR, "errorCode,Too long " |
| 10402 | "DOMAIN_LIST"); |
| 10403 | return 0; |
| 10404 | } |
| 10405 | snprintf(dut->ap_domain_name_list, |
| 10406 | sizeof(dut->ap_domain_name_list), "%s", val); |
| 10407 | pos = dut->ap_domain_name_list; |
| 10408 | while (*pos) { |
| 10409 | if (*pos == ';') |
| 10410 | *pos = ','; |
| 10411 | pos++; |
| 10412 | } |
| 10413 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_domain_name_list %s", |
| 10414 | dut->ap_domain_name_list); |
| 10415 | } |
| 10416 | |
| 10417 | val = get_param(cmd, "OPER_NAME"); |
| 10418 | if (val) { |
| 10419 | dut->ap_oper_name = atoi(val); |
| 10420 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_oper_name %d", |
| 10421 | dut->ap_oper_name); |
| 10422 | } |
| 10423 | |
| 10424 | val = get_param(cmd, "VENUE_NAME"); |
| 10425 | if (val) { |
| 10426 | dut->ap_venue_name = atoi(val); |
| 10427 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_venue_name %d", |
| 10428 | dut->ap_venue_name); |
| 10429 | } |
| 10430 | |
| 10431 | val = get_param(cmd, "GAS_CB_DELAY"); |
| 10432 | if (val) { |
| 10433 | dut->ap_gas_cb_delay = atoi(val); |
| 10434 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_gas_cb_delay %d", |
| 10435 | dut->ap_gas_cb_delay); |
| 10436 | } |
| 10437 | |
| 10438 | val = get_param(cmd, "MIH"); |
| 10439 | if (val && atoi(val) > 0) { |
| 10440 | send_resp(dut, conn, SIGMA_ERROR, "errorCode,MIH not " |
| 10441 | "supported"); |
| 10442 | return 0; |
| 10443 | } |
| 10444 | |
| 10445 | val = get_param(cmd, "L2_TRAFFIC_INSPECT"); |
| 10446 | if (val) { |
| 10447 | dut->ap_l2tif = atoi(val); |
| 10448 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_l2tif %d", |
| 10449 | dut->ap_l2tif); |
| 10450 | } |
| 10451 | |
| 10452 | val = get_param(cmd, "BCST_UNCST"); |
| 10453 | if (val) { |
| 10454 | send_resp(dut, conn, SIGMA_ERROR, |
| 10455 | "errorCode,BCST_UNCST not yet supported"); |
| 10456 | return 0; |
| 10457 | } |
| 10458 | |
| 10459 | val = get_param(cmd, "PLMN_MCC"); |
| 10460 | if (val) { |
| 10461 | char mcc[100], *start, *end; |
| 10462 | int i = 0; |
| 10463 | if (strlen(val) >= sizeof(mcc)) { |
| 10464 | send_resp(dut, conn, SIGMA_ERROR, |
| 10465 | "errorCode,PLMN_MCC too long"); |
| 10466 | return 0; |
| 10467 | } |
Peng Xu | b8fc5cc | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 10468 | strlcpy(mcc, val, sizeof(mcc)); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 10469 | start = mcc; |
| 10470 | while ((end = strchr(start, ';'))) { |
| 10471 | /* process all except the last */ |
| 10472 | *end = '\0'; |
| 10473 | if (strlen(start) != 3) { |
| 10474 | send_resp(dut, conn, SIGMA_ERROR, |
| 10475 | "errorCode,Invalid PLMN_MCC"); |
| 10476 | return 0; |
| 10477 | } |
| 10478 | snprintf(dut->ap_plmn_mcc[i], |
| 10479 | sizeof(dut->ap_plmn_mcc[i]), "%s", start); |
| 10480 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_plmn_mcc %s", |
| 10481 | dut->ap_plmn_mcc[i]); |
| 10482 | i++; |
| 10483 | start = end + 1; |
| 10484 | *end = ';'; |
| 10485 | } |
| 10486 | if (strlen(start) != 3) { |
| 10487 | send_resp(dut, conn, SIGMA_ERROR, |
| 10488 | "errorCode,Invalid PLMN_MCC"); |
| 10489 | return 0; |
| 10490 | } |
| 10491 | /* process last or only one */ |
| 10492 | snprintf(dut->ap_plmn_mcc[i], |
| 10493 | sizeof(dut->ap_plmn_mcc[i]), "%s", start); |
| 10494 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_plmn_mcc %s", |
| 10495 | dut->ap_plmn_mcc[i]); |
| 10496 | } |
| 10497 | |
| 10498 | val = get_param(cmd, "PLMN_MNC"); |
| 10499 | if (val) { |
| 10500 | char mnc[100], *start, *end; |
| 10501 | int i = 0; |
| 10502 | if (strlen(val) >= sizeof(mnc)) { |
| 10503 | send_resp(dut, conn, SIGMA_ERROR, |
| 10504 | "errorCode,PLMN_MNC too long"); |
| 10505 | return 0; |
| 10506 | } |
Peng Xu | b8fc5cc | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 10507 | strlcpy(mnc, val, sizeof(mnc)); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 10508 | start = mnc; |
| 10509 | while ((end = strchr(start, ';'))) { |
| 10510 | *end = '\0'; |
| 10511 | if (strlen(start) != 2 && strlen(start) != 3) { |
| 10512 | send_resp(dut, conn, SIGMA_ERROR, |
| 10513 | "errorCode,Invalid PLMN_MNC"); |
| 10514 | return 0; |
| 10515 | } |
| 10516 | snprintf(dut->ap_plmn_mnc[i], |
| 10517 | sizeof(dut->ap_plmn_mnc[i]), "%s", start); |
| 10518 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_plmn_mnc %s", |
| 10519 | dut->ap_plmn_mnc[i]); |
| 10520 | i++; |
| 10521 | start = end + 1; |
| 10522 | *end = ';'; |
| 10523 | } |
| 10524 | if (strlen(start) != 2 && strlen(start) != 3) { |
| 10525 | send_resp(dut, conn, SIGMA_ERROR, |
| 10526 | "errorCode,Invalid PLMN_MNC"); |
| 10527 | return 0; |
| 10528 | } |
| 10529 | snprintf(dut->ap_plmn_mnc[i], |
| 10530 | sizeof(dut->ap_plmn_mnc[i]), "%s", start); |
| 10531 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_plmn_mnc %s", |
| 10532 | dut->ap_plmn_mnc[i]); |
| 10533 | } |
| 10534 | |
| 10535 | val = get_param(cmd, "PROXY_ARP"); |
| 10536 | if (val) { |
| 10537 | dut->ap_proxy_arp = atoi(val); |
| 10538 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_proxy_arp %d", |
| 10539 | dut->ap_proxy_arp); |
| 10540 | } |
| 10541 | |
| 10542 | val = get_param(cmd, "WAN_METRICS"); |
| 10543 | if (val) { |
| 10544 | dut->ap_wan_metrics = atoi(val); |
| 10545 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_wan_metrics %d", |
| 10546 | dut->ap_wan_metrics); |
| 10547 | } |
| 10548 | |
| 10549 | val = get_param(cmd, "CONN_CAP"); |
| 10550 | if (val) { |
| 10551 | dut->ap_conn_capab = atoi(val); |
| 10552 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_conn_capab %d", |
| 10553 | dut->ap_conn_capab); |
| 10554 | } |
| 10555 | |
| 10556 | val = get_param(cmd, "IP_ADD_TYPE_AVAIL"); |
| 10557 | if (val) { |
| 10558 | dut->ap_ip_addr_type_avail = atoi(val); |
| 10559 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_ip_addr_type_avail %d", |
| 10560 | dut->ap_ip_addr_type_avail); |
| 10561 | } |
| 10562 | |
| 10563 | val = get_param(cmd, "NET_AUTH_TYPE"); |
| 10564 | if (val) { |
| 10565 | dut->ap_net_auth_type = atoi(val); |
| 10566 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_net_auth_type %d", |
| 10567 | dut->ap_net_auth_type); |
| 10568 | } |
| 10569 | |
| 10570 | val = get_param(cmd, "OP_CLASS"); |
| 10571 | if (val == NULL) |
| 10572 | val = get_param(cmd, "OPER_CLASS"); |
| 10573 | if (val) { |
| 10574 | dut->ap_oper_class = atoi(val); |
| 10575 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_oper_class %d", |
| 10576 | dut->ap_oper_class); |
| 10577 | } |
| 10578 | |
| 10579 | val = get_param(cmd, "OSU_PROVIDER_LIST"); |
| 10580 | if (val) { |
| 10581 | dut->ap_osu_provider_list = atoi(val); |
| 10582 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_osu_provider_list %d", |
| 10583 | dut->ap_osu_provider_list); |
| 10584 | } |
| 10585 | |
Jouni Malinen | 93a837f | 2018-11-01 17:09:22 +0200 | [diff] [blame] | 10586 | val = get_param(cmd, "OSU_PROVIDER_NAI_LIST"); |
| 10587 | if (val) { |
| 10588 | dut->ap_osu_provider_nai_list = atoi(val); |
| 10589 | sigma_dut_print(dut, DUT_MSG_INFO, |
| 10590 | "ap_osu_provider_nai_list %d", |
| 10591 | dut->ap_osu_provider_nai_list); |
| 10592 | } |
| 10593 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 10594 | val = get_param(cmd, "OSU_SERVER_URI"); |
| 10595 | if (val) { |
| 10596 | i = 0; |
| 10597 | do { |
| 10598 | int len; |
| 10599 | const char *uri = val; |
| 10600 | val = strchr(val, ' '); |
| 10601 | len = val ? (val++ - uri) : (int) strlen(uri); |
| 10602 | if (len > 0 && len < 256) { |
| 10603 | memcpy(dut->ap_osu_server_uri[i], uri, len); |
| 10604 | dut->ap_osu_server_uri[i][len] = '\0'; |
| 10605 | sigma_dut_print(dut, DUT_MSG_INFO, |
| 10606 | "ap_osu_server_uri[%d] %s", i, |
| 10607 | dut->ap_osu_server_uri[i]); |
| 10608 | } |
| 10609 | } while (val && ++i < 10); |
| 10610 | } |
| 10611 | |
| 10612 | val = get_param(cmd, "OSU_METHOD"); |
| 10613 | if (val) { |
| 10614 | i = 0; |
| 10615 | do { |
| 10616 | int len; |
| 10617 | const char *method = val; |
| 10618 | val = strchr(val, ' '); |
| 10619 | len = val ? (val++ - method) : (int) strlen(method); |
| 10620 | if (len > 0) { |
| 10621 | if (strncasecmp(method, "SOAP", len) == 0) |
| 10622 | dut->ap_osu_method[i] = 1; |
| 10623 | else if (strncasecmp(method, "OMADM", len) == 0) |
| 10624 | dut->ap_osu_method[i] = 0; |
| 10625 | else |
| 10626 | return -2; |
| 10627 | } |
| 10628 | } while (val && ++i < 10); |
| 10629 | } |
| 10630 | |
| 10631 | val = get_param(cmd, "OSU_SSID"); |
| 10632 | if (val) { |
| 10633 | if (strlen(val) > 0 && strlen(val) <= 32) { |
Peng Xu | b8fc5cc | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 10634 | strlcpy(dut->ap_osu_ssid, val, |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 10635 | sizeof(dut->ap_osu_ssid)); |
| 10636 | sigma_dut_print(dut, DUT_MSG_INFO, |
| 10637 | "ap_osu_ssid %s", |
| 10638 | dut->ap_osu_ssid); |
| 10639 | } |
| 10640 | } |
| 10641 | |
| 10642 | val = get_param(cmd, "OSU_ICON_TAG"); |
| 10643 | if (val) |
| 10644 | dut->ap_osu_icon_tag = atoi(val); |
| 10645 | |
| 10646 | val = get_param(cmd, "QoS_MAP_SET"); |
| 10647 | if (val) { |
| 10648 | dut->ap_qos_map_set = atoi(val); |
| 10649 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_qos_map_set %d", |
| 10650 | dut->ap_qos_map_set); |
| 10651 | } |
| 10652 | |
| 10653 | val = get_param(cmd, "BSS_LOAD"); |
| 10654 | if (val) { |
| 10655 | dut->ap_bss_load = atoi(val); |
| 10656 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_bss_load %d", |
| 10657 | dut->ap_bss_load); |
| 10658 | } |
| 10659 | |
Jouni Malinen | 54a89b0 | 2018-05-01 00:16:26 +0300 | [diff] [blame] | 10660 | val = get_param(cmd, "Venue_URL"); |
| 10661 | if (val) |
| 10662 | dut->ap_venue_url = atoi(val); |
| 10663 | |
Jouni Malinen | f7ff42b | 2018-05-01 00:21:56 +0300 | [diff] [blame] | 10664 | val = get_param(cmd, "Advice_of_Charge"); |
| 10665 | if (val) |
| 10666 | dut->ap_advice_of_charge = atoi(val); |
| 10667 | |
Jouni Malinen | ac10453 | 2018-05-01 00:27:37 +0300 | [diff] [blame] | 10668 | val = get_param(cmd, "Operator_Icon_Metadata"); |
| 10669 | if (val) |
| 10670 | dut->ap_oper_icon_metadata = atoi(val); |
| 10671 | |
Jouni Malinen | ac36714 | 2018-05-01 00:32:24 +0300 | [diff] [blame] | 10672 | val = get_param(cmd, "TnC_File_Name"); |
| 10673 | if (val) |
| 10674 | dut->ap_tnc_file_name = atoi(val); |
| 10675 | |
| 10676 | val = get_param(cmd, "TnC_File_Time_Stamp"); |
| 10677 | if (val) |
| 10678 | dut->ap_tnc_time_stamp = strtol(val, NULL, 10); |
| 10679 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 10680 | return 1; |
| 10681 | } |
| 10682 | |
| 10683 | |
| 10684 | void nfc_status(struct sigma_dut *dut, const char *state, const char *oper) |
| 10685 | { |
| 10686 | char buf[100]; |
| 10687 | |
| 10688 | if (!file_exists("nfc-status")) |
| 10689 | return; |
| 10690 | |
| 10691 | snprintf(buf, sizeof(buf), "./nfc-status %s %s", state, oper); |
| 10692 | run_system(dut, buf); |
| 10693 | } |
| 10694 | |
| 10695 | |
| 10696 | static int run_nfc_command(struct sigma_dut *dut, const char *cmd, |
| 10697 | const char *info) |
| 10698 | { |
| 10699 | int res; |
| 10700 | |
| 10701 | printf("\n\n\n=====[ NFC operation ]=========================\n\n"); |
| 10702 | printf("%s\n\n", info); |
| 10703 | |
| 10704 | nfc_status(dut, "START", info); |
| 10705 | res = run_system(dut, cmd); |
| 10706 | nfc_status(dut, res ? "FAIL" : "SUCCESS", info); |
| 10707 | if (res) { |
| 10708 | sigma_dut_print(dut, DUT_MSG_INFO, "Failed to run '%s': %d", |
| 10709 | cmd, res); |
| 10710 | return res; |
| 10711 | } |
| 10712 | |
| 10713 | return 0; |
| 10714 | } |
| 10715 | |
| 10716 | |
| 10717 | static int ap_nfc_write_config_token(struct sigma_dut *dut, |
| 10718 | struct sigma_conn *conn, |
| 10719 | struct sigma_cmd *cmd) |
| 10720 | { |
| 10721 | int res; |
| 10722 | char buf[300]; |
| 10723 | |
| 10724 | run_system(dut, "killall wps-ap-nfc.py"); |
| 10725 | unlink("nfc-success"); |
| 10726 | snprintf(buf, sizeof(buf), |
| 10727 | "./wps-ap-nfc.py --no-wait %s%s --success nfc-success write-config", |
| 10728 | dut->summary_log ? "--summary " : "", |
| 10729 | dut->summary_log ? dut->summary_log : ""); |
| 10730 | res = run_nfc_command(dut, buf, |
| 10731 | "Touch NFC Tag to write WPS configuration token"); |
| 10732 | if (res || !file_exists("nfc-success")) { |
| 10733 | send_resp(dut, conn, SIGMA_ERROR, |
| 10734 | "ErrorCode,Failed to write tag"); |
| 10735 | return 0; |
| 10736 | } |
| 10737 | |
| 10738 | return 1; |
| 10739 | } |
| 10740 | |
| 10741 | |
| 10742 | static int ap_nfc_wps_read_passwd(struct sigma_dut *dut, |
| 10743 | struct sigma_conn *conn, |
| 10744 | struct sigma_cmd *cmd) |
| 10745 | { |
| 10746 | int res; |
| 10747 | char buf[300]; |
| 10748 | |
| 10749 | run_system(dut, "killall wps-ap-nfc.py"); |
| 10750 | |
| 10751 | unlink("nfc-success"); |
| 10752 | snprintf(buf, sizeof(buf), |
| 10753 | "./wps-ap-nfc.py -1 --no-wait %s%s --success nfc-success", |
| 10754 | dut->summary_log ? "--summary " : "", |
| 10755 | dut->summary_log ? dut->summary_log : ""); |
| 10756 | res = run_nfc_command(dut, buf, "Touch NFC Tag to read it"); |
| 10757 | if (res || !file_exists("nfc-success")) { |
| 10758 | send_resp(dut, conn, SIGMA_ERROR, |
| 10759 | "ErrorCode,Failed to read tag"); |
| 10760 | return 0; |
| 10761 | } |
| 10762 | |
| 10763 | return 1; |
| 10764 | } |
| 10765 | |
| 10766 | |
| 10767 | static int ap_nfc_write_password_token(struct sigma_dut *dut, |
| 10768 | struct sigma_conn *conn, |
| 10769 | struct sigma_cmd *cmd) |
| 10770 | { |
| 10771 | int res; |
| 10772 | char buf[300]; |
| 10773 | |
| 10774 | run_system(dut, "killall wps-ap-nfc.py"); |
| 10775 | unlink("nfc-success"); |
| 10776 | snprintf(buf, sizeof(buf), |
| 10777 | "./wps-ap-nfc.py --no-wait %s%s --success nfc-success write-password", |
| 10778 | dut->summary_log ? "--summary " : "", |
| 10779 | dut->summary_log ? dut->summary_log : ""); |
| 10780 | res = run_nfc_command(dut, buf, |
| 10781 | "Touch NFC Tag to write WPS password token"); |
| 10782 | if (res || !file_exists("nfc-success")) { |
| 10783 | send_resp(dut, conn, SIGMA_ERROR, |
| 10784 | "ErrorCode,Failed to write tag"); |
| 10785 | return 0; |
| 10786 | } |
| 10787 | |
| 10788 | if (run_hostapd_cli(dut, "wps_nfc_token enable") != 0) { |
| 10789 | send_resp(dut, conn, SIGMA_ERROR, |
| 10790 | "ErrorCode,Failed to enable NFC password token"); |
| 10791 | return 0; |
| 10792 | } |
| 10793 | |
| 10794 | return 1; |
| 10795 | } |
| 10796 | |
| 10797 | |
| 10798 | static int ap_nfc_wps_connection_handover(struct sigma_dut *dut, |
| 10799 | struct sigma_conn *conn, |
| 10800 | struct sigma_cmd *cmd) |
| 10801 | { |
| 10802 | int res; |
| 10803 | char buf[300]; |
| 10804 | |
| 10805 | run_system(dut, "killall wps-ap-nfc.py"); |
| 10806 | unlink("nfc-success"); |
| 10807 | snprintf(buf, sizeof(buf), |
| 10808 | "./wps-ap-nfc.py -1 --no-wait %s%s --success nfc-success", |
| 10809 | dut->summary_log ? "--summary " : "", |
| 10810 | dut->summary_log ? dut->summary_log : ""); |
| 10811 | res = run_nfc_command(dut, buf, |
| 10812 | "Touch NFC Device to respond to WPS connection handover"); |
| 10813 | if (res) { |
| 10814 | send_resp(dut, conn, SIGMA_ERROR, |
| 10815 | "ErrorCode,Failed to enable NFC for connection " |
| 10816 | "handover"); |
| 10817 | return 0; |
| 10818 | } |
| 10819 | if (!file_exists("nfc-success")) { |
| 10820 | send_resp(dut, conn, SIGMA_ERROR, |
| 10821 | "ErrorCode,Failed to complete NFC connection handover"); |
| 10822 | return 0; |
| 10823 | } |
| 10824 | |
| 10825 | return 1; |
| 10826 | } |
| 10827 | |
| 10828 | |
Jouni Malinen | f722271 | 2019-06-13 01:50:21 +0300 | [diff] [blame] | 10829 | static enum sigma_cmd_result cmd_ap_nfc_action(struct sigma_dut *dut, |
| 10830 | struct sigma_conn *conn, |
| 10831 | struct sigma_cmd *cmd) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 10832 | { |
| 10833 | /* const char *name = get_param(cmd, "Name"); */ |
| 10834 | /* const char *intf = get_param(cmd, "Interface"); */ |
| 10835 | const char *oper = get_param(cmd, "Operation"); |
| 10836 | |
| 10837 | if (oper == NULL) |
| 10838 | return -1; |
| 10839 | |
| 10840 | if (strcasecmp(oper, "WRITE_CONFIG") == 0) |
| 10841 | return ap_nfc_write_config_token(dut, conn, cmd); |
| 10842 | if (strcasecmp(oper, "WRITE_PASSWD") == 0) |
| 10843 | return ap_nfc_write_password_token(dut, conn, cmd); |
| 10844 | if (strcasecmp(oper, "WPS_READ_PASSWD") == 0) |
| 10845 | return ap_nfc_wps_read_passwd(dut, conn, cmd); |
| 10846 | if (strcasecmp(oper, "WPS_CONN_HNDOVR") == 0) |
| 10847 | return ap_nfc_wps_connection_handover(dut, conn, cmd); |
| 10848 | |
| 10849 | send_resp(dut, conn, SIGMA_ERROR, "ErrorCode,Unsupported operation"); |
| 10850 | return 0; |
| 10851 | } |
| 10852 | |
| 10853 | |
Jouni Malinen | f722271 | 2019-06-13 01:50:21 +0300 | [diff] [blame] | 10854 | static enum sigma_cmd_result cmd_ap_wps_read_pin(struct sigma_dut *dut, |
| 10855 | struct sigma_conn *conn, |
| 10856 | struct sigma_cmd *cmd) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 10857 | { |
| 10858 | char *pin = "12345670"; /* TODO: use random PIN */ |
| 10859 | char resp[100]; |
| 10860 | |
| 10861 | snprintf(resp, sizeof(resp), "PIN,%s", pin); |
| 10862 | send_resp(dut, conn, SIGMA_COMPLETE, resp); |
| 10863 | |
| 10864 | return 0; |
| 10865 | } |
| 10866 | |
| 10867 | |
Jouni Malinen | f722271 | 2019-06-13 01:50:21 +0300 | [diff] [blame] | 10868 | static enum sigma_cmd_result cmd_ap_wps_enter_pin(struct sigma_dut *dut, |
| 10869 | struct sigma_conn *conn, |
| 10870 | struct sigma_cmd *cmd) |
Alexei Avshalom Lazar | 6427969 | 2018-12-23 16:49:49 +0200 | [diff] [blame] | 10871 | { |
| 10872 | const char *pin = get_param(cmd, "PIN"); |
| 10873 | char wps_pin[11]; |
| 10874 | |
| 10875 | if (!pin) |
| 10876 | return -1; |
| 10877 | |
| 10878 | sigma_dut_print(dut, DUT_MSG_DEBUG, |
| 10879 | "Authorize a client to join with WPS PIN %s", pin); |
| 10880 | |
| 10881 | strlcpy(wps_pin, pin, sizeof(wps_pin)); |
| 10882 | /* we need to tolerate extra '-' characters entered */ |
| 10883 | str_remove_chars(wps_pin, '-'); |
| 10884 | strlcpy(dut->wps_pin, wps_pin, sizeof(dut->wps_pin)); |
| 10885 | dut->wps_method = WFA_CS_WPS_PIN_KEYPAD; |
| 10886 | |
| 10887 | return 1; |
| 10888 | } |
| 10889 | |
| 10890 | |
Jouni Malinen | f722271 | 2019-06-13 01:50:21 +0300 | [diff] [blame] | 10891 | static enum sigma_cmd_result cmd_ap_wps_set_pbc(struct sigma_dut *dut, |
| 10892 | struct sigma_conn *conn, |
| 10893 | struct sigma_cmd *cmd) |
Alexei Avshalom Lazar | 6427969 | 2018-12-23 16:49:49 +0200 | [diff] [blame] | 10894 | { |
| 10895 | sigma_dut_print(dut, DUT_MSG_DEBUG, |
| 10896 | "Selecting the push button configuration method"); |
| 10897 | |
| 10898 | dut->wps_method = WFA_CS_WPS_PBC; |
| 10899 | |
| 10900 | return 1; |
| 10901 | } |
| 10902 | |
| 10903 | |
Alexei Avshalom Lazar | 043230b | 2019-02-04 14:11:24 +0200 | [diff] [blame] | 10904 | int ap_wps_registration(struct sigma_dut *dut, struct sigma_conn *conn, |
| 10905 | struct sigma_cmd *cmd) |
| 10906 | { |
| 10907 | char buf[100], resp[256]; |
| 10908 | const char *intf = get_param(cmd, "interface"); |
| 10909 | const char *config_method = get_param(cmd, "WPSConfigMethod"); |
| 10910 | |
| 10911 | if (config_method && strcasecmp(config_method, "PBC") == 0) |
| 10912 | dut->wps_method = WFA_CS_WPS_PBC; |
| 10913 | |
| 10914 | if (!intf) |
Jouni Malinen | 016ae6c | 2019-11-04 17:00:01 +0200 | [diff] [blame] | 10915 | intf = get_main_ifname(dut); |
Alexei Avshalom Lazar | 043230b | 2019-02-04 14:11:24 +0200 | [diff] [blame] | 10916 | |
| 10917 | if (dut->wps_method == WFA_CS_WPS_NOT_READY) { |
| 10918 | send_resp(dut, conn, SIGMA_ERROR, |
| 10919 | "ErrorCode,WPS parameters not yet set"); |
| 10920 | return STATUS_SENT; |
| 10921 | } |
| 10922 | |
| 10923 | if (dut->wps_method == WFA_CS_WPS_PBC) |
| 10924 | snprintf(buf, sizeof(buf), "WPS_PBC"); |
| 10925 | else /* WFA_CS_WPS_PIN_KEYPAD */ |
| 10926 | snprintf(buf, sizeof(buf), "WPS_PIN any %s", dut->wps_pin); |
| 10927 | |
| 10928 | /* Run WPS command */ |
| 10929 | if (hapd_command(intf, buf) < 0) { |
| 10930 | /* command fails immediately if overlapped session detected */ |
| 10931 | snprintf(resp, sizeof(resp), "WpsState,OverlapSession"); |
| 10932 | send_resp(dut, conn, SIGMA_COMPLETE, resp); |
| 10933 | return STATUS_SENT; |
| 10934 | } |
| 10935 | |
| 10936 | /* In AP mode return immediately and do not wait for WPS registration */ |
| 10937 | return SUCCESS_SEND_STATUS; |
| 10938 | } |
| 10939 | |
| 10940 | |
Jouni Malinen | f722271 | 2019-06-13 01:50:21 +0300 | [diff] [blame] | 10941 | static enum sigma_cmd_result cmd_ap_get_parameter(struct sigma_dut *dut, |
| 10942 | struct sigma_conn *conn, |
| 10943 | struct sigma_cmd *cmd) |
Alexei Avshalom Lazar | 0c1d82d | 2018-12-23 17:02:42 +0200 | [diff] [blame] | 10944 | { |
| 10945 | char value[256], resp[512]; |
| 10946 | const char *param = get_param(cmd, "parameter"); |
| 10947 | const char *ifname = get_param(cmd, "Interface"); |
| 10948 | |
| 10949 | if (!ifname) |
Jouni Malinen | 016ae6c | 2019-11-04 17:00:01 +0200 | [diff] [blame] | 10950 | ifname = get_main_ifname(dut); |
Alexei Avshalom Lazar | 0c1d82d | 2018-12-23 17:02:42 +0200 | [diff] [blame] | 10951 | |
| 10952 | if (!param) { |
| 10953 | send_resp(dut, conn, SIGMA_ERROR, |
| 10954 | "ErrorCode,Parameter not specified"); |
| 10955 | return 0; |
| 10956 | } |
| 10957 | |
| 10958 | if (strcasecmp(param, "SSID") == 0) { |
| 10959 | if (get_hapd_config(ifname, "ssid", value, sizeof(value))) { |
| 10960 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 10961 | "Failed to get SSID"); |
| 10962 | return -2; |
| 10963 | } |
| 10964 | snprintf(resp, sizeof(resp), "SSID,%s", value); |
| 10965 | } else if (strcasecmp(param, "PSK") == 0) { |
| 10966 | if (get_hapd_config(ifname, "passphrase", value, |
| 10967 | sizeof(value))) { |
| 10968 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 10969 | "Failed to get PSK"); |
| 10970 | return -2; |
| 10971 | } |
| 10972 | snprintf(resp, sizeof(resp), "PSK,%s", value); |
| 10973 | } else { |
| 10974 | send_resp(dut, conn, SIGMA_ERROR, |
| 10975 | "ErrorCode,Unsupported parameter"); |
| 10976 | return 0; |
| 10977 | } |
| 10978 | |
| 10979 | send_resp(dut, conn, SIGMA_COMPLETE, resp); |
| 10980 | return 0; |
| 10981 | } |
| 10982 | |
| 10983 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 10984 | static int ath_vht_op_mode_notif(struct sigma_dut *dut, const char *ifname, |
| 10985 | const char *val) |
| 10986 | { |
| 10987 | char *token, *result; |
| 10988 | int nss = 0, chwidth = 0; |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 10989 | char *saveptr; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 10990 | |
| 10991 | /* |
| 10992 | * The following commands should be invoked to generate |
| 10993 | * VHT op mode notification |
| 10994 | */ |
| 10995 | |
| 10996 | /* Extract the NSS info */ |
| 10997 | token = strdup(val); |
| 10998 | if (!token) |
| 10999 | return -1; |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 11000 | result = strtok_r(token, ";", &saveptr); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 11001 | if (result) { |
| 11002 | int count = atoi(result); |
| 11003 | |
| 11004 | /* We do not support NSS > 3 */ |
| 11005 | if (count < 0 || count > 3) { |
| 11006 | free(token); |
| 11007 | return -1; |
| 11008 | } |
| 11009 | |
| 11010 | /* Convert nss to chainmask */ |
| 11011 | while (count--) |
| 11012 | nss = (nss << 1) | 1; |
| 11013 | |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 11014 | run_iwpriv(dut, ifname, "rxchainmask %d", nss); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 11015 | } |
| 11016 | |
| 11017 | /* Extract the Channel width info */ |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 11018 | result = strtok_r(NULL, ";", &saveptr); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 11019 | if (result) { |
| 11020 | switch (atoi(result)) { |
| 11021 | case 20: |
| 11022 | chwidth = 0; |
| 11023 | break; |
| 11024 | case 40: |
| 11025 | chwidth = 1; |
| 11026 | break; |
| 11027 | case 80: |
| 11028 | chwidth = 2; |
| 11029 | break; |
| 11030 | case 160: |
| 11031 | chwidth = 3; |
| 11032 | break; |
| 11033 | default: |
| 11034 | chwidth = 2; |
| 11035 | break; |
| 11036 | } |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 11037 | run_iwpriv(dut, ifname, "chwidth %d", chwidth); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 11038 | } |
| 11039 | |
| 11040 | /* Send the opmode notification */ |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 11041 | run_iwpriv(dut, ifname, "opmode_notify 1"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 11042 | free(token); |
| 11043 | |
| 11044 | return 0; |
| 11045 | } |
| 11046 | |
| 11047 | |
| 11048 | static int ath_vht_nss_mcs(struct sigma_dut *dut, const char *ifname, |
| 11049 | const char *val) |
| 11050 | { |
| 11051 | /* String (nss_operating_mode; mcs_operating_mode) */ |
| 11052 | int nss, mcs; |
| 11053 | char *token, *result; |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 11054 | char *saveptr; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 11055 | |
| 11056 | token = strdup(val); |
| 11057 | if (!token) |
| 11058 | return -1; |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 11059 | result = strtok_r(token, ";", &saveptr); |
Pradeep Reddy POTTETI | 41b8c54 | 2016-06-15 16:09:46 +0530 | [diff] [blame] | 11060 | if (!result) { |
| 11061 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 11062 | "VHT NSS not specified"); |
| 11063 | goto end; |
| 11064 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 11065 | if (strcasecmp(result, "def") != 0) { |
| 11066 | nss = atoi(result); |
| 11067 | |
| 11068 | if (nss == 4) |
| 11069 | ath_disable_txbf(dut, ifname); |
| 11070 | |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 11071 | run_iwpriv(dut, ifname, "nss %d", nss); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 11072 | } else { |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 11073 | if (dut->device_type == AP_testbed && dut->ap_sgi80 == 1) |
| 11074 | run_iwpriv(dut, ifname, "nss 1"); |
Priyadharshini Gowthaman | 78ee2ef | 2019-11-15 16:08:28 -0800 | [diff] [blame] | 11075 | if (dut->device_type == AP_testbed && |
| 11076 | dut->program == PROGRAM_HE) { |
| 11077 | nss = dut->ap_tx_streams; |
| 11078 | run_iwpriv(dut, ifname, "nss %d", nss); |
| 11079 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 11080 | } |
| 11081 | |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 11082 | result = strtok_r(NULL, ";", &saveptr); |
Pradeep Reddy POTTETI | 41b8c54 | 2016-06-15 16:09:46 +0530 | [diff] [blame] | 11083 | if (!result) { |
| 11084 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 11085 | "VHT MCS not specified"); |
| 11086 | goto end; |
| 11087 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 11088 | if (strcasecmp(result, "def") == 0) { |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 11089 | if (dut->device_type == AP_testbed && dut->ap_sgi80 == 1) |
| 11090 | run_iwpriv(dut, ifname, "vhtmcs 7"); |
| 11091 | else |
| 11092 | run_iwpriv(dut, ifname, "set11NRates 0"); |
Priyadharshini Gowthaman | 78ee2ef | 2019-11-15 16:08:28 -0800 | [diff] [blame] | 11093 | if (dut->device_type == AP_testbed && |
| 11094 | dut->program == PROGRAM_HE) |
| 11095 | run_iwpriv(dut, ifname, "he_mcs 7"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 11096 | } else { |
| 11097 | mcs = atoi(result); |
Priyadharshini Gowthaman | 78ee2ef | 2019-11-15 16:08:28 -0800 | [diff] [blame] | 11098 | if (dut->program == PROGRAM_HE) |
| 11099 | run_iwpriv(dut, ifname, "he_mcs %d", mcs); |
| 11100 | else |
| 11101 | run_iwpriv(dut, ifname, "vhtmcs %d", mcs); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 11102 | } |
| 11103 | |
Pradeep Reddy POTTETI | 41b8c54 | 2016-06-15 16:09:46 +0530 | [diff] [blame] | 11104 | end: |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 11105 | free(token); |
| 11106 | return 0; |
| 11107 | } |
| 11108 | |
| 11109 | |
| 11110 | static int ath_vht_chnum_band(struct sigma_dut *dut, const char *ifname, |
| 11111 | const char *val) |
| 11112 | { |
| 11113 | char *token, *result; |
| 11114 | int channel = 36; |
| 11115 | int chwidth = 80; |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 11116 | char *saveptr; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 11117 | |
| 11118 | /* Extract the channel info */ |
| 11119 | token = strdup(val); |
| 11120 | if (!token) |
| 11121 | return -1; |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 11122 | result = strtok_r(token, ";", &saveptr); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 11123 | if (result) |
| 11124 | channel = atoi(result); |
| 11125 | |
| 11126 | /* Extract the channel width info */ |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 11127 | result = strtok_r(NULL, ";", &saveptr); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 11128 | if (result) |
| 11129 | chwidth = atoi(result); |
| 11130 | |
| 11131 | /* Issue the channel switch command */ |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 11132 | run_iwpriv(dut, ifname, "doth_ch_chwidth %d 10 %d", channel, chwidth); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 11133 | |
| 11134 | free(token); |
| 11135 | return 0; |
| 11136 | } |
| 11137 | |
| 11138 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 11139 | static int ath_ndpa_stainfo_mac(struct sigma_dut *dut, const char *ifname, |
| 11140 | const char *val) |
| 11141 | { |
| 11142 | char buf[80]; |
| 11143 | unsigned char mac_addr[6]; |
| 11144 | |
| 11145 | if (parse_mac_address(dut, val, mac_addr) < 0) |
| 11146 | return -1; |
| 11147 | |
| 11148 | snprintf(buf, sizeof(buf), |
| 11149 | "wifitool %s beeliner_fw_test 92 0x%02x%02x%02x%02x", |
| 11150 | ifname, mac_addr[0], mac_addr[1], mac_addr[2], mac_addr[3]); |
| 11151 | run_system(dut, buf); |
| 11152 | |
| 11153 | snprintf(buf, sizeof(buf), "wifitool %s beeliner_fw_test 93 0x%02x%02x", |
| 11154 | ifname, mac_addr[4], mac_addr[5]); |
| 11155 | run_system(dut, buf); |
| 11156 | |
| 11157 | snprintf(buf, sizeof(buf), "wifitool %s beeliner_fw_test 94 1", ifname); |
| 11158 | run_system(dut, buf); |
| 11159 | |
| 11160 | return 0; |
| 11161 | } |
| 11162 | |
| 11163 | |
Priyadharshini Gowthaman | 8c5b9a4 | 2019-07-31 14:38:48 -0700 | [diff] [blame] | 11164 | void novap_reset(struct sigma_dut *dut, const char *ifname, int reset) |
Priyadharshini Gowthaman | 39beafa | 2015-11-09 14:11:25 -0800 | [diff] [blame] | 11165 | { |
Priyadharshini Gowthaman | 8c5b9a4 | 2019-07-31 14:38:48 -0700 | [diff] [blame] | 11166 | run_iwpriv(dut, ifname, "novap_reset %d", reset); |
Priyadharshini Gowthaman | 39beafa | 2015-11-09 14:11:25 -0800 | [diff] [blame] | 11167 | } |
| 11168 | |
| 11169 | |
Jouni Malinen | b433543 | 2019-06-13 02:23:57 +0300 | [diff] [blame] | 11170 | static struct mbo_pref_ap * mbo_find_nebor_ap_entry(struct sigma_dut *dut, |
| 11171 | const uint8_t *mac_addr) |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 11172 | { |
Adil Saeed Musthafa | 6906372 | 2017-04-10 23:13:40 -0700 | [diff] [blame] | 11173 | int i; |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 11174 | |
Adil Saeed Musthafa | 6906372 | 2017-04-10 23:13:40 -0700 | [diff] [blame] | 11175 | for (i = 0; i < dut->mbo_pref_ap_cnt; i++) { |
| 11176 | if (memcmp(mac_addr, dut->mbo_pref_aps[i].mac_addr, |
| 11177 | ETH_ALEN) == 0) |
| 11178 | return &dut->mbo_pref_aps[i]; |
| 11179 | } |
| 11180 | return NULL; |
| 11181 | } |
| 11182 | |
| 11183 | |
| 11184 | static void mbo_add_nebor_entry(struct sigma_dut *dut, const uint8_t *mac_addr, |
| 11185 | int ap_ne_class, int ap_ne_op_ch, |
| 11186 | int ap_ne_pref) |
| 11187 | { |
| 11188 | struct mbo_pref_ap *entry; |
| 11189 | uint8_t self_mac[ETH_ALEN]; |
| 11190 | char ifname[50]; |
| 11191 | |
| 11192 | get_if_name(dut, ifname, sizeof(ifname), 1); |
| 11193 | get_hwaddr(ifname, self_mac); |
| 11194 | |
| 11195 | if (memcmp(mac_addr, self_mac, ETH_ALEN) == 0) |
| 11196 | entry = &dut->mbo_self_ap_tuple; |
| 11197 | else |
| 11198 | entry = mbo_find_nebor_ap_entry(dut, mac_addr); |
| 11199 | |
| 11200 | if (!entry) { |
| 11201 | if (dut->mbo_pref_ap_cnt >= MBO_MAX_PREF_BSSIDS) { |
| 11202 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 11203 | "Nebor AP List is full. Not adding"); |
| 11204 | return; |
| 11205 | } |
| 11206 | entry = &dut->mbo_pref_aps[dut->mbo_pref_ap_cnt]; |
| 11207 | dut->mbo_pref_ap_cnt++; |
| 11208 | memcpy(entry->mac_addr, mac_addr, ETH_ALEN); |
| 11209 | entry->ap_ne_class = -1; |
| 11210 | entry->ap_ne_op_ch = -1; |
| 11211 | entry->ap_ne_pref = -1; |
| 11212 | } |
| 11213 | if (ap_ne_class != -1) |
| 11214 | entry->ap_ne_class = ap_ne_class; |
| 11215 | if (ap_ne_op_ch != -1) |
| 11216 | entry->ap_ne_op_ch = ap_ne_op_ch; |
| 11217 | if (ap_ne_pref != -1) |
| 11218 | entry->ap_ne_pref = ap_ne_pref; |
| 11219 | } |
| 11220 | |
| 11221 | |
| 11222 | static int ath_set_nebor_bssid(struct sigma_dut *dut, const char *ifname, |
| 11223 | struct sigma_cmd *cmd) |
| 11224 | { |
| 11225 | unsigned char mac_addr[ETH_ALEN]; |
| 11226 | const char *val; |
| 11227 | /* |
| 11228 | * -1 is invalid value for the following |
| 11229 | * to differentiate between unset and set values |
| 11230 | * -1 => implies not set by CAPI |
| 11231 | */ |
| 11232 | int ap_ne_class = -1, ap_ne_op_ch = -1, ap_ne_pref = -1; |
| 11233 | int list_offset = dut->mbo_pref_ap_cnt; |
| 11234 | |
| 11235 | if (list_offset >= MBO_MAX_PREF_BSSIDS) { |
| 11236 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 11237 | "AP Pref Entry list is full"); |
| 11238 | return -1; |
| 11239 | } |
| 11240 | |
| 11241 | val = get_param(cmd, "Nebor_Op_Class"); |
| 11242 | if (val) |
| 11243 | ap_ne_class = atoi(val); |
| 11244 | |
| 11245 | val = get_param(cmd, "Nebor_Op_Ch"); |
| 11246 | if (val) |
| 11247 | ap_ne_op_ch = atoi(val); |
| 11248 | |
| 11249 | val = get_param(cmd, "Nebor_Pref"); |
| 11250 | if (val) |
| 11251 | ap_ne_pref = atoi(val); |
| 11252 | |
| 11253 | val = get_param(cmd, "Nebor_BSSID"); |
| 11254 | if (!val || parse_mac_address(dut, val, mac_addr) < 0) |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 11255 | return -1; |
| 11256 | |
Adil Saeed Musthafa | 6906372 | 2017-04-10 23:13:40 -0700 | [diff] [blame] | 11257 | mbo_add_nebor_entry(dut, mac_addr, ap_ne_class, ap_ne_op_ch, |
| 11258 | ap_ne_pref); |
| 11259 | apply_mbo_pref_ap_list(dut); |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 11260 | return 0; |
| 11261 | } |
| 11262 | |
| 11263 | |
Priyadharshini Gowthaman | c067edf | 2019-06-20 11:23:27 -0700 | [diff] [blame] | 11264 | static enum sigma_cmd_result he_ltf(struct sigma_dut *dut, |
| 11265 | struct sigma_conn *conn, |
| 11266 | const char *ifname, const char *val) |
| 11267 | { |
| 11268 | const char *var; |
| 11269 | |
| 11270 | if (dut->ap_he_ulofdma == VALUE_ENABLED) |
| 11271 | var = "he_ul_ltf"; |
| 11272 | else |
| 11273 | var = "he_ltf"; |
| 11274 | |
| 11275 | if (strcmp(val, "6.4") == 0) { |
| 11276 | run_iwpriv(dut, ifname, "%s 2", var); |
| 11277 | } else if (strcmp(val, "12.8") == 0) { |
| 11278 | run_iwpriv(dut, ifname, "%s 3", var); |
| 11279 | } else if (strcmp(val, "3.2") == 0) { |
| 11280 | run_iwpriv(dut, ifname, "%s 1", var); |
| 11281 | } else { |
| 11282 | send_resp(dut, conn, SIGMA_ERROR, "errorCode,Unsupported LTF"); |
| 11283 | return STATUS_SENT_ERROR; |
| 11284 | } |
| 11285 | |
| 11286 | return SUCCESS_SEND_STATUS; |
| 11287 | } |
| 11288 | |
| 11289 | |
Priyadharshini Gowthaman | cc6ff5a | 2019-06-20 11:23:52 -0700 | [diff] [blame] | 11290 | static enum sigma_cmd_result he_shortgi(struct sigma_dut *dut, |
| 11291 | struct sigma_conn *conn, |
| 11292 | const char *ifname, |
| 11293 | const char *val) |
| 11294 | { |
| 11295 | const char *var; |
| 11296 | |
| 11297 | if (dut->ap_he_ulofdma == VALUE_ENABLED) |
| 11298 | var = "he_ul_shortgi"; |
| 11299 | else |
| 11300 | var = "shortgi"; |
| 11301 | |
| 11302 | if (strcmp(val, "0.8") == 0) { |
| 11303 | run_iwpriv(dut, ifname, "%s 0", var); |
| 11304 | } else if (strcmp(val, "1.6") == 0) { |
| 11305 | run_iwpriv(dut, ifname, "%s 2", var); |
| 11306 | } else if (strcmp(val, "3.2") == 0) { |
| 11307 | run_iwpriv(dut, ifname, "%s 3", var); |
| 11308 | } else { |
| 11309 | send_resp(dut, conn, SIGMA_ERROR, |
| 11310 | "errorCode,Unsupported shortGI"); |
| 11311 | return STATUS_SENT_ERROR; |
| 11312 | } |
| 11313 | |
| 11314 | return SUCCESS_SEND_STATUS; |
| 11315 | } |
| 11316 | |
| 11317 | |
| 11318 | static enum sigma_cmd_result he_ar_gi_ltf_mask(struct sigma_dut *dut, |
| 11319 | struct sigma_conn *conn, |
| 11320 | const char *ifname, |
| 11321 | const char *val) |
| 11322 | { |
| 11323 | |
| 11324 | uint32_t he_ar_gi_ltf; |
| 11325 | uint16_t he_ar_gi, he_ar_ltf; |
| 11326 | |
| 11327 | if (strcmp(val, "0.4") == 0) { |
| 11328 | he_ar_gi = 0x01; |
| 11329 | } else if (strcmp(val, "0.8") == 0) { |
| 11330 | he_ar_gi = 0x02; |
| 11331 | } else if (strcmp(val, "1.6") == 0) { |
| 11332 | he_ar_gi = 0x04; |
| 11333 | } else if (strcmp(val, "3.2") == 0) { |
| 11334 | he_ar_gi = 0x08; |
| 11335 | } else { |
| 11336 | send_resp(dut, conn, SIGMA_ERROR, |
| 11337 | "errorCode,Unsupported shortGI"); |
| 11338 | return STATUS_SENT_ERROR; |
| 11339 | } |
| 11340 | |
| 11341 | if (dut->ar_ltf && strcmp(dut->ar_ltf, "6.4") == 0) { |
| 11342 | he_ar_ltf = 0x02; |
| 11343 | } else if (dut->ar_ltf && strcmp(dut->ar_ltf, "12.8") == 0) { |
| 11344 | he_ar_ltf = 0x04; |
| 11345 | } else if (dut->ar_ltf && strcmp(dut->ar_ltf, "3.2") == 0) { |
| 11346 | he_ar_ltf = 0x01; |
| 11347 | } else { |
| 11348 | send_resp(dut, conn, SIGMA_ERROR, |
| 11349 | "errorCode,Unsupported LTF"); |
| 11350 | return STATUS_SENT_ERROR; |
| 11351 | } |
| 11352 | |
| 11353 | he_ar_gi_ltf = (he_ar_gi << 8) | he_ar_ltf; |
| 11354 | run_iwpriv(dut, ifname, "he_ar_gi_ltf %lu", he_ar_gi_ltf); |
| 11355 | |
| 11356 | return SUCCESS_SEND_STATUS; |
| 11357 | } |
| 11358 | |
| 11359 | |
Priyadharshini Gowthaman | 9e7d831 | 2019-06-20 11:24:03 -0700 | [diff] [blame] | 11360 | static enum sigma_cmd_result he_rualloctones(struct sigma_dut *dut, |
| 11361 | struct sigma_conn *conn, |
| 11362 | const char *ifname, |
| 11363 | const char *val) |
| 11364 | { |
| 11365 | char *token, *result; |
| 11366 | int value; |
| 11367 | char *saveptr; |
| 11368 | int rualloc_type; |
| 11369 | enum sigma_cmd_result ret = SUCCESS_SEND_STATUS; |
| 11370 | |
| 11371 | token = strdup(val); |
| 11372 | if (!token) |
| 11373 | return -1; |
| 11374 | result = strtok_r(token, ":", &saveptr); |
| 11375 | if (!result) { |
| 11376 | free(token); |
| 11377 | send_resp(dut, conn, SIGMA_ERROR, |
| 11378 | "errorCode,RUAllocTones not specified"); |
| 11379 | return STATUS_SENT_ERROR; |
| 11380 | } |
| 11381 | |
| 11382 | /* |
| 11383 | * ru_allocation_type can take the values of: |
| 11384 | * 1 - DL OFDMA data RU allocation |
| 11385 | * 3 - UL OFDMA data RU allocation |
| 11386 | */ |
| 11387 | rualloc_type = dut->ap_he_ulofdma == VALUE_ENABLED ? 3 : 1; |
| 11388 | |
| 11389 | |
| 11390 | value = atoi(result); |
| 11391 | if (value == 106) { |
| 11392 | enum value_not_set_enabled_disabled ap_he_rualloc_106_80 = |
| 11393 | VALUE_NOT_SET; |
| 11394 | |
| 11395 | result = strtok_r(NULL, ":", &saveptr); |
| 11396 | if (result) { |
| 11397 | result = strtok_r(NULL, ":", &saveptr); |
| 11398 | if (result) |
| 11399 | ap_he_rualloc_106_80 = VALUE_ENABLED; |
| 11400 | else |
| 11401 | ap_he_rualloc_106_80 = VALUE_DISABLED; |
| 11402 | } |
| 11403 | if (ap_he_rualloc_106_80 == VALUE_ENABLED) { |
| 11404 | run_system_wrapper(dut, |
| 11405 | "wifitool %s setUnitTestCmd 0x4b 9 %d 0 2 1 2 2 2 3 2", |
| 11406 | ifname, rualloc_type); |
| 11407 | } else { |
| 11408 | run_system_wrapper(dut, |
| 11409 | "wifitool %s setUnitTestCmd 0x4b 5 %d 0 2 1 2", |
| 11410 | ifname, rualloc_type); |
| 11411 | } |
| 11412 | } else if (value == 242) { |
| 11413 | run_system_wrapper( |
| 11414 | dut, |
| 11415 | "wifitool %s setUnitTestCmd 0x4b 9 %d 0 3 1 3 2 3 3 3", |
| 11416 | ifname, rualloc_type); |
| 11417 | } else if (value == 26) { |
| 11418 | run_system_wrapper( |
| 11419 | dut, |
| 11420 | "wifitool %s setUnitTestCmd 0x4b 9 %d 0 0 2 0 5 0 7 0", |
| 11421 | ifname, rualloc_type); |
| 11422 | } else if (value == 52) { |
| 11423 | run_system_wrapper( |
| 11424 | dut, |
| 11425 | "wifitool %s setUnitTestCmd 0x4b 9 %d 0 1 1 1 2 1 3 1", |
| 11426 | ifname, rualloc_type); |
| 11427 | } else if (value == 484) { |
| 11428 | run_system_wrapper( |
| 11429 | dut, |
| 11430 | "wifitool %s setUnitTestCmd 0x4b 5 %d 0 4 1 4", |
| 11431 | ifname, rualloc_type); |
| 11432 | } else if (value == 996) { |
| 11433 | run_system_wrapper(dut, |
| 11434 | "wifitool %s setUnitTestCmd 0x4b 3 %d 0 5", |
| 11435 | ifname, rualloc_type); |
| 11436 | } else { |
| 11437 | send_resp(dut, conn, SIGMA_ERROR, |
| 11438 | "errorCode,Unsupported RUAllocTones"); |
| 11439 | ret = STATUS_SENT_ERROR; |
| 11440 | } |
| 11441 | |
| 11442 | free(token); |
| 11443 | return ret; |
| 11444 | } |
| 11445 | |
| 11446 | |
Priyadharshini Gowthaman | 7e43870 | 2019-08-09 12:05:05 -0700 | [diff] [blame] | 11447 | static void ath_set_trigger_type_0(struct sigma_dut *dut, const char *ifname) |
| 11448 | { |
| 11449 | /* TriggerType "0" for Basic trigger */ |
| 11450 | if (dut->ap_channel >= 36) { |
| 11451 | /* 1 and 2 here is interpreted to 5g and 2g (bitmasks) */ |
| 11452 | run_system_wrapper(dut, |
| 11453 | "wifitool %s setUnitTestCmd 0x47 2 42 1", |
| 11454 | ifname); |
| 11455 | } else { |
| 11456 | run_system_wrapper(dut, |
| 11457 | "wifitool %s setUnitTestCmd 0x47 2 42 2", |
| 11458 | ifname); |
| 11459 | } |
| 11460 | run_system_wrapper(dut, "wifitool %s setUnitTestCmd 0x47 2 43 6", |
| 11461 | ifname); |
| 11462 | } |
| 11463 | |
| 11464 | |
| 11465 | static void ath_set_trigger_type_1(struct sigma_dut *dut, const char *ifname) |
| 11466 | { |
| 11467 | /* TriggerType "1" for MU BRP */ |
| 11468 | run_system_wrapper(dut, "wifitool %s setUnitTestCmd 0x47 2 7 1", |
| 11469 | ifname); |
| 11470 | mubrp_commands(dut, ifname); |
| 11471 | } |
| 11472 | |
| 11473 | |
| 11474 | static void ath_set_trigger_type_2(struct sigma_dut *dut, const char *ifname) |
| 11475 | { |
| 11476 | /* TriggerType "2" for MU BAR */ |
| 11477 | if (dut->ap_channel >= 36) { |
| 11478 | /* RU allocation RU 242 - DL OFDMA data */ |
| 11479 | run_system_wrapper(dut, |
| 11480 | "wifitool %s setUnitTestCmd 0x4b 5 9 0 3 1 3 2 3 3 3", |
| 11481 | ifname); |
| 11482 | /* RU allocation RU 52 - UL BA */ |
| 11483 | run_system_wrapper(dut, |
| 11484 | "wifitool %s setUnitTestCmd 0x4b 5 9 0 2 1 2 2 2 3 2", |
| 11485 | ifname); |
| 11486 | } else { |
| 11487 | /* RU allocation RU 52 - DL ofdma data */ |
| 11488 | run_system_wrapper(dut, |
| 11489 | "wifitool %s setUnitTestCmd 0x4b 5 9 0 1 1 1 2 1 3 1", |
| 11490 | ifname); |
| 11491 | } |
| 11492 | /* Force TBPPDU duration to 400 us */ |
| 11493 | run_system_wrapper(dut, "wifitool %s setUnitTestCmd 0x48 2 63 400", |
| 11494 | ifname); |
| 11495 | /* 0 to enable MU BAR, 1 to enable SU BAR */ |
| 11496 | run_system_wrapper(dut, "wifitool %s setUnitTestCmd 0x47 2 49 0", |
| 11497 | ifname); |
| 11498 | /* MU BAR */ |
| 11499 | run_system_wrapper(dut, "wifitool %s setUnitTestCmd 0x47 2 64 0", |
| 11500 | ifname); |
| 11501 | } |
| 11502 | |
| 11503 | |
| 11504 | static void ath_set_trigger_type_3(struct sigma_dut *dut, const char *ifname) |
| 11505 | { |
| 11506 | /* TriggerType "3" for MU RTS */ |
| 11507 | /* Send MU RTS Trigger - '1' is to enable MU RTS */ |
| 11508 | run_system_wrapper(dut, "wifitool %s setUnitTestCmd 0x47 2 101 1", |
| 11509 | ifname); |
| 11510 | } |
| 11511 | |
| 11512 | |
| 11513 | static void ath_set_trigger_type_4(struct sigma_dut *dut, const char *ifname, |
| 11514 | const char *basedev) |
| 11515 | { |
| 11516 | /* TriggerType "4" for BSRP */ |
| 11517 | run_system_wrapper(dut, "cfg80211tool %s he_ul_trig_int 200", basedev); |
| 11518 | run_system_wrapper(dut, "wifitool %s setUnitTestCmd 0x48 2 63 1000", |
| 11519 | ifname); |
| 11520 | if (dut->ap_channel >= 36) { |
| 11521 | run_system_wrapper(dut, |
| 11522 | "wifitool %s setUnitTestCmd 0x47 2 42 1", |
| 11523 | ifname); |
| 11524 | } else { |
| 11525 | run_system_wrapper(dut, |
| 11526 | "wifitool %s setUnitTestCmd 0x47 2 42 2", |
| 11527 | ifname); |
| 11528 | } |
| 11529 | /* Send BSRP command */ |
| 11530 | run_system_wrapper(dut, "wifitool %s setUnitTestCmd 0x47 2 43 7", |
| 11531 | ifname); |
| 11532 | } |
| 11533 | |
| 11534 | |
Jouni Malinen | 6076ffc | 2019-08-08 18:18:02 +0300 | [diff] [blame] | 11535 | static enum sigma_cmd_result ath_ap_set_rfeature(struct sigma_dut *dut, |
| 11536 | struct sigma_conn *conn, |
| 11537 | struct sigma_cmd *cmd) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 11538 | { |
| 11539 | const char *val; |
Jouni Malinen | 016ae6c | 2019-11-04 17:00:01 +0200 | [diff] [blame] | 11540 | const char *ifname; |
Priyadharshini Gowthaman | c067edf | 2019-06-20 11:23:27 -0700 | [diff] [blame] | 11541 | enum sigma_cmd_result res; |
Priyadharshini Gowthaman | f8c032d | 2019-07-31 14:38:02 -0700 | [diff] [blame] | 11542 | const char *basedev = "wifi0"; |
Priyadharshini Gowthaman | 2f8c317 | 2019-07-31 14:38:12 -0700 | [diff] [blame] | 11543 | int trigtype; |
Priyadharshini Gowthaman | 51c0fec | 2019-08-09 12:04:05 -0700 | [diff] [blame] | 11544 | int he_ackpolicymac = 0; |
Priyadharshini Gowthaman | e87e2c9 | 2019-08-09 12:04:31 -0700 | [diff] [blame] | 11545 | char *num_ss = NULL; |
| 11546 | char *nss[4] = { NULL, NULL, NULL, NULL }; |
Priyadharshini Gowthaman | dca0c54 | 2019-08-09 12:04:42 -0700 | [diff] [blame] | 11547 | char *aid[4] = { NULL, NULL, NULL, NULL }; |
| 11548 | char *aid_ss = NULL; |
Priyadharshini Gowthaman | 2da1ecc | 2019-08-09 12:04:54 -0700 | [diff] [blame] | 11549 | int omctrl_rxnss = 0, omctrl_chwidth = 0; |
Priyadharshini Gowthaman | 872fb29 | 2019-08-09 12:05:27 -0700 | [diff] [blame] | 11550 | int param; |
Priyadharshini Gowthaman | 51c0fec | 2019-08-09 12:04:05 -0700 | [diff] [blame] | 11551 | unsigned char mac_addr[ETH_ALEN]; |
| 11552 | |
| 11553 | memset(mac_addr, 0x00, ETH_ALEN); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 11554 | |
Jouni Malinen | 016ae6c | 2019-11-04 17:00:01 +0200 | [diff] [blame] | 11555 | ifname = get_main_ifname(dut); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 11556 | |
Priyadharshini Gowthaman | f8c032d | 2019-07-31 14:38:02 -0700 | [diff] [blame] | 11557 | if (sigma_radio_ifname[0]) |
| 11558 | basedev = sigma_radio_ifname[0]; |
| 11559 | |
Priyadharshini Gowthaman | 39beafa | 2015-11-09 14:11:25 -0800 | [diff] [blame] | 11560 | /* Disable vap reset between the commands */ |
Priyadharshini Gowthaman | 8c5b9a4 | 2019-07-31 14:38:48 -0700 | [diff] [blame] | 11561 | novap_reset(dut, ifname, 1); |
Priyadharshini Gowthaman | 39beafa | 2015-11-09 14:11:25 -0800 | [diff] [blame] | 11562 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 11563 | val = get_param(cmd, "Opt_md_notif_ie"); |
| 11564 | if (val && ath_vht_op_mode_notif(dut, ifname, val) < 0) |
Jouni Malinen | 6076ffc | 2019-08-08 18:18:02 +0300 | [diff] [blame] | 11565 | return ERROR_SEND_STATUS; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 11566 | |
| 11567 | /* TODO: Optional arguments */ |
| 11568 | |
| 11569 | val = get_param(cmd, "nss_mcs_opt"); |
| 11570 | if (val && ath_vht_nss_mcs(dut, ifname, val) < 0) |
Jouni Malinen | 6076ffc | 2019-08-08 18:18:02 +0300 | [diff] [blame] | 11571 | return ERROR_SEND_STATUS; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 11572 | |
| 11573 | val = get_param(cmd, "chnum_band"); |
| 11574 | if (val && ath_vht_chnum_band(dut, ifname, val) < 0) |
Jouni Malinen | 6076ffc | 2019-08-08 18:18:02 +0300 | [diff] [blame] | 11575 | return ERROR_SEND_STATUS; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 11576 | |
| 11577 | val = get_param(cmd, "RTS_FORCE"); |
| 11578 | if (val) |
| 11579 | ath_config_rts_force(dut, ifname, val); |
| 11580 | |
| 11581 | val = get_param(cmd, "DYN_BW_SGNL"); |
| 11582 | if (val) |
| 11583 | ath_config_dyn_bw_sig(dut, ifname, val); |
| 11584 | |
| 11585 | val = get_param(cmd, "CTS_WIDTH"); |
| 11586 | if (val) |
| 11587 | ath_set_cts_width(dut, ifname, val); |
| 11588 | |
| 11589 | val = get_param(cmd, "Ndpa_stainfo_mac"); |
| 11590 | if (val && ath_ndpa_stainfo_mac(dut, ifname, val) < 0) |
Jouni Malinen | 6076ffc | 2019-08-08 18:18:02 +0300 | [diff] [blame] | 11591 | return ERROR_SEND_STATUS; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 11592 | |
| 11593 | val = get_param(cmd, "txBandwidth"); |
| 11594 | if (val && ath_set_width(dut, conn, ifname, val) < 0) |
Jouni Malinen | 6076ffc | 2019-08-08 18:18:02 +0300 | [diff] [blame] | 11595 | return ERROR_SEND_STATUS; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 11596 | |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 11597 | val = get_param(cmd, "Assoc_Disallow"); |
| 11598 | if (val) |
| 11599 | ath_set_assoc_disallow(dut, ifname, val); |
| 11600 | |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 11601 | |
Adil Saeed Musthafa | 6906372 | 2017-04-10 23:13:40 -0700 | [diff] [blame] | 11602 | ath_set_nebor_bssid(dut, ifname, cmd); |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 11603 | val = get_param(cmd, "BTMReq_DisAssoc_Imnt"); |
priyadharshini gowthaman | 776562e | 2017-12-20 12:33:34 -0800 | [diff] [blame] | 11604 | if (val) { |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 11605 | dut->ap_btmreq_disassoc_imnt = atoi(val); |
priyadharshini gowthaman | 776562e | 2017-12-20 12:33:34 -0800 | [diff] [blame] | 11606 | dut->ap_disassoc_timer = 1000; |
| 11607 | } |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 11608 | |
| 11609 | val = get_param(cmd, "BTMReq_Term_Bit"); |
| 11610 | if (val) |
| 11611 | dut->ap_btmreq_term_bit = atoi(val); |
| 11612 | |
Adil Saeed Musthafa | 48c5ab9 | 2017-04-10 23:13:35 -0700 | [diff] [blame] | 11613 | val = get_param(cmd, "Assoc_Delay"); |
priyadharshini gowthaman | 776562e | 2017-12-20 12:33:34 -0800 | [diff] [blame] | 11614 | if (val) { |
| 11615 | dut->ap_assoc_delay = 1; |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 11616 | run_iwpriv(dut, ifname, "mbo_asoc_ret %s", val); |
priyadharshini gowthaman | 776562e | 2017-12-20 12:33:34 -0800 | [diff] [blame] | 11617 | } |
Adil Saeed Musthafa | 48c5ab9 | 2017-04-10 23:13:35 -0700 | [diff] [blame] | 11618 | |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 11619 | val = get_param(cmd, "Disassoc_Timer"); |
| 11620 | if (val) |
| 11621 | dut->ap_disassoc_timer = atoi(val); |
| 11622 | |
| 11623 | val = get_param(cmd, "BSS_Term_Duration"); |
| 11624 | if (val) |
| 11625 | dut->ap_btmreq_bss_term_dur = atoi(val); |
| 11626 | |
priyadharshini gowthaman | 94062b5 | 2017-12-20 12:33:34 -0800 | [diff] [blame] | 11627 | val = get_param(cmd, "BSS_Term_TSF"); |
| 11628 | if (val) |
| 11629 | dut->ap_btmreq_bss_term_tsf = atoi(val); |
| 11630 | |
priyadharshini gowthaman | cb22e43 | 2017-12-28 15:23:31 -0800 | [diff] [blame] | 11631 | val = get_param(cmd, "TxPower"); |
| 11632 | if (val) |
| 11633 | ath_set_txpower(dut, ifname, val); |
| 11634 | |
| 11635 | val = get_param(cmd, "DownlinkAvailCap"); |
| 11636 | if (val) |
| 11637 | dut->ap_dl_availcap = atoi(val); |
| 11638 | |
| 11639 | val = get_param(cmd, "UplinkAvailCap"); |
| 11640 | if (val) { |
| 11641 | dut->ap_ul_availcap = atoi(val); |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 11642 | run_iwpriv(dut, ifname, "oce_wan_mtr %d %d", |
| 11643 | dut->ap_dl_availcap, dut->ap_ul_availcap); |
priyadharshini gowthaman | cb22e43 | 2017-12-28 15:23:31 -0800 | [diff] [blame] | 11644 | } |
| 11645 | |
| 11646 | val = get_param(cmd, "RSSIthreshold"); |
| 11647 | if (val) { |
| 11648 | int rssithreshold; |
| 11649 | |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 11650 | run_iwpriv(dut, ifname, "oce_asoc_rej 1"); |
priyadharshini gowthaman | cb22e43 | 2017-12-28 15:23:31 -0800 | [diff] [blame] | 11651 | rssithreshold = atoi(val); |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 11652 | run_iwpriv(dut, ifname, "oce_asoc_rssi %d", rssithreshold); |
priyadharshini gowthaman | cb22e43 | 2017-12-28 15:23:31 -0800 | [diff] [blame] | 11653 | } |
| 11654 | |
| 11655 | val = get_param(cmd, "RetryDelay"); |
| 11656 | if (val) { |
| 11657 | int retrydelay; |
| 11658 | |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 11659 | run_iwpriv(dut, ifname, "oce_asoc_rej 1"); |
priyadharshini gowthaman | cb22e43 | 2017-12-28 15:23:31 -0800 | [diff] [blame] | 11660 | retrydelay = atoi(val); |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 11661 | run_iwpriv(dut, ifname, "oce_asoc_dly %d", retrydelay); |
priyadharshini gowthaman | cb22e43 | 2017-12-28 15:23:31 -0800 | [diff] [blame] | 11662 | } |
| 11663 | |
Priyadharshini Gowthaman | c067edf | 2019-06-20 11:23:27 -0700 | [diff] [blame] | 11664 | val = get_param(cmd, "LTF"); |
| 11665 | if (val) { |
| 11666 | if (dut->ap_fixed_rate) { |
| 11667 | res = he_ltf(dut, conn, ifname, val); |
| 11668 | if (res != SUCCESS_SEND_STATUS) |
| 11669 | return res; |
| 11670 | } else { |
| 11671 | free(dut->ar_ltf); |
| 11672 | dut->ar_ltf = strdup(val); |
| 11673 | if (!dut->ar_ltf) |
Jouni Malinen | 6076ffc | 2019-08-08 18:18:02 +0300 | [diff] [blame] | 11674 | return ERROR_SEND_STATUS; |
Priyadharshini Gowthaman | c067edf | 2019-06-20 11:23:27 -0700 | [diff] [blame] | 11675 | } |
| 11676 | } |
| 11677 | |
Priyadharshini Gowthaman | cc6ff5a | 2019-06-20 11:23:52 -0700 | [diff] [blame] | 11678 | val = get_param(cmd, "GI"); |
| 11679 | if (val) { |
| 11680 | if (dut->ap_fixed_rate) |
| 11681 | res = he_shortgi(dut, conn, ifname, val); |
| 11682 | else |
| 11683 | res = he_ar_gi_ltf_mask(dut, conn, ifname, val); |
| 11684 | if (res != SUCCESS_SEND_STATUS) |
| 11685 | return res; |
| 11686 | } |
| 11687 | |
Priyadharshini Gowthaman | 9e7d831 | 2019-06-20 11:24:03 -0700 | [diff] [blame] | 11688 | val = get_param(cmd, "RUAllocTones"); |
| 11689 | if (val) { |
| 11690 | res = he_rualloctones(dut, conn, ifname, val); |
| 11691 | if (res != SUCCESS_SEND_STATUS) |
| 11692 | return res; |
| 11693 | } |
| 11694 | |
Priyadharshini Gowthaman | 803fd66 | 2019-07-31 14:37:49 -0700 | [diff] [blame] | 11695 | val = get_param(cmd, "MPDU_MU_SpacingFactor"); |
| 11696 | if (val) |
| 11697 | run_system_wrapper(dut, |
| 11698 | "wifitool %s setUnitTestCmd 0x48 2 119, %s", |
| 11699 | ifname, val); |
| 11700 | |
| 11701 | val = get_param(cmd, "PPDUTxType"); |
| 11702 | if (val) { |
| 11703 | if (strcasecmp(val, "HE-SU") == 0) { |
| 11704 | /* Change PPDU format type to HE-SU MCS 1 */ |
| 11705 | run_system_wrapper(dut, |
| 11706 | "wifitool %s setUnitTestCmd 0x48 2 89 0x401", |
| 11707 | ifname); |
| 11708 | } else if (strcasecmp(val, "legacy") == 0) { |
| 11709 | /* Change PPDU format type to non-HT */ |
| 11710 | run_system_wrapper(dut, |
| 11711 | "wifitool %s setUnitTestCmd 0x48 2 89 3", |
| 11712 | ifname); |
| 11713 | } else { |
| 11714 | send_resp(dut, conn, SIGMA_ERROR, |
| 11715 | "errorCode,Unsupported PPDUTxType"); |
| 11716 | return STATUS_SENT_ERROR; |
| 11717 | } |
| 11718 | } |
| 11719 | |
| 11720 | val = get_param(cmd, "TXOPDuration"); |
| 11721 | if (val) { |
| 11722 | if (strcasecmp(val, "UNSPECIFIED") == 0) { |
| 11723 | /* The hardware is hardcoded with 0x7f; do nothing */ |
| 11724 | } else { |
| 11725 | send_resp(dut, conn, SIGMA_ERROR, |
| 11726 | "errorCode,Unsupported TXOPDuration"); |
| 11727 | return STATUS_SENT_ERROR; |
| 11728 | } |
| 11729 | } |
| 11730 | |
Priyadharshini Gowthaman | f8c032d | 2019-07-31 14:38:02 -0700 | [diff] [blame] | 11731 | val = get_param(cmd, "Trig_Usrinfo_UL-MCS"); |
| 11732 | if (val) |
| 11733 | run_iwpriv(dut, ifname, "he_ul_mcs %d", atoi(val)); |
| 11734 | |
| 11735 | val = get_param(cmd, "Trig_Usrinfo_UL-Target-RSSI"); |
| 11736 | if (val) { |
| 11737 | /* Set target RSSI to -55 dBm */ |
| 11738 | run_system_wrapper(dut, |
| 11739 | "wifitool %s setUnitTestCmd 0x4b 2 7 %d", |
| 11740 | ifname, atoi(val) - 110); |
| 11741 | } |
| 11742 | |
| 11743 | val = get_param(cmd, "Trig_Interval"); |
| 11744 | if (val) |
| 11745 | run_iwpriv(dut, basedev, "he_ul_trig_int %d", atoi(val)); |
| 11746 | |
| 11747 | val = get_param(cmd, "Trig_ComInfo_ULLength"); |
| 11748 | if (val) |
| 11749 | run_system_wrapper(dut, |
| 11750 | "wifitool %s setUnitTestCmd 0x48 2 141 %d", |
| 11751 | ifname, atoi(val)); |
| 11752 | |
Priyadharshini Gowthaman | 2f8c317 | 2019-07-31 14:38:12 -0700 | [diff] [blame] | 11753 | val = get_param(cmd, "DisableTriggerType"); |
| 11754 | if (val) { |
| 11755 | trigtype = atoi(val); |
| 11756 | switch (trigtype) { |
| 11757 | case 0: |
| 11758 | /* DisableTriggerType "0" for basic trigger */ |
| 11759 | run_system_wrapper(dut, |
| 11760 | "wifitool %s setUnitTestCmd 0x47 2 42 0", |
| 11761 | ifname); |
| 11762 | break; |
| 11763 | default: |
| 11764 | /* Nothing to be done for now */ |
| 11765 | break; |
| 11766 | } |
| 11767 | } |
| 11768 | |
| 11769 | val = get_param(cmd, "Trigger_TxBF"); |
| 11770 | if (val) { |
| 11771 | if (strcasecmp(val, "enable") == 0) { |
| 11772 | run_iwpriv(dut, ifname, "he_sounding_mode 0x9"); |
| 11773 | } else if (strcasecmp(val, "disable") == 0) { |
| 11774 | run_iwpriv(dut, ifname, "he_sounding_mode 0x1"); |
| 11775 | } else { |
| 11776 | send_resp(dut, conn, SIGMA_ERROR, |
| 11777 | "errorCode,Unsupported trigger_txbf"); |
| 11778 | return STATUS_SENT_ERROR; |
| 11779 | } |
| 11780 | } |
| 11781 | |
Priyadharshini Gowthaman | 7b94f08 | 2019-07-31 14:38:25 -0700 | [diff] [blame] | 11782 | val = get_param(cmd, "Trig_UsrInfo_RUAlloc"); |
| 11783 | if (val) { |
| 11784 | res = he_rualloctones(dut, conn, ifname, val); |
| 11785 | if (res != SUCCESS_SEND_STATUS) |
| 11786 | return res; |
| 11787 | } |
| 11788 | |
Priyadharshini Gowthaman | 8701fac | 2019-07-31 14:38:48 -0700 | [diff] [blame] | 11789 | val = get_param(cmd, "TriggerCoding"); |
| 11790 | if (val) { |
| 11791 | if (strcasecmp(val, "BCC") == 0) { |
| 11792 | /* In case of LDPC enable this command can force BCC if |
| 11793 | * RU size <= 242 */ |
| 11794 | run_iwpriv(dut, ifname, "he_ul_ldpc 0"); |
| 11795 | } else if (strcasecmp(val, "LDPC") == 0) { |
| 11796 | novap_reset(dut, ifname, 0); |
| 11797 | run_iwpriv(dut, ifname, "he_ul_ldpc 1"); |
| 11798 | novap_reset(dut, ifname, 1); |
| 11799 | } else { |
| 11800 | send_resp(dut, conn, SIGMA_ERROR, |
| 11801 | "errorCode,Unsupported TriggerCoding"); |
| 11802 | return STATUS_SENT_ERROR; |
| 11803 | } |
| 11804 | } |
| 11805 | |
Priyadharshini Gowthaman | 51c0fec | 2019-08-09 12:04:05 -0700 | [diff] [blame] | 11806 | val = get_param(cmd, "AckPolicy_MAC"); |
| 11807 | if (val) { |
| 11808 | if (parse_mac_address(dut, val, mac_addr) < 0) { |
| 11809 | send_resp(dut, conn, SIGMA_ERROR, |
| 11810 | "errorCode,MAC Address not in proper format"); |
| 11811 | return STATUS_SENT_ERROR; |
| 11812 | } |
| 11813 | he_ackpolicymac = 1; |
| 11814 | } |
| 11815 | |
| 11816 | val = get_param(cmd, "AckPolicy"); |
| 11817 | if (val) { |
| 11818 | int ap_he_ackpolicy; |
| 11819 | |
| 11820 | ap_he_ackpolicy = atoi(val); |
| 11821 | if (ap_he_ackpolicy == 0 && he_ackpolicymac) { |
| 11822 | /* Disable all-BAR ackpolicy for MU-MIMO */ |
| 11823 | run_system_wrapper(dut, |
| 11824 | "wifitool %s setUnitTestCmd 0x48 2 62 0", |
| 11825 | ifname); |
| 11826 | /* Disable all-BAR ackpolicy first */ |
| 11827 | run_system_wrapper(dut, |
| 11828 | "wifitool %s setUnitTestCmd 0x48 2 64 0", |
| 11829 | ifname); |
| 11830 | /* Set normal ack policy for the STA with the specified |
| 11831 | * MAC address in DL-TX case */ |
| 11832 | run_system_wrapper(dut, |
| 11833 | "wifitool %s setUnitTestCmd 0x4b 8 8 1 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x", |
| 11834 | ifname, mac_addr[0], mac_addr[1], |
| 11835 | mac_addr[2], mac_addr[3], |
| 11836 | mac_addr[4], mac_addr[5]); |
| 11837 | } else if (ap_he_ackpolicy == 3) { |
| 11838 | /* Enable all-BAR ackpolicy for MU-MIMO DL */ |
| 11839 | run_system_wrapper(dut, |
| 11840 | "wifitool %s setUnitTestCmd 0x48 2 62 1", |
| 11841 | ifname); |
| 11842 | /* Enable all-BAR ackpolicy */ |
| 11843 | run_system_wrapper(dut, |
| 11844 | "wifitool %s setUnitTestCmd 0x48 2 64 1", |
| 11845 | ifname); |
| 11846 | } else if (ap_he_ackpolicy == 4) { |
| 11847 | /* Enable htp-ack ackpolicy */ |
| 11848 | run_system_wrapper(dut, |
| 11849 | "wifitool %s setUnitTestCmd 0x47 2 99 1", |
| 11850 | ifname); |
| 11851 | } else { |
| 11852 | send_resp(dut, conn, SIGMA_ERROR, |
| 11853 | "errorCode,Invalid AckPolicy setting"); |
| 11854 | return STATUS_SENT_ERROR; |
| 11855 | } |
| 11856 | } |
| 11857 | |
Priyadharshini Gowthaman | c9a88c7 | 2019-08-09 12:04:17 -0700 | [diff] [blame] | 11858 | val = get_param(cmd, "Trig_ComInfo_GI-LTF"); |
| 11859 | if (val) { |
| 11860 | int trig_gi_ltf; |
| 11861 | |
| 11862 | trig_gi_ltf = atoi(val); |
| 11863 | if (trig_gi_ltf == 0) { |
| 11864 | he_ltf(dut, conn, ifname, "3.2"); |
| 11865 | he_shortgi(dut, conn, ifname, "1.6"); |
| 11866 | } else if (trig_gi_ltf == 1) { |
| 11867 | he_ltf(dut, conn, ifname, "6.4"); |
| 11868 | he_shortgi(dut, conn, ifname, "1.6"); |
| 11869 | } else if (trig_gi_ltf == 2) { |
| 11870 | he_ltf(dut, conn, ifname, "12.8"); |
| 11871 | he_shortgi(dut, conn, ifname, "3.2"); |
| 11872 | } else { |
| 11873 | send_resp(dut, conn, SIGMA_ERROR, |
| 11874 | "errorCode,Unsupported Trig_ComInfo_GI-LTF"); |
| 11875 | return STATUS_SENT_ERROR; |
| 11876 | } |
| 11877 | } |
| 11878 | |
| 11879 | val = get_param(cmd, "Trig_ComInfo_BW"); |
| 11880 | if (val) { |
| 11881 | int chwidth; |
| 11882 | |
| 11883 | chwidth = atoi(val); |
| 11884 | /* Set the channel width */ |
| 11885 | run_iwpriv(dut, ifname, "chwidth %d", chwidth); |
| 11886 | } |
| 11887 | |
Priyadharshini Gowthaman | e87e2c9 | 2019-08-09 12:04:31 -0700 | [diff] [blame] | 11888 | val = get_param(cmd, "NumSS"); |
| 11889 | if (val) { |
| 11890 | int i = 0; |
| 11891 | char *numss_val; |
| 11892 | char *saveptr; |
| 11893 | |
| 11894 | num_ss = strdup(val); |
| 11895 | if (!num_ss) |
| 11896 | return ERROR_SEND_STATUS; |
| 11897 | |
| 11898 | numss_val = strtok_r(num_ss, " ", &saveptr); |
| 11899 | for (i = 0; numss_val && i < 4; i++) { |
| 11900 | nss[i] = numss_val; |
| 11901 | numss_val = strtok_r(NULL, " ", &saveptr); |
| 11902 | } |
| 11903 | } |
| 11904 | |
| 11905 | val = get_param(cmd, "NumSS_MAC"); |
| 11906 | if (val) { |
| 11907 | char *sta_mac_str; |
| 11908 | char *saveptr; |
| 11909 | char *sta_mac_list_str; |
| 11910 | |
| 11911 | sta_mac_list_str = strdup(val); |
| 11912 | if (!sta_mac_list_str) { |
| 11913 | free(num_ss); |
| 11914 | return ERROR_SEND_STATUS; |
| 11915 | } |
| 11916 | |
| 11917 | sta_mac_str = strtok_r(sta_mac_list_str, " ", &saveptr); |
| 11918 | if (sta_mac_str && nss[0]) { |
| 11919 | run_system_wrapper(dut, |
| 11920 | "wifitool %s chmask_persta %s %s", |
| 11921 | ifname, sta_mac_str, nss[0]); |
| 11922 | } |
| 11923 | |
| 11924 | sta_mac_str = strtok_r(NULL, " ", &saveptr); |
| 11925 | if (sta_mac_str && nss[1]) { |
| 11926 | run_system_wrapper(dut, |
| 11927 | "wifitool %s chmask_persta %s %s", |
| 11928 | ifname, sta_mac_str, nss[1]); |
| 11929 | } |
| 11930 | |
| 11931 | sta_mac_str = strtok_r(NULL, " ", &saveptr); |
| 11932 | if (sta_mac_str && nss[2]) { |
| 11933 | run_system_wrapper(dut, |
| 11934 | "wifitool %s chmask_persta %s %s", |
| 11935 | ifname, sta_mac_str, nss[2]); |
| 11936 | } |
| 11937 | |
| 11938 | sta_mac_str = strtok_r(NULL, " ", &saveptr); |
| 11939 | if (sta_mac_str && nss[3]) { |
| 11940 | run_system_wrapper(dut, |
| 11941 | "wifitool %s chmask_persta %s %s", |
| 11942 | ifname, sta_mac_str, nss[3]); |
| 11943 | } |
| 11944 | |
| 11945 | free(sta_mac_list_str); |
| 11946 | } |
| 11947 | |
| 11948 | free(num_ss); |
| 11949 | num_ss = NULL; |
| 11950 | |
Priyadharshini Gowthaman | dca0c54 | 2019-08-09 12:04:42 -0700 | [diff] [blame] | 11951 | val = get_param(cmd, "AID"); |
| 11952 | if (val) { |
| 11953 | int i = 0; |
| 11954 | char *aid_val; |
| 11955 | char *saveptr; |
| 11956 | |
| 11957 | aid_ss = strdup(val); |
| 11958 | if (!aid_ss) |
| 11959 | return ERROR_SEND_STATUS; |
| 11960 | |
| 11961 | aid_val = strtok_r(aid_ss, " ", &saveptr); |
| 11962 | for (i = 0; aid_val && i < 4; i++) { |
| 11963 | aid[i] = aid_val; |
| 11964 | aid_val = strtok_r(NULL, " ", &saveptr); |
| 11965 | } |
| 11966 | } |
| 11967 | |
| 11968 | val = get_param(cmd, "AddbaReq"); |
| 11969 | if (val) { |
| 11970 | if (strcasecmp(val, "enable") == 0) { |
| 11971 | run_iwpriv(dut, ifname, "setaddbaoper 1"); |
| 11972 | run_system_wrapper(dut, |
| 11973 | "wifitool %s sendaddba %s 0 64", |
| 11974 | ifname, aid[0]); |
| 11975 | } else { |
| 11976 | send_resp(dut, conn, SIGMA_ERROR, |
| 11977 | "errorCode,Unsupported AddbaReq value"); |
| 11978 | free(aid_ss); |
| 11979 | return STATUS_SENT_ERROR; |
| 11980 | } |
| 11981 | } |
| 11982 | |
| 11983 | val = get_param(cmd, "AddbaResp"); |
| 11984 | if (val) { |
| 11985 | if (aid_ss && strcasecmp(val, "accepted") == 0) { |
| 11986 | int aid_1 = atoi(aid_ss); |
| 11987 | |
| 11988 | if (aid_1 == 1) |
| 11989 | aid_1 = 2; |
| 11990 | else |
| 11991 | aid_1 = aid_1 - 1; |
| 11992 | |
| 11993 | /* There is no mechanism in place to reject Add BA Req |
| 11994 | * from all STAs and selectively accept Add BA Req from |
| 11995 | * a specified STA. Instead, it can accept Add BA Req |
| 11996 | * from all STAs and selectively reject from specified |
| 11997 | * STAs. Make changes for the same using the below |
| 11998 | * commands. */ |
| 11999 | run_system_wrapper(dut, ifname, "setaddbaoper 1"); |
| 12000 | run_system_wrapper(dut, "wifitool %s refusealladdbas 0", |
| 12001 | ifname); |
| 12002 | run_system_wrapper(dut, |
| 12003 | "wifitool %s setaddbaresp %d 0 37", |
| 12004 | ifname, aid_1); |
| 12005 | } else { |
| 12006 | send_resp(dut, conn, SIGMA_ERROR, |
| 12007 | "errorCode,Unsupported Addbaresp value"); |
| 12008 | free(aid_ss); |
| 12009 | return STATUS_SENT_ERROR; |
| 12010 | } |
| 12011 | } |
| 12012 | |
| 12013 | val = get_param(cmd, "Trig_UsrInfo_SSAlloc_RA-RU"); |
| 12014 | if (val) { |
| 12015 | char *ssalloc_str; |
| 12016 | char *saveptr; |
| 12017 | char *ssalloc_list_str; |
| 12018 | |
| 12019 | ssalloc_list_str = strdup(val); |
| 12020 | if (!ssalloc_list_str) { |
| 12021 | free(aid_ss); |
| 12022 | return ERROR_SEND_STATUS; |
| 12023 | } |
| 12024 | |
| 12025 | ssalloc_str = strtok_r(ssalloc_list_str, ":", &saveptr); |
| 12026 | if (ssalloc_str && aid[0]) { |
| 12027 | run_system_wrapper(dut, "wifitool %s peer_nss %s %s", |
| 12028 | ifname, aid[0], ssalloc_str); |
| 12029 | } |
| 12030 | |
| 12031 | ssalloc_str = strtok_r(NULL, " ", &saveptr); |
| 12032 | if (ssalloc_str && aid[1]) { |
| 12033 | run_system_wrapper(dut, "wifitool %s peer_nss %s %s", |
| 12034 | ifname, aid[1], ssalloc_str); |
| 12035 | } |
| 12036 | |
| 12037 | ssalloc_str = strtok_r(NULL, " ", &saveptr); |
| 12038 | if (ssalloc_str && aid[2]) { |
| 12039 | run_system_wrapper(dut, "wifitool %s peer_nss %s %s", |
| 12040 | ifname, aid[2], ssalloc_str); |
| 12041 | } |
| 12042 | |
| 12043 | ssalloc_str = strtok_r(NULL, " ", &saveptr); |
| 12044 | if (ssalloc_str && aid[3]) { |
| 12045 | run_system_wrapper(dut, "wifitool %s peer_nss %s %s", |
| 12046 | ifname, aid[3], ssalloc_str); |
| 12047 | } |
| 12048 | |
| 12049 | free(ssalloc_list_str); |
| 12050 | } |
| 12051 | |
| 12052 | free(aid_ss); |
| 12053 | aid_ss = NULL; |
| 12054 | |
Priyadharshini Gowthaman | 2da1ecc | 2019-08-09 12:04:54 -0700 | [diff] [blame] | 12055 | val = get_param(cmd, "OMCtrl_RxNSS"); |
| 12056 | if (val) |
| 12057 | omctrl_rxnss = atoi(val); |
| 12058 | |
| 12059 | val = get_param(cmd, "OMCtrl_ChnlWidth"); |
| 12060 | if (val) |
| 12061 | omctrl_chwidth = atoi(val); |
| 12062 | |
| 12063 | val = get_param(cmd, "Client_mac"); |
| 12064 | if (val) { |
| 12065 | if (parse_mac_address(dut, val, mac_addr) < 0) { |
| 12066 | send_resp(dut, conn, SIGMA_ERROR, |
| 12067 | "errorCode,MAC Address not in proper format"); |
| 12068 | return STATUS_SENT_ERROR; |
| 12069 | } |
| 12070 | |
| 12071 | /* setUnitTestCmd 13 7 1 mac3mac2mac1mac0 mac5mac4 <rx_nss> |
| 12072 | * <bw> <ulmu> <tx_nss> */ |
| 12073 | run_system_wrapper(dut, |
| 12074 | "wifitool %s setUnitTestCmd 13 7 1 0x%02x%02x%02x%02x 0x%02x%02x %d %d 1 %d", |
| 12075 | ifname, mac_addr[3], mac_addr[2], |
| 12076 | mac_addr[1], mac_addr[0], mac_addr[5], |
| 12077 | mac_addr[4], omctrl_rxnss, |
| 12078 | omctrl_chwidth, omctrl_rxnss); |
| 12079 | } |
| 12080 | |
Priyadharshini Gowthaman | 7e43870 | 2019-08-09 12:05:05 -0700 | [diff] [blame] | 12081 | val = get_param(cmd, "TriggerType"); |
| 12082 | if (val) { |
| 12083 | trigtype = atoi(val); |
| 12084 | switch (trigtype) { |
| 12085 | case 0: |
| 12086 | ath_set_trigger_type_0(dut, ifname); |
| 12087 | break; |
| 12088 | case 1: |
| 12089 | ath_set_trigger_type_1(dut, ifname); |
| 12090 | break; |
| 12091 | case 2: |
| 12092 | ath_set_trigger_type_2(dut, ifname); |
| 12093 | break; |
| 12094 | case 3: |
| 12095 | ath_set_trigger_type_3(dut, ifname); |
| 12096 | break; |
| 12097 | case 4: |
| 12098 | ath_set_trigger_type_4(dut, ifname, basedev); |
| 12099 | break; |
| 12100 | default: |
| 12101 | send_resp(dut, conn, SIGMA_ERROR, |
| 12102 | "errorCode,TriggerType not supported"); |
| 12103 | return STATUS_SENT_ERROR; |
| 12104 | } |
| 12105 | } |
| 12106 | |
Priyadharshini Gowthaman | c352d82 | 2019-08-09 12:05:16 -0700 | [diff] [blame] | 12107 | val = get_param(cmd, "HE_TXOPDurRTSThr"); |
| 12108 | if (val) |
| 12109 | run_iwpriv(dut, ifname, "he_rtsthrshld %d", atoi(val)); |
| 12110 | |
| 12111 | val = get_param(cmd, "NAV_Update"); |
| 12112 | if (val) { |
| 12113 | if (strcasecmp(val, "disable") == 0) { |
| 12114 | run_iwpriv(dut, basedev, "nav_config 1 0"); |
| 12115 | } else if (strcasecmp(val, "enable") == 0) { |
| 12116 | /* Do nothing */ |
| 12117 | } else { |
| 12118 | send_resp(dut, conn, SIGMA_ERROR, |
| 12119 | "errorCode,Unsupported NAV update"); |
| 12120 | return STATUS_SENT_ERROR; |
| 12121 | } |
| 12122 | } |
| 12123 | |
Priyadharshini Gowthaman | 872fb29 | 2019-08-09 12:05:27 -0700 | [diff] [blame] | 12124 | /* Configure WMM Parameter Elements */ |
| 12125 | val = get_param(cmd, "STA_WMMPE_ECWmin_BE"); |
| 12126 | if (val) { |
| 12127 | param = atoi(val); |
| 12128 | run_iwpriv(dut, ifname, "cwmin %d 1 %d", AP_AC_BE, param); |
| 12129 | } |
| 12130 | |
| 12131 | val = get_param(cmd, "STA_WMMPE_ECWmin_BK"); |
| 12132 | if (val) { |
| 12133 | param = atoi(val); |
| 12134 | run_iwpriv(dut, ifname, "cwmin %d 1 %d", AP_AC_BK, param); |
| 12135 | } |
| 12136 | |
| 12137 | val = get_param(cmd, "STA_WMMPE_ECWmin_VI"); |
| 12138 | if (val) { |
| 12139 | param = atoi(val); |
| 12140 | run_iwpriv(dut, ifname, "cwmin %d 1 %d", AP_AC_VI, param); |
| 12141 | } |
| 12142 | |
| 12143 | val = get_param(cmd, "STA_WMMPE_ECWmin_VO"); |
| 12144 | if (val) { |
| 12145 | param = atoi(val); |
| 12146 | run_iwpriv(dut, ifname, "cwmin %d 1 %d", AP_AC_VO, param); |
| 12147 | } |
| 12148 | |
| 12149 | val = get_param(cmd, "STA_WMMPE_ECWmax_BE"); |
| 12150 | if (val) { |
| 12151 | param = atoi(val); |
| 12152 | run_iwpriv(dut, ifname, "cwmax %d 1 %d", AP_AC_BE, param); |
| 12153 | } |
| 12154 | |
| 12155 | val = get_param(cmd, "STA_WMMPE_ECWmax_BK"); |
| 12156 | if (val) { |
| 12157 | param = atoi(val); |
| 12158 | run_iwpriv(dut, ifname, "cwmax %d 1 %d", AP_AC_BK, param); |
| 12159 | } |
| 12160 | |
| 12161 | val = get_param(cmd, "STA_WMMPE_ECWmax_VI"); |
| 12162 | if (val) { |
| 12163 | param = atoi(val); |
| 12164 | run_iwpriv(dut, ifname, "cwmax %d 1 %d", AP_AC_VI, param); |
| 12165 | } |
| 12166 | |
| 12167 | val = get_param(cmd, "STA_WMMPE_ECWmax_VO"); |
| 12168 | if (val) { |
| 12169 | param = atoi(val); |
| 12170 | run_iwpriv(dut, ifname, "cwmax %d 1 %d", AP_AC_VO, param); |
| 12171 | } |
| 12172 | |
| 12173 | val = get_param(cmd, "STA_WMMPE_AIFSN_BE"); |
| 12174 | if (val) { |
| 12175 | param = atoi(val); |
| 12176 | run_iwpriv(dut, ifname, "aifs %d 1 %d", AP_AC_BE, param); |
| 12177 | } |
| 12178 | |
| 12179 | val = get_param(cmd, "STA_WMMPE_AIFSN_BK"); |
| 12180 | if (val) { |
| 12181 | param = atoi(val); |
| 12182 | run_iwpriv(dut, ifname, "aifs %d 1 %d", AP_AC_BK, param); |
| 12183 | } |
| 12184 | |
| 12185 | val = get_param(cmd, "STA_WMMPE_AIFSN_VI"); |
| 12186 | if (val) { |
| 12187 | param = atoi(val); |
| 12188 | run_iwpriv(dut, ifname, "aifs %d 1 %d", AP_AC_VI, param); |
| 12189 | } |
| 12190 | |
| 12191 | val = get_param(cmd, "STA_WMMPE_AIFSN_VO"); |
| 12192 | if (val) { |
| 12193 | param = atoi(val); |
| 12194 | run_iwpriv(dut, ifname, "aifs %d 1 %d", AP_AC_VO, param); |
| 12195 | } |
| 12196 | |
| 12197 | |
| 12198 | val = get_param(cmd, "STA_WMMPE_TXOP_BE"); |
| 12199 | if (val) { |
| 12200 | param = atoi(val); |
| 12201 | run_iwpriv(dut, ifname, "txoplimit %d 1 %d", AP_AC_BE, param); |
| 12202 | } |
| 12203 | |
| 12204 | val = get_param(cmd, "STA_WMMPE_TOXP_BK"); |
| 12205 | if (val) { |
| 12206 | param = atoi(val); |
| 12207 | run_iwpriv(dut, ifname, "txoplimit %d 1 %d", AP_AC_BK, param); |
| 12208 | } |
| 12209 | |
| 12210 | val = get_param(cmd, "STA_WMMPE_TXOP_VI"); |
| 12211 | if (val) { |
| 12212 | param = atoi(val); |
| 12213 | run_iwpriv(dut, ifname, "txoplimit %d %d", AP_AC_VI, param); |
| 12214 | } |
| 12215 | |
| 12216 | val = get_param(cmd, "STA_WMMPE_TXOP_VO"); |
| 12217 | if (val) { |
| 12218 | param = atoi(val); |
| 12219 | run_iwpriv(dut, ifname, "txoplimit %d 1 %d", AP_AC_VO, param); |
| 12220 | } |
| 12221 | |
Priyadharshini Gowthaman | c46b7e4 | 2019-08-09 12:05:37 -0700 | [diff] [blame] | 12222 | /* Configure MU EDCA */ |
| 12223 | val = get_param(cmd, "STA_MUEDCA_ECWmin_BE"); |
| 12224 | if (val) { |
| 12225 | param = atoi(val); |
| 12226 | run_iwpriv(dut, ifname, "muedca_ecwmin %d %d", AP_AC_BE, param); |
| 12227 | } |
| 12228 | |
| 12229 | val = get_param(cmd, "STA_MUEDCA_ECWmin_BK"); |
| 12230 | if (val) { |
| 12231 | param = atoi(val); |
| 12232 | run_iwpriv(dut, ifname, "muedca_ecwmin %d %d", AP_AC_BK, param); |
| 12233 | } |
| 12234 | |
| 12235 | val = get_param(cmd, "STA_MUEDCA_ECWmin_VI"); |
| 12236 | if (val) { |
| 12237 | param = atoi(val); |
| 12238 | run_iwpriv(dut, ifname, "muedca_ecwmin %d %d", AP_AC_VI, param); |
| 12239 | } |
| 12240 | |
| 12241 | val = get_param(cmd, "STA_MUEDCA_ECWmin_VO"); |
| 12242 | if (val) { |
| 12243 | param = atoi(val); |
| 12244 | run_iwpriv(dut, ifname, "muedca_ecwmin %d %d", AP_AC_VO, param); |
| 12245 | } |
| 12246 | |
| 12247 | val = get_param(cmd, "STA_MUEDCA_ECWmax_BE"); |
| 12248 | if (val) { |
| 12249 | param = atoi(val); |
| 12250 | run_iwpriv(dut, ifname, "muedca_ecwmax %d %d", AP_AC_BE, param); |
| 12251 | } |
| 12252 | |
| 12253 | val = get_param(cmd, "STA_MUEDCA_ECWmax_BK"); |
| 12254 | if (val) { |
| 12255 | param = atoi(val); |
| 12256 | run_iwpriv(dut, ifname, "muedca_ecwmax %d %d", AP_AC_BK, param); |
| 12257 | } |
| 12258 | |
| 12259 | val = get_param(cmd, "STA_MUEDCA_ECWmax_VI"); |
| 12260 | if (val) { |
| 12261 | param = atoi(val); |
| 12262 | run_iwpriv(dut, ifname, "muedca_ecwmax %d %d", AP_AC_VI, param); |
| 12263 | } |
| 12264 | |
| 12265 | val = get_param(cmd, "STA_MUEDCA_ECWmax_VO"); |
| 12266 | if (val) { |
| 12267 | param = atoi(val); |
| 12268 | run_iwpriv(dut, ifname, "muedca_ecwmax %d %d", AP_AC_VO, param); |
| 12269 | } |
| 12270 | |
| 12271 | val = get_param(cmd, "STA_MUEDCA_AIFSN_BE"); |
| 12272 | if (val) { |
| 12273 | param = atoi(val); |
| 12274 | run_iwpriv(dut, ifname, "muedca_aifsn %d %d", AP_AC_BE, param); |
| 12275 | } |
| 12276 | |
| 12277 | val = get_param(cmd, "STA_MUEDCA_AIFSN_BK"); |
| 12278 | if (val) { |
| 12279 | param = atoi(val); |
| 12280 | run_iwpriv(dut, ifname, "muedca_aifsn %d %d", AP_AC_BK, param); |
| 12281 | } |
| 12282 | |
| 12283 | val = get_param(cmd, "STA_MUEDCA_AIFSN_VI"); |
| 12284 | if (val) { |
| 12285 | param = atoi(val); |
| 12286 | run_iwpriv(dut, ifname, "muedca_aifsn %d %d", AP_AC_VI, param); |
| 12287 | } |
| 12288 | |
| 12289 | val = get_param(cmd, "STA_MUEDCA_AIFSN_VO"); |
| 12290 | if (val) { |
| 12291 | param = atoi(val); |
| 12292 | run_iwpriv(dut, ifname, "muedca_aifsn %d %d", AP_AC_VO, param); |
| 12293 | } |
| 12294 | |
| 12295 | val = get_param(cmd, "STA_MUEDCA_Timer_BE"); |
| 12296 | if (val) { |
| 12297 | param = atoi(val); |
| 12298 | run_iwpriv(dut, ifname, "muedca_timer %d %d", AP_AC_BE, param); |
| 12299 | } |
| 12300 | |
| 12301 | val = get_param(cmd, "STA_MUEDCA_Timer_BK"); |
| 12302 | if (val) { |
| 12303 | param = atoi(val); |
| 12304 | run_iwpriv(dut, ifname, "muedca_timer %d %d", AP_AC_BK, param); |
| 12305 | } |
| 12306 | |
| 12307 | val = get_param(cmd, "STA_MUEDCA_Timer_VI"); |
| 12308 | if (val) { |
| 12309 | param = atoi(val); |
| 12310 | run_iwpriv(dut, ifname, "muedca_timer %d %d", AP_AC_VI, param); |
| 12311 | } |
| 12312 | |
| 12313 | val = get_param(cmd, "STA_MUEDCA_Timer_VO"); |
| 12314 | if (val) { |
| 12315 | param = atoi(val); |
| 12316 | run_iwpriv(dut, ifname, "muedca_timer %d %d", AP_AC_VO, param); |
| 12317 | } |
| 12318 | |
Jouni Malinen | 6076ffc | 2019-08-08 18:18:02 +0300 | [diff] [blame] | 12319 | return SUCCESS_SEND_STATUS; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 12320 | } |
| 12321 | |
| 12322 | |
Pradeep Reddy POTTETI | 88fd82c | 2016-03-14 12:20:18 +0530 | [diff] [blame] | 12323 | static int wcn_vht_chnum_band(struct sigma_dut *dut, const char *ifname, |
| 12324 | const char *val) |
| 12325 | { |
| 12326 | char *token, *result; |
| 12327 | int channel = 36; |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 12328 | char *saveptr; |
Pradeep Reddy POTTETI | 88fd82c | 2016-03-14 12:20:18 +0530 | [diff] [blame] | 12329 | |
| 12330 | /* Extract the channel info */ |
| 12331 | token = strdup(val); |
| 12332 | if (!token) |
| 12333 | return -1; |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 12334 | result = strtok_r(token, ";", &saveptr); |
Pradeep Reddy POTTETI | 88fd82c | 2016-03-14 12:20:18 +0530 | [diff] [blame] | 12335 | if (result) |
| 12336 | channel = atoi(result); |
| 12337 | |
| 12338 | /* Issue the channel switch command */ |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 12339 | run_iwpriv(dut, ifname, "setChanChange %d", channel); |
Pradeep Reddy POTTETI | 88fd82c | 2016-03-14 12:20:18 +0530 | [diff] [blame] | 12340 | |
| 12341 | free(token); |
| 12342 | return 0; |
| 12343 | } |
| 12344 | |
| 12345 | |
| 12346 | static int wcn_ap_set_rfeature(struct sigma_dut *dut, struct sigma_conn *conn, |
| 12347 | struct sigma_cmd *cmd) |
| 12348 | { |
| 12349 | const char *val; |
Jouni Malinen | 016ae6c | 2019-11-04 17:00:01 +0200 | [diff] [blame] | 12350 | const char *ifname; |
Pradeep Reddy POTTETI | 88fd82c | 2016-03-14 12:20:18 +0530 | [diff] [blame] | 12351 | |
Jouni Malinen | 016ae6c | 2019-11-04 17:00:01 +0200 | [diff] [blame] | 12352 | ifname = get_main_ifname(dut); |
Pradeep Reddy POTTETI | 88fd82c | 2016-03-14 12:20:18 +0530 | [diff] [blame] | 12353 | |
| 12354 | val = get_param(cmd, "chnum_band"); |
| 12355 | if (val && wcn_vht_chnum_band(dut, ifname, val) < 0) |
| 12356 | return -1; |
| 12357 | |
| 12358 | return 1; |
| 12359 | } |
| 12360 | |
| 12361 | |
Mohammed Shafi Shajakhan | b53d8f9 | 2017-02-28 09:05:15 +0530 | [diff] [blame] | 12362 | static int mac80211_vht_chnum_band(struct sigma_dut *dut, const char *ifname, |
| 12363 | const char *val) |
| 12364 | { |
| 12365 | char *token, *result; |
| 12366 | int channel = 36, chwidth = 80, center_freq_idx, center_freq, |
| 12367 | channel_freq; |
| 12368 | char buf[100]; |
| 12369 | char *saveptr; |
Jouni Malinen | 3aa7286 | 2019-05-29 23:14:51 +0300 | [diff] [blame] | 12370 | int res; |
Mohammed Shafi Shajakhan | b53d8f9 | 2017-02-28 09:05:15 +0530 | [diff] [blame] | 12371 | |
| 12372 | /* Extract the channel info */ |
| 12373 | token = strdup(val); |
| 12374 | if (!token) |
| 12375 | return -1; |
| 12376 | result = strtok_r(token, ";", &saveptr); |
| 12377 | if (result) |
| 12378 | channel = atoi(result); |
| 12379 | |
| 12380 | /* Extract the channel width info */ |
| 12381 | result = strtok_r(NULL, ";", &saveptr); |
| 12382 | if (result) |
| 12383 | chwidth = atoi(result); |
| 12384 | |
| 12385 | center_freq_idx = get_oper_centr_freq_seq_idx(chwidth, channel); |
| 12386 | if (center_freq_idx < 0) { |
| 12387 | free(token); |
| 12388 | return -1; |
| 12389 | } |
| 12390 | |
| 12391 | center_freq = get_5g_channel_freq(center_freq_idx); |
| 12392 | channel_freq = get_5g_channel_freq(channel); |
| 12393 | |
| 12394 | /* Issue the channel switch command */ |
Jouni Malinen | 3aa7286 | 2019-05-29 23:14:51 +0300 | [diff] [blame] | 12395 | res = snprintf(buf, sizeof(buf), |
| 12396 | " -i %s chan_switch 10 %d sec_channel_offset=1 center_freq1=%d bandwidth=%d blocktx vht", |
| 12397 | ifname, channel_freq, center_freq, chwidth); |
| 12398 | 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] | 12399 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 12400 | "hostapd_cli chan_switch failed"); |
| 12401 | } |
| 12402 | |
| 12403 | free(token); |
| 12404 | return 0; |
| 12405 | } |
| 12406 | |
| 12407 | |
| 12408 | static int mac80211_ap_set_rfeature(struct sigma_dut *dut, |
| 12409 | struct sigma_conn *conn, |
| 12410 | struct sigma_cmd *cmd) |
| 12411 | { |
| 12412 | const char *val; |
Jouni Malinen | 016ae6c | 2019-11-04 17:00:01 +0200 | [diff] [blame] | 12413 | const char *ifname; |
Mohammed Shafi Shajakhan | b53d8f9 | 2017-02-28 09:05:15 +0530 | [diff] [blame] | 12414 | |
Jouni Malinen | 016ae6c | 2019-11-04 17:00:01 +0200 | [diff] [blame] | 12415 | ifname = get_main_ifname(dut); |
Tamizh chelvam | 638fb47 | 2019-08-15 14:00:31 +0530 | [diff] [blame] | 12416 | |
| 12417 | val = get_param(cmd, "RTS_FORCE"); |
| 12418 | if (val) |
| 12419 | mac80211_config_rts_force(dut, ifname, val); |
| 12420 | |
Mohammed Shafi Shajakhan | b53d8f9 | 2017-02-28 09:05:15 +0530 | [diff] [blame] | 12421 | val = get_param(cmd, "chnum_band"); |
| 12422 | if (val && mac80211_vht_chnum_band(dut, ifname, val) < 0) |
| 12423 | return -1; |
| 12424 | |
| 12425 | return 1; |
| 12426 | } |
| 12427 | |
| 12428 | |
Alexei Avshalom Lazar | bc180dc | 2018-12-18 16:01:14 +0200 | [diff] [blame] | 12429 | #ifdef __linux__ |
| 12430 | static int wil6210_ap_set_rfeature(struct sigma_dut *dut, |
| 12431 | struct sigma_conn *conn, |
| 12432 | struct sigma_cmd *cmd) |
| 12433 | { |
| 12434 | const char *val; |
| 12435 | |
| 12436 | val = get_param(cmd, "ExtSchIE"); |
| 12437 | if (val && !strcasecmp(val, "Enable")) { |
| 12438 | struct sigma_ese_alloc allocs[MAX_ESE_ALLOCS]; |
| 12439 | int count = MAX_ESE_ALLOCS; |
| 12440 | |
| 12441 | if (sta_extract_60g_ese(dut, cmd, allocs, &count)) |
| 12442 | return -1; |
| 12443 | if (wil6210_set_ese(dut, count, allocs)) |
| 12444 | return -1; |
| 12445 | return 1; |
| 12446 | } |
| 12447 | |
| 12448 | send_resp(dut, conn, SIGMA_ERROR, |
| 12449 | "errorCode,Invalid ap_set_rfeature(60G)"); |
| 12450 | return 0; |
| 12451 | } |
| 12452 | #endif /* __linux__ */ |
| 12453 | |
| 12454 | |
Jouni Malinen | f722271 | 2019-06-13 01:50:21 +0300 | [diff] [blame] | 12455 | static enum sigma_cmd_result cmd_ap_set_rfeature(struct sigma_dut *dut, |
| 12456 | struct sigma_conn *conn, |
| 12457 | struct sigma_cmd *cmd) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 12458 | { |
| 12459 | /* const char *name = get_param(cmd, "NAME"); */ |
| 12460 | /* const char *type = get_param(cmd, "Type"); */ |
| 12461 | |
Jouni Malinen | 016ae6c | 2019-11-04 17:00:01 +0200 | [diff] [blame] | 12462 | switch (get_driver_type(dut)) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 12463 | case DRIVER_ATHEROS: |
| 12464 | return ath_ap_set_rfeature(dut, conn, cmd); |
| 12465 | case DRIVER_OPENWRT: |
| 12466 | switch (get_openwrt_driver_type()) { |
| 12467 | case OPENWRT_DRIVER_ATHEROS: |
| 12468 | return ath_ap_set_rfeature(dut, conn, cmd); |
| 12469 | default: |
| 12470 | send_resp(dut, conn, SIGMA_ERROR, |
| 12471 | "errorCode,Unsupported ap_set_rfeature with the current openwrt driver"); |
| 12472 | return 0; |
| 12473 | } |
Sreelakshmi Konamki | 0e4fcf9 | 2016-04-26 19:55:01 +0530 | [diff] [blame] | 12474 | case DRIVER_LINUX_WCN: |
Pradeep Reddy POTTETI | 88fd82c | 2016-03-14 12:20:18 +0530 | [diff] [blame] | 12475 | case DRIVER_WCN: |
| 12476 | return wcn_ap_set_rfeature(dut, conn, cmd); |
Mohammed Shafi Shajakhan | b53d8f9 | 2017-02-28 09:05:15 +0530 | [diff] [blame] | 12477 | case DRIVER_MAC80211: |
| 12478 | return mac80211_ap_set_rfeature(dut, conn, cmd); |
Alexei Avshalom Lazar | bc180dc | 2018-12-18 16:01:14 +0200 | [diff] [blame] | 12479 | #ifdef __linux__ |
| 12480 | case DRIVER_WIL6210: |
| 12481 | return wil6210_ap_set_rfeature(dut, conn, cmd); |
| 12482 | #endif /* __linux__ */ |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 12483 | default: |
| 12484 | send_resp(dut, conn, SIGMA_ERROR, |
| 12485 | "errorCode,Unsupported ap_set_rfeature with the current driver"); |
| 12486 | return 0; |
| 12487 | } |
| 12488 | } |
| 12489 | |
| 12490 | |
Jouni Malinen | f722271 | 2019-06-13 01:50:21 +0300 | [diff] [blame] | 12491 | static enum sigma_cmd_result cmd_accesspoint(struct sigma_dut *dut, |
| 12492 | struct sigma_conn *conn, |
| 12493 | struct sigma_cmd *cmd) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 12494 | { |
| 12495 | /* const char *name = get_param(cmd, "NAME"); */ |
| 12496 | return 1; |
| 12497 | } |
| 12498 | |
| 12499 | |
Jouni Malinen | f722271 | 2019-06-13 01:50:21 +0300 | [diff] [blame] | 12500 | static enum sigma_cmd_result |
| 12501 | cmd_ap_preset_testparameters(struct sigma_dut *dut, struct sigma_conn *conn, |
| 12502 | struct sigma_cmd *cmd) |
priyadharshini gowthaman | 9149afc | 2018-01-15 13:40:18 -0800 | [diff] [blame] | 12503 | { |
| 12504 | const char *val; |
| 12505 | |
| 12506 | val = get_param(cmd, "Oper_Chn"); |
| 12507 | if (val) { |
| 12508 | dut->ap_oper_chn = 1; |
| 12509 | dut->ap_channel = atoi(val); |
| 12510 | } |
| 12511 | |
Jouni Malinen | ba4f2d4 | 2019-10-04 16:13:41 +0300 | [diff] [blame] | 12512 | val = get_param(cmd, "DPPConfiguratorAddress"); |
| 12513 | if (val) { |
| 12514 | free(dut->ap_dpp_conf_addr); |
| 12515 | dut->ap_dpp_conf_addr = strdup(val); |
| 12516 | } |
| 12517 | |
| 12518 | val = get_param(cmd, "DPPConfiguratorPKHash"); |
| 12519 | if (val) { |
| 12520 | free(dut->ap_dpp_conf_pkhash); |
| 12521 | dut->ap_dpp_conf_pkhash = strdup(val); |
| 12522 | } |
| 12523 | |
priyadharshini gowthaman | 9149afc | 2018-01-15 13:40:18 -0800 | [diff] [blame] | 12524 | return 1; |
| 12525 | } |
| 12526 | |
| 12527 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 12528 | void ap_register_cmds(void) |
| 12529 | { |
| 12530 | sigma_dut_reg_cmd("ap_ca_version", NULL, cmd_ap_ca_version); |
| 12531 | sigma_dut_reg_cmd("ap_set_wireless", NULL, cmd_ap_set_wireless); |
| 12532 | sigma_dut_reg_cmd("ap_send_addba_req", NULL, cmd_ap_send_addba_req); |
| 12533 | sigma_dut_reg_cmd("ap_set_11n_wireless", NULL, cmd_ap_set_wireless); |
| 12534 | sigma_dut_reg_cmd("ap_set_11n", NULL, cmd_ap_set_wireless); |
| 12535 | 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] | 12536 | sigma_dut_reg_cmd("ap_set_11h", NULL, cmd_ap_set_wireless); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 12537 | sigma_dut_reg_cmd("ap_set_security", NULL, cmd_ap_set_security); |
| 12538 | sigma_dut_reg_cmd("ap_set_apqos", NULL, cmd_ap_set_apqos); |
| 12539 | sigma_dut_reg_cmd("ap_set_staqos", NULL, cmd_ap_set_staqos); |
| 12540 | sigma_dut_reg_cmd("ap_set_radius", NULL, cmd_ap_set_radius); |
| 12541 | sigma_dut_reg_cmd("ap_reboot", NULL, cmd_ap_reboot); |
| 12542 | sigma_dut_reg_cmd("ap_config_commit", NULL, cmd_ap_config_commit); |
| 12543 | sigma_dut_reg_cmd("ap_reset_default", NULL, cmd_ap_reset_default); |
| 12544 | sigma_dut_reg_cmd("ap_get_info", NULL, cmd_ap_get_info); |
| 12545 | sigma_dut_reg_cmd("ap_deauth_sta", NULL, cmd_ap_deauth_sta); |
| 12546 | sigma_dut_reg_cmd("ap_send_frame", NULL, cmd_ap_send_frame); |
| 12547 | sigma_dut_reg_cmd("ap_get_mac_address", NULL, cmd_ap_get_mac_address); |
| 12548 | sigma_dut_reg_cmd("ap_set_pmf", NULL, cmd_ap_set_pmf); |
| 12549 | sigma_dut_reg_cmd("ap_set_hs2", NULL, cmd_ap_set_hs2); |
| 12550 | sigma_dut_reg_cmd("ap_set_rfeature", NULL, cmd_ap_set_rfeature); |
| 12551 | sigma_dut_reg_cmd("ap_nfc_action", NULL, cmd_ap_nfc_action); |
| 12552 | 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] | 12553 | sigma_dut_reg_cmd("ap_wps_enter_pin", NULL, cmd_ap_wps_enter_pin); |
| 12554 | 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] | 12555 | sigma_dut_reg_cmd("ap_get_parameter", NULL, cmd_ap_get_parameter); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 12556 | sigma_dut_reg_cmd("AccessPoint", NULL, cmd_accesspoint); |
priyadharshini gowthaman | 9149afc | 2018-01-15 13:40:18 -0800 | [diff] [blame] | 12557 | sigma_dut_reg_cmd("ap_preset_testparameters", NULL, |
| 12558 | cmd_ap_preset_testparameters); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 12559 | } |