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_main_ifname; |
| 103 | extern char *sigma_wpas_ctrl; |
| 104 | extern char *sigma_hapd_ctrl; |
| 105 | extern char *ap_inet_addr; |
| 106 | extern char *ap_inet_mask; |
| 107 | extern char *sigma_radio_ifname[]; |
| 108 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 109 | static int ath_ap_start_hostapd(struct sigma_dut *dut); |
| 110 | static void ath_ap_set_params(struct sigma_dut *dut); |
| 111 | static int kill_process(struct sigma_dut *dut, char *proc_name, |
| 112 | unsigned char is_proc_instance_one, int sig); |
| 113 | |
| 114 | |
Jouni Malinen | 6be21c8 | 2018-08-01 18:47:24 +0300 | [diff] [blame] | 115 | static int ap_ft_enabled(struct sigma_dut *dut) |
| 116 | { |
| 117 | return dut->ap_ft_oa == 1 || |
Jouni Malinen | 9f94331 | 2019-08-19 23:49:16 +0300 | [diff] [blame] | 118 | dut->ap_ft_ds == VALUE_ENABLED || |
Jouni Malinen | 6be21c8 | 2018-08-01 18:47:24 +0300 | [diff] [blame] | 119 | dut->ap_key_mgmt == AP_WPA2_FT_EAP || |
| 120 | dut->ap_key_mgmt == AP_WPA2_FT_PSK || |
Jouni Malinen | da5f35b | 2019-03-26 00:25:53 +0200 | [diff] [blame] | 121 | dut->ap_key_mgmt == AP_WPA2_ENT_FT_EAP || |
| 122 | (dut->ap_akm_values & |
| 123 | ((1 << AKM_FT_EAP) | |
| 124 | (1 << AKM_FT_PSK) | |
| 125 | (1 << AKM_FT_SAE) | |
| 126 | (1 << AKM_FT_SUITE_B) | |
| 127 | (1 << AKM_FT_FILS_SHA256) | |
| 128 | (1 << AKM_FT_FILS_SHA384))); |
Jouni Malinen | 6be21c8 | 2018-08-01 18:47:24 +0300 | [diff] [blame] | 129 | } |
| 130 | |
| 131 | |
Jouni Malinen | f722271 | 2019-06-13 01:50:21 +0300 | [diff] [blame] | 132 | static enum sigma_cmd_result cmd_ap_ca_version(struct sigma_dut *dut, |
| 133 | struct sigma_conn *conn, |
| 134 | struct sigma_cmd *cmd) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 135 | { |
| 136 | /* const char *name = get_param(cmd, "NAME"); */ |
| 137 | send_resp(dut, conn, SIGMA_COMPLETE, "version,1.0"); |
| 138 | return 0; |
| 139 | } |
| 140 | |
| 141 | |
Jouni Malinen | d6bf1b4 | 2017-06-23 17:51:01 +0300 | [diff] [blame] | 142 | static void kill_hostapd_process_pid(struct sigma_dut *dut) |
| 143 | { |
| 144 | FILE *f; |
| 145 | int pid, res; |
| 146 | char path[100]; |
| 147 | int count; |
| 148 | |
| 149 | f = fopen(SIGMA_DUT_HOSTAPD_PID_FILE, "r"); |
| 150 | if (!f) |
| 151 | return; |
| 152 | res = fscanf(f, "%d", &pid); |
| 153 | fclose(f); |
| 154 | if (res != 1) |
| 155 | return; |
| 156 | sigma_dut_print(dut, DUT_MSG_INFO, "Killing hostapd pid %d", pid); |
| 157 | kill(pid, SIGTERM); |
| 158 | snprintf(path, sizeof(path), "/proc/%d", pid); |
| 159 | for (count = 0; count < 20 && file_exists(path); count++) |
| 160 | usleep(100000); |
| 161 | } |
| 162 | |
| 163 | |
Jouni Malinen | 2e6ccc2 | 2017-09-04 13:43:16 +0300 | [diff] [blame] | 164 | int get_hwaddr(const char *ifname, unsigned char *hwaddr) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 165 | { |
| 166 | #ifndef __QNXNTO__ |
| 167 | struct ifreq ifr; |
| 168 | int s; |
| 169 | |
| 170 | s = socket(AF_INET, SOCK_DGRAM, 0); |
| 171 | if (s < 0) |
| 172 | return -1; |
| 173 | memset(&ifr, 0, sizeof(ifr)); |
Peng Xu | b8fc5cc | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 174 | strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name)); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 175 | if (ioctl(s, SIOCGIFHWADDR, &ifr) < 0) { |
| 176 | perror("ioctl"); |
| 177 | close(s); |
| 178 | return -1; |
| 179 | } |
| 180 | close(s); |
| 181 | memcpy(hwaddr, ifr.ifr_hwaddr.sa_data, 6); |
| 182 | #else /* __QNXNTO__ */ |
| 183 | struct ifaddrs *ifaddrshead = NULL; |
| 184 | int found = 0; |
| 185 | struct ifaddrs *temp_ifap = NULL; |
| 186 | struct sockaddr_dl *sdl = NULL; |
| 187 | |
| 188 | if (getifaddrs(&ifaddrshead) != 0) { |
| 189 | perror("getifaddrs failed"); |
| 190 | return -1; |
| 191 | } |
| 192 | |
| 193 | for (temp_ifap = ifaddrshead; ifaddrshead && !found; |
| 194 | ifaddrshead = ifaddrshead->ifa_next) { |
| 195 | if (ifaddrshead->ifa_addr->sa_family == AF_LINK && |
| 196 | strcmp(ifaddrshead->ifa_name, ifname) == 0) { |
| 197 | found = 1; |
| 198 | sdl = (struct sockaddr_dl *) ifaddrshead->ifa_addr; |
| 199 | if (sdl) |
| 200 | memcpy(hwaddr, LLADDR(sdl), sdl->sdl_alen); |
| 201 | } |
| 202 | } |
| 203 | |
| 204 | if (temp_ifap) |
| 205 | freeifaddrs(temp_ifap); |
| 206 | |
| 207 | if (!found) { |
| 208 | perror("Failed to get the interface"); |
| 209 | return -1; |
| 210 | } |
| 211 | #endif /* __QNXNTO__ */ |
| 212 | return 0; |
| 213 | } |
| 214 | |
| 215 | |
| 216 | static void ath_ap_set_group_id(struct sigma_dut *dut, const char *ifname, |
| 217 | const char *val) |
| 218 | { |
| 219 | char buf[60]; |
| 220 | |
| 221 | snprintf(buf, sizeof(buf), "wifitool %s beeliner_fw_test 55 %d", |
| 222 | ifname, atoi(val)); |
| 223 | if (system(buf) != 0) { |
| 224 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 225 | "wifitool ap_group_id failed"); |
| 226 | } |
| 227 | } |
| 228 | |
| 229 | |
| 230 | void ath_set_cts_width(struct sigma_dut *dut, const char *ifname, |
| 231 | const char *val) |
| 232 | { |
| 233 | char buf[60]; |
| 234 | |
| 235 | /* TODO: Enable support for other values */ |
| 236 | if (strcasecmp(val, "40") == 0) { |
| 237 | snprintf(buf, sizeof(buf), "wifitool %s beeliner_fw_test 54 1", |
| 238 | ifname); |
| 239 | if (system(buf) != 0) { |
| 240 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 241 | "wifitool cts_width failed"); |
| 242 | } |
Priyadharshini Gowthaman | 818afef | 2015-11-09 13:28:15 -0800 | [diff] [blame] | 243 | snprintf(buf, sizeof(buf), |
| 244 | "athdiag --set --address=0x10024 --val=0xd90b8a14"); |
| 245 | if (system(buf) != 0) { |
| 246 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 247 | "disabling phy restart failed"); |
| 248 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 249 | } else { |
| 250 | sigma_dut_print(dut, DUT_MSG_ERROR, "Unsupported CTS_WIDTH"); |
| 251 | } |
| 252 | } |
| 253 | |
| 254 | |
Priyadharshini Gowthaman | 818afef | 2015-11-09 13:28:15 -0800 | [diff] [blame] | 255 | void ath_config_dyn_bw_sig(struct sigma_dut *dut, const char *ifname, |
| 256 | const char *val) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 257 | { |
| 258 | char buf[60]; |
| 259 | |
| 260 | if (strcasecmp(val, "enable") == 0) { |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 261 | dut->ap_dyn_bw_sig = VALUE_ENABLED; |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 262 | run_iwpriv(dut, ifname, "cwmenable 1"); |
| 263 | |
Priyadharshini Gowthaman | 818afef | 2015-11-09 13:28:15 -0800 | [diff] [blame] | 264 | snprintf(buf, sizeof(buf), "wifitool %s beeliner_fw_test 96 1", |
| 265 | ifname); |
| 266 | if (system(buf) != 0) { |
| 267 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 268 | "disabling RTS from rate control logic failed"); |
| 269 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 270 | } else if (strcasecmp(val, "disable") == 0) { |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 271 | dut->ap_dyn_bw_sig = VALUE_DISABLED; |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 272 | run_iwpriv(dut, ifname, "cwmenable 0"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 273 | } else { |
| 274 | sigma_dut_print(dut, DUT_MSG_ERROR, "Unsupported DYN_BW_SGL"); |
| 275 | } |
| 276 | } |
| 277 | |
| 278 | |
| 279 | static void ath_config_rts_force(struct sigma_dut *dut, const char *ifname, |
| 280 | const char *val) |
| 281 | { |
| 282 | char buf[60]; |
| 283 | |
| 284 | if (strcasecmp(val, "enable") == 0) { |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 285 | dut->ap_sig_rts = VALUE_ENABLED; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 286 | snprintf(buf, sizeof(buf), "iwconfig %s rts 64", ifname); |
| 287 | if (system(buf) != 0) { |
| 288 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 289 | "iwconfig rts 64 failed"); |
| 290 | } |
priyadharshini gowthaman | 270870e | 2015-12-09 10:10:23 -0800 | [diff] [blame] | 291 | snprintf(buf, sizeof(buf), "wifitool %s beeliner_fw_test 100 1", |
| 292 | ifname); |
| 293 | if (system(buf) != 0) { |
| 294 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 295 | "wifitool beeliner_fw_test 100 1 failed"); |
| 296 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 297 | } else if (strcasecmp(val, "disable") == 0) { |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 298 | dut->ap_sig_rts = VALUE_DISABLED; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 299 | snprintf(buf, sizeof(buf), "iwconfig %s rts 2347", ifname); |
| 300 | if (system(buf) != 0) { |
| 301 | sigma_dut_print(dut, DUT_MSG_ERROR, |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 302 | "iwconfig rts 2347 failed"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 303 | } |
| 304 | } else { |
| 305 | sigma_dut_print(dut, DUT_MSG_ERROR, "Unsupported RTS_FORCE"); |
| 306 | } |
| 307 | } |
| 308 | |
| 309 | |
priyadharshini gowthaman | 09d613e | 2017-12-20 11:43:44 -0800 | [diff] [blame] | 310 | static void ath_radio(struct sigma_dut *dut, const char *val) |
| 311 | { |
| 312 | if (strcasecmp(val, "on") == 0) { |
| 313 | if (dut->ap_interface_5g == 1) { |
| 314 | run_system(dut, "uci set wireless.wifi0.disabled=0"); |
| 315 | } else if (dut->ap_interface_2g == 1) { |
| 316 | run_system(dut, "uci set wireless.wifi1.disabled=0"); |
| 317 | } else { |
| 318 | run_system(dut, "uci set wireless.wifi0.disabled=0"); |
| 319 | run_system(dut, "uci set wireless.wifi1.disabled=0"); |
| 320 | } |
| 321 | run_system(dut, "uci commit"); |
| 322 | run_system(dut, "wifi down"); |
| 323 | run_system(dut, "wifi up"); |
| 324 | } else if (strcasecmp(val, "off") == 0) { |
| 325 | if (dut->ap_interface_5g == 1) { |
| 326 | run_system(dut, "uci set wireless.wifi0.disabled=1"); |
| 327 | } else if (dut->ap_interface_2g == 1) { |
| 328 | run_system(dut, "uci set wireless.wifi1.disabled=1"); |
| 329 | } else { |
| 330 | run_system(dut, "uci set wireless.wifi0.disabled=1"); |
| 331 | run_system(dut, "uci set wireless.wifi1.disabled=1"); |
| 332 | } |
| 333 | run_system(dut, "uci commit"); |
| 334 | run_system(dut, "wifi down"); |
| 335 | run_system(dut, "wifi up"); |
| 336 | } |
| 337 | } |
| 338 | |
| 339 | |
priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 340 | static void deauth_disassoc(struct sigma_dut *dut, const char *ifname, |
| 341 | const char *val) |
| 342 | { |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 343 | if (strcasecmp(val, "disable") == 0) |
| 344 | run_iwpriv(dut, ifname, "stealthdown 1"); |
priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 345 | } |
| 346 | |
| 347 | |
priyadharshini gowthaman | cb22e43 | 2017-12-28 15:23:31 -0800 | [diff] [blame] | 348 | static void ath_set_txpower(struct sigma_dut *dut, const char *ifname, |
| 349 | const char *val) |
| 350 | { |
| 351 | char buf[60]; |
| 352 | |
| 353 | if (strcasecmp(val, "high") == 0) |
| 354 | snprintf(buf, sizeof(buf), "iwconfig %s txpower 29", ifname); |
| 355 | else if (strcasecmp(val, "low") == 0) |
| 356 | snprintf(buf, sizeof(buf), "iwconfig %s txpower 1", ifname); |
| 357 | else |
| 358 | sigma_dut_print(dut, DUT_MSG_ERROR, "Unsupported txpower"); |
| 359 | |
| 360 | if (system(buf) != 0) |
| 361 | sigma_dut_print(dut, DUT_MSG_ERROR, "setting txpower failed"); |
| 362 | } |
| 363 | |
| 364 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 365 | static enum ap_mode get_mode(const char *str) |
| 366 | { |
| 367 | if (strcasecmp(str, "11a") == 0) |
| 368 | return AP_11a; |
| 369 | else if (strcasecmp(str, "11g") == 0) |
| 370 | return AP_11g; |
| 371 | else if (strcasecmp(str, "11b") == 0) |
| 372 | return AP_11b; |
| 373 | else if (strcasecmp(str, "11na") == 0) |
| 374 | return AP_11na; |
| 375 | else if (strcasecmp(str, "11ng") == 0) |
| 376 | return AP_11ng; |
| 377 | else if (strcasecmp(str, "11ac") == 0 || strcasecmp(str, "ac") == 0) |
| 378 | return AP_11ac; |
Alexei Avshalom Lazar | 2712cc8 | 2018-12-23 16:29:14 +0200 | [diff] [blame] | 379 | else if (strcasecmp(str, "11ad") == 0) |
| 380 | return AP_11ad; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 381 | else |
| 382 | return AP_inval; |
| 383 | } |
| 384 | |
| 385 | |
| 386 | static int run_hostapd_cli(struct sigma_dut *dut, char *buf) |
| 387 | { |
| 388 | char command[1000]; |
| 389 | const char *bin; |
| 390 | enum driver_type drv = get_driver_type(); |
Adil Saeed Musthafa | 3dd6ca7 | 2017-05-15 12:45:18 -0700 | [diff] [blame] | 391 | char *sigma_hapd_file = sigma_hapd_ctrl; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 392 | |
| 393 | if (file_exists("hostapd_cli")) |
| 394 | bin = "./hostapd_cli"; |
Jouni Malinen | d6bf1b4 | 2017-06-23 17:51:01 +0300 | [diff] [blame] | 395 | else if (file_exists("../../hostapd/hostapd_cli")) |
| 396 | bin = "../../hostapd/hostapd_cli"; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 397 | else |
| 398 | bin = "hostapd_cli"; |
| 399 | |
| 400 | if (drv == DRIVER_OPENWRT && sigma_hapd_ctrl == NULL) { |
Adil Saeed Musthafa | 3dd6ca7 | 2017-05-15 12:45:18 -0700 | [diff] [blame] | 401 | sigma_hapd_file = "/var/run/hostapd-wifi0"; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 402 | |
| 403 | if (sigma_radio_ifname[0] && |
| 404 | strcmp(sigma_radio_ifname[0], "wifi1") == 0) |
Adil Saeed Musthafa | 3dd6ca7 | 2017-05-15 12:45:18 -0700 | [diff] [blame] | 405 | sigma_hapd_file = "/var/run/hostapd-wifi1"; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 406 | else if (sigma_radio_ifname[0] && |
| 407 | strcmp(sigma_radio_ifname[0], "wifi2") == 0) |
Adil Saeed Musthafa | 3dd6ca7 | 2017-05-15 12:45:18 -0700 | [diff] [blame] | 408 | sigma_hapd_file = "/var/run/hostapd-wifi2"; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 409 | } |
| 410 | |
Adil Saeed Musthafa | 3dd6ca7 | 2017-05-15 12:45:18 -0700 | [diff] [blame] | 411 | if (sigma_hapd_file) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 412 | snprintf(command, sizeof(command), "%s -p %s %s", |
Adil Saeed Musthafa | 3dd6ca7 | 2017-05-15 12:45:18 -0700 | [diff] [blame] | 413 | bin, sigma_hapd_file, buf); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 414 | else |
| 415 | snprintf(command, sizeof(command), "%s %s", bin, buf); |
| 416 | return run_system(dut, command); |
| 417 | } |
| 418 | |
| 419 | |
priyadharshini gowthaman | 8e26ff4 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 420 | static int ath_set_lci_config(struct sigma_dut *dut, const char *val, |
| 421 | struct sigma_cmd *cmd) |
| 422 | { |
| 423 | FILE *f; |
| 424 | int i; |
| 425 | |
| 426 | f = fopen("/tmp/lci_cfg.txt", "w"); |
| 427 | if (!f) { |
| 428 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 429 | "Failed to open /tmp/lci_cfg.txt"); |
| 430 | return -1; |
| 431 | } |
| 432 | |
| 433 | for (i = 2; i < cmd->count; i++) |
| 434 | fprintf(f, "%s = %s \n", cmd->params[i], cmd->values[i]); |
| 435 | fprintf(f, "\n"); |
| 436 | fclose(f); |
| 437 | |
| 438 | return 0; |
| 439 | } |
| 440 | |
| 441 | |
hangtian | 0060662 | 2019-04-19 11:15:48 +0800 | [diff] [blame] | 442 | static void set_ap_country_code(struct sigma_dut *dut) |
| 443 | { |
| 444 | #if defined(ANDROID) || defined(LINUX_EMBEDDED) |
| 445 | char buf[256]; |
| 446 | |
| 447 | if (dut->ap_countrycode[0]) { |
| 448 | snprintf(buf, sizeof(buf), "DRIVER COUNTRY %s", |
| 449 | dut->ap_countrycode); |
| 450 | if (wpa_command(get_station_ifname(), buf) < 0) |
| 451 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 452 | "Failed to set country code"); |
| 453 | else |
| 454 | sigma_dut_print(dut, DUT_MSG_INFO, |
| 455 | "Successfully set country code to %s", |
| 456 | dut->ap_countrycode); |
| 457 | } |
| 458 | #endif |
| 459 | } |
| 460 | |
| 461 | |
Jouni Malinen | f722271 | 2019-06-13 01:50:21 +0300 | [diff] [blame] | 462 | static enum sigma_cmd_result cmd_ap_set_wireless(struct sigma_dut *dut, |
| 463 | struct sigma_conn *conn, |
| 464 | struct sigma_cmd *cmd) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 465 | { |
| 466 | /* const char *name = get_param(cmd, "NAME"); */ |
| 467 | /* const char *ifname = get_param(cmd, "INTERFACE"); */ |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 468 | const char *val; |
| 469 | unsigned int wlan_tag = 1; |
| 470 | char *ifname = get_main_ifname(); |
Alexei Avshalom Lazar | 79f5727 | 2018-12-23 17:22:47 +0200 | [diff] [blame] | 471 | char buf[128]; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 472 | |
Alexei Avshalom Lazar | 2712cc8 | 2018-12-23 16:29:14 +0200 | [diff] [blame] | 473 | /* Allow program to be overridden if specified in the ap_set_wireless |
| 474 | * to support some 60 GHz test scripts where the program may be 60 GHz |
| 475 | * or WPS. */ |
| 476 | val = get_param(cmd, "PROGRAM"); |
| 477 | if (val) |
| 478 | dut->program = sigma_program_to_enum(val); |
| 479 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 480 | val = get_param(cmd, "WLAN_TAG"); |
| 481 | if (val) { |
| 482 | wlan_tag = atoi(val); |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 483 | if (wlan_tag < 1 || wlan_tag > 3) { |
| 484 | /* |
| 485 | * The only valid WLAN Tags as of now as per the latest |
| 486 | * WFA scripts are 1, 2, and 3. |
| 487 | */ |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 488 | send_resp(dut, conn, SIGMA_INVALID, |
| 489 | "errorCode,Invalid WLAN_TAG"); |
Jouni Malinen | dccfd0c | 2019-10-30 12:05:59 +0200 | [diff] [blame] | 490 | return STATUS_SENT; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 491 | } |
| 492 | } |
| 493 | |
priyadharshini gowthaman | 09d613e | 2017-12-20 11:43:44 -0800 | [diff] [blame] | 494 | val = get_param(cmd, "Interface"); |
| 495 | if (val) { |
| 496 | if (strcasecmp(val, "5G") == 0) |
| 497 | dut->ap_interface_5g = 1; |
| 498 | else |
| 499 | dut->ap_interface_2g = 1; |
| 500 | |
| 501 | if (dut->ap_interface_5g && dut->ap_interface_2g) |
| 502 | dut->ap_is_dual = 1; |
| 503 | } |
| 504 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 505 | val = get_param(cmd, "CountryCode"); |
| 506 | if (val) { |
| 507 | if (strlen(val) > sizeof(dut->ap_countrycode) - 1) |
Jouni Malinen | dccfd0c | 2019-10-30 12:05:59 +0200 | [diff] [blame] | 508 | return INVALID_SEND_STATUS; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 509 | snprintf(dut->ap_countrycode, sizeof(dut->ap_countrycode), |
| 510 | "%s", val); |
hangtian | 0060662 | 2019-04-19 11:15:48 +0800 | [diff] [blame] | 511 | |
| 512 | /* |
| 513 | * Regdomain self-managed driver does not accept hostapd country |
| 514 | * code setting in all cases. Try to use wpa_supplicant DRIVER |
| 515 | * command first to set the driver to a specific country code |
| 516 | * before starting AP functionality. This is targeting cases |
| 517 | * where wpa_supplicant is running on the device as well for |
| 518 | * non-AP mode functionality. |
| 519 | */ |
| 520 | if (get_driver_type() == DRIVER_LINUX_WCN) |
| 521 | set_ap_country_code(dut); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 522 | } |
| 523 | |
Pradeep Reddy POTTETI | fba27db | 2015-11-20 16:42:22 +0530 | [diff] [blame] | 524 | val = get_param(cmd, "regulatory_mode"); |
| 525 | if (val) { |
| 526 | if (strcasecmp(val, "11d") == 0 || strcasecmp(val, "11h") == 0) |
| 527 | dut->ap_regulatory_mode = AP_80211D_MODE_ENABLED; |
| 528 | } |
| 529 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 530 | val = get_param(cmd, "SSID"); |
| 531 | if (val) { |
| 532 | if (strlen(val) > sizeof(dut->ap_ssid) - 1) |
Jouni Malinen | dccfd0c | 2019-10-30 12:05:59 +0200 | [diff] [blame] | 533 | return INVALID_SEND_STATUS; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 534 | |
| 535 | if (wlan_tag == 1) { |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 536 | /* |
| 537 | * If tag is not specified, it is deemed to be 1. |
| 538 | * Hence tag of 1 is a special case and the values |
| 539 | * corresponding to wlan-tag=1 are stored separately |
| 540 | * from the values corresponding tags 2 and 3. |
| 541 | * This approach minimises the changes to existing code |
| 542 | * since most of the sigma_dut code does not deal with |
| 543 | * WLAN-TAG CAPI variable. |
| 544 | */ |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 545 | snprintf(dut->ap_ssid, |
| 546 | sizeof(dut->ap_ssid), "%s", val); |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 547 | } else { |
| 548 | snprintf(dut->ap_tag_ssid[wlan_tag - 2], |
| 549 | sizeof(dut->ap_tag_ssid[wlan_tag - 2]), |
| 550 | "%s", val); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 551 | } |
| 552 | } |
| 553 | |
| 554 | val = get_param(cmd, "CHANNEL"); |
| 555 | if (val) { |
| 556 | const char *pos; |
| 557 | dut->ap_channel = atoi(val); |
| 558 | pos = strchr(val, ';'); |
| 559 | if (pos) { |
| 560 | pos++; |
| 561 | dut->ap_channel_1 = atoi(pos); |
| 562 | } |
| 563 | } |
| 564 | |
Pradeep Reddy POTTETI | fba27db | 2015-11-20 16:42:22 +0530 | [diff] [blame] | 565 | /* Overwrite the AP channel with DFS channel if configured */ |
| 566 | val = get_param(cmd, "dfs_chan"); |
| 567 | if (val) { |
| 568 | dut->ap_channel = atoi(val); |
| 569 | } |
| 570 | |
| 571 | val = get_param(cmd, "dfs_mode"); |
| 572 | if (val) { |
| 573 | if (strcasecmp(val, "Enable") == 0) |
| 574 | dut->ap_dfs_mode = AP_DFS_MODE_ENABLED; |
| 575 | else if (strcasecmp(val, "Disable") == 0) |
| 576 | dut->ap_dfs_mode = AP_DFS_MODE_DISABLED; |
| 577 | else |
| 578 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 579 | "Unsupported dfs_mode value: %s", val); |
| 580 | } |
| 581 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 582 | val = get_param(cmd, "MODE"); |
| 583 | if (val) { |
| 584 | char *str, *pos; |
| 585 | |
| 586 | str = strdup(val); |
| 587 | if (str == NULL) |
Jouni Malinen | dccfd0c | 2019-10-30 12:05:59 +0200 | [diff] [blame] | 588 | return INVALID_SEND_STATUS; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 589 | pos = strchr(str, ';'); |
| 590 | if (pos) |
| 591 | *pos++ = '\0'; |
| 592 | |
| 593 | dut->ap_is_dual = 0; |
| 594 | dut->ap_mode = get_mode(str); |
| 595 | if (dut->ap_mode == AP_inval) { |
| 596 | send_resp(dut, conn, SIGMA_INVALID, |
| 597 | "errorCode,Unsupported MODE"); |
| 598 | free(str); |
Jouni Malinen | dccfd0c | 2019-10-30 12:05:59 +0200 | [diff] [blame] | 599 | return STATUS_SENT; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 600 | } |
priyadharshini gowthaman | 63ab848 | 2017-12-28 15:32:55 -0800 | [diff] [blame] | 601 | if (dut->ap_mode == AP_11ac && dut->ap_80plus80 != 1) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 602 | dut->ap_chwidth = AP_80; |
| 603 | |
| 604 | if (pos) { |
| 605 | dut->ap_mode_1 = get_mode(pos); |
| 606 | if (dut->ap_mode_1 == AP_inval) { |
| 607 | send_resp(dut, conn, SIGMA_INVALID, |
| 608 | "errorCode,Unsupported MODE"); |
| 609 | free(str); |
Jouni Malinen | dccfd0c | 2019-10-30 12:05:59 +0200 | [diff] [blame] | 610 | return STATUS_SENT; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 611 | } |
| 612 | if (dut->ap_mode_1 == AP_11ac) |
| 613 | dut->ap_chwidth_1 = AP_80; |
| 614 | dut->ap_is_dual = 1; |
| 615 | } |
| 616 | |
| 617 | free(str); |
| 618 | } else if (dut->ap_mode == AP_inval) { |
| 619 | if (dut->ap_channel <= 11) |
| 620 | dut->ap_mode = AP_11ng; |
| 621 | else if (dut->program == PROGRAM_VHT) |
| 622 | dut->ap_mode = AP_11ac; |
| 623 | else |
| 624 | dut->ap_mode = AP_11na; |
| 625 | } |
| 626 | |
Alexei Avshalom Lazar | 2712cc8 | 2018-12-23 16:29:14 +0200 | [diff] [blame] | 627 | /* Override the AP mode in case of 60 GHz */ |
| 628 | if (dut->program == PROGRAM_60GHZ) { |
| 629 | dut->ap_mode = AP_11ad; |
| 630 | /* Workaround to force channel 2 if not specified */ |
| 631 | if (!dut->ap_channel) |
| 632 | dut->ap_channel = 2; |
| 633 | } |
| 634 | |
Pradeep Reddy POTTETI | 0d3db63 | 2016-03-11 15:21:11 +0530 | [diff] [blame] | 635 | val = get_param(cmd, "WME"); |
| 636 | if (val) { |
| 637 | if (strcasecmp(val, "on") == 0) |
| 638 | dut->ap_wme = AP_WME_ON; |
| 639 | else if (strcasecmp(val, "off") == 0) |
| 640 | dut->ap_wme = AP_WME_OFF; |
| 641 | else |
| 642 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 643 | "Unsupported WME value: %s", val); |
| 644 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 645 | |
Mohammed Shafi Shajakhan | 02e3b82 | 2017-02-23 04:15:02 +0530 | [diff] [blame] | 646 | val = get_param(cmd, "WMMPS"); |
| 647 | if (val) { |
| 648 | if (strcasecmp(val, "on") == 0) |
| 649 | dut->ap_wmmps = AP_WMMPS_ON; |
| 650 | else if (strcasecmp(val, "off") == 0) |
| 651 | dut->ap_wmmps = AP_WMMPS_OFF; |
| 652 | else |
| 653 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 654 | "Unsupported WMMPS value: %s", val); |
| 655 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 656 | |
| 657 | val = get_param(cmd, "RTS"); |
| 658 | if (val) |
| 659 | dut->ap_rts = atoi(val); |
| 660 | |
| 661 | val = get_param(cmd, "FRGMNT"); |
| 662 | if (val) |
| 663 | dut->ap_frgmnt = atoi(val); |
| 664 | |
| 665 | /* TODO: PWRSAVE */ |
| 666 | |
| 667 | val = get_param(cmd, "BCNINT"); |
| 668 | if (val) |
| 669 | dut->ap_bcnint = atoi(val); |
| 670 | |
| 671 | val = get_param(cmd, "RADIO"); |
| 672 | if (val) { |
Mohammed Shafi Shajakhan | 94997f9 | 2017-01-09 21:31:09 +0530 | [diff] [blame] | 673 | enum driver_type drv = get_driver_type(); |
| 674 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 675 | if (strcasecmp(val, "on") == 0) { |
priyadharshini gowthaman | 09d613e | 2017-12-20 11:43:44 -0800 | [diff] [blame] | 676 | if (drv == DRIVER_OPENWRT) |
| 677 | ath_radio(dut, val); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 678 | if (drv == DRIVER_ATHEROS) |
| 679 | ath_ap_start_hostapd(dut); |
| 680 | else if (cmd_ap_config_commit(dut, conn, cmd) <= 0) |
Jouni Malinen | dccfd0c | 2019-10-30 12:05:59 +0200 | [diff] [blame] | 681 | return STATUS_SENT; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 682 | } else if (strcasecmp(val, "off") == 0) { |
Mohammed Shafi Shajakhan | 94997f9 | 2017-01-09 21:31:09 +0530 | [diff] [blame] | 683 | if (drv == DRIVER_OPENWRT) { |
priyadharshini gowthaman | 09d613e | 2017-12-20 11:43:44 -0800 | [diff] [blame] | 684 | ath_radio(dut, val); |
Jouni Malinen | d6bf1b4 | 2017-06-23 17:51:01 +0300 | [diff] [blame] | 685 | } else if (dut->use_hostapd_pid_file) { |
| 686 | kill_hostapd_process_pid(dut); |
Mohammed Shafi Shajakhan | 94997f9 | 2017-01-09 21:31:09 +0530 | [diff] [blame] | 687 | } else if (kill_process(dut, "(hostapd)", 1, |
| 688 | SIGTERM) == 0 || |
| 689 | system("killall hostapd") == 0) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 690 | sigma_dut_print(dut, DUT_MSG_INFO, |
| 691 | "Killed hostapd on radio,off"); |
| 692 | } |
| 693 | } else { |
| 694 | send_resp(dut, conn, SIGMA_INVALID, |
| 695 | "errorCode,Unsupported RADIO value"); |
Jouni Malinen | dccfd0c | 2019-10-30 12:05:59 +0200 | [diff] [blame] | 696 | return STATUS_SENT; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 697 | } |
| 698 | } |
| 699 | |
| 700 | val = get_param(cmd, "P2PMgmtBit"); |
| 701 | if (val) |
| 702 | dut->ap_p2p_mgmt = atoi(val); |
| 703 | |
| 704 | /* TODO: ChannelUsage */ |
| 705 | |
| 706 | /* TODO: 40_INTOLERANT */ |
| 707 | |
| 708 | val = get_param(cmd, "ADDBA_REJECT"); |
| 709 | if (val) { |
| 710 | if (strcasecmp(val, "Enable") == 0) |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 711 | dut->ap_addba_reject = VALUE_ENABLED; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 712 | else if (strcasecmp(val, "Disable") == 0) |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 713 | dut->ap_addba_reject = VALUE_DISABLED; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 714 | } |
| 715 | |
| 716 | val = get_param(cmd, "AMPDU"); |
| 717 | if (val) { |
| 718 | if (strcasecmp(val, "Enable") == 0) |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 719 | dut->ap_ampdu = VALUE_ENABLED; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 720 | else if (strcasecmp(val, "Disable") == 0) |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 721 | dut->ap_ampdu = VALUE_DISABLED; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 722 | } |
| 723 | |
| 724 | val = get_param(cmd, "AMPDU_EXP"); |
| 725 | if (val) |
| 726 | dut->ap_ampdu_exp = atoi(val); |
| 727 | |
| 728 | val = get_param(cmd, "AMSDU"); |
| 729 | if (val) { |
| 730 | if (strcasecmp(val, "Enable") == 0) |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 731 | dut->ap_amsdu = VALUE_ENABLED; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 732 | else if (strcasecmp(val, "Disable") == 0) |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 733 | dut->ap_amsdu = VALUE_DISABLED; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 734 | } |
| 735 | |
| 736 | val = get_param(cmd, "NoAck"); |
| 737 | if (val) { |
| 738 | if (strcasecmp(val, "on") == 0) |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 739 | dut->ap_noack = VALUE_ENABLED; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 740 | else if (strcasecmp(val, "off") == 0) |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 741 | dut->ap_noack = VALUE_DISABLED; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 742 | } |
| 743 | |
| 744 | /* TODO: GREENFIELD */ |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 745 | /* TODO: MCS_32 */ |
| 746 | |
Pradeep Reddy Potteti | 4b0cdee | 2017-03-15 12:37:33 +0530 | [diff] [blame] | 747 | val = get_param(cmd, "OFFSET"); |
| 748 | if (val) { |
| 749 | if (strcasecmp(val, "Above") == 0) |
| 750 | dut->ap_chwidth_offset = SEC_CH_40ABOVE; |
| 751 | else if (strcasecmp(val, "Below") == 0) |
| 752 | dut->ap_chwidth_offset = SEC_CH_40BELOW; |
| 753 | } |
| 754 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 755 | val = get_param(cmd, "MCS_FIXEDRATE"); |
| 756 | if (val) { |
| 757 | dut->ap_fixed_rate = 1; |
| 758 | dut->ap_mcs = atoi(val); |
| 759 | } |
| 760 | |
| 761 | val = get_param(cmd, "SPATIAL_RX_STREAM"); |
| 762 | if (val) { |
| 763 | if (strcasecmp(val, "1SS") == 0 || strcasecmp(val, "1") == 0) { |
| 764 | dut->ap_rx_streams = 1; |
| 765 | if (dut->device_type == AP_testbed) |
| 766 | dut->ap_vhtmcs_map = 0xfffc; |
| 767 | } else if (strcasecmp(val, "2SS") == 0 || |
| 768 | strcasecmp(val, "2") == 0) { |
| 769 | dut->ap_rx_streams = 2; |
| 770 | if (dut->device_type == AP_testbed) |
| 771 | dut->ap_vhtmcs_map = 0xfff0; |
| 772 | } else if (strcasecmp(val, "3SS") == 0 || |
| 773 | strcasecmp(val, "3") == 0) { |
| 774 | dut->ap_rx_streams = 3; |
| 775 | if (dut->device_type == AP_testbed) |
| 776 | dut->ap_vhtmcs_map = 0xffc0; |
| 777 | } else if (strcasecmp(val, "4SS") == 0 || |
| 778 | strcasecmp(val, "4") == 0) { |
| 779 | dut->ap_rx_streams = 4; |
| 780 | } |
| 781 | } |
| 782 | |
| 783 | val = get_param(cmd, "SPATIAL_TX_STREAM"); |
| 784 | if (val) { |
| 785 | if (strcasecmp(val, "1SS") == 0 || |
| 786 | strcasecmp(val, "1") == 0) { |
| 787 | dut->ap_tx_streams = 1; |
| 788 | if (dut->device_type == AP_testbed) |
| 789 | dut->ap_vhtmcs_map = 0xfffc; |
| 790 | } else if (strcasecmp(val, "2SS") == 0 || |
| 791 | strcasecmp(val, "2") == 0) { |
| 792 | dut->ap_tx_streams = 2; |
| 793 | if (dut->device_type == AP_testbed) |
| 794 | dut->ap_vhtmcs_map = 0xfff0; |
| 795 | } else if (strcasecmp(val, "3SS") == 0 || |
| 796 | strcasecmp(val, "3") == 0) { |
| 797 | dut->ap_tx_streams = 3; |
| 798 | if (dut->device_type == AP_testbed) |
| 799 | dut->ap_vhtmcs_map = 0xffc0; |
| 800 | } else if (strcasecmp(val, "4SS") == 0 || |
| 801 | strcasecmp(val, "4") == 0) { |
| 802 | dut->ap_tx_streams = 4; |
| 803 | } |
| 804 | } |
| 805 | |
Adil Saeed Musthafa | 33ea287 | 2017-04-10 23:13:24 -0700 | [diff] [blame] | 806 | val = get_param(cmd, "BSS_max_idle"); |
| 807 | if (val) { |
| 808 | if (strncasecmp(val, "Enable", 7) == 0) { |
| 809 | dut->wnm_bss_max_feature = VALUE_ENABLED; |
| 810 | } else if (strncasecmp(val, "Disable", 8) == 0) { |
| 811 | dut->wnm_bss_max_feature = VALUE_DISABLED; |
| 812 | } else { |
| 813 | send_resp(dut, conn, SIGMA_ERROR, |
| 814 | "errorCode,Invalid value for BSS_max_Feature"); |
Jouni Malinen | dccfd0c | 2019-10-30 12:05:59 +0200 | [diff] [blame] | 815 | return STATUS_SENT; |
Adil Saeed Musthafa | 33ea287 | 2017-04-10 23:13:24 -0700 | [diff] [blame] | 816 | } |
| 817 | } |
| 818 | |
| 819 | val = get_param(cmd, "BSS_Idle_Protection_options"); |
| 820 | if (val) { |
| 821 | int protection = (int) strtol(val, (char **) NULL, 10); |
| 822 | |
| 823 | if (protection != 1 && protection != 0) { |
| 824 | send_resp(dut, conn, SIGMA_ERROR, |
| 825 | "errorCode,Invalid value for BSS_Idle_Protection_options"); |
Jouni Malinen | dccfd0c | 2019-10-30 12:05:59 +0200 | [diff] [blame] | 826 | return STATUS_SENT; |
Adil Saeed Musthafa | 33ea287 | 2017-04-10 23:13:24 -0700 | [diff] [blame] | 827 | } |
| 828 | dut->wnm_bss_max_protection = protection ? |
| 829 | VALUE_ENABLED : VALUE_DISABLED; |
| 830 | } |
| 831 | |
| 832 | val = get_param(cmd, "BSS_max_Idle_period"); |
| 833 | if (val) { |
Jouni Malinen | 544edf0 | 2019-02-25 19:02:33 +0200 | [diff] [blame] | 834 | long int idle_time = strtol(val, (char **) NULL, 10); |
Adil Saeed Musthafa | 33ea287 | 2017-04-10 23:13:24 -0700 | [diff] [blame] | 835 | |
| 836 | if (idle_time == LONG_MIN || idle_time == LONG_MAX) { |
| 837 | send_resp(dut, conn, SIGMA_ERROR, |
| 838 | "errorCode,Invalid value for BSS_max_Idle_period"); |
Jouni Malinen | dccfd0c | 2019-10-30 12:05:59 +0200 | [diff] [blame] | 839 | return STATUS_SENT; |
Adil Saeed Musthafa | 33ea287 | 2017-04-10 23:13:24 -0700 | [diff] [blame] | 840 | } |
Jouni Malinen | 544edf0 | 2019-02-25 19:02:33 +0200 | [diff] [blame] | 841 | dut->wnm_bss_max_idle_time = (int) idle_time; |
Adil Saeed Musthafa | 33ea287 | 2017-04-10 23:13:24 -0700 | [diff] [blame] | 842 | } |
| 843 | |
| 844 | val = get_param(cmd, "PROXY_ARP"); |
| 845 | if (val) |
| 846 | dut->ap_proxy_arp = (int) strtol(val, (char **) NULL, 10); |
| 847 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 848 | val = get_param(cmd, "nss_mcs_cap"); |
| 849 | if (val) { |
| 850 | int nss, mcs; |
| 851 | char token[20]; |
| 852 | char *result = NULL; |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 853 | char *saveptr; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 854 | |
| 855 | if (strlen(val) >= sizeof(token)) |
Jouni Malinen | dccfd0c | 2019-10-30 12:05:59 +0200 | [diff] [blame] | 856 | return INVALID_SEND_STATUS; |
Jouni Malinen | 947fdf6 | 2017-05-14 22:29:32 +0300 | [diff] [blame] | 857 | strlcpy(token, val, sizeof(token)); |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 858 | result = strtok_r(token, ";", &saveptr); |
Pradeep Reddy POTTETI | 41b8c54 | 2016-06-15 16:09:46 +0530 | [diff] [blame] | 859 | if (!result) { |
Jouni Malinen | 9aa4b37 | 2019-10-30 12:08:15 +0200 | [diff] [blame^] | 860 | send_resp(dut, conn, SIGMA_ERROR, |
| 861 | "errorCode,VHT NSS not specified"); |
| 862 | return STATUS_SENT; |
Pradeep Reddy POTTETI | 41b8c54 | 2016-06-15 16:09:46 +0530 | [diff] [blame] | 863 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 864 | nss = atoi(result); |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 865 | result = strtok_r(NULL, ";", &saveptr); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 866 | if (result == NULL) { |
Jouni Malinen | 9aa4b37 | 2019-10-30 12:08:15 +0200 | [diff] [blame^] | 867 | send_resp(dut, conn, SIGMA_ERROR, |
| 868 | "errorCode,VHTMCS not specified"); |
| 869 | return STATUS_SENT; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 870 | } |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 871 | result = strtok_r(result, "-", &saveptr); |
| 872 | result = strtok_r(NULL, "-", &saveptr); |
Pradeep Reddy POTTETI | 41b8c54 | 2016-06-15 16:09:46 +0530 | [diff] [blame] | 873 | if (!result) { |
Jouni Malinen | 9aa4b37 | 2019-10-30 12:08:15 +0200 | [diff] [blame^] | 874 | send_resp(dut, conn, SIGMA_ERROR, |
| 875 | "errorCode,VHT MCS not specified"); |
| 876 | return STATUS_SENT; |
Pradeep Reddy POTTETI | 41b8c54 | 2016-06-15 16:09:46 +0530 | [diff] [blame] | 877 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 878 | mcs = atoi(result); |
| 879 | switch (nss) { |
| 880 | case 1: |
| 881 | switch (mcs) { |
| 882 | case 7: |
| 883 | dut->ap_vhtmcs_map = 0xfffc; |
| 884 | break; |
| 885 | case 8: |
| 886 | dut->ap_vhtmcs_map = 0xfffd; |
| 887 | break; |
| 888 | case 9: |
| 889 | dut->ap_vhtmcs_map = 0xfffe; |
| 890 | break; |
| 891 | default: |
| 892 | dut->ap_vhtmcs_map = 0xfffe; |
| 893 | break; |
| 894 | } |
| 895 | break; |
| 896 | case 2: |
| 897 | switch (mcs) { |
| 898 | case 7: |
| 899 | dut->ap_vhtmcs_map = 0xfff0; |
| 900 | break; |
| 901 | case 8: |
| 902 | dut->ap_vhtmcs_map = 0xfff5; |
| 903 | break; |
| 904 | case 9: |
| 905 | dut->ap_vhtmcs_map = 0xfffa; |
| 906 | break; |
| 907 | default: |
| 908 | dut->ap_vhtmcs_map = 0xfffa; |
| 909 | break; |
| 910 | } |
| 911 | break; |
| 912 | case 3: |
| 913 | switch (mcs) { |
| 914 | case 7: |
| 915 | dut->ap_vhtmcs_map = 0xffc0; |
| 916 | break; |
| 917 | case 8: |
| 918 | dut->ap_vhtmcs_map = 0xffd5; |
| 919 | break; |
| 920 | case 9: |
| 921 | dut->ap_vhtmcs_map = 0xffea; |
| 922 | break; |
| 923 | default: |
| 924 | dut->ap_vhtmcs_map = 0xffea; |
| 925 | break; |
| 926 | } |
| 927 | break; |
| 928 | default: |
| 929 | dut->ap_vhtmcs_map = 0xffea; |
| 930 | break; |
| 931 | } |
| 932 | } |
| 933 | |
| 934 | /* TODO: MPDU_MIN_START_SPACING */ |
| 935 | /* TODO: RIFS_TEST */ |
| 936 | /* TODO: SGI20 */ |
| 937 | |
| 938 | val = get_param(cmd, "STBC_TX"); |
| 939 | if (val) |
| 940 | dut->ap_tx_stbc = atoi(val); |
| 941 | |
| 942 | val = get_param(cmd, "WIDTH"); |
| 943 | if (val) { |
| 944 | if (strcasecmp(val, "20") == 0) |
| 945 | dut->ap_chwidth = AP_20; |
| 946 | else if (strcasecmp(val, "40") == 0) |
| 947 | dut->ap_chwidth = AP_40; |
| 948 | else if (strcasecmp(val, "80") == 0) |
| 949 | dut->ap_chwidth = AP_80; |
| 950 | else if (strcasecmp(val, "160") == 0) |
| 951 | dut->ap_chwidth = AP_160; |
priyadharshini gowthaman | 63ab848 | 2017-12-28 15:32:55 -0800 | [diff] [blame] | 952 | else if (strcasecmp(val, "80plus80") == 0) { |
| 953 | dut->ap_80plus80 = 1; |
| 954 | dut->ap_chwidth = AP_80_80; |
| 955 | } else if (strcasecmp(val, "Auto") == 0) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 956 | dut->ap_chwidth = AP_AUTO; |
| 957 | else { |
| 958 | send_resp(dut, conn, SIGMA_INVALID, |
| 959 | "errorCode,Unsupported WIDTH"); |
Jouni Malinen | dccfd0c | 2019-10-30 12:05:59 +0200 | [diff] [blame] | 960 | return STATUS_SENT; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 961 | } |
| 962 | } |
| 963 | |
| 964 | /* TODO: WIDTH_SCAN */ |
| 965 | |
| 966 | val = get_param(cmd, "TDLSProhibit"); |
| 967 | dut->ap_tdls_prohibit = val && strcasecmp(val, "Enabled") == 0; |
| 968 | val = get_param(cmd, "TDLSChswitchProhibit"); |
| 969 | dut->ap_tdls_prohibit_chswitch = |
| 970 | val && strcasecmp(val, "Enabled") == 0; |
| 971 | val = get_param(cmd, "HS2"); |
| 972 | if (val && wlan_tag == 1) |
| 973 | dut->ap_hs2 = atoi(val); |
| 974 | val = get_param(cmd, "P2P_CROSS_CONNECT"); |
| 975 | if (val) |
| 976 | dut->ap_p2p_cross_connect = strcasecmp(val, "Enabled") == 0; |
| 977 | |
| 978 | val = get_param(cmd, "FakePubKey"); |
| 979 | dut->ap_fake_pkhash = val && atoi(val); |
| 980 | |
| 981 | val = get_param(cmd, "vht_tkip"); |
| 982 | dut->ap_allow_vht_tkip = val && strcasecmp(val, "Enable") == 0; |
| 983 | val = get_param(cmd, "vht_wep"); |
| 984 | dut->ap_allow_vht_wep = val && strcasecmp(val, "Enable") == 0; |
| 985 | |
| 986 | val = get_param(cmd, "Protect_mode"); |
| 987 | dut->ap_disable_protection = val && strcasecmp(val, "Disable") == 0; |
| 988 | |
| 989 | val = get_param(cmd, "DYN_BW_SGNL"); |
| 990 | if (val) { |
| 991 | switch (get_driver_type()) { |
| 992 | case DRIVER_OPENWRT: |
| 993 | switch (get_openwrt_driver_type()) { |
| 994 | case OPENWRT_DRIVER_ATHEROS: |
| 995 | ath_config_dyn_bw_sig(dut, ifname, val); |
| 996 | break; |
| 997 | default: |
| 998 | send_resp(dut, conn, SIGMA_ERROR, |
| 999 | "errorCode,Unsupported DYN_BW_SGNL with OpenWrt driver"); |
Jouni Malinen | dccfd0c | 2019-10-30 12:05:59 +0200 | [diff] [blame] | 1000 | return STATUS_SENT; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1001 | } |
| 1002 | break; |
Nirav Shah | 8ad8d74 | 2017-10-17 10:49:11 +0530 | [diff] [blame] | 1003 | case DRIVER_WCN: |
| 1004 | case DRIVER_LINUX_WCN: |
| 1005 | ath_config_dyn_bw_sig(dut, ifname, val); |
| 1006 | break; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1007 | default: |
| 1008 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 1009 | "Unsupported DYN_BW_SGL with the current driver"); |
| 1010 | break; |
| 1011 | } |
| 1012 | } |
| 1013 | |
| 1014 | val = get_param(cmd, "SGI80"); |
| 1015 | if (val) { |
| 1016 | if (strcasecmp(val, "enable") == 0) |
| 1017 | dut->ap_sgi80 = 1; |
| 1018 | else if (strcasecmp(val, "disable") == 0) |
| 1019 | dut->ap_sgi80 = 0; |
| 1020 | else { |
| 1021 | send_resp(dut, conn, SIGMA_INVALID, |
| 1022 | "errorCode,Unsupported SGI80"); |
Jouni Malinen | dccfd0c | 2019-10-30 12:05:59 +0200 | [diff] [blame] | 1023 | return STATUS_SENT; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1024 | } |
| 1025 | } |
| 1026 | |
| 1027 | val = get_param(cmd, "LDPC"); |
| 1028 | if (val) { |
| 1029 | if (strcasecmp(val, "enable") == 0) |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 1030 | dut->ap_ldpc = VALUE_ENABLED; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1031 | else if (strcasecmp(val, "disable") == 0) |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 1032 | dut->ap_ldpc = VALUE_DISABLED; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1033 | else { |
| 1034 | send_resp(dut, conn, SIGMA_INVALID, |
| 1035 | "errorCode,Unsupported LDPC"); |
Jouni Malinen | dccfd0c | 2019-10-30 12:05:59 +0200 | [diff] [blame] | 1036 | return STATUS_SENT; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1037 | } |
| 1038 | } |
| 1039 | |
| 1040 | val = get_param(cmd, "BW_SGNL"); |
| 1041 | if (val) { |
| 1042 | /* |
| 1043 | * With dynamic bandwidth signaling enabled we should see |
| 1044 | * RTS if the threshold is met. |
| 1045 | */ |
| 1046 | if (strcasecmp(val, "enable") == 0) { |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 1047 | dut->ap_sig_rts = VALUE_ENABLED; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1048 | } else if (strcasecmp(val, "disable") == 0) { |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 1049 | dut->ap_sig_rts = VALUE_DISABLED; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1050 | } else { |
| 1051 | send_resp(dut, conn, SIGMA_INVALID, |
| 1052 | "errorCode,Unsupported BW_SGNL"); |
Jouni Malinen | dccfd0c | 2019-10-30 12:05:59 +0200 | [diff] [blame] | 1053 | return STATUS_SENT; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1054 | } |
| 1055 | } |
| 1056 | |
| 1057 | val = get_param(cmd, "RTS_FORCE"); |
| 1058 | if (val) { |
| 1059 | switch (get_driver_type()) { |
| 1060 | case DRIVER_OPENWRT: |
| 1061 | switch (get_openwrt_driver_type()) { |
| 1062 | case OPENWRT_DRIVER_ATHEROS: |
| 1063 | ath_config_rts_force(dut, ifname, val); |
| 1064 | break; |
| 1065 | default: |
| 1066 | send_resp(dut, conn, SIGMA_ERROR, |
| 1067 | "errorCode,Unsupported RTS_FORCE with OpenWrt driver"); |
Jouni Malinen | dccfd0c | 2019-10-30 12:05:59 +0200 | [diff] [blame] | 1068 | return STATUS_SENT; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1069 | } |
| 1070 | break; |
| 1071 | default: |
| 1072 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 1073 | "Unsupported RTS_FORCE with the current driver"); |
| 1074 | break; |
| 1075 | } |
| 1076 | } |
| 1077 | |
| 1078 | val = get_param(cmd, "Zero_crc"); |
| 1079 | if (val) { |
| 1080 | switch (get_driver_type()) { |
| 1081 | case DRIVER_ATHEROS: |
| 1082 | ath_set_zero_crc(dut, val); |
| 1083 | break; |
| 1084 | case DRIVER_OPENWRT: |
| 1085 | switch (get_openwrt_driver_type()) { |
| 1086 | case OPENWRT_DRIVER_ATHEROS: |
| 1087 | ath_set_zero_crc(dut, val); |
| 1088 | break; |
| 1089 | default: |
| 1090 | send_resp(dut, conn, SIGMA_ERROR, |
| 1091 | "errorCode,Unsupported zero_crc with the current driver"); |
Jouni Malinen | dccfd0c | 2019-10-30 12:05:59 +0200 | [diff] [blame] | 1092 | return STATUS_SENT; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1093 | } |
| 1094 | break; |
| 1095 | default: |
| 1096 | send_resp(dut, conn, SIGMA_ERROR, |
| 1097 | "errorCode,Unsupported zero_crc with the current driver"); |
Jouni Malinen | dccfd0c | 2019-10-30 12:05:59 +0200 | [diff] [blame] | 1098 | return STATUS_SENT; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1099 | } |
| 1100 | } |
| 1101 | |
| 1102 | val = get_param(cmd, "TxBF"); |
| 1103 | if (val) |
| 1104 | dut->ap_txBF = strcasecmp(val, "enable") == 0; |
| 1105 | |
| 1106 | val = get_param(cmd, "MU_TxBF"); |
Manikanta Pubbisetty | 210f7c8 | 2017-02-14 12:33:54 +0530 | [diff] [blame] | 1107 | if (val) { |
| 1108 | if (strcasecmp(val, "enable") == 0) { |
| 1109 | dut->ap_txBF = 1; |
| 1110 | dut->ap_mu_txBF = 1; |
| 1111 | } else if (strcasecmp(val, "disable") == 0) { |
| 1112 | dut->ap_txBF = 0; |
| 1113 | dut->ap_mu_txBF = 0; |
| 1114 | } else { |
| 1115 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 1116 | "Unsupported MU_TxBF"); |
| 1117 | } |
| 1118 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1119 | |
| 1120 | /* UNSUPPORTED: tx_lgi_rate */ |
| 1121 | |
| 1122 | val = get_param(cmd, "wpsnfc"); |
| 1123 | if (val) |
| 1124 | dut->ap_wpsnfc = atoi(val); |
| 1125 | |
| 1126 | val = get_param(cmd, "GROUP_ID"); |
| 1127 | if (val) { |
| 1128 | switch (get_driver_type()) { |
| 1129 | case DRIVER_OPENWRT: |
| 1130 | switch (get_openwrt_driver_type()) { |
| 1131 | case OPENWRT_DRIVER_ATHEROS: |
| 1132 | ath_ap_set_group_id(dut, ifname, val); |
| 1133 | break; |
| 1134 | default: |
| 1135 | send_resp(dut, conn, SIGMA_ERROR, |
| 1136 | "errorCode,Unsupported group_id with the current driver"); |
Jouni Malinen | dccfd0c | 2019-10-30 12:05:59 +0200 | [diff] [blame] | 1137 | return STATUS_SENT; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1138 | } |
| 1139 | break; |
| 1140 | default: |
| 1141 | send_resp(dut, conn, SIGMA_ERROR, |
| 1142 | "errorCode,Unsupported group_id with the current driver"); |
Jouni Malinen | dccfd0c | 2019-10-30 12:05:59 +0200 | [diff] [blame] | 1143 | return STATUS_SENT; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1144 | } |
| 1145 | } |
| 1146 | |
| 1147 | val = get_param(cmd, "CTS_WIDTH"); |
| 1148 | if (val) { |
| 1149 | switch (get_driver_type()) { |
| 1150 | case DRIVER_OPENWRT: |
| 1151 | switch (get_openwrt_driver_type()) { |
| 1152 | case OPENWRT_DRIVER_ATHEROS: |
| 1153 | ath_set_cts_width(dut, ifname, val); |
| 1154 | break; |
| 1155 | default: |
| 1156 | send_resp(dut, conn, SIGMA_ERROR, |
| 1157 | "errorCode,Unsupported cts_width with the current driver"); |
Jouni Malinen | dccfd0c | 2019-10-30 12:05:59 +0200 | [diff] [blame] | 1158 | return STATUS_SENT; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1159 | } |
| 1160 | break; |
| 1161 | default: |
| 1162 | send_resp(dut, conn, SIGMA_ERROR, |
| 1163 | "errorCode,Unsupported cts_width with the current driver"); |
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 | |
priyadharshini gowthaman | 264d544 | 2016-02-25 15:52:22 -0800 | [diff] [blame] | 1168 | val = get_param(cmd, "MU_NDPA_FrameFormat"); |
| 1169 | if (val) |
| 1170 | dut->ap_ndpa_frame = atoi(val); |
| 1171 | |
priyadharshini gowthaman | c52fff8 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 1172 | val = get_param(cmd, "interworking"); |
| 1173 | if (val && strcmp(val, "1") == 0) |
| 1174 | dut->ap_interworking = 1; |
| 1175 | |
| 1176 | val = get_param(cmd, "GAS_CB_DELAY"); |
| 1177 | if (val) |
| 1178 | dut->ap_gas_cb_delay = atoi(val); |
| 1179 | |
priyadharshini gowthaman | 8e26ff4 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 1180 | val = get_param(cmd, "LCI"); |
| 1181 | if (val) { |
| 1182 | if (strlen(val) > sizeof(dut->ap_val_lci) - 1) |
Jouni Malinen | dccfd0c | 2019-10-30 12:05:59 +0200 | [diff] [blame] | 1183 | return INVALID_SEND_STATUS; |
priyadharshini gowthaman | 8e26ff4 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 1184 | dut->ap_lci = 1; |
| 1185 | snprintf(dut->ap_val_lci, sizeof(dut->ap_val_lci), "%s", val); |
| 1186 | ath_set_lci_config(dut, val, cmd); |
| 1187 | } |
| 1188 | |
priyadharshini gowthaman | c2357bd | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 1189 | val = get_param(cmd, "InfoZ"); |
| 1190 | if (val) { |
| 1191 | if (strlen(val) > sizeof(dut->ap_infoz) - 1) |
Jouni Malinen | dccfd0c | 2019-10-30 12:05:59 +0200 | [diff] [blame] | 1192 | return INVALID_SEND_STATUS; |
priyadharshini gowthaman | c2357bd | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 1193 | snprintf(dut->ap_infoz, sizeof(dut->ap_infoz), "%s", val); |
| 1194 | } |
| 1195 | |
priyadharshini gowthaman | 8e26ff4 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 1196 | val = get_param(cmd, "LocCivicAddr"); |
| 1197 | if (val) { |
| 1198 | if (strlen(val) > sizeof(dut->ap_val_lcr) - 1) |
Jouni Malinen | dccfd0c | 2019-10-30 12:05:59 +0200 | [diff] [blame] | 1199 | return INVALID_SEND_STATUS; |
priyadharshini gowthaman | 8e26ff4 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 1200 | dut->ap_lcr = 1; |
| 1201 | snprintf(dut->ap_val_lcr, sizeof(dut->ap_val_lcr), "%s", val); |
| 1202 | if (dut->ap_lci == 0) |
| 1203 | ath_set_lci_config(dut, val, cmd); |
| 1204 | } |
| 1205 | |
| 1206 | val = get_param(cmd, "NeighAPBSSID"); |
| 1207 | if (val) { |
| 1208 | if (dut->ap_neighap < 3) { |
| 1209 | if (parse_mac_address( |
| 1210 | dut, val, |
| 1211 | dut->ap_val_neighap[dut->ap_neighap]) < 0) { |
| 1212 | send_resp(dut, conn, SIGMA_INVALID, |
| 1213 | "Failed to parse MAC address"); |
Jouni Malinen | dccfd0c | 2019-10-30 12:05:59 +0200 | [diff] [blame] | 1214 | return STATUS_SENT; |
priyadharshini gowthaman | 8e26ff4 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 1215 | } |
| 1216 | dut->ap_neighap++; |
| 1217 | if (dut->ap_lci == 1) |
| 1218 | dut->ap_scan = 1; |
| 1219 | } |
| 1220 | } |
| 1221 | |
| 1222 | val = get_param(cmd, "OpChannel"); |
| 1223 | if (val) { |
| 1224 | if (dut->ap_opchannel < 3) { |
| 1225 | dut->ap_val_opchannel[dut->ap_opchannel] = atoi(val); |
| 1226 | dut->ap_opchannel++; |
| 1227 | } |
| 1228 | } |
| 1229 | |
priyadharshini gowthaman | c2357bd | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 1230 | val = get_param(cmd, "URI-FQDNdescriptor"); |
| 1231 | if (val) { |
| 1232 | if (strcasecmp(val, "HELD") == 0) { |
| 1233 | dut->ap_fqdn_held = 1; |
| 1234 | } else if (strcasecmp(val, "SUPL") == 0) { |
| 1235 | dut->ap_fqdn_supl = 1; |
| 1236 | } else { |
| 1237 | send_resp(dut, conn, SIGMA_INVALID, |
| 1238 | "errorCode,Unsupported URI-FQDNdescriptor"); |
Jouni Malinen | dccfd0c | 2019-10-30 12:05:59 +0200 | [diff] [blame] | 1239 | return STATUS_SENT; |
priyadharshini gowthaman | c2357bd | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 1240 | } |
| 1241 | } |
| 1242 | |
Adil Saeed Musthafa | 604c826 | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 1243 | val = get_param(cmd, "Reg_Domain"); |
| 1244 | if (val) { |
| 1245 | if (strcasecmp(val, "Local") == 0) { |
| 1246 | dut->ap_reg_domain = REG_DOMAIN_LOCAL; |
| 1247 | } else if (strcasecmp(val, "Global") == 0) { |
| 1248 | dut->ap_reg_domain = REG_DOMAIN_GLOBAL; |
| 1249 | } else { |
| 1250 | send_resp(dut, conn, SIGMA_ERROR, |
| 1251 | "errorCode,Wrong value for Reg_Domain"); |
Jouni Malinen | dccfd0c | 2019-10-30 12:05:59 +0200 | [diff] [blame] | 1252 | return STATUS_SENT; |
Adil Saeed Musthafa | 604c826 | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 1253 | } |
| 1254 | } |
| 1255 | |
Adil Saeed Musthafa | 4ec61bd | 2017-04-10 23:13:41 -0700 | [diff] [blame] | 1256 | val = get_param(cmd, "NAME"); |
| 1257 | if (val) { |
| 1258 | if (strcasecmp(val, "ap1mbo") == 0) |
| 1259 | dut->ap_name = 1; |
| 1260 | else if (strcasecmp(val, "ap2mbo") == 0) |
| 1261 | dut->ap_name = 2; |
| 1262 | else |
| 1263 | dut->ap_name = 0; |
| 1264 | } |
| 1265 | |
| 1266 | val = get_param(cmd, "FT_OA"); |
| 1267 | if (val) { |
| 1268 | if (strcasecmp(val, "Enable") == 0) { |
| 1269 | dut->ap_ft_oa = 1; |
| 1270 | } else if (strcasecmp(val, "Disable") == 0) { |
| 1271 | dut->ap_ft_oa = 0; |
| 1272 | } else { |
| 1273 | send_resp(dut, conn, SIGMA_ERROR, |
| 1274 | "errorCode,Wrong value for FT_OA"); |
Jouni Malinen | dccfd0c | 2019-10-30 12:05:59 +0200 | [diff] [blame] | 1275 | return STATUS_SENT; |
Adil Saeed Musthafa | 4ec61bd | 2017-04-10 23:13:41 -0700 | [diff] [blame] | 1276 | } |
| 1277 | } |
| 1278 | |
Jouni Malinen | 9f94331 | 2019-08-19 23:49:16 +0300 | [diff] [blame] | 1279 | val = get_param(cmd, "FT_DS"); |
| 1280 | if (val) { |
| 1281 | if (strcasecmp(val, "Enable") == 0) { |
| 1282 | dut->ap_ft_ds = VALUE_ENABLED; |
| 1283 | } else if (strcasecmp(val, "Disable") == 0) { |
| 1284 | dut->ap_ft_ds = VALUE_DISABLED; |
| 1285 | } else { |
| 1286 | send_resp(dut, conn, SIGMA_ERROR, |
| 1287 | "errorCode,Unsupported value for FT_DS"); |
| 1288 | return STATUS_SENT_ERROR; |
| 1289 | } |
| 1290 | } |
| 1291 | |
Adil Saeed Musthafa | 023108a | 2017-04-10 23:13:37 -0700 | [diff] [blame] | 1292 | val = get_param(cmd, "Cellular_Cap_Pref"); |
| 1293 | if (val) |
| 1294 | dut->ap_cell_cap_pref = atoi(val); |
| 1295 | |
Adil Saeed Musthafa | cf752fa | 2017-04-10 23:13:32 -0700 | [diff] [blame] | 1296 | val = get_param(cmd, "DOMAIN"); |
| 1297 | if (val) { |
| 1298 | if (strlen(val) >= sizeof(dut->ap_mobility_domain)) { |
| 1299 | send_resp(dut, conn, SIGMA_ERROR, |
| 1300 | "errorCode,Too long DOMAIN"); |
Jouni Malinen | dccfd0c | 2019-10-30 12:05:59 +0200 | [diff] [blame] | 1301 | return STATUS_SENT; |
Adil Saeed Musthafa | cf752fa | 2017-04-10 23:13:32 -0700 | [diff] [blame] | 1302 | } |
| 1303 | snprintf(dut->ap_mobility_domain, |
| 1304 | sizeof(dut->ap_mobility_domain), "%s", val); |
| 1305 | } |
| 1306 | |
Adil Saeed Musthafa | 4ec61bd | 2017-04-10 23:13:41 -0700 | [diff] [blame] | 1307 | val = get_param(cmd, "ft_bss_list"); |
| 1308 | if (val) { |
| 1309 | char *mac_str; |
| 1310 | int i; |
| 1311 | char *saveptr; |
| 1312 | char *mac_list_str; |
| 1313 | |
| 1314 | mac_list_str = strdup(val); |
| 1315 | if (!mac_list_str) |
Jouni Malinen | dccfd0c | 2019-10-30 12:05:59 +0200 | [diff] [blame] | 1316 | return INVALID_SEND_STATUS; |
Adil Saeed Musthafa | 4ec61bd | 2017-04-10 23:13:41 -0700 | [diff] [blame] | 1317 | mac_str = strtok_r(mac_list_str, " ", &saveptr); |
| 1318 | for (i = 0; mac_str && i < MAX_FT_BSS_LIST; i++) { |
| 1319 | if (parse_mac_address(dut, mac_str, |
| 1320 | dut->ft_bss_mac_list[i]) < 0) { |
| 1321 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 1322 | "MAC Address not in proper format"); |
| 1323 | break; |
| 1324 | } |
| 1325 | dut->ft_bss_mac_cnt++; |
| 1326 | mac_str = strtok_r(NULL, " ", &saveptr); |
| 1327 | } |
| 1328 | sigma_dut_print(dut, DUT_MSG_DEBUG, |
| 1329 | "Storing the following FT BSS MAC List"); |
| 1330 | for (i = 0; i < dut->ft_bss_mac_cnt; i++) { |
| 1331 | sigma_dut_print(dut, DUT_MSG_DEBUG, |
| 1332 | "MAC[%d] %02x:%02x:%02x:%02x:%02x:%02x", |
| 1333 | i, |
| 1334 | dut->ft_bss_mac_list[i][0], |
| 1335 | dut->ft_bss_mac_list[i][1], |
| 1336 | dut->ft_bss_mac_list[i][2], |
| 1337 | dut->ft_bss_mac_list[i][3], |
| 1338 | dut->ft_bss_mac_list[i][4], |
| 1339 | dut->ft_bss_mac_list[i][5]); |
| 1340 | } |
| 1341 | free(mac_list_str); |
| 1342 | } |
| 1343 | |
priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 1344 | val = get_param(cmd, "OCESupport"); |
| 1345 | if (val) { |
| 1346 | if (strcasecmp(val, "enable") == 0) { |
| 1347 | dut->ap_oce = VALUE_ENABLED; |
| 1348 | } else if (strcasecmp(val, "disable") == 0) { |
| 1349 | dut->ap_oce = VALUE_DISABLED; |
| 1350 | dut->ap_filsdscv = VALUE_DISABLED; |
| 1351 | } else { |
| 1352 | send_resp(dut, conn, SIGMA_INVALID, |
| 1353 | "errorCode,Unsupported OCE"); |
Jouni Malinen | dccfd0c | 2019-10-30 12:05:59 +0200 | [diff] [blame] | 1354 | return STATUS_SENT; |
priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 1355 | } |
| 1356 | } |
| 1357 | |
| 1358 | val = get_param(cmd, "FILSDscvInterval"); |
| 1359 | if (val) |
| 1360 | dut->ap_fils_dscv_int = atoi(val); |
| 1361 | |
| 1362 | val = get_param(cmd, "BroadcastSSID"); |
| 1363 | if (val) { |
| 1364 | if (strcasecmp(val, "enable") == 0) { |
| 1365 | dut->ap_broadcast_ssid = VALUE_ENABLED; |
| 1366 | } else if (strcasecmp(val, "disable") == 0) { |
| 1367 | dut->ap_broadcast_ssid = VALUE_DISABLED; |
| 1368 | } else { |
| 1369 | send_resp(dut, conn, SIGMA_INVALID, |
| 1370 | "errorCode,Unsupported hidden SSID"); |
Jouni Malinen | dccfd0c | 2019-10-30 12:05:59 +0200 | [diff] [blame] | 1371 | return STATUS_SENT; |
priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 1372 | } |
| 1373 | } |
| 1374 | |
| 1375 | val = get_param(cmd, "FILSDscv"); |
| 1376 | if (val) { |
| 1377 | if (strcasecmp(val, "enable") == 0) { |
| 1378 | dut->ap_filsdscv = VALUE_ENABLED; |
| 1379 | } else if (strcasecmp(val, "disable") == 0) { |
| 1380 | dut->ap_filsdscv = VALUE_DISABLED; |
| 1381 | } else { |
| 1382 | send_resp(dut, conn, SIGMA_INVALID, |
| 1383 | "errorCode,Unsupported FILSDscv"); |
Jouni Malinen | dccfd0c | 2019-10-30 12:05:59 +0200 | [diff] [blame] | 1384 | return STATUS_SENT; |
priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 1385 | } |
| 1386 | } |
| 1387 | |
| 1388 | val = get_param(cmd, "FILSHLP"); |
| 1389 | if (val) { |
| 1390 | if (strcasecmp(val, "enable") == 0) { |
| 1391 | dut->ap_filshlp = VALUE_ENABLED; |
| 1392 | } else if (strcasecmp(val, "disable") == 0) { |
| 1393 | dut->ap_filshlp = VALUE_DISABLED; |
| 1394 | } else { |
| 1395 | send_resp(dut, conn, SIGMA_INVALID, |
| 1396 | "errorCode,Unsupported FILSHLP"); |
Jouni Malinen | dccfd0c | 2019-10-30 12:05:59 +0200 | [diff] [blame] | 1397 | return STATUS_SENT; |
priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 1398 | } |
| 1399 | } |
| 1400 | |
| 1401 | val = get_param(cmd, "NAIRealm"); |
| 1402 | if (val) { |
| 1403 | dut->ap_nairealm_int = 1; |
| 1404 | if (strlen(val) > sizeof(dut->ap_nairealm) - 1) |
Jouni Malinen | dccfd0c | 2019-10-30 12:05:59 +0200 | [diff] [blame] | 1405 | return INVALID_SEND_STATUS; |
priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 1406 | snprintf(dut->ap_nairealm, sizeof(dut->ap_nairealm), "%s", val); |
| 1407 | } |
| 1408 | |
| 1409 | val = get_param(cmd, "DeauthDisassocTx"); |
| 1410 | if (val) { |
| 1411 | if (strcasecmp(val, "disable") == 0) { |
| 1412 | deauth_disassoc(dut, ifname, val); |
| 1413 | } else { |
| 1414 | send_resp(dut, conn, SIGMA_INVALID, |
| 1415 | "errorCode,Unsupported DeauthDisassocTx"); |
Jouni Malinen | dccfd0c | 2019-10-30 12:05:59 +0200 | [diff] [blame] | 1416 | return STATUS_SENT; |
priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 1417 | } |
| 1418 | } |
| 1419 | |
| 1420 | val = get_param(cmd, "RNR"); |
| 1421 | if (val) { |
| 1422 | if (strcasecmp(val, "enable") == 0) { |
| 1423 | dut->ap_rnr = VALUE_ENABLED; |
| 1424 | } else if (strcasecmp(val, "disable") == 0) { |
| 1425 | dut->ap_rnr = VALUE_DISABLED; |
| 1426 | } else { |
| 1427 | send_resp(dut, conn, SIGMA_INVALID, |
| 1428 | "errorCode,Unsupported RNR"); |
Jouni Malinen | dccfd0c | 2019-10-30 12:05:59 +0200 | [diff] [blame] | 1429 | return STATUS_SENT; |
priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 1430 | } |
| 1431 | } |
| 1432 | |
| 1433 | val = get_param(cmd, "BLEChannelUtil"); |
| 1434 | if (val) |
| 1435 | dut->ap_blechanutil = atoi(val); |
| 1436 | |
| 1437 | val = get_param(cmd, "BLEAvailAdminCap"); |
| 1438 | if (val) |
| 1439 | dut->ap_ble_admit_cap = atoi(val); |
| 1440 | |
| 1441 | val = get_param(cmd, "DataPPDUDuration"); |
| 1442 | if (val) |
| 1443 | dut->ap_datappdudura = atoi(val); |
| 1444 | |
| 1445 | val = get_param(cmd, "AirTimeFract"); |
| 1446 | if (val) |
| 1447 | dut->ap_airtimefract = atoi(val); |
| 1448 | |
| 1449 | val = get_param(cmd, "dhcpServIPADDR"); |
| 1450 | if (val) { |
| 1451 | if (strlen(val) > sizeof(dut->ap_dhcpserv_ipaddr) - 1) |
Jouni Malinen | dccfd0c | 2019-10-30 12:05:59 +0200 | [diff] [blame] | 1452 | return INVALID_SEND_STATUS; |
priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 1453 | snprintf(dut->ap_dhcpserv_ipaddr, |
| 1454 | sizeof(dut->ap_dhcpserv_ipaddr), "%s", val); |
| 1455 | dut->ap_dhcp_stop = 1; |
| 1456 | } |
| 1457 | |
| 1458 | val = get_param(cmd, "ESP_IE"); |
| 1459 | if (val) { |
| 1460 | if (strcasecmp(val, "enable") == 0) { |
| 1461 | dut->ap_esp = VALUE_ENABLED; |
| 1462 | } else if (strcasecmp(val, "disable") == 0) { |
| 1463 | dut->ap_esp = VALUE_DISABLED; |
| 1464 | } else { |
| 1465 | send_resp(dut, conn, SIGMA_INVALID, |
| 1466 | "errorCode,Unsupported ESP_IE"); |
Jouni Malinen | dccfd0c | 2019-10-30 12:05:59 +0200 | [diff] [blame] | 1467 | return STATUS_SENT; |
priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 1468 | } |
| 1469 | } |
| 1470 | |
| 1471 | val = get_param(cmd, "BAWinSize"); |
| 1472 | if (val) |
| 1473 | dut->ap_bawinsize = atoi(val); |
| 1474 | |
| 1475 | val = get_param(cmd, "BLEStaCount"); |
| 1476 | if (val) |
| 1477 | dut->ap_blestacnt = atoi(val); |
| 1478 | |
priyadharshini gowthaman | 350f191 | 2018-06-04 13:09:12 -0700 | [diff] [blame] | 1479 | val = get_param(cmd, "PPDUTxType"); |
| 1480 | if (val) { |
| 1481 | if (strcasecmp(val, "MU") == 0) { |
| 1482 | dut->ap_he_ppdu = PPDU_MU; |
Priyadharshini Gowthaman | fe60c50 | 2019-08-14 13:00:34 -0700 | [diff] [blame] | 1483 | } else if (strcasecmp(val, "HE-SU") == 0) { |
| 1484 | /* Do nothing */ |
| 1485 | } else if (strcasecmp(val, "SU") == 0) { |
| 1486 | /* Do nothing */ |
| 1487 | } else if (strcasecmp(val, "legacy") == 0) { |
| 1488 | /* Do nothing */ |
| 1489 | } else if (strcasecmp(val, "ER") == 0) { |
| 1490 | /* Do nothing */ |
| 1491 | } else if (strcasecmp(val, "TB") == 0) { |
| 1492 | /* Do nothing */ |
priyadharshini gowthaman | 350f191 | 2018-06-04 13:09:12 -0700 | [diff] [blame] | 1493 | } else { |
Priyadharshini Gowthaman | fe60c50 | 2019-08-14 13:00:34 -0700 | [diff] [blame] | 1494 | send_resp(dut, conn, SIGMA_ERROR, |
priyadharshini gowthaman | 350f191 | 2018-06-04 13:09:12 -0700 | [diff] [blame] | 1495 | "errorCode,Unsupported PPDUTxType"); |
Priyadharshini Gowthaman | fe60c50 | 2019-08-14 13:00:34 -0700 | [diff] [blame] | 1496 | return STATUS_SENT_ERROR; |
priyadharshini gowthaman | 350f191 | 2018-06-04 13:09:12 -0700 | [diff] [blame] | 1497 | } |
| 1498 | } |
| 1499 | |
Alexei Avshalom Lazar | 33f700c | 2018-12-18 16:00:39 +0200 | [diff] [blame] | 1500 | val = get_param(cmd, "WscIEFragment"); |
| 1501 | if (val && strcasecmp(val, "enable") == 0) { |
| 1502 | sigma_dut_print(dut, DUT_MSG_DEBUG, |
| 1503 | "Enable WSC IE fragmentation"); |
| 1504 | dut->wsc_fragment = 1; |
| 1505 | } |
| 1506 | |
Alexei Avshalom Lazar | 744ae8a | 2019-01-31 17:26:46 +0200 | [diff] [blame] | 1507 | val = get_param(cmd, "WpsVersion"); |
| 1508 | if (val) |
| 1509 | dut->wps_forced_version = get_wps_forced_version(dut, val); |
| 1510 | |
Alexei Avshalom Lazar | 2eccf4d | 2019-01-31 10:03:59 +0200 | [diff] [blame] | 1511 | val = get_param(cmd, "WscEAPFragment"); |
| 1512 | if (val && strcasecmp(val, "enable") == 0) |
| 1513 | dut->eap_fragment = 1; |
| 1514 | |
Alexei Avshalom Lazar | 79f5727 | 2018-12-23 17:22:47 +0200 | [diff] [blame] | 1515 | val = get_param(cmd, "MSDUSize"); |
| 1516 | if (val) { |
| 1517 | int mtu; |
| 1518 | |
| 1519 | dut->amsdu_size = atoi(val); |
| 1520 | if (dut->amsdu_size > IEEE80211_MAX_DATA_LEN_DMG || |
| 1521 | dut->amsdu_size < IEEE80211_SNAP_LEN_DMG) { |
| 1522 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 1523 | "MSDUSize %d is above max %d or below min %d", |
| 1524 | dut->amsdu_size, |
| 1525 | IEEE80211_MAX_DATA_LEN_DMG, |
| 1526 | IEEE80211_SNAP_LEN_DMG); |
| 1527 | dut->amsdu_size = 0; |
Jouni Malinen | 0e29cf2 | 2019-02-19 01:13:21 +0200 | [diff] [blame] | 1528 | return ERROR_SEND_STATUS; |
Alexei Avshalom Lazar | 79f5727 | 2018-12-23 17:22:47 +0200 | [diff] [blame] | 1529 | } |
| 1530 | |
| 1531 | mtu = dut->amsdu_size - IEEE80211_SNAP_LEN_DMG; |
| 1532 | sigma_dut_print(dut, DUT_MSG_DEBUG, |
| 1533 | "Setting amsdu_size to %d", mtu); |
| 1534 | snprintf(buf, sizeof(buf), "ifconfig %s mtu %d", |
| 1535 | get_station_ifname(), mtu); |
| 1536 | |
| 1537 | if (system(buf) != 0) { |
| 1538 | sigma_dut_print(dut, DUT_MSG_ERROR, "Failed to set %s", |
| 1539 | buf); |
Jouni Malinen | 0e29cf2 | 2019-02-19 01:13:21 +0200 | [diff] [blame] | 1540 | return ERROR_SEND_STATUS; |
Alexei Avshalom Lazar | 79f5727 | 2018-12-23 17:22:47 +0200 | [diff] [blame] | 1541 | } |
| 1542 | } |
| 1543 | |
Alexei Avshalom Lazar | 0e239a9 | 2018-12-23 17:27:50 +0200 | [diff] [blame] | 1544 | val = get_param(cmd, "BAckRcvBuf"); |
| 1545 | if (val) { |
| 1546 | dut->back_rcv_buf = atoi(val); |
| 1547 | if (dut->back_rcv_buf == 0) { |
| 1548 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 1549 | "Failed to convert %s or value is 0", |
| 1550 | val); |
Jouni Malinen | 0e29cf2 | 2019-02-19 01:13:21 +0200 | [diff] [blame] | 1551 | return ERROR_SEND_STATUS; |
Alexei Avshalom Lazar | 0e239a9 | 2018-12-23 17:27:50 +0200 | [diff] [blame] | 1552 | } |
| 1553 | |
| 1554 | sigma_dut_print(dut, DUT_MSG_DEBUG, |
| 1555 | "Setting BAckRcvBuf to %s", val); |
| 1556 | } |
| 1557 | |
Alexei Avshalom Lazar | bc180dc | 2018-12-18 16:01:14 +0200 | [diff] [blame] | 1558 | val = get_param(cmd, "ExtSchIE"); |
| 1559 | if (val && !strcasecmp(val, "Enable")) { |
| 1560 | int num_allocs = MAX_ESE_ALLOCS; |
| 1561 | |
| 1562 | if (sta_extract_60g_ese(dut, cmd, dut->ap_ese_allocs, |
| 1563 | &num_allocs)) { |
| 1564 | send_resp(dut, conn, SIGMA_INVALID, |
| 1565 | "errorCode,Invalid ExtSchIE"); |
Jouni Malinen | dccfd0c | 2019-10-30 12:05:59 +0200 | [diff] [blame] | 1566 | return STATUS_SENT; |
Alexei Avshalom Lazar | bc180dc | 2018-12-18 16:01:14 +0200 | [diff] [blame] | 1567 | } |
| 1568 | dut->ap_num_ese_allocs = num_allocs; |
| 1569 | } |
| 1570 | |
Alexei Avshalom Lazar | 49498b8 | 2019-01-31 15:16:32 +0200 | [diff] [blame] | 1571 | if (is_60g_sigma_dut(dut)) { |
| 1572 | unsigned int abft_len = 1; /* default is one slot */ |
| 1573 | |
| 1574 | val = get_param(cmd, "ABFTLRang"); |
| 1575 | if (val) { |
| 1576 | sigma_dut_print(dut, DUT_MSG_DEBUG, |
| 1577 | "ABFTLRang parameter %s", val); |
| 1578 | if (strcasecmp(val, "Gt1") == 0) |
| 1579 | abft_len = 2; /* 2 slots in this case */ |
| 1580 | } |
| 1581 | |
| 1582 | if (sta_set_60g_abft_len(dut, conn, abft_len)) { |
| 1583 | send_resp(dut, conn, SIGMA_ERROR, |
| 1584 | "ErrorCode,Can't set ABFT length"); |
| 1585 | return STATUS_SENT; |
| 1586 | } |
| 1587 | } |
| 1588 | |
Priyadharshini Gowthaman | c067edf | 2019-06-20 11:23:27 -0700 | [diff] [blame] | 1589 | val = get_param(cmd, "OFDMA"); |
| 1590 | if (val) { |
| 1591 | if (strcasecmp(val, "UL") == 0) { |
| 1592 | dut->ap_he_ulofdma = VALUE_ENABLED; |
Priyadharshini Gowthaman | fe60c50 | 2019-08-14 13:00:34 -0700 | [diff] [blame] | 1593 | } else if (strcasecmp(val, "DL") == 0) { |
| 1594 | dut->ap_he_dlofdma = VALUE_ENABLED; |
| 1595 | } else if (strcasecmp(val, "DL-20and80") == 0) { |
| 1596 | dut->ap_he_dlofdma = VALUE_ENABLED; |
Priyadharshini Gowthaman | c067edf | 2019-06-20 11:23:27 -0700 | [diff] [blame] | 1597 | } else { |
| 1598 | send_resp(dut, conn, SIGMA_ERROR, |
| 1599 | "errorCode,Unsupported OFDMA value"); |
| 1600 | return STATUS_SENT_ERROR; |
| 1601 | } |
| 1602 | } |
| 1603 | |
Priyadharshini Gowthaman | bc94889 | 2019-09-10 14:22:49 -0700 | [diff] [blame] | 1604 | val = get_param(cmd, "NumSoundDim"); |
| 1605 | if (val) |
| 1606 | dut->ap_numsounddim = atoi(val); |
| 1607 | |
Priyadharshini Gowthaman | 670b323 | 2019-09-10 16:09:19 -0700 | [diff] [blame] | 1608 | val = get_param(cmd, "BCC"); |
| 1609 | if (val) { |
| 1610 | if (strcasecmp(val, "enable") == 0) { |
| 1611 | dut->ap_bcc = VALUE_ENABLED; |
| 1612 | dut->ap_ldpc = VALUE_DISABLED; |
| 1613 | } else if (strcasecmp(val, "disable") == 0) { |
| 1614 | dut->ap_ldpc = VALUE_ENABLED; |
| 1615 | dut->ap_bcc = VALUE_DISABLED; |
| 1616 | } else { |
| 1617 | send_resp(dut, conn, SIGMA_ERROR, |
| 1618 | "errorCode,Unsupported BCC value"); |
| 1619 | return STATUS_SENT_ERROR; |
| 1620 | } |
| 1621 | } |
| 1622 | |
Priyadharshini Gowthaman | 6bc4c1e | 2019-09-10 16:24:51 -0700 | [diff] [blame] | 1623 | val = get_param(cmd, "FrgmntSupport"); |
| 1624 | if (val) { |
| 1625 | if (strcasecmp(val, "enable") == 0) { |
| 1626 | dut->ap_he_frag = VALUE_ENABLED; |
| 1627 | } else if (strcasecmp(val, "disable") == 0) { |
| 1628 | dut->ap_he_frag = VALUE_DISABLED; |
| 1629 | } else { |
| 1630 | send_resp(dut, conn, SIGMA_ERROR, |
| 1631 | "errorCode,Unsupported FrgmntSupport value"); |
| 1632 | return STATUS_SENT_ERROR; |
| 1633 | } |
| 1634 | } |
| 1635 | |
Priyadharshini Gowthaman | 1a686bd | 2019-09-19 14:41:40 -0700 | [diff] [blame] | 1636 | val = get_param(cmd, "ADDBAReq_BufSize"); |
| 1637 | if (val) { |
| 1638 | if (strcasecmp(val, "le64") == 0) { |
| 1639 | dut->ap_ba_bufsize = BA_BUFSIZE_64; |
| 1640 | } else if (strcasecmp(val, "gt64") == 0) { |
| 1641 | dut->ap_ba_bufsize = BA_BUFSIZE_256; |
| 1642 | } else { |
| 1643 | send_resp(dut, conn, SIGMA_ERROR, |
| 1644 | "errorCode,Unsupported ADDBAReq Buffer Size"); |
| 1645 | return STATUS_SENT_ERROR; |
| 1646 | } |
| 1647 | } |
| 1648 | |
| 1649 | val = get_param(cmd, "ADDBAResp_BufSize"); |
| 1650 | if (val) { |
| 1651 | if (strcasecmp(val, "gt64") == 0) { |
| 1652 | dut->ap_ba_bufsize = BA_BUFSIZE_256; |
| 1653 | } else { |
| 1654 | send_resp(dut, conn, SIGMA_ERROR, |
| 1655 | "errorCode,Unsupported ADDBAResp Buffer Size"); |
| 1656 | return STATUS_SENT_ERROR; |
| 1657 | } |
| 1658 | } |
| 1659 | |
Priyadharshini Gowthaman | 21895a5 | 2019-10-07 16:56:16 -0700 | [diff] [blame] | 1660 | val = get_param(cmd, "MU_EDCA"); |
| 1661 | if (val) { |
| 1662 | if (strcasecmp(val, "override") == 0) { |
| 1663 | dut->ap_mu_edca = VALUE_ENABLED; |
| 1664 | } else if (strcasecmp(val, "disable") == 0) { |
| 1665 | dut->ap_mu_edca = VALUE_DISABLED; |
| 1666 | } else { |
| 1667 | send_resp(dut, conn, SIGMA_ERROR, |
| 1668 | "errorCode,Unsupported mu_edca param value"); |
| 1669 | return STATUS_SENT_ERROR; |
| 1670 | } |
| 1671 | } |
| 1672 | |
Priyadharshini Gowthaman | dee79e2 | 2019-10-07 16:56:27 -0700 | [diff] [blame] | 1673 | val = get_param(cmd, "MIMO"); |
| 1674 | if (val) { |
| 1675 | if (strcasecmp(val, "DL") == 0) { |
| 1676 | dut->ap_he_mimo = MIMO_DL; |
| 1677 | } else if (strcasecmp(val, "UL") == 0) { |
| 1678 | dut->ap_he_mimo = MIMO_UL; |
| 1679 | } else { |
| 1680 | send_resp(dut, conn, SIGMA_ERROR, |
| 1681 | "errorCode,Unsupported mimo param value"); |
| 1682 | return STATUS_SENT_ERROR; |
| 1683 | } |
| 1684 | } |
| 1685 | |
Priyadharshini Gowthaman | 43d6b41 | 2019-10-07 16:56:37 -0700 | [diff] [blame] | 1686 | val = get_param(cmd, "HE_TXOPDurRTSThr"); |
| 1687 | if (val) { |
| 1688 | if (strcasecmp(val, "enable") == 0) { |
| 1689 | dut->ap_he_rtsthrshld = VALUE_ENABLED; |
| 1690 | } else if (strcasecmp(val, "disable") == 0) { |
| 1691 | dut->ap_he_rtsthrshld = VALUE_DISABLED; |
| 1692 | } else { |
| 1693 | send_resp(dut, conn, SIGMA_ERROR, |
| 1694 | "errorCode,Unsupported HE_TXOPDurRTSThr value"); |
| 1695 | return STATUS_SENT_ERROR; |
| 1696 | } |
| 1697 | } |
| 1698 | |
Jouni Malinen | dccfd0c | 2019-10-30 12:05:59 +0200 | [diff] [blame] | 1699 | return SUCCESS_SEND_STATUS; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1700 | } |
| 1701 | |
| 1702 | |
| 1703 | static void ath_inject_frame(struct sigma_dut *dut, const char *ifname, int tid) |
| 1704 | { |
| 1705 | char buf[256]; |
| 1706 | int tid_to_dscp[] = { 0x00, 0x20, 0x40, 0x60, 0x80, 0xa0, 0xc0, 0xe0 }; |
| 1707 | |
Pradeep Reddy POTTETI | d31d132 | 2016-10-13 17:22:03 +0530 | [diff] [blame] | 1708 | if (tid < 0 || |
| 1709 | tid >= (int) (sizeof(tid_to_dscp) / sizeof(tid_to_dscp[0]))) { |
| 1710 | sigma_dut_print(dut, DUT_MSG_ERROR, "Unsupported TID: %d", tid); |
| 1711 | return; |
| 1712 | } |
| 1713 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1714 | snprintf(buf, sizeof(buf), |
| 1715 | "wlanconfig %s list sta | grep : | cut -b 1-17 > %s", |
| 1716 | ifname, VI_QOS_TMP_FILE); |
| 1717 | if (system(buf) != 0) |
| 1718 | return; |
| 1719 | |
| 1720 | snprintf(buf, sizeof(buf), |
| 1721 | "ifconfig %s | grep HWaddr | cut -b 39-56 >> %s", |
| 1722 | ifname, VI_QOS_TMP_FILE); |
| 1723 | if (system(buf) != 0) |
| 1724 | sigma_dut_print(dut, DUT_MSG_ERROR, "Retrieve HWaddr failed"); |
| 1725 | |
| 1726 | snprintf(buf, sizeof(buf), "sed -n '3,$p' %s >> %s", |
| 1727 | VI_QOS_REFFILE, VI_QOS_TMP_FILE); |
| 1728 | if (system(buf) != 0) { |
| 1729 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 1730 | "Output redirection to VI_QOS_TMP_FILE failed"); |
| 1731 | } |
| 1732 | |
| 1733 | snprintf(buf, sizeof(buf), "sed '5 c %x' %s > %s", |
| 1734 | tid_to_dscp[tid], VI_QOS_TMP_FILE, VI_QOS_FILE); |
| 1735 | if (system(buf) != 0) { |
| 1736 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 1737 | "Append TID to VI_QOS_FILE failed "); |
| 1738 | } |
| 1739 | |
| 1740 | snprintf(buf, sizeof(buf), "ethinject %s %s", ifname, VI_QOS_FILE); |
| 1741 | if (system(buf) != 0) |
| 1742 | sigma_dut_print(dut, DUT_MSG_ERROR, "Ethinject frame failed"); |
| 1743 | } |
| 1744 | |
| 1745 | |
| 1746 | static int ath_ap_send_addba_req(struct sigma_dut *dut, struct sigma_conn *conn, |
| 1747 | struct sigma_cmd *cmd) |
| 1748 | { |
| 1749 | const char *val; |
| 1750 | char *ifname; |
| 1751 | char buf[256]; |
| 1752 | int tid = 0; |
| 1753 | |
| 1754 | ifname = get_main_ifname(); |
| 1755 | val = get_param(cmd, "TID"); |
| 1756 | if (val) { |
| 1757 | tid = atoi(val); |
| 1758 | if (tid) |
| 1759 | ath_inject_frame(dut, ifname, tid); |
| 1760 | } |
| 1761 | |
| 1762 | /* NOTE: This is the command sequence on Peregrine for ADDBA */ |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 1763 | run_iwpriv(dut, ifname, "setaddbaoper 1"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1764 | |
| 1765 | snprintf(buf, sizeof(buf), "wifitool %s senddelba 1 %d 1 4", |
| 1766 | ifname, tid); |
| 1767 | if (system(buf) != 0) { |
| 1768 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 1769 | "wifitool senddelba failed"); |
| 1770 | } |
| 1771 | |
| 1772 | snprintf(buf, sizeof(buf), "wifitool %s sendaddba 1 %d 64", |
| 1773 | ifname, tid); |
| 1774 | if (system(buf) != 0) { |
| 1775 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 1776 | "wifitool sendaddba failed"); |
| 1777 | } |
| 1778 | |
| 1779 | return 1; |
| 1780 | } |
| 1781 | |
| 1782 | |
Mohammed Shafi Shajakhan | a0535d4 | 2016-06-17 11:55:00 +0530 | [diff] [blame] | 1783 | static int ath10k_debug_enable_addba_req(struct sigma_dut *dut, int tid, |
| 1784 | const char *sta_mac, |
| 1785 | const char *dir_path) |
| 1786 | { |
| 1787 | DIR *dir; |
| 1788 | struct dirent *entry; |
| 1789 | char buf[128], path[128]; |
Jouni Malinen | 3aa7286 | 2019-05-29 23:14:51 +0300 | [diff] [blame] | 1790 | int ret = 0, res; |
Mohammed Shafi Shajakhan | a0535d4 | 2016-06-17 11:55:00 +0530 | [diff] [blame] | 1791 | |
| 1792 | dir = opendir(dir_path); |
| 1793 | if (!dir) |
| 1794 | return 0; |
| 1795 | |
| 1796 | while ((entry = readdir(dir))) { |
| 1797 | ret = 1; |
| 1798 | |
| 1799 | if (strcmp(entry->d_name, ".") == 0 || |
| 1800 | strcmp(entry->d_name, "..") == 0) |
| 1801 | continue; |
| 1802 | |
Jouni Malinen | 3aa7286 | 2019-05-29 23:14:51 +0300 | [diff] [blame] | 1803 | res = snprintf(path, sizeof(path) - 1, "%s/%s", |
| 1804 | dir_path, entry->d_name); |
| 1805 | if (res < 0 || res >= sizeof(path)) |
| 1806 | continue; |
Mohammed Shafi Shajakhan | a0535d4 | 2016-06-17 11:55:00 +0530 | [diff] [blame] | 1807 | |
| 1808 | if (strcmp(entry->d_name, sta_mac) == 0) { |
Jouni Malinen | 3aa7286 | 2019-05-29 23:14:51 +0300 | [diff] [blame] | 1809 | res = snprintf(buf, sizeof(buf), |
| 1810 | "echo 1 > %s/aggr_mode", path); |
| 1811 | if (res < 0 || res >= sizeof(buf) || system(buf) != 0) { |
Mohammed Shafi Shajakhan | a0535d4 | 2016-06-17 11:55:00 +0530 | [diff] [blame] | 1812 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 1813 | "Failed to set aggr mode for ath10k"); |
| 1814 | } |
| 1815 | |
Jouni Malinen | 3aa7286 | 2019-05-29 23:14:51 +0300 | [diff] [blame] | 1816 | res = snprintf(buf, sizeof(buf), |
| 1817 | "echo %d 32 > %s/addba", tid, path); |
| 1818 | if (res < 0 || res >= sizeof(buf) || system(buf) != 0) { |
Mohammed Shafi Shajakhan | a0535d4 | 2016-06-17 11:55:00 +0530 | [diff] [blame] | 1819 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 1820 | "Failed to set addbareq for ath10k"); |
| 1821 | } |
| 1822 | |
| 1823 | break; |
| 1824 | } |
| 1825 | |
| 1826 | /* Recursively search subdirectories */ |
| 1827 | ath10k_debug_enable_addba_req(dut, tid, sta_mac, path); |
| 1828 | } |
| 1829 | |
| 1830 | closedir(dir); |
| 1831 | |
| 1832 | return ret; |
| 1833 | } |
| 1834 | |
| 1835 | |
| 1836 | static int ath10k_ap_send_addba_req(struct sigma_dut *dut, |
| 1837 | struct sigma_cmd *cmd) |
| 1838 | { |
| 1839 | const char *val; |
| 1840 | int tid = 0; |
| 1841 | |
| 1842 | val = get_param(cmd, "TID"); |
| 1843 | if (val) |
| 1844 | tid = atoi(val); |
| 1845 | |
| 1846 | val = get_param(cmd, "sta_mac_address"); |
| 1847 | if (!val) { |
| 1848 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 1849 | "Failed to parse station MAC address"); |
| 1850 | return 0; |
| 1851 | } |
| 1852 | |
| 1853 | return ath10k_debug_enable_addba_req(dut, tid, val, |
| 1854 | "/sys/kernel/debug/ieee80211"); |
| 1855 | } |
| 1856 | |
| 1857 | |
Jouni Malinen | f722271 | 2019-06-13 01:50:21 +0300 | [diff] [blame] | 1858 | static enum sigma_cmd_result cmd_ap_send_addba_req(struct sigma_dut *dut, |
| 1859 | struct sigma_conn *conn, |
| 1860 | struct sigma_cmd *cmd) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1861 | { |
| 1862 | /* const char *name = get_param(cmd, "NAME"); */ |
| 1863 | /* const char *ifname = get_param(cmd, "INTERFACE"); */ |
Mohammed Shafi Shajakhan | a0535d4 | 2016-06-17 11:55:00 +0530 | [diff] [blame] | 1864 | struct stat s; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1865 | |
| 1866 | switch (get_driver_type()) { |
| 1867 | case DRIVER_ATHEROS: |
| 1868 | return ath_ap_send_addba_req(dut, conn, cmd); |
Alexei Avshalom Lazar | 79fa3fe | 2018-12-24 15:43:33 +0200 | [diff] [blame] | 1869 | #ifdef __linux__ |
| 1870 | case DRIVER_WIL6210: |
| 1871 | return send_addba_60g(dut, conn, cmd, "sta_mac_address"); |
| 1872 | #endif /* __linux__ */ |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1873 | case DRIVER_OPENWRT: |
| 1874 | switch (get_openwrt_driver_type()) { |
| 1875 | case OPENWRT_DRIVER_ATHEROS: |
| 1876 | return ath_ap_send_addba_req(dut, conn, cmd); |
| 1877 | default: |
| 1878 | send_resp(dut, conn, SIGMA_ERROR, |
| 1879 | "errorCode,ap_send_addba_req not supported with this driver"); |
| 1880 | return 0; |
| 1881 | } |
Pradeep Reddy POTTETI | fdb0491 | 2016-08-02 14:16:24 +0530 | [diff] [blame] | 1882 | case DRIVER_WCN: |
| 1883 | case DRIVER_LINUX_WCN: |
| 1884 | /* AP automatically sends ADDBA request after association. */ |
| 1885 | sigma_dut_print(dut, DUT_MSG_INFO, |
| 1886 | "ap_send_addba_req command ignored"); |
| 1887 | return 1; |
Mohammed Shafi Shajakhan | a0535d4 | 2016-06-17 11:55:00 +0530 | [diff] [blame] | 1888 | case DRIVER_MAC80211: |
| 1889 | if (stat("/sys/module/ath10k_core", &s) == 0) |
| 1890 | return ath10k_ap_send_addba_req(dut, cmd); |
| 1891 | /* fall through */ |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1892 | default: |
| 1893 | send_resp(dut, conn, SIGMA_ERROR, |
| 1894 | "errorCode,ap_send_addba_req not supported with this driver"); |
| 1895 | return 0; |
| 1896 | } |
| 1897 | } |
| 1898 | |
| 1899 | |
Jouni Malinen | f722271 | 2019-06-13 01:50:21 +0300 | [diff] [blame] | 1900 | static enum sigma_cmd_result cmd_ap_set_security(struct sigma_dut *dut, |
| 1901 | struct sigma_conn *conn, |
| 1902 | struct sigma_cmd *cmd) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1903 | { |
| 1904 | /* const char *name = get_param(cmd, "NAME"); */ |
| 1905 | const char *val; |
| 1906 | unsigned int wlan_tag = 1; |
Ankita Bajaj | 0d212e8 | 2017-11-27 15:54:57 +0530 | [diff] [blame] | 1907 | const char *security; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1908 | |
| 1909 | val = get_param(cmd, "WLAN_TAG"); |
| 1910 | if (val) |
| 1911 | wlan_tag = atoi(val); |
| 1912 | |
Ankita Bajaj | 0d212e8 | 2017-11-27 15:54:57 +0530 | [diff] [blame] | 1913 | security = get_param(cmd, "Security"); |
| 1914 | |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 1915 | if (wlan_tag > 1) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1916 | val = get_param(cmd, "KEYMGNT"); |
Ankita Bajaj | 0d212e8 | 2017-11-27 15:54:57 +0530 | [diff] [blame] | 1917 | if (!val) |
| 1918 | val = get_param(cmd, "KeyMgmtType"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1919 | if (val) { |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 1920 | if (strcasecmp(val, "NONE") == 0) { |
| 1921 | dut->ap_tag_key_mgmt[wlan_tag - 2] = AP2_OPEN; |
| 1922 | } else if (strcasecmp(val, "OSEN") == 0 && |
| 1923 | wlan_tag == 2) { |
| 1924 | /* |
| 1925 | * OSEN only supported on WLAN_TAG = 2 for now |
| 1926 | */ |
| 1927 | dut->ap_tag_key_mgmt[wlan_tag - 2] = AP2_OSEN; |
Ankita Bajaj | 0d212e8 | 2017-11-27 15:54:57 +0530 | [diff] [blame] | 1928 | } else if (strcasecmp(val, "WPA2-PSK") == 0 || |
| 1929 | (security && |
| 1930 | strcasecmp(security, "PSK") == 0 && |
| 1931 | strcasecmp(val, "WPA2") == 0)) { |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 1932 | dut->ap_tag_key_mgmt[wlan_tag - 2] = |
| 1933 | AP2_WPA2_PSK; |
Jouni Malinen | 353ba8b | 2018-01-10 17:04:12 +0200 | [diff] [blame] | 1934 | } else if (strcasecmp(val, "OWE") == 0 && |
| 1935 | wlan_tag == 2) { |
| 1936 | dut->ap_tag_key_mgmt[wlan_tag - 2] = |
| 1937 | AP2_WPA2_OWE; |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 1938 | } else { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1939 | send_resp(dut, conn, SIGMA_INVALID, |
| 1940 | "errorCode,Unsupported KEYMGNT"); |
| 1941 | return 0; |
| 1942 | } |
| 1943 | return 1; |
| 1944 | } |
| 1945 | } |
| 1946 | |
| 1947 | val = get_param(cmd, "KEYMGNT"); |
Ankita Bajaj | 0d212e8 | 2017-11-27 15:54:57 +0530 | [diff] [blame] | 1948 | if (!val) |
| 1949 | val = get_param(cmd,"KeyMgmtType"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1950 | if (val) { |
Ankita Bajaj | 0d212e8 | 2017-11-27 15:54:57 +0530 | [diff] [blame] | 1951 | if (strcasecmp(val, "WPA2-PSK") == 0 || |
| 1952 | (security && strcasecmp(security, "PSK") == 0 && |
| 1953 | strcasecmp(val, "WPA2") == 0)) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1954 | dut->ap_key_mgmt = AP_WPA2_PSK; |
| 1955 | dut->ap_cipher = AP_CCMP; |
| 1956 | } else if (strcasecmp(val, "WPA2-EAP") == 0 || |
| 1957 | strcasecmp(val, "WPA2-Ent") == 0) { |
| 1958 | dut->ap_key_mgmt = AP_WPA2_EAP; |
| 1959 | dut->ap_cipher = AP_CCMP; |
Jouni Malinen | ad395a2 | 2017-09-01 21:13:46 +0300 | [diff] [blame] | 1960 | } else if (strcasecmp(val, "SuiteB") == 0) { |
| 1961 | dut->ap_key_mgmt = AP_SUITEB; |
| 1962 | dut->ap_cipher = AP_GCMP_256; |
Jouni Malinen | d75e4d8 | 2018-01-11 20:21:15 +0200 | [diff] [blame] | 1963 | dut->ap_pmf = AP_PMF_REQUIRED; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1964 | } else if (strcasecmp(val, "WPA-PSK") == 0) { |
| 1965 | dut->ap_key_mgmt = AP_WPA_PSK; |
| 1966 | dut->ap_cipher = AP_TKIP; |
| 1967 | } else if (strcasecmp(val, "WPA-EAP") == 0 || |
| 1968 | strcasecmp(val, "WPA-Ent") == 0) { |
| 1969 | dut->ap_key_mgmt = AP_WPA_EAP; |
| 1970 | dut->ap_cipher = AP_TKIP; |
| 1971 | } else if (strcasecmp(val, "WPA2-Mixed") == 0) { |
| 1972 | dut->ap_key_mgmt = AP_WPA2_EAP_MIXED; |
| 1973 | dut->ap_cipher = AP_CCMP_TKIP; |
| 1974 | } else if (strcasecmp(val, "WPA2-PSK-Mixed") == 0) { |
| 1975 | dut->ap_key_mgmt = AP_WPA2_PSK_MIXED; |
| 1976 | dut->ap_cipher = AP_CCMP_TKIP; |
Jouni Malinen | 794a7a3 | 2018-01-10 16:39:34 +0200 | [diff] [blame] | 1977 | } else if (strcasecmp(val, "WPA2-SAE") == 0 || |
| 1978 | strcasecmp(val, "SAE") == 0) { |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 1979 | dut->ap_key_mgmt = AP_WPA2_SAE; |
| 1980 | dut->ap_cipher = AP_CCMP; |
Jouni Malinen | 1287cd7 | 2018-01-04 17:08:01 +0200 | [diff] [blame] | 1981 | dut->ap_pmf = AP_PMF_REQUIRED; |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 1982 | } else if (strcasecmp(val, "WPA2-PSK-SAE") == 0) { |
| 1983 | dut->ap_key_mgmt = AP_WPA2_PSK_SAE; |
| 1984 | dut->ap_cipher = AP_CCMP; |
Jouni Malinen | 1287cd7 | 2018-01-04 17:08:01 +0200 | [diff] [blame] | 1985 | dut->ap_pmf = AP_PMF_OPTIONAL; |
Jouni Malinen | 147b3c3 | 2017-10-09 16:51:54 +0300 | [diff] [blame] | 1986 | } else if (strcasecmp(val, "OWE") == 0) { |
| 1987 | dut->ap_key_mgmt = AP_WPA2_OWE; |
| 1988 | dut->ap_cipher = AP_CCMP; |
Jouni Malinen | 1287cd7 | 2018-01-04 17:08:01 +0200 | [diff] [blame] | 1989 | dut->ap_pmf = AP_PMF_REQUIRED; |
Jouni Malinen | 4cf699f | 2018-06-19 00:46:27 +0300 | [diff] [blame] | 1990 | } else if (strcasecmp(val, "WPA2-ENT-OSEN") == 0) { |
| 1991 | dut->ap_key_mgmt = AP_WPA2_EAP_OSEN; |
| 1992 | dut->ap_cipher = AP_CCMP; |
| 1993 | dut->ap_pmf = AP_PMF_OPTIONAL; |
Jouni Malinen | c2b9121 | 2018-09-12 02:26:39 +0300 | [diff] [blame] | 1994 | } else if (strcasecmp(val, "OSEN") == 0) { |
| 1995 | dut->ap_key_mgmt = AP_OSEN; |
| 1996 | dut->ap_cipher = AP_CCMP; |
Jouni Malinen | 6be21c8 | 2018-08-01 18:47:24 +0300 | [diff] [blame] | 1997 | } else if (strcasecmp(val, "FT-EAP") == 0) { |
| 1998 | dut->ap_key_mgmt = AP_WPA2_FT_EAP; |
| 1999 | dut->ap_cipher = AP_CCMP; |
| 2000 | dut->ap_pmf = AP_PMF_OPTIONAL; |
| 2001 | } else if (strcasecmp(val, "FT-PSK") == 0) { |
| 2002 | dut->ap_key_mgmt = AP_WPA2_FT_PSK; |
| 2003 | dut->ap_cipher = AP_CCMP; |
| 2004 | dut->ap_pmf = AP_PMF_OPTIONAL; |
| 2005 | } else if (strcasecmp(val, "WPA2-ENT-256") == 0) { |
| 2006 | dut->ap_key_mgmt = AP_WPA2_EAP_SHA256; |
| 2007 | dut->ap_cipher = AP_CCMP; |
| 2008 | dut->ap_pmf = AP_PMF_OPTIONAL; |
| 2009 | } else if (strcasecmp(val, "WPA2-PSK-256") == 0) { |
| 2010 | dut->ap_key_mgmt = AP_WPA2_PSK_SHA256; |
| 2011 | dut->ap_cipher = AP_CCMP; |
| 2012 | dut->ap_pmf = AP_PMF_OPTIONAL; |
| 2013 | } else if (strcasecmp(val, "WPA2-ENT-FT-EAP") == 0) { |
| 2014 | dut->ap_key_mgmt = AP_WPA2_ENT_FT_EAP; |
| 2015 | dut->ap_cipher = AP_CCMP; |
| 2016 | dut->ap_pmf = AP_PMF_OPTIONAL; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2017 | } else if (strcasecmp(val, "NONE") == 0) { |
| 2018 | dut->ap_key_mgmt = AP_OPEN; |
| 2019 | dut->ap_cipher = AP_PLAIN; |
| 2020 | } else { |
| 2021 | send_resp(dut, conn, SIGMA_INVALID, |
| 2022 | "errorCode,Unsupported KEYMGNT"); |
| 2023 | return 0; |
| 2024 | } |
| 2025 | } |
| 2026 | |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 2027 | val = get_param(cmd, "ECGroupID"); |
| 2028 | if (val) { |
Jouni Malinen | ed670f4 | 2017-08-31 01:39:28 +0300 | [diff] [blame] | 2029 | free(dut->ap_sae_groups); |
| 2030 | dut->ap_sae_groups = strdup(val); |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 2031 | } |
| 2032 | |
Jouni Malinen | 2f524ce | 2017-08-31 01:43:29 +0300 | [diff] [blame] | 2033 | val = get_param(cmd, "AntiCloggingThreshold"); |
| 2034 | if (val) |
| 2035 | dut->sae_anti_clogging_threshold = atoi(val); |
| 2036 | |
Jouni Malinen | b347db0 | 2017-09-02 01:36:03 +0300 | [diff] [blame] | 2037 | val = get_param(cmd, "Reflection"); |
| 2038 | if (val) |
| 2039 | dut->sae_reflection = strcasecmp(val, "SAE") == 0; |
| 2040 | |
Jouni Malinen | 6814313 | 2017-09-02 02:34:08 +0300 | [diff] [blame] | 2041 | val = get_param(cmd, "InvalidSAEElement"); |
| 2042 | if (val) { |
| 2043 | free(dut->sae_commit_override); |
| 2044 | dut->sae_commit_override = strdup(val); |
| 2045 | } |
| 2046 | |
Jouni Malinen | 09550de | 2019-03-26 00:24:11 +0200 | [diff] [blame] | 2047 | val = get_param(cmd, "SAEPasswords"); |
| 2048 | if (val) { |
| 2049 | free(dut->ap_sae_passwords); |
| 2050 | dut->ap_sae_passwords = strdup(val); |
| 2051 | } |
| 2052 | |
Jouni Malinen | 3c740ab | 2019-10-10 15:55:11 +0300 | [diff] [blame] | 2053 | val = get_param(cmd, "SAE_Confirm_Immediate"); |
| 2054 | if (val) |
| 2055 | dut->sae_confirm_immediate = get_enable_disable(val); |
| 2056 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2057 | val = get_param(cmd, "ENCRYPT"); |
Ankita Bajaj | 0d212e8 | 2017-11-27 15:54:57 +0530 | [diff] [blame] | 2058 | if (!val) |
| 2059 | val = get_param(cmd, "EncpType"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2060 | if (val) { |
| 2061 | if (strcasecmp(val, "WEP") == 0) { |
| 2062 | dut->ap_cipher = AP_WEP; |
| 2063 | } else if (strcasecmp(val, "TKIP") == 0) { |
| 2064 | dut->ap_cipher = AP_TKIP; |
| 2065 | } else if (strcasecmp(val, "AES") == 0 || |
| 2066 | strcasecmp(val, "AES-CCMP") == 0) { |
| 2067 | dut->ap_cipher = AP_CCMP; |
Jouni Malinen | 3d633da | 2017-09-14 22:19:21 +0300 | [diff] [blame] | 2068 | } else if (strcasecmp(val, "AES-GCMP") == 0) { |
| 2069 | dut->ap_cipher = AP_GCMP_128; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2070 | } else { |
| 2071 | send_resp(dut, conn, SIGMA_INVALID, |
| 2072 | "errorCode,Unsupported ENCRYPT"); |
| 2073 | return 0; |
| 2074 | } |
| 2075 | } |
| 2076 | |
Jouni Malinen | 3d633da | 2017-09-14 22:19:21 +0300 | [diff] [blame] | 2077 | val = get_param(cmd, "PairwiseCipher"); |
| 2078 | if (val) { |
| 2079 | if (strcasecmp(val, "AES-GCMP-256") == 0) { |
| 2080 | dut->ap_cipher = AP_GCMP_256; |
| 2081 | } else if (strcasecmp(val, "AES-CCMP-256") == 0) { |
| 2082 | dut->ap_cipher = AP_CCMP_256; |
| 2083 | } else if (strcasecmp(val, "AES-GCMP-128") == 0) { |
| 2084 | dut->ap_cipher = AP_GCMP_128; |
| 2085 | } else if (strcasecmp(val, "AES-CCMP-128") == 0) { |
| 2086 | dut->ap_cipher = AP_CCMP; |
Jouni Malinen | d538c78 | 2017-11-17 12:13:04 +0200 | [diff] [blame] | 2087 | } else if (strcasecmp(val, "AES-CCMP-128 AES-GCMP-256") == 0 || |
| 2088 | strcasecmp(val, "AES-GCMP-256 AES-CCMP-128") == 0) { |
| 2089 | dut->ap_cipher = AP_CCMP_128_GCMP_256; |
Jouni Malinen | 3d633da | 2017-09-14 22:19:21 +0300 | [diff] [blame] | 2090 | } else { |
| 2091 | send_resp(dut, conn, SIGMA_INVALID, |
| 2092 | "errorCode,Unsupported PairwiseCipher"); |
| 2093 | return 0; |
| 2094 | } |
| 2095 | } |
| 2096 | |
Jouni Malinen | 2ba2449 | 2017-11-17 12:43:59 +0200 | [diff] [blame] | 2097 | val = get_param(cmd, "GroupCipher"); |
| 2098 | if (val) { |
| 2099 | if (strcasecmp(val, "AES-GCMP-256") == 0) { |
| 2100 | dut->ap_group_cipher = AP_GCMP_256; |
| 2101 | } else if (strcasecmp(val, "AES-CCMP-256") == 0) { |
| 2102 | dut->ap_group_cipher = AP_CCMP_256; |
| 2103 | } else if (strcasecmp(val, "AES-GCMP-128") == 0) { |
| 2104 | dut->ap_group_cipher = AP_GCMP_128; |
| 2105 | } else if (strcasecmp(val, "AES-CCMP-128") == 0) { |
| 2106 | dut->ap_group_cipher = AP_CCMP; |
| 2107 | } else { |
| 2108 | send_resp(dut, conn, SIGMA_INVALID, |
| 2109 | "errorCode,Unsupported GroupCipher"); |
| 2110 | return 0; |
| 2111 | } |
| 2112 | } |
| 2113 | |
Jouni Malinen | 3d633da | 2017-09-14 22:19:21 +0300 | [diff] [blame] | 2114 | val = get_param(cmd, "GroupMgntCipher"); |
| 2115 | if (val) { |
| 2116 | if (strcasecmp(val, "BIP-GMAC-256") == 0) { |
| 2117 | dut->ap_group_mgmt_cipher = AP_BIP_GMAC_256; |
| 2118 | } else if (strcasecmp(val, "BIP-CMAC-256") == 0) { |
| 2119 | dut->ap_group_mgmt_cipher = AP_BIP_CMAC_256; |
| 2120 | } else if (strcasecmp(val, "BIP-GMAC-128") == 0) { |
| 2121 | dut->ap_group_mgmt_cipher = AP_BIP_GMAC_128; |
| 2122 | } else if (strcasecmp(val, "BIP-CMAC-128") == 0) { |
| 2123 | dut->ap_group_mgmt_cipher = AP_BIP_CMAC_128; |
| 2124 | } else { |
| 2125 | send_resp(dut, conn, SIGMA_INVALID, |
| 2126 | "errorCode,Unsupported GroupMgntCipher"); |
| 2127 | return 0; |
| 2128 | } |
| 2129 | } |
| 2130 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2131 | val = get_param(cmd, "WEPKEY"); |
| 2132 | if (val) { |
| 2133 | size_t len; |
| 2134 | if (dut->ap_cipher != AP_WEP) { |
| 2135 | send_resp(dut, conn, SIGMA_INVALID, |
| 2136 | "errorCode,Unexpected WEPKEY without WEP " |
| 2137 | "configuration"); |
| 2138 | return 0; |
| 2139 | } |
| 2140 | len = strlen(val); |
| 2141 | if (len != 10 && len != 26) { |
| 2142 | send_resp(dut, conn, SIGMA_INVALID, |
| 2143 | "errorCode,Unexpected WEPKEY length"); |
| 2144 | return 0; |
| 2145 | } |
| 2146 | snprintf(dut->ap_wepkey, sizeof(dut->ap_wepkey), "%s", val); |
| 2147 | } |
| 2148 | |
| 2149 | val = get_param(cmd, "PSK"); |
Ankita Bajaj | 0d212e8 | 2017-11-27 15:54:57 +0530 | [diff] [blame] | 2150 | if (!val) |
| 2151 | val = get_param(cmd, "passphrase"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2152 | if (val) { |
Jouni Malinen | da5f35b | 2019-03-26 00:25:53 +0200 | [diff] [blame] | 2153 | if (dut->ap_key_mgmt != AP_WPA2_SAE && |
| 2154 | (dut->ap_akm_values & (AKM_WPA_PSK | AKM_SAE)) != |
| 2155 | AKM_SAE && |
| 2156 | strlen(val) > 64) { |
| 2157 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 2158 | "Too long PSK/passphtase"); |
Jouni Malinen | 2126f42 | 2017-10-11 23:24:33 +0300 | [diff] [blame] | 2159 | return -1; |
Jouni Malinen | da5f35b | 2019-03-26 00:25:53 +0200 | [diff] [blame] | 2160 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2161 | if (strlen(val) > sizeof(dut->ap_passphrase) - 1) |
| 2162 | return -1; |
| 2163 | snprintf(dut->ap_passphrase, sizeof(dut->ap_passphrase), |
| 2164 | "%s", val); |
| 2165 | } |
| 2166 | |
Jouni Malinen | 6337062 | 2017-11-18 17:47:13 +0200 | [diff] [blame] | 2167 | val = get_param(cmd, "PSKHEX"); |
| 2168 | if (val) { |
| 2169 | if (strlen(val) != 64) |
| 2170 | return -1; |
| 2171 | strlcpy(dut->ap_psk, val, sizeof(dut->ap_psk)); |
| 2172 | } |
| 2173 | |
Ankita Bajaj | 0d212e8 | 2017-11-27 15:54:57 +0530 | [diff] [blame] | 2174 | if (dut->program == PROGRAM_OCE && dut->dev_role == DEVROLE_STA_CFON) |
| 2175 | dut->ap_pmf = AP_PMF_OPTIONAL; |
| 2176 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2177 | val = get_param(cmd, "PMF"); |
| 2178 | if (val) { |
| 2179 | if (strcasecmp(val, "Disabled") == 0) { |
| 2180 | dut->ap_pmf = AP_PMF_DISABLED; |
| 2181 | } else if (strcasecmp(val, "Optional") == 0) { |
| 2182 | dut->ap_pmf = AP_PMF_OPTIONAL; |
| 2183 | } else if (strcasecmp(val, "Required") == 0) { |
| 2184 | dut->ap_pmf = AP_PMF_REQUIRED; |
| 2185 | } else { |
| 2186 | send_resp(dut, conn, SIGMA_INVALID, |
| 2187 | "errorCode,Unsupported PMF"); |
| 2188 | return 0; |
| 2189 | } |
| 2190 | } |
| 2191 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2192 | dut->ap_add_sha256 = 0; |
| 2193 | val = get_param(cmd, "SHA256AD"); |
| 2194 | if (val == NULL) |
| 2195 | val = get_param(cmd, "SHA256"); |
| 2196 | if (val) { |
| 2197 | if (strcasecmp(val, "Disabled") == 0) { |
| 2198 | } else if (strcasecmp(val, "Enabled") == 0) { |
| 2199 | dut->ap_add_sha256 = 1; |
| 2200 | } else { |
| 2201 | send_resp(dut, conn, SIGMA_INVALID, |
Jouni Malinen | a7fa620 | 2019-03-26 00:22:10 +0200 | [diff] [blame] | 2202 | "errorCode,Unsupported SHA256"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2203 | return 0; |
| 2204 | } |
| 2205 | } |
| 2206 | |
Sarvepalli, Rajesh Babu | 24dc7e4 | 2016-03-18 21:27:26 +0530 | [diff] [blame] | 2207 | val = get_param(cmd, "PreAuthentication"); |
| 2208 | if (val) { |
| 2209 | if (strcasecmp(val, "disabled") == 0) { |
| 2210 | dut->ap_rsn_preauth = 0; |
| 2211 | } else if (strcasecmp(val, "enabled") == 0) { |
| 2212 | dut->ap_rsn_preauth = 1; |
| 2213 | } else { |
| 2214 | send_resp(dut, conn, SIGMA_INVALID, |
| 2215 | "errorCode,Unsupported PreAuthentication value"); |
| 2216 | return 0; |
| 2217 | } |
| 2218 | } |
| 2219 | |
priyadharshini gowthaman | de81f39 | 2017-12-28 15:28:49 -0800 | [diff] [blame] | 2220 | val = get_param(cmd, "AKMSuiteType"); |
| 2221 | if (val) { |
Jouni Malinen | da5f35b | 2019-03-26 00:25:53 +0200 | [diff] [blame] | 2222 | const char *in_pos = val; |
priyadharshini gowthaman | de81f39 | 2017-12-28 15:28:49 -0800 | [diff] [blame] | 2223 | |
Jouni Malinen | da5f35b | 2019-03-26 00:25:53 +0200 | [diff] [blame] | 2224 | dut->ap_akm_values = 0; |
| 2225 | while (*in_pos) { |
| 2226 | int akm = atoi(in_pos); |
| 2227 | |
| 2228 | if (akm < 0 || akm >= 32) { |
| 2229 | send_resp(dut, conn, SIGMA_ERROR, |
| 2230 | "errorCode,Unsupported AKMSuiteType value"); |
| 2231 | return STATUS_SENT; |
| 2232 | } |
| 2233 | |
| 2234 | dut->ap_akm_values |= 1 << akm; |
| 2235 | |
| 2236 | in_pos = strchr(in_pos, ';'); |
| 2237 | if (!in_pos) |
| 2238 | break; |
| 2239 | while (*in_pos == ';') |
| 2240 | in_pos++; |
priyadharshini gowthaman | de81f39 | 2017-12-28 15:28:49 -0800 | [diff] [blame] | 2241 | } |
Jouni Malinen | da5f35b | 2019-03-26 00:25:53 +0200 | [diff] [blame] | 2242 | dut->ap_akm = 1; |
| 2243 | if (dut->ap_akm_values & (1 << 14)) |
| 2244 | dut->ap_add_sha384 = 1; |
| 2245 | if (dut->ap_akm_values & (1 << 15)) |
| 2246 | dut->ap_add_sha384 = 1; |
| 2247 | } |
| 2248 | |
| 2249 | if (dut->ap_key_mgmt == AP_OPEN && !dut->ap_akm_values) { |
| 2250 | dut->ap_hs2 = 0; |
| 2251 | dut->ap_pmf = AP_PMF_DISABLED; |
priyadharshini gowthaman | de81f39 | 2017-12-28 15:28:49 -0800 | [diff] [blame] | 2252 | } |
| 2253 | |
| 2254 | val = get_param(cmd, "PMKSACaching"); |
| 2255 | if (val) { |
| 2256 | dut->ap_pmksa = 1; |
| 2257 | if (strcasecmp(val, "disabled") == 0) { |
| 2258 | dut->ap_pmksa_caching = 1; |
| 2259 | } else if (strcasecmp(val, "enabled") == 0) { |
| 2260 | dut->ap_pmksa_caching = 0; |
| 2261 | } else { |
| 2262 | send_resp(dut, conn, SIGMA_INVALID, |
| 2263 | "errorCode,Unsupported PMKSACaching value"); |
| 2264 | return 0; |
| 2265 | } |
| 2266 | } |
| 2267 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2268 | return 1; |
| 2269 | } |
| 2270 | |
| 2271 | |
Ankita Bajaj | 0d5825b | 2017-10-25 16:20:17 +0530 | [diff] [blame] | 2272 | int sta_cfon_set_wireless(struct sigma_dut *dut, struct sigma_conn *conn, |
| 2273 | struct sigma_cmd *cmd) |
| 2274 | { |
| 2275 | int status; |
| 2276 | |
| 2277 | status = cmd_ap_set_wireless(dut, conn, cmd); |
| 2278 | if (status != 1) |
| 2279 | return status; |
Ankita Bajaj | 0d212e8 | 2017-11-27 15:54:57 +0530 | [diff] [blame] | 2280 | status = cmd_ap_set_security(dut, conn, cmd); |
| 2281 | if (status != 1) |
| 2282 | return status; |
Ankita Bajaj | 0d5825b | 2017-10-25 16:20:17 +0530 | [diff] [blame] | 2283 | return cmd_ap_config_commit(dut, conn, cmd); |
| 2284 | } |
| 2285 | |
| 2286 | |
Jouni Malinen | f722271 | 2019-06-13 01:50:21 +0300 | [diff] [blame] | 2287 | static enum sigma_cmd_result cmd_ap_set_radius(struct sigma_dut *dut, |
| 2288 | struct sigma_conn *conn, |
| 2289 | struct sigma_cmd *cmd) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2290 | { |
| 2291 | /* const char *name = get_param(cmd, "NAME"); */ |
| 2292 | const char *val; |
| 2293 | unsigned int wlan_tag = 1, radius_port = 0; |
| 2294 | char *radius_ipaddr = NULL, *radius_password = NULL; |
| 2295 | |
| 2296 | val = get_param(cmd, "WLAN_TAG"); |
| 2297 | if (val) { |
| 2298 | wlan_tag = atoi(val); |
| 2299 | if (wlan_tag != 1 && wlan_tag != 2) { |
| 2300 | send_resp(dut, conn, SIGMA_INVALID, |
| 2301 | "errorCode,Invalid WLAN_TAG"); |
| 2302 | return 0; |
| 2303 | } |
| 2304 | } |
| 2305 | |
| 2306 | val = get_param(cmd, "PORT"); |
| 2307 | if (val) |
| 2308 | radius_port = atoi(val); |
| 2309 | |
| 2310 | if (wlan_tag == 1) { |
| 2311 | if (radius_port) |
| 2312 | dut->ap_radius_port = radius_port; |
| 2313 | radius_ipaddr = dut->ap_radius_ipaddr; |
| 2314 | radius_password = dut->ap_radius_password; |
| 2315 | } else if (wlan_tag == 2) { |
| 2316 | if (radius_port) |
| 2317 | dut->ap2_radius_port = radius_port; |
| 2318 | radius_ipaddr = dut->ap2_radius_ipaddr; |
| 2319 | radius_password = dut->ap2_radius_password; |
| 2320 | } |
| 2321 | |
| 2322 | val = get_param(cmd, "IPADDR"); |
| 2323 | if (val) { |
| 2324 | if (strlen(val) > sizeof(dut->ap_radius_ipaddr) - 1) |
| 2325 | return -1; |
| 2326 | snprintf(radius_ipaddr, sizeof(dut->ap_radius_ipaddr), |
| 2327 | "%s", val); |
| 2328 | } |
| 2329 | |
| 2330 | val = get_param(cmd, "PASSWORD"); |
| 2331 | if (val) { |
| 2332 | if (strlen(val) > sizeof(dut->ap_radius_password) - 1) |
| 2333 | return -1; |
| 2334 | snprintf(radius_password, |
| 2335 | sizeof(dut->ap_radius_password), "%s", val); |
| 2336 | } |
| 2337 | |
| 2338 | return 1; |
| 2339 | } |
| 2340 | |
| 2341 | |
| 2342 | static void owrt_ap_set_radio(struct sigma_dut *dut, int id, |
| 2343 | const char *key, const char *val) |
| 2344 | { |
| 2345 | char buf[100]; |
| 2346 | |
| 2347 | if (val == NULL) { |
| 2348 | snprintf(buf, sizeof(buf), |
| 2349 | "uci delete wireless.wifi%d.%s", id, key); |
| 2350 | run_system(dut, buf); |
| 2351 | return; |
| 2352 | } |
| 2353 | |
| 2354 | snprintf(buf, sizeof(buf), "uci set wireless.wifi%d.%s=%s", |
| 2355 | id, key, val); |
| 2356 | run_system(dut, buf); |
| 2357 | } |
| 2358 | |
| 2359 | |
| 2360 | static void owrt_ap_set_list_radio(struct sigma_dut *dut, int id, |
| 2361 | const char *key, const char *val) |
| 2362 | { |
| 2363 | char buf[256]; |
| 2364 | |
| 2365 | if (val == NULL) { |
| 2366 | snprintf(buf, sizeof(buf), |
| 2367 | "uci del_list wireless.wifi%d.%s", id, key); |
| 2368 | run_system(dut, buf); |
| 2369 | return; |
| 2370 | } |
| 2371 | |
| 2372 | snprintf(buf, sizeof(buf), "uci add_list wireless.wifi%d.%s=%s", |
| 2373 | id, key, val); |
| 2374 | run_system(dut, buf); |
| 2375 | } |
| 2376 | |
| 2377 | |
| 2378 | static void owrt_ap_set_vap(struct sigma_dut *dut, int id, const char *key, |
| 2379 | const char *val) |
| 2380 | { |
| 2381 | char buf[256]; |
| 2382 | |
| 2383 | if (val == NULL) { |
| 2384 | snprintf(buf, sizeof(buf), |
| 2385 | "uci delete wireless.@wifi-iface[%d].%s", id, key); |
| 2386 | run_system(dut, buf); |
| 2387 | return; |
| 2388 | } |
| 2389 | |
| 2390 | snprintf(buf, sizeof(buf), "uci set wireless.@wifi-iface[%d].%s=%s", |
| 2391 | id, key, val); |
| 2392 | run_system(dut, buf); |
| 2393 | } |
| 2394 | |
| 2395 | |
| 2396 | static void owrt_ap_set_list_vap(struct sigma_dut *dut, int id, |
| 2397 | const char *key, const char *val) |
| 2398 | { |
priyadharshini gowthaman | 2323d0a | 2016-09-02 15:48:02 -0700 | [diff] [blame] | 2399 | char buf[1024]; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2400 | |
| 2401 | if (val == NULL) { |
| 2402 | snprintf(buf, sizeof(buf), |
| 2403 | "uci del_list wireless.@wifi-iface[%d].%s", id, key); |
| 2404 | run_system(dut, buf); |
| 2405 | return; |
| 2406 | } |
| 2407 | |
| 2408 | snprintf(buf, sizeof(buf), |
| 2409 | "uci add_list wireless.@wifi-iface[%d].%s=%s", |
| 2410 | id, key, val); |
| 2411 | run_system(dut, buf); |
| 2412 | } |
| 2413 | |
| 2414 | |
| 2415 | static void owrt_ap_add_vap(struct sigma_dut *dut, int id, const char *key, |
| 2416 | const char *val) |
| 2417 | { |
| 2418 | char buf[256]; |
Jouni Malinen | 3aa7286 | 2019-05-29 23:14:51 +0300 | [diff] [blame] | 2419 | int res; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2420 | |
| 2421 | if (val == NULL) { |
Jouni Malinen | 3aa7286 | 2019-05-29 23:14:51 +0300 | [diff] [blame] | 2422 | res = snprintf(buf, sizeof(buf), |
| 2423 | "uci delete wireless.@wifi-iface[%d].%s", |
| 2424 | id, key); |
| 2425 | if (res >= 0 && res < sizeof(buf)) |
| 2426 | run_system(dut, buf); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2427 | return; |
| 2428 | } |
| 2429 | |
Jouni Malinen | 3aa7286 | 2019-05-29 23:14:51 +0300 | [diff] [blame] | 2430 | run_system(dut, "uci add wireless wifi-iface"); |
| 2431 | res = snprintf(buf, sizeof(buf), |
| 2432 | "uci set wireless.@wifi-iface[%d].%s=%s", |
| 2433 | id, key, val); |
| 2434 | if (res >= 0 && res < sizeof(buf)) |
| 2435 | run_system(dut, buf); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2436 | snprintf(buf, sizeof(buf), "uci set wireless.@wifi-iface[%d].%s=%s", |
| 2437 | id, "network", "lan"); |
| 2438 | run_system(dut, buf); |
| 2439 | snprintf(buf, sizeof(buf), "uci set wireless.@wifi-iface[%d].%s=%s", |
| 2440 | id, "mode", "ap"); |
| 2441 | run_system(dut, buf); |
| 2442 | snprintf(buf, sizeof(buf), "uci set wireless.@wifi-iface[%d].%s=%s", |
| 2443 | id, "encryption", "none"); |
| 2444 | run_system(dut, buf); |
| 2445 | } |
| 2446 | |
| 2447 | |
Alejandro Vasquez | 363f558 | 2018-07-17 11:25:05 -0700 | [diff] [blame] | 2448 | #define OPENWRT_MAX_NUM_RADIOS (MAX_RADIO + 1) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2449 | static void owrt_ap_config_radio(struct sigma_dut *dut) |
| 2450 | { |
Alejandro Vasquez | 363f558 | 2018-07-17 11:25:05 -0700 | [diff] [blame] | 2451 | int radio_id[MAX_RADIO] = { 0, 1, 2 }; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2452 | int radio_count, radio_no; |
| 2453 | char buf[64]; |
| 2454 | |
| 2455 | for (radio_count = 0; radio_count < OPENWRT_MAX_NUM_RADIOS; |
| 2456 | radio_count++) { |
| 2457 | snprintf(buf, sizeof(buf), "%s%d", "wifi", radio_count); |
| 2458 | for (radio_no = 0; radio_no < MAX_RADIO; radio_no++) { |
| 2459 | if (!sigma_radio_ifname[radio_no] || |
| 2460 | strcmp(sigma_radio_ifname[radio_no], buf) != 0) |
| 2461 | continue; |
| 2462 | owrt_ap_set_radio(dut, radio_count, "disabled", "0"); |
| 2463 | owrt_ap_set_vap(dut, radio_count, "device", buf); |
| 2464 | radio_id[radio_no] = radio_count; |
| 2465 | } |
| 2466 | } |
| 2467 | |
| 2468 | /* Hardware mode (11a/b/g/n/ac) & HT mode selection */ |
| 2469 | switch (dut->ap_mode) { |
| 2470 | case AP_11g: |
| 2471 | owrt_ap_set_radio(dut, radio_id[0], "hwmode", "11g"); |
| 2472 | break; |
| 2473 | case AP_11b: |
| 2474 | owrt_ap_set_radio(dut, radio_id[0], "hwmode", "11b"); |
| 2475 | break; |
| 2476 | case AP_11ng: |
| 2477 | owrt_ap_set_radio(dut, radio_id[0], "hwmode", "11ng"); |
| 2478 | owrt_ap_set_radio(dut, radio_id[0], "htmode", "HT20"); |
| 2479 | break; |
| 2480 | case AP_11a: |
| 2481 | owrt_ap_set_radio(dut, radio_id[0], "hwmode", "11a"); |
| 2482 | break; |
| 2483 | case AP_11na: |
| 2484 | owrt_ap_set_radio(dut, radio_id[0], "hwmode", "11na"); |
| 2485 | owrt_ap_set_radio(dut, radio_id[0], "htmode", "HT20"); |
| 2486 | break; |
| 2487 | case AP_11ac: |
| 2488 | owrt_ap_set_radio(dut, radio_id[0], "hwmode", "11ac"); |
| 2489 | owrt_ap_set_radio(dut, radio_id[0], "htmode", "HT80"); |
| 2490 | break; |
| 2491 | case AP_inval: |
| 2492 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 2493 | "MODE NOT SPECIFIED!"); |
| 2494 | return; |
| 2495 | default: |
| 2496 | owrt_ap_set_radio(dut, radio_id[0], "hwmode", "11ng"); |
| 2497 | owrt_ap_set_radio(dut, radio_id[0], "htmode", "HT20"); |
| 2498 | break; |
| 2499 | } |
| 2500 | |
| 2501 | if (dut->ap_is_dual) { |
| 2502 | /* Hardware mode (11a/b/g/n/ac) & HT mode selection */ |
| 2503 | switch (dut->ap_mode_1) { |
| 2504 | case AP_11g: |
| 2505 | owrt_ap_set_radio(dut, radio_id[1], "hwmode", "11g"); |
| 2506 | break; |
| 2507 | case AP_11b: |
| 2508 | owrt_ap_set_radio(dut, radio_id[1], "hwmode", "11b"); |
| 2509 | break; |
| 2510 | case AP_11ng: |
| 2511 | owrt_ap_set_radio(dut, radio_id[1], "hwmode", "11ng"); |
| 2512 | owrt_ap_set_radio(dut, radio_id[1], "htmode", "HT20"); |
| 2513 | break; |
| 2514 | case AP_11a: |
| 2515 | owrt_ap_set_radio(dut, radio_id[1], "hwmode", "11a"); |
| 2516 | break; |
| 2517 | case AP_11na: |
| 2518 | owrt_ap_set_radio(dut, radio_id[1], "hwmode", "11na"); |
| 2519 | owrt_ap_set_radio(dut, radio_id[1], "htmode", "HT20"); |
| 2520 | break; |
| 2521 | case AP_11ac: |
| 2522 | owrt_ap_set_radio(dut, radio_id[1], "hwmode", "11ac"); |
| 2523 | owrt_ap_set_radio(dut, radio_id[1], "htmode", "HT80"); |
| 2524 | break; |
| 2525 | case AP_inval: |
| 2526 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 2527 | "MODE NOT SPECIFIED!"); |
| 2528 | return; |
| 2529 | default: |
| 2530 | owrt_ap_set_radio(dut, radio_id[1], "hwmode", "11ng"); |
| 2531 | owrt_ap_set_radio(dut, radio_id[1], "htmode", "HT20"); |
| 2532 | break; |
| 2533 | } |
| 2534 | |
| 2535 | } |
| 2536 | |
| 2537 | /* Channel */ |
| 2538 | snprintf(buf, sizeof(buf), "%d", dut->ap_channel); |
| 2539 | owrt_ap_set_radio(dut, radio_id[0], "channel", buf); |
| 2540 | |
| 2541 | switch (dut->ap_chwidth) { |
| 2542 | case AP_20: |
| 2543 | owrt_ap_set_radio(dut, radio_id[0], "htmode", "HT20"); |
| 2544 | break; |
| 2545 | case AP_40: |
| 2546 | owrt_ap_set_radio(dut, radio_id[0], "htmode", "HT40"); |
| 2547 | break; |
| 2548 | case AP_80: |
| 2549 | owrt_ap_set_radio(dut, radio_id[0], "htmode", "HT80"); |
| 2550 | break; |
| 2551 | case AP_160: |
| 2552 | owrt_ap_set_radio(dut, radio_id[0], "htmode", "HT160"); |
| 2553 | break; |
priyadharshini gowthaman | 63ab848 | 2017-12-28 15:32:55 -0800 | [diff] [blame] | 2554 | case AP_80_80: |
| 2555 | owrt_ap_set_radio(dut, radio_id[0], "htmode", "HT80_80"); |
| 2556 | break; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2557 | case AP_AUTO: |
| 2558 | default: |
| 2559 | break; |
| 2560 | } |
| 2561 | |
| 2562 | if (dut->ap_channel == 140 || dut->ap_channel == 144) { |
| 2563 | if (get_openwrt_driver_type() == OPENWRT_DRIVER_ATHEROS) |
| 2564 | owrt_ap_set_radio(dut, radio_id[0], "set_ch_144", "3"); |
| 2565 | } |
| 2566 | |
| 2567 | if (dut->ap_is_dual) { |
| 2568 | snprintf(buf, sizeof(buf), "%d", dut->ap_channel_1); |
| 2569 | owrt_ap_set_radio(dut, radio_id[1], "channel", buf); |
| 2570 | } |
| 2571 | |
Adil Saeed Musthafa | 604c826 | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 2572 | /* Country Code */ |
| 2573 | if (dut->ap_reg_domain == REG_DOMAIN_GLOBAL) { |
| 2574 | const char *country; |
| 2575 | |
| 2576 | country = dut->ap_countrycode[0] ? dut->ap_countrycode : "US"; |
| 2577 | snprintf(buf, sizeof(buf), "%s4", country); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2578 | owrt_ap_set_radio(dut, radio_id[0], "country", buf); |
priyadharshini gowthaman | 27406b0 | 2017-12-28 15:35:45 -0800 | [diff] [blame] | 2579 | if (dut->ap_is_dual) |
| 2580 | owrt_ap_set_radio(dut, radio_id[1], "country", buf); |
Adil Saeed Musthafa | 604c826 | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 2581 | } else if (dut->ap_countrycode[0]) { |
| 2582 | owrt_ap_set_radio(dut, radio_id[0], "country", |
| 2583 | dut->ap_countrycode); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2584 | } |
| 2585 | |
| 2586 | if (dut->ap_disable_protection == 1) { |
| 2587 | owrt_ap_set_list_radio(dut, radio_id[0], "aggr_burst", "'0 0'"); |
| 2588 | owrt_ap_set_list_radio(dut, radio_id[0], "aggr_burst", "'1 0'"); |
| 2589 | owrt_ap_set_list_radio(dut, radio_id[0], "aggr_burst", "'2 0'"); |
| 2590 | owrt_ap_set_list_radio(dut, radio_id[0], "aggr_burst", "'3 0'"); |
| 2591 | } |
priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 2592 | |
| 2593 | if (dut->ap_oce == VALUE_ENABLED && |
| 2594 | get_driver_type() == DRIVER_OPENWRT) |
| 2595 | owrt_ap_set_radio(dut, radio_id[0], "bcnburst", "1"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2596 | } |
| 2597 | |
| 2598 | |
| 2599 | static int owrt_ap_config_vap_hs2(struct sigma_dut *dut, int vap_id) |
| 2600 | { |
| 2601 | char buf[256]; |
| 2602 | |
| 2603 | snprintf(buf, sizeof(buf), "%d", dut->ap_hs2); |
| 2604 | owrt_ap_set_vap(dut, vap_id, "hs20", buf); |
| 2605 | owrt_ap_set_vap(dut, vap_id, "qbssload", "1"); |
| 2606 | owrt_ap_set_vap(dut, vap_id, "hs20_deauth_req_timeout","3"); |
| 2607 | |
| 2608 | owrt_ap_set_list_vap(dut, vap_id, "hs20_oper_friendly_name", |
| 2609 | "'eng:Wi-Fi Alliance'"); |
| 2610 | |
| 2611 | owrt_ap_set_list_vap(dut, vap_id, "hs20_oper_friendly_name", |
| 2612 | "'chi:Wi-Fi\xe8\x81\x94\xe7\x9b\x9f'"); |
| 2613 | |
| 2614 | if (dut->ap_wan_metrics == 1) |
| 2615 | owrt_ap_set_vap(dut, vap_id, "hs20_wan_metrics", |
| 2616 | "'01:2500:384:0:0:10'"); |
| 2617 | else if (dut->ap_wan_metrics == 1) |
| 2618 | owrt_ap_set_vap(dut, vap_id, "hs20_wan_metrics", |
| 2619 | "'01:1500:384:20:20:10'"); |
| 2620 | else if (dut->ap_wan_metrics == 2) |
| 2621 | owrt_ap_set_vap(dut, vap_id, "hs20_wan_metrics", |
| 2622 | "'01:1500:384:20:20:10'"); |
| 2623 | else if (dut->ap_wan_metrics == 3) |
| 2624 | owrt_ap_set_vap(dut, vap_id, "hs20_wan_metrics", |
| 2625 | "'01:2000:1000:20:20:10'"); |
| 2626 | else if (dut->ap_wan_metrics == 4) |
| 2627 | owrt_ap_set_vap(dut, vap_id, "hs20_wan_metrics", |
| 2628 | "'01:8000:1000:20:20:10'"); |
| 2629 | else if (dut->ap_wan_metrics == 5) |
| 2630 | owrt_ap_set_vap(dut, vap_id, "hs20_wan_metrics", |
| 2631 | "'01:9000:5000:20:20:10'"); |
| 2632 | |
| 2633 | if (dut->ap_conn_capab == 1) { |
| 2634 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", "'1:0:0'"); |
| 2635 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", |
| 2636 | "'6:20:1'"); |
| 2637 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", |
| 2638 | "'6:22:0'"); |
| 2639 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", |
| 2640 | "'6:80:1'"); |
| 2641 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", |
| 2642 | "'6:443:1'"); |
| 2643 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", |
| 2644 | "'6:1723:0'"); |
| 2645 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", |
| 2646 | "'6:5060:0'"); |
| 2647 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", |
| 2648 | "'17:500:1'"); |
| 2649 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", |
| 2650 | "'17:5060:0'"); |
| 2651 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", |
| 2652 | "'17:4500:1'"); |
| 2653 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", |
| 2654 | "'50:0:1'"); |
| 2655 | } else if (dut->ap_conn_capab == 2) { |
| 2656 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", |
| 2657 | "'6:80:1'"); |
| 2658 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", |
| 2659 | "'6:443:1'"); |
| 2660 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", |
| 2661 | "'17:5060:1'"); |
| 2662 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", |
| 2663 | "'6:5060:1'"); |
| 2664 | } else if (dut->ap_conn_capab == 3) { |
| 2665 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", |
| 2666 | "'6:80:1'"); |
| 2667 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", |
| 2668 | "'6:443:1'"); |
| 2669 | } |
| 2670 | |
| 2671 | if (dut->ap_oper_class == 1) |
| 2672 | snprintf(buf, sizeof(buf), "%s", "51"); |
| 2673 | else if (dut->ap_oper_class == 2) |
| 2674 | snprintf(buf, sizeof(buf), "%s", "73"); |
| 2675 | else if (dut->ap_oper_class == 3) |
| 2676 | snprintf(buf, sizeof(buf), "%s", "5173"); |
| 2677 | |
| 2678 | if (dut->ap_oper_class) |
| 2679 | owrt_ap_set_vap(dut, vap_id, "hs20_operating_class", buf); |
| 2680 | |
| 2681 | if (dut->ap_osu_provider_list) { |
| 2682 | char *osu_friendly_name = NULL; |
| 2683 | char *osu_icon = NULL; |
| 2684 | char *osu_ssid = NULL; |
| 2685 | char *osu_nai = NULL; |
| 2686 | char *osu_service_desc = NULL; |
| 2687 | char *hs20_icon_filename = NULL; |
| 2688 | char hs20_icon[150]; |
| 2689 | int osu_method; |
| 2690 | |
| 2691 | hs20_icon_filename = "icon_red_zxx.png"; |
| 2692 | if (dut->ap_osu_icon_tag == 2) |
| 2693 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 2694 | snprintf(hs20_icon, sizeof(hs20_icon), |
| 2695 | "'128:61:zxx:image/png:icon_red_zxx.png:/etc/ath/%s'", |
| 2696 | hs20_icon_filename); |
| 2697 | osu_icon = "icon_red_zxx.png"; |
| 2698 | osu_ssid = "OSU"; |
| 2699 | osu_friendly_name = "'kor:SP 빨강 테스트 전용'"; |
| 2700 | osu_service_desc = "'kor:테스트 목적으로 무료 서비스'"; |
| 2701 | osu_method = (dut->ap_osu_method[0] == 0xFF) ? 1 : |
| 2702 | dut->ap_osu_method[0]; |
| 2703 | |
| 2704 | if (strlen(dut->ap_osu_server_uri[0])) |
| 2705 | owrt_ap_set_list_vap(dut, vap_id, "osu_server_uri", |
| 2706 | dut->ap_osu_server_uri[0]); |
| 2707 | else |
| 2708 | owrt_ap_set_list_vap(dut, vap_id, "osu_server_uri", |
| 2709 | "'https://osu-server.r2-testbed.wi-fi.org/'"); |
| 2710 | switch (dut->ap_osu_provider_list) { |
| 2711 | case 1: |
| 2712 | case 101: |
| 2713 | owrt_ap_set_list_vap(dut, vap_id, "osu_friendly_name", |
| 2714 | "'eng:SP Red Test Only'"); |
| 2715 | owrt_ap_set_list_vap(dut, vap_id, "osu_service_desc", |
| 2716 | "'eng:Free service for test purpose'"); |
| 2717 | owrt_ap_set_list_vap(dut, vap_id, "hs20_icon", |
| 2718 | hs20_icon); |
| 2719 | |
| 2720 | hs20_icon_filename = "icon_red_eng.png"; |
| 2721 | if (dut->ap_osu_icon_tag == 2) |
| 2722 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 2723 | |
| 2724 | snprintf(hs20_icon, sizeof(hs20_icon), |
| 2725 | "'160:76:eng:image/png:icon_red_eng.png:/etc/ath/%s'", |
| 2726 | hs20_icon_filename); |
| 2727 | owrt_ap_set_list_vap(dut, vap_id, "osu_icon", |
| 2728 | "icon_red_eng.png"); |
| 2729 | break; |
| 2730 | case 2: |
| 2731 | case 102: |
| 2732 | owrt_ap_set_list_vap(dut, vap_id, "osu_friendly_name", |
| 2733 | "'eng:Wireless Broadband Alliance'"); |
| 2734 | owrt_ap_set_list_vap(dut, vap_id, "osu_service_desc", |
| 2735 | "'eng:Free service for test purpose'"); |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2736 | hs20_icon_filename = "icon_orange_zxx.png"; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2737 | if (dut->ap_osu_icon_tag == 2) |
| 2738 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 2739 | |
| 2740 | snprintf(hs20_icon, sizeof(hs20_icon), |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2741 | "'128:61:zxx:image/png:icon_orange_zxx.png:/etc/ath/%s'", |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2742 | hs20_icon_filename); |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2743 | osu_icon = "icon_orange_zxx.png"; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2744 | osu_friendly_name = "'kor:와이어리스 브로드밴드 얼라이언스'"; |
| 2745 | break; |
| 2746 | case 3: |
| 2747 | case 103: |
Jouni Malinen | 02502de | 2018-10-15 17:19:33 +0300 | [diff] [blame] | 2748 | osu_friendly_name = "'spa:SP Red Test Only'"; |
| 2749 | osu_service_desc = "'spa:Free service for test purpose'"; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2750 | break; |
| 2751 | case 4: |
| 2752 | case 104: |
| 2753 | owrt_ap_set_list_vap(dut, vap_id, "osu_friendly_name", |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2754 | "'eng:SP Orange Test Only'"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2755 | owrt_ap_set_list_vap(dut, vap_id, "osu_service_desc", |
| 2756 | "'eng:Free service for test purpose'"); |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2757 | hs20_icon_filename = "icon_orange_eng.png"; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2758 | if (dut->ap_osu_icon_tag == 2) |
| 2759 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 2760 | |
| 2761 | snprintf(hs20_icon, sizeof(hs20_icon), |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2762 | "'160:76:eng:image/png:icon_orange_eng.png:/etc/ath/%s'", |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2763 | hs20_icon_filename); |
| 2764 | owrt_ap_set_list_vap(dut, vap_id, "hs20_icon", |
| 2765 | hs20_icon); |
Jouni Malinen | fd45ad5 | 2018-10-15 17:06:18 +0300 | [diff] [blame] | 2766 | osu_friendly_name = "'kor:SP 오렌지 테스트 전용'"; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2767 | |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2768 | hs20_icon_filename = "icon_orange_zxx.png"; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2769 | if (dut->ap_osu_icon_tag == 2) |
| 2770 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 2771 | |
| 2772 | snprintf(hs20_icon, sizeof(hs20_icon), |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2773 | "'128:61:zxx:image/png:icon_orange_zxx.png:/etc/ath/%s'", |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2774 | hs20_icon_filename); |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2775 | osu_icon = "icon_orange_zxx.png"; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2776 | break; |
| 2777 | case 5: |
| 2778 | case 105: |
| 2779 | owrt_ap_set_list_vap(dut, vap_id, "osu_friendly_name", |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2780 | "'eng:SP Orange Test Only'"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2781 | owrt_ap_set_list_vap(dut, vap_id, "osu_service_desc", |
| 2782 | "'eng:Free service for test purpose'"); |
Jouni Malinen | fd45ad5 | 2018-10-15 17:06:18 +0300 | [diff] [blame] | 2783 | osu_friendly_name = "'kor:SP 오렌지 테스트 전용'"; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2784 | |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2785 | hs20_icon_filename = "icon_orange_zxx.png"; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2786 | if (dut->ap_osu_icon_tag == 2) |
| 2787 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 2788 | |
| 2789 | snprintf(hs20_icon, sizeof(hs20_icon), |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2790 | "'128:61:zxx:image/png:icon_orange_zxx.png:/etc/ath/%s'", |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2791 | hs20_icon_filename); |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2792 | osu_icon = "icon_orange_zxx.png"; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2793 | break; |
| 2794 | case 6: |
| 2795 | case 106: |
| 2796 | owrt_ap_set_list_vap(dut, vap_id, "osu_friendly_name", |
| 2797 | "'eng:SP Green Test Only'"); |
| 2798 | owrt_ap_set_list_vap(dut, vap_id, "osu_friendly_name", |
| 2799 | "'kor:SP 초록 테스트 전용'"); |
| 2800 | |
| 2801 | hs20_icon_filename = "icon_green_zxx.png"; |
| 2802 | if (dut->ap_osu_icon_tag == 2) |
| 2803 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 2804 | |
| 2805 | snprintf(hs20_icon, sizeof(hs20_icon), |
| 2806 | "'128:61:zxx:image/png:icon_green_zxx.png:/etc/ath/%s'", |
| 2807 | hs20_icon_filename); |
| 2808 | owrt_ap_set_list_vap(dut, vap_id, "hs20_icon", |
| 2809 | hs20_icon); |
| 2810 | |
| 2811 | owrt_ap_set_list_vap(dut, vap_id, "osu_icon", |
| 2812 | "'icon_green_zxx.png'"); |
| 2813 | osu_method = (dut->ap_osu_method[0] == 0xFF) ? 0 : |
| 2814 | dut->ap_osu_method[0]; |
| 2815 | |
| 2816 | snprintf(buf, sizeof(buf), "%d", osu_method); |
| 2817 | owrt_ap_set_vap(dut, vap_id, "osu_method_list", buf); |
| 2818 | |
| 2819 | if (strlen(dut->ap_osu_server_uri[1])) |
| 2820 | owrt_ap_set_list_vap(dut, vap_id, |
| 2821 | "osu_server_uri", |
| 2822 | dut->ap_osu_server_uri[1]); |
| 2823 | else |
| 2824 | owrt_ap_set_list_vap(dut, vap_id, |
| 2825 | "osu_server_uri", |
| 2826 | "'https://osu-server.r2-testbed.wi-fi.org/'"); |
| 2827 | |
| 2828 | owrt_ap_set_list_vap(dut, vap_id, "osu_friendly_name", |
| 2829 | "'eng:SP Orange Test Only'"); |
| 2830 | |
| 2831 | hs20_icon_filename = "icon_orange_zxx.png"; |
| 2832 | if (dut->ap_osu_icon_tag == 2) |
| 2833 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 2834 | |
| 2835 | snprintf(hs20_icon, sizeof(hs20_icon), |
| 2836 | "'128:61:zxx:image/png:icon_orange_zxx.png:/etc/ath/%s'", |
| 2837 | hs20_icon_filename); |
| 2838 | |
| 2839 | osu_icon = "icon_orange_zxx.png"; |
| 2840 | osu_friendly_name = "'kor:SP 오렌지 테스트 전용'"; |
| 2841 | osu_method = (dut->ap_osu_method[1] == 0xFF) ? 0 : |
| 2842 | dut->ap_osu_method[1]; |
| 2843 | osu_service_desc = NULL; |
| 2844 | break; |
| 2845 | case 7: |
| 2846 | case 107: |
| 2847 | owrt_ap_set_list_vap(dut, vap_id, "osu_friendly_name", |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2848 | "'eng:SP Green Test Only'"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2849 | owrt_ap_set_list_vap(dut, vap_id, "osu_service_desc", |
| 2850 | "'eng:Free service for test purpose'"); |
| 2851 | |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2852 | hs20_icon_filename = "icon_green_eng.png"; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2853 | if (dut->ap_osu_icon_tag == 2) |
| 2854 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 2855 | |
| 2856 | snprintf(hs20_icon, sizeof(hs20_icon), |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2857 | "'160:76:eng:image/png:icon_green_eng.png:/etc/ath/%s'", |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2858 | hs20_icon_filename); |
| 2859 | owrt_ap_set_list_vap(dut, vap_id, "hs20_icon", |
| 2860 | hs20_icon); |
| 2861 | |
| 2862 | owrt_ap_set_list_vap(dut, vap_id, "osu_icon", |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2863 | "'icon_green_eng.png'"); |
Jouni Malinen | fd45ad5 | 2018-10-15 17:06:18 +0300 | [diff] [blame] | 2864 | osu_friendly_name = "'kor:SP 초록 테스트 전용'"; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2865 | |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2866 | hs20_icon_filename = "icon_green_zxx.png"; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2867 | if (dut->ap_osu_icon_tag == 2) |
| 2868 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 2869 | |
| 2870 | snprintf(hs20_icon, sizeof(hs20_icon), |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2871 | "'128:61:zxx:image/png:icon_green_zxx.png:/etc/ath/%s'", |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2872 | hs20_icon_filename); |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2873 | osu_icon = "icon_green_zxx.png"; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2874 | break; |
| 2875 | case 8: |
| 2876 | case 108: |
| 2877 | owrt_ap_set_list_vap(dut, vap_id, "osu_friendly_name", |
| 2878 | "'eng:SP Red Test Only'"); |
| 2879 | owrt_ap_set_list_vap(dut, vap_id, "osu_service_desc", |
| 2880 | "'eng:Free service for test purpose'"); |
| 2881 | osu_ssid = "OSU-Encrypted"; |
| 2882 | osu_nai = "'anonymous@hotspot.net'"; |
| 2883 | break; |
| 2884 | case 9: |
| 2885 | case 109: |
| 2886 | osu_ssid = "OSU-OSEN"; |
| 2887 | osu_nai = "'test-anonymous@wi-fi.org'"; |
| 2888 | osu_friendly_name = "'eng:SP Orange Test Only'"; |
| 2889 | hs20_icon_filename = "icon_orange_zxx.png"; |
| 2890 | if (dut->ap_osu_icon_tag == 2) |
| 2891 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 2892 | |
| 2893 | snprintf(hs20_icon, sizeof(hs20_icon), |
| 2894 | "'128:61:zxx:image/png:icon_orange_zxx.png:/etc/ath/%s'", |
| 2895 | hs20_icon_filename); |
| 2896 | osu_icon = "icon_orange_zxx.png"; |
| 2897 | osu_method = (dut->ap_osu_method[0] == 0xFF) ? 1 : |
| 2898 | dut->ap_osu_method[0]; |
| 2899 | osu_service_desc = NULL; |
| 2900 | break; |
| 2901 | default: |
| 2902 | break; |
| 2903 | } |
| 2904 | |
| 2905 | if (strlen(dut->ap_osu_ssid)) { |
Jouni Malinen | e6ac6a0 | 2018-09-11 02:40:17 +0300 | [diff] [blame] | 2906 | if (dut->ap_tag_ssid[0][0] && |
| 2907 | strcmp(dut->ap_tag_ssid[0], |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 2908 | dut->ap_osu_ssid) != 0 && |
| 2909 | strcmp(dut->ap_tag_ssid[0], osu_ssid) != 0) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2910 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 2911 | "OSU_SSID and WLAN_TAG2 SSID differ"); |
| 2912 | return -2; |
| 2913 | } |
| 2914 | |
| 2915 | snprintf(buf, sizeof(buf), "'\"%s\"'", |
| 2916 | dut->ap_osu_ssid); |
| 2917 | } else { |
| 2918 | snprintf(buf, sizeof(buf), "'\"%s\"'", osu_ssid); |
| 2919 | } |
| 2920 | |
| 2921 | owrt_ap_set_vap(dut, vap_id, "osu_ssid", buf); |
| 2922 | |
| 2923 | |
| 2924 | if (osu_friendly_name) |
| 2925 | owrt_ap_set_list_vap(dut, vap_id, "osu_friendly_name", |
| 2926 | osu_friendly_name); |
| 2927 | if (osu_service_desc) |
| 2928 | owrt_ap_set_list_vap(dut, vap_id, "osu_service_desc", |
| 2929 | osu_service_desc); |
| 2930 | if (osu_nai) |
| 2931 | owrt_ap_set_vap(dut, vap_id, "osu_nai", osu_nai); |
| 2932 | |
| 2933 | owrt_ap_set_list_vap(dut, vap_id, "hs20_icon", hs20_icon); |
| 2934 | |
| 2935 | if (osu_icon) |
| 2936 | owrt_ap_set_list_vap(dut, vap_id, "osu_icon", |
| 2937 | osu_icon); |
| 2938 | |
| 2939 | if (dut->ap_osu_provider_list > 100) { |
| 2940 | owrt_ap_set_list_vap(dut, vap_id, "osu_method_list", |
| 2941 | "0"); |
| 2942 | } else { |
| 2943 | snprintf(buf, sizeof(buf), "%d", osu_method); |
| 2944 | owrt_ap_set_list_vap(dut, vap_id, "osu_method_list", |
| 2945 | buf); |
| 2946 | } |
| 2947 | } |
| 2948 | |
| 2949 | return 0; |
| 2950 | } |
| 2951 | |
| 2952 | |
Jouni Malinen | 1370122 | 2019-02-19 12:10:53 +0200 | [diff] [blame] | 2953 | static int set_anqp_elem_value(struct sigma_dut *dut, const char *ifname, |
| 2954 | char *anqp_string, size_t str_size) |
Adil Saeed Musthafa | a8d7484 | 2017-04-10 23:13:39 -0700 | [diff] [blame] | 2955 | { |
| 2956 | unsigned char bssid[ETH_ALEN]; |
| 2957 | unsigned char dummy_mac[] = { 0x00, 0x10, 0x20, 0x30, 0x40, 0x50 }; |
| 2958 | int preference = 0xff; |
| 2959 | |
Jouni Malinen | 1370122 | 2019-02-19 12:10:53 +0200 | [diff] [blame] | 2960 | if (get_hwaddr(ifname, bssid) < 0) |
| 2961 | return -1; |
Adil Saeed Musthafa | a8d7484 | 2017-04-10 23:13:39 -0700 | [diff] [blame] | 2962 | snprintf(anqp_string, str_size, |
| 2963 | "272:3410%02x%02x%02x%02x%02x%02xf70000007330000301%02x3410%02x%02x%02x%02x%02x%02xf70000007330000301%02x", |
| 2964 | bssid[0], bssid[1], bssid[2], bssid[3], bssid[4], bssid[5], |
| 2965 | preference, |
| 2966 | dummy_mac[0], dummy_mac[1], dummy_mac[2], |
| 2967 | dummy_mac[3], dummy_mac[4], dummy_mac[5], |
| 2968 | preference - 1); |
Jouni Malinen | 1370122 | 2019-02-19 12:10:53 +0200 | [diff] [blame] | 2969 | return 0; |
Adil Saeed Musthafa | a8d7484 | 2017-04-10 23:13:39 -0700 | [diff] [blame] | 2970 | } |
| 2971 | |
| 2972 | |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 2973 | static void get_if_name(struct sigma_dut *dut, char *ifname_str, |
| 2974 | size_t str_size, int wlan_tag) |
| 2975 | { |
Jouni Malinen | f898464 | 2017-10-12 00:02:37 +0300 | [diff] [blame] | 2976 | const char *ifname; |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 2977 | enum driver_type drv; |
| 2978 | |
| 2979 | drv = get_driver_type(); |
Jouni Malinen | f898464 | 2017-10-12 00:02:37 +0300 | [diff] [blame] | 2980 | if (dut->hostapd_ifname && if_nametoindex(dut->hostapd_ifname) > 0) { |
| 2981 | ifname = dut->hostapd_ifname; |
| 2982 | } else if (drv == DRIVER_ATHEROS) { |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 2983 | if ((dut->ap_mode == AP_11a || dut->ap_mode == AP_11na || |
| 2984 | dut->ap_mode == AP_11ac) && |
| 2985 | if_nametoindex("ath1") > 0) |
| 2986 | ifname = "ath1"; |
| 2987 | else |
| 2988 | ifname = "ath0"; |
| 2989 | } else if (drv == DRIVER_OPENWRT) { |
| 2990 | if (sigma_radio_ifname[0] && |
| 2991 | strcmp(sigma_radio_ifname[0], "wifi2") == 0) |
| 2992 | ifname = "ath2"; |
| 2993 | else if (sigma_radio_ifname[0] && |
| 2994 | strcmp(sigma_radio_ifname[0], "wifi1") == 0) |
| 2995 | ifname = "ath1"; |
| 2996 | else |
| 2997 | ifname = "ath0"; |
Alexei Avshalom Lazar | 2712cc8 | 2018-12-23 16:29:14 +0200 | [diff] [blame] | 2998 | } else if (drv == DRIVER_WIL6210) { |
| 2999 | ifname = get_main_ifname(); |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 3000 | } else { |
| 3001 | if ((dut->ap_mode == AP_11a || dut->ap_mode == AP_11na || |
| 3002 | dut->ap_mode == AP_11ac) && |
| 3003 | if_nametoindex("wlan1") > 0) |
| 3004 | ifname = "wlan1"; |
| 3005 | else |
| 3006 | ifname = "wlan0"; |
| 3007 | } |
| 3008 | |
| 3009 | if (drv == DRIVER_OPENWRT && wlan_tag > 1) { |
| 3010 | /* Handle tagged-ifname only on OPENWRT for now */ |
| 3011 | snprintf(ifname_str, str_size, "%s%d", ifname, wlan_tag - 1); |
Liangwei Dong | 8357289 | 2019-01-10 13:51:48 +0800 | [diff] [blame] | 3012 | } else if ((drv == DRIVER_MAC80211 || drv == DRIVER_LINUX_WCN) && |
| 3013 | wlan_tag == 2) { |
Jouni Malinen | f898464 | 2017-10-12 00:02:37 +0300 | [diff] [blame] | 3014 | snprintf(ifname_str, str_size, "%s_1", ifname); |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 3015 | } else { |
| 3016 | snprintf(ifname_str, str_size, "%s", ifname); |
| 3017 | } |
| 3018 | } |
| 3019 | |
| 3020 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3021 | static int owrt_ap_config_vap(struct sigma_dut *dut) |
| 3022 | { |
| 3023 | char buf[256], *temp; |
Jouni Malinen | 3aa7286 | 2019-05-29 23:14:51 +0300 | [diff] [blame] | 3024 | int vap_id = 0, vap_count, i, j, res; |
priyadharshini gowthaman | 0454706 | 2018-01-15 11:59:55 -0800 | [diff] [blame] | 3025 | const char *ifname; |
| 3026 | char ifname2[50]; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3027 | |
priyadharshini gowthaman | 7356126 | 2018-02-20 13:24:59 -0800 | [diff] [blame] | 3028 | if (sigma_radio_ifname[0] && |
| 3029 | strcmp(sigma_radio_ifname[0], "wifi2") == 0) |
| 3030 | ifname = "ath2"; |
| 3031 | else if (sigma_radio_ifname[0] && |
| 3032 | strcmp(sigma_radio_ifname[0], "wifi1") == 0) |
| 3033 | ifname = "ath1"; |
| 3034 | else |
| 3035 | ifname = "ath0"; |
| 3036 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3037 | 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] | 3038 | snprintf(buf, sizeof(buf), "wifi%d", vap_count); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3039 | |
| 3040 | for (vap_id = 0; vap_id < MAX_RADIO; vap_id++) { |
| 3041 | if (sigma_radio_ifname[vap_id] && |
| 3042 | strcmp(sigma_radio_ifname[vap_id], buf) == 0) |
| 3043 | break; |
| 3044 | } |
| 3045 | if (vap_id == MAX_RADIO) |
| 3046 | continue; |
| 3047 | |
| 3048 | /* Single VAP configuration */ |
| 3049 | if (!dut->ap_is_dual) |
| 3050 | vap_id = vap_count; |
| 3051 | |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 3052 | for (j = 0; j < MAX_WLAN_TAGS - 1; j++) { |
| 3053 | /* |
| 3054 | * We keep a separate array of ap_tag_ssid and |
| 3055 | * ap_tag_key_mgmt for tags starting from WLAN_TAG=2. |
| 3056 | * So j=0 => WLAN_TAG = 2 |
| 3057 | */ |
| 3058 | int wlan_tag = j + 2; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3059 | |
priyadharshini gowthaman | 0e209fc | 2018-01-26 15:15:37 -0800 | [diff] [blame] | 3060 | if (wlan_tag == 2 && dut->program == PROGRAM_WPA3 && |
| 3061 | (dut->ap_interface_5g || dut->ap_interface_2g)) { |
Jouni Malinen | 3aa7286 | 2019-05-29 23:14:51 +0300 | [diff] [blame] | 3062 | res = snprintf( |
| 3063 | dut->ap_tag_ssid[wlan_tag - 2], |
| 3064 | sizeof(dut->ap_tag_ssid[wlan_tag - 2]), |
| 3065 | "%s-owe", dut->ap_ssid); |
| 3066 | if (res < 0 || |
| 3067 | res >= sizeof(dut->ap_tag_ssid[wlan_tag - |
| 3068 | 2])) |
| 3069 | dut->ap_tag_ssid[wlan_tag - 2][0] = |
| 3070 | '\0'; |
priyadharshini gowthaman | 0e209fc | 2018-01-26 15:15:37 -0800 | [diff] [blame] | 3071 | } |
| 3072 | |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 3073 | if (dut->ap_tag_ssid[j][0] == '\0') |
| 3074 | continue; |
| 3075 | |
| 3076 | snprintf(buf, sizeof(buf), "%s%d", "wifi", vap_count); |
| 3077 | owrt_ap_add_vap(dut, vap_count + (wlan_tag - 1), |
| 3078 | "device", buf); |
| 3079 | /* SSID */ |
| 3080 | snprintf(buf, sizeof(buf), "\"%s\"", |
| 3081 | dut->ap_tag_ssid[j]); |
| 3082 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), |
| 3083 | "ssid", buf); |
| 3084 | |
priyadharshini gowthaman | 0454706 | 2018-01-15 11:59:55 -0800 | [diff] [blame] | 3085 | if (dut->ap_key_mgmt == AP_WPA2_OWE && |
| 3086 | dut->ap_tag_ssid[0][0] && |
| 3087 | dut->ap_tag_key_mgmt[0] == AP2_OPEN) { |
| 3088 | /* OWE transition mode */ |
| 3089 | snprintf(buf, sizeof(buf), "%s", ifname); |
| 3090 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), |
| 3091 | "owe_transition_ifname", buf); |
| 3092 | } |
| 3093 | |
| 3094 | if (dut->ap_key_mgmt == AP_OPEN && |
| 3095 | dut->ap_tag_key_mgmt[0] == AP2_WPA2_OWE) { |
| 3096 | /* OWE transition mode */ |
| 3097 | snprintf(buf, sizeof(buf), "%s", ifname); |
| 3098 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), |
| 3099 | "owe_transition_ifname", buf); |
| 3100 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), |
| 3101 | "hidden", "1"); |
| 3102 | } |
| 3103 | |
Jouni Malinen | 6be21c8 | 2018-08-01 18:47:24 +0300 | [diff] [blame] | 3104 | if (ap_ft_enabled(dut)) { |
priyadharshini gowthaman | 47189f5 | 2017-12-28 12:37:46 -0800 | [diff] [blame] | 3105 | unsigned char self_mac[ETH_ALEN]; |
| 3106 | char mac_str[20]; |
| 3107 | |
| 3108 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), |
| 3109 | "mobility_domain", |
| 3110 | dut->ap_mobility_domain); |
| 3111 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), |
Jouni Malinen | 9f94331 | 2019-08-19 23:49:16 +0300 | [diff] [blame] | 3112 | "ft_over_ds", |
| 3113 | dut->ap_ft_ds == VALUE_ENABLED ? |
| 3114 | "1" : "0"); |
priyadharshini gowthaman | 47189f5 | 2017-12-28 12:37:46 -0800 | [diff] [blame] | 3115 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), |
| 3116 | "ieee80211r", "1"); |
| 3117 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), |
| 3118 | "nasid", "nas1.example.com"); |
Jouni Malinen | 1370122 | 2019-02-19 12:10:53 +0200 | [diff] [blame] | 3119 | if (get_hwaddr(sigma_radio_ifname[0], |
| 3120 | self_mac) < 0) |
| 3121 | return -1; |
priyadharshini gowthaman | 47189f5 | 2017-12-28 12:37:46 -0800 | [diff] [blame] | 3122 | snprintf(mac_str, sizeof(mac_str), |
| 3123 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 3124 | self_mac[0], self_mac[1], self_mac[2], |
| 3125 | self_mac[3], self_mac[4], self_mac[5]); |
| 3126 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), |
| 3127 | "ap_macaddr", mac_str); |
| 3128 | snprintf(mac_str, sizeof(mac_str), |
| 3129 | "%02x%02x%02x%02x%02x%02x", |
| 3130 | self_mac[0], self_mac[1], self_mac[2], |
| 3131 | self_mac[3], self_mac[4], self_mac[5]); |
| 3132 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), |
| 3133 | "r1_key_holder", mac_str); |
| 3134 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), |
| 3135 | "ft_psk_generate_local", "1"); |
| 3136 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), |
| 3137 | "kh_key_hex", |
| 3138 | "000102030405060708090a0b0c0d0e0f"); |
| 3139 | snprintf(mac_str, sizeof(mac_str), |
| 3140 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 3141 | dut->ft_bss_mac_list[0][0], |
| 3142 | dut->ft_bss_mac_list[0][1], |
| 3143 | dut->ft_bss_mac_list[0][2], |
| 3144 | dut->ft_bss_mac_list[0][3], |
| 3145 | dut->ft_bss_mac_list[0][4], |
| 3146 | dut->ft_bss_mac_list[0][5]); |
| 3147 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), |
| 3148 | "ap2_macaddr", mac_str); |
| 3149 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), |
| 3150 | "ap2_r1_key_holder", mac_str); |
| 3151 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), |
| 3152 | "nasid2", "nas2.example.com"); |
| 3153 | } |
| 3154 | |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 3155 | if (dut->ap_tag_key_mgmt[j] == AP2_OSEN && |
| 3156 | wlan_tag == 2) { |
| 3157 | /* Only supported for WLAN_TAG=2 */ |
| 3158 | owrt_ap_set_vap(dut, vap_count + 1, "osen", |
| 3159 | "1"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3160 | snprintf(buf, sizeof(buf), "wpa2"); |
| 3161 | owrt_ap_set_vap(dut, vap_count + 1, |
| 3162 | "encryption", buf); |
| 3163 | snprintf(buf, sizeof(buf), "%s", |
| 3164 | dut->ap2_radius_ipaddr); |
| 3165 | owrt_ap_set_vap(dut, vap_count + 1, |
| 3166 | "auth_server", buf); |
| 3167 | snprintf(buf, sizeof(buf), "%d", |
| 3168 | dut->ap2_radius_port); |
| 3169 | owrt_ap_set_vap(dut, vap_count + 1, |
| 3170 | "auth_port", buf); |
| 3171 | snprintf(buf, sizeof(buf), "%s", |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 3172 | dut->ap2_radius_password); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3173 | owrt_ap_set_vap(dut, vap_count + 1, |
| 3174 | "auth_secret", buf); |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 3175 | } else if (dut->ap_tag_key_mgmt[j] == AP2_WPA2_PSK) { |
| 3176 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), |
| 3177 | "encryption", "psk2+ccmp"); |
| 3178 | snprintf(buf, sizeof(buf), "\"%s\"", |
| 3179 | dut->ap_passphrase); |
| 3180 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), |
| 3181 | "key", buf); |
| 3182 | snprintf(buf, sizeof(buf), "%d", dut->ap_pmf); |
priyadharshini gowthaman | 47189f5 | 2017-12-28 12:37:46 -0800 | [diff] [blame] | 3183 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 3184 | "ieee80211w", buf); |
priyadharshini gowthaman | 0454706 | 2018-01-15 11:59:55 -0800 | [diff] [blame] | 3185 | } else if (dut->ap_tag_key_mgmt[0] == AP2_WPA2_OWE) { |
| 3186 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), |
| 3187 | "owe", "1"); |
| 3188 | snprintf(buf, sizeof(buf), "ccmp"); |
| 3189 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), |
| 3190 | "encryption", buf); |
| 3191 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), |
| 3192 | "ieee80211w", "2"); |
| 3193 | if (dut->ap_sae_groups) { |
| 3194 | snprintf(buf, sizeof(buf), "\'%s\'", |
| 3195 | dut->ap_sae_groups); |
priyadharshini gowthaman | b59bfe4 | 2018-08-30 15:14:08 -0700 | [diff] [blame] | 3196 | owrt_ap_set_list_vap(dut, vap_count + |
| 3197 | (wlan_tag - 1), |
| 3198 | "owe_groups", buf); |
priyadharshini gowthaman | 0454706 | 2018-01-15 11:59:55 -0800 | [diff] [blame] | 3199 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3200 | } |
| 3201 | } |
| 3202 | |
priyadharshini gowthaman | 47189f5 | 2017-12-28 12:37:46 -0800 | [diff] [blame] | 3203 | /* Now set anqp_elem and ft_oa for wlan_tag = 1 */ |
Adil Saeed Musthafa | a8d7484 | 2017-04-10 23:13:39 -0700 | [diff] [blame] | 3204 | if (dut->program == PROGRAM_MBO && |
| 3205 | get_driver_type() == DRIVER_OPENWRT) { |
priyadharshini gowthaman | 47189f5 | 2017-12-28 12:37:46 -0800 | [diff] [blame] | 3206 | unsigned char self_mac[ETH_ALEN]; |
| 3207 | char mac_str[20]; |
Adil Saeed Musthafa | a8d7484 | 2017-04-10 23:13:39 -0700 | [diff] [blame] | 3208 | char anqp_string[200]; |
| 3209 | |
Jouni Malinen | 1370122 | 2019-02-19 12:10:53 +0200 | [diff] [blame] | 3210 | if (set_anqp_elem_value(dut, sigma_radio_ifname[0], |
| 3211 | anqp_string, |
| 3212 | sizeof(anqp_string)) < 0) |
| 3213 | return -1; |
Adil Saeed Musthafa | a8d7484 | 2017-04-10 23:13:39 -0700 | [diff] [blame] | 3214 | owrt_ap_set_list_vap(dut, vap_count, "anqp_elem", |
| 3215 | anqp_string); |
priyadharshini gowthaman | 47189f5 | 2017-12-28 12:37:46 -0800 | [diff] [blame] | 3216 | |
Jouni Malinen | 6be21c8 | 2018-08-01 18:47:24 +0300 | [diff] [blame] | 3217 | if (ap_ft_enabled(dut)) { |
priyadharshini gowthaman | 47189f5 | 2017-12-28 12:37:46 -0800 | [diff] [blame] | 3218 | owrt_ap_set_vap(dut, vap_count, |
| 3219 | "mobility_domain", |
| 3220 | dut->ap_mobility_domain); |
| 3221 | owrt_ap_set_vap(dut, vap_count, |
Jouni Malinen | 9f94331 | 2019-08-19 23:49:16 +0300 | [diff] [blame] | 3222 | "ft_over_ds", |
| 3223 | dut->ap_ft_ds == VALUE_ENABLED ? |
| 3224 | "1" : "0"); |
priyadharshini gowthaman | 47189f5 | 2017-12-28 12:37:46 -0800 | [diff] [blame] | 3225 | owrt_ap_set_vap(dut, vap_count, |
| 3226 | "ieee80211r", "1"); |
| 3227 | owrt_ap_set_vap(dut, vap_count, |
| 3228 | "nasid", "nas1.example.com"); |
| 3229 | get_hwaddr(sigma_radio_ifname[0], self_mac); |
| 3230 | snprintf(mac_str, sizeof(mac_str), |
| 3231 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 3232 | self_mac[0], self_mac[1], self_mac[2], |
| 3233 | self_mac[3], self_mac[4], self_mac[5]); |
| 3234 | owrt_ap_set_vap(dut, vap_count, |
| 3235 | "ap_macaddr", mac_str); |
| 3236 | snprintf(mac_str, sizeof(mac_str), |
| 3237 | "%02x%02x%02x%02x%02x%02x", |
| 3238 | self_mac[0], self_mac[1], self_mac[2], |
| 3239 | self_mac[3], self_mac[4], self_mac[5]); |
| 3240 | owrt_ap_set_vap(dut, vap_count, |
| 3241 | "r1_key_holder", mac_str); |
| 3242 | owrt_ap_set_vap(dut, vap_count, |
| 3243 | "ft_psk_generate_local", "1"); |
| 3244 | owrt_ap_set_vap(dut, vap_count, |
| 3245 | "kh_key_hex", |
| 3246 | "000102030405060708090a0b0c0d0e0f"); |
| 3247 | snprintf(mac_str, sizeof(mac_str), |
| 3248 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 3249 | dut->ft_bss_mac_list[0][0], |
| 3250 | dut->ft_bss_mac_list[0][1], |
| 3251 | dut->ft_bss_mac_list[0][2], |
| 3252 | dut->ft_bss_mac_list[0][3], |
| 3253 | dut->ft_bss_mac_list[0][4], |
| 3254 | dut->ft_bss_mac_list[0][5]); |
| 3255 | owrt_ap_set_vap(dut, vap_count, |
| 3256 | "ap2_macaddr", mac_str); |
| 3257 | owrt_ap_set_vap(dut, vap_count, |
| 3258 | "ap2_r1_key_holder", mac_str); |
| 3259 | owrt_ap_set_vap(dut, vap_count, |
| 3260 | "nasid2", "nas2.example.com"); |
| 3261 | } |
Adil Saeed Musthafa | a8d7484 | 2017-04-10 23:13:39 -0700 | [diff] [blame] | 3262 | } |
| 3263 | |
priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 3264 | if (dut->ap_oce == VALUE_ENABLED && |
| 3265 | get_driver_type() == DRIVER_OPENWRT) { |
| 3266 | owrt_ap_set_vap(dut, vap_id, "oce", "1"); |
| 3267 | owrt_ap_set_vap(dut, vap_id, "qbssload", "1"); |
| 3268 | owrt_ap_set_vap(dut, vap_id, "bpr_enable", "1"); |
| 3269 | |
priyadharshini gowthaman | 63ab848 | 2017-12-28 15:32:55 -0800 | [diff] [blame] | 3270 | if (dut->ap_80plus80 == 1) |
| 3271 | owrt_ap_set_vap(dut, vap_id, "cfreq2", "5775"); |
| 3272 | |
priyadharshini gowthaman | de81f39 | 2017-12-28 15:28:49 -0800 | [diff] [blame] | 3273 | if (dut->ap_akm == 1) { |
| 3274 | owrt_ap_set_vap(dut, vap_id, "wpa_group_rekey", |
| 3275 | "3600"); |
| 3276 | owrt_ap_set_vap(dut, vap_id, "key", "12345678"); |
| 3277 | owrt_ap_set_vap(dut, vap_id, "ieee80211ai", |
| 3278 | "1"); |
| 3279 | owrt_ap_set_vap(dut, vap_id, "fils_cache_id", |
| 3280 | "1234"); |
| 3281 | owrt_ap_set_vap(dut, vap_id, |
| 3282 | "erp_send_reauth_start", "1"); |
| 3283 | } |
| 3284 | |
priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 3285 | if (dut->ap_filshlp == VALUE_ENABLED) { |
| 3286 | struct ifreq ifr; |
| 3287 | char *ifname; |
| 3288 | int s; |
| 3289 | struct sockaddr_in *ipaddr; |
| 3290 | |
| 3291 | s = socket(AF_INET, SOCK_DGRAM, 0); |
| 3292 | if (s < 0) { |
| 3293 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 3294 | "Failed to open socket"); |
| 3295 | return -1; |
| 3296 | } |
| 3297 | ifr.ifr_addr.sa_family = AF_INET; |
| 3298 | |
| 3299 | memset(&ifr, 0, sizeof(ifr)); |
| 3300 | ifname = "br-lan"; |
| 3301 | strlcpy(ifr.ifr_name, ifname, |
| 3302 | sizeof(ifr.ifr_name)); |
| 3303 | if (ioctl(s, SIOCGIFADDR, &ifr) < 0) { |
| 3304 | perror("ioctl"); |
| 3305 | close(s); |
| 3306 | return -1; |
| 3307 | } |
| 3308 | |
| 3309 | ipaddr = (struct sockaddr_in*)&ifr.ifr_addr; |
| 3310 | snprintf(buf, sizeof(buf), "%s", |
| 3311 | inet_ntoa(ipaddr->sin_addr)); |
| 3312 | owrt_ap_set_vap(dut, vap_id, "own_ip_addr", |
| 3313 | buf); |
| 3314 | snprintf(buf, sizeof(buf), "%s", |
| 3315 | dut->ap_dhcpserv_ipaddr); |
| 3316 | owrt_ap_set_vap(dut, vap_id, "dhcp_server", |
| 3317 | buf); |
| 3318 | owrt_ap_set_vap(dut, vap_id, |
| 3319 | "dhcp_rapid_commit_proxy", "1"); |
| 3320 | owrt_ap_set_vap(dut, vap_id, |
| 3321 | "fils_hlp_wait_time", "300"); |
| 3322 | } |
| 3323 | |
| 3324 | if (dut->ap_filsdscv == VALUE_ENABLED) { |
| 3325 | owrt_ap_set_vap(dut, vap_id, "ieee80211ai", |
| 3326 | "1"); |
| 3327 | owrt_ap_set_vap(dut, vap_id, "fils_fd_period", |
| 3328 | "20"); |
| 3329 | } |
| 3330 | } |
| 3331 | |
| 3332 | if (dut->ap_filsdscv == VALUE_DISABLED) { |
| 3333 | owrt_ap_set_vap(dut, vap_id, "ieee80211ai", "0"); |
| 3334 | owrt_ap_set_vap(dut, vap_id, "fils_fd_period", "0"); |
| 3335 | } |
| 3336 | |
| 3337 | if (dut->ap_oce == VALUE_DISABLED && |
| 3338 | get_driver_type() == DRIVER_OPENWRT) { |
| 3339 | owrt_ap_set_vap(dut, vap_id, "oce", "0"); |
| 3340 | owrt_ap_set_vap(dut, vap_id, "qbssload", "0"); |
| 3341 | owrt_ap_set_vap(dut, vap_id, "bpr_enable", "0"); |
| 3342 | |
| 3343 | if (dut->ap_filsdscv == VALUE_DISABLED) { |
| 3344 | owrt_ap_set_vap(dut, vap_id, "ieee80211ai", |
| 3345 | "0"); |
| 3346 | owrt_ap_set_vap(dut, vap_id, "fils_fd_period", |
| 3347 | "0"); |
| 3348 | } |
| 3349 | |
| 3350 | if (dut->device_type == AP_testbed) |
| 3351 | owrt_ap_set_vap(dut, vap_id, "mbo", "1"); |
| 3352 | } |
| 3353 | |
| 3354 | /* NAIRealm */ |
| 3355 | if (dut->ap_nairealm_int == 1) { |
| 3356 | snprintf(buf, sizeof(buf), "\"%s\"", dut->ap_nairealm); |
| 3357 | owrt_ap_set_vap(dut, vap_id, "fils_realm", buf); |
| 3358 | owrt_ap_set_vap(dut, vap_id, "erp_domain", buf); |
| 3359 | } |
| 3360 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3361 | /* SSID */ |
| 3362 | snprintf(buf, sizeof(buf), "\"%s\"", dut->ap_ssid); |
| 3363 | owrt_ap_set_vap(dut, vap_count, "ssid", buf); |
| 3364 | |
| 3365 | /* Encryption */ |
| 3366 | switch (dut->ap_key_mgmt) { |
| 3367 | case AP_OPEN: |
| 3368 | if (dut->ap_cipher == AP_WEP) { |
| 3369 | owrt_ap_set_vap(dut, vap_count, "encryption", |
| 3370 | "wep-mixed"); |
| 3371 | owrt_ap_set_vap(dut, vap_count, "key", |
| 3372 | dut->ap_wepkey); |
| 3373 | } else { |
| 3374 | owrt_ap_set_vap(dut, vap_count, "encryption", |
| 3375 | "none"); |
| 3376 | } |
priyadharshini gowthaman | 0454706 | 2018-01-15 11:59:55 -0800 | [diff] [blame] | 3377 | if (dut->ap_key_mgmt == AP_OPEN && |
| 3378 | dut->ap_tag_key_mgmt[0] == AP2_WPA2_OWE) { |
| 3379 | /* OWE transition mode */ |
| 3380 | snprintf(ifname2, sizeof(ifname2), "%s1", |
| 3381 | ifname); |
| 3382 | owrt_ap_set_vap(dut, vap_count, |
| 3383 | "owe_transition_ifname", |
| 3384 | ifname2); |
| 3385 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3386 | break; |
| 3387 | case AP_WPA2_PSK: |
| 3388 | case AP_WPA2_PSK_MIXED: |
| 3389 | case AP_WPA_PSK: |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 3390 | case AP_WPA2_SAE: |
| 3391 | case AP_WPA2_PSK_SAE: |
priyadharshini gowthaman | cce6ca0 | 2018-01-15 11:12:45 -0800 | [diff] [blame] | 3392 | if (dut->ap_key_mgmt == AP_WPA2_PSK || |
| 3393 | dut->ap_key_mgmt == AP_WPA2_PSK_SAE) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3394 | snprintf(buf, sizeof(buf), "psk2"); |
| 3395 | } else if (dut->ap_key_mgmt == AP_WPA2_PSK_MIXED) { |
| 3396 | snprintf(buf, sizeof(buf), "psk-mixed"); |
priyadharshini gowthaman | cce6ca0 | 2018-01-15 11:12:45 -0800 | [diff] [blame] | 3397 | } else if (dut->ap_key_mgmt == AP_WPA2_SAE) { |
| 3398 | snprintf(buf, sizeof(buf), "ccmp"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3399 | } else { |
| 3400 | snprintf(buf, sizeof(buf), "psk"); |
| 3401 | } |
| 3402 | |
priyadharshini gowthaman | cce6ca0 | 2018-01-15 11:12:45 -0800 | [diff] [blame] | 3403 | if (dut->ap_key_mgmt != AP_WPA2_SAE) { |
| 3404 | if (dut->ap_cipher == AP_CCMP_TKIP) |
| 3405 | strlcat(buf, "+ccmp+tkip", sizeof(buf)); |
| 3406 | else if (dut->ap_cipher == AP_TKIP) |
| 3407 | strlcat(buf, "+tkip", sizeof(buf)); |
Alexei Avshalom Lazar | 2712cc8 | 2018-12-23 16:29:14 +0200 | [diff] [blame] | 3408 | else if (dut->ap_cipher == AP_GCMP_128) |
| 3409 | strlcat(buf, "+gcmp", sizeof(buf)); |
priyadharshini gowthaman | cce6ca0 | 2018-01-15 11:12:45 -0800 | [diff] [blame] | 3410 | else |
| 3411 | strlcat(buf, "+ccmp", sizeof(buf)); |
| 3412 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3413 | |
| 3414 | owrt_ap_set_vap(dut, vap_count, "encryption", buf); |
priyadharshini gowthaman | cce6ca0 | 2018-01-15 11:12:45 -0800 | [diff] [blame] | 3415 | |
| 3416 | if (!dut->ap_passphrase[0] && dut->ap_psk[0]) { |
| 3417 | snprintf(buf, sizeof(buf), "\"%s\"", |
| 3418 | dut->ap_psk); |
| 3419 | owrt_ap_set_vap(dut, vap_count, "key", buf); |
| 3420 | } else { |
| 3421 | snprintf(buf, sizeof(buf), "\"%s\"", |
| 3422 | dut->ap_passphrase); |
| 3423 | owrt_ap_set_vap(dut, vap_count, "key", buf); |
| 3424 | } |
| 3425 | |
| 3426 | if (dut->ap_key_mgmt == AP_WPA2_SAE || |
| 3427 | dut->ap_key_mgmt == AP_WPA2_PSK_SAE) |
| 3428 | owrt_ap_set_vap(dut, vap_count, "sae", "1"); |
| 3429 | else |
| 3430 | owrt_ap_set_vap(dut, vap_count, "sae", "0"); |
| 3431 | |
| 3432 | if (dut->ap_key_mgmt == AP_WPA2_SAE) { |
| 3433 | snprintf(buf, sizeof(buf), "%s", |
| 3434 | dut->ap_passphrase); |
| 3435 | owrt_ap_set_vap(dut, vap_count, "sae_password", |
| 3436 | buf); |
| 3437 | } else { |
| 3438 | snprintf(buf, sizeof(buf), "%s", |
| 3439 | dut->ap_passphrase); |
| 3440 | owrt_ap_set_vap(dut, vap_count, |
| 3441 | "wpa_passphrase", buf); |
| 3442 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3443 | break; |
| 3444 | case AP_WPA2_EAP: |
| 3445 | case AP_WPA2_EAP_MIXED: |
| 3446 | case AP_WPA_EAP: |
| 3447 | if (dut->ap_key_mgmt == AP_WPA2_EAP) { |
| 3448 | snprintf(buf, sizeof(buf), "wpa2"); |
| 3449 | } else if (dut->ap_key_mgmt == AP_WPA2_EAP_MIXED) { |
| 3450 | snprintf(buf, sizeof(buf), "wpa-mixed"); |
| 3451 | } else { |
| 3452 | snprintf(buf, sizeof(buf), "wpa"); |
| 3453 | } |
| 3454 | |
Peng Xu | 591be45 | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 3455 | if (dut->ap_cipher == AP_CCMP_TKIP) |
| 3456 | strlcat(buf, "+ccmp+tkip", sizeof(buf)); |
| 3457 | else if (dut->ap_cipher == AP_TKIP) |
| 3458 | strlcat(buf, "+tkip", sizeof(buf)); |
| 3459 | else |
| 3460 | strlcat(buf, "+ccmp", sizeof(buf)); |
| 3461 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3462 | owrt_ap_set_vap(dut, vap_count, "encryption", buf); |
| 3463 | snprintf(buf, sizeof(buf), "%s", dut->ap_radius_ipaddr); |
| 3464 | owrt_ap_set_vap(dut, vap_count, "auth_server", buf); |
| 3465 | snprintf(buf, sizeof(buf), "%d", dut->ap_radius_port); |
| 3466 | owrt_ap_set_vap(dut, vap_count, "auth_port", buf); |
| 3467 | snprintf(buf, sizeof(buf), "%s", |
| 3468 | dut->ap_radius_password); |
| 3469 | owrt_ap_set_vap(dut, vap_count, "auth_secret", buf); |
| 3470 | break; |
Jouni Malinen | 4cf699f | 2018-06-19 00:46:27 +0300 | [diff] [blame] | 3471 | case AP_WPA2_EAP_OSEN: |
Jouni Malinen | c2b9121 | 2018-09-12 02:26:39 +0300 | [diff] [blame] | 3472 | case AP_OSEN: |
Jouni Malinen | 6be21c8 | 2018-08-01 18:47:24 +0300 | [diff] [blame] | 3473 | case AP_WPA2_FT_EAP: |
| 3474 | case AP_WPA2_FT_PSK: |
| 3475 | case AP_WPA2_EAP_SHA256: |
| 3476 | case AP_WPA2_PSK_SHA256: |
| 3477 | case AP_WPA2_ENT_FT_EAP: |
Jouni Malinen | 4cf699f | 2018-06-19 00:46:27 +0300 | [diff] [blame] | 3478 | /* TODO */ |
| 3479 | break; |
Jouni Malinen | ad395a2 | 2017-09-01 21:13:46 +0300 | [diff] [blame] | 3480 | case AP_SUITEB: |
priyadharshini gowthaman | 2136bd5 | 2018-01-15 11:28:55 -0800 | [diff] [blame] | 3481 | owrt_ap_set_vap(dut, vap_count, "suite_b", "192"); |
| 3482 | snprintf(buf, sizeof(buf), "gcmp"); |
| 3483 | owrt_ap_set_vap(dut, vap_count, "encryption", buf); |
| 3484 | snprintf(buf, sizeof(buf), "%s", dut->ap_radius_ipaddr); |
| 3485 | owrt_ap_set_vap(dut, vap_count, "auth_server", buf); |
| 3486 | snprintf(buf, sizeof(buf), "%d", dut->ap_radius_port); |
| 3487 | owrt_ap_set_vap(dut, vap_count, "auth_port", buf); |
| 3488 | snprintf(buf, sizeof(buf), "%s", |
| 3489 | dut->ap_radius_password); |
| 3490 | owrt_ap_set_vap(dut, vap_count, "auth_secret", buf); |
| 3491 | snprintf(buf, sizeof(buf), "%d", |
| 3492 | dut->ap_group_mgmt_cipher); |
| 3493 | owrt_ap_set_vap(dut, vap_count, "group_mgmt_cipher", |
| 3494 | buf); |
Jouni Malinen | ad395a2 | 2017-09-01 21:13:46 +0300 | [diff] [blame] | 3495 | break; |
Jouni Malinen | 147b3c3 | 2017-10-09 16:51:54 +0300 | [diff] [blame] | 3496 | case AP_WPA2_OWE: |
priyadharshini gowthaman | 0454706 | 2018-01-15 11:59:55 -0800 | [diff] [blame] | 3497 | owrt_ap_set_vap(dut, vap_count, "owe", "1"); |
| 3498 | snprintf(buf, sizeof(buf), "ccmp"); |
| 3499 | owrt_ap_set_vap(dut, vap_count, "encryption", buf); |
| 3500 | if (dut->ap_sae_groups) { |
| 3501 | snprintf(buf, sizeof(buf), "\'%s\'", |
| 3502 | dut->ap_sae_groups); |
priyadharshini gowthaman | b59bfe4 | 2018-08-30 15:14:08 -0700 | [diff] [blame] | 3503 | owrt_ap_set_list_vap(dut, vap_count, |
| 3504 | "owe_groups", buf); |
priyadharshini gowthaman | 0454706 | 2018-01-15 11:59:55 -0800 | [diff] [blame] | 3505 | } |
| 3506 | |
| 3507 | if (dut->ap_key_mgmt == AP_WPA2_OWE && |
| 3508 | dut->ap_tag_ssid[0][0] && |
| 3509 | dut->ap_tag_key_mgmt[0] == AP2_OPEN) { |
| 3510 | /* OWE transition mode */ |
| 3511 | snprintf(ifname2, sizeof(ifname2), "%s1", |
| 3512 | ifname); |
| 3513 | owrt_ap_set_vap(dut, vap_count, |
| 3514 | "owe_transition_ifname", |
| 3515 | ifname2); |
| 3516 | owrt_ap_set_vap(dut, vap_count, "hidden", "1"); |
| 3517 | } |
Jouni Malinen | 147b3c3 | 2017-10-09 16:51:54 +0300 | [diff] [blame] | 3518 | break; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3519 | } |
| 3520 | |
| 3521 | if (!dut->ap_is_dual) |
| 3522 | break; |
| 3523 | } |
| 3524 | |
| 3525 | if (dut->ap_is_dual) |
| 3526 | return 1; |
| 3527 | |
| 3528 | /* PMF */ |
| 3529 | snprintf(buf, sizeof(buf), "%d", dut->ap_pmf); |
| 3530 | owrt_ap_set_vap(dut, vap_id, "ieee80211w", buf); |
| 3531 | |
| 3532 | /* Add SHA256 */ |
| 3533 | snprintf(buf, sizeof(buf), "%d", dut->ap_add_sha256); |
| 3534 | owrt_ap_set_vap(dut, vap_id, "add_sha256", buf); |
| 3535 | |
priyadharshini gowthaman | de81f39 | 2017-12-28 15:28:49 -0800 | [diff] [blame] | 3536 | /* Add SHA384 for akmsuitetype 15 */ |
| 3537 | if (dut->ap_akm == 1) { |
| 3538 | snprintf(buf, sizeof(buf), "%d", dut->ap_add_sha384); |
| 3539 | owrt_ap_set_vap(dut, vap_id, "add_sha384", buf); |
| 3540 | } |
| 3541 | |
Sarvepalli, Rajesh Babu | 24dc7e4 | 2016-03-18 21:27:26 +0530 | [diff] [blame] | 3542 | /* Enable RSN preauthentication, if asked to */ |
| 3543 | snprintf(buf, sizeof(buf), "%d", dut->ap_rsn_preauth); |
| 3544 | owrt_ap_set_vap(dut, vap_id, "rsn_preauth", buf); |
| 3545 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3546 | /* Hotspot 2.0 */ |
| 3547 | if (dut->ap_hs2) { |
| 3548 | int ret; |
| 3549 | |
| 3550 | ret = owrt_ap_config_vap_hs2(dut, vap_id); |
| 3551 | if (ret) |
| 3552 | return ret; |
| 3553 | } |
| 3554 | |
| 3555 | /* Interworking */ |
| 3556 | if (dut->ap_interworking) { |
| 3557 | snprintf(buf, sizeof(buf), "%d", dut->ap_access_net_type); |
| 3558 | owrt_ap_set_vap(dut, vap_id, "access_network_type", buf); |
| 3559 | snprintf(buf, sizeof(buf), "%d", dut->ap_internet); |
| 3560 | owrt_ap_set_vap(dut, vap_id, "internet", buf); |
| 3561 | snprintf(buf, sizeof(buf), "%d", dut->ap_venue_group); |
| 3562 | owrt_ap_set_vap(dut, vap_id, "venue_group", buf); |
| 3563 | snprintf(buf, sizeof(buf), "%d", dut->ap_venue_type); |
| 3564 | owrt_ap_set_vap(dut, vap_id, "venue_type", buf); |
| 3565 | snprintf(buf, sizeof(buf), "%s", dut->ap_hessid); |
| 3566 | owrt_ap_set_vap(dut, vap_id, "hessid", buf); |
| 3567 | |
| 3568 | if (dut->ap_gas_cb_delay > 0) { |
| 3569 | snprintf(buf, sizeof(buf), "%d", dut->ap_gas_cb_delay); |
| 3570 | owrt_ap_set_vap(dut, vap_id, "gas_comeback_delay", buf); |
| 3571 | } |
| 3572 | |
| 3573 | if (dut->ap_roaming_cons[0]) { |
| 3574 | char *rcons, *temp_ptr; |
| 3575 | |
| 3576 | rcons = strdup(dut->ap_roaming_cons); |
| 3577 | if (rcons == NULL) |
Jouni Malinen | 1370122 | 2019-02-19 12:10:53 +0200 | [diff] [blame] | 3578 | return -1; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3579 | |
| 3580 | temp_ptr = strchr(rcons, ';'); |
| 3581 | |
| 3582 | if (temp_ptr) |
| 3583 | *temp_ptr++ = '\0'; |
| 3584 | |
| 3585 | owrt_ap_set_list_vap(dut, vap_id, "roaming_consortium", |
| 3586 | rcons); |
| 3587 | |
| 3588 | if (temp_ptr) |
| 3589 | owrt_ap_set_list_vap(dut, vap_id, |
| 3590 | "roaming_consortium", |
| 3591 | temp_ptr); |
| 3592 | |
| 3593 | free(rcons); |
| 3594 | } |
| 3595 | } |
| 3596 | |
| 3597 | if (dut->ap_venue_name) { |
| 3598 | owrt_ap_set_list_vap(dut, vap_id, "venue_name", |
| 3599 | "'P\"eng:Wi-Fi Alliance\\n2989 Copper Road\\nSanta Clara, CA 95051, USA\"'"); |
| 3600 | owrt_ap_set_list_vap(dut, vap_id, "venue_name", |
| 3601 | "\'"ANQP_VENUE_NAME_1_CHI"\'"); |
| 3602 | } |
| 3603 | |
| 3604 | if (dut->ap_net_auth_type == 1) { |
priyadharshini gowthaman | 9b8a8c3 | 2018-08-31 10:49:24 -0700 | [diff] [blame] | 3605 | owrt_ap_set_list_vap(dut, vap_id, "network_auth_type", |
| 3606 | "'00https://tandc-server.wi-fi.org'"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3607 | } else if (dut->ap_net_auth_type == 2) { |
priyadharshini gowthaman | 9b8a8c3 | 2018-08-31 10:49:24 -0700 | [diff] [blame] | 3608 | owrt_ap_set_list_vap(dut, vap_id, "network_auth_type", "'01'"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3609 | } |
| 3610 | |
| 3611 | if (dut->ap_nai_realm_list == 1) { |
| 3612 | owrt_ap_set_list_vap(dut, vap_id, "nai_realm", |
| 3613 | "'0,mail.example.com;cisco.com;wi-fi.org,21[2:4][5:7]'"); |
| 3614 | owrt_ap_set_list_vap(dut, vap_id, "nai_realm", |
| 3615 | "'0,wi-fi.org;example.com,13[5:6]'"); |
| 3616 | |
| 3617 | } else if (dut->ap_nai_realm_list == 2) { |
| 3618 | owrt_ap_set_list_vap(dut, vap_id, "nai_realm", |
| 3619 | "'0,wi-fi.org,21[2:4][5:7]'"); |
| 3620 | } else if (dut->ap_nai_realm_list == 3) { |
| 3621 | owrt_ap_set_list_vap(dut, vap_id, "nai_realm", |
| 3622 | "'0,cisco.com;wi-fi.org,21[2:4][5:7]'"); |
| 3623 | owrt_ap_set_list_vap(dut, vap_id, "nai_realm", |
| 3624 | "'0,wi-fi.org;example.com,13[5:6]'"); |
| 3625 | } else if (dut->ap_nai_realm_list == 4) { |
| 3626 | owrt_ap_set_list_vap(dut, vap_id, "nai_realm", |
| 3627 | "'0,mail.example.com,21[2:4][5:7],13[5:6]'"); |
| 3628 | } else if (dut->ap_nai_realm_list == 5) { |
| 3629 | owrt_ap_set_list_vap(dut, vap_id, "nai_realm", |
| 3630 | "'0,wi-fi.org;ruckuswireless.com,21[2:4][5:7]'"); |
| 3631 | } else if (dut->ap_nai_realm_list == 6) { |
| 3632 | owrt_ap_set_list_vap(dut, vap_id, "nai_realm", |
| 3633 | "'0,wi-fi.org;mail.example.com,21[2:4][5:7]'"); |
| 3634 | } else if (dut->ap_nai_realm_list == 7) { |
| 3635 | owrt_ap_set_list_vap(dut, vap_id, "nai_realm", |
| 3636 | "'0,wi-fi.org,13[5:6]'"); |
| 3637 | owrt_ap_set_list_vap(dut, vap_id, "nai_realm", |
| 3638 | "'0,wi-fi.org,21[2:4][5:7]'"); |
| 3639 | } |
| 3640 | |
| 3641 | if (dut->ap_domain_name_list[0]) |
| 3642 | owrt_ap_set_list_vap(dut, vap_id, "domain_name", |
| 3643 | dut->ap_domain_name_list); |
| 3644 | |
| 3645 | if (dut->ap_ip_addr_type_avail) |
| 3646 | owrt_ap_set_vap(dut, vap_id, "ipaddr_type_availability", |
| 3647 | "'0c'"); |
| 3648 | |
| 3649 | temp = buf; |
| 3650 | |
| 3651 | *temp++ = '\''; |
| 3652 | |
| 3653 | for (i = 0; dut->ap_plmn_mcc[i][0] && dut->ap_plmn_mnc[i][0]; i++) { |
| 3654 | if (i) |
| 3655 | *temp++ = ';'; |
| 3656 | |
| 3657 | snprintf(temp, |
| 3658 | sizeof(dut->ap_plmn_mcc[i]) + |
| 3659 | sizeof(dut->ap_plmn_mnc[i]) + 1, |
| 3660 | "%s,%s", |
| 3661 | dut->ap_plmn_mcc[i], |
| 3662 | dut->ap_plmn_mnc[i]); |
| 3663 | |
| 3664 | temp += strlen(dut->ap_plmn_mcc[i]) + |
| 3665 | strlen(dut->ap_plmn_mnc[i]) + 1; |
| 3666 | } |
| 3667 | |
| 3668 | *temp++ = '\''; |
| 3669 | *temp++ = '\0'; |
| 3670 | |
| 3671 | if (i) |
| 3672 | owrt_ap_set_vap(dut, vap_id, "anqp_3gpp_cell_net", buf); |
| 3673 | |
| 3674 | if (dut->ap_qos_map_set == 1) |
| 3675 | owrt_ap_set_vap(dut, vap_id, "qos_map_set", QOS_MAP_SET_1); |
| 3676 | else if (dut->ap_qos_map_set == 2) |
| 3677 | owrt_ap_set_vap(dut, vap_id, "qos_map_set", QOS_MAP_SET_2); |
| 3678 | |
| 3679 | /* Proxy-ARP */ |
| 3680 | snprintf(buf, sizeof(buf), "%d", dut->ap_proxy_arp); |
| 3681 | owrt_ap_set_vap(dut, vap_id, "proxyarp", buf); |
| 3682 | |
| 3683 | /* DGAF */ |
| 3684 | snprintf(buf, sizeof(buf), "%d", dut->ap_dgaf_disable); |
| 3685 | /* parse to hostapd */ |
| 3686 | owrt_ap_set_vap(dut, vap_id, "disable_dgaf", buf); |
| 3687 | /* parse to wifi driver */ |
| 3688 | owrt_ap_set_vap(dut, vap_id, "dgaf_disable", buf); |
| 3689 | |
| 3690 | /* HCBSSLoad */ |
| 3691 | if (dut->ap_bss_load) { |
| 3692 | unsigned int bssload = 0; |
| 3693 | |
| 3694 | if (dut->ap_bss_load == 1) { |
| 3695 | /* STA count: 1, CU: 50, AAC: 65535 */ |
| 3696 | bssload = 0x0132ffff; |
| 3697 | } else if (dut->ap_bss_load == 2) { |
| 3698 | /* STA count: 1, CU: 200, AAC: 65535 */ |
| 3699 | bssload = 0x01c8ffff; |
| 3700 | } else if (dut->ap_bss_load == 3) { |
| 3701 | /* STA count: 1, CU: 75, AAC: 65535 */ |
| 3702 | bssload = 0x014bffff; |
| 3703 | } |
| 3704 | |
| 3705 | snprintf(buf, sizeof(buf), "%d", bssload); |
| 3706 | owrt_ap_set_vap(dut, vap_id, "hcbssload", buf); |
| 3707 | } |
| 3708 | |
| 3709 | /* L2TIF */ |
| 3710 | if (dut->ap_l2tif) |
| 3711 | owrt_ap_set_vap(dut, vap_id, "l2tif", "1"); |
| 3712 | |
| 3713 | if (dut->ap_disable_protection == 1) |
| 3714 | owrt_ap_set_vap(dut, vap_id, "enablertscts", "0"); |
| 3715 | |
Sunil Dutt | 77b213d | 2017-09-14 18:24:40 +0300 | [diff] [blame] | 3716 | if (dut->ap_txBF) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3717 | owrt_ap_set_vap(dut, vap_id, "vhtsubfee", "1"); |
| 3718 | owrt_ap_set_vap(dut, vap_id, "vhtsubfer", "1"); |
| 3719 | } |
| 3720 | |
Mohammed Shafi Shajakhan | 061af00 | 2016-06-02 20:10:54 +0530 | [diff] [blame] | 3721 | if (dut->ap_mu_txBF) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3722 | owrt_ap_set_vap(dut, vap_id, "vhtmubfer", "1"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3723 | |
Vasanthakumar Pandurangan | 2b5431d | 2016-01-12 15:52:48 +0530 | [diff] [blame] | 3724 | if (dut->ap_tx_stbc) { |
| 3725 | /* STBC and beamforming are mutually exclusive features */ |
| 3726 | owrt_ap_set_vap(dut, vap_id, "implicitbf", "0"); |
| 3727 | } |
| 3728 | |
Priyadharshini Gowthaman | 8fb1504 | 2015-11-25 18:27:41 +0530 | [diff] [blame] | 3729 | /* enable dfsmode */ |
| 3730 | snprintf(buf, sizeof(buf), "%d", dut->ap_dfs_mode); |
| 3731 | owrt_ap_set_vap(dut, vap_id, "doth", buf); |
| 3732 | |
priyadharshini gowthaman | 2323d0a | 2016-09-02 15:48:02 -0700 | [diff] [blame] | 3733 | if (dut->program == PROGRAM_LOC && dut->ap_interworking) { |
| 3734 | char anqpval[1024]; |
| 3735 | |
| 3736 | owrt_ap_set_vap(dut, vap_id, "interworking", "1"); |
| 3737 | |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 3738 | 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] | 3739 | snprintf(anqpval, sizeof(anqpval), |
| 3740 | "'265:0010%s%s060101'", |
priyadharshini gowthaman | 2323d0a | 2016-09-02 15:48:02 -0700 | [diff] [blame] | 3741 | dut->ap_val_lci, dut->ap_infoz); |
| 3742 | owrt_ap_set_list_vap(dut, vap_id, "anqp_elem", anqpval); |
| 3743 | } |
| 3744 | |
| 3745 | if (dut->ap_lcr == 1) { |
Pradeep Reddy Potteti | b48012a | 2016-11-28 16:58:54 +0530 | [diff] [blame] | 3746 | snprintf(anqpval, sizeof(anqpval), |
| 3747 | "'266:0000b2555302ae%s'", |
priyadharshini gowthaman | 2323d0a | 2016-09-02 15:48:02 -0700 | [diff] [blame] | 3748 | dut->ap_val_lcr); |
| 3749 | owrt_ap_set_list_vap(dut, vap_id, "anqp_elem", anqpval); |
| 3750 | } |
| 3751 | |
| 3752 | if (dut->ap_fqdn_held == 1 && dut->ap_fqdn_supl == 1) |
| 3753 | owrt_ap_set_list_vap(dut, vap_id, "anqp_elem", |
| 3754 | "'267:00110168656c642e6578616d706c652e636f6d0011027375706c2e6578616d706c652e636f6d'"); |
| 3755 | } |
| 3756 | |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 3757 | if (dut->program == PROGRAM_MBO) { |
| 3758 | owrt_ap_set_vap(dut, vap_id, "interworking", "1"); |
| 3759 | owrt_ap_set_vap(dut, vap_id, "mbo", "1"); |
| 3760 | owrt_ap_set_vap(dut, vap_id, "rrm", "1"); |
Adil Saeed Musthafa | 65160c0 | 2017-04-10 23:13:38 -0700 | [diff] [blame] | 3761 | owrt_ap_set_vap(dut, vap_id, "mbo_cell_conn_pref", "1"); |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 3762 | |
| 3763 | owrt_ap_set_list_vap(dut, vap_id, "anqp_elem", |
| 3764 | "'272:34108cfdf0020df1f7000000733000030101'"); |
Adil Saeed Musthafa | ed5faae | 2017-04-10 23:13:36 -0700 | [diff] [blame] | 3765 | snprintf(buf, sizeof(buf), "%d", dut->ap_gas_cb_delay); |
| 3766 | owrt_ap_set_vap(dut, vap_id, "gas_comeback_delay", buf); |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 3767 | } |
| 3768 | |
Jouni Malinen | 6be21c8 | 2018-08-01 18:47:24 +0300 | [diff] [blame] | 3769 | if (ap_ft_enabled(dut)) { |
Adil Saeed Musthafa | 4ec61bd | 2017-04-10 23:13:41 -0700 | [diff] [blame] | 3770 | unsigned char self_mac[ETH_ALEN]; |
| 3771 | char mac_str[20]; |
| 3772 | |
Jouni Malinen | 9f94331 | 2019-08-19 23:49:16 +0300 | [diff] [blame] | 3773 | owrt_ap_set_vap(dut, vap_id, "ft_over_ds", |
| 3774 | dut->ap_ft_ds == VALUE_ENABLED ? "1" : "0"); |
Adil Saeed Musthafa | 4ec61bd | 2017-04-10 23:13:41 -0700 | [diff] [blame] | 3775 | owrt_ap_set_vap(dut, vap_id, "ieee80211r", "1"); |
Jouni Malinen | 1370122 | 2019-02-19 12:10:53 +0200 | [diff] [blame] | 3776 | if (get_hwaddr(sigma_radio_ifname[0], self_mac) < 0) |
| 3777 | return -1; |
Adil Saeed Musthafa | 4ec61bd | 2017-04-10 23:13:41 -0700 | [diff] [blame] | 3778 | snprintf(mac_str, sizeof(mac_str), |
| 3779 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 3780 | self_mac[0], self_mac[1], self_mac[2], |
| 3781 | self_mac[3], self_mac[4], self_mac[5]); |
| 3782 | owrt_ap_set_vap(dut, vap_id, "ap_macaddr", mac_str); |
priyadharshini gowthaman | 47189f5 | 2017-12-28 12:37:46 -0800 | [diff] [blame] | 3783 | snprintf(mac_str, sizeof(mac_str), |
| 3784 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 3785 | self_mac[0], self_mac[1], self_mac[2], |
| 3786 | self_mac[3], self_mac[4], self_mac[5]); |
| 3787 | 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] | 3788 | owrt_ap_set_vap(dut, vap_id, "ft_psk_generate_local", "1"); |
| 3789 | owrt_ap_set_vap(dut, vap_id, "kh_key_hex", |
| 3790 | "000102030405060708090a0b0c0d0e0f"); |
| 3791 | snprintf(mac_str, sizeof(mac_str), |
| 3792 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 3793 | dut->ft_bss_mac_list[0][0], |
| 3794 | dut->ft_bss_mac_list[0][1], |
| 3795 | dut->ft_bss_mac_list[0][2], |
| 3796 | dut->ft_bss_mac_list[0][3], |
| 3797 | dut->ft_bss_mac_list[0][4], |
| 3798 | dut->ft_bss_mac_list[0][5]); |
| 3799 | owrt_ap_set_vap(dut, vap_id, "ap2_macaddr", mac_str); |
priyadharshini gowthaman | 47189f5 | 2017-12-28 12:37:46 -0800 | [diff] [blame] | 3800 | owrt_ap_set_vap(dut, vap_id, "mobility_domain", |
| 3801 | dut->ap_mobility_domain); |
| 3802 | 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] | 3803 | } |
| 3804 | |
Jouni Malinen | 6be21c8 | 2018-08-01 18:47:24 +0300 | [diff] [blame] | 3805 | if ((ap_ft_enabled(dut) && dut->ap_name == 0) || |
| 3806 | (ap_ft_enabled(dut) && dut->ap_name == 2)) { |
Adil Saeed Musthafa | 4ec61bd | 2017-04-10 23:13:41 -0700 | [diff] [blame] | 3807 | owrt_ap_set_vap(dut, vap_id, "nasid2", "nas2.example.com"); |
| 3808 | owrt_ap_set_vap(dut, vap_id, "nasid", "nas1.example.com"); |
Adil Saeed Musthafa | 4ec61bd | 2017-04-10 23:13:41 -0700 | [diff] [blame] | 3809 | } |
| 3810 | |
Jouni Malinen | 6be21c8 | 2018-08-01 18:47:24 +0300 | [diff] [blame] | 3811 | if (ap_ft_enabled(dut) && dut->ap_name == 1) { |
Adil Saeed Musthafa | 4ec61bd | 2017-04-10 23:13:41 -0700 | [diff] [blame] | 3812 | owrt_ap_set_vap(dut, vap_id, "nasid2", "nas1.example.com"); |
| 3813 | owrt_ap_set_vap(dut, vap_id, "nasid", "nas2.example.com"); |
Adil Saeed Musthafa | 4ec61bd | 2017-04-10 23:13:41 -0700 | [diff] [blame] | 3814 | } |
| 3815 | |
priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 3816 | if (dut->ap_broadcast_ssid == VALUE_DISABLED) |
| 3817 | owrt_ap_set_vap(dut, vap_id, "hidden", "1"); |
| 3818 | |
priyadharshini gowthaman | de81f39 | 2017-12-28 15:28:49 -0800 | [diff] [blame] | 3819 | /* Enable/disable PMKSA caching, if asked to */ |
| 3820 | if (dut->ap_pmksa == 1) { |
| 3821 | snprintf(buf, sizeof(buf), "%d", dut->ap_pmksa_caching); |
| 3822 | owrt_ap_set_vap(dut, vap_id, "disable_pmksa_caching", buf); |
| 3823 | } |
| 3824 | |
priyadharshini gowthaman | cce6ca0 | 2018-01-15 11:12:45 -0800 | [diff] [blame] | 3825 | if (dut->rsne_override) { |
| 3826 | snprintf(buf, sizeof(buf), "%s", dut->rsne_override); |
| 3827 | owrt_ap_set_vap(dut, vap_count, "own_ie_override", buf); |
| 3828 | } |
| 3829 | |
| 3830 | if (dut->sae_commit_override) { |
| 3831 | snprintf(buf, sizeof(buf), "%s", dut->sae_commit_override); |
| 3832 | owrt_ap_set_vap(dut, vap_count, "sae_commit_override", buf); |
| 3833 | } |
| 3834 | |
| 3835 | if (dut->ap_sae_groups) { |
| 3836 | snprintf(buf, sizeof(buf), "\'%s\'", dut->ap_sae_groups); |
priyadharshini gowthaman | b59bfe4 | 2018-08-30 15:14:08 -0700 | [diff] [blame] | 3837 | owrt_ap_set_list_vap(dut, vap_count, "sae_groups", buf); |
priyadharshini gowthaman | cce6ca0 | 2018-01-15 11:12:45 -0800 | [diff] [blame] | 3838 | } |
| 3839 | |
| 3840 | if (dut->sae_anti_clogging_threshold >= 0) { |
| 3841 | snprintf(buf, sizeof(buf), "%d", |
| 3842 | dut->sae_anti_clogging_threshold); |
| 3843 | owrt_ap_set_vap(dut, vap_count, "sae_anti_clogging_threshold", |
| 3844 | buf); |
| 3845 | } |
| 3846 | |
| 3847 | if (dut->sae_reflection) |
| 3848 | owrt_ap_set_vap(dut, vap_count, "sae_reflection_attack", "1"); |
Jouni Malinen | 3c740ab | 2019-10-10 15:55:11 +0300 | [diff] [blame] | 3849 | if (dut->sae_confirm_immediate) |
| 3850 | owrt_ap_set_vap(dut, vap_count, "sae_confirm_immediate", "1"); |
priyadharshini gowthaman | cce6ca0 | 2018-01-15 11:12:45 -0800 | [diff] [blame] | 3851 | |
Priyadharshini Gowthaman | fe60c50 | 2019-08-14 13:00:34 -0700 | [diff] [blame] | 3852 | if (dut->program == PROGRAM_HE && |
| 3853 | (dut->ap_txBF || dut->ap_he_ulofdma == VALUE_ENABLED)) { |
| 3854 | switch (dut->ap_chwidth) { |
| 3855 | case AP_20: |
| 3856 | owrt_ap_set_vap(dut, vap_id, "chwidth", "0"); |
| 3857 | break; |
| 3858 | case AP_40: |
| 3859 | owrt_ap_set_vap(dut, vap_id, "chwidth", "1"); |
| 3860 | break; |
| 3861 | case AP_80: |
| 3862 | owrt_ap_set_vap(dut, vap_id, "chwidth", "2"); |
| 3863 | break; |
| 3864 | case AP_160: |
| 3865 | owrt_ap_set_vap(dut, vap_id, "chwidth", "3"); |
| 3866 | break; |
| 3867 | case AP_80_80: |
| 3868 | owrt_ap_set_vap(dut, vap_id, "chwidth", "3"); |
| 3869 | break; |
| 3870 | case AP_AUTO: |
| 3871 | break; |
| 3872 | } |
| 3873 | } |
| 3874 | |
| 3875 | if (dut->ap_he_dlofdma == VALUE_ENABLED && dut->ap_he_ppdu == PPDU_MU) { |
| 3876 | dut->ap_txBF = 0; |
| 3877 | dut->ap_mu_txBF = 0; |
| 3878 | owrt_ap_set_vap(dut, vap_id, "vhtsubfer", "0"); |
| 3879 | owrt_ap_set_vap(dut, vap_id, "vhtsubfee", "0"); |
| 3880 | owrt_ap_set_vap(dut, vap_id, "he_subfer", "0"); |
| 3881 | } |
| 3882 | |
Priyadharshini Gowthaman | dee79e2 | 2019-10-07 16:56:27 -0700 | [diff] [blame] | 3883 | if (dut->program == PROGRAM_HE && |
| 3884 | (dut->ap_txBF || dut->ap_he_ulofdma == VALUE_ENABLED || |
| 3885 | dut->ap_he_mimo == MIMO_DL)) { |
| 3886 | switch (dut->ap_chwidth) { |
| 3887 | case AP_20: |
| 3888 | owrt_ap_set_vap(dut, vap_id, "chwidth", "0"); |
| 3889 | break; |
| 3890 | case AP_40: |
| 3891 | owrt_ap_set_vap(dut, vap_id, "chwidth", "1"); |
| 3892 | break; |
| 3893 | case AP_80: |
| 3894 | owrt_ap_set_vap(dut, vap_id, "chwidth", "2"); |
| 3895 | break; |
| 3896 | case AP_160: |
| 3897 | owrt_ap_set_vap(dut, vap_id, "chwidth", "3"); |
| 3898 | break; |
| 3899 | case AP_80_80: |
| 3900 | owrt_ap_set_vap(dut, vap_id, "chwidth", "3"); |
| 3901 | break; |
| 3902 | case AP_AUTO: |
| 3903 | default: |
| 3904 | break; |
| 3905 | } |
| 3906 | } |
| 3907 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3908 | return 1; |
| 3909 | } |
| 3910 | |
| 3911 | |
priyadharshini gowthaman | 2500f20 | 2016-10-13 17:13:55 -0700 | [diff] [blame] | 3912 | static int owrt_ap_config_vap_anqp(struct sigma_dut *dut) |
| 3913 | { |
| 3914 | char anqpval[1024]; |
| 3915 | unsigned char addr[6]; |
| 3916 | unsigned char addr2[6]; |
| 3917 | struct ifreq ifr; |
| 3918 | char *ifname; |
| 3919 | int s; |
| 3920 | int vap_id = 0; |
| 3921 | |
| 3922 | s = socket(AF_INET, SOCK_DGRAM, 0); |
| 3923 | if (s < 0) { |
| 3924 | sigma_dut_print(dut, DUT_MSG_ERROR, "Failed to open socket"); |
| 3925 | return -1; |
| 3926 | } |
| 3927 | |
| 3928 | memset(&ifr, 0, sizeof(ifr)); |
| 3929 | ifname = "ath0"; |
Peng Xu | b8fc5cc | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 3930 | strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name)); |
priyadharshini gowthaman | 2500f20 | 2016-10-13 17:13:55 -0700 | [diff] [blame] | 3931 | if (ioctl(s, SIOCGIFHWADDR, &ifr) < 0) { |
| 3932 | perror("ioctl"); |
| 3933 | close(s); |
| 3934 | return -1; |
| 3935 | } |
| 3936 | memcpy(addr, ifr.ifr_hwaddr.sa_data, 6); |
| 3937 | |
| 3938 | memset(&ifr, 0, sizeof(ifr)); |
| 3939 | ifname = "ath01"; |
Peng Xu | b8fc5cc | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 3940 | strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name)); |
priyadharshini gowthaman | 2500f20 | 2016-10-13 17:13:55 -0700 | [diff] [blame] | 3941 | if (ioctl(s, SIOCGIFHWADDR, &ifr) < 0) { |
| 3942 | perror("ioctl"); |
| 3943 | close(s); |
| 3944 | return -1; |
| 3945 | } |
| 3946 | close(s); |
| 3947 | memcpy(addr2, ifr.ifr_hwaddr.sa_data, 6); |
| 3948 | |
| 3949 | snprintf(anqpval, sizeof(anqpval), |
| 3950 | "'265:0010%s%s060101070d00%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x'", |
| 3951 | dut->ap_val_lci, dut->ap_infoz, |
| 3952 | addr[0], addr[1], addr[2], addr[3], addr[4], addr[5], |
| 3953 | addr2[0], addr2[1], addr2[2], addr2[3], addr2[4], addr2[5]); |
| 3954 | |
| 3955 | owrt_ap_set_list_vap(dut, vap_id, "anqp_elem", anqpval); |
| 3956 | return 0; |
| 3957 | } |
| 3958 | |
| 3959 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3960 | static int owrt_ap_post_config_commit(struct sigma_dut *dut, |
| 3961 | struct sigma_conn *conn, |
| 3962 | struct sigma_cmd *cmd) |
| 3963 | { |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 3964 | int ap_security = 0; |
| 3965 | int i; |
| 3966 | |
| 3967 | for (i = 0; i < MAX_WLAN_TAGS - 1; i++) { |
| 3968 | if (dut->ap_tag_key_mgmt[i] != AP2_OPEN) |
| 3969 | ap_security = 1; |
| 3970 | } |
| 3971 | if (dut->ap_key_mgmt != AP_OPEN) |
| 3972 | ap_security = 1; |
| 3973 | if (ap_security) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3974 | /* allow some time for hostapd to start before returning |
| 3975 | * success */ |
| 3976 | usleep(500000); |
| 3977 | |
| 3978 | if (run_hostapd_cli(dut, "ping") != 0) { |
| 3979 | send_resp(dut, conn, SIGMA_ERROR, |
| 3980 | "errorCode,Failed to talk to hostapd"); |
| 3981 | return 0; |
| 3982 | } |
| 3983 | } |
| 3984 | |
| 3985 | if (get_openwrt_driver_type() == OPENWRT_DRIVER_ATHEROS) |
| 3986 | ath_ap_set_params(dut); |
| 3987 | |
| 3988 | /* Send response */ |
| 3989 | return 1; |
| 3990 | } |
| 3991 | |
| 3992 | |
| 3993 | static int cmd_owrt_ap_config_commit(struct sigma_dut *dut, |
| 3994 | struct sigma_conn *conn, |
| 3995 | struct sigma_cmd *cmd) |
| 3996 | { |
priyadharshini gowthaman | b4de196 | 2018-01-15 12:21:04 -0800 | [diff] [blame] | 3997 | if (dut->program == PROGRAM_DPP && |
| 3998 | get_driver_type() == DRIVER_OPENWRT) { |
| 3999 | wpa_command(dut->hostapd_ifname, "DPP_BOOTSTRAP_REMOVE *"); |
| 4000 | wpa_command(dut->hostapd_ifname, "DPP_PKEX_REMOVE *"); |
| 4001 | } |
| 4002 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4003 | /* Stop the AP */ |
| 4004 | run_system(dut, "wifi down"); |
| 4005 | |
| 4006 | /* Reset the wireless configuration */ |
Mohammed Shafi Shajakhan | f789f82 | 2016-04-07 18:53:16 +0530 | [diff] [blame] | 4007 | run_system(dut, "rm -rf /etc/config/wireless"); |
| 4008 | switch (get_openwrt_driver_type()) { |
| 4009 | case OPENWRT_DRIVER_ATHEROS: |
| 4010 | run_system(dut, "wifi detect qcawifi > /etc/config/wireless"); |
| 4011 | break; |
| 4012 | default: |
| 4013 | run_system(dut, "wifi detect > /etc/config/wireless"); |
| 4014 | break; |
| 4015 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4016 | |
| 4017 | /* Configure Radio & VAP, commit the config */ |
| 4018 | owrt_ap_config_radio(dut); |
Jouni Malinen | 1370122 | 2019-02-19 12:10:53 +0200 | [diff] [blame] | 4019 | if (owrt_ap_config_vap(dut) < 0) |
| 4020 | return ERROR_SEND_STATUS; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4021 | run_system(dut, "uci commit"); |
| 4022 | |
| 4023 | /* Start AP */ |
| 4024 | run_system(dut, "wifi up"); |
Adil Saeed Musthafa | a8d7484 | 2017-04-10 23:13:39 -0700 | [diff] [blame] | 4025 | if (dut->program != PROGRAM_MBO && |
| 4026 | dut->ap_lci == 1 && dut->ap_interworking && |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 4027 | strlen(dut->ap_tag_ssid[0]) > 0) { |
Adil Saeed Musthafa | a8d7484 | 2017-04-10 23:13:39 -0700 | [diff] [blame] | 4028 | /* |
| 4029 | * MBO has a different ANQP element value which is set in |
| 4030 | * owrt_ap_config_vap(). |
| 4031 | */ |
priyadharshini gowthaman | 2500f20 | 2016-10-13 17:13:55 -0700 | [diff] [blame] | 4032 | owrt_ap_config_vap_anqp(dut); |
| 4033 | run_system(dut, "uci commit"); |
| 4034 | run_system(dut, "wifi"); |
| 4035 | } |
| 4036 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4037 | return owrt_ap_post_config_commit(dut, conn, cmd); |
| 4038 | } |
| 4039 | |
| 4040 | |
| 4041 | static void cmd_owrt_ap_hs2_reset(struct sigma_dut *dut) |
| 4042 | { |
| 4043 | unsigned char bssid[6]; |
| 4044 | char buf[100]; |
| 4045 | char *ifname, *radio_name; |
| 4046 | int vap_id = 0; |
| 4047 | |
| 4048 | if (sigma_radio_ifname[0] && |
| 4049 | strcmp(sigma_radio_ifname[0], "wifi2") == 0) { |
| 4050 | ifname = "ath2"; |
| 4051 | radio_name = "wifi2"; |
| 4052 | vap_id = 2; |
| 4053 | } else if (sigma_radio_ifname[0] && |
| 4054 | strcmp(sigma_radio_ifname[0], "wifi1") == 0) { |
| 4055 | ifname = "ath1"; |
| 4056 | radio_name = "wifi1"; |
| 4057 | vap_id = 1; |
| 4058 | } else { |
| 4059 | ifname = "ath0"; |
| 4060 | radio_name = "wifi0"; |
| 4061 | vap_id = 0; |
| 4062 | } |
| 4063 | |
| 4064 | if (!get_hwaddr(ifname, bssid)) { |
| 4065 | snprintf(buf, sizeof(buf), "%s", bssid); |
| 4066 | owrt_ap_set_vap(dut, vap_id, "hessid", buf); |
| 4067 | snprintf(dut->ap_hessid, sizeof(dut->ap_hessid), |
| 4068 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 4069 | bssid[0], bssid[1], bssid[2], bssid[3], |
| 4070 | bssid[4], bssid[5]); |
| 4071 | } else { |
| 4072 | if (!get_hwaddr(radio_name, bssid)) { |
| 4073 | snprintf(buf, sizeof(buf), "%s", dut->ap_hessid); |
| 4074 | owrt_ap_set_vap(dut, vap_id, "hessid", buf); |
| 4075 | snprintf(dut->ap_hessid, sizeof(dut->ap_hessid), |
| 4076 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 4077 | bssid[0], bssid[1], bssid[2], bssid[3], |
| 4078 | bssid[4], bssid[5]); |
| 4079 | } else { |
| 4080 | /* Select & enable/disable radios */ |
| 4081 | if (sigma_radio_ifname[0] && |
| 4082 | strcmp(sigma_radio_ifname[0], "wifi2") == 0) { |
| 4083 | /* We want to use wifi2 */ |
| 4084 | owrt_ap_set_radio(dut, 0, "disabled", "1"); |
| 4085 | owrt_ap_set_radio(dut, 1, "disabled", "1"); |
| 4086 | owrt_ap_set_radio(dut, 2, "disabled", "0"); |
| 4087 | owrt_ap_set_vap(dut, vap_id, "device", "wifi2"); |
| 4088 | } else if (sigma_radio_ifname[0] && |
| 4089 | strcmp(sigma_radio_ifname[0], "wifi1") == 0) { |
| 4090 | /* We want to use wifi1 */ |
| 4091 | owrt_ap_set_radio(dut, 0, "disabled", "1"); |
| 4092 | owrt_ap_set_radio(dut, 1, "disabled", "0"); |
| 4093 | owrt_ap_set_vap(dut, vap_id, "device", "wifi1"); |
| 4094 | } else { |
| 4095 | /* We want to use wifi0 */ |
| 4096 | owrt_ap_set_radio(dut, 0, "disabled", "0"); |
| 4097 | owrt_ap_set_radio(dut, 1, "disabled", "1"); |
| 4098 | owrt_ap_set_vap(dut, vap_id, "device", "wifi0"); |
| 4099 | } |
| 4100 | |
| 4101 | run_system(dut, "uci commit"); |
| 4102 | run_system(dut, "wifi up"); |
| 4103 | |
| 4104 | if (!get_hwaddr(radio_name, bssid)) { |
| 4105 | snprintf(buf, sizeof(buf), "%s", |
| 4106 | dut->ap_hessid); |
| 4107 | owrt_ap_set_vap(dut, vap_id, "hessid", buf); |
| 4108 | snprintf(dut->ap_hessid, sizeof(dut->ap_hessid), |
| 4109 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 4110 | bssid[0], bssid[1], bssid[2], bssid[3], |
| 4111 | bssid[4], bssid[5]); |
| 4112 | } |
| 4113 | } |
| 4114 | } |
| 4115 | } |
| 4116 | |
| 4117 | |
Jouni Malinen | f722271 | 2019-06-13 01:50:21 +0300 | [diff] [blame] | 4118 | static enum sigma_cmd_result cmd_ap_reboot(struct sigma_dut *dut, |
| 4119 | struct sigma_conn *conn, |
| 4120 | struct sigma_cmd *cmd) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4121 | { |
| 4122 | switch (get_driver_type()) { |
| 4123 | case DRIVER_ATHEROS: |
| 4124 | run_system(dut, "apdown"); |
| 4125 | sleep(1); |
| 4126 | run_system(dut, "reboot"); |
| 4127 | break; |
| 4128 | case DRIVER_OPENWRT: |
| 4129 | run_system(dut, "wifi down"); |
| 4130 | sleep(1); |
| 4131 | run_system(dut, "reboot"); |
| 4132 | break; |
| 4133 | default: |
| 4134 | sigma_dut_print(dut, DUT_MSG_INFO, "Ignore ap_reboot command"); |
| 4135 | break; |
| 4136 | } |
| 4137 | |
| 4138 | return 1; |
| 4139 | } |
| 4140 | |
| 4141 | |
| 4142 | int ascii2hexstr(const char *str, char *hex) |
| 4143 | { |
| 4144 | int i, length; |
| 4145 | |
| 4146 | length = strlen(str); |
| 4147 | |
| 4148 | for (i = 0; i < length; i++) |
| 4149 | snprintf(hex + i * 2, 3, "%X", str[i]); |
| 4150 | |
| 4151 | hex[length * 2] = '\0'; |
| 4152 | return 1; |
| 4153 | } |
| 4154 | |
| 4155 | |
| 4156 | static int kill_process(struct sigma_dut *dut, char *proc_name, |
| 4157 | unsigned char is_proc_instance_one, int sig) |
| 4158 | { |
| 4159 | #ifdef __linux__ |
| 4160 | struct dirent *dp, *dp_in; |
| 4161 | const char *direc = "/proc/"; |
| 4162 | char buf[100]; |
| 4163 | DIR *dir = opendir(direc); |
| 4164 | DIR *dir_in; |
| 4165 | FILE *fp; |
| 4166 | char *pid, *temp; |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 4167 | char *saveptr; |
Jouni Malinen | 3aa7286 | 2019-05-29 23:14:51 +0300 | [diff] [blame] | 4168 | int ret = -1, res; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4169 | |
| 4170 | if (dir == NULL) |
Pradeep Reddy Potteti | d068e64 | 2017-02-17 20:03:12 +0530 | [diff] [blame] | 4171 | return ret; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4172 | |
| 4173 | while ((dp = readdir(dir)) != NULL) { |
| 4174 | if (dp->d_type != DT_DIR) |
| 4175 | continue; |
| 4176 | |
Jouni Malinen | 3aa7286 | 2019-05-29 23:14:51 +0300 | [diff] [blame] | 4177 | res = snprintf(buf, sizeof(buf), "%s%s", direc, dp->d_name); |
| 4178 | if (res < 0 || res >= sizeof(buf)) |
| 4179 | continue; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4180 | dir_in = opendir(buf); |
| 4181 | if (dir_in == NULL) |
| 4182 | continue; |
| 4183 | dp_in = readdir(dir_in); |
| 4184 | closedir(dir_in); |
| 4185 | if (dp_in == NULL) |
| 4186 | continue; |
Jouni Malinen | 3aa7286 | 2019-05-29 23:14:51 +0300 | [diff] [blame] | 4187 | res = snprintf(buf, sizeof(buf), "%s%s/stat", |
| 4188 | direc, dp->d_name); |
| 4189 | if (res < 0 || res >= sizeof(buf)) |
| 4190 | continue; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4191 | fp = fopen(buf, "r"); |
| 4192 | if (fp == NULL) |
| 4193 | continue; |
| 4194 | if (fgets(buf, 100, fp) == NULL) |
| 4195 | buf[0] = '\0'; |
| 4196 | fclose(fp); |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 4197 | pid = strtok_r(buf, " ", &saveptr); |
| 4198 | temp = strtok_r(NULL, " ", &saveptr); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4199 | if (pid && temp && |
| 4200 | strncmp(temp, proc_name, strlen(proc_name)) == 0) { |
| 4201 | sigma_dut_print(dut, DUT_MSG_INFO, |
| 4202 | "killing %s process with PID %s", |
| 4203 | proc_name, pid); |
| 4204 | snprintf(buf, sizeof(buf), "kill -%d %d", sig, |
| 4205 | atoi(pid)); |
| 4206 | run_system(dut, buf); |
Pradeep Reddy Potteti | d068e64 | 2017-02-17 20:03:12 +0530 | [diff] [blame] | 4207 | ret = 0; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4208 | if (is_proc_instance_one) |
| 4209 | break; |
| 4210 | } |
| 4211 | } |
| 4212 | |
| 4213 | closedir(dir); |
| 4214 | |
Pradeep Reddy Potteti | d068e64 | 2017-02-17 20:03:12 +0530 | [diff] [blame] | 4215 | return ret; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4216 | #else /* __linux__ */ |
| 4217 | return -1; |
| 4218 | #endif /* __linux__ */ |
| 4219 | } |
| 4220 | |
| 4221 | |
| 4222 | static int run_ndc(struct sigma_dut *dut, char *buf) |
| 4223 | { |
| 4224 | sigma_dut_print(dut, DUT_MSG_INFO, "CMD NDC:: %s", buf); |
| 4225 | sleep(2); |
| 4226 | return run_system(dut, buf); |
| 4227 | } |
| 4228 | |
| 4229 | |
| 4230 | static int sigma_write_cfg(struct sigma_dut *dut, const char *pfile, |
| 4231 | const char *field, const char *value) |
| 4232 | { |
| 4233 | FILE *fcfg, *ftmp; |
| 4234 | char buf[MAX_CONF_LINE_LEN + 1]; |
| 4235 | int len, found = 0, res; |
| 4236 | |
| 4237 | /* Open the configuration file */ |
| 4238 | fcfg = fopen(pfile, "r"); |
| 4239 | if (!fcfg) { |
| 4240 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4241 | "Failed to open hostapd conf file"); |
| 4242 | return -1; |
| 4243 | } |
| 4244 | |
| 4245 | snprintf(buf, sizeof(buf), "%s~", pfile); |
| 4246 | /* Open a temporary file */ |
| 4247 | ftmp = fopen(buf, "w+"); |
| 4248 | if (!ftmp) { |
| 4249 | fclose(fcfg); |
| 4250 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4251 | "Failed to open temp buf"); |
| 4252 | return -1; |
| 4253 | } |
| 4254 | |
| 4255 | /* Read the values from the configuration file */ |
| 4256 | len = strlen(field); |
| 4257 | while (fgets(buf, MAX_CONF_LINE_LEN, fcfg)) { |
| 4258 | char *pline = buf; |
| 4259 | |
| 4260 | /* commented line */ |
| 4261 | if (buf[0] == '#') |
| 4262 | pline++; |
| 4263 | |
| 4264 | /* Identify the configuration parameter to be updated */ |
| 4265 | if (!found && strncmp(pline, field, len) == 0 && |
| 4266 | pline[len] == '=') { |
| 4267 | snprintf(buf, sizeof(buf), "%s=%s\n", field, value); |
| 4268 | found = 1; |
| 4269 | sigma_dut_print(dut, DUT_MSG_INFO, |
| 4270 | "Updated hostapd conf file"); |
| 4271 | } |
| 4272 | |
| 4273 | fprintf(ftmp, "%s", buf); |
| 4274 | } |
| 4275 | |
| 4276 | if (!found) { |
| 4277 | /* Configuration line not found */ |
| 4278 | /* Add the new line at the end of file */ |
| 4279 | fprintf(ftmp, "%s=%s\n", field, value); |
| 4280 | sigma_dut_print(dut, DUT_MSG_INFO, |
| 4281 | "Adding a new line in hostapd conf file"); |
| 4282 | } |
| 4283 | |
| 4284 | fclose(fcfg); |
| 4285 | fclose(ftmp); |
| 4286 | |
| 4287 | snprintf(buf, sizeof(buf), "%s~", pfile); |
| 4288 | |
| 4289 | /* Restore the updated configuration file */ |
| 4290 | res = rename(buf, pfile); |
| 4291 | |
| 4292 | /* Remove the temporary file. Ignore the return value */ |
| 4293 | unlink(buf); |
| 4294 | |
| 4295 | /* chmod is needed because open() may not set permissions properly |
| 4296 | * depending on the current umask */ |
| 4297 | if (chmod(pfile, 0660) < 0) { |
| 4298 | unlink(pfile); |
| 4299 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4300 | "Error changing permissions"); |
| 4301 | return -1; |
| 4302 | } |
| 4303 | |
| 4304 | if (res < 0) { |
| 4305 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4306 | "Error restoring conf file"); |
| 4307 | return -1; |
| 4308 | } |
| 4309 | |
| 4310 | return 0; |
| 4311 | } |
| 4312 | |
| 4313 | |
| 4314 | static int cmd_wcn_ap_config_commit(struct sigma_dut *dut, |
| 4315 | struct sigma_conn *conn, |
| 4316 | struct sigma_cmd *cmd) |
| 4317 | { |
| 4318 | char buf[100]; |
| 4319 | struct stat s; |
| 4320 | int num_tries = 0, ret; |
| 4321 | |
Pradeep Reddy Potteti | d068e64 | 2017-02-17 20:03:12 +0530 | [diff] [blame] | 4322 | if (kill_process(dut, "(netd)", 1, SIGKILL) == 0 || |
| 4323 | system("killall netd") == 0) { |
| 4324 | /* Avoid Error: Error connecting (Connection refused) |
| 4325 | * Wait some time to allow netd to reinitialize. |
| 4326 | */ |
| 4327 | usleep(1500000); |
| 4328 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4329 | |
| 4330 | while (num_tries < 10) { |
| 4331 | ret = run_ndc(dut, "ndc softap stopap"); |
| 4332 | num_tries++; |
| 4333 | if (WIFEXITED(ret)) |
| 4334 | ret = WEXITSTATUS(ret); |
| 4335 | /* On success, NDC exits with 0 */ |
| 4336 | if (ret == 0) |
| 4337 | break; |
| 4338 | sigma_dut_print(dut, DUT_MSG_INFO, |
| 4339 | "Try No. %d: ndc softap stopap failed, exit code %d", |
| 4340 | num_tries, ret); |
| 4341 | } |
| 4342 | |
| 4343 | if (ret != 0) |
| 4344 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4345 | "ndc softap stopap command failed for 10 times - giving up"); |
| 4346 | |
| 4347 | #ifdef ANDROID |
| 4348 | /* Unload/Load driver to cleanup the state of the driver */ |
Ajit Vaishya | 14d1f9a | 2017-09-04 23:24:25 +0530 | [diff] [blame] | 4349 | system("rmmod -f wlan"); |
| 4350 | usleep(500000); |
| 4351 | system("insmod /system/lib/modules/wlan.ko"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4352 | #else /* ANDROID */ |
| 4353 | run_ndc(dut, "ndc softap qccmd set enable_softap=0"); |
| 4354 | run_ndc(dut, "ndc softap qccmd set enable_softap=1"); |
| 4355 | #endif /* ANDROID */ |
| 4356 | |
| 4357 | switch (dut->ap_mode) { |
| 4358 | case AP_11g: |
| 4359 | run_ndc(dut, "ndc softap qccmd set hw_mode=g-only"); |
| 4360 | break; |
| 4361 | case AP_11b: |
| 4362 | run_ndc(dut, "ndc softap qccmd set hw_mode=b-only"); |
| 4363 | break; |
| 4364 | case AP_11ng: |
| 4365 | run_ndc(dut, "ndc softap qccmd set hw_mode=n"); |
| 4366 | break; |
| 4367 | case AP_11a: |
| 4368 | run_ndc(dut, "ndc softap qccmd set hw_mode=a-only"); |
| 4369 | break; |
| 4370 | case AP_11na: |
| 4371 | run_ndc(dut, "ndc softap qccmd set hw_mode=n"); |
| 4372 | break; |
| 4373 | case AP_11ac: |
| 4374 | run_ndc(dut, "ndc softap qccmd set hw_mode=ac"); |
| 4375 | break; |
| 4376 | default: |
| 4377 | break; |
| 4378 | } |
| 4379 | |
| 4380 | snprintf(buf, sizeof(buf), "ndc softap qccmd set channel=%d", |
| 4381 | dut->ap_channel); |
| 4382 | run_ndc(dut, buf); |
| 4383 | |
| 4384 | /* |
| 4385 | * ndc doesn't support double quotes as SSID string, so re-write |
| 4386 | * hostapd configuration file to update SSID. |
| 4387 | */ |
| 4388 | if (dut->ap_ssid[0] != '\0') |
| 4389 | sigma_write_cfg(dut, ANDROID_CONFIG_FILE, "ssid", dut->ap_ssid); |
| 4390 | |
| 4391 | switch (dut->ap_key_mgmt) { |
| 4392 | case AP_OPEN: |
| 4393 | if (dut->ap_cipher == AP_WEP) { |
| 4394 | run_ndc(dut, "ndc softap qccmd set security_mode=1"); |
| 4395 | snprintf(buf, sizeof(buf), |
| 4396 | "ndc softap qccmd set wep_key0=%s", |
| 4397 | dut->ap_wepkey); |
| 4398 | run_ndc(dut, buf); |
| 4399 | } else { |
| 4400 | run_ndc(dut, "ndc softap qccmd set security_mode=0"); |
| 4401 | } |
| 4402 | break; |
| 4403 | case AP_WPA2_PSK: |
| 4404 | case AP_WPA2_PSK_MIXED: |
| 4405 | case AP_WPA_PSK: |
| 4406 | if (dut->ap_key_mgmt == AP_WPA2_PSK) |
| 4407 | run_ndc(dut, "ndc softap qccmd set security_mode=3"); |
| 4408 | else if (dut->ap_key_mgmt == AP_WPA2_PSK_MIXED) |
| 4409 | run_ndc(dut, "ndc softap qccmd set security_mode=4"); |
| 4410 | else |
| 4411 | run_ndc(dut, "ndc softap qccmd set security_mode=2"); |
| 4412 | |
| 4413 | /* |
| 4414 | * ndc doesn't support some special characters as passphrase, |
| 4415 | * so re-write hostapd configuration file to update Passphrase. |
| 4416 | */ |
| 4417 | if (dut->ap_passphrase[0] != '\0') |
| 4418 | sigma_write_cfg(dut, ANDROID_CONFIG_FILE, |
| 4419 | "wpa_passphrase", dut->ap_passphrase); |
| 4420 | |
| 4421 | if (dut->ap_cipher == AP_CCMP_TKIP) |
| 4422 | run_ndc(dut, "ndc softap qccmd set wpa_pairwise=" |
| 4423 | "TKIP CCMP"); |
| 4424 | else if (dut->ap_cipher == AP_TKIP) |
| 4425 | run_ndc(dut, "ndc softap qccmd set wpa_pairwise=" |
| 4426 | "TKIP"); |
| 4427 | else |
| 4428 | run_ndc(dut, "ndc softap qccmd set wpa_pairwise=" |
| 4429 | "CCMP &"); |
| 4430 | break; |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 4431 | case AP_WPA2_SAE: |
| 4432 | case AP_WPA2_PSK_SAE: |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4433 | case AP_WPA2_EAP: |
| 4434 | case AP_WPA2_EAP_MIXED: |
| 4435 | case AP_WPA_EAP: |
Jouni Malinen | ad395a2 | 2017-09-01 21:13:46 +0300 | [diff] [blame] | 4436 | case AP_SUITEB: |
Jouni Malinen | 147b3c3 | 2017-10-09 16:51:54 +0300 | [diff] [blame] | 4437 | case AP_WPA2_OWE: |
Jouni Malinen | 4cf699f | 2018-06-19 00:46:27 +0300 | [diff] [blame] | 4438 | case AP_WPA2_EAP_OSEN: |
Jouni Malinen | c2b9121 | 2018-09-12 02:26:39 +0300 | [diff] [blame] | 4439 | case AP_OSEN: |
Jouni Malinen | 6be21c8 | 2018-08-01 18:47:24 +0300 | [diff] [blame] | 4440 | case AP_WPA2_FT_EAP: |
| 4441 | case AP_WPA2_FT_PSK: |
| 4442 | case AP_WPA2_EAP_SHA256: |
| 4443 | case AP_WPA2_PSK_SHA256: |
| 4444 | case AP_WPA2_ENT_FT_EAP: |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4445 | /* Not supported */ |
| 4446 | break; |
| 4447 | } |
| 4448 | |
| 4449 | switch (dut->ap_pmf) { |
| 4450 | case AP_PMF_DISABLED: |
| 4451 | run_ndc(dut, "ndc softap qccmd set ieee80211w=0"); |
| 4452 | break; |
| 4453 | case AP_PMF_OPTIONAL: |
| 4454 | run_ndc(dut, "ndc softap qccmd set ieee80211w=1"); |
| 4455 | if (dut->ap_add_sha256) |
| 4456 | run_ndc(dut, "ndc softap qccmd set wpa_key_mgmt=WPA-PSK WPA-PSK-SHA256"); |
| 4457 | else |
| 4458 | run_ndc(dut, "ndc softap qccmd set wpa_key_mgmt=WPA-PSK"); |
| 4459 | break; |
| 4460 | case AP_PMF_REQUIRED: |
| 4461 | run_ndc(dut, "ndc softap qccmd set ieee80211w=2"); |
| 4462 | run_ndc(dut, "ndc softap qccmd set wpa_key_mgmt=WPA-PSK-SHA256"); |
| 4463 | break; |
| 4464 | } |
| 4465 | |
| 4466 | if (dut->ap_countrycode[0]) { |
| 4467 | snprintf(buf, sizeof(buf), |
| 4468 | "ndc softap qccmd set country_code=%s", |
| 4469 | dut->ap_countrycode); |
| 4470 | run_ndc(dut, buf); |
| 4471 | } |
| 4472 | |
Pradeep Reddy POTTETI | fba27db | 2015-11-20 16:42:22 +0530 | [diff] [blame] | 4473 | if (dut->ap_regulatory_mode == AP_80211D_MODE_ENABLED) |
| 4474 | run_ndc(dut, "ndc softap qccmd set ieee80211d=1"); |
| 4475 | |
| 4476 | if (dut->ap_dfs_mode == AP_DFS_MODE_ENABLED) |
| 4477 | run_ndc(dut, "ndc softap qccmd set ieee80211h=1"); |
| 4478 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4479 | run_ndc(dut, "ndc softap startap"); |
| 4480 | |
| 4481 | snprintf(buf, sizeof(buf), "%s%s", sigma_wpas_ctrl, sigma_main_ifname); |
| 4482 | num_tries = 0; |
| 4483 | while (num_tries < 10 && (ret = stat(buf, &s) != 0)) { |
| 4484 | run_ndc(dut, "ndc softap stopap"); |
| 4485 | run_ndc(dut, "ndc softap startap"); |
| 4486 | num_tries++; |
| 4487 | } |
| 4488 | |
| 4489 | if (num_tries == 10) { |
| 4490 | sigma_dut_print(dut, DUT_MSG_INFO, "Tried 10 times with ctrl " |
| 4491 | "iface %s :: reboot the APDUT", buf); |
| 4492 | return ret; |
| 4493 | } |
| 4494 | |
| 4495 | sigma_dut_print(dut, DUT_MSG_INFO, "setting ip addr %s mask %s", |
| 4496 | ap_inet_addr, ap_inet_mask); |
| 4497 | snprintf(buf, sizeof(buf), "ifconfig %s %s netmask %s up", |
| 4498 | sigma_main_ifname, ap_inet_addr, ap_inet_mask); |
| 4499 | if (system(buf) != 0) { |
| 4500 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4501 | "Failed to intialize the interface"); |
| 4502 | return -1; |
| 4503 | } |
| 4504 | |
| 4505 | return 1; |
| 4506 | } |
| 4507 | |
| 4508 | |
| 4509 | static int append_hostapd_conf_hs2(struct sigma_dut *dut, FILE *f) |
| 4510 | { |
| 4511 | fprintf(f, "hs20=1\nhs20_deauth_req_timeout=3\n" |
| 4512 | "disable_dgaf=%d\n", dut->ap_dgaf_disable); |
| 4513 | |
| 4514 | if (dut->ap_oper_name) { |
| 4515 | fprintf(f, "hs20_oper_friendly_name=eng:Wi-Fi Alliance\n"); |
| 4516 | fprintf(f, "hs20_oper_friendly_name=chi:Wi-Fi\xe8\x81\x94\xe7\x9b\x9f\n"); |
| 4517 | } |
| 4518 | |
| 4519 | if (dut->ap_wan_metrics == 1) |
| 4520 | fprintf(f, "hs20_wan_metrics=01:2500:384:0:0:10\n"); |
| 4521 | else if (dut->ap_wan_metrics == 2) |
| 4522 | fprintf(f, "hs20_wan_metrics=01:1500:384:20:20:10\n"); |
| 4523 | else if (dut->ap_wan_metrics == 3) |
| 4524 | fprintf(f, "hs20_wan_metrics=01:2000:1000:20:20:10\n"); |
| 4525 | else if (dut->ap_wan_metrics == 4) |
| 4526 | fprintf(f, "hs20_wan_metrics=01:8000:1000:20:20:10\n"); |
| 4527 | else if (dut->ap_wan_metrics == 5) |
| 4528 | fprintf(f, "hs20_wan_metrics=01:9000:5000:20:20:10\n"); |
| 4529 | |
| 4530 | if (dut->ap_conn_capab == 1) { |
| 4531 | fprintf(f, "hs20_conn_capab=1:0:0\n"); |
| 4532 | fprintf(f, "hs20_conn_capab=6:20:1\n"); |
| 4533 | fprintf(f, "hs20_conn_capab=6:22:0\n"); |
| 4534 | fprintf(f, "hs20_conn_capab=6:80:1\n"); |
| 4535 | fprintf(f, "hs20_conn_capab=6:443:1\n"); |
| 4536 | fprintf(f, "hs20_conn_capab=6:1723:0\n"); |
| 4537 | fprintf(f, "hs20_conn_capab=6:5060:0\n"); |
| 4538 | fprintf(f, "hs20_conn_capab=17:500:1\n"); |
| 4539 | fprintf(f, "hs20_conn_capab=17:5060:0\n"); |
| 4540 | fprintf(f, "hs20_conn_capab=17:4500:1\n"); |
| 4541 | fprintf(f, "hs20_conn_capab=50:0:1\n"); |
| 4542 | } else if (dut->ap_conn_capab == 2) { |
| 4543 | fprintf(f, "hs20_conn_capab=6:80:1\n"); |
| 4544 | fprintf(f, "hs20_conn_capab=6:443:1\n"); |
| 4545 | fprintf(f, "hs20_conn_capab=17:5060:1\n"); |
| 4546 | fprintf(f, "hs20_conn_capab=6:5060:1\n"); |
| 4547 | } else if (dut->ap_conn_capab == 3) { |
| 4548 | fprintf(f, "hs20_conn_capab=6:80:1\n"); |
| 4549 | fprintf(f, "hs20_conn_capab=6:443:1\n"); |
| 4550 | } else if (dut->ap_conn_capab == 4) { |
| 4551 | fprintf(f, "hs20_conn_capab=6:80:1\n"); |
| 4552 | fprintf(f, "hs20_conn_capab=6:443:1\n"); |
| 4553 | fprintf(f, "hs20_conn_capab=6:5060:1\n"); |
| 4554 | fprintf(f, "hs20_conn_capab=17:5060:1\n"); |
| 4555 | } |
| 4556 | |
| 4557 | if (dut->ap_oper_class == 1) |
| 4558 | fprintf(f, "hs20_operating_class=51\n"); |
| 4559 | else if (dut->ap_oper_class == 2) |
| 4560 | fprintf(f, "hs20_operating_class=73\n"); |
| 4561 | else if (dut->ap_oper_class == 3) |
| 4562 | fprintf(f, "hs20_operating_class=5173\n"); |
| 4563 | |
| 4564 | if (dut->ap_osu_provider_list) { |
| 4565 | char *osu_friendly_name = NULL; |
| 4566 | char *osu_icon = NULL; |
| 4567 | char *osu_ssid = NULL; |
| 4568 | char *osu_nai = NULL; |
Jouni Malinen | 93a837f | 2018-11-01 17:09:22 +0200 | [diff] [blame] | 4569 | char *osu_nai2 = NULL; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4570 | char *osu_service_desc = NULL; |
| 4571 | char *hs20_icon_filename = NULL; |
| 4572 | char hs20_icon[150]; |
| 4573 | int osu_method; |
| 4574 | |
| 4575 | hs20_icon_filename = "icon_red_zxx.png"; |
| 4576 | if (dut->ap_osu_icon_tag == 2) |
| 4577 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 4578 | snprintf(hs20_icon, sizeof(hs20_icon), |
| 4579 | "128:61:zxx:image/png:icon_red_zxx.png:/etc/ath/%s", |
| 4580 | hs20_icon_filename); |
| 4581 | osu_icon = "icon_red_zxx.png"; |
| 4582 | osu_ssid = "OSU"; |
| 4583 | osu_friendly_name = "kor:SP 빨강 테스트 전용"; |
| 4584 | osu_service_desc = "kor:테스트 목적으로 무료 서비스"; |
| 4585 | osu_method = (dut->ap_osu_method[0] == 0xFF) ? 1 : dut->ap_osu_method[0]; |
| 4586 | |
| 4587 | if (strlen(dut->ap_osu_server_uri[0])) |
| 4588 | fprintf(f, "osu_server_uri=%s\n", dut->ap_osu_server_uri[0]); |
| 4589 | else |
| 4590 | fprintf(f, "osu_server_uri=https://osu-server.r2-testbed.wi-fi.org/\n"); |
| 4591 | |
| 4592 | switch (dut->ap_osu_provider_list) { |
| 4593 | case 1: |
| 4594 | case 101: |
| 4595 | fprintf(f, "osu_friendly_name=eng:SP Red Test Only\n"); |
| 4596 | fprintf(f, "osu_service_desc=eng:Free service for test purpose\n"); |
| 4597 | hs20_icon_filename = "icon_red_eng.png"; |
| 4598 | if (dut->ap_osu_icon_tag == 2) |
| 4599 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 4600 | fprintf(f, "hs20_icon=160:76:eng:image/png:icon_red_eng.png:/etc/ath/%s\n", |
| 4601 | hs20_icon_filename); |
| 4602 | fprintf(f, "osu_icon=icon_red_eng.png\n"); |
| 4603 | break; |
| 4604 | case 2: |
| 4605 | case 102: |
| 4606 | fprintf(f, "osu_friendly_name=eng:Wireless Broadband Alliance\n"); |
| 4607 | fprintf(f, "osu_service_desc=eng:Free service for test purpose\n"); |
| 4608 | hs20_icon_filename = "icon_orange_zxx.png"; |
| 4609 | if (dut->ap_osu_icon_tag == 2) |
| 4610 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 4611 | snprintf(hs20_icon, sizeof(hs20_icon), |
| 4612 | "128:61:zxx:image/png:icon_orange_zxx.png:/etc/ath/%s", |
| 4613 | hs20_icon_filename); |
| 4614 | osu_icon = "icon_orange_zxx.png"; |
| 4615 | osu_friendly_name = "kor:와이어리스 브로드밴드 얼라이언스"; |
| 4616 | break; |
| 4617 | case 3: |
| 4618 | case 103: |
| 4619 | osu_friendly_name = "spa:SP Red Test Only"; |
| 4620 | osu_service_desc = "spa:Free service for test purpose"; |
| 4621 | break; |
| 4622 | case 4: |
| 4623 | case 104: |
| 4624 | fprintf(f, "osu_friendly_name=eng:SP Orange Test Only\n"); |
| 4625 | fprintf(f, "osu_service_desc=eng:Free service for test purpose\n"); |
| 4626 | hs20_icon_filename = "icon_orange_eng.png"; |
| 4627 | if (dut->ap_osu_icon_tag == 2) |
| 4628 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 4629 | fprintf(f, "hs20_icon=160:76:eng:image/png:icon_orange_eng.png:/etc/ath/%s\n", |
| 4630 | hs20_icon_filename); |
| 4631 | fprintf(f, "osu_icon=icon_orange_eng.png\n"); |
| 4632 | osu_friendly_name = "kor:SP 오렌지 테스트 전용"; |
| 4633 | |
| 4634 | hs20_icon_filename = "icon_orange_zxx.png"; |
| 4635 | if (dut->ap_osu_icon_tag == 2) |
| 4636 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 4637 | snprintf(hs20_icon, sizeof(hs20_icon), |
| 4638 | "128:61:zxx:image/png:icon_orange_zxx.png:/etc/ath/%s", |
| 4639 | hs20_icon_filename); |
| 4640 | osu_icon = "icon_orange_zxx.png"; |
| 4641 | break; |
| 4642 | case 5: |
| 4643 | case 105: |
| 4644 | fprintf(f, "osu_friendly_name=eng:SP Orange Test Only\n"); |
| 4645 | fprintf(f, "osu_service_desc=eng:Free service for test purpose\n"); |
| 4646 | osu_friendly_name = "kor:SP 오렌지 테스트 전용"; |
| 4647 | hs20_icon_filename = "icon_orange_zxx.png"; |
| 4648 | if (dut->ap_osu_icon_tag == 2) |
| 4649 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 4650 | snprintf(hs20_icon, sizeof(hs20_icon), |
| 4651 | "128:61:zxx:image/png:icon_orange_zxx.png:/etc/ath/%s", |
| 4652 | hs20_icon_filename); |
| 4653 | osu_icon = "icon_orange_zxx.png"; |
| 4654 | break; |
| 4655 | case 6: |
| 4656 | case 106: |
| 4657 | fprintf(f, "osu_friendly_name=eng:SP Green Test Only\n"); |
| 4658 | fprintf(f, "osu_friendly_name=kor:SP 초록 테스트 전용\n"); |
| 4659 | hs20_icon_filename = "icon_green_zxx.png"; |
| 4660 | if (dut->ap_osu_icon_tag == 2) |
| 4661 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 4662 | fprintf(f, "hs20_icon=128:61:zxx:image/png:icon_green_zxx.png:/etc/ath/%s\n", |
| 4663 | hs20_icon_filename); |
| 4664 | fprintf(f, "osu_icon=icon_green_zxx.png\n"); |
| 4665 | osu_method = (dut->ap_osu_method[0] == 0xFF) ? 0 : dut->ap_osu_method[0]; |
| 4666 | fprintf(f, "osu_method_list=%d\n", osu_method); |
| 4667 | |
| 4668 | if (strlen(dut->ap_osu_server_uri[1])) |
| 4669 | fprintf(f, "osu_server_uri=%s\n", dut->ap_osu_server_uri[1]); |
| 4670 | else |
| 4671 | fprintf(f, "osu_server_uri=https://osu-server.r2-testbed.wi-fi.org/\n"); |
| 4672 | fprintf(f, "osu_friendly_name=eng:SP Orange Test Only\n"); |
| 4673 | hs20_icon_filename = "icon_orange_zxx.png"; |
| 4674 | if (dut->ap_osu_icon_tag == 2) |
| 4675 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 4676 | snprintf(hs20_icon, sizeof(hs20_icon), |
| 4677 | "128:61:zxx:image/png:icon_orange_zxx.png:/etc/ath/%s", |
| 4678 | hs20_icon_filename); |
| 4679 | osu_icon = "icon_orange_zxx.png"; |
| 4680 | osu_friendly_name = "kor:SP 오렌지 테스트 전용"; |
| 4681 | osu_method = (dut->ap_osu_method[1] == 0xFF) ? 0 : dut->ap_osu_method[1]; |
| 4682 | osu_service_desc = NULL; |
| 4683 | break; |
| 4684 | case 7: |
| 4685 | case 107: |
| 4686 | fprintf(f, "osu_friendly_name=eng:SP Green Test Only\n"); |
| 4687 | fprintf(f, "osu_service_desc=eng:Free service for test purpose\n"); |
| 4688 | hs20_icon_filename = "icon_green_eng.png"; |
| 4689 | if (dut->ap_osu_icon_tag == 2) |
| 4690 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 4691 | fprintf(f, "hs20_icon=160:76:eng:image/png:icon_green_eng.png:/etc/ath/%s\n", |
| 4692 | hs20_icon_filename); |
| 4693 | fprintf(f, "osu_icon=icon_green_eng.png\n"); |
| 4694 | osu_friendly_name = "kor:SP 초록 테스트 전용"; |
| 4695 | |
| 4696 | hs20_icon_filename = "icon_green_zxx.png"; |
| 4697 | if (dut->ap_osu_icon_tag == 2) |
| 4698 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 4699 | snprintf(hs20_icon, sizeof(hs20_icon), |
| 4700 | "128:61:zxx:image/png:icon_green_zxx.png:/etc/ath/%s", |
| 4701 | hs20_icon_filename); |
| 4702 | osu_icon = "icon_green_zxx.png"; |
| 4703 | break; |
| 4704 | case 8: |
| 4705 | case 108: |
| 4706 | fprintf(f, "osu_friendly_name=eng:SP Red Test Only\n"); |
| 4707 | fprintf(f, "osu_service_desc=eng:Free service for test purpose\n"); |
| 4708 | osu_ssid = "OSU-Encrypted"; |
| 4709 | osu_nai = "anonymous@hotspot.net"; |
| 4710 | break; |
| 4711 | case 9: |
| 4712 | case 109: |
| 4713 | osu_ssid = "OSU-OSEN"; |
| 4714 | osu_nai = "test-anonymous@wi-fi.org"; |
| 4715 | osu_friendly_name = "eng:SP Orange Test Only"; |
| 4716 | hs20_icon_filename = "icon_orange_zxx.png"; |
| 4717 | if (dut->ap_osu_icon_tag == 2) |
| 4718 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 4719 | snprintf(hs20_icon, sizeof(hs20_icon), |
| 4720 | "128:61:zxx:image/png:icon_orange_zxx.png:/etc/ath/%s", |
| 4721 | hs20_icon_filename); |
| 4722 | osu_icon = "icon_orange_zxx.png"; |
| 4723 | osu_method = (dut->ap_osu_method[0] == 0xFF) ? 1 : dut->ap_osu_method[0]; |
| 4724 | osu_service_desc = NULL; |
| 4725 | break; |
Jouni Malinen | 93a837f | 2018-11-01 17:09:22 +0200 | [diff] [blame] | 4726 | case 10: |
| 4727 | case 110: |
| 4728 | /* OSU Provider #1 */ |
| 4729 | fprintf(f, "osu_friendly_name=eng:SP Orange Test Only\n"); |
| 4730 | fprintf(f, "osu_friendly_name=kor:SP 오렌지 테스트 전용\n"); |
| 4731 | fprintf(f, "hs20_icon=128:61:zxx:image/png:icon_orange_zxx.png:/etc/ath/icon_orange_zxx.png\n"); |
| 4732 | fprintf(f, "osu_icon=icon_orange_zxx.png\n"); |
| 4733 | osu_method = (dut->ap_osu_method[0] == 0xFF) ? |
| 4734 | 1 : dut->ap_osu_method[0]; |
| 4735 | fprintf(f, "osu_method_list=%d\n", osu_method); |
| 4736 | fprintf(f, "osu_nai=test-anonymous@wi-fi.org\n"); |
| 4737 | switch (dut->ap_osu_provider_nai_list) { |
| 4738 | case 3: |
| 4739 | fprintf(f, |
| 4740 | "osu_nai2=test-anonymous@wi-fi.org\n"); |
| 4741 | break; |
| 4742 | case 4: |
| 4743 | fprintf(f, "osu_nai2=random@hotspot.net\n"); |
| 4744 | break; |
| 4745 | } |
| 4746 | |
| 4747 | /* OSU Provider #2 */ |
| 4748 | /* SP Red from defaults */ |
| 4749 | if (strlen(dut->ap_osu_server_uri[1])) |
| 4750 | fprintf(f, "osu_server_uri=%s\n", dut->ap_osu_server_uri[1]); |
| 4751 | else |
| 4752 | fprintf(f, "osu_server_uri=https://osu-server.r2-testbed.wi-fi.org/\n"); |
| 4753 | fprintf(f, "osu_friendly_name=eng:SP Red Test Only\n"); |
| 4754 | snprintf(hs20_icon, sizeof(hs20_icon), |
| 4755 | "128:61:zxx:image/png:icon_red_zxx.png:/etc/ath/icon_red_zxx.png"); |
| 4756 | osu_method = (dut->ap_osu_method[1] == 0xFF) ? |
| 4757 | 1 : dut->ap_osu_method[1]; |
| 4758 | osu_service_desc = NULL; |
| 4759 | osu_nai = "anonymous@hotspot.net"; |
| 4760 | break; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4761 | default: |
| 4762 | break; |
| 4763 | } |
| 4764 | |
Jouni Malinen | 93a837f | 2018-11-01 17:09:22 +0200 | [diff] [blame] | 4765 | switch (dut->ap_osu_provider_nai_list) { |
| 4766 | case 1: |
| 4767 | osu_nai2 = "anonymous@hotspot.net"; |
| 4768 | break; |
| 4769 | case 2: |
| 4770 | osu_nai2 = "test-anonymous@wi-fi.org"; |
| 4771 | break; |
| 4772 | case 3: |
| 4773 | /* OSU Provider NAI #1 written above */ |
| 4774 | /* OSU Provider NAI #2 */ |
| 4775 | osu_nai2 = "anonymous@hotspot.net"; |
| 4776 | break; |
| 4777 | case 4: |
| 4778 | /* OSU Provider NAI #1 written above */ |
| 4779 | /* OSU Provider NAI #2 */ |
| 4780 | osu_nai2 = "anonymous@hotspot.net"; |
| 4781 | break; |
| 4782 | } |
| 4783 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4784 | if (strlen(dut->ap_osu_ssid)) { |
Jouni Malinen | e6ac6a0 | 2018-09-11 02:40:17 +0300 | [diff] [blame] | 4785 | if (dut->ap_tag_ssid[0][0] && |
| 4786 | strcmp(dut->ap_tag_ssid[0], dut->ap_osu_ssid) && |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 4787 | strcmp(dut->ap_tag_ssid[0], osu_ssid)) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4788 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4789 | "OSU_SSID and " |
| 4790 | "WLAN_TAG2 SSID differ"); |
| 4791 | return -2; |
| 4792 | } |
| 4793 | fprintf(f, "osu_ssid=\"%s\"\n", dut->ap_osu_ssid); |
| 4794 | } else |
| 4795 | fprintf(f, "osu_ssid=\"%s\"\n", osu_ssid); |
| 4796 | |
| 4797 | |
| 4798 | if (osu_friendly_name) |
| 4799 | fprintf(f, "osu_friendly_name=%s\n", osu_friendly_name); |
| 4800 | |
| 4801 | if (osu_service_desc) |
| 4802 | fprintf(f, "osu_service_desc=%s\n", osu_service_desc); |
| 4803 | |
| 4804 | if (osu_nai) |
| 4805 | fprintf(f, "osu_nai=%s\n", osu_nai); |
Jouni Malinen | 93a837f | 2018-11-01 17:09:22 +0200 | [diff] [blame] | 4806 | if (osu_nai2) |
| 4807 | fprintf(f, "osu_nai2=%s\n", osu_nai2); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4808 | |
| 4809 | fprintf(f, "hs20_icon=%s\n", hs20_icon); |
| 4810 | |
| 4811 | if (osu_icon) |
| 4812 | fprintf(f, "osu_icon=%s\n", osu_icon); |
| 4813 | |
| 4814 | if (dut->ap_osu_provider_list > 100) |
| 4815 | fprintf(f, "osu_method_list=0\n"); |
| 4816 | else |
| 4817 | fprintf(f, "osu_method_list=%d\n", osu_method); |
| 4818 | } |
| 4819 | |
Jouni Malinen | 54a89b0 | 2018-05-01 00:16:26 +0300 | [diff] [blame] | 4820 | switch (dut->ap_venue_url) { |
| 4821 | case 1: |
| 4822 | fprintf(f, |
| 4823 | "venue_url=1:https://venue-server.r2m-testbed.wi-fi.org/floorplans/index.html\n" |
| 4824 | "venue_url=1:https://venue-server.r2m-testbed.wi-fi.org/directory/index.html\n"); |
| 4825 | break; |
| 4826 | case 2: |
| 4827 | fprintf(f, |
| 4828 | "venue_url=1:https://the-great-mall.r2m-testbed.wi-fi.org/floorplans/index.html\n" |
| 4829 | "venue_url=2:https://abercrombie.r2m-testbed.wi-fi.org/floorplans/index.html\n" |
| 4830 | "venue_url=3:https://adidas.r2m-testbed.wi-fi.org/floorplans/index.html\n" |
| 4831 | "venue_url=4:https://aeropostale.r2m-testbed.wi-fi.org/floorplans/index.html\n" |
| 4832 | "venue_url=5:https://agaci.r2m-testbed.wi-fi.org/floorplans/index.html\n" |
| 4833 | "venue_url=6:https://aldo-shoes.r2m-testbed.wi-fi.org/floorplans/index.html\n" |
| 4834 | "venue_url=7:https://american-eagle-outfitters.r2m-testbed.wi-fi.org/floorplans/index.html\n" |
| 4835 | "venue_url=8:https://anderson-bakery.r2m-testbed.wi-fi.org/floorplans/index.html\n" |
| 4836 | "venue_url=9:https://banana-republic-factory-store.r2m-testbed.wi-fi.org/floorplans/index.html\n" |
| 4837 | "venue_url=10:https://bed-bath-and-beyond.r2m-testbed.wi-fi.org/floorplans/index.html\n" |
| 4838 | ); |
| 4839 | break; |
| 4840 | } |
| 4841 | |
Jouni Malinen | f7ff42b | 2018-05-01 00:21:56 +0300 | [diff] [blame] | 4842 | switch (dut->ap_advice_of_charge) { |
| 4843 | case 1: |
| 4844 | fprintf(f, "anqp_elem=278:" ADV_OF_CHARGE_1 "\n"); |
| 4845 | break; |
| 4846 | } |
| 4847 | |
Jouni Malinen | ac10453 | 2018-05-01 00:27:37 +0300 | [diff] [blame] | 4848 | switch (dut->ap_oper_icon_metadata) { |
| 4849 | case 1: |
| 4850 | fprintf(f, |
| 4851 | "hs20_icon=160:76:eng:image/png:icon_red_eng.png:/etc/ath/icon_red_eng.png\n" |
| 4852 | "operator_icon=icon_red_eng.png\n"); |
| 4853 | break; |
| 4854 | } |
| 4855 | |
Jouni Malinen | ac36714 | 2018-05-01 00:32:24 +0300 | [diff] [blame] | 4856 | switch (dut->ap_tnc_file_name) { |
| 4857 | case 1: |
| 4858 | fprintf(f, "hs20_t_c_filename=tandc-id1-content.txt\n"); |
| 4859 | break; |
| 4860 | } |
| 4861 | |
| 4862 | if (dut->ap_tnc_time_stamp) |
| 4863 | fprintf(f, "hs20_t_c_timestamp=%u\n", dut->ap_tnc_time_stamp); |
| 4864 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4865 | return 0; |
| 4866 | } |
| 4867 | |
| 4868 | |
| 4869 | static void write_ap_roaming_cons(FILE *f, const char *list) |
| 4870 | { |
| 4871 | char *buf, *pos, *end; |
| 4872 | |
| 4873 | if (list == NULL || list[0] == '\0') |
| 4874 | return; |
| 4875 | |
| 4876 | buf = strdup(list); |
| 4877 | if (buf == NULL) |
| 4878 | return; |
| 4879 | |
| 4880 | pos = buf; |
| 4881 | while (pos && *pos) { |
| 4882 | end = strchr(pos, ';'); |
| 4883 | if (end) |
| 4884 | *end++ = '\0'; |
| 4885 | fprintf(f, "roaming_consortium=%s\n", pos); |
| 4886 | pos = end; |
| 4887 | } |
| 4888 | |
| 4889 | free(buf); |
| 4890 | } |
| 4891 | |
| 4892 | |
| 4893 | static int append_hostapd_conf_interworking(struct sigma_dut *dut, FILE *f) |
| 4894 | { |
| 4895 | int i; |
| 4896 | char buf[100], *temp; |
| 4897 | |
| 4898 | if (dut->ap_gas_cb_delay > 0) |
| 4899 | fprintf(f, "gas_comeback_delay=%d\n", |
| 4900 | dut->ap_gas_cb_delay); |
| 4901 | |
| 4902 | fprintf(f, "interworking=1\n" |
| 4903 | "access_network_type=%d\n" |
| 4904 | "internet=%d\n" |
| 4905 | "asra=0\n" |
| 4906 | "esr=0\n" |
| 4907 | "uesa=0\n" |
| 4908 | "venue_group=%d\n" |
| 4909 | "venue_type=%d\n", |
| 4910 | dut->ap_access_net_type, |
| 4911 | dut->ap_internet, |
| 4912 | dut->ap_venue_group, |
| 4913 | dut->ap_venue_type); |
| 4914 | if (dut->ap_hessid[0]) |
| 4915 | fprintf(f, "hessid=%s\n", dut->ap_hessid); |
| 4916 | |
| 4917 | write_ap_roaming_cons(f, dut->ap_roaming_cons); |
| 4918 | |
| 4919 | if (dut->ap_venue_name) { |
| 4920 | fprintf(f, "venue_name=P\"eng:Wi-Fi Alliance\\n2989 Copper Road\\nSanta Clara, CA 95051, USA\"\n"); |
| 4921 | fprintf(f, "venue_name=%s\n", ANQP_VENUE_NAME_1_CHI); |
| 4922 | } |
| 4923 | |
| 4924 | if (dut->ap_net_auth_type == 1) |
| 4925 | fprintf(f, "network_auth_type=00https://tandc-server.wi-fi.org\n"); |
| 4926 | else if (dut->ap_net_auth_type == 2) |
| 4927 | fprintf(f, "network_auth_type=01\n"); |
| 4928 | |
| 4929 | if (dut->ap_nai_realm_list == 1) { |
| 4930 | fprintf(f, "nai_realm=0,mail.example.com;cisco.com;wi-fi.org,21[2:4][5:7]\n"); |
| 4931 | fprintf(f, "nai_realm=0,wi-fi.org;example.com,13[5:6]\n"); |
| 4932 | } else if (dut->ap_nai_realm_list == 2) { |
| 4933 | fprintf(f, "nai_realm=0,wi-fi.org,21[2:4][5:7]\n"); |
| 4934 | } else if (dut->ap_nai_realm_list == 3) { |
| 4935 | fprintf(f, "nai_realm=0,cisco.com;wi-fi.org,21[2:4][5:7]\n"); |
| 4936 | fprintf(f, "nai_realm=0,wi-fi.org;example.com,13[5:6]\n"); |
| 4937 | } else if (dut->ap_nai_realm_list == 4) { |
| 4938 | fprintf(f, "nai_realm=0,mail.example.com,21[2:4][5:7],13[5:6]\n"); |
| 4939 | } else if (dut->ap_nai_realm_list == 5) { |
| 4940 | fprintf(f, "nai_realm=0,wi-fi.org;ruckuswireless.com,21[2:4][5:7]\n"); |
| 4941 | } else if (dut->ap_nai_realm_list == 6) { |
| 4942 | fprintf(f, "nai_realm=0,wi-fi.org;mail.example.com,21[2:4][5:7]\n"); |
| 4943 | } else if (dut->ap_nai_realm_list == 7) { |
| 4944 | fprintf(f, "nai_realm=0,wi-fi.org,13[5:6]\n"); |
| 4945 | fprintf(f, "nai_realm=0,wi-fi.org,21[2:4][5:7]\n"); |
| 4946 | } |
| 4947 | |
| 4948 | if (dut->ap_domain_name_list[0]) { |
| 4949 | fprintf(f, "domain_name=%s\n", |
| 4950 | dut->ap_domain_name_list); |
| 4951 | } |
| 4952 | |
| 4953 | if (dut->ap_ip_addr_type_avail == 1) { |
| 4954 | fprintf(f, "ipaddr_type_availability=0c\n"); |
| 4955 | } |
| 4956 | |
| 4957 | temp = buf; |
| 4958 | for (i = 0; dut->ap_plmn_mcc[i][0] && dut->ap_plmn_mnc[i][0]; |
| 4959 | i++) { |
| 4960 | if (i) |
| 4961 | *temp++ = ';'; |
| 4962 | |
| 4963 | snprintf(temp, |
| 4964 | sizeof(dut->ap_plmn_mcc[i]) + |
| 4965 | sizeof(dut->ap_plmn_mnc[i]) + 1, |
| 4966 | "%s,%s", |
| 4967 | dut->ap_plmn_mcc[i], |
| 4968 | dut->ap_plmn_mnc[i]); |
| 4969 | |
| 4970 | temp += strlen(dut->ap_plmn_mcc[i]) + |
| 4971 | strlen(dut->ap_plmn_mnc[i]) + 1; |
| 4972 | } |
| 4973 | if (i) |
| 4974 | fprintf(f, "anqp_3gpp_cell_net=%s\n", buf); |
| 4975 | |
| 4976 | if (dut->ap_qos_map_set == 1) |
| 4977 | fprintf(f, "qos_map_set=%s\n", QOS_MAP_SET_1); |
| 4978 | else if (dut->ap_qos_map_set == 2) |
| 4979 | fprintf(f, "qos_map_set=%s\n", QOS_MAP_SET_2); |
| 4980 | |
| 4981 | return 0; |
| 4982 | } |
| 4983 | |
| 4984 | |
| 4985 | static int ath_ap_append_hostapd_conf(struct sigma_dut *dut) |
| 4986 | { |
| 4987 | FILE *f; |
| 4988 | |
| 4989 | if (kill_process(dut, "(hostapd)", 1, SIGTERM) == 0 || |
| 4990 | system("killall hostapd") == 0) { |
| 4991 | int i; |
| 4992 | |
| 4993 | /* Wait some time to allow hostapd to complete cleanup before |
| 4994 | * starting a new process */ |
| 4995 | for (i = 0; i < 10; i++) { |
| 4996 | usleep(500000); |
| 4997 | if (system("pidof hostapd") != 0) |
| 4998 | break; |
| 4999 | } |
| 5000 | } |
| 5001 | |
| 5002 | f = fopen("/tmp/secath0", "a"); |
| 5003 | if (f == NULL) |
| 5004 | return -2; |
| 5005 | |
| 5006 | if (dut->ap_hs2 && append_hostapd_conf_hs2(dut, f)) { |
| 5007 | fclose(f); |
| 5008 | return -2; |
| 5009 | } |
| 5010 | |
| 5011 | if (dut->ap_interworking && append_hostapd_conf_interworking(dut, f)) { |
| 5012 | fclose(f); |
| 5013 | return -2; |
| 5014 | } |
| 5015 | |
| 5016 | fflush(f); |
| 5017 | fclose(f); |
| 5018 | return ath_ap_start_hostapd(dut); |
| 5019 | } |
| 5020 | |
| 5021 | |
| 5022 | static int ath_ap_start_hostapd(struct sigma_dut *dut) |
| 5023 | { |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 5024 | if (dut->ap_tag_key_mgmt[0] == AP2_OSEN) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5025 | run_system(dut, "hostapd -B /tmp/secath0 /tmp/secath1 -e /etc/wpa2/entropy"); |
| 5026 | else |
| 5027 | run_system(dut, "hostapd -B /tmp/secath0 -e /etc/wpa2/entropy"); |
| 5028 | |
| 5029 | return 0; |
| 5030 | } |
| 5031 | |
| 5032 | |
| 5033 | #define LE16(a) ((((a) & 0xff) << 8) | (((a) >> 8) & 0xff)) |
| 5034 | |
| 5035 | static int cmd_ath_ap_anqpserver_start(struct sigma_dut *dut) |
| 5036 | { |
| 5037 | FILE *f; |
| 5038 | int nai_realm = 0, domain_name = 0, oper_name = 0, venue_name = 0, |
| 5039 | wan_metrics = 0, conn_cap = 0, ipaddr_avail = 0, cell_net = 0; |
| 5040 | char buf[100]; |
| 5041 | int i; |
| 5042 | |
| 5043 | f = fopen("/root/anqpserver.conf", "w"); |
| 5044 | if (f == NULL) |
| 5045 | return -1; |
| 5046 | |
| 5047 | if (dut->ap_nai_realm_list == 1) { |
| 5048 | nai_realm = 1; |
| 5049 | 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"); |
| 5050 | } else if (dut->ap_nai_realm_list == 2) { |
| 5051 | nai_realm = 1; |
| 5052 | fprintf(f, "dyn_nai_home_realm=encoding=00realm=wi-fi.org;eap_method=0Dauth_id=05auth_val=06\n"); |
| 5053 | } else if (dut->ap_nai_realm_list == 3) { |
| 5054 | nai_realm = 1; |
| 5055 | 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"); |
| 5056 | } else if (dut->ap_nai_realm_list == 4) { |
| 5057 | nai_realm = 1; |
| 5058 | 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"); |
| 5059 | } else |
| 5060 | sigma_dut_print(dut, DUT_MSG_INFO, "not setting nai_realm"); |
| 5061 | |
| 5062 | if (dut->ap_domain_name_list[0]) { |
| 5063 | char *next, *start, *dnbuf, *dn1, *anqp_dn; |
| 5064 | int len, dn_len_max; |
| 5065 | dnbuf = strdup(dut->ap_domain_name_list); |
Pradeep Reddy POTTETI | 673d85c | 2016-07-26 19:08:07 +0530 | [diff] [blame] | 5066 | if (dnbuf == NULL) { |
| 5067 | fclose(f); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5068 | return 0; |
Pradeep Reddy POTTETI | 673d85c | 2016-07-26 19:08:07 +0530 | [diff] [blame] | 5069 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5070 | |
| 5071 | len = strlen(dnbuf); |
| 5072 | dn_len_max = 50 + len*2; |
| 5073 | anqp_dn = malloc(dn_len_max); |
| 5074 | if (anqp_dn == NULL) { |
| 5075 | free(dnbuf); |
Pradeep Reddy POTTETI | 673d85c | 2016-07-26 19:08:07 +0530 | [diff] [blame] | 5076 | fclose(f); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5077 | return -1; |
| 5078 | } |
| 5079 | start = dnbuf; |
| 5080 | dn1 = anqp_dn; |
| 5081 | while (start && *start) { |
| 5082 | char *hexstr; |
| 5083 | |
| 5084 | next = strchr(start, ','); |
| 5085 | if (next) |
| 5086 | *next++ = '\0'; |
| 5087 | |
| 5088 | len = strlen(start); |
vamsi krishna | 2e88130 | 2016-05-25 15:02:39 +0530 | [diff] [blame] | 5089 | hexstr = malloc(len * 2 + 1); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5090 | if (hexstr == NULL) { |
| 5091 | free(dnbuf); |
| 5092 | free(anqp_dn); |
Pradeep Reddy POTTETI | 673d85c | 2016-07-26 19:08:07 +0530 | [diff] [blame] | 5093 | fclose(f); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5094 | return -1; |
| 5095 | } |
| 5096 | ascii2hexstr(start, hexstr); |
| 5097 | snprintf(dn1, dn_len_max, "%02x%s", len, hexstr); |
| 5098 | free(hexstr); |
| 5099 | dn1 += 2 + len * 2; |
| 5100 | dn_len_max -= 2 + len * 2; |
| 5101 | start = next; |
| 5102 | } |
| 5103 | free(dnbuf); |
| 5104 | if (dut->ap_gas_cb_delay) { |
| 5105 | fprintf(f, "dyn_domain_name=0c01%04x%s", |
| 5106 | LE16((unsigned int) strlen(anqp_dn)), anqp_dn); |
| 5107 | domain_name = 1; |
| 5108 | } else |
| 5109 | fprintf(f, "domain_name=0c01%04x%s", |
| 5110 | LE16((unsigned int) strlen(anqp_dn)), anqp_dn); |
| 5111 | free(anqp_dn); |
| 5112 | } else |
| 5113 | sigma_dut_print(dut, DUT_MSG_INFO, "not setting domain_name"); |
| 5114 | |
| 5115 | sigma_dut_print(dut, DUT_MSG_INFO, "not setting roaming_consortium"); |
| 5116 | |
| 5117 | if (dut->ap_oper_name) { |
| 5118 | if (dut->ap_gas_cb_delay) { |
| 5119 | fprintf(f, "dyn_oper_friendly_name=" |
| 5120 | ANQP_HS20_OPERATOR_FRIENDLY_NAME_1 "\n"); |
| 5121 | oper_name = 1; |
| 5122 | } else |
| 5123 | fprintf(f, "oper_friendly_name=" |
| 5124 | ANQP_HS20_OPERATOR_FRIENDLY_NAME_1 "\n"); |
| 5125 | } else |
| 5126 | sigma_dut_print(dut, DUT_MSG_INFO, "not setting oper_name"); |
| 5127 | |
| 5128 | if (dut->ap_venue_name) { |
| 5129 | if (dut->ap_gas_cb_delay) { |
| 5130 | fprintf(f, "dyn_venue_name=" ANQP_VENUE_NAME_1 "\n"); |
| 5131 | venue_name = 1; |
| 5132 | } else |
| 5133 | fprintf(f, "venue_name=" ANQP_VENUE_NAME_1 "\n"); |
| 5134 | } else |
| 5135 | sigma_dut_print(dut, DUT_MSG_ERROR, "not setting venue_name"); |
| 5136 | |
| 5137 | if (dut->ap_wan_metrics) { |
| 5138 | if (dut->ap_gas_cb_delay) { |
| 5139 | fprintf(f, "dyn_wan_metrics=" ANQP_HS20_WAN_METRICS_1 "\n"); |
| 5140 | wan_metrics = 1; |
| 5141 | } else |
| 5142 | fprintf(f, "wan_metrics=" ANQP_HS20_WAN_METRICS_1 |
| 5143 | "\n"); |
| 5144 | } else |
| 5145 | sigma_dut_print(dut, DUT_MSG_ERROR, "not setting wan_metrics"); |
| 5146 | |
| 5147 | if (dut->ap_conn_capab) { |
| 5148 | if (dut->ap_gas_cb_delay) { |
| 5149 | fprintf(f, "dyn_conn_capability=" |
| 5150 | ANQP_HS20_CONNECTION_CAPABILITY_1 "\n"); |
| 5151 | conn_cap = 1; |
| 5152 | } else |
| 5153 | fprintf(f, "conn_capability=" |
| 5154 | ANQP_HS20_CONNECTION_CAPABILITY_1 "\n"); |
| 5155 | } else |
| 5156 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5157 | "not setting conn_capability"); |
| 5158 | |
| 5159 | if (dut->ap_ip_addr_type_avail) { |
| 5160 | if (dut->ap_gas_cb_delay) { |
| 5161 | fprintf(f, "dyn_ipaddr_type=" ANQP_IP_ADDR_TYPE_1 |
| 5162 | "\n"); |
| 5163 | ipaddr_avail = 1; |
| 5164 | } else |
| 5165 | fprintf(f, "ipaddr_type=" ANQP_IP_ADDR_TYPE_1 "\n"); |
| 5166 | } else |
| 5167 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5168 | "not setting ipaddr_type_avail"); |
| 5169 | |
| 5170 | for (i = 0; dut->ap_plmn_mcc[i][0] && dut->ap_plmn_mnc[i][0]; i++) { |
| 5171 | snprintf(buf + i * 6, sizeof(buf) - i * 6, "%c%c%c%c%c%c", |
| 5172 | dut->ap_plmn_mcc[i][1], |
| 5173 | dut->ap_plmn_mcc[i][0], |
| 5174 | dut->ap_plmn_mnc[i][2] == '\0' ? |
| 5175 | 'f' : dut->ap_plmn_mnc[i][2], |
| 5176 | dut->ap_plmn_mcc[i][2], |
| 5177 | dut->ap_plmn_mnc[i][1], |
| 5178 | dut->ap_plmn_mnc[i][0]); |
| 5179 | } |
| 5180 | if (i) { |
| 5181 | uint16_t ie_len = (i * 3) + 5; |
| 5182 | if (dut->ap_gas_cb_delay) { |
| 5183 | fprintf(f, "dyn_cell_net=0801"); |
| 5184 | cell_net = 1; |
| 5185 | } else |
| 5186 | fprintf(f, "cell_net=0801"); |
| 5187 | fprintf(f, "%04x", LE16(ie_len)); |
| 5188 | fprintf(f, "00"); /* version */ |
| 5189 | fprintf(f, "%02x", (i * 3) + 3); /* user data hdr length */ |
| 5190 | fprintf(f, "00"); /* plmn list */ |
| 5191 | fprintf(f, "%02x", (i * 3) + 1); /* length of plmn list */ |
| 5192 | fprintf(f, "%02x", i); /* number of plmns */ |
| 5193 | fprintf(f, "%s\n", buf); /* plmns */ |
| 5194 | } else |
| 5195 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5196 | "not setting 3gpp_cellular_network"); |
| 5197 | |
| 5198 | if (nai_realm || domain_name || oper_name || venue_name || |
| 5199 | wan_metrics || conn_cap || ipaddr_avail || cell_net) { |
| 5200 | fprintf(f, "anqp_attach="); |
| 5201 | if (venue_name) |
| 5202 | fprintf(f, "00000104%4.4x", dut->ap_gas_cb_delay); |
| 5203 | if (nai_realm) |
| 5204 | fprintf(f, "00000107%4.4x", dut->ap_gas_cb_delay); |
| 5205 | if (cell_net) |
| 5206 | fprintf(f, "00000108%4.4x", dut->ap_gas_cb_delay); |
| 5207 | if (domain_name) |
| 5208 | fprintf(f, "0000010c%4.4x", dut->ap_gas_cb_delay); |
| 5209 | if (oper_name) |
| 5210 | fprintf(f, "00010003%4.4x", dut->ap_gas_cb_delay); |
| 5211 | if (wan_metrics) |
| 5212 | fprintf(f, "00010004%4.4x", dut->ap_gas_cb_delay); |
| 5213 | if (conn_cap) |
| 5214 | fprintf(f, "00010005%4.4x", dut->ap_gas_cb_delay); |
| 5215 | fprintf(f, "00010006%4.4x", dut->ap_gas_cb_delay); |
| 5216 | fprintf(f, "\n"); |
| 5217 | } |
| 5218 | |
| 5219 | fclose(f); |
| 5220 | |
| 5221 | run_system(dut, "anqpserver -i ath0 &"); |
| 5222 | if (!dut->ap_anqpserver_on) |
| 5223 | run_system(dut, "killall anqpserver"); |
| 5224 | |
| 5225 | return 1; |
| 5226 | } |
| 5227 | |
| 5228 | |
| 5229 | static void cmd_ath_ap_radio_config(struct sigma_dut *dut) |
| 5230 | { |
| 5231 | char buf[100]; |
| 5232 | |
| 5233 | run_system(dut, "cfg -a AP_STARTMODE=standard"); |
| 5234 | |
| 5235 | if (sigma_radio_ifname[0] && |
| 5236 | strcmp(sigma_radio_ifname[0], "wifi1") == 0) { |
| 5237 | run_system(dut, "cfg -a AP_RADIO_ID=1"); |
| 5238 | switch (dut->ap_mode) { |
| 5239 | case AP_11g: |
| 5240 | run_system(dut, "cfg -a AP_CHMODE_2=11G"); |
| 5241 | break; |
| 5242 | case AP_11b: |
| 5243 | run_system(dut, "cfg -a AP_CHMODE_2=11B"); |
| 5244 | break; |
| 5245 | case AP_11ng: |
| 5246 | run_system(dut, "cfg -a AP_CHMODE_2=11NGHT20"); |
| 5247 | break; |
| 5248 | case AP_11a: |
| 5249 | run_system(dut, "cfg -a AP_CHMODE_2=11A"); |
| 5250 | break; |
| 5251 | case AP_11na: |
| 5252 | run_system(dut, "cfg -a AP_CHMODE_2=11NAHT20"); |
| 5253 | break; |
| 5254 | case AP_11ac: |
| 5255 | run_system(dut, "cfg -a AP_CHMODE_2=11ACVHT80"); |
| 5256 | break; |
| 5257 | default: |
| 5258 | run_system(dut, "cfg -a AP_CHMODE_2=11ACVHT80"); |
| 5259 | break; |
| 5260 | } |
| 5261 | |
| 5262 | switch (dut->ap_rx_streams) { |
| 5263 | case 1: |
| 5264 | run_system(dut, "cfg -a RX_CHAINMASK_2=1"); |
| 5265 | break; |
| 5266 | case 2: |
| 5267 | run_system(dut, "cfg -a RX_CHAINMASK_2=3"); |
| 5268 | break; |
| 5269 | case 3: |
| 5270 | run_system(dut, "cfg -a RX_CHAINMASK_2=7"); |
| 5271 | break; |
| 5272 | } |
| 5273 | |
| 5274 | switch (dut->ap_tx_streams) { |
| 5275 | case 1: |
| 5276 | run_system(dut, "cfg -a TX_CHAINMASK_2=1"); |
| 5277 | break; |
| 5278 | case 2: |
| 5279 | run_system(dut, "cfg -a TX_CHAINMASK_2=3"); |
| 5280 | break; |
| 5281 | case 3: |
| 5282 | run_system(dut, "cfg -a TX_CHAINMASK_2=7"); |
| 5283 | break; |
| 5284 | } |
| 5285 | |
| 5286 | switch (dut->ap_chwidth) { |
| 5287 | case AP_20: |
| 5288 | run_system(dut, "cfg -a AP_CHMODE_2=11ACVHT20"); |
| 5289 | break; |
| 5290 | case AP_40: |
| 5291 | run_system(dut, "cfg -a AP_CHMODE_2=11ACVHT40"); |
| 5292 | break; |
| 5293 | case AP_80: |
| 5294 | run_system(dut, "cfg -a AP_CHMODE_2=11ACVHT80"); |
| 5295 | break; |
| 5296 | case AP_160: |
| 5297 | case AP_AUTO: |
| 5298 | default: |
| 5299 | run_system(dut, "cfg -a AP_CHMODE_2=11ACVHT80"); |
| 5300 | break; |
| 5301 | } |
| 5302 | |
| 5303 | if (dut->ap_tx_stbc) { |
| 5304 | run_system(dut, "cfg -a TX_STBC_2=1"); |
| 5305 | } |
| 5306 | |
| 5307 | snprintf(buf, sizeof(buf), "cfg -a AP_PRIMARY_CH_2=%d", |
| 5308 | dut->ap_channel); |
| 5309 | |
| 5310 | if (dut->ap_is_dual) { |
| 5311 | switch (dut->ap_mode_1) { |
| 5312 | case AP_11g: |
| 5313 | run_system(dut, "cfg -a AP_CHMODE=11G"); |
| 5314 | break; |
| 5315 | case AP_11b: |
| 5316 | run_system(dut, "cfg -a AP_CHMODE=11B"); |
| 5317 | break; |
| 5318 | case AP_11ng: |
| 5319 | run_system(dut, "cfg -a AP_CHMODE=11NGHT20"); |
| 5320 | break; |
| 5321 | case AP_11a: |
| 5322 | run_system(dut, "cfg -a AP_CHMODE=11A"); |
| 5323 | break; |
| 5324 | case AP_11na: |
| 5325 | run_system(dut, "cfg -a AP_CHMODE=11NAHT20"); |
| 5326 | break; |
| 5327 | case AP_11ac: |
| 5328 | run_system(dut, "cfg -a AP_CHMODE=11ACVHT80"); |
| 5329 | break; |
| 5330 | default: |
| 5331 | run_system(dut, "cfg -a AP_CHMODE=11NGHT20"); |
| 5332 | break; |
| 5333 | } |
| 5334 | snprintf(buf, sizeof(buf), "cfg -a AP_PRIMARY_CH=%d", |
| 5335 | dut->ap_channel_1); |
| 5336 | } |
| 5337 | run_system(dut, buf); |
| 5338 | } else { |
| 5339 | run_system(dut, "cfg -a AP_RADIO_ID=0"); |
| 5340 | switch (dut->ap_mode) { |
| 5341 | case AP_11g: |
| 5342 | run_system(dut, "cfg -a AP_CHMODE=11G"); |
| 5343 | break; |
| 5344 | case AP_11b: |
| 5345 | run_system(dut, "cfg -a AP_CHMODE=11B"); |
| 5346 | break; |
| 5347 | case AP_11ng: |
| 5348 | run_system(dut, "cfg -a AP_CHMODE=11NGHT20"); |
| 5349 | break; |
| 5350 | case AP_11a: |
| 5351 | run_system(dut, "cfg -a AP_CHMODE=11A"); |
| 5352 | break; |
| 5353 | case AP_11na: |
| 5354 | run_system(dut, "cfg -a AP_CHMODE=11NAHT20"); |
| 5355 | break; |
| 5356 | case AP_11ac: |
| 5357 | run_system(dut, "cfg -a AP_CHMODE=11ACVHT80"); |
| 5358 | break; |
| 5359 | default: |
| 5360 | run_system(dut, "cfg -a AP_CHMODE=11NGHT20"); |
| 5361 | break; |
| 5362 | } |
| 5363 | snprintf(buf, sizeof(buf), "cfg -a AP_PRIMARY_CH=%d", |
| 5364 | dut->ap_channel); |
| 5365 | run_system(dut, buf); |
| 5366 | } |
| 5367 | |
| 5368 | if (dut->ap_sgi80 == 1) { |
| 5369 | run_system(dut, "cfg -a SHORTGI=1"); |
| 5370 | run_system(dut, "cfg -a SHORTGI_2=1"); |
| 5371 | } else if (dut->ap_sgi80 == 0) { |
| 5372 | run_system(dut, "cfg -a SHORTGI=0"); |
| 5373 | run_system(dut, "cfg -a SHORTGI_2=0"); |
| 5374 | } |
| 5375 | |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 5376 | if (dut->ap_ldpc == VALUE_ENABLED) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5377 | run_system(dut, "cfg -a LDPC=1"); |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 5378 | else if (dut->ap_ldpc == VALUE_DISABLED) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5379 | run_system(dut, "cfg -a LDPC=0"); |
| 5380 | } |
| 5381 | |
| 5382 | |
| 5383 | void ath_disable_txbf(struct sigma_dut *dut, const char *intf) |
| 5384 | { |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 5385 | run_iwpriv(dut, intf, "vhtsubfee 0"); |
| 5386 | run_iwpriv(dut, intf, "vhtsubfer 0"); |
| 5387 | run_iwpriv(dut, intf, "vhtmubfee 0"); |
| 5388 | run_iwpriv(dut, intf, "vhtmubfer 0"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5389 | } |
| 5390 | |
| 5391 | |
Adil Saeed Musthafa | 05ec744 | 2017-04-10 23:13:35 -0700 | [diff] [blame] | 5392 | static void ath_set_assoc_disallow(struct sigma_dut *dut, const char *ifname, |
| 5393 | const char *val) |
| 5394 | { |
| 5395 | if (strcasecmp(val, "enable") == 0) { |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 5396 | run_iwpriv(dut, ifname, "mbo_asoc_dis 1"); |
Adil Saeed Musthafa | 05ec744 | 2017-04-10 23:13:35 -0700 | [diff] [blame] | 5397 | } else if (strcasecmp(val, "disable") == 0) { |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 5398 | run_iwpriv(dut, ifname, "mbo_asoc_dis 0"); |
Adil Saeed Musthafa | 05ec744 | 2017-04-10 23:13:35 -0700 | [diff] [blame] | 5399 | } else { |
| 5400 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5401 | "Unsupported assoc_disallow"); |
| 5402 | } |
| 5403 | } |
| 5404 | |
| 5405 | |
Adil Saeed Musthafa | 6906372 | 2017-04-10 23:13:40 -0700 | [diff] [blame] | 5406 | static void apply_mbo_pref_ap_list(struct sigma_dut *dut) |
| 5407 | { |
| 5408 | int i; |
| 5409 | int least_pref = 1 << 8; |
| 5410 | char ifname[20]; |
| 5411 | uint8_t self_mac[ETH_ALEN]; |
| 5412 | char buf[200]; |
| 5413 | int ap_ne_class, ap_ne_pref, ap_ne_op_ch; |
| 5414 | |
| 5415 | get_if_name(dut, ifname, sizeof(ifname), 1); |
| 5416 | get_hwaddr(ifname, self_mac); |
| 5417 | |
| 5418 | /* Clear off */ |
| 5419 | snprintf(buf, sizeof(buf), |
| 5420 | "wifitool %s setbssidpref 00:00:00:00:00:00 0 0 0", |
| 5421 | ifname); |
| 5422 | run_system(dut, buf); |
| 5423 | |
| 5424 | /* Find the least preference number */ |
| 5425 | for (i = 0; i < dut->mbo_pref_ap_cnt; i++) { |
| 5426 | unsigned char *mac_addr = dut->mbo_pref_aps[i].mac_addr; |
| 5427 | |
| 5428 | ap_ne_class = 1; |
| 5429 | ap_ne_pref = 255; |
| 5430 | ap_ne_op_ch = 1; |
| 5431 | if (dut->mbo_pref_aps[i].ap_ne_pref != -1) |
| 5432 | ap_ne_pref = dut->mbo_pref_aps[i].ap_ne_pref; |
| 5433 | if (dut->mbo_pref_aps[i].ap_ne_class != -1) |
| 5434 | ap_ne_class = dut->mbo_pref_aps[i].ap_ne_class; |
| 5435 | if (dut->mbo_pref_aps[i].ap_ne_op_ch != -1) |
| 5436 | ap_ne_op_ch = dut->mbo_pref_aps[i].ap_ne_op_ch; |
| 5437 | |
| 5438 | if (ap_ne_pref < least_pref) |
| 5439 | least_pref = ap_ne_pref; |
| 5440 | snprintf(buf, sizeof(buf), |
| 5441 | "wifitool %s setbssidpref %02x:%02x:%02x:%02x:%02x:%02x %d %d %d", |
| 5442 | ifname, mac_addr[0], mac_addr[1], mac_addr[2], |
| 5443 | mac_addr[3], mac_addr[4], mac_addr[5], |
| 5444 | ap_ne_pref, ap_ne_class, ap_ne_op_ch); |
| 5445 | run_system(dut, buf); |
| 5446 | } |
| 5447 | |
| 5448 | /* Now add the self AP Address */ |
| 5449 | if (dut->mbo_self_ap_tuple.ap_ne_class == -1) { |
| 5450 | if (dut->ap_channel <= 11) |
| 5451 | ap_ne_class = 81; |
| 5452 | else |
| 5453 | ap_ne_class = 115; |
| 5454 | } else { |
| 5455 | ap_ne_class = dut->mbo_self_ap_tuple.ap_ne_class; |
| 5456 | } |
| 5457 | |
| 5458 | if (dut->mbo_self_ap_tuple.ap_ne_op_ch == -1) |
| 5459 | ap_ne_op_ch = dut->ap_channel; |
| 5460 | else |
| 5461 | ap_ne_op_ch = dut->mbo_self_ap_tuple.ap_ne_op_ch; |
| 5462 | |
| 5463 | if (dut->mbo_self_ap_tuple.ap_ne_pref == -1) |
| 5464 | ap_ne_pref = least_pref - 1; |
| 5465 | else |
| 5466 | ap_ne_pref = dut->mbo_self_ap_tuple.ap_ne_pref; |
| 5467 | |
| 5468 | snprintf(buf, sizeof(buf), |
| 5469 | "wifitool %s setbssidpref %02x:%02x:%02x:%02x:%02x:%02x %d %d %d", |
| 5470 | ifname, self_mac[0], self_mac[1], self_mac[2], |
| 5471 | self_mac[3], self_mac[4], self_mac[5], |
| 5472 | ap_ne_pref, |
| 5473 | ap_ne_class, |
| 5474 | ap_ne_op_ch); |
| 5475 | run_system(dut, buf); |
| 5476 | } |
| 5477 | |
| 5478 | |
Priyadharshini Gowthaman | 7e43870 | 2019-08-09 12:05:05 -0700 | [diff] [blame] | 5479 | static void mubrp_commands(struct sigma_dut *dut, const char *ifname) |
| 5480 | { |
| 5481 | run_iwpriv(dut, ifname, "he_subfer 1"); |
| 5482 | run_iwpriv(dut, ifname, "he_mubfer 1"); |
| 5483 | /* To enable MU_AX with MU_BRP trigger */ |
| 5484 | run_iwpriv(dut, ifname, "he_sounding_mode 13"); |
| 5485 | /* Sets g_force_1x1_peer to 1 which should be reset to zero for non MU |
| 5486 | * test cases */ |
| 5487 | run_system_wrapper(dut, "wifitool %s setUnitTestCmd 0x48 2 118 1", |
| 5488 | ifname); |
| 5489 | /* Disable DL OFDMA */ |
| 5490 | run_system_wrapper(dut, "wifitool %s setUnitTestCmd 0x47 2 11 0", |
| 5491 | ifname); |
| 5492 | } |
| 5493 | |
| 5494 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5495 | static void ath_ap_set_params(struct sigma_dut *dut) |
| 5496 | { |
priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 5497 | const char *basedev = "wifi0"; |
| 5498 | const char *basedev_radio = "wifi1"; |
| 5499 | char *ifname = get_main_ifname(); |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 5500 | char *ifname_dual = NULL; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5501 | int i; |
priyadharshini gowthaman | 8e26ff4 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 5502 | char buf[300]; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5503 | |
priyadharshini gowthaman | e161746 | 2017-04-25 12:03:59 -0700 | [diff] [blame] | 5504 | if (sigma_radio_ifname[0]) |
| 5505 | basedev = sigma_radio_ifname[0]; |
| 5506 | |
priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 5507 | if (dut->ap_is_dual == 1) { |
| 5508 | basedev = sigma_radio_ifname[0]; |
| 5509 | basedev_radio = sigma_radio_ifname[1]; |
| 5510 | if (sigma_radio_ifname[0] && |
| 5511 | strcmp(sigma_radio_ifname[0], "wifi0") == 0) { |
| 5512 | ifname = "ath0"; |
| 5513 | ifname_dual = "ath1"; |
| 5514 | } else { |
| 5515 | ifname = "ath1"; |
| 5516 | ifname_dual = "ath0"; |
| 5517 | } |
| 5518 | } |
| 5519 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5520 | if (dut->ap_countrycode[0]) { |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 5521 | run_iwpriv(dut, basedev, "setCountry %s", dut->ap_countrycode); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5522 | sigma_dut_print(dut, DUT_MSG_INFO, "Set countrycode"); |
| 5523 | } |
| 5524 | |
| 5525 | for (i = 0; i < NUM_AP_AC; i++) { |
| 5526 | if (dut->ap_qos[i].ac) { |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 5527 | run_iwpriv(dut, ifname, "cwmin %d 0 %d", i, |
| 5528 | dut->ap_qos[i].cwmin); |
| 5529 | run_iwpriv(dut, ifname, "cwmax %d 0 %d", i, |
| 5530 | dut->ap_qos[i].cwmax); |
| 5531 | run_iwpriv(dut, ifname, "aifs %d 0 %d", i, |
| 5532 | dut->ap_qos[i].aifs); |
| 5533 | run_iwpriv(dut, ifname, "txoplimit %d 0 %d", i, |
| 5534 | dut->ap_qos[i].txop); |
| 5535 | run_iwpriv(dut, ifname, "acm %d 0 %d", i, |
| 5536 | dut->ap_qos[i].acm); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5537 | } |
| 5538 | } |
| 5539 | |
| 5540 | for (i = 0; i < NUM_AP_AC; i++) { |
| 5541 | if (dut->ap_sta_qos[i].ac) { |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 5542 | run_iwpriv(dut, ifname, "cwmin %d 1 %d", i, |
| 5543 | dut->ap_sta_qos[i].cwmin); |
| 5544 | run_iwpriv(dut, ifname, "cwmax %d 1 %d", i, |
| 5545 | dut->ap_sta_qos[i].cwmax); |
| 5546 | run_iwpriv(dut, ifname, "aifs %d 1 %d", i, |
| 5547 | dut->ap_sta_qos[i].aifs); |
| 5548 | run_iwpriv(dut, ifname, "txoplimit %d 1 %d", i, |
| 5549 | dut->ap_sta_qos[i].txop); |
| 5550 | run_iwpriv(dut, ifname, "acm %d 1 %d", i, |
| 5551 | dut->ap_sta_qos[i].acm); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5552 | } |
| 5553 | } |
| 5554 | |
| 5555 | if (dut->ap_disable_protection == 1) { |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 5556 | run_iwpriv(dut, ifname, "enablertscts 0"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5557 | sigma_dut_print(dut, DUT_MSG_INFO, "Disabled rtscts"); |
| 5558 | } |
| 5559 | |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 5560 | if (dut->ap_ldpc == VALUE_ENABLED) |
| 5561 | run_iwpriv(dut, ifname, "ldpc 3"); |
| 5562 | else if (dut->ap_ldpc == VALUE_DISABLED) |
| 5563 | run_iwpriv(dut, ifname, "ldpc 0"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5564 | |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 5565 | if (dut->ap_ampdu == VALUE_ENABLED) |
| 5566 | run_iwpriv(dut, ifname, "ampdu 1"); |
| 5567 | else if (dut->ap_ampdu == VALUE_DISABLED) |
| 5568 | run_iwpriv(dut, ifname, "ampdu 0"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5569 | |
| 5570 | if (dut->ap_ampdu_exp) { |
| 5571 | if (dut->program == PROGRAM_VHT) { |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 5572 | run_iwpriv(dut, ifname, "vhtmaxampdu %d", |
| 5573 | dut->ap_ampdu_exp); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5574 | } else { |
| 5575 | /* 11N */ |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 5576 | run_iwpriv(dut, ifname, "maxampdu %d", |
| 5577 | dut->ap_ampdu_exp); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5578 | } |
| 5579 | } |
| 5580 | |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 5581 | if (dut->ap_noack == VALUE_ENABLED) { |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 5582 | run_iwpriv(dut, ifname, "noackpolicy 0 0 1"); |
| 5583 | run_iwpriv(dut, ifname, "noackpolicy 1 0 1"); |
| 5584 | run_iwpriv(dut, ifname, "noackpolicy 2 0 1"); |
| 5585 | run_iwpriv(dut, ifname, "noackpolicy 3 0 1"); |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 5586 | } else if (dut->ap_noack == VALUE_DISABLED) { |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 5587 | run_iwpriv(dut, ifname, "noackpolicy 0 0 0"); |
| 5588 | run_iwpriv(dut, ifname, "noackpolicy 1 0 0"); |
| 5589 | run_iwpriv(dut, ifname, "noackpolicy 2 0 0"); |
| 5590 | run_iwpriv(dut, ifname, "noackpolicy 3 0 0"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5591 | } |
| 5592 | |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 5593 | if (dut->device_type == AP_testbed && dut->ap_vhtmcs_map) |
| 5594 | run_iwpriv(dut, ifname, "vht_mcsmap 0x%04x", |
| 5595 | dut->ap_vhtmcs_map); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5596 | |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 5597 | if (dut->ap_amsdu == VALUE_ENABLED) |
| 5598 | run_iwpriv(dut, ifname, "amsdu 2"); |
| 5599 | else if (dut->ap_amsdu == VALUE_DISABLED) |
| 5600 | run_iwpriv(dut, ifname, "amsdu 1"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5601 | |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 5602 | if (dut->ap_rx_amsdu == VALUE_ENABLED) |
| 5603 | run_iwpriv(dut, basedev_radio, "rx_amsdu 1"); |
| 5604 | else if (dut->ap_rx_amsdu == VALUE_DISABLED) |
| 5605 | run_iwpriv(dut, basedev_radio, "rx_amsdu 0"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5606 | |
| 5607 | /* Command sequence to generate single VHT AMSDU and MPDU */ |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 5608 | if (dut->ap_addba_reject != VALUE_NOT_SET && |
| 5609 | dut->ap_ampdu == VALUE_DISABLED && |
| 5610 | dut->ap_amsdu == VALUE_ENABLED) { |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 5611 | run_iwpriv(dut, ifname, "setaddbaoper 1"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5612 | |
| 5613 | snprintf(buf, sizeof(buf), |
| 5614 | "wifitool %s senddelba 1 0 1 4", ifname); |
| 5615 | if (system(buf) != 0) { |
| 5616 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5617 | "wifitool senddelba failed"); |
| 5618 | } |
| 5619 | |
| 5620 | snprintf(buf, sizeof(buf), "wifitool %s sendsingleamsdu 1 0", |
| 5621 | ifname); |
| 5622 | if (system(buf) != 0) { |
| 5623 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5624 | "wifitool sendsingleamsdu failed"); |
| 5625 | } |
| 5626 | |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 5627 | run_iwpriv(dut, ifname, "amsdu 10"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5628 | } |
| 5629 | |
| 5630 | if (dut->ap_mode == AP_11ac) { |
| 5631 | int chwidth, nss; |
| 5632 | |
| 5633 | switch (dut->ap_chwidth) { |
| 5634 | case AP_20: |
| 5635 | chwidth = 0; |
| 5636 | break; |
| 5637 | case AP_40: |
| 5638 | chwidth = 1; |
| 5639 | break; |
| 5640 | case AP_80: |
| 5641 | chwidth = 2; |
| 5642 | break; |
| 5643 | case AP_160: |
| 5644 | chwidth = 3; |
| 5645 | break; |
priyadharshini gowthaman | 63ab848 | 2017-12-28 15:32:55 -0800 | [diff] [blame] | 5646 | case AP_80_80: |
| 5647 | chwidth = 3; |
| 5648 | break; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5649 | default: |
| 5650 | chwidth = 0; |
| 5651 | break; |
| 5652 | } |
| 5653 | |
| 5654 | switch (dut->ap_tx_streams) { |
| 5655 | case 1: |
| 5656 | nss = 1; |
| 5657 | break; |
| 5658 | case 2: |
| 5659 | nss = 2; |
| 5660 | break; |
| 5661 | case 3: |
| 5662 | nss = 3; |
| 5663 | break; |
| 5664 | case 4: |
| 5665 | nss = 4; |
| 5666 | break; |
| 5667 | default: |
| 5668 | nss = 3; |
| 5669 | break; |
| 5670 | } |
| 5671 | |
| 5672 | if (dut->ap_fixed_rate) { |
| 5673 | if (nss == 4) |
| 5674 | ath_disable_txbf(dut, ifname); |
| 5675 | |
| 5676 | /* Set the nss */ |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 5677 | run_iwpriv(dut, ifname, "nss %d", nss); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5678 | |
| 5679 | /* Set the channel width */ |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 5680 | run_iwpriv(dut, ifname, "chwidth %d", chwidth); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5681 | |
| 5682 | /* Set the VHT MCS */ |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 5683 | run_iwpriv(dut, ifname, "vhtmcs %d", dut->ap_mcs); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5684 | } |
| 5685 | } |
| 5686 | |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 5687 | if (dut->ap_dyn_bw_sig == VALUE_ENABLED) |
| 5688 | run_iwpriv(dut, ifname, "cwmenable 1"); |
| 5689 | else if (dut->ap_dyn_bw_sig == VALUE_DISABLED) |
| 5690 | run_iwpriv(dut, ifname, "cwmenable 0"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5691 | |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 5692 | if (dut->ap_sig_rts == VALUE_ENABLED) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5693 | snprintf(buf, sizeof(buf), "iwconfig %s rts 64", ifname); |
| 5694 | if (system(buf) != 0) { |
| 5695 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5696 | "iwconfig rts 64 failed"); |
| 5697 | } |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 5698 | } else if (dut->ap_sig_rts == VALUE_DISABLED) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5699 | snprintf(buf, sizeof(buf), "iwconfig %s rts 2347", ifname); |
| 5700 | if (system(buf) != 0) { |
| 5701 | sigma_dut_print(dut, DUT_MSG_ERROR, |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 5702 | "iwconfig rts 2347 failed"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5703 | } |
| 5704 | } |
| 5705 | |
| 5706 | if (dut->ap_hs2) { |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 5707 | run_iwpriv(dut, ifname, "qbssload 1"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5708 | sigma_dut_print(dut, DUT_MSG_INFO, "Enabled qbssload"); |
| 5709 | } |
| 5710 | |
| 5711 | if (dut->ap_bss_load && dut->ap_bss_load != -1) { |
| 5712 | unsigned int bssload = 0; |
| 5713 | |
| 5714 | if (dut->ap_bss_load == 1) { |
| 5715 | /* STA count: 1, CU: 50, AAC: 65535 */ |
| 5716 | bssload = 0x0132ffff; |
| 5717 | } else if (dut->ap_bss_load == 2) { |
| 5718 | /* STA count: 1, CU: 200, AAC: 65535 */ |
| 5719 | bssload = 0x01c8ffff; |
| 5720 | } else if (dut->ap_bss_load == 3) { |
| 5721 | /* STA count: 1, CU: 75, AAC: 65535 */ |
| 5722 | bssload = 0x014bffff; |
| 5723 | } |
| 5724 | |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 5725 | run_iwpriv(dut, ifname, "hcbssload %u", bssload); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5726 | } else if (dut->ap_bss_load == 0) { |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 5727 | run_iwpriv(dut, ifname, "qbssload 0"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5728 | sigma_dut_print(dut, DUT_MSG_INFO, "Disabled qbssload"); |
| 5729 | } |
| 5730 | |
| 5731 | if (dut->ap_dgaf_disable) { |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 5732 | run_iwpriv(dut, ifname, "dgaf_disable 1"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5733 | sigma_dut_print(dut, DUT_MSG_INFO, "Enabled dgaf_disable"); |
| 5734 | } |
| 5735 | |
| 5736 | if (dut->ap_l2tif) { |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 5737 | run_iwpriv(dut, ifname, "l2tif 1"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5738 | snprintf(buf, sizeof(buf), |
| 5739 | "echo 1 > /sys/class/net/br0/brif/ath0/hotspot_l2tif"); |
| 5740 | if (system(buf) != 0) |
| 5741 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5742 | "l2tif br failed"); |
| 5743 | |
| 5744 | snprintf(buf, sizeof(buf), |
| 5745 | "echo 1 > /sys/class/net/br0/brif/eth0/hotspot_wan"); |
| 5746 | if (system(buf) != 0) |
| 5747 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5748 | "l2tif brif failed"); |
| 5749 | sigma_dut_print(dut, DUT_MSG_INFO, "Enabled l2tif"); |
| 5750 | } |
priyadharshini gowthaman | 264d544 | 2016-02-25 15:52:22 -0800 | [diff] [blame] | 5751 | |
| 5752 | if (dut->ap_ndpa_frame == 0) { |
| 5753 | snprintf(buf, sizeof(buf), |
| 5754 | "wifitool %s beeliner_fw_test 117 192", ifname); |
| 5755 | if (system(buf) != 0) { |
| 5756 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5757 | "wifitool beeliner_fw_test 117 192 failed"); |
| 5758 | } |
| 5759 | snprintf(buf, sizeof(buf), |
| 5760 | "wifitool %s beeliner_fw_test 118 192", ifname); |
| 5761 | if (system(buf) != 0) { |
| 5762 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5763 | "wifitool beeliner_fw_test 117 192 failed"); |
| 5764 | } |
| 5765 | } else if (dut->ap_ndpa_frame == 1) { |
| 5766 | /* Driver default - no changes needed */ |
| 5767 | } else if (dut->ap_ndpa_frame == 2) { |
| 5768 | snprintf(buf, sizeof(buf), |
| 5769 | "wifitool %s beeliner_fw_test 115 1", ifname); |
| 5770 | if (system(buf) != 0) { |
| 5771 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5772 | "wifitool beeliner_fw_test 117 192 failed"); |
| 5773 | } |
| 5774 | snprintf(buf, sizeof(buf), |
| 5775 | "wifitool %s beeliner_fw_test 116 1", ifname); |
| 5776 | if (system(buf) != 0) { |
| 5777 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5778 | "wifitool beeliner_fw_test 117 192 failed"); |
| 5779 | } |
| 5780 | } |
priyadharshini gowthaman | 8e26ff4 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 5781 | |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 5782 | if (dut->ap_rtt == 1) |
| 5783 | run_iwpriv(dut, ifname, "enable_rtt 1"); |
priyadharshini gowthaman | 8e26ff4 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 5784 | |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 5785 | if (dut->ap_lci == 1) |
| 5786 | run_iwpriv(dut, ifname, "enable_lci 1"); |
priyadharshini gowthaman | 8e26ff4 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 5787 | |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 5788 | if (dut->ap_lcr == 1) |
| 5789 | run_iwpriv(dut, ifname, "enable_lcr 1"); |
priyadharshini gowthaman | 8e26ff4 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 5790 | |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 5791 | if (dut->ap_rrm == 1) |
| 5792 | run_iwpriv(dut, ifname, "enable_rmm 1"); |
priyadharshini gowthaman | 8e26ff4 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 5793 | |
| 5794 | if (dut->ap_lci == 1 || dut->ap_lcr == 1) { |
| 5795 | run_system(dut, "wpc -l /tmp/lci_cfg.txt"); |
| 5796 | } |
| 5797 | |
| 5798 | if (dut->ap_neighap >= 1 && dut->ap_lci == 0) { |
| 5799 | FILE *f; |
| 5800 | |
| 5801 | f = fopen("/tmp/nbr_report.txt", "w"); |
| 5802 | if (!f) { |
| 5803 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5804 | "Failed to open /tmp/nbr_report.txt"); |
| 5805 | return; |
| 5806 | } |
| 5807 | |
| 5808 | fprintf(f, |
| 5809 | "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", |
| 5810 | dut->ap_val_neighap[0][0], dut->ap_val_neighap[0][1], |
| 5811 | dut->ap_val_neighap[0][2], dut->ap_val_neighap[0][3], |
| 5812 | dut->ap_val_neighap[0][4], dut->ap_val_neighap[0][5], |
| 5813 | dut->ap_val_opchannel[0]); |
| 5814 | fclose(f); |
| 5815 | |
| 5816 | f = fopen("/tmp/ftmrr.txt", "w"); |
| 5817 | if (!f) { |
| 5818 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5819 | "Failed to open /tmp/ftmrr.txt"); |
| 5820 | return; |
| 5821 | } |
| 5822 | |
| 5823 | fprintf(f, |
| 5824 | "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", |
| 5825 | dut->ap_val_neighap[0][0], dut->ap_val_neighap[0][1], |
| 5826 | dut->ap_val_neighap[0][2], dut->ap_val_neighap[0][3], |
| 5827 | dut->ap_val_neighap[0][4], dut->ap_val_neighap[0][5], |
| 5828 | dut->ap_val_opchannel[0]); |
| 5829 | fclose(f); |
| 5830 | } |
| 5831 | |
| 5832 | if (dut->ap_neighap >= 2 && dut->ap_lci == 0) { |
| 5833 | FILE *f; |
| 5834 | |
| 5835 | f = fopen("/tmp/nbr_report.txt", "a"); |
| 5836 | if (!f) { |
| 5837 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5838 | "Failed to open /tmp/nbr_report.txt"); |
| 5839 | return; |
| 5840 | } |
| 5841 | fprintf(f, |
| 5842 | "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", |
| 5843 | dut->ap_val_neighap[1][0], dut->ap_val_neighap[1][1], |
| 5844 | dut->ap_val_neighap[1][2], dut->ap_val_neighap[1][3], |
| 5845 | dut->ap_val_neighap[1][4], dut->ap_val_neighap[1][5], |
| 5846 | dut->ap_val_opchannel[1]); |
| 5847 | fclose(f); |
| 5848 | |
| 5849 | f = fopen("/tmp/ftmrr.txt", "a"); |
| 5850 | if (!f) { |
| 5851 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5852 | "Failed to open /tmp/ftmrr.txt"); |
| 5853 | return; |
| 5854 | } |
| 5855 | fprintf(f, |
| 5856 | "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", |
| 5857 | dut->ap_val_neighap[1][0], dut->ap_val_neighap[1][1], |
| 5858 | dut->ap_val_neighap[1][2], dut->ap_val_neighap[1][3], |
| 5859 | dut->ap_val_neighap[1][4], dut->ap_val_neighap[1][5], |
| 5860 | dut->ap_val_opchannel[1]); |
| 5861 | fclose(f); |
| 5862 | } |
| 5863 | |
| 5864 | if (dut->ap_neighap >= 3 && dut->ap_lci == 0) { |
| 5865 | FILE *f; |
| 5866 | |
| 5867 | f = fopen("/tmp/nbr_report.txt", "a"); |
| 5868 | if (!f) { |
| 5869 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5870 | "Failed to open /tmp/nbr_report.txt"); |
| 5871 | return; |
| 5872 | } |
| 5873 | |
| 5874 | fprintf(f, |
| 5875 | "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", |
| 5876 | dut->ap_val_neighap[2][0], dut->ap_val_neighap[2][1], |
| 5877 | dut->ap_val_neighap[2][2], dut->ap_val_neighap[2][3], |
| 5878 | dut->ap_val_neighap[2][4], dut->ap_val_neighap[2][5], |
| 5879 | dut->ap_val_opchannel[2]); |
| 5880 | fclose(f); |
| 5881 | |
| 5882 | f = fopen("/tmp/ftmrr.txt", "a"); |
| 5883 | if (!f) { |
| 5884 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5885 | "Failed to open /tmp/ftmrr.txt"); |
| 5886 | return; |
| 5887 | } |
| 5888 | |
| 5889 | fprintf(f, |
| 5890 | "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", |
| 5891 | dut->ap_val_neighap[2][0], dut->ap_val_neighap[2][1], |
| 5892 | dut->ap_val_neighap[2][2], dut->ap_val_neighap[2][3], |
| 5893 | dut->ap_val_neighap[2][4], dut->ap_val_neighap[2][5], |
| 5894 | dut->ap_val_opchannel[2]); |
| 5895 | fclose(f); |
| 5896 | } |
| 5897 | |
| 5898 | if (dut->ap_neighap) { |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 5899 | run_iwpriv(dut, ifname, "enable_rtt 1"); |
| 5900 | run_iwpriv(dut, ifname, "enable_lci 1"); |
| 5901 | run_iwpriv(dut, ifname, "enable_lcr 1"); |
| 5902 | run_iwpriv(dut, ifname, "enable_rrm 1"); |
priyadharshini gowthaman | 8e26ff4 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 5903 | } |
| 5904 | |
| 5905 | if (dut->ap_scan == 1) { |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 5906 | run_iwpriv(dut, ifname, "scanentryage 600"); |
priyadharshini gowthaman | 8e26ff4 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 5907 | snprintf(buf, sizeof(buf), "iwlist %s scan", ifname); |
| 5908 | run_system(dut, buf); |
| 5909 | } |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 5910 | |
| 5911 | if (dut->ap_set_bssidpref) { |
| 5912 | snprintf(buf, sizeof(buf), |
| 5913 | "wifitool %s setbssidpref 00:00:00:00:00:00 0 00 00", |
| 5914 | ifname); |
| 5915 | if (system(buf) != 0) { |
| 5916 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5917 | "wifitool clear bssidpref failed"); |
| 5918 | } |
| 5919 | } |
Adil Saeed Musthafa | 33ea287 | 2017-04-10 23:13:24 -0700 | [diff] [blame] | 5920 | |
| 5921 | if (dut->wnm_bss_max_feature != VALUE_NOT_SET) { |
| 5922 | int feature_enable; |
| 5923 | |
| 5924 | feature_enable = dut->wnm_bss_max_feature == VALUE_ENABLED; |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 5925 | run_iwpriv(dut, ifname, "wnm %d", feature_enable); |
| 5926 | run_iwpriv(dut, ifname, "wnm_bss %d", feature_enable); |
Adil Saeed Musthafa | 33ea287 | 2017-04-10 23:13:24 -0700 | [diff] [blame] | 5927 | if (feature_enable) { |
| 5928 | const char *extra = ""; |
| 5929 | |
| 5930 | if (dut->wnm_bss_max_protection != VALUE_NOT_SET) { |
| 5931 | if (dut->wnm_bss_max_protection == |
| 5932 | VALUE_ENABLED) |
| 5933 | extra = " 1"; |
| 5934 | else |
| 5935 | extra = " 0"; |
| 5936 | } |
| 5937 | snprintf(buf, sizeof(buf), |
| 5938 | "wlanconfig %s wnm setbssmax %d%s", |
| 5939 | ifname, dut->wnm_bss_max_idle_time, extra); |
| 5940 | run_system(dut, buf); |
| 5941 | } |
| 5942 | } |
Adil Saeed Musthafa | 05ec744 | 2017-04-10 23:13:35 -0700 | [diff] [blame] | 5943 | |
Adil Saeed Musthafa | 023108a | 2017-04-10 23:13:37 -0700 | [diff] [blame] | 5944 | if (dut->program == PROGRAM_MBO) { |
Adil Saeed Musthafa | 6906372 | 2017-04-10 23:13:40 -0700 | [diff] [blame] | 5945 | apply_mbo_pref_ap_list(dut); |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 5946 | run_iwpriv(dut, ifname, "mbo_cel_pref %d", |
| 5947 | dut->ap_cell_cap_pref); |
| 5948 | run_iwpriv(dut, ifname, "mbocap 0x40"); |
Adil Saeed Musthafa | 05ec744 | 2017-04-10 23:13:35 -0700 | [diff] [blame] | 5949 | ath_set_assoc_disallow(dut, ifname, "disable"); |
Adil Saeed Musthafa | 023108a | 2017-04-10 23:13:37 -0700 | [diff] [blame] | 5950 | } |
priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 5951 | |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 5952 | if (dut->ap_oce == VALUE_ENABLED) |
| 5953 | run_iwpriv(dut, ifname, "set_bpr_enable 1"); |
priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 5954 | |
| 5955 | if (dut->ap_oce == VALUE_ENABLED && dut->ap_channel <= 11) { |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 5956 | run_iwpriv(dut, ifname, "prb_rate 5500"); |
| 5957 | run_iwpriv(dut, ifname, "set_bcn_rate 5500"); |
priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 5958 | } |
| 5959 | |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 5960 | if (dut->ap_oce == VALUE_DISABLED) |
| 5961 | run_iwpriv(dut, ifname, "set_bpr_enable 0"); |
priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 5962 | |
| 5963 | if (dut->ap_oce == VALUE_DISABLED && dut->ap_channel <= 11) { |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 5964 | run_iwpriv(dut, ifname, "mgmt_rate 1000"); |
| 5965 | run_iwpriv(dut, ifname, "set_bcn_rate 1000"); |
priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 5966 | } |
| 5967 | |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 5968 | if (dut->ap_bcnint) |
| 5969 | run_iwpriv(dut, ifname, "bintval %d", dut->ap_bcnint); |
priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 5970 | |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 5971 | if (dut->ap_filsdscv == VALUE_DISABLED) |
| 5972 | run_iwpriv(dut, ifname, "enable_fils 0 0"); |
priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 5973 | |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 5974 | if (dut->ap_filshlp == VALUE_ENABLED) |
| 5975 | run_iwpriv(dut, ifname, "oce_hlp 1"); |
| 5976 | else if (dut->ap_filshlp == VALUE_DISABLED) |
| 5977 | run_iwpriv(dut, ifname, "oce_hlp 0"); |
priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 5978 | |
| 5979 | /* When RNR is enabled, also enable apchannelreport, background scan */ |
| 5980 | if (dut->ap_rnr == VALUE_ENABLED) { |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 5981 | run_iwpriv(dut, ifname, "rnr 1"); |
| 5982 | run_iwpriv(dut, ifname, "rnr_tbtt 1"); |
| 5983 | run_iwpriv(dut, ifname, "apchanrpt 1"); |
| 5984 | run_iwpriv(dut, basedev, "acs_ctrlflags 0x4"); |
| 5985 | run_iwpriv(dut, basedev, "acs_scanintvl 60"); |
| 5986 | run_iwpriv(dut, basedev, "acs_bkscanen 1"); |
priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 5987 | if (dut->ap_is_dual == 1) { |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 5988 | run_iwpriv(dut, ifname_dual, "rnr 1"); |
| 5989 | run_iwpriv(dut, ifname_dual, "rnr_tbtt 1"); |
| 5990 | run_iwpriv(dut, ifname_dual, "apchanrpt 1"); |
| 5991 | run_iwpriv(dut, basedev_radio, "acs_ctrlflags 0x4"); |
| 5992 | run_iwpriv(dut, basedev_radio, "acs_scanintvl 60"); |
| 5993 | run_iwpriv(dut, basedev_radio, "acs_bkscanen 1"); |
priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 5994 | } |
| 5995 | } |
| 5996 | |
| 5997 | if (dut->ap_blechanutil || dut->ap_ble_admit_cap || dut->ap_blestacnt) { |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 5998 | run_iwpriv(dut, ifname, "qbssload 0"); |
priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 5999 | snprintf(buf, sizeof(buf), |
| 6000 | "wlanconfig %s addie ftype 0 len 7 data 0b05%02x%02x%02x%02x%02x ", |
| 6001 | ifname, dut->ap_blestacnt & 0xFF, |
| 6002 | dut->ap_blestacnt >> 8, dut->ap_blechanutil, |
| 6003 | dut->ap_ble_admit_cap & 0xFF, |
| 6004 | dut->ap_ble_admit_cap >> 8); |
| 6005 | run_system(dut, buf); |
| 6006 | snprintf(buf, sizeof(buf), |
| 6007 | "wlanconfig %s addie ftype 2 len 7 data 0b05%02x%02x%02x%02x%02x ", |
| 6008 | ifname, dut->ap_blestacnt & 0xFF, |
| 6009 | dut->ap_blestacnt >> 8, dut->ap_blechanutil, |
| 6010 | dut->ap_ble_admit_cap & 0xFF, |
| 6011 | dut->ap_ble_admit_cap >> 8); |
| 6012 | run_system(dut, buf); |
| 6013 | } |
| 6014 | |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 6015 | if (dut->ap_esp == VALUE_ENABLED) |
| 6016 | run_iwpriv(dut, basedev, "esp_period 5"); |
| 6017 | else if (dut->ap_esp == VALUE_DISABLED) |
| 6018 | run_iwpriv(dut, basedev, "esp_period 0"); |
priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 6019 | |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 6020 | if (dut->ap_datappdudura) |
| 6021 | run_iwpriv(dut, basedev, "esp_ppdu_dur %d", |
| 6022 | dut->ap_datappdudura); |
priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 6023 | |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 6024 | if (dut->ap_airtimefract) |
| 6025 | run_iwpriv(dut, basedev, "esp_airtime %d", |
| 6026 | dut->ap_airtimefract); |
priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 6027 | |
| 6028 | if (dut->ap_dhcp_stop) { |
| 6029 | snprintf(buf, sizeof(buf), "/etc/init.d/dnsmasq stop"); |
| 6030 | run_system(dut, buf); |
| 6031 | } |
| 6032 | |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 6033 | if (dut->ap_bawinsize) |
| 6034 | run_iwpriv(dut, basedev, "esp_ba_window %d", dut->ap_bawinsize); |
priyadharshini gowthaman | b4de196 | 2018-01-15 12:21:04 -0800 | [diff] [blame] | 6035 | |
| 6036 | if (dut->program == PROGRAM_DPP) { |
| 6037 | if (dut->ap_interface_2g == 1) { |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 6038 | run_iwpriv(dut, ifname, "set_bcn_rate 5500"); |
| 6039 | run_iwpriv(dut, ifname, "prb_rate 5500"); |
| 6040 | run_iwpriv(dut, ifname, "mgmt_rate 5500"); |
priyadharshini gowthaman | b4de196 | 2018-01-15 12:21:04 -0800 | [diff] [blame] | 6041 | } |
| 6042 | |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 6043 | run_iwpriv(dut, basedev, "set_rxfilter 0xffffffff"); |
priyadharshini gowthaman | b4de196 | 2018-01-15 12:21:04 -0800 | [diff] [blame] | 6044 | dut->hostapd_running = 1; |
| 6045 | } |
priyadharshini gowthaman | 350f191 | 2018-06-04 13:09:12 -0700 | [diff] [blame] | 6046 | |
Priyadharshini Gowthaman | fe60c50 | 2019-08-14 13:00:34 -0700 | [diff] [blame] | 6047 | if (dut->ap_he_ulofdma == VALUE_ENABLED) { |
| 6048 | run_iwpriv(dut, ifname, "he_ul_ofdma 1"); |
| 6049 | run_iwpriv(dut, ifname, "he_mu_edca 1"); |
| 6050 | |
| 6051 | /* Disable sounding for UL OFDMA */ |
| 6052 | run_system_wrapper(dut, "wifitool %s setUnitTestCmd 0x47 2 7 0", |
priyadharshini gowthaman | 350f191 | 2018-06-04 13:09:12 -0700 | [diff] [blame] | 6053 | ifname); |
Priyadharshini Gowthaman | fe60c50 | 2019-08-14 13:00:34 -0700 | [diff] [blame] | 6054 | |
| 6055 | if ((dut->ap_rx_streams || dut->ap_tx_streams) && |
| 6056 | dut->device_type == AP_testbed) { |
| 6057 | unsigned int txchainmask = 0x00; |
| 6058 | |
| 6059 | switch (dut->ap_rx_streams) { |
| 6060 | case 1: |
| 6061 | txchainmask = 0x01; |
| 6062 | break; |
| 6063 | case 2: |
| 6064 | txchainmask = 0x03; |
| 6065 | break; |
| 6066 | case 3: |
| 6067 | txchainmask = 0x07; |
| 6068 | break; |
| 6069 | case 4: |
| 6070 | txchainmask = 0x0f; |
| 6071 | break; |
| 6072 | case 5: |
| 6073 | txchainmask = 0x1f; |
| 6074 | break; |
| 6075 | case 6: |
| 6076 | txchainmask = 0x3f; |
| 6077 | break; |
| 6078 | case 7: |
| 6079 | txchainmask = 0x7f; |
| 6080 | break; |
| 6081 | case 8: |
| 6082 | txchainmask = 0xff; |
| 6083 | break; |
| 6084 | } |
| 6085 | |
| 6086 | run_iwpriv(dut, ifname, "he_ul_nss %d", |
| 6087 | dut->ap_rx_streams); |
| 6088 | run_iwpriv(dut, basedev, "txchainmask %d", txchainmask); |
| 6089 | run_iwpriv(dut, basedev, "rxchainmask %d", txchainmask); |
| 6090 | } |
| 6091 | |
| 6092 | if (dut->ap_channel == 100 && dut->device_type == AP_testbed) |
| 6093 | run_system_wrapper(dut, "iwpriv %s inact 1000", ifname); |
| 6094 | |
| 6095 | run_iwpriv(dut, ifname, "he_ul_ltf 3"); |
| 6096 | run_iwpriv(dut, ifname, "he_ul_shortgi 3"); |
| 6097 | run_iwpriv(dut, basedev, "he_ul_trig_int 2"); |
| 6098 | |
| 6099 | /* Set random RU allocation */ |
| 6100 | run_system_wrapper(dut, "wifitool %s setUnitTestCmd 0x47 2 9 1", |
| 6101 | ifname); |
| 6102 | /* To set TBTT PPDU duration (us) */ |
| 6103 | run_system_wrapper(dut, |
| 6104 | "wifitool %s setUnitTestCmd 0x48 2 63 1908", |
| 6105 | ifname); |
| 6106 | } |
| 6107 | |
| 6108 | if (dut->program == PROGRAM_HE && dut->device_type == AP_testbed && |
| 6109 | dut->ap_he_dlofdma == VALUE_DISABLED) |
| 6110 | run_iwpriv(dut, ifname, "he_dl_ofdma 0"); |
| 6111 | |
| 6112 | if (dut->ap_he_dlofdma == VALUE_ENABLED) { |
| 6113 | run_iwpriv(dut, ifname, "he_dl_ofdma 1", ifname); |
| 6114 | |
| 6115 | /* For fixed MCS */ |
| 6116 | novap_reset(dut, ifname, 0); |
| 6117 | run_iwpriv(dut, ifname, |
| 6118 | "cfg80211tool %s setratemask 3 0x80f80f80 0x0f80f80f 0xf80f80f8"); |
| 6119 | } |
| 6120 | |
| 6121 | if (dut->ap_he_ppdu == PPDU_MU && dut->ap_he_dlofdma == VALUE_ENABLED) { |
| 6122 | /* Increase the min TX time limit for MU MIMO to disable MU MIMO |
| 6123 | * scheduling */ |
| 6124 | run_system_wrapper(dut, |
| 6125 | "wifitool %s setUnitTestCmd 0x47 2 11 1000000", |
| 6126 | ifname); |
| 6127 | /* Increase the max TX time limit for DL OFDMA to enable OFDMA |
| 6128 | * scheduling */ |
| 6129 | run_system_wrapper(dut, |
| 6130 | "wifitool %s setUnitTestCmd 0x47 2 17 1000000", |
| 6131 | ifname); |
| 6132 | /* Disable 'force SU schedule' to enable MU sch */ |
| 6133 | run_system_wrapper(dut, "wifitool %s setUnitTestCmd 0x47 2 8 0", |
| 6134 | ifname); |
| 6135 | /* Enable MU 11ax support in sch algo */ |
priyadharshini gowthaman | 350f191 | 2018-06-04 13:09:12 -0700 | [diff] [blame] | 6136 | run_system_wrapper(dut, |
| 6137 | "wifitool %s setUnitTestCmd 0x47 2 29 0", |
| 6138 | ifname); |
Priyadharshini Gowthaman | fe60c50 | 2019-08-14 13:00:34 -0700 | [diff] [blame] | 6139 | /* Enable to sort RU allocation */ |
| 6140 | run_system_wrapper(dut, "wifitool %s setUnitTestCmd 0x4b 2 2 1", |
| 6141 | ifname); |
priyadharshini gowthaman | 350f191 | 2018-06-04 13:09:12 -0700 | [diff] [blame] | 6142 | } |
Priyadharshini Gowthaman | bc94889 | 2019-09-10 14:22:49 -0700 | [diff] [blame] | 6143 | |
| 6144 | if (dut->ap_numsounddim) { |
| 6145 | unsigned int txchainmask = 0; |
| 6146 | |
| 6147 | switch (dut->ap_numsounddim) { |
| 6148 | case 1: |
| 6149 | txchainmask = 0x01; |
| 6150 | break; |
| 6151 | case 2: |
| 6152 | txchainmask = 0x03; |
| 6153 | break; |
| 6154 | case 3: |
| 6155 | txchainmask = 0x07; |
| 6156 | break; |
| 6157 | case 4: |
| 6158 | txchainmask = 0x0f; |
| 6159 | break; |
| 6160 | case 5: |
| 6161 | txchainmask = 0x1f; |
| 6162 | break; |
| 6163 | case 6: |
| 6164 | txchainmask = 0x3f; |
| 6165 | break; |
| 6166 | case 7: |
| 6167 | txchainmask = 0x7f; |
| 6168 | break; |
| 6169 | case 8: |
| 6170 | txchainmask = 0xff; |
| 6171 | break; |
| 6172 | } |
| 6173 | run_iwpriv(dut, basedev, "txchainmask %d", txchainmask); |
| 6174 | } |
| 6175 | |
| 6176 | if (dut->ap_numsounddim && dut->device_type == AP_testbed) { |
| 6177 | /* Sets g_force_1x1_peer to 1 which should be reset to zero |
| 6178 | * for non-MU test cases */ |
| 6179 | run_system_wrapper(dut, |
| 6180 | "wifitool %s setUnitTestCmd 0x48 2 118 1", |
| 6181 | ifname); |
| 6182 | if (dut->ap_mu_txBF) { |
| 6183 | /* Disable DL OFDMA */ |
| 6184 | run_system_wrapper(dut, |
| 6185 | "wifitool %s setUnitTestCmd 0x47 2 11 0", |
| 6186 | ifname); |
| 6187 | } |
| 6188 | } |
Priyadharshini Gowthaman | 670b323 | 2019-09-10 16:09:19 -0700 | [diff] [blame] | 6189 | |
| 6190 | if (dut->ap_channel <= 11 && dut->program == PROGRAM_HE && |
| 6191 | dut->device_type == AP_testbed) { |
| 6192 | dut->ap_bcc = VALUE_ENABLED; |
| 6193 | run_iwpriv(dut, ifname, "vht_11ng 0"); |
| 6194 | } |
| 6195 | |
| 6196 | if (dut->ap_bcc == VALUE_ENABLED) { |
| 6197 | run_iwpriv(dut, ifname, "mode 11AHE20"); |
| 6198 | run_iwpriv(dut, ifname, "nss 2"); |
| 6199 | run_iwpriv(dut, ifname, "he_txmcsmap 0x0"); |
| 6200 | run_iwpriv(dut, ifname, "he_rxmcsmap 0x0"); |
| 6201 | } |
Priyadharshini Gowthaman | 6bc4c1e | 2019-09-10 16:24:51 -0700 | [diff] [blame] | 6202 | |
| 6203 | if (dut->ap_he_frag == VALUE_ENABLED) |
| 6204 | run_iwpriv(dut, ifname, "he_frag 1"); |
| 6205 | else if (dut->ap_he_frag == VALUE_DISABLED) |
| 6206 | run_iwpriv(dut, ifname, "he_frag 0"); |
Priyadharshini Gowthaman | 1a686bd | 2019-09-19 14:41:40 -0700 | [diff] [blame] | 6207 | |
| 6208 | if (dut->ap_ba_bufsize != BA_BUFSIZE_NOT_SET) { |
| 6209 | if (dut->ap_ba_bufsize == BA_BUFSIZE_64) |
| 6210 | run_iwpriv(dut, ifname, "ba_bufsize 0"); |
| 6211 | else |
| 6212 | run_iwpriv(dut, ifname, "ba_bufsize 1"); |
| 6213 | } |
Priyadharshini Gowthaman | 21895a5 | 2019-10-07 16:56:16 -0700 | [diff] [blame] | 6214 | |
| 6215 | if (dut->ap_mu_edca == VALUE_ENABLED) |
| 6216 | run_iwpriv(dut, ifname, "he_mu_edca 1"); |
Priyadharshini Gowthaman | dee79e2 | 2019-10-07 16:56:27 -0700 | [diff] [blame] | 6217 | |
| 6218 | if (dut->ap_he_mimo == MIMO_DL) { |
| 6219 | mubrp_commands(dut, ifname); |
| 6220 | if (dut->device_type != AP_testbed) |
| 6221 | run_system_wrapper( |
| 6222 | dut, "wifitool %s setUnitTestCmd 0x48 2 100 2", |
| 6223 | ifname); |
| 6224 | } |
| 6225 | |
| 6226 | if (dut->ap_he_mimo == MIMO_UL) |
| 6227 | run_iwpriv(dut, ifname, "he_mubfee 1"); |
Priyadharshini Gowthaman | 43d6b41 | 2019-10-07 16:56:37 -0700 | [diff] [blame] | 6228 | |
| 6229 | if (dut->ap_he_rtsthrshld == VALUE_ENABLED) |
| 6230 | run_iwpriv(dut, ifname, "he_rtsthrshld 512"); |
| 6231 | else if (dut->ap_he_rtsthrshld == VALUE_DISABLED) |
| 6232 | run_iwpriv(dut, ifname, "he_rtsthrshld 1024"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6233 | } |
| 6234 | |
| 6235 | |
| 6236 | static int cmd_ath_ap_config_commit(struct sigma_dut *dut, |
| 6237 | struct sigma_conn *conn, |
| 6238 | struct sigma_cmd *cmd) |
| 6239 | { |
| 6240 | /* const char *name = get_param(cmd, "NAME"); */ |
| 6241 | char buf[100]; |
| 6242 | struct stat s; |
| 6243 | const char *ifname = dut->ap_is_dual ? "ath1" : "ath0"; |
Jouni Malinen | 3aa7286 | 2019-05-29 23:14:51 +0300 | [diff] [blame] | 6244 | int res; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6245 | |
| 6246 | if (stat("/proc/athversion", &s) == 0) { |
| 6247 | sigma_dut_print(dut, DUT_MSG_INFO, "Run apdown"); |
| 6248 | run_system(dut, "apdown"); |
| 6249 | } |
| 6250 | |
| 6251 | cmd_ath_ap_radio_config(dut); |
| 6252 | |
| 6253 | snprintf(buf, sizeof(buf), "cfg -a 'AP_SSID=%s'", dut->ap_ssid); |
| 6254 | run_system(dut, buf); |
| 6255 | |
| 6256 | switch (dut->ap_key_mgmt) { |
| 6257 | case AP_OPEN: |
| 6258 | if (dut->ap_cipher == AP_WEP) { |
| 6259 | run_system(dut, "cfg -a AP_SECMODE=WEP"); |
| 6260 | run_system(dut, "cfg -a AP_SECFILE=NONE"); |
| 6261 | /* shared auth mode not supported */ |
| 6262 | run_system(dut, "cfg -a AP_WEP_MODE_0=1"); |
| 6263 | run_system(dut, "cfg -a AP_WEP_MODE_1=1"); |
| 6264 | snprintf(buf, sizeof(buf), |
| 6265 | "cfg -a WEP_RADIO_NUM0_KEY_1=%s", |
| 6266 | dut->ap_wepkey); |
| 6267 | run_system(dut, buf); |
| 6268 | snprintf(buf, sizeof(buf), |
| 6269 | "cfg -a WEP_RADIO_NUM1_KEY_1=%s", |
| 6270 | dut->ap_wepkey); |
| 6271 | run_system(dut, buf); |
| 6272 | } else { |
| 6273 | run_system(dut, "cfg -a AP_SECMODE=None"); |
| 6274 | } |
| 6275 | break; |
| 6276 | case AP_WPA2_PSK: |
| 6277 | case AP_WPA2_PSK_MIXED: |
| 6278 | case AP_WPA_PSK: |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 6279 | case AP_WPA2_SAE: |
| 6280 | case AP_WPA2_PSK_SAE: |
| 6281 | if (dut->ap_key_mgmt == AP_WPA2_PSK || |
| 6282 | dut->ap_key_mgmt == AP_WPA2_SAE || |
| 6283 | dut->ap_key_mgmt == AP_WPA2_PSK_SAE) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6284 | run_system(dut, "cfg -a AP_WPA=2"); |
| 6285 | else if (dut->ap_key_mgmt == AP_WPA2_PSK_MIXED) |
| 6286 | run_system(dut, "cfg -a AP_WPA=3"); |
| 6287 | else |
| 6288 | run_system(dut, "cfg -a AP_WPA=1"); |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 6289 | /* TODO: SAE configuration */ |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6290 | run_system(dut, "cfg -a AP_SECMODE=WPA"); |
| 6291 | run_system(dut, "cfg -a AP_SECFILE=PSK"); |
Jouni Malinen | 3aa7286 | 2019-05-29 23:14:51 +0300 | [diff] [blame] | 6292 | res = snprintf(buf, sizeof(buf), "cfg -a 'PSK_KEY=%s'", |
| 6293 | dut->ap_passphrase); |
| 6294 | if (res < 0 || res >= sizeof(buf)) |
| 6295 | return ERROR_SEND_STATUS; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6296 | run_system(dut, buf); |
| 6297 | if (dut->ap_cipher == AP_CCMP_TKIP) |
| 6298 | run_system(dut, "cfg -a AP_CYPHER=\"CCMP TKIP\""); |
| 6299 | else if (dut->ap_cipher == AP_TKIP) |
| 6300 | run_system(dut, "cfg -a AP_CYPHER=TKIP"); |
| 6301 | else |
| 6302 | run_system(dut, "cfg -a AP_CYPHER=CCMP"); |
| 6303 | break; |
| 6304 | case AP_WPA2_EAP: |
| 6305 | case AP_WPA2_EAP_MIXED: |
| 6306 | case AP_WPA_EAP: |
| 6307 | if (dut->ap_key_mgmt == AP_WPA2_EAP) |
| 6308 | run_system(dut, "cfg -a AP_WPA=2"); |
| 6309 | else if (dut->ap_key_mgmt == AP_WPA2_EAP_MIXED) |
| 6310 | run_system(dut, "cfg -a AP_WPA=3"); |
| 6311 | else |
| 6312 | run_system(dut, "cfg -a AP_WPA=1"); |
| 6313 | run_system(dut, "cfg -a AP_SECMODE=WPA"); |
| 6314 | run_system(dut, "cfg -a AP_SECFILE=EAP"); |
| 6315 | if (dut->ap_cipher == AP_CCMP_TKIP) |
| 6316 | run_system(dut, "cfg -a AP_CYPHER=\"CCMP TKIP\""); |
| 6317 | else if (dut->ap_cipher == AP_TKIP) |
| 6318 | run_system(dut, "cfg -a AP_CYPHER=TKIP"); |
| 6319 | else |
| 6320 | run_system(dut, "cfg -a AP_CYPHER=CCMP"); |
| 6321 | snprintf(buf, sizeof(buf), "cfg -a AP_AUTH_SERVER=%s", |
| 6322 | dut->ap_radius_ipaddr); |
| 6323 | run_system(dut, buf); |
| 6324 | snprintf(buf, sizeof(buf), "cfg -a AP_AUTH_PORT=%d", |
| 6325 | dut->ap_radius_port); |
| 6326 | run_system(dut, buf); |
Jouni Malinen | 3aa7286 | 2019-05-29 23:14:51 +0300 | [diff] [blame] | 6327 | res = snprintf(buf, sizeof(buf), "cfg -a AP_AUTH_SECRET=%s", |
| 6328 | dut->ap_radius_password); |
| 6329 | if (res < 0 || res >= sizeof(buf)) |
| 6330 | return ERROR_SEND_STATUS; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6331 | run_system(dut, buf); |
| 6332 | break; |
Jouni Malinen | 4cf699f | 2018-06-19 00:46:27 +0300 | [diff] [blame] | 6333 | case AP_WPA2_EAP_OSEN: |
| 6334 | /* TODO */ |
| 6335 | sigma_dut_print(dut, DUT_MSG_ERROR, "EAP+OSEN not supported"); |
| 6336 | break; |
Jouni Malinen | ad395a2 | 2017-09-01 21:13:46 +0300 | [diff] [blame] | 6337 | case AP_SUITEB: |
| 6338 | /* TODO */ |
| 6339 | sigma_dut_print(dut, DUT_MSG_ERROR, "SuiteB not supported"); |
| 6340 | break; |
Jouni Malinen | 147b3c3 | 2017-10-09 16:51:54 +0300 | [diff] [blame] | 6341 | case AP_WPA2_OWE: |
| 6342 | /* TODO */ |
| 6343 | sigma_dut_print(dut, DUT_MSG_ERROR, "OWE not supported"); |
| 6344 | break; |
Jouni Malinen | 6be21c8 | 2018-08-01 18:47:24 +0300 | [diff] [blame] | 6345 | case AP_WPA2_FT_EAP: |
| 6346 | case AP_WPA2_FT_PSK: |
| 6347 | case AP_WPA2_EAP_SHA256: |
| 6348 | case AP_WPA2_PSK_SHA256: |
| 6349 | case AP_WPA2_ENT_FT_EAP: |
Jouni Malinen | c2b9121 | 2018-09-12 02:26:39 +0300 | [diff] [blame] | 6350 | case AP_OSEN: |
Jouni Malinen | 6be21c8 | 2018-08-01 18:47:24 +0300 | [diff] [blame] | 6351 | /* TODO */ |
| 6352 | send_resp(dut, conn, SIGMA_ERROR, |
| 6353 | "errorCode,Unsupported KeyMgnt value"); |
| 6354 | return 0; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6355 | } |
| 6356 | |
| 6357 | if (dut->ap_is_dual) { |
| 6358 | /* ath1 settings in case of dual */ |
| 6359 | snprintf(buf, sizeof(buf), "cfg -a 'AP_SSID_2=%s'", |
| 6360 | dut->ap_ssid); |
| 6361 | run_system(dut, buf); |
| 6362 | |
| 6363 | switch (dut->ap_key_mgmt) { |
| 6364 | case AP_OPEN: |
| 6365 | if (dut->ap_cipher == AP_WEP) { |
| 6366 | run_system(dut, "cfg -a AP_SECMODE_2=WEP"); |
| 6367 | run_system(dut, "cfg -a AP_SECFILE_2=NONE"); |
| 6368 | /* shared auth mode not supported */ |
| 6369 | run_system(dut, "cfg -a AP_WEP_MODE_0=1"); |
| 6370 | run_system(dut, "cfg -a AP_WEP_MODE_1=1"); |
| 6371 | snprintf(buf, sizeof(buf), |
| 6372 | "cfg -a WEP_RADIO_NUM0_KEY_1=%s", |
| 6373 | dut->ap_wepkey); |
| 6374 | run_system(dut, buf); |
| 6375 | snprintf(buf, sizeof(buf), |
| 6376 | "cfg -a WEP_RADIO_NUM1_KEY_1=%s", |
| 6377 | dut->ap_wepkey); |
| 6378 | run_system(dut, buf); |
| 6379 | } else { |
| 6380 | run_system(dut, "cfg -a AP_SECMODE_2=None"); |
| 6381 | } |
| 6382 | break; |
| 6383 | case AP_WPA2_PSK: |
| 6384 | case AP_WPA2_PSK_MIXED: |
| 6385 | case AP_WPA_PSK: |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 6386 | case AP_WPA2_SAE: |
| 6387 | case AP_WPA2_PSK_SAE: |
| 6388 | if (dut->ap_key_mgmt == AP_WPA2_PSK || |
| 6389 | dut->ap_key_mgmt == AP_WPA2_SAE || |
| 6390 | dut->ap_key_mgmt == AP_WPA2_PSK_SAE) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6391 | run_system(dut, "cfg -a AP_WPA_2=2"); |
| 6392 | else if (dut->ap_key_mgmt == AP_WPA2_PSK_MIXED) |
| 6393 | run_system(dut, "cfg -a AP_WPA_2=3"); |
| 6394 | else |
| 6395 | run_system(dut, "cfg -a AP_WPA_2=1"); |
| 6396 | // run_system(dut, "cfg -a AP_WPA_2=2"); |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 6397 | /* TODO: SAE configuration */ |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6398 | run_system(dut, "cfg -a AP_SECMODE_2=WPA"); |
| 6399 | run_system(dut, "cfg -a AP_SECFILE_2=PSK"); |
Jouni Malinen | 3aa7286 | 2019-05-29 23:14:51 +0300 | [diff] [blame] | 6400 | res = snprintf(buf, sizeof(buf), |
| 6401 | "cfg -a 'PSK_KEY_2=%s'", |
| 6402 | dut->ap_passphrase); |
| 6403 | if (res < 0 || res >= sizeof(buf)) |
| 6404 | return ERROR_SEND_STATUS; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6405 | run_system(dut, buf); |
| 6406 | if (dut->ap_cipher == AP_CCMP_TKIP) |
| 6407 | run_system(dut, "cfg -a AP_CYPHER_2=\"CCMP TKIP\""); |
| 6408 | else if (dut->ap_cipher == AP_TKIP) |
| 6409 | run_system(dut, "cfg -a AP_CYPHER_2=TKIP"); |
| 6410 | else |
| 6411 | run_system(dut, "cfg -a AP_CYPHER_2=CCMP"); |
| 6412 | break; |
| 6413 | case AP_WPA2_EAP: |
| 6414 | case AP_WPA2_EAP_MIXED: |
| 6415 | case AP_WPA_EAP: |
| 6416 | if (dut->ap_key_mgmt == AP_WPA2_EAP) |
| 6417 | run_system(dut, "cfg -a AP_WPA_2=2"); |
| 6418 | else if (dut->ap_key_mgmt == AP_WPA2_EAP_MIXED) |
| 6419 | run_system(dut, "cfg -a AP_WPA_2=3"); |
| 6420 | else |
| 6421 | run_system(dut, "cfg -a AP_WPA_2=1"); |
| 6422 | run_system(dut, "cfg -a AP_SECMODE_2=WPA"); |
| 6423 | run_system(dut, "cfg -a AP_SECFILE_2=EAP"); |
| 6424 | if (dut->ap_cipher == AP_CCMP_TKIP) |
| 6425 | run_system(dut, "cfg -a AP_CYPHER_2=\"CCMP TKIP\""); |
| 6426 | else if (dut->ap_cipher == AP_TKIP) |
| 6427 | run_system(dut, "cfg -a AP_CYPHER_2=TKIP"); |
| 6428 | else |
| 6429 | run_system(dut, "cfg -a AP_CYPHER_2=CCMP"); |
| 6430 | |
| 6431 | snprintf(buf, sizeof(buf), "cfg -a AP_AUTH_SERVER_2=%s", |
| 6432 | dut->ap_radius_ipaddr); |
| 6433 | run_system(dut, buf); |
| 6434 | snprintf(buf, sizeof(buf), "cfg -a AP_AUTH_PORT_2=%d", |
| 6435 | dut->ap_radius_port); |
| 6436 | run_system(dut, buf); |
Jouni Malinen | 3aa7286 | 2019-05-29 23:14:51 +0300 | [diff] [blame] | 6437 | res = snprintf(buf, sizeof(buf), |
| 6438 | "cfg -a AP_AUTH_SECRET_2=%s", |
| 6439 | dut->ap_radius_password); |
| 6440 | if (res < 0 || res >= sizeof(buf)) |
| 6441 | return ERROR_SEND_STATUS; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6442 | run_system(dut, buf); |
| 6443 | break; |
Jouni Malinen | 4cf699f | 2018-06-19 00:46:27 +0300 | [diff] [blame] | 6444 | case AP_WPA2_EAP_OSEN: |
| 6445 | /* TODO */ |
| 6446 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 6447 | "EAP+OSEN not supported"); |
| 6448 | break; |
Jouni Malinen | ad395a2 | 2017-09-01 21:13:46 +0300 | [diff] [blame] | 6449 | case AP_SUITEB: |
| 6450 | /* TODO */ |
| 6451 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 6452 | "SuiteB not supported"); |
| 6453 | break; |
Jouni Malinen | 147b3c3 | 2017-10-09 16:51:54 +0300 | [diff] [blame] | 6454 | case AP_WPA2_OWE: |
| 6455 | /* TODO */ |
| 6456 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 6457 | "OWE not supported"); |
| 6458 | break; |
Jouni Malinen | 6be21c8 | 2018-08-01 18:47:24 +0300 | [diff] [blame] | 6459 | case AP_WPA2_FT_EAP: |
| 6460 | case AP_WPA2_FT_PSK: |
| 6461 | case AP_WPA2_EAP_SHA256: |
| 6462 | case AP_WPA2_PSK_SHA256: |
| 6463 | case AP_WPA2_ENT_FT_EAP: |
Jouni Malinen | c2b9121 | 2018-09-12 02:26:39 +0300 | [diff] [blame] | 6464 | case AP_OSEN: |
Jouni Malinen | 6be21c8 | 2018-08-01 18:47:24 +0300 | [diff] [blame] | 6465 | /* TODO */ |
| 6466 | send_resp(dut, conn, SIGMA_ERROR, |
| 6467 | "errorCode,Unsupported KeyMgnt value"); |
| 6468 | return 0; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6469 | } |
| 6470 | |
| 6471 | /* wifi0 settings in case of dual */ |
| 6472 | run_system(dut, "cfg -a AP_RADIO_ID=0"); |
| 6473 | run_system(dut, "cfg -a AP_PRIMARY_CH=6"); |
| 6474 | run_system(dut, "cfg -a AP_STARTMODE=dual"); |
| 6475 | run_system(dut, "cfg -a AP_CHMODE=11NGHT40PLUS"); |
| 6476 | run_system(dut, "cfg -a TX_CHAINMASK=7"); |
| 6477 | run_system(dut, "cfg -a RX_CHAINMASK=7"); |
| 6478 | } |
| 6479 | |
| 6480 | switch (dut->ap_pmf) { |
| 6481 | case AP_PMF_DISABLED: |
| 6482 | snprintf(buf, sizeof(buf), "cfg -a AP_PMF=0"); |
| 6483 | run_system(dut, buf); |
| 6484 | break; |
| 6485 | case AP_PMF_OPTIONAL: |
| 6486 | snprintf(buf, sizeof(buf), "cfg -a AP_PMF=1"); |
| 6487 | run_system(dut, buf); |
| 6488 | break; |
| 6489 | case AP_PMF_REQUIRED: |
| 6490 | snprintf(buf, sizeof(buf), "cfg -a AP_PMF=2"); |
| 6491 | run_system(dut, buf); |
| 6492 | break; |
| 6493 | } |
| 6494 | if (dut->ap_add_sha256) { |
| 6495 | snprintf(buf, sizeof(buf), "cfg -a AP_WPA_SHA256=1"); |
| 6496 | run_system(dut, buf); |
| 6497 | } else { |
| 6498 | snprintf(buf, sizeof(buf), "cfg -r AP_WPA_SHA256"); |
| 6499 | run_system(dut, buf); |
| 6500 | } |
| 6501 | |
| 6502 | if (dut->ap_hs2) |
| 6503 | run_system(dut, "cfg -a AP_HOTSPOT=1"); |
| 6504 | else |
| 6505 | run_system(dut, "cfg -r AP_HOTSPOT"); |
| 6506 | |
| 6507 | if (dut->ap_interworking) { |
| 6508 | snprintf(buf, sizeof(buf), "cfg -a AP_HOTSPOT_ANT=%d", |
| 6509 | dut->ap_access_net_type); |
| 6510 | run_system(dut, buf); |
| 6511 | snprintf(buf, sizeof(buf), "cfg -a AP_HOTSPOT_INTERNET=%d", |
| 6512 | dut->ap_internet); |
| 6513 | run_system(dut, buf); |
| 6514 | snprintf(buf, sizeof(buf), "cfg -a AP_HOTSPOT_VENUEGROUP=%d", |
| 6515 | dut->ap_venue_group); |
| 6516 | run_system(dut, buf); |
| 6517 | snprintf(buf, sizeof(buf), "cfg -a AP_HOTSPOT_VENUETYPE=%d", |
| 6518 | dut->ap_venue_type); |
| 6519 | run_system(dut, buf); |
| 6520 | snprintf(buf, sizeof(buf), "cfg -a AP_HOTSPOT_HESSID=%s", |
| 6521 | dut->ap_hessid); |
| 6522 | run_system(dut, buf); |
| 6523 | |
| 6524 | if (dut->ap_roaming_cons[0]) { |
| 6525 | char *second, *rc; |
| 6526 | rc = strdup(dut->ap_roaming_cons); |
| 6527 | if (rc == NULL) |
| 6528 | return 0; |
| 6529 | |
| 6530 | second = strchr(rc, ';'); |
| 6531 | if (second) |
| 6532 | *second++ = '\0'; |
| 6533 | |
| 6534 | snprintf(buf, sizeof(buf), |
| 6535 | "cfg -a AP_HOTSPOT_ROAMINGCONSORTIUM=%s", rc); |
| 6536 | run_system(dut, buf); |
| 6537 | |
| 6538 | if (second) { |
| 6539 | snprintf(buf, sizeof(buf), |
| 6540 | "cfg -a AP_HOTSPOT_ROAMINGCONSORTIUM2" |
| 6541 | "=%s", second); |
| 6542 | run_system(dut, buf); |
| 6543 | } |
| 6544 | free(rc); |
| 6545 | } else { |
| 6546 | run_system(dut, "cfg -r AP_HOTSPOT_ROAMINGCONSORTIUM"); |
| 6547 | run_system(dut, |
| 6548 | "cfg -r AP_HOTSPOT_ROAMINGCONSORTIUM2"); |
| 6549 | } |
| 6550 | } else { |
| 6551 | run_system(dut, "cfg -r AP_HOTSPOT_ANT"); |
| 6552 | run_system(dut, "cfg -r AP_HOTSPOT_INTERNET"); |
| 6553 | run_system(dut, "cfg -r AP_HOTSPOT_VENUEGROUP"); |
| 6554 | run_system(dut, "cfg -r AP_HOTSPOT_VENUETYPE"); |
| 6555 | run_system(dut, "cfg -r AP_HOTSPOT_HESSID"); |
| 6556 | run_system(dut, "cfg -r AP_HOTSPOT_ROAMINGCONSORTIUM"); |
| 6557 | run_system(dut, "cfg -r AP_HOTSPOT_ROAMINGCONSORTIUM2"); |
| 6558 | } |
| 6559 | |
| 6560 | if (dut->ap_proxy_arp) |
| 6561 | run_system(dut, "cfg -a IEEE80211V_PROXYARP=1"); |
| 6562 | else |
| 6563 | run_system(dut, "cfg -a IEEE80211V_PROXYARP=0"); |
| 6564 | if (dut->ap_dgaf_disable) |
| 6565 | run_system(dut, "cfg -a AP_HOTSPOT_DISABLE_DGAF=1"); |
| 6566 | else |
| 6567 | run_system(dut, "cfg -r AP_HOTSPOT_DISABLE_DGAF"); |
| 6568 | |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 6569 | if (strlen(dut->ap_tag_ssid[0])) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6570 | snprintf(buf, sizeof(buf), |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 6571 | "cfg -a AP_SSID_2=%s", dut->ap_tag_ssid[0]); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6572 | run_system(dut, buf); |
| 6573 | |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 6574 | if (dut->ap_tag_key_mgmt[0] == AP2_OSEN) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6575 | run_system(dut, "cfg -a AP_SECMODE_2=WPA"); |
| 6576 | run_system(dut, "cfg -a AP_SECFILE_2=OSEN"); |
| 6577 | |
Jouni Malinen | 3aa7286 | 2019-05-29 23:14:51 +0300 | [diff] [blame] | 6578 | res = snprintf(buf, sizeof(buf), |
| 6579 | "cfg -a AP_AUTH_SERVER_2=%s", |
| 6580 | dut->ap2_radius_ipaddr); |
| 6581 | if (res < 0 || res >= sizeof(buf)) |
| 6582 | return ERROR_SEND_STATUS; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6583 | run_system(dut, buf); |
| 6584 | |
Jouni Malinen | 3aa7286 | 2019-05-29 23:14:51 +0300 | [diff] [blame] | 6585 | res = snprintf(buf, sizeof(buf), |
| 6586 | "cfg -a AP_AUTH_PORT_2=%d", |
| 6587 | dut->ap2_radius_port); |
| 6588 | if (res < 0 || res >= sizeof(buf)) |
| 6589 | return ERROR_SEND_STATUS; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6590 | run_system(dut, buf); |
| 6591 | |
Jouni Malinen | 3aa7286 | 2019-05-29 23:14:51 +0300 | [diff] [blame] | 6592 | res = snprintf(buf, sizeof(buf), |
| 6593 | "cfg -a AP_AUTH_SECRET_2=%s", |
| 6594 | dut->ap2_radius_password); |
| 6595 | if (res < 0 || res >= sizeof(buf)) |
| 6596 | return ERROR_SEND_STATUS; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6597 | run_system(dut, buf); |
| 6598 | } else { |
| 6599 | run_system(dut, "cfg -a AP_SECMODE_2=None"); |
| 6600 | run_system(dut, "cfg -r AP_AUTH_SERVER_2"); |
| 6601 | run_system(dut, "cfg -r AP_AUTH_PORT_2"); |
| 6602 | run_system(dut, "cfg -r AP_AUTH_SECRET_2"); |
| 6603 | } |
| 6604 | |
| 6605 | run_system(dut, "cfg -a AP_STARTMODE=multi"); |
| 6606 | } |
| 6607 | |
| 6608 | run_system(dut, "cfg -c"); |
| 6609 | |
| 6610 | sigma_dut_print(dut, DUT_MSG_INFO, "Starting AP"); |
| 6611 | if (system("apup") != 0) { |
| 6612 | /* to be debugged why apup returns error |
| 6613 | send_resp(dut, conn, SIGMA_ERROR, |
| 6614 | "errorCode,apup failed"); |
| 6615 | return 0; |
| 6616 | */ |
| 6617 | } |
| 6618 | sigma_dut_print(dut, DUT_MSG_INFO, "AP started"); |
| 6619 | |
| 6620 | if (dut->ap_key_mgmt != AP_OPEN) { |
| 6621 | int res; |
| 6622 | /* allow some time for hostapd to start before returning |
| 6623 | * success */ |
| 6624 | usleep(500000); |
| 6625 | if (run_hostapd_cli(dut, "ping") != 0) { |
| 6626 | send_resp(dut, conn, SIGMA_ERROR, |
| 6627 | "errorCode,Failed to talk to hostapd"); |
| 6628 | return 0; |
| 6629 | } |
| 6630 | |
| 6631 | if (dut->ap_hs2 && !dut->ap_anqpserver) { |
| 6632 | /* the cfg app doesn't like ";" in the variables */ |
| 6633 | res = ath_ap_append_hostapd_conf(dut); |
| 6634 | if (res < 0) |
| 6635 | return res; |
| 6636 | |
| 6637 | /* wait for hostapd to be ready */ |
| 6638 | usleep(500000); |
| 6639 | if (run_hostapd_cli(dut, "ping") != 0) { |
| 6640 | send_resp(dut, conn, SIGMA_ERROR, |
| 6641 | "errorCode,Failed to talk to " |
| 6642 | "hostapd"); |
| 6643 | return 0; |
| 6644 | } |
| 6645 | } |
| 6646 | } |
| 6647 | |
| 6648 | ath_ap_set_params(dut); |
| 6649 | |
| 6650 | if (dut->ap_anqpserver) |
| 6651 | return cmd_ath_ap_anqpserver_start(dut); |
| 6652 | |
| 6653 | if (dut->ap2_proxy_arp) |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 6654 | run_iwpriv(dut, ifname, "proxy_arp 1"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6655 | |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 6656 | if (dut->ap_allow_vht_wep || dut->ap_allow_vht_tkip) |
| 6657 | run_iwpriv(dut, ifname, "htweptkip 1"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6658 | |
| 6659 | return 1; |
| 6660 | } |
| 6661 | |
| 6662 | |
| 6663 | static int set_ebtables_proxy_arp(struct sigma_dut *dut, const char *chain, |
| 6664 | const char *ifname) |
| 6665 | { |
| 6666 | char buf[200]; |
| 6667 | |
| 6668 | if (!chain || !ifname) |
| 6669 | return -2; |
| 6670 | |
| 6671 | snprintf(buf, sizeof(buf), "ebtables -P %s ACCEPT", chain); |
| 6672 | if (system(buf) != 0) { |
| 6673 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 6674 | "Failed to set ebtables rules, RULE-1, %s", |
| 6675 | chain); |
| 6676 | return -2; |
| 6677 | } |
| 6678 | |
| 6679 | snprintf(buf, sizeof(buf), |
| 6680 | "ebtables -A %s -p ARP -d Broadcast -o %s -j DROP", |
| 6681 | chain, ifname); |
| 6682 | if (system(buf) != 0) { |
| 6683 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 6684 | "Failed to set ebtables rules, RULE-2, %s", |
| 6685 | chain); |
| 6686 | return -2; |
| 6687 | } |
| 6688 | |
| 6689 | snprintf(buf, sizeof(buf), |
| 6690 | "ebtables -A %s -d Multicast -p IPv6 --ip6-protocol ipv6-icmp --ip6-icmp-type neighbor-solicitation -o %s -j DROP", |
| 6691 | chain, ifname); |
| 6692 | if (system(buf) != 0) { |
| 6693 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 6694 | "Failed to set ebtables rules, RULE-3, %s", |
| 6695 | chain); |
| 6696 | return -2; |
| 6697 | } |
| 6698 | |
| 6699 | snprintf(buf, sizeof(buf), |
| 6700 | "ebtables -A %s -d Multicast -p IPv6 --ip6-protocol ipv6-icmp --ip6-icmp-type neighbor-advertisement -o %s -j DROP", |
| 6701 | chain, ifname); |
| 6702 | if (system(buf) != 0) { |
| 6703 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 6704 | "Failed to set ebtables rules, RULE-4, %s", |
| 6705 | chain); |
| 6706 | return -2; |
| 6707 | } |
| 6708 | |
| 6709 | return 0; |
| 6710 | } |
| 6711 | |
| 6712 | |
| 6713 | static int set_ebtables_disable_dgaf(struct sigma_dut *dut, |
| 6714 | const char *chain, |
| 6715 | const char *ifname) |
| 6716 | { |
| 6717 | char buf[200]; |
| 6718 | |
| 6719 | if (!chain || !ifname) |
| 6720 | return -2; |
| 6721 | |
| 6722 | snprintf(buf, sizeof(buf), "ebtables -P %s ACCEPT", chain); |
| 6723 | if (system(buf) != 0) { |
| 6724 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 6725 | "Failed to set ebtables rules, RULE-5, %s", |
| 6726 | chain); |
| 6727 | return -2; |
| 6728 | } |
| 6729 | |
| 6730 | snprintf(buf, sizeof(buf), |
| 6731 | "ebtables -A %s -p ARP -d Broadcast -o %s -j DROP", |
| 6732 | chain, ifname); |
| 6733 | if (system(buf) != 0) { |
| 6734 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 6735 | "Failed to set ebtables rules, RULE-6, %s", |
| 6736 | chain); |
| 6737 | return -2; |
| 6738 | } |
| 6739 | |
| 6740 | snprintf(buf, sizeof(buf), |
| 6741 | "ebtables -A %s -p IPv4 -d Multicast -o %s -j DROP", |
| 6742 | chain, ifname); |
| 6743 | if (system(buf) != 0) { |
| 6744 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 6745 | "Failed to set ebtables rules, RULE-7, %s", |
| 6746 | chain); |
| 6747 | return -2; |
| 6748 | } |
| 6749 | |
| 6750 | snprintf(buf, sizeof(buf), |
| 6751 | "ebtables -A %s -p IPv6 -d Multicast -o %s -j DROP", |
| 6752 | chain, ifname); |
| 6753 | if (system(buf) != 0) { |
| 6754 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 6755 | "Failed to set ebtables rules, RULE-8, %s", |
| 6756 | chain); |
| 6757 | return -2; |
| 6758 | } |
| 6759 | |
| 6760 | return 0; |
| 6761 | } |
| 6762 | |
| 6763 | |
Jouni Malinen | dbbc2c4 | 2018-11-14 23:55:41 +0200 | [diff] [blame] | 6764 | static void set_ebtables_forward_drop(struct sigma_dut *dut, |
| 6765 | const char *ifname, const char *ifname2) |
| 6766 | { |
| 6767 | char buf[128]; |
| 6768 | |
| 6769 | snprintf(buf, sizeof(buf), "ebtables -A FORWARD -i %s -o %s -j DROP", |
| 6770 | ifname, ifname2); |
| 6771 | if (system(buf) != 0) |
| 6772 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 6773 | "Failed to set ebtables rule"); |
| 6774 | |
| 6775 | snprintf(buf, sizeof(buf), "ebtables -A FORWARD -i %s -o %s -j DROP", |
| 6776 | ifname2, ifname); |
| 6777 | if (system(buf) != 0) |
| 6778 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 6779 | "Failed to set ebtables rule"); |
| 6780 | } |
| 6781 | |
| 6782 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6783 | static int check_channel(int channel) |
| 6784 | { |
| 6785 | int channel_list[] = { 36, 40, 44, 48, 52, 60, 64, 100, 104, 108, 112, |
| 6786 | 116, 120, 124, 128, 132, 140, 144, 149, 153, 157, |
| 6787 | 161, 165 }; |
| 6788 | int num_chan = sizeof(channel_list) / sizeof(int); |
| 6789 | int i; |
| 6790 | |
| 6791 | for (i = 0; i < num_chan; i++) { |
| 6792 | if (channel == channel_list[i]) |
| 6793 | return i; |
| 6794 | } |
| 6795 | |
| 6796 | return -1; |
| 6797 | } |
| 6798 | |
| 6799 | |
| 6800 | static int get_oper_centr_freq_seq_idx(int chwidth, int channel) |
| 6801 | { |
| 6802 | int ch_base; |
| 6803 | int period; |
| 6804 | |
| 6805 | if (check_channel(channel) < 0) |
| 6806 | return -1; |
| 6807 | |
| 6808 | if (channel >= 36 && channel <= 64) |
| 6809 | ch_base = 36; |
| 6810 | else if (channel >= 100 && channel <= 144) |
| 6811 | ch_base = 100; |
| 6812 | else |
| 6813 | ch_base = 149; |
| 6814 | |
| 6815 | period = channel % ch_base * 5 / chwidth; |
| 6816 | return ch_base + period * chwidth / 5 + (chwidth - 20) / 10; |
| 6817 | } |
| 6818 | |
| 6819 | |
| 6820 | static int is_ht40plus_chan(int chan) |
| 6821 | { |
| 6822 | return chan == 36 || chan == 44 || chan == 52 || chan == 60 || |
| 6823 | chan == 100 || chan == 108 || chan == 116 || chan == 124 || |
| 6824 | chan == 132 || chan == 149 || chan == 157; |
| 6825 | } |
| 6826 | |
| 6827 | |
| 6828 | static int is_ht40minus_chan(int chan) |
| 6829 | { |
| 6830 | return chan == 40 || chan == 48 || chan == 56 || chan == 64 || |
| 6831 | chan == 104 || chan == 112 || chan == 120 || chan == 128 || |
| 6832 | chan == 136 || chan == 153 || chan == 161; |
| 6833 | } |
| 6834 | |
| 6835 | |
Mohammed Shafi Shajakhan | b53d8f9 | 2017-02-28 09:05:15 +0530 | [diff] [blame] | 6836 | static int get_5g_channel_freq(int chan) |
| 6837 | { |
| 6838 | return 5000 + chan * 5; |
| 6839 | } |
| 6840 | |
| 6841 | |
Jouni Malinen | 3d633da | 2017-09-14 22:19:21 +0300 | [diff] [blame] | 6842 | static const char * hostapd_cipher_name(enum ap_cipher cipher) |
| 6843 | { |
| 6844 | switch (cipher) { |
| 6845 | case AP_CCMP: |
| 6846 | return "CCMP"; |
| 6847 | case AP_TKIP: |
| 6848 | return "TKIP"; |
| 6849 | case AP_CCMP_TKIP: |
| 6850 | return "CCMP TKIP"; |
| 6851 | case AP_GCMP_256: |
| 6852 | return "GCMP-256"; |
| 6853 | case AP_GCMP_128: |
| 6854 | return "GCMP"; |
| 6855 | case AP_CCMP_256: |
| 6856 | return "CCMP-256"; |
Jouni Malinen | d538c78 | 2017-11-17 12:13:04 +0200 | [diff] [blame] | 6857 | case AP_CCMP_128_GCMP_256: |
| 6858 | return "CCMP GCMP-256"; |
Jouni Malinen | 3d633da | 2017-09-14 22:19:21 +0300 | [diff] [blame] | 6859 | default: |
| 6860 | return "UNKNOWN"; |
| 6861 | } |
| 6862 | } |
| 6863 | |
| 6864 | |
| 6865 | static const char * |
| 6866 | hostapd_group_mgmt_cipher_name(enum ap_group_mgmt_cipher cipher) |
| 6867 | { |
| 6868 | switch (cipher) { |
| 6869 | case AP_BIP_GMAC_256: |
Jouni Malinen | 57887a2 | 2017-10-10 20:43:25 +0300 | [diff] [blame] | 6870 | return "BIP-GMAC-256"; |
Jouni Malinen | 3d633da | 2017-09-14 22:19:21 +0300 | [diff] [blame] | 6871 | case AP_BIP_CMAC_256: |
| 6872 | return "BIP-CMAC-256"; |
| 6873 | case AP_BIP_GMAC_128: |
| 6874 | return "BIP-GMAC-128"; |
| 6875 | case AP_BIP_CMAC_128: |
| 6876 | return "AES-128-CMAC"; |
| 6877 | default: |
| 6878 | return "UNKNOWN"; |
| 6879 | } |
| 6880 | } |
| 6881 | |
| 6882 | |
Alexei Avshalom Lazar | bc180dc | 2018-12-18 16:01:14 +0200 | [diff] [blame] | 6883 | static int ap_set_60g_ese(struct sigma_dut *dut, int count, |
| 6884 | struct sigma_ese_alloc *allocs) |
| 6885 | { |
| 6886 | switch (get_driver_type()) { |
| 6887 | #ifdef __linux__ |
| 6888 | case DRIVER_WIL6210: |
| 6889 | return wil6210_set_ese(dut, count, allocs); |
| 6890 | #endif /* __linux__ */ |
| 6891 | default: |
| 6892 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 6893 | "Unsupported ap_set_60g_ese with the current driver"); |
| 6894 | return -1; |
| 6895 | } |
| 6896 | } |
| 6897 | |
| 6898 | |
Alexei Avshalom Lazar | aad97b0 | 2018-12-18 16:01:23 +0200 | [diff] [blame] | 6899 | static int ap_set_force_mcs(struct sigma_dut *dut, int force, int mcs) |
| 6900 | { |
| 6901 | switch (get_driver_type()) { |
| 6902 | #ifdef __linux__ |
| 6903 | case DRIVER_WIL6210: |
| 6904 | return wil6210_set_force_mcs(dut, force, mcs); |
| 6905 | #endif /* __linux__ */ |
| 6906 | default: |
| 6907 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 6908 | "Unsupported ap_set_force_mcs with the current driver"); |
| 6909 | return -1; |
| 6910 | } |
| 6911 | } |
| 6912 | |
| 6913 | |
Jouni Malinen | f722271 | 2019-06-13 01:50:21 +0300 | [diff] [blame] | 6914 | enum sigma_cmd_result cmd_ap_config_commit(struct sigma_dut *dut, |
| 6915 | struct sigma_conn *conn, |
| 6916 | struct sigma_cmd *cmd) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6917 | { |
| 6918 | /* const char *name = get_param(cmd, "NAME"); */ |
| 6919 | FILE *f; |
| 6920 | const char *ifname; |
| 6921 | char buf[500]; |
| 6922 | char path[100]; |
| 6923 | enum driver_type drv; |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 6924 | const char *key_mgmt; |
Srinivas Dasari | a1deeaa | 2018-06-18 22:54:04 +0530 | [diff] [blame] | 6925 | #ifdef ANDROID |
| 6926 | struct group *gr; |
| 6927 | #endif /* ANDROID */ |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6928 | |
| 6929 | drv = get_driver_type(); |
| 6930 | |
| 6931 | if (dut->mode == SIGMA_MODE_STATION) { |
| 6932 | stop_sta_mode(dut); |
| 6933 | sleep(1); |
| 6934 | } |
| 6935 | |
| 6936 | if (dut->mode == SIGMA_MODE_SNIFFER && dut->sniffer_ifname) { |
| 6937 | snprintf(buf, sizeof(buf), "ifconfig %s down", |
| 6938 | dut->sniffer_ifname); |
| 6939 | if (system(buf) != 0) { |
| 6940 | sigma_dut_print(dut, DUT_MSG_INFO, |
| 6941 | "Failed to run '%s'", buf); |
| 6942 | } |
| 6943 | snprintf(buf, sizeof(buf), "iw dev %s set type station", |
| 6944 | dut->sniffer_ifname); |
| 6945 | if (system(buf) != 0) { |
| 6946 | sigma_dut_print(dut, DUT_MSG_INFO, |
| 6947 | "Failed to run '%s'", buf); |
| 6948 | } |
| 6949 | } |
| 6950 | |
| 6951 | dut->mode = SIGMA_MODE_AP; |
| 6952 | |
| 6953 | if (drv == DRIVER_ATHEROS) |
| 6954 | return cmd_ath_ap_config_commit(dut, conn, cmd); |
| 6955 | if (drv == DRIVER_WCN) |
| 6956 | return cmd_wcn_ap_config_commit(dut, conn, cmd); |
| 6957 | if (drv == DRIVER_OPENWRT) |
| 6958 | return cmd_owrt_ap_config_commit(dut, conn, cmd); |
| 6959 | |
| 6960 | f = fopen(SIGMA_TMPDIR "/sigma_dut-ap.conf", "w"); |
| 6961 | if (f == NULL) { |
| 6962 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 6963 | "%s: Failed to open sigma_dut-ap.conf", |
| 6964 | __func__); |
| 6965 | return -2; |
| 6966 | } |
| 6967 | switch (dut->ap_mode) { |
| 6968 | case AP_11g: |
| 6969 | case AP_11b: |
| 6970 | case AP_11ng: |
Pradeep Reddy Potteti | 08eaeba | 2017-06-14 12:43:19 +0530 | [diff] [blame] | 6971 | ifname = (drv == DRIVER_MAC80211) ? "wlan0" : "ath0"; |
| 6972 | if ((drv == DRIVER_QNXNTO || drv == DRIVER_LINUX_WCN) && |
| 6973 | sigma_main_ifname) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6974 | ifname = sigma_main_ifname; |
| 6975 | fprintf(f, "hw_mode=g\n"); |
| 6976 | break; |
| 6977 | case AP_11a: |
| 6978 | case AP_11na: |
| 6979 | case AP_11ac: |
Pradeep Reddy Potteti | 08eaeba | 2017-06-14 12:43:19 +0530 | [diff] [blame] | 6980 | if (drv == DRIVER_QNXNTO || drv == DRIVER_LINUX_WCN) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6981 | if (sigma_main_ifname) |
| 6982 | ifname = sigma_main_ifname; |
| 6983 | else |
| 6984 | ifname = "wlan0"; |
Pradeep Reddy Potteti | 08eaeba | 2017-06-14 12:43:19 +0530 | [diff] [blame] | 6985 | } else if (drv == DRIVER_MAC80211) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6986 | if (if_nametoindex("wlan1") > 0) |
| 6987 | ifname = "wlan1"; |
| 6988 | else |
| 6989 | ifname = "wlan0"; |
| 6990 | } else { |
| 6991 | ifname = get_main_ifname(); |
| 6992 | } |
| 6993 | fprintf(f, "hw_mode=a\n"); |
| 6994 | break; |
Alexei Avshalom Lazar | 2712cc8 | 2018-12-23 16:29:14 +0200 | [diff] [blame] | 6995 | case AP_11ad: |
| 6996 | ifname = get_main_ifname(); |
| 6997 | fprintf(f, "hw_mode=ad\n"); |
| 6998 | break; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6999 | default: |
| 7000 | fclose(f); |
| 7001 | return -1; |
| 7002 | } |
Jouni Malinen | d6bf1b4 | 2017-06-23 17:51:01 +0300 | [diff] [blame] | 7003 | if (dut->hostapd_ifname) |
| 7004 | ifname = dut->hostapd_ifname; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7005 | |
Sreelakshmi Konamki | b692f10 | 2016-04-26 19:47:00 +0530 | [diff] [blame] | 7006 | if (drv == DRIVER_MAC80211 || drv == DRIVER_LINUX_WCN) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7007 | fprintf(f, "driver=nl80211\n"); |
| 7008 | |
Sreelakshmi Konamki | b692f10 | 2016-04-26 19:47:00 +0530 | [diff] [blame] | 7009 | if ((drv == DRIVER_MAC80211 || drv == DRIVER_QNXNTO || |
| 7010 | drv == DRIVER_LINUX_WCN) && |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7011 | (dut->ap_mode == AP_11ng || dut->ap_mode == AP_11na)) { |
Tamizh chelvam | 431c600 | 2017-03-07 17:07:16 +0530 | [diff] [blame] | 7012 | int ht40plus = 0, ht40minus = 0, tx_stbc = 0; |
| 7013 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7014 | fprintf(f, "ieee80211n=1\n"); |
Pradeep Reddy Potteti | bf8af29 | 2017-02-15 15:28:39 +0530 | [diff] [blame] | 7015 | if (dut->ap_mode == AP_11ng && |
| 7016 | (dut->ap_chwidth == AP_40 || |
| 7017 | (dut->ap_chwidth == AP_AUTO && |
| 7018 | dut->default_11ng_ap_chwidth == AP_40))) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7019 | if (dut->ap_channel >= 1 && dut->ap_channel <= 7) |
Tamizh chelvam | 431c600 | 2017-03-07 17:07:16 +0530 | [diff] [blame] | 7020 | ht40plus = 1; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7021 | else if (dut->ap_channel >= 8 && dut->ap_channel <= 11) |
Tamizh chelvam | 431c600 | 2017-03-07 17:07:16 +0530 | [diff] [blame] | 7022 | ht40minus = 1; |
| 7023 | fprintf(f, "obss_interval=300\n"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7024 | } |
| 7025 | |
| 7026 | /* configure ht_capab based on channel width */ |
| 7027 | if (dut->ap_mode == AP_11na && |
| 7028 | (dut->ap_chwidth == AP_40 || |
| 7029 | (dut->ap_chwidth == AP_AUTO && |
Pradeep Reddy Potteti | bf8af29 | 2017-02-15 15:28:39 +0530 | [diff] [blame] | 7030 | dut->default_11na_ap_chwidth == AP_40))) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7031 | if (is_ht40plus_chan(dut->ap_channel)) |
Tamizh chelvam | 431c600 | 2017-03-07 17:07:16 +0530 | [diff] [blame] | 7032 | ht40plus = 1; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7033 | else if (is_ht40minus_chan(dut->ap_channel)) |
Tamizh chelvam | 431c600 | 2017-03-07 17:07:16 +0530 | [diff] [blame] | 7034 | ht40minus = 1; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7035 | } |
Mohammed Shafi Shajakhan | 31d8a15 | 2016-06-02 20:10:55 +0530 | [diff] [blame] | 7036 | |
| 7037 | if (dut->ap_tx_stbc) |
Tamizh chelvam | 431c600 | 2017-03-07 17:07:16 +0530 | [diff] [blame] | 7038 | tx_stbc = 1; |
Mohammed Shafi Shajakhan | 31d8a15 | 2016-06-02 20:10:55 +0530 | [diff] [blame] | 7039 | |
Pradeep Reddy Potteti | 4b0cdee | 2017-03-15 12:37:33 +0530 | [diff] [blame] | 7040 | /* Overwrite the ht_capab with offset value if configured */ |
| 7041 | if (dut->ap_chwidth == AP_40 && |
| 7042 | dut->ap_chwidth_offset == SEC_CH_40ABOVE) { |
| 7043 | ht40plus = 1; |
| 7044 | ht40minus = 0; |
| 7045 | } else if (dut->ap_chwidth == AP_40 && |
| 7046 | dut->ap_chwidth_offset == SEC_CH_40BELOW) { |
| 7047 | ht40minus = 1; |
| 7048 | ht40plus = 0; |
| 7049 | } |
| 7050 | |
Tamizh chelvam | 431c600 | 2017-03-07 17:07:16 +0530 | [diff] [blame] | 7051 | fprintf(f, "ht_capab=%s%s%s\n", |
| 7052 | ht40plus ? "[HT40+]" : "", |
| 7053 | ht40minus ? "[HT40-]" : "", |
| 7054 | tx_stbc ? "[TX-STBC]" : ""); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7055 | } |
| 7056 | |
Sreelakshmi Konamki | b692f10 | 2016-04-26 19:47:00 +0530 | [diff] [blame] | 7057 | if ((drv == DRIVER_MAC80211 || drv == DRIVER_QNXNTO || |
| 7058 | drv == DRIVER_LINUX_WCN) && |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7059 | dut->ap_mode == AP_11ac) { |
Hu Wang | 2939210 | 2019-07-03 15:41:12 +0800 | [diff] [blame] | 7060 | int ht40plus = 0, ht40minus = 0; |
| 7061 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7062 | fprintf(f, "ieee80211ac=1\n" |
Hu Wang | 2939210 | 2019-07-03 15:41:12 +0800 | [diff] [blame] | 7063 | "ieee80211n=1\n"); |
| 7064 | |
| 7065 | /* configure ht_capab based on channel width */ |
| 7066 | if (dut->ap_chwidth != AP_20) { |
| 7067 | if (is_ht40plus_chan(dut->ap_channel)) |
| 7068 | ht40plus = 1; |
| 7069 | else if (is_ht40minus_chan(dut->ap_channel)) |
| 7070 | ht40minus = 1; |
| 7071 | |
| 7072 | fprintf(f, "ht_capab=%s%s\n", |
| 7073 | ht40plus ? "[HT40+]" : "", |
| 7074 | ht40minus ? "[HT40-]" : ""); |
| 7075 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7076 | } |
| 7077 | |
Sreelakshmi Konamki | b692f10 | 2016-04-26 19:47:00 +0530 | [diff] [blame] | 7078 | if ((drv == DRIVER_MAC80211 || drv == DRIVER_QNXNTO || |
| 7079 | drv == DRIVER_LINUX_WCN) && |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7080 | (dut->ap_mode == AP_11ac || dut->ap_mode == AP_11na)) { |
| 7081 | if (dut->ap_countrycode[0]) { |
| 7082 | fprintf(f, "country_code=%s\n", dut->ap_countrycode); |
| 7083 | fprintf(f, "ieee80211d=1\n"); |
| 7084 | fprintf(f, "ieee80211h=1\n"); |
| 7085 | } |
| 7086 | } |
| 7087 | |
| 7088 | fprintf(f, "interface=%s\n", ifname); |
| 7089 | if (dut->bridge) |
| 7090 | fprintf(f, "bridge=%s\n", dut->bridge); |
| 7091 | fprintf(f, "channel=%d\n", dut->ap_channel); |
| 7092 | |
| 7093 | if (sigma_hapd_ctrl) |
| 7094 | fprintf(f, "ctrl_interface=%s\n", sigma_hapd_ctrl); |
| 7095 | else |
| 7096 | fprintf(f, "ctrl_interface=/var/run/hostapd\n"); |
| 7097 | |
| 7098 | if (dut->ap_ssid[0]) |
| 7099 | fprintf(f, "ssid=%s\n", dut->ap_ssid); |
| 7100 | else |
| 7101 | fprintf(f, "ssid=QCA AP OOB\n"); |
| 7102 | if (dut->ap_bcnint) |
| 7103 | fprintf(f, "beacon_int=%d\n", dut->ap_bcnint); |
| 7104 | |
Jouni Malinen | da5f35b | 2019-03-26 00:25:53 +0200 | [diff] [blame] | 7105 | if (dut->ap_akm_values) { |
| 7106 | struct { |
| 7107 | int akm; |
| 7108 | const char *str; |
| 7109 | } akms[] = { |
| 7110 | { AKM_WPA_EAP, "WPA-EAP" }, |
| 7111 | { AKM_WPA_PSK, "WPA-PSK" }, |
| 7112 | { AKM_FT_EAP, "FT-EAP" }, |
| 7113 | { AKM_FT_PSK, "FT-PSK" }, |
| 7114 | { AKM_EAP_SHA256, "WPA-EAP-SHA256" }, |
| 7115 | { AKM_PSK_SHA256, "WPA-PSK-SHA256" }, |
| 7116 | { AKM_SAE, "SAE" }, |
| 7117 | { AKM_FT_SAE, "FT-SAE" }, |
| 7118 | { AKM_SUITE_B, "WPA-EAP-SUITE-B-192" }, |
| 7119 | { AKM_FT_SUITE_B, "FT-EAP-SHA384" }, |
| 7120 | { AKM_FILS_SHA256, "FILS-SHA256" }, |
| 7121 | { AKM_FILS_SHA384, "FILS-SHA384" }, |
| 7122 | { AKM_FT_FILS_SHA256, "FT-FILS-SHA256" }, |
| 7123 | { AKM_FT_FILS_SHA384, "FT-FILS-SHA384" }, |
| 7124 | }; |
Jouni Malinen | 8400c08 | 2019-04-26 13:26:07 +0300 | [diff] [blame] | 7125 | int first = 1; |
| 7126 | unsigned int i; |
Jouni Malinen | da5f35b | 2019-03-26 00:25:53 +0200 | [diff] [blame] | 7127 | |
| 7128 | fprintf(f, "wpa_key_mgmt="); |
| 7129 | for (i = 0; i < ARRAY_SIZE(akms); i++) { |
| 7130 | if (dut->ap_akm_values & (1 << akms[i].akm)) { |
| 7131 | fprintf(f, "%s%s", first ? "" : " ", |
| 7132 | akms[i].str); |
| 7133 | first = 0; |
| 7134 | } |
| 7135 | } |
| 7136 | fprintf(f, "\n"); |
| 7137 | /* TODO: mixed mode and WPAv1 only */ |
| 7138 | fprintf(f, "wpa=2\n"); |
| 7139 | fprintf(f, "wpa_pairwise=%s\n", |
| 7140 | hostapd_cipher_name(dut->ap_cipher)); |
| 7141 | if (dut->ap_group_cipher != AP_NO_GROUP_CIPHER_SET) |
| 7142 | fprintf(f, "group_cipher=%s\n", |
| 7143 | hostapd_cipher_name(dut->ap_group_cipher)); |
Jouni Malinen | 3e25541 | 2019-03-28 22:04:08 +0200 | [diff] [blame] | 7144 | if ((dut->ap_akm_values & |
| 7145 | ((1 << AKM_SAE) | (1 << AKM_FT_SAE))) && |
| 7146 | !(dut->ap_akm_values & |
| 7147 | ((1 << AKM_WPA_PSK) | (1 << AKM_FT_PSK))) && |
Jouni Malinen | da5f35b | 2019-03-26 00:25:53 +0200 | [diff] [blame] | 7148 | dut->ap_passphrase[0]) |
| 7149 | fprintf(f, "sae_password=%s\n", dut->ap_passphrase); |
| 7150 | else if (!dut->ap_passphrase[0] && dut->ap_psk[0]) |
| 7151 | fprintf(f, "wpa_psk=%s", dut->ap_psk); |
| 7152 | else if (dut->ap_passphrase[0]) |
| 7153 | fprintf(f, "wpa_passphrase=%s\n", dut->ap_passphrase); |
Jouni Malinen | 10ed9e7 | 2019-03-28 03:00:11 +0200 | [diff] [blame] | 7154 | if (dut->ap_akm_values & ((1 << AKM_WPA_EAP) | |
Jouni Malinen | e5393c3 | 2019-06-20 01:34:34 +0300 | [diff] [blame] | 7155 | (1 << AKM_FT_EAP) | |
Jouni Malinen | 10ed9e7 | 2019-03-28 03:00:11 +0200 | [diff] [blame] | 7156 | (1 << AKM_EAP_SHA256) | |
| 7157 | (1 << AKM_SUITE_B) | |
| 7158 | (1 << AKM_FT_SUITE_B) | |
| 7159 | (1 << AKM_FILS_SHA256) | |
| 7160 | (1 << AKM_FILS_SHA384) | |
| 7161 | (1 << AKM_FT_FILS_SHA256) | |
| 7162 | (1 << AKM_FT_FILS_SHA384))) { |
| 7163 | fprintf(f, "ieee8021x=1\n"); |
| 7164 | fprintf(f, "auth_server_addr=%s\n", |
| 7165 | dut->ap_radius_ipaddr); |
| 7166 | if (dut->ap_radius_port) |
| 7167 | fprintf(f, "auth_server_port=%d\n", |
| 7168 | dut->ap_radius_port); |
| 7169 | fprintf(f, "auth_server_shared_secret=%s\n", |
| 7170 | dut->ap_radius_password); |
| 7171 | } |
Jouni Malinen | da5f35b | 2019-03-26 00:25:53 +0200 | [diff] [blame] | 7172 | goto skip_key_mgmt; |
| 7173 | } |
| 7174 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7175 | switch (dut->ap_key_mgmt) { |
| 7176 | case AP_OPEN: |
| 7177 | if (dut->ap_cipher == AP_WEP) |
| 7178 | fprintf(f, "wep_key0=%s\n", dut->ap_wepkey); |
| 7179 | break; |
| 7180 | case AP_WPA2_PSK: |
| 7181 | case AP_WPA2_PSK_MIXED: |
| 7182 | case AP_WPA_PSK: |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 7183 | case AP_WPA2_SAE: |
| 7184 | case AP_WPA2_PSK_SAE: |
Jouni Malinen | 6be21c8 | 2018-08-01 18:47:24 +0300 | [diff] [blame] | 7185 | case AP_WPA2_PSK_SHA256: |
| 7186 | case AP_WPA2_FT_PSK: |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 7187 | if (dut->ap_key_mgmt == AP_WPA2_PSK || |
| 7188 | dut->ap_key_mgmt == AP_WPA2_SAE || |
Jouni Malinen | 6be21c8 | 2018-08-01 18:47:24 +0300 | [diff] [blame] | 7189 | dut->ap_key_mgmt == AP_WPA2_PSK_SAE || |
| 7190 | dut->ap_key_mgmt == AP_WPA2_PSK_SHA256 || |
| 7191 | dut->ap_key_mgmt == AP_WPA2_FT_PSK) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7192 | fprintf(f, "wpa=2\n"); |
| 7193 | else if (dut->ap_key_mgmt == AP_WPA2_PSK_MIXED) |
| 7194 | fprintf(f, "wpa=3\n"); |
| 7195 | else |
| 7196 | fprintf(f, "wpa=1\n"); |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 7197 | if (dut->ap_key_mgmt == AP_WPA2_SAE) |
| 7198 | key_mgmt = "SAE"; |
| 7199 | else if (dut->ap_key_mgmt == AP_WPA2_PSK_SAE) |
| 7200 | key_mgmt = "WPA-PSK SAE"; |
| 7201 | else |
| 7202 | key_mgmt = "WPA-PSK"; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7203 | switch (dut->ap_pmf) { |
| 7204 | case AP_PMF_DISABLED: |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 7205 | fprintf(f, "wpa_key_mgmt=%s%s\n", key_mgmt, |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7206 | dut->ap_add_sha256 ? " WPA-PSK-SHA256" : ""); |
| 7207 | break; |
| 7208 | case AP_PMF_OPTIONAL: |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 7209 | fprintf(f, "wpa_key_mgmt=%s%s\n", key_mgmt, |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7210 | dut->ap_add_sha256 ? " WPA-PSK-SHA256" : ""); |
| 7211 | break; |
| 7212 | case AP_PMF_REQUIRED: |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 7213 | if (dut->ap_key_mgmt == AP_WPA2_SAE) |
| 7214 | key_mgmt = "SAE"; |
| 7215 | else if (dut->ap_key_mgmt == AP_WPA2_PSK_SAE) |
| 7216 | key_mgmt = "WPA-PSK-SHA256 SAE"; |
| 7217 | else |
| 7218 | key_mgmt = "WPA-PSK-SHA256"; |
| 7219 | fprintf(f, "wpa_key_mgmt=%s\n", key_mgmt); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7220 | break; |
| 7221 | } |
Jouni Malinen | 6be21c8 | 2018-08-01 18:47:24 +0300 | [diff] [blame] | 7222 | if (dut->ap_key_mgmt == AP_WPA2_PSK_SHA256) |
| 7223 | fprintf(f, "wpa_key_mgmt=WPA-PSK-SHA256\n"); |
| 7224 | else if (dut->ap_key_mgmt == AP_WPA2_FT_PSK) |
| 7225 | fprintf(f, "wpa_key_mgmt=FT-PSK\n"); |
Jouni Malinen | 2ba2449 | 2017-11-17 12:43:59 +0200 | [diff] [blame] | 7226 | fprintf(f, "wpa_pairwise=%s\n", |
| 7227 | hostapd_cipher_name(dut->ap_cipher)); |
| 7228 | if (dut->ap_group_cipher != AP_NO_GROUP_CIPHER_SET) |
| 7229 | fprintf(f, "group_cipher=%s\n", |
| 7230 | hostapd_cipher_name(dut->ap_group_cipher)); |
Jouni Malinen | 2126f42 | 2017-10-11 23:24:33 +0300 | [diff] [blame] | 7231 | if (dut->ap_key_mgmt == AP_WPA2_SAE) |
| 7232 | fprintf(f, "sae_password=%s\n", dut->ap_passphrase); |
Jouni Malinen | 6337062 | 2017-11-18 17:47:13 +0200 | [diff] [blame] | 7233 | else if (!dut->ap_passphrase[0] && dut->ap_psk[0]) |
| 7234 | fprintf(f, "wpa_psk=%s", dut->ap_psk); |
Jouni Malinen | 2126f42 | 2017-10-11 23:24:33 +0300 | [diff] [blame] | 7235 | else |
| 7236 | fprintf(f, "wpa_passphrase=%s\n", dut->ap_passphrase); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7237 | break; |
| 7238 | case AP_WPA2_EAP: |
| 7239 | case AP_WPA2_EAP_MIXED: |
| 7240 | case AP_WPA_EAP: |
Jouni Malinen | 4cf699f | 2018-06-19 00:46:27 +0300 | [diff] [blame] | 7241 | case AP_WPA2_EAP_OSEN: |
Jouni Malinen | 6be21c8 | 2018-08-01 18:47:24 +0300 | [diff] [blame] | 7242 | case AP_WPA2_EAP_SHA256: |
| 7243 | case AP_WPA2_FT_EAP: |
| 7244 | case AP_WPA2_ENT_FT_EAP: |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7245 | fprintf(f, "ieee8021x=1\n"); |
Jouni Malinen | 4cf699f | 2018-06-19 00:46:27 +0300 | [diff] [blame] | 7246 | if (dut->ap_key_mgmt == AP_WPA2_EAP || |
Jouni Malinen | 6be21c8 | 2018-08-01 18:47:24 +0300 | [diff] [blame] | 7247 | dut->ap_key_mgmt == AP_WPA2_EAP_OSEN || |
| 7248 | dut->ap_key_mgmt == AP_WPA2_EAP_SHA256 || |
| 7249 | dut->ap_key_mgmt == AP_WPA2_FT_EAP || |
| 7250 | dut->ap_key_mgmt == AP_WPA2_ENT_FT_EAP) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7251 | fprintf(f, "wpa=2\n"); |
| 7252 | else if (dut->ap_key_mgmt == AP_WPA2_EAP_MIXED) |
| 7253 | fprintf(f, "wpa=3\n"); |
| 7254 | else |
| 7255 | fprintf(f, "wpa=1\n"); |
| 7256 | switch (dut->ap_pmf) { |
| 7257 | case AP_PMF_DISABLED: |
| 7258 | fprintf(f, "wpa_key_mgmt=WPA-EAP%s\n", |
| 7259 | dut->ap_add_sha256 ? " WPA-EAP-SHA256" : ""); |
| 7260 | break; |
| 7261 | case AP_PMF_OPTIONAL: |
Jouni Malinen | 4cf699f | 2018-06-19 00:46:27 +0300 | [diff] [blame] | 7262 | fprintf(f, "wpa_key_mgmt=WPA-EAP%s%s\n", |
| 7263 | dut->ap_add_sha256 ? " WPA-EAP-SHA256" : "", |
| 7264 | dut->ap_key_mgmt == AP_WPA2_EAP_OSEN ? " OSEN" : |
| 7265 | ""); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7266 | break; |
| 7267 | case AP_PMF_REQUIRED: |
Jouni Malinen | 4cf699f | 2018-06-19 00:46:27 +0300 | [diff] [blame] | 7268 | fprintf(f, "wpa_key_mgmt=WPA-EAP-SHA256%s\n", |
| 7269 | dut->ap_key_mgmt == AP_WPA2_EAP_OSEN ? " OSEN" : |
| 7270 | ""); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7271 | break; |
| 7272 | } |
Jouni Malinen | 6be21c8 | 2018-08-01 18:47:24 +0300 | [diff] [blame] | 7273 | if (dut->ap_key_mgmt == AP_WPA2_EAP_SHA256) |
| 7274 | fprintf(f, "wpa_key_mgmt=WPA-EAP-SHA256\n"); |
| 7275 | else if (dut->ap_key_mgmt == AP_WPA2_FT_EAP) |
| 7276 | fprintf(f, "wpa_key_mgmt=FT-EAP\n"); |
| 7277 | else if (dut->ap_key_mgmt == AP_WPA2_ENT_FT_EAP) |
| 7278 | fprintf(f, "wpa_key_mgmt=FT-EAP WPA-EAP\n"); |
Jouni Malinen | 2ba2449 | 2017-11-17 12:43:59 +0200 | [diff] [blame] | 7279 | fprintf(f, "wpa_pairwise=%s\n", |
| 7280 | hostapd_cipher_name(dut->ap_cipher)); |
| 7281 | if (dut->ap_group_cipher != AP_NO_GROUP_CIPHER_SET) |
| 7282 | fprintf(f, "group_cipher=%s\n", |
| 7283 | hostapd_cipher_name(dut->ap_group_cipher)); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7284 | fprintf(f, "auth_server_addr=%s\n", dut->ap_radius_ipaddr); |
| 7285 | if (dut->ap_radius_port) |
| 7286 | fprintf(f, "auth_server_port=%d\n", |
| 7287 | dut->ap_radius_port); |
| 7288 | fprintf(f, "auth_server_shared_secret=%s\n", |
| 7289 | dut->ap_radius_password); |
Jouni Malinen | 1a2bc99 | 2018-06-22 11:50:59 +0300 | [diff] [blame] | 7290 | if (dut->program == PROGRAM_HS2_R3) { |
| 7291 | fprintf(f, "radius_das_port=3799\n"); |
| 7292 | fprintf(f, "radius_das_client=0.0.0.0 %s\n", |
| 7293 | dut->ap_radius_password); |
| 7294 | fprintf(f, "radius_das_require_event_timestamp=1\n"); |
| 7295 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7296 | break; |
Jouni Malinen | ad395a2 | 2017-09-01 21:13:46 +0300 | [diff] [blame] | 7297 | case AP_SUITEB: |
| 7298 | fprintf(f, "ieee8021x=1\n"); |
| 7299 | fprintf(f, "wpa=2\n"); |
| 7300 | fprintf(f, "wpa_key_mgmt=WPA-EAP-SUITE-B-192\n"); |
Jouni Malinen | 3d633da | 2017-09-14 22:19:21 +0300 | [diff] [blame] | 7301 | fprintf(f, "wpa_pairwise=%s\n", |
| 7302 | hostapd_cipher_name(dut->ap_cipher)); |
Jouni Malinen | 2ba2449 | 2017-11-17 12:43:59 +0200 | [diff] [blame] | 7303 | if (dut->ap_group_cipher != AP_NO_GROUP_CIPHER_SET) |
| 7304 | fprintf(f, "group_cipher=%s\n", |
| 7305 | hostapd_cipher_name(dut->ap_group_cipher)); |
Jouni Malinen | 3d633da | 2017-09-14 22:19:21 +0300 | [diff] [blame] | 7306 | if (dut->ap_group_mgmt_cipher != AP_NO_GROUP_MGMT_CIPHER_SET) |
| 7307 | fprintf(f, "group_mgmt_cipher=%s\n", |
| 7308 | hostapd_group_mgmt_cipher_name( |
| 7309 | dut->ap_group_mgmt_cipher)); |
Jouni Malinen | ad395a2 | 2017-09-01 21:13:46 +0300 | [diff] [blame] | 7310 | fprintf(f, "auth_server_addr=%s\n", dut->ap_radius_ipaddr); |
| 7311 | if (dut->ap_radius_port) |
| 7312 | fprintf(f, "auth_server_port=%d\n", |
| 7313 | dut->ap_radius_port); |
| 7314 | fprintf(f, "auth_server_shared_secret=%s\n", |
| 7315 | dut->ap_radius_password); |
| 7316 | break; |
Jouni Malinen | 147b3c3 | 2017-10-09 16:51:54 +0300 | [diff] [blame] | 7317 | case AP_WPA2_OWE: |
| 7318 | fprintf(f, "wpa=2\n"); |
| 7319 | fprintf(f, "wpa_key_mgmt=OWE\n"); |
| 7320 | fprintf(f, "rsn_pairwise=%s\n", |
| 7321 | hostapd_cipher_name(dut->ap_cipher)); |
Jouni Malinen | 72461d4 | 2017-10-10 19:20:45 +0300 | [diff] [blame] | 7322 | if (dut->ap_sae_groups) |
| 7323 | fprintf(f, "owe_groups=%s\n", dut->ap_sae_groups); |
Jouni Malinen | 147b3c3 | 2017-10-09 16:51:54 +0300 | [diff] [blame] | 7324 | break; |
Jouni Malinen | c2b9121 | 2018-09-12 02:26:39 +0300 | [diff] [blame] | 7325 | case AP_OSEN: |
| 7326 | fprintf(f, "osen=1\n"); |
| 7327 | fprintf(f, "disable_dgaf=1\n"); |
| 7328 | fprintf(f, "wpa_pairwise=%s\n", |
| 7329 | hostapd_cipher_name(dut->ap_cipher)); |
| 7330 | if (dut->ap_group_cipher != AP_NO_GROUP_CIPHER_SET) |
| 7331 | fprintf(f, "group_cipher=%s\n", |
| 7332 | hostapd_cipher_name(dut->ap_group_cipher)); |
| 7333 | fprintf(f, "auth_server_addr=%s\n", dut->ap_radius_ipaddr); |
| 7334 | if (dut->ap_radius_port) |
| 7335 | fprintf(f, "auth_server_port=%d\n", |
| 7336 | dut->ap_radius_port); |
| 7337 | fprintf(f, "auth_server_shared_secret=%s\n", |
| 7338 | dut->ap_radius_password); |
| 7339 | break; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7340 | } |
Jouni Malinen | da5f35b | 2019-03-26 00:25:53 +0200 | [diff] [blame] | 7341 | skip_key_mgmt: |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7342 | |
Jouni Malinen | 09550de | 2019-03-26 00:24:11 +0200 | [diff] [blame] | 7343 | if (dut->ap_sae_passwords) { |
| 7344 | char *tmp, *pos, *end, *id; |
| 7345 | |
| 7346 | tmp = strdup(dut->ap_sae_passwords); |
| 7347 | if (!tmp) { |
| 7348 | fclose(f); |
| 7349 | return ERROR_SEND_STATUS; |
| 7350 | } |
| 7351 | |
| 7352 | pos = tmp; |
| 7353 | while (*pos) { |
| 7354 | end = strchr(pos, ';'); |
| 7355 | if (end) |
| 7356 | *end = '\0'; |
| 7357 | id = strchr(pos, ':'); |
| 7358 | if (id) |
| 7359 | *id++ = '\0'; |
| 7360 | |
| 7361 | fprintf(f, "sae_password=%s%s%s\n", |
| 7362 | pos, id ? "|id=" : "", id ? id : ""); |
| 7363 | if (!end) |
| 7364 | break; |
| 7365 | pos = end + 1; |
| 7366 | } |
| 7367 | |
| 7368 | free(tmp); |
| 7369 | } |
| 7370 | |
Anilkumar Kolli | f0fd599 | 2017-02-23 12:54:01 +0530 | [diff] [blame] | 7371 | if (dut->ap_rsn_preauth) |
| 7372 | fprintf(f, "rsn_preauth=1\n"); |
| 7373 | |
Jouni Malinen | b75c532 | 2019-06-14 01:47:43 +0300 | [diff] [blame] | 7374 | if (dut->ap_pmksa && dut->ap_pmksa_caching) |
| 7375 | fprintf(f, "disable_pmksa_caching=1\n"); |
| 7376 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7377 | switch (dut->ap_pmf) { |
| 7378 | case AP_PMF_DISABLED: |
| 7379 | break; |
| 7380 | case AP_PMF_OPTIONAL: |
| 7381 | fprintf(f, "ieee80211w=1\n"); |
Jouni Malinen | da5f35b | 2019-03-26 00:25:53 +0200 | [diff] [blame] | 7382 | if (dut->ap_key_mgmt == AP_WPA2_PSK_SAE || |
| 7383 | (dut->ap_akm_values & (AKM_SAE | AKM_WPA_PSK)) == |
| 7384 | (AKM_SAE | AKM_WPA_PSK)) |
Jouni Malinen | 1287cd7 | 2018-01-04 17:08:01 +0200 | [diff] [blame] | 7385 | fprintf(f, "sae_require_mfp=1\n"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7386 | break; |
| 7387 | case AP_PMF_REQUIRED: |
| 7388 | fprintf(f, "ieee80211w=2\n"); |
| 7389 | break; |
| 7390 | } |
| 7391 | |
Jouni Malinen | 10ed9e7 | 2019-03-28 03:00:11 +0200 | [diff] [blame] | 7392 | if (dut->ap_pmf != AP_PMF_DISABLED && |
| 7393 | dut->ap_group_mgmt_cipher != AP_NO_GROUP_MGMT_CIPHER_SET) |
| 7394 | fprintf(f, "group_mgmt_cipher=%s\n", |
| 7395 | hostapd_group_mgmt_cipher_name( |
| 7396 | dut->ap_group_mgmt_cipher)); |
| 7397 | |
Jouni Malinen | 6be21c8 | 2018-08-01 18:47:24 +0300 | [diff] [blame] | 7398 | if (ap_ft_enabled(dut)) { |
| 7399 | unsigned char own_addr[ETH_ALEN]; |
| 7400 | |
| 7401 | fprintf(f, "mobility_domain=%s\n", dut->ap_mobility_domain); |
Jouni Malinen | 9f94331 | 2019-08-19 23:49:16 +0300 | [diff] [blame] | 7402 | 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] | 7403 | if (get_hwaddr(ifname, own_addr) < 0) { |
| 7404 | memset(own_addr, 0, ETH_ALEN); |
| 7405 | own_addr[0] = 0x02; |
| 7406 | } |
Jouni Malinen | c967446 | 2019-03-26 02:40:19 +0200 | [diff] [blame] | 7407 | fprintf(f, |
| 7408 | "nas_identifier=%02x%02x%02x%02x%02x%02x.nas.example.com\n", |
| 7409 | own_addr[0], own_addr[1], own_addr[2], |
| 7410 | own_addr[3], own_addr[4], own_addr[5]); |
Jouni Malinen | 6be21c8 | 2018-08-01 18:47:24 +0300 | [diff] [blame] | 7411 | fprintf(f, "r1_key_holder=%02x%02x%02x%02x%02x%02x\n", |
| 7412 | own_addr[0], own_addr[1], own_addr[2], |
| 7413 | own_addr[3], own_addr[4], own_addr[5]); |
| 7414 | fprintf(f, "ft_psk_generate_local=1\n"); |
| 7415 | fprintf(f, "pmk_r1_push=0\n"); |
| 7416 | fprintf(f, |
Jouni Malinen | 69222a6 | 2019-03-26 01:56:20 +0200 | [diff] [blame] | 7417 | "r0kh=ff:ff:ff:ff:ff:ff * 00112233445566778899aabbccddeeff00112233445566778899aabbccddeeff\n"); |
Jouni Malinen | 6be21c8 | 2018-08-01 18:47:24 +0300 | [diff] [blame] | 7418 | fprintf(f, |
Jouni Malinen | 69222a6 | 2019-03-26 01:56:20 +0200 | [diff] [blame] | 7419 | "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] | 7420 | } |
| 7421 | |
Jouni Malinen | 3c367e8 | 2017-06-23 17:01:47 +0300 | [diff] [blame] | 7422 | if (dut->rsne_override) |
| 7423 | fprintf(f, "own_ie_override=%s\n", dut->rsne_override); |
| 7424 | |
Jouni Malinen | 6814313 | 2017-09-02 02:34:08 +0300 | [diff] [blame] | 7425 | if (dut->sae_commit_override) |
| 7426 | fprintf(f, "sae_commit_override=%s\n", |
| 7427 | dut->sae_commit_override); |
| 7428 | |
Jouni Malinen | ed670f4 | 2017-08-31 01:39:28 +0300 | [diff] [blame] | 7429 | if (dut->ap_sae_groups) |
| 7430 | fprintf(f, "sae_groups=%s\n", dut->ap_sae_groups); |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 7431 | |
Jouni Malinen | 2f524ce | 2017-08-31 01:43:29 +0300 | [diff] [blame] | 7432 | if (dut->sae_anti_clogging_threshold >= 0) |
| 7433 | fprintf(f, "sae_anti_clogging_threshold=%d\n", |
| 7434 | dut->sae_anti_clogging_threshold); |
Jouni Malinen | b347db0 | 2017-09-02 01:36:03 +0300 | [diff] [blame] | 7435 | if (dut->sae_reflection) |
| 7436 | fprintf(f, "sae_reflection_attack=1\n"); |
Jouni Malinen | 3c740ab | 2019-10-10 15:55:11 +0300 | [diff] [blame] | 7437 | if (dut->sae_confirm_immediate) |
| 7438 | fprintf(f, "sae_confirm_immediate=1\n"); |
Jouni Malinen | 2f524ce | 2017-08-31 01:43:29 +0300 | [diff] [blame] | 7439 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7440 | if (dut->ap_p2p_mgmt) |
| 7441 | fprintf(f, "manage_p2p=1\n"); |
| 7442 | |
| 7443 | if (dut->ap_tdls_prohibit || dut->ap_l2tif) |
| 7444 | fprintf(f, "tdls_prohibit=1\n"); |
| 7445 | if (dut->ap_tdls_prohibit_chswitch || dut->ap_l2tif) |
| 7446 | fprintf(f, "tdls_prohibit_chan_switch=1\n"); |
| 7447 | if (dut->ap_p2p_cross_connect >= 0) { |
| 7448 | fprintf(f, "manage_p2p=1\n" |
| 7449 | "allow_cross_connection=%d\n", |
| 7450 | dut->ap_p2p_cross_connect); |
| 7451 | } |
| 7452 | |
Jouni Malinen | 4d479c9 | 2018-11-06 00:43:36 +0200 | [diff] [blame] | 7453 | if (dut->ap_l2tif || dut->ap_proxy_arp || |
| 7454 | dut->ap_key_mgmt == AP_WPA2_EAP_OSEN) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7455 | if (!dut->bridge) { |
| 7456 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 7457 | "Bridge must be configured. Run with -b <brname>."); |
| 7458 | fclose(f); |
| 7459 | return -2; |
| 7460 | } |
| 7461 | fprintf(f, "ap_isolate=1\n"); |
| 7462 | } |
| 7463 | |
| 7464 | if (dut->ap_proxy_arp) |
| 7465 | fprintf(f, "proxy_arp=1\n"); |
| 7466 | |
Pradeep Reddy POTTETI | 0d3db63 | 2016-03-11 15:21:11 +0530 | [diff] [blame] | 7467 | if (dut->ap_wme) |
| 7468 | fprintf(f, "wmm_enabled=1\n"); |
| 7469 | |
Mohammed Shafi Shajakhan | 02e3b82 | 2017-02-23 04:15:02 +0530 | [diff] [blame] | 7470 | if (dut->ap_wmmps == AP_WMMPS_ON) |
| 7471 | fprintf(f, "uapsd_advertisement_enabled=1\n"); |
| 7472 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7473 | if (dut->ap_hs2) { |
| 7474 | if (dut->ap_bss_load) { |
| 7475 | char *bss_load; |
| 7476 | |
| 7477 | switch (dut->ap_bss_load) { |
| 7478 | case -1: |
| 7479 | bss_load = "bss_load_update_period=10"; |
| 7480 | break; |
| 7481 | case 1: |
| 7482 | /* STA count: 1, CU: 50, AAC: 65535 */ |
| 7483 | bss_load = "bss_load_test=1:50:65535"; |
| 7484 | break; |
| 7485 | case 2: |
| 7486 | /* STA count: 1, CU: 200, AAC: 65535 */ |
| 7487 | bss_load = "bss_load_test=1:200:65535"; |
| 7488 | break; |
| 7489 | case 3: |
| 7490 | /* STA count: 1, CU: 75, AAC: 65535 */ |
| 7491 | bss_load = "bss_load_test=1:75:65535"; |
| 7492 | break; |
| 7493 | default: |
| 7494 | bss_load = NULL; |
| 7495 | break; |
| 7496 | } |
| 7497 | |
| 7498 | if (!bss_load) { |
| 7499 | fclose(f); |
| 7500 | return -2; |
| 7501 | } |
| 7502 | fprintf(f, "%s\n", bss_load); |
| 7503 | } |
| 7504 | |
| 7505 | if (append_hostapd_conf_hs2(dut, f)) { |
| 7506 | fclose(f); |
| 7507 | return -2; |
| 7508 | } |
| 7509 | } |
| 7510 | |
| 7511 | if (dut->ap_interworking && append_hostapd_conf_interworking(dut, f)) { |
| 7512 | fclose(f); |
| 7513 | return -2; |
| 7514 | } |
| 7515 | |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 7516 | if (dut->ap_hs2 && strlen(dut->ap_tag_ssid[0])) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7517 | unsigned char bssid[6]; |
| 7518 | char ifname2[50]; |
| 7519 | |
Pradeep Reddy POTTETI | 673d85c | 2016-07-26 19:08:07 +0530 | [diff] [blame] | 7520 | if (get_hwaddr(ifname, bssid)) { |
| 7521 | fclose(f); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7522 | return -2; |
Pradeep Reddy POTTETI | 673d85c | 2016-07-26 19:08:07 +0530 | [diff] [blame] | 7523 | } |
Jouni Malinen | b37f0bc | 2018-05-03 18:29:55 +0300 | [diff] [blame] | 7524 | if (bssid[0] & 0x02) |
| 7525 | bssid[5] ^= 0x01; |
| 7526 | else |
| 7527 | bssid[0] |= 0x02; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7528 | |
| 7529 | snprintf(ifname2, sizeof(ifname2), "%s_1", ifname); |
Jouni Malinen | 10b47b2 | 2018-06-07 23:28:07 +0300 | [diff] [blame] | 7530 | fprintf(f, "bss=%s\n", ifname2); |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 7531 | fprintf(f, "ssid=%s\n", dut->ap_tag_ssid[0]); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7532 | if (dut->bridge) |
| 7533 | fprintf(f, "bridge=%s\n", dut->bridge); |
Liangwei Dong | 911cb14 | 2019-01-10 14:35:55 +0800 | [diff] [blame] | 7534 | |
| 7535 | if (drv == DRIVER_LINUX_WCN) |
| 7536 | fprintf(f, "use_driver_iface_addr=1\n"); |
| 7537 | else |
| 7538 | fprintf(f, "bssid=%02x:%02x:%02x:%02x:%02x:%02x\n", |
| 7539 | bssid[0], bssid[1], bssid[2], bssid[3], |
| 7540 | bssid[4], bssid[5]); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7541 | |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 7542 | if (dut->ap_tag_key_mgmt[0] == AP2_OSEN) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7543 | fprintf(f, "osen=1\n"); |
Sriram R | 61f5d95 | 2018-06-07 17:47:07 +0530 | [diff] [blame] | 7544 | /* Disable DGAF for OSEN BSS */ |
| 7545 | fprintf(f, "disable_dgaf=1\n"); |
Jouni Malinen | dbbc2c4 | 2018-11-14 23:55:41 +0200 | [diff] [blame] | 7546 | fprintf(f, "ap_isolate=1\n"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7547 | if (strlen(dut->ap2_radius_ipaddr)) |
| 7548 | fprintf(f, "auth_server_addr=%s\n", |
| 7549 | dut->ap2_radius_ipaddr); |
| 7550 | if (dut->ap2_radius_port) |
| 7551 | fprintf(f, "auth_server_port=%d\n", |
| 7552 | dut->ap2_radius_port); |
| 7553 | if (strlen(dut->ap2_radius_password)) |
| 7554 | fprintf(f, "auth_server_shared_secret=%s\n", |
| 7555 | dut->ap2_radius_password); |
Jouni Malinen | dbbc2c4 | 2018-11-14 23:55:41 +0200 | [diff] [blame] | 7556 | |
| 7557 | set_ebtables_forward_drop(dut, ifname, ifname2); |
| 7558 | } else if (dut->ap2_osu) { |
| 7559 | fprintf(f, "ap_isolate=1\n"); |
| 7560 | set_ebtables_forward_drop(dut, ifname, ifname2); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7561 | } |
| 7562 | |
| 7563 | if (dut->ap2_proxy_arp) { |
| 7564 | if (!dut->bridge) { |
| 7565 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 7566 | "Bridge must be configured. Run with -b <brname>."); |
| 7567 | fclose(f); |
| 7568 | return -2; |
| 7569 | } |
| 7570 | fprintf(f, "ap_isolate=1\n"); |
| 7571 | fprintf(f, "proxy_arp=1\n"); |
| 7572 | |
| 7573 | if (set_ebtables_proxy_arp(dut, "FORWARD", ifname2) || |
| 7574 | set_ebtables_proxy_arp(dut, "OUTPUT", ifname2)) { |
| 7575 | fclose(f); |
| 7576 | return -2; |
| 7577 | } |
| 7578 | |
| 7579 | } |
| 7580 | } |
| 7581 | |
| 7582 | if (dut->program == PROGRAM_WPS) { |
Alexei Avshalom Lazar | d303e47 | 2018-12-23 16:49:49 +0200 | [diff] [blame] | 7583 | /* 60G WPS tests requires wps_state of 2 (configured) */ |
| 7584 | int wps_state = is_60g_sigma_dut(dut) ? 2 : 1; |
| 7585 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7586 | fprintf(f, "eap_server=1\n" |
Alexei Avshalom Lazar | d303e47 | 2018-12-23 16:49:49 +0200 | [diff] [blame] | 7587 | "wps_state=%d\n" |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7588 | "device_name=QCA AP\n" |
| 7589 | "manufacturer=QCA\n" |
| 7590 | "device_type=6-0050F204-1\n" |
Alexei Avshalom Lazar | d303e47 | 2018-12-23 16:49:49 +0200 | [diff] [blame] | 7591 | "config_methods=label virtual_display %s" |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7592 | "virtual_push_button keypad%s\n" |
| 7593 | "ap_pin=12345670\n" |
| 7594 | "friendly_name=QCA Access Point\n" |
| 7595 | "upnp_iface=%s\n", |
Alexei Avshalom Lazar | d303e47 | 2018-12-23 16:49:49 +0200 | [diff] [blame] | 7596 | wps_state, |
| 7597 | is_60g_sigma_dut(dut) ? "physical_display " : "", |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7598 | dut->ap_wpsnfc ? " nfc_interface ext_nfc_token" : "", |
| 7599 | dut->bridge ? dut->bridge : ifname); |
Alexei Avshalom Lazar | 33f700c | 2018-12-18 16:00:39 +0200 | [diff] [blame] | 7600 | if (dut->wsc_fragment) { |
| 7601 | fprintf(f, "device_name=%s\n" |
| 7602 | "manufacturer=%s\n" |
| 7603 | "model_name=%s\n" |
| 7604 | "model_number=%s\n" |
| 7605 | "serial_number=%s\n", |
| 7606 | WPS_LONG_DEVICE_NAME, |
| 7607 | WPS_LONG_MANUFACTURER, |
| 7608 | WPS_LONG_MODEL_NAME, |
| 7609 | WPS_LONG_MODEL_NUMBER, |
| 7610 | WPS_LONG_SERIAL_NUMBER); |
| 7611 | } else { |
| 7612 | fprintf(f, "device_name=QCA AP\n" |
| 7613 | "manufacturer=QCA\n"); |
| 7614 | } |
Alexei Avshalom Lazar | 2eccf4d | 2019-01-31 10:03:59 +0200 | [diff] [blame] | 7615 | if (dut->eap_fragment) |
| 7616 | fprintf(f, "fragment_size=128\n"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7617 | } |
| 7618 | |
Jouni Malinen | ba4f2d4 | 2019-10-04 16:13:41 +0300 | [diff] [blame] | 7619 | if (dut->ap_dpp_conf_addr && dut->ap_dpp_conf_pkhash) |
| 7620 | fprintf(f, "dpp_controller=ipaddr=%s pkhash=%s\n", |
| 7621 | dut->ap_dpp_conf_addr, dut->ap_dpp_conf_pkhash); |
| 7622 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7623 | if (dut->program == PROGRAM_VHT) { |
| 7624 | int vht_oper_centr_freq_idx; |
| 7625 | |
| 7626 | if (check_channel(dut->ap_channel) < 0) { |
| 7627 | send_resp(dut, conn, SIGMA_INVALID, |
| 7628 | "errorCode,Invalid channel"); |
Pradeep Reddy POTTETI | 673d85c | 2016-07-26 19:08:07 +0530 | [diff] [blame] | 7629 | fclose(f); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7630 | return 0; |
| 7631 | } |
| 7632 | |
| 7633 | switch (dut->ap_chwidth) { |
| 7634 | case AP_20: |
| 7635 | dut->ap_vht_chwidth = AP_20_40_VHT_OPER_CHWIDTH; |
| 7636 | vht_oper_centr_freq_idx = |
| 7637 | get_oper_centr_freq_seq_idx(20, |
| 7638 | dut->ap_channel); |
| 7639 | break; |
| 7640 | case AP_40: |
| 7641 | dut->ap_vht_chwidth = AP_20_40_VHT_OPER_CHWIDTH; |
| 7642 | vht_oper_centr_freq_idx = |
| 7643 | get_oper_centr_freq_seq_idx(40, |
| 7644 | dut->ap_channel); |
| 7645 | break; |
| 7646 | case AP_80: |
| 7647 | dut->ap_vht_chwidth = AP_80_VHT_OPER_CHWIDTH; |
| 7648 | vht_oper_centr_freq_idx = |
| 7649 | get_oper_centr_freq_seq_idx(80, |
| 7650 | dut->ap_channel); |
| 7651 | break; |
| 7652 | case AP_160: |
| 7653 | dut->ap_vht_chwidth = AP_160_VHT_OPER_CHWIDTH; |
| 7654 | vht_oper_centr_freq_idx = |
| 7655 | get_oper_centr_freq_seq_idx(160, |
| 7656 | dut->ap_channel); |
| 7657 | break; |
| 7658 | default: |
| 7659 | dut->ap_vht_chwidth = VHT_DEFAULT_OPER_CHWIDTH; |
| 7660 | vht_oper_centr_freq_idx = |
| 7661 | get_oper_centr_freq_seq_idx(80, |
| 7662 | dut->ap_channel); |
| 7663 | break; |
| 7664 | } |
| 7665 | fprintf(f, "vht_oper_centr_freq_seg0_idx=%d\n", |
| 7666 | vht_oper_centr_freq_idx); |
| 7667 | fprintf(f, "vht_oper_chwidth=%d\n", dut->ap_vht_chwidth); |
| 7668 | |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 7669 | if (dut->ap_sgi80 || dut->ap_txBF || |
| 7670 | dut->ap_ldpc != VALUE_NOT_SET || |
Mohammed Shafi Shajakhan | f3e68d9 | 2016-06-02 20:10:57 +0530 | [diff] [blame] | 7671 | dut->ap_tx_stbc || dut->ap_mu_txBF) { |
| 7672 | fprintf(f, "vht_capab=%s%s%s%s%s\n", |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7673 | dut->ap_sgi80 ? "[SHORT-GI-80]" : "", |
Mohammed Shafi Shajakhan | c039ce3 | 2016-06-02 20:10:58 +0530 | [diff] [blame] | 7674 | dut->ap_txBF ? |
Tamizh chelvam | 8312f6d | 2016-06-02 20:10:59 +0530 | [diff] [blame] | 7675 | "[SU-BEAMFORMER][SU-BEAMFORMEE][BF-ANTENNA-2][SOUNDING-DIMENSION-2]" : "", |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 7676 | (dut->ap_ldpc == VALUE_ENABLED) ? |
| 7677 | "[RXLDPC]" : "", |
Mohammed Shafi Shajakhan | f3e68d9 | 2016-06-02 20:10:57 +0530 | [diff] [blame] | 7678 | dut->ap_tx_stbc ? "[TX-STBC-2BY1]" : "", |
| 7679 | dut->ap_mu_txBF ? "[MU-BEAMFORMER]" : ""); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7680 | } |
| 7681 | } |
| 7682 | |
Jouni Malinen | 6d1d739 | 2017-10-10 20:35:29 +0300 | [diff] [blame] | 7683 | if (dut->ap_key_mgmt == AP_WPA2_OWE && dut->ap_tag_ssid[0][0] && |
| 7684 | dut->ap_tag_key_mgmt[0] == AP2_OPEN) { |
| 7685 | /* OWE transition mode */ |
| 7686 | unsigned char bssid[6]; |
| 7687 | char ifname2[50]; |
| 7688 | unsigned long val; |
| 7689 | FILE *f2; |
| 7690 | |
| 7691 | snprintf(ifname2, sizeof(ifname2), "%s_1", ifname); |
| 7692 | |
| 7693 | fprintf(f, "owe_transition_ifname=%s\n", ifname2); |
| 7694 | val = 0x12345678; /* default to something */ |
| 7695 | f2 = fopen("/dev/urandom", "r"); |
| 7696 | if (f2) { |
| 7697 | if (fread(&val, 1, sizeof(val), f2) != sizeof(val)) { |
| 7698 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 7699 | "Could not read /dev/urandom"); |
| 7700 | } |
| 7701 | fclose(f2); |
| 7702 | } |
| 7703 | fprintf(f, "ssid=owe-%lx\n", val); |
Liangwei Dong | d3b87da | 2019-01-09 20:10:20 +0800 | [diff] [blame] | 7704 | fprintf(f, "ignore_broadcast_ssid=1\n"); |
Jouni Malinen | 6d1d739 | 2017-10-10 20:35:29 +0300 | [diff] [blame] | 7705 | |
| 7706 | if (get_hwaddr(ifname, bssid)) { |
| 7707 | fclose(f); |
| 7708 | return -2; |
| 7709 | } |
| 7710 | if (bssid[0] & 0x02) |
| 7711 | bssid[5] ^= 0x01; |
| 7712 | else |
| 7713 | bssid[0] |= 0x02; |
| 7714 | |
| 7715 | fprintf(f, "bss=%s\n", ifname2); |
| 7716 | fprintf(f, "ssid=%s\n", dut->ap_ssid); |
| 7717 | if (dut->bridge) |
| 7718 | fprintf(f, "bridge=%s\n", dut->bridge); |
Liangwei Dong | 911cb14 | 2019-01-10 14:35:55 +0800 | [diff] [blame] | 7719 | if (drv == DRIVER_LINUX_WCN) |
| 7720 | fprintf(f, "use_driver_iface_addr=1\n"); |
| 7721 | else |
| 7722 | fprintf(f, "bssid=%02x:%02x:%02x:%02x:%02x:%02x\n", |
| 7723 | bssid[0], bssid[1], bssid[2], bssid[3], |
| 7724 | bssid[4], bssid[5]); |
Jouni Malinen | 6d1d739 | 2017-10-10 20:35:29 +0300 | [diff] [blame] | 7725 | fprintf(f, "owe_transition_ifname=%s\n", ifname); |
| 7726 | } |
| 7727 | |
Jouni Malinen | 353ba8b | 2018-01-10 17:04:12 +0200 | [diff] [blame] | 7728 | if (dut->ap_key_mgmt == AP_OPEN && |
| 7729 | dut->ap_tag_key_mgmt[0] == AP2_WPA2_OWE) { |
| 7730 | /* OWE transition mode */ |
| 7731 | unsigned char bssid[6]; |
| 7732 | char ifname2[50]; |
| 7733 | unsigned long val; |
| 7734 | FILE *f2; |
| 7735 | |
| 7736 | snprintf(ifname2, sizeof(ifname2), "%s_1", ifname); |
| 7737 | |
| 7738 | fprintf(f, "owe_transition_ifname=%s\n", ifname2); |
| 7739 | fprintf(f, "ssid=%s\n", dut->ap_ssid); |
| 7740 | |
| 7741 | if (get_hwaddr(ifname, bssid)) { |
| 7742 | fclose(f); |
| 7743 | return -2; |
| 7744 | } |
| 7745 | if (bssid[0] & 0x02) |
| 7746 | bssid[5] ^= 0x01; |
| 7747 | else |
| 7748 | bssid[0] |= 0x02; |
| 7749 | |
| 7750 | fprintf(f, "bss=%s\n", ifname2); |
| 7751 | val = 0x12345678; /* default to something */ |
| 7752 | f2 = fopen("/dev/urandom", "r"); |
| 7753 | if (f2) { |
| 7754 | if (fread(&val, 1, sizeof(val), f2) != sizeof(val)) { |
| 7755 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 7756 | "Could not read /dev/urandom"); |
| 7757 | } |
| 7758 | fclose(f2); |
| 7759 | } |
| 7760 | fprintf(f, "ssid=owe-%lx\n", val); |
| 7761 | if (dut->bridge) |
| 7762 | fprintf(f, "bridge=%s\n", dut->bridge); |
Liangwei Dong | 911cb14 | 2019-01-10 14:35:55 +0800 | [diff] [blame] | 7763 | if (drv == DRIVER_LINUX_WCN) |
| 7764 | fprintf(f, "use_driver_iface_addr=1\n"); |
| 7765 | else |
| 7766 | fprintf(f, "bssid=%02x:%02x:%02x:%02x:%02x:%02x\n", |
| 7767 | bssid[0], bssid[1], bssid[2], bssid[3], |
| 7768 | bssid[4], bssid[5]); |
Jouni Malinen | 353ba8b | 2018-01-10 17:04:12 +0200 | [diff] [blame] | 7769 | fprintf(f, "owe_transition_ifname=%s\n", ifname); |
| 7770 | fprintf(f, "wpa=2\n"); |
| 7771 | fprintf(f, "wpa_key_mgmt=OWE\n"); |
| 7772 | fprintf(f, "rsn_pairwise=CCMP\n"); |
| 7773 | fprintf(f, "ieee80211w=2\n"); |
Liangwei Dong | d3b87da | 2019-01-09 20:10:20 +0800 | [diff] [blame] | 7774 | fprintf(f, "ignore_broadcast_ssid=1\n"); |
Jouni Malinen | 353ba8b | 2018-01-10 17:04:12 +0200 | [diff] [blame] | 7775 | if (dut->ap_sae_groups) |
| 7776 | fprintf(f, "owe_groups=%s\n", dut->ap_sae_groups); |
| 7777 | } |
| 7778 | |
Ankita Bajaj | 0d5825b | 2017-10-25 16:20:17 +0530 | [diff] [blame] | 7779 | if (dut->program == PROGRAM_OCE) { |
| 7780 | fprintf(f, "oce=%d\n", |
| 7781 | dut->dev_role == DEVROLE_STA_CFON ? 2 : 1); |
| 7782 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7783 | fclose(f); |
Jouni Malinen | d6bf1b4 | 2017-06-23 17:51:01 +0300 | [diff] [blame] | 7784 | if (dut->use_hostapd_pid_file) |
| 7785 | kill_hostapd_process_pid(dut); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7786 | #ifdef __QNXNTO__ |
| 7787 | if (system("slay hostapd") == 0) |
| 7788 | #else /* __QNXNTO__ */ |
Jouni Malinen | d6bf1b4 | 2017-06-23 17:51:01 +0300 | [diff] [blame] | 7789 | if (!dut->use_hostapd_pid_file && |
| 7790 | (kill_process(dut, "(hostapd)", 1, SIGTERM) == 0 || |
| 7791 | system("killall hostapd") == 0)) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7792 | #endif /* __QNXNTO__ */ |
| 7793 | { |
| 7794 | int i; |
| 7795 | /* Wait some time to allow hostapd to complete cleanup before |
| 7796 | * starting a new process */ |
| 7797 | for (i = 0; i < 10; i++) { |
| 7798 | usleep(500000); |
| 7799 | #ifdef __QNXNTO__ |
| 7800 | if (system("pidin | grep hostapd") != 0) |
| 7801 | break; |
| 7802 | #else /* __QNXNTO__ */ |
| 7803 | if (system("pidof hostapd") != 0) |
| 7804 | break; |
| 7805 | #endif /* __QNXNTO__ */ |
| 7806 | } |
| 7807 | } |
Jouni Malinen | d86e582 | 2017-08-29 03:55:32 +0300 | [diff] [blame] | 7808 | dut->hostapd_running = 0; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7809 | |
Pradeep Reddy POTTETI | a076c30 | 2016-05-16 13:36:07 +0530 | [diff] [blame] | 7810 | #ifdef ANDROID |
| 7811 | /* Set proper conf file permissions so that hostapd process |
| 7812 | * can access it. |
| 7813 | */ |
| 7814 | if (chmod(SIGMA_TMPDIR "/sigma_dut-ap.conf", |
| 7815 | S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP) < 0) |
| 7816 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 7817 | "Error changing permissions"); |
| 7818 | |
Srinivas Dasari | a1deeaa | 2018-06-18 22:54:04 +0530 | [diff] [blame] | 7819 | gr = getgrnam("wifi"); |
| 7820 | if (!gr || |
| 7821 | 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] | 7822 | sigma_dut_print(dut, DUT_MSG_ERROR, "Error changing groupid"); |
| 7823 | #endif /* ANDROID */ |
| 7824 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7825 | if (drv == DRIVER_QNXNTO) { |
| 7826 | snprintf(buf, sizeof(buf), |
Pradeep Reddy POTTETI | bf4a974 | 2016-02-04 12:32:30 +0530 | [diff] [blame] | 7827 | "hostapd -B %s%s %s%s" SIGMA_TMPDIR |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7828 | "/sigma_dut-ap.conf", |
| 7829 | dut->hostapd_debug_log ? "-ddKt -f " : "", |
| 7830 | dut->hostapd_debug_log ? dut->hostapd_debug_log : "", |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7831 | dut->hostapd_entropy_log ? " -e" : "", |
| 7832 | dut->hostapd_entropy_log ? dut->hostapd_entropy_log : |
| 7833 | ""); |
| 7834 | } else { |
| 7835 | /* |
| 7836 | * It looks like a monitor interface can cause some issues for |
| 7837 | * beaconing, so remove it (if injection was used) before |
| 7838 | * starting hostapd. |
| 7839 | */ |
| 7840 | if (if_nametoindex("sigmadut") > 0 && |
| 7841 | system("iw dev sigmadut del") != 0) |
| 7842 | sigma_dut_print(dut, DUT_MSG_ERROR, "Failed to remove " |
| 7843 | "monitor interface"); |
| 7844 | |
Jouni Malinen | d6bf1b4 | 2017-06-23 17:51:01 +0300 | [diff] [blame] | 7845 | snprintf(path, sizeof(path), "%shostapd", |
| 7846 | file_exists("hostapd") ? "./" : ""); |
| 7847 | 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] | 7848 | "/sigma_dut-ap.conf", |
Jouni Malinen | d6bf1b4 | 2017-06-23 17:51:01 +0300 | [diff] [blame] | 7849 | dut->hostapd_bin ? dut->hostapd_bin : path, |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7850 | dut->hostapd_debug_log ? " -ddKt -f" : "", |
| 7851 | dut->hostapd_debug_log ? dut->hostapd_debug_log : "", |
| 7852 | dut->hostapd_entropy_log ? " -e" : "", |
| 7853 | dut->hostapd_entropy_log ? dut->hostapd_entropy_log : |
Jouni Malinen | d6bf1b4 | 2017-06-23 17:51:01 +0300 | [diff] [blame] | 7854 | "", |
| 7855 | dut->use_hostapd_pid_file ? |
| 7856 | " -P " SIGMA_DUT_HOSTAPD_PID_FILE : ""); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7857 | } |
| 7858 | |
Jouni Malinen | d6bf1b4 | 2017-06-23 17:51:01 +0300 | [diff] [blame] | 7859 | sigma_dut_print(dut, DUT_MSG_DEBUG, "hostapd command: %s", buf); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7860 | if (system(buf) != 0) { |
| 7861 | send_resp(dut, conn, SIGMA_ERROR, |
| 7862 | "errorCode,Failed to start hostapd"); |
| 7863 | return 0; |
| 7864 | } |
| 7865 | |
| 7866 | /* allow some time for hostapd to start before returning success */ |
| 7867 | usleep(500000); |
| 7868 | if (run_hostapd_cli(dut, "ping") != 0) { |
| 7869 | send_resp(dut, conn, SIGMA_ERROR, |
| 7870 | "errorCode,Failed to talk to hostapd"); |
| 7871 | return 0; |
| 7872 | } |
| 7873 | |
Pradeep Reddy Potteti | 923a9b3 | 2017-06-14 12:18:59 +0530 | [diff] [blame] | 7874 | if (drv == DRIVER_LINUX_WCN) { |
Hu Wang | f5cb900 | 2019-08-21 14:18:57 +0800 | [diff] [blame] | 7875 | const char *ifname_ptr = ifname; |
| 7876 | |
| 7877 | if ((dut->ap_key_mgmt == AP_OPEN && |
| 7878 | dut->ap_tag_key_mgmt[0] == AP2_WPA2_OWE) || |
| 7879 | (dut->ap_key_mgmt == AP_WPA2_OWE && |
| 7880 | dut->ap_tag_ssid[0][0] && |
| 7881 | dut->ap_tag_key_mgmt[0] == AP2_OPEN)) { |
| 7882 | /* OWE transition mode */ |
| 7883 | if (dut->bridge) |
| 7884 | ifname_ptr = dut->bridge; |
| 7885 | } |
| 7886 | |
| 7887 | sigma_dut_print(dut, DUT_MSG_INFO, |
| 7888 | "setting ip addr %s mask %s ifname %s", |
| 7889 | ap_inet_addr, ap_inet_mask, ifname_ptr); |
Pradeep Reddy Potteti | 923a9b3 | 2017-06-14 12:18:59 +0530 | [diff] [blame] | 7890 | snprintf(buf, sizeof(buf), "ifconfig %s %s netmask %s up", |
Hu Wang | f5cb900 | 2019-08-21 14:18:57 +0800 | [diff] [blame] | 7891 | ifname_ptr, ap_inet_addr, ap_inet_mask); |
Pradeep Reddy Potteti | 923a9b3 | 2017-06-14 12:18:59 +0530 | [diff] [blame] | 7892 | if (system(buf) != 0) { |
| 7893 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 7894 | "Failed to initialize the interface"); |
| 7895 | return -1; |
| 7896 | } |
| 7897 | } |
| 7898 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7899 | if (dut->ap_l2tif) { |
| 7900 | snprintf(path, sizeof(path), |
| 7901 | "/sys/class/net/%s/brport/hairpin_mode", |
| 7902 | ifname); |
| 7903 | if (!file_exists(path)) { |
| 7904 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 7905 | "%s must be binded to the bridge for L2TIF", |
| 7906 | ifname); |
| 7907 | return -2; |
| 7908 | } |
| 7909 | |
| 7910 | snprintf(buf, sizeof(buf), "echo 1 > %s", path); |
| 7911 | if (system(buf) != 0) { |
| 7912 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 7913 | "Failed to enable hairpin_mode for L2TIF"); |
| 7914 | return -2; |
| 7915 | } |
| 7916 | |
| 7917 | snprintf(buf, sizeof(buf), "ebtables -P FORWARD ACCEPT"); |
| 7918 | if (system(buf) != 0) { |
| 7919 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 7920 | "Failed to set ebtables rules, RULE-9"); |
| 7921 | return -2; |
| 7922 | } |
| 7923 | |
| 7924 | snprintf(buf, sizeof(buf), |
| 7925 | "ebtables -A FORWARD -p IPv4 --ip-proto icmp -i %s -j DROP", |
| 7926 | ifname); |
| 7927 | if (system(buf) != 0) { |
| 7928 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 7929 | "Failed to set ebtables rules, RULE-11"); |
| 7930 | return -2; |
| 7931 | } |
| 7932 | } |
| 7933 | |
| 7934 | if (dut->ap_proxy_arp) { |
| 7935 | if (dut->ap_dgaf_disable) { |
| 7936 | if (set_ebtables_disable_dgaf(dut, "FORWARD", ifname) || |
| 7937 | set_ebtables_disable_dgaf(dut, "OUTPUT", ifname)) |
| 7938 | return -2; |
| 7939 | } else { |
| 7940 | if (set_ebtables_proxy_arp(dut, "FORWARD", ifname) || |
| 7941 | set_ebtables_proxy_arp(dut, "OUTPUT", ifname)) |
| 7942 | return -2; |
| 7943 | } |
| 7944 | |
| 7945 | /* For 4.5-(c) */ |
| 7946 | snprintf(buf, sizeof(buf), |
| 7947 | "ebtables -A FORWARD -p ARP --arp-opcode 2 -i %s -j DROP", |
| 7948 | ifname); |
| 7949 | if (system(buf) != 0) { |
| 7950 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 7951 | "Failed to set ebtables rules, RULE-10"); |
| 7952 | return -2; |
| 7953 | } |
| 7954 | } |
| 7955 | |
| 7956 | if (dut->ap_tdls_prohibit || dut->ap_l2tif) { |
| 7957 | /* Drop TDLS frames */ |
| 7958 | snprintf(buf, sizeof(buf), |
| 7959 | "ebtables -A FORWARD -p 0x890d -i %s -j DROP", ifname); |
| 7960 | if (system(buf) != 0) { |
| 7961 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 7962 | "Failed to set ebtables rules, RULE-13"); |
| 7963 | return -2; |
| 7964 | } |
| 7965 | } |
| 7966 | |
| 7967 | if (dut->ap_fake_pkhash && |
| 7968 | run_hostapd_cli(dut, "set wps_corrupt_pkhash 1") != 0) { |
| 7969 | send_resp(dut, conn, SIGMA_ERROR, |
| 7970 | "errorCode,Could not enable FakePubKey"); |
| 7971 | return 0; |
| 7972 | } |
| 7973 | |
Alexei Avshalom Lazar | bc180dc | 2018-12-18 16:01:14 +0200 | [diff] [blame] | 7974 | if (dut->program == PROGRAM_60GHZ && dut->ap_num_ese_allocs > 0) { |
| 7975 | /* wait extra time for AP to start */ |
| 7976 | sleep(2); |
| 7977 | if (ap_set_60g_ese(dut, dut->ap_num_ese_allocs, |
| 7978 | dut->ap_ese_allocs)) { |
| 7979 | send_resp(dut, conn, SIGMA_ERROR, |
| 7980 | "errorCode,Could not set ExtSch"); |
| 7981 | return 0; |
| 7982 | } |
Alexei Avshalom Lazar | aad97b0 | 2018-12-18 16:01:23 +0200 | [diff] [blame] | 7983 | if (dut->ap_fixed_rate) { |
| 7984 | sigma_dut_print(dut, DUT_MSG_DEBUG, |
| 7985 | "forcing TX MCS index %d", |
| 7986 | dut->ap_mcs); |
| 7987 | if (ap_set_force_mcs(dut, 1, dut->ap_mcs)) { |
| 7988 | send_resp(dut, conn, SIGMA_ERROR, |
| 7989 | "errorCode,Could not force MCS"); |
| 7990 | return -2; |
| 7991 | } |
| 7992 | } |
Alexei Avshalom Lazar | bc180dc | 2018-12-18 16:01:14 +0200 | [diff] [blame] | 7993 | } |
| 7994 | |
Alexei Avshalom Lazar | 744ae8a | 2019-01-31 17:26:46 +0200 | [diff] [blame] | 7995 | if (dut->wps_forced_version) { |
| 7996 | snprintf(buf, sizeof(buf), "SET wps_version_number %d", |
| 7997 | dut->wps_forced_version); |
| 7998 | if (hapd_command(ifname, buf) < 0) { |
| 7999 | send_resp(dut, conn, SIGMA_ERROR, |
| 8000 | "errorCode,Fail to set wps_version_number"); |
| 8001 | return STATUS_SENT; |
| 8002 | } |
| 8003 | } |
| 8004 | |
Jouni Malinen | d86e582 | 2017-08-29 03:55:32 +0300 | [diff] [blame] | 8005 | dut->hostapd_running = 1; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8006 | return 1; |
| 8007 | } |
| 8008 | |
| 8009 | |
Pradeep Reddy POTTETI | eff4611 | 2016-10-13 17:22:03 +0530 | [diff] [blame] | 8010 | static int parse_qos_params(struct sigma_dut *dut, struct sigma_conn *conn, |
| 8011 | struct qos_params *qos, const char *cwmin, |
| 8012 | const char *cwmax, const char *aifs, |
| 8013 | const char *txop, const char *acm) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8014 | { |
Pradeep Reddy POTTETI | eff4611 | 2016-10-13 17:22:03 +0530 | [diff] [blame] | 8015 | int val; |
| 8016 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8017 | if (cwmin) { |
| 8018 | qos->ac = 1; |
Pradeep Reddy POTTETI | eff4611 | 2016-10-13 17:22:03 +0530 | [diff] [blame] | 8019 | val = atoi(cwmin); |
| 8020 | if (val < 0 || val > 15) { |
| 8021 | send_resp(dut, conn, SIGMA_INVALID, |
| 8022 | "errorCode,Invalid cwMin"); |
| 8023 | return 0; |
| 8024 | } |
| 8025 | qos->cwmin = val; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8026 | } |
| 8027 | |
| 8028 | if (cwmax) { |
| 8029 | qos->ac = 1; |
Pradeep Reddy POTTETI | eff4611 | 2016-10-13 17:22:03 +0530 | [diff] [blame] | 8030 | val = atoi(cwmax); |
| 8031 | if (val < 0 || val > 15) { |
| 8032 | send_resp(dut, conn, SIGMA_INVALID, |
| 8033 | "errorCode,Invalid cwMax"); |
| 8034 | return 0; |
| 8035 | } |
| 8036 | qos->cwmax = val; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8037 | } |
| 8038 | |
| 8039 | if (aifs) { |
| 8040 | qos->ac = 1; |
Pradeep Reddy POTTETI | eff4611 | 2016-10-13 17:22:03 +0530 | [diff] [blame] | 8041 | val = atoi(aifs); |
| 8042 | if (val < 1 || val > 255) { |
| 8043 | send_resp(dut, conn, SIGMA_INVALID, |
| 8044 | "errorCode,Invalid AIFS"); |
| 8045 | return 0; |
| 8046 | } |
| 8047 | qos->aifs = val; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8048 | } |
| 8049 | |
| 8050 | if (txop) { |
| 8051 | qos->ac = 1; |
Pradeep Reddy POTTETI | eff4611 | 2016-10-13 17:22:03 +0530 | [diff] [blame] | 8052 | val = atoi(txop); |
| 8053 | if (val < 0 || val > 0xffff) { |
| 8054 | send_resp(dut, conn, SIGMA_INVALID, |
| 8055 | "errorCode,Invalid txop"); |
| 8056 | return 0; |
| 8057 | } |
| 8058 | qos->txop = val * 32; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8059 | } |
| 8060 | |
| 8061 | if (acm) { |
| 8062 | qos->ac = 1; |
| 8063 | qos->acm = strcasecmp(acm, "on") == 0; |
| 8064 | } |
Pradeep Reddy POTTETI | eff4611 | 2016-10-13 17:22:03 +0530 | [diff] [blame] | 8065 | |
| 8066 | return 1; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8067 | } |
| 8068 | |
| 8069 | |
Jouni Malinen | f722271 | 2019-06-13 01:50:21 +0300 | [diff] [blame] | 8070 | static enum sigma_cmd_result cmd_ap_set_apqos(struct sigma_dut *dut, |
| 8071 | struct sigma_conn *conn, |
| 8072 | struct sigma_cmd *cmd) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8073 | { |
| 8074 | /* TXOP: The values provided here for VHT5G only */ |
Pradeep Reddy POTTETI | eff4611 | 2016-10-13 17:22:03 +0530 | [diff] [blame] | 8075 | if (!parse_qos_params(dut, conn, &dut->ap_qos[AP_AC_VO], |
| 8076 | get_param(cmd, "cwmin_VO"), |
| 8077 | get_param(cmd, "cwmax_VO"), |
| 8078 | get_param(cmd, "AIFS_VO"), |
| 8079 | get_param(cmd, "TXOP_VO"), |
| 8080 | get_param(cmd, "ACM_VO")) || |
| 8081 | !parse_qos_params(dut, conn, &dut->ap_qos[AP_AC_VI], |
| 8082 | get_param(cmd, "cwmin_VI"), |
| 8083 | get_param(cmd, "cwmax_VI"), |
| 8084 | get_param(cmd, "AIFS_VI"), |
| 8085 | get_param(cmd, "TXOP_VI"), |
| 8086 | get_param(cmd, "ACM_VI")) || |
| 8087 | !parse_qos_params(dut, conn, &dut->ap_qos[AP_AC_BE], |
| 8088 | get_param(cmd, "cwmin_BE"), |
| 8089 | get_param(cmd, "cwmax_BE"), |
| 8090 | get_param(cmd, "AIFS_BE"), |
| 8091 | get_param(cmd, "TXOP_BE"), |
| 8092 | get_param(cmd, "ACM_BE")) || |
| 8093 | !parse_qos_params(dut, conn, &dut->ap_qos[AP_AC_BK], |
| 8094 | get_param(cmd, "cwmin_BK"), |
| 8095 | get_param(cmd, "cwmax_BK"), |
| 8096 | get_param(cmd, "AIFS_BK"), |
| 8097 | get_param(cmd, "TXOP_BK"), |
| 8098 | get_param(cmd, "ACM_BK"))) |
| 8099 | return 0; |
| 8100 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8101 | return 1; |
| 8102 | } |
| 8103 | |
| 8104 | |
Jouni Malinen | f722271 | 2019-06-13 01:50:21 +0300 | [diff] [blame] | 8105 | static enum sigma_cmd_result cmd_ap_set_staqos(struct sigma_dut *dut, |
| 8106 | struct sigma_conn *conn, |
| 8107 | struct sigma_cmd *cmd) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8108 | { |
Pradeep Reddy POTTETI | eff4611 | 2016-10-13 17:22:03 +0530 | [diff] [blame] | 8109 | if (!parse_qos_params(dut, conn, &dut->ap_sta_qos[AP_AC_VO], |
| 8110 | get_param(cmd, "cwmin_VO"), |
| 8111 | get_param(cmd, "cwmax_VO"), |
| 8112 | get_param(cmd, "AIFS_VO"), |
| 8113 | get_param(cmd, "TXOP_VO"), |
| 8114 | get_param(cmd, "ACM_VO")) || |
| 8115 | !parse_qos_params(dut, conn, &dut->ap_sta_qos[AP_AC_VI], |
| 8116 | get_param(cmd, "cwmin_VI"), |
| 8117 | get_param(cmd, "cwmax_VI"), |
| 8118 | get_param(cmd, "AIFS_VI"), |
| 8119 | get_param(cmd, "TXOP_VI"), |
| 8120 | get_param(cmd, "ACM_VI")) || |
| 8121 | !parse_qos_params(dut, conn, &dut->ap_sta_qos[AP_AC_BE], |
| 8122 | get_param(cmd, "cwmin_BE"), |
| 8123 | get_param(cmd, "cwmax_BE"), |
| 8124 | get_param(cmd, "AIFS_BE"), |
| 8125 | get_param(cmd, "TXOP_BE"), |
| 8126 | get_param(cmd, "ACM_BE")) || |
| 8127 | !parse_qos_params(dut, conn, &dut->ap_sta_qos[AP_AC_BK], |
| 8128 | get_param(cmd, "cwmin_BK"), |
| 8129 | get_param(cmd, "cwmax_BK"), |
| 8130 | get_param(cmd, "AIFS_BK"), |
| 8131 | get_param(cmd, "TXOP_BK"), |
| 8132 | get_param(cmd, "ACM_BK"))) |
| 8133 | return 0; |
| 8134 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8135 | return 1; |
| 8136 | } |
| 8137 | |
| 8138 | |
| 8139 | static void cmd_ath_ap_hs2_reset(struct sigma_dut *dut) |
| 8140 | { |
| 8141 | unsigned char bssid[6]; |
| 8142 | char buf[100]; |
| 8143 | run_system(dut, "cfg -a AP_SSID=\"Hotspot 2.0\""); |
| 8144 | run_system(dut, "cfg -a AP_PRIMARY_CH=1"); |
| 8145 | run_system(dut, "cfg -a AP_SECMODE=WPA"); |
| 8146 | run_system(dut, "cfg -a AP_SECFILE=EAP"); |
| 8147 | run_system(dut, "cfg -a AP_WPA=2"); |
| 8148 | run_system(dut, "cfg -a AP_CYPHER=CCMP"); |
| 8149 | run_system(dut, "cfg -a AP_HOTSPOT=1"); |
| 8150 | run_system(dut, "cfg -a AP_HOTSPOT_ANT=2"); |
| 8151 | run_system(dut, "cfg -a AP_HOTSPOT_INTERNET=0"); |
| 8152 | run_system(dut, "cfg -a AP_HOTSPOT_VENUEGROUP=2"); |
| 8153 | run_system(dut, "cfg -a AP_HOTSPOT_VENUETYPE=8"); |
| 8154 | run_system(dut, "cfg -a AP_HOTSPOT_ROAMINGCONSORTIUM=506f9a"); |
| 8155 | run_system(dut, "cfg -a AP_HOTSPOT_ROAMINGCONSORTIUM2=001bc504bd"); |
| 8156 | if (!get_hwaddr("ath0", bssid)) { |
| 8157 | snprintf(buf, sizeof(buf), "cfg -a AP_HOTSPOT_HESSID=" |
| 8158 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 8159 | bssid[0], bssid[1], bssid[2], bssid[3], |
| 8160 | bssid[4], bssid[5]); |
| 8161 | run_system(dut, buf); |
| 8162 | snprintf(dut->ap_hessid, sizeof(dut->ap_hessid), |
| 8163 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 8164 | bssid[0], bssid[1], bssid[2], bssid[3], |
| 8165 | bssid[4], bssid[5]); |
| 8166 | } else { |
| 8167 | if (!get_hwaddr("wifi0", bssid)) { |
| 8168 | snprintf(buf, sizeof(buf), "cfg -a AP_HOTSPOT_HESSID=" |
| 8169 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 8170 | bssid[0], bssid[1], bssid[2], bssid[3], |
| 8171 | bssid[4], bssid[5]); |
| 8172 | run_system(dut, buf); |
| 8173 | snprintf(dut->ap_hessid, sizeof(dut->ap_hessid), |
| 8174 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 8175 | bssid[0], bssid[1], bssid[2], bssid[3], |
| 8176 | bssid[4], bssid[5]); |
| 8177 | } else { |
| 8178 | /* load the driver and try again */ |
| 8179 | run_system(dut, "/etc/rc.d/rc.wlan up"); |
| 8180 | |
| 8181 | if (!get_hwaddr("wifi0", bssid)) { |
| 8182 | snprintf(buf, sizeof(buf), |
| 8183 | "cfg -a AP_HOTSPOT_HESSID=" |
| 8184 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 8185 | bssid[0], bssid[1], bssid[2], |
| 8186 | bssid[3], bssid[4], bssid[5]); |
| 8187 | run_system(dut, buf); |
| 8188 | snprintf(dut->ap_hessid, |
| 8189 | sizeof(dut->ap_hessid), |
| 8190 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 8191 | bssid[0], bssid[1], bssid[2], |
| 8192 | bssid[3], bssid[4], bssid[5]); |
| 8193 | } |
| 8194 | } |
| 8195 | } |
| 8196 | |
| 8197 | run_system(dut, "cfg -r AP_SSID_2"); |
| 8198 | run_system(dut, "cfg -c"); |
| 8199 | /* run_system(dut, "cfg -s"); */ |
| 8200 | } |
| 8201 | |
| 8202 | |
| 8203 | static void ath_reset_vht_defaults(struct sigma_dut *dut) |
| 8204 | { |
| 8205 | run_system(dut, "cfg -x"); |
| 8206 | run_system(dut, "cfg -a AP_RADIO_ID=1"); |
| 8207 | run_system(dut, "cfg -a AP_PRIMARY_CH_2=36"); |
| 8208 | run_system(dut, "cfg -a AP_STARTMODE=standard"); |
| 8209 | run_system(dut, "cfg -a AP_CHMODE_2=11ACVHT80"); |
| 8210 | run_system(dut, "cfg -a TX_CHAINMASK_2=7"); |
| 8211 | run_system(dut, "cfg -a RX_CHAINMASK_2=7"); |
| 8212 | run_system(dut, "cfg -a ATH_countrycode=0x348"); |
| 8213 | /* NOTE: For Beeliner we have to turn off MU-MIMO */ |
| 8214 | if (system("rm /tmp/secath*") != 0) { |
| 8215 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 8216 | "Failed to remove secath file"); |
| 8217 | } |
| 8218 | } |
| 8219 | |
| 8220 | |
Jouni Malinen | f722271 | 2019-06-13 01:50:21 +0300 | [diff] [blame] | 8221 | static enum sigma_cmd_result cmd_ap_reset_default(struct sigma_dut *dut, |
| 8222 | struct sigma_conn *conn, |
| 8223 | struct sigma_cmd *cmd) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8224 | { |
Ankita Bajaj | 0d5825b | 2017-10-25 16:20:17 +0530 | [diff] [blame] | 8225 | const char *type, *program; |
Pradeep Reddy POTTETI | 83b8067 | 2016-09-02 13:01:44 +0530 | [diff] [blame] | 8226 | enum driver_type drv; |
Alexei Avshalom Lazar | 2712cc8 | 2018-12-23 16:29:14 +0200 | [diff] [blame] | 8227 | char buf[128]; |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 8228 | int i; |
| 8229 | |
| 8230 | for (i = 0; i < MAX_WLAN_TAGS - 1; i++) { |
| 8231 | /* |
| 8232 | * Reset all tagged SSIDs to NULL-string and all key management |
| 8233 | * to open. |
| 8234 | */ |
| 8235 | dut->ap_tag_ssid[i][0] = '\0'; |
| 8236 | dut->ap_tag_key_mgmt[i] = AP2_OPEN; |
| 8237 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8238 | |
Pradeep Reddy POTTETI | 83b8067 | 2016-09-02 13:01:44 +0530 | [diff] [blame] | 8239 | drv = get_driver_type(); |
Ankita Bajaj | 0d5825b | 2017-10-25 16:20:17 +0530 | [diff] [blame] | 8240 | |
| 8241 | program = get_param(cmd, "program"); |
| 8242 | if (!program) |
| 8243 | program = get_param(cmd, "prog"); |
| 8244 | dut->program = sigma_program_to_enum(program); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8245 | dut->device_type = AP_unknown; |
| 8246 | type = get_param(cmd, "type"); |
| 8247 | if (type && strcasecmp(type, "Testbed") == 0) |
| 8248 | dut->device_type = AP_testbed; |
| 8249 | if (type && strcasecmp(type, "DUT") == 0) |
| 8250 | dut->device_type = AP_dut; |
| 8251 | |
| 8252 | dut->ap_rts = 0; |
| 8253 | dut->ap_frgmnt = 0; |
| 8254 | dut->ap_bcnint = 0; |
| 8255 | dut->ap_key_mgmt = AP_OPEN; |
| 8256 | dut->ap_ssid[0] = '\0'; |
| 8257 | dut->ap_fake_pkhash = 0; |
| 8258 | memset(dut->ap_qos, 0, sizeof(dut->ap_qos)); |
| 8259 | memset(dut->ap_sta_qos, 0, sizeof(dut->ap_sta_qos)); |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 8260 | dut->ap_addba_reject = VALUE_NOT_SET; |
| 8261 | dut->ap_noack = VALUE_NOT_SET; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8262 | dut->ap_is_dual = 0; |
| 8263 | dut->ap_mode = AP_inval; |
| 8264 | dut->ap_mode_1 = AP_inval; |
| 8265 | |
| 8266 | dut->ap_allow_vht_wep = 0; |
| 8267 | dut->ap_allow_vht_tkip = 0; |
| 8268 | dut->ap_disable_protection = 0; |
| 8269 | memset(dut->ap_countrycode, 0, sizeof(dut->ap_countrycode)); |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 8270 | dut->ap_dyn_bw_sig = VALUE_NOT_SET; |
| 8271 | dut->ap_ldpc = VALUE_NOT_SET; |
| 8272 | dut->ap_sig_rts = VALUE_NOT_SET; |
| 8273 | dut->ap_rx_amsdu = VALUE_NOT_SET; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8274 | dut->ap_txBF = 0; |
Mohammed Shafi Shajakhan | 495fdb2 | 2016-06-02 20:10:56 +0530 | [diff] [blame] | 8275 | dut->ap_mu_txBF = 0; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8276 | dut->ap_chwidth = AP_AUTO; |
| 8277 | |
Sarvepalli, Rajesh Babu | 24dc7e4 | 2016-03-18 21:27:26 +0530 | [diff] [blame] | 8278 | dut->ap_rsn_preauth = 0; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8279 | dut->ap_wpsnfc = 0; |
| 8280 | dut->ap_bss_load = -1; |
| 8281 | dut->ap_p2p_cross_connect = -1; |
| 8282 | |
Pradeep Reddy POTTETI | fba27db | 2015-11-20 16:42:22 +0530 | [diff] [blame] | 8283 | dut->ap_regulatory_mode = AP_80211D_MODE_DISABLED; |
| 8284 | dut->ap_dfs_mode = AP_DFS_MODE_DISABLED; |
Pradeep Reddy Potteti | 4b0cdee | 2017-03-15 12:37:33 +0530 | [diff] [blame] | 8285 | dut->ap_chwidth_offset = SEC_CH_NO; |
Pradeep Reddy POTTETI | fba27db | 2015-11-20 16:42:22 +0530 | [diff] [blame] | 8286 | |
Adil Saeed Musthafa | 6906372 | 2017-04-10 23:13:40 -0700 | [diff] [blame] | 8287 | dut->mbo_pref_ap_cnt = 0; |
Adil Saeed Musthafa | 4ec61bd | 2017-04-10 23:13:41 -0700 | [diff] [blame] | 8288 | dut->ft_bss_mac_cnt = 0; |
priyadharshini gowthaman | 09d613e | 2017-12-20 11:43:44 -0800 | [diff] [blame] | 8289 | dut->ap_interface_5g = 0; |
| 8290 | dut->ap_interface_2g = 0; |
priyadharshini gowthaman | a3fe8c6 | 2018-01-26 15:19:41 -0800 | [diff] [blame] | 8291 | dut->ap_pmf = AP_PMF_DISABLED; |
Adil Saeed Musthafa | 6906372 | 2017-04-10 23:13:40 -0700 | [diff] [blame] | 8292 | |
Alexei Avshalom Lazar | 33f700c | 2018-12-18 16:00:39 +0200 | [diff] [blame] | 8293 | dut->wsc_fragment = 0; |
Alexei Avshalom Lazar | 2eccf4d | 2019-01-31 10:03:59 +0200 | [diff] [blame] | 8294 | dut->eap_fragment = 0; |
Alexei Avshalom Lazar | 744ae8a | 2019-01-31 17:26:46 +0200 | [diff] [blame] | 8295 | dut->wps_forced_version = 0; |
Alexei Avshalom Lazar | 33f700c | 2018-12-18 16:00:39 +0200 | [diff] [blame] | 8296 | |
Mohammed Shafi Shajakhan | 02e3b82 | 2017-02-23 04:15:02 +0530 | [diff] [blame] | 8297 | if (dut->program == PROGRAM_HT || dut->program == PROGRAM_VHT) { |
Pradeep Reddy POTTETI | 0d3db63 | 2016-03-11 15:21:11 +0530 | [diff] [blame] | 8298 | dut->ap_wme = AP_WME_ON; |
Mohammed Shafi Shajakhan | 02e3b82 | 2017-02-23 04:15:02 +0530 | [diff] [blame] | 8299 | dut->ap_wmmps = AP_WMMPS_ON; |
| 8300 | } else { |
Pradeep Reddy POTTETI | 0d3db63 | 2016-03-11 15:21:11 +0530 | [diff] [blame] | 8301 | dut->ap_wme = AP_WME_OFF; |
Mohammed Shafi Shajakhan | 02e3b82 | 2017-02-23 04:15:02 +0530 | [diff] [blame] | 8302 | dut->ap_wmmps = AP_WMMPS_OFF; |
| 8303 | } |
Pradeep Reddy POTTETI | 0d3db63 | 2016-03-11 15:21:11 +0530 | [diff] [blame] | 8304 | |
Jouni Malinen | 54a89b0 | 2018-05-01 00:16:26 +0300 | [diff] [blame] | 8305 | dut->ap_venue_url = 0; |
Jouni Malinen | f7ff42b | 2018-05-01 00:21:56 +0300 | [diff] [blame] | 8306 | dut->ap_advice_of_charge = 0; |
Jouni Malinen | ac10453 | 2018-05-01 00:27:37 +0300 | [diff] [blame] | 8307 | dut->ap_oper_icon_metadata = 0; |
Jouni Malinen | ac36714 | 2018-05-01 00:32:24 +0300 | [diff] [blame] | 8308 | dut->ap_tnc_file_name = 0; |
| 8309 | dut->ap_tnc_time_stamp = 0; |
Jouni Malinen | 54a89b0 | 2018-05-01 00:16:26 +0300 | [diff] [blame] | 8310 | |
Jouni Malinen | da5f35b | 2019-03-26 00:25:53 +0200 | [diff] [blame] | 8311 | dut->ap_akm_values = 0; |
Jouni Malinen | 09550de | 2019-03-26 00:24:11 +0200 | [diff] [blame] | 8312 | free(dut->ap_sae_passwords); |
| 8313 | dut->ap_sae_passwords = NULL; |
| 8314 | |
Adil Saeed Musthafa | 33ea287 | 2017-04-10 23:13:24 -0700 | [diff] [blame] | 8315 | if (dut->program == PROGRAM_HS2 || dut->program == PROGRAM_HS2_R2 || |
Jouni Malinen | ba63045 | 2018-06-22 11:49:59 +0300 | [diff] [blame] | 8316 | dut->program == PROGRAM_HS2_R3 || |
Adil Saeed Musthafa | 33ea287 | 2017-04-10 23:13:24 -0700 | [diff] [blame] | 8317 | dut->program == PROGRAM_IOTLP) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8318 | int i; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8319 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8320 | if (drv == DRIVER_ATHEROS) |
| 8321 | cmd_ath_ap_hs2_reset(dut); |
| 8322 | else if (drv == DRIVER_OPENWRT) |
| 8323 | cmd_owrt_ap_hs2_reset(dut); |
| 8324 | |
| 8325 | dut->ap_interworking = 1; |
| 8326 | dut->ap_access_net_type = 2; |
| 8327 | dut->ap_internet = 0; |
| 8328 | dut->ap_venue_group = 2; |
| 8329 | dut->ap_venue_type = 8; |
| 8330 | dut->ap_domain_name_list[0] = '\0'; |
| 8331 | dut->ap_hs2 = 1; |
| 8332 | snprintf(dut->ap_roaming_cons, sizeof(dut->ap_roaming_cons), |
| 8333 | "506f9a;001bc504bd"); |
| 8334 | dut->ap_l2tif = 0; |
| 8335 | dut->ap_proxy_arp = 0; |
| 8336 | if (dut->bridge) { |
| 8337 | char buf[50]; |
| 8338 | |
| 8339 | snprintf(buf, sizeof(buf), "ip neigh flush dev %s", |
| 8340 | dut->bridge); |
| 8341 | if (system(buf) != 0) { |
| 8342 | sigma_dut_print(dut, DUT_MSG_DEBUG, |
| 8343 | "%s ip neigh table flushing failed", |
| 8344 | dut->bridge); |
| 8345 | } |
| 8346 | |
| 8347 | snprintf(buf, sizeof(buf), "ebtables -F"); |
| 8348 | if (system(buf) != 0) { |
| 8349 | sigma_dut_print(dut, DUT_MSG_DEBUG, |
| 8350 | "%s ebtables flushing failed", |
| 8351 | dut->bridge); |
| 8352 | } |
| 8353 | } |
| 8354 | dut->ap_dgaf_disable = 0; |
| 8355 | dut->ap_p2p_cross_connect = 0; |
| 8356 | dut->ap_gas_cb_delay = 0; |
| 8357 | dut->ap_nai_realm_list = 0; |
| 8358 | dut->ap_oper_name = 0; |
| 8359 | dut->ap_venue_name = 0; |
| 8360 | for (i = 0; i < 10; i++) { |
| 8361 | dut->ap_plmn_mcc[i][0] = '\0'; |
| 8362 | dut->ap_plmn_mnc[i][0] = '\0'; |
| 8363 | } |
| 8364 | dut->ap_wan_metrics = 0; |
| 8365 | dut->ap_conn_capab = 0; |
| 8366 | dut->ap_ip_addr_type_avail = 0; |
| 8367 | dut->ap_net_auth_type = 0; |
| 8368 | dut->ap_oper_class = 0; |
| 8369 | dut->ap_pmf = 0; |
| 8370 | dut->ap_add_sha256 = 0; |
| 8371 | } |
| 8372 | |
Jouni Malinen | ba63045 | 2018-06-22 11:49:59 +0300 | [diff] [blame] | 8373 | if (dut->program == PROGRAM_HS2_R2 || dut->program == PROGRAM_HS2_R3 || |
| 8374 | dut->program == PROGRAM_IOTLP) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8375 | int i; |
| 8376 | const char hessid[] = "50:6f:9a:00:11:22"; |
| 8377 | |
| 8378 | memcpy(dut->ap_hessid, hessid, strlen(hessid) + 1); |
| 8379 | dut->ap_osu_ssid[0] = '\0'; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8380 | dut->ap_pmf = 1; |
| 8381 | dut->ap_osu_provider_list = 0; |
Jouni Malinen | 93a837f | 2018-11-01 17:09:22 +0200 | [diff] [blame] | 8382 | dut->ap_osu_provider_nai_list = 0; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8383 | for (i = 0; i < 10; i++) { |
| 8384 | dut->ap_osu_server_uri[i][0] = '\0'; |
| 8385 | dut->ap_osu_method[i] = 0xFF; |
| 8386 | } |
| 8387 | dut->ap_qos_map_set = 0; |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 8388 | dut->ap_tag_key_mgmt[0] = AP2_OPEN; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8389 | dut->ap2_proxy_arp = 0; |
Jouni Malinen | dbbc2c4 | 2018-11-14 23:55:41 +0200 | [diff] [blame] | 8390 | dut->ap2_osu = 0; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8391 | dut->ap_osu_icon_tag = 0; |
| 8392 | } |
| 8393 | |
| 8394 | if (dut->program == PROGRAM_VHT) { |
| 8395 | /* Set up the defaults */ |
| 8396 | dut->ap_mode = AP_11ac; |
| 8397 | dut->ap_channel = 36; |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 8398 | dut->ap_ampdu = VALUE_NOT_SET; |
priyadharshini gowthaman | 264d544 | 2016-02-25 15:52:22 -0800 | [diff] [blame] | 8399 | dut->ap_ndpa_frame = 1; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8400 | if (dut->device_type == AP_testbed) { |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 8401 | dut->ap_amsdu = VALUE_DISABLED; |
| 8402 | dut->ap_ldpc = VALUE_DISABLED; |
| 8403 | dut->ap_rx_amsdu = VALUE_DISABLED; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8404 | dut->ap_sgi80 = 0; |
| 8405 | } else { |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 8406 | dut->ap_amsdu = VALUE_ENABLED; |
Pradeep Reddy POTTETI | 83b8067 | 2016-09-02 13:01:44 +0530 | [diff] [blame] | 8407 | /* |
| 8408 | * As LDPC is optional, don't enable this by default |
| 8409 | * for LINUX-WCN driver. The ap_set_wireless command |
| 8410 | * can be used to enable LDPC, when needed. |
| 8411 | */ |
| 8412 | if (drv != DRIVER_LINUX_WCN) |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 8413 | dut->ap_ldpc = VALUE_ENABLED; |
| 8414 | dut->ap_rx_amsdu = VALUE_ENABLED; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8415 | dut->ap_sgi80 = 1; |
| 8416 | } |
| 8417 | dut->ap_fixed_rate = 0; |
| 8418 | dut->ap_rx_streams = 3; |
| 8419 | dut->ap_tx_streams = 3; |
| 8420 | dut->ap_vhtmcs_map = 0; |
| 8421 | dut->ap_chwidth = AP_80; |
| 8422 | dut->ap_tx_stbc = 1; |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 8423 | dut->ap_dyn_bw_sig = VALUE_ENABLED; |
Mohammed Shafi Shajakhan | bae7230 | 2016-03-02 11:56:23 +0530 | [diff] [blame] | 8424 | if (get_openwrt_driver_type() == OPENWRT_DRIVER_ATHEROS) |
| 8425 | dut->ap_dfs_mode = AP_DFS_MODE_ENABLED; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8426 | if (get_driver_type() == DRIVER_ATHEROS) |
| 8427 | ath_reset_vht_defaults(dut); |
| 8428 | } |
| 8429 | |
Adil Saeed Musthafa | 33ea287 | 2017-04-10 23:13:24 -0700 | [diff] [blame] | 8430 | if (dut->program == PROGRAM_IOTLP) { |
| 8431 | dut->wnm_bss_max_feature = VALUE_DISABLED; |
| 8432 | dut->wnm_bss_max_idle_time = 0; |
| 8433 | dut->wnm_bss_max_protection = VALUE_NOT_SET; |
| 8434 | dut->ap_proxy_arp = 1; |
| 8435 | } else { |
| 8436 | /* |
| 8437 | * Do not touch the BSS-MAX Idle time feature |
| 8438 | * if the program is not IOTLP. |
| 8439 | */ |
| 8440 | dut->wnm_bss_max_feature = VALUE_NOT_SET; |
| 8441 | dut->wnm_bss_max_idle_time = 0; |
| 8442 | dut->wnm_bss_max_protection = VALUE_NOT_SET; |
| 8443 | } |
| 8444 | |
priyadharshini gowthaman | a27b5b6 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 8445 | if (dut->program == PROGRAM_LOC) { |
priyadharshini gowthaman | 8e26ff4 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 8446 | dut->ap_rrm = 1; |
| 8447 | dut->ap_rtt = 1; |
| 8448 | dut->ap_lci = 0; |
| 8449 | dut->ap_val_lci[0] = '\0'; |
priyadharshini gowthaman | c2357bd | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 8450 | dut->ap_infoz[0] = '\0'; |
priyadharshini gowthaman | 8e26ff4 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 8451 | dut->ap_lcr = 0; |
| 8452 | dut->ap_val_lcr[0] = '\0'; |
| 8453 | dut->ap_neighap = 0; |
| 8454 | dut->ap_opchannel = 0; |
| 8455 | dut->ap_scan = 0; |
priyadharshini gowthaman | c2357bd | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 8456 | dut->ap_fqdn_held = 0; |
| 8457 | dut->ap_fqdn_supl = 0; |
priyadharshini gowthaman | c52fff8 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 8458 | dut->ap_interworking = 0; |
| 8459 | dut->ap_gas_cb_delay = 0; |
priyadharshini gowthaman | a27b5b6 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 8460 | dut->ap_msnt_type = 0; |
| 8461 | } |
Adil Saeed Musthafa | 4ec61bd | 2017-04-10 23:13:41 -0700 | [diff] [blame] | 8462 | dut->ap_ft_oa = 0; |
Jouni Malinen | 9f94331 | 2019-08-19 23:49:16 +0300 | [diff] [blame] | 8463 | dut->ap_ft_ds = VALUE_NOT_SET; |
Adil Saeed Musthafa | 604c826 | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 8464 | dut->ap_reg_domain = REG_DOMAIN_NOT_SET; |
Adil Saeed Musthafa | cf752fa | 2017-04-10 23:13:32 -0700 | [diff] [blame] | 8465 | dut->ap_mobility_domain[0] = '\0'; |
priyadharshini gowthaman | a27b5b6 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 8466 | |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 8467 | if (dut->program == PROGRAM_MBO) { |
| 8468 | dut->ap_mbo = 1; |
| 8469 | dut->ap_interworking = 1; |
| 8470 | dut->ap_ne_class = 0; |
| 8471 | dut->ap_ne_op_ch = 0; |
| 8472 | dut->ap_set_bssidpref = 1; |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 8473 | dut->ap_btmreq_disassoc_imnt = 0; |
| 8474 | dut->ap_btmreq_term_bit = 0; |
| 8475 | dut->ap_disassoc_timer = 0; |
| 8476 | dut->ap_btmreq_bss_term_dur = 0; |
Adil Saeed Musthafa | 16d9e63 | 2017-04-10 23:13:38 -0700 | [diff] [blame] | 8477 | dut->ap_channel = 36; |
| 8478 | dut->ap_chwidth = AP_20; |
Adil Saeed Musthafa | 023108a | 2017-04-10 23:13:37 -0700 | [diff] [blame] | 8479 | dut->ap_cell_cap_pref = 0; |
Adil Saeed Musthafa | ed5faae | 2017-04-10 23:13:36 -0700 | [diff] [blame] | 8480 | dut->ap_gas_cb_delay = 0; |
Adil Saeed Musthafa | 6906372 | 2017-04-10 23:13:40 -0700 | [diff] [blame] | 8481 | dut->mbo_self_ap_tuple.ap_ne_class = -1; |
| 8482 | dut->mbo_self_ap_tuple.ap_ne_pref = -1; /* Not set */ |
| 8483 | dut->mbo_self_ap_tuple.ap_ne_op_ch = -1; |
priyadharshini gowthaman | 94062b5 | 2017-12-20 12:33:34 -0800 | [diff] [blame] | 8484 | dut->ap_btmreq_bss_term_tsf = 0; |
priyadharshini gowthaman | 776562e | 2017-12-20 12:33:34 -0800 | [diff] [blame] | 8485 | dut->ap_assoc_delay = 0; |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 8486 | } |
| 8487 | |
priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 8488 | if (dut->program == PROGRAM_OCE) { |
| 8489 | if (dut->ap_dhcp_stop) |
| 8490 | run_system(dut, "/etc/init.d/dnsmasq start"); |
| 8491 | |
| 8492 | dut->ap_dhcp_stop = 0; |
| 8493 | dut->ap_oce = VALUE_ENABLED; |
| 8494 | dut->ap_broadcast_ssid = VALUE_ENABLED; |
| 8495 | dut->ap_fils_dscv_int = 20; |
| 8496 | dut->ap_filsdscv = VALUE_ENABLED; |
| 8497 | dut->ap_filshlp = VALUE_DISABLED; |
| 8498 | dut->ap_rnr = VALUE_DISABLED; |
| 8499 | dut->ap_nairealm[0] = '\0'; |
| 8500 | dut->ap_nairealm_int = 0; |
| 8501 | dut->ap_blechanutil = 0; |
| 8502 | dut->ap_ble_admit_cap = 0; |
| 8503 | dut->ap_esp = VALUE_ENABLED; |
| 8504 | dut->ap_datappdudura = 0; |
| 8505 | dut->ap_airtimefract = 0; |
| 8506 | dut->ap_blestacnt = 0; |
priyadharshini gowthaman | cb22e43 | 2017-12-28 15:23:31 -0800 | [diff] [blame] | 8507 | dut->ap_ul_availcap = 0; |
| 8508 | dut->ap_dl_availcap = 0; |
priyadharshini gowthaman | de81f39 | 2017-12-28 15:28:49 -0800 | [diff] [blame] | 8509 | dut->ap_akm = 0; |
| 8510 | dut->ap_add_sha256 = 0; |
| 8511 | dut->ap_add_sha384 = 0; |
priyadharshini gowthaman | 63ab848 | 2017-12-28 15:32:55 -0800 | [diff] [blame] | 8512 | dut->ap_80plus80 = 0; |
priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 8513 | } |
| 8514 | |
priyadharshini gowthaman | 350f191 | 2018-06-04 13:09:12 -0700 | [diff] [blame] | 8515 | dut->ap_he_ppdu = PPDU_NOT_SET; |
Priyadharshini Gowthaman | fe60c50 | 2019-08-14 13:00:34 -0700 | [diff] [blame] | 8516 | dut->ap_he_ulofdma = VALUE_NOT_SET; |
Priyadharshini Gowthaman | bc94889 | 2019-09-10 14:22:49 -0700 | [diff] [blame] | 8517 | dut->ap_numsounddim = 0; |
Priyadharshini Gowthaman | 670b323 | 2019-09-10 16:09:19 -0700 | [diff] [blame] | 8518 | dut->ap_bcc = VALUE_DISABLED; |
Priyadharshini Gowthaman | 21895a5 | 2019-10-07 16:56:16 -0700 | [diff] [blame] | 8519 | dut->ap_mu_edca = VALUE_DISABLED; |
Priyadharshini Gowthaman | dee79e2 | 2019-10-07 16:56:27 -0700 | [diff] [blame] | 8520 | dut->ap_he_mimo = MIMO_NOT_SET; |
Priyadharshini Gowthaman | 43d6b41 | 2019-10-07 16:56:37 -0700 | [diff] [blame] | 8521 | dut->ap_he_rtsthrshld = VALUE_NOT_SET; |
Priyadharshini Gowthaman | 6bc4c1e | 2019-09-10 16:24:51 -0700 | [diff] [blame] | 8522 | if (dut->device_type == AP_testbed) { |
Priyadharshini Gowthaman | fe60c50 | 2019-08-14 13:00:34 -0700 | [diff] [blame] | 8523 | dut->ap_he_dlofdma = VALUE_DISABLED; |
Priyadharshini Gowthaman | 6bc4c1e | 2019-09-10 16:24:51 -0700 | [diff] [blame] | 8524 | dut->ap_he_frag = VALUE_DISABLED; |
| 8525 | } else { |
Priyadharshini Gowthaman | fe60c50 | 2019-08-14 13:00:34 -0700 | [diff] [blame] | 8526 | dut->ap_he_dlofdma = VALUE_NOT_SET; |
Priyadharshini Gowthaman | 6bc4c1e | 2019-09-10 16:24:51 -0700 | [diff] [blame] | 8527 | dut->ap_he_frag = VALUE_NOT_SET; |
Priyadharshini Gowthaman | 1a686bd | 2019-09-19 14:41:40 -0700 | [diff] [blame] | 8528 | dut->ap_ba_bufsize = BA_BUFSIZE_NOT_SET; |
Priyadharshini Gowthaman | 6bc4c1e | 2019-09-10 16:24:51 -0700 | [diff] [blame] | 8529 | } |
priyadharshini gowthaman | 350f191 | 2018-06-04 13:09:12 -0700 | [diff] [blame] | 8530 | |
Priyadharshini Gowthaman | 670b323 | 2019-09-10 16:09:19 -0700 | [diff] [blame] | 8531 | if (dut->program == PROGRAM_HE) { |
Priyadharshini Gowthaman | 1a686bd | 2019-09-19 14:41:40 -0700 | [diff] [blame] | 8532 | if (dut->device_type == AP_testbed) { |
Priyadharshini Gowthaman | 670b323 | 2019-09-10 16:09:19 -0700 | [diff] [blame] | 8533 | dut->ap_ldpc = VALUE_DISABLED; |
Priyadharshini Gowthaman | 1a686bd | 2019-09-19 14:41:40 -0700 | [diff] [blame] | 8534 | dut->ap_ba_bufsize = BA_BUFSIZE_64; |
| 8535 | } |
Priyadharshini Gowthaman | 670b323 | 2019-09-10 16:09:19 -0700 | [diff] [blame] | 8536 | } |
| 8537 | |
priyadharshini gowthaman | 9149afc | 2018-01-15 13:40:18 -0800 | [diff] [blame] | 8538 | dut->ap_oper_chn = 0; |
| 8539 | |
Jouni Malinen | b75c532 | 2019-06-14 01:47:43 +0300 | [diff] [blame] | 8540 | dut->ap_pmksa = 0; |
| 8541 | dut->ap_pmksa_caching = 0; |
| 8542 | |
Jouni Malinen | 3c367e8 | 2017-06-23 17:01:47 +0300 | [diff] [blame] | 8543 | free(dut->rsne_override); |
| 8544 | dut->rsne_override = NULL; |
| 8545 | |
Jouni Malinen | 6814313 | 2017-09-02 02:34:08 +0300 | [diff] [blame] | 8546 | free(dut->sae_commit_override); |
| 8547 | dut->sae_commit_override = NULL; |
| 8548 | |
Jouni Malinen | ed670f4 | 2017-08-31 01:39:28 +0300 | [diff] [blame] | 8549 | free(dut->ap_sae_groups); |
| 8550 | dut->ap_sae_groups = NULL; |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 8551 | |
Jouni Malinen | 2f524ce | 2017-08-31 01:43:29 +0300 | [diff] [blame] | 8552 | dut->sae_anti_clogging_threshold = -1; |
Jouni Malinen | b347db0 | 2017-09-02 01:36:03 +0300 | [diff] [blame] | 8553 | dut->sae_reflection = 0; |
Jouni Malinen | 3c740ab | 2019-10-10 15:55:11 +0300 | [diff] [blame] | 8554 | dut->sae_confirm_immediate = 0; |
Jouni Malinen | 2f524ce | 2017-08-31 01:43:29 +0300 | [diff] [blame] | 8555 | |
Jouni Malinen | 3d633da | 2017-09-14 22:19:21 +0300 | [diff] [blame] | 8556 | dut->ap_cipher = AP_CCMP; |
Jouni Malinen | 2ba2449 | 2017-11-17 12:43:59 +0200 | [diff] [blame] | 8557 | dut->ap_group_cipher = AP_NO_GROUP_CIPHER_SET; |
Jouni Malinen | 3d633da | 2017-09-14 22:19:21 +0300 | [diff] [blame] | 8558 | dut->ap_group_mgmt_cipher = AP_NO_GROUP_MGMT_CIPHER_SET; |
Jouni Malinen | 6337062 | 2017-11-18 17:47:13 +0200 | [diff] [blame] | 8559 | dut->ap_passphrase[0] = '\0'; |
| 8560 | dut->ap_psk[0] = '\0'; |
Jouni Malinen | 3d633da | 2017-09-14 22:19:21 +0300 | [diff] [blame] | 8561 | |
Jouni Malinen | d86e582 | 2017-08-29 03:55:32 +0300 | [diff] [blame] | 8562 | dut->dpp_conf_id = -1; |
Jouni Malinen | ba4f2d4 | 2019-10-04 16:13:41 +0300 | [diff] [blame] | 8563 | free(dut->ap_dpp_conf_addr); |
| 8564 | dut->ap_dpp_conf_addr = NULL; |
| 8565 | free(dut->ap_dpp_conf_pkhash); |
| 8566 | dut->ap_dpp_conf_pkhash = NULL; |
Jouni Malinen | d86e582 | 2017-08-29 03:55:32 +0300 | [diff] [blame] | 8567 | |
Alexei Avshalom Lazar | eee9ab0 | 2018-12-24 16:27:48 +0200 | [diff] [blame] | 8568 | if (is_60g_sigma_dut(dut)) { |
Alexei Avshalom Lazar | 2712cc8 | 2018-12-23 16:29:14 +0200 | [diff] [blame] | 8569 | dut->ap_mode = AP_11ad; |
| 8570 | dut->ap_channel = 2; |
Alexei Avshalom Lazar | eee9ab0 | 2018-12-24 16:27:48 +0200 | [diff] [blame] | 8571 | dut->wps_disable = 0; /* WPS is enabled */ |
Alexei Avshalom Lazar | 2712cc8 | 2018-12-23 16:29:14 +0200 | [diff] [blame] | 8572 | dut->ap_pmf = 0; |
Alexei Avshalom Lazar | bc180dc | 2018-12-18 16:01:14 +0200 | [diff] [blame] | 8573 | dut->ap_num_ese_allocs = 0; |
Alexei Avshalom Lazar | 2712cc8 | 2018-12-23 16:29:14 +0200 | [diff] [blame] | 8574 | dut->ap_fixed_rate = 0; |
| 8575 | |
| 8576 | dut->dev_role = DEVROLE_AP; |
| 8577 | |
| 8578 | sigma_dut_print(dut, DUT_MSG_DEBUG, |
| 8579 | "Setting msdu_size to MAX: 7912"); |
| 8580 | snprintf(buf, sizeof(buf), "ifconfig %s mtu 7912", |
| 8581 | get_main_ifname()); |
| 8582 | |
| 8583 | if (system(buf) != 0) { |
| 8584 | sigma_dut_print(dut, DUT_MSG_ERROR, "Failed to set %s", |
| 8585 | buf); |
Jouni Malinen | 0e29cf2 | 2019-02-19 01:13:21 +0200 | [diff] [blame] | 8586 | return ERROR_SEND_STATUS; |
Alexei Avshalom Lazar | 2712cc8 | 2018-12-23 16:29:14 +0200 | [diff] [blame] | 8587 | } |
| 8588 | |
Alexei Avshalom Lazar | aad97b0 | 2018-12-18 16:01:23 +0200 | [diff] [blame] | 8589 | if (ap_set_force_mcs(dut, 0, 1)) { |
| 8590 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 8591 | "Failed to reset force MCS"); |
Jouni Malinen | 0e29cf2 | 2019-02-19 01:13:21 +0200 | [diff] [blame] | 8592 | return ERROR_SEND_STATUS; |
Alexei Avshalom Lazar | aad97b0 | 2018-12-18 16:01:23 +0200 | [diff] [blame] | 8593 | } |
| 8594 | |
Alexei Avshalom Lazar | 2712cc8 | 2018-12-23 16:29:14 +0200 | [diff] [blame] | 8595 | if (set_ps(get_main_ifname(), dut, 1)) { |
| 8596 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 8597 | "Failed to enable power save"); |
Jouni Malinen | 0e29cf2 | 2019-02-19 01:13:21 +0200 | [diff] [blame] | 8598 | return ERROR_SEND_STATUS; |
Alexei Avshalom Lazar | 2712cc8 | 2018-12-23 16:29:14 +0200 | [diff] [blame] | 8599 | } |
| 8600 | } |
| 8601 | |
Alexei Avshalom Lazar | b6d25d5 | 2019-02-04 14:08:44 +0200 | [diff] [blame] | 8602 | if (dut->program == PROGRAM_WPS && |
| 8603 | get_driver_type() == DRIVER_WIL6210) { |
| 8604 | /* |
| 8605 | * In 60 GHz WPS tests, we configure the AP OOB to |
| 8606 | * secure connection with a random passphrase. |
| 8607 | */ |
| 8608 | char r[16], passphrase[65]; |
| 8609 | |
| 8610 | if (random_get_bytes(r, sizeof(r))) { |
| 8611 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 8612 | "Failed to get random bytes"); |
| 8613 | return ERROR_SEND_STATUS; |
| 8614 | } |
| 8615 | if (base64_encode(r, sizeof(r), |
| 8616 | passphrase, sizeof(passphrase))) { |
| 8617 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 8618 | "Failed to generate random passphrase"); |
| 8619 | return ERROR_SEND_STATUS; |
| 8620 | } |
| 8621 | |
| 8622 | dut->ap_key_mgmt = AP_WPA2_PSK; |
| 8623 | dut->ap_cipher = AP_GCMP_128; |
| 8624 | strlcpy(dut->ap_passphrase, passphrase, |
| 8625 | sizeof(dut->ap_passphrase)); |
| 8626 | sigma_dut_print(dut, DUT_MSG_DEBUG, |
| 8627 | "60G WPS: configure secure AP with random passphrase"); |
| 8628 | } |
| 8629 | |
Jouni Malinen | d86e582 | 2017-08-29 03:55:32 +0300 | [diff] [blame] | 8630 | dut->hostapd_running = 0; |
priyadharshini gowthaman | 9947fd3 | 2018-01-26 15:19:41 -0800 | [diff] [blame] | 8631 | |
| 8632 | if (get_openwrt_driver_type() == OPENWRT_DRIVER_ATHEROS) |
| 8633 | return 1; |
| 8634 | |
Jouni Malinen | d6bf1b4 | 2017-06-23 17:51:01 +0300 | [diff] [blame] | 8635 | if (dut->use_hostapd_pid_file) { |
| 8636 | kill_hostapd_process_pid(dut); |
| 8637 | } else if (kill_process(dut, "(hostapd)", 1, SIGTERM) == 0 || |
| 8638 | system("killall hostapd") == 0) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8639 | int i; |
| 8640 | /* Wait some time to allow hostapd to complete cleanup before |
| 8641 | * starting a new process */ |
| 8642 | for (i = 0; i < 10; i++) { |
| 8643 | usleep(500000); |
| 8644 | if (system("pidof hostapd") != 0) |
| 8645 | break; |
| 8646 | } |
| 8647 | } |
| 8648 | |
| 8649 | if (if_nametoindex("sigmadut") > 0 && |
| 8650 | system("iw dev sigmadut del") != 0) |
| 8651 | sigma_dut_print(dut, DUT_MSG_ERROR, "Failed to remove " |
| 8652 | "monitor interface"); |
| 8653 | |
| 8654 | return 1; |
| 8655 | } |
| 8656 | |
| 8657 | |
Ankita Bajaj | 0d5825b | 2017-10-25 16:20:17 +0530 | [diff] [blame] | 8658 | int sta_cfon_reset_default(struct sigma_dut *dut, struct sigma_conn *conn, |
| 8659 | struct sigma_cmd *cmd) |
| 8660 | { |
| 8661 | return cmd_ap_reset_default(dut, conn, cmd); |
| 8662 | } |
| 8663 | |
| 8664 | |
Jouni Malinen | f722271 | 2019-06-13 01:50:21 +0300 | [diff] [blame] | 8665 | static enum sigma_cmd_result cmd_ap_get_info(struct sigma_dut *dut, |
| 8666 | struct sigma_conn *conn, |
| 8667 | struct sigma_cmd *cmd) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8668 | { |
| 8669 | /* const char *name = get_param(cmd, "NAME"); */ |
| 8670 | struct stat s; |
| 8671 | char resp[200]; |
| 8672 | FILE *f; |
| 8673 | enum driver_type drv = get_driver_type(); |
Jouni Malinen | 3aa7286 | 2019-05-29 23:14:51 +0300 | [diff] [blame] | 8674 | int res; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8675 | |
| 8676 | switch (drv) { |
| 8677 | case DRIVER_ATHEROS: { |
| 8678 | /* Atheros AP */ |
| 8679 | struct utsname uts; |
| 8680 | char *version, athver[100]; |
| 8681 | |
| 8682 | if (stat("/proc/athversion", &s) != 0) { |
| 8683 | if (system("/etc/rc.d/rc.wlan up") != 0) { |
| 8684 | } |
| 8685 | } |
| 8686 | |
| 8687 | athver[0] = '\0'; |
| 8688 | f = fopen("/proc/athversion", "r"); |
| 8689 | if (f) { |
| 8690 | if (fgets(athver, sizeof(athver), f)) { |
| 8691 | char *pos = strchr(athver, '\n'); |
| 8692 | if (pos) |
| 8693 | *pos = '\0'; |
| 8694 | } |
| 8695 | fclose(f); |
| 8696 | } |
| 8697 | |
| 8698 | if (uname(&uts) == 0) |
| 8699 | version = uts.release; |
| 8700 | else |
| 8701 | version = "Unknown"; |
| 8702 | |
| 8703 | if (if_nametoindex("ath1") > 0) |
Jouni Malinen | 3aa7286 | 2019-05-29 23:14:51 +0300 | [diff] [blame] | 8704 | res = snprintf(resp, sizeof(resp), |
| 8705 | "interface,ath0_24G ath1_5G,agent,1.0,version,%s/drv:%s", |
| 8706 | version, athver); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8707 | else |
Jouni Malinen | 3aa7286 | 2019-05-29 23:14:51 +0300 | [diff] [blame] | 8708 | res = snprintf(resp, sizeof(resp), |
| 8709 | "interface,ath0_24G,agent,1.0,version,%s/drv:%s", |
| 8710 | version, athver); |
| 8711 | if (res < 0 || res >= sizeof(resp)) |
| 8712 | send_resp(dut, conn, SIGMA_ERROR, NULL); |
| 8713 | else |
| 8714 | send_resp(dut, conn, SIGMA_COMPLETE, resp); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8715 | return 0; |
| 8716 | } |
Sreelakshmi Konamki | b692f10 | 2016-04-26 19:47:00 +0530 | [diff] [blame] | 8717 | case DRIVER_LINUX_WCN: |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8718 | case DRIVER_MAC80211: { |
| 8719 | struct utsname uts; |
| 8720 | char *version; |
| 8721 | |
| 8722 | if (uname(&uts) == 0) |
| 8723 | version = uts.release; |
| 8724 | else |
| 8725 | version = "Unknown"; |
| 8726 | |
| 8727 | if (if_nametoindex("wlan1") > 0) |
| 8728 | snprintf(resp, sizeof(resp), "interface,wlan0_24G " |
| 8729 | "wlan1_5G,agent,1.0,version,%s", version); |
| 8730 | else |
| 8731 | snprintf(resp, sizeof(resp), "interface,wlan0_any," |
| 8732 | "agent,1.0,version,%s", version); |
| 8733 | |
| 8734 | send_resp(dut, conn, SIGMA_COMPLETE, resp); |
| 8735 | return 0; |
| 8736 | } |
| 8737 | case DRIVER_QNXNTO: { |
| 8738 | struct utsname uts; |
| 8739 | char *version; |
| 8740 | |
| 8741 | if (uname(&uts) == 0) |
| 8742 | version = uts.release; |
| 8743 | else |
| 8744 | version = "Unknown"; |
| 8745 | snprintf(resp, sizeof(resp), |
| 8746 | "interface,%s_any,agent,1.0,version,%s", |
| 8747 | sigma_main_ifname ? sigma_main_ifname : "NA", |
| 8748 | version); |
| 8749 | send_resp(dut, conn, SIGMA_COMPLETE, resp); |
| 8750 | return 0; |
| 8751 | } |
| 8752 | case DRIVER_OPENWRT: { |
| 8753 | switch (get_openwrt_driver_type()) { |
| 8754 | case OPENWRT_DRIVER_ATHEROS: { |
| 8755 | struct utsname uts; |
| 8756 | char *version; |
| 8757 | |
| 8758 | if (uname(&uts) == 0) |
| 8759 | version = uts.release; |
| 8760 | else |
| 8761 | version = "Unknown"; |
| 8762 | |
| 8763 | if (if_nametoindex("ath1") > 0) |
| 8764 | snprintf(resp, sizeof(resp), |
| 8765 | "interface,ath0_5G ath1_24G,agent,1.0,version,%s", |
| 8766 | version); |
| 8767 | else |
| 8768 | snprintf(resp, sizeof(resp), |
| 8769 | "interface,ath0_any,agent,1.0,version,%s", |
| 8770 | version); |
| 8771 | |
| 8772 | send_resp(dut, conn, SIGMA_COMPLETE, resp); |
| 8773 | return 0; |
| 8774 | } |
| 8775 | default: |
| 8776 | send_resp(dut, conn, SIGMA_ERROR, |
| 8777 | "errorCode,Unsupported openwrt driver"); |
| 8778 | return 0; |
| 8779 | } |
| 8780 | } |
| 8781 | default: |
| 8782 | send_resp(dut, conn, SIGMA_ERROR, |
| 8783 | "errorCode,Unsupported driver"); |
| 8784 | return 0; |
| 8785 | } |
| 8786 | } |
| 8787 | |
| 8788 | |
Jouni Malinen | f722271 | 2019-06-13 01:50:21 +0300 | [diff] [blame] | 8789 | static enum sigma_cmd_result cmd_ap_deauth_sta(struct sigma_dut *dut, |
| 8790 | struct sigma_conn *conn, |
| 8791 | struct sigma_cmd *cmd) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8792 | { |
| 8793 | /* const char *name = get_param(cmd, "NAME"); */ |
| 8794 | /* const char *ifname = get_param(cmd, "INTERFACE"); */ |
| 8795 | const char *val; |
| 8796 | char buf[100]; |
| 8797 | |
| 8798 | val = get_param(cmd, "MinorCode"); |
| 8799 | if (val) { |
| 8800 | /* TODO: add support for P2P minor code */ |
| 8801 | send_resp(dut, conn, SIGMA_ERROR, "errorCode,MinorCode not " |
| 8802 | "yet supported"); |
| 8803 | return 0; |
| 8804 | } |
| 8805 | |
| 8806 | val = get_param(cmd, "STA_MAC_ADDRESS"); |
| 8807 | if (val == NULL) |
| 8808 | return -1; |
| 8809 | snprintf(buf, sizeof(buf), "deauth %s", val); |
| 8810 | if (run_hostapd_cli(dut, buf) != 0) |
| 8811 | return -2; |
| 8812 | |
| 8813 | return 1; |
| 8814 | } |
| 8815 | |
| 8816 | |
| 8817 | #ifdef __linux__ |
| 8818 | int inject_frame(int s, const void *data, size_t len, int encrypt); |
| 8819 | int open_monitor(const char *ifname); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8820 | #endif /* __linux__ */ |
| 8821 | |
| 8822 | enum send_frame_type { |
| 8823 | DISASSOC, DEAUTH, SAQUERY |
| 8824 | }; |
| 8825 | enum send_frame_protection { |
| 8826 | CORRECT_KEY, INCORRECT_KEY, UNPROTECTED |
| 8827 | }; |
| 8828 | |
| 8829 | |
| 8830 | static int ap_inject_frame(struct sigma_dut *dut, struct sigma_conn *conn, |
| 8831 | enum send_frame_type frame, |
| 8832 | enum send_frame_protection protected, |
| 8833 | const char *sta_addr) |
| 8834 | { |
| 8835 | #ifdef __linux__ |
| 8836 | unsigned char buf[1000], *pos; |
| 8837 | int s, res; |
| 8838 | unsigned char addr_sta[6], addr_own[6]; |
| 8839 | char *ifname; |
| 8840 | char cbuf[100]; |
| 8841 | struct ifreq ifr; |
| 8842 | |
| 8843 | if ((dut->ap_mode == AP_11a || dut->ap_mode == AP_11na || |
| 8844 | dut->ap_mode == AP_11ac) && |
| 8845 | if_nametoindex("wlan1") > 0) |
| 8846 | ifname = "wlan1"; |
| 8847 | else |
| 8848 | ifname = "wlan0"; |
| 8849 | |
| 8850 | if (hwaddr_aton(sta_addr, addr_sta) < 0) |
| 8851 | return -1; |
| 8852 | |
| 8853 | s = socket(AF_INET, SOCK_DGRAM, 0); |
| 8854 | if (s < 0) |
| 8855 | return -1; |
| 8856 | memset(&ifr, 0, sizeof(ifr)); |
Peng Xu | b8fc5cc | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 8857 | strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name)); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8858 | if (ioctl(s, SIOCGIFHWADDR, &ifr) < 0) { |
| 8859 | perror("ioctl"); |
| 8860 | close(s); |
| 8861 | return -1; |
| 8862 | } |
| 8863 | close(s); |
| 8864 | memcpy(addr_own, ifr.ifr_hwaddr.sa_data, 6); |
| 8865 | |
| 8866 | if (if_nametoindex("sigmadut") == 0) { |
| 8867 | snprintf(cbuf, sizeof(cbuf), |
| 8868 | "iw dev %s interface add sigmadut type monitor", |
| 8869 | ifname); |
| 8870 | if (system(cbuf) != 0 || |
| 8871 | if_nametoindex("sigmadut") == 0) { |
| 8872 | sigma_dut_print(dut, DUT_MSG_ERROR, "Failed to add " |
| 8873 | "monitor interface with '%s'", cbuf); |
| 8874 | return -2; |
| 8875 | } |
| 8876 | } |
| 8877 | |
| 8878 | if (system("ifconfig sigmadut up") != 0) { |
| 8879 | sigma_dut_print(dut, DUT_MSG_ERROR, "Failed to set " |
| 8880 | "monitor interface up"); |
| 8881 | return -2; |
| 8882 | } |
| 8883 | |
| 8884 | pos = buf; |
| 8885 | |
| 8886 | /* Frame Control */ |
| 8887 | switch (frame) { |
| 8888 | case DISASSOC: |
| 8889 | *pos++ = 0xa0; |
| 8890 | break; |
| 8891 | case DEAUTH: |
| 8892 | *pos++ = 0xc0; |
| 8893 | break; |
| 8894 | case SAQUERY: |
| 8895 | *pos++ = 0xd0; |
| 8896 | break; |
| 8897 | } |
| 8898 | |
| 8899 | if (protected == INCORRECT_KEY) |
| 8900 | *pos++ = 0x40; /* Set Protected field to 1 */ |
| 8901 | else |
| 8902 | *pos++ = 0x00; |
| 8903 | |
| 8904 | /* Duration */ |
| 8905 | *pos++ = 0x00; |
| 8906 | *pos++ = 0x00; |
| 8907 | |
| 8908 | /* addr1 = DA (station) */ |
| 8909 | memcpy(pos, addr_sta, 6); |
| 8910 | pos += 6; |
| 8911 | /* addr2 = SA (own address) */ |
| 8912 | memcpy(pos, addr_own, 6); |
| 8913 | pos += 6; |
| 8914 | /* addr3 = BSSID (own address) */ |
| 8915 | memcpy(pos, addr_own, 6); |
| 8916 | pos += 6; |
| 8917 | |
| 8918 | /* Seq# (to be filled by driver/mac80211) */ |
| 8919 | *pos++ = 0x00; |
| 8920 | *pos++ = 0x00; |
| 8921 | |
| 8922 | if (protected == INCORRECT_KEY) { |
| 8923 | /* CCMP parameters */ |
| 8924 | memcpy(pos, "\x61\x01\x00\x20\x00\x10\x00\x00", 8); |
| 8925 | pos += 8; |
| 8926 | } |
| 8927 | |
| 8928 | if (protected == INCORRECT_KEY) { |
| 8929 | switch (frame) { |
| 8930 | case DEAUTH: |
| 8931 | /* Reason code (encrypted) */ |
| 8932 | memcpy(pos, "\xa7\x39", 2); |
| 8933 | pos += 2; |
| 8934 | break; |
| 8935 | case DISASSOC: |
| 8936 | /* Reason code (encrypted) */ |
| 8937 | memcpy(pos, "\xa7\x39", 2); |
| 8938 | pos += 2; |
| 8939 | break; |
| 8940 | case SAQUERY: |
| 8941 | /* Category|Action|TransID (encrypted) */ |
| 8942 | memcpy(pos, "\x6f\xbd\xe9\x4d", 4); |
| 8943 | pos += 4; |
| 8944 | break; |
| 8945 | default: |
| 8946 | return -1; |
| 8947 | } |
| 8948 | |
| 8949 | /* CCMP MIC */ |
| 8950 | memcpy(pos, "\xc8\xd8\x3b\x06\x5d\xb7\x25\x68", 8); |
| 8951 | pos += 8; |
| 8952 | } else { |
| 8953 | switch (frame) { |
| 8954 | case DEAUTH: |
| 8955 | /* reason code = 8 */ |
| 8956 | *pos++ = 0x08; |
| 8957 | *pos++ = 0x00; |
| 8958 | break; |
| 8959 | case DISASSOC: |
| 8960 | /* reason code = 8 */ |
| 8961 | *pos++ = 0x08; |
| 8962 | *pos++ = 0x00; |
| 8963 | break; |
| 8964 | case SAQUERY: |
| 8965 | /* Category - SA Query */ |
| 8966 | *pos++ = 0x08; |
| 8967 | /* SA query Action - Request */ |
| 8968 | *pos++ = 0x00; |
| 8969 | /* Transaction ID */ |
| 8970 | *pos++ = 0x12; |
| 8971 | *pos++ = 0x34; |
| 8972 | break; |
| 8973 | } |
| 8974 | } |
| 8975 | |
| 8976 | s = open_monitor("sigmadut"); |
| 8977 | if (s < 0) { |
| 8978 | send_resp(dut, conn, SIGMA_ERROR, "errorCode,Failed to open " |
| 8979 | "monitor socket"); |
| 8980 | return 0; |
| 8981 | } |
| 8982 | |
| 8983 | res = inject_frame(s, buf, pos - buf, protected == CORRECT_KEY); |
| 8984 | if (res < 0) { |
| 8985 | send_resp(dut, conn, SIGMA_ERROR, "errorCode,Failed to " |
| 8986 | "inject frame"); |
Pradeep Reddy POTTETI | 673d85c | 2016-07-26 19:08:07 +0530 | [diff] [blame] | 8987 | close(s); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8988 | return 0; |
| 8989 | } |
| 8990 | if (res < pos - buf) { |
| 8991 | send_resp(dut, conn, SIGMA_ERROR, "errorCode,Only partial " |
| 8992 | "frame sent"); |
Pradeep Reddy POTTETI | 673d85c | 2016-07-26 19:08:07 +0530 | [diff] [blame] | 8993 | close(s); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8994 | return 0; |
| 8995 | } |
| 8996 | |
| 8997 | close(s); |
| 8998 | |
| 8999 | return 1; |
| 9000 | #else /* __linux__ */ |
| 9001 | send_resp(dut, conn, SIGMA_ERROR, "errorCode,ap_send_frame not " |
| 9002 | "yet supported"); |
| 9003 | return 0; |
| 9004 | #endif /* __linux__ */ |
| 9005 | } |
| 9006 | |
| 9007 | |
| 9008 | int ap_send_frame_hs2(struct sigma_dut *dut, struct sigma_conn *conn, |
| 9009 | struct sigma_cmd *cmd) |
| 9010 | { |
| 9011 | const char *val, *dest; |
| 9012 | char buf[100]; |
| 9013 | |
| 9014 | val = get_param(cmd, "FrameName"); |
| 9015 | if (val == NULL) |
| 9016 | return -1; |
| 9017 | |
| 9018 | if (strcasecmp(val, "QoSMapConfigure") == 0) { |
| 9019 | dest = get_param(cmd, "Dest"); |
| 9020 | if (!dest) |
| 9021 | return -1; |
| 9022 | |
| 9023 | val = get_param(cmd, "QoS_MAP_SET"); |
| 9024 | if (val) { |
| 9025 | dut->ap_qos_map_set = atoi(val); |
| 9026 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_qos_map_set %d", |
| 9027 | dut->ap_qos_map_set); |
| 9028 | } |
| 9029 | |
| 9030 | if (dut->ap_qos_map_set == 1) |
| 9031 | run_hostapd_cli(dut, "set_qos_map_set " QOS_MAP_SET_1); |
| 9032 | else if (dut->ap_qos_map_set == 2) |
| 9033 | run_hostapd_cli(dut, "set_qos_map_set " QOS_MAP_SET_2); |
| 9034 | |
| 9035 | snprintf(buf, sizeof(buf), "send_qos_map_conf %s", dest); |
| 9036 | if (run_hostapd_cli(dut, buf) != 0) |
| 9037 | return -1; |
| 9038 | } |
| 9039 | |
| 9040 | return 1; |
| 9041 | } |
| 9042 | |
| 9043 | |
| 9044 | static int ath_ap_send_frame_vht(struct sigma_dut *dut, struct sigma_conn *conn, |
| 9045 | struct sigma_cmd *cmd) |
| 9046 | { |
| 9047 | const char *val; |
| 9048 | char *ifname; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9049 | int chwidth, nss; |
| 9050 | |
| 9051 | val = get_param(cmd, "FrameName"); |
| 9052 | if (!val || strcasecmp(val, "op_md_notif_frm") != 0) { |
| 9053 | send_resp(dut, conn, SIGMA_ERROR, |
| 9054 | "errorCode,Unsupported FrameName"); |
| 9055 | return 0; |
| 9056 | } |
| 9057 | |
| 9058 | /* |
| 9059 | * Sequence of commands for Opmode notification on |
| 9060 | * Peregrine based products |
| 9061 | */ |
| 9062 | ifname = get_main_ifname(); |
| 9063 | |
| 9064 | /* Disable STBC */ |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 9065 | run_iwpriv(dut, ifname, "tx_stbc 0"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9066 | |
| 9067 | /* Check whether optional arg channel width was passed */ |
| 9068 | val = get_param(cmd, "Channel_width"); |
| 9069 | if (val) { |
| 9070 | switch (atoi(val)) { |
| 9071 | case 20: |
| 9072 | chwidth = 0; |
| 9073 | break; |
| 9074 | case 40: |
| 9075 | chwidth = 1; |
| 9076 | break; |
| 9077 | case 80: |
| 9078 | chwidth = 2; |
| 9079 | break; |
| 9080 | case 160: |
| 9081 | chwidth = 3; |
| 9082 | break; |
| 9083 | default: |
| 9084 | chwidth = 2; |
| 9085 | break; |
| 9086 | } |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 9087 | run_iwpriv(dut, ifname, "chwidth %d", chwidth); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9088 | } |
| 9089 | |
| 9090 | /* Check whether optional arg NSS was passed */ |
| 9091 | val = get_param(cmd, "NSS"); |
| 9092 | if (val) { |
| 9093 | /* Convert nss to chainmask */ |
| 9094 | switch (atoi(val)) { |
| 9095 | case 1: |
| 9096 | nss = 1; |
| 9097 | break; |
| 9098 | case 2: |
| 9099 | nss = 3; |
| 9100 | break; |
| 9101 | case 3: |
| 9102 | nss = 7; |
| 9103 | break; |
| 9104 | default: |
| 9105 | /* We do not support NSS > 3 */ |
| 9106 | nss = 3; |
| 9107 | break; |
| 9108 | } |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 9109 | run_iwpriv(dut, ifname, "rxchainmask %d", nss); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9110 | } |
| 9111 | |
| 9112 | /* Send the opmode notification */ |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 9113 | run_iwpriv(dut, ifname, "opmode_notify 1"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9114 | |
| 9115 | return 1; |
| 9116 | } |
| 9117 | |
| 9118 | |
priyadharshini gowthaman | a27b5b6 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 9119 | static int ath_ap_send_frame_loc(struct sigma_dut *dut, struct sigma_conn *conn, |
| 9120 | struct sigma_cmd *cmd) |
| 9121 | { |
| 9122 | const char *val; |
| 9123 | FILE *f; |
priyadharshini gowthaman | a61badd | 2016-08-16 13:37:27 -0700 | [diff] [blame] | 9124 | int rand_int = 0; |
priyadharshini gowthaman | a27b5b6 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 9125 | |
| 9126 | val = get_param(cmd, "MsntType"); |
| 9127 | if (val) { |
| 9128 | if (dut->ap_msnt_type == 0) |
| 9129 | dut->ap_msnt_type = atoi(val); |
| 9130 | |
| 9131 | if (dut->ap_msnt_type != 5 && dut->ap_msnt_type != 2) { |
| 9132 | dut->ap_msnt_type = atoi(val); |
| 9133 | if (dut->ap_msnt_type == 1) { |
priyadharshini gowthaman | a61badd | 2016-08-16 13:37:27 -0700 | [diff] [blame] | 9134 | val = get_param(cmd, "RandInterval"); |
| 9135 | if (val) |
| 9136 | rand_int = atoi(val); |
priyadharshini gowthaman | a27b5b6 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 9137 | f = fopen("/tmp/ftmrr.txt", "a"); |
| 9138 | if (!f) { |
| 9139 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 9140 | "Failed to open /tmp/ftmrr.txt"); |
| 9141 | return -1; |
| 9142 | } |
| 9143 | |
| 9144 | fprintf(f, "sta_mac = %s\n", cmd->values[3]); |
priyadharshini gowthaman | a61badd | 2016-08-16 13:37:27 -0700 | [diff] [blame] | 9145 | 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", |
| 9146 | rand_int, cmd->values[7]); |
priyadharshini gowthaman | a27b5b6 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 9147 | fclose(f); |
| 9148 | dut->ap_msnt_type = 5; |
| 9149 | run_system(dut, "wpc -f /tmp/ftmrr.txt"); |
| 9150 | } |
| 9151 | } else if (dut->ap_msnt_type == 5) { |
| 9152 | run_system(dut, "wpc -f /tmp/ftmrr.txt"); |
| 9153 | } else if (dut->ap_msnt_type == 2) { |
| 9154 | f = fopen("/tmp/wru.txt", "w"); |
| 9155 | if (!f) { |
| 9156 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 9157 | "Failed to open /tmp/wru.txt"); |
| 9158 | return -1; |
| 9159 | } |
| 9160 | |
| 9161 | fprintf(f, "sta_mac = %s\n", cmd->values[3]); |
| 9162 | fprintf(f, "meas_type = 0x08\ndialogtoken = 0x1\nnum_repetitions = 0x0\nmeas_token = 0x1\nmeas_req_mode = 0x00\nloc_subject = 0x01\n"); |
| 9163 | fclose(f); |
| 9164 | run_system(dut, "wpc -w /tmp/wru.txt"); |
| 9165 | } |
| 9166 | } |
| 9167 | return 1; |
| 9168 | } |
| 9169 | |
| 9170 | |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 9171 | /* |
| 9172 | * The following functions parse_send_frame_params_int(), |
| 9173 | * parse_send_frame_params_str(), and parse_send_frame_params_mac() |
| 9174 | * are used by ath_ap_send_frame_bcn_rpt_req(). |
| 9175 | * Beacon Report Request is a frame used as part of the MBO program. |
| 9176 | * The command for sending beacon report has a lot of |
| 9177 | * arguments and having these functions reduces code size. |
| 9178 | * |
| 9179 | */ |
| 9180 | static int parse_send_frame_params_int(char *param, struct sigma_cmd *cmd, |
| 9181 | struct sigma_dut *dut, |
| 9182 | char *buf, size_t buf_size) |
| 9183 | { |
| 9184 | const char *str_val; |
| 9185 | int int_val; |
| 9186 | char temp[100]; |
| 9187 | |
| 9188 | str_val = get_param(cmd, param); |
| 9189 | if (!str_val) { |
| 9190 | sigma_dut_print(dut, DUT_MSG_ERROR, "%s not given", param); |
| 9191 | return -1; |
| 9192 | } |
| 9193 | int_val = atoi(str_val); |
| 9194 | snprintf(temp, sizeof(temp), " %d", int_val); |
Peng Xu | 591be45 | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 9195 | strlcat(buf, temp, buf_size); |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 9196 | return 0; |
| 9197 | } |
| 9198 | |
| 9199 | |
| 9200 | static int parse_send_frame_params_str(char *param, struct sigma_cmd *cmd, |
| 9201 | struct sigma_dut *dut, |
| 9202 | char *buf, size_t buf_size) |
| 9203 | { |
| 9204 | const char *str_val; |
| 9205 | char temp[100]; |
| 9206 | |
| 9207 | str_val = get_param(cmd, param); |
| 9208 | if (!str_val) { |
| 9209 | sigma_dut_print(dut, DUT_MSG_ERROR, "%s not given", param); |
| 9210 | return -1; |
| 9211 | } |
| 9212 | snprintf(temp, sizeof(temp), " %s", str_val); |
| 9213 | temp[sizeof(temp) - 1] = '\0'; |
Peng Xu | 591be45 | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 9214 | strlcat(buf, temp, buf_size); |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 9215 | return 0; |
| 9216 | } |
| 9217 | |
| 9218 | |
| 9219 | static int parse_send_frame_params_mac(char *param, struct sigma_cmd *cmd, |
| 9220 | struct sigma_dut *dut, |
| 9221 | char *buf, size_t buf_size) |
| 9222 | { |
| 9223 | const char *str_val; |
| 9224 | unsigned char mac[6]; |
| 9225 | char temp[100]; |
| 9226 | |
| 9227 | str_val = get_param(cmd, param); |
| 9228 | if (!str_val) { |
| 9229 | sigma_dut_print(dut, DUT_MSG_ERROR, "%s not given", param); |
| 9230 | return -1; |
| 9231 | } |
| 9232 | |
| 9233 | if (parse_mac_address(dut, str_val, mac) < 0) { |
| 9234 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 9235 | "MAC Address not in proper format"); |
| 9236 | return -1; |
| 9237 | } |
| 9238 | snprintf(temp, sizeof(temp), " %02x:%02x:%02x:%02x:%02x:%02x", |
| 9239 | mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]); |
Peng Xu | 591be45 | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 9240 | strlcat(buf, temp, buf_size); |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 9241 | return 0; |
| 9242 | } |
| 9243 | |
| 9244 | |
| 9245 | static void fill_1_or_0_based_on_presence(struct sigma_cmd *cmd, char *param, |
| 9246 | char *buf, size_t buf_size) |
| 9247 | { |
| 9248 | const char *str_val; |
| 9249 | char *value = " 1"; |
| 9250 | |
| 9251 | str_val = get_param(cmd, param); |
| 9252 | if (!str_val || str_val[0] == '\0') |
| 9253 | value = " 0"; |
Peng Xu | 591be45 | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 9254 | strlcat(buf, value, buf_size); |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 9255 | |
| 9256 | } |
| 9257 | |
| 9258 | |
| 9259 | /* |
| 9260 | * wifitool athN sendbcnrpt |
| 9261 | * <STA MAC - Plugs in from Dest_MAC> |
| 9262 | * <regclass - Plugs in from RegClass - int> |
| 9263 | * <channum - Plugs in from Channel PARAM of dev_send_frame - int> |
| 9264 | * <rand_ivl - Plugs in from RandInt - string> |
| 9265 | * <duration - Plugs in from MeaDur - integer> |
| 9266 | * <mode - Plugs in from MeaMode - string> |
| 9267 | * <req_ssid - Plugs in from SSID PARAM of dev_send_frame - string> |
| 9268 | * <rep_cond - Plugs in from RptCond - integer> |
| 9269 | * <rpt_detail - Plugs in from RptDet - integer> |
| 9270 | * <req_ie - Plugs in from ReqInfo PARAM of dev_send_frame - string> |
| 9271 | * <chanrpt_mode - Plugs in from APChanRpt - integer> |
| 9272 | * <specific_bssid - Plugs in from BSSID PARAM of dev_send_frame> |
| 9273 | * [AP channel numbers] |
| 9274 | */ |
| 9275 | static int ath_ap_send_frame_bcn_rpt_req(struct sigma_dut *dut, |
| 9276 | struct sigma_cmd *cmd, |
| 9277 | const char *ifname) |
| 9278 | { |
| 9279 | char buf[100]; |
| 9280 | int rpt_det; |
| 9281 | const char *str_val; |
| 9282 | const char *mea_mode; |
| 9283 | |
| 9284 | snprintf(buf, sizeof(buf), "wifitool %s sendbcnrpt", ifname); |
| 9285 | |
| 9286 | if (parse_send_frame_params_mac("Dest_MAC", cmd, dut, buf, sizeof(buf))) |
| 9287 | return -1; |
| 9288 | if (parse_send_frame_params_int("RegClass", cmd, dut, buf, sizeof(buf))) |
| 9289 | return -1; |
| 9290 | if (parse_send_frame_params_int("Channel", cmd, dut, buf, sizeof(buf))) |
| 9291 | return -1; |
| 9292 | if (parse_send_frame_params_str("RandInt", cmd, dut, buf, sizeof(buf))) |
| 9293 | return -1; |
| 9294 | if (parse_send_frame_params_int("MeaDur", cmd, dut, buf, sizeof(buf))) |
| 9295 | return -1; |
| 9296 | |
| 9297 | str_val = get_param(cmd, "MeaMode"); |
| 9298 | if (!str_val) { |
| 9299 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 9300 | "MeaMode parameter not present in send bcn-rpt-req"); |
| 9301 | return -1; |
| 9302 | } |
| 9303 | if (strcasecmp(str_val, "passive") == 0) { |
| 9304 | mea_mode = " 0"; |
| 9305 | } else if (strcasecmp(str_val, "active") == 0) { |
| 9306 | mea_mode = " 1"; |
| 9307 | } else if (strcasecmp(str_val, "table") == 0) { |
| 9308 | mea_mode = " 2"; |
| 9309 | } else { |
| 9310 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 9311 | "MEA-MODE Value not correctly given"); |
| 9312 | return -1; |
| 9313 | } |
Peng Xu | 591be45 | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 9314 | strlcat(buf, mea_mode, sizeof(buf)); |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 9315 | |
| 9316 | fill_1_or_0_based_on_presence(cmd, "SSID", buf, sizeof(buf)); |
| 9317 | |
| 9318 | if (parse_send_frame_params_int("RptCond", cmd, dut, buf, sizeof(buf))) |
| 9319 | return -1; |
| 9320 | |
| 9321 | if (parse_send_frame_params_int("RptDet", cmd, dut, buf, sizeof(buf))) |
| 9322 | return -1; |
| 9323 | str_val = get_param(cmd, "RptDet"); |
| 9324 | rpt_det = str_val ? atoi(str_val) : 0; |
| 9325 | |
| 9326 | if (rpt_det) |
| 9327 | fill_1_or_0_based_on_presence(cmd, "ReqInfo", buf, sizeof(buf)); |
| 9328 | else |
Peng Xu | 591be45 | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 9329 | strlcat(buf, " 0", sizeof(buf)); |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 9330 | |
| 9331 | if (rpt_det) |
| 9332 | fill_1_or_0_based_on_presence(cmd, "APChanRpt", buf, |
| 9333 | sizeof(buf)); |
| 9334 | else |
Peng Xu | 591be45 | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 9335 | strlcat(buf, " 0", sizeof(buf)); |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 9336 | |
| 9337 | if (parse_send_frame_params_mac("BSSID", cmd, dut, buf, sizeof(buf))) |
| 9338 | return -1; |
| 9339 | |
priyadharshini gowthaman | 2a4d20e | 2017-12-28 13:01:34 -0800 | [diff] [blame] | 9340 | str_val = get_param(cmd, "APChanRpt"); |
| 9341 | if (str_val) { |
| 9342 | const char *pos; |
| 9343 | int ap_chanrpt; |
| 9344 | int ap_chanrpt_2 = 0; |
| 9345 | char chanrpt[100]; |
| 9346 | |
| 9347 | ap_chanrpt = atoi(str_val); |
| 9348 | pos = strchr(str_val, '_'); |
| 9349 | if (pos) { |
| 9350 | pos++; |
| 9351 | ap_chanrpt_2 = atoi(pos); |
| 9352 | } |
| 9353 | if (ap_chanrpt) { |
| 9354 | snprintf(chanrpt, sizeof(chanrpt), " %d", ap_chanrpt); |
| 9355 | strlcat(buf, chanrpt, sizeof(buf)); |
| 9356 | } |
| 9357 | if (ap_chanrpt_2) { |
| 9358 | snprintf(chanrpt, sizeof(chanrpt), " %d", ap_chanrpt_2); |
| 9359 | strlcat(buf, chanrpt, sizeof(buf)); |
| 9360 | } |
| 9361 | } |
| 9362 | |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 9363 | run_system(dut, buf); |
| 9364 | return 0; |
| 9365 | } |
| 9366 | |
| 9367 | |
| 9368 | static void inform_and_sleep(struct sigma_dut *dut, int seconds) |
| 9369 | { |
| 9370 | sigma_dut_print(dut, DUT_MSG_DEBUG, "sleeping for %d seconds", seconds); |
| 9371 | sleep(seconds); |
| 9372 | sigma_dut_print(dut, DUT_MSG_DEBUG, "woke up after %d seconds", |
| 9373 | seconds); |
| 9374 | } |
| 9375 | |
| 9376 | |
| 9377 | static int ath_ap_send_frame_btm_req(struct sigma_dut *dut, |
| 9378 | struct sigma_cmd *cmd, const char *ifname) |
| 9379 | { |
| 9380 | unsigned char mac_addr[ETH_ALEN]; |
| 9381 | int disassoc_timer; |
| 9382 | char buf[100]; |
| 9383 | const char *val; |
| 9384 | int cand_list = 1; |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 9385 | |
| 9386 | val = get_param(cmd, "Dest_MAC"); |
| 9387 | if (!val || parse_mac_address(dut, val, mac_addr) < 0) { |
| 9388 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 9389 | "MAC Address not in proper format"); |
| 9390 | return -1; |
| 9391 | } |
| 9392 | |
| 9393 | val = get_param(cmd, "Disassoc_Timer"); |
| 9394 | if (val) |
| 9395 | disassoc_timer = atoi(val); |
| 9396 | else |
| 9397 | disassoc_timer = dut->ap_disassoc_timer; |
Jouni Malinen | 032aeab | 2018-01-04 12:30:46 +0200 | [diff] [blame] | 9398 | if (disassoc_timer < 0) { |
| 9399 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 9400 | "Invalid Disassoc_Timer value %d", |
| 9401 | disassoc_timer); |
| 9402 | return -1; |
| 9403 | } |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 9404 | |
| 9405 | val = get_param(cmd, "Cand_List"); |
| 9406 | if (val && val[0]) |
| 9407 | cand_list = atoi(val); |
| 9408 | |
| 9409 | val = get_param(cmd, "BTMQuery_Reason_Code"); |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 9410 | if (val) |
| 9411 | run_iwpriv(dut, ifname, "mbo_trans_rs %s", val); |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 9412 | |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 9413 | if (dut->ap_btmreq_disassoc_imnt && !dut->ap_assoc_delay) |
| 9414 | run_iwpriv(dut, ifname, "mbo_asoc_ret 1"); |
priyadharshini gowthaman | 776562e | 2017-12-20 12:33:34 -0800 | [diff] [blame] | 9415 | |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 9416 | snprintf(buf, sizeof(buf), |
priyadharshini gowthaman | 776562e | 2017-12-20 12:33:34 -0800 | [diff] [blame] | 9417 | "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] | 9418 | ifname, mac_addr[0], mac_addr[1], mac_addr[2], mac_addr[3], |
| 9419 | mac_addr[4], mac_addr[5], cand_list, disassoc_timer, |
| 9420 | dut->ap_btmreq_disassoc_imnt, |
| 9421 | dut->ap_btmreq_term_bit, |
priyadharshini gowthaman | 94062b5 | 2017-12-20 12:33:34 -0800 | [diff] [blame] | 9422 | dut->ap_btmreq_bss_term_tsf, |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 9423 | dut->ap_btmreq_bss_term_dur); |
| 9424 | run_system(dut, buf); |
| 9425 | |
| 9426 | if (dut->ap_btmreq_term_bit) { |
priyadharshini gowthaman | 94062b5 | 2017-12-20 12:33:34 -0800 | [diff] [blame] | 9427 | if (dut->ap_btmreq_bss_term_tsf >= 2) |
| 9428 | inform_and_sleep(dut, dut->ap_btmreq_bss_term_tsf - 2); |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 9429 | run_iwpriv(dut, ifname, "kickmac %02x:%02x:%02x:%02x:%02x:%02x", |
| 9430 | mac_addr[0], mac_addr[1], mac_addr[2], |
| 9431 | mac_addr[3], mac_addr[4], mac_addr[5]); |
priyadharshini gowthaman | 776562e | 2017-12-20 12:33:34 -0800 | [diff] [blame] | 9432 | inform_and_sleep(dut, 2); |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 9433 | run_system_wrapper(dut, "ifconfig %s down", ifname); |
priyadharshini gowthaman | 776562e | 2017-12-20 12:33:34 -0800 | [diff] [blame] | 9434 | inform_and_sleep(dut, 5); |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 9435 | run_system_wrapper(dut, "ifconfig %s up", ifname); |
| 9436 | } else if (dut->ap_btmreq_disassoc_imnt) { |
| 9437 | inform_and_sleep(dut, (disassoc_timer / 1000) + 1); |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 9438 | run_iwpriv(dut, ifname, "kickmac %02x:%02x:%02x:%02x:%02x:%02x", |
| 9439 | mac_addr[0], mac_addr[1], mac_addr[2], |
| 9440 | mac_addr[3], mac_addr[4], mac_addr[5]); |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 9441 | } |
| 9442 | return 0; |
| 9443 | } |
| 9444 | |
| 9445 | |
priyadharshini gowthaman | 2a4d20e | 2017-12-28 13:01:34 -0800 | [diff] [blame] | 9446 | static int ath_ap_send_frame_disassoc(struct sigma_dut *dut, |
| 9447 | struct sigma_cmd *cmd, const char *ifname) |
| 9448 | { |
| 9449 | unsigned char mac_addr[ETH_ALEN]; |
| 9450 | const char *val; |
| 9451 | |
| 9452 | val = get_param(cmd, "Dest_MAC"); |
| 9453 | if (!val || parse_mac_address(dut, val, mac_addr) < 0) { |
| 9454 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 9455 | "MAC Address not in proper format"); |
| 9456 | return -1; |
| 9457 | } |
| 9458 | |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 9459 | run_iwpriv(dut, ifname, "kickmac %02x:%02x:%02x:%02x:%02x:%02x", |
| 9460 | mac_addr[0], mac_addr[1], mac_addr[2], |
| 9461 | mac_addr[3], mac_addr[4], mac_addr[5]); |
priyadharshini gowthaman | 2a4d20e | 2017-12-28 13:01:34 -0800 | [diff] [blame] | 9462 | return 0; |
| 9463 | } |
| 9464 | |
| 9465 | |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 9466 | static int ath_ap_send_frame_mbo(struct sigma_dut *dut, struct sigma_conn *conn, |
| 9467 | struct sigma_cmd *cmd) |
| 9468 | { |
| 9469 | const char *val; |
| 9470 | char *ifname; |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 9471 | |
| 9472 | ifname = get_main_ifname(); |
| 9473 | |
| 9474 | val = get_param(cmd, "FrameName"); |
| 9475 | if (!val) |
| 9476 | return -1; |
| 9477 | |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 9478 | if (strcasecmp(val, "BTMReq") == 0) |
| 9479 | ath_ap_send_frame_btm_req(dut, cmd, ifname); |
| 9480 | else if (strcasecmp(val, "BcnRptReq") == 0) |
| 9481 | ath_ap_send_frame_bcn_rpt_req(dut, cmd, ifname); |
priyadharshini gowthaman | 2a4d20e | 2017-12-28 13:01:34 -0800 | [diff] [blame] | 9482 | else if (strcasecmp(val, "disassoc") == 0) |
| 9483 | ath_ap_send_frame_disassoc(dut, cmd, ifname); |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 9484 | else |
| 9485 | return -1; |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 9486 | |
| 9487 | return 1; |
| 9488 | } |
| 9489 | |
| 9490 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9491 | static int ap_send_frame_vht(struct sigma_dut *dut, struct sigma_conn *conn, |
| 9492 | struct sigma_cmd *cmd) |
| 9493 | { |
| 9494 | switch (get_driver_type()) { |
| 9495 | case DRIVER_ATHEROS: |
| 9496 | return ath_ap_send_frame_vht(dut, conn, cmd); |
| 9497 | break; |
| 9498 | case DRIVER_OPENWRT: |
| 9499 | switch (get_openwrt_driver_type()) { |
| 9500 | case OPENWRT_DRIVER_ATHEROS: |
| 9501 | return ath_ap_send_frame_vht(dut, conn, cmd); |
| 9502 | default: |
| 9503 | send_resp(dut, conn, SIGMA_ERROR, |
| 9504 | "errorCode,Unsupported ap_send_frame with the current openwrt driver"); |
| 9505 | return 0; |
| 9506 | } |
| 9507 | default: |
| 9508 | send_resp(dut, conn, SIGMA_ERROR, |
| 9509 | "errorCode,Unsupported ap_send_frame with the current driver"); |
| 9510 | return 0; |
| 9511 | } |
| 9512 | } |
| 9513 | |
| 9514 | |
priyadharshini gowthaman | a27b5b6 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 9515 | static int ap_send_frame_loc(struct sigma_dut *dut, struct sigma_conn *conn, |
| 9516 | struct sigma_cmd *cmd) |
| 9517 | { |
| 9518 | switch (get_driver_type()) { |
| 9519 | case DRIVER_ATHEROS: |
| 9520 | return ath_ap_send_frame_loc(dut, conn, cmd); |
| 9521 | case DRIVER_OPENWRT: |
| 9522 | switch (get_openwrt_driver_type()) { |
| 9523 | case OPENWRT_DRIVER_ATHEROS: |
| 9524 | return ath_ap_send_frame_loc(dut, conn, cmd); |
| 9525 | default: |
| 9526 | send_resp(dut, conn, SIGMA_ERROR, |
| 9527 | "errorCode,Unsupported ap_send_frame_loc with the current openwrt driver"); |
| 9528 | return 0; |
| 9529 | } |
| 9530 | default: |
| 9531 | send_resp(dut, conn, SIGMA_ERROR, |
| 9532 | "errorCode,Unsupported ap_send_frame_loc with the current driver"); |
| 9533 | return 0; |
| 9534 | } |
| 9535 | } |
| 9536 | |
| 9537 | |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 9538 | static int ap_send_frame_mbo(struct sigma_dut *dut, struct sigma_conn *conn, |
| 9539 | struct sigma_cmd *cmd) |
| 9540 | { |
| 9541 | switch (get_driver_type()) { |
| 9542 | case DRIVER_ATHEROS: |
| 9543 | return ath_ap_send_frame_mbo(dut, conn, cmd); |
| 9544 | case DRIVER_OPENWRT: |
| 9545 | switch (get_openwrt_driver_type()) { |
| 9546 | case OPENWRT_DRIVER_ATHEROS: |
| 9547 | return ath_ap_send_frame_mbo(dut, conn, cmd); |
| 9548 | default: |
| 9549 | send_resp(dut, conn, SIGMA_ERROR, |
| 9550 | "errorCode,Unsupported ap_send_frame with the current openwrt driver"); |
| 9551 | return 0; |
| 9552 | } |
| 9553 | default: |
| 9554 | send_resp(dut, conn, SIGMA_ERROR, |
| 9555 | "errorCode,Unsupported ap_send_frame with the current driver"); |
| 9556 | return 0; |
| 9557 | } |
| 9558 | } |
| 9559 | |
| 9560 | |
Lior David | 0fe101e | 2017-03-09 16:09:50 +0200 | [diff] [blame] | 9561 | static int ap_send_frame_60g(struct sigma_dut *dut, |
| 9562 | struct sigma_conn *conn, |
| 9563 | struct sigma_cmd *cmd) |
| 9564 | { |
| 9565 | switch (get_driver_type()) { |
| 9566 | #ifdef __linux__ |
| 9567 | case DRIVER_WIL6210: |
| 9568 | return wil6210_send_frame_60g(dut, conn, cmd); |
| 9569 | #endif /* __linux__ */ |
| 9570 | default: |
| 9571 | send_resp(dut, conn, SIGMA_ERROR, |
| 9572 | "errorCode,Unsupported sta_set_frame(60G) with the current driver"); |
| 9573 | return 0; |
| 9574 | } |
| 9575 | } |
| 9576 | |
| 9577 | |
Jouni Malinen | f722271 | 2019-06-13 01:50:21 +0300 | [diff] [blame] | 9578 | enum sigma_cmd_result cmd_ap_send_frame(struct sigma_dut *dut, |
| 9579 | struct sigma_conn *conn, |
| 9580 | struct sigma_cmd *cmd) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9581 | { |
| 9582 | /* const char *name = get_param(cmd, "NAME"); */ |
| 9583 | /* const char *ifname = get_param(cmd, "INTERFACE"); */ |
| 9584 | const char *val; |
| 9585 | enum send_frame_type frame; |
| 9586 | enum send_frame_protection protected; |
| 9587 | char buf[100]; |
| 9588 | |
| 9589 | val = get_param(cmd, "Program"); |
| 9590 | if (val) { |
| 9591 | if (strcasecmp(val, "HS2") == 0 || |
Adil Saeed Musthafa | 33ea287 | 2017-04-10 23:13:24 -0700 | [diff] [blame] | 9592 | strcasecmp(val, "HS2-R2") == 0 || |
| 9593 | strcasecmp(val, "IOTLP") == 0) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9594 | return ap_send_frame_hs2(dut, conn, cmd); |
| 9595 | if (strcasecmp(val, "VHT") == 0) |
| 9596 | return ap_send_frame_vht(dut, conn, cmd); |
priyadharshini gowthaman | a27b5b6 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 9597 | if (strcasecmp(val, "LOC") == 0) |
| 9598 | return ap_send_frame_loc(dut, conn, cmd); |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 9599 | if (strcasecmp(val, "MBO") == 0) |
| 9600 | return ap_send_frame_mbo(dut, conn, cmd); |
Lior David | 0fe101e | 2017-03-09 16:09:50 +0200 | [diff] [blame] | 9601 | if (strcasecmp(val, "60GHz") == 0) |
| 9602 | return ap_send_frame_60g(dut, conn, cmd); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9603 | } |
| 9604 | |
| 9605 | val = get_param(cmd, "PMFFrameType"); |
| 9606 | if (val == NULL) |
| 9607 | val = get_param(cmd, "FrameName"); |
| 9608 | if (val == NULL) |
| 9609 | val = get_param(cmd, "Type"); |
| 9610 | if (val == NULL) |
| 9611 | return -1; |
| 9612 | if (strcasecmp(val, "disassoc") == 0) |
| 9613 | frame = DISASSOC; |
| 9614 | else if (strcasecmp(val, "deauth") == 0) |
| 9615 | frame = DEAUTH; |
| 9616 | else if (strcasecmp(val, "saquery") == 0) |
| 9617 | frame = SAQUERY; |
| 9618 | else { |
| 9619 | send_resp(dut, conn, SIGMA_ERROR, "errorCode,Unsupported " |
| 9620 | "PMFFrameType"); |
| 9621 | return 0; |
| 9622 | } |
| 9623 | |
| 9624 | val = get_param(cmd, "PMFProtected"); |
| 9625 | if (val == NULL) |
| 9626 | val = get_param(cmd, "Protected"); |
| 9627 | if (val == NULL) |
| 9628 | return -1; |
| 9629 | if (strcasecmp(val, "Correct-key") == 0 || |
| 9630 | strcasecmp(val, "CorrectKey") == 0) |
| 9631 | protected = CORRECT_KEY; |
| 9632 | else if (strcasecmp(val, "IncorrectKey") == 0) |
| 9633 | protected = INCORRECT_KEY; |
| 9634 | else if (strcasecmp(val, "Unprotected") == 0) |
| 9635 | protected = UNPROTECTED; |
| 9636 | else { |
| 9637 | send_resp(dut, conn, SIGMA_ERROR, "errorCode,Unsupported " |
| 9638 | "PMFProtected"); |
| 9639 | return 0; |
| 9640 | } |
| 9641 | |
| 9642 | val = get_param(cmd, "stationID"); |
| 9643 | if (val == NULL) |
| 9644 | return -1; |
| 9645 | |
| 9646 | if (protected == INCORRECT_KEY || |
| 9647 | (protected == UNPROTECTED && frame == SAQUERY)) |
| 9648 | return ap_inject_frame(dut, conn, frame, protected, val); |
| 9649 | |
| 9650 | switch (frame) { |
| 9651 | case DISASSOC: |
| 9652 | snprintf(buf, sizeof(buf), "disassoc %s test=%d", |
| 9653 | val, protected == CORRECT_KEY); |
| 9654 | break; |
| 9655 | case DEAUTH: |
| 9656 | snprintf(buf, sizeof(buf), "deauth %s test=%d", |
| 9657 | val, protected == CORRECT_KEY); |
| 9658 | break; |
| 9659 | case SAQUERY: |
| 9660 | snprintf(buf, sizeof(buf), "sa_query %s", val); |
| 9661 | break; |
| 9662 | } |
| 9663 | |
| 9664 | if (run_hostapd_cli(dut, buf) != 0) |
| 9665 | return -2; |
| 9666 | |
| 9667 | return 1; |
| 9668 | } |
| 9669 | |
| 9670 | |
Jouni Malinen | f722271 | 2019-06-13 01:50:21 +0300 | [diff] [blame] | 9671 | static enum sigma_cmd_result cmd_ap_get_mac_address(struct sigma_dut *dut, |
| 9672 | struct sigma_conn *conn, |
| 9673 | struct sigma_cmd *cmd) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9674 | { |
| 9675 | #if defined( __linux__) |
| 9676 | /* const char *name = get_param(cmd, "NAME"); */ |
| 9677 | /* const char *ifname = get_param(cmd, "INTERFACE"); */ |
Jouni Malinen | f898464 | 2017-10-12 00:02:37 +0300 | [diff] [blame] | 9678 | char resp[100]; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9679 | unsigned char addr[6]; |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 9680 | char ifname[50]; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9681 | struct ifreq ifr; |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 9682 | int s, wlan_tag = 1; |
| 9683 | const char *val; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9684 | |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 9685 | val = get_param(cmd, "WLAN_TAG"); |
| 9686 | if (val) { |
| 9687 | wlan_tag = atoi(val); |
| 9688 | if (wlan_tag < 1 || wlan_tag > 3) { |
| 9689 | /* |
| 9690 | * The only valid WLAN Tags as of now as per the latest |
| 9691 | * WFA scripts are 1, 2, and 3. |
| 9692 | */ |
Jouni Malinen | f898464 | 2017-10-12 00:02:37 +0300 | [diff] [blame] | 9693 | send_resp(dut, conn, SIGMA_ERROR, |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 9694 | "errorCode,Unsupported WLAN_TAG"); |
| 9695 | return 0; |
| 9696 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9697 | } |
| 9698 | |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 9699 | get_if_name(dut, ifname, sizeof(ifname), wlan_tag); |
| 9700 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9701 | s = socket(AF_INET, SOCK_DGRAM, 0); |
| 9702 | if (s < 0) |
| 9703 | return -1; |
| 9704 | memset(&ifr, 0, sizeof(ifr)); |
Peng Xu | b8fc5cc | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 9705 | strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name)); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9706 | if (ioctl(s, SIOCGIFHWADDR, &ifr) < 0) { |
| 9707 | perror("ioctl"); |
| 9708 | close(s); |
Jouni Malinen | f898464 | 2017-10-12 00:02:37 +0300 | [diff] [blame] | 9709 | snprintf(resp, sizeof(resp), |
| 9710 | "errorCode,Could not find interface %s", ifname); |
| 9711 | send_resp(dut, conn, SIGMA_ERROR, resp); |
| 9712 | return 0; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9713 | } |
| 9714 | close(s); |
| 9715 | memcpy(addr, ifr.ifr_hwaddr.sa_data, 6); |
| 9716 | |
| 9717 | snprintf(resp, sizeof(resp), "mac,%02x:%02x:%02x:%02x:%02x:%02x", |
| 9718 | addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]); |
| 9719 | send_resp(dut, conn, SIGMA_COMPLETE, resp); |
| 9720 | return 0; |
| 9721 | #elif defined( __QNXNTO__) |
| 9722 | char resp[50]; |
| 9723 | unsigned char addr[6]; |
| 9724 | |
| 9725 | if (!sigma_main_ifname) { |
| 9726 | send_resp(dut, conn, SIGMA_ERROR, "ifname is null"); |
| 9727 | return 0; |
| 9728 | } |
| 9729 | |
| 9730 | if (get_hwaddr(sigma_main_ifname, addr) != 0) { |
| 9731 | send_resp(dut, conn, SIGMA_ERROR, |
| 9732 | "errorCode,Failed to get address"); |
| 9733 | return 0; |
| 9734 | } |
| 9735 | snprintf(resp, sizeof(resp), "mac,%02x:%02x:%02x:%02x:%02x:%02x", |
| 9736 | addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]); |
| 9737 | send_resp(dut, conn, SIGMA_COMPLETE, resp); |
| 9738 | return 0; |
| 9739 | #else /* __linux__ */ |
| 9740 | send_resp(dut, conn, SIGMA_ERROR, "errorCode,ap_get_mac_address not " |
| 9741 | "yet supported"); |
| 9742 | return 0; |
| 9743 | #endif /* __linux__ */ |
| 9744 | } |
| 9745 | |
| 9746 | |
Ankita Bajaj | 0d5825b | 2017-10-25 16:20:17 +0530 | [diff] [blame] | 9747 | int sta_cfon_get_mac_address(struct sigma_dut *dut, struct sigma_conn *conn, |
| 9748 | struct sigma_cmd *cmd) |
| 9749 | { |
| 9750 | return cmd_ap_get_mac_address(dut, conn, cmd); |
| 9751 | } |
| 9752 | |
| 9753 | |
Jouni Malinen | f722271 | 2019-06-13 01:50:21 +0300 | [diff] [blame] | 9754 | static enum sigma_cmd_result cmd_ap_set_pmf(struct sigma_dut *dut, |
| 9755 | struct sigma_conn *conn, |
| 9756 | struct sigma_cmd *cmd) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9757 | { |
| 9758 | /* |
| 9759 | * Ignore the command since the parameters are already handled through |
| 9760 | * ap_set_security. |
| 9761 | */ |
| 9762 | |
| 9763 | return 1; |
| 9764 | } |
| 9765 | |
| 9766 | |
Jouni Malinen | f722271 | 2019-06-13 01:50:21 +0300 | [diff] [blame] | 9767 | static enum sigma_cmd_result cmd_ap_set_hs2(struct sigma_dut *dut, |
| 9768 | struct sigma_conn *conn, |
| 9769 | struct sigma_cmd *cmd) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9770 | { |
| 9771 | /* const char *name = get_param(cmd, "NAME"); */ |
| 9772 | /* const char *ifname = get_param(cmd, "INTERFACE"); */ |
| 9773 | const char *val, *dest; |
| 9774 | char *pos, buf[100]; |
| 9775 | int i, wlan_tag = 1; |
| 9776 | |
| 9777 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_set_hs2: Processing the " |
| 9778 | "following parameters"); |
| 9779 | for (i = 0; i < cmd->count; i++) { |
| 9780 | sigma_dut_print(dut, DUT_MSG_INFO, "%s %s", cmd->params[i], |
| 9781 | (cmd->values[i] ? cmd->values[i] : "NULL")); |
| 9782 | } |
| 9783 | |
| 9784 | val = get_param(cmd, "ICMPv4_ECHO"); |
| 9785 | if (val && atoi(val)) { |
| 9786 | snprintf(buf, sizeof(buf), "ebtables -F"); |
| 9787 | if (system(buf) != 0) { |
| 9788 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 9789 | "Failed to set ebtables rules, RULE-12"); |
| 9790 | } |
| 9791 | return 1; |
| 9792 | } |
| 9793 | |
| 9794 | val = get_param(cmd, "WLAN_TAG"); |
| 9795 | if (val) { |
| 9796 | wlan_tag = atoi(val); |
| 9797 | if (wlan_tag != 1 && wlan_tag != 2) { |
| 9798 | send_resp(dut, conn, SIGMA_INVALID, |
| 9799 | "errorCode,Invalid WLAN_TAG"); |
| 9800 | return 0; |
| 9801 | } |
| 9802 | } |
| 9803 | |
| 9804 | if (wlan_tag == 2) { |
| 9805 | val = get_param(cmd, "PROXY_ARP"); |
| 9806 | if (val) |
| 9807 | dut->ap2_proxy_arp = atoi(val); |
Jouni Malinen | dbbc2c4 | 2018-11-14 23:55:41 +0200 | [diff] [blame] | 9808 | |
| 9809 | val = get_param(cmd, "OSU"); |
| 9810 | if (val) |
| 9811 | dut->ap2_osu = atoi(val); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9812 | return 1; |
| 9813 | } |
| 9814 | |
| 9815 | dest = get_param(cmd, "STA_MAC"); |
| 9816 | if (dest) { |
| 9817 | /* This is a special/ugly way of using this command. |
| 9818 | * If "Dest" MAC is included, assume that this command |
| 9819 | * is being issued after ap_config_commit for dynamically |
| 9820 | * setting the QoS Map Set. |
| 9821 | */ |
| 9822 | val = get_param(cmd, "QoS_MAP_SET"); |
| 9823 | if (val) { |
| 9824 | dut->ap_qos_map_set = atoi(val); |
| 9825 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_qos_map_set %d", |
| 9826 | dut->ap_qos_map_set); |
| 9827 | } |
| 9828 | |
| 9829 | if (dut->ap_qos_map_set == 1) |
| 9830 | run_hostapd_cli(dut, "set_qos_map_set " QOS_MAP_SET_1); |
| 9831 | else if (dut->ap_qos_map_set == 2) |
| 9832 | run_hostapd_cli(dut, "set_qos_map_set " QOS_MAP_SET_2); |
| 9833 | |
| 9834 | snprintf(buf, sizeof(buf), "send_qos_map_conf %s", dest); |
| 9835 | if (run_hostapd_cli(dut, buf) != 0) |
| 9836 | return -1; |
| 9837 | } |
| 9838 | |
| 9839 | val = get_param(cmd, "DGAF_DISABLE"); |
| 9840 | if (val) |
| 9841 | dut->ap_dgaf_disable = atoi(val); |
| 9842 | |
| 9843 | dut->ap_interworking = 1; |
| 9844 | |
| 9845 | val = get_param(cmd, "INTERWORKING"); |
| 9846 | if (val == NULL) |
| 9847 | val = get_param(cmd, "INTERNETWORKING"); |
| 9848 | if (val != NULL && atoi(val) == 0) { |
| 9849 | dut->ap_interworking = 0; |
| 9850 | dut->ap_hs2 = 0; |
| 9851 | return 1; |
| 9852 | } |
| 9853 | |
| 9854 | val = get_param(cmd, "ACCS_NET_TYPE"); |
| 9855 | if (val) { |
| 9856 | if (strcasecmp(val, "Chargeable_Public_Network") == 0 || |
| 9857 | strcasecmp(val, "Chargable_Public_Network") == 0 || |
| 9858 | strcasecmp(val, "Chargable Public Network") == 0) |
| 9859 | dut->ap_access_net_type = 2; |
| 9860 | else |
| 9861 | dut->ap_access_net_type = atoi(val); |
| 9862 | } |
| 9863 | |
| 9864 | val = get_param(cmd, "INTERNET"); |
| 9865 | if (val) |
| 9866 | dut->ap_internet = atoi(val); |
| 9867 | |
| 9868 | val = get_param(cmd, "VENUE_GRP"); |
| 9869 | if (val) { |
| 9870 | if (strcasecmp(val, "Business") == 0) |
| 9871 | dut->ap_venue_group = 2; |
| 9872 | else |
| 9873 | dut->ap_venue_group = atoi(val); |
| 9874 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_venue_name %d", |
| 9875 | dut->ap_venue_name); |
| 9876 | } |
| 9877 | |
| 9878 | val = get_param(cmd, "VENUE_TYPE"); |
| 9879 | if (val) { |
| 9880 | if (strcasecmp(val, "R&D") == 0) |
| 9881 | dut->ap_venue_type = 8; |
| 9882 | else |
| 9883 | dut->ap_venue_type = atoi(val); |
| 9884 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_venue_type %d", |
| 9885 | dut->ap_venue_type); |
| 9886 | } |
| 9887 | |
| 9888 | val = get_param(cmd, "HESSID"); |
| 9889 | if (val) { |
| 9890 | if (strlen(val) >= sizeof(dut->ap_hessid)) { |
| 9891 | send_resp(dut, conn, SIGMA_ERROR, |
| 9892 | "errorCode,Invalid HESSID"); |
| 9893 | return 0; |
| 9894 | } |
| 9895 | snprintf(dut->ap_hessid, sizeof(dut->ap_hessid), "%s", val); |
| 9896 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_hessid %s", |
| 9897 | dut->ap_hessid); |
| 9898 | } |
| 9899 | |
| 9900 | val = get_param(cmd, "ROAMING_CONS"); |
| 9901 | if (val) { |
| 9902 | if (strlen(val) >= sizeof(dut->ap_roaming_cons)) { |
| 9903 | send_resp(dut, conn, SIGMA_ERROR, |
| 9904 | "errorCode,Invalid ROAMING_CONS"); |
| 9905 | return 0; |
| 9906 | } |
| 9907 | if (strcasecmp(val, "Disabled") == 0) { |
| 9908 | dut->ap_roaming_cons[0] = '\0'; |
| 9909 | } else { |
| 9910 | snprintf(dut->ap_roaming_cons, |
| 9911 | sizeof(dut->ap_roaming_cons), "%s", val); |
| 9912 | } |
| 9913 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_roaming_cons %s", |
| 9914 | dut->ap_roaming_cons); |
| 9915 | } |
| 9916 | |
| 9917 | val = get_param(cmd, "ANQP"); |
| 9918 | if (val) |
| 9919 | dut->ap_anqpserver_on = atoi(val); |
| 9920 | |
| 9921 | val = get_param(cmd, "NAI_REALM_LIST"); |
| 9922 | if (val) { |
| 9923 | dut->ap_nai_realm_list = atoi(val); |
| 9924 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_nai_realm_list %d", |
| 9925 | dut->ap_nai_realm_list); |
| 9926 | } |
| 9927 | |
| 9928 | val = get_param(cmd, "3GPP_INFO"); |
| 9929 | if (val) { |
| 9930 | /* What kind of encoding format is used?! */ |
| 9931 | send_resp(dut, conn, SIGMA_ERROR, "errorCode,3GPP_INFO " |
| 9932 | "not yet supported (contents not fully defined)"); |
| 9933 | return 0; |
| 9934 | } |
| 9935 | |
| 9936 | val = get_param(cmd, "DOMAIN_LIST"); |
| 9937 | if (val) { |
| 9938 | if (strlen(val) >= sizeof(dut->ap_domain_name_list)) { |
| 9939 | send_resp(dut, conn, SIGMA_ERROR, "errorCode,Too long " |
| 9940 | "DOMAIN_LIST"); |
| 9941 | return 0; |
| 9942 | } |
| 9943 | snprintf(dut->ap_domain_name_list, |
| 9944 | sizeof(dut->ap_domain_name_list), "%s", val); |
| 9945 | pos = dut->ap_domain_name_list; |
| 9946 | while (*pos) { |
| 9947 | if (*pos == ';') |
| 9948 | *pos = ','; |
| 9949 | pos++; |
| 9950 | } |
| 9951 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_domain_name_list %s", |
| 9952 | dut->ap_domain_name_list); |
| 9953 | } |
| 9954 | |
| 9955 | val = get_param(cmd, "OPER_NAME"); |
| 9956 | if (val) { |
| 9957 | dut->ap_oper_name = atoi(val); |
| 9958 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_oper_name %d", |
| 9959 | dut->ap_oper_name); |
| 9960 | } |
| 9961 | |
| 9962 | val = get_param(cmd, "VENUE_NAME"); |
| 9963 | if (val) { |
| 9964 | dut->ap_venue_name = atoi(val); |
| 9965 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_venue_name %d", |
| 9966 | dut->ap_venue_name); |
| 9967 | } |
| 9968 | |
| 9969 | val = get_param(cmd, "GAS_CB_DELAY"); |
| 9970 | if (val) { |
| 9971 | dut->ap_gas_cb_delay = atoi(val); |
| 9972 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_gas_cb_delay %d", |
| 9973 | dut->ap_gas_cb_delay); |
| 9974 | } |
| 9975 | |
| 9976 | val = get_param(cmd, "MIH"); |
| 9977 | if (val && atoi(val) > 0) { |
| 9978 | send_resp(dut, conn, SIGMA_ERROR, "errorCode,MIH not " |
| 9979 | "supported"); |
| 9980 | return 0; |
| 9981 | } |
| 9982 | |
| 9983 | val = get_param(cmd, "L2_TRAFFIC_INSPECT"); |
| 9984 | if (val) { |
| 9985 | dut->ap_l2tif = atoi(val); |
| 9986 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_l2tif %d", |
| 9987 | dut->ap_l2tif); |
| 9988 | } |
| 9989 | |
| 9990 | val = get_param(cmd, "BCST_UNCST"); |
| 9991 | if (val) { |
| 9992 | send_resp(dut, conn, SIGMA_ERROR, |
| 9993 | "errorCode,BCST_UNCST not yet supported"); |
| 9994 | return 0; |
| 9995 | } |
| 9996 | |
| 9997 | val = get_param(cmd, "PLMN_MCC"); |
| 9998 | if (val) { |
| 9999 | char mcc[100], *start, *end; |
| 10000 | int i = 0; |
| 10001 | if (strlen(val) >= sizeof(mcc)) { |
| 10002 | send_resp(dut, conn, SIGMA_ERROR, |
| 10003 | "errorCode,PLMN_MCC too long"); |
| 10004 | return 0; |
| 10005 | } |
Peng Xu | b8fc5cc | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 10006 | strlcpy(mcc, val, sizeof(mcc)); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 10007 | start = mcc; |
| 10008 | while ((end = strchr(start, ';'))) { |
| 10009 | /* process all except the last */ |
| 10010 | *end = '\0'; |
| 10011 | if (strlen(start) != 3) { |
| 10012 | send_resp(dut, conn, SIGMA_ERROR, |
| 10013 | "errorCode,Invalid PLMN_MCC"); |
| 10014 | return 0; |
| 10015 | } |
| 10016 | snprintf(dut->ap_plmn_mcc[i], |
| 10017 | sizeof(dut->ap_plmn_mcc[i]), "%s", start); |
| 10018 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_plmn_mcc %s", |
| 10019 | dut->ap_plmn_mcc[i]); |
| 10020 | i++; |
| 10021 | start = end + 1; |
| 10022 | *end = ';'; |
| 10023 | } |
| 10024 | if (strlen(start) != 3) { |
| 10025 | send_resp(dut, conn, SIGMA_ERROR, |
| 10026 | "errorCode,Invalid PLMN_MCC"); |
| 10027 | return 0; |
| 10028 | } |
| 10029 | /* process last or only one */ |
| 10030 | snprintf(dut->ap_plmn_mcc[i], |
| 10031 | sizeof(dut->ap_plmn_mcc[i]), "%s", start); |
| 10032 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_plmn_mcc %s", |
| 10033 | dut->ap_plmn_mcc[i]); |
| 10034 | } |
| 10035 | |
| 10036 | val = get_param(cmd, "PLMN_MNC"); |
| 10037 | if (val) { |
| 10038 | char mnc[100], *start, *end; |
| 10039 | int i = 0; |
| 10040 | if (strlen(val) >= sizeof(mnc)) { |
| 10041 | send_resp(dut, conn, SIGMA_ERROR, |
| 10042 | "errorCode,PLMN_MNC too long"); |
| 10043 | return 0; |
| 10044 | } |
Peng Xu | b8fc5cc | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 10045 | strlcpy(mnc, val, sizeof(mnc)); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 10046 | start = mnc; |
| 10047 | while ((end = strchr(start, ';'))) { |
| 10048 | *end = '\0'; |
| 10049 | if (strlen(start) != 2 && strlen(start) != 3) { |
| 10050 | send_resp(dut, conn, SIGMA_ERROR, |
| 10051 | "errorCode,Invalid PLMN_MNC"); |
| 10052 | return 0; |
| 10053 | } |
| 10054 | snprintf(dut->ap_plmn_mnc[i], |
| 10055 | sizeof(dut->ap_plmn_mnc[i]), "%s", start); |
| 10056 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_plmn_mnc %s", |
| 10057 | dut->ap_plmn_mnc[i]); |
| 10058 | i++; |
| 10059 | start = end + 1; |
| 10060 | *end = ';'; |
| 10061 | } |
| 10062 | if (strlen(start) != 2 && strlen(start) != 3) { |
| 10063 | send_resp(dut, conn, SIGMA_ERROR, |
| 10064 | "errorCode,Invalid PLMN_MNC"); |
| 10065 | return 0; |
| 10066 | } |
| 10067 | snprintf(dut->ap_plmn_mnc[i], |
| 10068 | sizeof(dut->ap_plmn_mnc[i]), "%s", start); |
| 10069 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_plmn_mnc %s", |
| 10070 | dut->ap_plmn_mnc[i]); |
| 10071 | } |
| 10072 | |
| 10073 | val = get_param(cmd, "PROXY_ARP"); |
| 10074 | if (val) { |
| 10075 | dut->ap_proxy_arp = atoi(val); |
| 10076 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_proxy_arp %d", |
| 10077 | dut->ap_proxy_arp); |
| 10078 | } |
| 10079 | |
| 10080 | val = get_param(cmd, "WAN_METRICS"); |
| 10081 | if (val) { |
| 10082 | dut->ap_wan_metrics = atoi(val); |
| 10083 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_wan_metrics %d", |
| 10084 | dut->ap_wan_metrics); |
| 10085 | } |
| 10086 | |
| 10087 | val = get_param(cmd, "CONN_CAP"); |
| 10088 | if (val) { |
| 10089 | dut->ap_conn_capab = atoi(val); |
| 10090 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_conn_capab %d", |
| 10091 | dut->ap_conn_capab); |
| 10092 | } |
| 10093 | |
| 10094 | val = get_param(cmd, "IP_ADD_TYPE_AVAIL"); |
| 10095 | if (val) { |
| 10096 | dut->ap_ip_addr_type_avail = atoi(val); |
| 10097 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_ip_addr_type_avail %d", |
| 10098 | dut->ap_ip_addr_type_avail); |
| 10099 | } |
| 10100 | |
| 10101 | val = get_param(cmd, "NET_AUTH_TYPE"); |
| 10102 | if (val) { |
| 10103 | dut->ap_net_auth_type = atoi(val); |
| 10104 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_net_auth_type %d", |
| 10105 | dut->ap_net_auth_type); |
| 10106 | } |
| 10107 | |
| 10108 | val = get_param(cmd, "OP_CLASS"); |
| 10109 | if (val == NULL) |
| 10110 | val = get_param(cmd, "OPER_CLASS"); |
| 10111 | if (val) { |
| 10112 | dut->ap_oper_class = atoi(val); |
| 10113 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_oper_class %d", |
| 10114 | dut->ap_oper_class); |
| 10115 | } |
| 10116 | |
| 10117 | val = get_param(cmd, "OSU_PROVIDER_LIST"); |
| 10118 | if (val) { |
| 10119 | dut->ap_osu_provider_list = atoi(val); |
| 10120 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_osu_provider_list %d", |
| 10121 | dut->ap_osu_provider_list); |
| 10122 | } |
| 10123 | |
Jouni Malinen | 93a837f | 2018-11-01 17:09:22 +0200 | [diff] [blame] | 10124 | val = get_param(cmd, "OSU_PROVIDER_NAI_LIST"); |
| 10125 | if (val) { |
| 10126 | dut->ap_osu_provider_nai_list = atoi(val); |
| 10127 | sigma_dut_print(dut, DUT_MSG_INFO, |
| 10128 | "ap_osu_provider_nai_list %d", |
| 10129 | dut->ap_osu_provider_nai_list); |
| 10130 | } |
| 10131 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 10132 | val = get_param(cmd, "OSU_SERVER_URI"); |
| 10133 | if (val) { |
| 10134 | i = 0; |
| 10135 | do { |
| 10136 | int len; |
| 10137 | const char *uri = val; |
| 10138 | val = strchr(val, ' '); |
| 10139 | len = val ? (val++ - uri) : (int) strlen(uri); |
| 10140 | if (len > 0 && len < 256) { |
| 10141 | memcpy(dut->ap_osu_server_uri[i], uri, len); |
| 10142 | dut->ap_osu_server_uri[i][len] = '\0'; |
| 10143 | sigma_dut_print(dut, DUT_MSG_INFO, |
| 10144 | "ap_osu_server_uri[%d] %s", i, |
| 10145 | dut->ap_osu_server_uri[i]); |
| 10146 | } |
| 10147 | } while (val && ++i < 10); |
| 10148 | } |
| 10149 | |
| 10150 | val = get_param(cmd, "OSU_METHOD"); |
| 10151 | if (val) { |
| 10152 | i = 0; |
| 10153 | do { |
| 10154 | int len; |
| 10155 | const char *method = val; |
| 10156 | val = strchr(val, ' '); |
| 10157 | len = val ? (val++ - method) : (int) strlen(method); |
| 10158 | if (len > 0) { |
| 10159 | if (strncasecmp(method, "SOAP", len) == 0) |
| 10160 | dut->ap_osu_method[i] = 1; |
| 10161 | else if (strncasecmp(method, "OMADM", len) == 0) |
| 10162 | dut->ap_osu_method[i] = 0; |
| 10163 | else |
| 10164 | return -2; |
| 10165 | } |
| 10166 | } while (val && ++i < 10); |
| 10167 | } |
| 10168 | |
| 10169 | val = get_param(cmd, "OSU_SSID"); |
| 10170 | if (val) { |
| 10171 | if (strlen(val) > 0 && strlen(val) <= 32) { |
Peng Xu | b8fc5cc | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 10172 | strlcpy(dut->ap_osu_ssid, val, |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 10173 | sizeof(dut->ap_osu_ssid)); |
| 10174 | sigma_dut_print(dut, DUT_MSG_INFO, |
| 10175 | "ap_osu_ssid %s", |
| 10176 | dut->ap_osu_ssid); |
| 10177 | } |
| 10178 | } |
| 10179 | |
| 10180 | val = get_param(cmd, "OSU_ICON_TAG"); |
| 10181 | if (val) |
| 10182 | dut->ap_osu_icon_tag = atoi(val); |
| 10183 | |
| 10184 | val = get_param(cmd, "QoS_MAP_SET"); |
| 10185 | if (val) { |
| 10186 | dut->ap_qos_map_set = atoi(val); |
| 10187 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_qos_map_set %d", |
| 10188 | dut->ap_qos_map_set); |
| 10189 | } |
| 10190 | |
| 10191 | val = get_param(cmd, "BSS_LOAD"); |
| 10192 | if (val) { |
| 10193 | dut->ap_bss_load = atoi(val); |
| 10194 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_bss_load %d", |
| 10195 | dut->ap_bss_load); |
| 10196 | } |
| 10197 | |
Jouni Malinen | 54a89b0 | 2018-05-01 00:16:26 +0300 | [diff] [blame] | 10198 | val = get_param(cmd, "Venue_URL"); |
| 10199 | if (val) |
| 10200 | dut->ap_venue_url = atoi(val); |
| 10201 | |
Jouni Malinen | f7ff42b | 2018-05-01 00:21:56 +0300 | [diff] [blame] | 10202 | val = get_param(cmd, "Advice_of_Charge"); |
| 10203 | if (val) |
| 10204 | dut->ap_advice_of_charge = atoi(val); |
| 10205 | |
Jouni Malinen | ac10453 | 2018-05-01 00:27:37 +0300 | [diff] [blame] | 10206 | val = get_param(cmd, "Operator_Icon_Metadata"); |
| 10207 | if (val) |
| 10208 | dut->ap_oper_icon_metadata = atoi(val); |
| 10209 | |
Jouni Malinen | ac36714 | 2018-05-01 00:32:24 +0300 | [diff] [blame] | 10210 | val = get_param(cmd, "TnC_File_Name"); |
| 10211 | if (val) |
| 10212 | dut->ap_tnc_file_name = atoi(val); |
| 10213 | |
| 10214 | val = get_param(cmd, "TnC_File_Time_Stamp"); |
| 10215 | if (val) |
| 10216 | dut->ap_tnc_time_stamp = strtol(val, NULL, 10); |
| 10217 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 10218 | return 1; |
| 10219 | } |
| 10220 | |
| 10221 | |
| 10222 | void nfc_status(struct sigma_dut *dut, const char *state, const char *oper) |
| 10223 | { |
| 10224 | char buf[100]; |
| 10225 | |
| 10226 | if (!file_exists("nfc-status")) |
| 10227 | return; |
| 10228 | |
| 10229 | snprintf(buf, sizeof(buf), "./nfc-status %s %s", state, oper); |
| 10230 | run_system(dut, buf); |
| 10231 | } |
| 10232 | |
| 10233 | |
| 10234 | static int run_nfc_command(struct sigma_dut *dut, const char *cmd, |
| 10235 | const char *info) |
| 10236 | { |
| 10237 | int res; |
| 10238 | |
| 10239 | printf("\n\n\n=====[ NFC operation ]=========================\n\n"); |
| 10240 | printf("%s\n\n", info); |
| 10241 | |
| 10242 | nfc_status(dut, "START", info); |
| 10243 | res = run_system(dut, cmd); |
| 10244 | nfc_status(dut, res ? "FAIL" : "SUCCESS", info); |
| 10245 | if (res) { |
| 10246 | sigma_dut_print(dut, DUT_MSG_INFO, "Failed to run '%s': %d", |
| 10247 | cmd, res); |
| 10248 | return res; |
| 10249 | } |
| 10250 | |
| 10251 | return 0; |
| 10252 | } |
| 10253 | |
| 10254 | |
| 10255 | static int ap_nfc_write_config_token(struct sigma_dut *dut, |
| 10256 | struct sigma_conn *conn, |
| 10257 | struct sigma_cmd *cmd) |
| 10258 | { |
| 10259 | int res; |
| 10260 | char buf[300]; |
| 10261 | |
| 10262 | run_system(dut, "killall wps-ap-nfc.py"); |
| 10263 | unlink("nfc-success"); |
| 10264 | snprintf(buf, sizeof(buf), |
| 10265 | "./wps-ap-nfc.py --no-wait %s%s --success nfc-success write-config", |
| 10266 | dut->summary_log ? "--summary " : "", |
| 10267 | dut->summary_log ? dut->summary_log : ""); |
| 10268 | res = run_nfc_command(dut, buf, |
| 10269 | "Touch NFC Tag to write WPS configuration token"); |
| 10270 | if (res || !file_exists("nfc-success")) { |
| 10271 | send_resp(dut, conn, SIGMA_ERROR, |
| 10272 | "ErrorCode,Failed to write tag"); |
| 10273 | return 0; |
| 10274 | } |
| 10275 | |
| 10276 | return 1; |
| 10277 | } |
| 10278 | |
| 10279 | |
| 10280 | static int ap_nfc_wps_read_passwd(struct sigma_dut *dut, |
| 10281 | struct sigma_conn *conn, |
| 10282 | struct sigma_cmd *cmd) |
| 10283 | { |
| 10284 | int res; |
| 10285 | char buf[300]; |
| 10286 | |
| 10287 | run_system(dut, "killall wps-ap-nfc.py"); |
| 10288 | |
| 10289 | unlink("nfc-success"); |
| 10290 | snprintf(buf, sizeof(buf), |
| 10291 | "./wps-ap-nfc.py -1 --no-wait %s%s --success nfc-success", |
| 10292 | dut->summary_log ? "--summary " : "", |
| 10293 | dut->summary_log ? dut->summary_log : ""); |
| 10294 | res = run_nfc_command(dut, buf, "Touch NFC Tag to read it"); |
| 10295 | if (res || !file_exists("nfc-success")) { |
| 10296 | send_resp(dut, conn, SIGMA_ERROR, |
| 10297 | "ErrorCode,Failed to read tag"); |
| 10298 | return 0; |
| 10299 | } |
| 10300 | |
| 10301 | return 1; |
| 10302 | } |
| 10303 | |
| 10304 | |
| 10305 | static int ap_nfc_write_password_token(struct sigma_dut *dut, |
| 10306 | struct sigma_conn *conn, |
| 10307 | struct sigma_cmd *cmd) |
| 10308 | { |
| 10309 | int res; |
| 10310 | char buf[300]; |
| 10311 | |
| 10312 | run_system(dut, "killall wps-ap-nfc.py"); |
| 10313 | unlink("nfc-success"); |
| 10314 | snprintf(buf, sizeof(buf), |
| 10315 | "./wps-ap-nfc.py --no-wait %s%s --success nfc-success write-password", |
| 10316 | dut->summary_log ? "--summary " : "", |
| 10317 | dut->summary_log ? dut->summary_log : ""); |
| 10318 | res = run_nfc_command(dut, buf, |
| 10319 | "Touch NFC Tag to write WPS password token"); |
| 10320 | if (res || !file_exists("nfc-success")) { |
| 10321 | send_resp(dut, conn, SIGMA_ERROR, |
| 10322 | "ErrorCode,Failed to write tag"); |
| 10323 | return 0; |
| 10324 | } |
| 10325 | |
| 10326 | if (run_hostapd_cli(dut, "wps_nfc_token enable") != 0) { |
| 10327 | send_resp(dut, conn, SIGMA_ERROR, |
| 10328 | "ErrorCode,Failed to enable NFC password token"); |
| 10329 | return 0; |
| 10330 | } |
| 10331 | |
| 10332 | return 1; |
| 10333 | } |
| 10334 | |
| 10335 | |
| 10336 | static int ap_nfc_wps_connection_handover(struct sigma_dut *dut, |
| 10337 | struct sigma_conn *conn, |
| 10338 | struct sigma_cmd *cmd) |
| 10339 | { |
| 10340 | int res; |
| 10341 | char buf[300]; |
| 10342 | |
| 10343 | run_system(dut, "killall wps-ap-nfc.py"); |
| 10344 | unlink("nfc-success"); |
| 10345 | snprintf(buf, sizeof(buf), |
| 10346 | "./wps-ap-nfc.py -1 --no-wait %s%s --success nfc-success", |
| 10347 | dut->summary_log ? "--summary " : "", |
| 10348 | dut->summary_log ? dut->summary_log : ""); |
| 10349 | res = run_nfc_command(dut, buf, |
| 10350 | "Touch NFC Device to respond to WPS connection handover"); |
| 10351 | if (res) { |
| 10352 | send_resp(dut, conn, SIGMA_ERROR, |
| 10353 | "ErrorCode,Failed to enable NFC for connection " |
| 10354 | "handover"); |
| 10355 | return 0; |
| 10356 | } |
| 10357 | if (!file_exists("nfc-success")) { |
| 10358 | send_resp(dut, conn, SIGMA_ERROR, |
| 10359 | "ErrorCode,Failed to complete NFC connection handover"); |
| 10360 | return 0; |
| 10361 | } |
| 10362 | |
| 10363 | return 1; |
| 10364 | } |
| 10365 | |
| 10366 | |
Jouni Malinen | f722271 | 2019-06-13 01:50:21 +0300 | [diff] [blame] | 10367 | static enum sigma_cmd_result cmd_ap_nfc_action(struct sigma_dut *dut, |
| 10368 | struct sigma_conn *conn, |
| 10369 | struct sigma_cmd *cmd) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 10370 | { |
| 10371 | /* const char *name = get_param(cmd, "Name"); */ |
| 10372 | /* const char *intf = get_param(cmd, "Interface"); */ |
| 10373 | const char *oper = get_param(cmd, "Operation"); |
| 10374 | |
| 10375 | if (oper == NULL) |
| 10376 | return -1; |
| 10377 | |
| 10378 | if (strcasecmp(oper, "WRITE_CONFIG") == 0) |
| 10379 | return ap_nfc_write_config_token(dut, conn, cmd); |
| 10380 | if (strcasecmp(oper, "WRITE_PASSWD") == 0) |
| 10381 | return ap_nfc_write_password_token(dut, conn, cmd); |
| 10382 | if (strcasecmp(oper, "WPS_READ_PASSWD") == 0) |
| 10383 | return ap_nfc_wps_read_passwd(dut, conn, cmd); |
| 10384 | if (strcasecmp(oper, "WPS_CONN_HNDOVR") == 0) |
| 10385 | return ap_nfc_wps_connection_handover(dut, conn, cmd); |
| 10386 | |
| 10387 | send_resp(dut, conn, SIGMA_ERROR, "ErrorCode,Unsupported operation"); |
| 10388 | return 0; |
| 10389 | } |
| 10390 | |
| 10391 | |
Jouni Malinen | f722271 | 2019-06-13 01:50:21 +0300 | [diff] [blame] | 10392 | static enum sigma_cmd_result cmd_ap_wps_read_pin(struct sigma_dut *dut, |
| 10393 | struct sigma_conn *conn, |
| 10394 | struct sigma_cmd *cmd) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 10395 | { |
| 10396 | char *pin = "12345670"; /* TODO: use random PIN */ |
| 10397 | char resp[100]; |
| 10398 | |
| 10399 | snprintf(resp, sizeof(resp), "PIN,%s", pin); |
| 10400 | send_resp(dut, conn, SIGMA_COMPLETE, resp); |
| 10401 | |
| 10402 | return 0; |
| 10403 | } |
| 10404 | |
| 10405 | |
Jouni Malinen | f722271 | 2019-06-13 01:50:21 +0300 | [diff] [blame] | 10406 | static enum sigma_cmd_result cmd_ap_wps_enter_pin(struct sigma_dut *dut, |
| 10407 | struct sigma_conn *conn, |
| 10408 | struct sigma_cmd *cmd) |
Alexei Avshalom Lazar | 6427969 | 2018-12-23 16:49:49 +0200 | [diff] [blame] | 10409 | { |
| 10410 | const char *pin = get_param(cmd, "PIN"); |
| 10411 | char wps_pin[11]; |
| 10412 | |
| 10413 | if (!pin) |
| 10414 | return -1; |
| 10415 | |
| 10416 | sigma_dut_print(dut, DUT_MSG_DEBUG, |
| 10417 | "Authorize a client to join with WPS PIN %s", pin); |
| 10418 | |
| 10419 | strlcpy(wps_pin, pin, sizeof(wps_pin)); |
| 10420 | /* we need to tolerate extra '-' characters entered */ |
| 10421 | str_remove_chars(wps_pin, '-'); |
| 10422 | strlcpy(dut->wps_pin, wps_pin, sizeof(dut->wps_pin)); |
| 10423 | dut->wps_method = WFA_CS_WPS_PIN_KEYPAD; |
| 10424 | |
| 10425 | return 1; |
| 10426 | } |
| 10427 | |
| 10428 | |
Jouni Malinen | f722271 | 2019-06-13 01:50:21 +0300 | [diff] [blame] | 10429 | static enum sigma_cmd_result cmd_ap_wps_set_pbc(struct sigma_dut *dut, |
| 10430 | struct sigma_conn *conn, |
| 10431 | struct sigma_cmd *cmd) |
Alexei Avshalom Lazar | 6427969 | 2018-12-23 16:49:49 +0200 | [diff] [blame] | 10432 | { |
| 10433 | sigma_dut_print(dut, DUT_MSG_DEBUG, |
| 10434 | "Selecting the push button configuration method"); |
| 10435 | |
| 10436 | dut->wps_method = WFA_CS_WPS_PBC; |
| 10437 | |
| 10438 | return 1; |
| 10439 | } |
| 10440 | |
| 10441 | |
Alexei Avshalom Lazar | 043230b | 2019-02-04 14:11:24 +0200 | [diff] [blame] | 10442 | int ap_wps_registration(struct sigma_dut *dut, struct sigma_conn *conn, |
| 10443 | struct sigma_cmd *cmd) |
| 10444 | { |
| 10445 | char buf[100], resp[256]; |
| 10446 | const char *intf = get_param(cmd, "interface"); |
| 10447 | const char *config_method = get_param(cmd, "WPSConfigMethod"); |
| 10448 | |
| 10449 | if (config_method && strcasecmp(config_method, "PBC") == 0) |
| 10450 | dut->wps_method = WFA_CS_WPS_PBC; |
| 10451 | |
| 10452 | if (!intf) |
| 10453 | intf = get_main_ifname(); |
| 10454 | |
| 10455 | if (dut->wps_method == WFA_CS_WPS_NOT_READY) { |
| 10456 | send_resp(dut, conn, SIGMA_ERROR, |
| 10457 | "ErrorCode,WPS parameters not yet set"); |
| 10458 | return STATUS_SENT; |
| 10459 | } |
| 10460 | |
| 10461 | if (dut->wps_method == WFA_CS_WPS_PBC) |
| 10462 | snprintf(buf, sizeof(buf), "WPS_PBC"); |
| 10463 | else /* WFA_CS_WPS_PIN_KEYPAD */ |
| 10464 | snprintf(buf, sizeof(buf), "WPS_PIN any %s", dut->wps_pin); |
| 10465 | |
| 10466 | /* Run WPS command */ |
| 10467 | if (hapd_command(intf, buf) < 0) { |
| 10468 | /* command fails immediately if overlapped session detected */ |
| 10469 | snprintf(resp, sizeof(resp), "WpsState,OverlapSession"); |
| 10470 | send_resp(dut, conn, SIGMA_COMPLETE, resp); |
| 10471 | return STATUS_SENT; |
| 10472 | } |
| 10473 | |
| 10474 | /* In AP mode return immediately and do not wait for WPS registration */ |
| 10475 | return SUCCESS_SEND_STATUS; |
| 10476 | } |
| 10477 | |
| 10478 | |
Jouni Malinen | f722271 | 2019-06-13 01:50:21 +0300 | [diff] [blame] | 10479 | static enum sigma_cmd_result cmd_ap_get_parameter(struct sigma_dut *dut, |
| 10480 | struct sigma_conn *conn, |
| 10481 | struct sigma_cmd *cmd) |
Alexei Avshalom Lazar | 0c1d82d | 2018-12-23 17:02:42 +0200 | [diff] [blame] | 10482 | { |
| 10483 | char value[256], resp[512]; |
| 10484 | const char *param = get_param(cmd, "parameter"); |
| 10485 | const char *ifname = get_param(cmd, "Interface"); |
| 10486 | |
| 10487 | if (!ifname) |
| 10488 | ifname = get_main_ifname(); |
| 10489 | |
| 10490 | if (!param) { |
| 10491 | send_resp(dut, conn, SIGMA_ERROR, |
| 10492 | "ErrorCode,Parameter not specified"); |
| 10493 | return 0; |
| 10494 | } |
| 10495 | |
| 10496 | if (strcasecmp(param, "SSID") == 0) { |
| 10497 | if (get_hapd_config(ifname, "ssid", value, sizeof(value))) { |
| 10498 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 10499 | "Failed to get SSID"); |
| 10500 | return -2; |
| 10501 | } |
| 10502 | snprintf(resp, sizeof(resp), "SSID,%s", value); |
| 10503 | } else if (strcasecmp(param, "PSK") == 0) { |
| 10504 | if (get_hapd_config(ifname, "passphrase", value, |
| 10505 | sizeof(value))) { |
| 10506 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 10507 | "Failed to get PSK"); |
| 10508 | return -2; |
| 10509 | } |
| 10510 | snprintf(resp, sizeof(resp), "PSK,%s", value); |
| 10511 | } else { |
| 10512 | send_resp(dut, conn, SIGMA_ERROR, |
| 10513 | "ErrorCode,Unsupported parameter"); |
| 10514 | return 0; |
| 10515 | } |
| 10516 | |
| 10517 | send_resp(dut, conn, SIGMA_COMPLETE, resp); |
| 10518 | return 0; |
| 10519 | } |
| 10520 | |
| 10521 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 10522 | static int ath_vht_op_mode_notif(struct sigma_dut *dut, const char *ifname, |
| 10523 | const char *val) |
| 10524 | { |
| 10525 | char *token, *result; |
| 10526 | int nss = 0, chwidth = 0; |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 10527 | char *saveptr; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 10528 | |
| 10529 | /* |
| 10530 | * The following commands should be invoked to generate |
| 10531 | * VHT op mode notification |
| 10532 | */ |
| 10533 | |
| 10534 | /* Extract the NSS info */ |
| 10535 | token = strdup(val); |
| 10536 | if (!token) |
| 10537 | return -1; |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 10538 | result = strtok_r(token, ";", &saveptr); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 10539 | if (result) { |
| 10540 | int count = atoi(result); |
| 10541 | |
| 10542 | /* We do not support NSS > 3 */ |
| 10543 | if (count < 0 || count > 3) { |
| 10544 | free(token); |
| 10545 | return -1; |
| 10546 | } |
| 10547 | |
| 10548 | /* Convert nss to chainmask */ |
| 10549 | while (count--) |
| 10550 | nss = (nss << 1) | 1; |
| 10551 | |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 10552 | run_iwpriv(dut, ifname, "rxchainmask %d", nss); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 10553 | } |
| 10554 | |
| 10555 | /* Extract the Channel width info */ |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 10556 | result = strtok_r(NULL, ";", &saveptr); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 10557 | if (result) { |
| 10558 | switch (atoi(result)) { |
| 10559 | case 20: |
| 10560 | chwidth = 0; |
| 10561 | break; |
| 10562 | case 40: |
| 10563 | chwidth = 1; |
| 10564 | break; |
| 10565 | case 80: |
| 10566 | chwidth = 2; |
| 10567 | break; |
| 10568 | case 160: |
| 10569 | chwidth = 3; |
| 10570 | break; |
| 10571 | default: |
| 10572 | chwidth = 2; |
| 10573 | break; |
| 10574 | } |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 10575 | run_iwpriv(dut, ifname, "chwidth %d", chwidth); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 10576 | } |
| 10577 | |
| 10578 | /* Send the opmode notification */ |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 10579 | run_iwpriv(dut, ifname, "opmode_notify 1"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 10580 | free(token); |
| 10581 | |
| 10582 | return 0; |
| 10583 | } |
| 10584 | |
| 10585 | |
| 10586 | static int ath_vht_nss_mcs(struct sigma_dut *dut, const char *ifname, |
| 10587 | const char *val) |
| 10588 | { |
| 10589 | /* String (nss_operating_mode; mcs_operating_mode) */ |
| 10590 | int nss, mcs; |
| 10591 | char *token, *result; |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 10592 | char *saveptr; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 10593 | |
| 10594 | token = strdup(val); |
| 10595 | if (!token) |
| 10596 | return -1; |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 10597 | result = strtok_r(token, ";", &saveptr); |
Pradeep Reddy POTTETI | 41b8c54 | 2016-06-15 16:09:46 +0530 | [diff] [blame] | 10598 | if (!result) { |
| 10599 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 10600 | "VHT NSS not specified"); |
| 10601 | goto end; |
| 10602 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 10603 | if (strcasecmp(result, "def") != 0) { |
| 10604 | nss = atoi(result); |
| 10605 | |
| 10606 | if (nss == 4) |
| 10607 | ath_disable_txbf(dut, ifname); |
| 10608 | |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 10609 | run_iwpriv(dut, ifname, "nss %d", nss); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 10610 | } else { |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 10611 | if (dut->device_type == AP_testbed && dut->ap_sgi80 == 1) |
| 10612 | run_iwpriv(dut, ifname, "nss 1"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 10613 | } |
| 10614 | |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 10615 | result = strtok_r(NULL, ";", &saveptr); |
Pradeep Reddy POTTETI | 41b8c54 | 2016-06-15 16:09:46 +0530 | [diff] [blame] | 10616 | if (!result) { |
| 10617 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 10618 | "VHT MCS not specified"); |
| 10619 | goto end; |
| 10620 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 10621 | if (strcasecmp(result, "def") == 0) { |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 10622 | if (dut->device_type == AP_testbed && dut->ap_sgi80 == 1) |
| 10623 | run_iwpriv(dut, ifname, "vhtmcs 7"); |
| 10624 | else |
| 10625 | run_iwpriv(dut, ifname, "set11NRates 0"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 10626 | } else { |
| 10627 | mcs = atoi(result); |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 10628 | run_iwpriv(dut, ifname, "vhtmcs %d", mcs); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 10629 | } |
| 10630 | |
Pradeep Reddy POTTETI | 41b8c54 | 2016-06-15 16:09:46 +0530 | [diff] [blame] | 10631 | end: |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 10632 | free(token); |
| 10633 | return 0; |
| 10634 | } |
| 10635 | |
| 10636 | |
| 10637 | static int ath_vht_chnum_band(struct sigma_dut *dut, const char *ifname, |
| 10638 | const char *val) |
| 10639 | { |
| 10640 | char *token, *result; |
| 10641 | int channel = 36; |
| 10642 | int chwidth = 80; |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 10643 | char *saveptr; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 10644 | |
| 10645 | /* Extract the channel info */ |
| 10646 | token = strdup(val); |
| 10647 | if (!token) |
| 10648 | return -1; |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 10649 | result = strtok_r(token, ";", &saveptr); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 10650 | if (result) |
| 10651 | channel = atoi(result); |
| 10652 | |
| 10653 | /* Extract the channel width info */ |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 10654 | result = strtok_r(NULL, ";", &saveptr); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 10655 | if (result) |
| 10656 | chwidth = atoi(result); |
| 10657 | |
| 10658 | /* Issue the channel switch command */ |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 10659 | run_iwpriv(dut, ifname, "doth_ch_chwidth %d 10 %d", channel, chwidth); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 10660 | |
| 10661 | free(token); |
| 10662 | return 0; |
| 10663 | } |
| 10664 | |
| 10665 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 10666 | static int ath_ndpa_stainfo_mac(struct sigma_dut *dut, const char *ifname, |
| 10667 | const char *val) |
| 10668 | { |
| 10669 | char buf[80]; |
| 10670 | unsigned char mac_addr[6]; |
| 10671 | |
| 10672 | if (parse_mac_address(dut, val, mac_addr) < 0) |
| 10673 | return -1; |
| 10674 | |
| 10675 | snprintf(buf, sizeof(buf), |
| 10676 | "wifitool %s beeliner_fw_test 92 0x%02x%02x%02x%02x", |
| 10677 | ifname, mac_addr[0], mac_addr[1], mac_addr[2], mac_addr[3]); |
| 10678 | run_system(dut, buf); |
| 10679 | |
| 10680 | snprintf(buf, sizeof(buf), "wifitool %s beeliner_fw_test 93 0x%02x%02x", |
| 10681 | ifname, mac_addr[4], mac_addr[5]); |
| 10682 | run_system(dut, buf); |
| 10683 | |
| 10684 | snprintf(buf, sizeof(buf), "wifitool %s beeliner_fw_test 94 1", ifname); |
| 10685 | run_system(dut, buf); |
| 10686 | |
| 10687 | return 0; |
| 10688 | } |
| 10689 | |
| 10690 | |
Priyadharshini Gowthaman | 8c5b9a4 | 2019-07-31 14:38:48 -0700 | [diff] [blame] | 10691 | void novap_reset(struct sigma_dut *dut, const char *ifname, int reset) |
Priyadharshini Gowthaman | 39beafa | 2015-11-09 14:11:25 -0800 | [diff] [blame] | 10692 | { |
Priyadharshini Gowthaman | 8c5b9a4 | 2019-07-31 14:38:48 -0700 | [diff] [blame] | 10693 | run_iwpriv(dut, ifname, "novap_reset %d", reset); |
Priyadharshini Gowthaman | 39beafa | 2015-11-09 14:11:25 -0800 | [diff] [blame] | 10694 | } |
| 10695 | |
| 10696 | |
Jouni Malinen | b433543 | 2019-06-13 02:23:57 +0300 | [diff] [blame] | 10697 | static struct mbo_pref_ap * mbo_find_nebor_ap_entry(struct sigma_dut *dut, |
| 10698 | const uint8_t *mac_addr) |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 10699 | { |
Adil Saeed Musthafa | 6906372 | 2017-04-10 23:13:40 -0700 | [diff] [blame] | 10700 | int i; |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 10701 | |
Adil Saeed Musthafa | 6906372 | 2017-04-10 23:13:40 -0700 | [diff] [blame] | 10702 | for (i = 0; i < dut->mbo_pref_ap_cnt; i++) { |
| 10703 | if (memcmp(mac_addr, dut->mbo_pref_aps[i].mac_addr, |
| 10704 | ETH_ALEN) == 0) |
| 10705 | return &dut->mbo_pref_aps[i]; |
| 10706 | } |
| 10707 | return NULL; |
| 10708 | } |
| 10709 | |
| 10710 | |
| 10711 | static void mbo_add_nebor_entry(struct sigma_dut *dut, const uint8_t *mac_addr, |
| 10712 | int ap_ne_class, int ap_ne_op_ch, |
| 10713 | int ap_ne_pref) |
| 10714 | { |
| 10715 | struct mbo_pref_ap *entry; |
| 10716 | uint8_t self_mac[ETH_ALEN]; |
| 10717 | char ifname[50]; |
| 10718 | |
| 10719 | get_if_name(dut, ifname, sizeof(ifname), 1); |
| 10720 | get_hwaddr(ifname, self_mac); |
| 10721 | |
| 10722 | if (memcmp(mac_addr, self_mac, ETH_ALEN) == 0) |
| 10723 | entry = &dut->mbo_self_ap_tuple; |
| 10724 | else |
| 10725 | entry = mbo_find_nebor_ap_entry(dut, mac_addr); |
| 10726 | |
| 10727 | if (!entry) { |
| 10728 | if (dut->mbo_pref_ap_cnt >= MBO_MAX_PREF_BSSIDS) { |
| 10729 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 10730 | "Nebor AP List is full. Not adding"); |
| 10731 | return; |
| 10732 | } |
| 10733 | entry = &dut->mbo_pref_aps[dut->mbo_pref_ap_cnt]; |
| 10734 | dut->mbo_pref_ap_cnt++; |
| 10735 | memcpy(entry->mac_addr, mac_addr, ETH_ALEN); |
| 10736 | entry->ap_ne_class = -1; |
| 10737 | entry->ap_ne_op_ch = -1; |
| 10738 | entry->ap_ne_pref = -1; |
| 10739 | } |
| 10740 | if (ap_ne_class != -1) |
| 10741 | entry->ap_ne_class = ap_ne_class; |
| 10742 | if (ap_ne_op_ch != -1) |
| 10743 | entry->ap_ne_op_ch = ap_ne_op_ch; |
| 10744 | if (ap_ne_pref != -1) |
| 10745 | entry->ap_ne_pref = ap_ne_pref; |
| 10746 | } |
| 10747 | |
| 10748 | |
| 10749 | static int ath_set_nebor_bssid(struct sigma_dut *dut, const char *ifname, |
| 10750 | struct sigma_cmd *cmd) |
| 10751 | { |
| 10752 | unsigned char mac_addr[ETH_ALEN]; |
| 10753 | const char *val; |
| 10754 | /* |
| 10755 | * -1 is invalid value for the following |
| 10756 | * to differentiate between unset and set values |
| 10757 | * -1 => implies not set by CAPI |
| 10758 | */ |
| 10759 | int ap_ne_class = -1, ap_ne_op_ch = -1, ap_ne_pref = -1; |
| 10760 | int list_offset = dut->mbo_pref_ap_cnt; |
| 10761 | |
| 10762 | if (list_offset >= MBO_MAX_PREF_BSSIDS) { |
| 10763 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 10764 | "AP Pref Entry list is full"); |
| 10765 | return -1; |
| 10766 | } |
| 10767 | |
| 10768 | val = get_param(cmd, "Nebor_Op_Class"); |
| 10769 | if (val) |
| 10770 | ap_ne_class = atoi(val); |
| 10771 | |
| 10772 | val = get_param(cmd, "Nebor_Op_Ch"); |
| 10773 | if (val) |
| 10774 | ap_ne_op_ch = atoi(val); |
| 10775 | |
| 10776 | val = get_param(cmd, "Nebor_Pref"); |
| 10777 | if (val) |
| 10778 | ap_ne_pref = atoi(val); |
| 10779 | |
| 10780 | val = get_param(cmd, "Nebor_BSSID"); |
| 10781 | if (!val || parse_mac_address(dut, val, mac_addr) < 0) |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 10782 | return -1; |
| 10783 | |
Adil Saeed Musthafa | 6906372 | 2017-04-10 23:13:40 -0700 | [diff] [blame] | 10784 | mbo_add_nebor_entry(dut, mac_addr, ap_ne_class, ap_ne_op_ch, |
| 10785 | ap_ne_pref); |
| 10786 | apply_mbo_pref_ap_list(dut); |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 10787 | return 0; |
| 10788 | } |
| 10789 | |
| 10790 | |
Priyadharshini Gowthaman | c067edf | 2019-06-20 11:23:27 -0700 | [diff] [blame] | 10791 | static enum sigma_cmd_result he_ltf(struct sigma_dut *dut, |
| 10792 | struct sigma_conn *conn, |
| 10793 | const char *ifname, const char *val) |
| 10794 | { |
| 10795 | const char *var; |
| 10796 | |
| 10797 | if (dut->ap_he_ulofdma == VALUE_ENABLED) |
| 10798 | var = "he_ul_ltf"; |
| 10799 | else |
| 10800 | var = "he_ltf"; |
| 10801 | |
| 10802 | if (strcmp(val, "6.4") == 0) { |
| 10803 | run_iwpriv(dut, ifname, "%s 2", var); |
| 10804 | } else if (strcmp(val, "12.8") == 0) { |
| 10805 | run_iwpriv(dut, ifname, "%s 3", var); |
| 10806 | } else if (strcmp(val, "3.2") == 0) { |
| 10807 | run_iwpriv(dut, ifname, "%s 1", var); |
| 10808 | } else { |
| 10809 | send_resp(dut, conn, SIGMA_ERROR, "errorCode,Unsupported LTF"); |
| 10810 | return STATUS_SENT_ERROR; |
| 10811 | } |
| 10812 | |
| 10813 | return SUCCESS_SEND_STATUS; |
| 10814 | } |
| 10815 | |
| 10816 | |
Priyadharshini Gowthaman | cc6ff5a | 2019-06-20 11:23:52 -0700 | [diff] [blame] | 10817 | static enum sigma_cmd_result he_shortgi(struct sigma_dut *dut, |
| 10818 | struct sigma_conn *conn, |
| 10819 | const char *ifname, |
| 10820 | const char *val) |
| 10821 | { |
| 10822 | const char *var; |
| 10823 | |
| 10824 | if (dut->ap_he_ulofdma == VALUE_ENABLED) |
| 10825 | var = "he_ul_shortgi"; |
| 10826 | else |
| 10827 | var = "shortgi"; |
| 10828 | |
| 10829 | if (strcmp(val, "0.8") == 0) { |
| 10830 | run_iwpriv(dut, ifname, "%s 0", var); |
| 10831 | } else if (strcmp(val, "1.6") == 0) { |
| 10832 | run_iwpriv(dut, ifname, "%s 2", var); |
| 10833 | } else if (strcmp(val, "3.2") == 0) { |
| 10834 | run_iwpriv(dut, ifname, "%s 3", var); |
| 10835 | } else { |
| 10836 | send_resp(dut, conn, SIGMA_ERROR, |
| 10837 | "errorCode,Unsupported shortGI"); |
| 10838 | return STATUS_SENT_ERROR; |
| 10839 | } |
| 10840 | |
| 10841 | return SUCCESS_SEND_STATUS; |
| 10842 | } |
| 10843 | |
| 10844 | |
| 10845 | static enum sigma_cmd_result he_ar_gi_ltf_mask(struct sigma_dut *dut, |
| 10846 | struct sigma_conn *conn, |
| 10847 | const char *ifname, |
| 10848 | const char *val) |
| 10849 | { |
| 10850 | |
| 10851 | uint32_t he_ar_gi_ltf; |
| 10852 | uint16_t he_ar_gi, he_ar_ltf; |
| 10853 | |
| 10854 | if (strcmp(val, "0.4") == 0) { |
| 10855 | he_ar_gi = 0x01; |
| 10856 | } else if (strcmp(val, "0.8") == 0) { |
| 10857 | he_ar_gi = 0x02; |
| 10858 | } else if (strcmp(val, "1.6") == 0) { |
| 10859 | he_ar_gi = 0x04; |
| 10860 | } else if (strcmp(val, "3.2") == 0) { |
| 10861 | he_ar_gi = 0x08; |
| 10862 | } else { |
| 10863 | send_resp(dut, conn, SIGMA_ERROR, |
| 10864 | "errorCode,Unsupported shortGI"); |
| 10865 | return STATUS_SENT_ERROR; |
| 10866 | } |
| 10867 | |
| 10868 | if (dut->ar_ltf && strcmp(dut->ar_ltf, "6.4") == 0) { |
| 10869 | he_ar_ltf = 0x02; |
| 10870 | } else if (dut->ar_ltf && strcmp(dut->ar_ltf, "12.8") == 0) { |
| 10871 | he_ar_ltf = 0x04; |
| 10872 | } else if (dut->ar_ltf && strcmp(dut->ar_ltf, "3.2") == 0) { |
| 10873 | he_ar_ltf = 0x01; |
| 10874 | } else { |
| 10875 | send_resp(dut, conn, SIGMA_ERROR, |
| 10876 | "errorCode,Unsupported LTF"); |
| 10877 | return STATUS_SENT_ERROR; |
| 10878 | } |
| 10879 | |
| 10880 | he_ar_gi_ltf = (he_ar_gi << 8) | he_ar_ltf; |
| 10881 | run_iwpriv(dut, ifname, "he_ar_gi_ltf %lu", he_ar_gi_ltf); |
| 10882 | |
| 10883 | return SUCCESS_SEND_STATUS; |
| 10884 | } |
| 10885 | |
| 10886 | |
Priyadharshini Gowthaman | 9e7d831 | 2019-06-20 11:24:03 -0700 | [diff] [blame] | 10887 | static enum sigma_cmd_result he_rualloctones(struct sigma_dut *dut, |
| 10888 | struct sigma_conn *conn, |
| 10889 | const char *ifname, |
| 10890 | const char *val) |
| 10891 | { |
| 10892 | char *token, *result; |
| 10893 | int value; |
| 10894 | char *saveptr; |
| 10895 | int rualloc_type; |
| 10896 | enum sigma_cmd_result ret = SUCCESS_SEND_STATUS; |
| 10897 | |
| 10898 | token = strdup(val); |
| 10899 | if (!token) |
| 10900 | return -1; |
| 10901 | result = strtok_r(token, ":", &saveptr); |
| 10902 | if (!result) { |
| 10903 | free(token); |
| 10904 | send_resp(dut, conn, SIGMA_ERROR, |
| 10905 | "errorCode,RUAllocTones not specified"); |
| 10906 | return STATUS_SENT_ERROR; |
| 10907 | } |
| 10908 | |
| 10909 | /* |
| 10910 | * ru_allocation_type can take the values of: |
| 10911 | * 1 - DL OFDMA data RU allocation |
| 10912 | * 3 - UL OFDMA data RU allocation |
| 10913 | */ |
| 10914 | rualloc_type = dut->ap_he_ulofdma == VALUE_ENABLED ? 3 : 1; |
| 10915 | |
| 10916 | |
| 10917 | value = atoi(result); |
| 10918 | if (value == 106) { |
| 10919 | enum value_not_set_enabled_disabled ap_he_rualloc_106_80 = |
| 10920 | VALUE_NOT_SET; |
| 10921 | |
| 10922 | result = strtok_r(NULL, ":", &saveptr); |
| 10923 | if (result) { |
| 10924 | result = strtok_r(NULL, ":", &saveptr); |
| 10925 | if (result) |
| 10926 | ap_he_rualloc_106_80 = VALUE_ENABLED; |
| 10927 | else |
| 10928 | ap_he_rualloc_106_80 = VALUE_DISABLED; |
| 10929 | } |
| 10930 | if (ap_he_rualloc_106_80 == VALUE_ENABLED) { |
| 10931 | run_system_wrapper(dut, |
| 10932 | "wifitool %s setUnitTestCmd 0x4b 9 %d 0 2 1 2 2 2 3 2", |
| 10933 | ifname, rualloc_type); |
| 10934 | } else { |
| 10935 | run_system_wrapper(dut, |
| 10936 | "wifitool %s setUnitTestCmd 0x4b 5 %d 0 2 1 2", |
| 10937 | ifname, rualloc_type); |
| 10938 | } |
| 10939 | } else if (value == 242) { |
| 10940 | run_system_wrapper( |
| 10941 | dut, |
| 10942 | "wifitool %s setUnitTestCmd 0x4b 9 %d 0 3 1 3 2 3 3 3", |
| 10943 | ifname, rualloc_type); |
| 10944 | } else if (value == 26) { |
| 10945 | run_system_wrapper( |
| 10946 | dut, |
| 10947 | "wifitool %s setUnitTestCmd 0x4b 9 %d 0 0 2 0 5 0 7 0", |
| 10948 | ifname, rualloc_type); |
| 10949 | } else if (value == 52) { |
| 10950 | run_system_wrapper( |
| 10951 | dut, |
| 10952 | "wifitool %s setUnitTestCmd 0x4b 9 %d 0 1 1 1 2 1 3 1", |
| 10953 | ifname, rualloc_type); |
| 10954 | } else if (value == 484) { |
| 10955 | run_system_wrapper( |
| 10956 | dut, |
| 10957 | "wifitool %s setUnitTestCmd 0x4b 5 %d 0 4 1 4", |
| 10958 | ifname, rualloc_type); |
| 10959 | } else if (value == 996) { |
| 10960 | run_system_wrapper(dut, |
| 10961 | "wifitool %s setUnitTestCmd 0x4b 3 %d 0 5", |
| 10962 | ifname, rualloc_type); |
| 10963 | } else { |
| 10964 | send_resp(dut, conn, SIGMA_ERROR, |
| 10965 | "errorCode,Unsupported RUAllocTones"); |
| 10966 | ret = STATUS_SENT_ERROR; |
| 10967 | } |
| 10968 | |
| 10969 | free(token); |
| 10970 | return ret; |
| 10971 | } |
| 10972 | |
| 10973 | |
Priyadharshini Gowthaman | 7e43870 | 2019-08-09 12:05:05 -0700 | [diff] [blame] | 10974 | static void ath_set_trigger_type_0(struct sigma_dut *dut, const char *ifname) |
| 10975 | { |
| 10976 | /* TriggerType "0" for Basic trigger */ |
| 10977 | if (dut->ap_channel >= 36) { |
| 10978 | /* 1 and 2 here is interpreted to 5g and 2g (bitmasks) */ |
| 10979 | run_system_wrapper(dut, |
| 10980 | "wifitool %s setUnitTestCmd 0x47 2 42 1", |
| 10981 | ifname); |
| 10982 | } else { |
| 10983 | run_system_wrapper(dut, |
| 10984 | "wifitool %s setUnitTestCmd 0x47 2 42 2", |
| 10985 | ifname); |
| 10986 | } |
| 10987 | run_system_wrapper(dut, "wifitool %s setUnitTestCmd 0x47 2 43 6", |
| 10988 | ifname); |
| 10989 | } |
| 10990 | |
| 10991 | |
| 10992 | static void ath_set_trigger_type_1(struct sigma_dut *dut, const char *ifname) |
| 10993 | { |
| 10994 | /* TriggerType "1" for MU BRP */ |
| 10995 | run_system_wrapper(dut, "wifitool %s setUnitTestCmd 0x47 2 7 1", |
| 10996 | ifname); |
| 10997 | mubrp_commands(dut, ifname); |
| 10998 | } |
| 10999 | |
| 11000 | |
| 11001 | static void ath_set_trigger_type_2(struct sigma_dut *dut, const char *ifname) |
| 11002 | { |
| 11003 | /* TriggerType "2" for MU BAR */ |
| 11004 | if (dut->ap_channel >= 36) { |
| 11005 | /* RU allocation RU 242 - DL OFDMA data */ |
| 11006 | run_system_wrapper(dut, |
| 11007 | "wifitool %s setUnitTestCmd 0x4b 5 9 0 3 1 3 2 3 3 3", |
| 11008 | ifname); |
| 11009 | /* RU allocation RU 52 - UL BA */ |
| 11010 | run_system_wrapper(dut, |
| 11011 | "wifitool %s setUnitTestCmd 0x4b 5 9 0 2 1 2 2 2 3 2", |
| 11012 | ifname); |
| 11013 | } else { |
| 11014 | /* RU allocation RU 52 - DL ofdma data */ |
| 11015 | run_system_wrapper(dut, |
| 11016 | "wifitool %s setUnitTestCmd 0x4b 5 9 0 1 1 1 2 1 3 1", |
| 11017 | ifname); |
| 11018 | } |
| 11019 | /* Force TBPPDU duration to 400 us */ |
| 11020 | run_system_wrapper(dut, "wifitool %s setUnitTestCmd 0x48 2 63 400", |
| 11021 | ifname); |
| 11022 | /* 0 to enable MU BAR, 1 to enable SU BAR */ |
| 11023 | run_system_wrapper(dut, "wifitool %s setUnitTestCmd 0x47 2 49 0", |
| 11024 | ifname); |
| 11025 | /* MU BAR */ |
| 11026 | run_system_wrapper(dut, "wifitool %s setUnitTestCmd 0x47 2 64 0", |
| 11027 | ifname); |
| 11028 | } |
| 11029 | |
| 11030 | |
| 11031 | static void ath_set_trigger_type_3(struct sigma_dut *dut, const char *ifname) |
| 11032 | { |
| 11033 | /* TriggerType "3" for MU RTS */ |
| 11034 | /* Send MU RTS Trigger - '1' is to enable MU RTS */ |
| 11035 | run_system_wrapper(dut, "wifitool %s setUnitTestCmd 0x47 2 101 1", |
| 11036 | ifname); |
| 11037 | } |
| 11038 | |
| 11039 | |
| 11040 | static void ath_set_trigger_type_4(struct sigma_dut *dut, const char *ifname, |
| 11041 | const char *basedev) |
| 11042 | { |
| 11043 | /* TriggerType "4" for BSRP */ |
| 11044 | run_system_wrapper(dut, "cfg80211tool %s he_ul_trig_int 200", basedev); |
| 11045 | run_system_wrapper(dut, "wifitool %s setUnitTestCmd 0x48 2 63 1000", |
| 11046 | ifname); |
| 11047 | if (dut->ap_channel >= 36) { |
| 11048 | run_system_wrapper(dut, |
| 11049 | "wifitool %s setUnitTestCmd 0x47 2 42 1", |
| 11050 | ifname); |
| 11051 | } else { |
| 11052 | run_system_wrapper(dut, |
| 11053 | "wifitool %s setUnitTestCmd 0x47 2 42 2", |
| 11054 | ifname); |
| 11055 | } |
| 11056 | /* Send BSRP command */ |
| 11057 | run_system_wrapper(dut, "wifitool %s setUnitTestCmd 0x47 2 43 7", |
| 11058 | ifname); |
| 11059 | } |
| 11060 | |
| 11061 | |
Jouni Malinen | 6076ffc | 2019-08-08 18:18:02 +0300 | [diff] [blame] | 11062 | static enum sigma_cmd_result ath_ap_set_rfeature(struct sigma_dut *dut, |
| 11063 | struct sigma_conn *conn, |
| 11064 | struct sigma_cmd *cmd) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 11065 | { |
| 11066 | const char *val; |
| 11067 | char *ifname; |
Priyadharshini Gowthaman | c067edf | 2019-06-20 11:23:27 -0700 | [diff] [blame] | 11068 | enum sigma_cmd_result res; |
Priyadharshini Gowthaman | f8c032d | 2019-07-31 14:38:02 -0700 | [diff] [blame] | 11069 | const char *basedev = "wifi0"; |
Priyadharshini Gowthaman | 2f8c317 | 2019-07-31 14:38:12 -0700 | [diff] [blame] | 11070 | int trigtype; |
Priyadharshini Gowthaman | 51c0fec | 2019-08-09 12:04:05 -0700 | [diff] [blame] | 11071 | int he_ackpolicymac = 0; |
Priyadharshini Gowthaman | e87e2c9 | 2019-08-09 12:04:31 -0700 | [diff] [blame] | 11072 | char *num_ss = NULL; |
| 11073 | char *nss[4] = { NULL, NULL, NULL, NULL }; |
Priyadharshini Gowthaman | dca0c54 | 2019-08-09 12:04:42 -0700 | [diff] [blame] | 11074 | char *aid[4] = { NULL, NULL, NULL, NULL }; |
| 11075 | char *aid_ss = NULL; |
Priyadharshini Gowthaman | 2da1ecc | 2019-08-09 12:04:54 -0700 | [diff] [blame] | 11076 | int omctrl_rxnss = 0, omctrl_chwidth = 0; |
Priyadharshini Gowthaman | 872fb29 | 2019-08-09 12:05:27 -0700 | [diff] [blame] | 11077 | int param; |
Priyadharshini Gowthaman | 51c0fec | 2019-08-09 12:04:05 -0700 | [diff] [blame] | 11078 | unsigned char mac_addr[ETH_ALEN]; |
| 11079 | |
| 11080 | memset(mac_addr, 0x00, ETH_ALEN); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 11081 | |
| 11082 | ifname = get_main_ifname(); |
| 11083 | |
Priyadharshini Gowthaman | f8c032d | 2019-07-31 14:38:02 -0700 | [diff] [blame] | 11084 | if (sigma_radio_ifname[0]) |
| 11085 | basedev = sigma_radio_ifname[0]; |
| 11086 | |
Priyadharshini Gowthaman | 39beafa | 2015-11-09 14:11:25 -0800 | [diff] [blame] | 11087 | /* Disable vap reset between the commands */ |
Priyadharshini Gowthaman | 8c5b9a4 | 2019-07-31 14:38:48 -0700 | [diff] [blame] | 11088 | novap_reset(dut, ifname, 1); |
Priyadharshini Gowthaman | 39beafa | 2015-11-09 14:11:25 -0800 | [diff] [blame] | 11089 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 11090 | val = get_param(cmd, "Opt_md_notif_ie"); |
| 11091 | if (val && ath_vht_op_mode_notif(dut, ifname, val) < 0) |
Jouni Malinen | 6076ffc | 2019-08-08 18:18:02 +0300 | [diff] [blame] | 11092 | return ERROR_SEND_STATUS; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 11093 | |
| 11094 | /* TODO: Optional arguments */ |
| 11095 | |
| 11096 | val = get_param(cmd, "nss_mcs_opt"); |
| 11097 | if (val && ath_vht_nss_mcs(dut, ifname, val) < 0) |
Jouni Malinen | 6076ffc | 2019-08-08 18:18:02 +0300 | [diff] [blame] | 11098 | return ERROR_SEND_STATUS; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 11099 | |
| 11100 | val = get_param(cmd, "chnum_band"); |
| 11101 | if (val && ath_vht_chnum_band(dut, ifname, val) < 0) |
Jouni Malinen | 6076ffc | 2019-08-08 18:18:02 +0300 | [diff] [blame] | 11102 | return ERROR_SEND_STATUS; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 11103 | |
| 11104 | val = get_param(cmd, "RTS_FORCE"); |
| 11105 | if (val) |
| 11106 | ath_config_rts_force(dut, ifname, val); |
| 11107 | |
| 11108 | val = get_param(cmd, "DYN_BW_SGNL"); |
| 11109 | if (val) |
| 11110 | ath_config_dyn_bw_sig(dut, ifname, val); |
| 11111 | |
| 11112 | val = get_param(cmd, "CTS_WIDTH"); |
| 11113 | if (val) |
| 11114 | ath_set_cts_width(dut, ifname, val); |
| 11115 | |
| 11116 | val = get_param(cmd, "Ndpa_stainfo_mac"); |
| 11117 | if (val && ath_ndpa_stainfo_mac(dut, ifname, val) < 0) |
Jouni Malinen | 6076ffc | 2019-08-08 18:18:02 +0300 | [diff] [blame] | 11118 | return ERROR_SEND_STATUS; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 11119 | |
| 11120 | val = get_param(cmd, "txBandwidth"); |
| 11121 | if (val && ath_set_width(dut, conn, ifname, val) < 0) |
Jouni Malinen | 6076ffc | 2019-08-08 18:18:02 +0300 | [diff] [blame] | 11122 | return ERROR_SEND_STATUS; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 11123 | |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 11124 | val = get_param(cmd, "Assoc_Disallow"); |
| 11125 | if (val) |
| 11126 | ath_set_assoc_disallow(dut, ifname, val); |
| 11127 | |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 11128 | |
Adil Saeed Musthafa | 6906372 | 2017-04-10 23:13:40 -0700 | [diff] [blame] | 11129 | ath_set_nebor_bssid(dut, ifname, cmd); |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 11130 | val = get_param(cmd, "BTMReq_DisAssoc_Imnt"); |
priyadharshini gowthaman | 776562e | 2017-12-20 12:33:34 -0800 | [diff] [blame] | 11131 | if (val) { |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 11132 | dut->ap_btmreq_disassoc_imnt = atoi(val); |
priyadharshini gowthaman | 776562e | 2017-12-20 12:33:34 -0800 | [diff] [blame] | 11133 | dut->ap_disassoc_timer = 1000; |
| 11134 | } |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 11135 | |
| 11136 | val = get_param(cmd, "BTMReq_Term_Bit"); |
| 11137 | if (val) |
| 11138 | dut->ap_btmreq_term_bit = atoi(val); |
| 11139 | |
Adil Saeed Musthafa | 48c5ab9 | 2017-04-10 23:13:35 -0700 | [diff] [blame] | 11140 | val = get_param(cmd, "Assoc_Delay"); |
priyadharshini gowthaman | 776562e | 2017-12-20 12:33:34 -0800 | [diff] [blame] | 11141 | if (val) { |
| 11142 | dut->ap_assoc_delay = 1; |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 11143 | run_iwpriv(dut, ifname, "mbo_asoc_ret %s", val); |
priyadharshini gowthaman | 776562e | 2017-12-20 12:33:34 -0800 | [diff] [blame] | 11144 | } |
Adil Saeed Musthafa | 48c5ab9 | 2017-04-10 23:13:35 -0700 | [diff] [blame] | 11145 | |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 11146 | val = get_param(cmd, "Disassoc_Timer"); |
| 11147 | if (val) |
| 11148 | dut->ap_disassoc_timer = atoi(val); |
| 11149 | |
| 11150 | val = get_param(cmd, "BSS_Term_Duration"); |
| 11151 | if (val) |
| 11152 | dut->ap_btmreq_bss_term_dur = atoi(val); |
| 11153 | |
priyadharshini gowthaman | 94062b5 | 2017-12-20 12:33:34 -0800 | [diff] [blame] | 11154 | val = get_param(cmd, "BSS_Term_TSF"); |
| 11155 | if (val) |
| 11156 | dut->ap_btmreq_bss_term_tsf = atoi(val); |
| 11157 | |
priyadharshini gowthaman | cb22e43 | 2017-12-28 15:23:31 -0800 | [diff] [blame] | 11158 | val = get_param(cmd, "TxPower"); |
| 11159 | if (val) |
| 11160 | ath_set_txpower(dut, ifname, val); |
| 11161 | |
| 11162 | val = get_param(cmd, "DownlinkAvailCap"); |
| 11163 | if (val) |
| 11164 | dut->ap_dl_availcap = atoi(val); |
| 11165 | |
| 11166 | val = get_param(cmd, "UplinkAvailCap"); |
| 11167 | if (val) { |
| 11168 | dut->ap_ul_availcap = atoi(val); |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 11169 | run_iwpriv(dut, ifname, "oce_wan_mtr %d %d", |
| 11170 | dut->ap_dl_availcap, dut->ap_ul_availcap); |
priyadharshini gowthaman | cb22e43 | 2017-12-28 15:23:31 -0800 | [diff] [blame] | 11171 | } |
| 11172 | |
| 11173 | val = get_param(cmd, "RSSIthreshold"); |
| 11174 | if (val) { |
| 11175 | int rssithreshold; |
| 11176 | |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 11177 | run_iwpriv(dut, ifname, "oce_asoc_rej 1"); |
priyadharshini gowthaman | cb22e43 | 2017-12-28 15:23:31 -0800 | [diff] [blame] | 11178 | rssithreshold = atoi(val); |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 11179 | run_iwpriv(dut, ifname, "oce_asoc_rssi %d", rssithreshold); |
priyadharshini gowthaman | cb22e43 | 2017-12-28 15:23:31 -0800 | [diff] [blame] | 11180 | } |
| 11181 | |
| 11182 | val = get_param(cmd, "RetryDelay"); |
| 11183 | if (val) { |
| 11184 | int retrydelay; |
| 11185 | |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 11186 | run_iwpriv(dut, ifname, "oce_asoc_rej 1"); |
priyadharshini gowthaman | cb22e43 | 2017-12-28 15:23:31 -0800 | [diff] [blame] | 11187 | retrydelay = atoi(val); |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 11188 | run_iwpriv(dut, ifname, "oce_asoc_dly %d", retrydelay); |
priyadharshini gowthaman | cb22e43 | 2017-12-28 15:23:31 -0800 | [diff] [blame] | 11189 | } |
| 11190 | |
Priyadharshini Gowthaman | c067edf | 2019-06-20 11:23:27 -0700 | [diff] [blame] | 11191 | val = get_param(cmd, "LTF"); |
| 11192 | if (val) { |
| 11193 | if (dut->ap_fixed_rate) { |
| 11194 | res = he_ltf(dut, conn, ifname, val); |
| 11195 | if (res != SUCCESS_SEND_STATUS) |
| 11196 | return res; |
| 11197 | } else { |
| 11198 | free(dut->ar_ltf); |
| 11199 | dut->ar_ltf = strdup(val); |
| 11200 | if (!dut->ar_ltf) |
Jouni Malinen | 6076ffc | 2019-08-08 18:18:02 +0300 | [diff] [blame] | 11201 | return ERROR_SEND_STATUS; |
Priyadharshini Gowthaman | c067edf | 2019-06-20 11:23:27 -0700 | [diff] [blame] | 11202 | } |
| 11203 | } |
| 11204 | |
Priyadharshini Gowthaman | cc6ff5a | 2019-06-20 11:23:52 -0700 | [diff] [blame] | 11205 | val = get_param(cmd, "GI"); |
| 11206 | if (val) { |
| 11207 | if (dut->ap_fixed_rate) |
| 11208 | res = he_shortgi(dut, conn, ifname, val); |
| 11209 | else |
| 11210 | res = he_ar_gi_ltf_mask(dut, conn, ifname, val); |
| 11211 | if (res != SUCCESS_SEND_STATUS) |
| 11212 | return res; |
| 11213 | } |
| 11214 | |
Priyadharshini Gowthaman | 9e7d831 | 2019-06-20 11:24:03 -0700 | [diff] [blame] | 11215 | val = get_param(cmd, "RUAllocTones"); |
| 11216 | if (val) { |
| 11217 | res = he_rualloctones(dut, conn, ifname, val); |
| 11218 | if (res != SUCCESS_SEND_STATUS) |
| 11219 | return res; |
| 11220 | } |
| 11221 | |
Priyadharshini Gowthaman | 803fd66 | 2019-07-31 14:37:49 -0700 | [diff] [blame] | 11222 | val = get_param(cmd, "MPDU_MU_SpacingFactor"); |
| 11223 | if (val) |
| 11224 | run_system_wrapper(dut, |
| 11225 | "wifitool %s setUnitTestCmd 0x48 2 119, %s", |
| 11226 | ifname, val); |
| 11227 | |
| 11228 | val = get_param(cmd, "PPDUTxType"); |
| 11229 | if (val) { |
| 11230 | if (strcasecmp(val, "HE-SU") == 0) { |
| 11231 | /* Change PPDU format type to HE-SU MCS 1 */ |
| 11232 | run_system_wrapper(dut, |
| 11233 | "wifitool %s setUnitTestCmd 0x48 2 89 0x401", |
| 11234 | ifname); |
| 11235 | } else if (strcasecmp(val, "legacy") == 0) { |
| 11236 | /* Change PPDU format type to non-HT */ |
| 11237 | run_system_wrapper(dut, |
| 11238 | "wifitool %s setUnitTestCmd 0x48 2 89 3", |
| 11239 | ifname); |
| 11240 | } else { |
| 11241 | send_resp(dut, conn, SIGMA_ERROR, |
| 11242 | "errorCode,Unsupported PPDUTxType"); |
| 11243 | return STATUS_SENT_ERROR; |
| 11244 | } |
| 11245 | } |
| 11246 | |
| 11247 | val = get_param(cmd, "TXOPDuration"); |
| 11248 | if (val) { |
| 11249 | if (strcasecmp(val, "UNSPECIFIED") == 0) { |
| 11250 | /* The hardware is hardcoded with 0x7f; do nothing */ |
| 11251 | } else { |
| 11252 | send_resp(dut, conn, SIGMA_ERROR, |
| 11253 | "errorCode,Unsupported TXOPDuration"); |
| 11254 | return STATUS_SENT_ERROR; |
| 11255 | } |
| 11256 | } |
| 11257 | |
Priyadharshini Gowthaman | f8c032d | 2019-07-31 14:38:02 -0700 | [diff] [blame] | 11258 | val = get_param(cmd, "Trig_Usrinfo_UL-MCS"); |
| 11259 | if (val) |
| 11260 | run_iwpriv(dut, ifname, "he_ul_mcs %d", atoi(val)); |
| 11261 | |
| 11262 | val = get_param(cmd, "Trig_Usrinfo_UL-Target-RSSI"); |
| 11263 | if (val) { |
| 11264 | /* Set target RSSI to -55 dBm */ |
| 11265 | run_system_wrapper(dut, |
| 11266 | "wifitool %s setUnitTestCmd 0x4b 2 7 %d", |
| 11267 | ifname, atoi(val) - 110); |
| 11268 | } |
| 11269 | |
| 11270 | val = get_param(cmd, "Trig_Interval"); |
| 11271 | if (val) |
| 11272 | run_iwpriv(dut, basedev, "he_ul_trig_int %d", atoi(val)); |
| 11273 | |
| 11274 | val = get_param(cmd, "Trig_ComInfo_ULLength"); |
| 11275 | if (val) |
| 11276 | run_system_wrapper(dut, |
| 11277 | "wifitool %s setUnitTestCmd 0x48 2 141 %d", |
| 11278 | ifname, atoi(val)); |
| 11279 | |
Priyadharshini Gowthaman | 2f8c317 | 2019-07-31 14:38:12 -0700 | [diff] [blame] | 11280 | val = get_param(cmd, "DisableTriggerType"); |
| 11281 | if (val) { |
| 11282 | trigtype = atoi(val); |
| 11283 | switch (trigtype) { |
| 11284 | case 0: |
| 11285 | /* DisableTriggerType "0" for basic trigger */ |
| 11286 | run_system_wrapper(dut, |
| 11287 | "wifitool %s setUnitTestCmd 0x47 2 42 0", |
| 11288 | ifname); |
| 11289 | break; |
| 11290 | default: |
| 11291 | /* Nothing to be done for now */ |
| 11292 | break; |
| 11293 | } |
| 11294 | } |
| 11295 | |
| 11296 | val = get_param(cmd, "Trigger_TxBF"); |
| 11297 | if (val) { |
| 11298 | if (strcasecmp(val, "enable") == 0) { |
| 11299 | run_iwpriv(dut, ifname, "he_sounding_mode 0x9"); |
| 11300 | } else if (strcasecmp(val, "disable") == 0) { |
| 11301 | run_iwpriv(dut, ifname, "he_sounding_mode 0x1"); |
| 11302 | } else { |
| 11303 | send_resp(dut, conn, SIGMA_ERROR, |
| 11304 | "errorCode,Unsupported trigger_txbf"); |
| 11305 | return STATUS_SENT_ERROR; |
| 11306 | } |
| 11307 | } |
| 11308 | |
Priyadharshini Gowthaman | 7b94f08 | 2019-07-31 14:38:25 -0700 | [diff] [blame] | 11309 | val = get_param(cmd, "Trig_UsrInfo_RUAlloc"); |
| 11310 | if (val) { |
| 11311 | res = he_rualloctones(dut, conn, ifname, val); |
| 11312 | if (res != SUCCESS_SEND_STATUS) |
| 11313 | return res; |
| 11314 | } |
| 11315 | |
Priyadharshini Gowthaman | 8701fac | 2019-07-31 14:38:48 -0700 | [diff] [blame] | 11316 | val = get_param(cmd, "TriggerCoding"); |
| 11317 | if (val) { |
| 11318 | if (strcasecmp(val, "BCC") == 0) { |
| 11319 | /* In case of LDPC enable this command can force BCC if |
| 11320 | * RU size <= 242 */ |
| 11321 | run_iwpriv(dut, ifname, "he_ul_ldpc 0"); |
| 11322 | } else if (strcasecmp(val, "LDPC") == 0) { |
| 11323 | novap_reset(dut, ifname, 0); |
| 11324 | run_iwpriv(dut, ifname, "he_ul_ldpc 1"); |
| 11325 | novap_reset(dut, ifname, 1); |
| 11326 | } else { |
| 11327 | send_resp(dut, conn, SIGMA_ERROR, |
| 11328 | "errorCode,Unsupported TriggerCoding"); |
| 11329 | return STATUS_SENT_ERROR; |
| 11330 | } |
| 11331 | } |
| 11332 | |
Priyadharshini Gowthaman | 51c0fec | 2019-08-09 12:04:05 -0700 | [diff] [blame] | 11333 | val = get_param(cmd, "AckPolicy_MAC"); |
| 11334 | if (val) { |
| 11335 | if (parse_mac_address(dut, val, mac_addr) < 0) { |
| 11336 | send_resp(dut, conn, SIGMA_ERROR, |
| 11337 | "errorCode,MAC Address not in proper format"); |
| 11338 | return STATUS_SENT_ERROR; |
| 11339 | } |
| 11340 | he_ackpolicymac = 1; |
| 11341 | } |
| 11342 | |
| 11343 | val = get_param(cmd, "AckPolicy"); |
| 11344 | if (val) { |
| 11345 | int ap_he_ackpolicy; |
| 11346 | |
| 11347 | ap_he_ackpolicy = atoi(val); |
| 11348 | if (ap_he_ackpolicy == 0 && he_ackpolicymac) { |
| 11349 | /* Disable all-BAR ackpolicy for MU-MIMO */ |
| 11350 | run_system_wrapper(dut, |
| 11351 | "wifitool %s setUnitTestCmd 0x48 2 62 0", |
| 11352 | ifname); |
| 11353 | /* Disable all-BAR ackpolicy first */ |
| 11354 | run_system_wrapper(dut, |
| 11355 | "wifitool %s setUnitTestCmd 0x48 2 64 0", |
| 11356 | ifname); |
| 11357 | /* Set normal ack policy for the STA with the specified |
| 11358 | * MAC address in DL-TX case */ |
| 11359 | run_system_wrapper(dut, |
| 11360 | "wifitool %s setUnitTestCmd 0x4b 8 8 1 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x", |
| 11361 | ifname, mac_addr[0], mac_addr[1], |
| 11362 | mac_addr[2], mac_addr[3], |
| 11363 | mac_addr[4], mac_addr[5]); |
| 11364 | } else if (ap_he_ackpolicy == 3) { |
| 11365 | /* Enable all-BAR ackpolicy for MU-MIMO DL */ |
| 11366 | run_system_wrapper(dut, |
| 11367 | "wifitool %s setUnitTestCmd 0x48 2 62 1", |
| 11368 | ifname); |
| 11369 | /* Enable all-BAR ackpolicy */ |
| 11370 | run_system_wrapper(dut, |
| 11371 | "wifitool %s setUnitTestCmd 0x48 2 64 1", |
| 11372 | ifname); |
| 11373 | } else if (ap_he_ackpolicy == 4) { |
| 11374 | /* Enable htp-ack ackpolicy */ |
| 11375 | run_system_wrapper(dut, |
| 11376 | "wifitool %s setUnitTestCmd 0x47 2 99 1", |
| 11377 | ifname); |
| 11378 | } else { |
| 11379 | send_resp(dut, conn, SIGMA_ERROR, |
| 11380 | "errorCode,Invalid AckPolicy setting"); |
| 11381 | return STATUS_SENT_ERROR; |
| 11382 | } |
| 11383 | } |
| 11384 | |
Priyadharshini Gowthaman | c9a88c7 | 2019-08-09 12:04:17 -0700 | [diff] [blame] | 11385 | val = get_param(cmd, "Trig_ComInfo_GI-LTF"); |
| 11386 | if (val) { |
| 11387 | int trig_gi_ltf; |
| 11388 | |
| 11389 | trig_gi_ltf = atoi(val); |
| 11390 | if (trig_gi_ltf == 0) { |
| 11391 | he_ltf(dut, conn, ifname, "3.2"); |
| 11392 | he_shortgi(dut, conn, ifname, "1.6"); |
| 11393 | } else if (trig_gi_ltf == 1) { |
| 11394 | he_ltf(dut, conn, ifname, "6.4"); |
| 11395 | he_shortgi(dut, conn, ifname, "1.6"); |
| 11396 | } else if (trig_gi_ltf == 2) { |
| 11397 | he_ltf(dut, conn, ifname, "12.8"); |
| 11398 | he_shortgi(dut, conn, ifname, "3.2"); |
| 11399 | } else { |
| 11400 | send_resp(dut, conn, SIGMA_ERROR, |
| 11401 | "errorCode,Unsupported Trig_ComInfo_GI-LTF"); |
| 11402 | return STATUS_SENT_ERROR; |
| 11403 | } |
| 11404 | } |
| 11405 | |
| 11406 | val = get_param(cmd, "Trig_ComInfo_BW"); |
| 11407 | if (val) { |
| 11408 | int chwidth; |
| 11409 | |
| 11410 | chwidth = atoi(val); |
| 11411 | /* Set the channel width */ |
| 11412 | run_iwpriv(dut, ifname, "chwidth %d", chwidth); |
| 11413 | } |
| 11414 | |
Priyadharshini Gowthaman | e87e2c9 | 2019-08-09 12:04:31 -0700 | [diff] [blame] | 11415 | val = get_param(cmd, "NumSS"); |
| 11416 | if (val) { |
| 11417 | int i = 0; |
| 11418 | char *numss_val; |
| 11419 | char *saveptr; |
| 11420 | |
| 11421 | num_ss = strdup(val); |
| 11422 | if (!num_ss) |
| 11423 | return ERROR_SEND_STATUS; |
| 11424 | |
| 11425 | numss_val = strtok_r(num_ss, " ", &saveptr); |
| 11426 | for (i = 0; numss_val && i < 4; i++) { |
| 11427 | nss[i] = numss_val; |
| 11428 | numss_val = strtok_r(NULL, " ", &saveptr); |
| 11429 | } |
| 11430 | } |
| 11431 | |
| 11432 | val = get_param(cmd, "NumSS_MAC"); |
| 11433 | if (val) { |
| 11434 | char *sta_mac_str; |
| 11435 | char *saveptr; |
| 11436 | char *sta_mac_list_str; |
| 11437 | |
| 11438 | sta_mac_list_str = strdup(val); |
| 11439 | if (!sta_mac_list_str) { |
| 11440 | free(num_ss); |
| 11441 | return ERROR_SEND_STATUS; |
| 11442 | } |
| 11443 | |
| 11444 | sta_mac_str = strtok_r(sta_mac_list_str, " ", &saveptr); |
| 11445 | if (sta_mac_str && nss[0]) { |
| 11446 | run_system_wrapper(dut, |
| 11447 | "wifitool %s chmask_persta %s %s", |
| 11448 | ifname, sta_mac_str, nss[0]); |
| 11449 | } |
| 11450 | |
| 11451 | sta_mac_str = strtok_r(NULL, " ", &saveptr); |
| 11452 | if (sta_mac_str && nss[1]) { |
| 11453 | run_system_wrapper(dut, |
| 11454 | "wifitool %s chmask_persta %s %s", |
| 11455 | ifname, sta_mac_str, nss[1]); |
| 11456 | } |
| 11457 | |
| 11458 | sta_mac_str = strtok_r(NULL, " ", &saveptr); |
| 11459 | if (sta_mac_str && nss[2]) { |
| 11460 | run_system_wrapper(dut, |
| 11461 | "wifitool %s chmask_persta %s %s", |
| 11462 | ifname, sta_mac_str, nss[2]); |
| 11463 | } |
| 11464 | |
| 11465 | sta_mac_str = strtok_r(NULL, " ", &saveptr); |
| 11466 | if (sta_mac_str && nss[3]) { |
| 11467 | run_system_wrapper(dut, |
| 11468 | "wifitool %s chmask_persta %s %s", |
| 11469 | ifname, sta_mac_str, nss[3]); |
| 11470 | } |
| 11471 | |
| 11472 | free(sta_mac_list_str); |
| 11473 | } |
| 11474 | |
| 11475 | free(num_ss); |
| 11476 | num_ss = NULL; |
| 11477 | |
Priyadharshini Gowthaman | dca0c54 | 2019-08-09 12:04:42 -0700 | [diff] [blame] | 11478 | val = get_param(cmd, "AID"); |
| 11479 | if (val) { |
| 11480 | int i = 0; |
| 11481 | char *aid_val; |
| 11482 | char *saveptr; |
| 11483 | |
| 11484 | aid_ss = strdup(val); |
| 11485 | if (!aid_ss) |
| 11486 | return ERROR_SEND_STATUS; |
| 11487 | |
| 11488 | aid_val = strtok_r(aid_ss, " ", &saveptr); |
| 11489 | for (i = 0; aid_val && i < 4; i++) { |
| 11490 | aid[i] = aid_val; |
| 11491 | aid_val = strtok_r(NULL, " ", &saveptr); |
| 11492 | } |
| 11493 | } |
| 11494 | |
| 11495 | val = get_param(cmd, "AddbaReq"); |
| 11496 | if (val) { |
| 11497 | if (strcasecmp(val, "enable") == 0) { |
| 11498 | run_iwpriv(dut, ifname, "setaddbaoper 1"); |
| 11499 | run_system_wrapper(dut, |
| 11500 | "wifitool %s sendaddba %s 0 64", |
| 11501 | ifname, aid[0]); |
| 11502 | } else { |
| 11503 | send_resp(dut, conn, SIGMA_ERROR, |
| 11504 | "errorCode,Unsupported AddbaReq value"); |
| 11505 | free(aid_ss); |
| 11506 | return STATUS_SENT_ERROR; |
| 11507 | } |
| 11508 | } |
| 11509 | |
| 11510 | val = get_param(cmd, "AddbaResp"); |
| 11511 | if (val) { |
| 11512 | if (aid_ss && strcasecmp(val, "accepted") == 0) { |
| 11513 | int aid_1 = atoi(aid_ss); |
| 11514 | |
| 11515 | if (aid_1 == 1) |
| 11516 | aid_1 = 2; |
| 11517 | else |
| 11518 | aid_1 = aid_1 - 1; |
| 11519 | |
| 11520 | /* There is no mechanism in place to reject Add BA Req |
| 11521 | * from all STAs and selectively accept Add BA Req from |
| 11522 | * a specified STA. Instead, it can accept Add BA Req |
| 11523 | * from all STAs and selectively reject from specified |
| 11524 | * STAs. Make changes for the same using the below |
| 11525 | * commands. */ |
| 11526 | run_system_wrapper(dut, ifname, "setaddbaoper 1"); |
| 11527 | run_system_wrapper(dut, "wifitool %s refusealladdbas 0", |
| 11528 | ifname); |
| 11529 | run_system_wrapper(dut, |
| 11530 | "wifitool %s setaddbaresp %d 0 37", |
| 11531 | ifname, aid_1); |
| 11532 | } else { |
| 11533 | send_resp(dut, conn, SIGMA_ERROR, |
| 11534 | "errorCode,Unsupported Addbaresp value"); |
| 11535 | free(aid_ss); |
| 11536 | return STATUS_SENT_ERROR; |
| 11537 | } |
| 11538 | } |
| 11539 | |
| 11540 | val = get_param(cmd, "Trig_UsrInfo_SSAlloc_RA-RU"); |
| 11541 | if (val) { |
| 11542 | char *ssalloc_str; |
| 11543 | char *saveptr; |
| 11544 | char *ssalloc_list_str; |
| 11545 | |
| 11546 | ssalloc_list_str = strdup(val); |
| 11547 | if (!ssalloc_list_str) { |
| 11548 | free(aid_ss); |
| 11549 | return ERROR_SEND_STATUS; |
| 11550 | } |
| 11551 | |
| 11552 | ssalloc_str = strtok_r(ssalloc_list_str, ":", &saveptr); |
| 11553 | if (ssalloc_str && aid[0]) { |
| 11554 | run_system_wrapper(dut, "wifitool %s peer_nss %s %s", |
| 11555 | ifname, aid[0], ssalloc_str); |
| 11556 | } |
| 11557 | |
| 11558 | ssalloc_str = strtok_r(NULL, " ", &saveptr); |
| 11559 | if (ssalloc_str && aid[1]) { |
| 11560 | run_system_wrapper(dut, "wifitool %s peer_nss %s %s", |
| 11561 | ifname, aid[1], ssalloc_str); |
| 11562 | } |
| 11563 | |
| 11564 | ssalloc_str = strtok_r(NULL, " ", &saveptr); |
| 11565 | if (ssalloc_str && aid[2]) { |
| 11566 | run_system_wrapper(dut, "wifitool %s peer_nss %s %s", |
| 11567 | ifname, aid[2], ssalloc_str); |
| 11568 | } |
| 11569 | |
| 11570 | ssalloc_str = strtok_r(NULL, " ", &saveptr); |
| 11571 | if (ssalloc_str && aid[3]) { |
| 11572 | run_system_wrapper(dut, "wifitool %s peer_nss %s %s", |
| 11573 | ifname, aid[3], ssalloc_str); |
| 11574 | } |
| 11575 | |
| 11576 | free(ssalloc_list_str); |
| 11577 | } |
| 11578 | |
| 11579 | free(aid_ss); |
| 11580 | aid_ss = NULL; |
| 11581 | |
Priyadharshini Gowthaman | 2da1ecc | 2019-08-09 12:04:54 -0700 | [diff] [blame] | 11582 | val = get_param(cmd, "OMCtrl_RxNSS"); |
| 11583 | if (val) |
| 11584 | omctrl_rxnss = atoi(val); |
| 11585 | |
| 11586 | val = get_param(cmd, "OMCtrl_ChnlWidth"); |
| 11587 | if (val) |
| 11588 | omctrl_chwidth = atoi(val); |
| 11589 | |
| 11590 | val = get_param(cmd, "Client_mac"); |
| 11591 | if (val) { |
| 11592 | if (parse_mac_address(dut, val, mac_addr) < 0) { |
| 11593 | send_resp(dut, conn, SIGMA_ERROR, |
| 11594 | "errorCode,MAC Address not in proper format"); |
| 11595 | return STATUS_SENT_ERROR; |
| 11596 | } |
| 11597 | |
| 11598 | /* setUnitTestCmd 13 7 1 mac3mac2mac1mac0 mac5mac4 <rx_nss> |
| 11599 | * <bw> <ulmu> <tx_nss> */ |
| 11600 | run_system_wrapper(dut, |
| 11601 | "wifitool %s setUnitTestCmd 13 7 1 0x%02x%02x%02x%02x 0x%02x%02x %d %d 1 %d", |
| 11602 | ifname, mac_addr[3], mac_addr[2], |
| 11603 | mac_addr[1], mac_addr[0], mac_addr[5], |
| 11604 | mac_addr[4], omctrl_rxnss, |
| 11605 | omctrl_chwidth, omctrl_rxnss); |
| 11606 | } |
| 11607 | |
Priyadharshini Gowthaman | 7e43870 | 2019-08-09 12:05:05 -0700 | [diff] [blame] | 11608 | val = get_param(cmd, "TriggerType"); |
| 11609 | if (val) { |
| 11610 | trigtype = atoi(val); |
| 11611 | switch (trigtype) { |
| 11612 | case 0: |
| 11613 | ath_set_trigger_type_0(dut, ifname); |
| 11614 | break; |
| 11615 | case 1: |
| 11616 | ath_set_trigger_type_1(dut, ifname); |
| 11617 | break; |
| 11618 | case 2: |
| 11619 | ath_set_trigger_type_2(dut, ifname); |
| 11620 | break; |
| 11621 | case 3: |
| 11622 | ath_set_trigger_type_3(dut, ifname); |
| 11623 | break; |
| 11624 | case 4: |
| 11625 | ath_set_trigger_type_4(dut, ifname, basedev); |
| 11626 | break; |
| 11627 | default: |
| 11628 | send_resp(dut, conn, SIGMA_ERROR, |
| 11629 | "errorCode,TriggerType not supported"); |
| 11630 | return STATUS_SENT_ERROR; |
| 11631 | } |
| 11632 | } |
| 11633 | |
Priyadharshini Gowthaman | c352d82 | 2019-08-09 12:05:16 -0700 | [diff] [blame] | 11634 | val = get_param(cmd, "HE_TXOPDurRTSThr"); |
| 11635 | if (val) |
| 11636 | run_iwpriv(dut, ifname, "he_rtsthrshld %d", atoi(val)); |
| 11637 | |
| 11638 | val = get_param(cmd, "NAV_Update"); |
| 11639 | if (val) { |
| 11640 | if (strcasecmp(val, "disable") == 0) { |
| 11641 | run_iwpriv(dut, basedev, "nav_config 1 0"); |
| 11642 | } else if (strcasecmp(val, "enable") == 0) { |
| 11643 | /* Do nothing */ |
| 11644 | } else { |
| 11645 | send_resp(dut, conn, SIGMA_ERROR, |
| 11646 | "errorCode,Unsupported NAV update"); |
| 11647 | return STATUS_SENT_ERROR; |
| 11648 | } |
| 11649 | } |
| 11650 | |
Priyadharshini Gowthaman | 872fb29 | 2019-08-09 12:05:27 -0700 | [diff] [blame] | 11651 | /* Configure WMM Parameter Elements */ |
| 11652 | val = get_param(cmd, "STA_WMMPE_ECWmin_BE"); |
| 11653 | if (val) { |
| 11654 | param = atoi(val); |
| 11655 | run_iwpriv(dut, ifname, "cwmin %d 1 %d", AP_AC_BE, param); |
| 11656 | } |
| 11657 | |
| 11658 | val = get_param(cmd, "STA_WMMPE_ECWmin_BK"); |
| 11659 | if (val) { |
| 11660 | param = atoi(val); |
| 11661 | run_iwpriv(dut, ifname, "cwmin %d 1 %d", AP_AC_BK, param); |
| 11662 | } |
| 11663 | |
| 11664 | val = get_param(cmd, "STA_WMMPE_ECWmin_VI"); |
| 11665 | if (val) { |
| 11666 | param = atoi(val); |
| 11667 | run_iwpriv(dut, ifname, "cwmin %d 1 %d", AP_AC_VI, param); |
| 11668 | } |
| 11669 | |
| 11670 | val = get_param(cmd, "STA_WMMPE_ECWmin_VO"); |
| 11671 | if (val) { |
| 11672 | param = atoi(val); |
| 11673 | run_iwpriv(dut, ifname, "cwmin %d 1 %d", AP_AC_VO, param); |
| 11674 | } |
| 11675 | |
| 11676 | val = get_param(cmd, "STA_WMMPE_ECWmax_BE"); |
| 11677 | if (val) { |
| 11678 | param = atoi(val); |
| 11679 | run_iwpriv(dut, ifname, "cwmax %d 1 %d", AP_AC_BE, param); |
| 11680 | } |
| 11681 | |
| 11682 | val = get_param(cmd, "STA_WMMPE_ECWmax_BK"); |
| 11683 | if (val) { |
| 11684 | param = atoi(val); |
| 11685 | run_iwpriv(dut, ifname, "cwmax %d 1 %d", AP_AC_BK, param); |
| 11686 | } |
| 11687 | |
| 11688 | val = get_param(cmd, "STA_WMMPE_ECWmax_VI"); |
| 11689 | if (val) { |
| 11690 | param = atoi(val); |
| 11691 | run_iwpriv(dut, ifname, "cwmax %d 1 %d", AP_AC_VI, param); |
| 11692 | } |
| 11693 | |
| 11694 | val = get_param(cmd, "STA_WMMPE_ECWmax_VO"); |
| 11695 | if (val) { |
| 11696 | param = atoi(val); |
| 11697 | run_iwpriv(dut, ifname, "cwmax %d 1 %d", AP_AC_VO, param); |
| 11698 | } |
| 11699 | |
| 11700 | val = get_param(cmd, "STA_WMMPE_AIFSN_BE"); |
| 11701 | if (val) { |
| 11702 | param = atoi(val); |
| 11703 | run_iwpriv(dut, ifname, "aifs %d 1 %d", AP_AC_BE, param); |
| 11704 | } |
| 11705 | |
| 11706 | val = get_param(cmd, "STA_WMMPE_AIFSN_BK"); |
| 11707 | if (val) { |
| 11708 | param = atoi(val); |
| 11709 | run_iwpriv(dut, ifname, "aifs %d 1 %d", AP_AC_BK, param); |
| 11710 | } |
| 11711 | |
| 11712 | val = get_param(cmd, "STA_WMMPE_AIFSN_VI"); |
| 11713 | if (val) { |
| 11714 | param = atoi(val); |
| 11715 | run_iwpriv(dut, ifname, "aifs %d 1 %d", AP_AC_VI, param); |
| 11716 | } |
| 11717 | |
| 11718 | val = get_param(cmd, "STA_WMMPE_AIFSN_VO"); |
| 11719 | if (val) { |
| 11720 | param = atoi(val); |
| 11721 | run_iwpriv(dut, ifname, "aifs %d 1 %d", AP_AC_VO, param); |
| 11722 | } |
| 11723 | |
| 11724 | |
| 11725 | val = get_param(cmd, "STA_WMMPE_TXOP_BE"); |
| 11726 | if (val) { |
| 11727 | param = atoi(val); |
| 11728 | run_iwpriv(dut, ifname, "txoplimit %d 1 %d", AP_AC_BE, param); |
| 11729 | } |
| 11730 | |
| 11731 | val = get_param(cmd, "STA_WMMPE_TOXP_BK"); |
| 11732 | if (val) { |
| 11733 | param = atoi(val); |
| 11734 | run_iwpriv(dut, ifname, "txoplimit %d 1 %d", AP_AC_BK, param); |
| 11735 | } |
| 11736 | |
| 11737 | val = get_param(cmd, "STA_WMMPE_TXOP_VI"); |
| 11738 | if (val) { |
| 11739 | param = atoi(val); |
| 11740 | run_iwpriv(dut, ifname, "txoplimit %d %d", AP_AC_VI, param); |
| 11741 | } |
| 11742 | |
| 11743 | val = get_param(cmd, "STA_WMMPE_TXOP_VO"); |
| 11744 | if (val) { |
| 11745 | param = atoi(val); |
| 11746 | run_iwpriv(dut, ifname, "txoplimit %d 1 %d", AP_AC_VO, param); |
| 11747 | } |
| 11748 | |
Priyadharshini Gowthaman | c46b7e4 | 2019-08-09 12:05:37 -0700 | [diff] [blame] | 11749 | /* Configure MU EDCA */ |
| 11750 | val = get_param(cmd, "STA_MUEDCA_ECWmin_BE"); |
| 11751 | if (val) { |
| 11752 | param = atoi(val); |
| 11753 | run_iwpriv(dut, ifname, "muedca_ecwmin %d %d", AP_AC_BE, param); |
| 11754 | } |
| 11755 | |
| 11756 | val = get_param(cmd, "STA_MUEDCA_ECWmin_BK"); |
| 11757 | if (val) { |
| 11758 | param = atoi(val); |
| 11759 | run_iwpriv(dut, ifname, "muedca_ecwmin %d %d", AP_AC_BK, param); |
| 11760 | } |
| 11761 | |
| 11762 | val = get_param(cmd, "STA_MUEDCA_ECWmin_VI"); |
| 11763 | if (val) { |
| 11764 | param = atoi(val); |
| 11765 | run_iwpriv(dut, ifname, "muedca_ecwmin %d %d", AP_AC_VI, param); |
| 11766 | } |
| 11767 | |
| 11768 | val = get_param(cmd, "STA_MUEDCA_ECWmin_VO"); |
| 11769 | if (val) { |
| 11770 | param = atoi(val); |
| 11771 | run_iwpriv(dut, ifname, "muedca_ecwmin %d %d", AP_AC_VO, param); |
| 11772 | } |
| 11773 | |
| 11774 | val = get_param(cmd, "STA_MUEDCA_ECWmax_BE"); |
| 11775 | if (val) { |
| 11776 | param = atoi(val); |
| 11777 | run_iwpriv(dut, ifname, "muedca_ecwmax %d %d", AP_AC_BE, param); |
| 11778 | } |
| 11779 | |
| 11780 | val = get_param(cmd, "STA_MUEDCA_ECWmax_BK"); |
| 11781 | if (val) { |
| 11782 | param = atoi(val); |
| 11783 | run_iwpriv(dut, ifname, "muedca_ecwmax %d %d", AP_AC_BK, param); |
| 11784 | } |
| 11785 | |
| 11786 | val = get_param(cmd, "STA_MUEDCA_ECWmax_VI"); |
| 11787 | if (val) { |
| 11788 | param = atoi(val); |
| 11789 | run_iwpriv(dut, ifname, "muedca_ecwmax %d %d", AP_AC_VI, param); |
| 11790 | } |
| 11791 | |
| 11792 | val = get_param(cmd, "STA_MUEDCA_ECWmax_VO"); |
| 11793 | if (val) { |
| 11794 | param = atoi(val); |
| 11795 | run_iwpriv(dut, ifname, "muedca_ecwmax %d %d", AP_AC_VO, param); |
| 11796 | } |
| 11797 | |
| 11798 | val = get_param(cmd, "STA_MUEDCA_AIFSN_BE"); |
| 11799 | if (val) { |
| 11800 | param = atoi(val); |
| 11801 | run_iwpriv(dut, ifname, "muedca_aifsn %d %d", AP_AC_BE, param); |
| 11802 | } |
| 11803 | |
| 11804 | val = get_param(cmd, "STA_MUEDCA_AIFSN_BK"); |
| 11805 | if (val) { |
| 11806 | param = atoi(val); |
| 11807 | run_iwpriv(dut, ifname, "muedca_aifsn %d %d", AP_AC_BK, param); |
| 11808 | } |
| 11809 | |
| 11810 | val = get_param(cmd, "STA_MUEDCA_AIFSN_VI"); |
| 11811 | if (val) { |
| 11812 | param = atoi(val); |
| 11813 | run_iwpriv(dut, ifname, "muedca_aifsn %d %d", AP_AC_VI, param); |
| 11814 | } |
| 11815 | |
| 11816 | val = get_param(cmd, "STA_MUEDCA_AIFSN_VO"); |
| 11817 | if (val) { |
| 11818 | param = atoi(val); |
| 11819 | run_iwpriv(dut, ifname, "muedca_aifsn %d %d", AP_AC_VO, param); |
| 11820 | } |
| 11821 | |
| 11822 | val = get_param(cmd, "STA_MUEDCA_Timer_BE"); |
| 11823 | if (val) { |
| 11824 | param = atoi(val); |
| 11825 | run_iwpriv(dut, ifname, "muedca_timer %d %d", AP_AC_BE, param); |
| 11826 | } |
| 11827 | |
| 11828 | val = get_param(cmd, "STA_MUEDCA_Timer_BK"); |
| 11829 | if (val) { |
| 11830 | param = atoi(val); |
| 11831 | run_iwpriv(dut, ifname, "muedca_timer %d %d", AP_AC_BK, param); |
| 11832 | } |
| 11833 | |
| 11834 | val = get_param(cmd, "STA_MUEDCA_Timer_VI"); |
| 11835 | if (val) { |
| 11836 | param = atoi(val); |
| 11837 | run_iwpriv(dut, ifname, "muedca_timer %d %d", AP_AC_VI, param); |
| 11838 | } |
| 11839 | |
| 11840 | val = get_param(cmd, "STA_MUEDCA_Timer_VO"); |
| 11841 | if (val) { |
| 11842 | param = atoi(val); |
| 11843 | run_iwpriv(dut, ifname, "muedca_timer %d %d", AP_AC_VO, param); |
| 11844 | } |
| 11845 | |
Jouni Malinen | 6076ffc | 2019-08-08 18:18:02 +0300 | [diff] [blame] | 11846 | return SUCCESS_SEND_STATUS; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 11847 | } |
| 11848 | |
| 11849 | |
Pradeep Reddy POTTETI | 88fd82c | 2016-03-14 12:20:18 +0530 | [diff] [blame] | 11850 | static int wcn_vht_chnum_band(struct sigma_dut *dut, const char *ifname, |
| 11851 | const char *val) |
| 11852 | { |
| 11853 | char *token, *result; |
| 11854 | int channel = 36; |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 11855 | char *saveptr; |
Pradeep Reddy POTTETI | 88fd82c | 2016-03-14 12:20:18 +0530 | [diff] [blame] | 11856 | |
| 11857 | /* Extract the channel info */ |
| 11858 | token = strdup(val); |
| 11859 | if (!token) |
| 11860 | return -1; |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 11861 | result = strtok_r(token, ";", &saveptr); |
Pradeep Reddy POTTETI | 88fd82c | 2016-03-14 12:20:18 +0530 | [diff] [blame] | 11862 | if (result) |
| 11863 | channel = atoi(result); |
| 11864 | |
| 11865 | /* Issue the channel switch command */ |
Priyadharshini Gowthaman | d06f100 | 2019-04-22 15:45:41 -0700 | [diff] [blame] | 11866 | run_iwpriv(dut, ifname, "setChanChange %d", channel); |
Pradeep Reddy POTTETI | 88fd82c | 2016-03-14 12:20:18 +0530 | [diff] [blame] | 11867 | |
| 11868 | free(token); |
| 11869 | return 0; |
| 11870 | } |
| 11871 | |
| 11872 | |
| 11873 | static int wcn_ap_set_rfeature(struct sigma_dut *dut, struct sigma_conn *conn, |
| 11874 | struct sigma_cmd *cmd) |
| 11875 | { |
| 11876 | const char *val; |
| 11877 | char *ifname; |
| 11878 | |
| 11879 | ifname = get_main_ifname(); |
| 11880 | |
| 11881 | val = get_param(cmd, "chnum_band"); |
| 11882 | if (val && wcn_vht_chnum_band(dut, ifname, val) < 0) |
| 11883 | return -1; |
| 11884 | |
| 11885 | return 1; |
| 11886 | } |
| 11887 | |
| 11888 | |
Mohammed Shafi Shajakhan | b53d8f9 | 2017-02-28 09:05:15 +0530 | [diff] [blame] | 11889 | static int mac80211_vht_chnum_band(struct sigma_dut *dut, const char *ifname, |
| 11890 | const char *val) |
| 11891 | { |
| 11892 | char *token, *result; |
| 11893 | int channel = 36, chwidth = 80, center_freq_idx, center_freq, |
| 11894 | channel_freq; |
| 11895 | char buf[100]; |
| 11896 | char *saveptr; |
Jouni Malinen | 3aa7286 | 2019-05-29 23:14:51 +0300 | [diff] [blame] | 11897 | int res; |
Mohammed Shafi Shajakhan | b53d8f9 | 2017-02-28 09:05:15 +0530 | [diff] [blame] | 11898 | |
| 11899 | /* Extract the channel info */ |
| 11900 | token = strdup(val); |
| 11901 | if (!token) |
| 11902 | return -1; |
| 11903 | result = strtok_r(token, ";", &saveptr); |
| 11904 | if (result) |
| 11905 | channel = atoi(result); |
| 11906 | |
| 11907 | /* Extract the channel width info */ |
| 11908 | result = strtok_r(NULL, ";", &saveptr); |
| 11909 | if (result) |
| 11910 | chwidth = atoi(result); |
| 11911 | |
| 11912 | center_freq_idx = get_oper_centr_freq_seq_idx(chwidth, channel); |
| 11913 | if (center_freq_idx < 0) { |
| 11914 | free(token); |
| 11915 | return -1; |
| 11916 | } |
| 11917 | |
| 11918 | center_freq = get_5g_channel_freq(center_freq_idx); |
| 11919 | channel_freq = get_5g_channel_freq(channel); |
| 11920 | |
| 11921 | /* Issue the channel switch command */ |
Jouni Malinen | 3aa7286 | 2019-05-29 23:14:51 +0300 | [diff] [blame] | 11922 | res = snprintf(buf, sizeof(buf), |
| 11923 | " -i %s chan_switch 10 %d sec_channel_offset=1 center_freq1=%d bandwidth=%d blocktx vht", |
| 11924 | ifname, channel_freq, center_freq, chwidth); |
| 11925 | 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] | 11926 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 11927 | "hostapd_cli chan_switch failed"); |
| 11928 | } |
| 11929 | |
| 11930 | free(token); |
| 11931 | return 0; |
| 11932 | } |
| 11933 | |
| 11934 | |
| 11935 | static int mac80211_ap_set_rfeature(struct sigma_dut *dut, |
| 11936 | struct sigma_conn *conn, |
| 11937 | struct sigma_cmd *cmd) |
| 11938 | { |
| 11939 | const char *val; |
| 11940 | char *ifname; |
| 11941 | |
| 11942 | ifname = get_main_ifname(); |
| 11943 | val = get_param(cmd, "chnum_band"); |
| 11944 | if (val && mac80211_vht_chnum_band(dut, ifname, val) < 0) |
| 11945 | return -1; |
| 11946 | |
| 11947 | return 1; |
| 11948 | } |
| 11949 | |
| 11950 | |
Alexei Avshalom Lazar | bc180dc | 2018-12-18 16:01:14 +0200 | [diff] [blame] | 11951 | #ifdef __linux__ |
| 11952 | static int wil6210_ap_set_rfeature(struct sigma_dut *dut, |
| 11953 | struct sigma_conn *conn, |
| 11954 | struct sigma_cmd *cmd) |
| 11955 | { |
| 11956 | const char *val; |
| 11957 | |
| 11958 | val = get_param(cmd, "ExtSchIE"); |
| 11959 | if (val && !strcasecmp(val, "Enable")) { |
| 11960 | struct sigma_ese_alloc allocs[MAX_ESE_ALLOCS]; |
| 11961 | int count = MAX_ESE_ALLOCS; |
| 11962 | |
| 11963 | if (sta_extract_60g_ese(dut, cmd, allocs, &count)) |
| 11964 | return -1; |
| 11965 | if (wil6210_set_ese(dut, count, allocs)) |
| 11966 | return -1; |
| 11967 | return 1; |
| 11968 | } |
| 11969 | |
| 11970 | send_resp(dut, conn, SIGMA_ERROR, |
| 11971 | "errorCode,Invalid ap_set_rfeature(60G)"); |
| 11972 | return 0; |
| 11973 | } |
| 11974 | #endif /* __linux__ */ |
| 11975 | |
| 11976 | |
Jouni Malinen | f722271 | 2019-06-13 01:50:21 +0300 | [diff] [blame] | 11977 | static enum sigma_cmd_result cmd_ap_set_rfeature(struct sigma_dut *dut, |
| 11978 | struct sigma_conn *conn, |
| 11979 | struct sigma_cmd *cmd) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 11980 | { |
| 11981 | /* const char *name = get_param(cmd, "NAME"); */ |
| 11982 | /* const char *type = get_param(cmd, "Type"); */ |
| 11983 | |
| 11984 | switch (get_driver_type()) { |
| 11985 | case DRIVER_ATHEROS: |
| 11986 | return ath_ap_set_rfeature(dut, conn, cmd); |
| 11987 | case DRIVER_OPENWRT: |
| 11988 | switch (get_openwrt_driver_type()) { |
| 11989 | case OPENWRT_DRIVER_ATHEROS: |
| 11990 | return ath_ap_set_rfeature(dut, conn, cmd); |
| 11991 | default: |
| 11992 | send_resp(dut, conn, SIGMA_ERROR, |
| 11993 | "errorCode,Unsupported ap_set_rfeature with the current openwrt driver"); |
| 11994 | return 0; |
| 11995 | } |
Sreelakshmi Konamki | 0e4fcf9 | 2016-04-26 19:55:01 +0530 | [diff] [blame] | 11996 | case DRIVER_LINUX_WCN: |
Pradeep Reddy POTTETI | 88fd82c | 2016-03-14 12:20:18 +0530 | [diff] [blame] | 11997 | case DRIVER_WCN: |
| 11998 | return wcn_ap_set_rfeature(dut, conn, cmd); |
Mohammed Shafi Shajakhan | b53d8f9 | 2017-02-28 09:05:15 +0530 | [diff] [blame] | 11999 | case DRIVER_MAC80211: |
| 12000 | return mac80211_ap_set_rfeature(dut, conn, cmd); |
Alexei Avshalom Lazar | bc180dc | 2018-12-18 16:01:14 +0200 | [diff] [blame] | 12001 | #ifdef __linux__ |
| 12002 | case DRIVER_WIL6210: |
| 12003 | return wil6210_ap_set_rfeature(dut, conn, cmd); |
| 12004 | #endif /* __linux__ */ |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 12005 | default: |
| 12006 | send_resp(dut, conn, SIGMA_ERROR, |
| 12007 | "errorCode,Unsupported ap_set_rfeature with the current driver"); |
| 12008 | return 0; |
| 12009 | } |
| 12010 | } |
| 12011 | |
| 12012 | |
Jouni Malinen | f722271 | 2019-06-13 01:50:21 +0300 | [diff] [blame] | 12013 | static enum sigma_cmd_result cmd_accesspoint(struct sigma_dut *dut, |
| 12014 | struct sigma_conn *conn, |
| 12015 | struct sigma_cmd *cmd) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 12016 | { |
| 12017 | /* const char *name = get_param(cmd, "NAME"); */ |
| 12018 | return 1; |
| 12019 | } |
| 12020 | |
| 12021 | |
Jouni Malinen | f722271 | 2019-06-13 01:50:21 +0300 | [diff] [blame] | 12022 | static enum sigma_cmd_result |
| 12023 | cmd_ap_preset_testparameters(struct sigma_dut *dut, struct sigma_conn *conn, |
| 12024 | struct sigma_cmd *cmd) |
priyadharshini gowthaman | 9149afc | 2018-01-15 13:40:18 -0800 | [diff] [blame] | 12025 | { |
| 12026 | const char *val; |
| 12027 | |
| 12028 | val = get_param(cmd, "Oper_Chn"); |
| 12029 | if (val) { |
| 12030 | dut->ap_oper_chn = 1; |
| 12031 | dut->ap_channel = atoi(val); |
| 12032 | } |
| 12033 | |
Jouni Malinen | ba4f2d4 | 2019-10-04 16:13:41 +0300 | [diff] [blame] | 12034 | val = get_param(cmd, "DPPConfiguratorAddress"); |
| 12035 | if (val) { |
| 12036 | free(dut->ap_dpp_conf_addr); |
| 12037 | dut->ap_dpp_conf_addr = strdup(val); |
| 12038 | } |
| 12039 | |
| 12040 | val = get_param(cmd, "DPPConfiguratorPKHash"); |
| 12041 | if (val) { |
| 12042 | free(dut->ap_dpp_conf_pkhash); |
| 12043 | dut->ap_dpp_conf_pkhash = strdup(val); |
| 12044 | } |
| 12045 | |
priyadharshini gowthaman | 9149afc | 2018-01-15 13:40:18 -0800 | [diff] [blame] | 12046 | return 1; |
| 12047 | } |
| 12048 | |
| 12049 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 12050 | void ap_register_cmds(void) |
| 12051 | { |
| 12052 | sigma_dut_reg_cmd("ap_ca_version", NULL, cmd_ap_ca_version); |
| 12053 | sigma_dut_reg_cmd("ap_set_wireless", NULL, cmd_ap_set_wireless); |
| 12054 | sigma_dut_reg_cmd("ap_send_addba_req", NULL, cmd_ap_send_addba_req); |
| 12055 | sigma_dut_reg_cmd("ap_set_11n_wireless", NULL, cmd_ap_set_wireless); |
| 12056 | sigma_dut_reg_cmd("ap_set_11n", NULL, cmd_ap_set_wireless); |
| 12057 | 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] | 12058 | sigma_dut_reg_cmd("ap_set_11h", NULL, cmd_ap_set_wireless); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 12059 | sigma_dut_reg_cmd("ap_set_security", NULL, cmd_ap_set_security); |
| 12060 | sigma_dut_reg_cmd("ap_set_apqos", NULL, cmd_ap_set_apqos); |
| 12061 | sigma_dut_reg_cmd("ap_set_staqos", NULL, cmd_ap_set_staqos); |
| 12062 | sigma_dut_reg_cmd("ap_set_radius", NULL, cmd_ap_set_radius); |
| 12063 | sigma_dut_reg_cmd("ap_reboot", NULL, cmd_ap_reboot); |
| 12064 | sigma_dut_reg_cmd("ap_config_commit", NULL, cmd_ap_config_commit); |
| 12065 | sigma_dut_reg_cmd("ap_reset_default", NULL, cmd_ap_reset_default); |
| 12066 | sigma_dut_reg_cmd("ap_get_info", NULL, cmd_ap_get_info); |
| 12067 | sigma_dut_reg_cmd("ap_deauth_sta", NULL, cmd_ap_deauth_sta); |
| 12068 | sigma_dut_reg_cmd("ap_send_frame", NULL, cmd_ap_send_frame); |
| 12069 | sigma_dut_reg_cmd("ap_get_mac_address", NULL, cmd_ap_get_mac_address); |
| 12070 | sigma_dut_reg_cmd("ap_set_pmf", NULL, cmd_ap_set_pmf); |
| 12071 | sigma_dut_reg_cmd("ap_set_hs2", NULL, cmd_ap_set_hs2); |
| 12072 | sigma_dut_reg_cmd("ap_set_rfeature", NULL, cmd_ap_set_rfeature); |
| 12073 | sigma_dut_reg_cmd("ap_nfc_action", NULL, cmd_ap_nfc_action); |
| 12074 | 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] | 12075 | sigma_dut_reg_cmd("ap_wps_enter_pin", NULL, cmd_ap_wps_enter_pin); |
| 12076 | 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] | 12077 | sigma_dut_reg_cmd("ap_get_parameter", NULL, cmd_ap_get_parameter); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 12078 | sigma_dut_reg_cmd("AccessPoint", NULL, cmd_accesspoint); |
priyadharshini gowthaman | 9149afc | 2018-01-15 13:40:18 -0800 | [diff] [blame] | 12079 | sigma_dut_reg_cmd("ap_preset_testparameters", NULL, |
| 12080 | cmd_ap_preset_testparameters); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 12081 | } |