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 | c12ea4a | 2018-01-05 21:07:10 +0200 | [diff] [blame] | 5 | * Copyright (c) 2018, 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__ */ |
| 26 | #include "wpa_helpers.h" |
| 27 | #ifdef ANDROID |
| 28 | #include <hardware_legacy/wifi.h> |
Veerendranath Jakkam | d7e0008 | 2018-04-25 19:46:01 +0530 | [diff] [blame] | 29 | #include <grp.h> |
| 30 | #include <pwd.h> |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 31 | #endif /* ANDROID */ |
| 32 | |
| 33 | /* Temporary files for ap_send_addba_req */ |
| 34 | #define VI_QOS_TMP_FILE "/tmp/vi-qos.tmp" |
| 35 | #define VI_QOS_FILE "/tmp/vi-qos.txt" |
| 36 | #define VI_QOS_REFFILE "/etc/vi-qos.txt" |
| 37 | |
| 38 | /* Configuration file name on Android */ |
| 39 | #ifndef ANDROID_CONFIG_FILE |
| 40 | #define ANDROID_CONFIG_FILE "/data/misc/wifi/hostapd.conf" |
| 41 | #endif /* ANDROID_CONFIG_FILE */ |
| 42 | /* Maximum length of the line in the configuration file */ |
| 43 | #define MAX_CONF_LINE_LEN (156) |
| 44 | |
Jouni Malinen | d6bf1b4 | 2017-06-23 17:51:01 +0300 | [diff] [blame] | 45 | #ifndef SIGMA_DUT_HOSTAPD_PID_FILE |
| 46 | #define SIGMA_DUT_HOSTAPD_PID_FILE "/tmp/sigma_dut-ap-hostapd.pid" |
| 47 | #endif /* SIGMA_DUT_HOSTAPD_PID_FILE */ |
| 48 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 49 | /* The following is taken from Hotspot 2.0 testplan Appendix B.1 */ |
| 50 | #define ANQP_VENUE_NAME_1 "02019c0002083d656e6757692d466920416c6c69616e63650a3239383920436f7070657220526f61640a53616e746120436c6172612c2043412039353035312c205553415b63686957692d4669e88194e79b9fe5ae9ee9aa8ce5aea40ae4ba8ce4b99de585abe4b99de5b9b4e5ba93e69f8fe8b7af0ae59ca3e5858be68b89e68b892c20e58aa0e588a9e7a68fe5b0bce4ba9a39353035312c20e7be8ee59bbd" |
| 51 | #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\"" |
| 52 | #define ANQP_IP_ADDR_TYPE_1 "060101000c" |
| 53 | #define ANQP_HS20_OPERATOR_FRIENDLY_NAME_1 "dddd2700506f9a11030011656e6757692d466920416c6c69616e63650e63686957692d4669e88194e79b9f" |
| 54 | #define ANQP_HS20_WAN_METRICS_1 "dddd1300506f9a11040001c40900008001000000000000" |
| 55 | #define ANQP_HS20_CONNECTION_CAPABILITY_1 "dddd3200506f9a1105000100000006140001061600000650000106bb010106bb060006c4130011f4010111c413001194110132000001" |
| 56 | #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" |
| 57 | #define QOS_MAP_SET_2 "8,15,0,7,255,255,16,31,32,39,255,255,40,47,48,63" |
| 58 | |
Jouni Malinen | f7ff42b | 2018-05-01 00:21:56 +0300 | [diff] [blame] | 59 | #define ADV_OF_CHARGE_1 \ |
Jouni Malinen | 3001b43 | 2018-05-03 18:18:15 +0300 | [diff] [blame] | 60 | "bc01000000d200454e475553443c3f786d6c2076657273696f6e3d22312e30222065" \ |
Jouni Malinen | f7ff42b | 2018-05-01 00:21:56 +0300 | [diff] [blame] | 61 | "6e636f64696e673d225554462d38223f3e3c506c616e20786d6c6e733d22687474703a2f2f77" \ |
| 62 | "77772e77692d66692e6f72672f73706563696669636174696f6e732f686f7473706f7432646f" \ |
| 63 | "74302f76312e302f616f637069223e3c4465736372697074696f6e3e57692d46692061636365" \ |
| 64 | "737320666f72203120686f75722c207768696c6520796f752077616974206174207468652067" \ |
Jouni Malinen | 3001b43 | 2018-05-03 18:18:15 +0300 | [diff] [blame] | 65 | "6174652c2024302e39393c2f4465736372697074696f6e3e3c2f506c616e3ee3004652414341" \ |
Jouni Malinen | f7ff42b | 2018-05-01 00:21:56 +0300 | [diff] [blame] | 66 | "443c3f786d6c2076657273696f6e3d22312e302220656e636f64696e673d225554462d38223f" \ |
| 67 | "3e3c506c616e20786d6c6e733d22687474703a2f2f7777772e77692d66692e6f72672f737065" \ |
| 68 | "63696669636174696f6e732f686f7473706f7432646f74302f76312e302f616f637069223e3c" \ |
Jouni Malinen | 3001b43 | 2018-05-03 18:18:15 +0300 | [diff] [blame] | 69 | "4465736372697074696f6e3e416363c3a8732057692d46692070656e64616e74203120686575" \ |
| 70 | "72652c2070656e64616e742071756520766f757320617474656e64657a20c3a0206c6120706f" \ |
| 71 | "7274652c20302c393920243c2f4465736372697074696f6e3e3c2f506c616e3ea101010000c7" \ |
| 72 | "00454e475553443c3f786d6c2076657273696f6e3d22312e302220656e636f64696e673d2255" \ |
| 73 | "54462d38223f3e3c506c616e20786d6c6e733d22687474703a2f2f7777772e77692d66692e6f" \ |
| 74 | "72672f73706563696669636174696f6e732f686f7473706f7432646f74302f76312e302f616f" \ |
| 75 | "637069223e3c4465736372697074696f6e3e446f776e6c6f616420766964656f7320666f7220" \ |
| 76 | "796f757220666c696768742c2024322e393920666f7220313047423c2f446573637269707469" \ |
| 77 | "6f6e3e3c2f506c616e3ed3004652414341443c3f786d6c2076657273696f6e3d22312e302220" \ |
| 78 | "656e636f64696e673d225554462d38223f3e3c506c616e20786d6c6e733d22687474703a2f2f" \ |
| 79 | "7777772e77692d66692e6f72672f73706563696669636174696f6e732f686f7473706f743264" \ |
| 80 | "6f74302f76312e302f616f637069223e3c4465736372697074696f6e3e54c3a96cc3a9636861" \ |
| 81 | "7267657a2064657320766964c3a96f7320706f757220766f74726520766f6c2c20322c393920" \ |
| 82 | "2420706f757220313020476f3c2f4465736372697074696f6e3e3c2f506c616e3ee40003002b" \ |
| 83 | "736572766963652d70726f76696465722e636f6d3b66656465726174696f6e2e6578616d706c" \ |
| 84 | "652e636f6db400454e475553443c3f786d6c2076657273696f6e3d22312e302220656e636f64" \ |
| 85 | "696e673d225554462d38223f3e3c506c616e20786d6c6e733d22687474703a2f2f7777772e77" \ |
| 86 | "692d66692e6f72672f73706563696669636174696f6e732f686f7473706f7432646f74302f76" \ |
| 87 | "312e302f616f637069223e3c4465736372697074696f6e3e46726565207769746820796f7572" \ |
| 88 | "20737562736372697074696f6e213c2f4465736372697074696f6e3e3c2f506c616e3e" |
Jouni Malinen | f7ff42b | 2018-05-01 00:21:56 +0300 | [diff] [blame] | 89 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 90 | extern char *sigma_main_ifname; |
| 91 | extern char *sigma_wpas_ctrl; |
| 92 | extern char *sigma_hapd_ctrl; |
| 93 | extern char *ap_inet_addr; |
| 94 | extern char *ap_inet_mask; |
| 95 | extern char *sigma_radio_ifname[]; |
| 96 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 97 | static int ath_ap_start_hostapd(struct sigma_dut *dut); |
| 98 | static void ath_ap_set_params(struct sigma_dut *dut); |
| 99 | static int kill_process(struct sigma_dut *dut, char *proc_name, |
| 100 | unsigned char is_proc_instance_one, int sig); |
| 101 | |
| 102 | |
Jouni Malinen | 6be21c8 | 2018-08-01 18:47:24 +0300 | [diff] [blame] | 103 | static int ap_ft_enabled(struct sigma_dut *dut) |
| 104 | { |
| 105 | return dut->ap_ft_oa == 1 || |
| 106 | dut->ap_key_mgmt == AP_WPA2_FT_EAP || |
| 107 | dut->ap_key_mgmt == AP_WPA2_FT_PSK || |
| 108 | dut->ap_key_mgmt == AP_WPA2_ENT_FT_EAP; |
| 109 | } |
| 110 | |
| 111 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 112 | static int cmd_ap_ca_version(struct sigma_dut *dut, struct sigma_conn *conn, |
| 113 | struct sigma_cmd *cmd) |
| 114 | { |
| 115 | /* const char *name = get_param(cmd, "NAME"); */ |
| 116 | send_resp(dut, conn, SIGMA_COMPLETE, "version,1.0"); |
| 117 | return 0; |
| 118 | } |
| 119 | |
| 120 | |
Jouni Malinen | d6bf1b4 | 2017-06-23 17:51:01 +0300 | [diff] [blame] | 121 | static void kill_hostapd_process_pid(struct sigma_dut *dut) |
| 122 | { |
| 123 | FILE *f; |
| 124 | int pid, res; |
| 125 | char path[100]; |
| 126 | int count; |
| 127 | |
| 128 | f = fopen(SIGMA_DUT_HOSTAPD_PID_FILE, "r"); |
| 129 | if (!f) |
| 130 | return; |
| 131 | res = fscanf(f, "%d", &pid); |
| 132 | fclose(f); |
| 133 | if (res != 1) |
| 134 | return; |
| 135 | sigma_dut_print(dut, DUT_MSG_INFO, "Killing hostapd pid %d", pid); |
| 136 | kill(pid, SIGTERM); |
| 137 | snprintf(path, sizeof(path), "/proc/%d", pid); |
| 138 | for (count = 0; count < 20 && file_exists(path); count++) |
| 139 | usleep(100000); |
| 140 | } |
| 141 | |
| 142 | |
Jouni Malinen | 2e6ccc2 | 2017-09-04 13:43:16 +0300 | [diff] [blame] | 143 | int get_hwaddr(const char *ifname, unsigned char *hwaddr) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 144 | { |
| 145 | #ifndef __QNXNTO__ |
| 146 | struct ifreq ifr; |
| 147 | int s; |
| 148 | |
| 149 | s = socket(AF_INET, SOCK_DGRAM, 0); |
| 150 | if (s < 0) |
| 151 | return -1; |
| 152 | memset(&ifr, 0, sizeof(ifr)); |
Peng Xu | b8fc5cc | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 153 | strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name)); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 154 | if (ioctl(s, SIOCGIFHWADDR, &ifr) < 0) { |
| 155 | perror("ioctl"); |
| 156 | close(s); |
| 157 | return -1; |
| 158 | } |
| 159 | close(s); |
| 160 | memcpy(hwaddr, ifr.ifr_hwaddr.sa_data, 6); |
| 161 | #else /* __QNXNTO__ */ |
| 162 | struct ifaddrs *ifaddrshead = NULL; |
| 163 | int found = 0; |
| 164 | struct ifaddrs *temp_ifap = NULL; |
| 165 | struct sockaddr_dl *sdl = NULL; |
| 166 | |
| 167 | if (getifaddrs(&ifaddrshead) != 0) { |
| 168 | perror("getifaddrs failed"); |
| 169 | return -1; |
| 170 | } |
| 171 | |
| 172 | for (temp_ifap = ifaddrshead; ifaddrshead && !found; |
| 173 | ifaddrshead = ifaddrshead->ifa_next) { |
| 174 | if (ifaddrshead->ifa_addr->sa_family == AF_LINK && |
| 175 | strcmp(ifaddrshead->ifa_name, ifname) == 0) { |
| 176 | found = 1; |
| 177 | sdl = (struct sockaddr_dl *) ifaddrshead->ifa_addr; |
| 178 | if (sdl) |
| 179 | memcpy(hwaddr, LLADDR(sdl), sdl->sdl_alen); |
| 180 | } |
| 181 | } |
| 182 | |
| 183 | if (temp_ifap) |
| 184 | freeifaddrs(temp_ifap); |
| 185 | |
| 186 | if (!found) { |
| 187 | perror("Failed to get the interface"); |
| 188 | return -1; |
| 189 | } |
| 190 | #endif /* __QNXNTO__ */ |
| 191 | return 0; |
| 192 | } |
| 193 | |
| 194 | |
| 195 | static void ath_ap_set_group_id(struct sigma_dut *dut, const char *ifname, |
| 196 | const char *val) |
| 197 | { |
| 198 | char buf[60]; |
| 199 | |
| 200 | snprintf(buf, sizeof(buf), "wifitool %s beeliner_fw_test 55 %d", |
| 201 | ifname, atoi(val)); |
| 202 | if (system(buf) != 0) { |
| 203 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 204 | "wifitool ap_group_id failed"); |
| 205 | } |
| 206 | } |
| 207 | |
| 208 | |
| 209 | void ath_set_cts_width(struct sigma_dut *dut, const char *ifname, |
| 210 | const char *val) |
| 211 | { |
| 212 | char buf[60]; |
| 213 | |
| 214 | /* TODO: Enable support for other values */ |
| 215 | if (strcasecmp(val, "40") == 0) { |
| 216 | snprintf(buf, sizeof(buf), "wifitool %s beeliner_fw_test 54 1", |
| 217 | ifname); |
| 218 | if (system(buf) != 0) { |
| 219 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 220 | "wifitool cts_width failed"); |
| 221 | } |
Priyadharshini Gowthaman | 818afef | 2015-11-09 13:28:15 -0800 | [diff] [blame] | 222 | snprintf(buf, sizeof(buf), |
| 223 | "athdiag --set --address=0x10024 --val=0xd90b8a14"); |
| 224 | if (system(buf) != 0) { |
| 225 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 226 | "disabling phy restart failed"); |
| 227 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 228 | } else { |
| 229 | sigma_dut_print(dut, DUT_MSG_ERROR, "Unsupported CTS_WIDTH"); |
| 230 | } |
| 231 | } |
| 232 | |
| 233 | |
Priyadharshini Gowthaman | 818afef | 2015-11-09 13:28:15 -0800 | [diff] [blame] | 234 | void ath_config_dyn_bw_sig(struct sigma_dut *dut, const char *ifname, |
| 235 | const char *val) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 236 | { |
| 237 | char buf[60]; |
| 238 | |
| 239 | if (strcasecmp(val, "enable") == 0) { |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 240 | dut->ap_dyn_bw_sig = VALUE_ENABLED; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 241 | snprintf(buf, sizeof(buf), "iwpriv %s cwmenable 1", ifname); |
| 242 | if (system(buf) != 0) { |
| 243 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 244 | "iwpriv cwmenable 1 failed"); |
| 245 | } |
Priyadharshini Gowthaman | 818afef | 2015-11-09 13:28:15 -0800 | [diff] [blame] | 246 | snprintf(buf, sizeof(buf), "wifitool %s beeliner_fw_test 96 1", |
| 247 | ifname); |
| 248 | if (system(buf) != 0) { |
| 249 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 250 | "disabling RTS from rate control logic failed"); |
| 251 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 252 | } else if (strcasecmp(val, "disable") == 0) { |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 253 | dut->ap_dyn_bw_sig = VALUE_DISABLED; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 254 | snprintf(buf, sizeof(buf), "iwpriv %s cwmenable 0", ifname); |
| 255 | if (system(buf) != 0) { |
| 256 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 257 | "iwpriv cwmenable 0 failed"); |
| 258 | } |
| 259 | } else { |
| 260 | sigma_dut_print(dut, DUT_MSG_ERROR, "Unsupported DYN_BW_SGL"); |
| 261 | } |
| 262 | } |
| 263 | |
| 264 | |
| 265 | static void ath_config_rts_force(struct sigma_dut *dut, const char *ifname, |
| 266 | const char *val) |
| 267 | { |
| 268 | char buf[60]; |
| 269 | |
| 270 | if (strcasecmp(val, "enable") == 0) { |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 271 | dut->ap_sig_rts = VALUE_ENABLED; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 272 | snprintf(buf, sizeof(buf), "iwconfig %s rts 64", ifname); |
| 273 | if (system(buf) != 0) { |
| 274 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 275 | "iwconfig rts 64 failed"); |
| 276 | } |
priyadharshini gowthaman | 270870e | 2015-12-09 10:10:23 -0800 | [diff] [blame] | 277 | snprintf(buf, sizeof(buf), "wifitool %s beeliner_fw_test 100 1", |
| 278 | ifname); |
| 279 | if (system(buf) != 0) { |
| 280 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 281 | "wifitool beeliner_fw_test 100 1 failed"); |
| 282 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 283 | } else if (strcasecmp(val, "disable") == 0) { |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 284 | dut->ap_sig_rts = VALUE_DISABLED; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 285 | snprintf(buf, sizeof(buf), "iwconfig %s rts 2347", ifname); |
| 286 | if (system(buf) != 0) { |
| 287 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 288 | "iwpriv rts 2347 failed"); |
| 289 | } |
| 290 | } else { |
| 291 | sigma_dut_print(dut, DUT_MSG_ERROR, "Unsupported RTS_FORCE"); |
| 292 | } |
| 293 | } |
| 294 | |
| 295 | |
priyadharshini gowthaman | 09d613e | 2017-12-20 11:43:44 -0800 | [diff] [blame] | 296 | static void ath_radio(struct sigma_dut *dut, const char *val) |
| 297 | { |
| 298 | if (strcasecmp(val, "on") == 0) { |
| 299 | if (dut->ap_interface_5g == 1) { |
| 300 | run_system(dut, "uci set wireless.wifi0.disabled=0"); |
| 301 | } else if (dut->ap_interface_2g == 1) { |
| 302 | run_system(dut, "uci set wireless.wifi1.disabled=0"); |
| 303 | } else { |
| 304 | run_system(dut, "uci set wireless.wifi0.disabled=0"); |
| 305 | run_system(dut, "uci set wireless.wifi1.disabled=0"); |
| 306 | } |
| 307 | run_system(dut, "uci commit"); |
| 308 | run_system(dut, "wifi down"); |
| 309 | run_system(dut, "wifi up"); |
| 310 | } else if (strcasecmp(val, "off") == 0) { |
| 311 | if (dut->ap_interface_5g == 1) { |
| 312 | run_system(dut, "uci set wireless.wifi0.disabled=1"); |
| 313 | } else if (dut->ap_interface_2g == 1) { |
| 314 | run_system(dut, "uci set wireless.wifi1.disabled=1"); |
| 315 | } else { |
| 316 | run_system(dut, "uci set wireless.wifi0.disabled=1"); |
| 317 | run_system(dut, "uci set wireless.wifi1.disabled=1"); |
| 318 | } |
| 319 | run_system(dut, "uci commit"); |
| 320 | run_system(dut, "wifi down"); |
| 321 | run_system(dut, "wifi up"); |
| 322 | } |
| 323 | } |
| 324 | |
| 325 | |
priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 326 | static void deauth_disassoc(struct sigma_dut *dut, const char *ifname, |
| 327 | const char *val) |
| 328 | { |
| 329 | char buf[60]; |
| 330 | |
| 331 | if (strcasecmp(val, "disable") == 0) { |
| 332 | snprintf(buf, sizeof(buf), "iwpriv %s stealthdown 1", ifname); |
| 333 | if (system(buf) != 0) { |
| 334 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 335 | "disable deauthdisassoctx failed"); |
| 336 | } |
| 337 | } |
| 338 | } |
| 339 | |
| 340 | |
priyadharshini gowthaman | cb22e43 | 2017-12-28 15:23:31 -0800 | [diff] [blame] | 341 | static void ath_set_txpower(struct sigma_dut *dut, const char *ifname, |
| 342 | const char *val) |
| 343 | { |
| 344 | char buf[60]; |
| 345 | |
| 346 | if (strcasecmp(val, "high") == 0) |
| 347 | snprintf(buf, sizeof(buf), "iwconfig %s txpower 29", ifname); |
| 348 | else if (strcasecmp(val, "low") == 0) |
| 349 | snprintf(buf, sizeof(buf), "iwconfig %s txpower 1", ifname); |
| 350 | else |
| 351 | sigma_dut_print(dut, DUT_MSG_ERROR, "Unsupported txpower"); |
| 352 | |
| 353 | if (system(buf) != 0) |
| 354 | sigma_dut_print(dut, DUT_MSG_ERROR, "setting txpower failed"); |
| 355 | } |
| 356 | |
| 357 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 358 | static enum ap_mode get_mode(const char *str) |
| 359 | { |
| 360 | if (strcasecmp(str, "11a") == 0) |
| 361 | return AP_11a; |
| 362 | else if (strcasecmp(str, "11g") == 0) |
| 363 | return AP_11g; |
| 364 | else if (strcasecmp(str, "11b") == 0) |
| 365 | return AP_11b; |
| 366 | else if (strcasecmp(str, "11na") == 0) |
| 367 | return AP_11na; |
| 368 | else if (strcasecmp(str, "11ng") == 0) |
| 369 | return AP_11ng; |
| 370 | else if (strcasecmp(str, "11ac") == 0 || strcasecmp(str, "ac") == 0) |
| 371 | return AP_11ac; |
| 372 | else |
| 373 | return AP_inval; |
| 374 | } |
| 375 | |
| 376 | |
| 377 | static int run_hostapd_cli(struct sigma_dut *dut, char *buf) |
| 378 | { |
| 379 | char command[1000]; |
| 380 | const char *bin; |
| 381 | enum driver_type drv = get_driver_type(); |
Adil Saeed Musthafa | 3dd6ca7 | 2017-05-15 12:45:18 -0700 | [diff] [blame] | 382 | char *sigma_hapd_file = sigma_hapd_ctrl; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 383 | |
| 384 | if (file_exists("hostapd_cli")) |
| 385 | bin = "./hostapd_cli"; |
Jouni Malinen | d6bf1b4 | 2017-06-23 17:51:01 +0300 | [diff] [blame] | 386 | else if (file_exists("../../hostapd/hostapd_cli")) |
| 387 | bin = "../../hostapd/hostapd_cli"; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 388 | else |
| 389 | bin = "hostapd_cli"; |
| 390 | |
| 391 | if (drv == DRIVER_OPENWRT && sigma_hapd_ctrl == NULL) { |
Adil Saeed Musthafa | 3dd6ca7 | 2017-05-15 12:45:18 -0700 | [diff] [blame] | 392 | sigma_hapd_file = "/var/run/hostapd-wifi0"; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 393 | |
| 394 | if (sigma_radio_ifname[0] && |
| 395 | strcmp(sigma_radio_ifname[0], "wifi1") == 0) |
Adil Saeed Musthafa | 3dd6ca7 | 2017-05-15 12:45:18 -0700 | [diff] [blame] | 396 | sigma_hapd_file = "/var/run/hostapd-wifi1"; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 397 | else if (sigma_radio_ifname[0] && |
| 398 | strcmp(sigma_radio_ifname[0], "wifi2") == 0) |
Adil Saeed Musthafa | 3dd6ca7 | 2017-05-15 12:45:18 -0700 | [diff] [blame] | 399 | sigma_hapd_file = "/var/run/hostapd-wifi2"; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 400 | } |
| 401 | |
Adil Saeed Musthafa | 3dd6ca7 | 2017-05-15 12:45:18 -0700 | [diff] [blame] | 402 | if (sigma_hapd_file) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 403 | snprintf(command, sizeof(command), "%s -p %s %s", |
Adil Saeed Musthafa | 3dd6ca7 | 2017-05-15 12:45:18 -0700 | [diff] [blame] | 404 | bin, sigma_hapd_file, buf); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 405 | else |
| 406 | snprintf(command, sizeof(command), "%s %s", bin, buf); |
| 407 | return run_system(dut, command); |
| 408 | } |
| 409 | |
| 410 | |
priyadharshini gowthaman | 8e26ff4 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 411 | static int ath_set_lci_config(struct sigma_dut *dut, const char *val, |
| 412 | struct sigma_cmd *cmd) |
| 413 | { |
| 414 | FILE *f; |
| 415 | int i; |
| 416 | |
| 417 | f = fopen("/tmp/lci_cfg.txt", "w"); |
| 418 | if (!f) { |
| 419 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 420 | "Failed to open /tmp/lci_cfg.txt"); |
| 421 | return -1; |
| 422 | } |
| 423 | |
| 424 | for (i = 2; i < cmd->count; i++) |
| 425 | fprintf(f, "%s = %s \n", cmd->params[i], cmd->values[i]); |
| 426 | fprintf(f, "\n"); |
| 427 | fclose(f); |
| 428 | |
| 429 | return 0; |
| 430 | } |
| 431 | |
| 432 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 433 | static int cmd_ap_set_wireless(struct sigma_dut *dut, struct sigma_conn *conn, |
| 434 | struct sigma_cmd *cmd) |
| 435 | { |
| 436 | /* const char *name = get_param(cmd, "NAME"); */ |
| 437 | /* const char *ifname = get_param(cmd, "INTERFACE"); */ |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 438 | const char *val; |
| 439 | unsigned int wlan_tag = 1; |
| 440 | char *ifname = get_main_ifname(); |
| 441 | |
| 442 | val = get_param(cmd, "WLAN_TAG"); |
| 443 | if (val) { |
| 444 | wlan_tag = atoi(val); |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 445 | if (wlan_tag < 1 || wlan_tag > 3) { |
| 446 | /* |
| 447 | * The only valid WLAN Tags as of now as per the latest |
| 448 | * WFA scripts are 1, 2, and 3. |
| 449 | */ |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 450 | send_resp(dut, conn, SIGMA_INVALID, |
| 451 | "errorCode,Invalid WLAN_TAG"); |
| 452 | return 0; |
| 453 | } |
| 454 | } |
| 455 | |
priyadharshini gowthaman | 09d613e | 2017-12-20 11:43:44 -0800 | [diff] [blame] | 456 | val = get_param(cmd, "Interface"); |
| 457 | if (val) { |
| 458 | if (strcasecmp(val, "5G") == 0) |
| 459 | dut->ap_interface_5g = 1; |
| 460 | else |
| 461 | dut->ap_interface_2g = 1; |
| 462 | |
| 463 | if (dut->ap_interface_5g && dut->ap_interface_2g) |
| 464 | dut->ap_is_dual = 1; |
| 465 | } |
| 466 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 467 | val = get_param(cmd, "CountryCode"); |
| 468 | if (val) { |
| 469 | if (strlen(val) > sizeof(dut->ap_countrycode) - 1) |
| 470 | return -1; |
| 471 | snprintf(dut->ap_countrycode, sizeof(dut->ap_countrycode), |
| 472 | "%s", val); |
| 473 | } |
| 474 | |
Pradeep Reddy POTTETI | fba27db | 2015-11-20 16:42:22 +0530 | [diff] [blame] | 475 | val = get_param(cmd, "regulatory_mode"); |
| 476 | if (val) { |
| 477 | if (strcasecmp(val, "11d") == 0 || strcasecmp(val, "11h") == 0) |
| 478 | dut->ap_regulatory_mode = AP_80211D_MODE_ENABLED; |
| 479 | } |
| 480 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 481 | val = get_param(cmd, "SSID"); |
| 482 | if (val) { |
| 483 | if (strlen(val) > sizeof(dut->ap_ssid) - 1) |
| 484 | return -1; |
| 485 | |
| 486 | if (wlan_tag == 1) { |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 487 | /* |
| 488 | * If tag is not specified, it is deemed to be 1. |
| 489 | * Hence tag of 1 is a special case and the values |
| 490 | * corresponding to wlan-tag=1 are stored separately |
| 491 | * from the values corresponding tags 2 and 3. |
| 492 | * This approach minimises the changes to existing code |
| 493 | * since most of the sigma_dut code does not deal with |
| 494 | * WLAN-TAG CAPI variable. |
| 495 | */ |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 496 | snprintf(dut->ap_ssid, |
| 497 | sizeof(dut->ap_ssid), "%s", val); |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 498 | } else { |
| 499 | snprintf(dut->ap_tag_ssid[wlan_tag - 2], |
| 500 | sizeof(dut->ap_tag_ssid[wlan_tag - 2]), |
| 501 | "%s", val); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 502 | } |
| 503 | } |
| 504 | |
| 505 | val = get_param(cmd, "CHANNEL"); |
| 506 | if (val) { |
| 507 | const char *pos; |
| 508 | dut->ap_channel = atoi(val); |
| 509 | pos = strchr(val, ';'); |
| 510 | if (pos) { |
| 511 | pos++; |
| 512 | dut->ap_channel_1 = atoi(pos); |
| 513 | } |
| 514 | } |
| 515 | |
Pradeep Reddy POTTETI | fba27db | 2015-11-20 16:42:22 +0530 | [diff] [blame] | 516 | /* Overwrite the AP channel with DFS channel if configured */ |
| 517 | val = get_param(cmd, "dfs_chan"); |
| 518 | if (val) { |
| 519 | dut->ap_channel = atoi(val); |
| 520 | } |
| 521 | |
| 522 | val = get_param(cmd, "dfs_mode"); |
| 523 | if (val) { |
| 524 | if (strcasecmp(val, "Enable") == 0) |
| 525 | dut->ap_dfs_mode = AP_DFS_MODE_ENABLED; |
| 526 | else if (strcasecmp(val, "Disable") == 0) |
| 527 | dut->ap_dfs_mode = AP_DFS_MODE_DISABLED; |
| 528 | else |
| 529 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 530 | "Unsupported dfs_mode value: %s", val); |
| 531 | } |
| 532 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 533 | val = get_param(cmd, "MODE"); |
| 534 | if (val) { |
| 535 | char *str, *pos; |
| 536 | |
| 537 | str = strdup(val); |
| 538 | if (str == NULL) |
| 539 | return -1; |
| 540 | pos = strchr(str, ';'); |
| 541 | if (pos) |
| 542 | *pos++ = '\0'; |
| 543 | |
| 544 | dut->ap_is_dual = 0; |
| 545 | dut->ap_mode = get_mode(str); |
| 546 | if (dut->ap_mode == AP_inval) { |
| 547 | send_resp(dut, conn, SIGMA_INVALID, |
| 548 | "errorCode,Unsupported MODE"); |
| 549 | free(str); |
| 550 | return 0; |
| 551 | } |
priyadharshini gowthaman | 63ab848 | 2017-12-28 15:32:55 -0800 | [diff] [blame] | 552 | if (dut->ap_mode == AP_11ac && dut->ap_80plus80 != 1) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 553 | dut->ap_chwidth = AP_80; |
| 554 | |
| 555 | if (pos) { |
| 556 | dut->ap_mode_1 = get_mode(pos); |
| 557 | if (dut->ap_mode_1 == AP_inval) { |
| 558 | send_resp(dut, conn, SIGMA_INVALID, |
| 559 | "errorCode,Unsupported MODE"); |
| 560 | free(str); |
| 561 | return 0; |
| 562 | } |
| 563 | if (dut->ap_mode_1 == AP_11ac) |
| 564 | dut->ap_chwidth_1 = AP_80; |
| 565 | dut->ap_is_dual = 1; |
| 566 | } |
| 567 | |
| 568 | free(str); |
| 569 | } else if (dut->ap_mode == AP_inval) { |
| 570 | if (dut->ap_channel <= 11) |
| 571 | dut->ap_mode = AP_11ng; |
| 572 | else if (dut->program == PROGRAM_VHT) |
| 573 | dut->ap_mode = AP_11ac; |
| 574 | else |
| 575 | dut->ap_mode = AP_11na; |
| 576 | } |
| 577 | |
Pradeep Reddy POTTETI | 0d3db63 | 2016-03-11 15:21:11 +0530 | [diff] [blame] | 578 | val = get_param(cmd, "WME"); |
| 579 | if (val) { |
| 580 | if (strcasecmp(val, "on") == 0) |
| 581 | dut->ap_wme = AP_WME_ON; |
| 582 | else if (strcasecmp(val, "off") == 0) |
| 583 | dut->ap_wme = AP_WME_OFF; |
| 584 | else |
| 585 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 586 | "Unsupported WME value: %s", val); |
| 587 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 588 | |
Mohammed Shafi Shajakhan | 02e3b82 | 2017-02-23 04:15:02 +0530 | [diff] [blame] | 589 | val = get_param(cmd, "WMMPS"); |
| 590 | if (val) { |
| 591 | if (strcasecmp(val, "on") == 0) |
| 592 | dut->ap_wmmps = AP_WMMPS_ON; |
| 593 | else if (strcasecmp(val, "off") == 0) |
| 594 | dut->ap_wmmps = AP_WMMPS_OFF; |
| 595 | else |
| 596 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 597 | "Unsupported WMMPS value: %s", val); |
| 598 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 599 | |
| 600 | val = get_param(cmd, "RTS"); |
| 601 | if (val) |
| 602 | dut->ap_rts = atoi(val); |
| 603 | |
| 604 | val = get_param(cmd, "FRGMNT"); |
| 605 | if (val) |
| 606 | dut->ap_frgmnt = atoi(val); |
| 607 | |
| 608 | /* TODO: PWRSAVE */ |
| 609 | |
| 610 | val = get_param(cmd, "BCNINT"); |
| 611 | if (val) |
| 612 | dut->ap_bcnint = atoi(val); |
| 613 | |
| 614 | val = get_param(cmd, "RADIO"); |
| 615 | if (val) { |
Mohammed Shafi Shajakhan | 94997f9 | 2017-01-09 21:31:09 +0530 | [diff] [blame] | 616 | enum driver_type drv = get_driver_type(); |
| 617 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 618 | if (strcasecmp(val, "on") == 0) { |
priyadharshini gowthaman | 09d613e | 2017-12-20 11:43:44 -0800 | [diff] [blame] | 619 | if (drv == DRIVER_OPENWRT) |
| 620 | ath_radio(dut, val); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 621 | if (drv == DRIVER_ATHEROS) |
| 622 | ath_ap_start_hostapd(dut); |
| 623 | else if (cmd_ap_config_commit(dut, conn, cmd) <= 0) |
| 624 | return 0; |
| 625 | } else if (strcasecmp(val, "off") == 0) { |
Mohammed Shafi Shajakhan | 94997f9 | 2017-01-09 21:31:09 +0530 | [diff] [blame] | 626 | if (drv == DRIVER_OPENWRT) { |
priyadharshini gowthaman | 09d613e | 2017-12-20 11:43:44 -0800 | [diff] [blame] | 627 | ath_radio(dut, val); |
Jouni Malinen | d6bf1b4 | 2017-06-23 17:51:01 +0300 | [diff] [blame] | 628 | } else if (dut->use_hostapd_pid_file) { |
| 629 | kill_hostapd_process_pid(dut); |
Mohammed Shafi Shajakhan | 94997f9 | 2017-01-09 21:31:09 +0530 | [diff] [blame] | 630 | } else if (kill_process(dut, "(hostapd)", 1, |
| 631 | SIGTERM) == 0 || |
| 632 | system("killall hostapd") == 0) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 633 | sigma_dut_print(dut, DUT_MSG_INFO, |
| 634 | "Killed hostapd on radio,off"); |
| 635 | } |
| 636 | } else { |
| 637 | send_resp(dut, conn, SIGMA_INVALID, |
| 638 | "errorCode,Unsupported RADIO value"); |
| 639 | return 0; |
| 640 | } |
| 641 | } |
| 642 | |
| 643 | val = get_param(cmd, "P2PMgmtBit"); |
| 644 | if (val) |
| 645 | dut->ap_p2p_mgmt = atoi(val); |
| 646 | |
| 647 | /* TODO: ChannelUsage */ |
| 648 | |
| 649 | /* TODO: 40_INTOLERANT */ |
| 650 | |
| 651 | val = get_param(cmd, "ADDBA_REJECT"); |
| 652 | if (val) { |
| 653 | if (strcasecmp(val, "Enable") == 0) |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 654 | dut->ap_addba_reject = VALUE_ENABLED; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 655 | else if (strcasecmp(val, "Disable") == 0) |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 656 | dut->ap_addba_reject = VALUE_DISABLED; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 657 | } |
| 658 | |
| 659 | val = get_param(cmd, "AMPDU"); |
| 660 | if (val) { |
| 661 | if (strcasecmp(val, "Enable") == 0) |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 662 | dut->ap_ampdu = VALUE_ENABLED; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 663 | else if (strcasecmp(val, "Disable") == 0) |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 664 | dut->ap_ampdu = VALUE_DISABLED; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 665 | } |
| 666 | |
| 667 | val = get_param(cmd, "AMPDU_EXP"); |
| 668 | if (val) |
| 669 | dut->ap_ampdu_exp = atoi(val); |
| 670 | |
| 671 | val = get_param(cmd, "AMSDU"); |
| 672 | if (val) { |
| 673 | if (strcasecmp(val, "Enable") == 0) |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 674 | dut->ap_amsdu = VALUE_ENABLED; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 675 | else if (strcasecmp(val, "Disable") == 0) |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 676 | dut->ap_amsdu = VALUE_DISABLED; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 677 | } |
| 678 | |
| 679 | val = get_param(cmd, "NoAck"); |
| 680 | if (val) { |
| 681 | if (strcasecmp(val, "on") == 0) |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 682 | dut->ap_noack = VALUE_ENABLED; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 683 | else if (strcasecmp(val, "off") == 0) |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 684 | dut->ap_noack = VALUE_DISABLED; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 685 | } |
| 686 | |
| 687 | /* TODO: GREENFIELD */ |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 688 | /* TODO: MCS_32 */ |
| 689 | |
Pradeep Reddy Potteti | 4b0cdee | 2017-03-15 12:37:33 +0530 | [diff] [blame] | 690 | val = get_param(cmd, "OFFSET"); |
| 691 | if (val) { |
| 692 | if (strcasecmp(val, "Above") == 0) |
| 693 | dut->ap_chwidth_offset = SEC_CH_40ABOVE; |
| 694 | else if (strcasecmp(val, "Below") == 0) |
| 695 | dut->ap_chwidth_offset = SEC_CH_40BELOW; |
| 696 | } |
| 697 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 698 | val = get_param(cmd, "MCS_FIXEDRATE"); |
| 699 | if (val) { |
| 700 | dut->ap_fixed_rate = 1; |
| 701 | dut->ap_mcs = atoi(val); |
| 702 | } |
| 703 | |
| 704 | val = get_param(cmd, "SPATIAL_RX_STREAM"); |
| 705 | if (val) { |
| 706 | if (strcasecmp(val, "1SS") == 0 || strcasecmp(val, "1") == 0) { |
| 707 | dut->ap_rx_streams = 1; |
| 708 | if (dut->device_type == AP_testbed) |
| 709 | dut->ap_vhtmcs_map = 0xfffc; |
| 710 | } else if (strcasecmp(val, "2SS") == 0 || |
| 711 | strcasecmp(val, "2") == 0) { |
| 712 | dut->ap_rx_streams = 2; |
| 713 | if (dut->device_type == AP_testbed) |
| 714 | dut->ap_vhtmcs_map = 0xfff0; |
| 715 | } else if (strcasecmp(val, "3SS") == 0 || |
| 716 | strcasecmp(val, "3") == 0) { |
| 717 | dut->ap_rx_streams = 3; |
| 718 | if (dut->device_type == AP_testbed) |
| 719 | dut->ap_vhtmcs_map = 0xffc0; |
| 720 | } else if (strcasecmp(val, "4SS") == 0 || |
| 721 | strcasecmp(val, "4") == 0) { |
| 722 | dut->ap_rx_streams = 4; |
| 723 | } |
| 724 | } |
| 725 | |
| 726 | val = get_param(cmd, "SPATIAL_TX_STREAM"); |
| 727 | if (val) { |
| 728 | if (strcasecmp(val, "1SS") == 0 || |
| 729 | strcasecmp(val, "1") == 0) { |
| 730 | dut->ap_tx_streams = 1; |
| 731 | if (dut->device_type == AP_testbed) |
| 732 | dut->ap_vhtmcs_map = 0xfffc; |
| 733 | } else if (strcasecmp(val, "2SS") == 0 || |
| 734 | strcasecmp(val, "2") == 0) { |
| 735 | dut->ap_tx_streams = 2; |
| 736 | if (dut->device_type == AP_testbed) |
| 737 | dut->ap_vhtmcs_map = 0xfff0; |
| 738 | } else if (strcasecmp(val, "3SS") == 0 || |
| 739 | strcasecmp(val, "3") == 0) { |
| 740 | dut->ap_tx_streams = 3; |
| 741 | if (dut->device_type == AP_testbed) |
| 742 | dut->ap_vhtmcs_map = 0xffc0; |
| 743 | } else if (strcasecmp(val, "4SS") == 0 || |
| 744 | strcasecmp(val, "4") == 0) { |
| 745 | dut->ap_tx_streams = 4; |
| 746 | } |
| 747 | } |
| 748 | |
Adil Saeed Musthafa | 33ea287 | 2017-04-10 23:13:24 -0700 | [diff] [blame] | 749 | val = get_param(cmd, "BSS_max_idle"); |
| 750 | if (val) { |
| 751 | if (strncasecmp(val, "Enable", 7) == 0) { |
| 752 | dut->wnm_bss_max_feature = VALUE_ENABLED; |
| 753 | } else if (strncasecmp(val, "Disable", 8) == 0) { |
| 754 | dut->wnm_bss_max_feature = VALUE_DISABLED; |
| 755 | } else { |
| 756 | send_resp(dut, conn, SIGMA_ERROR, |
| 757 | "errorCode,Invalid value for BSS_max_Feature"); |
| 758 | return 0; |
| 759 | } |
| 760 | } |
| 761 | |
| 762 | val = get_param(cmd, "BSS_Idle_Protection_options"); |
| 763 | if (val) { |
| 764 | int protection = (int) strtol(val, (char **) NULL, 10); |
| 765 | |
| 766 | if (protection != 1 && protection != 0) { |
| 767 | send_resp(dut, conn, SIGMA_ERROR, |
| 768 | "errorCode,Invalid value for BSS_Idle_Protection_options"); |
| 769 | return 0; |
| 770 | } |
| 771 | dut->wnm_bss_max_protection = protection ? |
| 772 | VALUE_ENABLED : VALUE_DISABLED; |
| 773 | } |
| 774 | |
| 775 | val = get_param(cmd, "BSS_max_Idle_period"); |
| 776 | if (val) { |
| 777 | int idle_time = (int) strtol(val, (char **) NULL, 10); |
| 778 | |
| 779 | if (idle_time == LONG_MIN || idle_time == LONG_MAX) { |
| 780 | send_resp(dut, conn, SIGMA_ERROR, |
| 781 | "errorCode,Invalid value for BSS_max_Idle_period"); |
| 782 | return 0; |
| 783 | } |
| 784 | dut->wnm_bss_max_idle_time = idle_time; |
| 785 | } |
| 786 | |
| 787 | val = get_param(cmd, "PROXY_ARP"); |
| 788 | if (val) |
| 789 | dut->ap_proxy_arp = (int) strtol(val, (char **) NULL, 10); |
| 790 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 791 | val = get_param(cmd, "nss_mcs_cap"); |
| 792 | if (val) { |
| 793 | int nss, mcs; |
| 794 | char token[20]; |
| 795 | char *result = NULL; |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 796 | char *saveptr; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 797 | |
| 798 | if (strlen(val) >= sizeof(token)) |
| 799 | return -1; |
Jouni Malinen | 947fdf6 | 2017-05-14 22:29:32 +0300 | [diff] [blame] | 800 | strlcpy(token, val, sizeof(token)); |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 801 | result = strtok_r(token, ";", &saveptr); |
Pradeep Reddy POTTETI | 41b8c54 | 2016-06-15 16:09:46 +0530 | [diff] [blame] | 802 | if (!result) { |
| 803 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 804 | "VHT NSS not specified"); |
| 805 | return 0; |
| 806 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 807 | nss = atoi(result); |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 808 | result = strtok_r(NULL, ";", &saveptr); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 809 | if (result == NULL) { |
| 810 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 811 | "VHTMCS NOT SPECIFIED!"); |
| 812 | return 0; |
| 813 | } |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 814 | result = strtok_r(result, "-", &saveptr); |
| 815 | result = strtok_r(NULL, "-", &saveptr); |
Pradeep Reddy POTTETI | 41b8c54 | 2016-06-15 16:09:46 +0530 | [diff] [blame] | 816 | if (!result) { |
| 817 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 818 | "VHT MCS not specified"); |
| 819 | return 0; |
| 820 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 821 | mcs = atoi(result); |
| 822 | switch (nss) { |
| 823 | case 1: |
| 824 | switch (mcs) { |
| 825 | case 7: |
| 826 | dut->ap_vhtmcs_map = 0xfffc; |
| 827 | break; |
| 828 | case 8: |
| 829 | dut->ap_vhtmcs_map = 0xfffd; |
| 830 | break; |
| 831 | case 9: |
| 832 | dut->ap_vhtmcs_map = 0xfffe; |
| 833 | break; |
| 834 | default: |
| 835 | dut->ap_vhtmcs_map = 0xfffe; |
| 836 | break; |
| 837 | } |
| 838 | break; |
| 839 | case 2: |
| 840 | switch (mcs) { |
| 841 | case 7: |
| 842 | dut->ap_vhtmcs_map = 0xfff0; |
| 843 | break; |
| 844 | case 8: |
| 845 | dut->ap_vhtmcs_map = 0xfff5; |
| 846 | break; |
| 847 | case 9: |
| 848 | dut->ap_vhtmcs_map = 0xfffa; |
| 849 | break; |
| 850 | default: |
| 851 | dut->ap_vhtmcs_map = 0xfffa; |
| 852 | break; |
| 853 | } |
| 854 | break; |
| 855 | case 3: |
| 856 | switch (mcs) { |
| 857 | case 7: |
| 858 | dut->ap_vhtmcs_map = 0xffc0; |
| 859 | break; |
| 860 | case 8: |
| 861 | dut->ap_vhtmcs_map = 0xffd5; |
| 862 | break; |
| 863 | case 9: |
| 864 | dut->ap_vhtmcs_map = 0xffea; |
| 865 | break; |
| 866 | default: |
| 867 | dut->ap_vhtmcs_map = 0xffea; |
| 868 | break; |
| 869 | } |
| 870 | break; |
| 871 | default: |
| 872 | dut->ap_vhtmcs_map = 0xffea; |
| 873 | break; |
| 874 | } |
| 875 | } |
| 876 | |
| 877 | /* TODO: MPDU_MIN_START_SPACING */ |
| 878 | /* TODO: RIFS_TEST */ |
| 879 | /* TODO: SGI20 */ |
| 880 | |
| 881 | val = get_param(cmd, "STBC_TX"); |
| 882 | if (val) |
| 883 | dut->ap_tx_stbc = atoi(val); |
| 884 | |
| 885 | val = get_param(cmd, "WIDTH"); |
| 886 | if (val) { |
| 887 | if (strcasecmp(val, "20") == 0) |
| 888 | dut->ap_chwidth = AP_20; |
| 889 | else if (strcasecmp(val, "40") == 0) |
| 890 | dut->ap_chwidth = AP_40; |
| 891 | else if (strcasecmp(val, "80") == 0) |
| 892 | dut->ap_chwidth = AP_80; |
| 893 | else if (strcasecmp(val, "160") == 0) |
| 894 | dut->ap_chwidth = AP_160; |
priyadharshini gowthaman | 63ab848 | 2017-12-28 15:32:55 -0800 | [diff] [blame] | 895 | else if (strcasecmp(val, "80plus80") == 0) { |
| 896 | dut->ap_80plus80 = 1; |
| 897 | dut->ap_chwidth = AP_80_80; |
| 898 | } else if (strcasecmp(val, "Auto") == 0) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 899 | dut->ap_chwidth = AP_AUTO; |
| 900 | else { |
| 901 | send_resp(dut, conn, SIGMA_INVALID, |
| 902 | "errorCode,Unsupported WIDTH"); |
| 903 | return 0; |
| 904 | } |
| 905 | } |
| 906 | |
| 907 | /* TODO: WIDTH_SCAN */ |
| 908 | |
| 909 | val = get_param(cmd, "TDLSProhibit"); |
| 910 | dut->ap_tdls_prohibit = val && strcasecmp(val, "Enabled") == 0; |
| 911 | val = get_param(cmd, "TDLSChswitchProhibit"); |
| 912 | dut->ap_tdls_prohibit_chswitch = |
| 913 | val && strcasecmp(val, "Enabled") == 0; |
| 914 | val = get_param(cmd, "HS2"); |
| 915 | if (val && wlan_tag == 1) |
| 916 | dut->ap_hs2 = atoi(val); |
| 917 | val = get_param(cmd, "P2P_CROSS_CONNECT"); |
| 918 | if (val) |
| 919 | dut->ap_p2p_cross_connect = strcasecmp(val, "Enabled") == 0; |
| 920 | |
| 921 | val = get_param(cmd, "FakePubKey"); |
| 922 | dut->ap_fake_pkhash = val && atoi(val); |
| 923 | |
| 924 | val = get_param(cmd, "vht_tkip"); |
| 925 | dut->ap_allow_vht_tkip = val && strcasecmp(val, "Enable") == 0; |
| 926 | val = get_param(cmd, "vht_wep"); |
| 927 | dut->ap_allow_vht_wep = val && strcasecmp(val, "Enable") == 0; |
| 928 | |
| 929 | val = get_param(cmd, "Protect_mode"); |
| 930 | dut->ap_disable_protection = val && strcasecmp(val, "Disable") == 0; |
| 931 | |
| 932 | val = get_param(cmd, "DYN_BW_SGNL"); |
| 933 | if (val) { |
| 934 | switch (get_driver_type()) { |
| 935 | case DRIVER_OPENWRT: |
| 936 | switch (get_openwrt_driver_type()) { |
| 937 | case OPENWRT_DRIVER_ATHEROS: |
| 938 | ath_config_dyn_bw_sig(dut, ifname, val); |
| 939 | break; |
| 940 | default: |
| 941 | send_resp(dut, conn, SIGMA_ERROR, |
| 942 | "errorCode,Unsupported DYN_BW_SGNL with OpenWrt driver"); |
| 943 | return 0; |
| 944 | } |
| 945 | break; |
Nirav Shah | 8ad8d74 | 2017-10-17 10:49:11 +0530 | [diff] [blame] | 946 | case DRIVER_WCN: |
| 947 | case DRIVER_LINUX_WCN: |
| 948 | ath_config_dyn_bw_sig(dut, ifname, val); |
| 949 | break; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 950 | default: |
| 951 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 952 | "Unsupported DYN_BW_SGL with the current driver"); |
| 953 | break; |
| 954 | } |
| 955 | } |
| 956 | |
| 957 | val = get_param(cmd, "SGI80"); |
| 958 | if (val) { |
| 959 | if (strcasecmp(val, "enable") == 0) |
| 960 | dut->ap_sgi80 = 1; |
| 961 | else if (strcasecmp(val, "disable") == 0) |
| 962 | dut->ap_sgi80 = 0; |
| 963 | else { |
| 964 | send_resp(dut, conn, SIGMA_INVALID, |
| 965 | "errorCode,Unsupported SGI80"); |
| 966 | return 0; |
| 967 | } |
| 968 | } |
| 969 | |
| 970 | val = get_param(cmd, "LDPC"); |
| 971 | if (val) { |
| 972 | if (strcasecmp(val, "enable") == 0) |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 973 | dut->ap_ldpc = VALUE_ENABLED; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 974 | else if (strcasecmp(val, "disable") == 0) |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 975 | dut->ap_ldpc = VALUE_DISABLED; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 976 | else { |
| 977 | send_resp(dut, conn, SIGMA_INVALID, |
| 978 | "errorCode,Unsupported LDPC"); |
| 979 | return 0; |
| 980 | } |
| 981 | } |
| 982 | |
| 983 | val = get_param(cmd, "BW_SGNL"); |
| 984 | if (val) { |
| 985 | /* |
| 986 | * With dynamic bandwidth signaling enabled we should see |
| 987 | * RTS if the threshold is met. |
| 988 | */ |
| 989 | if (strcasecmp(val, "enable") == 0) { |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 990 | dut->ap_sig_rts = VALUE_ENABLED; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 991 | } else if (strcasecmp(val, "disable") == 0) { |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 992 | dut->ap_sig_rts = VALUE_DISABLED; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 993 | } else { |
| 994 | send_resp(dut, conn, SIGMA_INVALID, |
| 995 | "errorCode,Unsupported BW_SGNL"); |
| 996 | return 0; |
| 997 | } |
| 998 | } |
| 999 | |
| 1000 | val = get_param(cmd, "RTS_FORCE"); |
| 1001 | if (val) { |
| 1002 | switch (get_driver_type()) { |
| 1003 | case DRIVER_OPENWRT: |
| 1004 | switch (get_openwrt_driver_type()) { |
| 1005 | case OPENWRT_DRIVER_ATHEROS: |
| 1006 | ath_config_rts_force(dut, ifname, val); |
| 1007 | break; |
| 1008 | default: |
| 1009 | send_resp(dut, conn, SIGMA_ERROR, |
| 1010 | "errorCode,Unsupported RTS_FORCE with OpenWrt driver"); |
| 1011 | return 0; |
| 1012 | } |
| 1013 | break; |
| 1014 | default: |
| 1015 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 1016 | "Unsupported RTS_FORCE with the current driver"); |
| 1017 | break; |
| 1018 | } |
| 1019 | } |
| 1020 | |
| 1021 | val = get_param(cmd, "Zero_crc"); |
| 1022 | if (val) { |
| 1023 | switch (get_driver_type()) { |
| 1024 | case DRIVER_ATHEROS: |
| 1025 | ath_set_zero_crc(dut, val); |
| 1026 | break; |
| 1027 | case DRIVER_OPENWRT: |
| 1028 | switch (get_openwrt_driver_type()) { |
| 1029 | case OPENWRT_DRIVER_ATHEROS: |
| 1030 | ath_set_zero_crc(dut, val); |
| 1031 | break; |
| 1032 | default: |
| 1033 | send_resp(dut, conn, SIGMA_ERROR, |
| 1034 | "errorCode,Unsupported zero_crc with the current driver"); |
| 1035 | return 0; |
| 1036 | } |
| 1037 | break; |
| 1038 | default: |
| 1039 | send_resp(dut, conn, SIGMA_ERROR, |
| 1040 | "errorCode,Unsupported zero_crc with the current driver"); |
| 1041 | return 0; |
| 1042 | } |
| 1043 | } |
| 1044 | |
| 1045 | val = get_param(cmd, "TxBF"); |
| 1046 | if (val) |
| 1047 | dut->ap_txBF = strcasecmp(val, "enable") == 0; |
| 1048 | |
| 1049 | val = get_param(cmd, "MU_TxBF"); |
Manikanta Pubbisetty | 210f7c8 | 2017-02-14 12:33:54 +0530 | [diff] [blame] | 1050 | if (val) { |
| 1051 | if (strcasecmp(val, "enable") == 0) { |
| 1052 | dut->ap_txBF = 1; |
| 1053 | dut->ap_mu_txBF = 1; |
| 1054 | } else if (strcasecmp(val, "disable") == 0) { |
| 1055 | dut->ap_txBF = 0; |
| 1056 | dut->ap_mu_txBF = 0; |
| 1057 | } else { |
| 1058 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 1059 | "Unsupported MU_TxBF"); |
| 1060 | } |
| 1061 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1062 | |
| 1063 | /* UNSUPPORTED: tx_lgi_rate */ |
| 1064 | |
| 1065 | val = get_param(cmd, "wpsnfc"); |
| 1066 | if (val) |
| 1067 | dut->ap_wpsnfc = atoi(val); |
| 1068 | |
| 1069 | val = get_param(cmd, "GROUP_ID"); |
| 1070 | if (val) { |
| 1071 | switch (get_driver_type()) { |
| 1072 | case DRIVER_OPENWRT: |
| 1073 | switch (get_openwrt_driver_type()) { |
| 1074 | case OPENWRT_DRIVER_ATHEROS: |
| 1075 | ath_ap_set_group_id(dut, ifname, val); |
| 1076 | break; |
| 1077 | default: |
| 1078 | send_resp(dut, conn, SIGMA_ERROR, |
| 1079 | "errorCode,Unsupported group_id with the current driver"); |
| 1080 | return 0; |
| 1081 | } |
| 1082 | break; |
| 1083 | default: |
| 1084 | send_resp(dut, conn, SIGMA_ERROR, |
| 1085 | "errorCode,Unsupported group_id with the current driver"); |
| 1086 | return 0; |
| 1087 | } |
| 1088 | } |
| 1089 | |
| 1090 | val = get_param(cmd, "CTS_WIDTH"); |
| 1091 | if (val) { |
| 1092 | switch (get_driver_type()) { |
| 1093 | case DRIVER_OPENWRT: |
| 1094 | switch (get_openwrt_driver_type()) { |
| 1095 | case OPENWRT_DRIVER_ATHEROS: |
| 1096 | ath_set_cts_width(dut, ifname, val); |
| 1097 | break; |
| 1098 | default: |
| 1099 | send_resp(dut, conn, SIGMA_ERROR, |
| 1100 | "errorCode,Unsupported cts_width with the current driver"); |
| 1101 | return 0; |
| 1102 | } |
| 1103 | break; |
| 1104 | default: |
| 1105 | send_resp(dut, conn, SIGMA_ERROR, |
| 1106 | "errorCode,Unsupported cts_width with the current driver"); |
| 1107 | return 0; |
| 1108 | } |
| 1109 | } |
| 1110 | |
priyadharshini gowthaman | 264d544 | 2016-02-25 15:52:22 -0800 | [diff] [blame] | 1111 | val = get_param(cmd, "MU_NDPA_FrameFormat"); |
| 1112 | if (val) |
| 1113 | dut->ap_ndpa_frame = atoi(val); |
| 1114 | |
priyadharshini gowthaman | c52fff8 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 1115 | val = get_param(cmd, "interworking"); |
| 1116 | if (val && strcmp(val, "1") == 0) |
| 1117 | dut->ap_interworking = 1; |
| 1118 | |
| 1119 | val = get_param(cmd, "GAS_CB_DELAY"); |
| 1120 | if (val) |
| 1121 | dut->ap_gas_cb_delay = atoi(val); |
| 1122 | |
priyadharshini gowthaman | 8e26ff4 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 1123 | val = get_param(cmd, "LCI"); |
| 1124 | if (val) { |
| 1125 | if (strlen(val) > sizeof(dut->ap_val_lci) - 1) |
| 1126 | return -1; |
| 1127 | dut->ap_lci = 1; |
| 1128 | snprintf(dut->ap_val_lci, sizeof(dut->ap_val_lci), "%s", val); |
| 1129 | ath_set_lci_config(dut, val, cmd); |
| 1130 | } |
| 1131 | |
priyadharshini gowthaman | c2357bd | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 1132 | val = get_param(cmd, "InfoZ"); |
| 1133 | if (val) { |
| 1134 | if (strlen(val) > sizeof(dut->ap_infoz) - 1) |
| 1135 | return -1; |
| 1136 | snprintf(dut->ap_infoz, sizeof(dut->ap_infoz), "%s", val); |
| 1137 | } |
| 1138 | |
priyadharshini gowthaman | 8e26ff4 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 1139 | val = get_param(cmd, "LocCivicAddr"); |
| 1140 | if (val) { |
| 1141 | if (strlen(val) > sizeof(dut->ap_val_lcr) - 1) |
| 1142 | return -1; |
| 1143 | dut->ap_lcr = 1; |
| 1144 | snprintf(dut->ap_val_lcr, sizeof(dut->ap_val_lcr), "%s", val); |
| 1145 | if (dut->ap_lci == 0) |
| 1146 | ath_set_lci_config(dut, val, cmd); |
| 1147 | } |
| 1148 | |
| 1149 | val = get_param(cmd, "NeighAPBSSID"); |
| 1150 | if (val) { |
| 1151 | if (dut->ap_neighap < 3) { |
| 1152 | if (parse_mac_address( |
| 1153 | dut, val, |
| 1154 | dut->ap_val_neighap[dut->ap_neighap]) < 0) { |
| 1155 | send_resp(dut, conn, SIGMA_INVALID, |
| 1156 | "Failed to parse MAC address"); |
| 1157 | return 0; |
| 1158 | } |
| 1159 | dut->ap_neighap++; |
| 1160 | if (dut->ap_lci == 1) |
| 1161 | dut->ap_scan = 1; |
| 1162 | } |
| 1163 | } |
| 1164 | |
| 1165 | val = get_param(cmd, "OpChannel"); |
| 1166 | if (val) { |
| 1167 | if (dut->ap_opchannel < 3) { |
| 1168 | dut->ap_val_opchannel[dut->ap_opchannel] = atoi(val); |
| 1169 | dut->ap_opchannel++; |
| 1170 | } |
| 1171 | } |
| 1172 | |
priyadharshini gowthaman | c2357bd | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 1173 | val = get_param(cmd, "URI-FQDNdescriptor"); |
| 1174 | if (val) { |
| 1175 | if (strcasecmp(val, "HELD") == 0) { |
| 1176 | dut->ap_fqdn_held = 1; |
| 1177 | } else if (strcasecmp(val, "SUPL") == 0) { |
| 1178 | dut->ap_fqdn_supl = 1; |
| 1179 | } else { |
| 1180 | send_resp(dut, conn, SIGMA_INVALID, |
| 1181 | "errorCode,Unsupported URI-FQDNdescriptor"); |
| 1182 | return 0; |
| 1183 | } |
| 1184 | } |
| 1185 | |
Adil Saeed Musthafa | 604c826 | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 1186 | val = get_param(cmd, "Reg_Domain"); |
| 1187 | if (val) { |
| 1188 | if (strcasecmp(val, "Local") == 0) { |
| 1189 | dut->ap_reg_domain = REG_DOMAIN_LOCAL; |
| 1190 | } else if (strcasecmp(val, "Global") == 0) { |
| 1191 | dut->ap_reg_domain = REG_DOMAIN_GLOBAL; |
| 1192 | } else { |
| 1193 | send_resp(dut, conn, SIGMA_ERROR, |
| 1194 | "errorCode,Wrong value for Reg_Domain"); |
| 1195 | return 0; |
| 1196 | } |
| 1197 | } |
| 1198 | |
Adil Saeed Musthafa | 4ec61bd | 2017-04-10 23:13:41 -0700 | [diff] [blame] | 1199 | val = get_param(cmd, "NAME"); |
| 1200 | if (val) { |
| 1201 | if (strcasecmp(val, "ap1mbo") == 0) |
| 1202 | dut->ap_name = 1; |
| 1203 | else if (strcasecmp(val, "ap2mbo") == 0) |
| 1204 | dut->ap_name = 2; |
| 1205 | else |
| 1206 | dut->ap_name = 0; |
| 1207 | } |
| 1208 | |
| 1209 | val = get_param(cmd, "FT_OA"); |
| 1210 | if (val) { |
| 1211 | if (strcasecmp(val, "Enable") == 0) { |
| 1212 | dut->ap_ft_oa = 1; |
| 1213 | } else if (strcasecmp(val, "Disable") == 0) { |
| 1214 | dut->ap_ft_oa = 0; |
| 1215 | } else { |
| 1216 | send_resp(dut, conn, SIGMA_ERROR, |
| 1217 | "errorCode,Wrong value for FT_OA"); |
| 1218 | return 0; |
| 1219 | } |
| 1220 | } |
| 1221 | |
Adil Saeed Musthafa | 023108a | 2017-04-10 23:13:37 -0700 | [diff] [blame] | 1222 | val = get_param(cmd, "Cellular_Cap_Pref"); |
| 1223 | if (val) |
| 1224 | dut->ap_cell_cap_pref = atoi(val); |
| 1225 | |
Adil Saeed Musthafa | cf752fa | 2017-04-10 23:13:32 -0700 | [diff] [blame] | 1226 | val = get_param(cmd, "DOMAIN"); |
| 1227 | if (val) { |
| 1228 | if (strlen(val) >= sizeof(dut->ap_mobility_domain)) { |
| 1229 | send_resp(dut, conn, SIGMA_ERROR, |
| 1230 | "errorCode,Too long DOMAIN"); |
| 1231 | return 0; |
| 1232 | } |
| 1233 | snprintf(dut->ap_mobility_domain, |
| 1234 | sizeof(dut->ap_mobility_domain), "%s", val); |
| 1235 | } |
| 1236 | |
Adil Saeed Musthafa | 4ec61bd | 2017-04-10 23:13:41 -0700 | [diff] [blame] | 1237 | val = get_param(cmd, "ft_bss_list"); |
| 1238 | if (val) { |
| 1239 | char *mac_str; |
| 1240 | int i; |
| 1241 | char *saveptr; |
| 1242 | char *mac_list_str; |
| 1243 | |
| 1244 | mac_list_str = strdup(val); |
| 1245 | if (!mac_list_str) |
| 1246 | return -1; |
| 1247 | mac_str = strtok_r(mac_list_str, " ", &saveptr); |
| 1248 | for (i = 0; mac_str && i < MAX_FT_BSS_LIST; i++) { |
| 1249 | if (parse_mac_address(dut, mac_str, |
| 1250 | dut->ft_bss_mac_list[i]) < 0) { |
| 1251 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 1252 | "MAC Address not in proper format"); |
| 1253 | break; |
| 1254 | } |
| 1255 | dut->ft_bss_mac_cnt++; |
| 1256 | mac_str = strtok_r(NULL, " ", &saveptr); |
| 1257 | } |
| 1258 | sigma_dut_print(dut, DUT_MSG_DEBUG, |
| 1259 | "Storing the following FT BSS MAC List"); |
| 1260 | for (i = 0; i < dut->ft_bss_mac_cnt; i++) { |
| 1261 | sigma_dut_print(dut, DUT_MSG_DEBUG, |
| 1262 | "MAC[%d] %02x:%02x:%02x:%02x:%02x:%02x", |
| 1263 | i, |
| 1264 | dut->ft_bss_mac_list[i][0], |
| 1265 | dut->ft_bss_mac_list[i][1], |
| 1266 | dut->ft_bss_mac_list[i][2], |
| 1267 | dut->ft_bss_mac_list[i][3], |
| 1268 | dut->ft_bss_mac_list[i][4], |
| 1269 | dut->ft_bss_mac_list[i][5]); |
| 1270 | } |
| 1271 | free(mac_list_str); |
| 1272 | } |
| 1273 | |
priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 1274 | val = get_param(cmd, "OCESupport"); |
| 1275 | if (val) { |
| 1276 | if (strcasecmp(val, "enable") == 0) { |
| 1277 | dut->ap_oce = VALUE_ENABLED; |
| 1278 | } else if (strcasecmp(val, "disable") == 0) { |
| 1279 | dut->ap_oce = VALUE_DISABLED; |
| 1280 | dut->ap_filsdscv = VALUE_DISABLED; |
| 1281 | } else { |
| 1282 | send_resp(dut, conn, SIGMA_INVALID, |
| 1283 | "errorCode,Unsupported OCE"); |
| 1284 | return 0; |
| 1285 | } |
| 1286 | } |
| 1287 | |
| 1288 | val = get_param(cmd, "FILSDscvInterval"); |
| 1289 | if (val) |
| 1290 | dut->ap_fils_dscv_int = atoi(val); |
| 1291 | |
| 1292 | val = get_param(cmd, "BroadcastSSID"); |
| 1293 | if (val) { |
| 1294 | if (strcasecmp(val, "enable") == 0) { |
| 1295 | dut->ap_broadcast_ssid = VALUE_ENABLED; |
| 1296 | } else if (strcasecmp(val, "disable") == 0) { |
| 1297 | dut->ap_broadcast_ssid = VALUE_DISABLED; |
| 1298 | } else { |
| 1299 | send_resp(dut, conn, SIGMA_INVALID, |
| 1300 | "errorCode,Unsupported hidden SSID"); |
| 1301 | return 0; |
| 1302 | } |
| 1303 | } |
| 1304 | |
| 1305 | val = get_param(cmd, "FILSDscv"); |
| 1306 | if (val) { |
| 1307 | if (strcasecmp(val, "enable") == 0) { |
| 1308 | dut->ap_filsdscv = VALUE_ENABLED; |
| 1309 | } else if (strcasecmp(val, "disable") == 0) { |
| 1310 | dut->ap_filsdscv = VALUE_DISABLED; |
| 1311 | } else { |
| 1312 | send_resp(dut, conn, SIGMA_INVALID, |
| 1313 | "errorCode,Unsupported FILSDscv"); |
| 1314 | return 0; |
| 1315 | } |
| 1316 | } |
| 1317 | |
| 1318 | val = get_param(cmd, "FILSHLP"); |
| 1319 | if (val) { |
| 1320 | if (strcasecmp(val, "enable") == 0) { |
| 1321 | dut->ap_filshlp = VALUE_ENABLED; |
| 1322 | } else if (strcasecmp(val, "disable") == 0) { |
| 1323 | dut->ap_filshlp = VALUE_DISABLED; |
| 1324 | } else { |
| 1325 | send_resp(dut, conn, SIGMA_INVALID, |
| 1326 | "errorCode,Unsupported FILSHLP"); |
| 1327 | return 0; |
| 1328 | } |
| 1329 | } |
| 1330 | |
| 1331 | val = get_param(cmd, "NAIRealm"); |
| 1332 | if (val) { |
| 1333 | dut->ap_nairealm_int = 1; |
| 1334 | if (strlen(val) > sizeof(dut->ap_nairealm) - 1) |
| 1335 | return -1; |
| 1336 | snprintf(dut->ap_nairealm, sizeof(dut->ap_nairealm), "%s", val); |
| 1337 | } |
| 1338 | |
| 1339 | val = get_param(cmd, "DeauthDisassocTx"); |
| 1340 | if (val) { |
| 1341 | if (strcasecmp(val, "disable") == 0) { |
| 1342 | deauth_disassoc(dut, ifname, val); |
| 1343 | } else { |
| 1344 | send_resp(dut, conn, SIGMA_INVALID, |
| 1345 | "errorCode,Unsupported DeauthDisassocTx"); |
| 1346 | return 0; |
| 1347 | } |
| 1348 | } |
| 1349 | |
| 1350 | val = get_param(cmd, "RNR"); |
| 1351 | if (val) { |
| 1352 | if (strcasecmp(val, "enable") == 0) { |
| 1353 | dut->ap_rnr = VALUE_ENABLED; |
| 1354 | } else if (strcasecmp(val, "disable") == 0) { |
| 1355 | dut->ap_rnr = VALUE_DISABLED; |
| 1356 | } else { |
| 1357 | send_resp(dut, conn, SIGMA_INVALID, |
| 1358 | "errorCode,Unsupported RNR"); |
| 1359 | return 0; |
| 1360 | } |
| 1361 | } |
| 1362 | |
| 1363 | val = get_param(cmd, "BLEChannelUtil"); |
| 1364 | if (val) |
| 1365 | dut->ap_blechanutil = atoi(val); |
| 1366 | |
| 1367 | val = get_param(cmd, "BLEAvailAdminCap"); |
| 1368 | if (val) |
| 1369 | dut->ap_ble_admit_cap = atoi(val); |
| 1370 | |
| 1371 | val = get_param(cmd, "DataPPDUDuration"); |
| 1372 | if (val) |
| 1373 | dut->ap_datappdudura = atoi(val); |
| 1374 | |
| 1375 | val = get_param(cmd, "AirTimeFract"); |
| 1376 | if (val) |
| 1377 | dut->ap_airtimefract = atoi(val); |
| 1378 | |
| 1379 | val = get_param(cmd, "dhcpServIPADDR"); |
| 1380 | if (val) { |
| 1381 | if (strlen(val) > sizeof(dut->ap_dhcpserv_ipaddr) - 1) |
| 1382 | return -1; |
| 1383 | snprintf(dut->ap_dhcpserv_ipaddr, |
| 1384 | sizeof(dut->ap_dhcpserv_ipaddr), "%s", val); |
| 1385 | dut->ap_dhcp_stop = 1; |
| 1386 | } |
| 1387 | |
| 1388 | val = get_param(cmd, "ESP_IE"); |
| 1389 | if (val) { |
| 1390 | if (strcasecmp(val, "enable") == 0) { |
| 1391 | dut->ap_esp = VALUE_ENABLED; |
| 1392 | } else if (strcasecmp(val, "disable") == 0) { |
| 1393 | dut->ap_esp = VALUE_DISABLED; |
| 1394 | } else { |
| 1395 | send_resp(dut, conn, SIGMA_INVALID, |
| 1396 | "errorCode,Unsupported ESP_IE"); |
| 1397 | return 0; |
| 1398 | } |
| 1399 | } |
| 1400 | |
| 1401 | val = get_param(cmd, "BAWinSize"); |
| 1402 | if (val) |
| 1403 | dut->ap_bawinsize = atoi(val); |
| 1404 | |
| 1405 | val = get_param(cmd, "BLEStaCount"); |
| 1406 | if (val) |
| 1407 | dut->ap_blestacnt = atoi(val); |
| 1408 | |
priyadharshini gowthaman | 350f191 | 2018-06-04 13:09:12 -0700 | [diff] [blame] | 1409 | val = get_param(cmd, "PPDUTxType"); |
| 1410 | if (val) { |
| 1411 | if (strcasecmp(val, "MU") == 0) { |
| 1412 | dut->ap_he_ppdu = PPDU_MU; |
| 1413 | } else { |
| 1414 | send_resp(dut, conn, SIGMA_INVALID, |
| 1415 | "errorCode,Unsupported PPDUTxType"); |
| 1416 | return 0; |
| 1417 | } |
| 1418 | } |
| 1419 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1420 | return 1; |
| 1421 | } |
| 1422 | |
| 1423 | |
| 1424 | static void ath_inject_frame(struct sigma_dut *dut, const char *ifname, int tid) |
| 1425 | { |
| 1426 | char buf[256]; |
| 1427 | int tid_to_dscp[] = { 0x00, 0x20, 0x40, 0x60, 0x80, 0xa0, 0xc0, 0xe0 }; |
| 1428 | |
Pradeep Reddy POTTETI | d31d132 | 2016-10-13 17:22:03 +0530 | [diff] [blame] | 1429 | if (tid < 0 || |
| 1430 | tid >= (int) (sizeof(tid_to_dscp) / sizeof(tid_to_dscp[0]))) { |
| 1431 | sigma_dut_print(dut, DUT_MSG_ERROR, "Unsupported TID: %d", tid); |
| 1432 | return; |
| 1433 | } |
| 1434 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1435 | snprintf(buf, sizeof(buf), |
| 1436 | "wlanconfig %s list sta | grep : | cut -b 1-17 > %s", |
| 1437 | ifname, VI_QOS_TMP_FILE); |
| 1438 | if (system(buf) != 0) |
| 1439 | return; |
| 1440 | |
| 1441 | snprintf(buf, sizeof(buf), |
| 1442 | "ifconfig %s | grep HWaddr | cut -b 39-56 >> %s", |
| 1443 | ifname, VI_QOS_TMP_FILE); |
| 1444 | if (system(buf) != 0) |
| 1445 | sigma_dut_print(dut, DUT_MSG_ERROR, "Retrieve HWaddr failed"); |
| 1446 | |
| 1447 | snprintf(buf, sizeof(buf), "sed -n '3,$p' %s >> %s", |
| 1448 | VI_QOS_REFFILE, VI_QOS_TMP_FILE); |
| 1449 | if (system(buf) != 0) { |
| 1450 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 1451 | "Output redirection to VI_QOS_TMP_FILE failed"); |
| 1452 | } |
| 1453 | |
| 1454 | snprintf(buf, sizeof(buf), "sed '5 c %x' %s > %s", |
| 1455 | tid_to_dscp[tid], VI_QOS_TMP_FILE, VI_QOS_FILE); |
| 1456 | if (system(buf) != 0) { |
| 1457 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 1458 | "Append TID to VI_QOS_FILE failed "); |
| 1459 | } |
| 1460 | |
| 1461 | snprintf(buf, sizeof(buf), "ethinject %s %s", ifname, VI_QOS_FILE); |
| 1462 | if (system(buf) != 0) |
| 1463 | sigma_dut_print(dut, DUT_MSG_ERROR, "Ethinject frame failed"); |
| 1464 | } |
| 1465 | |
| 1466 | |
| 1467 | static int ath_ap_send_addba_req(struct sigma_dut *dut, struct sigma_conn *conn, |
| 1468 | struct sigma_cmd *cmd) |
| 1469 | { |
| 1470 | const char *val; |
| 1471 | char *ifname; |
| 1472 | char buf[256]; |
| 1473 | int tid = 0; |
| 1474 | |
| 1475 | ifname = get_main_ifname(); |
| 1476 | val = get_param(cmd, "TID"); |
| 1477 | if (val) { |
| 1478 | tid = atoi(val); |
| 1479 | if (tid) |
| 1480 | ath_inject_frame(dut, ifname, tid); |
| 1481 | } |
| 1482 | |
| 1483 | /* NOTE: This is the command sequence on Peregrine for ADDBA */ |
| 1484 | snprintf(buf, sizeof(buf), "iwpriv %s setaddbaoper 1", ifname); |
| 1485 | if (system(buf) != 0) { |
| 1486 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 1487 | "iwpriv setaddbaoper failed"); |
| 1488 | } |
| 1489 | |
| 1490 | snprintf(buf, sizeof(buf), "wifitool %s senddelba 1 %d 1 4", |
| 1491 | ifname, tid); |
| 1492 | if (system(buf) != 0) { |
| 1493 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 1494 | "wifitool senddelba failed"); |
| 1495 | } |
| 1496 | |
| 1497 | snprintf(buf, sizeof(buf), "wifitool %s sendaddba 1 %d 64", |
| 1498 | ifname, tid); |
| 1499 | if (system(buf) != 0) { |
| 1500 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 1501 | "wifitool sendaddba failed"); |
| 1502 | } |
| 1503 | |
| 1504 | return 1; |
| 1505 | } |
| 1506 | |
| 1507 | |
Mohammed Shafi Shajakhan | a0535d4 | 2016-06-17 11:55:00 +0530 | [diff] [blame] | 1508 | static int ath10k_debug_enable_addba_req(struct sigma_dut *dut, int tid, |
| 1509 | const char *sta_mac, |
| 1510 | const char *dir_path) |
| 1511 | { |
| 1512 | DIR *dir; |
| 1513 | struct dirent *entry; |
| 1514 | char buf[128], path[128]; |
| 1515 | int ret = 0; |
| 1516 | |
| 1517 | dir = opendir(dir_path); |
| 1518 | if (!dir) |
| 1519 | return 0; |
| 1520 | |
| 1521 | while ((entry = readdir(dir))) { |
| 1522 | ret = 1; |
| 1523 | |
| 1524 | if (strcmp(entry->d_name, ".") == 0 || |
| 1525 | strcmp(entry->d_name, "..") == 0) |
| 1526 | continue; |
| 1527 | |
| 1528 | snprintf(path, sizeof(path) - 1, "%s/%s", |
| 1529 | dir_path, entry->d_name); |
| 1530 | path[sizeof(path) - 1] = 0; |
| 1531 | |
| 1532 | if (strcmp(entry->d_name, sta_mac) == 0) { |
| 1533 | snprintf(buf, sizeof(buf), "echo 1 > %s/aggr_mode", |
| 1534 | path); |
| 1535 | if (system(buf) != 0) { |
| 1536 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 1537 | "Failed to set aggr mode for ath10k"); |
| 1538 | } |
| 1539 | |
| 1540 | snprintf(buf, sizeof(buf), "echo %d 32 > %s/addba", |
| 1541 | tid, path); |
| 1542 | if (system(buf) != 0) { |
| 1543 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 1544 | "Failed to set addbareq for ath10k"); |
| 1545 | } |
| 1546 | |
| 1547 | break; |
| 1548 | } |
| 1549 | |
| 1550 | /* Recursively search subdirectories */ |
| 1551 | ath10k_debug_enable_addba_req(dut, tid, sta_mac, path); |
| 1552 | } |
| 1553 | |
| 1554 | closedir(dir); |
| 1555 | |
| 1556 | return ret; |
| 1557 | } |
| 1558 | |
| 1559 | |
| 1560 | static int ath10k_ap_send_addba_req(struct sigma_dut *dut, |
| 1561 | struct sigma_cmd *cmd) |
| 1562 | { |
| 1563 | const char *val; |
| 1564 | int tid = 0; |
| 1565 | |
| 1566 | val = get_param(cmd, "TID"); |
| 1567 | if (val) |
| 1568 | tid = atoi(val); |
| 1569 | |
| 1570 | val = get_param(cmd, "sta_mac_address"); |
| 1571 | if (!val) { |
| 1572 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 1573 | "Failed to parse station MAC address"); |
| 1574 | return 0; |
| 1575 | } |
| 1576 | |
| 1577 | return ath10k_debug_enable_addba_req(dut, tid, val, |
| 1578 | "/sys/kernel/debug/ieee80211"); |
| 1579 | } |
| 1580 | |
| 1581 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1582 | static int cmd_ap_send_addba_req(struct sigma_dut *dut, struct sigma_conn *conn, |
| 1583 | struct sigma_cmd *cmd) |
| 1584 | { |
| 1585 | /* const char *name = get_param(cmd, "NAME"); */ |
| 1586 | /* const char *ifname = get_param(cmd, "INTERFACE"); */ |
Mohammed Shafi Shajakhan | a0535d4 | 2016-06-17 11:55:00 +0530 | [diff] [blame] | 1587 | struct stat s; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1588 | |
| 1589 | switch (get_driver_type()) { |
| 1590 | case DRIVER_ATHEROS: |
| 1591 | return ath_ap_send_addba_req(dut, conn, cmd); |
| 1592 | case DRIVER_OPENWRT: |
| 1593 | switch (get_openwrt_driver_type()) { |
| 1594 | case OPENWRT_DRIVER_ATHEROS: |
| 1595 | return ath_ap_send_addba_req(dut, conn, cmd); |
| 1596 | default: |
| 1597 | send_resp(dut, conn, SIGMA_ERROR, |
| 1598 | "errorCode,ap_send_addba_req not supported with this driver"); |
| 1599 | return 0; |
| 1600 | } |
Pradeep Reddy POTTETI | fdb0491 | 2016-08-02 14:16:24 +0530 | [diff] [blame] | 1601 | case DRIVER_WCN: |
| 1602 | case DRIVER_LINUX_WCN: |
| 1603 | /* AP automatically sends ADDBA request after association. */ |
| 1604 | sigma_dut_print(dut, DUT_MSG_INFO, |
| 1605 | "ap_send_addba_req command ignored"); |
| 1606 | return 1; |
Mohammed Shafi Shajakhan | a0535d4 | 2016-06-17 11:55:00 +0530 | [diff] [blame] | 1607 | case DRIVER_MAC80211: |
| 1608 | if (stat("/sys/module/ath10k_core", &s) == 0) |
| 1609 | return ath10k_ap_send_addba_req(dut, cmd); |
| 1610 | /* fall through */ |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1611 | default: |
| 1612 | send_resp(dut, conn, SIGMA_ERROR, |
| 1613 | "errorCode,ap_send_addba_req not supported with this driver"); |
| 1614 | return 0; |
| 1615 | } |
| 1616 | } |
| 1617 | |
| 1618 | |
| 1619 | static int cmd_ap_set_security(struct sigma_dut *dut, struct sigma_conn *conn, |
| 1620 | struct sigma_cmd *cmd) |
| 1621 | { |
| 1622 | /* const char *name = get_param(cmd, "NAME"); */ |
| 1623 | const char *val; |
| 1624 | unsigned int wlan_tag = 1; |
Ankita Bajaj | 0d212e8 | 2017-11-27 15:54:57 +0530 | [diff] [blame] | 1625 | const char *security; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1626 | |
| 1627 | val = get_param(cmd, "WLAN_TAG"); |
| 1628 | if (val) |
| 1629 | wlan_tag = atoi(val); |
| 1630 | |
Ankita Bajaj | 0d212e8 | 2017-11-27 15:54:57 +0530 | [diff] [blame] | 1631 | security = get_param(cmd, "Security"); |
| 1632 | |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 1633 | if (wlan_tag > 1) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1634 | val = get_param(cmd, "KEYMGNT"); |
Ankita Bajaj | 0d212e8 | 2017-11-27 15:54:57 +0530 | [diff] [blame] | 1635 | if (!val) |
| 1636 | val = get_param(cmd, "KeyMgmtType"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1637 | if (val) { |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 1638 | if (strcasecmp(val, "NONE") == 0) { |
| 1639 | dut->ap_tag_key_mgmt[wlan_tag - 2] = AP2_OPEN; |
| 1640 | } else if (strcasecmp(val, "OSEN") == 0 && |
| 1641 | wlan_tag == 2) { |
| 1642 | /* |
| 1643 | * OSEN only supported on WLAN_TAG = 2 for now |
| 1644 | */ |
| 1645 | dut->ap_tag_key_mgmt[wlan_tag - 2] = AP2_OSEN; |
Ankita Bajaj | 0d212e8 | 2017-11-27 15:54:57 +0530 | [diff] [blame] | 1646 | } else if (strcasecmp(val, "WPA2-PSK") == 0 || |
| 1647 | (security && |
| 1648 | strcasecmp(security, "PSK") == 0 && |
| 1649 | strcasecmp(val, "WPA2") == 0)) { |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 1650 | dut->ap_tag_key_mgmt[wlan_tag - 2] = |
| 1651 | AP2_WPA2_PSK; |
Jouni Malinen | 353ba8b | 2018-01-10 17:04:12 +0200 | [diff] [blame] | 1652 | } else if (strcasecmp(val, "OWE") == 0 && |
| 1653 | wlan_tag == 2) { |
| 1654 | dut->ap_tag_key_mgmt[wlan_tag - 2] = |
| 1655 | AP2_WPA2_OWE; |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 1656 | } else { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1657 | send_resp(dut, conn, SIGMA_INVALID, |
| 1658 | "errorCode,Unsupported KEYMGNT"); |
| 1659 | return 0; |
| 1660 | } |
| 1661 | return 1; |
| 1662 | } |
| 1663 | } |
| 1664 | |
| 1665 | val = get_param(cmd, "KEYMGNT"); |
Ankita Bajaj | 0d212e8 | 2017-11-27 15:54:57 +0530 | [diff] [blame] | 1666 | if (!val) |
| 1667 | val = get_param(cmd,"KeyMgmtType"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1668 | if (val) { |
Ankita Bajaj | 0d212e8 | 2017-11-27 15:54:57 +0530 | [diff] [blame] | 1669 | if (strcasecmp(val, "WPA2-PSK") == 0 || |
| 1670 | (security && strcasecmp(security, "PSK") == 0 && |
| 1671 | strcasecmp(val, "WPA2") == 0)) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1672 | dut->ap_key_mgmt = AP_WPA2_PSK; |
| 1673 | dut->ap_cipher = AP_CCMP; |
| 1674 | } else if (strcasecmp(val, "WPA2-EAP") == 0 || |
| 1675 | strcasecmp(val, "WPA2-Ent") == 0) { |
| 1676 | dut->ap_key_mgmt = AP_WPA2_EAP; |
| 1677 | dut->ap_cipher = AP_CCMP; |
Jouni Malinen | ad395a2 | 2017-09-01 21:13:46 +0300 | [diff] [blame] | 1678 | } else if (strcasecmp(val, "SuiteB") == 0) { |
| 1679 | dut->ap_key_mgmt = AP_SUITEB; |
| 1680 | dut->ap_cipher = AP_GCMP_256; |
Jouni Malinen | d75e4d8 | 2018-01-11 20:21:15 +0200 | [diff] [blame] | 1681 | dut->ap_pmf = AP_PMF_REQUIRED; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1682 | } else if (strcasecmp(val, "WPA-PSK") == 0) { |
| 1683 | dut->ap_key_mgmt = AP_WPA_PSK; |
| 1684 | dut->ap_cipher = AP_TKIP; |
| 1685 | } else if (strcasecmp(val, "WPA-EAP") == 0 || |
| 1686 | strcasecmp(val, "WPA-Ent") == 0) { |
| 1687 | dut->ap_key_mgmt = AP_WPA_EAP; |
| 1688 | dut->ap_cipher = AP_TKIP; |
| 1689 | } else if (strcasecmp(val, "WPA2-Mixed") == 0) { |
| 1690 | dut->ap_key_mgmt = AP_WPA2_EAP_MIXED; |
| 1691 | dut->ap_cipher = AP_CCMP_TKIP; |
| 1692 | } else if (strcasecmp(val, "WPA2-PSK-Mixed") == 0) { |
| 1693 | dut->ap_key_mgmt = AP_WPA2_PSK_MIXED; |
| 1694 | dut->ap_cipher = AP_CCMP_TKIP; |
Jouni Malinen | 794a7a3 | 2018-01-10 16:39:34 +0200 | [diff] [blame] | 1695 | } else if (strcasecmp(val, "WPA2-SAE") == 0 || |
| 1696 | strcasecmp(val, "SAE") == 0) { |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 1697 | dut->ap_key_mgmt = AP_WPA2_SAE; |
| 1698 | dut->ap_cipher = AP_CCMP; |
Jouni Malinen | 1287cd7 | 2018-01-04 17:08:01 +0200 | [diff] [blame] | 1699 | dut->ap_pmf = AP_PMF_REQUIRED; |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 1700 | } else if (strcasecmp(val, "WPA2-PSK-SAE") == 0) { |
| 1701 | dut->ap_key_mgmt = AP_WPA2_PSK_SAE; |
| 1702 | dut->ap_cipher = AP_CCMP; |
Jouni Malinen | 1287cd7 | 2018-01-04 17:08:01 +0200 | [diff] [blame] | 1703 | dut->ap_pmf = AP_PMF_OPTIONAL; |
Jouni Malinen | 147b3c3 | 2017-10-09 16:51:54 +0300 | [diff] [blame] | 1704 | } else if (strcasecmp(val, "OWE") == 0) { |
| 1705 | dut->ap_key_mgmt = AP_WPA2_OWE; |
| 1706 | dut->ap_cipher = AP_CCMP; |
Jouni Malinen | 1287cd7 | 2018-01-04 17:08:01 +0200 | [diff] [blame] | 1707 | dut->ap_pmf = AP_PMF_REQUIRED; |
Jouni Malinen | 4cf699f | 2018-06-19 00:46:27 +0300 | [diff] [blame] | 1708 | } else if (strcasecmp(val, "WPA2-ENT-OSEN") == 0) { |
| 1709 | dut->ap_key_mgmt = AP_WPA2_EAP_OSEN; |
| 1710 | dut->ap_cipher = AP_CCMP; |
| 1711 | dut->ap_pmf = AP_PMF_OPTIONAL; |
Jouni Malinen | 6be21c8 | 2018-08-01 18:47:24 +0300 | [diff] [blame] | 1712 | } else if (strcasecmp(val, "FT-EAP") == 0) { |
| 1713 | dut->ap_key_mgmt = AP_WPA2_FT_EAP; |
| 1714 | dut->ap_cipher = AP_CCMP; |
| 1715 | dut->ap_pmf = AP_PMF_OPTIONAL; |
| 1716 | } else if (strcasecmp(val, "FT-PSK") == 0) { |
| 1717 | dut->ap_key_mgmt = AP_WPA2_FT_PSK; |
| 1718 | dut->ap_cipher = AP_CCMP; |
| 1719 | dut->ap_pmf = AP_PMF_OPTIONAL; |
| 1720 | } else if (strcasecmp(val, "WPA2-ENT-256") == 0) { |
| 1721 | dut->ap_key_mgmt = AP_WPA2_EAP_SHA256; |
| 1722 | dut->ap_cipher = AP_CCMP; |
| 1723 | dut->ap_pmf = AP_PMF_OPTIONAL; |
| 1724 | } else if (strcasecmp(val, "WPA2-PSK-256") == 0) { |
| 1725 | dut->ap_key_mgmt = AP_WPA2_PSK_SHA256; |
| 1726 | dut->ap_cipher = AP_CCMP; |
| 1727 | dut->ap_pmf = AP_PMF_OPTIONAL; |
| 1728 | } else if (strcasecmp(val, "WPA2-ENT-FT-EAP") == 0) { |
| 1729 | dut->ap_key_mgmt = AP_WPA2_ENT_FT_EAP; |
| 1730 | dut->ap_cipher = AP_CCMP; |
| 1731 | dut->ap_pmf = AP_PMF_OPTIONAL; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1732 | } else if (strcasecmp(val, "NONE") == 0) { |
| 1733 | dut->ap_key_mgmt = AP_OPEN; |
| 1734 | dut->ap_cipher = AP_PLAIN; |
| 1735 | } else { |
| 1736 | send_resp(dut, conn, SIGMA_INVALID, |
| 1737 | "errorCode,Unsupported KEYMGNT"); |
| 1738 | return 0; |
| 1739 | } |
| 1740 | } |
| 1741 | |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 1742 | val = get_param(cmd, "ECGroupID"); |
| 1743 | if (val) { |
Jouni Malinen | ed670f4 | 2017-08-31 01:39:28 +0300 | [diff] [blame] | 1744 | free(dut->ap_sae_groups); |
| 1745 | dut->ap_sae_groups = strdup(val); |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 1746 | } |
| 1747 | |
Jouni Malinen | 2f524ce | 2017-08-31 01:43:29 +0300 | [diff] [blame] | 1748 | val = get_param(cmd, "AntiCloggingThreshold"); |
| 1749 | if (val) |
| 1750 | dut->sae_anti_clogging_threshold = atoi(val); |
| 1751 | |
Jouni Malinen | b347db0 | 2017-09-02 01:36:03 +0300 | [diff] [blame] | 1752 | val = get_param(cmd, "Reflection"); |
| 1753 | if (val) |
| 1754 | dut->sae_reflection = strcasecmp(val, "SAE") == 0; |
| 1755 | |
Jouni Malinen | 6814313 | 2017-09-02 02:34:08 +0300 | [diff] [blame] | 1756 | val = get_param(cmd, "InvalidSAEElement"); |
| 1757 | if (val) { |
| 1758 | free(dut->sae_commit_override); |
| 1759 | dut->sae_commit_override = strdup(val); |
| 1760 | } |
| 1761 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1762 | val = get_param(cmd, "ENCRYPT"); |
Ankita Bajaj | 0d212e8 | 2017-11-27 15:54:57 +0530 | [diff] [blame] | 1763 | if (!val) |
| 1764 | val = get_param(cmd, "EncpType"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1765 | if (val) { |
| 1766 | if (strcasecmp(val, "WEP") == 0) { |
| 1767 | dut->ap_cipher = AP_WEP; |
| 1768 | } else if (strcasecmp(val, "TKIP") == 0) { |
| 1769 | dut->ap_cipher = AP_TKIP; |
| 1770 | } else if (strcasecmp(val, "AES") == 0 || |
| 1771 | strcasecmp(val, "AES-CCMP") == 0) { |
| 1772 | dut->ap_cipher = AP_CCMP; |
Jouni Malinen | 3d633da | 2017-09-14 22:19:21 +0300 | [diff] [blame] | 1773 | } else if (strcasecmp(val, "AES-GCMP") == 0) { |
| 1774 | dut->ap_cipher = AP_GCMP_128; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1775 | } else { |
| 1776 | send_resp(dut, conn, SIGMA_INVALID, |
| 1777 | "errorCode,Unsupported ENCRYPT"); |
| 1778 | return 0; |
| 1779 | } |
| 1780 | } |
| 1781 | |
Jouni Malinen | 3d633da | 2017-09-14 22:19:21 +0300 | [diff] [blame] | 1782 | val = get_param(cmd, "PairwiseCipher"); |
| 1783 | if (val) { |
| 1784 | if (strcasecmp(val, "AES-GCMP-256") == 0) { |
| 1785 | dut->ap_cipher = AP_GCMP_256; |
| 1786 | } else if (strcasecmp(val, "AES-CCMP-256") == 0) { |
| 1787 | dut->ap_cipher = AP_CCMP_256; |
| 1788 | } else if (strcasecmp(val, "AES-GCMP-128") == 0) { |
| 1789 | dut->ap_cipher = AP_GCMP_128; |
| 1790 | } else if (strcasecmp(val, "AES-CCMP-128") == 0) { |
| 1791 | dut->ap_cipher = AP_CCMP; |
Jouni Malinen | d538c78 | 2017-11-17 12:13:04 +0200 | [diff] [blame] | 1792 | } else if (strcasecmp(val, "AES-CCMP-128 AES-GCMP-256") == 0 || |
| 1793 | strcasecmp(val, "AES-GCMP-256 AES-CCMP-128") == 0) { |
| 1794 | dut->ap_cipher = AP_CCMP_128_GCMP_256; |
Jouni Malinen | 3d633da | 2017-09-14 22:19:21 +0300 | [diff] [blame] | 1795 | } else { |
| 1796 | send_resp(dut, conn, SIGMA_INVALID, |
| 1797 | "errorCode,Unsupported PairwiseCipher"); |
| 1798 | return 0; |
| 1799 | } |
| 1800 | } |
| 1801 | |
Jouni Malinen | 2ba2449 | 2017-11-17 12:43:59 +0200 | [diff] [blame] | 1802 | val = get_param(cmd, "GroupCipher"); |
| 1803 | if (val) { |
| 1804 | if (strcasecmp(val, "AES-GCMP-256") == 0) { |
| 1805 | dut->ap_group_cipher = AP_GCMP_256; |
| 1806 | } else if (strcasecmp(val, "AES-CCMP-256") == 0) { |
| 1807 | dut->ap_group_cipher = AP_CCMP_256; |
| 1808 | } else if (strcasecmp(val, "AES-GCMP-128") == 0) { |
| 1809 | dut->ap_group_cipher = AP_GCMP_128; |
| 1810 | } else if (strcasecmp(val, "AES-CCMP-128") == 0) { |
| 1811 | dut->ap_group_cipher = AP_CCMP; |
| 1812 | } else { |
| 1813 | send_resp(dut, conn, SIGMA_INVALID, |
| 1814 | "errorCode,Unsupported GroupCipher"); |
| 1815 | return 0; |
| 1816 | } |
| 1817 | } |
| 1818 | |
Jouni Malinen | 3d633da | 2017-09-14 22:19:21 +0300 | [diff] [blame] | 1819 | val = get_param(cmd, "GroupMgntCipher"); |
| 1820 | if (val) { |
| 1821 | if (strcasecmp(val, "BIP-GMAC-256") == 0) { |
| 1822 | dut->ap_group_mgmt_cipher = AP_BIP_GMAC_256; |
| 1823 | } else if (strcasecmp(val, "BIP-CMAC-256") == 0) { |
| 1824 | dut->ap_group_mgmt_cipher = AP_BIP_CMAC_256; |
| 1825 | } else if (strcasecmp(val, "BIP-GMAC-128") == 0) { |
| 1826 | dut->ap_group_mgmt_cipher = AP_BIP_GMAC_128; |
| 1827 | } else if (strcasecmp(val, "BIP-CMAC-128") == 0) { |
| 1828 | dut->ap_group_mgmt_cipher = AP_BIP_CMAC_128; |
| 1829 | } else { |
| 1830 | send_resp(dut, conn, SIGMA_INVALID, |
| 1831 | "errorCode,Unsupported GroupMgntCipher"); |
| 1832 | return 0; |
| 1833 | } |
| 1834 | } |
| 1835 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1836 | val = get_param(cmd, "WEPKEY"); |
| 1837 | if (val) { |
| 1838 | size_t len; |
| 1839 | if (dut->ap_cipher != AP_WEP) { |
| 1840 | send_resp(dut, conn, SIGMA_INVALID, |
| 1841 | "errorCode,Unexpected WEPKEY without WEP " |
| 1842 | "configuration"); |
| 1843 | return 0; |
| 1844 | } |
| 1845 | len = strlen(val); |
| 1846 | if (len != 10 && len != 26) { |
| 1847 | send_resp(dut, conn, SIGMA_INVALID, |
| 1848 | "errorCode,Unexpected WEPKEY length"); |
| 1849 | return 0; |
| 1850 | } |
| 1851 | snprintf(dut->ap_wepkey, sizeof(dut->ap_wepkey), "%s", val); |
| 1852 | } |
| 1853 | |
| 1854 | val = get_param(cmd, "PSK"); |
Ankita Bajaj | 0d212e8 | 2017-11-27 15:54:57 +0530 | [diff] [blame] | 1855 | if (!val) |
| 1856 | val = get_param(cmd, "passphrase"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1857 | if (val) { |
Jouni Malinen | 2126f42 | 2017-10-11 23:24:33 +0300 | [diff] [blame] | 1858 | if (dut->ap_key_mgmt != AP_WPA2_SAE && strlen(val) > 64) |
| 1859 | return -1; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1860 | if (strlen(val) > sizeof(dut->ap_passphrase) - 1) |
| 1861 | return -1; |
| 1862 | snprintf(dut->ap_passphrase, sizeof(dut->ap_passphrase), |
| 1863 | "%s", val); |
| 1864 | } |
| 1865 | |
Jouni Malinen | 6337062 | 2017-11-18 17:47:13 +0200 | [diff] [blame] | 1866 | val = get_param(cmd, "PSKHEX"); |
| 1867 | if (val) { |
| 1868 | if (strlen(val) != 64) |
| 1869 | return -1; |
| 1870 | strlcpy(dut->ap_psk, val, sizeof(dut->ap_psk)); |
| 1871 | } |
| 1872 | |
Ankita Bajaj | 0d212e8 | 2017-11-27 15:54:57 +0530 | [diff] [blame] | 1873 | if (dut->program == PROGRAM_OCE && dut->dev_role == DEVROLE_STA_CFON) |
| 1874 | dut->ap_pmf = AP_PMF_OPTIONAL; |
| 1875 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1876 | val = get_param(cmd, "PMF"); |
| 1877 | if (val) { |
| 1878 | if (strcasecmp(val, "Disabled") == 0) { |
| 1879 | dut->ap_pmf = AP_PMF_DISABLED; |
| 1880 | } else if (strcasecmp(val, "Optional") == 0) { |
| 1881 | dut->ap_pmf = AP_PMF_OPTIONAL; |
| 1882 | } else if (strcasecmp(val, "Required") == 0) { |
| 1883 | dut->ap_pmf = AP_PMF_REQUIRED; |
| 1884 | } else { |
| 1885 | send_resp(dut, conn, SIGMA_INVALID, |
| 1886 | "errorCode,Unsupported PMF"); |
| 1887 | return 0; |
| 1888 | } |
| 1889 | } |
| 1890 | |
| 1891 | if (dut->ap_key_mgmt == AP_OPEN) { |
| 1892 | dut->ap_hs2 = 0; |
| 1893 | dut->ap_pmf = AP_PMF_DISABLED; |
| 1894 | } |
| 1895 | |
| 1896 | dut->ap_add_sha256 = 0; |
| 1897 | val = get_param(cmd, "SHA256AD"); |
| 1898 | if (val == NULL) |
| 1899 | val = get_param(cmd, "SHA256"); |
| 1900 | if (val) { |
| 1901 | if (strcasecmp(val, "Disabled") == 0) { |
| 1902 | } else if (strcasecmp(val, "Enabled") == 0) { |
| 1903 | dut->ap_add_sha256 = 1; |
| 1904 | } else { |
| 1905 | send_resp(dut, conn, SIGMA_INVALID, |
| 1906 | "errorCode,Unsupported PMF"); |
| 1907 | return 0; |
| 1908 | } |
| 1909 | } |
| 1910 | |
Sarvepalli, Rajesh Babu | 24dc7e4 | 2016-03-18 21:27:26 +0530 | [diff] [blame] | 1911 | val = get_param(cmd, "PreAuthentication"); |
| 1912 | if (val) { |
| 1913 | if (strcasecmp(val, "disabled") == 0) { |
| 1914 | dut->ap_rsn_preauth = 0; |
| 1915 | } else if (strcasecmp(val, "enabled") == 0) { |
| 1916 | dut->ap_rsn_preauth = 1; |
| 1917 | } else { |
| 1918 | send_resp(dut, conn, SIGMA_INVALID, |
| 1919 | "errorCode,Unsupported PreAuthentication value"); |
| 1920 | return 0; |
| 1921 | } |
| 1922 | } |
| 1923 | |
priyadharshini gowthaman | de81f39 | 2017-12-28 15:28:49 -0800 | [diff] [blame] | 1924 | val = get_param(cmd, "AKMSuiteType"); |
| 1925 | if (val) { |
| 1926 | unsigned int akmsuitetype = 0; |
| 1927 | |
| 1928 | dut->ap_akm = 1; |
| 1929 | akmsuitetype = atoi(val); |
| 1930 | if (akmsuitetype == 14) { |
| 1931 | dut->ap_add_sha256 = 1; |
| 1932 | } else if (akmsuitetype == 15) { |
| 1933 | dut->ap_add_sha384 = 1; |
| 1934 | } else { |
| 1935 | send_resp(dut, conn, SIGMA_INVALID, |
| 1936 | "errorCode,Unsupported AKMSuitetype"); |
| 1937 | return 0; |
| 1938 | } |
| 1939 | } |
| 1940 | |
| 1941 | val = get_param(cmd, "PMKSACaching"); |
| 1942 | if (val) { |
| 1943 | dut->ap_pmksa = 1; |
| 1944 | if (strcasecmp(val, "disabled") == 0) { |
| 1945 | dut->ap_pmksa_caching = 1; |
| 1946 | } else if (strcasecmp(val, "enabled") == 0) { |
| 1947 | dut->ap_pmksa_caching = 0; |
| 1948 | } else { |
| 1949 | send_resp(dut, conn, SIGMA_INVALID, |
| 1950 | "errorCode,Unsupported PMKSACaching value"); |
| 1951 | return 0; |
| 1952 | } |
| 1953 | } |
| 1954 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1955 | return 1; |
| 1956 | } |
| 1957 | |
| 1958 | |
Ankita Bajaj | 0d5825b | 2017-10-25 16:20:17 +0530 | [diff] [blame] | 1959 | int sta_cfon_set_wireless(struct sigma_dut *dut, struct sigma_conn *conn, |
| 1960 | struct sigma_cmd *cmd) |
| 1961 | { |
| 1962 | int status; |
| 1963 | |
| 1964 | status = cmd_ap_set_wireless(dut, conn, cmd); |
| 1965 | if (status != 1) |
| 1966 | return status; |
Ankita Bajaj | 0d212e8 | 2017-11-27 15:54:57 +0530 | [diff] [blame] | 1967 | status = cmd_ap_set_security(dut, conn, cmd); |
| 1968 | if (status != 1) |
| 1969 | return status; |
Ankita Bajaj | 0d5825b | 2017-10-25 16:20:17 +0530 | [diff] [blame] | 1970 | return cmd_ap_config_commit(dut, conn, cmd); |
| 1971 | } |
| 1972 | |
| 1973 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1974 | static int cmd_ap_set_radius(struct sigma_dut *dut, struct sigma_conn *conn, |
| 1975 | struct sigma_cmd *cmd) |
| 1976 | { |
| 1977 | /* const char *name = get_param(cmd, "NAME"); */ |
| 1978 | const char *val; |
| 1979 | unsigned int wlan_tag = 1, radius_port = 0; |
| 1980 | char *radius_ipaddr = NULL, *radius_password = NULL; |
| 1981 | |
| 1982 | val = get_param(cmd, "WLAN_TAG"); |
| 1983 | if (val) { |
| 1984 | wlan_tag = atoi(val); |
| 1985 | if (wlan_tag != 1 && wlan_tag != 2) { |
| 1986 | send_resp(dut, conn, SIGMA_INVALID, |
| 1987 | "errorCode,Invalid WLAN_TAG"); |
| 1988 | return 0; |
| 1989 | } |
| 1990 | } |
| 1991 | |
| 1992 | val = get_param(cmd, "PORT"); |
| 1993 | if (val) |
| 1994 | radius_port = atoi(val); |
| 1995 | |
| 1996 | if (wlan_tag == 1) { |
| 1997 | if (radius_port) |
| 1998 | dut->ap_radius_port = radius_port; |
| 1999 | radius_ipaddr = dut->ap_radius_ipaddr; |
| 2000 | radius_password = dut->ap_radius_password; |
| 2001 | } else if (wlan_tag == 2) { |
| 2002 | if (radius_port) |
| 2003 | dut->ap2_radius_port = radius_port; |
| 2004 | radius_ipaddr = dut->ap2_radius_ipaddr; |
| 2005 | radius_password = dut->ap2_radius_password; |
| 2006 | } |
| 2007 | |
| 2008 | val = get_param(cmd, "IPADDR"); |
| 2009 | if (val) { |
| 2010 | if (strlen(val) > sizeof(dut->ap_radius_ipaddr) - 1) |
| 2011 | return -1; |
| 2012 | snprintf(radius_ipaddr, sizeof(dut->ap_radius_ipaddr), |
| 2013 | "%s", val); |
| 2014 | } |
| 2015 | |
| 2016 | val = get_param(cmd, "PASSWORD"); |
| 2017 | if (val) { |
| 2018 | if (strlen(val) > sizeof(dut->ap_radius_password) - 1) |
| 2019 | return -1; |
| 2020 | snprintf(radius_password, |
| 2021 | sizeof(dut->ap_radius_password), "%s", val); |
| 2022 | } |
| 2023 | |
| 2024 | return 1; |
| 2025 | } |
| 2026 | |
| 2027 | |
| 2028 | static void owrt_ap_set_radio(struct sigma_dut *dut, int id, |
| 2029 | const char *key, const char *val) |
| 2030 | { |
| 2031 | char buf[100]; |
| 2032 | |
| 2033 | if (val == NULL) { |
| 2034 | snprintf(buf, sizeof(buf), |
| 2035 | "uci delete wireless.wifi%d.%s", id, key); |
| 2036 | run_system(dut, buf); |
| 2037 | return; |
| 2038 | } |
| 2039 | |
| 2040 | snprintf(buf, sizeof(buf), "uci set wireless.wifi%d.%s=%s", |
| 2041 | id, key, val); |
| 2042 | run_system(dut, buf); |
| 2043 | } |
| 2044 | |
| 2045 | |
| 2046 | static void owrt_ap_set_list_radio(struct sigma_dut *dut, int id, |
| 2047 | const char *key, const char *val) |
| 2048 | { |
| 2049 | char buf[256]; |
| 2050 | |
| 2051 | if (val == NULL) { |
| 2052 | snprintf(buf, sizeof(buf), |
| 2053 | "uci del_list wireless.wifi%d.%s", id, key); |
| 2054 | run_system(dut, buf); |
| 2055 | return; |
| 2056 | } |
| 2057 | |
| 2058 | snprintf(buf, sizeof(buf), "uci add_list wireless.wifi%d.%s=%s", |
| 2059 | id, key, val); |
| 2060 | run_system(dut, buf); |
| 2061 | } |
| 2062 | |
| 2063 | |
| 2064 | static void owrt_ap_set_vap(struct sigma_dut *dut, int id, const char *key, |
| 2065 | const char *val) |
| 2066 | { |
| 2067 | char buf[256]; |
| 2068 | |
| 2069 | if (val == NULL) { |
| 2070 | snprintf(buf, sizeof(buf), |
| 2071 | "uci delete wireless.@wifi-iface[%d].%s", id, key); |
| 2072 | run_system(dut, buf); |
| 2073 | return; |
| 2074 | } |
| 2075 | |
| 2076 | snprintf(buf, sizeof(buf), "uci set wireless.@wifi-iface[%d].%s=%s", |
| 2077 | id, key, val); |
| 2078 | run_system(dut, buf); |
| 2079 | } |
| 2080 | |
| 2081 | |
| 2082 | static void owrt_ap_set_list_vap(struct sigma_dut *dut, int id, |
| 2083 | const char *key, const char *val) |
| 2084 | { |
priyadharshini gowthaman | 2323d0a | 2016-09-02 15:48:02 -0700 | [diff] [blame] | 2085 | char buf[1024]; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2086 | |
| 2087 | if (val == NULL) { |
| 2088 | snprintf(buf, sizeof(buf), |
| 2089 | "uci del_list wireless.@wifi-iface[%d].%s", id, key); |
| 2090 | run_system(dut, buf); |
| 2091 | return; |
| 2092 | } |
| 2093 | |
| 2094 | snprintf(buf, sizeof(buf), |
| 2095 | "uci add_list wireless.@wifi-iface[%d].%s=%s", |
| 2096 | id, key, val); |
| 2097 | run_system(dut, buf); |
| 2098 | } |
| 2099 | |
| 2100 | |
| 2101 | static void owrt_ap_add_vap(struct sigma_dut *dut, int id, const char *key, |
| 2102 | const char *val) |
| 2103 | { |
| 2104 | char buf[256]; |
| 2105 | |
| 2106 | if (val == NULL) { |
| 2107 | snprintf(buf, sizeof(buf), |
| 2108 | "uci delete wireless.@wifi-iface[%d].%s", id, key); |
| 2109 | run_system(dut, buf); |
| 2110 | return; |
| 2111 | } |
| 2112 | |
| 2113 | snprintf(buf, sizeof(buf), "uci add wireless wifi-iface"); |
| 2114 | run_system(dut, buf); |
| 2115 | snprintf(buf, sizeof(buf), "uci set wireless.@wifi-iface[%d].%s=%s", |
| 2116 | id, key, val); |
| 2117 | run_system(dut, buf); |
| 2118 | snprintf(buf, sizeof(buf), "uci set wireless.@wifi-iface[%d].%s=%s", |
| 2119 | id, "network", "lan"); |
| 2120 | run_system(dut, buf); |
| 2121 | snprintf(buf, sizeof(buf), "uci set wireless.@wifi-iface[%d].%s=%s", |
| 2122 | id, "mode", "ap"); |
| 2123 | run_system(dut, buf); |
| 2124 | snprintf(buf, sizeof(buf), "uci set wireless.@wifi-iface[%d].%s=%s", |
| 2125 | id, "encryption", "none"); |
| 2126 | run_system(dut, buf); |
| 2127 | } |
| 2128 | |
| 2129 | |
Alejandro Vasquez | 363f558 | 2018-07-17 11:25:05 -0700 | [diff] [blame] | 2130 | #define OPENWRT_MAX_NUM_RADIOS (MAX_RADIO + 1) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2131 | static void owrt_ap_config_radio(struct sigma_dut *dut) |
| 2132 | { |
Alejandro Vasquez | 363f558 | 2018-07-17 11:25:05 -0700 | [diff] [blame] | 2133 | int radio_id[MAX_RADIO] = { 0, 1, 2 }; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2134 | int radio_count, radio_no; |
| 2135 | char buf[64]; |
| 2136 | |
| 2137 | for (radio_count = 0; radio_count < OPENWRT_MAX_NUM_RADIOS; |
| 2138 | radio_count++) { |
| 2139 | snprintf(buf, sizeof(buf), "%s%d", "wifi", radio_count); |
| 2140 | for (radio_no = 0; radio_no < MAX_RADIO; radio_no++) { |
| 2141 | if (!sigma_radio_ifname[radio_no] || |
| 2142 | strcmp(sigma_radio_ifname[radio_no], buf) != 0) |
| 2143 | continue; |
| 2144 | owrt_ap_set_radio(dut, radio_count, "disabled", "0"); |
| 2145 | owrt_ap_set_vap(dut, radio_count, "device", buf); |
| 2146 | radio_id[radio_no] = radio_count; |
| 2147 | } |
| 2148 | } |
| 2149 | |
| 2150 | /* Hardware mode (11a/b/g/n/ac) & HT mode selection */ |
| 2151 | switch (dut->ap_mode) { |
| 2152 | case AP_11g: |
| 2153 | owrt_ap_set_radio(dut, radio_id[0], "hwmode", "11g"); |
| 2154 | break; |
| 2155 | case AP_11b: |
| 2156 | owrt_ap_set_radio(dut, radio_id[0], "hwmode", "11b"); |
| 2157 | break; |
| 2158 | case AP_11ng: |
| 2159 | owrt_ap_set_radio(dut, radio_id[0], "hwmode", "11ng"); |
| 2160 | owrt_ap_set_radio(dut, radio_id[0], "htmode", "HT20"); |
| 2161 | break; |
| 2162 | case AP_11a: |
| 2163 | owrt_ap_set_radio(dut, radio_id[0], "hwmode", "11a"); |
| 2164 | break; |
| 2165 | case AP_11na: |
| 2166 | owrt_ap_set_radio(dut, radio_id[0], "hwmode", "11na"); |
| 2167 | owrt_ap_set_radio(dut, radio_id[0], "htmode", "HT20"); |
| 2168 | break; |
| 2169 | case AP_11ac: |
| 2170 | owrt_ap_set_radio(dut, radio_id[0], "hwmode", "11ac"); |
| 2171 | owrt_ap_set_radio(dut, radio_id[0], "htmode", "HT80"); |
| 2172 | break; |
| 2173 | case AP_inval: |
| 2174 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 2175 | "MODE NOT SPECIFIED!"); |
| 2176 | return; |
| 2177 | default: |
| 2178 | owrt_ap_set_radio(dut, radio_id[0], "hwmode", "11ng"); |
| 2179 | owrt_ap_set_radio(dut, radio_id[0], "htmode", "HT20"); |
| 2180 | break; |
| 2181 | } |
| 2182 | |
| 2183 | if (dut->ap_is_dual) { |
| 2184 | /* Hardware mode (11a/b/g/n/ac) & HT mode selection */ |
| 2185 | switch (dut->ap_mode_1) { |
| 2186 | case AP_11g: |
| 2187 | owrt_ap_set_radio(dut, radio_id[1], "hwmode", "11g"); |
| 2188 | break; |
| 2189 | case AP_11b: |
| 2190 | owrt_ap_set_radio(dut, radio_id[1], "hwmode", "11b"); |
| 2191 | break; |
| 2192 | case AP_11ng: |
| 2193 | owrt_ap_set_radio(dut, radio_id[1], "hwmode", "11ng"); |
| 2194 | owrt_ap_set_radio(dut, radio_id[1], "htmode", "HT20"); |
| 2195 | break; |
| 2196 | case AP_11a: |
| 2197 | owrt_ap_set_radio(dut, radio_id[1], "hwmode", "11a"); |
| 2198 | break; |
| 2199 | case AP_11na: |
| 2200 | owrt_ap_set_radio(dut, radio_id[1], "hwmode", "11na"); |
| 2201 | owrt_ap_set_radio(dut, radio_id[1], "htmode", "HT20"); |
| 2202 | break; |
| 2203 | case AP_11ac: |
| 2204 | owrt_ap_set_radio(dut, radio_id[1], "hwmode", "11ac"); |
| 2205 | owrt_ap_set_radio(dut, radio_id[1], "htmode", "HT80"); |
| 2206 | break; |
| 2207 | case AP_inval: |
| 2208 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 2209 | "MODE NOT SPECIFIED!"); |
| 2210 | return; |
| 2211 | default: |
| 2212 | owrt_ap_set_radio(dut, radio_id[1], "hwmode", "11ng"); |
| 2213 | owrt_ap_set_radio(dut, radio_id[1], "htmode", "HT20"); |
| 2214 | break; |
| 2215 | } |
| 2216 | |
| 2217 | } |
| 2218 | |
| 2219 | /* Channel */ |
| 2220 | snprintf(buf, sizeof(buf), "%d", dut->ap_channel); |
| 2221 | owrt_ap_set_radio(dut, radio_id[0], "channel", buf); |
| 2222 | |
| 2223 | switch (dut->ap_chwidth) { |
| 2224 | case AP_20: |
| 2225 | owrt_ap_set_radio(dut, radio_id[0], "htmode", "HT20"); |
| 2226 | break; |
| 2227 | case AP_40: |
| 2228 | owrt_ap_set_radio(dut, radio_id[0], "htmode", "HT40"); |
| 2229 | break; |
| 2230 | case AP_80: |
| 2231 | owrt_ap_set_radio(dut, radio_id[0], "htmode", "HT80"); |
| 2232 | break; |
| 2233 | case AP_160: |
| 2234 | owrt_ap_set_radio(dut, radio_id[0], "htmode", "HT160"); |
| 2235 | break; |
priyadharshini gowthaman | 63ab848 | 2017-12-28 15:32:55 -0800 | [diff] [blame] | 2236 | case AP_80_80: |
| 2237 | owrt_ap_set_radio(dut, radio_id[0], "htmode", "HT80_80"); |
| 2238 | break; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2239 | case AP_AUTO: |
| 2240 | default: |
| 2241 | break; |
| 2242 | } |
| 2243 | |
| 2244 | if (dut->ap_channel == 140 || dut->ap_channel == 144) { |
| 2245 | if (get_openwrt_driver_type() == OPENWRT_DRIVER_ATHEROS) |
| 2246 | owrt_ap_set_radio(dut, radio_id[0], "set_ch_144", "3"); |
| 2247 | } |
| 2248 | |
| 2249 | if (dut->ap_is_dual) { |
| 2250 | snprintf(buf, sizeof(buf), "%d", dut->ap_channel_1); |
| 2251 | owrt_ap_set_radio(dut, radio_id[1], "channel", buf); |
| 2252 | } |
| 2253 | |
Adil Saeed Musthafa | 604c826 | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 2254 | /* Country Code */ |
| 2255 | if (dut->ap_reg_domain == REG_DOMAIN_GLOBAL) { |
| 2256 | const char *country; |
| 2257 | |
| 2258 | country = dut->ap_countrycode[0] ? dut->ap_countrycode : "US"; |
| 2259 | snprintf(buf, sizeof(buf), "%s4", country); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2260 | owrt_ap_set_radio(dut, radio_id[0], "country", buf); |
priyadharshini gowthaman | 27406b0 | 2017-12-28 15:35:45 -0800 | [diff] [blame] | 2261 | if (dut->ap_is_dual) |
| 2262 | owrt_ap_set_radio(dut, radio_id[1], "country", buf); |
Adil Saeed Musthafa | 604c826 | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 2263 | } else if (dut->ap_countrycode[0]) { |
| 2264 | owrt_ap_set_radio(dut, radio_id[0], "country", |
| 2265 | dut->ap_countrycode); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2266 | } |
| 2267 | |
| 2268 | if (dut->ap_disable_protection == 1) { |
| 2269 | owrt_ap_set_list_radio(dut, radio_id[0], "aggr_burst", "'0 0'"); |
| 2270 | owrt_ap_set_list_radio(dut, radio_id[0], "aggr_burst", "'1 0'"); |
| 2271 | owrt_ap_set_list_radio(dut, radio_id[0], "aggr_burst", "'2 0'"); |
| 2272 | owrt_ap_set_list_radio(dut, radio_id[0], "aggr_burst", "'3 0'"); |
| 2273 | } |
priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 2274 | |
| 2275 | if (dut->ap_oce == VALUE_ENABLED && |
| 2276 | get_driver_type() == DRIVER_OPENWRT) |
| 2277 | owrt_ap_set_radio(dut, radio_id[0], "bcnburst", "1"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2278 | } |
| 2279 | |
| 2280 | |
| 2281 | static int owrt_ap_config_vap_hs2(struct sigma_dut *dut, int vap_id) |
| 2282 | { |
| 2283 | char buf[256]; |
| 2284 | |
| 2285 | snprintf(buf, sizeof(buf), "%d", dut->ap_hs2); |
| 2286 | owrt_ap_set_vap(dut, vap_id, "hs20", buf); |
| 2287 | owrt_ap_set_vap(dut, vap_id, "qbssload", "1"); |
| 2288 | owrt_ap_set_vap(dut, vap_id, "hs20_deauth_req_timeout","3"); |
| 2289 | |
| 2290 | owrt_ap_set_list_vap(dut, vap_id, "hs20_oper_friendly_name", |
| 2291 | "'eng:Wi-Fi Alliance'"); |
| 2292 | |
| 2293 | owrt_ap_set_list_vap(dut, vap_id, "hs20_oper_friendly_name", |
| 2294 | "'chi:Wi-Fi\xe8\x81\x94\xe7\x9b\x9f'"); |
| 2295 | |
| 2296 | if (dut->ap_wan_metrics == 1) |
| 2297 | owrt_ap_set_vap(dut, vap_id, "hs20_wan_metrics", |
| 2298 | "'01:2500:384:0:0:10'"); |
| 2299 | else if (dut->ap_wan_metrics == 1) |
| 2300 | owrt_ap_set_vap(dut, vap_id, "hs20_wan_metrics", |
| 2301 | "'01:1500:384:20:20:10'"); |
| 2302 | else if (dut->ap_wan_metrics == 2) |
| 2303 | owrt_ap_set_vap(dut, vap_id, "hs20_wan_metrics", |
| 2304 | "'01:1500:384:20:20:10'"); |
| 2305 | else if (dut->ap_wan_metrics == 3) |
| 2306 | owrt_ap_set_vap(dut, vap_id, "hs20_wan_metrics", |
| 2307 | "'01:2000:1000:20:20:10'"); |
| 2308 | else if (dut->ap_wan_metrics == 4) |
| 2309 | owrt_ap_set_vap(dut, vap_id, "hs20_wan_metrics", |
| 2310 | "'01:8000:1000:20:20:10'"); |
| 2311 | else if (dut->ap_wan_metrics == 5) |
| 2312 | owrt_ap_set_vap(dut, vap_id, "hs20_wan_metrics", |
| 2313 | "'01:9000:5000:20:20:10'"); |
| 2314 | |
| 2315 | if (dut->ap_conn_capab == 1) { |
| 2316 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", "'1:0:0'"); |
| 2317 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", |
| 2318 | "'6:20:1'"); |
| 2319 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", |
| 2320 | "'6:22:0'"); |
| 2321 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", |
| 2322 | "'6:80:1'"); |
| 2323 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", |
| 2324 | "'6:443:1'"); |
| 2325 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", |
| 2326 | "'6:1723:0'"); |
| 2327 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", |
| 2328 | "'6:5060:0'"); |
| 2329 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", |
| 2330 | "'17:500:1'"); |
| 2331 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", |
| 2332 | "'17:5060:0'"); |
| 2333 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", |
| 2334 | "'17:4500:1'"); |
| 2335 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", |
| 2336 | "'50:0:1'"); |
| 2337 | } else if (dut->ap_conn_capab == 2) { |
| 2338 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", |
| 2339 | "'6:80:1'"); |
| 2340 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", |
| 2341 | "'6:443:1'"); |
| 2342 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", |
| 2343 | "'17:5060:1'"); |
| 2344 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", |
| 2345 | "'6:5060:1'"); |
| 2346 | } else if (dut->ap_conn_capab == 3) { |
| 2347 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", |
| 2348 | "'6:80:1'"); |
| 2349 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", |
| 2350 | "'6:443:1'"); |
| 2351 | } |
| 2352 | |
| 2353 | if (dut->ap_oper_class == 1) |
| 2354 | snprintf(buf, sizeof(buf), "%s", "51"); |
| 2355 | else if (dut->ap_oper_class == 2) |
| 2356 | snprintf(buf, sizeof(buf), "%s", "73"); |
| 2357 | else if (dut->ap_oper_class == 3) |
| 2358 | snprintf(buf, sizeof(buf), "%s", "5173"); |
| 2359 | |
| 2360 | if (dut->ap_oper_class) |
| 2361 | owrt_ap_set_vap(dut, vap_id, "hs20_operating_class", buf); |
| 2362 | |
| 2363 | if (dut->ap_osu_provider_list) { |
| 2364 | char *osu_friendly_name = NULL; |
| 2365 | char *osu_icon = NULL; |
| 2366 | char *osu_ssid = NULL; |
| 2367 | char *osu_nai = NULL; |
| 2368 | char *osu_service_desc = NULL; |
| 2369 | char *hs20_icon_filename = NULL; |
| 2370 | char hs20_icon[150]; |
| 2371 | int osu_method; |
| 2372 | |
| 2373 | hs20_icon_filename = "icon_red_zxx.png"; |
| 2374 | if (dut->ap_osu_icon_tag == 2) |
| 2375 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 2376 | snprintf(hs20_icon, sizeof(hs20_icon), |
| 2377 | "'128:61:zxx:image/png:icon_red_zxx.png:/etc/ath/%s'", |
| 2378 | hs20_icon_filename); |
| 2379 | osu_icon = "icon_red_zxx.png"; |
| 2380 | osu_ssid = "OSU"; |
| 2381 | osu_friendly_name = "'kor:SP 빨강 테스트 전용'"; |
| 2382 | osu_service_desc = "'kor:테스트 목적으로 무료 서비스'"; |
| 2383 | osu_method = (dut->ap_osu_method[0] == 0xFF) ? 1 : |
| 2384 | dut->ap_osu_method[0]; |
| 2385 | |
| 2386 | if (strlen(dut->ap_osu_server_uri[0])) |
| 2387 | owrt_ap_set_list_vap(dut, vap_id, "osu_server_uri", |
| 2388 | dut->ap_osu_server_uri[0]); |
| 2389 | else |
| 2390 | owrt_ap_set_list_vap(dut, vap_id, "osu_server_uri", |
| 2391 | "'https://osu-server.r2-testbed.wi-fi.org/'"); |
| 2392 | switch (dut->ap_osu_provider_list) { |
| 2393 | case 1: |
| 2394 | case 101: |
| 2395 | owrt_ap_set_list_vap(dut, vap_id, "osu_friendly_name", |
| 2396 | "'eng:SP Red Test Only'"); |
| 2397 | owrt_ap_set_list_vap(dut, vap_id, "osu_service_desc", |
| 2398 | "'eng:Free service for test purpose'"); |
| 2399 | owrt_ap_set_list_vap(dut, vap_id, "hs20_icon", |
| 2400 | hs20_icon); |
| 2401 | |
| 2402 | hs20_icon_filename = "icon_red_eng.png"; |
| 2403 | if (dut->ap_osu_icon_tag == 2) |
| 2404 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 2405 | |
| 2406 | snprintf(hs20_icon, sizeof(hs20_icon), |
| 2407 | "'160:76:eng:image/png:icon_red_eng.png:/etc/ath/%s'", |
| 2408 | hs20_icon_filename); |
| 2409 | owrt_ap_set_list_vap(dut, vap_id, "osu_icon", |
| 2410 | "icon_red_eng.png"); |
| 2411 | break; |
| 2412 | case 2: |
| 2413 | case 102: |
| 2414 | owrt_ap_set_list_vap(dut, vap_id, "osu_friendly_name", |
| 2415 | "'eng:Wireless Broadband Alliance'"); |
| 2416 | owrt_ap_set_list_vap(dut, vap_id, "osu_service_desc", |
| 2417 | "'eng:Free service for test purpose'"); |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2418 | hs20_icon_filename = "icon_orange_zxx.png"; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2419 | if (dut->ap_osu_icon_tag == 2) |
| 2420 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 2421 | |
| 2422 | snprintf(hs20_icon, sizeof(hs20_icon), |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2423 | "'128:61:zxx:image/png:icon_orange_zxx.png:/etc/ath/%s'", |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2424 | hs20_icon_filename); |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2425 | osu_icon = "icon_orange_zxx.png"; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2426 | osu_friendly_name = "'kor:와이어리스 브로드밴드 얼라이언스'"; |
| 2427 | break; |
| 2428 | case 3: |
| 2429 | case 103: |
| 2430 | osu_friendly_name = "spa:SP Red Test Only"; |
| 2431 | osu_service_desc = "spa:Free service for test purpose"; |
| 2432 | break; |
| 2433 | case 4: |
| 2434 | case 104: |
| 2435 | owrt_ap_set_list_vap(dut, vap_id, "osu_friendly_name", |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2436 | "'eng:SP Orange Test Only'"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2437 | owrt_ap_set_list_vap(dut, vap_id, "osu_service_desc", |
| 2438 | "'eng:Free service for test purpose'"); |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2439 | hs20_icon_filename = "icon_orange_eng.png"; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2440 | if (dut->ap_osu_icon_tag == 2) |
| 2441 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 2442 | |
| 2443 | snprintf(hs20_icon, sizeof(hs20_icon), |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2444 | "'160:76:eng:image/png:icon_orange_eng.png:/etc/ath/%s'", |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2445 | hs20_icon_filename); |
| 2446 | owrt_ap_set_list_vap(dut, vap_id, "hs20_icon", |
| 2447 | hs20_icon); |
| 2448 | osu_friendly_name = "'kor:SP 파랑 테스트 전용'"; |
| 2449 | |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2450 | hs20_icon_filename = "icon_orange_zxx.png"; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2451 | if (dut->ap_osu_icon_tag == 2) |
| 2452 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 2453 | |
| 2454 | snprintf(hs20_icon, sizeof(hs20_icon), |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2455 | "'128:61:zxx:image/png:icon_orange_zxx.png:/etc/ath/%s'", |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2456 | hs20_icon_filename); |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2457 | osu_icon = "icon_orange_zxx.png"; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2458 | break; |
| 2459 | case 5: |
| 2460 | case 105: |
| 2461 | owrt_ap_set_list_vap(dut, vap_id, "osu_friendly_name", |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2462 | "'eng:SP Orange Test Only'"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2463 | owrt_ap_set_list_vap(dut, vap_id, "osu_service_desc", |
| 2464 | "'eng:Free service for test purpose'"); |
| 2465 | osu_friendly_name = "'kor:SP 파랑 테스트 전용'"; |
| 2466 | |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2467 | hs20_icon_filename = "icon_orange_zxx.png"; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2468 | if (dut->ap_osu_icon_tag == 2) |
| 2469 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 2470 | |
| 2471 | snprintf(hs20_icon, sizeof(hs20_icon), |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2472 | "'128:61:zxx:image/png:icon_orange_zxx.png:/etc/ath/%s'", |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2473 | hs20_icon_filename); |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2474 | osu_icon = "icon_orange_zxx.png"; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2475 | break; |
| 2476 | case 6: |
| 2477 | case 106: |
| 2478 | owrt_ap_set_list_vap(dut, vap_id, "osu_friendly_name", |
| 2479 | "'eng:SP Green Test Only'"); |
| 2480 | owrt_ap_set_list_vap(dut, vap_id, "osu_friendly_name", |
| 2481 | "'kor:SP 초록 테스트 전용'"); |
| 2482 | |
| 2483 | hs20_icon_filename = "icon_green_zxx.png"; |
| 2484 | if (dut->ap_osu_icon_tag == 2) |
| 2485 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 2486 | |
| 2487 | snprintf(hs20_icon, sizeof(hs20_icon), |
| 2488 | "'128:61:zxx:image/png:icon_green_zxx.png:/etc/ath/%s'", |
| 2489 | hs20_icon_filename); |
| 2490 | owrt_ap_set_list_vap(dut, vap_id, "hs20_icon", |
| 2491 | hs20_icon); |
| 2492 | |
| 2493 | owrt_ap_set_list_vap(dut, vap_id, "osu_icon", |
| 2494 | "'icon_green_zxx.png'"); |
| 2495 | osu_method = (dut->ap_osu_method[0] == 0xFF) ? 0 : |
| 2496 | dut->ap_osu_method[0]; |
| 2497 | |
| 2498 | snprintf(buf, sizeof(buf), "%d", osu_method); |
| 2499 | owrt_ap_set_vap(dut, vap_id, "osu_method_list", buf); |
| 2500 | |
| 2501 | if (strlen(dut->ap_osu_server_uri[1])) |
| 2502 | owrt_ap_set_list_vap(dut, vap_id, |
| 2503 | "osu_server_uri", |
| 2504 | dut->ap_osu_server_uri[1]); |
| 2505 | else |
| 2506 | owrt_ap_set_list_vap(dut, vap_id, |
| 2507 | "osu_server_uri", |
| 2508 | "'https://osu-server.r2-testbed.wi-fi.org/'"); |
| 2509 | |
| 2510 | owrt_ap_set_list_vap(dut, vap_id, "osu_friendly_name", |
| 2511 | "'eng:SP Orange Test Only'"); |
| 2512 | |
| 2513 | hs20_icon_filename = "icon_orange_zxx.png"; |
| 2514 | if (dut->ap_osu_icon_tag == 2) |
| 2515 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 2516 | |
| 2517 | snprintf(hs20_icon, sizeof(hs20_icon), |
| 2518 | "'128:61:zxx:image/png:icon_orange_zxx.png:/etc/ath/%s'", |
| 2519 | hs20_icon_filename); |
| 2520 | |
| 2521 | osu_icon = "icon_orange_zxx.png"; |
| 2522 | osu_friendly_name = "'kor:SP 오렌지 테스트 전용'"; |
| 2523 | osu_method = (dut->ap_osu_method[1] == 0xFF) ? 0 : |
| 2524 | dut->ap_osu_method[1]; |
| 2525 | osu_service_desc = NULL; |
| 2526 | break; |
| 2527 | case 7: |
| 2528 | case 107: |
| 2529 | owrt_ap_set_list_vap(dut, vap_id, "osu_friendly_name", |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2530 | "'eng:SP Green Test Only'"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2531 | owrt_ap_set_list_vap(dut, vap_id, "osu_service_desc", |
| 2532 | "'eng:Free service for test purpose'"); |
| 2533 | |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2534 | hs20_icon_filename = "icon_green_eng.png"; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2535 | if (dut->ap_osu_icon_tag == 2) |
| 2536 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 2537 | |
| 2538 | snprintf(hs20_icon, sizeof(hs20_icon), |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2539 | "'160:76:eng:image/png:icon_green_eng.png:/etc/ath/%s'", |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2540 | hs20_icon_filename); |
| 2541 | owrt_ap_set_list_vap(dut, vap_id, "hs20_icon", |
| 2542 | hs20_icon); |
| 2543 | |
| 2544 | owrt_ap_set_list_vap(dut, vap_id, "osu_icon", |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2545 | "'icon_green_eng.png'"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2546 | osu_friendly_name = "'kor:SP 오렌지 테스트 전용'"; |
| 2547 | |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2548 | hs20_icon_filename = "icon_green_zxx.png"; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2549 | if (dut->ap_osu_icon_tag == 2) |
| 2550 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 2551 | |
| 2552 | snprintf(hs20_icon, sizeof(hs20_icon), |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2553 | "'128:61:zxx:image/png:icon_green_zxx.png:/etc/ath/%s'", |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2554 | hs20_icon_filename); |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2555 | osu_icon = "icon_green_zxx.png"; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2556 | break; |
| 2557 | case 8: |
| 2558 | case 108: |
| 2559 | owrt_ap_set_list_vap(dut, vap_id, "osu_friendly_name", |
| 2560 | "'eng:SP Red Test Only'"); |
| 2561 | owrt_ap_set_list_vap(dut, vap_id, "osu_service_desc", |
| 2562 | "'eng:Free service for test purpose'"); |
| 2563 | osu_ssid = "OSU-Encrypted"; |
| 2564 | osu_nai = "'anonymous@hotspot.net'"; |
| 2565 | break; |
| 2566 | case 9: |
| 2567 | case 109: |
| 2568 | osu_ssid = "OSU-OSEN"; |
| 2569 | osu_nai = "'test-anonymous@wi-fi.org'"; |
| 2570 | osu_friendly_name = "'eng:SP Orange Test Only'"; |
| 2571 | hs20_icon_filename = "icon_orange_zxx.png"; |
| 2572 | if (dut->ap_osu_icon_tag == 2) |
| 2573 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 2574 | |
| 2575 | snprintf(hs20_icon, sizeof(hs20_icon), |
| 2576 | "'128:61:zxx:image/png:icon_orange_zxx.png:/etc/ath/%s'", |
| 2577 | hs20_icon_filename); |
| 2578 | osu_icon = "icon_orange_zxx.png"; |
| 2579 | osu_method = (dut->ap_osu_method[0] == 0xFF) ? 1 : |
| 2580 | dut->ap_osu_method[0]; |
| 2581 | osu_service_desc = NULL; |
| 2582 | break; |
| 2583 | default: |
| 2584 | break; |
| 2585 | } |
| 2586 | |
| 2587 | if (strlen(dut->ap_osu_ssid)) { |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 2588 | if (strcmp(dut->ap_tag_ssid[0], |
| 2589 | dut->ap_osu_ssid) != 0 && |
| 2590 | strcmp(dut->ap_tag_ssid[0], osu_ssid) != 0) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2591 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 2592 | "OSU_SSID and WLAN_TAG2 SSID differ"); |
| 2593 | return -2; |
| 2594 | } |
| 2595 | |
| 2596 | snprintf(buf, sizeof(buf), "'\"%s\"'", |
| 2597 | dut->ap_osu_ssid); |
| 2598 | } else { |
| 2599 | snprintf(buf, sizeof(buf), "'\"%s\"'", osu_ssid); |
| 2600 | } |
| 2601 | |
| 2602 | owrt_ap_set_vap(dut, vap_id, "osu_ssid", buf); |
| 2603 | |
| 2604 | |
| 2605 | if (osu_friendly_name) |
| 2606 | owrt_ap_set_list_vap(dut, vap_id, "osu_friendly_name", |
| 2607 | osu_friendly_name); |
| 2608 | if (osu_service_desc) |
| 2609 | owrt_ap_set_list_vap(dut, vap_id, "osu_service_desc", |
| 2610 | osu_service_desc); |
| 2611 | if (osu_nai) |
| 2612 | owrt_ap_set_vap(dut, vap_id, "osu_nai", osu_nai); |
| 2613 | |
| 2614 | owrt_ap_set_list_vap(dut, vap_id, "hs20_icon", hs20_icon); |
| 2615 | |
| 2616 | if (osu_icon) |
| 2617 | owrt_ap_set_list_vap(dut, vap_id, "osu_icon", |
| 2618 | osu_icon); |
| 2619 | |
| 2620 | if (dut->ap_osu_provider_list > 100) { |
| 2621 | owrt_ap_set_list_vap(dut, vap_id, "osu_method_list", |
| 2622 | "0"); |
| 2623 | } else { |
| 2624 | snprintf(buf, sizeof(buf), "%d", osu_method); |
| 2625 | owrt_ap_set_list_vap(dut, vap_id, "osu_method_list", |
| 2626 | buf); |
| 2627 | } |
| 2628 | } |
| 2629 | |
| 2630 | return 0; |
| 2631 | } |
| 2632 | |
| 2633 | |
Adil Saeed Musthafa | a8d7484 | 2017-04-10 23:13:39 -0700 | [diff] [blame] | 2634 | static void set_anqp_elem_value(struct sigma_dut *dut, const char *ifname, |
| 2635 | char *anqp_string, size_t str_size) |
| 2636 | { |
| 2637 | unsigned char bssid[ETH_ALEN]; |
| 2638 | unsigned char dummy_mac[] = { 0x00, 0x10, 0x20, 0x30, 0x40, 0x50 }; |
| 2639 | int preference = 0xff; |
| 2640 | |
| 2641 | get_hwaddr(ifname, bssid); |
| 2642 | snprintf(anqp_string, str_size, |
| 2643 | "272:3410%02x%02x%02x%02x%02x%02xf70000007330000301%02x3410%02x%02x%02x%02x%02x%02xf70000007330000301%02x", |
| 2644 | bssid[0], bssid[1], bssid[2], bssid[3], bssid[4], bssid[5], |
| 2645 | preference, |
| 2646 | dummy_mac[0], dummy_mac[1], dummy_mac[2], |
| 2647 | dummy_mac[3], dummy_mac[4], dummy_mac[5], |
| 2648 | preference - 1); |
| 2649 | } |
| 2650 | |
| 2651 | |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 2652 | static void get_if_name(struct sigma_dut *dut, char *ifname_str, |
| 2653 | size_t str_size, int wlan_tag) |
| 2654 | { |
Jouni Malinen | f898464 | 2017-10-12 00:02:37 +0300 | [diff] [blame] | 2655 | const char *ifname; |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 2656 | enum driver_type drv; |
| 2657 | |
| 2658 | drv = get_driver_type(); |
Jouni Malinen | f898464 | 2017-10-12 00:02:37 +0300 | [diff] [blame] | 2659 | if (dut->hostapd_ifname && if_nametoindex(dut->hostapd_ifname) > 0) { |
| 2660 | ifname = dut->hostapd_ifname; |
| 2661 | } else if (drv == DRIVER_ATHEROS) { |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 2662 | if ((dut->ap_mode == AP_11a || dut->ap_mode == AP_11na || |
| 2663 | dut->ap_mode == AP_11ac) && |
| 2664 | if_nametoindex("ath1") > 0) |
| 2665 | ifname = "ath1"; |
| 2666 | else |
| 2667 | ifname = "ath0"; |
| 2668 | } else if (drv == DRIVER_OPENWRT) { |
| 2669 | if (sigma_radio_ifname[0] && |
| 2670 | strcmp(sigma_radio_ifname[0], "wifi2") == 0) |
| 2671 | ifname = "ath2"; |
| 2672 | else if (sigma_radio_ifname[0] && |
| 2673 | strcmp(sigma_radio_ifname[0], "wifi1") == 0) |
| 2674 | ifname = "ath1"; |
| 2675 | else |
| 2676 | ifname = "ath0"; |
| 2677 | } else { |
| 2678 | if ((dut->ap_mode == AP_11a || dut->ap_mode == AP_11na || |
| 2679 | dut->ap_mode == AP_11ac) && |
| 2680 | if_nametoindex("wlan1") > 0) |
| 2681 | ifname = "wlan1"; |
| 2682 | else |
| 2683 | ifname = "wlan0"; |
| 2684 | } |
| 2685 | |
| 2686 | if (drv == DRIVER_OPENWRT && wlan_tag > 1) { |
| 2687 | /* Handle tagged-ifname only on OPENWRT for now */ |
| 2688 | snprintf(ifname_str, str_size, "%s%d", ifname, wlan_tag - 1); |
Jouni Malinen | f898464 | 2017-10-12 00:02:37 +0300 | [diff] [blame] | 2689 | } else if (drv == DRIVER_MAC80211 && wlan_tag == 2) { |
| 2690 | snprintf(ifname_str, str_size, "%s_1", ifname); |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 2691 | } else { |
| 2692 | snprintf(ifname_str, str_size, "%s", ifname); |
| 2693 | } |
| 2694 | } |
| 2695 | |
| 2696 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2697 | static int owrt_ap_config_vap(struct sigma_dut *dut) |
| 2698 | { |
| 2699 | char buf[256], *temp; |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 2700 | int vap_id = 0, vap_count, i, j; |
priyadharshini gowthaman | 0454706 | 2018-01-15 11:59:55 -0800 | [diff] [blame] | 2701 | const char *ifname; |
| 2702 | char ifname2[50]; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2703 | |
priyadharshini gowthaman | 7356126 | 2018-02-20 13:24:59 -0800 | [diff] [blame] | 2704 | if (sigma_radio_ifname[0] && |
| 2705 | strcmp(sigma_radio_ifname[0], "wifi2") == 0) |
| 2706 | ifname = "ath2"; |
| 2707 | else if (sigma_radio_ifname[0] && |
| 2708 | strcmp(sigma_radio_ifname[0], "wifi1") == 0) |
| 2709 | ifname = "ath1"; |
| 2710 | else |
| 2711 | ifname = "ath0"; |
| 2712 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2713 | 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] | 2714 | snprintf(buf, sizeof(buf), "wifi%d", vap_count); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2715 | |
| 2716 | for (vap_id = 0; vap_id < MAX_RADIO; vap_id++) { |
| 2717 | if (sigma_radio_ifname[vap_id] && |
| 2718 | strcmp(sigma_radio_ifname[vap_id], buf) == 0) |
| 2719 | break; |
| 2720 | } |
| 2721 | if (vap_id == MAX_RADIO) |
| 2722 | continue; |
| 2723 | |
| 2724 | /* Single VAP configuration */ |
| 2725 | if (!dut->ap_is_dual) |
| 2726 | vap_id = vap_count; |
| 2727 | |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 2728 | for (j = 0; j < MAX_WLAN_TAGS - 1; j++) { |
| 2729 | /* |
| 2730 | * We keep a separate array of ap_tag_ssid and |
| 2731 | * ap_tag_key_mgmt for tags starting from WLAN_TAG=2. |
| 2732 | * So j=0 => WLAN_TAG = 2 |
| 2733 | */ |
| 2734 | int wlan_tag = j + 2; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2735 | |
priyadharshini gowthaman | 0e209fc | 2018-01-26 15:15:37 -0800 | [diff] [blame] | 2736 | if (wlan_tag == 2 && dut->program == PROGRAM_WPA3 && |
| 2737 | (dut->ap_interface_5g || dut->ap_interface_2g)) { |
| 2738 | snprintf(dut->ap_tag_ssid[wlan_tag - 2], |
| 2739 | sizeof(dut->ap_tag_ssid[wlan_tag - 2]), |
| 2740 | "%s-owe", dut->ap_ssid); |
| 2741 | } |
| 2742 | |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 2743 | if (dut->ap_tag_ssid[j][0] == '\0') |
| 2744 | continue; |
| 2745 | |
| 2746 | snprintf(buf, sizeof(buf), "%s%d", "wifi", vap_count); |
| 2747 | owrt_ap_add_vap(dut, vap_count + (wlan_tag - 1), |
| 2748 | "device", buf); |
| 2749 | /* SSID */ |
| 2750 | snprintf(buf, sizeof(buf), "\"%s\"", |
| 2751 | dut->ap_tag_ssid[j]); |
| 2752 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), |
| 2753 | "ssid", buf); |
| 2754 | |
priyadharshini gowthaman | 0454706 | 2018-01-15 11:59:55 -0800 | [diff] [blame] | 2755 | if (dut->ap_key_mgmt == AP_WPA2_OWE && |
| 2756 | dut->ap_tag_ssid[0][0] && |
| 2757 | dut->ap_tag_key_mgmt[0] == AP2_OPEN) { |
| 2758 | /* OWE transition mode */ |
| 2759 | snprintf(buf, sizeof(buf), "%s", ifname); |
| 2760 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), |
| 2761 | "owe_transition_ifname", buf); |
| 2762 | } |
| 2763 | |
| 2764 | if (dut->ap_key_mgmt == AP_OPEN && |
| 2765 | dut->ap_tag_key_mgmt[0] == AP2_WPA2_OWE) { |
| 2766 | /* OWE transition mode */ |
| 2767 | snprintf(buf, sizeof(buf), "%s", ifname); |
| 2768 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), |
| 2769 | "owe_transition_ifname", buf); |
| 2770 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), |
| 2771 | "hidden", "1"); |
| 2772 | } |
| 2773 | |
Jouni Malinen | 6be21c8 | 2018-08-01 18:47:24 +0300 | [diff] [blame] | 2774 | if (ap_ft_enabled(dut)) { |
priyadharshini gowthaman | 47189f5 | 2017-12-28 12:37:46 -0800 | [diff] [blame] | 2775 | unsigned char self_mac[ETH_ALEN]; |
| 2776 | char mac_str[20]; |
| 2777 | |
| 2778 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), |
| 2779 | "mobility_domain", |
| 2780 | dut->ap_mobility_domain); |
| 2781 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), |
| 2782 | "ft_over_ds", "0"); |
| 2783 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), |
| 2784 | "ieee80211r", "1"); |
| 2785 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), |
| 2786 | "nasid", "nas1.example.com"); |
| 2787 | get_hwaddr(sigma_radio_ifname[0], self_mac); |
| 2788 | snprintf(mac_str, sizeof(mac_str), |
| 2789 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 2790 | self_mac[0], self_mac[1], self_mac[2], |
| 2791 | self_mac[3], self_mac[4], self_mac[5]); |
| 2792 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), |
| 2793 | "ap_macaddr", mac_str); |
| 2794 | snprintf(mac_str, sizeof(mac_str), |
| 2795 | "%02x%02x%02x%02x%02x%02x", |
| 2796 | self_mac[0], self_mac[1], self_mac[2], |
| 2797 | self_mac[3], self_mac[4], self_mac[5]); |
| 2798 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), |
| 2799 | "r1_key_holder", mac_str); |
| 2800 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), |
| 2801 | "ft_psk_generate_local", "1"); |
| 2802 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), |
| 2803 | "kh_key_hex", |
| 2804 | "000102030405060708090a0b0c0d0e0f"); |
| 2805 | snprintf(mac_str, sizeof(mac_str), |
| 2806 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 2807 | dut->ft_bss_mac_list[0][0], |
| 2808 | dut->ft_bss_mac_list[0][1], |
| 2809 | dut->ft_bss_mac_list[0][2], |
| 2810 | dut->ft_bss_mac_list[0][3], |
| 2811 | dut->ft_bss_mac_list[0][4], |
| 2812 | dut->ft_bss_mac_list[0][5]); |
| 2813 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), |
| 2814 | "ap2_macaddr", mac_str); |
| 2815 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), |
| 2816 | "ap2_r1_key_holder", mac_str); |
| 2817 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), |
| 2818 | "nasid2", "nas2.example.com"); |
| 2819 | } |
| 2820 | |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 2821 | if (dut->ap_tag_key_mgmt[j] == AP2_OSEN && |
| 2822 | wlan_tag == 2) { |
| 2823 | /* Only supported for WLAN_TAG=2 */ |
| 2824 | owrt_ap_set_vap(dut, vap_count + 1, "osen", |
| 2825 | "1"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2826 | snprintf(buf, sizeof(buf), "wpa2"); |
| 2827 | owrt_ap_set_vap(dut, vap_count + 1, |
| 2828 | "encryption", buf); |
| 2829 | snprintf(buf, sizeof(buf), "%s", |
| 2830 | dut->ap2_radius_ipaddr); |
| 2831 | owrt_ap_set_vap(dut, vap_count + 1, |
| 2832 | "auth_server", buf); |
| 2833 | snprintf(buf, sizeof(buf), "%d", |
| 2834 | dut->ap2_radius_port); |
| 2835 | owrt_ap_set_vap(dut, vap_count + 1, |
| 2836 | "auth_port", buf); |
| 2837 | snprintf(buf, sizeof(buf), "%s", |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 2838 | dut->ap2_radius_password); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2839 | owrt_ap_set_vap(dut, vap_count + 1, |
| 2840 | "auth_secret", buf); |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 2841 | } else if (dut->ap_tag_key_mgmt[j] == AP2_WPA2_PSK) { |
| 2842 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), |
| 2843 | "encryption", "psk2+ccmp"); |
| 2844 | snprintf(buf, sizeof(buf), "\"%s\"", |
| 2845 | dut->ap_passphrase); |
| 2846 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), |
| 2847 | "key", buf); |
| 2848 | snprintf(buf, sizeof(buf), "%d", dut->ap_pmf); |
priyadharshini gowthaman | 47189f5 | 2017-12-28 12:37:46 -0800 | [diff] [blame] | 2849 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 2850 | "ieee80211w", buf); |
priyadharshini gowthaman | 0454706 | 2018-01-15 11:59:55 -0800 | [diff] [blame] | 2851 | } else if (dut->ap_tag_key_mgmt[0] == AP2_WPA2_OWE) { |
| 2852 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), |
| 2853 | "owe", "1"); |
| 2854 | snprintf(buf, sizeof(buf), "ccmp"); |
| 2855 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), |
| 2856 | "encryption", buf); |
| 2857 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), |
| 2858 | "ieee80211w", "2"); |
| 2859 | if (dut->ap_sae_groups) { |
| 2860 | snprintf(buf, sizeof(buf), "\'%s\'", |
| 2861 | dut->ap_sae_groups); |
| 2862 | owrt_ap_set_vap(dut, vap_count + |
| 2863 | (wlan_tag - 1), |
| 2864 | "owe_groups", buf); |
| 2865 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2866 | } |
| 2867 | } |
| 2868 | |
priyadharshini gowthaman | 47189f5 | 2017-12-28 12:37:46 -0800 | [diff] [blame] | 2869 | /* Now set anqp_elem and ft_oa for wlan_tag = 1 */ |
Adil Saeed Musthafa | a8d7484 | 2017-04-10 23:13:39 -0700 | [diff] [blame] | 2870 | if (dut->program == PROGRAM_MBO && |
| 2871 | get_driver_type() == DRIVER_OPENWRT) { |
priyadharshini gowthaman | 47189f5 | 2017-12-28 12:37:46 -0800 | [diff] [blame] | 2872 | unsigned char self_mac[ETH_ALEN]; |
| 2873 | char mac_str[20]; |
Adil Saeed Musthafa | a8d7484 | 2017-04-10 23:13:39 -0700 | [diff] [blame] | 2874 | char anqp_string[200]; |
| 2875 | |
| 2876 | set_anqp_elem_value(dut, sigma_radio_ifname[0], |
| 2877 | anqp_string, sizeof(anqp_string)); |
| 2878 | owrt_ap_set_list_vap(dut, vap_count, "anqp_elem", |
| 2879 | anqp_string); |
priyadharshini gowthaman | 47189f5 | 2017-12-28 12:37:46 -0800 | [diff] [blame] | 2880 | |
Jouni Malinen | 6be21c8 | 2018-08-01 18:47:24 +0300 | [diff] [blame] | 2881 | if (ap_ft_enabled(dut)) { |
priyadharshini gowthaman | 47189f5 | 2017-12-28 12:37:46 -0800 | [diff] [blame] | 2882 | owrt_ap_set_vap(dut, vap_count, |
| 2883 | "mobility_domain", |
| 2884 | dut->ap_mobility_domain); |
| 2885 | owrt_ap_set_vap(dut, vap_count, |
| 2886 | "ft_over_ds", "0"); |
| 2887 | owrt_ap_set_vap(dut, vap_count, |
| 2888 | "ieee80211r", "1"); |
| 2889 | owrt_ap_set_vap(dut, vap_count, |
| 2890 | "nasid", "nas1.example.com"); |
| 2891 | get_hwaddr(sigma_radio_ifname[0], self_mac); |
| 2892 | snprintf(mac_str, sizeof(mac_str), |
| 2893 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 2894 | self_mac[0], self_mac[1], self_mac[2], |
| 2895 | self_mac[3], self_mac[4], self_mac[5]); |
| 2896 | owrt_ap_set_vap(dut, vap_count, |
| 2897 | "ap_macaddr", mac_str); |
| 2898 | snprintf(mac_str, sizeof(mac_str), |
| 2899 | "%02x%02x%02x%02x%02x%02x", |
| 2900 | self_mac[0], self_mac[1], self_mac[2], |
| 2901 | self_mac[3], self_mac[4], self_mac[5]); |
| 2902 | owrt_ap_set_vap(dut, vap_count, |
| 2903 | "r1_key_holder", mac_str); |
| 2904 | owrt_ap_set_vap(dut, vap_count, |
| 2905 | "ft_psk_generate_local", "1"); |
| 2906 | owrt_ap_set_vap(dut, vap_count, |
| 2907 | "kh_key_hex", |
| 2908 | "000102030405060708090a0b0c0d0e0f"); |
| 2909 | snprintf(mac_str, sizeof(mac_str), |
| 2910 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 2911 | dut->ft_bss_mac_list[0][0], |
| 2912 | dut->ft_bss_mac_list[0][1], |
| 2913 | dut->ft_bss_mac_list[0][2], |
| 2914 | dut->ft_bss_mac_list[0][3], |
| 2915 | dut->ft_bss_mac_list[0][4], |
| 2916 | dut->ft_bss_mac_list[0][5]); |
| 2917 | owrt_ap_set_vap(dut, vap_count, |
| 2918 | "ap2_macaddr", mac_str); |
| 2919 | owrt_ap_set_vap(dut, vap_count, |
| 2920 | "ap2_r1_key_holder", mac_str); |
| 2921 | owrt_ap_set_vap(dut, vap_count, |
| 2922 | "nasid2", "nas2.example.com"); |
| 2923 | } |
Adil Saeed Musthafa | a8d7484 | 2017-04-10 23:13:39 -0700 | [diff] [blame] | 2924 | } |
| 2925 | |
priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 2926 | if (dut->ap_oce == VALUE_ENABLED && |
| 2927 | get_driver_type() == DRIVER_OPENWRT) { |
| 2928 | owrt_ap_set_vap(dut, vap_id, "oce", "1"); |
| 2929 | owrt_ap_set_vap(dut, vap_id, "qbssload", "1"); |
| 2930 | owrt_ap_set_vap(dut, vap_id, "bpr_enable", "1"); |
| 2931 | |
priyadharshini gowthaman | 63ab848 | 2017-12-28 15:32:55 -0800 | [diff] [blame] | 2932 | if (dut->ap_80plus80 == 1) |
| 2933 | owrt_ap_set_vap(dut, vap_id, "cfreq2", "5775"); |
| 2934 | |
priyadharshini gowthaman | de81f39 | 2017-12-28 15:28:49 -0800 | [diff] [blame] | 2935 | if (dut->ap_akm == 1) { |
| 2936 | owrt_ap_set_vap(dut, vap_id, "wpa_group_rekey", |
| 2937 | "3600"); |
| 2938 | owrt_ap_set_vap(dut, vap_id, "key", "12345678"); |
| 2939 | owrt_ap_set_vap(dut, vap_id, "ieee80211ai", |
| 2940 | "1"); |
| 2941 | owrt_ap_set_vap(dut, vap_id, "fils_cache_id", |
| 2942 | "1234"); |
| 2943 | owrt_ap_set_vap(dut, vap_id, |
| 2944 | "erp_send_reauth_start", "1"); |
| 2945 | } |
| 2946 | |
priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 2947 | if (dut->ap_filshlp == VALUE_ENABLED) { |
| 2948 | struct ifreq ifr; |
| 2949 | char *ifname; |
| 2950 | int s; |
| 2951 | struct sockaddr_in *ipaddr; |
| 2952 | |
| 2953 | s = socket(AF_INET, SOCK_DGRAM, 0); |
| 2954 | if (s < 0) { |
| 2955 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 2956 | "Failed to open socket"); |
| 2957 | return -1; |
| 2958 | } |
| 2959 | ifr.ifr_addr.sa_family = AF_INET; |
| 2960 | |
| 2961 | memset(&ifr, 0, sizeof(ifr)); |
| 2962 | ifname = "br-lan"; |
| 2963 | strlcpy(ifr.ifr_name, ifname, |
| 2964 | sizeof(ifr.ifr_name)); |
| 2965 | if (ioctl(s, SIOCGIFADDR, &ifr) < 0) { |
| 2966 | perror("ioctl"); |
| 2967 | close(s); |
| 2968 | return -1; |
| 2969 | } |
| 2970 | |
| 2971 | ipaddr = (struct sockaddr_in*)&ifr.ifr_addr; |
| 2972 | snprintf(buf, sizeof(buf), "%s", |
| 2973 | inet_ntoa(ipaddr->sin_addr)); |
| 2974 | owrt_ap_set_vap(dut, vap_id, "own_ip_addr", |
| 2975 | buf); |
| 2976 | snprintf(buf, sizeof(buf), "%s", |
| 2977 | dut->ap_dhcpserv_ipaddr); |
| 2978 | owrt_ap_set_vap(dut, vap_id, "dhcp_server", |
| 2979 | buf); |
| 2980 | owrt_ap_set_vap(dut, vap_id, |
| 2981 | "dhcp_rapid_commit_proxy", "1"); |
| 2982 | owrt_ap_set_vap(dut, vap_id, |
| 2983 | "fils_hlp_wait_time", "300"); |
| 2984 | } |
| 2985 | |
| 2986 | if (dut->ap_filsdscv == VALUE_ENABLED) { |
| 2987 | owrt_ap_set_vap(dut, vap_id, "ieee80211ai", |
| 2988 | "1"); |
| 2989 | owrt_ap_set_vap(dut, vap_id, "fils_fd_period", |
| 2990 | "20"); |
| 2991 | } |
| 2992 | } |
| 2993 | |
| 2994 | if (dut->ap_filsdscv == VALUE_DISABLED) { |
| 2995 | owrt_ap_set_vap(dut, vap_id, "ieee80211ai", "0"); |
| 2996 | owrt_ap_set_vap(dut, vap_id, "fils_fd_period", "0"); |
| 2997 | } |
| 2998 | |
| 2999 | if (dut->ap_oce == VALUE_DISABLED && |
| 3000 | get_driver_type() == DRIVER_OPENWRT) { |
| 3001 | owrt_ap_set_vap(dut, vap_id, "oce", "0"); |
| 3002 | owrt_ap_set_vap(dut, vap_id, "qbssload", "0"); |
| 3003 | owrt_ap_set_vap(dut, vap_id, "bpr_enable", "0"); |
| 3004 | |
| 3005 | if (dut->ap_filsdscv == VALUE_DISABLED) { |
| 3006 | owrt_ap_set_vap(dut, vap_id, "ieee80211ai", |
| 3007 | "0"); |
| 3008 | owrt_ap_set_vap(dut, vap_id, "fils_fd_period", |
| 3009 | "0"); |
| 3010 | } |
| 3011 | |
| 3012 | if (dut->device_type == AP_testbed) |
| 3013 | owrt_ap_set_vap(dut, vap_id, "mbo", "1"); |
| 3014 | } |
| 3015 | |
| 3016 | /* NAIRealm */ |
| 3017 | if (dut->ap_nairealm_int == 1) { |
| 3018 | snprintf(buf, sizeof(buf), "\"%s\"", dut->ap_nairealm); |
| 3019 | owrt_ap_set_vap(dut, vap_id, "fils_realm", buf); |
| 3020 | owrt_ap_set_vap(dut, vap_id, "erp_domain", buf); |
| 3021 | } |
| 3022 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3023 | /* SSID */ |
| 3024 | snprintf(buf, sizeof(buf), "\"%s\"", dut->ap_ssid); |
| 3025 | owrt_ap_set_vap(dut, vap_count, "ssid", buf); |
| 3026 | |
| 3027 | /* Encryption */ |
| 3028 | switch (dut->ap_key_mgmt) { |
| 3029 | case AP_OPEN: |
| 3030 | if (dut->ap_cipher == AP_WEP) { |
| 3031 | owrt_ap_set_vap(dut, vap_count, "encryption", |
| 3032 | "wep-mixed"); |
| 3033 | owrt_ap_set_vap(dut, vap_count, "key", |
| 3034 | dut->ap_wepkey); |
| 3035 | } else { |
| 3036 | owrt_ap_set_vap(dut, vap_count, "encryption", |
| 3037 | "none"); |
| 3038 | } |
priyadharshini gowthaman | 0454706 | 2018-01-15 11:59:55 -0800 | [diff] [blame] | 3039 | if (dut->ap_key_mgmt == AP_OPEN && |
| 3040 | dut->ap_tag_key_mgmt[0] == AP2_WPA2_OWE) { |
| 3041 | /* OWE transition mode */ |
| 3042 | snprintf(ifname2, sizeof(ifname2), "%s1", |
| 3043 | ifname); |
| 3044 | owrt_ap_set_vap(dut, vap_count, |
| 3045 | "owe_transition_ifname", |
| 3046 | ifname2); |
| 3047 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3048 | break; |
| 3049 | case AP_WPA2_PSK: |
| 3050 | case AP_WPA2_PSK_MIXED: |
| 3051 | case AP_WPA_PSK: |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 3052 | case AP_WPA2_SAE: |
| 3053 | case AP_WPA2_PSK_SAE: |
priyadharshini gowthaman | cce6ca0 | 2018-01-15 11:12:45 -0800 | [diff] [blame] | 3054 | if (dut->ap_key_mgmt == AP_WPA2_PSK || |
| 3055 | dut->ap_key_mgmt == AP_WPA2_PSK_SAE) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3056 | snprintf(buf, sizeof(buf), "psk2"); |
| 3057 | } else if (dut->ap_key_mgmt == AP_WPA2_PSK_MIXED) { |
| 3058 | snprintf(buf, sizeof(buf), "psk-mixed"); |
priyadharshini gowthaman | cce6ca0 | 2018-01-15 11:12:45 -0800 | [diff] [blame] | 3059 | } else if (dut->ap_key_mgmt == AP_WPA2_SAE) { |
| 3060 | snprintf(buf, sizeof(buf), "ccmp"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3061 | } else { |
| 3062 | snprintf(buf, sizeof(buf), "psk"); |
| 3063 | } |
| 3064 | |
priyadharshini gowthaman | cce6ca0 | 2018-01-15 11:12:45 -0800 | [diff] [blame] | 3065 | if (dut->ap_key_mgmt != AP_WPA2_SAE) { |
| 3066 | if (dut->ap_cipher == AP_CCMP_TKIP) |
| 3067 | strlcat(buf, "+ccmp+tkip", sizeof(buf)); |
| 3068 | else if (dut->ap_cipher == AP_TKIP) |
| 3069 | strlcat(buf, "+tkip", sizeof(buf)); |
| 3070 | else |
| 3071 | strlcat(buf, "+ccmp", sizeof(buf)); |
| 3072 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3073 | |
| 3074 | owrt_ap_set_vap(dut, vap_count, "encryption", buf); |
priyadharshini gowthaman | cce6ca0 | 2018-01-15 11:12:45 -0800 | [diff] [blame] | 3075 | |
| 3076 | if (!dut->ap_passphrase[0] && dut->ap_psk[0]) { |
| 3077 | snprintf(buf, sizeof(buf), "\"%s\"", |
| 3078 | dut->ap_psk); |
| 3079 | owrt_ap_set_vap(dut, vap_count, "key", buf); |
| 3080 | } else { |
| 3081 | snprintf(buf, sizeof(buf), "\"%s\"", |
| 3082 | dut->ap_passphrase); |
| 3083 | owrt_ap_set_vap(dut, vap_count, "key", buf); |
| 3084 | } |
| 3085 | |
| 3086 | if (dut->ap_key_mgmt == AP_WPA2_SAE || |
| 3087 | dut->ap_key_mgmt == AP_WPA2_PSK_SAE) |
| 3088 | owrt_ap_set_vap(dut, vap_count, "sae", "1"); |
| 3089 | else |
| 3090 | owrt_ap_set_vap(dut, vap_count, "sae", "0"); |
| 3091 | |
| 3092 | if (dut->ap_key_mgmt == AP_WPA2_SAE) { |
| 3093 | snprintf(buf, sizeof(buf), "%s", |
| 3094 | dut->ap_passphrase); |
| 3095 | owrt_ap_set_vap(dut, vap_count, "sae_password", |
| 3096 | buf); |
| 3097 | } else { |
| 3098 | snprintf(buf, sizeof(buf), "%s", |
| 3099 | dut->ap_passphrase); |
| 3100 | owrt_ap_set_vap(dut, vap_count, |
| 3101 | "wpa_passphrase", buf); |
| 3102 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3103 | break; |
| 3104 | case AP_WPA2_EAP: |
| 3105 | case AP_WPA2_EAP_MIXED: |
| 3106 | case AP_WPA_EAP: |
| 3107 | if (dut->ap_key_mgmt == AP_WPA2_EAP) { |
| 3108 | snprintf(buf, sizeof(buf), "wpa2"); |
| 3109 | } else if (dut->ap_key_mgmt == AP_WPA2_EAP_MIXED) { |
| 3110 | snprintf(buf, sizeof(buf), "wpa-mixed"); |
| 3111 | } else { |
| 3112 | snprintf(buf, sizeof(buf), "wpa"); |
| 3113 | } |
| 3114 | |
Peng Xu | 591be45 | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 3115 | if (dut->ap_cipher == AP_CCMP_TKIP) |
| 3116 | strlcat(buf, "+ccmp+tkip", sizeof(buf)); |
| 3117 | else if (dut->ap_cipher == AP_TKIP) |
| 3118 | strlcat(buf, "+tkip", sizeof(buf)); |
| 3119 | else |
| 3120 | strlcat(buf, "+ccmp", sizeof(buf)); |
| 3121 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3122 | owrt_ap_set_vap(dut, vap_count, "encryption", buf); |
| 3123 | snprintf(buf, sizeof(buf), "%s", dut->ap_radius_ipaddr); |
| 3124 | owrt_ap_set_vap(dut, vap_count, "auth_server", buf); |
| 3125 | snprintf(buf, sizeof(buf), "%d", dut->ap_radius_port); |
| 3126 | owrt_ap_set_vap(dut, vap_count, "auth_port", buf); |
| 3127 | snprintf(buf, sizeof(buf), "%s", |
| 3128 | dut->ap_radius_password); |
| 3129 | owrt_ap_set_vap(dut, vap_count, "auth_secret", buf); |
| 3130 | break; |
Jouni Malinen | 4cf699f | 2018-06-19 00:46:27 +0300 | [diff] [blame] | 3131 | case AP_WPA2_EAP_OSEN: |
Jouni Malinen | 6be21c8 | 2018-08-01 18:47:24 +0300 | [diff] [blame] | 3132 | case AP_WPA2_FT_EAP: |
| 3133 | case AP_WPA2_FT_PSK: |
| 3134 | case AP_WPA2_EAP_SHA256: |
| 3135 | case AP_WPA2_PSK_SHA256: |
| 3136 | case AP_WPA2_ENT_FT_EAP: |
Jouni Malinen | 4cf699f | 2018-06-19 00:46:27 +0300 | [diff] [blame] | 3137 | /* TODO */ |
| 3138 | break; |
Jouni Malinen | ad395a2 | 2017-09-01 21:13:46 +0300 | [diff] [blame] | 3139 | case AP_SUITEB: |
priyadharshini gowthaman | 2136bd5 | 2018-01-15 11:28:55 -0800 | [diff] [blame] | 3140 | owrt_ap_set_vap(dut, vap_count, "suite_b", "192"); |
| 3141 | snprintf(buf, sizeof(buf), "gcmp"); |
| 3142 | owrt_ap_set_vap(dut, vap_count, "encryption", buf); |
| 3143 | snprintf(buf, sizeof(buf), "%s", dut->ap_radius_ipaddr); |
| 3144 | owrt_ap_set_vap(dut, vap_count, "auth_server", buf); |
| 3145 | snprintf(buf, sizeof(buf), "%d", dut->ap_radius_port); |
| 3146 | owrt_ap_set_vap(dut, vap_count, "auth_port", buf); |
| 3147 | snprintf(buf, sizeof(buf), "%s", |
| 3148 | dut->ap_radius_password); |
| 3149 | owrt_ap_set_vap(dut, vap_count, "auth_secret", buf); |
| 3150 | snprintf(buf, sizeof(buf), "%d", |
| 3151 | dut->ap_group_mgmt_cipher); |
| 3152 | owrt_ap_set_vap(dut, vap_count, "group_mgmt_cipher", |
| 3153 | buf); |
Jouni Malinen | ad395a2 | 2017-09-01 21:13:46 +0300 | [diff] [blame] | 3154 | break; |
Jouni Malinen | 147b3c3 | 2017-10-09 16:51:54 +0300 | [diff] [blame] | 3155 | case AP_WPA2_OWE: |
priyadharshini gowthaman | 0454706 | 2018-01-15 11:59:55 -0800 | [diff] [blame] | 3156 | owrt_ap_set_vap(dut, vap_count, "owe", "1"); |
| 3157 | snprintf(buf, sizeof(buf), "ccmp"); |
| 3158 | owrt_ap_set_vap(dut, vap_count, "encryption", buf); |
| 3159 | if (dut->ap_sae_groups) { |
| 3160 | snprintf(buf, sizeof(buf), "\'%s\'", |
| 3161 | dut->ap_sae_groups); |
| 3162 | owrt_ap_set_vap(dut, vap_count, "owe_groups", |
| 3163 | buf); |
| 3164 | } |
| 3165 | |
| 3166 | if (dut->ap_key_mgmt == AP_WPA2_OWE && |
| 3167 | dut->ap_tag_ssid[0][0] && |
| 3168 | dut->ap_tag_key_mgmt[0] == AP2_OPEN) { |
| 3169 | /* OWE transition mode */ |
| 3170 | snprintf(ifname2, sizeof(ifname2), "%s1", |
| 3171 | ifname); |
| 3172 | owrt_ap_set_vap(dut, vap_count, |
| 3173 | "owe_transition_ifname", |
| 3174 | ifname2); |
| 3175 | owrt_ap_set_vap(dut, vap_count, "hidden", "1"); |
| 3176 | } |
Jouni Malinen | 147b3c3 | 2017-10-09 16:51:54 +0300 | [diff] [blame] | 3177 | break; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3178 | } |
| 3179 | |
| 3180 | if (!dut->ap_is_dual) |
| 3181 | break; |
| 3182 | } |
| 3183 | |
| 3184 | if (dut->ap_is_dual) |
| 3185 | return 1; |
| 3186 | |
| 3187 | /* PMF */ |
| 3188 | snprintf(buf, sizeof(buf), "%d", dut->ap_pmf); |
| 3189 | owrt_ap_set_vap(dut, vap_id, "ieee80211w", buf); |
| 3190 | |
| 3191 | /* Add SHA256 */ |
| 3192 | snprintf(buf, sizeof(buf), "%d", dut->ap_add_sha256); |
| 3193 | owrt_ap_set_vap(dut, vap_id, "add_sha256", buf); |
| 3194 | |
priyadharshini gowthaman | de81f39 | 2017-12-28 15:28:49 -0800 | [diff] [blame] | 3195 | /* Add SHA384 for akmsuitetype 15 */ |
| 3196 | if (dut->ap_akm == 1) { |
| 3197 | snprintf(buf, sizeof(buf), "%d", dut->ap_add_sha384); |
| 3198 | owrt_ap_set_vap(dut, vap_id, "add_sha384", buf); |
| 3199 | } |
| 3200 | |
Sarvepalli, Rajesh Babu | 24dc7e4 | 2016-03-18 21:27:26 +0530 | [diff] [blame] | 3201 | /* Enable RSN preauthentication, if asked to */ |
| 3202 | snprintf(buf, sizeof(buf), "%d", dut->ap_rsn_preauth); |
| 3203 | owrt_ap_set_vap(dut, vap_id, "rsn_preauth", buf); |
| 3204 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3205 | /* Hotspot 2.0 */ |
| 3206 | if (dut->ap_hs2) { |
| 3207 | int ret; |
| 3208 | |
| 3209 | ret = owrt_ap_config_vap_hs2(dut, vap_id); |
| 3210 | if (ret) |
| 3211 | return ret; |
| 3212 | } |
| 3213 | |
| 3214 | /* Interworking */ |
| 3215 | if (dut->ap_interworking) { |
| 3216 | snprintf(buf, sizeof(buf), "%d", dut->ap_access_net_type); |
| 3217 | owrt_ap_set_vap(dut, vap_id, "access_network_type", buf); |
| 3218 | snprintf(buf, sizeof(buf), "%d", dut->ap_internet); |
| 3219 | owrt_ap_set_vap(dut, vap_id, "internet", buf); |
| 3220 | snprintf(buf, sizeof(buf), "%d", dut->ap_venue_group); |
| 3221 | owrt_ap_set_vap(dut, vap_id, "venue_group", buf); |
| 3222 | snprintf(buf, sizeof(buf), "%d", dut->ap_venue_type); |
| 3223 | owrt_ap_set_vap(dut, vap_id, "venue_type", buf); |
| 3224 | snprintf(buf, sizeof(buf), "%s", dut->ap_hessid); |
| 3225 | owrt_ap_set_vap(dut, vap_id, "hessid", buf); |
| 3226 | |
| 3227 | if (dut->ap_gas_cb_delay > 0) { |
| 3228 | snprintf(buf, sizeof(buf), "%d", dut->ap_gas_cb_delay); |
| 3229 | owrt_ap_set_vap(dut, vap_id, "gas_comeback_delay", buf); |
| 3230 | } |
| 3231 | |
| 3232 | if (dut->ap_roaming_cons[0]) { |
| 3233 | char *rcons, *temp_ptr; |
| 3234 | |
| 3235 | rcons = strdup(dut->ap_roaming_cons); |
| 3236 | if (rcons == NULL) |
| 3237 | return 0; |
| 3238 | |
| 3239 | temp_ptr = strchr(rcons, ';'); |
| 3240 | |
| 3241 | if (temp_ptr) |
| 3242 | *temp_ptr++ = '\0'; |
| 3243 | |
| 3244 | owrt_ap_set_list_vap(dut, vap_id, "roaming_consortium", |
| 3245 | rcons); |
| 3246 | |
| 3247 | if (temp_ptr) |
| 3248 | owrt_ap_set_list_vap(dut, vap_id, |
| 3249 | "roaming_consortium", |
| 3250 | temp_ptr); |
| 3251 | |
| 3252 | free(rcons); |
| 3253 | } |
| 3254 | } |
| 3255 | |
| 3256 | if (dut->ap_venue_name) { |
| 3257 | owrt_ap_set_list_vap(dut, vap_id, "venue_name", |
| 3258 | "'P\"eng:Wi-Fi Alliance\\n2989 Copper Road\\nSanta Clara, CA 95051, USA\"'"); |
| 3259 | owrt_ap_set_list_vap(dut, vap_id, "venue_name", |
| 3260 | "\'"ANQP_VENUE_NAME_1_CHI"\'"); |
| 3261 | } |
| 3262 | |
| 3263 | if (dut->ap_net_auth_type == 1) { |
| 3264 | owrt_ap_set_vap(dut, vap_id, "network_auth_type", |
| 3265 | "'00https://tandc-server.wi-fi.org'"); |
| 3266 | } else if (dut->ap_net_auth_type == 2) { |
| 3267 | owrt_ap_set_vap(dut, vap_id, "network_auth_type", "'01'"); |
| 3268 | } |
| 3269 | |
| 3270 | if (dut->ap_nai_realm_list == 1) { |
| 3271 | owrt_ap_set_list_vap(dut, vap_id, "nai_realm", |
| 3272 | "'0,mail.example.com;cisco.com;wi-fi.org,21[2:4][5:7]'"); |
| 3273 | owrt_ap_set_list_vap(dut, vap_id, "nai_realm", |
| 3274 | "'0,wi-fi.org;example.com,13[5:6]'"); |
| 3275 | |
| 3276 | } else if (dut->ap_nai_realm_list == 2) { |
| 3277 | owrt_ap_set_list_vap(dut, vap_id, "nai_realm", |
| 3278 | "'0,wi-fi.org,21[2:4][5:7]'"); |
| 3279 | } else if (dut->ap_nai_realm_list == 3) { |
| 3280 | owrt_ap_set_list_vap(dut, vap_id, "nai_realm", |
| 3281 | "'0,cisco.com;wi-fi.org,21[2:4][5:7]'"); |
| 3282 | owrt_ap_set_list_vap(dut, vap_id, "nai_realm", |
| 3283 | "'0,wi-fi.org;example.com,13[5:6]'"); |
| 3284 | } else if (dut->ap_nai_realm_list == 4) { |
| 3285 | owrt_ap_set_list_vap(dut, vap_id, "nai_realm", |
| 3286 | "'0,mail.example.com,21[2:4][5:7],13[5:6]'"); |
| 3287 | } else if (dut->ap_nai_realm_list == 5) { |
| 3288 | owrt_ap_set_list_vap(dut, vap_id, "nai_realm", |
| 3289 | "'0,wi-fi.org;ruckuswireless.com,21[2:4][5:7]'"); |
| 3290 | } else if (dut->ap_nai_realm_list == 6) { |
| 3291 | owrt_ap_set_list_vap(dut, vap_id, "nai_realm", |
| 3292 | "'0,wi-fi.org;mail.example.com,21[2:4][5:7]'"); |
| 3293 | } else if (dut->ap_nai_realm_list == 7) { |
| 3294 | owrt_ap_set_list_vap(dut, vap_id, "nai_realm", |
| 3295 | "'0,wi-fi.org,13[5:6]'"); |
| 3296 | owrt_ap_set_list_vap(dut, vap_id, "nai_realm", |
| 3297 | "'0,wi-fi.org,21[2:4][5:7]'"); |
| 3298 | } |
| 3299 | |
| 3300 | if (dut->ap_domain_name_list[0]) |
| 3301 | owrt_ap_set_list_vap(dut, vap_id, "domain_name", |
| 3302 | dut->ap_domain_name_list); |
| 3303 | |
| 3304 | if (dut->ap_ip_addr_type_avail) |
| 3305 | owrt_ap_set_vap(dut, vap_id, "ipaddr_type_availability", |
| 3306 | "'0c'"); |
| 3307 | |
| 3308 | temp = buf; |
| 3309 | |
| 3310 | *temp++ = '\''; |
| 3311 | |
| 3312 | for (i = 0; dut->ap_plmn_mcc[i][0] && dut->ap_plmn_mnc[i][0]; i++) { |
| 3313 | if (i) |
| 3314 | *temp++ = ';'; |
| 3315 | |
| 3316 | snprintf(temp, |
| 3317 | sizeof(dut->ap_plmn_mcc[i]) + |
| 3318 | sizeof(dut->ap_plmn_mnc[i]) + 1, |
| 3319 | "%s,%s", |
| 3320 | dut->ap_plmn_mcc[i], |
| 3321 | dut->ap_plmn_mnc[i]); |
| 3322 | |
| 3323 | temp += strlen(dut->ap_plmn_mcc[i]) + |
| 3324 | strlen(dut->ap_plmn_mnc[i]) + 1; |
| 3325 | } |
| 3326 | |
| 3327 | *temp++ = '\''; |
| 3328 | *temp++ = '\0'; |
| 3329 | |
| 3330 | if (i) |
| 3331 | owrt_ap_set_vap(dut, vap_id, "anqp_3gpp_cell_net", buf); |
| 3332 | |
| 3333 | if (dut->ap_qos_map_set == 1) |
| 3334 | owrt_ap_set_vap(dut, vap_id, "qos_map_set", QOS_MAP_SET_1); |
| 3335 | else if (dut->ap_qos_map_set == 2) |
| 3336 | owrt_ap_set_vap(dut, vap_id, "qos_map_set", QOS_MAP_SET_2); |
| 3337 | |
| 3338 | /* Proxy-ARP */ |
| 3339 | snprintf(buf, sizeof(buf), "%d", dut->ap_proxy_arp); |
| 3340 | owrt_ap_set_vap(dut, vap_id, "proxyarp", buf); |
| 3341 | |
| 3342 | /* DGAF */ |
| 3343 | snprintf(buf, sizeof(buf), "%d", dut->ap_dgaf_disable); |
| 3344 | /* parse to hostapd */ |
| 3345 | owrt_ap_set_vap(dut, vap_id, "disable_dgaf", buf); |
| 3346 | /* parse to wifi driver */ |
| 3347 | owrt_ap_set_vap(dut, vap_id, "dgaf_disable", buf); |
| 3348 | |
| 3349 | /* HCBSSLoad */ |
| 3350 | if (dut->ap_bss_load) { |
| 3351 | unsigned int bssload = 0; |
| 3352 | |
| 3353 | if (dut->ap_bss_load == 1) { |
| 3354 | /* STA count: 1, CU: 50, AAC: 65535 */ |
| 3355 | bssload = 0x0132ffff; |
| 3356 | } else if (dut->ap_bss_load == 2) { |
| 3357 | /* STA count: 1, CU: 200, AAC: 65535 */ |
| 3358 | bssload = 0x01c8ffff; |
| 3359 | } else if (dut->ap_bss_load == 3) { |
| 3360 | /* STA count: 1, CU: 75, AAC: 65535 */ |
| 3361 | bssload = 0x014bffff; |
| 3362 | } |
| 3363 | |
| 3364 | snprintf(buf, sizeof(buf), "%d", bssload); |
| 3365 | owrt_ap_set_vap(dut, vap_id, "hcbssload", buf); |
| 3366 | } |
| 3367 | |
| 3368 | /* L2TIF */ |
| 3369 | if (dut->ap_l2tif) |
| 3370 | owrt_ap_set_vap(dut, vap_id, "l2tif", "1"); |
| 3371 | |
| 3372 | if (dut->ap_disable_protection == 1) |
| 3373 | owrt_ap_set_vap(dut, vap_id, "enablertscts", "0"); |
| 3374 | |
Sunil Dutt | 77b213d | 2017-09-14 18:24:40 +0300 | [diff] [blame] | 3375 | if (dut->ap_txBF) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3376 | owrt_ap_set_vap(dut, vap_id, "vhtsubfee", "1"); |
| 3377 | owrt_ap_set_vap(dut, vap_id, "vhtsubfer", "1"); |
| 3378 | } |
| 3379 | |
Mohammed Shafi Shajakhan | 061af00 | 2016-06-02 20:10:54 +0530 | [diff] [blame] | 3380 | if (dut->ap_mu_txBF) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3381 | owrt_ap_set_vap(dut, vap_id, "vhtmubfer", "1"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3382 | |
Vasanthakumar Pandurangan | 2b5431d | 2016-01-12 15:52:48 +0530 | [diff] [blame] | 3383 | if (dut->ap_tx_stbc) { |
| 3384 | /* STBC and beamforming are mutually exclusive features */ |
| 3385 | owrt_ap_set_vap(dut, vap_id, "implicitbf", "0"); |
| 3386 | } |
| 3387 | |
Priyadharshini Gowthaman | 8fb1504 | 2015-11-25 18:27:41 +0530 | [diff] [blame] | 3388 | /* enable dfsmode */ |
| 3389 | snprintf(buf, sizeof(buf), "%d", dut->ap_dfs_mode); |
| 3390 | owrt_ap_set_vap(dut, vap_id, "doth", buf); |
| 3391 | |
priyadharshini gowthaman | 2323d0a | 2016-09-02 15:48:02 -0700 | [diff] [blame] | 3392 | if (dut->program == PROGRAM_LOC && dut->ap_interworking) { |
| 3393 | char anqpval[1024]; |
| 3394 | |
| 3395 | owrt_ap_set_vap(dut, vap_id, "interworking", "1"); |
| 3396 | |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 3397 | 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] | 3398 | snprintf(anqpval, sizeof(anqpval), |
| 3399 | "'265:0010%s%s060101'", |
priyadharshini gowthaman | 2323d0a | 2016-09-02 15:48:02 -0700 | [diff] [blame] | 3400 | dut->ap_val_lci, dut->ap_infoz); |
| 3401 | owrt_ap_set_list_vap(dut, vap_id, "anqp_elem", anqpval); |
| 3402 | } |
| 3403 | |
| 3404 | if (dut->ap_lcr == 1) { |
Pradeep Reddy Potteti | b48012a | 2016-11-28 16:58:54 +0530 | [diff] [blame] | 3405 | snprintf(anqpval, sizeof(anqpval), |
| 3406 | "'266:0000b2555302ae%s'", |
priyadharshini gowthaman | 2323d0a | 2016-09-02 15:48:02 -0700 | [diff] [blame] | 3407 | dut->ap_val_lcr); |
| 3408 | owrt_ap_set_list_vap(dut, vap_id, "anqp_elem", anqpval); |
| 3409 | } |
| 3410 | |
| 3411 | if (dut->ap_fqdn_held == 1 && dut->ap_fqdn_supl == 1) |
| 3412 | owrt_ap_set_list_vap(dut, vap_id, "anqp_elem", |
| 3413 | "'267:00110168656c642e6578616d706c652e636f6d0011027375706c2e6578616d706c652e636f6d'"); |
| 3414 | } |
| 3415 | |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 3416 | if (dut->program == PROGRAM_MBO) { |
| 3417 | owrt_ap_set_vap(dut, vap_id, "interworking", "1"); |
| 3418 | owrt_ap_set_vap(dut, vap_id, "mbo", "1"); |
| 3419 | owrt_ap_set_vap(dut, vap_id, "rrm", "1"); |
Adil Saeed Musthafa | 65160c0 | 2017-04-10 23:13:38 -0700 | [diff] [blame] | 3420 | owrt_ap_set_vap(dut, vap_id, "mbo_cell_conn_pref", "1"); |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 3421 | |
| 3422 | owrt_ap_set_list_vap(dut, vap_id, "anqp_elem", |
| 3423 | "'272:34108cfdf0020df1f7000000733000030101'"); |
Adil Saeed Musthafa | ed5faae | 2017-04-10 23:13:36 -0700 | [diff] [blame] | 3424 | snprintf(buf, sizeof(buf), "%d", dut->ap_gas_cb_delay); |
| 3425 | owrt_ap_set_vap(dut, vap_id, "gas_comeback_delay", buf); |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 3426 | } |
| 3427 | |
Jouni Malinen | 6be21c8 | 2018-08-01 18:47:24 +0300 | [diff] [blame] | 3428 | if (ap_ft_enabled(dut)) { |
Adil Saeed Musthafa | 4ec61bd | 2017-04-10 23:13:41 -0700 | [diff] [blame] | 3429 | unsigned char self_mac[ETH_ALEN]; |
| 3430 | char mac_str[20]; |
| 3431 | |
| 3432 | owrt_ap_set_vap(dut, vap_id, "ft_over_ds", "0"); |
| 3433 | owrt_ap_set_vap(dut, vap_id, "ieee80211r", "1"); |
| 3434 | get_hwaddr(sigma_radio_ifname[0], self_mac); |
| 3435 | snprintf(mac_str, sizeof(mac_str), |
| 3436 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 3437 | self_mac[0], self_mac[1], self_mac[2], |
| 3438 | self_mac[3], self_mac[4], self_mac[5]); |
| 3439 | owrt_ap_set_vap(dut, vap_id, "ap_macaddr", mac_str); |
priyadharshini gowthaman | 47189f5 | 2017-12-28 12:37:46 -0800 | [diff] [blame] | 3440 | snprintf(mac_str, sizeof(mac_str), |
| 3441 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 3442 | self_mac[0], self_mac[1], self_mac[2], |
| 3443 | self_mac[3], self_mac[4], self_mac[5]); |
| 3444 | 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] | 3445 | owrt_ap_set_vap(dut, vap_id, "ft_psk_generate_local", "1"); |
| 3446 | owrt_ap_set_vap(dut, vap_id, "kh_key_hex", |
| 3447 | "000102030405060708090a0b0c0d0e0f"); |
| 3448 | snprintf(mac_str, sizeof(mac_str), |
| 3449 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 3450 | dut->ft_bss_mac_list[0][0], |
| 3451 | dut->ft_bss_mac_list[0][1], |
| 3452 | dut->ft_bss_mac_list[0][2], |
| 3453 | dut->ft_bss_mac_list[0][3], |
| 3454 | dut->ft_bss_mac_list[0][4], |
| 3455 | dut->ft_bss_mac_list[0][5]); |
| 3456 | owrt_ap_set_vap(dut, vap_id, "ap2_macaddr", mac_str); |
priyadharshini gowthaman | 47189f5 | 2017-12-28 12:37:46 -0800 | [diff] [blame] | 3457 | owrt_ap_set_vap(dut, vap_id, "mobility_domain", |
| 3458 | dut->ap_mobility_domain); |
| 3459 | 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] | 3460 | } |
| 3461 | |
Jouni Malinen | 6be21c8 | 2018-08-01 18:47:24 +0300 | [diff] [blame] | 3462 | if ((ap_ft_enabled(dut) && dut->ap_name == 0) || |
| 3463 | (ap_ft_enabled(dut) && dut->ap_name == 2)) { |
Adil Saeed Musthafa | 4ec61bd | 2017-04-10 23:13:41 -0700 | [diff] [blame] | 3464 | owrt_ap_set_vap(dut, vap_id, "nasid2", "nas2.example.com"); |
| 3465 | owrt_ap_set_vap(dut, vap_id, "nasid", "nas1.example.com"); |
Adil Saeed Musthafa | 4ec61bd | 2017-04-10 23:13:41 -0700 | [diff] [blame] | 3466 | } |
| 3467 | |
Jouni Malinen | 6be21c8 | 2018-08-01 18:47:24 +0300 | [diff] [blame] | 3468 | if (ap_ft_enabled(dut) && dut->ap_name == 1) { |
Adil Saeed Musthafa | 4ec61bd | 2017-04-10 23:13:41 -0700 | [diff] [blame] | 3469 | owrt_ap_set_vap(dut, vap_id, "nasid2", "nas1.example.com"); |
| 3470 | owrt_ap_set_vap(dut, vap_id, "nasid", "nas2.example.com"); |
Adil Saeed Musthafa | 4ec61bd | 2017-04-10 23:13:41 -0700 | [diff] [blame] | 3471 | } |
| 3472 | |
priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 3473 | if (dut->ap_broadcast_ssid == VALUE_DISABLED) |
| 3474 | owrt_ap_set_vap(dut, vap_id, "hidden", "1"); |
| 3475 | |
priyadharshini gowthaman | de81f39 | 2017-12-28 15:28:49 -0800 | [diff] [blame] | 3476 | /* Enable/disable PMKSA caching, if asked to */ |
| 3477 | if (dut->ap_pmksa == 1) { |
| 3478 | snprintf(buf, sizeof(buf), "%d", dut->ap_pmksa_caching); |
| 3479 | owrt_ap_set_vap(dut, vap_id, "disable_pmksa_caching", buf); |
| 3480 | } |
| 3481 | |
priyadharshini gowthaman | cce6ca0 | 2018-01-15 11:12:45 -0800 | [diff] [blame] | 3482 | if (dut->rsne_override) { |
| 3483 | snprintf(buf, sizeof(buf), "%s", dut->rsne_override); |
| 3484 | owrt_ap_set_vap(dut, vap_count, "own_ie_override", buf); |
| 3485 | } |
| 3486 | |
| 3487 | if (dut->sae_commit_override) { |
| 3488 | snprintf(buf, sizeof(buf), "%s", dut->sae_commit_override); |
| 3489 | owrt_ap_set_vap(dut, vap_count, "sae_commit_override", buf); |
| 3490 | } |
| 3491 | |
| 3492 | if (dut->ap_sae_groups) { |
| 3493 | snprintf(buf, sizeof(buf), "\'%s\'", dut->ap_sae_groups); |
| 3494 | owrt_ap_set_vap(dut, vap_count, "sae_groups", buf); |
| 3495 | } |
| 3496 | |
| 3497 | if (dut->sae_anti_clogging_threshold >= 0) { |
| 3498 | snprintf(buf, sizeof(buf), "%d", |
| 3499 | dut->sae_anti_clogging_threshold); |
| 3500 | owrt_ap_set_vap(dut, vap_count, "sae_anti_clogging_threshold", |
| 3501 | buf); |
| 3502 | } |
| 3503 | |
| 3504 | if (dut->sae_reflection) |
| 3505 | owrt_ap_set_vap(dut, vap_count, "sae_reflection_attack", "1"); |
| 3506 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3507 | return 1; |
| 3508 | } |
| 3509 | |
| 3510 | |
priyadharshini gowthaman | 2500f20 | 2016-10-13 17:13:55 -0700 | [diff] [blame] | 3511 | static int owrt_ap_config_vap_anqp(struct sigma_dut *dut) |
| 3512 | { |
| 3513 | char anqpval[1024]; |
| 3514 | unsigned char addr[6]; |
| 3515 | unsigned char addr2[6]; |
| 3516 | struct ifreq ifr; |
| 3517 | char *ifname; |
| 3518 | int s; |
| 3519 | int vap_id = 0; |
| 3520 | |
| 3521 | s = socket(AF_INET, SOCK_DGRAM, 0); |
| 3522 | if (s < 0) { |
| 3523 | sigma_dut_print(dut, DUT_MSG_ERROR, "Failed to open socket"); |
| 3524 | return -1; |
| 3525 | } |
| 3526 | |
| 3527 | memset(&ifr, 0, sizeof(ifr)); |
| 3528 | ifname = "ath0"; |
Peng Xu | b8fc5cc | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 3529 | strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name)); |
priyadharshini gowthaman | 2500f20 | 2016-10-13 17:13:55 -0700 | [diff] [blame] | 3530 | if (ioctl(s, SIOCGIFHWADDR, &ifr) < 0) { |
| 3531 | perror("ioctl"); |
| 3532 | close(s); |
| 3533 | return -1; |
| 3534 | } |
| 3535 | memcpy(addr, ifr.ifr_hwaddr.sa_data, 6); |
| 3536 | |
| 3537 | memset(&ifr, 0, sizeof(ifr)); |
| 3538 | ifname = "ath01"; |
Peng Xu | b8fc5cc | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 3539 | strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name)); |
priyadharshini gowthaman | 2500f20 | 2016-10-13 17:13:55 -0700 | [diff] [blame] | 3540 | if (ioctl(s, SIOCGIFHWADDR, &ifr) < 0) { |
| 3541 | perror("ioctl"); |
| 3542 | close(s); |
| 3543 | return -1; |
| 3544 | } |
| 3545 | close(s); |
| 3546 | memcpy(addr2, ifr.ifr_hwaddr.sa_data, 6); |
| 3547 | |
| 3548 | snprintf(anqpval, sizeof(anqpval), |
| 3549 | "'265:0010%s%s060101070d00%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x'", |
| 3550 | dut->ap_val_lci, dut->ap_infoz, |
| 3551 | addr[0], addr[1], addr[2], addr[3], addr[4], addr[5], |
| 3552 | addr2[0], addr2[1], addr2[2], addr2[3], addr2[4], addr2[5]); |
| 3553 | |
| 3554 | owrt_ap_set_list_vap(dut, vap_id, "anqp_elem", anqpval); |
| 3555 | return 0; |
| 3556 | } |
| 3557 | |
| 3558 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3559 | static int owrt_ap_post_config_commit(struct sigma_dut *dut, |
| 3560 | struct sigma_conn *conn, |
| 3561 | struct sigma_cmd *cmd) |
| 3562 | { |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 3563 | int ap_security = 0; |
| 3564 | int i; |
| 3565 | |
| 3566 | for (i = 0; i < MAX_WLAN_TAGS - 1; i++) { |
| 3567 | if (dut->ap_tag_key_mgmt[i] != AP2_OPEN) |
| 3568 | ap_security = 1; |
| 3569 | } |
| 3570 | if (dut->ap_key_mgmt != AP_OPEN) |
| 3571 | ap_security = 1; |
| 3572 | if (ap_security) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3573 | /* allow some time for hostapd to start before returning |
| 3574 | * success */ |
| 3575 | usleep(500000); |
| 3576 | |
| 3577 | if (run_hostapd_cli(dut, "ping") != 0) { |
| 3578 | send_resp(dut, conn, SIGMA_ERROR, |
| 3579 | "errorCode,Failed to talk to hostapd"); |
| 3580 | return 0; |
| 3581 | } |
| 3582 | } |
| 3583 | |
| 3584 | if (get_openwrt_driver_type() == OPENWRT_DRIVER_ATHEROS) |
| 3585 | ath_ap_set_params(dut); |
| 3586 | |
| 3587 | /* Send response */ |
| 3588 | return 1; |
| 3589 | } |
| 3590 | |
| 3591 | |
| 3592 | static int cmd_owrt_ap_config_commit(struct sigma_dut *dut, |
| 3593 | struct sigma_conn *conn, |
| 3594 | struct sigma_cmd *cmd) |
| 3595 | { |
priyadharshini gowthaman | b4de196 | 2018-01-15 12:21:04 -0800 | [diff] [blame] | 3596 | if (dut->program == PROGRAM_DPP && |
| 3597 | get_driver_type() == DRIVER_OPENWRT) { |
| 3598 | wpa_command(dut->hostapd_ifname, "DPP_BOOTSTRAP_REMOVE *"); |
| 3599 | wpa_command(dut->hostapd_ifname, "DPP_PKEX_REMOVE *"); |
| 3600 | } |
| 3601 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3602 | /* Stop the AP */ |
| 3603 | run_system(dut, "wifi down"); |
| 3604 | |
| 3605 | /* Reset the wireless configuration */ |
Mohammed Shafi Shajakhan | f789f82 | 2016-04-07 18:53:16 +0530 | [diff] [blame] | 3606 | run_system(dut, "rm -rf /etc/config/wireless"); |
| 3607 | switch (get_openwrt_driver_type()) { |
| 3608 | case OPENWRT_DRIVER_ATHEROS: |
| 3609 | run_system(dut, "wifi detect qcawifi > /etc/config/wireless"); |
| 3610 | break; |
| 3611 | default: |
| 3612 | run_system(dut, "wifi detect > /etc/config/wireless"); |
| 3613 | break; |
| 3614 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3615 | |
| 3616 | /* Configure Radio & VAP, commit the config */ |
| 3617 | owrt_ap_config_radio(dut); |
| 3618 | owrt_ap_config_vap(dut); |
| 3619 | run_system(dut, "uci commit"); |
| 3620 | |
| 3621 | /* Start AP */ |
| 3622 | run_system(dut, "wifi up"); |
Adil Saeed Musthafa | a8d7484 | 2017-04-10 23:13:39 -0700 | [diff] [blame] | 3623 | if (dut->program != PROGRAM_MBO && |
| 3624 | dut->ap_lci == 1 && dut->ap_interworking && |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 3625 | strlen(dut->ap_tag_ssid[0]) > 0) { |
Adil Saeed Musthafa | a8d7484 | 2017-04-10 23:13:39 -0700 | [diff] [blame] | 3626 | /* |
| 3627 | * MBO has a different ANQP element value which is set in |
| 3628 | * owrt_ap_config_vap(). |
| 3629 | */ |
priyadharshini gowthaman | 2500f20 | 2016-10-13 17:13:55 -0700 | [diff] [blame] | 3630 | owrt_ap_config_vap_anqp(dut); |
| 3631 | run_system(dut, "uci commit"); |
| 3632 | run_system(dut, "wifi"); |
| 3633 | } |
| 3634 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3635 | return owrt_ap_post_config_commit(dut, conn, cmd); |
| 3636 | } |
| 3637 | |
| 3638 | |
| 3639 | static void cmd_owrt_ap_hs2_reset(struct sigma_dut *dut) |
| 3640 | { |
| 3641 | unsigned char bssid[6]; |
| 3642 | char buf[100]; |
| 3643 | char *ifname, *radio_name; |
| 3644 | int vap_id = 0; |
| 3645 | |
| 3646 | if (sigma_radio_ifname[0] && |
| 3647 | strcmp(sigma_radio_ifname[0], "wifi2") == 0) { |
| 3648 | ifname = "ath2"; |
| 3649 | radio_name = "wifi2"; |
| 3650 | vap_id = 2; |
| 3651 | } else if (sigma_radio_ifname[0] && |
| 3652 | strcmp(sigma_radio_ifname[0], "wifi1") == 0) { |
| 3653 | ifname = "ath1"; |
| 3654 | radio_name = "wifi1"; |
| 3655 | vap_id = 1; |
| 3656 | } else { |
| 3657 | ifname = "ath0"; |
| 3658 | radio_name = "wifi0"; |
| 3659 | vap_id = 0; |
| 3660 | } |
| 3661 | |
| 3662 | if (!get_hwaddr(ifname, bssid)) { |
| 3663 | snprintf(buf, sizeof(buf), "%s", bssid); |
| 3664 | owrt_ap_set_vap(dut, vap_id, "hessid", buf); |
| 3665 | snprintf(dut->ap_hessid, sizeof(dut->ap_hessid), |
| 3666 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 3667 | bssid[0], bssid[1], bssid[2], bssid[3], |
| 3668 | bssid[4], bssid[5]); |
| 3669 | } else { |
| 3670 | if (!get_hwaddr(radio_name, bssid)) { |
| 3671 | snprintf(buf, sizeof(buf), "%s", dut->ap_hessid); |
| 3672 | owrt_ap_set_vap(dut, vap_id, "hessid", buf); |
| 3673 | snprintf(dut->ap_hessid, sizeof(dut->ap_hessid), |
| 3674 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 3675 | bssid[0], bssid[1], bssid[2], bssid[3], |
| 3676 | bssid[4], bssid[5]); |
| 3677 | } else { |
| 3678 | /* Select & enable/disable radios */ |
| 3679 | if (sigma_radio_ifname[0] && |
| 3680 | strcmp(sigma_radio_ifname[0], "wifi2") == 0) { |
| 3681 | /* We want to use wifi2 */ |
| 3682 | owrt_ap_set_radio(dut, 0, "disabled", "1"); |
| 3683 | owrt_ap_set_radio(dut, 1, "disabled", "1"); |
| 3684 | owrt_ap_set_radio(dut, 2, "disabled", "0"); |
| 3685 | owrt_ap_set_vap(dut, vap_id, "device", "wifi2"); |
| 3686 | } else if (sigma_radio_ifname[0] && |
| 3687 | strcmp(sigma_radio_ifname[0], "wifi1") == 0) { |
| 3688 | /* We want to use wifi1 */ |
| 3689 | owrt_ap_set_radio(dut, 0, "disabled", "1"); |
| 3690 | owrt_ap_set_radio(dut, 1, "disabled", "0"); |
| 3691 | owrt_ap_set_vap(dut, vap_id, "device", "wifi1"); |
| 3692 | } else { |
| 3693 | /* We want to use wifi0 */ |
| 3694 | owrt_ap_set_radio(dut, 0, "disabled", "0"); |
| 3695 | owrt_ap_set_radio(dut, 1, "disabled", "1"); |
| 3696 | owrt_ap_set_vap(dut, vap_id, "device", "wifi0"); |
| 3697 | } |
| 3698 | |
| 3699 | run_system(dut, "uci commit"); |
| 3700 | run_system(dut, "wifi up"); |
| 3701 | |
| 3702 | if (!get_hwaddr(radio_name, bssid)) { |
| 3703 | snprintf(buf, sizeof(buf), "%s", |
| 3704 | dut->ap_hessid); |
| 3705 | owrt_ap_set_vap(dut, vap_id, "hessid", buf); |
| 3706 | snprintf(dut->ap_hessid, sizeof(dut->ap_hessid), |
| 3707 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 3708 | bssid[0], bssid[1], bssid[2], bssid[3], |
| 3709 | bssid[4], bssid[5]); |
| 3710 | } |
| 3711 | } |
| 3712 | } |
| 3713 | } |
| 3714 | |
| 3715 | |
| 3716 | static int cmd_ap_reboot(struct sigma_dut *dut, struct sigma_conn *conn, |
| 3717 | struct sigma_cmd *cmd) |
| 3718 | { |
| 3719 | switch (get_driver_type()) { |
| 3720 | case DRIVER_ATHEROS: |
| 3721 | run_system(dut, "apdown"); |
| 3722 | sleep(1); |
| 3723 | run_system(dut, "reboot"); |
| 3724 | break; |
| 3725 | case DRIVER_OPENWRT: |
| 3726 | run_system(dut, "wifi down"); |
| 3727 | sleep(1); |
| 3728 | run_system(dut, "reboot"); |
| 3729 | break; |
| 3730 | default: |
| 3731 | sigma_dut_print(dut, DUT_MSG_INFO, "Ignore ap_reboot command"); |
| 3732 | break; |
| 3733 | } |
| 3734 | |
| 3735 | return 1; |
| 3736 | } |
| 3737 | |
| 3738 | |
| 3739 | int ascii2hexstr(const char *str, char *hex) |
| 3740 | { |
| 3741 | int i, length; |
| 3742 | |
| 3743 | length = strlen(str); |
| 3744 | |
| 3745 | for (i = 0; i < length; i++) |
| 3746 | snprintf(hex + i * 2, 3, "%X", str[i]); |
| 3747 | |
| 3748 | hex[length * 2] = '\0'; |
| 3749 | return 1; |
| 3750 | } |
| 3751 | |
| 3752 | |
| 3753 | static int kill_process(struct sigma_dut *dut, char *proc_name, |
| 3754 | unsigned char is_proc_instance_one, int sig) |
| 3755 | { |
| 3756 | #ifdef __linux__ |
| 3757 | struct dirent *dp, *dp_in; |
| 3758 | const char *direc = "/proc/"; |
| 3759 | char buf[100]; |
| 3760 | DIR *dir = opendir(direc); |
| 3761 | DIR *dir_in; |
| 3762 | FILE *fp; |
| 3763 | char *pid, *temp; |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 3764 | char *saveptr; |
Pradeep Reddy Potteti | d068e64 | 2017-02-17 20:03:12 +0530 | [diff] [blame] | 3765 | int ret = -1; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3766 | |
| 3767 | if (dir == NULL) |
Pradeep Reddy Potteti | d068e64 | 2017-02-17 20:03:12 +0530 | [diff] [blame] | 3768 | return ret; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3769 | |
| 3770 | while ((dp = readdir(dir)) != NULL) { |
| 3771 | if (dp->d_type != DT_DIR) |
| 3772 | continue; |
| 3773 | |
| 3774 | snprintf(buf, sizeof(buf), "%s%s", direc, dp->d_name); |
| 3775 | dir_in = opendir(buf); |
| 3776 | if (dir_in == NULL) |
| 3777 | continue; |
| 3778 | dp_in = readdir(dir_in); |
| 3779 | closedir(dir_in); |
| 3780 | if (dp_in == NULL) |
| 3781 | continue; |
| 3782 | snprintf(buf, sizeof(buf), "%s%s/stat", direc, dp->d_name); |
| 3783 | fp = fopen(buf, "r"); |
| 3784 | if (fp == NULL) |
| 3785 | continue; |
| 3786 | if (fgets(buf, 100, fp) == NULL) |
| 3787 | buf[0] = '\0'; |
| 3788 | fclose(fp); |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 3789 | pid = strtok_r(buf, " ", &saveptr); |
| 3790 | temp = strtok_r(NULL, " ", &saveptr); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3791 | if (pid && temp && |
| 3792 | strncmp(temp, proc_name, strlen(proc_name)) == 0) { |
| 3793 | sigma_dut_print(dut, DUT_MSG_INFO, |
| 3794 | "killing %s process with PID %s", |
| 3795 | proc_name, pid); |
| 3796 | snprintf(buf, sizeof(buf), "kill -%d %d", sig, |
| 3797 | atoi(pid)); |
| 3798 | run_system(dut, buf); |
Pradeep Reddy Potteti | d068e64 | 2017-02-17 20:03:12 +0530 | [diff] [blame] | 3799 | ret = 0; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3800 | if (is_proc_instance_one) |
| 3801 | break; |
| 3802 | } |
| 3803 | } |
| 3804 | |
| 3805 | closedir(dir); |
| 3806 | |
Pradeep Reddy Potteti | d068e64 | 2017-02-17 20:03:12 +0530 | [diff] [blame] | 3807 | return ret; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3808 | #else /* __linux__ */ |
| 3809 | return -1; |
| 3810 | #endif /* __linux__ */ |
| 3811 | } |
| 3812 | |
| 3813 | |
| 3814 | static int run_ndc(struct sigma_dut *dut, char *buf) |
| 3815 | { |
| 3816 | sigma_dut_print(dut, DUT_MSG_INFO, "CMD NDC:: %s", buf); |
| 3817 | sleep(2); |
| 3818 | return run_system(dut, buf); |
| 3819 | } |
| 3820 | |
| 3821 | |
| 3822 | static int sigma_write_cfg(struct sigma_dut *dut, const char *pfile, |
| 3823 | const char *field, const char *value) |
| 3824 | { |
| 3825 | FILE *fcfg, *ftmp; |
| 3826 | char buf[MAX_CONF_LINE_LEN + 1]; |
| 3827 | int len, found = 0, res; |
| 3828 | |
| 3829 | /* Open the configuration file */ |
| 3830 | fcfg = fopen(pfile, "r"); |
| 3831 | if (!fcfg) { |
| 3832 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 3833 | "Failed to open hostapd conf file"); |
| 3834 | return -1; |
| 3835 | } |
| 3836 | |
| 3837 | snprintf(buf, sizeof(buf), "%s~", pfile); |
| 3838 | /* Open a temporary file */ |
| 3839 | ftmp = fopen(buf, "w+"); |
| 3840 | if (!ftmp) { |
| 3841 | fclose(fcfg); |
| 3842 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 3843 | "Failed to open temp buf"); |
| 3844 | return -1; |
| 3845 | } |
| 3846 | |
| 3847 | /* Read the values from the configuration file */ |
| 3848 | len = strlen(field); |
| 3849 | while (fgets(buf, MAX_CONF_LINE_LEN, fcfg)) { |
| 3850 | char *pline = buf; |
| 3851 | |
| 3852 | /* commented line */ |
| 3853 | if (buf[0] == '#') |
| 3854 | pline++; |
| 3855 | |
| 3856 | /* Identify the configuration parameter to be updated */ |
| 3857 | if (!found && strncmp(pline, field, len) == 0 && |
| 3858 | pline[len] == '=') { |
| 3859 | snprintf(buf, sizeof(buf), "%s=%s\n", field, value); |
| 3860 | found = 1; |
| 3861 | sigma_dut_print(dut, DUT_MSG_INFO, |
| 3862 | "Updated hostapd conf file"); |
| 3863 | } |
| 3864 | |
| 3865 | fprintf(ftmp, "%s", buf); |
| 3866 | } |
| 3867 | |
| 3868 | if (!found) { |
| 3869 | /* Configuration line not found */ |
| 3870 | /* Add the new line at the end of file */ |
| 3871 | fprintf(ftmp, "%s=%s\n", field, value); |
| 3872 | sigma_dut_print(dut, DUT_MSG_INFO, |
| 3873 | "Adding a new line in hostapd conf file"); |
| 3874 | } |
| 3875 | |
| 3876 | fclose(fcfg); |
| 3877 | fclose(ftmp); |
| 3878 | |
| 3879 | snprintf(buf, sizeof(buf), "%s~", pfile); |
| 3880 | |
| 3881 | /* Restore the updated configuration file */ |
| 3882 | res = rename(buf, pfile); |
| 3883 | |
| 3884 | /* Remove the temporary file. Ignore the return value */ |
| 3885 | unlink(buf); |
| 3886 | |
| 3887 | /* chmod is needed because open() may not set permissions properly |
| 3888 | * depending on the current umask */ |
| 3889 | if (chmod(pfile, 0660) < 0) { |
| 3890 | unlink(pfile); |
| 3891 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 3892 | "Error changing permissions"); |
| 3893 | return -1; |
| 3894 | } |
| 3895 | |
| 3896 | if (res < 0) { |
| 3897 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 3898 | "Error restoring conf file"); |
| 3899 | return -1; |
| 3900 | } |
| 3901 | |
| 3902 | return 0; |
| 3903 | } |
| 3904 | |
| 3905 | |
| 3906 | static int cmd_wcn_ap_config_commit(struct sigma_dut *dut, |
| 3907 | struct sigma_conn *conn, |
| 3908 | struct sigma_cmd *cmd) |
| 3909 | { |
| 3910 | char buf[100]; |
| 3911 | struct stat s; |
| 3912 | int num_tries = 0, ret; |
| 3913 | |
Pradeep Reddy Potteti | d068e64 | 2017-02-17 20:03:12 +0530 | [diff] [blame] | 3914 | if (kill_process(dut, "(netd)", 1, SIGKILL) == 0 || |
| 3915 | system("killall netd") == 0) { |
| 3916 | /* Avoid Error: Error connecting (Connection refused) |
| 3917 | * Wait some time to allow netd to reinitialize. |
| 3918 | */ |
| 3919 | usleep(1500000); |
| 3920 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3921 | |
| 3922 | while (num_tries < 10) { |
| 3923 | ret = run_ndc(dut, "ndc softap stopap"); |
| 3924 | num_tries++; |
| 3925 | if (WIFEXITED(ret)) |
| 3926 | ret = WEXITSTATUS(ret); |
| 3927 | /* On success, NDC exits with 0 */ |
| 3928 | if (ret == 0) |
| 3929 | break; |
| 3930 | sigma_dut_print(dut, DUT_MSG_INFO, |
| 3931 | "Try No. %d: ndc softap stopap failed, exit code %d", |
| 3932 | num_tries, ret); |
| 3933 | } |
| 3934 | |
| 3935 | if (ret != 0) |
| 3936 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 3937 | "ndc softap stopap command failed for 10 times - giving up"); |
| 3938 | |
| 3939 | #ifdef ANDROID |
| 3940 | /* Unload/Load driver to cleanup the state of the driver */ |
Ajit Vaishya | 14d1f9a | 2017-09-04 23:24:25 +0530 | [diff] [blame] | 3941 | system("rmmod -f wlan"); |
| 3942 | usleep(500000); |
| 3943 | system("insmod /system/lib/modules/wlan.ko"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3944 | #else /* ANDROID */ |
| 3945 | run_ndc(dut, "ndc softap qccmd set enable_softap=0"); |
| 3946 | run_ndc(dut, "ndc softap qccmd set enable_softap=1"); |
| 3947 | #endif /* ANDROID */ |
| 3948 | |
| 3949 | switch (dut->ap_mode) { |
| 3950 | case AP_11g: |
| 3951 | run_ndc(dut, "ndc softap qccmd set hw_mode=g-only"); |
| 3952 | break; |
| 3953 | case AP_11b: |
| 3954 | run_ndc(dut, "ndc softap qccmd set hw_mode=b-only"); |
| 3955 | break; |
| 3956 | case AP_11ng: |
| 3957 | run_ndc(dut, "ndc softap qccmd set hw_mode=n"); |
| 3958 | break; |
| 3959 | case AP_11a: |
| 3960 | run_ndc(dut, "ndc softap qccmd set hw_mode=a-only"); |
| 3961 | break; |
| 3962 | case AP_11na: |
| 3963 | run_ndc(dut, "ndc softap qccmd set hw_mode=n"); |
| 3964 | break; |
| 3965 | case AP_11ac: |
| 3966 | run_ndc(dut, "ndc softap qccmd set hw_mode=ac"); |
| 3967 | break; |
| 3968 | default: |
| 3969 | break; |
| 3970 | } |
| 3971 | |
| 3972 | snprintf(buf, sizeof(buf), "ndc softap qccmd set channel=%d", |
| 3973 | dut->ap_channel); |
| 3974 | run_ndc(dut, buf); |
| 3975 | |
| 3976 | /* |
| 3977 | * ndc doesn't support double quotes as SSID string, so re-write |
| 3978 | * hostapd configuration file to update SSID. |
| 3979 | */ |
| 3980 | if (dut->ap_ssid[0] != '\0') |
| 3981 | sigma_write_cfg(dut, ANDROID_CONFIG_FILE, "ssid", dut->ap_ssid); |
| 3982 | |
| 3983 | switch (dut->ap_key_mgmt) { |
| 3984 | case AP_OPEN: |
| 3985 | if (dut->ap_cipher == AP_WEP) { |
| 3986 | run_ndc(dut, "ndc softap qccmd set security_mode=1"); |
| 3987 | snprintf(buf, sizeof(buf), |
| 3988 | "ndc softap qccmd set wep_key0=%s", |
| 3989 | dut->ap_wepkey); |
| 3990 | run_ndc(dut, buf); |
| 3991 | } else { |
| 3992 | run_ndc(dut, "ndc softap qccmd set security_mode=0"); |
| 3993 | } |
| 3994 | break; |
| 3995 | case AP_WPA2_PSK: |
| 3996 | case AP_WPA2_PSK_MIXED: |
| 3997 | case AP_WPA_PSK: |
| 3998 | if (dut->ap_key_mgmt == AP_WPA2_PSK) |
| 3999 | run_ndc(dut, "ndc softap qccmd set security_mode=3"); |
| 4000 | else if (dut->ap_key_mgmt == AP_WPA2_PSK_MIXED) |
| 4001 | run_ndc(dut, "ndc softap qccmd set security_mode=4"); |
| 4002 | else |
| 4003 | run_ndc(dut, "ndc softap qccmd set security_mode=2"); |
| 4004 | |
| 4005 | /* |
| 4006 | * ndc doesn't support some special characters as passphrase, |
| 4007 | * so re-write hostapd configuration file to update Passphrase. |
| 4008 | */ |
| 4009 | if (dut->ap_passphrase[0] != '\0') |
| 4010 | sigma_write_cfg(dut, ANDROID_CONFIG_FILE, |
| 4011 | "wpa_passphrase", dut->ap_passphrase); |
| 4012 | |
| 4013 | if (dut->ap_cipher == AP_CCMP_TKIP) |
| 4014 | run_ndc(dut, "ndc softap qccmd set wpa_pairwise=" |
| 4015 | "TKIP CCMP"); |
| 4016 | else if (dut->ap_cipher == AP_TKIP) |
| 4017 | run_ndc(dut, "ndc softap qccmd set wpa_pairwise=" |
| 4018 | "TKIP"); |
| 4019 | else |
| 4020 | run_ndc(dut, "ndc softap qccmd set wpa_pairwise=" |
| 4021 | "CCMP &"); |
| 4022 | break; |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 4023 | case AP_WPA2_SAE: |
| 4024 | case AP_WPA2_PSK_SAE: |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4025 | case AP_WPA2_EAP: |
| 4026 | case AP_WPA2_EAP_MIXED: |
| 4027 | case AP_WPA_EAP: |
Jouni Malinen | ad395a2 | 2017-09-01 21:13:46 +0300 | [diff] [blame] | 4028 | case AP_SUITEB: |
Jouni Malinen | 147b3c3 | 2017-10-09 16:51:54 +0300 | [diff] [blame] | 4029 | case AP_WPA2_OWE: |
Jouni Malinen | 4cf699f | 2018-06-19 00:46:27 +0300 | [diff] [blame] | 4030 | case AP_WPA2_EAP_OSEN: |
Jouni Malinen | 6be21c8 | 2018-08-01 18:47:24 +0300 | [diff] [blame] | 4031 | case AP_WPA2_FT_EAP: |
| 4032 | case AP_WPA2_FT_PSK: |
| 4033 | case AP_WPA2_EAP_SHA256: |
| 4034 | case AP_WPA2_PSK_SHA256: |
| 4035 | case AP_WPA2_ENT_FT_EAP: |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4036 | /* Not supported */ |
| 4037 | break; |
| 4038 | } |
| 4039 | |
| 4040 | switch (dut->ap_pmf) { |
| 4041 | case AP_PMF_DISABLED: |
| 4042 | run_ndc(dut, "ndc softap qccmd set ieee80211w=0"); |
| 4043 | break; |
| 4044 | case AP_PMF_OPTIONAL: |
| 4045 | run_ndc(dut, "ndc softap qccmd set ieee80211w=1"); |
| 4046 | if (dut->ap_add_sha256) |
| 4047 | run_ndc(dut, "ndc softap qccmd set wpa_key_mgmt=WPA-PSK WPA-PSK-SHA256"); |
| 4048 | else |
| 4049 | run_ndc(dut, "ndc softap qccmd set wpa_key_mgmt=WPA-PSK"); |
| 4050 | break; |
| 4051 | case AP_PMF_REQUIRED: |
| 4052 | run_ndc(dut, "ndc softap qccmd set ieee80211w=2"); |
| 4053 | run_ndc(dut, "ndc softap qccmd set wpa_key_mgmt=WPA-PSK-SHA256"); |
| 4054 | break; |
| 4055 | } |
| 4056 | |
| 4057 | if (dut->ap_countrycode[0]) { |
| 4058 | snprintf(buf, sizeof(buf), |
| 4059 | "ndc softap qccmd set country_code=%s", |
| 4060 | dut->ap_countrycode); |
| 4061 | run_ndc(dut, buf); |
| 4062 | } |
| 4063 | |
Pradeep Reddy POTTETI | fba27db | 2015-11-20 16:42:22 +0530 | [diff] [blame] | 4064 | if (dut->ap_regulatory_mode == AP_80211D_MODE_ENABLED) |
| 4065 | run_ndc(dut, "ndc softap qccmd set ieee80211d=1"); |
| 4066 | |
| 4067 | if (dut->ap_dfs_mode == AP_DFS_MODE_ENABLED) |
| 4068 | run_ndc(dut, "ndc softap qccmd set ieee80211h=1"); |
| 4069 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4070 | run_ndc(dut, "ndc softap startap"); |
| 4071 | |
| 4072 | snprintf(buf, sizeof(buf), "%s%s", sigma_wpas_ctrl, sigma_main_ifname); |
| 4073 | num_tries = 0; |
| 4074 | while (num_tries < 10 && (ret = stat(buf, &s) != 0)) { |
| 4075 | run_ndc(dut, "ndc softap stopap"); |
| 4076 | run_ndc(dut, "ndc softap startap"); |
| 4077 | num_tries++; |
| 4078 | } |
| 4079 | |
| 4080 | if (num_tries == 10) { |
| 4081 | sigma_dut_print(dut, DUT_MSG_INFO, "Tried 10 times with ctrl " |
| 4082 | "iface %s :: reboot the APDUT", buf); |
| 4083 | return ret; |
| 4084 | } |
| 4085 | |
| 4086 | sigma_dut_print(dut, DUT_MSG_INFO, "setting ip addr %s mask %s", |
| 4087 | ap_inet_addr, ap_inet_mask); |
| 4088 | snprintf(buf, sizeof(buf), "ifconfig %s %s netmask %s up", |
| 4089 | sigma_main_ifname, ap_inet_addr, ap_inet_mask); |
| 4090 | if (system(buf) != 0) { |
| 4091 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4092 | "Failed to intialize the interface"); |
| 4093 | return -1; |
| 4094 | } |
| 4095 | |
| 4096 | return 1; |
| 4097 | } |
| 4098 | |
| 4099 | |
| 4100 | static int append_hostapd_conf_hs2(struct sigma_dut *dut, FILE *f) |
| 4101 | { |
| 4102 | fprintf(f, "hs20=1\nhs20_deauth_req_timeout=3\n" |
| 4103 | "disable_dgaf=%d\n", dut->ap_dgaf_disable); |
| 4104 | |
| 4105 | if (dut->ap_oper_name) { |
| 4106 | fprintf(f, "hs20_oper_friendly_name=eng:Wi-Fi Alliance\n"); |
| 4107 | fprintf(f, "hs20_oper_friendly_name=chi:Wi-Fi\xe8\x81\x94\xe7\x9b\x9f\n"); |
| 4108 | } |
| 4109 | |
| 4110 | if (dut->ap_wan_metrics == 1) |
| 4111 | fprintf(f, "hs20_wan_metrics=01:2500:384:0:0:10\n"); |
| 4112 | else if (dut->ap_wan_metrics == 2) |
| 4113 | fprintf(f, "hs20_wan_metrics=01:1500:384:20:20:10\n"); |
| 4114 | else if (dut->ap_wan_metrics == 3) |
| 4115 | fprintf(f, "hs20_wan_metrics=01:2000:1000:20:20:10\n"); |
| 4116 | else if (dut->ap_wan_metrics == 4) |
| 4117 | fprintf(f, "hs20_wan_metrics=01:8000:1000:20:20:10\n"); |
| 4118 | else if (dut->ap_wan_metrics == 5) |
| 4119 | fprintf(f, "hs20_wan_metrics=01:9000:5000:20:20:10\n"); |
| 4120 | |
| 4121 | if (dut->ap_conn_capab == 1) { |
| 4122 | fprintf(f, "hs20_conn_capab=1:0:0\n"); |
| 4123 | fprintf(f, "hs20_conn_capab=6:20:1\n"); |
| 4124 | fprintf(f, "hs20_conn_capab=6:22:0\n"); |
| 4125 | fprintf(f, "hs20_conn_capab=6:80:1\n"); |
| 4126 | fprintf(f, "hs20_conn_capab=6:443:1\n"); |
| 4127 | fprintf(f, "hs20_conn_capab=6:1723:0\n"); |
| 4128 | fprintf(f, "hs20_conn_capab=6:5060:0\n"); |
| 4129 | fprintf(f, "hs20_conn_capab=17:500:1\n"); |
| 4130 | fprintf(f, "hs20_conn_capab=17:5060:0\n"); |
| 4131 | fprintf(f, "hs20_conn_capab=17:4500:1\n"); |
| 4132 | fprintf(f, "hs20_conn_capab=50:0:1\n"); |
| 4133 | } else if (dut->ap_conn_capab == 2) { |
| 4134 | fprintf(f, "hs20_conn_capab=6:80:1\n"); |
| 4135 | fprintf(f, "hs20_conn_capab=6:443:1\n"); |
| 4136 | fprintf(f, "hs20_conn_capab=17:5060:1\n"); |
| 4137 | fprintf(f, "hs20_conn_capab=6:5060:1\n"); |
| 4138 | } else if (dut->ap_conn_capab == 3) { |
| 4139 | fprintf(f, "hs20_conn_capab=6:80:1\n"); |
| 4140 | fprintf(f, "hs20_conn_capab=6:443:1\n"); |
| 4141 | } else if (dut->ap_conn_capab == 4) { |
| 4142 | fprintf(f, "hs20_conn_capab=6:80:1\n"); |
| 4143 | fprintf(f, "hs20_conn_capab=6:443:1\n"); |
| 4144 | fprintf(f, "hs20_conn_capab=6:5060:1\n"); |
| 4145 | fprintf(f, "hs20_conn_capab=17:5060:1\n"); |
| 4146 | } |
| 4147 | |
| 4148 | if (dut->ap_oper_class == 1) |
| 4149 | fprintf(f, "hs20_operating_class=51\n"); |
| 4150 | else if (dut->ap_oper_class == 2) |
| 4151 | fprintf(f, "hs20_operating_class=73\n"); |
| 4152 | else if (dut->ap_oper_class == 3) |
| 4153 | fprintf(f, "hs20_operating_class=5173\n"); |
| 4154 | |
| 4155 | if (dut->ap_osu_provider_list) { |
| 4156 | char *osu_friendly_name = NULL; |
| 4157 | char *osu_icon = NULL; |
| 4158 | char *osu_ssid = NULL; |
| 4159 | char *osu_nai = NULL; |
| 4160 | char *osu_service_desc = NULL; |
| 4161 | char *hs20_icon_filename = NULL; |
| 4162 | char hs20_icon[150]; |
| 4163 | int osu_method; |
| 4164 | |
| 4165 | hs20_icon_filename = "icon_red_zxx.png"; |
| 4166 | if (dut->ap_osu_icon_tag == 2) |
| 4167 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 4168 | snprintf(hs20_icon, sizeof(hs20_icon), |
| 4169 | "128:61:zxx:image/png:icon_red_zxx.png:/etc/ath/%s", |
| 4170 | hs20_icon_filename); |
| 4171 | osu_icon = "icon_red_zxx.png"; |
| 4172 | osu_ssid = "OSU"; |
| 4173 | osu_friendly_name = "kor:SP 빨강 테스트 전용"; |
| 4174 | osu_service_desc = "kor:테스트 목적으로 무료 서비스"; |
| 4175 | osu_method = (dut->ap_osu_method[0] == 0xFF) ? 1 : dut->ap_osu_method[0]; |
| 4176 | |
| 4177 | if (strlen(dut->ap_osu_server_uri[0])) |
| 4178 | fprintf(f, "osu_server_uri=%s\n", dut->ap_osu_server_uri[0]); |
| 4179 | else |
| 4180 | fprintf(f, "osu_server_uri=https://osu-server.r2-testbed.wi-fi.org/\n"); |
| 4181 | |
| 4182 | switch (dut->ap_osu_provider_list) { |
| 4183 | case 1: |
| 4184 | case 101: |
| 4185 | fprintf(f, "osu_friendly_name=eng:SP Red Test Only\n"); |
| 4186 | fprintf(f, "osu_service_desc=eng:Free service for test purpose\n"); |
| 4187 | hs20_icon_filename = "icon_red_eng.png"; |
| 4188 | if (dut->ap_osu_icon_tag == 2) |
| 4189 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 4190 | fprintf(f, "hs20_icon=160:76:eng:image/png:icon_red_eng.png:/etc/ath/%s\n", |
| 4191 | hs20_icon_filename); |
| 4192 | fprintf(f, "osu_icon=icon_red_eng.png\n"); |
| 4193 | break; |
| 4194 | case 2: |
| 4195 | case 102: |
| 4196 | fprintf(f, "osu_friendly_name=eng:Wireless Broadband Alliance\n"); |
| 4197 | fprintf(f, "osu_service_desc=eng:Free service for test purpose\n"); |
| 4198 | hs20_icon_filename = "icon_orange_zxx.png"; |
| 4199 | if (dut->ap_osu_icon_tag == 2) |
| 4200 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 4201 | snprintf(hs20_icon, sizeof(hs20_icon), |
| 4202 | "128:61:zxx:image/png:icon_orange_zxx.png:/etc/ath/%s", |
| 4203 | hs20_icon_filename); |
| 4204 | osu_icon = "icon_orange_zxx.png"; |
| 4205 | osu_friendly_name = "kor:와이어리스 브로드밴드 얼라이언스"; |
| 4206 | break; |
| 4207 | case 3: |
| 4208 | case 103: |
| 4209 | osu_friendly_name = "spa:SP Red Test Only"; |
| 4210 | osu_service_desc = "spa:Free service for test purpose"; |
| 4211 | break; |
| 4212 | case 4: |
| 4213 | case 104: |
| 4214 | fprintf(f, "osu_friendly_name=eng:SP Orange Test Only\n"); |
| 4215 | fprintf(f, "osu_service_desc=eng:Free service for test purpose\n"); |
| 4216 | hs20_icon_filename = "icon_orange_eng.png"; |
| 4217 | if (dut->ap_osu_icon_tag == 2) |
| 4218 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 4219 | fprintf(f, "hs20_icon=160:76:eng:image/png:icon_orange_eng.png:/etc/ath/%s\n", |
| 4220 | hs20_icon_filename); |
| 4221 | fprintf(f, "osu_icon=icon_orange_eng.png\n"); |
| 4222 | osu_friendly_name = "kor:SP 오렌지 테스트 전용"; |
| 4223 | |
| 4224 | hs20_icon_filename = "icon_orange_zxx.png"; |
| 4225 | if (dut->ap_osu_icon_tag == 2) |
| 4226 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 4227 | snprintf(hs20_icon, sizeof(hs20_icon), |
| 4228 | "128:61:zxx:image/png:icon_orange_zxx.png:/etc/ath/%s", |
| 4229 | hs20_icon_filename); |
| 4230 | osu_icon = "icon_orange_zxx.png"; |
| 4231 | break; |
| 4232 | case 5: |
| 4233 | case 105: |
| 4234 | fprintf(f, "osu_friendly_name=eng:SP Orange Test Only\n"); |
| 4235 | fprintf(f, "osu_service_desc=eng:Free service for test purpose\n"); |
| 4236 | osu_friendly_name = "kor:SP 오렌지 테스트 전용"; |
| 4237 | hs20_icon_filename = "icon_orange_zxx.png"; |
| 4238 | if (dut->ap_osu_icon_tag == 2) |
| 4239 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 4240 | snprintf(hs20_icon, sizeof(hs20_icon), |
| 4241 | "128:61:zxx:image/png:icon_orange_zxx.png:/etc/ath/%s", |
| 4242 | hs20_icon_filename); |
| 4243 | osu_icon = "icon_orange_zxx.png"; |
| 4244 | break; |
| 4245 | case 6: |
| 4246 | case 106: |
| 4247 | fprintf(f, "osu_friendly_name=eng:SP Green Test Only\n"); |
| 4248 | fprintf(f, "osu_friendly_name=kor:SP 초록 테스트 전용\n"); |
| 4249 | hs20_icon_filename = "icon_green_zxx.png"; |
| 4250 | if (dut->ap_osu_icon_tag == 2) |
| 4251 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 4252 | fprintf(f, "hs20_icon=128:61:zxx:image/png:icon_green_zxx.png:/etc/ath/%s\n", |
| 4253 | hs20_icon_filename); |
| 4254 | fprintf(f, "osu_icon=icon_green_zxx.png\n"); |
| 4255 | osu_method = (dut->ap_osu_method[0] == 0xFF) ? 0 : dut->ap_osu_method[0]; |
| 4256 | fprintf(f, "osu_method_list=%d\n", osu_method); |
| 4257 | |
| 4258 | if (strlen(dut->ap_osu_server_uri[1])) |
| 4259 | fprintf(f, "osu_server_uri=%s\n", dut->ap_osu_server_uri[1]); |
| 4260 | else |
| 4261 | fprintf(f, "osu_server_uri=https://osu-server.r2-testbed.wi-fi.org/\n"); |
| 4262 | fprintf(f, "osu_friendly_name=eng:SP Orange Test Only\n"); |
| 4263 | hs20_icon_filename = "icon_orange_zxx.png"; |
| 4264 | if (dut->ap_osu_icon_tag == 2) |
| 4265 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 4266 | snprintf(hs20_icon, sizeof(hs20_icon), |
| 4267 | "128:61:zxx:image/png:icon_orange_zxx.png:/etc/ath/%s", |
| 4268 | hs20_icon_filename); |
| 4269 | osu_icon = "icon_orange_zxx.png"; |
| 4270 | osu_friendly_name = "kor:SP 오렌지 테스트 전용"; |
| 4271 | osu_method = (dut->ap_osu_method[1] == 0xFF) ? 0 : dut->ap_osu_method[1]; |
| 4272 | osu_service_desc = NULL; |
| 4273 | break; |
| 4274 | case 7: |
| 4275 | case 107: |
| 4276 | fprintf(f, "osu_friendly_name=eng:SP Green Test Only\n"); |
| 4277 | fprintf(f, "osu_service_desc=eng:Free service for test purpose\n"); |
| 4278 | hs20_icon_filename = "icon_green_eng.png"; |
| 4279 | if (dut->ap_osu_icon_tag == 2) |
| 4280 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 4281 | fprintf(f, "hs20_icon=160:76:eng:image/png:icon_green_eng.png:/etc/ath/%s\n", |
| 4282 | hs20_icon_filename); |
| 4283 | fprintf(f, "osu_icon=icon_green_eng.png\n"); |
| 4284 | osu_friendly_name = "kor:SP 초록 테스트 전용"; |
| 4285 | |
| 4286 | hs20_icon_filename = "icon_green_zxx.png"; |
| 4287 | if (dut->ap_osu_icon_tag == 2) |
| 4288 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 4289 | snprintf(hs20_icon, sizeof(hs20_icon), |
| 4290 | "128:61:zxx:image/png:icon_green_zxx.png:/etc/ath/%s", |
| 4291 | hs20_icon_filename); |
| 4292 | osu_icon = "icon_green_zxx.png"; |
| 4293 | break; |
| 4294 | case 8: |
| 4295 | case 108: |
| 4296 | fprintf(f, "osu_friendly_name=eng:SP Red Test Only\n"); |
| 4297 | fprintf(f, "osu_service_desc=eng:Free service for test purpose\n"); |
| 4298 | osu_ssid = "OSU-Encrypted"; |
| 4299 | osu_nai = "anonymous@hotspot.net"; |
| 4300 | break; |
| 4301 | case 9: |
| 4302 | case 109: |
| 4303 | osu_ssid = "OSU-OSEN"; |
| 4304 | osu_nai = "test-anonymous@wi-fi.org"; |
| 4305 | osu_friendly_name = "eng:SP Orange Test Only"; |
| 4306 | hs20_icon_filename = "icon_orange_zxx.png"; |
| 4307 | if (dut->ap_osu_icon_tag == 2) |
| 4308 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 4309 | snprintf(hs20_icon, sizeof(hs20_icon), |
| 4310 | "128:61:zxx:image/png:icon_orange_zxx.png:/etc/ath/%s", |
| 4311 | hs20_icon_filename); |
| 4312 | osu_icon = "icon_orange_zxx.png"; |
| 4313 | osu_method = (dut->ap_osu_method[0] == 0xFF) ? 1 : dut->ap_osu_method[0]; |
| 4314 | osu_service_desc = NULL; |
| 4315 | break; |
| 4316 | default: |
| 4317 | break; |
| 4318 | } |
| 4319 | |
| 4320 | if (strlen(dut->ap_osu_ssid)) { |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 4321 | if (strcmp(dut->ap_tag_ssid[0], dut->ap_osu_ssid) && |
| 4322 | strcmp(dut->ap_tag_ssid[0], osu_ssid)) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4323 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4324 | "OSU_SSID and " |
| 4325 | "WLAN_TAG2 SSID differ"); |
| 4326 | return -2; |
| 4327 | } |
| 4328 | fprintf(f, "osu_ssid=\"%s\"\n", dut->ap_osu_ssid); |
| 4329 | } else |
| 4330 | fprintf(f, "osu_ssid=\"%s\"\n", osu_ssid); |
| 4331 | |
| 4332 | |
| 4333 | if (osu_friendly_name) |
| 4334 | fprintf(f, "osu_friendly_name=%s\n", osu_friendly_name); |
| 4335 | |
| 4336 | if (osu_service_desc) |
| 4337 | fprintf(f, "osu_service_desc=%s\n", osu_service_desc); |
| 4338 | |
| 4339 | if (osu_nai) |
| 4340 | fprintf(f, "osu_nai=%s\n", osu_nai); |
| 4341 | |
| 4342 | fprintf(f, "hs20_icon=%s\n", hs20_icon); |
| 4343 | |
| 4344 | if (osu_icon) |
| 4345 | fprintf(f, "osu_icon=%s\n", osu_icon); |
| 4346 | |
| 4347 | if (dut->ap_osu_provider_list > 100) |
| 4348 | fprintf(f, "osu_method_list=0\n"); |
| 4349 | else |
| 4350 | fprintf(f, "osu_method_list=%d\n", osu_method); |
| 4351 | } |
| 4352 | |
Jouni Malinen | 54a89b0 | 2018-05-01 00:16:26 +0300 | [diff] [blame] | 4353 | switch (dut->ap_venue_url) { |
| 4354 | case 1: |
| 4355 | fprintf(f, |
| 4356 | "venue_url=1:https://venue-server.r2m-testbed.wi-fi.org/floorplans/index.html\n" |
| 4357 | "venue_url=1:https://venue-server.r2m-testbed.wi-fi.org/directory/index.html\n"); |
| 4358 | break; |
| 4359 | case 2: |
| 4360 | fprintf(f, |
| 4361 | "venue_url=1:https://the-great-mall.r2m-testbed.wi-fi.org/floorplans/index.html\n" |
| 4362 | "venue_url=2:https://abercrombie.r2m-testbed.wi-fi.org/floorplans/index.html\n" |
| 4363 | "venue_url=3:https://adidas.r2m-testbed.wi-fi.org/floorplans/index.html\n" |
| 4364 | "venue_url=4:https://aeropostale.r2m-testbed.wi-fi.org/floorplans/index.html\n" |
| 4365 | "venue_url=5:https://agaci.r2m-testbed.wi-fi.org/floorplans/index.html\n" |
| 4366 | "venue_url=6:https://aldo-shoes.r2m-testbed.wi-fi.org/floorplans/index.html\n" |
| 4367 | "venue_url=7:https://american-eagle-outfitters.r2m-testbed.wi-fi.org/floorplans/index.html\n" |
| 4368 | "venue_url=8:https://anderson-bakery.r2m-testbed.wi-fi.org/floorplans/index.html\n" |
| 4369 | "venue_url=9:https://banana-republic-factory-store.r2m-testbed.wi-fi.org/floorplans/index.html\n" |
| 4370 | "venue_url=10:https://bed-bath-and-beyond.r2m-testbed.wi-fi.org/floorplans/index.html\n" |
| 4371 | ); |
| 4372 | break; |
| 4373 | } |
| 4374 | |
Jouni Malinen | f7ff42b | 2018-05-01 00:21:56 +0300 | [diff] [blame] | 4375 | switch (dut->ap_advice_of_charge) { |
| 4376 | case 1: |
| 4377 | fprintf(f, "anqp_elem=278:" ADV_OF_CHARGE_1 "\n"); |
| 4378 | break; |
| 4379 | } |
| 4380 | |
Jouni Malinen | ac10453 | 2018-05-01 00:27:37 +0300 | [diff] [blame] | 4381 | switch (dut->ap_oper_icon_metadata) { |
| 4382 | case 1: |
| 4383 | fprintf(f, |
| 4384 | "hs20_icon=160:76:eng:image/png:icon_red_eng.png:/etc/ath/icon_red_eng.png\n" |
| 4385 | "operator_icon=icon_red_eng.png\n"); |
| 4386 | break; |
| 4387 | } |
| 4388 | |
Jouni Malinen | ac36714 | 2018-05-01 00:32:24 +0300 | [diff] [blame] | 4389 | switch (dut->ap_tnc_file_name) { |
| 4390 | case 1: |
| 4391 | fprintf(f, "hs20_t_c_filename=tandc-id1-content.txt\n"); |
| 4392 | break; |
| 4393 | } |
| 4394 | |
| 4395 | if (dut->ap_tnc_time_stamp) |
| 4396 | fprintf(f, "hs20_t_c_timestamp=%u\n", dut->ap_tnc_time_stamp); |
| 4397 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4398 | return 0; |
| 4399 | } |
| 4400 | |
| 4401 | |
| 4402 | static void write_ap_roaming_cons(FILE *f, const char *list) |
| 4403 | { |
| 4404 | char *buf, *pos, *end; |
| 4405 | |
| 4406 | if (list == NULL || list[0] == '\0') |
| 4407 | return; |
| 4408 | |
| 4409 | buf = strdup(list); |
| 4410 | if (buf == NULL) |
| 4411 | return; |
| 4412 | |
| 4413 | pos = buf; |
| 4414 | while (pos && *pos) { |
| 4415 | end = strchr(pos, ';'); |
| 4416 | if (end) |
| 4417 | *end++ = '\0'; |
| 4418 | fprintf(f, "roaming_consortium=%s\n", pos); |
| 4419 | pos = end; |
| 4420 | } |
| 4421 | |
| 4422 | free(buf); |
| 4423 | } |
| 4424 | |
| 4425 | |
| 4426 | static int append_hostapd_conf_interworking(struct sigma_dut *dut, FILE *f) |
| 4427 | { |
| 4428 | int i; |
| 4429 | char buf[100], *temp; |
| 4430 | |
| 4431 | if (dut->ap_gas_cb_delay > 0) |
| 4432 | fprintf(f, "gas_comeback_delay=%d\n", |
| 4433 | dut->ap_gas_cb_delay); |
| 4434 | |
| 4435 | fprintf(f, "interworking=1\n" |
| 4436 | "access_network_type=%d\n" |
| 4437 | "internet=%d\n" |
| 4438 | "asra=0\n" |
| 4439 | "esr=0\n" |
| 4440 | "uesa=0\n" |
| 4441 | "venue_group=%d\n" |
| 4442 | "venue_type=%d\n", |
| 4443 | dut->ap_access_net_type, |
| 4444 | dut->ap_internet, |
| 4445 | dut->ap_venue_group, |
| 4446 | dut->ap_venue_type); |
| 4447 | if (dut->ap_hessid[0]) |
| 4448 | fprintf(f, "hessid=%s\n", dut->ap_hessid); |
| 4449 | |
| 4450 | write_ap_roaming_cons(f, dut->ap_roaming_cons); |
| 4451 | |
| 4452 | if (dut->ap_venue_name) { |
| 4453 | fprintf(f, "venue_name=P\"eng:Wi-Fi Alliance\\n2989 Copper Road\\nSanta Clara, CA 95051, USA\"\n"); |
| 4454 | fprintf(f, "venue_name=%s\n", ANQP_VENUE_NAME_1_CHI); |
| 4455 | } |
| 4456 | |
| 4457 | if (dut->ap_net_auth_type == 1) |
| 4458 | fprintf(f, "network_auth_type=00https://tandc-server.wi-fi.org\n"); |
| 4459 | else if (dut->ap_net_auth_type == 2) |
| 4460 | fprintf(f, "network_auth_type=01\n"); |
| 4461 | |
| 4462 | if (dut->ap_nai_realm_list == 1) { |
| 4463 | fprintf(f, "nai_realm=0,mail.example.com;cisco.com;wi-fi.org,21[2:4][5:7]\n"); |
| 4464 | fprintf(f, "nai_realm=0,wi-fi.org;example.com,13[5:6]\n"); |
| 4465 | } else if (dut->ap_nai_realm_list == 2) { |
| 4466 | fprintf(f, "nai_realm=0,wi-fi.org,21[2:4][5:7]\n"); |
| 4467 | } else if (dut->ap_nai_realm_list == 3) { |
| 4468 | fprintf(f, "nai_realm=0,cisco.com;wi-fi.org,21[2:4][5:7]\n"); |
| 4469 | fprintf(f, "nai_realm=0,wi-fi.org;example.com,13[5:6]\n"); |
| 4470 | } else if (dut->ap_nai_realm_list == 4) { |
| 4471 | fprintf(f, "nai_realm=0,mail.example.com,21[2:4][5:7],13[5:6]\n"); |
| 4472 | } else if (dut->ap_nai_realm_list == 5) { |
| 4473 | fprintf(f, "nai_realm=0,wi-fi.org;ruckuswireless.com,21[2:4][5:7]\n"); |
| 4474 | } else if (dut->ap_nai_realm_list == 6) { |
| 4475 | fprintf(f, "nai_realm=0,wi-fi.org;mail.example.com,21[2:4][5:7]\n"); |
| 4476 | } else if (dut->ap_nai_realm_list == 7) { |
| 4477 | fprintf(f, "nai_realm=0,wi-fi.org,13[5:6]\n"); |
| 4478 | fprintf(f, "nai_realm=0,wi-fi.org,21[2:4][5:7]\n"); |
| 4479 | } |
| 4480 | |
| 4481 | if (dut->ap_domain_name_list[0]) { |
| 4482 | fprintf(f, "domain_name=%s\n", |
| 4483 | dut->ap_domain_name_list); |
| 4484 | } |
| 4485 | |
| 4486 | if (dut->ap_ip_addr_type_avail == 1) { |
| 4487 | fprintf(f, "ipaddr_type_availability=0c\n"); |
| 4488 | } |
| 4489 | |
| 4490 | temp = buf; |
| 4491 | for (i = 0; dut->ap_plmn_mcc[i][0] && dut->ap_plmn_mnc[i][0]; |
| 4492 | i++) { |
| 4493 | if (i) |
| 4494 | *temp++ = ';'; |
| 4495 | |
| 4496 | snprintf(temp, |
| 4497 | sizeof(dut->ap_plmn_mcc[i]) + |
| 4498 | sizeof(dut->ap_plmn_mnc[i]) + 1, |
| 4499 | "%s,%s", |
| 4500 | dut->ap_plmn_mcc[i], |
| 4501 | dut->ap_plmn_mnc[i]); |
| 4502 | |
| 4503 | temp += strlen(dut->ap_plmn_mcc[i]) + |
| 4504 | strlen(dut->ap_plmn_mnc[i]) + 1; |
| 4505 | } |
| 4506 | if (i) |
| 4507 | fprintf(f, "anqp_3gpp_cell_net=%s\n", buf); |
| 4508 | |
| 4509 | if (dut->ap_qos_map_set == 1) |
| 4510 | fprintf(f, "qos_map_set=%s\n", QOS_MAP_SET_1); |
| 4511 | else if (dut->ap_qos_map_set == 2) |
| 4512 | fprintf(f, "qos_map_set=%s\n", QOS_MAP_SET_2); |
| 4513 | |
| 4514 | return 0; |
| 4515 | } |
| 4516 | |
| 4517 | |
| 4518 | static int ath_ap_append_hostapd_conf(struct sigma_dut *dut) |
| 4519 | { |
| 4520 | FILE *f; |
| 4521 | |
| 4522 | if (kill_process(dut, "(hostapd)", 1, SIGTERM) == 0 || |
| 4523 | system("killall hostapd") == 0) { |
| 4524 | int i; |
| 4525 | |
| 4526 | /* Wait some time to allow hostapd to complete cleanup before |
| 4527 | * starting a new process */ |
| 4528 | for (i = 0; i < 10; i++) { |
| 4529 | usleep(500000); |
| 4530 | if (system("pidof hostapd") != 0) |
| 4531 | break; |
| 4532 | } |
| 4533 | } |
| 4534 | |
| 4535 | f = fopen("/tmp/secath0", "a"); |
| 4536 | if (f == NULL) |
| 4537 | return -2; |
| 4538 | |
| 4539 | if (dut->ap_hs2 && append_hostapd_conf_hs2(dut, f)) { |
| 4540 | fclose(f); |
| 4541 | return -2; |
| 4542 | } |
| 4543 | |
| 4544 | if (dut->ap_interworking && append_hostapd_conf_interworking(dut, f)) { |
| 4545 | fclose(f); |
| 4546 | return -2; |
| 4547 | } |
| 4548 | |
| 4549 | fflush(f); |
| 4550 | fclose(f); |
| 4551 | return ath_ap_start_hostapd(dut); |
| 4552 | } |
| 4553 | |
| 4554 | |
| 4555 | static int ath_ap_start_hostapd(struct sigma_dut *dut) |
| 4556 | { |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 4557 | if (dut->ap_tag_key_mgmt[0] == AP2_OSEN) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4558 | run_system(dut, "hostapd -B /tmp/secath0 /tmp/secath1 -e /etc/wpa2/entropy"); |
| 4559 | else |
| 4560 | run_system(dut, "hostapd -B /tmp/secath0 -e /etc/wpa2/entropy"); |
| 4561 | |
| 4562 | return 0; |
| 4563 | } |
| 4564 | |
| 4565 | |
| 4566 | #define LE16(a) ((((a) & 0xff) << 8) | (((a) >> 8) & 0xff)) |
| 4567 | |
| 4568 | static int cmd_ath_ap_anqpserver_start(struct sigma_dut *dut) |
| 4569 | { |
| 4570 | FILE *f; |
| 4571 | int nai_realm = 0, domain_name = 0, oper_name = 0, venue_name = 0, |
| 4572 | wan_metrics = 0, conn_cap = 0, ipaddr_avail = 0, cell_net = 0; |
| 4573 | char buf[100]; |
| 4574 | int i; |
| 4575 | |
| 4576 | f = fopen("/root/anqpserver.conf", "w"); |
| 4577 | if (f == NULL) |
| 4578 | return -1; |
| 4579 | |
| 4580 | if (dut->ap_nai_realm_list == 1) { |
| 4581 | nai_realm = 1; |
| 4582 | 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"); |
| 4583 | } else if (dut->ap_nai_realm_list == 2) { |
| 4584 | nai_realm = 1; |
| 4585 | fprintf(f, "dyn_nai_home_realm=encoding=00realm=wi-fi.org;eap_method=0Dauth_id=05auth_val=06\n"); |
| 4586 | } else if (dut->ap_nai_realm_list == 3) { |
| 4587 | nai_realm = 1; |
| 4588 | 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"); |
| 4589 | } else if (dut->ap_nai_realm_list == 4) { |
| 4590 | nai_realm = 1; |
| 4591 | 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"); |
| 4592 | } else |
| 4593 | sigma_dut_print(dut, DUT_MSG_INFO, "not setting nai_realm"); |
| 4594 | |
| 4595 | if (dut->ap_domain_name_list[0]) { |
| 4596 | char *next, *start, *dnbuf, *dn1, *anqp_dn; |
| 4597 | int len, dn_len_max; |
| 4598 | dnbuf = strdup(dut->ap_domain_name_list); |
Pradeep Reddy POTTETI | 673d85c | 2016-07-26 19:08:07 +0530 | [diff] [blame] | 4599 | if (dnbuf == NULL) { |
| 4600 | fclose(f); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4601 | return 0; |
Pradeep Reddy POTTETI | 673d85c | 2016-07-26 19:08:07 +0530 | [diff] [blame] | 4602 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4603 | |
| 4604 | len = strlen(dnbuf); |
| 4605 | dn_len_max = 50 + len*2; |
| 4606 | anqp_dn = malloc(dn_len_max); |
| 4607 | if (anqp_dn == NULL) { |
| 4608 | free(dnbuf); |
Pradeep Reddy POTTETI | 673d85c | 2016-07-26 19:08:07 +0530 | [diff] [blame] | 4609 | fclose(f); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4610 | return -1; |
| 4611 | } |
| 4612 | start = dnbuf; |
| 4613 | dn1 = anqp_dn; |
| 4614 | while (start && *start) { |
| 4615 | char *hexstr; |
| 4616 | |
| 4617 | next = strchr(start, ','); |
| 4618 | if (next) |
| 4619 | *next++ = '\0'; |
| 4620 | |
| 4621 | len = strlen(start); |
vamsi krishna | 2e88130 | 2016-05-25 15:02:39 +0530 | [diff] [blame] | 4622 | hexstr = malloc(len * 2 + 1); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4623 | if (hexstr == NULL) { |
| 4624 | free(dnbuf); |
| 4625 | free(anqp_dn); |
Pradeep Reddy POTTETI | 673d85c | 2016-07-26 19:08:07 +0530 | [diff] [blame] | 4626 | fclose(f); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4627 | return -1; |
| 4628 | } |
| 4629 | ascii2hexstr(start, hexstr); |
| 4630 | snprintf(dn1, dn_len_max, "%02x%s", len, hexstr); |
| 4631 | free(hexstr); |
| 4632 | dn1 += 2 + len * 2; |
| 4633 | dn_len_max -= 2 + len * 2; |
| 4634 | start = next; |
| 4635 | } |
| 4636 | free(dnbuf); |
| 4637 | if (dut->ap_gas_cb_delay) { |
| 4638 | fprintf(f, "dyn_domain_name=0c01%04x%s", |
| 4639 | LE16((unsigned int) strlen(anqp_dn)), anqp_dn); |
| 4640 | domain_name = 1; |
| 4641 | } else |
| 4642 | fprintf(f, "domain_name=0c01%04x%s", |
| 4643 | LE16((unsigned int) strlen(anqp_dn)), anqp_dn); |
| 4644 | free(anqp_dn); |
| 4645 | } else |
| 4646 | sigma_dut_print(dut, DUT_MSG_INFO, "not setting domain_name"); |
| 4647 | |
| 4648 | sigma_dut_print(dut, DUT_MSG_INFO, "not setting roaming_consortium"); |
| 4649 | |
| 4650 | if (dut->ap_oper_name) { |
| 4651 | if (dut->ap_gas_cb_delay) { |
| 4652 | fprintf(f, "dyn_oper_friendly_name=" |
| 4653 | ANQP_HS20_OPERATOR_FRIENDLY_NAME_1 "\n"); |
| 4654 | oper_name = 1; |
| 4655 | } else |
| 4656 | fprintf(f, "oper_friendly_name=" |
| 4657 | ANQP_HS20_OPERATOR_FRIENDLY_NAME_1 "\n"); |
| 4658 | } else |
| 4659 | sigma_dut_print(dut, DUT_MSG_INFO, "not setting oper_name"); |
| 4660 | |
| 4661 | if (dut->ap_venue_name) { |
| 4662 | if (dut->ap_gas_cb_delay) { |
| 4663 | fprintf(f, "dyn_venue_name=" ANQP_VENUE_NAME_1 "\n"); |
| 4664 | venue_name = 1; |
| 4665 | } else |
| 4666 | fprintf(f, "venue_name=" ANQP_VENUE_NAME_1 "\n"); |
| 4667 | } else |
| 4668 | sigma_dut_print(dut, DUT_MSG_ERROR, "not setting venue_name"); |
| 4669 | |
| 4670 | if (dut->ap_wan_metrics) { |
| 4671 | if (dut->ap_gas_cb_delay) { |
| 4672 | fprintf(f, "dyn_wan_metrics=" ANQP_HS20_WAN_METRICS_1 "\n"); |
| 4673 | wan_metrics = 1; |
| 4674 | } else |
| 4675 | fprintf(f, "wan_metrics=" ANQP_HS20_WAN_METRICS_1 |
| 4676 | "\n"); |
| 4677 | } else |
| 4678 | sigma_dut_print(dut, DUT_MSG_ERROR, "not setting wan_metrics"); |
| 4679 | |
| 4680 | if (dut->ap_conn_capab) { |
| 4681 | if (dut->ap_gas_cb_delay) { |
| 4682 | fprintf(f, "dyn_conn_capability=" |
| 4683 | ANQP_HS20_CONNECTION_CAPABILITY_1 "\n"); |
| 4684 | conn_cap = 1; |
| 4685 | } else |
| 4686 | fprintf(f, "conn_capability=" |
| 4687 | ANQP_HS20_CONNECTION_CAPABILITY_1 "\n"); |
| 4688 | } else |
| 4689 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4690 | "not setting conn_capability"); |
| 4691 | |
| 4692 | if (dut->ap_ip_addr_type_avail) { |
| 4693 | if (dut->ap_gas_cb_delay) { |
| 4694 | fprintf(f, "dyn_ipaddr_type=" ANQP_IP_ADDR_TYPE_1 |
| 4695 | "\n"); |
| 4696 | ipaddr_avail = 1; |
| 4697 | } else |
| 4698 | fprintf(f, "ipaddr_type=" ANQP_IP_ADDR_TYPE_1 "\n"); |
| 4699 | } else |
| 4700 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4701 | "not setting ipaddr_type_avail"); |
| 4702 | |
| 4703 | for (i = 0; dut->ap_plmn_mcc[i][0] && dut->ap_plmn_mnc[i][0]; i++) { |
| 4704 | snprintf(buf + i * 6, sizeof(buf) - i * 6, "%c%c%c%c%c%c", |
| 4705 | dut->ap_plmn_mcc[i][1], |
| 4706 | dut->ap_plmn_mcc[i][0], |
| 4707 | dut->ap_plmn_mnc[i][2] == '\0' ? |
| 4708 | 'f' : dut->ap_plmn_mnc[i][2], |
| 4709 | dut->ap_plmn_mcc[i][2], |
| 4710 | dut->ap_plmn_mnc[i][1], |
| 4711 | dut->ap_plmn_mnc[i][0]); |
| 4712 | } |
| 4713 | if (i) { |
| 4714 | uint16_t ie_len = (i * 3) + 5; |
| 4715 | if (dut->ap_gas_cb_delay) { |
| 4716 | fprintf(f, "dyn_cell_net=0801"); |
| 4717 | cell_net = 1; |
| 4718 | } else |
| 4719 | fprintf(f, "cell_net=0801"); |
| 4720 | fprintf(f, "%04x", LE16(ie_len)); |
| 4721 | fprintf(f, "00"); /* version */ |
| 4722 | fprintf(f, "%02x", (i * 3) + 3); /* user data hdr length */ |
| 4723 | fprintf(f, "00"); /* plmn list */ |
| 4724 | fprintf(f, "%02x", (i * 3) + 1); /* length of plmn list */ |
| 4725 | fprintf(f, "%02x", i); /* number of plmns */ |
| 4726 | fprintf(f, "%s\n", buf); /* plmns */ |
| 4727 | } else |
| 4728 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4729 | "not setting 3gpp_cellular_network"); |
| 4730 | |
| 4731 | if (nai_realm || domain_name || oper_name || venue_name || |
| 4732 | wan_metrics || conn_cap || ipaddr_avail || cell_net) { |
| 4733 | fprintf(f, "anqp_attach="); |
| 4734 | if (venue_name) |
| 4735 | fprintf(f, "00000104%4.4x", dut->ap_gas_cb_delay); |
| 4736 | if (nai_realm) |
| 4737 | fprintf(f, "00000107%4.4x", dut->ap_gas_cb_delay); |
| 4738 | if (cell_net) |
| 4739 | fprintf(f, "00000108%4.4x", dut->ap_gas_cb_delay); |
| 4740 | if (domain_name) |
| 4741 | fprintf(f, "0000010c%4.4x", dut->ap_gas_cb_delay); |
| 4742 | if (oper_name) |
| 4743 | fprintf(f, "00010003%4.4x", dut->ap_gas_cb_delay); |
| 4744 | if (wan_metrics) |
| 4745 | fprintf(f, "00010004%4.4x", dut->ap_gas_cb_delay); |
| 4746 | if (conn_cap) |
| 4747 | fprintf(f, "00010005%4.4x", dut->ap_gas_cb_delay); |
| 4748 | fprintf(f, "00010006%4.4x", dut->ap_gas_cb_delay); |
| 4749 | fprintf(f, "\n"); |
| 4750 | } |
| 4751 | |
| 4752 | fclose(f); |
| 4753 | |
| 4754 | run_system(dut, "anqpserver -i ath0 &"); |
| 4755 | if (!dut->ap_anqpserver_on) |
| 4756 | run_system(dut, "killall anqpserver"); |
| 4757 | |
| 4758 | return 1; |
| 4759 | } |
| 4760 | |
| 4761 | |
| 4762 | static void cmd_ath_ap_radio_config(struct sigma_dut *dut) |
| 4763 | { |
| 4764 | char buf[100]; |
| 4765 | |
| 4766 | run_system(dut, "cfg -a AP_STARTMODE=standard"); |
| 4767 | |
| 4768 | if (sigma_radio_ifname[0] && |
| 4769 | strcmp(sigma_radio_ifname[0], "wifi1") == 0) { |
| 4770 | run_system(dut, "cfg -a AP_RADIO_ID=1"); |
| 4771 | switch (dut->ap_mode) { |
| 4772 | case AP_11g: |
| 4773 | run_system(dut, "cfg -a AP_CHMODE_2=11G"); |
| 4774 | break; |
| 4775 | case AP_11b: |
| 4776 | run_system(dut, "cfg -a AP_CHMODE_2=11B"); |
| 4777 | break; |
| 4778 | case AP_11ng: |
| 4779 | run_system(dut, "cfg -a AP_CHMODE_2=11NGHT20"); |
| 4780 | break; |
| 4781 | case AP_11a: |
| 4782 | run_system(dut, "cfg -a AP_CHMODE_2=11A"); |
| 4783 | break; |
| 4784 | case AP_11na: |
| 4785 | run_system(dut, "cfg -a AP_CHMODE_2=11NAHT20"); |
| 4786 | break; |
| 4787 | case AP_11ac: |
| 4788 | run_system(dut, "cfg -a AP_CHMODE_2=11ACVHT80"); |
| 4789 | break; |
| 4790 | default: |
| 4791 | run_system(dut, "cfg -a AP_CHMODE_2=11ACVHT80"); |
| 4792 | break; |
| 4793 | } |
| 4794 | |
| 4795 | switch (dut->ap_rx_streams) { |
| 4796 | case 1: |
| 4797 | run_system(dut, "cfg -a RX_CHAINMASK_2=1"); |
| 4798 | break; |
| 4799 | case 2: |
| 4800 | run_system(dut, "cfg -a RX_CHAINMASK_2=3"); |
| 4801 | break; |
| 4802 | case 3: |
| 4803 | run_system(dut, "cfg -a RX_CHAINMASK_2=7"); |
| 4804 | break; |
| 4805 | } |
| 4806 | |
| 4807 | switch (dut->ap_tx_streams) { |
| 4808 | case 1: |
| 4809 | run_system(dut, "cfg -a TX_CHAINMASK_2=1"); |
| 4810 | break; |
| 4811 | case 2: |
| 4812 | run_system(dut, "cfg -a TX_CHAINMASK_2=3"); |
| 4813 | break; |
| 4814 | case 3: |
| 4815 | run_system(dut, "cfg -a TX_CHAINMASK_2=7"); |
| 4816 | break; |
| 4817 | } |
| 4818 | |
| 4819 | switch (dut->ap_chwidth) { |
| 4820 | case AP_20: |
| 4821 | run_system(dut, "cfg -a AP_CHMODE_2=11ACVHT20"); |
| 4822 | break; |
| 4823 | case AP_40: |
| 4824 | run_system(dut, "cfg -a AP_CHMODE_2=11ACVHT40"); |
| 4825 | break; |
| 4826 | case AP_80: |
| 4827 | run_system(dut, "cfg -a AP_CHMODE_2=11ACVHT80"); |
| 4828 | break; |
| 4829 | case AP_160: |
| 4830 | case AP_AUTO: |
| 4831 | default: |
| 4832 | run_system(dut, "cfg -a AP_CHMODE_2=11ACVHT80"); |
| 4833 | break; |
| 4834 | } |
| 4835 | |
| 4836 | if (dut->ap_tx_stbc) { |
| 4837 | run_system(dut, "cfg -a TX_STBC_2=1"); |
| 4838 | } |
| 4839 | |
| 4840 | snprintf(buf, sizeof(buf), "cfg -a AP_PRIMARY_CH_2=%d", |
| 4841 | dut->ap_channel); |
| 4842 | |
| 4843 | if (dut->ap_is_dual) { |
| 4844 | switch (dut->ap_mode_1) { |
| 4845 | case AP_11g: |
| 4846 | run_system(dut, "cfg -a AP_CHMODE=11G"); |
| 4847 | break; |
| 4848 | case AP_11b: |
| 4849 | run_system(dut, "cfg -a AP_CHMODE=11B"); |
| 4850 | break; |
| 4851 | case AP_11ng: |
| 4852 | run_system(dut, "cfg -a AP_CHMODE=11NGHT20"); |
| 4853 | break; |
| 4854 | case AP_11a: |
| 4855 | run_system(dut, "cfg -a AP_CHMODE=11A"); |
| 4856 | break; |
| 4857 | case AP_11na: |
| 4858 | run_system(dut, "cfg -a AP_CHMODE=11NAHT20"); |
| 4859 | break; |
| 4860 | case AP_11ac: |
| 4861 | run_system(dut, "cfg -a AP_CHMODE=11ACVHT80"); |
| 4862 | break; |
| 4863 | default: |
| 4864 | run_system(dut, "cfg -a AP_CHMODE=11NGHT20"); |
| 4865 | break; |
| 4866 | } |
| 4867 | snprintf(buf, sizeof(buf), "cfg -a AP_PRIMARY_CH=%d", |
| 4868 | dut->ap_channel_1); |
| 4869 | } |
| 4870 | run_system(dut, buf); |
| 4871 | } else { |
| 4872 | run_system(dut, "cfg -a AP_RADIO_ID=0"); |
| 4873 | switch (dut->ap_mode) { |
| 4874 | case AP_11g: |
| 4875 | run_system(dut, "cfg -a AP_CHMODE=11G"); |
| 4876 | break; |
| 4877 | case AP_11b: |
| 4878 | run_system(dut, "cfg -a AP_CHMODE=11B"); |
| 4879 | break; |
| 4880 | case AP_11ng: |
| 4881 | run_system(dut, "cfg -a AP_CHMODE=11NGHT20"); |
| 4882 | break; |
| 4883 | case AP_11a: |
| 4884 | run_system(dut, "cfg -a AP_CHMODE=11A"); |
| 4885 | break; |
| 4886 | case AP_11na: |
| 4887 | run_system(dut, "cfg -a AP_CHMODE=11NAHT20"); |
| 4888 | break; |
| 4889 | case AP_11ac: |
| 4890 | run_system(dut, "cfg -a AP_CHMODE=11ACVHT80"); |
| 4891 | break; |
| 4892 | default: |
| 4893 | run_system(dut, "cfg -a AP_CHMODE=11NGHT20"); |
| 4894 | break; |
| 4895 | } |
| 4896 | snprintf(buf, sizeof(buf), "cfg -a AP_PRIMARY_CH=%d", |
| 4897 | dut->ap_channel); |
| 4898 | run_system(dut, buf); |
| 4899 | } |
| 4900 | |
| 4901 | if (dut->ap_sgi80 == 1) { |
| 4902 | run_system(dut, "cfg -a SHORTGI=1"); |
| 4903 | run_system(dut, "cfg -a SHORTGI_2=1"); |
| 4904 | } else if (dut->ap_sgi80 == 0) { |
| 4905 | run_system(dut, "cfg -a SHORTGI=0"); |
| 4906 | run_system(dut, "cfg -a SHORTGI_2=0"); |
| 4907 | } |
| 4908 | |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 4909 | if (dut->ap_ldpc == VALUE_ENABLED) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4910 | run_system(dut, "cfg -a LDPC=1"); |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 4911 | else if (dut->ap_ldpc == VALUE_DISABLED) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4912 | run_system(dut, "cfg -a LDPC=0"); |
| 4913 | } |
| 4914 | |
| 4915 | |
| 4916 | void ath_disable_txbf(struct sigma_dut *dut, const char *intf) |
| 4917 | { |
| 4918 | char buf[50]; |
| 4919 | |
| 4920 | snprintf(buf, sizeof(buf), "iwpriv %s vhtsubfee 0", intf); |
| 4921 | if (system(buf) != 0) |
| 4922 | sigma_dut_print(dut, DUT_MSG_ERROR, "iwpriv vhtsubfee failed"); |
| 4923 | |
| 4924 | snprintf(buf, sizeof(buf), "iwpriv %s vhtsubfer 0", intf); |
| 4925 | if (system(buf) != 0) |
| 4926 | sigma_dut_print(dut, DUT_MSG_ERROR, "iwpriv vhtsubfer failed"); |
| 4927 | |
| 4928 | snprintf(buf, sizeof(buf), "iwpriv %s vhtmubfee 0", intf); |
| 4929 | if (system(buf) != 0) |
| 4930 | sigma_dut_print(dut, DUT_MSG_ERROR, "iwpriv vhtmubfee failed"); |
| 4931 | |
| 4932 | snprintf(buf, sizeof(buf), "iwpriv %s vhtmubfer 0", intf); |
| 4933 | if (system(buf) != 0) |
| 4934 | sigma_dut_print(dut, DUT_MSG_ERROR, "iwpriv vhtmubfer failed"); |
| 4935 | } |
| 4936 | |
| 4937 | |
Adil Saeed Musthafa | 05ec744 | 2017-04-10 23:13:35 -0700 | [diff] [blame] | 4938 | static void ath_set_assoc_disallow(struct sigma_dut *dut, const char *ifname, |
| 4939 | const char *val) |
| 4940 | { |
| 4941 | if (strcasecmp(val, "enable") == 0) { |
| 4942 | run_system_wrapper(dut, "iwpriv %s mbo_asoc_dis 1", ifname); |
| 4943 | } else if (strcasecmp(val, "disable") == 0) { |
| 4944 | run_system_wrapper(dut, "iwpriv %s mbo_asoc_dis 0", ifname); |
| 4945 | } else { |
| 4946 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4947 | "Unsupported assoc_disallow"); |
| 4948 | } |
| 4949 | } |
| 4950 | |
| 4951 | |
Adil Saeed Musthafa | 6906372 | 2017-04-10 23:13:40 -0700 | [diff] [blame] | 4952 | static void apply_mbo_pref_ap_list(struct sigma_dut *dut) |
| 4953 | { |
| 4954 | int i; |
| 4955 | int least_pref = 1 << 8; |
| 4956 | char ifname[20]; |
| 4957 | uint8_t self_mac[ETH_ALEN]; |
| 4958 | char buf[200]; |
| 4959 | int ap_ne_class, ap_ne_pref, ap_ne_op_ch; |
| 4960 | |
| 4961 | get_if_name(dut, ifname, sizeof(ifname), 1); |
| 4962 | get_hwaddr(ifname, self_mac); |
| 4963 | |
| 4964 | /* Clear off */ |
| 4965 | snprintf(buf, sizeof(buf), |
| 4966 | "wifitool %s setbssidpref 00:00:00:00:00:00 0 0 0", |
| 4967 | ifname); |
| 4968 | run_system(dut, buf); |
| 4969 | |
| 4970 | /* Find the least preference number */ |
| 4971 | for (i = 0; i < dut->mbo_pref_ap_cnt; i++) { |
| 4972 | unsigned char *mac_addr = dut->mbo_pref_aps[i].mac_addr; |
| 4973 | |
| 4974 | ap_ne_class = 1; |
| 4975 | ap_ne_pref = 255; |
| 4976 | ap_ne_op_ch = 1; |
| 4977 | if (dut->mbo_pref_aps[i].ap_ne_pref != -1) |
| 4978 | ap_ne_pref = dut->mbo_pref_aps[i].ap_ne_pref; |
| 4979 | if (dut->mbo_pref_aps[i].ap_ne_class != -1) |
| 4980 | ap_ne_class = dut->mbo_pref_aps[i].ap_ne_class; |
| 4981 | if (dut->mbo_pref_aps[i].ap_ne_op_ch != -1) |
| 4982 | ap_ne_op_ch = dut->mbo_pref_aps[i].ap_ne_op_ch; |
| 4983 | |
| 4984 | if (ap_ne_pref < least_pref) |
| 4985 | least_pref = ap_ne_pref; |
| 4986 | snprintf(buf, sizeof(buf), |
| 4987 | "wifitool %s setbssidpref %02x:%02x:%02x:%02x:%02x:%02x %d %d %d", |
| 4988 | ifname, mac_addr[0], mac_addr[1], mac_addr[2], |
| 4989 | mac_addr[3], mac_addr[4], mac_addr[5], |
| 4990 | ap_ne_pref, ap_ne_class, ap_ne_op_ch); |
| 4991 | run_system(dut, buf); |
| 4992 | } |
| 4993 | |
| 4994 | /* Now add the self AP Address */ |
| 4995 | if (dut->mbo_self_ap_tuple.ap_ne_class == -1) { |
| 4996 | if (dut->ap_channel <= 11) |
| 4997 | ap_ne_class = 81; |
| 4998 | else |
| 4999 | ap_ne_class = 115; |
| 5000 | } else { |
| 5001 | ap_ne_class = dut->mbo_self_ap_tuple.ap_ne_class; |
| 5002 | } |
| 5003 | |
| 5004 | if (dut->mbo_self_ap_tuple.ap_ne_op_ch == -1) |
| 5005 | ap_ne_op_ch = dut->ap_channel; |
| 5006 | else |
| 5007 | ap_ne_op_ch = dut->mbo_self_ap_tuple.ap_ne_op_ch; |
| 5008 | |
| 5009 | if (dut->mbo_self_ap_tuple.ap_ne_pref == -1) |
| 5010 | ap_ne_pref = least_pref - 1; |
| 5011 | else |
| 5012 | ap_ne_pref = dut->mbo_self_ap_tuple.ap_ne_pref; |
| 5013 | |
| 5014 | snprintf(buf, sizeof(buf), |
| 5015 | "wifitool %s setbssidpref %02x:%02x:%02x:%02x:%02x:%02x %d %d %d", |
| 5016 | ifname, self_mac[0], self_mac[1], self_mac[2], |
| 5017 | self_mac[3], self_mac[4], self_mac[5], |
| 5018 | ap_ne_pref, |
| 5019 | ap_ne_class, |
| 5020 | ap_ne_op_ch); |
| 5021 | run_system(dut, buf); |
| 5022 | } |
| 5023 | |
| 5024 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5025 | static void ath_ap_set_params(struct sigma_dut *dut) |
| 5026 | { |
priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 5027 | const char *basedev = "wifi0"; |
| 5028 | const char *basedev_radio = "wifi1"; |
| 5029 | char *ifname = get_main_ifname(); |
| 5030 | char *ifname_dual; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5031 | int i; |
priyadharshini gowthaman | 8e26ff4 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 5032 | char buf[300]; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5033 | |
priyadharshini gowthaman | e161746 | 2017-04-25 12:03:59 -0700 | [diff] [blame] | 5034 | if (sigma_radio_ifname[0]) |
| 5035 | basedev = sigma_radio_ifname[0]; |
| 5036 | |
priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 5037 | if (dut->ap_is_dual == 1) { |
| 5038 | basedev = sigma_radio_ifname[0]; |
| 5039 | basedev_radio = sigma_radio_ifname[1]; |
| 5040 | if (sigma_radio_ifname[0] && |
| 5041 | strcmp(sigma_radio_ifname[0], "wifi0") == 0) { |
| 5042 | ifname = "ath0"; |
| 5043 | ifname_dual = "ath1"; |
| 5044 | } else { |
| 5045 | ifname = "ath1"; |
| 5046 | ifname_dual = "ath0"; |
| 5047 | } |
| 5048 | } |
| 5049 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5050 | if (dut->ap_countrycode[0]) { |
| 5051 | snprintf(buf, sizeof(buf), "iwpriv %s setCountry %s", |
| 5052 | basedev, dut->ap_countrycode); |
| 5053 | if (system(buf) != 0) { |
| 5054 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5055 | "iwpriv setCountry failed"); |
| 5056 | } |
| 5057 | sigma_dut_print(dut, DUT_MSG_INFO, "Set countrycode"); |
| 5058 | } |
| 5059 | |
| 5060 | for (i = 0; i < NUM_AP_AC; i++) { |
| 5061 | if (dut->ap_qos[i].ac) { |
| 5062 | snprintf(buf, sizeof(buf), "iwpriv %s cwmin %d 0 %d", |
| 5063 | ifname, i, dut->ap_qos[i].cwmin); |
| 5064 | if (system(buf) != 0) { |
| 5065 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5066 | "iwpriv cwmin failed"); |
| 5067 | } |
| 5068 | |
| 5069 | snprintf(buf, sizeof(buf), "iwpriv %s cwmax %d 0 %d", |
| 5070 | ifname, i, dut->ap_qos[i].cwmax); |
| 5071 | if (system(buf) != 0) { |
| 5072 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5073 | "iwpriv cwmax failed"); |
| 5074 | } |
| 5075 | |
| 5076 | snprintf(buf, sizeof(buf), "iwpriv %s aifs %d 0 %d", |
| 5077 | ifname, i, dut->ap_qos[i].aifs); |
| 5078 | if (system(buf) != 0) { |
| 5079 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5080 | "iwpriv aifs failed"); |
| 5081 | } |
| 5082 | |
| 5083 | snprintf(buf, sizeof(buf), |
| 5084 | "iwpriv %s txoplimit %d 0 %d", |
| 5085 | ifname, i, dut->ap_qos[i].txop); |
| 5086 | if (system(buf) != 0) { |
| 5087 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5088 | "iwpriv txoplimit failed"); |
| 5089 | } |
| 5090 | |
| 5091 | snprintf(buf, sizeof(buf), "iwpriv %s acm %d 0 %d", |
| 5092 | ifname, i, dut->ap_qos[i].acm); |
| 5093 | if (system(buf) != 0) { |
| 5094 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5095 | "iwpriv acm failed"); |
| 5096 | } |
| 5097 | } |
| 5098 | } |
| 5099 | |
| 5100 | for (i = 0; i < NUM_AP_AC; i++) { |
| 5101 | if (dut->ap_sta_qos[i].ac) { |
| 5102 | snprintf(buf, sizeof(buf), "iwpriv %s cwmin %d 1 %d", |
| 5103 | ifname, i, dut->ap_sta_qos[i].cwmin); |
| 5104 | if (system(buf) != 0) { |
| 5105 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5106 | "iwpriv cwmin failed"); |
| 5107 | } |
| 5108 | |
| 5109 | snprintf(buf, sizeof(buf), "iwpriv %s cwmax %d 1 %d", |
| 5110 | ifname, i, dut->ap_sta_qos[i].cwmax); |
| 5111 | if (system(buf) != 0) { |
| 5112 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5113 | "iwpriv cwmax failed"); |
| 5114 | } |
| 5115 | |
| 5116 | snprintf(buf, sizeof(buf), "iwpriv %s aifs %d 1 %d", |
| 5117 | ifname, i, dut->ap_sta_qos[i].aifs); |
| 5118 | if (system(buf) != 0) { |
| 5119 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5120 | "iwpriv aifs failed"); |
| 5121 | } |
| 5122 | |
| 5123 | snprintf(buf, sizeof(buf), |
| 5124 | "iwpriv %s txoplimit %d 1 %d", |
| 5125 | ifname, i, dut->ap_sta_qos[i].txop); |
| 5126 | if (system(buf) != 0) { |
| 5127 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5128 | "iwpriv txoplimit failed"); |
| 5129 | } |
| 5130 | |
| 5131 | snprintf(buf, sizeof(buf), "iwpriv %s acm %d 1 %d", |
| 5132 | ifname, i, dut->ap_sta_qos[i].acm); |
| 5133 | if (system(buf) != 0) { |
| 5134 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5135 | "iwpriv acm failed"); |
| 5136 | } |
| 5137 | } |
| 5138 | } |
| 5139 | |
| 5140 | if (dut->ap_disable_protection == 1) { |
| 5141 | snprintf(buf, sizeof(buf), "iwpriv %s enablertscts 0", ifname); |
| 5142 | if (system(buf) != 0) { |
| 5143 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5144 | "iwpriv enablertscts failed"); |
| 5145 | } |
| 5146 | sigma_dut_print(dut, DUT_MSG_INFO, "Disabled rtscts"); |
| 5147 | } |
| 5148 | |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 5149 | if (dut->ap_ldpc == VALUE_ENABLED) { |
Sarvepalli, Rajesh Babu | 580572a | 2016-11-29 22:07:14 +0530 | [diff] [blame] | 5150 | snprintf(buf, sizeof(buf), "iwpriv %s ldpc 3", ifname); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5151 | if (system(buf) != 0) { |
| 5152 | sigma_dut_print(dut, DUT_MSG_ERROR, |
priyadharshini gowthaman | 15b299d | 2017-04-20 12:10:45 -0700 | [diff] [blame] | 5153 | "iwpriv ldpc 3 failed"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5154 | } |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 5155 | } else if (dut->ap_ldpc == VALUE_DISABLED) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5156 | snprintf(buf, sizeof(buf), "iwpriv %s ldpc 0", ifname); |
| 5157 | if (system(buf) != 0) { |
| 5158 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5159 | "iwpriv ldpc 0 failed"); |
| 5160 | } |
| 5161 | } |
| 5162 | |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 5163 | if (dut->ap_ampdu == VALUE_ENABLED) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5164 | snprintf(buf, sizeof(buf), "iwpriv %s ampdu 1", ifname); |
| 5165 | if (system(buf) != 0) { |
| 5166 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5167 | "iwpriv ampdu 1 failed"); |
| 5168 | } |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 5169 | } else if (dut->ap_ampdu == VALUE_DISABLED) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5170 | snprintf(buf, sizeof(buf), "iwpriv %s ampdu 0", ifname); |
| 5171 | if (system(buf) != 0) { |
| 5172 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5173 | "iwpriv ampdu 0 failed"); |
| 5174 | } |
| 5175 | } |
| 5176 | |
| 5177 | if (dut->ap_ampdu_exp) { |
| 5178 | if (dut->program == PROGRAM_VHT) { |
| 5179 | snprintf(buf, sizeof(buf), "iwpriv %s vhtmaxampdu %d", |
| 5180 | ifname, dut->ap_ampdu_exp); |
| 5181 | if (system(buf) != 0) { |
| 5182 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5183 | "iwpriv vhtmaxampdu failed"); |
| 5184 | } |
| 5185 | } else { |
| 5186 | /* 11N */ |
| 5187 | snprintf(buf, sizeof(buf), "iwpriv %s maxampdu %d", |
| 5188 | ifname, dut->ap_ampdu_exp); |
| 5189 | if (system(buf) != 0) { |
| 5190 | sigma_dut_print(dut, DUT_MSG_ERROR, "iwpriv maxampdu failed"); |
| 5191 | } |
| 5192 | } |
| 5193 | } |
| 5194 | |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 5195 | if (dut->ap_noack == VALUE_ENABLED) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5196 | snprintf(buf, sizeof(buf), "iwpriv %s noackpolicy 0 0 1", ifname); |
| 5197 | if (system(buf) != 0) { |
| 5198 | sigma_dut_print(dut, DUT_MSG_ERROR, "iwpriv noackpolicy 0 0 1 failed"); |
| 5199 | } |
| 5200 | snprintf(buf, sizeof(buf), "iwpriv %s noackpolicy 1 0 1", ifname); |
| 5201 | if (system(buf) != 0) { |
| 5202 | sigma_dut_print(dut, DUT_MSG_ERROR, "iwpriv noackpolicy 1 0 1 failed"); |
| 5203 | } |
| 5204 | snprintf(buf, sizeof(buf), "iwpriv %s noackpolicy 2 0 1", ifname); |
| 5205 | if (system(buf) != 0) { |
| 5206 | sigma_dut_print(dut, DUT_MSG_ERROR, "iwpriv noackpolicy 2 0 1 failed"); |
| 5207 | } |
| 5208 | snprintf(buf, sizeof(buf), "iwpriv %s noackpolicy 3 0 1", ifname); |
| 5209 | if (system(buf) != 0) { |
| 5210 | sigma_dut_print(dut, DUT_MSG_ERROR, "iwpriv noackpolicy 3 0 1 failed"); |
| 5211 | } |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 5212 | } else if (dut->ap_noack == VALUE_DISABLED) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5213 | snprintf(buf, sizeof(buf), "iwpriv %s noackpolicy 0 0 0", ifname); |
| 5214 | if (system(buf) != 0) { |
| 5215 | sigma_dut_print(dut, DUT_MSG_ERROR, "iwpriv noackpolicy 0 0 0 failed"); |
| 5216 | } |
| 5217 | snprintf(buf, sizeof(buf), "iwpriv %s noackpolicy 1 0 0", ifname); |
| 5218 | if (system(buf) != 0) { |
| 5219 | sigma_dut_print(dut, DUT_MSG_ERROR, "iwpriv noackpolicy 1 0 0 failed"); |
| 5220 | } |
| 5221 | snprintf(buf, sizeof(buf), "iwpriv %s noackpolicy 2 0 0", ifname); |
| 5222 | if (system(buf) != 0) { |
| 5223 | sigma_dut_print(dut, DUT_MSG_ERROR, "iwpriv noackpolicy 2 0 0 failed"); |
| 5224 | } |
| 5225 | snprintf(buf, sizeof(buf), "iwpriv %s noackpolicy 3 0 0", ifname); |
| 5226 | if (system(buf) != 0) { |
| 5227 | sigma_dut_print(dut, DUT_MSG_ERROR, "iwpriv noackpolicy 3 0 0 failed"); |
| 5228 | } |
| 5229 | } |
| 5230 | |
| 5231 | if (dut->device_type == AP_testbed && dut->ap_vhtmcs_map) { |
| 5232 | snprintf(buf, sizeof(buf), "iwpriv %s vht_mcsmap 0x%04x", |
| 5233 | ifname, dut->ap_vhtmcs_map); |
| 5234 | if (system(buf) != 0) { |
| 5235 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5236 | "iwpriv vht_mcsmap failed"); |
| 5237 | } |
| 5238 | } |
| 5239 | |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 5240 | if (dut->ap_amsdu == VALUE_ENABLED) { |
Sunil Dutt | 27ec7f6 | 2017-09-14 18:22:59 +0300 | [diff] [blame] | 5241 | snprintf(buf, sizeof(buf), "iwpriv %s amsdu 2", ifname); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5242 | if (system(buf) != 0) { |
Sunil Dutt | 27ec7f6 | 2017-09-14 18:22:59 +0300 | [diff] [blame] | 5243 | sigma_dut_print(dut, DUT_MSG_ERROR, "iwpriv amsdu 2 failed"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5244 | } |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 5245 | } else if (dut->ap_amsdu == VALUE_DISABLED) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5246 | snprintf(buf, sizeof(buf), "iwpriv %s amsdu 1", ifname); |
| 5247 | if (system(buf) != 0) { |
| 5248 | sigma_dut_print(dut, DUT_MSG_ERROR, "iwpriv amsdu 1 failed"); |
| 5249 | } |
| 5250 | } |
| 5251 | |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 5252 | if (dut->ap_rx_amsdu == VALUE_ENABLED) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5253 | snprintf(buf, sizeof(buf), "iwpriv wifi1 rx_amsdu 1"); |
| 5254 | if (system(buf) != 0) { |
| 5255 | sigma_dut_print(dut, DUT_MSG_ERROR, "iwpriv rx_amsdu 1 failed"); |
| 5256 | } |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 5257 | } else if (dut->ap_rx_amsdu == VALUE_DISABLED) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5258 | snprintf(buf, sizeof(buf), "iwpriv wifi1 rx_amsdu 0"); |
| 5259 | if (system(buf) != 0) { |
| 5260 | sigma_dut_print(dut, DUT_MSG_ERROR, "iwpriv rx_amsdu 0 failed"); |
| 5261 | } |
| 5262 | } |
| 5263 | |
| 5264 | /* Command sequence to generate single VHT AMSDU and MPDU */ |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 5265 | if (dut->ap_addba_reject != VALUE_NOT_SET && |
| 5266 | dut->ap_ampdu == VALUE_DISABLED && |
| 5267 | dut->ap_amsdu == VALUE_ENABLED) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5268 | snprintf(buf, sizeof(buf), "iwpriv %s setaddbaoper 1", ifname); |
| 5269 | if (system(buf) != 0) { |
| 5270 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5271 | "iwpriv setaddbaoper 1 failed"); |
| 5272 | } |
| 5273 | |
| 5274 | snprintf(buf, sizeof(buf), |
| 5275 | "wifitool %s senddelba 1 0 1 4", ifname); |
| 5276 | if (system(buf) != 0) { |
| 5277 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5278 | "wifitool senddelba failed"); |
| 5279 | } |
| 5280 | |
| 5281 | snprintf(buf, sizeof(buf), "wifitool %s sendsingleamsdu 1 0", |
| 5282 | ifname); |
| 5283 | if (system(buf) != 0) { |
| 5284 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5285 | "wifitool sendsingleamsdu failed"); |
| 5286 | } |
| 5287 | |
| 5288 | snprintf(buf, sizeof(buf), "iwpriv %s amsdu 10", ifname); |
| 5289 | if (system(buf) != 0) { |
| 5290 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5291 | "iwpriv amsdu failed"); |
| 5292 | } |
| 5293 | } |
| 5294 | |
| 5295 | if (dut->ap_mode == AP_11ac) { |
| 5296 | int chwidth, nss; |
| 5297 | |
| 5298 | switch (dut->ap_chwidth) { |
| 5299 | case AP_20: |
| 5300 | chwidth = 0; |
| 5301 | break; |
| 5302 | case AP_40: |
| 5303 | chwidth = 1; |
| 5304 | break; |
| 5305 | case AP_80: |
| 5306 | chwidth = 2; |
| 5307 | break; |
| 5308 | case AP_160: |
| 5309 | chwidth = 3; |
| 5310 | break; |
priyadharshini gowthaman | 63ab848 | 2017-12-28 15:32:55 -0800 | [diff] [blame] | 5311 | case AP_80_80: |
| 5312 | chwidth = 3; |
| 5313 | break; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5314 | default: |
| 5315 | chwidth = 0; |
| 5316 | break; |
| 5317 | } |
| 5318 | |
| 5319 | switch (dut->ap_tx_streams) { |
| 5320 | case 1: |
| 5321 | nss = 1; |
| 5322 | break; |
| 5323 | case 2: |
| 5324 | nss = 2; |
| 5325 | break; |
| 5326 | case 3: |
| 5327 | nss = 3; |
| 5328 | break; |
| 5329 | case 4: |
| 5330 | nss = 4; |
| 5331 | break; |
| 5332 | default: |
| 5333 | nss = 3; |
| 5334 | break; |
| 5335 | } |
| 5336 | |
| 5337 | if (dut->ap_fixed_rate) { |
| 5338 | if (nss == 4) |
| 5339 | ath_disable_txbf(dut, ifname); |
| 5340 | |
| 5341 | /* Set the nss */ |
| 5342 | snprintf(buf, sizeof(buf), "iwpriv %s nss %d", |
| 5343 | ifname, nss); |
| 5344 | if (system(buf) != 0) { |
| 5345 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5346 | "iwpriv nss failed"); |
| 5347 | } |
| 5348 | |
| 5349 | /* Set the channel width */ |
| 5350 | snprintf(buf, sizeof(buf), "iwpriv %s chwidth %d", |
| 5351 | ifname, chwidth); |
| 5352 | if (system(buf) != 0) { |
| 5353 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5354 | "iwpriv chwidth failed"); |
| 5355 | } |
| 5356 | |
| 5357 | /* Set the VHT MCS */ |
| 5358 | snprintf(buf, sizeof(buf), "iwpriv %s vhtmcs %d", |
| 5359 | ifname, dut->ap_mcs); |
| 5360 | if (system(buf) != 0) { |
| 5361 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5362 | "iwpriv vhtmcs failed"); |
| 5363 | } |
| 5364 | } |
| 5365 | } |
| 5366 | |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 5367 | if (dut->ap_dyn_bw_sig == VALUE_ENABLED) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5368 | snprintf(buf, sizeof(buf), "iwpriv %s cwmenable 1", ifname); |
| 5369 | if (system(buf) != 0) { |
| 5370 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5371 | "iwpriv cwmenable 1 failed"); |
| 5372 | } |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 5373 | } else if (dut->ap_dyn_bw_sig == VALUE_DISABLED) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5374 | snprintf(buf, sizeof(buf), "iwpriv %s cwmenable 0", ifname); |
| 5375 | if (system(buf) != 0) { |
| 5376 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5377 | "iwpriv cwmenable 0 failed"); |
| 5378 | } |
| 5379 | } |
| 5380 | |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 5381 | if (dut->ap_sig_rts == VALUE_ENABLED) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5382 | snprintf(buf, sizeof(buf), "iwconfig %s rts 64", ifname); |
| 5383 | if (system(buf) != 0) { |
| 5384 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5385 | "iwconfig rts 64 failed"); |
| 5386 | } |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 5387 | } else if (dut->ap_sig_rts == VALUE_DISABLED) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5388 | snprintf(buf, sizeof(buf), "iwconfig %s rts 2347", ifname); |
| 5389 | if (system(buf) != 0) { |
| 5390 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5391 | "iwpriv rts 2347 failed"); |
| 5392 | } |
| 5393 | } |
| 5394 | |
| 5395 | if (dut->ap_hs2) { |
| 5396 | snprintf(buf, sizeof(buf), "iwpriv %s qbssload 1", ifname); |
| 5397 | if (system(buf) != 0) { |
| 5398 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5399 | "iwpriv qbssload failed"); |
| 5400 | } |
| 5401 | sigma_dut_print(dut, DUT_MSG_INFO, "Enabled qbssload"); |
| 5402 | } |
| 5403 | |
| 5404 | if (dut->ap_bss_load && dut->ap_bss_load != -1) { |
| 5405 | unsigned int bssload = 0; |
| 5406 | |
| 5407 | if (dut->ap_bss_load == 1) { |
| 5408 | /* STA count: 1, CU: 50, AAC: 65535 */ |
| 5409 | bssload = 0x0132ffff; |
| 5410 | } else if (dut->ap_bss_load == 2) { |
| 5411 | /* STA count: 1, CU: 200, AAC: 65535 */ |
| 5412 | bssload = 0x01c8ffff; |
| 5413 | } else if (dut->ap_bss_load == 3) { |
| 5414 | /* STA count: 1, CU: 75, AAC: 65535 */ |
| 5415 | bssload = 0x014bffff; |
| 5416 | } |
| 5417 | |
| 5418 | snprintf(buf, sizeof(buf), "iwpriv %s hcbssload %u", |
| 5419 | ifname, bssload); |
| 5420 | if (system(buf) != 0) { |
| 5421 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5422 | "iwpriv hcbssload failed"); |
| 5423 | } |
| 5424 | } else if (dut->ap_bss_load == 0) { |
| 5425 | snprintf(buf, sizeof(buf), "iwpriv %s qbssload 0", ifname); |
| 5426 | if (system(buf) != 0) { |
| 5427 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5428 | "iwpriv qbssload failed"); |
| 5429 | } |
| 5430 | sigma_dut_print(dut, DUT_MSG_INFO, "Disabled qbssload"); |
| 5431 | } |
| 5432 | |
| 5433 | if (dut->ap_dgaf_disable) { |
| 5434 | snprintf(buf, sizeof(buf), "iwpriv %s dgaf_disable 1", ifname); |
| 5435 | if (system(buf) != 0) { |
| 5436 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5437 | "iwpriv dgaf_disable failed"); |
| 5438 | } |
| 5439 | sigma_dut_print(dut, DUT_MSG_INFO, "Enabled dgaf_disable"); |
| 5440 | } |
| 5441 | |
| 5442 | if (dut->ap_l2tif) { |
| 5443 | snprintf(buf, sizeof(buf), "iwpriv %s l2tif 1", ifname); |
| 5444 | if (system(buf) != 0) { |
| 5445 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5446 | "iwpriv l2tif failed"); |
| 5447 | } |
| 5448 | snprintf(buf, sizeof(buf), |
| 5449 | "echo 1 > /sys/class/net/br0/brif/ath0/hotspot_l2tif"); |
| 5450 | if (system(buf) != 0) |
| 5451 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5452 | "l2tif br failed"); |
| 5453 | |
| 5454 | snprintf(buf, sizeof(buf), |
| 5455 | "echo 1 > /sys/class/net/br0/brif/eth0/hotspot_wan"); |
| 5456 | if (system(buf) != 0) |
| 5457 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5458 | "l2tif brif failed"); |
| 5459 | sigma_dut_print(dut, DUT_MSG_INFO, "Enabled l2tif"); |
| 5460 | } |
priyadharshini gowthaman | 264d544 | 2016-02-25 15:52:22 -0800 | [diff] [blame] | 5461 | |
| 5462 | if (dut->ap_ndpa_frame == 0) { |
| 5463 | snprintf(buf, sizeof(buf), |
| 5464 | "wifitool %s beeliner_fw_test 117 192", ifname); |
| 5465 | if (system(buf) != 0) { |
| 5466 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5467 | "wifitool beeliner_fw_test 117 192 failed"); |
| 5468 | } |
| 5469 | snprintf(buf, sizeof(buf), |
| 5470 | "wifitool %s beeliner_fw_test 118 192", ifname); |
| 5471 | if (system(buf) != 0) { |
| 5472 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5473 | "wifitool beeliner_fw_test 117 192 failed"); |
| 5474 | } |
| 5475 | } else if (dut->ap_ndpa_frame == 1) { |
| 5476 | /* Driver default - no changes needed */ |
| 5477 | } else if (dut->ap_ndpa_frame == 2) { |
| 5478 | snprintf(buf, sizeof(buf), |
| 5479 | "wifitool %s beeliner_fw_test 115 1", ifname); |
| 5480 | if (system(buf) != 0) { |
| 5481 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5482 | "wifitool beeliner_fw_test 117 192 failed"); |
| 5483 | } |
| 5484 | snprintf(buf, sizeof(buf), |
| 5485 | "wifitool %s beeliner_fw_test 116 1", ifname); |
| 5486 | if (system(buf) != 0) { |
| 5487 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5488 | "wifitool beeliner_fw_test 117 192 failed"); |
| 5489 | } |
| 5490 | } |
priyadharshini gowthaman | 8e26ff4 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 5491 | |
| 5492 | if (dut->ap_rtt == 1) { |
| 5493 | snprintf(buf, sizeof(buf), "iwpriv %s enable_rtt 1", ifname); |
| 5494 | run_system(dut, buf); |
| 5495 | } |
| 5496 | |
| 5497 | if (dut->ap_lci == 1) { |
| 5498 | snprintf(buf, sizeof(buf), "iwpriv %s enable_lci 1", ifname); |
| 5499 | run_system(dut, buf); |
| 5500 | } |
| 5501 | |
| 5502 | if (dut->ap_lcr == 1) { |
| 5503 | snprintf(buf, sizeof(buf), "iwpriv %s enable_lcr 1", ifname); |
| 5504 | run_system(dut, buf); |
| 5505 | } |
| 5506 | |
| 5507 | if (dut->ap_rrm == 1) { |
| 5508 | snprintf(buf, sizeof(buf), "iwpriv %s rrm 1", ifname); |
| 5509 | run_system(dut, buf); |
| 5510 | } |
| 5511 | |
| 5512 | if (dut->ap_lci == 1 || dut->ap_lcr == 1) { |
| 5513 | run_system(dut, "wpc -l /tmp/lci_cfg.txt"); |
| 5514 | } |
| 5515 | |
| 5516 | if (dut->ap_neighap >= 1 && dut->ap_lci == 0) { |
| 5517 | FILE *f; |
| 5518 | |
| 5519 | f = fopen("/tmp/nbr_report.txt", "w"); |
| 5520 | if (!f) { |
| 5521 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5522 | "Failed to open /tmp/nbr_report.txt"); |
| 5523 | return; |
| 5524 | } |
| 5525 | |
| 5526 | fprintf(f, |
| 5527 | "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", |
| 5528 | dut->ap_val_neighap[0][0], dut->ap_val_neighap[0][1], |
| 5529 | dut->ap_val_neighap[0][2], dut->ap_val_neighap[0][3], |
| 5530 | dut->ap_val_neighap[0][4], dut->ap_val_neighap[0][5], |
| 5531 | dut->ap_val_opchannel[0]); |
| 5532 | fclose(f); |
| 5533 | |
| 5534 | f = fopen("/tmp/ftmrr.txt", "w"); |
| 5535 | if (!f) { |
| 5536 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5537 | "Failed to open /tmp/ftmrr.txt"); |
| 5538 | return; |
| 5539 | } |
| 5540 | |
| 5541 | fprintf(f, |
| 5542 | "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", |
| 5543 | dut->ap_val_neighap[0][0], dut->ap_val_neighap[0][1], |
| 5544 | dut->ap_val_neighap[0][2], dut->ap_val_neighap[0][3], |
| 5545 | dut->ap_val_neighap[0][4], dut->ap_val_neighap[0][5], |
| 5546 | dut->ap_val_opchannel[0]); |
| 5547 | fclose(f); |
| 5548 | } |
| 5549 | |
| 5550 | if (dut->ap_neighap >= 2 && dut->ap_lci == 0) { |
| 5551 | FILE *f; |
| 5552 | |
| 5553 | f = fopen("/tmp/nbr_report.txt", "a"); |
| 5554 | if (!f) { |
| 5555 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5556 | "Failed to open /tmp/nbr_report.txt"); |
| 5557 | return; |
| 5558 | } |
| 5559 | fprintf(f, |
| 5560 | "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", |
| 5561 | dut->ap_val_neighap[1][0], dut->ap_val_neighap[1][1], |
| 5562 | dut->ap_val_neighap[1][2], dut->ap_val_neighap[1][3], |
| 5563 | dut->ap_val_neighap[1][4], dut->ap_val_neighap[1][5], |
| 5564 | dut->ap_val_opchannel[1]); |
| 5565 | fclose(f); |
| 5566 | |
| 5567 | f = fopen("/tmp/ftmrr.txt", "a"); |
| 5568 | if (!f) { |
| 5569 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5570 | "Failed to open /tmp/ftmrr.txt"); |
| 5571 | return; |
| 5572 | } |
| 5573 | fprintf(f, |
| 5574 | "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", |
| 5575 | dut->ap_val_neighap[1][0], dut->ap_val_neighap[1][1], |
| 5576 | dut->ap_val_neighap[1][2], dut->ap_val_neighap[1][3], |
| 5577 | dut->ap_val_neighap[1][4], dut->ap_val_neighap[1][5], |
| 5578 | dut->ap_val_opchannel[1]); |
| 5579 | fclose(f); |
| 5580 | } |
| 5581 | |
| 5582 | if (dut->ap_neighap >= 3 && dut->ap_lci == 0) { |
| 5583 | FILE *f; |
| 5584 | |
| 5585 | f = fopen("/tmp/nbr_report.txt", "a"); |
| 5586 | if (!f) { |
| 5587 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5588 | "Failed to open /tmp/nbr_report.txt"); |
| 5589 | return; |
| 5590 | } |
| 5591 | |
| 5592 | fprintf(f, |
| 5593 | "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", |
| 5594 | dut->ap_val_neighap[2][0], dut->ap_val_neighap[2][1], |
| 5595 | dut->ap_val_neighap[2][2], dut->ap_val_neighap[2][3], |
| 5596 | dut->ap_val_neighap[2][4], dut->ap_val_neighap[2][5], |
| 5597 | dut->ap_val_opchannel[2]); |
| 5598 | fclose(f); |
| 5599 | |
| 5600 | f = fopen("/tmp/ftmrr.txt", "a"); |
| 5601 | if (!f) { |
| 5602 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5603 | "Failed to open /tmp/ftmrr.txt"); |
| 5604 | return; |
| 5605 | } |
| 5606 | |
| 5607 | fprintf(f, |
| 5608 | "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", |
| 5609 | dut->ap_val_neighap[2][0], dut->ap_val_neighap[2][1], |
| 5610 | dut->ap_val_neighap[2][2], dut->ap_val_neighap[2][3], |
| 5611 | dut->ap_val_neighap[2][4], dut->ap_val_neighap[2][5], |
| 5612 | dut->ap_val_opchannel[2]); |
| 5613 | fclose(f); |
| 5614 | } |
| 5615 | |
| 5616 | if (dut->ap_neighap) { |
| 5617 | snprintf(buf, sizeof(buf), "iwpriv %s enable_rtt 1", ifname); |
| 5618 | run_system(dut, buf); |
| 5619 | snprintf(buf, sizeof(buf), "iwpriv %s enable_lci 1", ifname); |
| 5620 | run_system(dut, buf); |
| 5621 | snprintf(buf, sizeof(buf), "iwpriv %s enable_lcr 1", ifname); |
| 5622 | run_system(dut, buf); |
| 5623 | snprintf(buf, sizeof(buf), "iwpriv %s rrm 1", ifname); |
| 5624 | run_system(dut, buf); |
| 5625 | } |
| 5626 | |
| 5627 | if (dut->ap_scan == 1) { |
| 5628 | snprintf(buf, sizeof(buf), "iwpriv %s scanentryage 600", |
| 5629 | ifname); |
| 5630 | run_system(dut, buf); |
| 5631 | snprintf(buf, sizeof(buf), "iwlist %s scan", ifname); |
| 5632 | run_system(dut, buf); |
| 5633 | } |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 5634 | |
| 5635 | if (dut->ap_set_bssidpref) { |
| 5636 | snprintf(buf, sizeof(buf), |
| 5637 | "wifitool %s setbssidpref 00:00:00:00:00:00 0 00 00", |
| 5638 | ifname); |
| 5639 | if (system(buf) != 0) { |
| 5640 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5641 | "wifitool clear bssidpref failed"); |
| 5642 | } |
| 5643 | } |
Adil Saeed Musthafa | 33ea287 | 2017-04-10 23:13:24 -0700 | [diff] [blame] | 5644 | |
| 5645 | if (dut->wnm_bss_max_feature != VALUE_NOT_SET) { |
| 5646 | int feature_enable; |
| 5647 | |
| 5648 | feature_enable = dut->wnm_bss_max_feature == VALUE_ENABLED; |
| 5649 | snprintf(buf, sizeof(buf), "iwpriv %s wnm %d", |
| 5650 | ifname, feature_enable); |
| 5651 | run_system(dut, buf); |
| 5652 | snprintf(buf, sizeof(buf), "iwpriv %s wnm_bss %d", |
| 5653 | ifname, feature_enable); |
| 5654 | run_system(dut, buf); |
| 5655 | if (feature_enable) { |
| 5656 | const char *extra = ""; |
| 5657 | |
| 5658 | if (dut->wnm_bss_max_protection != VALUE_NOT_SET) { |
| 5659 | if (dut->wnm_bss_max_protection == |
| 5660 | VALUE_ENABLED) |
| 5661 | extra = " 1"; |
| 5662 | else |
| 5663 | extra = " 0"; |
| 5664 | } |
| 5665 | snprintf(buf, sizeof(buf), |
| 5666 | "wlanconfig %s wnm setbssmax %d%s", |
| 5667 | ifname, dut->wnm_bss_max_idle_time, extra); |
| 5668 | run_system(dut, buf); |
| 5669 | } |
| 5670 | } |
Adil Saeed Musthafa | 05ec744 | 2017-04-10 23:13:35 -0700 | [diff] [blame] | 5671 | |
Adil Saeed Musthafa | 023108a | 2017-04-10 23:13:37 -0700 | [diff] [blame] | 5672 | if (dut->program == PROGRAM_MBO) { |
Adil Saeed Musthafa | 6906372 | 2017-04-10 23:13:40 -0700 | [diff] [blame] | 5673 | apply_mbo_pref_ap_list(dut); |
| 5674 | |
Adil Saeed Musthafa | 023108a | 2017-04-10 23:13:37 -0700 | [diff] [blame] | 5675 | snprintf(buf, sizeof(buf), "iwpriv %s mbo_cel_pref %d", |
| 5676 | ifname, dut->ap_cell_cap_pref); |
| 5677 | run_system(dut, buf); |
Adil Saeed Musthafa | 16d9e63 | 2017-04-10 23:13:38 -0700 | [diff] [blame] | 5678 | |
| 5679 | snprintf(buf, sizeof(buf), "iwpriv %s mbocap 0x40", ifname); |
| 5680 | run_system(dut, buf); |
| 5681 | |
Adil Saeed Musthafa | 05ec744 | 2017-04-10 23:13:35 -0700 | [diff] [blame] | 5682 | ath_set_assoc_disallow(dut, ifname, "disable"); |
Adil Saeed Musthafa | 023108a | 2017-04-10 23:13:37 -0700 | [diff] [blame] | 5683 | } |
priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 5684 | |
| 5685 | if (dut->ap_oce == VALUE_ENABLED) { |
| 5686 | snprintf(buf, sizeof(buf), "iwpriv %s set_bpr_enable 1", |
| 5687 | ifname); |
| 5688 | run_system(dut, buf); |
| 5689 | } |
| 5690 | |
| 5691 | if (dut->ap_oce == VALUE_ENABLED && dut->ap_channel <= 11) { |
| 5692 | snprintf(buf, sizeof(buf), "iwpriv %s prb_rate 5500", ifname); |
| 5693 | run_system(dut, buf); |
| 5694 | snprintf(buf, sizeof(buf), "iwpriv %s set_bcn_rate 5500", |
| 5695 | ifname); |
| 5696 | run_system(dut, buf); |
| 5697 | } |
| 5698 | |
| 5699 | if (dut->ap_oce == VALUE_DISABLED) { |
| 5700 | snprintf(buf, sizeof(buf), "iwpriv %s set_bpr_enable 0", |
| 5701 | ifname); |
| 5702 | run_system(dut, buf); |
| 5703 | } |
| 5704 | |
| 5705 | if (dut->ap_oce == VALUE_DISABLED && dut->ap_channel <= 11) { |
| 5706 | snprintf(buf, sizeof(buf), "iwpriv %s mgmt_rate 1000", ifname); |
| 5707 | run_system(dut, buf); |
| 5708 | snprintf(buf, sizeof(buf), "iwpriv %s set_bcn_rate 1000", |
| 5709 | ifname); |
| 5710 | run_system(dut, buf); |
| 5711 | } |
| 5712 | |
| 5713 | if (dut->ap_bcnint) { |
| 5714 | snprintf(buf, sizeof(buf), "iwpriv %s bintval %d", ifname, |
| 5715 | dut->ap_bcnint); |
| 5716 | run_system(dut, buf); |
| 5717 | } |
| 5718 | |
| 5719 | if (dut->ap_filsdscv == VALUE_DISABLED) { |
| 5720 | snprintf(buf, sizeof(buf), "iwpriv %s enable_fils 0 0", ifname); |
| 5721 | run_system(dut, buf); |
| 5722 | } |
| 5723 | |
| 5724 | if (dut->ap_filshlp == VALUE_ENABLED) { |
| 5725 | snprintf(buf, sizeof(buf), "iwpriv %s oce_hlp 1", ifname); |
| 5726 | if (system(buf) != 0) { |
| 5727 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5728 | "iwpriv filshlp enable failed"); |
| 5729 | } |
| 5730 | } else if (dut->ap_filshlp == VALUE_DISABLED) { |
| 5731 | snprintf(buf, sizeof(buf), "iwpriv %s oce_hlp 0", ifname); |
| 5732 | if (system(buf) != 0) { |
| 5733 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5734 | "iwpriv filshlp disable failed"); |
| 5735 | } |
| 5736 | } |
| 5737 | |
| 5738 | /* When RNR is enabled, also enable apchannelreport, background scan */ |
| 5739 | if (dut->ap_rnr == VALUE_ENABLED) { |
| 5740 | snprintf(buf, sizeof(buf), "iwpriv %s rnr 1", ifname); |
| 5741 | run_system(dut, buf); |
| 5742 | snprintf(buf, sizeof(buf), "iwpriv %s rnr_tbtt 1", ifname); |
| 5743 | run_system(dut, buf); |
| 5744 | snprintf(buf, sizeof(buf), "iwpriv %s apchanrpt 1", ifname); |
| 5745 | run_system(dut, buf); |
| 5746 | snprintf(buf, sizeof(buf), "iwpriv %s acs_ctrlflags 0x4", |
| 5747 | basedev); |
| 5748 | run_system(dut, buf); |
| 5749 | snprintf(buf, sizeof(buf), "iwpriv %s acs_scanintvl 60", |
| 5750 | basedev); |
| 5751 | run_system(dut, buf); |
| 5752 | snprintf(buf, sizeof(buf), "iwpriv %s acs_bkscanen 1", basedev); |
| 5753 | run_system(dut, buf); |
| 5754 | if (dut->ap_is_dual == 1) { |
| 5755 | snprintf(buf, sizeof(buf), "iwpriv %s rnr 1", |
| 5756 | ifname_dual); |
| 5757 | run_system(dut, buf); |
| 5758 | snprintf(buf, sizeof(buf), "iwpriv %s rnr_tbtt 1", |
| 5759 | ifname_dual); |
| 5760 | run_system(dut, buf); |
| 5761 | snprintf(buf, sizeof(buf), "iwpriv %s apchanrpt 1", |
| 5762 | ifname_dual); |
| 5763 | run_system(dut, buf); |
| 5764 | snprintf(buf, sizeof(buf), |
| 5765 | "iwpriv %s acs_ctrlflags 0x4", basedev_radio); |
| 5766 | run_system(dut, buf); |
| 5767 | snprintf(buf, sizeof(buf), "iwpriv %s acs_scanintvl 60", |
| 5768 | basedev_radio); |
| 5769 | run_system(dut, buf); |
| 5770 | snprintf(buf, sizeof(buf), "iwpriv %s acs_bkscanen 1", |
| 5771 | basedev_radio); |
| 5772 | run_system(dut, buf); |
| 5773 | } |
| 5774 | } |
| 5775 | |
| 5776 | if (dut->ap_blechanutil || dut->ap_ble_admit_cap || dut->ap_blestacnt) { |
| 5777 | snprintf(buf, sizeof(buf), "iwpriv %s qbssload 0", ifname); |
| 5778 | run_system(dut, buf); |
| 5779 | snprintf(buf, sizeof(buf), |
| 5780 | "wlanconfig %s addie ftype 0 len 7 data 0b05%02x%02x%02x%02x%02x ", |
| 5781 | ifname, dut->ap_blestacnt & 0xFF, |
| 5782 | dut->ap_blestacnt >> 8, dut->ap_blechanutil, |
| 5783 | dut->ap_ble_admit_cap & 0xFF, |
| 5784 | dut->ap_ble_admit_cap >> 8); |
| 5785 | run_system(dut, buf); |
| 5786 | snprintf(buf, sizeof(buf), |
| 5787 | "wlanconfig %s addie ftype 2 len 7 data 0b05%02x%02x%02x%02x%02x ", |
| 5788 | ifname, dut->ap_blestacnt & 0xFF, |
| 5789 | dut->ap_blestacnt >> 8, dut->ap_blechanutil, |
| 5790 | dut->ap_ble_admit_cap & 0xFF, |
| 5791 | dut->ap_ble_admit_cap >> 8); |
| 5792 | run_system(dut, buf); |
| 5793 | } |
| 5794 | |
| 5795 | if (dut->ap_esp == VALUE_ENABLED) { |
| 5796 | snprintf(buf, sizeof(buf), "iwpriv %s esp_period 5", basedev); |
| 5797 | if (system(buf) != 0) { |
| 5798 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5799 | "iwpriv esp enable failed"); |
| 5800 | } |
| 5801 | } else if (dut->ap_esp == VALUE_DISABLED) { |
| 5802 | snprintf(buf, sizeof(buf), "iwpriv %s esp_period 0", basedev); |
| 5803 | if (system(buf) != 0) { |
| 5804 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5805 | "iwpriv esp disable failed"); |
| 5806 | } |
| 5807 | } |
| 5808 | |
| 5809 | if (dut->ap_datappdudura) { |
| 5810 | snprintf(buf, sizeof(buf), "iwpriv %s esp_ppdu_dur %d", basedev, |
| 5811 | dut->ap_datappdudura); |
| 5812 | run_system(dut, buf); |
| 5813 | } |
| 5814 | |
| 5815 | if (dut->ap_airtimefract) { |
| 5816 | snprintf(buf, sizeof(buf), "iwpriv %s esp_airtime %d", basedev, |
| 5817 | dut->ap_airtimefract); |
| 5818 | run_system(dut, buf); |
| 5819 | } |
| 5820 | |
| 5821 | if (dut->ap_dhcp_stop) { |
| 5822 | snprintf(buf, sizeof(buf), "/etc/init.d/dnsmasq stop"); |
| 5823 | run_system(dut, buf); |
| 5824 | } |
| 5825 | |
| 5826 | if (dut->ap_bawinsize) { |
| 5827 | snprintf(buf, sizeof(buf), "iwpriv %s esp_ba_window %d", |
| 5828 | basedev, dut->ap_bawinsize); |
| 5829 | run_system(dut, buf); |
| 5830 | } |
priyadharshini gowthaman | b4de196 | 2018-01-15 12:21:04 -0800 | [diff] [blame] | 5831 | |
| 5832 | if (dut->program == PROGRAM_DPP) { |
| 5833 | if (dut->ap_interface_2g == 1) { |
| 5834 | snprintf(buf, sizeof(buf), |
| 5835 | "iwpriv %s set_bcn_rate 5500", ifname); |
| 5836 | run_system(dut, buf); |
| 5837 | snprintf(buf, sizeof(buf), |
| 5838 | "iwpriv %s prb_rate 5500", ifname); |
| 5839 | run_system(dut, buf); |
| 5840 | snprintf(buf, sizeof(buf), |
| 5841 | "iwpriv %s mgmt_rate 5500", ifname); |
| 5842 | run_system(dut, buf); |
| 5843 | } |
| 5844 | |
| 5845 | snprintf(buf, sizeof(buf), "iwpriv %s set_rxfilter 0xffffffff", |
| 5846 | basedev); |
| 5847 | run_system(dut, buf); |
| 5848 | dut->hostapd_running = 1; |
| 5849 | } |
priyadharshini gowthaman | 350f191 | 2018-06-04 13:09:12 -0700 | [diff] [blame] | 5850 | |
| 5851 | if (dut->ap_he_ppdu == PPDU_MU) { |
| 5852 | run_system_wrapper( |
| 5853 | dut, "wifitool %s setUnitTestCmd 0x47 2 11 1000000", |
| 5854 | ifname); |
| 5855 | run_system_wrapper( |
| 5856 | dut, "wifitool %s setUnitTestCmd 0x47 2 17 1000000", |
| 5857 | ifname); |
| 5858 | run_system_wrapper(dut, |
| 5859 | "wifitool %s setUnitTestCmd 0x47 2 8 0", |
| 5860 | ifname); |
| 5861 | run_system_wrapper(dut, |
| 5862 | "wifitool %s setUnitTestCmd 0x47 2 29 0", |
| 5863 | ifname); |
| 5864 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5865 | } |
| 5866 | |
| 5867 | |
| 5868 | static int cmd_ath_ap_config_commit(struct sigma_dut *dut, |
| 5869 | struct sigma_conn *conn, |
| 5870 | struct sigma_cmd *cmd) |
| 5871 | { |
| 5872 | /* const char *name = get_param(cmd, "NAME"); */ |
| 5873 | char buf[100]; |
| 5874 | struct stat s; |
| 5875 | const char *ifname = dut->ap_is_dual ? "ath1" : "ath0"; |
| 5876 | |
| 5877 | if (stat("/proc/athversion", &s) == 0) { |
| 5878 | sigma_dut_print(dut, DUT_MSG_INFO, "Run apdown"); |
| 5879 | run_system(dut, "apdown"); |
| 5880 | } |
| 5881 | |
| 5882 | cmd_ath_ap_radio_config(dut); |
| 5883 | |
| 5884 | snprintf(buf, sizeof(buf), "cfg -a 'AP_SSID=%s'", dut->ap_ssid); |
| 5885 | run_system(dut, buf); |
| 5886 | |
| 5887 | switch (dut->ap_key_mgmt) { |
| 5888 | case AP_OPEN: |
| 5889 | if (dut->ap_cipher == AP_WEP) { |
| 5890 | run_system(dut, "cfg -a AP_SECMODE=WEP"); |
| 5891 | run_system(dut, "cfg -a AP_SECFILE=NONE"); |
| 5892 | /* shared auth mode not supported */ |
| 5893 | run_system(dut, "cfg -a AP_WEP_MODE_0=1"); |
| 5894 | run_system(dut, "cfg -a AP_WEP_MODE_1=1"); |
| 5895 | snprintf(buf, sizeof(buf), |
| 5896 | "cfg -a WEP_RADIO_NUM0_KEY_1=%s", |
| 5897 | dut->ap_wepkey); |
| 5898 | run_system(dut, buf); |
| 5899 | snprintf(buf, sizeof(buf), |
| 5900 | "cfg -a WEP_RADIO_NUM1_KEY_1=%s", |
| 5901 | dut->ap_wepkey); |
| 5902 | run_system(dut, buf); |
| 5903 | } else { |
| 5904 | run_system(dut, "cfg -a AP_SECMODE=None"); |
| 5905 | } |
| 5906 | break; |
| 5907 | case AP_WPA2_PSK: |
| 5908 | case AP_WPA2_PSK_MIXED: |
| 5909 | case AP_WPA_PSK: |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 5910 | case AP_WPA2_SAE: |
| 5911 | case AP_WPA2_PSK_SAE: |
| 5912 | if (dut->ap_key_mgmt == AP_WPA2_PSK || |
| 5913 | dut->ap_key_mgmt == AP_WPA2_SAE || |
| 5914 | dut->ap_key_mgmt == AP_WPA2_PSK_SAE) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5915 | run_system(dut, "cfg -a AP_WPA=2"); |
| 5916 | else if (dut->ap_key_mgmt == AP_WPA2_PSK_MIXED) |
| 5917 | run_system(dut, "cfg -a AP_WPA=3"); |
| 5918 | else |
| 5919 | run_system(dut, "cfg -a AP_WPA=1"); |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 5920 | /* TODO: SAE configuration */ |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5921 | run_system(dut, "cfg -a AP_SECMODE=WPA"); |
| 5922 | run_system(dut, "cfg -a AP_SECFILE=PSK"); |
| 5923 | snprintf(buf, sizeof(buf), "cfg -a 'PSK_KEY=%s'", |
| 5924 | dut->ap_passphrase); |
| 5925 | run_system(dut, buf); |
| 5926 | if (dut->ap_cipher == AP_CCMP_TKIP) |
| 5927 | run_system(dut, "cfg -a AP_CYPHER=\"CCMP TKIP\""); |
| 5928 | else if (dut->ap_cipher == AP_TKIP) |
| 5929 | run_system(dut, "cfg -a AP_CYPHER=TKIP"); |
| 5930 | else |
| 5931 | run_system(dut, "cfg -a AP_CYPHER=CCMP"); |
| 5932 | break; |
| 5933 | case AP_WPA2_EAP: |
| 5934 | case AP_WPA2_EAP_MIXED: |
| 5935 | case AP_WPA_EAP: |
| 5936 | if (dut->ap_key_mgmt == AP_WPA2_EAP) |
| 5937 | run_system(dut, "cfg -a AP_WPA=2"); |
| 5938 | else if (dut->ap_key_mgmt == AP_WPA2_EAP_MIXED) |
| 5939 | run_system(dut, "cfg -a AP_WPA=3"); |
| 5940 | else |
| 5941 | run_system(dut, "cfg -a AP_WPA=1"); |
| 5942 | run_system(dut, "cfg -a AP_SECMODE=WPA"); |
| 5943 | run_system(dut, "cfg -a AP_SECFILE=EAP"); |
| 5944 | if (dut->ap_cipher == AP_CCMP_TKIP) |
| 5945 | run_system(dut, "cfg -a AP_CYPHER=\"CCMP TKIP\""); |
| 5946 | else if (dut->ap_cipher == AP_TKIP) |
| 5947 | run_system(dut, "cfg -a AP_CYPHER=TKIP"); |
| 5948 | else |
| 5949 | run_system(dut, "cfg -a AP_CYPHER=CCMP"); |
| 5950 | snprintf(buf, sizeof(buf), "cfg -a AP_AUTH_SERVER=%s", |
| 5951 | dut->ap_radius_ipaddr); |
| 5952 | run_system(dut, buf); |
| 5953 | snprintf(buf, sizeof(buf), "cfg -a AP_AUTH_PORT=%d", |
| 5954 | dut->ap_radius_port); |
| 5955 | run_system(dut, buf); |
| 5956 | snprintf(buf, sizeof(buf), "cfg -a AP_AUTH_SECRET=%s", |
| 5957 | dut->ap_radius_password); |
| 5958 | run_system(dut, buf); |
| 5959 | break; |
Jouni Malinen | 4cf699f | 2018-06-19 00:46:27 +0300 | [diff] [blame] | 5960 | case AP_WPA2_EAP_OSEN: |
| 5961 | /* TODO */ |
| 5962 | sigma_dut_print(dut, DUT_MSG_ERROR, "EAP+OSEN not supported"); |
| 5963 | break; |
Jouni Malinen | ad395a2 | 2017-09-01 21:13:46 +0300 | [diff] [blame] | 5964 | case AP_SUITEB: |
| 5965 | /* TODO */ |
| 5966 | sigma_dut_print(dut, DUT_MSG_ERROR, "SuiteB not supported"); |
| 5967 | break; |
Jouni Malinen | 147b3c3 | 2017-10-09 16:51:54 +0300 | [diff] [blame] | 5968 | case AP_WPA2_OWE: |
| 5969 | /* TODO */ |
| 5970 | sigma_dut_print(dut, DUT_MSG_ERROR, "OWE not supported"); |
| 5971 | break; |
Jouni Malinen | 6be21c8 | 2018-08-01 18:47:24 +0300 | [diff] [blame] | 5972 | case AP_WPA2_FT_EAP: |
| 5973 | case AP_WPA2_FT_PSK: |
| 5974 | case AP_WPA2_EAP_SHA256: |
| 5975 | case AP_WPA2_PSK_SHA256: |
| 5976 | case AP_WPA2_ENT_FT_EAP: |
| 5977 | /* TODO */ |
| 5978 | send_resp(dut, conn, SIGMA_ERROR, |
| 5979 | "errorCode,Unsupported KeyMgnt value"); |
| 5980 | return 0; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5981 | } |
| 5982 | |
| 5983 | if (dut->ap_is_dual) { |
| 5984 | /* ath1 settings in case of dual */ |
| 5985 | snprintf(buf, sizeof(buf), "cfg -a 'AP_SSID_2=%s'", |
| 5986 | dut->ap_ssid); |
| 5987 | run_system(dut, buf); |
| 5988 | |
| 5989 | switch (dut->ap_key_mgmt) { |
| 5990 | case AP_OPEN: |
| 5991 | if (dut->ap_cipher == AP_WEP) { |
| 5992 | run_system(dut, "cfg -a AP_SECMODE_2=WEP"); |
| 5993 | run_system(dut, "cfg -a AP_SECFILE_2=NONE"); |
| 5994 | /* shared auth mode not supported */ |
| 5995 | run_system(dut, "cfg -a AP_WEP_MODE_0=1"); |
| 5996 | run_system(dut, "cfg -a AP_WEP_MODE_1=1"); |
| 5997 | snprintf(buf, sizeof(buf), |
| 5998 | "cfg -a WEP_RADIO_NUM0_KEY_1=%s", |
| 5999 | dut->ap_wepkey); |
| 6000 | run_system(dut, buf); |
| 6001 | snprintf(buf, sizeof(buf), |
| 6002 | "cfg -a WEP_RADIO_NUM1_KEY_1=%s", |
| 6003 | dut->ap_wepkey); |
| 6004 | run_system(dut, buf); |
| 6005 | } else { |
| 6006 | run_system(dut, "cfg -a AP_SECMODE_2=None"); |
| 6007 | } |
| 6008 | break; |
| 6009 | case AP_WPA2_PSK: |
| 6010 | case AP_WPA2_PSK_MIXED: |
| 6011 | case AP_WPA_PSK: |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 6012 | case AP_WPA2_SAE: |
| 6013 | case AP_WPA2_PSK_SAE: |
| 6014 | if (dut->ap_key_mgmt == AP_WPA2_PSK || |
| 6015 | dut->ap_key_mgmt == AP_WPA2_SAE || |
| 6016 | dut->ap_key_mgmt == AP_WPA2_PSK_SAE) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6017 | run_system(dut, "cfg -a AP_WPA_2=2"); |
| 6018 | else if (dut->ap_key_mgmt == AP_WPA2_PSK_MIXED) |
| 6019 | run_system(dut, "cfg -a AP_WPA_2=3"); |
| 6020 | else |
| 6021 | run_system(dut, "cfg -a AP_WPA_2=1"); |
| 6022 | // run_system(dut, "cfg -a AP_WPA_2=2"); |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 6023 | /* TODO: SAE configuration */ |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6024 | run_system(dut, "cfg -a AP_SECMODE_2=WPA"); |
| 6025 | run_system(dut, "cfg -a AP_SECFILE_2=PSK"); |
| 6026 | snprintf(buf, sizeof(buf), "cfg -a 'PSK_KEY_2=%s'", |
| 6027 | dut->ap_passphrase); |
| 6028 | run_system(dut, buf); |
| 6029 | if (dut->ap_cipher == AP_CCMP_TKIP) |
| 6030 | run_system(dut, "cfg -a AP_CYPHER_2=\"CCMP TKIP\""); |
| 6031 | else if (dut->ap_cipher == AP_TKIP) |
| 6032 | run_system(dut, "cfg -a AP_CYPHER_2=TKIP"); |
| 6033 | else |
| 6034 | run_system(dut, "cfg -a AP_CYPHER_2=CCMP"); |
| 6035 | break; |
| 6036 | case AP_WPA2_EAP: |
| 6037 | case AP_WPA2_EAP_MIXED: |
| 6038 | case AP_WPA_EAP: |
| 6039 | if (dut->ap_key_mgmt == AP_WPA2_EAP) |
| 6040 | run_system(dut, "cfg -a AP_WPA_2=2"); |
| 6041 | else if (dut->ap_key_mgmt == AP_WPA2_EAP_MIXED) |
| 6042 | run_system(dut, "cfg -a AP_WPA_2=3"); |
| 6043 | else |
| 6044 | run_system(dut, "cfg -a AP_WPA_2=1"); |
| 6045 | run_system(dut, "cfg -a AP_SECMODE_2=WPA"); |
| 6046 | run_system(dut, "cfg -a AP_SECFILE_2=EAP"); |
| 6047 | if (dut->ap_cipher == AP_CCMP_TKIP) |
| 6048 | run_system(dut, "cfg -a AP_CYPHER_2=\"CCMP TKIP\""); |
| 6049 | else if (dut->ap_cipher == AP_TKIP) |
| 6050 | run_system(dut, "cfg -a AP_CYPHER_2=TKIP"); |
| 6051 | else |
| 6052 | run_system(dut, "cfg -a AP_CYPHER_2=CCMP"); |
| 6053 | |
| 6054 | snprintf(buf, sizeof(buf), "cfg -a AP_AUTH_SERVER_2=%s", |
| 6055 | dut->ap_radius_ipaddr); |
| 6056 | run_system(dut, buf); |
| 6057 | snprintf(buf, sizeof(buf), "cfg -a AP_AUTH_PORT_2=%d", |
| 6058 | dut->ap_radius_port); |
| 6059 | run_system(dut, buf); |
| 6060 | snprintf(buf, sizeof(buf), "cfg -a AP_AUTH_SECRET_2=%s", |
| 6061 | dut->ap_radius_password); |
| 6062 | run_system(dut, buf); |
| 6063 | break; |
Jouni Malinen | 4cf699f | 2018-06-19 00:46:27 +0300 | [diff] [blame] | 6064 | case AP_WPA2_EAP_OSEN: |
| 6065 | /* TODO */ |
| 6066 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 6067 | "EAP+OSEN not supported"); |
| 6068 | break; |
Jouni Malinen | ad395a2 | 2017-09-01 21:13:46 +0300 | [diff] [blame] | 6069 | case AP_SUITEB: |
| 6070 | /* TODO */ |
| 6071 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 6072 | "SuiteB not supported"); |
| 6073 | break; |
Jouni Malinen | 147b3c3 | 2017-10-09 16:51:54 +0300 | [diff] [blame] | 6074 | case AP_WPA2_OWE: |
| 6075 | /* TODO */ |
| 6076 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 6077 | "OWE not supported"); |
| 6078 | break; |
Jouni Malinen | 6be21c8 | 2018-08-01 18:47:24 +0300 | [diff] [blame] | 6079 | case AP_WPA2_FT_EAP: |
| 6080 | case AP_WPA2_FT_PSK: |
| 6081 | case AP_WPA2_EAP_SHA256: |
| 6082 | case AP_WPA2_PSK_SHA256: |
| 6083 | case AP_WPA2_ENT_FT_EAP: |
| 6084 | /* TODO */ |
| 6085 | send_resp(dut, conn, SIGMA_ERROR, |
| 6086 | "errorCode,Unsupported KeyMgnt value"); |
| 6087 | return 0; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6088 | } |
| 6089 | |
| 6090 | /* wifi0 settings in case of dual */ |
| 6091 | run_system(dut, "cfg -a AP_RADIO_ID=0"); |
| 6092 | run_system(dut, "cfg -a AP_PRIMARY_CH=6"); |
| 6093 | run_system(dut, "cfg -a AP_STARTMODE=dual"); |
| 6094 | run_system(dut, "cfg -a AP_CHMODE=11NGHT40PLUS"); |
| 6095 | run_system(dut, "cfg -a TX_CHAINMASK=7"); |
| 6096 | run_system(dut, "cfg -a RX_CHAINMASK=7"); |
| 6097 | } |
| 6098 | |
| 6099 | switch (dut->ap_pmf) { |
| 6100 | case AP_PMF_DISABLED: |
| 6101 | snprintf(buf, sizeof(buf), "cfg -a AP_PMF=0"); |
| 6102 | run_system(dut, buf); |
| 6103 | break; |
| 6104 | case AP_PMF_OPTIONAL: |
| 6105 | snprintf(buf, sizeof(buf), "cfg -a AP_PMF=1"); |
| 6106 | run_system(dut, buf); |
| 6107 | break; |
| 6108 | case AP_PMF_REQUIRED: |
| 6109 | snprintf(buf, sizeof(buf), "cfg -a AP_PMF=2"); |
| 6110 | run_system(dut, buf); |
| 6111 | break; |
| 6112 | } |
| 6113 | if (dut->ap_add_sha256) { |
| 6114 | snprintf(buf, sizeof(buf), "cfg -a AP_WPA_SHA256=1"); |
| 6115 | run_system(dut, buf); |
| 6116 | } else { |
| 6117 | snprintf(buf, sizeof(buf), "cfg -r AP_WPA_SHA256"); |
| 6118 | run_system(dut, buf); |
| 6119 | } |
| 6120 | |
| 6121 | if (dut->ap_hs2) |
| 6122 | run_system(dut, "cfg -a AP_HOTSPOT=1"); |
| 6123 | else |
| 6124 | run_system(dut, "cfg -r AP_HOTSPOT"); |
| 6125 | |
| 6126 | if (dut->ap_interworking) { |
| 6127 | snprintf(buf, sizeof(buf), "cfg -a AP_HOTSPOT_ANT=%d", |
| 6128 | dut->ap_access_net_type); |
| 6129 | run_system(dut, buf); |
| 6130 | snprintf(buf, sizeof(buf), "cfg -a AP_HOTSPOT_INTERNET=%d", |
| 6131 | dut->ap_internet); |
| 6132 | run_system(dut, buf); |
| 6133 | snprintf(buf, sizeof(buf), "cfg -a AP_HOTSPOT_VENUEGROUP=%d", |
| 6134 | dut->ap_venue_group); |
| 6135 | run_system(dut, buf); |
| 6136 | snprintf(buf, sizeof(buf), "cfg -a AP_HOTSPOT_VENUETYPE=%d", |
| 6137 | dut->ap_venue_type); |
| 6138 | run_system(dut, buf); |
| 6139 | snprintf(buf, sizeof(buf), "cfg -a AP_HOTSPOT_HESSID=%s", |
| 6140 | dut->ap_hessid); |
| 6141 | run_system(dut, buf); |
| 6142 | |
| 6143 | if (dut->ap_roaming_cons[0]) { |
| 6144 | char *second, *rc; |
| 6145 | rc = strdup(dut->ap_roaming_cons); |
| 6146 | if (rc == NULL) |
| 6147 | return 0; |
| 6148 | |
| 6149 | second = strchr(rc, ';'); |
| 6150 | if (second) |
| 6151 | *second++ = '\0'; |
| 6152 | |
| 6153 | snprintf(buf, sizeof(buf), |
| 6154 | "cfg -a AP_HOTSPOT_ROAMINGCONSORTIUM=%s", rc); |
| 6155 | run_system(dut, buf); |
| 6156 | |
| 6157 | if (second) { |
| 6158 | snprintf(buf, sizeof(buf), |
| 6159 | "cfg -a AP_HOTSPOT_ROAMINGCONSORTIUM2" |
| 6160 | "=%s", second); |
| 6161 | run_system(dut, buf); |
| 6162 | } |
| 6163 | free(rc); |
| 6164 | } else { |
| 6165 | run_system(dut, "cfg -r AP_HOTSPOT_ROAMINGCONSORTIUM"); |
| 6166 | run_system(dut, |
| 6167 | "cfg -r AP_HOTSPOT_ROAMINGCONSORTIUM2"); |
| 6168 | } |
| 6169 | } else { |
| 6170 | run_system(dut, "cfg -r AP_HOTSPOT_ANT"); |
| 6171 | run_system(dut, "cfg -r AP_HOTSPOT_INTERNET"); |
| 6172 | run_system(dut, "cfg -r AP_HOTSPOT_VENUEGROUP"); |
| 6173 | run_system(dut, "cfg -r AP_HOTSPOT_VENUETYPE"); |
| 6174 | run_system(dut, "cfg -r AP_HOTSPOT_HESSID"); |
| 6175 | run_system(dut, "cfg -r AP_HOTSPOT_ROAMINGCONSORTIUM"); |
| 6176 | run_system(dut, "cfg -r AP_HOTSPOT_ROAMINGCONSORTIUM2"); |
| 6177 | } |
| 6178 | |
| 6179 | if (dut->ap_proxy_arp) |
| 6180 | run_system(dut, "cfg -a IEEE80211V_PROXYARP=1"); |
| 6181 | else |
| 6182 | run_system(dut, "cfg -a IEEE80211V_PROXYARP=0"); |
| 6183 | if (dut->ap_dgaf_disable) |
| 6184 | run_system(dut, "cfg -a AP_HOTSPOT_DISABLE_DGAF=1"); |
| 6185 | else |
| 6186 | run_system(dut, "cfg -r AP_HOTSPOT_DISABLE_DGAF"); |
| 6187 | |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 6188 | if (strlen(dut->ap_tag_ssid[0])) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6189 | snprintf(buf, sizeof(buf), |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 6190 | "cfg -a AP_SSID_2=%s", dut->ap_tag_ssid[0]); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6191 | run_system(dut, buf); |
| 6192 | |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 6193 | if (dut->ap_tag_key_mgmt[0] == AP2_OSEN) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6194 | run_system(dut, "cfg -a AP_SECMODE_2=WPA"); |
| 6195 | run_system(dut, "cfg -a AP_SECFILE_2=OSEN"); |
| 6196 | |
| 6197 | snprintf(buf, sizeof(buf), "cfg -a AP_AUTH_SERVER_2=%s", |
| 6198 | dut->ap2_radius_ipaddr); |
| 6199 | run_system(dut, buf); |
| 6200 | |
| 6201 | snprintf(buf, sizeof(buf), "cfg -a AP_AUTH_PORT_2=%d", |
| 6202 | dut->ap2_radius_port); |
| 6203 | run_system(dut, buf); |
| 6204 | |
| 6205 | snprintf(buf, sizeof(buf), "cfg -a AP_AUTH_SECRET_2=%s", |
| 6206 | dut->ap2_radius_password); |
| 6207 | run_system(dut, buf); |
| 6208 | } else { |
| 6209 | run_system(dut, "cfg -a AP_SECMODE_2=None"); |
| 6210 | run_system(dut, "cfg -r AP_AUTH_SERVER_2"); |
| 6211 | run_system(dut, "cfg -r AP_AUTH_PORT_2"); |
| 6212 | run_system(dut, "cfg -r AP_AUTH_SECRET_2"); |
| 6213 | } |
| 6214 | |
| 6215 | run_system(dut, "cfg -a AP_STARTMODE=multi"); |
| 6216 | } |
| 6217 | |
| 6218 | run_system(dut, "cfg -c"); |
| 6219 | |
| 6220 | sigma_dut_print(dut, DUT_MSG_INFO, "Starting AP"); |
| 6221 | if (system("apup") != 0) { |
| 6222 | /* to be debugged why apup returns error |
| 6223 | send_resp(dut, conn, SIGMA_ERROR, |
| 6224 | "errorCode,apup failed"); |
| 6225 | return 0; |
| 6226 | */ |
| 6227 | } |
| 6228 | sigma_dut_print(dut, DUT_MSG_INFO, "AP started"); |
| 6229 | |
| 6230 | if (dut->ap_key_mgmt != AP_OPEN) { |
| 6231 | int res; |
| 6232 | /* allow some time for hostapd to start before returning |
| 6233 | * success */ |
| 6234 | usleep(500000); |
| 6235 | if (run_hostapd_cli(dut, "ping") != 0) { |
| 6236 | send_resp(dut, conn, SIGMA_ERROR, |
| 6237 | "errorCode,Failed to talk to hostapd"); |
| 6238 | return 0; |
| 6239 | } |
| 6240 | |
| 6241 | if (dut->ap_hs2 && !dut->ap_anqpserver) { |
| 6242 | /* the cfg app doesn't like ";" in the variables */ |
| 6243 | res = ath_ap_append_hostapd_conf(dut); |
| 6244 | if (res < 0) |
| 6245 | return res; |
| 6246 | |
| 6247 | /* wait for hostapd to be ready */ |
| 6248 | usleep(500000); |
| 6249 | if (run_hostapd_cli(dut, "ping") != 0) { |
| 6250 | send_resp(dut, conn, SIGMA_ERROR, |
| 6251 | "errorCode,Failed to talk to " |
| 6252 | "hostapd"); |
| 6253 | return 0; |
| 6254 | } |
| 6255 | } |
| 6256 | } |
| 6257 | |
| 6258 | ath_ap_set_params(dut); |
| 6259 | |
| 6260 | if (dut->ap_anqpserver) |
| 6261 | return cmd_ath_ap_anqpserver_start(dut); |
| 6262 | |
| 6263 | if (dut->ap2_proxy_arp) |
| 6264 | run_system(dut, "iwpriv ath1 proxy_arp 1"); |
| 6265 | |
| 6266 | if (dut->ap_allow_vht_wep || dut->ap_allow_vht_tkip) { |
| 6267 | snprintf(buf, sizeof(buf), "iwpriv %s htweptkip 1", ifname); |
| 6268 | if (system(buf) != 0) { |
| 6269 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 6270 | "iwpriv htweptkip failed"); |
| 6271 | } |
| 6272 | } |
| 6273 | |
| 6274 | return 1; |
| 6275 | } |
| 6276 | |
| 6277 | |
| 6278 | static int set_ebtables_proxy_arp(struct sigma_dut *dut, const char *chain, |
| 6279 | const char *ifname) |
| 6280 | { |
| 6281 | char buf[200]; |
| 6282 | |
| 6283 | if (!chain || !ifname) |
| 6284 | return -2; |
| 6285 | |
| 6286 | snprintf(buf, sizeof(buf), "ebtables -P %s ACCEPT", chain); |
| 6287 | if (system(buf) != 0) { |
| 6288 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 6289 | "Failed to set ebtables rules, RULE-1, %s", |
| 6290 | chain); |
| 6291 | return -2; |
| 6292 | } |
| 6293 | |
| 6294 | snprintf(buf, sizeof(buf), |
| 6295 | "ebtables -A %s -p ARP -d Broadcast -o %s -j DROP", |
| 6296 | chain, ifname); |
| 6297 | if (system(buf) != 0) { |
| 6298 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 6299 | "Failed to set ebtables rules, RULE-2, %s", |
| 6300 | chain); |
| 6301 | return -2; |
| 6302 | } |
| 6303 | |
| 6304 | snprintf(buf, sizeof(buf), |
| 6305 | "ebtables -A %s -d Multicast -p IPv6 --ip6-protocol ipv6-icmp --ip6-icmp-type neighbor-solicitation -o %s -j DROP", |
| 6306 | chain, ifname); |
| 6307 | if (system(buf) != 0) { |
| 6308 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 6309 | "Failed to set ebtables rules, RULE-3, %s", |
| 6310 | chain); |
| 6311 | return -2; |
| 6312 | } |
| 6313 | |
| 6314 | snprintf(buf, sizeof(buf), |
| 6315 | "ebtables -A %s -d Multicast -p IPv6 --ip6-protocol ipv6-icmp --ip6-icmp-type neighbor-advertisement -o %s -j DROP", |
| 6316 | chain, ifname); |
| 6317 | if (system(buf) != 0) { |
| 6318 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 6319 | "Failed to set ebtables rules, RULE-4, %s", |
| 6320 | chain); |
| 6321 | return -2; |
| 6322 | } |
| 6323 | |
| 6324 | return 0; |
| 6325 | } |
| 6326 | |
| 6327 | |
| 6328 | static int set_ebtables_disable_dgaf(struct sigma_dut *dut, |
| 6329 | const char *chain, |
| 6330 | const char *ifname) |
| 6331 | { |
| 6332 | char buf[200]; |
| 6333 | |
| 6334 | if (!chain || !ifname) |
| 6335 | return -2; |
| 6336 | |
| 6337 | snprintf(buf, sizeof(buf), "ebtables -P %s ACCEPT", chain); |
| 6338 | if (system(buf) != 0) { |
| 6339 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 6340 | "Failed to set ebtables rules, RULE-5, %s", |
| 6341 | chain); |
| 6342 | return -2; |
| 6343 | } |
| 6344 | |
| 6345 | snprintf(buf, sizeof(buf), |
| 6346 | "ebtables -A %s -p ARP -d Broadcast -o %s -j DROP", |
| 6347 | chain, ifname); |
| 6348 | if (system(buf) != 0) { |
| 6349 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 6350 | "Failed to set ebtables rules, RULE-6, %s", |
| 6351 | chain); |
| 6352 | return -2; |
| 6353 | } |
| 6354 | |
| 6355 | snprintf(buf, sizeof(buf), |
| 6356 | "ebtables -A %s -p IPv4 -d Multicast -o %s -j DROP", |
| 6357 | chain, ifname); |
| 6358 | if (system(buf) != 0) { |
| 6359 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 6360 | "Failed to set ebtables rules, RULE-7, %s", |
| 6361 | chain); |
| 6362 | return -2; |
| 6363 | } |
| 6364 | |
| 6365 | snprintf(buf, sizeof(buf), |
| 6366 | "ebtables -A %s -p IPv6 -d Multicast -o %s -j DROP", |
| 6367 | chain, ifname); |
| 6368 | if (system(buf) != 0) { |
| 6369 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 6370 | "Failed to set ebtables rules, RULE-8, %s", |
| 6371 | chain); |
| 6372 | return -2; |
| 6373 | } |
| 6374 | |
| 6375 | return 0; |
| 6376 | } |
| 6377 | |
| 6378 | |
| 6379 | static int check_channel(int channel) |
| 6380 | { |
| 6381 | int channel_list[] = { 36, 40, 44, 48, 52, 60, 64, 100, 104, 108, 112, |
| 6382 | 116, 120, 124, 128, 132, 140, 144, 149, 153, 157, |
| 6383 | 161, 165 }; |
| 6384 | int num_chan = sizeof(channel_list) / sizeof(int); |
| 6385 | int i; |
| 6386 | |
| 6387 | for (i = 0; i < num_chan; i++) { |
| 6388 | if (channel == channel_list[i]) |
| 6389 | return i; |
| 6390 | } |
| 6391 | |
| 6392 | return -1; |
| 6393 | } |
| 6394 | |
| 6395 | |
| 6396 | static int get_oper_centr_freq_seq_idx(int chwidth, int channel) |
| 6397 | { |
| 6398 | int ch_base; |
| 6399 | int period; |
| 6400 | |
| 6401 | if (check_channel(channel) < 0) |
| 6402 | return -1; |
| 6403 | |
| 6404 | if (channel >= 36 && channel <= 64) |
| 6405 | ch_base = 36; |
| 6406 | else if (channel >= 100 && channel <= 144) |
| 6407 | ch_base = 100; |
| 6408 | else |
| 6409 | ch_base = 149; |
| 6410 | |
| 6411 | period = channel % ch_base * 5 / chwidth; |
| 6412 | return ch_base + period * chwidth / 5 + (chwidth - 20) / 10; |
| 6413 | } |
| 6414 | |
| 6415 | |
| 6416 | static int is_ht40plus_chan(int chan) |
| 6417 | { |
| 6418 | return chan == 36 || chan == 44 || chan == 52 || chan == 60 || |
| 6419 | chan == 100 || chan == 108 || chan == 116 || chan == 124 || |
| 6420 | chan == 132 || chan == 149 || chan == 157; |
| 6421 | } |
| 6422 | |
| 6423 | |
| 6424 | static int is_ht40minus_chan(int chan) |
| 6425 | { |
| 6426 | return chan == 40 || chan == 48 || chan == 56 || chan == 64 || |
| 6427 | chan == 104 || chan == 112 || chan == 120 || chan == 128 || |
| 6428 | chan == 136 || chan == 153 || chan == 161; |
| 6429 | } |
| 6430 | |
| 6431 | |
Mohammed Shafi Shajakhan | b53d8f9 | 2017-02-28 09:05:15 +0530 | [diff] [blame] | 6432 | static int get_5g_channel_freq(int chan) |
| 6433 | { |
| 6434 | return 5000 + chan * 5; |
| 6435 | } |
| 6436 | |
| 6437 | |
Jouni Malinen | 3d633da | 2017-09-14 22:19:21 +0300 | [diff] [blame] | 6438 | static const char * hostapd_cipher_name(enum ap_cipher cipher) |
| 6439 | { |
| 6440 | switch (cipher) { |
| 6441 | case AP_CCMP: |
| 6442 | return "CCMP"; |
| 6443 | case AP_TKIP: |
| 6444 | return "TKIP"; |
| 6445 | case AP_CCMP_TKIP: |
| 6446 | return "CCMP TKIP"; |
| 6447 | case AP_GCMP_256: |
| 6448 | return "GCMP-256"; |
| 6449 | case AP_GCMP_128: |
| 6450 | return "GCMP"; |
| 6451 | case AP_CCMP_256: |
| 6452 | return "CCMP-256"; |
Jouni Malinen | d538c78 | 2017-11-17 12:13:04 +0200 | [diff] [blame] | 6453 | case AP_CCMP_128_GCMP_256: |
| 6454 | return "CCMP GCMP-256"; |
Jouni Malinen | 3d633da | 2017-09-14 22:19:21 +0300 | [diff] [blame] | 6455 | default: |
| 6456 | return "UNKNOWN"; |
| 6457 | } |
| 6458 | } |
| 6459 | |
| 6460 | |
| 6461 | static const char * |
| 6462 | hostapd_group_mgmt_cipher_name(enum ap_group_mgmt_cipher cipher) |
| 6463 | { |
| 6464 | switch (cipher) { |
| 6465 | case AP_BIP_GMAC_256: |
Jouni Malinen | 57887a2 | 2017-10-10 20:43:25 +0300 | [diff] [blame] | 6466 | return "BIP-GMAC-256"; |
Jouni Malinen | 3d633da | 2017-09-14 22:19:21 +0300 | [diff] [blame] | 6467 | case AP_BIP_CMAC_256: |
| 6468 | return "BIP-CMAC-256"; |
| 6469 | case AP_BIP_GMAC_128: |
| 6470 | return "BIP-GMAC-128"; |
| 6471 | case AP_BIP_CMAC_128: |
| 6472 | return "AES-128-CMAC"; |
| 6473 | default: |
| 6474 | return "UNKNOWN"; |
| 6475 | } |
| 6476 | } |
| 6477 | |
| 6478 | |
Jouni Malinen | a326d7b | 2017-09-04 13:46:02 +0300 | [diff] [blame] | 6479 | int cmd_ap_config_commit(struct sigma_dut *dut, struct sigma_conn *conn, |
| 6480 | struct sigma_cmd *cmd) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6481 | { |
| 6482 | /* const char *name = get_param(cmd, "NAME"); */ |
| 6483 | FILE *f; |
| 6484 | const char *ifname; |
| 6485 | char buf[500]; |
| 6486 | char path[100]; |
| 6487 | enum driver_type drv; |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 6488 | const char *key_mgmt; |
Srinivas Dasari | a1deeaa | 2018-06-18 22:54:04 +0530 | [diff] [blame] | 6489 | #ifdef ANDROID |
| 6490 | struct group *gr; |
| 6491 | #endif /* ANDROID */ |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6492 | |
| 6493 | drv = get_driver_type(); |
| 6494 | |
| 6495 | if (dut->mode == SIGMA_MODE_STATION) { |
| 6496 | stop_sta_mode(dut); |
| 6497 | sleep(1); |
| 6498 | } |
| 6499 | |
| 6500 | if (dut->mode == SIGMA_MODE_SNIFFER && dut->sniffer_ifname) { |
| 6501 | snprintf(buf, sizeof(buf), "ifconfig %s down", |
| 6502 | dut->sniffer_ifname); |
| 6503 | if (system(buf) != 0) { |
| 6504 | sigma_dut_print(dut, DUT_MSG_INFO, |
| 6505 | "Failed to run '%s'", buf); |
| 6506 | } |
| 6507 | snprintf(buf, sizeof(buf), "iw dev %s set type station", |
| 6508 | dut->sniffer_ifname); |
| 6509 | if (system(buf) != 0) { |
| 6510 | sigma_dut_print(dut, DUT_MSG_INFO, |
| 6511 | "Failed to run '%s'", buf); |
| 6512 | } |
| 6513 | } |
| 6514 | |
| 6515 | dut->mode = SIGMA_MODE_AP; |
| 6516 | |
| 6517 | if (drv == DRIVER_ATHEROS) |
| 6518 | return cmd_ath_ap_config_commit(dut, conn, cmd); |
| 6519 | if (drv == DRIVER_WCN) |
| 6520 | return cmd_wcn_ap_config_commit(dut, conn, cmd); |
| 6521 | if (drv == DRIVER_OPENWRT) |
| 6522 | return cmd_owrt_ap_config_commit(dut, conn, cmd); |
| 6523 | |
| 6524 | f = fopen(SIGMA_TMPDIR "/sigma_dut-ap.conf", "w"); |
| 6525 | if (f == NULL) { |
| 6526 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 6527 | "%s: Failed to open sigma_dut-ap.conf", |
| 6528 | __func__); |
| 6529 | return -2; |
| 6530 | } |
| 6531 | switch (dut->ap_mode) { |
| 6532 | case AP_11g: |
| 6533 | case AP_11b: |
| 6534 | case AP_11ng: |
Pradeep Reddy Potteti | 08eaeba | 2017-06-14 12:43:19 +0530 | [diff] [blame] | 6535 | ifname = (drv == DRIVER_MAC80211) ? "wlan0" : "ath0"; |
| 6536 | if ((drv == DRIVER_QNXNTO || drv == DRIVER_LINUX_WCN) && |
| 6537 | sigma_main_ifname) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6538 | ifname = sigma_main_ifname; |
| 6539 | fprintf(f, "hw_mode=g\n"); |
| 6540 | break; |
| 6541 | case AP_11a: |
| 6542 | case AP_11na: |
| 6543 | case AP_11ac: |
Pradeep Reddy Potteti | 08eaeba | 2017-06-14 12:43:19 +0530 | [diff] [blame] | 6544 | if (drv == DRIVER_QNXNTO || drv == DRIVER_LINUX_WCN) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6545 | if (sigma_main_ifname) |
| 6546 | ifname = sigma_main_ifname; |
| 6547 | else |
| 6548 | ifname = "wlan0"; |
Pradeep Reddy Potteti | 08eaeba | 2017-06-14 12:43:19 +0530 | [diff] [blame] | 6549 | } else if (drv == DRIVER_MAC80211) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6550 | if (if_nametoindex("wlan1") > 0) |
| 6551 | ifname = "wlan1"; |
| 6552 | else |
| 6553 | ifname = "wlan0"; |
| 6554 | } else { |
| 6555 | ifname = get_main_ifname(); |
| 6556 | } |
| 6557 | fprintf(f, "hw_mode=a\n"); |
| 6558 | break; |
| 6559 | default: |
| 6560 | fclose(f); |
| 6561 | return -1; |
| 6562 | } |
Jouni Malinen | d6bf1b4 | 2017-06-23 17:51:01 +0300 | [diff] [blame] | 6563 | if (dut->hostapd_ifname) |
| 6564 | ifname = dut->hostapd_ifname; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6565 | |
Sreelakshmi Konamki | b692f10 | 2016-04-26 19:47:00 +0530 | [diff] [blame] | 6566 | if (drv == DRIVER_MAC80211 || drv == DRIVER_LINUX_WCN) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6567 | fprintf(f, "driver=nl80211\n"); |
| 6568 | |
Sreelakshmi Konamki | b692f10 | 2016-04-26 19:47:00 +0530 | [diff] [blame] | 6569 | if ((drv == DRIVER_MAC80211 || drv == DRIVER_QNXNTO || |
| 6570 | drv == DRIVER_LINUX_WCN) && |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6571 | (dut->ap_mode == AP_11ng || dut->ap_mode == AP_11na)) { |
Tamizh chelvam | 431c600 | 2017-03-07 17:07:16 +0530 | [diff] [blame] | 6572 | int ht40plus = 0, ht40minus = 0, tx_stbc = 0; |
| 6573 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6574 | fprintf(f, "ieee80211n=1\n"); |
Pradeep Reddy Potteti | bf8af29 | 2017-02-15 15:28:39 +0530 | [diff] [blame] | 6575 | if (dut->ap_mode == AP_11ng && |
| 6576 | (dut->ap_chwidth == AP_40 || |
| 6577 | (dut->ap_chwidth == AP_AUTO && |
| 6578 | dut->default_11ng_ap_chwidth == AP_40))) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6579 | if (dut->ap_channel >= 1 && dut->ap_channel <= 7) |
Tamizh chelvam | 431c600 | 2017-03-07 17:07:16 +0530 | [diff] [blame] | 6580 | ht40plus = 1; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6581 | else if (dut->ap_channel >= 8 && dut->ap_channel <= 11) |
Tamizh chelvam | 431c600 | 2017-03-07 17:07:16 +0530 | [diff] [blame] | 6582 | ht40minus = 1; |
| 6583 | fprintf(f, "obss_interval=300\n"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6584 | } |
| 6585 | |
| 6586 | /* configure ht_capab based on channel width */ |
| 6587 | if (dut->ap_mode == AP_11na && |
| 6588 | (dut->ap_chwidth == AP_40 || |
| 6589 | (dut->ap_chwidth == AP_AUTO && |
Pradeep Reddy Potteti | bf8af29 | 2017-02-15 15:28:39 +0530 | [diff] [blame] | 6590 | dut->default_11na_ap_chwidth == AP_40))) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6591 | if (is_ht40plus_chan(dut->ap_channel)) |
Tamizh chelvam | 431c600 | 2017-03-07 17:07:16 +0530 | [diff] [blame] | 6592 | ht40plus = 1; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6593 | else if (is_ht40minus_chan(dut->ap_channel)) |
Tamizh chelvam | 431c600 | 2017-03-07 17:07:16 +0530 | [diff] [blame] | 6594 | ht40minus = 1; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6595 | } |
Mohammed Shafi Shajakhan | 31d8a15 | 2016-06-02 20:10:55 +0530 | [diff] [blame] | 6596 | |
| 6597 | if (dut->ap_tx_stbc) |
Tamizh chelvam | 431c600 | 2017-03-07 17:07:16 +0530 | [diff] [blame] | 6598 | tx_stbc = 1; |
Mohammed Shafi Shajakhan | 31d8a15 | 2016-06-02 20:10:55 +0530 | [diff] [blame] | 6599 | |
Pradeep Reddy Potteti | 4b0cdee | 2017-03-15 12:37:33 +0530 | [diff] [blame] | 6600 | /* Overwrite the ht_capab with offset value if configured */ |
| 6601 | if (dut->ap_chwidth == AP_40 && |
| 6602 | dut->ap_chwidth_offset == SEC_CH_40ABOVE) { |
| 6603 | ht40plus = 1; |
| 6604 | ht40minus = 0; |
| 6605 | } else if (dut->ap_chwidth == AP_40 && |
| 6606 | dut->ap_chwidth_offset == SEC_CH_40BELOW) { |
| 6607 | ht40minus = 1; |
| 6608 | ht40plus = 0; |
| 6609 | } |
| 6610 | |
Tamizh chelvam | 431c600 | 2017-03-07 17:07:16 +0530 | [diff] [blame] | 6611 | fprintf(f, "ht_capab=%s%s%s\n", |
| 6612 | ht40plus ? "[HT40+]" : "", |
| 6613 | ht40minus ? "[HT40-]" : "", |
| 6614 | tx_stbc ? "[TX-STBC]" : ""); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6615 | } |
| 6616 | |
Sreelakshmi Konamki | b692f10 | 2016-04-26 19:47:00 +0530 | [diff] [blame] | 6617 | if ((drv == DRIVER_MAC80211 || drv == DRIVER_QNXNTO || |
| 6618 | drv == DRIVER_LINUX_WCN) && |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6619 | dut->ap_mode == AP_11ac) { |
| 6620 | fprintf(f, "ieee80211ac=1\n" |
| 6621 | "ieee80211n=1\n" |
| 6622 | "ht_capab=[HT40+]\n"); |
| 6623 | } |
| 6624 | |
Sreelakshmi Konamki | b692f10 | 2016-04-26 19:47:00 +0530 | [diff] [blame] | 6625 | if ((drv == DRIVER_MAC80211 || drv == DRIVER_QNXNTO || |
| 6626 | drv == DRIVER_LINUX_WCN) && |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6627 | (dut->ap_mode == AP_11ac || dut->ap_mode == AP_11na)) { |
| 6628 | if (dut->ap_countrycode[0]) { |
| 6629 | fprintf(f, "country_code=%s\n", dut->ap_countrycode); |
| 6630 | fprintf(f, "ieee80211d=1\n"); |
| 6631 | fprintf(f, "ieee80211h=1\n"); |
| 6632 | } |
| 6633 | } |
| 6634 | |
| 6635 | fprintf(f, "interface=%s\n", ifname); |
| 6636 | if (dut->bridge) |
| 6637 | fprintf(f, "bridge=%s\n", dut->bridge); |
| 6638 | fprintf(f, "channel=%d\n", dut->ap_channel); |
| 6639 | |
| 6640 | if (sigma_hapd_ctrl) |
| 6641 | fprintf(f, "ctrl_interface=%s\n", sigma_hapd_ctrl); |
| 6642 | else |
| 6643 | fprintf(f, "ctrl_interface=/var/run/hostapd\n"); |
| 6644 | |
| 6645 | if (dut->ap_ssid[0]) |
| 6646 | fprintf(f, "ssid=%s\n", dut->ap_ssid); |
| 6647 | else |
| 6648 | fprintf(f, "ssid=QCA AP OOB\n"); |
| 6649 | if (dut->ap_bcnint) |
| 6650 | fprintf(f, "beacon_int=%d\n", dut->ap_bcnint); |
| 6651 | |
| 6652 | switch (dut->ap_key_mgmt) { |
| 6653 | case AP_OPEN: |
| 6654 | if (dut->ap_cipher == AP_WEP) |
| 6655 | fprintf(f, "wep_key0=%s\n", dut->ap_wepkey); |
| 6656 | break; |
| 6657 | case AP_WPA2_PSK: |
| 6658 | case AP_WPA2_PSK_MIXED: |
| 6659 | case AP_WPA_PSK: |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 6660 | case AP_WPA2_SAE: |
| 6661 | case AP_WPA2_PSK_SAE: |
Jouni Malinen | 6be21c8 | 2018-08-01 18:47:24 +0300 | [diff] [blame] | 6662 | case AP_WPA2_PSK_SHA256: |
| 6663 | case AP_WPA2_FT_PSK: |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 6664 | if (dut->ap_key_mgmt == AP_WPA2_PSK || |
| 6665 | dut->ap_key_mgmt == AP_WPA2_SAE || |
Jouni Malinen | 6be21c8 | 2018-08-01 18:47:24 +0300 | [diff] [blame] | 6666 | dut->ap_key_mgmt == AP_WPA2_PSK_SAE || |
| 6667 | dut->ap_key_mgmt == AP_WPA2_PSK_SHA256 || |
| 6668 | dut->ap_key_mgmt == AP_WPA2_FT_PSK) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6669 | fprintf(f, "wpa=2\n"); |
| 6670 | else if (dut->ap_key_mgmt == AP_WPA2_PSK_MIXED) |
| 6671 | fprintf(f, "wpa=3\n"); |
| 6672 | else |
| 6673 | fprintf(f, "wpa=1\n"); |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 6674 | if (dut->ap_key_mgmt == AP_WPA2_SAE) |
| 6675 | key_mgmt = "SAE"; |
| 6676 | else if (dut->ap_key_mgmt == AP_WPA2_PSK_SAE) |
| 6677 | key_mgmt = "WPA-PSK SAE"; |
| 6678 | else |
| 6679 | key_mgmt = "WPA-PSK"; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6680 | switch (dut->ap_pmf) { |
| 6681 | case AP_PMF_DISABLED: |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 6682 | fprintf(f, "wpa_key_mgmt=%s%s\n", key_mgmt, |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6683 | dut->ap_add_sha256 ? " WPA-PSK-SHA256" : ""); |
| 6684 | break; |
| 6685 | case AP_PMF_OPTIONAL: |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 6686 | fprintf(f, "wpa_key_mgmt=%s%s\n", key_mgmt, |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6687 | dut->ap_add_sha256 ? " WPA-PSK-SHA256" : ""); |
| 6688 | break; |
| 6689 | case AP_PMF_REQUIRED: |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 6690 | if (dut->ap_key_mgmt == AP_WPA2_SAE) |
| 6691 | key_mgmt = "SAE"; |
| 6692 | else if (dut->ap_key_mgmt == AP_WPA2_PSK_SAE) |
| 6693 | key_mgmt = "WPA-PSK-SHA256 SAE"; |
| 6694 | else |
| 6695 | key_mgmt = "WPA-PSK-SHA256"; |
| 6696 | fprintf(f, "wpa_key_mgmt=%s\n", key_mgmt); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6697 | break; |
| 6698 | } |
Jouni Malinen | 6be21c8 | 2018-08-01 18:47:24 +0300 | [diff] [blame] | 6699 | if (dut->ap_key_mgmt == AP_WPA2_PSK_SHA256) |
| 6700 | fprintf(f, "wpa_key_mgmt=WPA-PSK-SHA256\n"); |
| 6701 | else if (dut->ap_key_mgmt == AP_WPA2_FT_PSK) |
| 6702 | fprintf(f, "wpa_key_mgmt=FT-PSK\n"); |
Jouni Malinen | 2ba2449 | 2017-11-17 12:43:59 +0200 | [diff] [blame] | 6703 | fprintf(f, "wpa_pairwise=%s\n", |
| 6704 | hostapd_cipher_name(dut->ap_cipher)); |
| 6705 | if (dut->ap_group_cipher != AP_NO_GROUP_CIPHER_SET) |
| 6706 | fprintf(f, "group_cipher=%s\n", |
| 6707 | hostapd_cipher_name(dut->ap_group_cipher)); |
Jouni Malinen | 2126f42 | 2017-10-11 23:24:33 +0300 | [diff] [blame] | 6708 | if (dut->ap_key_mgmt == AP_WPA2_SAE) |
| 6709 | fprintf(f, "sae_password=%s\n", dut->ap_passphrase); |
Jouni Malinen | 6337062 | 2017-11-18 17:47:13 +0200 | [diff] [blame] | 6710 | else if (!dut->ap_passphrase[0] && dut->ap_psk[0]) |
| 6711 | fprintf(f, "wpa_psk=%s", dut->ap_psk); |
Jouni Malinen | 2126f42 | 2017-10-11 23:24:33 +0300 | [diff] [blame] | 6712 | else |
| 6713 | fprintf(f, "wpa_passphrase=%s\n", dut->ap_passphrase); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6714 | break; |
| 6715 | case AP_WPA2_EAP: |
| 6716 | case AP_WPA2_EAP_MIXED: |
| 6717 | case AP_WPA_EAP: |
Jouni Malinen | 4cf699f | 2018-06-19 00:46:27 +0300 | [diff] [blame] | 6718 | case AP_WPA2_EAP_OSEN: |
Jouni Malinen | 6be21c8 | 2018-08-01 18:47:24 +0300 | [diff] [blame] | 6719 | case AP_WPA2_EAP_SHA256: |
| 6720 | case AP_WPA2_FT_EAP: |
| 6721 | case AP_WPA2_ENT_FT_EAP: |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6722 | fprintf(f, "ieee8021x=1\n"); |
Jouni Malinen | 4cf699f | 2018-06-19 00:46:27 +0300 | [diff] [blame] | 6723 | if (dut->ap_key_mgmt == AP_WPA2_EAP || |
Jouni Malinen | 6be21c8 | 2018-08-01 18:47:24 +0300 | [diff] [blame] | 6724 | dut->ap_key_mgmt == AP_WPA2_EAP_OSEN || |
| 6725 | dut->ap_key_mgmt == AP_WPA2_EAP_SHA256 || |
| 6726 | dut->ap_key_mgmt == AP_WPA2_FT_EAP || |
| 6727 | dut->ap_key_mgmt == AP_WPA2_ENT_FT_EAP) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6728 | fprintf(f, "wpa=2\n"); |
| 6729 | else if (dut->ap_key_mgmt == AP_WPA2_EAP_MIXED) |
| 6730 | fprintf(f, "wpa=3\n"); |
| 6731 | else |
| 6732 | fprintf(f, "wpa=1\n"); |
| 6733 | switch (dut->ap_pmf) { |
| 6734 | case AP_PMF_DISABLED: |
| 6735 | fprintf(f, "wpa_key_mgmt=WPA-EAP%s\n", |
| 6736 | dut->ap_add_sha256 ? " WPA-EAP-SHA256" : ""); |
| 6737 | break; |
| 6738 | case AP_PMF_OPTIONAL: |
Jouni Malinen | 4cf699f | 2018-06-19 00:46:27 +0300 | [diff] [blame] | 6739 | fprintf(f, "wpa_key_mgmt=WPA-EAP%s%s\n", |
| 6740 | dut->ap_add_sha256 ? " WPA-EAP-SHA256" : "", |
| 6741 | dut->ap_key_mgmt == AP_WPA2_EAP_OSEN ? " OSEN" : |
| 6742 | ""); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6743 | break; |
| 6744 | case AP_PMF_REQUIRED: |
Jouni Malinen | 4cf699f | 2018-06-19 00:46:27 +0300 | [diff] [blame] | 6745 | fprintf(f, "wpa_key_mgmt=WPA-EAP-SHA256%s\n", |
| 6746 | dut->ap_key_mgmt == AP_WPA2_EAP_OSEN ? " OSEN" : |
| 6747 | ""); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6748 | break; |
| 6749 | } |
Jouni Malinen | 6be21c8 | 2018-08-01 18:47:24 +0300 | [diff] [blame] | 6750 | if (dut->ap_key_mgmt == AP_WPA2_EAP_SHA256) |
| 6751 | fprintf(f, "wpa_key_mgmt=WPA-EAP-SHA256\n"); |
| 6752 | else if (dut->ap_key_mgmt == AP_WPA2_FT_EAP) |
| 6753 | fprintf(f, "wpa_key_mgmt=FT-EAP\n"); |
| 6754 | else if (dut->ap_key_mgmt == AP_WPA2_ENT_FT_EAP) |
| 6755 | fprintf(f, "wpa_key_mgmt=FT-EAP WPA-EAP\n"); |
Jouni Malinen | 2ba2449 | 2017-11-17 12:43:59 +0200 | [diff] [blame] | 6756 | fprintf(f, "wpa_pairwise=%s\n", |
| 6757 | hostapd_cipher_name(dut->ap_cipher)); |
| 6758 | if (dut->ap_group_cipher != AP_NO_GROUP_CIPHER_SET) |
| 6759 | fprintf(f, "group_cipher=%s\n", |
| 6760 | hostapd_cipher_name(dut->ap_group_cipher)); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6761 | fprintf(f, "auth_server_addr=%s\n", dut->ap_radius_ipaddr); |
| 6762 | if (dut->ap_radius_port) |
| 6763 | fprintf(f, "auth_server_port=%d\n", |
| 6764 | dut->ap_radius_port); |
| 6765 | fprintf(f, "auth_server_shared_secret=%s\n", |
| 6766 | dut->ap_radius_password); |
Jouni Malinen | 1a2bc99 | 2018-06-22 11:50:59 +0300 | [diff] [blame] | 6767 | if (dut->program == PROGRAM_HS2_R3) { |
| 6768 | fprintf(f, "radius_das_port=3799\n"); |
| 6769 | fprintf(f, "radius_das_client=0.0.0.0 %s\n", |
| 6770 | dut->ap_radius_password); |
| 6771 | fprintf(f, "radius_das_require_event_timestamp=1\n"); |
| 6772 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6773 | break; |
Jouni Malinen | ad395a2 | 2017-09-01 21:13:46 +0300 | [diff] [blame] | 6774 | case AP_SUITEB: |
| 6775 | fprintf(f, "ieee8021x=1\n"); |
| 6776 | fprintf(f, "wpa=2\n"); |
| 6777 | fprintf(f, "wpa_key_mgmt=WPA-EAP-SUITE-B-192\n"); |
Jouni Malinen | 3d633da | 2017-09-14 22:19:21 +0300 | [diff] [blame] | 6778 | fprintf(f, "wpa_pairwise=%s\n", |
| 6779 | hostapd_cipher_name(dut->ap_cipher)); |
Jouni Malinen | 2ba2449 | 2017-11-17 12:43:59 +0200 | [diff] [blame] | 6780 | if (dut->ap_group_cipher != AP_NO_GROUP_CIPHER_SET) |
| 6781 | fprintf(f, "group_cipher=%s\n", |
| 6782 | hostapd_cipher_name(dut->ap_group_cipher)); |
Jouni Malinen | 3d633da | 2017-09-14 22:19:21 +0300 | [diff] [blame] | 6783 | if (dut->ap_group_mgmt_cipher != AP_NO_GROUP_MGMT_CIPHER_SET) |
| 6784 | fprintf(f, "group_mgmt_cipher=%s\n", |
| 6785 | hostapd_group_mgmt_cipher_name( |
| 6786 | dut->ap_group_mgmt_cipher)); |
Jouni Malinen | ad395a2 | 2017-09-01 21:13:46 +0300 | [diff] [blame] | 6787 | fprintf(f, "auth_server_addr=%s\n", dut->ap_radius_ipaddr); |
| 6788 | if (dut->ap_radius_port) |
| 6789 | fprintf(f, "auth_server_port=%d\n", |
| 6790 | dut->ap_radius_port); |
| 6791 | fprintf(f, "auth_server_shared_secret=%s\n", |
| 6792 | dut->ap_radius_password); |
| 6793 | break; |
Jouni Malinen | 147b3c3 | 2017-10-09 16:51:54 +0300 | [diff] [blame] | 6794 | case AP_WPA2_OWE: |
| 6795 | fprintf(f, "wpa=2\n"); |
| 6796 | fprintf(f, "wpa_key_mgmt=OWE\n"); |
| 6797 | fprintf(f, "rsn_pairwise=%s\n", |
| 6798 | hostapd_cipher_name(dut->ap_cipher)); |
Jouni Malinen | 72461d4 | 2017-10-10 19:20:45 +0300 | [diff] [blame] | 6799 | if (dut->ap_sae_groups) |
| 6800 | fprintf(f, "owe_groups=%s\n", dut->ap_sae_groups); |
Jouni Malinen | 147b3c3 | 2017-10-09 16:51:54 +0300 | [diff] [blame] | 6801 | break; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6802 | } |
| 6803 | |
Anilkumar Kolli | f0fd599 | 2017-02-23 12:54:01 +0530 | [diff] [blame] | 6804 | if (dut->ap_rsn_preauth) |
| 6805 | fprintf(f, "rsn_preauth=1\n"); |
| 6806 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6807 | switch (dut->ap_pmf) { |
| 6808 | case AP_PMF_DISABLED: |
| 6809 | break; |
| 6810 | case AP_PMF_OPTIONAL: |
| 6811 | fprintf(f, "ieee80211w=1\n"); |
Jouni Malinen | 1287cd7 | 2018-01-04 17:08:01 +0200 | [diff] [blame] | 6812 | if (dut->ap_key_mgmt == AP_WPA2_PSK_SAE) |
| 6813 | fprintf(f, "sae_require_mfp=1\n"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6814 | break; |
| 6815 | case AP_PMF_REQUIRED: |
| 6816 | fprintf(f, "ieee80211w=2\n"); |
| 6817 | break; |
| 6818 | } |
| 6819 | |
Jouni Malinen | 6be21c8 | 2018-08-01 18:47:24 +0300 | [diff] [blame] | 6820 | if (ap_ft_enabled(dut)) { |
| 6821 | unsigned char own_addr[ETH_ALEN]; |
| 6822 | |
| 6823 | fprintf(f, "mobility_domain=%s\n", dut->ap_mobility_domain); |
| 6824 | fprintf(f, "ft_over_ds=0\n"); |
| 6825 | fprintf(f, "nas_identifier=nas1.example.com\n"); |
| 6826 | if (get_hwaddr(ifname, own_addr) < 0) { |
| 6827 | memset(own_addr, 0, ETH_ALEN); |
| 6828 | own_addr[0] = 0x02; |
| 6829 | } |
| 6830 | fprintf(f, "r1_key_holder=%02x%02x%02x%02x%02x%02x\n", |
| 6831 | own_addr[0], own_addr[1], own_addr[2], |
| 6832 | own_addr[3], own_addr[4], own_addr[5]); |
| 6833 | fprintf(f, "ft_psk_generate_local=1\n"); |
| 6834 | fprintf(f, "pmk_r1_push=0\n"); |
| 6835 | fprintf(f, |
| 6836 | "r0kh=ff:ff:ff:ff:ff:ff * 00112233445566778899aabbccddeeff00112233445566778899aabbccddeeff"); |
| 6837 | fprintf(f, |
| 6838 | "r1kh=00:00:00:00:00:00 00:00:00:00:00:00 00112233445566778899aabbccddeeff00112233445566778899aabbccddeeff"); |
| 6839 | } |
| 6840 | |
Jouni Malinen | 3c367e8 | 2017-06-23 17:01:47 +0300 | [diff] [blame] | 6841 | if (dut->rsne_override) |
| 6842 | fprintf(f, "own_ie_override=%s\n", dut->rsne_override); |
| 6843 | |
Jouni Malinen | 6814313 | 2017-09-02 02:34:08 +0300 | [diff] [blame] | 6844 | if (dut->sae_commit_override) |
| 6845 | fprintf(f, "sae_commit_override=%s\n", |
| 6846 | dut->sae_commit_override); |
| 6847 | |
Jouni Malinen | ed670f4 | 2017-08-31 01:39:28 +0300 | [diff] [blame] | 6848 | if (dut->ap_sae_groups) |
| 6849 | fprintf(f, "sae_groups=%s\n", dut->ap_sae_groups); |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 6850 | |
Jouni Malinen | 2f524ce | 2017-08-31 01:43:29 +0300 | [diff] [blame] | 6851 | if (dut->sae_anti_clogging_threshold >= 0) |
| 6852 | fprintf(f, "sae_anti_clogging_threshold=%d\n", |
| 6853 | dut->sae_anti_clogging_threshold); |
Jouni Malinen | b347db0 | 2017-09-02 01:36:03 +0300 | [diff] [blame] | 6854 | if (dut->sae_reflection) |
| 6855 | fprintf(f, "sae_reflection_attack=1\n"); |
Jouni Malinen | 2f524ce | 2017-08-31 01:43:29 +0300 | [diff] [blame] | 6856 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6857 | if (dut->ap_p2p_mgmt) |
| 6858 | fprintf(f, "manage_p2p=1\n"); |
| 6859 | |
| 6860 | if (dut->ap_tdls_prohibit || dut->ap_l2tif) |
| 6861 | fprintf(f, "tdls_prohibit=1\n"); |
| 6862 | if (dut->ap_tdls_prohibit_chswitch || dut->ap_l2tif) |
| 6863 | fprintf(f, "tdls_prohibit_chan_switch=1\n"); |
| 6864 | if (dut->ap_p2p_cross_connect >= 0) { |
| 6865 | fprintf(f, "manage_p2p=1\n" |
| 6866 | "allow_cross_connection=%d\n", |
| 6867 | dut->ap_p2p_cross_connect); |
| 6868 | } |
| 6869 | |
| 6870 | if (dut->ap_l2tif || dut->ap_proxy_arp) { |
| 6871 | if (!dut->bridge) { |
| 6872 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 6873 | "Bridge must be configured. Run with -b <brname>."); |
| 6874 | fclose(f); |
| 6875 | return -2; |
| 6876 | } |
| 6877 | fprintf(f, "ap_isolate=1\n"); |
| 6878 | } |
| 6879 | |
| 6880 | if (dut->ap_proxy_arp) |
| 6881 | fprintf(f, "proxy_arp=1\n"); |
| 6882 | |
Pradeep Reddy POTTETI | 0d3db63 | 2016-03-11 15:21:11 +0530 | [diff] [blame] | 6883 | if (dut->ap_wme) |
| 6884 | fprintf(f, "wmm_enabled=1\n"); |
| 6885 | |
Mohammed Shafi Shajakhan | 02e3b82 | 2017-02-23 04:15:02 +0530 | [diff] [blame] | 6886 | if (dut->ap_wmmps == AP_WMMPS_ON) |
| 6887 | fprintf(f, "uapsd_advertisement_enabled=1\n"); |
| 6888 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6889 | if (dut->ap_hs2) { |
| 6890 | if (dut->ap_bss_load) { |
| 6891 | char *bss_load; |
| 6892 | |
| 6893 | switch (dut->ap_bss_load) { |
| 6894 | case -1: |
| 6895 | bss_load = "bss_load_update_period=10"; |
| 6896 | break; |
| 6897 | case 1: |
| 6898 | /* STA count: 1, CU: 50, AAC: 65535 */ |
| 6899 | bss_load = "bss_load_test=1:50:65535"; |
| 6900 | break; |
| 6901 | case 2: |
| 6902 | /* STA count: 1, CU: 200, AAC: 65535 */ |
| 6903 | bss_load = "bss_load_test=1:200:65535"; |
| 6904 | break; |
| 6905 | case 3: |
| 6906 | /* STA count: 1, CU: 75, AAC: 65535 */ |
| 6907 | bss_load = "bss_load_test=1:75:65535"; |
| 6908 | break; |
| 6909 | default: |
| 6910 | bss_load = NULL; |
| 6911 | break; |
| 6912 | } |
| 6913 | |
| 6914 | if (!bss_load) { |
| 6915 | fclose(f); |
| 6916 | return -2; |
| 6917 | } |
| 6918 | fprintf(f, "%s\n", bss_load); |
| 6919 | } |
| 6920 | |
| 6921 | if (append_hostapd_conf_hs2(dut, f)) { |
| 6922 | fclose(f); |
| 6923 | return -2; |
| 6924 | } |
| 6925 | } |
| 6926 | |
| 6927 | if (dut->ap_interworking && append_hostapd_conf_interworking(dut, f)) { |
| 6928 | fclose(f); |
| 6929 | return -2; |
| 6930 | } |
| 6931 | |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 6932 | if (dut->ap_hs2 && strlen(dut->ap_tag_ssid[0])) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6933 | unsigned char bssid[6]; |
| 6934 | char ifname2[50]; |
| 6935 | |
Pradeep Reddy POTTETI | 673d85c | 2016-07-26 19:08:07 +0530 | [diff] [blame] | 6936 | if (get_hwaddr(ifname, bssid)) { |
| 6937 | fclose(f); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6938 | return -2; |
Pradeep Reddy POTTETI | 673d85c | 2016-07-26 19:08:07 +0530 | [diff] [blame] | 6939 | } |
Jouni Malinen | b37f0bc | 2018-05-03 18:29:55 +0300 | [diff] [blame] | 6940 | if (bssid[0] & 0x02) |
| 6941 | bssid[5] ^= 0x01; |
| 6942 | else |
| 6943 | bssid[0] |= 0x02; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6944 | |
| 6945 | snprintf(ifname2, sizeof(ifname2), "%s_1", ifname); |
Jouni Malinen | 10b47b2 | 2018-06-07 23:28:07 +0300 | [diff] [blame] | 6946 | fprintf(f, "bss=%s\n", ifname2); |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 6947 | fprintf(f, "ssid=%s\n", dut->ap_tag_ssid[0]); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6948 | if (dut->bridge) |
| 6949 | fprintf(f, "bridge=%s\n", dut->bridge); |
| 6950 | fprintf(f, "bssid=%02x:%02x:%02x:%02x:%02x:%02x\n", |
| 6951 | bssid[0], bssid[1], bssid[2], bssid[3], |
| 6952 | bssid[4], bssid[5]); |
| 6953 | |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 6954 | if (dut->ap_tag_key_mgmt[0] == AP2_OSEN) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6955 | fprintf(f, "osen=1\n"); |
Sriram R | 61f5d95 | 2018-06-07 17:47:07 +0530 | [diff] [blame] | 6956 | /* Disable DGAF for OSEN BSS */ |
| 6957 | fprintf(f, "disable_dgaf=1\n"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6958 | if (strlen(dut->ap2_radius_ipaddr)) |
| 6959 | fprintf(f, "auth_server_addr=%s\n", |
| 6960 | dut->ap2_radius_ipaddr); |
| 6961 | if (dut->ap2_radius_port) |
| 6962 | fprintf(f, "auth_server_port=%d\n", |
| 6963 | dut->ap2_radius_port); |
| 6964 | if (strlen(dut->ap2_radius_password)) |
| 6965 | fprintf(f, "auth_server_shared_secret=%s\n", |
| 6966 | dut->ap2_radius_password); |
| 6967 | } |
| 6968 | |
| 6969 | if (dut->ap2_proxy_arp) { |
| 6970 | if (!dut->bridge) { |
| 6971 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 6972 | "Bridge must be configured. Run with -b <brname>."); |
| 6973 | fclose(f); |
| 6974 | return -2; |
| 6975 | } |
| 6976 | fprintf(f, "ap_isolate=1\n"); |
| 6977 | fprintf(f, "proxy_arp=1\n"); |
| 6978 | |
| 6979 | if (set_ebtables_proxy_arp(dut, "FORWARD", ifname2) || |
| 6980 | set_ebtables_proxy_arp(dut, "OUTPUT", ifname2)) { |
| 6981 | fclose(f); |
| 6982 | return -2; |
| 6983 | } |
| 6984 | |
| 6985 | } |
| 6986 | } |
| 6987 | |
| 6988 | if (dut->program == PROGRAM_WPS) { |
| 6989 | fprintf(f, "eap_server=1\n" |
| 6990 | "wps_state=1\n" |
| 6991 | "device_name=QCA AP\n" |
| 6992 | "manufacturer=QCA\n" |
| 6993 | "device_type=6-0050F204-1\n" |
| 6994 | "config_methods=label virtual_display " |
| 6995 | "virtual_push_button keypad%s\n" |
| 6996 | "ap_pin=12345670\n" |
| 6997 | "friendly_name=QCA Access Point\n" |
| 6998 | "upnp_iface=%s\n", |
| 6999 | dut->ap_wpsnfc ? " nfc_interface ext_nfc_token" : "", |
| 7000 | dut->bridge ? dut->bridge : ifname); |
| 7001 | } |
| 7002 | |
| 7003 | if (dut->program == PROGRAM_VHT) { |
| 7004 | int vht_oper_centr_freq_idx; |
| 7005 | |
| 7006 | if (check_channel(dut->ap_channel) < 0) { |
| 7007 | send_resp(dut, conn, SIGMA_INVALID, |
| 7008 | "errorCode,Invalid channel"); |
Pradeep Reddy POTTETI | 673d85c | 2016-07-26 19:08:07 +0530 | [diff] [blame] | 7009 | fclose(f); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7010 | return 0; |
| 7011 | } |
| 7012 | |
| 7013 | switch (dut->ap_chwidth) { |
| 7014 | case AP_20: |
| 7015 | dut->ap_vht_chwidth = AP_20_40_VHT_OPER_CHWIDTH; |
| 7016 | vht_oper_centr_freq_idx = |
| 7017 | get_oper_centr_freq_seq_idx(20, |
| 7018 | dut->ap_channel); |
| 7019 | break; |
| 7020 | case AP_40: |
| 7021 | dut->ap_vht_chwidth = AP_20_40_VHT_OPER_CHWIDTH; |
| 7022 | vht_oper_centr_freq_idx = |
| 7023 | get_oper_centr_freq_seq_idx(40, |
| 7024 | dut->ap_channel); |
| 7025 | break; |
| 7026 | case AP_80: |
| 7027 | dut->ap_vht_chwidth = AP_80_VHT_OPER_CHWIDTH; |
| 7028 | vht_oper_centr_freq_idx = |
| 7029 | get_oper_centr_freq_seq_idx(80, |
| 7030 | dut->ap_channel); |
| 7031 | break; |
| 7032 | case AP_160: |
| 7033 | dut->ap_vht_chwidth = AP_160_VHT_OPER_CHWIDTH; |
| 7034 | vht_oper_centr_freq_idx = |
| 7035 | get_oper_centr_freq_seq_idx(160, |
| 7036 | dut->ap_channel); |
| 7037 | break; |
| 7038 | default: |
| 7039 | dut->ap_vht_chwidth = VHT_DEFAULT_OPER_CHWIDTH; |
| 7040 | vht_oper_centr_freq_idx = |
| 7041 | get_oper_centr_freq_seq_idx(80, |
| 7042 | dut->ap_channel); |
| 7043 | break; |
| 7044 | } |
| 7045 | fprintf(f, "vht_oper_centr_freq_seg0_idx=%d\n", |
| 7046 | vht_oper_centr_freq_idx); |
| 7047 | fprintf(f, "vht_oper_chwidth=%d\n", dut->ap_vht_chwidth); |
| 7048 | |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 7049 | if (dut->ap_sgi80 || dut->ap_txBF || |
| 7050 | dut->ap_ldpc != VALUE_NOT_SET || |
Mohammed Shafi Shajakhan | f3e68d9 | 2016-06-02 20:10:57 +0530 | [diff] [blame] | 7051 | dut->ap_tx_stbc || dut->ap_mu_txBF) { |
| 7052 | fprintf(f, "vht_capab=%s%s%s%s%s\n", |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7053 | dut->ap_sgi80 ? "[SHORT-GI-80]" : "", |
Mohammed Shafi Shajakhan | c039ce3 | 2016-06-02 20:10:58 +0530 | [diff] [blame] | 7054 | dut->ap_txBF ? |
Tamizh chelvam | 8312f6d | 2016-06-02 20:10:59 +0530 | [diff] [blame] | 7055 | "[SU-BEAMFORMER][SU-BEAMFORMEE][BF-ANTENNA-2][SOUNDING-DIMENSION-2]" : "", |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 7056 | (dut->ap_ldpc == VALUE_ENABLED) ? |
| 7057 | "[RXLDPC]" : "", |
Mohammed Shafi Shajakhan | f3e68d9 | 2016-06-02 20:10:57 +0530 | [diff] [blame] | 7058 | dut->ap_tx_stbc ? "[TX-STBC-2BY1]" : "", |
| 7059 | dut->ap_mu_txBF ? "[MU-BEAMFORMER]" : ""); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7060 | } |
| 7061 | } |
| 7062 | |
Jouni Malinen | 6d1d739 | 2017-10-10 20:35:29 +0300 | [diff] [blame] | 7063 | if (dut->ap_key_mgmt == AP_WPA2_OWE && dut->ap_tag_ssid[0][0] && |
| 7064 | dut->ap_tag_key_mgmt[0] == AP2_OPEN) { |
| 7065 | /* OWE transition mode */ |
| 7066 | unsigned char bssid[6]; |
| 7067 | char ifname2[50]; |
| 7068 | unsigned long val; |
| 7069 | FILE *f2; |
| 7070 | |
| 7071 | snprintf(ifname2, sizeof(ifname2), "%s_1", ifname); |
| 7072 | |
| 7073 | fprintf(f, "owe_transition_ifname=%s\n", ifname2); |
| 7074 | val = 0x12345678; /* default to something */ |
| 7075 | f2 = fopen("/dev/urandom", "r"); |
| 7076 | if (f2) { |
| 7077 | if (fread(&val, 1, sizeof(val), f2) != sizeof(val)) { |
| 7078 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 7079 | "Could not read /dev/urandom"); |
| 7080 | } |
| 7081 | fclose(f2); |
| 7082 | } |
| 7083 | fprintf(f, "ssid=owe-%lx\n", val); |
| 7084 | |
| 7085 | if (get_hwaddr(ifname, bssid)) { |
| 7086 | fclose(f); |
| 7087 | return -2; |
| 7088 | } |
| 7089 | if (bssid[0] & 0x02) |
| 7090 | bssid[5] ^= 0x01; |
| 7091 | else |
| 7092 | bssid[0] |= 0x02; |
| 7093 | |
| 7094 | fprintf(f, "bss=%s\n", ifname2); |
| 7095 | fprintf(f, "ssid=%s\n", dut->ap_ssid); |
| 7096 | if (dut->bridge) |
| 7097 | fprintf(f, "bridge=%s\n", dut->bridge); |
| 7098 | fprintf(f, "bssid=%02x:%02x:%02x:%02x:%02x:%02x\n", |
| 7099 | bssid[0], bssid[1], bssid[2], bssid[3], |
| 7100 | bssid[4], bssid[5]); |
| 7101 | fprintf(f, "owe_transition_ifname=%s\n", ifname); |
| 7102 | } |
| 7103 | |
Jouni Malinen | 353ba8b | 2018-01-10 17:04:12 +0200 | [diff] [blame] | 7104 | if (dut->ap_key_mgmt == AP_OPEN && |
| 7105 | dut->ap_tag_key_mgmt[0] == AP2_WPA2_OWE) { |
| 7106 | /* OWE transition mode */ |
| 7107 | unsigned char bssid[6]; |
| 7108 | char ifname2[50]; |
| 7109 | unsigned long val; |
| 7110 | FILE *f2; |
| 7111 | |
| 7112 | snprintf(ifname2, sizeof(ifname2), "%s_1", ifname); |
| 7113 | |
| 7114 | fprintf(f, "owe_transition_ifname=%s\n", ifname2); |
| 7115 | fprintf(f, "ssid=%s\n", dut->ap_ssid); |
| 7116 | |
| 7117 | if (get_hwaddr(ifname, bssid)) { |
| 7118 | fclose(f); |
| 7119 | return -2; |
| 7120 | } |
| 7121 | if (bssid[0] & 0x02) |
| 7122 | bssid[5] ^= 0x01; |
| 7123 | else |
| 7124 | bssid[0] |= 0x02; |
| 7125 | |
| 7126 | fprintf(f, "bss=%s\n", ifname2); |
| 7127 | val = 0x12345678; /* default to something */ |
| 7128 | f2 = fopen("/dev/urandom", "r"); |
| 7129 | if (f2) { |
| 7130 | if (fread(&val, 1, sizeof(val), f2) != sizeof(val)) { |
| 7131 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 7132 | "Could not read /dev/urandom"); |
| 7133 | } |
| 7134 | fclose(f2); |
| 7135 | } |
| 7136 | fprintf(f, "ssid=owe-%lx\n", val); |
| 7137 | if (dut->bridge) |
| 7138 | fprintf(f, "bridge=%s\n", dut->bridge); |
| 7139 | fprintf(f, "bssid=%02x:%02x:%02x:%02x:%02x:%02x\n", |
| 7140 | bssid[0], bssid[1], bssid[2], bssid[3], |
| 7141 | bssid[4], bssid[5]); |
| 7142 | fprintf(f, "owe_transition_ifname=%s\n", ifname); |
| 7143 | fprintf(f, "wpa=2\n"); |
| 7144 | fprintf(f, "wpa_key_mgmt=OWE\n"); |
| 7145 | fprintf(f, "rsn_pairwise=CCMP\n"); |
| 7146 | fprintf(f, "ieee80211w=2\n"); |
| 7147 | if (dut->ap_sae_groups) |
| 7148 | fprintf(f, "owe_groups=%s\n", dut->ap_sae_groups); |
| 7149 | } |
| 7150 | |
Ankita Bajaj | 0d5825b | 2017-10-25 16:20:17 +0530 | [diff] [blame] | 7151 | if (dut->program == PROGRAM_OCE) { |
| 7152 | fprintf(f, "oce=%d\n", |
| 7153 | dut->dev_role == DEVROLE_STA_CFON ? 2 : 1); |
| 7154 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7155 | fclose(f); |
Jouni Malinen | d6bf1b4 | 2017-06-23 17:51:01 +0300 | [diff] [blame] | 7156 | if (dut->use_hostapd_pid_file) |
| 7157 | kill_hostapd_process_pid(dut); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7158 | #ifdef __QNXNTO__ |
| 7159 | if (system("slay hostapd") == 0) |
| 7160 | #else /* __QNXNTO__ */ |
Jouni Malinen | d6bf1b4 | 2017-06-23 17:51:01 +0300 | [diff] [blame] | 7161 | if (!dut->use_hostapd_pid_file && |
| 7162 | (kill_process(dut, "(hostapd)", 1, SIGTERM) == 0 || |
| 7163 | system("killall hostapd") == 0)) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7164 | #endif /* __QNXNTO__ */ |
| 7165 | { |
| 7166 | int i; |
| 7167 | /* Wait some time to allow hostapd to complete cleanup before |
| 7168 | * starting a new process */ |
| 7169 | for (i = 0; i < 10; i++) { |
| 7170 | usleep(500000); |
| 7171 | #ifdef __QNXNTO__ |
| 7172 | if (system("pidin | grep hostapd") != 0) |
| 7173 | break; |
| 7174 | #else /* __QNXNTO__ */ |
| 7175 | if (system("pidof hostapd") != 0) |
| 7176 | break; |
| 7177 | #endif /* __QNXNTO__ */ |
| 7178 | } |
| 7179 | } |
Jouni Malinen | d86e582 | 2017-08-29 03:55:32 +0300 | [diff] [blame] | 7180 | dut->hostapd_running = 0; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7181 | |
Pradeep Reddy POTTETI | a076c30 | 2016-05-16 13:36:07 +0530 | [diff] [blame] | 7182 | #ifdef ANDROID |
| 7183 | /* Set proper conf file permissions so that hostapd process |
| 7184 | * can access it. |
| 7185 | */ |
| 7186 | if (chmod(SIGMA_TMPDIR "/sigma_dut-ap.conf", |
| 7187 | S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP) < 0) |
| 7188 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 7189 | "Error changing permissions"); |
| 7190 | |
Srinivas Dasari | a1deeaa | 2018-06-18 22:54:04 +0530 | [diff] [blame] | 7191 | gr = getgrnam("wifi"); |
| 7192 | if (!gr || |
| 7193 | 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] | 7194 | sigma_dut_print(dut, DUT_MSG_ERROR, "Error changing groupid"); |
| 7195 | #endif /* ANDROID */ |
| 7196 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7197 | if (drv == DRIVER_QNXNTO) { |
| 7198 | snprintf(buf, sizeof(buf), |
Pradeep Reddy POTTETI | bf4a974 | 2016-02-04 12:32:30 +0530 | [diff] [blame] | 7199 | "hostapd -B %s%s %s%s" SIGMA_TMPDIR |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7200 | "/sigma_dut-ap.conf", |
| 7201 | dut->hostapd_debug_log ? "-ddKt -f " : "", |
| 7202 | dut->hostapd_debug_log ? dut->hostapd_debug_log : "", |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7203 | dut->hostapd_entropy_log ? " -e" : "", |
| 7204 | dut->hostapd_entropy_log ? dut->hostapd_entropy_log : |
| 7205 | ""); |
| 7206 | } else { |
| 7207 | /* |
| 7208 | * It looks like a monitor interface can cause some issues for |
| 7209 | * beaconing, so remove it (if injection was used) before |
| 7210 | * starting hostapd. |
| 7211 | */ |
| 7212 | if (if_nametoindex("sigmadut") > 0 && |
| 7213 | system("iw dev sigmadut del") != 0) |
| 7214 | sigma_dut_print(dut, DUT_MSG_ERROR, "Failed to remove " |
| 7215 | "monitor interface"); |
| 7216 | |
Jouni Malinen | d6bf1b4 | 2017-06-23 17:51:01 +0300 | [diff] [blame] | 7217 | snprintf(path, sizeof(path), "%shostapd", |
| 7218 | file_exists("hostapd") ? "./" : ""); |
| 7219 | 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] | 7220 | "/sigma_dut-ap.conf", |
Jouni Malinen | d6bf1b4 | 2017-06-23 17:51:01 +0300 | [diff] [blame] | 7221 | dut->hostapd_bin ? dut->hostapd_bin : path, |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7222 | dut->hostapd_debug_log ? " -ddKt -f" : "", |
| 7223 | dut->hostapd_debug_log ? dut->hostapd_debug_log : "", |
| 7224 | dut->hostapd_entropy_log ? " -e" : "", |
| 7225 | dut->hostapd_entropy_log ? dut->hostapd_entropy_log : |
Jouni Malinen | d6bf1b4 | 2017-06-23 17:51:01 +0300 | [diff] [blame] | 7226 | "", |
| 7227 | dut->use_hostapd_pid_file ? |
| 7228 | " -P " SIGMA_DUT_HOSTAPD_PID_FILE : ""); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7229 | } |
| 7230 | |
Jouni Malinen | d6bf1b4 | 2017-06-23 17:51:01 +0300 | [diff] [blame] | 7231 | sigma_dut_print(dut, DUT_MSG_DEBUG, "hostapd command: %s", buf); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7232 | if (system(buf) != 0) { |
| 7233 | send_resp(dut, conn, SIGMA_ERROR, |
| 7234 | "errorCode,Failed to start hostapd"); |
| 7235 | return 0; |
| 7236 | } |
| 7237 | |
| 7238 | /* allow some time for hostapd to start before returning success */ |
| 7239 | usleep(500000); |
| 7240 | if (run_hostapd_cli(dut, "ping") != 0) { |
| 7241 | send_resp(dut, conn, SIGMA_ERROR, |
| 7242 | "errorCode,Failed to talk to hostapd"); |
| 7243 | return 0; |
| 7244 | } |
| 7245 | |
Pradeep Reddy Potteti | 923a9b3 | 2017-06-14 12:18:59 +0530 | [diff] [blame] | 7246 | if (drv == DRIVER_LINUX_WCN) { |
| 7247 | sigma_dut_print(dut, DUT_MSG_INFO, "setting ip addr %s mask %s", |
| 7248 | ap_inet_addr, ap_inet_mask); |
| 7249 | snprintf(buf, sizeof(buf), "ifconfig %s %s netmask %s up", |
| 7250 | ifname, ap_inet_addr, ap_inet_mask); |
| 7251 | if (system(buf) != 0) { |
| 7252 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 7253 | "Failed to initialize the interface"); |
| 7254 | return -1; |
| 7255 | } |
| 7256 | } |
| 7257 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7258 | if (dut->ap_l2tif) { |
| 7259 | snprintf(path, sizeof(path), |
| 7260 | "/sys/class/net/%s/brport/hairpin_mode", |
| 7261 | ifname); |
| 7262 | if (!file_exists(path)) { |
| 7263 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 7264 | "%s must be binded to the bridge for L2TIF", |
| 7265 | ifname); |
| 7266 | return -2; |
| 7267 | } |
| 7268 | |
| 7269 | snprintf(buf, sizeof(buf), "echo 1 > %s", path); |
| 7270 | if (system(buf) != 0) { |
| 7271 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 7272 | "Failed to enable hairpin_mode for L2TIF"); |
| 7273 | return -2; |
| 7274 | } |
| 7275 | |
| 7276 | snprintf(buf, sizeof(buf), "ebtables -P FORWARD ACCEPT"); |
| 7277 | if (system(buf) != 0) { |
| 7278 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 7279 | "Failed to set ebtables rules, RULE-9"); |
| 7280 | return -2; |
| 7281 | } |
| 7282 | |
| 7283 | snprintf(buf, sizeof(buf), |
| 7284 | "ebtables -A FORWARD -p IPv4 --ip-proto icmp -i %s -j DROP", |
| 7285 | ifname); |
| 7286 | if (system(buf) != 0) { |
| 7287 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 7288 | "Failed to set ebtables rules, RULE-11"); |
| 7289 | return -2; |
| 7290 | } |
| 7291 | } |
| 7292 | |
| 7293 | if (dut->ap_proxy_arp) { |
| 7294 | if (dut->ap_dgaf_disable) { |
| 7295 | if (set_ebtables_disable_dgaf(dut, "FORWARD", ifname) || |
| 7296 | set_ebtables_disable_dgaf(dut, "OUTPUT", ifname)) |
| 7297 | return -2; |
| 7298 | } else { |
| 7299 | if (set_ebtables_proxy_arp(dut, "FORWARD", ifname) || |
| 7300 | set_ebtables_proxy_arp(dut, "OUTPUT", ifname)) |
| 7301 | return -2; |
| 7302 | } |
| 7303 | |
| 7304 | /* For 4.5-(c) */ |
| 7305 | snprintf(buf, sizeof(buf), |
| 7306 | "ebtables -A FORWARD -p ARP --arp-opcode 2 -i %s -j DROP", |
| 7307 | ifname); |
| 7308 | if (system(buf) != 0) { |
| 7309 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 7310 | "Failed to set ebtables rules, RULE-10"); |
| 7311 | return -2; |
| 7312 | } |
| 7313 | } |
| 7314 | |
| 7315 | if (dut->ap_tdls_prohibit || dut->ap_l2tif) { |
| 7316 | /* Drop TDLS frames */ |
| 7317 | snprintf(buf, sizeof(buf), |
| 7318 | "ebtables -A FORWARD -p 0x890d -i %s -j DROP", ifname); |
| 7319 | if (system(buf) != 0) { |
| 7320 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 7321 | "Failed to set ebtables rules, RULE-13"); |
| 7322 | return -2; |
| 7323 | } |
| 7324 | } |
| 7325 | |
| 7326 | if (dut->ap_fake_pkhash && |
| 7327 | run_hostapd_cli(dut, "set wps_corrupt_pkhash 1") != 0) { |
| 7328 | send_resp(dut, conn, SIGMA_ERROR, |
| 7329 | "errorCode,Could not enable FakePubKey"); |
| 7330 | return 0; |
| 7331 | } |
| 7332 | |
Jouni Malinen | d86e582 | 2017-08-29 03:55:32 +0300 | [diff] [blame] | 7333 | dut->hostapd_running = 1; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7334 | return 1; |
| 7335 | } |
| 7336 | |
| 7337 | |
Pradeep Reddy POTTETI | eff4611 | 2016-10-13 17:22:03 +0530 | [diff] [blame] | 7338 | static int parse_qos_params(struct sigma_dut *dut, struct sigma_conn *conn, |
| 7339 | struct qos_params *qos, const char *cwmin, |
| 7340 | const char *cwmax, const char *aifs, |
| 7341 | const char *txop, const char *acm) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7342 | { |
Pradeep Reddy POTTETI | eff4611 | 2016-10-13 17:22:03 +0530 | [diff] [blame] | 7343 | int val; |
| 7344 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7345 | if (cwmin) { |
| 7346 | qos->ac = 1; |
Pradeep Reddy POTTETI | eff4611 | 2016-10-13 17:22:03 +0530 | [diff] [blame] | 7347 | val = atoi(cwmin); |
| 7348 | if (val < 0 || val > 15) { |
| 7349 | send_resp(dut, conn, SIGMA_INVALID, |
| 7350 | "errorCode,Invalid cwMin"); |
| 7351 | return 0; |
| 7352 | } |
| 7353 | qos->cwmin = val; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7354 | } |
| 7355 | |
| 7356 | if (cwmax) { |
| 7357 | qos->ac = 1; |
Pradeep Reddy POTTETI | eff4611 | 2016-10-13 17:22:03 +0530 | [diff] [blame] | 7358 | val = atoi(cwmax); |
| 7359 | if (val < 0 || val > 15) { |
| 7360 | send_resp(dut, conn, SIGMA_INVALID, |
| 7361 | "errorCode,Invalid cwMax"); |
| 7362 | return 0; |
| 7363 | } |
| 7364 | qos->cwmax = val; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7365 | } |
| 7366 | |
| 7367 | if (aifs) { |
| 7368 | qos->ac = 1; |
Pradeep Reddy POTTETI | eff4611 | 2016-10-13 17:22:03 +0530 | [diff] [blame] | 7369 | val = atoi(aifs); |
| 7370 | if (val < 1 || val > 255) { |
| 7371 | send_resp(dut, conn, SIGMA_INVALID, |
| 7372 | "errorCode,Invalid AIFS"); |
| 7373 | return 0; |
| 7374 | } |
| 7375 | qos->aifs = val; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7376 | } |
| 7377 | |
| 7378 | if (txop) { |
| 7379 | qos->ac = 1; |
Pradeep Reddy POTTETI | eff4611 | 2016-10-13 17:22:03 +0530 | [diff] [blame] | 7380 | val = atoi(txop); |
| 7381 | if (val < 0 || val > 0xffff) { |
| 7382 | send_resp(dut, conn, SIGMA_INVALID, |
| 7383 | "errorCode,Invalid txop"); |
| 7384 | return 0; |
| 7385 | } |
| 7386 | qos->txop = val * 32; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7387 | } |
| 7388 | |
| 7389 | if (acm) { |
| 7390 | qos->ac = 1; |
| 7391 | qos->acm = strcasecmp(acm, "on") == 0; |
| 7392 | } |
Pradeep Reddy POTTETI | eff4611 | 2016-10-13 17:22:03 +0530 | [diff] [blame] | 7393 | |
| 7394 | return 1; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7395 | } |
| 7396 | |
| 7397 | |
| 7398 | static int cmd_ap_set_apqos(struct sigma_dut *dut, struct sigma_conn *conn, |
| 7399 | struct sigma_cmd *cmd) |
| 7400 | { |
| 7401 | /* TXOP: The values provided here for VHT5G only */ |
Pradeep Reddy POTTETI | eff4611 | 2016-10-13 17:22:03 +0530 | [diff] [blame] | 7402 | if (!parse_qos_params(dut, conn, &dut->ap_qos[AP_AC_VO], |
| 7403 | get_param(cmd, "cwmin_VO"), |
| 7404 | get_param(cmd, "cwmax_VO"), |
| 7405 | get_param(cmd, "AIFS_VO"), |
| 7406 | get_param(cmd, "TXOP_VO"), |
| 7407 | get_param(cmd, "ACM_VO")) || |
| 7408 | !parse_qos_params(dut, conn, &dut->ap_qos[AP_AC_VI], |
| 7409 | get_param(cmd, "cwmin_VI"), |
| 7410 | get_param(cmd, "cwmax_VI"), |
| 7411 | get_param(cmd, "AIFS_VI"), |
| 7412 | get_param(cmd, "TXOP_VI"), |
| 7413 | get_param(cmd, "ACM_VI")) || |
| 7414 | !parse_qos_params(dut, conn, &dut->ap_qos[AP_AC_BE], |
| 7415 | get_param(cmd, "cwmin_BE"), |
| 7416 | get_param(cmd, "cwmax_BE"), |
| 7417 | get_param(cmd, "AIFS_BE"), |
| 7418 | get_param(cmd, "TXOP_BE"), |
| 7419 | get_param(cmd, "ACM_BE")) || |
| 7420 | !parse_qos_params(dut, conn, &dut->ap_qos[AP_AC_BK], |
| 7421 | get_param(cmd, "cwmin_BK"), |
| 7422 | get_param(cmd, "cwmax_BK"), |
| 7423 | get_param(cmd, "AIFS_BK"), |
| 7424 | get_param(cmd, "TXOP_BK"), |
| 7425 | get_param(cmd, "ACM_BK"))) |
| 7426 | return 0; |
| 7427 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7428 | return 1; |
| 7429 | } |
| 7430 | |
| 7431 | |
| 7432 | static int cmd_ap_set_staqos(struct sigma_dut *dut, struct sigma_conn *conn, |
| 7433 | struct sigma_cmd *cmd) |
| 7434 | { |
Pradeep Reddy POTTETI | eff4611 | 2016-10-13 17:22:03 +0530 | [diff] [blame] | 7435 | if (!parse_qos_params(dut, conn, &dut->ap_sta_qos[AP_AC_VO], |
| 7436 | get_param(cmd, "cwmin_VO"), |
| 7437 | get_param(cmd, "cwmax_VO"), |
| 7438 | get_param(cmd, "AIFS_VO"), |
| 7439 | get_param(cmd, "TXOP_VO"), |
| 7440 | get_param(cmd, "ACM_VO")) || |
| 7441 | !parse_qos_params(dut, conn, &dut->ap_sta_qos[AP_AC_VI], |
| 7442 | get_param(cmd, "cwmin_VI"), |
| 7443 | get_param(cmd, "cwmax_VI"), |
| 7444 | get_param(cmd, "AIFS_VI"), |
| 7445 | get_param(cmd, "TXOP_VI"), |
| 7446 | get_param(cmd, "ACM_VI")) || |
| 7447 | !parse_qos_params(dut, conn, &dut->ap_sta_qos[AP_AC_BE], |
| 7448 | get_param(cmd, "cwmin_BE"), |
| 7449 | get_param(cmd, "cwmax_BE"), |
| 7450 | get_param(cmd, "AIFS_BE"), |
| 7451 | get_param(cmd, "TXOP_BE"), |
| 7452 | get_param(cmd, "ACM_BE")) || |
| 7453 | !parse_qos_params(dut, conn, &dut->ap_sta_qos[AP_AC_BK], |
| 7454 | get_param(cmd, "cwmin_BK"), |
| 7455 | get_param(cmd, "cwmax_BK"), |
| 7456 | get_param(cmd, "AIFS_BK"), |
| 7457 | get_param(cmd, "TXOP_BK"), |
| 7458 | get_param(cmd, "ACM_BK"))) |
| 7459 | return 0; |
| 7460 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7461 | return 1; |
| 7462 | } |
| 7463 | |
| 7464 | |
| 7465 | static void cmd_ath_ap_hs2_reset(struct sigma_dut *dut) |
| 7466 | { |
| 7467 | unsigned char bssid[6]; |
| 7468 | char buf[100]; |
| 7469 | run_system(dut, "cfg -a AP_SSID=\"Hotspot 2.0\""); |
| 7470 | run_system(dut, "cfg -a AP_PRIMARY_CH=1"); |
| 7471 | run_system(dut, "cfg -a AP_SECMODE=WPA"); |
| 7472 | run_system(dut, "cfg -a AP_SECFILE=EAP"); |
| 7473 | run_system(dut, "cfg -a AP_WPA=2"); |
| 7474 | run_system(dut, "cfg -a AP_CYPHER=CCMP"); |
| 7475 | run_system(dut, "cfg -a AP_HOTSPOT=1"); |
| 7476 | run_system(dut, "cfg -a AP_HOTSPOT_ANT=2"); |
| 7477 | run_system(dut, "cfg -a AP_HOTSPOT_INTERNET=0"); |
| 7478 | run_system(dut, "cfg -a AP_HOTSPOT_VENUEGROUP=2"); |
| 7479 | run_system(dut, "cfg -a AP_HOTSPOT_VENUETYPE=8"); |
| 7480 | run_system(dut, "cfg -a AP_HOTSPOT_ROAMINGCONSORTIUM=506f9a"); |
| 7481 | run_system(dut, "cfg -a AP_HOTSPOT_ROAMINGCONSORTIUM2=001bc504bd"); |
| 7482 | if (!get_hwaddr("ath0", bssid)) { |
| 7483 | snprintf(buf, sizeof(buf), "cfg -a AP_HOTSPOT_HESSID=" |
| 7484 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 7485 | bssid[0], bssid[1], bssid[2], bssid[3], |
| 7486 | bssid[4], bssid[5]); |
| 7487 | run_system(dut, buf); |
| 7488 | snprintf(dut->ap_hessid, sizeof(dut->ap_hessid), |
| 7489 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 7490 | bssid[0], bssid[1], bssid[2], bssid[3], |
| 7491 | bssid[4], bssid[5]); |
| 7492 | } else { |
| 7493 | if (!get_hwaddr("wifi0", bssid)) { |
| 7494 | snprintf(buf, sizeof(buf), "cfg -a AP_HOTSPOT_HESSID=" |
| 7495 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 7496 | bssid[0], bssid[1], bssid[2], bssid[3], |
| 7497 | bssid[4], bssid[5]); |
| 7498 | run_system(dut, buf); |
| 7499 | snprintf(dut->ap_hessid, sizeof(dut->ap_hessid), |
| 7500 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 7501 | bssid[0], bssid[1], bssid[2], bssid[3], |
| 7502 | bssid[4], bssid[5]); |
| 7503 | } else { |
| 7504 | /* load the driver and try again */ |
| 7505 | run_system(dut, "/etc/rc.d/rc.wlan up"); |
| 7506 | |
| 7507 | if (!get_hwaddr("wifi0", bssid)) { |
| 7508 | snprintf(buf, sizeof(buf), |
| 7509 | "cfg -a AP_HOTSPOT_HESSID=" |
| 7510 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 7511 | bssid[0], bssid[1], bssid[2], |
| 7512 | bssid[3], bssid[4], bssid[5]); |
| 7513 | run_system(dut, buf); |
| 7514 | snprintf(dut->ap_hessid, |
| 7515 | sizeof(dut->ap_hessid), |
| 7516 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 7517 | bssid[0], bssid[1], bssid[2], |
| 7518 | bssid[3], bssid[4], bssid[5]); |
| 7519 | } |
| 7520 | } |
| 7521 | } |
| 7522 | |
| 7523 | run_system(dut, "cfg -r AP_SSID_2"); |
| 7524 | run_system(dut, "cfg -c"); |
| 7525 | /* run_system(dut, "cfg -s"); */ |
| 7526 | } |
| 7527 | |
| 7528 | |
| 7529 | static void ath_reset_vht_defaults(struct sigma_dut *dut) |
| 7530 | { |
| 7531 | run_system(dut, "cfg -x"); |
| 7532 | run_system(dut, "cfg -a AP_RADIO_ID=1"); |
| 7533 | run_system(dut, "cfg -a AP_PRIMARY_CH_2=36"); |
| 7534 | run_system(dut, "cfg -a AP_STARTMODE=standard"); |
| 7535 | run_system(dut, "cfg -a AP_CHMODE_2=11ACVHT80"); |
| 7536 | run_system(dut, "cfg -a TX_CHAINMASK_2=7"); |
| 7537 | run_system(dut, "cfg -a RX_CHAINMASK_2=7"); |
| 7538 | run_system(dut, "cfg -a ATH_countrycode=0x348"); |
| 7539 | /* NOTE: For Beeliner we have to turn off MU-MIMO */ |
| 7540 | if (system("rm /tmp/secath*") != 0) { |
| 7541 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 7542 | "Failed to remove secath file"); |
| 7543 | } |
| 7544 | } |
| 7545 | |
| 7546 | |
| 7547 | static int cmd_ap_reset_default(struct sigma_dut *dut, struct sigma_conn *conn, |
| 7548 | struct sigma_cmd *cmd) |
| 7549 | { |
Ankita Bajaj | 0d5825b | 2017-10-25 16:20:17 +0530 | [diff] [blame] | 7550 | const char *type, *program; |
Pradeep Reddy POTTETI | 83b8067 | 2016-09-02 13:01:44 +0530 | [diff] [blame] | 7551 | enum driver_type drv; |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 7552 | int i; |
| 7553 | |
| 7554 | for (i = 0; i < MAX_WLAN_TAGS - 1; i++) { |
| 7555 | /* |
| 7556 | * Reset all tagged SSIDs to NULL-string and all key management |
| 7557 | * to open. |
| 7558 | */ |
| 7559 | dut->ap_tag_ssid[i][0] = '\0'; |
| 7560 | dut->ap_tag_key_mgmt[i] = AP2_OPEN; |
| 7561 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7562 | |
Pradeep Reddy POTTETI | 83b8067 | 2016-09-02 13:01:44 +0530 | [diff] [blame] | 7563 | drv = get_driver_type(); |
Ankita Bajaj | 0d5825b | 2017-10-25 16:20:17 +0530 | [diff] [blame] | 7564 | |
| 7565 | program = get_param(cmd, "program"); |
| 7566 | if (!program) |
| 7567 | program = get_param(cmd, "prog"); |
| 7568 | dut->program = sigma_program_to_enum(program); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7569 | dut->device_type = AP_unknown; |
| 7570 | type = get_param(cmd, "type"); |
| 7571 | if (type && strcasecmp(type, "Testbed") == 0) |
| 7572 | dut->device_type = AP_testbed; |
| 7573 | if (type && strcasecmp(type, "DUT") == 0) |
| 7574 | dut->device_type = AP_dut; |
| 7575 | |
| 7576 | dut->ap_rts = 0; |
| 7577 | dut->ap_frgmnt = 0; |
| 7578 | dut->ap_bcnint = 0; |
| 7579 | dut->ap_key_mgmt = AP_OPEN; |
| 7580 | dut->ap_ssid[0] = '\0'; |
| 7581 | dut->ap_fake_pkhash = 0; |
| 7582 | memset(dut->ap_qos, 0, sizeof(dut->ap_qos)); |
| 7583 | memset(dut->ap_sta_qos, 0, sizeof(dut->ap_sta_qos)); |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 7584 | dut->ap_addba_reject = VALUE_NOT_SET; |
| 7585 | dut->ap_noack = VALUE_NOT_SET; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7586 | dut->ap_is_dual = 0; |
| 7587 | dut->ap_mode = AP_inval; |
| 7588 | dut->ap_mode_1 = AP_inval; |
| 7589 | |
| 7590 | dut->ap_allow_vht_wep = 0; |
| 7591 | dut->ap_allow_vht_tkip = 0; |
| 7592 | dut->ap_disable_protection = 0; |
| 7593 | memset(dut->ap_countrycode, 0, sizeof(dut->ap_countrycode)); |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 7594 | dut->ap_dyn_bw_sig = VALUE_NOT_SET; |
| 7595 | dut->ap_ldpc = VALUE_NOT_SET; |
| 7596 | dut->ap_sig_rts = VALUE_NOT_SET; |
| 7597 | dut->ap_rx_amsdu = VALUE_NOT_SET; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7598 | dut->ap_txBF = 0; |
Mohammed Shafi Shajakhan | 495fdb2 | 2016-06-02 20:10:56 +0530 | [diff] [blame] | 7599 | dut->ap_mu_txBF = 0; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7600 | dut->ap_chwidth = AP_AUTO; |
| 7601 | |
Sarvepalli, Rajesh Babu | 24dc7e4 | 2016-03-18 21:27:26 +0530 | [diff] [blame] | 7602 | dut->ap_rsn_preauth = 0; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7603 | dut->ap_wpsnfc = 0; |
| 7604 | dut->ap_bss_load = -1; |
| 7605 | dut->ap_p2p_cross_connect = -1; |
| 7606 | |
Pradeep Reddy POTTETI | fba27db | 2015-11-20 16:42:22 +0530 | [diff] [blame] | 7607 | dut->ap_regulatory_mode = AP_80211D_MODE_DISABLED; |
| 7608 | dut->ap_dfs_mode = AP_DFS_MODE_DISABLED; |
Pradeep Reddy Potteti | 4b0cdee | 2017-03-15 12:37:33 +0530 | [diff] [blame] | 7609 | dut->ap_chwidth_offset = SEC_CH_NO; |
Pradeep Reddy POTTETI | fba27db | 2015-11-20 16:42:22 +0530 | [diff] [blame] | 7610 | |
Adil Saeed Musthafa | 6906372 | 2017-04-10 23:13:40 -0700 | [diff] [blame] | 7611 | dut->mbo_pref_ap_cnt = 0; |
Adil Saeed Musthafa | 4ec61bd | 2017-04-10 23:13:41 -0700 | [diff] [blame] | 7612 | dut->ft_bss_mac_cnt = 0; |
priyadharshini gowthaman | 09d613e | 2017-12-20 11:43:44 -0800 | [diff] [blame] | 7613 | dut->ap_interface_5g = 0; |
| 7614 | dut->ap_interface_2g = 0; |
priyadharshini gowthaman | a3fe8c6 | 2018-01-26 15:19:41 -0800 | [diff] [blame] | 7615 | dut->ap_pmf = AP_PMF_DISABLED; |
Adil Saeed Musthafa | 6906372 | 2017-04-10 23:13:40 -0700 | [diff] [blame] | 7616 | |
Mohammed Shafi Shajakhan | 02e3b82 | 2017-02-23 04:15:02 +0530 | [diff] [blame] | 7617 | if (dut->program == PROGRAM_HT || dut->program == PROGRAM_VHT) { |
Pradeep Reddy POTTETI | 0d3db63 | 2016-03-11 15:21:11 +0530 | [diff] [blame] | 7618 | dut->ap_wme = AP_WME_ON; |
Mohammed Shafi Shajakhan | 02e3b82 | 2017-02-23 04:15:02 +0530 | [diff] [blame] | 7619 | dut->ap_wmmps = AP_WMMPS_ON; |
| 7620 | } else { |
Pradeep Reddy POTTETI | 0d3db63 | 2016-03-11 15:21:11 +0530 | [diff] [blame] | 7621 | dut->ap_wme = AP_WME_OFF; |
Mohammed Shafi Shajakhan | 02e3b82 | 2017-02-23 04:15:02 +0530 | [diff] [blame] | 7622 | dut->ap_wmmps = AP_WMMPS_OFF; |
| 7623 | } |
Pradeep Reddy POTTETI | 0d3db63 | 2016-03-11 15:21:11 +0530 | [diff] [blame] | 7624 | |
Jouni Malinen | 54a89b0 | 2018-05-01 00:16:26 +0300 | [diff] [blame] | 7625 | dut->ap_venue_url = 0; |
Jouni Malinen | f7ff42b | 2018-05-01 00:21:56 +0300 | [diff] [blame] | 7626 | dut->ap_advice_of_charge = 0; |
Jouni Malinen | ac10453 | 2018-05-01 00:27:37 +0300 | [diff] [blame] | 7627 | dut->ap_oper_icon_metadata = 0; |
Jouni Malinen | ac36714 | 2018-05-01 00:32:24 +0300 | [diff] [blame] | 7628 | dut->ap_tnc_file_name = 0; |
| 7629 | dut->ap_tnc_time_stamp = 0; |
Jouni Malinen | 54a89b0 | 2018-05-01 00:16:26 +0300 | [diff] [blame] | 7630 | |
Adil Saeed Musthafa | 33ea287 | 2017-04-10 23:13:24 -0700 | [diff] [blame] | 7631 | if (dut->program == PROGRAM_HS2 || dut->program == PROGRAM_HS2_R2 || |
Jouni Malinen | ba63045 | 2018-06-22 11:49:59 +0300 | [diff] [blame] | 7632 | dut->program == PROGRAM_HS2_R3 || |
Adil Saeed Musthafa | 33ea287 | 2017-04-10 23:13:24 -0700 | [diff] [blame] | 7633 | dut->program == PROGRAM_IOTLP) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7634 | int i; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7635 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7636 | if (drv == DRIVER_ATHEROS) |
| 7637 | cmd_ath_ap_hs2_reset(dut); |
| 7638 | else if (drv == DRIVER_OPENWRT) |
| 7639 | cmd_owrt_ap_hs2_reset(dut); |
| 7640 | |
| 7641 | dut->ap_interworking = 1; |
| 7642 | dut->ap_access_net_type = 2; |
| 7643 | dut->ap_internet = 0; |
| 7644 | dut->ap_venue_group = 2; |
| 7645 | dut->ap_venue_type = 8; |
| 7646 | dut->ap_domain_name_list[0] = '\0'; |
| 7647 | dut->ap_hs2 = 1; |
| 7648 | snprintf(dut->ap_roaming_cons, sizeof(dut->ap_roaming_cons), |
| 7649 | "506f9a;001bc504bd"); |
| 7650 | dut->ap_l2tif = 0; |
| 7651 | dut->ap_proxy_arp = 0; |
| 7652 | if (dut->bridge) { |
| 7653 | char buf[50]; |
| 7654 | |
| 7655 | snprintf(buf, sizeof(buf), "ip neigh flush dev %s", |
| 7656 | dut->bridge); |
| 7657 | if (system(buf) != 0) { |
| 7658 | sigma_dut_print(dut, DUT_MSG_DEBUG, |
| 7659 | "%s ip neigh table flushing failed", |
| 7660 | dut->bridge); |
| 7661 | } |
| 7662 | |
| 7663 | snprintf(buf, sizeof(buf), "ebtables -F"); |
| 7664 | if (system(buf) != 0) { |
| 7665 | sigma_dut_print(dut, DUT_MSG_DEBUG, |
| 7666 | "%s ebtables flushing failed", |
| 7667 | dut->bridge); |
| 7668 | } |
| 7669 | } |
| 7670 | dut->ap_dgaf_disable = 0; |
| 7671 | dut->ap_p2p_cross_connect = 0; |
| 7672 | dut->ap_gas_cb_delay = 0; |
| 7673 | dut->ap_nai_realm_list = 0; |
| 7674 | dut->ap_oper_name = 0; |
| 7675 | dut->ap_venue_name = 0; |
| 7676 | for (i = 0; i < 10; i++) { |
| 7677 | dut->ap_plmn_mcc[i][0] = '\0'; |
| 7678 | dut->ap_plmn_mnc[i][0] = '\0'; |
| 7679 | } |
| 7680 | dut->ap_wan_metrics = 0; |
| 7681 | dut->ap_conn_capab = 0; |
| 7682 | dut->ap_ip_addr_type_avail = 0; |
| 7683 | dut->ap_net_auth_type = 0; |
| 7684 | dut->ap_oper_class = 0; |
| 7685 | dut->ap_pmf = 0; |
| 7686 | dut->ap_add_sha256 = 0; |
| 7687 | } |
| 7688 | |
Jouni Malinen | ba63045 | 2018-06-22 11:49:59 +0300 | [diff] [blame] | 7689 | if (dut->program == PROGRAM_HS2_R2 || dut->program == PROGRAM_HS2_R3 || |
| 7690 | dut->program == PROGRAM_IOTLP) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7691 | int i; |
| 7692 | const char hessid[] = "50:6f:9a:00:11:22"; |
| 7693 | |
| 7694 | memcpy(dut->ap_hessid, hessid, strlen(hessid) + 1); |
| 7695 | dut->ap_osu_ssid[0] = '\0'; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7696 | dut->ap_pmf = 1; |
| 7697 | dut->ap_osu_provider_list = 0; |
| 7698 | for (i = 0; i < 10; i++) { |
| 7699 | dut->ap_osu_server_uri[i][0] = '\0'; |
| 7700 | dut->ap_osu_method[i] = 0xFF; |
| 7701 | } |
| 7702 | dut->ap_qos_map_set = 0; |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 7703 | dut->ap_tag_key_mgmt[0] = AP2_OPEN; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7704 | dut->ap2_proxy_arp = 0; |
| 7705 | dut->ap_osu_icon_tag = 0; |
| 7706 | } |
| 7707 | |
| 7708 | if (dut->program == PROGRAM_VHT) { |
| 7709 | /* Set up the defaults */ |
| 7710 | dut->ap_mode = AP_11ac; |
| 7711 | dut->ap_channel = 36; |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 7712 | dut->ap_ampdu = VALUE_NOT_SET; |
priyadharshini gowthaman | 264d544 | 2016-02-25 15:52:22 -0800 | [diff] [blame] | 7713 | dut->ap_ndpa_frame = 1; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7714 | if (dut->device_type == AP_testbed) { |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 7715 | dut->ap_amsdu = VALUE_DISABLED; |
| 7716 | dut->ap_ldpc = VALUE_DISABLED; |
| 7717 | dut->ap_rx_amsdu = VALUE_DISABLED; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7718 | dut->ap_sgi80 = 0; |
| 7719 | } else { |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 7720 | dut->ap_amsdu = VALUE_ENABLED; |
Pradeep Reddy POTTETI | 83b8067 | 2016-09-02 13:01:44 +0530 | [diff] [blame] | 7721 | /* |
| 7722 | * As LDPC is optional, don't enable this by default |
| 7723 | * for LINUX-WCN driver. The ap_set_wireless command |
| 7724 | * can be used to enable LDPC, when needed. |
| 7725 | */ |
| 7726 | if (drv != DRIVER_LINUX_WCN) |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 7727 | dut->ap_ldpc = VALUE_ENABLED; |
| 7728 | dut->ap_rx_amsdu = VALUE_ENABLED; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7729 | dut->ap_sgi80 = 1; |
| 7730 | } |
| 7731 | dut->ap_fixed_rate = 0; |
| 7732 | dut->ap_rx_streams = 3; |
| 7733 | dut->ap_tx_streams = 3; |
| 7734 | dut->ap_vhtmcs_map = 0; |
| 7735 | dut->ap_chwidth = AP_80; |
| 7736 | dut->ap_tx_stbc = 1; |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 7737 | dut->ap_dyn_bw_sig = VALUE_ENABLED; |
Mohammed Shafi Shajakhan | bae7230 | 2016-03-02 11:56:23 +0530 | [diff] [blame] | 7738 | if (get_openwrt_driver_type() == OPENWRT_DRIVER_ATHEROS) |
| 7739 | dut->ap_dfs_mode = AP_DFS_MODE_ENABLED; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7740 | if (get_driver_type() == DRIVER_ATHEROS) |
| 7741 | ath_reset_vht_defaults(dut); |
| 7742 | } |
| 7743 | |
Adil Saeed Musthafa | 33ea287 | 2017-04-10 23:13:24 -0700 | [diff] [blame] | 7744 | if (dut->program == PROGRAM_IOTLP) { |
| 7745 | dut->wnm_bss_max_feature = VALUE_DISABLED; |
| 7746 | dut->wnm_bss_max_idle_time = 0; |
| 7747 | dut->wnm_bss_max_protection = VALUE_NOT_SET; |
| 7748 | dut->ap_proxy_arp = 1; |
| 7749 | } else { |
| 7750 | /* |
| 7751 | * Do not touch the BSS-MAX Idle time feature |
| 7752 | * if the program is not IOTLP. |
| 7753 | */ |
| 7754 | dut->wnm_bss_max_feature = VALUE_NOT_SET; |
| 7755 | dut->wnm_bss_max_idle_time = 0; |
| 7756 | dut->wnm_bss_max_protection = VALUE_NOT_SET; |
| 7757 | } |
| 7758 | |
priyadharshini gowthaman | a27b5b6 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 7759 | if (dut->program == PROGRAM_LOC) { |
priyadharshini gowthaman | 8e26ff4 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 7760 | dut->ap_rrm = 1; |
| 7761 | dut->ap_rtt = 1; |
| 7762 | dut->ap_lci = 0; |
| 7763 | dut->ap_val_lci[0] = '\0'; |
priyadharshini gowthaman | c2357bd | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 7764 | dut->ap_infoz[0] = '\0'; |
priyadharshini gowthaman | 8e26ff4 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 7765 | dut->ap_lcr = 0; |
| 7766 | dut->ap_val_lcr[0] = '\0'; |
| 7767 | dut->ap_neighap = 0; |
| 7768 | dut->ap_opchannel = 0; |
| 7769 | dut->ap_scan = 0; |
priyadharshini gowthaman | c2357bd | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 7770 | dut->ap_fqdn_held = 0; |
| 7771 | dut->ap_fqdn_supl = 0; |
priyadharshini gowthaman | c52fff8 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 7772 | dut->ap_interworking = 0; |
| 7773 | dut->ap_gas_cb_delay = 0; |
priyadharshini gowthaman | a27b5b6 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 7774 | dut->ap_msnt_type = 0; |
| 7775 | } |
Adil Saeed Musthafa | 4ec61bd | 2017-04-10 23:13:41 -0700 | [diff] [blame] | 7776 | dut->ap_ft_oa = 0; |
Adil Saeed Musthafa | 604c826 | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 7777 | dut->ap_reg_domain = REG_DOMAIN_NOT_SET; |
Adil Saeed Musthafa | cf752fa | 2017-04-10 23:13:32 -0700 | [diff] [blame] | 7778 | dut->ap_mobility_domain[0] = '\0'; |
priyadharshini gowthaman | a27b5b6 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 7779 | |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 7780 | if (dut->program == PROGRAM_MBO) { |
| 7781 | dut->ap_mbo = 1; |
| 7782 | dut->ap_interworking = 1; |
| 7783 | dut->ap_ne_class = 0; |
| 7784 | dut->ap_ne_op_ch = 0; |
| 7785 | dut->ap_set_bssidpref = 1; |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 7786 | dut->ap_btmreq_disassoc_imnt = 0; |
| 7787 | dut->ap_btmreq_term_bit = 0; |
| 7788 | dut->ap_disassoc_timer = 0; |
| 7789 | dut->ap_btmreq_bss_term_dur = 0; |
Adil Saeed Musthafa | 16d9e63 | 2017-04-10 23:13:38 -0700 | [diff] [blame] | 7790 | dut->ap_channel = 36; |
| 7791 | dut->ap_chwidth = AP_20; |
Adil Saeed Musthafa | 023108a | 2017-04-10 23:13:37 -0700 | [diff] [blame] | 7792 | dut->ap_cell_cap_pref = 0; |
Adil Saeed Musthafa | ed5faae | 2017-04-10 23:13:36 -0700 | [diff] [blame] | 7793 | dut->ap_gas_cb_delay = 0; |
Adil Saeed Musthafa | 6906372 | 2017-04-10 23:13:40 -0700 | [diff] [blame] | 7794 | dut->mbo_self_ap_tuple.ap_ne_class = -1; |
| 7795 | dut->mbo_self_ap_tuple.ap_ne_pref = -1; /* Not set */ |
| 7796 | dut->mbo_self_ap_tuple.ap_ne_op_ch = -1; |
priyadharshini gowthaman | 94062b5 | 2017-12-20 12:33:34 -0800 | [diff] [blame] | 7797 | dut->ap_btmreq_bss_term_tsf = 0; |
priyadharshini gowthaman | 776562e | 2017-12-20 12:33:34 -0800 | [diff] [blame] | 7798 | dut->ap_assoc_delay = 0; |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 7799 | } |
| 7800 | |
priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 7801 | if (dut->program == PROGRAM_OCE) { |
| 7802 | if (dut->ap_dhcp_stop) |
| 7803 | run_system(dut, "/etc/init.d/dnsmasq start"); |
| 7804 | |
| 7805 | dut->ap_dhcp_stop = 0; |
| 7806 | dut->ap_oce = VALUE_ENABLED; |
| 7807 | dut->ap_broadcast_ssid = VALUE_ENABLED; |
| 7808 | dut->ap_fils_dscv_int = 20; |
| 7809 | dut->ap_filsdscv = VALUE_ENABLED; |
| 7810 | dut->ap_filshlp = VALUE_DISABLED; |
| 7811 | dut->ap_rnr = VALUE_DISABLED; |
| 7812 | dut->ap_nairealm[0] = '\0'; |
| 7813 | dut->ap_nairealm_int = 0; |
| 7814 | dut->ap_blechanutil = 0; |
| 7815 | dut->ap_ble_admit_cap = 0; |
| 7816 | dut->ap_esp = VALUE_ENABLED; |
| 7817 | dut->ap_datappdudura = 0; |
| 7818 | dut->ap_airtimefract = 0; |
| 7819 | dut->ap_blestacnt = 0; |
priyadharshini gowthaman | cb22e43 | 2017-12-28 15:23:31 -0800 | [diff] [blame] | 7820 | dut->ap_ul_availcap = 0; |
| 7821 | dut->ap_dl_availcap = 0; |
priyadharshini gowthaman | de81f39 | 2017-12-28 15:28:49 -0800 | [diff] [blame] | 7822 | dut->ap_akm = 0; |
| 7823 | dut->ap_add_sha256 = 0; |
| 7824 | dut->ap_add_sha384 = 0; |
| 7825 | dut->ap_pmksa = 0; |
| 7826 | dut->ap_pmksa_caching = 0; |
priyadharshini gowthaman | 63ab848 | 2017-12-28 15:32:55 -0800 | [diff] [blame] | 7827 | dut->ap_80plus80 = 0; |
priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 7828 | } |
| 7829 | |
priyadharshini gowthaman | 350f191 | 2018-06-04 13:09:12 -0700 | [diff] [blame] | 7830 | dut->ap_he_ppdu = PPDU_NOT_SET; |
| 7831 | |
priyadharshini gowthaman | 9149afc | 2018-01-15 13:40:18 -0800 | [diff] [blame] | 7832 | dut->ap_oper_chn = 0; |
| 7833 | |
Jouni Malinen | 3c367e8 | 2017-06-23 17:01:47 +0300 | [diff] [blame] | 7834 | free(dut->rsne_override); |
| 7835 | dut->rsne_override = NULL; |
| 7836 | |
Jouni Malinen | 6814313 | 2017-09-02 02:34:08 +0300 | [diff] [blame] | 7837 | free(dut->sae_commit_override); |
| 7838 | dut->sae_commit_override = NULL; |
| 7839 | |
Jouni Malinen | ed670f4 | 2017-08-31 01:39:28 +0300 | [diff] [blame] | 7840 | free(dut->ap_sae_groups); |
| 7841 | dut->ap_sae_groups = NULL; |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 7842 | |
Jouni Malinen | 2f524ce | 2017-08-31 01:43:29 +0300 | [diff] [blame] | 7843 | dut->sae_anti_clogging_threshold = -1; |
Jouni Malinen | b347db0 | 2017-09-02 01:36:03 +0300 | [diff] [blame] | 7844 | dut->sae_reflection = 0; |
Jouni Malinen | 2f524ce | 2017-08-31 01:43:29 +0300 | [diff] [blame] | 7845 | |
Jouni Malinen | 3d633da | 2017-09-14 22:19:21 +0300 | [diff] [blame] | 7846 | dut->ap_cipher = AP_CCMP; |
Jouni Malinen | 2ba2449 | 2017-11-17 12:43:59 +0200 | [diff] [blame] | 7847 | dut->ap_group_cipher = AP_NO_GROUP_CIPHER_SET; |
Jouni Malinen | 3d633da | 2017-09-14 22:19:21 +0300 | [diff] [blame] | 7848 | dut->ap_group_mgmt_cipher = AP_NO_GROUP_MGMT_CIPHER_SET; |
Jouni Malinen | 6337062 | 2017-11-18 17:47:13 +0200 | [diff] [blame] | 7849 | dut->ap_passphrase[0] = '\0'; |
| 7850 | dut->ap_psk[0] = '\0'; |
Jouni Malinen | 3d633da | 2017-09-14 22:19:21 +0300 | [diff] [blame] | 7851 | |
Jouni Malinen | d86e582 | 2017-08-29 03:55:32 +0300 | [diff] [blame] | 7852 | dut->dpp_conf_id = -1; |
| 7853 | |
| 7854 | dut->hostapd_running = 0; |
priyadharshini gowthaman | 9947fd3 | 2018-01-26 15:19:41 -0800 | [diff] [blame] | 7855 | |
| 7856 | if (get_openwrt_driver_type() == OPENWRT_DRIVER_ATHEROS) |
| 7857 | return 1; |
| 7858 | |
Jouni Malinen | d6bf1b4 | 2017-06-23 17:51:01 +0300 | [diff] [blame] | 7859 | if (dut->use_hostapd_pid_file) { |
| 7860 | kill_hostapd_process_pid(dut); |
| 7861 | } else if (kill_process(dut, "(hostapd)", 1, SIGTERM) == 0 || |
| 7862 | system("killall hostapd") == 0) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7863 | int i; |
| 7864 | /* Wait some time to allow hostapd to complete cleanup before |
| 7865 | * starting a new process */ |
| 7866 | for (i = 0; i < 10; i++) { |
| 7867 | usleep(500000); |
| 7868 | if (system("pidof hostapd") != 0) |
| 7869 | break; |
| 7870 | } |
| 7871 | } |
| 7872 | |
| 7873 | if (if_nametoindex("sigmadut") > 0 && |
| 7874 | system("iw dev sigmadut del") != 0) |
| 7875 | sigma_dut_print(dut, DUT_MSG_ERROR, "Failed to remove " |
| 7876 | "monitor interface"); |
| 7877 | |
| 7878 | return 1; |
| 7879 | } |
| 7880 | |
| 7881 | |
Ankita Bajaj | 0d5825b | 2017-10-25 16:20:17 +0530 | [diff] [blame] | 7882 | int sta_cfon_reset_default(struct sigma_dut *dut, struct sigma_conn *conn, |
| 7883 | struct sigma_cmd *cmd) |
| 7884 | { |
| 7885 | return cmd_ap_reset_default(dut, conn, cmd); |
| 7886 | } |
| 7887 | |
| 7888 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7889 | static int cmd_ap_get_info(struct sigma_dut *dut, struct sigma_conn *conn, |
| 7890 | struct sigma_cmd *cmd) |
| 7891 | { |
| 7892 | /* const char *name = get_param(cmd, "NAME"); */ |
| 7893 | struct stat s; |
| 7894 | char resp[200]; |
| 7895 | FILE *f; |
| 7896 | enum driver_type drv = get_driver_type(); |
| 7897 | |
| 7898 | switch (drv) { |
| 7899 | case DRIVER_ATHEROS: { |
| 7900 | /* Atheros AP */ |
| 7901 | struct utsname uts; |
| 7902 | char *version, athver[100]; |
| 7903 | |
| 7904 | if (stat("/proc/athversion", &s) != 0) { |
| 7905 | if (system("/etc/rc.d/rc.wlan up") != 0) { |
| 7906 | } |
| 7907 | } |
| 7908 | |
| 7909 | athver[0] = '\0'; |
| 7910 | f = fopen("/proc/athversion", "r"); |
| 7911 | if (f) { |
| 7912 | if (fgets(athver, sizeof(athver), f)) { |
| 7913 | char *pos = strchr(athver, '\n'); |
| 7914 | if (pos) |
| 7915 | *pos = '\0'; |
| 7916 | } |
| 7917 | fclose(f); |
| 7918 | } |
| 7919 | |
| 7920 | if (uname(&uts) == 0) |
| 7921 | version = uts.release; |
| 7922 | else |
| 7923 | version = "Unknown"; |
| 7924 | |
| 7925 | if (if_nametoindex("ath1") > 0) |
| 7926 | snprintf(resp, sizeof(resp), "interface,ath0_24G " |
| 7927 | "ath1_5G,agent,1.0,version,%s/drv:%s", |
| 7928 | version, athver); |
| 7929 | else |
| 7930 | snprintf(resp, sizeof(resp), "interface,ath0_24G," |
| 7931 | "agent,1.0,version,%s/drv:%s", |
| 7932 | version, athver); |
| 7933 | |
| 7934 | send_resp(dut, conn, SIGMA_COMPLETE, resp); |
| 7935 | return 0; |
| 7936 | } |
Sreelakshmi Konamki | b692f10 | 2016-04-26 19:47:00 +0530 | [diff] [blame] | 7937 | case DRIVER_LINUX_WCN: |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7938 | case DRIVER_MAC80211: { |
| 7939 | struct utsname uts; |
| 7940 | char *version; |
| 7941 | |
| 7942 | if (uname(&uts) == 0) |
| 7943 | version = uts.release; |
| 7944 | else |
| 7945 | version = "Unknown"; |
| 7946 | |
| 7947 | if (if_nametoindex("wlan1") > 0) |
| 7948 | snprintf(resp, sizeof(resp), "interface,wlan0_24G " |
| 7949 | "wlan1_5G,agent,1.0,version,%s", version); |
| 7950 | else |
| 7951 | snprintf(resp, sizeof(resp), "interface,wlan0_any," |
| 7952 | "agent,1.0,version,%s", version); |
| 7953 | |
| 7954 | send_resp(dut, conn, SIGMA_COMPLETE, resp); |
| 7955 | return 0; |
| 7956 | } |
| 7957 | case DRIVER_QNXNTO: { |
| 7958 | struct utsname uts; |
| 7959 | char *version; |
| 7960 | |
| 7961 | if (uname(&uts) == 0) |
| 7962 | version = uts.release; |
| 7963 | else |
| 7964 | version = "Unknown"; |
| 7965 | snprintf(resp, sizeof(resp), |
| 7966 | "interface,%s_any,agent,1.0,version,%s", |
| 7967 | sigma_main_ifname ? sigma_main_ifname : "NA", |
| 7968 | version); |
| 7969 | send_resp(dut, conn, SIGMA_COMPLETE, resp); |
| 7970 | return 0; |
| 7971 | } |
| 7972 | case DRIVER_OPENWRT: { |
| 7973 | switch (get_openwrt_driver_type()) { |
| 7974 | case OPENWRT_DRIVER_ATHEROS: { |
| 7975 | struct utsname uts; |
| 7976 | char *version; |
| 7977 | |
| 7978 | if (uname(&uts) == 0) |
| 7979 | version = uts.release; |
| 7980 | else |
| 7981 | version = "Unknown"; |
| 7982 | |
| 7983 | if (if_nametoindex("ath1") > 0) |
| 7984 | snprintf(resp, sizeof(resp), |
| 7985 | "interface,ath0_5G ath1_24G,agent,1.0,version,%s", |
| 7986 | version); |
| 7987 | else |
| 7988 | snprintf(resp, sizeof(resp), |
| 7989 | "interface,ath0_any,agent,1.0,version,%s", |
| 7990 | version); |
| 7991 | |
| 7992 | send_resp(dut, conn, SIGMA_COMPLETE, resp); |
| 7993 | return 0; |
| 7994 | } |
| 7995 | default: |
| 7996 | send_resp(dut, conn, SIGMA_ERROR, |
| 7997 | "errorCode,Unsupported openwrt driver"); |
| 7998 | return 0; |
| 7999 | } |
| 8000 | } |
| 8001 | default: |
| 8002 | send_resp(dut, conn, SIGMA_ERROR, |
| 8003 | "errorCode,Unsupported driver"); |
| 8004 | return 0; |
| 8005 | } |
| 8006 | } |
| 8007 | |
| 8008 | |
| 8009 | static int cmd_ap_deauth_sta(struct sigma_dut *dut, struct sigma_conn *conn, |
| 8010 | struct sigma_cmd *cmd) |
| 8011 | { |
| 8012 | /* const char *name = get_param(cmd, "NAME"); */ |
| 8013 | /* const char *ifname = get_param(cmd, "INTERFACE"); */ |
| 8014 | const char *val; |
| 8015 | char buf[100]; |
| 8016 | |
| 8017 | val = get_param(cmd, "MinorCode"); |
| 8018 | if (val) { |
| 8019 | /* TODO: add support for P2P minor code */ |
| 8020 | send_resp(dut, conn, SIGMA_ERROR, "errorCode,MinorCode not " |
| 8021 | "yet supported"); |
| 8022 | return 0; |
| 8023 | } |
| 8024 | |
| 8025 | val = get_param(cmd, "STA_MAC_ADDRESS"); |
| 8026 | if (val == NULL) |
| 8027 | return -1; |
| 8028 | snprintf(buf, sizeof(buf), "deauth %s", val); |
| 8029 | if (run_hostapd_cli(dut, buf) != 0) |
| 8030 | return -2; |
| 8031 | |
| 8032 | return 1; |
| 8033 | } |
| 8034 | |
| 8035 | |
| 8036 | #ifdef __linux__ |
| 8037 | int inject_frame(int s, const void *data, size_t len, int encrypt); |
| 8038 | int open_monitor(const char *ifname); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8039 | #endif /* __linux__ */ |
| 8040 | |
| 8041 | enum send_frame_type { |
| 8042 | DISASSOC, DEAUTH, SAQUERY |
| 8043 | }; |
| 8044 | enum send_frame_protection { |
| 8045 | CORRECT_KEY, INCORRECT_KEY, UNPROTECTED |
| 8046 | }; |
| 8047 | |
| 8048 | |
| 8049 | static int ap_inject_frame(struct sigma_dut *dut, struct sigma_conn *conn, |
| 8050 | enum send_frame_type frame, |
| 8051 | enum send_frame_protection protected, |
| 8052 | const char *sta_addr) |
| 8053 | { |
| 8054 | #ifdef __linux__ |
| 8055 | unsigned char buf[1000], *pos; |
| 8056 | int s, res; |
| 8057 | unsigned char addr_sta[6], addr_own[6]; |
| 8058 | char *ifname; |
| 8059 | char cbuf[100]; |
| 8060 | struct ifreq ifr; |
| 8061 | |
| 8062 | if ((dut->ap_mode == AP_11a || dut->ap_mode == AP_11na || |
| 8063 | dut->ap_mode == AP_11ac) && |
| 8064 | if_nametoindex("wlan1") > 0) |
| 8065 | ifname = "wlan1"; |
| 8066 | else |
| 8067 | ifname = "wlan0"; |
| 8068 | |
| 8069 | if (hwaddr_aton(sta_addr, addr_sta) < 0) |
| 8070 | return -1; |
| 8071 | |
| 8072 | s = socket(AF_INET, SOCK_DGRAM, 0); |
| 8073 | if (s < 0) |
| 8074 | return -1; |
| 8075 | memset(&ifr, 0, sizeof(ifr)); |
Peng Xu | b8fc5cc | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 8076 | strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name)); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8077 | if (ioctl(s, SIOCGIFHWADDR, &ifr) < 0) { |
| 8078 | perror("ioctl"); |
| 8079 | close(s); |
| 8080 | return -1; |
| 8081 | } |
| 8082 | close(s); |
| 8083 | memcpy(addr_own, ifr.ifr_hwaddr.sa_data, 6); |
| 8084 | |
| 8085 | if (if_nametoindex("sigmadut") == 0) { |
| 8086 | snprintf(cbuf, sizeof(cbuf), |
| 8087 | "iw dev %s interface add sigmadut type monitor", |
| 8088 | ifname); |
| 8089 | if (system(cbuf) != 0 || |
| 8090 | if_nametoindex("sigmadut") == 0) { |
| 8091 | sigma_dut_print(dut, DUT_MSG_ERROR, "Failed to add " |
| 8092 | "monitor interface with '%s'", cbuf); |
| 8093 | return -2; |
| 8094 | } |
| 8095 | } |
| 8096 | |
| 8097 | if (system("ifconfig sigmadut up") != 0) { |
| 8098 | sigma_dut_print(dut, DUT_MSG_ERROR, "Failed to set " |
| 8099 | "monitor interface up"); |
| 8100 | return -2; |
| 8101 | } |
| 8102 | |
| 8103 | pos = buf; |
| 8104 | |
| 8105 | /* Frame Control */ |
| 8106 | switch (frame) { |
| 8107 | case DISASSOC: |
| 8108 | *pos++ = 0xa0; |
| 8109 | break; |
| 8110 | case DEAUTH: |
| 8111 | *pos++ = 0xc0; |
| 8112 | break; |
| 8113 | case SAQUERY: |
| 8114 | *pos++ = 0xd0; |
| 8115 | break; |
| 8116 | } |
| 8117 | |
| 8118 | if (protected == INCORRECT_KEY) |
| 8119 | *pos++ = 0x40; /* Set Protected field to 1 */ |
| 8120 | else |
| 8121 | *pos++ = 0x00; |
| 8122 | |
| 8123 | /* Duration */ |
| 8124 | *pos++ = 0x00; |
| 8125 | *pos++ = 0x00; |
| 8126 | |
| 8127 | /* addr1 = DA (station) */ |
| 8128 | memcpy(pos, addr_sta, 6); |
| 8129 | pos += 6; |
| 8130 | /* addr2 = SA (own address) */ |
| 8131 | memcpy(pos, addr_own, 6); |
| 8132 | pos += 6; |
| 8133 | /* addr3 = BSSID (own address) */ |
| 8134 | memcpy(pos, addr_own, 6); |
| 8135 | pos += 6; |
| 8136 | |
| 8137 | /* Seq# (to be filled by driver/mac80211) */ |
| 8138 | *pos++ = 0x00; |
| 8139 | *pos++ = 0x00; |
| 8140 | |
| 8141 | if (protected == INCORRECT_KEY) { |
| 8142 | /* CCMP parameters */ |
| 8143 | memcpy(pos, "\x61\x01\x00\x20\x00\x10\x00\x00", 8); |
| 8144 | pos += 8; |
| 8145 | } |
| 8146 | |
| 8147 | if (protected == INCORRECT_KEY) { |
| 8148 | switch (frame) { |
| 8149 | case DEAUTH: |
| 8150 | /* Reason code (encrypted) */ |
| 8151 | memcpy(pos, "\xa7\x39", 2); |
| 8152 | pos += 2; |
| 8153 | break; |
| 8154 | case DISASSOC: |
| 8155 | /* Reason code (encrypted) */ |
| 8156 | memcpy(pos, "\xa7\x39", 2); |
| 8157 | pos += 2; |
| 8158 | break; |
| 8159 | case SAQUERY: |
| 8160 | /* Category|Action|TransID (encrypted) */ |
| 8161 | memcpy(pos, "\x6f\xbd\xe9\x4d", 4); |
| 8162 | pos += 4; |
| 8163 | break; |
| 8164 | default: |
| 8165 | return -1; |
| 8166 | } |
| 8167 | |
| 8168 | /* CCMP MIC */ |
| 8169 | memcpy(pos, "\xc8\xd8\x3b\x06\x5d\xb7\x25\x68", 8); |
| 8170 | pos += 8; |
| 8171 | } else { |
| 8172 | switch (frame) { |
| 8173 | case DEAUTH: |
| 8174 | /* reason code = 8 */ |
| 8175 | *pos++ = 0x08; |
| 8176 | *pos++ = 0x00; |
| 8177 | break; |
| 8178 | case DISASSOC: |
| 8179 | /* reason code = 8 */ |
| 8180 | *pos++ = 0x08; |
| 8181 | *pos++ = 0x00; |
| 8182 | break; |
| 8183 | case SAQUERY: |
| 8184 | /* Category - SA Query */ |
| 8185 | *pos++ = 0x08; |
| 8186 | /* SA query Action - Request */ |
| 8187 | *pos++ = 0x00; |
| 8188 | /* Transaction ID */ |
| 8189 | *pos++ = 0x12; |
| 8190 | *pos++ = 0x34; |
| 8191 | break; |
| 8192 | } |
| 8193 | } |
| 8194 | |
| 8195 | s = open_monitor("sigmadut"); |
| 8196 | if (s < 0) { |
| 8197 | send_resp(dut, conn, SIGMA_ERROR, "errorCode,Failed to open " |
| 8198 | "monitor socket"); |
| 8199 | return 0; |
| 8200 | } |
| 8201 | |
| 8202 | res = inject_frame(s, buf, pos - buf, protected == CORRECT_KEY); |
| 8203 | if (res < 0) { |
| 8204 | send_resp(dut, conn, SIGMA_ERROR, "errorCode,Failed to " |
| 8205 | "inject frame"); |
Pradeep Reddy POTTETI | 673d85c | 2016-07-26 19:08:07 +0530 | [diff] [blame] | 8206 | close(s); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8207 | return 0; |
| 8208 | } |
| 8209 | if (res < pos - buf) { |
| 8210 | send_resp(dut, conn, SIGMA_ERROR, "errorCode,Only partial " |
| 8211 | "frame sent"); |
Pradeep Reddy POTTETI | 673d85c | 2016-07-26 19:08:07 +0530 | [diff] [blame] | 8212 | close(s); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8213 | return 0; |
| 8214 | } |
| 8215 | |
| 8216 | close(s); |
| 8217 | |
| 8218 | return 1; |
| 8219 | #else /* __linux__ */ |
| 8220 | send_resp(dut, conn, SIGMA_ERROR, "errorCode,ap_send_frame not " |
| 8221 | "yet supported"); |
| 8222 | return 0; |
| 8223 | #endif /* __linux__ */ |
| 8224 | } |
| 8225 | |
| 8226 | |
| 8227 | int ap_send_frame_hs2(struct sigma_dut *dut, struct sigma_conn *conn, |
| 8228 | struct sigma_cmd *cmd) |
| 8229 | { |
| 8230 | const char *val, *dest; |
| 8231 | char buf[100]; |
| 8232 | |
| 8233 | val = get_param(cmd, "FrameName"); |
| 8234 | if (val == NULL) |
| 8235 | return -1; |
| 8236 | |
| 8237 | if (strcasecmp(val, "QoSMapConfigure") == 0) { |
| 8238 | dest = get_param(cmd, "Dest"); |
| 8239 | if (!dest) |
| 8240 | return -1; |
| 8241 | |
| 8242 | val = get_param(cmd, "QoS_MAP_SET"); |
| 8243 | if (val) { |
| 8244 | dut->ap_qos_map_set = atoi(val); |
| 8245 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_qos_map_set %d", |
| 8246 | dut->ap_qos_map_set); |
| 8247 | } |
| 8248 | |
| 8249 | if (dut->ap_qos_map_set == 1) |
| 8250 | run_hostapd_cli(dut, "set_qos_map_set " QOS_MAP_SET_1); |
| 8251 | else if (dut->ap_qos_map_set == 2) |
| 8252 | run_hostapd_cli(dut, "set_qos_map_set " QOS_MAP_SET_2); |
| 8253 | |
| 8254 | snprintf(buf, sizeof(buf), "send_qos_map_conf %s", dest); |
| 8255 | if (run_hostapd_cli(dut, buf) != 0) |
| 8256 | return -1; |
| 8257 | } |
| 8258 | |
| 8259 | return 1; |
| 8260 | } |
| 8261 | |
| 8262 | |
| 8263 | static int ath_ap_send_frame_vht(struct sigma_dut *dut, struct sigma_conn *conn, |
| 8264 | struct sigma_cmd *cmd) |
| 8265 | { |
| 8266 | const char *val; |
| 8267 | char *ifname; |
| 8268 | char buf[100]; |
| 8269 | int chwidth, nss; |
| 8270 | |
| 8271 | val = get_param(cmd, "FrameName"); |
| 8272 | if (!val || strcasecmp(val, "op_md_notif_frm") != 0) { |
| 8273 | send_resp(dut, conn, SIGMA_ERROR, |
| 8274 | "errorCode,Unsupported FrameName"); |
| 8275 | return 0; |
| 8276 | } |
| 8277 | |
| 8278 | /* |
| 8279 | * Sequence of commands for Opmode notification on |
| 8280 | * Peregrine based products |
| 8281 | */ |
| 8282 | ifname = get_main_ifname(); |
| 8283 | |
| 8284 | /* Disable STBC */ |
| 8285 | snprintf(buf, sizeof(buf), "iwpriv %s tx_stbc 0", ifname); |
| 8286 | if (system(buf) != 0) { |
| 8287 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 8288 | "iwpriv tx_stbc 0 failed!"); |
| 8289 | } |
| 8290 | |
| 8291 | /* Check whether optional arg channel width was passed */ |
| 8292 | val = get_param(cmd, "Channel_width"); |
| 8293 | if (val) { |
| 8294 | switch (atoi(val)) { |
| 8295 | case 20: |
| 8296 | chwidth = 0; |
| 8297 | break; |
| 8298 | case 40: |
| 8299 | chwidth = 1; |
| 8300 | break; |
| 8301 | case 80: |
| 8302 | chwidth = 2; |
| 8303 | break; |
| 8304 | case 160: |
| 8305 | chwidth = 3; |
| 8306 | break; |
| 8307 | default: |
| 8308 | chwidth = 2; |
| 8309 | break; |
| 8310 | } |
| 8311 | snprintf(buf, sizeof(buf), "iwpriv %s chwidth %d", |
| 8312 | ifname, chwidth); |
| 8313 | if (system(buf) != 0) { |
| 8314 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 8315 | "iwpriv chwidth failed!"); |
| 8316 | } |
| 8317 | } |
| 8318 | |
| 8319 | /* Check whether optional arg NSS was passed */ |
| 8320 | val = get_param(cmd, "NSS"); |
| 8321 | if (val) { |
| 8322 | /* Convert nss to chainmask */ |
| 8323 | switch (atoi(val)) { |
| 8324 | case 1: |
| 8325 | nss = 1; |
| 8326 | break; |
| 8327 | case 2: |
| 8328 | nss = 3; |
| 8329 | break; |
| 8330 | case 3: |
| 8331 | nss = 7; |
| 8332 | break; |
| 8333 | default: |
| 8334 | /* We do not support NSS > 3 */ |
| 8335 | nss = 3; |
| 8336 | break; |
| 8337 | } |
| 8338 | snprintf(buf, sizeof(buf), "iwpriv %s rxchainmask %d", |
| 8339 | ifname, nss); |
| 8340 | if (system(buf) != 0) { |
| 8341 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 8342 | "iwpriv rxchainmask failed!"); |
| 8343 | } |
| 8344 | } |
| 8345 | |
| 8346 | /* Send the opmode notification */ |
Sunil Dutt | 27ec7f6 | 2017-09-14 18:22:59 +0300 | [diff] [blame] | 8347 | snprintf(buf, sizeof(buf), "iwpriv %s opmode_notify 1", ifname); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8348 | if (system(buf) != 0) { |
| 8349 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 8350 | "iwpriv opmode_notify failed!"); |
| 8351 | } |
| 8352 | |
| 8353 | return 1; |
| 8354 | } |
| 8355 | |
| 8356 | |
priyadharshini gowthaman | a27b5b6 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 8357 | static int ath_ap_send_frame_loc(struct sigma_dut *dut, struct sigma_conn *conn, |
| 8358 | struct sigma_cmd *cmd) |
| 8359 | { |
| 8360 | const char *val; |
| 8361 | FILE *f; |
priyadharshini gowthaman | a61badd | 2016-08-16 13:37:27 -0700 | [diff] [blame] | 8362 | int rand_int = 0; |
priyadharshini gowthaman | a27b5b6 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 8363 | |
| 8364 | val = get_param(cmd, "MsntType"); |
| 8365 | if (val) { |
| 8366 | if (dut->ap_msnt_type == 0) |
| 8367 | dut->ap_msnt_type = atoi(val); |
| 8368 | |
| 8369 | if (dut->ap_msnt_type != 5 && dut->ap_msnt_type != 2) { |
| 8370 | dut->ap_msnt_type = atoi(val); |
| 8371 | if (dut->ap_msnt_type == 1) { |
priyadharshini gowthaman | a61badd | 2016-08-16 13:37:27 -0700 | [diff] [blame] | 8372 | val = get_param(cmd, "RandInterval"); |
| 8373 | if (val) |
| 8374 | rand_int = atoi(val); |
priyadharshini gowthaman | a27b5b6 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 8375 | f = fopen("/tmp/ftmrr.txt", "a"); |
| 8376 | if (!f) { |
| 8377 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 8378 | "Failed to open /tmp/ftmrr.txt"); |
| 8379 | return -1; |
| 8380 | } |
| 8381 | |
| 8382 | fprintf(f, "sta_mac = %s\n", cmd->values[3]); |
priyadharshini gowthaman | a61badd | 2016-08-16 13:37:27 -0700 | [diff] [blame] | 8383 | 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", |
| 8384 | rand_int, cmd->values[7]); |
priyadharshini gowthaman | a27b5b6 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 8385 | fclose(f); |
| 8386 | dut->ap_msnt_type = 5; |
| 8387 | run_system(dut, "wpc -f /tmp/ftmrr.txt"); |
| 8388 | } |
| 8389 | } else if (dut->ap_msnt_type == 5) { |
| 8390 | run_system(dut, "wpc -f /tmp/ftmrr.txt"); |
| 8391 | } else if (dut->ap_msnt_type == 2) { |
| 8392 | f = fopen("/tmp/wru.txt", "w"); |
| 8393 | if (!f) { |
| 8394 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 8395 | "Failed to open /tmp/wru.txt"); |
| 8396 | return -1; |
| 8397 | } |
| 8398 | |
| 8399 | fprintf(f, "sta_mac = %s\n", cmd->values[3]); |
| 8400 | fprintf(f, "meas_type = 0x08\ndialogtoken = 0x1\nnum_repetitions = 0x0\nmeas_token = 0x1\nmeas_req_mode = 0x00\nloc_subject = 0x01\n"); |
| 8401 | fclose(f); |
| 8402 | run_system(dut, "wpc -w /tmp/wru.txt"); |
| 8403 | } |
| 8404 | } |
| 8405 | return 1; |
| 8406 | } |
| 8407 | |
| 8408 | |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 8409 | /* |
| 8410 | * The following functions parse_send_frame_params_int(), |
| 8411 | * parse_send_frame_params_str(), and parse_send_frame_params_mac() |
| 8412 | * are used by ath_ap_send_frame_bcn_rpt_req(). |
| 8413 | * Beacon Report Request is a frame used as part of the MBO program. |
| 8414 | * The command for sending beacon report has a lot of |
| 8415 | * arguments and having these functions reduces code size. |
| 8416 | * |
| 8417 | */ |
| 8418 | static int parse_send_frame_params_int(char *param, struct sigma_cmd *cmd, |
| 8419 | struct sigma_dut *dut, |
| 8420 | char *buf, size_t buf_size) |
| 8421 | { |
| 8422 | const char *str_val; |
| 8423 | int int_val; |
| 8424 | char temp[100]; |
| 8425 | |
| 8426 | str_val = get_param(cmd, param); |
| 8427 | if (!str_val) { |
| 8428 | sigma_dut_print(dut, DUT_MSG_ERROR, "%s not given", param); |
| 8429 | return -1; |
| 8430 | } |
| 8431 | int_val = atoi(str_val); |
| 8432 | snprintf(temp, sizeof(temp), " %d", int_val); |
Peng Xu | 591be45 | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 8433 | strlcat(buf, temp, buf_size); |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 8434 | return 0; |
| 8435 | } |
| 8436 | |
| 8437 | |
| 8438 | static int parse_send_frame_params_str(char *param, struct sigma_cmd *cmd, |
| 8439 | struct sigma_dut *dut, |
| 8440 | char *buf, size_t buf_size) |
| 8441 | { |
| 8442 | const char *str_val; |
| 8443 | char temp[100]; |
| 8444 | |
| 8445 | str_val = get_param(cmd, param); |
| 8446 | if (!str_val) { |
| 8447 | sigma_dut_print(dut, DUT_MSG_ERROR, "%s not given", param); |
| 8448 | return -1; |
| 8449 | } |
| 8450 | snprintf(temp, sizeof(temp), " %s", str_val); |
| 8451 | temp[sizeof(temp) - 1] = '\0'; |
Peng Xu | 591be45 | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 8452 | strlcat(buf, temp, buf_size); |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 8453 | return 0; |
| 8454 | } |
| 8455 | |
| 8456 | |
| 8457 | static int parse_send_frame_params_mac(char *param, struct sigma_cmd *cmd, |
| 8458 | struct sigma_dut *dut, |
| 8459 | char *buf, size_t buf_size) |
| 8460 | { |
| 8461 | const char *str_val; |
| 8462 | unsigned char mac[6]; |
| 8463 | char temp[100]; |
| 8464 | |
| 8465 | str_val = get_param(cmd, param); |
| 8466 | if (!str_val) { |
| 8467 | sigma_dut_print(dut, DUT_MSG_ERROR, "%s not given", param); |
| 8468 | return -1; |
| 8469 | } |
| 8470 | |
| 8471 | if (parse_mac_address(dut, str_val, mac) < 0) { |
| 8472 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 8473 | "MAC Address not in proper format"); |
| 8474 | return -1; |
| 8475 | } |
| 8476 | snprintf(temp, sizeof(temp), " %02x:%02x:%02x:%02x:%02x:%02x", |
| 8477 | mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]); |
Peng Xu | 591be45 | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 8478 | strlcat(buf, temp, buf_size); |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 8479 | return 0; |
| 8480 | } |
| 8481 | |
| 8482 | |
| 8483 | static void fill_1_or_0_based_on_presence(struct sigma_cmd *cmd, char *param, |
| 8484 | char *buf, size_t buf_size) |
| 8485 | { |
| 8486 | const char *str_val; |
| 8487 | char *value = " 1"; |
| 8488 | |
| 8489 | str_val = get_param(cmd, param); |
| 8490 | if (!str_val || str_val[0] == '\0') |
| 8491 | value = " 0"; |
Peng Xu | 591be45 | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 8492 | strlcat(buf, value, buf_size); |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 8493 | |
| 8494 | } |
| 8495 | |
| 8496 | |
| 8497 | /* |
| 8498 | * wifitool athN sendbcnrpt |
| 8499 | * <STA MAC - Plugs in from Dest_MAC> |
| 8500 | * <regclass - Plugs in from RegClass - int> |
| 8501 | * <channum - Plugs in from Channel PARAM of dev_send_frame - int> |
| 8502 | * <rand_ivl - Plugs in from RandInt - string> |
| 8503 | * <duration - Plugs in from MeaDur - integer> |
| 8504 | * <mode - Plugs in from MeaMode - string> |
| 8505 | * <req_ssid - Plugs in from SSID PARAM of dev_send_frame - string> |
| 8506 | * <rep_cond - Plugs in from RptCond - integer> |
| 8507 | * <rpt_detail - Plugs in from RptDet - integer> |
| 8508 | * <req_ie - Plugs in from ReqInfo PARAM of dev_send_frame - string> |
| 8509 | * <chanrpt_mode - Plugs in from APChanRpt - integer> |
| 8510 | * <specific_bssid - Plugs in from BSSID PARAM of dev_send_frame> |
| 8511 | * [AP channel numbers] |
| 8512 | */ |
| 8513 | static int ath_ap_send_frame_bcn_rpt_req(struct sigma_dut *dut, |
| 8514 | struct sigma_cmd *cmd, |
| 8515 | const char *ifname) |
| 8516 | { |
| 8517 | char buf[100]; |
| 8518 | int rpt_det; |
| 8519 | const char *str_val; |
| 8520 | const char *mea_mode; |
| 8521 | |
| 8522 | snprintf(buf, sizeof(buf), "wifitool %s sendbcnrpt", ifname); |
| 8523 | |
| 8524 | if (parse_send_frame_params_mac("Dest_MAC", cmd, dut, buf, sizeof(buf))) |
| 8525 | return -1; |
| 8526 | if (parse_send_frame_params_int("RegClass", cmd, dut, buf, sizeof(buf))) |
| 8527 | return -1; |
| 8528 | if (parse_send_frame_params_int("Channel", cmd, dut, buf, sizeof(buf))) |
| 8529 | return -1; |
| 8530 | if (parse_send_frame_params_str("RandInt", cmd, dut, buf, sizeof(buf))) |
| 8531 | return -1; |
| 8532 | if (parse_send_frame_params_int("MeaDur", cmd, dut, buf, sizeof(buf))) |
| 8533 | return -1; |
| 8534 | |
| 8535 | str_val = get_param(cmd, "MeaMode"); |
| 8536 | if (!str_val) { |
| 8537 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 8538 | "MeaMode parameter not present in send bcn-rpt-req"); |
| 8539 | return -1; |
| 8540 | } |
| 8541 | if (strcasecmp(str_val, "passive") == 0) { |
| 8542 | mea_mode = " 0"; |
| 8543 | } else if (strcasecmp(str_val, "active") == 0) { |
| 8544 | mea_mode = " 1"; |
| 8545 | } else if (strcasecmp(str_val, "table") == 0) { |
| 8546 | mea_mode = " 2"; |
| 8547 | } else { |
| 8548 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 8549 | "MEA-MODE Value not correctly given"); |
| 8550 | return -1; |
| 8551 | } |
Peng Xu | 591be45 | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 8552 | strlcat(buf, mea_mode, sizeof(buf)); |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 8553 | |
| 8554 | fill_1_or_0_based_on_presence(cmd, "SSID", buf, sizeof(buf)); |
| 8555 | |
| 8556 | if (parse_send_frame_params_int("RptCond", cmd, dut, buf, sizeof(buf))) |
| 8557 | return -1; |
| 8558 | |
| 8559 | if (parse_send_frame_params_int("RptDet", cmd, dut, buf, sizeof(buf))) |
| 8560 | return -1; |
| 8561 | str_val = get_param(cmd, "RptDet"); |
| 8562 | rpt_det = str_val ? atoi(str_val) : 0; |
| 8563 | |
| 8564 | if (rpt_det) |
| 8565 | fill_1_or_0_based_on_presence(cmd, "ReqInfo", buf, sizeof(buf)); |
| 8566 | else |
Peng Xu | 591be45 | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 8567 | strlcat(buf, " 0", sizeof(buf)); |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 8568 | |
| 8569 | if (rpt_det) |
| 8570 | fill_1_or_0_based_on_presence(cmd, "APChanRpt", buf, |
| 8571 | sizeof(buf)); |
| 8572 | else |
Peng Xu | 591be45 | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 8573 | strlcat(buf, " 0", sizeof(buf)); |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 8574 | |
| 8575 | if (parse_send_frame_params_mac("BSSID", cmd, dut, buf, sizeof(buf))) |
| 8576 | return -1; |
| 8577 | |
priyadharshini gowthaman | 2a4d20e | 2017-12-28 13:01:34 -0800 | [diff] [blame] | 8578 | str_val = get_param(cmd, "APChanRpt"); |
| 8579 | if (str_val) { |
| 8580 | const char *pos; |
| 8581 | int ap_chanrpt; |
| 8582 | int ap_chanrpt_2 = 0; |
| 8583 | char chanrpt[100]; |
| 8584 | |
| 8585 | ap_chanrpt = atoi(str_val); |
| 8586 | pos = strchr(str_val, '_'); |
| 8587 | if (pos) { |
| 8588 | pos++; |
| 8589 | ap_chanrpt_2 = atoi(pos); |
| 8590 | } |
| 8591 | if (ap_chanrpt) { |
| 8592 | snprintf(chanrpt, sizeof(chanrpt), " %d", ap_chanrpt); |
| 8593 | strlcat(buf, chanrpt, sizeof(buf)); |
| 8594 | } |
| 8595 | if (ap_chanrpt_2) { |
| 8596 | snprintf(chanrpt, sizeof(chanrpt), " %d", ap_chanrpt_2); |
| 8597 | strlcat(buf, chanrpt, sizeof(buf)); |
| 8598 | } |
| 8599 | } |
| 8600 | |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 8601 | run_system(dut, buf); |
| 8602 | return 0; |
| 8603 | } |
| 8604 | |
| 8605 | |
| 8606 | static void inform_and_sleep(struct sigma_dut *dut, int seconds) |
| 8607 | { |
| 8608 | sigma_dut_print(dut, DUT_MSG_DEBUG, "sleeping for %d seconds", seconds); |
| 8609 | sleep(seconds); |
| 8610 | sigma_dut_print(dut, DUT_MSG_DEBUG, "woke up after %d seconds", |
| 8611 | seconds); |
| 8612 | } |
| 8613 | |
| 8614 | |
| 8615 | static int ath_ap_send_frame_btm_req(struct sigma_dut *dut, |
| 8616 | struct sigma_cmd *cmd, const char *ifname) |
| 8617 | { |
| 8618 | unsigned char mac_addr[ETH_ALEN]; |
| 8619 | int disassoc_timer; |
| 8620 | char buf[100]; |
| 8621 | const char *val; |
| 8622 | int cand_list = 1; |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 8623 | |
| 8624 | val = get_param(cmd, "Dest_MAC"); |
| 8625 | if (!val || parse_mac_address(dut, val, mac_addr) < 0) { |
| 8626 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 8627 | "MAC Address not in proper format"); |
| 8628 | return -1; |
| 8629 | } |
| 8630 | |
| 8631 | val = get_param(cmd, "Disassoc_Timer"); |
| 8632 | if (val) |
| 8633 | disassoc_timer = atoi(val); |
| 8634 | else |
| 8635 | disassoc_timer = dut->ap_disassoc_timer; |
Jouni Malinen | 032aeab | 2018-01-04 12:30:46 +0200 | [diff] [blame] | 8636 | if (disassoc_timer < 0) { |
| 8637 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 8638 | "Invalid Disassoc_Timer value %d", |
| 8639 | disassoc_timer); |
| 8640 | return -1; |
| 8641 | } |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 8642 | |
| 8643 | val = get_param(cmd, "Cand_List"); |
| 8644 | if (val && val[0]) |
| 8645 | cand_list = atoi(val); |
| 8646 | |
| 8647 | val = get_param(cmd, "BTMQuery_Reason_Code"); |
| 8648 | if (val) { |
| 8649 | snprintf(buf, sizeof(buf), "iwpriv %s mbo_trans_rs %s", |
| 8650 | ifname, val); |
| 8651 | run_system(dut, buf); |
| 8652 | } |
| 8653 | |
priyadharshini gowthaman | 776562e | 2017-12-20 12:33:34 -0800 | [diff] [blame] | 8654 | if (dut->ap_btmreq_disassoc_imnt && !dut->ap_assoc_delay) { |
| 8655 | snprintf(buf, sizeof(buf), "iwpriv %s mbo_asoc_ret 1", ifname); |
| 8656 | run_system(dut, buf); |
| 8657 | } |
| 8658 | |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 8659 | snprintf(buf, sizeof(buf), |
priyadharshini gowthaman | 776562e | 2017-12-20 12:33:34 -0800 | [diff] [blame] | 8660 | "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] | 8661 | ifname, mac_addr[0], mac_addr[1], mac_addr[2], mac_addr[3], |
| 8662 | mac_addr[4], mac_addr[5], cand_list, disassoc_timer, |
| 8663 | dut->ap_btmreq_disassoc_imnt, |
| 8664 | dut->ap_btmreq_term_bit, |
priyadharshini gowthaman | 94062b5 | 2017-12-20 12:33:34 -0800 | [diff] [blame] | 8665 | dut->ap_btmreq_bss_term_tsf, |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 8666 | dut->ap_btmreq_bss_term_dur); |
| 8667 | run_system(dut, buf); |
| 8668 | |
| 8669 | if (dut->ap_btmreq_term_bit) { |
priyadharshini gowthaman | 94062b5 | 2017-12-20 12:33:34 -0800 | [diff] [blame] | 8670 | if (dut->ap_btmreq_bss_term_tsf >= 2) |
| 8671 | inform_and_sleep(dut, dut->ap_btmreq_bss_term_tsf - 2); |
priyadharshini gowthaman | 776562e | 2017-12-20 12:33:34 -0800 | [diff] [blame] | 8672 | run_system_wrapper( |
| 8673 | dut, "iwpriv %s kickmac %02x:%02x:%02x:%02x:%02x:%02x", |
| 8674 | ifname, |
| 8675 | mac_addr[0], mac_addr[1], mac_addr[2], |
| 8676 | mac_addr[3], mac_addr[4], mac_addr[5]); |
| 8677 | inform_and_sleep(dut, 2); |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 8678 | run_system_wrapper(dut, "ifconfig %s down", ifname); |
priyadharshini gowthaman | 776562e | 2017-12-20 12:33:34 -0800 | [diff] [blame] | 8679 | inform_and_sleep(dut, 5); |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 8680 | run_system_wrapper(dut, "ifconfig %s up", ifname); |
| 8681 | } else if (dut->ap_btmreq_disassoc_imnt) { |
| 8682 | inform_and_sleep(dut, (disassoc_timer / 1000) + 1); |
| 8683 | run_system_wrapper(dut, |
| 8684 | "iwpriv %s kickmac %02x:%02x:%02x:%02x:%02x:%02x", |
| 8685 | ifname, |
| 8686 | mac_addr[0], mac_addr[1], mac_addr[2], |
| 8687 | mac_addr[3], mac_addr[4], mac_addr[5]); |
| 8688 | } |
| 8689 | return 0; |
| 8690 | } |
| 8691 | |
| 8692 | |
priyadharshini gowthaman | 2a4d20e | 2017-12-28 13:01:34 -0800 | [diff] [blame] | 8693 | static int ath_ap_send_frame_disassoc(struct sigma_dut *dut, |
| 8694 | struct sigma_cmd *cmd, const char *ifname) |
| 8695 | { |
| 8696 | unsigned char mac_addr[ETH_ALEN]; |
| 8697 | const char *val; |
| 8698 | |
| 8699 | val = get_param(cmd, "Dest_MAC"); |
| 8700 | if (!val || parse_mac_address(dut, val, mac_addr) < 0) { |
| 8701 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 8702 | "MAC Address not in proper format"); |
| 8703 | return -1; |
| 8704 | } |
| 8705 | |
| 8706 | run_system_wrapper(dut, |
| 8707 | "iwpriv %s kickmac %02x:%02x:%02x:%02x:%02x:%02x", |
| 8708 | ifname, mac_addr[0], mac_addr[1], mac_addr[2], |
| 8709 | mac_addr[3], mac_addr[4], mac_addr[5]); |
| 8710 | return 0; |
| 8711 | } |
| 8712 | |
| 8713 | |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 8714 | static int ath_ap_send_frame_mbo(struct sigma_dut *dut, struct sigma_conn *conn, |
| 8715 | struct sigma_cmd *cmd) |
| 8716 | { |
| 8717 | const char *val; |
| 8718 | char *ifname; |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 8719 | |
| 8720 | ifname = get_main_ifname(); |
| 8721 | |
| 8722 | val = get_param(cmd, "FrameName"); |
| 8723 | if (!val) |
| 8724 | return -1; |
| 8725 | |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 8726 | if (strcasecmp(val, "BTMReq") == 0) |
| 8727 | ath_ap_send_frame_btm_req(dut, cmd, ifname); |
| 8728 | else if (strcasecmp(val, "BcnRptReq") == 0) |
| 8729 | ath_ap_send_frame_bcn_rpt_req(dut, cmd, ifname); |
priyadharshini gowthaman | 2a4d20e | 2017-12-28 13:01:34 -0800 | [diff] [blame] | 8730 | else if (strcasecmp(val, "disassoc") == 0) |
| 8731 | ath_ap_send_frame_disassoc(dut, cmd, ifname); |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 8732 | else |
| 8733 | return -1; |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 8734 | |
| 8735 | return 1; |
| 8736 | } |
| 8737 | |
| 8738 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8739 | static int ap_send_frame_vht(struct sigma_dut *dut, struct sigma_conn *conn, |
| 8740 | struct sigma_cmd *cmd) |
| 8741 | { |
| 8742 | switch (get_driver_type()) { |
| 8743 | case DRIVER_ATHEROS: |
| 8744 | return ath_ap_send_frame_vht(dut, conn, cmd); |
| 8745 | break; |
| 8746 | case DRIVER_OPENWRT: |
| 8747 | switch (get_openwrt_driver_type()) { |
| 8748 | case OPENWRT_DRIVER_ATHEROS: |
| 8749 | return ath_ap_send_frame_vht(dut, conn, cmd); |
| 8750 | default: |
| 8751 | send_resp(dut, conn, SIGMA_ERROR, |
| 8752 | "errorCode,Unsupported ap_send_frame with the current openwrt driver"); |
| 8753 | return 0; |
| 8754 | } |
| 8755 | default: |
| 8756 | send_resp(dut, conn, SIGMA_ERROR, |
| 8757 | "errorCode,Unsupported ap_send_frame with the current driver"); |
| 8758 | return 0; |
| 8759 | } |
| 8760 | } |
| 8761 | |
| 8762 | |
priyadharshini gowthaman | a27b5b6 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 8763 | static int ap_send_frame_loc(struct sigma_dut *dut, struct sigma_conn *conn, |
| 8764 | struct sigma_cmd *cmd) |
| 8765 | { |
| 8766 | switch (get_driver_type()) { |
| 8767 | case DRIVER_ATHEROS: |
| 8768 | return ath_ap_send_frame_loc(dut, conn, cmd); |
| 8769 | case DRIVER_OPENWRT: |
| 8770 | switch (get_openwrt_driver_type()) { |
| 8771 | case OPENWRT_DRIVER_ATHEROS: |
| 8772 | return ath_ap_send_frame_loc(dut, conn, cmd); |
| 8773 | default: |
| 8774 | send_resp(dut, conn, SIGMA_ERROR, |
| 8775 | "errorCode,Unsupported ap_send_frame_loc with the current openwrt driver"); |
| 8776 | return 0; |
| 8777 | } |
| 8778 | default: |
| 8779 | send_resp(dut, conn, SIGMA_ERROR, |
| 8780 | "errorCode,Unsupported ap_send_frame_loc with the current driver"); |
| 8781 | return 0; |
| 8782 | } |
| 8783 | } |
| 8784 | |
| 8785 | |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 8786 | static int ap_send_frame_mbo(struct sigma_dut *dut, struct sigma_conn *conn, |
| 8787 | struct sigma_cmd *cmd) |
| 8788 | { |
| 8789 | switch (get_driver_type()) { |
| 8790 | case DRIVER_ATHEROS: |
| 8791 | return ath_ap_send_frame_mbo(dut, conn, cmd); |
| 8792 | case DRIVER_OPENWRT: |
| 8793 | switch (get_openwrt_driver_type()) { |
| 8794 | case OPENWRT_DRIVER_ATHEROS: |
| 8795 | return ath_ap_send_frame_mbo(dut, conn, cmd); |
| 8796 | default: |
| 8797 | send_resp(dut, conn, SIGMA_ERROR, |
| 8798 | "errorCode,Unsupported ap_send_frame with the current openwrt driver"); |
| 8799 | return 0; |
| 8800 | } |
| 8801 | default: |
| 8802 | send_resp(dut, conn, SIGMA_ERROR, |
| 8803 | "errorCode,Unsupported ap_send_frame with the current driver"); |
| 8804 | return 0; |
| 8805 | } |
| 8806 | } |
| 8807 | |
| 8808 | |
Lior David | 0fe101e | 2017-03-09 16:09:50 +0200 | [diff] [blame] | 8809 | static int ap_send_frame_60g(struct sigma_dut *dut, |
| 8810 | struct sigma_conn *conn, |
| 8811 | struct sigma_cmd *cmd) |
| 8812 | { |
| 8813 | switch (get_driver_type()) { |
| 8814 | #ifdef __linux__ |
| 8815 | case DRIVER_WIL6210: |
| 8816 | return wil6210_send_frame_60g(dut, conn, cmd); |
| 8817 | #endif /* __linux__ */ |
| 8818 | default: |
| 8819 | send_resp(dut, conn, SIGMA_ERROR, |
| 8820 | "errorCode,Unsupported sta_set_frame(60G) with the current driver"); |
| 8821 | return 0; |
| 8822 | } |
| 8823 | } |
| 8824 | |
| 8825 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8826 | int cmd_ap_send_frame(struct sigma_dut *dut, struct sigma_conn *conn, |
| 8827 | struct sigma_cmd *cmd) |
| 8828 | { |
| 8829 | /* const char *name = get_param(cmd, "NAME"); */ |
| 8830 | /* const char *ifname = get_param(cmd, "INTERFACE"); */ |
| 8831 | const char *val; |
| 8832 | enum send_frame_type frame; |
| 8833 | enum send_frame_protection protected; |
| 8834 | char buf[100]; |
| 8835 | |
| 8836 | val = get_param(cmd, "Program"); |
| 8837 | if (val) { |
| 8838 | if (strcasecmp(val, "HS2") == 0 || |
Adil Saeed Musthafa | 33ea287 | 2017-04-10 23:13:24 -0700 | [diff] [blame] | 8839 | strcasecmp(val, "HS2-R2") == 0 || |
| 8840 | strcasecmp(val, "IOTLP") == 0) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8841 | return ap_send_frame_hs2(dut, conn, cmd); |
| 8842 | if (strcasecmp(val, "VHT") == 0) |
| 8843 | return ap_send_frame_vht(dut, conn, cmd); |
priyadharshini gowthaman | a27b5b6 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 8844 | if (strcasecmp(val, "LOC") == 0) |
| 8845 | return ap_send_frame_loc(dut, conn, cmd); |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 8846 | if (strcasecmp(val, "MBO") == 0) |
| 8847 | return ap_send_frame_mbo(dut, conn, cmd); |
Lior David | 0fe101e | 2017-03-09 16:09:50 +0200 | [diff] [blame] | 8848 | if (strcasecmp(val, "60GHz") == 0) |
| 8849 | return ap_send_frame_60g(dut, conn, cmd); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8850 | } |
| 8851 | |
| 8852 | val = get_param(cmd, "PMFFrameType"); |
| 8853 | if (val == NULL) |
| 8854 | val = get_param(cmd, "FrameName"); |
| 8855 | if (val == NULL) |
| 8856 | val = get_param(cmd, "Type"); |
| 8857 | if (val == NULL) |
| 8858 | return -1; |
| 8859 | if (strcasecmp(val, "disassoc") == 0) |
| 8860 | frame = DISASSOC; |
| 8861 | else if (strcasecmp(val, "deauth") == 0) |
| 8862 | frame = DEAUTH; |
| 8863 | else if (strcasecmp(val, "saquery") == 0) |
| 8864 | frame = SAQUERY; |
| 8865 | else { |
| 8866 | send_resp(dut, conn, SIGMA_ERROR, "errorCode,Unsupported " |
| 8867 | "PMFFrameType"); |
| 8868 | return 0; |
| 8869 | } |
| 8870 | |
| 8871 | val = get_param(cmd, "PMFProtected"); |
| 8872 | if (val == NULL) |
| 8873 | val = get_param(cmd, "Protected"); |
| 8874 | if (val == NULL) |
| 8875 | return -1; |
| 8876 | if (strcasecmp(val, "Correct-key") == 0 || |
| 8877 | strcasecmp(val, "CorrectKey") == 0) |
| 8878 | protected = CORRECT_KEY; |
| 8879 | else if (strcasecmp(val, "IncorrectKey") == 0) |
| 8880 | protected = INCORRECT_KEY; |
| 8881 | else if (strcasecmp(val, "Unprotected") == 0) |
| 8882 | protected = UNPROTECTED; |
| 8883 | else { |
| 8884 | send_resp(dut, conn, SIGMA_ERROR, "errorCode,Unsupported " |
| 8885 | "PMFProtected"); |
| 8886 | return 0; |
| 8887 | } |
| 8888 | |
| 8889 | val = get_param(cmd, "stationID"); |
| 8890 | if (val == NULL) |
| 8891 | return -1; |
| 8892 | |
| 8893 | if (protected == INCORRECT_KEY || |
| 8894 | (protected == UNPROTECTED && frame == SAQUERY)) |
| 8895 | return ap_inject_frame(dut, conn, frame, protected, val); |
| 8896 | |
| 8897 | switch (frame) { |
| 8898 | case DISASSOC: |
| 8899 | snprintf(buf, sizeof(buf), "disassoc %s test=%d", |
| 8900 | val, protected == CORRECT_KEY); |
| 8901 | break; |
| 8902 | case DEAUTH: |
| 8903 | snprintf(buf, sizeof(buf), "deauth %s test=%d", |
| 8904 | val, protected == CORRECT_KEY); |
| 8905 | break; |
| 8906 | case SAQUERY: |
| 8907 | snprintf(buf, sizeof(buf), "sa_query %s", val); |
| 8908 | break; |
| 8909 | } |
| 8910 | |
| 8911 | if (run_hostapd_cli(dut, buf) != 0) |
| 8912 | return -2; |
| 8913 | |
| 8914 | return 1; |
| 8915 | } |
| 8916 | |
| 8917 | |
| 8918 | static int cmd_ap_get_mac_address(struct sigma_dut *dut, |
| 8919 | struct sigma_conn *conn, |
| 8920 | struct sigma_cmd *cmd) |
| 8921 | { |
| 8922 | #if defined( __linux__) |
| 8923 | /* const char *name = get_param(cmd, "NAME"); */ |
| 8924 | /* const char *ifname = get_param(cmd, "INTERFACE"); */ |
Jouni Malinen | f898464 | 2017-10-12 00:02:37 +0300 | [diff] [blame] | 8925 | char resp[100]; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8926 | unsigned char addr[6]; |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 8927 | char ifname[50]; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8928 | struct ifreq ifr; |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 8929 | int s, wlan_tag = 1; |
| 8930 | const char *val; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8931 | |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 8932 | val = get_param(cmd, "WLAN_TAG"); |
| 8933 | if (val) { |
| 8934 | wlan_tag = atoi(val); |
| 8935 | if (wlan_tag < 1 || wlan_tag > 3) { |
| 8936 | /* |
| 8937 | * The only valid WLAN Tags as of now as per the latest |
| 8938 | * WFA scripts are 1, 2, and 3. |
| 8939 | */ |
Jouni Malinen | f898464 | 2017-10-12 00:02:37 +0300 | [diff] [blame] | 8940 | send_resp(dut, conn, SIGMA_ERROR, |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 8941 | "errorCode,Unsupported WLAN_TAG"); |
| 8942 | return 0; |
| 8943 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8944 | } |
| 8945 | |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 8946 | get_if_name(dut, ifname, sizeof(ifname), wlan_tag); |
| 8947 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8948 | s = socket(AF_INET, SOCK_DGRAM, 0); |
| 8949 | if (s < 0) |
| 8950 | return -1; |
| 8951 | memset(&ifr, 0, sizeof(ifr)); |
Peng Xu | b8fc5cc | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 8952 | strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name)); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8953 | if (ioctl(s, SIOCGIFHWADDR, &ifr) < 0) { |
| 8954 | perror("ioctl"); |
| 8955 | close(s); |
Jouni Malinen | f898464 | 2017-10-12 00:02:37 +0300 | [diff] [blame] | 8956 | snprintf(resp, sizeof(resp), |
| 8957 | "errorCode,Could not find interface %s", ifname); |
| 8958 | send_resp(dut, conn, SIGMA_ERROR, resp); |
| 8959 | return 0; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8960 | } |
| 8961 | close(s); |
| 8962 | memcpy(addr, ifr.ifr_hwaddr.sa_data, 6); |
| 8963 | |
| 8964 | snprintf(resp, sizeof(resp), "mac,%02x:%02x:%02x:%02x:%02x:%02x", |
| 8965 | addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]); |
| 8966 | send_resp(dut, conn, SIGMA_COMPLETE, resp); |
| 8967 | return 0; |
| 8968 | #elif defined( __QNXNTO__) |
| 8969 | char resp[50]; |
| 8970 | unsigned char addr[6]; |
| 8971 | |
| 8972 | if (!sigma_main_ifname) { |
| 8973 | send_resp(dut, conn, SIGMA_ERROR, "ifname is null"); |
| 8974 | return 0; |
| 8975 | } |
| 8976 | |
| 8977 | if (get_hwaddr(sigma_main_ifname, addr) != 0) { |
| 8978 | send_resp(dut, conn, SIGMA_ERROR, |
| 8979 | "errorCode,Failed to get address"); |
| 8980 | return 0; |
| 8981 | } |
| 8982 | snprintf(resp, sizeof(resp), "mac,%02x:%02x:%02x:%02x:%02x:%02x", |
| 8983 | addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]); |
| 8984 | send_resp(dut, conn, SIGMA_COMPLETE, resp); |
| 8985 | return 0; |
| 8986 | #else /* __linux__ */ |
| 8987 | send_resp(dut, conn, SIGMA_ERROR, "errorCode,ap_get_mac_address not " |
| 8988 | "yet supported"); |
| 8989 | return 0; |
| 8990 | #endif /* __linux__ */ |
| 8991 | } |
| 8992 | |
| 8993 | |
Ankita Bajaj | 0d5825b | 2017-10-25 16:20:17 +0530 | [diff] [blame] | 8994 | int sta_cfon_get_mac_address(struct sigma_dut *dut, struct sigma_conn *conn, |
| 8995 | struct sigma_cmd *cmd) |
| 8996 | { |
| 8997 | return cmd_ap_get_mac_address(dut, conn, cmd); |
| 8998 | } |
| 8999 | |
| 9000 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9001 | static int cmd_ap_set_pmf(struct sigma_dut *dut, struct sigma_conn *conn, |
| 9002 | struct sigma_cmd *cmd) |
| 9003 | { |
| 9004 | /* |
| 9005 | * Ignore the command since the parameters are already handled through |
| 9006 | * ap_set_security. |
| 9007 | */ |
| 9008 | |
| 9009 | return 1; |
| 9010 | } |
| 9011 | |
| 9012 | |
| 9013 | static int cmd_ap_set_hs2(struct sigma_dut *dut, struct sigma_conn *conn, |
| 9014 | struct sigma_cmd *cmd) |
| 9015 | { |
| 9016 | /* const char *name = get_param(cmd, "NAME"); */ |
| 9017 | /* const char *ifname = get_param(cmd, "INTERFACE"); */ |
| 9018 | const char *val, *dest; |
| 9019 | char *pos, buf[100]; |
| 9020 | int i, wlan_tag = 1; |
| 9021 | |
| 9022 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_set_hs2: Processing the " |
| 9023 | "following parameters"); |
| 9024 | for (i = 0; i < cmd->count; i++) { |
| 9025 | sigma_dut_print(dut, DUT_MSG_INFO, "%s %s", cmd->params[i], |
| 9026 | (cmd->values[i] ? cmd->values[i] : "NULL")); |
| 9027 | } |
| 9028 | |
| 9029 | val = get_param(cmd, "ICMPv4_ECHO"); |
| 9030 | if (val && atoi(val)) { |
| 9031 | snprintf(buf, sizeof(buf), "ebtables -F"); |
| 9032 | if (system(buf) != 0) { |
| 9033 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 9034 | "Failed to set ebtables rules, RULE-12"); |
| 9035 | } |
| 9036 | return 1; |
| 9037 | } |
| 9038 | |
| 9039 | val = get_param(cmd, "WLAN_TAG"); |
| 9040 | if (val) { |
| 9041 | wlan_tag = atoi(val); |
| 9042 | if (wlan_tag != 1 && wlan_tag != 2) { |
| 9043 | send_resp(dut, conn, SIGMA_INVALID, |
| 9044 | "errorCode,Invalid WLAN_TAG"); |
| 9045 | return 0; |
| 9046 | } |
| 9047 | } |
| 9048 | |
| 9049 | if (wlan_tag == 2) { |
| 9050 | val = get_param(cmd, "PROXY_ARP"); |
| 9051 | if (val) |
| 9052 | dut->ap2_proxy_arp = atoi(val); |
| 9053 | return 1; |
| 9054 | } |
| 9055 | |
| 9056 | dest = get_param(cmd, "STA_MAC"); |
| 9057 | if (dest) { |
| 9058 | /* This is a special/ugly way of using this command. |
| 9059 | * If "Dest" MAC is included, assume that this command |
| 9060 | * is being issued after ap_config_commit for dynamically |
| 9061 | * setting the QoS Map Set. |
| 9062 | */ |
| 9063 | val = get_param(cmd, "QoS_MAP_SET"); |
| 9064 | if (val) { |
| 9065 | dut->ap_qos_map_set = atoi(val); |
| 9066 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_qos_map_set %d", |
| 9067 | dut->ap_qos_map_set); |
| 9068 | } |
| 9069 | |
| 9070 | if (dut->ap_qos_map_set == 1) |
| 9071 | run_hostapd_cli(dut, "set_qos_map_set " QOS_MAP_SET_1); |
| 9072 | else if (dut->ap_qos_map_set == 2) |
| 9073 | run_hostapd_cli(dut, "set_qos_map_set " QOS_MAP_SET_2); |
| 9074 | |
| 9075 | snprintf(buf, sizeof(buf), "send_qos_map_conf %s", dest); |
| 9076 | if (run_hostapd_cli(dut, buf) != 0) |
| 9077 | return -1; |
| 9078 | } |
| 9079 | |
| 9080 | val = get_param(cmd, "DGAF_DISABLE"); |
| 9081 | if (val) |
| 9082 | dut->ap_dgaf_disable = atoi(val); |
| 9083 | |
| 9084 | dut->ap_interworking = 1; |
| 9085 | |
| 9086 | val = get_param(cmd, "INTERWORKING"); |
| 9087 | if (val == NULL) |
| 9088 | val = get_param(cmd, "INTERNETWORKING"); |
| 9089 | if (val != NULL && atoi(val) == 0) { |
| 9090 | dut->ap_interworking = 0; |
| 9091 | dut->ap_hs2 = 0; |
| 9092 | return 1; |
| 9093 | } |
| 9094 | |
| 9095 | val = get_param(cmd, "ACCS_NET_TYPE"); |
| 9096 | if (val) { |
| 9097 | if (strcasecmp(val, "Chargeable_Public_Network") == 0 || |
| 9098 | strcasecmp(val, "Chargable_Public_Network") == 0 || |
| 9099 | strcasecmp(val, "Chargable Public Network") == 0) |
| 9100 | dut->ap_access_net_type = 2; |
| 9101 | else |
| 9102 | dut->ap_access_net_type = atoi(val); |
| 9103 | } |
| 9104 | |
| 9105 | val = get_param(cmd, "INTERNET"); |
| 9106 | if (val) |
| 9107 | dut->ap_internet = atoi(val); |
| 9108 | |
| 9109 | val = get_param(cmd, "VENUE_GRP"); |
| 9110 | if (val) { |
| 9111 | if (strcasecmp(val, "Business") == 0) |
| 9112 | dut->ap_venue_group = 2; |
| 9113 | else |
| 9114 | dut->ap_venue_group = atoi(val); |
| 9115 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_venue_name %d", |
| 9116 | dut->ap_venue_name); |
| 9117 | } |
| 9118 | |
| 9119 | val = get_param(cmd, "VENUE_TYPE"); |
| 9120 | if (val) { |
| 9121 | if (strcasecmp(val, "R&D") == 0) |
| 9122 | dut->ap_venue_type = 8; |
| 9123 | else |
| 9124 | dut->ap_venue_type = atoi(val); |
| 9125 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_venue_type %d", |
| 9126 | dut->ap_venue_type); |
| 9127 | } |
| 9128 | |
| 9129 | val = get_param(cmd, "HESSID"); |
| 9130 | if (val) { |
| 9131 | if (strlen(val) >= sizeof(dut->ap_hessid)) { |
| 9132 | send_resp(dut, conn, SIGMA_ERROR, |
| 9133 | "errorCode,Invalid HESSID"); |
| 9134 | return 0; |
| 9135 | } |
| 9136 | snprintf(dut->ap_hessid, sizeof(dut->ap_hessid), "%s", val); |
| 9137 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_hessid %s", |
| 9138 | dut->ap_hessid); |
| 9139 | } |
| 9140 | |
| 9141 | val = get_param(cmd, "ROAMING_CONS"); |
| 9142 | if (val) { |
| 9143 | if (strlen(val) >= sizeof(dut->ap_roaming_cons)) { |
| 9144 | send_resp(dut, conn, SIGMA_ERROR, |
| 9145 | "errorCode,Invalid ROAMING_CONS"); |
| 9146 | return 0; |
| 9147 | } |
| 9148 | if (strcasecmp(val, "Disabled") == 0) { |
| 9149 | dut->ap_roaming_cons[0] = '\0'; |
| 9150 | } else { |
| 9151 | snprintf(dut->ap_roaming_cons, |
| 9152 | sizeof(dut->ap_roaming_cons), "%s", val); |
| 9153 | } |
| 9154 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_roaming_cons %s", |
| 9155 | dut->ap_roaming_cons); |
| 9156 | } |
| 9157 | |
| 9158 | val = get_param(cmd, "ANQP"); |
| 9159 | if (val) |
| 9160 | dut->ap_anqpserver_on = atoi(val); |
| 9161 | |
| 9162 | val = get_param(cmd, "NAI_REALM_LIST"); |
| 9163 | if (val) { |
| 9164 | dut->ap_nai_realm_list = atoi(val); |
| 9165 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_nai_realm_list %d", |
| 9166 | dut->ap_nai_realm_list); |
| 9167 | } |
| 9168 | |
| 9169 | val = get_param(cmd, "3GPP_INFO"); |
| 9170 | if (val) { |
| 9171 | /* What kind of encoding format is used?! */ |
| 9172 | send_resp(dut, conn, SIGMA_ERROR, "errorCode,3GPP_INFO " |
| 9173 | "not yet supported (contents not fully defined)"); |
| 9174 | return 0; |
| 9175 | } |
| 9176 | |
| 9177 | val = get_param(cmd, "DOMAIN_LIST"); |
| 9178 | if (val) { |
| 9179 | if (strlen(val) >= sizeof(dut->ap_domain_name_list)) { |
| 9180 | send_resp(dut, conn, SIGMA_ERROR, "errorCode,Too long " |
| 9181 | "DOMAIN_LIST"); |
| 9182 | return 0; |
| 9183 | } |
| 9184 | snprintf(dut->ap_domain_name_list, |
| 9185 | sizeof(dut->ap_domain_name_list), "%s", val); |
| 9186 | pos = dut->ap_domain_name_list; |
| 9187 | while (*pos) { |
| 9188 | if (*pos == ';') |
| 9189 | *pos = ','; |
| 9190 | pos++; |
| 9191 | } |
| 9192 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_domain_name_list %s", |
| 9193 | dut->ap_domain_name_list); |
| 9194 | } |
| 9195 | |
| 9196 | val = get_param(cmd, "OPER_NAME"); |
| 9197 | if (val) { |
| 9198 | dut->ap_oper_name = atoi(val); |
| 9199 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_oper_name %d", |
| 9200 | dut->ap_oper_name); |
| 9201 | } |
| 9202 | |
| 9203 | val = get_param(cmd, "VENUE_NAME"); |
| 9204 | if (val) { |
| 9205 | dut->ap_venue_name = atoi(val); |
| 9206 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_venue_name %d", |
| 9207 | dut->ap_venue_name); |
| 9208 | } |
| 9209 | |
| 9210 | val = get_param(cmd, "GAS_CB_DELAY"); |
| 9211 | if (val) { |
| 9212 | dut->ap_gas_cb_delay = atoi(val); |
| 9213 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_gas_cb_delay %d", |
| 9214 | dut->ap_gas_cb_delay); |
| 9215 | } |
| 9216 | |
| 9217 | val = get_param(cmd, "MIH"); |
| 9218 | if (val && atoi(val) > 0) { |
| 9219 | send_resp(dut, conn, SIGMA_ERROR, "errorCode,MIH not " |
| 9220 | "supported"); |
| 9221 | return 0; |
| 9222 | } |
| 9223 | |
| 9224 | val = get_param(cmd, "L2_TRAFFIC_INSPECT"); |
| 9225 | if (val) { |
| 9226 | dut->ap_l2tif = atoi(val); |
| 9227 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_l2tif %d", |
| 9228 | dut->ap_l2tif); |
| 9229 | } |
| 9230 | |
| 9231 | val = get_param(cmd, "BCST_UNCST"); |
| 9232 | if (val) { |
| 9233 | send_resp(dut, conn, SIGMA_ERROR, |
| 9234 | "errorCode,BCST_UNCST not yet supported"); |
| 9235 | return 0; |
| 9236 | } |
| 9237 | |
| 9238 | val = get_param(cmd, "PLMN_MCC"); |
| 9239 | if (val) { |
| 9240 | char mcc[100], *start, *end; |
| 9241 | int i = 0; |
| 9242 | if (strlen(val) >= sizeof(mcc)) { |
| 9243 | send_resp(dut, conn, SIGMA_ERROR, |
| 9244 | "errorCode,PLMN_MCC too long"); |
| 9245 | return 0; |
| 9246 | } |
Peng Xu | b8fc5cc | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 9247 | strlcpy(mcc, val, sizeof(mcc)); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9248 | start = mcc; |
| 9249 | while ((end = strchr(start, ';'))) { |
| 9250 | /* process all except the last */ |
| 9251 | *end = '\0'; |
| 9252 | if (strlen(start) != 3) { |
| 9253 | send_resp(dut, conn, SIGMA_ERROR, |
| 9254 | "errorCode,Invalid PLMN_MCC"); |
| 9255 | return 0; |
| 9256 | } |
| 9257 | snprintf(dut->ap_plmn_mcc[i], |
| 9258 | sizeof(dut->ap_plmn_mcc[i]), "%s", start); |
| 9259 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_plmn_mcc %s", |
| 9260 | dut->ap_plmn_mcc[i]); |
| 9261 | i++; |
| 9262 | start = end + 1; |
| 9263 | *end = ';'; |
| 9264 | } |
| 9265 | if (strlen(start) != 3) { |
| 9266 | send_resp(dut, conn, SIGMA_ERROR, |
| 9267 | "errorCode,Invalid PLMN_MCC"); |
| 9268 | return 0; |
| 9269 | } |
| 9270 | /* process last or only one */ |
| 9271 | snprintf(dut->ap_plmn_mcc[i], |
| 9272 | sizeof(dut->ap_plmn_mcc[i]), "%s", start); |
| 9273 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_plmn_mcc %s", |
| 9274 | dut->ap_plmn_mcc[i]); |
| 9275 | } |
| 9276 | |
| 9277 | val = get_param(cmd, "PLMN_MNC"); |
| 9278 | if (val) { |
| 9279 | char mnc[100], *start, *end; |
| 9280 | int i = 0; |
| 9281 | if (strlen(val) >= sizeof(mnc)) { |
| 9282 | send_resp(dut, conn, SIGMA_ERROR, |
| 9283 | "errorCode,PLMN_MNC too long"); |
| 9284 | return 0; |
| 9285 | } |
Peng Xu | b8fc5cc | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 9286 | strlcpy(mnc, val, sizeof(mnc)); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9287 | start = mnc; |
| 9288 | while ((end = strchr(start, ';'))) { |
| 9289 | *end = '\0'; |
| 9290 | if (strlen(start) != 2 && strlen(start) != 3) { |
| 9291 | send_resp(dut, conn, SIGMA_ERROR, |
| 9292 | "errorCode,Invalid PLMN_MNC"); |
| 9293 | return 0; |
| 9294 | } |
| 9295 | snprintf(dut->ap_plmn_mnc[i], |
| 9296 | sizeof(dut->ap_plmn_mnc[i]), "%s", start); |
| 9297 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_plmn_mnc %s", |
| 9298 | dut->ap_plmn_mnc[i]); |
| 9299 | i++; |
| 9300 | start = end + 1; |
| 9301 | *end = ';'; |
| 9302 | } |
| 9303 | if (strlen(start) != 2 && strlen(start) != 3) { |
| 9304 | send_resp(dut, conn, SIGMA_ERROR, |
| 9305 | "errorCode,Invalid PLMN_MNC"); |
| 9306 | return 0; |
| 9307 | } |
| 9308 | snprintf(dut->ap_plmn_mnc[i], |
| 9309 | sizeof(dut->ap_plmn_mnc[i]), "%s", start); |
| 9310 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_plmn_mnc %s", |
| 9311 | dut->ap_plmn_mnc[i]); |
| 9312 | } |
| 9313 | |
| 9314 | val = get_param(cmd, "PROXY_ARP"); |
| 9315 | if (val) { |
| 9316 | dut->ap_proxy_arp = atoi(val); |
| 9317 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_proxy_arp %d", |
| 9318 | dut->ap_proxy_arp); |
| 9319 | } |
| 9320 | |
| 9321 | val = get_param(cmd, "WAN_METRICS"); |
| 9322 | if (val) { |
| 9323 | dut->ap_wan_metrics = atoi(val); |
| 9324 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_wan_metrics %d", |
| 9325 | dut->ap_wan_metrics); |
| 9326 | } |
| 9327 | |
| 9328 | val = get_param(cmd, "CONN_CAP"); |
| 9329 | if (val) { |
| 9330 | dut->ap_conn_capab = atoi(val); |
| 9331 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_conn_capab %d", |
| 9332 | dut->ap_conn_capab); |
| 9333 | } |
| 9334 | |
| 9335 | val = get_param(cmd, "IP_ADD_TYPE_AVAIL"); |
| 9336 | if (val) { |
| 9337 | dut->ap_ip_addr_type_avail = atoi(val); |
| 9338 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_ip_addr_type_avail %d", |
| 9339 | dut->ap_ip_addr_type_avail); |
| 9340 | } |
| 9341 | |
| 9342 | val = get_param(cmd, "NET_AUTH_TYPE"); |
| 9343 | if (val) { |
| 9344 | dut->ap_net_auth_type = atoi(val); |
| 9345 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_net_auth_type %d", |
| 9346 | dut->ap_net_auth_type); |
| 9347 | } |
| 9348 | |
| 9349 | val = get_param(cmd, "OP_CLASS"); |
| 9350 | if (val == NULL) |
| 9351 | val = get_param(cmd, "OPER_CLASS"); |
| 9352 | if (val) { |
| 9353 | dut->ap_oper_class = atoi(val); |
| 9354 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_oper_class %d", |
| 9355 | dut->ap_oper_class); |
| 9356 | } |
| 9357 | |
| 9358 | val = get_param(cmd, "OSU_PROVIDER_LIST"); |
| 9359 | if (val) { |
| 9360 | dut->ap_osu_provider_list = atoi(val); |
| 9361 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_osu_provider_list %d", |
| 9362 | dut->ap_osu_provider_list); |
| 9363 | } |
| 9364 | |
| 9365 | val = get_param(cmd, "OSU_SERVER_URI"); |
| 9366 | if (val) { |
| 9367 | i = 0; |
| 9368 | do { |
| 9369 | int len; |
| 9370 | const char *uri = val; |
| 9371 | val = strchr(val, ' '); |
| 9372 | len = val ? (val++ - uri) : (int) strlen(uri); |
| 9373 | if (len > 0 && len < 256) { |
| 9374 | memcpy(dut->ap_osu_server_uri[i], uri, len); |
| 9375 | dut->ap_osu_server_uri[i][len] = '\0'; |
| 9376 | sigma_dut_print(dut, DUT_MSG_INFO, |
| 9377 | "ap_osu_server_uri[%d] %s", i, |
| 9378 | dut->ap_osu_server_uri[i]); |
| 9379 | } |
| 9380 | } while (val && ++i < 10); |
| 9381 | } |
| 9382 | |
| 9383 | val = get_param(cmd, "OSU_METHOD"); |
| 9384 | if (val) { |
| 9385 | i = 0; |
| 9386 | do { |
| 9387 | int len; |
| 9388 | const char *method = val; |
| 9389 | val = strchr(val, ' '); |
| 9390 | len = val ? (val++ - method) : (int) strlen(method); |
| 9391 | if (len > 0) { |
| 9392 | if (strncasecmp(method, "SOAP", len) == 0) |
| 9393 | dut->ap_osu_method[i] = 1; |
| 9394 | else if (strncasecmp(method, "OMADM", len) == 0) |
| 9395 | dut->ap_osu_method[i] = 0; |
| 9396 | else |
| 9397 | return -2; |
| 9398 | } |
| 9399 | } while (val && ++i < 10); |
| 9400 | } |
| 9401 | |
| 9402 | val = get_param(cmd, "OSU_SSID"); |
| 9403 | if (val) { |
| 9404 | if (strlen(val) > 0 && strlen(val) <= 32) { |
Peng Xu | b8fc5cc | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 9405 | strlcpy(dut->ap_osu_ssid, val, |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9406 | sizeof(dut->ap_osu_ssid)); |
| 9407 | sigma_dut_print(dut, DUT_MSG_INFO, |
| 9408 | "ap_osu_ssid %s", |
| 9409 | dut->ap_osu_ssid); |
| 9410 | } |
| 9411 | } |
| 9412 | |
| 9413 | val = get_param(cmd, "OSU_ICON_TAG"); |
| 9414 | if (val) |
| 9415 | dut->ap_osu_icon_tag = atoi(val); |
| 9416 | |
| 9417 | val = get_param(cmd, "QoS_MAP_SET"); |
| 9418 | if (val) { |
| 9419 | dut->ap_qos_map_set = atoi(val); |
| 9420 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_qos_map_set %d", |
| 9421 | dut->ap_qos_map_set); |
| 9422 | } |
| 9423 | |
| 9424 | val = get_param(cmd, "BSS_LOAD"); |
| 9425 | if (val) { |
| 9426 | dut->ap_bss_load = atoi(val); |
| 9427 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_bss_load %d", |
| 9428 | dut->ap_bss_load); |
| 9429 | } |
| 9430 | |
Jouni Malinen | 54a89b0 | 2018-05-01 00:16:26 +0300 | [diff] [blame] | 9431 | val = get_param(cmd, "Venue_URL"); |
| 9432 | if (val) |
| 9433 | dut->ap_venue_url = atoi(val); |
| 9434 | |
Jouni Malinen | f7ff42b | 2018-05-01 00:21:56 +0300 | [diff] [blame] | 9435 | val = get_param(cmd, "Advice_of_Charge"); |
| 9436 | if (val) |
| 9437 | dut->ap_advice_of_charge = atoi(val); |
| 9438 | |
Jouni Malinen | ac10453 | 2018-05-01 00:27:37 +0300 | [diff] [blame] | 9439 | val = get_param(cmd, "Operator_Icon_Metadata"); |
| 9440 | if (val) |
| 9441 | dut->ap_oper_icon_metadata = atoi(val); |
| 9442 | |
Jouni Malinen | ac36714 | 2018-05-01 00:32:24 +0300 | [diff] [blame] | 9443 | val = get_param(cmd, "TnC_File_Name"); |
| 9444 | if (val) |
| 9445 | dut->ap_tnc_file_name = atoi(val); |
| 9446 | |
| 9447 | val = get_param(cmd, "TnC_File_Time_Stamp"); |
| 9448 | if (val) |
| 9449 | dut->ap_tnc_time_stamp = strtol(val, NULL, 10); |
| 9450 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9451 | return 1; |
| 9452 | } |
| 9453 | |
| 9454 | |
| 9455 | void nfc_status(struct sigma_dut *dut, const char *state, const char *oper) |
| 9456 | { |
| 9457 | char buf[100]; |
| 9458 | |
| 9459 | if (!file_exists("nfc-status")) |
| 9460 | return; |
| 9461 | |
| 9462 | snprintf(buf, sizeof(buf), "./nfc-status %s %s", state, oper); |
| 9463 | run_system(dut, buf); |
| 9464 | } |
| 9465 | |
| 9466 | |
| 9467 | static int run_nfc_command(struct sigma_dut *dut, const char *cmd, |
| 9468 | const char *info) |
| 9469 | { |
| 9470 | int res; |
| 9471 | |
| 9472 | printf("\n\n\n=====[ NFC operation ]=========================\n\n"); |
| 9473 | printf("%s\n\n", info); |
| 9474 | |
| 9475 | nfc_status(dut, "START", info); |
| 9476 | res = run_system(dut, cmd); |
| 9477 | nfc_status(dut, res ? "FAIL" : "SUCCESS", info); |
| 9478 | if (res) { |
| 9479 | sigma_dut_print(dut, DUT_MSG_INFO, "Failed to run '%s': %d", |
| 9480 | cmd, res); |
| 9481 | return res; |
| 9482 | } |
| 9483 | |
| 9484 | return 0; |
| 9485 | } |
| 9486 | |
| 9487 | |
| 9488 | static int ap_nfc_write_config_token(struct sigma_dut *dut, |
| 9489 | struct sigma_conn *conn, |
| 9490 | struct sigma_cmd *cmd) |
| 9491 | { |
| 9492 | int res; |
| 9493 | char buf[300]; |
| 9494 | |
| 9495 | run_system(dut, "killall wps-ap-nfc.py"); |
| 9496 | unlink("nfc-success"); |
| 9497 | snprintf(buf, sizeof(buf), |
| 9498 | "./wps-ap-nfc.py --no-wait %s%s --success nfc-success write-config", |
| 9499 | dut->summary_log ? "--summary " : "", |
| 9500 | dut->summary_log ? dut->summary_log : ""); |
| 9501 | res = run_nfc_command(dut, buf, |
| 9502 | "Touch NFC Tag to write WPS configuration token"); |
| 9503 | if (res || !file_exists("nfc-success")) { |
| 9504 | send_resp(dut, conn, SIGMA_ERROR, |
| 9505 | "ErrorCode,Failed to write tag"); |
| 9506 | return 0; |
| 9507 | } |
| 9508 | |
| 9509 | return 1; |
| 9510 | } |
| 9511 | |
| 9512 | |
| 9513 | static int ap_nfc_wps_read_passwd(struct sigma_dut *dut, |
| 9514 | struct sigma_conn *conn, |
| 9515 | struct sigma_cmd *cmd) |
| 9516 | { |
| 9517 | int res; |
| 9518 | char buf[300]; |
| 9519 | |
| 9520 | run_system(dut, "killall wps-ap-nfc.py"); |
| 9521 | |
| 9522 | unlink("nfc-success"); |
| 9523 | snprintf(buf, sizeof(buf), |
| 9524 | "./wps-ap-nfc.py -1 --no-wait %s%s --success nfc-success", |
| 9525 | dut->summary_log ? "--summary " : "", |
| 9526 | dut->summary_log ? dut->summary_log : ""); |
| 9527 | res = run_nfc_command(dut, buf, "Touch NFC Tag to read it"); |
| 9528 | if (res || !file_exists("nfc-success")) { |
| 9529 | send_resp(dut, conn, SIGMA_ERROR, |
| 9530 | "ErrorCode,Failed to read tag"); |
| 9531 | return 0; |
| 9532 | } |
| 9533 | |
| 9534 | return 1; |
| 9535 | } |
| 9536 | |
| 9537 | |
| 9538 | static int ap_nfc_write_password_token(struct sigma_dut *dut, |
| 9539 | struct sigma_conn *conn, |
| 9540 | struct sigma_cmd *cmd) |
| 9541 | { |
| 9542 | int res; |
| 9543 | char buf[300]; |
| 9544 | |
| 9545 | run_system(dut, "killall wps-ap-nfc.py"); |
| 9546 | unlink("nfc-success"); |
| 9547 | snprintf(buf, sizeof(buf), |
| 9548 | "./wps-ap-nfc.py --no-wait %s%s --success nfc-success write-password", |
| 9549 | dut->summary_log ? "--summary " : "", |
| 9550 | dut->summary_log ? dut->summary_log : ""); |
| 9551 | res = run_nfc_command(dut, buf, |
| 9552 | "Touch NFC Tag to write WPS password token"); |
| 9553 | if (res || !file_exists("nfc-success")) { |
| 9554 | send_resp(dut, conn, SIGMA_ERROR, |
| 9555 | "ErrorCode,Failed to write tag"); |
| 9556 | return 0; |
| 9557 | } |
| 9558 | |
| 9559 | if (run_hostapd_cli(dut, "wps_nfc_token enable") != 0) { |
| 9560 | send_resp(dut, conn, SIGMA_ERROR, |
| 9561 | "ErrorCode,Failed to enable NFC password token"); |
| 9562 | return 0; |
| 9563 | } |
| 9564 | |
| 9565 | return 1; |
| 9566 | } |
| 9567 | |
| 9568 | |
| 9569 | static int ap_nfc_wps_connection_handover(struct sigma_dut *dut, |
| 9570 | struct sigma_conn *conn, |
| 9571 | struct sigma_cmd *cmd) |
| 9572 | { |
| 9573 | int res; |
| 9574 | char buf[300]; |
| 9575 | |
| 9576 | run_system(dut, "killall wps-ap-nfc.py"); |
| 9577 | unlink("nfc-success"); |
| 9578 | snprintf(buf, sizeof(buf), |
| 9579 | "./wps-ap-nfc.py -1 --no-wait %s%s --success nfc-success", |
| 9580 | dut->summary_log ? "--summary " : "", |
| 9581 | dut->summary_log ? dut->summary_log : ""); |
| 9582 | res = run_nfc_command(dut, buf, |
| 9583 | "Touch NFC Device to respond to WPS connection handover"); |
| 9584 | if (res) { |
| 9585 | send_resp(dut, conn, SIGMA_ERROR, |
| 9586 | "ErrorCode,Failed to enable NFC for connection " |
| 9587 | "handover"); |
| 9588 | return 0; |
| 9589 | } |
| 9590 | if (!file_exists("nfc-success")) { |
| 9591 | send_resp(dut, conn, SIGMA_ERROR, |
| 9592 | "ErrorCode,Failed to complete NFC connection handover"); |
| 9593 | return 0; |
| 9594 | } |
| 9595 | |
| 9596 | return 1; |
| 9597 | } |
| 9598 | |
| 9599 | |
| 9600 | static int cmd_ap_nfc_action(struct sigma_dut *dut, struct sigma_conn *conn, |
| 9601 | struct sigma_cmd *cmd) |
| 9602 | { |
| 9603 | /* const char *name = get_param(cmd, "Name"); */ |
| 9604 | /* const char *intf = get_param(cmd, "Interface"); */ |
| 9605 | const char *oper = get_param(cmd, "Operation"); |
| 9606 | |
| 9607 | if (oper == NULL) |
| 9608 | return -1; |
| 9609 | |
| 9610 | if (strcasecmp(oper, "WRITE_CONFIG") == 0) |
| 9611 | return ap_nfc_write_config_token(dut, conn, cmd); |
| 9612 | if (strcasecmp(oper, "WRITE_PASSWD") == 0) |
| 9613 | return ap_nfc_write_password_token(dut, conn, cmd); |
| 9614 | if (strcasecmp(oper, "WPS_READ_PASSWD") == 0) |
| 9615 | return ap_nfc_wps_read_passwd(dut, conn, cmd); |
| 9616 | if (strcasecmp(oper, "WPS_CONN_HNDOVR") == 0) |
| 9617 | return ap_nfc_wps_connection_handover(dut, conn, cmd); |
| 9618 | |
| 9619 | send_resp(dut, conn, SIGMA_ERROR, "ErrorCode,Unsupported operation"); |
| 9620 | return 0; |
| 9621 | } |
| 9622 | |
| 9623 | |
| 9624 | static int cmd_ap_wps_read_pin(struct sigma_dut *dut, struct sigma_conn *conn, |
| 9625 | struct sigma_cmd *cmd) |
| 9626 | { |
| 9627 | char *pin = "12345670"; /* TODO: use random PIN */ |
| 9628 | char resp[100]; |
| 9629 | |
| 9630 | snprintf(resp, sizeof(resp), "PIN,%s", pin); |
| 9631 | send_resp(dut, conn, SIGMA_COMPLETE, resp); |
| 9632 | |
| 9633 | return 0; |
| 9634 | } |
| 9635 | |
| 9636 | |
| 9637 | static int ath_vht_op_mode_notif(struct sigma_dut *dut, const char *ifname, |
| 9638 | const char *val) |
| 9639 | { |
| 9640 | char *token, *result; |
| 9641 | int nss = 0, chwidth = 0; |
| 9642 | char buf[100]; |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 9643 | char *saveptr; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9644 | |
| 9645 | /* |
| 9646 | * The following commands should be invoked to generate |
| 9647 | * VHT op mode notification |
| 9648 | */ |
| 9649 | |
| 9650 | /* Extract the NSS info */ |
| 9651 | token = strdup(val); |
| 9652 | if (!token) |
| 9653 | return -1; |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 9654 | result = strtok_r(token, ";", &saveptr); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9655 | if (result) { |
| 9656 | int count = atoi(result); |
| 9657 | |
| 9658 | /* We do not support NSS > 3 */ |
| 9659 | if (count < 0 || count > 3) { |
| 9660 | free(token); |
| 9661 | return -1; |
| 9662 | } |
| 9663 | |
| 9664 | /* Convert nss to chainmask */ |
| 9665 | while (count--) |
| 9666 | nss = (nss << 1) | 1; |
| 9667 | |
| 9668 | snprintf(buf, sizeof(buf), "iwpriv %s rxchainmask %d", |
| 9669 | ifname, nss); |
| 9670 | if (system(buf) != 0) { |
| 9671 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 9672 | "iwpriv wifi1 rxchainmask failed!"); |
| 9673 | } |
| 9674 | } |
| 9675 | |
| 9676 | /* Extract the Channel width info */ |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 9677 | result = strtok_r(NULL, ";", &saveptr); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9678 | if (result) { |
| 9679 | switch (atoi(result)) { |
| 9680 | case 20: |
| 9681 | chwidth = 0; |
| 9682 | break; |
| 9683 | case 40: |
| 9684 | chwidth = 1; |
| 9685 | break; |
| 9686 | case 80: |
| 9687 | chwidth = 2; |
| 9688 | break; |
| 9689 | case 160: |
| 9690 | chwidth = 3; |
| 9691 | break; |
| 9692 | default: |
| 9693 | chwidth = 2; |
| 9694 | break; |
| 9695 | } |
| 9696 | snprintf(buf, sizeof(buf), "iwpriv %s chwidth %d", |
| 9697 | ifname, chwidth); |
| 9698 | if (system(buf) != 0) { |
| 9699 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 9700 | "iwpriv chwidth failed!"); |
| 9701 | } |
| 9702 | } |
| 9703 | |
| 9704 | /* Send the opmode notification */ |
Sunil Dutt | 27ec7f6 | 2017-09-14 18:22:59 +0300 | [diff] [blame] | 9705 | snprintf(buf, sizeof(buf), "iwpriv %s opmode_notify 1", ifname); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9706 | if (system(buf) != 0) { |
| 9707 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 9708 | "iwpriv opmode_notify failed!"); |
| 9709 | } |
| 9710 | free(token); |
| 9711 | |
| 9712 | return 0; |
| 9713 | } |
| 9714 | |
| 9715 | |
| 9716 | static int ath_vht_nss_mcs(struct sigma_dut *dut, const char *ifname, |
| 9717 | const char *val) |
| 9718 | { |
| 9719 | /* String (nss_operating_mode; mcs_operating_mode) */ |
| 9720 | int nss, mcs; |
| 9721 | char *token, *result; |
| 9722 | char buf[100]; |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 9723 | char *saveptr; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9724 | |
| 9725 | token = strdup(val); |
| 9726 | if (!token) |
| 9727 | return -1; |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 9728 | result = strtok_r(token, ";", &saveptr); |
Pradeep Reddy POTTETI | 41b8c54 | 2016-06-15 16:09:46 +0530 | [diff] [blame] | 9729 | if (!result) { |
| 9730 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 9731 | "VHT NSS not specified"); |
| 9732 | goto end; |
| 9733 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9734 | if (strcasecmp(result, "def") != 0) { |
| 9735 | nss = atoi(result); |
| 9736 | |
| 9737 | if (nss == 4) |
| 9738 | ath_disable_txbf(dut, ifname); |
| 9739 | |
| 9740 | snprintf(buf, sizeof(buf), "iwpriv %s nss %d", ifname, nss); |
| 9741 | if (system(buf) != 0) { |
| 9742 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 9743 | "iwpriv nss failed"); |
| 9744 | } |
| 9745 | } else { |
| 9746 | if (dut->device_type == AP_testbed && dut->ap_sgi80 == 1) { |
| 9747 | snprintf(buf, sizeof(buf), "iwpriv %s nss 1", ifname); |
| 9748 | if (system(buf) != 0) { |
| 9749 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 9750 | "iwpriv nss failed"); |
| 9751 | } |
| 9752 | } |
| 9753 | } |
| 9754 | |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 9755 | result = strtok_r(NULL, ";", &saveptr); |
Pradeep Reddy POTTETI | 41b8c54 | 2016-06-15 16:09:46 +0530 | [diff] [blame] | 9756 | if (!result) { |
| 9757 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 9758 | "VHT MCS not specified"); |
| 9759 | goto end; |
| 9760 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9761 | if (strcasecmp(result, "def") == 0) { |
| 9762 | if (dut->device_type == AP_testbed && dut->ap_sgi80 == 1) { |
| 9763 | snprintf(buf, sizeof(buf), "iwpriv %s vhtmcs 7", |
| 9764 | ifname); |
| 9765 | if (system(buf) != 0) { |
| 9766 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 9767 | "iwpriv vhtmcs failed"); |
| 9768 | } |
| 9769 | } else { |
| 9770 | snprintf(buf, sizeof(buf), |
| 9771 | "iwpriv %s set11NRates 0", ifname); |
| 9772 | if (system(buf) != 0) { |
| 9773 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 9774 | "iwpriv set11NRates failed"); |
| 9775 | } |
| 9776 | } |
| 9777 | } else { |
| 9778 | mcs = atoi(result); |
| 9779 | snprintf(buf, sizeof(buf), "iwpriv %s vhtmcs %d", ifname, mcs); |
| 9780 | if (system(buf) != 0) { |
| 9781 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 9782 | "iwpriv vhtmcs failed"); |
| 9783 | } |
| 9784 | } |
| 9785 | |
Pradeep Reddy POTTETI | 41b8c54 | 2016-06-15 16:09:46 +0530 | [diff] [blame] | 9786 | end: |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9787 | free(token); |
| 9788 | return 0; |
| 9789 | } |
| 9790 | |
| 9791 | |
| 9792 | static int ath_vht_chnum_band(struct sigma_dut *dut, const char *ifname, |
| 9793 | const char *val) |
| 9794 | { |
| 9795 | char *token, *result; |
| 9796 | int channel = 36; |
| 9797 | int chwidth = 80; |
| 9798 | char buf[100]; |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 9799 | char *saveptr; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9800 | |
| 9801 | /* Extract the channel info */ |
| 9802 | token = strdup(val); |
| 9803 | if (!token) |
| 9804 | return -1; |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 9805 | result = strtok_r(token, ";", &saveptr); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9806 | if (result) |
| 9807 | channel = atoi(result); |
| 9808 | |
| 9809 | /* Extract the channel width info */ |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 9810 | result = strtok_r(NULL, ";", &saveptr); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9811 | if (result) |
| 9812 | chwidth = atoi(result); |
| 9813 | |
| 9814 | /* Issue the channel switch command */ |
| 9815 | snprintf(buf, sizeof(buf), "iwpriv %s doth_ch_chwidth %d 10 %d", |
| 9816 | ifname, channel, chwidth); |
| 9817 | if (system(buf) != 0) { |
| 9818 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 9819 | "iwpriv doth_ch_chwidth failed!"); |
| 9820 | } |
| 9821 | |
| 9822 | free(token); |
| 9823 | return 0; |
| 9824 | } |
| 9825 | |
| 9826 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9827 | static int ath_ndpa_stainfo_mac(struct sigma_dut *dut, const char *ifname, |
| 9828 | const char *val) |
| 9829 | { |
| 9830 | char buf[80]; |
| 9831 | unsigned char mac_addr[6]; |
| 9832 | |
| 9833 | if (parse_mac_address(dut, val, mac_addr) < 0) |
| 9834 | return -1; |
| 9835 | |
| 9836 | snprintf(buf, sizeof(buf), |
| 9837 | "wifitool %s beeliner_fw_test 92 0x%02x%02x%02x%02x", |
| 9838 | ifname, mac_addr[0], mac_addr[1], mac_addr[2], mac_addr[3]); |
| 9839 | run_system(dut, buf); |
| 9840 | |
| 9841 | snprintf(buf, sizeof(buf), "wifitool %s beeliner_fw_test 93 0x%02x%02x", |
| 9842 | ifname, mac_addr[4], mac_addr[5]); |
| 9843 | run_system(dut, buf); |
| 9844 | |
| 9845 | snprintf(buf, sizeof(buf), "wifitool %s beeliner_fw_test 94 1", ifname); |
| 9846 | run_system(dut, buf); |
| 9847 | |
| 9848 | return 0; |
| 9849 | } |
| 9850 | |
| 9851 | |
priyadharshini gowthaman | e5e2517 | 2015-12-08 14:53:48 -0800 | [diff] [blame] | 9852 | void novap_reset(struct sigma_dut *dut, const char *ifname) |
Priyadharshini Gowthaman | 39beafa | 2015-11-09 14:11:25 -0800 | [diff] [blame] | 9853 | { |
| 9854 | char buf[60]; |
| 9855 | |
| 9856 | snprintf(buf, sizeof(buf), "iwpriv %s novap_reset 1", ifname); |
| 9857 | if (system(buf) != 0) { |
| 9858 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 9859 | "disabling novap reset failed"); |
| 9860 | } |
| 9861 | } |
| 9862 | |
| 9863 | |
Adil Saeed Musthafa | 6906372 | 2017-04-10 23:13:40 -0700 | [diff] [blame] | 9864 | struct mbo_pref_ap * mbo_find_nebor_ap_entry(struct sigma_dut *dut, |
| 9865 | const uint8_t *mac_addr) |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 9866 | { |
Adil Saeed Musthafa | 6906372 | 2017-04-10 23:13:40 -0700 | [diff] [blame] | 9867 | int i; |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 9868 | |
Adil Saeed Musthafa | 6906372 | 2017-04-10 23:13:40 -0700 | [diff] [blame] | 9869 | for (i = 0; i < dut->mbo_pref_ap_cnt; i++) { |
| 9870 | if (memcmp(mac_addr, dut->mbo_pref_aps[i].mac_addr, |
| 9871 | ETH_ALEN) == 0) |
| 9872 | return &dut->mbo_pref_aps[i]; |
| 9873 | } |
| 9874 | return NULL; |
| 9875 | } |
| 9876 | |
| 9877 | |
| 9878 | static void mbo_add_nebor_entry(struct sigma_dut *dut, const uint8_t *mac_addr, |
| 9879 | int ap_ne_class, int ap_ne_op_ch, |
| 9880 | int ap_ne_pref) |
| 9881 | { |
| 9882 | struct mbo_pref_ap *entry; |
| 9883 | uint8_t self_mac[ETH_ALEN]; |
| 9884 | char ifname[50]; |
| 9885 | |
| 9886 | get_if_name(dut, ifname, sizeof(ifname), 1); |
| 9887 | get_hwaddr(ifname, self_mac); |
| 9888 | |
| 9889 | if (memcmp(mac_addr, self_mac, ETH_ALEN) == 0) |
| 9890 | entry = &dut->mbo_self_ap_tuple; |
| 9891 | else |
| 9892 | entry = mbo_find_nebor_ap_entry(dut, mac_addr); |
| 9893 | |
| 9894 | if (!entry) { |
| 9895 | if (dut->mbo_pref_ap_cnt >= MBO_MAX_PREF_BSSIDS) { |
| 9896 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 9897 | "Nebor AP List is full. Not adding"); |
| 9898 | return; |
| 9899 | } |
| 9900 | entry = &dut->mbo_pref_aps[dut->mbo_pref_ap_cnt]; |
| 9901 | dut->mbo_pref_ap_cnt++; |
| 9902 | memcpy(entry->mac_addr, mac_addr, ETH_ALEN); |
| 9903 | entry->ap_ne_class = -1; |
| 9904 | entry->ap_ne_op_ch = -1; |
| 9905 | entry->ap_ne_pref = -1; |
| 9906 | } |
| 9907 | if (ap_ne_class != -1) |
| 9908 | entry->ap_ne_class = ap_ne_class; |
| 9909 | if (ap_ne_op_ch != -1) |
| 9910 | entry->ap_ne_op_ch = ap_ne_op_ch; |
| 9911 | if (ap_ne_pref != -1) |
| 9912 | entry->ap_ne_pref = ap_ne_pref; |
| 9913 | } |
| 9914 | |
| 9915 | |
| 9916 | static int ath_set_nebor_bssid(struct sigma_dut *dut, const char *ifname, |
| 9917 | struct sigma_cmd *cmd) |
| 9918 | { |
| 9919 | unsigned char mac_addr[ETH_ALEN]; |
| 9920 | const char *val; |
| 9921 | /* |
| 9922 | * -1 is invalid value for the following |
| 9923 | * to differentiate between unset and set values |
| 9924 | * -1 => implies not set by CAPI |
| 9925 | */ |
| 9926 | int ap_ne_class = -1, ap_ne_op_ch = -1, ap_ne_pref = -1; |
| 9927 | int list_offset = dut->mbo_pref_ap_cnt; |
| 9928 | |
| 9929 | if (list_offset >= MBO_MAX_PREF_BSSIDS) { |
| 9930 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 9931 | "AP Pref Entry list is full"); |
| 9932 | return -1; |
| 9933 | } |
| 9934 | |
| 9935 | val = get_param(cmd, "Nebor_Op_Class"); |
| 9936 | if (val) |
| 9937 | ap_ne_class = atoi(val); |
| 9938 | |
| 9939 | val = get_param(cmd, "Nebor_Op_Ch"); |
| 9940 | if (val) |
| 9941 | ap_ne_op_ch = atoi(val); |
| 9942 | |
| 9943 | val = get_param(cmd, "Nebor_Pref"); |
| 9944 | if (val) |
| 9945 | ap_ne_pref = atoi(val); |
| 9946 | |
| 9947 | val = get_param(cmd, "Nebor_BSSID"); |
| 9948 | if (!val || parse_mac_address(dut, val, mac_addr) < 0) |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 9949 | return -1; |
| 9950 | |
Adil Saeed Musthafa | 6906372 | 2017-04-10 23:13:40 -0700 | [diff] [blame] | 9951 | mbo_add_nebor_entry(dut, mac_addr, ap_ne_class, ap_ne_op_ch, |
| 9952 | ap_ne_pref); |
| 9953 | apply_mbo_pref_ap_list(dut); |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 9954 | return 0; |
| 9955 | } |
| 9956 | |
| 9957 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9958 | static int ath_ap_set_rfeature(struct sigma_dut *dut, struct sigma_conn *conn, |
| 9959 | struct sigma_cmd *cmd) |
| 9960 | { |
| 9961 | const char *val; |
| 9962 | char *ifname; |
| 9963 | |
| 9964 | ifname = get_main_ifname(); |
| 9965 | |
Priyadharshini Gowthaman | 39beafa | 2015-11-09 14:11:25 -0800 | [diff] [blame] | 9966 | /* Disable vap reset between the commands */ |
| 9967 | novap_reset(dut, ifname); |
| 9968 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9969 | val = get_param(cmd, "Opt_md_notif_ie"); |
| 9970 | if (val && ath_vht_op_mode_notif(dut, ifname, val) < 0) |
| 9971 | return -1; |
| 9972 | |
| 9973 | /* TODO: Optional arguments */ |
| 9974 | |
| 9975 | val = get_param(cmd, "nss_mcs_opt"); |
| 9976 | if (val && ath_vht_nss_mcs(dut, ifname, val) < 0) |
| 9977 | return -1; |
| 9978 | |
| 9979 | val = get_param(cmd, "chnum_band"); |
| 9980 | if (val && ath_vht_chnum_band(dut, ifname, val) < 0) |
| 9981 | return -1; |
| 9982 | |
| 9983 | val = get_param(cmd, "RTS_FORCE"); |
| 9984 | if (val) |
| 9985 | ath_config_rts_force(dut, ifname, val); |
| 9986 | |
| 9987 | val = get_param(cmd, "DYN_BW_SGNL"); |
| 9988 | if (val) |
| 9989 | ath_config_dyn_bw_sig(dut, ifname, val); |
| 9990 | |
| 9991 | val = get_param(cmd, "CTS_WIDTH"); |
| 9992 | if (val) |
| 9993 | ath_set_cts_width(dut, ifname, val); |
| 9994 | |
| 9995 | val = get_param(cmd, "Ndpa_stainfo_mac"); |
| 9996 | if (val && ath_ndpa_stainfo_mac(dut, ifname, val) < 0) |
| 9997 | return -1; |
| 9998 | |
| 9999 | val = get_param(cmd, "txBandwidth"); |
| 10000 | if (val && ath_set_width(dut, conn, ifname, val) < 0) |
| 10001 | return -1; |
| 10002 | |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 10003 | val = get_param(cmd, "Assoc_Disallow"); |
| 10004 | if (val) |
| 10005 | ath_set_assoc_disallow(dut, ifname, val); |
| 10006 | |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 10007 | |
Adil Saeed Musthafa | 6906372 | 2017-04-10 23:13:40 -0700 | [diff] [blame] | 10008 | ath_set_nebor_bssid(dut, ifname, cmd); |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 10009 | val = get_param(cmd, "BTMReq_DisAssoc_Imnt"); |
priyadharshini gowthaman | 776562e | 2017-12-20 12:33:34 -0800 | [diff] [blame] | 10010 | if (val) { |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 10011 | dut->ap_btmreq_disassoc_imnt = atoi(val); |
priyadharshini gowthaman | 776562e | 2017-12-20 12:33:34 -0800 | [diff] [blame] | 10012 | dut->ap_disassoc_timer = 1000; |
| 10013 | } |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 10014 | |
| 10015 | val = get_param(cmd, "BTMReq_Term_Bit"); |
| 10016 | if (val) |
| 10017 | dut->ap_btmreq_term_bit = atoi(val); |
| 10018 | |
Adil Saeed Musthafa | 48c5ab9 | 2017-04-10 23:13:35 -0700 | [diff] [blame] | 10019 | val = get_param(cmd, "Assoc_Delay"); |
priyadharshini gowthaman | 776562e | 2017-12-20 12:33:34 -0800 | [diff] [blame] | 10020 | if (val) { |
| 10021 | dut->ap_assoc_delay = 1; |
Adil Saeed Musthafa | 48c5ab9 | 2017-04-10 23:13:35 -0700 | [diff] [blame] | 10022 | run_system_wrapper(dut, "iwpriv %s mbo_asoc_ret %s", |
| 10023 | ifname, val); |
priyadharshini gowthaman | 776562e | 2017-12-20 12:33:34 -0800 | [diff] [blame] | 10024 | } |
Adil Saeed Musthafa | 48c5ab9 | 2017-04-10 23:13:35 -0700 | [diff] [blame] | 10025 | |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 10026 | val = get_param(cmd, "Disassoc_Timer"); |
| 10027 | if (val) |
| 10028 | dut->ap_disassoc_timer = atoi(val); |
| 10029 | |
| 10030 | val = get_param(cmd, "BSS_Term_Duration"); |
| 10031 | if (val) |
| 10032 | dut->ap_btmreq_bss_term_dur = atoi(val); |
| 10033 | |
priyadharshini gowthaman | 94062b5 | 2017-12-20 12:33:34 -0800 | [diff] [blame] | 10034 | val = get_param(cmd, "BSS_Term_TSF"); |
| 10035 | if (val) |
| 10036 | dut->ap_btmreq_bss_term_tsf = atoi(val); |
| 10037 | |
priyadharshini gowthaman | cb22e43 | 2017-12-28 15:23:31 -0800 | [diff] [blame] | 10038 | val = get_param(cmd, "TxPower"); |
| 10039 | if (val) |
| 10040 | ath_set_txpower(dut, ifname, val); |
| 10041 | |
| 10042 | val = get_param(cmd, "DownlinkAvailCap"); |
| 10043 | if (val) |
| 10044 | dut->ap_dl_availcap = atoi(val); |
| 10045 | |
| 10046 | val = get_param(cmd, "UplinkAvailCap"); |
| 10047 | if (val) { |
| 10048 | dut->ap_ul_availcap = atoi(val); |
| 10049 | run_system_wrapper(dut, "iwpriv %s oce_wan_mtr %d %d", ifname, |
| 10050 | dut->ap_dl_availcap, dut->ap_ul_availcap); |
| 10051 | } |
| 10052 | |
| 10053 | val = get_param(cmd, "RSSIthreshold"); |
| 10054 | if (val) { |
| 10055 | int rssithreshold; |
| 10056 | |
| 10057 | run_system_wrapper(dut, "iwpriv %s oce_asoc_rej 1", ifname); |
| 10058 | rssithreshold = atoi(val); |
| 10059 | run_system_wrapper(dut, "iwpriv %s oce_asoc_rssi %d", ifname, |
| 10060 | rssithreshold); |
| 10061 | } |
| 10062 | |
| 10063 | val = get_param(cmd, "RetryDelay"); |
| 10064 | if (val) { |
| 10065 | int retrydelay; |
| 10066 | |
| 10067 | run_system_wrapper(dut, "iwpriv %s oce_asoc_rej 1", ifname); |
| 10068 | retrydelay = atoi(val); |
| 10069 | run_system_wrapper(dut, "iwpriv %s oce_asoc_dly %d", ifname, |
| 10070 | retrydelay); |
| 10071 | } |
| 10072 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 10073 | return 1; |
| 10074 | } |
| 10075 | |
| 10076 | |
Pradeep Reddy POTTETI | 88fd82c | 2016-03-14 12:20:18 +0530 | [diff] [blame] | 10077 | static int wcn_vht_chnum_band(struct sigma_dut *dut, const char *ifname, |
| 10078 | const char *val) |
| 10079 | { |
| 10080 | char *token, *result; |
| 10081 | int channel = 36; |
| 10082 | char buf[100]; |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 10083 | char *saveptr; |
Pradeep Reddy POTTETI | 88fd82c | 2016-03-14 12:20:18 +0530 | [diff] [blame] | 10084 | |
| 10085 | /* Extract the channel info */ |
| 10086 | token = strdup(val); |
| 10087 | if (!token) |
| 10088 | return -1; |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 10089 | result = strtok_r(token, ";", &saveptr); |
Pradeep Reddy POTTETI | 88fd82c | 2016-03-14 12:20:18 +0530 | [diff] [blame] | 10090 | if (result) |
| 10091 | channel = atoi(result); |
| 10092 | |
| 10093 | /* Issue the channel switch command */ |
| 10094 | snprintf(buf, sizeof(buf), "iwpriv %s setChanChange %d", |
| 10095 | ifname, channel); |
| 10096 | if (system(buf) != 0) { |
| 10097 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 10098 | "iwpriv setChanChange failed!"); |
| 10099 | } |
| 10100 | |
| 10101 | free(token); |
| 10102 | return 0; |
| 10103 | } |
| 10104 | |
| 10105 | |
| 10106 | static int wcn_ap_set_rfeature(struct sigma_dut *dut, struct sigma_conn *conn, |
| 10107 | struct sigma_cmd *cmd) |
| 10108 | { |
| 10109 | const char *val; |
| 10110 | char *ifname; |
| 10111 | |
| 10112 | ifname = get_main_ifname(); |
| 10113 | |
| 10114 | val = get_param(cmd, "chnum_band"); |
| 10115 | if (val && wcn_vht_chnum_band(dut, ifname, val) < 0) |
| 10116 | return -1; |
| 10117 | |
| 10118 | return 1; |
| 10119 | } |
| 10120 | |
| 10121 | |
Mohammed Shafi Shajakhan | b53d8f9 | 2017-02-28 09:05:15 +0530 | [diff] [blame] | 10122 | static int mac80211_vht_chnum_band(struct sigma_dut *dut, const char *ifname, |
| 10123 | const char *val) |
| 10124 | { |
| 10125 | char *token, *result; |
| 10126 | int channel = 36, chwidth = 80, center_freq_idx, center_freq, |
| 10127 | channel_freq; |
| 10128 | char buf[100]; |
| 10129 | char *saveptr; |
| 10130 | |
| 10131 | /* Extract the channel info */ |
| 10132 | token = strdup(val); |
| 10133 | if (!token) |
| 10134 | return -1; |
| 10135 | result = strtok_r(token, ";", &saveptr); |
| 10136 | if (result) |
| 10137 | channel = atoi(result); |
| 10138 | |
| 10139 | /* Extract the channel width info */ |
| 10140 | result = strtok_r(NULL, ";", &saveptr); |
| 10141 | if (result) |
| 10142 | chwidth = atoi(result); |
| 10143 | |
| 10144 | center_freq_idx = get_oper_centr_freq_seq_idx(chwidth, channel); |
| 10145 | if (center_freq_idx < 0) { |
| 10146 | free(token); |
| 10147 | return -1; |
| 10148 | } |
| 10149 | |
| 10150 | center_freq = get_5g_channel_freq(center_freq_idx); |
| 10151 | channel_freq = get_5g_channel_freq(channel); |
| 10152 | |
| 10153 | /* Issue the channel switch command */ |
| 10154 | snprintf(buf, sizeof(buf), |
| 10155 | " -i %s chan_switch 10 %d sec_channel_offset=1 center_freq1=%d bandwidth=%d blocktx vht", |
| 10156 | ifname, channel_freq, center_freq, chwidth); |
| 10157 | if (run_hostapd_cli(dut,buf) != 0) { |
| 10158 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 10159 | "hostapd_cli chan_switch failed"); |
| 10160 | } |
| 10161 | |
| 10162 | free(token); |
| 10163 | return 0; |
| 10164 | } |
| 10165 | |
| 10166 | |
| 10167 | static int mac80211_ap_set_rfeature(struct sigma_dut *dut, |
| 10168 | struct sigma_conn *conn, |
| 10169 | struct sigma_cmd *cmd) |
| 10170 | { |
| 10171 | const char *val; |
| 10172 | char *ifname; |
| 10173 | |
| 10174 | ifname = get_main_ifname(); |
| 10175 | val = get_param(cmd, "chnum_band"); |
| 10176 | if (val && mac80211_vht_chnum_band(dut, ifname, val) < 0) |
| 10177 | return -1; |
| 10178 | |
| 10179 | return 1; |
| 10180 | } |
| 10181 | |
| 10182 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 10183 | static int cmd_ap_set_rfeature(struct sigma_dut *dut, struct sigma_conn *conn, |
| 10184 | struct sigma_cmd *cmd) |
| 10185 | { |
| 10186 | /* const char *name = get_param(cmd, "NAME"); */ |
| 10187 | /* const char *type = get_param(cmd, "Type"); */ |
| 10188 | |
| 10189 | switch (get_driver_type()) { |
| 10190 | case DRIVER_ATHEROS: |
| 10191 | return ath_ap_set_rfeature(dut, conn, cmd); |
| 10192 | case DRIVER_OPENWRT: |
| 10193 | switch (get_openwrt_driver_type()) { |
| 10194 | case OPENWRT_DRIVER_ATHEROS: |
| 10195 | return ath_ap_set_rfeature(dut, conn, cmd); |
| 10196 | default: |
| 10197 | send_resp(dut, conn, SIGMA_ERROR, |
| 10198 | "errorCode,Unsupported ap_set_rfeature with the current openwrt driver"); |
| 10199 | return 0; |
| 10200 | } |
Sreelakshmi Konamki | 0e4fcf9 | 2016-04-26 19:55:01 +0530 | [diff] [blame] | 10201 | case DRIVER_LINUX_WCN: |
Pradeep Reddy POTTETI | 88fd82c | 2016-03-14 12:20:18 +0530 | [diff] [blame] | 10202 | case DRIVER_WCN: |
| 10203 | return wcn_ap_set_rfeature(dut, conn, cmd); |
Mohammed Shafi Shajakhan | b53d8f9 | 2017-02-28 09:05:15 +0530 | [diff] [blame] | 10204 | case DRIVER_MAC80211: |
| 10205 | return mac80211_ap_set_rfeature(dut, conn, cmd); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 10206 | default: |
| 10207 | send_resp(dut, conn, SIGMA_ERROR, |
| 10208 | "errorCode,Unsupported ap_set_rfeature with the current driver"); |
| 10209 | return 0; |
| 10210 | } |
| 10211 | } |
| 10212 | |
| 10213 | |
| 10214 | static int cmd_accesspoint(struct sigma_dut *dut, struct sigma_conn *conn, |
| 10215 | struct sigma_cmd *cmd) |
| 10216 | { |
| 10217 | /* const char *name = get_param(cmd, "NAME"); */ |
| 10218 | return 1; |
| 10219 | } |
| 10220 | |
| 10221 | |
priyadharshini gowthaman | 9149afc | 2018-01-15 13:40:18 -0800 | [diff] [blame] | 10222 | static int cmd_ap_preset_testparameters(struct sigma_dut *dut, |
| 10223 | struct sigma_conn *conn, |
| 10224 | struct sigma_cmd *cmd) |
| 10225 | { |
| 10226 | const char *val; |
| 10227 | |
| 10228 | val = get_param(cmd, "Oper_Chn"); |
| 10229 | if (val) { |
| 10230 | dut->ap_oper_chn = 1; |
| 10231 | dut->ap_channel = atoi(val); |
| 10232 | } |
| 10233 | |
| 10234 | return 1; |
| 10235 | } |
| 10236 | |
| 10237 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 10238 | void ap_register_cmds(void) |
| 10239 | { |
| 10240 | sigma_dut_reg_cmd("ap_ca_version", NULL, cmd_ap_ca_version); |
| 10241 | sigma_dut_reg_cmd("ap_set_wireless", NULL, cmd_ap_set_wireless); |
| 10242 | sigma_dut_reg_cmd("ap_send_addba_req", NULL, cmd_ap_send_addba_req); |
| 10243 | sigma_dut_reg_cmd("ap_set_11n_wireless", NULL, cmd_ap_set_wireless); |
| 10244 | sigma_dut_reg_cmd("ap_set_11n", NULL, cmd_ap_set_wireless); |
| 10245 | 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] | 10246 | sigma_dut_reg_cmd("ap_set_11h", NULL, cmd_ap_set_wireless); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 10247 | sigma_dut_reg_cmd("ap_set_security", NULL, cmd_ap_set_security); |
| 10248 | sigma_dut_reg_cmd("ap_set_apqos", NULL, cmd_ap_set_apqos); |
| 10249 | sigma_dut_reg_cmd("ap_set_staqos", NULL, cmd_ap_set_staqos); |
| 10250 | sigma_dut_reg_cmd("ap_set_radius", NULL, cmd_ap_set_radius); |
| 10251 | sigma_dut_reg_cmd("ap_reboot", NULL, cmd_ap_reboot); |
| 10252 | sigma_dut_reg_cmd("ap_config_commit", NULL, cmd_ap_config_commit); |
| 10253 | sigma_dut_reg_cmd("ap_reset_default", NULL, cmd_ap_reset_default); |
| 10254 | sigma_dut_reg_cmd("ap_get_info", NULL, cmd_ap_get_info); |
| 10255 | sigma_dut_reg_cmd("ap_deauth_sta", NULL, cmd_ap_deauth_sta); |
| 10256 | sigma_dut_reg_cmd("ap_send_frame", NULL, cmd_ap_send_frame); |
| 10257 | sigma_dut_reg_cmd("ap_get_mac_address", NULL, cmd_ap_get_mac_address); |
| 10258 | sigma_dut_reg_cmd("ap_set_pmf", NULL, cmd_ap_set_pmf); |
| 10259 | sigma_dut_reg_cmd("ap_set_hs2", NULL, cmd_ap_set_hs2); |
| 10260 | sigma_dut_reg_cmd("ap_set_rfeature", NULL, cmd_ap_set_rfeature); |
| 10261 | sigma_dut_reg_cmd("ap_nfc_action", NULL, cmd_ap_nfc_action); |
| 10262 | sigma_dut_reg_cmd("ap_wps_read_pin", NULL, cmd_ap_wps_read_pin); |
| 10263 | sigma_dut_reg_cmd("AccessPoint", NULL, cmd_accesspoint); |
priyadharshini gowthaman | 9149afc | 2018-01-15 13:40:18 -0800 | [diff] [blame] | 10264 | sigma_dut_reg_cmd("ap_preset_testparameters", NULL, |
| 10265 | cmd_ap_preset_testparameters); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 10266 | } |