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> |
Pradeep Reddy POTTETI | a076c30 | 2016-05-16 13:36:07 +0530 | [diff] [blame] | 29 | #include <private/android_filesystem_config.h> |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 30 | #endif /* ANDROID */ |
| 31 | |
| 32 | /* Temporary files for ap_send_addba_req */ |
| 33 | #define VI_QOS_TMP_FILE "/tmp/vi-qos.tmp" |
| 34 | #define VI_QOS_FILE "/tmp/vi-qos.txt" |
| 35 | #define VI_QOS_REFFILE "/etc/vi-qos.txt" |
| 36 | |
| 37 | /* Configuration file name on Android */ |
| 38 | #ifndef ANDROID_CONFIG_FILE |
| 39 | #define ANDROID_CONFIG_FILE "/data/misc/wifi/hostapd.conf" |
| 40 | #endif /* ANDROID_CONFIG_FILE */ |
| 41 | /* Maximum length of the line in the configuration file */ |
| 42 | #define MAX_CONF_LINE_LEN (156) |
| 43 | |
Jouni Malinen | d6bf1b4 | 2017-06-23 17:51:01 +0300 | [diff] [blame] | 44 | #ifndef SIGMA_DUT_HOSTAPD_PID_FILE |
| 45 | #define SIGMA_DUT_HOSTAPD_PID_FILE "/tmp/sigma_dut-ap-hostapd.pid" |
| 46 | #endif /* SIGMA_DUT_HOSTAPD_PID_FILE */ |
| 47 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 48 | /* The following is taken from Hotspot 2.0 testplan Appendix B.1 */ |
| 49 | #define ANQP_VENUE_NAME_1 "02019c0002083d656e6757692d466920416c6c69616e63650a3239383920436f7070657220526f61640a53616e746120436c6172612c2043412039353035312c205553415b63686957692d4669e88194e79b9fe5ae9ee9aa8ce5aea40ae4ba8ce4b99de585abe4b99de5b9b4e5ba93e69f8fe8b7af0ae59ca3e5858be68b89e68b892c20e58aa0e588a9e7a68fe5b0bce4ba9a39353035312c20e7be8ee59bbd" |
| 50 | #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\"" |
| 51 | #define ANQP_IP_ADDR_TYPE_1 "060101000c" |
| 52 | #define ANQP_HS20_OPERATOR_FRIENDLY_NAME_1 "dddd2700506f9a11030011656e6757692d466920416c6c69616e63650e63686957692d4669e88194e79b9f" |
| 53 | #define ANQP_HS20_WAN_METRICS_1 "dddd1300506f9a11040001c40900008001000000000000" |
| 54 | #define ANQP_HS20_CONNECTION_CAPABILITY_1 "dddd3200506f9a1105000100000006140001061600000650000106bb010106bb060006c4130011f4010111c413001194110132000001" |
| 55 | #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" |
| 56 | #define QOS_MAP_SET_2 "8,15,0,7,255,255,16,31,32,39,255,255,40,47,48,63" |
| 57 | |
| 58 | extern char *sigma_main_ifname; |
| 59 | extern char *sigma_wpas_ctrl; |
| 60 | extern char *sigma_hapd_ctrl; |
| 61 | extern char *ap_inet_addr; |
| 62 | extern char *ap_inet_mask; |
| 63 | extern char *sigma_radio_ifname[]; |
| 64 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 65 | static int ath_ap_start_hostapd(struct sigma_dut *dut); |
| 66 | static void ath_ap_set_params(struct sigma_dut *dut); |
| 67 | static int kill_process(struct sigma_dut *dut, char *proc_name, |
| 68 | unsigned char is_proc_instance_one, int sig); |
| 69 | |
| 70 | |
| 71 | static int cmd_ap_ca_version(struct sigma_dut *dut, struct sigma_conn *conn, |
| 72 | struct sigma_cmd *cmd) |
| 73 | { |
| 74 | /* const char *name = get_param(cmd, "NAME"); */ |
| 75 | send_resp(dut, conn, SIGMA_COMPLETE, "version,1.0"); |
| 76 | return 0; |
| 77 | } |
| 78 | |
| 79 | |
Jouni Malinen | d6bf1b4 | 2017-06-23 17:51:01 +0300 | [diff] [blame] | 80 | static void kill_hostapd_process_pid(struct sigma_dut *dut) |
| 81 | { |
| 82 | FILE *f; |
| 83 | int pid, res; |
| 84 | char path[100]; |
| 85 | int count; |
| 86 | |
| 87 | f = fopen(SIGMA_DUT_HOSTAPD_PID_FILE, "r"); |
| 88 | if (!f) |
| 89 | return; |
| 90 | res = fscanf(f, "%d", &pid); |
| 91 | fclose(f); |
| 92 | if (res != 1) |
| 93 | return; |
| 94 | sigma_dut_print(dut, DUT_MSG_INFO, "Killing hostapd pid %d", pid); |
| 95 | kill(pid, SIGTERM); |
| 96 | snprintf(path, sizeof(path), "/proc/%d", pid); |
| 97 | for (count = 0; count < 20 && file_exists(path); count++) |
| 98 | usleep(100000); |
| 99 | } |
| 100 | |
| 101 | |
Jouni Malinen | 2e6ccc2 | 2017-09-04 13:43:16 +0300 | [diff] [blame] | 102 | int get_hwaddr(const char *ifname, unsigned char *hwaddr) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 103 | { |
| 104 | #ifndef __QNXNTO__ |
| 105 | struct ifreq ifr; |
| 106 | int s; |
| 107 | |
| 108 | s = socket(AF_INET, SOCK_DGRAM, 0); |
| 109 | if (s < 0) |
| 110 | return -1; |
| 111 | memset(&ifr, 0, sizeof(ifr)); |
Peng Xu | b8fc5cc | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 112 | strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name)); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 113 | if (ioctl(s, SIOCGIFHWADDR, &ifr) < 0) { |
| 114 | perror("ioctl"); |
| 115 | close(s); |
| 116 | return -1; |
| 117 | } |
| 118 | close(s); |
| 119 | memcpy(hwaddr, ifr.ifr_hwaddr.sa_data, 6); |
| 120 | #else /* __QNXNTO__ */ |
| 121 | struct ifaddrs *ifaddrshead = NULL; |
| 122 | int found = 0; |
| 123 | struct ifaddrs *temp_ifap = NULL; |
| 124 | struct sockaddr_dl *sdl = NULL; |
| 125 | |
| 126 | if (getifaddrs(&ifaddrshead) != 0) { |
| 127 | perror("getifaddrs failed"); |
| 128 | return -1; |
| 129 | } |
| 130 | |
| 131 | for (temp_ifap = ifaddrshead; ifaddrshead && !found; |
| 132 | ifaddrshead = ifaddrshead->ifa_next) { |
| 133 | if (ifaddrshead->ifa_addr->sa_family == AF_LINK && |
| 134 | strcmp(ifaddrshead->ifa_name, ifname) == 0) { |
| 135 | found = 1; |
| 136 | sdl = (struct sockaddr_dl *) ifaddrshead->ifa_addr; |
| 137 | if (sdl) |
| 138 | memcpy(hwaddr, LLADDR(sdl), sdl->sdl_alen); |
| 139 | } |
| 140 | } |
| 141 | |
| 142 | if (temp_ifap) |
| 143 | freeifaddrs(temp_ifap); |
| 144 | |
| 145 | if (!found) { |
| 146 | perror("Failed to get the interface"); |
| 147 | return -1; |
| 148 | } |
| 149 | #endif /* __QNXNTO__ */ |
| 150 | return 0; |
| 151 | } |
| 152 | |
| 153 | |
| 154 | static void ath_ap_set_group_id(struct sigma_dut *dut, const char *ifname, |
| 155 | const char *val) |
| 156 | { |
| 157 | char buf[60]; |
| 158 | |
| 159 | snprintf(buf, sizeof(buf), "wifitool %s beeliner_fw_test 55 %d", |
| 160 | ifname, atoi(val)); |
| 161 | if (system(buf) != 0) { |
| 162 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 163 | "wifitool ap_group_id failed"); |
| 164 | } |
| 165 | } |
| 166 | |
| 167 | |
| 168 | void ath_set_cts_width(struct sigma_dut *dut, const char *ifname, |
| 169 | const char *val) |
| 170 | { |
| 171 | char buf[60]; |
| 172 | |
| 173 | /* TODO: Enable support for other values */ |
| 174 | if (strcasecmp(val, "40") == 0) { |
| 175 | snprintf(buf, sizeof(buf), "wifitool %s beeliner_fw_test 54 1", |
| 176 | ifname); |
| 177 | if (system(buf) != 0) { |
| 178 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 179 | "wifitool cts_width failed"); |
| 180 | } |
Priyadharshini Gowthaman | 818afef | 2015-11-09 13:28:15 -0800 | [diff] [blame] | 181 | snprintf(buf, sizeof(buf), |
| 182 | "athdiag --set --address=0x10024 --val=0xd90b8a14"); |
| 183 | if (system(buf) != 0) { |
| 184 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 185 | "disabling phy restart failed"); |
| 186 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 187 | } else { |
| 188 | sigma_dut_print(dut, DUT_MSG_ERROR, "Unsupported CTS_WIDTH"); |
| 189 | } |
| 190 | } |
| 191 | |
| 192 | |
Priyadharshini Gowthaman | 818afef | 2015-11-09 13:28:15 -0800 | [diff] [blame] | 193 | void ath_config_dyn_bw_sig(struct sigma_dut *dut, const char *ifname, |
| 194 | const char *val) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 195 | { |
| 196 | char buf[60]; |
| 197 | |
| 198 | if (strcasecmp(val, "enable") == 0) { |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 199 | dut->ap_dyn_bw_sig = VALUE_ENABLED; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 200 | snprintf(buf, sizeof(buf), "iwpriv %s cwmenable 1", ifname); |
| 201 | if (system(buf) != 0) { |
| 202 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 203 | "iwpriv cwmenable 1 failed"); |
| 204 | } |
Priyadharshini Gowthaman | 818afef | 2015-11-09 13:28:15 -0800 | [diff] [blame] | 205 | snprintf(buf, sizeof(buf), "wifitool %s beeliner_fw_test 96 1", |
| 206 | ifname); |
| 207 | if (system(buf) != 0) { |
| 208 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 209 | "disabling RTS from rate control logic failed"); |
| 210 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 211 | } else if (strcasecmp(val, "disable") == 0) { |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 212 | dut->ap_dyn_bw_sig = VALUE_DISABLED; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 213 | snprintf(buf, sizeof(buf), "iwpriv %s cwmenable 0", ifname); |
| 214 | if (system(buf) != 0) { |
| 215 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 216 | "iwpriv cwmenable 0 failed"); |
| 217 | } |
| 218 | } else { |
| 219 | sigma_dut_print(dut, DUT_MSG_ERROR, "Unsupported DYN_BW_SGL"); |
| 220 | } |
| 221 | } |
| 222 | |
| 223 | |
| 224 | static void ath_config_rts_force(struct sigma_dut *dut, const char *ifname, |
| 225 | const char *val) |
| 226 | { |
| 227 | char buf[60]; |
| 228 | |
| 229 | if (strcasecmp(val, "enable") == 0) { |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 230 | dut->ap_sig_rts = VALUE_ENABLED; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 231 | snprintf(buf, sizeof(buf), "iwconfig %s rts 64", ifname); |
| 232 | if (system(buf) != 0) { |
| 233 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 234 | "iwconfig rts 64 failed"); |
| 235 | } |
priyadharshini gowthaman | 270870e | 2015-12-09 10:10:23 -0800 | [diff] [blame] | 236 | snprintf(buf, sizeof(buf), "wifitool %s beeliner_fw_test 100 1", |
| 237 | ifname); |
| 238 | if (system(buf) != 0) { |
| 239 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 240 | "wifitool beeliner_fw_test 100 1 failed"); |
| 241 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 242 | } else if (strcasecmp(val, "disable") == 0) { |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 243 | dut->ap_sig_rts = VALUE_DISABLED; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 244 | snprintf(buf, sizeof(buf), "iwconfig %s rts 2347", ifname); |
| 245 | if (system(buf) != 0) { |
| 246 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 247 | "iwpriv rts 2347 failed"); |
| 248 | } |
| 249 | } else { |
| 250 | sigma_dut_print(dut, DUT_MSG_ERROR, "Unsupported RTS_FORCE"); |
| 251 | } |
| 252 | } |
| 253 | |
| 254 | |
priyadharshini gowthaman | 09d613e | 2017-12-20 11:43:44 -0800 | [diff] [blame] | 255 | static void ath_radio(struct sigma_dut *dut, const char *val) |
| 256 | { |
| 257 | if (strcasecmp(val, "on") == 0) { |
| 258 | if (dut->ap_interface_5g == 1) { |
| 259 | run_system(dut, "uci set wireless.wifi0.disabled=0"); |
| 260 | } else if (dut->ap_interface_2g == 1) { |
| 261 | run_system(dut, "uci set wireless.wifi1.disabled=0"); |
| 262 | } else { |
| 263 | run_system(dut, "uci set wireless.wifi0.disabled=0"); |
| 264 | run_system(dut, "uci set wireless.wifi1.disabled=0"); |
| 265 | } |
| 266 | run_system(dut, "uci commit"); |
| 267 | run_system(dut, "wifi down"); |
| 268 | run_system(dut, "wifi up"); |
| 269 | } else if (strcasecmp(val, "off") == 0) { |
| 270 | if (dut->ap_interface_5g == 1) { |
| 271 | run_system(dut, "uci set wireless.wifi0.disabled=1"); |
| 272 | } else if (dut->ap_interface_2g == 1) { |
| 273 | run_system(dut, "uci set wireless.wifi1.disabled=1"); |
| 274 | } else { |
| 275 | run_system(dut, "uci set wireless.wifi0.disabled=1"); |
| 276 | run_system(dut, "uci set wireless.wifi1.disabled=1"); |
| 277 | } |
| 278 | run_system(dut, "uci commit"); |
| 279 | run_system(dut, "wifi down"); |
| 280 | run_system(dut, "wifi up"); |
| 281 | } |
| 282 | } |
| 283 | |
| 284 | |
priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 285 | static void deauth_disassoc(struct sigma_dut *dut, const char *ifname, |
| 286 | const char *val) |
| 287 | { |
| 288 | char buf[60]; |
| 289 | |
| 290 | if (strcasecmp(val, "disable") == 0) { |
| 291 | snprintf(buf, sizeof(buf), "iwpriv %s stealthdown 1", ifname); |
| 292 | if (system(buf) != 0) { |
| 293 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 294 | "disable deauthdisassoctx failed"); |
| 295 | } |
| 296 | } |
| 297 | } |
| 298 | |
| 299 | |
priyadharshini gowthaman | cb22e43 | 2017-12-28 15:23:31 -0800 | [diff] [blame] | 300 | static void ath_set_txpower(struct sigma_dut *dut, const char *ifname, |
| 301 | const char *val) |
| 302 | { |
| 303 | char buf[60]; |
| 304 | |
| 305 | if (strcasecmp(val, "high") == 0) |
| 306 | snprintf(buf, sizeof(buf), "iwconfig %s txpower 29", ifname); |
| 307 | else if (strcasecmp(val, "low") == 0) |
| 308 | snprintf(buf, sizeof(buf), "iwconfig %s txpower 1", ifname); |
| 309 | else |
| 310 | sigma_dut_print(dut, DUT_MSG_ERROR, "Unsupported txpower"); |
| 311 | |
| 312 | if (system(buf) != 0) |
| 313 | sigma_dut_print(dut, DUT_MSG_ERROR, "setting txpower failed"); |
| 314 | } |
| 315 | |
| 316 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 317 | static enum ap_mode get_mode(const char *str) |
| 318 | { |
| 319 | if (strcasecmp(str, "11a") == 0) |
| 320 | return AP_11a; |
| 321 | else if (strcasecmp(str, "11g") == 0) |
| 322 | return AP_11g; |
| 323 | else if (strcasecmp(str, "11b") == 0) |
| 324 | return AP_11b; |
| 325 | else if (strcasecmp(str, "11na") == 0) |
| 326 | return AP_11na; |
| 327 | else if (strcasecmp(str, "11ng") == 0) |
| 328 | return AP_11ng; |
| 329 | else if (strcasecmp(str, "11ac") == 0 || strcasecmp(str, "ac") == 0) |
| 330 | return AP_11ac; |
| 331 | else |
| 332 | return AP_inval; |
| 333 | } |
| 334 | |
| 335 | |
| 336 | static int run_hostapd_cli(struct sigma_dut *dut, char *buf) |
| 337 | { |
| 338 | char command[1000]; |
| 339 | const char *bin; |
| 340 | enum driver_type drv = get_driver_type(); |
Adil Saeed Musthafa | 3dd6ca7 | 2017-05-15 12:45:18 -0700 | [diff] [blame] | 341 | char *sigma_hapd_file = sigma_hapd_ctrl; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 342 | |
| 343 | if (file_exists("hostapd_cli")) |
| 344 | bin = "./hostapd_cli"; |
Jouni Malinen | d6bf1b4 | 2017-06-23 17:51:01 +0300 | [diff] [blame] | 345 | else if (file_exists("../../hostapd/hostapd_cli")) |
| 346 | bin = "../../hostapd/hostapd_cli"; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 347 | else |
| 348 | bin = "hostapd_cli"; |
| 349 | |
| 350 | if (drv == DRIVER_OPENWRT && sigma_hapd_ctrl == NULL) { |
Adil Saeed Musthafa | 3dd6ca7 | 2017-05-15 12:45:18 -0700 | [diff] [blame] | 351 | sigma_hapd_file = "/var/run/hostapd-wifi0"; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 352 | |
| 353 | if (sigma_radio_ifname[0] && |
| 354 | strcmp(sigma_radio_ifname[0], "wifi1") == 0) |
Adil Saeed Musthafa | 3dd6ca7 | 2017-05-15 12:45:18 -0700 | [diff] [blame] | 355 | sigma_hapd_file = "/var/run/hostapd-wifi1"; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 356 | else if (sigma_radio_ifname[0] && |
| 357 | strcmp(sigma_radio_ifname[0], "wifi2") == 0) |
Adil Saeed Musthafa | 3dd6ca7 | 2017-05-15 12:45:18 -0700 | [diff] [blame] | 358 | sigma_hapd_file = "/var/run/hostapd-wifi2"; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 359 | } |
| 360 | |
Adil Saeed Musthafa | 3dd6ca7 | 2017-05-15 12:45:18 -0700 | [diff] [blame] | 361 | if (sigma_hapd_file) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 362 | snprintf(command, sizeof(command), "%s -p %s %s", |
Adil Saeed Musthafa | 3dd6ca7 | 2017-05-15 12:45:18 -0700 | [diff] [blame] | 363 | bin, sigma_hapd_file, buf); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 364 | else |
| 365 | snprintf(command, sizeof(command), "%s %s", bin, buf); |
| 366 | return run_system(dut, command); |
| 367 | } |
| 368 | |
| 369 | |
priyadharshini gowthaman | 8e26ff4 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 370 | static int ath_set_lci_config(struct sigma_dut *dut, const char *val, |
| 371 | struct sigma_cmd *cmd) |
| 372 | { |
| 373 | FILE *f; |
| 374 | int i; |
| 375 | |
| 376 | f = fopen("/tmp/lci_cfg.txt", "w"); |
| 377 | if (!f) { |
| 378 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 379 | "Failed to open /tmp/lci_cfg.txt"); |
| 380 | return -1; |
| 381 | } |
| 382 | |
| 383 | for (i = 2; i < cmd->count; i++) |
| 384 | fprintf(f, "%s = %s \n", cmd->params[i], cmd->values[i]); |
| 385 | fprintf(f, "\n"); |
| 386 | fclose(f); |
| 387 | |
| 388 | return 0; |
| 389 | } |
| 390 | |
| 391 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 392 | static int cmd_ap_set_wireless(struct sigma_dut *dut, struct sigma_conn *conn, |
| 393 | struct sigma_cmd *cmd) |
| 394 | { |
| 395 | /* const char *name = get_param(cmd, "NAME"); */ |
| 396 | /* const char *ifname = get_param(cmd, "INTERFACE"); */ |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 397 | const char *val; |
| 398 | unsigned int wlan_tag = 1; |
| 399 | char *ifname = get_main_ifname(); |
| 400 | |
| 401 | val = get_param(cmd, "WLAN_TAG"); |
| 402 | if (val) { |
| 403 | wlan_tag = atoi(val); |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 404 | if (wlan_tag < 1 || wlan_tag > 3) { |
| 405 | /* |
| 406 | * The only valid WLAN Tags as of now as per the latest |
| 407 | * WFA scripts are 1, 2, and 3. |
| 408 | */ |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 409 | send_resp(dut, conn, SIGMA_INVALID, |
| 410 | "errorCode,Invalid WLAN_TAG"); |
| 411 | return 0; |
| 412 | } |
| 413 | } |
| 414 | |
priyadharshini gowthaman | 09d613e | 2017-12-20 11:43:44 -0800 | [diff] [blame] | 415 | val = get_param(cmd, "Interface"); |
| 416 | if (val) { |
| 417 | if (strcasecmp(val, "5G") == 0) |
| 418 | dut->ap_interface_5g = 1; |
| 419 | else |
| 420 | dut->ap_interface_2g = 1; |
| 421 | |
| 422 | if (dut->ap_interface_5g && dut->ap_interface_2g) |
| 423 | dut->ap_is_dual = 1; |
| 424 | } |
| 425 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 426 | val = get_param(cmd, "CountryCode"); |
| 427 | if (val) { |
| 428 | if (strlen(val) > sizeof(dut->ap_countrycode) - 1) |
| 429 | return -1; |
| 430 | snprintf(dut->ap_countrycode, sizeof(dut->ap_countrycode), |
| 431 | "%s", val); |
| 432 | } |
| 433 | |
Pradeep Reddy POTTETI | fba27db | 2015-11-20 16:42:22 +0530 | [diff] [blame] | 434 | val = get_param(cmd, "regulatory_mode"); |
| 435 | if (val) { |
| 436 | if (strcasecmp(val, "11d") == 0 || strcasecmp(val, "11h") == 0) |
| 437 | dut->ap_regulatory_mode = AP_80211D_MODE_ENABLED; |
| 438 | } |
| 439 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 440 | val = get_param(cmd, "SSID"); |
| 441 | if (val) { |
| 442 | if (strlen(val) > sizeof(dut->ap_ssid) - 1) |
| 443 | return -1; |
| 444 | |
| 445 | if (wlan_tag == 1) { |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 446 | /* |
| 447 | * If tag is not specified, it is deemed to be 1. |
| 448 | * Hence tag of 1 is a special case and the values |
| 449 | * corresponding to wlan-tag=1 are stored separately |
| 450 | * from the values corresponding tags 2 and 3. |
| 451 | * This approach minimises the changes to existing code |
| 452 | * since most of the sigma_dut code does not deal with |
| 453 | * WLAN-TAG CAPI variable. |
| 454 | */ |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 455 | snprintf(dut->ap_ssid, |
| 456 | sizeof(dut->ap_ssid), "%s", val); |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 457 | } else { |
| 458 | snprintf(dut->ap_tag_ssid[wlan_tag - 2], |
| 459 | sizeof(dut->ap_tag_ssid[wlan_tag - 2]), |
| 460 | "%s", val); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 461 | } |
| 462 | } |
| 463 | |
| 464 | val = get_param(cmd, "CHANNEL"); |
| 465 | if (val) { |
| 466 | const char *pos; |
| 467 | dut->ap_channel = atoi(val); |
| 468 | pos = strchr(val, ';'); |
| 469 | if (pos) { |
| 470 | pos++; |
| 471 | dut->ap_channel_1 = atoi(pos); |
| 472 | } |
| 473 | } |
| 474 | |
Pradeep Reddy POTTETI | fba27db | 2015-11-20 16:42:22 +0530 | [diff] [blame] | 475 | /* Overwrite the AP channel with DFS channel if configured */ |
| 476 | val = get_param(cmd, "dfs_chan"); |
| 477 | if (val) { |
| 478 | dut->ap_channel = atoi(val); |
| 479 | } |
| 480 | |
| 481 | val = get_param(cmd, "dfs_mode"); |
| 482 | if (val) { |
| 483 | if (strcasecmp(val, "Enable") == 0) |
| 484 | dut->ap_dfs_mode = AP_DFS_MODE_ENABLED; |
| 485 | else if (strcasecmp(val, "Disable") == 0) |
| 486 | dut->ap_dfs_mode = AP_DFS_MODE_DISABLED; |
| 487 | else |
| 488 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 489 | "Unsupported dfs_mode value: %s", val); |
| 490 | } |
| 491 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 492 | val = get_param(cmd, "MODE"); |
| 493 | if (val) { |
| 494 | char *str, *pos; |
| 495 | |
| 496 | str = strdup(val); |
| 497 | if (str == NULL) |
| 498 | return -1; |
| 499 | pos = strchr(str, ';'); |
| 500 | if (pos) |
| 501 | *pos++ = '\0'; |
| 502 | |
| 503 | dut->ap_is_dual = 0; |
| 504 | dut->ap_mode = get_mode(str); |
| 505 | if (dut->ap_mode == AP_inval) { |
| 506 | send_resp(dut, conn, SIGMA_INVALID, |
| 507 | "errorCode,Unsupported MODE"); |
| 508 | free(str); |
| 509 | return 0; |
| 510 | } |
priyadharshini gowthaman | 63ab848 | 2017-12-28 15:32:55 -0800 | [diff] [blame] | 511 | if (dut->ap_mode == AP_11ac && dut->ap_80plus80 != 1) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 512 | dut->ap_chwidth = AP_80; |
| 513 | |
| 514 | if (pos) { |
| 515 | dut->ap_mode_1 = get_mode(pos); |
| 516 | if (dut->ap_mode_1 == AP_inval) { |
| 517 | send_resp(dut, conn, SIGMA_INVALID, |
| 518 | "errorCode,Unsupported MODE"); |
| 519 | free(str); |
| 520 | return 0; |
| 521 | } |
| 522 | if (dut->ap_mode_1 == AP_11ac) |
| 523 | dut->ap_chwidth_1 = AP_80; |
| 524 | dut->ap_is_dual = 1; |
| 525 | } |
| 526 | |
| 527 | free(str); |
| 528 | } else if (dut->ap_mode == AP_inval) { |
| 529 | if (dut->ap_channel <= 11) |
| 530 | dut->ap_mode = AP_11ng; |
| 531 | else if (dut->program == PROGRAM_VHT) |
| 532 | dut->ap_mode = AP_11ac; |
| 533 | else |
| 534 | dut->ap_mode = AP_11na; |
| 535 | } |
| 536 | |
Pradeep Reddy POTTETI | 0d3db63 | 2016-03-11 15:21:11 +0530 | [diff] [blame] | 537 | val = get_param(cmd, "WME"); |
| 538 | if (val) { |
| 539 | if (strcasecmp(val, "on") == 0) |
| 540 | dut->ap_wme = AP_WME_ON; |
| 541 | else if (strcasecmp(val, "off") == 0) |
| 542 | dut->ap_wme = AP_WME_OFF; |
| 543 | else |
| 544 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 545 | "Unsupported WME value: %s", val); |
| 546 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 547 | |
Mohammed Shafi Shajakhan | 02e3b82 | 2017-02-23 04:15:02 +0530 | [diff] [blame] | 548 | val = get_param(cmd, "WMMPS"); |
| 549 | if (val) { |
| 550 | if (strcasecmp(val, "on") == 0) |
| 551 | dut->ap_wmmps = AP_WMMPS_ON; |
| 552 | else if (strcasecmp(val, "off") == 0) |
| 553 | dut->ap_wmmps = AP_WMMPS_OFF; |
| 554 | else |
| 555 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 556 | "Unsupported WMMPS value: %s", val); |
| 557 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 558 | |
| 559 | val = get_param(cmd, "RTS"); |
| 560 | if (val) |
| 561 | dut->ap_rts = atoi(val); |
| 562 | |
| 563 | val = get_param(cmd, "FRGMNT"); |
| 564 | if (val) |
| 565 | dut->ap_frgmnt = atoi(val); |
| 566 | |
| 567 | /* TODO: PWRSAVE */ |
| 568 | |
| 569 | val = get_param(cmd, "BCNINT"); |
| 570 | if (val) |
| 571 | dut->ap_bcnint = atoi(val); |
| 572 | |
| 573 | val = get_param(cmd, "RADIO"); |
| 574 | if (val) { |
Mohammed Shafi Shajakhan | 94997f9 | 2017-01-09 21:31:09 +0530 | [diff] [blame] | 575 | enum driver_type drv = get_driver_type(); |
| 576 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 577 | if (strcasecmp(val, "on") == 0) { |
priyadharshini gowthaman | 09d613e | 2017-12-20 11:43:44 -0800 | [diff] [blame] | 578 | if (drv == DRIVER_OPENWRT) |
| 579 | ath_radio(dut, val); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 580 | if (drv == DRIVER_ATHEROS) |
| 581 | ath_ap_start_hostapd(dut); |
| 582 | else if (cmd_ap_config_commit(dut, conn, cmd) <= 0) |
| 583 | return 0; |
| 584 | } else if (strcasecmp(val, "off") == 0) { |
Mohammed Shafi Shajakhan | 94997f9 | 2017-01-09 21:31:09 +0530 | [diff] [blame] | 585 | if (drv == DRIVER_OPENWRT) { |
priyadharshini gowthaman | 09d613e | 2017-12-20 11:43:44 -0800 | [diff] [blame] | 586 | ath_radio(dut, val); |
Jouni Malinen | d6bf1b4 | 2017-06-23 17:51:01 +0300 | [diff] [blame] | 587 | } else if (dut->use_hostapd_pid_file) { |
| 588 | kill_hostapd_process_pid(dut); |
Mohammed Shafi Shajakhan | 94997f9 | 2017-01-09 21:31:09 +0530 | [diff] [blame] | 589 | } else if (kill_process(dut, "(hostapd)", 1, |
| 590 | SIGTERM) == 0 || |
| 591 | system("killall hostapd") == 0) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 592 | sigma_dut_print(dut, DUT_MSG_INFO, |
| 593 | "Killed hostapd on radio,off"); |
| 594 | } |
| 595 | } else { |
| 596 | send_resp(dut, conn, SIGMA_INVALID, |
| 597 | "errorCode,Unsupported RADIO value"); |
| 598 | return 0; |
| 599 | } |
| 600 | } |
| 601 | |
| 602 | val = get_param(cmd, "P2PMgmtBit"); |
| 603 | if (val) |
| 604 | dut->ap_p2p_mgmt = atoi(val); |
| 605 | |
| 606 | /* TODO: ChannelUsage */ |
| 607 | |
| 608 | /* TODO: 40_INTOLERANT */ |
| 609 | |
| 610 | val = get_param(cmd, "ADDBA_REJECT"); |
| 611 | if (val) { |
| 612 | if (strcasecmp(val, "Enable") == 0) |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 613 | dut->ap_addba_reject = VALUE_ENABLED; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 614 | else if (strcasecmp(val, "Disable") == 0) |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 615 | dut->ap_addba_reject = VALUE_DISABLED; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 616 | } |
| 617 | |
| 618 | val = get_param(cmd, "AMPDU"); |
| 619 | if (val) { |
| 620 | if (strcasecmp(val, "Enable") == 0) |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 621 | dut->ap_ampdu = VALUE_ENABLED; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 622 | else if (strcasecmp(val, "Disable") == 0) |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 623 | dut->ap_ampdu = VALUE_DISABLED; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 624 | } |
| 625 | |
| 626 | val = get_param(cmd, "AMPDU_EXP"); |
| 627 | if (val) |
| 628 | dut->ap_ampdu_exp = atoi(val); |
| 629 | |
| 630 | val = get_param(cmd, "AMSDU"); |
| 631 | if (val) { |
| 632 | if (strcasecmp(val, "Enable") == 0) |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 633 | dut->ap_amsdu = VALUE_ENABLED; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 634 | else if (strcasecmp(val, "Disable") == 0) |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 635 | dut->ap_amsdu = VALUE_DISABLED; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 636 | } |
| 637 | |
| 638 | val = get_param(cmd, "NoAck"); |
| 639 | if (val) { |
| 640 | if (strcasecmp(val, "on") == 0) |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 641 | dut->ap_noack = VALUE_ENABLED; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 642 | else if (strcasecmp(val, "off") == 0) |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 643 | dut->ap_noack = VALUE_DISABLED; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 644 | } |
| 645 | |
| 646 | /* TODO: GREENFIELD */ |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 647 | /* TODO: MCS_32 */ |
| 648 | |
Pradeep Reddy Potteti | 4b0cdee | 2017-03-15 12:37:33 +0530 | [diff] [blame] | 649 | val = get_param(cmd, "OFFSET"); |
| 650 | if (val) { |
| 651 | if (strcasecmp(val, "Above") == 0) |
| 652 | dut->ap_chwidth_offset = SEC_CH_40ABOVE; |
| 653 | else if (strcasecmp(val, "Below") == 0) |
| 654 | dut->ap_chwidth_offset = SEC_CH_40BELOW; |
| 655 | } |
| 656 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 657 | val = get_param(cmd, "MCS_FIXEDRATE"); |
| 658 | if (val) { |
| 659 | dut->ap_fixed_rate = 1; |
| 660 | dut->ap_mcs = atoi(val); |
| 661 | } |
| 662 | |
| 663 | val = get_param(cmd, "SPATIAL_RX_STREAM"); |
| 664 | if (val) { |
| 665 | if (strcasecmp(val, "1SS") == 0 || strcasecmp(val, "1") == 0) { |
| 666 | dut->ap_rx_streams = 1; |
| 667 | if (dut->device_type == AP_testbed) |
| 668 | dut->ap_vhtmcs_map = 0xfffc; |
| 669 | } else if (strcasecmp(val, "2SS") == 0 || |
| 670 | strcasecmp(val, "2") == 0) { |
| 671 | dut->ap_rx_streams = 2; |
| 672 | if (dut->device_type == AP_testbed) |
| 673 | dut->ap_vhtmcs_map = 0xfff0; |
| 674 | } else if (strcasecmp(val, "3SS") == 0 || |
| 675 | strcasecmp(val, "3") == 0) { |
| 676 | dut->ap_rx_streams = 3; |
| 677 | if (dut->device_type == AP_testbed) |
| 678 | dut->ap_vhtmcs_map = 0xffc0; |
| 679 | } else if (strcasecmp(val, "4SS") == 0 || |
| 680 | strcasecmp(val, "4") == 0) { |
| 681 | dut->ap_rx_streams = 4; |
| 682 | } |
| 683 | } |
| 684 | |
| 685 | val = get_param(cmd, "SPATIAL_TX_STREAM"); |
| 686 | if (val) { |
| 687 | if (strcasecmp(val, "1SS") == 0 || |
| 688 | strcasecmp(val, "1") == 0) { |
| 689 | dut->ap_tx_streams = 1; |
| 690 | if (dut->device_type == AP_testbed) |
| 691 | dut->ap_vhtmcs_map = 0xfffc; |
| 692 | } else if (strcasecmp(val, "2SS") == 0 || |
| 693 | strcasecmp(val, "2") == 0) { |
| 694 | dut->ap_tx_streams = 2; |
| 695 | if (dut->device_type == AP_testbed) |
| 696 | dut->ap_vhtmcs_map = 0xfff0; |
| 697 | } else if (strcasecmp(val, "3SS") == 0 || |
| 698 | strcasecmp(val, "3") == 0) { |
| 699 | dut->ap_tx_streams = 3; |
| 700 | if (dut->device_type == AP_testbed) |
| 701 | dut->ap_vhtmcs_map = 0xffc0; |
| 702 | } else if (strcasecmp(val, "4SS") == 0 || |
| 703 | strcasecmp(val, "4") == 0) { |
| 704 | dut->ap_tx_streams = 4; |
| 705 | } |
| 706 | } |
| 707 | |
Adil Saeed Musthafa | 33ea287 | 2017-04-10 23:13:24 -0700 | [diff] [blame] | 708 | val = get_param(cmd, "BSS_max_idle"); |
| 709 | if (val) { |
| 710 | if (strncasecmp(val, "Enable", 7) == 0) { |
| 711 | dut->wnm_bss_max_feature = VALUE_ENABLED; |
| 712 | } else if (strncasecmp(val, "Disable", 8) == 0) { |
| 713 | dut->wnm_bss_max_feature = VALUE_DISABLED; |
| 714 | } else { |
| 715 | send_resp(dut, conn, SIGMA_ERROR, |
| 716 | "errorCode,Invalid value for BSS_max_Feature"); |
| 717 | return 0; |
| 718 | } |
| 719 | } |
| 720 | |
| 721 | val = get_param(cmd, "BSS_Idle_Protection_options"); |
| 722 | if (val) { |
| 723 | int protection = (int) strtol(val, (char **) NULL, 10); |
| 724 | |
| 725 | if (protection != 1 && protection != 0) { |
| 726 | send_resp(dut, conn, SIGMA_ERROR, |
| 727 | "errorCode,Invalid value for BSS_Idle_Protection_options"); |
| 728 | return 0; |
| 729 | } |
| 730 | dut->wnm_bss_max_protection = protection ? |
| 731 | VALUE_ENABLED : VALUE_DISABLED; |
| 732 | } |
| 733 | |
| 734 | val = get_param(cmd, "BSS_max_Idle_period"); |
| 735 | if (val) { |
| 736 | int idle_time = (int) strtol(val, (char **) NULL, 10); |
| 737 | |
| 738 | if (idle_time == LONG_MIN || idle_time == LONG_MAX) { |
| 739 | send_resp(dut, conn, SIGMA_ERROR, |
| 740 | "errorCode,Invalid value for BSS_max_Idle_period"); |
| 741 | return 0; |
| 742 | } |
| 743 | dut->wnm_bss_max_idle_time = idle_time; |
| 744 | } |
| 745 | |
| 746 | val = get_param(cmd, "PROXY_ARP"); |
| 747 | if (val) |
| 748 | dut->ap_proxy_arp = (int) strtol(val, (char **) NULL, 10); |
| 749 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 750 | val = get_param(cmd, "nss_mcs_cap"); |
| 751 | if (val) { |
| 752 | int nss, mcs; |
| 753 | char token[20]; |
| 754 | char *result = NULL; |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 755 | char *saveptr; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 756 | |
| 757 | if (strlen(val) >= sizeof(token)) |
| 758 | return -1; |
Jouni Malinen | 947fdf6 | 2017-05-14 22:29:32 +0300 | [diff] [blame] | 759 | strlcpy(token, val, sizeof(token)); |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 760 | result = strtok_r(token, ";", &saveptr); |
Pradeep Reddy POTTETI | 41b8c54 | 2016-06-15 16:09:46 +0530 | [diff] [blame] | 761 | if (!result) { |
| 762 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 763 | "VHT NSS not specified"); |
| 764 | return 0; |
| 765 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 766 | nss = atoi(result); |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 767 | result = strtok_r(NULL, ";", &saveptr); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 768 | if (result == NULL) { |
| 769 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 770 | "VHTMCS NOT SPECIFIED!"); |
| 771 | return 0; |
| 772 | } |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 773 | result = strtok_r(result, "-", &saveptr); |
| 774 | result = strtok_r(NULL, "-", &saveptr); |
Pradeep Reddy POTTETI | 41b8c54 | 2016-06-15 16:09:46 +0530 | [diff] [blame] | 775 | if (!result) { |
| 776 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 777 | "VHT MCS not specified"); |
| 778 | return 0; |
| 779 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 780 | mcs = atoi(result); |
| 781 | switch (nss) { |
| 782 | case 1: |
| 783 | switch (mcs) { |
| 784 | case 7: |
| 785 | dut->ap_vhtmcs_map = 0xfffc; |
| 786 | break; |
| 787 | case 8: |
| 788 | dut->ap_vhtmcs_map = 0xfffd; |
| 789 | break; |
| 790 | case 9: |
| 791 | dut->ap_vhtmcs_map = 0xfffe; |
| 792 | break; |
| 793 | default: |
| 794 | dut->ap_vhtmcs_map = 0xfffe; |
| 795 | break; |
| 796 | } |
| 797 | break; |
| 798 | case 2: |
| 799 | switch (mcs) { |
| 800 | case 7: |
| 801 | dut->ap_vhtmcs_map = 0xfff0; |
| 802 | break; |
| 803 | case 8: |
| 804 | dut->ap_vhtmcs_map = 0xfff5; |
| 805 | break; |
| 806 | case 9: |
| 807 | dut->ap_vhtmcs_map = 0xfffa; |
| 808 | break; |
| 809 | default: |
| 810 | dut->ap_vhtmcs_map = 0xfffa; |
| 811 | break; |
| 812 | } |
| 813 | break; |
| 814 | case 3: |
| 815 | switch (mcs) { |
| 816 | case 7: |
| 817 | dut->ap_vhtmcs_map = 0xffc0; |
| 818 | break; |
| 819 | case 8: |
| 820 | dut->ap_vhtmcs_map = 0xffd5; |
| 821 | break; |
| 822 | case 9: |
| 823 | dut->ap_vhtmcs_map = 0xffea; |
| 824 | break; |
| 825 | default: |
| 826 | dut->ap_vhtmcs_map = 0xffea; |
| 827 | break; |
| 828 | } |
| 829 | break; |
| 830 | default: |
| 831 | dut->ap_vhtmcs_map = 0xffea; |
| 832 | break; |
| 833 | } |
| 834 | } |
| 835 | |
| 836 | /* TODO: MPDU_MIN_START_SPACING */ |
| 837 | /* TODO: RIFS_TEST */ |
| 838 | /* TODO: SGI20 */ |
| 839 | |
| 840 | val = get_param(cmd, "STBC_TX"); |
| 841 | if (val) |
| 842 | dut->ap_tx_stbc = atoi(val); |
| 843 | |
| 844 | val = get_param(cmd, "WIDTH"); |
| 845 | if (val) { |
| 846 | if (strcasecmp(val, "20") == 0) |
| 847 | dut->ap_chwidth = AP_20; |
| 848 | else if (strcasecmp(val, "40") == 0) |
| 849 | dut->ap_chwidth = AP_40; |
| 850 | else if (strcasecmp(val, "80") == 0) |
| 851 | dut->ap_chwidth = AP_80; |
| 852 | else if (strcasecmp(val, "160") == 0) |
| 853 | dut->ap_chwidth = AP_160; |
priyadharshini gowthaman | 63ab848 | 2017-12-28 15:32:55 -0800 | [diff] [blame] | 854 | else if (strcasecmp(val, "80plus80") == 0) { |
| 855 | dut->ap_80plus80 = 1; |
| 856 | dut->ap_chwidth = AP_80_80; |
| 857 | } else if (strcasecmp(val, "Auto") == 0) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 858 | dut->ap_chwidth = AP_AUTO; |
| 859 | else { |
| 860 | send_resp(dut, conn, SIGMA_INVALID, |
| 861 | "errorCode,Unsupported WIDTH"); |
| 862 | return 0; |
| 863 | } |
| 864 | } |
| 865 | |
| 866 | /* TODO: WIDTH_SCAN */ |
| 867 | |
| 868 | val = get_param(cmd, "TDLSProhibit"); |
| 869 | dut->ap_tdls_prohibit = val && strcasecmp(val, "Enabled") == 0; |
| 870 | val = get_param(cmd, "TDLSChswitchProhibit"); |
| 871 | dut->ap_tdls_prohibit_chswitch = |
| 872 | val && strcasecmp(val, "Enabled") == 0; |
| 873 | val = get_param(cmd, "HS2"); |
| 874 | if (val && wlan_tag == 1) |
| 875 | dut->ap_hs2 = atoi(val); |
| 876 | val = get_param(cmd, "P2P_CROSS_CONNECT"); |
| 877 | if (val) |
| 878 | dut->ap_p2p_cross_connect = strcasecmp(val, "Enabled") == 0; |
| 879 | |
| 880 | val = get_param(cmd, "FakePubKey"); |
| 881 | dut->ap_fake_pkhash = val && atoi(val); |
| 882 | |
| 883 | val = get_param(cmd, "vht_tkip"); |
| 884 | dut->ap_allow_vht_tkip = val && strcasecmp(val, "Enable") == 0; |
| 885 | val = get_param(cmd, "vht_wep"); |
| 886 | dut->ap_allow_vht_wep = val && strcasecmp(val, "Enable") == 0; |
| 887 | |
| 888 | val = get_param(cmd, "Protect_mode"); |
| 889 | dut->ap_disable_protection = val && strcasecmp(val, "Disable") == 0; |
| 890 | |
| 891 | val = get_param(cmd, "DYN_BW_SGNL"); |
| 892 | if (val) { |
| 893 | switch (get_driver_type()) { |
| 894 | case DRIVER_OPENWRT: |
| 895 | switch (get_openwrt_driver_type()) { |
| 896 | case OPENWRT_DRIVER_ATHEROS: |
| 897 | ath_config_dyn_bw_sig(dut, ifname, val); |
| 898 | break; |
| 899 | default: |
| 900 | send_resp(dut, conn, SIGMA_ERROR, |
| 901 | "errorCode,Unsupported DYN_BW_SGNL with OpenWrt driver"); |
| 902 | return 0; |
| 903 | } |
| 904 | break; |
Nirav Shah | 8ad8d74 | 2017-10-17 10:49:11 +0530 | [diff] [blame] | 905 | case DRIVER_WCN: |
| 906 | case DRIVER_LINUX_WCN: |
| 907 | ath_config_dyn_bw_sig(dut, ifname, val); |
| 908 | break; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 909 | default: |
| 910 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 911 | "Unsupported DYN_BW_SGL with the current driver"); |
| 912 | break; |
| 913 | } |
| 914 | } |
| 915 | |
| 916 | val = get_param(cmd, "SGI80"); |
| 917 | if (val) { |
| 918 | if (strcasecmp(val, "enable") == 0) |
| 919 | dut->ap_sgi80 = 1; |
| 920 | else if (strcasecmp(val, "disable") == 0) |
| 921 | dut->ap_sgi80 = 0; |
| 922 | else { |
| 923 | send_resp(dut, conn, SIGMA_INVALID, |
| 924 | "errorCode,Unsupported SGI80"); |
| 925 | return 0; |
| 926 | } |
| 927 | } |
| 928 | |
| 929 | val = get_param(cmd, "LDPC"); |
| 930 | if (val) { |
| 931 | if (strcasecmp(val, "enable") == 0) |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 932 | dut->ap_ldpc = VALUE_ENABLED; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 933 | else if (strcasecmp(val, "disable") == 0) |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 934 | dut->ap_ldpc = VALUE_DISABLED; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 935 | else { |
| 936 | send_resp(dut, conn, SIGMA_INVALID, |
| 937 | "errorCode,Unsupported LDPC"); |
| 938 | return 0; |
| 939 | } |
| 940 | } |
| 941 | |
| 942 | val = get_param(cmd, "BW_SGNL"); |
| 943 | if (val) { |
| 944 | /* |
| 945 | * With dynamic bandwidth signaling enabled we should see |
| 946 | * RTS if the threshold is met. |
| 947 | */ |
| 948 | if (strcasecmp(val, "enable") == 0) { |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 949 | dut->ap_sig_rts = VALUE_ENABLED; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 950 | } else if (strcasecmp(val, "disable") == 0) { |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 951 | dut->ap_sig_rts = VALUE_DISABLED; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 952 | } else { |
| 953 | send_resp(dut, conn, SIGMA_INVALID, |
| 954 | "errorCode,Unsupported BW_SGNL"); |
| 955 | return 0; |
| 956 | } |
| 957 | } |
| 958 | |
| 959 | val = get_param(cmd, "RTS_FORCE"); |
| 960 | if (val) { |
| 961 | switch (get_driver_type()) { |
| 962 | case DRIVER_OPENWRT: |
| 963 | switch (get_openwrt_driver_type()) { |
| 964 | case OPENWRT_DRIVER_ATHEROS: |
| 965 | ath_config_rts_force(dut, ifname, val); |
| 966 | break; |
| 967 | default: |
| 968 | send_resp(dut, conn, SIGMA_ERROR, |
| 969 | "errorCode,Unsupported RTS_FORCE with OpenWrt driver"); |
| 970 | return 0; |
| 971 | } |
| 972 | break; |
| 973 | default: |
| 974 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 975 | "Unsupported RTS_FORCE with the current driver"); |
| 976 | break; |
| 977 | } |
| 978 | } |
| 979 | |
| 980 | val = get_param(cmd, "Zero_crc"); |
| 981 | if (val) { |
| 982 | switch (get_driver_type()) { |
| 983 | case DRIVER_ATHEROS: |
| 984 | ath_set_zero_crc(dut, val); |
| 985 | break; |
| 986 | case DRIVER_OPENWRT: |
| 987 | switch (get_openwrt_driver_type()) { |
| 988 | case OPENWRT_DRIVER_ATHEROS: |
| 989 | ath_set_zero_crc(dut, val); |
| 990 | break; |
| 991 | default: |
| 992 | send_resp(dut, conn, SIGMA_ERROR, |
| 993 | "errorCode,Unsupported zero_crc with the current driver"); |
| 994 | return 0; |
| 995 | } |
| 996 | break; |
| 997 | default: |
| 998 | send_resp(dut, conn, SIGMA_ERROR, |
| 999 | "errorCode,Unsupported zero_crc with the current driver"); |
| 1000 | return 0; |
| 1001 | } |
| 1002 | } |
| 1003 | |
| 1004 | val = get_param(cmd, "TxBF"); |
| 1005 | if (val) |
| 1006 | dut->ap_txBF = strcasecmp(val, "enable") == 0; |
| 1007 | |
| 1008 | val = get_param(cmd, "MU_TxBF"); |
Manikanta Pubbisetty | 210f7c8 | 2017-02-14 12:33:54 +0530 | [diff] [blame] | 1009 | if (val) { |
| 1010 | if (strcasecmp(val, "enable") == 0) { |
| 1011 | dut->ap_txBF = 1; |
| 1012 | dut->ap_mu_txBF = 1; |
| 1013 | } else if (strcasecmp(val, "disable") == 0) { |
| 1014 | dut->ap_txBF = 0; |
| 1015 | dut->ap_mu_txBF = 0; |
| 1016 | } else { |
| 1017 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 1018 | "Unsupported MU_TxBF"); |
| 1019 | } |
| 1020 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1021 | |
| 1022 | /* UNSUPPORTED: tx_lgi_rate */ |
| 1023 | |
| 1024 | val = get_param(cmd, "wpsnfc"); |
| 1025 | if (val) |
| 1026 | dut->ap_wpsnfc = atoi(val); |
| 1027 | |
| 1028 | val = get_param(cmd, "GROUP_ID"); |
| 1029 | if (val) { |
| 1030 | switch (get_driver_type()) { |
| 1031 | case DRIVER_OPENWRT: |
| 1032 | switch (get_openwrt_driver_type()) { |
| 1033 | case OPENWRT_DRIVER_ATHEROS: |
| 1034 | ath_ap_set_group_id(dut, ifname, val); |
| 1035 | break; |
| 1036 | default: |
| 1037 | send_resp(dut, conn, SIGMA_ERROR, |
| 1038 | "errorCode,Unsupported group_id with the current driver"); |
| 1039 | return 0; |
| 1040 | } |
| 1041 | break; |
| 1042 | default: |
| 1043 | send_resp(dut, conn, SIGMA_ERROR, |
| 1044 | "errorCode,Unsupported group_id with the current driver"); |
| 1045 | return 0; |
| 1046 | } |
| 1047 | } |
| 1048 | |
| 1049 | val = get_param(cmd, "CTS_WIDTH"); |
| 1050 | if (val) { |
| 1051 | switch (get_driver_type()) { |
| 1052 | case DRIVER_OPENWRT: |
| 1053 | switch (get_openwrt_driver_type()) { |
| 1054 | case OPENWRT_DRIVER_ATHEROS: |
| 1055 | ath_set_cts_width(dut, ifname, val); |
| 1056 | break; |
| 1057 | default: |
| 1058 | send_resp(dut, conn, SIGMA_ERROR, |
| 1059 | "errorCode,Unsupported cts_width with the current driver"); |
| 1060 | return 0; |
| 1061 | } |
| 1062 | break; |
| 1063 | default: |
| 1064 | send_resp(dut, conn, SIGMA_ERROR, |
| 1065 | "errorCode,Unsupported cts_width with the current driver"); |
| 1066 | return 0; |
| 1067 | } |
| 1068 | } |
| 1069 | |
priyadharshini gowthaman | 264d544 | 2016-02-25 15:52:22 -0800 | [diff] [blame] | 1070 | val = get_param(cmd, "MU_NDPA_FrameFormat"); |
| 1071 | if (val) |
| 1072 | dut->ap_ndpa_frame = atoi(val); |
| 1073 | |
priyadharshini gowthaman | c52fff8 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 1074 | val = get_param(cmd, "interworking"); |
| 1075 | if (val && strcmp(val, "1") == 0) |
| 1076 | dut->ap_interworking = 1; |
| 1077 | |
| 1078 | val = get_param(cmd, "GAS_CB_DELAY"); |
| 1079 | if (val) |
| 1080 | dut->ap_gas_cb_delay = atoi(val); |
| 1081 | |
priyadharshini gowthaman | 8e26ff4 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 1082 | val = get_param(cmd, "LCI"); |
| 1083 | if (val) { |
| 1084 | if (strlen(val) > sizeof(dut->ap_val_lci) - 1) |
| 1085 | return -1; |
| 1086 | dut->ap_lci = 1; |
| 1087 | snprintf(dut->ap_val_lci, sizeof(dut->ap_val_lci), "%s", val); |
| 1088 | ath_set_lci_config(dut, val, cmd); |
| 1089 | } |
| 1090 | |
priyadharshini gowthaman | c2357bd | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 1091 | val = get_param(cmd, "InfoZ"); |
| 1092 | if (val) { |
| 1093 | if (strlen(val) > sizeof(dut->ap_infoz) - 1) |
| 1094 | return -1; |
| 1095 | snprintf(dut->ap_infoz, sizeof(dut->ap_infoz), "%s", val); |
| 1096 | } |
| 1097 | |
priyadharshini gowthaman | 8e26ff4 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 1098 | val = get_param(cmd, "LocCivicAddr"); |
| 1099 | if (val) { |
| 1100 | if (strlen(val) > sizeof(dut->ap_val_lcr) - 1) |
| 1101 | return -1; |
| 1102 | dut->ap_lcr = 1; |
| 1103 | snprintf(dut->ap_val_lcr, sizeof(dut->ap_val_lcr), "%s", val); |
| 1104 | if (dut->ap_lci == 0) |
| 1105 | ath_set_lci_config(dut, val, cmd); |
| 1106 | } |
| 1107 | |
| 1108 | val = get_param(cmd, "NeighAPBSSID"); |
| 1109 | if (val) { |
| 1110 | if (dut->ap_neighap < 3) { |
| 1111 | if (parse_mac_address( |
| 1112 | dut, val, |
| 1113 | dut->ap_val_neighap[dut->ap_neighap]) < 0) { |
| 1114 | send_resp(dut, conn, SIGMA_INVALID, |
| 1115 | "Failed to parse MAC address"); |
| 1116 | return 0; |
| 1117 | } |
| 1118 | dut->ap_neighap++; |
| 1119 | if (dut->ap_lci == 1) |
| 1120 | dut->ap_scan = 1; |
| 1121 | } |
| 1122 | } |
| 1123 | |
| 1124 | val = get_param(cmd, "OpChannel"); |
| 1125 | if (val) { |
| 1126 | if (dut->ap_opchannel < 3) { |
| 1127 | dut->ap_val_opchannel[dut->ap_opchannel] = atoi(val); |
| 1128 | dut->ap_opchannel++; |
| 1129 | } |
| 1130 | } |
| 1131 | |
priyadharshini gowthaman | c2357bd | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 1132 | val = get_param(cmd, "URI-FQDNdescriptor"); |
| 1133 | if (val) { |
| 1134 | if (strcasecmp(val, "HELD") == 0) { |
| 1135 | dut->ap_fqdn_held = 1; |
| 1136 | } else if (strcasecmp(val, "SUPL") == 0) { |
| 1137 | dut->ap_fqdn_supl = 1; |
| 1138 | } else { |
| 1139 | send_resp(dut, conn, SIGMA_INVALID, |
| 1140 | "errorCode,Unsupported URI-FQDNdescriptor"); |
| 1141 | return 0; |
| 1142 | } |
| 1143 | } |
| 1144 | |
Adil Saeed Musthafa | 604c826 | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 1145 | val = get_param(cmd, "Reg_Domain"); |
| 1146 | if (val) { |
| 1147 | if (strcasecmp(val, "Local") == 0) { |
| 1148 | dut->ap_reg_domain = REG_DOMAIN_LOCAL; |
| 1149 | } else if (strcasecmp(val, "Global") == 0) { |
| 1150 | dut->ap_reg_domain = REG_DOMAIN_GLOBAL; |
| 1151 | } else { |
| 1152 | send_resp(dut, conn, SIGMA_ERROR, |
| 1153 | "errorCode,Wrong value for Reg_Domain"); |
| 1154 | return 0; |
| 1155 | } |
| 1156 | } |
| 1157 | |
Adil Saeed Musthafa | 4ec61bd | 2017-04-10 23:13:41 -0700 | [diff] [blame] | 1158 | val = get_param(cmd, "NAME"); |
| 1159 | if (val) { |
| 1160 | if (strcasecmp(val, "ap1mbo") == 0) |
| 1161 | dut->ap_name = 1; |
| 1162 | else if (strcasecmp(val, "ap2mbo") == 0) |
| 1163 | dut->ap_name = 2; |
| 1164 | else |
| 1165 | dut->ap_name = 0; |
| 1166 | } |
| 1167 | |
| 1168 | val = get_param(cmd, "FT_OA"); |
| 1169 | if (val) { |
| 1170 | if (strcasecmp(val, "Enable") == 0) { |
| 1171 | dut->ap_ft_oa = 1; |
| 1172 | } else if (strcasecmp(val, "Disable") == 0) { |
| 1173 | dut->ap_ft_oa = 0; |
| 1174 | } else { |
| 1175 | send_resp(dut, conn, SIGMA_ERROR, |
| 1176 | "errorCode,Wrong value for FT_OA"); |
| 1177 | return 0; |
| 1178 | } |
| 1179 | } |
| 1180 | |
Adil Saeed Musthafa | 023108a | 2017-04-10 23:13:37 -0700 | [diff] [blame] | 1181 | val = get_param(cmd, "Cellular_Cap_Pref"); |
| 1182 | if (val) |
| 1183 | dut->ap_cell_cap_pref = atoi(val); |
| 1184 | |
Adil Saeed Musthafa | cf752fa | 2017-04-10 23:13:32 -0700 | [diff] [blame] | 1185 | val = get_param(cmd, "DOMAIN"); |
| 1186 | if (val) { |
| 1187 | if (strlen(val) >= sizeof(dut->ap_mobility_domain)) { |
| 1188 | send_resp(dut, conn, SIGMA_ERROR, |
| 1189 | "errorCode,Too long DOMAIN"); |
| 1190 | return 0; |
| 1191 | } |
| 1192 | snprintf(dut->ap_mobility_domain, |
| 1193 | sizeof(dut->ap_mobility_domain), "%s", val); |
| 1194 | } |
| 1195 | |
Adil Saeed Musthafa | 4ec61bd | 2017-04-10 23:13:41 -0700 | [diff] [blame] | 1196 | val = get_param(cmd, "ft_bss_list"); |
| 1197 | if (val) { |
| 1198 | char *mac_str; |
| 1199 | int i; |
| 1200 | char *saveptr; |
| 1201 | char *mac_list_str; |
| 1202 | |
| 1203 | mac_list_str = strdup(val); |
| 1204 | if (!mac_list_str) |
| 1205 | return -1; |
| 1206 | mac_str = strtok_r(mac_list_str, " ", &saveptr); |
| 1207 | for (i = 0; mac_str && i < MAX_FT_BSS_LIST; i++) { |
| 1208 | if (parse_mac_address(dut, mac_str, |
| 1209 | dut->ft_bss_mac_list[i]) < 0) { |
| 1210 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 1211 | "MAC Address not in proper format"); |
| 1212 | break; |
| 1213 | } |
| 1214 | dut->ft_bss_mac_cnt++; |
| 1215 | mac_str = strtok_r(NULL, " ", &saveptr); |
| 1216 | } |
| 1217 | sigma_dut_print(dut, DUT_MSG_DEBUG, |
| 1218 | "Storing the following FT BSS MAC List"); |
| 1219 | for (i = 0; i < dut->ft_bss_mac_cnt; i++) { |
| 1220 | sigma_dut_print(dut, DUT_MSG_DEBUG, |
| 1221 | "MAC[%d] %02x:%02x:%02x:%02x:%02x:%02x", |
| 1222 | i, |
| 1223 | dut->ft_bss_mac_list[i][0], |
| 1224 | dut->ft_bss_mac_list[i][1], |
| 1225 | dut->ft_bss_mac_list[i][2], |
| 1226 | dut->ft_bss_mac_list[i][3], |
| 1227 | dut->ft_bss_mac_list[i][4], |
| 1228 | dut->ft_bss_mac_list[i][5]); |
| 1229 | } |
| 1230 | free(mac_list_str); |
| 1231 | } |
| 1232 | |
priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 1233 | val = get_param(cmd, "OCESupport"); |
| 1234 | if (val) { |
| 1235 | if (strcasecmp(val, "enable") == 0) { |
| 1236 | dut->ap_oce = VALUE_ENABLED; |
| 1237 | } else if (strcasecmp(val, "disable") == 0) { |
| 1238 | dut->ap_oce = VALUE_DISABLED; |
| 1239 | dut->ap_filsdscv = VALUE_DISABLED; |
| 1240 | } else { |
| 1241 | send_resp(dut, conn, SIGMA_INVALID, |
| 1242 | "errorCode,Unsupported OCE"); |
| 1243 | return 0; |
| 1244 | } |
| 1245 | } |
| 1246 | |
| 1247 | val = get_param(cmd, "FILSDscvInterval"); |
| 1248 | if (val) |
| 1249 | dut->ap_fils_dscv_int = atoi(val); |
| 1250 | |
| 1251 | val = get_param(cmd, "BroadcastSSID"); |
| 1252 | if (val) { |
| 1253 | if (strcasecmp(val, "enable") == 0) { |
| 1254 | dut->ap_broadcast_ssid = VALUE_ENABLED; |
| 1255 | } else if (strcasecmp(val, "disable") == 0) { |
| 1256 | dut->ap_broadcast_ssid = VALUE_DISABLED; |
| 1257 | } else { |
| 1258 | send_resp(dut, conn, SIGMA_INVALID, |
| 1259 | "errorCode,Unsupported hidden SSID"); |
| 1260 | return 0; |
| 1261 | } |
| 1262 | } |
| 1263 | |
| 1264 | val = get_param(cmd, "FILSDscv"); |
| 1265 | if (val) { |
| 1266 | if (strcasecmp(val, "enable") == 0) { |
| 1267 | dut->ap_filsdscv = VALUE_ENABLED; |
| 1268 | } else if (strcasecmp(val, "disable") == 0) { |
| 1269 | dut->ap_filsdscv = VALUE_DISABLED; |
| 1270 | } else { |
| 1271 | send_resp(dut, conn, SIGMA_INVALID, |
| 1272 | "errorCode,Unsupported FILSDscv"); |
| 1273 | return 0; |
| 1274 | } |
| 1275 | } |
| 1276 | |
| 1277 | val = get_param(cmd, "FILSHLP"); |
| 1278 | if (val) { |
| 1279 | if (strcasecmp(val, "enable") == 0) { |
| 1280 | dut->ap_filshlp = VALUE_ENABLED; |
| 1281 | } else if (strcasecmp(val, "disable") == 0) { |
| 1282 | dut->ap_filshlp = VALUE_DISABLED; |
| 1283 | } else { |
| 1284 | send_resp(dut, conn, SIGMA_INVALID, |
| 1285 | "errorCode,Unsupported FILSHLP"); |
| 1286 | return 0; |
| 1287 | } |
| 1288 | } |
| 1289 | |
| 1290 | val = get_param(cmd, "NAIRealm"); |
| 1291 | if (val) { |
| 1292 | dut->ap_nairealm_int = 1; |
| 1293 | if (strlen(val) > sizeof(dut->ap_nairealm) - 1) |
| 1294 | return -1; |
| 1295 | snprintf(dut->ap_nairealm, sizeof(dut->ap_nairealm), "%s", val); |
| 1296 | } |
| 1297 | |
| 1298 | val = get_param(cmd, "DeauthDisassocTx"); |
| 1299 | if (val) { |
| 1300 | if (strcasecmp(val, "disable") == 0) { |
| 1301 | deauth_disassoc(dut, ifname, val); |
| 1302 | } else { |
| 1303 | send_resp(dut, conn, SIGMA_INVALID, |
| 1304 | "errorCode,Unsupported DeauthDisassocTx"); |
| 1305 | return 0; |
| 1306 | } |
| 1307 | } |
| 1308 | |
| 1309 | val = get_param(cmd, "RNR"); |
| 1310 | if (val) { |
| 1311 | if (strcasecmp(val, "enable") == 0) { |
| 1312 | dut->ap_rnr = VALUE_ENABLED; |
| 1313 | } else if (strcasecmp(val, "disable") == 0) { |
| 1314 | dut->ap_rnr = VALUE_DISABLED; |
| 1315 | } else { |
| 1316 | send_resp(dut, conn, SIGMA_INVALID, |
| 1317 | "errorCode,Unsupported RNR"); |
| 1318 | return 0; |
| 1319 | } |
| 1320 | } |
| 1321 | |
| 1322 | val = get_param(cmd, "BLEChannelUtil"); |
| 1323 | if (val) |
| 1324 | dut->ap_blechanutil = atoi(val); |
| 1325 | |
| 1326 | val = get_param(cmd, "BLEAvailAdminCap"); |
| 1327 | if (val) |
| 1328 | dut->ap_ble_admit_cap = atoi(val); |
| 1329 | |
| 1330 | val = get_param(cmd, "DataPPDUDuration"); |
| 1331 | if (val) |
| 1332 | dut->ap_datappdudura = atoi(val); |
| 1333 | |
| 1334 | val = get_param(cmd, "AirTimeFract"); |
| 1335 | if (val) |
| 1336 | dut->ap_airtimefract = atoi(val); |
| 1337 | |
| 1338 | val = get_param(cmd, "dhcpServIPADDR"); |
| 1339 | if (val) { |
| 1340 | if (strlen(val) > sizeof(dut->ap_dhcpserv_ipaddr) - 1) |
| 1341 | return -1; |
| 1342 | snprintf(dut->ap_dhcpserv_ipaddr, |
| 1343 | sizeof(dut->ap_dhcpserv_ipaddr), "%s", val); |
| 1344 | dut->ap_dhcp_stop = 1; |
| 1345 | } |
| 1346 | |
| 1347 | val = get_param(cmd, "ESP_IE"); |
| 1348 | if (val) { |
| 1349 | if (strcasecmp(val, "enable") == 0) { |
| 1350 | dut->ap_esp = VALUE_ENABLED; |
| 1351 | } else if (strcasecmp(val, "disable") == 0) { |
| 1352 | dut->ap_esp = VALUE_DISABLED; |
| 1353 | } else { |
| 1354 | send_resp(dut, conn, SIGMA_INVALID, |
| 1355 | "errorCode,Unsupported ESP_IE"); |
| 1356 | return 0; |
| 1357 | } |
| 1358 | } |
| 1359 | |
| 1360 | val = get_param(cmd, "BAWinSize"); |
| 1361 | if (val) |
| 1362 | dut->ap_bawinsize = atoi(val); |
| 1363 | |
| 1364 | val = get_param(cmd, "BLEStaCount"); |
| 1365 | if (val) |
| 1366 | dut->ap_blestacnt = atoi(val); |
| 1367 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1368 | return 1; |
| 1369 | } |
| 1370 | |
| 1371 | |
| 1372 | static void ath_inject_frame(struct sigma_dut *dut, const char *ifname, int tid) |
| 1373 | { |
| 1374 | char buf[256]; |
| 1375 | int tid_to_dscp[] = { 0x00, 0x20, 0x40, 0x60, 0x80, 0xa0, 0xc0, 0xe0 }; |
| 1376 | |
Pradeep Reddy POTTETI | d31d132 | 2016-10-13 17:22:03 +0530 | [diff] [blame] | 1377 | if (tid < 0 || |
| 1378 | tid >= (int) (sizeof(tid_to_dscp) / sizeof(tid_to_dscp[0]))) { |
| 1379 | sigma_dut_print(dut, DUT_MSG_ERROR, "Unsupported TID: %d", tid); |
| 1380 | return; |
| 1381 | } |
| 1382 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1383 | snprintf(buf, sizeof(buf), |
| 1384 | "wlanconfig %s list sta | grep : | cut -b 1-17 > %s", |
| 1385 | ifname, VI_QOS_TMP_FILE); |
| 1386 | if (system(buf) != 0) |
| 1387 | return; |
| 1388 | |
| 1389 | snprintf(buf, sizeof(buf), |
| 1390 | "ifconfig %s | grep HWaddr | cut -b 39-56 >> %s", |
| 1391 | ifname, VI_QOS_TMP_FILE); |
| 1392 | if (system(buf) != 0) |
| 1393 | sigma_dut_print(dut, DUT_MSG_ERROR, "Retrieve HWaddr failed"); |
| 1394 | |
| 1395 | snprintf(buf, sizeof(buf), "sed -n '3,$p' %s >> %s", |
| 1396 | VI_QOS_REFFILE, VI_QOS_TMP_FILE); |
| 1397 | if (system(buf) != 0) { |
| 1398 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 1399 | "Output redirection to VI_QOS_TMP_FILE failed"); |
| 1400 | } |
| 1401 | |
| 1402 | snprintf(buf, sizeof(buf), "sed '5 c %x' %s > %s", |
| 1403 | tid_to_dscp[tid], VI_QOS_TMP_FILE, VI_QOS_FILE); |
| 1404 | if (system(buf) != 0) { |
| 1405 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 1406 | "Append TID to VI_QOS_FILE failed "); |
| 1407 | } |
| 1408 | |
| 1409 | snprintf(buf, sizeof(buf), "ethinject %s %s", ifname, VI_QOS_FILE); |
| 1410 | if (system(buf) != 0) |
| 1411 | sigma_dut_print(dut, DUT_MSG_ERROR, "Ethinject frame failed"); |
| 1412 | } |
| 1413 | |
| 1414 | |
| 1415 | static int ath_ap_send_addba_req(struct sigma_dut *dut, struct sigma_conn *conn, |
| 1416 | struct sigma_cmd *cmd) |
| 1417 | { |
| 1418 | const char *val; |
| 1419 | char *ifname; |
| 1420 | char buf[256]; |
| 1421 | int tid = 0; |
| 1422 | |
| 1423 | ifname = get_main_ifname(); |
| 1424 | val = get_param(cmd, "TID"); |
| 1425 | if (val) { |
| 1426 | tid = atoi(val); |
| 1427 | if (tid) |
| 1428 | ath_inject_frame(dut, ifname, tid); |
| 1429 | } |
| 1430 | |
| 1431 | /* NOTE: This is the command sequence on Peregrine for ADDBA */ |
| 1432 | snprintf(buf, sizeof(buf), "iwpriv %s setaddbaoper 1", ifname); |
| 1433 | if (system(buf) != 0) { |
| 1434 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 1435 | "iwpriv setaddbaoper failed"); |
| 1436 | } |
| 1437 | |
| 1438 | snprintf(buf, sizeof(buf), "wifitool %s senddelba 1 %d 1 4", |
| 1439 | ifname, tid); |
| 1440 | if (system(buf) != 0) { |
| 1441 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 1442 | "wifitool senddelba failed"); |
| 1443 | } |
| 1444 | |
| 1445 | snprintf(buf, sizeof(buf), "wifitool %s sendaddba 1 %d 64", |
| 1446 | ifname, tid); |
| 1447 | if (system(buf) != 0) { |
| 1448 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 1449 | "wifitool sendaddba failed"); |
| 1450 | } |
| 1451 | |
| 1452 | return 1; |
| 1453 | } |
| 1454 | |
| 1455 | |
Mohammed Shafi Shajakhan | a0535d4 | 2016-06-17 11:55:00 +0530 | [diff] [blame] | 1456 | static int ath10k_debug_enable_addba_req(struct sigma_dut *dut, int tid, |
| 1457 | const char *sta_mac, |
| 1458 | const char *dir_path) |
| 1459 | { |
| 1460 | DIR *dir; |
| 1461 | struct dirent *entry; |
| 1462 | char buf[128], path[128]; |
| 1463 | int ret = 0; |
| 1464 | |
| 1465 | dir = opendir(dir_path); |
| 1466 | if (!dir) |
| 1467 | return 0; |
| 1468 | |
| 1469 | while ((entry = readdir(dir))) { |
| 1470 | ret = 1; |
| 1471 | |
| 1472 | if (strcmp(entry->d_name, ".") == 0 || |
| 1473 | strcmp(entry->d_name, "..") == 0) |
| 1474 | continue; |
| 1475 | |
| 1476 | snprintf(path, sizeof(path) - 1, "%s/%s", |
| 1477 | dir_path, entry->d_name); |
| 1478 | path[sizeof(path) - 1] = 0; |
| 1479 | |
| 1480 | if (strcmp(entry->d_name, sta_mac) == 0) { |
| 1481 | snprintf(buf, sizeof(buf), "echo 1 > %s/aggr_mode", |
| 1482 | path); |
| 1483 | if (system(buf) != 0) { |
| 1484 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 1485 | "Failed to set aggr mode for ath10k"); |
| 1486 | } |
| 1487 | |
| 1488 | snprintf(buf, sizeof(buf), "echo %d 32 > %s/addba", |
| 1489 | tid, path); |
| 1490 | if (system(buf) != 0) { |
| 1491 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 1492 | "Failed to set addbareq for ath10k"); |
| 1493 | } |
| 1494 | |
| 1495 | break; |
| 1496 | } |
| 1497 | |
| 1498 | /* Recursively search subdirectories */ |
| 1499 | ath10k_debug_enable_addba_req(dut, tid, sta_mac, path); |
| 1500 | } |
| 1501 | |
| 1502 | closedir(dir); |
| 1503 | |
| 1504 | return ret; |
| 1505 | } |
| 1506 | |
| 1507 | |
| 1508 | static int ath10k_ap_send_addba_req(struct sigma_dut *dut, |
| 1509 | struct sigma_cmd *cmd) |
| 1510 | { |
| 1511 | const char *val; |
| 1512 | int tid = 0; |
| 1513 | |
| 1514 | val = get_param(cmd, "TID"); |
| 1515 | if (val) |
| 1516 | tid = atoi(val); |
| 1517 | |
| 1518 | val = get_param(cmd, "sta_mac_address"); |
| 1519 | if (!val) { |
| 1520 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 1521 | "Failed to parse station MAC address"); |
| 1522 | return 0; |
| 1523 | } |
| 1524 | |
| 1525 | return ath10k_debug_enable_addba_req(dut, tid, val, |
| 1526 | "/sys/kernel/debug/ieee80211"); |
| 1527 | } |
| 1528 | |
| 1529 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1530 | static int cmd_ap_send_addba_req(struct sigma_dut *dut, struct sigma_conn *conn, |
| 1531 | struct sigma_cmd *cmd) |
| 1532 | { |
| 1533 | /* const char *name = get_param(cmd, "NAME"); */ |
| 1534 | /* const char *ifname = get_param(cmd, "INTERFACE"); */ |
Mohammed Shafi Shajakhan | a0535d4 | 2016-06-17 11:55:00 +0530 | [diff] [blame] | 1535 | struct stat s; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1536 | |
| 1537 | switch (get_driver_type()) { |
| 1538 | case DRIVER_ATHEROS: |
| 1539 | return ath_ap_send_addba_req(dut, conn, cmd); |
| 1540 | case DRIVER_OPENWRT: |
| 1541 | switch (get_openwrt_driver_type()) { |
| 1542 | case OPENWRT_DRIVER_ATHEROS: |
| 1543 | return ath_ap_send_addba_req(dut, conn, cmd); |
| 1544 | default: |
| 1545 | send_resp(dut, conn, SIGMA_ERROR, |
| 1546 | "errorCode,ap_send_addba_req not supported with this driver"); |
| 1547 | return 0; |
| 1548 | } |
Pradeep Reddy POTTETI | fdb0491 | 2016-08-02 14:16:24 +0530 | [diff] [blame] | 1549 | case DRIVER_WCN: |
| 1550 | case DRIVER_LINUX_WCN: |
| 1551 | /* AP automatically sends ADDBA request after association. */ |
| 1552 | sigma_dut_print(dut, DUT_MSG_INFO, |
| 1553 | "ap_send_addba_req command ignored"); |
| 1554 | return 1; |
Mohammed Shafi Shajakhan | a0535d4 | 2016-06-17 11:55:00 +0530 | [diff] [blame] | 1555 | case DRIVER_MAC80211: |
| 1556 | if (stat("/sys/module/ath10k_core", &s) == 0) |
| 1557 | return ath10k_ap_send_addba_req(dut, cmd); |
| 1558 | /* fall through */ |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1559 | default: |
| 1560 | send_resp(dut, conn, SIGMA_ERROR, |
| 1561 | "errorCode,ap_send_addba_req not supported with this driver"); |
| 1562 | return 0; |
| 1563 | } |
| 1564 | } |
| 1565 | |
| 1566 | |
| 1567 | static int cmd_ap_set_security(struct sigma_dut *dut, struct sigma_conn *conn, |
| 1568 | struct sigma_cmd *cmd) |
| 1569 | { |
| 1570 | /* const char *name = get_param(cmd, "NAME"); */ |
| 1571 | const char *val; |
| 1572 | unsigned int wlan_tag = 1; |
Ankita Bajaj | 0d212e8 | 2017-11-27 15:54:57 +0530 | [diff] [blame] | 1573 | const char *security; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1574 | |
| 1575 | val = get_param(cmd, "WLAN_TAG"); |
| 1576 | if (val) |
| 1577 | wlan_tag = atoi(val); |
| 1578 | |
Ankita Bajaj | 0d212e8 | 2017-11-27 15:54:57 +0530 | [diff] [blame] | 1579 | security = get_param(cmd, "Security"); |
| 1580 | |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 1581 | if (wlan_tag > 1) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1582 | val = get_param(cmd, "KEYMGNT"); |
Ankita Bajaj | 0d212e8 | 2017-11-27 15:54:57 +0530 | [diff] [blame] | 1583 | if (!val) |
| 1584 | val = get_param(cmd, "KeyMgmtType"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1585 | if (val) { |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 1586 | if (strcasecmp(val, "NONE") == 0) { |
| 1587 | dut->ap_tag_key_mgmt[wlan_tag - 2] = AP2_OPEN; |
| 1588 | } else if (strcasecmp(val, "OSEN") == 0 && |
| 1589 | wlan_tag == 2) { |
| 1590 | /* |
| 1591 | * OSEN only supported on WLAN_TAG = 2 for now |
| 1592 | */ |
| 1593 | dut->ap_tag_key_mgmt[wlan_tag - 2] = AP2_OSEN; |
Ankita Bajaj | 0d212e8 | 2017-11-27 15:54:57 +0530 | [diff] [blame] | 1594 | } else if (strcasecmp(val, "WPA2-PSK") == 0 || |
| 1595 | (security && |
| 1596 | strcasecmp(security, "PSK") == 0 && |
| 1597 | strcasecmp(val, "WPA2") == 0)) { |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 1598 | dut->ap_tag_key_mgmt[wlan_tag - 2] = |
| 1599 | AP2_WPA2_PSK; |
Jouni Malinen | 353ba8b | 2018-01-10 17:04:12 +0200 | [diff] [blame] | 1600 | } else if (strcasecmp(val, "OWE") == 0 && |
| 1601 | wlan_tag == 2) { |
| 1602 | dut->ap_tag_key_mgmt[wlan_tag - 2] = |
| 1603 | AP2_WPA2_OWE; |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 1604 | } else { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1605 | send_resp(dut, conn, SIGMA_INVALID, |
| 1606 | "errorCode,Unsupported KEYMGNT"); |
| 1607 | return 0; |
| 1608 | } |
| 1609 | return 1; |
| 1610 | } |
| 1611 | } |
| 1612 | |
| 1613 | val = get_param(cmd, "KEYMGNT"); |
Ankita Bajaj | 0d212e8 | 2017-11-27 15:54:57 +0530 | [diff] [blame] | 1614 | if (!val) |
| 1615 | val = get_param(cmd,"KeyMgmtType"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1616 | if (val) { |
Ankita Bajaj | 0d212e8 | 2017-11-27 15:54:57 +0530 | [diff] [blame] | 1617 | if (strcasecmp(val, "WPA2-PSK") == 0 || |
| 1618 | (security && strcasecmp(security, "PSK") == 0 && |
| 1619 | strcasecmp(val, "WPA2") == 0)) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1620 | dut->ap_key_mgmt = AP_WPA2_PSK; |
| 1621 | dut->ap_cipher = AP_CCMP; |
| 1622 | } else if (strcasecmp(val, "WPA2-EAP") == 0 || |
| 1623 | strcasecmp(val, "WPA2-Ent") == 0) { |
| 1624 | dut->ap_key_mgmt = AP_WPA2_EAP; |
| 1625 | dut->ap_cipher = AP_CCMP; |
Jouni Malinen | ad395a2 | 2017-09-01 21:13:46 +0300 | [diff] [blame] | 1626 | } else if (strcasecmp(val, "SuiteB") == 0) { |
| 1627 | dut->ap_key_mgmt = AP_SUITEB; |
| 1628 | dut->ap_cipher = AP_GCMP_256; |
Jouni Malinen | d75e4d8 | 2018-01-11 20:21:15 +0200 | [diff] [blame] | 1629 | dut->ap_pmf = AP_PMF_REQUIRED; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1630 | } else if (strcasecmp(val, "WPA-PSK") == 0) { |
| 1631 | dut->ap_key_mgmt = AP_WPA_PSK; |
| 1632 | dut->ap_cipher = AP_TKIP; |
| 1633 | } else if (strcasecmp(val, "WPA-EAP") == 0 || |
| 1634 | strcasecmp(val, "WPA-Ent") == 0) { |
| 1635 | dut->ap_key_mgmt = AP_WPA_EAP; |
| 1636 | dut->ap_cipher = AP_TKIP; |
| 1637 | } else if (strcasecmp(val, "WPA2-Mixed") == 0) { |
| 1638 | dut->ap_key_mgmt = AP_WPA2_EAP_MIXED; |
| 1639 | dut->ap_cipher = AP_CCMP_TKIP; |
| 1640 | } else if (strcasecmp(val, "WPA2-PSK-Mixed") == 0) { |
| 1641 | dut->ap_key_mgmt = AP_WPA2_PSK_MIXED; |
| 1642 | dut->ap_cipher = AP_CCMP_TKIP; |
Jouni Malinen | 794a7a3 | 2018-01-10 16:39:34 +0200 | [diff] [blame] | 1643 | } else if (strcasecmp(val, "WPA2-SAE") == 0 || |
| 1644 | strcasecmp(val, "SAE") == 0) { |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 1645 | dut->ap_key_mgmt = AP_WPA2_SAE; |
| 1646 | dut->ap_cipher = AP_CCMP; |
Jouni Malinen | 1287cd7 | 2018-01-04 17:08:01 +0200 | [diff] [blame] | 1647 | dut->ap_pmf = AP_PMF_REQUIRED; |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 1648 | } else if (strcasecmp(val, "WPA2-PSK-SAE") == 0) { |
| 1649 | dut->ap_key_mgmt = AP_WPA2_PSK_SAE; |
| 1650 | dut->ap_cipher = AP_CCMP; |
Jouni Malinen | 1287cd7 | 2018-01-04 17:08:01 +0200 | [diff] [blame] | 1651 | dut->ap_pmf = AP_PMF_OPTIONAL; |
Jouni Malinen | 147b3c3 | 2017-10-09 16:51:54 +0300 | [diff] [blame] | 1652 | } else if (strcasecmp(val, "OWE") == 0) { |
| 1653 | dut->ap_key_mgmt = AP_WPA2_OWE; |
| 1654 | dut->ap_cipher = AP_CCMP; |
Jouni Malinen | 1287cd7 | 2018-01-04 17:08:01 +0200 | [diff] [blame] | 1655 | dut->ap_pmf = AP_PMF_REQUIRED; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1656 | } else if (strcasecmp(val, "NONE") == 0) { |
| 1657 | dut->ap_key_mgmt = AP_OPEN; |
| 1658 | dut->ap_cipher = AP_PLAIN; |
| 1659 | } else { |
| 1660 | send_resp(dut, conn, SIGMA_INVALID, |
| 1661 | "errorCode,Unsupported KEYMGNT"); |
| 1662 | return 0; |
| 1663 | } |
| 1664 | } |
| 1665 | |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 1666 | val = get_param(cmd, "ECGroupID"); |
| 1667 | if (val) { |
Jouni Malinen | ed670f4 | 2017-08-31 01:39:28 +0300 | [diff] [blame] | 1668 | free(dut->ap_sae_groups); |
| 1669 | dut->ap_sae_groups = strdup(val); |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 1670 | } |
| 1671 | |
Jouni Malinen | 2f524ce | 2017-08-31 01:43:29 +0300 | [diff] [blame] | 1672 | val = get_param(cmd, "AntiCloggingThreshold"); |
| 1673 | if (val) |
| 1674 | dut->sae_anti_clogging_threshold = atoi(val); |
| 1675 | |
Jouni Malinen | b347db0 | 2017-09-02 01:36:03 +0300 | [diff] [blame] | 1676 | val = get_param(cmd, "Reflection"); |
| 1677 | if (val) |
| 1678 | dut->sae_reflection = strcasecmp(val, "SAE") == 0; |
| 1679 | |
Jouni Malinen | 6814313 | 2017-09-02 02:34:08 +0300 | [diff] [blame] | 1680 | val = get_param(cmd, "InvalidSAEElement"); |
| 1681 | if (val) { |
| 1682 | free(dut->sae_commit_override); |
| 1683 | dut->sae_commit_override = strdup(val); |
| 1684 | } |
| 1685 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1686 | val = get_param(cmd, "ENCRYPT"); |
Ankita Bajaj | 0d212e8 | 2017-11-27 15:54:57 +0530 | [diff] [blame] | 1687 | if (!val) |
| 1688 | val = get_param(cmd, "EncpType"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1689 | if (val) { |
| 1690 | if (strcasecmp(val, "WEP") == 0) { |
| 1691 | dut->ap_cipher = AP_WEP; |
| 1692 | } else if (strcasecmp(val, "TKIP") == 0) { |
| 1693 | dut->ap_cipher = AP_TKIP; |
| 1694 | } else if (strcasecmp(val, "AES") == 0 || |
| 1695 | strcasecmp(val, "AES-CCMP") == 0) { |
| 1696 | dut->ap_cipher = AP_CCMP; |
Jouni Malinen | 3d633da | 2017-09-14 22:19:21 +0300 | [diff] [blame] | 1697 | } else if (strcasecmp(val, "AES-GCMP") == 0) { |
| 1698 | dut->ap_cipher = AP_GCMP_128; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1699 | } else { |
| 1700 | send_resp(dut, conn, SIGMA_INVALID, |
| 1701 | "errorCode,Unsupported ENCRYPT"); |
| 1702 | return 0; |
| 1703 | } |
| 1704 | } |
| 1705 | |
Jouni Malinen | 3d633da | 2017-09-14 22:19:21 +0300 | [diff] [blame] | 1706 | val = get_param(cmd, "PairwiseCipher"); |
| 1707 | if (val) { |
| 1708 | if (strcasecmp(val, "AES-GCMP-256") == 0) { |
| 1709 | dut->ap_cipher = AP_GCMP_256; |
| 1710 | } else if (strcasecmp(val, "AES-CCMP-256") == 0) { |
| 1711 | dut->ap_cipher = AP_CCMP_256; |
| 1712 | } else if (strcasecmp(val, "AES-GCMP-128") == 0) { |
| 1713 | dut->ap_cipher = AP_GCMP_128; |
| 1714 | } else if (strcasecmp(val, "AES-CCMP-128") == 0) { |
| 1715 | dut->ap_cipher = AP_CCMP; |
Jouni Malinen | d538c78 | 2017-11-17 12:13:04 +0200 | [diff] [blame] | 1716 | } else if (strcasecmp(val, "AES-CCMP-128 AES-GCMP-256") == 0 || |
| 1717 | strcasecmp(val, "AES-GCMP-256 AES-CCMP-128") == 0) { |
| 1718 | dut->ap_cipher = AP_CCMP_128_GCMP_256; |
Jouni Malinen | 3d633da | 2017-09-14 22:19:21 +0300 | [diff] [blame] | 1719 | } else { |
| 1720 | send_resp(dut, conn, SIGMA_INVALID, |
| 1721 | "errorCode,Unsupported PairwiseCipher"); |
| 1722 | return 0; |
| 1723 | } |
| 1724 | } |
| 1725 | |
Jouni Malinen | 2ba2449 | 2017-11-17 12:43:59 +0200 | [diff] [blame] | 1726 | val = get_param(cmd, "GroupCipher"); |
| 1727 | if (val) { |
| 1728 | if (strcasecmp(val, "AES-GCMP-256") == 0) { |
| 1729 | dut->ap_group_cipher = AP_GCMP_256; |
| 1730 | } else if (strcasecmp(val, "AES-CCMP-256") == 0) { |
| 1731 | dut->ap_group_cipher = AP_CCMP_256; |
| 1732 | } else if (strcasecmp(val, "AES-GCMP-128") == 0) { |
| 1733 | dut->ap_group_cipher = AP_GCMP_128; |
| 1734 | } else if (strcasecmp(val, "AES-CCMP-128") == 0) { |
| 1735 | dut->ap_group_cipher = AP_CCMP; |
| 1736 | } else { |
| 1737 | send_resp(dut, conn, SIGMA_INVALID, |
| 1738 | "errorCode,Unsupported GroupCipher"); |
| 1739 | return 0; |
| 1740 | } |
| 1741 | } |
| 1742 | |
Jouni Malinen | 3d633da | 2017-09-14 22:19:21 +0300 | [diff] [blame] | 1743 | val = get_param(cmd, "GroupMgntCipher"); |
| 1744 | if (val) { |
| 1745 | if (strcasecmp(val, "BIP-GMAC-256") == 0) { |
| 1746 | dut->ap_group_mgmt_cipher = AP_BIP_GMAC_256; |
| 1747 | } else if (strcasecmp(val, "BIP-CMAC-256") == 0) { |
| 1748 | dut->ap_group_mgmt_cipher = AP_BIP_CMAC_256; |
| 1749 | } else if (strcasecmp(val, "BIP-GMAC-128") == 0) { |
| 1750 | dut->ap_group_mgmt_cipher = AP_BIP_GMAC_128; |
| 1751 | } else if (strcasecmp(val, "BIP-CMAC-128") == 0) { |
| 1752 | dut->ap_group_mgmt_cipher = AP_BIP_CMAC_128; |
| 1753 | } else { |
| 1754 | send_resp(dut, conn, SIGMA_INVALID, |
| 1755 | "errorCode,Unsupported GroupMgntCipher"); |
| 1756 | return 0; |
| 1757 | } |
| 1758 | } |
| 1759 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1760 | val = get_param(cmd, "WEPKEY"); |
| 1761 | if (val) { |
| 1762 | size_t len; |
| 1763 | if (dut->ap_cipher != AP_WEP) { |
| 1764 | send_resp(dut, conn, SIGMA_INVALID, |
| 1765 | "errorCode,Unexpected WEPKEY without WEP " |
| 1766 | "configuration"); |
| 1767 | return 0; |
| 1768 | } |
| 1769 | len = strlen(val); |
| 1770 | if (len != 10 && len != 26) { |
| 1771 | send_resp(dut, conn, SIGMA_INVALID, |
| 1772 | "errorCode,Unexpected WEPKEY length"); |
| 1773 | return 0; |
| 1774 | } |
| 1775 | snprintf(dut->ap_wepkey, sizeof(dut->ap_wepkey), "%s", val); |
| 1776 | } |
| 1777 | |
| 1778 | val = get_param(cmd, "PSK"); |
Ankita Bajaj | 0d212e8 | 2017-11-27 15:54:57 +0530 | [diff] [blame] | 1779 | if (!val) |
| 1780 | val = get_param(cmd, "passphrase"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1781 | if (val) { |
Jouni Malinen | 2126f42 | 2017-10-11 23:24:33 +0300 | [diff] [blame] | 1782 | if (dut->ap_key_mgmt != AP_WPA2_SAE && strlen(val) > 64) |
| 1783 | return -1; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1784 | if (strlen(val) > sizeof(dut->ap_passphrase) - 1) |
| 1785 | return -1; |
| 1786 | snprintf(dut->ap_passphrase, sizeof(dut->ap_passphrase), |
| 1787 | "%s", val); |
| 1788 | } |
| 1789 | |
Jouni Malinen | 6337062 | 2017-11-18 17:47:13 +0200 | [diff] [blame] | 1790 | val = get_param(cmd, "PSKHEX"); |
| 1791 | if (val) { |
| 1792 | if (strlen(val) != 64) |
| 1793 | return -1; |
| 1794 | strlcpy(dut->ap_psk, val, sizeof(dut->ap_psk)); |
| 1795 | } |
| 1796 | |
Ankita Bajaj | 0d212e8 | 2017-11-27 15:54:57 +0530 | [diff] [blame] | 1797 | if (dut->program == PROGRAM_OCE && dut->dev_role == DEVROLE_STA_CFON) |
| 1798 | dut->ap_pmf = AP_PMF_OPTIONAL; |
| 1799 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1800 | val = get_param(cmd, "PMF"); |
| 1801 | if (val) { |
| 1802 | if (strcasecmp(val, "Disabled") == 0) { |
| 1803 | dut->ap_pmf = AP_PMF_DISABLED; |
| 1804 | } else if (strcasecmp(val, "Optional") == 0) { |
| 1805 | dut->ap_pmf = AP_PMF_OPTIONAL; |
| 1806 | } else if (strcasecmp(val, "Required") == 0) { |
| 1807 | dut->ap_pmf = AP_PMF_REQUIRED; |
| 1808 | } else { |
| 1809 | send_resp(dut, conn, SIGMA_INVALID, |
| 1810 | "errorCode,Unsupported PMF"); |
| 1811 | return 0; |
| 1812 | } |
| 1813 | } |
| 1814 | |
| 1815 | if (dut->ap_key_mgmt == AP_OPEN) { |
| 1816 | dut->ap_hs2 = 0; |
| 1817 | dut->ap_pmf = AP_PMF_DISABLED; |
| 1818 | } |
| 1819 | |
| 1820 | dut->ap_add_sha256 = 0; |
| 1821 | val = get_param(cmd, "SHA256AD"); |
| 1822 | if (val == NULL) |
| 1823 | val = get_param(cmd, "SHA256"); |
| 1824 | if (val) { |
| 1825 | if (strcasecmp(val, "Disabled") == 0) { |
| 1826 | } else if (strcasecmp(val, "Enabled") == 0) { |
| 1827 | dut->ap_add_sha256 = 1; |
| 1828 | } else { |
| 1829 | send_resp(dut, conn, SIGMA_INVALID, |
| 1830 | "errorCode,Unsupported PMF"); |
| 1831 | return 0; |
| 1832 | } |
| 1833 | } |
| 1834 | |
Sarvepalli, Rajesh Babu | 24dc7e4 | 2016-03-18 21:27:26 +0530 | [diff] [blame] | 1835 | val = get_param(cmd, "PreAuthentication"); |
| 1836 | if (val) { |
| 1837 | if (strcasecmp(val, "disabled") == 0) { |
| 1838 | dut->ap_rsn_preauth = 0; |
| 1839 | } else if (strcasecmp(val, "enabled") == 0) { |
| 1840 | dut->ap_rsn_preauth = 1; |
| 1841 | } else { |
| 1842 | send_resp(dut, conn, SIGMA_INVALID, |
| 1843 | "errorCode,Unsupported PreAuthentication value"); |
| 1844 | return 0; |
| 1845 | } |
| 1846 | } |
| 1847 | |
priyadharshini gowthaman | de81f39 | 2017-12-28 15:28:49 -0800 | [diff] [blame] | 1848 | val = get_param(cmd, "AKMSuiteType"); |
| 1849 | if (val) { |
| 1850 | unsigned int akmsuitetype = 0; |
| 1851 | |
| 1852 | dut->ap_akm = 1; |
| 1853 | akmsuitetype = atoi(val); |
| 1854 | if (akmsuitetype == 14) { |
| 1855 | dut->ap_add_sha256 = 1; |
| 1856 | } else if (akmsuitetype == 15) { |
| 1857 | dut->ap_add_sha384 = 1; |
| 1858 | } else { |
| 1859 | send_resp(dut, conn, SIGMA_INVALID, |
| 1860 | "errorCode,Unsupported AKMSuitetype"); |
| 1861 | return 0; |
| 1862 | } |
| 1863 | } |
| 1864 | |
| 1865 | val = get_param(cmd, "PMKSACaching"); |
| 1866 | if (val) { |
| 1867 | dut->ap_pmksa = 1; |
| 1868 | if (strcasecmp(val, "disabled") == 0) { |
| 1869 | dut->ap_pmksa_caching = 1; |
| 1870 | } else if (strcasecmp(val, "enabled") == 0) { |
| 1871 | dut->ap_pmksa_caching = 0; |
| 1872 | } else { |
| 1873 | send_resp(dut, conn, SIGMA_INVALID, |
| 1874 | "errorCode,Unsupported PMKSACaching value"); |
| 1875 | return 0; |
| 1876 | } |
| 1877 | } |
| 1878 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1879 | return 1; |
| 1880 | } |
| 1881 | |
| 1882 | |
Ankita Bajaj | 0d5825b | 2017-10-25 16:20:17 +0530 | [diff] [blame] | 1883 | int sta_cfon_set_wireless(struct sigma_dut *dut, struct sigma_conn *conn, |
| 1884 | struct sigma_cmd *cmd) |
| 1885 | { |
| 1886 | int status; |
| 1887 | |
| 1888 | status = cmd_ap_set_wireless(dut, conn, cmd); |
| 1889 | if (status != 1) |
| 1890 | return status; |
Ankita Bajaj | 0d212e8 | 2017-11-27 15:54:57 +0530 | [diff] [blame] | 1891 | status = cmd_ap_set_security(dut, conn, cmd); |
| 1892 | if (status != 1) |
| 1893 | return status; |
Ankita Bajaj | 0d5825b | 2017-10-25 16:20:17 +0530 | [diff] [blame] | 1894 | return cmd_ap_config_commit(dut, conn, cmd); |
| 1895 | } |
| 1896 | |
| 1897 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1898 | static int cmd_ap_set_radius(struct sigma_dut *dut, struct sigma_conn *conn, |
| 1899 | struct sigma_cmd *cmd) |
| 1900 | { |
| 1901 | /* const char *name = get_param(cmd, "NAME"); */ |
| 1902 | const char *val; |
| 1903 | unsigned int wlan_tag = 1, radius_port = 0; |
| 1904 | char *radius_ipaddr = NULL, *radius_password = NULL; |
| 1905 | |
| 1906 | val = get_param(cmd, "WLAN_TAG"); |
| 1907 | if (val) { |
| 1908 | wlan_tag = atoi(val); |
| 1909 | if (wlan_tag != 1 && wlan_tag != 2) { |
| 1910 | send_resp(dut, conn, SIGMA_INVALID, |
| 1911 | "errorCode,Invalid WLAN_TAG"); |
| 1912 | return 0; |
| 1913 | } |
| 1914 | } |
| 1915 | |
| 1916 | val = get_param(cmd, "PORT"); |
| 1917 | if (val) |
| 1918 | radius_port = atoi(val); |
| 1919 | |
| 1920 | if (wlan_tag == 1) { |
| 1921 | if (radius_port) |
| 1922 | dut->ap_radius_port = radius_port; |
| 1923 | radius_ipaddr = dut->ap_radius_ipaddr; |
| 1924 | radius_password = dut->ap_radius_password; |
| 1925 | } else if (wlan_tag == 2) { |
| 1926 | if (radius_port) |
| 1927 | dut->ap2_radius_port = radius_port; |
| 1928 | radius_ipaddr = dut->ap2_radius_ipaddr; |
| 1929 | radius_password = dut->ap2_radius_password; |
| 1930 | } |
| 1931 | |
| 1932 | val = get_param(cmd, "IPADDR"); |
| 1933 | if (val) { |
| 1934 | if (strlen(val) > sizeof(dut->ap_radius_ipaddr) - 1) |
| 1935 | return -1; |
| 1936 | snprintf(radius_ipaddr, sizeof(dut->ap_radius_ipaddr), |
| 1937 | "%s", val); |
| 1938 | } |
| 1939 | |
| 1940 | val = get_param(cmd, "PASSWORD"); |
| 1941 | if (val) { |
| 1942 | if (strlen(val) > sizeof(dut->ap_radius_password) - 1) |
| 1943 | return -1; |
| 1944 | snprintf(radius_password, |
| 1945 | sizeof(dut->ap_radius_password), "%s", val); |
| 1946 | } |
| 1947 | |
| 1948 | return 1; |
| 1949 | } |
| 1950 | |
| 1951 | |
| 1952 | static void owrt_ap_set_radio(struct sigma_dut *dut, int id, |
| 1953 | const char *key, const char *val) |
| 1954 | { |
| 1955 | char buf[100]; |
| 1956 | |
| 1957 | if (val == NULL) { |
| 1958 | snprintf(buf, sizeof(buf), |
| 1959 | "uci delete wireless.wifi%d.%s", id, key); |
| 1960 | run_system(dut, buf); |
| 1961 | return; |
| 1962 | } |
| 1963 | |
| 1964 | snprintf(buf, sizeof(buf), "uci set wireless.wifi%d.%s=%s", |
| 1965 | id, key, val); |
| 1966 | run_system(dut, buf); |
| 1967 | } |
| 1968 | |
| 1969 | |
| 1970 | static void owrt_ap_set_list_radio(struct sigma_dut *dut, int id, |
| 1971 | const char *key, const char *val) |
| 1972 | { |
| 1973 | char buf[256]; |
| 1974 | |
| 1975 | if (val == NULL) { |
| 1976 | snprintf(buf, sizeof(buf), |
| 1977 | "uci del_list wireless.wifi%d.%s", id, key); |
| 1978 | run_system(dut, buf); |
| 1979 | return; |
| 1980 | } |
| 1981 | |
| 1982 | snprintf(buf, sizeof(buf), "uci add_list wireless.wifi%d.%s=%s", |
| 1983 | id, key, val); |
| 1984 | run_system(dut, buf); |
| 1985 | } |
| 1986 | |
| 1987 | |
| 1988 | static void owrt_ap_set_vap(struct sigma_dut *dut, int id, const char *key, |
| 1989 | const char *val) |
| 1990 | { |
| 1991 | char buf[256]; |
| 1992 | |
| 1993 | if (val == NULL) { |
| 1994 | snprintf(buf, sizeof(buf), |
| 1995 | "uci delete wireless.@wifi-iface[%d].%s", id, key); |
| 1996 | run_system(dut, buf); |
| 1997 | return; |
| 1998 | } |
| 1999 | |
| 2000 | snprintf(buf, sizeof(buf), "uci set wireless.@wifi-iface[%d].%s=%s", |
| 2001 | id, key, val); |
| 2002 | run_system(dut, buf); |
| 2003 | } |
| 2004 | |
| 2005 | |
| 2006 | static void owrt_ap_set_list_vap(struct sigma_dut *dut, int id, |
| 2007 | const char *key, const char *val) |
| 2008 | { |
priyadharshini gowthaman | 2323d0a | 2016-09-02 15:48:02 -0700 | [diff] [blame] | 2009 | char buf[1024]; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2010 | |
| 2011 | if (val == NULL) { |
| 2012 | snprintf(buf, sizeof(buf), |
| 2013 | "uci del_list wireless.@wifi-iface[%d].%s", id, key); |
| 2014 | run_system(dut, buf); |
| 2015 | return; |
| 2016 | } |
| 2017 | |
| 2018 | snprintf(buf, sizeof(buf), |
| 2019 | "uci add_list wireless.@wifi-iface[%d].%s=%s", |
| 2020 | id, key, val); |
| 2021 | run_system(dut, buf); |
| 2022 | } |
| 2023 | |
| 2024 | |
| 2025 | static void owrt_ap_add_vap(struct sigma_dut *dut, int id, const char *key, |
| 2026 | const char *val) |
| 2027 | { |
| 2028 | char buf[256]; |
| 2029 | |
| 2030 | if (val == NULL) { |
| 2031 | snprintf(buf, sizeof(buf), |
| 2032 | "uci delete wireless.@wifi-iface[%d].%s", id, key); |
| 2033 | run_system(dut, buf); |
| 2034 | return; |
| 2035 | } |
| 2036 | |
| 2037 | snprintf(buf, sizeof(buf), "uci add wireless wifi-iface"); |
| 2038 | run_system(dut, buf); |
| 2039 | snprintf(buf, sizeof(buf), "uci set wireless.@wifi-iface[%d].%s=%s", |
| 2040 | id, key, val); |
| 2041 | run_system(dut, buf); |
| 2042 | snprintf(buf, sizeof(buf), "uci set wireless.@wifi-iface[%d].%s=%s", |
| 2043 | id, "network", "lan"); |
| 2044 | run_system(dut, buf); |
| 2045 | snprintf(buf, sizeof(buf), "uci set wireless.@wifi-iface[%d].%s=%s", |
| 2046 | id, "mode", "ap"); |
| 2047 | run_system(dut, buf); |
| 2048 | snprintf(buf, sizeof(buf), "uci set wireless.@wifi-iface[%d].%s=%s", |
| 2049 | id, "encryption", "none"); |
| 2050 | run_system(dut, buf); |
| 2051 | } |
| 2052 | |
| 2053 | |
| 2054 | #define OPENWRT_MAX_NUM_RADIOS 3 |
| 2055 | static void owrt_ap_config_radio(struct sigma_dut *dut) |
| 2056 | { |
| 2057 | int radio_id[MAX_RADIO] = { 0, 1 }; |
| 2058 | int radio_count, radio_no; |
| 2059 | char buf[64]; |
| 2060 | |
| 2061 | for (radio_count = 0; radio_count < OPENWRT_MAX_NUM_RADIOS; |
| 2062 | radio_count++) { |
| 2063 | snprintf(buf, sizeof(buf), "%s%d", "wifi", radio_count); |
| 2064 | for (radio_no = 0; radio_no < MAX_RADIO; radio_no++) { |
| 2065 | if (!sigma_radio_ifname[radio_no] || |
| 2066 | strcmp(sigma_radio_ifname[radio_no], buf) != 0) |
| 2067 | continue; |
| 2068 | owrt_ap_set_radio(dut, radio_count, "disabled", "0"); |
| 2069 | owrt_ap_set_vap(dut, radio_count, "device", buf); |
| 2070 | radio_id[radio_no] = radio_count; |
| 2071 | } |
| 2072 | } |
| 2073 | |
| 2074 | /* Hardware mode (11a/b/g/n/ac) & HT mode selection */ |
| 2075 | switch (dut->ap_mode) { |
| 2076 | case AP_11g: |
| 2077 | owrt_ap_set_radio(dut, radio_id[0], "hwmode", "11g"); |
| 2078 | break; |
| 2079 | case AP_11b: |
| 2080 | owrt_ap_set_radio(dut, radio_id[0], "hwmode", "11b"); |
| 2081 | break; |
| 2082 | case AP_11ng: |
| 2083 | owrt_ap_set_radio(dut, radio_id[0], "hwmode", "11ng"); |
| 2084 | owrt_ap_set_radio(dut, radio_id[0], "htmode", "HT20"); |
| 2085 | break; |
| 2086 | case AP_11a: |
| 2087 | owrt_ap_set_radio(dut, radio_id[0], "hwmode", "11a"); |
| 2088 | break; |
| 2089 | case AP_11na: |
| 2090 | owrt_ap_set_radio(dut, radio_id[0], "hwmode", "11na"); |
| 2091 | owrt_ap_set_radio(dut, radio_id[0], "htmode", "HT20"); |
| 2092 | break; |
| 2093 | case AP_11ac: |
| 2094 | owrt_ap_set_radio(dut, radio_id[0], "hwmode", "11ac"); |
| 2095 | owrt_ap_set_radio(dut, radio_id[0], "htmode", "HT80"); |
| 2096 | break; |
| 2097 | case AP_inval: |
| 2098 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 2099 | "MODE NOT SPECIFIED!"); |
| 2100 | return; |
| 2101 | default: |
| 2102 | owrt_ap_set_radio(dut, radio_id[0], "hwmode", "11ng"); |
| 2103 | owrt_ap_set_radio(dut, radio_id[0], "htmode", "HT20"); |
| 2104 | break; |
| 2105 | } |
| 2106 | |
| 2107 | if (dut->ap_is_dual) { |
| 2108 | /* Hardware mode (11a/b/g/n/ac) & HT mode selection */ |
| 2109 | switch (dut->ap_mode_1) { |
| 2110 | case AP_11g: |
| 2111 | owrt_ap_set_radio(dut, radio_id[1], "hwmode", "11g"); |
| 2112 | break; |
| 2113 | case AP_11b: |
| 2114 | owrt_ap_set_radio(dut, radio_id[1], "hwmode", "11b"); |
| 2115 | break; |
| 2116 | case AP_11ng: |
| 2117 | owrt_ap_set_radio(dut, radio_id[1], "hwmode", "11ng"); |
| 2118 | owrt_ap_set_radio(dut, radio_id[1], "htmode", "HT20"); |
| 2119 | break; |
| 2120 | case AP_11a: |
| 2121 | owrt_ap_set_radio(dut, radio_id[1], "hwmode", "11a"); |
| 2122 | break; |
| 2123 | case AP_11na: |
| 2124 | owrt_ap_set_radio(dut, radio_id[1], "hwmode", "11na"); |
| 2125 | owrt_ap_set_radio(dut, radio_id[1], "htmode", "HT20"); |
| 2126 | break; |
| 2127 | case AP_11ac: |
| 2128 | owrt_ap_set_radio(dut, radio_id[1], "hwmode", "11ac"); |
| 2129 | owrt_ap_set_radio(dut, radio_id[1], "htmode", "HT80"); |
| 2130 | break; |
| 2131 | case AP_inval: |
| 2132 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 2133 | "MODE NOT SPECIFIED!"); |
| 2134 | return; |
| 2135 | default: |
| 2136 | owrt_ap_set_radio(dut, radio_id[1], "hwmode", "11ng"); |
| 2137 | owrt_ap_set_radio(dut, radio_id[1], "htmode", "HT20"); |
| 2138 | break; |
| 2139 | } |
| 2140 | |
| 2141 | } |
| 2142 | |
| 2143 | /* Channel */ |
| 2144 | snprintf(buf, sizeof(buf), "%d", dut->ap_channel); |
| 2145 | owrt_ap_set_radio(dut, radio_id[0], "channel", buf); |
| 2146 | |
| 2147 | switch (dut->ap_chwidth) { |
| 2148 | case AP_20: |
| 2149 | owrt_ap_set_radio(dut, radio_id[0], "htmode", "HT20"); |
| 2150 | break; |
| 2151 | case AP_40: |
| 2152 | owrt_ap_set_radio(dut, radio_id[0], "htmode", "HT40"); |
| 2153 | break; |
| 2154 | case AP_80: |
| 2155 | owrt_ap_set_radio(dut, radio_id[0], "htmode", "HT80"); |
| 2156 | break; |
| 2157 | case AP_160: |
| 2158 | owrt_ap_set_radio(dut, radio_id[0], "htmode", "HT160"); |
| 2159 | break; |
priyadharshini gowthaman | 63ab848 | 2017-12-28 15:32:55 -0800 | [diff] [blame] | 2160 | case AP_80_80: |
| 2161 | owrt_ap_set_radio(dut, radio_id[0], "htmode", "HT80_80"); |
| 2162 | break; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2163 | case AP_AUTO: |
| 2164 | default: |
| 2165 | break; |
| 2166 | } |
| 2167 | |
| 2168 | if (dut->ap_channel == 140 || dut->ap_channel == 144) { |
| 2169 | if (get_openwrt_driver_type() == OPENWRT_DRIVER_ATHEROS) |
| 2170 | owrt_ap_set_radio(dut, radio_id[0], "set_ch_144", "3"); |
| 2171 | } |
| 2172 | |
| 2173 | if (dut->ap_is_dual) { |
| 2174 | snprintf(buf, sizeof(buf), "%d", dut->ap_channel_1); |
| 2175 | owrt_ap_set_radio(dut, radio_id[1], "channel", buf); |
| 2176 | } |
| 2177 | |
Adil Saeed Musthafa | 604c826 | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 2178 | /* Country Code */ |
| 2179 | if (dut->ap_reg_domain == REG_DOMAIN_GLOBAL) { |
| 2180 | const char *country; |
| 2181 | |
| 2182 | country = dut->ap_countrycode[0] ? dut->ap_countrycode : "US"; |
| 2183 | snprintf(buf, sizeof(buf), "%s4", country); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2184 | owrt_ap_set_radio(dut, radio_id[0], "country", buf); |
priyadharshini gowthaman | 27406b0 | 2017-12-28 15:35:45 -0800 | [diff] [blame] | 2185 | if (dut->ap_is_dual) |
| 2186 | owrt_ap_set_radio(dut, radio_id[1], "country", buf); |
Adil Saeed Musthafa | 604c826 | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 2187 | } else if (dut->ap_countrycode[0]) { |
| 2188 | owrt_ap_set_radio(dut, radio_id[0], "country", |
| 2189 | dut->ap_countrycode); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2190 | } |
| 2191 | |
| 2192 | if (dut->ap_disable_protection == 1) { |
| 2193 | owrt_ap_set_list_radio(dut, radio_id[0], "aggr_burst", "'0 0'"); |
| 2194 | owrt_ap_set_list_radio(dut, radio_id[0], "aggr_burst", "'1 0'"); |
| 2195 | owrt_ap_set_list_radio(dut, radio_id[0], "aggr_burst", "'2 0'"); |
| 2196 | owrt_ap_set_list_radio(dut, radio_id[0], "aggr_burst", "'3 0'"); |
| 2197 | } |
priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 2198 | |
| 2199 | if (dut->ap_oce == VALUE_ENABLED && |
| 2200 | get_driver_type() == DRIVER_OPENWRT) |
| 2201 | owrt_ap_set_radio(dut, radio_id[0], "bcnburst", "1"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2202 | } |
| 2203 | |
| 2204 | |
| 2205 | static int owrt_ap_config_vap_hs2(struct sigma_dut *dut, int vap_id) |
| 2206 | { |
| 2207 | char buf[256]; |
| 2208 | |
| 2209 | snprintf(buf, sizeof(buf), "%d", dut->ap_hs2); |
| 2210 | owrt_ap_set_vap(dut, vap_id, "hs20", buf); |
| 2211 | owrt_ap_set_vap(dut, vap_id, "qbssload", "1"); |
| 2212 | owrt_ap_set_vap(dut, vap_id, "hs20_deauth_req_timeout","3"); |
| 2213 | |
| 2214 | owrt_ap_set_list_vap(dut, vap_id, "hs20_oper_friendly_name", |
| 2215 | "'eng:Wi-Fi Alliance'"); |
| 2216 | |
| 2217 | owrt_ap_set_list_vap(dut, vap_id, "hs20_oper_friendly_name", |
| 2218 | "'chi:Wi-Fi\xe8\x81\x94\xe7\x9b\x9f'"); |
| 2219 | |
| 2220 | if (dut->ap_wan_metrics == 1) |
| 2221 | owrt_ap_set_vap(dut, vap_id, "hs20_wan_metrics", |
| 2222 | "'01:2500:384:0:0:10'"); |
| 2223 | else if (dut->ap_wan_metrics == 1) |
| 2224 | owrt_ap_set_vap(dut, vap_id, "hs20_wan_metrics", |
| 2225 | "'01:1500:384:20:20:10'"); |
| 2226 | else if (dut->ap_wan_metrics == 2) |
| 2227 | owrt_ap_set_vap(dut, vap_id, "hs20_wan_metrics", |
| 2228 | "'01:1500:384:20:20:10'"); |
| 2229 | else if (dut->ap_wan_metrics == 3) |
| 2230 | owrt_ap_set_vap(dut, vap_id, "hs20_wan_metrics", |
| 2231 | "'01:2000:1000:20:20:10'"); |
| 2232 | else if (dut->ap_wan_metrics == 4) |
| 2233 | owrt_ap_set_vap(dut, vap_id, "hs20_wan_metrics", |
| 2234 | "'01:8000:1000:20:20:10'"); |
| 2235 | else if (dut->ap_wan_metrics == 5) |
| 2236 | owrt_ap_set_vap(dut, vap_id, "hs20_wan_metrics", |
| 2237 | "'01:9000:5000:20:20:10'"); |
| 2238 | |
| 2239 | if (dut->ap_conn_capab == 1) { |
| 2240 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", "'1:0:0'"); |
| 2241 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", |
| 2242 | "'6:20:1'"); |
| 2243 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", |
| 2244 | "'6:22:0'"); |
| 2245 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", |
| 2246 | "'6:80:1'"); |
| 2247 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", |
| 2248 | "'6:443:1'"); |
| 2249 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", |
| 2250 | "'6:1723:0'"); |
| 2251 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", |
| 2252 | "'6:5060:0'"); |
| 2253 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", |
| 2254 | "'17:500:1'"); |
| 2255 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", |
| 2256 | "'17:5060:0'"); |
| 2257 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", |
| 2258 | "'17:4500:1'"); |
| 2259 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", |
| 2260 | "'50:0:1'"); |
| 2261 | } else if (dut->ap_conn_capab == 2) { |
| 2262 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", |
| 2263 | "'6:80:1'"); |
| 2264 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", |
| 2265 | "'6:443:1'"); |
| 2266 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", |
| 2267 | "'17:5060:1'"); |
| 2268 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", |
| 2269 | "'6:5060:1'"); |
| 2270 | } else if (dut->ap_conn_capab == 3) { |
| 2271 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", |
| 2272 | "'6:80:1'"); |
| 2273 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", |
| 2274 | "'6:443:1'"); |
| 2275 | } |
| 2276 | |
| 2277 | if (dut->ap_oper_class == 1) |
| 2278 | snprintf(buf, sizeof(buf), "%s", "51"); |
| 2279 | else if (dut->ap_oper_class == 2) |
| 2280 | snprintf(buf, sizeof(buf), "%s", "73"); |
| 2281 | else if (dut->ap_oper_class == 3) |
| 2282 | snprintf(buf, sizeof(buf), "%s", "5173"); |
| 2283 | |
| 2284 | if (dut->ap_oper_class) |
| 2285 | owrt_ap_set_vap(dut, vap_id, "hs20_operating_class", buf); |
| 2286 | |
| 2287 | if (dut->ap_osu_provider_list) { |
| 2288 | char *osu_friendly_name = NULL; |
| 2289 | char *osu_icon = NULL; |
| 2290 | char *osu_ssid = NULL; |
| 2291 | char *osu_nai = NULL; |
| 2292 | char *osu_service_desc = NULL; |
| 2293 | char *hs20_icon_filename = NULL; |
| 2294 | char hs20_icon[150]; |
| 2295 | int osu_method; |
| 2296 | |
| 2297 | hs20_icon_filename = "icon_red_zxx.png"; |
| 2298 | if (dut->ap_osu_icon_tag == 2) |
| 2299 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 2300 | snprintf(hs20_icon, sizeof(hs20_icon), |
| 2301 | "'128:61:zxx:image/png:icon_red_zxx.png:/etc/ath/%s'", |
| 2302 | hs20_icon_filename); |
| 2303 | osu_icon = "icon_red_zxx.png"; |
| 2304 | osu_ssid = "OSU"; |
| 2305 | osu_friendly_name = "'kor:SP 빨강 테스트 전용'"; |
| 2306 | osu_service_desc = "'kor:테스트 목적으로 무료 서비스'"; |
| 2307 | osu_method = (dut->ap_osu_method[0] == 0xFF) ? 1 : |
| 2308 | dut->ap_osu_method[0]; |
| 2309 | |
| 2310 | if (strlen(dut->ap_osu_server_uri[0])) |
| 2311 | owrt_ap_set_list_vap(dut, vap_id, "osu_server_uri", |
| 2312 | dut->ap_osu_server_uri[0]); |
| 2313 | else |
| 2314 | owrt_ap_set_list_vap(dut, vap_id, "osu_server_uri", |
| 2315 | "'https://osu-server.r2-testbed.wi-fi.org/'"); |
| 2316 | switch (dut->ap_osu_provider_list) { |
| 2317 | case 1: |
| 2318 | case 101: |
| 2319 | owrt_ap_set_list_vap(dut, vap_id, "osu_friendly_name", |
| 2320 | "'eng:SP Red Test Only'"); |
| 2321 | owrt_ap_set_list_vap(dut, vap_id, "osu_service_desc", |
| 2322 | "'eng:Free service for test purpose'"); |
| 2323 | owrt_ap_set_list_vap(dut, vap_id, "hs20_icon", |
| 2324 | hs20_icon); |
| 2325 | |
| 2326 | hs20_icon_filename = "icon_red_eng.png"; |
| 2327 | if (dut->ap_osu_icon_tag == 2) |
| 2328 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 2329 | |
| 2330 | snprintf(hs20_icon, sizeof(hs20_icon), |
| 2331 | "'160:76:eng:image/png:icon_red_eng.png:/etc/ath/%s'", |
| 2332 | hs20_icon_filename); |
| 2333 | owrt_ap_set_list_vap(dut, vap_id, "osu_icon", |
| 2334 | "icon_red_eng.png"); |
| 2335 | break; |
| 2336 | case 2: |
| 2337 | case 102: |
| 2338 | owrt_ap_set_list_vap(dut, vap_id, "osu_friendly_name", |
| 2339 | "'eng:Wireless Broadband Alliance'"); |
| 2340 | owrt_ap_set_list_vap(dut, vap_id, "osu_service_desc", |
| 2341 | "'eng:Free service for test purpose'"); |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2342 | hs20_icon_filename = "icon_orange_zxx.png"; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2343 | if (dut->ap_osu_icon_tag == 2) |
| 2344 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 2345 | |
| 2346 | snprintf(hs20_icon, sizeof(hs20_icon), |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2347 | "'128:61:zxx:image/png:icon_orange_zxx.png:/etc/ath/%s'", |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2348 | hs20_icon_filename); |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2349 | osu_icon = "icon_orange_zxx.png"; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2350 | osu_friendly_name = "'kor:와이어리스 브로드밴드 얼라이언스'"; |
| 2351 | break; |
| 2352 | case 3: |
| 2353 | case 103: |
| 2354 | osu_friendly_name = "spa:SP Red Test Only"; |
| 2355 | osu_service_desc = "spa:Free service for test purpose"; |
| 2356 | break; |
| 2357 | case 4: |
| 2358 | case 104: |
| 2359 | owrt_ap_set_list_vap(dut, vap_id, "osu_friendly_name", |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2360 | "'eng:SP Orange Test Only'"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2361 | owrt_ap_set_list_vap(dut, vap_id, "osu_service_desc", |
| 2362 | "'eng:Free service for test purpose'"); |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2363 | hs20_icon_filename = "icon_orange_eng.png"; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2364 | if (dut->ap_osu_icon_tag == 2) |
| 2365 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 2366 | |
| 2367 | snprintf(hs20_icon, sizeof(hs20_icon), |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2368 | "'160:76:eng:image/png:icon_orange_eng.png:/etc/ath/%s'", |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2369 | hs20_icon_filename); |
| 2370 | owrt_ap_set_list_vap(dut, vap_id, "hs20_icon", |
| 2371 | hs20_icon); |
| 2372 | osu_friendly_name = "'kor:SP 파랑 테스트 전용'"; |
| 2373 | |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2374 | hs20_icon_filename = "icon_orange_zxx.png"; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2375 | if (dut->ap_osu_icon_tag == 2) |
| 2376 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 2377 | |
| 2378 | snprintf(hs20_icon, sizeof(hs20_icon), |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2379 | "'128:61:zxx:image/png:icon_orange_zxx.png:/etc/ath/%s'", |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2380 | hs20_icon_filename); |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2381 | osu_icon = "icon_orange_zxx.png"; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2382 | break; |
| 2383 | case 5: |
| 2384 | case 105: |
| 2385 | owrt_ap_set_list_vap(dut, vap_id, "osu_friendly_name", |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2386 | "'eng:SP Orange Test Only'"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2387 | owrt_ap_set_list_vap(dut, vap_id, "osu_service_desc", |
| 2388 | "'eng:Free service for test purpose'"); |
| 2389 | osu_friendly_name = "'kor:SP 파랑 테스트 전용'"; |
| 2390 | |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2391 | hs20_icon_filename = "icon_orange_zxx.png"; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2392 | if (dut->ap_osu_icon_tag == 2) |
| 2393 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 2394 | |
| 2395 | snprintf(hs20_icon, sizeof(hs20_icon), |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2396 | "'128:61:zxx:image/png:icon_orange_zxx.png:/etc/ath/%s'", |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2397 | hs20_icon_filename); |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2398 | osu_icon = "icon_orange_zxx.png"; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2399 | break; |
| 2400 | case 6: |
| 2401 | case 106: |
| 2402 | owrt_ap_set_list_vap(dut, vap_id, "osu_friendly_name", |
| 2403 | "'eng:SP Green Test Only'"); |
| 2404 | owrt_ap_set_list_vap(dut, vap_id, "osu_friendly_name", |
| 2405 | "'kor:SP 초록 테스트 전용'"); |
| 2406 | |
| 2407 | hs20_icon_filename = "icon_green_zxx.png"; |
| 2408 | if (dut->ap_osu_icon_tag == 2) |
| 2409 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 2410 | |
| 2411 | snprintf(hs20_icon, sizeof(hs20_icon), |
| 2412 | "'128:61:zxx:image/png:icon_green_zxx.png:/etc/ath/%s'", |
| 2413 | hs20_icon_filename); |
| 2414 | owrt_ap_set_list_vap(dut, vap_id, "hs20_icon", |
| 2415 | hs20_icon); |
| 2416 | |
| 2417 | owrt_ap_set_list_vap(dut, vap_id, "osu_icon", |
| 2418 | "'icon_green_zxx.png'"); |
| 2419 | osu_method = (dut->ap_osu_method[0] == 0xFF) ? 0 : |
| 2420 | dut->ap_osu_method[0]; |
| 2421 | |
| 2422 | snprintf(buf, sizeof(buf), "%d", osu_method); |
| 2423 | owrt_ap_set_vap(dut, vap_id, "osu_method_list", buf); |
| 2424 | |
| 2425 | if (strlen(dut->ap_osu_server_uri[1])) |
| 2426 | owrt_ap_set_list_vap(dut, vap_id, |
| 2427 | "osu_server_uri", |
| 2428 | dut->ap_osu_server_uri[1]); |
| 2429 | else |
| 2430 | owrt_ap_set_list_vap(dut, vap_id, |
| 2431 | "osu_server_uri", |
| 2432 | "'https://osu-server.r2-testbed.wi-fi.org/'"); |
| 2433 | |
| 2434 | owrt_ap_set_list_vap(dut, vap_id, "osu_friendly_name", |
| 2435 | "'eng:SP Orange Test Only'"); |
| 2436 | |
| 2437 | hs20_icon_filename = "icon_orange_zxx.png"; |
| 2438 | if (dut->ap_osu_icon_tag == 2) |
| 2439 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 2440 | |
| 2441 | snprintf(hs20_icon, sizeof(hs20_icon), |
| 2442 | "'128:61:zxx:image/png:icon_orange_zxx.png:/etc/ath/%s'", |
| 2443 | hs20_icon_filename); |
| 2444 | |
| 2445 | osu_icon = "icon_orange_zxx.png"; |
| 2446 | osu_friendly_name = "'kor:SP 오렌지 테스트 전용'"; |
| 2447 | osu_method = (dut->ap_osu_method[1] == 0xFF) ? 0 : |
| 2448 | dut->ap_osu_method[1]; |
| 2449 | osu_service_desc = NULL; |
| 2450 | break; |
| 2451 | case 7: |
| 2452 | case 107: |
| 2453 | owrt_ap_set_list_vap(dut, vap_id, "osu_friendly_name", |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2454 | "'eng:SP Green Test Only'"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2455 | owrt_ap_set_list_vap(dut, vap_id, "osu_service_desc", |
| 2456 | "'eng:Free service for test purpose'"); |
| 2457 | |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2458 | hs20_icon_filename = "icon_green_eng.png"; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2459 | if (dut->ap_osu_icon_tag == 2) |
| 2460 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 2461 | |
| 2462 | snprintf(hs20_icon, sizeof(hs20_icon), |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2463 | "'160:76:eng:image/png:icon_green_eng.png:/etc/ath/%s'", |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2464 | hs20_icon_filename); |
| 2465 | owrt_ap_set_list_vap(dut, vap_id, "hs20_icon", |
| 2466 | hs20_icon); |
| 2467 | |
| 2468 | owrt_ap_set_list_vap(dut, vap_id, "osu_icon", |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2469 | "'icon_green_eng.png'"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2470 | osu_friendly_name = "'kor:SP 오렌지 테스트 전용'"; |
| 2471 | |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2472 | hs20_icon_filename = "icon_green_zxx.png"; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2473 | if (dut->ap_osu_icon_tag == 2) |
| 2474 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 2475 | |
| 2476 | snprintf(hs20_icon, sizeof(hs20_icon), |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2477 | "'128:61:zxx:image/png:icon_green_zxx.png:/etc/ath/%s'", |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2478 | hs20_icon_filename); |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2479 | osu_icon = "icon_green_zxx.png"; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2480 | break; |
| 2481 | case 8: |
| 2482 | case 108: |
| 2483 | owrt_ap_set_list_vap(dut, vap_id, "osu_friendly_name", |
| 2484 | "'eng:SP Red Test Only'"); |
| 2485 | owrt_ap_set_list_vap(dut, vap_id, "osu_service_desc", |
| 2486 | "'eng:Free service for test purpose'"); |
| 2487 | osu_ssid = "OSU-Encrypted"; |
| 2488 | osu_nai = "'anonymous@hotspot.net'"; |
| 2489 | break; |
| 2490 | case 9: |
| 2491 | case 109: |
| 2492 | osu_ssid = "OSU-OSEN"; |
| 2493 | osu_nai = "'test-anonymous@wi-fi.org'"; |
| 2494 | osu_friendly_name = "'eng:SP Orange Test Only'"; |
| 2495 | hs20_icon_filename = "icon_orange_zxx.png"; |
| 2496 | if (dut->ap_osu_icon_tag == 2) |
| 2497 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 2498 | |
| 2499 | snprintf(hs20_icon, sizeof(hs20_icon), |
| 2500 | "'128:61:zxx:image/png:icon_orange_zxx.png:/etc/ath/%s'", |
| 2501 | hs20_icon_filename); |
| 2502 | osu_icon = "icon_orange_zxx.png"; |
| 2503 | osu_method = (dut->ap_osu_method[0] == 0xFF) ? 1 : |
| 2504 | dut->ap_osu_method[0]; |
| 2505 | osu_service_desc = NULL; |
| 2506 | break; |
| 2507 | default: |
| 2508 | break; |
| 2509 | } |
| 2510 | |
| 2511 | if (strlen(dut->ap_osu_ssid)) { |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 2512 | if (strcmp(dut->ap_tag_ssid[0], |
| 2513 | dut->ap_osu_ssid) != 0 && |
| 2514 | strcmp(dut->ap_tag_ssid[0], osu_ssid) != 0) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2515 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 2516 | "OSU_SSID and WLAN_TAG2 SSID differ"); |
| 2517 | return -2; |
| 2518 | } |
| 2519 | |
| 2520 | snprintf(buf, sizeof(buf), "'\"%s\"'", |
| 2521 | dut->ap_osu_ssid); |
| 2522 | } else { |
| 2523 | snprintf(buf, sizeof(buf), "'\"%s\"'", osu_ssid); |
| 2524 | } |
| 2525 | |
| 2526 | owrt_ap_set_vap(dut, vap_id, "osu_ssid", buf); |
| 2527 | |
| 2528 | |
| 2529 | if (osu_friendly_name) |
| 2530 | owrt_ap_set_list_vap(dut, vap_id, "osu_friendly_name", |
| 2531 | osu_friendly_name); |
| 2532 | if (osu_service_desc) |
| 2533 | owrt_ap_set_list_vap(dut, vap_id, "osu_service_desc", |
| 2534 | osu_service_desc); |
| 2535 | if (osu_nai) |
| 2536 | owrt_ap_set_vap(dut, vap_id, "osu_nai", osu_nai); |
| 2537 | |
| 2538 | owrt_ap_set_list_vap(dut, vap_id, "hs20_icon", hs20_icon); |
| 2539 | |
| 2540 | if (osu_icon) |
| 2541 | owrt_ap_set_list_vap(dut, vap_id, "osu_icon", |
| 2542 | osu_icon); |
| 2543 | |
| 2544 | if (dut->ap_osu_provider_list > 100) { |
| 2545 | owrt_ap_set_list_vap(dut, vap_id, "osu_method_list", |
| 2546 | "0"); |
| 2547 | } else { |
| 2548 | snprintf(buf, sizeof(buf), "%d", osu_method); |
| 2549 | owrt_ap_set_list_vap(dut, vap_id, "osu_method_list", |
| 2550 | buf); |
| 2551 | } |
| 2552 | } |
| 2553 | |
| 2554 | return 0; |
| 2555 | } |
| 2556 | |
| 2557 | |
Adil Saeed Musthafa | a8d7484 | 2017-04-10 23:13:39 -0700 | [diff] [blame] | 2558 | static void set_anqp_elem_value(struct sigma_dut *dut, const char *ifname, |
| 2559 | char *anqp_string, size_t str_size) |
| 2560 | { |
| 2561 | unsigned char bssid[ETH_ALEN]; |
| 2562 | unsigned char dummy_mac[] = { 0x00, 0x10, 0x20, 0x30, 0x40, 0x50 }; |
| 2563 | int preference = 0xff; |
| 2564 | |
| 2565 | get_hwaddr(ifname, bssid); |
| 2566 | snprintf(anqp_string, str_size, |
| 2567 | "272:3410%02x%02x%02x%02x%02x%02xf70000007330000301%02x3410%02x%02x%02x%02x%02x%02xf70000007330000301%02x", |
| 2568 | bssid[0], bssid[1], bssid[2], bssid[3], bssid[4], bssid[5], |
| 2569 | preference, |
| 2570 | dummy_mac[0], dummy_mac[1], dummy_mac[2], |
| 2571 | dummy_mac[3], dummy_mac[4], dummy_mac[5], |
| 2572 | preference - 1); |
| 2573 | } |
| 2574 | |
| 2575 | |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 2576 | static void get_if_name(struct sigma_dut *dut, char *ifname_str, |
| 2577 | size_t str_size, int wlan_tag) |
| 2578 | { |
Jouni Malinen | f898464 | 2017-10-12 00:02:37 +0300 | [diff] [blame] | 2579 | const char *ifname; |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 2580 | enum driver_type drv; |
| 2581 | |
| 2582 | drv = get_driver_type(); |
Jouni Malinen | f898464 | 2017-10-12 00:02:37 +0300 | [diff] [blame] | 2583 | if (dut->hostapd_ifname && if_nametoindex(dut->hostapd_ifname) > 0) { |
| 2584 | ifname = dut->hostapd_ifname; |
| 2585 | } else if (drv == DRIVER_ATHEROS) { |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 2586 | if ((dut->ap_mode == AP_11a || dut->ap_mode == AP_11na || |
| 2587 | dut->ap_mode == AP_11ac) && |
| 2588 | if_nametoindex("ath1") > 0) |
| 2589 | ifname = "ath1"; |
| 2590 | else |
| 2591 | ifname = "ath0"; |
| 2592 | } else if (drv == DRIVER_OPENWRT) { |
| 2593 | if (sigma_radio_ifname[0] && |
| 2594 | strcmp(sigma_radio_ifname[0], "wifi2") == 0) |
| 2595 | ifname = "ath2"; |
| 2596 | else if (sigma_radio_ifname[0] && |
| 2597 | strcmp(sigma_radio_ifname[0], "wifi1") == 0) |
| 2598 | ifname = "ath1"; |
| 2599 | else |
| 2600 | ifname = "ath0"; |
| 2601 | } else { |
| 2602 | if ((dut->ap_mode == AP_11a || dut->ap_mode == AP_11na || |
| 2603 | dut->ap_mode == AP_11ac) && |
| 2604 | if_nametoindex("wlan1") > 0) |
| 2605 | ifname = "wlan1"; |
| 2606 | else |
| 2607 | ifname = "wlan0"; |
| 2608 | } |
| 2609 | |
| 2610 | if (drv == DRIVER_OPENWRT && wlan_tag > 1) { |
| 2611 | /* Handle tagged-ifname only on OPENWRT for now */ |
| 2612 | snprintf(ifname_str, str_size, "%s%d", ifname, wlan_tag - 1); |
Jouni Malinen | f898464 | 2017-10-12 00:02:37 +0300 | [diff] [blame] | 2613 | } else if (drv == DRIVER_MAC80211 && wlan_tag == 2) { |
| 2614 | snprintf(ifname_str, str_size, "%s_1", ifname); |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 2615 | } else { |
| 2616 | snprintf(ifname_str, str_size, "%s", ifname); |
| 2617 | } |
| 2618 | } |
| 2619 | |
| 2620 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2621 | static int owrt_ap_config_vap(struct sigma_dut *dut) |
| 2622 | { |
| 2623 | char buf[256], *temp; |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 2624 | int vap_id = 0, vap_count, i, j; |
priyadharshini gowthaman | 0454706 | 2018-01-15 11:59:55 -0800 | [diff] [blame] | 2625 | const char *ifname; |
| 2626 | char ifname2[50]; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2627 | |
priyadharshini gowthaman | 7356126 | 2018-02-20 13:24:59 -0800 | [diff] [blame] | 2628 | if (sigma_radio_ifname[0] && |
| 2629 | strcmp(sigma_radio_ifname[0], "wifi2") == 0) |
| 2630 | ifname = "ath2"; |
| 2631 | else if (sigma_radio_ifname[0] && |
| 2632 | strcmp(sigma_radio_ifname[0], "wifi1") == 0) |
| 2633 | ifname = "ath1"; |
| 2634 | else |
| 2635 | ifname = "ath0"; |
| 2636 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2637 | 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] | 2638 | snprintf(buf, sizeof(buf), "wifi%d", vap_count); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2639 | |
| 2640 | for (vap_id = 0; vap_id < MAX_RADIO; vap_id++) { |
| 2641 | if (sigma_radio_ifname[vap_id] && |
| 2642 | strcmp(sigma_radio_ifname[vap_id], buf) == 0) |
| 2643 | break; |
| 2644 | } |
| 2645 | if (vap_id == MAX_RADIO) |
| 2646 | continue; |
| 2647 | |
| 2648 | /* Single VAP configuration */ |
| 2649 | if (!dut->ap_is_dual) |
| 2650 | vap_id = vap_count; |
| 2651 | |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 2652 | for (j = 0; j < MAX_WLAN_TAGS - 1; j++) { |
| 2653 | /* |
| 2654 | * We keep a separate array of ap_tag_ssid and |
| 2655 | * ap_tag_key_mgmt for tags starting from WLAN_TAG=2. |
| 2656 | * So j=0 => WLAN_TAG = 2 |
| 2657 | */ |
| 2658 | int wlan_tag = j + 2; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2659 | |
priyadharshini gowthaman | 0e209fc | 2018-01-26 15:15:37 -0800 | [diff] [blame] | 2660 | if (wlan_tag == 2 && dut->program == PROGRAM_WPA3 && |
| 2661 | (dut->ap_interface_5g || dut->ap_interface_2g)) { |
| 2662 | snprintf(dut->ap_tag_ssid[wlan_tag - 2], |
| 2663 | sizeof(dut->ap_tag_ssid[wlan_tag - 2]), |
| 2664 | "%s-owe", dut->ap_ssid); |
| 2665 | } |
| 2666 | |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 2667 | if (dut->ap_tag_ssid[j][0] == '\0') |
| 2668 | continue; |
| 2669 | |
| 2670 | snprintf(buf, sizeof(buf), "%s%d", "wifi", vap_count); |
| 2671 | owrt_ap_add_vap(dut, vap_count + (wlan_tag - 1), |
| 2672 | "device", buf); |
| 2673 | /* SSID */ |
| 2674 | snprintf(buf, sizeof(buf), "\"%s\"", |
| 2675 | dut->ap_tag_ssid[j]); |
| 2676 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), |
| 2677 | "ssid", buf); |
| 2678 | |
priyadharshini gowthaman | 0454706 | 2018-01-15 11:59:55 -0800 | [diff] [blame] | 2679 | if (dut->ap_key_mgmt == AP_WPA2_OWE && |
| 2680 | dut->ap_tag_ssid[0][0] && |
| 2681 | dut->ap_tag_key_mgmt[0] == AP2_OPEN) { |
| 2682 | /* OWE transition mode */ |
| 2683 | snprintf(buf, sizeof(buf), "%s", ifname); |
| 2684 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), |
| 2685 | "owe_transition_ifname", buf); |
| 2686 | } |
| 2687 | |
| 2688 | if (dut->ap_key_mgmt == AP_OPEN && |
| 2689 | dut->ap_tag_key_mgmt[0] == AP2_WPA2_OWE) { |
| 2690 | /* OWE transition mode */ |
| 2691 | snprintf(buf, sizeof(buf), "%s", ifname); |
| 2692 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), |
| 2693 | "owe_transition_ifname", buf); |
| 2694 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), |
| 2695 | "hidden", "1"); |
| 2696 | } |
| 2697 | |
priyadharshini gowthaman | 47189f5 | 2017-12-28 12:37:46 -0800 | [diff] [blame] | 2698 | if (dut->ap_ft_oa == 1) { |
| 2699 | unsigned char self_mac[ETH_ALEN]; |
| 2700 | char mac_str[20]; |
| 2701 | |
| 2702 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), |
| 2703 | "mobility_domain", |
| 2704 | dut->ap_mobility_domain); |
| 2705 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), |
| 2706 | "ft_over_ds", "0"); |
| 2707 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), |
| 2708 | "ieee80211r", "1"); |
| 2709 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), |
| 2710 | "nasid", "nas1.example.com"); |
| 2711 | get_hwaddr(sigma_radio_ifname[0], self_mac); |
| 2712 | snprintf(mac_str, sizeof(mac_str), |
| 2713 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 2714 | self_mac[0], self_mac[1], self_mac[2], |
| 2715 | self_mac[3], self_mac[4], self_mac[5]); |
| 2716 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), |
| 2717 | "ap_macaddr", mac_str); |
| 2718 | snprintf(mac_str, sizeof(mac_str), |
| 2719 | "%02x%02x%02x%02x%02x%02x", |
| 2720 | self_mac[0], self_mac[1], self_mac[2], |
| 2721 | self_mac[3], self_mac[4], self_mac[5]); |
| 2722 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), |
| 2723 | "r1_key_holder", mac_str); |
| 2724 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), |
| 2725 | "ft_psk_generate_local", "1"); |
| 2726 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), |
| 2727 | "kh_key_hex", |
| 2728 | "000102030405060708090a0b0c0d0e0f"); |
| 2729 | snprintf(mac_str, sizeof(mac_str), |
| 2730 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 2731 | dut->ft_bss_mac_list[0][0], |
| 2732 | dut->ft_bss_mac_list[0][1], |
| 2733 | dut->ft_bss_mac_list[0][2], |
| 2734 | dut->ft_bss_mac_list[0][3], |
| 2735 | dut->ft_bss_mac_list[0][4], |
| 2736 | dut->ft_bss_mac_list[0][5]); |
| 2737 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), |
| 2738 | "ap2_macaddr", mac_str); |
| 2739 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), |
| 2740 | "ap2_r1_key_holder", mac_str); |
| 2741 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), |
| 2742 | "nasid2", "nas2.example.com"); |
| 2743 | } |
| 2744 | |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 2745 | if (dut->ap_tag_key_mgmt[j] == AP2_OSEN && |
| 2746 | wlan_tag == 2) { |
| 2747 | /* Only supported for WLAN_TAG=2 */ |
| 2748 | owrt_ap_set_vap(dut, vap_count + 1, "osen", |
| 2749 | "1"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2750 | snprintf(buf, sizeof(buf), "wpa2"); |
| 2751 | owrt_ap_set_vap(dut, vap_count + 1, |
| 2752 | "encryption", buf); |
| 2753 | snprintf(buf, sizeof(buf), "%s", |
| 2754 | dut->ap2_radius_ipaddr); |
| 2755 | owrt_ap_set_vap(dut, vap_count + 1, |
| 2756 | "auth_server", buf); |
| 2757 | snprintf(buf, sizeof(buf), "%d", |
| 2758 | dut->ap2_radius_port); |
| 2759 | owrt_ap_set_vap(dut, vap_count + 1, |
| 2760 | "auth_port", buf); |
| 2761 | snprintf(buf, sizeof(buf), "%s", |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 2762 | dut->ap2_radius_password); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2763 | owrt_ap_set_vap(dut, vap_count + 1, |
| 2764 | "auth_secret", buf); |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 2765 | } else if (dut->ap_tag_key_mgmt[j] == AP2_WPA2_PSK) { |
| 2766 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), |
| 2767 | "encryption", "psk2+ccmp"); |
| 2768 | snprintf(buf, sizeof(buf), "\"%s\"", |
| 2769 | dut->ap_passphrase); |
| 2770 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), |
| 2771 | "key", buf); |
| 2772 | snprintf(buf, sizeof(buf), "%d", dut->ap_pmf); |
priyadharshini gowthaman | 47189f5 | 2017-12-28 12:37:46 -0800 | [diff] [blame] | 2773 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 2774 | "ieee80211w", buf); |
priyadharshini gowthaman | 0454706 | 2018-01-15 11:59:55 -0800 | [diff] [blame] | 2775 | } else if (dut->ap_tag_key_mgmt[0] == AP2_WPA2_OWE) { |
| 2776 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), |
| 2777 | "owe", "1"); |
| 2778 | snprintf(buf, sizeof(buf), "ccmp"); |
| 2779 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), |
| 2780 | "encryption", buf); |
| 2781 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), |
| 2782 | "ieee80211w", "2"); |
| 2783 | if (dut->ap_sae_groups) { |
| 2784 | snprintf(buf, sizeof(buf), "\'%s\'", |
| 2785 | dut->ap_sae_groups); |
| 2786 | owrt_ap_set_vap(dut, vap_count + |
| 2787 | (wlan_tag - 1), |
| 2788 | "owe_groups", buf); |
| 2789 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2790 | } |
| 2791 | } |
| 2792 | |
priyadharshini gowthaman | 47189f5 | 2017-12-28 12:37:46 -0800 | [diff] [blame] | 2793 | /* Now set anqp_elem and ft_oa for wlan_tag = 1 */ |
Adil Saeed Musthafa | a8d7484 | 2017-04-10 23:13:39 -0700 | [diff] [blame] | 2794 | if (dut->program == PROGRAM_MBO && |
| 2795 | get_driver_type() == DRIVER_OPENWRT) { |
priyadharshini gowthaman | 47189f5 | 2017-12-28 12:37:46 -0800 | [diff] [blame] | 2796 | unsigned char self_mac[ETH_ALEN]; |
| 2797 | char mac_str[20]; |
Adil Saeed Musthafa | a8d7484 | 2017-04-10 23:13:39 -0700 | [diff] [blame] | 2798 | char anqp_string[200]; |
| 2799 | |
| 2800 | set_anqp_elem_value(dut, sigma_radio_ifname[0], |
| 2801 | anqp_string, sizeof(anqp_string)); |
| 2802 | owrt_ap_set_list_vap(dut, vap_count, "anqp_elem", |
| 2803 | anqp_string); |
priyadharshini gowthaman | 47189f5 | 2017-12-28 12:37:46 -0800 | [diff] [blame] | 2804 | |
| 2805 | if (dut->ap_ft_oa == 1) { |
| 2806 | owrt_ap_set_vap(dut, vap_count, |
| 2807 | "mobility_domain", |
| 2808 | dut->ap_mobility_domain); |
| 2809 | owrt_ap_set_vap(dut, vap_count, |
| 2810 | "ft_over_ds", "0"); |
| 2811 | owrt_ap_set_vap(dut, vap_count, |
| 2812 | "ieee80211r", "1"); |
| 2813 | owrt_ap_set_vap(dut, vap_count, |
| 2814 | "nasid", "nas1.example.com"); |
| 2815 | get_hwaddr(sigma_radio_ifname[0], self_mac); |
| 2816 | snprintf(mac_str, sizeof(mac_str), |
| 2817 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 2818 | self_mac[0], self_mac[1], self_mac[2], |
| 2819 | self_mac[3], self_mac[4], self_mac[5]); |
| 2820 | owrt_ap_set_vap(dut, vap_count, |
| 2821 | "ap_macaddr", mac_str); |
| 2822 | snprintf(mac_str, sizeof(mac_str), |
| 2823 | "%02x%02x%02x%02x%02x%02x", |
| 2824 | self_mac[0], self_mac[1], self_mac[2], |
| 2825 | self_mac[3], self_mac[4], self_mac[5]); |
| 2826 | owrt_ap_set_vap(dut, vap_count, |
| 2827 | "r1_key_holder", mac_str); |
| 2828 | owrt_ap_set_vap(dut, vap_count, |
| 2829 | "ft_psk_generate_local", "1"); |
| 2830 | owrt_ap_set_vap(dut, vap_count, |
| 2831 | "kh_key_hex", |
| 2832 | "000102030405060708090a0b0c0d0e0f"); |
| 2833 | snprintf(mac_str, sizeof(mac_str), |
| 2834 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 2835 | dut->ft_bss_mac_list[0][0], |
| 2836 | dut->ft_bss_mac_list[0][1], |
| 2837 | dut->ft_bss_mac_list[0][2], |
| 2838 | dut->ft_bss_mac_list[0][3], |
| 2839 | dut->ft_bss_mac_list[0][4], |
| 2840 | dut->ft_bss_mac_list[0][5]); |
| 2841 | owrt_ap_set_vap(dut, vap_count, |
| 2842 | "ap2_macaddr", mac_str); |
| 2843 | owrt_ap_set_vap(dut, vap_count, |
| 2844 | "ap2_r1_key_holder", mac_str); |
| 2845 | owrt_ap_set_vap(dut, vap_count, |
| 2846 | "nasid2", "nas2.example.com"); |
| 2847 | } |
Adil Saeed Musthafa | a8d7484 | 2017-04-10 23:13:39 -0700 | [diff] [blame] | 2848 | } |
| 2849 | |
priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 2850 | if (dut->ap_oce == VALUE_ENABLED && |
| 2851 | get_driver_type() == DRIVER_OPENWRT) { |
| 2852 | owrt_ap_set_vap(dut, vap_id, "oce", "1"); |
| 2853 | owrt_ap_set_vap(dut, vap_id, "qbssload", "1"); |
| 2854 | owrt_ap_set_vap(dut, vap_id, "bpr_enable", "1"); |
| 2855 | |
priyadharshini gowthaman | 63ab848 | 2017-12-28 15:32:55 -0800 | [diff] [blame] | 2856 | if (dut->ap_80plus80 == 1) |
| 2857 | owrt_ap_set_vap(dut, vap_id, "cfreq2", "5775"); |
| 2858 | |
priyadharshini gowthaman | de81f39 | 2017-12-28 15:28:49 -0800 | [diff] [blame] | 2859 | if (dut->ap_akm == 1) { |
| 2860 | owrt_ap_set_vap(dut, vap_id, "wpa_group_rekey", |
| 2861 | "3600"); |
| 2862 | owrt_ap_set_vap(dut, vap_id, "key", "12345678"); |
| 2863 | owrt_ap_set_vap(dut, vap_id, "ieee80211ai", |
| 2864 | "1"); |
| 2865 | owrt_ap_set_vap(dut, vap_id, "fils_cache_id", |
| 2866 | "1234"); |
| 2867 | owrt_ap_set_vap(dut, vap_id, |
| 2868 | "erp_send_reauth_start", "1"); |
| 2869 | } |
| 2870 | |
priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 2871 | if (dut->ap_filshlp == VALUE_ENABLED) { |
| 2872 | struct ifreq ifr; |
| 2873 | char *ifname; |
| 2874 | int s; |
| 2875 | struct sockaddr_in *ipaddr; |
| 2876 | |
| 2877 | s = socket(AF_INET, SOCK_DGRAM, 0); |
| 2878 | if (s < 0) { |
| 2879 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 2880 | "Failed to open socket"); |
| 2881 | return -1; |
| 2882 | } |
| 2883 | ifr.ifr_addr.sa_family = AF_INET; |
| 2884 | |
| 2885 | memset(&ifr, 0, sizeof(ifr)); |
| 2886 | ifname = "br-lan"; |
| 2887 | strlcpy(ifr.ifr_name, ifname, |
| 2888 | sizeof(ifr.ifr_name)); |
| 2889 | if (ioctl(s, SIOCGIFADDR, &ifr) < 0) { |
| 2890 | perror("ioctl"); |
| 2891 | close(s); |
| 2892 | return -1; |
| 2893 | } |
| 2894 | |
| 2895 | ipaddr = (struct sockaddr_in*)&ifr.ifr_addr; |
| 2896 | snprintf(buf, sizeof(buf), "%s", |
| 2897 | inet_ntoa(ipaddr->sin_addr)); |
| 2898 | owrt_ap_set_vap(dut, vap_id, "own_ip_addr", |
| 2899 | buf); |
| 2900 | snprintf(buf, sizeof(buf), "%s", |
| 2901 | dut->ap_dhcpserv_ipaddr); |
| 2902 | owrt_ap_set_vap(dut, vap_id, "dhcp_server", |
| 2903 | buf); |
| 2904 | owrt_ap_set_vap(dut, vap_id, |
| 2905 | "dhcp_rapid_commit_proxy", "1"); |
| 2906 | owrt_ap_set_vap(dut, vap_id, |
| 2907 | "fils_hlp_wait_time", "300"); |
| 2908 | } |
| 2909 | |
| 2910 | if (dut->ap_filsdscv == VALUE_ENABLED) { |
| 2911 | owrt_ap_set_vap(dut, vap_id, "ieee80211ai", |
| 2912 | "1"); |
| 2913 | owrt_ap_set_vap(dut, vap_id, "fils_fd_period", |
| 2914 | "20"); |
| 2915 | } |
| 2916 | } |
| 2917 | |
| 2918 | if (dut->ap_filsdscv == VALUE_DISABLED) { |
| 2919 | owrt_ap_set_vap(dut, vap_id, "ieee80211ai", "0"); |
| 2920 | owrt_ap_set_vap(dut, vap_id, "fils_fd_period", "0"); |
| 2921 | } |
| 2922 | |
| 2923 | if (dut->ap_oce == VALUE_DISABLED && |
| 2924 | get_driver_type() == DRIVER_OPENWRT) { |
| 2925 | owrt_ap_set_vap(dut, vap_id, "oce", "0"); |
| 2926 | owrt_ap_set_vap(dut, vap_id, "qbssload", "0"); |
| 2927 | owrt_ap_set_vap(dut, vap_id, "bpr_enable", "0"); |
| 2928 | |
| 2929 | if (dut->ap_filsdscv == VALUE_DISABLED) { |
| 2930 | owrt_ap_set_vap(dut, vap_id, "ieee80211ai", |
| 2931 | "0"); |
| 2932 | owrt_ap_set_vap(dut, vap_id, "fils_fd_period", |
| 2933 | "0"); |
| 2934 | } |
| 2935 | |
| 2936 | if (dut->device_type == AP_testbed) |
| 2937 | owrt_ap_set_vap(dut, vap_id, "mbo", "1"); |
| 2938 | } |
| 2939 | |
| 2940 | /* NAIRealm */ |
| 2941 | if (dut->ap_nairealm_int == 1) { |
| 2942 | snprintf(buf, sizeof(buf), "\"%s\"", dut->ap_nairealm); |
| 2943 | owrt_ap_set_vap(dut, vap_id, "fils_realm", buf); |
| 2944 | owrt_ap_set_vap(dut, vap_id, "erp_domain", buf); |
| 2945 | } |
| 2946 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2947 | /* SSID */ |
| 2948 | snprintf(buf, sizeof(buf), "\"%s\"", dut->ap_ssid); |
| 2949 | owrt_ap_set_vap(dut, vap_count, "ssid", buf); |
| 2950 | |
| 2951 | /* Encryption */ |
| 2952 | switch (dut->ap_key_mgmt) { |
| 2953 | case AP_OPEN: |
| 2954 | if (dut->ap_cipher == AP_WEP) { |
| 2955 | owrt_ap_set_vap(dut, vap_count, "encryption", |
| 2956 | "wep-mixed"); |
| 2957 | owrt_ap_set_vap(dut, vap_count, "key", |
| 2958 | dut->ap_wepkey); |
| 2959 | } else { |
| 2960 | owrt_ap_set_vap(dut, vap_count, "encryption", |
| 2961 | "none"); |
| 2962 | } |
priyadharshini gowthaman | 0454706 | 2018-01-15 11:59:55 -0800 | [diff] [blame] | 2963 | if (dut->ap_key_mgmt == AP_OPEN && |
| 2964 | dut->ap_tag_key_mgmt[0] == AP2_WPA2_OWE) { |
| 2965 | /* OWE transition mode */ |
| 2966 | snprintf(ifname2, sizeof(ifname2), "%s1", |
| 2967 | ifname); |
| 2968 | owrt_ap_set_vap(dut, vap_count, |
| 2969 | "owe_transition_ifname", |
| 2970 | ifname2); |
| 2971 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2972 | break; |
| 2973 | case AP_WPA2_PSK: |
| 2974 | case AP_WPA2_PSK_MIXED: |
| 2975 | case AP_WPA_PSK: |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 2976 | case AP_WPA2_SAE: |
| 2977 | case AP_WPA2_PSK_SAE: |
priyadharshini gowthaman | cce6ca0 | 2018-01-15 11:12:45 -0800 | [diff] [blame] | 2978 | if (dut->ap_key_mgmt == AP_WPA2_PSK || |
| 2979 | dut->ap_key_mgmt == AP_WPA2_PSK_SAE) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2980 | snprintf(buf, sizeof(buf), "psk2"); |
| 2981 | } else if (dut->ap_key_mgmt == AP_WPA2_PSK_MIXED) { |
| 2982 | snprintf(buf, sizeof(buf), "psk-mixed"); |
priyadharshini gowthaman | cce6ca0 | 2018-01-15 11:12:45 -0800 | [diff] [blame] | 2983 | } else if (dut->ap_key_mgmt == AP_WPA2_SAE) { |
| 2984 | snprintf(buf, sizeof(buf), "ccmp"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2985 | } else { |
| 2986 | snprintf(buf, sizeof(buf), "psk"); |
| 2987 | } |
| 2988 | |
priyadharshini gowthaman | cce6ca0 | 2018-01-15 11:12:45 -0800 | [diff] [blame] | 2989 | if (dut->ap_key_mgmt != AP_WPA2_SAE) { |
| 2990 | if (dut->ap_cipher == AP_CCMP_TKIP) |
| 2991 | strlcat(buf, "+ccmp+tkip", sizeof(buf)); |
| 2992 | else if (dut->ap_cipher == AP_TKIP) |
| 2993 | strlcat(buf, "+tkip", sizeof(buf)); |
| 2994 | else |
| 2995 | strlcat(buf, "+ccmp", sizeof(buf)); |
| 2996 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2997 | |
| 2998 | owrt_ap_set_vap(dut, vap_count, "encryption", buf); |
priyadharshini gowthaman | cce6ca0 | 2018-01-15 11:12:45 -0800 | [diff] [blame] | 2999 | |
| 3000 | if (!dut->ap_passphrase[0] && dut->ap_psk[0]) { |
| 3001 | snprintf(buf, sizeof(buf), "\"%s\"", |
| 3002 | dut->ap_psk); |
| 3003 | owrt_ap_set_vap(dut, vap_count, "key", buf); |
| 3004 | } else { |
| 3005 | snprintf(buf, sizeof(buf), "\"%s\"", |
| 3006 | dut->ap_passphrase); |
| 3007 | owrt_ap_set_vap(dut, vap_count, "key", buf); |
| 3008 | } |
| 3009 | |
| 3010 | if (dut->ap_key_mgmt == AP_WPA2_SAE || |
| 3011 | dut->ap_key_mgmt == AP_WPA2_PSK_SAE) |
| 3012 | owrt_ap_set_vap(dut, vap_count, "sae", "1"); |
| 3013 | else |
| 3014 | owrt_ap_set_vap(dut, vap_count, "sae", "0"); |
| 3015 | |
| 3016 | if (dut->ap_key_mgmt == AP_WPA2_SAE) { |
| 3017 | snprintf(buf, sizeof(buf), "%s", |
| 3018 | dut->ap_passphrase); |
| 3019 | owrt_ap_set_vap(dut, vap_count, "sae_password", |
| 3020 | buf); |
| 3021 | } else { |
| 3022 | snprintf(buf, sizeof(buf), "%s", |
| 3023 | dut->ap_passphrase); |
| 3024 | owrt_ap_set_vap(dut, vap_count, |
| 3025 | "wpa_passphrase", buf); |
| 3026 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3027 | break; |
| 3028 | case AP_WPA2_EAP: |
| 3029 | case AP_WPA2_EAP_MIXED: |
| 3030 | case AP_WPA_EAP: |
| 3031 | if (dut->ap_key_mgmt == AP_WPA2_EAP) { |
| 3032 | snprintf(buf, sizeof(buf), "wpa2"); |
| 3033 | } else if (dut->ap_key_mgmt == AP_WPA2_EAP_MIXED) { |
| 3034 | snprintf(buf, sizeof(buf), "wpa-mixed"); |
| 3035 | } else { |
| 3036 | snprintf(buf, sizeof(buf), "wpa"); |
| 3037 | } |
| 3038 | |
Peng Xu | 591be45 | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 3039 | if (dut->ap_cipher == AP_CCMP_TKIP) |
| 3040 | strlcat(buf, "+ccmp+tkip", sizeof(buf)); |
| 3041 | else if (dut->ap_cipher == AP_TKIP) |
| 3042 | strlcat(buf, "+tkip", sizeof(buf)); |
| 3043 | else |
| 3044 | strlcat(buf, "+ccmp", sizeof(buf)); |
| 3045 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3046 | owrt_ap_set_vap(dut, vap_count, "encryption", buf); |
| 3047 | snprintf(buf, sizeof(buf), "%s", dut->ap_radius_ipaddr); |
| 3048 | owrt_ap_set_vap(dut, vap_count, "auth_server", buf); |
| 3049 | snprintf(buf, sizeof(buf), "%d", dut->ap_radius_port); |
| 3050 | owrt_ap_set_vap(dut, vap_count, "auth_port", buf); |
| 3051 | snprintf(buf, sizeof(buf), "%s", |
| 3052 | dut->ap_radius_password); |
| 3053 | owrt_ap_set_vap(dut, vap_count, "auth_secret", buf); |
| 3054 | break; |
Jouni Malinen | ad395a2 | 2017-09-01 21:13:46 +0300 | [diff] [blame] | 3055 | case AP_SUITEB: |
priyadharshini gowthaman | 2136bd5 | 2018-01-15 11:28:55 -0800 | [diff] [blame] | 3056 | owrt_ap_set_vap(dut, vap_count, "suite_b", "192"); |
| 3057 | snprintf(buf, sizeof(buf), "gcmp"); |
| 3058 | owrt_ap_set_vap(dut, vap_count, "encryption", buf); |
| 3059 | snprintf(buf, sizeof(buf), "%s", dut->ap_radius_ipaddr); |
| 3060 | owrt_ap_set_vap(dut, vap_count, "auth_server", buf); |
| 3061 | snprintf(buf, sizeof(buf), "%d", dut->ap_radius_port); |
| 3062 | owrt_ap_set_vap(dut, vap_count, "auth_port", buf); |
| 3063 | snprintf(buf, sizeof(buf), "%s", |
| 3064 | dut->ap_radius_password); |
| 3065 | owrt_ap_set_vap(dut, vap_count, "auth_secret", buf); |
| 3066 | snprintf(buf, sizeof(buf), "%d", |
| 3067 | dut->ap_group_mgmt_cipher); |
| 3068 | owrt_ap_set_vap(dut, vap_count, "group_mgmt_cipher", |
| 3069 | buf); |
Jouni Malinen | ad395a2 | 2017-09-01 21:13:46 +0300 | [diff] [blame] | 3070 | break; |
Jouni Malinen | 147b3c3 | 2017-10-09 16:51:54 +0300 | [diff] [blame] | 3071 | case AP_WPA2_OWE: |
priyadharshini gowthaman | 0454706 | 2018-01-15 11:59:55 -0800 | [diff] [blame] | 3072 | owrt_ap_set_vap(dut, vap_count, "owe", "1"); |
| 3073 | snprintf(buf, sizeof(buf), "ccmp"); |
| 3074 | owrt_ap_set_vap(dut, vap_count, "encryption", buf); |
| 3075 | if (dut->ap_sae_groups) { |
| 3076 | snprintf(buf, sizeof(buf), "\'%s\'", |
| 3077 | dut->ap_sae_groups); |
| 3078 | owrt_ap_set_vap(dut, vap_count, "owe_groups", |
| 3079 | buf); |
| 3080 | } |
| 3081 | |
| 3082 | if (dut->ap_key_mgmt == AP_WPA2_OWE && |
| 3083 | dut->ap_tag_ssid[0][0] && |
| 3084 | dut->ap_tag_key_mgmt[0] == AP2_OPEN) { |
| 3085 | /* OWE transition mode */ |
| 3086 | snprintf(ifname2, sizeof(ifname2), "%s1", |
| 3087 | ifname); |
| 3088 | owrt_ap_set_vap(dut, vap_count, |
| 3089 | "owe_transition_ifname", |
| 3090 | ifname2); |
| 3091 | owrt_ap_set_vap(dut, vap_count, "hidden", "1"); |
| 3092 | } |
Jouni Malinen | 147b3c3 | 2017-10-09 16:51:54 +0300 | [diff] [blame] | 3093 | break; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3094 | } |
| 3095 | |
| 3096 | if (!dut->ap_is_dual) |
| 3097 | break; |
| 3098 | } |
| 3099 | |
| 3100 | if (dut->ap_is_dual) |
| 3101 | return 1; |
| 3102 | |
| 3103 | /* PMF */ |
| 3104 | snprintf(buf, sizeof(buf), "%d", dut->ap_pmf); |
| 3105 | owrt_ap_set_vap(dut, vap_id, "ieee80211w", buf); |
| 3106 | |
| 3107 | /* Add SHA256 */ |
| 3108 | snprintf(buf, sizeof(buf), "%d", dut->ap_add_sha256); |
| 3109 | owrt_ap_set_vap(dut, vap_id, "add_sha256", buf); |
| 3110 | |
priyadharshini gowthaman | de81f39 | 2017-12-28 15:28:49 -0800 | [diff] [blame] | 3111 | /* Add SHA384 for akmsuitetype 15 */ |
| 3112 | if (dut->ap_akm == 1) { |
| 3113 | snprintf(buf, sizeof(buf), "%d", dut->ap_add_sha384); |
| 3114 | owrt_ap_set_vap(dut, vap_id, "add_sha384", buf); |
| 3115 | } |
| 3116 | |
Sarvepalli, Rajesh Babu | 24dc7e4 | 2016-03-18 21:27:26 +0530 | [diff] [blame] | 3117 | /* Enable RSN preauthentication, if asked to */ |
| 3118 | snprintf(buf, sizeof(buf), "%d", dut->ap_rsn_preauth); |
| 3119 | owrt_ap_set_vap(dut, vap_id, "rsn_preauth", buf); |
| 3120 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3121 | /* Hotspot 2.0 */ |
| 3122 | if (dut->ap_hs2) { |
| 3123 | int ret; |
| 3124 | |
| 3125 | ret = owrt_ap_config_vap_hs2(dut, vap_id); |
| 3126 | if (ret) |
| 3127 | return ret; |
| 3128 | } |
| 3129 | |
| 3130 | /* Interworking */ |
| 3131 | if (dut->ap_interworking) { |
| 3132 | snprintf(buf, sizeof(buf), "%d", dut->ap_access_net_type); |
| 3133 | owrt_ap_set_vap(dut, vap_id, "access_network_type", buf); |
| 3134 | snprintf(buf, sizeof(buf), "%d", dut->ap_internet); |
| 3135 | owrt_ap_set_vap(dut, vap_id, "internet", buf); |
| 3136 | snprintf(buf, sizeof(buf), "%d", dut->ap_venue_group); |
| 3137 | owrt_ap_set_vap(dut, vap_id, "venue_group", buf); |
| 3138 | snprintf(buf, sizeof(buf), "%d", dut->ap_venue_type); |
| 3139 | owrt_ap_set_vap(dut, vap_id, "venue_type", buf); |
| 3140 | snprintf(buf, sizeof(buf), "%s", dut->ap_hessid); |
| 3141 | owrt_ap_set_vap(dut, vap_id, "hessid", buf); |
| 3142 | |
| 3143 | if (dut->ap_gas_cb_delay > 0) { |
| 3144 | snprintf(buf, sizeof(buf), "%d", dut->ap_gas_cb_delay); |
| 3145 | owrt_ap_set_vap(dut, vap_id, "gas_comeback_delay", buf); |
| 3146 | } |
| 3147 | |
| 3148 | if (dut->ap_roaming_cons[0]) { |
| 3149 | char *rcons, *temp_ptr; |
| 3150 | |
| 3151 | rcons = strdup(dut->ap_roaming_cons); |
| 3152 | if (rcons == NULL) |
| 3153 | return 0; |
| 3154 | |
| 3155 | temp_ptr = strchr(rcons, ';'); |
| 3156 | |
| 3157 | if (temp_ptr) |
| 3158 | *temp_ptr++ = '\0'; |
| 3159 | |
| 3160 | owrt_ap_set_list_vap(dut, vap_id, "roaming_consortium", |
| 3161 | rcons); |
| 3162 | |
| 3163 | if (temp_ptr) |
| 3164 | owrt_ap_set_list_vap(dut, vap_id, |
| 3165 | "roaming_consortium", |
| 3166 | temp_ptr); |
| 3167 | |
| 3168 | free(rcons); |
| 3169 | } |
| 3170 | } |
| 3171 | |
| 3172 | if (dut->ap_venue_name) { |
| 3173 | owrt_ap_set_list_vap(dut, vap_id, "venue_name", |
| 3174 | "'P\"eng:Wi-Fi Alliance\\n2989 Copper Road\\nSanta Clara, CA 95051, USA\"'"); |
| 3175 | owrt_ap_set_list_vap(dut, vap_id, "venue_name", |
| 3176 | "\'"ANQP_VENUE_NAME_1_CHI"\'"); |
| 3177 | } |
| 3178 | |
| 3179 | if (dut->ap_net_auth_type == 1) { |
| 3180 | owrt_ap_set_vap(dut, vap_id, "network_auth_type", |
| 3181 | "'00https://tandc-server.wi-fi.org'"); |
| 3182 | } else if (dut->ap_net_auth_type == 2) { |
| 3183 | owrt_ap_set_vap(dut, vap_id, "network_auth_type", "'01'"); |
| 3184 | } |
| 3185 | |
| 3186 | if (dut->ap_nai_realm_list == 1) { |
| 3187 | owrt_ap_set_list_vap(dut, vap_id, "nai_realm", |
| 3188 | "'0,mail.example.com;cisco.com;wi-fi.org,21[2:4][5:7]'"); |
| 3189 | owrt_ap_set_list_vap(dut, vap_id, "nai_realm", |
| 3190 | "'0,wi-fi.org;example.com,13[5:6]'"); |
| 3191 | |
| 3192 | } else if (dut->ap_nai_realm_list == 2) { |
| 3193 | owrt_ap_set_list_vap(dut, vap_id, "nai_realm", |
| 3194 | "'0,wi-fi.org,21[2:4][5:7]'"); |
| 3195 | } else if (dut->ap_nai_realm_list == 3) { |
| 3196 | owrt_ap_set_list_vap(dut, vap_id, "nai_realm", |
| 3197 | "'0,cisco.com;wi-fi.org,21[2:4][5:7]'"); |
| 3198 | owrt_ap_set_list_vap(dut, vap_id, "nai_realm", |
| 3199 | "'0,wi-fi.org;example.com,13[5:6]'"); |
| 3200 | } else if (dut->ap_nai_realm_list == 4) { |
| 3201 | owrt_ap_set_list_vap(dut, vap_id, "nai_realm", |
| 3202 | "'0,mail.example.com,21[2:4][5:7],13[5:6]'"); |
| 3203 | } else if (dut->ap_nai_realm_list == 5) { |
| 3204 | owrt_ap_set_list_vap(dut, vap_id, "nai_realm", |
| 3205 | "'0,wi-fi.org;ruckuswireless.com,21[2:4][5:7]'"); |
| 3206 | } else if (dut->ap_nai_realm_list == 6) { |
| 3207 | owrt_ap_set_list_vap(dut, vap_id, "nai_realm", |
| 3208 | "'0,wi-fi.org;mail.example.com,21[2:4][5:7]'"); |
| 3209 | } else if (dut->ap_nai_realm_list == 7) { |
| 3210 | owrt_ap_set_list_vap(dut, vap_id, "nai_realm", |
| 3211 | "'0,wi-fi.org,13[5:6]'"); |
| 3212 | owrt_ap_set_list_vap(dut, vap_id, "nai_realm", |
| 3213 | "'0,wi-fi.org,21[2:4][5:7]'"); |
| 3214 | } |
| 3215 | |
| 3216 | if (dut->ap_domain_name_list[0]) |
| 3217 | owrt_ap_set_list_vap(dut, vap_id, "domain_name", |
| 3218 | dut->ap_domain_name_list); |
| 3219 | |
| 3220 | if (dut->ap_ip_addr_type_avail) |
| 3221 | owrt_ap_set_vap(dut, vap_id, "ipaddr_type_availability", |
| 3222 | "'0c'"); |
| 3223 | |
| 3224 | temp = buf; |
| 3225 | |
| 3226 | *temp++ = '\''; |
| 3227 | |
| 3228 | for (i = 0; dut->ap_plmn_mcc[i][0] && dut->ap_plmn_mnc[i][0]; i++) { |
| 3229 | if (i) |
| 3230 | *temp++ = ';'; |
| 3231 | |
| 3232 | snprintf(temp, |
| 3233 | sizeof(dut->ap_plmn_mcc[i]) + |
| 3234 | sizeof(dut->ap_plmn_mnc[i]) + 1, |
| 3235 | "%s,%s", |
| 3236 | dut->ap_plmn_mcc[i], |
| 3237 | dut->ap_plmn_mnc[i]); |
| 3238 | |
| 3239 | temp += strlen(dut->ap_plmn_mcc[i]) + |
| 3240 | strlen(dut->ap_plmn_mnc[i]) + 1; |
| 3241 | } |
| 3242 | |
| 3243 | *temp++ = '\''; |
| 3244 | *temp++ = '\0'; |
| 3245 | |
| 3246 | if (i) |
| 3247 | owrt_ap_set_vap(dut, vap_id, "anqp_3gpp_cell_net", buf); |
| 3248 | |
| 3249 | if (dut->ap_qos_map_set == 1) |
| 3250 | owrt_ap_set_vap(dut, vap_id, "qos_map_set", QOS_MAP_SET_1); |
| 3251 | else if (dut->ap_qos_map_set == 2) |
| 3252 | owrt_ap_set_vap(dut, vap_id, "qos_map_set", QOS_MAP_SET_2); |
| 3253 | |
| 3254 | /* Proxy-ARP */ |
| 3255 | snprintf(buf, sizeof(buf), "%d", dut->ap_proxy_arp); |
| 3256 | owrt_ap_set_vap(dut, vap_id, "proxyarp", buf); |
| 3257 | |
| 3258 | /* DGAF */ |
| 3259 | snprintf(buf, sizeof(buf), "%d", dut->ap_dgaf_disable); |
| 3260 | /* parse to hostapd */ |
| 3261 | owrt_ap_set_vap(dut, vap_id, "disable_dgaf", buf); |
| 3262 | /* parse to wifi driver */ |
| 3263 | owrt_ap_set_vap(dut, vap_id, "dgaf_disable", buf); |
| 3264 | |
| 3265 | /* HCBSSLoad */ |
| 3266 | if (dut->ap_bss_load) { |
| 3267 | unsigned int bssload = 0; |
| 3268 | |
| 3269 | if (dut->ap_bss_load == 1) { |
| 3270 | /* STA count: 1, CU: 50, AAC: 65535 */ |
| 3271 | bssload = 0x0132ffff; |
| 3272 | } else if (dut->ap_bss_load == 2) { |
| 3273 | /* STA count: 1, CU: 200, AAC: 65535 */ |
| 3274 | bssload = 0x01c8ffff; |
| 3275 | } else if (dut->ap_bss_load == 3) { |
| 3276 | /* STA count: 1, CU: 75, AAC: 65535 */ |
| 3277 | bssload = 0x014bffff; |
| 3278 | } |
| 3279 | |
| 3280 | snprintf(buf, sizeof(buf), "%d", bssload); |
| 3281 | owrt_ap_set_vap(dut, vap_id, "hcbssload", buf); |
| 3282 | } |
| 3283 | |
| 3284 | /* L2TIF */ |
| 3285 | if (dut->ap_l2tif) |
| 3286 | owrt_ap_set_vap(dut, vap_id, "l2tif", "1"); |
| 3287 | |
| 3288 | if (dut->ap_disable_protection == 1) |
| 3289 | owrt_ap_set_vap(dut, vap_id, "enablertscts", "0"); |
| 3290 | |
Sunil Dutt | 77b213d | 2017-09-14 18:24:40 +0300 | [diff] [blame] | 3291 | if (dut->ap_txBF) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3292 | owrt_ap_set_vap(dut, vap_id, "vhtsubfee", "1"); |
| 3293 | owrt_ap_set_vap(dut, vap_id, "vhtsubfer", "1"); |
| 3294 | } |
| 3295 | |
Mohammed Shafi Shajakhan | 061af00 | 2016-06-02 20:10:54 +0530 | [diff] [blame] | 3296 | if (dut->ap_mu_txBF) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3297 | owrt_ap_set_vap(dut, vap_id, "vhtmubfer", "1"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3298 | |
Vasanthakumar Pandurangan | 2b5431d | 2016-01-12 15:52:48 +0530 | [diff] [blame] | 3299 | if (dut->ap_tx_stbc) { |
| 3300 | /* STBC and beamforming are mutually exclusive features */ |
| 3301 | owrt_ap_set_vap(dut, vap_id, "implicitbf", "0"); |
| 3302 | } |
| 3303 | |
Priyadharshini Gowthaman | 8fb1504 | 2015-11-25 18:27:41 +0530 | [diff] [blame] | 3304 | /* enable dfsmode */ |
| 3305 | snprintf(buf, sizeof(buf), "%d", dut->ap_dfs_mode); |
| 3306 | owrt_ap_set_vap(dut, vap_id, "doth", buf); |
| 3307 | |
priyadharshini gowthaman | 2323d0a | 2016-09-02 15:48:02 -0700 | [diff] [blame] | 3308 | if (dut->program == PROGRAM_LOC && dut->ap_interworking) { |
| 3309 | char anqpval[1024]; |
| 3310 | |
| 3311 | owrt_ap_set_vap(dut, vap_id, "interworking", "1"); |
| 3312 | |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 3313 | 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] | 3314 | snprintf(anqpval, sizeof(anqpval), |
| 3315 | "'265:0010%s%s060101'", |
priyadharshini gowthaman | 2323d0a | 2016-09-02 15:48:02 -0700 | [diff] [blame] | 3316 | dut->ap_val_lci, dut->ap_infoz); |
| 3317 | owrt_ap_set_list_vap(dut, vap_id, "anqp_elem", anqpval); |
| 3318 | } |
| 3319 | |
| 3320 | if (dut->ap_lcr == 1) { |
Pradeep Reddy Potteti | b48012a | 2016-11-28 16:58:54 +0530 | [diff] [blame] | 3321 | snprintf(anqpval, sizeof(anqpval), |
| 3322 | "'266:0000b2555302ae%s'", |
priyadharshini gowthaman | 2323d0a | 2016-09-02 15:48:02 -0700 | [diff] [blame] | 3323 | dut->ap_val_lcr); |
| 3324 | owrt_ap_set_list_vap(dut, vap_id, "anqp_elem", anqpval); |
| 3325 | } |
| 3326 | |
| 3327 | if (dut->ap_fqdn_held == 1 && dut->ap_fqdn_supl == 1) |
| 3328 | owrt_ap_set_list_vap(dut, vap_id, "anqp_elem", |
| 3329 | "'267:00110168656c642e6578616d706c652e636f6d0011027375706c2e6578616d706c652e636f6d'"); |
| 3330 | } |
| 3331 | |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 3332 | if (dut->program == PROGRAM_MBO) { |
| 3333 | owrt_ap_set_vap(dut, vap_id, "interworking", "1"); |
| 3334 | owrt_ap_set_vap(dut, vap_id, "mbo", "1"); |
| 3335 | owrt_ap_set_vap(dut, vap_id, "rrm", "1"); |
Adil Saeed Musthafa | 65160c0 | 2017-04-10 23:13:38 -0700 | [diff] [blame] | 3336 | owrt_ap_set_vap(dut, vap_id, "mbo_cell_conn_pref", "1"); |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 3337 | |
| 3338 | owrt_ap_set_list_vap(dut, vap_id, "anqp_elem", |
| 3339 | "'272:34108cfdf0020df1f7000000733000030101'"); |
Adil Saeed Musthafa | ed5faae | 2017-04-10 23:13:36 -0700 | [diff] [blame] | 3340 | snprintf(buf, sizeof(buf), "%d", dut->ap_gas_cb_delay); |
| 3341 | owrt_ap_set_vap(dut, vap_id, "gas_comeback_delay", buf); |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 3342 | } |
| 3343 | |
Adil Saeed Musthafa | 4ec61bd | 2017-04-10 23:13:41 -0700 | [diff] [blame] | 3344 | if (dut->ap_ft_oa == 1) { |
| 3345 | unsigned char self_mac[ETH_ALEN]; |
| 3346 | char mac_str[20]; |
| 3347 | |
| 3348 | owrt_ap_set_vap(dut, vap_id, "ft_over_ds", "0"); |
| 3349 | owrt_ap_set_vap(dut, vap_id, "ieee80211r", "1"); |
| 3350 | get_hwaddr(sigma_radio_ifname[0], self_mac); |
| 3351 | snprintf(mac_str, sizeof(mac_str), |
| 3352 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 3353 | self_mac[0], self_mac[1], self_mac[2], |
| 3354 | self_mac[3], self_mac[4], self_mac[5]); |
| 3355 | owrt_ap_set_vap(dut, vap_id, "ap_macaddr", mac_str); |
priyadharshini gowthaman | 47189f5 | 2017-12-28 12:37:46 -0800 | [diff] [blame] | 3356 | snprintf(mac_str, sizeof(mac_str), |
| 3357 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 3358 | self_mac[0], self_mac[1], self_mac[2], |
| 3359 | self_mac[3], self_mac[4], self_mac[5]); |
| 3360 | 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] | 3361 | owrt_ap_set_vap(dut, vap_id, "ft_psk_generate_local", "1"); |
| 3362 | owrt_ap_set_vap(dut, vap_id, "kh_key_hex", |
| 3363 | "000102030405060708090a0b0c0d0e0f"); |
| 3364 | snprintf(mac_str, sizeof(mac_str), |
| 3365 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 3366 | dut->ft_bss_mac_list[0][0], |
| 3367 | dut->ft_bss_mac_list[0][1], |
| 3368 | dut->ft_bss_mac_list[0][2], |
| 3369 | dut->ft_bss_mac_list[0][3], |
| 3370 | dut->ft_bss_mac_list[0][4], |
| 3371 | dut->ft_bss_mac_list[0][5]); |
| 3372 | owrt_ap_set_vap(dut, vap_id, "ap2_macaddr", mac_str); |
priyadharshini gowthaman | 47189f5 | 2017-12-28 12:37:46 -0800 | [diff] [blame] | 3373 | owrt_ap_set_vap(dut, vap_id, "mobility_domain", |
| 3374 | dut->ap_mobility_domain); |
| 3375 | 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] | 3376 | } |
| 3377 | |
| 3378 | if ((dut->ap_ft_oa == 1 && dut->ap_name == 0) || |
| 3379 | (dut->ap_ft_oa == 1 && dut->ap_name == 2)) { |
Adil Saeed Musthafa | 4ec61bd | 2017-04-10 23:13:41 -0700 | [diff] [blame] | 3380 | owrt_ap_set_vap(dut, vap_id, "nasid2", "nas2.example.com"); |
| 3381 | owrt_ap_set_vap(dut, vap_id, "nasid", "nas1.example.com"); |
Adil Saeed Musthafa | 4ec61bd | 2017-04-10 23:13:41 -0700 | [diff] [blame] | 3382 | } |
| 3383 | |
| 3384 | if (dut->ap_ft_oa == 1 && dut->ap_name == 1) { |
Adil Saeed Musthafa | 4ec61bd | 2017-04-10 23:13:41 -0700 | [diff] [blame] | 3385 | owrt_ap_set_vap(dut, vap_id, "nasid2", "nas1.example.com"); |
| 3386 | owrt_ap_set_vap(dut, vap_id, "nasid", "nas2.example.com"); |
Adil Saeed Musthafa | 4ec61bd | 2017-04-10 23:13:41 -0700 | [diff] [blame] | 3387 | } |
| 3388 | |
priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 3389 | if (dut->ap_broadcast_ssid == VALUE_DISABLED) |
| 3390 | owrt_ap_set_vap(dut, vap_id, "hidden", "1"); |
| 3391 | |
priyadharshini gowthaman | de81f39 | 2017-12-28 15:28:49 -0800 | [diff] [blame] | 3392 | /* Enable/disable PMKSA caching, if asked to */ |
| 3393 | if (dut->ap_pmksa == 1) { |
| 3394 | snprintf(buf, sizeof(buf), "%d", dut->ap_pmksa_caching); |
| 3395 | owrt_ap_set_vap(dut, vap_id, "disable_pmksa_caching", buf); |
| 3396 | } |
| 3397 | |
priyadharshini gowthaman | cce6ca0 | 2018-01-15 11:12:45 -0800 | [diff] [blame] | 3398 | if (dut->rsne_override) { |
| 3399 | snprintf(buf, sizeof(buf), "%s", dut->rsne_override); |
| 3400 | owrt_ap_set_vap(dut, vap_count, "own_ie_override", buf); |
| 3401 | } |
| 3402 | |
| 3403 | if (dut->sae_commit_override) { |
| 3404 | snprintf(buf, sizeof(buf), "%s", dut->sae_commit_override); |
| 3405 | owrt_ap_set_vap(dut, vap_count, "sae_commit_override", buf); |
| 3406 | } |
| 3407 | |
| 3408 | if (dut->ap_sae_groups) { |
| 3409 | snprintf(buf, sizeof(buf), "\'%s\'", dut->ap_sae_groups); |
| 3410 | owrt_ap_set_vap(dut, vap_count, "sae_groups", buf); |
| 3411 | } |
| 3412 | |
| 3413 | if (dut->sae_anti_clogging_threshold >= 0) { |
| 3414 | snprintf(buf, sizeof(buf), "%d", |
| 3415 | dut->sae_anti_clogging_threshold); |
| 3416 | owrt_ap_set_vap(dut, vap_count, "sae_anti_clogging_threshold", |
| 3417 | buf); |
| 3418 | } |
| 3419 | |
| 3420 | if (dut->sae_reflection) |
| 3421 | owrt_ap_set_vap(dut, vap_count, "sae_reflection_attack", "1"); |
| 3422 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3423 | return 1; |
| 3424 | } |
| 3425 | |
| 3426 | |
priyadharshini gowthaman | 2500f20 | 2016-10-13 17:13:55 -0700 | [diff] [blame] | 3427 | static int owrt_ap_config_vap_anqp(struct sigma_dut *dut) |
| 3428 | { |
| 3429 | char anqpval[1024]; |
| 3430 | unsigned char addr[6]; |
| 3431 | unsigned char addr2[6]; |
| 3432 | struct ifreq ifr; |
| 3433 | char *ifname; |
| 3434 | int s; |
| 3435 | int vap_id = 0; |
| 3436 | |
| 3437 | s = socket(AF_INET, SOCK_DGRAM, 0); |
| 3438 | if (s < 0) { |
| 3439 | sigma_dut_print(dut, DUT_MSG_ERROR, "Failed to open socket"); |
| 3440 | return -1; |
| 3441 | } |
| 3442 | |
| 3443 | memset(&ifr, 0, sizeof(ifr)); |
| 3444 | ifname = "ath0"; |
Peng Xu | b8fc5cc | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 3445 | strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name)); |
priyadharshini gowthaman | 2500f20 | 2016-10-13 17:13:55 -0700 | [diff] [blame] | 3446 | if (ioctl(s, SIOCGIFHWADDR, &ifr) < 0) { |
| 3447 | perror("ioctl"); |
| 3448 | close(s); |
| 3449 | return -1; |
| 3450 | } |
| 3451 | memcpy(addr, ifr.ifr_hwaddr.sa_data, 6); |
| 3452 | |
| 3453 | memset(&ifr, 0, sizeof(ifr)); |
| 3454 | ifname = "ath01"; |
Peng Xu | b8fc5cc | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 3455 | strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name)); |
priyadharshini gowthaman | 2500f20 | 2016-10-13 17:13:55 -0700 | [diff] [blame] | 3456 | if (ioctl(s, SIOCGIFHWADDR, &ifr) < 0) { |
| 3457 | perror("ioctl"); |
| 3458 | close(s); |
| 3459 | return -1; |
| 3460 | } |
| 3461 | close(s); |
| 3462 | memcpy(addr2, ifr.ifr_hwaddr.sa_data, 6); |
| 3463 | |
| 3464 | snprintf(anqpval, sizeof(anqpval), |
| 3465 | "'265:0010%s%s060101070d00%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x'", |
| 3466 | dut->ap_val_lci, dut->ap_infoz, |
| 3467 | addr[0], addr[1], addr[2], addr[3], addr[4], addr[5], |
| 3468 | addr2[0], addr2[1], addr2[2], addr2[3], addr2[4], addr2[5]); |
| 3469 | |
| 3470 | owrt_ap_set_list_vap(dut, vap_id, "anqp_elem", anqpval); |
| 3471 | return 0; |
| 3472 | } |
| 3473 | |
| 3474 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3475 | static int owrt_ap_post_config_commit(struct sigma_dut *dut, |
| 3476 | struct sigma_conn *conn, |
| 3477 | struct sigma_cmd *cmd) |
| 3478 | { |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 3479 | int ap_security = 0; |
| 3480 | int i; |
| 3481 | |
| 3482 | for (i = 0; i < MAX_WLAN_TAGS - 1; i++) { |
| 3483 | if (dut->ap_tag_key_mgmt[i] != AP2_OPEN) |
| 3484 | ap_security = 1; |
| 3485 | } |
| 3486 | if (dut->ap_key_mgmt != AP_OPEN) |
| 3487 | ap_security = 1; |
| 3488 | if (ap_security) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3489 | /* allow some time for hostapd to start before returning |
| 3490 | * success */ |
| 3491 | usleep(500000); |
| 3492 | |
| 3493 | if (run_hostapd_cli(dut, "ping") != 0) { |
| 3494 | send_resp(dut, conn, SIGMA_ERROR, |
| 3495 | "errorCode,Failed to talk to hostapd"); |
| 3496 | return 0; |
| 3497 | } |
| 3498 | } |
| 3499 | |
| 3500 | if (get_openwrt_driver_type() == OPENWRT_DRIVER_ATHEROS) |
| 3501 | ath_ap_set_params(dut); |
| 3502 | |
| 3503 | /* Send response */ |
| 3504 | return 1; |
| 3505 | } |
| 3506 | |
| 3507 | |
| 3508 | static int cmd_owrt_ap_config_commit(struct sigma_dut *dut, |
| 3509 | struct sigma_conn *conn, |
| 3510 | struct sigma_cmd *cmd) |
| 3511 | { |
priyadharshini gowthaman | b4de196 | 2018-01-15 12:21:04 -0800 | [diff] [blame] | 3512 | if (dut->program == PROGRAM_DPP && |
| 3513 | get_driver_type() == DRIVER_OPENWRT) { |
| 3514 | wpa_command(dut->hostapd_ifname, "DPP_BOOTSTRAP_REMOVE *"); |
| 3515 | wpa_command(dut->hostapd_ifname, "DPP_PKEX_REMOVE *"); |
| 3516 | } |
| 3517 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3518 | /* Stop the AP */ |
| 3519 | run_system(dut, "wifi down"); |
| 3520 | |
| 3521 | /* Reset the wireless configuration */ |
Mohammed Shafi Shajakhan | f789f82 | 2016-04-07 18:53:16 +0530 | [diff] [blame] | 3522 | run_system(dut, "rm -rf /etc/config/wireless"); |
| 3523 | switch (get_openwrt_driver_type()) { |
| 3524 | case OPENWRT_DRIVER_ATHEROS: |
| 3525 | run_system(dut, "wifi detect qcawifi > /etc/config/wireless"); |
| 3526 | break; |
| 3527 | default: |
| 3528 | run_system(dut, "wifi detect > /etc/config/wireless"); |
| 3529 | break; |
| 3530 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3531 | |
| 3532 | /* Configure Radio & VAP, commit the config */ |
| 3533 | owrt_ap_config_radio(dut); |
| 3534 | owrt_ap_config_vap(dut); |
| 3535 | run_system(dut, "uci commit"); |
| 3536 | |
| 3537 | /* Start AP */ |
| 3538 | run_system(dut, "wifi up"); |
Adil Saeed Musthafa | a8d7484 | 2017-04-10 23:13:39 -0700 | [diff] [blame] | 3539 | if (dut->program != PROGRAM_MBO && |
| 3540 | dut->ap_lci == 1 && dut->ap_interworking && |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 3541 | strlen(dut->ap_tag_ssid[0]) > 0) { |
Adil Saeed Musthafa | a8d7484 | 2017-04-10 23:13:39 -0700 | [diff] [blame] | 3542 | /* |
| 3543 | * MBO has a different ANQP element value which is set in |
| 3544 | * owrt_ap_config_vap(). |
| 3545 | */ |
priyadharshini gowthaman | 2500f20 | 2016-10-13 17:13:55 -0700 | [diff] [blame] | 3546 | owrt_ap_config_vap_anqp(dut); |
| 3547 | run_system(dut, "uci commit"); |
| 3548 | run_system(dut, "wifi"); |
| 3549 | } |
| 3550 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3551 | return owrt_ap_post_config_commit(dut, conn, cmd); |
| 3552 | } |
| 3553 | |
| 3554 | |
| 3555 | static void cmd_owrt_ap_hs2_reset(struct sigma_dut *dut) |
| 3556 | { |
| 3557 | unsigned char bssid[6]; |
| 3558 | char buf[100]; |
| 3559 | char *ifname, *radio_name; |
| 3560 | int vap_id = 0; |
| 3561 | |
| 3562 | if (sigma_radio_ifname[0] && |
| 3563 | strcmp(sigma_radio_ifname[0], "wifi2") == 0) { |
| 3564 | ifname = "ath2"; |
| 3565 | radio_name = "wifi2"; |
| 3566 | vap_id = 2; |
| 3567 | } else if (sigma_radio_ifname[0] && |
| 3568 | strcmp(sigma_radio_ifname[0], "wifi1") == 0) { |
| 3569 | ifname = "ath1"; |
| 3570 | radio_name = "wifi1"; |
| 3571 | vap_id = 1; |
| 3572 | } else { |
| 3573 | ifname = "ath0"; |
| 3574 | radio_name = "wifi0"; |
| 3575 | vap_id = 0; |
| 3576 | } |
| 3577 | |
| 3578 | if (!get_hwaddr(ifname, bssid)) { |
| 3579 | snprintf(buf, sizeof(buf), "%s", bssid); |
| 3580 | owrt_ap_set_vap(dut, vap_id, "hessid", buf); |
| 3581 | snprintf(dut->ap_hessid, sizeof(dut->ap_hessid), |
| 3582 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 3583 | bssid[0], bssid[1], bssid[2], bssid[3], |
| 3584 | bssid[4], bssid[5]); |
| 3585 | } else { |
| 3586 | if (!get_hwaddr(radio_name, bssid)) { |
| 3587 | snprintf(buf, sizeof(buf), "%s", dut->ap_hessid); |
| 3588 | owrt_ap_set_vap(dut, vap_id, "hessid", buf); |
| 3589 | snprintf(dut->ap_hessid, sizeof(dut->ap_hessid), |
| 3590 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 3591 | bssid[0], bssid[1], bssid[2], bssid[3], |
| 3592 | bssid[4], bssid[5]); |
| 3593 | } else { |
| 3594 | /* Select & enable/disable radios */ |
| 3595 | if (sigma_radio_ifname[0] && |
| 3596 | strcmp(sigma_radio_ifname[0], "wifi2") == 0) { |
| 3597 | /* We want to use wifi2 */ |
| 3598 | owrt_ap_set_radio(dut, 0, "disabled", "1"); |
| 3599 | owrt_ap_set_radio(dut, 1, "disabled", "1"); |
| 3600 | owrt_ap_set_radio(dut, 2, "disabled", "0"); |
| 3601 | owrt_ap_set_vap(dut, vap_id, "device", "wifi2"); |
| 3602 | } else if (sigma_radio_ifname[0] && |
| 3603 | strcmp(sigma_radio_ifname[0], "wifi1") == 0) { |
| 3604 | /* We want to use wifi1 */ |
| 3605 | owrt_ap_set_radio(dut, 0, "disabled", "1"); |
| 3606 | owrt_ap_set_radio(dut, 1, "disabled", "0"); |
| 3607 | owrt_ap_set_vap(dut, vap_id, "device", "wifi1"); |
| 3608 | } else { |
| 3609 | /* We want to use wifi0 */ |
| 3610 | owrt_ap_set_radio(dut, 0, "disabled", "0"); |
| 3611 | owrt_ap_set_radio(dut, 1, "disabled", "1"); |
| 3612 | owrt_ap_set_vap(dut, vap_id, "device", "wifi0"); |
| 3613 | } |
| 3614 | |
| 3615 | run_system(dut, "uci commit"); |
| 3616 | run_system(dut, "wifi up"); |
| 3617 | |
| 3618 | if (!get_hwaddr(radio_name, bssid)) { |
| 3619 | snprintf(buf, sizeof(buf), "%s", |
| 3620 | dut->ap_hessid); |
| 3621 | owrt_ap_set_vap(dut, vap_id, "hessid", buf); |
| 3622 | snprintf(dut->ap_hessid, sizeof(dut->ap_hessid), |
| 3623 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 3624 | bssid[0], bssid[1], bssid[2], bssid[3], |
| 3625 | bssid[4], bssid[5]); |
| 3626 | } |
| 3627 | } |
| 3628 | } |
| 3629 | } |
| 3630 | |
| 3631 | |
| 3632 | static int cmd_ap_reboot(struct sigma_dut *dut, struct sigma_conn *conn, |
| 3633 | struct sigma_cmd *cmd) |
| 3634 | { |
| 3635 | switch (get_driver_type()) { |
| 3636 | case DRIVER_ATHEROS: |
| 3637 | run_system(dut, "apdown"); |
| 3638 | sleep(1); |
| 3639 | run_system(dut, "reboot"); |
| 3640 | break; |
| 3641 | case DRIVER_OPENWRT: |
| 3642 | run_system(dut, "wifi down"); |
| 3643 | sleep(1); |
| 3644 | run_system(dut, "reboot"); |
| 3645 | break; |
| 3646 | default: |
| 3647 | sigma_dut_print(dut, DUT_MSG_INFO, "Ignore ap_reboot command"); |
| 3648 | break; |
| 3649 | } |
| 3650 | |
| 3651 | return 1; |
| 3652 | } |
| 3653 | |
| 3654 | |
| 3655 | int ascii2hexstr(const char *str, char *hex) |
| 3656 | { |
| 3657 | int i, length; |
| 3658 | |
| 3659 | length = strlen(str); |
| 3660 | |
| 3661 | for (i = 0; i < length; i++) |
| 3662 | snprintf(hex + i * 2, 3, "%X", str[i]); |
| 3663 | |
| 3664 | hex[length * 2] = '\0'; |
| 3665 | return 1; |
| 3666 | } |
| 3667 | |
| 3668 | |
| 3669 | static int kill_process(struct sigma_dut *dut, char *proc_name, |
| 3670 | unsigned char is_proc_instance_one, int sig) |
| 3671 | { |
| 3672 | #ifdef __linux__ |
| 3673 | struct dirent *dp, *dp_in; |
| 3674 | const char *direc = "/proc/"; |
| 3675 | char buf[100]; |
| 3676 | DIR *dir = opendir(direc); |
| 3677 | DIR *dir_in; |
| 3678 | FILE *fp; |
| 3679 | char *pid, *temp; |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 3680 | char *saveptr; |
Pradeep Reddy Potteti | d068e64 | 2017-02-17 20:03:12 +0530 | [diff] [blame] | 3681 | int ret = -1; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3682 | |
| 3683 | if (dir == NULL) |
Pradeep Reddy Potteti | d068e64 | 2017-02-17 20:03:12 +0530 | [diff] [blame] | 3684 | return ret; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3685 | |
| 3686 | while ((dp = readdir(dir)) != NULL) { |
| 3687 | if (dp->d_type != DT_DIR) |
| 3688 | continue; |
| 3689 | |
| 3690 | snprintf(buf, sizeof(buf), "%s%s", direc, dp->d_name); |
| 3691 | dir_in = opendir(buf); |
| 3692 | if (dir_in == NULL) |
| 3693 | continue; |
| 3694 | dp_in = readdir(dir_in); |
| 3695 | closedir(dir_in); |
| 3696 | if (dp_in == NULL) |
| 3697 | continue; |
| 3698 | snprintf(buf, sizeof(buf), "%s%s/stat", direc, dp->d_name); |
| 3699 | fp = fopen(buf, "r"); |
| 3700 | if (fp == NULL) |
| 3701 | continue; |
| 3702 | if (fgets(buf, 100, fp) == NULL) |
| 3703 | buf[0] = '\0'; |
| 3704 | fclose(fp); |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 3705 | pid = strtok_r(buf, " ", &saveptr); |
| 3706 | temp = strtok_r(NULL, " ", &saveptr); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3707 | if (pid && temp && |
| 3708 | strncmp(temp, proc_name, strlen(proc_name)) == 0) { |
| 3709 | sigma_dut_print(dut, DUT_MSG_INFO, |
| 3710 | "killing %s process with PID %s", |
| 3711 | proc_name, pid); |
| 3712 | snprintf(buf, sizeof(buf), "kill -%d %d", sig, |
| 3713 | atoi(pid)); |
| 3714 | run_system(dut, buf); |
Pradeep Reddy Potteti | d068e64 | 2017-02-17 20:03:12 +0530 | [diff] [blame] | 3715 | ret = 0; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3716 | if (is_proc_instance_one) |
| 3717 | break; |
| 3718 | } |
| 3719 | } |
| 3720 | |
| 3721 | closedir(dir); |
| 3722 | |
Pradeep Reddy Potteti | d068e64 | 2017-02-17 20:03:12 +0530 | [diff] [blame] | 3723 | return ret; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3724 | #else /* __linux__ */ |
| 3725 | return -1; |
| 3726 | #endif /* __linux__ */ |
| 3727 | } |
| 3728 | |
| 3729 | |
| 3730 | static int run_ndc(struct sigma_dut *dut, char *buf) |
| 3731 | { |
| 3732 | sigma_dut_print(dut, DUT_MSG_INFO, "CMD NDC:: %s", buf); |
| 3733 | sleep(2); |
| 3734 | return run_system(dut, buf); |
| 3735 | } |
| 3736 | |
| 3737 | |
| 3738 | static int sigma_write_cfg(struct sigma_dut *dut, const char *pfile, |
| 3739 | const char *field, const char *value) |
| 3740 | { |
| 3741 | FILE *fcfg, *ftmp; |
| 3742 | char buf[MAX_CONF_LINE_LEN + 1]; |
| 3743 | int len, found = 0, res; |
| 3744 | |
| 3745 | /* Open the configuration file */ |
| 3746 | fcfg = fopen(pfile, "r"); |
| 3747 | if (!fcfg) { |
| 3748 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 3749 | "Failed to open hostapd conf file"); |
| 3750 | return -1; |
| 3751 | } |
| 3752 | |
| 3753 | snprintf(buf, sizeof(buf), "%s~", pfile); |
| 3754 | /* Open a temporary file */ |
| 3755 | ftmp = fopen(buf, "w+"); |
| 3756 | if (!ftmp) { |
| 3757 | fclose(fcfg); |
| 3758 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 3759 | "Failed to open temp buf"); |
| 3760 | return -1; |
| 3761 | } |
| 3762 | |
| 3763 | /* Read the values from the configuration file */ |
| 3764 | len = strlen(field); |
| 3765 | while (fgets(buf, MAX_CONF_LINE_LEN, fcfg)) { |
| 3766 | char *pline = buf; |
| 3767 | |
| 3768 | /* commented line */ |
| 3769 | if (buf[0] == '#') |
| 3770 | pline++; |
| 3771 | |
| 3772 | /* Identify the configuration parameter to be updated */ |
| 3773 | if (!found && strncmp(pline, field, len) == 0 && |
| 3774 | pline[len] == '=') { |
| 3775 | snprintf(buf, sizeof(buf), "%s=%s\n", field, value); |
| 3776 | found = 1; |
| 3777 | sigma_dut_print(dut, DUT_MSG_INFO, |
| 3778 | "Updated hostapd conf file"); |
| 3779 | } |
| 3780 | |
| 3781 | fprintf(ftmp, "%s", buf); |
| 3782 | } |
| 3783 | |
| 3784 | if (!found) { |
| 3785 | /* Configuration line not found */ |
| 3786 | /* Add the new line at the end of file */ |
| 3787 | fprintf(ftmp, "%s=%s\n", field, value); |
| 3788 | sigma_dut_print(dut, DUT_MSG_INFO, |
| 3789 | "Adding a new line in hostapd conf file"); |
| 3790 | } |
| 3791 | |
| 3792 | fclose(fcfg); |
| 3793 | fclose(ftmp); |
| 3794 | |
| 3795 | snprintf(buf, sizeof(buf), "%s~", pfile); |
| 3796 | |
| 3797 | /* Restore the updated configuration file */ |
| 3798 | res = rename(buf, pfile); |
| 3799 | |
| 3800 | /* Remove the temporary file. Ignore the return value */ |
| 3801 | unlink(buf); |
| 3802 | |
| 3803 | /* chmod is needed because open() may not set permissions properly |
| 3804 | * depending on the current umask */ |
| 3805 | if (chmod(pfile, 0660) < 0) { |
| 3806 | unlink(pfile); |
| 3807 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 3808 | "Error changing permissions"); |
| 3809 | return -1; |
| 3810 | } |
| 3811 | |
| 3812 | if (res < 0) { |
| 3813 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 3814 | "Error restoring conf file"); |
| 3815 | return -1; |
| 3816 | } |
| 3817 | |
| 3818 | return 0; |
| 3819 | } |
| 3820 | |
| 3821 | |
| 3822 | static int cmd_wcn_ap_config_commit(struct sigma_dut *dut, |
| 3823 | struct sigma_conn *conn, |
| 3824 | struct sigma_cmd *cmd) |
| 3825 | { |
| 3826 | char buf[100]; |
| 3827 | struct stat s; |
| 3828 | int num_tries = 0, ret; |
| 3829 | |
Pradeep Reddy Potteti | d068e64 | 2017-02-17 20:03:12 +0530 | [diff] [blame] | 3830 | if (kill_process(dut, "(netd)", 1, SIGKILL) == 0 || |
| 3831 | system("killall netd") == 0) { |
| 3832 | /* Avoid Error: Error connecting (Connection refused) |
| 3833 | * Wait some time to allow netd to reinitialize. |
| 3834 | */ |
| 3835 | usleep(1500000); |
| 3836 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3837 | |
| 3838 | while (num_tries < 10) { |
| 3839 | ret = run_ndc(dut, "ndc softap stopap"); |
| 3840 | num_tries++; |
| 3841 | if (WIFEXITED(ret)) |
| 3842 | ret = WEXITSTATUS(ret); |
| 3843 | /* On success, NDC exits with 0 */ |
| 3844 | if (ret == 0) |
| 3845 | break; |
| 3846 | sigma_dut_print(dut, DUT_MSG_INFO, |
| 3847 | "Try No. %d: ndc softap stopap failed, exit code %d", |
| 3848 | num_tries, ret); |
| 3849 | } |
| 3850 | |
| 3851 | if (ret != 0) |
| 3852 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 3853 | "ndc softap stopap command failed for 10 times - giving up"); |
| 3854 | |
| 3855 | #ifdef ANDROID |
| 3856 | /* Unload/Load driver to cleanup the state of the driver */ |
Ajit Vaishya | 14d1f9a | 2017-09-04 23:24:25 +0530 | [diff] [blame] | 3857 | system("rmmod -f wlan"); |
| 3858 | usleep(500000); |
| 3859 | system("insmod /system/lib/modules/wlan.ko"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3860 | #else /* ANDROID */ |
| 3861 | run_ndc(dut, "ndc softap qccmd set enable_softap=0"); |
| 3862 | run_ndc(dut, "ndc softap qccmd set enable_softap=1"); |
| 3863 | #endif /* ANDROID */ |
| 3864 | |
| 3865 | switch (dut->ap_mode) { |
| 3866 | case AP_11g: |
| 3867 | run_ndc(dut, "ndc softap qccmd set hw_mode=g-only"); |
| 3868 | break; |
| 3869 | case AP_11b: |
| 3870 | run_ndc(dut, "ndc softap qccmd set hw_mode=b-only"); |
| 3871 | break; |
| 3872 | case AP_11ng: |
| 3873 | run_ndc(dut, "ndc softap qccmd set hw_mode=n"); |
| 3874 | break; |
| 3875 | case AP_11a: |
| 3876 | run_ndc(dut, "ndc softap qccmd set hw_mode=a-only"); |
| 3877 | break; |
| 3878 | case AP_11na: |
| 3879 | run_ndc(dut, "ndc softap qccmd set hw_mode=n"); |
| 3880 | break; |
| 3881 | case AP_11ac: |
| 3882 | run_ndc(dut, "ndc softap qccmd set hw_mode=ac"); |
| 3883 | break; |
| 3884 | default: |
| 3885 | break; |
| 3886 | } |
| 3887 | |
| 3888 | snprintf(buf, sizeof(buf), "ndc softap qccmd set channel=%d", |
| 3889 | dut->ap_channel); |
| 3890 | run_ndc(dut, buf); |
| 3891 | |
| 3892 | /* |
| 3893 | * ndc doesn't support double quotes as SSID string, so re-write |
| 3894 | * hostapd configuration file to update SSID. |
| 3895 | */ |
| 3896 | if (dut->ap_ssid[0] != '\0') |
| 3897 | sigma_write_cfg(dut, ANDROID_CONFIG_FILE, "ssid", dut->ap_ssid); |
| 3898 | |
| 3899 | switch (dut->ap_key_mgmt) { |
| 3900 | case AP_OPEN: |
| 3901 | if (dut->ap_cipher == AP_WEP) { |
| 3902 | run_ndc(dut, "ndc softap qccmd set security_mode=1"); |
| 3903 | snprintf(buf, sizeof(buf), |
| 3904 | "ndc softap qccmd set wep_key0=%s", |
| 3905 | dut->ap_wepkey); |
| 3906 | run_ndc(dut, buf); |
| 3907 | } else { |
| 3908 | run_ndc(dut, "ndc softap qccmd set security_mode=0"); |
| 3909 | } |
| 3910 | break; |
| 3911 | case AP_WPA2_PSK: |
| 3912 | case AP_WPA2_PSK_MIXED: |
| 3913 | case AP_WPA_PSK: |
| 3914 | if (dut->ap_key_mgmt == AP_WPA2_PSK) |
| 3915 | run_ndc(dut, "ndc softap qccmd set security_mode=3"); |
| 3916 | else if (dut->ap_key_mgmt == AP_WPA2_PSK_MIXED) |
| 3917 | run_ndc(dut, "ndc softap qccmd set security_mode=4"); |
| 3918 | else |
| 3919 | run_ndc(dut, "ndc softap qccmd set security_mode=2"); |
| 3920 | |
| 3921 | /* |
| 3922 | * ndc doesn't support some special characters as passphrase, |
| 3923 | * so re-write hostapd configuration file to update Passphrase. |
| 3924 | */ |
| 3925 | if (dut->ap_passphrase[0] != '\0') |
| 3926 | sigma_write_cfg(dut, ANDROID_CONFIG_FILE, |
| 3927 | "wpa_passphrase", dut->ap_passphrase); |
| 3928 | |
| 3929 | if (dut->ap_cipher == AP_CCMP_TKIP) |
| 3930 | run_ndc(dut, "ndc softap qccmd set wpa_pairwise=" |
| 3931 | "TKIP CCMP"); |
| 3932 | else if (dut->ap_cipher == AP_TKIP) |
| 3933 | run_ndc(dut, "ndc softap qccmd set wpa_pairwise=" |
| 3934 | "TKIP"); |
| 3935 | else |
| 3936 | run_ndc(dut, "ndc softap qccmd set wpa_pairwise=" |
| 3937 | "CCMP &"); |
| 3938 | break; |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 3939 | case AP_WPA2_SAE: |
| 3940 | case AP_WPA2_PSK_SAE: |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3941 | case AP_WPA2_EAP: |
| 3942 | case AP_WPA2_EAP_MIXED: |
| 3943 | case AP_WPA_EAP: |
Jouni Malinen | ad395a2 | 2017-09-01 21:13:46 +0300 | [diff] [blame] | 3944 | case AP_SUITEB: |
Jouni Malinen | 147b3c3 | 2017-10-09 16:51:54 +0300 | [diff] [blame] | 3945 | case AP_WPA2_OWE: |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3946 | /* Not supported */ |
| 3947 | break; |
| 3948 | } |
| 3949 | |
| 3950 | switch (dut->ap_pmf) { |
| 3951 | case AP_PMF_DISABLED: |
| 3952 | run_ndc(dut, "ndc softap qccmd set ieee80211w=0"); |
| 3953 | break; |
| 3954 | case AP_PMF_OPTIONAL: |
| 3955 | run_ndc(dut, "ndc softap qccmd set ieee80211w=1"); |
| 3956 | if (dut->ap_add_sha256) |
| 3957 | run_ndc(dut, "ndc softap qccmd set wpa_key_mgmt=WPA-PSK WPA-PSK-SHA256"); |
| 3958 | else |
| 3959 | run_ndc(dut, "ndc softap qccmd set wpa_key_mgmt=WPA-PSK"); |
| 3960 | break; |
| 3961 | case AP_PMF_REQUIRED: |
| 3962 | run_ndc(dut, "ndc softap qccmd set ieee80211w=2"); |
| 3963 | run_ndc(dut, "ndc softap qccmd set wpa_key_mgmt=WPA-PSK-SHA256"); |
| 3964 | break; |
| 3965 | } |
| 3966 | |
| 3967 | if (dut->ap_countrycode[0]) { |
| 3968 | snprintf(buf, sizeof(buf), |
| 3969 | "ndc softap qccmd set country_code=%s", |
| 3970 | dut->ap_countrycode); |
| 3971 | run_ndc(dut, buf); |
| 3972 | } |
| 3973 | |
Pradeep Reddy POTTETI | fba27db | 2015-11-20 16:42:22 +0530 | [diff] [blame] | 3974 | if (dut->ap_regulatory_mode == AP_80211D_MODE_ENABLED) |
| 3975 | run_ndc(dut, "ndc softap qccmd set ieee80211d=1"); |
| 3976 | |
| 3977 | if (dut->ap_dfs_mode == AP_DFS_MODE_ENABLED) |
| 3978 | run_ndc(dut, "ndc softap qccmd set ieee80211h=1"); |
| 3979 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3980 | run_ndc(dut, "ndc softap startap"); |
| 3981 | |
| 3982 | snprintf(buf, sizeof(buf), "%s%s", sigma_wpas_ctrl, sigma_main_ifname); |
| 3983 | num_tries = 0; |
| 3984 | while (num_tries < 10 && (ret = stat(buf, &s) != 0)) { |
| 3985 | run_ndc(dut, "ndc softap stopap"); |
| 3986 | run_ndc(dut, "ndc softap startap"); |
| 3987 | num_tries++; |
| 3988 | } |
| 3989 | |
| 3990 | if (num_tries == 10) { |
| 3991 | sigma_dut_print(dut, DUT_MSG_INFO, "Tried 10 times with ctrl " |
| 3992 | "iface %s :: reboot the APDUT", buf); |
| 3993 | return ret; |
| 3994 | } |
| 3995 | |
| 3996 | sigma_dut_print(dut, DUT_MSG_INFO, "setting ip addr %s mask %s", |
| 3997 | ap_inet_addr, ap_inet_mask); |
| 3998 | snprintf(buf, sizeof(buf), "ifconfig %s %s netmask %s up", |
| 3999 | sigma_main_ifname, ap_inet_addr, ap_inet_mask); |
| 4000 | if (system(buf) != 0) { |
| 4001 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4002 | "Failed to intialize the interface"); |
| 4003 | return -1; |
| 4004 | } |
| 4005 | |
| 4006 | return 1; |
| 4007 | } |
| 4008 | |
| 4009 | |
| 4010 | static int append_hostapd_conf_hs2(struct sigma_dut *dut, FILE *f) |
| 4011 | { |
| 4012 | fprintf(f, "hs20=1\nhs20_deauth_req_timeout=3\n" |
| 4013 | "disable_dgaf=%d\n", dut->ap_dgaf_disable); |
| 4014 | |
| 4015 | if (dut->ap_oper_name) { |
| 4016 | fprintf(f, "hs20_oper_friendly_name=eng:Wi-Fi Alliance\n"); |
| 4017 | fprintf(f, "hs20_oper_friendly_name=chi:Wi-Fi\xe8\x81\x94\xe7\x9b\x9f\n"); |
| 4018 | } |
| 4019 | |
| 4020 | if (dut->ap_wan_metrics == 1) |
| 4021 | fprintf(f, "hs20_wan_metrics=01:2500:384:0:0:10\n"); |
| 4022 | else if (dut->ap_wan_metrics == 2) |
| 4023 | fprintf(f, "hs20_wan_metrics=01:1500:384:20:20:10\n"); |
| 4024 | else if (dut->ap_wan_metrics == 3) |
| 4025 | fprintf(f, "hs20_wan_metrics=01:2000:1000:20:20:10\n"); |
| 4026 | else if (dut->ap_wan_metrics == 4) |
| 4027 | fprintf(f, "hs20_wan_metrics=01:8000:1000:20:20:10\n"); |
| 4028 | else if (dut->ap_wan_metrics == 5) |
| 4029 | fprintf(f, "hs20_wan_metrics=01:9000:5000:20:20:10\n"); |
| 4030 | |
| 4031 | if (dut->ap_conn_capab == 1) { |
| 4032 | fprintf(f, "hs20_conn_capab=1:0:0\n"); |
| 4033 | fprintf(f, "hs20_conn_capab=6:20:1\n"); |
| 4034 | fprintf(f, "hs20_conn_capab=6:22:0\n"); |
| 4035 | fprintf(f, "hs20_conn_capab=6:80:1\n"); |
| 4036 | fprintf(f, "hs20_conn_capab=6:443:1\n"); |
| 4037 | fprintf(f, "hs20_conn_capab=6:1723:0\n"); |
| 4038 | fprintf(f, "hs20_conn_capab=6:5060:0\n"); |
| 4039 | fprintf(f, "hs20_conn_capab=17:500:1\n"); |
| 4040 | fprintf(f, "hs20_conn_capab=17:5060:0\n"); |
| 4041 | fprintf(f, "hs20_conn_capab=17:4500:1\n"); |
| 4042 | fprintf(f, "hs20_conn_capab=50:0:1\n"); |
| 4043 | } else if (dut->ap_conn_capab == 2) { |
| 4044 | fprintf(f, "hs20_conn_capab=6:80:1\n"); |
| 4045 | fprintf(f, "hs20_conn_capab=6:443:1\n"); |
| 4046 | fprintf(f, "hs20_conn_capab=17:5060:1\n"); |
| 4047 | fprintf(f, "hs20_conn_capab=6:5060:1\n"); |
| 4048 | } else if (dut->ap_conn_capab == 3) { |
| 4049 | fprintf(f, "hs20_conn_capab=6:80:1\n"); |
| 4050 | fprintf(f, "hs20_conn_capab=6:443:1\n"); |
| 4051 | } else if (dut->ap_conn_capab == 4) { |
| 4052 | fprintf(f, "hs20_conn_capab=6:80:1\n"); |
| 4053 | fprintf(f, "hs20_conn_capab=6:443:1\n"); |
| 4054 | fprintf(f, "hs20_conn_capab=6:5060:1\n"); |
| 4055 | fprintf(f, "hs20_conn_capab=17:5060:1\n"); |
| 4056 | } |
| 4057 | |
| 4058 | if (dut->ap_oper_class == 1) |
| 4059 | fprintf(f, "hs20_operating_class=51\n"); |
| 4060 | else if (dut->ap_oper_class == 2) |
| 4061 | fprintf(f, "hs20_operating_class=73\n"); |
| 4062 | else if (dut->ap_oper_class == 3) |
| 4063 | fprintf(f, "hs20_operating_class=5173\n"); |
| 4064 | |
| 4065 | if (dut->ap_osu_provider_list) { |
| 4066 | char *osu_friendly_name = NULL; |
| 4067 | char *osu_icon = NULL; |
| 4068 | char *osu_ssid = NULL; |
| 4069 | char *osu_nai = NULL; |
| 4070 | char *osu_service_desc = NULL; |
| 4071 | char *hs20_icon_filename = NULL; |
| 4072 | char hs20_icon[150]; |
| 4073 | int osu_method; |
| 4074 | |
| 4075 | hs20_icon_filename = "icon_red_zxx.png"; |
| 4076 | if (dut->ap_osu_icon_tag == 2) |
| 4077 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 4078 | snprintf(hs20_icon, sizeof(hs20_icon), |
| 4079 | "128:61:zxx:image/png:icon_red_zxx.png:/etc/ath/%s", |
| 4080 | hs20_icon_filename); |
| 4081 | osu_icon = "icon_red_zxx.png"; |
| 4082 | osu_ssid = "OSU"; |
| 4083 | osu_friendly_name = "kor:SP 빨강 테스트 전용"; |
| 4084 | osu_service_desc = "kor:테스트 목적으로 무료 서비스"; |
| 4085 | osu_method = (dut->ap_osu_method[0] == 0xFF) ? 1 : dut->ap_osu_method[0]; |
| 4086 | |
| 4087 | if (strlen(dut->ap_osu_server_uri[0])) |
| 4088 | fprintf(f, "osu_server_uri=%s\n", dut->ap_osu_server_uri[0]); |
| 4089 | else |
| 4090 | fprintf(f, "osu_server_uri=https://osu-server.r2-testbed.wi-fi.org/\n"); |
| 4091 | |
| 4092 | switch (dut->ap_osu_provider_list) { |
| 4093 | case 1: |
| 4094 | case 101: |
| 4095 | fprintf(f, "osu_friendly_name=eng:SP Red Test Only\n"); |
| 4096 | fprintf(f, "osu_service_desc=eng:Free service for test purpose\n"); |
| 4097 | hs20_icon_filename = "icon_red_eng.png"; |
| 4098 | if (dut->ap_osu_icon_tag == 2) |
| 4099 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 4100 | fprintf(f, "hs20_icon=160:76:eng:image/png:icon_red_eng.png:/etc/ath/%s\n", |
| 4101 | hs20_icon_filename); |
| 4102 | fprintf(f, "osu_icon=icon_red_eng.png\n"); |
| 4103 | break; |
| 4104 | case 2: |
| 4105 | case 102: |
| 4106 | fprintf(f, "osu_friendly_name=eng:Wireless Broadband Alliance\n"); |
| 4107 | fprintf(f, "osu_service_desc=eng:Free service for test purpose\n"); |
| 4108 | hs20_icon_filename = "icon_orange_zxx.png"; |
| 4109 | if (dut->ap_osu_icon_tag == 2) |
| 4110 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 4111 | snprintf(hs20_icon, sizeof(hs20_icon), |
| 4112 | "128:61:zxx:image/png:icon_orange_zxx.png:/etc/ath/%s", |
| 4113 | hs20_icon_filename); |
| 4114 | osu_icon = "icon_orange_zxx.png"; |
| 4115 | osu_friendly_name = "kor:와이어리스 브로드밴드 얼라이언스"; |
| 4116 | break; |
| 4117 | case 3: |
| 4118 | case 103: |
| 4119 | osu_friendly_name = "spa:SP Red Test Only"; |
| 4120 | osu_service_desc = "spa:Free service for test purpose"; |
| 4121 | break; |
| 4122 | case 4: |
| 4123 | case 104: |
| 4124 | fprintf(f, "osu_friendly_name=eng:SP Orange Test Only\n"); |
| 4125 | fprintf(f, "osu_service_desc=eng:Free service for test purpose\n"); |
| 4126 | hs20_icon_filename = "icon_orange_eng.png"; |
| 4127 | if (dut->ap_osu_icon_tag == 2) |
| 4128 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 4129 | fprintf(f, "hs20_icon=160:76:eng:image/png:icon_orange_eng.png:/etc/ath/%s\n", |
| 4130 | hs20_icon_filename); |
| 4131 | fprintf(f, "osu_icon=icon_orange_eng.png\n"); |
| 4132 | osu_friendly_name = "kor:SP 오렌지 테스트 전용"; |
| 4133 | |
| 4134 | hs20_icon_filename = "icon_orange_zxx.png"; |
| 4135 | if (dut->ap_osu_icon_tag == 2) |
| 4136 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 4137 | snprintf(hs20_icon, sizeof(hs20_icon), |
| 4138 | "128:61:zxx:image/png:icon_orange_zxx.png:/etc/ath/%s", |
| 4139 | hs20_icon_filename); |
| 4140 | osu_icon = "icon_orange_zxx.png"; |
| 4141 | break; |
| 4142 | case 5: |
| 4143 | case 105: |
| 4144 | fprintf(f, "osu_friendly_name=eng:SP Orange Test Only\n"); |
| 4145 | fprintf(f, "osu_service_desc=eng:Free service for test purpose\n"); |
| 4146 | osu_friendly_name = "kor:SP 오렌지 테스트 전용"; |
| 4147 | hs20_icon_filename = "icon_orange_zxx.png"; |
| 4148 | if (dut->ap_osu_icon_tag == 2) |
| 4149 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 4150 | snprintf(hs20_icon, sizeof(hs20_icon), |
| 4151 | "128:61:zxx:image/png:icon_orange_zxx.png:/etc/ath/%s", |
| 4152 | hs20_icon_filename); |
| 4153 | osu_icon = "icon_orange_zxx.png"; |
| 4154 | break; |
| 4155 | case 6: |
| 4156 | case 106: |
| 4157 | fprintf(f, "osu_friendly_name=eng:SP Green Test Only\n"); |
| 4158 | fprintf(f, "osu_friendly_name=kor:SP 초록 테스트 전용\n"); |
| 4159 | hs20_icon_filename = "icon_green_zxx.png"; |
| 4160 | if (dut->ap_osu_icon_tag == 2) |
| 4161 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 4162 | fprintf(f, "hs20_icon=128:61:zxx:image/png:icon_green_zxx.png:/etc/ath/%s\n", |
| 4163 | hs20_icon_filename); |
| 4164 | fprintf(f, "osu_icon=icon_green_zxx.png\n"); |
| 4165 | osu_method = (dut->ap_osu_method[0] == 0xFF) ? 0 : dut->ap_osu_method[0]; |
| 4166 | fprintf(f, "osu_method_list=%d\n", osu_method); |
| 4167 | |
| 4168 | if (strlen(dut->ap_osu_server_uri[1])) |
| 4169 | fprintf(f, "osu_server_uri=%s\n", dut->ap_osu_server_uri[1]); |
| 4170 | else |
| 4171 | fprintf(f, "osu_server_uri=https://osu-server.r2-testbed.wi-fi.org/\n"); |
| 4172 | fprintf(f, "osu_friendly_name=eng:SP Orange Test Only\n"); |
| 4173 | hs20_icon_filename = "icon_orange_zxx.png"; |
| 4174 | if (dut->ap_osu_icon_tag == 2) |
| 4175 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 4176 | snprintf(hs20_icon, sizeof(hs20_icon), |
| 4177 | "128:61:zxx:image/png:icon_orange_zxx.png:/etc/ath/%s", |
| 4178 | hs20_icon_filename); |
| 4179 | osu_icon = "icon_orange_zxx.png"; |
| 4180 | osu_friendly_name = "kor:SP 오렌지 테스트 전용"; |
| 4181 | osu_method = (dut->ap_osu_method[1] == 0xFF) ? 0 : dut->ap_osu_method[1]; |
| 4182 | osu_service_desc = NULL; |
| 4183 | break; |
| 4184 | case 7: |
| 4185 | case 107: |
| 4186 | fprintf(f, "osu_friendly_name=eng:SP Green Test Only\n"); |
| 4187 | fprintf(f, "osu_service_desc=eng:Free service for test purpose\n"); |
| 4188 | hs20_icon_filename = "icon_green_eng.png"; |
| 4189 | if (dut->ap_osu_icon_tag == 2) |
| 4190 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 4191 | fprintf(f, "hs20_icon=160:76:eng:image/png:icon_green_eng.png:/etc/ath/%s\n", |
| 4192 | hs20_icon_filename); |
| 4193 | fprintf(f, "osu_icon=icon_green_eng.png\n"); |
| 4194 | osu_friendly_name = "kor:SP 초록 테스트 전용"; |
| 4195 | |
| 4196 | hs20_icon_filename = "icon_green_zxx.png"; |
| 4197 | if (dut->ap_osu_icon_tag == 2) |
| 4198 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 4199 | snprintf(hs20_icon, sizeof(hs20_icon), |
| 4200 | "128:61:zxx:image/png:icon_green_zxx.png:/etc/ath/%s", |
| 4201 | hs20_icon_filename); |
| 4202 | osu_icon = "icon_green_zxx.png"; |
| 4203 | break; |
| 4204 | case 8: |
| 4205 | case 108: |
| 4206 | fprintf(f, "osu_friendly_name=eng:SP Red Test Only\n"); |
| 4207 | fprintf(f, "osu_service_desc=eng:Free service for test purpose\n"); |
| 4208 | osu_ssid = "OSU-Encrypted"; |
| 4209 | osu_nai = "anonymous@hotspot.net"; |
| 4210 | break; |
| 4211 | case 9: |
| 4212 | case 109: |
| 4213 | osu_ssid = "OSU-OSEN"; |
| 4214 | osu_nai = "test-anonymous@wi-fi.org"; |
| 4215 | osu_friendly_name = "eng:SP Orange Test Only"; |
| 4216 | hs20_icon_filename = "icon_orange_zxx.png"; |
| 4217 | if (dut->ap_osu_icon_tag == 2) |
| 4218 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 4219 | snprintf(hs20_icon, sizeof(hs20_icon), |
| 4220 | "128:61:zxx:image/png:icon_orange_zxx.png:/etc/ath/%s", |
| 4221 | hs20_icon_filename); |
| 4222 | osu_icon = "icon_orange_zxx.png"; |
| 4223 | osu_method = (dut->ap_osu_method[0] == 0xFF) ? 1 : dut->ap_osu_method[0]; |
| 4224 | osu_service_desc = NULL; |
| 4225 | break; |
| 4226 | default: |
| 4227 | break; |
| 4228 | } |
| 4229 | |
| 4230 | if (strlen(dut->ap_osu_ssid)) { |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 4231 | if (strcmp(dut->ap_tag_ssid[0], dut->ap_osu_ssid) && |
| 4232 | strcmp(dut->ap_tag_ssid[0], osu_ssid)) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4233 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4234 | "OSU_SSID and " |
| 4235 | "WLAN_TAG2 SSID differ"); |
| 4236 | return -2; |
| 4237 | } |
| 4238 | fprintf(f, "osu_ssid=\"%s\"\n", dut->ap_osu_ssid); |
| 4239 | } else |
| 4240 | fprintf(f, "osu_ssid=\"%s\"\n", osu_ssid); |
| 4241 | |
| 4242 | |
| 4243 | if (osu_friendly_name) |
| 4244 | fprintf(f, "osu_friendly_name=%s\n", osu_friendly_name); |
| 4245 | |
| 4246 | if (osu_service_desc) |
| 4247 | fprintf(f, "osu_service_desc=%s\n", osu_service_desc); |
| 4248 | |
| 4249 | if (osu_nai) |
| 4250 | fprintf(f, "osu_nai=%s\n", osu_nai); |
| 4251 | |
| 4252 | fprintf(f, "hs20_icon=%s\n", hs20_icon); |
| 4253 | |
| 4254 | if (osu_icon) |
| 4255 | fprintf(f, "osu_icon=%s\n", osu_icon); |
| 4256 | |
| 4257 | if (dut->ap_osu_provider_list > 100) |
| 4258 | fprintf(f, "osu_method_list=0\n"); |
| 4259 | else |
| 4260 | fprintf(f, "osu_method_list=%d\n", osu_method); |
| 4261 | } |
| 4262 | |
| 4263 | return 0; |
| 4264 | } |
| 4265 | |
| 4266 | |
| 4267 | static void write_ap_roaming_cons(FILE *f, const char *list) |
| 4268 | { |
| 4269 | char *buf, *pos, *end; |
| 4270 | |
| 4271 | if (list == NULL || list[0] == '\0') |
| 4272 | return; |
| 4273 | |
| 4274 | buf = strdup(list); |
| 4275 | if (buf == NULL) |
| 4276 | return; |
| 4277 | |
| 4278 | pos = buf; |
| 4279 | while (pos && *pos) { |
| 4280 | end = strchr(pos, ';'); |
| 4281 | if (end) |
| 4282 | *end++ = '\0'; |
| 4283 | fprintf(f, "roaming_consortium=%s\n", pos); |
| 4284 | pos = end; |
| 4285 | } |
| 4286 | |
| 4287 | free(buf); |
| 4288 | } |
| 4289 | |
| 4290 | |
| 4291 | static int append_hostapd_conf_interworking(struct sigma_dut *dut, FILE *f) |
| 4292 | { |
| 4293 | int i; |
| 4294 | char buf[100], *temp; |
| 4295 | |
| 4296 | if (dut->ap_gas_cb_delay > 0) |
| 4297 | fprintf(f, "gas_comeback_delay=%d\n", |
| 4298 | dut->ap_gas_cb_delay); |
| 4299 | |
| 4300 | fprintf(f, "interworking=1\n" |
| 4301 | "access_network_type=%d\n" |
| 4302 | "internet=%d\n" |
| 4303 | "asra=0\n" |
| 4304 | "esr=0\n" |
| 4305 | "uesa=0\n" |
| 4306 | "venue_group=%d\n" |
| 4307 | "venue_type=%d\n", |
| 4308 | dut->ap_access_net_type, |
| 4309 | dut->ap_internet, |
| 4310 | dut->ap_venue_group, |
| 4311 | dut->ap_venue_type); |
| 4312 | if (dut->ap_hessid[0]) |
| 4313 | fprintf(f, "hessid=%s\n", dut->ap_hessid); |
| 4314 | |
| 4315 | write_ap_roaming_cons(f, dut->ap_roaming_cons); |
| 4316 | |
| 4317 | if (dut->ap_venue_name) { |
| 4318 | fprintf(f, "venue_name=P\"eng:Wi-Fi Alliance\\n2989 Copper Road\\nSanta Clara, CA 95051, USA\"\n"); |
| 4319 | fprintf(f, "venue_name=%s\n", ANQP_VENUE_NAME_1_CHI); |
| 4320 | } |
| 4321 | |
| 4322 | if (dut->ap_net_auth_type == 1) |
| 4323 | fprintf(f, "network_auth_type=00https://tandc-server.wi-fi.org\n"); |
| 4324 | else if (dut->ap_net_auth_type == 2) |
| 4325 | fprintf(f, "network_auth_type=01\n"); |
| 4326 | |
| 4327 | if (dut->ap_nai_realm_list == 1) { |
| 4328 | fprintf(f, "nai_realm=0,mail.example.com;cisco.com;wi-fi.org,21[2:4][5:7]\n"); |
| 4329 | fprintf(f, "nai_realm=0,wi-fi.org;example.com,13[5:6]\n"); |
| 4330 | } else if (dut->ap_nai_realm_list == 2) { |
| 4331 | fprintf(f, "nai_realm=0,wi-fi.org,21[2:4][5:7]\n"); |
| 4332 | } else if (dut->ap_nai_realm_list == 3) { |
| 4333 | fprintf(f, "nai_realm=0,cisco.com;wi-fi.org,21[2:4][5:7]\n"); |
| 4334 | fprintf(f, "nai_realm=0,wi-fi.org;example.com,13[5:6]\n"); |
| 4335 | } else if (dut->ap_nai_realm_list == 4) { |
| 4336 | fprintf(f, "nai_realm=0,mail.example.com,21[2:4][5:7],13[5:6]\n"); |
| 4337 | } else if (dut->ap_nai_realm_list == 5) { |
| 4338 | fprintf(f, "nai_realm=0,wi-fi.org;ruckuswireless.com,21[2:4][5:7]\n"); |
| 4339 | } else if (dut->ap_nai_realm_list == 6) { |
| 4340 | fprintf(f, "nai_realm=0,wi-fi.org;mail.example.com,21[2:4][5:7]\n"); |
| 4341 | } else if (dut->ap_nai_realm_list == 7) { |
| 4342 | fprintf(f, "nai_realm=0,wi-fi.org,13[5:6]\n"); |
| 4343 | fprintf(f, "nai_realm=0,wi-fi.org,21[2:4][5:7]\n"); |
| 4344 | } |
| 4345 | |
| 4346 | if (dut->ap_domain_name_list[0]) { |
| 4347 | fprintf(f, "domain_name=%s\n", |
| 4348 | dut->ap_domain_name_list); |
| 4349 | } |
| 4350 | |
| 4351 | if (dut->ap_ip_addr_type_avail == 1) { |
| 4352 | fprintf(f, "ipaddr_type_availability=0c\n"); |
| 4353 | } |
| 4354 | |
| 4355 | temp = buf; |
| 4356 | for (i = 0; dut->ap_plmn_mcc[i][0] && dut->ap_plmn_mnc[i][0]; |
| 4357 | i++) { |
| 4358 | if (i) |
| 4359 | *temp++ = ';'; |
| 4360 | |
| 4361 | snprintf(temp, |
| 4362 | sizeof(dut->ap_plmn_mcc[i]) + |
| 4363 | sizeof(dut->ap_plmn_mnc[i]) + 1, |
| 4364 | "%s,%s", |
| 4365 | dut->ap_plmn_mcc[i], |
| 4366 | dut->ap_plmn_mnc[i]); |
| 4367 | |
| 4368 | temp += strlen(dut->ap_plmn_mcc[i]) + |
| 4369 | strlen(dut->ap_plmn_mnc[i]) + 1; |
| 4370 | } |
| 4371 | if (i) |
| 4372 | fprintf(f, "anqp_3gpp_cell_net=%s\n", buf); |
| 4373 | |
| 4374 | if (dut->ap_qos_map_set == 1) |
| 4375 | fprintf(f, "qos_map_set=%s\n", QOS_MAP_SET_1); |
| 4376 | else if (dut->ap_qos_map_set == 2) |
| 4377 | fprintf(f, "qos_map_set=%s\n", QOS_MAP_SET_2); |
| 4378 | |
| 4379 | return 0; |
| 4380 | } |
| 4381 | |
| 4382 | |
| 4383 | static int ath_ap_append_hostapd_conf(struct sigma_dut *dut) |
| 4384 | { |
| 4385 | FILE *f; |
| 4386 | |
| 4387 | if (kill_process(dut, "(hostapd)", 1, SIGTERM) == 0 || |
| 4388 | system("killall hostapd") == 0) { |
| 4389 | int i; |
| 4390 | |
| 4391 | /* Wait some time to allow hostapd to complete cleanup before |
| 4392 | * starting a new process */ |
| 4393 | for (i = 0; i < 10; i++) { |
| 4394 | usleep(500000); |
| 4395 | if (system("pidof hostapd") != 0) |
| 4396 | break; |
| 4397 | } |
| 4398 | } |
| 4399 | |
| 4400 | f = fopen("/tmp/secath0", "a"); |
| 4401 | if (f == NULL) |
| 4402 | return -2; |
| 4403 | |
| 4404 | if (dut->ap_hs2 && append_hostapd_conf_hs2(dut, f)) { |
| 4405 | fclose(f); |
| 4406 | return -2; |
| 4407 | } |
| 4408 | |
| 4409 | if (dut->ap_interworking && append_hostapd_conf_interworking(dut, f)) { |
| 4410 | fclose(f); |
| 4411 | return -2; |
| 4412 | } |
| 4413 | |
| 4414 | fflush(f); |
| 4415 | fclose(f); |
| 4416 | return ath_ap_start_hostapd(dut); |
| 4417 | } |
| 4418 | |
| 4419 | |
| 4420 | static int ath_ap_start_hostapd(struct sigma_dut *dut) |
| 4421 | { |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 4422 | if (dut->ap_tag_key_mgmt[0] == AP2_OSEN) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4423 | run_system(dut, "hostapd -B /tmp/secath0 /tmp/secath1 -e /etc/wpa2/entropy"); |
| 4424 | else |
| 4425 | run_system(dut, "hostapd -B /tmp/secath0 -e /etc/wpa2/entropy"); |
| 4426 | |
| 4427 | return 0; |
| 4428 | } |
| 4429 | |
| 4430 | |
| 4431 | #define LE16(a) ((((a) & 0xff) << 8) | (((a) >> 8) & 0xff)) |
| 4432 | |
| 4433 | static int cmd_ath_ap_anqpserver_start(struct sigma_dut *dut) |
| 4434 | { |
| 4435 | FILE *f; |
| 4436 | int nai_realm = 0, domain_name = 0, oper_name = 0, venue_name = 0, |
| 4437 | wan_metrics = 0, conn_cap = 0, ipaddr_avail = 0, cell_net = 0; |
| 4438 | char buf[100]; |
| 4439 | int i; |
| 4440 | |
| 4441 | f = fopen("/root/anqpserver.conf", "w"); |
| 4442 | if (f == NULL) |
| 4443 | return -1; |
| 4444 | |
| 4445 | if (dut->ap_nai_realm_list == 1) { |
| 4446 | nai_realm = 1; |
| 4447 | 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"); |
| 4448 | } else if (dut->ap_nai_realm_list == 2) { |
| 4449 | nai_realm = 1; |
| 4450 | fprintf(f, "dyn_nai_home_realm=encoding=00realm=wi-fi.org;eap_method=0Dauth_id=05auth_val=06\n"); |
| 4451 | } else if (dut->ap_nai_realm_list == 3) { |
| 4452 | nai_realm = 1; |
| 4453 | 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"); |
| 4454 | } else if (dut->ap_nai_realm_list == 4) { |
| 4455 | nai_realm = 1; |
| 4456 | 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"); |
| 4457 | } else |
| 4458 | sigma_dut_print(dut, DUT_MSG_INFO, "not setting nai_realm"); |
| 4459 | |
| 4460 | if (dut->ap_domain_name_list[0]) { |
| 4461 | char *next, *start, *dnbuf, *dn1, *anqp_dn; |
| 4462 | int len, dn_len_max; |
| 4463 | dnbuf = strdup(dut->ap_domain_name_list); |
Pradeep Reddy POTTETI | 673d85c | 2016-07-26 19:08:07 +0530 | [diff] [blame] | 4464 | if (dnbuf == NULL) { |
| 4465 | fclose(f); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4466 | return 0; |
Pradeep Reddy POTTETI | 673d85c | 2016-07-26 19:08:07 +0530 | [diff] [blame] | 4467 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4468 | |
| 4469 | len = strlen(dnbuf); |
| 4470 | dn_len_max = 50 + len*2; |
| 4471 | anqp_dn = malloc(dn_len_max); |
| 4472 | if (anqp_dn == NULL) { |
| 4473 | free(dnbuf); |
Pradeep Reddy POTTETI | 673d85c | 2016-07-26 19:08:07 +0530 | [diff] [blame] | 4474 | fclose(f); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4475 | return -1; |
| 4476 | } |
| 4477 | start = dnbuf; |
| 4478 | dn1 = anqp_dn; |
| 4479 | while (start && *start) { |
| 4480 | char *hexstr; |
| 4481 | |
| 4482 | next = strchr(start, ','); |
| 4483 | if (next) |
| 4484 | *next++ = '\0'; |
| 4485 | |
| 4486 | len = strlen(start); |
vamsi krishna | 2e88130 | 2016-05-25 15:02:39 +0530 | [diff] [blame] | 4487 | hexstr = malloc(len * 2 + 1); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4488 | if (hexstr == NULL) { |
| 4489 | free(dnbuf); |
| 4490 | free(anqp_dn); |
Pradeep Reddy POTTETI | 673d85c | 2016-07-26 19:08:07 +0530 | [diff] [blame] | 4491 | fclose(f); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4492 | return -1; |
| 4493 | } |
| 4494 | ascii2hexstr(start, hexstr); |
| 4495 | snprintf(dn1, dn_len_max, "%02x%s", len, hexstr); |
| 4496 | free(hexstr); |
| 4497 | dn1 += 2 + len * 2; |
| 4498 | dn_len_max -= 2 + len * 2; |
| 4499 | start = next; |
| 4500 | } |
| 4501 | free(dnbuf); |
| 4502 | if (dut->ap_gas_cb_delay) { |
| 4503 | fprintf(f, "dyn_domain_name=0c01%04x%s", |
| 4504 | LE16((unsigned int) strlen(anqp_dn)), anqp_dn); |
| 4505 | domain_name = 1; |
| 4506 | } else |
| 4507 | fprintf(f, "domain_name=0c01%04x%s", |
| 4508 | LE16((unsigned int) strlen(anqp_dn)), anqp_dn); |
| 4509 | free(anqp_dn); |
| 4510 | } else |
| 4511 | sigma_dut_print(dut, DUT_MSG_INFO, "not setting domain_name"); |
| 4512 | |
| 4513 | sigma_dut_print(dut, DUT_MSG_INFO, "not setting roaming_consortium"); |
| 4514 | |
| 4515 | if (dut->ap_oper_name) { |
| 4516 | if (dut->ap_gas_cb_delay) { |
| 4517 | fprintf(f, "dyn_oper_friendly_name=" |
| 4518 | ANQP_HS20_OPERATOR_FRIENDLY_NAME_1 "\n"); |
| 4519 | oper_name = 1; |
| 4520 | } else |
| 4521 | fprintf(f, "oper_friendly_name=" |
| 4522 | ANQP_HS20_OPERATOR_FRIENDLY_NAME_1 "\n"); |
| 4523 | } else |
| 4524 | sigma_dut_print(dut, DUT_MSG_INFO, "not setting oper_name"); |
| 4525 | |
| 4526 | if (dut->ap_venue_name) { |
| 4527 | if (dut->ap_gas_cb_delay) { |
| 4528 | fprintf(f, "dyn_venue_name=" ANQP_VENUE_NAME_1 "\n"); |
| 4529 | venue_name = 1; |
| 4530 | } else |
| 4531 | fprintf(f, "venue_name=" ANQP_VENUE_NAME_1 "\n"); |
| 4532 | } else |
| 4533 | sigma_dut_print(dut, DUT_MSG_ERROR, "not setting venue_name"); |
| 4534 | |
| 4535 | if (dut->ap_wan_metrics) { |
| 4536 | if (dut->ap_gas_cb_delay) { |
| 4537 | fprintf(f, "dyn_wan_metrics=" ANQP_HS20_WAN_METRICS_1 "\n"); |
| 4538 | wan_metrics = 1; |
| 4539 | } else |
| 4540 | fprintf(f, "wan_metrics=" ANQP_HS20_WAN_METRICS_1 |
| 4541 | "\n"); |
| 4542 | } else |
| 4543 | sigma_dut_print(dut, DUT_MSG_ERROR, "not setting wan_metrics"); |
| 4544 | |
| 4545 | if (dut->ap_conn_capab) { |
| 4546 | if (dut->ap_gas_cb_delay) { |
| 4547 | fprintf(f, "dyn_conn_capability=" |
| 4548 | ANQP_HS20_CONNECTION_CAPABILITY_1 "\n"); |
| 4549 | conn_cap = 1; |
| 4550 | } else |
| 4551 | fprintf(f, "conn_capability=" |
| 4552 | ANQP_HS20_CONNECTION_CAPABILITY_1 "\n"); |
| 4553 | } else |
| 4554 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4555 | "not setting conn_capability"); |
| 4556 | |
| 4557 | if (dut->ap_ip_addr_type_avail) { |
| 4558 | if (dut->ap_gas_cb_delay) { |
| 4559 | fprintf(f, "dyn_ipaddr_type=" ANQP_IP_ADDR_TYPE_1 |
| 4560 | "\n"); |
| 4561 | ipaddr_avail = 1; |
| 4562 | } else |
| 4563 | fprintf(f, "ipaddr_type=" ANQP_IP_ADDR_TYPE_1 "\n"); |
| 4564 | } else |
| 4565 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4566 | "not setting ipaddr_type_avail"); |
| 4567 | |
| 4568 | for (i = 0; dut->ap_plmn_mcc[i][0] && dut->ap_plmn_mnc[i][0]; i++) { |
| 4569 | snprintf(buf + i * 6, sizeof(buf) - i * 6, "%c%c%c%c%c%c", |
| 4570 | dut->ap_plmn_mcc[i][1], |
| 4571 | dut->ap_plmn_mcc[i][0], |
| 4572 | dut->ap_plmn_mnc[i][2] == '\0' ? |
| 4573 | 'f' : dut->ap_plmn_mnc[i][2], |
| 4574 | dut->ap_plmn_mcc[i][2], |
| 4575 | dut->ap_plmn_mnc[i][1], |
| 4576 | dut->ap_plmn_mnc[i][0]); |
| 4577 | } |
| 4578 | if (i) { |
| 4579 | uint16_t ie_len = (i * 3) + 5; |
| 4580 | if (dut->ap_gas_cb_delay) { |
| 4581 | fprintf(f, "dyn_cell_net=0801"); |
| 4582 | cell_net = 1; |
| 4583 | } else |
| 4584 | fprintf(f, "cell_net=0801"); |
| 4585 | fprintf(f, "%04x", LE16(ie_len)); |
| 4586 | fprintf(f, "00"); /* version */ |
| 4587 | fprintf(f, "%02x", (i * 3) + 3); /* user data hdr length */ |
| 4588 | fprintf(f, "00"); /* plmn list */ |
| 4589 | fprintf(f, "%02x", (i * 3) + 1); /* length of plmn list */ |
| 4590 | fprintf(f, "%02x", i); /* number of plmns */ |
| 4591 | fprintf(f, "%s\n", buf); /* plmns */ |
| 4592 | } else |
| 4593 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4594 | "not setting 3gpp_cellular_network"); |
| 4595 | |
| 4596 | if (nai_realm || domain_name || oper_name || venue_name || |
| 4597 | wan_metrics || conn_cap || ipaddr_avail || cell_net) { |
| 4598 | fprintf(f, "anqp_attach="); |
| 4599 | if (venue_name) |
| 4600 | fprintf(f, "00000104%4.4x", dut->ap_gas_cb_delay); |
| 4601 | if (nai_realm) |
| 4602 | fprintf(f, "00000107%4.4x", dut->ap_gas_cb_delay); |
| 4603 | if (cell_net) |
| 4604 | fprintf(f, "00000108%4.4x", dut->ap_gas_cb_delay); |
| 4605 | if (domain_name) |
| 4606 | fprintf(f, "0000010c%4.4x", dut->ap_gas_cb_delay); |
| 4607 | if (oper_name) |
| 4608 | fprintf(f, "00010003%4.4x", dut->ap_gas_cb_delay); |
| 4609 | if (wan_metrics) |
| 4610 | fprintf(f, "00010004%4.4x", dut->ap_gas_cb_delay); |
| 4611 | if (conn_cap) |
| 4612 | fprintf(f, "00010005%4.4x", dut->ap_gas_cb_delay); |
| 4613 | fprintf(f, "00010006%4.4x", dut->ap_gas_cb_delay); |
| 4614 | fprintf(f, "\n"); |
| 4615 | } |
| 4616 | |
| 4617 | fclose(f); |
| 4618 | |
| 4619 | run_system(dut, "anqpserver -i ath0 &"); |
| 4620 | if (!dut->ap_anqpserver_on) |
| 4621 | run_system(dut, "killall anqpserver"); |
| 4622 | |
| 4623 | return 1; |
| 4624 | } |
| 4625 | |
| 4626 | |
| 4627 | static void cmd_ath_ap_radio_config(struct sigma_dut *dut) |
| 4628 | { |
| 4629 | char buf[100]; |
| 4630 | |
| 4631 | run_system(dut, "cfg -a AP_STARTMODE=standard"); |
| 4632 | |
| 4633 | if (sigma_radio_ifname[0] && |
| 4634 | strcmp(sigma_radio_ifname[0], "wifi1") == 0) { |
| 4635 | run_system(dut, "cfg -a AP_RADIO_ID=1"); |
| 4636 | switch (dut->ap_mode) { |
| 4637 | case AP_11g: |
| 4638 | run_system(dut, "cfg -a AP_CHMODE_2=11G"); |
| 4639 | break; |
| 4640 | case AP_11b: |
| 4641 | run_system(dut, "cfg -a AP_CHMODE_2=11B"); |
| 4642 | break; |
| 4643 | case AP_11ng: |
| 4644 | run_system(dut, "cfg -a AP_CHMODE_2=11NGHT20"); |
| 4645 | break; |
| 4646 | case AP_11a: |
| 4647 | run_system(dut, "cfg -a AP_CHMODE_2=11A"); |
| 4648 | break; |
| 4649 | case AP_11na: |
| 4650 | run_system(dut, "cfg -a AP_CHMODE_2=11NAHT20"); |
| 4651 | break; |
| 4652 | case AP_11ac: |
| 4653 | run_system(dut, "cfg -a AP_CHMODE_2=11ACVHT80"); |
| 4654 | break; |
| 4655 | default: |
| 4656 | run_system(dut, "cfg -a AP_CHMODE_2=11ACVHT80"); |
| 4657 | break; |
| 4658 | } |
| 4659 | |
| 4660 | switch (dut->ap_rx_streams) { |
| 4661 | case 1: |
| 4662 | run_system(dut, "cfg -a RX_CHAINMASK_2=1"); |
| 4663 | break; |
| 4664 | case 2: |
| 4665 | run_system(dut, "cfg -a RX_CHAINMASK_2=3"); |
| 4666 | break; |
| 4667 | case 3: |
| 4668 | run_system(dut, "cfg -a RX_CHAINMASK_2=7"); |
| 4669 | break; |
| 4670 | } |
| 4671 | |
| 4672 | switch (dut->ap_tx_streams) { |
| 4673 | case 1: |
| 4674 | run_system(dut, "cfg -a TX_CHAINMASK_2=1"); |
| 4675 | break; |
| 4676 | case 2: |
| 4677 | run_system(dut, "cfg -a TX_CHAINMASK_2=3"); |
| 4678 | break; |
| 4679 | case 3: |
| 4680 | run_system(dut, "cfg -a TX_CHAINMASK_2=7"); |
| 4681 | break; |
| 4682 | } |
| 4683 | |
| 4684 | switch (dut->ap_chwidth) { |
| 4685 | case AP_20: |
| 4686 | run_system(dut, "cfg -a AP_CHMODE_2=11ACVHT20"); |
| 4687 | break; |
| 4688 | case AP_40: |
| 4689 | run_system(dut, "cfg -a AP_CHMODE_2=11ACVHT40"); |
| 4690 | break; |
| 4691 | case AP_80: |
| 4692 | run_system(dut, "cfg -a AP_CHMODE_2=11ACVHT80"); |
| 4693 | break; |
| 4694 | case AP_160: |
| 4695 | case AP_AUTO: |
| 4696 | default: |
| 4697 | run_system(dut, "cfg -a AP_CHMODE_2=11ACVHT80"); |
| 4698 | break; |
| 4699 | } |
| 4700 | |
| 4701 | if (dut->ap_tx_stbc) { |
| 4702 | run_system(dut, "cfg -a TX_STBC_2=1"); |
| 4703 | } |
| 4704 | |
| 4705 | snprintf(buf, sizeof(buf), "cfg -a AP_PRIMARY_CH_2=%d", |
| 4706 | dut->ap_channel); |
| 4707 | |
| 4708 | if (dut->ap_is_dual) { |
| 4709 | switch (dut->ap_mode_1) { |
| 4710 | case AP_11g: |
| 4711 | run_system(dut, "cfg -a AP_CHMODE=11G"); |
| 4712 | break; |
| 4713 | case AP_11b: |
| 4714 | run_system(dut, "cfg -a AP_CHMODE=11B"); |
| 4715 | break; |
| 4716 | case AP_11ng: |
| 4717 | run_system(dut, "cfg -a AP_CHMODE=11NGHT20"); |
| 4718 | break; |
| 4719 | case AP_11a: |
| 4720 | run_system(dut, "cfg -a AP_CHMODE=11A"); |
| 4721 | break; |
| 4722 | case AP_11na: |
| 4723 | run_system(dut, "cfg -a AP_CHMODE=11NAHT20"); |
| 4724 | break; |
| 4725 | case AP_11ac: |
| 4726 | run_system(dut, "cfg -a AP_CHMODE=11ACVHT80"); |
| 4727 | break; |
| 4728 | default: |
| 4729 | run_system(dut, "cfg -a AP_CHMODE=11NGHT20"); |
| 4730 | break; |
| 4731 | } |
| 4732 | snprintf(buf, sizeof(buf), "cfg -a AP_PRIMARY_CH=%d", |
| 4733 | dut->ap_channel_1); |
| 4734 | } |
| 4735 | run_system(dut, buf); |
| 4736 | } else { |
| 4737 | run_system(dut, "cfg -a AP_RADIO_ID=0"); |
| 4738 | switch (dut->ap_mode) { |
| 4739 | case AP_11g: |
| 4740 | run_system(dut, "cfg -a AP_CHMODE=11G"); |
| 4741 | break; |
| 4742 | case AP_11b: |
| 4743 | run_system(dut, "cfg -a AP_CHMODE=11B"); |
| 4744 | break; |
| 4745 | case AP_11ng: |
| 4746 | run_system(dut, "cfg -a AP_CHMODE=11NGHT20"); |
| 4747 | break; |
| 4748 | case AP_11a: |
| 4749 | run_system(dut, "cfg -a AP_CHMODE=11A"); |
| 4750 | break; |
| 4751 | case AP_11na: |
| 4752 | run_system(dut, "cfg -a AP_CHMODE=11NAHT20"); |
| 4753 | break; |
| 4754 | case AP_11ac: |
| 4755 | run_system(dut, "cfg -a AP_CHMODE=11ACVHT80"); |
| 4756 | break; |
| 4757 | default: |
| 4758 | run_system(dut, "cfg -a AP_CHMODE=11NGHT20"); |
| 4759 | break; |
| 4760 | } |
| 4761 | snprintf(buf, sizeof(buf), "cfg -a AP_PRIMARY_CH=%d", |
| 4762 | dut->ap_channel); |
| 4763 | run_system(dut, buf); |
| 4764 | } |
| 4765 | |
| 4766 | if (dut->ap_sgi80 == 1) { |
| 4767 | run_system(dut, "cfg -a SHORTGI=1"); |
| 4768 | run_system(dut, "cfg -a SHORTGI_2=1"); |
| 4769 | } else if (dut->ap_sgi80 == 0) { |
| 4770 | run_system(dut, "cfg -a SHORTGI=0"); |
| 4771 | run_system(dut, "cfg -a SHORTGI_2=0"); |
| 4772 | } |
| 4773 | |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 4774 | if (dut->ap_ldpc == VALUE_ENABLED) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4775 | run_system(dut, "cfg -a LDPC=1"); |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 4776 | else if (dut->ap_ldpc == VALUE_DISABLED) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4777 | run_system(dut, "cfg -a LDPC=0"); |
| 4778 | } |
| 4779 | |
| 4780 | |
| 4781 | void ath_disable_txbf(struct sigma_dut *dut, const char *intf) |
| 4782 | { |
| 4783 | char buf[50]; |
| 4784 | |
| 4785 | snprintf(buf, sizeof(buf), "iwpriv %s vhtsubfee 0", intf); |
| 4786 | if (system(buf) != 0) |
| 4787 | sigma_dut_print(dut, DUT_MSG_ERROR, "iwpriv vhtsubfee failed"); |
| 4788 | |
| 4789 | snprintf(buf, sizeof(buf), "iwpriv %s vhtsubfer 0", intf); |
| 4790 | if (system(buf) != 0) |
| 4791 | sigma_dut_print(dut, DUT_MSG_ERROR, "iwpriv vhtsubfer failed"); |
| 4792 | |
| 4793 | snprintf(buf, sizeof(buf), "iwpriv %s vhtmubfee 0", intf); |
| 4794 | if (system(buf) != 0) |
| 4795 | sigma_dut_print(dut, DUT_MSG_ERROR, "iwpriv vhtmubfee failed"); |
| 4796 | |
| 4797 | snprintf(buf, sizeof(buf), "iwpriv %s vhtmubfer 0", intf); |
| 4798 | if (system(buf) != 0) |
| 4799 | sigma_dut_print(dut, DUT_MSG_ERROR, "iwpriv vhtmubfer failed"); |
| 4800 | } |
| 4801 | |
| 4802 | |
Adil Saeed Musthafa | 05ec744 | 2017-04-10 23:13:35 -0700 | [diff] [blame] | 4803 | static void ath_set_assoc_disallow(struct sigma_dut *dut, const char *ifname, |
| 4804 | const char *val) |
| 4805 | { |
| 4806 | if (strcasecmp(val, "enable") == 0) { |
| 4807 | run_system_wrapper(dut, "iwpriv %s mbo_asoc_dis 1", ifname); |
| 4808 | } else if (strcasecmp(val, "disable") == 0) { |
| 4809 | run_system_wrapper(dut, "iwpriv %s mbo_asoc_dis 0", ifname); |
| 4810 | } else { |
| 4811 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4812 | "Unsupported assoc_disallow"); |
| 4813 | } |
| 4814 | } |
| 4815 | |
| 4816 | |
Adil Saeed Musthafa | 6906372 | 2017-04-10 23:13:40 -0700 | [diff] [blame] | 4817 | static void apply_mbo_pref_ap_list(struct sigma_dut *dut) |
| 4818 | { |
| 4819 | int i; |
| 4820 | int least_pref = 1 << 8; |
| 4821 | char ifname[20]; |
| 4822 | uint8_t self_mac[ETH_ALEN]; |
| 4823 | char buf[200]; |
| 4824 | int ap_ne_class, ap_ne_pref, ap_ne_op_ch; |
| 4825 | |
| 4826 | get_if_name(dut, ifname, sizeof(ifname), 1); |
| 4827 | get_hwaddr(ifname, self_mac); |
| 4828 | |
| 4829 | /* Clear off */ |
| 4830 | snprintf(buf, sizeof(buf), |
| 4831 | "wifitool %s setbssidpref 00:00:00:00:00:00 0 0 0", |
| 4832 | ifname); |
| 4833 | run_system(dut, buf); |
| 4834 | |
| 4835 | /* Find the least preference number */ |
| 4836 | for (i = 0; i < dut->mbo_pref_ap_cnt; i++) { |
| 4837 | unsigned char *mac_addr = dut->mbo_pref_aps[i].mac_addr; |
| 4838 | |
| 4839 | ap_ne_class = 1; |
| 4840 | ap_ne_pref = 255; |
| 4841 | ap_ne_op_ch = 1; |
| 4842 | if (dut->mbo_pref_aps[i].ap_ne_pref != -1) |
| 4843 | ap_ne_pref = dut->mbo_pref_aps[i].ap_ne_pref; |
| 4844 | if (dut->mbo_pref_aps[i].ap_ne_class != -1) |
| 4845 | ap_ne_class = dut->mbo_pref_aps[i].ap_ne_class; |
| 4846 | if (dut->mbo_pref_aps[i].ap_ne_op_ch != -1) |
| 4847 | ap_ne_op_ch = dut->mbo_pref_aps[i].ap_ne_op_ch; |
| 4848 | |
| 4849 | if (ap_ne_pref < least_pref) |
| 4850 | least_pref = ap_ne_pref; |
| 4851 | snprintf(buf, sizeof(buf), |
| 4852 | "wifitool %s setbssidpref %02x:%02x:%02x:%02x:%02x:%02x %d %d %d", |
| 4853 | ifname, mac_addr[0], mac_addr[1], mac_addr[2], |
| 4854 | mac_addr[3], mac_addr[4], mac_addr[5], |
| 4855 | ap_ne_pref, ap_ne_class, ap_ne_op_ch); |
| 4856 | run_system(dut, buf); |
| 4857 | } |
| 4858 | |
| 4859 | /* Now add the self AP Address */ |
| 4860 | if (dut->mbo_self_ap_tuple.ap_ne_class == -1) { |
| 4861 | if (dut->ap_channel <= 11) |
| 4862 | ap_ne_class = 81; |
| 4863 | else |
| 4864 | ap_ne_class = 115; |
| 4865 | } else { |
| 4866 | ap_ne_class = dut->mbo_self_ap_tuple.ap_ne_class; |
| 4867 | } |
| 4868 | |
| 4869 | if (dut->mbo_self_ap_tuple.ap_ne_op_ch == -1) |
| 4870 | ap_ne_op_ch = dut->ap_channel; |
| 4871 | else |
| 4872 | ap_ne_op_ch = dut->mbo_self_ap_tuple.ap_ne_op_ch; |
| 4873 | |
| 4874 | if (dut->mbo_self_ap_tuple.ap_ne_pref == -1) |
| 4875 | ap_ne_pref = least_pref - 1; |
| 4876 | else |
| 4877 | ap_ne_pref = dut->mbo_self_ap_tuple.ap_ne_pref; |
| 4878 | |
| 4879 | snprintf(buf, sizeof(buf), |
| 4880 | "wifitool %s setbssidpref %02x:%02x:%02x:%02x:%02x:%02x %d %d %d", |
| 4881 | ifname, self_mac[0], self_mac[1], self_mac[2], |
| 4882 | self_mac[3], self_mac[4], self_mac[5], |
| 4883 | ap_ne_pref, |
| 4884 | ap_ne_class, |
| 4885 | ap_ne_op_ch); |
| 4886 | run_system(dut, buf); |
| 4887 | } |
| 4888 | |
| 4889 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4890 | static void ath_ap_set_params(struct sigma_dut *dut) |
| 4891 | { |
priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 4892 | const char *basedev = "wifi0"; |
| 4893 | const char *basedev_radio = "wifi1"; |
| 4894 | char *ifname = get_main_ifname(); |
| 4895 | char *ifname_dual; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4896 | int i; |
priyadharshini gowthaman | 8e26ff4 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 4897 | char buf[300]; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4898 | |
priyadharshini gowthaman | e161746 | 2017-04-25 12:03:59 -0700 | [diff] [blame] | 4899 | if (sigma_radio_ifname[0]) |
| 4900 | basedev = sigma_radio_ifname[0]; |
| 4901 | |
priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 4902 | if (dut->ap_is_dual == 1) { |
| 4903 | basedev = sigma_radio_ifname[0]; |
| 4904 | basedev_radio = sigma_radio_ifname[1]; |
| 4905 | if (sigma_radio_ifname[0] && |
| 4906 | strcmp(sigma_radio_ifname[0], "wifi0") == 0) { |
| 4907 | ifname = "ath0"; |
| 4908 | ifname_dual = "ath1"; |
| 4909 | } else { |
| 4910 | ifname = "ath1"; |
| 4911 | ifname_dual = "ath0"; |
| 4912 | } |
| 4913 | } |
| 4914 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4915 | if (dut->ap_countrycode[0]) { |
| 4916 | snprintf(buf, sizeof(buf), "iwpriv %s setCountry %s", |
| 4917 | basedev, dut->ap_countrycode); |
| 4918 | if (system(buf) != 0) { |
| 4919 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4920 | "iwpriv setCountry failed"); |
| 4921 | } |
| 4922 | sigma_dut_print(dut, DUT_MSG_INFO, "Set countrycode"); |
| 4923 | } |
| 4924 | |
| 4925 | for (i = 0; i < NUM_AP_AC; i++) { |
| 4926 | if (dut->ap_qos[i].ac) { |
| 4927 | snprintf(buf, sizeof(buf), "iwpriv %s cwmin %d 0 %d", |
| 4928 | ifname, i, dut->ap_qos[i].cwmin); |
| 4929 | if (system(buf) != 0) { |
| 4930 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4931 | "iwpriv cwmin failed"); |
| 4932 | } |
| 4933 | |
| 4934 | snprintf(buf, sizeof(buf), "iwpriv %s cwmax %d 0 %d", |
| 4935 | ifname, i, dut->ap_qos[i].cwmax); |
| 4936 | if (system(buf) != 0) { |
| 4937 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4938 | "iwpriv cwmax failed"); |
| 4939 | } |
| 4940 | |
| 4941 | snprintf(buf, sizeof(buf), "iwpriv %s aifs %d 0 %d", |
| 4942 | ifname, i, dut->ap_qos[i].aifs); |
| 4943 | if (system(buf) != 0) { |
| 4944 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4945 | "iwpriv aifs failed"); |
| 4946 | } |
| 4947 | |
| 4948 | snprintf(buf, sizeof(buf), |
| 4949 | "iwpriv %s txoplimit %d 0 %d", |
| 4950 | ifname, i, dut->ap_qos[i].txop); |
| 4951 | if (system(buf) != 0) { |
| 4952 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4953 | "iwpriv txoplimit failed"); |
| 4954 | } |
| 4955 | |
| 4956 | snprintf(buf, sizeof(buf), "iwpriv %s acm %d 0 %d", |
| 4957 | ifname, i, dut->ap_qos[i].acm); |
| 4958 | if (system(buf) != 0) { |
| 4959 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4960 | "iwpriv acm failed"); |
| 4961 | } |
| 4962 | } |
| 4963 | } |
| 4964 | |
| 4965 | for (i = 0; i < NUM_AP_AC; i++) { |
| 4966 | if (dut->ap_sta_qos[i].ac) { |
| 4967 | snprintf(buf, sizeof(buf), "iwpriv %s cwmin %d 1 %d", |
| 4968 | ifname, i, dut->ap_sta_qos[i].cwmin); |
| 4969 | if (system(buf) != 0) { |
| 4970 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4971 | "iwpriv cwmin failed"); |
| 4972 | } |
| 4973 | |
| 4974 | snprintf(buf, sizeof(buf), "iwpriv %s cwmax %d 1 %d", |
| 4975 | ifname, i, dut->ap_sta_qos[i].cwmax); |
| 4976 | if (system(buf) != 0) { |
| 4977 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4978 | "iwpriv cwmax failed"); |
| 4979 | } |
| 4980 | |
| 4981 | snprintf(buf, sizeof(buf), "iwpriv %s aifs %d 1 %d", |
| 4982 | ifname, i, dut->ap_sta_qos[i].aifs); |
| 4983 | if (system(buf) != 0) { |
| 4984 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4985 | "iwpriv aifs failed"); |
| 4986 | } |
| 4987 | |
| 4988 | snprintf(buf, sizeof(buf), |
| 4989 | "iwpriv %s txoplimit %d 1 %d", |
| 4990 | ifname, i, dut->ap_sta_qos[i].txop); |
| 4991 | if (system(buf) != 0) { |
| 4992 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4993 | "iwpriv txoplimit failed"); |
| 4994 | } |
| 4995 | |
| 4996 | snprintf(buf, sizeof(buf), "iwpriv %s acm %d 1 %d", |
| 4997 | ifname, i, dut->ap_sta_qos[i].acm); |
| 4998 | if (system(buf) != 0) { |
| 4999 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5000 | "iwpriv acm failed"); |
| 5001 | } |
| 5002 | } |
| 5003 | } |
| 5004 | |
| 5005 | if (dut->ap_disable_protection == 1) { |
| 5006 | snprintf(buf, sizeof(buf), "iwpriv %s enablertscts 0", ifname); |
| 5007 | if (system(buf) != 0) { |
| 5008 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5009 | "iwpriv enablertscts failed"); |
| 5010 | } |
| 5011 | sigma_dut_print(dut, DUT_MSG_INFO, "Disabled rtscts"); |
| 5012 | } |
| 5013 | |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 5014 | if (dut->ap_ldpc == VALUE_ENABLED) { |
Sarvepalli, Rajesh Babu | 580572a | 2016-11-29 22:07:14 +0530 | [diff] [blame] | 5015 | snprintf(buf, sizeof(buf), "iwpriv %s ldpc 3", ifname); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5016 | if (system(buf) != 0) { |
| 5017 | sigma_dut_print(dut, DUT_MSG_ERROR, |
priyadharshini gowthaman | 15b299d | 2017-04-20 12:10:45 -0700 | [diff] [blame] | 5018 | "iwpriv ldpc 3 failed"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5019 | } |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 5020 | } else if (dut->ap_ldpc == VALUE_DISABLED) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5021 | snprintf(buf, sizeof(buf), "iwpriv %s ldpc 0", ifname); |
| 5022 | if (system(buf) != 0) { |
| 5023 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5024 | "iwpriv ldpc 0 failed"); |
| 5025 | } |
| 5026 | } |
| 5027 | |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 5028 | if (dut->ap_ampdu == VALUE_ENABLED) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5029 | snprintf(buf, sizeof(buf), "iwpriv %s ampdu 1", ifname); |
| 5030 | if (system(buf) != 0) { |
| 5031 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5032 | "iwpriv ampdu 1 failed"); |
| 5033 | } |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 5034 | } else if (dut->ap_ampdu == VALUE_DISABLED) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5035 | snprintf(buf, sizeof(buf), "iwpriv %s ampdu 0", ifname); |
| 5036 | if (system(buf) != 0) { |
| 5037 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5038 | "iwpriv ampdu 0 failed"); |
| 5039 | } |
| 5040 | } |
| 5041 | |
| 5042 | if (dut->ap_ampdu_exp) { |
| 5043 | if (dut->program == PROGRAM_VHT) { |
| 5044 | snprintf(buf, sizeof(buf), "iwpriv %s vhtmaxampdu %d", |
| 5045 | ifname, dut->ap_ampdu_exp); |
| 5046 | if (system(buf) != 0) { |
| 5047 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5048 | "iwpriv vhtmaxampdu failed"); |
| 5049 | } |
| 5050 | } else { |
| 5051 | /* 11N */ |
| 5052 | snprintf(buf, sizeof(buf), "iwpriv %s maxampdu %d", |
| 5053 | ifname, dut->ap_ampdu_exp); |
| 5054 | if (system(buf) != 0) { |
| 5055 | sigma_dut_print(dut, DUT_MSG_ERROR, "iwpriv maxampdu failed"); |
| 5056 | } |
| 5057 | } |
| 5058 | } |
| 5059 | |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 5060 | if (dut->ap_noack == VALUE_ENABLED) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5061 | snprintf(buf, sizeof(buf), "iwpriv %s noackpolicy 0 0 1", ifname); |
| 5062 | if (system(buf) != 0) { |
| 5063 | sigma_dut_print(dut, DUT_MSG_ERROR, "iwpriv noackpolicy 0 0 1 failed"); |
| 5064 | } |
| 5065 | snprintf(buf, sizeof(buf), "iwpriv %s noackpolicy 1 0 1", ifname); |
| 5066 | if (system(buf) != 0) { |
| 5067 | sigma_dut_print(dut, DUT_MSG_ERROR, "iwpriv noackpolicy 1 0 1 failed"); |
| 5068 | } |
| 5069 | snprintf(buf, sizeof(buf), "iwpriv %s noackpolicy 2 0 1", ifname); |
| 5070 | if (system(buf) != 0) { |
| 5071 | sigma_dut_print(dut, DUT_MSG_ERROR, "iwpriv noackpolicy 2 0 1 failed"); |
| 5072 | } |
| 5073 | snprintf(buf, sizeof(buf), "iwpriv %s noackpolicy 3 0 1", ifname); |
| 5074 | if (system(buf) != 0) { |
| 5075 | sigma_dut_print(dut, DUT_MSG_ERROR, "iwpriv noackpolicy 3 0 1 failed"); |
| 5076 | } |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 5077 | } else if (dut->ap_noack == VALUE_DISABLED) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5078 | snprintf(buf, sizeof(buf), "iwpriv %s noackpolicy 0 0 0", ifname); |
| 5079 | if (system(buf) != 0) { |
| 5080 | sigma_dut_print(dut, DUT_MSG_ERROR, "iwpriv noackpolicy 0 0 0 failed"); |
| 5081 | } |
| 5082 | snprintf(buf, sizeof(buf), "iwpriv %s noackpolicy 1 0 0", ifname); |
| 5083 | if (system(buf) != 0) { |
| 5084 | sigma_dut_print(dut, DUT_MSG_ERROR, "iwpriv noackpolicy 1 0 0 failed"); |
| 5085 | } |
| 5086 | snprintf(buf, sizeof(buf), "iwpriv %s noackpolicy 2 0 0", ifname); |
| 5087 | if (system(buf) != 0) { |
| 5088 | sigma_dut_print(dut, DUT_MSG_ERROR, "iwpriv noackpolicy 2 0 0 failed"); |
| 5089 | } |
| 5090 | snprintf(buf, sizeof(buf), "iwpriv %s noackpolicy 3 0 0", ifname); |
| 5091 | if (system(buf) != 0) { |
| 5092 | sigma_dut_print(dut, DUT_MSG_ERROR, "iwpriv noackpolicy 3 0 0 failed"); |
| 5093 | } |
| 5094 | } |
| 5095 | |
| 5096 | if (dut->device_type == AP_testbed && dut->ap_vhtmcs_map) { |
| 5097 | snprintf(buf, sizeof(buf), "iwpriv %s vht_mcsmap 0x%04x", |
| 5098 | ifname, dut->ap_vhtmcs_map); |
| 5099 | if (system(buf) != 0) { |
| 5100 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5101 | "iwpriv vht_mcsmap failed"); |
| 5102 | } |
| 5103 | } |
| 5104 | |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 5105 | if (dut->ap_amsdu == VALUE_ENABLED) { |
Sunil Dutt | 27ec7f6 | 2017-09-14 18:22:59 +0300 | [diff] [blame] | 5106 | snprintf(buf, sizeof(buf), "iwpriv %s amsdu 2", ifname); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5107 | if (system(buf) != 0) { |
Sunil Dutt | 27ec7f6 | 2017-09-14 18:22:59 +0300 | [diff] [blame] | 5108 | sigma_dut_print(dut, DUT_MSG_ERROR, "iwpriv amsdu 2 failed"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5109 | } |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 5110 | } else if (dut->ap_amsdu == VALUE_DISABLED) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5111 | snprintf(buf, sizeof(buf), "iwpriv %s amsdu 1", ifname); |
| 5112 | if (system(buf) != 0) { |
| 5113 | sigma_dut_print(dut, DUT_MSG_ERROR, "iwpriv amsdu 1 failed"); |
| 5114 | } |
| 5115 | } |
| 5116 | |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 5117 | if (dut->ap_rx_amsdu == VALUE_ENABLED) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5118 | snprintf(buf, sizeof(buf), "iwpriv wifi1 rx_amsdu 1"); |
| 5119 | if (system(buf) != 0) { |
| 5120 | sigma_dut_print(dut, DUT_MSG_ERROR, "iwpriv rx_amsdu 1 failed"); |
| 5121 | } |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 5122 | } else if (dut->ap_rx_amsdu == VALUE_DISABLED) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5123 | snprintf(buf, sizeof(buf), "iwpriv wifi1 rx_amsdu 0"); |
| 5124 | if (system(buf) != 0) { |
| 5125 | sigma_dut_print(dut, DUT_MSG_ERROR, "iwpriv rx_amsdu 0 failed"); |
| 5126 | } |
| 5127 | } |
| 5128 | |
| 5129 | /* Command sequence to generate single VHT AMSDU and MPDU */ |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 5130 | if (dut->ap_addba_reject != VALUE_NOT_SET && |
| 5131 | dut->ap_ampdu == VALUE_DISABLED && |
| 5132 | dut->ap_amsdu == VALUE_ENABLED) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5133 | snprintf(buf, sizeof(buf), "iwpriv %s setaddbaoper 1", ifname); |
| 5134 | if (system(buf) != 0) { |
| 5135 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5136 | "iwpriv setaddbaoper 1 failed"); |
| 5137 | } |
| 5138 | |
| 5139 | snprintf(buf, sizeof(buf), |
| 5140 | "wifitool %s senddelba 1 0 1 4", ifname); |
| 5141 | if (system(buf) != 0) { |
| 5142 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5143 | "wifitool senddelba failed"); |
| 5144 | } |
| 5145 | |
| 5146 | snprintf(buf, sizeof(buf), "wifitool %s sendsingleamsdu 1 0", |
| 5147 | ifname); |
| 5148 | if (system(buf) != 0) { |
| 5149 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5150 | "wifitool sendsingleamsdu failed"); |
| 5151 | } |
| 5152 | |
| 5153 | snprintf(buf, sizeof(buf), "iwpriv %s amsdu 10", ifname); |
| 5154 | if (system(buf) != 0) { |
| 5155 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5156 | "iwpriv amsdu failed"); |
| 5157 | } |
| 5158 | } |
| 5159 | |
| 5160 | if (dut->ap_mode == AP_11ac) { |
| 5161 | int chwidth, nss; |
| 5162 | |
| 5163 | switch (dut->ap_chwidth) { |
| 5164 | case AP_20: |
| 5165 | chwidth = 0; |
| 5166 | break; |
| 5167 | case AP_40: |
| 5168 | chwidth = 1; |
| 5169 | break; |
| 5170 | case AP_80: |
| 5171 | chwidth = 2; |
| 5172 | break; |
| 5173 | case AP_160: |
| 5174 | chwidth = 3; |
| 5175 | break; |
priyadharshini gowthaman | 63ab848 | 2017-12-28 15:32:55 -0800 | [diff] [blame] | 5176 | case AP_80_80: |
| 5177 | chwidth = 3; |
| 5178 | break; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5179 | default: |
| 5180 | chwidth = 0; |
| 5181 | break; |
| 5182 | } |
| 5183 | |
| 5184 | switch (dut->ap_tx_streams) { |
| 5185 | case 1: |
| 5186 | nss = 1; |
| 5187 | break; |
| 5188 | case 2: |
| 5189 | nss = 2; |
| 5190 | break; |
| 5191 | case 3: |
| 5192 | nss = 3; |
| 5193 | break; |
| 5194 | case 4: |
| 5195 | nss = 4; |
| 5196 | break; |
| 5197 | default: |
| 5198 | nss = 3; |
| 5199 | break; |
| 5200 | } |
| 5201 | |
| 5202 | if (dut->ap_fixed_rate) { |
| 5203 | if (nss == 4) |
| 5204 | ath_disable_txbf(dut, ifname); |
| 5205 | |
| 5206 | /* Set the nss */ |
| 5207 | snprintf(buf, sizeof(buf), "iwpriv %s nss %d", |
| 5208 | ifname, nss); |
| 5209 | if (system(buf) != 0) { |
| 5210 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5211 | "iwpriv nss failed"); |
| 5212 | } |
| 5213 | |
| 5214 | /* Set the channel width */ |
| 5215 | snprintf(buf, sizeof(buf), "iwpriv %s chwidth %d", |
| 5216 | ifname, chwidth); |
| 5217 | if (system(buf) != 0) { |
| 5218 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5219 | "iwpriv chwidth failed"); |
| 5220 | } |
| 5221 | |
| 5222 | /* Set the VHT MCS */ |
| 5223 | snprintf(buf, sizeof(buf), "iwpriv %s vhtmcs %d", |
| 5224 | ifname, dut->ap_mcs); |
| 5225 | if (system(buf) != 0) { |
| 5226 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5227 | "iwpriv vhtmcs failed"); |
| 5228 | } |
| 5229 | } |
| 5230 | } |
| 5231 | |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 5232 | if (dut->ap_dyn_bw_sig == VALUE_ENABLED) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5233 | snprintf(buf, sizeof(buf), "iwpriv %s cwmenable 1", ifname); |
| 5234 | if (system(buf) != 0) { |
| 5235 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5236 | "iwpriv cwmenable 1 failed"); |
| 5237 | } |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 5238 | } else if (dut->ap_dyn_bw_sig == VALUE_DISABLED) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5239 | snprintf(buf, sizeof(buf), "iwpriv %s cwmenable 0", ifname); |
| 5240 | if (system(buf) != 0) { |
| 5241 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5242 | "iwpriv cwmenable 0 failed"); |
| 5243 | } |
| 5244 | } |
| 5245 | |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 5246 | if (dut->ap_sig_rts == VALUE_ENABLED) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5247 | snprintf(buf, sizeof(buf), "iwconfig %s rts 64", ifname); |
| 5248 | if (system(buf) != 0) { |
| 5249 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5250 | "iwconfig rts 64 failed"); |
| 5251 | } |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 5252 | } else if (dut->ap_sig_rts == VALUE_DISABLED) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5253 | snprintf(buf, sizeof(buf), "iwconfig %s rts 2347", ifname); |
| 5254 | if (system(buf) != 0) { |
| 5255 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5256 | "iwpriv rts 2347 failed"); |
| 5257 | } |
| 5258 | } |
| 5259 | |
| 5260 | if (dut->ap_hs2) { |
| 5261 | snprintf(buf, sizeof(buf), "iwpriv %s qbssload 1", ifname); |
| 5262 | if (system(buf) != 0) { |
| 5263 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5264 | "iwpriv qbssload failed"); |
| 5265 | } |
| 5266 | sigma_dut_print(dut, DUT_MSG_INFO, "Enabled qbssload"); |
| 5267 | } |
| 5268 | |
| 5269 | if (dut->ap_bss_load && dut->ap_bss_load != -1) { |
| 5270 | unsigned int bssload = 0; |
| 5271 | |
| 5272 | if (dut->ap_bss_load == 1) { |
| 5273 | /* STA count: 1, CU: 50, AAC: 65535 */ |
| 5274 | bssload = 0x0132ffff; |
| 5275 | } else if (dut->ap_bss_load == 2) { |
| 5276 | /* STA count: 1, CU: 200, AAC: 65535 */ |
| 5277 | bssload = 0x01c8ffff; |
| 5278 | } else if (dut->ap_bss_load == 3) { |
| 5279 | /* STA count: 1, CU: 75, AAC: 65535 */ |
| 5280 | bssload = 0x014bffff; |
| 5281 | } |
| 5282 | |
| 5283 | snprintf(buf, sizeof(buf), "iwpriv %s hcbssload %u", |
| 5284 | ifname, bssload); |
| 5285 | if (system(buf) != 0) { |
| 5286 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5287 | "iwpriv hcbssload failed"); |
| 5288 | } |
| 5289 | } else if (dut->ap_bss_load == 0) { |
| 5290 | snprintf(buf, sizeof(buf), "iwpriv %s qbssload 0", ifname); |
| 5291 | if (system(buf) != 0) { |
| 5292 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5293 | "iwpriv qbssload failed"); |
| 5294 | } |
| 5295 | sigma_dut_print(dut, DUT_MSG_INFO, "Disabled qbssload"); |
| 5296 | } |
| 5297 | |
| 5298 | if (dut->ap_dgaf_disable) { |
| 5299 | snprintf(buf, sizeof(buf), "iwpriv %s dgaf_disable 1", ifname); |
| 5300 | if (system(buf) != 0) { |
| 5301 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5302 | "iwpriv dgaf_disable failed"); |
| 5303 | } |
| 5304 | sigma_dut_print(dut, DUT_MSG_INFO, "Enabled dgaf_disable"); |
| 5305 | } |
| 5306 | |
| 5307 | if (dut->ap_l2tif) { |
| 5308 | snprintf(buf, sizeof(buf), "iwpriv %s l2tif 1", ifname); |
| 5309 | if (system(buf) != 0) { |
| 5310 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5311 | "iwpriv l2tif failed"); |
| 5312 | } |
| 5313 | snprintf(buf, sizeof(buf), |
| 5314 | "echo 1 > /sys/class/net/br0/brif/ath0/hotspot_l2tif"); |
| 5315 | if (system(buf) != 0) |
| 5316 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5317 | "l2tif br failed"); |
| 5318 | |
| 5319 | snprintf(buf, sizeof(buf), |
| 5320 | "echo 1 > /sys/class/net/br0/brif/eth0/hotspot_wan"); |
| 5321 | if (system(buf) != 0) |
| 5322 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5323 | "l2tif brif failed"); |
| 5324 | sigma_dut_print(dut, DUT_MSG_INFO, "Enabled l2tif"); |
| 5325 | } |
priyadharshini gowthaman | 264d544 | 2016-02-25 15:52:22 -0800 | [diff] [blame] | 5326 | |
| 5327 | if (dut->ap_ndpa_frame == 0) { |
| 5328 | snprintf(buf, sizeof(buf), |
| 5329 | "wifitool %s beeliner_fw_test 117 192", ifname); |
| 5330 | if (system(buf) != 0) { |
| 5331 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5332 | "wifitool beeliner_fw_test 117 192 failed"); |
| 5333 | } |
| 5334 | snprintf(buf, sizeof(buf), |
| 5335 | "wifitool %s beeliner_fw_test 118 192", ifname); |
| 5336 | if (system(buf) != 0) { |
| 5337 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5338 | "wifitool beeliner_fw_test 117 192 failed"); |
| 5339 | } |
| 5340 | } else if (dut->ap_ndpa_frame == 1) { |
| 5341 | /* Driver default - no changes needed */ |
| 5342 | } else if (dut->ap_ndpa_frame == 2) { |
| 5343 | snprintf(buf, sizeof(buf), |
| 5344 | "wifitool %s beeliner_fw_test 115 1", ifname); |
| 5345 | if (system(buf) != 0) { |
| 5346 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5347 | "wifitool beeliner_fw_test 117 192 failed"); |
| 5348 | } |
| 5349 | snprintf(buf, sizeof(buf), |
| 5350 | "wifitool %s beeliner_fw_test 116 1", ifname); |
| 5351 | if (system(buf) != 0) { |
| 5352 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5353 | "wifitool beeliner_fw_test 117 192 failed"); |
| 5354 | } |
| 5355 | } |
priyadharshini gowthaman | 8e26ff4 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 5356 | |
| 5357 | if (dut->ap_rtt == 1) { |
| 5358 | snprintf(buf, sizeof(buf), "iwpriv %s enable_rtt 1", ifname); |
| 5359 | run_system(dut, buf); |
| 5360 | } |
| 5361 | |
| 5362 | if (dut->ap_lci == 1) { |
| 5363 | snprintf(buf, sizeof(buf), "iwpriv %s enable_lci 1", ifname); |
| 5364 | run_system(dut, buf); |
| 5365 | } |
| 5366 | |
| 5367 | if (dut->ap_lcr == 1) { |
| 5368 | snprintf(buf, sizeof(buf), "iwpriv %s enable_lcr 1", ifname); |
| 5369 | run_system(dut, buf); |
| 5370 | } |
| 5371 | |
| 5372 | if (dut->ap_rrm == 1) { |
| 5373 | snprintf(buf, sizeof(buf), "iwpriv %s rrm 1", ifname); |
| 5374 | run_system(dut, buf); |
| 5375 | } |
| 5376 | |
| 5377 | if (dut->ap_lci == 1 || dut->ap_lcr == 1) { |
| 5378 | run_system(dut, "wpc -l /tmp/lci_cfg.txt"); |
| 5379 | } |
| 5380 | |
| 5381 | if (dut->ap_neighap >= 1 && dut->ap_lci == 0) { |
| 5382 | FILE *f; |
| 5383 | |
| 5384 | f = fopen("/tmp/nbr_report.txt", "w"); |
| 5385 | if (!f) { |
| 5386 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5387 | "Failed to open /tmp/nbr_report.txt"); |
| 5388 | return; |
| 5389 | } |
| 5390 | |
| 5391 | fprintf(f, |
| 5392 | "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", |
| 5393 | dut->ap_val_neighap[0][0], dut->ap_val_neighap[0][1], |
| 5394 | dut->ap_val_neighap[0][2], dut->ap_val_neighap[0][3], |
| 5395 | dut->ap_val_neighap[0][4], dut->ap_val_neighap[0][5], |
| 5396 | dut->ap_val_opchannel[0]); |
| 5397 | fclose(f); |
| 5398 | |
| 5399 | f = fopen("/tmp/ftmrr.txt", "w"); |
| 5400 | if (!f) { |
| 5401 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5402 | "Failed to open /tmp/ftmrr.txt"); |
| 5403 | return; |
| 5404 | } |
| 5405 | |
| 5406 | fprintf(f, |
| 5407 | "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", |
| 5408 | dut->ap_val_neighap[0][0], dut->ap_val_neighap[0][1], |
| 5409 | dut->ap_val_neighap[0][2], dut->ap_val_neighap[0][3], |
| 5410 | dut->ap_val_neighap[0][4], dut->ap_val_neighap[0][5], |
| 5411 | dut->ap_val_opchannel[0]); |
| 5412 | fclose(f); |
| 5413 | } |
| 5414 | |
| 5415 | if (dut->ap_neighap >= 2 && dut->ap_lci == 0) { |
| 5416 | FILE *f; |
| 5417 | |
| 5418 | f = fopen("/tmp/nbr_report.txt", "a"); |
| 5419 | if (!f) { |
| 5420 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5421 | "Failed to open /tmp/nbr_report.txt"); |
| 5422 | return; |
| 5423 | } |
| 5424 | fprintf(f, |
| 5425 | "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", |
| 5426 | dut->ap_val_neighap[1][0], dut->ap_val_neighap[1][1], |
| 5427 | dut->ap_val_neighap[1][2], dut->ap_val_neighap[1][3], |
| 5428 | dut->ap_val_neighap[1][4], dut->ap_val_neighap[1][5], |
| 5429 | dut->ap_val_opchannel[1]); |
| 5430 | fclose(f); |
| 5431 | |
| 5432 | f = fopen("/tmp/ftmrr.txt", "a"); |
| 5433 | if (!f) { |
| 5434 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5435 | "Failed to open /tmp/ftmrr.txt"); |
| 5436 | return; |
| 5437 | } |
| 5438 | fprintf(f, |
| 5439 | "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", |
| 5440 | dut->ap_val_neighap[1][0], dut->ap_val_neighap[1][1], |
| 5441 | dut->ap_val_neighap[1][2], dut->ap_val_neighap[1][3], |
| 5442 | dut->ap_val_neighap[1][4], dut->ap_val_neighap[1][5], |
| 5443 | dut->ap_val_opchannel[1]); |
| 5444 | fclose(f); |
| 5445 | } |
| 5446 | |
| 5447 | if (dut->ap_neighap >= 3 && dut->ap_lci == 0) { |
| 5448 | FILE *f; |
| 5449 | |
| 5450 | f = fopen("/tmp/nbr_report.txt", "a"); |
| 5451 | if (!f) { |
| 5452 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5453 | "Failed to open /tmp/nbr_report.txt"); |
| 5454 | return; |
| 5455 | } |
| 5456 | |
| 5457 | fprintf(f, |
| 5458 | "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", |
| 5459 | dut->ap_val_neighap[2][0], dut->ap_val_neighap[2][1], |
| 5460 | dut->ap_val_neighap[2][2], dut->ap_val_neighap[2][3], |
| 5461 | dut->ap_val_neighap[2][4], dut->ap_val_neighap[2][5], |
| 5462 | dut->ap_val_opchannel[2]); |
| 5463 | fclose(f); |
| 5464 | |
| 5465 | f = fopen("/tmp/ftmrr.txt", "a"); |
| 5466 | if (!f) { |
| 5467 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5468 | "Failed to open /tmp/ftmrr.txt"); |
| 5469 | return; |
| 5470 | } |
| 5471 | |
| 5472 | fprintf(f, |
| 5473 | "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", |
| 5474 | dut->ap_val_neighap[2][0], dut->ap_val_neighap[2][1], |
| 5475 | dut->ap_val_neighap[2][2], dut->ap_val_neighap[2][3], |
| 5476 | dut->ap_val_neighap[2][4], dut->ap_val_neighap[2][5], |
| 5477 | dut->ap_val_opchannel[2]); |
| 5478 | fclose(f); |
| 5479 | } |
| 5480 | |
| 5481 | if (dut->ap_neighap) { |
| 5482 | snprintf(buf, sizeof(buf), "iwpriv %s enable_rtt 1", ifname); |
| 5483 | run_system(dut, buf); |
| 5484 | snprintf(buf, sizeof(buf), "iwpriv %s enable_lci 1", ifname); |
| 5485 | run_system(dut, buf); |
| 5486 | snprintf(buf, sizeof(buf), "iwpriv %s enable_lcr 1", ifname); |
| 5487 | run_system(dut, buf); |
| 5488 | snprintf(buf, sizeof(buf), "iwpriv %s rrm 1", ifname); |
| 5489 | run_system(dut, buf); |
| 5490 | } |
| 5491 | |
| 5492 | if (dut->ap_scan == 1) { |
| 5493 | snprintf(buf, sizeof(buf), "iwpriv %s scanentryage 600", |
| 5494 | ifname); |
| 5495 | run_system(dut, buf); |
| 5496 | snprintf(buf, sizeof(buf), "iwlist %s scan", ifname); |
| 5497 | run_system(dut, buf); |
| 5498 | } |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 5499 | |
| 5500 | if (dut->ap_set_bssidpref) { |
| 5501 | snprintf(buf, sizeof(buf), |
| 5502 | "wifitool %s setbssidpref 00:00:00:00:00:00 0 00 00", |
| 5503 | ifname); |
| 5504 | if (system(buf) != 0) { |
| 5505 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5506 | "wifitool clear bssidpref failed"); |
| 5507 | } |
| 5508 | } |
Adil Saeed Musthafa | 33ea287 | 2017-04-10 23:13:24 -0700 | [diff] [blame] | 5509 | |
| 5510 | if (dut->wnm_bss_max_feature != VALUE_NOT_SET) { |
| 5511 | int feature_enable; |
| 5512 | |
| 5513 | feature_enable = dut->wnm_bss_max_feature == VALUE_ENABLED; |
| 5514 | snprintf(buf, sizeof(buf), "iwpriv %s wnm %d", |
| 5515 | ifname, feature_enable); |
| 5516 | run_system(dut, buf); |
| 5517 | snprintf(buf, sizeof(buf), "iwpriv %s wnm_bss %d", |
| 5518 | ifname, feature_enable); |
| 5519 | run_system(dut, buf); |
| 5520 | if (feature_enable) { |
| 5521 | const char *extra = ""; |
| 5522 | |
| 5523 | if (dut->wnm_bss_max_protection != VALUE_NOT_SET) { |
| 5524 | if (dut->wnm_bss_max_protection == |
| 5525 | VALUE_ENABLED) |
| 5526 | extra = " 1"; |
| 5527 | else |
| 5528 | extra = " 0"; |
| 5529 | } |
| 5530 | snprintf(buf, sizeof(buf), |
| 5531 | "wlanconfig %s wnm setbssmax %d%s", |
| 5532 | ifname, dut->wnm_bss_max_idle_time, extra); |
| 5533 | run_system(dut, buf); |
| 5534 | } |
| 5535 | } |
Adil Saeed Musthafa | 05ec744 | 2017-04-10 23:13:35 -0700 | [diff] [blame] | 5536 | |
Adil Saeed Musthafa | 023108a | 2017-04-10 23:13:37 -0700 | [diff] [blame] | 5537 | if (dut->program == PROGRAM_MBO) { |
Adil Saeed Musthafa | 6906372 | 2017-04-10 23:13:40 -0700 | [diff] [blame] | 5538 | apply_mbo_pref_ap_list(dut); |
| 5539 | |
Adil Saeed Musthafa | 023108a | 2017-04-10 23:13:37 -0700 | [diff] [blame] | 5540 | snprintf(buf, sizeof(buf), "iwpriv %s mbo_cel_pref %d", |
| 5541 | ifname, dut->ap_cell_cap_pref); |
| 5542 | run_system(dut, buf); |
Adil Saeed Musthafa | 16d9e63 | 2017-04-10 23:13:38 -0700 | [diff] [blame] | 5543 | |
| 5544 | snprintf(buf, sizeof(buf), "iwpriv %s mbocap 0x40", ifname); |
| 5545 | run_system(dut, buf); |
| 5546 | |
Adil Saeed Musthafa | 05ec744 | 2017-04-10 23:13:35 -0700 | [diff] [blame] | 5547 | ath_set_assoc_disallow(dut, ifname, "disable"); |
Adil Saeed Musthafa | 023108a | 2017-04-10 23:13:37 -0700 | [diff] [blame] | 5548 | } |
priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 5549 | |
| 5550 | if (dut->ap_oce == VALUE_ENABLED) { |
| 5551 | snprintf(buf, sizeof(buf), "iwpriv %s set_bpr_enable 1", |
| 5552 | ifname); |
| 5553 | run_system(dut, buf); |
| 5554 | } |
| 5555 | |
| 5556 | if (dut->ap_oce == VALUE_ENABLED && dut->ap_channel <= 11) { |
| 5557 | snprintf(buf, sizeof(buf), "iwpriv %s prb_rate 5500", ifname); |
| 5558 | run_system(dut, buf); |
| 5559 | snprintf(buf, sizeof(buf), "iwpriv %s set_bcn_rate 5500", |
| 5560 | ifname); |
| 5561 | run_system(dut, buf); |
| 5562 | } |
| 5563 | |
| 5564 | if (dut->ap_oce == VALUE_DISABLED) { |
| 5565 | snprintf(buf, sizeof(buf), "iwpriv %s set_bpr_enable 0", |
| 5566 | ifname); |
| 5567 | run_system(dut, buf); |
| 5568 | } |
| 5569 | |
| 5570 | if (dut->ap_oce == VALUE_DISABLED && dut->ap_channel <= 11) { |
| 5571 | snprintf(buf, sizeof(buf), "iwpriv %s mgmt_rate 1000", ifname); |
| 5572 | run_system(dut, buf); |
| 5573 | snprintf(buf, sizeof(buf), "iwpriv %s set_bcn_rate 1000", |
| 5574 | ifname); |
| 5575 | run_system(dut, buf); |
| 5576 | } |
| 5577 | |
| 5578 | if (dut->ap_bcnint) { |
| 5579 | snprintf(buf, sizeof(buf), "iwpriv %s bintval %d", ifname, |
| 5580 | dut->ap_bcnint); |
| 5581 | run_system(dut, buf); |
| 5582 | } |
| 5583 | |
| 5584 | if (dut->ap_filsdscv == VALUE_DISABLED) { |
| 5585 | snprintf(buf, sizeof(buf), "iwpriv %s enable_fils 0 0", ifname); |
| 5586 | run_system(dut, buf); |
| 5587 | } |
| 5588 | |
| 5589 | if (dut->ap_filshlp == VALUE_ENABLED) { |
| 5590 | snprintf(buf, sizeof(buf), "iwpriv %s oce_hlp 1", ifname); |
| 5591 | if (system(buf) != 0) { |
| 5592 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5593 | "iwpriv filshlp enable failed"); |
| 5594 | } |
| 5595 | } else if (dut->ap_filshlp == VALUE_DISABLED) { |
| 5596 | snprintf(buf, sizeof(buf), "iwpriv %s oce_hlp 0", ifname); |
| 5597 | if (system(buf) != 0) { |
| 5598 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5599 | "iwpriv filshlp disable failed"); |
| 5600 | } |
| 5601 | } |
| 5602 | |
| 5603 | /* When RNR is enabled, also enable apchannelreport, background scan */ |
| 5604 | if (dut->ap_rnr == VALUE_ENABLED) { |
| 5605 | snprintf(buf, sizeof(buf), "iwpriv %s rnr 1", ifname); |
| 5606 | run_system(dut, buf); |
| 5607 | snprintf(buf, sizeof(buf), "iwpriv %s rnr_tbtt 1", ifname); |
| 5608 | run_system(dut, buf); |
| 5609 | snprintf(buf, sizeof(buf), "iwpriv %s apchanrpt 1", ifname); |
| 5610 | run_system(dut, buf); |
| 5611 | snprintf(buf, sizeof(buf), "iwpriv %s acs_ctrlflags 0x4", |
| 5612 | basedev); |
| 5613 | run_system(dut, buf); |
| 5614 | snprintf(buf, sizeof(buf), "iwpriv %s acs_scanintvl 60", |
| 5615 | basedev); |
| 5616 | run_system(dut, buf); |
| 5617 | snprintf(buf, sizeof(buf), "iwpriv %s acs_bkscanen 1", basedev); |
| 5618 | run_system(dut, buf); |
| 5619 | if (dut->ap_is_dual == 1) { |
| 5620 | snprintf(buf, sizeof(buf), "iwpriv %s rnr 1", |
| 5621 | ifname_dual); |
| 5622 | run_system(dut, buf); |
| 5623 | snprintf(buf, sizeof(buf), "iwpriv %s rnr_tbtt 1", |
| 5624 | ifname_dual); |
| 5625 | run_system(dut, buf); |
| 5626 | snprintf(buf, sizeof(buf), "iwpriv %s apchanrpt 1", |
| 5627 | ifname_dual); |
| 5628 | run_system(dut, buf); |
| 5629 | snprintf(buf, sizeof(buf), |
| 5630 | "iwpriv %s acs_ctrlflags 0x4", basedev_radio); |
| 5631 | run_system(dut, buf); |
| 5632 | snprintf(buf, sizeof(buf), "iwpriv %s acs_scanintvl 60", |
| 5633 | basedev_radio); |
| 5634 | run_system(dut, buf); |
| 5635 | snprintf(buf, sizeof(buf), "iwpriv %s acs_bkscanen 1", |
| 5636 | basedev_radio); |
| 5637 | run_system(dut, buf); |
| 5638 | } |
| 5639 | } |
| 5640 | |
| 5641 | if (dut->ap_blechanutil || dut->ap_ble_admit_cap || dut->ap_blestacnt) { |
| 5642 | snprintf(buf, sizeof(buf), "iwpriv %s qbssload 0", ifname); |
| 5643 | run_system(dut, buf); |
| 5644 | snprintf(buf, sizeof(buf), |
| 5645 | "wlanconfig %s addie ftype 0 len 7 data 0b05%02x%02x%02x%02x%02x ", |
| 5646 | ifname, dut->ap_blestacnt & 0xFF, |
| 5647 | dut->ap_blestacnt >> 8, dut->ap_blechanutil, |
| 5648 | dut->ap_ble_admit_cap & 0xFF, |
| 5649 | dut->ap_ble_admit_cap >> 8); |
| 5650 | run_system(dut, buf); |
| 5651 | snprintf(buf, sizeof(buf), |
| 5652 | "wlanconfig %s addie ftype 2 len 7 data 0b05%02x%02x%02x%02x%02x ", |
| 5653 | ifname, dut->ap_blestacnt & 0xFF, |
| 5654 | dut->ap_blestacnt >> 8, dut->ap_blechanutil, |
| 5655 | dut->ap_ble_admit_cap & 0xFF, |
| 5656 | dut->ap_ble_admit_cap >> 8); |
| 5657 | run_system(dut, buf); |
| 5658 | } |
| 5659 | |
| 5660 | if (dut->ap_esp == VALUE_ENABLED) { |
| 5661 | snprintf(buf, sizeof(buf), "iwpriv %s esp_period 5", basedev); |
| 5662 | if (system(buf) != 0) { |
| 5663 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5664 | "iwpriv esp enable failed"); |
| 5665 | } |
| 5666 | } else if (dut->ap_esp == VALUE_DISABLED) { |
| 5667 | snprintf(buf, sizeof(buf), "iwpriv %s esp_period 0", basedev); |
| 5668 | if (system(buf) != 0) { |
| 5669 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5670 | "iwpriv esp disable failed"); |
| 5671 | } |
| 5672 | } |
| 5673 | |
| 5674 | if (dut->ap_datappdudura) { |
| 5675 | snprintf(buf, sizeof(buf), "iwpriv %s esp_ppdu_dur %d", basedev, |
| 5676 | dut->ap_datappdudura); |
| 5677 | run_system(dut, buf); |
| 5678 | } |
| 5679 | |
| 5680 | if (dut->ap_airtimefract) { |
| 5681 | snprintf(buf, sizeof(buf), "iwpriv %s esp_airtime %d", basedev, |
| 5682 | dut->ap_airtimefract); |
| 5683 | run_system(dut, buf); |
| 5684 | } |
| 5685 | |
| 5686 | if (dut->ap_dhcp_stop) { |
| 5687 | snprintf(buf, sizeof(buf), "/etc/init.d/dnsmasq stop"); |
| 5688 | run_system(dut, buf); |
| 5689 | } |
| 5690 | |
| 5691 | if (dut->ap_bawinsize) { |
| 5692 | snprintf(buf, sizeof(buf), "iwpriv %s esp_ba_window %d", |
| 5693 | basedev, dut->ap_bawinsize); |
| 5694 | run_system(dut, buf); |
| 5695 | } |
priyadharshini gowthaman | b4de196 | 2018-01-15 12:21:04 -0800 | [diff] [blame] | 5696 | |
| 5697 | if (dut->program == PROGRAM_DPP) { |
| 5698 | if (dut->ap_interface_2g == 1) { |
| 5699 | snprintf(buf, sizeof(buf), |
| 5700 | "iwpriv %s set_bcn_rate 5500", ifname); |
| 5701 | run_system(dut, buf); |
| 5702 | snprintf(buf, sizeof(buf), |
| 5703 | "iwpriv %s prb_rate 5500", ifname); |
| 5704 | run_system(dut, buf); |
| 5705 | snprintf(buf, sizeof(buf), |
| 5706 | "iwpriv %s mgmt_rate 5500", ifname); |
| 5707 | run_system(dut, buf); |
| 5708 | } |
| 5709 | |
| 5710 | snprintf(buf, sizeof(buf), "iwpriv %s set_rxfilter 0xffffffff", |
| 5711 | basedev); |
| 5712 | run_system(dut, buf); |
| 5713 | dut->hostapd_running = 1; |
| 5714 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5715 | } |
| 5716 | |
| 5717 | |
| 5718 | static int cmd_ath_ap_config_commit(struct sigma_dut *dut, |
| 5719 | struct sigma_conn *conn, |
| 5720 | struct sigma_cmd *cmd) |
| 5721 | { |
| 5722 | /* const char *name = get_param(cmd, "NAME"); */ |
| 5723 | char buf[100]; |
| 5724 | struct stat s; |
| 5725 | const char *ifname = dut->ap_is_dual ? "ath1" : "ath0"; |
| 5726 | |
| 5727 | if (stat("/proc/athversion", &s) == 0) { |
| 5728 | sigma_dut_print(dut, DUT_MSG_INFO, "Run apdown"); |
| 5729 | run_system(dut, "apdown"); |
| 5730 | } |
| 5731 | |
| 5732 | cmd_ath_ap_radio_config(dut); |
| 5733 | |
| 5734 | snprintf(buf, sizeof(buf), "cfg -a 'AP_SSID=%s'", dut->ap_ssid); |
| 5735 | run_system(dut, buf); |
| 5736 | |
| 5737 | switch (dut->ap_key_mgmt) { |
| 5738 | case AP_OPEN: |
| 5739 | if (dut->ap_cipher == AP_WEP) { |
| 5740 | run_system(dut, "cfg -a AP_SECMODE=WEP"); |
| 5741 | run_system(dut, "cfg -a AP_SECFILE=NONE"); |
| 5742 | /* shared auth mode not supported */ |
| 5743 | run_system(dut, "cfg -a AP_WEP_MODE_0=1"); |
| 5744 | run_system(dut, "cfg -a AP_WEP_MODE_1=1"); |
| 5745 | snprintf(buf, sizeof(buf), |
| 5746 | "cfg -a WEP_RADIO_NUM0_KEY_1=%s", |
| 5747 | dut->ap_wepkey); |
| 5748 | run_system(dut, buf); |
| 5749 | snprintf(buf, sizeof(buf), |
| 5750 | "cfg -a WEP_RADIO_NUM1_KEY_1=%s", |
| 5751 | dut->ap_wepkey); |
| 5752 | run_system(dut, buf); |
| 5753 | } else { |
| 5754 | run_system(dut, "cfg -a AP_SECMODE=None"); |
| 5755 | } |
| 5756 | break; |
| 5757 | case AP_WPA2_PSK: |
| 5758 | case AP_WPA2_PSK_MIXED: |
| 5759 | case AP_WPA_PSK: |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 5760 | case AP_WPA2_SAE: |
| 5761 | case AP_WPA2_PSK_SAE: |
| 5762 | if (dut->ap_key_mgmt == AP_WPA2_PSK || |
| 5763 | dut->ap_key_mgmt == AP_WPA2_SAE || |
| 5764 | dut->ap_key_mgmt == AP_WPA2_PSK_SAE) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5765 | run_system(dut, "cfg -a AP_WPA=2"); |
| 5766 | else if (dut->ap_key_mgmt == AP_WPA2_PSK_MIXED) |
| 5767 | run_system(dut, "cfg -a AP_WPA=3"); |
| 5768 | else |
| 5769 | run_system(dut, "cfg -a AP_WPA=1"); |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 5770 | /* TODO: SAE configuration */ |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5771 | run_system(dut, "cfg -a AP_SECMODE=WPA"); |
| 5772 | run_system(dut, "cfg -a AP_SECFILE=PSK"); |
| 5773 | snprintf(buf, sizeof(buf), "cfg -a 'PSK_KEY=%s'", |
| 5774 | dut->ap_passphrase); |
| 5775 | run_system(dut, buf); |
| 5776 | if (dut->ap_cipher == AP_CCMP_TKIP) |
| 5777 | run_system(dut, "cfg -a AP_CYPHER=\"CCMP TKIP\""); |
| 5778 | else if (dut->ap_cipher == AP_TKIP) |
| 5779 | run_system(dut, "cfg -a AP_CYPHER=TKIP"); |
| 5780 | else |
| 5781 | run_system(dut, "cfg -a AP_CYPHER=CCMP"); |
| 5782 | break; |
| 5783 | case AP_WPA2_EAP: |
| 5784 | case AP_WPA2_EAP_MIXED: |
| 5785 | case AP_WPA_EAP: |
| 5786 | if (dut->ap_key_mgmt == AP_WPA2_EAP) |
| 5787 | run_system(dut, "cfg -a AP_WPA=2"); |
| 5788 | else if (dut->ap_key_mgmt == AP_WPA2_EAP_MIXED) |
| 5789 | run_system(dut, "cfg -a AP_WPA=3"); |
| 5790 | else |
| 5791 | run_system(dut, "cfg -a AP_WPA=1"); |
| 5792 | run_system(dut, "cfg -a AP_SECMODE=WPA"); |
| 5793 | run_system(dut, "cfg -a AP_SECFILE=EAP"); |
| 5794 | if (dut->ap_cipher == AP_CCMP_TKIP) |
| 5795 | run_system(dut, "cfg -a AP_CYPHER=\"CCMP TKIP\""); |
| 5796 | else if (dut->ap_cipher == AP_TKIP) |
| 5797 | run_system(dut, "cfg -a AP_CYPHER=TKIP"); |
| 5798 | else |
| 5799 | run_system(dut, "cfg -a AP_CYPHER=CCMP"); |
| 5800 | snprintf(buf, sizeof(buf), "cfg -a AP_AUTH_SERVER=%s", |
| 5801 | dut->ap_radius_ipaddr); |
| 5802 | run_system(dut, buf); |
| 5803 | snprintf(buf, sizeof(buf), "cfg -a AP_AUTH_PORT=%d", |
| 5804 | dut->ap_radius_port); |
| 5805 | run_system(dut, buf); |
| 5806 | snprintf(buf, sizeof(buf), "cfg -a AP_AUTH_SECRET=%s", |
| 5807 | dut->ap_radius_password); |
| 5808 | run_system(dut, buf); |
| 5809 | break; |
Jouni Malinen | ad395a2 | 2017-09-01 21:13:46 +0300 | [diff] [blame] | 5810 | case AP_SUITEB: |
| 5811 | /* TODO */ |
| 5812 | sigma_dut_print(dut, DUT_MSG_ERROR, "SuiteB not supported"); |
| 5813 | break; |
Jouni Malinen | 147b3c3 | 2017-10-09 16:51:54 +0300 | [diff] [blame] | 5814 | case AP_WPA2_OWE: |
| 5815 | /* TODO */ |
| 5816 | sigma_dut_print(dut, DUT_MSG_ERROR, "OWE not supported"); |
| 5817 | break; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5818 | } |
| 5819 | |
| 5820 | if (dut->ap_is_dual) { |
| 5821 | /* ath1 settings in case of dual */ |
| 5822 | snprintf(buf, sizeof(buf), "cfg -a 'AP_SSID_2=%s'", |
| 5823 | dut->ap_ssid); |
| 5824 | run_system(dut, buf); |
| 5825 | |
| 5826 | switch (dut->ap_key_mgmt) { |
| 5827 | case AP_OPEN: |
| 5828 | if (dut->ap_cipher == AP_WEP) { |
| 5829 | run_system(dut, "cfg -a AP_SECMODE_2=WEP"); |
| 5830 | run_system(dut, "cfg -a AP_SECFILE_2=NONE"); |
| 5831 | /* shared auth mode not supported */ |
| 5832 | run_system(dut, "cfg -a AP_WEP_MODE_0=1"); |
| 5833 | run_system(dut, "cfg -a AP_WEP_MODE_1=1"); |
| 5834 | snprintf(buf, sizeof(buf), |
| 5835 | "cfg -a WEP_RADIO_NUM0_KEY_1=%s", |
| 5836 | dut->ap_wepkey); |
| 5837 | run_system(dut, buf); |
| 5838 | snprintf(buf, sizeof(buf), |
| 5839 | "cfg -a WEP_RADIO_NUM1_KEY_1=%s", |
| 5840 | dut->ap_wepkey); |
| 5841 | run_system(dut, buf); |
| 5842 | } else { |
| 5843 | run_system(dut, "cfg -a AP_SECMODE_2=None"); |
| 5844 | } |
| 5845 | break; |
| 5846 | case AP_WPA2_PSK: |
| 5847 | case AP_WPA2_PSK_MIXED: |
| 5848 | case AP_WPA_PSK: |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 5849 | case AP_WPA2_SAE: |
| 5850 | case AP_WPA2_PSK_SAE: |
| 5851 | if (dut->ap_key_mgmt == AP_WPA2_PSK || |
| 5852 | dut->ap_key_mgmt == AP_WPA2_SAE || |
| 5853 | dut->ap_key_mgmt == AP_WPA2_PSK_SAE) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5854 | run_system(dut, "cfg -a AP_WPA_2=2"); |
| 5855 | else if (dut->ap_key_mgmt == AP_WPA2_PSK_MIXED) |
| 5856 | run_system(dut, "cfg -a AP_WPA_2=3"); |
| 5857 | else |
| 5858 | run_system(dut, "cfg -a AP_WPA_2=1"); |
| 5859 | // run_system(dut, "cfg -a AP_WPA_2=2"); |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 5860 | /* TODO: SAE configuration */ |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5861 | run_system(dut, "cfg -a AP_SECMODE_2=WPA"); |
| 5862 | run_system(dut, "cfg -a AP_SECFILE_2=PSK"); |
| 5863 | snprintf(buf, sizeof(buf), "cfg -a 'PSK_KEY_2=%s'", |
| 5864 | dut->ap_passphrase); |
| 5865 | run_system(dut, buf); |
| 5866 | if (dut->ap_cipher == AP_CCMP_TKIP) |
| 5867 | run_system(dut, "cfg -a AP_CYPHER_2=\"CCMP TKIP\""); |
| 5868 | else if (dut->ap_cipher == AP_TKIP) |
| 5869 | run_system(dut, "cfg -a AP_CYPHER_2=TKIP"); |
| 5870 | else |
| 5871 | run_system(dut, "cfg -a AP_CYPHER_2=CCMP"); |
| 5872 | break; |
| 5873 | case AP_WPA2_EAP: |
| 5874 | case AP_WPA2_EAP_MIXED: |
| 5875 | case AP_WPA_EAP: |
| 5876 | if (dut->ap_key_mgmt == AP_WPA2_EAP) |
| 5877 | run_system(dut, "cfg -a AP_WPA_2=2"); |
| 5878 | else if (dut->ap_key_mgmt == AP_WPA2_EAP_MIXED) |
| 5879 | run_system(dut, "cfg -a AP_WPA_2=3"); |
| 5880 | else |
| 5881 | run_system(dut, "cfg -a AP_WPA_2=1"); |
| 5882 | run_system(dut, "cfg -a AP_SECMODE_2=WPA"); |
| 5883 | run_system(dut, "cfg -a AP_SECFILE_2=EAP"); |
| 5884 | if (dut->ap_cipher == AP_CCMP_TKIP) |
| 5885 | run_system(dut, "cfg -a AP_CYPHER_2=\"CCMP TKIP\""); |
| 5886 | else if (dut->ap_cipher == AP_TKIP) |
| 5887 | run_system(dut, "cfg -a AP_CYPHER_2=TKIP"); |
| 5888 | else |
| 5889 | run_system(dut, "cfg -a AP_CYPHER_2=CCMP"); |
| 5890 | |
| 5891 | snprintf(buf, sizeof(buf), "cfg -a AP_AUTH_SERVER_2=%s", |
| 5892 | dut->ap_radius_ipaddr); |
| 5893 | run_system(dut, buf); |
| 5894 | snprintf(buf, sizeof(buf), "cfg -a AP_AUTH_PORT_2=%d", |
| 5895 | dut->ap_radius_port); |
| 5896 | run_system(dut, buf); |
| 5897 | snprintf(buf, sizeof(buf), "cfg -a AP_AUTH_SECRET_2=%s", |
| 5898 | dut->ap_radius_password); |
| 5899 | run_system(dut, buf); |
| 5900 | break; |
Jouni Malinen | ad395a2 | 2017-09-01 21:13:46 +0300 | [diff] [blame] | 5901 | case AP_SUITEB: |
| 5902 | /* TODO */ |
| 5903 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5904 | "SuiteB not supported"); |
| 5905 | break; |
Jouni Malinen | 147b3c3 | 2017-10-09 16:51:54 +0300 | [diff] [blame] | 5906 | case AP_WPA2_OWE: |
| 5907 | /* TODO */ |
| 5908 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5909 | "OWE not supported"); |
| 5910 | break; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5911 | } |
| 5912 | |
| 5913 | /* wifi0 settings in case of dual */ |
| 5914 | run_system(dut, "cfg -a AP_RADIO_ID=0"); |
| 5915 | run_system(dut, "cfg -a AP_PRIMARY_CH=6"); |
| 5916 | run_system(dut, "cfg -a AP_STARTMODE=dual"); |
| 5917 | run_system(dut, "cfg -a AP_CHMODE=11NGHT40PLUS"); |
| 5918 | run_system(dut, "cfg -a TX_CHAINMASK=7"); |
| 5919 | run_system(dut, "cfg -a RX_CHAINMASK=7"); |
| 5920 | } |
| 5921 | |
| 5922 | switch (dut->ap_pmf) { |
| 5923 | case AP_PMF_DISABLED: |
| 5924 | snprintf(buf, sizeof(buf), "cfg -a AP_PMF=0"); |
| 5925 | run_system(dut, buf); |
| 5926 | break; |
| 5927 | case AP_PMF_OPTIONAL: |
| 5928 | snprintf(buf, sizeof(buf), "cfg -a AP_PMF=1"); |
| 5929 | run_system(dut, buf); |
| 5930 | break; |
| 5931 | case AP_PMF_REQUIRED: |
| 5932 | snprintf(buf, sizeof(buf), "cfg -a AP_PMF=2"); |
| 5933 | run_system(dut, buf); |
| 5934 | break; |
| 5935 | } |
| 5936 | if (dut->ap_add_sha256) { |
| 5937 | snprintf(buf, sizeof(buf), "cfg -a AP_WPA_SHA256=1"); |
| 5938 | run_system(dut, buf); |
| 5939 | } else { |
| 5940 | snprintf(buf, sizeof(buf), "cfg -r AP_WPA_SHA256"); |
| 5941 | run_system(dut, buf); |
| 5942 | } |
| 5943 | |
| 5944 | if (dut->ap_hs2) |
| 5945 | run_system(dut, "cfg -a AP_HOTSPOT=1"); |
| 5946 | else |
| 5947 | run_system(dut, "cfg -r AP_HOTSPOT"); |
| 5948 | |
| 5949 | if (dut->ap_interworking) { |
| 5950 | snprintf(buf, sizeof(buf), "cfg -a AP_HOTSPOT_ANT=%d", |
| 5951 | dut->ap_access_net_type); |
| 5952 | run_system(dut, buf); |
| 5953 | snprintf(buf, sizeof(buf), "cfg -a AP_HOTSPOT_INTERNET=%d", |
| 5954 | dut->ap_internet); |
| 5955 | run_system(dut, buf); |
| 5956 | snprintf(buf, sizeof(buf), "cfg -a AP_HOTSPOT_VENUEGROUP=%d", |
| 5957 | dut->ap_venue_group); |
| 5958 | run_system(dut, buf); |
| 5959 | snprintf(buf, sizeof(buf), "cfg -a AP_HOTSPOT_VENUETYPE=%d", |
| 5960 | dut->ap_venue_type); |
| 5961 | run_system(dut, buf); |
| 5962 | snprintf(buf, sizeof(buf), "cfg -a AP_HOTSPOT_HESSID=%s", |
| 5963 | dut->ap_hessid); |
| 5964 | run_system(dut, buf); |
| 5965 | |
| 5966 | if (dut->ap_roaming_cons[0]) { |
| 5967 | char *second, *rc; |
| 5968 | rc = strdup(dut->ap_roaming_cons); |
| 5969 | if (rc == NULL) |
| 5970 | return 0; |
| 5971 | |
| 5972 | second = strchr(rc, ';'); |
| 5973 | if (second) |
| 5974 | *second++ = '\0'; |
| 5975 | |
| 5976 | snprintf(buf, sizeof(buf), |
| 5977 | "cfg -a AP_HOTSPOT_ROAMINGCONSORTIUM=%s", rc); |
| 5978 | run_system(dut, buf); |
| 5979 | |
| 5980 | if (second) { |
| 5981 | snprintf(buf, sizeof(buf), |
| 5982 | "cfg -a AP_HOTSPOT_ROAMINGCONSORTIUM2" |
| 5983 | "=%s", second); |
| 5984 | run_system(dut, buf); |
| 5985 | } |
| 5986 | free(rc); |
| 5987 | } else { |
| 5988 | run_system(dut, "cfg -r AP_HOTSPOT_ROAMINGCONSORTIUM"); |
| 5989 | run_system(dut, |
| 5990 | "cfg -r AP_HOTSPOT_ROAMINGCONSORTIUM2"); |
| 5991 | } |
| 5992 | } else { |
| 5993 | run_system(dut, "cfg -r AP_HOTSPOT_ANT"); |
| 5994 | run_system(dut, "cfg -r AP_HOTSPOT_INTERNET"); |
| 5995 | run_system(dut, "cfg -r AP_HOTSPOT_VENUEGROUP"); |
| 5996 | run_system(dut, "cfg -r AP_HOTSPOT_VENUETYPE"); |
| 5997 | run_system(dut, "cfg -r AP_HOTSPOT_HESSID"); |
| 5998 | run_system(dut, "cfg -r AP_HOTSPOT_ROAMINGCONSORTIUM"); |
| 5999 | run_system(dut, "cfg -r AP_HOTSPOT_ROAMINGCONSORTIUM2"); |
| 6000 | } |
| 6001 | |
| 6002 | if (dut->ap_proxy_arp) |
| 6003 | run_system(dut, "cfg -a IEEE80211V_PROXYARP=1"); |
| 6004 | else |
| 6005 | run_system(dut, "cfg -a IEEE80211V_PROXYARP=0"); |
| 6006 | if (dut->ap_dgaf_disable) |
| 6007 | run_system(dut, "cfg -a AP_HOTSPOT_DISABLE_DGAF=1"); |
| 6008 | else |
| 6009 | run_system(dut, "cfg -r AP_HOTSPOT_DISABLE_DGAF"); |
| 6010 | |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 6011 | if (strlen(dut->ap_tag_ssid[0])) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6012 | snprintf(buf, sizeof(buf), |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 6013 | "cfg -a AP_SSID_2=%s", dut->ap_tag_ssid[0]); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6014 | run_system(dut, buf); |
| 6015 | |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 6016 | if (dut->ap_tag_key_mgmt[0] == AP2_OSEN) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6017 | run_system(dut, "cfg -a AP_SECMODE_2=WPA"); |
| 6018 | run_system(dut, "cfg -a AP_SECFILE_2=OSEN"); |
| 6019 | |
| 6020 | snprintf(buf, sizeof(buf), "cfg -a AP_AUTH_SERVER_2=%s", |
| 6021 | dut->ap2_radius_ipaddr); |
| 6022 | run_system(dut, buf); |
| 6023 | |
| 6024 | snprintf(buf, sizeof(buf), "cfg -a AP_AUTH_PORT_2=%d", |
| 6025 | dut->ap2_radius_port); |
| 6026 | run_system(dut, buf); |
| 6027 | |
| 6028 | snprintf(buf, sizeof(buf), "cfg -a AP_AUTH_SECRET_2=%s", |
| 6029 | dut->ap2_radius_password); |
| 6030 | run_system(dut, buf); |
| 6031 | } else { |
| 6032 | run_system(dut, "cfg -a AP_SECMODE_2=None"); |
| 6033 | run_system(dut, "cfg -r AP_AUTH_SERVER_2"); |
| 6034 | run_system(dut, "cfg -r AP_AUTH_PORT_2"); |
| 6035 | run_system(dut, "cfg -r AP_AUTH_SECRET_2"); |
| 6036 | } |
| 6037 | |
| 6038 | run_system(dut, "cfg -a AP_STARTMODE=multi"); |
| 6039 | } |
| 6040 | |
| 6041 | run_system(dut, "cfg -c"); |
| 6042 | |
| 6043 | sigma_dut_print(dut, DUT_MSG_INFO, "Starting AP"); |
| 6044 | if (system("apup") != 0) { |
| 6045 | /* to be debugged why apup returns error |
| 6046 | send_resp(dut, conn, SIGMA_ERROR, |
| 6047 | "errorCode,apup failed"); |
| 6048 | return 0; |
| 6049 | */ |
| 6050 | } |
| 6051 | sigma_dut_print(dut, DUT_MSG_INFO, "AP started"); |
| 6052 | |
| 6053 | if (dut->ap_key_mgmt != AP_OPEN) { |
| 6054 | int res; |
| 6055 | /* allow some time for hostapd to start before returning |
| 6056 | * success */ |
| 6057 | usleep(500000); |
| 6058 | if (run_hostapd_cli(dut, "ping") != 0) { |
| 6059 | send_resp(dut, conn, SIGMA_ERROR, |
| 6060 | "errorCode,Failed to talk to hostapd"); |
| 6061 | return 0; |
| 6062 | } |
| 6063 | |
| 6064 | if (dut->ap_hs2 && !dut->ap_anqpserver) { |
| 6065 | /* the cfg app doesn't like ";" in the variables */ |
| 6066 | res = ath_ap_append_hostapd_conf(dut); |
| 6067 | if (res < 0) |
| 6068 | return res; |
| 6069 | |
| 6070 | /* wait for hostapd to be ready */ |
| 6071 | usleep(500000); |
| 6072 | if (run_hostapd_cli(dut, "ping") != 0) { |
| 6073 | send_resp(dut, conn, SIGMA_ERROR, |
| 6074 | "errorCode,Failed to talk to " |
| 6075 | "hostapd"); |
| 6076 | return 0; |
| 6077 | } |
| 6078 | } |
| 6079 | } |
| 6080 | |
| 6081 | ath_ap_set_params(dut); |
| 6082 | |
| 6083 | if (dut->ap_anqpserver) |
| 6084 | return cmd_ath_ap_anqpserver_start(dut); |
| 6085 | |
| 6086 | if (dut->ap2_proxy_arp) |
| 6087 | run_system(dut, "iwpriv ath1 proxy_arp 1"); |
| 6088 | |
| 6089 | if (dut->ap_allow_vht_wep || dut->ap_allow_vht_tkip) { |
| 6090 | snprintf(buf, sizeof(buf), "iwpriv %s htweptkip 1", ifname); |
| 6091 | if (system(buf) != 0) { |
| 6092 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 6093 | "iwpriv htweptkip failed"); |
| 6094 | } |
| 6095 | } |
| 6096 | |
| 6097 | return 1; |
| 6098 | } |
| 6099 | |
| 6100 | |
| 6101 | static int set_ebtables_proxy_arp(struct sigma_dut *dut, const char *chain, |
| 6102 | const char *ifname) |
| 6103 | { |
| 6104 | char buf[200]; |
| 6105 | |
| 6106 | if (!chain || !ifname) |
| 6107 | return -2; |
| 6108 | |
| 6109 | snprintf(buf, sizeof(buf), "ebtables -P %s ACCEPT", chain); |
| 6110 | if (system(buf) != 0) { |
| 6111 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 6112 | "Failed to set ebtables rules, RULE-1, %s", |
| 6113 | chain); |
| 6114 | return -2; |
| 6115 | } |
| 6116 | |
| 6117 | snprintf(buf, sizeof(buf), |
| 6118 | "ebtables -A %s -p ARP -d Broadcast -o %s -j DROP", |
| 6119 | chain, ifname); |
| 6120 | if (system(buf) != 0) { |
| 6121 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 6122 | "Failed to set ebtables rules, RULE-2, %s", |
| 6123 | chain); |
| 6124 | return -2; |
| 6125 | } |
| 6126 | |
| 6127 | snprintf(buf, sizeof(buf), |
| 6128 | "ebtables -A %s -d Multicast -p IPv6 --ip6-protocol ipv6-icmp --ip6-icmp-type neighbor-solicitation -o %s -j DROP", |
| 6129 | chain, ifname); |
| 6130 | if (system(buf) != 0) { |
| 6131 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 6132 | "Failed to set ebtables rules, RULE-3, %s", |
| 6133 | chain); |
| 6134 | return -2; |
| 6135 | } |
| 6136 | |
| 6137 | snprintf(buf, sizeof(buf), |
| 6138 | "ebtables -A %s -d Multicast -p IPv6 --ip6-protocol ipv6-icmp --ip6-icmp-type neighbor-advertisement -o %s -j DROP", |
| 6139 | chain, ifname); |
| 6140 | if (system(buf) != 0) { |
| 6141 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 6142 | "Failed to set ebtables rules, RULE-4, %s", |
| 6143 | chain); |
| 6144 | return -2; |
| 6145 | } |
| 6146 | |
| 6147 | return 0; |
| 6148 | } |
| 6149 | |
| 6150 | |
| 6151 | static int set_ebtables_disable_dgaf(struct sigma_dut *dut, |
| 6152 | const char *chain, |
| 6153 | const char *ifname) |
| 6154 | { |
| 6155 | char buf[200]; |
| 6156 | |
| 6157 | if (!chain || !ifname) |
| 6158 | return -2; |
| 6159 | |
| 6160 | snprintf(buf, sizeof(buf), "ebtables -P %s ACCEPT", chain); |
| 6161 | if (system(buf) != 0) { |
| 6162 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 6163 | "Failed to set ebtables rules, RULE-5, %s", |
| 6164 | chain); |
| 6165 | return -2; |
| 6166 | } |
| 6167 | |
| 6168 | snprintf(buf, sizeof(buf), |
| 6169 | "ebtables -A %s -p ARP -d Broadcast -o %s -j DROP", |
| 6170 | chain, ifname); |
| 6171 | if (system(buf) != 0) { |
| 6172 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 6173 | "Failed to set ebtables rules, RULE-6, %s", |
| 6174 | chain); |
| 6175 | return -2; |
| 6176 | } |
| 6177 | |
| 6178 | snprintf(buf, sizeof(buf), |
| 6179 | "ebtables -A %s -p IPv4 -d Multicast -o %s -j DROP", |
| 6180 | chain, ifname); |
| 6181 | if (system(buf) != 0) { |
| 6182 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 6183 | "Failed to set ebtables rules, RULE-7, %s", |
| 6184 | chain); |
| 6185 | return -2; |
| 6186 | } |
| 6187 | |
| 6188 | snprintf(buf, sizeof(buf), |
| 6189 | "ebtables -A %s -p IPv6 -d Multicast -o %s -j DROP", |
| 6190 | chain, ifname); |
| 6191 | if (system(buf) != 0) { |
| 6192 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 6193 | "Failed to set ebtables rules, RULE-8, %s", |
| 6194 | chain); |
| 6195 | return -2; |
| 6196 | } |
| 6197 | |
| 6198 | return 0; |
| 6199 | } |
| 6200 | |
| 6201 | |
| 6202 | static int check_channel(int channel) |
| 6203 | { |
| 6204 | int channel_list[] = { 36, 40, 44, 48, 52, 60, 64, 100, 104, 108, 112, |
| 6205 | 116, 120, 124, 128, 132, 140, 144, 149, 153, 157, |
| 6206 | 161, 165 }; |
| 6207 | int num_chan = sizeof(channel_list) / sizeof(int); |
| 6208 | int i; |
| 6209 | |
| 6210 | for (i = 0; i < num_chan; i++) { |
| 6211 | if (channel == channel_list[i]) |
| 6212 | return i; |
| 6213 | } |
| 6214 | |
| 6215 | return -1; |
| 6216 | } |
| 6217 | |
| 6218 | |
| 6219 | static int get_oper_centr_freq_seq_idx(int chwidth, int channel) |
| 6220 | { |
| 6221 | int ch_base; |
| 6222 | int period; |
| 6223 | |
| 6224 | if (check_channel(channel) < 0) |
| 6225 | return -1; |
| 6226 | |
| 6227 | if (channel >= 36 && channel <= 64) |
| 6228 | ch_base = 36; |
| 6229 | else if (channel >= 100 && channel <= 144) |
| 6230 | ch_base = 100; |
| 6231 | else |
| 6232 | ch_base = 149; |
| 6233 | |
| 6234 | period = channel % ch_base * 5 / chwidth; |
| 6235 | return ch_base + period * chwidth / 5 + (chwidth - 20) / 10; |
| 6236 | } |
| 6237 | |
| 6238 | |
| 6239 | static int is_ht40plus_chan(int chan) |
| 6240 | { |
| 6241 | return chan == 36 || chan == 44 || chan == 52 || chan == 60 || |
| 6242 | chan == 100 || chan == 108 || chan == 116 || chan == 124 || |
| 6243 | chan == 132 || chan == 149 || chan == 157; |
| 6244 | } |
| 6245 | |
| 6246 | |
| 6247 | static int is_ht40minus_chan(int chan) |
| 6248 | { |
| 6249 | return chan == 40 || chan == 48 || chan == 56 || chan == 64 || |
| 6250 | chan == 104 || chan == 112 || chan == 120 || chan == 128 || |
| 6251 | chan == 136 || chan == 153 || chan == 161; |
| 6252 | } |
| 6253 | |
| 6254 | |
Mohammed Shafi Shajakhan | b53d8f9 | 2017-02-28 09:05:15 +0530 | [diff] [blame] | 6255 | static int get_5g_channel_freq(int chan) |
| 6256 | { |
| 6257 | return 5000 + chan * 5; |
| 6258 | } |
| 6259 | |
| 6260 | |
Jouni Malinen | 3d633da | 2017-09-14 22:19:21 +0300 | [diff] [blame] | 6261 | static const char * hostapd_cipher_name(enum ap_cipher cipher) |
| 6262 | { |
| 6263 | switch (cipher) { |
| 6264 | case AP_CCMP: |
| 6265 | return "CCMP"; |
| 6266 | case AP_TKIP: |
| 6267 | return "TKIP"; |
| 6268 | case AP_CCMP_TKIP: |
| 6269 | return "CCMP TKIP"; |
| 6270 | case AP_GCMP_256: |
| 6271 | return "GCMP-256"; |
| 6272 | case AP_GCMP_128: |
| 6273 | return "GCMP"; |
| 6274 | case AP_CCMP_256: |
| 6275 | return "CCMP-256"; |
Jouni Malinen | d538c78 | 2017-11-17 12:13:04 +0200 | [diff] [blame] | 6276 | case AP_CCMP_128_GCMP_256: |
| 6277 | return "CCMP GCMP-256"; |
Jouni Malinen | 3d633da | 2017-09-14 22:19:21 +0300 | [diff] [blame] | 6278 | default: |
| 6279 | return "UNKNOWN"; |
| 6280 | } |
| 6281 | } |
| 6282 | |
| 6283 | |
| 6284 | static const char * |
| 6285 | hostapd_group_mgmt_cipher_name(enum ap_group_mgmt_cipher cipher) |
| 6286 | { |
| 6287 | switch (cipher) { |
| 6288 | case AP_BIP_GMAC_256: |
Jouni Malinen | 57887a2 | 2017-10-10 20:43:25 +0300 | [diff] [blame] | 6289 | return "BIP-GMAC-256"; |
Jouni Malinen | 3d633da | 2017-09-14 22:19:21 +0300 | [diff] [blame] | 6290 | case AP_BIP_CMAC_256: |
| 6291 | return "BIP-CMAC-256"; |
| 6292 | case AP_BIP_GMAC_128: |
| 6293 | return "BIP-GMAC-128"; |
| 6294 | case AP_BIP_CMAC_128: |
| 6295 | return "AES-128-CMAC"; |
| 6296 | default: |
| 6297 | return "UNKNOWN"; |
| 6298 | } |
| 6299 | } |
| 6300 | |
| 6301 | |
Jouni Malinen | a326d7b | 2017-09-04 13:46:02 +0300 | [diff] [blame] | 6302 | int cmd_ap_config_commit(struct sigma_dut *dut, struct sigma_conn *conn, |
| 6303 | struct sigma_cmd *cmd) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6304 | { |
| 6305 | /* const char *name = get_param(cmd, "NAME"); */ |
| 6306 | FILE *f; |
| 6307 | const char *ifname; |
| 6308 | char buf[500]; |
| 6309 | char path[100]; |
| 6310 | enum driver_type drv; |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 6311 | const char *key_mgmt; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6312 | |
| 6313 | drv = get_driver_type(); |
| 6314 | |
| 6315 | if (dut->mode == SIGMA_MODE_STATION) { |
| 6316 | stop_sta_mode(dut); |
| 6317 | sleep(1); |
| 6318 | } |
| 6319 | |
| 6320 | if (dut->mode == SIGMA_MODE_SNIFFER && dut->sniffer_ifname) { |
| 6321 | snprintf(buf, sizeof(buf), "ifconfig %s down", |
| 6322 | dut->sniffer_ifname); |
| 6323 | if (system(buf) != 0) { |
| 6324 | sigma_dut_print(dut, DUT_MSG_INFO, |
| 6325 | "Failed to run '%s'", buf); |
| 6326 | } |
| 6327 | snprintf(buf, sizeof(buf), "iw dev %s set type station", |
| 6328 | dut->sniffer_ifname); |
| 6329 | if (system(buf) != 0) { |
| 6330 | sigma_dut_print(dut, DUT_MSG_INFO, |
| 6331 | "Failed to run '%s'", buf); |
| 6332 | } |
| 6333 | } |
| 6334 | |
| 6335 | dut->mode = SIGMA_MODE_AP; |
| 6336 | |
| 6337 | if (drv == DRIVER_ATHEROS) |
| 6338 | return cmd_ath_ap_config_commit(dut, conn, cmd); |
| 6339 | if (drv == DRIVER_WCN) |
| 6340 | return cmd_wcn_ap_config_commit(dut, conn, cmd); |
| 6341 | if (drv == DRIVER_OPENWRT) |
| 6342 | return cmd_owrt_ap_config_commit(dut, conn, cmd); |
| 6343 | |
| 6344 | f = fopen(SIGMA_TMPDIR "/sigma_dut-ap.conf", "w"); |
| 6345 | if (f == NULL) { |
| 6346 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 6347 | "%s: Failed to open sigma_dut-ap.conf", |
| 6348 | __func__); |
| 6349 | return -2; |
| 6350 | } |
| 6351 | switch (dut->ap_mode) { |
| 6352 | case AP_11g: |
| 6353 | case AP_11b: |
| 6354 | case AP_11ng: |
Pradeep Reddy Potteti | 08eaeba | 2017-06-14 12:43:19 +0530 | [diff] [blame] | 6355 | ifname = (drv == DRIVER_MAC80211) ? "wlan0" : "ath0"; |
| 6356 | if ((drv == DRIVER_QNXNTO || drv == DRIVER_LINUX_WCN) && |
| 6357 | sigma_main_ifname) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6358 | ifname = sigma_main_ifname; |
| 6359 | fprintf(f, "hw_mode=g\n"); |
| 6360 | break; |
| 6361 | case AP_11a: |
| 6362 | case AP_11na: |
| 6363 | case AP_11ac: |
Pradeep Reddy Potteti | 08eaeba | 2017-06-14 12:43:19 +0530 | [diff] [blame] | 6364 | if (drv == DRIVER_QNXNTO || drv == DRIVER_LINUX_WCN) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6365 | if (sigma_main_ifname) |
| 6366 | ifname = sigma_main_ifname; |
| 6367 | else |
| 6368 | ifname = "wlan0"; |
Pradeep Reddy Potteti | 08eaeba | 2017-06-14 12:43:19 +0530 | [diff] [blame] | 6369 | } else if (drv == DRIVER_MAC80211) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6370 | if (if_nametoindex("wlan1") > 0) |
| 6371 | ifname = "wlan1"; |
| 6372 | else |
| 6373 | ifname = "wlan0"; |
| 6374 | } else { |
| 6375 | ifname = get_main_ifname(); |
| 6376 | } |
| 6377 | fprintf(f, "hw_mode=a\n"); |
| 6378 | break; |
| 6379 | default: |
| 6380 | fclose(f); |
| 6381 | return -1; |
| 6382 | } |
Jouni Malinen | d6bf1b4 | 2017-06-23 17:51:01 +0300 | [diff] [blame] | 6383 | if (dut->hostapd_ifname) |
| 6384 | ifname = dut->hostapd_ifname; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6385 | |
Sreelakshmi Konamki | b692f10 | 2016-04-26 19:47:00 +0530 | [diff] [blame] | 6386 | if (drv == DRIVER_MAC80211 || drv == DRIVER_LINUX_WCN) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6387 | fprintf(f, "driver=nl80211\n"); |
| 6388 | |
Sreelakshmi Konamki | b692f10 | 2016-04-26 19:47:00 +0530 | [diff] [blame] | 6389 | if ((drv == DRIVER_MAC80211 || drv == DRIVER_QNXNTO || |
| 6390 | drv == DRIVER_LINUX_WCN) && |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6391 | (dut->ap_mode == AP_11ng || dut->ap_mode == AP_11na)) { |
Tamizh chelvam | 431c600 | 2017-03-07 17:07:16 +0530 | [diff] [blame] | 6392 | int ht40plus = 0, ht40minus = 0, tx_stbc = 0; |
| 6393 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6394 | fprintf(f, "ieee80211n=1\n"); |
Pradeep Reddy Potteti | bf8af29 | 2017-02-15 15:28:39 +0530 | [diff] [blame] | 6395 | if (dut->ap_mode == AP_11ng && |
| 6396 | (dut->ap_chwidth == AP_40 || |
| 6397 | (dut->ap_chwidth == AP_AUTO && |
| 6398 | dut->default_11ng_ap_chwidth == AP_40))) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6399 | if (dut->ap_channel >= 1 && dut->ap_channel <= 7) |
Tamizh chelvam | 431c600 | 2017-03-07 17:07:16 +0530 | [diff] [blame] | 6400 | ht40plus = 1; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6401 | else if (dut->ap_channel >= 8 && dut->ap_channel <= 11) |
Tamizh chelvam | 431c600 | 2017-03-07 17:07:16 +0530 | [diff] [blame] | 6402 | ht40minus = 1; |
| 6403 | fprintf(f, "obss_interval=300\n"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6404 | } |
| 6405 | |
| 6406 | /* configure ht_capab based on channel width */ |
| 6407 | if (dut->ap_mode == AP_11na && |
| 6408 | (dut->ap_chwidth == AP_40 || |
| 6409 | (dut->ap_chwidth == AP_AUTO && |
Pradeep Reddy Potteti | bf8af29 | 2017-02-15 15:28:39 +0530 | [diff] [blame] | 6410 | dut->default_11na_ap_chwidth == AP_40))) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6411 | if (is_ht40plus_chan(dut->ap_channel)) |
Tamizh chelvam | 431c600 | 2017-03-07 17:07:16 +0530 | [diff] [blame] | 6412 | ht40plus = 1; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6413 | else if (is_ht40minus_chan(dut->ap_channel)) |
Tamizh chelvam | 431c600 | 2017-03-07 17:07:16 +0530 | [diff] [blame] | 6414 | ht40minus = 1; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6415 | } |
Mohammed Shafi Shajakhan | 31d8a15 | 2016-06-02 20:10:55 +0530 | [diff] [blame] | 6416 | |
| 6417 | if (dut->ap_tx_stbc) |
Tamizh chelvam | 431c600 | 2017-03-07 17:07:16 +0530 | [diff] [blame] | 6418 | tx_stbc = 1; |
Mohammed Shafi Shajakhan | 31d8a15 | 2016-06-02 20:10:55 +0530 | [diff] [blame] | 6419 | |
Pradeep Reddy Potteti | 4b0cdee | 2017-03-15 12:37:33 +0530 | [diff] [blame] | 6420 | /* Overwrite the ht_capab with offset value if configured */ |
| 6421 | if (dut->ap_chwidth == AP_40 && |
| 6422 | dut->ap_chwidth_offset == SEC_CH_40ABOVE) { |
| 6423 | ht40plus = 1; |
| 6424 | ht40minus = 0; |
| 6425 | } else if (dut->ap_chwidth == AP_40 && |
| 6426 | dut->ap_chwidth_offset == SEC_CH_40BELOW) { |
| 6427 | ht40minus = 1; |
| 6428 | ht40plus = 0; |
| 6429 | } |
| 6430 | |
Tamizh chelvam | 431c600 | 2017-03-07 17:07:16 +0530 | [diff] [blame] | 6431 | fprintf(f, "ht_capab=%s%s%s\n", |
| 6432 | ht40plus ? "[HT40+]" : "", |
| 6433 | ht40minus ? "[HT40-]" : "", |
| 6434 | tx_stbc ? "[TX-STBC]" : ""); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6435 | } |
| 6436 | |
Sreelakshmi Konamki | b692f10 | 2016-04-26 19:47:00 +0530 | [diff] [blame] | 6437 | if ((drv == DRIVER_MAC80211 || drv == DRIVER_QNXNTO || |
| 6438 | drv == DRIVER_LINUX_WCN) && |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6439 | dut->ap_mode == AP_11ac) { |
| 6440 | fprintf(f, "ieee80211ac=1\n" |
| 6441 | "ieee80211n=1\n" |
| 6442 | "ht_capab=[HT40+]\n"); |
| 6443 | } |
| 6444 | |
Sreelakshmi Konamki | b692f10 | 2016-04-26 19:47:00 +0530 | [diff] [blame] | 6445 | if ((drv == DRIVER_MAC80211 || drv == DRIVER_QNXNTO || |
| 6446 | drv == DRIVER_LINUX_WCN) && |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6447 | (dut->ap_mode == AP_11ac || dut->ap_mode == AP_11na)) { |
| 6448 | if (dut->ap_countrycode[0]) { |
| 6449 | fprintf(f, "country_code=%s\n", dut->ap_countrycode); |
| 6450 | fprintf(f, "ieee80211d=1\n"); |
| 6451 | fprintf(f, "ieee80211h=1\n"); |
| 6452 | } |
| 6453 | } |
| 6454 | |
| 6455 | fprintf(f, "interface=%s\n", ifname); |
| 6456 | if (dut->bridge) |
| 6457 | fprintf(f, "bridge=%s\n", dut->bridge); |
| 6458 | fprintf(f, "channel=%d\n", dut->ap_channel); |
| 6459 | |
| 6460 | if (sigma_hapd_ctrl) |
| 6461 | fprintf(f, "ctrl_interface=%s\n", sigma_hapd_ctrl); |
| 6462 | else |
| 6463 | fprintf(f, "ctrl_interface=/var/run/hostapd\n"); |
| 6464 | |
| 6465 | if (dut->ap_ssid[0]) |
| 6466 | fprintf(f, "ssid=%s\n", dut->ap_ssid); |
| 6467 | else |
| 6468 | fprintf(f, "ssid=QCA AP OOB\n"); |
| 6469 | if (dut->ap_bcnint) |
| 6470 | fprintf(f, "beacon_int=%d\n", dut->ap_bcnint); |
| 6471 | |
| 6472 | switch (dut->ap_key_mgmt) { |
| 6473 | case AP_OPEN: |
| 6474 | if (dut->ap_cipher == AP_WEP) |
| 6475 | fprintf(f, "wep_key0=%s\n", dut->ap_wepkey); |
| 6476 | break; |
| 6477 | case AP_WPA2_PSK: |
| 6478 | case AP_WPA2_PSK_MIXED: |
| 6479 | case AP_WPA_PSK: |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 6480 | case AP_WPA2_SAE: |
| 6481 | case AP_WPA2_PSK_SAE: |
| 6482 | if (dut->ap_key_mgmt == AP_WPA2_PSK || |
| 6483 | dut->ap_key_mgmt == AP_WPA2_SAE || |
| 6484 | dut->ap_key_mgmt == AP_WPA2_PSK_SAE) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6485 | fprintf(f, "wpa=2\n"); |
| 6486 | else if (dut->ap_key_mgmt == AP_WPA2_PSK_MIXED) |
| 6487 | fprintf(f, "wpa=3\n"); |
| 6488 | else |
| 6489 | fprintf(f, "wpa=1\n"); |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 6490 | if (dut->ap_key_mgmt == AP_WPA2_SAE) |
| 6491 | key_mgmt = "SAE"; |
| 6492 | else if (dut->ap_key_mgmt == AP_WPA2_PSK_SAE) |
| 6493 | key_mgmt = "WPA-PSK SAE"; |
| 6494 | else |
| 6495 | key_mgmt = "WPA-PSK"; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6496 | switch (dut->ap_pmf) { |
| 6497 | case AP_PMF_DISABLED: |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 6498 | fprintf(f, "wpa_key_mgmt=%s%s\n", key_mgmt, |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6499 | dut->ap_add_sha256 ? " WPA-PSK-SHA256" : ""); |
| 6500 | break; |
| 6501 | case AP_PMF_OPTIONAL: |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 6502 | fprintf(f, "wpa_key_mgmt=%s%s\n", key_mgmt, |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6503 | dut->ap_add_sha256 ? " WPA-PSK-SHA256" : ""); |
| 6504 | break; |
| 6505 | case AP_PMF_REQUIRED: |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 6506 | if (dut->ap_key_mgmt == AP_WPA2_SAE) |
| 6507 | key_mgmt = "SAE"; |
| 6508 | else if (dut->ap_key_mgmt == AP_WPA2_PSK_SAE) |
| 6509 | key_mgmt = "WPA-PSK-SHA256 SAE"; |
| 6510 | else |
| 6511 | key_mgmt = "WPA-PSK-SHA256"; |
| 6512 | fprintf(f, "wpa_key_mgmt=%s\n", key_mgmt); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6513 | break; |
| 6514 | } |
Jouni Malinen | 2ba2449 | 2017-11-17 12:43:59 +0200 | [diff] [blame] | 6515 | fprintf(f, "wpa_pairwise=%s\n", |
| 6516 | hostapd_cipher_name(dut->ap_cipher)); |
| 6517 | if (dut->ap_group_cipher != AP_NO_GROUP_CIPHER_SET) |
| 6518 | fprintf(f, "group_cipher=%s\n", |
| 6519 | hostapd_cipher_name(dut->ap_group_cipher)); |
Jouni Malinen | 2126f42 | 2017-10-11 23:24:33 +0300 | [diff] [blame] | 6520 | if (dut->ap_key_mgmt == AP_WPA2_SAE) |
| 6521 | fprintf(f, "sae_password=%s\n", dut->ap_passphrase); |
Jouni Malinen | 6337062 | 2017-11-18 17:47:13 +0200 | [diff] [blame] | 6522 | else if (!dut->ap_passphrase[0] && dut->ap_psk[0]) |
| 6523 | fprintf(f, "wpa_psk=%s", dut->ap_psk); |
Jouni Malinen | 2126f42 | 2017-10-11 23:24:33 +0300 | [diff] [blame] | 6524 | else |
| 6525 | fprintf(f, "wpa_passphrase=%s\n", dut->ap_passphrase); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6526 | break; |
| 6527 | case AP_WPA2_EAP: |
| 6528 | case AP_WPA2_EAP_MIXED: |
| 6529 | case AP_WPA_EAP: |
| 6530 | fprintf(f, "ieee8021x=1\n"); |
| 6531 | if (dut->ap_key_mgmt == AP_WPA2_EAP) |
| 6532 | fprintf(f, "wpa=2\n"); |
| 6533 | else if (dut->ap_key_mgmt == AP_WPA2_EAP_MIXED) |
| 6534 | fprintf(f, "wpa=3\n"); |
| 6535 | else |
| 6536 | fprintf(f, "wpa=1\n"); |
| 6537 | switch (dut->ap_pmf) { |
| 6538 | case AP_PMF_DISABLED: |
| 6539 | fprintf(f, "wpa_key_mgmt=WPA-EAP%s\n", |
| 6540 | dut->ap_add_sha256 ? " WPA-EAP-SHA256" : ""); |
| 6541 | break; |
| 6542 | case AP_PMF_OPTIONAL: |
| 6543 | fprintf(f, "wpa_key_mgmt=WPA-EAP%s\n", |
| 6544 | dut->ap_add_sha256 ? " WPA-EAP-SHA256" : ""); |
| 6545 | break; |
| 6546 | case AP_PMF_REQUIRED: |
| 6547 | fprintf(f, "wpa_key_mgmt=WPA-EAP-SHA256\n"); |
| 6548 | break; |
| 6549 | } |
Jouni Malinen | 2ba2449 | 2017-11-17 12:43:59 +0200 | [diff] [blame] | 6550 | fprintf(f, "wpa_pairwise=%s\n", |
| 6551 | hostapd_cipher_name(dut->ap_cipher)); |
| 6552 | if (dut->ap_group_cipher != AP_NO_GROUP_CIPHER_SET) |
| 6553 | fprintf(f, "group_cipher=%s\n", |
| 6554 | hostapd_cipher_name(dut->ap_group_cipher)); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6555 | fprintf(f, "auth_server_addr=%s\n", dut->ap_radius_ipaddr); |
| 6556 | if (dut->ap_radius_port) |
| 6557 | fprintf(f, "auth_server_port=%d\n", |
| 6558 | dut->ap_radius_port); |
| 6559 | fprintf(f, "auth_server_shared_secret=%s\n", |
| 6560 | dut->ap_radius_password); |
| 6561 | break; |
Jouni Malinen | ad395a2 | 2017-09-01 21:13:46 +0300 | [diff] [blame] | 6562 | case AP_SUITEB: |
| 6563 | fprintf(f, "ieee8021x=1\n"); |
| 6564 | fprintf(f, "wpa=2\n"); |
| 6565 | fprintf(f, "wpa_key_mgmt=WPA-EAP-SUITE-B-192\n"); |
Jouni Malinen | 3d633da | 2017-09-14 22:19:21 +0300 | [diff] [blame] | 6566 | fprintf(f, "wpa_pairwise=%s\n", |
| 6567 | hostapd_cipher_name(dut->ap_cipher)); |
Jouni Malinen | 2ba2449 | 2017-11-17 12:43:59 +0200 | [diff] [blame] | 6568 | if (dut->ap_group_cipher != AP_NO_GROUP_CIPHER_SET) |
| 6569 | fprintf(f, "group_cipher=%s\n", |
| 6570 | hostapd_cipher_name(dut->ap_group_cipher)); |
Jouni Malinen | 3d633da | 2017-09-14 22:19:21 +0300 | [diff] [blame] | 6571 | if (dut->ap_group_mgmt_cipher != AP_NO_GROUP_MGMT_CIPHER_SET) |
| 6572 | fprintf(f, "group_mgmt_cipher=%s\n", |
| 6573 | hostapd_group_mgmt_cipher_name( |
| 6574 | dut->ap_group_mgmt_cipher)); |
Jouni Malinen | ad395a2 | 2017-09-01 21:13:46 +0300 | [diff] [blame] | 6575 | fprintf(f, "auth_server_addr=%s\n", dut->ap_radius_ipaddr); |
| 6576 | if (dut->ap_radius_port) |
| 6577 | fprintf(f, "auth_server_port=%d\n", |
| 6578 | dut->ap_radius_port); |
| 6579 | fprintf(f, "auth_server_shared_secret=%s\n", |
| 6580 | dut->ap_radius_password); |
| 6581 | break; |
Jouni Malinen | 147b3c3 | 2017-10-09 16:51:54 +0300 | [diff] [blame] | 6582 | case AP_WPA2_OWE: |
| 6583 | fprintf(f, "wpa=2\n"); |
| 6584 | fprintf(f, "wpa_key_mgmt=OWE\n"); |
| 6585 | fprintf(f, "rsn_pairwise=%s\n", |
| 6586 | hostapd_cipher_name(dut->ap_cipher)); |
Jouni Malinen | 72461d4 | 2017-10-10 19:20:45 +0300 | [diff] [blame] | 6587 | if (dut->ap_sae_groups) |
| 6588 | fprintf(f, "owe_groups=%s\n", dut->ap_sae_groups); |
Jouni Malinen | 147b3c3 | 2017-10-09 16:51:54 +0300 | [diff] [blame] | 6589 | break; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6590 | } |
| 6591 | |
Anilkumar Kolli | f0fd599 | 2017-02-23 12:54:01 +0530 | [diff] [blame] | 6592 | if (dut->ap_rsn_preauth) |
| 6593 | fprintf(f, "rsn_preauth=1\n"); |
| 6594 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6595 | switch (dut->ap_pmf) { |
| 6596 | case AP_PMF_DISABLED: |
| 6597 | break; |
| 6598 | case AP_PMF_OPTIONAL: |
| 6599 | fprintf(f, "ieee80211w=1\n"); |
Jouni Malinen | 1287cd7 | 2018-01-04 17:08:01 +0200 | [diff] [blame] | 6600 | if (dut->ap_key_mgmt == AP_WPA2_PSK_SAE) |
| 6601 | fprintf(f, "sae_require_mfp=1\n"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6602 | break; |
| 6603 | case AP_PMF_REQUIRED: |
| 6604 | fprintf(f, "ieee80211w=2\n"); |
| 6605 | break; |
| 6606 | } |
| 6607 | |
Jouni Malinen | 3c367e8 | 2017-06-23 17:01:47 +0300 | [diff] [blame] | 6608 | if (dut->rsne_override) |
| 6609 | fprintf(f, "own_ie_override=%s\n", dut->rsne_override); |
| 6610 | |
Jouni Malinen | 6814313 | 2017-09-02 02:34:08 +0300 | [diff] [blame] | 6611 | if (dut->sae_commit_override) |
| 6612 | fprintf(f, "sae_commit_override=%s\n", |
| 6613 | dut->sae_commit_override); |
| 6614 | |
Jouni Malinen | ed670f4 | 2017-08-31 01:39:28 +0300 | [diff] [blame] | 6615 | if (dut->ap_sae_groups) |
| 6616 | fprintf(f, "sae_groups=%s\n", dut->ap_sae_groups); |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 6617 | |
Jouni Malinen | 2f524ce | 2017-08-31 01:43:29 +0300 | [diff] [blame] | 6618 | if (dut->sae_anti_clogging_threshold >= 0) |
| 6619 | fprintf(f, "sae_anti_clogging_threshold=%d\n", |
| 6620 | dut->sae_anti_clogging_threshold); |
Jouni Malinen | b347db0 | 2017-09-02 01:36:03 +0300 | [diff] [blame] | 6621 | if (dut->sae_reflection) |
| 6622 | fprintf(f, "sae_reflection_attack=1\n"); |
Jouni Malinen | 2f524ce | 2017-08-31 01:43:29 +0300 | [diff] [blame] | 6623 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6624 | if (dut->ap_p2p_mgmt) |
| 6625 | fprintf(f, "manage_p2p=1\n"); |
| 6626 | |
| 6627 | if (dut->ap_tdls_prohibit || dut->ap_l2tif) |
| 6628 | fprintf(f, "tdls_prohibit=1\n"); |
| 6629 | if (dut->ap_tdls_prohibit_chswitch || dut->ap_l2tif) |
| 6630 | fprintf(f, "tdls_prohibit_chan_switch=1\n"); |
| 6631 | if (dut->ap_p2p_cross_connect >= 0) { |
| 6632 | fprintf(f, "manage_p2p=1\n" |
| 6633 | "allow_cross_connection=%d\n", |
| 6634 | dut->ap_p2p_cross_connect); |
| 6635 | } |
| 6636 | |
| 6637 | if (dut->ap_l2tif || dut->ap_proxy_arp) { |
| 6638 | if (!dut->bridge) { |
| 6639 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 6640 | "Bridge must be configured. Run with -b <brname>."); |
| 6641 | fclose(f); |
| 6642 | return -2; |
| 6643 | } |
| 6644 | fprintf(f, "ap_isolate=1\n"); |
| 6645 | } |
| 6646 | |
| 6647 | if (dut->ap_proxy_arp) |
| 6648 | fprintf(f, "proxy_arp=1\n"); |
| 6649 | |
Pradeep Reddy POTTETI | 0d3db63 | 2016-03-11 15:21:11 +0530 | [diff] [blame] | 6650 | if (dut->ap_wme) |
| 6651 | fprintf(f, "wmm_enabled=1\n"); |
| 6652 | |
Mohammed Shafi Shajakhan | 02e3b82 | 2017-02-23 04:15:02 +0530 | [diff] [blame] | 6653 | if (dut->ap_wmmps == AP_WMMPS_ON) |
| 6654 | fprintf(f, "uapsd_advertisement_enabled=1\n"); |
| 6655 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6656 | if (dut->ap_hs2) { |
| 6657 | if (dut->ap_bss_load) { |
| 6658 | char *bss_load; |
| 6659 | |
| 6660 | switch (dut->ap_bss_load) { |
| 6661 | case -1: |
| 6662 | bss_load = "bss_load_update_period=10"; |
| 6663 | break; |
| 6664 | case 1: |
| 6665 | /* STA count: 1, CU: 50, AAC: 65535 */ |
| 6666 | bss_load = "bss_load_test=1:50:65535"; |
| 6667 | break; |
| 6668 | case 2: |
| 6669 | /* STA count: 1, CU: 200, AAC: 65535 */ |
| 6670 | bss_load = "bss_load_test=1:200:65535"; |
| 6671 | break; |
| 6672 | case 3: |
| 6673 | /* STA count: 1, CU: 75, AAC: 65535 */ |
| 6674 | bss_load = "bss_load_test=1:75:65535"; |
| 6675 | break; |
| 6676 | default: |
| 6677 | bss_load = NULL; |
| 6678 | break; |
| 6679 | } |
| 6680 | |
| 6681 | if (!bss_load) { |
| 6682 | fclose(f); |
| 6683 | return -2; |
| 6684 | } |
| 6685 | fprintf(f, "%s\n", bss_load); |
| 6686 | } |
| 6687 | |
| 6688 | if (append_hostapd_conf_hs2(dut, f)) { |
| 6689 | fclose(f); |
| 6690 | return -2; |
| 6691 | } |
| 6692 | } |
| 6693 | |
| 6694 | if (dut->ap_interworking && append_hostapd_conf_interworking(dut, f)) { |
| 6695 | fclose(f); |
| 6696 | return -2; |
| 6697 | } |
| 6698 | |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 6699 | if (dut->ap_hs2 && strlen(dut->ap_tag_ssid[0])) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6700 | unsigned char bssid[6]; |
| 6701 | char ifname2[50]; |
| 6702 | |
Pradeep Reddy POTTETI | 673d85c | 2016-07-26 19:08:07 +0530 | [diff] [blame] | 6703 | if (get_hwaddr(ifname, bssid)) { |
| 6704 | fclose(f); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6705 | return -2; |
Pradeep Reddy POTTETI | 673d85c | 2016-07-26 19:08:07 +0530 | [diff] [blame] | 6706 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6707 | bssid[0] |= 0x02; |
| 6708 | |
| 6709 | snprintf(ifname2, sizeof(ifname2), "%s_1", ifname); |
| 6710 | fprintf(f, "bss=%s_1\n", ifname2); |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 6711 | fprintf(f, "ssid=%s\n", dut->ap_tag_ssid[0]); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6712 | if (dut->bridge) |
| 6713 | fprintf(f, "bridge=%s\n", dut->bridge); |
| 6714 | fprintf(f, "bssid=%02x:%02x:%02x:%02x:%02x:%02x\n", |
| 6715 | bssid[0], bssid[1], bssid[2], bssid[3], |
| 6716 | bssid[4], bssid[5]); |
| 6717 | |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 6718 | if (dut->ap_tag_key_mgmt[0] == AP2_OSEN) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6719 | fprintf(f, "osen=1\n"); |
| 6720 | if (strlen(dut->ap2_radius_ipaddr)) |
| 6721 | fprintf(f, "auth_server_addr=%s\n", |
| 6722 | dut->ap2_radius_ipaddr); |
| 6723 | if (dut->ap2_radius_port) |
| 6724 | fprintf(f, "auth_server_port=%d\n", |
| 6725 | dut->ap2_radius_port); |
| 6726 | if (strlen(dut->ap2_radius_password)) |
| 6727 | fprintf(f, "auth_server_shared_secret=%s\n", |
| 6728 | dut->ap2_radius_password); |
| 6729 | } |
| 6730 | |
| 6731 | if (dut->ap2_proxy_arp) { |
| 6732 | if (!dut->bridge) { |
| 6733 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 6734 | "Bridge must be configured. Run with -b <brname>."); |
| 6735 | fclose(f); |
| 6736 | return -2; |
| 6737 | } |
| 6738 | fprintf(f, "ap_isolate=1\n"); |
| 6739 | fprintf(f, "proxy_arp=1\n"); |
| 6740 | |
| 6741 | if (set_ebtables_proxy_arp(dut, "FORWARD", ifname2) || |
| 6742 | set_ebtables_proxy_arp(dut, "OUTPUT", ifname2)) { |
| 6743 | fclose(f); |
| 6744 | return -2; |
| 6745 | } |
| 6746 | |
| 6747 | } |
| 6748 | } |
| 6749 | |
| 6750 | if (dut->program == PROGRAM_WPS) { |
| 6751 | fprintf(f, "eap_server=1\n" |
| 6752 | "wps_state=1\n" |
| 6753 | "device_name=QCA AP\n" |
| 6754 | "manufacturer=QCA\n" |
| 6755 | "device_type=6-0050F204-1\n" |
| 6756 | "config_methods=label virtual_display " |
| 6757 | "virtual_push_button keypad%s\n" |
| 6758 | "ap_pin=12345670\n" |
| 6759 | "friendly_name=QCA Access Point\n" |
| 6760 | "upnp_iface=%s\n", |
| 6761 | dut->ap_wpsnfc ? " nfc_interface ext_nfc_token" : "", |
| 6762 | dut->bridge ? dut->bridge : ifname); |
| 6763 | } |
| 6764 | |
| 6765 | if (dut->program == PROGRAM_VHT) { |
| 6766 | int vht_oper_centr_freq_idx; |
| 6767 | |
| 6768 | if (check_channel(dut->ap_channel) < 0) { |
| 6769 | send_resp(dut, conn, SIGMA_INVALID, |
| 6770 | "errorCode,Invalid channel"); |
Pradeep Reddy POTTETI | 673d85c | 2016-07-26 19:08:07 +0530 | [diff] [blame] | 6771 | fclose(f); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6772 | return 0; |
| 6773 | } |
| 6774 | |
| 6775 | switch (dut->ap_chwidth) { |
| 6776 | case AP_20: |
| 6777 | dut->ap_vht_chwidth = AP_20_40_VHT_OPER_CHWIDTH; |
| 6778 | vht_oper_centr_freq_idx = |
| 6779 | get_oper_centr_freq_seq_idx(20, |
| 6780 | dut->ap_channel); |
| 6781 | break; |
| 6782 | case AP_40: |
| 6783 | dut->ap_vht_chwidth = AP_20_40_VHT_OPER_CHWIDTH; |
| 6784 | vht_oper_centr_freq_idx = |
| 6785 | get_oper_centr_freq_seq_idx(40, |
| 6786 | dut->ap_channel); |
| 6787 | break; |
| 6788 | case AP_80: |
| 6789 | dut->ap_vht_chwidth = AP_80_VHT_OPER_CHWIDTH; |
| 6790 | vht_oper_centr_freq_idx = |
| 6791 | get_oper_centr_freq_seq_idx(80, |
| 6792 | dut->ap_channel); |
| 6793 | break; |
| 6794 | case AP_160: |
| 6795 | dut->ap_vht_chwidth = AP_160_VHT_OPER_CHWIDTH; |
| 6796 | vht_oper_centr_freq_idx = |
| 6797 | get_oper_centr_freq_seq_idx(160, |
| 6798 | dut->ap_channel); |
| 6799 | break; |
| 6800 | default: |
| 6801 | dut->ap_vht_chwidth = VHT_DEFAULT_OPER_CHWIDTH; |
| 6802 | vht_oper_centr_freq_idx = |
| 6803 | get_oper_centr_freq_seq_idx(80, |
| 6804 | dut->ap_channel); |
| 6805 | break; |
| 6806 | } |
| 6807 | fprintf(f, "vht_oper_centr_freq_seg0_idx=%d\n", |
| 6808 | vht_oper_centr_freq_idx); |
| 6809 | fprintf(f, "vht_oper_chwidth=%d\n", dut->ap_vht_chwidth); |
| 6810 | |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 6811 | if (dut->ap_sgi80 || dut->ap_txBF || |
| 6812 | dut->ap_ldpc != VALUE_NOT_SET || |
Mohammed Shafi Shajakhan | f3e68d9 | 2016-06-02 20:10:57 +0530 | [diff] [blame] | 6813 | dut->ap_tx_stbc || dut->ap_mu_txBF) { |
| 6814 | fprintf(f, "vht_capab=%s%s%s%s%s\n", |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6815 | dut->ap_sgi80 ? "[SHORT-GI-80]" : "", |
Mohammed Shafi Shajakhan | c039ce3 | 2016-06-02 20:10:58 +0530 | [diff] [blame] | 6816 | dut->ap_txBF ? |
Tamizh chelvam | 8312f6d | 2016-06-02 20:10:59 +0530 | [diff] [blame] | 6817 | "[SU-BEAMFORMER][SU-BEAMFORMEE][BF-ANTENNA-2][SOUNDING-DIMENSION-2]" : "", |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 6818 | (dut->ap_ldpc == VALUE_ENABLED) ? |
| 6819 | "[RXLDPC]" : "", |
Mohammed Shafi Shajakhan | f3e68d9 | 2016-06-02 20:10:57 +0530 | [diff] [blame] | 6820 | dut->ap_tx_stbc ? "[TX-STBC-2BY1]" : "", |
| 6821 | dut->ap_mu_txBF ? "[MU-BEAMFORMER]" : ""); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6822 | } |
| 6823 | } |
| 6824 | |
Jouni Malinen | 6d1d739 | 2017-10-10 20:35:29 +0300 | [diff] [blame] | 6825 | if (dut->ap_key_mgmt == AP_WPA2_OWE && dut->ap_tag_ssid[0][0] && |
| 6826 | dut->ap_tag_key_mgmt[0] == AP2_OPEN) { |
| 6827 | /* OWE transition mode */ |
| 6828 | unsigned char bssid[6]; |
| 6829 | char ifname2[50]; |
| 6830 | unsigned long val; |
| 6831 | FILE *f2; |
| 6832 | |
| 6833 | snprintf(ifname2, sizeof(ifname2), "%s_1", ifname); |
| 6834 | |
| 6835 | fprintf(f, "owe_transition_ifname=%s\n", ifname2); |
| 6836 | val = 0x12345678; /* default to something */ |
| 6837 | f2 = fopen("/dev/urandom", "r"); |
| 6838 | if (f2) { |
| 6839 | if (fread(&val, 1, sizeof(val), f2) != sizeof(val)) { |
| 6840 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 6841 | "Could not read /dev/urandom"); |
| 6842 | } |
| 6843 | fclose(f2); |
| 6844 | } |
| 6845 | fprintf(f, "ssid=owe-%lx\n", val); |
| 6846 | |
| 6847 | if (get_hwaddr(ifname, bssid)) { |
| 6848 | fclose(f); |
| 6849 | return -2; |
| 6850 | } |
| 6851 | if (bssid[0] & 0x02) |
| 6852 | bssid[5] ^= 0x01; |
| 6853 | else |
| 6854 | bssid[0] |= 0x02; |
| 6855 | |
| 6856 | fprintf(f, "bss=%s\n", ifname2); |
| 6857 | fprintf(f, "ssid=%s\n", dut->ap_ssid); |
| 6858 | if (dut->bridge) |
| 6859 | fprintf(f, "bridge=%s\n", dut->bridge); |
| 6860 | fprintf(f, "bssid=%02x:%02x:%02x:%02x:%02x:%02x\n", |
| 6861 | bssid[0], bssid[1], bssid[2], bssid[3], |
| 6862 | bssid[4], bssid[5]); |
| 6863 | fprintf(f, "owe_transition_ifname=%s\n", ifname); |
| 6864 | } |
| 6865 | |
Jouni Malinen | 353ba8b | 2018-01-10 17:04:12 +0200 | [diff] [blame] | 6866 | if (dut->ap_key_mgmt == AP_OPEN && |
| 6867 | dut->ap_tag_key_mgmt[0] == AP2_WPA2_OWE) { |
| 6868 | /* OWE transition mode */ |
| 6869 | unsigned char bssid[6]; |
| 6870 | char ifname2[50]; |
| 6871 | unsigned long val; |
| 6872 | FILE *f2; |
| 6873 | |
| 6874 | snprintf(ifname2, sizeof(ifname2), "%s_1", ifname); |
| 6875 | |
| 6876 | fprintf(f, "owe_transition_ifname=%s\n", ifname2); |
| 6877 | fprintf(f, "ssid=%s\n", dut->ap_ssid); |
| 6878 | |
| 6879 | if (get_hwaddr(ifname, bssid)) { |
| 6880 | fclose(f); |
| 6881 | return -2; |
| 6882 | } |
| 6883 | if (bssid[0] & 0x02) |
| 6884 | bssid[5] ^= 0x01; |
| 6885 | else |
| 6886 | bssid[0] |= 0x02; |
| 6887 | |
| 6888 | fprintf(f, "bss=%s\n", ifname2); |
| 6889 | val = 0x12345678; /* default to something */ |
| 6890 | f2 = fopen("/dev/urandom", "r"); |
| 6891 | if (f2) { |
| 6892 | if (fread(&val, 1, sizeof(val), f2) != sizeof(val)) { |
| 6893 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 6894 | "Could not read /dev/urandom"); |
| 6895 | } |
| 6896 | fclose(f2); |
| 6897 | } |
| 6898 | fprintf(f, "ssid=owe-%lx\n", val); |
| 6899 | if (dut->bridge) |
| 6900 | fprintf(f, "bridge=%s\n", dut->bridge); |
| 6901 | fprintf(f, "bssid=%02x:%02x:%02x:%02x:%02x:%02x\n", |
| 6902 | bssid[0], bssid[1], bssid[2], bssid[3], |
| 6903 | bssid[4], bssid[5]); |
| 6904 | fprintf(f, "owe_transition_ifname=%s\n", ifname); |
| 6905 | fprintf(f, "wpa=2\n"); |
| 6906 | fprintf(f, "wpa_key_mgmt=OWE\n"); |
| 6907 | fprintf(f, "rsn_pairwise=CCMP\n"); |
| 6908 | fprintf(f, "ieee80211w=2\n"); |
| 6909 | if (dut->ap_sae_groups) |
| 6910 | fprintf(f, "owe_groups=%s\n", dut->ap_sae_groups); |
| 6911 | } |
| 6912 | |
Ankita Bajaj | 0d5825b | 2017-10-25 16:20:17 +0530 | [diff] [blame] | 6913 | if (dut->program == PROGRAM_OCE) { |
| 6914 | fprintf(f, "oce=%d\n", |
| 6915 | dut->dev_role == DEVROLE_STA_CFON ? 2 : 1); |
| 6916 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6917 | fclose(f); |
Jouni Malinen | d6bf1b4 | 2017-06-23 17:51:01 +0300 | [diff] [blame] | 6918 | if (dut->use_hostapd_pid_file) |
| 6919 | kill_hostapd_process_pid(dut); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6920 | #ifdef __QNXNTO__ |
| 6921 | if (system("slay hostapd") == 0) |
| 6922 | #else /* __QNXNTO__ */ |
Jouni Malinen | d6bf1b4 | 2017-06-23 17:51:01 +0300 | [diff] [blame] | 6923 | if (!dut->use_hostapd_pid_file && |
| 6924 | (kill_process(dut, "(hostapd)", 1, SIGTERM) == 0 || |
| 6925 | system("killall hostapd") == 0)) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6926 | #endif /* __QNXNTO__ */ |
| 6927 | { |
| 6928 | int i; |
| 6929 | /* Wait some time to allow hostapd to complete cleanup before |
| 6930 | * starting a new process */ |
| 6931 | for (i = 0; i < 10; i++) { |
| 6932 | usleep(500000); |
| 6933 | #ifdef __QNXNTO__ |
| 6934 | if (system("pidin | grep hostapd") != 0) |
| 6935 | break; |
| 6936 | #else /* __QNXNTO__ */ |
| 6937 | if (system("pidof hostapd") != 0) |
| 6938 | break; |
| 6939 | #endif /* __QNXNTO__ */ |
| 6940 | } |
| 6941 | } |
Jouni Malinen | d86e582 | 2017-08-29 03:55:32 +0300 | [diff] [blame] | 6942 | dut->hostapd_running = 0; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6943 | |
Pradeep Reddy POTTETI | a076c30 | 2016-05-16 13:36:07 +0530 | [diff] [blame] | 6944 | #ifdef ANDROID |
| 6945 | /* Set proper conf file permissions so that hostapd process |
| 6946 | * can access it. |
| 6947 | */ |
| 6948 | if (chmod(SIGMA_TMPDIR "/sigma_dut-ap.conf", |
| 6949 | S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP) < 0) |
| 6950 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 6951 | "Error changing permissions"); |
| 6952 | |
| 6953 | if (chown(SIGMA_TMPDIR "/sigma_dut-ap.conf", -1, AID_WIFI) < 0) |
| 6954 | sigma_dut_print(dut, DUT_MSG_ERROR, "Error changing groupid"); |
| 6955 | #endif /* ANDROID */ |
| 6956 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6957 | if (drv == DRIVER_QNXNTO) { |
| 6958 | snprintf(buf, sizeof(buf), |
Pradeep Reddy POTTETI | bf4a974 | 2016-02-04 12:32:30 +0530 | [diff] [blame] | 6959 | "hostapd -B %s%s %s%s" SIGMA_TMPDIR |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6960 | "/sigma_dut-ap.conf", |
| 6961 | dut->hostapd_debug_log ? "-ddKt -f " : "", |
| 6962 | dut->hostapd_debug_log ? dut->hostapd_debug_log : "", |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6963 | dut->hostapd_entropy_log ? " -e" : "", |
| 6964 | dut->hostapd_entropy_log ? dut->hostapd_entropy_log : |
| 6965 | ""); |
| 6966 | } else { |
| 6967 | /* |
| 6968 | * It looks like a monitor interface can cause some issues for |
| 6969 | * beaconing, so remove it (if injection was used) before |
| 6970 | * starting hostapd. |
| 6971 | */ |
| 6972 | if (if_nametoindex("sigmadut") > 0 && |
| 6973 | system("iw dev sigmadut del") != 0) |
| 6974 | sigma_dut_print(dut, DUT_MSG_ERROR, "Failed to remove " |
| 6975 | "monitor interface"); |
| 6976 | |
Jouni Malinen | d6bf1b4 | 2017-06-23 17:51:01 +0300 | [diff] [blame] | 6977 | snprintf(path, sizeof(path), "%shostapd", |
| 6978 | file_exists("hostapd") ? "./" : ""); |
| 6979 | 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] | 6980 | "/sigma_dut-ap.conf", |
Jouni Malinen | d6bf1b4 | 2017-06-23 17:51:01 +0300 | [diff] [blame] | 6981 | dut->hostapd_bin ? dut->hostapd_bin : path, |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6982 | dut->hostapd_debug_log ? " -ddKt -f" : "", |
| 6983 | dut->hostapd_debug_log ? dut->hostapd_debug_log : "", |
| 6984 | dut->hostapd_entropy_log ? " -e" : "", |
| 6985 | dut->hostapd_entropy_log ? dut->hostapd_entropy_log : |
Jouni Malinen | d6bf1b4 | 2017-06-23 17:51:01 +0300 | [diff] [blame] | 6986 | "", |
| 6987 | dut->use_hostapd_pid_file ? |
| 6988 | " -P " SIGMA_DUT_HOSTAPD_PID_FILE : ""); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6989 | } |
| 6990 | |
Jouni Malinen | d6bf1b4 | 2017-06-23 17:51:01 +0300 | [diff] [blame] | 6991 | sigma_dut_print(dut, DUT_MSG_DEBUG, "hostapd command: %s", buf); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6992 | if (system(buf) != 0) { |
| 6993 | send_resp(dut, conn, SIGMA_ERROR, |
| 6994 | "errorCode,Failed to start hostapd"); |
| 6995 | return 0; |
| 6996 | } |
| 6997 | |
| 6998 | /* allow some time for hostapd to start before returning success */ |
| 6999 | usleep(500000); |
| 7000 | if (run_hostapd_cli(dut, "ping") != 0) { |
| 7001 | send_resp(dut, conn, SIGMA_ERROR, |
| 7002 | "errorCode,Failed to talk to hostapd"); |
| 7003 | return 0; |
| 7004 | } |
| 7005 | |
Pradeep Reddy Potteti | 923a9b3 | 2017-06-14 12:18:59 +0530 | [diff] [blame] | 7006 | if (drv == DRIVER_LINUX_WCN) { |
| 7007 | sigma_dut_print(dut, DUT_MSG_INFO, "setting ip addr %s mask %s", |
| 7008 | ap_inet_addr, ap_inet_mask); |
| 7009 | snprintf(buf, sizeof(buf), "ifconfig %s %s netmask %s up", |
| 7010 | ifname, ap_inet_addr, ap_inet_mask); |
| 7011 | if (system(buf) != 0) { |
| 7012 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 7013 | "Failed to initialize the interface"); |
| 7014 | return -1; |
| 7015 | } |
| 7016 | } |
| 7017 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7018 | if (dut->ap_l2tif) { |
| 7019 | snprintf(path, sizeof(path), |
| 7020 | "/sys/class/net/%s/brport/hairpin_mode", |
| 7021 | ifname); |
| 7022 | if (!file_exists(path)) { |
| 7023 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 7024 | "%s must be binded to the bridge for L2TIF", |
| 7025 | ifname); |
| 7026 | return -2; |
| 7027 | } |
| 7028 | |
| 7029 | snprintf(buf, sizeof(buf), "echo 1 > %s", path); |
| 7030 | if (system(buf) != 0) { |
| 7031 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 7032 | "Failed to enable hairpin_mode for L2TIF"); |
| 7033 | return -2; |
| 7034 | } |
| 7035 | |
| 7036 | snprintf(buf, sizeof(buf), "ebtables -P FORWARD ACCEPT"); |
| 7037 | if (system(buf) != 0) { |
| 7038 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 7039 | "Failed to set ebtables rules, RULE-9"); |
| 7040 | return -2; |
| 7041 | } |
| 7042 | |
| 7043 | snprintf(buf, sizeof(buf), |
| 7044 | "ebtables -A FORWARD -p IPv4 --ip-proto icmp -i %s -j DROP", |
| 7045 | ifname); |
| 7046 | if (system(buf) != 0) { |
| 7047 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 7048 | "Failed to set ebtables rules, RULE-11"); |
| 7049 | return -2; |
| 7050 | } |
| 7051 | } |
| 7052 | |
| 7053 | if (dut->ap_proxy_arp) { |
| 7054 | if (dut->ap_dgaf_disable) { |
| 7055 | if (set_ebtables_disable_dgaf(dut, "FORWARD", ifname) || |
| 7056 | set_ebtables_disable_dgaf(dut, "OUTPUT", ifname)) |
| 7057 | return -2; |
| 7058 | } else { |
| 7059 | if (set_ebtables_proxy_arp(dut, "FORWARD", ifname) || |
| 7060 | set_ebtables_proxy_arp(dut, "OUTPUT", ifname)) |
| 7061 | return -2; |
| 7062 | } |
| 7063 | |
| 7064 | /* For 4.5-(c) */ |
| 7065 | snprintf(buf, sizeof(buf), |
| 7066 | "ebtables -A FORWARD -p ARP --arp-opcode 2 -i %s -j DROP", |
| 7067 | ifname); |
| 7068 | if (system(buf) != 0) { |
| 7069 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 7070 | "Failed to set ebtables rules, RULE-10"); |
| 7071 | return -2; |
| 7072 | } |
| 7073 | } |
| 7074 | |
| 7075 | if (dut->ap_tdls_prohibit || dut->ap_l2tif) { |
| 7076 | /* Drop TDLS frames */ |
| 7077 | snprintf(buf, sizeof(buf), |
| 7078 | "ebtables -A FORWARD -p 0x890d -i %s -j DROP", ifname); |
| 7079 | if (system(buf) != 0) { |
| 7080 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 7081 | "Failed to set ebtables rules, RULE-13"); |
| 7082 | return -2; |
| 7083 | } |
| 7084 | } |
| 7085 | |
| 7086 | if (dut->ap_fake_pkhash && |
| 7087 | run_hostapd_cli(dut, "set wps_corrupt_pkhash 1") != 0) { |
| 7088 | send_resp(dut, conn, SIGMA_ERROR, |
| 7089 | "errorCode,Could not enable FakePubKey"); |
| 7090 | return 0; |
| 7091 | } |
| 7092 | |
Jouni Malinen | d86e582 | 2017-08-29 03:55:32 +0300 | [diff] [blame] | 7093 | dut->hostapd_running = 1; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7094 | return 1; |
| 7095 | } |
| 7096 | |
| 7097 | |
Pradeep Reddy POTTETI | eff4611 | 2016-10-13 17:22:03 +0530 | [diff] [blame] | 7098 | static int parse_qos_params(struct sigma_dut *dut, struct sigma_conn *conn, |
| 7099 | struct qos_params *qos, const char *cwmin, |
| 7100 | const char *cwmax, const char *aifs, |
| 7101 | const char *txop, const char *acm) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7102 | { |
Pradeep Reddy POTTETI | eff4611 | 2016-10-13 17:22:03 +0530 | [diff] [blame] | 7103 | int val; |
| 7104 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7105 | if (cwmin) { |
| 7106 | qos->ac = 1; |
Pradeep Reddy POTTETI | eff4611 | 2016-10-13 17:22:03 +0530 | [diff] [blame] | 7107 | val = atoi(cwmin); |
| 7108 | if (val < 0 || val > 15) { |
| 7109 | send_resp(dut, conn, SIGMA_INVALID, |
| 7110 | "errorCode,Invalid cwMin"); |
| 7111 | return 0; |
| 7112 | } |
| 7113 | qos->cwmin = val; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7114 | } |
| 7115 | |
| 7116 | if (cwmax) { |
| 7117 | qos->ac = 1; |
Pradeep Reddy POTTETI | eff4611 | 2016-10-13 17:22:03 +0530 | [diff] [blame] | 7118 | val = atoi(cwmax); |
| 7119 | if (val < 0 || val > 15) { |
| 7120 | send_resp(dut, conn, SIGMA_INVALID, |
| 7121 | "errorCode,Invalid cwMax"); |
| 7122 | return 0; |
| 7123 | } |
| 7124 | qos->cwmax = val; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7125 | } |
| 7126 | |
| 7127 | if (aifs) { |
| 7128 | qos->ac = 1; |
Pradeep Reddy POTTETI | eff4611 | 2016-10-13 17:22:03 +0530 | [diff] [blame] | 7129 | val = atoi(aifs); |
| 7130 | if (val < 1 || val > 255) { |
| 7131 | send_resp(dut, conn, SIGMA_INVALID, |
| 7132 | "errorCode,Invalid AIFS"); |
| 7133 | return 0; |
| 7134 | } |
| 7135 | qos->aifs = val; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7136 | } |
| 7137 | |
| 7138 | if (txop) { |
| 7139 | qos->ac = 1; |
Pradeep Reddy POTTETI | eff4611 | 2016-10-13 17:22:03 +0530 | [diff] [blame] | 7140 | val = atoi(txop); |
| 7141 | if (val < 0 || val > 0xffff) { |
| 7142 | send_resp(dut, conn, SIGMA_INVALID, |
| 7143 | "errorCode,Invalid txop"); |
| 7144 | return 0; |
| 7145 | } |
| 7146 | qos->txop = val * 32; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7147 | } |
| 7148 | |
| 7149 | if (acm) { |
| 7150 | qos->ac = 1; |
| 7151 | qos->acm = strcasecmp(acm, "on") == 0; |
| 7152 | } |
Pradeep Reddy POTTETI | eff4611 | 2016-10-13 17:22:03 +0530 | [diff] [blame] | 7153 | |
| 7154 | return 1; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7155 | } |
| 7156 | |
| 7157 | |
| 7158 | static int cmd_ap_set_apqos(struct sigma_dut *dut, struct sigma_conn *conn, |
| 7159 | struct sigma_cmd *cmd) |
| 7160 | { |
| 7161 | /* TXOP: The values provided here for VHT5G only */ |
Pradeep Reddy POTTETI | eff4611 | 2016-10-13 17:22:03 +0530 | [diff] [blame] | 7162 | if (!parse_qos_params(dut, conn, &dut->ap_qos[AP_AC_VO], |
| 7163 | get_param(cmd, "cwmin_VO"), |
| 7164 | get_param(cmd, "cwmax_VO"), |
| 7165 | get_param(cmd, "AIFS_VO"), |
| 7166 | get_param(cmd, "TXOP_VO"), |
| 7167 | get_param(cmd, "ACM_VO")) || |
| 7168 | !parse_qos_params(dut, conn, &dut->ap_qos[AP_AC_VI], |
| 7169 | get_param(cmd, "cwmin_VI"), |
| 7170 | get_param(cmd, "cwmax_VI"), |
| 7171 | get_param(cmd, "AIFS_VI"), |
| 7172 | get_param(cmd, "TXOP_VI"), |
| 7173 | get_param(cmd, "ACM_VI")) || |
| 7174 | !parse_qos_params(dut, conn, &dut->ap_qos[AP_AC_BE], |
| 7175 | get_param(cmd, "cwmin_BE"), |
| 7176 | get_param(cmd, "cwmax_BE"), |
| 7177 | get_param(cmd, "AIFS_BE"), |
| 7178 | get_param(cmd, "TXOP_BE"), |
| 7179 | get_param(cmd, "ACM_BE")) || |
| 7180 | !parse_qos_params(dut, conn, &dut->ap_qos[AP_AC_BK], |
| 7181 | get_param(cmd, "cwmin_BK"), |
| 7182 | get_param(cmd, "cwmax_BK"), |
| 7183 | get_param(cmd, "AIFS_BK"), |
| 7184 | get_param(cmd, "TXOP_BK"), |
| 7185 | get_param(cmd, "ACM_BK"))) |
| 7186 | return 0; |
| 7187 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7188 | return 1; |
| 7189 | } |
| 7190 | |
| 7191 | |
| 7192 | static int cmd_ap_set_staqos(struct sigma_dut *dut, struct sigma_conn *conn, |
| 7193 | struct sigma_cmd *cmd) |
| 7194 | { |
Pradeep Reddy POTTETI | eff4611 | 2016-10-13 17:22:03 +0530 | [diff] [blame] | 7195 | if (!parse_qos_params(dut, conn, &dut->ap_sta_qos[AP_AC_VO], |
| 7196 | get_param(cmd, "cwmin_VO"), |
| 7197 | get_param(cmd, "cwmax_VO"), |
| 7198 | get_param(cmd, "AIFS_VO"), |
| 7199 | get_param(cmd, "TXOP_VO"), |
| 7200 | get_param(cmd, "ACM_VO")) || |
| 7201 | !parse_qos_params(dut, conn, &dut->ap_sta_qos[AP_AC_VI], |
| 7202 | get_param(cmd, "cwmin_VI"), |
| 7203 | get_param(cmd, "cwmax_VI"), |
| 7204 | get_param(cmd, "AIFS_VI"), |
| 7205 | get_param(cmd, "TXOP_VI"), |
| 7206 | get_param(cmd, "ACM_VI")) || |
| 7207 | !parse_qos_params(dut, conn, &dut->ap_sta_qos[AP_AC_BE], |
| 7208 | get_param(cmd, "cwmin_BE"), |
| 7209 | get_param(cmd, "cwmax_BE"), |
| 7210 | get_param(cmd, "AIFS_BE"), |
| 7211 | get_param(cmd, "TXOP_BE"), |
| 7212 | get_param(cmd, "ACM_BE")) || |
| 7213 | !parse_qos_params(dut, conn, &dut->ap_sta_qos[AP_AC_BK], |
| 7214 | get_param(cmd, "cwmin_BK"), |
| 7215 | get_param(cmd, "cwmax_BK"), |
| 7216 | get_param(cmd, "AIFS_BK"), |
| 7217 | get_param(cmd, "TXOP_BK"), |
| 7218 | get_param(cmd, "ACM_BK"))) |
| 7219 | return 0; |
| 7220 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7221 | return 1; |
| 7222 | } |
| 7223 | |
| 7224 | |
| 7225 | static void cmd_ath_ap_hs2_reset(struct sigma_dut *dut) |
| 7226 | { |
| 7227 | unsigned char bssid[6]; |
| 7228 | char buf[100]; |
| 7229 | run_system(dut, "cfg -a AP_SSID=\"Hotspot 2.0\""); |
| 7230 | run_system(dut, "cfg -a AP_PRIMARY_CH=1"); |
| 7231 | run_system(dut, "cfg -a AP_SECMODE=WPA"); |
| 7232 | run_system(dut, "cfg -a AP_SECFILE=EAP"); |
| 7233 | run_system(dut, "cfg -a AP_WPA=2"); |
| 7234 | run_system(dut, "cfg -a AP_CYPHER=CCMP"); |
| 7235 | run_system(dut, "cfg -a AP_HOTSPOT=1"); |
| 7236 | run_system(dut, "cfg -a AP_HOTSPOT_ANT=2"); |
| 7237 | run_system(dut, "cfg -a AP_HOTSPOT_INTERNET=0"); |
| 7238 | run_system(dut, "cfg -a AP_HOTSPOT_VENUEGROUP=2"); |
| 7239 | run_system(dut, "cfg -a AP_HOTSPOT_VENUETYPE=8"); |
| 7240 | run_system(dut, "cfg -a AP_HOTSPOT_ROAMINGCONSORTIUM=506f9a"); |
| 7241 | run_system(dut, "cfg -a AP_HOTSPOT_ROAMINGCONSORTIUM2=001bc504bd"); |
| 7242 | if (!get_hwaddr("ath0", bssid)) { |
| 7243 | snprintf(buf, sizeof(buf), "cfg -a AP_HOTSPOT_HESSID=" |
| 7244 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 7245 | bssid[0], bssid[1], bssid[2], bssid[3], |
| 7246 | bssid[4], bssid[5]); |
| 7247 | run_system(dut, buf); |
| 7248 | snprintf(dut->ap_hessid, sizeof(dut->ap_hessid), |
| 7249 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 7250 | bssid[0], bssid[1], bssid[2], bssid[3], |
| 7251 | bssid[4], bssid[5]); |
| 7252 | } else { |
| 7253 | if (!get_hwaddr("wifi0", bssid)) { |
| 7254 | snprintf(buf, sizeof(buf), "cfg -a AP_HOTSPOT_HESSID=" |
| 7255 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 7256 | bssid[0], bssid[1], bssid[2], bssid[3], |
| 7257 | bssid[4], bssid[5]); |
| 7258 | run_system(dut, buf); |
| 7259 | snprintf(dut->ap_hessid, sizeof(dut->ap_hessid), |
| 7260 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 7261 | bssid[0], bssid[1], bssid[2], bssid[3], |
| 7262 | bssid[4], bssid[5]); |
| 7263 | } else { |
| 7264 | /* load the driver and try again */ |
| 7265 | run_system(dut, "/etc/rc.d/rc.wlan up"); |
| 7266 | |
| 7267 | if (!get_hwaddr("wifi0", bssid)) { |
| 7268 | snprintf(buf, sizeof(buf), |
| 7269 | "cfg -a AP_HOTSPOT_HESSID=" |
| 7270 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 7271 | bssid[0], bssid[1], bssid[2], |
| 7272 | bssid[3], bssid[4], bssid[5]); |
| 7273 | run_system(dut, buf); |
| 7274 | snprintf(dut->ap_hessid, |
| 7275 | sizeof(dut->ap_hessid), |
| 7276 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 7277 | bssid[0], bssid[1], bssid[2], |
| 7278 | bssid[3], bssid[4], bssid[5]); |
| 7279 | } |
| 7280 | } |
| 7281 | } |
| 7282 | |
| 7283 | run_system(dut, "cfg -r AP_SSID_2"); |
| 7284 | run_system(dut, "cfg -c"); |
| 7285 | /* run_system(dut, "cfg -s"); */ |
| 7286 | } |
| 7287 | |
| 7288 | |
| 7289 | static void ath_reset_vht_defaults(struct sigma_dut *dut) |
| 7290 | { |
| 7291 | run_system(dut, "cfg -x"); |
| 7292 | run_system(dut, "cfg -a AP_RADIO_ID=1"); |
| 7293 | run_system(dut, "cfg -a AP_PRIMARY_CH_2=36"); |
| 7294 | run_system(dut, "cfg -a AP_STARTMODE=standard"); |
| 7295 | run_system(dut, "cfg -a AP_CHMODE_2=11ACVHT80"); |
| 7296 | run_system(dut, "cfg -a TX_CHAINMASK_2=7"); |
| 7297 | run_system(dut, "cfg -a RX_CHAINMASK_2=7"); |
| 7298 | run_system(dut, "cfg -a ATH_countrycode=0x348"); |
| 7299 | /* NOTE: For Beeliner we have to turn off MU-MIMO */ |
| 7300 | if (system("rm /tmp/secath*") != 0) { |
| 7301 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 7302 | "Failed to remove secath file"); |
| 7303 | } |
| 7304 | } |
| 7305 | |
| 7306 | |
| 7307 | static int cmd_ap_reset_default(struct sigma_dut *dut, struct sigma_conn *conn, |
| 7308 | struct sigma_cmd *cmd) |
| 7309 | { |
Ankita Bajaj | 0d5825b | 2017-10-25 16:20:17 +0530 | [diff] [blame] | 7310 | const char *type, *program; |
Pradeep Reddy POTTETI | 83b8067 | 2016-09-02 13:01:44 +0530 | [diff] [blame] | 7311 | enum driver_type drv; |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 7312 | int i; |
| 7313 | |
| 7314 | for (i = 0; i < MAX_WLAN_TAGS - 1; i++) { |
| 7315 | /* |
| 7316 | * Reset all tagged SSIDs to NULL-string and all key management |
| 7317 | * to open. |
| 7318 | */ |
| 7319 | dut->ap_tag_ssid[i][0] = '\0'; |
| 7320 | dut->ap_tag_key_mgmt[i] = AP2_OPEN; |
| 7321 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7322 | |
Pradeep Reddy POTTETI | 83b8067 | 2016-09-02 13:01:44 +0530 | [diff] [blame] | 7323 | drv = get_driver_type(); |
Ankita Bajaj | 0d5825b | 2017-10-25 16:20:17 +0530 | [diff] [blame] | 7324 | |
| 7325 | program = get_param(cmd, "program"); |
| 7326 | if (!program) |
| 7327 | program = get_param(cmd, "prog"); |
| 7328 | dut->program = sigma_program_to_enum(program); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7329 | dut->device_type = AP_unknown; |
| 7330 | type = get_param(cmd, "type"); |
| 7331 | if (type && strcasecmp(type, "Testbed") == 0) |
| 7332 | dut->device_type = AP_testbed; |
| 7333 | if (type && strcasecmp(type, "DUT") == 0) |
| 7334 | dut->device_type = AP_dut; |
| 7335 | |
| 7336 | dut->ap_rts = 0; |
| 7337 | dut->ap_frgmnt = 0; |
| 7338 | dut->ap_bcnint = 0; |
| 7339 | dut->ap_key_mgmt = AP_OPEN; |
| 7340 | dut->ap_ssid[0] = '\0'; |
| 7341 | dut->ap_fake_pkhash = 0; |
| 7342 | memset(dut->ap_qos, 0, sizeof(dut->ap_qos)); |
| 7343 | memset(dut->ap_sta_qos, 0, sizeof(dut->ap_sta_qos)); |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 7344 | dut->ap_addba_reject = VALUE_NOT_SET; |
| 7345 | dut->ap_noack = VALUE_NOT_SET; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7346 | dut->ap_is_dual = 0; |
| 7347 | dut->ap_mode = AP_inval; |
| 7348 | dut->ap_mode_1 = AP_inval; |
| 7349 | |
| 7350 | dut->ap_allow_vht_wep = 0; |
| 7351 | dut->ap_allow_vht_tkip = 0; |
| 7352 | dut->ap_disable_protection = 0; |
| 7353 | memset(dut->ap_countrycode, 0, sizeof(dut->ap_countrycode)); |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 7354 | dut->ap_dyn_bw_sig = VALUE_NOT_SET; |
| 7355 | dut->ap_ldpc = VALUE_NOT_SET; |
| 7356 | dut->ap_sig_rts = VALUE_NOT_SET; |
| 7357 | dut->ap_rx_amsdu = VALUE_NOT_SET; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7358 | dut->ap_txBF = 0; |
Mohammed Shafi Shajakhan | 495fdb2 | 2016-06-02 20:10:56 +0530 | [diff] [blame] | 7359 | dut->ap_mu_txBF = 0; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7360 | dut->ap_chwidth = AP_AUTO; |
| 7361 | |
Sarvepalli, Rajesh Babu | 24dc7e4 | 2016-03-18 21:27:26 +0530 | [diff] [blame] | 7362 | dut->ap_rsn_preauth = 0; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7363 | dut->ap_wpsnfc = 0; |
| 7364 | dut->ap_bss_load = -1; |
| 7365 | dut->ap_p2p_cross_connect = -1; |
| 7366 | |
Pradeep Reddy POTTETI | fba27db | 2015-11-20 16:42:22 +0530 | [diff] [blame] | 7367 | dut->ap_regulatory_mode = AP_80211D_MODE_DISABLED; |
| 7368 | dut->ap_dfs_mode = AP_DFS_MODE_DISABLED; |
Pradeep Reddy Potteti | 4b0cdee | 2017-03-15 12:37:33 +0530 | [diff] [blame] | 7369 | dut->ap_chwidth_offset = SEC_CH_NO; |
Pradeep Reddy POTTETI | fba27db | 2015-11-20 16:42:22 +0530 | [diff] [blame] | 7370 | |
Adil Saeed Musthafa | 6906372 | 2017-04-10 23:13:40 -0700 | [diff] [blame] | 7371 | dut->mbo_pref_ap_cnt = 0; |
Adil Saeed Musthafa | 4ec61bd | 2017-04-10 23:13:41 -0700 | [diff] [blame] | 7372 | dut->ft_bss_mac_cnt = 0; |
priyadharshini gowthaman | 09d613e | 2017-12-20 11:43:44 -0800 | [diff] [blame] | 7373 | dut->ap_interface_5g = 0; |
| 7374 | dut->ap_interface_2g = 0; |
priyadharshini gowthaman | a3fe8c6 | 2018-01-26 15:19:41 -0800 | [diff] [blame] | 7375 | dut->ap_pmf = AP_PMF_DISABLED; |
Adil Saeed Musthafa | 6906372 | 2017-04-10 23:13:40 -0700 | [diff] [blame] | 7376 | |
Mohammed Shafi Shajakhan | 02e3b82 | 2017-02-23 04:15:02 +0530 | [diff] [blame] | 7377 | if (dut->program == PROGRAM_HT || dut->program == PROGRAM_VHT) { |
Pradeep Reddy POTTETI | 0d3db63 | 2016-03-11 15:21:11 +0530 | [diff] [blame] | 7378 | dut->ap_wme = AP_WME_ON; |
Mohammed Shafi Shajakhan | 02e3b82 | 2017-02-23 04:15:02 +0530 | [diff] [blame] | 7379 | dut->ap_wmmps = AP_WMMPS_ON; |
| 7380 | } else { |
Pradeep Reddy POTTETI | 0d3db63 | 2016-03-11 15:21:11 +0530 | [diff] [blame] | 7381 | dut->ap_wme = AP_WME_OFF; |
Mohammed Shafi Shajakhan | 02e3b82 | 2017-02-23 04:15:02 +0530 | [diff] [blame] | 7382 | dut->ap_wmmps = AP_WMMPS_OFF; |
| 7383 | } |
Pradeep Reddy POTTETI | 0d3db63 | 2016-03-11 15:21:11 +0530 | [diff] [blame] | 7384 | |
Adil Saeed Musthafa | 33ea287 | 2017-04-10 23:13:24 -0700 | [diff] [blame] | 7385 | if (dut->program == PROGRAM_HS2 || dut->program == PROGRAM_HS2_R2 || |
| 7386 | dut->program == PROGRAM_IOTLP) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7387 | int i; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7388 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7389 | if (drv == DRIVER_ATHEROS) |
| 7390 | cmd_ath_ap_hs2_reset(dut); |
| 7391 | else if (drv == DRIVER_OPENWRT) |
| 7392 | cmd_owrt_ap_hs2_reset(dut); |
| 7393 | |
| 7394 | dut->ap_interworking = 1; |
| 7395 | dut->ap_access_net_type = 2; |
| 7396 | dut->ap_internet = 0; |
| 7397 | dut->ap_venue_group = 2; |
| 7398 | dut->ap_venue_type = 8; |
| 7399 | dut->ap_domain_name_list[0] = '\0'; |
| 7400 | dut->ap_hs2 = 1; |
| 7401 | snprintf(dut->ap_roaming_cons, sizeof(dut->ap_roaming_cons), |
| 7402 | "506f9a;001bc504bd"); |
| 7403 | dut->ap_l2tif = 0; |
| 7404 | dut->ap_proxy_arp = 0; |
| 7405 | if (dut->bridge) { |
| 7406 | char buf[50]; |
| 7407 | |
| 7408 | snprintf(buf, sizeof(buf), "ip neigh flush dev %s", |
| 7409 | dut->bridge); |
| 7410 | if (system(buf) != 0) { |
| 7411 | sigma_dut_print(dut, DUT_MSG_DEBUG, |
| 7412 | "%s ip neigh table flushing failed", |
| 7413 | dut->bridge); |
| 7414 | } |
| 7415 | |
| 7416 | snprintf(buf, sizeof(buf), "ebtables -F"); |
| 7417 | if (system(buf) != 0) { |
| 7418 | sigma_dut_print(dut, DUT_MSG_DEBUG, |
| 7419 | "%s ebtables flushing failed", |
| 7420 | dut->bridge); |
| 7421 | } |
| 7422 | } |
| 7423 | dut->ap_dgaf_disable = 0; |
| 7424 | dut->ap_p2p_cross_connect = 0; |
| 7425 | dut->ap_gas_cb_delay = 0; |
| 7426 | dut->ap_nai_realm_list = 0; |
| 7427 | dut->ap_oper_name = 0; |
| 7428 | dut->ap_venue_name = 0; |
| 7429 | for (i = 0; i < 10; i++) { |
| 7430 | dut->ap_plmn_mcc[i][0] = '\0'; |
| 7431 | dut->ap_plmn_mnc[i][0] = '\0'; |
| 7432 | } |
| 7433 | dut->ap_wan_metrics = 0; |
| 7434 | dut->ap_conn_capab = 0; |
| 7435 | dut->ap_ip_addr_type_avail = 0; |
| 7436 | dut->ap_net_auth_type = 0; |
| 7437 | dut->ap_oper_class = 0; |
| 7438 | dut->ap_pmf = 0; |
| 7439 | dut->ap_add_sha256 = 0; |
| 7440 | } |
| 7441 | |
Adil Saeed Musthafa | 33ea287 | 2017-04-10 23:13:24 -0700 | [diff] [blame] | 7442 | if (dut->program == PROGRAM_HS2_R2 || dut->program == PROGRAM_IOTLP) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7443 | int i; |
| 7444 | const char hessid[] = "50:6f:9a:00:11:22"; |
| 7445 | |
| 7446 | memcpy(dut->ap_hessid, hessid, strlen(hessid) + 1); |
| 7447 | dut->ap_osu_ssid[0] = '\0'; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7448 | dut->ap_pmf = 1; |
| 7449 | dut->ap_osu_provider_list = 0; |
| 7450 | for (i = 0; i < 10; i++) { |
| 7451 | dut->ap_osu_server_uri[i][0] = '\0'; |
| 7452 | dut->ap_osu_method[i] = 0xFF; |
| 7453 | } |
| 7454 | dut->ap_qos_map_set = 0; |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 7455 | dut->ap_tag_key_mgmt[0] = AP2_OPEN; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7456 | dut->ap2_proxy_arp = 0; |
| 7457 | dut->ap_osu_icon_tag = 0; |
| 7458 | } |
| 7459 | |
| 7460 | if (dut->program == PROGRAM_VHT) { |
| 7461 | /* Set up the defaults */ |
| 7462 | dut->ap_mode = AP_11ac; |
| 7463 | dut->ap_channel = 36; |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 7464 | dut->ap_ampdu = VALUE_NOT_SET; |
priyadharshini gowthaman | 264d544 | 2016-02-25 15:52:22 -0800 | [diff] [blame] | 7465 | dut->ap_ndpa_frame = 1; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7466 | if (dut->device_type == AP_testbed) { |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 7467 | dut->ap_amsdu = VALUE_DISABLED; |
| 7468 | dut->ap_ldpc = VALUE_DISABLED; |
| 7469 | dut->ap_rx_amsdu = VALUE_DISABLED; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7470 | dut->ap_sgi80 = 0; |
| 7471 | } else { |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 7472 | dut->ap_amsdu = VALUE_ENABLED; |
Pradeep Reddy POTTETI | 83b8067 | 2016-09-02 13:01:44 +0530 | [diff] [blame] | 7473 | /* |
| 7474 | * As LDPC is optional, don't enable this by default |
| 7475 | * for LINUX-WCN driver. The ap_set_wireless command |
| 7476 | * can be used to enable LDPC, when needed. |
| 7477 | */ |
| 7478 | if (drv != DRIVER_LINUX_WCN) |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 7479 | dut->ap_ldpc = VALUE_ENABLED; |
| 7480 | dut->ap_rx_amsdu = VALUE_ENABLED; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7481 | dut->ap_sgi80 = 1; |
| 7482 | } |
| 7483 | dut->ap_fixed_rate = 0; |
| 7484 | dut->ap_rx_streams = 3; |
| 7485 | dut->ap_tx_streams = 3; |
| 7486 | dut->ap_vhtmcs_map = 0; |
| 7487 | dut->ap_chwidth = AP_80; |
| 7488 | dut->ap_tx_stbc = 1; |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 7489 | dut->ap_dyn_bw_sig = VALUE_ENABLED; |
Mohammed Shafi Shajakhan | bae7230 | 2016-03-02 11:56:23 +0530 | [diff] [blame] | 7490 | if (get_openwrt_driver_type() == OPENWRT_DRIVER_ATHEROS) |
| 7491 | dut->ap_dfs_mode = AP_DFS_MODE_ENABLED; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7492 | if (get_driver_type() == DRIVER_ATHEROS) |
| 7493 | ath_reset_vht_defaults(dut); |
| 7494 | } |
| 7495 | |
Adil Saeed Musthafa | 33ea287 | 2017-04-10 23:13:24 -0700 | [diff] [blame] | 7496 | if (dut->program == PROGRAM_IOTLP) { |
| 7497 | dut->wnm_bss_max_feature = VALUE_DISABLED; |
| 7498 | dut->wnm_bss_max_idle_time = 0; |
| 7499 | dut->wnm_bss_max_protection = VALUE_NOT_SET; |
| 7500 | dut->ap_proxy_arp = 1; |
| 7501 | } else { |
| 7502 | /* |
| 7503 | * Do not touch the BSS-MAX Idle time feature |
| 7504 | * if the program is not IOTLP. |
| 7505 | */ |
| 7506 | dut->wnm_bss_max_feature = VALUE_NOT_SET; |
| 7507 | dut->wnm_bss_max_idle_time = 0; |
| 7508 | dut->wnm_bss_max_protection = VALUE_NOT_SET; |
| 7509 | } |
| 7510 | |
priyadharshini gowthaman | a27b5b6 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 7511 | if (dut->program == PROGRAM_LOC) { |
priyadharshini gowthaman | 8e26ff4 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 7512 | dut->ap_rrm = 1; |
| 7513 | dut->ap_rtt = 1; |
| 7514 | dut->ap_lci = 0; |
| 7515 | dut->ap_val_lci[0] = '\0'; |
priyadharshini gowthaman | c2357bd | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 7516 | dut->ap_infoz[0] = '\0'; |
priyadharshini gowthaman | 8e26ff4 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 7517 | dut->ap_lcr = 0; |
| 7518 | dut->ap_val_lcr[0] = '\0'; |
| 7519 | dut->ap_neighap = 0; |
| 7520 | dut->ap_opchannel = 0; |
| 7521 | dut->ap_scan = 0; |
priyadharshini gowthaman | c2357bd | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 7522 | dut->ap_fqdn_held = 0; |
| 7523 | dut->ap_fqdn_supl = 0; |
priyadharshini gowthaman | c52fff8 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 7524 | dut->ap_interworking = 0; |
| 7525 | dut->ap_gas_cb_delay = 0; |
priyadharshini gowthaman | a27b5b6 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 7526 | dut->ap_msnt_type = 0; |
| 7527 | } |
Adil Saeed Musthafa | 4ec61bd | 2017-04-10 23:13:41 -0700 | [diff] [blame] | 7528 | dut->ap_ft_oa = 0; |
Adil Saeed Musthafa | 604c826 | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 7529 | dut->ap_reg_domain = REG_DOMAIN_NOT_SET; |
Adil Saeed Musthafa | cf752fa | 2017-04-10 23:13:32 -0700 | [diff] [blame] | 7530 | dut->ap_mobility_domain[0] = '\0'; |
priyadharshini gowthaman | a27b5b6 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 7531 | |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 7532 | if (dut->program == PROGRAM_MBO) { |
| 7533 | dut->ap_mbo = 1; |
| 7534 | dut->ap_interworking = 1; |
| 7535 | dut->ap_ne_class = 0; |
| 7536 | dut->ap_ne_op_ch = 0; |
| 7537 | dut->ap_set_bssidpref = 1; |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 7538 | dut->ap_btmreq_disassoc_imnt = 0; |
| 7539 | dut->ap_btmreq_term_bit = 0; |
| 7540 | dut->ap_disassoc_timer = 0; |
| 7541 | dut->ap_btmreq_bss_term_dur = 0; |
Adil Saeed Musthafa | 16d9e63 | 2017-04-10 23:13:38 -0700 | [diff] [blame] | 7542 | dut->ap_channel = 36; |
| 7543 | dut->ap_chwidth = AP_20; |
Adil Saeed Musthafa | 023108a | 2017-04-10 23:13:37 -0700 | [diff] [blame] | 7544 | dut->ap_cell_cap_pref = 0; |
Adil Saeed Musthafa | ed5faae | 2017-04-10 23:13:36 -0700 | [diff] [blame] | 7545 | dut->ap_gas_cb_delay = 0; |
Adil Saeed Musthafa | 6906372 | 2017-04-10 23:13:40 -0700 | [diff] [blame] | 7546 | dut->mbo_self_ap_tuple.ap_ne_class = -1; |
| 7547 | dut->mbo_self_ap_tuple.ap_ne_pref = -1; /* Not set */ |
| 7548 | dut->mbo_self_ap_tuple.ap_ne_op_ch = -1; |
priyadharshini gowthaman | 94062b5 | 2017-12-20 12:33:34 -0800 | [diff] [blame] | 7549 | dut->ap_btmreq_bss_term_tsf = 0; |
priyadharshini gowthaman | 776562e | 2017-12-20 12:33:34 -0800 | [diff] [blame] | 7550 | dut->ap_assoc_delay = 0; |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 7551 | } |
| 7552 | |
priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 7553 | if (dut->program == PROGRAM_OCE) { |
| 7554 | if (dut->ap_dhcp_stop) |
| 7555 | run_system(dut, "/etc/init.d/dnsmasq start"); |
| 7556 | |
| 7557 | dut->ap_dhcp_stop = 0; |
| 7558 | dut->ap_oce = VALUE_ENABLED; |
| 7559 | dut->ap_broadcast_ssid = VALUE_ENABLED; |
| 7560 | dut->ap_fils_dscv_int = 20; |
| 7561 | dut->ap_filsdscv = VALUE_ENABLED; |
| 7562 | dut->ap_filshlp = VALUE_DISABLED; |
| 7563 | dut->ap_rnr = VALUE_DISABLED; |
| 7564 | dut->ap_nairealm[0] = '\0'; |
| 7565 | dut->ap_nairealm_int = 0; |
| 7566 | dut->ap_blechanutil = 0; |
| 7567 | dut->ap_ble_admit_cap = 0; |
| 7568 | dut->ap_esp = VALUE_ENABLED; |
| 7569 | dut->ap_datappdudura = 0; |
| 7570 | dut->ap_airtimefract = 0; |
| 7571 | dut->ap_blestacnt = 0; |
priyadharshini gowthaman | cb22e43 | 2017-12-28 15:23:31 -0800 | [diff] [blame] | 7572 | dut->ap_ul_availcap = 0; |
| 7573 | dut->ap_dl_availcap = 0; |
priyadharshini gowthaman | de81f39 | 2017-12-28 15:28:49 -0800 | [diff] [blame] | 7574 | dut->ap_akm = 0; |
| 7575 | dut->ap_add_sha256 = 0; |
| 7576 | dut->ap_add_sha384 = 0; |
| 7577 | dut->ap_pmksa = 0; |
| 7578 | dut->ap_pmksa_caching = 0; |
priyadharshini gowthaman | 63ab848 | 2017-12-28 15:32:55 -0800 | [diff] [blame] | 7579 | dut->ap_80plus80 = 0; |
priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 7580 | } |
| 7581 | |
priyadharshini gowthaman | 9149afc | 2018-01-15 13:40:18 -0800 | [diff] [blame] | 7582 | dut->ap_oper_chn = 0; |
| 7583 | |
Jouni Malinen | 3c367e8 | 2017-06-23 17:01:47 +0300 | [diff] [blame] | 7584 | free(dut->rsne_override); |
| 7585 | dut->rsne_override = NULL; |
| 7586 | |
Jouni Malinen | 6814313 | 2017-09-02 02:34:08 +0300 | [diff] [blame] | 7587 | free(dut->sae_commit_override); |
| 7588 | dut->sae_commit_override = NULL; |
| 7589 | |
Jouni Malinen | ed670f4 | 2017-08-31 01:39:28 +0300 | [diff] [blame] | 7590 | free(dut->ap_sae_groups); |
| 7591 | dut->ap_sae_groups = NULL; |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 7592 | |
Jouni Malinen | 2f524ce | 2017-08-31 01:43:29 +0300 | [diff] [blame] | 7593 | dut->sae_anti_clogging_threshold = -1; |
Jouni Malinen | b347db0 | 2017-09-02 01:36:03 +0300 | [diff] [blame] | 7594 | dut->sae_reflection = 0; |
Jouni Malinen | 2f524ce | 2017-08-31 01:43:29 +0300 | [diff] [blame] | 7595 | |
Jouni Malinen | 3d633da | 2017-09-14 22:19:21 +0300 | [diff] [blame] | 7596 | dut->ap_cipher = AP_CCMP; |
Jouni Malinen | 2ba2449 | 2017-11-17 12:43:59 +0200 | [diff] [blame] | 7597 | dut->ap_group_cipher = AP_NO_GROUP_CIPHER_SET; |
Jouni Malinen | 3d633da | 2017-09-14 22:19:21 +0300 | [diff] [blame] | 7598 | dut->ap_group_mgmt_cipher = AP_NO_GROUP_MGMT_CIPHER_SET; |
Jouni Malinen | 6337062 | 2017-11-18 17:47:13 +0200 | [diff] [blame] | 7599 | dut->ap_passphrase[0] = '\0'; |
| 7600 | dut->ap_psk[0] = '\0'; |
Jouni Malinen | 3d633da | 2017-09-14 22:19:21 +0300 | [diff] [blame] | 7601 | |
Jouni Malinen | d86e582 | 2017-08-29 03:55:32 +0300 | [diff] [blame] | 7602 | dut->dpp_conf_id = -1; |
| 7603 | |
| 7604 | dut->hostapd_running = 0; |
priyadharshini gowthaman | 9947fd3 | 2018-01-26 15:19:41 -0800 | [diff] [blame] | 7605 | |
| 7606 | if (get_openwrt_driver_type() == OPENWRT_DRIVER_ATHEROS) |
| 7607 | return 1; |
| 7608 | |
Jouni Malinen | d6bf1b4 | 2017-06-23 17:51:01 +0300 | [diff] [blame] | 7609 | if (dut->use_hostapd_pid_file) { |
| 7610 | kill_hostapd_process_pid(dut); |
| 7611 | } else if (kill_process(dut, "(hostapd)", 1, SIGTERM) == 0 || |
| 7612 | system("killall hostapd") == 0) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7613 | int i; |
| 7614 | /* Wait some time to allow hostapd to complete cleanup before |
| 7615 | * starting a new process */ |
| 7616 | for (i = 0; i < 10; i++) { |
| 7617 | usleep(500000); |
| 7618 | if (system("pidof hostapd") != 0) |
| 7619 | break; |
| 7620 | } |
| 7621 | } |
| 7622 | |
| 7623 | if (if_nametoindex("sigmadut") > 0 && |
| 7624 | system("iw dev sigmadut del") != 0) |
| 7625 | sigma_dut_print(dut, DUT_MSG_ERROR, "Failed to remove " |
| 7626 | "monitor interface"); |
| 7627 | |
| 7628 | return 1; |
| 7629 | } |
| 7630 | |
| 7631 | |
Ankita Bajaj | 0d5825b | 2017-10-25 16:20:17 +0530 | [diff] [blame] | 7632 | int sta_cfon_reset_default(struct sigma_dut *dut, struct sigma_conn *conn, |
| 7633 | struct sigma_cmd *cmd) |
| 7634 | { |
| 7635 | return cmd_ap_reset_default(dut, conn, cmd); |
| 7636 | } |
| 7637 | |
| 7638 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7639 | static int cmd_ap_get_info(struct sigma_dut *dut, struct sigma_conn *conn, |
| 7640 | struct sigma_cmd *cmd) |
| 7641 | { |
| 7642 | /* const char *name = get_param(cmd, "NAME"); */ |
| 7643 | struct stat s; |
| 7644 | char resp[200]; |
| 7645 | FILE *f; |
| 7646 | enum driver_type drv = get_driver_type(); |
| 7647 | |
| 7648 | switch (drv) { |
| 7649 | case DRIVER_ATHEROS: { |
| 7650 | /* Atheros AP */ |
| 7651 | struct utsname uts; |
| 7652 | char *version, athver[100]; |
| 7653 | |
| 7654 | if (stat("/proc/athversion", &s) != 0) { |
| 7655 | if (system("/etc/rc.d/rc.wlan up") != 0) { |
| 7656 | } |
| 7657 | } |
| 7658 | |
| 7659 | athver[0] = '\0'; |
| 7660 | f = fopen("/proc/athversion", "r"); |
| 7661 | if (f) { |
| 7662 | if (fgets(athver, sizeof(athver), f)) { |
| 7663 | char *pos = strchr(athver, '\n'); |
| 7664 | if (pos) |
| 7665 | *pos = '\0'; |
| 7666 | } |
| 7667 | fclose(f); |
| 7668 | } |
| 7669 | |
| 7670 | if (uname(&uts) == 0) |
| 7671 | version = uts.release; |
| 7672 | else |
| 7673 | version = "Unknown"; |
| 7674 | |
| 7675 | if (if_nametoindex("ath1") > 0) |
| 7676 | snprintf(resp, sizeof(resp), "interface,ath0_24G " |
| 7677 | "ath1_5G,agent,1.0,version,%s/drv:%s", |
| 7678 | version, athver); |
| 7679 | else |
| 7680 | snprintf(resp, sizeof(resp), "interface,ath0_24G," |
| 7681 | "agent,1.0,version,%s/drv:%s", |
| 7682 | version, athver); |
| 7683 | |
| 7684 | send_resp(dut, conn, SIGMA_COMPLETE, resp); |
| 7685 | return 0; |
| 7686 | } |
Sreelakshmi Konamki | b692f10 | 2016-04-26 19:47:00 +0530 | [diff] [blame] | 7687 | case DRIVER_LINUX_WCN: |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7688 | case DRIVER_MAC80211: { |
| 7689 | struct utsname uts; |
| 7690 | char *version; |
| 7691 | |
| 7692 | if (uname(&uts) == 0) |
| 7693 | version = uts.release; |
| 7694 | else |
| 7695 | version = "Unknown"; |
| 7696 | |
| 7697 | if (if_nametoindex("wlan1") > 0) |
| 7698 | snprintf(resp, sizeof(resp), "interface,wlan0_24G " |
| 7699 | "wlan1_5G,agent,1.0,version,%s", version); |
| 7700 | else |
| 7701 | snprintf(resp, sizeof(resp), "interface,wlan0_any," |
| 7702 | "agent,1.0,version,%s", version); |
| 7703 | |
| 7704 | send_resp(dut, conn, SIGMA_COMPLETE, resp); |
| 7705 | return 0; |
| 7706 | } |
| 7707 | case DRIVER_QNXNTO: { |
| 7708 | struct utsname uts; |
| 7709 | char *version; |
| 7710 | |
| 7711 | if (uname(&uts) == 0) |
| 7712 | version = uts.release; |
| 7713 | else |
| 7714 | version = "Unknown"; |
| 7715 | snprintf(resp, sizeof(resp), |
| 7716 | "interface,%s_any,agent,1.0,version,%s", |
| 7717 | sigma_main_ifname ? sigma_main_ifname : "NA", |
| 7718 | version); |
| 7719 | send_resp(dut, conn, SIGMA_COMPLETE, resp); |
| 7720 | return 0; |
| 7721 | } |
| 7722 | case DRIVER_OPENWRT: { |
| 7723 | switch (get_openwrt_driver_type()) { |
| 7724 | case OPENWRT_DRIVER_ATHEROS: { |
| 7725 | struct utsname uts; |
| 7726 | char *version; |
| 7727 | |
| 7728 | if (uname(&uts) == 0) |
| 7729 | version = uts.release; |
| 7730 | else |
| 7731 | version = "Unknown"; |
| 7732 | |
| 7733 | if (if_nametoindex("ath1") > 0) |
| 7734 | snprintf(resp, sizeof(resp), |
| 7735 | "interface,ath0_5G ath1_24G,agent,1.0,version,%s", |
| 7736 | version); |
| 7737 | else |
| 7738 | snprintf(resp, sizeof(resp), |
| 7739 | "interface,ath0_any,agent,1.0,version,%s", |
| 7740 | version); |
| 7741 | |
| 7742 | send_resp(dut, conn, SIGMA_COMPLETE, resp); |
| 7743 | return 0; |
| 7744 | } |
| 7745 | default: |
| 7746 | send_resp(dut, conn, SIGMA_ERROR, |
| 7747 | "errorCode,Unsupported openwrt driver"); |
| 7748 | return 0; |
| 7749 | } |
| 7750 | } |
| 7751 | default: |
| 7752 | send_resp(dut, conn, SIGMA_ERROR, |
| 7753 | "errorCode,Unsupported driver"); |
| 7754 | return 0; |
| 7755 | } |
| 7756 | } |
| 7757 | |
| 7758 | |
| 7759 | static int cmd_ap_deauth_sta(struct sigma_dut *dut, struct sigma_conn *conn, |
| 7760 | struct sigma_cmd *cmd) |
| 7761 | { |
| 7762 | /* const char *name = get_param(cmd, "NAME"); */ |
| 7763 | /* const char *ifname = get_param(cmd, "INTERFACE"); */ |
| 7764 | const char *val; |
| 7765 | char buf[100]; |
| 7766 | |
| 7767 | val = get_param(cmd, "MinorCode"); |
| 7768 | if (val) { |
| 7769 | /* TODO: add support for P2P minor code */ |
| 7770 | send_resp(dut, conn, SIGMA_ERROR, "errorCode,MinorCode not " |
| 7771 | "yet supported"); |
| 7772 | return 0; |
| 7773 | } |
| 7774 | |
| 7775 | val = get_param(cmd, "STA_MAC_ADDRESS"); |
| 7776 | if (val == NULL) |
| 7777 | return -1; |
| 7778 | snprintf(buf, sizeof(buf), "deauth %s", val); |
| 7779 | if (run_hostapd_cli(dut, buf) != 0) |
| 7780 | return -2; |
| 7781 | |
| 7782 | return 1; |
| 7783 | } |
| 7784 | |
| 7785 | |
| 7786 | #ifdef __linux__ |
| 7787 | int inject_frame(int s, const void *data, size_t len, int encrypt); |
| 7788 | int open_monitor(const char *ifname); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7789 | #endif /* __linux__ */ |
| 7790 | |
| 7791 | enum send_frame_type { |
| 7792 | DISASSOC, DEAUTH, SAQUERY |
| 7793 | }; |
| 7794 | enum send_frame_protection { |
| 7795 | CORRECT_KEY, INCORRECT_KEY, UNPROTECTED |
| 7796 | }; |
| 7797 | |
| 7798 | |
| 7799 | static int ap_inject_frame(struct sigma_dut *dut, struct sigma_conn *conn, |
| 7800 | enum send_frame_type frame, |
| 7801 | enum send_frame_protection protected, |
| 7802 | const char *sta_addr) |
| 7803 | { |
| 7804 | #ifdef __linux__ |
| 7805 | unsigned char buf[1000], *pos; |
| 7806 | int s, res; |
| 7807 | unsigned char addr_sta[6], addr_own[6]; |
| 7808 | char *ifname; |
| 7809 | char cbuf[100]; |
| 7810 | struct ifreq ifr; |
| 7811 | |
| 7812 | if ((dut->ap_mode == AP_11a || dut->ap_mode == AP_11na || |
| 7813 | dut->ap_mode == AP_11ac) && |
| 7814 | if_nametoindex("wlan1") > 0) |
| 7815 | ifname = "wlan1"; |
| 7816 | else |
| 7817 | ifname = "wlan0"; |
| 7818 | |
| 7819 | if (hwaddr_aton(sta_addr, addr_sta) < 0) |
| 7820 | return -1; |
| 7821 | |
| 7822 | s = socket(AF_INET, SOCK_DGRAM, 0); |
| 7823 | if (s < 0) |
| 7824 | return -1; |
| 7825 | memset(&ifr, 0, sizeof(ifr)); |
Peng Xu | b8fc5cc | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 7826 | strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name)); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7827 | if (ioctl(s, SIOCGIFHWADDR, &ifr) < 0) { |
| 7828 | perror("ioctl"); |
| 7829 | close(s); |
| 7830 | return -1; |
| 7831 | } |
| 7832 | close(s); |
| 7833 | memcpy(addr_own, ifr.ifr_hwaddr.sa_data, 6); |
| 7834 | |
| 7835 | if (if_nametoindex("sigmadut") == 0) { |
| 7836 | snprintf(cbuf, sizeof(cbuf), |
| 7837 | "iw dev %s interface add sigmadut type monitor", |
| 7838 | ifname); |
| 7839 | if (system(cbuf) != 0 || |
| 7840 | if_nametoindex("sigmadut") == 0) { |
| 7841 | sigma_dut_print(dut, DUT_MSG_ERROR, "Failed to add " |
| 7842 | "monitor interface with '%s'", cbuf); |
| 7843 | return -2; |
| 7844 | } |
| 7845 | } |
| 7846 | |
| 7847 | if (system("ifconfig sigmadut up") != 0) { |
| 7848 | sigma_dut_print(dut, DUT_MSG_ERROR, "Failed to set " |
| 7849 | "monitor interface up"); |
| 7850 | return -2; |
| 7851 | } |
| 7852 | |
| 7853 | pos = buf; |
| 7854 | |
| 7855 | /* Frame Control */ |
| 7856 | switch (frame) { |
| 7857 | case DISASSOC: |
| 7858 | *pos++ = 0xa0; |
| 7859 | break; |
| 7860 | case DEAUTH: |
| 7861 | *pos++ = 0xc0; |
| 7862 | break; |
| 7863 | case SAQUERY: |
| 7864 | *pos++ = 0xd0; |
| 7865 | break; |
| 7866 | } |
| 7867 | |
| 7868 | if (protected == INCORRECT_KEY) |
| 7869 | *pos++ = 0x40; /* Set Protected field to 1 */ |
| 7870 | else |
| 7871 | *pos++ = 0x00; |
| 7872 | |
| 7873 | /* Duration */ |
| 7874 | *pos++ = 0x00; |
| 7875 | *pos++ = 0x00; |
| 7876 | |
| 7877 | /* addr1 = DA (station) */ |
| 7878 | memcpy(pos, addr_sta, 6); |
| 7879 | pos += 6; |
| 7880 | /* addr2 = SA (own address) */ |
| 7881 | memcpy(pos, addr_own, 6); |
| 7882 | pos += 6; |
| 7883 | /* addr3 = BSSID (own address) */ |
| 7884 | memcpy(pos, addr_own, 6); |
| 7885 | pos += 6; |
| 7886 | |
| 7887 | /* Seq# (to be filled by driver/mac80211) */ |
| 7888 | *pos++ = 0x00; |
| 7889 | *pos++ = 0x00; |
| 7890 | |
| 7891 | if (protected == INCORRECT_KEY) { |
| 7892 | /* CCMP parameters */ |
| 7893 | memcpy(pos, "\x61\x01\x00\x20\x00\x10\x00\x00", 8); |
| 7894 | pos += 8; |
| 7895 | } |
| 7896 | |
| 7897 | if (protected == INCORRECT_KEY) { |
| 7898 | switch (frame) { |
| 7899 | case DEAUTH: |
| 7900 | /* Reason code (encrypted) */ |
| 7901 | memcpy(pos, "\xa7\x39", 2); |
| 7902 | pos += 2; |
| 7903 | break; |
| 7904 | case DISASSOC: |
| 7905 | /* Reason code (encrypted) */ |
| 7906 | memcpy(pos, "\xa7\x39", 2); |
| 7907 | pos += 2; |
| 7908 | break; |
| 7909 | case SAQUERY: |
| 7910 | /* Category|Action|TransID (encrypted) */ |
| 7911 | memcpy(pos, "\x6f\xbd\xe9\x4d", 4); |
| 7912 | pos += 4; |
| 7913 | break; |
| 7914 | default: |
| 7915 | return -1; |
| 7916 | } |
| 7917 | |
| 7918 | /* CCMP MIC */ |
| 7919 | memcpy(pos, "\xc8\xd8\x3b\x06\x5d\xb7\x25\x68", 8); |
| 7920 | pos += 8; |
| 7921 | } else { |
| 7922 | switch (frame) { |
| 7923 | case DEAUTH: |
| 7924 | /* reason code = 8 */ |
| 7925 | *pos++ = 0x08; |
| 7926 | *pos++ = 0x00; |
| 7927 | break; |
| 7928 | case DISASSOC: |
| 7929 | /* reason code = 8 */ |
| 7930 | *pos++ = 0x08; |
| 7931 | *pos++ = 0x00; |
| 7932 | break; |
| 7933 | case SAQUERY: |
| 7934 | /* Category - SA Query */ |
| 7935 | *pos++ = 0x08; |
| 7936 | /* SA query Action - Request */ |
| 7937 | *pos++ = 0x00; |
| 7938 | /* Transaction ID */ |
| 7939 | *pos++ = 0x12; |
| 7940 | *pos++ = 0x34; |
| 7941 | break; |
| 7942 | } |
| 7943 | } |
| 7944 | |
| 7945 | s = open_monitor("sigmadut"); |
| 7946 | if (s < 0) { |
| 7947 | send_resp(dut, conn, SIGMA_ERROR, "errorCode,Failed to open " |
| 7948 | "monitor socket"); |
| 7949 | return 0; |
| 7950 | } |
| 7951 | |
| 7952 | res = inject_frame(s, buf, pos - buf, protected == CORRECT_KEY); |
| 7953 | if (res < 0) { |
| 7954 | send_resp(dut, conn, SIGMA_ERROR, "errorCode,Failed to " |
| 7955 | "inject frame"); |
Pradeep Reddy POTTETI | 673d85c | 2016-07-26 19:08:07 +0530 | [diff] [blame] | 7956 | close(s); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7957 | return 0; |
| 7958 | } |
| 7959 | if (res < pos - buf) { |
| 7960 | send_resp(dut, conn, SIGMA_ERROR, "errorCode,Only partial " |
| 7961 | "frame sent"); |
Pradeep Reddy POTTETI | 673d85c | 2016-07-26 19:08:07 +0530 | [diff] [blame] | 7962 | close(s); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7963 | return 0; |
| 7964 | } |
| 7965 | |
| 7966 | close(s); |
| 7967 | |
| 7968 | return 1; |
| 7969 | #else /* __linux__ */ |
| 7970 | send_resp(dut, conn, SIGMA_ERROR, "errorCode,ap_send_frame not " |
| 7971 | "yet supported"); |
| 7972 | return 0; |
| 7973 | #endif /* __linux__ */ |
| 7974 | } |
| 7975 | |
| 7976 | |
| 7977 | int ap_send_frame_hs2(struct sigma_dut *dut, struct sigma_conn *conn, |
| 7978 | struct sigma_cmd *cmd) |
| 7979 | { |
| 7980 | const char *val, *dest; |
| 7981 | char buf[100]; |
| 7982 | |
| 7983 | val = get_param(cmd, "FrameName"); |
| 7984 | if (val == NULL) |
| 7985 | return -1; |
| 7986 | |
| 7987 | if (strcasecmp(val, "QoSMapConfigure") == 0) { |
| 7988 | dest = get_param(cmd, "Dest"); |
| 7989 | if (!dest) |
| 7990 | return -1; |
| 7991 | |
| 7992 | val = get_param(cmd, "QoS_MAP_SET"); |
| 7993 | if (val) { |
| 7994 | dut->ap_qos_map_set = atoi(val); |
| 7995 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_qos_map_set %d", |
| 7996 | dut->ap_qos_map_set); |
| 7997 | } |
| 7998 | |
| 7999 | if (dut->ap_qos_map_set == 1) |
| 8000 | run_hostapd_cli(dut, "set_qos_map_set " QOS_MAP_SET_1); |
| 8001 | else if (dut->ap_qos_map_set == 2) |
| 8002 | run_hostapd_cli(dut, "set_qos_map_set " QOS_MAP_SET_2); |
| 8003 | |
| 8004 | snprintf(buf, sizeof(buf), "send_qos_map_conf %s", dest); |
| 8005 | if (run_hostapd_cli(dut, buf) != 0) |
| 8006 | return -1; |
| 8007 | } |
| 8008 | |
| 8009 | return 1; |
| 8010 | } |
| 8011 | |
| 8012 | |
| 8013 | static int ath_ap_send_frame_vht(struct sigma_dut *dut, struct sigma_conn *conn, |
| 8014 | struct sigma_cmd *cmd) |
| 8015 | { |
| 8016 | const char *val; |
| 8017 | char *ifname; |
| 8018 | char buf[100]; |
| 8019 | int chwidth, nss; |
| 8020 | |
| 8021 | val = get_param(cmd, "FrameName"); |
| 8022 | if (!val || strcasecmp(val, "op_md_notif_frm") != 0) { |
| 8023 | send_resp(dut, conn, SIGMA_ERROR, |
| 8024 | "errorCode,Unsupported FrameName"); |
| 8025 | return 0; |
| 8026 | } |
| 8027 | |
| 8028 | /* |
| 8029 | * Sequence of commands for Opmode notification on |
| 8030 | * Peregrine based products |
| 8031 | */ |
| 8032 | ifname = get_main_ifname(); |
| 8033 | |
| 8034 | /* Disable STBC */ |
| 8035 | snprintf(buf, sizeof(buf), "iwpriv %s tx_stbc 0", ifname); |
| 8036 | if (system(buf) != 0) { |
| 8037 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 8038 | "iwpriv tx_stbc 0 failed!"); |
| 8039 | } |
| 8040 | |
| 8041 | /* Check whether optional arg channel width was passed */ |
| 8042 | val = get_param(cmd, "Channel_width"); |
| 8043 | if (val) { |
| 8044 | switch (atoi(val)) { |
| 8045 | case 20: |
| 8046 | chwidth = 0; |
| 8047 | break; |
| 8048 | case 40: |
| 8049 | chwidth = 1; |
| 8050 | break; |
| 8051 | case 80: |
| 8052 | chwidth = 2; |
| 8053 | break; |
| 8054 | case 160: |
| 8055 | chwidth = 3; |
| 8056 | break; |
| 8057 | default: |
| 8058 | chwidth = 2; |
| 8059 | break; |
| 8060 | } |
| 8061 | snprintf(buf, sizeof(buf), "iwpriv %s chwidth %d", |
| 8062 | ifname, chwidth); |
| 8063 | if (system(buf) != 0) { |
| 8064 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 8065 | "iwpriv chwidth failed!"); |
| 8066 | } |
| 8067 | } |
| 8068 | |
| 8069 | /* Check whether optional arg NSS was passed */ |
| 8070 | val = get_param(cmd, "NSS"); |
| 8071 | if (val) { |
| 8072 | /* Convert nss to chainmask */ |
| 8073 | switch (atoi(val)) { |
| 8074 | case 1: |
| 8075 | nss = 1; |
| 8076 | break; |
| 8077 | case 2: |
| 8078 | nss = 3; |
| 8079 | break; |
| 8080 | case 3: |
| 8081 | nss = 7; |
| 8082 | break; |
| 8083 | default: |
| 8084 | /* We do not support NSS > 3 */ |
| 8085 | nss = 3; |
| 8086 | break; |
| 8087 | } |
| 8088 | snprintf(buf, sizeof(buf), "iwpriv %s rxchainmask %d", |
| 8089 | ifname, nss); |
| 8090 | if (system(buf) != 0) { |
| 8091 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 8092 | "iwpriv rxchainmask failed!"); |
| 8093 | } |
| 8094 | } |
| 8095 | |
| 8096 | /* Send the opmode notification */ |
Sunil Dutt | 27ec7f6 | 2017-09-14 18:22:59 +0300 | [diff] [blame] | 8097 | snprintf(buf, sizeof(buf), "iwpriv %s opmode_notify 1", ifname); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8098 | if (system(buf) != 0) { |
| 8099 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 8100 | "iwpriv opmode_notify failed!"); |
| 8101 | } |
| 8102 | |
| 8103 | return 1; |
| 8104 | } |
| 8105 | |
| 8106 | |
priyadharshini gowthaman | a27b5b6 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 8107 | static int ath_ap_send_frame_loc(struct sigma_dut *dut, struct sigma_conn *conn, |
| 8108 | struct sigma_cmd *cmd) |
| 8109 | { |
| 8110 | const char *val; |
| 8111 | FILE *f; |
priyadharshini gowthaman | a61badd | 2016-08-16 13:37:27 -0700 | [diff] [blame] | 8112 | int rand_int = 0; |
priyadharshini gowthaman | a27b5b6 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 8113 | |
| 8114 | val = get_param(cmd, "MsntType"); |
| 8115 | if (val) { |
| 8116 | if (dut->ap_msnt_type == 0) |
| 8117 | dut->ap_msnt_type = atoi(val); |
| 8118 | |
| 8119 | if (dut->ap_msnt_type != 5 && dut->ap_msnt_type != 2) { |
| 8120 | dut->ap_msnt_type = atoi(val); |
| 8121 | if (dut->ap_msnt_type == 1) { |
priyadharshini gowthaman | a61badd | 2016-08-16 13:37:27 -0700 | [diff] [blame] | 8122 | val = get_param(cmd, "RandInterval"); |
| 8123 | if (val) |
| 8124 | rand_int = atoi(val); |
priyadharshini gowthaman | a27b5b6 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 8125 | f = fopen("/tmp/ftmrr.txt", "a"); |
| 8126 | if (!f) { |
| 8127 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 8128 | "Failed to open /tmp/ftmrr.txt"); |
| 8129 | return -1; |
| 8130 | } |
| 8131 | |
| 8132 | fprintf(f, "sta_mac = %s\n", cmd->values[3]); |
priyadharshini gowthaman | a61badd | 2016-08-16 13:37:27 -0700 | [diff] [blame] | 8133 | 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", |
| 8134 | rand_int, cmd->values[7]); |
priyadharshini gowthaman | a27b5b6 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 8135 | fclose(f); |
| 8136 | dut->ap_msnt_type = 5; |
| 8137 | run_system(dut, "wpc -f /tmp/ftmrr.txt"); |
| 8138 | } |
| 8139 | } else if (dut->ap_msnt_type == 5) { |
| 8140 | run_system(dut, "wpc -f /tmp/ftmrr.txt"); |
| 8141 | } else if (dut->ap_msnt_type == 2) { |
| 8142 | f = fopen("/tmp/wru.txt", "w"); |
| 8143 | if (!f) { |
| 8144 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 8145 | "Failed to open /tmp/wru.txt"); |
| 8146 | return -1; |
| 8147 | } |
| 8148 | |
| 8149 | fprintf(f, "sta_mac = %s\n", cmd->values[3]); |
| 8150 | fprintf(f, "meas_type = 0x08\ndialogtoken = 0x1\nnum_repetitions = 0x0\nmeas_token = 0x1\nmeas_req_mode = 0x00\nloc_subject = 0x01\n"); |
| 8151 | fclose(f); |
| 8152 | run_system(dut, "wpc -w /tmp/wru.txt"); |
| 8153 | } |
| 8154 | } |
| 8155 | return 1; |
| 8156 | } |
| 8157 | |
| 8158 | |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 8159 | /* |
| 8160 | * The following functions parse_send_frame_params_int(), |
| 8161 | * parse_send_frame_params_str(), and parse_send_frame_params_mac() |
| 8162 | * are used by ath_ap_send_frame_bcn_rpt_req(). |
| 8163 | * Beacon Report Request is a frame used as part of the MBO program. |
| 8164 | * The command for sending beacon report has a lot of |
| 8165 | * arguments and having these functions reduces code size. |
| 8166 | * |
| 8167 | */ |
| 8168 | static int parse_send_frame_params_int(char *param, struct sigma_cmd *cmd, |
| 8169 | struct sigma_dut *dut, |
| 8170 | char *buf, size_t buf_size) |
| 8171 | { |
| 8172 | const char *str_val; |
| 8173 | int int_val; |
| 8174 | char temp[100]; |
| 8175 | |
| 8176 | str_val = get_param(cmd, param); |
| 8177 | if (!str_val) { |
| 8178 | sigma_dut_print(dut, DUT_MSG_ERROR, "%s not given", param); |
| 8179 | return -1; |
| 8180 | } |
| 8181 | int_val = atoi(str_val); |
| 8182 | snprintf(temp, sizeof(temp), " %d", int_val); |
Peng Xu | 591be45 | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 8183 | strlcat(buf, temp, buf_size); |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 8184 | return 0; |
| 8185 | } |
| 8186 | |
| 8187 | |
| 8188 | static int parse_send_frame_params_str(char *param, struct sigma_cmd *cmd, |
| 8189 | struct sigma_dut *dut, |
| 8190 | char *buf, size_t buf_size) |
| 8191 | { |
| 8192 | const char *str_val; |
| 8193 | char temp[100]; |
| 8194 | |
| 8195 | str_val = get_param(cmd, param); |
| 8196 | if (!str_val) { |
| 8197 | sigma_dut_print(dut, DUT_MSG_ERROR, "%s not given", param); |
| 8198 | return -1; |
| 8199 | } |
| 8200 | snprintf(temp, sizeof(temp), " %s", str_val); |
| 8201 | temp[sizeof(temp) - 1] = '\0'; |
Peng Xu | 591be45 | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 8202 | strlcat(buf, temp, buf_size); |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 8203 | return 0; |
| 8204 | } |
| 8205 | |
| 8206 | |
| 8207 | static int parse_send_frame_params_mac(char *param, struct sigma_cmd *cmd, |
| 8208 | struct sigma_dut *dut, |
| 8209 | char *buf, size_t buf_size) |
| 8210 | { |
| 8211 | const char *str_val; |
| 8212 | unsigned char mac[6]; |
| 8213 | char temp[100]; |
| 8214 | |
| 8215 | str_val = get_param(cmd, param); |
| 8216 | if (!str_val) { |
| 8217 | sigma_dut_print(dut, DUT_MSG_ERROR, "%s not given", param); |
| 8218 | return -1; |
| 8219 | } |
| 8220 | |
| 8221 | if (parse_mac_address(dut, str_val, mac) < 0) { |
| 8222 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 8223 | "MAC Address not in proper format"); |
| 8224 | return -1; |
| 8225 | } |
| 8226 | snprintf(temp, sizeof(temp), " %02x:%02x:%02x:%02x:%02x:%02x", |
| 8227 | mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]); |
Peng Xu | 591be45 | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 8228 | strlcat(buf, temp, buf_size); |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 8229 | return 0; |
| 8230 | } |
| 8231 | |
| 8232 | |
| 8233 | static void fill_1_or_0_based_on_presence(struct sigma_cmd *cmd, char *param, |
| 8234 | char *buf, size_t buf_size) |
| 8235 | { |
| 8236 | const char *str_val; |
| 8237 | char *value = " 1"; |
| 8238 | |
| 8239 | str_val = get_param(cmd, param); |
| 8240 | if (!str_val || str_val[0] == '\0') |
| 8241 | value = " 0"; |
Peng Xu | 591be45 | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 8242 | strlcat(buf, value, buf_size); |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 8243 | |
| 8244 | } |
| 8245 | |
| 8246 | |
| 8247 | /* |
| 8248 | * wifitool athN sendbcnrpt |
| 8249 | * <STA MAC - Plugs in from Dest_MAC> |
| 8250 | * <regclass - Plugs in from RegClass - int> |
| 8251 | * <channum - Plugs in from Channel PARAM of dev_send_frame - int> |
| 8252 | * <rand_ivl - Plugs in from RandInt - string> |
| 8253 | * <duration - Plugs in from MeaDur - integer> |
| 8254 | * <mode - Plugs in from MeaMode - string> |
| 8255 | * <req_ssid - Plugs in from SSID PARAM of dev_send_frame - string> |
| 8256 | * <rep_cond - Plugs in from RptCond - integer> |
| 8257 | * <rpt_detail - Plugs in from RptDet - integer> |
| 8258 | * <req_ie - Plugs in from ReqInfo PARAM of dev_send_frame - string> |
| 8259 | * <chanrpt_mode - Plugs in from APChanRpt - integer> |
| 8260 | * <specific_bssid - Plugs in from BSSID PARAM of dev_send_frame> |
| 8261 | * [AP channel numbers] |
| 8262 | */ |
| 8263 | static int ath_ap_send_frame_bcn_rpt_req(struct sigma_dut *dut, |
| 8264 | struct sigma_cmd *cmd, |
| 8265 | const char *ifname) |
| 8266 | { |
| 8267 | char buf[100]; |
| 8268 | int rpt_det; |
| 8269 | const char *str_val; |
| 8270 | const char *mea_mode; |
| 8271 | |
| 8272 | snprintf(buf, sizeof(buf), "wifitool %s sendbcnrpt", ifname); |
| 8273 | |
| 8274 | if (parse_send_frame_params_mac("Dest_MAC", cmd, dut, buf, sizeof(buf))) |
| 8275 | return -1; |
| 8276 | if (parse_send_frame_params_int("RegClass", cmd, dut, buf, sizeof(buf))) |
| 8277 | return -1; |
| 8278 | if (parse_send_frame_params_int("Channel", cmd, dut, buf, sizeof(buf))) |
| 8279 | return -1; |
| 8280 | if (parse_send_frame_params_str("RandInt", cmd, dut, buf, sizeof(buf))) |
| 8281 | return -1; |
| 8282 | if (parse_send_frame_params_int("MeaDur", cmd, dut, buf, sizeof(buf))) |
| 8283 | return -1; |
| 8284 | |
| 8285 | str_val = get_param(cmd, "MeaMode"); |
| 8286 | if (!str_val) { |
| 8287 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 8288 | "MeaMode parameter not present in send bcn-rpt-req"); |
| 8289 | return -1; |
| 8290 | } |
| 8291 | if (strcasecmp(str_val, "passive") == 0) { |
| 8292 | mea_mode = " 0"; |
| 8293 | } else if (strcasecmp(str_val, "active") == 0) { |
| 8294 | mea_mode = " 1"; |
| 8295 | } else if (strcasecmp(str_val, "table") == 0) { |
| 8296 | mea_mode = " 2"; |
| 8297 | } else { |
| 8298 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 8299 | "MEA-MODE Value not correctly given"); |
| 8300 | return -1; |
| 8301 | } |
Peng Xu | 591be45 | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 8302 | strlcat(buf, mea_mode, sizeof(buf)); |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 8303 | |
| 8304 | fill_1_or_0_based_on_presence(cmd, "SSID", buf, sizeof(buf)); |
| 8305 | |
| 8306 | if (parse_send_frame_params_int("RptCond", cmd, dut, buf, sizeof(buf))) |
| 8307 | return -1; |
| 8308 | |
| 8309 | if (parse_send_frame_params_int("RptDet", cmd, dut, buf, sizeof(buf))) |
| 8310 | return -1; |
| 8311 | str_val = get_param(cmd, "RptDet"); |
| 8312 | rpt_det = str_val ? atoi(str_val) : 0; |
| 8313 | |
| 8314 | if (rpt_det) |
| 8315 | fill_1_or_0_based_on_presence(cmd, "ReqInfo", buf, sizeof(buf)); |
| 8316 | else |
Peng Xu | 591be45 | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 8317 | strlcat(buf, " 0", sizeof(buf)); |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 8318 | |
| 8319 | if (rpt_det) |
| 8320 | fill_1_or_0_based_on_presence(cmd, "APChanRpt", buf, |
| 8321 | sizeof(buf)); |
| 8322 | else |
Peng Xu | 591be45 | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 8323 | strlcat(buf, " 0", sizeof(buf)); |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 8324 | |
| 8325 | if (parse_send_frame_params_mac("BSSID", cmd, dut, buf, sizeof(buf))) |
| 8326 | return -1; |
| 8327 | |
priyadharshini gowthaman | 2a4d20e | 2017-12-28 13:01:34 -0800 | [diff] [blame] | 8328 | str_val = get_param(cmd, "APChanRpt"); |
| 8329 | if (str_val) { |
| 8330 | const char *pos; |
| 8331 | int ap_chanrpt; |
| 8332 | int ap_chanrpt_2 = 0; |
| 8333 | char chanrpt[100]; |
| 8334 | |
| 8335 | ap_chanrpt = atoi(str_val); |
| 8336 | pos = strchr(str_val, '_'); |
| 8337 | if (pos) { |
| 8338 | pos++; |
| 8339 | ap_chanrpt_2 = atoi(pos); |
| 8340 | } |
| 8341 | if (ap_chanrpt) { |
| 8342 | snprintf(chanrpt, sizeof(chanrpt), " %d", ap_chanrpt); |
| 8343 | strlcat(buf, chanrpt, sizeof(buf)); |
| 8344 | } |
| 8345 | if (ap_chanrpt_2) { |
| 8346 | snprintf(chanrpt, sizeof(chanrpt), " %d", ap_chanrpt_2); |
| 8347 | strlcat(buf, chanrpt, sizeof(buf)); |
| 8348 | } |
| 8349 | } |
| 8350 | |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 8351 | run_system(dut, buf); |
| 8352 | return 0; |
| 8353 | } |
| 8354 | |
| 8355 | |
| 8356 | static void inform_and_sleep(struct sigma_dut *dut, int seconds) |
| 8357 | { |
| 8358 | sigma_dut_print(dut, DUT_MSG_DEBUG, "sleeping for %d seconds", seconds); |
| 8359 | sleep(seconds); |
| 8360 | sigma_dut_print(dut, DUT_MSG_DEBUG, "woke up after %d seconds", |
| 8361 | seconds); |
| 8362 | } |
| 8363 | |
| 8364 | |
| 8365 | static int ath_ap_send_frame_btm_req(struct sigma_dut *dut, |
| 8366 | struct sigma_cmd *cmd, const char *ifname) |
| 8367 | { |
| 8368 | unsigned char mac_addr[ETH_ALEN]; |
| 8369 | int disassoc_timer; |
| 8370 | char buf[100]; |
| 8371 | const char *val; |
| 8372 | int cand_list = 1; |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 8373 | |
| 8374 | val = get_param(cmd, "Dest_MAC"); |
| 8375 | if (!val || parse_mac_address(dut, val, mac_addr) < 0) { |
| 8376 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 8377 | "MAC Address not in proper format"); |
| 8378 | return -1; |
| 8379 | } |
| 8380 | |
| 8381 | val = get_param(cmd, "Disassoc_Timer"); |
| 8382 | if (val) |
| 8383 | disassoc_timer = atoi(val); |
| 8384 | else |
| 8385 | disassoc_timer = dut->ap_disassoc_timer; |
Jouni Malinen | 032aeab | 2018-01-04 12:30:46 +0200 | [diff] [blame] | 8386 | if (disassoc_timer < 0) { |
| 8387 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 8388 | "Invalid Disassoc_Timer value %d", |
| 8389 | disassoc_timer); |
| 8390 | return -1; |
| 8391 | } |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 8392 | |
| 8393 | val = get_param(cmd, "Cand_List"); |
| 8394 | if (val && val[0]) |
| 8395 | cand_list = atoi(val); |
| 8396 | |
| 8397 | val = get_param(cmd, "BTMQuery_Reason_Code"); |
| 8398 | if (val) { |
| 8399 | snprintf(buf, sizeof(buf), "iwpriv %s mbo_trans_rs %s", |
| 8400 | ifname, val); |
| 8401 | run_system(dut, buf); |
| 8402 | } |
| 8403 | |
priyadharshini gowthaman | 776562e | 2017-12-20 12:33:34 -0800 | [diff] [blame] | 8404 | if (dut->ap_btmreq_disassoc_imnt && !dut->ap_assoc_delay) { |
| 8405 | snprintf(buf, sizeof(buf), "iwpriv %s mbo_asoc_ret 1", ifname); |
| 8406 | run_system(dut, buf); |
| 8407 | } |
| 8408 | |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 8409 | snprintf(buf, sizeof(buf), |
priyadharshini gowthaman | 776562e | 2017-12-20 12:33:34 -0800 | [diff] [blame] | 8410 | "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] | 8411 | ifname, mac_addr[0], mac_addr[1], mac_addr[2], mac_addr[3], |
| 8412 | mac_addr[4], mac_addr[5], cand_list, disassoc_timer, |
| 8413 | dut->ap_btmreq_disassoc_imnt, |
| 8414 | dut->ap_btmreq_term_bit, |
priyadharshini gowthaman | 94062b5 | 2017-12-20 12:33:34 -0800 | [diff] [blame] | 8415 | dut->ap_btmreq_bss_term_tsf, |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 8416 | dut->ap_btmreq_bss_term_dur); |
| 8417 | run_system(dut, buf); |
| 8418 | |
| 8419 | if (dut->ap_btmreq_term_bit) { |
priyadharshini gowthaman | 94062b5 | 2017-12-20 12:33:34 -0800 | [diff] [blame] | 8420 | if (dut->ap_btmreq_bss_term_tsf >= 2) |
| 8421 | inform_and_sleep(dut, dut->ap_btmreq_bss_term_tsf - 2); |
priyadharshini gowthaman | 776562e | 2017-12-20 12:33:34 -0800 | [diff] [blame] | 8422 | run_system_wrapper( |
| 8423 | dut, "iwpriv %s kickmac %02x:%02x:%02x:%02x:%02x:%02x", |
| 8424 | ifname, |
| 8425 | mac_addr[0], mac_addr[1], mac_addr[2], |
| 8426 | mac_addr[3], mac_addr[4], mac_addr[5]); |
| 8427 | inform_and_sleep(dut, 2); |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 8428 | run_system_wrapper(dut, "ifconfig %s down", ifname); |
priyadharshini gowthaman | 776562e | 2017-12-20 12:33:34 -0800 | [diff] [blame] | 8429 | inform_and_sleep(dut, 5); |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 8430 | run_system_wrapper(dut, "ifconfig %s up", ifname); |
| 8431 | } else if (dut->ap_btmreq_disassoc_imnt) { |
| 8432 | inform_and_sleep(dut, (disassoc_timer / 1000) + 1); |
| 8433 | run_system_wrapper(dut, |
| 8434 | "iwpriv %s kickmac %02x:%02x:%02x:%02x:%02x:%02x", |
| 8435 | ifname, |
| 8436 | mac_addr[0], mac_addr[1], mac_addr[2], |
| 8437 | mac_addr[3], mac_addr[4], mac_addr[5]); |
| 8438 | } |
| 8439 | return 0; |
| 8440 | } |
| 8441 | |
| 8442 | |
priyadharshini gowthaman | 2a4d20e | 2017-12-28 13:01:34 -0800 | [diff] [blame] | 8443 | static int ath_ap_send_frame_disassoc(struct sigma_dut *dut, |
| 8444 | struct sigma_cmd *cmd, const char *ifname) |
| 8445 | { |
| 8446 | unsigned char mac_addr[ETH_ALEN]; |
| 8447 | const char *val; |
| 8448 | |
| 8449 | val = get_param(cmd, "Dest_MAC"); |
| 8450 | if (!val || parse_mac_address(dut, val, mac_addr) < 0) { |
| 8451 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 8452 | "MAC Address not in proper format"); |
| 8453 | return -1; |
| 8454 | } |
| 8455 | |
| 8456 | run_system_wrapper(dut, |
| 8457 | "iwpriv %s kickmac %02x:%02x:%02x:%02x:%02x:%02x", |
| 8458 | ifname, mac_addr[0], mac_addr[1], mac_addr[2], |
| 8459 | mac_addr[3], mac_addr[4], mac_addr[5]); |
| 8460 | return 0; |
| 8461 | } |
| 8462 | |
| 8463 | |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 8464 | static int ath_ap_send_frame_mbo(struct sigma_dut *dut, struct sigma_conn *conn, |
| 8465 | struct sigma_cmd *cmd) |
| 8466 | { |
| 8467 | const char *val; |
| 8468 | char *ifname; |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 8469 | |
| 8470 | ifname = get_main_ifname(); |
| 8471 | |
| 8472 | val = get_param(cmd, "FrameName"); |
| 8473 | if (!val) |
| 8474 | return -1; |
| 8475 | |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 8476 | if (strcasecmp(val, "BTMReq") == 0) |
| 8477 | ath_ap_send_frame_btm_req(dut, cmd, ifname); |
| 8478 | else if (strcasecmp(val, "BcnRptReq") == 0) |
| 8479 | ath_ap_send_frame_bcn_rpt_req(dut, cmd, ifname); |
priyadharshini gowthaman | 2a4d20e | 2017-12-28 13:01:34 -0800 | [diff] [blame] | 8480 | else if (strcasecmp(val, "disassoc") == 0) |
| 8481 | ath_ap_send_frame_disassoc(dut, cmd, ifname); |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 8482 | else |
| 8483 | return -1; |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 8484 | |
| 8485 | return 1; |
| 8486 | } |
| 8487 | |
| 8488 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8489 | static int ap_send_frame_vht(struct sigma_dut *dut, struct sigma_conn *conn, |
| 8490 | struct sigma_cmd *cmd) |
| 8491 | { |
| 8492 | switch (get_driver_type()) { |
| 8493 | case DRIVER_ATHEROS: |
| 8494 | return ath_ap_send_frame_vht(dut, conn, cmd); |
| 8495 | break; |
| 8496 | case DRIVER_OPENWRT: |
| 8497 | switch (get_openwrt_driver_type()) { |
| 8498 | case OPENWRT_DRIVER_ATHEROS: |
| 8499 | return ath_ap_send_frame_vht(dut, conn, cmd); |
| 8500 | default: |
| 8501 | send_resp(dut, conn, SIGMA_ERROR, |
| 8502 | "errorCode,Unsupported ap_send_frame with the current openwrt driver"); |
| 8503 | return 0; |
| 8504 | } |
| 8505 | default: |
| 8506 | send_resp(dut, conn, SIGMA_ERROR, |
| 8507 | "errorCode,Unsupported ap_send_frame with the current driver"); |
| 8508 | return 0; |
| 8509 | } |
| 8510 | } |
| 8511 | |
| 8512 | |
priyadharshini gowthaman | a27b5b6 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 8513 | static int ap_send_frame_loc(struct sigma_dut *dut, struct sigma_conn *conn, |
| 8514 | struct sigma_cmd *cmd) |
| 8515 | { |
| 8516 | switch (get_driver_type()) { |
| 8517 | case DRIVER_ATHEROS: |
| 8518 | return ath_ap_send_frame_loc(dut, conn, cmd); |
| 8519 | case DRIVER_OPENWRT: |
| 8520 | switch (get_openwrt_driver_type()) { |
| 8521 | case OPENWRT_DRIVER_ATHEROS: |
| 8522 | return ath_ap_send_frame_loc(dut, conn, cmd); |
| 8523 | default: |
| 8524 | send_resp(dut, conn, SIGMA_ERROR, |
| 8525 | "errorCode,Unsupported ap_send_frame_loc with the current openwrt driver"); |
| 8526 | return 0; |
| 8527 | } |
| 8528 | default: |
| 8529 | send_resp(dut, conn, SIGMA_ERROR, |
| 8530 | "errorCode,Unsupported ap_send_frame_loc with the current driver"); |
| 8531 | return 0; |
| 8532 | } |
| 8533 | } |
| 8534 | |
| 8535 | |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 8536 | static int ap_send_frame_mbo(struct sigma_dut *dut, struct sigma_conn *conn, |
| 8537 | struct sigma_cmd *cmd) |
| 8538 | { |
| 8539 | switch (get_driver_type()) { |
| 8540 | case DRIVER_ATHEROS: |
| 8541 | return ath_ap_send_frame_mbo(dut, conn, cmd); |
| 8542 | case DRIVER_OPENWRT: |
| 8543 | switch (get_openwrt_driver_type()) { |
| 8544 | case OPENWRT_DRIVER_ATHEROS: |
| 8545 | return ath_ap_send_frame_mbo(dut, conn, cmd); |
| 8546 | default: |
| 8547 | send_resp(dut, conn, SIGMA_ERROR, |
| 8548 | "errorCode,Unsupported ap_send_frame with the current openwrt driver"); |
| 8549 | return 0; |
| 8550 | } |
| 8551 | default: |
| 8552 | send_resp(dut, conn, SIGMA_ERROR, |
| 8553 | "errorCode,Unsupported ap_send_frame with the current driver"); |
| 8554 | return 0; |
| 8555 | } |
| 8556 | } |
| 8557 | |
| 8558 | |
Lior David | 0fe101e | 2017-03-09 16:09:50 +0200 | [diff] [blame] | 8559 | static int ap_send_frame_60g(struct sigma_dut *dut, |
| 8560 | struct sigma_conn *conn, |
| 8561 | struct sigma_cmd *cmd) |
| 8562 | { |
| 8563 | switch (get_driver_type()) { |
| 8564 | #ifdef __linux__ |
| 8565 | case DRIVER_WIL6210: |
| 8566 | return wil6210_send_frame_60g(dut, conn, cmd); |
| 8567 | #endif /* __linux__ */ |
| 8568 | default: |
| 8569 | send_resp(dut, conn, SIGMA_ERROR, |
| 8570 | "errorCode,Unsupported sta_set_frame(60G) with the current driver"); |
| 8571 | return 0; |
| 8572 | } |
| 8573 | } |
| 8574 | |
| 8575 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8576 | int cmd_ap_send_frame(struct sigma_dut *dut, struct sigma_conn *conn, |
| 8577 | struct sigma_cmd *cmd) |
| 8578 | { |
| 8579 | /* const char *name = get_param(cmd, "NAME"); */ |
| 8580 | /* const char *ifname = get_param(cmd, "INTERFACE"); */ |
| 8581 | const char *val; |
| 8582 | enum send_frame_type frame; |
| 8583 | enum send_frame_protection protected; |
| 8584 | char buf[100]; |
| 8585 | |
| 8586 | val = get_param(cmd, "Program"); |
| 8587 | if (val) { |
| 8588 | if (strcasecmp(val, "HS2") == 0 || |
Adil Saeed Musthafa | 33ea287 | 2017-04-10 23:13:24 -0700 | [diff] [blame] | 8589 | strcasecmp(val, "HS2-R2") == 0 || |
| 8590 | strcasecmp(val, "IOTLP") == 0) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8591 | return ap_send_frame_hs2(dut, conn, cmd); |
| 8592 | if (strcasecmp(val, "VHT") == 0) |
| 8593 | return ap_send_frame_vht(dut, conn, cmd); |
priyadharshini gowthaman | a27b5b6 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 8594 | if (strcasecmp(val, "LOC") == 0) |
| 8595 | return ap_send_frame_loc(dut, conn, cmd); |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 8596 | if (strcasecmp(val, "MBO") == 0) |
| 8597 | return ap_send_frame_mbo(dut, conn, cmd); |
Lior David | 0fe101e | 2017-03-09 16:09:50 +0200 | [diff] [blame] | 8598 | if (strcasecmp(val, "60GHz") == 0) |
| 8599 | return ap_send_frame_60g(dut, conn, cmd); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8600 | } |
| 8601 | |
| 8602 | val = get_param(cmd, "PMFFrameType"); |
| 8603 | if (val == NULL) |
| 8604 | val = get_param(cmd, "FrameName"); |
| 8605 | if (val == NULL) |
| 8606 | val = get_param(cmd, "Type"); |
| 8607 | if (val == NULL) |
| 8608 | return -1; |
| 8609 | if (strcasecmp(val, "disassoc") == 0) |
| 8610 | frame = DISASSOC; |
| 8611 | else if (strcasecmp(val, "deauth") == 0) |
| 8612 | frame = DEAUTH; |
| 8613 | else if (strcasecmp(val, "saquery") == 0) |
| 8614 | frame = SAQUERY; |
| 8615 | else { |
| 8616 | send_resp(dut, conn, SIGMA_ERROR, "errorCode,Unsupported " |
| 8617 | "PMFFrameType"); |
| 8618 | return 0; |
| 8619 | } |
| 8620 | |
| 8621 | val = get_param(cmd, "PMFProtected"); |
| 8622 | if (val == NULL) |
| 8623 | val = get_param(cmd, "Protected"); |
| 8624 | if (val == NULL) |
| 8625 | return -1; |
| 8626 | if (strcasecmp(val, "Correct-key") == 0 || |
| 8627 | strcasecmp(val, "CorrectKey") == 0) |
| 8628 | protected = CORRECT_KEY; |
| 8629 | else if (strcasecmp(val, "IncorrectKey") == 0) |
| 8630 | protected = INCORRECT_KEY; |
| 8631 | else if (strcasecmp(val, "Unprotected") == 0) |
| 8632 | protected = UNPROTECTED; |
| 8633 | else { |
| 8634 | send_resp(dut, conn, SIGMA_ERROR, "errorCode,Unsupported " |
| 8635 | "PMFProtected"); |
| 8636 | return 0; |
| 8637 | } |
| 8638 | |
| 8639 | val = get_param(cmd, "stationID"); |
| 8640 | if (val == NULL) |
| 8641 | return -1; |
| 8642 | |
| 8643 | if (protected == INCORRECT_KEY || |
| 8644 | (protected == UNPROTECTED && frame == SAQUERY)) |
| 8645 | return ap_inject_frame(dut, conn, frame, protected, val); |
| 8646 | |
| 8647 | switch (frame) { |
| 8648 | case DISASSOC: |
| 8649 | snprintf(buf, sizeof(buf), "disassoc %s test=%d", |
| 8650 | val, protected == CORRECT_KEY); |
| 8651 | break; |
| 8652 | case DEAUTH: |
| 8653 | snprintf(buf, sizeof(buf), "deauth %s test=%d", |
| 8654 | val, protected == CORRECT_KEY); |
| 8655 | break; |
| 8656 | case SAQUERY: |
| 8657 | snprintf(buf, sizeof(buf), "sa_query %s", val); |
| 8658 | break; |
| 8659 | } |
| 8660 | |
| 8661 | if (run_hostapd_cli(dut, buf) != 0) |
| 8662 | return -2; |
| 8663 | |
| 8664 | return 1; |
| 8665 | } |
| 8666 | |
| 8667 | |
| 8668 | static int cmd_ap_get_mac_address(struct sigma_dut *dut, |
| 8669 | struct sigma_conn *conn, |
| 8670 | struct sigma_cmd *cmd) |
| 8671 | { |
| 8672 | #if defined( __linux__) |
| 8673 | /* const char *name = get_param(cmd, "NAME"); */ |
| 8674 | /* const char *ifname = get_param(cmd, "INTERFACE"); */ |
Jouni Malinen | f898464 | 2017-10-12 00:02:37 +0300 | [diff] [blame] | 8675 | char resp[100]; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8676 | unsigned char addr[6]; |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 8677 | char ifname[50]; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8678 | struct ifreq ifr; |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 8679 | int s, wlan_tag = 1; |
| 8680 | const char *val; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8681 | |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 8682 | val = get_param(cmd, "WLAN_TAG"); |
| 8683 | if (val) { |
| 8684 | wlan_tag = atoi(val); |
| 8685 | if (wlan_tag < 1 || wlan_tag > 3) { |
| 8686 | /* |
| 8687 | * The only valid WLAN Tags as of now as per the latest |
| 8688 | * WFA scripts are 1, 2, and 3. |
| 8689 | */ |
Jouni Malinen | f898464 | 2017-10-12 00:02:37 +0300 | [diff] [blame] | 8690 | send_resp(dut, conn, SIGMA_ERROR, |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 8691 | "errorCode,Unsupported WLAN_TAG"); |
| 8692 | return 0; |
| 8693 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8694 | } |
| 8695 | |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 8696 | get_if_name(dut, ifname, sizeof(ifname), wlan_tag); |
| 8697 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8698 | s = socket(AF_INET, SOCK_DGRAM, 0); |
| 8699 | if (s < 0) |
| 8700 | return -1; |
| 8701 | memset(&ifr, 0, sizeof(ifr)); |
Peng Xu | b8fc5cc | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 8702 | strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name)); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8703 | if (ioctl(s, SIOCGIFHWADDR, &ifr) < 0) { |
| 8704 | perror("ioctl"); |
| 8705 | close(s); |
Jouni Malinen | f898464 | 2017-10-12 00:02:37 +0300 | [diff] [blame] | 8706 | snprintf(resp, sizeof(resp), |
| 8707 | "errorCode,Could not find interface %s", ifname); |
| 8708 | send_resp(dut, conn, SIGMA_ERROR, resp); |
| 8709 | return 0; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8710 | } |
| 8711 | close(s); |
| 8712 | memcpy(addr, ifr.ifr_hwaddr.sa_data, 6); |
| 8713 | |
| 8714 | snprintf(resp, sizeof(resp), "mac,%02x:%02x:%02x:%02x:%02x:%02x", |
| 8715 | addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]); |
| 8716 | send_resp(dut, conn, SIGMA_COMPLETE, resp); |
| 8717 | return 0; |
| 8718 | #elif defined( __QNXNTO__) |
| 8719 | char resp[50]; |
| 8720 | unsigned char addr[6]; |
| 8721 | |
| 8722 | if (!sigma_main_ifname) { |
| 8723 | send_resp(dut, conn, SIGMA_ERROR, "ifname is null"); |
| 8724 | return 0; |
| 8725 | } |
| 8726 | |
| 8727 | if (get_hwaddr(sigma_main_ifname, addr) != 0) { |
| 8728 | send_resp(dut, conn, SIGMA_ERROR, |
| 8729 | "errorCode,Failed to get address"); |
| 8730 | return 0; |
| 8731 | } |
| 8732 | snprintf(resp, sizeof(resp), "mac,%02x:%02x:%02x:%02x:%02x:%02x", |
| 8733 | addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]); |
| 8734 | send_resp(dut, conn, SIGMA_COMPLETE, resp); |
| 8735 | return 0; |
| 8736 | #else /* __linux__ */ |
| 8737 | send_resp(dut, conn, SIGMA_ERROR, "errorCode,ap_get_mac_address not " |
| 8738 | "yet supported"); |
| 8739 | return 0; |
| 8740 | #endif /* __linux__ */ |
| 8741 | } |
| 8742 | |
| 8743 | |
Ankita Bajaj | 0d5825b | 2017-10-25 16:20:17 +0530 | [diff] [blame] | 8744 | int sta_cfon_get_mac_address(struct sigma_dut *dut, struct sigma_conn *conn, |
| 8745 | struct sigma_cmd *cmd) |
| 8746 | { |
| 8747 | return cmd_ap_get_mac_address(dut, conn, cmd); |
| 8748 | } |
| 8749 | |
| 8750 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8751 | static int cmd_ap_set_pmf(struct sigma_dut *dut, struct sigma_conn *conn, |
| 8752 | struct sigma_cmd *cmd) |
| 8753 | { |
| 8754 | /* |
| 8755 | * Ignore the command since the parameters are already handled through |
| 8756 | * ap_set_security. |
| 8757 | */ |
| 8758 | |
| 8759 | return 1; |
| 8760 | } |
| 8761 | |
| 8762 | |
| 8763 | static int cmd_ap_set_hs2(struct sigma_dut *dut, struct sigma_conn *conn, |
| 8764 | struct sigma_cmd *cmd) |
| 8765 | { |
| 8766 | /* const char *name = get_param(cmd, "NAME"); */ |
| 8767 | /* const char *ifname = get_param(cmd, "INTERFACE"); */ |
| 8768 | const char *val, *dest; |
| 8769 | char *pos, buf[100]; |
| 8770 | int i, wlan_tag = 1; |
| 8771 | |
| 8772 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_set_hs2: Processing the " |
| 8773 | "following parameters"); |
| 8774 | for (i = 0; i < cmd->count; i++) { |
| 8775 | sigma_dut_print(dut, DUT_MSG_INFO, "%s %s", cmd->params[i], |
| 8776 | (cmd->values[i] ? cmd->values[i] : "NULL")); |
| 8777 | } |
| 8778 | |
| 8779 | val = get_param(cmd, "ICMPv4_ECHO"); |
| 8780 | if (val && atoi(val)) { |
| 8781 | snprintf(buf, sizeof(buf), "ebtables -F"); |
| 8782 | if (system(buf) != 0) { |
| 8783 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 8784 | "Failed to set ebtables rules, RULE-12"); |
| 8785 | } |
| 8786 | return 1; |
| 8787 | } |
| 8788 | |
| 8789 | val = get_param(cmd, "WLAN_TAG"); |
| 8790 | if (val) { |
| 8791 | wlan_tag = atoi(val); |
| 8792 | if (wlan_tag != 1 && wlan_tag != 2) { |
| 8793 | send_resp(dut, conn, SIGMA_INVALID, |
| 8794 | "errorCode,Invalid WLAN_TAG"); |
| 8795 | return 0; |
| 8796 | } |
| 8797 | } |
| 8798 | |
| 8799 | if (wlan_tag == 2) { |
| 8800 | val = get_param(cmd, "PROXY_ARP"); |
| 8801 | if (val) |
| 8802 | dut->ap2_proxy_arp = atoi(val); |
| 8803 | return 1; |
| 8804 | } |
| 8805 | |
| 8806 | dest = get_param(cmd, "STA_MAC"); |
| 8807 | if (dest) { |
| 8808 | /* This is a special/ugly way of using this command. |
| 8809 | * If "Dest" MAC is included, assume that this command |
| 8810 | * is being issued after ap_config_commit for dynamically |
| 8811 | * setting the QoS Map Set. |
| 8812 | */ |
| 8813 | val = get_param(cmd, "QoS_MAP_SET"); |
| 8814 | if (val) { |
| 8815 | dut->ap_qos_map_set = atoi(val); |
| 8816 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_qos_map_set %d", |
| 8817 | dut->ap_qos_map_set); |
| 8818 | } |
| 8819 | |
| 8820 | if (dut->ap_qos_map_set == 1) |
| 8821 | run_hostapd_cli(dut, "set_qos_map_set " QOS_MAP_SET_1); |
| 8822 | else if (dut->ap_qos_map_set == 2) |
| 8823 | run_hostapd_cli(dut, "set_qos_map_set " QOS_MAP_SET_2); |
| 8824 | |
| 8825 | snprintf(buf, sizeof(buf), "send_qos_map_conf %s", dest); |
| 8826 | if (run_hostapd_cli(dut, buf) != 0) |
| 8827 | return -1; |
| 8828 | } |
| 8829 | |
| 8830 | val = get_param(cmd, "DGAF_DISABLE"); |
| 8831 | if (val) |
| 8832 | dut->ap_dgaf_disable = atoi(val); |
| 8833 | |
| 8834 | dut->ap_interworking = 1; |
| 8835 | |
| 8836 | val = get_param(cmd, "INTERWORKING"); |
| 8837 | if (val == NULL) |
| 8838 | val = get_param(cmd, "INTERNETWORKING"); |
| 8839 | if (val != NULL && atoi(val) == 0) { |
| 8840 | dut->ap_interworking = 0; |
| 8841 | dut->ap_hs2 = 0; |
| 8842 | return 1; |
| 8843 | } |
| 8844 | |
| 8845 | val = get_param(cmd, "ACCS_NET_TYPE"); |
| 8846 | if (val) { |
| 8847 | if (strcasecmp(val, "Chargeable_Public_Network") == 0 || |
| 8848 | strcasecmp(val, "Chargable_Public_Network") == 0 || |
| 8849 | strcasecmp(val, "Chargable Public Network") == 0) |
| 8850 | dut->ap_access_net_type = 2; |
| 8851 | else |
| 8852 | dut->ap_access_net_type = atoi(val); |
| 8853 | } |
| 8854 | |
| 8855 | val = get_param(cmd, "INTERNET"); |
| 8856 | if (val) |
| 8857 | dut->ap_internet = atoi(val); |
| 8858 | |
| 8859 | val = get_param(cmd, "VENUE_GRP"); |
| 8860 | if (val) { |
| 8861 | if (strcasecmp(val, "Business") == 0) |
| 8862 | dut->ap_venue_group = 2; |
| 8863 | else |
| 8864 | dut->ap_venue_group = atoi(val); |
| 8865 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_venue_name %d", |
| 8866 | dut->ap_venue_name); |
| 8867 | } |
| 8868 | |
| 8869 | val = get_param(cmd, "VENUE_TYPE"); |
| 8870 | if (val) { |
| 8871 | if (strcasecmp(val, "R&D") == 0) |
| 8872 | dut->ap_venue_type = 8; |
| 8873 | else |
| 8874 | dut->ap_venue_type = atoi(val); |
| 8875 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_venue_type %d", |
| 8876 | dut->ap_venue_type); |
| 8877 | } |
| 8878 | |
| 8879 | val = get_param(cmd, "HESSID"); |
| 8880 | if (val) { |
| 8881 | if (strlen(val) >= sizeof(dut->ap_hessid)) { |
| 8882 | send_resp(dut, conn, SIGMA_ERROR, |
| 8883 | "errorCode,Invalid HESSID"); |
| 8884 | return 0; |
| 8885 | } |
| 8886 | snprintf(dut->ap_hessid, sizeof(dut->ap_hessid), "%s", val); |
| 8887 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_hessid %s", |
| 8888 | dut->ap_hessid); |
| 8889 | } |
| 8890 | |
| 8891 | val = get_param(cmd, "ROAMING_CONS"); |
| 8892 | if (val) { |
| 8893 | if (strlen(val) >= sizeof(dut->ap_roaming_cons)) { |
| 8894 | send_resp(dut, conn, SIGMA_ERROR, |
| 8895 | "errorCode,Invalid ROAMING_CONS"); |
| 8896 | return 0; |
| 8897 | } |
| 8898 | if (strcasecmp(val, "Disabled") == 0) { |
| 8899 | dut->ap_roaming_cons[0] = '\0'; |
| 8900 | } else { |
| 8901 | snprintf(dut->ap_roaming_cons, |
| 8902 | sizeof(dut->ap_roaming_cons), "%s", val); |
| 8903 | } |
| 8904 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_roaming_cons %s", |
| 8905 | dut->ap_roaming_cons); |
| 8906 | } |
| 8907 | |
| 8908 | val = get_param(cmd, "ANQP"); |
| 8909 | if (val) |
| 8910 | dut->ap_anqpserver_on = atoi(val); |
| 8911 | |
| 8912 | val = get_param(cmd, "NAI_REALM_LIST"); |
| 8913 | if (val) { |
| 8914 | dut->ap_nai_realm_list = atoi(val); |
| 8915 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_nai_realm_list %d", |
| 8916 | dut->ap_nai_realm_list); |
| 8917 | } |
| 8918 | |
| 8919 | val = get_param(cmd, "3GPP_INFO"); |
| 8920 | if (val) { |
| 8921 | /* What kind of encoding format is used?! */ |
| 8922 | send_resp(dut, conn, SIGMA_ERROR, "errorCode,3GPP_INFO " |
| 8923 | "not yet supported (contents not fully defined)"); |
| 8924 | return 0; |
| 8925 | } |
| 8926 | |
| 8927 | val = get_param(cmd, "DOMAIN_LIST"); |
| 8928 | if (val) { |
| 8929 | if (strlen(val) >= sizeof(dut->ap_domain_name_list)) { |
| 8930 | send_resp(dut, conn, SIGMA_ERROR, "errorCode,Too long " |
| 8931 | "DOMAIN_LIST"); |
| 8932 | return 0; |
| 8933 | } |
| 8934 | snprintf(dut->ap_domain_name_list, |
| 8935 | sizeof(dut->ap_domain_name_list), "%s", val); |
| 8936 | pos = dut->ap_domain_name_list; |
| 8937 | while (*pos) { |
| 8938 | if (*pos == ';') |
| 8939 | *pos = ','; |
| 8940 | pos++; |
| 8941 | } |
| 8942 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_domain_name_list %s", |
| 8943 | dut->ap_domain_name_list); |
| 8944 | } |
| 8945 | |
| 8946 | val = get_param(cmd, "OPER_NAME"); |
| 8947 | if (val) { |
| 8948 | dut->ap_oper_name = atoi(val); |
| 8949 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_oper_name %d", |
| 8950 | dut->ap_oper_name); |
| 8951 | } |
| 8952 | |
| 8953 | val = get_param(cmd, "VENUE_NAME"); |
| 8954 | if (val) { |
| 8955 | dut->ap_venue_name = atoi(val); |
| 8956 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_venue_name %d", |
| 8957 | dut->ap_venue_name); |
| 8958 | } |
| 8959 | |
| 8960 | val = get_param(cmd, "GAS_CB_DELAY"); |
| 8961 | if (val) { |
| 8962 | dut->ap_gas_cb_delay = atoi(val); |
| 8963 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_gas_cb_delay %d", |
| 8964 | dut->ap_gas_cb_delay); |
| 8965 | } |
| 8966 | |
| 8967 | val = get_param(cmd, "MIH"); |
| 8968 | if (val && atoi(val) > 0) { |
| 8969 | send_resp(dut, conn, SIGMA_ERROR, "errorCode,MIH not " |
| 8970 | "supported"); |
| 8971 | return 0; |
| 8972 | } |
| 8973 | |
| 8974 | val = get_param(cmd, "L2_TRAFFIC_INSPECT"); |
| 8975 | if (val) { |
| 8976 | dut->ap_l2tif = atoi(val); |
| 8977 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_l2tif %d", |
| 8978 | dut->ap_l2tif); |
| 8979 | } |
| 8980 | |
| 8981 | val = get_param(cmd, "BCST_UNCST"); |
| 8982 | if (val) { |
| 8983 | send_resp(dut, conn, SIGMA_ERROR, |
| 8984 | "errorCode,BCST_UNCST not yet supported"); |
| 8985 | return 0; |
| 8986 | } |
| 8987 | |
| 8988 | val = get_param(cmd, "PLMN_MCC"); |
| 8989 | if (val) { |
| 8990 | char mcc[100], *start, *end; |
| 8991 | int i = 0; |
| 8992 | if (strlen(val) >= sizeof(mcc)) { |
| 8993 | send_resp(dut, conn, SIGMA_ERROR, |
| 8994 | "errorCode,PLMN_MCC too long"); |
| 8995 | return 0; |
| 8996 | } |
Peng Xu | b8fc5cc | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 8997 | strlcpy(mcc, val, sizeof(mcc)); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8998 | start = mcc; |
| 8999 | while ((end = strchr(start, ';'))) { |
| 9000 | /* process all except the last */ |
| 9001 | *end = '\0'; |
| 9002 | if (strlen(start) != 3) { |
| 9003 | send_resp(dut, conn, SIGMA_ERROR, |
| 9004 | "errorCode,Invalid PLMN_MCC"); |
| 9005 | return 0; |
| 9006 | } |
| 9007 | snprintf(dut->ap_plmn_mcc[i], |
| 9008 | sizeof(dut->ap_plmn_mcc[i]), "%s", start); |
| 9009 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_plmn_mcc %s", |
| 9010 | dut->ap_plmn_mcc[i]); |
| 9011 | i++; |
| 9012 | start = end + 1; |
| 9013 | *end = ';'; |
| 9014 | } |
| 9015 | if (strlen(start) != 3) { |
| 9016 | send_resp(dut, conn, SIGMA_ERROR, |
| 9017 | "errorCode,Invalid PLMN_MCC"); |
| 9018 | return 0; |
| 9019 | } |
| 9020 | /* process last or only one */ |
| 9021 | snprintf(dut->ap_plmn_mcc[i], |
| 9022 | sizeof(dut->ap_plmn_mcc[i]), "%s", start); |
| 9023 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_plmn_mcc %s", |
| 9024 | dut->ap_plmn_mcc[i]); |
| 9025 | } |
| 9026 | |
| 9027 | val = get_param(cmd, "PLMN_MNC"); |
| 9028 | if (val) { |
| 9029 | char mnc[100], *start, *end; |
| 9030 | int i = 0; |
| 9031 | if (strlen(val) >= sizeof(mnc)) { |
| 9032 | send_resp(dut, conn, SIGMA_ERROR, |
| 9033 | "errorCode,PLMN_MNC too long"); |
| 9034 | return 0; |
| 9035 | } |
Peng Xu | b8fc5cc | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 9036 | strlcpy(mnc, val, sizeof(mnc)); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9037 | start = mnc; |
| 9038 | while ((end = strchr(start, ';'))) { |
| 9039 | *end = '\0'; |
| 9040 | if (strlen(start) != 2 && strlen(start) != 3) { |
| 9041 | send_resp(dut, conn, SIGMA_ERROR, |
| 9042 | "errorCode,Invalid PLMN_MNC"); |
| 9043 | return 0; |
| 9044 | } |
| 9045 | snprintf(dut->ap_plmn_mnc[i], |
| 9046 | sizeof(dut->ap_plmn_mnc[i]), "%s", start); |
| 9047 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_plmn_mnc %s", |
| 9048 | dut->ap_plmn_mnc[i]); |
| 9049 | i++; |
| 9050 | start = end + 1; |
| 9051 | *end = ';'; |
| 9052 | } |
| 9053 | if (strlen(start) != 2 && strlen(start) != 3) { |
| 9054 | send_resp(dut, conn, SIGMA_ERROR, |
| 9055 | "errorCode,Invalid PLMN_MNC"); |
| 9056 | return 0; |
| 9057 | } |
| 9058 | snprintf(dut->ap_plmn_mnc[i], |
| 9059 | sizeof(dut->ap_plmn_mnc[i]), "%s", start); |
| 9060 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_plmn_mnc %s", |
| 9061 | dut->ap_plmn_mnc[i]); |
| 9062 | } |
| 9063 | |
| 9064 | val = get_param(cmd, "PROXY_ARP"); |
| 9065 | if (val) { |
| 9066 | dut->ap_proxy_arp = atoi(val); |
| 9067 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_proxy_arp %d", |
| 9068 | dut->ap_proxy_arp); |
| 9069 | } |
| 9070 | |
| 9071 | val = get_param(cmd, "WAN_METRICS"); |
| 9072 | if (val) { |
| 9073 | dut->ap_wan_metrics = atoi(val); |
| 9074 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_wan_metrics %d", |
| 9075 | dut->ap_wan_metrics); |
| 9076 | } |
| 9077 | |
| 9078 | val = get_param(cmd, "CONN_CAP"); |
| 9079 | if (val) { |
| 9080 | dut->ap_conn_capab = atoi(val); |
| 9081 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_conn_capab %d", |
| 9082 | dut->ap_conn_capab); |
| 9083 | } |
| 9084 | |
| 9085 | val = get_param(cmd, "IP_ADD_TYPE_AVAIL"); |
| 9086 | if (val) { |
| 9087 | dut->ap_ip_addr_type_avail = atoi(val); |
| 9088 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_ip_addr_type_avail %d", |
| 9089 | dut->ap_ip_addr_type_avail); |
| 9090 | } |
| 9091 | |
| 9092 | val = get_param(cmd, "NET_AUTH_TYPE"); |
| 9093 | if (val) { |
| 9094 | dut->ap_net_auth_type = atoi(val); |
| 9095 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_net_auth_type %d", |
| 9096 | dut->ap_net_auth_type); |
| 9097 | } |
| 9098 | |
| 9099 | val = get_param(cmd, "OP_CLASS"); |
| 9100 | if (val == NULL) |
| 9101 | val = get_param(cmd, "OPER_CLASS"); |
| 9102 | if (val) { |
| 9103 | dut->ap_oper_class = atoi(val); |
| 9104 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_oper_class %d", |
| 9105 | dut->ap_oper_class); |
| 9106 | } |
| 9107 | |
| 9108 | val = get_param(cmd, "OSU_PROVIDER_LIST"); |
| 9109 | if (val) { |
| 9110 | dut->ap_osu_provider_list = atoi(val); |
| 9111 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_osu_provider_list %d", |
| 9112 | dut->ap_osu_provider_list); |
| 9113 | } |
| 9114 | |
| 9115 | val = get_param(cmd, "OSU_SERVER_URI"); |
| 9116 | if (val) { |
| 9117 | i = 0; |
| 9118 | do { |
| 9119 | int len; |
| 9120 | const char *uri = val; |
| 9121 | val = strchr(val, ' '); |
| 9122 | len = val ? (val++ - uri) : (int) strlen(uri); |
| 9123 | if (len > 0 && len < 256) { |
| 9124 | memcpy(dut->ap_osu_server_uri[i], uri, len); |
| 9125 | dut->ap_osu_server_uri[i][len] = '\0'; |
| 9126 | sigma_dut_print(dut, DUT_MSG_INFO, |
| 9127 | "ap_osu_server_uri[%d] %s", i, |
| 9128 | dut->ap_osu_server_uri[i]); |
| 9129 | } |
| 9130 | } while (val && ++i < 10); |
| 9131 | } |
| 9132 | |
| 9133 | val = get_param(cmd, "OSU_METHOD"); |
| 9134 | if (val) { |
| 9135 | i = 0; |
| 9136 | do { |
| 9137 | int len; |
| 9138 | const char *method = val; |
| 9139 | val = strchr(val, ' '); |
| 9140 | len = val ? (val++ - method) : (int) strlen(method); |
| 9141 | if (len > 0) { |
| 9142 | if (strncasecmp(method, "SOAP", len) == 0) |
| 9143 | dut->ap_osu_method[i] = 1; |
| 9144 | else if (strncasecmp(method, "OMADM", len) == 0) |
| 9145 | dut->ap_osu_method[i] = 0; |
| 9146 | else |
| 9147 | return -2; |
| 9148 | } |
| 9149 | } while (val && ++i < 10); |
| 9150 | } |
| 9151 | |
| 9152 | val = get_param(cmd, "OSU_SSID"); |
| 9153 | if (val) { |
| 9154 | if (strlen(val) > 0 && strlen(val) <= 32) { |
Peng Xu | b8fc5cc | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 9155 | strlcpy(dut->ap_osu_ssid, val, |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9156 | sizeof(dut->ap_osu_ssid)); |
| 9157 | sigma_dut_print(dut, DUT_MSG_INFO, |
| 9158 | "ap_osu_ssid %s", |
| 9159 | dut->ap_osu_ssid); |
| 9160 | } |
| 9161 | } |
| 9162 | |
| 9163 | val = get_param(cmd, "OSU_ICON_TAG"); |
| 9164 | if (val) |
| 9165 | dut->ap_osu_icon_tag = atoi(val); |
| 9166 | |
| 9167 | val = get_param(cmd, "QoS_MAP_SET"); |
| 9168 | if (val) { |
| 9169 | dut->ap_qos_map_set = atoi(val); |
| 9170 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_qos_map_set %d", |
| 9171 | dut->ap_qos_map_set); |
| 9172 | } |
| 9173 | |
| 9174 | val = get_param(cmd, "BSS_LOAD"); |
| 9175 | if (val) { |
| 9176 | dut->ap_bss_load = atoi(val); |
| 9177 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_bss_load %d", |
| 9178 | dut->ap_bss_load); |
| 9179 | } |
| 9180 | |
| 9181 | return 1; |
| 9182 | } |
| 9183 | |
| 9184 | |
| 9185 | void nfc_status(struct sigma_dut *dut, const char *state, const char *oper) |
| 9186 | { |
| 9187 | char buf[100]; |
| 9188 | |
| 9189 | if (!file_exists("nfc-status")) |
| 9190 | return; |
| 9191 | |
| 9192 | snprintf(buf, sizeof(buf), "./nfc-status %s %s", state, oper); |
| 9193 | run_system(dut, buf); |
| 9194 | } |
| 9195 | |
| 9196 | |
| 9197 | static int run_nfc_command(struct sigma_dut *dut, const char *cmd, |
| 9198 | const char *info) |
| 9199 | { |
| 9200 | int res; |
| 9201 | |
| 9202 | printf("\n\n\n=====[ NFC operation ]=========================\n\n"); |
| 9203 | printf("%s\n\n", info); |
| 9204 | |
| 9205 | nfc_status(dut, "START", info); |
| 9206 | res = run_system(dut, cmd); |
| 9207 | nfc_status(dut, res ? "FAIL" : "SUCCESS", info); |
| 9208 | if (res) { |
| 9209 | sigma_dut_print(dut, DUT_MSG_INFO, "Failed to run '%s': %d", |
| 9210 | cmd, res); |
| 9211 | return res; |
| 9212 | } |
| 9213 | |
| 9214 | return 0; |
| 9215 | } |
| 9216 | |
| 9217 | |
| 9218 | static int ap_nfc_write_config_token(struct sigma_dut *dut, |
| 9219 | struct sigma_conn *conn, |
| 9220 | struct sigma_cmd *cmd) |
| 9221 | { |
| 9222 | int res; |
| 9223 | char buf[300]; |
| 9224 | |
| 9225 | run_system(dut, "killall wps-ap-nfc.py"); |
| 9226 | unlink("nfc-success"); |
| 9227 | snprintf(buf, sizeof(buf), |
| 9228 | "./wps-ap-nfc.py --no-wait %s%s --success nfc-success write-config", |
| 9229 | dut->summary_log ? "--summary " : "", |
| 9230 | dut->summary_log ? dut->summary_log : ""); |
| 9231 | res = run_nfc_command(dut, buf, |
| 9232 | "Touch NFC Tag to write WPS configuration token"); |
| 9233 | if (res || !file_exists("nfc-success")) { |
| 9234 | send_resp(dut, conn, SIGMA_ERROR, |
| 9235 | "ErrorCode,Failed to write tag"); |
| 9236 | return 0; |
| 9237 | } |
| 9238 | |
| 9239 | return 1; |
| 9240 | } |
| 9241 | |
| 9242 | |
| 9243 | static int ap_nfc_wps_read_passwd(struct sigma_dut *dut, |
| 9244 | struct sigma_conn *conn, |
| 9245 | struct sigma_cmd *cmd) |
| 9246 | { |
| 9247 | int res; |
| 9248 | char buf[300]; |
| 9249 | |
| 9250 | run_system(dut, "killall wps-ap-nfc.py"); |
| 9251 | |
| 9252 | unlink("nfc-success"); |
| 9253 | snprintf(buf, sizeof(buf), |
| 9254 | "./wps-ap-nfc.py -1 --no-wait %s%s --success nfc-success", |
| 9255 | dut->summary_log ? "--summary " : "", |
| 9256 | dut->summary_log ? dut->summary_log : ""); |
| 9257 | res = run_nfc_command(dut, buf, "Touch NFC Tag to read it"); |
| 9258 | if (res || !file_exists("nfc-success")) { |
| 9259 | send_resp(dut, conn, SIGMA_ERROR, |
| 9260 | "ErrorCode,Failed to read tag"); |
| 9261 | return 0; |
| 9262 | } |
| 9263 | |
| 9264 | return 1; |
| 9265 | } |
| 9266 | |
| 9267 | |
| 9268 | static int ap_nfc_write_password_token(struct sigma_dut *dut, |
| 9269 | struct sigma_conn *conn, |
| 9270 | struct sigma_cmd *cmd) |
| 9271 | { |
| 9272 | int res; |
| 9273 | char buf[300]; |
| 9274 | |
| 9275 | run_system(dut, "killall wps-ap-nfc.py"); |
| 9276 | unlink("nfc-success"); |
| 9277 | snprintf(buf, sizeof(buf), |
| 9278 | "./wps-ap-nfc.py --no-wait %s%s --success nfc-success write-password", |
| 9279 | dut->summary_log ? "--summary " : "", |
| 9280 | dut->summary_log ? dut->summary_log : ""); |
| 9281 | res = run_nfc_command(dut, buf, |
| 9282 | "Touch NFC Tag to write WPS password token"); |
| 9283 | if (res || !file_exists("nfc-success")) { |
| 9284 | send_resp(dut, conn, SIGMA_ERROR, |
| 9285 | "ErrorCode,Failed to write tag"); |
| 9286 | return 0; |
| 9287 | } |
| 9288 | |
| 9289 | if (run_hostapd_cli(dut, "wps_nfc_token enable") != 0) { |
| 9290 | send_resp(dut, conn, SIGMA_ERROR, |
| 9291 | "ErrorCode,Failed to enable NFC password token"); |
| 9292 | return 0; |
| 9293 | } |
| 9294 | |
| 9295 | return 1; |
| 9296 | } |
| 9297 | |
| 9298 | |
| 9299 | static int ap_nfc_wps_connection_handover(struct sigma_dut *dut, |
| 9300 | struct sigma_conn *conn, |
| 9301 | struct sigma_cmd *cmd) |
| 9302 | { |
| 9303 | int res; |
| 9304 | char buf[300]; |
| 9305 | |
| 9306 | run_system(dut, "killall wps-ap-nfc.py"); |
| 9307 | unlink("nfc-success"); |
| 9308 | snprintf(buf, sizeof(buf), |
| 9309 | "./wps-ap-nfc.py -1 --no-wait %s%s --success nfc-success", |
| 9310 | dut->summary_log ? "--summary " : "", |
| 9311 | dut->summary_log ? dut->summary_log : ""); |
| 9312 | res = run_nfc_command(dut, buf, |
| 9313 | "Touch NFC Device to respond to WPS connection handover"); |
| 9314 | if (res) { |
| 9315 | send_resp(dut, conn, SIGMA_ERROR, |
| 9316 | "ErrorCode,Failed to enable NFC for connection " |
| 9317 | "handover"); |
| 9318 | return 0; |
| 9319 | } |
| 9320 | if (!file_exists("nfc-success")) { |
| 9321 | send_resp(dut, conn, SIGMA_ERROR, |
| 9322 | "ErrorCode,Failed to complete NFC connection handover"); |
| 9323 | return 0; |
| 9324 | } |
| 9325 | |
| 9326 | return 1; |
| 9327 | } |
| 9328 | |
| 9329 | |
| 9330 | static int cmd_ap_nfc_action(struct sigma_dut *dut, struct sigma_conn *conn, |
| 9331 | struct sigma_cmd *cmd) |
| 9332 | { |
| 9333 | /* const char *name = get_param(cmd, "Name"); */ |
| 9334 | /* const char *intf = get_param(cmd, "Interface"); */ |
| 9335 | const char *oper = get_param(cmd, "Operation"); |
| 9336 | |
| 9337 | if (oper == NULL) |
| 9338 | return -1; |
| 9339 | |
| 9340 | if (strcasecmp(oper, "WRITE_CONFIG") == 0) |
| 9341 | return ap_nfc_write_config_token(dut, conn, cmd); |
| 9342 | if (strcasecmp(oper, "WRITE_PASSWD") == 0) |
| 9343 | return ap_nfc_write_password_token(dut, conn, cmd); |
| 9344 | if (strcasecmp(oper, "WPS_READ_PASSWD") == 0) |
| 9345 | return ap_nfc_wps_read_passwd(dut, conn, cmd); |
| 9346 | if (strcasecmp(oper, "WPS_CONN_HNDOVR") == 0) |
| 9347 | return ap_nfc_wps_connection_handover(dut, conn, cmd); |
| 9348 | |
| 9349 | send_resp(dut, conn, SIGMA_ERROR, "ErrorCode,Unsupported operation"); |
| 9350 | return 0; |
| 9351 | } |
| 9352 | |
| 9353 | |
| 9354 | static int cmd_ap_wps_read_pin(struct sigma_dut *dut, struct sigma_conn *conn, |
| 9355 | struct sigma_cmd *cmd) |
| 9356 | { |
| 9357 | char *pin = "12345670"; /* TODO: use random PIN */ |
| 9358 | char resp[100]; |
| 9359 | |
| 9360 | snprintf(resp, sizeof(resp), "PIN,%s", pin); |
| 9361 | send_resp(dut, conn, SIGMA_COMPLETE, resp); |
| 9362 | |
| 9363 | return 0; |
| 9364 | } |
| 9365 | |
| 9366 | |
| 9367 | static int ath_vht_op_mode_notif(struct sigma_dut *dut, const char *ifname, |
| 9368 | const char *val) |
| 9369 | { |
| 9370 | char *token, *result; |
| 9371 | int nss = 0, chwidth = 0; |
| 9372 | char buf[100]; |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 9373 | char *saveptr; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9374 | |
| 9375 | /* |
| 9376 | * The following commands should be invoked to generate |
| 9377 | * VHT op mode notification |
| 9378 | */ |
| 9379 | |
| 9380 | /* Extract the NSS info */ |
| 9381 | token = strdup(val); |
| 9382 | if (!token) |
| 9383 | return -1; |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 9384 | result = strtok_r(token, ";", &saveptr); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9385 | if (result) { |
| 9386 | int count = atoi(result); |
| 9387 | |
| 9388 | /* We do not support NSS > 3 */ |
| 9389 | if (count < 0 || count > 3) { |
| 9390 | free(token); |
| 9391 | return -1; |
| 9392 | } |
| 9393 | |
| 9394 | /* Convert nss to chainmask */ |
| 9395 | while (count--) |
| 9396 | nss = (nss << 1) | 1; |
| 9397 | |
| 9398 | snprintf(buf, sizeof(buf), "iwpriv %s rxchainmask %d", |
| 9399 | ifname, nss); |
| 9400 | if (system(buf) != 0) { |
| 9401 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 9402 | "iwpriv wifi1 rxchainmask failed!"); |
| 9403 | } |
| 9404 | } |
| 9405 | |
| 9406 | /* Extract the Channel width info */ |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 9407 | result = strtok_r(NULL, ";", &saveptr); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9408 | if (result) { |
| 9409 | switch (atoi(result)) { |
| 9410 | case 20: |
| 9411 | chwidth = 0; |
| 9412 | break; |
| 9413 | case 40: |
| 9414 | chwidth = 1; |
| 9415 | break; |
| 9416 | case 80: |
| 9417 | chwidth = 2; |
| 9418 | break; |
| 9419 | case 160: |
| 9420 | chwidth = 3; |
| 9421 | break; |
| 9422 | default: |
| 9423 | chwidth = 2; |
| 9424 | break; |
| 9425 | } |
| 9426 | snprintf(buf, sizeof(buf), "iwpriv %s chwidth %d", |
| 9427 | ifname, chwidth); |
| 9428 | if (system(buf) != 0) { |
| 9429 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 9430 | "iwpriv chwidth failed!"); |
| 9431 | } |
| 9432 | } |
| 9433 | |
| 9434 | /* Send the opmode notification */ |
Sunil Dutt | 27ec7f6 | 2017-09-14 18:22:59 +0300 | [diff] [blame] | 9435 | snprintf(buf, sizeof(buf), "iwpriv %s opmode_notify 1", ifname); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9436 | if (system(buf) != 0) { |
| 9437 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 9438 | "iwpriv opmode_notify failed!"); |
| 9439 | } |
| 9440 | free(token); |
| 9441 | |
| 9442 | return 0; |
| 9443 | } |
| 9444 | |
| 9445 | |
| 9446 | static int ath_vht_nss_mcs(struct sigma_dut *dut, const char *ifname, |
| 9447 | const char *val) |
| 9448 | { |
| 9449 | /* String (nss_operating_mode; mcs_operating_mode) */ |
| 9450 | int nss, mcs; |
| 9451 | char *token, *result; |
| 9452 | char buf[100]; |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 9453 | char *saveptr; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9454 | |
| 9455 | token = strdup(val); |
| 9456 | if (!token) |
| 9457 | return -1; |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 9458 | result = strtok_r(token, ";", &saveptr); |
Pradeep Reddy POTTETI | 41b8c54 | 2016-06-15 16:09:46 +0530 | [diff] [blame] | 9459 | if (!result) { |
| 9460 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 9461 | "VHT NSS not specified"); |
| 9462 | goto end; |
| 9463 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9464 | if (strcasecmp(result, "def") != 0) { |
| 9465 | nss = atoi(result); |
| 9466 | |
| 9467 | if (nss == 4) |
| 9468 | ath_disable_txbf(dut, ifname); |
| 9469 | |
| 9470 | snprintf(buf, sizeof(buf), "iwpriv %s nss %d", ifname, nss); |
| 9471 | if (system(buf) != 0) { |
| 9472 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 9473 | "iwpriv nss failed"); |
| 9474 | } |
| 9475 | } else { |
| 9476 | if (dut->device_type == AP_testbed && dut->ap_sgi80 == 1) { |
| 9477 | snprintf(buf, sizeof(buf), "iwpriv %s nss 1", ifname); |
| 9478 | if (system(buf) != 0) { |
| 9479 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 9480 | "iwpriv nss failed"); |
| 9481 | } |
| 9482 | } |
| 9483 | } |
| 9484 | |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 9485 | result = strtok_r(NULL, ";", &saveptr); |
Pradeep Reddy POTTETI | 41b8c54 | 2016-06-15 16:09:46 +0530 | [diff] [blame] | 9486 | if (!result) { |
| 9487 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 9488 | "VHT MCS not specified"); |
| 9489 | goto end; |
| 9490 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9491 | if (strcasecmp(result, "def") == 0) { |
| 9492 | if (dut->device_type == AP_testbed && dut->ap_sgi80 == 1) { |
| 9493 | snprintf(buf, sizeof(buf), "iwpriv %s vhtmcs 7", |
| 9494 | ifname); |
| 9495 | if (system(buf) != 0) { |
| 9496 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 9497 | "iwpriv vhtmcs failed"); |
| 9498 | } |
| 9499 | } else { |
| 9500 | snprintf(buf, sizeof(buf), |
| 9501 | "iwpriv %s set11NRates 0", ifname); |
| 9502 | if (system(buf) != 0) { |
| 9503 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 9504 | "iwpriv set11NRates failed"); |
| 9505 | } |
| 9506 | } |
| 9507 | } else { |
| 9508 | mcs = atoi(result); |
| 9509 | snprintf(buf, sizeof(buf), "iwpriv %s vhtmcs %d", ifname, mcs); |
| 9510 | if (system(buf) != 0) { |
| 9511 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 9512 | "iwpriv vhtmcs failed"); |
| 9513 | } |
| 9514 | } |
| 9515 | |
Pradeep Reddy POTTETI | 41b8c54 | 2016-06-15 16:09:46 +0530 | [diff] [blame] | 9516 | end: |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9517 | free(token); |
| 9518 | return 0; |
| 9519 | } |
| 9520 | |
| 9521 | |
| 9522 | static int ath_vht_chnum_band(struct sigma_dut *dut, const char *ifname, |
| 9523 | const char *val) |
| 9524 | { |
| 9525 | char *token, *result; |
| 9526 | int channel = 36; |
| 9527 | int chwidth = 80; |
| 9528 | char buf[100]; |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 9529 | char *saveptr; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9530 | |
| 9531 | /* Extract the channel info */ |
| 9532 | token = strdup(val); |
| 9533 | if (!token) |
| 9534 | return -1; |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 9535 | result = strtok_r(token, ";", &saveptr); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9536 | if (result) |
| 9537 | channel = atoi(result); |
| 9538 | |
| 9539 | /* Extract the channel width info */ |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 9540 | result = strtok_r(NULL, ";", &saveptr); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9541 | if (result) |
| 9542 | chwidth = atoi(result); |
| 9543 | |
| 9544 | /* Issue the channel switch command */ |
| 9545 | snprintf(buf, sizeof(buf), "iwpriv %s doth_ch_chwidth %d 10 %d", |
| 9546 | ifname, channel, chwidth); |
| 9547 | if (system(buf) != 0) { |
| 9548 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 9549 | "iwpriv doth_ch_chwidth failed!"); |
| 9550 | } |
| 9551 | |
| 9552 | free(token); |
| 9553 | return 0; |
| 9554 | } |
| 9555 | |
| 9556 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9557 | static int ath_ndpa_stainfo_mac(struct sigma_dut *dut, const char *ifname, |
| 9558 | const char *val) |
| 9559 | { |
| 9560 | char buf[80]; |
| 9561 | unsigned char mac_addr[6]; |
| 9562 | |
| 9563 | if (parse_mac_address(dut, val, mac_addr) < 0) |
| 9564 | return -1; |
| 9565 | |
| 9566 | snprintf(buf, sizeof(buf), |
| 9567 | "wifitool %s beeliner_fw_test 92 0x%02x%02x%02x%02x", |
| 9568 | ifname, mac_addr[0], mac_addr[1], mac_addr[2], mac_addr[3]); |
| 9569 | run_system(dut, buf); |
| 9570 | |
| 9571 | snprintf(buf, sizeof(buf), "wifitool %s beeliner_fw_test 93 0x%02x%02x", |
| 9572 | ifname, mac_addr[4], mac_addr[5]); |
| 9573 | run_system(dut, buf); |
| 9574 | |
| 9575 | snprintf(buf, sizeof(buf), "wifitool %s beeliner_fw_test 94 1", ifname); |
| 9576 | run_system(dut, buf); |
| 9577 | |
| 9578 | return 0; |
| 9579 | } |
| 9580 | |
| 9581 | |
priyadharshini gowthaman | e5e2517 | 2015-12-08 14:53:48 -0800 | [diff] [blame] | 9582 | void novap_reset(struct sigma_dut *dut, const char *ifname) |
Priyadharshini Gowthaman | 39beafa | 2015-11-09 14:11:25 -0800 | [diff] [blame] | 9583 | { |
| 9584 | char buf[60]; |
| 9585 | |
| 9586 | snprintf(buf, sizeof(buf), "iwpriv %s novap_reset 1", ifname); |
| 9587 | if (system(buf) != 0) { |
| 9588 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 9589 | "disabling novap reset failed"); |
| 9590 | } |
| 9591 | } |
| 9592 | |
| 9593 | |
Adil Saeed Musthafa | 6906372 | 2017-04-10 23:13:40 -0700 | [diff] [blame] | 9594 | struct mbo_pref_ap * mbo_find_nebor_ap_entry(struct sigma_dut *dut, |
| 9595 | const uint8_t *mac_addr) |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 9596 | { |
Adil Saeed Musthafa | 6906372 | 2017-04-10 23:13:40 -0700 | [diff] [blame] | 9597 | int i; |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 9598 | |
Adil Saeed Musthafa | 6906372 | 2017-04-10 23:13:40 -0700 | [diff] [blame] | 9599 | for (i = 0; i < dut->mbo_pref_ap_cnt; i++) { |
| 9600 | if (memcmp(mac_addr, dut->mbo_pref_aps[i].mac_addr, |
| 9601 | ETH_ALEN) == 0) |
| 9602 | return &dut->mbo_pref_aps[i]; |
| 9603 | } |
| 9604 | return NULL; |
| 9605 | } |
| 9606 | |
| 9607 | |
| 9608 | static void mbo_add_nebor_entry(struct sigma_dut *dut, const uint8_t *mac_addr, |
| 9609 | int ap_ne_class, int ap_ne_op_ch, |
| 9610 | int ap_ne_pref) |
| 9611 | { |
| 9612 | struct mbo_pref_ap *entry; |
| 9613 | uint8_t self_mac[ETH_ALEN]; |
| 9614 | char ifname[50]; |
| 9615 | |
| 9616 | get_if_name(dut, ifname, sizeof(ifname), 1); |
| 9617 | get_hwaddr(ifname, self_mac); |
| 9618 | |
| 9619 | if (memcmp(mac_addr, self_mac, ETH_ALEN) == 0) |
| 9620 | entry = &dut->mbo_self_ap_tuple; |
| 9621 | else |
| 9622 | entry = mbo_find_nebor_ap_entry(dut, mac_addr); |
| 9623 | |
| 9624 | if (!entry) { |
| 9625 | if (dut->mbo_pref_ap_cnt >= MBO_MAX_PREF_BSSIDS) { |
| 9626 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 9627 | "Nebor AP List is full. Not adding"); |
| 9628 | return; |
| 9629 | } |
| 9630 | entry = &dut->mbo_pref_aps[dut->mbo_pref_ap_cnt]; |
| 9631 | dut->mbo_pref_ap_cnt++; |
| 9632 | memcpy(entry->mac_addr, mac_addr, ETH_ALEN); |
| 9633 | entry->ap_ne_class = -1; |
| 9634 | entry->ap_ne_op_ch = -1; |
| 9635 | entry->ap_ne_pref = -1; |
| 9636 | } |
| 9637 | if (ap_ne_class != -1) |
| 9638 | entry->ap_ne_class = ap_ne_class; |
| 9639 | if (ap_ne_op_ch != -1) |
| 9640 | entry->ap_ne_op_ch = ap_ne_op_ch; |
| 9641 | if (ap_ne_pref != -1) |
| 9642 | entry->ap_ne_pref = ap_ne_pref; |
| 9643 | } |
| 9644 | |
| 9645 | |
| 9646 | static int ath_set_nebor_bssid(struct sigma_dut *dut, const char *ifname, |
| 9647 | struct sigma_cmd *cmd) |
| 9648 | { |
| 9649 | unsigned char mac_addr[ETH_ALEN]; |
| 9650 | const char *val; |
| 9651 | /* |
| 9652 | * -1 is invalid value for the following |
| 9653 | * to differentiate between unset and set values |
| 9654 | * -1 => implies not set by CAPI |
| 9655 | */ |
| 9656 | int ap_ne_class = -1, ap_ne_op_ch = -1, ap_ne_pref = -1; |
| 9657 | int list_offset = dut->mbo_pref_ap_cnt; |
| 9658 | |
| 9659 | if (list_offset >= MBO_MAX_PREF_BSSIDS) { |
| 9660 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 9661 | "AP Pref Entry list is full"); |
| 9662 | return -1; |
| 9663 | } |
| 9664 | |
| 9665 | val = get_param(cmd, "Nebor_Op_Class"); |
| 9666 | if (val) |
| 9667 | ap_ne_class = atoi(val); |
| 9668 | |
| 9669 | val = get_param(cmd, "Nebor_Op_Ch"); |
| 9670 | if (val) |
| 9671 | ap_ne_op_ch = atoi(val); |
| 9672 | |
| 9673 | val = get_param(cmd, "Nebor_Pref"); |
| 9674 | if (val) |
| 9675 | ap_ne_pref = atoi(val); |
| 9676 | |
| 9677 | val = get_param(cmd, "Nebor_BSSID"); |
| 9678 | if (!val || parse_mac_address(dut, val, mac_addr) < 0) |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 9679 | return -1; |
| 9680 | |
Adil Saeed Musthafa | 6906372 | 2017-04-10 23:13:40 -0700 | [diff] [blame] | 9681 | mbo_add_nebor_entry(dut, mac_addr, ap_ne_class, ap_ne_op_ch, |
| 9682 | ap_ne_pref); |
| 9683 | apply_mbo_pref_ap_list(dut); |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 9684 | return 0; |
| 9685 | } |
| 9686 | |
| 9687 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9688 | static int ath_ap_set_rfeature(struct sigma_dut *dut, struct sigma_conn *conn, |
| 9689 | struct sigma_cmd *cmd) |
| 9690 | { |
| 9691 | const char *val; |
| 9692 | char *ifname; |
| 9693 | |
| 9694 | ifname = get_main_ifname(); |
| 9695 | |
Priyadharshini Gowthaman | 39beafa | 2015-11-09 14:11:25 -0800 | [diff] [blame] | 9696 | /* Disable vap reset between the commands */ |
| 9697 | novap_reset(dut, ifname); |
| 9698 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9699 | val = get_param(cmd, "Opt_md_notif_ie"); |
| 9700 | if (val && ath_vht_op_mode_notif(dut, ifname, val) < 0) |
| 9701 | return -1; |
| 9702 | |
| 9703 | /* TODO: Optional arguments */ |
| 9704 | |
| 9705 | val = get_param(cmd, "nss_mcs_opt"); |
| 9706 | if (val && ath_vht_nss_mcs(dut, ifname, val) < 0) |
| 9707 | return -1; |
| 9708 | |
| 9709 | val = get_param(cmd, "chnum_band"); |
| 9710 | if (val && ath_vht_chnum_band(dut, ifname, val) < 0) |
| 9711 | return -1; |
| 9712 | |
| 9713 | val = get_param(cmd, "RTS_FORCE"); |
| 9714 | if (val) |
| 9715 | ath_config_rts_force(dut, ifname, val); |
| 9716 | |
| 9717 | val = get_param(cmd, "DYN_BW_SGNL"); |
| 9718 | if (val) |
| 9719 | ath_config_dyn_bw_sig(dut, ifname, val); |
| 9720 | |
| 9721 | val = get_param(cmd, "CTS_WIDTH"); |
| 9722 | if (val) |
| 9723 | ath_set_cts_width(dut, ifname, val); |
| 9724 | |
| 9725 | val = get_param(cmd, "Ndpa_stainfo_mac"); |
| 9726 | if (val && ath_ndpa_stainfo_mac(dut, ifname, val) < 0) |
| 9727 | return -1; |
| 9728 | |
| 9729 | val = get_param(cmd, "txBandwidth"); |
| 9730 | if (val && ath_set_width(dut, conn, ifname, val) < 0) |
| 9731 | return -1; |
| 9732 | |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 9733 | val = get_param(cmd, "Assoc_Disallow"); |
| 9734 | if (val) |
| 9735 | ath_set_assoc_disallow(dut, ifname, val); |
| 9736 | |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 9737 | |
Adil Saeed Musthafa | 6906372 | 2017-04-10 23:13:40 -0700 | [diff] [blame] | 9738 | ath_set_nebor_bssid(dut, ifname, cmd); |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 9739 | val = get_param(cmd, "BTMReq_DisAssoc_Imnt"); |
priyadharshini gowthaman | 776562e | 2017-12-20 12:33:34 -0800 | [diff] [blame] | 9740 | if (val) { |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 9741 | dut->ap_btmreq_disassoc_imnt = atoi(val); |
priyadharshini gowthaman | 776562e | 2017-12-20 12:33:34 -0800 | [diff] [blame] | 9742 | dut->ap_disassoc_timer = 1000; |
| 9743 | } |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 9744 | |
| 9745 | val = get_param(cmd, "BTMReq_Term_Bit"); |
| 9746 | if (val) |
| 9747 | dut->ap_btmreq_term_bit = atoi(val); |
| 9748 | |
Adil Saeed Musthafa | 48c5ab9 | 2017-04-10 23:13:35 -0700 | [diff] [blame] | 9749 | val = get_param(cmd, "Assoc_Delay"); |
priyadharshini gowthaman | 776562e | 2017-12-20 12:33:34 -0800 | [diff] [blame] | 9750 | if (val) { |
| 9751 | dut->ap_assoc_delay = 1; |
Adil Saeed Musthafa | 48c5ab9 | 2017-04-10 23:13:35 -0700 | [diff] [blame] | 9752 | run_system_wrapper(dut, "iwpriv %s mbo_asoc_ret %s", |
| 9753 | ifname, val); |
priyadharshini gowthaman | 776562e | 2017-12-20 12:33:34 -0800 | [diff] [blame] | 9754 | } |
Adil Saeed Musthafa | 48c5ab9 | 2017-04-10 23:13:35 -0700 | [diff] [blame] | 9755 | |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 9756 | val = get_param(cmd, "Disassoc_Timer"); |
| 9757 | if (val) |
| 9758 | dut->ap_disassoc_timer = atoi(val); |
| 9759 | |
| 9760 | val = get_param(cmd, "BSS_Term_Duration"); |
| 9761 | if (val) |
| 9762 | dut->ap_btmreq_bss_term_dur = atoi(val); |
| 9763 | |
priyadharshini gowthaman | 94062b5 | 2017-12-20 12:33:34 -0800 | [diff] [blame] | 9764 | val = get_param(cmd, "BSS_Term_TSF"); |
| 9765 | if (val) |
| 9766 | dut->ap_btmreq_bss_term_tsf = atoi(val); |
| 9767 | |
priyadharshini gowthaman | cb22e43 | 2017-12-28 15:23:31 -0800 | [diff] [blame] | 9768 | val = get_param(cmd, "TxPower"); |
| 9769 | if (val) |
| 9770 | ath_set_txpower(dut, ifname, val); |
| 9771 | |
| 9772 | val = get_param(cmd, "DownlinkAvailCap"); |
| 9773 | if (val) |
| 9774 | dut->ap_dl_availcap = atoi(val); |
| 9775 | |
| 9776 | val = get_param(cmd, "UplinkAvailCap"); |
| 9777 | if (val) { |
| 9778 | dut->ap_ul_availcap = atoi(val); |
| 9779 | run_system_wrapper(dut, "iwpriv %s oce_wan_mtr %d %d", ifname, |
| 9780 | dut->ap_dl_availcap, dut->ap_ul_availcap); |
| 9781 | } |
| 9782 | |
| 9783 | val = get_param(cmd, "RSSIthreshold"); |
| 9784 | if (val) { |
| 9785 | int rssithreshold; |
| 9786 | |
| 9787 | run_system_wrapper(dut, "iwpriv %s oce_asoc_rej 1", ifname); |
| 9788 | rssithreshold = atoi(val); |
| 9789 | run_system_wrapper(dut, "iwpriv %s oce_asoc_rssi %d", ifname, |
| 9790 | rssithreshold); |
| 9791 | } |
| 9792 | |
| 9793 | val = get_param(cmd, "RetryDelay"); |
| 9794 | if (val) { |
| 9795 | int retrydelay; |
| 9796 | |
| 9797 | run_system_wrapper(dut, "iwpriv %s oce_asoc_rej 1", ifname); |
| 9798 | retrydelay = atoi(val); |
| 9799 | run_system_wrapper(dut, "iwpriv %s oce_asoc_dly %d", ifname, |
| 9800 | retrydelay); |
| 9801 | } |
| 9802 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9803 | return 1; |
| 9804 | } |
| 9805 | |
| 9806 | |
Pradeep Reddy POTTETI | 88fd82c | 2016-03-14 12:20:18 +0530 | [diff] [blame] | 9807 | static int wcn_vht_chnum_band(struct sigma_dut *dut, const char *ifname, |
| 9808 | const char *val) |
| 9809 | { |
| 9810 | char *token, *result; |
| 9811 | int channel = 36; |
| 9812 | char buf[100]; |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 9813 | char *saveptr; |
Pradeep Reddy POTTETI | 88fd82c | 2016-03-14 12:20:18 +0530 | [diff] [blame] | 9814 | |
| 9815 | /* Extract the channel info */ |
| 9816 | token = strdup(val); |
| 9817 | if (!token) |
| 9818 | return -1; |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 9819 | result = strtok_r(token, ";", &saveptr); |
Pradeep Reddy POTTETI | 88fd82c | 2016-03-14 12:20:18 +0530 | [diff] [blame] | 9820 | if (result) |
| 9821 | channel = atoi(result); |
| 9822 | |
| 9823 | /* Issue the channel switch command */ |
| 9824 | snprintf(buf, sizeof(buf), "iwpriv %s setChanChange %d", |
| 9825 | ifname, channel); |
| 9826 | if (system(buf) != 0) { |
| 9827 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 9828 | "iwpriv setChanChange failed!"); |
| 9829 | } |
| 9830 | |
| 9831 | free(token); |
| 9832 | return 0; |
| 9833 | } |
| 9834 | |
| 9835 | |
| 9836 | static int wcn_ap_set_rfeature(struct sigma_dut *dut, struct sigma_conn *conn, |
| 9837 | struct sigma_cmd *cmd) |
| 9838 | { |
| 9839 | const char *val; |
| 9840 | char *ifname; |
| 9841 | |
| 9842 | ifname = get_main_ifname(); |
| 9843 | |
| 9844 | val = get_param(cmd, "chnum_band"); |
| 9845 | if (val && wcn_vht_chnum_band(dut, ifname, val) < 0) |
| 9846 | return -1; |
| 9847 | |
| 9848 | return 1; |
| 9849 | } |
| 9850 | |
| 9851 | |
Mohammed Shafi Shajakhan | b53d8f9 | 2017-02-28 09:05:15 +0530 | [diff] [blame] | 9852 | static int mac80211_vht_chnum_band(struct sigma_dut *dut, const char *ifname, |
| 9853 | const char *val) |
| 9854 | { |
| 9855 | char *token, *result; |
| 9856 | int channel = 36, chwidth = 80, center_freq_idx, center_freq, |
| 9857 | channel_freq; |
| 9858 | char buf[100]; |
| 9859 | char *saveptr; |
| 9860 | |
| 9861 | /* Extract the channel info */ |
| 9862 | token = strdup(val); |
| 9863 | if (!token) |
| 9864 | return -1; |
| 9865 | result = strtok_r(token, ";", &saveptr); |
| 9866 | if (result) |
| 9867 | channel = atoi(result); |
| 9868 | |
| 9869 | /* Extract the channel width info */ |
| 9870 | result = strtok_r(NULL, ";", &saveptr); |
| 9871 | if (result) |
| 9872 | chwidth = atoi(result); |
| 9873 | |
| 9874 | center_freq_idx = get_oper_centr_freq_seq_idx(chwidth, channel); |
| 9875 | if (center_freq_idx < 0) { |
| 9876 | free(token); |
| 9877 | return -1; |
| 9878 | } |
| 9879 | |
| 9880 | center_freq = get_5g_channel_freq(center_freq_idx); |
| 9881 | channel_freq = get_5g_channel_freq(channel); |
| 9882 | |
| 9883 | /* Issue the channel switch command */ |
| 9884 | snprintf(buf, sizeof(buf), |
| 9885 | " -i %s chan_switch 10 %d sec_channel_offset=1 center_freq1=%d bandwidth=%d blocktx vht", |
| 9886 | ifname, channel_freq, center_freq, chwidth); |
| 9887 | if (run_hostapd_cli(dut,buf) != 0) { |
| 9888 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 9889 | "hostapd_cli chan_switch failed"); |
| 9890 | } |
| 9891 | |
| 9892 | free(token); |
| 9893 | return 0; |
| 9894 | } |
| 9895 | |
| 9896 | |
| 9897 | static int mac80211_ap_set_rfeature(struct sigma_dut *dut, |
| 9898 | struct sigma_conn *conn, |
| 9899 | struct sigma_cmd *cmd) |
| 9900 | { |
| 9901 | const char *val; |
| 9902 | char *ifname; |
| 9903 | |
| 9904 | ifname = get_main_ifname(); |
| 9905 | val = get_param(cmd, "chnum_band"); |
| 9906 | if (val && mac80211_vht_chnum_band(dut, ifname, val) < 0) |
| 9907 | return -1; |
| 9908 | |
| 9909 | return 1; |
| 9910 | } |
| 9911 | |
| 9912 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9913 | static int cmd_ap_set_rfeature(struct sigma_dut *dut, struct sigma_conn *conn, |
| 9914 | struct sigma_cmd *cmd) |
| 9915 | { |
| 9916 | /* const char *name = get_param(cmd, "NAME"); */ |
| 9917 | /* const char *type = get_param(cmd, "Type"); */ |
| 9918 | |
| 9919 | switch (get_driver_type()) { |
| 9920 | case DRIVER_ATHEROS: |
| 9921 | return ath_ap_set_rfeature(dut, conn, cmd); |
| 9922 | case DRIVER_OPENWRT: |
| 9923 | switch (get_openwrt_driver_type()) { |
| 9924 | case OPENWRT_DRIVER_ATHEROS: |
| 9925 | return ath_ap_set_rfeature(dut, conn, cmd); |
| 9926 | default: |
| 9927 | send_resp(dut, conn, SIGMA_ERROR, |
| 9928 | "errorCode,Unsupported ap_set_rfeature with the current openwrt driver"); |
| 9929 | return 0; |
| 9930 | } |
Sreelakshmi Konamki | 0e4fcf9 | 2016-04-26 19:55:01 +0530 | [diff] [blame] | 9931 | case DRIVER_LINUX_WCN: |
Pradeep Reddy POTTETI | 88fd82c | 2016-03-14 12:20:18 +0530 | [diff] [blame] | 9932 | case DRIVER_WCN: |
| 9933 | return wcn_ap_set_rfeature(dut, conn, cmd); |
Mohammed Shafi Shajakhan | b53d8f9 | 2017-02-28 09:05:15 +0530 | [diff] [blame] | 9934 | case DRIVER_MAC80211: |
| 9935 | return mac80211_ap_set_rfeature(dut, conn, cmd); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9936 | default: |
| 9937 | send_resp(dut, conn, SIGMA_ERROR, |
| 9938 | "errorCode,Unsupported ap_set_rfeature with the current driver"); |
| 9939 | return 0; |
| 9940 | } |
| 9941 | } |
| 9942 | |
| 9943 | |
| 9944 | static int cmd_accesspoint(struct sigma_dut *dut, struct sigma_conn *conn, |
| 9945 | struct sigma_cmd *cmd) |
| 9946 | { |
| 9947 | /* const char *name = get_param(cmd, "NAME"); */ |
| 9948 | return 1; |
| 9949 | } |
| 9950 | |
| 9951 | |
priyadharshini gowthaman | 9149afc | 2018-01-15 13:40:18 -0800 | [diff] [blame] | 9952 | static int cmd_ap_preset_testparameters(struct sigma_dut *dut, |
| 9953 | struct sigma_conn *conn, |
| 9954 | struct sigma_cmd *cmd) |
| 9955 | { |
| 9956 | const char *val; |
| 9957 | |
| 9958 | val = get_param(cmd, "Oper_Chn"); |
| 9959 | if (val) { |
| 9960 | dut->ap_oper_chn = 1; |
| 9961 | dut->ap_channel = atoi(val); |
| 9962 | } |
| 9963 | |
| 9964 | return 1; |
| 9965 | } |
| 9966 | |
| 9967 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9968 | void ap_register_cmds(void) |
| 9969 | { |
| 9970 | sigma_dut_reg_cmd("ap_ca_version", NULL, cmd_ap_ca_version); |
| 9971 | sigma_dut_reg_cmd("ap_set_wireless", NULL, cmd_ap_set_wireless); |
| 9972 | sigma_dut_reg_cmd("ap_send_addba_req", NULL, cmd_ap_send_addba_req); |
| 9973 | sigma_dut_reg_cmd("ap_set_11n_wireless", NULL, cmd_ap_set_wireless); |
| 9974 | sigma_dut_reg_cmd("ap_set_11n", NULL, cmd_ap_set_wireless); |
| 9975 | 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] | 9976 | sigma_dut_reg_cmd("ap_set_11h", NULL, cmd_ap_set_wireless); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9977 | sigma_dut_reg_cmd("ap_set_security", NULL, cmd_ap_set_security); |
| 9978 | sigma_dut_reg_cmd("ap_set_apqos", NULL, cmd_ap_set_apqos); |
| 9979 | sigma_dut_reg_cmd("ap_set_staqos", NULL, cmd_ap_set_staqos); |
| 9980 | sigma_dut_reg_cmd("ap_set_radius", NULL, cmd_ap_set_radius); |
| 9981 | sigma_dut_reg_cmd("ap_reboot", NULL, cmd_ap_reboot); |
| 9982 | sigma_dut_reg_cmd("ap_config_commit", NULL, cmd_ap_config_commit); |
| 9983 | sigma_dut_reg_cmd("ap_reset_default", NULL, cmd_ap_reset_default); |
| 9984 | sigma_dut_reg_cmd("ap_get_info", NULL, cmd_ap_get_info); |
| 9985 | sigma_dut_reg_cmd("ap_deauth_sta", NULL, cmd_ap_deauth_sta); |
| 9986 | sigma_dut_reg_cmd("ap_send_frame", NULL, cmd_ap_send_frame); |
| 9987 | sigma_dut_reg_cmd("ap_get_mac_address", NULL, cmd_ap_get_mac_address); |
| 9988 | sigma_dut_reg_cmd("ap_set_pmf", NULL, cmd_ap_set_pmf); |
| 9989 | sigma_dut_reg_cmd("ap_set_hs2", NULL, cmd_ap_set_hs2); |
| 9990 | sigma_dut_reg_cmd("ap_set_rfeature", NULL, cmd_ap_set_rfeature); |
| 9991 | sigma_dut_reg_cmd("ap_nfc_action", NULL, cmd_ap_nfc_action); |
| 9992 | sigma_dut_reg_cmd("ap_wps_read_pin", NULL, cmd_ap_wps_read_pin); |
| 9993 | sigma_dut_reg_cmd("AccessPoint", NULL, cmd_accesspoint); |
priyadharshini gowthaman | 9149afc | 2018-01-15 13:40:18 -0800 | [diff] [blame] | 9994 | sigma_dut_reg_cmd("ap_preset_testparameters", NULL, |
| 9995 | cmd_ap_preset_testparameters); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9996 | } |