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. |
| 4 | * Copyright (c) 2011-2015, Qualcomm Atheros, Inc. |
| 5 | * All Rights Reserved. |
| 6 | * Licensed under the Clear BSD license. See README for more details. |
| 7 | */ |
| 8 | |
| 9 | #include "sigma_dut.h" |
| 10 | #include <sys/stat.h> |
| 11 | #include <sys/wait.h> |
| 12 | #include <sys/utsname.h> |
| 13 | #include <sys/ioctl.h> |
| 14 | #ifdef __linux__ |
Adil Saeed Musthafa | 33ea287 | 2017-04-10 23:13:24 -0700 | [diff] [blame] | 15 | #include <limits.h> |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 16 | #include <dirent.h> |
| 17 | #include <string.h> |
| 18 | #include <sys/types.h> |
| 19 | #include <unistd.h> |
| 20 | #endif /* __linux__ */ |
| 21 | #ifdef __QNXNTO__ |
| 22 | #include <ifaddrs.h> |
| 23 | #include <net/if_dl.h> |
| 24 | #endif /* __QNXNTO__ */ |
| 25 | #include "wpa_helpers.h" |
| 26 | #ifdef ANDROID |
| 27 | #include <hardware_legacy/wifi.h> |
Pradeep Reddy POTTETI | a076c30 | 2016-05-16 13:36:07 +0530 | [diff] [blame] | 28 | #include <private/android_filesystem_config.h> |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 29 | #endif /* ANDROID */ |
| 30 | |
| 31 | /* Temporary files for ap_send_addba_req */ |
| 32 | #define VI_QOS_TMP_FILE "/tmp/vi-qos.tmp" |
| 33 | #define VI_QOS_FILE "/tmp/vi-qos.txt" |
| 34 | #define VI_QOS_REFFILE "/etc/vi-qos.txt" |
| 35 | |
| 36 | /* Configuration file name on Android */ |
| 37 | #ifndef ANDROID_CONFIG_FILE |
| 38 | #define ANDROID_CONFIG_FILE "/data/misc/wifi/hostapd.conf" |
| 39 | #endif /* ANDROID_CONFIG_FILE */ |
| 40 | /* Maximum length of the line in the configuration file */ |
| 41 | #define MAX_CONF_LINE_LEN (156) |
| 42 | |
Jouni Malinen | d6bf1b4 | 2017-06-23 17:51:01 +0300 | [diff] [blame] | 43 | #ifndef SIGMA_DUT_HOSTAPD_PID_FILE |
| 44 | #define SIGMA_DUT_HOSTAPD_PID_FILE "/tmp/sigma_dut-ap-hostapd.pid" |
| 45 | #endif /* SIGMA_DUT_HOSTAPD_PID_FILE */ |
| 46 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 47 | /* The following is taken from Hotspot 2.0 testplan Appendix B.1 */ |
| 48 | #define ANQP_VENUE_NAME_1 "02019c0002083d656e6757692d466920416c6c69616e63650a3239383920436f7070657220526f61640a53616e746120436c6172612c2043412039353035312c205553415b63686957692d4669e88194e79b9fe5ae9ee9aa8ce5aea40ae4ba8ce4b99de585abe4b99de5b9b4e5ba93e69f8fe8b7af0ae59ca3e5858be68b89e68b892c20e58aa0e588a9e7a68fe5b0bce4ba9a39353035312c20e7be8ee59bbd" |
| 49 | #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\"" |
| 50 | #define ANQP_IP_ADDR_TYPE_1 "060101000c" |
| 51 | #define ANQP_HS20_OPERATOR_FRIENDLY_NAME_1 "dddd2700506f9a11030011656e6757692d466920416c6c69616e63650e63686957692d4669e88194e79b9f" |
| 52 | #define ANQP_HS20_WAN_METRICS_1 "dddd1300506f9a11040001c40900008001000000000000" |
| 53 | #define ANQP_HS20_CONNECTION_CAPABILITY_1 "dddd3200506f9a1105000100000006140001061600000650000106bb010106bb060006c4130011f4010111c413001194110132000001" |
| 54 | #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" |
| 55 | #define QOS_MAP_SET_2 "8,15,0,7,255,255,16,31,32,39,255,255,40,47,48,63" |
| 56 | |
| 57 | extern char *sigma_main_ifname; |
| 58 | extern char *sigma_wpas_ctrl; |
| 59 | extern char *sigma_hapd_ctrl; |
| 60 | extern char *ap_inet_addr; |
| 61 | extern char *ap_inet_mask; |
| 62 | extern char *sigma_radio_ifname[]; |
| 63 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 64 | static int ath_ap_start_hostapd(struct sigma_dut *dut); |
| 65 | static void ath_ap_set_params(struct sigma_dut *dut); |
| 66 | static int kill_process(struct sigma_dut *dut, char *proc_name, |
| 67 | unsigned char is_proc_instance_one, int sig); |
| 68 | |
| 69 | |
| 70 | static int cmd_ap_ca_version(struct sigma_dut *dut, struct sigma_conn *conn, |
| 71 | struct sigma_cmd *cmd) |
| 72 | { |
| 73 | /* const char *name = get_param(cmd, "NAME"); */ |
| 74 | send_resp(dut, conn, SIGMA_COMPLETE, "version,1.0"); |
| 75 | return 0; |
| 76 | } |
| 77 | |
| 78 | |
Jouni Malinen | d6bf1b4 | 2017-06-23 17:51:01 +0300 | [diff] [blame] | 79 | static void kill_hostapd_process_pid(struct sigma_dut *dut) |
| 80 | { |
| 81 | FILE *f; |
| 82 | int pid, res; |
| 83 | char path[100]; |
| 84 | int count; |
| 85 | |
| 86 | f = fopen(SIGMA_DUT_HOSTAPD_PID_FILE, "r"); |
| 87 | if (!f) |
| 88 | return; |
| 89 | res = fscanf(f, "%d", &pid); |
| 90 | fclose(f); |
| 91 | if (res != 1) |
| 92 | return; |
| 93 | sigma_dut_print(dut, DUT_MSG_INFO, "Killing hostapd pid %d", pid); |
| 94 | kill(pid, SIGTERM); |
| 95 | snprintf(path, sizeof(path), "/proc/%d", pid); |
| 96 | for (count = 0; count < 20 && file_exists(path); count++) |
| 97 | usleep(100000); |
| 98 | } |
| 99 | |
| 100 | |
Jouni Malinen | 2e6ccc2 | 2017-09-04 13:43:16 +0300 | [diff] [blame] | 101 | int get_hwaddr(const char *ifname, unsigned char *hwaddr) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 102 | { |
| 103 | #ifndef __QNXNTO__ |
| 104 | struct ifreq ifr; |
| 105 | int s; |
| 106 | |
| 107 | s = socket(AF_INET, SOCK_DGRAM, 0); |
| 108 | if (s < 0) |
| 109 | return -1; |
| 110 | memset(&ifr, 0, sizeof(ifr)); |
Peng Xu | b8fc5cc | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 111 | strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name)); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 112 | if (ioctl(s, SIOCGIFHWADDR, &ifr) < 0) { |
| 113 | perror("ioctl"); |
| 114 | close(s); |
| 115 | return -1; |
| 116 | } |
| 117 | close(s); |
| 118 | memcpy(hwaddr, ifr.ifr_hwaddr.sa_data, 6); |
| 119 | #else /* __QNXNTO__ */ |
| 120 | struct ifaddrs *ifaddrshead = NULL; |
| 121 | int found = 0; |
| 122 | struct ifaddrs *temp_ifap = NULL; |
| 123 | struct sockaddr_dl *sdl = NULL; |
| 124 | |
| 125 | if (getifaddrs(&ifaddrshead) != 0) { |
| 126 | perror("getifaddrs failed"); |
| 127 | return -1; |
| 128 | } |
| 129 | |
| 130 | for (temp_ifap = ifaddrshead; ifaddrshead && !found; |
| 131 | ifaddrshead = ifaddrshead->ifa_next) { |
| 132 | if (ifaddrshead->ifa_addr->sa_family == AF_LINK && |
| 133 | strcmp(ifaddrshead->ifa_name, ifname) == 0) { |
| 134 | found = 1; |
| 135 | sdl = (struct sockaddr_dl *) ifaddrshead->ifa_addr; |
| 136 | if (sdl) |
| 137 | memcpy(hwaddr, LLADDR(sdl), sdl->sdl_alen); |
| 138 | } |
| 139 | } |
| 140 | |
| 141 | if (temp_ifap) |
| 142 | freeifaddrs(temp_ifap); |
| 143 | |
| 144 | if (!found) { |
| 145 | perror("Failed to get the interface"); |
| 146 | return -1; |
| 147 | } |
| 148 | #endif /* __QNXNTO__ */ |
| 149 | return 0; |
| 150 | } |
| 151 | |
| 152 | |
| 153 | static void ath_ap_set_group_id(struct sigma_dut *dut, const char *ifname, |
| 154 | const char *val) |
| 155 | { |
| 156 | char buf[60]; |
| 157 | |
| 158 | snprintf(buf, sizeof(buf), "wifitool %s beeliner_fw_test 55 %d", |
| 159 | ifname, atoi(val)); |
| 160 | if (system(buf) != 0) { |
| 161 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 162 | "wifitool ap_group_id failed"); |
| 163 | } |
| 164 | } |
| 165 | |
| 166 | |
| 167 | void ath_set_cts_width(struct sigma_dut *dut, const char *ifname, |
| 168 | const char *val) |
| 169 | { |
| 170 | char buf[60]; |
| 171 | |
| 172 | /* TODO: Enable support for other values */ |
| 173 | if (strcasecmp(val, "40") == 0) { |
| 174 | snprintf(buf, sizeof(buf), "wifitool %s beeliner_fw_test 54 1", |
| 175 | ifname); |
| 176 | if (system(buf) != 0) { |
| 177 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 178 | "wifitool cts_width failed"); |
| 179 | } |
Priyadharshini Gowthaman | 818afef | 2015-11-09 13:28:15 -0800 | [diff] [blame] | 180 | snprintf(buf, sizeof(buf), |
| 181 | "athdiag --set --address=0x10024 --val=0xd90b8a14"); |
| 182 | if (system(buf) != 0) { |
| 183 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 184 | "disabling phy restart failed"); |
| 185 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 186 | } else { |
| 187 | sigma_dut_print(dut, DUT_MSG_ERROR, "Unsupported CTS_WIDTH"); |
| 188 | } |
| 189 | } |
| 190 | |
| 191 | |
Priyadharshini Gowthaman | 818afef | 2015-11-09 13:28:15 -0800 | [diff] [blame] | 192 | void ath_config_dyn_bw_sig(struct sigma_dut *dut, const char *ifname, |
| 193 | const char *val) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 194 | { |
| 195 | char buf[60]; |
| 196 | |
| 197 | if (strcasecmp(val, "enable") == 0) { |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 198 | dut->ap_dyn_bw_sig = VALUE_ENABLED; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 199 | snprintf(buf, sizeof(buf), "iwpriv %s cwmenable 1", ifname); |
| 200 | if (system(buf) != 0) { |
| 201 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 202 | "iwpriv cwmenable 1 failed"); |
| 203 | } |
Priyadharshini Gowthaman | 818afef | 2015-11-09 13:28:15 -0800 | [diff] [blame] | 204 | snprintf(buf, sizeof(buf), "wifitool %s beeliner_fw_test 96 1", |
| 205 | ifname); |
| 206 | if (system(buf) != 0) { |
| 207 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 208 | "disabling RTS from rate control logic failed"); |
| 209 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 210 | } else if (strcasecmp(val, "disable") == 0) { |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 211 | dut->ap_dyn_bw_sig = VALUE_DISABLED; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 212 | snprintf(buf, sizeof(buf), "iwpriv %s cwmenable 0", ifname); |
| 213 | if (system(buf) != 0) { |
| 214 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 215 | "iwpriv cwmenable 0 failed"); |
| 216 | } |
| 217 | } else { |
| 218 | sigma_dut_print(dut, DUT_MSG_ERROR, "Unsupported DYN_BW_SGL"); |
| 219 | } |
| 220 | } |
| 221 | |
| 222 | |
| 223 | static void ath_config_rts_force(struct sigma_dut *dut, const char *ifname, |
| 224 | const char *val) |
| 225 | { |
| 226 | char buf[60]; |
| 227 | |
| 228 | if (strcasecmp(val, "enable") == 0) { |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 229 | dut->ap_sig_rts = VALUE_ENABLED; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 230 | snprintf(buf, sizeof(buf), "iwconfig %s rts 64", ifname); |
| 231 | if (system(buf) != 0) { |
| 232 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 233 | "iwconfig rts 64 failed"); |
| 234 | } |
priyadharshini gowthaman | 270870e | 2015-12-09 10:10:23 -0800 | [diff] [blame] | 235 | snprintf(buf, sizeof(buf), "wifitool %s beeliner_fw_test 100 1", |
| 236 | ifname); |
| 237 | if (system(buf) != 0) { |
| 238 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 239 | "wifitool beeliner_fw_test 100 1 failed"); |
| 240 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 241 | } else if (strcasecmp(val, "disable") == 0) { |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 242 | dut->ap_sig_rts = VALUE_DISABLED; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 243 | snprintf(buf, sizeof(buf), "iwconfig %s rts 2347", ifname); |
| 244 | if (system(buf) != 0) { |
| 245 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 246 | "iwpriv rts 2347 failed"); |
| 247 | } |
| 248 | } else { |
| 249 | sigma_dut_print(dut, DUT_MSG_ERROR, "Unsupported RTS_FORCE"); |
| 250 | } |
| 251 | } |
| 252 | |
| 253 | |
| 254 | static enum ap_mode get_mode(const char *str) |
| 255 | { |
| 256 | if (strcasecmp(str, "11a") == 0) |
| 257 | return AP_11a; |
| 258 | else if (strcasecmp(str, "11g") == 0) |
| 259 | return AP_11g; |
| 260 | else if (strcasecmp(str, "11b") == 0) |
| 261 | return AP_11b; |
| 262 | else if (strcasecmp(str, "11na") == 0) |
| 263 | return AP_11na; |
| 264 | else if (strcasecmp(str, "11ng") == 0) |
| 265 | return AP_11ng; |
| 266 | else if (strcasecmp(str, "11ac") == 0 || strcasecmp(str, "ac") == 0) |
| 267 | return AP_11ac; |
| 268 | else |
| 269 | return AP_inval; |
| 270 | } |
| 271 | |
| 272 | |
| 273 | static int run_hostapd_cli(struct sigma_dut *dut, char *buf) |
| 274 | { |
| 275 | char command[1000]; |
| 276 | const char *bin; |
| 277 | enum driver_type drv = get_driver_type(); |
Adil Saeed Musthafa | 3dd6ca7 | 2017-05-15 12:45:18 -0700 | [diff] [blame] | 278 | char *sigma_hapd_file = sigma_hapd_ctrl; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 279 | |
| 280 | if (file_exists("hostapd_cli")) |
| 281 | bin = "./hostapd_cli"; |
Jouni Malinen | d6bf1b4 | 2017-06-23 17:51:01 +0300 | [diff] [blame] | 282 | else if (file_exists("../../hostapd/hostapd_cli")) |
| 283 | bin = "../../hostapd/hostapd_cli"; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 284 | else |
| 285 | bin = "hostapd_cli"; |
| 286 | |
| 287 | if (drv == DRIVER_OPENWRT && sigma_hapd_ctrl == NULL) { |
Adil Saeed Musthafa | 3dd6ca7 | 2017-05-15 12:45:18 -0700 | [diff] [blame] | 288 | sigma_hapd_file = "/var/run/hostapd-wifi0"; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 289 | |
| 290 | if (sigma_radio_ifname[0] && |
| 291 | strcmp(sigma_radio_ifname[0], "wifi1") == 0) |
Adil Saeed Musthafa | 3dd6ca7 | 2017-05-15 12:45:18 -0700 | [diff] [blame] | 292 | sigma_hapd_file = "/var/run/hostapd-wifi1"; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 293 | else if (sigma_radio_ifname[0] && |
| 294 | strcmp(sigma_radio_ifname[0], "wifi2") == 0) |
Adil Saeed Musthafa | 3dd6ca7 | 2017-05-15 12:45:18 -0700 | [diff] [blame] | 295 | sigma_hapd_file = "/var/run/hostapd-wifi2"; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 296 | } |
| 297 | |
Adil Saeed Musthafa | 3dd6ca7 | 2017-05-15 12:45:18 -0700 | [diff] [blame] | 298 | if (sigma_hapd_file) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 299 | snprintf(command, sizeof(command), "%s -p %s %s", |
Adil Saeed Musthafa | 3dd6ca7 | 2017-05-15 12:45:18 -0700 | [diff] [blame] | 300 | bin, sigma_hapd_file, buf); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 301 | else |
| 302 | snprintf(command, sizeof(command), "%s %s", bin, buf); |
| 303 | return run_system(dut, command); |
| 304 | } |
| 305 | |
| 306 | |
priyadharshini gowthaman | 8e26ff4 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 307 | static int ath_set_lci_config(struct sigma_dut *dut, const char *val, |
| 308 | struct sigma_cmd *cmd) |
| 309 | { |
| 310 | FILE *f; |
| 311 | int i; |
| 312 | |
| 313 | f = fopen("/tmp/lci_cfg.txt", "w"); |
| 314 | if (!f) { |
| 315 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 316 | "Failed to open /tmp/lci_cfg.txt"); |
| 317 | return -1; |
| 318 | } |
| 319 | |
| 320 | for (i = 2; i < cmd->count; i++) |
| 321 | fprintf(f, "%s = %s \n", cmd->params[i], cmd->values[i]); |
| 322 | fprintf(f, "\n"); |
| 323 | fclose(f); |
| 324 | |
| 325 | return 0; |
| 326 | } |
| 327 | |
| 328 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 329 | static int cmd_ap_set_wireless(struct sigma_dut *dut, struct sigma_conn *conn, |
| 330 | struct sigma_cmd *cmd) |
| 331 | { |
| 332 | /* const char *name = get_param(cmd, "NAME"); */ |
| 333 | /* const char *ifname = get_param(cmd, "INTERFACE"); */ |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 334 | const char *val; |
| 335 | unsigned int wlan_tag = 1; |
| 336 | char *ifname = get_main_ifname(); |
| 337 | |
| 338 | val = get_param(cmd, "WLAN_TAG"); |
| 339 | if (val) { |
| 340 | wlan_tag = atoi(val); |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 341 | if (wlan_tag < 1 || wlan_tag > 3) { |
| 342 | /* |
| 343 | * The only valid WLAN Tags as of now as per the latest |
| 344 | * WFA scripts are 1, 2, and 3. |
| 345 | */ |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 346 | send_resp(dut, conn, SIGMA_INVALID, |
| 347 | "errorCode,Invalid WLAN_TAG"); |
| 348 | return 0; |
| 349 | } |
| 350 | } |
| 351 | |
| 352 | val = get_param(cmd, "CountryCode"); |
| 353 | if (val) { |
| 354 | if (strlen(val) > sizeof(dut->ap_countrycode) - 1) |
| 355 | return -1; |
| 356 | snprintf(dut->ap_countrycode, sizeof(dut->ap_countrycode), |
| 357 | "%s", val); |
| 358 | } |
| 359 | |
Pradeep Reddy POTTETI | fba27db | 2015-11-20 16:42:22 +0530 | [diff] [blame] | 360 | val = get_param(cmd, "regulatory_mode"); |
| 361 | if (val) { |
| 362 | if (strcasecmp(val, "11d") == 0 || strcasecmp(val, "11h") == 0) |
| 363 | dut->ap_regulatory_mode = AP_80211D_MODE_ENABLED; |
| 364 | } |
| 365 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 366 | val = get_param(cmd, "SSID"); |
| 367 | if (val) { |
| 368 | if (strlen(val) > sizeof(dut->ap_ssid) - 1) |
| 369 | return -1; |
| 370 | |
| 371 | if (wlan_tag == 1) { |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 372 | /* |
| 373 | * If tag is not specified, it is deemed to be 1. |
| 374 | * Hence tag of 1 is a special case and the values |
| 375 | * corresponding to wlan-tag=1 are stored separately |
| 376 | * from the values corresponding tags 2 and 3. |
| 377 | * This approach minimises the changes to existing code |
| 378 | * since most of the sigma_dut code does not deal with |
| 379 | * WLAN-TAG CAPI variable. |
| 380 | */ |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 381 | snprintf(dut->ap_ssid, |
| 382 | sizeof(dut->ap_ssid), "%s", val); |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 383 | } else { |
| 384 | snprintf(dut->ap_tag_ssid[wlan_tag - 2], |
| 385 | sizeof(dut->ap_tag_ssid[wlan_tag - 2]), |
| 386 | "%s", val); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 387 | } |
| 388 | } |
| 389 | |
| 390 | val = get_param(cmd, "CHANNEL"); |
| 391 | if (val) { |
| 392 | const char *pos; |
| 393 | dut->ap_channel = atoi(val); |
| 394 | pos = strchr(val, ';'); |
| 395 | if (pos) { |
| 396 | pos++; |
| 397 | dut->ap_channel_1 = atoi(pos); |
| 398 | } |
| 399 | } |
| 400 | |
Pradeep Reddy POTTETI | fba27db | 2015-11-20 16:42:22 +0530 | [diff] [blame] | 401 | /* Overwrite the AP channel with DFS channel if configured */ |
| 402 | val = get_param(cmd, "dfs_chan"); |
| 403 | if (val) { |
| 404 | dut->ap_channel = atoi(val); |
| 405 | } |
| 406 | |
| 407 | val = get_param(cmd, "dfs_mode"); |
| 408 | if (val) { |
| 409 | if (strcasecmp(val, "Enable") == 0) |
| 410 | dut->ap_dfs_mode = AP_DFS_MODE_ENABLED; |
| 411 | else if (strcasecmp(val, "Disable") == 0) |
| 412 | dut->ap_dfs_mode = AP_DFS_MODE_DISABLED; |
| 413 | else |
| 414 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 415 | "Unsupported dfs_mode value: %s", val); |
| 416 | } |
| 417 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 418 | val = get_param(cmd, "MODE"); |
| 419 | if (val) { |
| 420 | char *str, *pos; |
| 421 | |
| 422 | str = strdup(val); |
| 423 | if (str == NULL) |
| 424 | return -1; |
| 425 | pos = strchr(str, ';'); |
| 426 | if (pos) |
| 427 | *pos++ = '\0'; |
| 428 | |
| 429 | dut->ap_is_dual = 0; |
| 430 | dut->ap_mode = get_mode(str); |
| 431 | if (dut->ap_mode == AP_inval) { |
| 432 | send_resp(dut, conn, SIGMA_INVALID, |
| 433 | "errorCode,Unsupported MODE"); |
| 434 | free(str); |
| 435 | return 0; |
| 436 | } |
| 437 | if (dut->ap_mode == AP_11ac) |
| 438 | dut->ap_chwidth = AP_80; |
| 439 | |
| 440 | if (pos) { |
| 441 | dut->ap_mode_1 = get_mode(pos); |
| 442 | if (dut->ap_mode_1 == AP_inval) { |
| 443 | send_resp(dut, conn, SIGMA_INVALID, |
| 444 | "errorCode,Unsupported MODE"); |
| 445 | free(str); |
| 446 | return 0; |
| 447 | } |
| 448 | if (dut->ap_mode_1 == AP_11ac) |
| 449 | dut->ap_chwidth_1 = AP_80; |
| 450 | dut->ap_is_dual = 1; |
| 451 | } |
| 452 | |
| 453 | free(str); |
| 454 | } else if (dut->ap_mode == AP_inval) { |
| 455 | if (dut->ap_channel <= 11) |
| 456 | dut->ap_mode = AP_11ng; |
| 457 | else if (dut->program == PROGRAM_VHT) |
| 458 | dut->ap_mode = AP_11ac; |
| 459 | else |
| 460 | dut->ap_mode = AP_11na; |
| 461 | } |
| 462 | |
Pradeep Reddy POTTETI | 0d3db63 | 2016-03-11 15:21:11 +0530 | [diff] [blame] | 463 | val = get_param(cmd, "WME"); |
| 464 | if (val) { |
| 465 | if (strcasecmp(val, "on") == 0) |
| 466 | dut->ap_wme = AP_WME_ON; |
| 467 | else if (strcasecmp(val, "off") == 0) |
| 468 | dut->ap_wme = AP_WME_OFF; |
| 469 | else |
| 470 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 471 | "Unsupported WME value: %s", val); |
| 472 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 473 | |
Mohammed Shafi Shajakhan | 02e3b82 | 2017-02-23 04:15:02 +0530 | [diff] [blame] | 474 | val = get_param(cmd, "WMMPS"); |
| 475 | if (val) { |
| 476 | if (strcasecmp(val, "on") == 0) |
| 477 | dut->ap_wmmps = AP_WMMPS_ON; |
| 478 | else if (strcasecmp(val, "off") == 0) |
| 479 | dut->ap_wmmps = AP_WMMPS_OFF; |
| 480 | else |
| 481 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 482 | "Unsupported WMMPS value: %s", val); |
| 483 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 484 | |
| 485 | val = get_param(cmd, "RTS"); |
| 486 | if (val) |
| 487 | dut->ap_rts = atoi(val); |
| 488 | |
| 489 | val = get_param(cmd, "FRGMNT"); |
| 490 | if (val) |
| 491 | dut->ap_frgmnt = atoi(val); |
| 492 | |
| 493 | /* TODO: PWRSAVE */ |
| 494 | |
| 495 | val = get_param(cmd, "BCNINT"); |
| 496 | if (val) |
| 497 | dut->ap_bcnint = atoi(val); |
| 498 | |
| 499 | val = get_param(cmd, "RADIO"); |
| 500 | if (val) { |
Mohammed Shafi Shajakhan | 94997f9 | 2017-01-09 21:31:09 +0530 | [diff] [blame] | 501 | enum driver_type drv = get_driver_type(); |
| 502 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 503 | if (strcasecmp(val, "on") == 0) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 504 | if (drv == DRIVER_ATHEROS) |
| 505 | ath_ap_start_hostapd(dut); |
| 506 | else if (cmd_ap_config_commit(dut, conn, cmd) <= 0) |
| 507 | return 0; |
| 508 | } else if (strcasecmp(val, "off") == 0) { |
Mohammed Shafi Shajakhan | 94997f9 | 2017-01-09 21:31:09 +0530 | [diff] [blame] | 509 | if (drv == DRIVER_OPENWRT) { |
| 510 | run_system(dut, "wifi down"); |
| 511 | sigma_dut_print(dut, DUT_MSG_INFO, |
| 512 | "wifi down on radio,off"); |
Jouni Malinen | d6bf1b4 | 2017-06-23 17:51:01 +0300 | [diff] [blame] | 513 | } else if (dut->use_hostapd_pid_file) { |
| 514 | kill_hostapd_process_pid(dut); |
Mohammed Shafi Shajakhan | 94997f9 | 2017-01-09 21:31:09 +0530 | [diff] [blame] | 515 | } else if (kill_process(dut, "(hostapd)", 1, |
| 516 | SIGTERM) == 0 || |
| 517 | system("killall hostapd") == 0) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 518 | sigma_dut_print(dut, DUT_MSG_INFO, |
| 519 | "Killed hostapd on radio,off"); |
| 520 | } |
| 521 | } else { |
| 522 | send_resp(dut, conn, SIGMA_INVALID, |
| 523 | "errorCode,Unsupported RADIO value"); |
| 524 | return 0; |
| 525 | } |
| 526 | } |
| 527 | |
| 528 | val = get_param(cmd, "P2PMgmtBit"); |
| 529 | if (val) |
| 530 | dut->ap_p2p_mgmt = atoi(val); |
| 531 | |
| 532 | /* TODO: ChannelUsage */ |
| 533 | |
| 534 | /* TODO: 40_INTOLERANT */ |
| 535 | |
| 536 | val = get_param(cmd, "ADDBA_REJECT"); |
| 537 | if (val) { |
| 538 | if (strcasecmp(val, "Enable") == 0) |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 539 | dut->ap_addba_reject = VALUE_ENABLED; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 540 | else if (strcasecmp(val, "Disable") == 0) |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 541 | dut->ap_addba_reject = VALUE_DISABLED; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 542 | } |
| 543 | |
| 544 | val = get_param(cmd, "AMPDU"); |
| 545 | if (val) { |
| 546 | if (strcasecmp(val, "Enable") == 0) |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 547 | dut->ap_ampdu = VALUE_ENABLED; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 548 | else if (strcasecmp(val, "Disable") == 0) |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 549 | dut->ap_ampdu = VALUE_DISABLED; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 550 | } |
| 551 | |
| 552 | val = get_param(cmd, "AMPDU_EXP"); |
| 553 | if (val) |
| 554 | dut->ap_ampdu_exp = atoi(val); |
| 555 | |
| 556 | val = get_param(cmd, "AMSDU"); |
| 557 | if (val) { |
| 558 | if (strcasecmp(val, "Enable") == 0) |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 559 | dut->ap_amsdu = VALUE_ENABLED; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 560 | else if (strcasecmp(val, "Disable") == 0) |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 561 | dut->ap_amsdu = VALUE_DISABLED; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 562 | } |
| 563 | |
| 564 | val = get_param(cmd, "NoAck"); |
| 565 | if (val) { |
| 566 | if (strcasecmp(val, "on") == 0) |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 567 | dut->ap_noack = VALUE_ENABLED; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 568 | else if (strcasecmp(val, "off") == 0) |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 569 | dut->ap_noack = VALUE_DISABLED; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 570 | } |
| 571 | |
| 572 | /* TODO: GREENFIELD */ |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 573 | /* TODO: MCS_32 */ |
| 574 | |
Pradeep Reddy Potteti | 4b0cdee | 2017-03-15 12:37:33 +0530 | [diff] [blame] | 575 | val = get_param(cmd, "OFFSET"); |
| 576 | if (val) { |
| 577 | if (strcasecmp(val, "Above") == 0) |
| 578 | dut->ap_chwidth_offset = SEC_CH_40ABOVE; |
| 579 | else if (strcasecmp(val, "Below") == 0) |
| 580 | dut->ap_chwidth_offset = SEC_CH_40BELOW; |
| 581 | } |
| 582 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 583 | val = get_param(cmd, "MCS_FIXEDRATE"); |
| 584 | if (val) { |
| 585 | dut->ap_fixed_rate = 1; |
| 586 | dut->ap_mcs = atoi(val); |
| 587 | } |
| 588 | |
| 589 | val = get_param(cmd, "SPATIAL_RX_STREAM"); |
| 590 | if (val) { |
| 591 | if (strcasecmp(val, "1SS") == 0 || strcasecmp(val, "1") == 0) { |
| 592 | dut->ap_rx_streams = 1; |
| 593 | if (dut->device_type == AP_testbed) |
| 594 | dut->ap_vhtmcs_map = 0xfffc; |
| 595 | } else if (strcasecmp(val, "2SS") == 0 || |
| 596 | strcasecmp(val, "2") == 0) { |
| 597 | dut->ap_rx_streams = 2; |
| 598 | if (dut->device_type == AP_testbed) |
| 599 | dut->ap_vhtmcs_map = 0xfff0; |
| 600 | } else if (strcasecmp(val, "3SS") == 0 || |
| 601 | strcasecmp(val, "3") == 0) { |
| 602 | dut->ap_rx_streams = 3; |
| 603 | if (dut->device_type == AP_testbed) |
| 604 | dut->ap_vhtmcs_map = 0xffc0; |
| 605 | } else if (strcasecmp(val, "4SS") == 0 || |
| 606 | strcasecmp(val, "4") == 0) { |
| 607 | dut->ap_rx_streams = 4; |
| 608 | } |
| 609 | } |
| 610 | |
| 611 | val = get_param(cmd, "SPATIAL_TX_STREAM"); |
| 612 | if (val) { |
| 613 | if (strcasecmp(val, "1SS") == 0 || |
| 614 | strcasecmp(val, "1") == 0) { |
| 615 | dut->ap_tx_streams = 1; |
| 616 | if (dut->device_type == AP_testbed) |
| 617 | dut->ap_vhtmcs_map = 0xfffc; |
| 618 | } else if (strcasecmp(val, "2SS") == 0 || |
| 619 | strcasecmp(val, "2") == 0) { |
| 620 | dut->ap_tx_streams = 2; |
| 621 | if (dut->device_type == AP_testbed) |
| 622 | dut->ap_vhtmcs_map = 0xfff0; |
| 623 | } else if (strcasecmp(val, "3SS") == 0 || |
| 624 | strcasecmp(val, "3") == 0) { |
| 625 | dut->ap_tx_streams = 3; |
| 626 | if (dut->device_type == AP_testbed) |
| 627 | dut->ap_vhtmcs_map = 0xffc0; |
| 628 | } else if (strcasecmp(val, "4SS") == 0 || |
| 629 | strcasecmp(val, "4") == 0) { |
| 630 | dut->ap_tx_streams = 4; |
| 631 | } |
| 632 | } |
| 633 | |
Adil Saeed Musthafa | 33ea287 | 2017-04-10 23:13:24 -0700 | [diff] [blame] | 634 | val = get_param(cmd, "BSS_max_idle"); |
| 635 | if (val) { |
| 636 | if (strncasecmp(val, "Enable", 7) == 0) { |
| 637 | dut->wnm_bss_max_feature = VALUE_ENABLED; |
| 638 | } else if (strncasecmp(val, "Disable", 8) == 0) { |
| 639 | dut->wnm_bss_max_feature = VALUE_DISABLED; |
| 640 | } else { |
| 641 | send_resp(dut, conn, SIGMA_ERROR, |
| 642 | "errorCode,Invalid value for BSS_max_Feature"); |
| 643 | return 0; |
| 644 | } |
| 645 | } |
| 646 | |
| 647 | val = get_param(cmd, "BSS_Idle_Protection_options"); |
| 648 | if (val) { |
| 649 | int protection = (int) strtol(val, (char **) NULL, 10); |
| 650 | |
| 651 | if (protection != 1 && protection != 0) { |
| 652 | send_resp(dut, conn, SIGMA_ERROR, |
| 653 | "errorCode,Invalid value for BSS_Idle_Protection_options"); |
| 654 | return 0; |
| 655 | } |
| 656 | dut->wnm_bss_max_protection = protection ? |
| 657 | VALUE_ENABLED : VALUE_DISABLED; |
| 658 | } |
| 659 | |
| 660 | val = get_param(cmd, "BSS_max_Idle_period"); |
| 661 | if (val) { |
| 662 | int idle_time = (int) strtol(val, (char **) NULL, 10); |
| 663 | |
| 664 | if (idle_time == LONG_MIN || idle_time == LONG_MAX) { |
| 665 | send_resp(dut, conn, SIGMA_ERROR, |
| 666 | "errorCode,Invalid value for BSS_max_Idle_period"); |
| 667 | return 0; |
| 668 | } |
| 669 | dut->wnm_bss_max_idle_time = idle_time; |
| 670 | } |
| 671 | |
| 672 | val = get_param(cmd, "PROXY_ARP"); |
| 673 | if (val) |
| 674 | dut->ap_proxy_arp = (int) strtol(val, (char **) NULL, 10); |
| 675 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 676 | val = get_param(cmd, "nss_mcs_cap"); |
| 677 | if (val) { |
| 678 | int nss, mcs; |
| 679 | char token[20]; |
| 680 | char *result = NULL; |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 681 | char *saveptr; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 682 | |
| 683 | if (strlen(val) >= sizeof(token)) |
| 684 | return -1; |
Jouni Malinen | 947fdf6 | 2017-05-14 22:29:32 +0300 | [diff] [blame] | 685 | strlcpy(token, val, sizeof(token)); |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 686 | result = strtok_r(token, ";", &saveptr); |
Pradeep Reddy POTTETI | 41b8c54 | 2016-06-15 16:09:46 +0530 | [diff] [blame] | 687 | if (!result) { |
| 688 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 689 | "VHT NSS not specified"); |
| 690 | return 0; |
| 691 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 692 | nss = atoi(result); |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 693 | result = strtok_r(NULL, ";", &saveptr); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 694 | if (result == NULL) { |
| 695 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 696 | "VHTMCS NOT SPECIFIED!"); |
| 697 | return 0; |
| 698 | } |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 699 | result = strtok_r(result, "-", &saveptr); |
| 700 | result = strtok_r(NULL, "-", &saveptr); |
Pradeep Reddy POTTETI | 41b8c54 | 2016-06-15 16:09:46 +0530 | [diff] [blame] | 701 | if (!result) { |
| 702 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 703 | "VHT MCS not specified"); |
| 704 | return 0; |
| 705 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 706 | mcs = atoi(result); |
| 707 | switch (nss) { |
| 708 | case 1: |
| 709 | switch (mcs) { |
| 710 | case 7: |
| 711 | dut->ap_vhtmcs_map = 0xfffc; |
| 712 | break; |
| 713 | case 8: |
| 714 | dut->ap_vhtmcs_map = 0xfffd; |
| 715 | break; |
| 716 | case 9: |
| 717 | dut->ap_vhtmcs_map = 0xfffe; |
| 718 | break; |
| 719 | default: |
| 720 | dut->ap_vhtmcs_map = 0xfffe; |
| 721 | break; |
| 722 | } |
| 723 | break; |
| 724 | case 2: |
| 725 | switch (mcs) { |
| 726 | case 7: |
| 727 | dut->ap_vhtmcs_map = 0xfff0; |
| 728 | break; |
| 729 | case 8: |
| 730 | dut->ap_vhtmcs_map = 0xfff5; |
| 731 | break; |
| 732 | case 9: |
| 733 | dut->ap_vhtmcs_map = 0xfffa; |
| 734 | break; |
| 735 | default: |
| 736 | dut->ap_vhtmcs_map = 0xfffa; |
| 737 | break; |
| 738 | } |
| 739 | break; |
| 740 | case 3: |
| 741 | switch (mcs) { |
| 742 | case 7: |
| 743 | dut->ap_vhtmcs_map = 0xffc0; |
| 744 | break; |
| 745 | case 8: |
| 746 | dut->ap_vhtmcs_map = 0xffd5; |
| 747 | break; |
| 748 | case 9: |
| 749 | dut->ap_vhtmcs_map = 0xffea; |
| 750 | break; |
| 751 | default: |
| 752 | dut->ap_vhtmcs_map = 0xffea; |
| 753 | break; |
| 754 | } |
| 755 | break; |
| 756 | default: |
| 757 | dut->ap_vhtmcs_map = 0xffea; |
| 758 | break; |
| 759 | } |
| 760 | } |
| 761 | |
| 762 | /* TODO: MPDU_MIN_START_SPACING */ |
| 763 | /* TODO: RIFS_TEST */ |
| 764 | /* TODO: SGI20 */ |
| 765 | |
| 766 | val = get_param(cmd, "STBC_TX"); |
| 767 | if (val) |
| 768 | dut->ap_tx_stbc = atoi(val); |
| 769 | |
| 770 | val = get_param(cmd, "WIDTH"); |
| 771 | if (val) { |
| 772 | if (strcasecmp(val, "20") == 0) |
| 773 | dut->ap_chwidth = AP_20; |
| 774 | else if (strcasecmp(val, "40") == 0) |
| 775 | dut->ap_chwidth = AP_40; |
| 776 | else if (strcasecmp(val, "80") == 0) |
| 777 | dut->ap_chwidth = AP_80; |
| 778 | else if (strcasecmp(val, "160") == 0) |
| 779 | dut->ap_chwidth = AP_160; |
| 780 | else if (strcasecmp(val, "Auto") == 0) |
| 781 | dut->ap_chwidth = AP_AUTO; |
| 782 | else { |
| 783 | send_resp(dut, conn, SIGMA_INVALID, |
| 784 | "errorCode,Unsupported WIDTH"); |
| 785 | return 0; |
| 786 | } |
| 787 | } |
| 788 | |
| 789 | /* TODO: WIDTH_SCAN */ |
| 790 | |
| 791 | val = get_param(cmd, "TDLSProhibit"); |
| 792 | dut->ap_tdls_prohibit = val && strcasecmp(val, "Enabled") == 0; |
| 793 | val = get_param(cmd, "TDLSChswitchProhibit"); |
| 794 | dut->ap_tdls_prohibit_chswitch = |
| 795 | val && strcasecmp(val, "Enabled") == 0; |
| 796 | val = get_param(cmd, "HS2"); |
| 797 | if (val && wlan_tag == 1) |
| 798 | dut->ap_hs2 = atoi(val); |
| 799 | val = get_param(cmd, "P2P_CROSS_CONNECT"); |
| 800 | if (val) |
| 801 | dut->ap_p2p_cross_connect = strcasecmp(val, "Enabled") == 0; |
| 802 | |
| 803 | val = get_param(cmd, "FakePubKey"); |
| 804 | dut->ap_fake_pkhash = val && atoi(val); |
| 805 | |
| 806 | val = get_param(cmd, "vht_tkip"); |
| 807 | dut->ap_allow_vht_tkip = val && strcasecmp(val, "Enable") == 0; |
| 808 | val = get_param(cmd, "vht_wep"); |
| 809 | dut->ap_allow_vht_wep = val && strcasecmp(val, "Enable") == 0; |
| 810 | |
| 811 | val = get_param(cmd, "Protect_mode"); |
| 812 | dut->ap_disable_protection = val && strcasecmp(val, "Disable") == 0; |
| 813 | |
| 814 | val = get_param(cmd, "DYN_BW_SGNL"); |
| 815 | if (val) { |
| 816 | switch (get_driver_type()) { |
| 817 | case DRIVER_OPENWRT: |
| 818 | switch (get_openwrt_driver_type()) { |
| 819 | case OPENWRT_DRIVER_ATHEROS: |
| 820 | ath_config_dyn_bw_sig(dut, ifname, val); |
| 821 | break; |
| 822 | default: |
| 823 | send_resp(dut, conn, SIGMA_ERROR, |
| 824 | "errorCode,Unsupported DYN_BW_SGNL with OpenWrt driver"); |
| 825 | return 0; |
| 826 | } |
| 827 | break; |
| 828 | default: |
| 829 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 830 | "Unsupported DYN_BW_SGL with the current driver"); |
| 831 | break; |
| 832 | } |
| 833 | } |
| 834 | |
| 835 | val = get_param(cmd, "SGI80"); |
| 836 | if (val) { |
| 837 | if (strcasecmp(val, "enable") == 0) |
| 838 | dut->ap_sgi80 = 1; |
| 839 | else if (strcasecmp(val, "disable") == 0) |
| 840 | dut->ap_sgi80 = 0; |
| 841 | else { |
| 842 | send_resp(dut, conn, SIGMA_INVALID, |
| 843 | "errorCode,Unsupported SGI80"); |
| 844 | return 0; |
| 845 | } |
| 846 | } |
| 847 | |
| 848 | val = get_param(cmd, "LDPC"); |
| 849 | if (val) { |
| 850 | if (strcasecmp(val, "enable") == 0) |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 851 | dut->ap_ldpc = VALUE_ENABLED; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 852 | else if (strcasecmp(val, "disable") == 0) |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 853 | dut->ap_ldpc = VALUE_DISABLED; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 854 | else { |
| 855 | send_resp(dut, conn, SIGMA_INVALID, |
| 856 | "errorCode,Unsupported LDPC"); |
| 857 | return 0; |
| 858 | } |
| 859 | } |
| 860 | |
| 861 | val = get_param(cmd, "BW_SGNL"); |
| 862 | if (val) { |
| 863 | /* |
| 864 | * With dynamic bandwidth signaling enabled we should see |
| 865 | * RTS if the threshold is met. |
| 866 | */ |
| 867 | if (strcasecmp(val, "enable") == 0) { |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 868 | dut->ap_sig_rts = VALUE_ENABLED; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 869 | } else if (strcasecmp(val, "disable") == 0) { |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 870 | dut->ap_sig_rts = VALUE_DISABLED; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 871 | } else { |
| 872 | send_resp(dut, conn, SIGMA_INVALID, |
| 873 | "errorCode,Unsupported BW_SGNL"); |
| 874 | return 0; |
| 875 | } |
| 876 | } |
| 877 | |
| 878 | val = get_param(cmd, "RTS_FORCE"); |
| 879 | if (val) { |
| 880 | switch (get_driver_type()) { |
| 881 | case DRIVER_OPENWRT: |
| 882 | switch (get_openwrt_driver_type()) { |
| 883 | case OPENWRT_DRIVER_ATHEROS: |
| 884 | ath_config_rts_force(dut, ifname, val); |
| 885 | break; |
| 886 | default: |
| 887 | send_resp(dut, conn, SIGMA_ERROR, |
| 888 | "errorCode,Unsupported RTS_FORCE with OpenWrt driver"); |
| 889 | return 0; |
| 890 | } |
| 891 | break; |
| 892 | default: |
| 893 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 894 | "Unsupported RTS_FORCE with the current driver"); |
| 895 | break; |
| 896 | } |
| 897 | } |
| 898 | |
| 899 | val = get_param(cmd, "Zero_crc"); |
| 900 | if (val) { |
| 901 | switch (get_driver_type()) { |
| 902 | case DRIVER_ATHEROS: |
| 903 | ath_set_zero_crc(dut, val); |
| 904 | break; |
| 905 | case DRIVER_OPENWRT: |
| 906 | switch (get_openwrt_driver_type()) { |
| 907 | case OPENWRT_DRIVER_ATHEROS: |
| 908 | ath_set_zero_crc(dut, val); |
| 909 | break; |
| 910 | default: |
| 911 | send_resp(dut, conn, SIGMA_ERROR, |
| 912 | "errorCode,Unsupported zero_crc with the current driver"); |
| 913 | return 0; |
| 914 | } |
| 915 | break; |
| 916 | default: |
| 917 | send_resp(dut, conn, SIGMA_ERROR, |
| 918 | "errorCode,Unsupported zero_crc with the current driver"); |
| 919 | return 0; |
| 920 | } |
| 921 | } |
| 922 | |
| 923 | val = get_param(cmd, "TxBF"); |
| 924 | if (val) |
| 925 | dut->ap_txBF = strcasecmp(val, "enable") == 0; |
| 926 | |
| 927 | val = get_param(cmd, "MU_TxBF"); |
Manikanta Pubbisetty | 210f7c8 | 2017-02-14 12:33:54 +0530 | [diff] [blame] | 928 | if (val) { |
| 929 | if (strcasecmp(val, "enable") == 0) { |
| 930 | dut->ap_txBF = 1; |
| 931 | dut->ap_mu_txBF = 1; |
| 932 | } else if (strcasecmp(val, "disable") == 0) { |
| 933 | dut->ap_txBF = 0; |
| 934 | dut->ap_mu_txBF = 0; |
| 935 | } else { |
| 936 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 937 | "Unsupported MU_TxBF"); |
| 938 | } |
| 939 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 940 | |
| 941 | /* UNSUPPORTED: tx_lgi_rate */ |
| 942 | |
| 943 | val = get_param(cmd, "wpsnfc"); |
| 944 | if (val) |
| 945 | dut->ap_wpsnfc = atoi(val); |
| 946 | |
| 947 | val = get_param(cmd, "GROUP_ID"); |
| 948 | if (val) { |
| 949 | switch (get_driver_type()) { |
| 950 | case DRIVER_OPENWRT: |
| 951 | switch (get_openwrt_driver_type()) { |
| 952 | case OPENWRT_DRIVER_ATHEROS: |
| 953 | ath_ap_set_group_id(dut, ifname, val); |
| 954 | break; |
| 955 | default: |
| 956 | send_resp(dut, conn, SIGMA_ERROR, |
| 957 | "errorCode,Unsupported group_id with the current driver"); |
| 958 | return 0; |
| 959 | } |
| 960 | break; |
| 961 | default: |
| 962 | send_resp(dut, conn, SIGMA_ERROR, |
| 963 | "errorCode,Unsupported group_id with the current driver"); |
| 964 | return 0; |
| 965 | } |
| 966 | } |
| 967 | |
| 968 | val = get_param(cmd, "CTS_WIDTH"); |
| 969 | if (val) { |
| 970 | switch (get_driver_type()) { |
| 971 | case DRIVER_OPENWRT: |
| 972 | switch (get_openwrt_driver_type()) { |
| 973 | case OPENWRT_DRIVER_ATHEROS: |
| 974 | ath_set_cts_width(dut, ifname, val); |
| 975 | break; |
| 976 | default: |
| 977 | send_resp(dut, conn, SIGMA_ERROR, |
| 978 | "errorCode,Unsupported cts_width with the current driver"); |
| 979 | return 0; |
| 980 | } |
| 981 | break; |
| 982 | default: |
| 983 | send_resp(dut, conn, SIGMA_ERROR, |
| 984 | "errorCode,Unsupported cts_width with the current driver"); |
| 985 | return 0; |
| 986 | } |
| 987 | } |
| 988 | |
priyadharshini gowthaman | 264d544 | 2016-02-25 15:52:22 -0800 | [diff] [blame] | 989 | val = get_param(cmd, "MU_NDPA_FrameFormat"); |
| 990 | if (val) |
| 991 | dut->ap_ndpa_frame = atoi(val); |
| 992 | |
priyadharshini gowthaman | c52fff8 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 993 | val = get_param(cmd, "interworking"); |
| 994 | if (val && strcmp(val, "1") == 0) |
| 995 | dut->ap_interworking = 1; |
| 996 | |
| 997 | val = get_param(cmd, "GAS_CB_DELAY"); |
| 998 | if (val) |
| 999 | dut->ap_gas_cb_delay = atoi(val); |
| 1000 | |
priyadharshini gowthaman | 8e26ff4 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 1001 | val = get_param(cmd, "LCI"); |
| 1002 | if (val) { |
| 1003 | if (strlen(val) > sizeof(dut->ap_val_lci) - 1) |
| 1004 | return -1; |
| 1005 | dut->ap_lci = 1; |
| 1006 | snprintf(dut->ap_val_lci, sizeof(dut->ap_val_lci), "%s", val); |
| 1007 | ath_set_lci_config(dut, val, cmd); |
| 1008 | } |
| 1009 | |
priyadharshini gowthaman | c2357bd | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 1010 | val = get_param(cmd, "InfoZ"); |
| 1011 | if (val) { |
| 1012 | if (strlen(val) > sizeof(dut->ap_infoz) - 1) |
| 1013 | return -1; |
| 1014 | snprintf(dut->ap_infoz, sizeof(dut->ap_infoz), "%s", val); |
| 1015 | } |
| 1016 | |
priyadharshini gowthaman | 8e26ff4 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 1017 | val = get_param(cmd, "LocCivicAddr"); |
| 1018 | if (val) { |
| 1019 | if (strlen(val) > sizeof(dut->ap_val_lcr) - 1) |
| 1020 | return -1; |
| 1021 | dut->ap_lcr = 1; |
| 1022 | snprintf(dut->ap_val_lcr, sizeof(dut->ap_val_lcr), "%s", val); |
| 1023 | if (dut->ap_lci == 0) |
| 1024 | ath_set_lci_config(dut, val, cmd); |
| 1025 | } |
| 1026 | |
| 1027 | val = get_param(cmd, "NeighAPBSSID"); |
| 1028 | if (val) { |
| 1029 | if (dut->ap_neighap < 3) { |
| 1030 | if (parse_mac_address( |
| 1031 | dut, val, |
| 1032 | dut->ap_val_neighap[dut->ap_neighap]) < 0) { |
| 1033 | send_resp(dut, conn, SIGMA_INVALID, |
| 1034 | "Failed to parse MAC address"); |
| 1035 | return 0; |
| 1036 | } |
| 1037 | dut->ap_neighap++; |
| 1038 | if (dut->ap_lci == 1) |
| 1039 | dut->ap_scan = 1; |
| 1040 | } |
| 1041 | } |
| 1042 | |
| 1043 | val = get_param(cmd, "OpChannel"); |
| 1044 | if (val) { |
| 1045 | if (dut->ap_opchannel < 3) { |
| 1046 | dut->ap_val_opchannel[dut->ap_opchannel] = atoi(val); |
| 1047 | dut->ap_opchannel++; |
| 1048 | } |
| 1049 | } |
| 1050 | |
priyadharshini gowthaman | c2357bd | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 1051 | val = get_param(cmd, "URI-FQDNdescriptor"); |
| 1052 | if (val) { |
| 1053 | if (strcasecmp(val, "HELD") == 0) { |
| 1054 | dut->ap_fqdn_held = 1; |
| 1055 | } else if (strcasecmp(val, "SUPL") == 0) { |
| 1056 | dut->ap_fqdn_supl = 1; |
| 1057 | } else { |
| 1058 | send_resp(dut, conn, SIGMA_INVALID, |
| 1059 | "errorCode,Unsupported URI-FQDNdescriptor"); |
| 1060 | return 0; |
| 1061 | } |
| 1062 | } |
| 1063 | |
Adil Saeed Musthafa | 604c826 | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 1064 | val = get_param(cmd, "Reg_Domain"); |
| 1065 | if (val) { |
| 1066 | if (strcasecmp(val, "Local") == 0) { |
| 1067 | dut->ap_reg_domain = REG_DOMAIN_LOCAL; |
| 1068 | } else if (strcasecmp(val, "Global") == 0) { |
| 1069 | dut->ap_reg_domain = REG_DOMAIN_GLOBAL; |
| 1070 | } else { |
| 1071 | send_resp(dut, conn, SIGMA_ERROR, |
| 1072 | "errorCode,Wrong value for Reg_Domain"); |
| 1073 | return 0; |
| 1074 | } |
| 1075 | } |
| 1076 | |
Adil Saeed Musthafa | 4ec61bd | 2017-04-10 23:13:41 -0700 | [diff] [blame] | 1077 | val = get_param(cmd, "NAME"); |
| 1078 | if (val) { |
| 1079 | if (strcasecmp(val, "ap1mbo") == 0) |
| 1080 | dut->ap_name = 1; |
| 1081 | else if (strcasecmp(val, "ap2mbo") == 0) |
| 1082 | dut->ap_name = 2; |
| 1083 | else |
| 1084 | dut->ap_name = 0; |
| 1085 | } |
| 1086 | |
| 1087 | val = get_param(cmd, "FT_OA"); |
| 1088 | if (val) { |
| 1089 | if (strcasecmp(val, "Enable") == 0) { |
| 1090 | dut->ap_ft_oa = 1; |
| 1091 | } else if (strcasecmp(val, "Disable") == 0) { |
| 1092 | dut->ap_ft_oa = 0; |
| 1093 | } else { |
| 1094 | send_resp(dut, conn, SIGMA_ERROR, |
| 1095 | "errorCode,Wrong value for FT_OA"); |
| 1096 | return 0; |
| 1097 | } |
| 1098 | } |
| 1099 | |
Adil Saeed Musthafa | 023108a | 2017-04-10 23:13:37 -0700 | [diff] [blame] | 1100 | val = get_param(cmd, "Cellular_Cap_Pref"); |
| 1101 | if (val) |
| 1102 | dut->ap_cell_cap_pref = atoi(val); |
| 1103 | |
Adil Saeed Musthafa | cf752fa | 2017-04-10 23:13:32 -0700 | [diff] [blame] | 1104 | val = get_param(cmd, "DOMAIN"); |
| 1105 | if (val) { |
| 1106 | if (strlen(val) >= sizeof(dut->ap_mobility_domain)) { |
| 1107 | send_resp(dut, conn, SIGMA_ERROR, |
| 1108 | "errorCode,Too long DOMAIN"); |
| 1109 | return 0; |
| 1110 | } |
| 1111 | snprintf(dut->ap_mobility_domain, |
| 1112 | sizeof(dut->ap_mobility_domain), "%s", val); |
| 1113 | } |
| 1114 | |
Adil Saeed Musthafa | 4ec61bd | 2017-04-10 23:13:41 -0700 | [diff] [blame] | 1115 | val = get_param(cmd, "ft_bss_list"); |
| 1116 | if (val) { |
| 1117 | char *mac_str; |
| 1118 | int i; |
| 1119 | char *saveptr; |
| 1120 | char *mac_list_str; |
| 1121 | |
| 1122 | mac_list_str = strdup(val); |
| 1123 | if (!mac_list_str) |
| 1124 | return -1; |
| 1125 | mac_str = strtok_r(mac_list_str, " ", &saveptr); |
| 1126 | for (i = 0; mac_str && i < MAX_FT_BSS_LIST; i++) { |
| 1127 | if (parse_mac_address(dut, mac_str, |
| 1128 | dut->ft_bss_mac_list[i]) < 0) { |
| 1129 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 1130 | "MAC Address not in proper format"); |
| 1131 | break; |
| 1132 | } |
| 1133 | dut->ft_bss_mac_cnt++; |
| 1134 | mac_str = strtok_r(NULL, " ", &saveptr); |
| 1135 | } |
| 1136 | sigma_dut_print(dut, DUT_MSG_DEBUG, |
| 1137 | "Storing the following FT BSS MAC List"); |
| 1138 | for (i = 0; i < dut->ft_bss_mac_cnt; i++) { |
| 1139 | sigma_dut_print(dut, DUT_MSG_DEBUG, |
| 1140 | "MAC[%d] %02x:%02x:%02x:%02x:%02x:%02x", |
| 1141 | i, |
| 1142 | dut->ft_bss_mac_list[i][0], |
| 1143 | dut->ft_bss_mac_list[i][1], |
| 1144 | dut->ft_bss_mac_list[i][2], |
| 1145 | dut->ft_bss_mac_list[i][3], |
| 1146 | dut->ft_bss_mac_list[i][4], |
| 1147 | dut->ft_bss_mac_list[i][5]); |
| 1148 | } |
| 1149 | free(mac_list_str); |
| 1150 | } |
| 1151 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1152 | return 1; |
| 1153 | } |
| 1154 | |
| 1155 | |
| 1156 | static void ath_inject_frame(struct sigma_dut *dut, const char *ifname, int tid) |
| 1157 | { |
| 1158 | char buf[256]; |
| 1159 | int tid_to_dscp[] = { 0x00, 0x20, 0x40, 0x60, 0x80, 0xa0, 0xc0, 0xe0 }; |
| 1160 | |
Pradeep Reddy POTTETI | d31d132 | 2016-10-13 17:22:03 +0530 | [diff] [blame] | 1161 | if (tid < 0 || |
| 1162 | tid >= (int) (sizeof(tid_to_dscp) / sizeof(tid_to_dscp[0]))) { |
| 1163 | sigma_dut_print(dut, DUT_MSG_ERROR, "Unsupported TID: %d", tid); |
| 1164 | return; |
| 1165 | } |
| 1166 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1167 | snprintf(buf, sizeof(buf), |
| 1168 | "wlanconfig %s list sta | grep : | cut -b 1-17 > %s", |
| 1169 | ifname, VI_QOS_TMP_FILE); |
| 1170 | if (system(buf) != 0) |
| 1171 | return; |
| 1172 | |
| 1173 | snprintf(buf, sizeof(buf), |
| 1174 | "ifconfig %s | grep HWaddr | cut -b 39-56 >> %s", |
| 1175 | ifname, VI_QOS_TMP_FILE); |
| 1176 | if (system(buf) != 0) |
| 1177 | sigma_dut_print(dut, DUT_MSG_ERROR, "Retrieve HWaddr failed"); |
| 1178 | |
| 1179 | snprintf(buf, sizeof(buf), "sed -n '3,$p' %s >> %s", |
| 1180 | VI_QOS_REFFILE, VI_QOS_TMP_FILE); |
| 1181 | if (system(buf) != 0) { |
| 1182 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 1183 | "Output redirection to VI_QOS_TMP_FILE failed"); |
| 1184 | } |
| 1185 | |
| 1186 | snprintf(buf, sizeof(buf), "sed '5 c %x' %s > %s", |
| 1187 | tid_to_dscp[tid], VI_QOS_TMP_FILE, VI_QOS_FILE); |
| 1188 | if (system(buf) != 0) { |
| 1189 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 1190 | "Append TID to VI_QOS_FILE failed "); |
| 1191 | } |
| 1192 | |
| 1193 | snprintf(buf, sizeof(buf), "ethinject %s %s", ifname, VI_QOS_FILE); |
| 1194 | if (system(buf) != 0) |
| 1195 | sigma_dut_print(dut, DUT_MSG_ERROR, "Ethinject frame failed"); |
| 1196 | } |
| 1197 | |
| 1198 | |
| 1199 | static int ath_ap_send_addba_req(struct sigma_dut *dut, struct sigma_conn *conn, |
| 1200 | struct sigma_cmd *cmd) |
| 1201 | { |
| 1202 | const char *val; |
| 1203 | char *ifname; |
| 1204 | char buf[256]; |
| 1205 | int tid = 0; |
| 1206 | |
| 1207 | ifname = get_main_ifname(); |
| 1208 | val = get_param(cmd, "TID"); |
| 1209 | if (val) { |
| 1210 | tid = atoi(val); |
| 1211 | if (tid) |
| 1212 | ath_inject_frame(dut, ifname, tid); |
| 1213 | } |
| 1214 | |
| 1215 | /* NOTE: This is the command sequence on Peregrine for ADDBA */ |
| 1216 | snprintf(buf, sizeof(buf), "iwpriv %s setaddbaoper 1", ifname); |
| 1217 | if (system(buf) != 0) { |
| 1218 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 1219 | "iwpriv setaddbaoper failed"); |
| 1220 | } |
| 1221 | |
| 1222 | snprintf(buf, sizeof(buf), "wifitool %s senddelba 1 %d 1 4", |
| 1223 | ifname, tid); |
| 1224 | if (system(buf) != 0) { |
| 1225 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 1226 | "wifitool senddelba failed"); |
| 1227 | } |
| 1228 | |
| 1229 | snprintf(buf, sizeof(buf), "wifitool %s sendaddba 1 %d 64", |
| 1230 | ifname, tid); |
| 1231 | if (system(buf) != 0) { |
| 1232 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 1233 | "wifitool sendaddba failed"); |
| 1234 | } |
| 1235 | |
| 1236 | return 1; |
| 1237 | } |
| 1238 | |
| 1239 | |
Mohammed Shafi Shajakhan | a0535d4 | 2016-06-17 11:55:00 +0530 | [diff] [blame] | 1240 | static int ath10k_debug_enable_addba_req(struct sigma_dut *dut, int tid, |
| 1241 | const char *sta_mac, |
| 1242 | const char *dir_path) |
| 1243 | { |
| 1244 | DIR *dir; |
| 1245 | struct dirent *entry; |
| 1246 | char buf[128], path[128]; |
| 1247 | int ret = 0; |
| 1248 | |
| 1249 | dir = opendir(dir_path); |
| 1250 | if (!dir) |
| 1251 | return 0; |
| 1252 | |
| 1253 | while ((entry = readdir(dir))) { |
| 1254 | ret = 1; |
| 1255 | |
| 1256 | if (strcmp(entry->d_name, ".") == 0 || |
| 1257 | strcmp(entry->d_name, "..") == 0) |
| 1258 | continue; |
| 1259 | |
| 1260 | snprintf(path, sizeof(path) - 1, "%s/%s", |
| 1261 | dir_path, entry->d_name); |
| 1262 | path[sizeof(path) - 1] = 0; |
| 1263 | |
| 1264 | if (strcmp(entry->d_name, sta_mac) == 0) { |
| 1265 | snprintf(buf, sizeof(buf), "echo 1 > %s/aggr_mode", |
| 1266 | path); |
| 1267 | if (system(buf) != 0) { |
| 1268 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 1269 | "Failed to set aggr mode for ath10k"); |
| 1270 | } |
| 1271 | |
| 1272 | snprintf(buf, sizeof(buf), "echo %d 32 > %s/addba", |
| 1273 | tid, path); |
| 1274 | if (system(buf) != 0) { |
| 1275 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 1276 | "Failed to set addbareq for ath10k"); |
| 1277 | } |
| 1278 | |
| 1279 | break; |
| 1280 | } |
| 1281 | |
| 1282 | /* Recursively search subdirectories */ |
| 1283 | ath10k_debug_enable_addba_req(dut, tid, sta_mac, path); |
| 1284 | } |
| 1285 | |
| 1286 | closedir(dir); |
| 1287 | |
| 1288 | return ret; |
| 1289 | } |
| 1290 | |
| 1291 | |
| 1292 | static int ath10k_ap_send_addba_req(struct sigma_dut *dut, |
| 1293 | struct sigma_cmd *cmd) |
| 1294 | { |
| 1295 | const char *val; |
| 1296 | int tid = 0; |
| 1297 | |
| 1298 | val = get_param(cmd, "TID"); |
| 1299 | if (val) |
| 1300 | tid = atoi(val); |
| 1301 | |
| 1302 | val = get_param(cmd, "sta_mac_address"); |
| 1303 | if (!val) { |
| 1304 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 1305 | "Failed to parse station MAC address"); |
| 1306 | return 0; |
| 1307 | } |
| 1308 | |
| 1309 | return ath10k_debug_enable_addba_req(dut, tid, val, |
| 1310 | "/sys/kernel/debug/ieee80211"); |
| 1311 | } |
| 1312 | |
| 1313 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1314 | static int cmd_ap_send_addba_req(struct sigma_dut *dut, struct sigma_conn *conn, |
| 1315 | struct sigma_cmd *cmd) |
| 1316 | { |
| 1317 | /* const char *name = get_param(cmd, "NAME"); */ |
| 1318 | /* const char *ifname = get_param(cmd, "INTERFACE"); */ |
Mohammed Shafi Shajakhan | a0535d4 | 2016-06-17 11:55:00 +0530 | [diff] [blame] | 1319 | struct stat s; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1320 | |
| 1321 | switch (get_driver_type()) { |
| 1322 | case DRIVER_ATHEROS: |
| 1323 | return ath_ap_send_addba_req(dut, conn, cmd); |
| 1324 | case DRIVER_OPENWRT: |
| 1325 | switch (get_openwrt_driver_type()) { |
| 1326 | case OPENWRT_DRIVER_ATHEROS: |
| 1327 | return ath_ap_send_addba_req(dut, conn, cmd); |
| 1328 | default: |
| 1329 | send_resp(dut, conn, SIGMA_ERROR, |
| 1330 | "errorCode,ap_send_addba_req not supported with this driver"); |
| 1331 | return 0; |
| 1332 | } |
Pradeep Reddy POTTETI | fdb0491 | 2016-08-02 14:16:24 +0530 | [diff] [blame] | 1333 | case DRIVER_WCN: |
| 1334 | case DRIVER_LINUX_WCN: |
| 1335 | /* AP automatically sends ADDBA request after association. */ |
| 1336 | sigma_dut_print(dut, DUT_MSG_INFO, |
| 1337 | "ap_send_addba_req command ignored"); |
| 1338 | return 1; |
Mohammed Shafi Shajakhan | a0535d4 | 2016-06-17 11:55:00 +0530 | [diff] [blame] | 1339 | case DRIVER_MAC80211: |
| 1340 | if (stat("/sys/module/ath10k_core", &s) == 0) |
| 1341 | return ath10k_ap_send_addba_req(dut, cmd); |
| 1342 | /* fall through */ |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1343 | default: |
| 1344 | send_resp(dut, conn, SIGMA_ERROR, |
| 1345 | "errorCode,ap_send_addba_req not supported with this driver"); |
| 1346 | return 0; |
| 1347 | } |
| 1348 | } |
| 1349 | |
| 1350 | |
| 1351 | static int cmd_ap_set_security(struct sigma_dut *dut, struct sigma_conn *conn, |
| 1352 | struct sigma_cmd *cmd) |
| 1353 | { |
| 1354 | /* const char *name = get_param(cmd, "NAME"); */ |
| 1355 | const char *val; |
| 1356 | unsigned int wlan_tag = 1; |
| 1357 | |
| 1358 | val = get_param(cmd, "WLAN_TAG"); |
| 1359 | if (val) |
| 1360 | wlan_tag = atoi(val); |
| 1361 | |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 1362 | if (wlan_tag > 1) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1363 | val = get_param(cmd, "KEYMGNT"); |
| 1364 | if (val) { |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 1365 | if (strcasecmp(val, "NONE") == 0) { |
| 1366 | dut->ap_tag_key_mgmt[wlan_tag - 2] = AP2_OPEN; |
| 1367 | } else if (strcasecmp(val, "OSEN") == 0 && |
| 1368 | wlan_tag == 2) { |
| 1369 | /* |
| 1370 | * OSEN only supported on WLAN_TAG = 2 for now |
| 1371 | */ |
| 1372 | dut->ap_tag_key_mgmt[wlan_tag - 2] = AP2_OSEN; |
| 1373 | } else if (strcasecmp(val, "WPA2-PSK") == 0) { |
| 1374 | dut->ap_tag_key_mgmt[wlan_tag - 2] = |
| 1375 | AP2_WPA2_PSK; |
| 1376 | } else { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1377 | send_resp(dut, conn, SIGMA_INVALID, |
| 1378 | "errorCode,Unsupported KEYMGNT"); |
| 1379 | return 0; |
| 1380 | } |
| 1381 | return 1; |
| 1382 | } |
| 1383 | } |
| 1384 | |
| 1385 | val = get_param(cmd, "KEYMGNT"); |
| 1386 | if (val) { |
| 1387 | if (strcasecmp(val, "WPA2-PSK") == 0) { |
| 1388 | dut->ap_key_mgmt = AP_WPA2_PSK; |
| 1389 | dut->ap_cipher = AP_CCMP; |
| 1390 | } else if (strcasecmp(val, "WPA2-EAP") == 0 || |
| 1391 | strcasecmp(val, "WPA2-Ent") == 0) { |
| 1392 | dut->ap_key_mgmt = AP_WPA2_EAP; |
| 1393 | dut->ap_cipher = AP_CCMP; |
Jouni Malinen | ad395a2 | 2017-09-01 21:13:46 +0300 | [diff] [blame] | 1394 | } else if (strcasecmp(val, "SuiteB") == 0) { |
| 1395 | dut->ap_key_mgmt = AP_SUITEB; |
| 1396 | dut->ap_cipher = AP_GCMP_256; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1397 | } else if (strcasecmp(val, "WPA-PSK") == 0) { |
| 1398 | dut->ap_key_mgmt = AP_WPA_PSK; |
| 1399 | dut->ap_cipher = AP_TKIP; |
| 1400 | } else if (strcasecmp(val, "WPA-EAP") == 0 || |
| 1401 | strcasecmp(val, "WPA-Ent") == 0) { |
| 1402 | dut->ap_key_mgmt = AP_WPA_EAP; |
| 1403 | dut->ap_cipher = AP_TKIP; |
| 1404 | } else if (strcasecmp(val, "WPA2-Mixed") == 0) { |
| 1405 | dut->ap_key_mgmt = AP_WPA2_EAP_MIXED; |
| 1406 | dut->ap_cipher = AP_CCMP_TKIP; |
| 1407 | } else if (strcasecmp(val, "WPA2-PSK-Mixed") == 0) { |
| 1408 | dut->ap_key_mgmt = AP_WPA2_PSK_MIXED; |
| 1409 | dut->ap_cipher = AP_CCMP_TKIP; |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 1410 | } else if (strcasecmp(val, "WPA2-SAE") == 0) { |
| 1411 | dut->ap_key_mgmt = AP_WPA2_SAE; |
| 1412 | dut->ap_cipher = AP_CCMP; |
| 1413 | } else if (strcasecmp(val, "WPA2-PSK-SAE") == 0) { |
| 1414 | dut->ap_key_mgmt = AP_WPA2_PSK_SAE; |
| 1415 | dut->ap_cipher = AP_CCMP; |
Jouni Malinen | 147b3c3 | 2017-10-09 16:51:54 +0300 | [diff] [blame] | 1416 | } else if (strcasecmp(val, "OWE") == 0) { |
| 1417 | dut->ap_key_mgmt = AP_WPA2_OWE; |
| 1418 | dut->ap_cipher = AP_CCMP; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1419 | } else if (strcasecmp(val, "NONE") == 0) { |
| 1420 | dut->ap_key_mgmt = AP_OPEN; |
| 1421 | dut->ap_cipher = AP_PLAIN; |
| 1422 | } else { |
| 1423 | send_resp(dut, conn, SIGMA_INVALID, |
| 1424 | "errorCode,Unsupported KEYMGNT"); |
| 1425 | return 0; |
| 1426 | } |
| 1427 | } |
| 1428 | |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 1429 | val = get_param(cmd, "ECGroupID"); |
| 1430 | if (val) { |
Jouni Malinen | ed670f4 | 2017-08-31 01:39:28 +0300 | [diff] [blame] | 1431 | free(dut->ap_sae_groups); |
| 1432 | dut->ap_sae_groups = strdup(val); |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 1433 | } |
| 1434 | |
Jouni Malinen | 2f524ce | 2017-08-31 01:43:29 +0300 | [diff] [blame] | 1435 | val = get_param(cmd, "AntiCloggingThreshold"); |
| 1436 | if (val) |
| 1437 | dut->sae_anti_clogging_threshold = atoi(val); |
| 1438 | |
Jouni Malinen | b347db0 | 2017-09-02 01:36:03 +0300 | [diff] [blame] | 1439 | val = get_param(cmd, "Reflection"); |
| 1440 | if (val) |
| 1441 | dut->sae_reflection = strcasecmp(val, "SAE") == 0; |
| 1442 | |
Jouni Malinen | 6814313 | 2017-09-02 02:34:08 +0300 | [diff] [blame] | 1443 | val = get_param(cmd, "InvalidSAEElement"); |
| 1444 | if (val) { |
| 1445 | free(dut->sae_commit_override); |
| 1446 | dut->sae_commit_override = strdup(val); |
| 1447 | } |
| 1448 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1449 | val = get_param(cmd, "ENCRYPT"); |
| 1450 | if (val) { |
| 1451 | if (strcasecmp(val, "WEP") == 0) { |
| 1452 | dut->ap_cipher = AP_WEP; |
| 1453 | } else if (strcasecmp(val, "TKIP") == 0) { |
| 1454 | dut->ap_cipher = AP_TKIP; |
| 1455 | } else if (strcasecmp(val, "AES") == 0 || |
| 1456 | strcasecmp(val, "AES-CCMP") == 0) { |
| 1457 | dut->ap_cipher = AP_CCMP; |
Jouni Malinen | 3d633da | 2017-09-14 22:19:21 +0300 | [diff] [blame] | 1458 | } else if (strcasecmp(val, "AES-GCMP") == 0) { |
| 1459 | dut->ap_cipher = AP_GCMP_128; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1460 | } else { |
| 1461 | send_resp(dut, conn, SIGMA_INVALID, |
| 1462 | "errorCode,Unsupported ENCRYPT"); |
| 1463 | return 0; |
| 1464 | } |
| 1465 | } |
| 1466 | |
Jouni Malinen | 3d633da | 2017-09-14 22:19:21 +0300 | [diff] [blame] | 1467 | val = get_param(cmd, "PairwiseCipher"); |
| 1468 | if (val) { |
| 1469 | if (strcasecmp(val, "AES-GCMP-256") == 0) { |
| 1470 | dut->ap_cipher = AP_GCMP_256; |
| 1471 | } else if (strcasecmp(val, "AES-CCMP-256") == 0) { |
| 1472 | dut->ap_cipher = AP_CCMP_256; |
| 1473 | } else if (strcasecmp(val, "AES-GCMP-128") == 0) { |
| 1474 | dut->ap_cipher = AP_GCMP_128; |
| 1475 | } else if (strcasecmp(val, "AES-CCMP-128") == 0) { |
| 1476 | dut->ap_cipher = AP_CCMP; |
| 1477 | } else { |
| 1478 | send_resp(dut, conn, SIGMA_INVALID, |
| 1479 | "errorCode,Unsupported PairwiseCipher"); |
| 1480 | return 0; |
| 1481 | } |
| 1482 | } |
| 1483 | |
| 1484 | val = get_param(cmd, "GroupMgntCipher"); |
| 1485 | if (val) { |
| 1486 | if (strcasecmp(val, "BIP-GMAC-256") == 0) { |
| 1487 | dut->ap_group_mgmt_cipher = AP_BIP_GMAC_256; |
| 1488 | } else if (strcasecmp(val, "BIP-CMAC-256") == 0) { |
| 1489 | dut->ap_group_mgmt_cipher = AP_BIP_CMAC_256; |
| 1490 | } else if (strcasecmp(val, "BIP-GMAC-128") == 0) { |
| 1491 | dut->ap_group_mgmt_cipher = AP_BIP_GMAC_128; |
| 1492 | } else if (strcasecmp(val, "BIP-CMAC-128") == 0) { |
| 1493 | dut->ap_group_mgmt_cipher = AP_BIP_CMAC_128; |
| 1494 | } else { |
| 1495 | send_resp(dut, conn, SIGMA_INVALID, |
| 1496 | "errorCode,Unsupported GroupMgntCipher"); |
| 1497 | return 0; |
| 1498 | } |
| 1499 | } |
| 1500 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1501 | val = get_param(cmd, "WEPKEY"); |
| 1502 | if (val) { |
| 1503 | size_t len; |
| 1504 | if (dut->ap_cipher != AP_WEP) { |
| 1505 | send_resp(dut, conn, SIGMA_INVALID, |
| 1506 | "errorCode,Unexpected WEPKEY without WEP " |
| 1507 | "configuration"); |
| 1508 | return 0; |
| 1509 | } |
| 1510 | len = strlen(val); |
| 1511 | if (len != 10 && len != 26) { |
| 1512 | send_resp(dut, conn, SIGMA_INVALID, |
| 1513 | "errorCode,Unexpected WEPKEY length"); |
| 1514 | return 0; |
| 1515 | } |
| 1516 | snprintf(dut->ap_wepkey, sizeof(dut->ap_wepkey), "%s", val); |
| 1517 | } |
| 1518 | |
| 1519 | val = get_param(cmd, "PSK"); |
| 1520 | if (val) { |
| 1521 | if (strlen(val) > sizeof(dut->ap_passphrase) - 1) |
| 1522 | return -1; |
| 1523 | snprintf(dut->ap_passphrase, sizeof(dut->ap_passphrase), |
| 1524 | "%s", val); |
| 1525 | } |
| 1526 | |
| 1527 | val = get_param(cmd, "PMF"); |
| 1528 | if (val) { |
| 1529 | if (strcasecmp(val, "Disabled") == 0) { |
| 1530 | dut->ap_pmf = AP_PMF_DISABLED; |
| 1531 | } else if (strcasecmp(val, "Optional") == 0) { |
| 1532 | dut->ap_pmf = AP_PMF_OPTIONAL; |
| 1533 | } else if (strcasecmp(val, "Required") == 0) { |
| 1534 | dut->ap_pmf = AP_PMF_REQUIRED; |
| 1535 | } else { |
| 1536 | send_resp(dut, conn, SIGMA_INVALID, |
| 1537 | "errorCode,Unsupported PMF"); |
| 1538 | return 0; |
| 1539 | } |
| 1540 | } |
| 1541 | |
| 1542 | if (dut->ap_key_mgmt == AP_OPEN) { |
| 1543 | dut->ap_hs2 = 0; |
| 1544 | dut->ap_pmf = AP_PMF_DISABLED; |
| 1545 | } |
| 1546 | |
| 1547 | dut->ap_add_sha256 = 0; |
| 1548 | val = get_param(cmd, "SHA256AD"); |
| 1549 | if (val == NULL) |
| 1550 | val = get_param(cmd, "SHA256"); |
| 1551 | if (val) { |
| 1552 | if (strcasecmp(val, "Disabled") == 0) { |
| 1553 | } else if (strcasecmp(val, "Enabled") == 0) { |
| 1554 | dut->ap_add_sha256 = 1; |
| 1555 | } else { |
| 1556 | send_resp(dut, conn, SIGMA_INVALID, |
| 1557 | "errorCode,Unsupported PMF"); |
| 1558 | return 0; |
| 1559 | } |
| 1560 | } |
| 1561 | |
Sarvepalli, Rajesh Babu | 24dc7e4 | 2016-03-18 21:27:26 +0530 | [diff] [blame] | 1562 | val = get_param(cmd, "PreAuthentication"); |
| 1563 | if (val) { |
| 1564 | if (strcasecmp(val, "disabled") == 0) { |
| 1565 | dut->ap_rsn_preauth = 0; |
| 1566 | } else if (strcasecmp(val, "enabled") == 0) { |
| 1567 | dut->ap_rsn_preauth = 1; |
| 1568 | } else { |
| 1569 | send_resp(dut, conn, SIGMA_INVALID, |
| 1570 | "errorCode,Unsupported PreAuthentication value"); |
| 1571 | return 0; |
| 1572 | } |
| 1573 | } |
| 1574 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1575 | return 1; |
| 1576 | } |
| 1577 | |
| 1578 | |
| 1579 | static int cmd_ap_set_radius(struct sigma_dut *dut, struct sigma_conn *conn, |
| 1580 | struct sigma_cmd *cmd) |
| 1581 | { |
| 1582 | /* const char *name = get_param(cmd, "NAME"); */ |
| 1583 | const char *val; |
| 1584 | unsigned int wlan_tag = 1, radius_port = 0; |
| 1585 | char *radius_ipaddr = NULL, *radius_password = NULL; |
| 1586 | |
| 1587 | val = get_param(cmd, "WLAN_TAG"); |
| 1588 | if (val) { |
| 1589 | wlan_tag = atoi(val); |
| 1590 | if (wlan_tag != 1 && wlan_tag != 2) { |
| 1591 | send_resp(dut, conn, SIGMA_INVALID, |
| 1592 | "errorCode,Invalid WLAN_TAG"); |
| 1593 | return 0; |
| 1594 | } |
| 1595 | } |
| 1596 | |
| 1597 | val = get_param(cmd, "PORT"); |
| 1598 | if (val) |
| 1599 | radius_port = atoi(val); |
| 1600 | |
| 1601 | if (wlan_tag == 1) { |
| 1602 | if (radius_port) |
| 1603 | dut->ap_radius_port = radius_port; |
| 1604 | radius_ipaddr = dut->ap_radius_ipaddr; |
| 1605 | radius_password = dut->ap_radius_password; |
| 1606 | } else if (wlan_tag == 2) { |
| 1607 | if (radius_port) |
| 1608 | dut->ap2_radius_port = radius_port; |
| 1609 | radius_ipaddr = dut->ap2_radius_ipaddr; |
| 1610 | radius_password = dut->ap2_radius_password; |
| 1611 | } |
| 1612 | |
| 1613 | val = get_param(cmd, "IPADDR"); |
| 1614 | if (val) { |
| 1615 | if (strlen(val) > sizeof(dut->ap_radius_ipaddr) - 1) |
| 1616 | return -1; |
| 1617 | snprintf(radius_ipaddr, sizeof(dut->ap_radius_ipaddr), |
| 1618 | "%s", val); |
| 1619 | } |
| 1620 | |
| 1621 | val = get_param(cmd, "PASSWORD"); |
| 1622 | if (val) { |
| 1623 | if (strlen(val) > sizeof(dut->ap_radius_password) - 1) |
| 1624 | return -1; |
| 1625 | snprintf(radius_password, |
| 1626 | sizeof(dut->ap_radius_password), "%s", val); |
| 1627 | } |
| 1628 | |
| 1629 | return 1; |
| 1630 | } |
| 1631 | |
| 1632 | |
| 1633 | static void owrt_ap_set_radio(struct sigma_dut *dut, int id, |
| 1634 | const char *key, const char *val) |
| 1635 | { |
| 1636 | char buf[100]; |
| 1637 | |
| 1638 | if (val == NULL) { |
| 1639 | snprintf(buf, sizeof(buf), |
| 1640 | "uci delete wireless.wifi%d.%s", id, key); |
| 1641 | run_system(dut, buf); |
| 1642 | return; |
| 1643 | } |
| 1644 | |
| 1645 | snprintf(buf, sizeof(buf), "uci set wireless.wifi%d.%s=%s", |
| 1646 | id, key, val); |
| 1647 | run_system(dut, buf); |
| 1648 | } |
| 1649 | |
| 1650 | |
| 1651 | static void owrt_ap_set_list_radio(struct sigma_dut *dut, int id, |
| 1652 | const char *key, const char *val) |
| 1653 | { |
| 1654 | char buf[256]; |
| 1655 | |
| 1656 | if (val == NULL) { |
| 1657 | snprintf(buf, sizeof(buf), |
| 1658 | "uci del_list wireless.wifi%d.%s", id, key); |
| 1659 | run_system(dut, buf); |
| 1660 | return; |
| 1661 | } |
| 1662 | |
| 1663 | snprintf(buf, sizeof(buf), "uci add_list wireless.wifi%d.%s=%s", |
| 1664 | id, key, val); |
| 1665 | run_system(dut, buf); |
| 1666 | } |
| 1667 | |
| 1668 | |
| 1669 | static void owrt_ap_set_vap(struct sigma_dut *dut, int id, const char *key, |
| 1670 | const char *val) |
| 1671 | { |
| 1672 | char buf[256]; |
| 1673 | |
| 1674 | if (val == NULL) { |
| 1675 | snprintf(buf, sizeof(buf), |
| 1676 | "uci delete wireless.@wifi-iface[%d].%s", id, key); |
| 1677 | run_system(dut, buf); |
| 1678 | return; |
| 1679 | } |
| 1680 | |
| 1681 | snprintf(buf, sizeof(buf), "uci set wireless.@wifi-iface[%d].%s=%s", |
| 1682 | id, key, val); |
| 1683 | run_system(dut, buf); |
| 1684 | } |
| 1685 | |
| 1686 | |
| 1687 | static void owrt_ap_set_list_vap(struct sigma_dut *dut, int id, |
| 1688 | const char *key, const char *val) |
| 1689 | { |
priyadharshini gowthaman | 2323d0a | 2016-09-02 15:48:02 -0700 | [diff] [blame] | 1690 | char buf[1024]; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1691 | |
| 1692 | if (val == NULL) { |
| 1693 | snprintf(buf, sizeof(buf), |
| 1694 | "uci del_list wireless.@wifi-iface[%d].%s", id, key); |
| 1695 | run_system(dut, buf); |
| 1696 | return; |
| 1697 | } |
| 1698 | |
| 1699 | snprintf(buf, sizeof(buf), |
| 1700 | "uci add_list wireless.@wifi-iface[%d].%s=%s", |
| 1701 | id, key, val); |
| 1702 | run_system(dut, buf); |
| 1703 | } |
| 1704 | |
| 1705 | |
| 1706 | static void owrt_ap_add_vap(struct sigma_dut *dut, int id, const char *key, |
| 1707 | const char *val) |
| 1708 | { |
| 1709 | char buf[256]; |
| 1710 | |
| 1711 | if (val == NULL) { |
| 1712 | snprintf(buf, sizeof(buf), |
| 1713 | "uci delete wireless.@wifi-iface[%d].%s", id, key); |
| 1714 | run_system(dut, buf); |
| 1715 | return; |
| 1716 | } |
| 1717 | |
| 1718 | snprintf(buf, sizeof(buf), "uci add wireless wifi-iface"); |
| 1719 | run_system(dut, buf); |
| 1720 | snprintf(buf, sizeof(buf), "uci set wireless.@wifi-iface[%d].%s=%s", |
| 1721 | id, key, val); |
| 1722 | run_system(dut, buf); |
| 1723 | snprintf(buf, sizeof(buf), "uci set wireless.@wifi-iface[%d].%s=%s", |
| 1724 | id, "network", "lan"); |
| 1725 | run_system(dut, buf); |
| 1726 | snprintf(buf, sizeof(buf), "uci set wireless.@wifi-iface[%d].%s=%s", |
| 1727 | id, "mode", "ap"); |
| 1728 | run_system(dut, buf); |
| 1729 | snprintf(buf, sizeof(buf), "uci set wireless.@wifi-iface[%d].%s=%s", |
| 1730 | id, "encryption", "none"); |
| 1731 | run_system(dut, buf); |
| 1732 | } |
| 1733 | |
| 1734 | |
| 1735 | #define OPENWRT_MAX_NUM_RADIOS 3 |
| 1736 | static void owrt_ap_config_radio(struct sigma_dut *dut) |
| 1737 | { |
| 1738 | int radio_id[MAX_RADIO] = { 0, 1 }; |
| 1739 | int radio_count, radio_no; |
| 1740 | char buf[64]; |
| 1741 | |
| 1742 | for (radio_count = 0; radio_count < OPENWRT_MAX_NUM_RADIOS; |
| 1743 | radio_count++) { |
| 1744 | snprintf(buf, sizeof(buf), "%s%d", "wifi", radio_count); |
| 1745 | for (radio_no = 0; radio_no < MAX_RADIO; radio_no++) { |
| 1746 | if (!sigma_radio_ifname[radio_no] || |
| 1747 | strcmp(sigma_radio_ifname[radio_no], buf) != 0) |
| 1748 | continue; |
| 1749 | owrt_ap_set_radio(dut, radio_count, "disabled", "0"); |
| 1750 | owrt_ap_set_vap(dut, radio_count, "device", buf); |
| 1751 | radio_id[radio_no] = radio_count; |
| 1752 | } |
| 1753 | } |
| 1754 | |
| 1755 | /* Hardware mode (11a/b/g/n/ac) & HT mode selection */ |
| 1756 | switch (dut->ap_mode) { |
| 1757 | case AP_11g: |
| 1758 | owrt_ap_set_radio(dut, radio_id[0], "hwmode", "11g"); |
| 1759 | break; |
| 1760 | case AP_11b: |
| 1761 | owrt_ap_set_radio(dut, radio_id[0], "hwmode", "11b"); |
| 1762 | break; |
| 1763 | case AP_11ng: |
| 1764 | owrt_ap_set_radio(dut, radio_id[0], "hwmode", "11ng"); |
| 1765 | owrt_ap_set_radio(dut, radio_id[0], "htmode", "HT20"); |
| 1766 | break; |
| 1767 | case AP_11a: |
| 1768 | owrt_ap_set_radio(dut, radio_id[0], "hwmode", "11a"); |
| 1769 | break; |
| 1770 | case AP_11na: |
| 1771 | owrt_ap_set_radio(dut, radio_id[0], "hwmode", "11na"); |
| 1772 | owrt_ap_set_radio(dut, radio_id[0], "htmode", "HT20"); |
| 1773 | break; |
| 1774 | case AP_11ac: |
| 1775 | owrt_ap_set_radio(dut, radio_id[0], "hwmode", "11ac"); |
| 1776 | owrt_ap_set_radio(dut, radio_id[0], "htmode", "HT80"); |
| 1777 | break; |
| 1778 | case AP_inval: |
| 1779 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 1780 | "MODE NOT SPECIFIED!"); |
| 1781 | return; |
| 1782 | default: |
| 1783 | owrt_ap_set_radio(dut, radio_id[0], "hwmode", "11ng"); |
| 1784 | owrt_ap_set_radio(dut, radio_id[0], "htmode", "HT20"); |
| 1785 | break; |
| 1786 | } |
| 1787 | |
| 1788 | if (dut->ap_is_dual) { |
| 1789 | /* Hardware mode (11a/b/g/n/ac) & HT mode selection */ |
| 1790 | switch (dut->ap_mode_1) { |
| 1791 | case AP_11g: |
| 1792 | owrt_ap_set_radio(dut, radio_id[1], "hwmode", "11g"); |
| 1793 | break; |
| 1794 | case AP_11b: |
| 1795 | owrt_ap_set_radio(dut, radio_id[1], "hwmode", "11b"); |
| 1796 | break; |
| 1797 | case AP_11ng: |
| 1798 | owrt_ap_set_radio(dut, radio_id[1], "hwmode", "11ng"); |
| 1799 | owrt_ap_set_radio(dut, radio_id[1], "htmode", "HT20"); |
| 1800 | break; |
| 1801 | case AP_11a: |
| 1802 | owrt_ap_set_radio(dut, radio_id[1], "hwmode", "11a"); |
| 1803 | break; |
| 1804 | case AP_11na: |
| 1805 | owrt_ap_set_radio(dut, radio_id[1], "hwmode", "11na"); |
| 1806 | owrt_ap_set_radio(dut, radio_id[1], "htmode", "HT20"); |
| 1807 | break; |
| 1808 | case AP_11ac: |
| 1809 | owrt_ap_set_radio(dut, radio_id[1], "hwmode", "11ac"); |
| 1810 | owrt_ap_set_radio(dut, radio_id[1], "htmode", "HT80"); |
| 1811 | break; |
| 1812 | case AP_inval: |
| 1813 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 1814 | "MODE NOT SPECIFIED!"); |
| 1815 | return; |
| 1816 | default: |
| 1817 | owrt_ap_set_radio(dut, radio_id[1], "hwmode", "11ng"); |
| 1818 | owrt_ap_set_radio(dut, radio_id[1], "htmode", "HT20"); |
| 1819 | break; |
| 1820 | } |
| 1821 | |
| 1822 | } |
| 1823 | |
| 1824 | /* Channel */ |
| 1825 | snprintf(buf, sizeof(buf), "%d", dut->ap_channel); |
| 1826 | owrt_ap_set_radio(dut, radio_id[0], "channel", buf); |
| 1827 | |
| 1828 | switch (dut->ap_chwidth) { |
| 1829 | case AP_20: |
| 1830 | owrt_ap_set_radio(dut, radio_id[0], "htmode", "HT20"); |
| 1831 | break; |
| 1832 | case AP_40: |
| 1833 | owrt_ap_set_radio(dut, radio_id[0], "htmode", "HT40"); |
| 1834 | break; |
| 1835 | case AP_80: |
| 1836 | owrt_ap_set_radio(dut, radio_id[0], "htmode", "HT80"); |
| 1837 | break; |
| 1838 | case AP_160: |
| 1839 | owrt_ap_set_radio(dut, radio_id[0], "htmode", "HT160"); |
| 1840 | break; |
| 1841 | case AP_AUTO: |
| 1842 | default: |
| 1843 | break; |
| 1844 | } |
| 1845 | |
| 1846 | if (dut->ap_channel == 140 || dut->ap_channel == 144) { |
| 1847 | if (get_openwrt_driver_type() == OPENWRT_DRIVER_ATHEROS) |
| 1848 | owrt_ap_set_radio(dut, radio_id[0], "set_ch_144", "3"); |
| 1849 | } |
| 1850 | |
| 1851 | if (dut->ap_is_dual) { |
| 1852 | snprintf(buf, sizeof(buf), "%d", dut->ap_channel_1); |
| 1853 | owrt_ap_set_radio(dut, radio_id[1], "channel", buf); |
| 1854 | } |
| 1855 | |
Adil Saeed Musthafa | 604c826 | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 1856 | /* Country Code */ |
| 1857 | if (dut->ap_reg_domain == REG_DOMAIN_GLOBAL) { |
| 1858 | const char *country; |
| 1859 | |
| 1860 | country = dut->ap_countrycode[0] ? dut->ap_countrycode : "US"; |
| 1861 | snprintf(buf, sizeof(buf), "%s4", country); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1862 | owrt_ap_set_radio(dut, radio_id[0], "country", buf); |
Adil Saeed Musthafa | 604c826 | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 1863 | } else if (dut->ap_countrycode[0]) { |
| 1864 | owrt_ap_set_radio(dut, radio_id[0], "country", |
| 1865 | dut->ap_countrycode); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1866 | } |
| 1867 | |
| 1868 | if (dut->ap_disable_protection == 1) { |
| 1869 | owrt_ap_set_list_radio(dut, radio_id[0], "aggr_burst", "'0 0'"); |
| 1870 | owrt_ap_set_list_radio(dut, radio_id[0], "aggr_burst", "'1 0'"); |
| 1871 | owrt_ap_set_list_radio(dut, radio_id[0], "aggr_burst", "'2 0'"); |
| 1872 | owrt_ap_set_list_radio(dut, radio_id[0], "aggr_burst", "'3 0'"); |
| 1873 | } |
| 1874 | } |
| 1875 | |
| 1876 | |
| 1877 | static int owrt_ap_config_vap_hs2(struct sigma_dut *dut, int vap_id) |
| 1878 | { |
| 1879 | char buf[256]; |
| 1880 | |
| 1881 | snprintf(buf, sizeof(buf), "%d", dut->ap_hs2); |
| 1882 | owrt_ap_set_vap(dut, vap_id, "hs20", buf); |
| 1883 | owrt_ap_set_vap(dut, vap_id, "qbssload", "1"); |
| 1884 | owrt_ap_set_vap(dut, vap_id, "hs20_deauth_req_timeout","3"); |
| 1885 | |
| 1886 | owrt_ap_set_list_vap(dut, vap_id, "hs20_oper_friendly_name", |
| 1887 | "'eng:Wi-Fi Alliance'"); |
| 1888 | |
| 1889 | owrt_ap_set_list_vap(dut, vap_id, "hs20_oper_friendly_name", |
| 1890 | "'chi:Wi-Fi\xe8\x81\x94\xe7\x9b\x9f'"); |
| 1891 | |
| 1892 | if (dut->ap_wan_metrics == 1) |
| 1893 | owrt_ap_set_vap(dut, vap_id, "hs20_wan_metrics", |
| 1894 | "'01:2500:384:0:0:10'"); |
| 1895 | else if (dut->ap_wan_metrics == 1) |
| 1896 | owrt_ap_set_vap(dut, vap_id, "hs20_wan_metrics", |
| 1897 | "'01:1500:384:20:20:10'"); |
| 1898 | else if (dut->ap_wan_metrics == 2) |
| 1899 | owrt_ap_set_vap(dut, vap_id, "hs20_wan_metrics", |
| 1900 | "'01:1500:384:20:20:10'"); |
| 1901 | else if (dut->ap_wan_metrics == 3) |
| 1902 | owrt_ap_set_vap(dut, vap_id, "hs20_wan_metrics", |
| 1903 | "'01:2000:1000:20:20:10'"); |
| 1904 | else if (dut->ap_wan_metrics == 4) |
| 1905 | owrt_ap_set_vap(dut, vap_id, "hs20_wan_metrics", |
| 1906 | "'01:8000:1000:20:20:10'"); |
| 1907 | else if (dut->ap_wan_metrics == 5) |
| 1908 | owrt_ap_set_vap(dut, vap_id, "hs20_wan_metrics", |
| 1909 | "'01:9000:5000:20:20:10'"); |
| 1910 | |
| 1911 | if (dut->ap_conn_capab == 1) { |
| 1912 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", "'1:0:0'"); |
| 1913 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", |
| 1914 | "'6:20:1'"); |
| 1915 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", |
| 1916 | "'6:22:0'"); |
| 1917 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", |
| 1918 | "'6:80:1'"); |
| 1919 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", |
| 1920 | "'6:443:1'"); |
| 1921 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", |
| 1922 | "'6:1723:0'"); |
| 1923 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", |
| 1924 | "'6:5060:0'"); |
| 1925 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", |
| 1926 | "'17:500:1'"); |
| 1927 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", |
| 1928 | "'17:5060:0'"); |
| 1929 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", |
| 1930 | "'17:4500:1'"); |
| 1931 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", |
| 1932 | "'50:0:1'"); |
| 1933 | } else if (dut->ap_conn_capab == 2) { |
| 1934 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", |
| 1935 | "'6:80:1'"); |
| 1936 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", |
| 1937 | "'6:443:1'"); |
| 1938 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", |
| 1939 | "'17:5060:1'"); |
| 1940 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", |
| 1941 | "'6:5060:1'"); |
| 1942 | } else if (dut->ap_conn_capab == 3) { |
| 1943 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", |
| 1944 | "'6:80:1'"); |
| 1945 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", |
| 1946 | "'6:443:1'"); |
| 1947 | } |
| 1948 | |
| 1949 | if (dut->ap_oper_class == 1) |
| 1950 | snprintf(buf, sizeof(buf), "%s", "51"); |
| 1951 | else if (dut->ap_oper_class == 2) |
| 1952 | snprintf(buf, sizeof(buf), "%s", "73"); |
| 1953 | else if (dut->ap_oper_class == 3) |
| 1954 | snprintf(buf, sizeof(buf), "%s", "5173"); |
| 1955 | |
| 1956 | if (dut->ap_oper_class) |
| 1957 | owrt_ap_set_vap(dut, vap_id, "hs20_operating_class", buf); |
| 1958 | |
| 1959 | if (dut->ap_osu_provider_list) { |
| 1960 | char *osu_friendly_name = NULL; |
| 1961 | char *osu_icon = NULL; |
| 1962 | char *osu_ssid = NULL; |
| 1963 | char *osu_nai = NULL; |
| 1964 | char *osu_service_desc = NULL; |
| 1965 | char *hs20_icon_filename = NULL; |
| 1966 | char hs20_icon[150]; |
| 1967 | int osu_method; |
| 1968 | |
| 1969 | hs20_icon_filename = "icon_red_zxx.png"; |
| 1970 | if (dut->ap_osu_icon_tag == 2) |
| 1971 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 1972 | snprintf(hs20_icon, sizeof(hs20_icon), |
| 1973 | "'128:61:zxx:image/png:icon_red_zxx.png:/etc/ath/%s'", |
| 1974 | hs20_icon_filename); |
| 1975 | osu_icon = "icon_red_zxx.png"; |
| 1976 | osu_ssid = "OSU"; |
| 1977 | osu_friendly_name = "'kor:SP 빨강 테스트 전용'"; |
| 1978 | osu_service_desc = "'kor:테스트 목적으로 무료 서비스'"; |
| 1979 | osu_method = (dut->ap_osu_method[0] == 0xFF) ? 1 : |
| 1980 | dut->ap_osu_method[0]; |
| 1981 | |
| 1982 | if (strlen(dut->ap_osu_server_uri[0])) |
| 1983 | owrt_ap_set_list_vap(dut, vap_id, "osu_server_uri", |
| 1984 | dut->ap_osu_server_uri[0]); |
| 1985 | else |
| 1986 | owrt_ap_set_list_vap(dut, vap_id, "osu_server_uri", |
| 1987 | "'https://osu-server.r2-testbed.wi-fi.org/'"); |
| 1988 | switch (dut->ap_osu_provider_list) { |
| 1989 | case 1: |
| 1990 | case 101: |
| 1991 | owrt_ap_set_list_vap(dut, vap_id, "osu_friendly_name", |
| 1992 | "'eng:SP Red Test Only'"); |
| 1993 | owrt_ap_set_list_vap(dut, vap_id, "osu_service_desc", |
| 1994 | "'eng:Free service for test purpose'"); |
| 1995 | owrt_ap_set_list_vap(dut, vap_id, "hs20_icon", |
| 1996 | hs20_icon); |
| 1997 | |
| 1998 | hs20_icon_filename = "icon_red_eng.png"; |
| 1999 | if (dut->ap_osu_icon_tag == 2) |
| 2000 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 2001 | |
| 2002 | snprintf(hs20_icon, sizeof(hs20_icon), |
| 2003 | "'160:76:eng:image/png:icon_red_eng.png:/etc/ath/%s'", |
| 2004 | hs20_icon_filename); |
| 2005 | owrt_ap_set_list_vap(dut, vap_id, "osu_icon", |
| 2006 | "icon_red_eng.png"); |
| 2007 | break; |
| 2008 | case 2: |
| 2009 | case 102: |
| 2010 | owrt_ap_set_list_vap(dut, vap_id, "osu_friendly_name", |
| 2011 | "'eng:Wireless Broadband Alliance'"); |
| 2012 | owrt_ap_set_list_vap(dut, vap_id, "osu_service_desc", |
| 2013 | "'eng:Free service for test purpose'"); |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2014 | hs20_icon_filename = "icon_orange_zxx.png"; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2015 | if (dut->ap_osu_icon_tag == 2) |
| 2016 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 2017 | |
| 2018 | snprintf(hs20_icon, sizeof(hs20_icon), |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2019 | "'128:61:zxx:image/png:icon_orange_zxx.png:/etc/ath/%s'", |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2020 | hs20_icon_filename); |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2021 | osu_icon = "icon_orange_zxx.png"; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2022 | osu_friendly_name = "'kor:와이어리스 브로드밴드 얼라이언스'"; |
| 2023 | break; |
| 2024 | case 3: |
| 2025 | case 103: |
| 2026 | osu_friendly_name = "spa:SP Red Test Only"; |
| 2027 | osu_service_desc = "spa:Free service for test purpose"; |
| 2028 | break; |
| 2029 | case 4: |
| 2030 | case 104: |
| 2031 | owrt_ap_set_list_vap(dut, vap_id, "osu_friendly_name", |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2032 | "'eng:SP Orange Test Only'"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2033 | owrt_ap_set_list_vap(dut, vap_id, "osu_service_desc", |
| 2034 | "'eng:Free service for test purpose'"); |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2035 | hs20_icon_filename = "icon_orange_eng.png"; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2036 | if (dut->ap_osu_icon_tag == 2) |
| 2037 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 2038 | |
| 2039 | snprintf(hs20_icon, sizeof(hs20_icon), |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2040 | "'160:76:eng:image/png:icon_orange_eng.png:/etc/ath/%s'", |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2041 | hs20_icon_filename); |
| 2042 | owrt_ap_set_list_vap(dut, vap_id, "hs20_icon", |
| 2043 | hs20_icon); |
| 2044 | osu_friendly_name = "'kor:SP 파랑 테스트 전용'"; |
| 2045 | |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2046 | hs20_icon_filename = "icon_orange_zxx.png"; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2047 | if (dut->ap_osu_icon_tag == 2) |
| 2048 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 2049 | |
| 2050 | snprintf(hs20_icon, sizeof(hs20_icon), |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2051 | "'128:61:zxx:image/png:icon_orange_zxx.png:/etc/ath/%s'", |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2052 | hs20_icon_filename); |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2053 | osu_icon = "icon_orange_zxx.png"; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2054 | break; |
| 2055 | case 5: |
| 2056 | case 105: |
| 2057 | owrt_ap_set_list_vap(dut, vap_id, "osu_friendly_name", |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2058 | "'eng:SP Orange Test Only'"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2059 | owrt_ap_set_list_vap(dut, vap_id, "osu_service_desc", |
| 2060 | "'eng:Free service for test purpose'"); |
| 2061 | osu_friendly_name = "'kor:SP 파랑 테스트 전용'"; |
| 2062 | |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2063 | hs20_icon_filename = "icon_orange_zxx.png"; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2064 | if (dut->ap_osu_icon_tag == 2) |
| 2065 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 2066 | |
| 2067 | snprintf(hs20_icon, sizeof(hs20_icon), |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2068 | "'128:61:zxx:image/png:icon_orange_zxx.png:/etc/ath/%s'", |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2069 | hs20_icon_filename); |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2070 | osu_icon = "icon_orange_zxx.png"; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2071 | break; |
| 2072 | case 6: |
| 2073 | case 106: |
| 2074 | owrt_ap_set_list_vap(dut, vap_id, "osu_friendly_name", |
| 2075 | "'eng:SP Green Test Only'"); |
| 2076 | owrt_ap_set_list_vap(dut, vap_id, "osu_friendly_name", |
| 2077 | "'kor:SP 초록 테스트 전용'"); |
| 2078 | |
| 2079 | hs20_icon_filename = "icon_green_zxx.png"; |
| 2080 | if (dut->ap_osu_icon_tag == 2) |
| 2081 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 2082 | |
| 2083 | snprintf(hs20_icon, sizeof(hs20_icon), |
| 2084 | "'128:61:zxx:image/png:icon_green_zxx.png:/etc/ath/%s'", |
| 2085 | hs20_icon_filename); |
| 2086 | owrt_ap_set_list_vap(dut, vap_id, "hs20_icon", |
| 2087 | hs20_icon); |
| 2088 | |
| 2089 | owrt_ap_set_list_vap(dut, vap_id, "osu_icon", |
| 2090 | "'icon_green_zxx.png'"); |
| 2091 | osu_method = (dut->ap_osu_method[0] == 0xFF) ? 0 : |
| 2092 | dut->ap_osu_method[0]; |
| 2093 | |
| 2094 | snprintf(buf, sizeof(buf), "%d", osu_method); |
| 2095 | owrt_ap_set_vap(dut, vap_id, "osu_method_list", buf); |
| 2096 | |
| 2097 | if (strlen(dut->ap_osu_server_uri[1])) |
| 2098 | owrt_ap_set_list_vap(dut, vap_id, |
| 2099 | "osu_server_uri", |
| 2100 | dut->ap_osu_server_uri[1]); |
| 2101 | else |
| 2102 | owrt_ap_set_list_vap(dut, vap_id, |
| 2103 | "osu_server_uri", |
| 2104 | "'https://osu-server.r2-testbed.wi-fi.org/'"); |
| 2105 | |
| 2106 | owrt_ap_set_list_vap(dut, vap_id, "osu_friendly_name", |
| 2107 | "'eng:SP Orange Test Only'"); |
| 2108 | |
| 2109 | hs20_icon_filename = "icon_orange_zxx.png"; |
| 2110 | if (dut->ap_osu_icon_tag == 2) |
| 2111 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 2112 | |
| 2113 | snprintf(hs20_icon, sizeof(hs20_icon), |
| 2114 | "'128:61:zxx:image/png:icon_orange_zxx.png:/etc/ath/%s'", |
| 2115 | hs20_icon_filename); |
| 2116 | |
| 2117 | osu_icon = "icon_orange_zxx.png"; |
| 2118 | osu_friendly_name = "'kor:SP 오렌지 테스트 전용'"; |
| 2119 | osu_method = (dut->ap_osu_method[1] == 0xFF) ? 0 : |
| 2120 | dut->ap_osu_method[1]; |
| 2121 | osu_service_desc = NULL; |
| 2122 | break; |
| 2123 | case 7: |
| 2124 | case 107: |
| 2125 | owrt_ap_set_list_vap(dut, vap_id, "osu_friendly_name", |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2126 | "'eng:SP Green Test Only'"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2127 | owrt_ap_set_list_vap(dut, vap_id, "osu_service_desc", |
| 2128 | "'eng:Free service for test purpose'"); |
| 2129 | |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2130 | hs20_icon_filename = "icon_green_eng.png"; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2131 | if (dut->ap_osu_icon_tag == 2) |
| 2132 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 2133 | |
| 2134 | snprintf(hs20_icon, sizeof(hs20_icon), |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2135 | "'160:76:eng:image/png:icon_green_eng.png:/etc/ath/%s'", |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2136 | hs20_icon_filename); |
| 2137 | owrt_ap_set_list_vap(dut, vap_id, "hs20_icon", |
| 2138 | hs20_icon); |
| 2139 | |
| 2140 | owrt_ap_set_list_vap(dut, vap_id, "osu_icon", |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2141 | "'icon_green_eng.png'"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2142 | osu_friendly_name = "'kor:SP 오렌지 테스트 전용'"; |
| 2143 | |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2144 | hs20_icon_filename = "icon_green_zxx.png"; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2145 | if (dut->ap_osu_icon_tag == 2) |
| 2146 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 2147 | |
| 2148 | snprintf(hs20_icon, sizeof(hs20_icon), |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2149 | "'128:61:zxx:image/png:icon_green_zxx.png:/etc/ath/%s'", |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2150 | hs20_icon_filename); |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2151 | osu_icon = "icon_green_zxx.png"; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2152 | break; |
| 2153 | case 8: |
| 2154 | case 108: |
| 2155 | owrt_ap_set_list_vap(dut, vap_id, "osu_friendly_name", |
| 2156 | "'eng:SP Red Test Only'"); |
| 2157 | owrt_ap_set_list_vap(dut, vap_id, "osu_service_desc", |
| 2158 | "'eng:Free service for test purpose'"); |
| 2159 | osu_ssid = "OSU-Encrypted"; |
| 2160 | osu_nai = "'anonymous@hotspot.net'"; |
| 2161 | break; |
| 2162 | case 9: |
| 2163 | case 109: |
| 2164 | osu_ssid = "OSU-OSEN"; |
| 2165 | osu_nai = "'test-anonymous@wi-fi.org'"; |
| 2166 | osu_friendly_name = "'eng:SP Orange Test Only'"; |
| 2167 | hs20_icon_filename = "icon_orange_zxx.png"; |
| 2168 | if (dut->ap_osu_icon_tag == 2) |
| 2169 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 2170 | |
| 2171 | snprintf(hs20_icon, sizeof(hs20_icon), |
| 2172 | "'128:61:zxx:image/png:icon_orange_zxx.png:/etc/ath/%s'", |
| 2173 | hs20_icon_filename); |
| 2174 | osu_icon = "icon_orange_zxx.png"; |
| 2175 | osu_method = (dut->ap_osu_method[0] == 0xFF) ? 1 : |
| 2176 | dut->ap_osu_method[0]; |
| 2177 | osu_service_desc = NULL; |
| 2178 | break; |
| 2179 | default: |
| 2180 | break; |
| 2181 | } |
| 2182 | |
| 2183 | if (strlen(dut->ap_osu_ssid)) { |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 2184 | if (strcmp(dut->ap_tag_ssid[0], |
| 2185 | dut->ap_osu_ssid) != 0 && |
| 2186 | strcmp(dut->ap_tag_ssid[0], osu_ssid) != 0) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2187 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 2188 | "OSU_SSID and WLAN_TAG2 SSID differ"); |
| 2189 | return -2; |
| 2190 | } |
| 2191 | |
| 2192 | snprintf(buf, sizeof(buf), "'\"%s\"'", |
| 2193 | dut->ap_osu_ssid); |
| 2194 | } else { |
| 2195 | snprintf(buf, sizeof(buf), "'\"%s\"'", osu_ssid); |
| 2196 | } |
| 2197 | |
| 2198 | owrt_ap_set_vap(dut, vap_id, "osu_ssid", buf); |
| 2199 | |
| 2200 | |
| 2201 | if (osu_friendly_name) |
| 2202 | owrt_ap_set_list_vap(dut, vap_id, "osu_friendly_name", |
| 2203 | osu_friendly_name); |
| 2204 | if (osu_service_desc) |
| 2205 | owrt_ap_set_list_vap(dut, vap_id, "osu_service_desc", |
| 2206 | osu_service_desc); |
| 2207 | if (osu_nai) |
| 2208 | owrt_ap_set_vap(dut, vap_id, "osu_nai", osu_nai); |
| 2209 | |
| 2210 | owrt_ap_set_list_vap(dut, vap_id, "hs20_icon", hs20_icon); |
| 2211 | |
| 2212 | if (osu_icon) |
| 2213 | owrt_ap_set_list_vap(dut, vap_id, "osu_icon", |
| 2214 | osu_icon); |
| 2215 | |
| 2216 | if (dut->ap_osu_provider_list > 100) { |
| 2217 | owrt_ap_set_list_vap(dut, vap_id, "osu_method_list", |
| 2218 | "0"); |
| 2219 | } else { |
| 2220 | snprintf(buf, sizeof(buf), "%d", osu_method); |
| 2221 | owrt_ap_set_list_vap(dut, vap_id, "osu_method_list", |
| 2222 | buf); |
| 2223 | } |
| 2224 | } |
| 2225 | |
| 2226 | return 0; |
| 2227 | } |
| 2228 | |
| 2229 | |
Adil Saeed Musthafa | a8d7484 | 2017-04-10 23:13:39 -0700 | [diff] [blame] | 2230 | static void set_anqp_elem_value(struct sigma_dut *dut, const char *ifname, |
| 2231 | char *anqp_string, size_t str_size) |
| 2232 | { |
| 2233 | unsigned char bssid[ETH_ALEN]; |
| 2234 | unsigned char dummy_mac[] = { 0x00, 0x10, 0x20, 0x30, 0x40, 0x50 }; |
| 2235 | int preference = 0xff; |
| 2236 | |
| 2237 | get_hwaddr(ifname, bssid); |
| 2238 | snprintf(anqp_string, str_size, |
| 2239 | "272:3410%02x%02x%02x%02x%02x%02xf70000007330000301%02x3410%02x%02x%02x%02x%02x%02xf70000007330000301%02x", |
| 2240 | bssid[0], bssid[1], bssid[2], bssid[3], bssid[4], bssid[5], |
| 2241 | preference, |
| 2242 | dummy_mac[0], dummy_mac[1], dummy_mac[2], |
| 2243 | dummy_mac[3], dummy_mac[4], dummy_mac[5], |
| 2244 | preference - 1); |
| 2245 | } |
| 2246 | |
| 2247 | |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 2248 | static void get_if_name(struct sigma_dut *dut, char *ifname_str, |
| 2249 | size_t str_size, int wlan_tag) |
| 2250 | { |
| 2251 | char *ifname; |
| 2252 | enum driver_type drv; |
| 2253 | |
| 2254 | drv = get_driver_type(); |
| 2255 | if (drv == DRIVER_ATHEROS) { |
| 2256 | if ((dut->ap_mode == AP_11a || dut->ap_mode == AP_11na || |
| 2257 | dut->ap_mode == AP_11ac) && |
| 2258 | if_nametoindex("ath1") > 0) |
| 2259 | ifname = "ath1"; |
| 2260 | else |
| 2261 | ifname = "ath0"; |
| 2262 | } else if (drv == DRIVER_OPENWRT) { |
| 2263 | if (sigma_radio_ifname[0] && |
| 2264 | strcmp(sigma_radio_ifname[0], "wifi2") == 0) |
| 2265 | ifname = "ath2"; |
| 2266 | else if (sigma_radio_ifname[0] && |
| 2267 | strcmp(sigma_radio_ifname[0], "wifi1") == 0) |
| 2268 | ifname = "ath1"; |
| 2269 | else |
| 2270 | ifname = "ath0"; |
| 2271 | } else { |
| 2272 | if ((dut->ap_mode == AP_11a || dut->ap_mode == AP_11na || |
| 2273 | dut->ap_mode == AP_11ac) && |
| 2274 | if_nametoindex("wlan1") > 0) |
| 2275 | ifname = "wlan1"; |
| 2276 | else |
| 2277 | ifname = "wlan0"; |
| 2278 | } |
| 2279 | |
| 2280 | if (drv == DRIVER_OPENWRT && wlan_tag > 1) { |
| 2281 | /* Handle tagged-ifname only on OPENWRT for now */ |
| 2282 | snprintf(ifname_str, str_size, "%s%d", ifname, wlan_tag - 1); |
| 2283 | } else { |
| 2284 | snprintf(ifname_str, str_size, "%s", ifname); |
| 2285 | } |
| 2286 | } |
| 2287 | |
| 2288 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2289 | static int owrt_ap_config_vap(struct sigma_dut *dut) |
| 2290 | { |
| 2291 | char buf[256], *temp; |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 2292 | int vap_id = 0, vap_count, i, j; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2293 | |
| 2294 | 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] | 2295 | snprintf(buf, sizeof(buf), "wifi%d", vap_count); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2296 | |
| 2297 | for (vap_id = 0; vap_id < MAX_RADIO; vap_id++) { |
| 2298 | if (sigma_radio_ifname[vap_id] && |
| 2299 | strcmp(sigma_radio_ifname[vap_id], buf) == 0) |
| 2300 | break; |
| 2301 | } |
| 2302 | if (vap_id == MAX_RADIO) |
| 2303 | continue; |
| 2304 | |
| 2305 | /* Single VAP configuration */ |
| 2306 | if (!dut->ap_is_dual) |
| 2307 | vap_id = vap_count; |
| 2308 | |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 2309 | for (j = 0; j < MAX_WLAN_TAGS - 1; j++) { |
| 2310 | /* |
| 2311 | * We keep a separate array of ap_tag_ssid and |
| 2312 | * ap_tag_key_mgmt for tags starting from WLAN_TAG=2. |
| 2313 | * So j=0 => WLAN_TAG = 2 |
| 2314 | */ |
| 2315 | int wlan_tag = j + 2; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2316 | |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 2317 | if (dut->ap_tag_ssid[j][0] == '\0') |
| 2318 | continue; |
| 2319 | |
| 2320 | snprintf(buf, sizeof(buf), "%s%d", "wifi", vap_count); |
| 2321 | owrt_ap_add_vap(dut, vap_count + (wlan_tag - 1), |
| 2322 | "device", buf); |
| 2323 | /* SSID */ |
| 2324 | snprintf(buf, sizeof(buf), "\"%s\"", |
| 2325 | dut->ap_tag_ssid[j]); |
| 2326 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), |
| 2327 | "ssid", buf); |
| 2328 | |
| 2329 | if (dut->ap_tag_key_mgmt[j] == AP2_OSEN && |
| 2330 | wlan_tag == 2) { |
| 2331 | /* Only supported for WLAN_TAG=2 */ |
| 2332 | owrt_ap_set_vap(dut, vap_count + 1, "osen", |
| 2333 | "1"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2334 | snprintf(buf, sizeof(buf), "wpa2"); |
| 2335 | owrt_ap_set_vap(dut, vap_count + 1, |
| 2336 | "encryption", buf); |
| 2337 | snprintf(buf, sizeof(buf), "%s", |
| 2338 | dut->ap2_radius_ipaddr); |
| 2339 | owrt_ap_set_vap(dut, vap_count + 1, |
| 2340 | "auth_server", buf); |
| 2341 | snprintf(buf, sizeof(buf), "%d", |
| 2342 | dut->ap2_radius_port); |
| 2343 | owrt_ap_set_vap(dut, vap_count + 1, |
| 2344 | "auth_port", buf); |
| 2345 | snprintf(buf, sizeof(buf), "%s", |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 2346 | dut->ap2_radius_password); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2347 | owrt_ap_set_vap(dut, vap_count + 1, |
| 2348 | "auth_secret", buf); |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 2349 | } else if (dut->ap_tag_key_mgmt[j] == AP2_WPA2_PSK) { |
| 2350 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), |
| 2351 | "encryption", "psk2+ccmp"); |
| 2352 | snprintf(buf, sizeof(buf), "\"%s\"", |
| 2353 | dut->ap_passphrase); |
| 2354 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), |
| 2355 | "key", buf); |
| 2356 | snprintf(buf, sizeof(buf), "%d", dut->ap_pmf); |
| 2357 | owrt_ap_set_vap(dut, vap_count + 1, |
| 2358 | "ieee80211w", buf); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2359 | } |
| 2360 | } |
| 2361 | |
Adil Saeed Musthafa | a8d7484 | 2017-04-10 23:13:39 -0700 | [diff] [blame] | 2362 | /* Now set anqp_elem for wlan_tag = 1 */ |
| 2363 | if (dut->program == PROGRAM_MBO && |
| 2364 | get_driver_type() == DRIVER_OPENWRT) { |
| 2365 | char anqp_string[200]; |
| 2366 | |
| 2367 | set_anqp_elem_value(dut, sigma_radio_ifname[0], |
| 2368 | anqp_string, sizeof(anqp_string)); |
| 2369 | owrt_ap_set_list_vap(dut, vap_count, "anqp_elem", |
| 2370 | anqp_string); |
| 2371 | } |
| 2372 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2373 | /* SSID */ |
| 2374 | snprintf(buf, sizeof(buf), "\"%s\"", dut->ap_ssid); |
| 2375 | owrt_ap_set_vap(dut, vap_count, "ssid", buf); |
| 2376 | |
| 2377 | /* Encryption */ |
| 2378 | switch (dut->ap_key_mgmt) { |
| 2379 | case AP_OPEN: |
| 2380 | if (dut->ap_cipher == AP_WEP) { |
| 2381 | owrt_ap_set_vap(dut, vap_count, "encryption", |
| 2382 | "wep-mixed"); |
| 2383 | owrt_ap_set_vap(dut, vap_count, "key", |
| 2384 | dut->ap_wepkey); |
| 2385 | } else { |
| 2386 | owrt_ap_set_vap(dut, vap_count, "encryption", |
| 2387 | "none"); |
| 2388 | } |
| 2389 | break; |
| 2390 | case AP_WPA2_PSK: |
| 2391 | case AP_WPA2_PSK_MIXED: |
| 2392 | case AP_WPA_PSK: |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 2393 | case AP_WPA2_SAE: |
| 2394 | case AP_WPA2_PSK_SAE: |
| 2395 | /* TODO: SAE configuration */ |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2396 | if (dut->ap_key_mgmt == AP_WPA2_PSK) { |
| 2397 | snprintf(buf, sizeof(buf), "psk2"); |
| 2398 | } else if (dut->ap_key_mgmt == AP_WPA2_PSK_MIXED) { |
| 2399 | snprintf(buf, sizeof(buf), "psk-mixed"); |
| 2400 | } else { |
| 2401 | snprintf(buf, sizeof(buf), "psk"); |
| 2402 | } |
| 2403 | |
Peng Xu | 591be45 | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 2404 | if (dut->ap_cipher == AP_CCMP_TKIP) |
| 2405 | strlcat(buf, "+ccmp+tkip", sizeof(buf)); |
| 2406 | else if (dut->ap_cipher == AP_TKIP) |
| 2407 | strlcat(buf, "+tkip", sizeof(buf)); |
| 2408 | else |
| 2409 | strlcat(buf, "+ccmp", sizeof(buf)); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2410 | |
| 2411 | owrt_ap_set_vap(dut, vap_count, "encryption", buf); |
| 2412 | snprintf(buf, sizeof(buf), "\"%s\"", |
| 2413 | dut->ap_passphrase); |
| 2414 | owrt_ap_set_vap(dut, vap_count, "key", buf); |
| 2415 | break; |
| 2416 | case AP_WPA2_EAP: |
| 2417 | case AP_WPA2_EAP_MIXED: |
| 2418 | case AP_WPA_EAP: |
| 2419 | if (dut->ap_key_mgmt == AP_WPA2_EAP) { |
| 2420 | snprintf(buf, sizeof(buf), "wpa2"); |
| 2421 | } else if (dut->ap_key_mgmt == AP_WPA2_EAP_MIXED) { |
| 2422 | snprintf(buf, sizeof(buf), "wpa-mixed"); |
| 2423 | } else { |
| 2424 | snprintf(buf, sizeof(buf), "wpa"); |
| 2425 | } |
| 2426 | |
Peng Xu | 591be45 | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 2427 | if (dut->ap_cipher == AP_CCMP_TKIP) |
| 2428 | strlcat(buf, "+ccmp+tkip", sizeof(buf)); |
| 2429 | else if (dut->ap_cipher == AP_TKIP) |
| 2430 | strlcat(buf, "+tkip", sizeof(buf)); |
| 2431 | else |
| 2432 | strlcat(buf, "+ccmp", sizeof(buf)); |
| 2433 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2434 | owrt_ap_set_vap(dut, vap_count, "encryption", buf); |
| 2435 | snprintf(buf, sizeof(buf), "%s", dut->ap_radius_ipaddr); |
| 2436 | owrt_ap_set_vap(dut, vap_count, "auth_server", buf); |
| 2437 | snprintf(buf, sizeof(buf), "%d", dut->ap_radius_port); |
| 2438 | owrt_ap_set_vap(dut, vap_count, "auth_port", buf); |
| 2439 | snprintf(buf, sizeof(buf), "%s", |
| 2440 | dut->ap_radius_password); |
| 2441 | owrt_ap_set_vap(dut, vap_count, "auth_secret", buf); |
| 2442 | break; |
Jouni Malinen | ad395a2 | 2017-09-01 21:13:46 +0300 | [diff] [blame] | 2443 | case AP_SUITEB: |
| 2444 | /* TODO */ |
| 2445 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 2446 | "SuiteB not supported"); |
| 2447 | break; |
Jouni Malinen | 147b3c3 | 2017-10-09 16:51:54 +0300 | [diff] [blame] | 2448 | case AP_WPA2_OWE: |
| 2449 | /* TODO */ |
| 2450 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 2451 | "OWE not supported"); |
| 2452 | break; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2453 | } |
| 2454 | |
| 2455 | if (!dut->ap_is_dual) |
| 2456 | break; |
| 2457 | } |
| 2458 | |
| 2459 | if (dut->ap_is_dual) |
| 2460 | return 1; |
| 2461 | |
| 2462 | /* PMF */ |
| 2463 | snprintf(buf, sizeof(buf), "%d", dut->ap_pmf); |
| 2464 | owrt_ap_set_vap(dut, vap_id, "ieee80211w", buf); |
| 2465 | |
| 2466 | /* Add SHA256 */ |
| 2467 | snprintf(buf, sizeof(buf), "%d", dut->ap_add_sha256); |
| 2468 | owrt_ap_set_vap(dut, vap_id, "add_sha256", buf); |
| 2469 | |
Sarvepalli, Rajesh Babu | 24dc7e4 | 2016-03-18 21:27:26 +0530 | [diff] [blame] | 2470 | /* Enable RSN preauthentication, if asked to */ |
| 2471 | snprintf(buf, sizeof(buf), "%d", dut->ap_rsn_preauth); |
| 2472 | owrt_ap_set_vap(dut, vap_id, "rsn_preauth", buf); |
| 2473 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2474 | /* Hotspot 2.0 */ |
| 2475 | if (dut->ap_hs2) { |
| 2476 | int ret; |
| 2477 | |
| 2478 | ret = owrt_ap_config_vap_hs2(dut, vap_id); |
| 2479 | if (ret) |
| 2480 | return ret; |
| 2481 | } |
| 2482 | |
| 2483 | /* Interworking */ |
| 2484 | if (dut->ap_interworking) { |
| 2485 | snprintf(buf, sizeof(buf), "%d", dut->ap_access_net_type); |
| 2486 | owrt_ap_set_vap(dut, vap_id, "access_network_type", buf); |
| 2487 | snprintf(buf, sizeof(buf), "%d", dut->ap_internet); |
| 2488 | owrt_ap_set_vap(dut, vap_id, "internet", buf); |
| 2489 | snprintf(buf, sizeof(buf), "%d", dut->ap_venue_group); |
| 2490 | owrt_ap_set_vap(dut, vap_id, "venue_group", buf); |
| 2491 | snprintf(buf, sizeof(buf), "%d", dut->ap_venue_type); |
| 2492 | owrt_ap_set_vap(dut, vap_id, "venue_type", buf); |
| 2493 | snprintf(buf, sizeof(buf), "%s", dut->ap_hessid); |
| 2494 | owrt_ap_set_vap(dut, vap_id, "hessid", buf); |
| 2495 | |
| 2496 | if (dut->ap_gas_cb_delay > 0) { |
| 2497 | snprintf(buf, sizeof(buf), "%d", dut->ap_gas_cb_delay); |
| 2498 | owrt_ap_set_vap(dut, vap_id, "gas_comeback_delay", buf); |
| 2499 | } |
| 2500 | |
| 2501 | if (dut->ap_roaming_cons[0]) { |
| 2502 | char *rcons, *temp_ptr; |
| 2503 | |
| 2504 | rcons = strdup(dut->ap_roaming_cons); |
| 2505 | if (rcons == NULL) |
| 2506 | return 0; |
| 2507 | |
| 2508 | temp_ptr = strchr(rcons, ';'); |
| 2509 | |
| 2510 | if (temp_ptr) |
| 2511 | *temp_ptr++ = '\0'; |
| 2512 | |
| 2513 | owrt_ap_set_list_vap(dut, vap_id, "roaming_consortium", |
| 2514 | rcons); |
| 2515 | |
| 2516 | if (temp_ptr) |
| 2517 | owrt_ap_set_list_vap(dut, vap_id, |
| 2518 | "roaming_consortium", |
| 2519 | temp_ptr); |
| 2520 | |
| 2521 | free(rcons); |
| 2522 | } |
| 2523 | } |
| 2524 | |
| 2525 | if (dut->ap_venue_name) { |
| 2526 | owrt_ap_set_list_vap(dut, vap_id, "venue_name", |
| 2527 | "'P\"eng:Wi-Fi Alliance\\n2989 Copper Road\\nSanta Clara, CA 95051, USA\"'"); |
| 2528 | owrt_ap_set_list_vap(dut, vap_id, "venue_name", |
| 2529 | "\'"ANQP_VENUE_NAME_1_CHI"\'"); |
| 2530 | } |
| 2531 | |
| 2532 | if (dut->ap_net_auth_type == 1) { |
| 2533 | owrt_ap_set_vap(dut, vap_id, "network_auth_type", |
| 2534 | "'00https://tandc-server.wi-fi.org'"); |
| 2535 | } else if (dut->ap_net_auth_type == 2) { |
| 2536 | owrt_ap_set_vap(dut, vap_id, "network_auth_type", "'01'"); |
| 2537 | } |
| 2538 | |
| 2539 | if (dut->ap_nai_realm_list == 1) { |
| 2540 | owrt_ap_set_list_vap(dut, vap_id, "nai_realm", |
| 2541 | "'0,mail.example.com;cisco.com;wi-fi.org,21[2:4][5:7]'"); |
| 2542 | owrt_ap_set_list_vap(dut, vap_id, "nai_realm", |
| 2543 | "'0,wi-fi.org;example.com,13[5:6]'"); |
| 2544 | |
| 2545 | } else if (dut->ap_nai_realm_list == 2) { |
| 2546 | owrt_ap_set_list_vap(dut, vap_id, "nai_realm", |
| 2547 | "'0,wi-fi.org,21[2:4][5:7]'"); |
| 2548 | } else if (dut->ap_nai_realm_list == 3) { |
| 2549 | owrt_ap_set_list_vap(dut, vap_id, "nai_realm", |
| 2550 | "'0,cisco.com;wi-fi.org,21[2:4][5:7]'"); |
| 2551 | owrt_ap_set_list_vap(dut, vap_id, "nai_realm", |
| 2552 | "'0,wi-fi.org;example.com,13[5:6]'"); |
| 2553 | } else if (dut->ap_nai_realm_list == 4) { |
| 2554 | owrt_ap_set_list_vap(dut, vap_id, "nai_realm", |
| 2555 | "'0,mail.example.com,21[2:4][5:7],13[5:6]'"); |
| 2556 | } else if (dut->ap_nai_realm_list == 5) { |
| 2557 | owrt_ap_set_list_vap(dut, vap_id, "nai_realm", |
| 2558 | "'0,wi-fi.org;ruckuswireless.com,21[2:4][5:7]'"); |
| 2559 | } else if (dut->ap_nai_realm_list == 6) { |
| 2560 | owrt_ap_set_list_vap(dut, vap_id, "nai_realm", |
| 2561 | "'0,wi-fi.org;mail.example.com,21[2:4][5:7]'"); |
| 2562 | } else if (dut->ap_nai_realm_list == 7) { |
| 2563 | owrt_ap_set_list_vap(dut, vap_id, "nai_realm", |
| 2564 | "'0,wi-fi.org,13[5:6]'"); |
| 2565 | owrt_ap_set_list_vap(dut, vap_id, "nai_realm", |
| 2566 | "'0,wi-fi.org,21[2:4][5:7]'"); |
| 2567 | } |
| 2568 | |
| 2569 | if (dut->ap_domain_name_list[0]) |
| 2570 | owrt_ap_set_list_vap(dut, vap_id, "domain_name", |
| 2571 | dut->ap_domain_name_list); |
| 2572 | |
| 2573 | if (dut->ap_ip_addr_type_avail) |
| 2574 | owrt_ap_set_vap(dut, vap_id, "ipaddr_type_availability", |
| 2575 | "'0c'"); |
| 2576 | |
| 2577 | temp = buf; |
| 2578 | |
| 2579 | *temp++ = '\''; |
| 2580 | |
| 2581 | for (i = 0; dut->ap_plmn_mcc[i][0] && dut->ap_plmn_mnc[i][0]; i++) { |
| 2582 | if (i) |
| 2583 | *temp++ = ';'; |
| 2584 | |
| 2585 | snprintf(temp, |
| 2586 | sizeof(dut->ap_plmn_mcc[i]) + |
| 2587 | sizeof(dut->ap_plmn_mnc[i]) + 1, |
| 2588 | "%s,%s", |
| 2589 | dut->ap_plmn_mcc[i], |
| 2590 | dut->ap_plmn_mnc[i]); |
| 2591 | |
| 2592 | temp += strlen(dut->ap_plmn_mcc[i]) + |
| 2593 | strlen(dut->ap_plmn_mnc[i]) + 1; |
| 2594 | } |
| 2595 | |
| 2596 | *temp++ = '\''; |
| 2597 | *temp++ = '\0'; |
| 2598 | |
| 2599 | if (i) |
| 2600 | owrt_ap_set_vap(dut, vap_id, "anqp_3gpp_cell_net", buf); |
| 2601 | |
| 2602 | if (dut->ap_qos_map_set == 1) |
| 2603 | owrt_ap_set_vap(dut, vap_id, "qos_map_set", QOS_MAP_SET_1); |
| 2604 | else if (dut->ap_qos_map_set == 2) |
| 2605 | owrt_ap_set_vap(dut, vap_id, "qos_map_set", QOS_MAP_SET_2); |
| 2606 | |
| 2607 | /* Proxy-ARP */ |
| 2608 | snprintf(buf, sizeof(buf), "%d", dut->ap_proxy_arp); |
| 2609 | owrt_ap_set_vap(dut, vap_id, "proxyarp", buf); |
| 2610 | |
| 2611 | /* DGAF */ |
| 2612 | snprintf(buf, sizeof(buf), "%d", dut->ap_dgaf_disable); |
| 2613 | /* parse to hostapd */ |
| 2614 | owrt_ap_set_vap(dut, vap_id, "disable_dgaf", buf); |
| 2615 | /* parse to wifi driver */ |
| 2616 | owrt_ap_set_vap(dut, vap_id, "dgaf_disable", buf); |
| 2617 | |
| 2618 | /* HCBSSLoad */ |
| 2619 | if (dut->ap_bss_load) { |
| 2620 | unsigned int bssload = 0; |
| 2621 | |
| 2622 | if (dut->ap_bss_load == 1) { |
| 2623 | /* STA count: 1, CU: 50, AAC: 65535 */ |
| 2624 | bssload = 0x0132ffff; |
| 2625 | } else if (dut->ap_bss_load == 2) { |
| 2626 | /* STA count: 1, CU: 200, AAC: 65535 */ |
| 2627 | bssload = 0x01c8ffff; |
| 2628 | } else if (dut->ap_bss_load == 3) { |
| 2629 | /* STA count: 1, CU: 75, AAC: 65535 */ |
| 2630 | bssload = 0x014bffff; |
| 2631 | } |
| 2632 | |
| 2633 | snprintf(buf, sizeof(buf), "%d", bssload); |
| 2634 | owrt_ap_set_vap(dut, vap_id, "hcbssload", buf); |
| 2635 | } |
| 2636 | |
| 2637 | /* L2TIF */ |
| 2638 | if (dut->ap_l2tif) |
| 2639 | owrt_ap_set_vap(dut, vap_id, "l2tif", "1"); |
| 2640 | |
| 2641 | if (dut->ap_disable_protection == 1) |
| 2642 | owrt_ap_set_vap(dut, vap_id, "enablertscts", "0"); |
| 2643 | |
Sunil Dutt | 77b213d | 2017-09-14 18:24:40 +0300 | [diff] [blame] | 2644 | if (dut->ap_txBF) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2645 | owrt_ap_set_vap(dut, vap_id, "vhtsubfee", "1"); |
| 2646 | owrt_ap_set_vap(dut, vap_id, "vhtsubfer", "1"); |
| 2647 | } |
| 2648 | |
Mohammed Shafi Shajakhan | 061af00 | 2016-06-02 20:10:54 +0530 | [diff] [blame] | 2649 | if (dut->ap_mu_txBF) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2650 | owrt_ap_set_vap(dut, vap_id, "vhtmubfer", "1"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2651 | |
Vasanthakumar Pandurangan | 2b5431d | 2016-01-12 15:52:48 +0530 | [diff] [blame] | 2652 | if (dut->ap_tx_stbc) { |
| 2653 | /* STBC and beamforming are mutually exclusive features */ |
| 2654 | owrt_ap_set_vap(dut, vap_id, "implicitbf", "0"); |
| 2655 | } |
| 2656 | |
Priyadharshini Gowthaman | 8fb1504 | 2015-11-25 18:27:41 +0530 | [diff] [blame] | 2657 | /* enable dfsmode */ |
| 2658 | snprintf(buf, sizeof(buf), "%d", dut->ap_dfs_mode); |
| 2659 | owrt_ap_set_vap(dut, vap_id, "doth", buf); |
| 2660 | |
priyadharshini gowthaman | 2323d0a | 2016-09-02 15:48:02 -0700 | [diff] [blame] | 2661 | if (dut->program == PROGRAM_LOC && dut->ap_interworking) { |
| 2662 | char anqpval[1024]; |
| 2663 | |
| 2664 | owrt_ap_set_vap(dut, vap_id, "interworking", "1"); |
| 2665 | |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 2666 | 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] | 2667 | snprintf(anqpval, sizeof(anqpval), |
| 2668 | "'265:0010%s%s060101'", |
priyadharshini gowthaman | 2323d0a | 2016-09-02 15:48:02 -0700 | [diff] [blame] | 2669 | dut->ap_val_lci, dut->ap_infoz); |
| 2670 | owrt_ap_set_list_vap(dut, vap_id, "anqp_elem", anqpval); |
| 2671 | } |
| 2672 | |
| 2673 | if (dut->ap_lcr == 1) { |
Pradeep Reddy Potteti | b48012a | 2016-11-28 16:58:54 +0530 | [diff] [blame] | 2674 | snprintf(anqpval, sizeof(anqpval), |
| 2675 | "'266:0000b2555302ae%s'", |
priyadharshini gowthaman | 2323d0a | 2016-09-02 15:48:02 -0700 | [diff] [blame] | 2676 | dut->ap_val_lcr); |
| 2677 | owrt_ap_set_list_vap(dut, vap_id, "anqp_elem", anqpval); |
| 2678 | } |
| 2679 | |
| 2680 | if (dut->ap_fqdn_held == 1 && dut->ap_fqdn_supl == 1) |
| 2681 | owrt_ap_set_list_vap(dut, vap_id, "anqp_elem", |
| 2682 | "'267:00110168656c642e6578616d706c652e636f6d0011027375706c2e6578616d706c652e636f6d'"); |
| 2683 | } |
| 2684 | |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 2685 | if (dut->program == PROGRAM_MBO) { |
| 2686 | owrt_ap_set_vap(dut, vap_id, "interworking", "1"); |
| 2687 | owrt_ap_set_vap(dut, vap_id, "mbo", "1"); |
| 2688 | owrt_ap_set_vap(dut, vap_id, "rrm", "1"); |
Adil Saeed Musthafa | 65160c0 | 2017-04-10 23:13:38 -0700 | [diff] [blame] | 2689 | owrt_ap_set_vap(dut, vap_id, "mbo_cell_conn_pref", "1"); |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 2690 | |
| 2691 | owrt_ap_set_list_vap(dut, vap_id, "anqp_elem", |
| 2692 | "'272:34108cfdf0020df1f7000000733000030101'"); |
Adil Saeed Musthafa | ed5faae | 2017-04-10 23:13:36 -0700 | [diff] [blame] | 2693 | snprintf(buf, sizeof(buf), "%d", dut->ap_gas_cb_delay); |
| 2694 | owrt_ap_set_vap(dut, vap_id, "gas_comeback_delay", buf); |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 2695 | } |
| 2696 | |
Adil Saeed Musthafa | 4ec61bd | 2017-04-10 23:13:41 -0700 | [diff] [blame] | 2697 | if (dut->ap_ft_oa == 1) { |
| 2698 | unsigned char self_mac[ETH_ALEN]; |
| 2699 | char mac_str[20]; |
| 2700 | |
| 2701 | owrt_ap_set_vap(dut, vap_id, "ft_over_ds", "0"); |
| 2702 | owrt_ap_set_vap(dut, vap_id, "ieee80211r", "1"); |
| 2703 | get_hwaddr(sigma_radio_ifname[0], self_mac); |
| 2704 | snprintf(mac_str, sizeof(mac_str), |
| 2705 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 2706 | self_mac[0], self_mac[1], self_mac[2], |
| 2707 | self_mac[3], self_mac[4], self_mac[5]); |
| 2708 | owrt_ap_set_vap(dut, vap_id, "ap_macaddr", mac_str); |
| 2709 | owrt_ap_set_vap(dut, vap_id, "ft_psk_generate_local", "1"); |
| 2710 | owrt_ap_set_vap(dut, vap_id, "kh_key_hex", |
| 2711 | "000102030405060708090a0b0c0d0e0f"); |
| 2712 | snprintf(mac_str, sizeof(mac_str), |
| 2713 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 2714 | dut->ft_bss_mac_list[0][0], |
| 2715 | dut->ft_bss_mac_list[0][1], |
| 2716 | dut->ft_bss_mac_list[0][2], |
| 2717 | dut->ft_bss_mac_list[0][3], |
| 2718 | dut->ft_bss_mac_list[0][4], |
| 2719 | dut->ft_bss_mac_list[0][5]); |
| 2720 | owrt_ap_set_vap(dut, vap_id, "ap2_macaddr", mac_str); |
| 2721 | } |
| 2722 | |
| 2723 | if ((dut->ap_ft_oa == 1 && dut->ap_name == 0) || |
| 2724 | (dut->ap_ft_oa == 1 && dut->ap_name == 2)) { |
| 2725 | owrt_ap_set_vap(dut, vap_id, "ap2_r1_key_holder", |
| 2726 | "00:01:02:03:04:06"); |
| 2727 | owrt_ap_set_vap(dut, vap_id, "nasid2", "nas2.example.com"); |
| 2728 | owrt_ap_set_vap(dut, vap_id, "nasid", "nas1.example.com"); |
| 2729 | owrt_ap_set_vap(dut, vap_id, "r1_key_holder", "000102030405"); |
| 2730 | } |
| 2731 | |
| 2732 | if (dut->ap_ft_oa == 1 && dut->ap_name == 1) { |
| 2733 | owrt_ap_set_vap(dut, vap_id, "ap2_r1_key_holder", |
| 2734 | "00:01:02:03:04:05"); |
| 2735 | owrt_ap_set_vap(dut, vap_id, "nasid2", "nas1.example.com"); |
| 2736 | owrt_ap_set_vap(dut, vap_id, "nasid", "nas2.example.com"); |
| 2737 | owrt_ap_set_vap(dut, vap_id, "r1_key_holder", "000102030406"); |
| 2738 | } |
| 2739 | |
Adil Saeed Musthafa | cf752fa | 2017-04-10 23:13:32 -0700 | [diff] [blame] | 2740 | if (dut->ap_mobility_domain[0]) |
| 2741 | owrt_ap_set_vap(dut, vap_id, "mobility_domain", |
| 2742 | dut->ap_mobility_domain); |
| 2743 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2744 | return 1; |
| 2745 | } |
| 2746 | |
| 2747 | |
priyadharshini gowthaman | 2500f20 | 2016-10-13 17:13:55 -0700 | [diff] [blame] | 2748 | static int owrt_ap_config_vap_anqp(struct sigma_dut *dut) |
| 2749 | { |
| 2750 | char anqpval[1024]; |
| 2751 | unsigned char addr[6]; |
| 2752 | unsigned char addr2[6]; |
| 2753 | struct ifreq ifr; |
| 2754 | char *ifname; |
| 2755 | int s; |
| 2756 | int vap_id = 0; |
| 2757 | |
| 2758 | s = socket(AF_INET, SOCK_DGRAM, 0); |
| 2759 | if (s < 0) { |
| 2760 | sigma_dut_print(dut, DUT_MSG_ERROR, "Failed to open socket"); |
| 2761 | return -1; |
| 2762 | } |
| 2763 | |
| 2764 | memset(&ifr, 0, sizeof(ifr)); |
| 2765 | ifname = "ath0"; |
Peng Xu | b8fc5cc | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 2766 | strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name)); |
priyadharshini gowthaman | 2500f20 | 2016-10-13 17:13:55 -0700 | [diff] [blame] | 2767 | if (ioctl(s, SIOCGIFHWADDR, &ifr) < 0) { |
| 2768 | perror("ioctl"); |
| 2769 | close(s); |
| 2770 | return -1; |
| 2771 | } |
| 2772 | memcpy(addr, ifr.ifr_hwaddr.sa_data, 6); |
| 2773 | |
| 2774 | memset(&ifr, 0, sizeof(ifr)); |
| 2775 | ifname = "ath01"; |
Peng Xu | b8fc5cc | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 2776 | strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name)); |
priyadharshini gowthaman | 2500f20 | 2016-10-13 17:13:55 -0700 | [diff] [blame] | 2777 | if (ioctl(s, SIOCGIFHWADDR, &ifr) < 0) { |
| 2778 | perror("ioctl"); |
| 2779 | close(s); |
| 2780 | return -1; |
| 2781 | } |
| 2782 | close(s); |
| 2783 | memcpy(addr2, ifr.ifr_hwaddr.sa_data, 6); |
| 2784 | |
| 2785 | snprintf(anqpval, sizeof(anqpval), |
| 2786 | "'265:0010%s%s060101070d00%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x'", |
| 2787 | dut->ap_val_lci, dut->ap_infoz, |
| 2788 | addr[0], addr[1], addr[2], addr[3], addr[4], addr[5], |
| 2789 | addr2[0], addr2[1], addr2[2], addr2[3], addr2[4], addr2[5]); |
| 2790 | |
| 2791 | owrt_ap_set_list_vap(dut, vap_id, "anqp_elem", anqpval); |
| 2792 | return 0; |
| 2793 | } |
| 2794 | |
| 2795 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2796 | static int owrt_ap_post_config_commit(struct sigma_dut *dut, |
| 2797 | struct sigma_conn *conn, |
| 2798 | struct sigma_cmd *cmd) |
| 2799 | { |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 2800 | int ap_security = 0; |
| 2801 | int i; |
| 2802 | |
| 2803 | for (i = 0; i < MAX_WLAN_TAGS - 1; i++) { |
| 2804 | if (dut->ap_tag_key_mgmt[i] != AP2_OPEN) |
| 2805 | ap_security = 1; |
| 2806 | } |
| 2807 | if (dut->ap_key_mgmt != AP_OPEN) |
| 2808 | ap_security = 1; |
| 2809 | if (ap_security) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2810 | /* allow some time for hostapd to start before returning |
| 2811 | * success */ |
| 2812 | usleep(500000); |
| 2813 | |
| 2814 | if (run_hostapd_cli(dut, "ping") != 0) { |
| 2815 | send_resp(dut, conn, SIGMA_ERROR, |
| 2816 | "errorCode,Failed to talk to hostapd"); |
| 2817 | return 0; |
| 2818 | } |
| 2819 | } |
| 2820 | |
| 2821 | if (get_openwrt_driver_type() == OPENWRT_DRIVER_ATHEROS) |
| 2822 | ath_ap_set_params(dut); |
| 2823 | |
| 2824 | /* Send response */ |
| 2825 | return 1; |
| 2826 | } |
| 2827 | |
| 2828 | |
| 2829 | static int cmd_owrt_ap_config_commit(struct sigma_dut *dut, |
| 2830 | struct sigma_conn *conn, |
| 2831 | struct sigma_cmd *cmd) |
| 2832 | { |
| 2833 | /* Stop the AP */ |
| 2834 | run_system(dut, "wifi down"); |
| 2835 | |
| 2836 | /* Reset the wireless configuration */ |
Mohammed Shafi Shajakhan | f789f82 | 2016-04-07 18:53:16 +0530 | [diff] [blame] | 2837 | run_system(dut, "rm -rf /etc/config/wireless"); |
| 2838 | switch (get_openwrt_driver_type()) { |
| 2839 | case OPENWRT_DRIVER_ATHEROS: |
| 2840 | run_system(dut, "wifi detect qcawifi > /etc/config/wireless"); |
| 2841 | break; |
| 2842 | default: |
| 2843 | run_system(dut, "wifi detect > /etc/config/wireless"); |
| 2844 | break; |
| 2845 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2846 | |
| 2847 | /* Configure Radio & VAP, commit the config */ |
| 2848 | owrt_ap_config_radio(dut); |
| 2849 | owrt_ap_config_vap(dut); |
| 2850 | run_system(dut, "uci commit"); |
| 2851 | |
| 2852 | /* Start AP */ |
| 2853 | run_system(dut, "wifi up"); |
Adil Saeed Musthafa | a8d7484 | 2017-04-10 23:13:39 -0700 | [diff] [blame] | 2854 | if (dut->program != PROGRAM_MBO && |
| 2855 | dut->ap_lci == 1 && dut->ap_interworking && |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 2856 | strlen(dut->ap_tag_ssid[0]) > 0) { |
Adil Saeed Musthafa | a8d7484 | 2017-04-10 23:13:39 -0700 | [diff] [blame] | 2857 | /* |
| 2858 | * MBO has a different ANQP element value which is set in |
| 2859 | * owrt_ap_config_vap(). |
| 2860 | */ |
priyadharshini gowthaman | 2500f20 | 2016-10-13 17:13:55 -0700 | [diff] [blame] | 2861 | owrt_ap_config_vap_anqp(dut); |
| 2862 | run_system(dut, "uci commit"); |
| 2863 | run_system(dut, "wifi"); |
| 2864 | } |
| 2865 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2866 | return owrt_ap_post_config_commit(dut, conn, cmd); |
| 2867 | } |
| 2868 | |
| 2869 | |
| 2870 | static void cmd_owrt_ap_hs2_reset(struct sigma_dut *dut) |
| 2871 | { |
| 2872 | unsigned char bssid[6]; |
| 2873 | char buf[100]; |
| 2874 | char *ifname, *radio_name; |
| 2875 | int vap_id = 0; |
| 2876 | |
| 2877 | if (sigma_radio_ifname[0] && |
| 2878 | strcmp(sigma_radio_ifname[0], "wifi2") == 0) { |
| 2879 | ifname = "ath2"; |
| 2880 | radio_name = "wifi2"; |
| 2881 | vap_id = 2; |
| 2882 | } else if (sigma_radio_ifname[0] && |
| 2883 | strcmp(sigma_radio_ifname[0], "wifi1") == 0) { |
| 2884 | ifname = "ath1"; |
| 2885 | radio_name = "wifi1"; |
| 2886 | vap_id = 1; |
| 2887 | } else { |
| 2888 | ifname = "ath0"; |
| 2889 | radio_name = "wifi0"; |
| 2890 | vap_id = 0; |
| 2891 | } |
| 2892 | |
| 2893 | if (!get_hwaddr(ifname, bssid)) { |
| 2894 | snprintf(buf, sizeof(buf), "%s", bssid); |
| 2895 | owrt_ap_set_vap(dut, vap_id, "hessid", buf); |
| 2896 | snprintf(dut->ap_hessid, sizeof(dut->ap_hessid), |
| 2897 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 2898 | bssid[0], bssid[1], bssid[2], bssid[3], |
| 2899 | bssid[4], bssid[5]); |
| 2900 | } else { |
| 2901 | if (!get_hwaddr(radio_name, bssid)) { |
| 2902 | snprintf(buf, sizeof(buf), "%s", dut->ap_hessid); |
| 2903 | owrt_ap_set_vap(dut, vap_id, "hessid", buf); |
| 2904 | snprintf(dut->ap_hessid, sizeof(dut->ap_hessid), |
| 2905 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 2906 | bssid[0], bssid[1], bssid[2], bssid[3], |
| 2907 | bssid[4], bssid[5]); |
| 2908 | } else { |
| 2909 | /* Select & enable/disable radios */ |
| 2910 | if (sigma_radio_ifname[0] && |
| 2911 | strcmp(sigma_radio_ifname[0], "wifi2") == 0) { |
| 2912 | /* We want to use wifi2 */ |
| 2913 | owrt_ap_set_radio(dut, 0, "disabled", "1"); |
| 2914 | owrt_ap_set_radio(dut, 1, "disabled", "1"); |
| 2915 | owrt_ap_set_radio(dut, 2, "disabled", "0"); |
| 2916 | owrt_ap_set_vap(dut, vap_id, "device", "wifi2"); |
| 2917 | } else if (sigma_radio_ifname[0] && |
| 2918 | strcmp(sigma_radio_ifname[0], "wifi1") == 0) { |
| 2919 | /* We want to use wifi1 */ |
| 2920 | owrt_ap_set_radio(dut, 0, "disabled", "1"); |
| 2921 | owrt_ap_set_radio(dut, 1, "disabled", "0"); |
| 2922 | owrt_ap_set_vap(dut, vap_id, "device", "wifi1"); |
| 2923 | } else { |
| 2924 | /* We want to use wifi0 */ |
| 2925 | owrt_ap_set_radio(dut, 0, "disabled", "0"); |
| 2926 | owrt_ap_set_radio(dut, 1, "disabled", "1"); |
| 2927 | owrt_ap_set_vap(dut, vap_id, "device", "wifi0"); |
| 2928 | } |
| 2929 | |
| 2930 | run_system(dut, "uci commit"); |
| 2931 | run_system(dut, "wifi up"); |
| 2932 | |
| 2933 | if (!get_hwaddr(radio_name, bssid)) { |
| 2934 | snprintf(buf, sizeof(buf), "%s", |
| 2935 | dut->ap_hessid); |
| 2936 | owrt_ap_set_vap(dut, vap_id, "hessid", buf); |
| 2937 | snprintf(dut->ap_hessid, sizeof(dut->ap_hessid), |
| 2938 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 2939 | bssid[0], bssid[1], bssid[2], bssid[3], |
| 2940 | bssid[4], bssid[5]); |
| 2941 | } |
| 2942 | } |
| 2943 | } |
| 2944 | } |
| 2945 | |
| 2946 | |
| 2947 | static int cmd_ap_reboot(struct sigma_dut *dut, struct sigma_conn *conn, |
| 2948 | struct sigma_cmd *cmd) |
| 2949 | { |
| 2950 | switch (get_driver_type()) { |
| 2951 | case DRIVER_ATHEROS: |
| 2952 | run_system(dut, "apdown"); |
| 2953 | sleep(1); |
| 2954 | run_system(dut, "reboot"); |
| 2955 | break; |
| 2956 | case DRIVER_OPENWRT: |
| 2957 | run_system(dut, "wifi down"); |
| 2958 | sleep(1); |
| 2959 | run_system(dut, "reboot"); |
| 2960 | break; |
| 2961 | default: |
| 2962 | sigma_dut_print(dut, DUT_MSG_INFO, "Ignore ap_reboot command"); |
| 2963 | break; |
| 2964 | } |
| 2965 | |
| 2966 | return 1; |
| 2967 | } |
| 2968 | |
| 2969 | |
| 2970 | int ascii2hexstr(const char *str, char *hex) |
| 2971 | { |
| 2972 | int i, length; |
| 2973 | |
| 2974 | length = strlen(str); |
| 2975 | |
| 2976 | for (i = 0; i < length; i++) |
| 2977 | snprintf(hex + i * 2, 3, "%X", str[i]); |
| 2978 | |
| 2979 | hex[length * 2] = '\0'; |
| 2980 | return 1; |
| 2981 | } |
| 2982 | |
| 2983 | |
| 2984 | static int kill_process(struct sigma_dut *dut, char *proc_name, |
| 2985 | unsigned char is_proc_instance_one, int sig) |
| 2986 | { |
| 2987 | #ifdef __linux__ |
| 2988 | struct dirent *dp, *dp_in; |
| 2989 | const char *direc = "/proc/"; |
| 2990 | char buf[100]; |
| 2991 | DIR *dir = opendir(direc); |
| 2992 | DIR *dir_in; |
| 2993 | FILE *fp; |
| 2994 | char *pid, *temp; |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 2995 | char *saveptr; |
Pradeep Reddy Potteti | d068e64 | 2017-02-17 20:03:12 +0530 | [diff] [blame] | 2996 | int ret = -1; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2997 | |
| 2998 | if (dir == NULL) |
Pradeep Reddy Potteti | d068e64 | 2017-02-17 20:03:12 +0530 | [diff] [blame] | 2999 | return ret; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3000 | |
| 3001 | while ((dp = readdir(dir)) != NULL) { |
| 3002 | if (dp->d_type != DT_DIR) |
| 3003 | continue; |
| 3004 | |
| 3005 | snprintf(buf, sizeof(buf), "%s%s", direc, dp->d_name); |
| 3006 | dir_in = opendir(buf); |
| 3007 | if (dir_in == NULL) |
| 3008 | continue; |
| 3009 | dp_in = readdir(dir_in); |
| 3010 | closedir(dir_in); |
| 3011 | if (dp_in == NULL) |
| 3012 | continue; |
| 3013 | snprintf(buf, sizeof(buf), "%s%s/stat", direc, dp->d_name); |
| 3014 | fp = fopen(buf, "r"); |
| 3015 | if (fp == NULL) |
| 3016 | continue; |
| 3017 | if (fgets(buf, 100, fp) == NULL) |
| 3018 | buf[0] = '\0'; |
| 3019 | fclose(fp); |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 3020 | pid = strtok_r(buf, " ", &saveptr); |
| 3021 | temp = strtok_r(NULL, " ", &saveptr); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3022 | if (pid && temp && |
| 3023 | strncmp(temp, proc_name, strlen(proc_name)) == 0) { |
| 3024 | sigma_dut_print(dut, DUT_MSG_INFO, |
| 3025 | "killing %s process with PID %s", |
| 3026 | proc_name, pid); |
| 3027 | snprintf(buf, sizeof(buf), "kill -%d %d", sig, |
| 3028 | atoi(pid)); |
| 3029 | run_system(dut, buf); |
Pradeep Reddy Potteti | d068e64 | 2017-02-17 20:03:12 +0530 | [diff] [blame] | 3030 | ret = 0; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3031 | if (is_proc_instance_one) |
| 3032 | break; |
| 3033 | } |
| 3034 | } |
| 3035 | |
| 3036 | closedir(dir); |
| 3037 | |
Pradeep Reddy Potteti | d068e64 | 2017-02-17 20:03:12 +0530 | [diff] [blame] | 3038 | return ret; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3039 | #else /* __linux__ */ |
| 3040 | return -1; |
| 3041 | #endif /* __linux__ */ |
| 3042 | } |
| 3043 | |
| 3044 | |
| 3045 | static int run_ndc(struct sigma_dut *dut, char *buf) |
| 3046 | { |
| 3047 | sigma_dut_print(dut, DUT_MSG_INFO, "CMD NDC:: %s", buf); |
| 3048 | sleep(2); |
| 3049 | return run_system(dut, buf); |
| 3050 | } |
| 3051 | |
| 3052 | |
| 3053 | static int sigma_write_cfg(struct sigma_dut *dut, const char *pfile, |
| 3054 | const char *field, const char *value) |
| 3055 | { |
| 3056 | FILE *fcfg, *ftmp; |
| 3057 | char buf[MAX_CONF_LINE_LEN + 1]; |
| 3058 | int len, found = 0, res; |
| 3059 | |
| 3060 | /* Open the configuration file */ |
| 3061 | fcfg = fopen(pfile, "r"); |
| 3062 | if (!fcfg) { |
| 3063 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 3064 | "Failed to open hostapd conf file"); |
| 3065 | return -1; |
| 3066 | } |
| 3067 | |
| 3068 | snprintf(buf, sizeof(buf), "%s~", pfile); |
| 3069 | /* Open a temporary file */ |
| 3070 | ftmp = fopen(buf, "w+"); |
| 3071 | if (!ftmp) { |
| 3072 | fclose(fcfg); |
| 3073 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 3074 | "Failed to open temp buf"); |
| 3075 | return -1; |
| 3076 | } |
| 3077 | |
| 3078 | /* Read the values from the configuration file */ |
| 3079 | len = strlen(field); |
| 3080 | while (fgets(buf, MAX_CONF_LINE_LEN, fcfg)) { |
| 3081 | char *pline = buf; |
| 3082 | |
| 3083 | /* commented line */ |
| 3084 | if (buf[0] == '#') |
| 3085 | pline++; |
| 3086 | |
| 3087 | /* Identify the configuration parameter to be updated */ |
| 3088 | if (!found && strncmp(pline, field, len) == 0 && |
| 3089 | pline[len] == '=') { |
| 3090 | snprintf(buf, sizeof(buf), "%s=%s\n", field, value); |
| 3091 | found = 1; |
| 3092 | sigma_dut_print(dut, DUT_MSG_INFO, |
| 3093 | "Updated hostapd conf file"); |
| 3094 | } |
| 3095 | |
| 3096 | fprintf(ftmp, "%s", buf); |
| 3097 | } |
| 3098 | |
| 3099 | if (!found) { |
| 3100 | /* Configuration line not found */ |
| 3101 | /* Add the new line at the end of file */ |
| 3102 | fprintf(ftmp, "%s=%s\n", field, value); |
| 3103 | sigma_dut_print(dut, DUT_MSG_INFO, |
| 3104 | "Adding a new line in hostapd conf file"); |
| 3105 | } |
| 3106 | |
| 3107 | fclose(fcfg); |
| 3108 | fclose(ftmp); |
| 3109 | |
| 3110 | snprintf(buf, sizeof(buf), "%s~", pfile); |
| 3111 | |
| 3112 | /* Restore the updated configuration file */ |
| 3113 | res = rename(buf, pfile); |
| 3114 | |
| 3115 | /* Remove the temporary file. Ignore the return value */ |
| 3116 | unlink(buf); |
| 3117 | |
| 3118 | /* chmod is needed because open() may not set permissions properly |
| 3119 | * depending on the current umask */ |
| 3120 | if (chmod(pfile, 0660) < 0) { |
| 3121 | unlink(pfile); |
| 3122 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 3123 | "Error changing permissions"); |
| 3124 | return -1; |
| 3125 | } |
| 3126 | |
| 3127 | if (res < 0) { |
| 3128 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 3129 | "Error restoring conf file"); |
| 3130 | return -1; |
| 3131 | } |
| 3132 | |
| 3133 | return 0; |
| 3134 | } |
| 3135 | |
| 3136 | |
| 3137 | static int cmd_wcn_ap_config_commit(struct sigma_dut *dut, |
| 3138 | struct sigma_conn *conn, |
| 3139 | struct sigma_cmd *cmd) |
| 3140 | { |
| 3141 | char buf[100]; |
| 3142 | struct stat s; |
| 3143 | int num_tries = 0, ret; |
| 3144 | |
Pradeep Reddy Potteti | d068e64 | 2017-02-17 20:03:12 +0530 | [diff] [blame] | 3145 | if (kill_process(dut, "(netd)", 1, SIGKILL) == 0 || |
| 3146 | system("killall netd") == 0) { |
| 3147 | /* Avoid Error: Error connecting (Connection refused) |
| 3148 | * Wait some time to allow netd to reinitialize. |
| 3149 | */ |
| 3150 | usleep(1500000); |
| 3151 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3152 | |
| 3153 | while (num_tries < 10) { |
| 3154 | ret = run_ndc(dut, "ndc softap stopap"); |
| 3155 | num_tries++; |
| 3156 | if (WIFEXITED(ret)) |
| 3157 | ret = WEXITSTATUS(ret); |
| 3158 | /* On success, NDC exits with 0 */ |
| 3159 | if (ret == 0) |
| 3160 | break; |
| 3161 | sigma_dut_print(dut, DUT_MSG_INFO, |
| 3162 | "Try No. %d: ndc softap stopap failed, exit code %d", |
| 3163 | num_tries, ret); |
| 3164 | } |
| 3165 | |
| 3166 | if (ret != 0) |
| 3167 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 3168 | "ndc softap stopap command failed for 10 times - giving up"); |
| 3169 | |
| 3170 | #ifdef ANDROID |
| 3171 | /* Unload/Load driver to cleanup the state of the driver */ |
Ajit Vaishya | 14d1f9a | 2017-09-04 23:24:25 +0530 | [diff] [blame] | 3172 | system("rmmod -f wlan"); |
| 3173 | usleep(500000); |
| 3174 | system("insmod /system/lib/modules/wlan.ko"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3175 | #else /* ANDROID */ |
| 3176 | run_ndc(dut, "ndc softap qccmd set enable_softap=0"); |
| 3177 | run_ndc(dut, "ndc softap qccmd set enable_softap=1"); |
| 3178 | #endif /* ANDROID */ |
| 3179 | |
| 3180 | switch (dut->ap_mode) { |
| 3181 | case AP_11g: |
| 3182 | run_ndc(dut, "ndc softap qccmd set hw_mode=g-only"); |
| 3183 | break; |
| 3184 | case AP_11b: |
| 3185 | run_ndc(dut, "ndc softap qccmd set hw_mode=b-only"); |
| 3186 | break; |
| 3187 | case AP_11ng: |
| 3188 | run_ndc(dut, "ndc softap qccmd set hw_mode=n"); |
| 3189 | break; |
| 3190 | case AP_11a: |
| 3191 | run_ndc(dut, "ndc softap qccmd set hw_mode=a-only"); |
| 3192 | break; |
| 3193 | case AP_11na: |
| 3194 | run_ndc(dut, "ndc softap qccmd set hw_mode=n"); |
| 3195 | break; |
| 3196 | case AP_11ac: |
| 3197 | run_ndc(dut, "ndc softap qccmd set hw_mode=ac"); |
| 3198 | break; |
| 3199 | default: |
| 3200 | break; |
| 3201 | } |
| 3202 | |
| 3203 | snprintf(buf, sizeof(buf), "ndc softap qccmd set channel=%d", |
| 3204 | dut->ap_channel); |
| 3205 | run_ndc(dut, buf); |
| 3206 | |
| 3207 | /* |
| 3208 | * ndc doesn't support double quotes as SSID string, so re-write |
| 3209 | * hostapd configuration file to update SSID. |
| 3210 | */ |
| 3211 | if (dut->ap_ssid[0] != '\0') |
| 3212 | sigma_write_cfg(dut, ANDROID_CONFIG_FILE, "ssid", dut->ap_ssid); |
| 3213 | |
| 3214 | switch (dut->ap_key_mgmt) { |
| 3215 | case AP_OPEN: |
| 3216 | if (dut->ap_cipher == AP_WEP) { |
| 3217 | run_ndc(dut, "ndc softap qccmd set security_mode=1"); |
| 3218 | snprintf(buf, sizeof(buf), |
| 3219 | "ndc softap qccmd set wep_key0=%s", |
| 3220 | dut->ap_wepkey); |
| 3221 | run_ndc(dut, buf); |
| 3222 | } else { |
| 3223 | run_ndc(dut, "ndc softap qccmd set security_mode=0"); |
| 3224 | } |
| 3225 | break; |
| 3226 | case AP_WPA2_PSK: |
| 3227 | case AP_WPA2_PSK_MIXED: |
| 3228 | case AP_WPA_PSK: |
| 3229 | if (dut->ap_key_mgmt == AP_WPA2_PSK) |
| 3230 | run_ndc(dut, "ndc softap qccmd set security_mode=3"); |
| 3231 | else if (dut->ap_key_mgmt == AP_WPA2_PSK_MIXED) |
| 3232 | run_ndc(dut, "ndc softap qccmd set security_mode=4"); |
| 3233 | else |
| 3234 | run_ndc(dut, "ndc softap qccmd set security_mode=2"); |
| 3235 | |
| 3236 | /* |
| 3237 | * ndc doesn't support some special characters as passphrase, |
| 3238 | * so re-write hostapd configuration file to update Passphrase. |
| 3239 | */ |
| 3240 | if (dut->ap_passphrase[0] != '\0') |
| 3241 | sigma_write_cfg(dut, ANDROID_CONFIG_FILE, |
| 3242 | "wpa_passphrase", dut->ap_passphrase); |
| 3243 | |
| 3244 | if (dut->ap_cipher == AP_CCMP_TKIP) |
| 3245 | run_ndc(dut, "ndc softap qccmd set wpa_pairwise=" |
| 3246 | "TKIP CCMP"); |
| 3247 | else if (dut->ap_cipher == AP_TKIP) |
| 3248 | run_ndc(dut, "ndc softap qccmd set wpa_pairwise=" |
| 3249 | "TKIP"); |
| 3250 | else |
| 3251 | run_ndc(dut, "ndc softap qccmd set wpa_pairwise=" |
| 3252 | "CCMP &"); |
| 3253 | break; |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 3254 | case AP_WPA2_SAE: |
| 3255 | case AP_WPA2_PSK_SAE: |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3256 | case AP_WPA2_EAP: |
| 3257 | case AP_WPA2_EAP_MIXED: |
| 3258 | case AP_WPA_EAP: |
Jouni Malinen | ad395a2 | 2017-09-01 21:13:46 +0300 | [diff] [blame] | 3259 | case AP_SUITEB: |
Jouni Malinen | 147b3c3 | 2017-10-09 16:51:54 +0300 | [diff] [blame] | 3260 | case AP_WPA2_OWE: |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3261 | /* Not supported */ |
| 3262 | break; |
| 3263 | } |
| 3264 | |
| 3265 | switch (dut->ap_pmf) { |
| 3266 | case AP_PMF_DISABLED: |
| 3267 | run_ndc(dut, "ndc softap qccmd set ieee80211w=0"); |
| 3268 | break; |
| 3269 | case AP_PMF_OPTIONAL: |
| 3270 | run_ndc(dut, "ndc softap qccmd set ieee80211w=1"); |
| 3271 | if (dut->ap_add_sha256) |
| 3272 | run_ndc(dut, "ndc softap qccmd set wpa_key_mgmt=WPA-PSK WPA-PSK-SHA256"); |
| 3273 | else |
| 3274 | run_ndc(dut, "ndc softap qccmd set wpa_key_mgmt=WPA-PSK"); |
| 3275 | break; |
| 3276 | case AP_PMF_REQUIRED: |
| 3277 | run_ndc(dut, "ndc softap qccmd set ieee80211w=2"); |
| 3278 | run_ndc(dut, "ndc softap qccmd set wpa_key_mgmt=WPA-PSK-SHA256"); |
| 3279 | break; |
| 3280 | } |
| 3281 | |
| 3282 | if (dut->ap_countrycode[0]) { |
| 3283 | snprintf(buf, sizeof(buf), |
| 3284 | "ndc softap qccmd set country_code=%s", |
| 3285 | dut->ap_countrycode); |
| 3286 | run_ndc(dut, buf); |
| 3287 | } |
| 3288 | |
Pradeep Reddy POTTETI | fba27db | 2015-11-20 16:42:22 +0530 | [diff] [blame] | 3289 | if (dut->ap_regulatory_mode == AP_80211D_MODE_ENABLED) |
| 3290 | run_ndc(dut, "ndc softap qccmd set ieee80211d=1"); |
| 3291 | |
| 3292 | if (dut->ap_dfs_mode == AP_DFS_MODE_ENABLED) |
| 3293 | run_ndc(dut, "ndc softap qccmd set ieee80211h=1"); |
| 3294 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3295 | run_ndc(dut, "ndc softap startap"); |
| 3296 | |
| 3297 | snprintf(buf, sizeof(buf), "%s%s", sigma_wpas_ctrl, sigma_main_ifname); |
| 3298 | num_tries = 0; |
| 3299 | while (num_tries < 10 && (ret = stat(buf, &s) != 0)) { |
| 3300 | run_ndc(dut, "ndc softap stopap"); |
| 3301 | run_ndc(dut, "ndc softap startap"); |
| 3302 | num_tries++; |
| 3303 | } |
| 3304 | |
| 3305 | if (num_tries == 10) { |
| 3306 | sigma_dut_print(dut, DUT_MSG_INFO, "Tried 10 times with ctrl " |
| 3307 | "iface %s :: reboot the APDUT", buf); |
| 3308 | return ret; |
| 3309 | } |
| 3310 | |
| 3311 | sigma_dut_print(dut, DUT_MSG_INFO, "setting ip addr %s mask %s", |
| 3312 | ap_inet_addr, ap_inet_mask); |
| 3313 | snprintf(buf, sizeof(buf), "ifconfig %s %s netmask %s up", |
| 3314 | sigma_main_ifname, ap_inet_addr, ap_inet_mask); |
| 3315 | if (system(buf) != 0) { |
| 3316 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 3317 | "Failed to intialize the interface"); |
| 3318 | return -1; |
| 3319 | } |
| 3320 | |
| 3321 | return 1; |
| 3322 | } |
| 3323 | |
| 3324 | |
| 3325 | static int append_hostapd_conf_hs2(struct sigma_dut *dut, FILE *f) |
| 3326 | { |
| 3327 | fprintf(f, "hs20=1\nhs20_deauth_req_timeout=3\n" |
| 3328 | "disable_dgaf=%d\n", dut->ap_dgaf_disable); |
| 3329 | |
| 3330 | if (dut->ap_oper_name) { |
| 3331 | fprintf(f, "hs20_oper_friendly_name=eng:Wi-Fi Alliance\n"); |
| 3332 | fprintf(f, "hs20_oper_friendly_name=chi:Wi-Fi\xe8\x81\x94\xe7\x9b\x9f\n"); |
| 3333 | } |
| 3334 | |
| 3335 | if (dut->ap_wan_metrics == 1) |
| 3336 | fprintf(f, "hs20_wan_metrics=01:2500:384:0:0:10\n"); |
| 3337 | else if (dut->ap_wan_metrics == 2) |
| 3338 | fprintf(f, "hs20_wan_metrics=01:1500:384:20:20:10\n"); |
| 3339 | else if (dut->ap_wan_metrics == 3) |
| 3340 | fprintf(f, "hs20_wan_metrics=01:2000:1000:20:20:10\n"); |
| 3341 | else if (dut->ap_wan_metrics == 4) |
| 3342 | fprintf(f, "hs20_wan_metrics=01:8000:1000:20:20:10\n"); |
| 3343 | else if (dut->ap_wan_metrics == 5) |
| 3344 | fprintf(f, "hs20_wan_metrics=01:9000:5000:20:20:10\n"); |
| 3345 | |
| 3346 | if (dut->ap_conn_capab == 1) { |
| 3347 | fprintf(f, "hs20_conn_capab=1:0:0\n"); |
| 3348 | fprintf(f, "hs20_conn_capab=6:20:1\n"); |
| 3349 | fprintf(f, "hs20_conn_capab=6:22:0\n"); |
| 3350 | fprintf(f, "hs20_conn_capab=6:80:1\n"); |
| 3351 | fprintf(f, "hs20_conn_capab=6:443:1\n"); |
| 3352 | fprintf(f, "hs20_conn_capab=6:1723:0\n"); |
| 3353 | fprintf(f, "hs20_conn_capab=6:5060:0\n"); |
| 3354 | fprintf(f, "hs20_conn_capab=17:500:1\n"); |
| 3355 | fprintf(f, "hs20_conn_capab=17:5060:0\n"); |
| 3356 | fprintf(f, "hs20_conn_capab=17:4500:1\n"); |
| 3357 | fprintf(f, "hs20_conn_capab=50:0:1\n"); |
| 3358 | } else if (dut->ap_conn_capab == 2) { |
| 3359 | fprintf(f, "hs20_conn_capab=6:80:1\n"); |
| 3360 | fprintf(f, "hs20_conn_capab=6:443:1\n"); |
| 3361 | fprintf(f, "hs20_conn_capab=17:5060:1\n"); |
| 3362 | fprintf(f, "hs20_conn_capab=6:5060:1\n"); |
| 3363 | } else if (dut->ap_conn_capab == 3) { |
| 3364 | fprintf(f, "hs20_conn_capab=6:80:1\n"); |
| 3365 | fprintf(f, "hs20_conn_capab=6:443:1\n"); |
| 3366 | } else if (dut->ap_conn_capab == 4) { |
| 3367 | fprintf(f, "hs20_conn_capab=6:80:1\n"); |
| 3368 | fprintf(f, "hs20_conn_capab=6:443:1\n"); |
| 3369 | fprintf(f, "hs20_conn_capab=6:5060:1\n"); |
| 3370 | fprintf(f, "hs20_conn_capab=17:5060:1\n"); |
| 3371 | } |
| 3372 | |
| 3373 | if (dut->ap_oper_class == 1) |
| 3374 | fprintf(f, "hs20_operating_class=51\n"); |
| 3375 | else if (dut->ap_oper_class == 2) |
| 3376 | fprintf(f, "hs20_operating_class=73\n"); |
| 3377 | else if (dut->ap_oper_class == 3) |
| 3378 | fprintf(f, "hs20_operating_class=5173\n"); |
| 3379 | |
| 3380 | if (dut->ap_osu_provider_list) { |
| 3381 | char *osu_friendly_name = NULL; |
| 3382 | char *osu_icon = NULL; |
| 3383 | char *osu_ssid = NULL; |
| 3384 | char *osu_nai = NULL; |
| 3385 | char *osu_service_desc = NULL; |
| 3386 | char *hs20_icon_filename = NULL; |
| 3387 | char hs20_icon[150]; |
| 3388 | int osu_method; |
| 3389 | |
| 3390 | hs20_icon_filename = "icon_red_zxx.png"; |
| 3391 | if (dut->ap_osu_icon_tag == 2) |
| 3392 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 3393 | snprintf(hs20_icon, sizeof(hs20_icon), |
| 3394 | "128:61:zxx:image/png:icon_red_zxx.png:/etc/ath/%s", |
| 3395 | hs20_icon_filename); |
| 3396 | osu_icon = "icon_red_zxx.png"; |
| 3397 | osu_ssid = "OSU"; |
| 3398 | osu_friendly_name = "kor:SP 빨강 테스트 전용"; |
| 3399 | osu_service_desc = "kor:테스트 목적으로 무료 서비스"; |
| 3400 | osu_method = (dut->ap_osu_method[0] == 0xFF) ? 1 : dut->ap_osu_method[0]; |
| 3401 | |
| 3402 | if (strlen(dut->ap_osu_server_uri[0])) |
| 3403 | fprintf(f, "osu_server_uri=%s\n", dut->ap_osu_server_uri[0]); |
| 3404 | else |
| 3405 | fprintf(f, "osu_server_uri=https://osu-server.r2-testbed.wi-fi.org/\n"); |
| 3406 | |
| 3407 | switch (dut->ap_osu_provider_list) { |
| 3408 | case 1: |
| 3409 | case 101: |
| 3410 | fprintf(f, "osu_friendly_name=eng:SP Red Test Only\n"); |
| 3411 | fprintf(f, "osu_service_desc=eng:Free service for test purpose\n"); |
| 3412 | hs20_icon_filename = "icon_red_eng.png"; |
| 3413 | if (dut->ap_osu_icon_tag == 2) |
| 3414 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 3415 | fprintf(f, "hs20_icon=160:76:eng:image/png:icon_red_eng.png:/etc/ath/%s\n", |
| 3416 | hs20_icon_filename); |
| 3417 | fprintf(f, "osu_icon=icon_red_eng.png\n"); |
| 3418 | break; |
| 3419 | case 2: |
| 3420 | case 102: |
| 3421 | fprintf(f, "osu_friendly_name=eng:Wireless Broadband Alliance\n"); |
| 3422 | fprintf(f, "osu_service_desc=eng:Free service for test purpose\n"); |
| 3423 | hs20_icon_filename = "icon_orange_zxx.png"; |
| 3424 | if (dut->ap_osu_icon_tag == 2) |
| 3425 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 3426 | snprintf(hs20_icon, sizeof(hs20_icon), |
| 3427 | "128:61:zxx:image/png:icon_orange_zxx.png:/etc/ath/%s", |
| 3428 | hs20_icon_filename); |
| 3429 | osu_icon = "icon_orange_zxx.png"; |
| 3430 | osu_friendly_name = "kor:와이어리스 브로드밴드 얼라이언스"; |
| 3431 | break; |
| 3432 | case 3: |
| 3433 | case 103: |
| 3434 | osu_friendly_name = "spa:SP Red Test Only"; |
| 3435 | osu_service_desc = "spa:Free service for test purpose"; |
| 3436 | break; |
| 3437 | case 4: |
| 3438 | case 104: |
| 3439 | fprintf(f, "osu_friendly_name=eng:SP Orange Test Only\n"); |
| 3440 | fprintf(f, "osu_service_desc=eng:Free service for test purpose\n"); |
| 3441 | hs20_icon_filename = "icon_orange_eng.png"; |
| 3442 | if (dut->ap_osu_icon_tag == 2) |
| 3443 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 3444 | fprintf(f, "hs20_icon=160:76:eng:image/png:icon_orange_eng.png:/etc/ath/%s\n", |
| 3445 | hs20_icon_filename); |
| 3446 | fprintf(f, "osu_icon=icon_orange_eng.png\n"); |
| 3447 | osu_friendly_name = "kor:SP 오렌지 테스트 전용"; |
| 3448 | |
| 3449 | hs20_icon_filename = "icon_orange_zxx.png"; |
| 3450 | if (dut->ap_osu_icon_tag == 2) |
| 3451 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 3452 | snprintf(hs20_icon, sizeof(hs20_icon), |
| 3453 | "128:61:zxx:image/png:icon_orange_zxx.png:/etc/ath/%s", |
| 3454 | hs20_icon_filename); |
| 3455 | osu_icon = "icon_orange_zxx.png"; |
| 3456 | break; |
| 3457 | case 5: |
| 3458 | case 105: |
| 3459 | fprintf(f, "osu_friendly_name=eng:SP Orange Test Only\n"); |
| 3460 | fprintf(f, "osu_service_desc=eng:Free service for test purpose\n"); |
| 3461 | osu_friendly_name = "kor:SP 오렌지 테스트 전용"; |
| 3462 | hs20_icon_filename = "icon_orange_zxx.png"; |
| 3463 | if (dut->ap_osu_icon_tag == 2) |
| 3464 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 3465 | snprintf(hs20_icon, sizeof(hs20_icon), |
| 3466 | "128:61:zxx:image/png:icon_orange_zxx.png:/etc/ath/%s", |
| 3467 | hs20_icon_filename); |
| 3468 | osu_icon = "icon_orange_zxx.png"; |
| 3469 | break; |
| 3470 | case 6: |
| 3471 | case 106: |
| 3472 | fprintf(f, "osu_friendly_name=eng:SP Green Test Only\n"); |
| 3473 | fprintf(f, "osu_friendly_name=kor:SP 초록 테스트 전용\n"); |
| 3474 | hs20_icon_filename = "icon_green_zxx.png"; |
| 3475 | if (dut->ap_osu_icon_tag == 2) |
| 3476 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 3477 | fprintf(f, "hs20_icon=128:61:zxx:image/png:icon_green_zxx.png:/etc/ath/%s\n", |
| 3478 | hs20_icon_filename); |
| 3479 | fprintf(f, "osu_icon=icon_green_zxx.png\n"); |
| 3480 | osu_method = (dut->ap_osu_method[0] == 0xFF) ? 0 : dut->ap_osu_method[0]; |
| 3481 | fprintf(f, "osu_method_list=%d\n", osu_method); |
| 3482 | |
| 3483 | if (strlen(dut->ap_osu_server_uri[1])) |
| 3484 | fprintf(f, "osu_server_uri=%s\n", dut->ap_osu_server_uri[1]); |
| 3485 | else |
| 3486 | fprintf(f, "osu_server_uri=https://osu-server.r2-testbed.wi-fi.org/\n"); |
| 3487 | fprintf(f, "osu_friendly_name=eng:SP Orange Test Only\n"); |
| 3488 | hs20_icon_filename = "icon_orange_zxx.png"; |
| 3489 | if (dut->ap_osu_icon_tag == 2) |
| 3490 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 3491 | snprintf(hs20_icon, sizeof(hs20_icon), |
| 3492 | "128:61:zxx:image/png:icon_orange_zxx.png:/etc/ath/%s", |
| 3493 | hs20_icon_filename); |
| 3494 | osu_icon = "icon_orange_zxx.png"; |
| 3495 | osu_friendly_name = "kor:SP 오렌지 테스트 전용"; |
| 3496 | osu_method = (dut->ap_osu_method[1] == 0xFF) ? 0 : dut->ap_osu_method[1]; |
| 3497 | osu_service_desc = NULL; |
| 3498 | break; |
| 3499 | case 7: |
| 3500 | case 107: |
| 3501 | fprintf(f, "osu_friendly_name=eng:SP Green Test Only\n"); |
| 3502 | fprintf(f, "osu_service_desc=eng:Free service for test purpose\n"); |
| 3503 | hs20_icon_filename = "icon_green_eng.png"; |
| 3504 | if (dut->ap_osu_icon_tag == 2) |
| 3505 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 3506 | fprintf(f, "hs20_icon=160:76:eng:image/png:icon_green_eng.png:/etc/ath/%s\n", |
| 3507 | hs20_icon_filename); |
| 3508 | fprintf(f, "osu_icon=icon_green_eng.png\n"); |
| 3509 | osu_friendly_name = "kor:SP 초록 테스트 전용"; |
| 3510 | |
| 3511 | hs20_icon_filename = "icon_green_zxx.png"; |
| 3512 | if (dut->ap_osu_icon_tag == 2) |
| 3513 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 3514 | snprintf(hs20_icon, sizeof(hs20_icon), |
| 3515 | "128:61:zxx:image/png:icon_green_zxx.png:/etc/ath/%s", |
| 3516 | hs20_icon_filename); |
| 3517 | osu_icon = "icon_green_zxx.png"; |
| 3518 | break; |
| 3519 | case 8: |
| 3520 | case 108: |
| 3521 | fprintf(f, "osu_friendly_name=eng:SP Red Test Only\n"); |
| 3522 | fprintf(f, "osu_service_desc=eng:Free service for test purpose\n"); |
| 3523 | osu_ssid = "OSU-Encrypted"; |
| 3524 | osu_nai = "anonymous@hotspot.net"; |
| 3525 | break; |
| 3526 | case 9: |
| 3527 | case 109: |
| 3528 | osu_ssid = "OSU-OSEN"; |
| 3529 | osu_nai = "test-anonymous@wi-fi.org"; |
| 3530 | osu_friendly_name = "eng:SP Orange Test Only"; |
| 3531 | hs20_icon_filename = "icon_orange_zxx.png"; |
| 3532 | if (dut->ap_osu_icon_tag == 2) |
| 3533 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 3534 | snprintf(hs20_icon, sizeof(hs20_icon), |
| 3535 | "128:61:zxx:image/png:icon_orange_zxx.png:/etc/ath/%s", |
| 3536 | hs20_icon_filename); |
| 3537 | osu_icon = "icon_orange_zxx.png"; |
| 3538 | osu_method = (dut->ap_osu_method[0] == 0xFF) ? 1 : dut->ap_osu_method[0]; |
| 3539 | osu_service_desc = NULL; |
| 3540 | break; |
| 3541 | default: |
| 3542 | break; |
| 3543 | } |
| 3544 | |
| 3545 | if (strlen(dut->ap_osu_ssid)) { |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 3546 | if (strcmp(dut->ap_tag_ssid[0], dut->ap_osu_ssid) && |
| 3547 | strcmp(dut->ap_tag_ssid[0], osu_ssid)) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3548 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 3549 | "OSU_SSID and " |
| 3550 | "WLAN_TAG2 SSID differ"); |
| 3551 | return -2; |
| 3552 | } |
| 3553 | fprintf(f, "osu_ssid=\"%s\"\n", dut->ap_osu_ssid); |
| 3554 | } else |
| 3555 | fprintf(f, "osu_ssid=\"%s\"\n", osu_ssid); |
| 3556 | |
| 3557 | |
| 3558 | if (osu_friendly_name) |
| 3559 | fprintf(f, "osu_friendly_name=%s\n", osu_friendly_name); |
| 3560 | |
| 3561 | if (osu_service_desc) |
| 3562 | fprintf(f, "osu_service_desc=%s\n", osu_service_desc); |
| 3563 | |
| 3564 | if (osu_nai) |
| 3565 | fprintf(f, "osu_nai=%s\n", osu_nai); |
| 3566 | |
| 3567 | fprintf(f, "hs20_icon=%s\n", hs20_icon); |
| 3568 | |
| 3569 | if (osu_icon) |
| 3570 | fprintf(f, "osu_icon=%s\n", osu_icon); |
| 3571 | |
| 3572 | if (dut->ap_osu_provider_list > 100) |
| 3573 | fprintf(f, "osu_method_list=0\n"); |
| 3574 | else |
| 3575 | fprintf(f, "osu_method_list=%d\n", osu_method); |
| 3576 | } |
| 3577 | |
| 3578 | return 0; |
| 3579 | } |
| 3580 | |
| 3581 | |
| 3582 | static void write_ap_roaming_cons(FILE *f, const char *list) |
| 3583 | { |
| 3584 | char *buf, *pos, *end; |
| 3585 | |
| 3586 | if (list == NULL || list[0] == '\0') |
| 3587 | return; |
| 3588 | |
| 3589 | buf = strdup(list); |
| 3590 | if (buf == NULL) |
| 3591 | return; |
| 3592 | |
| 3593 | pos = buf; |
| 3594 | while (pos && *pos) { |
| 3595 | end = strchr(pos, ';'); |
| 3596 | if (end) |
| 3597 | *end++ = '\0'; |
| 3598 | fprintf(f, "roaming_consortium=%s\n", pos); |
| 3599 | pos = end; |
| 3600 | } |
| 3601 | |
| 3602 | free(buf); |
| 3603 | } |
| 3604 | |
| 3605 | |
| 3606 | static int append_hostapd_conf_interworking(struct sigma_dut *dut, FILE *f) |
| 3607 | { |
| 3608 | int i; |
| 3609 | char buf[100], *temp; |
| 3610 | |
| 3611 | if (dut->ap_gas_cb_delay > 0) |
| 3612 | fprintf(f, "gas_comeback_delay=%d\n", |
| 3613 | dut->ap_gas_cb_delay); |
| 3614 | |
| 3615 | fprintf(f, "interworking=1\n" |
| 3616 | "access_network_type=%d\n" |
| 3617 | "internet=%d\n" |
| 3618 | "asra=0\n" |
| 3619 | "esr=0\n" |
| 3620 | "uesa=0\n" |
| 3621 | "venue_group=%d\n" |
| 3622 | "venue_type=%d\n", |
| 3623 | dut->ap_access_net_type, |
| 3624 | dut->ap_internet, |
| 3625 | dut->ap_venue_group, |
| 3626 | dut->ap_venue_type); |
| 3627 | if (dut->ap_hessid[0]) |
| 3628 | fprintf(f, "hessid=%s\n", dut->ap_hessid); |
| 3629 | |
| 3630 | write_ap_roaming_cons(f, dut->ap_roaming_cons); |
| 3631 | |
| 3632 | if (dut->ap_venue_name) { |
| 3633 | fprintf(f, "venue_name=P\"eng:Wi-Fi Alliance\\n2989 Copper Road\\nSanta Clara, CA 95051, USA\"\n"); |
| 3634 | fprintf(f, "venue_name=%s\n", ANQP_VENUE_NAME_1_CHI); |
| 3635 | } |
| 3636 | |
| 3637 | if (dut->ap_net_auth_type == 1) |
| 3638 | fprintf(f, "network_auth_type=00https://tandc-server.wi-fi.org\n"); |
| 3639 | else if (dut->ap_net_auth_type == 2) |
| 3640 | fprintf(f, "network_auth_type=01\n"); |
| 3641 | |
| 3642 | if (dut->ap_nai_realm_list == 1) { |
| 3643 | fprintf(f, "nai_realm=0,mail.example.com;cisco.com;wi-fi.org,21[2:4][5:7]\n"); |
| 3644 | fprintf(f, "nai_realm=0,wi-fi.org;example.com,13[5:6]\n"); |
| 3645 | } else if (dut->ap_nai_realm_list == 2) { |
| 3646 | fprintf(f, "nai_realm=0,wi-fi.org,21[2:4][5:7]\n"); |
| 3647 | } else if (dut->ap_nai_realm_list == 3) { |
| 3648 | fprintf(f, "nai_realm=0,cisco.com;wi-fi.org,21[2:4][5:7]\n"); |
| 3649 | fprintf(f, "nai_realm=0,wi-fi.org;example.com,13[5:6]\n"); |
| 3650 | } else if (dut->ap_nai_realm_list == 4) { |
| 3651 | fprintf(f, "nai_realm=0,mail.example.com,21[2:4][5:7],13[5:6]\n"); |
| 3652 | } else if (dut->ap_nai_realm_list == 5) { |
| 3653 | fprintf(f, "nai_realm=0,wi-fi.org;ruckuswireless.com,21[2:4][5:7]\n"); |
| 3654 | } else if (dut->ap_nai_realm_list == 6) { |
| 3655 | fprintf(f, "nai_realm=0,wi-fi.org;mail.example.com,21[2:4][5:7]\n"); |
| 3656 | } else if (dut->ap_nai_realm_list == 7) { |
| 3657 | fprintf(f, "nai_realm=0,wi-fi.org,13[5:6]\n"); |
| 3658 | fprintf(f, "nai_realm=0,wi-fi.org,21[2:4][5:7]\n"); |
| 3659 | } |
| 3660 | |
| 3661 | if (dut->ap_domain_name_list[0]) { |
| 3662 | fprintf(f, "domain_name=%s\n", |
| 3663 | dut->ap_domain_name_list); |
| 3664 | } |
| 3665 | |
| 3666 | if (dut->ap_ip_addr_type_avail == 1) { |
| 3667 | fprintf(f, "ipaddr_type_availability=0c\n"); |
| 3668 | } |
| 3669 | |
| 3670 | temp = buf; |
| 3671 | for (i = 0; dut->ap_plmn_mcc[i][0] && dut->ap_plmn_mnc[i][0]; |
| 3672 | i++) { |
| 3673 | if (i) |
| 3674 | *temp++ = ';'; |
| 3675 | |
| 3676 | snprintf(temp, |
| 3677 | sizeof(dut->ap_plmn_mcc[i]) + |
| 3678 | sizeof(dut->ap_plmn_mnc[i]) + 1, |
| 3679 | "%s,%s", |
| 3680 | dut->ap_plmn_mcc[i], |
| 3681 | dut->ap_plmn_mnc[i]); |
| 3682 | |
| 3683 | temp += strlen(dut->ap_plmn_mcc[i]) + |
| 3684 | strlen(dut->ap_plmn_mnc[i]) + 1; |
| 3685 | } |
| 3686 | if (i) |
| 3687 | fprintf(f, "anqp_3gpp_cell_net=%s\n", buf); |
| 3688 | |
| 3689 | if (dut->ap_qos_map_set == 1) |
| 3690 | fprintf(f, "qos_map_set=%s\n", QOS_MAP_SET_1); |
| 3691 | else if (dut->ap_qos_map_set == 2) |
| 3692 | fprintf(f, "qos_map_set=%s\n", QOS_MAP_SET_2); |
| 3693 | |
| 3694 | return 0; |
| 3695 | } |
| 3696 | |
| 3697 | |
| 3698 | static int ath_ap_append_hostapd_conf(struct sigma_dut *dut) |
| 3699 | { |
| 3700 | FILE *f; |
| 3701 | |
| 3702 | if (kill_process(dut, "(hostapd)", 1, SIGTERM) == 0 || |
| 3703 | system("killall hostapd") == 0) { |
| 3704 | int i; |
| 3705 | |
| 3706 | /* Wait some time to allow hostapd to complete cleanup before |
| 3707 | * starting a new process */ |
| 3708 | for (i = 0; i < 10; i++) { |
| 3709 | usleep(500000); |
| 3710 | if (system("pidof hostapd") != 0) |
| 3711 | break; |
| 3712 | } |
| 3713 | } |
| 3714 | |
| 3715 | f = fopen("/tmp/secath0", "a"); |
| 3716 | if (f == NULL) |
| 3717 | return -2; |
| 3718 | |
| 3719 | if (dut->ap_hs2 && append_hostapd_conf_hs2(dut, f)) { |
| 3720 | fclose(f); |
| 3721 | return -2; |
| 3722 | } |
| 3723 | |
| 3724 | if (dut->ap_interworking && append_hostapd_conf_interworking(dut, f)) { |
| 3725 | fclose(f); |
| 3726 | return -2; |
| 3727 | } |
| 3728 | |
| 3729 | fflush(f); |
| 3730 | fclose(f); |
| 3731 | return ath_ap_start_hostapd(dut); |
| 3732 | } |
| 3733 | |
| 3734 | |
| 3735 | static int ath_ap_start_hostapd(struct sigma_dut *dut) |
| 3736 | { |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 3737 | if (dut->ap_tag_key_mgmt[0] == AP2_OSEN) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3738 | run_system(dut, "hostapd -B /tmp/secath0 /tmp/secath1 -e /etc/wpa2/entropy"); |
| 3739 | else |
| 3740 | run_system(dut, "hostapd -B /tmp/secath0 -e /etc/wpa2/entropy"); |
| 3741 | |
| 3742 | return 0; |
| 3743 | } |
| 3744 | |
| 3745 | |
| 3746 | #define LE16(a) ((((a) & 0xff) << 8) | (((a) >> 8) & 0xff)) |
| 3747 | |
| 3748 | static int cmd_ath_ap_anqpserver_start(struct sigma_dut *dut) |
| 3749 | { |
| 3750 | FILE *f; |
| 3751 | int nai_realm = 0, domain_name = 0, oper_name = 0, venue_name = 0, |
| 3752 | wan_metrics = 0, conn_cap = 0, ipaddr_avail = 0, cell_net = 0; |
| 3753 | char buf[100]; |
| 3754 | int i; |
| 3755 | |
| 3756 | f = fopen("/root/anqpserver.conf", "w"); |
| 3757 | if (f == NULL) |
| 3758 | return -1; |
| 3759 | |
| 3760 | if (dut->ap_nai_realm_list == 1) { |
| 3761 | nai_realm = 1; |
| 3762 | 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"); |
| 3763 | } else if (dut->ap_nai_realm_list == 2) { |
| 3764 | nai_realm = 1; |
| 3765 | fprintf(f, "dyn_nai_home_realm=encoding=00realm=wi-fi.org;eap_method=0Dauth_id=05auth_val=06\n"); |
| 3766 | } else if (dut->ap_nai_realm_list == 3) { |
| 3767 | nai_realm = 1; |
| 3768 | 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"); |
| 3769 | } else if (dut->ap_nai_realm_list == 4) { |
| 3770 | nai_realm = 1; |
| 3771 | 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"); |
| 3772 | } else |
| 3773 | sigma_dut_print(dut, DUT_MSG_INFO, "not setting nai_realm"); |
| 3774 | |
| 3775 | if (dut->ap_domain_name_list[0]) { |
| 3776 | char *next, *start, *dnbuf, *dn1, *anqp_dn; |
| 3777 | int len, dn_len_max; |
| 3778 | dnbuf = strdup(dut->ap_domain_name_list); |
Pradeep Reddy POTTETI | 673d85c | 2016-07-26 19:08:07 +0530 | [diff] [blame] | 3779 | if (dnbuf == NULL) { |
| 3780 | fclose(f); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3781 | return 0; |
Pradeep Reddy POTTETI | 673d85c | 2016-07-26 19:08:07 +0530 | [diff] [blame] | 3782 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3783 | |
| 3784 | len = strlen(dnbuf); |
| 3785 | dn_len_max = 50 + len*2; |
| 3786 | anqp_dn = malloc(dn_len_max); |
| 3787 | if (anqp_dn == NULL) { |
| 3788 | free(dnbuf); |
Pradeep Reddy POTTETI | 673d85c | 2016-07-26 19:08:07 +0530 | [diff] [blame] | 3789 | fclose(f); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3790 | return -1; |
| 3791 | } |
| 3792 | start = dnbuf; |
| 3793 | dn1 = anqp_dn; |
| 3794 | while (start && *start) { |
| 3795 | char *hexstr; |
| 3796 | |
| 3797 | next = strchr(start, ','); |
| 3798 | if (next) |
| 3799 | *next++ = '\0'; |
| 3800 | |
| 3801 | len = strlen(start); |
vamsi krishna | 2e88130 | 2016-05-25 15:02:39 +0530 | [diff] [blame] | 3802 | hexstr = malloc(len * 2 + 1); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3803 | if (hexstr == NULL) { |
| 3804 | free(dnbuf); |
| 3805 | free(anqp_dn); |
Pradeep Reddy POTTETI | 673d85c | 2016-07-26 19:08:07 +0530 | [diff] [blame] | 3806 | fclose(f); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3807 | return -1; |
| 3808 | } |
| 3809 | ascii2hexstr(start, hexstr); |
| 3810 | snprintf(dn1, dn_len_max, "%02x%s", len, hexstr); |
| 3811 | free(hexstr); |
| 3812 | dn1 += 2 + len * 2; |
| 3813 | dn_len_max -= 2 + len * 2; |
| 3814 | start = next; |
| 3815 | } |
| 3816 | free(dnbuf); |
| 3817 | if (dut->ap_gas_cb_delay) { |
| 3818 | fprintf(f, "dyn_domain_name=0c01%04x%s", |
| 3819 | LE16((unsigned int) strlen(anqp_dn)), anqp_dn); |
| 3820 | domain_name = 1; |
| 3821 | } else |
| 3822 | fprintf(f, "domain_name=0c01%04x%s", |
| 3823 | LE16((unsigned int) strlen(anqp_dn)), anqp_dn); |
| 3824 | free(anqp_dn); |
| 3825 | } else |
| 3826 | sigma_dut_print(dut, DUT_MSG_INFO, "not setting domain_name"); |
| 3827 | |
| 3828 | sigma_dut_print(dut, DUT_MSG_INFO, "not setting roaming_consortium"); |
| 3829 | |
| 3830 | if (dut->ap_oper_name) { |
| 3831 | if (dut->ap_gas_cb_delay) { |
| 3832 | fprintf(f, "dyn_oper_friendly_name=" |
| 3833 | ANQP_HS20_OPERATOR_FRIENDLY_NAME_1 "\n"); |
| 3834 | oper_name = 1; |
| 3835 | } else |
| 3836 | fprintf(f, "oper_friendly_name=" |
| 3837 | ANQP_HS20_OPERATOR_FRIENDLY_NAME_1 "\n"); |
| 3838 | } else |
| 3839 | sigma_dut_print(dut, DUT_MSG_INFO, "not setting oper_name"); |
| 3840 | |
| 3841 | if (dut->ap_venue_name) { |
| 3842 | if (dut->ap_gas_cb_delay) { |
| 3843 | fprintf(f, "dyn_venue_name=" ANQP_VENUE_NAME_1 "\n"); |
| 3844 | venue_name = 1; |
| 3845 | } else |
| 3846 | fprintf(f, "venue_name=" ANQP_VENUE_NAME_1 "\n"); |
| 3847 | } else |
| 3848 | sigma_dut_print(dut, DUT_MSG_ERROR, "not setting venue_name"); |
| 3849 | |
| 3850 | if (dut->ap_wan_metrics) { |
| 3851 | if (dut->ap_gas_cb_delay) { |
| 3852 | fprintf(f, "dyn_wan_metrics=" ANQP_HS20_WAN_METRICS_1 "\n"); |
| 3853 | wan_metrics = 1; |
| 3854 | } else |
| 3855 | fprintf(f, "wan_metrics=" ANQP_HS20_WAN_METRICS_1 |
| 3856 | "\n"); |
| 3857 | } else |
| 3858 | sigma_dut_print(dut, DUT_MSG_ERROR, "not setting wan_metrics"); |
| 3859 | |
| 3860 | if (dut->ap_conn_capab) { |
| 3861 | if (dut->ap_gas_cb_delay) { |
| 3862 | fprintf(f, "dyn_conn_capability=" |
| 3863 | ANQP_HS20_CONNECTION_CAPABILITY_1 "\n"); |
| 3864 | conn_cap = 1; |
| 3865 | } else |
| 3866 | fprintf(f, "conn_capability=" |
| 3867 | ANQP_HS20_CONNECTION_CAPABILITY_1 "\n"); |
| 3868 | } else |
| 3869 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 3870 | "not setting conn_capability"); |
| 3871 | |
| 3872 | if (dut->ap_ip_addr_type_avail) { |
| 3873 | if (dut->ap_gas_cb_delay) { |
| 3874 | fprintf(f, "dyn_ipaddr_type=" ANQP_IP_ADDR_TYPE_1 |
| 3875 | "\n"); |
| 3876 | ipaddr_avail = 1; |
| 3877 | } else |
| 3878 | fprintf(f, "ipaddr_type=" ANQP_IP_ADDR_TYPE_1 "\n"); |
| 3879 | } else |
| 3880 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 3881 | "not setting ipaddr_type_avail"); |
| 3882 | |
| 3883 | for (i = 0; dut->ap_plmn_mcc[i][0] && dut->ap_plmn_mnc[i][0]; i++) { |
| 3884 | snprintf(buf + i * 6, sizeof(buf) - i * 6, "%c%c%c%c%c%c", |
| 3885 | dut->ap_plmn_mcc[i][1], |
| 3886 | dut->ap_plmn_mcc[i][0], |
| 3887 | dut->ap_plmn_mnc[i][2] == '\0' ? |
| 3888 | 'f' : dut->ap_plmn_mnc[i][2], |
| 3889 | dut->ap_plmn_mcc[i][2], |
| 3890 | dut->ap_plmn_mnc[i][1], |
| 3891 | dut->ap_plmn_mnc[i][0]); |
| 3892 | } |
| 3893 | if (i) { |
| 3894 | uint16_t ie_len = (i * 3) + 5; |
| 3895 | if (dut->ap_gas_cb_delay) { |
| 3896 | fprintf(f, "dyn_cell_net=0801"); |
| 3897 | cell_net = 1; |
| 3898 | } else |
| 3899 | fprintf(f, "cell_net=0801"); |
| 3900 | fprintf(f, "%04x", LE16(ie_len)); |
| 3901 | fprintf(f, "00"); /* version */ |
| 3902 | fprintf(f, "%02x", (i * 3) + 3); /* user data hdr length */ |
| 3903 | fprintf(f, "00"); /* plmn list */ |
| 3904 | fprintf(f, "%02x", (i * 3) + 1); /* length of plmn list */ |
| 3905 | fprintf(f, "%02x", i); /* number of plmns */ |
| 3906 | fprintf(f, "%s\n", buf); /* plmns */ |
| 3907 | } else |
| 3908 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 3909 | "not setting 3gpp_cellular_network"); |
| 3910 | |
| 3911 | if (nai_realm || domain_name || oper_name || venue_name || |
| 3912 | wan_metrics || conn_cap || ipaddr_avail || cell_net) { |
| 3913 | fprintf(f, "anqp_attach="); |
| 3914 | if (venue_name) |
| 3915 | fprintf(f, "00000104%4.4x", dut->ap_gas_cb_delay); |
| 3916 | if (nai_realm) |
| 3917 | fprintf(f, "00000107%4.4x", dut->ap_gas_cb_delay); |
| 3918 | if (cell_net) |
| 3919 | fprintf(f, "00000108%4.4x", dut->ap_gas_cb_delay); |
| 3920 | if (domain_name) |
| 3921 | fprintf(f, "0000010c%4.4x", dut->ap_gas_cb_delay); |
| 3922 | if (oper_name) |
| 3923 | fprintf(f, "00010003%4.4x", dut->ap_gas_cb_delay); |
| 3924 | if (wan_metrics) |
| 3925 | fprintf(f, "00010004%4.4x", dut->ap_gas_cb_delay); |
| 3926 | if (conn_cap) |
| 3927 | fprintf(f, "00010005%4.4x", dut->ap_gas_cb_delay); |
| 3928 | fprintf(f, "00010006%4.4x", dut->ap_gas_cb_delay); |
| 3929 | fprintf(f, "\n"); |
| 3930 | } |
| 3931 | |
| 3932 | fclose(f); |
| 3933 | |
| 3934 | run_system(dut, "anqpserver -i ath0 &"); |
| 3935 | if (!dut->ap_anqpserver_on) |
| 3936 | run_system(dut, "killall anqpserver"); |
| 3937 | |
| 3938 | return 1; |
| 3939 | } |
| 3940 | |
| 3941 | |
| 3942 | static void cmd_ath_ap_radio_config(struct sigma_dut *dut) |
| 3943 | { |
| 3944 | char buf[100]; |
| 3945 | |
| 3946 | run_system(dut, "cfg -a AP_STARTMODE=standard"); |
| 3947 | |
| 3948 | if (sigma_radio_ifname[0] && |
| 3949 | strcmp(sigma_radio_ifname[0], "wifi1") == 0) { |
| 3950 | run_system(dut, "cfg -a AP_RADIO_ID=1"); |
| 3951 | switch (dut->ap_mode) { |
| 3952 | case AP_11g: |
| 3953 | run_system(dut, "cfg -a AP_CHMODE_2=11G"); |
| 3954 | break; |
| 3955 | case AP_11b: |
| 3956 | run_system(dut, "cfg -a AP_CHMODE_2=11B"); |
| 3957 | break; |
| 3958 | case AP_11ng: |
| 3959 | run_system(dut, "cfg -a AP_CHMODE_2=11NGHT20"); |
| 3960 | break; |
| 3961 | case AP_11a: |
| 3962 | run_system(dut, "cfg -a AP_CHMODE_2=11A"); |
| 3963 | break; |
| 3964 | case AP_11na: |
| 3965 | run_system(dut, "cfg -a AP_CHMODE_2=11NAHT20"); |
| 3966 | break; |
| 3967 | case AP_11ac: |
| 3968 | run_system(dut, "cfg -a AP_CHMODE_2=11ACVHT80"); |
| 3969 | break; |
| 3970 | default: |
| 3971 | run_system(dut, "cfg -a AP_CHMODE_2=11ACVHT80"); |
| 3972 | break; |
| 3973 | } |
| 3974 | |
| 3975 | switch (dut->ap_rx_streams) { |
| 3976 | case 1: |
| 3977 | run_system(dut, "cfg -a RX_CHAINMASK_2=1"); |
| 3978 | break; |
| 3979 | case 2: |
| 3980 | run_system(dut, "cfg -a RX_CHAINMASK_2=3"); |
| 3981 | break; |
| 3982 | case 3: |
| 3983 | run_system(dut, "cfg -a RX_CHAINMASK_2=7"); |
| 3984 | break; |
| 3985 | } |
| 3986 | |
| 3987 | switch (dut->ap_tx_streams) { |
| 3988 | case 1: |
| 3989 | run_system(dut, "cfg -a TX_CHAINMASK_2=1"); |
| 3990 | break; |
| 3991 | case 2: |
| 3992 | run_system(dut, "cfg -a TX_CHAINMASK_2=3"); |
| 3993 | break; |
| 3994 | case 3: |
| 3995 | run_system(dut, "cfg -a TX_CHAINMASK_2=7"); |
| 3996 | break; |
| 3997 | } |
| 3998 | |
| 3999 | switch (dut->ap_chwidth) { |
| 4000 | case AP_20: |
| 4001 | run_system(dut, "cfg -a AP_CHMODE_2=11ACVHT20"); |
| 4002 | break; |
| 4003 | case AP_40: |
| 4004 | run_system(dut, "cfg -a AP_CHMODE_2=11ACVHT40"); |
| 4005 | break; |
| 4006 | case AP_80: |
| 4007 | run_system(dut, "cfg -a AP_CHMODE_2=11ACVHT80"); |
| 4008 | break; |
| 4009 | case AP_160: |
| 4010 | case AP_AUTO: |
| 4011 | default: |
| 4012 | run_system(dut, "cfg -a AP_CHMODE_2=11ACVHT80"); |
| 4013 | break; |
| 4014 | } |
| 4015 | |
| 4016 | if (dut->ap_tx_stbc) { |
| 4017 | run_system(dut, "cfg -a TX_STBC_2=1"); |
| 4018 | } |
| 4019 | |
| 4020 | snprintf(buf, sizeof(buf), "cfg -a AP_PRIMARY_CH_2=%d", |
| 4021 | dut->ap_channel); |
| 4022 | |
| 4023 | if (dut->ap_is_dual) { |
| 4024 | switch (dut->ap_mode_1) { |
| 4025 | case AP_11g: |
| 4026 | run_system(dut, "cfg -a AP_CHMODE=11G"); |
| 4027 | break; |
| 4028 | case AP_11b: |
| 4029 | run_system(dut, "cfg -a AP_CHMODE=11B"); |
| 4030 | break; |
| 4031 | case AP_11ng: |
| 4032 | run_system(dut, "cfg -a AP_CHMODE=11NGHT20"); |
| 4033 | break; |
| 4034 | case AP_11a: |
| 4035 | run_system(dut, "cfg -a AP_CHMODE=11A"); |
| 4036 | break; |
| 4037 | case AP_11na: |
| 4038 | run_system(dut, "cfg -a AP_CHMODE=11NAHT20"); |
| 4039 | break; |
| 4040 | case AP_11ac: |
| 4041 | run_system(dut, "cfg -a AP_CHMODE=11ACVHT80"); |
| 4042 | break; |
| 4043 | default: |
| 4044 | run_system(dut, "cfg -a AP_CHMODE=11NGHT20"); |
| 4045 | break; |
| 4046 | } |
| 4047 | snprintf(buf, sizeof(buf), "cfg -a AP_PRIMARY_CH=%d", |
| 4048 | dut->ap_channel_1); |
| 4049 | } |
| 4050 | run_system(dut, buf); |
| 4051 | } else { |
| 4052 | run_system(dut, "cfg -a AP_RADIO_ID=0"); |
| 4053 | switch (dut->ap_mode) { |
| 4054 | case AP_11g: |
| 4055 | run_system(dut, "cfg -a AP_CHMODE=11G"); |
| 4056 | break; |
| 4057 | case AP_11b: |
| 4058 | run_system(dut, "cfg -a AP_CHMODE=11B"); |
| 4059 | break; |
| 4060 | case AP_11ng: |
| 4061 | run_system(dut, "cfg -a AP_CHMODE=11NGHT20"); |
| 4062 | break; |
| 4063 | case AP_11a: |
| 4064 | run_system(dut, "cfg -a AP_CHMODE=11A"); |
| 4065 | break; |
| 4066 | case AP_11na: |
| 4067 | run_system(dut, "cfg -a AP_CHMODE=11NAHT20"); |
| 4068 | break; |
| 4069 | case AP_11ac: |
| 4070 | run_system(dut, "cfg -a AP_CHMODE=11ACVHT80"); |
| 4071 | break; |
| 4072 | default: |
| 4073 | run_system(dut, "cfg -a AP_CHMODE=11NGHT20"); |
| 4074 | break; |
| 4075 | } |
| 4076 | snprintf(buf, sizeof(buf), "cfg -a AP_PRIMARY_CH=%d", |
| 4077 | dut->ap_channel); |
| 4078 | run_system(dut, buf); |
| 4079 | } |
| 4080 | |
| 4081 | if (dut->ap_sgi80 == 1) { |
| 4082 | run_system(dut, "cfg -a SHORTGI=1"); |
| 4083 | run_system(dut, "cfg -a SHORTGI_2=1"); |
| 4084 | } else if (dut->ap_sgi80 == 0) { |
| 4085 | run_system(dut, "cfg -a SHORTGI=0"); |
| 4086 | run_system(dut, "cfg -a SHORTGI_2=0"); |
| 4087 | } |
| 4088 | |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 4089 | if (dut->ap_ldpc == VALUE_ENABLED) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4090 | run_system(dut, "cfg -a LDPC=1"); |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 4091 | else if (dut->ap_ldpc == VALUE_DISABLED) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4092 | run_system(dut, "cfg -a LDPC=0"); |
| 4093 | } |
| 4094 | |
| 4095 | |
| 4096 | void ath_disable_txbf(struct sigma_dut *dut, const char *intf) |
| 4097 | { |
| 4098 | char buf[50]; |
| 4099 | |
| 4100 | snprintf(buf, sizeof(buf), "iwpriv %s vhtsubfee 0", intf); |
| 4101 | if (system(buf) != 0) |
| 4102 | sigma_dut_print(dut, DUT_MSG_ERROR, "iwpriv vhtsubfee failed"); |
| 4103 | |
| 4104 | snprintf(buf, sizeof(buf), "iwpriv %s vhtsubfer 0", intf); |
| 4105 | if (system(buf) != 0) |
| 4106 | sigma_dut_print(dut, DUT_MSG_ERROR, "iwpriv vhtsubfer failed"); |
| 4107 | |
| 4108 | snprintf(buf, sizeof(buf), "iwpriv %s vhtmubfee 0", intf); |
| 4109 | if (system(buf) != 0) |
| 4110 | sigma_dut_print(dut, DUT_MSG_ERROR, "iwpriv vhtmubfee failed"); |
| 4111 | |
| 4112 | snprintf(buf, sizeof(buf), "iwpriv %s vhtmubfer 0", intf); |
| 4113 | if (system(buf) != 0) |
| 4114 | sigma_dut_print(dut, DUT_MSG_ERROR, "iwpriv vhtmubfer failed"); |
| 4115 | } |
| 4116 | |
| 4117 | |
Adil Saeed Musthafa | 05ec744 | 2017-04-10 23:13:35 -0700 | [diff] [blame] | 4118 | static void ath_set_assoc_disallow(struct sigma_dut *dut, const char *ifname, |
| 4119 | const char *val) |
| 4120 | { |
| 4121 | if (strcasecmp(val, "enable") == 0) { |
| 4122 | run_system_wrapper(dut, "iwpriv %s mbo_asoc_dis 1", ifname); |
| 4123 | } else if (strcasecmp(val, "disable") == 0) { |
| 4124 | run_system_wrapper(dut, "iwpriv %s mbo_asoc_dis 0", ifname); |
| 4125 | } else { |
| 4126 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4127 | "Unsupported assoc_disallow"); |
| 4128 | } |
| 4129 | } |
| 4130 | |
| 4131 | |
Adil Saeed Musthafa | 6906372 | 2017-04-10 23:13:40 -0700 | [diff] [blame] | 4132 | static void apply_mbo_pref_ap_list(struct sigma_dut *dut) |
| 4133 | { |
| 4134 | int i; |
| 4135 | int least_pref = 1 << 8; |
| 4136 | char ifname[20]; |
| 4137 | uint8_t self_mac[ETH_ALEN]; |
| 4138 | char buf[200]; |
| 4139 | int ap_ne_class, ap_ne_pref, ap_ne_op_ch; |
| 4140 | |
| 4141 | get_if_name(dut, ifname, sizeof(ifname), 1); |
| 4142 | get_hwaddr(ifname, self_mac); |
| 4143 | |
| 4144 | /* Clear off */ |
| 4145 | snprintf(buf, sizeof(buf), |
| 4146 | "wifitool %s setbssidpref 00:00:00:00:00:00 0 0 0", |
| 4147 | ifname); |
| 4148 | run_system(dut, buf); |
| 4149 | |
| 4150 | /* Find the least preference number */ |
| 4151 | for (i = 0; i < dut->mbo_pref_ap_cnt; i++) { |
| 4152 | unsigned char *mac_addr = dut->mbo_pref_aps[i].mac_addr; |
| 4153 | |
| 4154 | ap_ne_class = 1; |
| 4155 | ap_ne_pref = 255; |
| 4156 | ap_ne_op_ch = 1; |
| 4157 | if (dut->mbo_pref_aps[i].ap_ne_pref != -1) |
| 4158 | ap_ne_pref = dut->mbo_pref_aps[i].ap_ne_pref; |
| 4159 | if (dut->mbo_pref_aps[i].ap_ne_class != -1) |
| 4160 | ap_ne_class = dut->mbo_pref_aps[i].ap_ne_class; |
| 4161 | if (dut->mbo_pref_aps[i].ap_ne_op_ch != -1) |
| 4162 | ap_ne_op_ch = dut->mbo_pref_aps[i].ap_ne_op_ch; |
| 4163 | |
| 4164 | if (ap_ne_pref < least_pref) |
| 4165 | least_pref = ap_ne_pref; |
| 4166 | snprintf(buf, sizeof(buf), |
| 4167 | "wifitool %s setbssidpref %02x:%02x:%02x:%02x:%02x:%02x %d %d %d", |
| 4168 | ifname, mac_addr[0], mac_addr[1], mac_addr[2], |
| 4169 | mac_addr[3], mac_addr[4], mac_addr[5], |
| 4170 | ap_ne_pref, ap_ne_class, ap_ne_op_ch); |
| 4171 | run_system(dut, buf); |
| 4172 | } |
| 4173 | |
| 4174 | /* Now add the self AP Address */ |
| 4175 | if (dut->mbo_self_ap_tuple.ap_ne_class == -1) { |
| 4176 | if (dut->ap_channel <= 11) |
| 4177 | ap_ne_class = 81; |
| 4178 | else |
| 4179 | ap_ne_class = 115; |
| 4180 | } else { |
| 4181 | ap_ne_class = dut->mbo_self_ap_tuple.ap_ne_class; |
| 4182 | } |
| 4183 | |
| 4184 | if (dut->mbo_self_ap_tuple.ap_ne_op_ch == -1) |
| 4185 | ap_ne_op_ch = dut->ap_channel; |
| 4186 | else |
| 4187 | ap_ne_op_ch = dut->mbo_self_ap_tuple.ap_ne_op_ch; |
| 4188 | |
| 4189 | if (dut->mbo_self_ap_tuple.ap_ne_pref == -1) |
| 4190 | ap_ne_pref = least_pref - 1; |
| 4191 | else |
| 4192 | ap_ne_pref = dut->mbo_self_ap_tuple.ap_ne_pref; |
| 4193 | |
| 4194 | snprintf(buf, sizeof(buf), |
| 4195 | "wifitool %s setbssidpref %02x:%02x:%02x:%02x:%02x:%02x %d %d %d", |
| 4196 | ifname, self_mac[0], self_mac[1], self_mac[2], |
| 4197 | self_mac[3], self_mac[4], self_mac[5], |
| 4198 | ap_ne_pref, |
| 4199 | ap_ne_class, |
| 4200 | ap_ne_op_ch); |
| 4201 | run_system(dut, buf); |
| 4202 | } |
| 4203 | |
| 4204 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4205 | static void ath_ap_set_params(struct sigma_dut *dut) |
| 4206 | { |
| 4207 | const char *basedev = "wifi1"; |
priyadharshini gowthaman | e161746 | 2017-04-25 12:03:59 -0700 | [diff] [blame] | 4208 | const char *ifname = get_main_ifname(); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4209 | int i; |
priyadharshini gowthaman | 8e26ff4 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 4210 | char buf[300]; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4211 | |
priyadharshini gowthaman | e161746 | 2017-04-25 12:03:59 -0700 | [diff] [blame] | 4212 | if (sigma_radio_ifname[0]) |
| 4213 | basedev = sigma_radio_ifname[0]; |
| 4214 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4215 | if (dut->ap_countrycode[0]) { |
| 4216 | snprintf(buf, sizeof(buf), "iwpriv %s setCountry %s", |
| 4217 | basedev, dut->ap_countrycode); |
| 4218 | if (system(buf) != 0) { |
| 4219 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4220 | "iwpriv setCountry failed"); |
| 4221 | } |
| 4222 | sigma_dut_print(dut, DUT_MSG_INFO, "Set countrycode"); |
| 4223 | } |
| 4224 | |
| 4225 | for (i = 0; i < NUM_AP_AC; i++) { |
| 4226 | if (dut->ap_qos[i].ac) { |
| 4227 | snprintf(buf, sizeof(buf), "iwpriv %s cwmin %d 0 %d", |
| 4228 | ifname, i, dut->ap_qos[i].cwmin); |
| 4229 | if (system(buf) != 0) { |
| 4230 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4231 | "iwpriv cwmin failed"); |
| 4232 | } |
| 4233 | |
| 4234 | snprintf(buf, sizeof(buf), "iwpriv %s cwmax %d 0 %d", |
| 4235 | ifname, i, dut->ap_qos[i].cwmax); |
| 4236 | if (system(buf) != 0) { |
| 4237 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4238 | "iwpriv cwmax failed"); |
| 4239 | } |
| 4240 | |
| 4241 | snprintf(buf, sizeof(buf), "iwpriv %s aifs %d 0 %d", |
| 4242 | ifname, i, dut->ap_qos[i].aifs); |
| 4243 | if (system(buf) != 0) { |
| 4244 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4245 | "iwpriv aifs failed"); |
| 4246 | } |
| 4247 | |
| 4248 | snprintf(buf, sizeof(buf), |
| 4249 | "iwpriv %s txoplimit %d 0 %d", |
| 4250 | ifname, i, dut->ap_qos[i].txop); |
| 4251 | if (system(buf) != 0) { |
| 4252 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4253 | "iwpriv txoplimit failed"); |
| 4254 | } |
| 4255 | |
| 4256 | snprintf(buf, sizeof(buf), "iwpriv %s acm %d 0 %d", |
| 4257 | ifname, i, dut->ap_qos[i].acm); |
| 4258 | if (system(buf) != 0) { |
| 4259 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4260 | "iwpriv acm failed"); |
| 4261 | } |
| 4262 | } |
| 4263 | } |
| 4264 | |
| 4265 | for (i = 0; i < NUM_AP_AC; i++) { |
| 4266 | if (dut->ap_sta_qos[i].ac) { |
| 4267 | snprintf(buf, sizeof(buf), "iwpriv %s cwmin %d 1 %d", |
| 4268 | ifname, i, dut->ap_sta_qos[i].cwmin); |
| 4269 | if (system(buf) != 0) { |
| 4270 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4271 | "iwpriv cwmin failed"); |
| 4272 | } |
| 4273 | |
| 4274 | snprintf(buf, sizeof(buf), "iwpriv %s cwmax %d 1 %d", |
| 4275 | ifname, i, dut->ap_sta_qos[i].cwmax); |
| 4276 | if (system(buf) != 0) { |
| 4277 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4278 | "iwpriv cwmax failed"); |
| 4279 | } |
| 4280 | |
| 4281 | snprintf(buf, sizeof(buf), "iwpriv %s aifs %d 1 %d", |
| 4282 | ifname, i, dut->ap_sta_qos[i].aifs); |
| 4283 | if (system(buf) != 0) { |
| 4284 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4285 | "iwpriv aifs failed"); |
| 4286 | } |
| 4287 | |
| 4288 | snprintf(buf, sizeof(buf), |
| 4289 | "iwpriv %s txoplimit %d 1 %d", |
| 4290 | ifname, i, dut->ap_sta_qos[i].txop); |
| 4291 | if (system(buf) != 0) { |
| 4292 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4293 | "iwpriv txoplimit failed"); |
| 4294 | } |
| 4295 | |
| 4296 | snprintf(buf, sizeof(buf), "iwpriv %s acm %d 1 %d", |
| 4297 | ifname, i, dut->ap_sta_qos[i].acm); |
| 4298 | if (system(buf) != 0) { |
| 4299 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4300 | "iwpriv acm failed"); |
| 4301 | } |
| 4302 | } |
| 4303 | } |
| 4304 | |
| 4305 | if (dut->ap_disable_protection == 1) { |
| 4306 | snprintf(buf, sizeof(buf), "iwpriv %s enablertscts 0", ifname); |
| 4307 | if (system(buf) != 0) { |
| 4308 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4309 | "iwpriv enablertscts failed"); |
| 4310 | } |
| 4311 | sigma_dut_print(dut, DUT_MSG_INFO, "Disabled rtscts"); |
| 4312 | } |
| 4313 | |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 4314 | if (dut->ap_ldpc == VALUE_ENABLED) { |
Sarvepalli, Rajesh Babu | 580572a | 2016-11-29 22:07:14 +0530 | [diff] [blame] | 4315 | snprintf(buf, sizeof(buf), "iwpriv %s ldpc 3", ifname); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4316 | if (system(buf) != 0) { |
| 4317 | sigma_dut_print(dut, DUT_MSG_ERROR, |
priyadharshini gowthaman | 15b299d | 2017-04-20 12:10:45 -0700 | [diff] [blame] | 4318 | "iwpriv ldpc 3 failed"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4319 | } |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 4320 | } else if (dut->ap_ldpc == VALUE_DISABLED) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4321 | snprintf(buf, sizeof(buf), "iwpriv %s ldpc 0", ifname); |
| 4322 | if (system(buf) != 0) { |
| 4323 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4324 | "iwpriv ldpc 0 failed"); |
| 4325 | } |
| 4326 | } |
| 4327 | |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 4328 | if (dut->ap_ampdu == VALUE_ENABLED) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4329 | snprintf(buf, sizeof(buf), "iwpriv %s ampdu 1", ifname); |
| 4330 | if (system(buf) != 0) { |
| 4331 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4332 | "iwpriv ampdu 1 failed"); |
| 4333 | } |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 4334 | } else if (dut->ap_ampdu == VALUE_DISABLED) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4335 | snprintf(buf, sizeof(buf), "iwpriv %s ampdu 0", ifname); |
| 4336 | if (system(buf) != 0) { |
| 4337 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4338 | "iwpriv ampdu 0 failed"); |
| 4339 | } |
| 4340 | } |
| 4341 | |
| 4342 | if (dut->ap_ampdu_exp) { |
| 4343 | if (dut->program == PROGRAM_VHT) { |
| 4344 | snprintf(buf, sizeof(buf), "iwpriv %s vhtmaxampdu %d", |
| 4345 | ifname, dut->ap_ampdu_exp); |
| 4346 | if (system(buf) != 0) { |
| 4347 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4348 | "iwpriv vhtmaxampdu failed"); |
| 4349 | } |
| 4350 | } else { |
| 4351 | /* 11N */ |
| 4352 | snprintf(buf, sizeof(buf), "iwpriv %s maxampdu %d", |
| 4353 | ifname, dut->ap_ampdu_exp); |
| 4354 | if (system(buf) != 0) { |
| 4355 | sigma_dut_print(dut, DUT_MSG_ERROR, "iwpriv maxampdu failed"); |
| 4356 | } |
| 4357 | } |
| 4358 | } |
| 4359 | |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 4360 | if (dut->ap_noack == VALUE_ENABLED) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4361 | snprintf(buf, sizeof(buf), "iwpriv %s noackpolicy 0 0 1", ifname); |
| 4362 | if (system(buf) != 0) { |
| 4363 | sigma_dut_print(dut, DUT_MSG_ERROR, "iwpriv noackpolicy 0 0 1 failed"); |
| 4364 | } |
| 4365 | snprintf(buf, sizeof(buf), "iwpriv %s noackpolicy 1 0 1", ifname); |
| 4366 | if (system(buf) != 0) { |
| 4367 | sigma_dut_print(dut, DUT_MSG_ERROR, "iwpriv noackpolicy 1 0 1 failed"); |
| 4368 | } |
| 4369 | snprintf(buf, sizeof(buf), "iwpriv %s noackpolicy 2 0 1", ifname); |
| 4370 | if (system(buf) != 0) { |
| 4371 | sigma_dut_print(dut, DUT_MSG_ERROR, "iwpriv noackpolicy 2 0 1 failed"); |
| 4372 | } |
| 4373 | snprintf(buf, sizeof(buf), "iwpriv %s noackpolicy 3 0 1", ifname); |
| 4374 | if (system(buf) != 0) { |
| 4375 | sigma_dut_print(dut, DUT_MSG_ERROR, "iwpriv noackpolicy 3 0 1 failed"); |
| 4376 | } |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 4377 | } else if (dut->ap_noack == VALUE_DISABLED) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4378 | snprintf(buf, sizeof(buf), "iwpriv %s noackpolicy 0 0 0", ifname); |
| 4379 | if (system(buf) != 0) { |
| 4380 | sigma_dut_print(dut, DUT_MSG_ERROR, "iwpriv noackpolicy 0 0 0 failed"); |
| 4381 | } |
| 4382 | snprintf(buf, sizeof(buf), "iwpriv %s noackpolicy 1 0 0", ifname); |
| 4383 | if (system(buf) != 0) { |
| 4384 | sigma_dut_print(dut, DUT_MSG_ERROR, "iwpriv noackpolicy 1 0 0 failed"); |
| 4385 | } |
| 4386 | snprintf(buf, sizeof(buf), "iwpriv %s noackpolicy 2 0 0", ifname); |
| 4387 | if (system(buf) != 0) { |
| 4388 | sigma_dut_print(dut, DUT_MSG_ERROR, "iwpriv noackpolicy 2 0 0 failed"); |
| 4389 | } |
| 4390 | snprintf(buf, sizeof(buf), "iwpriv %s noackpolicy 3 0 0", ifname); |
| 4391 | if (system(buf) != 0) { |
| 4392 | sigma_dut_print(dut, DUT_MSG_ERROR, "iwpriv noackpolicy 3 0 0 failed"); |
| 4393 | } |
| 4394 | } |
| 4395 | |
| 4396 | if (dut->device_type == AP_testbed && dut->ap_vhtmcs_map) { |
| 4397 | snprintf(buf, sizeof(buf), "iwpriv %s vht_mcsmap 0x%04x", |
| 4398 | ifname, dut->ap_vhtmcs_map); |
| 4399 | if (system(buf) != 0) { |
| 4400 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4401 | "iwpriv vht_mcsmap failed"); |
| 4402 | } |
| 4403 | } |
| 4404 | |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 4405 | if (dut->ap_amsdu == VALUE_ENABLED) { |
Sunil Dutt | 27ec7f6 | 2017-09-14 18:22:59 +0300 | [diff] [blame] | 4406 | snprintf(buf, sizeof(buf), "iwpriv %s amsdu 2", ifname); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4407 | if (system(buf) != 0) { |
Sunil Dutt | 27ec7f6 | 2017-09-14 18:22:59 +0300 | [diff] [blame] | 4408 | sigma_dut_print(dut, DUT_MSG_ERROR, "iwpriv amsdu 2 failed"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4409 | } |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 4410 | } else if (dut->ap_amsdu == VALUE_DISABLED) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4411 | snprintf(buf, sizeof(buf), "iwpriv %s amsdu 1", ifname); |
| 4412 | if (system(buf) != 0) { |
| 4413 | sigma_dut_print(dut, DUT_MSG_ERROR, "iwpriv amsdu 1 failed"); |
| 4414 | } |
| 4415 | } |
| 4416 | |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 4417 | if (dut->ap_rx_amsdu == VALUE_ENABLED) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4418 | snprintf(buf, sizeof(buf), "iwpriv wifi1 rx_amsdu 1"); |
| 4419 | if (system(buf) != 0) { |
| 4420 | sigma_dut_print(dut, DUT_MSG_ERROR, "iwpriv rx_amsdu 1 failed"); |
| 4421 | } |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 4422 | } else if (dut->ap_rx_amsdu == VALUE_DISABLED) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4423 | snprintf(buf, sizeof(buf), "iwpriv wifi1 rx_amsdu 0"); |
| 4424 | if (system(buf) != 0) { |
| 4425 | sigma_dut_print(dut, DUT_MSG_ERROR, "iwpriv rx_amsdu 0 failed"); |
| 4426 | } |
| 4427 | } |
| 4428 | |
| 4429 | /* Command sequence to generate single VHT AMSDU and MPDU */ |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 4430 | if (dut->ap_addba_reject != VALUE_NOT_SET && |
| 4431 | dut->ap_ampdu == VALUE_DISABLED && |
| 4432 | dut->ap_amsdu == VALUE_ENABLED) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4433 | snprintf(buf, sizeof(buf), "iwpriv %s setaddbaoper 1", ifname); |
| 4434 | if (system(buf) != 0) { |
| 4435 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4436 | "iwpriv setaddbaoper 1 failed"); |
| 4437 | } |
| 4438 | |
| 4439 | snprintf(buf, sizeof(buf), |
| 4440 | "wifitool %s senddelba 1 0 1 4", ifname); |
| 4441 | if (system(buf) != 0) { |
| 4442 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4443 | "wifitool senddelba failed"); |
| 4444 | } |
| 4445 | |
| 4446 | snprintf(buf, sizeof(buf), "wifitool %s sendsingleamsdu 1 0", |
| 4447 | ifname); |
| 4448 | if (system(buf) != 0) { |
| 4449 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4450 | "wifitool sendsingleamsdu failed"); |
| 4451 | } |
| 4452 | |
| 4453 | snprintf(buf, sizeof(buf), "iwpriv %s amsdu 10", ifname); |
| 4454 | if (system(buf) != 0) { |
| 4455 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4456 | "iwpriv amsdu failed"); |
| 4457 | } |
| 4458 | } |
| 4459 | |
| 4460 | if (dut->ap_mode == AP_11ac) { |
| 4461 | int chwidth, nss; |
| 4462 | |
| 4463 | switch (dut->ap_chwidth) { |
| 4464 | case AP_20: |
| 4465 | chwidth = 0; |
| 4466 | break; |
| 4467 | case AP_40: |
| 4468 | chwidth = 1; |
| 4469 | break; |
| 4470 | case AP_80: |
| 4471 | chwidth = 2; |
| 4472 | break; |
| 4473 | case AP_160: |
| 4474 | chwidth = 3; |
| 4475 | break; |
| 4476 | default: |
| 4477 | chwidth = 0; |
| 4478 | break; |
| 4479 | } |
| 4480 | |
| 4481 | switch (dut->ap_tx_streams) { |
| 4482 | case 1: |
| 4483 | nss = 1; |
| 4484 | break; |
| 4485 | case 2: |
| 4486 | nss = 2; |
| 4487 | break; |
| 4488 | case 3: |
| 4489 | nss = 3; |
| 4490 | break; |
| 4491 | case 4: |
| 4492 | nss = 4; |
| 4493 | break; |
| 4494 | default: |
| 4495 | nss = 3; |
| 4496 | break; |
| 4497 | } |
| 4498 | |
| 4499 | if (dut->ap_fixed_rate) { |
| 4500 | if (nss == 4) |
| 4501 | ath_disable_txbf(dut, ifname); |
| 4502 | |
| 4503 | /* Set the nss */ |
| 4504 | snprintf(buf, sizeof(buf), "iwpriv %s nss %d", |
| 4505 | ifname, nss); |
| 4506 | if (system(buf) != 0) { |
| 4507 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4508 | "iwpriv nss failed"); |
| 4509 | } |
| 4510 | |
| 4511 | /* Set the channel width */ |
| 4512 | snprintf(buf, sizeof(buf), "iwpriv %s chwidth %d", |
| 4513 | ifname, chwidth); |
| 4514 | if (system(buf) != 0) { |
| 4515 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4516 | "iwpriv chwidth failed"); |
| 4517 | } |
| 4518 | |
| 4519 | /* Set the VHT MCS */ |
| 4520 | snprintf(buf, sizeof(buf), "iwpriv %s vhtmcs %d", |
| 4521 | ifname, dut->ap_mcs); |
| 4522 | if (system(buf) != 0) { |
| 4523 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4524 | "iwpriv vhtmcs failed"); |
| 4525 | } |
| 4526 | } |
| 4527 | } |
| 4528 | |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 4529 | if (dut->ap_dyn_bw_sig == VALUE_ENABLED) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4530 | snprintf(buf, sizeof(buf), "iwpriv %s cwmenable 1", ifname); |
| 4531 | if (system(buf) != 0) { |
| 4532 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4533 | "iwpriv cwmenable 1 failed"); |
| 4534 | } |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 4535 | } else if (dut->ap_dyn_bw_sig == VALUE_DISABLED) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4536 | snprintf(buf, sizeof(buf), "iwpriv %s cwmenable 0", ifname); |
| 4537 | if (system(buf) != 0) { |
| 4538 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4539 | "iwpriv cwmenable 0 failed"); |
| 4540 | } |
| 4541 | } |
| 4542 | |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 4543 | if (dut->ap_sig_rts == VALUE_ENABLED) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4544 | snprintf(buf, sizeof(buf), "iwconfig %s rts 64", ifname); |
| 4545 | if (system(buf) != 0) { |
| 4546 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4547 | "iwconfig rts 64 failed"); |
| 4548 | } |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 4549 | } else if (dut->ap_sig_rts == VALUE_DISABLED) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4550 | snprintf(buf, sizeof(buf), "iwconfig %s rts 2347", ifname); |
| 4551 | if (system(buf) != 0) { |
| 4552 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4553 | "iwpriv rts 2347 failed"); |
| 4554 | } |
| 4555 | } |
| 4556 | |
| 4557 | if (dut->ap_hs2) { |
| 4558 | snprintf(buf, sizeof(buf), "iwpriv %s qbssload 1", ifname); |
| 4559 | if (system(buf) != 0) { |
| 4560 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4561 | "iwpriv qbssload failed"); |
| 4562 | } |
| 4563 | sigma_dut_print(dut, DUT_MSG_INFO, "Enabled qbssload"); |
| 4564 | } |
| 4565 | |
| 4566 | if (dut->ap_bss_load && dut->ap_bss_load != -1) { |
| 4567 | unsigned int bssload = 0; |
| 4568 | |
| 4569 | if (dut->ap_bss_load == 1) { |
| 4570 | /* STA count: 1, CU: 50, AAC: 65535 */ |
| 4571 | bssload = 0x0132ffff; |
| 4572 | } else if (dut->ap_bss_load == 2) { |
| 4573 | /* STA count: 1, CU: 200, AAC: 65535 */ |
| 4574 | bssload = 0x01c8ffff; |
| 4575 | } else if (dut->ap_bss_load == 3) { |
| 4576 | /* STA count: 1, CU: 75, AAC: 65535 */ |
| 4577 | bssload = 0x014bffff; |
| 4578 | } |
| 4579 | |
| 4580 | snprintf(buf, sizeof(buf), "iwpriv %s hcbssload %u", |
| 4581 | ifname, bssload); |
| 4582 | if (system(buf) != 0) { |
| 4583 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4584 | "iwpriv hcbssload failed"); |
| 4585 | } |
| 4586 | } else if (dut->ap_bss_load == 0) { |
| 4587 | snprintf(buf, sizeof(buf), "iwpriv %s qbssload 0", ifname); |
| 4588 | if (system(buf) != 0) { |
| 4589 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4590 | "iwpriv qbssload failed"); |
| 4591 | } |
| 4592 | sigma_dut_print(dut, DUT_MSG_INFO, "Disabled qbssload"); |
| 4593 | } |
| 4594 | |
| 4595 | if (dut->ap_dgaf_disable) { |
| 4596 | snprintf(buf, sizeof(buf), "iwpriv %s dgaf_disable 1", ifname); |
| 4597 | if (system(buf) != 0) { |
| 4598 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4599 | "iwpriv dgaf_disable failed"); |
| 4600 | } |
| 4601 | sigma_dut_print(dut, DUT_MSG_INFO, "Enabled dgaf_disable"); |
| 4602 | } |
| 4603 | |
| 4604 | if (dut->ap_l2tif) { |
| 4605 | snprintf(buf, sizeof(buf), "iwpriv %s l2tif 1", ifname); |
| 4606 | if (system(buf) != 0) { |
| 4607 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4608 | "iwpriv l2tif failed"); |
| 4609 | } |
| 4610 | snprintf(buf, sizeof(buf), |
| 4611 | "echo 1 > /sys/class/net/br0/brif/ath0/hotspot_l2tif"); |
| 4612 | if (system(buf) != 0) |
| 4613 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4614 | "l2tif br failed"); |
| 4615 | |
| 4616 | snprintf(buf, sizeof(buf), |
| 4617 | "echo 1 > /sys/class/net/br0/brif/eth0/hotspot_wan"); |
| 4618 | if (system(buf) != 0) |
| 4619 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4620 | "l2tif brif failed"); |
| 4621 | sigma_dut_print(dut, DUT_MSG_INFO, "Enabled l2tif"); |
| 4622 | } |
priyadharshini gowthaman | 264d544 | 2016-02-25 15:52:22 -0800 | [diff] [blame] | 4623 | |
| 4624 | if (dut->ap_ndpa_frame == 0) { |
| 4625 | snprintf(buf, sizeof(buf), |
| 4626 | "wifitool %s beeliner_fw_test 117 192", ifname); |
| 4627 | if (system(buf) != 0) { |
| 4628 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4629 | "wifitool beeliner_fw_test 117 192 failed"); |
| 4630 | } |
| 4631 | snprintf(buf, sizeof(buf), |
| 4632 | "wifitool %s beeliner_fw_test 118 192", ifname); |
| 4633 | if (system(buf) != 0) { |
| 4634 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4635 | "wifitool beeliner_fw_test 117 192 failed"); |
| 4636 | } |
| 4637 | } else if (dut->ap_ndpa_frame == 1) { |
| 4638 | /* Driver default - no changes needed */ |
| 4639 | } else if (dut->ap_ndpa_frame == 2) { |
| 4640 | snprintf(buf, sizeof(buf), |
| 4641 | "wifitool %s beeliner_fw_test 115 1", ifname); |
| 4642 | if (system(buf) != 0) { |
| 4643 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4644 | "wifitool beeliner_fw_test 117 192 failed"); |
| 4645 | } |
| 4646 | snprintf(buf, sizeof(buf), |
| 4647 | "wifitool %s beeliner_fw_test 116 1", ifname); |
| 4648 | if (system(buf) != 0) { |
| 4649 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4650 | "wifitool beeliner_fw_test 117 192 failed"); |
| 4651 | } |
| 4652 | } |
priyadharshini gowthaman | 8e26ff4 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 4653 | |
| 4654 | if (dut->ap_rtt == 1) { |
| 4655 | snprintf(buf, sizeof(buf), "iwpriv %s enable_rtt 1", ifname); |
| 4656 | run_system(dut, buf); |
| 4657 | } |
| 4658 | |
| 4659 | if (dut->ap_lci == 1) { |
| 4660 | snprintf(buf, sizeof(buf), "iwpriv %s enable_lci 1", ifname); |
| 4661 | run_system(dut, buf); |
| 4662 | } |
| 4663 | |
| 4664 | if (dut->ap_lcr == 1) { |
| 4665 | snprintf(buf, sizeof(buf), "iwpriv %s enable_lcr 1", ifname); |
| 4666 | run_system(dut, buf); |
| 4667 | } |
| 4668 | |
| 4669 | if (dut->ap_rrm == 1) { |
| 4670 | snprintf(buf, sizeof(buf), "iwpriv %s rrm 1", ifname); |
| 4671 | run_system(dut, buf); |
| 4672 | } |
| 4673 | |
| 4674 | if (dut->ap_lci == 1 || dut->ap_lcr == 1) { |
| 4675 | run_system(dut, "wpc -l /tmp/lci_cfg.txt"); |
| 4676 | } |
| 4677 | |
| 4678 | if (dut->ap_neighap >= 1 && dut->ap_lci == 0) { |
| 4679 | FILE *f; |
| 4680 | |
| 4681 | f = fopen("/tmp/nbr_report.txt", "w"); |
| 4682 | if (!f) { |
| 4683 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4684 | "Failed to open /tmp/nbr_report.txt"); |
| 4685 | return; |
| 4686 | } |
| 4687 | |
| 4688 | fprintf(f, |
| 4689 | "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", |
| 4690 | dut->ap_val_neighap[0][0], dut->ap_val_neighap[0][1], |
| 4691 | dut->ap_val_neighap[0][2], dut->ap_val_neighap[0][3], |
| 4692 | dut->ap_val_neighap[0][4], dut->ap_val_neighap[0][5], |
| 4693 | dut->ap_val_opchannel[0]); |
| 4694 | fclose(f); |
| 4695 | |
| 4696 | f = fopen("/tmp/ftmrr.txt", "w"); |
| 4697 | if (!f) { |
| 4698 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4699 | "Failed to open /tmp/ftmrr.txt"); |
| 4700 | return; |
| 4701 | } |
| 4702 | |
| 4703 | fprintf(f, |
| 4704 | "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", |
| 4705 | dut->ap_val_neighap[0][0], dut->ap_val_neighap[0][1], |
| 4706 | dut->ap_val_neighap[0][2], dut->ap_val_neighap[0][3], |
| 4707 | dut->ap_val_neighap[0][4], dut->ap_val_neighap[0][5], |
| 4708 | dut->ap_val_opchannel[0]); |
| 4709 | fclose(f); |
| 4710 | } |
| 4711 | |
| 4712 | if (dut->ap_neighap >= 2 && dut->ap_lci == 0) { |
| 4713 | FILE *f; |
| 4714 | |
| 4715 | f = fopen("/tmp/nbr_report.txt", "a"); |
| 4716 | if (!f) { |
| 4717 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4718 | "Failed to open /tmp/nbr_report.txt"); |
| 4719 | return; |
| 4720 | } |
| 4721 | fprintf(f, |
| 4722 | "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", |
| 4723 | dut->ap_val_neighap[1][0], dut->ap_val_neighap[1][1], |
| 4724 | dut->ap_val_neighap[1][2], dut->ap_val_neighap[1][3], |
| 4725 | dut->ap_val_neighap[1][4], dut->ap_val_neighap[1][5], |
| 4726 | dut->ap_val_opchannel[1]); |
| 4727 | fclose(f); |
| 4728 | |
| 4729 | f = fopen("/tmp/ftmrr.txt", "a"); |
| 4730 | if (!f) { |
| 4731 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4732 | "Failed to open /tmp/ftmrr.txt"); |
| 4733 | return; |
| 4734 | } |
| 4735 | fprintf(f, |
| 4736 | "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", |
| 4737 | dut->ap_val_neighap[1][0], dut->ap_val_neighap[1][1], |
| 4738 | dut->ap_val_neighap[1][2], dut->ap_val_neighap[1][3], |
| 4739 | dut->ap_val_neighap[1][4], dut->ap_val_neighap[1][5], |
| 4740 | dut->ap_val_opchannel[1]); |
| 4741 | fclose(f); |
| 4742 | } |
| 4743 | |
| 4744 | if (dut->ap_neighap >= 3 && dut->ap_lci == 0) { |
| 4745 | FILE *f; |
| 4746 | |
| 4747 | f = fopen("/tmp/nbr_report.txt", "a"); |
| 4748 | if (!f) { |
| 4749 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4750 | "Failed to open /tmp/nbr_report.txt"); |
| 4751 | return; |
| 4752 | } |
| 4753 | |
| 4754 | fprintf(f, |
| 4755 | "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", |
| 4756 | dut->ap_val_neighap[2][0], dut->ap_val_neighap[2][1], |
| 4757 | dut->ap_val_neighap[2][2], dut->ap_val_neighap[2][3], |
| 4758 | dut->ap_val_neighap[2][4], dut->ap_val_neighap[2][5], |
| 4759 | dut->ap_val_opchannel[2]); |
| 4760 | fclose(f); |
| 4761 | |
| 4762 | f = fopen("/tmp/ftmrr.txt", "a"); |
| 4763 | if (!f) { |
| 4764 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4765 | "Failed to open /tmp/ftmrr.txt"); |
| 4766 | return; |
| 4767 | } |
| 4768 | |
| 4769 | fprintf(f, |
| 4770 | "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", |
| 4771 | dut->ap_val_neighap[2][0], dut->ap_val_neighap[2][1], |
| 4772 | dut->ap_val_neighap[2][2], dut->ap_val_neighap[2][3], |
| 4773 | dut->ap_val_neighap[2][4], dut->ap_val_neighap[2][5], |
| 4774 | dut->ap_val_opchannel[2]); |
| 4775 | fclose(f); |
| 4776 | } |
| 4777 | |
| 4778 | if (dut->ap_neighap) { |
| 4779 | snprintf(buf, sizeof(buf), "iwpriv %s enable_rtt 1", ifname); |
| 4780 | run_system(dut, buf); |
| 4781 | snprintf(buf, sizeof(buf), "iwpriv %s enable_lci 1", ifname); |
| 4782 | run_system(dut, buf); |
| 4783 | snprintf(buf, sizeof(buf), "iwpriv %s enable_lcr 1", ifname); |
| 4784 | run_system(dut, buf); |
| 4785 | snprintf(buf, sizeof(buf), "iwpriv %s rrm 1", ifname); |
| 4786 | run_system(dut, buf); |
| 4787 | } |
| 4788 | |
| 4789 | if (dut->ap_scan == 1) { |
| 4790 | snprintf(buf, sizeof(buf), "iwpriv %s scanentryage 600", |
| 4791 | ifname); |
| 4792 | run_system(dut, buf); |
| 4793 | snprintf(buf, sizeof(buf), "iwlist %s scan", ifname); |
| 4794 | run_system(dut, buf); |
| 4795 | } |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 4796 | |
| 4797 | if (dut->ap_set_bssidpref) { |
| 4798 | snprintf(buf, sizeof(buf), |
| 4799 | "wifitool %s setbssidpref 00:00:00:00:00:00 0 00 00", |
| 4800 | ifname); |
| 4801 | if (system(buf) != 0) { |
| 4802 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4803 | "wifitool clear bssidpref failed"); |
| 4804 | } |
| 4805 | } |
Adil Saeed Musthafa | 33ea287 | 2017-04-10 23:13:24 -0700 | [diff] [blame] | 4806 | |
| 4807 | if (dut->wnm_bss_max_feature != VALUE_NOT_SET) { |
| 4808 | int feature_enable; |
| 4809 | |
| 4810 | feature_enable = dut->wnm_bss_max_feature == VALUE_ENABLED; |
| 4811 | snprintf(buf, sizeof(buf), "iwpriv %s wnm %d", |
| 4812 | ifname, feature_enable); |
| 4813 | run_system(dut, buf); |
| 4814 | snprintf(buf, sizeof(buf), "iwpriv %s wnm_bss %d", |
| 4815 | ifname, feature_enable); |
| 4816 | run_system(dut, buf); |
| 4817 | if (feature_enable) { |
| 4818 | const char *extra = ""; |
| 4819 | |
| 4820 | if (dut->wnm_bss_max_protection != VALUE_NOT_SET) { |
| 4821 | if (dut->wnm_bss_max_protection == |
| 4822 | VALUE_ENABLED) |
| 4823 | extra = " 1"; |
| 4824 | else |
| 4825 | extra = " 0"; |
| 4826 | } |
| 4827 | snprintf(buf, sizeof(buf), |
| 4828 | "wlanconfig %s wnm setbssmax %d%s", |
| 4829 | ifname, dut->wnm_bss_max_idle_time, extra); |
| 4830 | run_system(dut, buf); |
| 4831 | } |
| 4832 | } |
Adil Saeed Musthafa | 05ec744 | 2017-04-10 23:13:35 -0700 | [diff] [blame] | 4833 | |
Adil Saeed Musthafa | 023108a | 2017-04-10 23:13:37 -0700 | [diff] [blame] | 4834 | if (dut->program == PROGRAM_MBO) { |
Adil Saeed Musthafa | 6906372 | 2017-04-10 23:13:40 -0700 | [diff] [blame] | 4835 | apply_mbo_pref_ap_list(dut); |
| 4836 | |
Adil Saeed Musthafa | 023108a | 2017-04-10 23:13:37 -0700 | [diff] [blame] | 4837 | snprintf(buf, sizeof(buf), "iwpriv %s mbo_cel_pref %d", |
| 4838 | ifname, dut->ap_cell_cap_pref); |
| 4839 | run_system(dut, buf); |
Adil Saeed Musthafa | 16d9e63 | 2017-04-10 23:13:38 -0700 | [diff] [blame] | 4840 | |
| 4841 | snprintf(buf, sizeof(buf), "iwpriv %s mbocap 0x40", ifname); |
| 4842 | run_system(dut, buf); |
| 4843 | |
Adil Saeed Musthafa | 05ec744 | 2017-04-10 23:13:35 -0700 | [diff] [blame] | 4844 | ath_set_assoc_disallow(dut, ifname, "disable"); |
Adil Saeed Musthafa | 023108a | 2017-04-10 23:13:37 -0700 | [diff] [blame] | 4845 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4846 | } |
| 4847 | |
| 4848 | |
| 4849 | static int cmd_ath_ap_config_commit(struct sigma_dut *dut, |
| 4850 | struct sigma_conn *conn, |
| 4851 | struct sigma_cmd *cmd) |
| 4852 | { |
| 4853 | /* const char *name = get_param(cmd, "NAME"); */ |
| 4854 | char buf[100]; |
| 4855 | struct stat s; |
| 4856 | const char *ifname = dut->ap_is_dual ? "ath1" : "ath0"; |
| 4857 | |
| 4858 | if (stat("/proc/athversion", &s) == 0) { |
| 4859 | sigma_dut_print(dut, DUT_MSG_INFO, "Run apdown"); |
| 4860 | run_system(dut, "apdown"); |
| 4861 | } |
| 4862 | |
| 4863 | cmd_ath_ap_radio_config(dut); |
| 4864 | |
| 4865 | snprintf(buf, sizeof(buf), "cfg -a 'AP_SSID=%s'", dut->ap_ssid); |
| 4866 | run_system(dut, buf); |
| 4867 | |
| 4868 | switch (dut->ap_key_mgmt) { |
| 4869 | case AP_OPEN: |
| 4870 | if (dut->ap_cipher == AP_WEP) { |
| 4871 | run_system(dut, "cfg -a AP_SECMODE=WEP"); |
| 4872 | run_system(dut, "cfg -a AP_SECFILE=NONE"); |
| 4873 | /* shared auth mode not supported */ |
| 4874 | run_system(dut, "cfg -a AP_WEP_MODE_0=1"); |
| 4875 | run_system(dut, "cfg -a AP_WEP_MODE_1=1"); |
| 4876 | snprintf(buf, sizeof(buf), |
| 4877 | "cfg -a WEP_RADIO_NUM0_KEY_1=%s", |
| 4878 | dut->ap_wepkey); |
| 4879 | run_system(dut, buf); |
| 4880 | snprintf(buf, sizeof(buf), |
| 4881 | "cfg -a WEP_RADIO_NUM1_KEY_1=%s", |
| 4882 | dut->ap_wepkey); |
| 4883 | run_system(dut, buf); |
| 4884 | } else { |
| 4885 | run_system(dut, "cfg -a AP_SECMODE=None"); |
| 4886 | } |
| 4887 | break; |
| 4888 | case AP_WPA2_PSK: |
| 4889 | case AP_WPA2_PSK_MIXED: |
| 4890 | case AP_WPA_PSK: |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 4891 | case AP_WPA2_SAE: |
| 4892 | case AP_WPA2_PSK_SAE: |
| 4893 | if (dut->ap_key_mgmt == AP_WPA2_PSK || |
| 4894 | dut->ap_key_mgmt == AP_WPA2_SAE || |
| 4895 | dut->ap_key_mgmt == AP_WPA2_PSK_SAE) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4896 | run_system(dut, "cfg -a AP_WPA=2"); |
| 4897 | else if (dut->ap_key_mgmt == AP_WPA2_PSK_MIXED) |
| 4898 | run_system(dut, "cfg -a AP_WPA=3"); |
| 4899 | else |
| 4900 | run_system(dut, "cfg -a AP_WPA=1"); |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 4901 | /* TODO: SAE configuration */ |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4902 | run_system(dut, "cfg -a AP_SECMODE=WPA"); |
| 4903 | run_system(dut, "cfg -a AP_SECFILE=PSK"); |
| 4904 | snprintf(buf, sizeof(buf), "cfg -a 'PSK_KEY=%s'", |
| 4905 | dut->ap_passphrase); |
| 4906 | run_system(dut, buf); |
| 4907 | if (dut->ap_cipher == AP_CCMP_TKIP) |
| 4908 | run_system(dut, "cfg -a AP_CYPHER=\"CCMP TKIP\""); |
| 4909 | else if (dut->ap_cipher == AP_TKIP) |
| 4910 | run_system(dut, "cfg -a AP_CYPHER=TKIP"); |
| 4911 | else |
| 4912 | run_system(dut, "cfg -a AP_CYPHER=CCMP"); |
| 4913 | break; |
| 4914 | case AP_WPA2_EAP: |
| 4915 | case AP_WPA2_EAP_MIXED: |
| 4916 | case AP_WPA_EAP: |
| 4917 | if (dut->ap_key_mgmt == AP_WPA2_EAP) |
| 4918 | run_system(dut, "cfg -a AP_WPA=2"); |
| 4919 | else if (dut->ap_key_mgmt == AP_WPA2_EAP_MIXED) |
| 4920 | run_system(dut, "cfg -a AP_WPA=3"); |
| 4921 | else |
| 4922 | run_system(dut, "cfg -a AP_WPA=1"); |
| 4923 | run_system(dut, "cfg -a AP_SECMODE=WPA"); |
| 4924 | run_system(dut, "cfg -a AP_SECFILE=EAP"); |
| 4925 | if (dut->ap_cipher == AP_CCMP_TKIP) |
| 4926 | run_system(dut, "cfg -a AP_CYPHER=\"CCMP TKIP\""); |
| 4927 | else if (dut->ap_cipher == AP_TKIP) |
| 4928 | run_system(dut, "cfg -a AP_CYPHER=TKIP"); |
| 4929 | else |
| 4930 | run_system(dut, "cfg -a AP_CYPHER=CCMP"); |
| 4931 | snprintf(buf, sizeof(buf), "cfg -a AP_AUTH_SERVER=%s", |
| 4932 | dut->ap_radius_ipaddr); |
| 4933 | run_system(dut, buf); |
| 4934 | snprintf(buf, sizeof(buf), "cfg -a AP_AUTH_PORT=%d", |
| 4935 | dut->ap_radius_port); |
| 4936 | run_system(dut, buf); |
| 4937 | snprintf(buf, sizeof(buf), "cfg -a AP_AUTH_SECRET=%s", |
| 4938 | dut->ap_radius_password); |
| 4939 | run_system(dut, buf); |
| 4940 | break; |
Jouni Malinen | ad395a2 | 2017-09-01 21:13:46 +0300 | [diff] [blame] | 4941 | case AP_SUITEB: |
| 4942 | /* TODO */ |
| 4943 | sigma_dut_print(dut, DUT_MSG_ERROR, "SuiteB not supported"); |
| 4944 | break; |
Jouni Malinen | 147b3c3 | 2017-10-09 16:51:54 +0300 | [diff] [blame] | 4945 | case AP_WPA2_OWE: |
| 4946 | /* TODO */ |
| 4947 | sigma_dut_print(dut, DUT_MSG_ERROR, "OWE not supported"); |
| 4948 | break; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4949 | } |
| 4950 | |
| 4951 | if (dut->ap_is_dual) { |
| 4952 | /* ath1 settings in case of dual */ |
| 4953 | snprintf(buf, sizeof(buf), "cfg -a 'AP_SSID_2=%s'", |
| 4954 | dut->ap_ssid); |
| 4955 | run_system(dut, buf); |
| 4956 | |
| 4957 | switch (dut->ap_key_mgmt) { |
| 4958 | case AP_OPEN: |
| 4959 | if (dut->ap_cipher == AP_WEP) { |
| 4960 | run_system(dut, "cfg -a AP_SECMODE_2=WEP"); |
| 4961 | run_system(dut, "cfg -a AP_SECFILE_2=NONE"); |
| 4962 | /* shared auth mode not supported */ |
| 4963 | run_system(dut, "cfg -a AP_WEP_MODE_0=1"); |
| 4964 | run_system(dut, "cfg -a AP_WEP_MODE_1=1"); |
| 4965 | snprintf(buf, sizeof(buf), |
| 4966 | "cfg -a WEP_RADIO_NUM0_KEY_1=%s", |
| 4967 | dut->ap_wepkey); |
| 4968 | run_system(dut, buf); |
| 4969 | snprintf(buf, sizeof(buf), |
| 4970 | "cfg -a WEP_RADIO_NUM1_KEY_1=%s", |
| 4971 | dut->ap_wepkey); |
| 4972 | run_system(dut, buf); |
| 4973 | } else { |
| 4974 | run_system(dut, "cfg -a AP_SECMODE_2=None"); |
| 4975 | } |
| 4976 | break; |
| 4977 | case AP_WPA2_PSK: |
| 4978 | case AP_WPA2_PSK_MIXED: |
| 4979 | case AP_WPA_PSK: |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 4980 | case AP_WPA2_SAE: |
| 4981 | case AP_WPA2_PSK_SAE: |
| 4982 | if (dut->ap_key_mgmt == AP_WPA2_PSK || |
| 4983 | dut->ap_key_mgmt == AP_WPA2_SAE || |
| 4984 | dut->ap_key_mgmt == AP_WPA2_PSK_SAE) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4985 | run_system(dut, "cfg -a AP_WPA_2=2"); |
| 4986 | else if (dut->ap_key_mgmt == AP_WPA2_PSK_MIXED) |
| 4987 | run_system(dut, "cfg -a AP_WPA_2=3"); |
| 4988 | else |
| 4989 | run_system(dut, "cfg -a AP_WPA_2=1"); |
| 4990 | // run_system(dut, "cfg -a AP_WPA_2=2"); |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 4991 | /* TODO: SAE configuration */ |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4992 | run_system(dut, "cfg -a AP_SECMODE_2=WPA"); |
| 4993 | run_system(dut, "cfg -a AP_SECFILE_2=PSK"); |
| 4994 | snprintf(buf, sizeof(buf), "cfg -a 'PSK_KEY_2=%s'", |
| 4995 | dut->ap_passphrase); |
| 4996 | run_system(dut, buf); |
| 4997 | if (dut->ap_cipher == AP_CCMP_TKIP) |
| 4998 | run_system(dut, "cfg -a AP_CYPHER_2=\"CCMP TKIP\""); |
| 4999 | else if (dut->ap_cipher == AP_TKIP) |
| 5000 | run_system(dut, "cfg -a AP_CYPHER_2=TKIP"); |
| 5001 | else |
| 5002 | run_system(dut, "cfg -a AP_CYPHER_2=CCMP"); |
| 5003 | break; |
| 5004 | case AP_WPA2_EAP: |
| 5005 | case AP_WPA2_EAP_MIXED: |
| 5006 | case AP_WPA_EAP: |
| 5007 | if (dut->ap_key_mgmt == AP_WPA2_EAP) |
| 5008 | run_system(dut, "cfg -a AP_WPA_2=2"); |
| 5009 | else if (dut->ap_key_mgmt == AP_WPA2_EAP_MIXED) |
| 5010 | run_system(dut, "cfg -a AP_WPA_2=3"); |
| 5011 | else |
| 5012 | run_system(dut, "cfg -a AP_WPA_2=1"); |
| 5013 | run_system(dut, "cfg -a AP_SECMODE_2=WPA"); |
| 5014 | run_system(dut, "cfg -a AP_SECFILE_2=EAP"); |
| 5015 | if (dut->ap_cipher == AP_CCMP_TKIP) |
| 5016 | run_system(dut, "cfg -a AP_CYPHER_2=\"CCMP TKIP\""); |
| 5017 | else if (dut->ap_cipher == AP_TKIP) |
| 5018 | run_system(dut, "cfg -a AP_CYPHER_2=TKIP"); |
| 5019 | else |
| 5020 | run_system(dut, "cfg -a AP_CYPHER_2=CCMP"); |
| 5021 | |
| 5022 | snprintf(buf, sizeof(buf), "cfg -a AP_AUTH_SERVER_2=%s", |
| 5023 | dut->ap_radius_ipaddr); |
| 5024 | run_system(dut, buf); |
| 5025 | snprintf(buf, sizeof(buf), "cfg -a AP_AUTH_PORT_2=%d", |
| 5026 | dut->ap_radius_port); |
| 5027 | run_system(dut, buf); |
| 5028 | snprintf(buf, sizeof(buf), "cfg -a AP_AUTH_SECRET_2=%s", |
| 5029 | dut->ap_radius_password); |
| 5030 | run_system(dut, buf); |
| 5031 | break; |
Jouni Malinen | ad395a2 | 2017-09-01 21:13:46 +0300 | [diff] [blame] | 5032 | case AP_SUITEB: |
| 5033 | /* TODO */ |
| 5034 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5035 | "SuiteB not supported"); |
| 5036 | break; |
Jouni Malinen | 147b3c3 | 2017-10-09 16:51:54 +0300 | [diff] [blame] | 5037 | case AP_WPA2_OWE: |
| 5038 | /* TODO */ |
| 5039 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5040 | "OWE not supported"); |
| 5041 | break; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5042 | } |
| 5043 | |
| 5044 | /* wifi0 settings in case of dual */ |
| 5045 | run_system(dut, "cfg -a AP_RADIO_ID=0"); |
| 5046 | run_system(dut, "cfg -a AP_PRIMARY_CH=6"); |
| 5047 | run_system(dut, "cfg -a AP_STARTMODE=dual"); |
| 5048 | run_system(dut, "cfg -a AP_CHMODE=11NGHT40PLUS"); |
| 5049 | run_system(dut, "cfg -a TX_CHAINMASK=7"); |
| 5050 | run_system(dut, "cfg -a RX_CHAINMASK=7"); |
| 5051 | } |
| 5052 | |
| 5053 | switch (dut->ap_pmf) { |
| 5054 | case AP_PMF_DISABLED: |
| 5055 | snprintf(buf, sizeof(buf), "cfg -a AP_PMF=0"); |
| 5056 | run_system(dut, buf); |
| 5057 | break; |
| 5058 | case AP_PMF_OPTIONAL: |
| 5059 | snprintf(buf, sizeof(buf), "cfg -a AP_PMF=1"); |
| 5060 | run_system(dut, buf); |
| 5061 | break; |
| 5062 | case AP_PMF_REQUIRED: |
| 5063 | snprintf(buf, sizeof(buf), "cfg -a AP_PMF=2"); |
| 5064 | run_system(dut, buf); |
| 5065 | break; |
| 5066 | } |
| 5067 | if (dut->ap_add_sha256) { |
| 5068 | snprintf(buf, sizeof(buf), "cfg -a AP_WPA_SHA256=1"); |
| 5069 | run_system(dut, buf); |
| 5070 | } else { |
| 5071 | snprintf(buf, sizeof(buf), "cfg -r AP_WPA_SHA256"); |
| 5072 | run_system(dut, buf); |
| 5073 | } |
| 5074 | |
| 5075 | if (dut->ap_hs2) |
| 5076 | run_system(dut, "cfg -a AP_HOTSPOT=1"); |
| 5077 | else |
| 5078 | run_system(dut, "cfg -r AP_HOTSPOT"); |
| 5079 | |
| 5080 | if (dut->ap_interworking) { |
| 5081 | snprintf(buf, sizeof(buf), "cfg -a AP_HOTSPOT_ANT=%d", |
| 5082 | dut->ap_access_net_type); |
| 5083 | run_system(dut, buf); |
| 5084 | snprintf(buf, sizeof(buf), "cfg -a AP_HOTSPOT_INTERNET=%d", |
| 5085 | dut->ap_internet); |
| 5086 | run_system(dut, buf); |
| 5087 | snprintf(buf, sizeof(buf), "cfg -a AP_HOTSPOT_VENUEGROUP=%d", |
| 5088 | dut->ap_venue_group); |
| 5089 | run_system(dut, buf); |
| 5090 | snprintf(buf, sizeof(buf), "cfg -a AP_HOTSPOT_VENUETYPE=%d", |
| 5091 | dut->ap_venue_type); |
| 5092 | run_system(dut, buf); |
| 5093 | snprintf(buf, sizeof(buf), "cfg -a AP_HOTSPOT_HESSID=%s", |
| 5094 | dut->ap_hessid); |
| 5095 | run_system(dut, buf); |
| 5096 | |
| 5097 | if (dut->ap_roaming_cons[0]) { |
| 5098 | char *second, *rc; |
| 5099 | rc = strdup(dut->ap_roaming_cons); |
| 5100 | if (rc == NULL) |
| 5101 | return 0; |
| 5102 | |
| 5103 | second = strchr(rc, ';'); |
| 5104 | if (second) |
| 5105 | *second++ = '\0'; |
| 5106 | |
| 5107 | snprintf(buf, sizeof(buf), |
| 5108 | "cfg -a AP_HOTSPOT_ROAMINGCONSORTIUM=%s", rc); |
| 5109 | run_system(dut, buf); |
| 5110 | |
| 5111 | if (second) { |
| 5112 | snprintf(buf, sizeof(buf), |
| 5113 | "cfg -a AP_HOTSPOT_ROAMINGCONSORTIUM2" |
| 5114 | "=%s", second); |
| 5115 | run_system(dut, buf); |
| 5116 | } |
| 5117 | free(rc); |
| 5118 | } else { |
| 5119 | run_system(dut, "cfg -r AP_HOTSPOT_ROAMINGCONSORTIUM"); |
| 5120 | run_system(dut, |
| 5121 | "cfg -r AP_HOTSPOT_ROAMINGCONSORTIUM2"); |
| 5122 | } |
| 5123 | } else { |
| 5124 | run_system(dut, "cfg -r AP_HOTSPOT_ANT"); |
| 5125 | run_system(dut, "cfg -r AP_HOTSPOT_INTERNET"); |
| 5126 | run_system(dut, "cfg -r AP_HOTSPOT_VENUEGROUP"); |
| 5127 | run_system(dut, "cfg -r AP_HOTSPOT_VENUETYPE"); |
| 5128 | run_system(dut, "cfg -r AP_HOTSPOT_HESSID"); |
| 5129 | run_system(dut, "cfg -r AP_HOTSPOT_ROAMINGCONSORTIUM"); |
| 5130 | run_system(dut, "cfg -r AP_HOTSPOT_ROAMINGCONSORTIUM2"); |
| 5131 | } |
| 5132 | |
| 5133 | if (dut->ap_proxy_arp) |
| 5134 | run_system(dut, "cfg -a IEEE80211V_PROXYARP=1"); |
| 5135 | else |
| 5136 | run_system(dut, "cfg -a IEEE80211V_PROXYARP=0"); |
| 5137 | if (dut->ap_dgaf_disable) |
| 5138 | run_system(dut, "cfg -a AP_HOTSPOT_DISABLE_DGAF=1"); |
| 5139 | else |
| 5140 | run_system(dut, "cfg -r AP_HOTSPOT_DISABLE_DGAF"); |
| 5141 | |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 5142 | if (strlen(dut->ap_tag_ssid[0])) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5143 | snprintf(buf, sizeof(buf), |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 5144 | "cfg -a AP_SSID_2=%s", dut->ap_tag_ssid[0]); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5145 | run_system(dut, buf); |
| 5146 | |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 5147 | if (dut->ap_tag_key_mgmt[0] == AP2_OSEN) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5148 | run_system(dut, "cfg -a AP_SECMODE_2=WPA"); |
| 5149 | run_system(dut, "cfg -a AP_SECFILE_2=OSEN"); |
| 5150 | |
| 5151 | snprintf(buf, sizeof(buf), "cfg -a AP_AUTH_SERVER_2=%s", |
| 5152 | dut->ap2_radius_ipaddr); |
| 5153 | run_system(dut, buf); |
| 5154 | |
| 5155 | snprintf(buf, sizeof(buf), "cfg -a AP_AUTH_PORT_2=%d", |
| 5156 | dut->ap2_radius_port); |
| 5157 | run_system(dut, buf); |
| 5158 | |
| 5159 | snprintf(buf, sizeof(buf), "cfg -a AP_AUTH_SECRET_2=%s", |
| 5160 | dut->ap2_radius_password); |
| 5161 | run_system(dut, buf); |
| 5162 | } else { |
| 5163 | run_system(dut, "cfg -a AP_SECMODE_2=None"); |
| 5164 | run_system(dut, "cfg -r AP_AUTH_SERVER_2"); |
| 5165 | run_system(dut, "cfg -r AP_AUTH_PORT_2"); |
| 5166 | run_system(dut, "cfg -r AP_AUTH_SECRET_2"); |
| 5167 | } |
| 5168 | |
| 5169 | run_system(dut, "cfg -a AP_STARTMODE=multi"); |
| 5170 | } |
| 5171 | |
| 5172 | run_system(dut, "cfg -c"); |
| 5173 | |
| 5174 | sigma_dut_print(dut, DUT_MSG_INFO, "Starting AP"); |
| 5175 | if (system("apup") != 0) { |
| 5176 | /* to be debugged why apup returns error |
| 5177 | send_resp(dut, conn, SIGMA_ERROR, |
| 5178 | "errorCode,apup failed"); |
| 5179 | return 0; |
| 5180 | */ |
| 5181 | } |
| 5182 | sigma_dut_print(dut, DUT_MSG_INFO, "AP started"); |
| 5183 | |
| 5184 | if (dut->ap_key_mgmt != AP_OPEN) { |
| 5185 | int res; |
| 5186 | /* allow some time for hostapd to start before returning |
| 5187 | * success */ |
| 5188 | usleep(500000); |
| 5189 | if (run_hostapd_cli(dut, "ping") != 0) { |
| 5190 | send_resp(dut, conn, SIGMA_ERROR, |
| 5191 | "errorCode,Failed to talk to hostapd"); |
| 5192 | return 0; |
| 5193 | } |
| 5194 | |
| 5195 | if (dut->ap_hs2 && !dut->ap_anqpserver) { |
| 5196 | /* the cfg app doesn't like ";" in the variables */ |
| 5197 | res = ath_ap_append_hostapd_conf(dut); |
| 5198 | if (res < 0) |
| 5199 | return res; |
| 5200 | |
| 5201 | /* wait for hostapd to be ready */ |
| 5202 | usleep(500000); |
| 5203 | if (run_hostapd_cli(dut, "ping") != 0) { |
| 5204 | send_resp(dut, conn, SIGMA_ERROR, |
| 5205 | "errorCode,Failed to talk to " |
| 5206 | "hostapd"); |
| 5207 | return 0; |
| 5208 | } |
| 5209 | } |
| 5210 | } |
| 5211 | |
| 5212 | ath_ap_set_params(dut); |
| 5213 | |
| 5214 | if (dut->ap_anqpserver) |
| 5215 | return cmd_ath_ap_anqpserver_start(dut); |
| 5216 | |
| 5217 | if (dut->ap2_proxy_arp) |
| 5218 | run_system(dut, "iwpriv ath1 proxy_arp 1"); |
| 5219 | |
| 5220 | if (dut->ap_allow_vht_wep || dut->ap_allow_vht_tkip) { |
| 5221 | snprintf(buf, sizeof(buf), "iwpriv %s htweptkip 1", ifname); |
| 5222 | if (system(buf) != 0) { |
| 5223 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5224 | "iwpriv htweptkip failed"); |
| 5225 | } |
| 5226 | } |
| 5227 | |
| 5228 | return 1; |
| 5229 | } |
| 5230 | |
| 5231 | |
| 5232 | static int set_ebtables_proxy_arp(struct sigma_dut *dut, const char *chain, |
| 5233 | const char *ifname) |
| 5234 | { |
| 5235 | char buf[200]; |
| 5236 | |
| 5237 | if (!chain || !ifname) |
| 5238 | return -2; |
| 5239 | |
| 5240 | snprintf(buf, sizeof(buf), "ebtables -P %s ACCEPT", chain); |
| 5241 | if (system(buf) != 0) { |
| 5242 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5243 | "Failed to set ebtables rules, RULE-1, %s", |
| 5244 | chain); |
| 5245 | return -2; |
| 5246 | } |
| 5247 | |
| 5248 | snprintf(buf, sizeof(buf), |
| 5249 | "ebtables -A %s -p ARP -d Broadcast -o %s -j DROP", |
| 5250 | chain, ifname); |
| 5251 | if (system(buf) != 0) { |
| 5252 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5253 | "Failed to set ebtables rules, RULE-2, %s", |
| 5254 | chain); |
| 5255 | return -2; |
| 5256 | } |
| 5257 | |
| 5258 | snprintf(buf, sizeof(buf), |
| 5259 | "ebtables -A %s -d Multicast -p IPv6 --ip6-protocol ipv6-icmp --ip6-icmp-type neighbor-solicitation -o %s -j DROP", |
| 5260 | chain, ifname); |
| 5261 | if (system(buf) != 0) { |
| 5262 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5263 | "Failed to set ebtables rules, RULE-3, %s", |
| 5264 | chain); |
| 5265 | return -2; |
| 5266 | } |
| 5267 | |
| 5268 | snprintf(buf, sizeof(buf), |
| 5269 | "ebtables -A %s -d Multicast -p IPv6 --ip6-protocol ipv6-icmp --ip6-icmp-type neighbor-advertisement -o %s -j DROP", |
| 5270 | chain, ifname); |
| 5271 | if (system(buf) != 0) { |
| 5272 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5273 | "Failed to set ebtables rules, RULE-4, %s", |
| 5274 | chain); |
| 5275 | return -2; |
| 5276 | } |
| 5277 | |
| 5278 | return 0; |
| 5279 | } |
| 5280 | |
| 5281 | |
| 5282 | static int set_ebtables_disable_dgaf(struct sigma_dut *dut, |
| 5283 | const char *chain, |
| 5284 | const char *ifname) |
| 5285 | { |
| 5286 | char buf[200]; |
| 5287 | |
| 5288 | if (!chain || !ifname) |
| 5289 | return -2; |
| 5290 | |
| 5291 | snprintf(buf, sizeof(buf), "ebtables -P %s ACCEPT", chain); |
| 5292 | if (system(buf) != 0) { |
| 5293 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5294 | "Failed to set ebtables rules, RULE-5, %s", |
| 5295 | chain); |
| 5296 | return -2; |
| 5297 | } |
| 5298 | |
| 5299 | snprintf(buf, sizeof(buf), |
| 5300 | "ebtables -A %s -p ARP -d Broadcast -o %s -j DROP", |
| 5301 | chain, ifname); |
| 5302 | if (system(buf) != 0) { |
| 5303 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5304 | "Failed to set ebtables rules, RULE-6, %s", |
| 5305 | chain); |
| 5306 | return -2; |
| 5307 | } |
| 5308 | |
| 5309 | snprintf(buf, sizeof(buf), |
| 5310 | "ebtables -A %s -p IPv4 -d Multicast -o %s -j DROP", |
| 5311 | chain, ifname); |
| 5312 | if (system(buf) != 0) { |
| 5313 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5314 | "Failed to set ebtables rules, RULE-7, %s", |
| 5315 | chain); |
| 5316 | return -2; |
| 5317 | } |
| 5318 | |
| 5319 | snprintf(buf, sizeof(buf), |
| 5320 | "ebtables -A %s -p IPv6 -d Multicast -o %s -j DROP", |
| 5321 | chain, ifname); |
| 5322 | if (system(buf) != 0) { |
| 5323 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5324 | "Failed to set ebtables rules, RULE-8, %s", |
| 5325 | chain); |
| 5326 | return -2; |
| 5327 | } |
| 5328 | |
| 5329 | return 0; |
| 5330 | } |
| 5331 | |
| 5332 | |
| 5333 | static int check_channel(int channel) |
| 5334 | { |
| 5335 | int channel_list[] = { 36, 40, 44, 48, 52, 60, 64, 100, 104, 108, 112, |
| 5336 | 116, 120, 124, 128, 132, 140, 144, 149, 153, 157, |
| 5337 | 161, 165 }; |
| 5338 | int num_chan = sizeof(channel_list) / sizeof(int); |
| 5339 | int i; |
| 5340 | |
| 5341 | for (i = 0; i < num_chan; i++) { |
| 5342 | if (channel == channel_list[i]) |
| 5343 | return i; |
| 5344 | } |
| 5345 | |
| 5346 | return -1; |
| 5347 | } |
| 5348 | |
| 5349 | |
| 5350 | static int get_oper_centr_freq_seq_idx(int chwidth, int channel) |
| 5351 | { |
| 5352 | int ch_base; |
| 5353 | int period; |
| 5354 | |
| 5355 | if (check_channel(channel) < 0) |
| 5356 | return -1; |
| 5357 | |
| 5358 | if (channel >= 36 && channel <= 64) |
| 5359 | ch_base = 36; |
| 5360 | else if (channel >= 100 && channel <= 144) |
| 5361 | ch_base = 100; |
| 5362 | else |
| 5363 | ch_base = 149; |
| 5364 | |
| 5365 | period = channel % ch_base * 5 / chwidth; |
| 5366 | return ch_base + period * chwidth / 5 + (chwidth - 20) / 10; |
| 5367 | } |
| 5368 | |
| 5369 | |
| 5370 | static int is_ht40plus_chan(int chan) |
| 5371 | { |
| 5372 | return chan == 36 || chan == 44 || chan == 52 || chan == 60 || |
| 5373 | chan == 100 || chan == 108 || chan == 116 || chan == 124 || |
| 5374 | chan == 132 || chan == 149 || chan == 157; |
| 5375 | } |
| 5376 | |
| 5377 | |
| 5378 | static int is_ht40minus_chan(int chan) |
| 5379 | { |
| 5380 | return chan == 40 || chan == 48 || chan == 56 || chan == 64 || |
| 5381 | chan == 104 || chan == 112 || chan == 120 || chan == 128 || |
| 5382 | chan == 136 || chan == 153 || chan == 161; |
| 5383 | } |
| 5384 | |
| 5385 | |
Mohammed Shafi Shajakhan | b53d8f9 | 2017-02-28 09:05:15 +0530 | [diff] [blame] | 5386 | static int get_5g_channel_freq(int chan) |
| 5387 | { |
| 5388 | return 5000 + chan * 5; |
| 5389 | } |
| 5390 | |
| 5391 | |
Jouni Malinen | 3d633da | 2017-09-14 22:19:21 +0300 | [diff] [blame] | 5392 | static const char * hostapd_cipher_name(enum ap_cipher cipher) |
| 5393 | { |
| 5394 | switch (cipher) { |
| 5395 | case AP_CCMP: |
| 5396 | return "CCMP"; |
| 5397 | case AP_TKIP: |
| 5398 | return "TKIP"; |
| 5399 | case AP_CCMP_TKIP: |
| 5400 | return "CCMP TKIP"; |
| 5401 | case AP_GCMP_256: |
| 5402 | return "GCMP-256"; |
| 5403 | case AP_GCMP_128: |
| 5404 | return "GCMP"; |
| 5405 | case AP_CCMP_256: |
| 5406 | return "CCMP-256"; |
| 5407 | default: |
| 5408 | return "UNKNOWN"; |
| 5409 | } |
| 5410 | } |
| 5411 | |
| 5412 | |
| 5413 | static const char * |
| 5414 | hostapd_group_mgmt_cipher_name(enum ap_group_mgmt_cipher cipher) |
| 5415 | { |
| 5416 | switch (cipher) { |
| 5417 | case AP_BIP_GMAC_256: |
| 5418 | return "BIP-GMAC-128"; |
| 5419 | case AP_BIP_CMAC_256: |
| 5420 | return "BIP-CMAC-256"; |
| 5421 | case AP_BIP_GMAC_128: |
| 5422 | return "BIP-GMAC-128"; |
| 5423 | case AP_BIP_CMAC_128: |
| 5424 | return "AES-128-CMAC"; |
| 5425 | default: |
| 5426 | return "UNKNOWN"; |
| 5427 | } |
| 5428 | } |
| 5429 | |
| 5430 | |
Jouni Malinen | a326d7b | 2017-09-04 13:46:02 +0300 | [diff] [blame] | 5431 | int cmd_ap_config_commit(struct sigma_dut *dut, struct sigma_conn *conn, |
| 5432 | struct sigma_cmd *cmd) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5433 | { |
| 5434 | /* const char *name = get_param(cmd, "NAME"); */ |
| 5435 | FILE *f; |
| 5436 | const char *ifname; |
| 5437 | char buf[500]; |
| 5438 | char path[100]; |
| 5439 | enum driver_type drv; |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 5440 | const char *key_mgmt; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5441 | |
| 5442 | drv = get_driver_type(); |
| 5443 | |
| 5444 | if (dut->mode == SIGMA_MODE_STATION) { |
| 5445 | stop_sta_mode(dut); |
| 5446 | sleep(1); |
| 5447 | } |
| 5448 | |
| 5449 | if (dut->mode == SIGMA_MODE_SNIFFER && dut->sniffer_ifname) { |
| 5450 | snprintf(buf, sizeof(buf), "ifconfig %s down", |
| 5451 | dut->sniffer_ifname); |
| 5452 | if (system(buf) != 0) { |
| 5453 | sigma_dut_print(dut, DUT_MSG_INFO, |
| 5454 | "Failed to run '%s'", buf); |
| 5455 | } |
| 5456 | snprintf(buf, sizeof(buf), "iw dev %s set type station", |
| 5457 | dut->sniffer_ifname); |
| 5458 | if (system(buf) != 0) { |
| 5459 | sigma_dut_print(dut, DUT_MSG_INFO, |
| 5460 | "Failed to run '%s'", buf); |
| 5461 | } |
| 5462 | } |
| 5463 | |
| 5464 | dut->mode = SIGMA_MODE_AP; |
| 5465 | |
| 5466 | if (drv == DRIVER_ATHEROS) |
| 5467 | return cmd_ath_ap_config_commit(dut, conn, cmd); |
| 5468 | if (drv == DRIVER_WCN) |
| 5469 | return cmd_wcn_ap_config_commit(dut, conn, cmd); |
| 5470 | if (drv == DRIVER_OPENWRT) |
| 5471 | return cmd_owrt_ap_config_commit(dut, conn, cmd); |
| 5472 | |
| 5473 | f = fopen(SIGMA_TMPDIR "/sigma_dut-ap.conf", "w"); |
| 5474 | if (f == NULL) { |
| 5475 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5476 | "%s: Failed to open sigma_dut-ap.conf", |
| 5477 | __func__); |
| 5478 | return -2; |
| 5479 | } |
| 5480 | switch (dut->ap_mode) { |
| 5481 | case AP_11g: |
| 5482 | case AP_11b: |
| 5483 | case AP_11ng: |
Pradeep Reddy Potteti | 08eaeba | 2017-06-14 12:43:19 +0530 | [diff] [blame] | 5484 | ifname = (drv == DRIVER_MAC80211) ? "wlan0" : "ath0"; |
| 5485 | if ((drv == DRIVER_QNXNTO || drv == DRIVER_LINUX_WCN) && |
| 5486 | sigma_main_ifname) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5487 | ifname = sigma_main_ifname; |
| 5488 | fprintf(f, "hw_mode=g\n"); |
| 5489 | break; |
| 5490 | case AP_11a: |
| 5491 | case AP_11na: |
| 5492 | case AP_11ac: |
Pradeep Reddy Potteti | 08eaeba | 2017-06-14 12:43:19 +0530 | [diff] [blame] | 5493 | if (drv == DRIVER_QNXNTO || drv == DRIVER_LINUX_WCN) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5494 | if (sigma_main_ifname) |
| 5495 | ifname = sigma_main_ifname; |
| 5496 | else |
| 5497 | ifname = "wlan0"; |
Pradeep Reddy Potteti | 08eaeba | 2017-06-14 12:43:19 +0530 | [diff] [blame] | 5498 | } else if (drv == DRIVER_MAC80211) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5499 | if (if_nametoindex("wlan1") > 0) |
| 5500 | ifname = "wlan1"; |
| 5501 | else |
| 5502 | ifname = "wlan0"; |
| 5503 | } else { |
| 5504 | ifname = get_main_ifname(); |
| 5505 | } |
| 5506 | fprintf(f, "hw_mode=a\n"); |
| 5507 | break; |
| 5508 | default: |
| 5509 | fclose(f); |
| 5510 | return -1; |
| 5511 | } |
Jouni Malinen | d6bf1b4 | 2017-06-23 17:51:01 +0300 | [diff] [blame] | 5512 | if (dut->hostapd_ifname) |
| 5513 | ifname = dut->hostapd_ifname; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5514 | |
Sreelakshmi Konamki | b692f10 | 2016-04-26 19:47:00 +0530 | [diff] [blame] | 5515 | if (drv == DRIVER_MAC80211 || drv == DRIVER_LINUX_WCN) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5516 | fprintf(f, "driver=nl80211\n"); |
| 5517 | |
Sreelakshmi Konamki | b692f10 | 2016-04-26 19:47:00 +0530 | [diff] [blame] | 5518 | if ((drv == DRIVER_MAC80211 || drv == DRIVER_QNXNTO || |
| 5519 | drv == DRIVER_LINUX_WCN) && |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5520 | (dut->ap_mode == AP_11ng || dut->ap_mode == AP_11na)) { |
Tamizh chelvam | 431c600 | 2017-03-07 17:07:16 +0530 | [diff] [blame] | 5521 | int ht40plus = 0, ht40minus = 0, tx_stbc = 0; |
| 5522 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5523 | fprintf(f, "ieee80211n=1\n"); |
Pradeep Reddy Potteti | bf8af29 | 2017-02-15 15:28:39 +0530 | [diff] [blame] | 5524 | if (dut->ap_mode == AP_11ng && |
| 5525 | (dut->ap_chwidth == AP_40 || |
| 5526 | (dut->ap_chwidth == AP_AUTO && |
| 5527 | dut->default_11ng_ap_chwidth == AP_40))) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5528 | if (dut->ap_channel >= 1 && dut->ap_channel <= 7) |
Tamizh chelvam | 431c600 | 2017-03-07 17:07:16 +0530 | [diff] [blame] | 5529 | ht40plus = 1; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5530 | else if (dut->ap_channel >= 8 && dut->ap_channel <= 11) |
Tamizh chelvam | 431c600 | 2017-03-07 17:07:16 +0530 | [diff] [blame] | 5531 | ht40minus = 1; |
| 5532 | fprintf(f, "obss_interval=300\n"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5533 | } |
| 5534 | |
| 5535 | /* configure ht_capab based on channel width */ |
| 5536 | if (dut->ap_mode == AP_11na && |
| 5537 | (dut->ap_chwidth == AP_40 || |
| 5538 | (dut->ap_chwidth == AP_AUTO && |
Pradeep Reddy Potteti | bf8af29 | 2017-02-15 15:28:39 +0530 | [diff] [blame] | 5539 | dut->default_11na_ap_chwidth == AP_40))) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5540 | if (is_ht40plus_chan(dut->ap_channel)) |
Tamizh chelvam | 431c600 | 2017-03-07 17:07:16 +0530 | [diff] [blame] | 5541 | ht40plus = 1; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5542 | else if (is_ht40minus_chan(dut->ap_channel)) |
Tamizh chelvam | 431c600 | 2017-03-07 17:07:16 +0530 | [diff] [blame] | 5543 | ht40minus = 1; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5544 | } |
Mohammed Shafi Shajakhan | 31d8a15 | 2016-06-02 20:10:55 +0530 | [diff] [blame] | 5545 | |
| 5546 | if (dut->ap_tx_stbc) |
Tamizh chelvam | 431c600 | 2017-03-07 17:07:16 +0530 | [diff] [blame] | 5547 | tx_stbc = 1; |
Mohammed Shafi Shajakhan | 31d8a15 | 2016-06-02 20:10:55 +0530 | [diff] [blame] | 5548 | |
Pradeep Reddy Potteti | 4b0cdee | 2017-03-15 12:37:33 +0530 | [diff] [blame] | 5549 | /* Overwrite the ht_capab with offset value if configured */ |
| 5550 | if (dut->ap_chwidth == AP_40 && |
| 5551 | dut->ap_chwidth_offset == SEC_CH_40ABOVE) { |
| 5552 | ht40plus = 1; |
| 5553 | ht40minus = 0; |
| 5554 | } else if (dut->ap_chwidth == AP_40 && |
| 5555 | dut->ap_chwidth_offset == SEC_CH_40BELOW) { |
| 5556 | ht40minus = 1; |
| 5557 | ht40plus = 0; |
| 5558 | } |
| 5559 | |
Tamizh chelvam | 431c600 | 2017-03-07 17:07:16 +0530 | [diff] [blame] | 5560 | fprintf(f, "ht_capab=%s%s%s\n", |
| 5561 | ht40plus ? "[HT40+]" : "", |
| 5562 | ht40minus ? "[HT40-]" : "", |
| 5563 | tx_stbc ? "[TX-STBC]" : ""); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5564 | } |
| 5565 | |
Sreelakshmi Konamki | b692f10 | 2016-04-26 19:47:00 +0530 | [diff] [blame] | 5566 | if ((drv == DRIVER_MAC80211 || drv == DRIVER_QNXNTO || |
| 5567 | drv == DRIVER_LINUX_WCN) && |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5568 | dut->ap_mode == AP_11ac) { |
| 5569 | fprintf(f, "ieee80211ac=1\n" |
| 5570 | "ieee80211n=1\n" |
| 5571 | "ht_capab=[HT40+]\n"); |
| 5572 | } |
| 5573 | |
Sreelakshmi Konamki | b692f10 | 2016-04-26 19:47:00 +0530 | [diff] [blame] | 5574 | if ((drv == DRIVER_MAC80211 || drv == DRIVER_QNXNTO || |
| 5575 | drv == DRIVER_LINUX_WCN) && |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5576 | (dut->ap_mode == AP_11ac || dut->ap_mode == AP_11na)) { |
| 5577 | if (dut->ap_countrycode[0]) { |
| 5578 | fprintf(f, "country_code=%s\n", dut->ap_countrycode); |
| 5579 | fprintf(f, "ieee80211d=1\n"); |
| 5580 | fprintf(f, "ieee80211h=1\n"); |
| 5581 | } |
| 5582 | } |
| 5583 | |
| 5584 | fprintf(f, "interface=%s\n", ifname); |
| 5585 | if (dut->bridge) |
| 5586 | fprintf(f, "bridge=%s\n", dut->bridge); |
| 5587 | fprintf(f, "channel=%d\n", dut->ap_channel); |
| 5588 | |
| 5589 | if (sigma_hapd_ctrl) |
| 5590 | fprintf(f, "ctrl_interface=%s\n", sigma_hapd_ctrl); |
| 5591 | else |
| 5592 | fprintf(f, "ctrl_interface=/var/run/hostapd\n"); |
| 5593 | |
| 5594 | if (dut->ap_ssid[0]) |
| 5595 | fprintf(f, "ssid=%s\n", dut->ap_ssid); |
| 5596 | else |
| 5597 | fprintf(f, "ssid=QCA AP OOB\n"); |
| 5598 | if (dut->ap_bcnint) |
| 5599 | fprintf(f, "beacon_int=%d\n", dut->ap_bcnint); |
| 5600 | |
| 5601 | switch (dut->ap_key_mgmt) { |
| 5602 | case AP_OPEN: |
| 5603 | if (dut->ap_cipher == AP_WEP) |
| 5604 | fprintf(f, "wep_key0=%s\n", dut->ap_wepkey); |
| 5605 | break; |
| 5606 | case AP_WPA2_PSK: |
| 5607 | case AP_WPA2_PSK_MIXED: |
| 5608 | case AP_WPA_PSK: |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 5609 | case AP_WPA2_SAE: |
| 5610 | case AP_WPA2_PSK_SAE: |
| 5611 | if (dut->ap_key_mgmt == AP_WPA2_PSK || |
| 5612 | dut->ap_key_mgmt == AP_WPA2_SAE || |
| 5613 | dut->ap_key_mgmt == AP_WPA2_PSK_SAE) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5614 | fprintf(f, "wpa=2\n"); |
| 5615 | else if (dut->ap_key_mgmt == AP_WPA2_PSK_MIXED) |
| 5616 | fprintf(f, "wpa=3\n"); |
| 5617 | else |
| 5618 | fprintf(f, "wpa=1\n"); |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 5619 | if (dut->ap_key_mgmt == AP_WPA2_SAE) |
| 5620 | key_mgmt = "SAE"; |
| 5621 | else if (dut->ap_key_mgmt == AP_WPA2_PSK_SAE) |
| 5622 | key_mgmt = "WPA-PSK SAE"; |
| 5623 | else |
| 5624 | key_mgmt = "WPA-PSK"; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5625 | switch (dut->ap_pmf) { |
| 5626 | case AP_PMF_DISABLED: |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 5627 | fprintf(f, "wpa_key_mgmt=%s%s\n", key_mgmt, |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5628 | dut->ap_add_sha256 ? " WPA-PSK-SHA256" : ""); |
| 5629 | break; |
| 5630 | case AP_PMF_OPTIONAL: |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 5631 | fprintf(f, "wpa_key_mgmt=%s%s\n", key_mgmt, |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5632 | dut->ap_add_sha256 ? " WPA-PSK-SHA256" : ""); |
| 5633 | break; |
| 5634 | case AP_PMF_REQUIRED: |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 5635 | if (dut->ap_key_mgmt == AP_WPA2_SAE) |
| 5636 | key_mgmt = "SAE"; |
| 5637 | else if (dut->ap_key_mgmt == AP_WPA2_PSK_SAE) |
| 5638 | key_mgmt = "WPA-PSK-SHA256 SAE"; |
| 5639 | else |
| 5640 | key_mgmt = "WPA-PSK-SHA256"; |
| 5641 | fprintf(f, "wpa_key_mgmt=%s\n", key_mgmt); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5642 | break; |
| 5643 | } |
| 5644 | if (dut->ap_cipher == AP_CCMP_TKIP) |
| 5645 | fprintf(f, "wpa_pairwise=CCMP TKIP\n"); |
| 5646 | else if (dut->ap_cipher == AP_TKIP) |
| 5647 | fprintf(f, "wpa_pairwise=TKIP\n"); |
| 5648 | else |
| 5649 | fprintf(f, "wpa_pairwise=CCMP\n"); |
| 5650 | fprintf(f, "wpa_passphrase=%s\n", dut->ap_passphrase); |
| 5651 | break; |
| 5652 | case AP_WPA2_EAP: |
| 5653 | case AP_WPA2_EAP_MIXED: |
| 5654 | case AP_WPA_EAP: |
| 5655 | fprintf(f, "ieee8021x=1\n"); |
| 5656 | if (dut->ap_key_mgmt == AP_WPA2_EAP) |
| 5657 | fprintf(f, "wpa=2\n"); |
| 5658 | else if (dut->ap_key_mgmt == AP_WPA2_EAP_MIXED) |
| 5659 | fprintf(f, "wpa=3\n"); |
| 5660 | else |
| 5661 | fprintf(f, "wpa=1\n"); |
| 5662 | switch (dut->ap_pmf) { |
| 5663 | case AP_PMF_DISABLED: |
| 5664 | fprintf(f, "wpa_key_mgmt=WPA-EAP%s\n", |
| 5665 | dut->ap_add_sha256 ? " WPA-EAP-SHA256" : ""); |
| 5666 | break; |
| 5667 | case AP_PMF_OPTIONAL: |
| 5668 | fprintf(f, "wpa_key_mgmt=WPA-EAP%s\n", |
| 5669 | dut->ap_add_sha256 ? " WPA-EAP-SHA256" : ""); |
| 5670 | break; |
| 5671 | case AP_PMF_REQUIRED: |
| 5672 | fprintf(f, "wpa_key_mgmt=WPA-EAP-SHA256\n"); |
| 5673 | break; |
| 5674 | } |
| 5675 | if (dut->ap_cipher == AP_CCMP_TKIP) |
| 5676 | fprintf(f, "wpa_pairwise=CCMP TKIP\n"); |
| 5677 | else if (dut->ap_cipher == AP_TKIP) |
| 5678 | fprintf(f, "wpa_pairwise=TKIP\n"); |
| 5679 | else |
| 5680 | fprintf(f, "wpa_pairwise=CCMP\n"); |
| 5681 | fprintf(f, "auth_server_addr=%s\n", dut->ap_radius_ipaddr); |
| 5682 | if (dut->ap_radius_port) |
| 5683 | fprintf(f, "auth_server_port=%d\n", |
| 5684 | dut->ap_radius_port); |
| 5685 | fprintf(f, "auth_server_shared_secret=%s\n", |
| 5686 | dut->ap_radius_password); |
| 5687 | break; |
Jouni Malinen | ad395a2 | 2017-09-01 21:13:46 +0300 | [diff] [blame] | 5688 | case AP_SUITEB: |
| 5689 | fprintf(f, "ieee8021x=1\n"); |
| 5690 | fprintf(f, "wpa=2\n"); |
| 5691 | fprintf(f, "wpa_key_mgmt=WPA-EAP-SUITE-B-192\n"); |
Jouni Malinen | 3d633da | 2017-09-14 22:19:21 +0300 | [diff] [blame] | 5692 | fprintf(f, "wpa_pairwise=%s\n", |
| 5693 | hostapd_cipher_name(dut->ap_cipher)); |
| 5694 | if (dut->ap_group_mgmt_cipher != AP_NO_GROUP_MGMT_CIPHER_SET) |
| 5695 | fprintf(f, "group_mgmt_cipher=%s\n", |
| 5696 | hostapd_group_mgmt_cipher_name( |
| 5697 | dut->ap_group_mgmt_cipher)); |
Jouni Malinen | ad395a2 | 2017-09-01 21:13:46 +0300 | [diff] [blame] | 5698 | fprintf(f, "auth_server_addr=%s\n", dut->ap_radius_ipaddr); |
| 5699 | if (dut->ap_radius_port) |
| 5700 | fprintf(f, "auth_server_port=%d\n", |
| 5701 | dut->ap_radius_port); |
| 5702 | fprintf(f, "auth_server_shared_secret=%s\n", |
| 5703 | dut->ap_radius_password); |
| 5704 | break; |
Jouni Malinen | 147b3c3 | 2017-10-09 16:51:54 +0300 | [diff] [blame] | 5705 | case AP_WPA2_OWE: |
| 5706 | fprintf(f, "wpa=2\n"); |
| 5707 | fprintf(f, "wpa_key_mgmt=OWE\n"); |
| 5708 | fprintf(f, "rsn_pairwise=%s\n", |
| 5709 | hostapd_cipher_name(dut->ap_cipher)); |
| 5710 | break; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5711 | } |
| 5712 | |
Anilkumar Kolli | f0fd599 | 2017-02-23 12:54:01 +0530 | [diff] [blame] | 5713 | if (dut->ap_rsn_preauth) |
| 5714 | fprintf(f, "rsn_preauth=1\n"); |
| 5715 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5716 | switch (dut->ap_pmf) { |
| 5717 | case AP_PMF_DISABLED: |
| 5718 | break; |
| 5719 | case AP_PMF_OPTIONAL: |
| 5720 | fprintf(f, "ieee80211w=1\n"); |
| 5721 | break; |
| 5722 | case AP_PMF_REQUIRED: |
| 5723 | fprintf(f, "ieee80211w=2\n"); |
| 5724 | break; |
| 5725 | } |
| 5726 | |
Jouni Malinen | 3c367e8 | 2017-06-23 17:01:47 +0300 | [diff] [blame] | 5727 | if (dut->rsne_override) |
| 5728 | fprintf(f, "own_ie_override=%s\n", dut->rsne_override); |
| 5729 | |
Jouni Malinen | 6814313 | 2017-09-02 02:34:08 +0300 | [diff] [blame] | 5730 | if (dut->sae_commit_override) |
| 5731 | fprintf(f, "sae_commit_override=%s\n", |
| 5732 | dut->sae_commit_override); |
| 5733 | |
Jouni Malinen | ed670f4 | 2017-08-31 01:39:28 +0300 | [diff] [blame] | 5734 | if (dut->ap_sae_groups) |
| 5735 | fprintf(f, "sae_groups=%s\n", dut->ap_sae_groups); |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 5736 | |
Jouni Malinen | 2f524ce | 2017-08-31 01:43:29 +0300 | [diff] [blame] | 5737 | if (dut->sae_anti_clogging_threshold >= 0) |
| 5738 | fprintf(f, "sae_anti_clogging_threshold=%d\n", |
| 5739 | dut->sae_anti_clogging_threshold); |
Jouni Malinen | b347db0 | 2017-09-02 01:36:03 +0300 | [diff] [blame] | 5740 | if (dut->sae_reflection) |
| 5741 | fprintf(f, "sae_reflection_attack=1\n"); |
Jouni Malinen | 2f524ce | 2017-08-31 01:43:29 +0300 | [diff] [blame] | 5742 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5743 | if (dut->ap_p2p_mgmt) |
| 5744 | fprintf(f, "manage_p2p=1\n"); |
| 5745 | |
| 5746 | if (dut->ap_tdls_prohibit || dut->ap_l2tif) |
| 5747 | fprintf(f, "tdls_prohibit=1\n"); |
| 5748 | if (dut->ap_tdls_prohibit_chswitch || dut->ap_l2tif) |
| 5749 | fprintf(f, "tdls_prohibit_chan_switch=1\n"); |
| 5750 | if (dut->ap_p2p_cross_connect >= 0) { |
| 5751 | fprintf(f, "manage_p2p=1\n" |
| 5752 | "allow_cross_connection=%d\n", |
| 5753 | dut->ap_p2p_cross_connect); |
| 5754 | } |
| 5755 | |
| 5756 | if (dut->ap_l2tif || dut->ap_proxy_arp) { |
| 5757 | if (!dut->bridge) { |
| 5758 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5759 | "Bridge must be configured. Run with -b <brname>."); |
| 5760 | fclose(f); |
| 5761 | return -2; |
| 5762 | } |
| 5763 | fprintf(f, "ap_isolate=1\n"); |
| 5764 | } |
| 5765 | |
| 5766 | if (dut->ap_proxy_arp) |
| 5767 | fprintf(f, "proxy_arp=1\n"); |
| 5768 | |
Pradeep Reddy POTTETI | 0d3db63 | 2016-03-11 15:21:11 +0530 | [diff] [blame] | 5769 | if (dut->ap_wme) |
| 5770 | fprintf(f, "wmm_enabled=1\n"); |
| 5771 | |
Mohammed Shafi Shajakhan | 02e3b82 | 2017-02-23 04:15:02 +0530 | [diff] [blame] | 5772 | if (dut->ap_wmmps == AP_WMMPS_ON) |
| 5773 | fprintf(f, "uapsd_advertisement_enabled=1\n"); |
| 5774 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5775 | if (dut->ap_hs2) { |
| 5776 | if (dut->ap_bss_load) { |
| 5777 | char *bss_load; |
| 5778 | |
| 5779 | switch (dut->ap_bss_load) { |
| 5780 | case -1: |
| 5781 | bss_load = "bss_load_update_period=10"; |
| 5782 | break; |
| 5783 | case 1: |
| 5784 | /* STA count: 1, CU: 50, AAC: 65535 */ |
| 5785 | bss_load = "bss_load_test=1:50:65535"; |
| 5786 | break; |
| 5787 | case 2: |
| 5788 | /* STA count: 1, CU: 200, AAC: 65535 */ |
| 5789 | bss_load = "bss_load_test=1:200:65535"; |
| 5790 | break; |
| 5791 | case 3: |
| 5792 | /* STA count: 1, CU: 75, AAC: 65535 */ |
| 5793 | bss_load = "bss_load_test=1:75:65535"; |
| 5794 | break; |
| 5795 | default: |
| 5796 | bss_load = NULL; |
| 5797 | break; |
| 5798 | } |
| 5799 | |
| 5800 | if (!bss_load) { |
| 5801 | fclose(f); |
| 5802 | return -2; |
| 5803 | } |
| 5804 | fprintf(f, "%s\n", bss_load); |
| 5805 | } |
| 5806 | |
| 5807 | if (append_hostapd_conf_hs2(dut, f)) { |
| 5808 | fclose(f); |
| 5809 | return -2; |
| 5810 | } |
| 5811 | } |
| 5812 | |
| 5813 | if (dut->ap_interworking && append_hostapd_conf_interworking(dut, f)) { |
| 5814 | fclose(f); |
| 5815 | return -2; |
| 5816 | } |
| 5817 | |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 5818 | if (dut->ap_hs2 && strlen(dut->ap_tag_ssid[0])) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5819 | unsigned char bssid[6]; |
| 5820 | char ifname2[50]; |
| 5821 | |
Pradeep Reddy POTTETI | 673d85c | 2016-07-26 19:08:07 +0530 | [diff] [blame] | 5822 | if (get_hwaddr(ifname, bssid)) { |
| 5823 | fclose(f); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5824 | return -2; |
Pradeep Reddy POTTETI | 673d85c | 2016-07-26 19:08:07 +0530 | [diff] [blame] | 5825 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5826 | bssid[0] |= 0x02; |
| 5827 | |
| 5828 | snprintf(ifname2, sizeof(ifname2), "%s_1", ifname); |
| 5829 | fprintf(f, "bss=%s_1\n", ifname2); |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 5830 | fprintf(f, "ssid=%s\n", dut->ap_tag_ssid[0]); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5831 | if (dut->bridge) |
| 5832 | fprintf(f, "bridge=%s\n", dut->bridge); |
| 5833 | fprintf(f, "bssid=%02x:%02x:%02x:%02x:%02x:%02x\n", |
| 5834 | bssid[0], bssid[1], bssid[2], bssid[3], |
| 5835 | bssid[4], bssid[5]); |
| 5836 | |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 5837 | if (dut->ap_tag_key_mgmt[0] == AP2_OSEN) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5838 | fprintf(f, "osen=1\n"); |
| 5839 | if (strlen(dut->ap2_radius_ipaddr)) |
| 5840 | fprintf(f, "auth_server_addr=%s\n", |
| 5841 | dut->ap2_radius_ipaddr); |
| 5842 | if (dut->ap2_radius_port) |
| 5843 | fprintf(f, "auth_server_port=%d\n", |
| 5844 | dut->ap2_radius_port); |
| 5845 | if (strlen(dut->ap2_radius_password)) |
| 5846 | fprintf(f, "auth_server_shared_secret=%s\n", |
| 5847 | dut->ap2_radius_password); |
| 5848 | } |
| 5849 | |
| 5850 | if (dut->ap2_proxy_arp) { |
| 5851 | if (!dut->bridge) { |
| 5852 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5853 | "Bridge must be configured. Run with -b <brname>."); |
| 5854 | fclose(f); |
| 5855 | return -2; |
| 5856 | } |
| 5857 | fprintf(f, "ap_isolate=1\n"); |
| 5858 | fprintf(f, "proxy_arp=1\n"); |
| 5859 | |
| 5860 | if (set_ebtables_proxy_arp(dut, "FORWARD", ifname2) || |
| 5861 | set_ebtables_proxy_arp(dut, "OUTPUT", ifname2)) { |
| 5862 | fclose(f); |
| 5863 | return -2; |
| 5864 | } |
| 5865 | |
| 5866 | } |
| 5867 | } |
| 5868 | |
| 5869 | if (dut->program == PROGRAM_WPS) { |
| 5870 | fprintf(f, "eap_server=1\n" |
| 5871 | "wps_state=1\n" |
| 5872 | "device_name=QCA AP\n" |
| 5873 | "manufacturer=QCA\n" |
| 5874 | "device_type=6-0050F204-1\n" |
| 5875 | "config_methods=label virtual_display " |
| 5876 | "virtual_push_button keypad%s\n" |
| 5877 | "ap_pin=12345670\n" |
| 5878 | "friendly_name=QCA Access Point\n" |
| 5879 | "upnp_iface=%s\n", |
| 5880 | dut->ap_wpsnfc ? " nfc_interface ext_nfc_token" : "", |
| 5881 | dut->bridge ? dut->bridge : ifname); |
| 5882 | } |
| 5883 | |
| 5884 | if (dut->program == PROGRAM_VHT) { |
| 5885 | int vht_oper_centr_freq_idx; |
| 5886 | |
| 5887 | if (check_channel(dut->ap_channel) < 0) { |
| 5888 | send_resp(dut, conn, SIGMA_INVALID, |
| 5889 | "errorCode,Invalid channel"); |
Pradeep Reddy POTTETI | 673d85c | 2016-07-26 19:08:07 +0530 | [diff] [blame] | 5890 | fclose(f); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5891 | return 0; |
| 5892 | } |
| 5893 | |
| 5894 | switch (dut->ap_chwidth) { |
| 5895 | case AP_20: |
| 5896 | dut->ap_vht_chwidth = AP_20_40_VHT_OPER_CHWIDTH; |
| 5897 | vht_oper_centr_freq_idx = |
| 5898 | get_oper_centr_freq_seq_idx(20, |
| 5899 | dut->ap_channel); |
| 5900 | break; |
| 5901 | case AP_40: |
| 5902 | dut->ap_vht_chwidth = AP_20_40_VHT_OPER_CHWIDTH; |
| 5903 | vht_oper_centr_freq_idx = |
| 5904 | get_oper_centr_freq_seq_idx(40, |
| 5905 | dut->ap_channel); |
| 5906 | break; |
| 5907 | case AP_80: |
| 5908 | dut->ap_vht_chwidth = AP_80_VHT_OPER_CHWIDTH; |
| 5909 | vht_oper_centr_freq_idx = |
| 5910 | get_oper_centr_freq_seq_idx(80, |
| 5911 | dut->ap_channel); |
| 5912 | break; |
| 5913 | case AP_160: |
| 5914 | dut->ap_vht_chwidth = AP_160_VHT_OPER_CHWIDTH; |
| 5915 | vht_oper_centr_freq_idx = |
| 5916 | get_oper_centr_freq_seq_idx(160, |
| 5917 | dut->ap_channel); |
| 5918 | break; |
| 5919 | default: |
| 5920 | dut->ap_vht_chwidth = VHT_DEFAULT_OPER_CHWIDTH; |
| 5921 | vht_oper_centr_freq_idx = |
| 5922 | get_oper_centr_freq_seq_idx(80, |
| 5923 | dut->ap_channel); |
| 5924 | break; |
| 5925 | } |
| 5926 | fprintf(f, "vht_oper_centr_freq_seg0_idx=%d\n", |
| 5927 | vht_oper_centr_freq_idx); |
| 5928 | fprintf(f, "vht_oper_chwidth=%d\n", dut->ap_vht_chwidth); |
| 5929 | |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 5930 | if (dut->ap_sgi80 || dut->ap_txBF || |
| 5931 | dut->ap_ldpc != VALUE_NOT_SET || |
Mohammed Shafi Shajakhan | f3e68d9 | 2016-06-02 20:10:57 +0530 | [diff] [blame] | 5932 | dut->ap_tx_stbc || dut->ap_mu_txBF) { |
| 5933 | fprintf(f, "vht_capab=%s%s%s%s%s\n", |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5934 | dut->ap_sgi80 ? "[SHORT-GI-80]" : "", |
Mohammed Shafi Shajakhan | c039ce3 | 2016-06-02 20:10:58 +0530 | [diff] [blame] | 5935 | dut->ap_txBF ? |
Tamizh chelvam | 8312f6d | 2016-06-02 20:10:59 +0530 | [diff] [blame] | 5936 | "[SU-BEAMFORMER][SU-BEAMFORMEE][BF-ANTENNA-2][SOUNDING-DIMENSION-2]" : "", |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 5937 | (dut->ap_ldpc == VALUE_ENABLED) ? |
| 5938 | "[RXLDPC]" : "", |
Mohammed Shafi Shajakhan | f3e68d9 | 2016-06-02 20:10:57 +0530 | [diff] [blame] | 5939 | dut->ap_tx_stbc ? "[TX-STBC-2BY1]" : "", |
| 5940 | dut->ap_mu_txBF ? "[MU-BEAMFORMER]" : ""); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5941 | } |
| 5942 | } |
| 5943 | |
| 5944 | fclose(f); |
Jouni Malinen | d6bf1b4 | 2017-06-23 17:51:01 +0300 | [diff] [blame] | 5945 | if (dut->use_hostapd_pid_file) |
| 5946 | kill_hostapd_process_pid(dut); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5947 | #ifdef __QNXNTO__ |
| 5948 | if (system("slay hostapd") == 0) |
| 5949 | #else /* __QNXNTO__ */ |
Jouni Malinen | d6bf1b4 | 2017-06-23 17:51:01 +0300 | [diff] [blame] | 5950 | if (!dut->use_hostapd_pid_file && |
| 5951 | (kill_process(dut, "(hostapd)", 1, SIGTERM) == 0 || |
| 5952 | system("killall hostapd") == 0)) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5953 | #endif /* __QNXNTO__ */ |
| 5954 | { |
| 5955 | int i; |
| 5956 | /* Wait some time to allow hostapd to complete cleanup before |
| 5957 | * starting a new process */ |
| 5958 | for (i = 0; i < 10; i++) { |
| 5959 | usleep(500000); |
| 5960 | #ifdef __QNXNTO__ |
| 5961 | if (system("pidin | grep hostapd") != 0) |
| 5962 | break; |
| 5963 | #else /* __QNXNTO__ */ |
| 5964 | if (system("pidof hostapd") != 0) |
| 5965 | break; |
| 5966 | #endif /* __QNXNTO__ */ |
| 5967 | } |
| 5968 | } |
Jouni Malinen | d86e582 | 2017-08-29 03:55:32 +0300 | [diff] [blame] | 5969 | dut->hostapd_running = 0; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5970 | |
Pradeep Reddy POTTETI | a076c30 | 2016-05-16 13:36:07 +0530 | [diff] [blame] | 5971 | #ifdef ANDROID |
| 5972 | /* Set proper conf file permissions so that hostapd process |
| 5973 | * can access it. |
| 5974 | */ |
| 5975 | if (chmod(SIGMA_TMPDIR "/sigma_dut-ap.conf", |
| 5976 | S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP) < 0) |
| 5977 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5978 | "Error changing permissions"); |
| 5979 | |
| 5980 | if (chown(SIGMA_TMPDIR "/sigma_dut-ap.conf", -1, AID_WIFI) < 0) |
| 5981 | sigma_dut_print(dut, DUT_MSG_ERROR, "Error changing groupid"); |
| 5982 | #endif /* ANDROID */ |
| 5983 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5984 | if (drv == DRIVER_QNXNTO) { |
| 5985 | snprintf(buf, sizeof(buf), |
Pradeep Reddy POTTETI | bf4a974 | 2016-02-04 12:32:30 +0530 | [diff] [blame] | 5986 | "hostapd -B %s%s %s%s" SIGMA_TMPDIR |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5987 | "/sigma_dut-ap.conf", |
| 5988 | dut->hostapd_debug_log ? "-ddKt -f " : "", |
| 5989 | dut->hostapd_debug_log ? dut->hostapd_debug_log : "", |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5990 | dut->hostapd_entropy_log ? " -e" : "", |
| 5991 | dut->hostapd_entropy_log ? dut->hostapd_entropy_log : |
| 5992 | ""); |
| 5993 | } else { |
| 5994 | /* |
| 5995 | * It looks like a monitor interface can cause some issues for |
| 5996 | * beaconing, so remove it (if injection was used) before |
| 5997 | * starting hostapd. |
| 5998 | */ |
| 5999 | if (if_nametoindex("sigmadut") > 0 && |
| 6000 | system("iw dev sigmadut del") != 0) |
| 6001 | sigma_dut_print(dut, DUT_MSG_ERROR, "Failed to remove " |
| 6002 | "monitor interface"); |
| 6003 | |
Jouni Malinen | d6bf1b4 | 2017-06-23 17:51:01 +0300 | [diff] [blame] | 6004 | snprintf(path, sizeof(path), "%shostapd", |
| 6005 | file_exists("hostapd") ? "./" : ""); |
| 6006 | 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] | 6007 | "/sigma_dut-ap.conf", |
Jouni Malinen | d6bf1b4 | 2017-06-23 17:51:01 +0300 | [diff] [blame] | 6008 | dut->hostapd_bin ? dut->hostapd_bin : path, |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6009 | dut->hostapd_debug_log ? " -ddKt -f" : "", |
| 6010 | dut->hostapd_debug_log ? dut->hostapd_debug_log : "", |
| 6011 | dut->hostapd_entropy_log ? " -e" : "", |
| 6012 | dut->hostapd_entropy_log ? dut->hostapd_entropy_log : |
Jouni Malinen | d6bf1b4 | 2017-06-23 17:51:01 +0300 | [diff] [blame] | 6013 | "", |
| 6014 | dut->use_hostapd_pid_file ? |
| 6015 | " -P " SIGMA_DUT_HOSTAPD_PID_FILE : ""); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6016 | } |
| 6017 | |
Jouni Malinen | d6bf1b4 | 2017-06-23 17:51:01 +0300 | [diff] [blame] | 6018 | sigma_dut_print(dut, DUT_MSG_DEBUG, "hostapd command: %s", buf); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6019 | if (system(buf) != 0) { |
| 6020 | send_resp(dut, conn, SIGMA_ERROR, |
| 6021 | "errorCode,Failed to start hostapd"); |
| 6022 | return 0; |
| 6023 | } |
| 6024 | |
| 6025 | /* allow some time for hostapd to start before returning success */ |
| 6026 | usleep(500000); |
| 6027 | if (run_hostapd_cli(dut, "ping") != 0) { |
| 6028 | send_resp(dut, conn, SIGMA_ERROR, |
| 6029 | "errorCode,Failed to talk to hostapd"); |
| 6030 | return 0; |
| 6031 | } |
| 6032 | |
Pradeep Reddy Potteti | 923a9b3 | 2017-06-14 12:18:59 +0530 | [diff] [blame] | 6033 | if (drv == DRIVER_LINUX_WCN) { |
| 6034 | sigma_dut_print(dut, DUT_MSG_INFO, "setting ip addr %s mask %s", |
| 6035 | ap_inet_addr, ap_inet_mask); |
| 6036 | snprintf(buf, sizeof(buf), "ifconfig %s %s netmask %s up", |
| 6037 | ifname, ap_inet_addr, ap_inet_mask); |
| 6038 | if (system(buf) != 0) { |
| 6039 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 6040 | "Failed to initialize the interface"); |
| 6041 | return -1; |
| 6042 | } |
| 6043 | } |
| 6044 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6045 | if (dut->ap_l2tif) { |
| 6046 | snprintf(path, sizeof(path), |
| 6047 | "/sys/class/net/%s/brport/hairpin_mode", |
| 6048 | ifname); |
| 6049 | if (!file_exists(path)) { |
| 6050 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 6051 | "%s must be binded to the bridge for L2TIF", |
| 6052 | ifname); |
| 6053 | return -2; |
| 6054 | } |
| 6055 | |
| 6056 | snprintf(buf, sizeof(buf), "echo 1 > %s", path); |
| 6057 | if (system(buf) != 0) { |
| 6058 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 6059 | "Failed to enable hairpin_mode for L2TIF"); |
| 6060 | return -2; |
| 6061 | } |
| 6062 | |
| 6063 | snprintf(buf, sizeof(buf), "ebtables -P FORWARD ACCEPT"); |
| 6064 | if (system(buf) != 0) { |
| 6065 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 6066 | "Failed to set ebtables rules, RULE-9"); |
| 6067 | return -2; |
| 6068 | } |
| 6069 | |
| 6070 | snprintf(buf, sizeof(buf), |
| 6071 | "ebtables -A FORWARD -p IPv4 --ip-proto icmp -i %s -j DROP", |
| 6072 | ifname); |
| 6073 | if (system(buf) != 0) { |
| 6074 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 6075 | "Failed to set ebtables rules, RULE-11"); |
| 6076 | return -2; |
| 6077 | } |
| 6078 | } |
| 6079 | |
| 6080 | if (dut->ap_proxy_arp) { |
| 6081 | if (dut->ap_dgaf_disable) { |
| 6082 | if (set_ebtables_disable_dgaf(dut, "FORWARD", ifname) || |
| 6083 | set_ebtables_disable_dgaf(dut, "OUTPUT", ifname)) |
| 6084 | return -2; |
| 6085 | } else { |
| 6086 | if (set_ebtables_proxy_arp(dut, "FORWARD", ifname) || |
| 6087 | set_ebtables_proxy_arp(dut, "OUTPUT", ifname)) |
| 6088 | return -2; |
| 6089 | } |
| 6090 | |
| 6091 | /* For 4.5-(c) */ |
| 6092 | snprintf(buf, sizeof(buf), |
| 6093 | "ebtables -A FORWARD -p ARP --arp-opcode 2 -i %s -j DROP", |
| 6094 | ifname); |
| 6095 | if (system(buf) != 0) { |
| 6096 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 6097 | "Failed to set ebtables rules, RULE-10"); |
| 6098 | return -2; |
| 6099 | } |
| 6100 | } |
| 6101 | |
| 6102 | if (dut->ap_tdls_prohibit || dut->ap_l2tif) { |
| 6103 | /* Drop TDLS frames */ |
| 6104 | snprintf(buf, sizeof(buf), |
| 6105 | "ebtables -A FORWARD -p 0x890d -i %s -j DROP", ifname); |
| 6106 | if (system(buf) != 0) { |
| 6107 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 6108 | "Failed to set ebtables rules, RULE-13"); |
| 6109 | return -2; |
| 6110 | } |
| 6111 | } |
| 6112 | |
| 6113 | if (dut->ap_fake_pkhash && |
| 6114 | run_hostapd_cli(dut, "set wps_corrupt_pkhash 1") != 0) { |
| 6115 | send_resp(dut, conn, SIGMA_ERROR, |
| 6116 | "errorCode,Could not enable FakePubKey"); |
| 6117 | return 0; |
| 6118 | } |
| 6119 | |
Jouni Malinen | d86e582 | 2017-08-29 03:55:32 +0300 | [diff] [blame] | 6120 | dut->hostapd_running = 1; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6121 | return 1; |
| 6122 | } |
| 6123 | |
| 6124 | |
Pradeep Reddy POTTETI | eff4611 | 2016-10-13 17:22:03 +0530 | [diff] [blame] | 6125 | static int parse_qos_params(struct sigma_dut *dut, struct sigma_conn *conn, |
| 6126 | struct qos_params *qos, const char *cwmin, |
| 6127 | const char *cwmax, const char *aifs, |
| 6128 | const char *txop, const char *acm) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6129 | { |
Pradeep Reddy POTTETI | eff4611 | 2016-10-13 17:22:03 +0530 | [diff] [blame] | 6130 | int val; |
| 6131 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6132 | if (cwmin) { |
| 6133 | qos->ac = 1; |
Pradeep Reddy POTTETI | eff4611 | 2016-10-13 17:22:03 +0530 | [diff] [blame] | 6134 | val = atoi(cwmin); |
| 6135 | if (val < 0 || val > 15) { |
| 6136 | send_resp(dut, conn, SIGMA_INVALID, |
| 6137 | "errorCode,Invalid cwMin"); |
| 6138 | return 0; |
| 6139 | } |
| 6140 | qos->cwmin = val; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6141 | } |
| 6142 | |
| 6143 | if (cwmax) { |
| 6144 | qos->ac = 1; |
Pradeep Reddy POTTETI | eff4611 | 2016-10-13 17:22:03 +0530 | [diff] [blame] | 6145 | val = atoi(cwmax); |
| 6146 | if (val < 0 || val > 15) { |
| 6147 | send_resp(dut, conn, SIGMA_INVALID, |
| 6148 | "errorCode,Invalid cwMax"); |
| 6149 | return 0; |
| 6150 | } |
| 6151 | qos->cwmax = val; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6152 | } |
| 6153 | |
| 6154 | if (aifs) { |
| 6155 | qos->ac = 1; |
Pradeep Reddy POTTETI | eff4611 | 2016-10-13 17:22:03 +0530 | [diff] [blame] | 6156 | val = atoi(aifs); |
| 6157 | if (val < 1 || val > 255) { |
| 6158 | send_resp(dut, conn, SIGMA_INVALID, |
| 6159 | "errorCode,Invalid AIFS"); |
| 6160 | return 0; |
| 6161 | } |
| 6162 | qos->aifs = val; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6163 | } |
| 6164 | |
| 6165 | if (txop) { |
| 6166 | qos->ac = 1; |
Pradeep Reddy POTTETI | eff4611 | 2016-10-13 17:22:03 +0530 | [diff] [blame] | 6167 | val = atoi(txop); |
| 6168 | if (val < 0 || val > 0xffff) { |
| 6169 | send_resp(dut, conn, SIGMA_INVALID, |
| 6170 | "errorCode,Invalid txop"); |
| 6171 | return 0; |
| 6172 | } |
| 6173 | qos->txop = val * 32; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6174 | } |
| 6175 | |
| 6176 | if (acm) { |
| 6177 | qos->ac = 1; |
| 6178 | qos->acm = strcasecmp(acm, "on") == 0; |
| 6179 | } |
Pradeep Reddy POTTETI | eff4611 | 2016-10-13 17:22:03 +0530 | [diff] [blame] | 6180 | |
| 6181 | return 1; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6182 | } |
| 6183 | |
| 6184 | |
| 6185 | static int cmd_ap_set_apqos(struct sigma_dut *dut, struct sigma_conn *conn, |
| 6186 | struct sigma_cmd *cmd) |
| 6187 | { |
| 6188 | /* TXOP: The values provided here for VHT5G only */ |
Pradeep Reddy POTTETI | eff4611 | 2016-10-13 17:22:03 +0530 | [diff] [blame] | 6189 | if (!parse_qos_params(dut, conn, &dut->ap_qos[AP_AC_VO], |
| 6190 | get_param(cmd, "cwmin_VO"), |
| 6191 | get_param(cmd, "cwmax_VO"), |
| 6192 | get_param(cmd, "AIFS_VO"), |
| 6193 | get_param(cmd, "TXOP_VO"), |
| 6194 | get_param(cmd, "ACM_VO")) || |
| 6195 | !parse_qos_params(dut, conn, &dut->ap_qos[AP_AC_VI], |
| 6196 | get_param(cmd, "cwmin_VI"), |
| 6197 | get_param(cmd, "cwmax_VI"), |
| 6198 | get_param(cmd, "AIFS_VI"), |
| 6199 | get_param(cmd, "TXOP_VI"), |
| 6200 | get_param(cmd, "ACM_VI")) || |
| 6201 | !parse_qos_params(dut, conn, &dut->ap_qos[AP_AC_BE], |
| 6202 | get_param(cmd, "cwmin_BE"), |
| 6203 | get_param(cmd, "cwmax_BE"), |
| 6204 | get_param(cmd, "AIFS_BE"), |
| 6205 | get_param(cmd, "TXOP_BE"), |
| 6206 | get_param(cmd, "ACM_BE")) || |
| 6207 | !parse_qos_params(dut, conn, &dut->ap_qos[AP_AC_BK], |
| 6208 | get_param(cmd, "cwmin_BK"), |
| 6209 | get_param(cmd, "cwmax_BK"), |
| 6210 | get_param(cmd, "AIFS_BK"), |
| 6211 | get_param(cmd, "TXOP_BK"), |
| 6212 | get_param(cmd, "ACM_BK"))) |
| 6213 | return 0; |
| 6214 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6215 | return 1; |
| 6216 | } |
| 6217 | |
| 6218 | |
| 6219 | static int cmd_ap_set_staqos(struct sigma_dut *dut, struct sigma_conn *conn, |
| 6220 | struct sigma_cmd *cmd) |
| 6221 | { |
Pradeep Reddy POTTETI | eff4611 | 2016-10-13 17:22:03 +0530 | [diff] [blame] | 6222 | if (!parse_qos_params(dut, conn, &dut->ap_sta_qos[AP_AC_VO], |
| 6223 | get_param(cmd, "cwmin_VO"), |
| 6224 | get_param(cmd, "cwmax_VO"), |
| 6225 | get_param(cmd, "AIFS_VO"), |
| 6226 | get_param(cmd, "TXOP_VO"), |
| 6227 | get_param(cmd, "ACM_VO")) || |
| 6228 | !parse_qos_params(dut, conn, &dut->ap_sta_qos[AP_AC_VI], |
| 6229 | get_param(cmd, "cwmin_VI"), |
| 6230 | get_param(cmd, "cwmax_VI"), |
| 6231 | get_param(cmd, "AIFS_VI"), |
| 6232 | get_param(cmd, "TXOP_VI"), |
| 6233 | get_param(cmd, "ACM_VI")) || |
| 6234 | !parse_qos_params(dut, conn, &dut->ap_sta_qos[AP_AC_BE], |
| 6235 | get_param(cmd, "cwmin_BE"), |
| 6236 | get_param(cmd, "cwmax_BE"), |
| 6237 | get_param(cmd, "AIFS_BE"), |
| 6238 | get_param(cmd, "TXOP_BE"), |
| 6239 | get_param(cmd, "ACM_BE")) || |
| 6240 | !parse_qos_params(dut, conn, &dut->ap_sta_qos[AP_AC_BK], |
| 6241 | get_param(cmd, "cwmin_BK"), |
| 6242 | get_param(cmd, "cwmax_BK"), |
| 6243 | get_param(cmd, "AIFS_BK"), |
| 6244 | get_param(cmd, "TXOP_BK"), |
| 6245 | get_param(cmd, "ACM_BK"))) |
| 6246 | return 0; |
| 6247 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6248 | return 1; |
| 6249 | } |
| 6250 | |
| 6251 | |
| 6252 | static void cmd_ath_ap_hs2_reset(struct sigma_dut *dut) |
| 6253 | { |
| 6254 | unsigned char bssid[6]; |
| 6255 | char buf[100]; |
| 6256 | run_system(dut, "cfg -a AP_SSID=\"Hotspot 2.0\""); |
| 6257 | run_system(dut, "cfg -a AP_PRIMARY_CH=1"); |
| 6258 | run_system(dut, "cfg -a AP_SECMODE=WPA"); |
| 6259 | run_system(dut, "cfg -a AP_SECFILE=EAP"); |
| 6260 | run_system(dut, "cfg -a AP_WPA=2"); |
| 6261 | run_system(dut, "cfg -a AP_CYPHER=CCMP"); |
| 6262 | run_system(dut, "cfg -a AP_HOTSPOT=1"); |
| 6263 | run_system(dut, "cfg -a AP_HOTSPOT_ANT=2"); |
| 6264 | run_system(dut, "cfg -a AP_HOTSPOT_INTERNET=0"); |
| 6265 | run_system(dut, "cfg -a AP_HOTSPOT_VENUEGROUP=2"); |
| 6266 | run_system(dut, "cfg -a AP_HOTSPOT_VENUETYPE=8"); |
| 6267 | run_system(dut, "cfg -a AP_HOTSPOT_ROAMINGCONSORTIUM=506f9a"); |
| 6268 | run_system(dut, "cfg -a AP_HOTSPOT_ROAMINGCONSORTIUM2=001bc504bd"); |
| 6269 | if (!get_hwaddr("ath0", bssid)) { |
| 6270 | snprintf(buf, sizeof(buf), "cfg -a AP_HOTSPOT_HESSID=" |
| 6271 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 6272 | bssid[0], bssid[1], bssid[2], bssid[3], |
| 6273 | bssid[4], bssid[5]); |
| 6274 | run_system(dut, buf); |
| 6275 | snprintf(dut->ap_hessid, sizeof(dut->ap_hessid), |
| 6276 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 6277 | bssid[0], bssid[1], bssid[2], bssid[3], |
| 6278 | bssid[4], bssid[5]); |
| 6279 | } else { |
| 6280 | if (!get_hwaddr("wifi0", bssid)) { |
| 6281 | snprintf(buf, sizeof(buf), "cfg -a AP_HOTSPOT_HESSID=" |
| 6282 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 6283 | bssid[0], bssid[1], bssid[2], bssid[3], |
| 6284 | bssid[4], bssid[5]); |
| 6285 | run_system(dut, buf); |
| 6286 | snprintf(dut->ap_hessid, sizeof(dut->ap_hessid), |
| 6287 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 6288 | bssid[0], bssid[1], bssid[2], bssid[3], |
| 6289 | bssid[4], bssid[5]); |
| 6290 | } else { |
| 6291 | /* load the driver and try again */ |
| 6292 | run_system(dut, "/etc/rc.d/rc.wlan up"); |
| 6293 | |
| 6294 | if (!get_hwaddr("wifi0", bssid)) { |
| 6295 | snprintf(buf, sizeof(buf), |
| 6296 | "cfg -a AP_HOTSPOT_HESSID=" |
| 6297 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 6298 | bssid[0], bssid[1], bssid[2], |
| 6299 | bssid[3], bssid[4], bssid[5]); |
| 6300 | run_system(dut, buf); |
| 6301 | snprintf(dut->ap_hessid, |
| 6302 | sizeof(dut->ap_hessid), |
| 6303 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 6304 | bssid[0], bssid[1], bssid[2], |
| 6305 | bssid[3], bssid[4], bssid[5]); |
| 6306 | } |
| 6307 | } |
| 6308 | } |
| 6309 | |
| 6310 | run_system(dut, "cfg -r AP_SSID_2"); |
| 6311 | run_system(dut, "cfg -c"); |
| 6312 | /* run_system(dut, "cfg -s"); */ |
| 6313 | } |
| 6314 | |
| 6315 | |
| 6316 | static void ath_reset_vht_defaults(struct sigma_dut *dut) |
| 6317 | { |
| 6318 | run_system(dut, "cfg -x"); |
| 6319 | run_system(dut, "cfg -a AP_RADIO_ID=1"); |
| 6320 | run_system(dut, "cfg -a AP_PRIMARY_CH_2=36"); |
| 6321 | run_system(dut, "cfg -a AP_STARTMODE=standard"); |
| 6322 | run_system(dut, "cfg -a AP_CHMODE_2=11ACVHT80"); |
| 6323 | run_system(dut, "cfg -a TX_CHAINMASK_2=7"); |
| 6324 | run_system(dut, "cfg -a RX_CHAINMASK_2=7"); |
| 6325 | run_system(dut, "cfg -a ATH_countrycode=0x348"); |
| 6326 | /* NOTE: For Beeliner we have to turn off MU-MIMO */ |
| 6327 | if (system("rm /tmp/secath*") != 0) { |
| 6328 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 6329 | "Failed to remove secath file"); |
| 6330 | } |
| 6331 | } |
| 6332 | |
| 6333 | |
| 6334 | static int cmd_ap_reset_default(struct sigma_dut *dut, struct sigma_conn *conn, |
| 6335 | struct sigma_cmd *cmd) |
| 6336 | { |
| 6337 | const char *type; |
Pradeep Reddy POTTETI | 83b8067 | 2016-09-02 13:01:44 +0530 | [diff] [blame] | 6338 | enum driver_type drv; |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 6339 | int i; |
| 6340 | |
| 6341 | for (i = 0; i < MAX_WLAN_TAGS - 1; i++) { |
| 6342 | /* |
| 6343 | * Reset all tagged SSIDs to NULL-string and all key management |
| 6344 | * to open. |
| 6345 | */ |
| 6346 | dut->ap_tag_ssid[i][0] = '\0'; |
| 6347 | dut->ap_tag_key_mgmt[i] = AP2_OPEN; |
| 6348 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6349 | |
Pradeep Reddy POTTETI | 83b8067 | 2016-09-02 13:01:44 +0530 | [diff] [blame] | 6350 | drv = get_driver_type(); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6351 | dut->program = sigma_program_to_enum(get_param(cmd, "PROGRAM")); |
| 6352 | dut->device_type = AP_unknown; |
| 6353 | type = get_param(cmd, "type"); |
| 6354 | if (type && strcasecmp(type, "Testbed") == 0) |
| 6355 | dut->device_type = AP_testbed; |
| 6356 | if (type && strcasecmp(type, "DUT") == 0) |
| 6357 | dut->device_type = AP_dut; |
| 6358 | |
| 6359 | dut->ap_rts = 0; |
| 6360 | dut->ap_frgmnt = 0; |
| 6361 | dut->ap_bcnint = 0; |
| 6362 | dut->ap_key_mgmt = AP_OPEN; |
| 6363 | dut->ap_ssid[0] = '\0'; |
| 6364 | dut->ap_fake_pkhash = 0; |
| 6365 | memset(dut->ap_qos, 0, sizeof(dut->ap_qos)); |
| 6366 | memset(dut->ap_sta_qos, 0, sizeof(dut->ap_sta_qos)); |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 6367 | dut->ap_addba_reject = VALUE_NOT_SET; |
| 6368 | dut->ap_noack = VALUE_NOT_SET; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6369 | dut->ap_is_dual = 0; |
| 6370 | dut->ap_mode = AP_inval; |
| 6371 | dut->ap_mode_1 = AP_inval; |
| 6372 | |
| 6373 | dut->ap_allow_vht_wep = 0; |
| 6374 | dut->ap_allow_vht_tkip = 0; |
| 6375 | dut->ap_disable_protection = 0; |
| 6376 | memset(dut->ap_countrycode, 0, sizeof(dut->ap_countrycode)); |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 6377 | dut->ap_dyn_bw_sig = VALUE_NOT_SET; |
| 6378 | dut->ap_ldpc = VALUE_NOT_SET; |
| 6379 | dut->ap_sig_rts = VALUE_NOT_SET; |
| 6380 | dut->ap_rx_amsdu = VALUE_NOT_SET; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6381 | dut->ap_txBF = 0; |
Mohammed Shafi Shajakhan | 495fdb2 | 2016-06-02 20:10:56 +0530 | [diff] [blame] | 6382 | dut->ap_mu_txBF = 0; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6383 | dut->ap_chwidth = AP_AUTO; |
| 6384 | |
Sarvepalli, Rajesh Babu | 24dc7e4 | 2016-03-18 21:27:26 +0530 | [diff] [blame] | 6385 | dut->ap_rsn_preauth = 0; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6386 | dut->ap_wpsnfc = 0; |
| 6387 | dut->ap_bss_load = -1; |
| 6388 | dut->ap_p2p_cross_connect = -1; |
| 6389 | |
Pradeep Reddy POTTETI | fba27db | 2015-11-20 16:42:22 +0530 | [diff] [blame] | 6390 | dut->ap_regulatory_mode = AP_80211D_MODE_DISABLED; |
| 6391 | dut->ap_dfs_mode = AP_DFS_MODE_DISABLED; |
Pradeep Reddy Potteti | 4b0cdee | 2017-03-15 12:37:33 +0530 | [diff] [blame] | 6392 | dut->ap_chwidth_offset = SEC_CH_NO; |
Pradeep Reddy POTTETI | fba27db | 2015-11-20 16:42:22 +0530 | [diff] [blame] | 6393 | |
Adil Saeed Musthafa | 6906372 | 2017-04-10 23:13:40 -0700 | [diff] [blame] | 6394 | dut->mbo_pref_ap_cnt = 0; |
Adil Saeed Musthafa | 4ec61bd | 2017-04-10 23:13:41 -0700 | [diff] [blame] | 6395 | dut->ft_bss_mac_cnt = 0; |
Adil Saeed Musthafa | 6906372 | 2017-04-10 23:13:40 -0700 | [diff] [blame] | 6396 | |
Mohammed Shafi Shajakhan | 02e3b82 | 2017-02-23 04:15:02 +0530 | [diff] [blame] | 6397 | if (dut->program == PROGRAM_HT || dut->program == PROGRAM_VHT) { |
Pradeep Reddy POTTETI | 0d3db63 | 2016-03-11 15:21:11 +0530 | [diff] [blame] | 6398 | dut->ap_wme = AP_WME_ON; |
Mohammed Shafi Shajakhan | 02e3b82 | 2017-02-23 04:15:02 +0530 | [diff] [blame] | 6399 | dut->ap_wmmps = AP_WMMPS_ON; |
| 6400 | } else { |
Pradeep Reddy POTTETI | 0d3db63 | 2016-03-11 15:21:11 +0530 | [diff] [blame] | 6401 | dut->ap_wme = AP_WME_OFF; |
Mohammed Shafi Shajakhan | 02e3b82 | 2017-02-23 04:15:02 +0530 | [diff] [blame] | 6402 | dut->ap_wmmps = AP_WMMPS_OFF; |
| 6403 | } |
Pradeep Reddy POTTETI | 0d3db63 | 2016-03-11 15:21:11 +0530 | [diff] [blame] | 6404 | |
Adil Saeed Musthafa | 33ea287 | 2017-04-10 23:13:24 -0700 | [diff] [blame] | 6405 | if (dut->program == PROGRAM_HS2 || dut->program == PROGRAM_HS2_R2 || |
| 6406 | dut->program == PROGRAM_IOTLP) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6407 | int i; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6408 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6409 | if (drv == DRIVER_ATHEROS) |
| 6410 | cmd_ath_ap_hs2_reset(dut); |
| 6411 | else if (drv == DRIVER_OPENWRT) |
| 6412 | cmd_owrt_ap_hs2_reset(dut); |
| 6413 | |
| 6414 | dut->ap_interworking = 1; |
| 6415 | dut->ap_access_net_type = 2; |
| 6416 | dut->ap_internet = 0; |
| 6417 | dut->ap_venue_group = 2; |
| 6418 | dut->ap_venue_type = 8; |
| 6419 | dut->ap_domain_name_list[0] = '\0'; |
| 6420 | dut->ap_hs2 = 1; |
| 6421 | snprintf(dut->ap_roaming_cons, sizeof(dut->ap_roaming_cons), |
| 6422 | "506f9a;001bc504bd"); |
| 6423 | dut->ap_l2tif = 0; |
| 6424 | dut->ap_proxy_arp = 0; |
| 6425 | if (dut->bridge) { |
| 6426 | char buf[50]; |
| 6427 | |
| 6428 | snprintf(buf, sizeof(buf), "ip neigh flush dev %s", |
| 6429 | dut->bridge); |
| 6430 | if (system(buf) != 0) { |
| 6431 | sigma_dut_print(dut, DUT_MSG_DEBUG, |
| 6432 | "%s ip neigh table flushing failed", |
| 6433 | dut->bridge); |
| 6434 | } |
| 6435 | |
| 6436 | snprintf(buf, sizeof(buf), "ebtables -F"); |
| 6437 | if (system(buf) != 0) { |
| 6438 | sigma_dut_print(dut, DUT_MSG_DEBUG, |
| 6439 | "%s ebtables flushing failed", |
| 6440 | dut->bridge); |
| 6441 | } |
| 6442 | } |
| 6443 | dut->ap_dgaf_disable = 0; |
| 6444 | dut->ap_p2p_cross_connect = 0; |
| 6445 | dut->ap_gas_cb_delay = 0; |
| 6446 | dut->ap_nai_realm_list = 0; |
| 6447 | dut->ap_oper_name = 0; |
| 6448 | dut->ap_venue_name = 0; |
| 6449 | for (i = 0; i < 10; i++) { |
| 6450 | dut->ap_plmn_mcc[i][0] = '\0'; |
| 6451 | dut->ap_plmn_mnc[i][0] = '\0'; |
| 6452 | } |
| 6453 | dut->ap_wan_metrics = 0; |
| 6454 | dut->ap_conn_capab = 0; |
| 6455 | dut->ap_ip_addr_type_avail = 0; |
| 6456 | dut->ap_net_auth_type = 0; |
| 6457 | dut->ap_oper_class = 0; |
| 6458 | dut->ap_pmf = 0; |
| 6459 | dut->ap_add_sha256 = 0; |
| 6460 | } |
| 6461 | |
Adil Saeed Musthafa | 33ea287 | 2017-04-10 23:13:24 -0700 | [diff] [blame] | 6462 | if (dut->program == PROGRAM_HS2_R2 || dut->program == PROGRAM_IOTLP) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6463 | int i; |
| 6464 | const char hessid[] = "50:6f:9a:00:11:22"; |
| 6465 | |
| 6466 | memcpy(dut->ap_hessid, hessid, strlen(hessid) + 1); |
| 6467 | dut->ap_osu_ssid[0] = '\0'; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6468 | dut->ap_pmf = 1; |
| 6469 | dut->ap_osu_provider_list = 0; |
| 6470 | for (i = 0; i < 10; i++) { |
| 6471 | dut->ap_osu_server_uri[i][0] = '\0'; |
| 6472 | dut->ap_osu_method[i] = 0xFF; |
| 6473 | } |
| 6474 | dut->ap_qos_map_set = 0; |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 6475 | dut->ap_tag_key_mgmt[0] = AP2_OPEN; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6476 | dut->ap2_proxy_arp = 0; |
| 6477 | dut->ap_osu_icon_tag = 0; |
| 6478 | } |
| 6479 | |
| 6480 | if (dut->program == PROGRAM_VHT) { |
| 6481 | /* Set up the defaults */ |
| 6482 | dut->ap_mode = AP_11ac; |
| 6483 | dut->ap_channel = 36; |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 6484 | dut->ap_ampdu = VALUE_NOT_SET; |
priyadharshini gowthaman | 264d544 | 2016-02-25 15:52:22 -0800 | [diff] [blame] | 6485 | dut->ap_ndpa_frame = 1; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6486 | if (dut->device_type == AP_testbed) { |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 6487 | dut->ap_amsdu = VALUE_DISABLED; |
| 6488 | dut->ap_ldpc = VALUE_DISABLED; |
| 6489 | dut->ap_rx_amsdu = VALUE_DISABLED; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6490 | dut->ap_sgi80 = 0; |
| 6491 | } else { |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 6492 | dut->ap_amsdu = VALUE_ENABLED; |
Pradeep Reddy POTTETI | 83b8067 | 2016-09-02 13:01:44 +0530 | [diff] [blame] | 6493 | /* |
| 6494 | * As LDPC is optional, don't enable this by default |
| 6495 | * for LINUX-WCN driver. The ap_set_wireless command |
| 6496 | * can be used to enable LDPC, when needed. |
| 6497 | */ |
| 6498 | if (drv != DRIVER_LINUX_WCN) |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 6499 | dut->ap_ldpc = VALUE_ENABLED; |
| 6500 | dut->ap_rx_amsdu = VALUE_ENABLED; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6501 | dut->ap_sgi80 = 1; |
| 6502 | } |
| 6503 | dut->ap_fixed_rate = 0; |
| 6504 | dut->ap_rx_streams = 3; |
| 6505 | dut->ap_tx_streams = 3; |
| 6506 | dut->ap_vhtmcs_map = 0; |
| 6507 | dut->ap_chwidth = AP_80; |
| 6508 | dut->ap_tx_stbc = 1; |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 6509 | dut->ap_dyn_bw_sig = VALUE_ENABLED; |
Mohammed Shafi Shajakhan | bae7230 | 2016-03-02 11:56:23 +0530 | [diff] [blame] | 6510 | if (get_openwrt_driver_type() == OPENWRT_DRIVER_ATHEROS) |
| 6511 | dut->ap_dfs_mode = AP_DFS_MODE_ENABLED; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6512 | if (get_driver_type() == DRIVER_ATHEROS) |
| 6513 | ath_reset_vht_defaults(dut); |
| 6514 | } |
| 6515 | |
Adil Saeed Musthafa | 33ea287 | 2017-04-10 23:13:24 -0700 | [diff] [blame] | 6516 | if (dut->program == PROGRAM_IOTLP) { |
| 6517 | dut->wnm_bss_max_feature = VALUE_DISABLED; |
| 6518 | dut->wnm_bss_max_idle_time = 0; |
| 6519 | dut->wnm_bss_max_protection = VALUE_NOT_SET; |
| 6520 | dut->ap_proxy_arp = 1; |
| 6521 | } else { |
| 6522 | /* |
| 6523 | * Do not touch the BSS-MAX Idle time feature |
| 6524 | * if the program is not IOTLP. |
| 6525 | */ |
| 6526 | dut->wnm_bss_max_feature = VALUE_NOT_SET; |
| 6527 | dut->wnm_bss_max_idle_time = 0; |
| 6528 | dut->wnm_bss_max_protection = VALUE_NOT_SET; |
| 6529 | } |
| 6530 | |
priyadharshini gowthaman | a27b5b6 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 6531 | if (dut->program == PROGRAM_LOC) { |
priyadharshini gowthaman | 8e26ff4 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 6532 | dut->ap_rrm = 1; |
| 6533 | dut->ap_rtt = 1; |
| 6534 | dut->ap_lci = 0; |
| 6535 | dut->ap_val_lci[0] = '\0'; |
priyadharshini gowthaman | c2357bd | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 6536 | dut->ap_infoz[0] = '\0'; |
priyadharshini gowthaman | 8e26ff4 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 6537 | dut->ap_lcr = 0; |
| 6538 | dut->ap_val_lcr[0] = '\0'; |
| 6539 | dut->ap_neighap = 0; |
| 6540 | dut->ap_opchannel = 0; |
| 6541 | dut->ap_scan = 0; |
priyadharshini gowthaman | c2357bd | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 6542 | dut->ap_fqdn_held = 0; |
| 6543 | dut->ap_fqdn_supl = 0; |
priyadharshini gowthaman | c52fff8 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 6544 | dut->ap_interworking = 0; |
| 6545 | dut->ap_gas_cb_delay = 0; |
priyadharshini gowthaman | a27b5b6 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 6546 | dut->ap_msnt_type = 0; |
| 6547 | } |
Adil Saeed Musthafa | 4ec61bd | 2017-04-10 23:13:41 -0700 | [diff] [blame] | 6548 | dut->ap_ft_oa = 0; |
Adil Saeed Musthafa | 604c826 | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 6549 | dut->ap_reg_domain = REG_DOMAIN_NOT_SET; |
Adil Saeed Musthafa | cf752fa | 2017-04-10 23:13:32 -0700 | [diff] [blame] | 6550 | dut->ap_mobility_domain[0] = '\0'; |
priyadharshini gowthaman | a27b5b6 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 6551 | |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 6552 | if (dut->program == PROGRAM_MBO) { |
| 6553 | dut->ap_mbo = 1; |
| 6554 | dut->ap_interworking = 1; |
| 6555 | dut->ap_ne_class = 0; |
| 6556 | dut->ap_ne_op_ch = 0; |
| 6557 | dut->ap_set_bssidpref = 1; |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 6558 | dut->ap_btmreq_disassoc_imnt = 0; |
| 6559 | dut->ap_btmreq_term_bit = 0; |
| 6560 | dut->ap_disassoc_timer = 0; |
| 6561 | dut->ap_btmreq_bss_term_dur = 0; |
Adil Saeed Musthafa | 16d9e63 | 2017-04-10 23:13:38 -0700 | [diff] [blame] | 6562 | dut->ap_channel = 36; |
| 6563 | dut->ap_chwidth = AP_20; |
Adil Saeed Musthafa | 023108a | 2017-04-10 23:13:37 -0700 | [diff] [blame] | 6564 | dut->ap_cell_cap_pref = 0; |
Adil Saeed Musthafa | ed5faae | 2017-04-10 23:13:36 -0700 | [diff] [blame] | 6565 | dut->ap_gas_cb_delay = 0; |
Adil Saeed Musthafa | 6906372 | 2017-04-10 23:13:40 -0700 | [diff] [blame] | 6566 | dut->mbo_self_ap_tuple.ap_ne_class = -1; |
| 6567 | dut->mbo_self_ap_tuple.ap_ne_pref = -1; /* Not set */ |
| 6568 | dut->mbo_self_ap_tuple.ap_ne_op_ch = -1; |
| 6569 | |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 6570 | } |
| 6571 | |
Jouni Malinen | 3c367e8 | 2017-06-23 17:01:47 +0300 | [diff] [blame] | 6572 | free(dut->rsne_override); |
| 6573 | dut->rsne_override = NULL; |
| 6574 | |
Jouni Malinen | 6814313 | 2017-09-02 02:34:08 +0300 | [diff] [blame] | 6575 | free(dut->sae_commit_override); |
| 6576 | dut->sae_commit_override = NULL; |
| 6577 | |
Jouni Malinen | ed670f4 | 2017-08-31 01:39:28 +0300 | [diff] [blame] | 6578 | free(dut->ap_sae_groups); |
| 6579 | dut->ap_sae_groups = NULL; |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 6580 | |
Jouni Malinen | 2f524ce | 2017-08-31 01:43:29 +0300 | [diff] [blame] | 6581 | dut->sae_anti_clogging_threshold = -1; |
Jouni Malinen | b347db0 | 2017-09-02 01:36:03 +0300 | [diff] [blame] | 6582 | dut->sae_reflection = 0; |
Jouni Malinen | 2f524ce | 2017-08-31 01:43:29 +0300 | [diff] [blame] | 6583 | |
Jouni Malinen | 3d633da | 2017-09-14 22:19:21 +0300 | [diff] [blame] | 6584 | dut->ap_cipher = AP_CCMP; |
| 6585 | dut->ap_group_mgmt_cipher = AP_NO_GROUP_MGMT_CIPHER_SET; |
| 6586 | |
Jouni Malinen | d86e582 | 2017-08-29 03:55:32 +0300 | [diff] [blame] | 6587 | dut->dpp_conf_id = -1; |
| 6588 | |
| 6589 | dut->hostapd_running = 0; |
Jouni Malinen | d6bf1b4 | 2017-06-23 17:51:01 +0300 | [diff] [blame] | 6590 | if (dut->use_hostapd_pid_file) { |
| 6591 | kill_hostapd_process_pid(dut); |
| 6592 | } else if (kill_process(dut, "(hostapd)", 1, SIGTERM) == 0 || |
| 6593 | system("killall hostapd") == 0) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6594 | int i; |
| 6595 | /* Wait some time to allow hostapd to complete cleanup before |
| 6596 | * starting a new process */ |
| 6597 | for (i = 0; i < 10; i++) { |
| 6598 | usleep(500000); |
| 6599 | if (system("pidof hostapd") != 0) |
| 6600 | break; |
| 6601 | } |
| 6602 | } |
| 6603 | |
| 6604 | if (if_nametoindex("sigmadut") > 0 && |
| 6605 | system("iw dev sigmadut del") != 0) |
| 6606 | sigma_dut_print(dut, DUT_MSG_ERROR, "Failed to remove " |
| 6607 | "monitor interface"); |
| 6608 | |
| 6609 | return 1; |
| 6610 | } |
| 6611 | |
| 6612 | |
| 6613 | static int cmd_ap_get_info(struct sigma_dut *dut, struct sigma_conn *conn, |
| 6614 | struct sigma_cmd *cmd) |
| 6615 | { |
| 6616 | /* const char *name = get_param(cmd, "NAME"); */ |
| 6617 | struct stat s; |
| 6618 | char resp[200]; |
| 6619 | FILE *f; |
| 6620 | enum driver_type drv = get_driver_type(); |
| 6621 | |
| 6622 | switch (drv) { |
| 6623 | case DRIVER_ATHEROS: { |
| 6624 | /* Atheros AP */ |
| 6625 | struct utsname uts; |
| 6626 | char *version, athver[100]; |
| 6627 | |
| 6628 | if (stat("/proc/athversion", &s) != 0) { |
| 6629 | if (system("/etc/rc.d/rc.wlan up") != 0) { |
| 6630 | } |
| 6631 | } |
| 6632 | |
| 6633 | athver[0] = '\0'; |
| 6634 | f = fopen("/proc/athversion", "r"); |
| 6635 | if (f) { |
| 6636 | if (fgets(athver, sizeof(athver), f)) { |
| 6637 | char *pos = strchr(athver, '\n'); |
| 6638 | if (pos) |
| 6639 | *pos = '\0'; |
| 6640 | } |
| 6641 | fclose(f); |
| 6642 | } |
| 6643 | |
| 6644 | if (uname(&uts) == 0) |
| 6645 | version = uts.release; |
| 6646 | else |
| 6647 | version = "Unknown"; |
| 6648 | |
| 6649 | if (if_nametoindex("ath1") > 0) |
| 6650 | snprintf(resp, sizeof(resp), "interface,ath0_24G " |
| 6651 | "ath1_5G,agent,1.0,version,%s/drv:%s", |
| 6652 | version, athver); |
| 6653 | else |
| 6654 | snprintf(resp, sizeof(resp), "interface,ath0_24G," |
| 6655 | "agent,1.0,version,%s/drv:%s", |
| 6656 | version, athver); |
| 6657 | |
| 6658 | send_resp(dut, conn, SIGMA_COMPLETE, resp); |
| 6659 | return 0; |
| 6660 | } |
Sreelakshmi Konamki | b692f10 | 2016-04-26 19:47:00 +0530 | [diff] [blame] | 6661 | case DRIVER_LINUX_WCN: |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6662 | case DRIVER_MAC80211: { |
| 6663 | struct utsname uts; |
| 6664 | char *version; |
| 6665 | |
| 6666 | if (uname(&uts) == 0) |
| 6667 | version = uts.release; |
| 6668 | else |
| 6669 | version = "Unknown"; |
| 6670 | |
| 6671 | if (if_nametoindex("wlan1") > 0) |
| 6672 | snprintf(resp, sizeof(resp), "interface,wlan0_24G " |
| 6673 | "wlan1_5G,agent,1.0,version,%s", version); |
| 6674 | else |
| 6675 | snprintf(resp, sizeof(resp), "interface,wlan0_any," |
| 6676 | "agent,1.0,version,%s", version); |
| 6677 | |
| 6678 | send_resp(dut, conn, SIGMA_COMPLETE, resp); |
| 6679 | return 0; |
| 6680 | } |
| 6681 | case DRIVER_QNXNTO: { |
| 6682 | struct utsname uts; |
| 6683 | char *version; |
| 6684 | |
| 6685 | if (uname(&uts) == 0) |
| 6686 | version = uts.release; |
| 6687 | else |
| 6688 | version = "Unknown"; |
| 6689 | snprintf(resp, sizeof(resp), |
| 6690 | "interface,%s_any,agent,1.0,version,%s", |
| 6691 | sigma_main_ifname ? sigma_main_ifname : "NA", |
| 6692 | version); |
| 6693 | send_resp(dut, conn, SIGMA_COMPLETE, resp); |
| 6694 | return 0; |
| 6695 | } |
| 6696 | case DRIVER_OPENWRT: { |
| 6697 | switch (get_openwrt_driver_type()) { |
| 6698 | case OPENWRT_DRIVER_ATHEROS: { |
| 6699 | struct utsname uts; |
| 6700 | char *version; |
| 6701 | |
| 6702 | if (uname(&uts) == 0) |
| 6703 | version = uts.release; |
| 6704 | else |
| 6705 | version = "Unknown"; |
| 6706 | |
| 6707 | if (if_nametoindex("ath1") > 0) |
| 6708 | snprintf(resp, sizeof(resp), |
| 6709 | "interface,ath0_5G ath1_24G,agent,1.0,version,%s", |
| 6710 | version); |
| 6711 | else |
| 6712 | snprintf(resp, sizeof(resp), |
| 6713 | "interface,ath0_any,agent,1.0,version,%s", |
| 6714 | version); |
| 6715 | |
| 6716 | send_resp(dut, conn, SIGMA_COMPLETE, resp); |
| 6717 | return 0; |
| 6718 | } |
| 6719 | default: |
| 6720 | send_resp(dut, conn, SIGMA_ERROR, |
| 6721 | "errorCode,Unsupported openwrt driver"); |
| 6722 | return 0; |
| 6723 | } |
| 6724 | } |
| 6725 | default: |
| 6726 | send_resp(dut, conn, SIGMA_ERROR, |
| 6727 | "errorCode,Unsupported driver"); |
| 6728 | return 0; |
| 6729 | } |
| 6730 | } |
| 6731 | |
| 6732 | |
| 6733 | static int cmd_ap_deauth_sta(struct sigma_dut *dut, struct sigma_conn *conn, |
| 6734 | struct sigma_cmd *cmd) |
| 6735 | { |
| 6736 | /* const char *name = get_param(cmd, "NAME"); */ |
| 6737 | /* const char *ifname = get_param(cmd, "INTERFACE"); */ |
| 6738 | const char *val; |
| 6739 | char buf[100]; |
| 6740 | |
| 6741 | val = get_param(cmd, "MinorCode"); |
| 6742 | if (val) { |
| 6743 | /* TODO: add support for P2P minor code */ |
| 6744 | send_resp(dut, conn, SIGMA_ERROR, "errorCode,MinorCode not " |
| 6745 | "yet supported"); |
| 6746 | return 0; |
| 6747 | } |
| 6748 | |
| 6749 | val = get_param(cmd, "STA_MAC_ADDRESS"); |
| 6750 | if (val == NULL) |
| 6751 | return -1; |
| 6752 | snprintf(buf, sizeof(buf), "deauth %s", val); |
| 6753 | if (run_hostapd_cli(dut, buf) != 0) |
| 6754 | return -2; |
| 6755 | |
| 6756 | return 1; |
| 6757 | } |
| 6758 | |
| 6759 | |
| 6760 | #ifdef __linux__ |
| 6761 | int inject_frame(int s, const void *data, size_t len, int encrypt); |
| 6762 | int open_monitor(const char *ifname); |
| 6763 | int hwaddr_aton(const char *txt, unsigned char *addr); |
| 6764 | #endif /* __linux__ */ |
| 6765 | |
| 6766 | enum send_frame_type { |
| 6767 | DISASSOC, DEAUTH, SAQUERY |
| 6768 | }; |
| 6769 | enum send_frame_protection { |
| 6770 | CORRECT_KEY, INCORRECT_KEY, UNPROTECTED |
| 6771 | }; |
| 6772 | |
| 6773 | |
| 6774 | static int ap_inject_frame(struct sigma_dut *dut, struct sigma_conn *conn, |
| 6775 | enum send_frame_type frame, |
| 6776 | enum send_frame_protection protected, |
| 6777 | const char *sta_addr) |
| 6778 | { |
| 6779 | #ifdef __linux__ |
| 6780 | unsigned char buf[1000], *pos; |
| 6781 | int s, res; |
| 6782 | unsigned char addr_sta[6], addr_own[6]; |
| 6783 | char *ifname; |
| 6784 | char cbuf[100]; |
| 6785 | struct ifreq ifr; |
| 6786 | |
| 6787 | if ((dut->ap_mode == AP_11a || dut->ap_mode == AP_11na || |
| 6788 | dut->ap_mode == AP_11ac) && |
| 6789 | if_nametoindex("wlan1") > 0) |
| 6790 | ifname = "wlan1"; |
| 6791 | else |
| 6792 | ifname = "wlan0"; |
| 6793 | |
| 6794 | if (hwaddr_aton(sta_addr, addr_sta) < 0) |
| 6795 | return -1; |
| 6796 | |
| 6797 | s = socket(AF_INET, SOCK_DGRAM, 0); |
| 6798 | if (s < 0) |
| 6799 | return -1; |
| 6800 | memset(&ifr, 0, sizeof(ifr)); |
Peng Xu | b8fc5cc | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 6801 | strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name)); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6802 | if (ioctl(s, SIOCGIFHWADDR, &ifr) < 0) { |
| 6803 | perror("ioctl"); |
| 6804 | close(s); |
| 6805 | return -1; |
| 6806 | } |
| 6807 | close(s); |
| 6808 | memcpy(addr_own, ifr.ifr_hwaddr.sa_data, 6); |
| 6809 | |
| 6810 | if (if_nametoindex("sigmadut") == 0) { |
| 6811 | snprintf(cbuf, sizeof(cbuf), |
| 6812 | "iw dev %s interface add sigmadut type monitor", |
| 6813 | ifname); |
| 6814 | if (system(cbuf) != 0 || |
| 6815 | if_nametoindex("sigmadut") == 0) { |
| 6816 | sigma_dut_print(dut, DUT_MSG_ERROR, "Failed to add " |
| 6817 | "monitor interface with '%s'", cbuf); |
| 6818 | return -2; |
| 6819 | } |
| 6820 | } |
| 6821 | |
| 6822 | if (system("ifconfig sigmadut up") != 0) { |
| 6823 | sigma_dut_print(dut, DUT_MSG_ERROR, "Failed to set " |
| 6824 | "monitor interface up"); |
| 6825 | return -2; |
| 6826 | } |
| 6827 | |
| 6828 | pos = buf; |
| 6829 | |
| 6830 | /* Frame Control */ |
| 6831 | switch (frame) { |
| 6832 | case DISASSOC: |
| 6833 | *pos++ = 0xa0; |
| 6834 | break; |
| 6835 | case DEAUTH: |
| 6836 | *pos++ = 0xc0; |
| 6837 | break; |
| 6838 | case SAQUERY: |
| 6839 | *pos++ = 0xd0; |
| 6840 | break; |
| 6841 | } |
| 6842 | |
| 6843 | if (protected == INCORRECT_KEY) |
| 6844 | *pos++ = 0x40; /* Set Protected field to 1 */ |
| 6845 | else |
| 6846 | *pos++ = 0x00; |
| 6847 | |
| 6848 | /* Duration */ |
| 6849 | *pos++ = 0x00; |
| 6850 | *pos++ = 0x00; |
| 6851 | |
| 6852 | /* addr1 = DA (station) */ |
| 6853 | memcpy(pos, addr_sta, 6); |
| 6854 | pos += 6; |
| 6855 | /* addr2 = SA (own address) */ |
| 6856 | memcpy(pos, addr_own, 6); |
| 6857 | pos += 6; |
| 6858 | /* addr3 = BSSID (own address) */ |
| 6859 | memcpy(pos, addr_own, 6); |
| 6860 | pos += 6; |
| 6861 | |
| 6862 | /* Seq# (to be filled by driver/mac80211) */ |
| 6863 | *pos++ = 0x00; |
| 6864 | *pos++ = 0x00; |
| 6865 | |
| 6866 | if (protected == INCORRECT_KEY) { |
| 6867 | /* CCMP parameters */ |
| 6868 | memcpy(pos, "\x61\x01\x00\x20\x00\x10\x00\x00", 8); |
| 6869 | pos += 8; |
| 6870 | } |
| 6871 | |
| 6872 | if (protected == INCORRECT_KEY) { |
| 6873 | switch (frame) { |
| 6874 | case DEAUTH: |
| 6875 | /* Reason code (encrypted) */ |
| 6876 | memcpy(pos, "\xa7\x39", 2); |
| 6877 | pos += 2; |
| 6878 | break; |
| 6879 | case DISASSOC: |
| 6880 | /* Reason code (encrypted) */ |
| 6881 | memcpy(pos, "\xa7\x39", 2); |
| 6882 | pos += 2; |
| 6883 | break; |
| 6884 | case SAQUERY: |
| 6885 | /* Category|Action|TransID (encrypted) */ |
| 6886 | memcpy(pos, "\x6f\xbd\xe9\x4d", 4); |
| 6887 | pos += 4; |
| 6888 | break; |
| 6889 | default: |
| 6890 | return -1; |
| 6891 | } |
| 6892 | |
| 6893 | /* CCMP MIC */ |
| 6894 | memcpy(pos, "\xc8\xd8\x3b\x06\x5d\xb7\x25\x68", 8); |
| 6895 | pos += 8; |
| 6896 | } else { |
| 6897 | switch (frame) { |
| 6898 | case DEAUTH: |
| 6899 | /* reason code = 8 */ |
| 6900 | *pos++ = 0x08; |
| 6901 | *pos++ = 0x00; |
| 6902 | break; |
| 6903 | case DISASSOC: |
| 6904 | /* reason code = 8 */ |
| 6905 | *pos++ = 0x08; |
| 6906 | *pos++ = 0x00; |
| 6907 | break; |
| 6908 | case SAQUERY: |
| 6909 | /* Category - SA Query */ |
| 6910 | *pos++ = 0x08; |
| 6911 | /* SA query Action - Request */ |
| 6912 | *pos++ = 0x00; |
| 6913 | /* Transaction ID */ |
| 6914 | *pos++ = 0x12; |
| 6915 | *pos++ = 0x34; |
| 6916 | break; |
| 6917 | } |
| 6918 | } |
| 6919 | |
| 6920 | s = open_monitor("sigmadut"); |
| 6921 | if (s < 0) { |
| 6922 | send_resp(dut, conn, SIGMA_ERROR, "errorCode,Failed to open " |
| 6923 | "monitor socket"); |
| 6924 | return 0; |
| 6925 | } |
| 6926 | |
| 6927 | res = inject_frame(s, buf, pos - buf, protected == CORRECT_KEY); |
| 6928 | if (res < 0) { |
| 6929 | send_resp(dut, conn, SIGMA_ERROR, "errorCode,Failed to " |
| 6930 | "inject frame"); |
Pradeep Reddy POTTETI | 673d85c | 2016-07-26 19:08:07 +0530 | [diff] [blame] | 6931 | close(s); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6932 | return 0; |
| 6933 | } |
| 6934 | if (res < pos - buf) { |
| 6935 | send_resp(dut, conn, SIGMA_ERROR, "errorCode,Only partial " |
| 6936 | "frame sent"); |
Pradeep Reddy POTTETI | 673d85c | 2016-07-26 19:08:07 +0530 | [diff] [blame] | 6937 | close(s); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6938 | return 0; |
| 6939 | } |
| 6940 | |
| 6941 | close(s); |
| 6942 | |
| 6943 | return 1; |
| 6944 | #else /* __linux__ */ |
| 6945 | send_resp(dut, conn, SIGMA_ERROR, "errorCode,ap_send_frame not " |
| 6946 | "yet supported"); |
| 6947 | return 0; |
| 6948 | #endif /* __linux__ */ |
| 6949 | } |
| 6950 | |
| 6951 | |
| 6952 | int ap_send_frame_hs2(struct sigma_dut *dut, struct sigma_conn *conn, |
| 6953 | struct sigma_cmd *cmd) |
| 6954 | { |
| 6955 | const char *val, *dest; |
| 6956 | char buf[100]; |
| 6957 | |
| 6958 | val = get_param(cmd, "FrameName"); |
| 6959 | if (val == NULL) |
| 6960 | return -1; |
| 6961 | |
| 6962 | if (strcasecmp(val, "QoSMapConfigure") == 0) { |
| 6963 | dest = get_param(cmd, "Dest"); |
| 6964 | if (!dest) |
| 6965 | return -1; |
| 6966 | |
| 6967 | val = get_param(cmd, "QoS_MAP_SET"); |
| 6968 | if (val) { |
| 6969 | dut->ap_qos_map_set = atoi(val); |
| 6970 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_qos_map_set %d", |
| 6971 | dut->ap_qos_map_set); |
| 6972 | } |
| 6973 | |
| 6974 | if (dut->ap_qos_map_set == 1) |
| 6975 | run_hostapd_cli(dut, "set_qos_map_set " QOS_MAP_SET_1); |
| 6976 | else if (dut->ap_qos_map_set == 2) |
| 6977 | run_hostapd_cli(dut, "set_qos_map_set " QOS_MAP_SET_2); |
| 6978 | |
| 6979 | snprintf(buf, sizeof(buf), "send_qos_map_conf %s", dest); |
| 6980 | if (run_hostapd_cli(dut, buf) != 0) |
| 6981 | return -1; |
| 6982 | } |
| 6983 | |
| 6984 | return 1; |
| 6985 | } |
| 6986 | |
| 6987 | |
| 6988 | static int ath_ap_send_frame_vht(struct sigma_dut *dut, struct sigma_conn *conn, |
| 6989 | struct sigma_cmd *cmd) |
| 6990 | { |
| 6991 | const char *val; |
| 6992 | char *ifname; |
| 6993 | char buf[100]; |
| 6994 | int chwidth, nss; |
| 6995 | |
| 6996 | val = get_param(cmd, "FrameName"); |
| 6997 | if (!val || strcasecmp(val, "op_md_notif_frm") != 0) { |
| 6998 | send_resp(dut, conn, SIGMA_ERROR, |
| 6999 | "errorCode,Unsupported FrameName"); |
| 7000 | return 0; |
| 7001 | } |
| 7002 | |
| 7003 | /* |
| 7004 | * Sequence of commands for Opmode notification on |
| 7005 | * Peregrine based products |
| 7006 | */ |
| 7007 | ifname = get_main_ifname(); |
| 7008 | |
| 7009 | /* Disable STBC */ |
| 7010 | snprintf(buf, sizeof(buf), "iwpriv %s tx_stbc 0", ifname); |
| 7011 | if (system(buf) != 0) { |
| 7012 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 7013 | "iwpriv tx_stbc 0 failed!"); |
| 7014 | } |
| 7015 | |
| 7016 | /* Check whether optional arg channel width was passed */ |
| 7017 | val = get_param(cmd, "Channel_width"); |
| 7018 | if (val) { |
| 7019 | switch (atoi(val)) { |
| 7020 | case 20: |
| 7021 | chwidth = 0; |
| 7022 | break; |
| 7023 | case 40: |
| 7024 | chwidth = 1; |
| 7025 | break; |
| 7026 | case 80: |
| 7027 | chwidth = 2; |
| 7028 | break; |
| 7029 | case 160: |
| 7030 | chwidth = 3; |
| 7031 | break; |
| 7032 | default: |
| 7033 | chwidth = 2; |
| 7034 | break; |
| 7035 | } |
| 7036 | snprintf(buf, sizeof(buf), "iwpriv %s chwidth %d", |
| 7037 | ifname, chwidth); |
| 7038 | if (system(buf) != 0) { |
| 7039 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 7040 | "iwpriv chwidth failed!"); |
| 7041 | } |
| 7042 | } |
| 7043 | |
| 7044 | /* Check whether optional arg NSS was passed */ |
| 7045 | val = get_param(cmd, "NSS"); |
| 7046 | if (val) { |
| 7047 | /* Convert nss to chainmask */ |
| 7048 | switch (atoi(val)) { |
| 7049 | case 1: |
| 7050 | nss = 1; |
| 7051 | break; |
| 7052 | case 2: |
| 7053 | nss = 3; |
| 7054 | break; |
| 7055 | case 3: |
| 7056 | nss = 7; |
| 7057 | break; |
| 7058 | default: |
| 7059 | /* We do not support NSS > 3 */ |
| 7060 | nss = 3; |
| 7061 | break; |
| 7062 | } |
| 7063 | snprintf(buf, sizeof(buf), "iwpriv %s rxchainmask %d", |
| 7064 | ifname, nss); |
| 7065 | if (system(buf) != 0) { |
| 7066 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 7067 | "iwpriv rxchainmask failed!"); |
| 7068 | } |
| 7069 | } |
| 7070 | |
| 7071 | /* Send the opmode notification */ |
Sunil Dutt | 27ec7f6 | 2017-09-14 18:22:59 +0300 | [diff] [blame] | 7072 | snprintf(buf, sizeof(buf), "iwpriv %s opmode_notify 1", ifname); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7073 | if (system(buf) != 0) { |
| 7074 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 7075 | "iwpriv opmode_notify failed!"); |
| 7076 | } |
| 7077 | |
| 7078 | return 1; |
| 7079 | } |
| 7080 | |
| 7081 | |
priyadharshini gowthaman | a27b5b6 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 7082 | static int ath_ap_send_frame_loc(struct sigma_dut *dut, struct sigma_conn *conn, |
| 7083 | struct sigma_cmd *cmd) |
| 7084 | { |
| 7085 | const char *val; |
| 7086 | FILE *f; |
priyadharshini gowthaman | a61badd | 2016-08-16 13:37:27 -0700 | [diff] [blame] | 7087 | int rand_int = 0; |
priyadharshini gowthaman | a27b5b6 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 7088 | |
| 7089 | val = get_param(cmd, "MsntType"); |
| 7090 | if (val) { |
| 7091 | if (dut->ap_msnt_type == 0) |
| 7092 | dut->ap_msnt_type = atoi(val); |
| 7093 | |
| 7094 | if (dut->ap_msnt_type != 5 && dut->ap_msnt_type != 2) { |
| 7095 | dut->ap_msnt_type = atoi(val); |
| 7096 | if (dut->ap_msnt_type == 1) { |
priyadharshini gowthaman | a61badd | 2016-08-16 13:37:27 -0700 | [diff] [blame] | 7097 | val = get_param(cmd, "RandInterval"); |
| 7098 | if (val) |
| 7099 | rand_int = atoi(val); |
priyadharshini gowthaman | a27b5b6 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 7100 | f = fopen("/tmp/ftmrr.txt", "a"); |
| 7101 | if (!f) { |
| 7102 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 7103 | "Failed to open /tmp/ftmrr.txt"); |
| 7104 | return -1; |
| 7105 | } |
| 7106 | |
| 7107 | fprintf(f, "sta_mac = %s\n", cmd->values[3]); |
priyadharshini gowthaman | a61badd | 2016-08-16 13:37:27 -0700 | [diff] [blame] | 7108 | 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", |
| 7109 | rand_int, cmd->values[7]); |
priyadharshini gowthaman | a27b5b6 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 7110 | fclose(f); |
| 7111 | dut->ap_msnt_type = 5; |
| 7112 | run_system(dut, "wpc -f /tmp/ftmrr.txt"); |
| 7113 | } |
| 7114 | } else if (dut->ap_msnt_type == 5) { |
| 7115 | run_system(dut, "wpc -f /tmp/ftmrr.txt"); |
| 7116 | } else if (dut->ap_msnt_type == 2) { |
| 7117 | f = fopen("/tmp/wru.txt", "w"); |
| 7118 | if (!f) { |
| 7119 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 7120 | "Failed to open /tmp/wru.txt"); |
| 7121 | return -1; |
| 7122 | } |
| 7123 | |
| 7124 | fprintf(f, "sta_mac = %s\n", cmd->values[3]); |
| 7125 | fprintf(f, "meas_type = 0x08\ndialogtoken = 0x1\nnum_repetitions = 0x0\nmeas_token = 0x1\nmeas_req_mode = 0x00\nloc_subject = 0x01\n"); |
| 7126 | fclose(f); |
| 7127 | run_system(dut, "wpc -w /tmp/wru.txt"); |
| 7128 | } |
| 7129 | } |
| 7130 | return 1; |
| 7131 | } |
| 7132 | |
| 7133 | |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 7134 | /* |
| 7135 | * The following functions parse_send_frame_params_int(), |
| 7136 | * parse_send_frame_params_str(), and parse_send_frame_params_mac() |
| 7137 | * are used by ath_ap_send_frame_bcn_rpt_req(). |
| 7138 | * Beacon Report Request is a frame used as part of the MBO program. |
| 7139 | * The command for sending beacon report has a lot of |
| 7140 | * arguments and having these functions reduces code size. |
| 7141 | * |
| 7142 | */ |
| 7143 | static int parse_send_frame_params_int(char *param, struct sigma_cmd *cmd, |
| 7144 | struct sigma_dut *dut, |
| 7145 | char *buf, size_t buf_size) |
| 7146 | { |
| 7147 | const char *str_val; |
| 7148 | int int_val; |
| 7149 | char temp[100]; |
| 7150 | |
| 7151 | str_val = get_param(cmd, param); |
| 7152 | if (!str_val) { |
| 7153 | sigma_dut_print(dut, DUT_MSG_ERROR, "%s not given", param); |
| 7154 | return -1; |
| 7155 | } |
| 7156 | int_val = atoi(str_val); |
| 7157 | snprintf(temp, sizeof(temp), " %d", int_val); |
Peng Xu | 591be45 | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 7158 | strlcat(buf, temp, buf_size); |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 7159 | return 0; |
| 7160 | } |
| 7161 | |
| 7162 | |
| 7163 | static int parse_send_frame_params_str(char *param, struct sigma_cmd *cmd, |
| 7164 | struct sigma_dut *dut, |
| 7165 | char *buf, size_t buf_size) |
| 7166 | { |
| 7167 | const char *str_val; |
| 7168 | char temp[100]; |
| 7169 | |
| 7170 | str_val = get_param(cmd, param); |
| 7171 | if (!str_val) { |
| 7172 | sigma_dut_print(dut, DUT_MSG_ERROR, "%s not given", param); |
| 7173 | return -1; |
| 7174 | } |
| 7175 | snprintf(temp, sizeof(temp), " %s", str_val); |
| 7176 | temp[sizeof(temp) - 1] = '\0'; |
Peng Xu | 591be45 | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 7177 | strlcat(buf, temp, buf_size); |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 7178 | return 0; |
| 7179 | } |
| 7180 | |
| 7181 | |
| 7182 | static int parse_send_frame_params_mac(char *param, struct sigma_cmd *cmd, |
| 7183 | struct sigma_dut *dut, |
| 7184 | char *buf, size_t buf_size) |
| 7185 | { |
| 7186 | const char *str_val; |
| 7187 | unsigned char mac[6]; |
| 7188 | char temp[100]; |
| 7189 | |
| 7190 | str_val = get_param(cmd, param); |
| 7191 | if (!str_val) { |
| 7192 | sigma_dut_print(dut, DUT_MSG_ERROR, "%s not given", param); |
| 7193 | return -1; |
| 7194 | } |
| 7195 | |
| 7196 | if (parse_mac_address(dut, str_val, mac) < 0) { |
| 7197 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 7198 | "MAC Address not in proper format"); |
| 7199 | return -1; |
| 7200 | } |
| 7201 | snprintf(temp, sizeof(temp), " %02x:%02x:%02x:%02x:%02x:%02x", |
| 7202 | mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]); |
Peng Xu | 591be45 | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 7203 | strlcat(buf, temp, buf_size); |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 7204 | return 0; |
| 7205 | } |
| 7206 | |
| 7207 | |
| 7208 | static void fill_1_or_0_based_on_presence(struct sigma_cmd *cmd, char *param, |
| 7209 | char *buf, size_t buf_size) |
| 7210 | { |
| 7211 | const char *str_val; |
| 7212 | char *value = " 1"; |
| 7213 | |
| 7214 | str_val = get_param(cmd, param); |
| 7215 | if (!str_val || str_val[0] == '\0') |
| 7216 | value = " 0"; |
Peng Xu | 591be45 | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 7217 | strlcat(buf, value, buf_size); |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 7218 | |
| 7219 | } |
| 7220 | |
| 7221 | |
| 7222 | /* |
| 7223 | * wifitool athN sendbcnrpt |
| 7224 | * <STA MAC - Plugs in from Dest_MAC> |
| 7225 | * <regclass - Plugs in from RegClass - int> |
| 7226 | * <channum - Plugs in from Channel PARAM of dev_send_frame - int> |
| 7227 | * <rand_ivl - Plugs in from RandInt - string> |
| 7228 | * <duration - Plugs in from MeaDur - integer> |
| 7229 | * <mode - Plugs in from MeaMode - string> |
| 7230 | * <req_ssid - Plugs in from SSID PARAM of dev_send_frame - string> |
| 7231 | * <rep_cond - Plugs in from RptCond - integer> |
| 7232 | * <rpt_detail - Plugs in from RptDet - integer> |
| 7233 | * <req_ie - Plugs in from ReqInfo PARAM of dev_send_frame - string> |
| 7234 | * <chanrpt_mode - Plugs in from APChanRpt - integer> |
| 7235 | * <specific_bssid - Plugs in from BSSID PARAM of dev_send_frame> |
| 7236 | * [AP channel numbers] |
| 7237 | */ |
| 7238 | static int ath_ap_send_frame_bcn_rpt_req(struct sigma_dut *dut, |
| 7239 | struct sigma_cmd *cmd, |
| 7240 | const char *ifname) |
| 7241 | { |
| 7242 | char buf[100]; |
| 7243 | int rpt_det; |
| 7244 | const char *str_val; |
| 7245 | const char *mea_mode; |
| 7246 | |
| 7247 | snprintf(buf, sizeof(buf), "wifitool %s sendbcnrpt", ifname); |
| 7248 | |
| 7249 | if (parse_send_frame_params_mac("Dest_MAC", cmd, dut, buf, sizeof(buf))) |
| 7250 | return -1; |
| 7251 | if (parse_send_frame_params_int("RegClass", cmd, dut, buf, sizeof(buf))) |
| 7252 | return -1; |
| 7253 | if (parse_send_frame_params_int("Channel", cmd, dut, buf, sizeof(buf))) |
| 7254 | return -1; |
| 7255 | if (parse_send_frame_params_str("RandInt", cmd, dut, buf, sizeof(buf))) |
| 7256 | return -1; |
| 7257 | if (parse_send_frame_params_int("MeaDur", cmd, dut, buf, sizeof(buf))) |
| 7258 | return -1; |
| 7259 | |
| 7260 | str_val = get_param(cmd, "MeaMode"); |
| 7261 | if (!str_val) { |
| 7262 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 7263 | "MeaMode parameter not present in send bcn-rpt-req"); |
| 7264 | return -1; |
| 7265 | } |
| 7266 | if (strcasecmp(str_val, "passive") == 0) { |
| 7267 | mea_mode = " 0"; |
| 7268 | } else if (strcasecmp(str_val, "active") == 0) { |
| 7269 | mea_mode = " 1"; |
| 7270 | } else if (strcasecmp(str_val, "table") == 0) { |
| 7271 | mea_mode = " 2"; |
| 7272 | } else { |
| 7273 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 7274 | "MEA-MODE Value not correctly given"); |
| 7275 | return -1; |
| 7276 | } |
Peng Xu | 591be45 | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 7277 | strlcat(buf, mea_mode, sizeof(buf)); |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 7278 | |
| 7279 | fill_1_or_0_based_on_presence(cmd, "SSID", buf, sizeof(buf)); |
| 7280 | |
| 7281 | if (parse_send_frame_params_int("RptCond", cmd, dut, buf, sizeof(buf))) |
| 7282 | return -1; |
| 7283 | |
| 7284 | if (parse_send_frame_params_int("RptDet", cmd, dut, buf, sizeof(buf))) |
| 7285 | return -1; |
| 7286 | str_val = get_param(cmd, "RptDet"); |
| 7287 | rpt_det = str_val ? atoi(str_val) : 0; |
| 7288 | |
| 7289 | if (rpt_det) |
| 7290 | fill_1_or_0_based_on_presence(cmd, "ReqInfo", buf, sizeof(buf)); |
| 7291 | else |
Peng Xu | 591be45 | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 7292 | strlcat(buf, " 0", sizeof(buf)); |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 7293 | |
| 7294 | if (rpt_det) |
| 7295 | fill_1_or_0_based_on_presence(cmd, "APChanRpt", buf, |
| 7296 | sizeof(buf)); |
| 7297 | else |
Peng Xu | 591be45 | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 7298 | strlcat(buf, " 0", sizeof(buf)); |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 7299 | |
| 7300 | if (parse_send_frame_params_mac("BSSID", cmd, dut, buf, sizeof(buf))) |
| 7301 | return -1; |
| 7302 | |
| 7303 | run_system(dut, buf); |
| 7304 | return 0; |
| 7305 | } |
| 7306 | |
| 7307 | |
| 7308 | static void inform_and_sleep(struct sigma_dut *dut, int seconds) |
| 7309 | { |
| 7310 | sigma_dut_print(dut, DUT_MSG_DEBUG, "sleeping for %d seconds", seconds); |
| 7311 | sleep(seconds); |
| 7312 | sigma_dut_print(dut, DUT_MSG_DEBUG, "woke up after %d seconds", |
| 7313 | seconds); |
| 7314 | } |
| 7315 | |
| 7316 | |
| 7317 | static int ath_ap_send_frame_btm_req(struct sigma_dut *dut, |
| 7318 | struct sigma_cmd *cmd, const char *ifname) |
| 7319 | { |
| 7320 | unsigned char mac_addr[ETH_ALEN]; |
| 7321 | int disassoc_timer; |
| 7322 | char buf[100]; |
| 7323 | const char *val; |
| 7324 | int cand_list = 1; |
| 7325 | int tsf = 2; |
| 7326 | |
| 7327 | val = get_param(cmd, "Dest_MAC"); |
| 7328 | if (!val || parse_mac_address(dut, val, mac_addr) < 0) { |
| 7329 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 7330 | "MAC Address not in proper format"); |
| 7331 | return -1; |
| 7332 | } |
| 7333 | |
| 7334 | val = get_param(cmd, "Disassoc_Timer"); |
| 7335 | if (val) |
| 7336 | disassoc_timer = atoi(val); |
| 7337 | else |
| 7338 | disassoc_timer = dut->ap_disassoc_timer; |
| 7339 | |
| 7340 | val = get_param(cmd, "Cand_List"); |
| 7341 | if (val && val[0]) |
| 7342 | cand_list = atoi(val); |
| 7343 | |
| 7344 | val = get_param(cmd, "BTMQuery_Reason_Code"); |
| 7345 | if (val) { |
| 7346 | snprintf(buf, sizeof(buf), "iwpriv %s mbo_trans_rs %s", |
| 7347 | ifname, val); |
| 7348 | run_system(dut, buf); |
| 7349 | } |
| 7350 | |
| 7351 | snprintf(buf, sizeof(buf), |
| 7352 | "wifitool %s sendbstmreq %02x:%02x:%02x:%02x:%02x:%02x %d %d 3 %d %d %d %d", |
| 7353 | ifname, mac_addr[0], mac_addr[1], mac_addr[2], mac_addr[3], |
| 7354 | mac_addr[4], mac_addr[5], cand_list, disassoc_timer, |
| 7355 | dut->ap_btmreq_disassoc_imnt, |
| 7356 | dut->ap_btmreq_term_bit, |
| 7357 | tsf, |
| 7358 | dut->ap_btmreq_bss_term_dur); |
| 7359 | run_system(dut, buf); |
| 7360 | |
| 7361 | if (dut->ap_btmreq_term_bit) { |
| 7362 | inform_and_sleep(dut, 3); |
| 7363 | run_system_wrapper(dut, "ifconfig %s down", ifname); |
| 7364 | inform_and_sleep(dut, dut->ap_btmreq_bss_term_dur * 60); |
| 7365 | run_system_wrapper(dut, "ifconfig %s up", ifname); |
| 7366 | } else if (dut->ap_btmreq_disassoc_imnt) { |
| 7367 | inform_and_sleep(dut, (disassoc_timer / 1000) + 1); |
| 7368 | run_system_wrapper(dut, |
| 7369 | "iwpriv %s kickmac %02x:%02x:%02x:%02x:%02x:%02x", |
| 7370 | ifname, |
| 7371 | mac_addr[0], mac_addr[1], mac_addr[2], |
| 7372 | mac_addr[3], mac_addr[4], mac_addr[5]); |
| 7373 | } |
| 7374 | return 0; |
| 7375 | } |
| 7376 | |
| 7377 | |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 7378 | static int ath_ap_send_frame_mbo(struct sigma_dut *dut, struct sigma_conn *conn, |
| 7379 | struct sigma_cmd *cmd) |
| 7380 | { |
| 7381 | const char *val; |
| 7382 | char *ifname; |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 7383 | |
| 7384 | ifname = get_main_ifname(); |
| 7385 | |
| 7386 | val = get_param(cmd, "FrameName"); |
| 7387 | if (!val) |
| 7388 | return -1; |
| 7389 | |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 7390 | if (strcasecmp(val, "BTMReq") == 0) |
| 7391 | ath_ap_send_frame_btm_req(dut, cmd, ifname); |
| 7392 | else if (strcasecmp(val, "BcnRptReq") == 0) |
| 7393 | ath_ap_send_frame_bcn_rpt_req(dut, cmd, ifname); |
| 7394 | else |
| 7395 | return -1; |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 7396 | |
| 7397 | return 1; |
| 7398 | } |
| 7399 | |
| 7400 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7401 | static int ap_send_frame_vht(struct sigma_dut *dut, struct sigma_conn *conn, |
| 7402 | struct sigma_cmd *cmd) |
| 7403 | { |
| 7404 | switch (get_driver_type()) { |
| 7405 | case DRIVER_ATHEROS: |
| 7406 | return ath_ap_send_frame_vht(dut, conn, cmd); |
| 7407 | break; |
| 7408 | case DRIVER_OPENWRT: |
| 7409 | switch (get_openwrt_driver_type()) { |
| 7410 | case OPENWRT_DRIVER_ATHEROS: |
| 7411 | return ath_ap_send_frame_vht(dut, conn, cmd); |
| 7412 | default: |
| 7413 | send_resp(dut, conn, SIGMA_ERROR, |
| 7414 | "errorCode,Unsupported ap_send_frame with the current openwrt driver"); |
| 7415 | return 0; |
| 7416 | } |
| 7417 | default: |
| 7418 | send_resp(dut, conn, SIGMA_ERROR, |
| 7419 | "errorCode,Unsupported ap_send_frame with the current driver"); |
| 7420 | return 0; |
| 7421 | } |
| 7422 | } |
| 7423 | |
| 7424 | |
priyadharshini gowthaman | a27b5b6 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 7425 | static int ap_send_frame_loc(struct sigma_dut *dut, struct sigma_conn *conn, |
| 7426 | struct sigma_cmd *cmd) |
| 7427 | { |
| 7428 | switch (get_driver_type()) { |
| 7429 | case DRIVER_ATHEROS: |
| 7430 | return ath_ap_send_frame_loc(dut, conn, cmd); |
| 7431 | case DRIVER_OPENWRT: |
| 7432 | switch (get_openwrt_driver_type()) { |
| 7433 | case OPENWRT_DRIVER_ATHEROS: |
| 7434 | return ath_ap_send_frame_loc(dut, conn, cmd); |
| 7435 | default: |
| 7436 | send_resp(dut, conn, SIGMA_ERROR, |
| 7437 | "errorCode,Unsupported ap_send_frame_loc with the current openwrt driver"); |
| 7438 | return 0; |
| 7439 | } |
| 7440 | default: |
| 7441 | send_resp(dut, conn, SIGMA_ERROR, |
| 7442 | "errorCode,Unsupported ap_send_frame_loc with the current driver"); |
| 7443 | return 0; |
| 7444 | } |
| 7445 | } |
| 7446 | |
| 7447 | |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 7448 | static int ap_send_frame_mbo(struct sigma_dut *dut, struct sigma_conn *conn, |
| 7449 | struct sigma_cmd *cmd) |
| 7450 | { |
| 7451 | switch (get_driver_type()) { |
| 7452 | case DRIVER_ATHEROS: |
| 7453 | return ath_ap_send_frame_mbo(dut, conn, cmd); |
| 7454 | case DRIVER_OPENWRT: |
| 7455 | switch (get_openwrt_driver_type()) { |
| 7456 | case OPENWRT_DRIVER_ATHEROS: |
| 7457 | return ath_ap_send_frame_mbo(dut, conn, cmd); |
| 7458 | default: |
| 7459 | send_resp(dut, conn, SIGMA_ERROR, |
| 7460 | "errorCode,Unsupported ap_send_frame with the current openwrt driver"); |
| 7461 | return 0; |
| 7462 | } |
| 7463 | default: |
| 7464 | send_resp(dut, conn, SIGMA_ERROR, |
| 7465 | "errorCode,Unsupported ap_send_frame with the current driver"); |
| 7466 | return 0; |
| 7467 | } |
| 7468 | } |
| 7469 | |
| 7470 | |
Lior David | 0fe101e | 2017-03-09 16:09:50 +0200 | [diff] [blame] | 7471 | static int ap_send_frame_60g(struct sigma_dut *dut, |
| 7472 | struct sigma_conn *conn, |
| 7473 | struct sigma_cmd *cmd) |
| 7474 | { |
| 7475 | switch (get_driver_type()) { |
| 7476 | #ifdef __linux__ |
| 7477 | case DRIVER_WIL6210: |
| 7478 | return wil6210_send_frame_60g(dut, conn, cmd); |
| 7479 | #endif /* __linux__ */ |
| 7480 | default: |
| 7481 | send_resp(dut, conn, SIGMA_ERROR, |
| 7482 | "errorCode,Unsupported sta_set_frame(60G) with the current driver"); |
| 7483 | return 0; |
| 7484 | } |
| 7485 | } |
| 7486 | |
| 7487 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7488 | int cmd_ap_send_frame(struct sigma_dut *dut, struct sigma_conn *conn, |
| 7489 | struct sigma_cmd *cmd) |
| 7490 | { |
| 7491 | /* const char *name = get_param(cmd, "NAME"); */ |
| 7492 | /* const char *ifname = get_param(cmd, "INTERFACE"); */ |
| 7493 | const char *val; |
| 7494 | enum send_frame_type frame; |
| 7495 | enum send_frame_protection protected; |
| 7496 | char buf[100]; |
| 7497 | |
| 7498 | val = get_param(cmd, "Program"); |
| 7499 | if (val) { |
| 7500 | if (strcasecmp(val, "HS2") == 0 || |
Adil Saeed Musthafa | 33ea287 | 2017-04-10 23:13:24 -0700 | [diff] [blame] | 7501 | strcasecmp(val, "HS2-R2") == 0 || |
| 7502 | strcasecmp(val, "IOTLP") == 0) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7503 | return ap_send_frame_hs2(dut, conn, cmd); |
| 7504 | if (strcasecmp(val, "VHT") == 0) |
| 7505 | return ap_send_frame_vht(dut, conn, cmd); |
priyadharshini gowthaman | a27b5b6 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 7506 | if (strcasecmp(val, "LOC") == 0) |
| 7507 | return ap_send_frame_loc(dut, conn, cmd); |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 7508 | if (strcasecmp(val, "MBO") == 0) |
| 7509 | return ap_send_frame_mbo(dut, conn, cmd); |
Lior David | 0fe101e | 2017-03-09 16:09:50 +0200 | [diff] [blame] | 7510 | if (strcasecmp(val, "60GHz") == 0) |
| 7511 | return ap_send_frame_60g(dut, conn, cmd); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7512 | } |
| 7513 | |
| 7514 | val = get_param(cmd, "PMFFrameType"); |
| 7515 | if (val == NULL) |
| 7516 | val = get_param(cmd, "FrameName"); |
| 7517 | if (val == NULL) |
| 7518 | val = get_param(cmd, "Type"); |
| 7519 | if (val == NULL) |
| 7520 | return -1; |
| 7521 | if (strcasecmp(val, "disassoc") == 0) |
| 7522 | frame = DISASSOC; |
| 7523 | else if (strcasecmp(val, "deauth") == 0) |
| 7524 | frame = DEAUTH; |
| 7525 | else if (strcasecmp(val, "saquery") == 0) |
| 7526 | frame = SAQUERY; |
| 7527 | else { |
| 7528 | send_resp(dut, conn, SIGMA_ERROR, "errorCode,Unsupported " |
| 7529 | "PMFFrameType"); |
| 7530 | return 0; |
| 7531 | } |
| 7532 | |
| 7533 | val = get_param(cmd, "PMFProtected"); |
| 7534 | if (val == NULL) |
| 7535 | val = get_param(cmd, "Protected"); |
| 7536 | if (val == NULL) |
| 7537 | return -1; |
| 7538 | if (strcasecmp(val, "Correct-key") == 0 || |
| 7539 | strcasecmp(val, "CorrectKey") == 0) |
| 7540 | protected = CORRECT_KEY; |
| 7541 | else if (strcasecmp(val, "IncorrectKey") == 0) |
| 7542 | protected = INCORRECT_KEY; |
| 7543 | else if (strcasecmp(val, "Unprotected") == 0) |
| 7544 | protected = UNPROTECTED; |
| 7545 | else { |
| 7546 | send_resp(dut, conn, SIGMA_ERROR, "errorCode,Unsupported " |
| 7547 | "PMFProtected"); |
| 7548 | return 0; |
| 7549 | } |
| 7550 | |
| 7551 | val = get_param(cmd, "stationID"); |
| 7552 | if (val == NULL) |
| 7553 | return -1; |
| 7554 | |
| 7555 | if (protected == INCORRECT_KEY || |
| 7556 | (protected == UNPROTECTED && frame == SAQUERY)) |
| 7557 | return ap_inject_frame(dut, conn, frame, protected, val); |
| 7558 | |
| 7559 | switch (frame) { |
| 7560 | case DISASSOC: |
| 7561 | snprintf(buf, sizeof(buf), "disassoc %s test=%d", |
| 7562 | val, protected == CORRECT_KEY); |
| 7563 | break; |
| 7564 | case DEAUTH: |
| 7565 | snprintf(buf, sizeof(buf), "deauth %s test=%d", |
| 7566 | val, protected == CORRECT_KEY); |
| 7567 | break; |
| 7568 | case SAQUERY: |
| 7569 | snprintf(buf, sizeof(buf), "sa_query %s", val); |
| 7570 | break; |
| 7571 | } |
| 7572 | |
| 7573 | if (run_hostapd_cli(dut, buf) != 0) |
| 7574 | return -2; |
| 7575 | |
| 7576 | return 1; |
| 7577 | } |
| 7578 | |
| 7579 | |
| 7580 | static int cmd_ap_get_mac_address(struct sigma_dut *dut, |
| 7581 | struct sigma_conn *conn, |
| 7582 | struct sigma_cmd *cmd) |
| 7583 | { |
| 7584 | #if defined( __linux__) |
| 7585 | /* const char *name = get_param(cmd, "NAME"); */ |
| 7586 | /* const char *ifname = get_param(cmd, "INTERFACE"); */ |
| 7587 | char resp[50]; |
| 7588 | unsigned char addr[6]; |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 7589 | char ifname[50]; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7590 | struct ifreq ifr; |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 7591 | int s, wlan_tag = 1; |
| 7592 | const char *val; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7593 | |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 7594 | val = get_param(cmd, "WLAN_TAG"); |
| 7595 | if (val) { |
| 7596 | wlan_tag = atoi(val); |
| 7597 | if (wlan_tag < 1 || wlan_tag > 3) { |
| 7598 | /* |
| 7599 | * The only valid WLAN Tags as of now as per the latest |
| 7600 | * WFA scripts are 1, 2, and 3. |
| 7601 | */ |
| 7602 | send_resp(dut, conn, SIGMA_INVALID, |
| 7603 | "errorCode,Unsupported WLAN_TAG"); |
| 7604 | return 0; |
| 7605 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7606 | } |
| 7607 | |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 7608 | get_if_name(dut, ifname, sizeof(ifname), wlan_tag); |
| 7609 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7610 | s = socket(AF_INET, SOCK_DGRAM, 0); |
| 7611 | if (s < 0) |
| 7612 | return -1; |
| 7613 | memset(&ifr, 0, sizeof(ifr)); |
Peng Xu | b8fc5cc | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 7614 | strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name)); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7615 | if (ioctl(s, SIOCGIFHWADDR, &ifr) < 0) { |
| 7616 | perror("ioctl"); |
| 7617 | close(s); |
| 7618 | return -1; |
| 7619 | } |
| 7620 | close(s); |
| 7621 | memcpy(addr, ifr.ifr_hwaddr.sa_data, 6); |
| 7622 | |
| 7623 | snprintf(resp, sizeof(resp), "mac,%02x:%02x:%02x:%02x:%02x:%02x", |
| 7624 | addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]); |
| 7625 | send_resp(dut, conn, SIGMA_COMPLETE, resp); |
| 7626 | return 0; |
| 7627 | #elif defined( __QNXNTO__) |
| 7628 | char resp[50]; |
| 7629 | unsigned char addr[6]; |
| 7630 | |
| 7631 | if (!sigma_main_ifname) { |
| 7632 | send_resp(dut, conn, SIGMA_ERROR, "ifname is null"); |
| 7633 | return 0; |
| 7634 | } |
| 7635 | |
| 7636 | if (get_hwaddr(sigma_main_ifname, addr) != 0) { |
| 7637 | send_resp(dut, conn, SIGMA_ERROR, |
| 7638 | "errorCode,Failed to get address"); |
| 7639 | return 0; |
| 7640 | } |
| 7641 | snprintf(resp, sizeof(resp), "mac,%02x:%02x:%02x:%02x:%02x:%02x", |
| 7642 | addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]); |
| 7643 | send_resp(dut, conn, SIGMA_COMPLETE, resp); |
| 7644 | return 0; |
| 7645 | #else /* __linux__ */ |
| 7646 | send_resp(dut, conn, SIGMA_ERROR, "errorCode,ap_get_mac_address not " |
| 7647 | "yet supported"); |
| 7648 | return 0; |
| 7649 | #endif /* __linux__ */ |
| 7650 | } |
| 7651 | |
| 7652 | |
| 7653 | static int cmd_ap_set_pmf(struct sigma_dut *dut, struct sigma_conn *conn, |
| 7654 | struct sigma_cmd *cmd) |
| 7655 | { |
| 7656 | /* |
| 7657 | * Ignore the command since the parameters are already handled through |
| 7658 | * ap_set_security. |
| 7659 | */ |
| 7660 | |
| 7661 | return 1; |
| 7662 | } |
| 7663 | |
| 7664 | |
| 7665 | static int cmd_ap_set_hs2(struct sigma_dut *dut, struct sigma_conn *conn, |
| 7666 | struct sigma_cmd *cmd) |
| 7667 | { |
| 7668 | /* const char *name = get_param(cmd, "NAME"); */ |
| 7669 | /* const char *ifname = get_param(cmd, "INTERFACE"); */ |
| 7670 | const char *val, *dest; |
| 7671 | char *pos, buf[100]; |
| 7672 | int i, wlan_tag = 1; |
| 7673 | |
| 7674 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_set_hs2: Processing the " |
| 7675 | "following parameters"); |
| 7676 | for (i = 0; i < cmd->count; i++) { |
| 7677 | sigma_dut_print(dut, DUT_MSG_INFO, "%s %s", cmd->params[i], |
| 7678 | (cmd->values[i] ? cmd->values[i] : "NULL")); |
| 7679 | } |
| 7680 | |
| 7681 | val = get_param(cmd, "ICMPv4_ECHO"); |
| 7682 | if (val && atoi(val)) { |
| 7683 | snprintf(buf, sizeof(buf), "ebtables -F"); |
| 7684 | if (system(buf) != 0) { |
| 7685 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 7686 | "Failed to set ebtables rules, RULE-12"); |
| 7687 | } |
| 7688 | return 1; |
| 7689 | } |
| 7690 | |
| 7691 | val = get_param(cmd, "WLAN_TAG"); |
| 7692 | if (val) { |
| 7693 | wlan_tag = atoi(val); |
| 7694 | if (wlan_tag != 1 && wlan_tag != 2) { |
| 7695 | send_resp(dut, conn, SIGMA_INVALID, |
| 7696 | "errorCode,Invalid WLAN_TAG"); |
| 7697 | return 0; |
| 7698 | } |
| 7699 | } |
| 7700 | |
| 7701 | if (wlan_tag == 2) { |
| 7702 | val = get_param(cmd, "PROXY_ARP"); |
| 7703 | if (val) |
| 7704 | dut->ap2_proxy_arp = atoi(val); |
| 7705 | return 1; |
| 7706 | } |
| 7707 | |
| 7708 | dest = get_param(cmd, "STA_MAC"); |
| 7709 | if (dest) { |
| 7710 | /* This is a special/ugly way of using this command. |
| 7711 | * If "Dest" MAC is included, assume that this command |
| 7712 | * is being issued after ap_config_commit for dynamically |
| 7713 | * setting the QoS Map Set. |
| 7714 | */ |
| 7715 | val = get_param(cmd, "QoS_MAP_SET"); |
| 7716 | if (val) { |
| 7717 | dut->ap_qos_map_set = atoi(val); |
| 7718 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_qos_map_set %d", |
| 7719 | dut->ap_qos_map_set); |
| 7720 | } |
| 7721 | |
| 7722 | if (dut->ap_qos_map_set == 1) |
| 7723 | run_hostapd_cli(dut, "set_qos_map_set " QOS_MAP_SET_1); |
| 7724 | else if (dut->ap_qos_map_set == 2) |
| 7725 | run_hostapd_cli(dut, "set_qos_map_set " QOS_MAP_SET_2); |
| 7726 | |
| 7727 | snprintf(buf, sizeof(buf), "send_qos_map_conf %s", dest); |
| 7728 | if (run_hostapd_cli(dut, buf) != 0) |
| 7729 | return -1; |
| 7730 | } |
| 7731 | |
| 7732 | val = get_param(cmd, "DGAF_DISABLE"); |
| 7733 | if (val) |
| 7734 | dut->ap_dgaf_disable = atoi(val); |
| 7735 | |
| 7736 | dut->ap_interworking = 1; |
| 7737 | |
| 7738 | val = get_param(cmd, "INTERWORKING"); |
| 7739 | if (val == NULL) |
| 7740 | val = get_param(cmd, "INTERNETWORKING"); |
| 7741 | if (val != NULL && atoi(val) == 0) { |
| 7742 | dut->ap_interworking = 0; |
| 7743 | dut->ap_hs2 = 0; |
| 7744 | return 1; |
| 7745 | } |
| 7746 | |
| 7747 | val = get_param(cmd, "ACCS_NET_TYPE"); |
| 7748 | if (val) { |
| 7749 | if (strcasecmp(val, "Chargeable_Public_Network") == 0 || |
| 7750 | strcasecmp(val, "Chargable_Public_Network") == 0 || |
| 7751 | strcasecmp(val, "Chargable Public Network") == 0) |
| 7752 | dut->ap_access_net_type = 2; |
| 7753 | else |
| 7754 | dut->ap_access_net_type = atoi(val); |
| 7755 | } |
| 7756 | |
| 7757 | val = get_param(cmd, "INTERNET"); |
| 7758 | if (val) |
| 7759 | dut->ap_internet = atoi(val); |
| 7760 | |
| 7761 | val = get_param(cmd, "VENUE_GRP"); |
| 7762 | if (val) { |
| 7763 | if (strcasecmp(val, "Business") == 0) |
| 7764 | dut->ap_venue_group = 2; |
| 7765 | else |
| 7766 | dut->ap_venue_group = atoi(val); |
| 7767 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_venue_name %d", |
| 7768 | dut->ap_venue_name); |
| 7769 | } |
| 7770 | |
| 7771 | val = get_param(cmd, "VENUE_TYPE"); |
| 7772 | if (val) { |
| 7773 | if (strcasecmp(val, "R&D") == 0) |
| 7774 | dut->ap_venue_type = 8; |
| 7775 | else |
| 7776 | dut->ap_venue_type = atoi(val); |
| 7777 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_venue_type %d", |
| 7778 | dut->ap_venue_type); |
| 7779 | } |
| 7780 | |
| 7781 | val = get_param(cmd, "HESSID"); |
| 7782 | if (val) { |
| 7783 | if (strlen(val) >= sizeof(dut->ap_hessid)) { |
| 7784 | send_resp(dut, conn, SIGMA_ERROR, |
| 7785 | "errorCode,Invalid HESSID"); |
| 7786 | return 0; |
| 7787 | } |
| 7788 | snprintf(dut->ap_hessid, sizeof(dut->ap_hessid), "%s", val); |
| 7789 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_hessid %s", |
| 7790 | dut->ap_hessid); |
| 7791 | } |
| 7792 | |
| 7793 | val = get_param(cmd, "ROAMING_CONS"); |
| 7794 | if (val) { |
| 7795 | if (strlen(val) >= sizeof(dut->ap_roaming_cons)) { |
| 7796 | send_resp(dut, conn, SIGMA_ERROR, |
| 7797 | "errorCode,Invalid ROAMING_CONS"); |
| 7798 | return 0; |
| 7799 | } |
| 7800 | if (strcasecmp(val, "Disabled") == 0) { |
| 7801 | dut->ap_roaming_cons[0] = '\0'; |
| 7802 | } else { |
| 7803 | snprintf(dut->ap_roaming_cons, |
| 7804 | sizeof(dut->ap_roaming_cons), "%s", val); |
| 7805 | } |
| 7806 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_roaming_cons %s", |
| 7807 | dut->ap_roaming_cons); |
| 7808 | } |
| 7809 | |
| 7810 | val = get_param(cmd, "ANQP"); |
| 7811 | if (val) |
| 7812 | dut->ap_anqpserver_on = atoi(val); |
| 7813 | |
| 7814 | val = get_param(cmd, "NAI_REALM_LIST"); |
| 7815 | if (val) { |
| 7816 | dut->ap_nai_realm_list = atoi(val); |
| 7817 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_nai_realm_list %d", |
| 7818 | dut->ap_nai_realm_list); |
| 7819 | } |
| 7820 | |
| 7821 | val = get_param(cmd, "3GPP_INFO"); |
| 7822 | if (val) { |
| 7823 | /* What kind of encoding format is used?! */ |
| 7824 | send_resp(dut, conn, SIGMA_ERROR, "errorCode,3GPP_INFO " |
| 7825 | "not yet supported (contents not fully defined)"); |
| 7826 | return 0; |
| 7827 | } |
| 7828 | |
| 7829 | val = get_param(cmd, "DOMAIN_LIST"); |
| 7830 | if (val) { |
| 7831 | if (strlen(val) >= sizeof(dut->ap_domain_name_list)) { |
| 7832 | send_resp(dut, conn, SIGMA_ERROR, "errorCode,Too long " |
| 7833 | "DOMAIN_LIST"); |
| 7834 | return 0; |
| 7835 | } |
| 7836 | snprintf(dut->ap_domain_name_list, |
| 7837 | sizeof(dut->ap_domain_name_list), "%s", val); |
| 7838 | pos = dut->ap_domain_name_list; |
| 7839 | while (*pos) { |
| 7840 | if (*pos == ';') |
| 7841 | *pos = ','; |
| 7842 | pos++; |
| 7843 | } |
| 7844 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_domain_name_list %s", |
| 7845 | dut->ap_domain_name_list); |
| 7846 | } |
| 7847 | |
| 7848 | val = get_param(cmd, "OPER_NAME"); |
| 7849 | if (val) { |
| 7850 | dut->ap_oper_name = atoi(val); |
| 7851 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_oper_name %d", |
| 7852 | dut->ap_oper_name); |
| 7853 | } |
| 7854 | |
| 7855 | val = get_param(cmd, "VENUE_NAME"); |
| 7856 | if (val) { |
| 7857 | dut->ap_venue_name = atoi(val); |
| 7858 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_venue_name %d", |
| 7859 | dut->ap_venue_name); |
| 7860 | } |
| 7861 | |
| 7862 | val = get_param(cmd, "GAS_CB_DELAY"); |
| 7863 | if (val) { |
| 7864 | dut->ap_gas_cb_delay = atoi(val); |
| 7865 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_gas_cb_delay %d", |
| 7866 | dut->ap_gas_cb_delay); |
| 7867 | } |
| 7868 | |
| 7869 | val = get_param(cmd, "MIH"); |
| 7870 | if (val && atoi(val) > 0) { |
| 7871 | send_resp(dut, conn, SIGMA_ERROR, "errorCode,MIH not " |
| 7872 | "supported"); |
| 7873 | return 0; |
| 7874 | } |
| 7875 | |
| 7876 | val = get_param(cmd, "L2_TRAFFIC_INSPECT"); |
| 7877 | if (val) { |
| 7878 | dut->ap_l2tif = atoi(val); |
| 7879 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_l2tif %d", |
| 7880 | dut->ap_l2tif); |
| 7881 | } |
| 7882 | |
| 7883 | val = get_param(cmd, "BCST_UNCST"); |
| 7884 | if (val) { |
| 7885 | send_resp(dut, conn, SIGMA_ERROR, |
| 7886 | "errorCode,BCST_UNCST not yet supported"); |
| 7887 | return 0; |
| 7888 | } |
| 7889 | |
| 7890 | val = get_param(cmd, "PLMN_MCC"); |
| 7891 | if (val) { |
| 7892 | char mcc[100], *start, *end; |
| 7893 | int i = 0; |
| 7894 | if (strlen(val) >= sizeof(mcc)) { |
| 7895 | send_resp(dut, conn, SIGMA_ERROR, |
| 7896 | "errorCode,PLMN_MCC too long"); |
| 7897 | return 0; |
| 7898 | } |
Peng Xu | b8fc5cc | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 7899 | strlcpy(mcc, val, sizeof(mcc)); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7900 | start = mcc; |
| 7901 | while ((end = strchr(start, ';'))) { |
| 7902 | /* process all except the last */ |
| 7903 | *end = '\0'; |
| 7904 | if (strlen(start) != 3) { |
| 7905 | send_resp(dut, conn, SIGMA_ERROR, |
| 7906 | "errorCode,Invalid PLMN_MCC"); |
| 7907 | return 0; |
| 7908 | } |
| 7909 | snprintf(dut->ap_plmn_mcc[i], |
| 7910 | sizeof(dut->ap_plmn_mcc[i]), "%s", start); |
| 7911 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_plmn_mcc %s", |
| 7912 | dut->ap_plmn_mcc[i]); |
| 7913 | i++; |
| 7914 | start = end + 1; |
| 7915 | *end = ';'; |
| 7916 | } |
| 7917 | if (strlen(start) != 3) { |
| 7918 | send_resp(dut, conn, SIGMA_ERROR, |
| 7919 | "errorCode,Invalid PLMN_MCC"); |
| 7920 | return 0; |
| 7921 | } |
| 7922 | /* process last or only one */ |
| 7923 | snprintf(dut->ap_plmn_mcc[i], |
| 7924 | sizeof(dut->ap_plmn_mcc[i]), "%s", start); |
| 7925 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_plmn_mcc %s", |
| 7926 | dut->ap_plmn_mcc[i]); |
| 7927 | } |
| 7928 | |
| 7929 | val = get_param(cmd, "PLMN_MNC"); |
| 7930 | if (val) { |
| 7931 | char mnc[100], *start, *end; |
| 7932 | int i = 0; |
| 7933 | if (strlen(val) >= sizeof(mnc)) { |
| 7934 | send_resp(dut, conn, SIGMA_ERROR, |
| 7935 | "errorCode,PLMN_MNC too long"); |
| 7936 | return 0; |
| 7937 | } |
Peng Xu | b8fc5cc | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 7938 | strlcpy(mnc, val, sizeof(mnc)); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7939 | start = mnc; |
| 7940 | while ((end = strchr(start, ';'))) { |
| 7941 | *end = '\0'; |
| 7942 | if (strlen(start) != 2 && strlen(start) != 3) { |
| 7943 | send_resp(dut, conn, SIGMA_ERROR, |
| 7944 | "errorCode,Invalid PLMN_MNC"); |
| 7945 | return 0; |
| 7946 | } |
| 7947 | snprintf(dut->ap_plmn_mnc[i], |
| 7948 | sizeof(dut->ap_plmn_mnc[i]), "%s", start); |
| 7949 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_plmn_mnc %s", |
| 7950 | dut->ap_plmn_mnc[i]); |
| 7951 | i++; |
| 7952 | start = end + 1; |
| 7953 | *end = ';'; |
| 7954 | } |
| 7955 | if (strlen(start) != 2 && strlen(start) != 3) { |
| 7956 | send_resp(dut, conn, SIGMA_ERROR, |
| 7957 | "errorCode,Invalid PLMN_MNC"); |
| 7958 | return 0; |
| 7959 | } |
| 7960 | snprintf(dut->ap_plmn_mnc[i], |
| 7961 | sizeof(dut->ap_plmn_mnc[i]), "%s", start); |
| 7962 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_plmn_mnc %s", |
| 7963 | dut->ap_plmn_mnc[i]); |
| 7964 | } |
| 7965 | |
| 7966 | val = get_param(cmd, "PROXY_ARP"); |
| 7967 | if (val) { |
| 7968 | dut->ap_proxy_arp = atoi(val); |
| 7969 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_proxy_arp %d", |
| 7970 | dut->ap_proxy_arp); |
| 7971 | } |
| 7972 | |
| 7973 | val = get_param(cmd, "WAN_METRICS"); |
| 7974 | if (val) { |
| 7975 | dut->ap_wan_metrics = atoi(val); |
| 7976 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_wan_metrics %d", |
| 7977 | dut->ap_wan_metrics); |
| 7978 | } |
| 7979 | |
| 7980 | val = get_param(cmd, "CONN_CAP"); |
| 7981 | if (val) { |
| 7982 | dut->ap_conn_capab = atoi(val); |
| 7983 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_conn_capab %d", |
| 7984 | dut->ap_conn_capab); |
| 7985 | } |
| 7986 | |
| 7987 | val = get_param(cmd, "IP_ADD_TYPE_AVAIL"); |
| 7988 | if (val) { |
| 7989 | dut->ap_ip_addr_type_avail = atoi(val); |
| 7990 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_ip_addr_type_avail %d", |
| 7991 | dut->ap_ip_addr_type_avail); |
| 7992 | } |
| 7993 | |
| 7994 | val = get_param(cmd, "NET_AUTH_TYPE"); |
| 7995 | if (val) { |
| 7996 | dut->ap_net_auth_type = atoi(val); |
| 7997 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_net_auth_type %d", |
| 7998 | dut->ap_net_auth_type); |
| 7999 | } |
| 8000 | |
| 8001 | val = get_param(cmd, "OP_CLASS"); |
| 8002 | if (val == NULL) |
| 8003 | val = get_param(cmd, "OPER_CLASS"); |
| 8004 | if (val) { |
| 8005 | dut->ap_oper_class = atoi(val); |
| 8006 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_oper_class %d", |
| 8007 | dut->ap_oper_class); |
| 8008 | } |
| 8009 | |
| 8010 | val = get_param(cmd, "OSU_PROVIDER_LIST"); |
| 8011 | if (val) { |
| 8012 | dut->ap_osu_provider_list = atoi(val); |
| 8013 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_osu_provider_list %d", |
| 8014 | dut->ap_osu_provider_list); |
| 8015 | } |
| 8016 | |
| 8017 | val = get_param(cmd, "OSU_SERVER_URI"); |
| 8018 | if (val) { |
| 8019 | i = 0; |
| 8020 | do { |
| 8021 | int len; |
| 8022 | const char *uri = val; |
| 8023 | val = strchr(val, ' '); |
| 8024 | len = val ? (val++ - uri) : (int) strlen(uri); |
| 8025 | if (len > 0 && len < 256) { |
| 8026 | memcpy(dut->ap_osu_server_uri[i], uri, len); |
| 8027 | dut->ap_osu_server_uri[i][len] = '\0'; |
| 8028 | sigma_dut_print(dut, DUT_MSG_INFO, |
| 8029 | "ap_osu_server_uri[%d] %s", i, |
| 8030 | dut->ap_osu_server_uri[i]); |
| 8031 | } |
| 8032 | } while (val && ++i < 10); |
| 8033 | } |
| 8034 | |
| 8035 | val = get_param(cmd, "OSU_METHOD"); |
| 8036 | if (val) { |
| 8037 | i = 0; |
| 8038 | do { |
| 8039 | int len; |
| 8040 | const char *method = val; |
| 8041 | val = strchr(val, ' '); |
| 8042 | len = val ? (val++ - method) : (int) strlen(method); |
| 8043 | if (len > 0) { |
| 8044 | if (strncasecmp(method, "SOAP", len) == 0) |
| 8045 | dut->ap_osu_method[i] = 1; |
| 8046 | else if (strncasecmp(method, "OMADM", len) == 0) |
| 8047 | dut->ap_osu_method[i] = 0; |
| 8048 | else |
| 8049 | return -2; |
| 8050 | } |
| 8051 | } while (val && ++i < 10); |
| 8052 | } |
| 8053 | |
| 8054 | val = get_param(cmd, "OSU_SSID"); |
| 8055 | if (val) { |
| 8056 | if (strlen(val) > 0 && strlen(val) <= 32) { |
Peng Xu | b8fc5cc | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 8057 | strlcpy(dut->ap_osu_ssid, val, |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8058 | sizeof(dut->ap_osu_ssid)); |
| 8059 | sigma_dut_print(dut, DUT_MSG_INFO, |
| 8060 | "ap_osu_ssid %s", |
| 8061 | dut->ap_osu_ssid); |
| 8062 | } |
| 8063 | } |
| 8064 | |
| 8065 | val = get_param(cmd, "OSU_ICON_TAG"); |
| 8066 | if (val) |
| 8067 | dut->ap_osu_icon_tag = atoi(val); |
| 8068 | |
| 8069 | val = get_param(cmd, "QoS_MAP_SET"); |
| 8070 | if (val) { |
| 8071 | dut->ap_qos_map_set = atoi(val); |
| 8072 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_qos_map_set %d", |
| 8073 | dut->ap_qos_map_set); |
| 8074 | } |
| 8075 | |
| 8076 | val = get_param(cmd, "BSS_LOAD"); |
| 8077 | if (val) { |
| 8078 | dut->ap_bss_load = atoi(val); |
| 8079 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_bss_load %d", |
| 8080 | dut->ap_bss_load); |
| 8081 | } |
| 8082 | |
| 8083 | return 1; |
| 8084 | } |
| 8085 | |
| 8086 | |
| 8087 | void nfc_status(struct sigma_dut *dut, const char *state, const char *oper) |
| 8088 | { |
| 8089 | char buf[100]; |
| 8090 | |
| 8091 | if (!file_exists("nfc-status")) |
| 8092 | return; |
| 8093 | |
| 8094 | snprintf(buf, sizeof(buf), "./nfc-status %s %s", state, oper); |
| 8095 | run_system(dut, buf); |
| 8096 | } |
| 8097 | |
| 8098 | |
| 8099 | static int run_nfc_command(struct sigma_dut *dut, const char *cmd, |
| 8100 | const char *info) |
| 8101 | { |
| 8102 | int res; |
| 8103 | |
| 8104 | printf("\n\n\n=====[ NFC operation ]=========================\n\n"); |
| 8105 | printf("%s\n\n", info); |
| 8106 | |
| 8107 | nfc_status(dut, "START", info); |
| 8108 | res = run_system(dut, cmd); |
| 8109 | nfc_status(dut, res ? "FAIL" : "SUCCESS", info); |
| 8110 | if (res) { |
| 8111 | sigma_dut_print(dut, DUT_MSG_INFO, "Failed to run '%s': %d", |
| 8112 | cmd, res); |
| 8113 | return res; |
| 8114 | } |
| 8115 | |
| 8116 | return 0; |
| 8117 | } |
| 8118 | |
| 8119 | |
| 8120 | static int ap_nfc_write_config_token(struct sigma_dut *dut, |
| 8121 | struct sigma_conn *conn, |
| 8122 | struct sigma_cmd *cmd) |
| 8123 | { |
| 8124 | int res; |
| 8125 | char buf[300]; |
| 8126 | |
| 8127 | run_system(dut, "killall wps-ap-nfc.py"); |
| 8128 | unlink("nfc-success"); |
| 8129 | snprintf(buf, sizeof(buf), |
| 8130 | "./wps-ap-nfc.py --no-wait %s%s --success nfc-success write-config", |
| 8131 | dut->summary_log ? "--summary " : "", |
| 8132 | dut->summary_log ? dut->summary_log : ""); |
| 8133 | res = run_nfc_command(dut, buf, |
| 8134 | "Touch NFC Tag to write WPS configuration token"); |
| 8135 | if (res || !file_exists("nfc-success")) { |
| 8136 | send_resp(dut, conn, SIGMA_ERROR, |
| 8137 | "ErrorCode,Failed to write tag"); |
| 8138 | return 0; |
| 8139 | } |
| 8140 | |
| 8141 | return 1; |
| 8142 | } |
| 8143 | |
| 8144 | |
| 8145 | static int ap_nfc_wps_read_passwd(struct sigma_dut *dut, |
| 8146 | struct sigma_conn *conn, |
| 8147 | struct sigma_cmd *cmd) |
| 8148 | { |
| 8149 | int res; |
| 8150 | char buf[300]; |
| 8151 | |
| 8152 | run_system(dut, "killall wps-ap-nfc.py"); |
| 8153 | |
| 8154 | unlink("nfc-success"); |
| 8155 | snprintf(buf, sizeof(buf), |
| 8156 | "./wps-ap-nfc.py -1 --no-wait %s%s --success nfc-success", |
| 8157 | dut->summary_log ? "--summary " : "", |
| 8158 | dut->summary_log ? dut->summary_log : ""); |
| 8159 | res = run_nfc_command(dut, buf, "Touch NFC Tag to read it"); |
| 8160 | if (res || !file_exists("nfc-success")) { |
| 8161 | send_resp(dut, conn, SIGMA_ERROR, |
| 8162 | "ErrorCode,Failed to read tag"); |
| 8163 | return 0; |
| 8164 | } |
| 8165 | |
| 8166 | return 1; |
| 8167 | } |
| 8168 | |
| 8169 | |
| 8170 | static int ap_nfc_write_password_token(struct sigma_dut *dut, |
| 8171 | struct sigma_conn *conn, |
| 8172 | struct sigma_cmd *cmd) |
| 8173 | { |
| 8174 | int res; |
| 8175 | char buf[300]; |
| 8176 | |
| 8177 | run_system(dut, "killall wps-ap-nfc.py"); |
| 8178 | unlink("nfc-success"); |
| 8179 | snprintf(buf, sizeof(buf), |
| 8180 | "./wps-ap-nfc.py --no-wait %s%s --success nfc-success write-password", |
| 8181 | dut->summary_log ? "--summary " : "", |
| 8182 | dut->summary_log ? dut->summary_log : ""); |
| 8183 | res = run_nfc_command(dut, buf, |
| 8184 | "Touch NFC Tag to write WPS password token"); |
| 8185 | if (res || !file_exists("nfc-success")) { |
| 8186 | send_resp(dut, conn, SIGMA_ERROR, |
| 8187 | "ErrorCode,Failed to write tag"); |
| 8188 | return 0; |
| 8189 | } |
| 8190 | |
| 8191 | if (run_hostapd_cli(dut, "wps_nfc_token enable") != 0) { |
| 8192 | send_resp(dut, conn, SIGMA_ERROR, |
| 8193 | "ErrorCode,Failed to enable NFC password token"); |
| 8194 | return 0; |
| 8195 | } |
| 8196 | |
| 8197 | return 1; |
| 8198 | } |
| 8199 | |
| 8200 | |
| 8201 | static int ap_nfc_wps_connection_handover(struct sigma_dut *dut, |
| 8202 | struct sigma_conn *conn, |
| 8203 | struct sigma_cmd *cmd) |
| 8204 | { |
| 8205 | int res; |
| 8206 | char buf[300]; |
| 8207 | |
| 8208 | run_system(dut, "killall wps-ap-nfc.py"); |
| 8209 | unlink("nfc-success"); |
| 8210 | snprintf(buf, sizeof(buf), |
| 8211 | "./wps-ap-nfc.py -1 --no-wait %s%s --success nfc-success", |
| 8212 | dut->summary_log ? "--summary " : "", |
| 8213 | dut->summary_log ? dut->summary_log : ""); |
| 8214 | res = run_nfc_command(dut, buf, |
| 8215 | "Touch NFC Device to respond to WPS connection handover"); |
| 8216 | if (res) { |
| 8217 | send_resp(dut, conn, SIGMA_ERROR, |
| 8218 | "ErrorCode,Failed to enable NFC for connection " |
| 8219 | "handover"); |
| 8220 | return 0; |
| 8221 | } |
| 8222 | if (!file_exists("nfc-success")) { |
| 8223 | send_resp(dut, conn, SIGMA_ERROR, |
| 8224 | "ErrorCode,Failed to complete NFC connection handover"); |
| 8225 | return 0; |
| 8226 | } |
| 8227 | |
| 8228 | return 1; |
| 8229 | } |
| 8230 | |
| 8231 | |
| 8232 | static int cmd_ap_nfc_action(struct sigma_dut *dut, struct sigma_conn *conn, |
| 8233 | struct sigma_cmd *cmd) |
| 8234 | { |
| 8235 | /* const char *name = get_param(cmd, "Name"); */ |
| 8236 | /* const char *intf = get_param(cmd, "Interface"); */ |
| 8237 | const char *oper = get_param(cmd, "Operation"); |
| 8238 | |
| 8239 | if (oper == NULL) |
| 8240 | return -1; |
| 8241 | |
| 8242 | if (strcasecmp(oper, "WRITE_CONFIG") == 0) |
| 8243 | return ap_nfc_write_config_token(dut, conn, cmd); |
| 8244 | if (strcasecmp(oper, "WRITE_PASSWD") == 0) |
| 8245 | return ap_nfc_write_password_token(dut, conn, cmd); |
| 8246 | if (strcasecmp(oper, "WPS_READ_PASSWD") == 0) |
| 8247 | return ap_nfc_wps_read_passwd(dut, conn, cmd); |
| 8248 | if (strcasecmp(oper, "WPS_CONN_HNDOVR") == 0) |
| 8249 | return ap_nfc_wps_connection_handover(dut, conn, cmd); |
| 8250 | |
| 8251 | send_resp(dut, conn, SIGMA_ERROR, "ErrorCode,Unsupported operation"); |
| 8252 | return 0; |
| 8253 | } |
| 8254 | |
| 8255 | |
| 8256 | static int cmd_ap_wps_read_pin(struct sigma_dut *dut, struct sigma_conn *conn, |
| 8257 | struct sigma_cmd *cmd) |
| 8258 | { |
| 8259 | char *pin = "12345670"; /* TODO: use random PIN */ |
| 8260 | char resp[100]; |
| 8261 | |
| 8262 | snprintf(resp, sizeof(resp), "PIN,%s", pin); |
| 8263 | send_resp(dut, conn, SIGMA_COMPLETE, resp); |
| 8264 | |
| 8265 | return 0; |
| 8266 | } |
| 8267 | |
| 8268 | |
| 8269 | static int ath_vht_op_mode_notif(struct sigma_dut *dut, const char *ifname, |
| 8270 | const char *val) |
| 8271 | { |
| 8272 | char *token, *result; |
| 8273 | int nss = 0, chwidth = 0; |
| 8274 | char buf[100]; |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 8275 | char *saveptr; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8276 | |
| 8277 | /* |
| 8278 | * The following commands should be invoked to generate |
| 8279 | * VHT op mode notification |
| 8280 | */ |
| 8281 | |
| 8282 | /* Extract the NSS info */ |
| 8283 | token = strdup(val); |
| 8284 | if (!token) |
| 8285 | return -1; |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 8286 | result = strtok_r(token, ";", &saveptr); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8287 | if (result) { |
| 8288 | int count = atoi(result); |
| 8289 | |
| 8290 | /* We do not support NSS > 3 */ |
| 8291 | if (count < 0 || count > 3) { |
| 8292 | free(token); |
| 8293 | return -1; |
| 8294 | } |
| 8295 | |
| 8296 | /* Convert nss to chainmask */ |
| 8297 | while (count--) |
| 8298 | nss = (nss << 1) | 1; |
| 8299 | |
| 8300 | snprintf(buf, sizeof(buf), "iwpriv %s rxchainmask %d", |
| 8301 | ifname, nss); |
| 8302 | if (system(buf) != 0) { |
| 8303 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 8304 | "iwpriv wifi1 rxchainmask failed!"); |
| 8305 | } |
| 8306 | } |
| 8307 | |
| 8308 | /* Extract the Channel width info */ |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 8309 | result = strtok_r(NULL, ";", &saveptr); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8310 | if (result) { |
| 8311 | switch (atoi(result)) { |
| 8312 | case 20: |
| 8313 | chwidth = 0; |
| 8314 | break; |
| 8315 | case 40: |
| 8316 | chwidth = 1; |
| 8317 | break; |
| 8318 | case 80: |
| 8319 | chwidth = 2; |
| 8320 | break; |
| 8321 | case 160: |
| 8322 | chwidth = 3; |
| 8323 | break; |
| 8324 | default: |
| 8325 | chwidth = 2; |
| 8326 | break; |
| 8327 | } |
| 8328 | snprintf(buf, sizeof(buf), "iwpriv %s chwidth %d", |
| 8329 | ifname, chwidth); |
| 8330 | if (system(buf) != 0) { |
| 8331 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 8332 | "iwpriv chwidth failed!"); |
| 8333 | } |
| 8334 | } |
| 8335 | |
| 8336 | /* Send the opmode notification */ |
Sunil Dutt | 27ec7f6 | 2017-09-14 18:22:59 +0300 | [diff] [blame] | 8337 | snprintf(buf, sizeof(buf), "iwpriv %s opmode_notify 1", ifname); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8338 | if (system(buf) != 0) { |
| 8339 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 8340 | "iwpriv opmode_notify failed!"); |
| 8341 | } |
| 8342 | free(token); |
| 8343 | |
| 8344 | return 0; |
| 8345 | } |
| 8346 | |
| 8347 | |
| 8348 | static int ath_vht_nss_mcs(struct sigma_dut *dut, const char *ifname, |
| 8349 | const char *val) |
| 8350 | { |
| 8351 | /* String (nss_operating_mode; mcs_operating_mode) */ |
| 8352 | int nss, mcs; |
| 8353 | char *token, *result; |
| 8354 | char buf[100]; |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 8355 | char *saveptr; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8356 | |
| 8357 | token = strdup(val); |
| 8358 | if (!token) |
| 8359 | return -1; |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 8360 | result = strtok_r(token, ";", &saveptr); |
Pradeep Reddy POTTETI | 41b8c54 | 2016-06-15 16:09:46 +0530 | [diff] [blame] | 8361 | if (!result) { |
| 8362 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 8363 | "VHT NSS not specified"); |
| 8364 | goto end; |
| 8365 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8366 | if (strcasecmp(result, "def") != 0) { |
| 8367 | nss = atoi(result); |
| 8368 | |
| 8369 | if (nss == 4) |
| 8370 | ath_disable_txbf(dut, ifname); |
| 8371 | |
| 8372 | snprintf(buf, sizeof(buf), "iwpriv %s nss %d", ifname, nss); |
| 8373 | if (system(buf) != 0) { |
| 8374 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 8375 | "iwpriv nss failed"); |
| 8376 | } |
| 8377 | } else { |
| 8378 | if (dut->device_type == AP_testbed && dut->ap_sgi80 == 1) { |
| 8379 | snprintf(buf, sizeof(buf), "iwpriv %s nss 1", ifname); |
| 8380 | if (system(buf) != 0) { |
| 8381 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 8382 | "iwpriv nss failed"); |
| 8383 | } |
| 8384 | } |
| 8385 | } |
| 8386 | |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 8387 | result = strtok_r(NULL, ";", &saveptr); |
Pradeep Reddy POTTETI | 41b8c54 | 2016-06-15 16:09:46 +0530 | [diff] [blame] | 8388 | if (!result) { |
| 8389 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 8390 | "VHT MCS not specified"); |
| 8391 | goto end; |
| 8392 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8393 | if (strcasecmp(result, "def") == 0) { |
| 8394 | if (dut->device_type == AP_testbed && dut->ap_sgi80 == 1) { |
| 8395 | snprintf(buf, sizeof(buf), "iwpriv %s vhtmcs 7", |
| 8396 | ifname); |
| 8397 | if (system(buf) != 0) { |
| 8398 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 8399 | "iwpriv vhtmcs failed"); |
| 8400 | } |
| 8401 | } else { |
| 8402 | snprintf(buf, sizeof(buf), |
| 8403 | "iwpriv %s set11NRates 0", ifname); |
| 8404 | if (system(buf) != 0) { |
| 8405 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 8406 | "iwpriv set11NRates failed"); |
| 8407 | } |
| 8408 | } |
| 8409 | } else { |
| 8410 | mcs = atoi(result); |
| 8411 | snprintf(buf, sizeof(buf), "iwpriv %s vhtmcs %d", ifname, mcs); |
| 8412 | if (system(buf) != 0) { |
| 8413 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 8414 | "iwpriv vhtmcs failed"); |
| 8415 | } |
| 8416 | } |
| 8417 | |
Pradeep Reddy POTTETI | 41b8c54 | 2016-06-15 16:09:46 +0530 | [diff] [blame] | 8418 | end: |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8419 | free(token); |
| 8420 | return 0; |
| 8421 | } |
| 8422 | |
| 8423 | |
| 8424 | static int ath_vht_chnum_band(struct sigma_dut *dut, const char *ifname, |
| 8425 | const char *val) |
| 8426 | { |
| 8427 | char *token, *result; |
| 8428 | int channel = 36; |
| 8429 | int chwidth = 80; |
| 8430 | char buf[100]; |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 8431 | char *saveptr; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8432 | |
| 8433 | /* Extract the channel info */ |
| 8434 | token = strdup(val); |
| 8435 | if (!token) |
| 8436 | return -1; |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 8437 | result = strtok_r(token, ";", &saveptr); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8438 | if (result) |
| 8439 | channel = atoi(result); |
| 8440 | |
| 8441 | /* Extract the channel width info */ |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 8442 | result = strtok_r(NULL, ";", &saveptr); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8443 | if (result) |
| 8444 | chwidth = atoi(result); |
| 8445 | |
| 8446 | /* Issue the channel switch command */ |
| 8447 | snprintf(buf, sizeof(buf), "iwpriv %s doth_ch_chwidth %d 10 %d", |
| 8448 | ifname, channel, chwidth); |
| 8449 | if (system(buf) != 0) { |
| 8450 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 8451 | "iwpriv doth_ch_chwidth failed!"); |
| 8452 | } |
| 8453 | |
| 8454 | free(token); |
| 8455 | return 0; |
| 8456 | } |
| 8457 | |
| 8458 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8459 | static int ath_ndpa_stainfo_mac(struct sigma_dut *dut, const char *ifname, |
| 8460 | const char *val) |
| 8461 | { |
| 8462 | char buf[80]; |
| 8463 | unsigned char mac_addr[6]; |
| 8464 | |
| 8465 | if (parse_mac_address(dut, val, mac_addr) < 0) |
| 8466 | return -1; |
| 8467 | |
| 8468 | snprintf(buf, sizeof(buf), |
| 8469 | "wifitool %s beeliner_fw_test 92 0x%02x%02x%02x%02x", |
| 8470 | ifname, mac_addr[0], mac_addr[1], mac_addr[2], mac_addr[3]); |
| 8471 | run_system(dut, buf); |
| 8472 | |
| 8473 | snprintf(buf, sizeof(buf), "wifitool %s beeliner_fw_test 93 0x%02x%02x", |
| 8474 | ifname, mac_addr[4], mac_addr[5]); |
| 8475 | run_system(dut, buf); |
| 8476 | |
| 8477 | snprintf(buf, sizeof(buf), "wifitool %s beeliner_fw_test 94 1", ifname); |
| 8478 | run_system(dut, buf); |
| 8479 | |
| 8480 | return 0; |
| 8481 | } |
| 8482 | |
| 8483 | |
priyadharshini gowthaman | e5e2517 | 2015-12-08 14:53:48 -0800 | [diff] [blame] | 8484 | void novap_reset(struct sigma_dut *dut, const char *ifname) |
Priyadharshini Gowthaman | 39beafa | 2015-11-09 14:11:25 -0800 | [diff] [blame] | 8485 | { |
| 8486 | char buf[60]; |
| 8487 | |
| 8488 | snprintf(buf, sizeof(buf), "iwpriv %s novap_reset 1", ifname); |
| 8489 | if (system(buf) != 0) { |
| 8490 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 8491 | "disabling novap reset failed"); |
| 8492 | } |
| 8493 | } |
| 8494 | |
| 8495 | |
Adil Saeed Musthafa | 6906372 | 2017-04-10 23:13:40 -0700 | [diff] [blame] | 8496 | struct mbo_pref_ap * mbo_find_nebor_ap_entry(struct sigma_dut *dut, |
| 8497 | const uint8_t *mac_addr) |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 8498 | { |
Adil Saeed Musthafa | 6906372 | 2017-04-10 23:13:40 -0700 | [diff] [blame] | 8499 | int i; |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 8500 | |
Adil Saeed Musthafa | 6906372 | 2017-04-10 23:13:40 -0700 | [diff] [blame] | 8501 | for (i = 0; i < dut->mbo_pref_ap_cnt; i++) { |
| 8502 | if (memcmp(mac_addr, dut->mbo_pref_aps[i].mac_addr, |
| 8503 | ETH_ALEN) == 0) |
| 8504 | return &dut->mbo_pref_aps[i]; |
| 8505 | } |
| 8506 | return NULL; |
| 8507 | } |
| 8508 | |
| 8509 | |
| 8510 | static void mbo_add_nebor_entry(struct sigma_dut *dut, const uint8_t *mac_addr, |
| 8511 | int ap_ne_class, int ap_ne_op_ch, |
| 8512 | int ap_ne_pref) |
| 8513 | { |
| 8514 | struct mbo_pref_ap *entry; |
| 8515 | uint8_t self_mac[ETH_ALEN]; |
| 8516 | char ifname[50]; |
| 8517 | |
| 8518 | get_if_name(dut, ifname, sizeof(ifname), 1); |
| 8519 | get_hwaddr(ifname, self_mac); |
| 8520 | |
| 8521 | if (memcmp(mac_addr, self_mac, ETH_ALEN) == 0) |
| 8522 | entry = &dut->mbo_self_ap_tuple; |
| 8523 | else |
| 8524 | entry = mbo_find_nebor_ap_entry(dut, mac_addr); |
| 8525 | |
| 8526 | if (!entry) { |
| 8527 | if (dut->mbo_pref_ap_cnt >= MBO_MAX_PREF_BSSIDS) { |
| 8528 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 8529 | "Nebor AP List is full. Not adding"); |
| 8530 | return; |
| 8531 | } |
| 8532 | entry = &dut->mbo_pref_aps[dut->mbo_pref_ap_cnt]; |
| 8533 | dut->mbo_pref_ap_cnt++; |
| 8534 | memcpy(entry->mac_addr, mac_addr, ETH_ALEN); |
| 8535 | entry->ap_ne_class = -1; |
| 8536 | entry->ap_ne_op_ch = -1; |
| 8537 | entry->ap_ne_pref = -1; |
| 8538 | } |
| 8539 | if (ap_ne_class != -1) |
| 8540 | entry->ap_ne_class = ap_ne_class; |
| 8541 | if (ap_ne_op_ch != -1) |
| 8542 | entry->ap_ne_op_ch = ap_ne_op_ch; |
| 8543 | if (ap_ne_pref != -1) |
| 8544 | entry->ap_ne_pref = ap_ne_pref; |
| 8545 | } |
| 8546 | |
| 8547 | |
| 8548 | static int ath_set_nebor_bssid(struct sigma_dut *dut, const char *ifname, |
| 8549 | struct sigma_cmd *cmd) |
| 8550 | { |
| 8551 | unsigned char mac_addr[ETH_ALEN]; |
| 8552 | const char *val; |
| 8553 | /* |
| 8554 | * -1 is invalid value for the following |
| 8555 | * to differentiate between unset and set values |
| 8556 | * -1 => implies not set by CAPI |
| 8557 | */ |
| 8558 | int ap_ne_class = -1, ap_ne_op_ch = -1, ap_ne_pref = -1; |
| 8559 | int list_offset = dut->mbo_pref_ap_cnt; |
| 8560 | |
| 8561 | if (list_offset >= MBO_MAX_PREF_BSSIDS) { |
| 8562 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 8563 | "AP Pref Entry list is full"); |
| 8564 | return -1; |
| 8565 | } |
| 8566 | |
| 8567 | val = get_param(cmd, "Nebor_Op_Class"); |
| 8568 | if (val) |
| 8569 | ap_ne_class = atoi(val); |
| 8570 | |
| 8571 | val = get_param(cmd, "Nebor_Op_Ch"); |
| 8572 | if (val) |
| 8573 | ap_ne_op_ch = atoi(val); |
| 8574 | |
| 8575 | val = get_param(cmd, "Nebor_Pref"); |
| 8576 | if (val) |
| 8577 | ap_ne_pref = atoi(val); |
| 8578 | |
| 8579 | val = get_param(cmd, "Nebor_BSSID"); |
| 8580 | if (!val || parse_mac_address(dut, val, mac_addr) < 0) |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 8581 | return -1; |
| 8582 | |
Adil Saeed Musthafa | 6906372 | 2017-04-10 23:13:40 -0700 | [diff] [blame] | 8583 | mbo_add_nebor_entry(dut, mac_addr, ap_ne_class, ap_ne_op_ch, |
| 8584 | ap_ne_pref); |
| 8585 | apply_mbo_pref_ap_list(dut); |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 8586 | return 0; |
| 8587 | } |
| 8588 | |
| 8589 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8590 | static int ath_ap_set_rfeature(struct sigma_dut *dut, struct sigma_conn *conn, |
| 8591 | struct sigma_cmd *cmd) |
| 8592 | { |
| 8593 | const char *val; |
| 8594 | char *ifname; |
| 8595 | |
| 8596 | ifname = get_main_ifname(); |
| 8597 | |
Priyadharshini Gowthaman | 39beafa | 2015-11-09 14:11:25 -0800 | [diff] [blame] | 8598 | /* Disable vap reset between the commands */ |
| 8599 | novap_reset(dut, ifname); |
| 8600 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8601 | val = get_param(cmd, "Opt_md_notif_ie"); |
| 8602 | if (val && ath_vht_op_mode_notif(dut, ifname, val) < 0) |
| 8603 | return -1; |
| 8604 | |
| 8605 | /* TODO: Optional arguments */ |
| 8606 | |
| 8607 | val = get_param(cmd, "nss_mcs_opt"); |
| 8608 | if (val && ath_vht_nss_mcs(dut, ifname, val) < 0) |
| 8609 | return -1; |
| 8610 | |
| 8611 | val = get_param(cmd, "chnum_band"); |
| 8612 | if (val && ath_vht_chnum_band(dut, ifname, val) < 0) |
| 8613 | return -1; |
| 8614 | |
| 8615 | val = get_param(cmd, "RTS_FORCE"); |
| 8616 | if (val) |
| 8617 | ath_config_rts_force(dut, ifname, val); |
| 8618 | |
| 8619 | val = get_param(cmd, "DYN_BW_SGNL"); |
| 8620 | if (val) |
| 8621 | ath_config_dyn_bw_sig(dut, ifname, val); |
| 8622 | |
| 8623 | val = get_param(cmd, "CTS_WIDTH"); |
| 8624 | if (val) |
| 8625 | ath_set_cts_width(dut, ifname, val); |
| 8626 | |
| 8627 | val = get_param(cmd, "Ndpa_stainfo_mac"); |
| 8628 | if (val && ath_ndpa_stainfo_mac(dut, ifname, val) < 0) |
| 8629 | return -1; |
| 8630 | |
| 8631 | val = get_param(cmd, "txBandwidth"); |
| 8632 | if (val && ath_set_width(dut, conn, ifname, val) < 0) |
| 8633 | return -1; |
| 8634 | |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 8635 | val = get_param(cmd, "Assoc_Disallow"); |
| 8636 | if (val) |
| 8637 | ath_set_assoc_disallow(dut, ifname, val); |
| 8638 | |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 8639 | |
Adil Saeed Musthafa | 6906372 | 2017-04-10 23:13:40 -0700 | [diff] [blame] | 8640 | ath_set_nebor_bssid(dut, ifname, cmd); |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 8641 | val = get_param(cmd, "BTMReq_DisAssoc_Imnt"); |
| 8642 | if (val) |
| 8643 | dut->ap_btmreq_disassoc_imnt = atoi(val); |
| 8644 | |
| 8645 | val = get_param(cmd, "BTMReq_Term_Bit"); |
| 8646 | if (val) |
| 8647 | dut->ap_btmreq_term_bit = atoi(val); |
| 8648 | |
Adil Saeed Musthafa | 48c5ab9 | 2017-04-10 23:13:35 -0700 | [diff] [blame] | 8649 | val = get_param(cmd, "Assoc_Delay"); |
| 8650 | if (val) |
| 8651 | run_system_wrapper(dut, "iwpriv %s mbo_asoc_ret %s", |
| 8652 | ifname, val); |
| 8653 | |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 8654 | val = get_param(cmd, "Disassoc_Timer"); |
| 8655 | if (val) |
| 8656 | dut->ap_disassoc_timer = atoi(val); |
| 8657 | |
| 8658 | val = get_param(cmd, "BSS_Term_Duration"); |
| 8659 | if (val) |
| 8660 | dut->ap_btmreq_bss_term_dur = atoi(val); |
| 8661 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8662 | return 1; |
| 8663 | } |
| 8664 | |
| 8665 | |
Pradeep Reddy POTTETI | 88fd82c | 2016-03-14 12:20:18 +0530 | [diff] [blame] | 8666 | static int wcn_vht_chnum_band(struct sigma_dut *dut, const char *ifname, |
| 8667 | const char *val) |
| 8668 | { |
| 8669 | char *token, *result; |
| 8670 | int channel = 36; |
| 8671 | char buf[100]; |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 8672 | char *saveptr; |
Pradeep Reddy POTTETI | 88fd82c | 2016-03-14 12:20:18 +0530 | [diff] [blame] | 8673 | |
| 8674 | /* Extract the channel info */ |
| 8675 | token = strdup(val); |
| 8676 | if (!token) |
| 8677 | return -1; |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 8678 | result = strtok_r(token, ";", &saveptr); |
Pradeep Reddy POTTETI | 88fd82c | 2016-03-14 12:20:18 +0530 | [diff] [blame] | 8679 | if (result) |
| 8680 | channel = atoi(result); |
| 8681 | |
| 8682 | /* Issue the channel switch command */ |
| 8683 | snprintf(buf, sizeof(buf), "iwpriv %s setChanChange %d", |
| 8684 | ifname, channel); |
| 8685 | if (system(buf) != 0) { |
| 8686 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 8687 | "iwpriv setChanChange failed!"); |
| 8688 | } |
| 8689 | |
| 8690 | free(token); |
| 8691 | return 0; |
| 8692 | } |
| 8693 | |
| 8694 | |
| 8695 | static int wcn_ap_set_rfeature(struct sigma_dut *dut, struct sigma_conn *conn, |
| 8696 | struct sigma_cmd *cmd) |
| 8697 | { |
| 8698 | const char *val; |
| 8699 | char *ifname; |
| 8700 | |
| 8701 | ifname = get_main_ifname(); |
| 8702 | |
| 8703 | val = get_param(cmd, "chnum_band"); |
| 8704 | if (val && wcn_vht_chnum_band(dut, ifname, val) < 0) |
| 8705 | return -1; |
| 8706 | |
| 8707 | return 1; |
| 8708 | } |
| 8709 | |
| 8710 | |
Mohammed Shafi Shajakhan | b53d8f9 | 2017-02-28 09:05:15 +0530 | [diff] [blame] | 8711 | static int mac80211_vht_chnum_band(struct sigma_dut *dut, const char *ifname, |
| 8712 | const char *val) |
| 8713 | { |
| 8714 | char *token, *result; |
| 8715 | int channel = 36, chwidth = 80, center_freq_idx, center_freq, |
| 8716 | channel_freq; |
| 8717 | char buf[100]; |
| 8718 | char *saveptr; |
| 8719 | |
| 8720 | /* Extract the channel info */ |
| 8721 | token = strdup(val); |
| 8722 | if (!token) |
| 8723 | return -1; |
| 8724 | result = strtok_r(token, ";", &saveptr); |
| 8725 | if (result) |
| 8726 | channel = atoi(result); |
| 8727 | |
| 8728 | /* Extract the channel width info */ |
| 8729 | result = strtok_r(NULL, ";", &saveptr); |
| 8730 | if (result) |
| 8731 | chwidth = atoi(result); |
| 8732 | |
| 8733 | center_freq_idx = get_oper_centr_freq_seq_idx(chwidth, channel); |
| 8734 | if (center_freq_idx < 0) { |
| 8735 | free(token); |
| 8736 | return -1; |
| 8737 | } |
| 8738 | |
| 8739 | center_freq = get_5g_channel_freq(center_freq_idx); |
| 8740 | channel_freq = get_5g_channel_freq(channel); |
| 8741 | |
| 8742 | /* Issue the channel switch command */ |
| 8743 | snprintf(buf, sizeof(buf), |
| 8744 | " -i %s chan_switch 10 %d sec_channel_offset=1 center_freq1=%d bandwidth=%d blocktx vht", |
| 8745 | ifname, channel_freq, center_freq, chwidth); |
| 8746 | if (run_hostapd_cli(dut,buf) != 0) { |
| 8747 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 8748 | "hostapd_cli chan_switch failed"); |
| 8749 | } |
| 8750 | |
| 8751 | free(token); |
| 8752 | return 0; |
| 8753 | } |
| 8754 | |
| 8755 | |
| 8756 | static int mac80211_ap_set_rfeature(struct sigma_dut *dut, |
| 8757 | struct sigma_conn *conn, |
| 8758 | struct sigma_cmd *cmd) |
| 8759 | { |
| 8760 | const char *val; |
| 8761 | char *ifname; |
| 8762 | |
| 8763 | ifname = get_main_ifname(); |
| 8764 | val = get_param(cmd, "chnum_band"); |
| 8765 | if (val && mac80211_vht_chnum_band(dut, ifname, val) < 0) |
| 8766 | return -1; |
| 8767 | |
| 8768 | return 1; |
| 8769 | } |
| 8770 | |
| 8771 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8772 | static int cmd_ap_set_rfeature(struct sigma_dut *dut, struct sigma_conn *conn, |
| 8773 | struct sigma_cmd *cmd) |
| 8774 | { |
| 8775 | /* const char *name = get_param(cmd, "NAME"); */ |
| 8776 | /* const char *type = get_param(cmd, "Type"); */ |
| 8777 | |
| 8778 | switch (get_driver_type()) { |
| 8779 | case DRIVER_ATHEROS: |
| 8780 | return ath_ap_set_rfeature(dut, conn, cmd); |
| 8781 | case DRIVER_OPENWRT: |
| 8782 | switch (get_openwrt_driver_type()) { |
| 8783 | case OPENWRT_DRIVER_ATHEROS: |
| 8784 | return ath_ap_set_rfeature(dut, conn, cmd); |
| 8785 | default: |
| 8786 | send_resp(dut, conn, SIGMA_ERROR, |
| 8787 | "errorCode,Unsupported ap_set_rfeature with the current openwrt driver"); |
| 8788 | return 0; |
| 8789 | } |
Sreelakshmi Konamki | 0e4fcf9 | 2016-04-26 19:55:01 +0530 | [diff] [blame] | 8790 | case DRIVER_LINUX_WCN: |
Pradeep Reddy POTTETI | 88fd82c | 2016-03-14 12:20:18 +0530 | [diff] [blame] | 8791 | case DRIVER_WCN: |
| 8792 | return wcn_ap_set_rfeature(dut, conn, cmd); |
Mohammed Shafi Shajakhan | b53d8f9 | 2017-02-28 09:05:15 +0530 | [diff] [blame] | 8793 | case DRIVER_MAC80211: |
| 8794 | return mac80211_ap_set_rfeature(dut, conn, cmd); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8795 | default: |
| 8796 | send_resp(dut, conn, SIGMA_ERROR, |
| 8797 | "errorCode,Unsupported ap_set_rfeature with the current driver"); |
| 8798 | return 0; |
| 8799 | } |
| 8800 | } |
| 8801 | |
| 8802 | |
| 8803 | static int cmd_accesspoint(struct sigma_dut *dut, struct sigma_conn *conn, |
| 8804 | struct sigma_cmd *cmd) |
| 8805 | { |
| 8806 | /* const char *name = get_param(cmd, "NAME"); */ |
| 8807 | return 1; |
| 8808 | } |
| 8809 | |
| 8810 | |
| 8811 | void ap_register_cmds(void) |
| 8812 | { |
| 8813 | sigma_dut_reg_cmd("ap_ca_version", NULL, cmd_ap_ca_version); |
| 8814 | sigma_dut_reg_cmd("ap_set_wireless", NULL, cmd_ap_set_wireless); |
| 8815 | sigma_dut_reg_cmd("ap_send_addba_req", NULL, cmd_ap_send_addba_req); |
| 8816 | sigma_dut_reg_cmd("ap_set_11n_wireless", NULL, cmd_ap_set_wireless); |
| 8817 | sigma_dut_reg_cmd("ap_set_11n", NULL, cmd_ap_set_wireless); |
| 8818 | 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] | 8819 | sigma_dut_reg_cmd("ap_set_11h", NULL, cmd_ap_set_wireless); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8820 | sigma_dut_reg_cmd("ap_set_security", NULL, cmd_ap_set_security); |
| 8821 | sigma_dut_reg_cmd("ap_set_apqos", NULL, cmd_ap_set_apqos); |
| 8822 | sigma_dut_reg_cmd("ap_set_staqos", NULL, cmd_ap_set_staqos); |
| 8823 | sigma_dut_reg_cmd("ap_set_radius", NULL, cmd_ap_set_radius); |
| 8824 | sigma_dut_reg_cmd("ap_reboot", NULL, cmd_ap_reboot); |
| 8825 | sigma_dut_reg_cmd("ap_config_commit", NULL, cmd_ap_config_commit); |
| 8826 | sigma_dut_reg_cmd("ap_reset_default", NULL, cmd_ap_reset_default); |
| 8827 | sigma_dut_reg_cmd("ap_get_info", NULL, cmd_ap_get_info); |
| 8828 | sigma_dut_reg_cmd("ap_deauth_sta", NULL, cmd_ap_deauth_sta); |
| 8829 | sigma_dut_reg_cmd("ap_send_frame", NULL, cmd_ap_send_frame); |
| 8830 | sigma_dut_reg_cmd("ap_get_mac_address", NULL, cmd_ap_get_mac_address); |
| 8831 | sigma_dut_reg_cmd("ap_set_pmf", NULL, cmd_ap_set_pmf); |
| 8832 | sigma_dut_reg_cmd("ap_set_hs2", NULL, cmd_ap_set_hs2); |
| 8833 | sigma_dut_reg_cmd("ap_set_rfeature", NULL, cmd_ap_set_rfeature); |
| 8834 | sigma_dut_reg_cmd("ap_nfc_action", NULL, cmd_ap_nfc_action); |
| 8835 | sigma_dut_reg_cmd("ap_wps_read_pin", NULL, cmd_ap_wps_read_pin); |
| 8836 | sigma_dut_reg_cmd("AccessPoint", NULL, cmd_accesspoint); |
| 8837 | } |