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 | |
| 2628 | 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] | 2629 | snprintf(buf, sizeof(buf), "wifi%d", vap_count); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2630 | |
| 2631 | for (vap_id = 0; vap_id < MAX_RADIO; vap_id++) { |
| 2632 | if (sigma_radio_ifname[vap_id] && |
| 2633 | strcmp(sigma_radio_ifname[vap_id], buf) == 0) |
| 2634 | break; |
| 2635 | } |
| 2636 | if (vap_id == MAX_RADIO) |
| 2637 | continue; |
| 2638 | |
| 2639 | /* Single VAP configuration */ |
| 2640 | if (!dut->ap_is_dual) |
| 2641 | vap_id = vap_count; |
| 2642 | |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 2643 | for (j = 0; j < MAX_WLAN_TAGS - 1; j++) { |
| 2644 | /* |
| 2645 | * We keep a separate array of ap_tag_ssid and |
| 2646 | * ap_tag_key_mgmt for tags starting from WLAN_TAG=2. |
| 2647 | * So j=0 => WLAN_TAG = 2 |
| 2648 | */ |
| 2649 | int wlan_tag = j + 2; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2650 | |
priyadharshini gowthaman | 0e209fc | 2018-01-26 15:15:37 -0800 | [diff] [blame] | 2651 | if (wlan_tag == 2 && dut->program == PROGRAM_WPA3 && |
| 2652 | (dut->ap_interface_5g || dut->ap_interface_2g)) { |
| 2653 | snprintf(dut->ap_tag_ssid[wlan_tag - 2], |
| 2654 | sizeof(dut->ap_tag_ssid[wlan_tag - 2]), |
| 2655 | "%s-owe", dut->ap_ssid); |
| 2656 | } |
| 2657 | |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 2658 | if (dut->ap_tag_ssid[j][0] == '\0') |
| 2659 | continue; |
| 2660 | |
| 2661 | snprintf(buf, sizeof(buf), "%s%d", "wifi", vap_count); |
| 2662 | owrt_ap_add_vap(dut, vap_count + (wlan_tag - 1), |
| 2663 | "device", buf); |
| 2664 | /* SSID */ |
| 2665 | snprintf(buf, sizeof(buf), "\"%s\"", |
| 2666 | dut->ap_tag_ssid[j]); |
| 2667 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), |
| 2668 | "ssid", buf); |
| 2669 | |
priyadharshini gowthaman | 0454706 | 2018-01-15 11:59:55 -0800 | [diff] [blame] | 2670 | if (dut->ap_key_mgmt == AP_WPA2_OWE && |
| 2671 | dut->ap_tag_ssid[0][0] && |
| 2672 | dut->ap_tag_key_mgmt[0] == AP2_OPEN) { |
| 2673 | /* OWE transition mode */ |
| 2674 | snprintf(buf, sizeof(buf), "%s", ifname); |
| 2675 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), |
| 2676 | "owe_transition_ifname", buf); |
| 2677 | } |
| 2678 | |
| 2679 | if (dut->ap_key_mgmt == AP_OPEN && |
| 2680 | dut->ap_tag_key_mgmt[0] == AP2_WPA2_OWE) { |
| 2681 | /* OWE transition mode */ |
| 2682 | snprintf(buf, sizeof(buf), "%s", ifname); |
| 2683 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), |
| 2684 | "owe_transition_ifname", buf); |
| 2685 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), |
| 2686 | "hidden", "1"); |
| 2687 | } |
| 2688 | |
priyadharshini gowthaman | 47189f5 | 2017-12-28 12:37:46 -0800 | [diff] [blame] | 2689 | if (dut->ap_ft_oa == 1) { |
| 2690 | unsigned char self_mac[ETH_ALEN]; |
| 2691 | char mac_str[20]; |
| 2692 | |
| 2693 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), |
| 2694 | "mobility_domain", |
| 2695 | dut->ap_mobility_domain); |
| 2696 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), |
| 2697 | "ft_over_ds", "0"); |
| 2698 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), |
| 2699 | "ieee80211r", "1"); |
| 2700 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), |
| 2701 | "nasid", "nas1.example.com"); |
| 2702 | get_hwaddr(sigma_radio_ifname[0], self_mac); |
| 2703 | snprintf(mac_str, sizeof(mac_str), |
| 2704 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 2705 | self_mac[0], self_mac[1], self_mac[2], |
| 2706 | self_mac[3], self_mac[4], self_mac[5]); |
| 2707 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), |
| 2708 | "ap_macaddr", mac_str); |
| 2709 | snprintf(mac_str, sizeof(mac_str), |
| 2710 | "%02x%02x%02x%02x%02x%02x", |
| 2711 | self_mac[0], self_mac[1], self_mac[2], |
| 2712 | self_mac[3], self_mac[4], self_mac[5]); |
| 2713 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), |
| 2714 | "r1_key_holder", mac_str); |
| 2715 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), |
| 2716 | "ft_psk_generate_local", "1"); |
| 2717 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), |
| 2718 | "kh_key_hex", |
| 2719 | "000102030405060708090a0b0c0d0e0f"); |
| 2720 | snprintf(mac_str, sizeof(mac_str), |
| 2721 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 2722 | dut->ft_bss_mac_list[0][0], |
| 2723 | dut->ft_bss_mac_list[0][1], |
| 2724 | dut->ft_bss_mac_list[0][2], |
| 2725 | dut->ft_bss_mac_list[0][3], |
| 2726 | dut->ft_bss_mac_list[0][4], |
| 2727 | dut->ft_bss_mac_list[0][5]); |
| 2728 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), |
| 2729 | "ap2_macaddr", mac_str); |
| 2730 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), |
| 2731 | "ap2_r1_key_holder", mac_str); |
| 2732 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), |
| 2733 | "nasid2", "nas2.example.com"); |
| 2734 | } |
| 2735 | |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 2736 | if (dut->ap_tag_key_mgmt[j] == AP2_OSEN && |
| 2737 | wlan_tag == 2) { |
| 2738 | /* Only supported for WLAN_TAG=2 */ |
| 2739 | owrt_ap_set_vap(dut, vap_count + 1, "osen", |
| 2740 | "1"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2741 | snprintf(buf, sizeof(buf), "wpa2"); |
| 2742 | owrt_ap_set_vap(dut, vap_count + 1, |
| 2743 | "encryption", buf); |
| 2744 | snprintf(buf, sizeof(buf), "%s", |
| 2745 | dut->ap2_radius_ipaddr); |
| 2746 | owrt_ap_set_vap(dut, vap_count + 1, |
| 2747 | "auth_server", buf); |
| 2748 | snprintf(buf, sizeof(buf), "%d", |
| 2749 | dut->ap2_radius_port); |
| 2750 | owrt_ap_set_vap(dut, vap_count + 1, |
| 2751 | "auth_port", buf); |
| 2752 | snprintf(buf, sizeof(buf), "%s", |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 2753 | dut->ap2_radius_password); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2754 | owrt_ap_set_vap(dut, vap_count + 1, |
| 2755 | "auth_secret", buf); |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 2756 | } else if (dut->ap_tag_key_mgmt[j] == AP2_WPA2_PSK) { |
| 2757 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), |
| 2758 | "encryption", "psk2+ccmp"); |
| 2759 | snprintf(buf, sizeof(buf), "\"%s\"", |
| 2760 | dut->ap_passphrase); |
| 2761 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), |
| 2762 | "key", buf); |
| 2763 | snprintf(buf, sizeof(buf), "%d", dut->ap_pmf); |
priyadharshini gowthaman | 47189f5 | 2017-12-28 12:37:46 -0800 | [diff] [blame] | 2764 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 2765 | "ieee80211w", buf); |
priyadharshini gowthaman | 0454706 | 2018-01-15 11:59:55 -0800 | [diff] [blame] | 2766 | } else if (dut->ap_tag_key_mgmt[0] == AP2_WPA2_OWE) { |
| 2767 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), |
| 2768 | "owe", "1"); |
| 2769 | snprintf(buf, sizeof(buf), "ccmp"); |
| 2770 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), |
| 2771 | "encryption", buf); |
| 2772 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), |
| 2773 | "ieee80211w", "2"); |
| 2774 | if (dut->ap_sae_groups) { |
| 2775 | snprintf(buf, sizeof(buf), "\'%s\'", |
| 2776 | dut->ap_sae_groups); |
| 2777 | owrt_ap_set_vap(dut, vap_count + |
| 2778 | (wlan_tag - 1), |
| 2779 | "owe_groups", buf); |
| 2780 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2781 | } |
| 2782 | } |
| 2783 | |
priyadharshini gowthaman | 47189f5 | 2017-12-28 12:37:46 -0800 | [diff] [blame] | 2784 | /* Now set anqp_elem and ft_oa for wlan_tag = 1 */ |
Adil Saeed Musthafa | a8d7484 | 2017-04-10 23:13:39 -0700 | [diff] [blame] | 2785 | if (dut->program == PROGRAM_MBO && |
| 2786 | get_driver_type() == DRIVER_OPENWRT) { |
priyadharshini gowthaman | 47189f5 | 2017-12-28 12:37:46 -0800 | [diff] [blame] | 2787 | unsigned char self_mac[ETH_ALEN]; |
| 2788 | char mac_str[20]; |
Adil Saeed Musthafa | a8d7484 | 2017-04-10 23:13:39 -0700 | [diff] [blame] | 2789 | char anqp_string[200]; |
| 2790 | |
| 2791 | set_anqp_elem_value(dut, sigma_radio_ifname[0], |
| 2792 | anqp_string, sizeof(anqp_string)); |
| 2793 | owrt_ap_set_list_vap(dut, vap_count, "anqp_elem", |
| 2794 | anqp_string); |
priyadharshini gowthaman | 47189f5 | 2017-12-28 12:37:46 -0800 | [diff] [blame] | 2795 | |
| 2796 | if (dut->ap_ft_oa == 1) { |
| 2797 | owrt_ap_set_vap(dut, vap_count, |
| 2798 | "mobility_domain", |
| 2799 | dut->ap_mobility_domain); |
| 2800 | owrt_ap_set_vap(dut, vap_count, |
| 2801 | "ft_over_ds", "0"); |
| 2802 | owrt_ap_set_vap(dut, vap_count, |
| 2803 | "ieee80211r", "1"); |
| 2804 | owrt_ap_set_vap(dut, vap_count, |
| 2805 | "nasid", "nas1.example.com"); |
| 2806 | get_hwaddr(sigma_radio_ifname[0], self_mac); |
| 2807 | snprintf(mac_str, sizeof(mac_str), |
| 2808 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 2809 | self_mac[0], self_mac[1], self_mac[2], |
| 2810 | self_mac[3], self_mac[4], self_mac[5]); |
| 2811 | owrt_ap_set_vap(dut, vap_count, |
| 2812 | "ap_macaddr", mac_str); |
| 2813 | snprintf(mac_str, sizeof(mac_str), |
| 2814 | "%02x%02x%02x%02x%02x%02x", |
| 2815 | self_mac[0], self_mac[1], self_mac[2], |
| 2816 | self_mac[3], self_mac[4], self_mac[5]); |
| 2817 | owrt_ap_set_vap(dut, vap_count, |
| 2818 | "r1_key_holder", mac_str); |
| 2819 | owrt_ap_set_vap(dut, vap_count, |
| 2820 | "ft_psk_generate_local", "1"); |
| 2821 | owrt_ap_set_vap(dut, vap_count, |
| 2822 | "kh_key_hex", |
| 2823 | "000102030405060708090a0b0c0d0e0f"); |
| 2824 | snprintf(mac_str, sizeof(mac_str), |
| 2825 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 2826 | dut->ft_bss_mac_list[0][0], |
| 2827 | dut->ft_bss_mac_list[0][1], |
| 2828 | dut->ft_bss_mac_list[0][2], |
| 2829 | dut->ft_bss_mac_list[0][3], |
| 2830 | dut->ft_bss_mac_list[0][4], |
| 2831 | dut->ft_bss_mac_list[0][5]); |
| 2832 | owrt_ap_set_vap(dut, vap_count, |
| 2833 | "ap2_macaddr", mac_str); |
| 2834 | owrt_ap_set_vap(dut, vap_count, |
| 2835 | "ap2_r1_key_holder", mac_str); |
| 2836 | owrt_ap_set_vap(dut, vap_count, |
| 2837 | "nasid2", "nas2.example.com"); |
| 2838 | } |
Adil Saeed Musthafa | a8d7484 | 2017-04-10 23:13:39 -0700 | [diff] [blame] | 2839 | } |
| 2840 | |
priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 2841 | if (dut->ap_oce == VALUE_ENABLED && |
| 2842 | get_driver_type() == DRIVER_OPENWRT) { |
| 2843 | owrt_ap_set_vap(dut, vap_id, "oce", "1"); |
| 2844 | owrt_ap_set_vap(dut, vap_id, "qbssload", "1"); |
| 2845 | owrt_ap_set_vap(dut, vap_id, "bpr_enable", "1"); |
| 2846 | |
priyadharshini gowthaman | 63ab848 | 2017-12-28 15:32:55 -0800 | [diff] [blame] | 2847 | if (dut->ap_80plus80 == 1) |
| 2848 | owrt_ap_set_vap(dut, vap_id, "cfreq2", "5775"); |
| 2849 | |
priyadharshini gowthaman | de81f39 | 2017-12-28 15:28:49 -0800 | [diff] [blame] | 2850 | if (dut->ap_akm == 1) { |
| 2851 | owrt_ap_set_vap(dut, vap_id, "wpa_group_rekey", |
| 2852 | "3600"); |
| 2853 | owrt_ap_set_vap(dut, vap_id, "key", "12345678"); |
| 2854 | owrt_ap_set_vap(dut, vap_id, "ieee80211ai", |
| 2855 | "1"); |
| 2856 | owrt_ap_set_vap(dut, vap_id, "fils_cache_id", |
| 2857 | "1234"); |
| 2858 | owrt_ap_set_vap(dut, vap_id, |
| 2859 | "erp_send_reauth_start", "1"); |
| 2860 | } |
| 2861 | |
priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 2862 | if (dut->ap_filshlp == VALUE_ENABLED) { |
| 2863 | struct ifreq ifr; |
| 2864 | char *ifname; |
| 2865 | int s; |
| 2866 | struct sockaddr_in *ipaddr; |
| 2867 | |
| 2868 | s = socket(AF_INET, SOCK_DGRAM, 0); |
| 2869 | if (s < 0) { |
| 2870 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 2871 | "Failed to open socket"); |
| 2872 | return -1; |
| 2873 | } |
| 2874 | ifr.ifr_addr.sa_family = AF_INET; |
| 2875 | |
| 2876 | memset(&ifr, 0, sizeof(ifr)); |
| 2877 | ifname = "br-lan"; |
| 2878 | strlcpy(ifr.ifr_name, ifname, |
| 2879 | sizeof(ifr.ifr_name)); |
| 2880 | if (ioctl(s, SIOCGIFADDR, &ifr) < 0) { |
| 2881 | perror("ioctl"); |
| 2882 | close(s); |
| 2883 | return -1; |
| 2884 | } |
| 2885 | |
| 2886 | ipaddr = (struct sockaddr_in*)&ifr.ifr_addr; |
| 2887 | snprintf(buf, sizeof(buf), "%s", |
| 2888 | inet_ntoa(ipaddr->sin_addr)); |
| 2889 | owrt_ap_set_vap(dut, vap_id, "own_ip_addr", |
| 2890 | buf); |
| 2891 | snprintf(buf, sizeof(buf), "%s", |
| 2892 | dut->ap_dhcpserv_ipaddr); |
| 2893 | owrt_ap_set_vap(dut, vap_id, "dhcp_server", |
| 2894 | buf); |
| 2895 | owrt_ap_set_vap(dut, vap_id, |
| 2896 | "dhcp_rapid_commit_proxy", "1"); |
| 2897 | owrt_ap_set_vap(dut, vap_id, |
| 2898 | "fils_hlp_wait_time", "300"); |
| 2899 | } |
| 2900 | |
| 2901 | if (dut->ap_filsdscv == VALUE_ENABLED) { |
| 2902 | owrt_ap_set_vap(dut, vap_id, "ieee80211ai", |
| 2903 | "1"); |
| 2904 | owrt_ap_set_vap(dut, vap_id, "fils_fd_period", |
| 2905 | "20"); |
| 2906 | } |
| 2907 | } |
| 2908 | |
| 2909 | if (dut->ap_filsdscv == VALUE_DISABLED) { |
| 2910 | owrt_ap_set_vap(dut, vap_id, "ieee80211ai", "0"); |
| 2911 | owrt_ap_set_vap(dut, vap_id, "fils_fd_period", "0"); |
| 2912 | } |
| 2913 | |
| 2914 | if (dut->ap_oce == VALUE_DISABLED && |
| 2915 | get_driver_type() == DRIVER_OPENWRT) { |
| 2916 | owrt_ap_set_vap(dut, vap_id, "oce", "0"); |
| 2917 | owrt_ap_set_vap(dut, vap_id, "qbssload", "0"); |
| 2918 | owrt_ap_set_vap(dut, vap_id, "bpr_enable", "0"); |
| 2919 | |
| 2920 | if (dut->ap_filsdscv == VALUE_DISABLED) { |
| 2921 | owrt_ap_set_vap(dut, vap_id, "ieee80211ai", |
| 2922 | "0"); |
| 2923 | owrt_ap_set_vap(dut, vap_id, "fils_fd_period", |
| 2924 | "0"); |
| 2925 | } |
| 2926 | |
| 2927 | if (dut->device_type == AP_testbed) |
| 2928 | owrt_ap_set_vap(dut, vap_id, "mbo", "1"); |
| 2929 | } |
| 2930 | |
| 2931 | /* NAIRealm */ |
| 2932 | if (dut->ap_nairealm_int == 1) { |
| 2933 | snprintf(buf, sizeof(buf), "\"%s\"", dut->ap_nairealm); |
| 2934 | owrt_ap_set_vap(dut, vap_id, "fils_realm", buf); |
| 2935 | owrt_ap_set_vap(dut, vap_id, "erp_domain", buf); |
| 2936 | } |
| 2937 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2938 | /* SSID */ |
| 2939 | snprintf(buf, sizeof(buf), "\"%s\"", dut->ap_ssid); |
| 2940 | owrt_ap_set_vap(dut, vap_count, "ssid", buf); |
| 2941 | |
| 2942 | /* Encryption */ |
| 2943 | switch (dut->ap_key_mgmt) { |
| 2944 | case AP_OPEN: |
| 2945 | if (dut->ap_cipher == AP_WEP) { |
| 2946 | owrt_ap_set_vap(dut, vap_count, "encryption", |
| 2947 | "wep-mixed"); |
| 2948 | owrt_ap_set_vap(dut, vap_count, "key", |
| 2949 | dut->ap_wepkey); |
| 2950 | } else { |
| 2951 | owrt_ap_set_vap(dut, vap_count, "encryption", |
| 2952 | "none"); |
| 2953 | } |
priyadharshini gowthaman | 0454706 | 2018-01-15 11:59:55 -0800 | [diff] [blame] | 2954 | if (dut->ap_key_mgmt == AP_OPEN && |
| 2955 | dut->ap_tag_key_mgmt[0] == AP2_WPA2_OWE) { |
| 2956 | /* OWE transition mode */ |
| 2957 | snprintf(ifname2, sizeof(ifname2), "%s1", |
| 2958 | ifname); |
| 2959 | owrt_ap_set_vap(dut, vap_count, |
| 2960 | "owe_transition_ifname", |
| 2961 | ifname2); |
| 2962 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2963 | break; |
| 2964 | case AP_WPA2_PSK: |
| 2965 | case AP_WPA2_PSK_MIXED: |
| 2966 | case AP_WPA_PSK: |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 2967 | case AP_WPA2_SAE: |
| 2968 | case AP_WPA2_PSK_SAE: |
priyadharshini gowthaman | cce6ca0 | 2018-01-15 11:12:45 -0800 | [diff] [blame] | 2969 | if (dut->ap_key_mgmt == AP_WPA2_PSK || |
| 2970 | dut->ap_key_mgmt == AP_WPA2_PSK_SAE) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2971 | snprintf(buf, sizeof(buf), "psk2"); |
| 2972 | } else if (dut->ap_key_mgmt == AP_WPA2_PSK_MIXED) { |
| 2973 | snprintf(buf, sizeof(buf), "psk-mixed"); |
priyadharshini gowthaman | cce6ca0 | 2018-01-15 11:12:45 -0800 | [diff] [blame] | 2974 | } else if (dut->ap_key_mgmt == AP_WPA2_SAE) { |
| 2975 | snprintf(buf, sizeof(buf), "ccmp"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2976 | } else { |
| 2977 | snprintf(buf, sizeof(buf), "psk"); |
| 2978 | } |
| 2979 | |
priyadharshini gowthaman | cce6ca0 | 2018-01-15 11:12:45 -0800 | [diff] [blame] | 2980 | if (dut->ap_key_mgmt != AP_WPA2_SAE) { |
| 2981 | if (dut->ap_cipher == AP_CCMP_TKIP) |
| 2982 | strlcat(buf, "+ccmp+tkip", sizeof(buf)); |
| 2983 | else if (dut->ap_cipher == AP_TKIP) |
| 2984 | strlcat(buf, "+tkip", sizeof(buf)); |
| 2985 | else |
| 2986 | strlcat(buf, "+ccmp", sizeof(buf)); |
| 2987 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2988 | |
| 2989 | owrt_ap_set_vap(dut, vap_count, "encryption", buf); |
priyadharshini gowthaman | cce6ca0 | 2018-01-15 11:12:45 -0800 | [diff] [blame] | 2990 | |
| 2991 | if (!dut->ap_passphrase[0] && dut->ap_psk[0]) { |
| 2992 | snprintf(buf, sizeof(buf), "\"%s\"", |
| 2993 | dut->ap_psk); |
| 2994 | owrt_ap_set_vap(dut, vap_count, "key", buf); |
| 2995 | } else { |
| 2996 | snprintf(buf, sizeof(buf), "\"%s\"", |
| 2997 | dut->ap_passphrase); |
| 2998 | owrt_ap_set_vap(dut, vap_count, "key", buf); |
| 2999 | } |
| 3000 | |
| 3001 | if (dut->ap_key_mgmt == AP_WPA2_SAE || |
| 3002 | dut->ap_key_mgmt == AP_WPA2_PSK_SAE) |
| 3003 | owrt_ap_set_vap(dut, vap_count, "sae", "1"); |
| 3004 | else |
| 3005 | owrt_ap_set_vap(dut, vap_count, "sae", "0"); |
| 3006 | |
| 3007 | if (dut->ap_key_mgmt == AP_WPA2_SAE) { |
| 3008 | snprintf(buf, sizeof(buf), "%s", |
| 3009 | dut->ap_passphrase); |
| 3010 | owrt_ap_set_vap(dut, vap_count, "sae_password", |
| 3011 | buf); |
| 3012 | } else { |
| 3013 | snprintf(buf, sizeof(buf), "%s", |
| 3014 | dut->ap_passphrase); |
| 3015 | owrt_ap_set_vap(dut, vap_count, |
| 3016 | "wpa_passphrase", buf); |
| 3017 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3018 | break; |
| 3019 | case AP_WPA2_EAP: |
| 3020 | case AP_WPA2_EAP_MIXED: |
| 3021 | case AP_WPA_EAP: |
| 3022 | if (dut->ap_key_mgmt == AP_WPA2_EAP) { |
| 3023 | snprintf(buf, sizeof(buf), "wpa2"); |
| 3024 | } else if (dut->ap_key_mgmt == AP_WPA2_EAP_MIXED) { |
| 3025 | snprintf(buf, sizeof(buf), "wpa-mixed"); |
| 3026 | } else { |
| 3027 | snprintf(buf, sizeof(buf), "wpa"); |
| 3028 | } |
| 3029 | |
Peng Xu | 591be45 | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 3030 | if (dut->ap_cipher == AP_CCMP_TKIP) |
| 3031 | strlcat(buf, "+ccmp+tkip", sizeof(buf)); |
| 3032 | else if (dut->ap_cipher == AP_TKIP) |
| 3033 | strlcat(buf, "+tkip", sizeof(buf)); |
| 3034 | else |
| 3035 | strlcat(buf, "+ccmp", sizeof(buf)); |
| 3036 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3037 | owrt_ap_set_vap(dut, vap_count, "encryption", buf); |
| 3038 | snprintf(buf, sizeof(buf), "%s", dut->ap_radius_ipaddr); |
| 3039 | owrt_ap_set_vap(dut, vap_count, "auth_server", buf); |
| 3040 | snprintf(buf, sizeof(buf), "%d", dut->ap_radius_port); |
| 3041 | owrt_ap_set_vap(dut, vap_count, "auth_port", buf); |
| 3042 | snprintf(buf, sizeof(buf), "%s", |
| 3043 | dut->ap_radius_password); |
| 3044 | owrt_ap_set_vap(dut, vap_count, "auth_secret", buf); |
| 3045 | break; |
Jouni Malinen | ad395a2 | 2017-09-01 21:13:46 +0300 | [diff] [blame] | 3046 | case AP_SUITEB: |
priyadharshini gowthaman | 2136bd5 | 2018-01-15 11:28:55 -0800 | [diff] [blame] | 3047 | owrt_ap_set_vap(dut, vap_count, "suite_b", "192"); |
| 3048 | snprintf(buf, sizeof(buf), "gcmp"); |
| 3049 | owrt_ap_set_vap(dut, vap_count, "encryption", buf); |
| 3050 | snprintf(buf, sizeof(buf), "%s", dut->ap_radius_ipaddr); |
| 3051 | owrt_ap_set_vap(dut, vap_count, "auth_server", buf); |
| 3052 | snprintf(buf, sizeof(buf), "%d", dut->ap_radius_port); |
| 3053 | owrt_ap_set_vap(dut, vap_count, "auth_port", buf); |
| 3054 | snprintf(buf, sizeof(buf), "%s", |
| 3055 | dut->ap_radius_password); |
| 3056 | owrt_ap_set_vap(dut, vap_count, "auth_secret", buf); |
| 3057 | snprintf(buf, sizeof(buf), "%d", |
| 3058 | dut->ap_group_mgmt_cipher); |
| 3059 | owrt_ap_set_vap(dut, vap_count, "group_mgmt_cipher", |
| 3060 | buf); |
Jouni Malinen | ad395a2 | 2017-09-01 21:13:46 +0300 | [diff] [blame] | 3061 | break; |
Jouni Malinen | 147b3c3 | 2017-10-09 16:51:54 +0300 | [diff] [blame] | 3062 | case AP_WPA2_OWE: |
priyadharshini gowthaman | 0454706 | 2018-01-15 11:59:55 -0800 | [diff] [blame] | 3063 | owrt_ap_set_vap(dut, vap_count, "owe", "1"); |
| 3064 | snprintf(buf, sizeof(buf), "ccmp"); |
| 3065 | owrt_ap_set_vap(dut, vap_count, "encryption", buf); |
| 3066 | if (dut->ap_sae_groups) { |
| 3067 | snprintf(buf, sizeof(buf), "\'%s\'", |
| 3068 | dut->ap_sae_groups); |
| 3069 | owrt_ap_set_vap(dut, vap_count, "owe_groups", |
| 3070 | buf); |
| 3071 | } |
| 3072 | |
| 3073 | if (dut->ap_key_mgmt == AP_WPA2_OWE && |
| 3074 | dut->ap_tag_ssid[0][0] && |
| 3075 | dut->ap_tag_key_mgmt[0] == AP2_OPEN) { |
| 3076 | /* OWE transition mode */ |
| 3077 | snprintf(ifname2, sizeof(ifname2), "%s1", |
| 3078 | ifname); |
| 3079 | owrt_ap_set_vap(dut, vap_count, |
| 3080 | "owe_transition_ifname", |
| 3081 | ifname2); |
| 3082 | owrt_ap_set_vap(dut, vap_count, "hidden", "1"); |
| 3083 | } |
Jouni Malinen | 147b3c3 | 2017-10-09 16:51:54 +0300 | [diff] [blame] | 3084 | break; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3085 | } |
| 3086 | |
| 3087 | if (!dut->ap_is_dual) |
| 3088 | break; |
| 3089 | } |
| 3090 | |
| 3091 | if (dut->ap_is_dual) |
| 3092 | return 1; |
| 3093 | |
| 3094 | /* PMF */ |
| 3095 | snprintf(buf, sizeof(buf), "%d", dut->ap_pmf); |
| 3096 | owrt_ap_set_vap(dut, vap_id, "ieee80211w", buf); |
| 3097 | |
| 3098 | /* Add SHA256 */ |
| 3099 | snprintf(buf, sizeof(buf), "%d", dut->ap_add_sha256); |
| 3100 | owrt_ap_set_vap(dut, vap_id, "add_sha256", buf); |
| 3101 | |
priyadharshini gowthaman | de81f39 | 2017-12-28 15:28:49 -0800 | [diff] [blame] | 3102 | /* Add SHA384 for akmsuitetype 15 */ |
| 3103 | if (dut->ap_akm == 1) { |
| 3104 | snprintf(buf, sizeof(buf), "%d", dut->ap_add_sha384); |
| 3105 | owrt_ap_set_vap(dut, vap_id, "add_sha384", buf); |
| 3106 | } |
| 3107 | |
Sarvepalli, Rajesh Babu | 24dc7e4 | 2016-03-18 21:27:26 +0530 | [diff] [blame] | 3108 | /* Enable RSN preauthentication, if asked to */ |
| 3109 | snprintf(buf, sizeof(buf), "%d", dut->ap_rsn_preauth); |
| 3110 | owrt_ap_set_vap(dut, vap_id, "rsn_preauth", buf); |
| 3111 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3112 | /* Hotspot 2.0 */ |
| 3113 | if (dut->ap_hs2) { |
| 3114 | int ret; |
| 3115 | |
| 3116 | ret = owrt_ap_config_vap_hs2(dut, vap_id); |
| 3117 | if (ret) |
| 3118 | return ret; |
| 3119 | } |
| 3120 | |
| 3121 | /* Interworking */ |
| 3122 | if (dut->ap_interworking) { |
| 3123 | snprintf(buf, sizeof(buf), "%d", dut->ap_access_net_type); |
| 3124 | owrt_ap_set_vap(dut, vap_id, "access_network_type", buf); |
| 3125 | snprintf(buf, sizeof(buf), "%d", dut->ap_internet); |
| 3126 | owrt_ap_set_vap(dut, vap_id, "internet", buf); |
| 3127 | snprintf(buf, sizeof(buf), "%d", dut->ap_venue_group); |
| 3128 | owrt_ap_set_vap(dut, vap_id, "venue_group", buf); |
| 3129 | snprintf(buf, sizeof(buf), "%d", dut->ap_venue_type); |
| 3130 | owrt_ap_set_vap(dut, vap_id, "venue_type", buf); |
| 3131 | snprintf(buf, sizeof(buf), "%s", dut->ap_hessid); |
| 3132 | owrt_ap_set_vap(dut, vap_id, "hessid", buf); |
| 3133 | |
| 3134 | if (dut->ap_gas_cb_delay > 0) { |
| 3135 | snprintf(buf, sizeof(buf), "%d", dut->ap_gas_cb_delay); |
| 3136 | owrt_ap_set_vap(dut, vap_id, "gas_comeback_delay", buf); |
| 3137 | } |
| 3138 | |
| 3139 | if (dut->ap_roaming_cons[0]) { |
| 3140 | char *rcons, *temp_ptr; |
| 3141 | |
| 3142 | rcons = strdup(dut->ap_roaming_cons); |
| 3143 | if (rcons == NULL) |
| 3144 | return 0; |
| 3145 | |
| 3146 | temp_ptr = strchr(rcons, ';'); |
| 3147 | |
| 3148 | if (temp_ptr) |
| 3149 | *temp_ptr++ = '\0'; |
| 3150 | |
| 3151 | owrt_ap_set_list_vap(dut, vap_id, "roaming_consortium", |
| 3152 | rcons); |
| 3153 | |
| 3154 | if (temp_ptr) |
| 3155 | owrt_ap_set_list_vap(dut, vap_id, |
| 3156 | "roaming_consortium", |
| 3157 | temp_ptr); |
| 3158 | |
| 3159 | free(rcons); |
| 3160 | } |
| 3161 | } |
| 3162 | |
| 3163 | if (dut->ap_venue_name) { |
| 3164 | owrt_ap_set_list_vap(dut, vap_id, "venue_name", |
| 3165 | "'P\"eng:Wi-Fi Alliance\\n2989 Copper Road\\nSanta Clara, CA 95051, USA\"'"); |
| 3166 | owrt_ap_set_list_vap(dut, vap_id, "venue_name", |
| 3167 | "\'"ANQP_VENUE_NAME_1_CHI"\'"); |
| 3168 | } |
| 3169 | |
| 3170 | if (dut->ap_net_auth_type == 1) { |
| 3171 | owrt_ap_set_vap(dut, vap_id, "network_auth_type", |
| 3172 | "'00https://tandc-server.wi-fi.org'"); |
| 3173 | } else if (dut->ap_net_auth_type == 2) { |
| 3174 | owrt_ap_set_vap(dut, vap_id, "network_auth_type", "'01'"); |
| 3175 | } |
| 3176 | |
| 3177 | if (dut->ap_nai_realm_list == 1) { |
| 3178 | owrt_ap_set_list_vap(dut, vap_id, "nai_realm", |
| 3179 | "'0,mail.example.com;cisco.com;wi-fi.org,21[2:4][5:7]'"); |
| 3180 | owrt_ap_set_list_vap(dut, vap_id, "nai_realm", |
| 3181 | "'0,wi-fi.org;example.com,13[5:6]'"); |
| 3182 | |
| 3183 | } else if (dut->ap_nai_realm_list == 2) { |
| 3184 | owrt_ap_set_list_vap(dut, vap_id, "nai_realm", |
| 3185 | "'0,wi-fi.org,21[2:4][5:7]'"); |
| 3186 | } else if (dut->ap_nai_realm_list == 3) { |
| 3187 | owrt_ap_set_list_vap(dut, vap_id, "nai_realm", |
| 3188 | "'0,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 | } else if (dut->ap_nai_realm_list == 4) { |
| 3192 | owrt_ap_set_list_vap(dut, vap_id, "nai_realm", |
| 3193 | "'0,mail.example.com,21[2:4][5:7],13[5:6]'"); |
| 3194 | } else if (dut->ap_nai_realm_list == 5) { |
| 3195 | owrt_ap_set_list_vap(dut, vap_id, "nai_realm", |
| 3196 | "'0,wi-fi.org;ruckuswireless.com,21[2:4][5:7]'"); |
| 3197 | } else if (dut->ap_nai_realm_list == 6) { |
| 3198 | owrt_ap_set_list_vap(dut, vap_id, "nai_realm", |
| 3199 | "'0,wi-fi.org;mail.example.com,21[2:4][5:7]'"); |
| 3200 | } else if (dut->ap_nai_realm_list == 7) { |
| 3201 | owrt_ap_set_list_vap(dut, vap_id, "nai_realm", |
| 3202 | "'0,wi-fi.org,13[5:6]'"); |
| 3203 | owrt_ap_set_list_vap(dut, vap_id, "nai_realm", |
| 3204 | "'0,wi-fi.org,21[2:4][5:7]'"); |
| 3205 | } |
| 3206 | |
| 3207 | if (dut->ap_domain_name_list[0]) |
| 3208 | owrt_ap_set_list_vap(dut, vap_id, "domain_name", |
| 3209 | dut->ap_domain_name_list); |
| 3210 | |
| 3211 | if (dut->ap_ip_addr_type_avail) |
| 3212 | owrt_ap_set_vap(dut, vap_id, "ipaddr_type_availability", |
| 3213 | "'0c'"); |
| 3214 | |
| 3215 | temp = buf; |
| 3216 | |
| 3217 | *temp++ = '\''; |
| 3218 | |
| 3219 | for (i = 0; dut->ap_plmn_mcc[i][0] && dut->ap_plmn_mnc[i][0]; i++) { |
| 3220 | if (i) |
| 3221 | *temp++ = ';'; |
| 3222 | |
| 3223 | snprintf(temp, |
| 3224 | sizeof(dut->ap_plmn_mcc[i]) + |
| 3225 | sizeof(dut->ap_plmn_mnc[i]) + 1, |
| 3226 | "%s,%s", |
| 3227 | dut->ap_plmn_mcc[i], |
| 3228 | dut->ap_plmn_mnc[i]); |
| 3229 | |
| 3230 | temp += strlen(dut->ap_plmn_mcc[i]) + |
| 3231 | strlen(dut->ap_plmn_mnc[i]) + 1; |
| 3232 | } |
| 3233 | |
| 3234 | *temp++ = '\''; |
| 3235 | *temp++ = '\0'; |
| 3236 | |
| 3237 | if (i) |
| 3238 | owrt_ap_set_vap(dut, vap_id, "anqp_3gpp_cell_net", buf); |
| 3239 | |
| 3240 | if (dut->ap_qos_map_set == 1) |
| 3241 | owrt_ap_set_vap(dut, vap_id, "qos_map_set", QOS_MAP_SET_1); |
| 3242 | else if (dut->ap_qos_map_set == 2) |
| 3243 | owrt_ap_set_vap(dut, vap_id, "qos_map_set", QOS_MAP_SET_2); |
| 3244 | |
| 3245 | /* Proxy-ARP */ |
| 3246 | snprintf(buf, sizeof(buf), "%d", dut->ap_proxy_arp); |
| 3247 | owrt_ap_set_vap(dut, vap_id, "proxyarp", buf); |
| 3248 | |
| 3249 | /* DGAF */ |
| 3250 | snprintf(buf, sizeof(buf), "%d", dut->ap_dgaf_disable); |
| 3251 | /* parse to hostapd */ |
| 3252 | owrt_ap_set_vap(dut, vap_id, "disable_dgaf", buf); |
| 3253 | /* parse to wifi driver */ |
| 3254 | owrt_ap_set_vap(dut, vap_id, "dgaf_disable", buf); |
| 3255 | |
| 3256 | /* HCBSSLoad */ |
| 3257 | if (dut->ap_bss_load) { |
| 3258 | unsigned int bssload = 0; |
| 3259 | |
| 3260 | if (dut->ap_bss_load == 1) { |
| 3261 | /* STA count: 1, CU: 50, AAC: 65535 */ |
| 3262 | bssload = 0x0132ffff; |
| 3263 | } else if (dut->ap_bss_load == 2) { |
| 3264 | /* STA count: 1, CU: 200, AAC: 65535 */ |
| 3265 | bssload = 0x01c8ffff; |
| 3266 | } else if (dut->ap_bss_load == 3) { |
| 3267 | /* STA count: 1, CU: 75, AAC: 65535 */ |
| 3268 | bssload = 0x014bffff; |
| 3269 | } |
| 3270 | |
| 3271 | snprintf(buf, sizeof(buf), "%d", bssload); |
| 3272 | owrt_ap_set_vap(dut, vap_id, "hcbssload", buf); |
| 3273 | } |
| 3274 | |
| 3275 | /* L2TIF */ |
| 3276 | if (dut->ap_l2tif) |
| 3277 | owrt_ap_set_vap(dut, vap_id, "l2tif", "1"); |
| 3278 | |
| 3279 | if (dut->ap_disable_protection == 1) |
| 3280 | owrt_ap_set_vap(dut, vap_id, "enablertscts", "0"); |
| 3281 | |
Sunil Dutt | 77b213d | 2017-09-14 18:24:40 +0300 | [diff] [blame] | 3282 | if (dut->ap_txBF) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3283 | owrt_ap_set_vap(dut, vap_id, "vhtsubfee", "1"); |
| 3284 | owrt_ap_set_vap(dut, vap_id, "vhtsubfer", "1"); |
| 3285 | } |
| 3286 | |
Mohammed Shafi Shajakhan | 061af00 | 2016-06-02 20:10:54 +0530 | [diff] [blame] | 3287 | if (dut->ap_mu_txBF) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3288 | owrt_ap_set_vap(dut, vap_id, "vhtmubfer", "1"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3289 | |
Vasanthakumar Pandurangan | 2b5431d | 2016-01-12 15:52:48 +0530 | [diff] [blame] | 3290 | if (dut->ap_tx_stbc) { |
| 3291 | /* STBC and beamforming are mutually exclusive features */ |
| 3292 | owrt_ap_set_vap(dut, vap_id, "implicitbf", "0"); |
| 3293 | } |
| 3294 | |
Priyadharshini Gowthaman | 8fb1504 | 2015-11-25 18:27:41 +0530 | [diff] [blame] | 3295 | /* enable dfsmode */ |
| 3296 | snprintf(buf, sizeof(buf), "%d", dut->ap_dfs_mode); |
| 3297 | owrt_ap_set_vap(dut, vap_id, "doth", buf); |
| 3298 | |
priyadharshini gowthaman | 2323d0a | 2016-09-02 15:48:02 -0700 | [diff] [blame] | 3299 | if (dut->program == PROGRAM_LOC && dut->ap_interworking) { |
| 3300 | char anqpval[1024]; |
| 3301 | |
| 3302 | owrt_ap_set_vap(dut, vap_id, "interworking", "1"); |
| 3303 | |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 3304 | 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] | 3305 | snprintf(anqpval, sizeof(anqpval), |
| 3306 | "'265:0010%s%s060101'", |
priyadharshini gowthaman | 2323d0a | 2016-09-02 15:48:02 -0700 | [diff] [blame] | 3307 | dut->ap_val_lci, dut->ap_infoz); |
| 3308 | owrt_ap_set_list_vap(dut, vap_id, "anqp_elem", anqpval); |
| 3309 | } |
| 3310 | |
| 3311 | if (dut->ap_lcr == 1) { |
Pradeep Reddy Potteti | b48012a | 2016-11-28 16:58:54 +0530 | [diff] [blame] | 3312 | snprintf(anqpval, sizeof(anqpval), |
| 3313 | "'266:0000b2555302ae%s'", |
priyadharshini gowthaman | 2323d0a | 2016-09-02 15:48:02 -0700 | [diff] [blame] | 3314 | dut->ap_val_lcr); |
| 3315 | owrt_ap_set_list_vap(dut, vap_id, "anqp_elem", anqpval); |
| 3316 | } |
| 3317 | |
| 3318 | if (dut->ap_fqdn_held == 1 && dut->ap_fqdn_supl == 1) |
| 3319 | owrt_ap_set_list_vap(dut, vap_id, "anqp_elem", |
| 3320 | "'267:00110168656c642e6578616d706c652e636f6d0011027375706c2e6578616d706c652e636f6d'"); |
| 3321 | } |
| 3322 | |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 3323 | if (dut->program == PROGRAM_MBO) { |
| 3324 | owrt_ap_set_vap(dut, vap_id, "interworking", "1"); |
| 3325 | owrt_ap_set_vap(dut, vap_id, "mbo", "1"); |
| 3326 | owrt_ap_set_vap(dut, vap_id, "rrm", "1"); |
Adil Saeed Musthafa | 65160c0 | 2017-04-10 23:13:38 -0700 | [diff] [blame] | 3327 | owrt_ap_set_vap(dut, vap_id, "mbo_cell_conn_pref", "1"); |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 3328 | |
| 3329 | owrt_ap_set_list_vap(dut, vap_id, "anqp_elem", |
| 3330 | "'272:34108cfdf0020df1f7000000733000030101'"); |
Adil Saeed Musthafa | ed5faae | 2017-04-10 23:13:36 -0700 | [diff] [blame] | 3331 | snprintf(buf, sizeof(buf), "%d", dut->ap_gas_cb_delay); |
| 3332 | owrt_ap_set_vap(dut, vap_id, "gas_comeback_delay", buf); |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 3333 | } |
| 3334 | |
Adil Saeed Musthafa | 4ec61bd | 2017-04-10 23:13:41 -0700 | [diff] [blame] | 3335 | if (dut->ap_ft_oa == 1) { |
| 3336 | unsigned char self_mac[ETH_ALEN]; |
| 3337 | char mac_str[20]; |
| 3338 | |
| 3339 | owrt_ap_set_vap(dut, vap_id, "ft_over_ds", "0"); |
| 3340 | owrt_ap_set_vap(dut, vap_id, "ieee80211r", "1"); |
| 3341 | get_hwaddr(sigma_radio_ifname[0], self_mac); |
| 3342 | snprintf(mac_str, sizeof(mac_str), |
| 3343 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 3344 | self_mac[0], self_mac[1], self_mac[2], |
| 3345 | self_mac[3], self_mac[4], self_mac[5]); |
| 3346 | owrt_ap_set_vap(dut, vap_id, "ap_macaddr", mac_str); |
priyadharshini gowthaman | 47189f5 | 2017-12-28 12:37:46 -0800 | [diff] [blame] | 3347 | snprintf(mac_str, sizeof(mac_str), |
| 3348 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 3349 | self_mac[0], self_mac[1], self_mac[2], |
| 3350 | self_mac[3], self_mac[4], self_mac[5]); |
| 3351 | 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] | 3352 | owrt_ap_set_vap(dut, vap_id, "ft_psk_generate_local", "1"); |
| 3353 | owrt_ap_set_vap(dut, vap_id, "kh_key_hex", |
| 3354 | "000102030405060708090a0b0c0d0e0f"); |
| 3355 | snprintf(mac_str, sizeof(mac_str), |
| 3356 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 3357 | dut->ft_bss_mac_list[0][0], |
| 3358 | dut->ft_bss_mac_list[0][1], |
| 3359 | dut->ft_bss_mac_list[0][2], |
| 3360 | dut->ft_bss_mac_list[0][3], |
| 3361 | dut->ft_bss_mac_list[0][4], |
| 3362 | dut->ft_bss_mac_list[0][5]); |
| 3363 | owrt_ap_set_vap(dut, vap_id, "ap2_macaddr", mac_str); |
priyadharshini gowthaman | 47189f5 | 2017-12-28 12:37:46 -0800 | [diff] [blame] | 3364 | owrt_ap_set_vap(dut, vap_id, "mobility_domain", |
| 3365 | dut->ap_mobility_domain); |
| 3366 | 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] | 3367 | } |
| 3368 | |
| 3369 | if ((dut->ap_ft_oa == 1 && dut->ap_name == 0) || |
| 3370 | (dut->ap_ft_oa == 1 && dut->ap_name == 2)) { |
Adil Saeed Musthafa | 4ec61bd | 2017-04-10 23:13:41 -0700 | [diff] [blame] | 3371 | owrt_ap_set_vap(dut, vap_id, "nasid2", "nas2.example.com"); |
| 3372 | owrt_ap_set_vap(dut, vap_id, "nasid", "nas1.example.com"); |
Adil Saeed Musthafa | 4ec61bd | 2017-04-10 23:13:41 -0700 | [diff] [blame] | 3373 | } |
| 3374 | |
| 3375 | if (dut->ap_ft_oa == 1 && dut->ap_name == 1) { |
Adil Saeed Musthafa | 4ec61bd | 2017-04-10 23:13:41 -0700 | [diff] [blame] | 3376 | owrt_ap_set_vap(dut, vap_id, "nasid2", "nas1.example.com"); |
| 3377 | owrt_ap_set_vap(dut, vap_id, "nasid", "nas2.example.com"); |
Adil Saeed Musthafa | 4ec61bd | 2017-04-10 23:13:41 -0700 | [diff] [blame] | 3378 | } |
| 3379 | |
priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 3380 | if (dut->ap_broadcast_ssid == VALUE_DISABLED) |
| 3381 | owrt_ap_set_vap(dut, vap_id, "hidden", "1"); |
| 3382 | |
priyadharshini gowthaman | de81f39 | 2017-12-28 15:28:49 -0800 | [diff] [blame] | 3383 | /* Enable/disable PMKSA caching, if asked to */ |
| 3384 | if (dut->ap_pmksa == 1) { |
| 3385 | snprintf(buf, sizeof(buf), "%d", dut->ap_pmksa_caching); |
| 3386 | owrt_ap_set_vap(dut, vap_id, "disable_pmksa_caching", buf); |
| 3387 | } |
| 3388 | |
priyadharshini gowthaman | cce6ca0 | 2018-01-15 11:12:45 -0800 | [diff] [blame] | 3389 | if (dut->rsne_override) { |
| 3390 | snprintf(buf, sizeof(buf), "%s", dut->rsne_override); |
| 3391 | owrt_ap_set_vap(dut, vap_count, "own_ie_override", buf); |
| 3392 | } |
| 3393 | |
| 3394 | if (dut->sae_commit_override) { |
| 3395 | snprintf(buf, sizeof(buf), "%s", dut->sae_commit_override); |
| 3396 | owrt_ap_set_vap(dut, vap_count, "sae_commit_override", buf); |
| 3397 | } |
| 3398 | |
| 3399 | if (dut->ap_sae_groups) { |
| 3400 | snprintf(buf, sizeof(buf), "\'%s\'", dut->ap_sae_groups); |
| 3401 | owrt_ap_set_vap(dut, vap_count, "sae_groups", buf); |
| 3402 | } |
| 3403 | |
| 3404 | if (dut->sae_anti_clogging_threshold >= 0) { |
| 3405 | snprintf(buf, sizeof(buf), "%d", |
| 3406 | dut->sae_anti_clogging_threshold); |
| 3407 | owrt_ap_set_vap(dut, vap_count, "sae_anti_clogging_threshold", |
| 3408 | buf); |
| 3409 | } |
| 3410 | |
| 3411 | if (dut->sae_reflection) |
| 3412 | owrt_ap_set_vap(dut, vap_count, "sae_reflection_attack", "1"); |
| 3413 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3414 | return 1; |
| 3415 | } |
| 3416 | |
| 3417 | |
priyadharshini gowthaman | 2500f20 | 2016-10-13 17:13:55 -0700 | [diff] [blame] | 3418 | static int owrt_ap_config_vap_anqp(struct sigma_dut *dut) |
| 3419 | { |
| 3420 | char anqpval[1024]; |
| 3421 | unsigned char addr[6]; |
| 3422 | unsigned char addr2[6]; |
| 3423 | struct ifreq ifr; |
| 3424 | char *ifname; |
| 3425 | int s; |
| 3426 | int vap_id = 0; |
| 3427 | |
| 3428 | s = socket(AF_INET, SOCK_DGRAM, 0); |
| 3429 | if (s < 0) { |
| 3430 | sigma_dut_print(dut, DUT_MSG_ERROR, "Failed to open socket"); |
| 3431 | return -1; |
| 3432 | } |
| 3433 | |
| 3434 | memset(&ifr, 0, sizeof(ifr)); |
| 3435 | ifname = "ath0"; |
Peng Xu | b8fc5cc | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 3436 | strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name)); |
priyadharshini gowthaman | 2500f20 | 2016-10-13 17:13:55 -0700 | [diff] [blame] | 3437 | if (ioctl(s, SIOCGIFHWADDR, &ifr) < 0) { |
| 3438 | perror("ioctl"); |
| 3439 | close(s); |
| 3440 | return -1; |
| 3441 | } |
| 3442 | memcpy(addr, ifr.ifr_hwaddr.sa_data, 6); |
| 3443 | |
| 3444 | memset(&ifr, 0, sizeof(ifr)); |
| 3445 | ifname = "ath01"; |
Peng Xu | b8fc5cc | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 3446 | strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name)); |
priyadharshini gowthaman | 2500f20 | 2016-10-13 17:13:55 -0700 | [diff] [blame] | 3447 | if (ioctl(s, SIOCGIFHWADDR, &ifr) < 0) { |
| 3448 | perror("ioctl"); |
| 3449 | close(s); |
| 3450 | return -1; |
| 3451 | } |
| 3452 | close(s); |
| 3453 | memcpy(addr2, ifr.ifr_hwaddr.sa_data, 6); |
| 3454 | |
| 3455 | snprintf(anqpval, sizeof(anqpval), |
| 3456 | "'265:0010%s%s060101070d00%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x'", |
| 3457 | dut->ap_val_lci, dut->ap_infoz, |
| 3458 | addr[0], addr[1], addr[2], addr[3], addr[4], addr[5], |
| 3459 | addr2[0], addr2[1], addr2[2], addr2[3], addr2[4], addr2[5]); |
| 3460 | |
| 3461 | owrt_ap_set_list_vap(dut, vap_id, "anqp_elem", anqpval); |
| 3462 | return 0; |
| 3463 | } |
| 3464 | |
| 3465 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3466 | static int owrt_ap_post_config_commit(struct sigma_dut *dut, |
| 3467 | struct sigma_conn *conn, |
| 3468 | struct sigma_cmd *cmd) |
| 3469 | { |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 3470 | int ap_security = 0; |
| 3471 | int i; |
| 3472 | |
| 3473 | for (i = 0; i < MAX_WLAN_TAGS - 1; i++) { |
| 3474 | if (dut->ap_tag_key_mgmt[i] != AP2_OPEN) |
| 3475 | ap_security = 1; |
| 3476 | } |
| 3477 | if (dut->ap_key_mgmt != AP_OPEN) |
| 3478 | ap_security = 1; |
| 3479 | if (ap_security) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3480 | /* allow some time for hostapd to start before returning |
| 3481 | * success */ |
| 3482 | usleep(500000); |
| 3483 | |
| 3484 | if (run_hostapd_cli(dut, "ping") != 0) { |
| 3485 | send_resp(dut, conn, SIGMA_ERROR, |
| 3486 | "errorCode,Failed to talk to hostapd"); |
| 3487 | return 0; |
| 3488 | } |
| 3489 | } |
| 3490 | |
| 3491 | if (get_openwrt_driver_type() == OPENWRT_DRIVER_ATHEROS) |
| 3492 | ath_ap_set_params(dut); |
| 3493 | |
| 3494 | /* Send response */ |
| 3495 | return 1; |
| 3496 | } |
| 3497 | |
| 3498 | |
| 3499 | static int cmd_owrt_ap_config_commit(struct sigma_dut *dut, |
| 3500 | struct sigma_conn *conn, |
| 3501 | struct sigma_cmd *cmd) |
| 3502 | { |
priyadharshini gowthaman | b4de196 | 2018-01-15 12:21:04 -0800 | [diff] [blame] | 3503 | if (dut->program == PROGRAM_DPP && |
| 3504 | get_driver_type() == DRIVER_OPENWRT) { |
| 3505 | wpa_command(dut->hostapd_ifname, "DPP_BOOTSTRAP_REMOVE *"); |
| 3506 | wpa_command(dut->hostapd_ifname, "DPP_PKEX_REMOVE *"); |
| 3507 | } |
| 3508 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3509 | /* Stop the AP */ |
| 3510 | run_system(dut, "wifi down"); |
| 3511 | |
| 3512 | /* Reset the wireless configuration */ |
Mohammed Shafi Shajakhan | f789f82 | 2016-04-07 18:53:16 +0530 | [diff] [blame] | 3513 | run_system(dut, "rm -rf /etc/config/wireless"); |
| 3514 | switch (get_openwrt_driver_type()) { |
| 3515 | case OPENWRT_DRIVER_ATHEROS: |
| 3516 | run_system(dut, "wifi detect qcawifi > /etc/config/wireless"); |
| 3517 | break; |
| 3518 | default: |
| 3519 | run_system(dut, "wifi detect > /etc/config/wireless"); |
| 3520 | break; |
| 3521 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3522 | |
| 3523 | /* Configure Radio & VAP, commit the config */ |
| 3524 | owrt_ap_config_radio(dut); |
| 3525 | owrt_ap_config_vap(dut); |
| 3526 | run_system(dut, "uci commit"); |
| 3527 | |
| 3528 | /* Start AP */ |
| 3529 | run_system(dut, "wifi up"); |
Adil Saeed Musthafa | a8d7484 | 2017-04-10 23:13:39 -0700 | [diff] [blame] | 3530 | if (dut->program != PROGRAM_MBO && |
| 3531 | dut->ap_lci == 1 && dut->ap_interworking && |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 3532 | strlen(dut->ap_tag_ssid[0]) > 0) { |
Adil Saeed Musthafa | a8d7484 | 2017-04-10 23:13:39 -0700 | [diff] [blame] | 3533 | /* |
| 3534 | * MBO has a different ANQP element value which is set in |
| 3535 | * owrt_ap_config_vap(). |
| 3536 | */ |
priyadharshini gowthaman | 2500f20 | 2016-10-13 17:13:55 -0700 | [diff] [blame] | 3537 | owrt_ap_config_vap_anqp(dut); |
| 3538 | run_system(dut, "uci commit"); |
| 3539 | run_system(dut, "wifi"); |
| 3540 | } |
| 3541 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3542 | return owrt_ap_post_config_commit(dut, conn, cmd); |
| 3543 | } |
| 3544 | |
| 3545 | |
| 3546 | static void cmd_owrt_ap_hs2_reset(struct sigma_dut *dut) |
| 3547 | { |
| 3548 | unsigned char bssid[6]; |
| 3549 | char buf[100]; |
| 3550 | char *ifname, *radio_name; |
| 3551 | int vap_id = 0; |
| 3552 | |
| 3553 | if (sigma_radio_ifname[0] && |
| 3554 | strcmp(sigma_radio_ifname[0], "wifi2") == 0) { |
| 3555 | ifname = "ath2"; |
| 3556 | radio_name = "wifi2"; |
| 3557 | vap_id = 2; |
| 3558 | } else if (sigma_radio_ifname[0] && |
| 3559 | strcmp(sigma_radio_ifname[0], "wifi1") == 0) { |
| 3560 | ifname = "ath1"; |
| 3561 | radio_name = "wifi1"; |
| 3562 | vap_id = 1; |
| 3563 | } else { |
| 3564 | ifname = "ath0"; |
| 3565 | radio_name = "wifi0"; |
| 3566 | vap_id = 0; |
| 3567 | } |
| 3568 | |
| 3569 | if (!get_hwaddr(ifname, bssid)) { |
| 3570 | snprintf(buf, sizeof(buf), "%s", bssid); |
| 3571 | owrt_ap_set_vap(dut, vap_id, "hessid", buf); |
| 3572 | snprintf(dut->ap_hessid, sizeof(dut->ap_hessid), |
| 3573 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 3574 | bssid[0], bssid[1], bssid[2], bssid[3], |
| 3575 | bssid[4], bssid[5]); |
| 3576 | } else { |
| 3577 | if (!get_hwaddr(radio_name, bssid)) { |
| 3578 | snprintf(buf, sizeof(buf), "%s", dut->ap_hessid); |
| 3579 | owrt_ap_set_vap(dut, vap_id, "hessid", buf); |
| 3580 | snprintf(dut->ap_hessid, sizeof(dut->ap_hessid), |
| 3581 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 3582 | bssid[0], bssid[1], bssid[2], bssid[3], |
| 3583 | bssid[4], bssid[5]); |
| 3584 | } else { |
| 3585 | /* Select & enable/disable radios */ |
| 3586 | if (sigma_radio_ifname[0] && |
| 3587 | strcmp(sigma_radio_ifname[0], "wifi2") == 0) { |
| 3588 | /* We want to use wifi2 */ |
| 3589 | owrt_ap_set_radio(dut, 0, "disabled", "1"); |
| 3590 | owrt_ap_set_radio(dut, 1, "disabled", "1"); |
| 3591 | owrt_ap_set_radio(dut, 2, "disabled", "0"); |
| 3592 | owrt_ap_set_vap(dut, vap_id, "device", "wifi2"); |
| 3593 | } else if (sigma_radio_ifname[0] && |
| 3594 | strcmp(sigma_radio_ifname[0], "wifi1") == 0) { |
| 3595 | /* We want to use wifi1 */ |
| 3596 | owrt_ap_set_radio(dut, 0, "disabled", "1"); |
| 3597 | owrt_ap_set_radio(dut, 1, "disabled", "0"); |
| 3598 | owrt_ap_set_vap(dut, vap_id, "device", "wifi1"); |
| 3599 | } else { |
| 3600 | /* We want to use wifi0 */ |
| 3601 | owrt_ap_set_radio(dut, 0, "disabled", "0"); |
| 3602 | owrt_ap_set_radio(dut, 1, "disabled", "1"); |
| 3603 | owrt_ap_set_vap(dut, vap_id, "device", "wifi0"); |
| 3604 | } |
| 3605 | |
| 3606 | run_system(dut, "uci commit"); |
| 3607 | run_system(dut, "wifi up"); |
| 3608 | |
| 3609 | if (!get_hwaddr(radio_name, bssid)) { |
| 3610 | snprintf(buf, sizeof(buf), "%s", |
| 3611 | dut->ap_hessid); |
| 3612 | owrt_ap_set_vap(dut, vap_id, "hessid", buf); |
| 3613 | snprintf(dut->ap_hessid, sizeof(dut->ap_hessid), |
| 3614 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 3615 | bssid[0], bssid[1], bssid[2], bssid[3], |
| 3616 | bssid[4], bssid[5]); |
| 3617 | } |
| 3618 | } |
| 3619 | } |
| 3620 | } |
| 3621 | |
| 3622 | |
| 3623 | static int cmd_ap_reboot(struct sigma_dut *dut, struct sigma_conn *conn, |
| 3624 | struct sigma_cmd *cmd) |
| 3625 | { |
| 3626 | switch (get_driver_type()) { |
| 3627 | case DRIVER_ATHEROS: |
| 3628 | run_system(dut, "apdown"); |
| 3629 | sleep(1); |
| 3630 | run_system(dut, "reboot"); |
| 3631 | break; |
| 3632 | case DRIVER_OPENWRT: |
| 3633 | run_system(dut, "wifi down"); |
| 3634 | sleep(1); |
| 3635 | run_system(dut, "reboot"); |
| 3636 | break; |
| 3637 | default: |
| 3638 | sigma_dut_print(dut, DUT_MSG_INFO, "Ignore ap_reboot command"); |
| 3639 | break; |
| 3640 | } |
| 3641 | |
| 3642 | return 1; |
| 3643 | } |
| 3644 | |
| 3645 | |
| 3646 | int ascii2hexstr(const char *str, char *hex) |
| 3647 | { |
| 3648 | int i, length; |
| 3649 | |
| 3650 | length = strlen(str); |
| 3651 | |
| 3652 | for (i = 0; i < length; i++) |
| 3653 | snprintf(hex + i * 2, 3, "%X", str[i]); |
| 3654 | |
| 3655 | hex[length * 2] = '\0'; |
| 3656 | return 1; |
| 3657 | } |
| 3658 | |
| 3659 | |
| 3660 | static int kill_process(struct sigma_dut *dut, char *proc_name, |
| 3661 | unsigned char is_proc_instance_one, int sig) |
| 3662 | { |
| 3663 | #ifdef __linux__ |
| 3664 | struct dirent *dp, *dp_in; |
| 3665 | const char *direc = "/proc/"; |
| 3666 | char buf[100]; |
| 3667 | DIR *dir = opendir(direc); |
| 3668 | DIR *dir_in; |
| 3669 | FILE *fp; |
| 3670 | char *pid, *temp; |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 3671 | char *saveptr; |
Pradeep Reddy Potteti | d068e64 | 2017-02-17 20:03:12 +0530 | [diff] [blame] | 3672 | int ret = -1; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3673 | |
| 3674 | if (dir == NULL) |
Pradeep Reddy Potteti | d068e64 | 2017-02-17 20:03:12 +0530 | [diff] [blame] | 3675 | return ret; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3676 | |
| 3677 | while ((dp = readdir(dir)) != NULL) { |
| 3678 | if (dp->d_type != DT_DIR) |
| 3679 | continue; |
| 3680 | |
| 3681 | snprintf(buf, sizeof(buf), "%s%s", direc, dp->d_name); |
| 3682 | dir_in = opendir(buf); |
| 3683 | if (dir_in == NULL) |
| 3684 | continue; |
| 3685 | dp_in = readdir(dir_in); |
| 3686 | closedir(dir_in); |
| 3687 | if (dp_in == NULL) |
| 3688 | continue; |
| 3689 | snprintf(buf, sizeof(buf), "%s%s/stat", direc, dp->d_name); |
| 3690 | fp = fopen(buf, "r"); |
| 3691 | if (fp == NULL) |
| 3692 | continue; |
| 3693 | if (fgets(buf, 100, fp) == NULL) |
| 3694 | buf[0] = '\0'; |
| 3695 | fclose(fp); |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 3696 | pid = strtok_r(buf, " ", &saveptr); |
| 3697 | temp = strtok_r(NULL, " ", &saveptr); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3698 | if (pid && temp && |
| 3699 | strncmp(temp, proc_name, strlen(proc_name)) == 0) { |
| 3700 | sigma_dut_print(dut, DUT_MSG_INFO, |
| 3701 | "killing %s process with PID %s", |
| 3702 | proc_name, pid); |
| 3703 | snprintf(buf, sizeof(buf), "kill -%d %d", sig, |
| 3704 | atoi(pid)); |
| 3705 | run_system(dut, buf); |
Pradeep Reddy Potteti | d068e64 | 2017-02-17 20:03:12 +0530 | [diff] [blame] | 3706 | ret = 0; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3707 | if (is_proc_instance_one) |
| 3708 | break; |
| 3709 | } |
| 3710 | } |
| 3711 | |
| 3712 | closedir(dir); |
| 3713 | |
Pradeep Reddy Potteti | d068e64 | 2017-02-17 20:03:12 +0530 | [diff] [blame] | 3714 | return ret; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3715 | #else /* __linux__ */ |
| 3716 | return -1; |
| 3717 | #endif /* __linux__ */ |
| 3718 | } |
| 3719 | |
| 3720 | |
| 3721 | static int run_ndc(struct sigma_dut *dut, char *buf) |
| 3722 | { |
| 3723 | sigma_dut_print(dut, DUT_MSG_INFO, "CMD NDC:: %s", buf); |
| 3724 | sleep(2); |
| 3725 | return run_system(dut, buf); |
| 3726 | } |
| 3727 | |
| 3728 | |
| 3729 | static int sigma_write_cfg(struct sigma_dut *dut, const char *pfile, |
| 3730 | const char *field, const char *value) |
| 3731 | { |
| 3732 | FILE *fcfg, *ftmp; |
| 3733 | char buf[MAX_CONF_LINE_LEN + 1]; |
| 3734 | int len, found = 0, res; |
| 3735 | |
| 3736 | /* Open the configuration file */ |
| 3737 | fcfg = fopen(pfile, "r"); |
| 3738 | if (!fcfg) { |
| 3739 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 3740 | "Failed to open hostapd conf file"); |
| 3741 | return -1; |
| 3742 | } |
| 3743 | |
| 3744 | snprintf(buf, sizeof(buf), "%s~", pfile); |
| 3745 | /* Open a temporary file */ |
| 3746 | ftmp = fopen(buf, "w+"); |
| 3747 | if (!ftmp) { |
| 3748 | fclose(fcfg); |
| 3749 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 3750 | "Failed to open temp buf"); |
| 3751 | return -1; |
| 3752 | } |
| 3753 | |
| 3754 | /* Read the values from the configuration file */ |
| 3755 | len = strlen(field); |
| 3756 | while (fgets(buf, MAX_CONF_LINE_LEN, fcfg)) { |
| 3757 | char *pline = buf; |
| 3758 | |
| 3759 | /* commented line */ |
| 3760 | if (buf[0] == '#') |
| 3761 | pline++; |
| 3762 | |
| 3763 | /* Identify the configuration parameter to be updated */ |
| 3764 | if (!found && strncmp(pline, field, len) == 0 && |
| 3765 | pline[len] == '=') { |
| 3766 | snprintf(buf, sizeof(buf), "%s=%s\n", field, value); |
| 3767 | found = 1; |
| 3768 | sigma_dut_print(dut, DUT_MSG_INFO, |
| 3769 | "Updated hostapd conf file"); |
| 3770 | } |
| 3771 | |
| 3772 | fprintf(ftmp, "%s", buf); |
| 3773 | } |
| 3774 | |
| 3775 | if (!found) { |
| 3776 | /* Configuration line not found */ |
| 3777 | /* Add the new line at the end of file */ |
| 3778 | fprintf(ftmp, "%s=%s\n", field, value); |
| 3779 | sigma_dut_print(dut, DUT_MSG_INFO, |
| 3780 | "Adding a new line in hostapd conf file"); |
| 3781 | } |
| 3782 | |
| 3783 | fclose(fcfg); |
| 3784 | fclose(ftmp); |
| 3785 | |
| 3786 | snprintf(buf, sizeof(buf), "%s~", pfile); |
| 3787 | |
| 3788 | /* Restore the updated configuration file */ |
| 3789 | res = rename(buf, pfile); |
| 3790 | |
| 3791 | /* Remove the temporary file. Ignore the return value */ |
| 3792 | unlink(buf); |
| 3793 | |
| 3794 | /* chmod is needed because open() may not set permissions properly |
| 3795 | * depending on the current umask */ |
| 3796 | if (chmod(pfile, 0660) < 0) { |
| 3797 | unlink(pfile); |
| 3798 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 3799 | "Error changing permissions"); |
| 3800 | return -1; |
| 3801 | } |
| 3802 | |
| 3803 | if (res < 0) { |
| 3804 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 3805 | "Error restoring conf file"); |
| 3806 | return -1; |
| 3807 | } |
| 3808 | |
| 3809 | return 0; |
| 3810 | } |
| 3811 | |
| 3812 | |
| 3813 | static int cmd_wcn_ap_config_commit(struct sigma_dut *dut, |
| 3814 | struct sigma_conn *conn, |
| 3815 | struct sigma_cmd *cmd) |
| 3816 | { |
| 3817 | char buf[100]; |
| 3818 | struct stat s; |
| 3819 | int num_tries = 0, ret; |
| 3820 | |
Pradeep Reddy Potteti | d068e64 | 2017-02-17 20:03:12 +0530 | [diff] [blame] | 3821 | if (kill_process(dut, "(netd)", 1, SIGKILL) == 0 || |
| 3822 | system("killall netd") == 0) { |
| 3823 | /* Avoid Error: Error connecting (Connection refused) |
| 3824 | * Wait some time to allow netd to reinitialize. |
| 3825 | */ |
| 3826 | usleep(1500000); |
| 3827 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3828 | |
| 3829 | while (num_tries < 10) { |
| 3830 | ret = run_ndc(dut, "ndc softap stopap"); |
| 3831 | num_tries++; |
| 3832 | if (WIFEXITED(ret)) |
| 3833 | ret = WEXITSTATUS(ret); |
| 3834 | /* On success, NDC exits with 0 */ |
| 3835 | if (ret == 0) |
| 3836 | break; |
| 3837 | sigma_dut_print(dut, DUT_MSG_INFO, |
| 3838 | "Try No. %d: ndc softap stopap failed, exit code %d", |
| 3839 | num_tries, ret); |
| 3840 | } |
| 3841 | |
| 3842 | if (ret != 0) |
| 3843 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 3844 | "ndc softap stopap command failed for 10 times - giving up"); |
| 3845 | |
| 3846 | #ifdef ANDROID |
| 3847 | /* Unload/Load driver to cleanup the state of the driver */ |
Ajit Vaishya | 14d1f9a | 2017-09-04 23:24:25 +0530 | [diff] [blame] | 3848 | system("rmmod -f wlan"); |
| 3849 | usleep(500000); |
| 3850 | system("insmod /system/lib/modules/wlan.ko"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3851 | #else /* ANDROID */ |
| 3852 | run_ndc(dut, "ndc softap qccmd set enable_softap=0"); |
| 3853 | run_ndc(dut, "ndc softap qccmd set enable_softap=1"); |
| 3854 | #endif /* ANDROID */ |
| 3855 | |
| 3856 | switch (dut->ap_mode) { |
| 3857 | case AP_11g: |
| 3858 | run_ndc(dut, "ndc softap qccmd set hw_mode=g-only"); |
| 3859 | break; |
| 3860 | case AP_11b: |
| 3861 | run_ndc(dut, "ndc softap qccmd set hw_mode=b-only"); |
| 3862 | break; |
| 3863 | case AP_11ng: |
| 3864 | run_ndc(dut, "ndc softap qccmd set hw_mode=n"); |
| 3865 | break; |
| 3866 | case AP_11a: |
| 3867 | run_ndc(dut, "ndc softap qccmd set hw_mode=a-only"); |
| 3868 | break; |
| 3869 | case AP_11na: |
| 3870 | run_ndc(dut, "ndc softap qccmd set hw_mode=n"); |
| 3871 | break; |
| 3872 | case AP_11ac: |
| 3873 | run_ndc(dut, "ndc softap qccmd set hw_mode=ac"); |
| 3874 | break; |
| 3875 | default: |
| 3876 | break; |
| 3877 | } |
| 3878 | |
| 3879 | snprintf(buf, sizeof(buf), "ndc softap qccmd set channel=%d", |
| 3880 | dut->ap_channel); |
| 3881 | run_ndc(dut, buf); |
| 3882 | |
| 3883 | /* |
| 3884 | * ndc doesn't support double quotes as SSID string, so re-write |
| 3885 | * hostapd configuration file to update SSID. |
| 3886 | */ |
| 3887 | if (dut->ap_ssid[0] != '\0') |
| 3888 | sigma_write_cfg(dut, ANDROID_CONFIG_FILE, "ssid", dut->ap_ssid); |
| 3889 | |
| 3890 | switch (dut->ap_key_mgmt) { |
| 3891 | case AP_OPEN: |
| 3892 | if (dut->ap_cipher == AP_WEP) { |
| 3893 | run_ndc(dut, "ndc softap qccmd set security_mode=1"); |
| 3894 | snprintf(buf, sizeof(buf), |
| 3895 | "ndc softap qccmd set wep_key0=%s", |
| 3896 | dut->ap_wepkey); |
| 3897 | run_ndc(dut, buf); |
| 3898 | } else { |
| 3899 | run_ndc(dut, "ndc softap qccmd set security_mode=0"); |
| 3900 | } |
| 3901 | break; |
| 3902 | case AP_WPA2_PSK: |
| 3903 | case AP_WPA2_PSK_MIXED: |
| 3904 | case AP_WPA_PSK: |
| 3905 | if (dut->ap_key_mgmt == AP_WPA2_PSK) |
| 3906 | run_ndc(dut, "ndc softap qccmd set security_mode=3"); |
| 3907 | else if (dut->ap_key_mgmt == AP_WPA2_PSK_MIXED) |
| 3908 | run_ndc(dut, "ndc softap qccmd set security_mode=4"); |
| 3909 | else |
| 3910 | run_ndc(dut, "ndc softap qccmd set security_mode=2"); |
| 3911 | |
| 3912 | /* |
| 3913 | * ndc doesn't support some special characters as passphrase, |
| 3914 | * so re-write hostapd configuration file to update Passphrase. |
| 3915 | */ |
| 3916 | if (dut->ap_passphrase[0] != '\0') |
| 3917 | sigma_write_cfg(dut, ANDROID_CONFIG_FILE, |
| 3918 | "wpa_passphrase", dut->ap_passphrase); |
| 3919 | |
| 3920 | if (dut->ap_cipher == AP_CCMP_TKIP) |
| 3921 | run_ndc(dut, "ndc softap qccmd set wpa_pairwise=" |
| 3922 | "TKIP CCMP"); |
| 3923 | else if (dut->ap_cipher == AP_TKIP) |
| 3924 | run_ndc(dut, "ndc softap qccmd set wpa_pairwise=" |
| 3925 | "TKIP"); |
| 3926 | else |
| 3927 | run_ndc(dut, "ndc softap qccmd set wpa_pairwise=" |
| 3928 | "CCMP &"); |
| 3929 | break; |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 3930 | case AP_WPA2_SAE: |
| 3931 | case AP_WPA2_PSK_SAE: |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3932 | case AP_WPA2_EAP: |
| 3933 | case AP_WPA2_EAP_MIXED: |
| 3934 | case AP_WPA_EAP: |
Jouni Malinen | ad395a2 | 2017-09-01 21:13:46 +0300 | [diff] [blame] | 3935 | case AP_SUITEB: |
Jouni Malinen | 147b3c3 | 2017-10-09 16:51:54 +0300 | [diff] [blame] | 3936 | case AP_WPA2_OWE: |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3937 | /* Not supported */ |
| 3938 | break; |
| 3939 | } |
| 3940 | |
| 3941 | switch (dut->ap_pmf) { |
| 3942 | case AP_PMF_DISABLED: |
| 3943 | run_ndc(dut, "ndc softap qccmd set ieee80211w=0"); |
| 3944 | break; |
| 3945 | case AP_PMF_OPTIONAL: |
| 3946 | run_ndc(dut, "ndc softap qccmd set ieee80211w=1"); |
| 3947 | if (dut->ap_add_sha256) |
| 3948 | run_ndc(dut, "ndc softap qccmd set wpa_key_mgmt=WPA-PSK WPA-PSK-SHA256"); |
| 3949 | else |
| 3950 | run_ndc(dut, "ndc softap qccmd set wpa_key_mgmt=WPA-PSK"); |
| 3951 | break; |
| 3952 | case AP_PMF_REQUIRED: |
| 3953 | run_ndc(dut, "ndc softap qccmd set ieee80211w=2"); |
| 3954 | run_ndc(dut, "ndc softap qccmd set wpa_key_mgmt=WPA-PSK-SHA256"); |
| 3955 | break; |
| 3956 | } |
| 3957 | |
| 3958 | if (dut->ap_countrycode[0]) { |
| 3959 | snprintf(buf, sizeof(buf), |
| 3960 | "ndc softap qccmd set country_code=%s", |
| 3961 | dut->ap_countrycode); |
| 3962 | run_ndc(dut, buf); |
| 3963 | } |
| 3964 | |
Pradeep Reddy POTTETI | fba27db | 2015-11-20 16:42:22 +0530 | [diff] [blame] | 3965 | if (dut->ap_regulatory_mode == AP_80211D_MODE_ENABLED) |
| 3966 | run_ndc(dut, "ndc softap qccmd set ieee80211d=1"); |
| 3967 | |
| 3968 | if (dut->ap_dfs_mode == AP_DFS_MODE_ENABLED) |
| 3969 | run_ndc(dut, "ndc softap qccmd set ieee80211h=1"); |
| 3970 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3971 | run_ndc(dut, "ndc softap startap"); |
| 3972 | |
| 3973 | snprintf(buf, sizeof(buf), "%s%s", sigma_wpas_ctrl, sigma_main_ifname); |
| 3974 | num_tries = 0; |
| 3975 | while (num_tries < 10 && (ret = stat(buf, &s) != 0)) { |
| 3976 | run_ndc(dut, "ndc softap stopap"); |
| 3977 | run_ndc(dut, "ndc softap startap"); |
| 3978 | num_tries++; |
| 3979 | } |
| 3980 | |
| 3981 | if (num_tries == 10) { |
| 3982 | sigma_dut_print(dut, DUT_MSG_INFO, "Tried 10 times with ctrl " |
| 3983 | "iface %s :: reboot the APDUT", buf); |
| 3984 | return ret; |
| 3985 | } |
| 3986 | |
| 3987 | sigma_dut_print(dut, DUT_MSG_INFO, "setting ip addr %s mask %s", |
| 3988 | ap_inet_addr, ap_inet_mask); |
| 3989 | snprintf(buf, sizeof(buf), "ifconfig %s %s netmask %s up", |
| 3990 | sigma_main_ifname, ap_inet_addr, ap_inet_mask); |
| 3991 | if (system(buf) != 0) { |
| 3992 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 3993 | "Failed to intialize the interface"); |
| 3994 | return -1; |
| 3995 | } |
| 3996 | |
| 3997 | return 1; |
| 3998 | } |
| 3999 | |
| 4000 | |
| 4001 | static int append_hostapd_conf_hs2(struct sigma_dut *dut, FILE *f) |
| 4002 | { |
| 4003 | fprintf(f, "hs20=1\nhs20_deauth_req_timeout=3\n" |
| 4004 | "disable_dgaf=%d\n", dut->ap_dgaf_disable); |
| 4005 | |
| 4006 | if (dut->ap_oper_name) { |
| 4007 | fprintf(f, "hs20_oper_friendly_name=eng:Wi-Fi Alliance\n"); |
| 4008 | fprintf(f, "hs20_oper_friendly_name=chi:Wi-Fi\xe8\x81\x94\xe7\x9b\x9f\n"); |
| 4009 | } |
| 4010 | |
| 4011 | if (dut->ap_wan_metrics == 1) |
| 4012 | fprintf(f, "hs20_wan_metrics=01:2500:384:0:0:10\n"); |
| 4013 | else if (dut->ap_wan_metrics == 2) |
| 4014 | fprintf(f, "hs20_wan_metrics=01:1500:384:20:20:10\n"); |
| 4015 | else if (dut->ap_wan_metrics == 3) |
| 4016 | fprintf(f, "hs20_wan_metrics=01:2000:1000:20:20:10\n"); |
| 4017 | else if (dut->ap_wan_metrics == 4) |
| 4018 | fprintf(f, "hs20_wan_metrics=01:8000:1000:20:20:10\n"); |
| 4019 | else if (dut->ap_wan_metrics == 5) |
| 4020 | fprintf(f, "hs20_wan_metrics=01:9000:5000:20:20:10\n"); |
| 4021 | |
| 4022 | if (dut->ap_conn_capab == 1) { |
| 4023 | fprintf(f, "hs20_conn_capab=1:0:0\n"); |
| 4024 | fprintf(f, "hs20_conn_capab=6:20:1\n"); |
| 4025 | fprintf(f, "hs20_conn_capab=6:22:0\n"); |
| 4026 | fprintf(f, "hs20_conn_capab=6:80:1\n"); |
| 4027 | fprintf(f, "hs20_conn_capab=6:443:1\n"); |
| 4028 | fprintf(f, "hs20_conn_capab=6:1723:0\n"); |
| 4029 | fprintf(f, "hs20_conn_capab=6:5060:0\n"); |
| 4030 | fprintf(f, "hs20_conn_capab=17:500:1\n"); |
| 4031 | fprintf(f, "hs20_conn_capab=17:5060:0\n"); |
| 4032 | fprintf(f, "hs20_conn_capab=17:4500:1\n"); |
| 4033 | fprintf(f, "hs20_conn_capab=50:0:1\n"); |
| 4034 | } else if (dut->ap_conn_capab == 2) { |
| 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=17:5060:1\n"); |
| 4038 | fprintf(f, "hs20_conn_capab=6:5060:1\n"); |
| 4039 | } else if (dut->ap_conn_capab == 3) { |
| 4040 | fprintf(f, "hs20_conn_capab=6:80:1\n"); |
| 4041 | fprintf(f, "hs20_conn_capab=6:443:1\n"); |
| 4042 | } else if (dut->ap_conn_capab == 4) { |
| 4043 | fprintf(f, "hs20_conn_capab=6:80:1\n"); |
| 4044 | fprintf(f, "hs20_conn_capab=6:443:1\n"); |
| 4045 | fprintf(f, "hs20_conn_capab=6:5060:1\n"); |
| 4046 | fprintf(f, "hs20_conn_capab=17:5060:1\n"); |
| 4047 | } |
| 4048 | |
| 4049 | if (dut->ap_oper_class == 1) |
| 4050 | fprintf(f, "hs20_operating_class=51\n"); |
| 4051 | else if (dut->ap_oper_class == 2) |
| 4052 | fprintf(f, "hs20_operating_class=73\n"); |
| 4053 | else if (dut->ap_oper_class == 3) |
| 4054 | fprintf(f, "hs20_operating_class=5173\n"); |
| 4055 | |
| 4056 | if (dut->ap_osu_provider_list) { |
| 4057 | char *osu_friendly_name = NULL; |
| 4058 | char *osu_icon = NULL; |
| 4059 | char *osu_ssid = NULL; |
| 4060 | char *osu_nai = NULL; |
| 4061 | char *osu_service_desc = NULL; |
| 4062 | char *hs20_icon_filename = NULL; |
| 4063 | char hs20_icon[150]; |
| 4064 | int osu_method; |
| 4065 | |
| 4066 | hs20_icon_filename = "icon_red_zxx.png"; |
| 4067 | if (dut->ap_osu_icon_tag == 2) |
| 4068 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 4069 | snprintf(hs20_icon, sizeof(hs20_icon), |
| 4070 | "128:61:zxx:image/png:icon_red_zxx.png:/etc/ath/%s", |
| 4071 | hs20_icon_filename); |
| 4072 | osu_icon = "icon_red_zxx.png"; |
| 4073 | osu_ssid = "OSU"; |
| 4074 | osu_friendly_name = "kor:SP 빨강 테스트 전용"; |
| 4075 | osu_service_desc = "kor:테스트 목적으로 무료 서비스"; |
| 4076 | osu_method = (dut->ap_osu_method[0] == 0xFF) ? 1 : dut->ap_osu_method[0]; |
| 4077 | |
| 4078 | if (strlen(dut->ap_osu_server_uri[0])) |
| 4079 | fprintf(f, "osu_server_uri=%s\n", dut->ap_osu_server_uri[0]); |
| 4080 | else |
| 4081 | fprintf(f, "osu_server_uri=https://osu-server.r2-testbed.wi-fi.org/\n"); |
| 4082 | |
| 4083 | switch (dut->ap_osu_provider_list) { |
| 4084 | case 1: |
| 4085 | case 101: |
| 4086 | fprintf(f, "osu_friendly_name=eng:SP Red Test Only\n"); |
| 4087 | fprintf(f, "osu_service_desc=eng:Free service for test purpose\n"); |
| 4088 | hs20_icon_filename = "icon_red_eng.png"; |
| 4089 | if (dut->ap_osu_icon_tag == 2) |
| 4090 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 4091 | fprintf(f, "hs20_icon=160:76:eng:image/png:icon_red_eng.png:/etc/ath/%s\n", |
| 4092 | hs20_icon_filename); |
| 4093 | fprintf(f, "osu_icon=icon_red_eng.png\n"); |
| 4094 | break; |
| 4095 | case 2: |
| 4096 | case 102: |
| 4097 | fprintf(f, "osu_friendly_name=eng:Wireless Broadband Alliance\n"); |
| 4098 | fprintf(f, "osu_service_desc=eng:Free service for test purpose\n"); |
| 4099 | hs20_icon_filename = "icon_orange_zxx.png"; |
| 4100 | if (dut->ap_osu_icon_tag == 2) |
| 4101 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 4102 | snprintf(hs20_icon, sizeof(hs20_icon), |
| 4103 | "128:61:zxx:image/png:icon_orange_zxx.png:/etc/ath/%s", |
| 4104 | hs20_icon_filename); |
| 4105 | osu_icon = "icon_orange_zxx.png"; |
| 4106 | osu_friendly_name = "kor:와이어리스 브로드밴드 얼라이언스"; |
| 4107 | break; |
| 4108 | case 3: |
| 4109 | case 103: |
| 4110 | osu_friendly_name = "spa:SP Red Test Only"; |
| 4111 | osu_service_desc = "spa:Free service for test purpose"; |
| 4112 | break; |
| 4113 | case 4: |
| 4114 | case 104: |
| 4115 | fprintf(f, "osu_friendly_name=eng:SP Orange Test Only\n"); |
| 4116 | fprintf(f, "osu_service_desc=eng:Free service for test purpose\n"); |
| 4117 | hs20_icon_filename = "icon_orange_eng.png"; |
| 4118 | if (dut->ap_osu_icon_tag == 2) |
| 4119 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 4120 | fprintf(f, "hs20_icon=160:76:eng:image/png:icon_orange_eng.png:/etc/ath/%s\n", |
| 4121 | hs20_icon_filename); |
| 4122 | fprintf(f, "osu_icon=icon_orange_eng.png\n"); |
| 4123 | osu_friendly_name = "kor:SP 오렌지 테스트 전용"; |
| 4124 | |
| 4125 | hs20_icon_filename = "icon_orange_zxx.png"; |
| 4126 | if (dut->ap_osu_icon_tag == 2) |
| 4127 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 4128 | snprintf(hs20_icon, sizeof(hs20_icon), |
| 4129 | "128:61:zxx:image/png:icon_orange_zxx.png:/etc/ath/%s", |
| 4130 | hs20_icon_filename); |
| 4131 | osu_icon = "icon_orange_zxx.png"; |
| 4132 | break; |
| 4133 | case 5: |
| 4134 | case 105: |
| 4135 | fprintf(f, "osu_friendly_name=eng:SP Orange Test Only\n"); |
| 4136 | fprintf(f, "osu_service_desc=eng:Free service for test purpose\n"); |
| 4137 | osu_friendly_name = "kor:SP 오렌지 테스트 전용"; |
| 4138 | hs20_icon_filename = "icon_orange_zxx.png"; |
| 4139 | if (dut->ap_osu_icon_tag == 2) |
| 4140 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 4141 | snprintf(hs20_icon, sizeof(hs20_icon), |
| 4142 | "128:61:zxx:image/png:icon_orange_zxx.png:/etc/ath/%s", |
| 4143 | hs20_icon_filename); |
| 4144 | osu_icon = "icon_orange_zxx.png"; |
| 4145 | break; |
| 4146 | case 6: |
| 4147 | case 106: |
| 4148 | fprintf(f, "osu_friendly_name=eng:SP Green Test Only\n"); |
| 4149 | fprintf(f, "osu_friendly_name=kor:SP 초록 테스트 전용\n"); |
| 4150 | hs20_icon_filename = "icon_green_zxx.png"; |
| 4151 | if (dut->ap_osu_icon_tag == 2) |
| 4152 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 4153 | fprintf(f, "hs20_icon=128:61:zxx:image/png:icon_green_zxx.png:/etc/ath/%s\n", |
| 4154 | hs20_icon_filename); |
| 4155 | fprintf(f, "osu_icon=icon_green_zxx.png\n"); |
| 4156 | osu_method = (dut->ap_osu_method[0] == 0xFF) ? 0 : dut->ap_osu_method[0]; |
| 4157 | fprintf(f, "osu_method_list=%d\n", osu_method); |
| 4158 | |
| 4159 | if (strlen(dut->ap_osu_server_uri[1])) |
| 4160 | fprintf(f, "osu_server_uri=%s\n", dut->ap_osu_server_uri[1]); |
| 4161 | else |
| 4162 | fprintf(f, "osu_server_uri=https://osu-server.r2-testbed.wi-fi.org/\n"); |
| 4163 | fprintf(f, "osu_friendly_name=eng:SP Orange Test Only\n"); |
| 4164 | hs20_icon_filename = "icon_orange_zxx.png"; |
| 4165 | if (dut->ap_osu_icon_tag == 2) |
| 4166 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 4167 | snprintf(hs20_icon, sizeof(hs20_icon), |
| 4168 | "128:61:zxx:image/png:icon_orange_zxx.png:/etc/ath/%s", |
| 4169 | hs20_icon_filename); |
| 4170 | osu_icon = "icon_orange_zxx.png"; |
| 4171 | osu_friendly_name = "kor:SP 오렌지 테스트 전용"; |
| 4172 | osu_method = (dut->ap_osu_method[1] == 0xFF) ? 0 : dut->ap_osu_method[1]; |
| 4173 | osu_service_desc = NULL; |
| 4174 | break; |
| 4175 | case 7: |
| 4176 | case 107: |
| 4177 | fprintf(f, "osu_friendly_name=eng:SP Green Test Only\n"); |
| 4178 | fprintf(f, "osu_service_desc=eng:Free service for test purpose\n"); |
| 4179 | hs20_icon_filename = "icon_green_eng.png"; |
| 4180 | if (dut->ap_osu_icon_tag == 2) |
| 4181 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 4182 | fprintf(f, "hs20_icon=160:76:eng:image/png:icon_green_eng.png:/etc/ath/%s\n", |
| 4183 | hs20_icon_filename); |
| 4184 | fprintf(f, "osu_icon=icon_green_eng.png\n"); |
| 4185 | osu_friendly_name = "kor:SP 초록 테스트 전용"; |
| 4186 | |
| 4187 | hs20_icon_filename = "icon_green_zxx.png"; |
| 4188 | if (dut->ap_osu_icon_tag == 2) |
| 4189 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 4190 | snprintf(hs20_icon, sizeof(hs20_icon), |
| 4191 | "128:61:zxx:image/png:icon_green_zxx.png:/etc/ath/%s", |
| 4192 | hs20_icon_filename); |
| 4193 | osu_icon = "icon_green_zxx.png"; |
| 4194 | break; |
| 4195 | case 8: |
| 4196 | case 108: |
| 4197 | fprintf(f, "osu_friendly_name=eng:SP Red Test Only\n"); |
| 4198 | fprintf(f, "osu_service_desc=eng:Free service for test purpose\n"); |
| 4199 | osu_ssid = "OSU-Encrypted"; |
| 4200 | osu_nai = "anonymous@hotspot.net"; |
| 4201 | break; |
| 4202 | case 9: |
| 4203 | case 109: |
| 4204 | osu_ssid = "OSU-OSEN"; |
| 4205 | osu_nai = "test-anonymous@wi-fi.org"; |
| 4206 | osu_friendly_name = "eng:SP Orange Test Only"; |
| 4207 | hs20_icon_filename = "icon_orange_zxx.png"; |
| 4208 | if (dut->ap_osu_icon_tag == 2) |
| 4209 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 4210 | snprintf(hs20_icon, sizeof(hs20_icon), |
| 4211 | "128:61:zxx:image/png:icon_orange_zxx.png:/etc/ath/%s", |
| 4212 | hs20_icon_filename); |
| 4213 | osu_icon = "icon_orange_zxx.png"; |
| 4214 | osu_method = (dut->ap_osu_method[0] == 0xFF) ? 1 : dut->ap_osu_method[0]; |
| 4215 | osu_service_desc = NULL; |
| 4216 | break; |
| 4217 | default: |
| 4218 | break; |
| 4219 | } |
| 4220 | |
| 4221 | if (strlen(dut->ap_osu_ssid)) { |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 4222 | if (strcmp(dut->ap_tag_ssid[0], dut->ap_osu_ssid) && |
| 4223 | strcmp(dut->ap_tag_ssid[0], osu_ssid)) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4224 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4225 | "OSU_SSID and " |
| 4226 | "WLAN_TAG2 SSID differ"); |
| 4227 | return -2; |
| 4228 | } |
| 4229 | fprintf(f, "osu_ssid=\"%s\"\n", dut->ap_osu_ssid); |
| 4230 | } else |
| 4231 | fprintf(f, "osu_ssid=\"%s\"\n", osu_ssid); |
| 4232 | |
| 4233 | |
| 4234 | if (osu_friendly_name) |
| 4235 | fprintf(f, "osu_friendly_name=%s\n", osu_friendly_name); |
| 4236 | |
| 4237 | if (osu_service_desc) |
| 4238 | fprintf(f, "osu_service_desc=%s\n", osu_service_desc); |
| 4239 | |
| 4240 | if (osu_nai) |
| 4241 | fprintf(f, "osu_nai=%s\n", osu_nai); |
| 4242 | |
| 4243 | fprintf(f, "hs20_icon=%s\n", hs20_icon); |
| 4244 | |
| 4245 | if (osu_icon) |
| 4246 | fprintf(f, "osu_icon=%s\n", osu_icon); |
| 4247 | |
| 4248 | if (dut->ap_osu_provider_list > 100) |
| 4249 | fprintf(f, "osu_method_list=0\n"); |
| 4250 | else |
| 4251 | fprintf(f, "osu_method_list=%d\n", osu_method); |
| 4252 | } |
| 4253 | |
| 4254 | return 0; |
| 4255 | } |
| 4256 | |
| 4257 | |
| 4258 | static void write_ap_roaming_cons(FILE *f, const char *list) |
| 4259 | { |
| 4260 | char *buf, *pos, *end; |
| 4261 | |
| 4262 | if (list == NULL || list[0] == '\0') |
| 4263 | return; |
| 4264 | |
| 4265 | buf = strdup(list); |
| 4266 | if (buf == NULL) |
| 4267 | return; |
| 4268 | |
| 4269 | pos = buf; |
| 4270 | while (pos && *pos) { |
| 4271 | end = strchr(pos, ';'); |
| 4272 | if (end) |
| 4273 | *end++ = '\0'; |
| 4274 | fprintf(f, "roaming_consortium=%s\n", pos); |
| 4275 | pos = end; |
| 4276 | } |
| 4277 | |
| 4278 | free(buf); |
| 4279 | } |
| 4280 | |
| 4281 | |
| 4282 | static int append_hostapd_conf_interworking(struct sigma_dut *dut, FILE *f) |
| 4283 | { |
| 4284 | int i; |
| 4285 | char buf[100], *temp; |
| 4286 | |
| 4287 | if (dut->ap_gas_cb_delay > 0) |
| 4288 | fprintf(f, "gas_comeback_delay=%d\n", |
| 4289 | dut->ap_gas_cb_delay); |
| 4290 | |
| 4291 | fprintf(f, "interworking=1\n" |
| 4292 | "access_network_type=%d\n" |
| 4293 | "internet=%d\n" |
| 4294 | "asra=0\n" |
| 4295 | "esr=0\n" |
| 4296 | "uesa=0\n" |
| 4297 | "venue_group=%d\n" |
| 4298 | "venue_type=%d\n", |
| 4299 | dut->ap_access_net_type, |
| 4300 | dut->ap_internet, |
| 4301 | dut->ap_venue_group, |
| 4302 | dut->ap_venue_type); |
| 4303 | if (dut->ap_hessid[0]) |
| 4304 | fprintf(f, "hessid=%s\n", dut->ap_hessid); |
| 4305 | |
| 4306 | write_ap_roaming_cons(f, dut->ap_roaming_cons); |
| 4307 | |
| 4308 | if (dut->ap_venue_name) { |
| 4309 | fprintf(f, "venue_name=P\"eng:Wi-Fi Alliance\\n2989 Copper Road\\nSanta Clara, CA 95051, USA\"\n"); |
| 4310 | fprintf(f, "venue_name=%s\n", ANQP_VENUE_NAME_1_CHI); |
| 4311 | } |
| 4312 | |
| 4313 | if (dut->ap_net_auth_type == 1) |
| 4314 | fprintf(f, "network_auth_type=00https://tandc-server.wi-fi.org\n"); |
| 4315 | else if (dut->ap_net_auth_type == 2) |
| 4316 | fprintf(f, "network_auth_type=01\n"); |
| 4317 | |
| 4318 | if (dut->ap_nai_realm_list == 1) { |
| 4319 | fprintf(f, "nai_realm=0,mail.example.com;cisco.com;wi-fi.org,21[2:4][5:7]\n"); |
| 4320 | fprintf(f, "nai_realm=0,wi-fi.org;example.com,13[5:6]\n"); |
| 4321 | } else if (dut->ap_nai_realm_list == 2) { |
| 4322 | fprintf(f, "nai_realm=0,wi-fi.org,21[2:4][5:7]\n"); |
| 4323 | } else if (dut->ap_nai_realm_list == 3) { |
| 4324 | fprintf(f, "nai_realm=0,cisco.com;wi-fi.org,21[2:4][5:7]\n"); |
| 4325 | fprintf(f, "nai_realm=0,wi-fi.org;example.com,13[5:6]\n"); |
| 4326 | } else if (dut->ap_nai_realm_list == 4) { |
| 4327 | fprintf(f, "nai_realm=0,mail.example.com,21[2:4][5:7],13[5:6]\n"); |
| 4328 | } else if (dut->ap_nai_realm_list == 5) { |
| 4329 | fprintf(f, "nai_realm=0,wi-fi.org;ruckuswireless.com,21[2:4][5:7]\n"); |
| 4330 | } else if (dut->ap_nai_realm_list == 6) { |
| 4331 | fprintf(f, "nai_realm=0,wi-fi.org;mail.example.com,21[2:4][5:7]\n"); |
| 4332 | } else if (dut->ap_nai_realm_list == 7) { |
| 4333 | fprintf(f, "nai_realm=0,wi-fi.org,13[5:6]\n"); |
| 4334 | fprintf(f, "nai_realm=0,wi-fi.org,21[2:4][5:7]\n"); |
| 4335 | } |
| 4336 | |
| 4337 | if (dut->ap_domain_name_list[0]) { |
| 4338 | fprintf(f, "domain_name=%s\n", |
| 4339 | dut->ap_domain_name_list); |
| 4340 | } |
| 4341 | |
| 4342 | if (dut->ap_ip_addr_type_avail == 1) { |
| 4343 | fprintf(f, "ipaddr_type_availability=0c\n"); |
| 4344 | } |
| 4345 | |
| 4346 | temp = buf; |
| 4347 | for (i = 0; dut->ap_plmn_mcc[i][0] && dut->ap_plmn_mnc[i][0]; |
| 4348 | i++) { |
| 4349 | if (i) |
| 4350 | *temp++ = ';'; |
| 4351 | |
| 4352 | snprintf(temp, |
| 4353 | sizeof(dut->ap_plmn_mcc[i]) + |
| 4354 | sizeof(dut->ap_plmn_mnc[i]) + 1, |
| 4355 | "%s,%s", |
| 4356 | dut->ap_plmn_mcc[i], |
| 4357 | dut->ap_plmn_mnc[i]); |
| 4358 | |
| 4359 | temp += strlen(dut->ap_plmn_mcc[i]) + |
| 4360 | strlen(dut->ap_plmn_mnc[i]) + 1; |
| 4361 | } |
| 4362 | if (i) |
| 4363 | fprintf(f, "anqp_3gpp_cell_net=%s\n", buf); |
| 4364 | |
| 4365 | if (dut->ap_qos_map_set == 1) |
| 4366 | fprintf(f, "qos_map_set=%s\n", QOS_MAP_SET_1); |
| 4367 | else if (dut->ap_qos_map_set == 2) |
| 4368 | fprintf(f, "qos_map_set=%s\n", QOS_MAP_SET_2); |
| 4369 | |
| 4370 | return 0; |
| 4371 | } |
| 4372 | |
| 4373 | |
| 4374 | static int ath_ap_append_hostapd_conf(struct sigma_dut *dut) |
| 4375 | { |
| 4376 | FILE *f; |
| 4377 | |
| 4378 | if (kill_process(dut, "(hostapd)", 1, SIGTERM) == 0 || |
| 4379 | system("killall hostapd") == 0) { |
| 4380 | int i; |
| 4381 | |
| 4382 | /* Wait some time to allow hostapd to complete cleanup before |
| 4383 | * starting a new process */ |
| 4384 | for (i = 0; i < 10; i++) { |
| 4385 | usleep(500000); |
| 4386 | if (system("pidof hostapd") != 0) |
| 4387 | break; |
| 4388 | } |
| 4389 | } |
| 4390 | |
| 4391 | f = fopen("/tmp/secath0", "a"); |
| 4392 | if (f == NULL) |
| 4393 | return -2; |
| 4394 | |
| 4395 | if (dut->ap_hs2 && append_hostapd_conf_hs2(dut, f)) { |
| 4396 | fclose(f); |
| 4397 | return -2; |
| 4398 | } |
| 4399 | |
| 4400 | if (dut->ap_interworking && append_hostapd_conf_interworking(dut, f)) { |
| 4401 | fclose(f); |
| 4402 | return -2; |
| 4403 | } |
| 4404 | |
| 4405 | fflush(f); |
| 4406 | fclose(f); |
| 4407 | return ath_ap_start_hostapd(dut); |
| 4408 | } |
| 4409 | |
| 4410 | |
| 4411 | static int ath_ap_start_hostapd(struct sigma_dut *dut) |
| 4412 | { |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 4413 | if (dut->ap_tag_key_mgmt[0] == AP2_OSEN) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4414 | run_system(dut, "hostapd -B /tmp/secath0 /tmp/secath1 -e /etc/wpa2/entropy"); |
| 4415 | else |
| 4416 | run_system(dut, "hostapd -B /tmp/secath0 -e /etc/wpa2/entropy"); |
| 4417 | |
| 4418 | return 0; |
| 4419 | } |
| 4420 | |
| 4421 | |
| 4422 | #define LE16(a) ((((a) & 0xff) << 8) | (((a) >> 8) & 0xff)) |
| 4423 | |
| 4424 | static int cmd_ath_ap_anqpserver_start(struct sigma_dut *dut) |
| 4425 | { |
| 4426 | FILE *f; |
| 4427 | int nai_realm = 0, domain_name = 0, oper_name = 0, venue_name = 0, |
| 4428 | wan_metrics = 0, conn_cap = 0, ipaddr_avail = 0, cell_net = 0; |
| 4429 | char buf[100]; |
| 4430 | int i; |
| 4431 | |
| 4432 | f = fopen("/root/anqpserver.conf", "w"); |
| 4433 | if (f == NULL) |
| 4434 | return -1; |
| 4435 | |
| 4436 | if (dut->ap_nai_realm_list == 1) { |
| 4437 | nai_realm = 1; |
| 4438 | 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"); |
| 4439 | } else if (dut->ap_nai_realm_list == 2) { |
| 4440 | nai_realm = 1; |
| 4441 | fprintf(f, "dyn_nai_home_realm=encoding=00realm=wi-fi.org;eap_method=0Dauth_id=05auth_val=06\n"); |
| 4442 | } else if (dut->ap_nai_realm_list == 3) { |
| 4443 | nai_realm = 1; |
| 4444 | 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"); |
| 4445 | } else if (dut->ap_nai_realm_list == 4) { |
| 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=mail.example.com;eap_method=0Dauth_id=05auth_val=06\n"); |
| 4448 | } else |
| 4449 | sigma_dut_print(dut, DUT_MSG_INFO, "not setting nai_realm"); |
| 4450 | |
| 4451 | if (dut->ap_domain_name_list[0]) { |
| 4452 | char *next, *start, *dnbuf, *dn1, *anqp_dn; |
| 4453 | int len, dn_len_max; |
| 4454 | dnbuf = strdup(dut->ap_domain_name_list); |
Pradeep Reddy POTTETI | 673d85c | 2016-07-26 19:08:07 +0530 | [diff] [blame] | 4455 | if (dnbuf == NULL) { |
| 4456 | fclose(f); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4457 | return 0; |
Pradeep Reddy POTTETI | 673d85c | 2016-07-26 19:08:07 +0530 | [diff] [blame] | 4458 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4459 | |
| 4460 | len = strlen(dnbuf); |
| 4461 | dn_len_max = 50 + len*2; |
| 4462 | anqp_dn = malloc(dn_len_max); |
| 4463 | if (anqp_dn == NULL) { |
| 4464 | free(dnbuf); |
Pradeep Reddy POTTETI | 673d85c | 2016-07-26 19:08:07 +0530 | [diff] [blame] | 4465 | fclose(f); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4466 | return -1; |
| 4467 | } |
| 4468 | start = dnbuf; |
| 4469 | dn1 = anqp_dn; |
| 4470 | while (start && *start) { |
| 4471 | char *hexstr; |
| 4472 | |
| 4473 | next = strchr(start, ','); |
| 4474 | if (next) |
| 4475 | *next++ = '\0'; |
| 4476 | |
| 4477 | len = strlen(start); |
vamsi krishna | 2e88130 | 2016-05-25 15:02:39 +0530 | [diff] [blame] | 4478 | hexstr = malloc(len * 2 + 1); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4479 | if (hexstr == NULL) { |
| 4480 | free(dnbuf); |
| 4481 | free(anqp_dn); |
Pradeep Reddy POTTETI | 673d85c | 2016-07-26 19:08:07 +0530 | [diff] [blame] | 4482 | fclose(f); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4483 | return -1; |
| 4484 | } |
| 4485 | ascii2hexstr(start, hexstr); |
| 4486 | snprintf(dn1, dn_len_max, "%02x%s", len, hexstr); |
| 4487 | free(hexstr); |
| 4488 | dn1 += 2 + len * 2; |
| 4489 | dn_len_max -= 2 + len * 2; |
| 4490 | start = next; |
| 4491 | } |
| 4492 | free(dnbuf); |
| 4493 | if (dut->ap_gas_cb_delay) { |
| 4494 | fprintf(f, "dyn_domain_name=0c01%04x%s", |
| 4495 | LE16((unsigned int) strlen(anqp_dn)), anqp_dn); |
| 4496 | domain_name = 1; |
| 4497 | } else |
| 4498 | fprintf(f, "domain_name=0c01%04x%s", |
| 4499 | LE16((unsigned int) strlen(anqp_dn)), anqp_dn); |
| 4500 | free(anqp_dn); |
| 4501 | } else |
| 4502 | sigma_dut_print(dut, DUT_MSG_INFO, "not setting domain_name"); |
| 4503 | |
| 4504 | sigma_dut_print(dut, DUT_MSG_INFO, "not setting roaming_consortium"); |
| 4505 | |
| 4506 | if (dut->ap_oper_name) { |
| 4507 | if (dut->ap_gas_cb_delay) { |
| 4508 | fprintf(f, "dyn_oper_friendly_name=" |
| 4509 | ANQP_HS20_OPERATOR_FRIENDLY_NAME_1 "\n"); |
| 4510 | oper_name = 1; |
| 4511 | } else |
| 4512 | fprintf(f, "oper_friendly_name=" |
| 4513 | ANQP_HS20_OPERATOR_FRIENDLY_NAME_1 "\n"); |
| 4514 | } else |
| 4515 | sigma_dut_print(dut, DUT_MSG_INFO, "not setting oper_name"); |
| 4516 | |
| 4517 | if (dut->ap_venue_name) { |
| 4518 | if (dut->ap_gas_cb_delay) { |
| 4519 | fprintf(f, "dyn_venue_name=" ANQP_VENUE_NAME_1 "\n"); |
| 4520 | venue_name = 1; |
| 4521 | } else |
| 4522 | fprintf(f, "venue_name=" ANQP_VENUE_NAME_1 "\n"); |
| 4523 | } else |
| 4524 | sigma_dut_print(dut, DUT_MSG_ERROR, "not setting venue_name"); |
| 4525 | |
| 4526 | if (dut->ap_wan_metrics) { |
| 4527 | if (dut->ap_gas_cb_delay) { |
| 4528 | fprintf(f, "dyn_wan_metrics=" ANQP_HS20_WAN_METRICS_1 "\n"); |
| 4529 | wan_metrics = 1; |
| 4530 | } else |
| 4531 | fprintf(f, "wan_metrics=" ANQP_HS20_WAN_METRICS_1 |
| 4532 | "\n"); |
| 4533 | } else |
| 4534 | sigma_dut_print(dut, DUT_MSG_ERROR, "not setting wan_metrics"); |
| 4535 | |
| 4536 | if (dut->ap_conn_capab) { |
| 4537 | if (dut->ap_gas_cb_delay) { |
| 4538 | fprintf(f, "dyn_conn_capability=" |
| 4539 | ANQP_HS20_CONNECTION_CAPABILITY_1 "\n"); |
| 4540 | conn_cap = 1; |
| 4541 | } else |
| 4542 | fprintf(f, "conn_capability=" |
| 4543 | ANQP_HS20_CONNECTION_CAPABILITY_1 "\n"); |
| 4544 | } else |
| 4545 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4546 | "not setting conn_capability"); |
| 4547 | |
| 4548 | if (dut->ap_ip_addr_type_avail) { |
| 4549 | if (dut->ap_gas_cb_delay) { |
| 4550 | fprintf(f, "dyn_ipaddr_type=" ANQP_IP_ADDR_TYPE_1 |
| 4551 | "\n"); |
| 4552 | ipaddr_avail = 1; |
| 4553 | } else |
| 4554 | fprintf(f, "ipaddr_type=" ANQP_IP_ADDR_TYPE_1 "\n"); |
| 4555 | } else |
| 4556 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4557 | "not setting ipaddr_type_avail"); |
| 4558 | |
| 4559 | for (i = 0; dut->ap_plmn_mcc[i][0] && dut->ap_plmn_mnc[i][0]; i++) { |
| 4560 | snprintf(buf + i * 6, sizeof(buf) - i * 6, "%c%c%c%c%c%c", |
| 4561 | dut->ap_plmn_mcc[i][1], |
| 4562 | dut->ap_plmn_mcc[i][0], |
| 4563 | dut->ap_plmn_mnc[i][2] == '\0' ? |
| 4564 | 'f' : dut->ap_plmn_mnc[i][2], |
| 4565 | dut->ap_plmn_mcc[i][2], |
| 4566 | dut->ap_plmn_mnc[i][1], |
| 4567 | dut->ap_plmn_mnc[i][0]); |
| 4568 | } |
| 4569 | if (i) { |
| 4570 | uint16_t ie_len = (i * 3) + 5; |
| 4571 | if (dut->ap_gas_cb_delay) { |
| 4572 | fprintf(f, "dyn_cell_net=0801"); |
| 4573 | cell_net = 1; |
| 4574 | } else |
| 4575 | fprintf(f, "cell_net=0801"); |
| 4576 | fprintf(f, "%04x", LE16(ie_len)); |
| 4577 | fprintf(f, "00"); /* version */ |
| 4578 | fprintf(f, "%02x", (i * 3) + 3); /* user data hdr length */ |
| 4579 | fprintf(f, "00"); /* plmn list */ |
| 4580 | fprintf(f, "%02x", (i * 3) + 1); /* length of plmn list */ |
| 4581 | fprintf(f, "%02x", i); /* number of plmns */ |
| 4582 | fprintf(f, "%s\n", buf); /* plmns */ |
| 4583 | } else |
| 4584 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4585 | "not setting 3gpp_cellular_network"); |
| 4586 | |
| 4587 | if (nai_realm || domain_name || oper_name || venue_name || |
| 4588 | wan_metrics || conn_cap || ipaddr_avail || cell_net) { |
| 4589 | fprintf(f, "anqp_attach="); |
| 4590 | if (venue_name) |
| 4591 | fprintf(f, "00000104%4.4x", dut->ap_gas_cb_delay); |
| 4592 | if (nai_realm) |
| 4593 | fprintf(f, "00000107%4.4x", dut->ap_gas_cb_delay); |
| 4594 | if (cell_net) |
| 4595 | fprintf(f, "00000108%4.4x", dut->ap_gas_cb_delay); |
| 4596 | if (domain_name) |
| 4597 | fprintf(f, "0000010c%4.4x", dut->ap_gas_cb_delay); |
| 4598 | if (oper_name) |
| 4599 | fprintf(f, "00010003%4.4x", dut->ap_gas_cb_delay); |
| 4600 | if (wan_metrics) |
| 4601 | fprintf(f, "00010004%4.4x", dut->ap_gas_cb_delay); |
| 4602 | if (conn_cap) |
| 4603 | fprintf(f, "00010005%4.4x", dut->ap_gas_cb_delay); |
| 4604 | fprintf(f, "00010006%4.4x", dut->ap_gas_cb_delay); |
| 4605 | fprintf(f, "\n"); |
| 4606 | } |
| 4607 | |
| 4608 | fclose(f); |
| 4609 | |
| 4610 | run_system(dut, "anqpserver -i ath0 &"); |
| 4611 | if (!dut->ap_anqpserver_on) |
| 4612 | run_system(dut, "killall anqpserver"); |
| 4613 | |
| 4614 | return 1; |
| 4615 | } |
| 4616 | |
| 4617 | |
| 4618 | static void cmd_ath_ap_radio_config(struct sigma_dut *dut) |
| 4619 | { |
| 4620 | char buf[100]; |
| 4621 | |
| 4622 | run_system(dut, "cfg -a AP_STARTMODE=standard"); |
| 4623 | |
| 4624 | if (sigma_radio_ifname[0] && |
| 4625 | strcmp(sigma_radio_ifname[0], "wifi1") == 0) { |
| 4626 | run_system(dut, "cfg -a AP_RADIO_ID=1"); |
| 4627 | switch (dut->ap_mode) { |
| 4628 | case AP_11g: |
| 4629 | run_system(dut, "cfg -a AP_CHMODE_2=11G"); |
| 4630 | break; |
| 4631 | case AP_11b: |
| 4632 | run_system(dut, "cfg -a AP_CHMODE_2=11B"); |
| 4633 | break; |
| 4634 | case AP_11ng: |
| 4635 | run_system(dut, "cfg -a AP_CHMODE_2=11NGHT20"); |
| 4636 | break; |
| 4637 | case AP_11a: |
| 4638 | run_system(dut, "cfg -a AP_CHMODE_2=11A"); |
| 4639 | break; |
| 4640 | case AP_11na: |
| 4641 | run_system(dut, "cfg -a AP_CHMODE_2=11NAHT20"); |
| 4642 | break; |
| 4643 | case AP_11ac: |
| 4644 | run_system(dut, "cfg -a AP_CHMODE_2=11ACVHT80"); |
| 4645 | break; |
| 4646 | default: |
| 4647 | run_system(dut, "cfg -a AP_CHMODE_2=11ACVHT80"); |
| 4648 | break; |
| 4649 | } |
| 4650 | |
| 4651 | switch (dut->ap_rx_streams) { |
| 4652 | case 1: |
| 4653 | run_system(dut, "cfg -a RX_CHAINMASK_2=1"); |
| 4654 | break; |
| 4655 | case 2: |
| 4656 | run_system(dut, "cfg -a RX_CHAINMASK_2=3"); |
| 4657 | break; |
| 4658 | case 3: |
| 4659 | run_system(dut, "cfg -a RX_CHAINMASK_2=7"); |
| 4660 | break; |
| 4661 | } |
| 4662 | |
| 4663 | switch (dut->ap_tx_streams) { |
| 4664 | case 1: |
| 4665 | run_system(dut, "cfg -a TX_CHAINMASK_2=1"); |
| 4666 | break; |
| 4667 | case 2: |
| 4668 | run_system(dut, "cfg -a TX_CHAINMASK_2=3"); |
| 4669 | break; |
| 4670 | case 3: |
| 4671 | run_system(dut, "cfg -a TX_CHAINMASK_2=7"); |
| 4672 | break; |
| 4673 | } |
| 4674 | |
| 4675 | switch (dut->ap_chwidth) { |
| 4676 | case AP_20: |
| 4677 | run_system(dut, "cfg -a AP_CHMODE_2=11ACVHT20"); |
| 4678 | break; |
| 4679 | case AP_40: |
| 4680 | run_system(dut, "cfg -a AP_CHMODE_2=11ACVHT40"); |
| 4681 | break; |
| 4682 | case AP_80: |
| 4683 | run_system(dut, "cfg -a AP_CHMODE_2=11ACVHT80"); |
| 4684 | break; |
| 4685 | case AP_160: |
| 4686 | case AP_AUTO: |
| 4687 | default: |
| 4688 | run_system(dut, "cfg -a AP_CHMODE_2=11ACVHT80"); |
| 4689 | break; |
| 4690 | } |
| 4691 | |
| 4692 | if (dut->ap_tx_stbc) { |
| 4693 | run_system(dut, "cfg -a TX_STBC_2=1"); |
| 4694 | } |
| 4695 | |
| 4696 | snprintf(buf, sizeof(buf), "cfg -a AP_PRIMARY_CH_2=%d", |
| 4697 | dut->ap_channel); |
| 4698 | |
| 4699 | if (dut->ap_is_dual) { |
| 4700 | switch (dut->ap_mode_1) { |
| 4701 | case AP_11g: |
| 4702 | run_system(dut, "cfg -a AP_CHMODE=11G"); |
| 4703 | break; |
| 4704 | case AP_11b: |
| 4705 | run_system(dut, "cfg -a AP_CHMODE=11B"); |
| 4706 | break; |
| 4707 | case AP_11ng: |
| 4708 | run_system(dut, "cfg -a AP_CHMODE=11NGHT20"); |
| 4709 | break; |
| 4710 | case AP_11a: |
| 4711 | run_system(dut, "cfg -a AP_CHMODE=11A"); |
| 4712 | break; |
| 4713 | case AP_11na: |
| 4714 | run_system(dut, "cfg -a AP_CHMODE=11NAHT20"); |
| 4715 | break; |
| 4716 | case AP_11ac: |
| 4717 | run_system(dut, "cfg -a AP_CHMODE=11ACVHT80"); |
| 4718 | break; |
| 4719 | default: |
| 4720 | run_system(dut, "cfg -a AP_CHMODE=11NGHT20"); |
| 4721 | break; |
| 4722 | } |
| 4723 | snprintf(buf, sizeof(buf), "cfg -a AP_PRIMARY_CH=%d", |
| 4724 | dut->ap_channel_1); |
| 4725 | } |
| 4726 | run_system(dut, buf); |
| 4727 | } else { |
| 4728 | run_system(dut, "cfg -a AP_RADIO_ID=0"); |
| 4729 | switch (dut->ap_mode) { |
| 4730 | case AP_11g: |
| 4731 | run_system(dut, "cfg -a AP_CHMODE=11G"); |
| 4732 | break; |
| 4733 | case AP_11b: |
| 4734 | run_system(dut, "cfg -a AP_CHMODE=11B"); |
| 4735 | break; |
| 4736 | case AP_11ng: |
| 4737 | run_system(dut, "cfg -a AP_CHMODE=11NGHT20"); |
| 4738 | break; |
| 4739 | case AP_11a: |
| 4740 | run_system(dut, "cfg -a AP_CHMODE=11A"); |
| 4741 | break; |
| 4742 | case AP_11na: |
| 4743 | run_system(dut, "cfg -a AP_CHMODE=11NAHT20"); |
| 4744 | break; |
| 4745 | case AP_11ac: |
| 4746 | run_system(dut, "cfg -a AP_CHMODE=11ACVHT80"); |
| 4747 | break; |
| 4748 | default: |
| 4749 | run_system(dut, "cfg -a AP_CHMODE=11NGHT20"); |
| 4750 | break; |
| 4751 | } |
| 4752 | snprintf(buf, sizeof(buf), "cfg -a AP_PRIMARY_CH=%d", |
| 4753 | dut->ap_channel); |
| 4754 | run_system(dut, buf); |
| 4755 | } |
| 4756 | |
| 4757 | if (dut->ap_sgi80 == 1) { |
| 4758 | run_system(dut, "cfg -a SHORTGI=1"); |
| 4759 | run_system(dut, "cfg -a SHORTGI_2=1"); |
| 4760 | } else if (dut->ap_sgi80 == 0) { |
| 4761 | run_system(dut, "cfg -a SHORTGI=0"); |
| 4762 | run_system(dut, "cfg -a SHORTGI_2=0"); |
| 4763 | } |
| 4764 | |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 4765 | if (dut->ap_ldpc == VALUE_ENABLED) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4766 | run_system(dut, "cfg -a LDPC=1"); |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 4767 | else if (dut->ap_ldpc == VALUE_DISABLED) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4768 | run_system(dut, "cfg -a LDPC=0"); |
| 4769 | } |
| 4770 | |
| 4771 | |
| 4772 | void ath_disable_txbf(struct sigma_dut *dut, const char *intf) |
| 4773 | { |
| 4774 | char buf[50]; |
| 4775 | |
| 4776 | snprintf(buf, sizeof(buf), "iwpriv %s vhtsubfee 0", intf); |
| 4777 | if (system(buf) != 0) |
| 4778 | sigma_dut_print(dut, DUT_MSG_ERROR, "iwpriv vhtsubfee failed"); |
| 4779 | |
| 4780 | snprintf(buf, sizeof(buf), "iwpriv %s vhtsubfer 0", intf); |
| 4781 | if (system(buf) != 0) |
| 4782 | sigma_dut_print(dut, DUT_MSG_ERROR, "iwpriv vhtsubfer failed"); |
| 4783 | |
| 4784 | snprintf(buf, sizeof(buf), "iwpriv %s vhtmubfee 0", intf); |
| 4785 | if (system(buf) != 0) |
| 4786 | sigma_dut_print(dut, DUT_MSG_ERROR, "iwpriv vhtmubfee failed"); |
| 4787 | |
| 4788 | snprintf(buf, sizeof(buf), "iwpriv %s vhtmubfer 0", intf); |
| 4789 | if (system(buf) != 0) |
| 4790 | sigma_dut_print(dut, DUT_MSG_ERROR, "iwpriv vhtmubfer failed"); |
| 4791 | } |
| 4792 | |
| 4793 | |
Adil Saeed Musthafa | 05ec744 | 2017-04-10 23:13:35 -0700 | [diff] [blame] | 4794 | static void ath_set_assoc_disallow(struct sigma_dut *dut, const char *ifname, |
| 4795 | const char *val) |
| 4796 | { |
| 4797 | if (strcasecmp(val, "enable") == 0) { |
| 4798 | run_system_wrapper(dut, "iwpriv %s mbo_asoc_dis 1", ifname); |
| 4799 | } else if (strcasecmp(val, "disable") == 0) { |
| 4800 | run_system_wrapper(dut, "iwpriv %s mbo_asoc_dis 0", ifname); |
| 4801 | } else { |
| 4802 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4803 | "Unsupported assoc_disallow"); |
| 4804 | } |
| 4805 | } |
| 4806 | |
| 4807 | |
Adil Saeed Musthafa | 6906372 | 2017-04-10 23:13:40 -0700 | [diff] [blame] | 4808 | static void apply_mbo_pref_ap_list(struct sigma_dut *dut) |
| 4809 | { |
| 4810 | int i; |
| 4811 | int least_pref = 1 << 8; |
| 4812 | char ifname[20]; |
| 4813 | uint8_t self_mac[ETH_ALEN]; |
| 4814 | char buf[200]; |
| 4815 | int ap_ne_class, ap_ne_pref, ap_ne_op_ch; |
| 4816 | |
| 4817 | get_if_name(dut, ifname, sizeof(ifname), 1); |
| 4818 | get_hwaddr(ifname, self_mac); |
| 4819 | |
| 4820 | /* Clear off */ |
| 4821 | snprintf(buf, sizeof(buf), |
| 4822 | "wifitool %s setbssidpref 00:00:00:00:00:00 0 0 0", |
| 4823 | ifname); |
| 4824 | run_system(dut, buf); |
| 4825 | |
| 4826 | /* Find the least preference number */ |
| 4827 | for (i = 0; i < dut->mbo_pref_ap_cnt; i++) { |
| 4828 | unsigned char *mac_addr = dut->mbo_pref_aps[i].mac_addr; |
| 4829 | |
| 4830 | ap_ne_class = 1; |
| 4831 | ap_ne_pref = 255; |
| 4832 | ap_ne_op_ch = 1; |
| 4833 | if (dut->mbo_pref_aps[i].ap_ne_pref != -1) |
| 4834 | ap_ne_pref = dut->mbo_pref_aps[i].ap_ne_pref; |
| 4835 | if (dut->mbo_pref_aps[i].ap_ne_class != -1) |
| 4836 | ap_ne_class = dut->mbo_pref_aps[i].ap_ne_class; |
| 4837 | if (dut->mbo_pref_aps[i].ap_ne_op_ch != -1) |
| 4838 | ap_ne_op_ch = dut->mbo_pref_aps[i].ap_ne_op_ch; |
| 4839 | |
| 4840 | if (ap_ne_pref < least_pref) |
| 4841 | least_pref = ap_ne_pref; |
| 4842 | snprintf(buf, sizeof(buf), |
| 4843 | "wifitool %s setbssidpref %02x:%02x:%02x:%02x:%02x:%02x %d %d %d", |
| 4844 | ifname, mac_addr[0], mac_addr[1], mac_addr[2], |
| 4845 | mac_addr[3], mac_addr[4], mac_addr[5], |
| 4846 | ap_ne_pref, ap_ne_class, ap_ne_op_ch); |
| 4847 | run_system(dut, buf); |
| 4848 | } |
| 4849 | |
| 4850 | /* Now add the self AP Address */ |
| 4851 | if (dut->mbo_self_ap_tuple.ap_ne_class == -1) { |
| 4852 | if (dut->ap_channel <= 11) |
| 4853 | ap_ne_class = 81; |
| 4854 | else |
| 4855 | ap_ne_class = 115; |
| 4856 | } else { |
| 4857 | ap_ne_class = dut->mbo_self_ap_tuple.ap_ne_class; |
| 4858 | } |
| 4859 | |
| 4860 | if (dut->mbo_self_ap_tuple.ap_ne_op_ch == -1) |
| 4861 | ap_ne_op_ch = dut->ap_channel; |
| 4862 | else |
| 4863 | ap_ne_op_ch = dut->mbo_self_ap_tuple.ap_ne_op_ch; |
| 4864 | |
| 4865 | if (dut->mbo_self_ap_tuple.ap_ne_pref == -1) |
| 4866 | ap_ne_pref = least_pref - 1; |
| 4867 | else |
| 4868 | ap_ne_pref = dut->mbo_self_ap_tuple.ap_ne_pref; |
| 4869 | |
| 4870 | snprintf(buf, sizeof(buf), |
| 4871 | "wifitool %s setbssidpref %02x:%02x:%02x:%02x:%02x:%02x %d %d %d", |
| 4872 | ifname, self_mac[0], self_mac[1], self_mac[2], |
| 4873 | self_mac[3], self_mac[4], self_mac[5], |
| 4874 | ap_ne_pref, |
| 4875 | ap_ne_class, |
| 4876 | ap_ne_op_ch); |
| 4877 | run_system(dut, buf); |
| 4878 | } |
| 4879 | |
| 4880 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4881 | static void ath_ap_set_params(struct sigma_dut *dut) |
| 4882 | { |
priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 4883 | const char *basedev = "wifi0"; |
| 4884 | const char *basedev_radio = "wifi1"; |
| 4885 | char *ifname = get_main_ifname(); |
| 4886 | char *ifname_dual; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4887 | int i; |
priyadharshini gowthaman | 8e26ff4 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 4888 | char buf[300]; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4889 | |
priyadharshini gowthaman | e161746 | 2017-04-25 12:03:59 -0700 | [diff] [blame] | 4890 | if (sigma_radio_ifname[0]) |
| 4891 | basedev = sigma_radio_ifname[0]; |
| 4892 | |
priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 4893 | if (dut->ap_is_dual == 1) { |
| 4894 | basedev = sigma_radio_ifname[0]; |
| 4895 | basedev_radio = sigma_radio_ifname[1]; |
| 4896 | if (sigma_radio_ifname[0] && |
| 4897 | strcmp(sigma_radio_ifname[0], "wifi0") == 0) { |
| 4898 | ifname = "ath0"; |
| 4899 | ifname_dual = "ath1"; |
| 4900 | } else { |
| 4901 | ifname = "ath1"; |
| 4902 | ifname_dual = "ath0"; |
| 4903 | } |
| 4904 | } |
| 4905 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4906 | if (dut->ap_countrycode[0]) { |
| 4907 | snprintf(buf, sizeof(buf), "iwpriv %s setCountry %s", |
| 4908 | basedev, dut->ap_countrycode); |
| 4909 | if (system(buf) != 0) { |
| 4910 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4911 | "iwpriv setCountry failed"); |
| 4912 | } |
| 4913 | sigma_dut_print(dut, DUT_MSG_INFO, "Set countrycode"); |
| 4914 | } |
| 4915 | |
| 4916 | for (i = 0; i < NUM_AP_AC; i++) { |
| 4917 | if (dut->ap_qos[i].ac) { |
| 4918 | snprintf(buf, sizeof(buf), "iwpriv %s cwmin %d 0 %d", |
| 4919 | ifname, i, dut->ap_qos[i].cwmin); |
| 4920 | if (system(buf) != 0) { |
| 4921 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4922 | "iwpriv cwmin failed"); |
| 4923 | } |
| 4924 | |
| 4925 | snprintf(buf, sizeof(buf), "iwpriv %s cwmax %d 0 %d", |
| 4926 | ifname, i, dut->ap_qos[i].cwmax); |
| 4927 | if (system(buf) != 0) { |
| 4928 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4929 | "iwpriv cwmax failed"); |
| 4930 | } |
| 4931 | |
| 4932 | snprintf(buf, sizeof(buf), "iwpriv %s aifs %d 0 %d", |
| 4933 | ifname, i, dut->ap_qos[i].aifs); |
| 4934 | if (system(buf) != 0) { |
| 4935 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4936 | "iwpriv aifs failed"); |
| 4937 | } |
| 4938 | |
| 4939 | snprintf(buf, sizeof(buf), |
| 4940 | "iwpriv %s txoplimit %d 0 %d", |
| 4941 | ifname, i, dut->ap_qos[i].txop); |
| 4942 | if (system(buf) != 0) { |
| 4943 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4944 | "iwpriv txoplimit failed"); |
| 4945 | } |
| 4946 | |
| 4947 | snprintf(buf, sizeof(buf), "iwpriv %s acm %d 0 %d", |
| 4948 | ifname, i, dut->ap_qos[i].acm); |
| 4949 | if (system(buf) != 0) { |
| 4950 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4951 | "iwpriv acm failed"); |
| 4952 | } |
| 4953 | } |
| 4954 | } |
| 4955 | |
| 4956 | for (i = 0; i < NUM_AP_AC; i++) { |
| 4957 | if (dut->ap_sta_qos[i].ac) { |
| 4958 | snprintf(buf, sizeof(buf), "iwpriv %s cwmin %d 1 %d", |
| 4959 | ifname, i, dut->ap_sta_qos[i].cwmin); |
| 4960 | if (system(buf) != 0) { |
| 4961 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4962 | "iwpriv cwmin failed"); |
| 4963 | } |
| 4964 | |
| 4965 | snprintf(buf, sizeof(buf), "iwpriv %s cwmax %d 1 %d", |
| 4966 | ifname, i, dut->ap_sta_qos[i].cwmax); |
| 4967 | if (system(buf) != 0) { |
| 4968 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4969 | "iwpriv cwmax failed"); |
| 4970 | } |
| 4971 | |
| 4972 | snprintf(buf, sizeof(buf), "iwpriv %s aifs %d 1 %d", |
| 4973 | ifname, i, dut->ap_sta_qos[i].aifs); |
| 4974 | if (system(buf) != 0) { |
| 4975 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4976 | "iwpriv aifs failed"); |
| 4977 | } |
| 4978 | |
| 4979 | snprintf(buf, sizeof(buf), |
| 4980 | "iwpriv %s txoplimit %d 1 %d", |
| 4981 | ifname, i, dut->ap_sta_qos[i].txop); |
| 4982 | if (system(buf) != 0) { |
| 4983 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4984 | "iwpriv txoplimit failed"); |
| 4985 | } |
| 4986 | |
| 4987 | snprintf(buf, sizeof(buf), "iwpriv %s acm %d 1 %d", |
| 4988 | ifname, i, dut->ap_sta_qos[i].acm); |
| 4989 | if (system(buf) != 0) { |
| 4990 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4991 | "iwpriv acm failed"); |
| 4992 | } |
| 4993 | } |
| 4994 | } |
| 4995 | |
| 4996 | if (dut->ap_disable_protection == 1) { |
| 4997 | snprintf(buf, sizeof(buf), "iwpriv %s enablertscts 0", ifname); |
| 4998 | if (system(buf) != 0) { |
| 4999 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5000 | "iwpriv enablertscts failed"); |
| 5001 | } |
| 5002 | sigma_dut_print(dut, DUT_MSG_INFO, "Disabled rtscts"); |
| 5003 | } |
| 5004 | |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 5005 | if (dut->ap_ldpc == VALUE_ENABLED) { |
Sarvepalli, Rajesh Babu | 580572a | 2016-11-29 22:07:14 +0530 | [diff] [blame] | 5006 | snprintf(buf, sizeof(buf), "iwpriv %s ldpc 3", ifname); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5007 | if (system(buf) != 0) { |
| 5008 | sigma_dut_print(dut, DUT_MSG_ERROR, |
priyadharshini gowthaman | 15b299d | 2017-04-20 12:10:45 -0700 | [diff] [blame] | 5009 | "iwpriv ldpc 3 failed"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5010 | } |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 5011 | } else if (dut->ap_ldpc == VALUE_DISABLED) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5012 | snprintf(buf, sizeof(buf), "iwpriv %s ldpc 0", ifname); |
| 5013 | if (system(buf) != 0) { |
| 5014 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5015 | "iwpriv ldpc 0 failed"); |
| 5016 | } |
| 5017 | } |
| 5018 | |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 5019 | if (dut->ap_ampdu == VALUE_ENABLED) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5020 | snprintf(buf, sizeof(buf), "iwpriv %s ampdu 1", ifname); |
| 5021 | if (system(buf) != 0) { |
| 5022 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5023 | "iwpriv ampdu 1 failed"); |
| 5024 | } |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 5025 | } else if (dut->ap_ampdu == VALUE_DISABLED) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5026 | snprintf(buf, sizeof(buf), "iwpriv %s ampdu 0", ifname); |
| 5027 | if (system(buf) != 0) { |
| 5028 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5029 | "iwpriv ampdu 0 failed"); |
| 5030 | } |
| 5031 | } |
| 5032 | |
| 5033 | if (dut->ap_ampdu_exp) { |
| 5034 | if (dut->program == PROGRAM_VHT) { |
| 5035 | snprintf(buf, sizeof(buf), "iwpriv %s vhtmaxampdu %d", |
| 5036 | ifname, dut->ap_ampdu_exp); |
| 5037 | if (system(buf) != 0) { |
| 5038 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5039 | "iwpriv vhtmaxampdu failed"); |
| 5040 | } |
| 5041 | } else { |
| 5042 | /* 11N */ |
| 5043 | snprintf(buf, sizeof(buf), "iwpriv %s maxampdu %d", |
| 5044 | ifname, dut->ap_ampdu_exp); |
| 5045 | if (system(buf) != 0) { |
| 5046 | sigma_dut_print(dut, DUT_MSG_ERROR, "iwpriv maxampdu failed"); |
| 5047 | } |
| 5048 | } |
| 5049 | } |
| 5050 | |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 5051 | if (dut->ap_noack == VALUE_ENABLED) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5052 | snprintf(buf, sizeof(buf), "iwpriv %s noackpolicy 0 0 1", ifname); |
| 5053 | if (system(buf) != 0) { |
| 5054 | sigma_dut_print(dut, DUT_MSG_ERROR, "iwpriv noackpolicy 0 0 1 failed"); |
| 5055 | } |
| 5056 | snprintf(buf, sizeof(buf), "iwpriv %s noackpolicy 1 0 1", ifname); |
| 5057 | if (system(buf) != 0) { |
| 5058 | sigma_dut_print(dut, DUT_MSG_ERROR, "iwpriv noackpolicy 1 0 1 failed"); |
| 5059 | } |
| 5060 | snprintf(buf, sizeof(buf), "iwpriv %s noackpolicy 2 0 1", ifname); |
| 5061 | if (system(buf) != 0) { |
| 5062 | sigma_dut_print(dut, DUT_MSG_ERROR, "iwpriv noackpolicy 2 0 1 failed"); |
| 5063 | } |
| 5064 | snprintf(buf, sizeof(buf), "iwpriv %s noackpolicy 3 0 1", ifname); |
| 5065 | if (system(buf) != 0) { |
| 5066 | sigma_dut_print(dut, DUT_MSG_ERROR, "iwpriv noackpolicy 3 0 1 failed"); |
| 5067 | } |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 5068 | } else if (dut->ap_noack == VALUE_DISABLED) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5069 | snprintf(buf, sizeof(buf), "iwpriv %s noackpolicy 0 0 0", ifname); |
| 5070 | if (system(buf) != 0) { |
| 5071 | sigma_dut_print(dut, DUT_MSG_ERROR, "iwpriv noackpolicy 0 0 0 failed"); |
| 5072 | } |
| 5073 | snprintf(buf, sizeof(buf), "iwpriv %s noackpolicy 1 0 0", ifname); |
| 5074 | if (system(buf) != 0) { |
| 5075 | sigma_dut_print(dut, DUT_MSG_ERROR, "iwpriv noackpolicy 1 0 0 failed"); |
| 5076 | } |
| 5077 | snprintf(buf, sizeof(buf), "iwpriv %s noackpolicy 2 0 0", ifname); |
| 5078 | if (system(buf) != 0) { |
| 5079 | sigma_dut_print(dut, DUT_MSG_ERROR, "iwpriv noackpolicy 2 0 0 failed"); |
| 5080 | } |
| 5081 | snprintf(buf, sizeof(buf), "iwpriv %s noackpolicy 3 0 0", ifname); |
| 5082 | if (system(buf) != 0) { |
| 5083 | sigma_dut_print(dut, DUT_MSG_ERROR, "iwpriv noackpolicy 3 0 0 failed"); |
| 5084 | } |
| 5085 | } |
| 5086 | |
| 5087 | if (dut->device_type == AP_testbed && dut->ap_vhtmcs_map) { |
| 5088 | snprintf(buf, sizeof(buf), "iwpriv %s vht_mcsmap 0x%04x", |
| 5089 | ifname, dut->ap_vhtmcs_map); |
| 5090 | if (system(buf) != 0) { |
| 5091 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5092 | "iwpriv vht_mcsmap failed"); |
| 5093 | } |
| 5094 | } |
| 5095 | |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 5096 | if (dut->ap_amsdu == VALUE_ENABLED) { |
Sunil Dutt | 27ec7f6 | 2017-09-14 18:22:59 +0300 | [diff] [blame] | 5097 | snprintf(buf, sizeof(buf), "iwpriv %s amsdu 2", ifname); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5098 | if (system(buf) != 0) { |
Sunil Dutt | 27ec7f6 | 2017-09-14 18:22:59 +0300 | [diff] [blame] | 5099 | sigma_dut_print(dut, DUT_MSG_ERROR, "iwpriv amsdu 2 failed"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5100 | } |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 5101 | } else if (dut->ap_amsdu == VALUE_DISABLED) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5102 | snprintf(buf, sizeof(buf), "iwpriv %s amsdu 1", ifname); |
| 5103 | if (system(buf) != 0) { |
| 5104 | sigma_dut_print(dut, DUT_MSG_ERROR, "iwpriv amsdu 1 failed"); |
| 5105 | } |
| 5106 | } |
| 5107 | |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 5108 | if (dut->ap_rx_amsdu == VALUE_ENABLED) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5109 | snprintf(buf, sizeof(buf), "iwpriv wifi1 rx_amsdu 1"); |
| 5110 | if (system(buf) != 0) { |
| 5111 | sigma_dut_print(dut, DUT_MSG_ERROR, "iwpriv rx_amsdu 1 failed"); |
| 5112 | } |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 5113 | } else if (dut->ap_rx_amsdu == VALUE_DISABLED) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5114 | snprintf(buf, sizeof(buf), "iwpriv wifi1 rx_amsdu 0"); |
| 5115 | if (system(buf) != 0) { |
| 5116 | sigma_dut_print(dut, DUT_MSG_ERROR, "iwpriv rx_amsdu 0 failed"); |
| 5117 | } |
| 5118 | } |
| 5119 | |
| 5120 | /* Command sequence to generate single VHT AMSDU and MPDU */ |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 5121 | if (dut->ap_addba_reject != VALUE_NOT_SET && |
| 5122 | dut->ap_ampdu == VALUE_DISABLED && |
| 5123 | dut->ap_amsdu == VALUE_ENABLED) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5124 | snprintf(buf, sizeof(buf), "iwpriv %s setaddbaoper 1", ifname); |
| 5125 | if (system(buf) != 0) { |
| 5126 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5127 | "iwpriv setaddbaoper 1 failed"); |
| 5128 | } |
| 5129 | |
| 5130 | snprintf(buf, sizeof(buf), |
| 5131 | "wifitool %s senddelba 1 0 1 4", ifname); |
| 5132 | if (system(buf) != 0) { |
| 5133 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5134 | "wifitool senddelba failed"); |
| 5135 | } |
| 5136 | |
| 5137 | snprintf(buf, sizeof(buf), "wifitool %s sendsingleamsdu 1 0", |
| 5138 | ifname); |
| 5139 | if (system(buf) != 0) { |
| 5140 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5141 | "wifitool sendsingleamsdu failed"); |
| 5142 | } |
| 5143 | |
| 5144 | snprintf(buf, sizeof(buf), "iwpriv %s amsdu 10", ifname); |
| 5145 | if (system(buf) != 0) { |
| 5146 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5147 | "iwpriv amsdu failed"); |
| 5148 | } |
| 5149 | } |
| 5150 | |
| 5151 | if (dut->ap_mode == AP_11ac) { |
| 5152 | int chwidth, nss; |
| 5153 | |
| 5154 | switch (dut->ap_chwidth) { |
| 5155 | case AP_20: |
| 5156 | chwidth = 0; |
| 5157 | break; |
| 5158 | case AP_40: |
| 5159 | chwidth = 1; |
| 5160 | break; |
| 5161 | case AP_80: |
| 5162 | chwidth = 2; |
| 5163 | break; |
| 5164 | case AP_160: |
| 5165 | chwidth = 3; |
| 5166 | break; |
priyadharshini gowthaman | 63ab848 | 2017-12-28 15:32:55 -0800 | [diff] [blame] | 5167 | case AP_80_80: |
| 5168 | chwidth = 3; |
| 5169 | break; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5170 | default: |
| 5171 | chwidth = 0; |
| 5172 | break; |
| 5173 | } |
| 5174 | |
| 5175 | switch (dut->ap_tx_streams) { |
| 5176 | case 1: |
| 5177 | nss = 1; |
| 5178 | break; |
| 5179 | case 2: |
| 5180 | nss = 2; |
| 5181 | break; |
| 5182 | case 3: |
| 5183 | nss = 3; |
| 5184 | break; |
| 5185 | case 4: |
| 5186 | nss = 4; |
| 5187 | break; |
| 5188 | default: |
| 5189 | nss = 3; |
| 5190 | break; |
| 5191 | } |
| 5192 | |
| 5193 | if (dut->ap_fixed_rate) { |
| 5194 | if (nss == 4) |
| 5195 | ath_disable_txbf(dut, ifname); |
| 5196 | |
| 5197 | /* Set the nss */ |
| 5198 | snprintf(buf, sizeof(buf), "iwpriv %s nss %d", |
| 5199 | ifname, nss); |
| 5200 | if (system(buf) != 0) { |
| 5201 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5202 | "iwpriv nss failed"); |
| 5203 | } |
| 5204 | |
| 5205 | /* Set the channel width */ |
| 5206 | snprintf(buf, sizeof(buf), "iwpriv %s chwidth %d", |
| 5207 | ifname, chwidth); |
| 5208 | if (system(buf) != 0) { |
| 5209 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5210 | "iwpriv chwidth failed"); |
| 5211 | } |
| 5212 | |
| 5213 | /* Set the VHT MCS */ |
| 5214 | snprintf(buf, sizeof(buf), "iwpriv %s vhtmcs %d", |
| 5215 | ifname, dut->ap_mcs); |
| 5216 | if (system(buf) != 0) { |
| 5217 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5218 | "iwpriv vhtmcs failed"); |
| 5219 | } |
| 5220 | } |
| 5221 | } |
| 5222 | |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 5223 | if (dut->ap_dyn_bw_sig == VALUE_ENABLED) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5224 | snprintf(buf, sizeof(buf), "iwpriv %s cwmenable 1", ifname); |
| 5225 | if (system(buf) != 0) { |
| 5226 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5227 | "iwpriv cwmenable 1 failed"); |
| 5228 | } |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 5229 | } else if (dut->ap_dyn_bw_sig == VALUE_DISABLED) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5230 | snprintf(buf, sizeof(buf), "iwpriv %s cwmenable 0", ifname); |
| 5231 | if (system(buf) != 0) { |
| 5232 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5233 | "iwpriv cwmenable 0 failed"); |
| 5234 | } |
| 5235 | } |
| 5236 | |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 5237 | if (dut->ap_sig_rts == VALUE_ENABLED) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5238 | snprintf(buf, sizeof(buf), "iwconfig %s rts 64", ifname); |
| 5239 | if (system(buf) != 0) { |
| 5240 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5241 | "iwconfig rts 64 failed"); |
| 5242 | } |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 5243 | } else if (dut->ap_sig_rts == VALUE_DISABLED) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5244 | snprintf(buf, sizeof(buf), "iwconfig %s rts 2347", ifname); |
| 5245 | if (system(buf) != 0) { |
| 5246 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5247 | "iwpriv rts 2347 failed"); |
| 5248 | } |
| 5249 | } |
| 5250 | |
| 5251 | if (dut->ap_hs2) { |
| 5252 | snprintf(buf, sizeof(buf), "iwpriv %s qbssload 1", ifname); |
| 5253 | if (system(buf) != 0) { |
| 5254 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5255 | "iwpriv qbssload failed"); |
| 5256 | } |
| 5257 | sigma_dut_print(dut, DUT_MSG_INFO, "Enabled qbssload"); |
| 5258 | } |
| 5259 | |
| 5260 | if (dut->ap_bss_load && dut->ap_bss_load != -1) { |
| 5261 | unsigned int bssload = 0; |
| 5262 | |
| 5263 | if (dut->ap_bss_load == 1) { |
| 5264 | /* STA count: 1, CU: 50, AAC: 65535 */ |
| 5265 | bssload = 0x0132ffff; |
| 5266 | } else if (dut->ap_bss_load == 2) { |
| 5267 | /* STA count: 1, CU: 200, AAC: 65535 */ |
| 5268 | bssload = 0x01c8ffff; |
| 5269 | } else if (dut->ap_bss_load == 3) { |
| 5270 | /* STA count: 1, CU: 75, AAC: 65535 */ |
| 5271 | bssload = 0x014bffff; |
| 5272 | } |
| 5273 | |
| 5274 | snprintf(buf, sizeof(buf), "iwpriv %s hcbssload %u", |
| 5275 | ifname, bssload); |
| 5276 | if (system(buf) != 0) { |
| 5277 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5278 | "iwpriv hcbssload failed"); |
| 5279 | } |
| 5280 | } else if (dut->ap_bss_load == 0) { |
| 5281 | snprintf(buf, sizeof(buf), "iwpriv %s qbssload 0", ifname); |
| 5282 | if (system(buf) != 0) { |
| 5283 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5284 | "iwpriv qbssload failed"); |
| 5285 | } |
| 5286 | sigma_dut_print(dut, DUT_MSG_INFO, "Disabled qbssload"); |
| 5287 | } |
| 5288 | |
| 5289 | if (dut->ap_dgaf_disable) { |
| 5290 | snprintf(buf, sizeof(buf), "iwpriv %s dgaf_disable 1", ifname); |
| 5291 | if (system(buf) != 0) { |
| 5292 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5293 | "iwpriv dgaf_disable failed"); |
| 5294 | } |
| 5295 | sigma_dut_print(dut, DUT_MSG_INFO, "Enabled dgaf_disable"); |
| 5296 | } |
| 5297 | |
| 5298 | if (dut->ap_l2tif) { |
| 5299 | snprintf(buf, sizeof(buf), "iwpriv %s l2tif 1", ifname); |
| 5300 | if (system(buf) != 0) { |
| 5301 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5302 | "iwpriv l2tif failed"); |
| 5303 | } |
| 5304 | snprintf(buf, sizeof(buf), |
| 5305 | "echo 1 > /sys/class/net/br0/brif/ath0/hotspot_l2tif"); |
| 5306 | if (system(buf) != 0) |
| 5307 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5308 | "l2tif br failed"); |
| 5309 | |
| 5310 | snprintf(buf, sizeof(buf), |
| 5311 | "echo 1 > /sys/class/net/br0/brif/eth0/hotspot_wan"); |
| 5312 | if (system(buf) != 0) |
| 5313 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5314 | "l2tif brif failed"); |
| 5315 | sigma_dut_print(dut, DUT_MSG_INFO, "Enabled l2tif"); |
| 5316 | } |
priyadharshini gowthaman | 264d544 | 2016-02-25 15:52:22 -0800 | [diff] [blame] | 5317 | |
| 5318 | if (dut->ap_ndpa_frame == 0) { |
| 5319 | snprintf(buf, sizeof(buf), |
| 5320 | "wifitool %s beeliner_fw_test 117 192", ifname); |
| 5321 | if (system(buf) != 0) { |
| 5322 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5323 | "wifitool beeliner_fw_test 117 192 failed"); |
| 5324 | } |
| 5325 | snprintf(buf, sizeof(buf), |
| 5326 | "wifitool %s beeliner_fw_test 118 192", ifname); |
| 5327 | if (system(buf) != 0) { |
| 5328 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5329 | "wifitool beeliner_fw_test 117 192 failed"); |
| 5330 | } |
| 5331 | } else if (dut->ap_ndpa_frame == 1) { |
| 5332 | /* Driver default - no changes needed */ |
| 5333 | } else if (dut->ap_ndpa_frame == 2) { |
| 5334 | snprintf(buf, sizeof(buf), |
| 5335 | "wifitool %s beeliner_fw_test 115 1", ifname); |
| 5336 | if (system(buf) != 0) { |
| 5337 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5338 | "wifitool beeliner_fw_test 117 192 failed"); |
| 5339 | } |
| 5340 | snprintf(buf, sizeof(buf), |
| 5341 | "wifitool %s beeliner_fw_test 116 1", ifname); |
| 5342 | if (system(buf) != 0) { |
| 5343 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5344 | "wifitool beeliner_fw_test 117 192 failed"); |
| 5345 | } |
| 5346 | } |
priyadharshini gowthaman | 8e26ff4 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 5347 | |
| 5348 | if (dut->ap_rtt == 1) { |
| 5349 | snprintf(buf, sizeof(buf), "iwpriv %s enable_rtt 1", ifname); |
| 5350 | run_system(dut, buf); |
| 5351 | } |
| 5352 | |
| 5353 | if (dut->ap_lci == 1) { |
| 5354 | snprintf(buf, sizeof(buf), "iwpriv %s enable_lci 1", ifname); |
| 5355 | run_system(dut, buf); |
| 5356 | } |
| 5357 | |
| 5358 | if (dut->ap_lcr == 1) { |
| 5359 | snprintf(buf, sizeof(buf), "iwpriv %s enable_lcr 1", ifname); |
| 5360 | run_system(dut, buf); |
| 5361 | } |
| 5362 | |
| 5363 | if (dut->ap_rrm == 1) { |
| 5364 | snprintf(buf, sizeof(buf), "iwpriv %s rrm 1", ifname); |
| 5365 | run_system(dut, buf); |
| 5366 | } |
| 5367 | |
| 5368 | if (dut->ap_lci == 1 || dut->ap_lcr == 1) { |
| 5369 | run_system(dut, "wpc -l /tmp/lci_cfg.txt"); |
| 5370 | } |
| 5371 | |
| 5372 | if (dut->ap_neighap >= 1 && dut->ap_lci == 0) { |
| 5373 | FILE *f; |
| 5374 | |
| 5375 | f = fopen("/tmp/nbr_report.txt", "w"); |
| 5376 | if (!f) { |
| 5377 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5378 | "Failed to open /tmp/nbr_report.txt"); |
| 5379 | return; |
| 5380 | } |
| 5381 | |
| 5382 | fprintf(f, |
| 5383 | "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", |
| 5384 | dut->ap_val_neighap[0][0], dut->ap_val_neighap[0][1], |
| 5385 | dut->ap_val_neighap[0][2], dut->ap_val_neighap[0][3], |
| 5386 | dut->ap_val_neighap[0][4], dut->ap_val_neighap[0][5], |
| 5387 | dut->ap_val_opchannel[0]); |
| 5388 | fclose(f); |
| 5389 | |
| 5390 | f = fopen("/tmp/ftmrr.txt", "w"); |
| 5391 | if (!f) { |
| 5392 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5393 | "Failed to open /tmp/ftmrr.txt"); |
| 5394 | return; |
| 5395 | } |
| 5396 | |
| 5397 | fprintf(f, |
| 5398 | "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", |
| 5399 | dut->ap_val_neighap[0][0], dut->ap_val_neighap[0][1], |
| 5400 | dut->ap_val_neighap[0][2], dut->ap_val_neighap[0][3], |
| 5401 | dut->ap_val_neighap[0][4], dut->ap_val_neighap[0][5], |
| 5402 | dut->ap_val_opchannel[0]); |
| 5403 | fclose(f); |
| 5404 | } |
| 5405 | |
| 5406 | if (dut->ap_neighap >= 2 && dut->ap_lci == 0) { |
| 5407 | FILE *f; |
| 5408 | |
| 5409 | f = fopen("/tmp/nbr_report.txt", "a"); |
| 5410 | if (!f) { |
| 5411 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5412 | "Failed to open /tmp/nbr_report.txt"); |
| 5413 | return; |
| 5414 | } |
| 5415 | fprintf(f, |
| 5416 | "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", |
| 5417 | dut->ap_val_neighap[1][0], dut->ap_val_neighap[1][1], |
| 5418 | dut->ap_val_neighap[1][2], dut->ap_val_neighap[1][3], |
| 5419 | dut->ap_val_neighap[1][4], dut->ap_val_neighap[1][5], |
| 5420 | dut->ap_val_opchannel[1]); |
| 5421 | fclose(f); |
| 5422 | |
| 5423 | f = fopen("/tmp/ftmrr.txt", "a"); |
| 5424 | if (!f) { |
| 5425 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5426 | "Failed to open /tmp/ftmrr.txt"); |
| 5427 | return; |
| 5428 | } |
| 5429 | fprintf(f, |
| 5430 | "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", |
| 5431 | dut->ap_val_neighap[1][0], dut->ap_val_neighap[1][1], |
| 5432 | dut->ap_val_neighap[1][2], dut->ap_val_neighap[1][3], |
| 5433 | dut->ap_val_neighap[1][4], dut->ap_val_neighap[1][5], |
| 5434 | dut->ap_val_opchannel[1]); |
| 5435 | fclose(f); |
| 5436 | } |
| 5437 | |
| 5438 | if (dut->ap_neighap >= 3 && dut->ap_lci == 0) { |
| 5439 | FILE *f; |
| 5440 | |
| 5441 | f = fopen("/tmp/nbr_report.txt", "a"); |
| 5442 | if (!f) { |
| 5443 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5444 | "Failed to open /tmp/nbr_report.txt"); |
| 5445 | return; |
| 5446 | } |
| 5447 | |
| 5448 | fprintf(f, |
| 5449 | "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", |
| 5450 | dut->ap_val_neighap[2][0], dut->ap_val_neighap[2][1], |
| 5451 | dut->ap_val_neighap[2][2], dut->ap_val_neighap[2][3], |
| 5452 | dut->ap_val_neighap[2][4], dut->ap_val_neighap[2][5], |
| 5453 | dut->ap_val_opchannel[2]); |
| 5454 | fclose(f); |
| 5455 | |
| 5456 | f = fopen("/tmp/ftmrr.txt", "a"); |
| 5457 | if (!f) { |
| 5458 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5459 | "Failed to open /tmp/ftmrr.txt"); |
| 5460 | return; |
| 5461 | } |
| 5462 | |
| 5463 | fprintf(f, |
| 5464 | "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", |
| 5465 | dut->ap_val_neighap[2][0], dut->ap_val_neighap[2][1], |
| 5466 | dut->ap_val_neighap[2][2], dut->ap_val_neighap[2][3], |
| 5467 | dut->ap_val_neighap[2][4], dut->ap_val_neighap[2][5], |
| 5468 | dut->ap_val_opchannel[2]); |
| 5469 | fclose(f); |
| 5470 | } |
| 5471 | |
| 5472 | if (dut->ap_neighap) { |
| 5473 | snprintf(buf, sizeof(buf), "iwpriv %s enable_rtt 1", ifname); |
| 5474 | run_system(dut, buf); |
| 5475 | snprintf(buf, sizeof(buf), "iwpriv %s enable_lci 1", ifname); |
| 5476 | run_system(dut, buf); |
| 5477 | snprintf(buf, sizeof(buf), "iwpriv %s enable_lcr 1", ifname); |
| 5478 | run_system(dut, buf); |
| 5479 | snprintf(buf, sizeof(buf), "iwpriv %s rrm 1", ifname); |
| 5480 | run_system(dut, buf); |
| 5481 | } |
| 5482 | |
| 5483 | if (dut->ap_scan == 1) { |
| 5484 | snprintf(buf, sizeof(buf), "iwpriv %s scanentryage 600", |
| 5485 | ifname); |
| 5486 | run_system(dut, buf); |
| 5487 | snprintf(buf, sizeof(buf), "iwlist %s scan", ifname); |
| 5488 | run_system(dut, buf); |
| 5489 | } |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 5490 | |
| 5491 | if (dut->ap_set_bssidpref) { |
| 5492 | snprintf(buf, sizeof(buf), |
| 5493 | "wifitool %s setbssidpref 00:00:00:00:00:00 0 00 00", |
| 5494 | ifname); |
| 5495 | if (system(buf) != 0) { |
| 5496 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5497 | "wifitool clear bssidpref failed"); |
| 5498 | } |
| 5499 | } |
Adil Saeed Musthafa | 33ea287 | 2017-04-10 23:13:24 -0700 | [diff] [blame] | 5500 | |
| 5501 | if (dut->wnm_bss_max_feature != VALUE_NOT_SET) { |
| 5502 | int feature_enable; |
| 5503 | |
| 5504 | feature_enable = dut->wnm_bss_max_feature == VALUE_ENABLED; |
| 5505 | snprintf(buf, sizeof(buf), "iwpriv %s wnm %d", |
| 5506 | ifname, feature_enable); |
| 5507 | run_system(dut, buf); |
| 5508 | snprintf(buf, sizeof(buf), "iwpriv %s wnm_bss %d", |
| 5509 | ifname, feature_enable); |
| 5510 | run_system(dut, buf); |
| 5511 | if (feature_enable) { |
| 5512 | const char *extra = ""; |
| 5513 | |
| 5514 | if (dut->wnm_bss_max_protection != VALUE_NOT_SET) { |
| 5515 | if (dut->wnm_bss_max_protection == |
| 5516 | VALUE_ENABLED) |
| 5517 | extra = " 1"; |
| 5518 | else |
| 5519 | extra = " 0"; |
| 5520 | } |
| 5521 | snprintf(buf, sizeof(buf), |
| 5522 | "wlanconfig %s wnm setbssmax %d%s", |
| 5523 | ifname, dut->wnm_bss_max_idle_time, extra); |
| 5524 | run_system(dut, buf); |
| 5525 | } |
| 5526 | } |
Adil Saeed Musthafa | 05ec744 | 2017-04-10 23:13:35 -0700 | [diff] [blame] | 5527 | |
Adil Saeed Musthafa | 023108a | 2017-04-10 23:13:37 -0700 | [diff] [blame] | 5528 | if (dut->program == PROGRAM_MBO) { |
Adil Saeed Musthafa | 6906372 | 2017-04-10 23:13:40 -0700 | [diff] [blame] | 5529 | apply_mbo_pref_ap_list(dut); |
| 5530 | |
Adil Saeed Musthafa | 023108a | 2017-04-10 23:13:37 -0700 | [diff] [blame] | 5531 | snprintf(buf, sizeof(buf), "iwpriv %s mbo_cel_pref %d", |
| 5532 | ifname, dut->ap_cell_cap_pref); |
| 5533 | run_system(dut, buf); |
Adil Saeed Musthafa | 16d9e63 | 2017-04-10 23:13:38 -0700 | [diff] [blame] | 5534 | |
| 5535 | snprintf(buf, sizeof(buf), "iwpriv %s mbocap 0x40", ifname); |
| 5536 | run_system(dut, buf); |
| 5537 | |
Adil Saeed Musthafa | 05ec744 | 2017-04-10 23:13:35 -0700 | [diff] [blame] | 5538 | ath_set_assoc_disallow(dut, ifname, "disable"); |
Adil Saeed Musthafa | 023108a | 2017-04-10 23:13:37 -0700 | [diff] [blame] | 5539 | } |
priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 5540 | |
| 5541 | if (dut->ap_oce == VALUE_ENABLED) { |
| 5542 | snprintf(buf, sizeof(buf), "iwpriv %s set_bpr_enable 1", |
| 5543 | ifname); |
| 5544 | run_system(dut, buf); |
| 5545 | } |
| 5546 | |
| 5547 | if (dut->ap_oce == VALUE_ENABLED && dut->ap_channel <= 11) { |
| 5548 | snprintf(buf, sizeof(buf), "iwpriv %s prb_rate 5500", ifname); |
| 5549 | run_system(dut, buf); |
| 5550 | snprintf(buf, sizeof(buf), "iwpriv %s set_bcn_rate 5500", |
| 5551 | ifname); |
| 5552 | run_system(dut, buf); |
| 5553 | } |
| 5554 | |
| 5555 | if (dut->ap_oce == VALUE_DISABLED) { |
| 5556 | snprintf(buf, sizeof(buf), "iwpriv %s set_bpr_enable 0", |
| 5557 | ifname); |
| 5558 | run_system(dut, buf); |
| 5559 | } |
| 5560 | |
| 5561 | if (dut->ap_oce == VALUE_DISABLED && dut->ap_channel <= 11) { |
| 5562 | snprintf(buf, sizeof(buf), "iwpriv %s mgmt_rate 1000", ifname); |
| 5563 | run_system(dut, buf); |
| 5564 | snprintf(buf, sizeof(buf), "iwpriv %s set_bcn_rate 1000", |
| 5565 | ifname); |
| 5566 | run_system(dut, buf); |
| 5567 | } |
| 5568 | |
| 5569 | if (dut->ap_bcnint) { |
| 5570 | snprintf(buf, sizeof(buf), "iwpriv %s bintval %d", ifname, |
| 5571 | dut->ap_bcnint); |
| 5572 | run_system(dut, buf); |
| 5573 | } |
| 5574 | |
| 5575 | if (dut->ap_filsdscv == VALUE_DISABLED) { |
| 5576 | snprintf(buf, sizeof(buf), "iwpriv %s enable_fils 0 0", ifname); |
| 5577 | run_system(dut, buf); |
| 5578 | } |
| 5579 | |
| 5580 | if (dut->ap_filshlp == VALUE_ENABLED) { |
| 5581 | snprintf(buf, sizeof(buf), "iwpriv %s oce_hlp 1", ifname); |
| 5582 | if (system(buf) != 0) { |
| 5583 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5584 | "iwpriv filshlp enable failed"); |
| 5585 | } |
| 5586 | } else if (dut->ap_filshlp == VALUE_DISABLED) { |
| 5587 | snprintf(buf, sizeof(buf), "iwpriv %s oce_hlp 0", ifname); |
| 5588 | if (system(buf) != 0) { |
| 5589 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5590 | "iwpriv filshlp disable failed"); |
| 5591 | } |
| 5592 | } |
| 5593 | |
| 5594 | /* When RNR is enabled, also enable apchannelreport, background scan */ |
| 5595 | if (dut->ap_rnr == VALUE_ENABLED) { |
| 5596 | snprintf(buf, sizeof(buf), "iwpriv %s rnr 1", ifname); |
| 5597 | run_system(dut, buf); |
| 5598 | snprintf(buf, sizeof(buf), "iwpriv %s rnr_tbtt 1", ifname); |
| 5599 | run_system(dut, buf); |
| 5600 | snprintf(buf, sizeof(buf), "iwpriv %s apchanrpt 1", ifname); |
| 5601 | run_system(dut, buf); |
| 5602 | snprintf(buf, sizeof(buf), "iwpriv %s acs_ctrlflags 0x4", |
| 5603 | basedev); |
| 5604 | run_system(dut, buf); |
| 5605 | snprintf(buf, sizeof(buf), "iwpriv %s acs_scanintvl 60", |
| 5606 | basedev); |
| 5607 | run_system(dut, buf); |
| 5608 | snprintf(buf, sizeof(buf), "iwpriv %s acs_bkscanen 1", basedev); |
| 5609 | run_system(dut, buf); |
| 5610 | if (dut->ap_is_dual == 1) { |
| 5611 | snprintf(buf, sizeof(buf), "iwpriv %s rnr 1", |
| 5612 | ifname_dual); |
| 5613 | run_system(dut, buf); |
| 5614 | snprintf(buf, sizeof(buf), "iwpriv %s rnr_tbtt 1", |
| 5615 | ifname_dual); |
| 5616 | run_system(dut, buf); |
| 5617 | snprintf(buf, sizeof(buf), "iwpriv %s apchanrpt 1", |
| 5618 | ifname_dual); |
| 5619 | run_system(dut, buf); |
| 5620 | snprintf(buf, sizeof(buf), |
| 5621 | "iwpriv %s acs_ctrlflags 0x4", basedev_radio); |
| 5622 | run_system(dut, buf); |
| 5623 | snprintf(buf, sizeof(buf), "iwpriv %s acs_scanintvl 60", |
| 5624 | basedev_radio); |
| 5625 | run_system(dut, buf); |
| 5626 | snprintf(buf, sizeof(buf), "iwpriv %s acs_bkscanen 1", |
| 5627 | basedev_radio); |
| 5628 | run_system(dut, buf); |
| 5629 | } |
| 5630 | } |
| 5631 | |
| 5632 | if (dut->ap_blechanutil || dut->ap_ble_admit_cap || dut->ap_blestacnt) { |
| 5633 | snprintf(buf, sizeof(buf), "iwpriv %s qbssload 0", ifname); |
| 5634 | run_system(dut, buf); |
| 5635 | snprintf(buf, sizeof(buf), |
| 5636 | "wlanconfig %s addie ftype 0 len 7 data 0b05%02x%02x%02x%02x%02x ", |
| 5637 | ifname, dut->ap_blestacnt & 0xFF, |
| 5638 | dut->ap_blestacnt >> 8, dut->ap_blechanutil, |
| 5639 | dut->ap_ble_admit_cap & 0xFF, |
| 5640 | dut->ap_ble_admit_cap >> 8); |
| 5641 | run_system(dut, buf); |
| 5642 | snprintf(buf, sizeof(buf), |
| 5643 | "wlanconfig %s addie ftype 2 len 7 data 0b05%02x%02x%02x%02x%02x ", |
| 5644 | ifname, dut->ap_blestacnt & 0xFF, |
| 5645 | dut->ap_blestacnt >> 8, dut->ap_blechanutil, |
| 5646 | dut->ap_ble_admit_cap & 0xFF, |
| 5647 | dut->ap_ble_admit_cap >> 8); |
| 5648 | run_system(dut, buf); |
| 5649 | } |
| 5650 | |
| 5651 | if (dut->ap_esp == VALUE_ENABLED) { |
| 5652 | snprintf(buf, sizeof(buf), "iwpriv %s esp_period 5", basedev); |
| 5653 | if (system(buf) != 0) { |
| 5654 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5655 | "iwpriv esp enable failed"); |
| 5656 | } |
| 5657 | } else if (dut->ap_esp == VALUE_DISABLED) { |
| 5658 | snprintf(buf, sizeof(buf), "iwpriv %s esp_period 0", basedev); |
| 5659 | if (system(buf) != 0) { |
| 5660 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5661 | "iwpriv esp disable failed"); |
| 5662 | } |
| 5663 | } |
| 5664 | |
| 5665 | if (dut->ap_datappdudura) { |
| 5666 | snprintf(buf, sizeof(buf), "iwpriv %s esp_ppdu_dur %d", basedev, |
| 5667 | dut->ap_datappdudura); |
| 5668 | run_system(dut, buf); |
| 5669 | } |
| 5670 | |
| 5671 | if (dut->ap_airtimefract) { |
| 5672 | snprintf(buf, sizeof(buf), "iwpriv %s esp_airtime %d", basedev, |
| 5673 | dut->ap_airtimefract); |
| 5674 | run_system(dut, buf); |
| 5675 | } |
| 5676 | |
| 5677 | if (dut->ap_dhcp_stop) { |
| 5678 | snprintf(buf, sizeof(buf), "/etc/init.d/dnsmasq stop"); |
| 5679 | run_system(dut, buf); |
| 5680 | } |
| 5681 | |
| 5682 | if (dut->ap_bawinsize) { |
| 5683 | snprintf(buf, sizeof(buf), "iwpriv %s esp_ba_window %d", |
| 5684 | basedev, dut->ap_bawinsize); |
| 5685 | run_system(dut, buf); |
| 5686 | } |
priyadharshini gowthaman | b4de196 | 2018-01-15 12:21:04 -0800 | [diff] [blame] | 5687 | |
| 5688 | if (dut->program == PROGRAM_DPP) { |
| 5689 | if (dut->ap_interface_2g == 1) { |
| 5690 | snprintf(buf, sizeof(buf), |
| 5691 | "iwpriv %s set_bcn_rate 5500", ifname); |
| 5692 | run_system(dut, buf); |
| 5693 | snprintf(buf, sizeof(buf), |
| 5694 | "iwpriv %s prb_rate 5500", ifname); |
| 5695 | run_system(dut, buf); |
| 5696 | snprintf(buf, sizeof(buf), |
| 5697 | "iwpriv %s mgmt_rate 5500", ifname); |
| 5698 | run_system(dut, buf); |
| 5699 | } |
| 5700 | |
| 5701 | snprintf(buf, sizeof(buf), "iwpriv %s set_rxfilter 0xffffffff", |
| 5702 | basedev); |
| 5703 | run_system(dut, buf); |
| 5704 | dut->hostapd_running = 1; |
| 5705 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5706 | } |
| 5707 | |
| 5708 | |
| 5709 | static int cmd_ath_ap_config_commit(struct sigma_dut *dut, |
| 5710 | struct sigma_conn *conn, |
| 5711 | struct sigma_cmd *cmd) |
| 5712 | { |
| 5713 | /* const char *name = get_param(cmd, "NAME"); */ |
| 5714 | char buf[100]; |
| 5715 | struct stat s; |
| 5716 | const char *ifname = dut->ap_is_dual ? "ath1" : "ath0"; |
| 5717 | |
| 5718 | if (stat("/proc/athversion", &s) == 0) { |
| 5719 | sigma_dut_print(dut, DUT_MSG_INFO, "Run apdown"); |
| 5720 | run_system(dut, "apdown"); |
| 5721 | } |
| 5722 | |
| 5723 | cmd_ath_ap_radio_config(dut); |
| 5724 | |
| 5725 | snprintf(buf, sizeof(buf), "cfg -a 'AP_SSID=%s'", dut->ap_ssid); |
| 5726 | run_system(dut, buf); |
| 5727 | |
| 5728 | switch (dut->ap_key_mgmt) { |
| 5729 | case AP_OPEN: |
| 5730 | if (dut->ap_cipher == AP_WEP) { |
| 5731 | run_system(dut, "cfg -a AP_SECMODE=WEP"); |
| 5732 | run_system(dut, "cfg -a AP_SECFILE=NONE"); |
| 5733 | /* shared auth mode not supported */ |
| 5734 | run_system(dut, "cfg -a AP_WEP_MODE_0=1"); |
| 5735 | run_system(dut, "cfg -a AP_WEP_MODE_1=1"); |
| 5736 | snprintf(buf, sizeof(buf), |
| 5737 | "cfg -a WEP_RADIO_NUM0_KEY_1=%s", |
| 5738 | dut->ap_wepkey); |
| 5739 | run_system(dut, buf); |
| 5740 | snprintf(buf, sizeof(buf), |
| 5741 | "cfg -a WEP_RADIO_NUM1_KEY_1=%s", |
| 5742 | dut->ap_wepkey); |
| 5743 | run_system(dut, buf); |
| 5744 | } else { |
| 5745 | run_system(dut, "cfg -a AP_SECMODE=None"); |
| 5746 | } |
| 5747 | break; |
| 5748 | case AP_WPA2_PSK: |
| 5749 | case AP_WPA2_PSK_MIXED: |
| 5750 | case AP_WPA_PSK: |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 5751 | case AP_WPA2_SAE: |
| 5752 | case AP_WPA2_PSK_SAE: |
| 5753 | if (dut->ap_key_mgmt == AP_WPA2_PSK || |
| 5754 | dut->ap_key_mgmt == AP_WPA2_SAE || |
| 5755 | dut->ap_key_mgmt == AP_WPA2_PSK_SAE) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5756 | run_system(dut, "cfg -a AP_WPA=2"); |
| 5757 | else if (dut->ap_key_mgmt == AP_WPA2_PSK_MIXED) |
| 5758 | run_system(dut, "cfg -a AP_WPA=3"); |
| 5759 | else |
| 5760 | run_system(dut, "cfg -a AP_WPA=1"); |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 5761 | /* TODO: SAE configuration */ |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5762 | run_system(dut, "cfg -a AP_SECMODE=WPA"); |
| 5763 | run_system(dut, "cfg -a AP_SECFILE=PSK"); |
| 5764 | snprintf(buf, sizeof(buf), "cfg -a 'PSK_KEY=%s'", |
| 5765 | dut->ap_passphrase); |
| 5766 | run_system(dut, buf); |
| 5767 | if (dut->ap_cipher == AP_CCMP_TKIP) |
| 5768 | run_system(dut, "cfg -a AP_CYPHER=\"CCMP TKIP\""); |
| 5769 | else if (dut->ap_cipher == AP_TKIP) |
| 5770 | run_system(dut, "cfg -a AP_CYPHER=TKIP"); |
| 5771 | else |
| 5772 | run_system(dut, "cfg -a AP_CYPHER=CCMP"); |
| 5773 | break; |
| 5774 | case AP_WPA2_EAP: |
| 5775 | case AP_WPA2_EAP_MIXED: |
| 5776 | case AP_WPA_EAP: |
| 5777 | if (dut->ap_key_mgmt == AP_WPA2_EAP) |
| 5778 | run_system(dut, "cfg -a AP_WPA=2"); |
| 5779 | else if (dut->ap_key_mgmt == AP_WPA2_EAP_MIXED) |
| 5780 | run_system(dut, "cfg -a AP_WPA=3"); |
| 5781 | else |
| 5782 | run_system(dut, "cfg -a AP_WPA=1"); |
| 5783 | run_system(dut, "cfg -a AP_SECMODE=WPA"); |
| 5784 | run_system(dut, "cfg -a AP_SECFILE=EAP"); |
| 5785 | if (dut->ap_cipher == AP_CCMP_TKIP) |
| 5786 | run_system(dut, "cfg -a AP_CYPHER=\"CCMP TKIP\""); |
| 5787 | else if (dut->ap_cipher == AP_TKIP) |
| 5788 | run_system(dut, "cfg -a AP_CYPHER=TKIP"); |
| 5789 | else |
| 5790 | run_system(dut, "cfg -a AP_CYPHER=CCMP"); |
| 5791 | snprintf(buf, sizeof(buf), "cfg -a AP_AUTH_SERVER=%s", |
| 5792 | dut->ap_radius_ipaddr); |
| 5793 | run_system(dut, buf); |
| 5794 | snprintf(buf, sizeof(buf), "cfg -a AP_AUTH_PORT=%d", |
| 5795 | dut->ap_radius_port); |
| 5796 | run_system(dut, buf); |
| 5797 | snprintf(buf, sizeof(buf), "cfg -a AP_AUTH_SECRET=%s", |
| 5798 | dut->ap_radius_password); |
| 5799 | run_system(dut, buf); |
| 5800 | break; |
Jouni Malinen | ad395a2 | 2017-09-01 21:13:46 +0300 | [diff] [blame] | 5801 | case AP_SUITEB: |
| 5802 | /* TODO */ |
| 5803 | sigma_dut_print(dut, DUT_MSG_ERROR, "SuiteB not supported"); |
| 5804 | break; |
Jouni Malinen | 147b3c3 | 2017-10-09 16:51:54 +0300 | [diff] [blame] | 5805 | case AP_WPA2_OWE: |
| 5806 | /* TODO */ |
| 5807 | sigma_dut_print(dut, DUT_MSG_ERROR, "OWE not supported"); |
| 5808 | break; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5809 | } |
| 5810 | |
| 5811 | if (dut->ap_is_dual) { |
| 5812 | /* ath1 settings in case of dual */ |
| 5813 | snprintf(buf, sizeof(buf), "cfg -a 'AP_SSID_2=%s'", |
| 5814 | dut->ap_ssid); |
| 5815 | run_system(dut, buf); |
| 5816 | |
| 5817 | switch (dut->ap_key_mgmt) { |
| 5818 | case AP_OPEN: |
| 5819 | if (dut->ap_cipher == AP_WEP) { |
| 5820 | run_system(dut, "cfg -a AP_SECMODE_2=WEP"); |
| 5821 | run_system(dut, "cfg -a AP_SECFILE_2=NONE"); |
| 5822 | /* shared auth mode not supported */ |
| 5823 | run_system(dut, "cfg -a AP_WEP_MODE_0=1"); |
| 5824 | run_system(dut, "cfg -a AP_WEP_MODE_1=1"); |
| 5825 | snprintf(buf, sizeof(buf), |
| 5826 | "cfg -a WEP_RADIO_NUM0_KEY_1=%s", |
| 5827 | dut->ap_wepkey); |
| 5828 | run_system(dut, buf); |
| 5829 | snprintf(buf, sizeof(buf), |
| 5830 | "cfg -a WEP_RADIO_NUM1_KEY_1=%s", |
| 5831 | dut->ap_wepkey); |
| 5832 | run_system(dut, buf); |
| 5833 | } else { |
| 5834 | run_system(dut, "cfg -a AP_SECMODE_2=None"); |
| 5835 | } |
| 5836 | break; |
| 5837 | case AP_WPA2_PSK: |
| 5838 | case AP_WPA2_PSK_MIXED: |
| 5839 | case AP_WPA_PSK: |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 5840 | case AP_WPA2_SAE: |
| 5841 | case AP_WPA2_PSK_SAE: |
| 5842 | if (dut->ap_key_mgmt == AP_WPA2_PSK || |
| 5843 | dut->ap_key_mgmt == AP_WPA2_SAE || |
| 5844 | dut->ap_key_mgmt == AP_WPA2_PSK_SAE) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5845 | run_system(dut, "cfg -a AP_WPA_2=2"); |
| 5846 | else if (dut->ap_key_mgmt == AP_WPA2_PSK_MIXED) |
| 5847 | run_system(dut, "cfg -a AP_WPA_2=3"); |
| 5848 | else |
| 5849 | run_system(dut, "cfg -a AP_WPA_2=1"); |
| 5850 | // run_system(dut, "cfg -a AP_WPA_2=2"); |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 5851 | /* TODO: SAE configuration */ |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5852 | run_system(dut, "cfg -a AP_SECMODE_2=WPA"); |
| 5853 | run_system(dut, "cfg -a AP_SECFILE_2=PSK"); |
| 5854 | snprintf(buf, sizeof(buf), "cfg -a 'PSK_KEY_2=%s'", |
| 5855 | dut->ap_passphrase); |
| 5856 | run_system(dut, buf); |
| 5857 | if (dut->ap_cipher == AP_CCMP_TKIP) |
| 5858 | run_system(dut, "cfg -a AP_CYPHER_2=\"CCMP TKIP\""); |
| 5859 | else if (dut->ap_cipher == AP_TKIP) |
| 5860 | run_system(dut, "cfg -a AP_CYPHER_2=TKIP"); |
| 5861 | else |
| 5862 | run_system(dut, "cfg -a AP_CYPHER_2=CCMP"); |
| 5863 | break; |
| 5864 | case AP_WPA2_EAP: |
| 5865 | case AP_WPA2_EAP_MIXED: |
| 5866 | case AP_WPA_EAP: |
| 5867 | if (dut->ap_key_mgmt == AP_WPA2_EAP) |
| 5868 | run_system(dut, "cfg -a AP_WPA_2=2"); |
| 5869 | else if (dut->ap_key_mgmt == AP_WPA2_EAP_MIXED) |
| 5870 | run_system(dut, "cfg -a AP_WPA_2=3"); |
| 5871 | else |
| 5872 | run_system(dut, "cfg -a AP_WPA_2=1"); |
| 5873 | run_system(dut, "cfg -a AP_SECMODE_2=WPA"); |
| 5874 | run_system(dut, "cfg -a AP_SECFILE_2=EAP"); |
| 5875 | if (dut->ap_cipher == AP_CCMP_TKIP) |
| 5876 | run_system(dut, "cfg -a AP_CYPHER_2=\"CCMP TKIP\""); |
| 5877 | else if (dut->ap_cipher == AP_TKIP) |
| 5878 | run_system(dut, "cfg -a AP_CYPHER_2=TKIP"); |
| 5879 | else |
| 5880 | run_system(dut, "cfg -a AP_CYPHER_2=CCMP"); |
| 5881 | |
| 5882 | snprintf(buf, sizeof(buf), "cfg -a AP_AUTH_SERVER_2=%s", |
| 5883 | dut->ap_radius_ipaddr); |
| 5884 | run_system(dut, buf); |
| 5885 | snprintf(buf, sizeof(buf), "cfg -a AP_AUTH_PORT_2=%d", |
| 5886 | dut->ap_radius_port); |
| 5887 | run_system(dut, buf); |
| 5888 | snprintf(buf, sizeof(buf), "cfg -a AP_AUTH_SECRET_2=%s", |
| 5889 | dut->ap_radius_password); |
| 5890 | run_system(dut, buf); |
| 5891 | break; |
Jouni Malinen | ad395a2 | 2017-09-01 21:13:46 +0300 | [diff] [blame] | 5892 | case AP_SUITEB: |
| 5893 | /* TODO */ |
| 5894 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5895 | "SuiteB not supported"); |
| 5896 | break; |
Jouni Malinen | 147b3c3 | 2017-10-09 16:51:54 +0300 | [diff] [blame] | 5897 | case AP_WPA2_OWE: |
| 5898 | /* TODO */ |
| 5899 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5900 | "OWE not supported"); |
| 5901 | break; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5902 | } |
| 5903 | |
| 5904 | /* wifi0 settings in case of dual */ |
| 5905 | run_system(dut, "cfg -a AP_RADIO_ID=0"); |
| 5906 | run_system(dut, "cfg -a AP_PRIMARY_CH=6"); |
| 5907 | run_system(dut, "cfg -a AP_STARTMODE=dual"); |
| 5908 | run_system(dut, "cfg -a AP_CHMODE=11NGHT40PLUS"); |
| 5909 | run_system(dut, "cfg -a TX_CHAINMASK=7"); |
| 5910 | run_system(dut, "cfg -a RX_CHAINMASK=7"); |
| 5911 | } |
| 5912 | |
| 5913 | switch (dut->ap_pmf) { |
| 5914 | case AP_PMF_DISABLED: |
| 5915 | snprintf(buf, sizeof(buf), "cfg -a AP_PMF=0"); |
| 5916 | run_system(dut, buf); |
| 5917 | break; |
| 5918 | case AP_PMF_OPTIONAL: |
| 5919 | snprintf(buf, sizeof(buf), "cfg -a AP_PMF=1"); |
| 5920 | run_system(dut, buf); |
| 5921 | break; |
| 5922 | case AP_PMF_REQUIRED: |
| 5923 | snprintf(buf, sizeof(buf), "cfg -a AP_PMF=2"); |
| 5924 | run_system(dut, buf); |
| 5925 | break; |
| 5926 | } |
| 5927 | if (dut->ap_add_sha256) { |
| 5928 | snprintf(buf, sizeof(buf), "cfg -a AP_WPA_SHA256=1"); |
| 5929 | run_system(dut, buf); |
| 5930 | } else { |
| 5931 | snprintf(buf, sizeof(buf), "cfg -r AP_WPA_SHA256"); |
| 5932 | run_system(dut, buf); |
| 5933 | } |
| 5934 | |
| 5935 | if (dut->ap_hs2) |
| 5936 | run_system(dut, "cfg -a AP_HOTSPOT=1"); |
| 5937 | else |
| 5938 | run_system(dut, "cfg -r AP_HOTSPOT"); |
| 5939 | |
| 5940 | if (dut->ap_interworking) { |
| 5941 | snprintf(buf, sizeof(buf), "cfg -a AP_HOTSPOT_ANT=%d", |
| 5942 | dut->ap_access_net_type); |
| 5943 | run_system(dut, buf); |
| 5944 | snprintf(buf, sizeof(buf), "cfg -a AP_HOTSPOT_INTERNET=%d", |
| 5945 | dut->ap_internet); |
| 5946 | run_system(dut, buf); |
| 5947 | snprintf(buf, sizeof(buf), "cfg -a AP_HOTSPOT_VENUEGROUP=%d", |
| 5948 | dut->ap_venue_group); |
| 5949 | run_system(dut, buf); |
| 5950 | snprintf(buf, sizeof(buf), "cfg -a AP_HOTSPOT_VENUETYPE=%d", |
| 5951 | dut->ap_venue_type); |
| 5952 | run_system(dut, buf); |
| 5953 | snprintf(buf, sizeof(buf), "cfg -a AP_HOTSPOT_HESSID=%s", |
| 5954 | dut->ap_hessid); |
| 5955 | run_system(dut, buf); |
| 5956 | |
| 5957 | if (dut->ap_roaming_cons[0]) { |
| 5958 | char *second, *rc; |
| 5959 | rc = strdup(dut->ap_roaming_cons); |
| 5960 | if (rc == NULL) |
| 5961 | return 0; |
| 5962 | |
| 5963 | second = strchr(rc, ';'); |
| 5964 | if (second) |
| 5965 | *second++ = '\0'; |
| 5966 | |
| 5967 | snprintf(buf, sizeof(buf), |
| 5968 | "cfg -a AP_HOTSPOT_ROAMINGCONSORTIUM=%s", rc); |
| 5969 | run_system(dut, buf); |
| 5970 | |
| 5971 | if (second) { |
| 5972 | snprintf(buf, sizeof(buf), |
| 5973 | "cfg -a AP_HOTSPOT_ROAMINGCONSORTIUM2" |
| 5974 | "=%s", second); |
| 5975 | run_system(dut, buf); |
| 5976 | } |
| 5977 | free(rc); |
| 5978 | } else { |
| 5979 | run_system(dut, "cfg -r AP_HOTSPOT_ROAMINGCONSORTIUM"); |
| 5980 | run_system(dut, |
| 5981 | "cfg -r AP_HOTSPOT_ROAMINGCONSORTIUM2"); |
| 5982 | } |
| 5983 | } else { |
| 5984 | run_system(dut, "cfg -r AP_HOTSPOT_ANT"); |
| 5985 | run_system(dut, "cfg -r AP_HOTSPOT_INTERNET"); |
| 5986 | run_system(dut, "cfg -r AP_HOTSPOT_VENUEGROUP"); |
| 5987 | run_system(dut, "cfg -r AP_HOTSPOT_VENUETYPE"); |
| 5988 | run_system(dut, "cfg -r AP_HOTSPOT_HESSID"); |
| 5989 | run_system(dut, "cfg -r AP_HOTSPOT_ROAMINGCONSORTIUM"); |
| 5990 | run_system(dut, "cfg -r AP_HOTSPOT_ROAMINGCONSORTIUM2"); |
| 5991 | } |
| 5992 | |
| 5993 | if (dut->ap_proxy_arp) |
| 5994 | run_system(dut, "cfg -a IEEE80211V_PROXYARP=1"); |
| 5995 | else |
| 5996 | run_system(dut, "cfg -a IEEE80211V_PROXYARP=0"); |
| 5997 | if (dut->ap_dgaf_disable) |
| 5998 | run_system(dut, "cfg -a AP_HOTSPOT_DISABLE_DGAF=1"); |
| 5999 | else |
| 6000 | run_system(dut, "cfg -r AP_HOTSPOT_DISABLE_DGAF"); |
| 6001 | |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 6002 | if (strlen(dut->ap_tag_ssid[0])) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6003 | snprintf(buf, sizeof(buf), |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 6004 | "cfg -a AP_SSID_2=%s", dut->ap_tag_ssid[0]); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6005 | run_system(dut, buf); |
| 6006 | |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 6007 | if (dut->ap_tag_key_mgmt[0] == AP2_OSEN) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6008 | run_system(dut, "cfg -a AP_SECMODE_2=WPA"); |
| 6009 | run_system(dut, "cfg -a AP_SECFILE_2=OSEN"); |
| 6010 | |
| 6011 | snprintf(buf, sizeof(buf), "cfg -a AP_AUTH_SERVER_2=%s", |
| 6012 | dut->ap2_radius_ipaddr); |
| 6013 | run_system(dut, buf); |
| 6014 | |
| 6015 | snprintf(buf, sizeof(buf), "cfg -a AP_AUTH_PORT_2=%d", |
| 6016 | dut->ap2_radius_port); |
| 6017 | run_system(dut, buf); |
| 6018 | |
| 6019 | snprintf(buf, sizeof(buf), "cfg -a AP_AUTH_SECRET_2=%s", |
| 6020 | dut->ap2_radius_password); |
| 6021 | run_system(dut, buf); |
| 6022 | } else { |
| 6023 | run_system(dut, "cfg -a AP_SECMODE_2=None"); |
| 6024 | run_system(dut, "cfg -r AP_AUTH_SERVER_2"); |
| 6025 | run_system(dut, "cfg -r AP_AUTH_PORT_2"); |
| 6026 | run_system(dut, "cfg -r AP_AUTH_SECRET_2"); |
| 6027 | } |
| 6028 | |
| 6029 | run_system(dut, "cfg -a AP_STARTMODE=multi"); |
| 6030 | } |
| 6031 | |
| 6032 | run_system(dut, "cfg -c"); |
| 6033 | |
| 6034 | sigma_dut_print(dut, DUT_MSG_INFO, "Starting AP"); |
| 6035 | if (system("apup") != 0) { |
| 6036 | /* to be debugged why apup returns error |
| 6037 | send_resp(dut, conn, SIGMA_ERROR, |
| 6038 | "errorCode,apup failed"); |
| 6039 | return 0; |
| 6040 | */ |
| 6041 | } |
| 6042 | sigma_dut_print(dut, DUT_MSG_INFO, "AP started"); |
| 6043 | |
| 6044 | if (dut->ap_key_mgmt != AP_OPEN) { |
| 6045 | int res; |
| 6046 | /* allow some time for hostapd to start before returning |
| 6047 | * success */ |
| 6048 | usleep(500000); |
| 6049 | if (run_hostapd_cli(dut, "ping") != 0) { |
| 6050 | send_resp(dut, conn, SIGMA_ERROR, |
| 6051 | "errorCode,Failed to talk to hostapd"); |
| 6052 | return 0; |
| 6053 | } |
| 6054 | |
| 6055 | if (dut->ap_hs2 && !dut->ap_anqpserver) { |
| 6056 | /* the cfg app doesn't like ";" in the variables */ |
| 6057 | res = ath_ap_append_hostapd_conf(dut); |
| 6058 | if (res < 0) |
| 6059 | return res; |
| 6060 | |
| 6061 | /* wait for hostapd to be ready */ |
| 6062 | usleep(500000); |
| 6063 | if (run_hostapd_cli(dut, "ping") != 0) { |
| 6064 | send_resp(dut, conn, SIGMA_ERROR, |
| 6065 | "errorCode,Failed to talk to " |
| 6066 | "hostapd"); |
| 6067 | return 0; |
| 6068 | } |
| 6069 | } |
| 6070 | } |
| 6071 | |
| 6072 | ath_ap_set_params(dut); |
| 6073 | |
| 6074 | if (dut->ap_anqpserver) |
| 6075 | return cmd_ath_ap_anqpserver_start(dut); |
| 6076 | |
| 6077 | if (dut->ap2_proxy_arp) |
| 6078 | run_system(dut, "iwpriv ath1 proxy_arp 1"); |
| 6079 | |
| 6080 | if (dut->ap_allow_vht_wep || dut->ap_allow_vht_tkip) { |
| 6081 | snprintf(buf, sizeof(buf), "iwpriv %s htweptkip 1", ifname); |
| 6082 | if (system(buf) != 0) { |
| 6083 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 6084 | "iwpriv htweptkip failed"); |
| 6085 | } |
| 6086 | } |
| 6087 | |
| 6088 | return 1; |
| 6089 | } |
| 6090 | |
| 6091 | |
| 6092 | static int set_ebtables_proxy_arp(struct sigma_dut *dut, const char *chain, |
| 6093 | const char *ifname) |
| 6094 | { |
| 6095 | char buf[200]; |
| 6096 | |
| 6097 | if (!chain || !ifname) |
| 6098 | return -2; |
| 6099 | |
| 6100 | snprintf(buf, sizeof(buf), "ebtables -P %s ACCEPT", chain); |
| 6101 | if (system(buf) != 0) { |
| 6102 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 6103 | "Failed to set ebtables rules, RULE-1, %s", |
| 6104 | chain); |
| 6105 | return -2; |
| 6106 | } |
| 6107 | |
| 6108 | snprintf(buf, sizeof(buf), |
| 6109 | "ebtables -A %s -p ARP -d Broadcast -o %s -j DROP", |
| 6110 | chain, ifname); |
| 6111 | if (system(buf) != 0) { |
| 6112 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 6113 | "Failed to set ebtables rules, RULE-2, %s", |
| 6114 | chain); |
| 6115 | return -2; |
| 6116 | } |
| 6117 | |
| 6118 | snprintf(buf, sizeof(buf), |
| 6119 | "ebtables -A %s -d Multicast -p IPv6 --ip6-protocol ipv6-icmp --ip6-icmp-type neighbor-solicitation -o %s -j DROP", |
| 6120 | chain, ifname); |
| 6121 | if (system(buf) != 0) { |
| 6122 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 6123 | "Failed to set ebtables rules, RULE-3, %s", |
| 6124 | chain); |
| 6125 | return -2; |
| 6126 | } |
| 6127 | |
| 6128 | snprintf(buf, sizeof(buf), |
| 6129 | "ebtables -A %s -d Multicast -p IPv6 --ip6-protocol ipv6-icmp --ip6-icmp-type neighbor-advertisement -o %s -j DROP", |
| 6130 | chain, ifname); |
| 6131 | if (system(buf) != 0) { |
| 6132 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 6133 | "Failed to set ebtables rules, RULE-4, %s", |
| 6134 | chain); |
| 6135 | return -2; |
| 6136 | } |
| 6137 | |
| 6138 | return 0; |
| 6139 | } |
| 6140 | |
| 6141 | |
| 6142 | static int set_ebtables_disable_dgaf(struct sigma_dut *dut, |
| 6143 | const char *chain, |
| 6144 | const char *ifname) |
| 6145 | { |
| 6146 | char buf[200]; |
| 6147 | |
| 6148 | if (!chain || !ifname) |
| 6149 | return -2; |
| 6150 | |
| 6151 | snprintf(buf, sizeof(buf), "ebtables -P %s ACCEPT", chain); |
| 6152 | if (system(buf) != 0) { |
| 6153 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 6154 | "Failed to set ebtables rules, RULE-5, %s", |
| 6155 | chain); |
| 6156 | return -2; |
| 6157 | } |
| 6158 | |
| 6159 | snprintf(buf, sizeof(buf), |
| 6160 | "ebtables -A %s -p ARP -d Broadcast -o %s -j DROP", |
| 6161 | chain, ifname); |
| 6162 | if (system(buf) != 0) { |
| 6163 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 6164 | "Failed to set ebtables rules, RULE-6, %s", |
| 6165 | chain); |
| 6166 | return -2; |
| 6167 | } |
| 6168 | |
| 6169 | snprintf(buf, sizeof(buf), |
| 6170 | "ebtables -A %s -p IPv4 -d Multicast -o %s -j DROP", |
| 6171 | chain, ifname); |
| 6172 | if (system(buf) != 0) { |
| 6173 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 6174 | "Failed to set ebtables rules, RULE-7, %s", |
| 6175 | chain); |
| 6176 | return -2; |
| 6177 | } |
| 6178 | |
| 6179 | snprintf(buf, sizeof(buf), |
| 6180 | "ebtables -A %s -p IPv6 -d Multicast -o %s -j DROP", |
| 6181 | chain, ifname); |
| 6182 | if (system(buf) != 0) { |
| 6183 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 6184 | "Failed to set ebtables rules, RULE-8, %s", |
| 6185 | chain); |
| 6186 | return -2; |
| 6187 | } |
| 6188 | |
| 6189 | return 0; |
| 6190 | } |
| 6191 | |
| 6192 | |
| 6193 | static int check_channel(int channel) |
| 6194 | { |
| 6195 | int channel_list[] = { 36, 40, 44, 48, 52, 60, 64, 100, 104, 108, 112, |
| 6196 | 116, 120, 124, 128, 132, 140, 144, 149, 153, 157, |
| 6197 | 161, 165 }; |
| 6198 | int num_chan = sizeof(channel_list) / sizeof(int); |
| 6199 | int i; |
| 6200 | |
| 6201 | for (i = 0; i < num_chan; i++) { |
| 6202 | if (channel == channel_list[i]) |
| 6203 | return i; |
| 6204 | } |
| 6205 | |
| 6206 | return -1; |
| 6207 | } |
| 6208 | |
| 6209 | |
| 6210 | static int get_oper_centr_freq_seq_idx(int chwidth, int channel) |
| 6211 | { |
| 6212 | int ch_base; |
| 6213 | int period; |
| 6214 | |
| 6215 | if (check_channel(channel) < 0) |
| 6216 | return -1; |
| 6217 | |
| 6218 | if (channel >= 36 && channel <= 64) |
| 6219 | ch_base = 36; |
| 6220 | else if (channel >= 100 && channel <= 144) |
| 6221 | ch_base = 100; |
| 6222 | else |
| 6223 | ch_base = 149; |
| 6224 | |
| 6225 | period = channel % ch_base * 5 / chwidth; |
| 6226 | return ch_base + period * chwidth / 5 + (chwidth - 20) / 10; |
| 6227 | } |
| 6228 | |
| 6229 | |
| 6230 | static int is_ht40plus_chan(int chan) |
| 6231 | { |
| 6232 | return chan == 36 || chan == 44 || chan == 52 || chan == 60 || |
| 6233 | chan == 100 || chan == 108 || chan == 116 || chan == 124 || |
| 6234 | chan == 132 || chan == 149 || chan == 157; |
| 6235 | } |
| 6236 | |
| 6237 | |
| 6238 | static int is_ht40minus_chan(int chan) |
| 6239 | { |
| 6240 | return chan == 40 || chan == 48 || chan == 56 || chan == 64 || |
| 6241 | chan == 104 || chan == 112 || chan == 120 || chan == 128 || |
| 6242 | chan == 136 || chan == 153 || chan == 161; |
| 6243 | } |
| 6244 | |
| 6245 | |
Mohammed Shafi Shajakhan | b53d8f9 | 2017-02-28 09:05:15 +0530 | [diff] [blame] | 6246 | static int get_5g_channel_freq(int chan) |
| 6247 | { |
| 6248 | return 5000 + chan * 5; |
| 6249 | } |
| 6250 | |
| 6251 | |
Jouni Malinen | 3d633da | 2017-09-14 22:19:21 +0300 | [diff] [blame] | 6252 | static const char * hostapd_cipher_name(enum ap_cipher cipher) |
| 6253 | { |
| 6254 | switch (cipher) { |
| 6255 | case AP_CCMP: |
| 6256 | return "CCMP"; |
| 6257 | case AP_TKIP: |
| 6258 | return "TKIP"; |
| 6259 | case AP_CCMP_TKIP: |
| 6260 | return "CCMP TKIP"; |
| 6261 | case AP_GCMP_256: |
| 6262 | return "GCMP-256"; |
| 6263 | case AP_GCMP_128: |
| 6264 | return "GCMP"; |
| 6265 | case AP_CCMP_256: |
| 6266 | return "CCMP-256"; |
Jouni Malinen | d538c78 | 2017-11-17 12:13:04 +0200 | [diff] [blame] | 6267 | case AP_CCMP_128_GCMP_256: |
| 6268 | return "CCMP GCMP-256"; |
Jouni Malinen | 3d633da | 2017-09-14 22:19:21 +0300 | [diff] [blame] | 6269 | default: |
| 6270 | return "UNKNOWN"; |
| 6271 | } |
| 6272 | } |
| 6273 | |
| 6274 | |
| 6275 | static const char * |
| 6276 | hostapd_group_mgmt_cipher_name(enum ap_group_mgmt_cipher cipher) |
| 6277 | { |
| 6278 | switch (cipher) { |
| 6279 | case AP_BIP_GMAC_256: |
Jouni Malinen | 57887a2 | 2017-10-10 20:43:25 +0300 | [diff] [blame] | 6280 | return "BIP-GMAC-256"; |
Jouni Malinen | 3d633da | 2017-09-14 22:19:21 +0300 | [diff] [blame] | 6281 | case AP_BIP_CMAC_256: |
| 6282 | return "BIP-CMAC-256"; |
| 6283 | case AP_BIP_GMAC_128: |
| 6284 | return "BIP-GMAC-128"; |
| 6285 | case AP_BIP_CMAC_128: |
| 6286 | return "AES-128-CMAC"; |
| 6287 | default: |
| 6288 | return "UNKNOWN"; |
| 6289 | } |
| 6290 | } |
| 6291 | |
| 6292 | |
Jouni Malinen | a326d7b | 2017-09-04 13:46:02 +0300 | [diff] [blame] | 6293 | int cmd_ap_config_commit(struct sigma_dut *dut, struct sigma_conn *conn, |
| 6294 | struct sigma_cmd *cmd) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6295 | { |
| 6296 | /* const char *name = get_param(cmd, "NAME"); */ |
| 6297 | FILE *f; |
| 6298 | const char *ifname; |
| 6299 | char buf[500]; |
| 6300 | char path[100]; |
| 6301 | enum driver_type drv; |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 6302 | const char *key_mgmt; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6303 | |
| 6304 | drv = get_driver_type(); |
| 6305 | |
| 6306 | if (dut->mode == SIGMA_MODE_STATION) { |
| 6307 | stop_sta_mode(dut); |
| 6308 | sleep(1); |
| 6309 | } |
| 6310 | |
| 6311 | if (dut->mode == SIGMA_MODE_SNIFFER && dut->sniffer_ifname) { |
| 6312 | snprintf(buf, sizeof(buf), "ifconfig %s down", |
| 6313 | dut->sniffer_ifname); |
| 6314 | if (system(buf) != 0) { |
| 6315 | sigma_dut_print(dut, DUT_MSG_INFO, |
| 6316 | "Failed to run '%s'", buf); |
| 6317 | } |
| 6318 | snprintf(buf, sizeof(buf), "iw dev %s set type station", |
| 6319 | dut->sniffer_ifname); |
| 6320 | if (system(buf) != 0) { |
| 6321 | sigma_dut_print(dut, DUT_MSG_INFO, |
| 6322 | "Failed to run '%s'", buf); |
| 6323 | } |
| 6324 | } |
| 6325 | |
| 6326 | dut->mode = SIGMA_MODE_AP; |
| 6327 | |
| 6328 | if (drv == DRIVER_ATHEROS) |
| 6329 | return cmd_ath_ap_config_commit(dut, conn, cmd); |
| 6330 | if (drv == DRIVER_WCN) |
| 6331 | return cmd_wcn_ap_config_commit(dut, conn, cmd); |
| 6332 | if (drv == DRIVER_OPENWRT) |
| 6333 | return cmd_owrt_ap_config_commit(dut, conn, cmd); |
| 6334 | |
| 6335 | f = fopen(SIGMA_TMPDIR "/sigma_dut-ap.conf", "w"); |
| 6336 | if (f == NULL) { |
| 6337 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 6338 | "%s: Failed to open sigma_dut-ap.conf", |
| 6339 | __func__); |
| 6340 | return -2; |
| 6341 | } |
| 6342 | switch (dut->ap_mode) { |
| 6343 | case AP_11g: |
| 6344 | case AP_11b: |
| 6345 | case AP_11ng: |
Pradeep Reddy Potteti | 08eaeba | 2017-06-14 12:43:19 +0530 | [diff] [blame] | 6346 | ifname = (drv == DRIVER_MAC80211) ? "wlan0" : "ath0"; |
| 6347 | if ((drv == DRIVER_QNXNTO || drv == DRIVER_LINUX_WCN) && |
| 6348 | sigma_main_ifname) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6349 | ifname = sigma_main_ifname; |
| 6350 | fprintf(f, "hw_mode=g\n"); |
| 6351 | break; |
| 6352 | case AP_11a: |
| 6353 | case AP_11na: |
| 6354 | case AP_11ac: |
Pradeep Reddy Potteti | 08eaeba | 2017-06-14 12:43:19 +0530 | [diff] [blame] | 6355 | if (drv == DRIVER_QNXNTO || drv == DRIVER_LINUX_WCN) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6356 | if (sigma_main_ifname) |
| 6357 | ifname = sigma_main_ifname; |
| 6358 | else |
| 6359 | ifname = "wlan0"; |
Pradeep Reddy Potteti | 08eaeba | 2017-06-14 12:43:19 +0530 | [diff] [blame] | 6360 | } else if (drv == DRIVER_MAC80211) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6361 | if (if_nametoindex("wlan1") > 0) |
| 6362 | ifname = "wlan1"; |
| 6363 | else |
| 6364 | ifname = "wlan0"; |
| 6365 | } else { |
| 6366 | ifname = get_main_ifname(); |
| 6367 | } |
| 6368 | fprintf(f, "hw_mode=a\n"); |
| 6369 | break; |
| 6370 | default: |
| 6371 | fclose(f); |
| 6372 | return -1; |
| 6373 | } |
Jouni Malinen | d6bf1b4 | 2017-06-23 17:51:01 +0300 | [diff] [blame] | 6374 | if (dut->hostapd_ifname) |
| 6375 | ifname = dut->hostapd_ifname; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6376 | |
Sreelakshmi Konamki | b692f10 | 2016-04-26 19:47:00 +0530 | [diff] [blame] | 6377 | if (drv == DRIVER_MAC80211 || drv == DRIVER_LINUX_WCN) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6378 | fprintf(f, "driver=nl80211\n"); |
| 6379 | |
Sreelakshmi Konamki | b692f10 | 2016-04-26 19:47:00 +0530 | [diff] [blame] | 6380 | if ((drv == DRIVER_MAC80211 || drv == DRIVER_QNXNTO || |
| 6381 | drv == DRIVER_LINUX_WCN) && |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6382 | (dut->ap_mode == AP_11ng || dut->ap_mode == AP_11na)) { |
Tamizh chelvam | 431c600 | 2017-03-07 17:07:16 +0530 | [diff] [blame] | 6383 | int ht40plus = 0, ht40minus = 0, tx_stbc = 0; |
| 6384 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6385 | fprintf(f, "ieee80211n=1\n"); |
Pradeep Reddy Potteti | bf8af29 | 2017-02-15 15:28:39 +0530 | [diff] [blame] | 6386 | if (dut->ap_mode == AP_11ng && |
| 6387 | (dut->ap_chwidth == AP_40 || |
| 6388 | (dut->ap_chwidth == AP_AUTO && |
| 6389 | dut->default_11ng_ap_chwidth == AP_40))) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6390 | if (dut->ap_channel >= 1 && dut->ap_channel <= 7) |
Tamizh chelvam | 431c600 | 2017-03-07 17:07:16 +0530 | [diff] [blame] | 6391 | ht40plus = 1; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6392 | else if (dut->ap_channel >= 8 && dut->ap_channel <= 11) |
Tamizh chelvam | 431c600 | 2017-03-07 17:07:16 +0530 | [diff] [blame] | 6393 | ht40minus = 1; |
| 6394 | fprintf(f, "obss_interval=300\n"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6395 | } |
| 6396 | |
| 6397 | /* configure ht_capab based on channel width */ |
| 6398 | if (dut->ap_mode == AP_11na && |
| 6399 | (dut->ap_chwidth == AP_40 || |
| 6400 | (dut->ap_chwidth == AP_AUTO && |
Pradeep Reddy Potteti | bf8af29 | 2017-02-15 15:28:39 +0530 | [diff] [blame] | 6401 | dut->default_11na_ap_chwidth == AP_40))) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6402 | if (is_ht40plus_chan(dut->ap_channel)) |
Tamizh chelvam | 431c600 | 2017-03-07 17:07:16 +0530 | [diff] [blame] | 6403 | ht40plus = 1; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6404 | else if (is_ht40minus_chan(dut->ap_channel)) |
Tamizh chelvam | 431c600 | 2017-03-07 17:07:16 +0530 | [diff] [blame] | 6405 | ht40minus = 1; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6406 | } |
Mohammed Shafi Shajakhan | 31d8a15 | 2016-06-02 20:10:55 +0530 | [diff] [blame] | 6407 | |
| 6408 | if (dut->ap_tx_stbc) |
Tamizh chelvam | 431c600 | 2017-03-07 17:07:16 +0530 | [diff] [blame] | 6409 | tx_stbc = 1; |
Mohammed Shafi Shajakhan | 31d8a15 | 2016-06-02 20:10:55 +0530 | [diff] [blame] | 6410 | |
Pradeep Reddy Potteti | 4b0cdee | 2017-03-15 12:37:33 +0530 | [diff] [blame] | 6411 | /* Overwrite the ht_capab with offset value if configured */ |
| 6412 | if (dut->ap_chwidth == AP_40 && |
| 6413 | dut->ap_chwidth_offset == SEC_CH_40ABOVE) { |
| 6414 | ht40plus = 1; |
| 6415 | ht40minus = 0; |
| 6416 | } else if (dut->ap_chwidth == AP_40 && |
| 6417 | dut->ap_chwidth_offset == SEC_CH_40BELOW) { |
| 6418 | ht40minus = 1; |
| 6419 | ht40plus = 0; |
| 6420 | } |
| 6421 | |
Tamizh chelvam | 431c600 | 2017-03-07 17:07:16 +0530 | [diff] [blame] | 6422 | fprintf(f, "ht_capab=%s%s%s\n", |
| 6423 | ht40plus ? "[HT40+]" : "", |
| 6424 | ht40minus ? "[HT40-]" : "", |
| 6425 | tx_stbc ? "[TX-STBC]" : ""); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6426 | } |
| 6427 | |
Sreelakshmi Konamki | b692f10 | 2016-04-26 19:47:00 +0530 | [diff] [blame] | 6428 | if ((drv == DRIVER_MAC80211 || drv == DRIVER_QNXNTO || |
| 6429 | drv == DRIVER_LINUX_WCN) && |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6430 | dut->ap_mode == AP_11ac) { |
| 6431 | fprintf(f, "ieee80211ac=1\n" |
| 6432 | "ieee80211n=1\n" |
| 6433 | "ht_capab=[HT40+]\n"); |
| 6434 | } |
| 6435 | |
Sreelakshmi Konamki | b692f10 | 2016-04-26 19:47:00 +0530 | [diff] [blame] | 6436 | if ((drv == DRIVER_MAC80211 || drv == DRIVER_QNXNTO || |
| 6437 | drv == DRIVER_LINUX_WCN) && |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6438 | (dut->ap_mode == AP_11ac || dut->ap_mode == AP_11na)) { |
| 6439 | if (dut->ap_countrycode[0]) { |
| 6440 | fprintf(f, "country_code=%s\n", dut->ap_countrycode); |
| 6441 | fprintf(f, "ieee80211d=1\n"); |
| 6442 | fprintf(f, "ieee80211h=1\n"); |
| 6443 | } |
| 6444 | } |
| 6445 | |
| 6446 | fprintf(f, "interface=%s\n", ifname); |
| 6447 | if (dut->bridge) |
| 6448 | fprintf(f, "bridge=%s\n", dut->bridge); |
| 6449 | fprintf(f, "channel=%d\n", dut->ap_channel); |
| 6450 | |
| 6451 | if (sigma_hapd_ctrl) |
| 6452 | fprintf(f, "ctrl_interface=%s\n", sigma_hapd_ctrl); |
| 6453 | else |
| 6454 | fprintf(f, "ctrl_interface=/var/run/hostapd\n"); |
| 6455 | |
| 6456 | if (dut->ap_ssid[0]) |
| 6457 | fprintf(f, "ssid=%s\n", dut->ap_ssid); |
| 6458 | else |
| 6459 | fprintf(f, "ssid=QCA AP OOB\n"); |
| 6460 | if (dut->ap_bcnint) |
| 6461 | fprintf(f, "beacon_int=%d\n", dut->ap_bcnint); |
| 6462 | |
| 6463 | switch (dut->ap_key_mgmt) { |
| 6464 | case AP_OPEN: |
| 6465 | if (dut->ap_cipher == AP_WEP) |
| 6466 | fprintf(f, "wep_key0=%s\n", dut->ap_wepkey); |
| 6467 | break; |
| 6468 | case AP_WPA2_PSK: |
| 6469 | case AP_WPA2_PSK_MIXED: |
| 6470 | case AP_WPA_PSK: |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 6471 | case AP_WPA2_SAE: |
| 6472 | case AP_WPA2_PSK_SAE: |
| 6473 | if (dut->ap_key_mgmt == AP_WPA2_PSK || |
| 6474 | dut->ap_key_mgmt == AP_WPA2_SAE || |
| 6475 | dut->ap_key_mgmt == AP_WPA2_PSK_SAE) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6476 | fprintf(f, "wpa=2\n"); |
| 6477 | else if (dut->ap_key_mgmt == AP_WPA2_PSK_MIXED) |
| 6478 | fprintf(f, "wpa=3\n"); |
| 6479 | else |
| 6480 | fprintf(f, "wpa=1\n"); |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 6481 | if (dut->ap_key_mgmt == AP_WPA2_SAE) |
| 6482 | key_mgmt = "SAE"; |
| 6483 | else if (dut->ap_key_mgmt == AP_WPA2_PSK_SAE) |
| 6484 | key_mgmt = "WPA-PSK SAE"; |
| 6485 | else |
| 6486 | key_mgmt = "WPA-PSK"; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6487 | switch (dut->ap_pmf) { |
| 6488 | case AP_PMF_DISABLED: |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 6489 | fprintf(f, "wpa_key_mgmt=%s%s\n", key_mgmt, |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6490 | dut->ap_add_sha256 ? " WPA-PSK-SHA256" : ""); |
| 6491 | break; |
| 6492 | case AP_PMF_OPTIONAL: |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 6493 | fprintf(f, "wpa_key_mgmt=%s%s\n", key_mgmt, |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6494 | dut->ap_add_sha256 ? " WPA-PSK-SHA256" : ""); |
| 6495 | break; |
| 6496 | case AP_PMF_REQUIRED: |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 6497 | if (dut->ap_key_mgmt == AP_WPA2_SAE) |
| 6498 | key_mgmt = "SAE"; |
| 6499 | else if (dut->ap_key_mgmt == AP_WPA2_PSK_SAE) |
| 6500 | key_mgmt = "WPA-PSK-SHA256 SAE"; |
| 6501 | else |
| 6502 | key_mgmt = "WPA-PSK-SHA256"; |
| 6503 | fprintf(f, "wpa_key_mgmt=%s\n", key_mgmt); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6504 | break; |
| 6505 | } |
Jouni Malinen | 2ba2449 | 2017-11-17 12:43:59 +0200 | [diff] [blame] | 6506 | fprintf(f, "wpa_pairwise=%s\n", |
| 6507 | hostapd_cipher_name(dut->ap_cipher)); |
| 6508 | if (dut->ap_group_cipher != AP_NO_GROUP_CIPHER_SET) |
| 6509 | fprintf(f, "group_cipher=%s\n", |
| 6510 | hostapd_cipher_name(dut->ap_group_cipher)); |
Jouni Malinen | 2126f42 | 2017-10-11 23:24:33 +0300 | [diff] [blame] | 6511 | if (dut->ap_key_mgmt == AP_WPA2_SAE) |
| 6512 | fprintf(f, "sae_password=%s\n", dut->ap_passphrase); |
Jouni Malinen | 6337062 | 2017-11-18 17:47:13 +0200 | [diff] [blame] | 6513 | else if (!dut->ap_passphrase[0] && dut->ap_psk[0]) |
| 6514 | fprintf(f, "wpa_psk=%s", dut->ap_psk); |
Jouni Malinen | 2126f42 | 2017-10-11 23:24:33 +0300 | [diff] [blame] | 6515 | else |
| 6516 | fprintf(f, "wpa_passphrase=%s\n", dut->ap_passphrase); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6517 | break; |
| 6518 | case AP_WPA2_EAP: |
| 6519 | case AP_WPA2_EAP_MIXED: |
| 6520 | case AP_WPA_EAP: |
| 6521 | fprintf(f, "ieee8021x=1\n"); |
| 6522 | if (dut->ap_key_mgmt == AP_WPA2_EAP) |
| 6523 | fprintf(f, "wpa=2\n"); |
| 6524 | else if (dut->ap_key_mgmt == AP_WPA2_EAP_MIXED) |
| 6525 | fprintf(f, "wpa=3\n"); |
| 6526 | else |
| 6527 | fprintf(f, "wpa=1\n"); |
| 6528 | switch (dut->ap_pmf) { |
| 6529 | case AP_PMF_DISABLED: |
| 6530 | fprintf(f, "wpa_key_mgmt=WPA-EAP%s\n", |
| 6531 | dut->ap_add_sha256 ? " WPA-EAP-SHA256" : ""); |
| 6532 | break; |
| 6533 | case AP_PMF_OPTIONAL: |
| 6534 | fprintf(f, "wpa_key_mgmt=WPA-EAP%s\n", |
| 6535 | dut->ap_add_sha256 ? " WPA-EAP-SHA256" : ""); |
| 6536 | break; |
| 6537 | case AP_PMF_REQUIRED: |
| 6538 | fprintf(f, "wpa_key_mgmt=WPA-EAP-SHA256\n"); |
| 6539 | break; |
| 6540 | } |
Jouni Malinen | 2ba2449 | 2017-11-17 12:43:59 +0200 | [diff] [blame] | 6541 | fprintf(f, "wpa_pairwise=%s\n", |
| 6542 | hostapd_cipher_name(dut->ap_cipher)); |
| 6543 | if (dut->ap_group_cipher != AP_NO_GROUP_CIPHER_SET) |
| 6544 | fprintf(f, "group_cipher=%s\n", |
| 6545 | hostapd_cipher_name(dut->ap_group_cipher)); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6546 | fprintf(f, "auth_server_addr=%s\n", dut->ap_radius_ipaddr); |
| 6547 | if (dut->ap_radius_port) |
| 6548 | fprintf(f, "auth_server_port=%d\n", |
| 6549 | dut->ap_radius_port); |
| 6550 | fprintf(f, "auth_server_shared_secret=%s\n", |
| 6551 | dut->ap_radius_password); |
| 6552 | break; |
Jouni Malinen | ad395a2 | 2017-09-01 21:13:46 +0300 | [diff] [blame] | 6553 | case AP_SUITEB: |
| 6554 | fprintf(f, "ieee8021x=1\n"); |
| 6555 | fprintf(f, "wpa=2\n"); |
| 6556 | fprintf(f, "wpa_key_mgmt=WPA-EAP-SUITE-B-192\n"); |
Jouni Malinen | 3d633da | 2017-09-14 22:19:21 +0300 | [diff] [blame] | 6557 | fprintf(f, "wpa_pairwise=%s\n", |
| 6558 | hostapd_cipher_name(dut->ap_cipher)); |
Jouni Malinen | 2ba2449 | 2017-11-17 12:43:59 +0200 | [diff] [blame] | 6559 | if (dut->ap_group_cipher != AP_NO_GROUP_CIPHER_SET) |
| 6560 | fprintf(f, "group_cipher=%s\n", |
| 6561 | hostapd_cipher_name(dut->ap_group_cipher)); |
Jouni Malinen | 3d633da | 2017-09-14 22:19:21 +0300 | [diff] [blame] | 6562 | if (dut->ap_group_mgmt_cipher != AP_NO_GROUP_MGMT_CIPHER_SET) |
| 6563 | fprintf(f, "group_mgmt_cipher=%s\n", |
| 6564 | hostapd_group_mgmt_cipher_name( |
| 6565 | dut->ap_group_mgmt_cipher)); |
Jouni Malinen | ad395a2 | 2017-09-01 21:13:46 +0300 | [diff] [blame] | 6566 | fprintf(f, "auth_server_addr=%s\n", dut->ap_radius_ipaddr); |
| 6567 | if (dut->ap_radius_port) |
| 6568 | fprintf(f, "auth_server_port=%d\n", |
| 6569 | dut->ap_radius_port); |
| 6570 | fprintf(f, "auth_server_shared_secret=%s\n", |
| 6571 | dut->ap_radius_password); |
| 6572 | break; |
Jouni Malinen | 147b3c3 | 2017-10-09 16:51:54 +0300 | [diff] [blame] | 6573 | case AP_WPA2_OWE: |
| 6574 | fprintf(f, "wpa=2\n"); |
| 6575 | fprintf(f, "wpa_key_mgmt=OWE\n"); |
| 6576 | fprintf(f, "rsn_pairwise=%s\n", |
| 6577 | hostapd_cipher_name(dut->ap_cipher)); |
Jouni Malinen | 72461d4 | 2017-10-10 19:20:45 +0300 | [diff] [blame] | 6578 | if (dut->ap_sae_groups) |
| 6579 | fprintf(f, "owe_groups=%s\n", dut->ap_sae_groups); |
Jouni Malinen | 147b3c3 | 2017-10-09 16:51:54 +0300 | [diff] [blame] | 6580 | break; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6581 | } |
| 6582 | |
Anilkumar Kolli | f0fd599 | 2017-02-23 12:54:01 +0530 | [diff] [blame] | 6583 | if (dut->ap_rsn_preauth) |
| 6584 | fprintf(f, "rsn_preauth=1\n"); |
| 6585 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6586 | switch (dut->ap_pmf) { |
| 6587 | case AP_PMF_DISABLED: |
| 6588 | break; |
| 6589 | case AP_PMF_OPTIONAL: |
| 6590 | fprintf(f, "ieee80211w=1\n"); |
Jouni Malinen | 1287cd7 | 2018-01-04 17:08:01 +0200 | [diff] [blame] | 6591 | if (dut->ap_key_mgmt == AP_WPA2_PSK_SAE) |
| 6592 | fprintf(f, "sae_require_mfp=1\n"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6593 | break; |
| 6594 | case AP_PMF_REQUIRED: |
| 6595 | fprintf(f, "ieee80211w=2\n"); |
| 6596 | break; |
| 6597 | } |
| 6598 | |
Jouni Malinen | 3c367e8 | 2017-06-23 17:01:47 +0300 | [diff] [blame] | 6599 | if (dut->rsne_override) |
| 6600 | fprintf(f, "own_ie_override=%s\n", dut->rsne_override); |
| 6601 | |
Jouni Malinen | 6814313 | 2017-09-02 02:34:08 +0300 | [diff] [blame] | 6602 | if (dut->sae_commit_override) |
| 6603 | fprintf(f, "sae_commit_override=%s\n", |
| 6604 | dut->sae_commit_override); |
| 6605 | |
Jouni Malinen | ed670f4 | 2017-08-31 01:39:28 +0300 | [diff] [blame] | 6606 | if (dut->ap_sae_groups) |
| 6607 | fprintf(f, "sae_groups=%s\n", dut->ap_sae_groups); |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 6608 | |
Jouni Malinen | 2f524ce | 2017-08-31 01:43:29 +0300 | [diff] [blame] | 6609 | if (dut->sae_anti_clogging_threshold >= 0) |
| 6610 | fprintf(f, "sae_anti_clogging_threshold=%d\n", |
| 6611 | dut->sae_anti_clogging_threshold); |
Jouni Malinen | b347db0 | 2017-09-02 01:36:03 +0300 | [diff] [blame] | 6612 | if (dut->sae_reflection) |
| 6613 | fprintf(f, "sae_reflection_attack=1\n"); |
Jouni Malinen | 2f524ce | 2017-08-31 01:43:29 +0300 | [diff] [blame] | 6614 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6615 | if (dut->ap_p2p_mgmt) |
| 6616 | fprintf(f, "manage_p2p=1\n"); |
| 6617 | |
| 6618 | if (dut->ap_tdls_prohibit || dut->ap_l2tif) |
| 6619 | fprintf(f, "tdls_prohibit=1\n"); |
| 6620 | if (dut->ap_tdls_prohibit_chswitch || dut->ap_l2tif) |
| 6621 | fprintf(f, "tdls_prohibit_chan_switch=1\n"); |
| 6622 | if (dut->ap_p2p_cross_connect >= 0) { |
| 6623 | fprintf(f, "manage_p2p=1\n" |
| 6624 | "allow_cross_connection=%d\n", |
| 6625 | dut->ap_p2p_cross_connect); |
| 6626 | } |
| 6627 | |
| 6628 | if (dut->ap_l2tif || dut->ap_proxy_arp) { |
| 6629 | if (!dut->bridge) { |
| 6630 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 6631 | "Bridge must be configured. Run with -b <brname>."); |
| 6632 | fclose(f); |
| 6633 | return -2; |
| 6634 | } |
| 6635 | fprintf(f, "ap_isolate=1\n"); |
| 6636 | } |
| 6637 | |
| 6638 | if (dut->ap_proxy_arp) |
| 6639 | fprintf(f, "proxy_arp=1\n"); |
| 6640 | |
Pradeep Reddy POTTETI | 0d3db63 | 2016-03-11 15:21:11 +0530 | [diff] [blame] | 6641 | if (dut->ap_wme) |
| 6642 | fprintf(f, "wmm_enabled=1\n"); |
| 6643 | |
Mohammed Shafi Shajakhan | 02e3b82 | 2017-02-23 04:15:02 +0530 | [diff] [blame] | 6644 | if (dut->ap_wmmps == AP_WMMPS_ON) |
| 6645 | fprintf(f, "uapsd_advertisement_enabled=1\n"); |
| 6646 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6647 | if (dut->ap_hs2) { |
| 6648 | if (dut->ap_bss_load) { |
| 6649 | char *bss_load; |
| 6650 | |
| 6651 | switch (dut->ap_bss_load) { |
| 6652 | case -1: |
| 6653 | bss_load = "bss_load_update_period=10"; |
| 6654 | break; |
| 6655 | case 1: |
| 6656 | /* STA count: 1, CU: 50, AAC: 65535 */ |
| 6657 | bss_load = "bss_load_test=1:50:65535"; |
| 6658 | break; |
| 6659 | case 2: |
| 6660 | /* STA count: 1, CU: 200, AAC: 65535 */ |
| 6661 | bss_load = "bss_load_test=1:200:65535"; |
| 6662 | break; |
| 6663 | case 3: |
| 6664 | /* STA count: 1, CU: 75, AAC: 65535 */ |
| 6665 | bss_load = "bss_load_test=1:75:65535"; |
| 6666 | break; |
| 6667 | default: |
| 6668 | bss_load = NULL; |
| 6669 | break; |
| 6670 | } |
| 6671 | |
| 6672 | if (!bss_load) { |
| 6673 | fclose(f); |
| 6674 | return -2; |
| 6675 | } |
| 6676 | fprintf(f, "%s\n", bss_load); |
| 6677 | } |
| 6678 | |
| 6679 | if (append_hostapd_conf_hs2(dut, f)) { |
| 6680 | fclose(f); |
| 6681 | return -2; |
| 6682 | } |
| 6683 | } |
| 6684 | |
| 6685 | if (dut->ap_interworking && append_hostapd_conf_interworking(dut, f)) { |
| 6686 | fclose(f); |
| 6687 | return -2; |
| 6688 | } |
| 6689 | |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 6690 | if (dut->ap_hs2 && strlen(dut->ap_tag_ssid[0])) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6691 | unsigned char bssid[6]; |
| 6692 | char ifname2[50]; |
| 6693 | |
Pradeep Reddy POTTETI | 673d85c | 2016-07-26 19:08:07 +0530 | [diff] [blame] | 6694 | if (get_hwaddr(ifname, bssid)) { |
| 6695 | fclose(f); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6696 | return -2; |
Pradeep Reddy POTTETI | 673d85c | 2016-07-26 19:08:07 +0530 | [diff] [blame] | 6697 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6698 | bssid[0] |= 0x02; |
| 6699 | |
| 6700 | snprintf(ifname2, sizeof(ifname2), "%s_1", ifname); |
| 6701 | fprintf(f, "bss=%s_1\n", ifname2); |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 6702 | fprintf(f, "ssid=%s\n", dut->ap_tag_ssid[0]); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6703 | if (dut->bridge) |
| 6704 | fprintf(f, "bridge=%s\n", dut->bridge); |
| 6705 | fprintf(f, "bssid=%02x:%02x:%02x:%02x:%02x:%02x\n", |
| 6706 | bssid[0], bssid[1], bssid[2], bssid[3], |
| 6707 | bssid[4], bssid[5]); |
| 6708 | |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 6709 | if (dut->ap_tag_key_mgmt[0] == AP2_OSEN) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6710 | fprintf(f, "osen=1\n"); |
| 6711 | if (strlen(dut->ap2_radius_ipaddr)) |
| 6712 | fprintf(f, "auth_server_addr=%s\n", |
| 6713 | dut->ap2_radius_ipaddr); |
| 6714 | if (dut->ap2_radius_port) |
| 6715 | fprintf(f, "auth_server_port=%d\n", |
| 6716 | dut->ap2_radius_port); |
| 6717 | if (strlen(dut->ap2_radius_password)) |
| 6718 | fprintf(f, "auth_server_shared_secret=%s\n", |
| 6719 | dut->ap2_radius_password); |
| 6720 | } |
| 6721 | |
| 6722 | if (dut->ap2_proxy_arp) { |
| 6723 | if (!dut->bridge) { |
| 6724 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 6725 | "Bridge must be configured. Run with -b <brname>."); |
| 6726 | fclose(f); |
| 6727 | return -2; |
| 6728 | } |
| 6729 | fprintf(f, "ap_isolate=1\n"); |
| 6730 | fprintf(f, "proxy_arp=1\n"); |
| 6731 | |
| 6732 | if (set_ebtables_proxy_arp(dut, "FORWARD", ifname2) || |
| 6733 | set_ebtables_proxy_arp(dut, "OUTPUT", ifname2)) { |
| 6734 | fclose(f); |
| 6735 | return -2; |
| 6736 | } |
| 6737 | |
| 6738 | } |
| 6739 | } |
| 6740 | |
| 6741 | if (dut->program == PROGRAM_WPS) { |
| 6742 | fprintf(f, "eap_server=1\n" |
| 6743 | "wps_state=1\n" |
| 6744 | "device_name=QCA AP\n" |
| 6745 | "manufacturer=QCA\n" |
| 6746 | "device_type=6-0050F204-1\n" |
| 6747 | "config_methods=label virtual_display " |
| 6748 | "virtual_push_button keypad%s\n" |
| 6749 | "ap_pin=12345670\n" |
| 6750 | "friendly_name=QCA Access Point\n" |
| 6751 | "upnp_iface=%s\n", |
| 6752 | dut->ap_wpsnfc ? " nfc_interface ext_nfc_token" : "", |
| 6753 | dut->bridge ? dut->bridge : ifname); |
| 6754 | } |
| 6755 | |
| 6756 | if (dut->program == PROGRAM_VHT) { |
| 6757 | int vht_oper_centr_freq_idx; |
| 6758 | |
| 6759 | if (check_channel(dut->ap_channel) < 0) { |
| 6760 | send_resp(dut, conn, SIGMA_INVALID, |
| 6761 | "errorCode,Invalid channel"); |
Pradeep Reddy POTTETI | 673d85c | 2016-07-26 19:08:07 +0530 | [diff] [blame] | 6762 | fclose(f); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6763 | return 0; |
| 6764 | } |
| 6765 | |
| 6766 | switch (dut->ap_chwidth) { |
| 6767 | case AP_20: |
| 6768 | dut->ap_vht_chwidth = AP_20_40_VHT_OPER_CHWIDTH; |
| 6769 | vht_oper_centr_freq_idx = |
| 6770 | get_oper_centr_freq_seq_idx(20, |
| 6771 | dut->ap_channel); |
| 6772 | break; |
| 6773 | case AP_40: |
| 6774 | dut->ap_vht_chwidth = AP_20_40_VHT_OPER_CHWIDTH; |
| 6775 | vht_oper_centr_freq_idx = |
| 6776 | get_oper_centr_freq_seq_idx(40, |
| 6777 | dut->ap_channel); |
| 6778 | break; |
| 6779 | case AP_80: |
| 6780 | dut->ap_vht_chwidth = AP_80_VHT_OPER_CHWIDTH; |
| 6781 | vht_oper_centr_freq_idx = |
| 6782 | get_oper_centr_freq_seq_idx(80, |
| 6783 | dut->ap_channel); |
| 6784 | break; |
| 6785 | case AP_160: |
| 6786 | dut->ap_vht_chwidth = AP_160_VHT_OPER_CHWIDTH; |
| 6787 | vht_oper_centr_freq_idx = |
| 6788 | get_oper_centr_freq_seq_idx(160, |
| 6789 | dut->ap_channel); |
| 6790 | break; |
| 6791 | default: |
| 6792 | dut->ap_vht_chwidth = VHT_DEFAULT_OPER_CHWIDTH; |
| 6793 | vht_oper_centr_freq_idx = |
| 6794 | get_oper_centr_freq_seq_idx(80, |
| 6795 | dut->ap_channel); |
| 6796 | break; |
| 6797 | } |
| 6798 | fprintf(f, "vht_oper_centr_freq_seg0_idx=%d\n", |
| 6799 | vht_oper_centr_freq_idx); |
| 6800 | fprintf(f, "vht_oper_chwidth=%d\n", dut->ap_vht_chwidth); |
| 6801 | |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 6802 | if (dut->ap_sgi80 || dut->ap_txBF || |
| 6803 | dut->ap_ldpc != VALUE_NOT_SET || |
Mohammed Shafi Shajakhan | f3e68d9 | 2016-06-02 20:10:57 +0530 | [diff] [blame] | 6804 | dut->ap_tx_stbc || dut->ap_mu_txBF) { |
| 6805 | fprintf(f, "vht_capab=%s%s%s%s%s\n", |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6806 | dut->ap_sgi80 ? "[SHORT-GI-80]" : "", |
Mohammed Shafi Shajakhan | c039ce3 | 2016-06-02 20:10:58 +0530 | [diff] [blame] | 6807 | dut->ap_txBF ? |
Tamizh chelvam | 8312f6d | 2016-06-02 20:10:59 +0530 | [diff] [blame] | 6808 | "[SU-BEAMFORMER][SU-BEAMFORMEE][BF-ANTENNA-2][SOUNDING-DIMENSION-2]" : "", |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 6809 | (dut->ap_ldpc == VALUE_ENABLED) ? |
| 6810 | "[RXLDPC]" : "", |
Mohammed Shafi Shajakhan | f3e68d9 | 2016-06-02 20:10:57 +0530 | [diff] [blame] | 6811 | dut->ap_tx_stbc ? "[TX-STBC-2BY1]" : "", |
| 6812 | dut->ap_mu_txBF ? "[MU-BEAMFORMER]" : ""); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6813 | } |
| 6814 | } |
| 6815 | |
Jouni Malinen | 6d1d739 | 2017-10-10 20:35:29 +0300 | [diff] [blame] | 6816 | if (dut->ap_key_mgmt == AP_WPA2_OWE && dut->ap_tag_ssid[0][0] && |
| 6817 | dut->ap_tag_key_mgmt[0] == AP2_OPEN) { |
| 6818 | /* OWE transition mode */ |
| 6819 | unsigned char bssid[6]; |
| 6820 | char ifname2[50]; |
| 6821 | unsigned long val; |
| 6822 | FILE *f2; |
| 6823 | |
| 6824 | snprintf(ifname2, sizeof(ifname2), "%s_1", ifname); |
| 6825 | |
| 6826 | fprintf(f, "owe_transition_ifname=%s\n", ifname2); |
| 6827 | val = 0x12345678; /* default to something */ |
| 6828 | f2 = fopen("/dev/urandom", "r"); |
| 6829 | if (f2) { |
| 6830 | if (fread(&val, 1, sizeof(val), f2) != sizeof(val)) { |
| 6831 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 6832 | "Could not read /dev/urandom"); |
| 6833 | } |
| 6834 | fclose(f2); |
| 6835 | } |
| 6836 | fprintf(f, "ssid=owe-%lx\n", val); |
| 6837 | |
| 6838 | if (get_hwaddr(ifname, bssid)) { |
| 6839 | fclose(f); |
| 6840 | return -2; |
| 6841 | } |
| 6842 | if (bssid[0] & 0x02) |
| 6843 | bssid[5] ^= 0x01; |
| 6844 | else |
| 6845 | bssid[0] |= 0x02; |
| 6846 | |
| 6847 | fprintf(f, "bss=%s\n", ifname2); |
| 6848 | fprintf(f, "ssid=%s\n", dut->ap_ssid); |
| 6849 | if (dut->bridge) |
| 6850 | fprintf(f, "bridge=%s\n", dut->bridge); |
| 6851 | fprintf(f, "bssid=%02x:%02x:%02x:%02x:%02x:%02x\n", |
| 6852 | bssid[0], bssid[1], bssid[2], bssid[3], |
| 6853 | bssid[4], bssid[5]); |
| 6854 | fprintf(f, "owe_transition_ifname=%s\n", ifname); |
| 6855 | } |
| 6856 | |
Jouni Malinen | 353ba8b | 2018-01-10 17:04:12 +0200 | [diff] [blame] | 6857 | if (dut->ap_key_mgmt == AP_OPEN && |
| 6858 | dut->ap_tag_key_mgmt[0] == AP2_WPA2_OWE) { |
| 6859 | /* OWE transition mode */ |
| 6860 | unsigned char bssid[6]; |
| 6861 | char ifname2[50]; |
| 6862 | unsigned long val; |
| 6863 | FILE *f2; |
| 6864 | |
| 6865 | snprintf(ifname2, sizeof(ifname2), "%s_1", ifname); |
| 6866 | |
| 6867 | fprintf(f, "owe_transition_ifname=%s\n", ifname2); |
| 6868 | fprintf(f, "ssid=%s\n", dut->ap_ssid); |
| 6869 | |
| 6870 | if (get_hwaddr(ifname, bssid)) { |
| 6871 | fclose(f); |
| 6872 | return -2; |
| 6873 | } |
| 6874 | if (bssid[0] & 0x02) |
| 6875 | bssid[5] ^= 0x01; |
| 6876 | else |
| 6877 | bssid[0] |= 0x02; |
| 6878 | |
| 6879 | fprintf(f, "bss=%s\n", ifname2); |
| 6880 | val = 0x12345678; /* default to something */ |
| 6881 | f2 = fopen("/dev/urandom", "r"); |
| 6882 | if (f2) { |
| 6883 | if (fread(&val, 1, sizeof(val), f2) != sizeof(val)) { |
| 6884 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 6885 | "Could not read /dev/urandom"); |
| 6886 | } |
| 6887 | fclose(f2); |
| 6888 | } |
| 6889 | fprintf(f, "ssid=owe-%lx\n", val); |
| 6890 | if (dut->bridge) |
| 6891 | fprintf(f, "bridge=%s\n", dut->bridge); |
| 6892 | fprintf(f, "bssid=%02x:%02x:%02x:%02x:%02x:%02x\n", |
| 6893 | bssid[0], bssid[1], bssid[2], bssid[3], |
| 6894 | bssid[4], bssid[5]); |
| 6895 | fprintf(f, "owe_transition_ifname=%s\n", ifname); |
| 6896 | fprintf(f, "wpa=2\n"); |
| 6897 | fprintf(f, "wpa_key_mgmt=OWE\n"); |
| 6898 | fprintf(f, "rsn_pairwise=CCMP\n"); |
| 6899 | fprintf(f, "ieee80211w=2\n"); |
| 6900 | if (dut->ap_sae_groups) |
| 6901 | fprintf(f, "owe_groups=%s\n", dut->ap_sae_groups); |
| 6902 | } |
| 6903 | |
Ankita Bajaj | 0d5825b | 2017-10-25 16:20:17 +0530 | [diff] [blame] | 6904 | if (dut->program == PROGRAM_OCE) { |
| 6905 | fprintf(f, "oce=%d\n", |
| 6906 | dut->dev_role == DEVROLE_STA_CFON ? 2 : 1); |
| 6907 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6908 | fclose(f); |
Jouni Malinen | d6bf1b4 | 2017-06-23 17:51:01 +0300 | [diff] [blame] | 6909 | if (dut->use_hostapd_pid_file) |
| 6910 | kill_hostapd_process_pid(dut); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6911 | #ifdef __QNXNTO__ |
| 6912 | if (system("slay hostapd") == 0) |
| 6913 | #else /* __QNXNTO__ */ |
Jouni Malinen | d6bf1b4 | 2017-06-23 17:51:01 +0300 | [diff] [blame] | 6914 | if (!dut->use_hostapd_pid_file && |
| 6915 | (kill_process(dut, "(hostapd)", 1, SIGTERM) == 0 || |
| 6916 | system("killall hostapd") == 0)) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6917 | #endif /* __QNXNTO__ */ |
| 6918 | { |
| 6919 | int i; |
| 6920 | /* Wait some time to allow hostapd to complete cleanup before |
| 6921 | * starting a new process */ |
| 6922 | for (i = 0; i < 10; i++) { |
| 6923 | usleep(500000); |
| 6924 | #ifdef __QNXNTO__ |
| 6925 | if (system("pidin | grep hostapd") != 0) |
| 6926 | break; |
| 6927 | #else /* __QNXNTO__ */ |
| 6928 | if (system("pidof hostapd") != 0) |
| 6929 | break; |
| 6930 | #endif /* __QNXNTO__ */ |
| 6931 | } |
| 6932 | } |
Jouni Malinen | d86e582 | 2017-08-29 03:55:32 +0300 | [diff] [blame] | 6933 | dut->hostapd_running = 0; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6934 | |
Pradeep Reddy POTTETI | a076c30 | 2016-05-16 13:36:07 +0530 | [diff] [blame] | 6935 | #ifdef ANDROID |
| 6936 | /* Set proper conf file permissions so that hostapd process |
| 6937 | * can access it. |
| 6938 | */ |
| 6939 | if (chmod(SIGMA_TMPDIR "/sigma_dut-ap.conf", |
| 6940 | S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP) < 0) |
| 6941 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 6942 | "Error changing permissions"); |
| 6943 | |
| 6944 | if (chown(SIGMA_TMPDIR "/sigma_dut-ap.conf", -1, AID_WIFI) < 0) |
| 6945 | sigma_dut_print(dut, DUT_MSG_ERROR, "Error changing groupid"); |
| 6946 | #endif /* ANDROID */ |
| 6947 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6948 | if (drv == DRIVER_QNXNTO) { |
| 6949 | snprintf(buf, sizeof(buf), |
Pradeep Reddy POTTETI | bf4a974 | 2016-02-04 12:32:30 +0530 | [diff] [blame] | 6950 | "hostapd -B %s%s %s%s" SIGMA_TMPDIR |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6951 | "/sigma_dut-ap.conf", |
| 6952 | dut->hostapd_debug_log ? "-ddKt -f " : "", |
| 6953 | dut->hostapd_debug_log ? dut->hostapd_debug_log : "", |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6954 | dut->hostapd_entropy_log ? " -e" : "", |
| 6955 | dut->hostapd_entropy_log ? dut->hostapd_entropy_log : |
| 6956 | ""); |
| 6957 | } else { |
| 6958 | /* |
| 6959 | * It looks like a monitor interface can cause some issues for |
| 6960 | * beaconing, so remove it (if injection was used) before |
| 6961 | * starting hostapd. |
| 6962 | */ |
| 6963 | if (if_nametoindex("sigmadut") > 0 && |
| 6964 | system("iw dev sigmadut del") != 0) |
| 6965 | sigma_dut_print(dut, DUT_MSG_ERROR, "Failed to remove " |
| 6966 | "monitor interface"); |
| 6967 | |
Jouni Malinen | d6bf1b4 | 2017-06-23 17:51:01 +0300 | [diff] [blame] | 6968 | snprintf(path, sizeof(path), "%shostapd", |
| 6969 | file_exists("hostapd") ? "./" : ""); |
| 6970 | 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] | 6971 | "/sigma_dut-ap.conf", |
Jouni Malinen | d6bf1b4 | 2017-06-23 17:51:01 +0300 | [diff] [blame] | 6972 | dut->hostapd_bin ? dut->hostapd_bin : path, |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6973 | dut->hostapd_debug_log ? " -ddKt -f" : "", |
| 6974 | dut->hostapd_debug_log ? dut->hostapd_debug_log : "", |
| 6975 | dut->hostapd_entropy_log ? " -e" : "", |
| 6976 | dut->hostapd_entropy_log ? dut->hostapd_entropy_log : |
Jouni Malinen | d6bf1b4 | 2017-06-23 17:51:01 +0300 | [diff] [blame] | 6977 | "", |
| 6978 | dut->use_hostapd_pid_file ? |
| 6979 | " -P " SIGMA_DUT_HOSTAPD_PID_FILE : ""); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6980 | } |
| 6981 | |
Jouni Malinen | d6bf1b4 | 2017-06-23 17:51:01 +0300 | [diff] [blame] | 6982 | sigma_dut_print(dut, DUT_MSG_DEBUG, "hostapd command: %s", buf); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6983 | if (system(buf) != 0) { |
| 6984 | send_resp(dut, conn, SIGMA_ERROR, |
| 6985 | "errorCode,Failed to start hostapd"); |
| 6986 | return 0; |
| 6987 | } |
| 6988 | |
| 6989 | /* allow some time for hostapd to start before returning success */ |
| 6990 | usleep(500000); |
| 6991 | if (run_hostapd_cli(dut, "ping") != 0) { |
| 6992 | send_resp(dut, conn, SIGMA_ERROR, |
| 6993 | "errorCode,Failed to talk to hostapd"); |
| 6994 | return 0; |
| 6995 | } |
| 6996 | |
Pradeep Reddy Potteti | 923a9b3 | 2017-06-14 12:18:59 +0530 | [diff] [blame] | 6997 | if (drv == DRIVER_LINUX_WCN) { |
| 6998 | sigma_dut_print(dut, DUT_MSG_INFO, "setting ip addr %s mask %s", |
| 6999 | ap_inet_addr, ap_inet_mask); |
| 7000 | snprintf(buf, sizeof(buf), "ifconfig %s %s netmask %s up", |
| 7001 | ifname, ap_inet_addr, ap_inet_mask); |
| 7002 | if (system(buf) != 0) { |
| 7003 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 7004 | "Failed to initialize the interface"); |
| 7005 | return -1; |
| 7006 | } |
| 7007 | } |
| 7008 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7009 | if (dut->ap_l2tif) { |
| 7010 | snprintf(path, sizeof(path), |
| 7011 | "/sys/class/net/%s/brport/hairpin_mode", |
| 7012 | ifname); |
| 7013 | if (!file_exists(path)) { |
| 7014 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 7015 | "%s must be binded to the bridge for L2TIF", |
| 7016 | ifname); |
| 7017 | return -2; |
| 7018 | } |
| 7019 | |
| 7020 | snprintf(buf, sizeof(buf), "echo 1 > %s", path); |
| 7021 | if (system(buf) != 0) { |
| 7022 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 7023 | "Failed to enable hairpin_mode for L2TIF"); |
| 7024 | return -2; |
| 7025 | } |
| 7026 | |
| 7027 | snprintf(buf, sizeof(buf), "ebtables -P FORWARD ACCEPT"); |
| 7028 | if (system(buf) != 0) { |
| 7029 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 7030 | "Failed to set ebtables rules, RULE-9"); |
| 7031 | return -2; |
| 7032 | } |
| 7033 | |
| 7034 | snprintf(buf, sizeof(buf), |
| 7035 | "ebtables -A FORWARD -p IPv4 --ip-proto icmp -i %s -j DROP", |
| 7036 | ifname); |
| 7037 | if (system(buf) != 0) { |
| 7038 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 7039 | "Failed to set ebtables rules, RULE-11"); |
| 7040 | return -2; |
| 7041 | } |
| 7042 | } |
| 7043 | |
| 7044 | if (dut->ap_proxy_arp) { |
| 7045 | if (dut->ap_dgaf_disable) { |
| 7046 | if (set_ebtables_disable_dgaf(dut, "FORWARD", ifname) || |
| 7047 | set_ebtables_disable_dgaf(dut, "OUTPUT", ifname)) |
| 7048 | return -2; |
| 7049 | } else { |
| 7050 | if (set_ebtables_proxy_arp(dut, "FORWARD", ifname) || |
| 7051 | set_ebtables_proxy_arp(dut, "OUTPUT", ifname)) |
| 7052 | return -2; |
| 7053 | } |
| 7054 | |
| 7055 | /* For 4.5-(c) */ |
| 7056 | snprintf(buf, sizeof(buf), |
| 7057 | "ebtables -A FORWARD -p ARP --arp-opcode 2 -i %s -j DROP", |
| 7058 | ifname); |
| 7059 | if (system(buf) != 0) { |
| 7060 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 7061 | "Failed to set ebtables rules, RULE-10"); |
| 7062 | return -2; |
| 7063 | } |
| 7064 | } |
| 7065 | |
| 7066 | if (dut->ap_tdls_prohibit || dut->ap_l2tif) { |
| 7067 | /* Drop TDLS frames */ |
| 7068 | snprintf(buf, sizeof(buf), |
| 7069 | "ebtables -A FORWARD -p 0x890d -i %s -j DROP", ifname); |
| 7070 | if (system(buf) != 0) { |
| 7071 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 7072 | "Failed to set ebtables rules, RULE-13"); |
| 7073 | return -2; |
| 7074 | } |
| 7075 | } |
| 7076 | |
| 7077 | if (dut->ap_fake_pkhash && |
| 7078 | run_hostapd_cli(dut, "set wps_corrupt_pkhash 1") != 0) { |
| 7079 | send_resp(dut, conn, SIGMA_ERROR, |
| 7080 | "errorCode,Could not enable FakePubKey"); |
| 7081 | return 0; |
| 7082 | } |
| 7083 | |
Jouni Malinen | d86e582 | 2017-08-29 03:55:32 +0300 | [diff] [blame] | 7084 | dut->hostapd_running = 1; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7085 | return 1; |
| 7086 | } |
| 7087 | |
| 7088 | |
Pradeep Reddy POTTETI | eff4611 | 2016-10-13 17:22:03 +0530 | [diff] [blame] | 7089 | static int parse_qos_params(struct sigma_dut *dut, struct sigma_conn *conn, |
| 7090 | struct qos_params *qos, const char *cwmin, |
| 7091 | const char *cwmax, const char *aifs, |
| 7092 | const char *txop, const char *acm) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7093 | { |
Pradeep Reddy POTTETI | eff4611 | 2016-10-13 17:22:03 +0530 | [diff] [blame] | 7094 | int val; |
| 7095 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7096 | if (cwmin) { |
| 7097 | qos->ac = 1; |
Pradeep Reddy POTTETI | eff4611 | 2016-10-13 17:22:03 +0530 | [diff] [blame] | 7098 | val = atoi(cwmin); |
| 7099 | if (val < 0 || val > 15) { |
| 7100 | send_resp(dut, conn, SIGMA_INVALID, |
| 7101 | "errorCode,Invalid cwMin"); |
| 7102 | return 0; |
| 7103 | } |
| 7104 | qos->cwmin = val; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7105 | } |
| 7106 | |
| 7107 | if (cwmax) { |
| 7108 | qos->ac = 1; |
Pradeep Reddy POTTETI | eff4611 | 2016-10-13 17:22:03 +0530 | [diff] [blame] | 7109 | val = atoi(cwmax); |
| 7110 | if (val < 0 || val > 15) { |
| 7111 | send_resp(dut, conn, SIGMA_INVALID, |
| 7112 | "errorCode,Invalid cwMax"); |
| 7113 | return 0; |
| 7114 | } |
| 7115 | qos->cwmax = val; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7116 | } |
| 7117 | |
| 7118 | if (aifs) { |
| 7119 | qos->ac = 1; |
Pradeep Reddy POTTETI | eff4611 | 2016-10-13 17:22:03 +0530 | [diff] [blame] | 7120 | val = atoi(aifs); |
| 7121 | if (val < 1 || val > 255) { |
| 7122 | send_resp(dut, conn, SIGMA_INVALID, |
| 7123 | "errorCode,Invalid AIFS"); |
| 7124 | return 0; |
| 7125 | } |
| 7126 | qos->aifs = val; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7127 | } |
| 7128 | |
| 7129 | if (txop) { |
| 7130 | qos->ac = 1; |
Pradeep Reddy POTTETI | eff4611 | 2016-10-13 17:22:03 +0530 | [diff] [blame] | 7131 | val = atoi(txop); |
| 7132 | if (val < 0 || val > 0xffff) { |
| 7133 | send_resp(dut, conn, SIGMA_INVALID, |
| 7134 | "errorCode,Invalid txop"); |
| 7135 | return 0; |
| 7136 | } |
| 7137 | qos->txop = val * 32; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7138 | } |
| 7139 | |
| 7140 | if (acm) { |
| 7141 | qos->ac = 1; |
| 7142 | qos->acm = strcasecmp(acm, "on") == 0; |
| 7143 | } |
Pradeep Reddy POTTETI | eff4611 | 2016-10-13 17:22:03 +0530 | [diff] [blame] | 7144 | |
| 7145 | return 1; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7146 | } |
| 7147 | |
| 7148 | |
| 7149 | static int cmd_ap_set_apqos(struct sigma_dut *dut, struct sigma_conn *conn, |
| 7150 | struct sigma_cmd *cmd) |
| 7151 | { |
| 7152 | /* TXOP: The values provided here for VHT5G only */ |
Pradeep Reddy POTTETI | eff4611 | 2016-10-13 17:22:03 +0530 | [diff] [blame] | 7153 | if (!parse_qos_params(dut, conn, &dut->ap_qos[AP_AC_VO], |
| 7154 | get_param(cmd, "cwmin_VO"), |
| 7155 | get_param(cmd, "cwmax_VO"), |
| 7156 | get_param(cmd, "AIFS_VO"), |
| 7157 | get_param(cmd, "TXOP_VO"), |
| 7158 | get_param(cmd, "ACM_VO")) || |
| 7159 | !parse_qos_params(dut, conn, &dut->ap_qos[AP_AC_VI], |
| 7160 | get_param(cmd, "cwmin_VI"), |
| 7161 | get_param(cmd, "cwmax_VI"), |
| 7162 | get_param(cmd, "AIFS_VI"), |
| 7163 | get_param(cmd, "TXOP_VI"), |
| 7164 | get_param(cmd, "ACM_VI")) || |
| 7165 | !parse_qos_params(dut, conn, &dut->ap_qos[AP_AC_BE], |
| 7166 | get_param(cmd, "cwmin_BE"), |
| 7167 | get_param(cmd, "cwmax_BE"), |
| 7168 | get_param(cmd, "AIFS_BE"), |
| 7169 | get_param(cmd, "TXOP_BE"), |
| 7170 | get_param(cmd, "ACM_BE")) || |
| 7171 | !parse_qos_params(dut, conn, &dut->ap_qos[AP_AC_BK], |
| 7172 | get_param(cmd, "cwmin_BK"), |
| 7173 | get_param(cmd, "cwmax_BK"), |
| 7174 | get_param(cmd, "AIFS_BK"), |
| 7175 | get_param(cmd, "TXOP_BK"), |
| 7176 | get_param(cmd, "ACM_BK"))) |
| 7177 | return 0; |
| 7178 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7179 | return 1; |
| 7180 | } |
| 7181 | |
| 7182 | |
| 7183 | static int cmd_ap_set_staqos(struct sigma_dut *dut, struct sigma_conn *conn, |
| 7184 | struct sigma_cmd *cmd) |
| 7185 | { |
Pradeep Reddy POTTETI | eff4611 | 2016-10-13 17:22:03 +0530 | [diff] [blame] | 7186 | if (!parse_qos_params(dut, conn, &dut->ap_sta_qos[AP_AC_VO], |
| 7187 | get_param(cmd, "cwmin_VO"), |
| 7188 | get_param(cmd, "cwmax_VO"), |
| 7189 | get_param(cmd, "AIFS_VO"), |
| 7190 | get_param(cmd, "TXOP_VO"), |
| 7191 | get_param(cmd, "ACM_VO")) || |
| 7192 | !parse_qos_params(dut, conn, &dut->ap_sta_qos[AP_AC_VI], |
| 7193 | get_param(cmd, "cwmin_VI"), |
| 7194 | get_param(cmd, "cwmax_VI"), |
| 7195 | get_param(cmd, "AIFS_VI"), |
| 7196 | get_param(cmd, "TXOP_VI"), |
| 7197 | get_param(cmd, "ACM_VI")) || |
| 7198 | !parse_qos_params(dut, conn, &dut->ap_sta_qos[AP_AC_BE], |
| 7199 | get_param(cmd, "cwmin_BE"), |
| 7200 | get_param(cmd, "cwmax_BE"), |
| 7201 | get_param(cmd, "AIFS_BE"), |
| 7202 | get_param(cmd, "TXOP_BE"), |
| 7203 | get_param(cmd, "ACM_BE")) || |
| 7204 | !parse_qos_params(dut, conn, &dut->ap_sta_qos[AP_AC_BK], |
| 7205 | get_param(cmd, "cwmin_BK"), |
| 7206 | get_param(cmd, "cwmax_BK"), |
| 7207 | get_param(cmd, "AIFS_BK"), |
| 7208 | get_param(cmd, "TXOP_BK"), |
| 7209 | get_param(cmd, "ACM_BK"))) |
| 7210 | return 0; |
| 7211 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7212 | return 1; |
| 7213 | } |
| 7214 | |
| 7215 | |
| 7216 | static void cmd_ath_ap_hs2_reset(struct sigma_dut *dut) |
| 7217 | { |
| 7218 | unsigned char bssid[6]; |
| 7219 | char buf[100]; |
| 7220 | run_system(dut, "cfg -a AP_SSID=\"Hotspot 2.0\""); |
| 7221 | run_system(dut, "cfg -a AP_PRIMARY_CH=1"); |
| 7222 | run_system(dut, "cfg -a AP_SECMODE=WPA"); |
| 7223 | run_system(dut, "cfg -a AP_SECFILE=EAP"); |
| 7224 | run_system(dut, "cfg -a AP_WPA=2"); |
| 7225 | run_system(dut, "cfg -a AP_CYPHER=CCMP"); |
| 7226 | run_system(dut, "cfg -a AP_HOTSPOT=1"); |
| 7227 | run_system(dut, "cfg -a AP_HOTSPOT_ANT=2"); |
| 7228 | run_system(dut, "cfg -a AP_HOTSPOT_INTERNET=0"); |
| 7229 | run_system(dut, "cfg -a AP_HOTSPOT_VENUEGROUP=2"); |
| 7230 | run_system(dut, "cfg -a AP_HOTSPOT_VENUETYPE=8"); |
| 7231 | run_system(dut, "cfg -a AP_HOTSPOT_ROAMINGCONSORTIUM=506f9a"); |
| 7232 | run_system(dut, "cfg -a AP_HOTSPOT_ROAMINGCONSORTIUM2=001bc504bd"); |
| 7233 | if (!get_hwaddr("ath0", bssid)) { |
| 7234 | snprintf(buf, sizeof(buf), "cfg -a AP_HOTSPOT_HESSID=" |
| 7235 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 7236 | bssid[0], bssid[1], bssid[2], bssid[3], |
| 7237 | bssid[4], bssid[5]); |
| 7238 | run_system(dut, buf); |
| 7239 | snprintf(dut->ap_hessid, sizeof(dut->ap_hessid), |
| 7240 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 7241 | bssid[0], bssid[1], bssid[2], bssid[3], |
| 7242 | bssid[4], bssid[5]); |
| 7243 | } else { |
| 7244 | if (!get_hwaddr("wifi0", bssid)) { |
| 7245 | snprintf(buf, sizeof(buf), "cfg -a AP_HOTSPOT_HESSID=" |
| 7246 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 7247 | bssid[0], bssid[1], bssid[2], bssid[3], |
| 7248 | bssid[4], bssid[5]); |
| 7249 | run_system(dut, buf); |
| 7250 | snprintf(dut->ap_hessid, sizeof(dut->ap_hessid), |
| 7251 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 7252 | bssid[0], bssid[1], bssid[2], bssid[3], |
| 7253 | bssid[4], bssid[5]); |
| 7254 | } else { |
| 7255 | /* load the driver and try again */ |
| 7256 | run_system(dut, "/etc/rc.d/rc.wlan up"); |
| 7257 | |
| 7258 | if (!get_hwaddr("wifi0", bssid)) { |
| 7259 | snprintf(buf, sizeof(buf), |
| 7260 | "cfg -a AP_HOTSPOT_HESSID=" |
| 7261 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 7262 | bssid[0], bssid[1], bssid[2], |
| 7263 | bssid[3], bssid[4], bssid[5]); |
| 7264 | run_system(dut, buf); |
| 7265 | snprintf(dut->ap_hessid, |
| 7266 | sizeof(dut->ap_hessid), |
| 7267 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 7268 | bssid[0], bssid[1], bssid[2], |
| 7269 | bssid[3], bssid[4], bssid[5]); |
| 7270 | } |
| 7271 | } |
| 7272 | } |
| 7273 | |
| 7274 | run_system(dut, "cfg -r AP_SSID_2"); |
| 7275 | run_system(dut, "cfg -c"); |
| 7276 | /* run_system(dut, "cfg -s"); */ |
| 7277 | } |
| 7278 | |
| 7279 | |
| 7280 | static void ath_reset_vht_defaults(struct sigma_dut *dut) |
| 7281 | { |
| 7282 | run_system(dut, "cfg -x"); |
| 7283 | run_system(dut, "cfg -a AP_RADIO_ID=1"); |
| 7284 | run_system(dut, "cfg -a AP_PRIMARY_CH_2=36"); |
| 7285 | run_system(dut, "cfg -a AP_STARTMODE=standard"); |
| 7286 | run_system(dut, "cfg -a AP_CHMODE_2=11ACVHT80"); |
| 7287 | run_system(dut, "cfg -a TX_CHAINMASK_2=7"); |
| 7288 | run_system(dut, "cfg -a RX_CHAINMASK_2=7"); |
| 7289 | run_system(dut, "cfg -a ATH_countrycode=0x348"); |
| 7290 | /* NOTE: For Beeliner we have to turn off MU-MIMO */ |
| 7291 | if (system("rm /tmp/secath*") != 0) { |
| 7292 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 7293 | "Failed to remove secath file"); |
| 7294 | } |
| 7295 | } |
| 7296 | |
| 7297 | |
| 7298 | static int cmd_ap_reset_default(struct sigma_dut *dut, struct sigma_conn *conn, |
| 7299 | struct sigma_cmd *cmd) |
| 7300 | { |
Ankita Bajaj | 0d5825b | 2017-10-25 16:20:17 +0530 | [diff] [blame] | 7301 | const char *type, *program; |
Pradeep Reddy POTTETI | 83b8067 | 2016-09-02 13:01:44 +0530 | [diff] [blame] | 7302 | enum driver_type drv; |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 7303 | int i; |
| 7304 | |
| 7305 | for (i = 0; i < MAX_WLAN_TAGS - 1; i++) { |
| 7306 | /* |
| 7307 | * Reset all tagged SSIDs to NULL-string and all key management |
| 7308 | * to open. |
| 7309 | */ |
| 7310 | dut->ap_tag_ssid[i][0] = '\0'; |
| 7311 | dut->ap_tag_key_mgmt[i] = AP2_OPEN; |
| 7312 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7313 | |
Pradeep Reddy POTTETI | 83b8067 | 2016-09-02 13:01:44 +0530 | [diff] [blame] | 7314 | drv = get_driver_type(); |
Ankita Bajaj | 0d5825b | 2017-10-25 16:20:17 +0530 | [diff] [blame] | 7315 | |
| 7316 | program = get_param(cmd, "program"); |
| 7317 | if (!program) |
| 7318 | program = get_param(cmd, "prog"); |
| 7319 | dut->program = sigma_program_to_enum(program); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7320 | dut->device_type = AP_unknown; |
| 7321 | type = get_param(cmd, "type"); |
| 7322 | if (type && strcasecmp(type, "Testbed") == 0) |
| 7323 | dut->device_type = AP_testbed; |
| 7324 | if (type && strcasecmp(type, "DUT") == 0) |
| 7325 | dut->device_type = AP_dut; |
| 7326 | |
| 7327 | dut->ap_rts = 0; |
| 7328 | dut->ap_frgmnt = 0; |
| 7329 | dut->ap_bcnint = 0; |
| 7330 | dut->ap_key_mgmt = AP_OPEN; |
| 7331 | dut->ap_ssid[0] = '\0'; |
| 7332 | dut->ap_fake_pkhash = 0; |
| 7333 | memset(dut->ap_qos, 0, sizeof(dut->ap_qos)); |
| 7334 | memset(dut->ap_sta_qos, 0, sizeof(dut->ap_sta_qos)); |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 7335 | dut->ap_addba_reject = VALUE_NOT_SET; |
| 7336 | dut->ap_noack = VALUE_NOT_SET; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7337 | dut->ap_is_dual = 0; |
| 7338 | dut->ap_mode = AP_inval; |
| 7339 | dut->ap_mode_1 = AP_inval; |
| 7340 | |
| 7341 | dut->ap_allow_vht_wep = 0; |
| 7342 | dut->ap_allow_vht_tkip = 0; |
| 7343 | dut->ap_disable_protection = 0; |
| 7344 | memset(dut->ap_countrycode, 0, sizeof(dut->ap_countrycode)); |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 7345 | dut->ap_dyn_bw_sig = VALUE_NOT_SET; |
| 7346 | dut->ap_ldpc = VALUE_NOT_SET; |
| 7347 | dut->ap_sig_rts = VALUE_NOT_SET; |
| 7348 | dut->ap_rx_amsdu = VALUE_NOT_SET; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7349 | dut->ap_txBF = 0; |
Mohammed Shafi Shajakhan | 495fdb2 | 2016-06-02 20:10:56 +0530 | [diff] [blame] | 7350 | dut->ap_mu_txBF = 0; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7351 | dut->ap_chwidth = AP_AUTO; |
| 7352 | |
Sarvepalli, Rajesh Babu | 24dc7e4 | 2016-03-18 21:27:26 +0530 | [diff] [blame] | 7353 | dut->ap_rsn_preauth = 0; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7354 | dut->ap_wpsnfc = 0; |
| 7355 | dut->ap_bss_load = -1; |
| 7356 | dut->ap_p2p_cross_connect = -1; |
| 7357 | |
Pradeep Reddy POTTETI | fba27db | 2015-11-20 16:42:22 +0530 | [diff] [blame] | 7358 | dut->ap_regulatory_mode = AP_80211D_MODE_DISABLED; |
| 7359 | dut->ap_dfs_mode = AP_DFS_MODE_DISABLED; |
Pradeep Reddy Potteti | 4b0cdee | 2017-03-15 12:37:33 +0530 | [diff] [blame] | 7360 | dut->ap_chwidth_offset = SEC_CH_NO; |
Pradeep Reddy POTTETI | fba27db | 2015-11-20 16:42:22 +0530 | [diff] [blame] | 7361 | |
Adil Saeed Musthafa | 6906372 | 2017-04-10 23:13:40 -0700 | [diff] [blame] | 7362 | dut->mbo_pref_ap_cnt = 0; |
Adil Saeed Musthafa | 4ec61bd | 2017-04-10 23:13:41 -0700 | [diff] [blame] | 7363 | dut->ft_bss_mac_cnt = 0; |
priyadharshini gowthaman | 09d613e | 2017-12-20 11:43:44 -0800 | [diff] [blame] | 7364 | dut->ap_interface_5g = 0; |
| 7365 | dut->ap_interface_2g = 0; |
priyadharshini gowthaman | a3fe8c6 | 2018-01-26 15:19:41 -0800 | [diff] [blame] | 7366 | dut->ap_pmf = AP_PMF_DISABLED; |
Adil Saeed Musthafa | 6906372 | 2017-04-10 23:13:40 -0700 | [diff] [blame] | 7367 | |
Mohammed Shafi Shajakhan | 02e3b82 | 2017-02-23 04:15:02 +0530 | [diff] [blame] | 7368 | if (dut->program == PROGRAM_HT || dut->program == PROGRAM_VHT) { |
Pradeep Reddy POTTETI | 0d3db63 | 2016-03-11 15:21:11 +0530 | [diff] [blame] | 7369 | dut->ap_wme = AP_WME_ON; |
Mohammed Shafi Shajakhan | 02e3b82 | 2017-02-23 04:15:02 +0530 | [diff] [blame] | 7370 | dut->ap_wmmps = AP_WMMPS_ON; |
| 7371 | } else { |
Pradeep Reddy POTTETI | 0d3db63 | 2016-03-11 15:21:11 +0530 | [diff] [blame] | 7372 | dut->ap_wme = AP_WME_OFF; |
Mohammed Shafi Shajakhan | 02e3b82 | 2017-02-23 04:15:02 +0530 | [diff] [blame] | 7373 | dut->ap_wmmps = AP_WMMPS_OFF; |
| 7374 | } |
Pradeep Reddy POTTETI | 0d3db63 | 2016-03-11 15:21:11 +0530 | [diff] [blame] | 7375 | |
Adil Saeed Musthafa | 33ea287 | 2017-04-10 23:13:24 -0700 | [diff] [blame] | 7376 | if (dut->program == PROGRAM_HS2 || dut->program == PROGRAM_HS2_R2 || |
| 7377 | dut->program == PROGRAM_IOTLP) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7378 | int i; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7379 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7380 | if (drv == DRIVER_ATHEROS) |
| 7381 | cmd_ath_ap_hs2_reset(dut); |
| 7382 | else if (drv == DRIVER_OPENWRT) |
| 7383 | cmd_owrt_ap_hs2_reset(dut); |
| 7384 | |
| 7385 | dut->ap_interworking = 1; |
| 7386 | dut->ap_access_net_type = 2; |
| 7387 | dut->ap_internet = 0; |
| 7388 | dut->ap_venue_group = 2; |
| 7389 | dut->ap_venue_type = 8; |
| 7390 | dut->ap_domain_name_list[0] = '\0'; |
| 7391 | dut->ap_hs2 = 1; |
| 7392 | snprintf(dut->ap_roaming_cons, sizeof(dut->ap_roaming_cons), |
| 7393 | "506f9a;001bc504bd"); |
| 7394 | dut->ap_l2tif = 0; |
| 7395 | dut->ap_proxy_arp = 0; |
| 7396 | if (dut->bridge) { |
| 7397 | char buf[50]; |
| 7398 | |
| 7399 | snprintf(buf, sizeof(buf), "ip neigh flush dev %s", |
| 7400 | dut->bridge); |
| 7401 | if (system(buf) != 0) { |
| 7402 | sigma_dut_print(dut, DUT_MSG_DEBUG, |
| 7403 | "%s ip neigh table flushing failed", |
| 7404 | dut->bridge); |
| 7405 | } |
| 7406 | |
| 7407 | snprintf(buf, sizeof(buf), "ebtables -F"); |
| 7408 | if (system(buf) != 0) { |
| 7409 | sigma_dut_print(dut, DUT_MSG_DEBUG, |
| 7410 | "%s ebtables flushing failed", |
| 7411 | dut->bridge); |
| 7412 | } |
| 7413 | } |
| 7414 | dut->ap_dgaf_disable = 0; |
| 7415 | dut->ap_p2p_cross_connect = 0; |
| 7416 | dut->ap_gas_cb_delay = 0; |
| 7417 | dut->ap_nai_realm_list = 0; |
| 7418 | dut->ap_oper_name = 0; |
| 7419 | dut->ap_venue_name = 0; |
| 7420 | for (i = 0; i < 10; i++) { |
| 7421 | dut->ap_plmn_mcc[i][0] = '\0'; |
| 7422 | dut->ap_plmn_mnc[i][0] = '\0'; |
| 7423 | } |
| 7424 | dut->ap_wan_metrics = 0; |
| 7425 | dut->ap_conn_capab = 0; |
| 7426 | dut->ap_ip_addr_type_avail = 0; |
| 7427 | dut->ap_net_auth_type = 0; |
| 7428 | dut->ap_oper_class = 0; |
| 7429 | dut->ap_pmf = 0; |
| 7430 | dut->ap_add_sha256 = 0; |
| 7431 | } |
| 7432 | |
Adil Saeed Musthafa | 33ea287 | 2017-04-10 23:13:24 -0700 | [diff] [blame] | 7433 | if (dut->program == PROGRAM_HS2_R2 || dut->program == PROGRAM_IOTLP) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7434 | int i; |
| 7435 | const char hessid[] = "50:6f:9a:00:11:22"; |
| 7436 | |
| 7437 | memcpy(dut->ap_hessid, hessid, strlen(hessid) + 1); |
| 7438 | dut->ap_osu_ssid[0] = '\0'; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7439 | dut->ap_pmf = 1; |
| 7440 | dut->ap_osu_provider_list = 0; |
| 7441 | for (i = 0; i < 10; i++) { |
| 7442 | dut->ap_osu_server_uri[i][0] = '\0'; |
| 7443 | dut->ap_osu_method[i] = 0xFF; |
| 7444 | } |
| 7445 | dut->ap_qos_map_set = 0; |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 7446 | dut->ap_tag_key_mgmt[0] = AP2_OPEN; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7447 | dut->ap2_proxy_arp = 0; |
| 7448 | dut->ap_osu_icon_tag = 0; |
| 7449 | } |
| 7450 | |
| 7451 | if (dut->program == PROGRAM_VHT) { |
| 7452 | /* Set up the defaults */ |
| 7453 | dut->ap_mode = AP_11ac; |
| 7454 | dut->ap_channel = 36; |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 7455 | dut->ap_ampdu = VALUE_NOT_SET; |
priyadharshini gowthaman | 264d544 | 2016-02-25 15:52:22 -0800 | [diff] [blame] | 7456 | dut->ap_ndpa_frame = 1; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7457 | if (dut->device_type == AP_testbed) { |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 7458 | dut->ap_amsdu = VALUE_DISABLED; |
| 7459 | dut->ap_ldpc = VALUE_DISABLED; |
| 7460 | dut->ap_rx_amsdu = VALUE_DISABLED; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7461 | dut->ap_sgi80 = 0; |
| 7462 | } else { |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 7463 | dut->ap_amsdu = VALUE_ENABLED; |
Pradeep Reddy POTTETI | 83b8067 | 2016-09-02 13:01:44 +0530 | [diff] [blame] | 7464 | /* |
| 7465 | * As LDPC is optional, don't enable this by default |
| 7466 | * for LINUX-WCN driver. The ap_set_wireless command |
| 7467 | * can be used to enable LDPC, when needed. |
| 7468 | */ |
| 7469 | if (drv != DRIVER_LINUX_WCN) |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 7470 | dut->ap_ldpc = VALUE_ENABLED; |
| 7471 | dut->ap_rx_amsdu = VALUE_ENABLED; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7472 | dut->ap_sgi80 = 1; |
| 7473 | } |
| 7474 | dut->ap_fixed_rate = 0; |
| 7475 | dut->ap_rx_streams = 3; |
| 7476 | dut->ap_tx_streams = 3; |
| 7477 | dut->ap_vhtmcs_map = 0; |
| 7478 | dut->ap_chwidth = AP_80; |
| 7479 | dut->ap_tx_stbc = 1; |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 7480 | dut->ap_dyn_bw_sig = VALUE_ENABLED; |
Mohammed Shafi Shajakhan | bae7230 | 2016-03-02 11:56:23 +0530 | [diff] [blame] | 7481 | if (get_openwrt_driver_type() == OPENWRT_DRIVER_ATHEROS) |
| 7482 | dut->ap_dfs_mode = AP_DFS_MODE_ENABLED; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7483 | if (get_driver_type() == DRIVER_ATHEROS) |
| 7484 | ath_reset_vht_defaults(dut); |
| 7485 | } |
| 7486 | |
Adil Saeed Musthafa | 33ea287 | 2017-04-10 23:13:24 -0700 | [diff] [blame] | 7487 | if (dut->program == PROGRAM_IOTLP) { |
| 7488 | dut->wnm_bss_max_feature = VALUE_DISABLED; |
| 7489 | dut->wnm_bss_max_idle_time = 0; |
| 7490 | dut->wnm_bss_max_protection = VALUE_NOT_SET; |
| 7491 | dut->ap_proxy_arp = 1; |
| 7492 | } else { |
| 7493 | /* |
| 7494 | * Do not touch the BSS-MAX Idle time feature |
| 7495 | * if the program is not IOTLP. |
| 7496 | */ |
| 7497 | dut->wnm_bss_max_feature = VALUE_NOT_SET; |
| 7498 | dut->wnm_bss_max_idle_time = 0; |
| 7499 | dut->wnm_bss_max_protection = VALUE_NOT_SET; |
| 7500 | } |
| 7501 | |
priyadharshini gowthaman | a27b5b6 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 7502 | if (dut->program == PROGRAM_LOC) { |
priyadharshini gowthaman | 8e26ff4 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 7503 | dut->ap_rrm = 1; |
| 7504 | dut->ap_rtt = 1; |
| 7505 | dut->ap_lci = 0; |
| 7506 | dut->ap_val_lci[0] = '\0'; |
priyadharshini gowthaman | c2357bd | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 7507 | dut->ap_infoz[0] = '\0'; |
priyadharshini gowthaman | 8e26ff4 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 7508 | dut->ap_lcr = 0; |
| 7509 | dut->ap_val_lcr[0] = '\0'; |
| 7510 | dut->ap_neighap = 0; |
| 7511 | dut->ap_opchannel = 0; |
| 7512 | dut->ap_scan = 0; |
priyadharshini gowthaman | c2357bd | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 7513 | dut->ap_fqdn_held = 0; |
| 7514 | dut->ap_fqdn_supl = 0; |
priyadharshini gowthaman | c52fff8 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 7515 | dut->ap_interworking = 0; |
| 7516 | dut->ap_gas_cb_delay = 0; |
priyadharshini gowthaman | a27b5b6 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 7517 | dut->ap_msnt_type = 0; |
| 7518 | } |
Adil Saeed Musthafa | 4ec61bd | 2017-04-10 23:13:41 -0700 | [diff] [blame] | 7519 | dut->ap_ft_oa = 0; |
Adil Saeed Musthafa | 604c826 | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 7520 | dut->ap_reg_domain = REG_DOMAIN_NOT_SET; |
Adil Saeed Musthafa | cf752fa | 2017-04-10 23:13:32 -0700 | [diff] [blame] | 7521 | dut->ap_mobility_domain[0] = '\0'; |
priyadharshini gowthaman | a27b5b6 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 7522 | |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 7523 | if (dut->program == PROGRAM_MBO) { |
| 7524 | dut->ap_mbo = 1; |
| 7525 | dut->ap_interworking = 1; |
| 7526 | dut->ap_ne_class = 0; |
| 7527 | dut->ap_ne_op_ch = 0; |
| 7528 | dut->ap_set_bssidpref = 1; |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 7529 | dut->ap_btmreq_disassoc_imnt = 0; |
| 7530 | dut->ap_btmreq_term_bit = 0; |
| 7531 | dut->ap_disassoc_timer = 0; |
| 7532 | dut->ap_btmreq_bss_term_dur = 0; |
Adil Saeed Musthafa | 16d9e63 | 2017-04-10 23:13:38 -0700 | [diff] [blame] | 7533 | dut->ap_channel = 36; |
| 7534 | dut->ap_chwidth = AP_20; |
Adil Saeed Musthafa | 023108a | 2017-04-10 23:13:37 -0700 | [diff] [blame] | 7535 | dut->ap_cell_cap_pref = 0; |
Adil Saeed Musthafa | ed5faae | 2017-04-10 23:13:36 -0700 | [diff] [blame] | 7536 | dut->ap_gas_cb_delay = 0; |
Adil Saeed Musthafa | 6906372 | 2017-04-10 23:13:40 -0700 | [diff] [blame] | 7537 | dut->mbo_self_ap_tuple.ap_ne_class = -1; |
| 7538 | dut->mbo_self_ap_tuple.ap_ne_pref = -1; /* Not set */ |
| 7539 | dut->mbo_self_ap_tuple.ap_ne_op_ch = -1; |
priyadharshini gowthaman | 94062b5 | 2017-12-20 12:33:34 -0800 | [diff] [blame] | 7540 | dut->ap_btmreq_bss_term_tsf = 0; |
priyadharshini gowthaman | 776562e | 2017-12-20 12:33:34 -0800 | [diff] [blame] | 7541 | dut->ap_assoc_delay = 0; |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 7542 | } |
| 7543 | |
priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 7544 | if (dut->program == PROGRAM_OCE) { |
| 7545 | if (dut->ap_dhcp_stop) |
| 7546 | run_system(dut, "/etc/init.d/dnsmasq start"); |
| 7547 | |
| 7548 | dut->ap_dhcp_stop = 0; |
| 7549 | dut->ap_oce = VALUE_ENABLED; |
| 7550 | dut->ap_broadcast_ssid = VALUE_ENABLED; |
| 7551 | dut->ap_fils_dscv_int = 20; |
| 7552 | dut->ap_filsdscv = VALUE_ENABLED; |
| 7553 | dut->ap_filshlp = VALUE_DISABLED; |
| 7554 | dut->ap_rnr = VALUE_DISABLED; |
| 7555 | dut->ap_nairealm[0] = '\0'; |
| 7556 | dut->ap_nairealm_int = 0; |
| 7557 | dut->ap_blechanutil = 0; |
| 7558 | dut->ap_ble_admit_cap = 0; |
| 7559 | dut->ap_esp = VALUE_ENABLED; |
| 7560 | dut->ap_datappdudura = 0; |
| 7561 | dut->ap_airtimefract = 0; |
| 7562 | dut->ap_blestacnt = 0; |
priyadharshini gowthaman | cb22e43 | 2017-12-28 15:23:31 -0800 | [diff] [blame] | 7563 | dut->ap_ul_availcap = 0; |
| 7564 | dut->ap_dl_availcap = 0; |
priyadharshini gowthaman | de81f39 | 2017-12-28 15:28:49 -0800 | [diff] [blame] | 7565 | dut->ap_akm = 0; |
| 7566 | dut->ap_add_sha256 = 0; |
| 7567 | dut->ap_add_sha384 = 0; |
| 7568 | dut->ap_pmksa = 0; |
| 7569 | dut->ap_pmksa_caching = 0; |
priyadharshini gowthaman | 63ab848 | 2017-12-28 15:32:55 -0800 | [diff] [blame] | 7570 | dut->ap_80plus80 = 0; |
priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 7571 | } |
| 7572 | |
priyadharshini gowthaman | 9149afc | 2018-01-15 13:40:18 -0800 | [diff] [blame] | 7573 | dut->ap_oper_chn = 0; |
| 7574 | |
Jouni Malinen | 3c367e8 | 2017-06-23 17:01:47 +0300 | [diff] [blame] | 7575 | free(dut->rsne_override); |
| 7576 | dut->rsne_override = NULL; |
| 7577 | |
Jouni Malinen | 6814313 | 2017-09-02 02:34:08 +0300 | [diff] [blame] | 7578 | free(dut->sae_commit_override); |
| 7579 | dut->sae_commit_override = NULL; |
| 7580 | |
Jouni Malinen | ed670f4 | 2017-08-31 01:39:28 +0300 | [diff] [blame] | 7581 | free(dut->ap_sae_groups); |
| 7582 | dut->ap_sae_groups = NULL; |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 7583 | |
Jouni Malinen | 2f524ce | 2017-08-31 01:43:29 +0300 | [diff] [blame] | 7584 | dut->sae_anti_clogging_threshold = -1; |
Jouni Malinen | b347db0 | 2017-09-02 01:36:03 +0300 | [diff] [blame] | 7585 | dut->sae_reflection = 0; |
Jouni Malinen | 2f524ce | 2017-08-31 01:43:29 +0300 | [diff] [blame] | 7586 | |
Jouni Malinen | 3d633da | 2017-09-14 22:19:21 +0300 | [diff] [blame] | 7587 | dut->ap_cipher = AP_CCMP; |
Jouni Malinen | 2ba2449 | 2017-11-17 12:43:59 +0200 | [diff] [blame] | 7588 | dut->ap_group_cipher = AP_NO_GROUP_CIPHER_SET; |
Jouni Malinen | 3d633da | 2017-09-14 22:19:21 +0300 | [diff] [blame] | 7589 | dut->ap_group_mgmt_cipher = AP_NO_GROUP_MGMT_CIPHER_SET; |
Jouni Malinen | 6337062 | 2017-11-18 17:47:13 +0200 | [diff] [blame] | 7590 | dut->ap_passphrase[0] = '\0'; |
| 7591 | dut->ap_psk[0] = '\0'; |
Jouni Malinen | 3d633da | 2017-09-14 22:19:21 +0300 | [diff] [blame] | 7592 | |
Jouni Malinen | d86e582 | 2017-08-29 03:55:32 +0300 | [diff] [blame] | 7593 | dut->dpp_conf_id = -1; |
| 7594 | |
| 7595 | dut->hostapd_running = 0; |
priyadharshini gowthaman | 9947fd3 | 2018-01-26 15:19:41 -0800 | [diff] [blame] | 7596 | |
| 7597 | if (get_openwrt_driver_type() == OPENWRT_DRIVER_ATHEROS) |
| 7598 | return 1; |
| 7599 | |
Jouni Malinen | d6bf1b4 | 2017-06-23 17:51:01 +0300 | [diff] [blame] | 7600 | if (dut->use_hostapd_pid_file) { |
| 7601 | kill_hostapd_process_pid(dut); |
| 7602 | } else if (kill_process(dut, "(hostapd)", 1, SIGTERM) == 0 || |
| 7603 | system("killall hostapd") == 0) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7604 | int i; |
| 7605 | /* Wait some time to allow hostapd to complete cleanup before |
| 7606 | * starting a new process */ |
| 7607 | for (i = 0; i < 10; i++) { |
| 7608 | usleep(500000); |
| 7609 | if (system("pidof hostapd") != 0) |
| 7610 | break; |
| 7611 | } |
| 7612 | } |
| 7613 | |
| 7614 | if (if_nametoindex("sigmadut") > 0 && |
| 7615 | system("iw dev sigmadut del") != 0) |
| 7616 | sigma_dut_print(dut, DUT_MSG_ERROR, "Failed to remove " |
| 7617 | "monitor interface"); |
| 7618 | |
| 7619 | return 1; |
| 7620 | } |
| 7621 | |
| 7622 | |
Ankita Bajaj | 0d5825b | 2017-10-25 16:20:17 +0530 | [diff] [blame] | 7623 | int sta_cfon_reset_default(struct sigma_dut *dut, struct sigma_conn *conn, |
| 7624 | struct sigma_cmd *cmd) |
| 7625 | { |
| 7626 | return cmd_ap_reset_default(dut, conn, cmd); |
| 7627 | } |
| 7628 | |
| 7629 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7630 | static int cmd_ap_get_info(struct sigma_dut *dut, struct sigma_conn *conn, |
| 7631 | struct sigma_cmd *cmd) |
| 7632 | { |
| 7633 | /* const char *name = get_param(cmd, "NAME"); */ |
| 7634 | struct stat s; |
| 7635 | char resp[200]; |
| 7636 | FILE *f; |
| 7637 | enum driver_type drv = get_driver_type(); |
| 7638 | |
| 7639 | switch (drv) { |
| 7640 | case DRIVER_ATHEROS: { |
| 7641 | /* Atheros AP */ |
| 7642 | struct utsname uts; |
| 7643 | char *version, athver[100]; |
| 7644 | |
| 7645 | if (stat("/proc/athversion", &s) != 0) { |
| 7646 | if (system("/etc/rc.d/rc.wlan up") != 0) { |
| 7647 | } |
| 7648 | } |
| 7649 | |
| 7650 | athver[0] = '\0'; |
| 7651 | f = fopen("/proc/athversion", "r"); |
| 7652 | if (f) { |
| 7653 | if (fgets(athver, sizeof(athver), f)) { |
| 7654 | char *pos = strchr(athver, '\n'); |
| 7655 | if (pos) |
| 7656 | *pos = '\0'; |
| 7657 | } |
| 7658 | fclose(f); |
| 7659 | } |
| 7660 | |
| 7661 | if (uname(&uts) == 0) |
| 7662 | version = uts.release; |
| 7663 | else |
| 7664 | version = "Unknown"; |
| 7665 | |
| 7666 | if (if_nametoindex("ath1") > 0) |
| 7667 | snprintf(resp, sizeof(resp), "interface,ath0_24G " |
| 7668 | "ath1_5G,agent,1.0,version,%s/drv:%s", |
| 7669 | version, athver); |
| 7670 | else |
| 7671 | snprintf(resp, sizeof(resp), "interface,ath0_24G," |
| 7672 | "agent,1.0,version,%s/drv:%s", |
| 7673 | version, athver); |
| 7674 | |
| 7675 | send_resp(dut, conn, SIGMA_COMPLETE, resp); |
| 7676 | return 0; |
| 7677 | } |
Sreelakshmi Konamki | b692f10 | 2016-04-26 19:47:00 +0530 | [diff] [blame] | 7678 | case DRIVER_LINUX_WCN: |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7679 | case DRIVER_MAC80211: { |
| 7680 | struct utsname uts; |
| 7681 | char *version; |
| 7682 | |
| 7683 | if (uname(&uts) == 0) |
| 7684 | version = uts.release; |
| 7685 | else |
| 7686 | version = "Unknown"; |
| 7687 | |
| 7688 | if (if_nametoindex("wlan1") > 0) |
| 7689 | snprintf(resp, sizeof(resp), "interface,wlan0_24G " |
| 7690 | "wlan1_5G,agent,1.0,version,%s", version); |
| 7691 | else |
| 7692 | snprintf(resp, sizeof(resp), "interface,wlan0_any," |
| 7693 | "agent,1.0,version,%s", version); |
| 7694 | |
| 7695 | send_resp(dut, conn, SIGMA_COMPLETE, resp); |
| 7696 | return 0; |
| 7697 | } |
| 7698 | case DRIVER_QNXNTO: { |
| 7699 | struct utsname uts; |
| 7700 | char *version; |
| 7701 | |
| 7702 | if (uname(&uts) == 0) |
| 7703 | version = uts.release; |
| 7704 | else |
| 7705 | version = "Unknown"; |
| 7706 | snprintf(resp, sizeof(resp), |
| 7707 | "interface,%s_any,agent,1.0,version,%s", |
| 7708 | sigma_main_ifname ? sigma_main_ifname : "NA", |
| 7709 | version); |
| 7710 | send_resp(dut, conn, SIGMA_COMPLETE, resp); |
| 7711 | return 0; |
| 7712 | } |
| 7713 | case DRIVER_OPENWRT: { |
| 7714 | switch (get_openwrt_driver_type()) { |
| 7715 | case OPENWRT_DRIVER_ATHEROS: { |
| 7716 | struct utsname uts; |
| 7717 | char *version; |
| 7718 | |
| 7719 | if (uname(&uts) == 0) |
| 7720 | version = uts.release; |
| 7721 | else |
| 7722 | version = "Unknown"; |
| 7723 | |
| 7724 | if (if_nametoindex("ath1") > 0) |
| 7725 | snprintf(resp, sizeof(resp), |
| 7726 | "interface,ath0_5G ath1_24G,agent,1.0,version,%s", |
| 7727 | version); |
| 7728 | else |
| 7729 | snprintf(resp, sizeof(resp), |
| 7730 | "interface,ath0_any,agent,1.0,version,%s", |
| 7731 | version); |
| 7732 | |
| 7733 | send_resp(dut, conn, SIGMA_COMPLETE, resp); |
| 7734 | return 0; |
| 7735 | } |
| 7736 | default: |
| 7737 | send_resp(dut, conn, SIGMA_ERROR, |
| 7738 | "errorCode,Unsupported openwrt driver"); |
| 7739 | return 0; |
| 7740 | } |
| 7741 | } |
| 7742 | default: |
| 7743 | send_resp(dut, conn, SIGMA_ERROR, |
| 7744 | "errorCode,Unsupported driver"); |
| 7745 | return 0; |
| 7746 | } |
| 7747 | } |
| 7748 | |
| 7749 | |
| 7750 | static int cmd_ap_deauth_sta(struct sigma_dut *dut, struct sigma_conn *conn, |
| 7751 | struct sigma_cmd *cmd) |
| 7752 | { |
| 7753 | /* const char *name = get_param(cmd, "NAME"); */ |
| 7754 | /* const char *ifname = get_param(cmd, "INTERFACE"); */ |
| 7755 | const char *val; |
| 7756 | char buf[100]; |
| 7757 | |
| 7758 | val = get_param(cmd, "MinorCode"); |
| 7759 | if (val) { |
| 7760 | /* TODO: add support for P2P minor code */ |
| 7761 | send_resp(dut, conn, SIGMA_ERROR, "errorCode,MinorCode not " |
| 7762 | "yet supported"); |
| 7763 | return 0; |
| 7764 | } |
| 7765 | |
| 7766 | val = get_param(cmd, "STA_MAC_ADDRESS"); |
| 7767 | if (val == NULL) |
| 7768 | return -1; |
| 7769 | snprintf(buf, sizeof(buf), "deauth %s", val); |
| 7770 | if (run_hostapd_cli(dut, buf) != 0) |
| 7771 | return -2; |
| 7772 | |
| 7773 | return 1; |
| 7774 | } |
| 7775 | |
| 7776 | |
| 7777 | #ifdef __linux__ |
| 7778 | int inject_frame(int s, const void *data, size_t len, int encrypt); |
| 7779 | int open_monitor(const char *ifname); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7780 | #endif /* __linux__ */ |
| 7781 | |
| 7782 | enum send_frame_type { |
| 7783 | DISASSOC, DEAUTH, SAQUERY |
| 7784 | }; |
| 7785 | enum send_frame_protection { |
| 7786 | CORRECT_KEY, INCORRECT_KEY, UNPROTECTED |
| 7787 | }; |
| 7788 | |
| 7789 | |
| 7790 | static int ap_inject_frame(struct sigma_dut *dut, struct sigma_conn *conn, |
| 7791 | enum send_frame_type frame, |
| 7792 | enum send_frame_protection protected, |
| 7793 | const char *sta_addr) |
| 7794 | { |
| 7795 | #ifdef __linux__ |
| 7796 | unsigned char buf[1000], *pos; |
| 7797 | int s, res; |
| 7798 | unsigned char addr_sta[6], addr_own[6]; |
| 7799 | char *ifname; |
| 7800 | char cbuf[100]; |
| 7801 | struct ifreq ifr; |
| 7802 | |
| 7803 | if ((dut->ap_mode == AP_11a || dut->ap_mode == AP_11na || |
| 7804 | dut->ap_mode == AP_11ac) && |
| 7805 | if_nametoindex("wlan1") > 0) |
| 7806 | ifname = "wlan1"; |
| 7807 | else |
| 7808 | ifname = "wlan0"; |
| 7809 | |
| 7810 | if (hwaddr_aton(sta_addr, addr_sta) < 0) |
| 7811 | return -1; |
| 7812 | |
| 7813 | s = socket(AF_INET, SOCK_DGRAM, 0); |
| 7814 | if (s < 0) |
| 7815 | return -1; |
| 7816 | memset(&ifr, 0, sizeof(ifr)); |
Peng Xu | b8fc5cc | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 7817 | strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name)); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7818 | if (ioctl(s, SIOCGIFHWADDR, &ifr) < 0) { |
| 7819 | perror("ioctl"); |
| 7820 | close(s); |
| 7821 | return -1; |
| 7822 | } |
| 7823 | close(s); |
| 7824 | memcpy(addr_own, ifr.ifr_hwaddr.sa_data, 6); |
| 7825 | |
| 7826 | if (if_nametoindex("sigmadut") == 0) { |
| 7827 | snprintf(cbuf, sizeof(cbuf), |
| 7828 | "iw dev %s interface add sigmadut type monitor", |
| 7829 | ifname); |
| 7830 | if (system(cbuf) != 0 || |
| 7831 | if_nametoindex("sigmadut") == 0) { |
| 7832 | sigma_dut_print(dut, DUT_MSG_ERROR, "Failed to add " |
| 7833 | "monitor interface with '%s'", cbuf); |
| 7834 | return -2; |
| 7835 | } |
| 7836 | } |
| 7837 | |
| 7838 | if (system("ifconfig sigmadut up") != 0) { |
| 7839 | sigma_dut_print(dut, DUT_MSG_ERROR, "Failed to set " |
| 7840 | "monitor interface up"); |
| 7841 | return -2; |
| 7842 | } |
| 7843 | |
| 7844 | pos = buf; |
| 7845 | |
| 7846 | /* Frame Control */ |
| 7847 | switch (frame) { |
| 7848 | case DISASSOC: |
| 7849 | *pos++ = 0xa0; |
| 7850 | break; |
| 7851 | case DEAUTH: |
| 7852 | *pos++ = 0xc0; |
| 7853 | break; |
| 7854 | case SAQUERY: |
| 7855 | *pos++ = 0xd0; |
| 7856 | break; |
| 7857 | } |
| 7858 | |
| 7859 | if (protected == INCORRECT_KEY) |
| 7860 | *pos++ = 0x40; /* Set Protected field to 1 */ |
| 7861 | else |
| 7862 | *pos++ = 0x00; |
| 7863 | |
| 7864 | /* Duration */ |
| 7865 | *pos++ = 0x00; |
| 7866 | *pos++ = 0x00; |
| 7867 | |
| 7868 | /* addr1 = DA (station) */ |
| 7869 | memcpy(pos, addr_sta, 6); |
| 7870 | pos += 6; |
| 7871 | /* addr2 = SA (own address) */ |
| 7872 | memcpy(pos, addr_own, 6); |
| 7873 | pos += 6; |
| 7874 | /* addr3 = BSSID (own address) */ |
| 7875 | memcpy(pos, addr_own, 6); |
| 7876 | pos += 6; |
| 7877 | |
| 7878 | /* Seq# (to be filled by driver/mac80211) */ |
| 7879 | *pos++ = 0x00; |
| 7880 | *pos++ = 0x00; |
| 7881 | |
| 7882 | if (protected == INCORRECT_KEY) { |
| 7883 | /* CCMP parameters */ |
| 7884 | memcpy(pos, "\x61\x01\x00\x20\x00\x10\x00\x00", 8); |
| 7885 | pos += 8; |
| 7886 | } |
| 7887 | |
| 7888 | if (protected == INCORRECT_KEY) { |
| 7889 | switch (frame) { |
| 7890 | case DEAUTH: |
| 7891 | /* Reason code (encrypted) */ |
| 7892 | memcpy(pos, "\xa7\x39", 2); |
| 7893 | pos += 2; |
| 7894 | break; |
| 7895 | case DISASSOC: |
| 7896 | /* Reason code (encrypted) */ |
| 7897 | memcpy(pos, "\xa7\x39", 2); |
| 7898 | pos += 2; |
| 7899 | break; |
| 7900 | case SAQUERY: |
| 7901 | /* Category|Action|TransID (encrypted) */ |
| 7902 | memcpy(pos, "\x6f\xbd\xe9\x4d", 4); |
| 7903 | pos += 4; |
| 7904 | break; |
| 7905 | default: |
| 7906 | return -1; |
| 7907 | } |
| 7908 | |
| 7909 | /* CCMP MIC */ |
| 7910 | memcpy(pos, "\xc8\xd8\x3b\x06\x5d\xb7\x25\x68", 8); |
| 7911 | pos += 8; |
| 7912 | } else { |
| 7913 | switch (frame) { |
| 7914 | case DEAUTH: |
| 7915 | /* reason code = 8 */ |
| 7916 | *pos++ = 0x08; |
| 7917 | *pos++ = 0x00; |
| 7918 | break; |
| 7919 | case DISASSOC: |
| 7920 | /* reason code = 8 */ |
| 7921 | *pos++ = 0x08; |
| 7922 | *pos++ = 0x00; |
| 7923 | break; |
| 7924 | case SAQUERY: |
| 7925 | /* Category - SA Query */ |
| 7926 | *pos++ = 0x08; |
| 7927 | /* SA query Action - Request */ |
| 7928 | *pos++ = 0x00; |
| 7929 | /* Transaction ID */ |
| 7930 | *pos++ = 0x12; |
| 7931 | *pos++ = 0x34; |
| 7932 | break; |
| 7933 | } |
| 7934 | } |
| 7935 | |
| 7936 | s = open_monitor("sigmadut"); |
| 7937 | if (s < 0) { |
| 7938 | send_resp(dut, conn, SIGMA_ERROR, "errorCode,Failed to open " |
| 7939 | "monitor socket"); |
| 7940 | return 0; |
| 7941 | } |
| 7942 | |
| 7943 | res = inject_frame(s, buf, pos - buf, protected == CORRECT_KEY); |
| 7944 | if (res < 0) { |
| 7945 | send_resp(dut, conn, SIGMA_ERROR, "errorCode,Failed to " |
| 7946 | "inject frame"); |
Pradeep Reddy POTTETI | 673d85c | 2016-07-26 19:08:07 +0530 | [diff] [blame] | 7947 | close(s); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7948 | return 0; |
| 7949 | } |
| 7950 | if (res < pos - buf) { |
| 7951 | send_resp(dut, conn, SIGMA_ERROR, "errorCode,Only partial " |
| 7952 | "frame sent"); |
Pradeep Reddy POTTETI | 673d85c | 2016-07-26 19:08:07 +0530 | [diff] [blame] | 7953 | close(s); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7954 | return 0; |
| 7955 | } |
| 7956 | |
| 7957 | close(s); |
| 7958 | |
| 7959 | return 1; |
| 7960 | #else /* __linux__ */ |
| 7961 | send_resp(dut, conn, SIGMA_ERROR, "errorCode,ap_send_frame not " |
| 7962 | "yet supported"); |
| 7963 | return 0; |
| 7964 | #endif /* __linux__ */ |
| 7965 | } |
| 7966 | |
| 7967 | |
| 7968 | int ap_send_frame_hs2(struct sigma_dut *dut, struct sigma_conn *conn, |
| 7969 | struct sigma_cmd *cmd) |
| 7970 | { |
| 7971 | const char *val, *dest; |
| 7972 | char buf[100]; |
| 7973 | |
| 7974 | val = get_param(cmd, "FrameName"); |
| 7975 | if (val == NULL) |
| 7976 | return -1; |
| 7977 | |
| 7978 | if (strcasecmp(val, "QoSMapConfigure") == 0) { |
| 7979 | dest = get_param(cmd, "Dest"); |
| 7980 | if (!dest) |
| 7981 | return -1; |
| 7982 | |
| 7983 | val = get_param(cmd, "QoS_MAP_SET"); |
| 7984 | if (val) { |
| 7985 | dut->ap_qos_map_set = atoi(val); |
| 7986 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_qos_map_set %d", |
| 7987 | dut->ap_qos_map_set); |
| 7988 | } |
| 7989 | |
| 7990 | if (dut->ap_qos_map_set == 1) |
| 7991 | run_hostapd_cli(dut, "set_qos_map_set " QOS_MAP_SET_1); |
| 7992 | else if (dut->ap_qos_map_set == 2) |
| 7993 | run_hostapd_cli(dut, "set_qos_map_set " QOS_MAP_SET_2); |
| 7994 | |
| 7995 | snprintf(buf, sizeof(buf), "send_qos_map_conf %s", dest); |
| 7996 | if (run_hostapd_cli(dut, buf) != 0) |
| 7997 | return -1; |
| 7998 | } |
| 7999 | |
| 8000 | return 1; |
| 8001 | } |
| 8002 | |
| 8003 | |
| 8004 | static int ath_ap_send_frame_vht(struct sigma_dut *dut, struct sigma_conn *conn, |
| 8005 | struct sigma_cmd *cmd) |
| 8006 | { |
| 8007 | const char *val; |
| 8008 | char *ifname; |
| 8009 | char buf[100]; |
| 8010 | int chwidth, nss; |
| 8011 | |
| 8012 | val = get_param(cmd, "FrameName"); |
| 8013 | if (!val || strcasecmp(val, "op_md_notif_frm") != 0) { |
| 8014 | send_resp(dut, conn, SIGMA_ERROR, |
| 8015 | "errorCode,Unsupported FrameName"); |
| 8016 | return 0; |
| 8017 | } |
| 8018 | |
| 8019 | /* |
| 8020 | * Sequence of commands for Opmode notification on |
| 8021 | * Peregrine based products |
| 8022 | */ |
| 8023 | ifname = get_main_ifname(); |
| 8024 | |
| 8025 | /* Disable STBC */ |
| 8026 | snprintf(buf, sizeof(buf), "iwpriv %s tx_stbc 0", ifname); |
| 8027 | if (system(buf) != 0) { |
| 8028 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 8029 | "iwpriv tx_stbc 0 failed!"); |
| 8030 | } |
| 8031 | |
| 8032 | /* Check whether optional arg channel width was passed */ |
| 8033 | val = get_param(cmd, "Channel_width"); |
| 8034 | if (val) { |
| 8035 | switch (atoi(val)) { |
| 8036 | case 20: |
| 8037 | chwidth = 0; |
| 8038 | break; |
| 8039 | case 40: |
| 8040 | chwidth = 1; |
| 8041 | break; |
| 8042 | case 80: |
| 8043 | chwidth = 2; |
| 8044 | break; |
| 8045 | case 160: |
| 8046 | chwidth = 3; |
| 8047 | break; |
| 8048 | default: |
| 8049 | chwidth = 2; |
| 8050 | break; |
| 8051 | } |
| 8052 | snprintf(buf, sizeof(buf), "iwpriv %s chwidth %d", |
| 8053 | ifname, chwidth); |
| 8054 | if (system(buf) != 0) { |
| 8055 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 8056 | "iwpriv chwidth failed!"); |
| 8057 | } |
| 8058 | } |
| 8059 | |
| 8060 | /* Check whether optional arg NSS was passed */ |
| 8061 | val = get_param(cmd, "NSS"); |
| 8062 | if (val) { |
| 8063 | /* Convert nss to chainmask */ |
| 8064 | switch (atoi(val)) { |
| 8065 | case 1: |
| 8066 | nss = 1; |
| 8067 | break; |
| 8068 | case 2: |
| 8069 | nss = 3; |
| 8070 | break; |
| 8071 | case 3: |
| 8072 | nss = 7; |
| 8073 | break; |
| 8074 | default: |
| 8075 | /* We do not support NSS > 3 */ |
| 8076 | nss = 3; |
| 8077 | break; |
| 8078 | } |
| 8079 | snprintf(buf, sizeof(buf), "iwpriv %s rxchainmask %d", |
| 8080 | ifname, nss); |
| 8081 | if (system(buf) != 0) { |
| 8082 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 8083 | "iwpriv rxchainmask failed!"); |
| 8084 | } |
| 8085 | } |
| 8086 | |
| 8087 | /* Send the opmode notification */ |
Sunil Dutt | 27ec7f6 | 2017-09-14 18:22:59 +0300 | [diff] [blame] | 8088 | snprintf(buf, sizeof(buf), "iwpriv %s opmode_notify 1", ifname); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8089 | if (system(buf) != 0) { |
| 8090 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 8091 | "iwpriv opmode_notify failed!"); |
| 8092 | } |
| 8093 | |
| 8094 | return 1; |
| 8095 | } |
| 8096 | |
| 8097 | |
priyadharshini gowthaman | a27b5b6 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 8098 | static int ath_ap_send_frame_loc(struct sigma_dut *dut, struct sigma_conn *conn, |
| 8099 | struct sigma_cmd *cmd) |
| 8100 | { |
| 8101 | const char *val; |
| 8102 | FILE *f; |
priyadharshini gowthaman | a61badd | 2016-08-16 13:37:27 -0700 | [diff] [blame] | 8103 | int rand_int = 0; |
priyadharshini gowthaman | a27b5b6 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 8104 | |
| 8105 | val = get_param(cmd, "MsntType"); |
| 8106 | if (val) { |
| 8107 | if (dut->ap_msnt_type == 0) |
| 8108 | dut->ap_msnt_type = atoi(val); |
| 8109 | |
| 8110 | if (dut->ap_msnt_type != 5 && dut->ap_msnt_type != 2) { |
| 8111 | dut->ap_msnt_type = atoi(val); |
| 8112 | if (dut->ap_msnt_type == 1) { |
priyadharshini gowthaman | a61badd | 2016-08-16 13:37:27 -0700 | [diff] [blame] | 8113 | val = get_param(cmd, "RandInterval"); |
| 8114 | if (val) |
| 8115 | rand_int = atoi(val); |
priyadharshini gowthaman | a27b5b6 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 8116 | f = fopen("/tmp/ftmrr.txt", "a"); |
| 8117 | if (!f) { |
| 8118 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 8119 | "Failed to open /tmp/ftmrr.txt"); |
| 8120 | return -1; |
| 8121 | } |
| 8122 | |
| 8123 | fprintf(f, "sta_mac = %s\n", cmd->values[3]); |
priyadharshini gowthaman | a61badd | 2016-08-16 13:37:27 -0700 | [diff] [blame] | 8124 | 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", |
| 8125 | rand_int, cmd->values[7]); |
priyadharshini gowthaman | a27b5b6 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 8126 | fclose(f); |
| 8127 | dut->ap_msnt_type = 5; |
| 8128 | run_system(dut, "wpc -f /tmp/ftmrr.txt"); |
| 8129 | } |
| 8130 | } else if (dut->ap_msnt_type == 5) { |
| 8131 | run_system(dut, "wpc -f /tmp/ftmrr.txt"); |
| 8132 | } else if (dut->ap_msnt_type == 2) { |
| 8133 | f = fopen("/tmp/wru.txt", "w"); |
| 8134 | if (!f) { |
| 8135 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 8136 | "Failed to open /tmp/wru.txt"); |
| 8137 | return -1; |
| 8138 | } |
| 8139 | |
| 8140 | fprintf(f, "sta_mac = %s\n", cmd->values[3]); |
| 8141 | fprintf(f, "meas_type = 0x08\ndialogtoken = 0x1\nnum_repetitions = 0x0\nmeas_token = 0x1\nmeas_req_mode = 0x00\nloc_subject = 0x01\n"); |
| 8142 | fclose(f); |
| 8143 | run_system(dut, "wpc -w /tmp/wru.txt"); |
| 8144 | } |
| 8145 | } |
| 8146 | return 1; |
| 8147 | } |
| 8148 | |
| 8149 | |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 8150 | /* |
| 8151 | * The following functions parse_send_frame_params_int(), |
| 8152 | * parse_send_frame_params_str(), and parse_send_frame_params_mac() |
| 8153 | * are used by ath_ap_send_frame_bcn_rpt_req(). |
| 8154 | * Beacon Report Request is a frame used as part of the MBO program. |
| 8155 | * The command for sending beacon report has a lot of |
| 8156 | * arguments and having these functions reduces code size. |
| 8157 | * |
| 8158 | */ |
| 8159 | static int parse_send_frame_params_int(char *param, struct sigma_cmd *cmd, |
| 8160 | struct sigma_dut *dut, |
| 8161 | char *buf, size_t buf_size) |
| 8162 | { |
| 8163 | const char *str_val; |
| 8164 | int int_val; |
| 8165 | char temp[100]; |
| 8166 | |
| 8167 | str_val = get_param(cmd, param); |
| 8168 | if (!str_val) { |
| 8169 | sigma_dut_print(dut, DUT_MSG_ERROR, "%s not given", param); |
| 8170 | return -1; |
| 8171 | } |
| 8172 | int_val = atoi(str_val); |
| 8173 | snprintf(temp, sizeof(temp), " %d", int_val); |
Peng Xu | 591be45 | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 8174 | strlcat(buf, temp, buf_size); |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 8175 | return 0; |
| 8176 | } |
| 8177 | |
| 8178 | |
| 8179 | static int parse_send_frame_params_str(char *param, struct sigma_cmd *cmd, |
| 8180 | struct sigma_dut *dut, |
| 8181 | char *buf, size_t buf_size) |
| 8182 | { |
| 8183 | const char *str_val; |
| 8184 | char temp[100]; |
| 8185 | |
| 8186 | str_val = get_param(cmd, param); |
| 8187 | if (!str_val) { |
| 8188 | sigma_dut_print(dut, DUT_MSG_ERROR, "%s not given", param); |
| 8189 | return -1; |
| 8190 | } |
| 8191 | snprintf(temp, sizeof(temp), " %s", str_val); |
| 8192 | temp[sizeof(temp) - 1] = '\0'; |
Peng Xu | 591be45 | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 8193 | strlcat(buf, temp, buf_size); |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 8194 | return 0; |
| 8195 | } |
| 8196 | |
| 8197 | |
| 8198 | static int parse_send_frame_params_mac(char *param, struct sigma_cmd *cmd, |
| 8199 | struct sigma_dut *dut, |
| 8200 | char *buf, size_t buf_size) |
| 8201 | { |
| 8202 | const char *str_val; |
| 8203 | unsigned char mac[6]; |
| 8204 | char temp[100]; |
| 8205 | |
| 8206 | str_val = get_param(cmd, param); |
| 8207 | if (!str_val) { |
| 8208 | sigma_dut_print(dut, DUT_MSG_ERROR, "%s not given", param); |
| 8209 | return -1; |
| 8210 | } |
| 8211 | |
| 8212 | if (parse_mac_address(dut, str_val, mac) < 0) { |
| 8213 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 8214 | "MAC Address not in proper format"); |
| 8215 | return -1; |
| 8216 | } |
| 8217 | snprintf(temp, sizeof(temp), " %02x:%02x:%02x:%02x:%02x:%02x", |
| 8218 | mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]); |
Peng Xu | 591be45 | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 8219 | strlcat(buf, temp, buf_size); |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 8220 | return 0; |
| 8221 | } |
| 8222 | |
| 8223 | |
| 8224 | static void fill_1_or_0_based_on_presence(struct sigma_cmd *cmd, char *param, |
| 8225 | char *buf, size_t buf_size) |
| 8226 | { |
| 8227 | const char *str_val; |
| 8228 | char *value = " 1"; |
| 8229 | |
| 8230 | str_val = get_param(cmd, param); |
| 8231 | if (!str_val || str_val[0] == '\0') |
| 8232 | value = " 0"; |
Peng Xu | 591be45 | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 8233 | strlcat(buf, value, buf_size); |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 8234 | |
| 8235 | } |
| 8236 | |
| 8237 | |
| 8238 | /* |
| 8239 | * wifitool athN sendbcnrpt |
| 8240 | * <STA MAC - Plugs in from Dest_MAC> |
| 8241 | * <regclass - Plugs in from RegClass - int> |
| 8242 | * <channum - Plugs in from Channel PARAM of dev_send_frame - int> |
| 8243 | * <rand_ivl - Plugs in from RandInt - string> |
| 8244 | * <duration - Plugs in from MeaDur - integer> |
| 8245 | * <mode - Plugs in from MeaMode - string> |
| 8246 | * <req_ssid - Plugs in from SSID PARAM of dev_send_frame - string> |
| 8247 | * <rep_cond - Plugs in from RptCond - integer> |
| 8248 | * <rpt_detail - Plugs in from RptDet - integer> |
| 8249 | * <req_ie - Plugs in from ReqInfo PARAM of dev_send_frame - string> |
| 8250 | * <chanrpt_mode - Plugs in from APChanRpt - integer> |
| 8251 | * <specific_bssid - Plugs in from BSSID PARAM of dev_send_frame> |
| 8252 | * [AP channel numbers] |
| 8253 | */ |
| 8254 | static int ath_ap_send_frame_bcn_rpt_req(struct sigma_dut *dut, |
| 8255 | struct sigma_cmd *cmd, |
| 8256 | const char *ifname) |
| 8257 | { |
| 8258 | char buf[100]; |
| 8259 | int rpt_det; |
| 8260 | const char *str_val; |
| 8261 | const char *mea_mode; |
| 8262 | |
| 8263 | snprintf(buf, sizeof(buf), "wifitool %s sendbcnrpt", ifname); |
| 8264 | |
| 8265 | if (parse_send_frame_params_mac("Dest_MAC", cmd, dut, buf, sizeof(buf))) |
| 8266 | return -1; |
| 8267 | if (parse_send_frame_params_int("RegClass", cmd, dut, buf, sizeof(buf))) |
| 8268 | return -1; |
| 8269 | if (parse_send_frame_params_int("Channel", cmd, dut, buf, sizeof(buf))) |
| 8270 | return -1; |
| 8271 | if (parse_send_frame_params_str("RandInt", cmd, dut, buf, sizeof(buf))) |
| 8272 | return -1; |
| 8273 | if (parse_send_frame_params_int("MeaDur", cmd, dut, buf, sizeof(buf))) |
| 8274 | return -1; |
| 8275 | |
| 8276 | str_val = get_param(cmd, "MeaMode"); |
| 8277 | if (!str_val) { |
| 8278 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 8279 | "MeaMode parameter not present in send bcn-rpt-req"); |
| 8280 | return -1; |
| 8281 | } |
| 8282 | if (strcasecmp(str_val, "passive") == 0) { |
| 8283 | mea_mode = " 0"; |
| 8284 | } else if (strcasecmp(str_val, "active") == 0) { |
| 8285 | mea_mode = " 1"; |
| 8286 | } else if (strcasecmp(str_val, "table") == 0) { |
| 8287 | mea_mode = " 2"; |
| 8288 | } else { |
| 8289 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 8290 | "MEA-MODE Value not correctly given"); |
| 8291 | return -1; |
| 8292 | } |
Peng Xu | 591be45 | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 8293 | strlcat(buf, mea_mode, sizeof(buf)); |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 8294 | |
| 8295 | fill_1_or_0_based_on_presence(cmd, "SSID", buf, sizeof(buf)); |
| 8296 | |
| 8297 | if (parse_send_frame_params_int("RptCond", cmd, dut, buf, sizeof(buf))) |
| 8298 | return -1; |
| 8299 | |
| 8300 | if (parse_send_frame_params_int("RptDet", cmd, dut, buf, sizeof(buf))) |
| 8301 | return -1; |
| 8302 | str_val = get_param(cmd, "RptDet"); |
| 8303 | rpt_det = str_val ? atoi(str_val) : 0; |
| 8304 | |
| 8305 | if (rpt_det) |
| 8306 | fill_1_or_0_based_on_presence(cmd, "ReqInfo", buf, sizeof(buf)); |
| 8307 | else |
Peng Xu | 591be45 | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 8308 | strlcat(buf, " 0", sizeof(buf)); |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 8309 | |
| 8310 | if (rpt_det) |
| 8311 | fill_1_or_0_based_on_presence(cmd, "APChanRpt", buf, |
| 8312 | sizeof(buf)); |
| 8313 | else |
Peng Xu | 591be45 | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 8314 | strlcat(buf, " 0", sizeof(buf)); |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 8315 | |
| 8316 | if (parse_send_frame_params_mac("BSSID", cmd, dut, buf, sizeof(buf))) |
| 8317 | return -1; |
| 8318 | |
priyadharshini gowthaman | 2a4d20e | 2017-12-28 13:01:34 -0800 | [diff] [blame] | 8319 | str_val = get_param(cmd, "APChanRpt"); |
| 8320 | if (str_val) { |
| 8321 | const char *pos; |
| 8322 | int ap_chanrpt; |
| 8323 | int ap_chanrpt_2 = 0; |
| 8324 | char chanrpt[100]; |
| 8325 | |
| 8326 | ap_chanrpt = atoi(str_val); |
| 8327 | pos = strchr(str_val, '_'); |
| 8328 | if (pos) { |
| 8329 | pos++; |
| 8330 | ap_chanrpt_2 = atoi(pos); |
| 8331 | } |
| 8332 | if (ap_chanrpt) { |
| 8333 | snprintf(chanrpt, sizeof(chanrpt), " %d", ap_chanrpt); |
| 8334 | strlcat(buf, chanrpt, sizeof(buf)); |
| 8335 | } |
| 8336 | if (ap_chanrpt_2) { |
| 8337 | snprintf(chanrpt, sizeof(chanrpt), " %d", ap_chanrpt_2); |
| 8338 | strlcat(buf, chanrpt, sizeof(buf)); |
| 8339 | } |
| 8340 | } |
| 8341 | |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 8342 | run_system(dut, buf); |
| 8343 | return 0; |
| 8344 | } |
| 8345 | |
| 8346 | |
| 8347 | static void inform_and_sleep(struct sigma_dut *dut, int seconds) |
| 8348 | { |
| 8349 | sigma_dut_print(dut, DUT_MSG_DEBUG, "sleeping for %d seconds", seconds); |
| 8350 | sleep(seconds); |
| 8351 | sigma_dut_print(dut, DUT_MSG_DEBUG, "woke up after %d seconds", |
| 8352 | seconds); |
| 8353 | } |
| 8354 | |
| 8355 | |
| 8356 | static int ath_ap_send_frame_btm_req(struct sigma_dut *dut, |
| 8357 | struct sigma_cmd *cmd, const char *ifname) |
| 8358 | { |
| 8359 | unsigned char mac_addr[ETH_ALEN]; |
| 8360 | int disassoc_timer; |
| 8361 | char buf[100]; |
| 8362 | const char *val; |
| 8363 | int cand_list = 1; |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 8364 | |
| 8365 | val = get_param(cmd, "Dest_MAC"); |
| 8366 | if (!val || parse_mac_address(dut, val, mac_addr) < 0) { |
| 8367 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 8368 | "MAC Address not in proper format"); |
| 8369 | return -1; |
| 8370 | } |
| 8371 | |
| 8372 | val = get_param(cmd, "Disassoc_Timer"); |
| 8373 | if (val) |
| 8374 | disassoc_timer = atoi(val); |
| 8375 | else |
| 8376 | disassoc_timer = dut->ap_disassoc_timer; |
Jouni Malinen | 032aeab | 2018-01-04 12:30:46 +0200 | [diff] [blame] | 8377 | if (disassoc_timer < 0) { |
| 8378 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 8379 | "Invalid Disassoc_Timer value %d", |
| 8380 | disassoc_timer); |
| 8381 | return -1; |
| 8382 | } |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 8383 | |
| 8384 | val = get_param(cmd, "Cand_List"); |
| 8385 | if (val && val[0]) |
| 8386 | cand_list = atoi(val); |
| 8387 | |
| 8388 | val = get_param(cmd, "BTMQuery_Reason_Code"); |
| 8389 | if (val) { |
| 8390 | snprintf(buf, sizeof(buf), "iwpriv %s mbo_trans_rs %s", |
| 8391 | ifname, val); |
| 8392 | run_system(dut, buf); |
| 8393 | } |
| 8394 | |
priyadharshini gowthaman | 776562e | 2017-12-20 12:33:34 -0800 | [diff] [blame] | 8395 | if (dut->ap_btmreq_disassoc_imnt && !dut->ap_assoc_delay) { |
| 8396 | snprintf(buf, sizeof(buf), "iwpriv %s mbo_asoc_ret 1", ifname); |
| 8397 | run_system(dut, buf); |
| 8398 | } |
| 8399 | |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 8400 | snprintf(buf, sizeof(buf), |
priyadharshini gowthaman | 776562e | 2017-12-20 12:33:34 -0800 | [diff] [blame] | 8401 | "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] | 8402 | ifname, mac_addr[0], mac_addr[1], mac_addr[2], mac_addr[3], |
| 8403 | mac_addr[4], mac_addr[5], cand_list, disassoc_timer, |
| 8404 | dut->ap_btmreq_disassoc_imnt, |
| 8405 | dut->ap_btmreq_term_bit, |
priyadharshini gowthaman | 94062b5 | 2017-12-20 12:33:34 -0800 | [diff] [blame] | 8406 | dut->ap_btmreq_bss_term_tsf, |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 8407 | dut->ap_btmreq_bss_term_dur); |
| 8408 | run_system(dut, buf); |
| 8409 | |
| 8410 | if (dut->ap_btmreq_term_bit) { |
priyadharshini gowthaman | 94062b5 | 2017-12-20 12:33:34 -0800 | [diff] [blame] | 8411 | if (dut->ap_btmreq_bss_term_tsf >= 2) |
| 8412 | inform_and_sleep(dut, dut->ap_btmreq_bss_term_tsf - 2); |
priyadharshini gowthaman | 776562e | 2017-12-20 12:33:34 -0800 | [diff] [blame] | 8413 | run_system_wrapper( |
| 8414 | dut, "iwpriv %s kickmac %02x:%02x:%02x:%02x:%02x:%02x", |
| 8415 | ifname, |
| 8416 | mac_addr[0], mac_addr[1], mac_addr[2], |
| 8417 | mac_addr[3], mac_addr[4], mac_addr[5]); |
| 8418 | inform_and_sleep(dut, 2); |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 8419 | run_system_wrapper(dut, "ifconfig %s down", ifname); |
priyadharshini gowthaman | 776562e | 2017-12-20 12:33:34 -0800 | [diff] [blame] | 8420 | inform_and_sleep(dut, 5); |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 8421 | run_system_wrapper(dut, "ifconfig %s up", ifname); |
| 8422 | } else if (dut->ap_btmreq_disassoc_imnt) { |
| 8423 | inform_and_sleep(dut, (disassoc_timer / 1000) + 1); |
| 8424 | run_system_wrapper(dut, |
| 8425 | "iwpriv %s kickmac %02x:%02x:%02x:%02x:%02x:%02x", |
| 8426 | ifname, |
| 8427 | mac_addr[0], mac_addr[1], mac_addr[2], |
| 8428 | mac_addr[3], mac_addr[4], mac_addr[5]); |
| 8429 | } |
| 8430 | return 0; |
| 8431 | } |
| 8432 | |
| 8433 | |
priyadharshini gowthaman | 2a4d20e | 2017-12-28 13:01:34 -0800 | [diff] [blame] | 8434 | static int ath_ap_send_frame_disassoc(struct sigma_dut *dut, |
| 8435 | struct sigma_cmd *cmd, const char *ifname) |
| 8436 | { |
| 8437 | unsigned char mac_addr[ETH_ALEN]; |
| 8438 | const char *val; |
| 8439 | |
| 8440 | val = get_param(cmd, "Dest_MAC"); |
| 8441 | if (!val || parse_mac_address(dut, val, mac_addr) < 0) { |
| 8442 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 8443 | "MAC Address not in proper format"); |
| 8444 | return -1; |
| 8445 | } |
| 8446 | |
| 8447 | run_system_wrapper(dut, |
| 8448 | "iwpriv %s kickmac %02x:%02x:%02x:%02x:%02x:%02x", |
| 8449 | ifname, mac_addr[0], mac_addr[1], mac_addr[2], |
| 8450 | mac_addr[3], mac_addr[4], mac_addr[5]); |
| 8451 | return 0; |
| 8452 | } |
| 8453 | |
| 8454 | |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 8455 | static int ath_ap_send_frame_mbo(struct sigma_dut *dut, struct sigma_conn *conn, |
| 8456 | struct sigma_cmd *cmd) |
| 8457 | { |
| 8458 | const char *val; |
| 8459 | char *ifname; |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 8460 | |
| 8461 | ifname = get_main_ifname(); |
| 8462 | |
| 8463 | val = get_param(cmd, "FrameName"); |
| 8464 | if (!val) |
| 8465 | return -1; |
| 8466 | |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 8467 | if (strcasecmp(val, "BTMReq") == 0) |
| 8468 | ath_ap_send_frame_btm_req(dut, cmd, ifname); |
| 8469 | else if (strcasecmp(val, "BcnRptReq") == 0) |
| 8470 | ath_ap_send_frame_bcn_rpt_req(dut, cmd, ifname); |
priyadharshini gowthaman | 2a4d20e | 2017-12-28 13:01:34 -0800 | [diff] [blame] | 8471 | else if (strcasecmp(val, "disassoc") == 0) |
| 8472 | ath_ap_send_frame_disassoc(dut, cmd, ifname); |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 8473 | else |
| 8474 | return -1; |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 8475 | |
| 8476 | return 1; |
| 8477 | } |
| 8478 | |
| 8479 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8480 | static int ap_send_frame_vht(struct sigma_dut *dut, struct sigma_conn *conn, |
| 8481 | struct sigma_cmd *cmd) |
| 8482 | { |
| 8483 | switch (get_driver_type()) { |
| 8484 | case DRIVER_ATHEROS: |
| 8485 | return ath_ap_send_frame_vht(dut, conn, cmd); |
| 8486 | break; |
| 8487 | case DRIVER_OPENWRT: |
| 8488 | switch (get_openwrt_driver_type()) { |
| 8489 | case OPENWRT_DRIVER_ATHEROS: |
| 8490 | return ath_ap_send_frame_vht(dut, conn, cmd); |
| 8491 | default: |
| 8492 | send_resp(dut, conn, SIGMA_ERROR, |
| 8493 | "errorCode,Unsupported ap_send_frame with the current openwrt driver"); |
| 8494 | return 0; |
| 8495 | } |
| 8496 | default: |
| 8497 | send_resp(dut, conn, SIGMA_ERROR, |
| 8498 | "errorCode,Unsupported ap_send_frame with the current driver"); |
| 8499 | return 0; |
| 8500 | } |
| 8501 | } |
| 8502 | |
| 8503 | |
priyadharshini gowthaman | a27b5b6 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 8504 | static int ap_send_frame_loc(struct sigma_dut *dut, struct sigma_conn *conn, |
| 8505 | struct sigma_cmd *cmd) |
| 8506 | { |
| 8507 | switch (get_driver_type()) { |
| 8508 | case DRIVER_ATHEROS: |
| 8509 | return ath_ap_send_frame_loc(dut, conn, cmd); |
| 8510 | case DRIVER_OPENWRT: |
| 8511 | switch (get_openwrt_driver_type()) { |
| 8512 | case OPENWRT_DRIVER_ATHEROS: |
| 8513 | return ath_ap_send_frame_loc(dut, conn, cmd); |
| 8514 | default: |
| 8515 | send_resp(dut, conn, SIGMA_ERROR, |
| 8516 | "errorCode,Unsupported ap_send_frame_loc with the current openwrt driver"); |
| 8517 | return 0; |
| 8518 | } |
| 8519 | default: |
| 8520 | send_resp(dut, conn, SIGMA_ERROR, |
| 8521 | "errorCode,Unsupported ap_send_frame_loc with the current driver"); |
| 8522 | return 0; |
| 8523 | } |
| 8524 | } |
| 8525 | |
| 8526 | |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 8527 | static int ap_send_frame_mbo(struct sigma_dut *dut, struct sigma_conn *conn, |
| 8528 | struct sigma_cmd *cmd) |
| 8529 | { |
| 8530 | switch (get_driver_type()) { |
| 8531 | case DRIVER_ATHEROS: |
| 8532 | return ath_ap_send_frame_mbo(dut, conn, cmd); |
| 8533 | case DRIVER_OPENWRT: |
| 8534 | switch (get_openwrt_driver_type()) { |
| 8535 | case OPENWRT_DRIVER_ATHEROS: |
| 8536 | return ath_ap_send_frame_mbo(dut, conn, cmd); |
| 8537 | default: |
| 8538 | send_resp(dut, conn, SIGMA_ERROR, |
| 8539 | "errorCode,Unsupported ap_send_frame with the current openwrt driver"); |
| 8540 | return 0; |
| 8541 | } |
| 8542 | default: |
| 8543 | send_resp(dut, conn, SIGMA_ERROR, |
| 8544 | "errorCode,Unsupported ap_send_frame with the current driver"); |
| 8545 | return 0; |
| 8546 | } |
| 8547 | } |
| 8548 | |
| 8549 | |
Lior David | 0fe101e | 2017-03-09 16:09:50 +0200 | [diff] [blame] | 8550 | static int ap_send_frame_60g(struct sigma_dut *dut, |
| 8551 | struct sigma_conn *conn, |
| 8552 | struct sigma_cmd *cmd) |
| 8553 | { |
| 8554 | switch (get_driver_type()) { |
| 8555 | #ifdef __linux__ |
| 8556 | case DRIVER_WIL6210: |
| 8557 | return wil6210_send_frame_60g(dut, conn, cmd); |
| 8558 | #endif /* __linux__ */ |
| 8559 | default: |
| 8560 | send_resp(dut, conn, SIGMA_ERROR, |
| 8561 | "errorCode,Unsupported sta_set_frame(60G) with the current driver"); |
| 8562 | return 0; |
| 8563 | } |
| 8564 | } |
| 8565 | |
| 8566 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8567 | int cmd_ap_send_frame(struct sigma_dut *dut, struct sigma_conn *conn, |
| 8568 | struct sigma_cmd *cmd) |
| 8569 | { |
| 8570 | /* const char *name = get_param(cmd, "NAME"); */ |
| 8571 | /* const char *ifname = get_param(cmd, "INTERFACE"); */ |
| 8572 | const char *val; |
| 8573 | enum send_frame_type frame; |
| 8574 | enum send_frame_protection protected; |
| 8575 | char buf[100]; |
| 8576 | |
| 8577 | val = get_param(cmd, "Program"); |
| 8578 | if (val) { |
| 8579 | if (strcasecmp(val, "HS2") == 0 || |
Adil Saeed Musthafa | 33ea287 | 2017-04-10 23:13:24 -0700 | [diff] [blame] | 8580 | strcasecmp(val, "HS2-R2") == 0 || |
| 8581 | strcasecmp(val, "IOTLP") == 0) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8582 | return ap_send_frame_hs2(dut, conn, cmd); |
| 8583 | if (strcasecmp(val, "VHT") == 0) |
| 8584 | return ap_send_frame_vht(dut, conn, cmd); |
priyadharshini gowthaman | a27b5b6 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 8585 | if (strcasecmp(val, "LOC") == 0) |
| 8586 | return ap_send_frame_loc(dut, conn, cmd); |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 8587 | if (strcasecmp(val, "MBO") == 0) |
| 8588 | return ap_send_frame_mbo(dut, conn, cmd); |
Lior David | 0fe101e | 2017-03-09 16:09:50 +0200 | [diff] [blame] | 8589 | if (strcasecmp(val, "60GHz") == 0) |
| 8590 | return ap_send_frame_60g(dut, conn, cmd); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8591 | } |
| 8592 | |
| 8593 | val = get_param(cmd, "PMFFrameType"); |
| 8594 | if (val == NULL) |
| 8595 | val = get_param(cmd, "FrameName"); |
| 8596 | if (val == NULL) |
| 8597 | val = get_param(cmd, "Type"); |
| 8598 | if (val == NULL) |
| 8599 | return -1; |
| 8600 | if (strcasecmp(val, "disassoc") == 0) |
| 8601 | frame = DISASSOC; |
| 8602 | else if (strcasecmp(val, "deauth") == 0) |
| 8603 | frame = DEAUTH; |
| 8604 | else if (strcasecmp(val, "saquery") == 0) |
| 8605 | frame = SAQUERY; |
| 8606 | else { |
| 8607 | send_resp(dut, conn, SIGMA_ERROR, "errorCode,Unsupported " |
| 8608 | "PMFFrameType"); |
| 8609 | return 0; |
| 8610 | } |
| 8611 | |
| 8612 | val = get_param(cmd, "PMFProtected"); |
| 8613 | if (val == NULL) |
| 8614 | val = get_param(cmd, "Protected"); |
| 8615 | if (val == NULL) |
| 8616 | return -1; |
| 8617 | if (strcasecmp(val, "Correct-key") == 0 || |
| 8618 | strcasecmp(val, "CorrectKey") == 0) |
| 8619 | protected = CORRECT_KEY; |
| 8620 | else if (strcasecmp(val, "IncorrectKey") == 0) |
| 8621 | protected = INCORRECT_KEY; |
| 8622 | else if (strcasecmp(val, "Unprotected") == 0) |
| 8623 | protected = UNPROTECTED; |
| 8624 | else { |
| 8625 | send_resp(dut, conn, SIGMA_ERROR, "errorCode,Unsupported " |
| 8626 | "PMFProtected"); |
| 8627 | return 0; |
| 8628 | } |
| 8629 | |
| 8630 | val = get_param(cmd, "stationID"); |
| 8631 | if (val == NULL) |
| 8632 | return -1; |
| 8633 | |
| 8634 | if (protected == INCORRECT_KEY || |
| 8635 | (protected == UNPROTECTED && frame == SAQUERY)) |
| 8636 | return ap_inject_frame(dut, conn, frame, protected, val); |
| 8637 | |
| 8638 | switch (frame) { |
| 8639 | case DISASSOC: |
| 8640 | snprintf(buf, sizeof(buf), "disassoc %s test=%d", |
| 8641 | val, protected == CORRECT_KEY); |
| 8642 | break; |
| 8643 | case DEAUTH: |
| 8644 | snprintf(buf, sizeof(buf), "deauth %s test=%d", |
| 8645 | val, protected == CORRECT_KEY); |
| 8646 | break; |
| 8647 | case SAQUERY: |
| 8648 | snprintf(buf, sizeof(buf), "sa_query %s", val); |
| 8649 | break; |
| 8650 | } |
| 8651 | |
| 8652 | if (run_hostapd_cli(dut, buf) != 0) |
| 8653 | return -2; |
| 8654 | |
| 8655 | return 1; |
| 8656 | } |
| 8657 | |
| 8658 | |
| 8659 | static int cmd_ap_get_mac_address(struct sigma_dut *dut, |
| 8660 | struct sigma_conn *conn, |
| 8661 | struct sigma_cmd *cmd) |
| 8662 | { |
| 8663 | #if defined( __linux__) |
| 8664 | /* const char *name = get_param(cmd, "NAME"); */ |
| 8665 | /* const char *ifname = get_param(cmd, "INTERFACE"); */ |
Jouni Malinen | f898464 | 2017-10-12 00:02:37 +0300 | [diff] [blame] | 8666 | char resp[100]; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8667 | unsigned char addr[6]; |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 8668 | char ifname[50]; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8669 | struct ifreq ifr; |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 8670 | int s, wlan_tag = 1; |
| 8671 | const char *val; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8672 | |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 8673 | val = get_param(cmd, "WLAN_TAG"); |
| 8674 | if (val) { |
| 8675 | wlan_tag = atoi(val); |
| 8676 | if (wlan_tag < 1 || wlan_tag > 3) { |
| 8677 | /* |
| 8678 | * The only valid WLAN Tags as of now as per the latest |
| 8679 | * WFA scripts are 1, 2, and 3. |
| 8680 | */ |
Jouni Malinen | f898464 | 2017-10-12 00:02:37 +0300 | [diff] [blame] | 8681 | send_resp(dut, conn, SIGMA_ERROR, |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 8682 | "errorCode,Unsupported WLAN_TAG"); |
| 8683 | return 0; |
| 8684 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8685 | } |
| 8686 | |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 8687 | get_if_name(dut, ifname, sizeof(ifname), wlan_tag); |
| 8688 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8689 | s = socket(AF_INET, SOCK_DGRAM, 0); |
| 8690 | if (s < 0) |
| 8691 | return -1; |
| 8692 | memset(&ifr, 0, sizeof(ifr)); |
Peng Xu | b8fc5cc | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 8693 | strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name)); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8694 | if (ioctl(s, SIOCGIFHWADDR, &ifr) < 0) { |
| 8695 | perror("ioctl"); |
| 8696 | close(s); |
Jouni Malinen | f898464 | 2017-10-12 00:02:37 +0300 | [diff] [blame] | 8697 | snprintf(resp, sizeof(resp), |
| 8698 | "errorCode,Could not find interface %s", ifname); |
| 8699 | send_resp(dut, conn, SIGMA_ERROR, resp); |
| 8700 | return 0; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8701 | } |
| 8702 | close(s); |
| 8703 | memcpy(addr, ifr.ifr_hwaddr.sa_data, 6); |
| 8704 | |
| 8705 | snprintf(resp, sizeof(resp), "mac,%02x:%02x:%02x:%02x:%02x:%02x", |
| 8706 | addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]); |
| 8707 | send_resp(dut, conn, SIGMA_COMPLETE, resp); |
| 8708 | return 0; |
| 8709 | #elif defined( __QNXNTO__) |
| 8710 | char resp[50]; |
| 8711 | unsigned char addr[6]; |
| 8712 | |
| 8713 | if (!sigma_main_ifname) { |
| 8714 | send_resp(dut, conn, SIGMA_ERROR, "ifname is null"); |
| 8715 | return 0; |
| 8716 | } |
| 8717 | |
| 8718 | if (get_hwaddr(sigma_main_ifname, addr) != 0) { |
| 8719 | send_resp(dut, conn, SIGMA_ERROR, |
| 8720 | "errorCode,Failed to get address"); |
| 8721 | return 0; |
| 8722 | } |
| 8723 | snprintf(resp, sizeof(resp), "mac,%02x:%02x:%02x:%02x:%02x:%02x", |
| 8724 | addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]); |
| 8725 | send_resp(dut, conn, SIGMA_COMPLETE, resp); |
| 8726 | return 0; |
| 8727 | #else /* __linux__ */ |
| 8728 | send_resp(dut, conn, SIGMA_ERROR, "errorCode,ap_get_mac_address not " |
| 8729 | "yet supported"); |
| 8730 | return 0; |
| 8731 | #endif /* __linux__ */ |
| 8732 | } |
| 8733 | |
| 8734 | |
Ankita Bajaj | 0d5825b | 2017-10-25 16:20:17 +0530 | [diff] [blame] | 8735 | int sta_cfon_get_mac_address(struct sigma_dut *dut, struct sigma_conn *conn, |
| 8736 | struct sigma_cmd *cmd) |
| 8737 | { |
| 8738 | return cmd_ap_get_mac_address(dut, conn, cmd); |
| 8739 | } |
| 8740 | |
| 8741 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8742 | static int cmd_ap_set_pmf(struct sigma_dut *dut, struct sigma_conn *conn, |
| 8743 | struct sigma_cmd *cmd) |
| 8744 | { |
| 8745 | /* |
| 8746 | * Ignore the command since the parameters are already handled through |
| 8747 | * ap_set_security. |
| 8748 | */ |
| 8749 | |
| 8750 | return 1; |
| 8751 | } |
| 8752 | |
| 8753 | |
| 8754 | static int cmd_ap_set_hs2(struct sigma_dut *dut, struct sigma_conn *conn, |
| 8755 | struct sigma_cmd *cmd) |
| 8756 | { |
| 8757 | /* const char *name = get_param(cmd, "NAME"); */ |
| 8758 | /* const char *ifname = get_param(cmd, "INTERFACE"); */ |
| 8759 | const char *val, *dest; |
| 8760 | char *pos, buf[100]; |
| 8761 | int i, wlan_tag = 1; |
| 8762 | |
| 8763 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_set_hs2: Processing the " |
| 8764 | "following parameters"); |
| 8765 | for (i = 0; i < cmd->count; i++) { |
| 8766 | sigma_dut_print(dut, DUT_MSG_INFO, "%s %s", cmd->params[i], |
| 8767 | (cmd->values[i] ? cmd->values[i] : "NULL")); |
| 8768 | } |
| 8769 | |
| 8770 | val = get_param(cmd, "ICMPv4_ECHO"); |
| 8771 | if (val && atoi(val)) { |
| 8772 | snprintf(buf, sizeof(buf), "ebtables -F"); |
| 8773 | if (system(buf) != 0) { |
| 8774 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 8775 | "Failed to set ebtables rules, RULE-12"); |
| 8776 | } |
| 8777 | return 1; |
| 8778 | } |
| 8779 | |
| 8780 | val = get_param(cmd, "WLAN_TAG"); |
| 8781 | if (val) { |
| 8782 | wlan_tag = atoi(val); |
| 8783 | if (wlan_tag != 1 && wlan_tag != 2) { |
| 8784 | send_resp(dut, conn, SIGMA_INVALID, |
| 8785 | "errorCode,Invalid WLAN_TAG"); |
| 8786 | return 0; |
| 8787 | } |
| 8788 | } |
| 8789 | |
| 8790 | if (wlan_tag == 2) { |
| 8791 | val = get_param(cmd, "PROXY_ARP"); |
| 8792 | if (val) |
| 8793 | dut->ap2_proxy_arp = atoi(val); |
| 8794 | return 1; |
| 8795 | } |
| 8796 | |
| 8797 | dest = get_param(cmd, "STA_MAC"); |
| 8798 | if (dest) { |
| 8799 | /* This is a special/ugly way of using this command. |
| 8800 | * If "Dest" MAC is included, assume that this command |
| 8801 | * is being issued after ap_config_commit for dynamically |
| 8802 | * setting the QoS Map Set. |
| 8803 | */ |
| 8804 | val = get_param(cmd, "QoS_MAP_SET"); |
| 8805 | if (val) { |
| 8806 | dut->ap_qos_map_set = atoi(val); |
| 8807 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_qos_map_set %d", |
| 8808 | dut->ap_qos_map_set); |
| 8809 | } |
| 8810 | |
| 8811 | if (dut->ap_qos_map_set == 1) |
| 8812 | run_hostapd_cli(dut, "set_qos_map_set " QOS_MAP_SET_1); |
| 8813 | else if (dut->ap_qos_map_set == 2) |
| 8814 | run_hostapd_cli(dut, "set_qos_map_set " QOS_MAP_SET_2); |
| 8815 | |
| 8816 | snprintf(buf, sizeof(buf), "send_qos_map_conf %s", dest); |
| 8817 | if (run_hostapd_cli(dut, buf) != 0) |
| 8818 | return -1; |
| 8819 | } |
| 8820 | |
| 8821 | val = get_param(cmd, "DGAF_DISABLE"); |
| 8822 | if (val) |
| 8823 | dut->ap_dgaf_disable = atoi(val); |
| 8824 | |
| 8825 | dut->ap_interworking = 1; |
| 8826 | |
| 8827 | val = get_param(cmd, "INTERWORKING"); |
| 8828 | if (val == NULL) |
| 8829 | val = get_param(cmd, "INTERNETWORKING"); |
| 8830 | if (val != NULL && atoi(val) == 0) { |
| 8831 | dut->ap_interworking = 0; |
| 8832 | dut->ap_hs2 = 0; |
| 8833 | return 1; |
| 8834 | } |
| 8835 | |
| 8836 | val = get_param(cmd, "ACCS_NET_TYPE"); |
| 8837 | if (val) { |
| 8838 | if (strcasecmp(val, "Chargeable_Public_Network") == 0 || |
| 8839 | strcasecmp(val, "Chargable_Public_Network") == 0 || |
| 8840 | strcasecmp(val, "Chargable Public Network") == 0) |
| 8841 | dut->ap_access_net_type = 2; |
| 8842 | else |
| 8843 | dut->ap_access_net_type = atoi(val); |
| 8844 | } |
| 8845 | |
| 8846 | val = get_param(cmd, "INTERNET"); |
| 8847 | if (val) |
| 8848 | dut->ap_internet = atoi(val); |
| 8849 | |
| 8850 | val = get_param(cmd, "VENUE_GRP"); |
| 8851 | if (val) { |
| 8852 | if (strcasecmp(val, "Business") == 0) |
| 8853 | dut->ap_venue_group = 2; |
| 8854 | else |
| 8855 | dut->ap_venue_group = atoi(val); |
| 8856 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_venue_name %d", |
| 8857 | dut->ap_venue_name); |
| 8858 | } |
| 8859 | |
| 8860 | val = get_param(cmd, "VENUE_TYPE"); |
| 8861 | if (val) { |
| 8862 | if (strcasecmp(val, "R&D") == 0) |
| 8863 | dut->ap_venue_type = 8; |
| 8864 | else |
| 8865 | dut->ap_venue_type = atoi(val); |
| 8866 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_venue_type %d", |
| 8867 | dut->ap_venue_type); |
| 8868 | } |
| 8869 | |
| 8870 | val = get_param(cmd, "HESSID"); |
| 8871 | if (val) { |
| 8872 | if (strlen(val) >= sizeof(dut->ap_hessid)) { |
| 8873 | send_resp(dut, conn, SIGMA_ERROR, |
| 8874 | "errorCode,Invalid HESSID"); |
| 8875 | return 0; |
| 8876 | } |
| 8877 | snprintf(dut->ap_hessid, sizeof(dut->ap_hessid), "%s", val); |
| 8878 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_hessid %s", |
| 8879 | dut->ap_hessid); |
| 8880 | } |
| 8881 | |
| 8882 | val = get_param(cmd, "ROAMING_CONS"); |
| 8883 | if (val) { |
| 8884 | if (strlen(val) >= sizeof(dut->ap_roaming_cons)) { |
| 8885 | send_resp(dut, conn, SIGMA_ERROR, |
| 8886 | "errorCode,Invalid ROAMING_CONS"); |
| 8887 | return 0; |
| 8888 | } |
| 8889 | if (strcasecmp(val, "Disabled") == 0) { |
| 8890 | dut->ap_roaming_cons[0] = '\0'; |
| 8891 | } else { |
| 8892 | snprintf(dut->ap_roaming_cons, |
| 8893 | sizeof(dut->ap_roaming_cons), "%s", val); |
| 8894 | } |
| 8895 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_roaming_cons %s", |
| 8896 | dut->ap_roaming_cons); |
| 8897 | } |
| 8898 | |
| 8899 | val = get_param(cmd, "ANQP"); |
| 8900 | if (val) |
| 8901 | dut->ap_anqpserver_on = atoi(val); |
| 8902 | |
| 8903 | val = get_param(cmd, "NAI_REALM_LIST"); |
| 8904 | if (val) { |
| 8905 | dut->ap_nai_realm_list = atoi(val); |
| 8906 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_nai_realm_list %d", |
| 8907 | dut->ap_nai_realm_list); |
| 8908 | } |
| 8909 | |
| 8910 | val = get_param(cmd, "3GPP_INFO"); |
| 8911 | if (val) { |
| 8912 | /* What kind of encoding format is used?! */ |
| 8913 | send_resp(dut, conn, SIGMA_ERROR, "errorCode,3GPP_INFO " |
| 8914 | "not yet supported (contents not fully defined)"); |
| 8915 | return 0; |
| 8916 | } |
| 8917 | |
| 8918 | val = get_param(cmd, "DOMAIN_LIST"); |
| 8919 | if (val) { |
| 8920 | if (strlen(val) >= sizeof(dut->ap_domain_name_list)) { |
| 8921 | send_resp(dut, conn, SIGMA_ERROR, "errorCode,Too long " |
| 8922 | "DOMAIN_LIST"); |
| 8923 | return 0; |
| 8924 | } |
| 8925 | snprintf(dut->ap_domain_name_list, |
| 8926 | sizeof(dut->ap_domain_name_list), "%s", val); |
| 8927 | pos = dut->ap_domain_name_list; |
| 8928 | while (*pos) { |
| 8929 | if (*pos == ';') |
| 8930 | *pos = ','; |
| 8931 | pos++; |
| 8932 | } |
| 8933 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_domain_name_list %s", |
| 8934 | dut->ap_domain_name_list); |
| 8935 | } |
| 8936 | |
| 8937 | val = get_param(cmd, "OPER_NAME"); |
| 8938 | if (val) { |
| 8939 | dut->ap_oper_name = atoi(val); |
| 8940 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_oper_name %d", |
| 8941 | dut->ap_oper_name); |
| 8942 | } |
| 8943 | |
| 8944 | val = get_param(cmd, "VENUE_NAME"); |
| 8945 | if (val) { |
| 8946 | dut->ap_venue_name = atoi(val); |
| 8947 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_venue_name %d", |
| 8948 | dut->ap_venue_name); |
| 8949 | } |
| 8950 | |
| 8951 | val = get_param(cmd, "GAS_CB_DELAY"); |
| 8952 | if (val) { |
| 8953 | dut->ap_gas_cb_delay = atoi(val); |
| 8954 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_gas_cb_delay %d", |
| 8955 | dut->ap_gas_cb_delay); |
| 8956 | } |
| 8957 | |
| 8958 | val = get_param(cmd, "MIH"); |
| 8959 | if (val && atoi(val) > 0) { |
| 8960 | send_resp(dut, conn, SIGMA_ERROR, "errorCode,MIH not " |
| 8961 | "supported"); |
| 8962 | return 0; |
| 8963 | } |
| 8964 | |
| 8965 | val = get_param(cmd, "L2_TRAFFIC_INSPECT"); |
| 8966 | if (val) { |
| 8967 | dut->ap_l2tif = atoi(val); |
| 8968 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_l2tif %d", |
| 8969 | dut->ap_l2tif); |
| 8970 | } |
| 8971 | |
| 8972 | val = get_param(cmd, "BCST_UNCST"); |
| 8973 | if (val) { |
| 8974 | send_resp(dut, conn, SIGMA_ERROR, |
| 8975 | "errorCode,BCST_UNCST not yet supported"); |
| 8976 | return 0; |
| 8977 | } |
| 8978 | |
| 8979 | val = get_param(cmd, "PLMN_MCC"); |
| 8980 | if (val) { |
| 8981 | char mcc[100], *start, *end; |
| 8982 | int i = 0; |
| 8983 | if (strlen(val) >= sizeof(mcc)) { |
| 8984 | send_resp(dut, conn, SIGMA_ERROR, |
| 8985 | "errorCode,PLMN_MCC too long"); |
| 8986 | return 0; |
| 8987 | } |
Peng Xu | b8fc5cc | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 8988 | strlcpy(mcc, val, sizeof(mcc)); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8989 | start = mcc; |
| 8990 | while ((end = strchr(start, ';'))) { |
| 8991 | /* process all except the last */ |
| 8992 | *end = '\0'; |
| 8993 | if (strlen(start) != 3) { |
| 8994 | send_resp(dut, conn, SIGMA_ERROR, |
| 8995 | "errorCode,Invalid PLMN_MCC"); |
| 8996 | return 0; |
| 8997 | } |
| 8998 | snprintf(dut->ap_plmn_mcc[i], |
| 8999 | sizeof(dut->ap_plmn_mcc[i]), "%s", start); |
| 9000 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_plmn_mcc %s", |
| 9001 | dut->ap_plmn_mcc[i]); |
| 9002 | i++; |
| 9003 | start = end + 1; |
| 9004 | *end = ';'; |
| 9005 | } |
| 9006 | if (strlen(start) != 3) { |
| 9007 | send_resp(dut, conn, SIGMA_ERROR, |
| 9008 | "errorCode,Invalid PLMN_MCC"); |
| 9009 | return 0; |
| 9010 | } |
| 9011 | /* process last or only one */ |
| 9012 | snprintf(dut->ap_plmn_mcc[i], |
| 9013 | sizeof(dut->ap_plmn_mcc[i]), "%s", start); |
| 9014 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_plmn_mcc %s", |
| 9015 | dut->ap_plmn_mcc[i]); |
| 9016 | } |
| 9017 | |
| 9018 | val = get_param(cmd, "PLMN_MNC"); |
| 9019 | if (val) { |
| 9020 | char mnc[100], *start, *end; |
| 9021 | int i = 0; |
| 9022 | if (strlen(val) >= sizeof(mnc)) { |
| 9023 | send_resp(dut, conn, SIGMA_ERROR, |
| 9024 | "errorCode,PLMN_MNC too long"); |
| 9025 | return 0; |
| 9026 | } |
Peng Xu | b8fc5cc | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 9027 | strlcpy(mnc, val, sizeof(mnc)); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9028 | start = mnc; |
| 9029 | while ((end = strchr(start, ';'))) { |
| 9030 | *end = '\0'; |
| 9031 | if (strlen(start) != 2 && strlen(start) != 3) { |
| 9032 | send_resp(dut, conn, SIGMA_ERROR, |
| 9033 | "errorCode,Invalid PLMN_MNC"); |
| 9034 | return 0; |
| 9035 | } |
| 9036 | snprintf(dut->ap_plmn_mnc[i], |
| 9037 | sizeof(dut->ap_plmn_mnc[i]), "%s", start); |
| 9038 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_plmn_mnc %s", |
| 9039 | dut->ap_plmn_mnc[i]); |
| 9040 | i++; |
| 9041 | start = end + 1; |
| 9042 | *end = ';'; |
| 9043 | } |
| 9044 | if (strlen(start) != 2 && strlen(start) != 3) { |
| 9045 | send_resp(dut, conn, SIGMA_ERROR, |
| 9046 | "errorCode,Invalid PLMN_MNC"); |
| 9047 | return 0; |
| 9048 | } |
| 9049 | snprintf(dut->ap_plmn_mnc[i], |
| 9050 | sizeof(dut->ap_plmn_mnc[i]), "%s", start); |
| 9051 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_plmn_mnc %s", |
| 9052 | dut->ap_plmn_mnc[i]); |
| 9053 | } |
| 9054 | |
| 9055 | val = get_param(cmd, "PROXY_ARP"); |
| 9056 | if (val) { |
| 9057 | dut->ap_proxy_arp = atoi(val); |
| 9058 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_proxy_arp %d", |
| 9059 | dut->ap_proxy_arp); |
| 9060 | } |
| 9061 | |
| 9062 | val = get_param(cmd, "WAN_METRICS"); |
| 9063 | if (val) { |
| 9064 | dut->ap_wan_metrics = atoi(val); |
| 9065 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_wan_metrics %d", |
| 9066 | dut->ap_wan_metrics); |
| 9067 | } |
| 9068 | |
| 9069 | val = get_param(cmd, "CONN_CAP"); |
| 9070 | if (val) { |
| 9071 | dut->ap_conn_capab = atoi(val); |
| 9072 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_conn_capab %d", |
| 9073 | dut->ap_conn_capab); |
| 9074 | } |
| 9075 | |
| 9076 | val = get_param(cmd, "IP_ADD_TYPE_AVAIL"); |
| 9077 | if (val) { |
| 9078 | dut->ap_ip_addr_type_avail = atoi(val); |
| 9079 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_ip_addr_type_avail %d", |
| 9080 | dut->ap_ip_addr_type_avail); |
| 9081 | } |
| 9082 | |
| 9083 | val = get_param(cmd, "NET_AUTH_TYPE"); |
| 9084 | if (val) { |
| 9085 | dut->ap_net_auth_type = atoi(val); |
| 9086 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_net_auth_type %d", |
| 9087 | dut->ap_net_auth_type); |
| 9088 | } |
| 9089 | |
| 9090 | val = get_param(cmd, "OP_CLASS"); |
| 9091 | if (val == NULL) |
| 9092 | val = get_param(cmd, "OPER_CLASS"); |
| 9093 | if (val) { |
| 9094 | dut->ap_oper_class = atoi(val); |
| 9095 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_oper_class %d", |
| 9096 | dut->ap_oper_class); |
| 9097 | } |
| 9098 | |
| 9099 | val = get_param(cmd, "OSU_PROVIDER_LIST"); |
| 9100 | if (val) { |
| 9101 | dut->ap_osu_provider_list = atoi(val); |
| 9102 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_osu_provider_list %d", |
| 9103 | dut->ap_osu_provider_list); |
| 9104 | } |
| 9105 | |
| 9106 | val = get_param(cmd, "OSU_SERVER_URI"); |
| 9107 | if (val) { |
| 9108 | i = 0; |
| 9109 | do { |
| 9110 | int len; |
| 9111 | const char *uri = val; |
| 9112 | val = strchr(val, ' '); |
| 9113 | len = val ? (val++ - uri) : (int) strlen(uri); |
| 9114 | if (len > 0 && len < 256) { |
| 9115 | memcpy(dut->ap_osu_server_uri[i], uri, len); |
| 9116 | dut->ap_osu_server_uri[i][len] = '\0'; |
| 9117 | sigma_dut_print(dut, DUT_MSG_INFO, |
| 9118 | "ap_osu_server_uri[%d] %s", i, |
| 9119 | dut->ap_osu_server_uri[i]); |
| 9120 | } |
| 9121 | } while (val && ++i < 10); |
| 9122 | } |
| 9123 | |
| 9124 | val = get_param(cmd, "OSU_METHOD"); |
| 9125 | if (val) { |
| 9126 | i = 0; |
| 9127 | do { |
| 9128 | int len; |
| 9129 | const char *method = val; |
| 9130 | val = strchr(val, ' '); |
| 9131 | len = val ? (val++ - method) : (int) strlen(method); |
| 9132 | if (len > 0) { |
| 9133 | if (strncasecmp(method, "SOAP", len) == 0) |
| 9134 | dut->ap_osu_method[i] = 1; |
| 9135 | else if (strncasecmp(method, "OMADM", len) == 0) |
| 9136 | dut->ap_osu_method[i] = 0; |
| 9137 | else |
| 9138 | return -2; |
| 9139 | } |
| 9140 | } while (val && ++i < 10); |
| 9141 | } |
| 9142 | |
| 9143 | val = get_param(cmd, "OSU_SSID"); |
| 9144 | if (val) { |
| 9145 | if (strlen(val) > 0 && strlen(val) <= 32) { |
Peng Xu | b8fc5cc | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 9146 | strlcpy(dut->ap_osu_ssid, val, |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9147 | sizeof(dut->ap_osu_ssid)); |
| 9148 | sigma_dut_print(dut, DUT_MSG_INFO, |
| 9149 | "ap_osu_ssid %s", |
| 9150 | dut->ap_osu_ssid); |
| 9151 | } |
| 9152 | } |
| 9153 | |
| 9154 | val = get_param(cmd, "OSU_ICON_TAG"); |
| 9155 | if (val) |
| 9156 | dut->ap_osu_icon_tag = atoi(val); |
| 9157 | |
| 9158 | val = get_param(cmd, "QoS_MAP_SET"); |
| 9159 | if (val) { |
| 9160 | dut->ap_qos_map_set = atoi(val); |
| 9161 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_qos_map_set %d", |
| 9162 | dut->ap_qos_map_set); |
| 9163 | } |
| 9164 | |
| 9165 | val = get_param(cmd, "BSS_LOAD"); |
| 9166 | if (val) { |
| 9167 | dut->ap_bss_load = atoi(val); |
| 9168 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_bss_load %d", |
| 9169 | dut->ap_bss_load); |
| 9170 | } |
| 9171 | |
| 9172 | return 1; |
| 9173 | } |
| 9174 | |
| 9175 | |
| 9176 | void nfc_status(struct sigma_dut *dut, const char *state, const char *oper) |
| 9177 | { |
| 9178 | char buf[100]; |
| 9179 | |
| 9180 | if (!file_exists("nfc-status")) |
| 9181 | return; |
| 9182 | |
| 9183 | snprintf(buf, sizeof(buf), "./nfc-status %s %s", state, oper); |
| 9184 | run_system(dut, buf); |
| 9185 | } |
| 9186 | |
| 9187 | |
| 9188 | static int run_nfc_command(struct sigma_dut *dut, const char *cmd, |
| 9189 | const char *info) |
| 9190 | { |
| 9191 | int res; |
| 9192 | |
| 9193 | printf("\n\n\n=====[ NFC operation ]=========================\n\n"); |
| 9194 | printf("%s\n\n", info); |
| 9195 | |
| 9196 | nfc_status(dut, "START", info); |
| 9197 | res = run_system(dut, cmd); |
| 9198 | nfc_status(dut, res ? "FAIL" : "SUCCESS", info); |
| 9199 | if (res) { |
| 9200 | sigma_dut_print(dut, DUT_MSG_INFO, "Failed to run '%s': %d", |
| 9201 | cmd, res); |
| 9202 | return res; |
| 9203 | } |
| 9204 | |
| 9205 | return 0; |
| 9206 | } |
| 9207 | |
| 9208 | |
| 9209 | static int ap_nfc_write_config_token(struct sigma_dut *dut, |
| 9210 | struct sigma_conn *conn, |
| 9211 | struct sigma_cmd *cmd) |
| 9212 | { |
| 9213 | int res; |
| 9214 | char buf[300]; |
| 9215 | |
| 9216 | run_system(dut, "killall wps-ap-nfc.py"); |
| 9217 | unlink("nfc-success"); |
| 9218 | snprintf(buf, sizeof(buf), |
| 9219 | "./wps-ap-nfc.py --no-wait %s%s --success nfc-success write-config", |
| 9220 | dut->summary_log ? "--summary " : "", |
| 9221 | dut->summary_log ? dut->summary_log : ""); |
| 9222 | res = run_nfc_command(dut, buf, |
| 9223 | "Touch NFC Tag to write WPS configuration token"); |
| 9224 | if (res || !file_exists("nfc-success")) { |
| 9225 | send_resp(dut, conn, SIGMA_ERROR, |
| 9226 | "ErrorCode,Failed to write tag"); |
| 9227 | return 0; |
| 9228 | } |
| 9229 | |
| 9230 | return 1; |
| 9231 | } |
| 9232 | |
| 9233 | |
| 9234 | static int ap_nfc_wps_read_passwd(struct sigma_dut *dut, |
| 9235 | struct sigma_conn *conn, |
| 9236 | struct sigma_cmd *cmd) |
| 9237 | { |
| 9238 | int res; |
| 9239 | char buf[300]; |
| 9240 | |
| 9241 | run_system(dut, "killall wps-ap-nfc.py"); |
| 9242 | |
| 9243 | unlink("nfc-success"); |
| 9244 | snprintf(buf, sizeof(buf), |
| 9245 | "./wps-ap-nfc.py -1 --no-wait %s%s --success nfc-success", |
| 9246 | dut->summary_log ? "--summary " : "", |
| 9247 | dut->summary_log ? dut->summary_log : ""); |
| 9248 | res = run_nfc_command(dut, buf, "Touch NFC Tag to read it"); |
| 9249 | if (res || !file_exists("nfc-success")) { |
| 9250 | send_resp(dut, conn, SIGMA_ERROR, |
| 9251 | "ErrorCode,Failed to read tag"); |
| 9252 | return 0; |
| 9253 | } |
| 9254 | |
| 9255 | return 1; |
| 9256 | } |
| 9257 | |
| 9258 | |
| 9259 | static int ap_nfc_write_password_token(struct sigma_dut *dut, |
| 9260 | struct sigma_conn *conn, |
| 9261 | struct sigma_cmd *cmd) |
| 9262 | { |
| 9263 | int res; |
| 9264 | char buf[300]; |
| 9265 | |
| 9266 | run_system(dut, "killall wps-ap-nfc.py"); |
| 9267 | unlink("nfc-success"); |
| 9268 | snprintf(buf, sizeof(buf), |
| 9269 | "./wps-ap-nfc.py --no-wait %s%s --success nfc-success write-password", |
| 9270 | dut->summary_log ? "--summary " : "", |
| 9271 | dut->summary_log ? dut->summary_log : ""); |
| 9272 | res = run_nfc_command(dut, buf, |
| 9273 | "Touch NFC Tag to write WPS password token"); |
| 9274 | if (res || !file_exists("nfc-success")) { |
| 9275 | send_resp(dut, conn, SIGMA_ERROR, |
| 9276 | "ErrorCode,Failed to write tag"); |
| 9277 | return 0; |
| 9278 | } |
| 9279 | |
| 9280 | if (run_hostapd_cli(dut, "wps_nfc_token enable") != 0) { |
| 9281 | send_resp(dut, conn, SIGMA_ERROR, |
| 9282 | "ErrorCode,Failed to enable NFC password token"); |
| 9283 | return 0; |
| 9284 | } |
| 9285 | |
| 9286 | return 1; |
| 9287 | } |
| 9288 | |
| 9289 | |
| 9290 | static int ap_nfc_wps_connection_handover(struct sigma_dut *dut, |
| 9291 | struct sigma_conn *conn, |
| 9292 | struct sigma_cmd *cmd) |
| 9293 | { |
| 9294 | int res; |
| 9295 | char buf[300]; |
| 9296 | |
| 9297 | run_system(dut, "killall wps-ap-nfc.py"); |
| 9298 | unlink("nfc-success"); |
| 9299 | snprintf(buf, sizeof(buf), |
| 9300 | "./wps-ap-nfc.py -1 --no-wait %s%s --success nfc-success", |
| 9301 | dut->summary_log ? "--summary " : "", |
| 9302 | dut->summary_log ? dut->summary_log : ""); |
| 9303 | res = run_nfc_command(dut, buf, |
| 9304 | "Touch NFC Device to respond to WPS connection handover"); |
| 9305 | if (res) { |
| 9306 | send_resp(dut, conn, SIGMA_ERROR, |
| 9307 | "ErrorCode,Failed to enable NFC for connection " |
| 9308 | "handover"); |
| 9309 | return 0; |
| 9310 | } |
| 9311 | if (!file_exists("nfc-success")) { |
| 9312 | send_resp(dut, conn, SIGMA_ERROR, |
| 9313 | "ErrorCode,Failed to complete NFC connection handover"); |
| 9314 | return 0; |
| 9315 | } |
| 9316 | |
| 9317 | return 1; |
| 9318 | } |
| 9319 | |
| 9320 | |
| 9321 | static int cmd_ap_nfc_action(struct sigma_dut *dut, struct sigma_conn *conn, |
| 9322 | struct sigma_cmd *cmd) |
| 9323 | { |
| 9324 | /* const char *name = get_param(cmd, "Name"); */ |
| 9325 | /* const char *intf = get_param(cmd, "Interface"); */ |
| 9326 | const char *oper = get_param(cmd, "Operation"); |
| 9327 | |
| 9328 | if (oper == NULL) |
| 9329 | return -1; |
| 9330 | |
| 9331 | if (strcasecmp(oper, "WRITE_CONFIG") == 0) |
| 9332 | return ap_nfc_write_config_token(dut, conn, cmd); |
| 9333 | if (strcasecmp(oper, "WRITE_PASSWD") == 0) |
| 9334 | return ap_nfc_write_password_token(dut, conn, cmd); |
| 9335 | if (strcasecmp(oper, "WPS_READ_PASSWD") == 0) |
| 9336 | return ap_nfc_wps_read_passwd(dut, conn, cmd); |
| 9337 | if (strcasecmp(oper, "WPS_CONN_HNDOVR") == 0) |
| 9338 | return ap_nfc_wps_connection_handover(dut, conn, cmd); |
| 9339 | |
| 9340 | send_resp(dut, conn, SIGMA_ERROR, "ErrorCode,Unsupported operation"); |
| 9341 | return 0; |
| 9342 | } |
| 9343 | |
| 9344 | |
| 9345 | static int cmd_ap_wps_read_pin(struct sigma_dut *dut, struct sigma_conn *conn, |
| 9346 | struct sigma_cmd *cmd) |
| 9347 | { |
| 9348 | char *pin = "12345670"; /* TODO: use random PIN */ |
| 9349 | char resp[100]; |
| 9350 | |
| 9351 | snprintf(resp, sizeof(resp), "PIN,%s", pin); |
| 9352 | send_resp(dut, conn, SIGMA_COMPLETE, resp); |
| 9353 | |
| 9354 | return 0; |
| 9355 | } |
| 9356 | |
| 9357 | |
| 9358 | static int ath_vht_op_mode_notif(struct sigma_dut *dut, const char *ifname, |
| 9359 | const char *val) |
| 9360 | { |
| 9361 | char *token, *result; |
| 9362 | int nss = 0, chwidth = 0; |
| 9363 | char buf[100]; |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 9364 | char *saveptr; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9365 | |
| 9366 | /* |
| 9367 | * The following commands should be invoked to generate |
| 9368 | * VHT op mode notification |
| 9369 | */ |
| 9370 | |
| 9371 | /* Extract the NSS info */ |
| 9372 | token = strdup(val); |
| 9373 | if (!token) |
| 9374 | return -1; |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 9375 | result = strtok_r(token, ";", &saveptr); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9376 | if (result) { |
| 9377 | int count = atoi(result); |
| 9378 | |
| 9379 | /* We do not support NSS > 3 */ |
| 9380 | if (count < 0 || count > 3) { |
| 9381 | free(token); |
| 9382 | return -1; |
| 9383 | } |
| 9384 | |
| 9385 | /* Convert nss to chainmask */ |
| 9386 | while (count--) |
| 9387 | nss = (nss << 1) | 1; |
| 9388 | |
| 9389 | snprintf(buf, sizeof(buf), "iwpriv %s rxchainmask %d", |
| 9390 | ifname, nss); |
| 9391 | if (system(buf) != 0) { |
| 9392 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 9393 | "iwpriv wifi1 rxchainmask failed!"); |
| 9394 | } |
| 9395 | } |
| 9396 | |
| 9397 | /* Extract the Channel width info */ |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 9398 | result = strtok_r(NULL, ";", &saveptr); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9399 | if (result) { |
| 9400 | switch (atoi(result)) { |
| 9401 | case 20: |
| 9402 | chwidth = 0; |
| 9403 | break; |
| 9404 | case 40: |
| 9405 | chwidth = 1; |
| 9406 | break; |
| 9407 | case 80: |
| 9408 | chwidth = 2; |
| 9409 | break; |
| 9410 | case 160: |
| 9411 | chwidth = 3; |
| 9412 | break; |
| 9413 | default: |
| 9414 | chwidth = 2; |
| 9415 | break; |
| 9416 | } |
| 9417 | snprintf(buf, sizeof(buf), "iwpriv %s chwidth %d", |
| 9418 | ifname, chwidth); |
| 9419 | if (system(buf) != 0) { |
| 9420 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 9421 | "iwpriv chwidth failed!"); |
| 9422 | } |
| 9423 | } |
| 9424 | |
| 9425 | /* Send the opmode notification */ |
Sunil Dutt | 27ec7f6 | 2017-09-14 18:22:59 +0300 | [diff] [blame] | 9426 | snprintf(buf, sizeof(buf), "iwpriv %s opmode_notify 1", ifname); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9427 | if (system(buf) != 0) { |
| 9428 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 9429 | "iwpriv opmode_notify failed!"); |
| 9430 | } |
| 9431 | free(token); |
| 9432 | |
| 9433 | return 0; |
| 9434 | } |
| 9435 | |
| 9436 | |
| 9437 | static int ath_vht_nss_mcs(struct sigma_dut *dut, const char *ifname, |
| 9438 | const char *val) |
| 9439 | { |
| 9440 | /* String (nss_operating_mode; mcs_operating_mode) */ |
| 9441 | int nss, mcs; |
| 9442 | char *token, *result; |
| 9443 | char buf[100]; |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 9444 | char *saveptr; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9445 | |
| 9446 | token = strdup(val); |
| 9447 | if (!token) |
| 9448 | return -1; |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 9449 | result = strtok_r(token, ";", &saveptr); |
Pradeep Reddy POTTETI | 41b8c54 | 2016-06-15 16:09:46 +0530 | [diff] [blame] | 9450 | if (!result) { |
| 9451 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 9452 | "VHT NSS not specified"); |
| 9453 | goto end; |
| 9454 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9455 | if (strcasecmp(result, "def") != 0) { |
| 9456 | nss = atoi(result); |
| 9457 | |
| 9458 | if (nss == 4) |
| 9459 | ath_disable_txbf(dut, ifname); |
| 9460 | |
| 9461 | snprintf(buf, sizeof(buf), "iwpriv %s nss %d", ifname, nss); |
| 9462 | if (system(buf) != 0) { |
| 9463 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 9464 | "iwpriv nss failed"); |
| 9465 | } |
| 9466 | } else { |
| 9467 | if (dut->device_type == AP_testbed && dut->ap_sgi80 == 1) { |
| 9468 | snprintf(buf, sizeof(buf), "iwpriv %s nss 1", ifname); |
| 9469 | if (system(buf) != 0) { |
| 9470 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 9471 | "iwpriv nss failed"); |
| 9472 | } |
| 9473 | } |
| 9474 | } |
| 9475 | |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 9476 | result = strtok_r(NULL, ";", &saveptr); |
Pradeep Reddy POTTETI | 41b8c54 | 2016-06-15 16:09:46 +0530 | [diff] [blame] | 9477 | if (!result) { |
| 9478 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 9479 | "VHT MCS not specified"); |
| 9480 | goto end; |
| 9481 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9482 | if (strcasecmp(result, "def") == 0) { |
| 9483 | if (dut->device_type == AP_testbed && dut->ap_sgi80 == 1) { |
| 9484 | snprintf(buf, sizeof(buf), "iwpriv %s vhtmcs 7", |
| 9485 | ifname); |
| 9486 | if (system(buf) != 0) { |
| 9487 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 9488 | "iwpriv vhtmcs failed"); |
| 9489 | } |
| 9490 | } else { |
| 9491 | snprintf(buf, sizeof(buf), |
| 9492 | "iwpriv %s set11NRates 0", ifname); |
| 9493 | if (system(buf) != 0) { |
| 9494 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 9495 | "iwpriv set11NRates failed"); |
| 9496 | } |
| 9497 | } |
| 9498 | } else { |
| 9499 | mcs = atoi(result); |
| 9500 | snprintf(buf, sizeof(buf), "iwpriv %s vhtmcs %d", ifname, mcs); |
| 9501 | if (system(buf) != 0) { |
| 9502 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 9503 | "iwpriv vhtmcs failed"); |
| 9504 | } |
| 9505 | } |
| 9506 | |
Pradeep Reddy POTTETI | 41b8c54 | 2016-06-15 16:09:46 +0530 | [diff] [blame] | 9507 | end: |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9508 | free(token); |
| 9509 | return 0; |
| 9510 | } |
| 9511 | |
| 9512 | |
| 9513 | static int ath_vht_chnum_band(struct sigma_dut *dut, const char *ifname, |
| 9514 | const char *val) |
| 9515 | { |
| 9516 | char *token, *result; |
| 9517 | int channel = 36; |
| 9518 | int chwidth = 80; |
| 9519 | char buf[100]; |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 9520 | char *saveptr; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9521 | |
| 9522 | /* Extract the channel info */ |
| 9523 | token = strdup(val); |
| 9524 | if (!token) |
| 9525 | return -1; |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 9526 | result = strtok_r(token, ";", &saveptr); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9527 | if (result) |
| 9528 | channel = atoi(result); |
| 9529 | |
| 9530 | /* Extract the channel width info */ |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 9531 | result = strtok_r(NULL, ";", &saveptr); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9532 | if (result) |
| 9533 | chwidth = atoi(result); |
| 9534 | |
| 9535 | /* Issue the channel switch command */ |
| 9536 | snprintf(buf, sizeof(buf), "iwpriv %s doth_ch_chwidth %d 10 %d", |
| 9537 | ifname, channel, chwidth); |
| 9538 | if (system(buf) != 0) { |
| 9539 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 9540 | "iwpriv doth_ch_chwidth failed!"); |
| 9541 | } |
| 9542 | |
| 9543 | free(token); |
| 9544 | return 0; |
| 9545 | } |
| 9546 | |
| 9547 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9548 | static int ath_ndpa_stainfo_mac(struct sigma_dut *dut, const char *ifname, |
| 9549 | const char *val) |
| 9550 | { |
| 9551 | char buf[80]; |
| 9552 | unsigned char mac_addr[6]; |
| 9553 | |
| 9554 | if (parse_mac_address(dut, val, mac_addr) < 0) |
| 9555 | return -1; |
| 9556 | |
| 9557 | snprintf(buf, sizeof(buf), |
| 9558 | "wifitool %s beeliner_fw_test 92 0x%02x%02x%02x%02x", |
| 9559 | ifname, mac_addr[0], mac_addr[1], mac_addr[2], mac_addr[3]); |
| 9560 | run_system(dut, buf); |
| 9561 | |
| 9562 | snprintf(buf, sizeof(buf), "wifitool %s beeliner_fw_test 93 0x%02x%02x", |
| 9563 | ifname, mac_addr[4], mac_addr[5]); |
| 9564 | run_system(dut, buf); |
| 9565 | |
| 9566 | snprintf(buf, sizeof(buf), "wifitool %s beeliner_fw_test 94 1", ifname); |
| 9567 | run_system(dut, buf); |
| 9568 | |
| 9569 | return 0; |
| 9570 | } |
| 9571 | |
| 9572 | |
priyadharshini gowthaman | e5e2517 | 2015-12-08 14:53:48 -0800 | [diff] [blame] | 9573 | void novap_reset(struct sigma_dut *dut, const char *ifname) |
Priyadharshini Gowthaman | 39beafa | 2015-11-09 14:11:25 -0800 | [diff] [blame] | 9574 | { |
| 9575 | char buf[60]; |
| 9576 | |
| 9577 | snprintf(buf, sizeof(buf), "iwpriv %s novap_reset 1", ifname); |
| 9578 | if (system(buf) != 0) { |
| 9579 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 9580 | "disabling novap reset failed"); |
| 9581 | } |
| 9582 | } |
| 9583 | |
| 9584 | |
Adil Saeed Musthafa | 6906372 | 2017-04-10 23:13:40 -0700 | [diff] [blame] | 9585 | struct mbo_pref_ap * mbo_find_nebor_ap_entry(struct sigma_dut *dut, |
| 9586 | const uint8_t *mac_addr) |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 9587 | { |
Adil Saeed Musthafa | 6906372 | 2017-04-10 23:13:40 -0700 | [diff] [blame] | 9588 | int i; |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 9589 | |
Adil Saeed Musthafa | 6906372 | 2017-04-10 23:13:40 -0700 | [diff] [blame] | 9590 | for (i = 0; i < dut->mbo_pref_ap_cnt; i++) { |
| 9591 | if (memcmp(mac_addr, dut->mbo_pref_aps[i].mac_addr, |
| 9592 | ETH_ALEN) == 0) |
| 9593 | return &dut->mbo_pref_aps[i]; |
| 9594 | } |
| 9595 | return NULL; |
| 9596 | } |
| 9597 | |
| 9598 | |
| 9599 | static void mbo_add_nebor_entry(struct sigma_dut *dut, const uint8_t *mac_addr, |
| 9600 | int ap_ne_class, int ap_ne_op_ch, |
| 9601 | int ap_ne_pref) |
| 9602 | { |
| 9603 | struct mbo_pref_ap *entry; |
| 9604 | uint8_t self_mac[ETH_ALEN]; |
| 9605 | char ifname[50]; |
| 9606 | |
| 9607 | get_if_name(dut, ifname, sizeof(ifname), 1); |
| 9608 | get_hwaddr(ifname, self_mac); |
| 9609 | |
| 9610 | if (memcmp(mac_addr, self_mac, ETH_ALEN) == 0) |
| 9611 | entry = &dut->mbo_self_ap_tuple; |
| 9612 | else |
| 9613 | entry = mbo_find_nebor_ap_entry(dut, mac_addr); |
| 9614 | |
| 9615 | if (!entry) { |
| 9616 | if (dut->mbo_pref_ap_cnt >= MBO_MAX_PREF_BSSIDS) { |
| 9617 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 9618 | "Nebor AP List is full. Not adding"); |
| 9619 | return; |
| 9620 | } |
| 9621 | entry = &dut->mbo_pref_aps[dut->mbo_pref_ap_cnt]; |
| 9622 | dut->mbo_pref_ap_cnt++; |
| 9623 | memcpy(entry->mac_addr, mac_addr, ETH_ALEN); |
| 9624 | entry->ap_ne_class = -1; |
| 9625 | entry->ap_ne_op_ch = -1; |
| 9626 | entry->ap_ne_pref = -1; |
| 9627 | } |
| 9628 | if (ap_ne_class != -1) |
| 9629 | entry->ap_ne_class = ap_ne_class; |
| 9630 | if (ap_ne_op_ch != -1) |
| 9631 | entry->ap_ne_op_ch = ap_ne_op_ch; |
| 9632 | if (ap_ne_pref != -1) |
| 9633 | entry->ap_ne_pref = ap_ne_pref; |
| 9634 | } |
| 9635 | |
| 9636 | |
| 9637 | static int ath_set_nebor_bssid(struct sigma_dut *dut, const char *ifname, |
| 9638 | struct sigma_cmd *cmd) |
| 9639 | { |
| 9640 | unsigned char mac_addr[ETH_ALEN]; |
| 9641 | const char *val; |
| 9642 | /* |
| 9643 | * -1 is invalid value for the following |
| 9644 | * to differentiate between unset and set values |
| 9645 | * -1 => implies not set by CAPI |
| 9646 | */ |
| 9647 | int ap_ne_class = -1, ap_ne_op_ch = -1, ap_ne_pref = -1; |
| 9648 | int list_offset = dut->mbo_pref_ap_cnt; |
| 9649 | |
| 9650 | if (list_offset >= MBO_MAX_PREF_BSSIDS) { |
| 9651 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 9652 | "AP Pref Entry list is full"); |
| 9653 | return -1; |
| 9654 | } |
| 9655 | |
| 9656 | val = get_param(cmd, "Nebor_Op_Class"); |
| 9657 | if (val) |
| 9658 | ap_ne_class = atoi(val); |
| 9659 | |
| 9660 | val = get_param(cmd, "Nebor_Op_Ch"); |
| 9661 | if (val) |
| 9662 | ap_ne_op_ch = atoi(val); |
| 9663 | |
| 9664 | val = get_param(cmd, "Nebor_Pref"); |
| 9665 | if (val) |
| 9666 | ap_ne_pref = atoi(val); |
| 9667 | |
| 9668 | val = get_param(cmd, "Nebor_BSSID"); |
| 9669 | if (!val || parse_mac_address(dut, val, mac_addr) < 0) |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 9670 | return -1; |
| 9671 | |
Adil Saeed Musthafa | 6906372 | 2017-04-10 23:13:40 -0700 | [diff] [blame] | 9672 | mbo_add_nebor_entry(dut, mac_addr, ap_ne_class, ap_ne_op_ch, |
| 9673 | ap_ne_pref); |
| 9674 | apply_mbo_pref_ap_list(dut); |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 9675 | return 0; |
| 9676 | } |
| 9677 | |
| 9678 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9679 | static int ath_ap_set_rfeature(struct sigma_dut *dut, struct sigma_conn *conn, |
| 9680 | struct sigma_cmd *cmd) |
| 9681 | { |
| 9682 | const char *val; |
| 9683 | char *ifname; |
| 9684 | |
| 9685 | ifname = get_main_ifname(); |
| 9686 | |
Priyadharshini Gowthaman | 39beafa | 2015-11-09 14:11:25 -0800 | [diff] [blame] | 9687 | /* Disable vap reset between the commands */ |
| 9688 | novap_reset(dut, ifname); |
| 9689 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9690 | val = get_param(cmd, "Opt_md_notif_ie"); |
| 9691 | if (val && ath_vht_op_mode_notif(dut, ifname, val) < 0) |
| 9692 | return -1; |
| 9693 | |
| 9694 | /* TODO: Optional arguments */ |
| 9695 | |
| 9696 | val = get_param(cmd, "nss_mcs_opt"); |
| 9697 | if (val && ath_vht_nss_mcs(dut, ifname, val) < 0) |
| 9698 | return -1; |
| 9699 | |
| 9700 | val = get_param(cmd, "chnum_band"); |
| 9701 | if (val && ath_vht_chnum_band(dut, ifname, val) < 0) |
| 9702 | return -1; |
| 9703 | |
| 9704 | val = get_param(cmd, "RTS_FORCE"); |
| 9705 | if (val) |
| 9706 | ath_config_rts_force(dut, ifname, val); |
| 9707 | |
| 9708 | val = get_param(cmd, "DYN_BW_SGNL"); |
| 9709 | if (val) |
| 9710 | ath_config_dyn_bw_sig(dut, ifname, val); |
| 9711 | |
| 9712 | val = get_param(cmd, "CTS_WIDTH"); |
| 9713 | if (val) |
| 9714 | ath_set_cts_width(dut, ifname, val); |
| 9715 | |
| 9716 | val = get_param(cmd, "Ndpa_stainfo_mac"); |
| 9717 | if (val && ath_ndpa_stainfo_mac(dut, ifname, val) < 0) |
| 9718 | return -1; |
| 9719 | |
| 9720 | val = get_param(cmd, "txBandwidth"); |
| 9721 | if (val && ath_set_width(dut, conn, ifname, val) < 0) |
| 9722 | return -1; |
| 9723 | |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 9724 | val = get_param(cmd, "Assoc_Disallow"); |
| 9725 | if (val) |
| 9726 | ath_set_assoc_disallow(dut, ifname, val); |
| 9727 | |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 9728 | |
Adil Saeed Musthafa | 6906372 | 2017-04-10 23:13:40 -0700 | [diff] [blame] | 9729 | ath_set_nebor_bssid(dut, ifname, cmd); |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 9730 | val = get_param(cmd, "BTMReq_DisAssoc_Imnt"); |
priyadharshini gowthaman | 776562e | 2017-12-20 12:33:34 -0800 | [diff] [blame] | 9731 | if (val) { |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 9732 | dut->ap_btmreq_disassoc_imnt = atoi(val); |
priyadharshini gowthaman | 776562e | 2017-12-20 12:33:34 -0800 | [diff] [blame] | 9733 | dut->ap_disassoc_timer = 1000; |
| 9734 | } |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 9735 | |
| 9736 | val = get_param(cmd, "BTMReq_Term_Bit"); |
| 9737 | if (val) |
| 9738 | dut->ap_btmreq_term_bit = atoi(val); |
| 9739 | |
Adil Saeed Musthafa | 48c5ab9 | 2017-04-10 23:13:35 -0700 | [diff] [blame] | 9740 | val = get_param(cmd, "Assoc_Delay"); |
priyadharshini gowthaman | 776562e | 2017-12-20 12:33:34 -0800 | [diff] [blame] | 9741 | if (val) { |
| 9742 | dut->ap_assoc_delay = 1; |
Adil Saeed Musthafa | 48c5ab9 | 2017-04-10 23:13:35 -0700 | [diff] [blame] | 9743 | run_system_wrapper(dut, "iwpriv %s mbo_asoc_ret %s", |
| 9744 | ifname, val); |
priyadharshini gowthaman | 776562e | 2017-12-20 12:33:34 -0800 | [diff] [blame] | 9745 | } |
Adil Saeed Musthafa | 48c5ab9 | 2017-04-10 23:13:35 -0700 | [diff] [blame] | 9746 | |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 9747 | val = get_param(cmd, "Disassoc_Timer"); |
| 9748 | if (val) |
| 9749 | dut->ap_disassoc_timer = atoi(val); |
| 9750 | |
| 9751 | val = get_param(cmd, "BSS_Term_Duration"); |
| 9752 | if (val) |
| 9753 | dut->ap_btmreq_bss_term_dur = atoi(val); |
| 9754 | |
priyadharshini gowthaman | 94062b5 | 2017-12-20 12:33:34 -0800 | [diff] [blame] | 9755 | val = get_param(cmd, "BSS_Term_TSF"); |
| 9756 | if (val) |
| 9757 | dut->ap_btmreq_bss_term_tsf = atoi(val); |
| 9758 | |
priyadharshini gowthaman | cb22e43 | 2017-12-28 15:23:31 -0800 | [diff] [blame] | 9759 | val = get_param(cmd, "TxPower"); |
| 9760 | if (val) |
| 9761 | ath_set_txpower(dut, ifname, val); |
| 9762 | |
| 9763 | val = get_param(cmd, "DownlinkAvailCap"); |
| 9764 | if (val) |
| 9765 | dut->ap_dl_availcap = atoi(val); |
| 9766 | |
| 9767 | val = get_param(cmd, "UplinkAvailCap"); |
| 9768 | if (val) { |
| 9769 | dut->ap_ul_availcap = atoi(val); |
| 9770 | run_system_wrapper(dut, "iwpriv %s oce_wan_mtr %d %d", ifname, |
| 9771 | dut->ap_dl_availcap, dut->ap_ul_availcap); |
| 9772 | } |
| 9773 | |
| 9774 | val = get_param(cmd, "RSSIthreshold"); |
| 9775 | if (val) { |
| 9776 | int rssithreshold; |
| 9777 | |
| 9778 | run_system_wrapper(dut, "iwpriv %s oce_asoc_rej 1", ifname); |
| 9779 | rssithreshold = atoi(val); |
| 9780 | run_system_wrapper(dut, "iwpriv %s oce_asoc_rssi %d", ifname, |
| 9781 | rssithreshold); |
| 9782 | } |
| 9783 | |
| 9784 | val = get_param(cmd, "RetryDelay"); |
| 9785 | if (val) { |
| 9786 | int retrydelay; |
| 9787 | |
| 9788 | run_system_wrapper(dut, "iwpriv %s oce_asoc_rej 1", ifname); |
| 9789 | retrydelay = atoi(val); |
| 9790 | run_system_wrapper(dut, "iwpriv %s oce_asoc_dly %d", ifname, |
| 9791 | retrydelay); |
| 9792 | } |
| 9793 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9794 | return 1; |
| 9795 | } |
| 9796 | |
| 9797 | |
Pradeep Reddy POTTETI | 88fd82c | 2016-03-14 12:20:18 +0530 | [diff] [blame] | 9798 | static int wcn_vht_chnum_band(struct sigma_dut *dut, const char *ifname, |
| 9799 | const char *val) |
| 9800 | { |
| 9801 | char *token, *result; |
| 9802 | int channel = 36; |
| 9803 | char buf[100]; |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 9804 | char *saveptr; |
Pradeep Reddy POTTETI | 88fd82c | 2016-03-14 12:20:18 +0530 | [diff] [blame] | 9805 | |
| 9806 | /* Extract the channel info */ |
| 9807 | token = strdup(val); |
| 9808 | if (!token) |
| 9809 | return -1; |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 9810 | result = strtok_r(token, ";", &saveptr); |
Pradeep Reddy POTTETI | 88fd82c | 2016-03-14 12:20:18 +0530 | [diff] [blame] | 9811 | if (result) |
| 9812 | channel = atoi(result); |
| 9813 | |
| 9814 | /* Issue the channel switch command */ |
| 9815 | snprintf(buf, sizeof(buf), "iwpriv %s setChanChange %d", |
| 9816 | ifname, channel); |
| 9817 | if (system(buf) != 0) { |
| 9818 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 9819 | "iwpriv setChanChange failed!"); |
| 9820 | } |
| 9821 | |
| 9822 | free(token); |
| 9823 | return 0; |
| 9824 | } |
| 9825 | |
| 9826 | |
| 9827 | static int wcn_ap_set_rfeature(struct sigma_dut *dut, struct sigma_conn *conn, |
| 9828 | struct sigma_cmd *cmd) |
| 9829 | { |
| 9830 | const char *val; |
| 9831 | char *ifname; |
| 9832 | |
| 9833 | ifname = get_main_ifname(); |
| 9834 | |
| 9835 | val = get_param(cmd, "chnum_band"); |
| 9836 | if (val && wcn_vht_chnum_band(dut, ifname, val) < 0) |
| 9837 | return -1; |
| 9838 | |
| 9839 | return 1; |
| 9840 | } |
| 9841 | |
| 9842 | |
Mohammed Shafi Shajakhan | b53d8f9 | 2017-02-28 09:05:15 +0530 | [diff] [blame] | 9843 | static int mac80211_vht_chnum_band(struct sigma_dut *dut, const char *ifname, |
| 9844 | const char *val) |
| 9845 | { |
| 9846 | char *token, *result; |
| 9847 | int channel = 36, chwidth = 80, center_freq_idx, center_freq, |
| 9848 | channel_freq; |
| 9849 | char buf[100]; |
| 9850 | char *saveptr; |
| 9851 | |
| 9852 | /* Extract the channel info */ |
| 9853 | token = strdup(val); |
| 9854 | if (!token) |
| 9855 | return -1; |
| 9856 | result = strtok_r(token, ";", &saveptr); |
| 9857 | if (result) |
| 9858 | channel = atoi(result); |
| 9859 | |
| 9860 | /* Extract the channel width info */ |
| 9861 | result = strtok_r(NULL, ";", &saveptr); |
| 9862 | if (result) |
| 9863 | chwidth = atoi(result); |
| 9864 | |
| 9865 | center_freq_idx = get_oper_centr_freq_seq_idx(chwidth, channel); |
| 9866 | if (center_freq_idx < 0) { |
| 9867 | free(token); |
| 9868 | return -1; |
| 9869 | } |
| 9870 | |
| 9871 | center_freq = get_5g_channel_freq(center_freq_idx); |
| 9872 | channel_freq = get_5g_channel_freq(channel); |
| 9873 | |
| 9874 | /* Issue the channel switch command */ |
| 9875 | snprintf(buf, sizeof(buf), |
| 9876 | " -i %s chan_switch 10 %d sec_channel_offset=1 center_freq1=%d bandwidth=%d blocktx vht", |
| 9877 | ifname, channel_freq, center_freq, chwidth); |
| 9878 | if (run_hostapd_cli(dut,buf) != 0) { |
| 9879 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 9880 | "hostapd_cli chan_switch failed"); |
| 9881 | } |
| 9882 | |
| 9883 | free(token); |
| 9884 | return 0; |
| 9885 | } |
| 9886 | |
| 9887 | |
| 9888 | static int mac80211_ap_set_rfeature(struct sigma_dut *dut, |
| 9889 | struct sigma_conn *conn, |
| 9890 | struct sigma_cmd *cmd) |
| 9891 | { |
| 9892 | const char *val; |
| 9893 | char *ifname; |
| 9894 | |
| 9895 | ifname = get_main_ifname(); |
| 9896 | val = get_param(cmd, "chnum_band"); |
| 9897 | if (val && mac80211_vht_chnum_band(dut, ifname, val) < 0) |
| 9898 | return -1; |
| 9899 | |
| 9900 | return 1; |
| 9901 | } |
| 9902 | |
| 9903 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9904 | static int cmd_ap_set_rfeature(struct sigma_dut *dut, struct sigma_conn *conn, |
| 9905 | struct sigma_cmd *cmd) |
| 9906 | { |
| 9907 | /* const char *name = get_param(cmd, "NAME"); */ |
| 9908 | /* const char *type = get_param(cmd, "Type"); */ |
| 9909 | |
| 9910 | switch (get_driver_type()) { |
| 9911 | case DRIVER_ATHEROS: |
| 9912 | return ath_ap_set_rfeature(dut, conn, cmd); |
| 9913 | case DRIVER_OPENWRT: |
| 9914 | switch (get_openwrt_driver_type()) { |
| 9915 | case OPENWRT_DRIVER_ATHEROS: |
| 9916 | return ath_ap_set_rfeature(dut, conn, cmd); |
| 9917 | default: |
| 9918 | send_resp(dut, conn, SIGMA_ERROR, |
| 9919 | "errorCode,Unsupported ap_set_rfeature with the current openwrt driver"); |
| 9920 | return 0; |
| 9921 | } |
Sreelakshmi Konamki | 0e4fcf9 | 2016-04-26 19:55:01 +0530 | [diff] [blame] | 9922 | case DRIVER_LINUX_WCN: |
Pradeep Reddy POTTETI | 88fd82c | 2016-03-14 12:20:18 +0530 | [diff] [blame] | 9923 | case DRIVER_WCN: |
| 9924 | return wcn_ap_set_rfeature(dut, conn, cmd); |
Mohammed Shafi Shajakhan | b53d8f9 | 2017-02-28 09:05:15 +0530 | [diff] [blame] | 9925 | case DRIVER_MAC80211: |
| 9926 | return mac80211_ap_set_rfeature(dut, conn, cmd); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9927 | default: |
| 9928 | send_resp(dut, conn, SIGMA_ERROR, |
| 9929 | "errorCode,Unsupported ap_set_rfeature with the current driver"); |
| 9930 | return 0; |
| 9931 | } |
| 9932 | } |
| 9933 | |
| 9934 | |
| 9935 | static int cmd_accesspoint(struct sigma_dut *dut, struct sigma_conn *conn, |
| 9936 | struct sigma_cmd *cmd) |
| 9937 | { |
| 9938 | /* const char *name = get_param(cmd, "NAME"); */ |
| 9939 | return 1; |
| 9940 | } |
| 9941 | |
| 9942 | |
priyadharshini gowthaman | 9149afc | 2018-01-15 13:40:18 -0800 | [diff] [blame] | 9943 | static int cmd_ap_preset_testparameters(struct sigma_dut *dut, |
| 9944 | struct sigma_conn *conn, |
| 9945 | struct sigma_cmd *cmd) |
| 9946 | { |
| 9947 | const char *val; |
| 9948 | |
| 9949 | val = get_param(cmd, "Oper_Chn"); |
| 9950 | if (val) { |
| 9951 | dut->ap_oper_chn = 1; |
| 9952 | dut->ap_channel = atoi(val); |
| 9953 | } |
| 9954 | |
| 9955 | return 1; |
| 9956 | } |
| 9957 | |
| 9958 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9959 | void ap_register_cmds(void) |
| 9960 | { |
| 9961 | sigma_dut_reg_cmd("ap_ca_version", NULL, cmd_ap_ca_version); |
| 9962 | sigma_dut_reg_cmd("ap_set_wireless", NULL, cmd_ap_set_wireless); |
| 9963 | sigma_dut_reg_cmd("ap_send_addba_req", NULL, cmd_ap_send_addba_req); |
| 9964 | sigma_dut_reg_cmd("ap_set_11n_wireless", NULL, cmd_ap_set_wireless); |
| 9965 | sigma_dut_reg_cmd("ap_set_11n", NULL, cmd_ap_set_wireless); |
| 9966 | 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] | 9967 | sigma_dut_reg_cmd("ap_set_11h", NULL, cmd_ap_set_wireless); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9968 | sigma_dut_reg_cmd("ap_set_security", NULL, cmd_ap_set_security); |
| 9969 | sigma_dut_reg_cmd("ap_set_apqos", NULL, cmd_ap_set_apqos); |
| 9970 | sigma_dut_reg_cmd("ap_set_staqos", NULL, cmd_ap_set_staqos); |
| 9971 | sigma_dut_reg_cmd("ap_set_radius", NULL, cmd_ap_set_radius); |
| 9972 | sigma_dut_reg_cmd("ap_reboot", NULL, cmd_ap_reboot); |
| 9973 | sigma_dut_reg_cmd("ap_config_commit", NULL, cmd_ap_config_commit); |
| 9974 | sigma_dut_reg_cmd("ap_reset_default", NULL, cmd_ap_reset_default); |
| 9975 | sigma_dut_reg_cmd("ap_get_info", NULL, cmd_ap_get_info); |
| 9976 | sigma_dut_reg_cmd("ap_deauth_sta", NULL, cmd_ap_deauth_sta); |
| 9977 | sigma_dut_reg_cmd("ap_send_frame", NULL, cmd_ap_send_frame); |
| 9978 | sigma_dut_reg_cmd("ap_get_mac_address", NULL, cmd_ap_get_mac_address); |
| 9979 | sigma_dut_reg_cmd("ap_set_pmf", NULL, cmd_ap_set_pmf); |
| 9980 | sigma_dut_reg_cmd("ap_set_hs2", NULL, cmd_ap_set_hs2); |
| 9981 | sigma_dut_reg_cmd("ap_set_rfeature", NULL, cmd_ap_set_rfeature); |
| 9982 | sigma_dut_reg_cmd("ap_nfc_action", NULL, cmd_ap_nfc_action); |
| 9983 | sigma_dut_reg_cmd("ap_wps_read_pin", NULL, cmd_ap_wps_read_pin); |
| 9984 | sigma_dut_reg_cmd("AccessPoint", NULL, cmd_accesspoint); |
priyadharshini gowthaman | 9149afc | 2018-01-15 13:40:18 -0800 | [diff] [blame] | 9985 | sigma_dut_reg_cmd("ap_preset_testparameters", NULL, |
| 9986 | cmd_ap_preset_testparameters); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9987 | } |