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; |
Nirav Shah | 8ad8d74 | 2017-10-17 10:49:11 +0530 | [diff] [blame] | 828 | case DRIVER_WCN: |
| 829 | case DRIVER_LINUX_WCN: |
| 830 | ath_config_dyn_bw_sig(dut, ifname, val); |
| 831 | break; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 832 | default: |
| 833 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 834 | "Unsupported DYN_BW_SGL with the current driver"); |
| 835 | break; |
| 836 | } |
| 837 | } |
| 838 | |
| 839 | val = get_param(cmd, "SGI80"); |
| 840 | if (val) { |
| 841 | if (strcasecmp(val, "enable") == 0) |
| 842 | dut->ap_sgi80 = 1; |
| 843 | else if (strcasecmp(val, "disable") == 0) |
| 844 | dut->ap_sgi80 = 0; |
| 845 | else { |
| 846 | send_resp(dut, conn, SIGMA_INVALID, |
| 847 | "errorCode,Unsupported SGI80"); |
| 848 | return 0; |
| 849 | } |
| 850 | } |
| 851 | |
| 852 | val = get_param(cmd, "LDPC"); |
| 853 | if (val) { |
| 854 | if (strcasecmp(val, "enable") == 0) |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 855 | dut->ap_ldpc = VALUE_ENABLED; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 856 | else if (strcasecmp(val, "disable") == 0) |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 857 | dut->ap_ldpc = VALUE_DISABLED; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 858 | else { |
| 859 | send_resp(dut, conn, SIGMA_INVALID, |
| 860 | "errorCode,Unsupported LDPC"); |
| 861 | return 0; |
| 862 | } |
| 863 | } |
| 864 | |
| 865 | val = get_param(cmd, "BW_SGNL"); |
| 866 | if (val) { |
| 867 | /* |
| 868 | * With dynamic bandwidth signaling enabled we should see |
| 869 | * RTS if the threshold is met. |
| 870 | */ |
| 871 | if (strcasecmp(val, "enable") == 0) { |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 872 | dut->ap_sig_rts = VALUE_ENABLED; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 873 | } else if (strcasecmp(val, "disable") == 0) { |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 874 | dut->ap_sig_rts = VALUE_DISABLED; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 875 | } else { |
| 876 | send_resp(dut, conn, SIGMA_INVALID, |
| 877 | "errorCode,Unsupported BW_SGNL"); |
| 878 | return 0; |
| 879 | } |
| 880 | } |
| 881 | |
| 882 | val = get_param(cmd, "RTS_FORCE"); |
| 883 | if (val) { |
| 884 | switch (get_driver_type()) { |
| 885 | case DRIVER_OPENWRT: |
| 886 | switch (get_openwrt_driver_type()) { |
| 887 | case OPENWRT_DRIVER_ATHEROS: |
| 888 | ath_config_rts_force(dut, ifname, val); |
| 889 | break; |
| 890 | default: |
| 891 | send_resp(dut, conn, SIGMA_ERROR, |
| 892 | "errorCode,Unsupported RTS_FORCE with OpenWrt driver"); |
| 893 | return 0; |
| 894 | } |
| 895 | break; |
| 896 | default: |
| 897 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 898 | "Unsupported RTS_FORCE with the current driver"); |
| 899 | break; |
| 900 | } |
| 901 | } |
| 902 | |
| 903 | val = get_param(cmd, "Zero_crc"); |
| 904 | if (val) { |
| 905 | switch (get_driver_type()) { |
| 906 | case DRIVER_ATHEROS: |
| 907 | ath_set_zero_crc(dut, val); |
| 908 | break; |
| 909 | case DRIVER_OPENWRT: |
| 910 | switch (get_openwrt_driver_type()) { |
| 911 | case OPENWRT_DRIVER_ATHEROS: |
| 912 | ath_set_zero_crc(dut, val); |
| 913 | break; |
| 914 | default: |
| 915 | send_resp(dut, conn, SIGMA_ERROR, |
| 916 | "errorCode,Unsupported zero_crc with the current driver"); |
| 917 | return 0; |
| 918 | } |
| 919 | break; |
| 920 | default: |
| 921 | send_resp(dut, conn, SIGMA_ERROR, |
| 922 | "errorCode,Unsupported zero_crc with the current driver"); |
| 923 | return 0; |
| 924 | } |
| 925 | } |
| 926 | |
| 927 | val = get_param(cmd, "TxBF"); |
| 928 | if (val) |
| 929 | dut->ap_txBF = strcasecmp(val, "enable") == 0; |
| 930 | |
| 931 | val = get_param(cmd, "MU_TxBF"); |
Manikanta Pubbisetty | 210f7c8 | 2017-02-14 12:33:54 +0530 | [diff] [blame] | 932 | if (val) { |
| 933 | if (strcasecmp(val, "enable") == 0) { |
| 934 | dut->ap_txBF = 1; |
| 935 | dut->ap_mu_txBF = 1; |
| 936 | } else if (strcasecmp(val, "disable") == 0) { |
| 937 | dut->ap_txBF = 0; |
| 938 | dut->ap_mu_txBF = 0; |
| 939 | } else { |
| 940 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 941 | "Unsupported MU_TxBF"); |
| 942 | } |
| 943 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 944 | |
| 945 | /* UNSUPPORTED: tx_lgi_rate */ |
| 946 | |
| 947 | val = get_param(cmd, "wpsnfc"); |
| 948 | if (val) |
| 949 | dut->ap_wpsnfc = atoi(val); |
| 950 | |
| 951 | val = get_param(cmd, "GROUP_ID"); |
| 952 | if (val) { |
| 953 | switch (get_driver_type()) { |
| 954 | case DRIVER_OPENWRT: |
| 955 | switch (get_openwrt_driver_type()) { |
| 956 | case OPENWRT_DRIVER_ATHEROS: |
| 957 | ath_ap_set_group_id(dut, ifname, val); |
| 958 | break; |
| 959 | default: |
| 960 | send_resp(dut, conn, SIGMA_ERROR, |
| 961 | "errorCode,Unsupported group_id with the current driver"); |
| 962 | return 0; |
| 963 | } |
| 964 | break; |
| 965 | default: |
| 966 | send_resp(dut, conn, SIGMA_ERROR, |
| 967 | "errorCode,Unsupported group_id with the current driver"); |
| 968 | return 0; |
| 969 | } |
| 970 | } |
| 971 | |
| 972 | val = get_param(cmd, "CTS_WIDTH"); |
| 973 | if (val) { |
| 974 | switch (get_driver_type()) { |
| 975 | case DRIVER_OPENWRT: |
| 976 | switch (get_openwrt_driver_type()) { |
| 977 | case OPENWRT_DRIVER_ATHEROS: |
| 978 | ath_set_cts_width(dut, ifname, val); |
| 979 | break; |
| 980 | default: |
| 981 | send_resp(dut, conn, SIGMA_ERROR, |
| 982 | "errorCode,Unsupported cts_width with the current driver"); |
| 983 | return 0; |
| 984 | } |
| 985 | break; |
| 986 | default: |
| 987 | send_resp(dut, conn, SIGMA_ERROR, |
| 988 | "errorCode,Unsupported cts_width with the current driver"); |
| 989 | return 0; |
| 990 | } |
| 991 | } |
| 992 | |
priyadharshini gowthaman | 264d544 | 2016-02-25 15:52:22 -0800 | [diff] [blame] | 993 | val = get_param(cmd, "MU_NDPA_FrameFormat"); |
| 994 | if (val) |
| 995 | dut->ap_ndpa_frame = atoi(val); |
| 996 | |
priyadharshini gowthaman | c52fff8 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 997 | val = get_param(cmd, "interworking"); |
| 998 | if (val && strcmp(val, "1") == 0) |
| 999 | dut->ap_interworking = 1; |
| 1000 | |
| 1001 | val = get_param(cmd, "GAS_CB_DELAY"); |
| 1002 | if (val) |
| 1003 | dut->ap_gas_cb_delay = atoi(val); |
| 1004 | |
priyadharshini gowthaman | 8e26ff4 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 1005 | val = get_param(cmd, "LCI"); |
| 1006 | if (val) { |
| 1007 | if (strlen(val) > sizeof(dut->ap_val_lci) - 1) |
| 1008 | return -1; |
| 1009 | dut->ap_lci = 1; |
| 1010 | snprintf(dut->ap_val_lci, sizeof(dut->ap_val_lci), "%s", val); |
| 1011 | ath_set_lci_config(dut, val, cmd); |
| 1012 | } |
| 1013 | |
priyadharshini gowthaman | c2357bd | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 1014 | val = get_param(cmd, "InfoZ"); |
| 1015 | if (val) { |
| 1016 | if (strlen(val) > sizeof(dut->ap_infoz) - 1) |
| 1017 | return -1; |
| 1018 | snprintf(dut->ap_infoz, sizeof(dut->ap_infoz), "%s", val); |
| 1019 | } |
| 1020 | |
priyadharshini gowthaman | 8e26ff4 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 1021 | val = get_param(cmd, "LocCivicAddr"); |
| 1022 | if (val) { |
| 1023 | if (strlen(val) > sizeof(dut->ap_val_lcr) - 1) |
| 1024 | return -1; |
| 1025 | dut->ap_lcr = 1; |
| 1026 | snprintf(dut->ap_val_lcr, sizeof(dut->ap_val_lcr), "%s", val); |
| 1027 | if (dut->ap_lci == 0) |
| 1028 | ath_set_lci_config(dut, val, cmd); |
| 1029 | } |
| 1030 | |
| 1031 | val = get_param(cmd, "NeighAPBSSID"); |
| 1032 | if (val) { |
| 1033 | if (dut->ap_neighap < 3) { |
| 1034 | if (parse_mac_address( |
| 1035 | dut, val, |
| 1036 | dut->ap_val_neighap[dut->ap_neighap]) < 0) { |
| 1037 | send_resp(dut, conn, SIGMA_INVALID, |
| 1038 | "Failed to parse MAC address"); |
| 1039 | return 0; |
| 1040 | } |
| 1041 | dut->ap_neighap++; |
| 1042 | if (dut->ap_lci == 1) |
| 1043 | dut->ap_scan = 1; |
| 1044 | } |
| 1045 | } |
| 1046 | |
| 1047 | val = get_param(cmd, "OpChannel"); |
| 1048 | if (val) { |
| 1049 | if (dut->ap_opchannel < 3) { |
| 1050 | dut->ap_val_opchannel[dut->ap_opchannel] = atoi(val); |
| 1051 | dut->ap_opchannel++; |
| 1052 | } |
| 1053 | } |
| 1054 | |
priyadharshini gowthaman | c2357bd | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 1055 | val = get_param(cmd, "URI-FQDNdescriptor"); |
| 1056 | if (val) { |
| 1057 | if (strcasecmp(val, "HELD") == 0) { |
| 1058 | dut->ap_fqdn_held = 1; |
| 1059 | } else if (strcasecmp(val, "SUPL") == 0) { |
| 1060 | dut->ap_fqdn_supl = 1; |
| 1061 | } else { |
| 1062 | send_resp(dut, conn, SIGMA_INVALID, |
| 1063 | "errorCode,Unsupported URI-FQDNdescriptor"); |
| 1064 | return 0; |
| 1065 | } |
| 1066 | } |
| 1067 | |
Adil Saeed Musthafa | 604c826 | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 1068 | val = get_param(cmd, "Reg_Domain"); |
| 1069 | if (val) { |
| 1070 | if (strcasecmp(val, "Local") == 0) { |
| 1071 | dut->ap_reg_domain = REG_DOMAIN_LOCAL; |
| 1072 | } else if (strcasecmp(val, "Global") == 0) { |
| 1073 | dut->ap_reg_domain = REG_DOMAIN_GLOBAL; |
| 1074 | } else { |
| 1075 | send_resp(dut, conn, SIGMA_ERROR, |
| 1076 | "errorCode,Wrong value for Reg_Domain"); |
| 1077 | return 0; |
| 1078 | } |
| 1079 | } |
| 1080 | |
Adil Saeed Musthafa | 4ec61bd | 2017-04-10 23:13:41 -0700 | [diff] [blame] | 1081 | val = get_param(cmd, "NAME"); |
| 1082 | if (val) { |
| 1083 | if (strcasecmp(val, "ap1mbo") == 0) |
| 1084 | dut->ap_name = 1; |
| 1085 | else if (strcasecmp(val, "ap2mbo") == 0) |
| 1086 | dut->ap_name = 2; |
| 1087 | else |
| 1088 | dut->ap_name = 0; |
| 1089 | } |
| 1090 | |
| 1091 | val = get_param(cmd, "FT_OA"); |
| 1092 | if (val) { |
| 1093 | if (strcasecmp(val, "Enable") == 0) { |
| 1094 | dut->ap_ft_oa = 1; |
| 1095 | } else if (strcasecmp(val, "Disable") == 0) { |
| 1096 | dut->ap_ft_oa = 0; |
| 1097 | } else { |
| 1098 | send_resp(dut, conn, SIGMA_ERROR, |
| 1099 | "errorCode,Wrong value for FT_OA"); |
| 1100 | return 0; |
| 1101 | } |
| 1102 | } |
| 1103 | |
Adil Saeed Musthafa | 023108a | 2017-04-10 23:13:37 -0700 | [diff] [blame] | 1104 | val = get_param(cmd, "Cellular_Cap_Pref"); |
| 1105 | if (val) |
| 1106 | dut->ap_cell_cap_pref = atoi(val); |
| 1107 | |
Adil Saeed Musthafa | cf752fa | 2017-04-10 23:13:32 -0700 | [diff] [blame] | 1108 | val = get_param(cmd, "DOMAIN"); |
| 1109 | if (val) { |
| 1110 | if (strlen(val) >= sizeof(dut->ap_mobility_domain)) { |
| 1111 | send_resp(dut, conn, SIGMA_ERROR, |
| 1112 | "errorCode,Too long DOMAIN"); |
| 1113 | return 0; |
| 1114 | } |
| 1115 | snprintf(dut->ap_mobility_domain, |
| 1116 | sizeof(dut->ap_mobility_domain), "%s", val); |
| 1117 | } |
| 1118 | |
Adil Saeed Musthafa | 4ec61bd | 2017-04-10 23:13:41 -0700 | [diff] [blame] | 1119 | val = get_param(cmd, "ft_bss_list"); |
| 1120 | if (val) { |
| 1121 | char *mac_str; |
| 1122 | int i; |
| 1123 | char *saveptr; |
| 1124 | char *mac_list_str; |
| 1125 | |
| 1126 | mac_list_str = strdup(val); |
| 1127 | if (!mac_list_str) |
| 1128 | return -1; |
| 1129 | mac_str = strtok_r(mac_list_str, " ", &saveptr); |
| 1130 | for (i = 0; mac_str && i < MAX_FT_BSS_LIST; i++) { |
| 1131 | if (parse_mac_address(dut, mac_str, |
| 1132 | dut->ft_bss_mac_list[i]) < 0) { |
| 1133 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 1134 | "MAC Address not in proper format"); |
| 1135 | break; |
| 1136 | } |
| 1137 | dut->ft_bss_mac_cnt++; |
| 1138 | mac_str = strtok_r(NULL, " ", &saveptr); |
| 1139 | } |
| 1140 | sigma_dut_print(dut, DUT_MSG_DEBUG, |
| 1141 | "Storing the following FT BSS MAC List"); |
| 1142 | for (i = 0; i < dut->ft_bss_mac_cnt; i++) { |
| 1143 | sigma_dut_print(dut, DUT_MSG_DEBUG, |
| 1144 | "MAC[%d] %02x:%02x:%02x:%02x:%02x:%02x", |
| 1145 | i, |
| 1146 | dut->ft_bss_mac_list[i][0], |
| 1147 | dut->ft_bss_mac_list[i][1], |
| 1148 | dut->ft_bss_mac_list[i][2], |
| 1149 | dut->ft_bss_mac_list[i][3], |
| 1150 | dut->ft_bss_mac_list[i][4], |
| 1151 | dut->ft_bss_mac_list[i][5]); |
| 1152 | } |
| 1153 | free(mac_list_str); |
| 1154 | } |
| 1155 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1156 | return 1; |
| 1157 | } |
| 1158 | |
| 1159 | |
| 1160 | static void ath_inject_frame(struct sigma_dut *dut, const char *ifname, int tid) |
| 1161 | { |
| 1162 | char buf[256]; |
| 1163 | int tid_to_dscp[] = { 0x00, 0x20, 0x40, 0x60, 0x80, 0xa0, 0xc0, 0xe0 }; |
| 1164 | |
Pradeep Reddy POTTETI | d31d132 | 2016-10-13 17:22:03 +0530 | [diff] [blame] | 1165 | if (tid < 0 || |
| 1166 | tid >= (int) (sizeof(tid_to_dscp) / sizeof(tid_to_dscp[0]))) { |
| 1167 | sigma_dut_print(dut, DUT_MSG_ERROR, "Unsupported TID: %d", tid); |
| 1168 | return; |
| 1169 | } |
| 1170 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1171 | snprintf(buf, sizeof(buf), |
| 1172 | "wlanconfig %s list sta | grep : | cut -b 1-17 > %s", |
| 1173 | ifname, VI_QOS_TMP_FILE); |
| 1174 | if (system(buf) != 0) |
| 1175 | return; |
| 1176 | |
| 1177 | snprintf(buf, sizeof(buf), |
| 1178 | "ifconfig %s | grep HWaddr | cut -b 39-56 >> %s", |
| 1179 | ifname, VI_QOS_TMP_FILE); |
| 1180 | if (system(buf) != 0) |
| 1181 | sigma_dut_print(dut, DUT_MSG_ERROR, "Retrieve HWaddr failed"); |
| 1182 | |
| 1183 | snprintf(buf, sizeof(buf), "sed -n '3,$p' %s >> %s", |
| 1184 | VI_QOS_REFFILE, VI_QOS_TMP_FILE); |
| 1185 | if (system(buf) != 0) { |
| 1186 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 1187 | "Output redirection to VI_QOS_TMP_FILE failed"); |
| 1188 | } |
| 1189 | |
| 1190 | snprintf(buf, sizeof(buf), "sed '5 c %x' %s > %s", |
| 1191 | tid_to_dscp[tid], VI_QOS_TMP_FILE, VI_QOS_FILE); |
| 1192 | if (system(buf) != 0) { |
| 1193 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 1194 | "Append TID to VI_QOS_FILE failed "); |
| 1195 | } |
| 1196 | |
| 1197 | snprintf(buf, sizeof(buf), "ethinject %s %s", ifname, VI_QOS_FILE); |
| 1198 | if (system(buf) != 0) |
| 1199 | sigma_dut_print(dut, DUT_MSG_ERROR, "Ethinject frame failed"); |
| 1200 | } |
| 1201 | |
| 1202 | |
| 1203 | static int ath_ap_send_addba_req(struct sigma_dut *dut, struct sigma_conn *conn, |
| 1204 | struct sigma_cmd *cmd) |
| 1205 | { |
| 1206 | const char *val; |
| 1207 | char *ifname; |
| 1208 | char buf[256]; |
| 1209 | int tid = 0; |
| 1210 | |
| 1211 | ifname = get_main_ifname(); |
| 1212 | val = get_param(cmd, "TID"); |
| 1213 | if (val) { |
| 1214 | tid = atoi(val); |
| 1215 | if (tid) |
| 1216 | ath_inject_frame(dut, ifname, tid); |
| 1217 | } |
| 1218 | |
| 1219 | /* NOTE: This is the command sequence on Peregrine for ADDBA */ |
| 1220 | snprintf(buf, sizeof(buf), "iwpriv %s setaddbaoper 1", ifname); |
| 1221 | if (system(buf) != 0) { |
| 1222 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 1223 | "iwpriv setaddbaoper failed"); |
| 1224 | } |
| 1225 | |
| 1226 | snprintf(buf, sizeof(buf), "wifitool %s senddelba 1 %d 1 4", |
| 1227 | ifname, tid); |
| 1228 | if (system(buf) != 0) { |
| 1229 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 1230 | "wifitool senddelba failed"); |
| 1231 | } |
| 1232 | |
| 1233 | snprintf(buf, sizeof(buf), "wifitool %s sendaddba 1 %d 64", |
| 1234 | ifname, tid); |
| 1235 | if (system(buf) != 0) { |
| 1236 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 1237 | "wifitool sendaddba failed"); |
| 1238 | } |
| 1239 | |
| 1240 | return 1; |
| 1241 | } |
| 1242 | |
| 1243 | |
Mohammed Shafi Shajakhan | a0535d4 | 2016-06-17 11:55:00 +0530 | [diff] [blame] | 1244 | static int ath10k_debug_enable_addba_req(struct sigma_dut *dut, int tid, |
| 1245 | const char *sta_mac, |
| 1246 | const char *dir_path) |
| 1247 | { |
| 1248 | DIR *dir; |
| 1249 | struct dirent *entry; |
| 1250 | char buf[128], path[128]; |
| 1251 | int ret = 0; |
| 1252 | |
| 1253 | dir = opendir(dir_path); |
| 1254 | if (!dir) |
| 1255 | return 0; |
| 1256 | |
| 1257 | while ((entry = readdir(dir))) { |
| 1258 | ret = 1; |
| 1259 | |
| 1260 | if (strcmp(entry->d_name, ".") == 0 || |
| 1261 | strcmp(entry->d_name, "..") == 0) |
| 1262 | continue; |
| 1263 | |
| 1264 | snprintf(path, sizeof(path) - 1, "%s/%s", |
| 1265 | dir_path, entry->d_name); |
| 1266 | path[sizeof(path) - 1] = 0; |
| 1267 | |
| 1268 | if (strcmp(entry->d_name, sta_mac) == 0) { |
| 1269 | snprintf(buf, sizeof(buf), "echo 1 > %s/aggr_mode", |
| 1270 | path); |
| 1271 | if (system(buf) != 0) { |
| 1272 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 1273 | "Failed to set aggr mode for ath10k"); |
| 1274 | } |
| 1275 | |
| 1276 | snprintf(buf, sizeof(buf), "echo %d 32 > %s/addba", |
| 1277 | tid, path); |
| 1278 | if (system(buf) != 0) { |
| 1279 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 1280 | "Failed to set addbareq for ath10k"); |
| 1281 | } |
| 1282 | |
| 1283 | break; |
| 1284 | } |
| 1285 | |
| 1286 | /* Recursively search subdirectories */ |
| 1287 | ath10k_debug_enable_addba_req(dut, tid, sta_mac, path); |
| 1288 | } |
| 1289 | |
| 1290 | closedir(dir); |
| 1291 | |
| 1292 | return ret; |
| 1293 | } |
| 1294 | |
| 1295 | |
| 1296 | static int ath10k_ap_send_addba_req(struct sigma_dut *dut, |
| 1297 | struct sigma_cmd *cmd) |
| 1298 | { |
| 1299 | const char *val; |
| 1300 | int tid = 0; |
| 1301 | |
| 1302 | val = get_param(cmd, "TID"); |
| 1303 | if (val) |
| 1304 | tid = atoi(val); |
| 1305 | |
| 1306 | val = get_param(cmd, "sta_mac_address"); |
| 1307 | if (!val) { |
| 1308 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 1309 | "Failed to parse station MAC address"); |
| 1310 | return 0; |
| 1311 | } |
| 1312 | |
| 1313 | return ath10k_debug_enable_addba_req(dut, tid, val, |
| 1314 | "/sys/kernel/debug/ieee80211"); |
| 1315 | } |
| 1316 | |
| 1317 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1318 | static int cmd_ap_send_addba_req(struct sigma_dut *dut, struct sigma_conn *conn, |
| 1319 | struct sigma_cmd *cmd) |
| 1320 | { |
| 1321 | /* const char *name = get_param(cmd, "NAME"); */ |
| 1322 | /* const char *ifname = get_param(cmd, "INTERFACE"); */ |
Mohammed Shafi Shajakhan | a0535d4 | 2016-06-17 11:55:00 +0530 | [diff] [blame] | 1323 | struct stat s; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1324 | |
| 1325 | switch (get_driver_type()) { |
| 1326 | case DRIVER_ATHEROS: |
| 1327 | return ath_ap_send_addba_req(dut, conn, cmd); |
| 1328 | case DRIVER_OPENWRT: |
| 1329 | switch (get_openwrt_driver_type()) { |
| 1330 | case OPENWRT_DRIVER_ATHEROS: |
| 1331 | return ath_ap_send_addba_req(dut, conn, cmd); |
| 1332 | default: |
| 1333 | send_resp(dut, conn, SIGMA_ERROR, |
| 1334 | "errorCode,ap_send_addba_req not supported with this driver"); |
| 1335 | return 0; |
| 1336 | } |
Pradeep Reddy POTTETI | fdb0491 | 2016-08-02 14:16:24 +0530 | [diff] [blame] | 1337 | case DRIVER_WCN: |
| 1338 | case DRIVER_LINUX_WCN: |
| 1339 | /* AP automatically sends ADDBA request after association. */ |
| 1340 | sigma_dut_print(dut, DUT_MSG_INFO, |
| 1341 | "ap_send_addba_req command ignored"); |
| 1342 | return 1; |
Mohammed Shafi Shajakhan | a0535d4 | 2016-06-17 11:55:00 +0530 | [diff] [blame] | 1343 | case DRIVER_MAC80211: |
| 1344 | if (stat("/sys/module/ath10k_core", &s) == 0) |
| 1345 | return ath10k_ap_send_addba_req(dut, cmd); |
| 1346 | /* fall through */ |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1347 | default: |
| 1348 | send_resp(dut, conn, SIGMA_ERROR, |
| 1349 | "errorCode,ap_send_addba_req not supported with this driver"); |
| 1350 | return 0; |
| 1351 | } |
| 1352 | } |
| 1353 | |
| 1354 | |
| 1355 | static int cmd_ap_set_security(struct sigma_dut *dut, struct sigma_conn *conn, |
| 1356 | struct sigma_cmd *cmd) |
| 1357 | { |
| 1358 | /* const char *name = get_param(cmd, "NAME"); */ |
| 1359 | const char *val; |
| 1360 | unsigned int wlan_tag = 1; |
| 1361 | |
| 1362 | val = get_param(cmd, "WLAN_TAG"); |
| 1363 | if (val) |
| 1364 | wlan_tag = atoi(val); |
| 1365 | |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 1366 | if (wlan_tag > 1) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1367 | val = get_param(cmd, "KEYMGNT"); |
| 1368 | if (val) { |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 1369 | if (strcasecmp(val, "NONE") == 0) { |
| 1370 | dut->ap_tag_key_mgmt[wlan_tag - 2] = AP2_OPEN; |
| 1371 | } else if (strcasecmp(val, "OSEN") == 0 && |
| 1372 | wlan_tag == 2) { |
| 1373 | /* |
| 1374 | * OSEN only supported on WLAN_TAG = 2 for now |
| 1375 | */ |
| 1376 | dut->ap_tag_key_mgmt[wlan_tag - 2] = AP2_OSEN; |
| 1377 | } else if (strcasecmp(val, "WPA2-PSK") == 0) { |
| 1378 | dut->ap_tag_key_mgmt[wlan_tag - 2] = |
| 1379 | AP2_WPA2_PSK; |
| 1380 | } else { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1381 | send_resp(dut, conn, SIGMA_INVALID, |
| 1382 | "errorCode,Unsupported KEYMGNT"); |
| 1383 | return 0; |
| 1384 | } |
| 1385 | return 1; |
| 1386 | } |
| 1387 | } |
| 1388 | |
| 1389 | val = get_param(cmd, "KEYMGNT"); |
| 1390 | if (val) { |
| 1391 | if (strcasecmp(val, "WPA2-PSK") == 0) { |
| 1392 | dut->ap_key_mgmt = AP_WPA2_PSK; |
| 1393 | dut->ap_cipher = AP_CCMP; |
| 1394 | } else if (strcasecmp(val, "WPA2-EAP") == 0 || |
| 1395 | strcasecmp(val, "WPA2-Ent") == 0) { |
| 1396 | dut->ap_key_mgmt = AP_WPA2_EAP; |
| 1397 | dut->ap_cipher = AP_CCMP; |
Jouni Malinen | ad395a2 | 2017-09-01 21:13:46 +0300 | [diff] [blame] | 1398 | } else if (strcasecmp(val, "SuiteB") == 0) { |
| 1399 | dut->ap_key_mgmt = AP_SUITEB; |
| 1400 | dut->ap_cipher = AP_GCMP_256; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1401 | } else if (strcasecmp(val, "WPA-PSK") == 0) { |
| 1402 | dut->ap_key_mgmt = AP_WPA_PSK; |
| 1403 | dut->ap_cipher = AP_TKIP; |
| 1404 | } else if (strcasecmp(val, "WPA-EAP") == 0 || |
| 1405 | strcasecmp(val, "WPA-Ent") == 0) { |
| 1406 | dut->ap_key_mgmt = AP_WPA_EAP; |
| 1407 | dut->ap_cipher = AP_TKIP; |
| 1408 | } else if (strcasecmp(val, "WPA2-Mixed") == 0) { |
| 1409 | dut->ap_key_mgmt = AP_WPA2_EAP_MIXED; |
| 1410 | dut->ap_cipher = AP_CCMP_TKIP; |
| 1411 | } else if (strcasecmp(val, "WPA2-PSK-Mixed") == 0) { |
| 1412 | dut->ap_key_mgmt = AP_WPA2_PSK_MIXED; |
| 1413 | dut->ap_cipher = AP_CCMP_TKIP; |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 1414 | } else if (strcasecmp(val, "WPA2-SAE") == 0) { |
| 1415 | dut->ap_key_mgmt = AP_WPA2_SAE; |
| 1416 | dut->ap_cipher = AP_CCMP; |
| 1417 | } else if (strcasecmp(val, "WPA2-PSK-SAE") == 0) { |
| 1418 | dut->ap_key_mgmt = AP_WPA2_PSK_SAE; |
| 1419 | dut->ap_cipher = AP_CCMP; |
Jouni Malinen | 147b3c3 | 2017-10-09 16:51:54 +0300 | [diff] [blame] | 1420 | } else if (strcasecmp(val, "OWE") == 0) { |
| 1421 | dut->ap_key_mgmt = AP_WPA2_OWE; |
| 1422 | dut->ap_cipher = AP_CCMP; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1423 | } else if (strcasecmp(val, "NONE") == 0) { |
| 1424 | dut->ap_key_mgmt = AP_OPEN; |
| 1425 | dut->ap_cipher = AP_PLAIN; |
| 1426 | } else { |
| 1427 | send_resp(dut, conn, SIGMA_INVALID, |
| 1428 | "errorCode,Unsupported KEYMGNT"); |
| 1429 | return 0; |
| 1430 | } |
| 1431 | } |
| 1432 | |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 1433 | val = get_param(cmd, "ECGroupID"); |
| 1434 | if (val) { |
Jouni Malinen | ed670f4 | 2017-08-31 01:39:28 +0300 | [diff] [blame] | 1435 | free(dut->ap_sae_groups); |
| 1436 | dut->ap_sae_groups = strdup(val); |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 1437 | } |
| 1438 | |
Jouni Malinen | 2f524ce | 2017-08-31 01:43:29 +0300 | [diff] [blame] | 1439 | val = get_param(cmd, "AntiCloggingThreshold"); |
| 1440 | if (val) |
| 1441 | dut->sae_anti_clogging_threshold = atoi(val); |
| 1442 | |
Jouni Malinen | b347db0 | 2017-09-02 01:36:03 +0300 | [diff] [blame] | 1443 | val = get_param(cmd, "Reflection"); |
| 1444 | if (val) |
| 1445 | dut->sae_reflection = strcasecmp(val, "SAE") == 0; |
| 1446 | |
Jouni Malinen | 6814313 | 2017-09-02 02:34:08 +0300 | [diff] [blame] | 1447 | val = get_param(cmd, "InvalidSAEElement"); |
| 1448 | if (val) { |
| 1449 | free(dut->sae_commit_override); |
| 1450 | dut->sae_commit_override = strdup(val); |
| 1451 | } |
| 1452 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1453 | val = get_param(cmd, "ENCRYPT"); |
| 1454 | if (val) { |
| 1455 | if (strcasecmp(val, "WEP") == 0) { |
| 1456 | dut->ap_cipher = AP_WEP; |
| 1457 | } else if (strcasecmp(val, "TKIP") == 0) { |
| 1458 | dut->ap_cipher = AP_TKIP; |
| 1459 | } else if (strcasecmp(val, "AES") == 0 || |
| 1460 | strcasecmp(val, "AES-CCMP") == 0) { |
| 1461 | dut->ap_cipher = AP_CCMP; |
Jouni Malinen | 3d633da | 2017-09-14 22:19:21 +0300 | [diff] [blame] | 1462 | } else if (strcasecmp(val, "AES-GCMP") == 0) { |
| 1463 | dut->ap_cipher = AP_GCMP_128; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1464 | } else { |
| 1465 | send_resp(dut, conn, SIGMA_INVALID, |
| 1466 | "errorCode,Unsupported ENCRYPT"); |
| 1467 | return 0; |
| 1468 | } |
| 1469 | } |
| 1470 | |
Jouni Malinen | 3d633da | 2017-09-14 22:19:21 +0300 | [diff] [blame] | 1471 | val = get_param(cmd, "PairwiseCipher"); |
| 1472 | if (val) { |
| 1473 | if (strcasecmp(val, "AES-GCMP-256") == 0) { |
| 1474 | dut->ap_cipher = AP_GCMP_256; |
| 1475 | } else if (strcasecmp(val, "AES-CCMP-256") == 0) { |
| 1476 | dut->ap_cipher = AP_CCMP_256; |
| 1477 | } else if (strcasecmp(val, "AES-GCMP-128") == 0) { |
| 1478 | dut->ap_cipher = AP_GCMP_128; |
| 1479 | } else if (strcasecmp(val, "AES-CCMP-128") == 0) { |
| 1480 | dut->ap_cipher = AP_CCMP; |
Jouni Malinen | d538c78 | 2017-11-17 12:13:04 +0200 | [diff] [blame^] | 1481 | } else if (strcasecmp(val, "AES-CCMP-128 AES-GCMP-256") == 0 || |
| 1482 | strcasecmp(val, "AES-GCMP-256 AES-CCMP-128") == 0) { |
| 1483 | dut->ap_cipher = AP_CCMP_128_GCMP_256; |
Jouni Malinen | 3d633da | 2017-09-14 22:19:21 +0300 | [diff] [blame] | 1484 | } else { |
| 1485 | send_resp(dut, conn, SIGMA_INVALID, |
| 1486 | "errorCode,Unsupported PairwiseCipher"); |
| 1487 | return 0; |
| 1488 | } |
| 1489 | } |
| 1490 | |
| 1491 | val = get_param(cmd, "GroupMgntCipher"); |
| 1492 | if (val) { |
| 1493 | if (strcasecmp(val, "BIP-GMAC-256") == 0) { |
| 1494 | dut->ap_group_mgmt_cipher = AP_BIP_GMAC_256; |
| 1495 | } else if (strcasecmp(val, "BIP-CMAC-256") == 0) { |
| 1496 | dut->ap_group_mgmt_cipher = AP_BIP_CMAC_256; |
| 1497 | } else if (strcasecmp(val, "BIP-GMAC-128") == 0) { |
| 1498 | dut->ap_group_mgmt_cipher = AP_BIP_GMAC_128; |
| 1499 | } else if (strcasecmp(val, "BIP-CMAC-128") == 0) { |
| 1500 | dut->ap_group_mgmt_cipher = AP_BIP_CMAC_128; |
| 1501 | } else { |
| 1502 | send_resp(dut, conn, SIGMA_INVALID, |
| 1503 | "errorCode,Unsupported GroupMgntCipher"); |
| 1504 | return 0; |
| 1505 | } |
| 1506 | } |
| 1507 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1508 | val = get_param(cmd, "WEPKEY"); |
| 1509 | if (val) { |
| 1510 | size_t len; |
| 1511 | if (dut->ap_cipher != AP_WEP) { |
| 1512 | send_resp(dut, conn, SIGMA_INVALID, |
| 1513 | "errorCode,Unexpected WEPKEY without WEP " |
| 1514 | "configuration"); |
| 1515 | return 0; |
| 1516 | } |
| 1517 | len = strlen(val); |
| 1518 | if (len != 10 && len != 26) { |
| 1519 | send_resp(dut, conn, SIGMA_INVALID, |
| 1520 | "errorCode,Unexpected WEPKEY length"); |
| 1521 | return 0; |
| 1522 | } |
| 1523 | snprintf(dut->ap_wepkey, sizeof(dut->ap_wepkey), "%s", val); |
| 1524 | } |
| 1525 | |
| 1526 | val = get_param(cmd, "PSK"); |
| 1527 | if (val) { |
Jouni Malinen | 2126f42 | 2017-10-11 23:24:33 +0300 | [diff] [blame] | 1528 | if (dut->ap_key_mgmt != AP_WPA2_SAE && strlen(val) > 64) |
| 1529 | return -1; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1530 | if (strlen(val) > sizeof(dut->ap_passphrase) - 1) |
| 1531 | return -1; |
| 1532 | snprintf(dut->ap_passphrase, sizeof(dut->ap_passphrase), |
| 1533 | "%s", val); |
| 1534 | } |
| 1535 | |
| 1536 | val = get_param(cmd, "PMF"); |
| 1537 | if (val) { |
| 1538 | if (strcasecmp(val, "Disabled") == 0) { |
| 1539 | dut->ap_pmf = AP_PMF_DISABLED; |
| 1540 | } else if (strcasecmp(val, "Optional") == 0) { |
| 1541 | dut->ap_pmf = AP_PMF_OPTIONAL; |
| 1542 | } else if (strcasecmp(val, "Required") == 0) { |
| 1543 | dut->ap_pmf = AP_PMF_REQUIRED; |
| 1544 | } else { |
| 1545 | send_resp(dut, conn, SIGMA_INVALID, |
| 1546 | "errorCode,Unsupported PMF"); |
| 1547 | return 0; |
| 1548 | } |
| 1549 | } |
| 1550 | |
| 1551 | if (dut->ap_key_mgmt == AP_OPEN) { |
| 1552 | dut->ap_hs2 = 0; |
| 1553 | dut->ap_pmf = AP_PMF_DISABLED; |
| 1554 | } |
| 1555 | |
| 1556 | dut->ap_add_sha256 = 0; |
| 1557 | val = get_param(cmd, "SHA256AD"); |
| 1558 | if (val == NULL) |
| 1559 | val = get_param(cmd, "SHA256"); |
| 1560 | if (val) { |
| 1561 | if (strcasecmp(val, "Disabled") == 0) { |
| 1562 | } else if (strcasecmp(val, "Enabled") == 0) { |
| 1563 | dut->ap_add_sha256 = 1; |
| 1564 | } else { |
| 1565 | send_resp(dut, conn, SIGMA_INVALID, |
| 1566 | "errorCode,Unsupported PMF"); |
| 1567 | return 0; |
| 1568 | } |
| 1569 | } |
| 1570 | |
Sarvepalli, Rajesh Babu | 24dc7e4 | 2016-03-18 21:27:26 +0530 | [diff] [blame] | 1571 | val = get_param(cmd, "PreAuthentication"); |
| 1572 | if (val) { |
| 1573 | if (strcasecmp(val, "disabled") == 0) { |
| 1574 | dut->ap_rsn_preauth = 0; |
| 1575 | } else if (strcasecmp(val, "enabled") == 0) { |
| 1576 | dut->ap_rsn_preauth = 1; |
| 1577 | } else { |
| 1578 | send_resp(dut, conn, SIGMA_INVALID, |
| 1579 | "errorCode,Unsupported PreAuthentication value"); |
| 1580 | return 0; |
| 1581 | } |
| 1582 | } |
| 1583 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1584 | return 1; |
| 1585 | } |
| 1586 | |
| 1587 | |
| 1588 | static int cmd_ap_set_radius(struct sigma_dut *dut, struct sigma_conn *conn, |
| 1589 | struct sigma_cmd *cmd) |
| 1590 | { |
| 1591 | /* const char *name = get_param(cmd, "NAME"); */ |
| 1592 | const char *val; |
| 1593 | unsigned int wlan_tag = 1, radius_port = 0; |
| 1594 | char *radius_ipaddr = NULL, *radius_password = NULL; |
| 1595 | |
| 1596 | val = get_param(cmd, "WLAN_TAG"); |
| 1597 | if (val) { |
| 1598 | wlan_tag = atoi(val); |
| 1599 | if (wlan_tag != 1 && wlan_tag != 2) { |
| 1600 | send_resp(dut, conn, SIGMA_INVALID, |
| 1601 | "errorCode,Invalid WLAN_TAG"); |
| 1602 | return 0; |
| 1603 | } |
| 1604 | } |
| 1605 | |
| 1606 | val = get_param(cmd, "PORT"); |
| 1607 | if (val) |
| 1608 | radius_port = atoi(val); |
| 1609 | |
| 1610 | if (wlan_tag == 1) { |
| 1611 | if (radius_port) |
| 1612 | dut->ap_radius_port = radius_port; |
| 1613 | radius_ipaddr = dut->ap_radius_ipaddr; |
| 1614 | radius_password = dut->ap_radius_password; |
| 1615 | } else if (wlan_tag == 2) { |
| 1616 | if (radius_port) |
| 1617 | dut->ap2_radius_port = radius_port; |
| 1618 | radius_ipaddr = dut->ap2_radius_ipaddr; |
| 1619 | radius_password = dut->ap2_radius_password; |
| 1620 | } |
| 1621 | |
| 1622 | val = get_param(cmd, "IPADDR"); |
| 1623 | if (val) { |
| 1624 | if (strlen(val) > sizeof(dut->ap_radius_ipaddr) - 1) |
| 1625 | return -1; |
| 1626 | snprintf(radius_ipaddr, sizeof(dut->ap_radius_ipaddr), |
| 1627 | "%s", val); |
| 1628 | } |
| 1629 | |
| 1630 | val = get_param(cmd, "PASSWORD"); |
| 1631 | if (val) { |
| 1632 | if (strlen(val) > sizeof(dut->ap_radius_password) - 1) |
| 1633 | return -1; |
| 1634 | snprintf(radius_password, |
| 1635 | sizeof(dut->ap_radius_password), "%s", val); |
| 1636 | } |
| 1637 | |
| 1638 | return 1; |
| 1639 | } |
| 1640 | |
| 1641 | |
| 1642 | static void owrt_ap_set_radio(struct sigma_dut *dut, int id, |
| 1643 | const char *key, const char *val) |
| 1644 | { |
| 1645 | char buf[100]; |
| 1646 | |
| 1647 | if (val == NULL) { |
| 1648 | snprintf(buf, sizeof(buf), |
| 1649 | "uci delete wireless.wifi%d.%s", id, key); |
| 1650 | run_system(dut, buf); |
| 1651 | return; |
| 1652 | } |
| 1653 | |
| 1654 | snprintf(buf, sizeof(buf), "uci set wireless.wifi%d.%s=%s", |
| 1655 | id, key, val); |
| 1656 | run_system(dut, buf); |
| 1657 | } |
| 1658 | |
| 1659 | |
| 1660 | static void owrt_ap_set_list_radio(struct sigma_dut *dut, int id, |
| 1661 | const char *key, const char *val) |
| 1662 | { |
| 1663 | char buf[256]; |
| 1664 | |
| 1665 | if (val == NULL) { |
| 1666 | snprintf(buf, sizeof(buf), |
| 1667 | "uci del_list wireless.wifi%d.%s", id, key); |
| 1668 | run_system(dut, buf); |
| 1669 | return; |
| 1670 | } |
| 1671 | |
| 1672 | snprintf(buf, sizeof(buf), "uci add_list wireless.wifi%d.%s=%s", |
| 1673 | id, key, val); |
| 1674 | run_system(dut, buf); |
| 1675 | } |
| 1676 | |
| 1677 | |
| 1678 | static void owrt_ap_set_vap(struct sigma_dut *dut, int id, const char *key, |
| 1679 | const char *val) |
| 1680 | { |
| 1681 | char buf[256]; |
| 1682 | |
| 1683 | if (val == NULL) { |
| 1684 | snprintf(buf, sizeof(buf), |
| 1685 | "uci delete wireless.@wifi-iface[%d].%s", id, key); |
| 1686 | run_system(dut, buf); |
| 1687 | return; |
| 1688 | } |
| 1689 | |
| 1690 | snprintf(buf, sizeof(buf), "uci set wireless.@wifi-iface[%d].%s=%s", |
| 1691 | id, key, val); |
| 1692 | run_system(dut, buf); |
| 1693 | } |
| 1694 | |
| 1695 | |
| 1696 | static void owrt_ap_set_list_vap(struct sigma_dut *dut, int id, |
| 1697 | const char *key, const char *val) |
| 1698 | { |
priyadharshini gowthaman | 2323d0a | 2016-09-02 15:48:02 -0700 | [diff] [blame] | 1699 | char buf[1024]; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1700 | |
| 1701 | if (val == NULL) { |
| 1702 | snprintf(buf, sizeof(buf), |
| 1703 | "uci del_list wireless.@wifi-iface[%d].%s", id, key); |
| 1704 | run_system(dut, buf); |
| 1705 | return; |
| 1706 | } |
| 1707 | |
| 1708 | snprintf(buf, sizeof(buf), |
| 1709 | "uci add_list wireless.@wifi-iface[%d].%s=%s", |
| 1710 | id, key, val); |
| 1711 | run_system(dut, buf); |
| 1712 | } |
| 1713 | |
| 1714 | |
| 1715 | static void owrt_ap_add_vap(struct sigma_dut *dut, int id, const char *key, |
| 1716 | const char *val) |
| 1717 | { |
| 1718 | char buf[256]; |
| 1719 | |
| 1720 | if (val == NULL) { |
| 1721 | snprintf(buf, sizeof(buf), |
| 1722 | "uci delete wireless.@wifi-iface[%d].%s", id, key); |
| 1723 | run_system(dut, buf); |
| 1724 | return; |
| 1725 | } |
| 1726 | |
| 1727 | snprintf(buf, sizeof(buf), "uci add wireless wifi-iface"); |
| 1728 | run_system(dut, buf); |
| 1729 | snprintf(buf, sizeof(buf), "uci set wireless.@wifi-iface[%d].%s=%s", |
| 1730 | id, key, val); |
| 1731 | run_system(dut, buf); |
| 1732 | snprintf(buf, sizeof(buf), "uci set wireless.@wifi-iface[%d].%s=%s", |
| 1733 | id, "network", "lan"); |
| 1734 | run_system(dut, buf); |
| 1735 | snprintf(buf, sizeof(buf), "uci set wireless.@wifi-iface[%d].%s=%s", |
| 1736 | id, "mode", "ap"); |
| 1737 | run_system(dut, buf); |
| 1738 | snprintf(buf, sizeof(buf), "uci set wireless.@wifi-iface[%d].%s=%s", |
| 1739 | id, "encryption", "none"); |
| 1740 | run_system(dut, buf); |
| 1741 | } |
| 1742 | |
| 1743 | |
| 1744 | #define OPENWRT_MAX_NUM_RADIOS 3 |
| 1745 | static void owrt_ap_config_radio(struct sigma_dut *dut) |
| 1746 | { |
| 1747 | int radio_id[MAX_RADIO] = { 0, 1 }; |
| 1748 | int radio_count, radio_no; |
| 1749 | char buf[64]; |
| 1750 | |
| 1751 | for (radio_count = 0; radio_count < OPENWRT_MAX_NUM_RADIOS; |
| 1752 | radio_count++) { |
| 1753 | snprintf(buf, sizeof(buf), "%s%d", "wifi", radio_count); |
| 1754 | for (radio_no = 0; radio_no < MAX_RADIO; radio_no++) { |
| 1755 | if (!sigma_radio_ifname[radio_no] || |
| 1756 | strcmp(sigma_radio_ifname[radio_no], buf) != 0) |
| 1757 | continue; |
| 1758 | owrt_ap_set_radio(dut, radio_count, "disabled", "0"); |
| 1759 | owrt_ap_set_vap(dut, radio_count, "device", buf); |
| 1760 | radio_id[radio_no] = radio_count; |
| 1761 | } |
| 1762 | } |
| 1763 | |
| 1764 | /* Hardware mode (11a/b/g/n/ac) & HT mode selection */ |
| 1765 | switch (dut->ap_mode) { |
| 1766 | case AP_11g: |
| 1767 | owrt_ap_set_radio(dut, radio_id[0], "hwmode", "11g"); |
| 1768 | break; |
| 1769 | case AP_11b: |
| 1770 | owrt_ap_set_radio(dut, radio_id[0], "hwmode", "11b"); |
| 1771 | break; |
| 1772 | case AP_11ng: |
| 1773 | owrt_ap_set_radio(dut, radio_id[0], "hwmode", "11ng"); |
| 1774 | owrt_ap_set_radio(dut, radio_id[0], "htmode", "HT20"); |
| 1775 | break; |
| 1776 | case AP_11a: |
| 1777 | owrt_ap_set_radio(dut, radio_id[0], "hwmode", "11a"); |
| 1778 | break; |
| 1779 | case AP_11na: |
| 1780 | owrt_ap_set_radio(dut, radio_id[0], "hwmode", "11na"); |
| 1781 | owrt_ap_set_radio(dut, radio_id[0], "htmode", "HT20"); |
| 1782 | break; |
| 1783 | case AP_11ac: |
| 1784 | owrt_ap_set_radio(dut, radio_id[0], "hwmode", "11ac"); |
| 1785 | owrt_ap_set_radio(dut, radio_id[0], "htmode", "HT80"); |
| 1786 | break; |
| 1787 | case AP_inval: |
| 1788 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 1789 | "MODE NOT SPECIFIED!"); |
| 1790 | return; |
| 1791 | default: |
| 1792 | owrt_ap_set_radio(dut, radio_id[0], "hwmode", "11ng"); |
| 1793 | owrt_ap_set_radio(dut, radio_id[0], "htmode", "HT20"); |
| 1794 | break; |
| 1795 | } |
| 1796 | |
| 1797 | if (dut->ap_is_dual) { |
| 1798 | /* Hardware mode (11a/b/g/n/ac) & HT mode selection */ |
| 1799 | switch (dut->ap_mode_1) { |
| 1800 | case AP_11g: |
| 1801 | owrt_ap_set_radio(dut, radio_id[1], "hwmode", "11g"); |
| 1802 | break; |
| 1803 | case AP_11b: |
| 1804 | owrt_ap_set_radio(dut, radio_id[1], "hwmode", "11b"); |
| 1805 | break; |
| 1806 | case AP_11ng: |
| 1807 | owrt_ap_set_radio(dut, radio_id[1], "hwmode", "11ng"); |
| 1808 | owrt_ap_set_radio(dut, radio_id[1], "htmode", "HT20"); |
| 1809 | break; |
| 1810 | case AP_11a: |
| 1811 | owrt_ap_set_radio(dut, radio_id[1], "hwmode", "11a"); |
| 1812 | break; |
| 1813 | case AP_11na: |
| 1814 | owrt_ap_set_radio(dut, radio_id[1], "hwmode", "11na"); |
| 1815 | owrt_ap_set_radio(dut, radio_id[1], "htmode", "HT20"); |
| 1816 | break; |
| 1817 | case AP_11ac: |
| 1818 | owrt_ap_set_radio(dut, radio_id[1], "hwmode", "11ac"); |
| 1819 | owrt_ap_set_radio(dut, radio_id[1], "htmode", "HT80"); |
| 1820 | break; |
| 1821 | case AP_inval: |
| 1822 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 1823 | "MODE NOT SPECIFIED!"); |
| 1824 | return; |
| 1825 | default: |
| 1826 | owrt_ap_set_radio(dut, radio_id[1], "hwmode", "11ng"); |
| 1827 | owrt_ap_set_radio(dut, radio_id[1], "htmode", "HT20"); |
| 1828 | break; |
| 1829 | } |
| 1830 | |
| 1831 | } |
| 1832 | |
| 1833 | /* Channel */ |
| 1834 | snprintf(buf, sizeof(buf), "%d", dut->ap_channel); |
| 1835 | owrt_ap_set_radio(dut, radio_id[0], "channel", buf); |
| 1836 | |
| 1837 | switch (dut->ap_chwidth) { |
| 1838 | case AP_20: |
| 1839 | owrt_ap_set_radio(dut, radio_id[0], "htmode", "HT20"); |
| 1840 | break; |
| 1841 | case AP_40: |
| 1842 | owrt_ap_set_radio(dut, radio_id[0], "htmode", "HT40"); |
| 1843 | break; |
| 1844 | case AP_80: |
| 1845 | owrt_ap_set_radio(dut, radio_id[0], "htmode", "HT80"); |
| 1846 | break; |
| 1847 | case AP_160: |
| 1848 | owrt_ap_set_radio(dut, radio_id[0], "htmode", "HT160"); |
| 1849 | break; |
| 1850 | case AP_AUTO: |
| 1851 | default: |
| 1852 | break; |
| 1853 | } |
| 1854 | |
| 1855 | if (dut->ap_channel == 140 || dut->ap_channel == 144) { |
| 1856 | if (get_openwrt_driver_type() == OPENWRT_DRIVER_ATHEROS) |
| 1857 | owrt_ap_set_radio(dut, radio_id[0], "set_ch_144", "3"); |
| 1858 | } |
| 1859 | |
| 1860 | if (dut->ap_is_dual) { |
| 1861 | snprintf(buf, sizeof(buf), "%d", dut->ap_channel_1); |
| 1862 | owrt_ap_set_radio(dut, radio_id[1], "channel", buf); |
| 1863 | } |
| 1864 | |
Adil Saeed Musthafa | 604c826 | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 1865 | /* Country Code */ |
| 1866 | if (dut->ap_reg_domain == REG_DOMAIN_GLOBAL) { |
| 1867 | const char *country; |
| 1868 | |
| 1869 | country = dut->ap_countrycode[0] ? dut->ap_countrycode : "US"; |
| 1870 | snprintf(buf, sizeof(buf), "%s4", country); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1871 | owrt_ap_set_radio(dut, radio_id[0], "country", buf); |
Adil Saeed Musthafa | 604c826 | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 1872 | } else if (dut->ap_countrycode[0]) { |
| 1873 | owrt_ap_set_radio(dut, radio_id[0], "country", |
| 1874 | dut->ap_countrycode); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1875 | } |
| 1876 | |
| 1877 | if (dut->ap_disable_protection == 1) { |
| 1878 | owrt_ap_set_list_radio(dut, radio_id[0], "aggr_burst", "'0 0'"); |
| 1879 | owrt_ap_set_list_radio(dut, radio_id[0], "aggr_burst", "'1 0'"); |
| 1880 | owrt_ap_set_list_radio(dut, radio_id[0], "aggr_burst", "'2 0'"); |
| 1881 | owrt_ap_set_list_radio(dut, radio_id[0], "aggr_burst", "'3 0'"); |
| 1882 | } |
| 1883 | } |
| 1884 | |
| 1885 | |
| 1886 | static int owrt_ap_config_vap_hs2(struct sigma_dut *dut, int vap_id) |
| 1887 | { |
| 1888 | char buf[256]; |
| 1889 | |
| 1890 | snprintf(buf, sizeof(buf), "%d", dut->ap_hs2); |
| 1891 | owrt_ap_set_vap(dut, vap_id, "hs20", buf); |
| 1892 | owrt_ap_set_vap(dut, vap_id, "qbssload", "1"); |
| 1893 | owrt_ap_set_vap(dut, vap_id, "hs20_deauth_req_timeout","3"); |
| 1894 | |
| 1895 | owrt_ap_set_list_vap(dut, vap_id, "hs20_oper_friendly_name", |
| 1896 | "'eng:Wi-Fi Alliance'"); |
| 1897 | |
| 1898 | owrt_ap_set_list_vap(dut, vap_id, "hs20_oper_friendly_name", |
| 1899 | "'chi:Wi-Fi\xe8\x81\x94\xe7\x9b\x9f'"); |
| 1900 | |
| 1901 | if (dut->ap_wan_metrics == 1) |
| 1902 | owrt_ap_set_vap(dut, vap_id, "hs20_wan_metrics", |
| 1903 | "'01:2500:384:0:0:10'"); |
| 1904 | else if (dut->ap_wan_metrics == 1) |
| 1905 | owrt_ap_set_vap(dut, vap_id, "hs20_wan_metrics", |
| 1906 | "'01:1500:384:20:20:10'"); |
| 1907 | else if (dut->ap_wan_metrics == 2) |
| 1908 | owrt_ap_set_vap(dut, vap_id, "hs20_wan_metrics", |
| 1909 | "'01:1500:384:20:20:10'"); |
| 1910 | else if (dut->ap_wan_metrics == 3) |
| 1911 | owrt_ap_set_vap(dut, vap_id, "hs20_wan_metrics", |
| 1912 | "'01:2000:1000:20:20:10'"); |
| 1913 | else if (dut->ap_wan_metrics == 4) |
| 1914 | owrt_ap_set_vap(dut, vap_id, "hs20_wan_metrics", |
| 1915 | "'01:8000:1000:20:20:10'"); |
| 1916 | else if (dut->ap_wan_metrics == 5) |
| 1917 | owrt_ap_set_vap(dut, vap_id, "hs20_wan_metrics", |
| 1918 | "'01:9000:5000:20:20:10'"); |
| 1919 | |
| 1920 | if (dut->ap_conn_capab == 1) { |
| 1921 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", "'1:0:0'"); |
| 1922 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", |
| 1923 | "'6:20:1'"); |
| 1924 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", |
| 1925 | "'6:22:0'"); |
| 1926 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", |
| 1927 | "'6:80:1'"); |
| 1928 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", |
| 1929 | "'6:443:1'"); |
| 1930 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", |
| 1931 | "'6:1723:0'"); |
| 1932 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", |
| 1933 | "'6:5060:0'"); |
| 1934 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", |
| 1935 | "'17:500:1'"); |
| 1936 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", |
| 1937 | "'17:5060:0'"); |
| 1938 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", |
| 1939 | "'17:4500:1'"); |
| 1940 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", |
| 1941 | "'50:0:1'"); |
| 1942 | } else if (dut->ap_conn_capab == 2) { |
| 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 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", |
| 1948 | "'17:5060:1'"); |
| 1949 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", |
| 1950 | "'6:5060:1'"); |
| 1951 | } else if (dut->ap_conn_capab == 3) { |
| 1952 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", |
| 1953 | "'6:80:1'"); |
| 1954 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", |
| 1955 | "'6:443:1'"); |
| 1956 | } |
| 1957 | |
| 1958 | if (dut->ap_oper_class == 1) |
| 1959 | snprintf(buf, sizeof(buf), "%s", "51"); |
| 1960 | else if (dut->ap_oper_class == 2) |
| 1961 | snprintf(buf, sizeof(buf), "%s", "73"); |
| 1962 | else if (dut->ap_oper_class == 3) |
| 1963 | snprintf(buf, sizeof(buf), "%s", "5173"); |
| 1964 | |
| 1965 | if (dut->ap_oper_class) |
| 1966 | owrt_ap_set_vap(dut, vap_id, "hs20_operating_class", buf); |
| 1967 | |
| 1968 | if (dut->ap_osu_provider_list) { |
| 1969 | char *osu_friendly_name = NULL; |
| 1970 | char *osu_icon = NULL; |
| 1971 | char *osu_ssid = NULL; |
| 1972 | char *osu_nai = NULL; |
| 1973 | char *osu_service_desc = NULL; |
| 1974 | char *hs20_icon_filename = NULL; |
| 1975 | char hs20_icon[150]; |
| 1976 | int osu_method; |
| 1977 | |
| 1978 | hs20_icon_filename = "icon_red_zxx.png"; |
| 1979 | if (dut->ap_osu_icon_tag == 2) |
| 1980 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 1981 | snprintf(hs20_icon, sizeof(hs20_icon), |
| 1982 | "'128:61:zxx:image/png:icon_red_zxx.png:/etc/ath/%s'", |
| 1983 | hs20_icon_filename); |
| 1984 | osu_icon = "icon_red_zxx.png"; |
| 1985 | osu_ssid = "OSU"; |
| 1986 | osu_friendly_name = "'kor:SP 빨강 테스트 전용'"; |
| 1987 | osu_service_desc = "'kor:테스트 목적으로 무료 서비스'"; |
| 1988 | osu_method = (dut->ap_osu_method[0] == 0xFF) ? 1 : |
| 1989 | dut->ap_osu_method[0]; |
| 1990 | |
| 1991 | if (strlen(dut->ap_osu_server_uri[0])) |
| 1992 | owrt_ap_set_list_vap(dut, vap_id, "osu_server_uri", |
| 1993 | dut->ap_osu_server_uri[0]); |
| 1994 | else |
| 1995 | owrt_ap_set_list_vap(dut, vap_id, "osu_server_uri", |
| 1996 | "'https://osu-server.r2-testbed.wi-fi.org/'"); |
| 1997 | switch (dut->ap_osu_provider_list) { |
| 1998 | case 1: |
| 1999 | case 101: |
| 2000 | owrt_ap_set_list_vap(dut, vap_id, "osu_friendly_name", |
| 2001 | "'eng:SP Red Test Only'"); |
| 2002 | owrt_ap_set_list_vap(dut, vap_id, "osu_service_desc", |
| 2003 | "'eng:Free service for test purpose'"); |
| 2004 | owrt_ap_set_list_vap(dut, vap_id, "hs20_icon", |
| 2005 | hs20_icon); |
| 2006 | |
| 2007 | hs20_icon_filename = "icon_red_eng.png"; |
| 2008 | if (dut->ap_osu_icon_tag == 2) |
| 2009 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 2010 | |
| 2011 | snprintf(hs20_icon, sizeof(hs20_icon), |
| 2012 | "'160:76:eng:image/png:icon_red_eng.png:/etc/ath/%s'", |
| 2013 | hs20_icon_filename); |
| 2014 | owrt_ap_set_list_vap(dut, vap_id, "osu_icon", |
| 2015 | "icon_red_eng.png"); |
| 2016 | break; |
| 2017 | case 2: |
| 2018 | case 102: |
| 2019 | owrt_ap_set_list_vap(dut, vap_id, "osu_friendly_name", |
| 2020 | "'eng:Wireless Broadband Alliance'"); |
| 2021 | owrt_ap_set_list_vap(dut, vap_id, "osu_service_desc", |
| 2022 | "'eng:Free service for test purpose'"); |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2023 | hs20_icon_filename = "icon_orange_zxx.png"; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2024 | if (dut->ap_osu_icon_tag == 2) |
| 2025 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 2026 | |
| 2027 | snprintf(hs20_icon, sizeof(hs20_icon), |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2028 | "'128:61:zxx:image/png:icon_orange_zxx.png:/etc/ath/%s'", |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2029 | hs20_icon_filename); |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2030 | osu_icon = "icon_orange_zxx.png"; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2031 | osu_friendly_name = "'kor:와이어리스 브로드밴드 얼라이언스'"; |
| 2032 | break; |
| 2033 | case 3: |
| 2034 | case 103: |
| 2035 | osu_friendly_name = "spa:SP Red Test Only"; |
| 2036 | osu_service_desc = "spa:Free service for test purpose"; |
| 2037 | break; |
| 2038 | case 4: |
| 2039 | case 104: |
| 2040 | owrt_ap_set_list_vap(dut, vap_id, "osu_friendly_name", |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2041 | "'eng:SP Orange Test Only'"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2042 | owrt_ap_set_list_vap(dut, vap_id, "osu_service_desc", |
| 2043 | "'eng:Free service for test purpose'"); |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2044 | hs20_icon_filename = "icon_orange_eng.png"; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2045 | if (dut->ap_osu_icon_tag == 2) |
| 2046 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 2047 | |
| 2048 | snprintf(hs20_icon, sizeof(hs20_icon), |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2049 | "'160:76:eng:image/png:icon_orange_eng.png:/etc/ath/%s'", |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2050 | hs20_icon_filename); |
| 2051 | owrt_ap_set_list_vap(dut, vap_id, "hs20_icon", |
| 2052 | hs20_icon); |
| 2053 | osu_friendly_name = "'kor:SP 파랑 테스트 전용'"; |
| 2054 | |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2055 | hs20_icon_filename = "icon_orange_zxx.png"; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2056 | if (dut->ap_osu_icon_tag == 2) |
| 2057 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 2058 | |
| 2059 | snprintf(hs20_icon, sizeof(hs20_icon), |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2060 | "'128:61:zxx:image/png:icon_orange_zxx.png:/etc/ath/%s'", |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2061 | hs20_icon_filename); |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2062 | osu_icon = "icon_orange_zxx.png"; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2063 | break; |
| 2064 | case 5: |
| 2065 | case 105: |
| 2066 | owrt_ap_set_list_vap(dut, vap_id, "osu_friendly_name", |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2067 | "'eng:SP Orange Test Only'"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2068 | owrt_ap_set_list_vap(dut, vap_id, "osu_service_desc", |
| 2069 | "'eng:Free service for test purpose'"); |
| 2070 | osu_friendly_name = "'kor:SP 파랑 테스트 전용'"; |
| 2071 | |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2072 | hs20_icon_filename = "icon_orange_zxx.png"; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2073 | if (dut->ap_osu_icon_tag == 2) |
| 2074 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 2075 | |
| 2076 | snprintf(hs20_icon, sizeof(hs20_icon), |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2077 | "'128:61:zxx:image/png:icon_orange_zxx.png:/etc/ath/%s'", |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2078 | hs20_icon_filename); |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2079 | osu_icon = "icon_orange_zxx.png"; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2080 | break; |
| 2081 | case 6: |
| 2082 | case 106: |
| 2083 | owrt_ap_set_list_vap(dut, vap_id, "osu_friendly_name", |
| 2084 | "'eng:SP Green Test Only'"); |
| 2085 | owrt_ap_set_list_vap(dut, vap_id, "osu_friendly_name", |
| 2086 | "'kor:SP 초록 테스트 전용'"); |
| 2087 | |
| 2088 | hs20_icon_filename = "icon_green_zxx.png"; |
| 2089 | if (dut->ap_osu_icon_tag == 2) |
| 2090 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 2091 | |
| 2092 | snprintf(hs20_icon, sizeof(hs20_icon), |
| 2093 | "'128:61:zxx:image/png:icon_green_zxx.png:/etc/ath/%s'", |
| 2094 | hs20_icon_filename); |
| 2095 | owrt_ap_set_list_vap(dut, vap_id, "hs20_icon", |
| 2096 | hs20_icon); |
| 2097 | |
| 2098 | owrt_ap_set_list_vap(dut, vap_id, "osu_icon", |
| 2099 | "'icon_green_zxx.png'"); |
| 2100 | osu_method = (dut->ap_osu_method[0] == 0xFF) ? 0 : |
| 2101 | dut->ap_osu_method[0]; |
| 2102 | |
| 2103 | snprintf(buf, sizeof(buf), "%d", osu_method); |
| 2104 | owrt_ap_set_vap(dut, vap_id, "osu_method_list", buf); |
| 2105 | |
| 2106 | if (strlen(dut->ap_osu_server_uri[1])) |
| 2107 | owrt_ap_set_list_vap(dut, vap_id, |
| 2108 | "osu_server_uri", |
| 2109 | dut->ap_osu_server_uri[1]); |
| 2110 | else |
| 2111 | owrt_ap_set_list_vap(dut, vap_id, |
| 2112 | "osu_server_uri", |
| 2113 | "'https://osu-server.r2-testbed.wi-fi.org/'"); |
| 2114 | |
| 2115 | owrt_ap_set_list_vap(dut, vap_id, "osu_friendly_name", |
| 2116 | "'eng:SP Orange Test Only'"); |
| 2117 | |
| 2118 | hs20_icon_filename = "icon_orange_zxx.png"; |
| 2119 | if (dut->ap_osu_icon_tag == 2) |
| 2120 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 2121 | |
| 2122 | snprintf(hs20_icon, sizeof(hs20_icon), |
| 2123 | "'128:61:zxx:image/png:icon_orange_zxx.png:/etc/ath/%s'", |
| 2124 | hs20_icon_filename); |
| 2125 | |
| 2126 | osu_icon = "icon_orange_zxx.png"; |
| 2127 | osu_friendly_name = "'kor:SP 오렌지 테스트 전용'"; |
| 2128 | osu_method = (dut->ap_osu_method[1] == 0xFF) ? 0 : |
| 2129 | dut->ap_osu_method[1]; |
| 2130 | osu_service_desc = NULL; |
| 2131 | break; |
| 2132 | case 7: |
| 2133 | case 107: |
| 2134 | owrt_ap_set_list_vap(dut, vap_id, "osu_friendly_name", |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2135 | "'eng:SP Green Test Only'"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2136 | owrt_ap_set_list_vap(dut, vap_id, "osu_service_desc", |
| 2137 | "'eng:Free service for test purpose'"); |
| 2138 | |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2139 | hs20_icon_filename = "icon_green_eng.png"; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2140 | if (dut->ap_osu_icon_tag == 2) |
| 2141 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 2142 | |
| 2143 | snprintf(hs20_icon, sizeof(hs20_icon), |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2144 | "'160:76:eng:image/png:icon_green_eng.png:/etc/ath/%s'", |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2145 | hs20_icon_filename); |
| 2146 | owrt_ap_set_list_vap(dut, vap_id, "hs20_icon", |
| 2147 | hs20_icon); |
| 2148 | |
| 2149 | owrt_ap_set_list_vap(dut, vap_id, "osu_icon", |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2150 | "'icon_green_eng.png'"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2151 | osu_friendly_name = "'kor:SP 오렌지 테스트 전용'"; |
| 2152 | |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2153 | hs20_icon_filename = "icon_green_zxx.png"; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2154 | if (dut->ap_osu_icon_tag == 2) |
| 2155 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 2156 | |
| 2157 | snprintf(hs20_icon, sizeof(hs20_icon), |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2158 | "'128:61:zxx:image/png:icon_green_zxx.png:/etc/ath/%s'", |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2159 | hs20_icon_filename); |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2160 | osu_icon = "icon_green_zxx.png"; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2161 | break; |
| 2162 | case 8: |
| 2163 | case 108: |
| 2164 | owrt_ap_set_list_vap(dut, vap_id, "osu_friendly_name", |
| 2165 | "'eng:SP Red Test Only'"); |
| 2166 | owrt_ap_set_list_vap(dut, vap_id, "osu_service_desc", |
| 2167 | "'eng:Free service for test purpose'"); |
| 2168 | osu_ssid = "OSU-Encrypted"; |
| 2169 | osu_nai = "'anonymous@hotspot.net'"; |
| 2170 | break; |
| 2171 | case 9: |
| 2172 | case 109: |
| 2173 | osu_ssid = "OSU-OSEN"; |
| 2174 | osu_nai = "'test-anonymous@wi-fi.org'"; |
| 2175 | osu_friendly_name = "'eng:SP Orange Test Only'"; |
| 2176 | hs20_icon_filename = "icon_orange_zxx.png"; |
| 2177 | if (dut->ap_osu_icon_tag == 2) |
| 2178 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 2179 | |
| 2180 | snprintf(hs20_icon, sizeof(hs20_icon), |
| 2181 | "'128:61:zxx:image/png:icon_orange_zxx.png:/etc/ath/%s'", |
| 2182 | hs20_icon_filename); |
| 2183 | osu_icon = "icon_orange_zxx.png"; |
| 2184 | osu_method = (dut->ap_osu_method[0] == 0xFF) ? 1 : |
| 2185 | dut->ap_osu_method[0]; |
| 2186 | osu_service_desc = NULL; |
| 2187 | break; |
| 2188 | default: |
| 2189 | break; |
| 2190 | } |
| 2191 | |
| 2192 | if (strlen(dut->ap_osu_ssid)) { |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 2193 | if (strcmp(dut->ap_tag_ssid[0], |
| 2194 | dut->ap_osu_ssid) != 0 && |
| 2195 | strcmp(dut->ap_tag_ssid[0], osu_ssid) != 0) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2196 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 2197 | "OSU_SSID and WLAN_TAG2 SSID differ"); |
| 2198 | return -2; |
| 2199 | } |
| 2200 | |
| 2201 | snprintf(buf, sizeof(buf), "'\"%s\"'", |
| 2202 | dut->ap_osu_ssid); |
| 2203 | } else { |
| 2204 | snprintf(buf, sizeof(buf), "'\"%s\"'", osu_ssid); |
| 2205 | } |
| 2206 | |
| 2207 | owrt_ap_set_vap(dut, vap_id, "osu_ssid", buf); |
| 2208 | |
| 2209 | |
| 2210 | if (osu_friendly_name) |
| 2211 | owrt_ap_set_list_vap(dut, vap_id, "osu_friendly_name", |
| 2212 | osu_friendly_name); |
| 2213 | if (osu_service_desc) |
| 2214 | owrt_ap_set_list_vap(dut, vap_id, "osu_service_desc", |
| 2215 | osu_service_desc); |
| 2216 | if (osu_nai) |
| 2217 | owrt_ap_set_vap(dut, vap_id, "osu_nai", osu_nai); |
| 2218 | |
| 2219 | owrt_ap_set_list_vap(dut, vap_id, "hs20_icon", hs20_icon); |
| 2220 | |
| 2221 | if (osu_icon) |
| 2222 | owrt_ap_set_list_vap(dut, vap_id, "osu_icon", |
| 2223 | osu_icon); |
| 2224 | |
| 2225 | if (dut->ap_osu_provider_list > 100) { |
| 2226 | owrt_ap_set_list_vap(dut, vap_id, "osu_method_list", |
| 2227 | "0"); |
| 2228 | } else { |
| 2229 | snprintf(buf, sizeof(buf), "%d", osu_method); |
| 2230 | owrt_ap_set_list_vap(dut, vap_id, "osu_method_list", |
| 2231 | buf); |
| 2232 | } |
| 2233 | } |
| 2234 | |
| 2235 | return 0; |
| 2236 | } |
| 2237 | |
| 2238 | |
Adil Saeed Musthafa | a8d7484 | 2017-04-10 23:13:39 -0700 | [diff] [blame] | 2239 | static void set_anqp_elem_value(struct sigma_dut *dut, const char *ifname, |
| 2240 | char *anqp_string, size_t str_size) |
| 2241 | { |
| 2242 | unsigned char bssid[ETH_ALEN]; |
| 2243 | unsigned char dummy_mac[] = { 0x00, 0x10, 0x20, 0x30, 0x40, 0x50 }; |
| 2244 | int preference = 0xff; |
| 2245 | |
| 2246 | get_hwaddr(ifname, bssid); |
| 2247 | snprintf(anqp_string, str_size, |
| 2248 | "272:3410%02x%02x%02x%02x%02x%02xf70000007330000301%02x3410%02x%02x%02x%02x%02x%02xf70000007330000301%02x", |
| 2249 | bssid[0], bssid[1], bssid[2], bssid[3], bssid[4], bssid[5], |
| 2250 | preference, |
| 2251 | dummy_mac[0], dummy_mac[1], dummy_mac[2], |
| 2252 | dummy_mac[3], dummy_mac[4], dummy_mac[5], |
| 2253 | preference - 1); |
| 2254 | } |
| 2255 | |
| 2256 | |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 2257 | static void get_if_name(struct sigma_dut *dut, char *ifname_str, |
| 2258 | size_t str_size, int wlan_tag) |
| 2259 | { |
Jouni Malinen | f898464 | 2017-10-12 00:02:37 +0300 | [diff] [blame] | 2260 | const char *ifname; |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 2261 | enum driver_type drv; |
| 2262 | |
| 2263 | drv = get_driver_type(); |
Jouni Malinen | f898464 | 2017-10-12 00:02:37 +0300 | [diff] [blame] | 2264 | if (dut->hostapd_ifname && if_nametoindex(dut->hostapd_ifname) > 0) { |
| 2265 | ifname = dut->hostapd_ifname; |
| 2266 | } else if (drv == DRIVER_ATHEROS) { |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 2267 | if ((dut->ap_mode == AP_11a || dut->ap_mode == AP_11na || |
| 2268 | dut->ap_mode == AP_11ac) && |
| 2269 | if_nametoindex("ath1") > 0) |
| 2270 | ifname = "ath1"; |
| 2271 | else |
| 2272 | ifname = "ath0"; |
| 2273 | } else if (drv == DRIVER_OPENWRT) { |
| 2274 | if (sigma_radio_ifname[0] && |
| 2275 | strcmp(sigma_radio_ifname[0], "wifi2") == 0) |
| 2276 | ifname = "ath2"; |
| 2277 | else if (sigma_radio_ifname[0] && |
| 2278 | strcmp(sigma_radio_ifname[0], "wifi1") == 0) |
| 2279 | ifname = "ath1"; |
| 2280 | else |
| 2281 | ifname = "ath0"; |
| 2282 | } else { |
| 2283 | if ((dut->ap_mode == AP_11a || dut->ap_mode == AP_11na || |
| 2284 | dut->ap_mode == AP_11ac) && |
| 2285 | if_nametoindex("wlan1") > 0) |
| 2286 | ifname = "wlan1"; |
| 2287 | else |
| 2288 | ifname = "wlan0"; |
| 2289 | } |
| 2290 | |
| 2291 | if (drv == DRIVER_OPENWRT && wlan_tag > 1) { |
| 2292 | /* Handle tagged-ifname only on OPENWRT for now */ |
| 2293 | snprintf(ifname_str, str_size, "%s%d", ifname, wlan_tag - 1); |
Jouni Malinen | f898464 | 2017-10-12 00:02:37 +0300 | [diff] [blame] | 2294 | } else if (drv == DRIVER_MAC80211 && wlan_tag == 2) { |
| 2295 | snprintf(ifname_str, str_size, "%s_1", ifname); |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 2296 | } else { |
| 2297 | snprintf(ifname_str, str_size, "%s", ifname); |
| 2298 | } |
| 2299 | } |
| 2300 | |
| 2301 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2302 | static int owrt_ap_config_vap(struct sigma_dut *dut) |
| 2303 | { |
| 2304 | char buf[256], *temp; |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 2305 | int vap_id = 0, vap_count, i, j; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2306 | |
| 2307 | 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] | 2308 | snprintf(buf, sizeof(buf), "wifi%d", vap_count); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2309 | |
| 2310 | for (vap_id = 0; vap_id < MAX_RADIO; vap_id++) { |
| 2311 | if (sigma_radio_ifname[vap_id] && |
| 2312 | strcmp(sigma_radio_ifname[vap_id], buf) == 0) |
| 2313 | break; |
| 2314 | } |
| 2315 | if (vap_id == MAX_RADIO) |
| 2316 | continue; |
| 2317 | |
| 2318 | /* Single VAP configuration */ |
| 2319 | if (!dut->ap_is_dual) |
| 2320 | vap_id = vap_count; |
| 2321 | |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 2322 | for (j = 0; j < MAX_WLAN_TAGS - 1; j++) { |
| 2323 | /* |
| 2324 | * We keep a separate array of ap_tag_ssid and |
| 2325 | * ap_tag_key_mgmt for tags starting from WLAN_TAG=2. |
| 2326 | * So j=0 => WLAN_TAG = 2 |
| 2327 | */ |
| 2328 | int wlan_tag = j + 2; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2329 | |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 2330 | if (dut->ap_tag_ssid[j][0] == '\0') |
| 2331 | continue; |
| 2332 | |
| 2333 | snprintf(buf, sizeof(buf), "%s%d", "wifi", vap_count); |
| 2334 | owrt_ap_add_vap(dut, vap_count + (wlan_tag - 1), |
| 2335 | "device", buf); |
| 2336 | /* SSID */ |
| 2337 | snprintf(buf, sizeof(buf), "\"%s\"", |
| 2338 | dut->ap_tag_ssid[j]); |
| 2339 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), |
| 2340 | "ssid", buf); |
| 2341 | |
| 2342 | if (dut->ap_tag_key_mgmt[j] == AP2_OSEN && |
| 2343 | wlan_tag == 2) { |
| 2344 | /* Only supported for WLAN_TAG=2 */ |
| 2345 | owrt_ap_set_vap(dut, vap_count + 1, "osen", |
| 2346 | "1"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2347 | snprintf(buf, sizeof(buf), "wpa2"); |
| 2348 | owrt_ap_set_vap(dut, vap_count + 1, |
| 2349 | "encryption", buf); |
| 2350 | snprintf(buf, sizeof(buf), "%s", |
| 2351 | dut->ap2_radius_ipaddr); |
| 2352 | owrt_ap_set_vap(dut, vap_count + 1, |
| 2353 | "auth_server", buf); |
| 2354 | snprintf(buf, sizeof(buf), "%d", |
| 2355 | dut->ap2_radius_port); |
| 2356 | owrt_ap_set_vap(dut, vap_count + 1, |
| 2357 | "auth_port", buf); |
| 2358 | snprintf(buf, sizeof(buf), "%s", |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 2359 | dut->ap2_radius_password); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2360 | owrt_ap_set_vap(dut, vap_count + 1, |
| 2361 | "auth_secret", buf); |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 2362 | } else if (dut->ap_tag_key_mgmt[j] == AP2_WPA2_PSK) { |
| 2363 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), |
| 2364 | "encryption", "psk2+ccmp"); |
| 2365 | snprintf(buf, sizeof(buf), "\"%s\"", |
| 2366 | dut->ap_passphrase); |
| 2367 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), |
| 2368 | "key", buf); |
| 2369 | snprintf(buf, sizeof(buf), "%d", dut->ap_pmf); |
| 2370 | owrt_ap_set_vap(dut, vap_count + 1, |
| 2371 | "ieee80211w", buf); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2372 | } |
| 2373 | } |
| 2374 | |
Adil Saeed Musthafa | a8d7484 | 2017-04-10 23:13:39 -0700 | [diff] [blame] | 2375 | /* Now set anqp_elem for wlan_tag = 1 */ |
| 2376 | if (dut->program == PROGRAM_MBO && |
| 2377 | get_driver_type() == DRIVER_OPENWRT) { |
| 2378 | char anqp_string[200]; |
| 2379 | |
| 2380 | set_anqp_elem_value(dut, sigma_radio_ifname[0], |
| 2381 | anqp_string, sizeof(anqp_string)); |
| 2382 | owrt_ap_set_list_vap(dut, vap_count, "anqp_elem", |
| 2383 | anqp_string); |
| 2384 | } |
| 2385 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2386 | /* SSID */ |
| 2387 | snprintf(buf, sizeof(buf), "\"%s\"", dut->ap_ssid); |
| 2388 | owrt_ap_set_vap(dut, vap_count, "ssid", buf); |
| 2389 | |
| 2390 | /* Encryption */ |
| 2391 | switch (dut->ap_key_mgmt) { |
| 2392 | case AP_OPEN: |
| 2393 | if (dut->ap_cipher == AP_WEP) { |
| 2394 | owrt_ap_set_vap(dut, vap_count, "encryption", |
| 2395 | "wep-mixed"); |
| 2396 | owrt_ap_set_vap(dut, vap_count, "key", |
| 2397 | dut->ap_wepkey); |
| 2398 | } else { |
| 2399 | owrt_ap_set_vap(dut, vap_count, "encryption", |
| 2400 | "none"); |
| 2401 | } |
| 2402 | break; |
| 2403 | case AP_WPA2_PSK: |
| 2404 | case AP_WPA2_PSK_MIXED: |
| 2405 | case AP_WPA_PSK: |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 2406 | case AP_WPA2_SAE: |
| 2407 | case AP_WPA2_PSK_SAE: |
| 2408 | /* TODO: SAE configuration */ |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2409 | if (dut->ap_key_mgmt == AP_WPA2_PSK) { |
| 2410 | snprintf(buf, sizeof(buf), "psk2"); |
| 2411 | } else if (dut->ap_key_mgmt == AP_WPA2_PSK_MIXED) { |
| 2412 | snprintf(buf, sizeof(buf), "psk-mixed"); |
| 2413 | } else { |
| 2414 | snprintf(buf, sizeof(buf), "psk"); |
| 2415 | } |
| 2416 | |
Peng Xu | 591be45 | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 2417 | if (dut->ap_cipher == AP_CCMP_TKIP) |
| 2418 | strlcat(buf, "+ccmp+tkip", sizeof(buf)); |
| 2419 | else if (dut->ap_cipher == AP_TKIP) |
| 2420 | strlcat(buf, "+tkip", sizeof(buf)); |
| 2421 | else |
| 2422 | strlcat(buf, "+ccmp", sizeof(buf)); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2423 | |
| 2424 | owrt_ap_set_vap(dut, vap_count, "encryption", buf); |
| 2425 | snprintf(buf, sizeof(buf), "\"%s\"", |
| 2426 | dut->ap_passphrase); |
| 2427 | owrt_ap_set_vap(dut, vap_count, "key", buf); |
| 2428 | break; |
| 2429 | case AP_WPA2_EAP: |
| 2430 | case AP_WPA2_EAP_MIXED: |
| 2431 | case AP_WPA_EAP: |
| 2432 | if (dut->ap_key_mgmt == AP_WPA2_EAP) { |
| 2433 | snprintf(buf, sizeof(buf), "wpa2"); |
| 2434 | } else if (dut->ap_key_mgmt == AP_WPA2_EAP_MIXED) { |
| 2435 | snprintf(buf, sizeof(buf), "wpa-mixed"); |
| 2436 | } else { |
| 2437 | snprintf(buf, sizeof(buf), "wpa"); |
| 2438 | } |
| 2439 | |
Peng Xu | 591be45 | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 2440 | if (dut->ap_cipher == AP_CCMP_TKIP) |
| 2441 | strlcat(buf, "+ccmp+tkip", sizeof(buf)); |
| 2442 | else if (dut->ap_cipher == AP_TKIP) |
| 2443 | strlcat(buf, "+tkip", sizeof(buf)); |
| 2444 | else |
| 2445 | strlcat(buf, "+ccmp", sizeof(buf)); |
| 2446 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2447 | owrt_ap_set_vap(dut, vap_count, "encryption", buf); |
| 2448 | snprintf(buf, sizeof(buf), "%s", dut->ap_radius_ipaddr); |
| 2449 | owrt_ap_set_vap(dut, vap_count, "auth_server", buf); |
| 2450 | snprintf(buf, sizeof(buf), "%d", dut->ap_radius_port); |
| 2451 | owrt_ap_set_vap(dut, vap_count, "auth_port", buf); |
| 2452 | snprintf(buf, sizeof(buf), "%s", |
| 2453 | dut->ap_radius_password); |
| 2454 | owrt_ap_set_vap(dut, vap_count, "auth_secret", buf); |
| 2455 | break; |
Jouni Malinen | ad395a2 | 2017-09-01 21:13:46 +0300 | [diff] [blame] | 2456 | case AP_SUITEB: |
| 2457 | /* TODO */ |
| 2458 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 2459 | "SuiteB not supported"); |
| 2460 | break; |
Jouni Malinen | 147b3c3 | 2017-10-09 16:51:54 +0300 | [diff] [blame] | 2461 | case AP_WPA2_OWE: |
| 2462 | /* TODO */ |
| 2463 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 2464 | "OWE not supported"); |
| 2465 | break; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2466 | } |
| 2467 | |
| 2468 | if (!dut->ap_is_dual) |
| 2469 | break; |
| 2470 | } |
| 2471 | |
| 2472 | if (dut->ap_is_dual) |
| 2473 | return 1; |
| 2474 | |
| 2475 | /* PMF */ |
| 2476 | snprintf(buf, sizeof(buf), "%d", dut->ap_pmf); |
| 2477 | owrt_ap_set_vap(dut, vap_id, "ieee80211w", buf); |
| 2478 | |
| 2479 | /* Add SHA256 */ |
| 2480 | snprintf(buf, sizeof(buf), "%d", dut->ap_add_sha256); |
| 2481 | owrt_ap_set_vap(dut, vap_id, "add_sha256", buf); |
| 2482 | |
Sarvepalli, Rajesh Babu | 24dc7e4 | 2016-03-18 21:27:26 +0530 | [diff] [blame] | 2483 | /* Enable RSN preauthentication, if asked to */ |
| 2484 | snprintf(buf, sizeof(buf), "%d", dut->ap_rsn_preauth); |
| 2485 | owrt_ap_set_vap(dut, vap_id, "rsn_preauth", buf); |
| 2486 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2487 | /* Hotspot 2.0 */ |
| 2488 | if (dut->ap_hs2) { |
| 2489 | int ret; |
| 2490 | |
| 2491 | ret = owrt_ap_config_vap_hs2(dut, vap_id); |
| 2492 | if (ret) |
| 2493 | return ret; |
| 2494 | } |
| 2495 | |
| 2496 | /* Interworking */ |
| 2497 | if (dut->ap_interworking) { |
| 2498 | snprintf(buf, sizeof(buf), "%d", dut->ap_access_net_type); |
| 2499 | owrt_ap_set_vap(dut, vap_id, "access_network_type", buf); |
| 2500 | snprintf(buf, sizeof(buf), "%d", dut->ap_internet); |
| 2501 | owrt_ap_set_vap(dut, vap_id, "internet", buf); |
| 2502 | snprintf(buf, sizeof(buf), "%d", dut->ap_venue_group); |
| 2503 | owrt_ap_set_vap(dut, vap_id, "venue_group", buf); |
| 2504 | snprintf(buf, sizeof(buf), "%d", dut->ap_venue_type); |
| 2505 | owrt_ap_set_vap(dut, vap_id, "venue_type", buf); |
| 2506 | snprintf(buf, sizeof(buf), "%s", dut->ap_hessid); |
| 2507 | owrt_ap_set_vap(dut, vap_id, "hessid", buf); |
| 2508 | |
| 2509 | if (dut->ap_gas_cb_delay > 0) { |
| 2510 | snprintf(buf, sizeof(buf), "%d", dut->ap_gas_cb_delay); |
| 2511 | owrt_ap_set_vap(dut, vap_id, "gas_comeback_delay", buf); |
| 2512 | } |
| 2513 | |
| 2514 | if (dut->ap_roaming_cons[0]) { |
| 2515 | char *rcons, *temp_ptr; |
| 2516 | |
| 2517 | rcons = strdup(dut->ap_roaming_cons); |
| 2518 | if (rcons == NULL) |
| 2519 | return 0; |
| 2520 | |
| 2521 | temp_ptr = strchr(rcons, ';'); |
| 2522 | |
| 2523 | if (temp_ptr) |
| 2524 | *temp_ptr++ = '\0'; |
| 2525 | |
| 2526 | owrt_ap_set_list_vap(dut, vap_id, "roaming_consortium", |
| 2527 | rcons); |
| 2528 | |
| 2529 | if (temp_ptr) |
| 2530 | owrt_ap_set_list_vap(dut, vap_id, |
| 2531 | "roaming_consortium", |
| 2532 | temp_ptr); |
| 2533 | |
| 2534 | free(rcons); |
| 2535 | } |
| 2536 | } |
| 2537 | |
| 2538 | if (dut->ap_venue_name) { |
| 2539 | owrt_ap_set_list_vap(dut, vap_id, "venue_name", |
| 2540 | "'P\"eng:Wi-Fi Alliance\\n2989 Copper Road\\nSanta Clara, CA 95051, USA\"'"); |
| 2541 | owrt_ap_set_list_vap(dut, vap_id, "venue_name", |
| 2542 | "\'"ANQP_VENUE_NAME_1_CHI"\'"); |
| 2543 | } |
| 2544 | |
| 2545 | if (dut->ap_net_auth_type == 1) { |
| 2546 | owrt_ap_set_vap(dut, vap_id, "network_auth_type", |
| 2547 | "'00https://tandc-server.wi-fi.org'"); |
| 2548 | } else if (dut->ap_net_auth_type == 2) { |
| 2549 | owrt_ap_set_vap(dut, vap_id, "network_auth_type", "'01'"); |
| 2550 | } |
| 2551 | |
| 2552 | if (dut->ap_nai_realm_list == 1) { |
| 2553 | owrt_ap_set_list_vap(dut, vap_id, "nai_realm", |
| 2554 | "'0,mail.example.com;cisco.com;wi-fi.org,21[2:4][5:7]'"); |
| 2555 | owrt_ap_set_list_vap(dut, vap_id, "nai_realm", |
| 2556 | "'0,wi-fi.org;example.com,13[5:6]'"); |
| 2557 | |
| 2558 | } else if (dut->ap_nai_realm_list == 2) { |
| 2559 | owrt_ap_set_list_vap(dut, vap_id, "nai_realm", |
| 2560 | "'0,wi-fi.org,21[2:4][5:7]'"); |
| 2561 | } else if (dut->ap_nai_realm_list == 3) { |
| 2562 | owrt_ap_set_list_vap(dut, vap_id, "nai_realm", |
| 2563 | "'0,cisco.com;wi-fi.org,21[2:4][5:7]'"); |
| 2564 | owrt_ap_set_list_vap(dut, vap_id, "nai_realm", |
| 2565 | "'0,wi-fi.org;example.com,13[5:6]'"); |
| 2566 | } else if (dut->ap_nai_realm_list == 4) { |
| 2567 | owrt_ap_set_list_vap(dut, vap_id, "nai_realm", |
| 2568 | "'0,mail.example.com,21[2:4][5:7],13[5:6]'"); |
| 2569 | } else if (dut->ap_nai_realm_list == 5) { |
| 2570 | owrt_ap_set_list_vap(dut, vap_id, "nai_realm", |
| 2571 | "'0,wi-fi.org;ruckuswireless.com,21[2:4][5:7]'"); |
| 2572 | } else if (dut->ap_nai_realm_list == 6) { |
| 2573 | owrt_ap_set_list_vap(dut, vap_id, "nai_realm", |
| 2574 | "'0,wi-fi.org;mail.example.com,21[2:4][5:7]'"); |
| 2575 | } else if (dut->ap_nai_realm_list == 7) { |
| 2576 | owrt_ap_set_list_vap(dut, vap_id, "nai_realm", |
| 2577 | "'0,wi-fi.org,13[5:6]'"); |
| 2578 | owrt_ap_set_list_vap(dut, vap_id, "nai_realm", |
| 2579 | "'0,wi-fi.org,21[2:4][5:7]'"); |
| 2580 | } |
| 2581 | |
| 2582 | if (dut->ap_domain_name_list[0]) |
| 2583 | owrt_ap_set_list_vap(dut, vap_id, "domain_name", |
| 2584 | dut->ap_domain_name_list); |
| 2585 | |
| 2586 | if (dut->ap_ip_addr_type_avail) |
| 2587 | owrt_ap_set_vap(dut, vap_id, "ipaddr_type_availability", |
| 2588 | "'0c'"); |
| 2589 | |
| 2590 | temp = buf; |
| 2591 | |
| 2592 | *temp++ = '\''; |
| 2593 | |
| 2594 | for (i = 0; dut->ap_plmn_mcc[i][0] && dut->ap_plmn_mnc[i][0]; i++) { |
| 2595 | if (i) |
| 2596 | *temp++ = ';'; |
| 2597 | |
| 2598 | snprintf(temp, |
| 2599 | sizeof(dut->ap_plmn_mcc[i]) + |
| 2600 | sizeof(dut->ap_plmn_mnc[i]) + 1, |
| 2601 | "%s,%s", |
| 2602 | dut->ap_plmn_mcc[i], |
| 2603 | dut->ap_plmn_mnc[i]); |
| 2604 | |
| 2605 | temp += strlen(dut->ap_plmn_mcc[i]) + |
| 2606 | strlen(dut->ap_plmn_mnc[i]) + 1; |
| 2607 | } |
| 2608 | |
| 2609 | *temp++ = '\''; |
| 2610 | *temp++ = '\0'; |
| 2611 | |
| 2612 | if (i) |
| 2613 | owrt_ap_set_vap(dut, vap_id, "anqp_3gpp_cell_net", buf); |
| 2614 | |
| 2615 | if (dut->ap_qos_map_set == 1) |
| 2616 | owrt_ap_set_vap(dut, vap_id, "qos_map_set", QOS_MAP_SET_1); |
| 2617 | else if (dut->ap_qos_map_set == 2) |
| 2618 | owrt_ap_set_vap(dut, vap_id, "qos_map_set", QOS_MAP_SET_2); |
| 2619 | |
| 2620 | /* Proxy-ARP */ |
| 2621 | snprintf(buf, sizeof(buf), "%d", dut->ap_proxy_arp); |
| 2622 | owrt_ap_set_vap(dut, vap_id, "proxyarp", buf); |
| 2623 | |
| 2624 | /* DGAF */ |
| 2625 | snprintf(buf, sizeof(buf), "%d", dut->ap_dgaf_disable); |
| 2626 | /* parse to hostapd */ |
| 2627 | owrt_ap_set_vap(dut, vap_id, "disable_dgaf", buf); |
| 2628 | /* parse to wifi driver */ |
| 2629 | owrt_ap_set_vap(dut, vap_id, "dgaf_disable", buf); |
| 2630 | |
| 2631 | /* HCBSSLoad */ |
| 2632 | if (dut->ap_bss_load) { |
| 2633 | unsigned int bssload = 0; |
| 2634 | |
| 2635 | if (dut->ap_bss_load == 1) { |
| 2636 | /* STA count: 1, CU: 50, AAC: 65535 */ |
| 2637 | bssload = 0x0132ffff; |
| 2638 | } else if (dut->ap_bss_load == 2) { |
| 2639 | /* STA count: 1, CU: 200, AAC: 65535 */ |
| 2640 | bssload = 0x01c8ffff; |
| 2641 | } else if (dut->ap_bss_load == 3) { |
| 2642 | /* STA count: 1, CU: 75, AAC: 65535 */ |
| 2643 | bssload = 0x014bffff; |
| 2644 | } |
| 2645 | |
| 2646 | snprintf(buf, sizeof(buf), "%d", bssload); |
| 2647 | owrt_ap_set_vap(dut, vap_id, "hcbssload", buf); |
| 2648 | } |
| 2649 | |
| 2650 | /* L2TIF */ |
| 2651 | if (dut->ap_l2tif) |
| 2652 | owrt_ap_set_vap(dut, vap_id, "l2tif", "1"); |
| 2653 | |
| 2654 | if (dut->ap_disable_protection == 1) |
| 2655 | owrt_ap_set_vap(dut, vap_id, "enablertscts", "0"); |
| 2656 | |
Sunil Dutt | 77b213d | 2017-09-14 18:24:40 +0300 | [diff] [blame] | 2657 | if (dut->ap_txBF) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2658 | owrt_ap_set_vap(dut, vap_id, "vhtsubfee", "1"); |
| 2659 | owrt_ap_set_vap(dut, vap_id, "vhtsubfer", "1"); |
| 2660 | } |
| 2661 | |
Mohammed Shafi Shajakhan | 061af00 | 2016-06-02 20:10:54 +0530 | [diff] [blame] | 2662 | if (dut->ap_mu_txBF) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2663 | owrt_ap_set_vap(dut, vap_id, "vhtmubfer", "1"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2664 | |
Vasanthakumar Pandurangan | 2b5431d | 2016-01-12 15:52:48 +0530 | [diff] [blame] | 2665 | if (dut->ap_tx_stbc) { |
| 2666 | /* STBC and beamforming are mutually exclusive features */ |
| 2667 | owrt_ap_set_vap(dut, vap_id, "implicitbf", "0"); |
| 2668 | } |
| 2669 | |
Priyadharshini Gowthaman | 8fb1504 | 2015-11-25 18:27:41 +0530 | [diff] [blame] | 2670 | /* enable dfsmode */ |
| 2671 | snprintf(buf, sizeof(buf), "%d", dut->ap_dfs_mode); |
| 2672 | owrt_ap_set_vap(dut, vap_id, "doth", buf); |
| 2673 | |
priyadharshini gowthaman | 2323d0a | 2016-09-02 15:48:02 -0700 | [diff] [blame] | 2674 | if (dut->program == PROGRAM_LOC && dut->ap_interworking) { |
| 2675 | char anqpval[1024]; |
| 2676 | |
| 2677 | owrt_ap_set_vap(dut, vap_id, "interworking", "1"); |
| 2678 | |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 2679 | 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] | 2680 | snprintf(anqpval, sizeof(anqpval), |
| 2681 | "'265:0010%s%s060101'", |
priyadharshini gowthaman | 2323d0a | 2016-09-02 15:48:02 -0700 | [diff] [blame] | 2682 | dut->ap_val_lci, dut->ap_infoz); |
| 2683 | owrt_ap_set_list_vap(dut, vap_id, "anqp_elem", anqpval); |
| 2684 | } |
| 2685 | |
| 2686 | if (dut->ap_lcr == 1) { |
Pradeep Reddy Potteti | b48012a | 2016-11-28 16:58:54 +0530 | [diff] [blame] | 2687 | snprintf(anqpval, sizeof(anqpval), |
| 2688 | "'266:0000b2555302ae%s'", |
priyadharshini gowthaman | 2323d0a | 2016-09-02 15:48:02 -0700 | [diff] [blame] | 2689 | dut->ap_val_lcr); |
| 2690 | owrt_ap_set_list_vap(dut, vap_id, "anqp_elem", anqpval); |
| 2691 | } |
| 2692 | |
| 2693 | if (dut->ap_fqdn_held == 1 && dut->ap_fqdn_supl == 1) |
| 2694 | owrt_ap_set_list_vap(dut, vap_id, "anqp_elem", |
| 2695 | "'267:00110168656c642e6578616d706c652e636f6d0011027375706c2e6578616d706c652e636f6d'"); |
| 2696 | } |
| 2697 | |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 2698 | if (dut->program == PROGRAM_MBO) { |
| 2699 | owrt_ap_set_vap(dut, vap_id, "interworking", "1"); |
| 2700 | owrt_ap_set_vap(dut, vap_id, "mbo", "1"); |
| 2701 | owrt_ap_set_vap(dut, vap_id, "rrm", "1"); |
Adil Saeed Musthafa | 65160c0 | 2017-04-10 23:13:38 -0700 | [diff] [blame] | 2702 | owrt_ap_set_vap(dut, vap_id, "mbo_cell_conn_pref", "1"); |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 2703 | |
| 2704 | owrt_ap_set_list_vap(dut, vap_id, "anqp_elem", |
| 2705 | "'272:34108cfdf0020df1f7000000733000030101'"); |
Adil Saeed Musthafa | ed5faae | 2017-04-10 23:13:36 -0700 | [diff] [blame] | 2706 | snprintf(buf, sizeof(buf), "%d", dut->ap_gas_cb_delay); |
| 2707 | owrt_ap_set_vap(dut, vap_id, "gas_comeback_delay", buf); |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 2708 | } |
| 2709 | |
Adil Saeed Musthafa | 4ec61bd | 2017-04-10 23:13:41 -0700 | [diff] [blame] | 2710 | if (dut->ap_ft_oa == 1) { |
| 2711 | unsigned char self_mac[ETH_ALEN]; |
| 2712 | char mac_str[20]; |
| 2713 | |
| 2714 | owrt_ap_set_vap(dut, vap_id, "ft_over_ds", "0"); |
| 2715 | owrt_ap_set_vap(dut, vap_id, "ieee80211r", "1"); |
| 2716 | get_hwaddr(sigma_radio_ifname[0], self_mac); |
| 2717 | snprintf(mac_str, sizeof(mac_str), |
| 2718 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 2719 | self_mac[0], self_mac[1], self_mac[2], |
| 2720 | self_mac[3], self_mac[4], self_mac[5]); |
| 2721 | owrt_ap_set_vap(dut, vap_id, "ap_macaddr", mac_str); |
| 2722 | owrt_ap_set_vap(dut, vap_id, "ft_psk_generate_local", "1"); |
| 2723 | owrt_ap_set_vap(dut, vap_id, "kh_key_hex", |
| 2724 | "000102030405060708090a0b0c0d0e0f"); |
| 2725 | snprintf(mac_str, sizeof(mac_str), |
| 2726 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 2727 | dut->ft_bss_mac_list[0][0], |
| 2728 | dut->ft_bss_mac_list[0][1], |
| 2729 | dut->ft_bss_mac_list[0][2], |
| 2730 | dut->ft_bss_mac_list[0][3], |
| 2731 | dut->ft_bss_mac_list[0][4], |
| 2732 | dut->ft_bss_mac_list[0][5]); |
| 2733 | owrt_ap_set_vap(dut, vap_id, "ap2_macaddr", mac_str); |
| 2734 | } |
| 2735 | |
| 2736 | if ((dut->ap_ft_oa == 1 && dut->ap_name == 0) || |
| 2737 | (dut->ap_ft_oa == 1 && dut->ap_name == 2)) { |
| 2738 | owrt_ap_set_vap(dut, vap_id, "ap2_r1_key_holder", |
| 2739 | "00:01:02:03:04:06"); |
| 2740 | owrt_ap_set_vap(dut, vap_id, "nasid2", "nas2.example.com"); |
| 2741 | owrt_ap_set_vap(dut, vap_id, "nasid", "nas1.example.com"); |
| 2742 | owrt_ap_set_vap(dut, vap_id, "r1_key_holder", "000102030405"); |
| 2743 | } |
| 2744 | |
| 2745 | if (dut->ap_ft_oa == 1 && dut->ap_name == 1) { |
| 2746 | owrt_ap_set_vap(dut, vap_id, "ap2_r1_key_holder", |
| 2747 | "00:01:02:03:04:05"); |
| 2748 | owrt_ap_set_vap(dut, vap_id, "nasid2", "nas1.example.com"); |
| 2749 | owrt_ap_set_vap(dut, vap_id, "nasid", "nas2.example.com"); |
| 2750 | owrt_ap_set_vap(dut, vap_id, "r1_key_holder", "000102030406"); |
| 2751 | } |
| 2752 | |
Adil Saeed Musthafa | cf752fa | 2017-04-10 23:13:32 -0700 | [diff] [blame] | 2753 | if (dut->ap_mobility_domain[0]) |
| 2754 | owrt_ap_set_vap(dut, vap_id, "mobility_domain", |
| 2755 | dut->ap_mobility_domain); |
| 2756 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2757 | return 1; |
| 2758 | } |
| 2759 | |
| 2760 | |
priyadharshini gowthaman | 2500f20 | 2016-10-13 17:13:55 -0700 | [diff] [blame] | 2761 | static int owrt_ap_config_vap_anqp(struct sigma_dut *dut) |
| 2762 | { |
| 2763 | char anqpval[1024]; |
| 2764 | unsigned char addr[6]; |
| 2765 | unsigned char addr2[6]; |
| 2766 | struct ifreq ifr; |
| 2767 | char *ifname; |
| 2768 | int s; |
| 2769 | int vap_id = 0; |
| 2770 | |
| 2771 | s = socket(AF_INET, SOCK_DGRAM, 0); |
| 2772 | if (s < 0) { |
| 2773 | sigma_dut_print(dut, DUT_MSG_ERROR, "Failed to open socket"); |
| 2774 | return -1; |
| 2775 | } |
| 2776 | |
| 2777 | memset(&ifr, 0, sizeof(ifr)); |
| 2778 | ifname = "ath0"; |
Peng Xu | b8fc5cc | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 2779 | strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name)); |
priyadharshini gowthaman | 2500f20 | 2016-10-13 17:13:55 -0700 | [diff] [blame] | 2780 | if (ioctl(s, SIOCGIFHWADDR, &ifr) < 0) { |
| 2781 | perror("ioctl"); |
| 2782 | close(s); |
| 2783 | return -1; |
| 2784 | } |
| 2785 | memcpy(addr, ifr.ifr_hwaddr.sa_data, 6); |
| 2786 | |
| 2787 | memset(&ifr, 0, sizeof(ifr)); |
| 2788 | ifname = "ath01"; |
Peng Xu | b8fc5cc | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 2789 | strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name)); |
priyadharshini gowthaman | 2500f20 | 2016-10-13 17:13:55 -0700 | [diff] [blame] | 2790 | if (ioctl(s, SIOCGIFHWADDR, &ifr) < 0) { |
| 2791 | perror("ioctl"); |
| 2792 | close(s); |
| 2793 | return -1; |
| 2794 | } |
| 2795 | close(s); |
| 2796 | memcpy(addr2, ifr.ifr_hwaddr.sa_data, 6); |
| 2797 | |
| 2798 | snprintf(anqpval, sizeof(anqpval), |
| 2799 | "'265:0010%s%s060101070d00%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x'", |
| 2800 | dut->ap_val_lci, dut->ap_infoz, |
| 2801 | addr[0], addr[1], addr[2], addr[3], addr[4], addr[5], |
| 2802 | addr2[0], addr2[1], addr2[2], addr2[3], addr2[4], addr2[5]); |
| 2803 | |
| 2804 | owrt_ap_set_list_vap(dut, vap_id, "anqp_elem", anqpval); |
| 2805 | return 0; |
| 2806 | } |
| 2807 | |
| 2808 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2809 | static int owrt_ap_post_config_commit(struct sigma_dut *dut, |
| 2810 | struct sigma_conn *conn, |
| 2811 | struct sigma_cmd *cmd) |
| 2812 | { |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 2813 | int ap_security = 0; |
| 2814 | int i; |
| 2815 | |
| 2816 | for (i = 0; i < MAX_WLAN_TAGS - 1; i++) { |
| 2817 | if (dut->ap_tag_key_mgmt[i] != AP2_OPEN) |
| 2818 | ap_security = 1; |
| 2819 | } |
| 2820 | if (dut->ap_key_mgmt != AP_OPEN) |
| 2821 | ap_security = 1; |
| 2822 | if (ap_security) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2823 | /* allow some time for hostapd to start before returning |
| 2824 | * success */ |
| 2825 | usleep(500000); |
| 2826 | |
| 2827 | if (run_hostapd_cli(dut, "ping") != 0) { |
| 2828 | send_resp(dut, conn, SIGMA_ERROR, |
| 2829 | "errorCode,Failed to talk to hostapd"); |
| 2830 | return 0; |
| 2831 | } |
| 2832 | } |
| 2833 | |
| 2834 | if (get_openwrt_driver_type() == OPENWRT_DRIVER_ATHEROS) |
| 2835 | ath_ap_set_params(dut); |
| 2836 | |
| 2837 | /* Send response */ |
| 2838 | return 1; |
| 2839 | } |
| 2840 | |
| 2841 | |
| 2842 | static int cmd_owrt_ap_config_commit(struct sigma_dut *dut, |
| 2843 | struct sigma_conn *conn, |
| 2844 | struct sigma_cmd *cmd) |
| 2845 | { |
| 2846 | /* Stop the AP */ |
| 2847 | run_system(dut, "wifi down"); |
| 2848 | |
| 2849 | /* Reset the wireless configuration */ |
Mohammed Shafi Shajakhan | f789f82 | 2016-04-07 18:53:16 +0530 | [diff] [blame] | 2850 | run_system(dut, "rm -rf /etc/config/wireless"); |
| 2851 | switch (get_openwrt_driver_type()) { |
| 2852 | case OPENWRT_DRIVER_ATHEROS: |
| 2853 | run_system(dut, "wifi detect qcawifi > /etc/config/wireless"); |
| 2854 | break; |
| 2855 | default: |
| 2856 | run_system(dut, "wifi detect > /etc/config/wireless"); |
| 2857 | break; |
| 2858 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2859 | |
| 2860 | /* Configure Radio & VAP, commit the config */ |
| 2861 | owrt_ap_config_radio(dut); |
| 2862 | owrt_ap_config_vap(dut); |
| 2863 | run_system(dut, "uci commit"); |
| 2864 | |
| 2865 | /* Start AP */ |
| 2866 | run_system(dut, "wifi up"); |
Adil Saeed Musthafa | a8d7484 | 2017-04-10 23:13:39 -0700 | [diff] [blame] | 2867 | if (dut->program != PROGRAM_MBO && |
| 2868 | dut->ap_lci == 1 && dut->ap_interworking && |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 2869 | strlen(dut->ap_tag_ssid[0]) > 0) { |
Adil Saeed Musthafa | a8d7484 | 2017-04-10 23:13:39 -0700 | [diff] [blame] | 2870 | /* |
| 2871 | * MBO has a different ANQP element value which is set in |
| 2872 | * owrt_ap_config_vap(). |
| 2873 | */ |
priyadharshini gowthaman | 2500f20 | 2016-10-13 17:13:55 -0700 | [diff] [blame] | 2874 | owrt_ap_config_vap_anqp(dut); |
| 2875 | run_system(dut, "uci commit"); |
| 2876 | run_system(dut, "wifi"); |
| 2877 | } |
| 2878 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2879 | return owrt_ap_post_config_commit(dut, conn, cmd); |
| 2880 | } |
| 2881 | |
| 2882 | |
| 2883 | static void cmd_owrt_ap_hs2_reset(struct sigma_dut *dut) |
| 2884 | { |
| 2885 | unsigned char bssid[6]; |
| 2886 | char buf[100]; |
| 2887 | char *ifname, *radio_name; |
| 2888 | int vap_id = 0; |
| 2889 | |
| 2890 | if (sigma_radio_ifname[0] && |
| 2891 | strcmp(sigma_radio_ifname[0], "wifi2") == 0) { |
| 2892 | ifname = "ath2"; |
| 2893 | radio_name = "wifi2"; |
| 2894 | vap_id = 2; |
| 2895 | } else if (sigma_radio_ifname[0] && |
| 2896 | strcmp(sigma_radio_ifname[0], "wifi1") == 0) { |
| 2897 | ifname = "ath1"; |
| 2898 | radio_name = "wifi1"; |
| 2899 | vap_id = 1; |
| 2900 | } else { |
| 2901 | ifname = "ath0"; |
| 2902 | radio_name = "wifi0"; |
| 2903 | vap_id = 0; |
| 2904 | } |
| 2905 | |
| 2906 | if (!get_hwaddr(ifname, bssid)) { |
| 2907 | snprintf(buf, sizeof(buf), "%s", bssid); |
| 2908 | owrt_ap_set_vap(dut, vap_id, "hessid", buf); |
| 2909 | snprintf(dut->ap_hessid, sizeof(dut->ap_hessid), |
| 2910 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 2911 | bssid[0], bssid[1], bssid[2], bssid[3], |
| 2912 | bssid[4], bssid[5]); |
| 2913 | } else { |
| 2914 | if (!get_hwaddr(radio_name, bssid)) { |
| 2915 | snprintf(buf, sizeof(buf), "%s", dut->ap_hessid); |
| 2916 | owrt_ap_set_vap(dut, vap_id, "hessid", buf); |
| 2917 | snprintf(dut->ap_hessid, sizeof(dut->ap_hessid), |
| 2918 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 2919 | bssid[0], bssid[1], bssid[2], bssid[3], |
| 2920 | bssid[4], bssid[5]); |
| 2921 | } else { |
| 2922 | /* Select & enable/disable radios */ |
| 2923 | if (sigma_radio_ifname[0] && |
| 2924 | strcmp(sigma_radio_ifname[0], "wifi2") == 0) { |
| 2925 | /* We want to use wifi2 */ |
| 2926 | owrt_ap_set_radio(dut, 0, "disabled", "1"); |
| 2927 | owrt_ap_set_radio(dut, 1, "disabled", "1"); |
| 2928 | owrt_ap_set_radio(dut, 2, "disabled", "0"); |
| 2929 | owrt_ap_set_vap(dut, vap_id, "device", "wifi2"); |
| 2930 | } else if (sigma_radio_ifname[0] && |
| 2931 | strcmp(sigma_radio_ifname[0], "wifi1") == 0) { |
| 2932 | /* We want to use wifi1 */ |
| 2933 | owrt_ap_set_radio(dut, 0, "disabled", "1"); |
| 2934 | owrt_ap_set_radio(dut, 1, "disabled", "0"); |
| 2935 | owrt_ap_set_vap(dut, vap_id, "device", "wifi1"); |
| 2936 | } else { |
| 2937 | /* We want to use wifi0 */ |
| 2938 | owrt_ap_set_radio(dut, 0, "disabled", "0"); |
| 2939 | owrt_ap_set_radio(dut, 1, "disabled", "1"); |
| 2940 | owrt_ap_set_vap(dut, vap_id, "device", "wifi0"); |
| 2941 | } |
| 2942 | |
| 2943 | run_system(dut, "uci commit"); |
| 2944 | run_system(dut, "wifi up"); |
| 2945 | |
| 2946 | if (!get_hwaddr(radio_name, bssid)) { |
| 2947 | snprintf(buf, sizeof(buf), "%s", |
| 2948 | dut->ap_hessid); |
| 2949 | owrt_ap_set_vap(dut, vap_id, "hessid", buf); |
| 2950 | snprintf(dut->ap_hessid, sizeof(dut->ap_hessid), |
| 2951 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 2952 | bssid[0], bssid[1], bssid[2], bssid[3], |
| 2953 | bssid[4], bssid[5]); |
| 2954 | } |
| 2955 | } |
| 2956 | } |
| 2957 | } |
| 2958 | |
| 2959 | |
| 2960 | static int cmd_ap_reboot(struct sigma_dut *dut, struct sigma_conn *conn, |
| 2961 | struct sigma_cmd *cmd) |
| 2962 | { |
| 2963 | switch (get_driver_type()) { |
| 2964 | case DRIVER_ATHEROS: |
| 2965 | run_system(dut, "apdown"); |
| 2966 | sleep(1); |
| 2967 | run_system(dut, "reboot"); |
| 2968 | break; |
| 2969 | case DRIVER_OPENWRT: |
| 2970 | run_system(dut, "wifi down"); |
| 2971 | sleep(1); |
| 2972 | run_system(dut, "reboot"); |
| 2973 | break; |
| 2974 | default: |
| 2975 | sigma_dut_print(dut, DUT_MSG_INFO, "Ignore ap_reboot command"); |
| 2976 | break; |
| 2977 | } |
| 2978 | |
| 2979 | return 1; |
| 2980 | } |
| 2981 | |
| 2982 | |
| 2983 | int ascii2hexstr(const char *str, char *hex) |
| 2984 | { |
| 2985 | int i, length; |
| 2986 | |
| 2987 | length = strlen(str); |
| 2988 | |
| 2989 | for (i = 0; i < length; i++) |
| 2990 | snprintf(hex + i * 2, 3, "%X", str[i]); |
| 2991 | |
| 2992 | hex[length * 2] = '\0'; |
| 2993 | return 1; |
| 2994 | } |
| 2995 | |
| 2996 | |
| 2997 | static int kill_process(struct sigma_dut *dut, char *proc_name, |
| 2998 | unsigned char is_proc_instance_one, int sig) |
| 2999 | { |
| 3000 | #ifdef __linux__ |
| 3001 | struct dirent *dp, *dp_in; |
| 3002 | const char *direc = "/proc/"; |
| 3003 | char buf[100]; |
| 3004 | DIR *dir = opendir(direc); |
| 3005 | DIR *dir_in; |
| 3006 | FILE *fp; |
| 3007 | char *pid, *temp; |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 3008 | char *saveptr; |
Pradeep Reddy Potteti | d068e64 | 2017-02-17 20:03:12 +0530 | [diff] [blame] | 3009 | int ret = -1; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3010 | |
| 3011 | if (dir == NULL) |
Pradeep Reddy Potteti | d068e64 | 2017-02-17 20:03:12 +0530 | [diff] [blame] | 3012 | return ret; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3013 | |
| 3014 | while ((dp = readdir(dir)) != NULL) { |
| 3015 | if (dp->d_type != DT_DIR) |
| 3016 | continue; |
| 3017 | |
| 3018 | snprintf(buf, sizeof(buf), "%s%s", direc, dp->d_name); |
| 3019 | dir_in = opendir(buf); |
| 3020 | if (dir_in == NULL) |
| 3021 | continue; |
| 3022 | dp_in = readdir(dir_in); |
| 3023 | closedir(dir_in); |
| 3024 | if (dp_in == NULL) |
| 3025 | continue; |
| 3026 | snprintf(buf, sizeof(buf), "%s%s/stat", direc, dp->d_name); |
| 3027 | fp = fopen(buf, "r"); |
| 3028 | if (fp == NULL) |
| 3029 | continue; |
| 3030 | if (fgets(buf, 100, fp) == NULL) |
| 3031 | buf[0] = '\0'; |
| 3032 | fclose(fp); |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 3033 | pid = strtok_r(buf, " ", &saveptr); |
| 3034 | temp = strtok_r(NULL, " ", &saveptr); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3035 | if (pid && temp && |
| 3036 | strncmp(temp, proc_name, strlen(proc_name)) == 0) { |
| 3037 | sigma_dut_print(dut, DUT_MSG_INFO, |
| 3038 | "killing %s process with PID %s", |
| 3039 | proc_name, pid); |
| 3040 | snprintf(buf, sizeof(buf), "kill -%d %d", sig, |
| 3041 | atoi(pid)); |
| 3042 | run_system(dut, buf); |
Pradeep Reddy Potteti | d068e64 | 2017-02-17 20:03:12 +0530 | [diff] [blame] | 3043 | ret = 0; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3044 | if (is_proc_instance_one) |
| 3045 | break; |
| 3046 | } |
| 3047 | } |
| 3048 | |
| 3049 | closedir(dir); |
| 3050 | |
Pradeep Reddy Potteti | d068e64 | 2017-02-17 20:03:12 +0530 | [diff] [blame] | 3051 | return ret; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3052 | #else /* __linux__ */ |
| 3053 | return -1; |
| 3054 | #endif /* __linux__ */ |
| 3055 | } |
| 3056 | |
| 3057 | |
| 3058 | static int run_ndc(struct sigma_dut *dut, char *buf) |
| 3059 | { |
| 3060 | sigma_dut_print(dut, DUT_MSG_INFO, "CMD NDC:: %s", buf); |
| 3061 | sleep(2); |
| 3062 | return run_system(dut, buf); |
| 3063 | } |
| 3064 | |
| 3065 | |
| 3066 | static int sigma_write_cfg(struct sigma_dut *dut, const char *pfile, |
| 3067 | const char *field, const char *value) |
| 3068 | { |
| 3069 | FILE *fcfg, *ftmp; |
| 3070 | char buf[MAX_CONF_LINE_LEN + 1]; |
| 3071 | int len, found = 0, res; |
| 3072 | |
| 3073 | /* Open the configuration file */ |
| 3074 | fcfg = fopen(pfile, "r"); |
| 3075 | if (!fcfg) { |
| 3076 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 3077 | "Failed to open hostapd conf file"); |
| 3078 | return -1; |
| 3079 | } |
| 3080 | |
| 3081 | snprintf(buf, sizeof(buf), "%s~", pfile); |
| 3082 | /* Open a temporary file */ |
| 3083 | ftmp = fopen(buf, "w+"); |
| 3084 | if (!ftmp) { |
| 3085 | fclose(fcfg); |
| 3086 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 3087 | "Failed to open temp buf"); |
| 3088 | return -1; |
| 3089 | } |
| 3090 | |
| 3091 | /* Read the values from the configuration file */ |
| 3092 | len = strlen(field); |
| 3093 | while (fgets(buf, MAX_CONF_LINE_LEN, fcfg)) { |
| 3094 | char *pline = buf; |
| 3095 | |
| 3096 | /* commented line */ |
| 3097 | if (buf[0] == '#') |
| 3098 | pline++; |
| 3099 | |
| 3100 | /* Identify the configuration parameter to be updated */ |
| 3101 | if (!found && strncmp(pline, field, len) == 0 && |
| 3102 | pline[len] == '=') { |
| 3103 | snprintf(buf, sizeof(buf), "%s=%s\n", field, value); |
| 3104 | found = 1; |
| 3105 | sigma_dut_print(dut, DUT_MSG_INFO, |
| 3106 | "Updated hostapd conf file"); |
| 3107 | } |
| 3108 | |
| 3109 | fprintf(ftmp, "%s", buf); |
| 3110 | } |
| 3111 | |
| 3112 | if (!found) { |
| 3113 | /* Configuration line not found */ |
| 3114 | /* Add the new line at the end of file */ |
| 3115 | fprintf(ftmp, "%s=%s\n", field, value); |
| 3116 | sigma_dut_print(dut, DUT_MSG_INFO, |
| 3117 | "Adding a new line in hostapd conf file"); |
| 3118 | } |
| 3119 | |
| 3120 | fclose(fcfg); |
| 3121 | fclose(ftmp); |
| 3122 | |
| 3123 | snprintf(buf, sizeof(buf), "%s~", pfile); |
| 3124 | |
| 3125 | /* Restore the updated configuration file */ |
| 3126 | res = rename(buf, pfile); |
| 3127 | |
| 3128 | /* Remove the temporary file. Ignore the return value */ |
| 3129 | unlink(buf); |
| 3130 | |
| 3131 | /* chmod is needed because open() may not set permissions properly |
| 3132 | * depending on the current umask */ |
| 3133 | if (chmod(pfile, 0660) < 0) { |
| 3134 | unlink(pfile); |
| 3135 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 3136 | "Error changing permissions"); |
| 3137 | return -1; |
| 3138 | } |
| 3139 | |
| 3140 | if (res < 0) { |
| 3141 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 3142 | "Error restoring conf file"); |
| 3143 | return -1; |
| 3144 | } |
| 3145 | |
| 3146 | return 0; |
| 3147 | } |
| 3148 | |
| 3149 | |
| 3150 | static int cmd_wcn_ap_config_commit(struct sigma_dut *dut, |
| 3151 | struct sigma_conn *conn, |
| 3152 | struct sigma_cmd *cmd) |
| 3153 | { |
| 3154 | char buf[100]; |
| 3155 | struct stat s; |
| 3156 | int num_tries = 0, ret; |
| 3157 | |
Pradeep Reddy Potteti | d068e64 | 2017-02-17 20:03:12 +0530 | [diff] [blame] | 3158 | if (kill_process(dut, "(netd)", 1, SIGKILL) == 0 || |
| 3159 | system("killall netd") == 0) { |
| 3160 | /* Avoid Error: Error connecting (Connection refused) |
| 3161 | * Wait some time to allow netd to reinitialize. |
| 3162 | */ |
| 3163 | usleep(1500000); |
| 3164 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3165 | |
| 3166 | while (num_tries < 10) { |
| 3167 | ret = run_ndc(dut, "ndc softap stopap"); |
| 3168 | num_tries++; |
| 3169 | if (WIFEXITED(ret)) |
| 3170 | ret = WEXITSTATUS(ret); |
| 3171 | /* On success, NDC exits with 0 */ |
| 3172 | if (ret == 0) |
| 3173 | break; |
| 3174 | sigma_dut_print(dut, DUT_MSG_INFO, |
| 3175 | "Try No. %d: ndc softap stopap failed, exit code %d", |
| 3176 | num_tries, ret); |
| 3177 | } |
| 3178 | |
| 3179 | if (ret != 0) |
| 3180 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 3181 | "ndc softap stopap command failed for 10 times - giving up"); |
| 3182 | |
| 3183 | #ifdef ANDROID |
| 3184 | /* Unload/Load driver to cleanup the state of the driver */ |
Ajit Vaishya | 14d1f9a | 2017-09-04 23:24:25 +0530 | [diff] [blame] | 3185 | system("rmmod -f wlan"); |
| 3186 | usleep(500000); |
| 3187 | system("insmod /system/lib/modules/wlan.ko"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3188 | #else /* ANDROID */ |
| 3189 | run_ndc(dut, "ndc softap qccmd set enable_softap=0"); |
| 3190 | run_ndc(dut, "ndc softap qccmd set enable_softap=1"); |
| 3191 | #endif /* ANDROID */ |
| 3192 | |
| 3193 | switch (dut->ap_mode) { |
| 3194 | case AP_11g: |
| 3195 | run_ndc(dut, "ndc softap qccmd set hw_mode=g-only"); |
| 3196 | break; |
| 3197 | case AP_11b: |
| 3198 | run_ndc(dut, "ndc softap qccmd set hw_mode=b-only"); |
| 3199 | break; |
| 3200 | case AP_11ng: |
| 3201 | run_ndc(dut, "ndc softap qccmd set hw_mode=n"); |
| 3202 | break; |
| 3203 | case AP_11a: |
| 3204 | run_ndc(dut, "ndc softap qccmd set hw_mode=a-only"); |
| 3205 | break; |
| 3206 | case AP_11na: |
| 3207 | run_ndc(dut, "ndc softap qccmd set hw_mode=n"); |
| 3208 | break; |
| 3209 | case AP_11ac: |
| 3210 | run_ndc(dut, "ndc softap qccmd set hw_mode=ac"); |
| 3211 | break; |
| 3212 | default: |
| 3213 | break; |
| 3214 | } |
| 3215 | |
| 3216 | snprintf(buf, sizeof(buf), "ndc softap qccmd set channel=%d", |
| 3217 | dut->ap_channel); |
| 3218 | run_ndc(dut, buf); |
| 3219 | |
| 3220 | /* |
| 3221 | * ndc doesn't support double quotes as SSID string, so re-write |
| 3222 | * hostapd configuration file to update SSID. |
| 3223 | */ |
| 3224 | if (dut->ap_ssid[0] != '\0') |
| 3225 | sigma_write_cfg(dut, ANDROID_CONFIG_FILE, "ssid", dut->ap_ssid); |
| 3226 | |
| 3227 | switch (dut->ap_key_mgmt) { |
| 3228 | case AP_OPEN: |
| 3229 | if (dut->ap_cipher == AP_WEP) { |
| 3230 | run_ndc(dut, "ndc softap qccmd set security_mode=1"); |
| 3231 | snprintf(buf, sizeof(buf), |
| 3232 | "ndc softap qccmd set wep_key0=%s", |
| 3233 | dut->ap_wepkey); |
| 3234 | run_ndc(dut, buf); |
| 3235 | } else { |
| 3236 | run_ndc(dut, "ndc softap qccmd set security_mode=0"); |
| 3237 | } |
| 3238 | break; |
| 3239 | case AP_WPA2_PSK: |
| 3240 | case AP_WPA2_PSK_MIXED: |
| 3241 | case AP_WPA_PSK: |
| 3242 | if (dut->ap_key_mgmt == AP_WPA2_PSK) |
| 3243 | run_ndc(dut, "ndc softap qccmd set security_mode=3"); |
| 3244 | else if (dut->ap_key_mgmt == AP_WPA2_PSK_MIXED) |
| 3245 | run_ndc(dut, "ndc softap qccmd set security_mode=4"); |
| 3246 | else |
| 3247 | run_ndc(dut, "ndc softap qccmd set security_mode=2"); |
| 3248 | |
| 3249 | /* |
| 3250 | * ndc doesn't support some special characters as passphrase, |
| 3251 | * so re-write hostapd configuration file to update Passphrase. |
| 3252 | */ |
| 3253 | if (dut->ap_passphrase[0] != '\0') |
| 3254 | sigma_write_cfg(dut, ANDROID_CONFIG_FILE, |
| 3255 | "wpa_passphrase", dut->ap_passphrase); |
| 3256 | |
| 3257 | if (dut->ap_cipher == AP_CCMP_TKIP) |
| 3258 | run_ndc(dut, "ndc softap qccmd set wpa_pairwise=" |
| 3259 | "TKIP CCMP"); |
| 3260 | else if (dut->ap_cipher == AP_TKIP) |
| 3261 | run_ndc(dut, "ndc softap qccmd set wpa_pairwise=" |
| 3262 | "TKIP"); |
| 3263 | else |
| 3264 | run_ndc(dut, "ndc softap qccmd set wpa_pairwise=" |
| 3265 | "CCMP &"); |
| 3266 | break; |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 3267 | case AP_WPA2_SAE: |
| 3268 | case AP_WPA2_PSK_SAE: |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3269 | case AP_WPA2_EAP: |
| 3270 | case AP_WPA2_EAP_MIXED: |
| 3271 | case AP_WPA_EAP: |
Jouni Malinen | ad395a2 | 2017-09-01 21:13:46 +0300 | [diff] [blame] | 3272 | case AP_SUITEB: |
Jouni Malinen | 147b3c3 | 2017-10-09 16:51:54 +0300 | [diff] [blame] | 3273 | case AP_WPA2_OWE: |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3274 | /* Not supported */ |
| 3275 | break; |
| 3276 | } |
| 3277 | |
| 3278 | switch (dut->ap_pmf) { |
| 3279 | case AP_PMF_DISABLED: |
| 3280 | run_ndc(dut, "ndc softap qccmd set ieee80211w=0"); |
| 3281 | break; |
| 3282 | case AP_PMF_OPTIONAL: |
| 3283 | run_ndc(dut, "ndc softap qccmd set ieee80211w=1"); |
| 3284 | if (dut->ap_add_sha256) |
| 3285 | run_ndc(dut, "ndc softap qccmd set wpa_key_mgmt=WPA-PSK WPA-PSK-SHA256"); |
| 3286 | else |
| 3287 | run_ndc(dut, "ndc softap qccmd set wpa_key_mgmt=WPA-PSK"); |
| 3288 | break; |
| 3289 | case AP_PMF_REQUIRED: |
| 3290 | run_ndc(dut, "ndc softap qccmd set ieee80211w=2"); |
| 3291 | run_ndc(dut, "ndc softap qccmd set wpa_key_mgmt=WPA-PSK-SHA256"); |
| 3292 | break; |
| 3293 | } |
| 3294 | |
| 3295 | if (dut->ap_countrycode[0]) { |
| 3296 | snprintf(buf, sizeof(buf), |
| 3297 | "ndc softap qccmd set country_code=%s", |
| 3298 | dut->ap_countrycode); |
| 3299 | run_ndc(dut, buf); |
| 3300 | } |
| 3301 | |
Pradeep Reddy POTTETI | fba27db | 2015-11-20 16:42:22 +0530 | [diff] [blame] | 3302 | if (dut->ap_regulatory_mode == AP_80211D_MODE_ENABLED) |
| 3303 | run_ndc(dut, "ndc softap qccmd set ieee80211d=1"); |
| 3304 | |
| 3305 | if (dut->ap_dfs_mode == AP_DFS_MODE_ENABLED) |
| 3306 | run_ndc(dut, "ndc softap qccmd set ieee80211h=1"); |
| 3307 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3308 | run_ndc(dut, "ndc softap startap"); |
| 3309 | |
| 3310 | snprintf(buf, sizeof(buf), "%s%s", sigma_wpas_ctrl, sigma_main_ifname); |
| 3311 | num_tries = 0; |
| 3312 | while (num_tries < 10 && (ret = stat(buf, &s) != 0)) { |
| 3313 | run_ndc(dut, "ndc softap stopap"); |
| 3314 | run_ndc(dut, "ndc softap startap"); |
| 3315 | num_tries++; |
| 3316 | } |
| 3317 | |
| 3318 | if (num_tries == 10) { |
| 3319 | sigma_dut_print(dut, DUT_MSG_INFO, "Tried 10 times with ctrl " |
| 3320 | "iface %s :: reboot the APDUT", buf); |
| 3321 | return ret; |
| 3322 | } |
| 3323 | |
| 3324 | sigma_dut_print(dut, DUT_MSG_INFO, "setting ip addr %s mask %s", |
| 3325 | ap_inet_addr, ap_inet_mask); |
| 3326 | snprintf(buf, sizeof(buf), "ifconfig %s %s netmask %s up", |
| 3327 | sigma_main_ifname, ap_inet_addr, ap_inet_mask); |
| 3328 | if (system(buf) != 0) { |
| 3329 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 3330 | "Failed to intialize the interface"); |
| 3331 | return -1; |
| 3332 | } |
| 3333 | |
| 3334 | return 1; |
| 3335 | } |
| 3336 | |
| 3337 | |
| 3338 | static int append_hostapd_conf_hs2(struct sigma_dut *dut, FILE *f) |
| 3339 | { |
| 3340 | fprintf(f, "hs20=1\nhs20_deauth_req_timeout=3\n" |
| 3341 | "disable_dgaf=%d\n", dut->ap_dgaf_disable); |
| 3342 | |
| 3343 | if (dut->ap_oper_name) { |
| 3344 | fprintf(f, "hs20_oper_friendly_name=eng:Wi-Fi Alliance\n"); |
| 3345 | fprintf(f, "hs20_oper_friendly_name=chi:Wi-Fi\xe8\x81\x94\xe7\x9b\x9f\n"); |
| 3346 | } |
| 3347 | |
| 3348 | if (dut->ap_wan_metrics == 1) |
| 3349 | fprintf(f, "hs20_wan_metrics=01:2500:384:0:0:10\n"); |
| 3350 | else if (dut->ap_wan_metrics == 2) |
| 3351 | fprintf(f, "hs20_wan_metrics=01:1500:384:20:20:10\n"); |
| 3352 | else if (dut->ap_wan_metrics == 3) |
| 3353 | fprintf(f, "hs20_wan_metrics=01:2000:1000:20:20:10\n"); |
| 3354 | else if (dut->ap_wan_metrics == 4) |
| 3355 | fprintf(f, "hs20_wan_metrics=01:8000:1000:20:20:10\n"); |
| 3356 | else if (dut->ap_wan_metrics == 5) |
| 3357 | fprintf(f, "hs20_wan_metrics=01:9000:5000:20:20:10\n"); |
| 3358 | |
| 3359 | if (dut->ap_conn_capab == 1) { |
| 3360 | fprintf(f, "hs20_conn_capab=1:0:0\n"); |
| 3361 | fprintf(f, "hs20_conn_capab=6:20:1\n"); |
| 3362 | fprintf(f, "hs20_conn_capab=6:22:0\n"); |
| 3363 | fprintf(f, "hs20_conn_capab=6:80:1\n"); |
| 3364 | fprintf(f, "hs20_conn_capab=6:443:1\n"); |
| 3365 | fprintf(f, "hs20_conn_capab=6:1723:0\n"); |
| 3366 | fprintf(f, "hs20_conn_capab=6:5060:0\n"); |
| 3367 | fprintf(f, "hs20_conn_capab=17:500:1\n"); |
| 3368 | fprintf(f, "hs20_conn_capab=17:5060:0\n"); |
| 3369 | fprintf(f, "hs20_conn_capab=17:4500:1\n"); |
| 3370 | fprintf(f, "hs20_conn_capab=50:0:1\n"); |
| 3371 | } else if (dut->ap_conn_capab == 2) { |
| 3372 | fprintf(f, "hs20_conn_capab=6:80:1\n"); |
| 3373 | fprintf(f, "hs20_conn_capab=6:443:1\n"); |
| 3374 | fprintf(f, "hs20_conn_capab=17:5060:1\n"); |
| 3375 | fprintf(f, "hs20_conn_capab=6:5060:1\n"); |
| 3376 | } else if (dut->ap_conn_capab == 3) { |
| 3377 | fprintf(f, "hs20_conn_capab=6:80:1\n"); |
| 3378 | fprintf(f, "hs20_conn_capab=6:443:1\n"); |
| 3379 | } else if (dut->ap_conn_capab == 4) { |
| 3380 | fprintf(f, "hs20_conn_capab=6:80:1\n"); |
| 3381 | fprintf(f, "hs20_conn_capab=6:443:1\n"); |
| 3382 | fprintf(f, "hs20_conn_capab=6:5060:1\n"); |
| 3383 | fprintf(f, "hs20_conn_capab=17:5060:1\n"); |
| 3384 | } |
| 3385 | |
| 3386 | if (dut->ap_oper_class == 1) |
| 3387 | fprintf(f, "hs20_operating_class=51\n"); |
| 3388 | else if (dut->ap_oper_class == 2) |
| 3389 | fprintf(f, "hs20_operating_class=73\n"); |
| 3390 | else if (dut->ap_oper_class == 3) |
| 3391 | fprintf(f, "hs20_operating_class=5173\n"); |
| 3392 | |
| 3393 | if (dut->ap_osu_provider_list) { |
| 3394 | char *osu_friendly_name = NULL; |
| 3395 | char *osu_icon = NULL; |
| 3396 | char *osu_ssid = NULL; |
| 3397 | char *osu_nai = NULL; |
| 3398 | char *osu_service_desc = NULL; |
| 3399 | char *hs20_icon_filename = NULL; |
| 3400 | char hs20_icon[150]; |
| 3401 | int osu_method; |
| 3402 | |
| 3403 | hs20_icon_filename = "icon_red_zxx.png"; |
| 3404 | if (dut->ap_osu_icon_tag == 2) |
| 3405 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 3406 | snprintf(hs20_icon, sizeof(hs20_icon), |
| 3407 | "128:61:zxx:image/png:icon_red_zxx.png:/etc/ath/%s", |
| 3408 | hs20_icon_filename); |
| 3409 | osu_icon = "icon_red_zxx.png"; |
| 3410 | osu_ssid = "OSU"; |
| 3411 | osu_friendly_name = "kor:SP 빨강 테스트 전용"; |
| 3412 | osu_service_desc = "kor:테스트 목적으로 무료 서비스"; |
| 3413 | osu_method = (dut->ap_osu_method[0] == 0xFF) ? 1 : dut->ap_osu_method[0]; |
| 3414 | |
| 3415 | if (strlen(dut->ap_osu_server_uri[0])) |
| 3416 | fprintf(f, "osu_server_uri=%s\n", dut->ap_osu_server_uri[0]); |
| 3417 | else |
| 3418 | fprintf(f, "osu_server_uri=https://osu-server.r2-testbed.wi-fi.org/\n"); |
| 3419 | |
| 3420 | switch (dut->ap_osu_provider_list) { |
| 3421 | case 1: |
| 3422 | case 101: |
| 3423 | fprintf(f, "osu_friendly_name=eng:SP Red Test Only\n"); |
| 3424 | fprintf(f, "osu_service_desc=eng:Free service for test purpose\n"); |
| 3425 | hs20_icon_filename = "icon_red_eng.png"; |
| 3426 | if (dut->ap_osu_icon_tag == 2) |
| 3427 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 3428 | fprintf(f, "hs20_icon=160:76:eng:image/png:icon_red_eng.png:/etc/ath/%s\n", |
| 3429 | hs20_icon_filename); |
| 3430 | fprintf(f, "osu_icon=icon_red_eng.png\n"); |
| 3431 | break; |
| 3432 | case 2: |
| 3433 | case 102: |
| 3434 | fprintf(f, "osu_friendly_name=eng:Wireless Broadband Alliance\n"); |
| 3435 | fprintf(f, "osu_service_desc=eng:Free service for test purpose\n"); |
| 3436 | hs20_icon_filename = "icon_orange_zxx.png"; |
| 3437 | if (dut->ap_osu_icon_tag == 2) |
| 3438 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 3439 | snprintf(hs20_icon, sizeof(hs20_icon), |
| 3440 | "128:61:zxx:image/png:icon_orange_zxx.png:/etc/ath/%s", |
| 3441 | hs20_icon_filename); |
| 3442 | osu_icon = "icon_orange_zxx.png"; |
| 3443 | osu_friendly_name = "kor:와이어리스 브로드밴드 얼라이언스"; |
| 3444 | break; |
| 3445 | case 3: |
| 3446 | case 103: |
| 3447 | osu_friendly_name = "spa:SP Red Test Only"; |
| 3448 | osu_service_desc = "spa:Free service for test purpose"; |
| 3449 | break; |
| 3450 | case 4: |
| 3451 | case 104: |
| 3452 | fprintf(f, "osu_friendly_name=eng:SP Orange Test Only\n"); |
| 3453 | fprintf(f, "osu_service_desc=eng:Free service for test purpose\n"); |
| 3454 | hs20_icon_filename = "icon_orange_eng.png"; |
| 3455 | if (dut->ap_osu_icon_tag == 2) |
| 3456 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 3457 | fprintf(f, "hs20_icon=160:76:eng:image/png:icon_orange_eng.png:/etc/ath/%s\n", |
| 3458 | hs20_icon_filename); |
| 3459 | fprintf(f, "osu_icon=icon_orange_eng.png\n"); |
| 3460 | osu_friendly_name = "kor:SP 오렌지 테스트 전용"; |
| 3461 | |
| 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 5: |
| 3471 | case 105: |
| 3472 | fprintf(f, "osu_friendly_name=eng:SP Orange Test Only\n"); |
| 3473 | fprintf(f, "osu_service_desc=eng:Free service for test purpose\n"); |
| 3474 | osu_friendly_name = "kor:SP 오렌지 테스트 전용"; |
| 3475 | hs20_icon_filename = "icon_orange_zxx.png"; |
| 3476 | if (dut->ap_osu_icon_tag == 2) |
| 3477 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 3478 | snprintf(hs20_icon, sizeof(hs20_icon), |
| 3479 | "128:61:zxx:image/png:icon_orange_zxx.png:/etc/ath/%s", |
| 3480 | hs20_icon_filename); |
| 3481 | osu_icon = "icon_orange_zxx.png"; |
| 3482 | break; |
| 3483 | case 6: |
| 3484 | case 106: |
| 3485 | fprintf(f, "osu_friendly_name=eng:SP Green Test Only\n"); |
| 3486 | fprintf(f, "osu_friendly_name=kor:SP 초록 테스트 전용\n"); |
| 3487 | hs20_icon_filename = "icon_green_zxx.png"; |
| 3488 | if (dut->ap_osu_icon_tag == 2) |
| 3489 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 3490 | fprintf(f, "hs20_icon=128:61:zxx:image/png:icon_green_zxx.png:/etc/ath/%s\n", |
| 3491 | hs20_icon_filename); |
| 3492 | fprintf(f, "osu_icon=icon_green_zxx.png\n"); |
| 3493 | osu_method = (dut->ap_osu_method[0] == 0xFF) ? 0 : dut->ap_osu_method[0]; |
| 3494 | fprintf(f, "osu_method_list=%d\n", osu_method); |
| 3495 | |
| 3496 | if (strlen(dut->ap_osu_server_uri[1])) |
| 3497 | fprintf(f, "osu_server_uri=%s\n", dut->ap_osu_server_uri[1]); |
| 3498 | else |
| 3499 | fprintf(f, "osu_server_uri=https://osu-server.r2-testbed.wi-fi.org/\n"); |
| 3500 | fprintf(f, "osu_friendly_name=eng:SP Orange Test Only\n"); |
| 3501 | hs20_icon_filename = "icon_orange_zxx.png"; |
| 3502 | if (dut->ap_osu_icon_tag == 2) |
| 3503 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 3504 | snprintf(hs20_icon, sizeof(hs20_icon), |
| 3505 | "128:61:zxx:image/png:icon_orange_zxx.png:/etc/ath/%s", |
| 3506 | hs20_icon_filename); |
| 3507 | osu_icon = "icon_orange_zxx.png"; |
| 3508 | osu_friendly_name = "kor:SP 오렌지 테스트 전용"; |
| 3509 | osu_method = (dut->ap_osu_method[1] == 0xFF) ? 0 : dut->ap_osu_method[1]; |
| 3510 | osu_service_desc = NULL; |
| 3511 | break; |
| 3512 | case 7: |
| 3513 | case 107: |
| 3514 | fprintf(f, "osu_friendly_name=eng:SP Green Test Only\n"); |
| 3515 | fprintf(f, "osu_service_desc=eng:Free service for test purpose\n"); |
| 3516 | hs20_icon_filename = "icon_green_eng.png"; |
| 3517 | if (dut->ap_osu_icon_tag == 2) |
| 3518 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 3519 | fprintf(f, "hs20_icon=160:76:eng:image/png:icon_green_eng.png:/etc/ath/%s\n", |
| 3520 | hs20_icon_filename); |
| 3521 | fprintf(f, "osu_icon=icon_green_eng.png\n"); |
| 3522 | osu_friendly_name = "kor:SP 초록 테스트 전용"; |
| 3523 | |
| 3524 | hs20_icon_filename = "icon_green_zxx.png"; |
| 3525 | if (dut->ap_osu_icon_tag == 2) |
| 3526 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 3527 | snprintf(hs20_icon, sizeof(hs20_icon), |
| 3528 | "128:61:zxx:image/png:icon_green_zxx.png:/etc/ath/%s", |
| 3529 | hs20_icon_filename); |
| 3530 | osu_icon = "icon_green_zxx.png"; |
| 3531 | break; |
| 3532 | case 8: |
| 3533 | case 108: |
| 3534 | fprintf(f, "osu_friendly_name=eng:SP Red Test Only\n"); |
| 3535 | fprintf(f, "osu_service_desc=eng:Free service for test purpose\n"); |
| 3536 | osu_ssid = "OSU-Encrypted"; |
| 3537 | osu_nai = "anonymous@hotspot.net"; |
| 3538 | break; |
| 3539 | case 9: |
| 3540 | case 109: |
| 3541 | osu_ssid = "OSU-OSEN"; |
| 3542 | osu_nai = "test-anonymous@wi-fi.org"; |
| 3543 | osu_friendly_name = "eng:SP Orange Test Only"; |
| 3544 | hs20_icon_filename = "icon_orange_zxx.png"; |
| 3545 | if (dut->ap_osu_icon_tag == 2) |
| 3546 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 3547 | snprintf(hs20_icon, sizeof(hs20_icon), |
| 3548 | "128:61:zxx:image/png:icon_orange_zxx.png:/etc/ath/%s", |
| 3549 | hs20_icon_filename); |
| 3550 | osu_icon = "icon_orange_zxx.png"; |
| 3551 | osu_method = (dut->ap_osu_method[0] == 0xFF) ? 1 : dut->ap_osu_method[0]; |
| 3552 | osu_service_desc = NULL; |
| 3553 | break; |
| 3554 | default: |
| 3555 | break; |
| 3556 | } |
| 3557 | |
| 3558 | if (strlen(dut->ap_osu_ssid)) { |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 3559 | if (strcmp(dut->ap_tag_ssid[0], dut->ap_osu_ssid) && |
| 3560 | strcmp(dut->ap_tag_ssid[0], osu_ssid)) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3561 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 3562 | "OSU_SSID and " |
| 3563 | "WLAN_TAG2 SSID differ"); |
| 3564 | return -2; |
| 3565 | } |
| 3566 | fprintf(f, "osu_ssid=\"%s\"\n", dut->ap_osu_ssid); |
| 3567 | } else |
| 3568 | fprintf(f, "osu_ssid=\"%s\"\n", osu_ssid); |
| 3569 | |
| 3570 | |
| 3571 | if (osu_friendly_name) |
| 3572 | fprintf(f, "osu_friendly_name=%s\n", osu_friendly_name); |
| 3573 | |
| 3574 | if (osu_service_desc) |
| 3575 | fprintf(f, "osu_service_desc=%s\n", osu_service_desc); |
| 3576 | |
| 3577 | if (osu_nai) |
| 3578 | fprintf(f, "osu_nai=%s\n", osu_nai); |
| 3579 | |
| 3580 | fprintf(f, "hs20_icon=%s\n", hs20_icon); |
| 3581 | |
| 3582 | if (osu_icon) |
| 3583 | fprintf(f, "osu_icon=%s\n", osu_icon); |
| 3584 | |
| 3585 | if (dut->ap_osu_provider_list > 100) |
| 3586 | fprintf(f, "osu_method_list=0\n"); |
| 3587 | else |
| 3588 | fprintf(f, "osu_method_list=%d\n", osu_method); |
| 3589 | } |
| 3590 | |
| 3591 | return 0; |
| 3592 | } |
| 3593 | |
| 3594 | |
| 3595 | static void write_ap_roaming_cons(FILE *f, const char *list) |
| 3596 | { |
| 3597 | char *buf, *pos, *end; |
| 3598 | |
| 3599 | if (list == NULL || list[0] == '\0') |
| 3600 | return; |
| 3601 | |
| 3602 | buf = strdup(list); |
| 3603 | if (buf == NULL) |
| 3604 | return; |
| 3605 | |
| 3606 | pos = buf; |
| 3607 | while (pos && *pos) { |
| 3608 | end = strchr(pos, ';'); |
| 3609 | if (end) |
| 3610 | *end++ = '\0'; |
| 3611 | fprintf(f, "roaming_consortium=%s\n", pos); |
| 3612 | pos = end; |
| 3613 | } |
| 3614 | |
| 3615 | free(buf); |
| 3616 | } |
| 3617 | |
| 3618 | |
| 3619 | static int append_hostapd_conf_interworking(struct sigma_dut *dut, FILE *f) |
| 3620 | { |
| 3621 | int i; |
| 3622 | char buf[100], *temp; |
| 3623 | |
| 3624 | if (dut->ap_gas_cb_delay > 0) |
| 3625 | fprintf(f, "gas_comeback_delay=%d\n", |
| 3626 | dut->ap_gas_cb_delay); |
| 3627 | |
| 3628 | fprintf(f, "interworking=1\n" |
| 3629 | "access_network_type=%d\n" |
| 3630 | "internet=%d\n" |
| 3631 | "asra=0\n" |
| 3632 | "esr=0\n" |
| 3633 | "uesa=0\n" |
| 3634 | "venue_group=%d\n" |
| 3635 | "venue_type=%d\n", |
| 3636 | dut->ap_access_net_type, |
| 3637 | dut->ap_internet, |
| 3638 | dut->ap_venue_group, |
| 3639 | dut->ap_venue_type); |
| 3640 | if (dut->ap_hessid[0]) |
| 3641 | fprintf(f, "hessid=%s\n", dut->ap_hessid); |
| 3642 | |
| 3643 | write_ap_roaming_cons(f, dut->ap_roaming_cons); |
| 3644 | |
| 3645 | if (dut->ap_venue_name) { |
| 3646 | fprintf(f, "venue_name=P\"eng:Wi-Fi Alliance\\n2989 Copper Road\\nSanta Clara, CA 95051, USA\"\n"); |
| 3647 | fprintf(f, "venue_name=%s\n", ANQP_VENUE_NAME_1_CHI); |
| 3648 | } |
| 3649 | |
| 3650 | if (dut->ap_net_auth_type == 1) |
| 3651 | fprintf(f, "network_auth_type=00https://tandc-server.wi-fi.org\n"); |
| 3652 | else if (dut->ap_net_auth_type == 2) |
| 3653 | fprintf(f, "network_auth_type=01\n"); |
| 3654 | |
| 3655 | if (dut->ap_nai_realm_list == 1) { |
| 3656 | fprintf(f, "nai_realm=0,mail.example.com;cisco.com;wi-fi.org,21[2:4][5:7]\n"); |
| 3657 | fprintf(f, "nai_realm=0,wi-fi.org;example.com,13[5:6]\n"); |
| 3658 | } else if (dut->ap_nai_realm_list == 2) { |
| 3659 | fprintf(f, "nai_realm=0,wi-fi.org,21[2:4][5:7]\n"); |
| 3660 | } else if (dut->ap_nai_realm_list == 3) { |
| 3661 | fprintf(f, "nai_realm=0,cisco.com;wi-fi.org,21[2:4][5:7]\n"); |
| 3662 | fprintf(f, "nai_realm=0,wi-fi.org;example.com,13[5:6]\n"); |
| 3663 | } else if (dut->ap_nai_realm_list == 4) { |
| 3664 | fprintf(f, "nai_realm=0,mail.example.com,21[2:4][5:7],13[5:6]\n"); |
| 3665 | } else if (dut->ap_nai_realm_list == 5) { |
| 3666 | fprintf(f, "nai_realm=0,wi-fi.org;ruckuswireless.com,21[2:4][5:7]\n"); |
| 3667 | } else if (dut->ap_nai_realm_list == 6) { |
| 3668 | fprintf(f, "nai_realm=0,wi-fi.org;mail.example.com,21[2:4][5:7]\n"); |
| 3669 | } else if (dut->ap_nai_realm_list == 7) { |
| 3670 | fprintf(f, "nai_realm=0,wi-fi.org,13[5:6]\n"); |
| 3671 | fprintf(f, "nai_realm=0,wi-fi.org,21[2:4][5:7]\n"); |
| 3672 | } |
| 3673 | |
| 3674 | if (dut->ap_domain_name_list[0]) { |
| 3675 | fprintf(f, "domain_name=%s\n", |
| 3676 | dut->ap_domain_name_list); |
| 3677 | } |
| 3678 | |
| 3679 | if (dut->ap_ip_addr_type_avail == 1) { |
| 3680 | fprintf(f, "ipaddr_type_availability=0c\n"); |
| 3681 | } |
| 3682 | |
| 3683 | temp = buf; |
| 3684 | for (i = 0; dut->ap_plmn_mcc[i][0] && dut->ap_plmn_mnc[i][0]; |
| 3685 | i++) { |
| 3686 | if (i) |
| 3687 | *temp++ = ';'; |
| 3688 | |
| 3689 | snprintf(temp, |
| 3690 | sizeof(dut->ap_plmn_mcc[i]) + |
| 3691 | sizeof(dut->ap_plmn_mnc[i]) + 1, |
| 3692 | "%s,%s", |
| 3693 | dut->ap_plmn_mcc[i], |
| 3694 | dut->ap_plmn_mnc[i]); |
| 3695 | |
| 3696 | temp += strlen(dut->ap_plmn_mcc[i]) + |
| 3697 | strlen(dut->ap_plmn_mnc[i]) + 1; |
| 3698 | } |
| 3699 | if (i) |
| 3700 | fprintf(f, "anqp_3gpp_cell_net=%s\n", buf); |
| 3701 | |
| 3702 | if (dut->ap_qos_map_set == 1) |
| 3703 | fprintf(f, "qos_map_set=%s\n", QOS_MAP_SET_1); |
| 3704 | else if (dut->ap_qos_map_set == 2) |
| 3705 | fprintf(f, "qos_map_set=%s\n", QOS_MAP_SET_2); |
| 3706 | |
| 3707 | return 0; |
| 3708 | } |
| 3709 | |
| 3710 | |
| 3711 | static int ath_ap_append_hostapd_conf(struct sigma_dut *dut) |
| 3712 | { |
| 3713 | FILE *f; |
| 3714 | |
| 3715 | if (kill_process(dut, "(hostapd)", 1, SIGTERM) == 0 || |
| 3716 | system("killall hostapd") == 0) { |
| 3717 | int i; |
| 3718 | |
| 3719 | /* Wait some time to allow hostapd to complete cleanup before |
| 3720 | * starting a new process */ |
| 3721 | for (i = 0; i < 10; i++) { |
| 3722 | usleep(500000); |
| 3723 | if (system("pidof hostapd") != 0) |
| 3724 | break; |
| 3725 | } |
| 3726 | } |
| 3727 | |
| 3728 | f = fopen("/tmp/secath0", "a"); |
| 3729 | if (f == NULL) |
| 3730 | return -2; |
| 3731 | |
| 3732 | if (dut->ap_hs2 && append_hostapd_conf_hs2(dut, f)) { |
| 3733 | fclose(f); |
| 3734 | return -2; |
| 3735 | } |
| 3736 | |
| 3737 | if (dut->ap_interworking && append_hostapd_conf_interworking(dut, f)) { |
| 3738 | fclose(f); |
| 3739 | return -2; |
| 3740 | } |
| 3741 | |
| 3742 | fflush(f); |
| 3743 | fclose(f); |
| 3744 | return ath_ap_start_hostapd(dut); |
| 3745 | } |
| 3746 | |
| 3747 | |
| 3748 | static int ath_ap_start_hostapd(struct sigma_dut *dut) |
| 3749 | { |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 3750 | if (dut->ap_tag_key_mgmt[0] == AP2_OSEN) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3751 | run_system(dut, "hostapd -B /tmp/secath0 /tmp/secath1 -e /etc/wpa2/entropy"); |
| 3752 | else |
| 3753 | run_system(dut, "hostapd -B /tmp/secath0 -e /etc/wpa2/entropy"); |
| 3754 | |
| 3755 | return 0; |
| 3756 | } |
| 3757 | |
| 3758 | |
| 3759 | #define LE16(a) ((((a) & 0xff) << 8) | (((a) >> 8) & 0xff)) |
| 3760 | |
| 3761 | static int cmd_ath_ap_anqpserver_start(struct sigma_dut *dut) |
| 3762 | { |
| 3763 | FILE *f; |
| 3764 | int nai_realm = 0, domain_name = 0, oper_name = 0, venue_name = 0, |
| 3765 | wan_metrics = 0, conn_cap = 0, ipaddr_avail = 0, cell_net = 0; |
| 3766 | char buf[100]; |
| 3767 | int i; |
| 3768 | |
| 3769 | f = fopen("/root/anqpserver.conf", "w"); |
| 3770 | if (f == NULL) |
| 3771 | return -1; |
| 3772 | |
| 3773 | if (dut->ap_nai_realm_list == 1) { |
| 3774 | nai_realm = 1; |
| 3775 | 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"); |
| 3776 | } else if (dut->ap_nai_realm_list == 2) { |
| 3777 | nai_realm = 1; |
| 3778 | fprintf(f, "dyn_nai_home_realm=encoding=00realm=wi-fi.org;eap_method=0Dauth_id=05auth_val=06\n"); |
| 3779 | } else if (dut->ap_nai_realm_list == 3) { |
| 3780 | nai_realm = 1; |
| 3781 | 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"); |
| 3782 | } else if (dut->ap_nai_realm_list == 4) { |
| 3783 | nai_realm = 1; |
| 3784 | 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"); |
| 3785 | } else |
| 3786 | sigma_dut_print(dut, DUT_MSG_INFO, "not setting nai_realm"); |
| 3787 | |
| 3788 | if (dut->ap_domain_name_list[0]) { |
| 3789 | char *next, *start, *dnbuf, *dn1, *anqp_dn; |
| 3790 | int len, dn_len_max; |
| 3791 | dnbuf = strdup(dut->ap_domain_name_list); |
Pradeep Reddy POTTETI | 673d85c | 2016-07-26 19:08:07 +0530 | [diff] [blame] | 3792 | if (dnbuf == NULL) { |
| 3793 | fclose(f); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3794 | return 0; |
Pradeep Reddy POTTETI | 673d85c | 2016-07-26 19:08:07 +0530 | [diff] [blame] | 3795 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3796 | |
| 3797 | len = strlen(dnbuf); |
| 3798 | dn_len_max = 50 + len*2; |
| 3799 | anqp_dn = malloc(dn_len_max); |
| 3800 | if (anqp_dn == NULL) { |
| 3801 | free(dnbuf); |
Pradeep Reddy POTTETI | 673d85c | 2016-07-26 19:08:07 +0530 | [diff] [blame] | 3802 | fclose(f); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3803 | return -1; |
| 3804 | } |
| 3805 | start = dnbuf; |
| 3806 | dn1 = anqp_dn; |
| 3807 | while (start && *start) { |
| 3808 | char *hexstr; |
| 3809 | |
| 3810 | next = strchr(start, ','); |
| 3811 | if (next) |
| 3812 | *next++ = '\0'; |
| 3813 | |
| 3814 | len = strlen(start); |
vamsi krishna | 2e88130 | 2016-05-25 15:02:39 +0530 | [diff] [blame] | 3815 | hexstr = malloc(len * 2 + 1); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3816 | if (hexstr == NULL) { |
| 3817 | free(dnbuf); |
| 3818 | free(anqp_dn); |
Pradeep Reddy POTTETI | 673d85c | 2016-07-26 19:08:07 +0530 | [diff] [blame] | 3819 | fclose(f); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3820 | return -1; |
| 3821 | } |
| 3822 | ascii2hexstr(start, hexstr); |
| 3823 | snprintf(dn1, dn_len_max, "%02x%s", len, hexstr); |
| 3824 | free(hexstr); |
| 3825 | dn1 += 2 + len * 2; |
| 3826 | dn_len_max -= 2 + len * 2; |
| 3827 | start = next; |
| 3828 | } |
| 3829 | free(dnbuf); |
| 3830 | if (dut->ap_gas_cb_delay) { |
| 3831 | fprintf(f, "dyn_domain_name=0c01%04x%s", |
| 3832 | LE16((unsigned int) strlen(anqp_dn)), anqp_dn); |
| 3833 | domain_name = 1; |
| 3834 | } else |
| 3835 | fprintf(f, "domain_name=0c01%04x%s", |
| 3836 | LE16((unsigned int) strlen(anqp_dn)), anqp_dn); |
| 3837 | free(anqp_dn); |
| 3838 | } else |
| 3839 | sigma_dut_print(dut, DUT_MSG_INFO, "not setting domain_name"); |
| 3840 | |
| 3841 | sigma_dut_print(dut, DUT_MSG_INFO, "not setting roaming_consortium"); |
| 3842 | |
| 3843 | if (dut->ap_oper_name) { |
| 3844 | if (dut->ap_gas_cb_delay) { |
| 3845 | fprintf(f, "dyn_oper_friendly_name=" |
| 3846 | ANQP_HS20_OPERATOR_FRIENDLY_NAME_1 "\n"); |
| 3847 | oper_name = 1; |
| 3848 | } else |
| 3849 | fprintf(f, "oper_friendly_name=" |
| 3850 | ANQP_HS20_OPERATOR_FRIENDLY_NAME_1 "\n"); |
| 3851 | } else |
| 3852 | sigma_dut_print(dut, DUT_MSG_INFO, "not setting oper_name"); |
| 3853 | |
| 3854 | if (dut->ap_venue_name) { |
| 3855 | if (dut->ap_gas_cb_delay) { |
| 3856 | fprintf(f, "dyn_venue_name=" ANQP_VENUE_NAME_1 "\n"); |
| 3857 | venue_name = 1; |
| 3858 | } else |
| 3859 | fprintf(f, "venue_name=" ANQP_VENUE_NAME_1 "\n"); |
| 3860 | } else |
| 3861 | sigma_dut_print(dut, DUT_MSG_ERROR, "not setting venue_name"); |
| 3862 | |
| 3863 | if (dut->ap_wan_metrics) { |
| 3864 | if (dut->ap_gas_cb_delay) { |
| 3865 | fprintf(f, "dyn_wan_metrics=" ANQP_HS20_WAN_METRICS_1 "\n"); |
| 3866 | wan_metrics = 1; |
| 3867 | } else |
| 3868 | fprintf(f, "wan_metrics=" ANQP_HS20_WAN_METRICS_1 |
| 3869 | "\n"); |
| 3870 | } else |
| 3871 | sigma_dut_print(dut, DUT_MSG_ERROR, "not setting wan_metrics"); |
| 3872 | |
| 3873 | if (dut->ap_conn_capab) { |
| 3874 | if (dut->ap_gas_cb_delay) { |
| 3875 | fprintf(f, "dyn_conn_capability=" |
| 3876 | ANQP_HS20_CONNECTION_CAPABILITY_1 "\n"); |
| 3877 | conn_cap = 1; |
| 3878 | } else |
| 3879 | fprintf(f, "conn_capability=" |
| 3880 | ANQP_HS20_CONNECTION_CAPABILITY_1 "\n"); |
| 3881 | } else |
| 3882 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 3883 | "not setting conn_capability"); |
| 3884 | |
| 3885 | if (dut->ap_ip_addr_type_avail) { |
| 3886 | if (dut->ap_gas_cb_delay) { |
| 3887 | fprintf(f, "dyn_ipaddr_type=" ANQP_IP_ADDR_TYPE_1 |
| 3888 | "\n"); |
| 3889 | ipaddr_avail = 1; |
| 3890 | } else |
| 3891 | fprintf(f, "ipaddr_type=" ANQP_IP_ADDR_TYPE_1 "\n"); |
| 3892 | } else |
| 3893 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 3894 | "not setting ipaddr_type_avail"); |
| 3895 | |
| 3896 | for (i = 0; dut->ap_plmn_mcc[i][0] && dut->ap_plmn_mnc[i][0]; i++) { |
| 3897 | snprintf(buf + i * 6, sizeof(buf) - i * 6, "%c%c%c%c%c%c", |
| 3898 | dut->ap_plmn_mcc[i][1], |
| 3899 | dut->ap_plmn_mcc[i][0], |
| 3900 | dut->ap_plmn_mnc[i][2] == '\0' ? |
| 3901 | 'f' : dut->ap_plmn_mnc[i][2], |
| 3902 | dut->ap_plmn_mcc[i][2], |
| 3903 | dut->ap_plmn_mnc[i][1], |
| 3904 | dut->ap_plmn_mnc[i][0]); |
| 3905 | } |
| 3906 | if (i) { |
| 3907 | uint16_t ie_len = (i * 3) + 5; |
| 3908 | if (dut->ap_gas_cb_delay) { |
| 3909 | fprintf(f, "dyn_cell_net=0801"); |
| 3910 | cell_net = 1; |
| 3911 | } else |
| 3912 | fprintf(f, "cell_net=0801"); |
| 3913 | fprintf(f, "%04x", LE16(ie_len)); |
| 3914 | fprintf(f, "00"); /* version */ |
| 3915 | fprintf(f, "%02x", (i * 3) + 3); /* user data hdr length */ |
| 3916 | fprintf(f, "00"); /* plmn list */ |
| 3917 | fprintf(f, "%02x", (i * 3) + 1); /* length of plmn list */ |
| 3918 | fprintf(f, "%02x", i); /* number of plmns */ |
| 3919 | fprintf(f, "%s\n", buf); /* plmns */ |
| 3920 | } else |
| 3921 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 3922 | "not setting 3gpp_cellular_network"); |
| 3923 | |
| 3924 | if (nai_realm || domain_name || oper_name || venue_name || |
| 3925 | wan_metrics || conn_cap || ipaddr_avail || cell_net) { |
| 3926 | fprintf(f, "anqp_attach="); |
| 3927 | if (venue_name) |
| 3928 | fprintf(f, "00000104%4.4x", dut->ap_gas_cb_delay); |
| 3929 | if (nai_realm) |
| 3930 | fprintf(f, "00000107%4.4x", dut->ap_gas_cb_delay); |
| 3931 | if (cell_net) |
| 3932 | fprintf(f, "00000108%4.4x", dut->ap_gas_cb_delay); |
| 3933 | if (domain_name) |
| 3934 | fprintf(f, "0000010c%4.4x", dut->ap_gas_cb_delay); |
| 3935 | if (oper_name) |
| 3936 | fprintf(f, "00010003%4.4x", dut->ap_gas_cb_delay); |
| 3937 | if (wan_metrics) |
| 3938 | fprintf(f, "00010004%4.4x", dut->ap_gas_cb_delay); |
| 3939 | if (conn_cap) |
| 3940 | fprintf(f, "00010005%4.4x", dut->ap_gas_cb_delay); |
| 3941 | fprintf(f, "00010006%4.4x", dut->ap_gas_cb_delay); |
| 3942 | fprintf(f, "\n"); |
| 3943 | } |
| 3944 | |
| 3945 | fclose(f); |
| 3946 | |
| 3947 | run_system(dut, "anqpserver -i ath0 &"); |
| 3948 | if (!dut->ap_anqpserver_on) |
| 3949 | run_system(dut, "killall anqpserver"); |
| 3950 | |
| 3951 | return 1; |
| 3952 | } |
| 3953 | |
| 3954 | |
| 3955 | static void cmd_ath_ap_radio_config(struct sigma_dut *dut) |
| 3956 | { |
| 3957 | char buf[100]; |
| 3958 | |
| 3959 | run_system(dut, "cfg -a AP_STARTMODE=standard"); |
| 3960 | |
| 3961 | if (sigma_radio_ifname[0] && |
| 3962 | strcmp(sigma_radio_ifname[0], "wifi1") == 0) { |
| 3963 | run_system(dut, "cfg -a AP_RADIO_ID=1"); |
| 3964 | switch (dut->ap_mode) { |
| 3965 | case AP_11g: |
| 3966 | run_system(dut, "cfg -a AP_CHMODE_2=11G"); |
| 3967 | break; |
| 3968 | case AP_11b: |
| 3969 | run_system(dut, "cfg -a AP_CHMODE_2=11B"); |
| 3970 | break; |
| 3971 | case AP_11ng: |
| 3972 | run_system(dut, "cfg -a AP_CHMODE_2=11NGHT20"); |
| 3973 | break; |
| 3974 | case AP_11a: |
| 3975 | run_system(dut, "cfg -a AP_CHMODE_2=11A"); |
| 3976 | break; |
| 3977 | case AP_11na: |
| 3978 | run_system(dut, "cfg -a AP_CHMODE_2=11NAHT20"); |
| 3979 | break; |
| 3980 | case AP_11ac: |
| 3981 | run_system(dut, "cfg -a AP_CHMODE_2=11ACVHT80"); |
| 3982 | break; |
| 3983 | default: |
| 3984 | run_system(dut, "cfg -a AP_CHMODE_2=11ACVHT80"); |
| 3985 | break; |
| 3986 | } |
| 3987 | |
| 3988 | switch (dut->ap_rx_streams) { |
| 3989 | case 1: |
| 3990 | run_system(dut, "cfg -a RX_CHAINMASK_2=1"); |
| 3991 | break; |
| 3992 | case 2: |
| 3993 | run_system(dut, "cfg -a RX_CHAINMASK_2=3"); |
| 3994 | break; |
| 3995 | case 3: |
| 3996 | run_system(dut, "cfg -a RX_CHAINMASK_2=7"); |
| 3997 | break; |
| 3998 | } |
| 3999 | |
| 4000 | switch (dut->ap_tx_streams) { |
| 4001 | case 1: |
| 4002 | run_system(dut, "cfg -a TX_CHAINMASK_2=1"); |
| 4003 | break; |
| 4004 | case 2: |
| 4005 | run_system(dut, "cfg -a TX_CHAINMASK_2=3"); |
| 4006 | break; |
| 4007 | case 3: |
| 4008 | run_system(dut, "cfg -a TX_CHAINMASK_2=7"); |
| 4009 | break; |
| 4010 | } |
| 4011 | |
| 4012 | switch (dut->ap_chwidth) { |
| 4013 | case AP_20: |
| 4014 | run_system(dut, "cfg -a AP_CHMODE_2=11ACVHT20"); |
| 4015 | break; |
| 4016 | case AP_40: |
| 4017 | run_system(dut, "cfg -a AP_CHMODE_2=11ACVHT40"); |
| 4018 | break; |
| 4019 | case AP_80: |
| 4020 | run_system(dut, "cfg -a AP_CHMODE_2=11ACVHT80"); |
| 4021 | break; |
| 4022 | case AP_160: |
| 4023 | case AP_AUTO: |
| 4024 | default: |
| 4025 | run_system(dut, "cfg -a AP_CHMODE_2=11ACVHT80"); |
| 4026 | break; |
| 4027 | } |
| 4028 | |
| 4029 | if (dut->ap_tx_stbc) { |
| 4030 | run_system(dut, "cfg -a TX_STBC_2=1"); |
| 4031 | } |
| 4032 | |
| 4033 | snprintf(buf, sizeof(buf), "cfg -a AP_PRIMARY_CH_2=%d", |
| 4034 | dut->ap_channel); |
| 4035 | |
| 4036 | if (dut->ap_is_dual) { |
| 4037 | switch (dut->ap_mode_1) { |
| 4038 | case AP_11g: |
| 4039 | run_system(dut, "cfg -a AP_CHMODE=11G"); |
| 4040 | break; |
| 4041 | case AP_11b: |
| 4042 | run_system(dut, "cfg -a AP_CHMODE=11B"); |
| 4043 | break; |
| 4044 | case AP_11ng: |
| 4045 | run_system(dut, "cfg -a AP_CHMODE=11NGHT20"); |
| 4046 | break; |
| 4047 | case AP_11a: |
| 4048 | run_system(dut, "cfg -a AP_CHMODE=11A"); |
| 4049 | break; |
| 4050 | case AP_11na: |
| 4051 | run_system(dut, "cfg -a AP_CHMODE=11NAHT20"); |
| 4052 | break; |
| 4053 | case AP_11ac: |
| 4054 | run_system(dut, "cfg -a AP_CHMODE=11ACVHT80"); |
| 4055 | break; |
| 4056 | default: |
| 4057 | run_system(dut, "cfg -a AP_CHMODE=11NGHT20"); |
| 4058 | break; |
| 4059 | } |
| 4060 | snprintf(buf, sizeof(buf), "cfg -a AP_PRIMARY_CH=%d", |
| 4061 | dut->ap_channel_1); |
| 4062 | } |
| 4063 | run_system(dut, buf); |
| 4064 | } else { |
| 4065 | run_system(dut, "cfg -a AP_RADIO_ID=0"); |
| 4066 | switch (dut->ap_mode) { |
| 4067 | case AP_11g: |
| 4068 | run_system(dut, "cfg -a AP_CHMODE=11G"); |
| 4069 | break; |
| 4070 | case AP_11b: |
| 4071 | run_system(dut, "cfg -a AP_CHMODE=11B"); |
| 4072 | break; |
| 4073 | case AP_11ng: |
| 4074 | run_system(dut, "cfg -a AP_CHMODE=11NGHT20"); |
| 4075 | break; |
| 4076 | case AP_11a: |
| 4077 | run_system(dut, "cfg -a AP_CHMODE=11A"); |
| 4078 | break; |
| 4079 | case AP_11na: |
| 4080 | run_system(dut, "cfg -a AP_CHMODE=11NAHT20"); |
| 4081 | break; |
| 4082 | case AP_11ac: |
| 4083 | run_system(dut, "cfg -a AP_CHMODE=11ACVHT80"); |
| 4084 | break; |
| 4085 | default: |
| 4086 | run_system(dut, "cfg -a AP_CHMODE=11NGHT20"); |
| 4087 | break; |
| 4088 | } |
| 4089 | snprintf(buf, sizeof(buf), "cfg -a AP_PRIMARY_CH=%d", |
| 4090 | dut->ap_channel); |
| 4091 | run_system(dut, buf); |
| 4092 | } |
| 4093 | |
| 4094 | if (dut->ap_sgi80 == 1) { |
| 4095 | run_system(dut, "cfg -a SHORTGI=1"); |
| 4096 | run_system(dut, "cfg -a SHORTGI_2=1"); |
| 4097 | } else if (dut->ap_sgi80 == 0) { |
| 4098 | run_system(dut, "cfg -a SHORTGI=0"); |
| 4099 | run_system(dut, "cfg -a SHORTGI_2=0"); |
| 4100 | } |
| 4101 | |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 4102 | if (dut->ap_ldpc == VALUE_ENABLED) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4103 | run_system(dut, "cfg -a LDPC=1"); |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 4104 | else if (dut->ap_ldpc == VALUE_DISABLED) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4105 | run_system(dut, "cfg -a LDPC=0"); |
| 4106 | } |
| 4107 | |
| 4108 | |
| 4109 | void ath_disable_txbf(struct sigma_dut *dut, const char *intf) |
| 4110 | { |
| 4111 | char buf[50]; |
| 4112 | |
| 4113 | snprintf(buf, sizeof(buf), "iwpriv %s vhtsubfee 0", intf); |
| 4114 | if (system(buf) != 0) |
| 4115 | sigma_dut_print(dut, DUT_MSG_ERROR, "iwpriv vhtsubfee failed"); |
| 4116 | |
| 4117 | snprintf(buf, sizeof(buf), "iwpriv %s vhtsubfer 0", intf); |
| 4118 | if (system(buf) != 0) |
| 4119 | sigma_dut_print(dut, DUT_MSG_ERROR, "iwpriv vhtsubfer failed"); |
| 4120 | |
| 4121 | snprintf(buf, sizeof(buf), "iwpriv %s vhtmubfee 0", intf); |
| 4122 | if (system(buf) != 0) |
| 4123 | sigma_dut_print(dut, DUT_MSG_ERROR, "iwpriv vhtmubfee failed"); |
| 4124 | |
| 4125 | snprintf(buf, sizeof(buf), "iwpriv %s vhtmubfer 0", intf); |
| 4126 | if (system(buf) != 0) |
| 4127 | sigma_dut_print(dut, DUT_MSG_ERROR, "iwpriv vhtmubfer failed"); |
| 4128 | } |
| 4129 | |
| 4130 | |
Adil Saeed Musthafa | 05ec744 | 2017-04-10 23:13:35 -0700 | [diff] [blame] | 4131 | static void ath_set_assoc_disallow(struct sigma_dut *dut, const char *ifname, |
| 4132 | const char *val) |
| 4133 | { |
| 4134 | if (strcasecmp(val, "enable") == 0) { |
| 4135 | run_system_wrapper(dut, "iwpriv %s mbo_asoc_dis 1", ifname); |
| 4136 | } else if (strcasecmp(val, "disable") == 0) { |
| 4137 | run_system_wrapper(dut, "iwpriv %s mbo_asoc_dis 0", ifname); |
| 4138 | } else { |
| 4139 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4140 | "Unsupported assoc_disallow"); |
| 4141 | } |
| 4142 | } |
| 4143 | |
| 4144 | |
Adil Saeed Musthafa | 6906372 | 2017-04-10 23:13:40 -0700 | [diff] [blame] | 4145 | static void apply_mbo_pref_ap_list(struct sigma_dut *dut) |
| 4146 | { |
| 4147 | int i; |
| 4148 | int least_pref = 1 << 8; |
| 4149 | char ifname[20]; |
| 4150 | uint8_t self_mac[ETH_ALEN]; |
| 4151 | char buf[200]; |
| 4152 | int ap_ne_class, ap_ne_pref, ap_ne_op_ch; |
| 4153 | |
| 4154 | get_if_name(dut, ifname, sizeof(ifname), 1); |
| 4155 | get_hwaddr(ifname, self_mac); |
| 4156 | |
| 4157 | /* Clear off */ |
| 4158 | snprintf(buf, sizeof(buf), |
| 4159 | "wifitool %s setbssidpref 00:00:00:00:00:00 0 0 0", |
| 4160 | ifname); |
| 4161 | run_system(dut, buf); |
| 4162 | |
| 4163 | /* Find the least preference number */ |
| 4164 | for (i = 0; i < dut->mbo_pref_ap_cnt; i++) { |
| 4165 | unsigned char *mac_addr = dut->mbo_pref_aps[i].mac_addr; |
| 4166 | |
| 4167 | ap_ne_class = 1; |
| 4168 | ap_ne_pref = 255; |
| 4169 | ap_ne_op_ch = 1; |
| 4170 | if (dut->mbo_pref_aps[i].ap_ne_pref != -1) |
| 4171 | ap_ne_pref = dut->mbo_pref_aps[i].ap_ne_pref; |
| 4172 | if (dut->mbo_pref_aps[i].ap_ne_class != -1) |
| 4173 | ap_ne_class = dut->mbo_pref_aps[i].ap_ne_class; |
| 4174 | if (dut->mbo_pref_aps[i].ap_ne_op_ch != -1) |
| 4175 | ap_ne_op_ch = dut->mbo_pref_aps[i].ap_ne_op_ch; |
| 4176 | |
| 4177 | if (ap_ne_pref < least_pref) |
| 4178 | least_pref = ap_ne_pref; |
| 4179 | snprintf(buf, sizeof(buf), |
| 4180 | "wifitool %s setbssidpref %02x:%02x:%02x:%02x:%02x:%02x %d %d %d", |
| 4181 | ifname, mac_addr[0], mac_addr[1], mac_addr[2], |
| 4182 | mac_addr[3], mac_addr[4], mac_addr[5], |
| 4183 | ap_ne_pref, ap_ne_class, ap_ne_op_ch); |
| 4184 | run_system(dut, buf); |
| 4185 | } |
| 4186 | |
| 4187 | /* Now add the self AP Address */ |
| 4188 | if (dut->mbo_self_ap_tuple.ap_ne_class == -1) { |
| 4189 | if (dut->ap_channel <= 11) |
| 4190 | ap_ne_class = 81; |
| 4191 | else |
| 4192 | ap_ne_class = 115; |
| 4193 | } else { |
| 4194 | ap_ne_class = dut->mbo_self_ap_tuple.ap_ne_class; |
| 4195 | } |
| 4196 | |
| 4197 | if (dut->mbo_self_ap_tuple.ap_ne_op_ch == -1) |
| 4198 | ap_ne_op_ch = dut->ap_channel; |
| 4199 | else |
| 4200 | ap_ne_op_ch = dut->mbo_self_ap_tuple.ap_ne_op_ch; |
| 4201 | |
| 4202 | if (dut->mbo_self_ap_tuple.ap_ne_pref == -1) |
| 4203 | ap_ne_pref = least_pref - 1; |
| 4204 | else |
| 4205 | ap_ne_pref = dut->mbo_self_ap_tuple.ap_ne_pref; |
| 4206 | |
| 4207 | snprintf(buf, sizeof(buf), |
| 4208 | "wifitool %s setbssidpref %02x:%02x:%02x:%02x:%02x:%02x %d %d %d", |
| 4209 | ifname, self_mac[0], self_mac[1], self_mac[2], |
| 4210 | self_mac[3], self_mac[4], self_mac[5], |
| 4211 | ap_ne_pref, |
| 4212 | ap_ne_class, |
| 4213 | ap_ne_op_ch); |
| 4214 | run_system(dut, buf); |
| 4215 | } |
| 4216 | |
| 4217 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4218 | static void ath_ap_set_params(struct sigma_dut *dut) |
| 4219 | { |
| 4220 | const char *basedev = "wifi1"; |
priyadharshini gowthaman | e161746 | 2017-04-25 12:03:59 -0700 | [diff] [blame] | 4221 | const char *ifname = get_main_ifname(); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4222 | int i; |
priyadharshini gowthaman | 8e26ff4 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 4223 | char buf[300]; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4224 | |
priyadharshini gowthaman | e161746 | 2017-04-25 12:03:59 -0700 | [diff] [blame] | 4225 | if (sigma_radio_ifname[0]) |
| 4226 | basedev = sigma_radio_ifname[0]; |
| 4227 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4228 | if (dut->ap_countrycode[0]) { |
| 4229 | snprintf(buf, sizeof(buf), "iwpriv %s setCountry %s", |
| 4230 | basedev, dut->ap_countrycode); |
| 4231 | if (system(buf) != 0) { |
| 4232 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4233 | "iwpriv setCountry failed"); |
| 4234 | } |
| 4235 | sigma_dut_print(dut, DUT_MSG_INFO, "Set countrycode"); |
| 4236 | } |
| 4237 | |
| 4238 | for (i = 0; i < NUM_AP_AC; i++) { |
| 4239 | if (dut->ap_qos[i].ac) { |
| 4240 | snprintf(buf, sizeof(buf), "iwpriv %s cwmin %d 0 %d", |
| 4241 | ifname, i, dut->ap_qos[i].cwmin); |
| 4242 | if (system(buf) != 0) { |
| 4243 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4244 | "iwpriv cwmin failed"); |
| 4245 | } |
| 4246 | |
| 4247 | snprintf(buf, sizeof(buf), "iwpriv %s cwmax %d 0 %d", |
| 4248 | ifname, i, dut->ap_qos[i].cwmax); |
| 4249 | if (system(buf) != 0) { |
| 4250 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4251 | "iwpriv cwmax failed"); |
| 4252 | } |
| 4253 | |
| 4254 | snprintf(buf, sizeof(buf), "iwpriv %s aifs %d 0 %d", |
| 4255 | ifname, i, dut->ap_qos[i].aifs); |
| 4256 | if (system(buf) != 0) { |
| 4257 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4258 | "iwpriv aifs failed"); |
| 4259 | } |
| 4260 | |
| 4261 | snprintf(buf, sizeof(buf), |
| 4262 | "iwpriv %s txoplimit %d 0 %d", |
| 4263 | ifname, i, dut->ap_qos[i].txop); |
| 4264 | if (system(buf) != 0) { |
| 4265 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4266 | "iwpriv txoplimit failed"); |
| 4267 | } |
| 4268 | |
| 4269 | snprintf(buf, sizeof(buf), "iwpriv %s acm %d 0 %d", |
| 4270 | ifname, i, dut->ap_qos[i].acm); |
| 4271 | if (system(buf) != 0) { |
| 4272 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4273 | "iwpriv acm failed"); |
| 4274 | } |
| 4275 | } |
| 4276 | } |
| 4277 | |
| 4278 | for (i = 0; i < NUM_AP_AC; i++) { |
| 4279 | if (dut->ap_sta_qos[i].ac) { |
| 4280 | snprintf(buf, sizeof(buf), "iwpriv %s cwmin %d 1 %d", |
| 4281 | ifname, i, dut->ap_sta_qos[i].cwmin); |
| 4282 | if (system(buf) != 0) { |
| 4283 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4284 | "iwpriv cwmin failed"); |
| 4285 | } |
| 4286 | |
| 4287 | snprintf(buf, sizeof(buf), "iwpriv %s cwmax %d 1 %d", |
| 4288 | ifname, i, dut->ap_sta_qos[i].cwmax); |
| 4289 | if (system(buf) != 0) { |
| 4290 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4291 | "iwpriv cwmax failed"); |
| 4292 | } |
| 4293 | |
| 4294 | snprintf(buf, sizeof(buf), "iwpriv %s aifs %d 1 %d", |
| 4295 | ifname, i, dut->ap_sta_qos[i].aifs); |
| 4296 | if (system(buf) != 0) { |
| 4297 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4298 | "iwpriv aifs failed"); |
| 4299 | } |
| 4300 | |
| 4301 | snprintf(buf, sizeof(buf), |
| 4302 | "iwpriv %s txoplimit %d 1 %d", |
| 4303 | ifname, i, dut->ap_sta_qos[i].txop); |
| 4304 | if (system(buf) != 0) { |
| 4305 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4306 | "iwpriv txoplimit failed"); |
| 4307 | } |
| 4308 | |
| 4309 | snprintf(buf, sizeof(buf), "iwpriv %s acm %d 1 %d", |
| 4310 | ifname, i, dut->ap_sta_qos[i].acm); |
| 4311 | if (system(buf) != 0) { |
| 4312 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4313 | "iwpriv acm failed"); |
| 4314 | } |
| 4315 | } |
| 4316 | } |
| 4317 | |
| 4318 | if (dut->ap_disable_protection == 1) { |
| 4319 | snprintf(buf, sizeof(buf), "iwpriv %s enablertscts 0", ifname); |
| 4320 | if (system(buf) != 0) { |
| 4321 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4322 | "iwpriv enablertscts failed"); |
| 4323 | } |
| 4324 | sigma_dut_print(dut, DUT_MSG_INFO, "Disabled rtscts"); |
| 4325 | } |
| 4326 | |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 4327 | if (dut->ap_ldpc == VALUE_ENABLED) { |
Sarvepalli, Rajesh Babu | 580572a | 2016-11-29 22:07:14 +0530 | [diff] [blame] | 4328 | snprintf(buf, sizeof(buf), "iwpriv %s ldpc 3", ifname); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4329 | if (system(buf) != 0) { |
| 4330 | sigma_dut_print(dut, DUT_MSG_ERROR, |
priyadharshini gowthaman | 15b299d | 2017-04-20 12:10:45 -0700 | [diff] [blame] | 4331 | "iwpriv ldpc 3 failed"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4332 | } |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 4333 | } else if (dut->ap_ldpc == VALUE_DISABLED) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4334 | snprintf(buf, sizeof(buf), "iwpriv %s ldpc 0", ifname); |
| 4335 | if (system(buf) != 0) { |
| 4336 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4337 | "iwpriv ldpc 0 failed"); |
| 4338 | } |
| 4339 | } |
| 4340 | |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 4341 | if (dut->ap_ampdu == VALUE_ENABLED) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4342 | snprintf(buf, sizeof(buf), "iwpriv %s ampdu 1", ifname); |
| 4343 | if (system(buf) != 0) { |
| 4344 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4345 | "iwpriv ampdu 1 failed"); |
| 4346 | } |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 4347 | } else if (dut->ap_ampdu == VALUE_DISABLED) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4348 | snprintf(buf, sizeof(buf), "iwpriv %s ampdu 0", ifname); |
| 4349 | if (system(buf) != 0) { |
| 4350 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4351 | "iwpriv ampdu 0 failed"); |
| 4352 | } |
| 4353 | } |
| 4354 | |
| 4355 | if (dut->ap_ampdu_exp) { |
| 4356 | if (dut->program == PROGRAM_VHT) { |
| 4357 | snprintf(buf, sizeof(buf), "iwpriv %s vhtmaxampdu %d", |
| 4358 | ifname, dut->ap_ampdu_exp); |
| 4359 | if (system(buf) != 0) { |
| 4360 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4361 | "iwpriv vhtmaxampdu failed"); |
| 4362 | } |
| 4363 | } else { |
| 4364 | /* 11N */ |
| 4365 | snprintf(buf, sizeof(buf), "iwpriv %s maxampdu %d", |
| 4366 | ifname, dut->ap_ampdu_exp); |
| 4367 | if (system(buf) != 0) { |
| 4368 | sigma_dut_print(dut, DUT_MSG_ERROR, "iwpriv maxampdu failed"); |
| 4369 | } |
| 4370 | } |
| 4371 | } |
| 4372 | |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 4373 | if (dut->ap_noack == VALUE_ENABLED) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4374 | snprintf(buf, sizeof(buf), "iwpriv %s noackpolicy 0 0 1", ifname); |
| 4375 | if (system(buf) != 0) { |
| 4376 | sigma_dut_print(dut, DUT_MSG_ERROR, "iwpriv noackpolicy 0 0 1 failed"); |
| 4377 | } |
| 4378 | snprintf(buf, sizeof(buf), "iwpriv %s noackpolicy 1 0 1", ifname); |
| 4379 | if (system(buf) != 0) { |
| 4380 | sigma_dut_print(dut, DUT_MSG_ERROR, "iwpriv noackpolicy 1 0 1 failed"); |
| 4381 | } |
| 4382 | snprintf(buf, sizeof(buf), "iwpriv %s noackpolicy 2 0 1", ifname); |
| 4383 | if (system(buf) != 0) { |
| 4384 | sigma_dut_print(dut, DUT_MSG_ERROR, "iwpriv noackpolicy 2 0 1 failed"); |
| 4385 | } |
| 4386 | snprintf(buf, sizeof(buf), "iwpriv %s noackpolicy 3 0 1", ifname); |
| 4387 | if (system(buf) != 0) { |
| 4388 | sigma_dut_print(dut, DUT_MSG_ERROR, "iwpriv noackpolicy 3 0 1 failed"); |
| 4389 | } |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 4390 | } else if (dut->ap_noack == VALUE_DISABLED) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4391 | snprintf(buf, sizeof(buf), "iwpriv %s noackpolicy 0 0 0", ifname); |
| 4392 | if (system(buf) != 0) { |
| 4393 | sigma_dut_print(dut, DUT_MSG_ERROR, "iwpriv noackpolicy 0 0 0 failed"); |
| 4394 | } |
| 4395 | snprintf(buf, sizeof(buf), "iwpriv %s noackpolicy 1 0 0", ifname); |
| 4396 | if (system(buf) != 0) { |
| 4397 | sigma_dut_print(dut, DUT_MSG_ERROR, "iwpriv noackpolicy 1 0 0 failed"); |
| 4398 | } |
| 4399 | snprintf(buf, sizeof(buf), "iwpriv %s noackpolicy 2 0 0", ifname); |
| 4400 | if (system(buf) != 0) { |
| 4401 | sigma_dut_print(dut, DUT_MSG_ERROR, "iwpriv noackpolicy 2 0 0 failed"); |
| 4402 | } |
| 4403 | snprintf(buf, sizeof(buf), "iwpriv %s noackpolicy 3 0 0", ifname); |
| 4404 | if (system(buf) != 0) { |
| 4405 | sigma_dut_print(dut, DUT_MSG_ERROR, "iwpriv noackpolicy 3 0 0 failed"); |
| 4406 | } |
| 4407 | } |
| 4408 | |
| 4409 | if (dut->device_type == AP_testbed && dut->ap_vhtmcs_map) { |
| 4410 | snprintf(buf, sizeof(buf), "iwpriv %s vht_mcsmap 0x%04x", |
| 4411 | ifname, dut->ap_vhtmcs_map); |
| 4412 | if (system(buf) != 0) { |
| 4413 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4414 | "iwpriv vht_mcsmap failed"); |
| 4415 | } |
| 4416 | } |
| 4417 | |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 4418 | if (dut->ap_amsdu == VALUE_ENABLED) { |
Sunil Dutt | 27ec7f6 | 2017-09-14 18:22:59 +0300 | [diff] [blame] | 4419 | snprintf(buf, sizeof(buf), "iwpriv %s amsdu 2", ifname); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4420 | if (system(buf) != 0) { |
Sunil Dutt | 27ec7f6 | 2017-09-14 18:22:59 +0300 | [diff] [blame] | 4421 | sigma_dut_print(dut, DUT_MSG_ERROR, "iwpriv amsdu 2 failed"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4422 | } |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 4423 | } else if (dut->ap_amsdu == VALUE_DISABLED) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4424 | snprintf(buf, sizeof(buf), "iwpriv %s amsdu 1", ifname); |
| 4425 | if (system(buf) != 0) { |
| 4426 | sigma_dut_print(dut, DUT_MSG_ERROR, "iwpriv amsdu 1 failed"); |
| 4427 | } |
| 4428 | } |
| 4429 | |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 4430 | if (dut->ap_rx_amsdu == VALUE_ENABLED) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4431 | snprintf(buf, sizeof(buf), "iwpriv wifi1 rx_amsdu 1"); |
| 4432 | if (system(buf) != 0) { |
| 4433 | sigma_dut_print(dut, DUT_MSG_ERROR, "iwpriv rx_amsdu 1 failed"); |
| 4434 | } |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 4435 | } else if (dut->ap_rx_amsdu == VALUE_DISABLED) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4436 | snprintf(buf, sizeof(buf), "iwpriv wifi1 rx_amsdu 0"); |
| 4437 | if (system(buf) != 0) { |
| 4438 | sigma_dut_print(dut, DUT_MSG_ERROR, "iwpriv rx_amsdu 0 failed"); |
| 4439 | } |
| 4440 | } |
| 4441 | |
| 4442 | /* Command sequence to generate single VHT AMSDU and MPDU */ |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 4443 | if (dut->ap_addba_reject != VALUE_NOT_SET && |
| 4444 | dut->ap_ampdu == VALUE_DISABLED && |
| 4445 | dut->ap_amsdu == VALUE_ENABLED) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4446 | snprintf(buf, sizeof(buf), "iwpriv %s setaddbaoper 1", ifname); |
| 4447 | if (system(buf) != 0) { |
| 4448 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4449 | "iwpriv setaddbaoper 1 failed"); |
| 4450 | } |
| 4451 | |
| 4452 | snprintf(buf, sizeof(buf), |
| 4453 | "wifitool %s senddelba 1 0 1 4", ifname); |
| 4454 | if (system(buf) != 0) { |
| 4455 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4456 | "wifitool senddelba failed"); |
| 4457 | } |
| 4458 | |
| 4459 | snprintf(buf, sizeof(buf), "wifitool %s sendsingleamsdu 1 0", |
| 4460 | ifname); |
| 4461 | if (system(buf) != 0) { |
| 4462 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4463 | "wifitool sendsingleamsdu failed"); |
| 4464 | } |
| 4465 | |
| 4466 | snprintf(buf, sizeof(buf), "iwpriv %s amsdu 10", ifname); |
| 4467 | if (system(buf) != 0) { |
| 4468 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4469 | "iwpriv amsdu failed"); |
| 4470 | } |
| 4471 | } |
| 4472 | |
| 4473 | if (dut->ap_mode == AP_11ac) { |
| 4474 | int chwidth, nss; |
| 4475 | |
| 4476 | switch (dut->ap_chwidth) { |
| 4477 | case AP_20: |
| 4478 | chwidth = 0; |
| 4479 | break; |
| 4480 | case AP_40: |
| 4481 | chwidth = 1; |
| 4482 | break; |
| 4483 | case AP_80: |
| 4484 | chwidth = 2; |
| 4485 | break; |
| 4486 | case AP_160: |
| 4487 | chwidth = 3; |
| 4488 | break; |
| 4489 | default: |
| 4490 | chwidth = 0; |
| 4491 | break; |
| 4492 | } |
| 4493 | |
| 4494 | switch (dut->ap_tx_streams) { |
| 4495 | case 1: |
| 4496 | nss = 1; |
| 4497 | break; |
| 4498 | case 2: |
| 4499 | nss = 2; |
| 4500 | break; |
| 4501 | case 3: |
| 4502 | nss = 3; |
| 4503 | break; |
| 4504 | case 4: |
| 4505 | nss = 4; |
| 4506 | break; |
| 4507 | default: |
| 4508 | nss = 3; |
| 4509 | break; |
| 4510 | } |
| 4511 | |
| 4512 | if (dut->ap_fixed_rate) { |
| 4513 | if (nss == 4) |
| 4514 | ath_disable_txbf(dut, ifname); |
| 4515 | |
| 4516 | /* Set the nss */ |
| 4517 | snprintf(buf, sizeof(buf), "iwpriv %s nss %d", |
| 4518 | ifname, nss); |
| 4519 | if (system(buf) != 0) { |
| 4520 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4521 | "iwpriv nss failed"); |
| 4522 | } |
| 4523 | |
| 4524 | /* Set the channel width */ |
| 4525 | snprintf(buf, sizeof(buf), "iwpriv %s chwidth %d", |
| 4526 | ifname, chwidth); |
| 4527 | if (system(buf) != 0) { |
| 4528 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4529 | "iwpriv chwidth failed"); |
| 4530 | } |
| 4531 | |
| 4532 | /* Set the VHT MCS */ |
| 4533 | snprintf(buf, sizeof(buf), "iwpriv %s vhtmcs %d", |
| 4534 | ifname, dut->ap_mcs); |
| 4535 | if (system(buf) != 0) { |
| 4536 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4537 | "iwpriv vhtmcs failed"); |
| 4538 | } |
| 4539 | } |
| 4540 | } |
| 4541 | |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 4542 | if (dut->ap_dyn_bw_sig == VALUE_ENABLED) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4543 | snprintf(buf, sizeof(buf), "iwpriv %s cwmenable 1", ifname); |
| 4544 | if (system(buf) != 0) { |
| 4545 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4546 | "iwpriv cwmenable 1 failed"); |
| 4547 | } |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 4548 | } else if (dut->ap_dyn_bw_sig == VALUE_DISABLED) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4549 | snprintf(buf, sizeof(buf), "iwpriv %s cwmenable 0", ifname); |
| 4550 | if (system(buf) != 0) { |
| 4551 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4552 | "iwpriv cwmenable 0 failed"); |
| 4553 | } |
| 4554 | } |
| 4555 | |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 4556 | if (dut->ap_sig_rts == VALUE_ENABLED) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4557 | snprintf(buf, sizeof(buf), "iwconfig %s rts 64", ifname); |
| 4558 | if (system(buf) != 0) { |
| 4559 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4560 | "iwconfig rts 64 failed"); |
| 4561 | } |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 4562 | } else if (dut->ap_sig_rts == VALUE_DISABLED) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4563 | snprintf(buf, sizeof(buf), "iwconfig %s rts 2347", ifname); |
| 4564 | if (system(buf) != 0) { |
| 4565 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4566 | "iwpriv rts 2347 failed"); |
| 4567 | } |
| 4568 | } |
| 4569 | |
| 4570 | if (dut->ap_hs2) { |
| 4571 | snprintf(buf, sizeof(buf), "iwpriv %s qbssload 1", ifname); |
| 4572 | if (system(buf) != 0) { |
| 4573 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4574 | "iwpriv qbssload failed"); |
| 4575 | } |
| 4576 | sigma_dut_print(dut, DUT_MSG_INFO, "Enabled qbssload"); |
| 4577 | } |
| 4578 | |
| 4579 | if (dut->ap_bss_load && dut->ap_bss_load != -1) { |
| 4580 | unsigned int bssload = 0; |
| 4581 | |
| 4582 | if (dut->ap_bss_load == 1) { |
| 4583 | /* STA count: 1, CU: 50, AAC: 65535 */ |
| 4584 | bssload = 0x0132ffff; |
| 4585 | } else if (dut->ap_bss_load == 2) { |
| 4586 | /* STA count: 1, CU: 200, AAC: 65535 */ |
| 4587 | bssload = 0x01c8ffff; |
| 4588 | } else if (dut->ap_bss_load == 3) { |
| 4589 | /* STA count: 1, CU: 75, AAC: 65535 */ |
| 4590 | bssload = 0x014bffff; |
| 4591 | } |
| 4592 | |
| 4593 | snprintf(buf, sizeof(buf), "iwpriv %s hcbssload %u", |
| 4594 | ifname, bssload); |
| 4595 | if (system(buf) != 0) { |
| 4596 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4597 | "iwpriv hcbssload failed"); |
| 4598 | } |
| 4599 | } else if (dut->ap_bss_load == 0) { |
| 4600 | snprintf(buf, sizeof(buf), "iwpriv %s qbssload 0", ifname); |
| 4601 | if (system(buf) != 0) { |
| 4602 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4603 | "iwpriv qbssload failed"); |
| 4604 | } |
| 4605 | sigma_dut_print(dut, DUT_MSG_INFO, "Disabled qbssload"); |
| 4606 | } |
| 4607 | |
| 4608 | if (dut->ap_dgaf_disable) { |
| 4609 | snprintf(buf, sizeof(buf), "iwpriv %s dgaf_disable 1", ifname); |
| 4610 | if (system(buf) != 0) { |
| 4611 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4612 | "iwpriv dgaf_disable failed"); |
| 4613 | } |
| 4614 | sigma_dut_print(dut, DUT_MSG_INFO, "Enabled dgaf_disable"); |
| 4615 | } |
| 4616 | |
| 4617 | if (dut->ap_l2tif) { |
| 4618 | snprintf(buf, sizeof(buf), "iwpriv %s l2tif 1", ifname); |
| 4619 | if (system(buf) != 0) { |
| 4620 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4621 | "iwpriv l2tif failed"); |
| 4622 | } |
| 4623 | snprintf(buf, sizeof(buf), |
| 4624 | "echo 1 > /sys/class/net/br0/brif/ath0/hotspot_l2tif"); |
| 4625 | if (system(buf) != 0) |
| 4626 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4627 | "l2tif br failed"); |
| 4628 | |
| 4629 | snprintf(buf, sizeof(buf), |
| 4630 | "echo 1 > /sys/class/net/br0/brif/eth0/hotspot_wan"); |
| 4631 | if (system(buf) != 0) |
| 4632 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4633 | "l2tif brif failed"); |
| 4634 | sigma_dut_print(dut, DUT_MSG_INFO, "Enabled l2tif"); |
| 4635 | } |
priyadharshini gowthaman | 264d544 | 2016-02-25 15:52:22 -0800 | [diff] [blame] | 4636 | |
| 4637 | if (dut->ap_ndpa_frame == 0) { |
| 4638 | snprintf(buf, sizeof(buf), |
| 4639 | "wifitool %s beeliner_fw_test 117 192", ifname); |
| 4640 | if (system(buf) != 0) { |
| 4641 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4642 | "wifitool beeliner_fw_test 117 192 failed"); |
| 4643 | } |
| 4644 | snprintf(buf, sizeof(buf), |
| 4645 | "wifitool %s beeliner_fw_test 118 192", ifname); |
| 4646 | if (system(buf) != 0) { |
| 4647 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4648 | "wifitool beeliner_fw_test 117 192 failed"); |
| 4649 | } |
| 4650 | } else if (dut->ap_ndpa_frame == 1) { |
| 4651 | /* Driver default - no changes needed */ |
| 4652 | } else if (dut->ap_ndpa_frame == 2) { |
| 4653 | snprintf(buf, sizeof(buf), |
| 4654 | "wifitool %s beeliner_fw_test 115 1", ifname); |
| 4655 | if (system(buf) != 0) { |
| 4656 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4657 | "wifitool beeliner_fw_test 117 192 failed"); |
| 4658 | } |
| 4659 | snprintf(buf, sizeof(buf), |
| 4660 | "wifitool %s beeliner_fw_test 116 1", ifname); |
| 4661 | if (system(buf) != 0) { |
| 4662 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4663 | "wifitool beeliner_fw_test 117 192 failed"); |
| 4664 | } |
| 4665 | } |
priyadharshini gowthaman | 8e26ff4 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 4666 | |
| 4667 | if (dut->ap_rtt == 1) { |
| 4668 | snprintf(buf, sizeof(buf), "iwpriv %s enable_rtt 1", ifname); |
| 4669 | run_system(dut, buf); |
| 4670 | } |
| 4671 | |
| 4672 | if (dut->ap_lci == 1) { |
| 4673 | snprintf(buf, sizeof(buf), "iwpriv %s enable_lci 1", ifname); |
| 4674 | run_system(dut, buf); |
| 4675 | } |
| 4676 | |
| 4677 | if (dut->ap_lcr == 1) { |
| 4678 | snprintf(buf, sizeof(buf), "iwpriv %s enable_lcr 1", ifname); |
| 4679 | run_system(dut, buf); |
| 4680 | } |
| 4681 | |
| 4682 | if (dut->ap_rrm == 1) { |
| 4683 | snprintf(buf, sizeof(buf), "iwpriv %s rrm 1", ifname); |
| 4684 | run_system(dut, buf); |
| 4685 | } |
| 4686 | |
| 4687 | if (dut->ap_lci == 1 || dut->ap_lcr == 1) { |
| 4688 | run_system(dut, "wpc -l /tmp/lci_cfg.txt"); |
| 4689 | } |
| 4690 | |
| 4691 | if (dut->ap_neighap >= 1 && dut->ap_lci == 0) { |
| 4692 | FILE *f; |
| 4693 | |
| 4694 | f = fopen("/tmp/nbr_report.txt", "w"); |
| 4695 | if (!f) { |
| 4696 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4697 | "Failed to open /tmp/nbr_report.txt"); |
| 4698 | return; |
| 4699 | } |
| 4700 | |
| 4701 | fprintf(f, |
| 4702 | "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", |
| 4703 | dut->ap_val_neighap[0][0], dut->ap_val_neighap[0][1], |
| 4704 | dut->ap_val_neighap[0][2], dut->ap_val_neighap[0][3], |
| 4705 | dut->ap_val_neighap[0][4], dut->ap_val_neighap[0][5], |
| 4706 | dut->ap_val_opchannel[0]); |
| 4707 | fclose(f); |
| 4708 | |
| 4709 | f = fopen("/tmp/ftmrr.txt", "w"); |
| 4710 | if (!f) { |
| 4711 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4712 | "Failed to open /tmp/ftmrr.txt"); |
| 4713 | return; |
| 4714 | } |
| 4715 | |
| 4716 | fprintf(f, |
| 4717 | "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", |
| 4718 | dut->ap_val_neighap[0][0], dut->ap_val_neighap[0][1], |
| 4719 | dut->ap_val_neighap[0][2], dut->ap_val_neighap[0][3], |
| 4720 | dut->ap_val_neighap[0][4], dut->ap_val_neighap[0][5], |
| 4721 | dut->ap_val_opchannel[0]); |
| 4722 | fclose(f); |
| 4723 | } |
| 4724 | |
| 4725 | if (dut->ap_neighap >= 2 && dut->ap_lci == 0) { |
| 4726 | FILE *f; |
| 4727 | |
| 4728 | f = fopen("/tmp/nbr_report.txt", "a"); |
| 4729 | if (!f) { |
| 4730 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4731 | "Failed to open /tmp/nbr_report.txt"); |
| 4732 | return; |
| 4733 | } |
| 4734 | fprintf(f, |
| 4735 | "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", |
| 4736 | dut->ap_val_neighap[1][0], dut->ap_val_neighap[1][1], |
| 4737 | dut->ap_val_neighap[1][2], dut->ap_val_neighap[1][3], |
| 4738 | dut->ap_val_neighap[1][4], dut->ap_val_neighap[1][5], |
| 4739 | dut->ap_val_opchannel[1]); |
| 4740 | fclose(f); |
| 4741 | |
| 4742 | f = fopen("/tmp/ftmrr.txt", "a"); |
| 4743 | if (!f) { |
| 4744 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4745 | "Failed to open /tmp/ftmrr.txt"); |
| 4746 | return; |
| 4747 | } |
| 4748 | fprintf(f, |
| 4749 | "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", |
| 4750 | dut->ap_val_neighap[1][0], dut->ap_val_neighap[1][1], |
| 4751 | dut->ap_val_neighap[1][2], dut->ap_val_neighap[1][3], |
| 4752 | dut->ap_val_neighap[1][4], dut->ap_val_neighap[1][5], |
| 4753 | dut->ap_val_opchannel[1]); |
| 4754 | fclose(f); |
| 4755 | } |
| 4756 | |
| 4757 | if (dut->ap_neighap >= 3 && dut->ap_lci == 0) { |
| 4758 | FILE *f; |
| 4759 | |
| 4760 | f = fopen("/tmp/nbr_report.txt", "a"); |
| 4761 | if (!f) { |
| 4762 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4763 | "Failed to open /tmp/nbr_report.txt"); |
| 4764 | return; |
| 4765 | } |
| 4766 | |
| 4767 | fprintf(f, |
| 4768 | "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", |
| 4769 | dut->ap_val_neighap[2][0], dut->ap_val_neighap[2][1], |
| 4770 | dut->ap_val_neighap[2][2], dut->ap_val_neighap[2][3], |
| 4771 | dut->ap_val_neighap[2][4], dut->ap_val_neighap[2][5], |
| 4772 | dut->ap_val_opchannel[2]); |
| 4773 | fclose(f); |
| 4774 | |
| 4775 | f = fopen("/tmp/ftmrr.txt", "a"); |
| 4776 | if (!f) { |
| 4777 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4778 | "Failed to open /tmp/ftmrr.txt"); |
| 4779 | return; |
| 4780 | } |
| 4781 | |
| 4782 | fprintf(f, |
| 4783 | "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", |
| 4784 | dut->ap_val_neighap[2][0], dut->ap_val_neighap[2][1], |
| 4785 | dut->ap_val_neighap[2][2], dut->ap_val_neighap[2][3], |
| 4786 | dut->ap_val_neighap[2][4], dut->ap_val_neighap[2][5], |
| 4787 | dut->ap_val_opchannel[2]); |
| 4788 | fclose(f); |
| 4789 | } |
| 4790 | |
| 4791 | if (dut->ap_neighap) { |
| 4792 | snprintf(buf, sizeof(buf), "iwpriv %s enable_rtt 1", ifname); |
| 4793 | run_system(dut, buf); |
| 4794 | snprintf(buf, sizeof(buf), "iwpriv %s enable_lci 1", ifname); |
| 4795 | run_system(dut, buf); |
| 4796 | snprintf(buf, sizeof(buf), "iwpriv %s enable_lcr 1", ifname); |
| 4797 | run_system(dut, buf); |
| 4798 | snprintf(buf, sizeof(buf), "iwpriv %s rrm 1", ifname); |
| 4799 | run_system(dut, buf); |
| 4800 | } |
| 4801 | |
| 4802 | if (dut->ap_scan == 1) { |
| 4803 | snprintf(buf, sizeof(buf), "iwpriv %s scanentryage 600", |
| 4804 | ifname); |
| 4805 | run_system(dut, buf); |
| 4806 | snprintf(buf, sizeof(buf), "iwlist %s scan", ifname); |
| 4807 | run_system(dut, buf); |
| 4808 | } |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 4809 | |
| 4810 | if (dut->ap_set_bssidpref) { |
| 4811 | snprintf(buf, sizeof(buf), |
| 4812 | "wifitool %s setbssidpref 00:00:00:00:00:00 0 00 00", |
| 4813 | ifname); |
| 4814 | if (system(buf) != 0) { |
| 4815 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4816 | "wifitool clear bssidpref failed"); |
| 4817 | } |
| 4818 | } |
Adil Saeed Musthafa | 33ea287 | 2017-04-10 23:13:24 -0700 | [diff] [blame] | 4819 | |
| 4820 | if (dut->wnm_bss_max_feature != VALUE_NOT_SET) { |
| 4821 | int feature_enable; |
| 4822 | |
| 4823 | feature_enable = dut->wnm_bss_max_feature == VALUE_ENABLED; |
| 4824 | snprintf(buf, sizeof(buf), "iwpriv %s wnm %d", |
| 4825 | ifname, feature_enable); |
| 4826 | run_system(dut, buf); |
| 4827 | snprintf(buf, sizeof(buf), "iwpriv %s wnm_bss %d", |
| 4828 | ifname, feature_enable); |
| 4829 | run_system(dut, buf); |
| 4830 | if (feature_enable) { |
| 4831 | const char *extra = ""; |
| 4832 | |
| 4833 | if (dut->wnm_bss_max_protection != VALUE_NOT_SET) { |
| 4834 | if (dut->wnm_bss_max_protection == |
| 4835 | VALUE_ENABLED) |
| 4836 | extra = " 1"; |
| 4837 | else |
| 4838 | extra = " 0"; |
| 4839 | } |
| 4840 | snprintf(buf, sizeof(buf), |
| 4841 | "wlanconfig %s wnm setbssmax %d%s", |
| 4842 | ifname, dut->wnm_bss_max_idle_time, extra); |
| 4843 | run_system(dut, buf); |
| 4844 | } |
| 4845 | } |
Adil Saeed Musthafa | 05ec744 | 2017-04-10 23:13:35 -0700 | [diff] [blame] | 4846 | |
Adil Saeed Musthafa | 023108a | 2017-04-10 23:13:37 -0700 | [diff] [blame] | 4847 | if (dut->program == PROGRAM_MBO) { |
Adil Saeed Musthafa | 6906372 | 2017-04-10 23:13:40 -0700 | [diff] [blame] | 4848 | apply_mbo_pref_ap_list(dut); |
| 4849 | |
Adil Saeed Musthafa | 023108a | 2017-04-10 23:13:37 -0700 | [diff] [blame] | 4850 | snprintf(buf, sizeof(buf), "iwpriv %s mbo_cel_pref %d", |
| 4851 | ifname, dut->ap_cell_cap_pref); |
| 4852 | run_system(dut, buf); |
Adil Saeed Musthafa | 16d9e63 | 2017-04-10 23:13:38 -0700 | [diff] [blame] | 4853 | |
| 4854 | snprintf(buf, sizeof(buf), "iwpriv %s mbocap 0x40", ifname); |
| 4855 | run_system(dut, buf); |
| 4856 | |
Adil Saeed Musthafa | 05ec744 | 2017-04-10 23:13:35 -0700 | [diff] [blame] | 4857 | ath_set_assoc_disallow(dut, ifname, "disable"); |
Adil Saeed Musthafa | 023108a | 2017-04-10 23:13:37 -0700 | [diff] [blame] | 4858 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4859 | } |
| 4860 | |
| 4861 | |
| 4862 | static int cmd_ath_ap_config_commit(struct sigma_dut *dut, |
| 4863 | struct sigma_conn *conn, |
| 4864 | struct sigma_cmd *cmd) |
| 4865 | { |
| 4866 | /* const char *name = get_param(cmd, "NAME"); */ |
| 4867 | char buf[100]; |
| 4868 | struct stat s; |
| 4869 | const char *ifname = dut->ap_is_dual ? "ath1" : "ath0"; |
| 4870 | |
| 4871 | if (stat("/proc/athversion", &s) == 0) { |
| 4872 | sigma_dut_print(dut, DUT_MSG_INFO, "Run apdown"); |
| 4873 | run_system(dut, "apdown"); |
| 4874 | } |
| 4875 | |
| 4876 | cmd_ath_ap_radio_config(dut); |
| 4877 | |
| 4878 | snprintf(buf, sizeof(buf), "cfg -a 'AP_SSID=%s'", dut->ap_ssid); |
| 4879 | run_system(dut, buf); |
| 4880 | |
| 4881 | switch (dut->ap_key_mgmt) { |
| 4882 | case AP_OPEN: |
| 4883 | if (dut->ap_cipher == AP_WEP) { |
| 4884 | run_system(dut, "cfg -a AP_SECMODE=WEP"); |
| 4885 | run_system(dut, "cfg -a AP_SECFILE=NONE"); |
| 4886 | /* shared auth mode not supported */ |
| 4887 | run_system(dut, "cfg -a AP_WEP_MODE_0=1"); |
| 4888 | run_system(dut, "cfg -a AP_WEP_MODE_1=1"); |
| 4889 | snprintf(buf, sizeof(buf), |
| 4890 | "cfg -a WEP_RADIO_NUM0_KEY_1=%s", |
| 4891 | dut->ap_wepkey); |
| 4892 | run_system(dut, buf); |
| 4893 | snprintf(buf, sizeof(buf), |
| 4894 | "cfg -a WEP_RADIO_NUM1_KEY_1=%s", |
| 4895 | dut->ap_wepkey); |
| 4896 | run_system(dut, buf); |
| 4897 | } else { |
| 4898 | run_system(dut, "cfg -a AP_SECMODE=None"); |
| 4899 | } |
| 4900 | break; |
| 4901 | case AP_WPA2_PSK: |
| 4902 | case AP_WPA2_PSK_MIXED: |
| 4903 | case AP_WPA_PSK: |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 4904 | case AP_WPA2_SAE: |
| 4905 | case AP_WPA2_PSK_SAE: |
| 4906 | if (dut->ap_key_mgmt == AP_WPA2_PSK || |
| 4907 | dut->ap_key_mgmt == AP_WPA2_SAE || |
| 4908 | dut->ap_key_mgmt == AP_WPA2_PSK_SAE) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4909 | run_system(dut, "cfg -a AP_WPA=2"); |
| 4910 | else if (dut->ap_key_mgmt == AP_WPA2_PSK_MIXED) |
| 4911 | run_system(dut, "cfg -a AP_WPA=3"); |
| 4912 | else |
| 4913 | run_system(dut, "cfg -a AP_WPA=1"); |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 4914 | /* TODO: SAE configuration */ |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4915 | run_system(dut, "cfg -a AP_SECMODE=WPA"); |
| 4916 | run_system(dut, "cfg -a AP_SECFILE=PSK"); |
| 4917 | snprintf(buf, sizeof(buf), "cfg -a 'PSK_KEY=%s'", |
| 4918 | dut->ap_passphrase); |
| 4919 | run_system(dut, buf); |
| 4920 | if (dut->ap_cipher == AP_CCMP_TKIP) |
| 4921 | run_system(dut, "cfg -a AP_CYPHER=\"CCMP TKIP\""); |
| 4922 | else if (dut->ap_cipher == AP_TKIP) |
| 4923 | run_system(dut, "cfg -a AP_CYPHER=TKIP"); |
| 4924 | else |
| 4925 | run_system(dut, "cfg -a AP_CYPHER=CCMP"); |
| 4926 | break; |
| 4927 | case AP_WPA2_EAP: |
| 4928 | case AP_WPA2_EAP_MIXED: |
| 4929 | case AP_WPA_EAP: |
| 4930 | if (dut->ap_key_mgmt == AP_WPA2_EAP) |
| 4931 | run_system(dut, "cfg -a AP_WPA=2"); |
| 4932 | else if (dut->ap_key_mgmt == AP_WPA2_EAP_MIXED) |
| 4933 | run_system(dut, "cfg -a AP_WPA=3"); |
| 4934 | else |
| 4935 | run_system(dut, "cfg -a AP_WPA=1"); |
| 4936 | run_system(dut, "cfg -a AP_SECMODE=WPA"); |
| 4937 | run_system(dut, "cfg -a AP_SECFILE=EAP"); |
| 4938 | if (dut->ap_cipher == AP_CCMP_TKIP) |
| 4939 | run_system(dut, "cfg -a AP_CYPHER=\"CCMP TKIP\""); |
| 4940 | else if (dut->ap_cipher == AP_TKIP) |
| 4941 | run_system(dut, "cfg -a AP_CYPHER=TKIP"); |
| 4942 | else |
| 4943 | run_system(dut, "cfg -a AP_CYPHER=CCMP"); |
| 4944 | snprintf(buf, sizeof(buf), "cfg -a AP_AUTH_SERVER=%s", |
| 4945 | dut->ap_radius_ipaddr); |
| 4946 | run_system(dut, buf); |
| 4947 | snprintf(buf, sizeof(buf), "cfg -a AP_AUTH_PORT=%d", |
| 4948 | dut->ap_radius_port); |
| 4949 | run_system(dut, buf); |
| 4950 | snprintf(buf, sizeof(buf), "cfg -a AP_AUTH_SECRET=%s", |
| 4951 | dut->ap_radius_password); |
| 4952 | run_system(dut, buf); |
| 4953 | break; |
Jouni Malinen | ad395a2 | 2017-09-01 21:13:46 +0300 | [diff] [blame] | 4954 | case AP_SUITEB: |
| 4955 | /* TODO */ |
| 4956 | sigma_dut_print(dut, DUT_MSG_ERROR, "SuiteB not supported"); |
| 4957 | break; |
Jouni Malinen | 147b3c3 | 2017-10-09 16:51:54 +0300 | [diff] [blame] | 4958 | case AP_WPA2_OWE: |
| 4959 | /* TODO */ |
| 4960 | sigma_dut_print(dut, DUT_MSG_ERROR, "OWE not supported"); |
| 4961 | break; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4962 | } |
| 4963 | |
| 4964 | if (dut->ap_is_dual) { |
| 4965 | /* ath1 settings in case of dual */ |
| 4966 | snprintf(buf, sizeof(buf), "cfg -a 'AP_SSID_2=%s'", |
| 4967 | dut->ap_ssid); |
| 4968 | run_system(dut, buf); |
| 4969 | |
| 4970 | switch (dut->ap_key_mgmt) { |
| 4971 | case AP_OPEN: |
| 4972 | if (dut->ap_cipher == AP_WEP) { |
| 4973 | run_system(dut, "cfg -a AP_SECMODE_2=WEP"); |
| 4974 | run_system(dut, "cfg -a AP_SECFILE_2=NONE"); |
| 4975 | /* shared auth mode not supported */ |
| 4976 | run_system(dut, "cfg -a AP_WEP_MODE_0=1"); |
| 4977 | run_system(dut, "cfg -a AP_WEP_MODE_1=1"); |
| 4978 | snprintf(buf, sizeof(buf), |
| 4979 | "cfg -a WEP_RADIO_NUM0_KEY_1=%s", |
| 4980 | dut->ap_wepkey); |
| 4981 | run_system(dut, buf); |
| 4982 | snprintf(buf, sizeof(buf), |
| 4983 | "cfg -a WEP_RADIO_NUM1_KEY_1=%s", |
| 4984 | dut->ap_wepkey); |
| 4985 | run_system(dut, buf); |
| 4986 | } else { |
| 4987 | run_system(dut, "cfg -a AP_SECMODE_2=None"); |
| 4988 | } |
| 4989 | break; |
| 4990 | case AP_WPA2_PSK: |
| 4991 | case AP_WPA2_PSK_MIXED: |
| 4992 | case AP_WPA_PSK: |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 4993 | case AP_WPA2_SAE: |
| 4994 | case AP_WPA2_PSK_SAE: |
| 4995 | if (dut->ap_key_mgmt == AP_WPA2_PSK || |
| 4996 | dut->ap_key_mgmt == AP_WPA2_SAE || |
| 4997 | dut->ap_key_mgmt == AP_WPA2_PSK_SAE) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4998 | run_system(dut, "cfg -a AP_WPA_2=2"); |
| 4999 | else if (dut->ap_key_mgmt == AP_WPA2_PSK_MIXED) |
| 5000 | run_system(dut, "cfg -a AP_WPA_2=3"); |
| 5001 | else |
| 5002 | run_system(dut, "cfg -a AP_WPA_2=1"); |
| 5003 | // run_system(dut, "cfg -a AP_WPA_2=2"); |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 5004 | /* TODO: SAE configuration */ |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5005 | run_system(dut, "cfg -a AP_SECMODE_2=WPA"); |
| 5006 | run_system(dut, "cfg -a AP_SECFILE_2=PSK"); |
| 5007 | snprintf(buf, sizeof(buf), "cfg -a 'PSK_KEY_2=%s'", |
| 5008 | dut->ap_passphrase); |
| 5009 | run_system(dut, buf); |
| 5010 | if (dut->ap_cipher == AP_CCMP_TKIP) |
| 5011 | run_system(dut, "cfg -a AP_CYPHER_2=\"CCMP TKIP\""); |
| 5012 | else if (dut->ap_cipher == AP_TKIP) |
| 5013 | run_system(dut, "cfg -a AP_CYPHER_2=TKIP"); |
| 5014 | else |
| 5015 | run_system(dut, "cfg -a AP_CYPHER_2=CCMP"); |
| 5016 | break; |
| 5017 | case AP_WPA2_EAP: |
| 5018 | case AP_WPA2_EAP_MIXED: |
| 5019 | case AP_WPA_EAP: |
| 5020 | if (dut->ap_key_mgmt == AP_WPA2_EAP) |
| 5021 | run_system(dut, "cfg -a AP_WPA_2=2"); |
| 5022 | else if (dut->ap_key_mgmt == AP_WPA2_EAP_MIXED) |
| 5023 | run_system(dut, "cfg -a AP_WPA_2=3"); |
| 5024 | else |
| 5025 | run_system(dut, "cfg -a AP_WPA_2=1"); |
| 5026 | run_system(dut, "cfg -a AP_SECMODE_2=WPA"); |
| 5027 | run_system(dut, "cfg -a AP_SECFILE_2=EAP"); |
| 5028 | if (dut->ap_cipher == AP_CCMP_TKIP) |
| 5029 | run_system(dut, "cfg -a AP_CYPHER_2=\"CCMP TKIP\""); |
| 5030 | else if (dut->ap_cipher == AP_TKIP) |
| 5031 | run_system(dut, "cfg -a AP_CYPHER_2=TKIP"); |
| 5032 | else |
| 5033 | run_system(dut, "cfg -a AP_CYPHER_2=CCMP"); |
| 5034 | |
| 5035 | snprintf(buf, sizeof(buf), "cfg -a AP_AUTH_SERVER_2=%s", |
| 5036 | dut->ap_radius_ipaddr); |
| 5037 | run_system(dut, buf); |
| 5038 | snprintf(buf, sizeof(buf), "cfg -a AP_AUTH_PORT_2=%d", |
| 5039 | dut->ap_radius_port); |
| 5040 | run_system(dut, buf); |
| 5041 | snprintf(buf, sizeof(buf), "cfg -a AP_AUTH_SECRET_2=%s", |
| 5042 | dut->ap_radius_password); |
| 5043 | run_system(dut, buf); |
| 5044 | break; |
Jouni Malinen | ad395a2 | 2017-09-01 21:13:46 +0300 | [diff] [blame] | 5045 | case AP_SUITEB: |
| 5046 | /* TODO */ |
| 5047 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5048 | "SuiteB not supported"); |
| 5049 | break; |
Jouni Malinen | 147b3c3 | 2017-10-09 16:51:54 +0300 | [diff] [blame] | 5050 | case AP_WPA2_OWE: |
| 5051 | /* TODO */ |
| 5052 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5053 | "OWE not supported"); |
| 5054 | break; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5055 | } |
| 5056 | |
| 5057 | /* wifi0 settings in case of dual */ |
| 5058 | run_system(dut, "cfg -a AP_RADIO_ID=0"); |
| 5059 | run_system(dut, "cfg -a AP_PRIMARY_CH=6"); |
| 5060 | run_system(dut, "cfg -a AP_STARTMODE=dual"); |
| 5061 | run_system(dut, "cfg -a AP_CHMODE=11NGHT40PLUS"); |
| 5062 | run_system(dut, "cfg -a TX_CHAINMASK=7"); |
| 5063 | run_system(dut, "cfg -a RX_CHAINMASK=7"); |
| 5064 | } |
| 5065 | |
| 5066 | switch (dut->ap_pmf) { |
| 5067 | case AP_PMF_DISABLED: |
| 5068 | snprintf(buf, sizeof(buf), "cfg -a AP_PMF=0"); |
| 5069 | run_system(dut, buf); |
| 5070 | break; |
| 5071 | case AP_PMF_OPTIONAL: |
| 5072 | snprintf(buf, sizeof(buf), "cfg -a AP_PMF=1"); |
| 5073 | run_system(dut, buf); |
| 5074 | break; |
| 5075 | case AP_PMF_REQUIRED: |
| 5076 | snprintf(buf, sizeof(buf), "cfg -a AP_PMF=2"); |
| 5077 | run_system(dut, buf); |
| 5078 | break; |
| 5079 | } |
| 5080 | if (dut->ap_add_sha256) { |
| 5081 | snprintf(buf, sizeof(buf), "cfg -a AP_WPA_SHA256=1"); |
| 5082 | run_system(dut, buf); |
| 5083 | } else { |
| 5084 | snprintf(buf, sizeof(buf), "cfg -r AP_WPA_SHA256"); |
| 5085 | run_system(dut, buf); |
| 5086 | } |
| 5087 | |
| 5088 | if (dut->ap_hs2) |
| 5089 | run_system(dut, "cfg -a AP_HOTSPOT=1"); |
| 5090 | else |
| 5091 | run_system(dut, "cfg -r AP_HOTSPOT"); |
| 5092 | |
| 5093 | if (dut->ap_interworking) { |
| 5094 | snprintf(buf, sizeof(buf), "cfg -a AP_HOTSPOT_ANT=%d", |
| 5095 | dut->ap_access_net_type); |
| 5096 | run_system(dut, buf); |
| 5097 | snprintf(buf, sizeof(buf), "cfg -a AP_HOTSPOT_INTERNET=%d", |
| 5098 | dut->ap_internet); |
| 5099 | run_system(dut, buf); |
| 5100 | snprintf(buf, sizeof(buf), "cfg -a AP_HOTSPOT_VENUEGROUP=%d", |
| 5101 | dut->ap_venue_group); |
| 5102 | run_system(dut, buf); |
| 5103 | snprintf(buf, sizeof(buf), "cfg -a AP_HOTSPOT_VENUETYPE=%d", |
| 5104 | dut->ap_venue_type); |
| 5105 | run_system(dut, buf); |
| 5106 | snprintf(buf, sizeof(buf), "cfg -a AP_HOTSPOT_HESSID=%s", |
| 5107 | dut->ap_hessid); |
| 5108 | run_system(dut, buf); |
| 5109 | |
| 5110 | if (dut->ap_roaming_cons[0]) { |
| 5111 | char *second, *rc; |
| 5112 | rc = strdup(dut->ap_roaming_cons); |
| 5113 | if (rc == NULL) |
| 5114 | return 0; |
| 5115 | |
| 5116 | second = strchr(rc, ';'); |
| 5117 | if (second) |
| 5118 | *second++ = '\0'; |
| 5119 | |
| 5120 | snprintf(buf, sizeof(buf), |
| 5121 | "cfg -a AP_HOTSPOT_ROAMINGCONSORTIUM=%s", rc); |
| 5122 | run_system(dut, buf); |
| 5123 | |
| 5124 | if (second) { |
| 5125 | snprintf(buf, sizeof(buf), |
| 5126 | "cfg -a AP_HOTSPOT_ROAMINGCONSORTIUM2" |
| 5127 | "=%s", second); |
| 5128 | run_system(dut, buf); |
| 5129 | } |
| 5130 | free(rc); |
| 5131 | } else { |
| 5132 | run_system(dut, "cfg -r AP_HOTSPOT_ROAMINGCONSORTIUM"); |
| 5133 | run_system(dut, |
| 5134 | "cfg -r AP_HOTSPOT_ROAMINGCONSORTIUM2"); |
| 5135 | } |
| 5136 | } else { |
| 5137 | run_system(dut, "cfg -r AP_HOTSPOT_ANT"); |
| 5138 | run_system(dut, "cfg -r AP_HOTSPOT_INTERNET"); |
| 5139 | run_system(dut, "cfg -r AP_HOTSPOT_VENUEGROUP"); |
| 5140 | run_system(dut, "cfg -r AP_HOTSPOT_VENUETYPE"); |
| 5141 | run_system(dut, "cfg -r AP_HOTSPOT_HESSID"); |
| 5142 | run_system(dut, "cfg -r AP_HOTSPOT_ROAMINGCONSORTIUM"); |
| 5143 | run_system(dut, "cfg -r AP_HOTSPOT_ROAMINGCONSORTIUM2"); |
| 5144 | } |
| 5145 | |
| 5146 | if (dut->ap_proxy_arp) |
| 5147 | run_system(dut, "cfg -a IEEE80211V_PROXYARP=1"); |
| 5148 | else |
| 5149 | run_system(dut, "cfg -a IEEE80211V_PROXYARP=0"); |
| 5150 | if (dut->ap_dgaf_disable) |
| 5151 | run_system(dut, "cfg -a AP_HOTSPOT_DISABLE_DGAF=1"); |
| 5152 | else |
| 5153 | run_system(dut, "cfg -r AP_HOTSPOT_DISABLE_DGAF"); |
| 5154 | |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 5155 | if (strlen(dut->ap_tag_ssid[0])) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5156 | snprintf(buf, sizeof(buf), |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 5157 | "cfg -a AP_SSID_2=%s", dut->ap_tag_ssid[0]); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5158 | run_system(dut, buf); |
| 5159 | |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 5160 | if (dut->ap_tag_key_mgmt[0] == AP2_OSEN) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5161 | run_system(dut, "cfg -a AP_SECMODE_2=WPA"); |
| 5162 | run_system(dut, "cfg -a AP_SECFILE_2=OSEN"); |
| 5163 | |
| 5164 | snprintf(buf, sizeof(buf), "cfg -a AP_AUTH_SERVER_2=%s", |
| 5165 | dut->ap2_radius_ipaddr); |
| 5166 | run_system(dut, buf); |
| 5167 | |
| 5168 | snprintf(buf, sizeof(buf), "cfg -a AP_AUTH_PORT_2=%d", |
| 5169 | dut->ap2_radius_port); |
| 5170 | run_system(dut, buf); |
| 5171 | |
| 5172 | snprintf(buf, sizeof(buf), "cfg -a AP_AUTH_SECRET_2=%s", |
| 5173 | dut->ap2_radius_password); |
| 5174 | run_system(dut, buf); |
| 5175 | } else { |
| 5176 | run_system(dut, "cfg -a AP_SECMODE_2=None"); |
| 5177 | run_system(dut, "cfg -r AP_AUTH_SERVER_2"); |
| 5178 | run_system(dut, "cfg -r AP_AUTH_PORT_2"); |
| 5179 | run_system(dut, "cfg -r AP_AUTH_SECRET_2"); |
| 5180 | } |
| 5181 | |
| 5182 | run_system(dut, "cfg -a AP_STARTMODE=multi"); |
| 5183 | } |
| 5184 | |
| 5185 | run_system(dut, "cfg -c"); |
| 5186 | |
| 5187 | sigma_dut_print(dut, DUT_MSG_INFO, "Starting AP"); |
| 5188 | if (system("apup") != 0) { |
| 5189 | /* to be debugged why apup returns error |
| 5190 | send_resp(dut, conn, SIGMA_ERROR, |
| 5191 | "errorCode,apup failed"); |
| 5192 | return 0; |
| 5193 | */ |
| 5194 | } |
| 5195 | sigma_dut_print(dut, DUT_MSG_INFO, "AP started"); |
| 5196 | |
| 5197 | if (dut->ap_key_mgmt != AP_OPEN) { |
| 5198 | int res; |
| 5199 | /* allow some time for hostapd to start before returning |
| 5200 | * success */ |
| 5201 | usleep(500000); |
| 5202 | if (run_hostapd_cli(dut, "ping") != 0) { |
| 5203 | send_resp(dut, conn, SIGMA_ERROR, |
| 5204 | "errorCode,Failed to talk to hostapd"); |
| 5205 | return 0; |
| 5206 | } |
| 5207 | |
| 5208 | if (dut->ap_hs2 && !dut->ap_anqpserver) { |
| 5209 | /* the cfg app doesn't like ";" in the variables */ |
| 5210 | res = ath_ap_append_hostapd_conf(dut); |
| 5211 | if (res < 0) |
| 5212 | return res; |
| 5213 | |
| 5214 | /* wait for hostapd to be ready */ |
| 5215 | usleep(500000); |
| 5216 | if (run_hostapd_cli(dut, "ping") != 0) { |
| 5217 | send_resp(dut, conn, SIGMA_ERROR, |
| 5218 | "errorCode,Failed to talk to " |
| 5219 | "hostapd"); |
| 5220 | return 0; |
| 5221 | } |
| 5222 | } |
| 5223 | } |
| 5224 | |
| 5225 | ath_ap_set_params(dut); |
| 5226 | |
| 5227 | if (dut->ap_anqpserver) |
| 5228 | return cmd_ath_ap_anqpserver_start(dut); |
| 5229 | |
| 5230 | if (dut->ap2_proxy_arp) |
| 5231 | run_system(dut, "iwpriv ath1 proxy_arp 1"); |
| 5232 | |
| 5233 | if (dut->ap_allow_vht_wep || dut->ap_allow_vht_tkip) { |
| 5234 | snprintf(buf, sizeof(buf), "iwpriv %s htweptkip 1", ifname); |
| 5235 | if (system(buf) != 0) { |
| 5236 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5237 | "iwpriv htweptkip failed"); |
| 5238 | } |
| 5239 | } |
| 5240 | |
| 5241 | return 1; |
| 5242 | } |
| 5243 | |
| 5244 | |
| 5245 | static int set_ebtables_proxy_arp(struct sigma_dut *dut, const char *chain, |
| 5246 | const char *ifname) |
| 5247 | { |
| 5248 | char buf[200]; |
| 5249 | |
| 5250 | if (!chain || !ifname) |
| 5251 | return -2; |
| 5252 | |
| 5253 | snprintf(buf, sizeof(buf), "ebtables -P %s ACCEPT", chain); |
| 5254 | if (system(buf) != 0) { |
| 5255 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5256 | "Failed to set ebtables rules, RULE-1, %s", |
| 5257 | chain); |
| 5258 | return -2; |
| 5259 | } |
| 5260 | |
| 5261 | snprintf(buf, sizeof(buf), |
| 5262 | "ebtables -A %s -p ARP -d Broadcast -o %s -j DROP", |
| 5263 | chain, ifname); |
| 5264 | if (system(buf) != 0) { |
| 5265 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5266 | "Failed to set ebtables rules, RULE-2, %s", |
| 5267 | chain); |
| 5268 | return -2; |
| 5269 | } |
| 5270 | |
| 5271 | snprintf(buf, sizeof(buf), |
| 5272 | "ebtables -A %s -d Multicast -p IPv6 --ip6-protocol ipv6-icmp --ip6-icmp-type neighbor-solicitation -o %s -j DROP", |
| 5273 | chain, ifname); |
| 5274 | if (system(buf) != 0) { |
| 5275 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5276 | "Failed to set ebtables rules, RULE-3, %s", |
| 5277 | chain); |
| 5278 | return -2; |
| 5279 | } |
| 5280 | |
| 5281 | snprintf(buf, sizeof(buf), |
| 5282 | "ebtables -A %s -d Multicast -p IPv6 --ip6-protocol ipv6-icmp --ip6-icmp-type neighbor-advertisement -o %s -j DROP", |
| 5283 | chain, ifname); |
| 5284 | if (system(buf) != 0) { |
| 5285 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5286 | "Failed to set ebtables rules, RULE-4, %s", |
| 5287 | chain); |
| 5288 | return -2; |
| 5289 | } |
| 5290 | |
| 5291 | return 0; |
| 5292 | } |
| 5293 | |
| 5294 | |
| 5295 | static int set_ebtables_disable_dgaf(struct sigma_dut *dut, |
| 5296 | const char *chain, |
| 5297 | const char *ifname) |
| 5298 | { |
| 5299 | char buf[200]; |
| 5300 | |
| 5301 | if (!chain || !ifname) |
| 5302 | return -2; |
| 5303 | |
| 5304 | snprintf(buf, sizeof(buf), "ebtables -P %s ACCEPT", chain); |
| 5305 | if (system(buf) != 0) { |
| 5306 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5307 | "Failed to set ebtables rules, RULE-5, %s", |
| 5308 | chain); |
| 5309 | return -2; |
| 5310 | } |
| 5311 | |
| 5312 | snprintf(buf, sizeof(buf), |
| 5313 | "ebtables -A %s -p ARP -d Broadcast -o %s -j DROP", |
| 5314 | chain, ifname); |
| 5315 | if (system(buf) != 0) { |
| 5316 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5317 | "Failed to set ebtables rules, RULE-6, %s", |
| 5318 | chain); |
| 5319 | return -2; |
| 5320 | } |
| 5321 | |
| 5322 | snprintf(buf, sizeof(buf), |
| 5323 | "ebtables -A %s -p IPv4 -d Multicast -o %s -j DROP", |
| 5324 | chain, ifname); |
| 5325 | if (system(buf) != 0) { |
| 5326 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5327 | "Failed to set ebtables rules, RULE-7, %s", |
| 5328 | chain); |
| 5329 | return -2; |
| 5330 | } |
| 5331 | |
| 5332 | snprintf(buf, sizeof(buf), |
| 5333 | "ebtables -A %s -p IPv6 -d Multicast -o %s -j DROP", |
| 5334 | chain, ifname); |
| 5335 | if (system(buf) != 0) { |
| 5336 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5337 | "Failed to set ebtables rules, RULE-8, %s", |
| 5338 | chain); |
| 5339 | return -2; |
| 5340 | } |
| 5341 | |
| 5342 | return 0; |
| 5343 | } |
| 5344 | |
| 5345 | |
| 5346 | static int check_channel(int channel) |
| 5347 | { |
| 5348 | int channel_list[] = { 36, 40, 44, 48, 52, 60, 64, 100, 104, 108, 112, |
| 5349 | 116, 120, 124, 128, 132, 140, 144, 149, 153, 157, |
| 5350 | 161, 165 }; |
| 5351 | int num_chan = sizeof(channel_list) / sizeof(int); |
| 5352 | int i; |
| 5353 | |
| 5354 | for (i = 0; i < num_chan; i++) { |
| 5355 | if (channel == channel_list[i]) |
| 5356 | return i; |
| 5357 | } |
| 5358 | |
| 5359 | return -1; |
| 5360 | } |
| 5361 | |
| 5362 | |
| 5363 | static int get_oper_centr_freq_seq_idx(int chwidth, int channel) |
| 5364 | { |
| 5365 | int ch_base; |
| 5366 | int period; |
| 5367 | |
| 5368 | if (check_channel(channel) < 0) |
| 5369 | return -1; |
| 5370 | |
| 5371 | if (channel >= 36 && channel <= 64) |
| 5372 | ch_base = 36; |
| 5373 | else if (channel >= 100 && channel <= 144) |
| 5374 | ch_base = 100; |
| 5375 | else |
| 5376 | ch_base = 149; |
| 5377 | |
| 5378 | period = channel % ch_base * 5 / chwidth; |
| 5379 | return ch_base + period * chwidth / 5 + (chwidth - 20) / 10; |
| 5380 | } |
| 5381 | |
| 5382 | |
| 5383 | static int is_ht40plus_chan(int chan) |
| 5384 | { |
| 5385 | return chan == 36 || chan == 44 || chan == 52 || chan == 60 || |
| 5386 | chan == 100 || chan == 108 || chan == 116 || chan == 124 || |
| 5387 | chan == 132 || chan == 149 || chan == 157; |
| 5388 | } |
| 5389 | |
| 5390 | |
| 5391 | static int is_ht40minus_chan(int chan) |
| 5392 | { |
| 5393 | return chan == 40 || chan == 48 || chan == 56 || chan == 64 || |
| 5394 | chan == 104 || chan == 112 || chan == 120 || chan == 128 || |
| 5395 | chan == 136 || chan == 153 || chan == 161; |
| 5396 | } |
| 5397 | |
| 5398 | |
Mohammed Shafi Shajakhan | b53d8f9 | 2017-02-28 09:05:15 +0530 | [diff] [blame] | 5399 | static int get_5g_channel_freq(int chan) |
| 5400 | { |
| 5401 | return 5000 + chan * 5; |
| 5402 | } |
| 5403 | |
| 5404 | |
Jouni Malinen | 3d633da | 2017-09-14 22:19:21 +0300 | [diff] [blame] | 5405 | static const char * hostapd_cipher_name(enum ap_cipher cipher) |
| 5406 | { |
| 5407 | switch (cipher) { |
| 5408 | case AP_CCMP: |
| 5409 | return "CCMP"; |
| 5410 | case AP_TKIP: |
| 5411 | return "TKIP"; |
| 5412 | case AP_CCMP_TKIP: |
| 5413 | return "CCMP TKIP"; |
| 5414 | case AP_GCMP_256: |
| 5415 | return "GCMP-256"; |
| 5416 | case AP_GCMP_128: |
| 5417 | return "GCMP"; |
| 5418 | case AP_CCMP_256: |
| 5419 | return "CCMP-256"; |
Jouni Malinen | d538c78 | 2017-11-17 12:13:04 +0200 | [diff] [blame^] | 5420 | case AP_CCMP_128_GCMP_256: |
| 5421 | return "CCMP GCMP-256"; |
Jouni Malinen | 3d633da | 2017-09-14 22:19:21 +0300 | [diff] [blame] | 5422 | default: |
| 5423 | return "UNKNOWN"; |
| 5424 | } |
| 5425 | } |
| 5426 | |
| 5427 | |
| 5428 | static const char * |
| 5429 | hostapd_group_mgmt_cipher_name(enum ap_group_mgmt_cipher cipher) |
| 5430 | { |
| 5431 | switch (cipher) { |
| 5432 | case AP_BIP_GMAC_256: |
Jouni Malinen | 57887a2 | 2017-10-10 20:43:25 +0300 | [diff] [blame] | 5433 | return "BIP-GMAC-256"; |
Jouni Malinen | 3d633da | 2017-09-14 22:19:21 +0300 | [diff] [blame] | 5434 | case AP_BIP_CMAC_256: |
| 5435 | return "BIP-CMAC-256"; |
| 5436 | case AP_BIP_GMAC_128: |
| 5437 | return "BIP-GMAC-128"; |
| 5438 | case AP_BIP_CMAC_128: |
| 5439 | return "AES-128-CMAC"; |
| 5440 | default: |
| 5441 | return "UNKNOWN"; |
| 5442 | } |
| 5443 | } |
| 5444 | |
| 5445 | |
Jouni Malinen | a326d7b | 2017-09-04 13:46:02 +0300 | [diff] [blame] | 5446 | int cmd_ap_config_commit(struct sigma_dut *dut, struct sigma_conn *conn, |
| 5447 | struct sigma_cmd *cmd) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5448 | { |
| 5449 | /* const char *name = get_param(cmd, "NAME"); */ |
| 5450 | FILE *f; |
| 5451 | const char *ifname; |
| 5452 | char buf[500]; |
| 5453 | char path[100]; |
| 5454 | enum driver_type drv; |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 5455 | const char *key_mgmt; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5456 | |
| 5457 | drv = get_driver_type(); |
| 5458 | |
| 5459 | if (dut->mode == SIGMA_MODE_STATION) { |
| 5460 | stop_sta_mode(dut); |
| 5461 | sleep(1); |
| 5462 | } |
| 5463 | |
| 5464 | if (dut->mode == SIGMA_MODE_SNIFFER && dut->sniffer_ifname) { |
| 5465 | snprintf(buf, sizeof(buf), "ifconfig %s down", |
| 5466 | dut->sniffer_ifname); |
| 5467 | if (system(buf) != 0) { |
| 5468 | sigma_dut_print(dut, DUT_MSG_INFO, |
| 5469 | "Failed to run '%s'", buf); |
| 5470 | } |
| 5471 | snprintf(buf, sizeof(buf), "iw dev %s set type station", |
| 5472 | dut->sniffer_ifname); |
| 5473 | if (system(buf) != 0) { |
| 5474 | sigma_dut_print(dut, DUT_MSG_INFO, |
| 5475 | "Failed to run '%s'", buf); |
| 5476 | } |
| 5477 | } |
| 5478 | |
| 5479 | dut->mode = SIGMA_MODE_AP; |
| 5480 | |
| 5481 | if (drv == DRIVER_ATHEROS) |
| 5482 | return cmd_ath_ap_config_commit(dut, conn, cmd); |
| 5483 | if (drv == DRIVER_WCN) |
| 5484 | return cmd_wcn_ap_config_commit(dut, conn, cmd); |
| 5485 | if (drv == DRIVER_OPENWRT) |
| 5486 | return cmd_owrt_ap_config_commit(dut, conn, cmd); |
| 5487 | |
| 5488 | f = fopen(SIGMA_TMPDIR "/sigma_dut-ap.conf", "w"); |
| 5489 | if (f == NULL) { |
| 5490 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5491 | "%s: Failed to open sigma_dut-ap.conf", |
| 5492 | __func__); |
| 5493 | return -2; |
| 5494 | } |
| 5495 | switch (dut->ap_mode) { |
| 5496 | case AP_11g: |
| 5497 | case AP_11b: |
| 5498 | case AP_11ng: |
Pradeep Reddy Potteti | 08eaeba | 2017-06-14 12:43:19 +0530 | [diff] [blame] | 5499 | ifname = (drv == DRIVER_MAC80211) ? "wlan0" : "ath0"; |
| 5500 | if ((drv == DRIVER_QNXNTO || drv == DRIVER_LINUX_WCN) && |
| 5501 | sigma_main_ifname) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5502 | ifname = sigma_main_ifname; |
| 5503 | fprintf(f, "hw_mode=g\n"); |
| 5504 | break; |
| 5505 | case AP_11a: |
| 5506 | case AP_11na: |
| 5507 | case AP_11ac: |
Pradeep Reddy Potteti | 08eaeba | 2017-06-14 12:43:19 +0530 | [diff] [blame] | 5508 | if (drv == DRIVER_QNXNTO || drv == DRIVER_LINUX_WCN) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5509 | if (sigma_main_ifname) |
| 5510 | ifname = sigma_main_ifname; |
| 5511 | else |
| 5512 | ifname = "wlan0"; |
Pradeep Reddy Potteti | 08eaeba | 2017-06-14 12:43:19 +0530 | [diff] [blame] | 5513 | } else if (drv == DRIVER_MAC80211) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5514 | if (if_nametoindex("wlan1") > 0) |
| 5515 | ifname = "wlan1"; |
| 5516 | else |
| 5517 | ifname = "wlan0"; |
| 5518 | } else { |
| 5519 | ifname = get_main_ifname(); |
| 5520 | } |
| 5521 | fprintf(f, "hw_mode=a\n"); |
| 5522 | break; |
| 5523 | default: |
| 5524 | fclose(f); |
| 5525 | return -1; |
| 5526 | } |
Jouni Malinen | d6bf1b4 | 2017-06-23 17:51:01 +0300 | [diff] [blame] | 5527 | if (dut->hostapd_ifname) |
| 5528 | ifname = dut->hostapd_ifname; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5529 | |
Sreelakshmi Konamki | b692f10 | 2016-04-26 19:47:00 +0530 | [diff] [blame] | 5530 | if (drv == DRIVER_MAC80211 || drv == DRIVER_LINUX_WCN) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5531 | fprintf(f, "driver=nl80211\n"); |
| 5532 | |
Sreelakshmi Konamki | b692f10 | 2016-04-26 19:47:00 +0530 | [diff] [blame] | 5533 | if ((drv == DRIVER_MAC80211 || drv == DRIVER_QNXNTO || |
| 5534 | drv == DRIVER_LINUX_WCN) && |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5535 | (dut->ap_mode == AP_11ng || dut->ap_mode == AP_11na)) { |
Tamizh chelvam | 431c600 | 2017-03-07 17:07:16 +0530 | [diff] [blame] | 5536 | int ht40plus = 0, ht40minus = 0, tx_stbc = 0; |
| 5537 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5538 | fprintf(f, "ieee80211n=1\n"); |
Pradeep Reddy Potteti | bf8af29 | 2017-02-15 15:28:39 +0530 | [diff] [blame] | 5539 | if (dut->ap_mode == AP_11ng && |
| 5540 | (dut->ap_chwidth == AP_40 || |
| 5541 | (dut->ap_chwidth == AP_AUTO && |
| 5542 | dut->default_11ng_ap_chwidth == AP_40))) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5543 | if (dut->ap_channel >= 1 && dut->ap_channel <= 7) |
Tamizh chelvam | 431c600 | 2017-03-07 17:07:16 +0530 | [diff] [blame] | 5544 | ht40plus = 1; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5545 | else if (dut->ap_channel >= 8 && dut->ap_channel <= 11) |
Tamizh chelvam | 431c600 | 2017-03-07 17:07:16 +0530 | [diff] [blame] | 5546 | ht40minus = 1; |
| 5547 | fprintf(f, "obss_interval=300\n"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5548 | } |
| 5549 | |
| 5550 | /* configure ht_capab based on channel width */ |
| 5551 | if (dut->ap_mode == AP_11na && |
| 5552 | (dut->ap_chwidth == AP_40 || |
| 5553 | (dut->ap_chwidth == AP_AUTO && |
Pradeep Reddy Potteti | bf8af29 | 2017-02-15 15:28:39 +0530 | [diff] [blame] | 5554 | dut->default_11na_ap_chwidth == AP_40))) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5555 | if (is_ht40plus_chan(dut->ap_channel)) |
Tamizh chelvam | 431c600 | 2017-03-07 17:07:16 +0530 | [diff] [blame] | 5556 | ht40plus = 1; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5557 | else if (is_ht40minus_chan(dut->ap_channel)) |
Tamizh chelvam | 431c600 | 2017-03-07 17:07:16 +0530 | [diff] [blame] | 5558 | ht40minus = 1; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5559 | } |
Mohammed Shafi Shajakhan | 31d8a15 | 2016-06-02 20:10:55 +0530 | [diff] [blame] | 5560 | |
| 5561 | if (dut->ap_tx_stbc) |
Tamizh chelvam | 431c600 | 2017-03-07 17:07:16 +0530 | [diff] [blame] | 5562 | tx_stbc = 1; |
Mohammed Shafi Shajakhan | 31d8a15 | 2016-06-02 20:10:55 +0530 | [diff] [blame] | 5563 | |
Pradeep Reddy Potteti | 4b0cdee | 2017-03-15 12:37:33 +0530 | [diff] [blame] | 5564 | /* Overwrite the ht_capab with offset value if configured */ |
| 5565 | if (dut->ap_chwidth == AP_40 && |
| 5566 | dut->ap_chwidth_offset == SEC_CH_40ABOVE) { |
| 5567 | ht40plus = 1; |
| 5568 | ht40minus = 0; |
| 5569 | } else if (dut->ap_chwidth == AP_40 && |
| 5570 | dut->ap_chwidth_offset == SEC_CH_40BELOW) { |
| 5571 | ht40minus = 1; |
| 5572 | ht40plus = 0; |
| 5573 | } |
| 5574 | |
Tamizh chelvam | 431c600 | 2017-03-07 17:07:16 +0530 | [diff] [blame] | 5575 | fprintf(f, "ht_capab=%s%s%s\n", |
| 5576 | ht40plus ? "[HT40+]" : "", |
| 5577 | ht40minus ? "[HT40-]" : "", |
| 5578 | tx_stbc ? "[TX-STBC]" : ""); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5579 | } |
| 5580 | |
Sreelakshmi Konamki | b692f10 | 2016-04-26 19:47:00 +0530 | [diff] [blame] | 5581 | if ((drv == DRIVER_MAC80211 || drv == DRIVER_QNXNTO || |
| 5582 | drv == DRIVER_LINUX_WCN) && |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5583 | dut->ap_mode == AP_11ac) { |
| 5584 | fprintf(f, "ieee80211ac=1\n" |
| 5585 | "ieee80211n=1\n" |
| 5586 | "ht_capab=[HT40+]\n"); |
| 5587 | } |
| 5588 | |
Sreelakshmi Konamki | b692f10 | 2016-04-26 19:47:00 +0530 | [diff] [blame] | 5589 | if ((drv == DRIVER_MAC80211 || drv == DRIVER_QNXNTO || |
| 5590 | drv == DRIVER_LINUX_WCN) && |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5591 | (dut->ap_mode == AP_11ac || dut->ap_mode == AP_11na)) { |
| 5592 | if (dut->ap_countrycode[0]) { |
| 5593 | fprintf(f, "country_code=%s\n", dut->ap_countrycode); |
| 5594 | fprintf(f, "ieee80211d=1\n"); |
| 5595 | fprintf(f, "ieee80211h=1\n"); |
| 5596 | } |
| 5597 | } |
| 5598 | |
| 5599 | fprintf(f, "interface=%s\n", ifname); |
| 5600 | if (dut->bridge) |
| 5601 | fprintf(f, "bridge=%s\n", dut->bridge); |
| 5602 | fprintf(f, "channel=%d\n", dut->ap_channel); |
| 5603 | |
| 5604 | if (sigma_hapd_ctrl) |
| 5605 | fprintf(f, "ctrl_interface=%s\n", sigma_hapd_ctrl); |
| 5606 | else |
| 5607 | fprintf(f, "ctrl_interface=/var/run/hostapd\n"); |
| 5608 | |
| 5609 | if (dut->ap_ssid[0]) |
| 5610 | fprintf(f, "ssid=%s\n", dut->ap_ssid); |
| 5611 | else |
| 5612 | fprintf(f, "ssid=QCA AP OOB\n"); |
| 5613 | if (dut->ap_bcnint) |
| 5614 | fprintf(f, "beacon_int=%d\n", dut->ap_bcnint); |
| 5615 | |
| 5616 | switch (dut->ap_key_mgmt) { |
| 5617 | case AP_OPEN: |
| 5618 | if (dut->ap_cipher == AP_WEP) |
| 5619 | fprintf(f, "wep_key0=%s\n", dut->ap_wepkey); |
| 5620 | break; |
| 5621 | case AP_WPA2_PSK: |
| 5622 | case AP_WPA2_PSK_MIXED: |
| 5623 | case AP_WPA_PSK: |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 5624 | case AP_WPA2_SAE: |
| 5625 | case AP_WPA2_PSK_SAE: |
| 5626 | if (dut->ap_key_mgmt == AP_WPA2_PSK || |
| 5627 | dut->ap_key_mgmt == AP_WPA2_SAE || |
| 5628 | dut->ap_key_mgmt == AP_WPA2_PSK_SAE) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5629 | fprintf(f, "wpa=2\n"); |
| 5630 | else if (dut->ap_key_mgmt == AP_WPA2_PSK_MIXED) |
| 5631 | fprintf(f, "wpa=3\n"); |
| 5632 | else |
| 5633 | fprintf(f, "wpa=1\n"); |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 5634 | if (dut->ap_key_mgmt == AP_WPA2_SAE) |
| 5635 | key_mgmt = "SAE"; |
| 5636 | else if (dut->ap_key_mgmt == AP_WPA2_PSK_SAE) |
| 5637 | key_mgmt = "WPA-PSK SAE"; |
| 5638 | else |
| 5639 | key_mgmt = "WPA-PSK"; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5640 | switch (dut->ap_pmf) { |
| 5641 | case AP_PMF_DISABLED: |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 5642 | fprintf(f, "wpa_key_mgmt=%s%s\n", key_mgmt, |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5643 | dut->ap_add_sha256 ? " WPA-PSK-SHA256" : ""); |
| 5644 | break; |
| 5645 | case AP_PMF_OPTIONAL: |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 5646 | fprintf(f, "wpa_key_mgmt=%s%s\n", key_mgmt, |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5647 | dut->ap_add_sha256 ? " WPA-PSK-SHA256" : ""); |
| 5648 | break; |
| 5649 | case AP_PMF_REQUIRED: |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 5650 | if (dut->ap_key_mgmt == AP_WPA2_SAE) |
| 5651 | key_mgmt = "SAE"; |
| 5652 | else if (dut->ap_key_mgmt == AP_WPA2_PSK_SAE) |
| 5653 | key_mgmt = "WPA-PSK-SHA256 SAE"; |
| 5654 | else |
| 5655 | key_mgmt = "WPA-PSK-SHA256"; |
| 5656 | fprintf(f, "wpa_key_mgmt=%s\n", key_mgmt); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5657 | break; |
| 5658 | } |
| 5659 | if (dut->ap_cipher == AP_CCMP_TKIP) |
| 5660 | fprintf(f, "wpa_pairwise=CCMP TKIP\n"); |
| 5661 | else if (dut->ap_cipher == AP_TKIP) |
| 5662 | fprintf(f, "wpa_pairwise=TKIP\n"); |
| 5663 | else |
| 5664 | fprintf(f, "wpa_pairwise=CCMP\n"); |
Jouni Malinen | 2126f42 | 2017-10-11 23:24:33 +0300 | [diff] [blame] | 5665 | if (dut->ap_key_mgmt == AP_WPA2_SAE) |
| 5666 | fprintf(f, "sae_password=%s\n", dut->ap_passphrase); |
| 5667 | else |
| 5668 | fprintf(f, "wpa_passphrase=%s\n", dut->ap_passphrase); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5669 | break; |
| 5670 | case AP_WPA2_EAP: |
| 5671 | case AP_WPA2_EAP_MIXED: |
| 5672 | case AP_WPA_EAP: |
| 5673 | fprintf(f, "ieee8021x=1\n"); |
| 5674 | if (dut->ap_key_mgmt == AP_WPA2_EAP) |
| 5675 | fprintf(f, "wpa=2\n"); |
| 5676 | else if (dut->ap_key_mgmt == AP_WPA2_EAP_MIXED) |
| 5677 | fprintf(f, "wpa=3\n"); |
| 5678 | else |
| 5679 | fprintf(f, "wpa=1\n"); |
| 5680 | switch (dut->ap_pmf) { |
| 5681 | case AP_PMF_DISABLED: |
| 5682 | fprintf(f, "wpa_key_mgmt=WPA-EAP%s\n", |
| 5683 | dut->ap_add_sha256 ? " WPA-EAP-SHA256" : ""); |
| 5684 | break; |
| 5685 | case AP_PMF_OPTIONAL: |
| 5686 | fprintf(f, "wpa_key_mgmt=WPA-EAP%s\n", |
| 5687 | dut->ap_add_sha256 ? " WPA-EAP-SHA256" : ""); |
| 5688 | break; |
| 5689 | case AP_PMF_REQUIRED: |
| 5690 | fprintf(f, "wpa_key_mgmt=WPA-EAP-SHA256\n"); |
| 5691 | break; |
| 5692 | } |
| 5693 | if (dut->ap_cipher == AP_CCMP_TKIP) |
| 5694 | fprintf(f, "wpa_pairwise=CCMP TKIP\n"); |
| 5695 | else if (dut->ap_cipher == AP_TKIP) |
| 5696 | fprintf(f, "wpa_pairwise=TKIP\n"); |
| 5697 | else |
| 5698 | fprintf(f, "wpa_pairwise=CCMP\n"); |
| 5699 | fprintf(f, "auth_server_addr=%s\n", dut->ap_radius_ipaddr); |
| 5700 | if (dut->ap_radius_port) |
| 5701 | fprintf(f, "auth_server_port=%d\n", |
| 5702 | dut->ap_radius_port); |
| 5703 | fprintf(f, "auth_server_shared_secret=%s\n", |
| 5704 | dut->ap_radius_password); |
| 5705 | break; |
Jouni Malinen | ad395a2 | 2017-09-01 21:13:46 +0300 | [diff] [blame] | 5706 | case AP_SUITEB: |
| 5707 | fprintf(f, "ieee8021x=1\n"); |
| 5708 | fprintf(f, "wpa=2\n"); |
| 5709 | fprintf(f, "wpa_key_mgmt=WPA-EAP-SUITE-B-192\n"); |
Jouni Malinen | 3d633da | 2017-09-14 22:19:21 +0300 | [diff] [blame] | 5710 | fprintf(f, "wpa_pairwise=%s\n", |
| 5711 | hostapd_cipher_name(dut->ap_cipher)); |
| 5712 | if (dut->ap_group_mgmt_cipher != AP_NO_GROUP_MGMT_CIPHER_SET) |
| 5713 | fprintf(f, "group_mgmt_cipher=%s\n", |
| 5714 | hostapd_group_mgmt_cipher_name( |
| 5715 | dut->ap_group_mgmt_cipher)); |
Jouni Malinen | ad395a2 | 2017-09-01 21:13:46 +0300 | [diff] [blame] | 5716 | fprintf(f, "auth_server_addr=%s\n", dut->ap_radius_ipaddr); |
| 5717 | if (dut->ap_radius_port) |
| 5718 | fprintf(f, "auth_server_port=%d\n", |
| 5719 | dut->ap_radius_port); |
| 5720 | fprintf(f, "auth_server_shared_secret=%s\n", |
| 5721 | dut->ap_radius_password); |
| 5722 | break; |
Jouni Malinen | 147b3c3 | 2017-10-09 16:51:54 +0300 | [diff] [blame] | 5723 | case AP_WPA2_OWE: |
| 5724 | fprintf(f, "wpa=2\n"); |
| 5725 | fprintf(f, "wpa_key_mgmt=OWE\n"); |
| 5726 | fprintf(f, "rsn_pairwise=%s\n", |
| 5727 | hostapd_cipher_name(dut->ap_cipher)); |
Jouni Malinen | 72461d4 | 2017-10-10 19:20:45 +0300 | [diff] [blame] | 5728 | if (dut->ap_sae_groups) |
| 5729 | fprintf(f, "owe_groups=%s\n", dut->ap_sae_groups); |
Jouni Malinen | 147b3c3 | 2017-10-09 16:51:54 +0300 | [diff] [blame] | 5730 | break; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5731 | } |
| 5732 | |
Anilkumar Kolli | f0fd599 | 2017-02-23 12:54:01 +0530 | [diff] [blame] | 5733 | if (dut->ap_rsn_preauth) |
| 5734 | fprintf(f, "rsn_preauth=1\n"); |
| 5735 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5736 | switch (dut->ap_pmf) { |
| 5737 | case AP_PMF_DISABLED: |
| 5738 | break; |
| 5739 | case AP_PMF_OPTIONAL: |
| 5740 | fprintf(f, "ieee80211w=1\n"); |
| 5741 | break; |
| 5742 | case AP_PMF_REQUIRED: |
| 5743 | fprintf(f, "ieee80211w=2\n"); |
| 5744 | break; |
| 5745 | } |
| 5746 | |
Jouni Malinen | 3c367e8 | 2017-06-23 17:01:47 +0300 | [diff] [blame] | 5747 | if (dut->rsne_override) |
| 5748 | fprintf(f, "own_ie_override=%s\n", dut->rsne_override); |
| 5749 | |
Jouni Malinen | 6814313 | 2017-09-02 02:34:08 +0300 | [diff] [blame] | 5750 | if (dut->sae_commit_override) |
| 5751 | fprintf(f, "sae_commit_override=%s\n", |
| 5752 | dut->sae_commit_override); |
| 5753 | |
Jouni Malinen | ed670f4 | 2017-08-31 01:39:28 +0300 | [diff] [blame] | 5754 | if (dut->ap_sae_groups) |
| 5755 | fprintf(f, "sae_groups=%s\n", dut->ap_sae_groups); |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 5756 | |
Jouni Malinen | 2f524ce | 2017-08-31 01:43:29 +0300 | [diff] [blame] | 5757 | if (dut->sae_anti_clogging_threshold >= 0) |
| 5758 | fprintf(f, "sae_anti_clogging_threshold=%d\n", |
| 5759 | dut->sae_anti_clogging_threshold); |
Jouni Malinen | b347db0 | 2017-09-02 01:36:03 +0300 | [diff] [blame] | 5760 | if (dut->sae_reflection) |
| 5761 | fprintf(f, "sae_reflection_attack=1\n"); |
Jouni Malinen | 2f524ce | 2017-08-31 01:43:29 +0300 | [diff] [blame] | 5762 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5763 | if (dut->ap_p2p_mgmt) |
| 5764 | fprintf(f, "manage_p2p=1\n"); |
| 5765 | |
| 5766 | if (dut->ap_tdls_prohibit || dut->ap_l2tif) |
| 5767 | fprintf(f, "tdls_prohibit=1\n"); |
| 5768 | if (dut->ap_tdls_prohibit_chswitch || dut->ap_l2tif) |
| 5769 | fprintf(f, "tdls_prohibit_chan_switch=1\n"); |
| 5770 | if (dut->ap_p2p_cross_connect >= 0) { |
| 5771 | fprintf(f, "manage_p2p=1\n" |
| 5772 | "allow_cross_connection=%d\n", |
| 5773 | dut->ap_p2p_cross_connect); |
| 5774 | } |
| 5775 | |
| 5776 | if (dut->ap_l2tif || dut->ap_proxy_arp) { |
| 5777 | if (!dut->bridge) { |
| 5778 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5779 | "Bridge must be configured. Run with -b <brname>."); |
| 5780 | fclose(f); |
| 5781 | return -2; |
| 5782 | } |
| 5783 | fprintf(f, "ap_isolate=1\n"); |
| 5784 | } |
| 5785 | |
| 5786 | if (dut->ap_proxy_arp) |
| 5787 | fprintf(f, "proxy_arp=1\n"); |
| 5788 | |
Pradeep Reddy POTTETI | 0d3db63 | 2016-03-11 15:21:11 +0530 | [diff] [blame] | 5789 | if (dut->ap_wme) |
| 5790 | fprintf(f, "wmm_enabled=1\n"); |
| 5791 | |
Mohammed Shafi Shajakhan | 02e3b82 | 2017-02-23 04:15:02 +0530 | [diff] [blame] | 5792 | if (dut->ap_wmmps == AP_WMMPS_ON) |
| 5793 | fprintf(f, "uapsd_advertisement_enabled=1\n"); |
| 5794 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5795 | if (dut->ap_hs2) { |
| 5796 | if (dut->ap_bss_load) { |
| 5797 | char *bss_load; |
| 5798 | |
| 5799 | switch (dut->ap_bss_load) { |
| 5800 | case -1: |
| 5801 | bss_load = "bss_load_update_period=10"; |
| 5802 | break; |
| 5803 | case 1: |
| 5804 | /* STA count: 1, CU: 50, AAC: 65535 */ |
| 5805 | bss_load = "bss_load_test=1:50:65535"; |
| 5806 | break; |
| 5807 | case 2: |
| 5808 | /* STA count: 1, CU: 200, AAC: 65535 */ |
| 5809 | bss_load = "bss_load_test=1:200:65535"; |
| 5810 | break; |
| 5811 | case 3: |
| 5812 | /* STA count: 1, CU: 75, AAC: 65535 */ |
| 5813 | bss_load = "bss_load_test=1:75:65535"; |
| 5814 | break; |
| 5815 | default: |
| 5816 | bss_load = NULL; |
| 5817 | break; |
| 5818 | } |
| 5819 | |
| 5820 | if (!bss_load) { |
| 5821 | fclose(f); |
| 5822 | return -2; |
| 5823 | } |
| 5824 | fprintf(f, "%s\n", bss_load); |
| 5825 | } |
| 5826 | |
| 5827 | if (append_hostapd_conf_hs2(dut, f)) { |
| 5828 | fclose(f); |
| 5829 | return -2; |
| 5830 | } |
| 5831 | } |
| 5832 | |
| 5833 | if (dut->ap_interworking && append_hostapd_conf_interworking(dut, f)) { |
| 5834 | fclose(f); |
| 5835 | return -2; |
| 5836 | } |
| 5837 | |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 5838 | if (dut->ap_hs2 && strlen(dut->ap_tag_ssid[0])) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5839 | unsigned char bssid[6]; |
| 5840 | char ifname2[50]; |
| 5841 | |
Pradeep Reddy POTTETI | 673d85c | 2016-07-26 19:08:07 +0530 | [diff] [blame] | 5842 | if (get_hwaddr(ifname, bssid)) { |
| 5843 | fclose(f); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5844 | return -2; |
Pradeep Reddy POTTETI | 673d85c | 2016-07-26 19:08:07 +0530 | [diff] [blame] | 5845 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5846 | bssid[0] |= 0x02; |
| 5847 | |
| 5848 | snprintf(ifname2, sizeof(ifname2), "%s_1", ifname); |
| 5849 | fprintf(f, "bss=%s_1\n", ifname2); |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 5850 | fprintf(f, "ssid=%s\n", dut->ap_tag_ssid[0]); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5851 | if (dut->bridge) |
| 5852 | fprintf(f, "bridge=%s\n", dut->bridge); |
| 5853 | fprintf(f, "bssid=%02x:%02x:%02x:%02x:%02x:%02x\n", |
| 5854 | bssid[0], bssid[1], bssid[2], bssid[3], |
| 5855 | bssid[4], bssid[5]); |
| 5856 | |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 5857 | if (dut->ap_tag_key_mgmt[0] == AP2_OSEN) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5858 | fprintf(f, "osen=1\n"); |
| 5859 | if (strlen(dut->ap2_radius_ipaddr)) |
| 5860 | fprintf(f, "auth_server_addr=%s\n", |
| 5861 | dut->ap2_radius_ipaddr); |
| 5862 | if (dut->ap2_radius_port) |
| 5863 | fprintf(f, "auth_server_port=%d\n", |
| 5864 | dut->ap2_radius_port); |
| 5865 | if (strlen(dut->ap2_radius_password)) |
| 5866 | fprintf(f, "auth_server_shared_secret=%s\n", |
| 5867 | dut->ap2_radius_password); |
| 5868 | } |
| 5869 | |
| 5870 | if (dut->ap2_proxy_arp) { |
| 5871 | if (!dut->bridge) { |
| 5872 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5873 | "Bridge must be configured. Run with -b <brname>."); |
| 5874 | fclose(f); |
| 5875 | return -2; |
| 5876 | } |
| 5877 | fprintf(f, "ap_isolate=1\n"); |
| 5878 | fprintf(f, "proxy_arp=1\n"); |
| 5879 | |
| 5880 | if (set_ebtables_proxy_arp(dut, "FORWARD", ifname2) || |
| 5881 | set_ebtables_proxy_arp(dut, "OUTPUT", ifname2)) { |
| 5882 | fclose(f); |
| 5883 | return -2; |
| 5884 | } |
| 5885 | |
| 5886 | } |
| 5887 | } |
| 5888 | |
| 5889 | if (dut->program == PROGRAM_WPS) { |
| 5890 | fprintf(f, "eap_server=1\n" |
| 5891 | "wps_state=1\n" |
| 5892 | "device_name=QCA AP\n" |
| 5893 | "manufacturer=QCA\n" |
| 5894 | "device_type=6-0050F204-1\n" |
| 5895 | "config_methods=label virtual_display " |
| 5896 | "virtual_push_button keypad%s\n" |
| 5897 | "ap_pin=12345670\n" |
| 5898 | "friendly_name=QCA Access Point\n" |
| 5899 | "upnp_iface=%s\n", |
| 5900 | dut->ap_wpsnfc ? " nfc_interface ext_nfc_token" : "", |
| 5901 | dut->bridge ? dut->bridge : ifname); |
| 5902 | } |
| 5903 | |
| 5904 | if (dut->program == PROGRAM_VHT) { |
| 5905 | int vht_oper_centr_freq_idx; |
| 5906 | |
| 5907 | if (check_channel(dut->ap_channel) < 0) { |
| 5908 | send_resp(dut, conn, SIGMA_INVALID, |
| 5909 | "errorCode,Invalid channel"); |
Pradeep Reddy POTTETI | 673d85c | 2016-07-26 19:08:07 +0530 | [diff] [blame] | 5910 | fclose(f); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5911 | return 0; |
| 5912 | } |
| 5913 | |
| 5914 | switch (dut->ap_chwidth) { |
| 5915 | case AP_20: |
| 5916 | dut->ap_vht_chwidth = AP_20_40_VHT_OPER_CHWIDTH; |
| 5917 | vht_oper_centr_freq_idx = |
| 5918 | get_oper_centr_freq_seq_idx(20, |
| 5919 | dut->ap_channel); |
| 5920 | break; |
| 5921 | case AP_40: |
| 5922 | dut->ap_vht_chwidth = AP_20_40_VHT_OPER_CHWIDTH; |
| 5923 | vht_oper_centr_freq_idx = |
| 5924 | get_oper_centr_freq_seq_idx(40, |
| 5925 | dut->ap_channel); |
| 5926 | break; |
| 5927 | case AP_80: |
| 5928 | dut->ap_vht_chwidth = AP_80_VHT_OPER_CHWIDTH; |
| 5929 | vht_oper_centr_freq_idx = |
| 5930 | get_oper_centr_freq_seq_idx(80, |
| 5931 | dut->ap_channel); |
| 5932 | break; |
| 5933 | case AP_160: |
| 5934 | dut->ap_vht_chwidth = AP_160_VHT_OPER_CHWIDTH; |
| 5935 | vht_oper_centr_freq_idx = |
| 5936 | get_oper_centr_freq_seq_idx(160, |
| 5937 | dut->ap_channel); |
| 5938 | break; |
| 5939 | default: |
| 5940 | dut->ap_vht_chwidth = VHT_DEFAULT_OPER_CHWIDTH; |
| 5941 | vht_oper_centr_freq_idx = |
| 5942 | get_oper_centr_freq_seq_idx(80, |
| 5943 | dut->ap_channel); |
| 5944 | break; |
| 5945 | } |
| 5946 | fprintf(f, "vht_oper_centr_freq_seg0_idx=%d\n", |
| 5947 | vht_oper_centr_freq_idx); |
| 5948 | fprintf(f, "vht_oper_chwidth=%d\n", dut->ap_vht_chwidth); |
| 5949 | |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 5950 | if (dut->ap_sgi80 || dut->ap_txBF || |
| 5951 | dut->ap_ldpc != VALUE_NOT_SET || |
Mohammed Shafi Shajakhan | f3e68d9 | 2016-06-02 20:10:57 +0530 | [diff] [blame] | 5952 | dut->ap_tx_stbc || dut->ap_mu_txBF) { |
| 5953 | fprintf(f, "vht_capab=%s%s%s%s%s\n", |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5954 | dut->ap_sgi80 ? "[SHORT-GI-80]" : "", |
Mohammed Shafi Shajakhan | c039ce3 | 2016-06-02 20:10:58 +0530 | [diff] [blame] | 5955 | dut->ap_txBF ? |
Tamizh chelvam | 8312f6d | 2016-06-02 20:10:59 +0530 | [diff] [blame] | 5956 | "[SU-BEAMFORMER][SU-BEAMFORMEE][BF-ANTENNA-2][SOUNDING-DIMENSION-2]" : "", |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 5957 | (dut->ap_ldpc == VALUE_ENABLED) ? |
| 5958 | "[RXLDPC]" : "", |
Mohammed Shafi Shajakhan | f3e68d9 | 2016-06-02 20:10:57 +0530 | [diff] [blame] | 5959 | dut->ap_tx_stbc ? "[TX-STBC-2BY1]" : "", |
| 5960 | dut->ap_mu_txBF ? "[MU-BEAMFORMER]" : ""); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5961 | } |
| 5962 | } |
| 5963 | |
Jouni Malinen | 6d1d739 | 2017-10-10 20:35:29 +0300 | [diff] [blame] | 5964 | if (dut->ap_key_mgmt == AP_WPA2_OWE && dut->ap_tag_ssid[0][0] && |
| 5965 | dut->ap_tag_key_mgmt[0] == AP2_OPEN) { |
| 5966 | /* OWE transition mode */ |
| 5967 | unsigned char bssid[6]; |
| 5968 | char ifname2[50]; |
| 5969 | unsigned long val; |
| 5970 | FILE *f2; |
| 5971 | |
| 5972 | snprintf(ifname2, sizeof(ifname2), "%s_1", ifname); |
| 5973 | |
| 5974 | fprintf(f, "owe_transition_ifname=%s\n", ifname2); |
| 5975 | val = 0x12345678; /* default to something */ |
| 5976 | f2 = fopen("/dev/urandom", "r"); |
| 5977 | if (f2) { |
| 5978 | if (fread(&val, 1, sizeof(val), f2) != sizeof(val)) { |
| 5979 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5980 | "Could not read /dev/urandom"); |
| 5981 | } |
| 5982 | fclose(f2); |
| 5983 | } |
| 5984 | fprintf(f, "ssid=owe-%lx\n", val); |
| 5985 | |
| 5986 | if (get_hwaddr(ifname, bssid)) { |
| 5987 | fclose(f); |
| 5988 | return -2; |
| 5989 | } |
| 5990 | if (bssid[0] & 0x02) |
| 5991 | bssid[5] ^= 0x01; |
| 5992 | else |
| 5993 | bssid[0] |= 0x02; |
| 5994 | |
| 5995 | fprintf(f, "bss=%s\n", ifname2); |
| 5996 | fprintf(f, "ssid=%s\n", dut->ap_ssid); |
| 5997 | if (dut->bridge) |
| 5998 | fprintf(f, "bridge=%s\n", dut->bridge); |
| 5999 | fprintf(f, "bssid=%02x:%02x:%02x:%02x:%02x:%02x\n", |
| 6000 | bssid[0], bssid[1], bssid[2], bssid[3], |
| 6001 | bssid[4], bssid[5]); |
| 6002 | fprintf(f, "owe_transition_ifname=%s\n", ifname); |
| 6003 | } |
| 6004 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6005 | fclose(f); |
Jouni Malinen | d6bf1b4 | 2017-06-23 17:51:01 +0300 | [diff] [blame] | 6006 | if (dut->use_hostapd_pid_file) |
| 6007 | kill_hostapd_process_pid(dut); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6008 | #ifdef __QNXNTO__ |
| 6009 | if (system("slay hostapd") == 0) |
| 6010 | #else /* __QNXNTO__ */ |
Jouni Malinen | d6bf1b4 | 2017-06-23 17:51:01 +0300 | [diff] [blame] | 6011 | if (!dut->use_hostapd_pid_file && |
| 6012 | (kill_process(dut, "(hostapd)", 1, SIGTERM) == 0 || |
| 6013 | system("killall hostapd") == 0)) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6014 | #endif /* __QNXNTO__ */ |
| 6015 | { |
| 6016 | int i; |
| 6017 | /* Wait some time to allow hostapd to complete cleanup before |
| 6018 | * starting a new process */ |
| 6019 | for (i = 0; i < 10; i++) { |
| 6020 | usleep(500000); |
| 6021 | #ifdef __QNXNTO__ |
| 6022 | if (system("pidin | grep hostapd") != 0) |
| 6023 | break; |
| 6024 | #else /* __QNXNTO__ */ |
| 6025 | if (system("pidof hostapd") != 0) |
| 6026 | break; |
| 6027 | #endif /* __QNXNTO__ */ |
| 6028 | } |
| 6029 | } |
Jouni Malinen | d86e582 | 2017-08-29 03:55:32 +0300 | [diff] [blame] | 6030 | dut->hostapd_running = 0; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6031 | |
Pradeep Reddy POTTETI | a076c30 | 2016-05-16 13:36:07 +0530 | [diff] [blame] | 6032 | #ifdef ANDROID |
| 6033 | /* Set proper conf file permissions so that hostapd process |
| 6034 | * can access it. |
| 6035 | */ |
| 6036 | if (chmod(SIGMA_TMPDIR "/sigma_dut-ap.conf", |
| 6037 | S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP) < 0) |
| 6038 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 6039 | "Error changing permissions"); |
| 6040 | |
| 6041 | if (chown(SIGMA_TMPDIR "/sigma_dut-ap.conf", -1, AID_WIFI) < 0) |
| 6042 | sigma_dut_print(dut, DUT_MSG_ERROR, "Error changing groupid"); |
| 6043 | #endif /* ANDROID */ |
| 6044 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6045 | if (drv == DRIVER_QNXNTO) { |
| 6046 | snprintf(buf, sizeof(buf), |
Pradeep Reddy POTTETI | bf4a974 | 2016-02-04 12:32:30 +0530 | [diff] [blame] | 6047 | "hostapd -B %s%s %s%s" SIGMA_TMPDIR |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6048 | "/sigma_dut-ap.conf", |
| 6049 | dut->hostapd_debug_log ? "-ddKt -f " : "", |
| 6050 | dut->hostapd_debug_log ? dut->hostapd_debug_log : "", |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6051 | dut->hostapd_entropy_log ? " -e" : "", |
| 6052 | dut->hostapd_entropy_log ? dut->hostapd_entropy_log : |
| 6053 | ""); |
| 6054 | } else { |
| 6055 | /* |
| 6056 | * It looks like a monitor interface can cause some issues for |
| 6057 | * beaconing, so remove it (if injection was used) before |
| 6058 | * starting hostapd. |
| 6059 | */ |
| 6060 | if (if_nametoindex("sigmadut") > 0 && |
| 6061 | system("iw dev sigmadut del") != 0) |
| 6062 | sigma_dut_print(dut, DUT_MSG_ERROR, "Failed to remove " |
| 6063 | "monitor interface"); |
| 6064 | |
Jouni Malinen | d6bf1b4 | 2017-06-23 17:51:01 +0300 | [diff] [blame] | 6065 | snprintf(path, sizeof(path), "%shostapd", |
| 6066 | file_exists("hostapd") ? "./" : ""); |
| 6067 | 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] | 6068 | "/sigma_dut-ap.conf", |
Jouni Malinen | d6bf1b4 | 2017-06-23 17:51:01 +0300 | [diff] [blame] | 6069 | dut->hostapd_bin ? dut->hostapd_bin : path, |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6070 | dut->hostapd_debug_log ? " -ddKt -f" : "", |
| 6071 | dut->hostapd_debug_log ? dut->hostapd_debug_log : "", |
| 6072 | dut->hostapd_entropy_log ? " -e" : "", |
| 6073 | dut->hostapd_entropy_log ? dut->hostapd_entropy_log : |
Jouni Malinen | d6bf1b4 | 2017-06-23 17:51:01 +0300 | [diff] [blame] | 6074 | "", |
| 6075 | dut->use_hostapd_pid_file ? |
| 6076 | " -P " SIGMA_DUT_HOSTAPD_PID_FILE : ""); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6077 | } |
| 6078 | |
Jouni Malinen | d6bf1b4 | 2017-06-23 17:51:01 +0300 | [diff] [blame] | 6079 | sigma_dut_print(dut, DUT_MSG_DEBUG, "hostapd command: %s", buf); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6080 | if (system(buf) != 0) { |
| 6081 | send_resp(dut, conn, SIGMA_ERROR, |
| 6082 | "errorCode,Failed to start hostapd"); |
| 6083 | return 0; |
| 6084 | } |
| 6085 | |
| 6086 | /* allow some time for hostapd to start before returning success */ |
| 6087 | usleep(500000); |
| 6088 | if (run_hostapd_cli(dut, "ping") != 0) { |
| 6089 | send_resp(dut, conn, SIGMA_ERROR, |
| 6090 | "errorCode,Failed to talk to hostapd"); |
| 6091 | return 0; |
| 6092 | } |
| 6093 | |
Pradeep Reddy Potteti | 923a9b3 | 2017-06-14 12:18:59 +0530 | [diff] [blame] | 6094 | if (drv == DRIVER_LINUX_WCN) { |
| 6095 | sigma_dut_print(dut, DUT_MSG_INFO, "setting ip addr %s mask %s", |
| 6096 | ap_inet_addr, ap_inet_mask); |
| 6097 | snprintf(buf, sizeof(buf), "ifconfig %s %s netmask %s up", |
| 6098 | ifname, ap_inet_addr, ap_inet_mask); |
| 6099 | if (system(buf) != 0) { |
| 6100 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 6101 | "Failed to initialize the interface"); |
| 6102 | return -1; |
| 6103 | } |
| 6104 | } |
| 6105 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6106 | if (dut->ap_l2tif) { |
| 6107 | snprintf(path, sizeof(path), |
| 6108 | "/sys/class/net/%s/brport/hairpin_mode", |
| 6109 | ifname); |
| 6110 | if (!file_exists(path)) { |
| 6111 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 6112 | "%s must be binded to the bridge for L2TIF", |
| 6113 | ifname); |
| 6114 | return -2; |
| 6115 | } |
| 6116 | |
| 6117 | snprintf(buf, sizeof(buf), "echo 1 > %s", path); |
| 6118 | if (system(buf) != 0) { |
| 6119 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 6120 | "Failed to enable hairpin_mode for L2TIF"); |
| 6121 | return -2; |
| 6122 | } |
| 6123 | |
| 6124 | snprintf(buf, sizeof(buf), "ebtables -P FORWARD ACCEPT"); |
| 6125 | if (system(buf) != 0) { |
| 6126 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 6127 | "Failed to set ebtables rules, RULE-9"); |
| 6128 | return -2; |
| 6129 | } |
| 6130 | |
| 6131 | snprintf(buf, sizeof(buf), |
| 6132 | "ebtables -A FORWARD -p IPv4 --ip-proto icmp -i %s -j DROP", |
| 6133 | ifname); |
| 6134 | if (system(buf) != 0) { |
| 6135 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 6136 | "Failed to set ebtables rules, RULE-11"); |
| 6137 | return -2; |
| 6138 | } |
| 6139 | } |
| 6140 | |
| 6141 | if (dut->ap_proxy_arp) { |
| 6142 | if (dut->ap_dgaf_disable) { |
| 6143 | if (set_ebtables_disable_dgaf(dut, "FORWARD", ifname) || |
| 6144 | set_ebtables_disable_dgaf(dut, "OUTPUT", ifname)) |
| 6145 | return -2; |
| 6146 | } else { |
| 6147 | if (set_ebtables_proxy_arp(dut, "FORWARD", ifname) || |
| 6148 | set_ebtables_proxy_arp(dut, "OUTPUT", ifname)) |
| 6149 | return -2; |
| 6150 | } |
| 6151 | |
| 6152 | /* For 4.5-(c) */ |
| 6153 | snprintf(buf, sizeof(buf), |
| 6154 | "ebtables -A FORWARD -p ARP --arp-opcode 2 -i %s -j DROP", |
| 6155 | ifname); |
| 6156 | if (system(buf) != 0) { |
| 6157 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 6158 | "Failed to set ebtables rules, RULE-10"); |
| 6159 | return -2; |
| 6160 | } |
| 6161 | } |
| 6162 | |
| 6163 | if (dut->ap_tdls_prohibit || dut->ap_l2tif) { |
| 6164 | /* Drop TDLS frames */ |
| 6165 | snprintf(buf, sizeof(buf), |
| 6166 | "ebtables -A FORWARD -p 0x890d -i %s -j DROP", ifname); |
| 6167 | if (system(buf) != 0) { |
| 6168 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 6169 | "Failed to set ebtables rules, RULE-13"); |
| 6170 | return -2; |
| 6171 | } |
| 6172 | } |
| 6173 | |
| 6174 | if (dut->ap_fake_pkhash && |
| 6175 | run_hostapd_cli(dut, "set wps_corrupt_pkhash 1") != 0) { |
| 6176 | send_resp(dut, conn, SIGMA_ERROR, |
| 6177 | "errorCode,Could not enable FakePubKey"); |
| 6178 | return 0; |
| 6179 | } |
| 6180 | |
Jouni Malinen | d86e582 | 2017-08-29 03:55:32 +0300 | [diff] [blame] | 6181 | dut->hostapd_running = 1; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6182 | return 1; |
| 6183 | } |
| 6184 | |
| 6185 | |
Pradeep Reddy POTTETI | eff4611 | 2016-10-13 17:22:03 +0530 | [diff] [blame] | 6186 | static int parse_qos_params(struct sigma_dut *dut, struct sigma_conn *conn, |
| 6187 | struct qos_params *qos, const char *cwmin, |
| 6188 | const char *cwmax, const char *aifs, |
| 6189 | const char *txop, const char *acm) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6190 | { |
Pradeep Reddy POTTETI | eff4611 | 2016-10-13 17:22:03 +0530 | [diff] [blame] | 6191 | int val; |
| 6192 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6193 | if (cwmin) { |
| 6194 | qos->ac = 1; |
Pradeep Reddy POTTETI | eff4611 | 2016-10-13 17:22:03 +0530 | [diff] [blame] | 6195 | val = atoi(cwmin); |
| 6196 | if (val < 0 || val > 15) { |
| 6197 | send_resp(dut, conn, SIGMA_INVALID, |
| 6198 | "errorCode,Invalid cwMin"); |
| 6199 | return 0; |
| 6200 | } |
| 6201 | qos->cwmin = val; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6202 | } |
| 6203 | |
| 6204 | if (cwmax) { |
| 6205 | qos->ac = 1; |
Pradeep Reddy POTTETI | eff4611 | 2016-10-13 17:22:03 +0530 | [diff] [blame] | 6206 | val = atoi(cwmax); |
| 6207 | if (val < 0 || val > 15) { |
| 6208 | send_resp(dut, conn, SIGMA_INVALID, |
| 6209 | "errorCode,Invalid cwMax"); |
| 6210 | return 0; |
| 6211 | } |
| 6212 | qos->cwmax = val; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6213 | } |
| 6214 | |
| 6215 | if (aifs) { |
| 6216 | qos->ac = 1; |
Pradeep Reddy POTTETI | eff4611 | 2016-10-13 17:22:03 +0530 | [diff] [blame] | 6217 | val = atoi(aifs); |
| 6218 | if (val < 1 || val > 255) { |
| 6219 | send_resp(dut, conn, SIGMA_INVALID, |
| 6220 | "errorCode,Invalid AIFS"); |
| 6221 | return 0; |
| 6222 | } |
| 6223 | qos->aifs = val; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6224 | } |
| 6225 | |
| 6226 | if (txop) { |
| 6227 | qos->ac = 1; |
Pradeep Reddy POTTETI | eff4611 | 2016-10-13 17:22:03 +0530 | [diff] [blame] | 6228 | val = atoi(txop); |
| 6229 | if (val < 0 || val > 0xffff) { |
| 6230 | send_resp(dut, conn, SIGMA_INVALID, |
| 6231 | "errorCode,Invalid txop"); |
| 6232 | return 0; |
| 6233 | } |
| 6234 | qos->txop = val * 32; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6235 | } |
| 6236 | |
| 6237 | if (acm) { |
| 6238 | qos->ac = 1; |
| 6239 | qos->acm = strcasecmp(acm, "on") == 0; |
| 6240 | } |
Pradeep Reddy POTTETI | eff4611 | 2016-10-13 17:22:03 +0530 | [diff] [blame] | 6241 | |
| 6242 | return 1; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6243 | } |
| 6244 | |
| 6245 | |
| 6246 | static int cmd_ap_set_apqos(struct sigma_dut *dut, struct sigma_conn *conn, |
| 6247 | struct sigma_cmd *cmd) |
| 6248 | { |
| 6249 | /* TXOP: The values provided here for VHT5G only */ |
Pradeep Reddy POTTETI | eff4611 | 2016-10-13 17:22:03 +0530 | [diff] [blame] | 6250 | if (!parse_qos_params(dut, conn, &dut->ap_qos[AP_AC_VO], |
| 6251 | get_param(cmd, "cwmin_VO"), |
| 6252 | get_param(cmd, "cwmax_VO"), |
| 6253 | get_param(cmd, "AIFS_VO"), |
| 6254 | get_param(cmd, "TXOP_VO"), |
| 6255 | get_param(cmd, "ACM_VO")) || |
| 6256 | !parse_qos_params(dut, conn, &dut->ap_qos[AP_AC_VI], |
| 6257 | get_param(cmd, "cwmin_VI"), |
| 6258 | get_param(cmd, "cwmax_VI"), |
| 6259 | get_param(cmd, "AIFS_VI"), |
| 6260 | get_param(cmd, "TXOP_VI"), |
| 6261 | get_param(cmd, "ACM_VI")) || |
| 6262 | !parse_qos_params(dut, conn, &dut->ap_qos[AP_AC_BE], |
| 6263 | get_param(cmd, "cwmin_BE"), |
| 6264 | get_param(cmd, "cwmax_BE"), |
| 6265 | get_param(cmd, "AIFS_BE"), |
| 6266 | get_param(cmd, "TXOP_BE"), |
| 6267 | get_param(cmd, "ACM_BE")) || |
| 6268 | !parse_qos_params(dut, conn, &dut->ap_qos[AP_AC_BK], |
| 6269 | get_param(cmd, "cwmin_BK"), |
| 6270 | get_param(cmd, "cwmax_BK"), |
| 6271 | get_param(cmd, "AIFS_BK"), |
| 6272 | get_param(cmd, "TXOP_BK"), |
| 6273 | get_param(cmd, "ACM_BK"))) |
| 6274 | return 0; |
| 6275 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6276 | return 1; |
| 6277 | } |
| 6278 | |
| 6279 | |
| 6280 | static int cmd_ap_set_staqos(struct sigma_dut *dut, struct sigma_conn *conn, |
| 6281 | struct sigma_cmd *cmd) |
| 6282 | { |
Pradeep Reddy POTTETI | eff4611 | 2016-10-13 17:22:03 +0530 | [diff] [blame] | 6283 | if (!parse_qos_params(dut, conn, &dut->ap_sta_qos[AP_AC_VO], |
| 6284 | get_param(cmd, "cwmin_VO"), |
| 6285 | get_param(cmd, "cwmax_VO"), |
| 6286 | get_param(cmd, "AIFS_VO"), |
| 6287 | get_param(cmd, "TXOP_VO"), |
| 6288 | get_param(cmd, "ACM_VO")) || |
| 6289 | !parse_qos_params(dut, conn, &dut->ap_sta_qos[AP_AC_VI], |
| 6290 | get_param(cmd, "cwmin_VI"), |
| 6291 | get_param(cmd, "cwmax_VI"), |
| 6292 | get_param(cmd, "AIFS_VI"), |
| 6293 | get_param(cmd, "TXOP_VI"), |
| 6294 | get_param(cmd, "ACM_VI")) || |
| 6295 | !parse_qos_params(dut, conn, &dut->ap_sta_qos[AP_AC_BE], |
| 6296 | get_param(cmd, "cwmin_BE"), |
| 6297 | get_param(cmd, "cwmax_BE"), |
| 6298 | get_param(cmd, "AIFS_BE"), |
| 6299 | get_param(cmd, "TXOP_BE"), |
| 6300 | get_param(cmd, "ACM_BE")) || |
| 6301 | !parse_qos_params(dut, conn, &dut->ap_sta_qos[AP_AC_BK], |
| 6302 | get_param(cmd, "cwmin_BK"), |
| 6303 | get_param(cmd, "cwmax_BK"), |
| 6304 | get_param(cmd, "AIFS_BK"), |
| 6305 | get_param(cmd, "TXOP_BK"), |
| 6306 | get_param(cmd, "ACM_BK"))) |
| 6307 | return 0; |
| 6308 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6309 | return 1; |
| 6310 | } |
| 6311 | |
| 6312 | |
| 6313 | static void cmd_ath_ap_hs2_reset(struct sigma_dut *dut) |
| 6314 | { |
| 6315 | unsigned char bssid[6]; |
| 6316 | char buf[100]; |
| 6317 | run_system(dut, "cfg -a AP_SSID=\"Hotspot 2.0\""); |
| 6318 | run_system(dut, "cfg -a AP_PRIMARY_CH=1"); |
| 6319 | run_system(dut, "cfg -a AP_SECMODE=WPA"); |
| 6320 | run_system(dut, "cfg -a AP_SECFILE=EAP"); |
| 6321 | run_system(dut, "cfg -a AP_WPA=2"); |
| 6322 | run_system(dut, "cfg -a AP_CYPHER=CCMP"); |
| 6323 | run_system(dut, "cfg -a AP_HOTSPOT=1"); |
| 6324 | run_system(dut, "cfg -a AP_HOTSPOT_ANT=2"); |
| 6325 | run_system(dut, "cfg -a AP_HOTSPOT_INTERNET=0"); |
| 6326 | run_system(dut, "cfg -a AP_HOTSPOT_VENUEGROUP=2"); |
| 6327 | run_system(dut, "cfg -a AP_HOTSPOT_VENUETYPE=8"); |
| 6328 | run_system(dut, "cfg -a AP_HOTSPOT_ROAMINGCONSORTIUM=506f9a"); |
| 6329 | run_system(dut, "cfg -a AP_HOTSPOT_ROAMINGCONSORTIUM2=001bc504bd"); |
| 6330 | if (!get_hwaddr("ath0", bssid)) { |
| 6331 | snprintf(buf, sizeof(buf), "cfg -a AP_HOTSPOT_HESSID=" |
| 6332 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 6333 | bssid[0], bssid[1], bssid[2], bssid[3], |
| 6334 | bssid[4], bssid[5]); |
| 6335 | run_system(dut, buf); |
| 6336 | snprintf(dut->ap_hessid, sizeof(dut->ap_hessid), |
| 6337 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 6338 | bssid[0], bssid[1], bssid[2], bssid[3], |
| 6339 | bssid[4], bssid[5]); |
| 6340 | } else { |
| 6341 | if (!get_hwaddr("wifi0", bssid)) { |
| 6342 | snprintf(buf, sizeof(buf), "cfg -a AP_HOTSPOT_HESSID=" |
| 6343 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 6344 | bssid[0], bssid[1], bssid[2], bssid[3], |
| 6345 | bssid[4], bssid[5]); |
| 6346 | run_system(dut, buf); |
| 6347 | snprintf(dut->ap_hessid, sizeof(dut->ap_hessid), |
| 6348 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 6349 | bssid[0], bssid[1], bssid[2], bssid[3], |
| 6350 | bssid[4], bssid[5]); |
| 6351 | } else { |
| 6352 | /* load the driver and try again */ |
| 6353 | run_system(dut, "/etc/rc.d/rc.wlan up"); |
| 6354 | |
| 6355 | if (!get_hwaddr("wifi0", bssid)) { |
| 6356 | snprintf(buf, sizeof(buf), |
| 6357 | "cfg -a AP_HOTSPOT_HESSID=" |
| 6358 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 6359 | bssid[0], bssid[1], bssid[2], |
| 6360 | bssid[3], bssid[4], bssid[5]); |
| 6361 | run_system(dut, buf); |
| 6362 | snprintf(dut->ap_hessid, |
| 6363 | sizeof(dut->ap_hessid), |
| 6364 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 6365 | bssid[0], bssid[1], bssid[2], |
| 6366 | bssid[3], bssid[4], bssid[5]); |
| 6367 | } |
| 6368 | } |
| 6369 | } |
| 6370 | |
| 6371 | run_system(dut, "cfg -r AP_SSID_2"); |
| 6372 | run_system(dut, "cfg -c"); |
| 6373 | /* run_system(dut, "cfg -s"); */ |
| 6374 | } |
| 6375 | |
| 6376 | |
| 6377 | static void ath_reset_vht_defaults(struct sigma_dut *dut) |
| 6378 | { |
| 6379 | run_system(dut, "cfg -x"); |
| 6380 | run_system(dut, "cfg -a AP_RADIO_ID=1"); |
| 6381 | run_system(dut, "cfg -a AP_PRIMARY_CH_2=36"); |
| 6382 | run_system(dut, "cfg -a AP_STARTMODE=standard"); |
| 6383 | run_system(dut, "cfg -a AP_CHMODE_2=11ACVHT80"); |
| 6384 | run_system(dut, "cfg -a TX_CHAINMASK_2=7"); |
| 6385 | run_system(dut, "cfg -a RX_CHAINMASK_2=7"); |
| 6386 | run_system(dut, "cfg -a ATH_countrycode=0x348"); |
| 6387 | /* NOTE: For Beeliner we have to turn off MU-MIMO */ |
| 6388 | if (system("rm /tmp/secath*") != 0) { |
| 6389 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 6390 | "Failed to remove secath file"); |
| 6391 | } |
| 6392 | } |
| 6393 | |
| 6394 | |
| 6395 | static int cmd_ap_reset_default(struct sigma_dut *dut, struct sigma_conn *conn, |
| 6396 | struct sigma_cmd *cmd) |
| 6397 | { |
| 6398 | const char *type; |
Pradeep Reddy POTTETI | 83b8067 | 2016-09-02 13:01:44 +0530 | [diff] [blame] | 6399 | enum driver_type drv; |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 6400 | int i; |
| 6401 | |
| 6402 | for (i = 0; i < MAX_WLAN_TAGS - 1; i++) { |
| 6403 | /* |
| 6404 | * Reset all tagged SSIDs to NULL-string and all key management |
| 6405 | * to open. |
| 6406 | */ |
| 6407 | dut->ap_tag_ssid[i][0] = '\0'; |
| 6408 | dut->ap_tag_key_mgmt[i] = AP2_OPEN; |
| 6409 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6410 | |
Pradeep Reddy POTTETI | 83b8067 | 2016-09-02 13:01:44 +0530 | [diff] [blame] | 6411 | drv = get_driver_type(); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6412 | dut->program = sigma_program_to_enum(get_param(cmd, "PROGRAM")); |
| 6413 | dut->device_type = AP_unknown; |
| 6414 | type = get_param(cmd, "type"); |
| 6415 | if (type && strcasecmp(type, "Testbed") == 0) |
| 6416 | dut->device_type = AP_testbed; |
| 6417 | if (type && strcasecmp(type, "DUT") == 0) |
| 6418 | dut->device_type = AP_dut; |
| 6419 | |
| 6420 | dut->ap_rts = 0; |
| 6421 | dut->ap_frgmnt = 0; |
| 6422 | dut->ap_bcnint = 0; |
| 6423 | dut->ap_key_mgmt = AP_OPEN; |
| 6424 | dut->ap_ssid[0] = '\0'; |
| 6425 | dut->ap_fake_pkhash = 0; |
| 6426 | memset(dut->ap_qos, 0, sizeof(dut->ap_qos)); |
| 6427 | memset(dut->ap_sta_qos, 0, sizeof(dut->ap_sta_qos)); |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 6428 | dut->ap_addba_reject = VALUE_NOT_SET; |
| 6429 | dut->ap_noack = VALUE_NOT_SET; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6430 | dut->ap_is_dual = 0; |
| 6431 | dut->ap_mode = AP_inval; |
| 6432 | dut->ap_mode_1 = AP_inval; |
| 6433 | |
| 6434 | dut->ap_allow_vht_wep = 0; |
| 6435 | dut->ap_allow_vht_tkip = 0; |
| 6436 | dut->ap_disable_protection = 0; |
| 6437 | memset(dut->ap_countrycode, 0, sizeof(dut->ap_countrycode)); |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 6438 | dut->ap_dyn_bw_sig = VALUE_NOT_SET; |
| 6439 | dut->ap_ldpc = VALUE_NOT_SET; |
| 6440 | dut->ap_sig_rts = VALUE_NOT_SET; |
| 6441 | dut->ap_rx_amsdu = VALUE_NOT_SET; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6442 | dut->ap_txBF = 0; |
Mohammed Shafi Shajakhan | 495fdb2 | 2016-06-02 20:10:56 +0530 | [diff] [blame] | 6443 | dut->ap_mu_txBF = 0; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6444 | dut->ap_chwidth = AP_AUTO; |
| 6445 | |
Sarvepalli, Rajesh Babu | 24dc7e4 | 2016-03-18 21:27:26 +0530 | [diff] [blame] | 6446 | dut->ap_rsn_preauth = 0; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6447 | dut->ap_wpsnfc = 0; |
| 6448 | dut->ap_bss_load = -1; |
| 6449 | dut->ap_p2p_cross_connect = -1; |
| 6450 | |
Pradeep Reddy POTTETI | fba27db | 2015-11-20 16:42:22 +0530 | [diff] [blame] | 6451 | dut->ap_regulatory_mode = AP_80211D_MODE_DISABLED; |
| 6452 | dut->ap_dfs_mode = AP_DFS_MODE_DISABLED; |
Pradeep Reddy Potteti | 4b0cdee | 2017-03-15 12:37:33 +0530 | [diff] [blame] | 6453 | dut->ap_chwidth_offset = SEC_CH_NO; |
Pradeep Reddy POTTETI | fba27db | 2015-11-20 16:42:22 +0530 | [diff] [blame] | 6454 | |
Adil Saeed Musthafa | 6906372 | 2017-04-10 23:13:40 -0700 | [diff] [blame] | 6455 | dut->mbo_pref_ap_cnt = 0; |
Adil Saeed Musthafa | 4ec61bd | 2017-04-10 23:13:41 -0700 | [diff] [blame] | 6456 | dut->ft_bss_mac_cnt = 0; |
Adil Saeed Musthafa | 6906372 | 2017-04-10 23:13:40 -0700 | [diff] [blame] | 6457 | |
Mohammed Shafi Shajakhan | 02e3b82 | 2017-02-23 04:15:02 +0530 | [diff] [blame] | 6458 | if (dut->program == PROGRAM_HT || dut->program == PROGRAM_VHT) { |
Pradeep Reddy POTTETI | 0d3db63 | 2016-03-11 15:21:11 +0530 | [diff] [blame] | 6459 | dut->ap_wme = AP_WME_ON; |
Mohammed Shafi Shajakhan | 02e3b82 | 2017-02-23 04:15:02 +0530 | [diff] [blame] | 6460 | dut->ap_wmmps = AP_WMMPS_ON; |
| 6461 | } else { |
Pradeep Reddy POTTETI | 0d3db63 | 2016-03-11 15:21:11 +0530 | [diff] [blame] | 6462 | dut->ap_wme = AP_WME_OFF; |
Mohammed Shafi Shajakhan | 02e3b82 | 2017-02-23 04:15:02 +0530 | [diff] [blame] | 6463 | dut->ap_wmmps = AP_WMMPS_OFF; |
| 6464 | } |
Pradeep Reddy POTTETI | 0d3db63 | 2016-03-11 15:21:11 +0530 | [diff] [blame] | 6465 | |
Adil Saeed Musthafa | 33ea287 | 2017-04-10 23:13:24 -0700 | [diff] [blame] | 6466 | if (dut->program == PROGRAM_HS2 || dut->program == PROGRAM_HS2_R2 || |
| 6467 | dut->program == PROGRAM_IOTLP) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6468 | int i; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6469 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6470 | if (drv == DRIVER_ATHEROS) |
| 6471 | cmd_ath_ap_hs2_reset(dut); |
| 6472 | else if (drv == DRIVER_OPENWRT) |
| 6473 | cmd_owrt_ap_hs2_reset(dut); |
| 6474 | |
| 6475 | dut->ap_interworking = 1; |
| 6476 | dut->ap_access_net_type = 2; |
| 6477 | dut->ap_internet = 0; |
| 6478 | dut->ap_venue_group = 2; |
| 6479 | dut->ap_venue_type = 8; |
| 6480 | dut->ap_domain_name_list[0] = '\0'; |
| 6481 | dut->ap_hs2 = 1; |
| 6482 | snprintf(dut->ap_roaming_cons, sizeof(dut->ap_roaming_cons), |
| 6483 | "506f9a;001bc504bd"); |
| 6484 | dut->ap_l2tif = 0; |
| 6485 | dut->ap_proxy_arp = 0; |
| 6486 | if (dut->bridge) { |
| 6487 | char buf[50]; |
| 6488 | |
| 6489 | snprintf(buf, sizeof(buf), "ip neigh flush dev %s", |
| 6490 | dut->bridge); |
| 6491 | if (system(buf) != 0) { |
| 6492 | sigma_dut_print(dut, DUT_MSG_DEBUG, |
| 6493 | "%s ip neigh table flushing failed", |
| 6494 | dut->bridge); |
| 6495 | } |
| 6496 | |
| 6497 | snprintf(buf, sizeof(buf), "ebtables -F"); |
| 6498 | if (system(buf) != 0) { |
| 6499 | sigma_dut_print(dut, DUT_MSG_DEBUG, |
| 6500 | "%s ebtables flushing failed", |
| 6501 | dut->bridge); |
| 6502 | } |
| 6503 | } |
| 6504 | dut->ap_dgaf_disable = 0; |
| 6505 | dut->ap_p2p_cross_connect = 0; |
| 6506 | dut->ap_gas_cb_delay = 0; |
| 6507 | dut->ap_nai_realm_list = 0; |
| 6508 | dut->ap_oper_name = 0; |
| 6509 | dut->ap_venue_name = 0; |
| 6510 | for (i = 0; i < 10; i++) { |
| 6511 | dut->ap_plmn_mcc[i][0] = '\0'; |
| 6512 | dut->ap_plmn_mnc[i][0] = '\0'; |
| 6513 | } |
| 6514 | dut->ap_wan_metrics = 0; |
| 6515 | dut->ap_conn_capab = 0; |
| 6516 | dut->ap_ip_addr_type_avail = 0; |
| 6517 | dut->ap_net_auth_type = 0; |
| 6518 | dut->ap_oper_class = 0; |
| 6519 | dut->ap_pmf = 0; |
| 6520 | dut->ap_add_sha256 = 0; |
| 6521 | } |
| 6522 | |
Adil Saeed Musthafa | 33ea287 | 2017-04-10 23:13:24 -0700 | [diff] [blame] | 6523 | if (dut->program == PROGRAM_HS2_R2 || dut->program == PROGRAM_IOTLP) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6524 | int i; |
| 6525 | const char hessid[] = "50:6f:9a:00:11:22"; |
| 6526 | |
| 6527 | memcpy(dut->ap_hessid, hessid, strlen(hessid) + 1); |
| 6528 | dut->ap_osu_ssid[0] = '\0'; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6529 | dut->ap_pmf = 1; |
| 6530 | dut->ap_osu_provider_list = 0; |
| 6531 | for (i = 0; i < 10; i++) { |
| 6532 | dut->ap_osu_server_uri[i][0] = '\0'; |
| 6533 | dut->ap_osu_method[i] = 0xFF; |
| 6534 | } |
| 6535 | dut->ap_qos_map_set = 0; |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 6536 | dut->ap_tag_key_mgmt[0] = AP2_OPEN; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6537 | dut->ap2_proxy_arp = 0; |
| 6538 | dut->ap_osu_icon_tag = 0; |
| 6539 | } |
| 6540 | |
| 6541 | if (dut->program == PROGRAM_VHT) { |
| 6542 | /* Set up the defaults */ |
| 6543 | dut->ap_mode = AP_11ac; |
| 6544 | dut->ap_channel = 36; |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 6545 | dut->ap_ampdu = VALUE_NOT_SET; |
priyadharshini gowthaman | 264d544 | 2016-02-25 15:52:22 -0800 | [diff] [blame] | 6546 | dut->ap_ndpa_frame = 1; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6547 | if (dut->device_type == AP_testbed) { |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 6548 | dut->ap_amsdu = VALUE_DISABLED; |
| 6549 | dut->ap_ldpc = VALUE_DISABLED; |
| 6550 | dut->ap_rx_amsdu = VALUE_DISABLED; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6551 | dut->ap_sgi80 = 0; |
| 6552 | } else { |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 6553 | dut->ap_amsdu = VALUE_ENABLED; |
Pradeep Reddy POTTETI | 83b8067 | 2016-09-02 13:01:44 +0530 | [diff] [blame] | 6554 | /* |
| 6555 | * As LDPC is optional, don't enable this by default |
| 6556 | * for LINUX-WCN driver. The ap_set_wireless command |
| 6557 | * can be used to enable LDPC, when needed. |
| 6558 | */ |
| 6559 | if (drv != DRIVER_LINUX_WCN) |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 6560 | dut->ap_ldpc = VALUE_ENABLED; |
| 6561 | dut->ap_rx_amsdu = VALUE_ENABLED; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6562 | dut->ap_sgi80 = 1; |
| 6563 | } |
| 6564 | dut->ap_fixed_rate = 0; |
| 6565 | dut->ap_rx_streams = 3; |
| 6566 | dut->ap_tx_streams = 3; |
| 6567 | dut->ap_vhtmcs_map = 0; |
| 6568 | dut->ap_chwidth = AP_80; |
| 6569 | dut->ap_tx_stbc = 1; |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 6570 | dut->ap_dyn_bw_sig = VALUE_ENABLED; |
Mohammed Shafi Shajakhan | bae7230 | 2016-03-02 11:56:23 +0530 | [diff] [blame] | 6571 | if (get_openwrt_driver_type() == OPENWRT_DRIVER_ATHEROS) |
| 6572 | dut->ap_dfs_mode = AP_DFS_MODE_ENABLED; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6573 | if (get_driver_type() == DRIVER_ATHEROS) |
| 6574 | ath_reset_vht_defaults(dut); |
| 6575 | } |
| 6576 | |
Adil Saeed Musthafa | 33ea287 | 2017-04-10 23:13:24 -0700 | [diff] [blame] | 6577 | if (dut->program == PROGRAM_IOTLP) { |
| 6578 | dut->wnm_bss_max_feature = VALUE_DISABLED; |
| 6579 | dut->wnm_bss_max_idle_time = 0; |
| 6580 | dut->wnm_bss_max_protection = VALUE_NOT_SET; |
| 6581 | dut->ap_proxy_arp = 1; |
| 6582 | } else { |
| 6583 | /* |
| 6584 | * Do not touch the BSS-MAX Idle time feature |
| 6585 | * if the program is not IOTLP. |
| 6586 | */ |
| 6587 | dut->wnm_bss_max_feature = VALUE_NOT_SET; |
| 6588 | dut->wnm_bss_max_idle_time = 0; |
| 6589 | dut->wnm_bss_max_protection = VALUE_NOT_SET; |
| 6590 | } |
| 6591 | |
priyadharshini gowthaman | a27b5b6 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 6592 | if (dut->program == PROGRAM_LOC) { |
priyadharshini gowthaman | 8e26ff4 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 6593 | dut->ap_rrm = 1; |
| 6594 | dut->ap_rtt = 1; |
| 6595 | dut->ap_lci = 0; |
| 6596 | dut->ap_val_lci[0] = '\0'; |
priyadharshini gowthaman | c2357bd | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 6597 | dut->ap_infoz[0] = '\0'; |
priyadharshini gowthaman | 8e26ff4 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 6598 | dut->ap_lcr = 0; |
| 6599 | dut->ap_val_lcr[0] = '\0'; |
| 6600 | dut->ap_neighap = 0; |
| 6601 | dut->ap_opchannel = 0; |
| 6602 | dut->ap_scan = 0; |
priyadharshini gowthaman | c2357bd | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 6603 | dut->ap_fqdn_held = 0; |
| 6604 | dut->ap_fqdn_supl = 0; |
priyadharshini gowthaman | c52fff8 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 6605 | dut->ap_interworking = 0; |
| 6606 | dut->ap_gas_cb_delay = 0; |
priyadharshini gowthaman | a27b5b6 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 6607 | dut->ap_msnt_type = 0; |
| 6608 | } |
Adil Saeed Musthafa | 4ec61bd | 2017-04-10 23:13:41 -0700 | [diff] [blame] | 6609 | dut->ap_ft_oa = 0; |
Adil Saeed Musthafa | 604c826 | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 6610 | dut->ap_reg_domain = REG_DOMAIN_NOT_SET; |
Adil Saeed Musthafa | cf752fa | 2017-04-10 23:13:32 -0700 | [diff] [blame] | 6611 | dut->ap_mobility_domain[0] = '\0'; |
priyadharshini gowthaman | a27b5b6 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 6612 | |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 6613 | if (dut->program == PROGRAM_MBO) { |
| 6614 | dut->ap_mbo = 1; |
| 6615 | dut->ap_interworking = 1; |
| 6616 | dut->ap_ne_class = 0; |
| 6617 | dut->ap_ne_op_ch = 0; |
| 6618 | dut->ap_set_bssidpref = 1; |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 6619 | dut->ap_btmreq_disassoc_imnt = 0; |
| 6620 | dut->ap_btmreq_term_bit = 0; |
| 6621 | dut->ap_disassoc_timer = 0; |
| 6622 | dut->ap_btmreq_bss_term_dur = 0; |
Adil Saeed Musthafa | 16d9e63 | 2017-04-10 23:13:38 -0700 | [diff] [blame] | 6623 | dut->ap_channel = 36; |
| 6624 | dut->ap_chwidth = AP_20; |
Adil Saeed Musthafa | 023108a | 2017-04-10 23:13:37 -0700 | [diff] [blame] | 6625 | dut->ap_cell_cap_pref = 0; |
Adil Saeed Musthafa | ed5faae | 2017-04-10 23:13:36 -0700 | [diff] [blame] | 6626 | dut->ap_gas_cb_delay = 0; |
Adil Saeed Musthafa | 6906372 | 2017-04-10 23:13:40 -0700 | [diff] [blame] | 6627 | dut->mbo_self_ap_tuple.ap_ne_class = -1; |
| 6628 | dut->mbo_self_ap_tuple.ap_ne_pref = -1; /* Not set */ |
| 6629 | dut->mbo_self_ap_tuple.ap_ne_op_ch = -1; |
| 6630 | |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 6631 | } |
| 6632 | |
Jouni Malinen | 3c367e8 | 2017-06-23 17:01:47 +0300 | [diff] [blame] | 6633 | free(dut->rsne_override); |
| 6634 | dut->rsne_override = NULL; |
| 6635 | |
Jouni Malinen | 6814313 | 2017-09-02 02:34:08 +0300 | [diff] [blame] | 6636 | free(dut->sae_commit_override); |
| 6637 | dut->sae_commit_override = NULL; |
| 6638 | |
Jouni Malinen | ed670f4 | 2017-08-31 01:39:28 +0300 | [diff] [blame] | 6639 | free(dut->ap_sae_groups); |
| 6640 | dut->ap_sae_groups = NULL; |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 6641 | |
Jouni Malinen | 2f524ce | 2017-08-31 01:43:29 +0300 | [diff] [blame] | 6642 | dut->sae_anti_clogging_threshold = -1; |
Jouni Malinen | b347db0 | 2017-09-02 01:36:03 +0300 | [diff] [blame] | 6643 | dut->sae_reflection = 0; |
Jouni Malinen | 2f524ce | 2017-08-31 01:43:29 +0300 | [diff] [blame] | 6644 | |
Jouni Malinen | 3d633da | 2017-09-14 22:19:21 +0300 | [diff] [blame] | 6645 | dut->ap_cipher = AP_CCMP; |
| 6646 | dut->ap_group_mgmt_cipher = AP_NO_GROUP_MGMT_CIPHER_SET; |
| 6647 | |
Jouni Malinen | d86e582 | 2017-08-29 03:55:32 +0300 | [diff] [blame] | 6648 | dut->dpp_conf_id = -1; |
| 6649 | |
| 6650 | dut->hostapd_running = 0; |
Jouni Malinen | d6bf1b4 | 2017-06-23 17:51:01 +0300 | [diff] [blame] | 6651 | if (dut->use_hostapd_pid_file) { |
| 6652 | kill_hostapd_process_pid(dut); |
| 6653 | } else if (kill_process(dut, "(hostapd)", 1, SIGTERM) == 0 || |
| 6654 | system("killall hostapd") == 0) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6655 | int i; |
| 6656 | /* Wait some time to allow hostapd to complete cleanup before |
| 6657 | * starting a new process */ |
| 6658 | for (i = 0; i < 10; i++) { |
| 6659 | usleep(500000); |
| 6660 | if (system("pidof hostapd") != 0) |
| 6661 | break; |
| 6662 | } |
| 6663 | } |
| 6664 | |
| 6665 | if (if_nametoindex("sigmadut") > 0 && |
| 6666 | system("iw dev sigmadut del") != 0) |
| 6667 | sigma_dut_print(dut, DUT_MSG_ERROR, "Failed to remove " |
| 6668 | "monitor interface"); |
| 6669 | |
| 6670 | return 1; |
| 6671 | } |
| 6672 | |
| 6673 | |
| 6674 | static int cmd_ap_get_info(struct sigma_dut *dut, struct sigma_conn *conn, |
| 6675 | struct sigma_cmd *cmd) |
| 6676 | { |
| 6677 | /* const char *name = get_param(cmd, "NAME"); */ |
| 6678 | struct stat s; |
| 6679 | char resp[200]; |
| 6680 | FILE *f; |
| 6681 | enum driver_type drv = get_driver_type(); |
| 6682 | |
| 6683 | switch (drv) { |
| 6684 | case DRIVER_ATHEROS: { |
| 6685 | /* Atheros AP */ |
| 6686 | struct utsname uts; |
| 6687 | char *version, athver[100]; |
| 6688 | |
| 6689 | if (stat("/proc/athversion", &s) != 0) { |
| 6690 | if (system("/etc/rc.d/rc.wlan up") != 0) { |
| 6691 | } |
| 6692 | } |
| 6693 | |
| 6694 | athver[0] = '\0'; |
| 6695 | f = fopen("/proc/athversion", "r"); |
| 6696 | if (f) { |
| 6697 | if (fgets(athver, sizeof(athver), f)) { |
| 6698 | char *pos = strchr(athver, '\n'); |
| 6699 | if (pos) |
| 6700 | *pos = '\0'; |
| 6701 | } |
| 6702 | fclose(f); |
| 6703 | } |
| 6704 | |
| 6705 | if (uname(&uts) == 0) |
| 6706 | version = uts.release; |
| 6707 | else |
| 6708 | version = "Unknown"; |
| 6709 | |
| 6710 | if (if_nametoindex("ath1") > 0) |
| 6711 | snprintf(resp, sizeof(resp), "interface,ath0_24G " |
| 6712 | "ath1_5G,agent,1.0,version,%s/drv:%s", |
| 6713 | version, athver); |
| 6714 | else |
| 6715 | snprintf(resp, sizeof(resp), "interface,ath0_24G," |
| 6716 | "agent,1.0,version,%s/drv:%s", |
| 6717 | version, athver); |
| 6718 | |
| 6719 | send_resp(dut, conn, SIGMA_COMPLETE, resp); |
| 6720 | return 0; |
| 6721 | } |
Sreelakshmi Konamki | b692f10 | 2016-04-26 19:47:00 +0530 | [diff] [blame] | 6722 | case DRIVER_LINUX_WCN: |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6723 | case DRIVER_MAC80211: { |
| 6724 | struct utsname uts; |
| 6725 | char *version; |
| 6726 | |
| 6727 | if (uname(&uts) == 0) |
| 6728 | version = uts.release; |
| 6729 | else |
| 6730 | version = "Unknown"; |
| 6731 | |
| 6732 | if (if_nametoindex("wlan1") > 0) |
| 6733 | snprintf(resp, sizeof(resp), "interface,wlan0_24G " |
| 6734 | "wlan1_5G,agent,1.0,version,%s", version); |
| 6735 | else |
| 6736 | snprintf(resp, sizeof(resp), "interface,wlan0_any," |
| 6737 | "agent,1.0,version,%s", version); |
| 6738 | |
| 6739 | send_resp(dut, conn, SIGMA_COMPLETE, resp); |
| 6740 | return 0; |
| 6741 | } |
| 6742 | case DRIVER_QNXNTO: { |
| 6743 | struct utsname uts; |
| 6744 | char *version; |
| 6745 | |
| 6746 | if (uname(&uts) == 0) |
| 6747 | version = uts.release; |
| 6748 | else |
| 6749 | version = "Unknown"; |
| 6750 | snprintf(resp, sizeof(resp), |
| 6751 | "interface,%s_any,agent,1.0,version,%s", |
| 6752 | sigma_main_ifname ? sigma_main_ifname : "NA", |
| 6753 | version); |
| 6754 | send_resp(dut, conn, SIGMA_COMPLETE, resp); |
| 6755 | return 0; |
| 6756 | } |
| 6757 | case DRIVER_OPENWRT: { |
| 6758 | switch (get_openwrt_driver_type()) { |
| 6759 | case OPENWRT_DRIVER_ATHEROS: { |
| 6760 | struct utsname uts; |
| 6761 | char *version; |
| 6762 | |
| 6763 | if (uname(&uts) == 0) |
| 6764 | version = uts.release; |
| 6765 | else |
| 6766 | version = "Unknown"; |
| 6767 | |
| 6768 | if (if_nametoindex("ath1") > 0) |
| 6769 | snprintf(resp, sizeof(resp), |
| 6770 | "interface,ath0_5G ath1_24G,agent,1.0,version,%s", |
| 6771 | version); |
| 6772 | else |
| 6773 | snprintf(resp, sizeof(resp), |
| 6774 | "interface,ath0_any,agent,1.0,version,%s", |
| 6775 | version); |
| 6776 | |
| 6777 | send_resp(dut, conn, SIGMA_COMPLETE, resp); |
| 6778 | return 0; |
| 6779 | } |
| 6780 | default: |
| 6781 | send_resp(dut, conn, SIGMA_ERROR, |
| 6782 | "errorCode,Unsupported openwrt driver"); |
| 6783 | return 0; |
| 6784 | } |
| 6785 | } |
| 6786 | default: |
| 6787 | send_resp(dut, conn, SIGMA_ERROR, |
| 6788 | "errorCode,Unsupported driver"); |
| 6789 | return 0; |
| 6790 | } |
| 6791 | } |
| 6792 | |
| 6793 | |
| 6794 | static int cmd_ap_deauth_sta(struct sigma_dut *dut, struct sigma_conn *conn, |
| 6795 | struct sigma_cmd *cmd) |
| 6796 | { |
| 6797 | /* const char *name = get_param(cmd, "NAME"); */ |
| 6798 | /* const char *ifname = get_param(cmd, "INTERFACE"); */ |
| 6799 | const char *val; |
| 6800 | char buf[100]; |
| 6801 | |
| 6802 | val = get_param(cmd, "MinorCode"); |
| 6803 | if (val) { |
| 6804 | /* TODO: add support for P2P minor code */ |
| 6805 | send_resp(dut, conn, SIGMA_ERROR, "errorCode,MinorCode not " |
| 6806 | "yet supported"); |
| 6807 | return 0; |
| 6808 | } |
| 6809 | |
| 6810 | val = get_param(cmd, "STA_MAC_ADDRESS"); |
| 6811 | if (val == NULL) |
| 6812 | return -1; |
| 6813 | snprintf(buf, sizeof(buf), "deauth %s", val); |
| 6814 | if (run_hostapd_cli(dut, buf) != 0) |
| 6815 | return -2; |
| 6816 | |
| 6817 | return 1; |
| 6818 | } |
| 6819 | |
| 6820 | |
| 6821 | #ifdef __linux__ |
| 6822 | int inject_frame(int s, const void *data, size_t len, int encrypt); |
| 6823 | int open_monitor(const char *ifname); |
| 6824 | int hwaddr_aton(const char *txt, unsigned char *addr); |
| 6825 | #endif /* __linux__ */ |
| 6826 | |
| 6827 | enum send_frame_type { |
| 6828 | DISASSOC, DEAUTH, SAQUERY |
| 6829 | }; |
| 6830 | enum send_frame_protection { |
| 6831 | CORRECT_KEY, INCORRECT_KEY, UNPROTECTED |
| 6832 | }; |
| 6833 | |
| 6834 | |
| 6835 | static int ap_inject_frame(struct sigma_dut *dut, struct sigma_conn *conn, |
| 6836 | enum send_frame_type frame, |
| 6837 | enum send_frame_protection protected, |
| 6838 | const char *sta_addr) |
| 6839 | { |
| 6840 | #ifdef __linux__ |
| 6841 | unsigned char buf[1000], *pos; |
| 6842 | int s, res; |
| 6843 | unsigned char addr_sta[6], addr_own[6]; |
| 6844 | char *ifname; |
| 6845 | char cbuf[100]; |
| 6846 | struct ifreq ifr; |
| 6847 | |
| 6848 | if ((dut->ap_mode == AP_11a || dut->ap_mode == AP_11na || |
| 6849 | dut->ap_mode == AP_11ac) && |
| 6850 | if_nametoindex("wlan1") > 0) |
| 6851 | ifname = "wlan1"; |
| 6852 | else |
| 6853 | ifname = "wlan0"; |
| 6854 | |
| 6855 | if (hwaddr_aton(sta_addr, addr_sta) < 0) |
| 6856 | return -1; |
| 6857 | |
| 6858 | s = socket(AF_INET, SOCK_DGRAM, 0); |
| 6859 | if (s < 0) |
| 6860 | return -1; |
| 6861 | memset(&ifr, 0, sizeof(ifr)); |
Peng Xu | b8fc5cc | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 6862 | strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name)); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6863 | if (ioctl(s, SIOCGIFHWADDR, &ifr) < 0) { |
| 6864 | perror("ioctl"); |
| 6865 | close(s); |
| 6866 | return -1; |
| 6867 | } |
| 6868 | close(s); |
| 6869 | memcpy(addr_own, ifr.ifr_hwaddr.sa_data, 6); |
| 6870 | |
| 6871 | if (if_nametoindex("sigmadut") == 0) { |
| 6872 | snprintf(cbuf, sizeof(cbuf), |
| 6873 | "iw dev %s interface add sigmadut type monitor", |
| 6874 | ifname); |
| 6875 | if (system(cbuf) != 0 || |
| 6876 | if_nametoindex("sigmadut") == 0) { |
| 6877 | sigma_dut_print(dut, DUT_MSG_ERROR, "Failed to add " |
| 6878 | "monitor interface with '%s'", cbuf); |
| 6879 | return -2; |
| 6880 | } |
| 6881 | } |
| 6882 | |
| 6883 | if (system("ifconfig sigmadut up") != 0) { |
| 6884 | sigma_dut_print(dut, DUT_MSG_ERROR, "Failed to set " |
| 6885 | "monitor interface up"); |
| 6886 | return -2; |
| 6887 | } |
| 6888 | |
| 6889 | pos = buf; |
| 6890 | |
| 6891 | /* Frame Control */ |
| 6892 | switch (frame) { |
| 6893 | case DISASSOC: |
| 6894 | *pos++ = 0xa0; |
| 6895 | break; |
| 6896 | case DEAUTH: |
| 6897 | *pos++ = 0xc0; |
| 6898 | break; |
| 6899 | case SAQUERY: |
| 6900 | *pos++ = 0xd0; |
| 6901 | break; |
| 6902 | } |
| 6903 | |
| 6904 | if (protected == INCORRECT_KEY) |
| 6905 | *pos++ = 0x40; /* Set Protected field to 1 */ |
| 6906 | else |
| 6907 | *pos++ = 0x00; |
| 6908 | |
| 6909 | /* Duration */ |
| 6910 | *pos++ = 0x00; |
| 6911 | *pos++ = 0x00; |
| 6912 | |
| 6913 | /* addr1 = DA (station) */ |
| 6914 | memcpy(pos, addr_sta, 6); |
| 6915 | pos += 6; |
| 6916 | /* addr2 = SA (own address) */ |
| 6917 | memcpy(pos, addr_own, 6); |
| 6918 | pos += 6; |
| 6919 | /* addr3 = BSSID (own address) */ |
| 6920 | memcpy(pos, addr_own, 6); |
| 6921 | pos += 6; |
| 6922 | |
| 6923 | /* Seq# (to be filled by driver/mac80211) */ |
| 6924 | *pos++ = 0x00; |
| 6925 | *pos++ = 0x00; |
| 6926 | |
| 6927 | if (protected == INCORRECT_KEY) { |
| 6928 | /* CCMP parameters */ |
| 6929 | memcpy(pos, "\x61\x01\x00\x20\x00\x10\x00\x00", 8); |
| 6930 | pos += 8; |
| 6931 | } |
| 6932 | |
| 6933 | if (protected == INCORRECT_KEY) { |
| 6934 | switch (frame) { |
| 6935 | case DEAUTH: |
| 6936 | /* Reason code (encrypted) */ |
| 6937 | memcpy(pos, "\xa7\x39", 2); |
| 6938 | pos += 2; |
| 6939 | break; |
| 6940 | case DISASSOC: |
| 6941 | /* Reason code (encrypted) */ |
| 6942 | memcpy(pos, "\xa7\x39", 2); |
| 6943 | pos += 2; |
| 6944 | break; |
| 6945 | case SAQUERY: |
| 6946 | /* Category|Action|TransID (encrypted) */ |
| 6947 | memcpy(pos, "\x6f\xbd\xe9\x4d", 4); |
| 6948 | pos += 4; |
| 6949 | break; |
| 6950 | default: |
| 6951 | return -1; |
| 6952 | } |
| 6953 | |
| 6954 | /* CCMP MIC */ |
| 6955 | memcpy(pos, "\xc8\xd8\x3b\x06\x5d\xb7\x25\x68", 8); |
| 6956 | pos += 8; |
| 6957 | } else { |
| 6958 | switch (frame) { |
| 6959 | case DEAUTH: |
| 6960 | /* reason code = 8 */ |
| 6961 | *pos++ = 0x08; |
| 6962 | *pos++ = 0x00; |
| 6963 | break; |
| 6964 | case DISASSOC: |
| 6965 | /* reason code = 8 */ |
| 6966 | *pos++ = 0x08; |
| 6967 | *pos++ = 0x00; |
| 6968 | break; |
| 6969 | case SAQUERY: |
| 6970 | /* Category - SA Query */ |
| 6971 | *pos++ = 0x08; |
| 6972 | /* SA query Action - Request */ |
| 6973 | *pos++ = 0x00; |
| 6974 | /* Transaction ID */ |
| 6975 | *pos++ = 0x12; |
| 6976 | *pos++ = 0x34; |
| 6977 | break; |
| 6978 | } |
| 6979 | } |
| 6980 | |
| 6981 | s = open_monitor("sigmadut"); |
| 6982 | if (s < 0) { |
| 6983 | send_resp(dut, conn, SIGMA_ERROR, "errorCode,Failed to open " |
| 6984 | "monitor socket"); |
| 6985 | return 0; |
| 6986 | } |
| 6987 | |
| 6988 | res = inject_frame(s, buf, pos - buf, protected == CORRECT_KEY); |
| 6989 | if (res < 0) { |
| 6990 | send_resp(dut, conn, SIGMA_ERROR, "errorCode,Failed to " |
| 6991 | "inject frame"); |
Pradeep Reddy POTTETI | 673d85c | 2016-07-26 19:08:07 +0530 | [diff] [blame] | 6992 | close(s); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6993 | return 0; |
| 6994 | } |
| 6995 | if (res < pos - buf) { |
| 6996 | send_resp(dut, conn, SIGMA_ERROR, "errorCode,Only partial " |
| 6997 | "frame sent"); |
Pradeep Reddy POTTETI | 673d85c | 2016-07-26 19:08:07 +0530 | [diff] [blame] | 6998 | close(s); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6999 | return 0; |
| 7000 | } |
| 7001 | |
| 7002 | close(s); |
| 7003 | |
| 7004 | return 1; |
| 7005 | #else /* __linux__ */ |
| 7006 | send_resp(dut, conn, SIGMA_ERROR, "errorCode,ap_send_frame not " |
| 7007 | "yet supported"); |
| 7008 | return 0; |
| 7009 | #endif /* __linux__ */ |
| 7010 | } |
| 7011 | |
| 7012 | |
| 7013 | int ap_send_frame_hs2(struct sigma_dut *dut, struct sigma_conn *conn, |
| 7014 | struct sigma_cmd *cmd) |
| 7015 | { |
| 7016 | const char *val, *dest; |
| 7017 | char buf[100]; |
| 7018 | |
| 7019 | val = get_param(cmd, "FrameName"); |
| 7020 | if (val == NULL) |
| 7021 | return -1; |
| 7022 | |
| 7023 | if (strcasecmp(val, "QoSMapConfigure") == 0) { |
| 7024 | dest = get_param(cmd, "Dest"); |
| 7025 | if (!dest) |
| 7026 | return -1; |
| 7027 | |
| 7028 | val = get_param(cmd, "QoS_MAP_SET"); |
| 7029 | if (val) { |
| 7030 | dut->ap_qos_map_set = atoi(val); |
| 7031 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_qos_map_set %d", |
| 7032 | dut->ap_qos_map_set); |
| 7033 | } |
| 7034 | |
| 7035 | if (dut->ap_qos_map_set == 1) |
| 7036 | run_hostapd_cli(dut, "set_qos_map_set " QOS_MAP_SET_1); |
| 7037 | else if (dut->ap_qos_map_set == 2) |
| 7038 | run_hostapd_cli(dut, "set_qos_map_set " QOS_MAP_SET_2); |
| 7039 | |
| 7040 | snprintf(buf, sizeof(buf), "send_qos_map_conf %s", dest); |
| 7041 | if (run_hostapd_cli(dut, buf) != 0) |
| 7042 | return -1; |
| 7043 | } |
| 7044 | |
| 7045 | return 1; |
| 7046 | } |
| 7047 | |
| 7048 | |
| 7049 | static int ath_ap_send_frame_vht(struct sigma_dut *dut, struct sigma_conn *conn, |
| 7050 | struct sigma_cmd *cmd) |
| 7051 | { |
| 7052 | const char *val; |
| 7053 | char *ifname; |
| 7054 | char buf[100]; |
| 7055 | int chwidth, nss; |
| 7056 | |
| 7057 | val = get_param(cmd, "FrameName"); |
| 7058 | if (!val || strcasecmp(val, "op_md_notif_frm") != 0) { |
| 7059 | send_resp(dut, conn, SIGMA_ERROR, |
| 7060 | "errorCode,Unsupported FrameName"); |
| 7061 | return 0; |
| 7062 | } |
| 7063 | |
| 7064 | /* |
| 7065 | * Sequence of commands for Opmode notification on |
| 7066 | * Peregrine based products |
| 7067 | */ |
| 7068 | ifname = get_main_ifname(); |
| 7069 | |
| 7070 | /* Disable STBC */ |
| 7071 | snprintf(buf, sizeof(buf), "iwpriv %s tx_stbc 0", ifname); |
| 7072 | if (system(buf) != 0) { |
| 7073 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 7074 | "iwpriv tx_stbc 0 failed!"); |
| 7075 | } |
| 7076 | |
| 7077 | /* Check whether optional arg channel width was passed */ |
| 7078 | val = get_param(cmd, "Channel_width"); |
| 7079 | if (val) { |
| 7080 | switch (atoi(val)) { |
| 7081 | case 20: |
| 7082 | chwidth = 0; |
| 7083 | break; |
| 7084 | case 40: |
| 7085 | chwidth = 1; |
| 7086 | break; |
| 7087 | case 80: |
| 7088 | chwidth = 2; |
| 7089 | break; |
| 7090 | case 160: |
| 7091 | chwidth = 3; |
| 7092 | break; |
| 7093 | default: |
| 7094 | chwidth = 2; |
| 7095 | break; |
| 7096 | } |
| 7097 | snprintf(buf, sizeof(buf), "iwpriv %s chwidth %d", |
| 7098 | ifname, chwidth); |
| 7099 | if (system(buf) != 0) { |
| 7100 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 7101 | "iwpriv chwidth failed!"); |
| 7102 | } |
| 7103 | } |
| 7104 | |
| 7105 | /* Check whether optional arg NSS was passed */ |
| 7106 | val = get_param(cmd, "NSS"); |
| 7107 | if (val) { |
| 7108 | /* Convert nss to chainmask */ |
| 7109 | switch (atoi(val)) { |
| 7110 | case 1: |
| 7111 | nss = 1; |
| 7112 | break; |
| 7113 | case 2: |
| 7114 | nss = 3; |
| 7115 | break; |
| 7116 | case 3: |
| 7117 | nss = 7; |
| 7118 | break; |
| 7119 | default: |
| 7120 | /* We do not support NSS > 3 */ |
| 7121 | nss = 3; |
| 7122 | break; |
| 7123 | } |
| 7124 | snprintf(buf, sizeof(buf), "iwpriv %s rxchainmask %d", |
| 7125 | ifname, nss); |
| 7126 | if (system(buf) != 0) { |
| 7127 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 7128 | "iwpriv rxchainmask failed!"); |
| 7129 | } |
| 7130 | } |
| 7131 | |
| 7132 | /* Send the opmode notification */ |
Sunil Dutt | 27ec7f6 | 2017-09-14 18:22:59 +0300 | [diff] [blame] | 7133 | snprintf(buf, sizeof(buf), "iwpriv %s opmode_notify 1", ifname); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7134 | if (system(buf) != 0) { |
| 7135 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 7136 | "iwpriv opmode_notify failed!"); |
| 7137 | } |
| 7138 | |
| 7139 | return 1; |
| 7140 | } |
| 7141 | |
| 7142 | |
priyadharshini gowthaman | a27b5b6 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 7143 | static int ath_ap_send_frame_loc(struct sigma_dut *dut, struct sigma_conn *conn, |
| 7144 | struct sigma_cmd *cmd) |
| 7145 | { |
| 7146 | const char *val; |
| 7147 | FILE *f; |
priyadharshini gowthaman | a61badd | 2016-08-16 13:37:27 -0700 | [diff] [blame] | 7148 | int rand_int = 0; |
priyadharshini gowthaman | a27b5b6 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 7149 | |
| 7150 | val = get_param(cmd, "MsntType"); |
| 7151 | if (val) { |
| 7152 | if (dut->ap_msnt_type == 0) |
| 7153 | dut->ap_msnt_type = atoi(val); |
| 7154 | |
| 7155 | if (dut->ap_msnt_type != 5 && dut->ap_msnt_type != 2) { |
| 7156 | dut->ap_msnt_type = atoi(val); |
| 7157 | if (dut->ap_msnt_type == 1) { |
priyadharshini gowthaman | a61badd | 2016-08-16 13:37:27 -0700 | [diff] [blame] | 7158 | val = get_param(cmd, "RandInterval"); |
| 7159 | if (val) |
| 7160 | rand_int = atoi(val); |
priyadharshini gowthaman | a27b5b6 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 7161 | f = fopen("/tmp/ftmrr.txt", "a"); |
| 7162 | if (!f) { |
| 7163 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 7164 | "Failed to open /tmp/ftmrr.txt"); |
| 7165 | return -1; |
| 7166 | } |
| 7167 | |
| 7168 | fprintf(f, "sta_mac = %s\n", cmd->values[3]); |
priyadharshini gowthaman | a61badd | 2016-08-16 13:37:27 -0700 | [diff] [blame] | 7169 | 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", |
| 7170 | rand_int, cmd->values[7]); |
priyadharshini gowthaman | a27b5b6 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 7171 | fclose(f); |
| 7172 | dut->ap_msnt_type = 5; |
| 7173 | run_system(dut, "wpc -f /tmp/ftmrr.txt"); |
| 7174 | } |
| 7175 | } else if (dut->ap_msnt_type == 5) { |
| 7176 | run_system(dut, "wpc -f /tmp/ftmrr.txt"); |
| 7177 | } else if (dut->ap_msnt_type == 2) { |
| 7178 | f = fopen("/tmp/wru.txt", "w"); |
| 7179 | if (!f) { |
| 7180 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 7181 | "Failed to open /tmp/wru.txt"); |
| 7182 | return -1; |
| 7183 | } |
| 7184 | |
| 7185 | fprintf(f, "sta_mac = %s\n", cmd->values[3]); |
| 7186 | fprintf(f, "meas_type = 0x08\ndialogtoken = 0x1\nnum_repetitions = 0x0\nmeas_token = 0x1\nmeas_req_mode = 0x00\nloc_subject = 0x01\n"); |
| 7187 | fclose(f); |
| 7188 | run_system(dut, "wpc -w /tmp/wru.txt"); |
| 7189 | } |
| 7190 | } |
| 7191 | return 1; |
| 7192 | } |
| 7193 | |
| 7194 | |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 7195 | /* |
| 7196 | * The following functions parse_send_frame_params_int(), |
| 7197 | * parse_send_frame_params_str(), and parse_send_frame_params_mac() |
| 7198 | * are used by ath_ap_send_frame_bcn_rpt_req(). |
| 7199 | * Beacon Report Request is a frame used as part of the MBO program. |
| 7200 | * The command for sending beacon report has a lot of |
| 7201 | * arguments and having these functions reduces code size. |
| 7202 | * |
| 7203 | */ |
| 7204 | static int parse_send_frame_params_int(char *param, struct sigma_cmd *cmd, |
| 7205 | struct sigma_dut *dut, |
| 7206 | char *buf, size_t buf_size) |
| 7207 | { |
| 7208 | const char *str_val; |
| 7209 | int int_val; |
| 7210 | char temp[100]; |
| 7211 | |
| 7212 | str_val = get_param(cmd, param); |
| 7213 | if (!str_val) { |
| 7214 | sigma_dut_print(dut, DUT_MSG_ERROR, "%s not given", param); |
| 7215 | return -1; |
| 7216 | } |
| 7217 | int_val = atoi(str_val); |
| 7218 | snprintf(temp, sizeof(temp), " %d", int_val); |
Peng Xu | 591be45 | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 7219 | strlcat(buf, temp, buf_size); |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 7220 | return 0; |
| 7221 | } |
| 7222 | |
| 7223 | |
| 7224 | static int parse_send_frame_params_str(char *param, struct sigma_cmd *cmd, |
| 7225 | struct sigma_dut *dut, |
| 7226 | char *buf, size_t buf_size) |
| 7227 | { |
| 7228 | const char *str_val; |
| 7229 | char temp[100]; |
| 7230 | |
| 7231 | str_val = get_param(cmd, param); |
| 7232 | if (!str_val) { |
| 7233 | sigma_dut_print(dut, DUT_MSG_ERROR, "%s not given", param); |
| 7234 | return -1; |
| 7235 | } |
| 7236 | snprintf(temp, sizeof(temp), " %s", str_val); |
| 7237 | temp[sizeof(temp) - 1] = '\0'; |
Peng Xu | 591be45 | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 7238 | strlcat(buf, temp, buf_size); |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 7239 | return 0; |
| 7240 | } |
| 7241 | |
| 7242 | |
| 7243 | static int parse_send_frame_params_mac(char *param, struct sigma_cmd *cmd, |
| 7244 | struct sigma_dut *dut, |
| 7245 | char *buf, size_t buf_size) |
| 7246 | { |
| 7247 | const char *str_val; |
| 7248 | unsigned char mac[6]; |
| 7249 | char temp[100]; |
| 7250 | |
| 7251 | str_val = get_param(cmd, param); |
| 7252 | if (!str_val) { |
| 7253 | sigma_dut_print(dut, DUT_MSG_ERROR, "%s not given", param); |
| 7254 | return -1; |
| 7255 | } |
| 7256 | |
| 7257 | if (parse_mac_address(dut, str_val, mac) < 0) { |
| 7258 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 7259 | "MAC Address not in proper format"); |
| 7260 | return -1; |
| 7261 | } |
| 7262 | snprintf(temp, sizeof(temp), " %02x:%02x:%02x:%02x:%02x:%02x", |
| 7263 | mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]); |
Peng Xu | 591be45 | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 7264 | strlcat(buf, temp, buf_size); |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 7265 | return 0; |
| 7266 | } |
| 7267 | |
| 7268 | |
| 7269 | static void fill_1_or_0_based_on_presence(struct sigma_cmd *cmd, char *param, |
| 7270 | char *buf, size_t buf_size) |
| 7271 | { |
| 7272 | const char *str_val; |
| 7273 | char *value = " 1"; |
| 7274 | |
| 7275 | str_val = get_param(cmd, param); |
| 7276 | if (!str_val || str_val[0] == '\0') |
| 7277 | value = " 0"; |
Peng Xu | 591be45 | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 7278 | strlcat(buf, value, buf_size); |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 7279 | |
| 7280 | } |
| 7281 | |
| 7282 | |
| 7283 | /* |
| 7284 | * wifitool athN sendbcnrpt |
| 7285 | * <STA MAC - Plugs in from Dest_MAC> |
| 7286 | * <regclass - Plugs in from RegClass - int> |
| 7287 | * <channum - Plugs in from Channel PARAM of dev_send_frame - int> |
| 7288 | * <rand_ivl - Plugs in from RandInt - string> |
| 7289 | * <duration - Plugs in from MeaDur - integer> |
| 7290 | * <mode - Plugs in from MeaMode - string> |
| 7291 | * <req_ssid - Plugs in from SSID PARAM of dev_send_frame - string> |
| 7292 | * <rep_cond - Plugs in from RptCond - integer> |
| 7293 | * <rpt_detail - Plugs in from RptDet - integer> |
| 7294 | * <req_ie - Plugs in from ReqInfo PARAM of dev_send_frame - string> |
| 7295 | * <chanrpt_mode - Plugs in from APChanRpt - integer> |
| 7296 | * <specific_bssid - Plugs in from BSSID PARAM of dev_send_frame> |
| 7297 | * [AP channel numbers] |
| 7298 | */ |
| 7299 | static int ath_ap_send_frame_bcn_rpt_req(struct sigma_dut *dut, |
| 7300 | struct sigma_cmd *cmd, |
| 7301 | const char *ifname) |
| 7302 | { |
| 7303 | char buf[100]; |
| 7304 | int rpt_det; |
| 7305 | const char *str_val; |
| 7306 | const char *mea_mode; |
| 7307 | |
| 7308 | snprintf(buf, sizeof(buf), "wifitool %s sendbcnrpt", ifname); |
| 7309 | |
| 7310 | if (parse_send_frame_params_mac("Dest_MAC", cmd, dut, buf, sizeof(buf))) |
| 7311 | return -1; |
| 7312 | if (parse_send_frame_params_int("RegClass", cmd, dut, buf, sizeof(buf))) |
| 7313 | return -1; |
| 7314 | if (parse_send_frame_params_int("Channel", cmd, dut, buf, sizeof(buf))) |
| 7315 | return -1; |
| 7316 | if (parse_send_frame_params_str("RandInt", cmd, dut, buf, sizeof(buf))) |
| 7317 | return -1; |
| 7318 | if (parse_send_frame_params_int("MeaDur", cmd, dut, buf, sizeof(buf))) |
| 7319 | return -1; |
| 7320 | |
| 7321 | str_val = get_param(cmd, "MeaMode"); |
| 7322 | if (!str_val) { |
| 7323 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 7324 | "MeaMode parameter not present in send bcn-rpt-req"); |
| 7325 | return -1; |
| 7326 | } |
| 7327 | if (strcasecmp(str_val, "passive") == 0) { |
| 7328 | mea_mode = " 0"; |
| 7329 | } else if (strcasecmp(str_val, "active") == 0) { |
| 7330 | mea_mode = " 1"; |
| 7331 | } else if (strcasecmp(str_val, "table") == 0) { |
| 7332 | mea_mode = " 2"; |
| 7333 | } else { |
| 7334 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 7335 | "MEA-MODE Value not correctly given"); |
| 7336 | return -1; |
| 7337 | } |
Peng Xu | 591be45 | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 7338 | strlcat(buf, mea_mode, sizeof(buf)); |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 7339 | |
| 7340 | fill_1_or_0_based_on_presence(cmd, "SSID", buf, sizeof(buf)); |
| 7341 | |
| 7342 | if (parse_send_frame_params_int("RptCond", cmd, dut, buf, sizeof(buf))) |
| 7343 | return -1; |
| 7344 | |
| 7345 | if (parse_send_frame_params_int("RptDet", cmd, dut, buf, sizeof(buf))) |
| 7346 | return -1; |
| 7347 | str_val = get_param(cmd, "RptDet"); |
| 7348 | rpt_det = str_val ? atoi(str_val) : 0; |
| 7349 | |
| 7350 | if (rpt_det) |
| 7351 | fill_1_or_0_based_on_presence(cmd, "ReqInfo", buf, sizeof(buf)); |
| 7352 | else |
Peng Xu | 591be45 | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 7353 | strlcat(buf, " 0", sizeof(buf)); |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 7354 | |
| 7355 | if (rpt_det) |
| 7356 | fill_1_or_0_based_on_presence(cmd, "APChanRpt", buf, |
| 7357 | sizeof(buf)); |
| 7358 | else |
Peng Xu | 591be45 | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 7359 | strlcat(buf, " 0", sizeof(buf)); |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 7360 | |
| 7361 | if (parse_send_frame_params_mac("BSSID", cmd, dut, buf, sizeof(buf))) |
| 7362 | return -1; |
| 7363 | |
| 7364 | run_system(dut, buf); |
| 7365 | return 0; |
| 7366 | } |
| 7367 | |
| 7368 | |
| 7369 | static void inform_and_sleep(struct sigma_dut *dut, int seconds) |
| 7370 | { |
| 7371 | sigma_dut_print(dut, DUT_MSG_DEBUG, "sleeping for %d seconds", seconds); |
| 7372 | sleep(seconds); |
| 7373 | sigma_dut_print(dut, DUT_MSG_DEBUG, "woke up after %d seconds", |
| 7374 | seconds); |
| 7375 | } |
| 7376 | |
| 7377 | |
| 7378 | static int ath_ap_send_frame_btm_req(struct sigma_dut *dut, |
| 7379 | struct sigma_cmd *cmd, const char *ifname) |
| 7380 | { |
| 7381 | unsigned char mac_addr[ETH_ALEN]; |
| 7382 | int disassoc_timer; |
| 7383 | char buf[100]; |
| 7384 | const char *val; |
| 7385 | int cand_list = 1; |
| 7386 | int tsf = 2; |
| 7387 | |
| 7388 | val = get_param(cmd, "Dest_MAC"); |
| 7389 | if (!val || parse_mac_address(dut, val, mac_addr) < 0) { |
| 7390 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 7391 | "MAC Address not in proper format"); |
| 7392 | return -1; |
| 7393 | } |
| 7394 | |
| 7395 | val = get_param(cmd, "Disassoc_Timer"); |
| 7396 | if (val) |
| 7397 | disassoc_timer = atoi(val); |
| 7398 | else |
| 7399 | disassoc_timer = dut->ap_disassoc_timer; |
| 7400 | |
| 7401 | val = get_param(cmd, "Cand_List"); |
| 7402 | if (val && val[0]) |
| 7403 | cand_list = atoi(val); |
| 7404 | |
| 7405 | val = get_param(cmd, "BTMQuery_Reason_Code"); |
| 7406 | if (val) { |
| 7407 | snprintf(buf, sizeof(buf), "iwpriv %s mbo_trans_rs %s", |
| 7408 | ifname, val); |
| 7409 | run_system(dut, buf); |
| 7410 | } |
| 7411 | |
| 7412 | snprintf(buf, sizeof(buf), |
| 7413 | "wifitool %s sendbstmreq %02x:%02x:%02x:%02x:%02x:%02x %d %d 3 %d %d %d %d", |
| 7414 | ifname, mac_addr[0], mac_addr[1], mac_addr[2], mac_addr[3], |
| 7415 | mac_addr[4], mac_addr[5], cand_list, disassoc_timer, |
| 7416 | dut->ap_btmreq_disassoc_imnt, |
| 7417 | dut->ap_btmreq_term_bit, |
| 7418 | tsf, |
| 7419 | dut->ap_btmreq_bss_term_dur); |
| 7420 | run_system(dut, buf); |
| 7421 | |
| 7422 | if (dut->ap_btmreq_term_bit) { |
| 7423 | inform_and_sleep(dut, 3); |
| 7424 | run_system_wrapper(dut, "ifconfig %s down", ifname); |
| 7425 | inform_and_sleep(dut, dut->ap_btmreq_bss_term_dur * 60); |
| 7426 | run_system_wrapper(dut, "ifconfig %s up", ifname); |
| 7427 | } else if (dut->ap_btmreq_disassoc_imnt) { |
| 7428 | inform_and_sleep(dut, (disassoc_timer / 1000) + 1); |
| 7429 | run_system_wrapper(dut, |
| 7430 | "iwpriv %s kickmac %02x:%02x:%02x:%02x:%02x:%02x", |
| 7431 | ifname, |
| 7432 | mac_addr[0], mac_addr[1], mac_addr[2], |
| 7433 | mac_addr[3], mac_addr[4], mac_addr[5]); |
| 7434 | } |
| 7435 | return 0; |
| 7436 | } |
| 7437 | |
| 7438 | |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 7439 | static int ath_ap_send_frame_mbo(struct sigma_dut *dut, struct sigma_conn *conn, |
| 7440 | struct sigma_cmd *cmd) |
| 7441 | { |
| 7442 | const char *val; |
| 7443 | char *ifname; |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 7444 | |
| 7445 | ifname = get_main_ifname(); |
| 7446 | |
| 7447 | val = get_param(cmd, "FrameName"); |
| 7448 | if (!val) |
| 7449 | return -1; |
| 7450 | |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 7451 | if (strcasecmp(val, "BTMReq") == 0) |
| 7452 | ath_ap_send_frame_btm_req(dut, cmd, ifname); |
| 7453 | else if (strcasecmp(val, "BcnRptReq") == 0) |
| 7454 | ath_ap_send_frame_bcn_rpt_req(dut, cmd, ifname); |
| 7455 | else |
| 7456 | return -1; |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 7457 | |
| 7458 | return 1; |
| 7459 | } |
| 7460 | |
| 7461 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7462 | static int ap_send_frame_vht(struct sigma_dut *dut, struct sigma_conn *conn, |
| 7463 | struct sigma_cmd *cmd) |
| 7464 | { |
| 7465 | switch (get_driver_type()) { |
| 7466 | case DRIVER_ATHEROS: |
| 7467 | return ath_ap_send_frame_vht(dut, conn, cmd); |
| 7468 | break; |
| 7469 | case DRIVER_OPENWRT: |
| 7470 | switch (get_openwrt_driver_type()) { |
| 7471 | case OPENWRT_DRIVER_ATHEROS: |
| 7472 | return ath_ap_send_frame_vht(dut, conn, cmd); |
| 7473 | default: |
| 7474 | send_resp(dut, conn, SIGMA_ERROR, |
| 7475 | "errorCode,Unsupported ap_send_frame with the current openwrt driver"); |
| 7476 | return 0; |
| 7477 | } |
| 7478 | default: |
| 7479 | send_resp(dut, conn, SIGMA_ERROR, |
| 7480 | "errorCode,Unsupported ap_send_frame with the current driver"); |
| 7481 | return 0; |
| 7482 | } |
| 7483 | } |
| 7484 | |
| 7485 | |
priyadharshini gowthaman | a27b5b6 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 7486 | static int ap_send_frame_loc(struct sigma_dut *dut, struct sigma_conn *conn, |
| 7487 | struct sigma_cmd *cmd) |
| 7488 | { |
| 7489 | switch (get_driver_type()) { |
| 7490 | case DRIVER_ATHEROS: |
| 7491 | return ath_ap_send_frame_loc(dut, conn, cmd); |
| 7492 | case DRIVER_OPENWRT: |
| 7493 | switch (get_openwrt_driver_type()) { |
| 7494 | case OPENWRT_DRIVER_ATHEROS: |
| 7495 | return ath_ap_send_frame_loc(dut, conn, cmd); |
| 7496 | default: |
| 7497 | send_resp(dut, conn, SIGMA_ERROR, |
| 7498 | "errorCode,Unsupported ap_send_frame_loc with the current openwrt driver"); |
| 7499 | return 0; |
| 7500 | } |
| 7501 | default: |
| 7502 | send_resp(dut, conn, SIGMA_ERROR, |
| 7503 | "errorCode,Unsupported ap_send_frame_loc with the current driver"); |
| 7504 | return 0; |
| 7505 | } |
| 7506 | } |
| 7507 | |
| 7508 | |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 7509 | static int ap_send_frame_mbo(struct sigma_dut *dut, struct sigma_conn *conn, |
| 7510 | struct sigma_cmd *cmd) |
| 7511 | { |
| 7512 | switch (get_driver_type()) { |
| 7513 | case DRIVER_ATHEROS: |
| 7514 | return ath_ap_send_frame_mbo(dut, conn, cmd); |
| 7515 | case DRIVER_OPENWRT: |
| 7516 | switch (get_openwrt_driver_type()) { |
| 7517 | case OPENWRT_DRIVER_ATHEROS: |
| 7518 | return ath_ap_send_frame_mbo(dut, conn, cmd); |
| 7519 | default: |
| 7520 | send_resp(dut, conn, SIGMA_ERROR, |
| 7521 | "errorCode,Unsupported ap_send_frame with the current openwrt driver"); |
| 7522 | return 0; |
| 7523 | } |
| 7524 | default: |
| 7525 | send_resp(dut, conn, SIGMA_ERROR, |
| 7526 | "errorCode,Unsupported ap_send_frame with the current driver"); |
| 7527 | return 0; |
| 7528 | } |
| 7529 | } |
| 7530 | |
| 7531 | |
Lior David | 0fe101e | 2017-03-09 16:09:50 +0200 | [diff] [blame] | 7532 | static int ap_send_frame_60g(struct sigma_dut *dut, |
| 7533 | struct sigma_conn *conn, |
| 7534 | struct sigma_cmd *cmd) |
| 7535 | { |
| 7536 | switch (get_driver_type()) { |
| 7537 | #ifdef __linux__ |
| 7538 | case DRIVER_WIL6210: |
| 7539 | return wil6210_send_frame_60g(dut, conn, cmd); |
| 7540 | #endif /* __linux__ */ |
| 7541 | default: |
| 7542 | send_resp(dut, conn, SIGMA_ERROR, |
| 7543 | "errorCode,Unsupported sta_set_frame(60G) with the current driver"); |
| 7544 | return 0; |
| 7545 | } |
| 7546 | } |
| 7547 | |
| 7548 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7549 | int cmd_ap_send_frame(struct sigma_dut *dut, struct sigma_conn *conn, |
| 7550 | struct sigma_cmd *cmd) |
| 7551 | { |
| 7552 | /* const char *name = get_param(cmd, "NAME"); */ |
| 7553 | /* const char *ifname = get_param(cmd, "INTERFACE"); */ |
| 7554 | const char *val; |
| 7555 | enum send_frame_type frame; |
| 7556 | enum send_frame_protection protected; |
| 7557 | char buf[100]; |
| 7558 | |
| 7559 | val = get_param(cmd, "Program"); |
| 7560 | if (val) { |
| 7561 | if (strcasecmp(val, "HS2") == 0 || |
Adil Saeed Musthafa | 33ea287 | 2017-04-10 23:13:24 -0700 | [diff] [blame] | 7562 | strcasecmp(val, "HS2-R2") == 0 || |
| 7563 | strcasecmp(val, "IOTLP") == 0) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7564 | return ap_send_frame_hs2(dut, conn, cmd); |
| 7565 | if (strcasecmp(val, "VHT") == 0) |
| 7566 | return ap_send_frame_vht(dut, conn, cmd); |
priyadharshini gowthaman | a27b5b6 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 7567 | if (strcasecmp(val, "LOC") == 0) |
| 7568 | return ap_send_frame_loc(dut, conn, cmd); |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 7569 | if (strcasecmp(val, "MBO") == 0) |
| 7570 | return ap_send_frame_mbo(dut, conn, cmd); |
Lior David | 0fe101e | 2017-03-09 16:09:50 +0200 | [diff] [blame] | 7571 | if (strcasecmp(val, "60GHz") == 0) |
| 7572 | return ap_send_frame_60g(dut, conn, cmd); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7573 | } |
| 7574 | |
| 7575 | val = get_param(cmd, "PMFFrameType"); |
| 7576 | if (val == NULL) |
| 7577 | val = get_param(cmd, "FrameName"); |
| 7578 | if (val == NULL) |
| 7579 | val = get_param(cmd, "Type"); |
| 7580 | if (val == NULL) |
| 7581 | return -1; |
| 7582 | if (strcasecmp(val, "disassoc") == 0) |
| 7583 | frame = DISASSOC; |
| 7584 | else if (strcasecmp(val, "deauth") == 0) |
| 7585 | frame = DEAUTH; |
| 7586 | else if (strcasecmp(val, "saquery") == 0) |
| 7587 | frame = SAQUERY; |
| 7588 | else { |
| 7589 | send_resp(dut, conn, SIGMA_ERROR, "errorCode,Unsupported " |
| 7590 | "PMFFrameType"); |
| 7591 | return 0; |
| 7592 | } |
| 7593 | |
| 7594 | val = get_param(cmd, "PMFProtected"); |
| 7595 | if (val == NULL) |
| 7596 | val = get_param(cmd, "Protected"); |
| 7597 | if (val == NULL) |
| 7598 | return -1; |
| 7599 | if (strcasecmp(val, "Correct-key") == 0 || |
| 7600 | strcasecmp(val, "CorrectKey") == 0) |
| 7601 | protected = CORRECT_KEY; |
| 7602 | else if (strcasecmp(val, "IncorrectKey") == 0) |
| 7603 | protected = INCORRECT_KEY; |
| 7604 | else if (strcasecmp(val, "Unprotected") == 0) |
| 7605 | protected = UNPROTECTED; |
| 7606 | else { |
| 7607 | send_resp(dut, conn, SIGMA_ERROR, "errorCode,Unsupported " |
| 7608 | "PMFProtected"); |
| 7609 | return 0; |
| 7610 | } |
| 7611 | |
| 7612 | val = get_param(cmd, "stationID"); |
| 7613 | if (val == NULL) |
| 7614 | return -1; |
| 7615 | |
| 7616 | if (protected == INCORRECT_KEY || |
| 7617 | (protected == UNPROTECTED && frame == SAQUERY)) |
| 7618 | return ap_inject_frame(dut, conn, frame, protected, val); |
| 7619 | |
| 7620 | switch (frame) { |
| 7621 | case DISASSOC: |
| 7622 | snprintf(buf, sizeof(buf), "disassoc %s test=%d", |
| 7623 | val, protected == CORRECT_KEY); |
| 7624 | break; |
| 7625 | case DEAUTH: |
| 7626 | snprintf(buf, sizeof(buf), "deauth %s test=%d", |
| 7627 | val, protected == CORRECT_KEY); |
| 7628 | break; |
| 7629 | case SAQUERY: |
| 7630 | snprintf(buf, sizeof(buf), "sa_query %s", val); |
| 7631 | break; |
| 7632 | } |
| 7633 | |
| 7634 | if (run_hostapd_cli(dut, buf) != 0) |
| 7635 | return -2; |
| 7636 | |
| 7637 | return 1; |
| 7638 | } |
| 7639 | |
| 7640 | |
| 7641 | static int cmd_ap_get_mac_address(struct sigma_dut *dut, |
| 7642 | struct sigma_conn *conn, |
| 7643 | struct sigma_cmd *cmd) |
| 7644 | { |
| 7645 | #if defined( __linux__) |
| 7646 | /* const char *name = get_param(cmd, "NAME"); */ |
| 7647 | /* const char *ifname = get_param(cmd, "INTERFACE"); */ |
Jouni Malinen | f898464 | 2017-10-12 00:02:37 +0300 | [diff] [blame] | 7648 | char resp[100]; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7649 | unsigned char addr[6]; |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 7650 | char ifname[50]; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7651 | struct ifreq ifr; |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 7652 | int s, wlan_tag = 1; |
| 7653 | const char *val; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7654 | |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 7655 | val = get_param(cmd, "WLAN_TAG"); |
| 7656 | if (val) { |
| 7657 | wlan_tag = atoi(val); |
| 7658 | if (wlan_tag < 1 || wlan_tag > 3) { |
| 7659 | /* |
| 7660 | * The only valid WLAN Tags as of now as per the latest |
| 7661 | * WFA scripts are 1, 2, and 3. |
| 7662 | */ |
Jouni Malinen | f898464 | 2017-10-12 00:02:37 +0300 | [diff] [blame] | 7663 | send_resp(dut, conn, SIGMA_ERROR, |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 7664 | "errorCode,Unsupported WLAN_TAG"); |
| 7665 | return 0; |
| 7666 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7667 | } |
| 7668 | |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 7669 | get_if_name(dut, ifname, sizeof(ifname), wlan_tag); |
| 7670 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7671 | s = socket(AF_INET, SOCK_DGRAM, 0); |
| 7672 | if (s < 0) |
| 7673 | return -1; |
| 7674 | memset(&ifr, 0, sizeof(ifr)); |
Peng Xu | b8fc5cc | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 7675 | strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name)); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7676 | if (ioctl(s, SIOCGIFHWADDR, &ifr) < 0) { |
| 7677 | perror("ioctl"); |
| 7678 | close(s); |
Jouni Malinen | f898464 | 2017-10-12 00:02:37 +0300 | [diff] [blame] | 7679 | snprintf(resp, sizeof(resp), |
| 7680 | "errorCode,Could not find interface %s", ifname); |
| 7681 | send_resp(dut, conn, SIGMA_ERROR, resp); |
| 7682 | return 0; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7683 | } |
| 7684 | close(s); |
| 7685 | memcpy(addr, ifr.ifr_hwaddr.sa_data, 6); |
| 7686 | |
| 7687 | snprintf(resp, sizeof(resp), "mac,%02x:%02x:%02x:%02x:%02x:%02x", |
| 7688 | addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]); |
| 7689 | send_resp(dut, conn, SIGMA_COMPLETE, resp); |
| 7690 | return 0; |
| 7691 | #elif defined( __QNXNTO__) |
| 7692 | char resp[50]; |
| 7693 | unsigned char addr[6]; |
| 7694 | |
| 7695 | if (!sigma_main_ifname) { |
| 7696 | send_resp(dut, conn, SIGMA_ERROR, "ifname is null"); |
| 7697 | return 0; |
| 7698 | } |
| 7699 | |
| 7700 | if (get_hwaddr(sigma_main_ifname, addr) != 0) { |
| 7701 | send_resp(dut, conn, SIGMA_ERROR, |
| 7702 | "errorCode,Failed to get address"); |
| 7703 | return 0; |
| 7704 | } |
| 7705 | snprintf(resp, sizeof(resp), "mac,%02x:%02x:%02x:%02x:%02x:%02x", |
| 7706 | addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]); |
| 7707 | send_resp(dut, conn, SIGMA_COMPLETE, resp); |
| 7708 | return 0; |
| 7709 | #else /* __linux__ */ |
| 7710 | send_resp(dut, conn, SIGMA_ERROR, "errorCode,ap_get_mac_address not " |
| 7711 | "yet supported"); |
| 7712 | return 0; |
| 7713 | #endif /* __linux__ */ |
| 7714 | } |
| 7715 | |
| 7716 | |
| 7717 | static int cmd_ap_set_pmf(struct sigma_dut *dut, struct sigma_conn *conn, |
| 7718 | struct sigma_cmd *cmd) |
| 7719 | { |
| 7720 | /* |
| 7721 | * Ignore the command since the parameters are already handled through |
| 7722 | * ap_set_security. |
| 7723 | */ |
| 7724 | |
| 7725 | return 1; |
| 7726 | } |
| 7727 | |
| 7728 | |
| 7729 | static int cmd_ap_set_hs2(struct sigma_dut *dut, struct sigma_conn *conn, |
| 7730 | struct sigma_cmd *cmd) |
| 7731 | { |
| 7732 | /* const char *name = get_param(cmd, "NAME"); */ |
| 7733 | /* const char *ifname = get_param(cmd, "INTERFACE"); */ |
| 7734 | const char *val, *dest; |
| 7735 | char *pos, buf[100]; |
| 7736 | int i, wlan_tag = 1; |
| 7737 | |
| 7738 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_set_hs2: Processing the " |
| 7739 | "following parameters"); |
| 7740 | for (i = 0; i < cmd->count; i++) { |
| 7741 | sigma_dut_print(dut, DUT_MSG_INFO, "%s %s", cmd->params[i], |
| 7742 | (cmd->values[i] ? cmd->values[i] : "NULL")); |
| 7743 | } |
| 7744 | |
| 7745 | val = get_param(cmd, "ICMPv4_ECHO"); |
| 7746 | if (val && atoi(val)) { |
| 7747 | snprintf(buf, sizeof(buf), "ebtables -F"); |
| 7748 | if (system(buf) != 0) { |
| 7749 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 7750 | "Failed to set ebtables rules, RULE-12"); |
| 7751 | } |
| 7752 | return 1; |
| 7753 | } |
| 7754 | |
| 7755 | val = get_param(cmd, "WLAN_TAG"); |
| 7756 | if (val) { |
| 7757 | wlan_tag = atoi(val); |
| 7758 | if (wlan_tag != 1 && wlan_tag != 2) { |
| 7759 | send_resp(dut, conn, SIGMA_INVALID, |
| 7760 | "errorCode,Invalid WLAN_TAG"); |
| 7761 | return 0; |
| 7762 | } |
| 7763 | } |
| 7764 | |
| 7765 | if (wlan_tag == 2) { |
| 7766 | val = get_param(cmd, "PROXY_ARP"); |
| 7767 | if (val) |
| 7768 | dut->ap2_proxy_arp = atoi(val); |
| 7769 | return 1; |
| 7770 | } |
| 7771 | |
| 7772 | dest = get_param(cmd, "STA_MAC"); |
| 7773 | if (dest) { |
| 7774 | /* This is a special/ugly way of using this command. |
| 7775 | * If "Dest" MAC is included, assume that this command |
| 7776 | * is being issued after ap_config_commit for dynamically |
| 7777 | * setting the QoS Map Set. |
| 7778 | */ |
| 7779 | val = get_param(cmd, "QoS_MAP_SET"); |
| 7780 | if (val) { |
| 7781 | dut->ap_qos_map_set = atoi(val); |
| 7782 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_qos_map_set %d", |
| 7783 | dut->ap_qos_map_set); |
| 7784 | } |
| 7785 | |
| 7786 | if (dut->ap_qos_map_set == 1) |
| 7787 | run_hostapd_cli(dut, "set_qos_map_set " QOS_MAP_SET_1); |
| 7788 | else if (dut->ap_qos_map_set == 2) |
| 7789 | run_hostapd_cli(dut, "set_qos_map_set " QOS_MAP_SET_2); |
| 7790 | |
| 7791 | snprintf(buf, sizeof(buf), "send_qos_map_conf %s", dest); |
| 7792 | if (run_hostapd_cli(dut, buf) != 0) |
| 7793 | return -1; |
| 7794 | } |
| 7795 | |
| 7796 | val = get_param(cmd, "DGAF_DISABLE"); |
| 7797 | if (val) |
| 7798 | dut->ap_dgaf_disable = atoi(val); |
| 7799 | |
| 7800 | dut->ap_interworking = 1; |
| 7801 | |
| 7802 | val = get_param(cmd, "INTERWORKING"); |
| 7803 | if (val == NULL) |
| 7804 | val = get_param(cmd, "INTERNETWORKING"); |
| 7805 | if (val != NULL && atoi(val) == 0) { |
| 7806 | dut->ap_interworking = 0; |
| 7807 | dut->ap_hs2 = 0; |
| 7808 | return 1; |
| 7809 | } |
| 7810 | |
| 7811 | val = get_param(cmd, "ACCS_NET_TYPE"); |
| 7812 | if (val) { |
| 7813 | if (strcasecmp(val, "Chargeable_Public_Network") == 0 || |
| 7814 | strcasecmp(val, "Chargable_Public_Network") == 0 || |
| 7815 | strcasecmp(val, "Chargable Public Network") == 0) |
| 7816 | dut->ap_access_net_type = 2; |
| 7817 | else |
| 7818 | dut->ap_access_net_type = atoi(val); |
| 7819 | } |
| 7820 | |
| 7821 | val = get_param(cmd, "INTERNET"); |
| 7822 | if (val) |
| 7823 | dut->ap_internet = atoi(val); |
| 7824 | |
| 7825 | val = get_param(cmd, "VENUE_GRP"); |
| 7826 | if (val) { |
| 7827 | if (strcasecmp(val, "Business") == 0) |
| 7828 | dut->ap_venue_group = 2; |
| 7829 | else |
| 7830 | dut->ap_venue_group = atoi(val); |
| 7831 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_venue_name %d", |
| 7832 | dut->ap_venue_name); |
| 7833 | } |
| 7834 | |
| 7835 | val = get_param(cmd, "VENUE_TYPE"); |
| 7836 | if (val) { |
| 7837 | if (strcasecmp(val, "R&D") == 0) |
| 7838 | dut->ap_venue_type = 8; |
| 7839 | else |
| 7840 | dut->ap_venue_type = atoi(val); |
| 7841 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_venue_type %d", |
| 7842 | dut->ap_venue_type); |
| 7843 | } |
| 7844 | |
| 7845 | val = get_param(cmd, "HESSID"); |
| 7846 | if (val) { |
| 7847 | if (strlen(val) >= sizeof(dut->ap_hessid)) { |
| 7848 | send_resp(dut, conn, SIGMA_ERROR, |
| 7849 | "errorCode,Invalid HESSID"); |
| 7850 | return 0; |
| 7851 | } |
| 7852 | snprintf(dut->ap_hessid, sizeof(dut->ap_hessid), "%s", val); |
| 7853 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_hessid %s", |
| 7854 | dut->ap_hessid); |
| 7855 | } |
| 7856 | |
| 7857 | val = get_param(cmd, "ROAMING_CONS"); |
| 7858 | if (val) { |
| 7859 | if (strlen(val) >= sizeof(dut->ap_roaming_cons)) { |
| 7860 | send_resp(dut, conn, SIGMA_ERROR, |
| 7861 | "errorCode,Invalid ROAMING_CONS"); |
| 7862 | return 0; |
| 7863 | } |
| 7864 | if (strcasecmp(val, "Disabled") == 0) { |
| 7865 | dut->ap_roaming_cons[0] = '\0'; |
| 7866 | } else { |
| 7867 | snprintf(dut->ap_roaming_cons, |
| 7868 | sizeof(dut->ap_roaming_cons), "%s", val); |
| 7869 | } |
| 7870 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_roaming_cons %s", |
| 7871 | dut->ap_roaming_cons); |
| 7872 | } |
| 7873 | |
| 7874 | val = get_param(cmd, "ANQP"); |
| 7875 | if (val) |
| 7876 | dut->ap_anqpserver_on = atoi(val); |
| 7877 | |
| 7878 | val = get_param(cmd, "NAI_REALM_LIST"); |
| 7879 | if (val) { |
| 7880 | dut->ap_nai_realm_list = atoi(val); |
| 7881 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_nai_realm_list %d", |
| 7882 | dut->ap_nai_realm_list); |
| 7883 | } |
| 7884 | |
| 7885 | val = get_param(cmd, "3GPP_INFO"); |
| 7886 | if (val) { |
| 7887 | /* What kind of encoding format is used?! */ |
| 7888 | send_resp(dut, conn, SIGMA_ERROR, "errorCode,3GPP_INFO " |
| 7889 | "not yet supported (contents not fully defined)"); |
| 7890 | return 0; |
| 7891 | } |
| 7892 | |
| 7893 | val = get_param(cmd, "DOMAIN_LIST"); |
| 7894 | if (val) { |
| 7895 | if (strlen(val) >= sizeof(dut->ap_domain_name_list)) { |
| 7896 | send_resp(dut, conn, SIGMA_ERROR, "errorCode,Too long " |
| 7897 | "DOMAIN_LIST"); |
| 7898 | return 0; |
| 7899 | } |
| 7900 | snprintf(dut->ap_domain_name_list, |
| 7901 | sizeof(dut->ap_domain_name_list), "%s", val); |
| 7902 | pos = dut->ap_domain_name_list; |
| 7903 | while (*pos) { |
| 7904 | if (*pos == ';') |
| 7905 | *pos = ','; |
| 7906 | pos++; |
| 7907 | } |
| 7908 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_domain_name_list %s", |
| 7909 | dut->ap_domain_name_list); |
| 7910 | } |
| 7911 | |
| 7912 | val = get_param(cmd, "OPER_NAME"); |
| 7913 | if (val) { |
| 7914 | dut->ap_oper_name = atoi(val); |
| 7915 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_oper_name %d", |
| 7916 | dut->ap_oper_name); |
| 7917 | } |
| 7918 | |
| 7919 | val = get_param(cmd, "VENUE_NAME"); |
| 7920 | if (val) { |
| 7921 | dut->ap_venue_name = atoi(val); |
| 7922 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_venue_name %d", |
| 7923 | dut->ap_venue_name); |
| 7924 | } |
| 7925 | |
| 7926 | val = get_param(cmd, "GAS_CB_DELAY"); |
| 7927 | if (val) { |
| 7928 | dut->ap_gas_cb_delay = atoi(val); |
| 7929 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_gas_cb_delay %d", |
| 7930 | dut->ap_gas_cb_delay); |
| 7931 | } |
| 7932 | |
| 7933 | val = get_param(cmd, "MIH"); |
| 7934 | if (val && atoi(val) > 0) { |
| 7935 | send_resp(dut, conn, SIGMA_ERROR, "errorCode,MIH not " |
| 7936 | "supported"); |
| 7937 | return 0; |
| 7938 | } |
| 7939 | |
| 7940 | val = get_param(cmd, "L2_TRAFFIC_INSPECT"); |
| 7941 | if (val) { |
| 7942 | dut->ap_l2tif = atoi(val); |
| 7943 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_l2tif %d", |
| 7944 | dut->ap_l2tif); |
| 7945 | } |
| 7946 | |
| 7947 | val = get_param(cmd, "BCST_UNCST"); |
| 7948 | if (val) { |
| 7949 | send_resp(dut, conn, SIGMA_ERROR, |
| 7950 | "errorCode,BCST_UNCST not yet supported"); |
| 7951 | return 0; |
| 7952 | } |
| 7953 | |
| 7954 | val = get_param(cmd, "PLMN_MCC"); |
| 7955 | if (val) { |
| 7956 | char mcc[100], *start, *end; |
| 7957 | int i = 0; |
| 7958 | if (strlen(val) >= sizeof(mcc)) { |
| 7959 | send_resp(dut, conn, SIGMA_ERROR, |
| 7960 | "errorCode,PLMN_MCC too long"); |
| 7961 | return 0; |
| 7962 | } |
Peng Xu | b8fc5cc | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 7963 | strlcpy(mcc, val, sizeof(mcc)); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7964 | start = mcc; |
| 7965 | while ((end = strchr(start, ';'))) { |
| 7966 | /* process all except the last */ |
| 7967 | *end = '\0'; |
| 7968 | if (strlen(start) != 3) { |
| 7969 | send_resp(dut, conn, SIGMA_ERROR, |
| 7970 | "errorCode,Invalid PLMN_MCC"); |
| 7971 | return 0; |
| 7972 | } |
| 7973 | snprintf(dut->ap_plmn_mcc[i], |
| 7974 | sizeof(dut->ap_plmn_mcc[i]), "%s", start); |
| 7975 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_plmn_mcc %s", |
| 7976 | dut->ap_plmn_mcc[i]); |
| 7977 | i++; |
| 7978 | start = end + 1; |
| 7979 | *end = ';'; |
| 7980 | } |
| 7981 | if (strlen(start) != 3) { |
| 7982 | send_resp(dut, conn, SIGMA_ERROR, |
| 7983 | "errorCode,Invalid PLMN_MCC"); |
| 7984 | return 0; |
| 7985 | } |
| 7986 | /* process last or only one */ |
| 7987 | snprintf(dut->ap_plmn_mcc[i], |
| 7988 | sizeof(dut->ap_plmn_mcc[i]), "%s", start); |
| 7989 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_plmn_mcc %s", |
| 7990 | dut->ap_plmn_mcc[i]); |
| 7991 | } |
| 7992 | |
| 7993 | val = get_param(cmd, "PLMN_MNC"); |
| 7994 | if (val) { |
| 7995 | char mnc[100], *start, *end; |
| 7996 | int i = 0; |
| 7997 | if (strlen(val) >= sizeof(mnc)) { |
| 7998 | send_resp(dut, conn, SIGMA_ERROR, |
| 7999 | "errorCode,PLMN_MNC too long"); |
| 8000 | return 0; |
| 8001 | } |
Peng Xu | b8fc5cc | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 8002 | strlcpy(mnc, val, sizeof(mnc)); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8003 | start = mnc; |
| 8004 | while ((end = strchr(start, ';'))) { |
| 8005 | *end = '\0'; |
| 8006 | if (strlen(start) != 2 && strlen(start) != 3) { |
| 8007 | send_resp(dut, conn, SIGMA_ERROR, |
| 8008 | "errorCode,Invalid PLMN_MNC"); |
| 8009 | return 0; |
| 8010 | } |
| 8011 | snprintf(dut->ap_plmn_mnc[i], |
| 8012 | sizeof(dut->ap_plmn_mnc[i]), "%s", start); |
| 8013 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_plmn_mnc %s", |
| 8014 | dut->ap_plmn_mnc[i]); |
| 8015 | i++; |
| 8016 | start = end + 1; |
| 8017 | *end = ';'; |
| 8018 | } |
| 8019 | if (strlen(start) != 2 && strlen(start) != 3) { |
| 8020 | send_resp(dut, conn, SIGMA_ERROR, |
| 8021 | "errorCode,Invalid PLMN_MNC"); |
| 8022 | return 0; |
| 8023 | } |
| 8024 | snprintf(dut->ap_plmn_mnc[i], |
| 8025 | sizeof(dut->ap_plmn_mnc[i]), "%s", start); |
| 8026 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_plmn_mnc %s", |
| 8027 | dut->ap_plmn_mnc[i]); |
| 8028 | } |
| 8029 | |
| 8030 | val = get_param(cmd, "PROXY_ARP"); |
| 8031 | if (val) { |
| 8032 | dut->ap_proxy_arp = atoi(val); |
| 8033 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_proxy_arp %d", |
| 8034 | dut->ap_proxy_arp); |
| 8035 | } |
| 8036 | |
| 8037 | val = get_param(cmd, "WAN_METRICS"); |
| 8038 | if (val) { |
| 8039 | dut->ap_wan_metrics = atoi(val); |
| 8040 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_wan_metrics %d", |
| 8041 | dut->ap_wan_metrics); |
| 8042 | } |
| 8043 | |
| 8044 | val = get_param(cmd, "CONN_CAP"); |
| 8045 | if (val) { |
| 8046 | dut->ap_conn_capab = atoi(val); |
| 8047 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_conn_capab %d", |
| 8048 | dut->ap_conn_capab); |
| 8049 | } |
| 8050 | |
| 8051 | val = get_param(cmd, "IP_ADD_TYPE_AVAIL"); |
| 8052 | if (val) { |
| 8053 | dut->ap_ip_addr_type_avail = atoi(val); |
| 8054 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_ip_addr_type_avail %d", |
| 8055 | dut->ap_ip_addr_type_avail); |
| 8056 | } |
| 8057 | |
| 8058 | val = get_param(cmd, "NET_AUTH_TYPE"); |
| 8059 | if (val) { |
| 8060 | dut->ap_net_auth_type = atoi(val); |
| 8061 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_net_auth_type %d", |
| 8062 | dut->ap_net_auth_type); |
| 8063 | } |
| 8064 | |
| 8065 | val = get_param(cmd, "OP_CLASS"); |
| 8066 | if (val == NULL) |
| 8067 | val = get_param(cmd, "OPER_CLASS"); |
| 8068 | if (val) { |
| 8069 | dut->ap_oper_class = atoi(val); |
| 8070 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_oper_class %d", |
| 8071 | dut->ap_oper_class); |
| 8072 | } |
| 8073 | |
| 8074 | val = get_param(cmd, "OSU_PROVIDER_LIST"); |
| 8075 | if (val) { |
| 8076 | dut->ap_osu_provider_list = atoi(val); |
| 8077 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_osu_provider_list %d", |
| 8078 | dut->ap_osu_provider_list); |
| 8079 | } |
| 8080 | |
| 8081 | val = get_param(cmd, "OSU_SERVER_URI"); |
| 8082 | if (val) { |
| 8083 | i = 0; |
| 8084 | do { |
| 8085 | int len; |
| 8086 | const char *uri = val; |
| 8087 | val = strchr(val, ' '); |
| 8088 | len = val ? (val++ - uri) : (int) strlen(uri); |
| 8089 | if (len > 0 && len < 256) { |
| 8090 | memcpy(dut->ap_osu_server_uri[i], uri, len); |
| 8091 | dut->ap_osu_server_uri[i][len] = '\0'; |
| 8092 | sigma_dut_print(dut, DUT_MSG_INFO, |
| 8093 | "ap_osu_server_uri[%d] %s", i, |
| 8094 | dut->ap_osu_server_uri[i]); |
| 8095 | } |
| 8096 | } while (val && ++i < 10); |
| 8097 | } |
| 8098 | |
| 8099 | val = get_param(cmd, "OSU_METHOD"); |
| 8100 | if (val) { |
| 8101 | i = 0; |
| 8102 | do { |
| 8103 | int len; |
| 8104 | const char *method = val; |
| 8105 | val = strchr(val, ' '); |
| 8106 | len = val ? (val++ - method) : (int) strlen(method); |
| 8107 | if (len > 0) { |
| 8108 | if (strncasecmp(method, "SOAP", len) == 0) |
| 8109 | dut->ap_osu_method[i] = 1; |
| 8110 | else if (strncasecmp(method, "OMADM", len) == 0) |
| 8111 | dut->ap_osu_method[i] = 0; |
| 8112 | else |
| 8113 | return -2; |
| 8114 | } |
| 8115 | } while (val && ++i < 10); |
| 8116 | } |
| 8117 | |
| 8118 | val = get_param(cmd, "OSU_SSID"); |
| 8119 | if (val) { |
| 8120 | if (strlen(val) > 0 && strlen(val) <= 32) { |
Peng Xu | b8fc5cc | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 8121 | strlcpy(dut->ap_osu_ssid, val, |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8122 | sizeof(dut->ap_osu_ssid)); |
| 8123 | sigma_dut_print(dut, DUT_MSG_INFO, |
| 8124 | "ap_osu_ssid %s", |
| 8125 | dut->ap_osu_ssid); |
| 8126 | } |
| 8127 | } |
| 8128 | |
| 8129 | val = get_param(cmd, "OSU_ICON_TAG"); |
| 8130 | if (val) |
| 8131 | dut->ap_osu_icon_tag = atoi(val); |
| 8132 | |
| 8133 | val = get_param(cmd, "QoS_MAP_SET"); |
| 8134 | if (val) { |
| 8135 | dut->ap_qos_map_set = atoi(val); |
| 8136 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_qos_map_set %d", |
| 8137 | dut->ap_qos_map_set); |
| 8138 | } |
| 8139 | |
| 8140 | val = get_param(cmd, "BSS_LOAD"); |
| 8141 | if (val) { |
| 8142 | dut->ap_bss_load = atoi(val); |
| 8143 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_bss_load %d", |
| 8144 | dut->ap_bss_load); |
| 8145 | } |
| 8146 | |
| 8147 | return 1; |
| 8148 | } |
| 8149 | |
| 8150 | |
| 8151 | void nfc_status(struct sigma_dut *dut, const char *state, const char *oper) |
| 8152 | { |
| 8153 | char buf[100]; |
| 8154 | |
| 8155 | if (!file_exists("nfc-status")) |
| 8156 | return; |
| 8157 | |
| 8158 | snprintf(buf, sizeof(buf), "./nfc-status %s %s", state, oper); |
| 8159 | run_system(dut, buf); |
| 8160 | } |
| 8161 | |
| 8162 | |
| 8163 | static int run_nfc_command(struct sigma_dut *dut, const char *cmd, |
| 8164 | const char *info) |
| 8165 | { |
| 8166 | int res; |
| 8167 | |
| 8168 | printf("\n\n\n=====[ NFC operation ]=========================\n\n"); |
| 8169 | printf("%s\n\n", info); |
| 8170 | |
| 8171 | nfc_status(dut, "START", info); |
| 8172 | res = run_system(dut, cmd); |
| 8173 | nfc_status(dut, res ? "FAIL" : "SUCCESS", info); |
| 8174 | if (res) { |
| 8175 | sigma_dut_print(dut, DUT_MSG_INFO, "Failed to run '%s': %d", |
| 8176 | cmd, res); |
| 8177 | return res; |
| 8178 | } |
| 8179 | |
| 8180 | return 0; |
| 8181 | } |
| 8182 | |
| 8183 | |
| 8184 | static int ap_nfc_write_config_token(struct sigma_dut *dut, |
| 8185 | struct sigma_conn *conn, |
| 8186 | struct sigma_cmd *cmd) |
| 8187 | { |
| 8188 | int res; |
| 8189 | char buf[300]; |
| 8190 | |
| 8191 | run_system(dut, "killall wps-ap-nfc.py"); |
| 8192 | unlink("nfc-success"); |
| 8193 | snprintf(buf, sizeof(buf), |
| 8194 | "./wps-ap-nfc.py --no-wait %s%s --success nfc-success write-config", |
| 8195 | dut->summary_log ? "--summary " : "", |
| 8196 | dut->summary_log ? dut->summary_log : ""); |
| 8197 | res = run_nfc_command(dut, buf, |
| 8198 | "Touch NFC Tag to write WPS configuration token"); |
| 8199 | if (res || !file_exists("nfc-success")) { |
| 8200 | send_resp(dut, conn, SIGMA_ERROR, |
| 8201 | "ErrorCode,Failed to write tag"); |
| 8202 | return 0; |
| 8203 | } |
| 8204 | |
| 8205 | return 1; |
| 8206 | } |
| 8207 | |
| 8208 | |
| 8209 | static int ap_nfc_wps_read_passwd(struct sigma_dut *dut, |
| 8210 | struct sigma_conn *conn, |
| 8211 | struct sigma_cmd *cmd) |
| 8212 | { |
| 8213 | int res; |
| 8214 | char buf[300]; |
| 8215 | |
| 8216 | run_system(dut, "killall wps-ap-nfc.py"); |
| 8217 | |
| 8218 | unlink("nfc-success"); |
| 8219 | snprintf(buf, sizeof(buf), |
| 8220 | "./wps-ap-nfc.py -1 --no-wait %s%s --success nfc-success", |
| 8221 | dut->summary_log ? "--summary " : "", |
| 8222 | dut->summary_log ? dut->summary_log : ""); |
| 8223 | res = run_nfc_command(dut, buf, "Touch NFC Tag to read it"); |
| 8224 | if (res || !file_exists("nfc-success")) { |
| 8225 | send_resp(dut, conn, SIGMA_ERROR, |
| 8226 | "ErrorCode,Failed to read tag"); |
| 8227 | return 0; |
| 8228 | } |
| 8229 | |
| 8230 | return 1; |
| 8231 | } |
| 8232 | |
| 8233 | |
| 8234 | static int ap_nfc_write_password_token(struct sigma_dut *dut, |
| 8235 | struct sigma_conn *conn, |
| 8236 | struct sigma_cmd *cmd) |
| 8237 | { |
| 8238 | int res; |
| 8239 | char buf[300]; |
| 8240 | |
| 8241 | run_system(dut, "killall wps-ap-nfc.py"); |
| 8242 | unlink("nfc-success"); |
| 8243 | snprintf(buf, sizeof(buf), |
| 8244 | "./wps-ap-nfc.py --no-wait %s%s --success nfc-success write-password", |
| 8245 | dut->summary_log ? "--summary " : "", |
| 8246 | dut->summary_log ? dut->summary_log : ""); |
| 8247 | res = run_nfc_command(dut, buf, |
| 8248 | "Touch NFC Tag to write WPS password token"); |
| 8249 | if (res || !file_exists("nfc-success")) { |
| 8250 | send_resp(dut, conn, SIGMA_ERROR, |
| 8251 | "ErrorCode,Failed to write tag"); |
| 8252 | return 0; |
| 8253 | } |
| 8254 | |
| 8255 | if (run_hostapd_cli(dut, "wps_nfc_token enable") != 0) { |
| 8256 | send_resp(dut, conn, SIGMA_ERROR, |
| 8257 | "ErrorCode,Failed to enable NFC password token"); |
| 8258 | return 0; |
| 8259 | } |
| 8260 | |
| 8261 | return 1; |
| 8262 | } |
| 8263 | |
| 8264 | |
| 8265 | static int ap_nfc_wps_connection_handover(struct sigma_dut *dut, |
| 8266 | struct sigma_conn *conn, |
| 8267 | struct sigma_cmd *cmd) |
| 8268 | { |
| 8269 | int res; |
| 8270 | char buf[300]; |
| 8271 | |
| 8272 | run_system(dut, "killall wps-ap-nfc.py"); |
| 8273 | unlink("nfc-success"); |
| 8274 | snprintf(buf, sizeof(buf), |
| 8275 | "./wps-ap-nfc.py -1 --no-wait %s%s --success nfc-success", |
| 8276 | dut->summary_log ? "--summary " : "", |
| 8277 | dut->summary_log ? dut->summary_log : ""); |
| 8278 | res = run_nfc_command(dut, buf, |
| 8279 | "Touch NFC Device to respond to WPS connection handover"); |
| 8280 | if (res) { |
| 8281 | send_resp(dut, conn, SIGMA_ERROR, |
| 8282 | "ErrorCode,Failed to enable NFC for connection " |
| 8283 | "handover"); |
| 8284 | return 0; |
| 8285 | } |
| 8286 | if (!file_exists("nfc-success")) { |
| 8287 | send_resp(dut, conn, SIGMA_ERROR, |
| 8288 | "ErrorCode,Failed to complete NFC connection handover"); |
| 8289 | return 0; |
| 8290 | } |
| 8291 | |
| 8292 | return 1; |
| 8293 | } |
| 8294 | |
| 8295 | |
| 8296 | static int cmd_ap_nfc_action(struct sigma_dut *dut, struct sigma_conn *conn, |
| 8297 | struct sigma_cmd *cmd) |
| 8298 | { |
| 8299 | /* const char *name = get_param(cmd, "Name"); */ |
| 8300 | /* const char *intf = get_param(cmd, "Interface"); */ |
| 8301 | const char *oper = get_param(cmd, "Operation"); |
| 8302 | |
| 8303 | if (oper == NULL) |
| 8304 | return -1; |
| 8305 | |
| 8306 | if (strcasecmp(oper, "WRITE_CONFIG") == 0) |
| 8307 | return ap_nfc_write_config_token(dut, conn, cmd); |
| 8308 | if (strcasecmp(oper, "WRITE_PASSWD") == 0) |
| 8309 | return ap_nfc_write_password_token(dut, conn, cmd); |
| 8310 | if (strcasecmp(oper, "WPS_READ_PASSWD") == 0) |
| 8311 | return ap_nfc_wps_read_passwd(dut, conn, cmd); |
| 8312 | if (strcasecmp(oper, "WPS_CONN_HNDOVR") == 0) |
| 8313 | return ap_nfc_wps_connection_handover(dut, conn, cmd); |
| 8314 | |
| 8315 | send_resp(dut, conn, SIGMA_ERROR, "ErrorCode,Unsupported operation"); |
| 8316 | return 0; |
| 8317 | } |
| 8318 | |
| 8319 | |
| 8320 | static int cmd_ap_wps_read_pin(struct sigma_dut *dut, struct sigma_conn *conn, |
| 8321 | struct sigma_cmd *cmd) |
| 8322 | { |
| 8323 | char *pin = "12345670"; /* TODO: use random PIN */ |
| 8324 | char resp[100]; |
| 8325 | |
| 8326 | snprintf(resp, sizeof(resp), "PIN,%s", pin); |
| 8327 | send_resp(dut, conn, SIGMA_COMPLETE, resp); |
| 8328 | |
| 8329 | return 0; |
| 8330 | } |
| 8331 | |
| 8332 | |
| 8333 | static int ath_vht_op_mode_notif(struct sigma_dut *dut, const char *ifname, |
| 8334 | const char *val) |
| 8335 | { |
| 8336 | char *token, *result; |
| 8337 | int nss = 0, chwidth = 0; |
| 8338 | char buf[100]; |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 8339 | char *saveptr; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8340 | |
| 8341 | /* |
| 8342 | * The following commands should be invoked to generate |
| 8343 | * VHT op mode notification |
| 8344 | */ |
| 8345 | |
| 8346 | /* Extract the NSS info */ |
| 8347 | token = strdup(val); |
| 8348 | if (!token) |
| 8349 | return -1; |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 8350 | result = strtok_r(token, ";", &saveptr); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8351 | if (result) { |
| 8352 | int count = atoi(result); |
| 8353 | |
| 8354 | /* We do not support NSS > 3 */ |
| 8355 | if (count < 0 || count > 3) { |
| 8356 | free(token); |
| 8357 | return -1; |
| 8358 | } |
| 8359 | |
| 8360 | /* Convert nss to chainmask */ |
| 8361 | while (count--) |
| 8362 | nss = (nss << 1) | 1; |
| 8363 | |
| 8364 | snprintf(buf, sizeof(buf), "iwpriv %s rxchainmask %d", |
| 8365 | ifname, nss); |
| 8366 | if (system(buf) != 0) { |
| 8367 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 8368 | "iwpriv wifi1 rxchainmask failed!"); |
| 8369 | } |
| 8370 | } |
| 8371 | |
| 8372 | /* Extract the Channel width info */ |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 8373 | result = strtok_r(NULL, ";", &saveptr); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8374 | if (result) { |
| 8375 | switch (atoi(result)) { |
| 8376 | case 20: |
| 8377 | chwidth = 0; |
| 8378 | break; |
| 8379 | case 40: |
| 8380 | chwidth = 1; |
| 8381 | break; |
| 8382 | case 80: |
| 8383 | chwidth = 2; |
| 8384 | break; |
| 8385 | case 160: |
| 8386 | chwidth = 3; |
| 8387 | break; |
| 8388 | default: |
| 8389 | chwidth = 2; |
| 8390 | break; |
| 8391 | } |
| 8392 | snprintf(buf, sizeof(buf), "iwpriv %s chwidth %d", |
| 8393 | ifname, chwidth); |
| 8394 | if (system(buf) != 0) { |
| 8395 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 8396 | "iwpriv chwidth failed!"); |
| 8397 | } |
| 8398 | } |
| 8399 | |
| 8400 | /* Send the opmode notification */ |
Sunil Dutt | 27ec7f6 | 2017-09-14 18:22:59 +0300 | [diff] [blame] | 8401 | snprintf(buf, sizeof(buf), "iwpriv %s opmode_notify 1", ifname); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8402 | if (system(buf) != 0) { |
| 8403 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 8404 | "iwpriv opmode_notify failed!"); |
| 8405 | } |
| 8406 | free(token); |
| 8407 | |
| 8408 | return 0; |
| 8409 | } |
| 8410 | |
| 8411 | |
| 8412 | static int ath_vht_nss_mcs(struct sigma_dut *dut, const char *ifname, |
| 8413 | const char *val) |
| 8414 | { |
| 8415 | /* String (nss_operating_mode; mcs_operating_mode) */ |
| 8416 | int nss, mcs; |
| 8417 | char *token, *result; |
| 8418 | char buf[100]; |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 8419 | char *saveptr; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8420 | |
| 8421 | token = strdup(val); |
| 8422 | if (!token) |
| 8423 | return -1; |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 8424 | result = strtok_r(token, ";", &saveptr); |
Pradeep Reddy POTTETI | 41b8c54 | 2016-06-15 16:09:46 +0530 | [diff] [blame] | 8425 | if (!result) { |
| 8426 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 8427 | "VHT NSS not specified"); |
| 8428 | goto end; |
| 8429 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8430 | if (strcasecmp(result, "def") != 0) { |
| 8431 | nss = atoi(result); |
| 8432 | |
| 8433 | if (nss == 4) |
| 8434 | ath_disable_txbf(dut, ifname); |
| 8435 | |
| 8436 | snprintf(buf, sizeof(buf), "iwpriv %s nss %d", ifname, nss); |
| 8437 | if (system(buf) != 0) { |
| 8438 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 8439 | "iwpriv nss failed"); |
| 8440 | } |
| 8441 | } else { |
| 8442 | if (dut->device_type == AP_testbed && dut->ap_sgi80 == 1) { |
| 8443 | snprintf(buf, sizeof(buf), "iwpriv %s nss 1", ifname); |
| 8444 | if (system(buf) != 0) { |
| 8445 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 8446 | "iwpriv nss failed"); |
| 8447 | } |
| 8448 | } |
| 8449 | } |
| 8450 | |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 8451 | result = strtok_r(NULL, ";", &saveptr); |
Pradeep Reddy POTTETI | 41b8c54 | 2016-06-15 16:09:46 +0530 | [diff] [blame] | 8452 | if (!result) { |
| 8453 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 8454 | "VHT MCS not specified"); |
| 8455 | goto end; |
| 8456 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8457 | if (strcasecmp(result, "def") == 0) { |
| 8458 | if (dut->device_type == AP_testbed && dut->ap_sgi80 == 1) { |
| 8459 | snprintf(buf, sizeof(buf), "iwpriv %s vhtmcs 7", |
| 8460 | ifname); |
| 8461 | if (system(buf) != 0) { |
| 8462 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 8463 | "iwpriv vhtmcs failed"); |
| 8464 | } |
| 8465 | } else { |
| 8466 | snprintf(buf, sizeof(buf), |
| 8467 | "iwpriv %s set11NRates 0", ifname); |
| 8468 | if (system(buf) != 0) { |
| 8469 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 8470 | "iwpriv set11NRates failed"); |
| 8471 | } |
| 8472 | } |
| 8473 | } else { |
| 8474 | mcs = atoi(result); |
| 8475 | snprintf(buf, sizeof(buf), "iwpriv %s vhtmcs %d", ifname, mcs); |
| 8476 | if (system(buf) != 0) { |
| 8477 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 8478 | "iwpriv vhtmcs failed"); |
| 8479 | } |
| 8480 | } |
| 8481 | |
Pradeep Reddy POTTETI | 41b8c54 | 2016-06-15 16:09:46 +0530 | [diff] [blame] | 8482 | end: |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8483 | free(token); |
| 8484 | return 0; |
| 8485 | } |
| 8486 | |
| 8487 | |
| 8488 | static int ath_vht_chnum_band(struct sigma_dut *dut, const char *ifname, |
| 8489 | const char *val) |
| 8490 | { |
| 8491 | char *token, *result; |
| 8492 | int channel = 36; |
| 8493 | int chwidth = 80; |
| 8494 | char buf[100]; |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 8495 | char *saveptr; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8496 | |
| 8497 | /* Extract the channel info */ |
| 8498 | token = strdup(val); |
| 8499 | if (!token) |
| 8500 | return -1; |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 8501 | result = strtok_r(token, ";", &saveptr); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8502 | if (result) |
| 8503 | channel = atoi(result); |
| 8504 | |
| 8505 | /* Extract the channel width info */ |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 8506 | result = strtok_r(NULL, ";", &saveptr); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8507 | if (result) |
| 8508 | chwidth = atoi(result); |
| 8509 | |
| 8510 | /* Issue the channel switch command */ |
| 8511 | snprintf(buf, sizeof(buf), "iwpriv %s doth_ch_chwidth %d 10 %d", |
| 8512 | ifname, channel, chwidth); |
| 8513 | if (system(buf) != 0) { |
| 8514 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 8515 | "iwpriv doth_ch_chwidth failed!"); |
| 8516 | } |
| 8517 | |
| 8518 | free(token); |
| 8519 | return 0; |
| 8520 | } |
| 8521 | |
| 8522 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8523 | static int ath_ndpa_stainfo_mac(struct sigma_dut *dut, const char *ifname, |
| 8524 | const char *val) |
| 8525 | { |
| 8526 | char buf[80]; |
| 8527 | unsigned char mac_addr[6]; |
| 8528 | |
| 8529 | if (parse_mac_address(dut, val, mac_addr) < 0) |
| 8530 | return -1; |
| 8531 | |
| 8532 | snprintf(buf, sizeof(buf), |
| 8533 | "wifitool %s beeliner_fw_test 92 0x%02x%02x%02x%02x", |
| 8534 | ifname, mac_addr[0], mac_addr[1], mac_addr[2], mac_addr[3]); |
| 8535 | run_system(dut, buf); |
| 8536 | |
| 8537 | snprintf(buf, sizeof(buf), "wifitool %s beeliner_fw_test 93 0x%02x%02x", |
| 8538 | ifname, mac_addr[4], mac_addr[5]); |
| 8539 | run_system(dut, buf); |
| 8540 | |
| 8541 | snprintf(buf, sizeof(buf), "wifitool %s beeliner_fw_test 94 1", ifname); |
| 8542 | run_system(dut, buf); |
| 8543 | |
| 8544 | return 0; |
| 8545 | } |
| 8546 | |
| 8547 | |
priyadharshini gowthaman | e5e2517 | 2015-12-08 14:53:48 -0800 | [diff] [blame] | 8548 | void novap_reset(struct sigma_dut *dut, const char *ifname) |
Priyadharshini Gowthaman | 39beafa | 2015-11-09 14:11:25 -0800 | [diff] [blame] | 8549 | { |
| 8550 | char buf[60]; |
| 8551 | |
| 8552 | snprintf(buf, sizeof(buf), "iwpriv %s novap_reset 1", ifname); |
| 8553 | if (system(buf) != 0) { |
| 8554 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 8555 | "disabling novap reset failed"); |
| 8556 | } |
| 8557 | } |
| 8558 | |
| 8559 | |
Adil Saeed Musthafa | 6906372 | 2017-04-10 23:13:40 -0700 | [diff] [blame] | 8560 | struct mbo_pref_ap * mbo_find_nebor_ap_entry(struct sigma_dut *dut, |
| 8561 | const uint8_t *mac_addr) |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 8562 | { |
Adil Saeed Musthafa | 6906372 | 2017-04-10 23:13:40 -0700 | [diff] [blame] | 8563 | int i; |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 8564 | |
Adil Saeed Musthafa | 6906372 | 2017-04-10 23:13:40 -0700 | [diff] [blame] | 8565 | for (i = 0; i < dut->mbo_pref_ap_cnt; i++) { |
| 8566 | if (memcmp(mac_addr, dut->mbo_pref_aps[i].mac_addr, |
| 8567 | ETH_ALEN) == 0) |
| 8568 | return &dut->mbo_pref_aps[i]; |
| 8569 | } |
| 8570 | return NULL; |
| 8571 | } |
| 8572 | |
| 8573 | |
| 8574 | static void mbo_add_nebor_entry(struct sigma_dut *dut, const uint8_t *mac_addr, |
| 8575 | int ap_ne_class, int ap_ne_op_ch, |
| 8576 | int ap_ne_pref) |
| 8577 | { |
| 8578 | struct mbo_pref_ap *entry; |
| 8579 | uint8_t self_mac[ETH_ALEN]; |
| 8580 | char ifname[50]; |
| 8581 | |
| 8582 | get_if_name(dut, ifname, sizeof(ifname), 1); |
| 8583 | get_hwaddr(ifname, self_mac); |
| 8584 | |
| 8585 | if (memcmp(mac_addr, self_mac, ETH_ALEN) == 0) |
| 8586 | entry = &dut->mbo_self_ap_tuple; |
| 8587 | else |
| 8588 | entry = mbo_find_nebor_ap_entry(dut, mac_addr); |
| 8589 | |
| 8590 | if (!entry) { |
| 8591 | if (dut->mbo_pref_ap_cnt >= MBO_MAX_PREF_BSSIDS) { |
| 8592 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 8593 | "Nebor AP List is full. Not adding"); |
| 8594 | return; |
| 8595 | } |
| 8596 | entry = &dut->mbo_pref_aps[dut->mbo_pref_ap_cnt]; |
| 8597 | dut->mbo_pref_ap_cnt++; |
| 8598 | memcpy(entry->mac_addr, mac_addr, ETH_ALEN); |
| 8599 | entry->ap_ne_class = -1; |
| 8600 | entry->ap_ne_op_ch = -1; |
| 8601 | entry->ap_ne_pref = -1; |
| 8602 | } |
| 8603 | if (ap_ne_class != -1) |
| 8604 | entry->ap_ne_class = ap_ne_class; |
| 8605 | if (ap_ne_op_ch != -1) |
| 8606 | entry->ap_ne_op_ch = ap_ne_op_ch; |
| 8607 | if (ap_ne_pref != -1) |
| 8608 | entry->ap_ne_pref = ap_ne_pref; |
| 8609 | } |
| 8610 | |
| 8611 | |
| 8612 | static int ath_set_nebor_bssid(struct sigma_dut *dut, const char *ifname, |
| 8613 | struct sigma_cmd *cmd) |
| 8614 | { |
| 8615 | unsigned char mac_addr[ETH_ALEN]; |
| 8616 | const char *val; |
| 8617 | /* |
| 8618 | * -1 is invalid value for the following |
| 8619 | * to differentiate between unset and set values |
| 8620 | * -1 => implies not set by CAPI |
| 8621 | */ |
| 8622 | int ap_ne_class = -1, ap_ne_op_ch = -1, ap_ne_pref = -1; |
| 8623 | int list_offset = dut->mbo_pref_ap_cnt; |
| 8624 | |
| 8625 | if (list_offset >= MBO_MAX_PREF_BSSIDS) { |
| 8626 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 8627 | "AP Pref Entry list is full"); |
| 8628 | return -1; |
| 8629 | } |
| 8630 | |
| 8631 | val = get_param(cmd, "Nebor_Op_Class"); |
| 8632 | if (val) |
| 8633 | ap_ne_class = atoi(val); |
| 8634 | |
| 8635 | val = get_param(cmd, "Nebor_Op_Ch"); |
| 8636 | if (val) |
| 8637 | ap_ne_op_ch = atoi(val); |
| 8638 | |
| 8639 | val = get_param(cmd, "Nebor_Pref"); |
| 8640 | if (val) |
| 8641 | ap_ne_pref = atoi(val); |
| 8642 | |
| 8643 | val = get_param(cmd, "Nebor_BSSID"); |
| 8644 | if (!val || parse_mac_address(dut, val, mac_addr) < 0) |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 8645 | return -1; |
| 8646 | |
Adil Saeed Musthafa | 6906372 | 2017-04-10 23:13:40 -0700 | [diff] [blame] | 8647 | mbo_add_nebor_entry(dut, mac_addr, ap_ne_class, ap_ne_op_ch, |
| 8648 | ap_ne_pref); |
| 8649 | apply_mbo_pref_ap_list(dut); |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 8650 | return 0; |
| 8651 | } |
| 8652 | |
| 8653 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8654 | static int ath_ap_set_rfeature(struct sigma_dut *dut, struct sigma_conn *conn, |
| 8655 | struct sigma_cmd *cmd) |
| 8656 | { |
| 8657 | const char *val; |
| 8658 | char *ifname; |
| 8659 | |
| 8660 | ifname = get_main_ifname(); |
| 8661 | |
Priyadharshini Gowthaman | 39beafa | 2015-11-09 14:11:25 -0800 | [diff] [blame] | 8662 | /* Disable vap reset between the commands */ |
| 8663 | novap_reset(dut, ifname); |
| 8664 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8665 | val = get_param(cmd, "Opt_md_notif_ie"); |
| 8666 | if (val && ath_vht_op_mode_notif(dut, ifname, val) < 0) |
| 8667 | return -1; |
| 8668 | |
| 8669 | /* TODO: Optional arguments */ |
| 8670 | |
| 8671 | val = get_param(cmd, "nss_mcs_opt"); |
| 8672 | if (val && ath_vht_nss_mcs(dut, ifname, val) < 0) |
| 8673 | return -1; |
| 8674 | |
| 8675 | val = get_param(cmd, "chnum_band"); |
| 8676 | if (val && ath_vht_chnum_band(dut, ifname, val) < 0) |
| 8677 | return -1; |
| 8678 | |
| 8679 | val = get_param(cmd, "RTS_FORCE"); |
| 8680 | if (val) |
| 8681 | ath_config_rts_force(dut, ifname, val); |
| 8682 | |
| 8683 | val = get_param(cmd, "DYN_BW_SGNL"); |
| 8684 | if (val) |
| 8685 | ath_config_dyn_bw_sig(dut, ifname, val); |
| 8686 | |
| 8687 | val = get_param(cmd, "CTS_WIDTH"); |
| 8688 | if (val) |
| 8689 | ath_set_cts_width(dut, ifname, val); |
| 8690 | |
| 8691 | val = get_param(cmd, "Ndpa_stainfo_mac"); |
| 8692 | if (val && ath_ndpa_stainfo_mac(dut, ifname, val) < 0) |
| 8693 | return -1; |
| 8694 | |
| 8695 | val = get_param(cmd, "txBandwidth"); |
| 8696 | if (val && ath_set_width(dut, conn, ifname, val) < 0) |
| 8697 | return -1; |
| 8698 | |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 8699 | val = get_param(cmd, "Assoc_Disallow"); |
| 8700 | if (val) |
| 8701 | ath_set_assoc_disallow(dut, ifname, val); |
| 8702 | |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 8703 | |
Adil Saeed Musthafa | 6906372 | 2017-04-10 23:13:40 -0700 | [diff] [blame] | 8704 | ath_set_nebor_bssid(dut, ifname, cmd); |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 8705 | val = get_param(cmd, "BTMReq_DisAssoc_Imnt"); |
| 8706 | if (val) |
| 8707 | dut->ap_btmreq_disassoc_imnt = atoi(val); |
| 8708 | |
| 8709 | val = get_param(cmd, "BTMReq_Term_Bit"); |
| 8710 | if (val) |
| 8711 | dut->ap_btmreq_term_bit = atoi(val); |
| 8712 | |
Adil Saeed Musthafa | 48c5ab9 | 2017-04-10 23:13:35 -0700 | [diff] [blame] | 8713 | val = get_param(cmd, "Assoc_Delay"); |
| 8714 | if (val) |
| 8715 | run_system_wrapper(dut, "iwpriv %s mbo_asoc_ret %s", |
| 8716 | ifname, val); |
| 8717 | |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 8718 | val = get_param(cmd, "Disassoc_Timer"); |
| 8719 | if (val) |
| 8720 | dut->ap_disassoc_timer = atoi(val); |
| 8721 | |
| 8722 | val = get_param(cmd, "BSS_Term_Duration"); |
| 8723 | if (val) |
| 8724 | dut->ap_btmreq_bss_term_dur = atoi(val); |
| 8725 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8726 | return 1; |
| 8727 | } |
| 8728 | |
| 8729 | |
Pradeep Reddy POTTETI | 88fd82c | 2016-03-14 12:20:18 +0530 | [diff] [blame] | 8730 | static int wcn_vht_chnum_band(struct sigma_dut *dut, const char *ifname, |
| 8731 | const char *val) |
| 8732 | { |
| 8733 | char *token, *result; |
| 8734 | int channel = 36; |
| 8735 | char buf[100]; |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 8736 | char *saveptr; |
Pradeep Reddy POTTETI | 88fd82c | 2016-03-14 12:20:18 +0530 | [diff] [blame] | 8737 | |
| 8738 | /* Extract the channel info */ |
| 8739 | token = strdup(val); |
| 8740 | if (!token) |
| 8741 | return -1; |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 8742 | result = strtok_r(token, ";", &saveptr); |
Pradeep Reddy POTTETI | 88fd82c | 2016-03-14 12:20:18 +0530 | [diff] [blame] | 8743 | if (result) |
| 8744 | channel = atoi(result); |
| 8745 | |
| 8746 | /* Issue the channel switch command */ |
| 8747 | snprintf(buf, sizeof(buf), "iwpriv %s setChanChange %d", |
| 8748 | ifname, channel); |
| 8749 | if (system(buf) != 0) { |
| 8750 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 8751 | "iwpriv setChanChange failed!"); |
| 8752 | } |
| 8753 | |
| 8754 | free(token); |
| 8755 | return 0; |
| 8756 | } |
| 8757 | |
| 8758 | |
| 8759 | static int wcn_ap_set_rfeature(struct sigma_dut *dut, struct sigma_conn *conn, |
| 8760 | struct sigma_cmd *cmd) |
| 8761 | { |
| 8762 | const char *val; |
| 8763 | char *ifname; |
| 8764 | |
| 8765 | ifname = get_main_ifname(); |
| 8766 | |
| 8767 | val = get_param(cmd, "chnum_band"); |
| 8768 | if (val && wcn_vht_chnum_band(dut, ifname, val) < 0) |
| 8769 | return -1; |
| 8770 | |
| 8771 | return 1; |
| 8772 | } |
| 8773 | |
| 8774 | |
Mohammed Shafi Shajakhan | b53d8f9 | 2017-02-28 09:05:15 +0530 | [diff] [blame] | 8775 | static int mac80211_vht_chnum_band(struct sigma_dut *dut, const char *ifname, |
| 8776 | const char *val) |
| 8777 | { |
| 8778 | char *token, *result; |
| 8779 | int channel = 36, chwidth = 80, center_freq_idx, center_freq, |
| 8780 | channel_freq; |
| 8781 | char buf[100]; |
| 8782 | char *saveptr; |
| 8783 | |
| 8784 | /* Extract the channel info */ |
| 8785 | token = strdup(val); |
| 8786 | if (!token) |
| 8787 | return -1; |
| 8788 | result = strtok_r(token, ";", &saveptr); |
| 8789 | if (result) |
| 8790 | channel = atoi(result); |
| 8791 | |
| 8792 | /* Extract the channel width info */ |
| 8793 | result = strtok_r(NULL, ";", &saveptr); |
| 8794 | if (result) |
| 8795 | chwidth = atoi(result); |
| 8796 | |
| 8797 | center_freq_idx = get_oper_centr_freq_seq_idx(chwidth, channel); |
| 8798 | if (center_freq_idx < 0) { |
| 8799 | free(token); |
| 8800 | return -1; |
| 8801 | } |
| 8802 | |
| 8803 | center_freq = get_5g_channel_freq(center_freq_idx); |
| 8804 | channel_freq = get_5g_channel_freq(channel); |
| 8805 | |
| 8806 | /* Issue the channel switch command */ |
| 8807 | snprintf(buf, sizeof(buf), |
| 8808 | " -i %s chan_switch 10 %d sec_channel_offset=1 center_freq1=%d bandwidth=%d blocktx vht", |
| 8809 | ifname, channel_freq, center_freq, chwidth); |
| 8810 | if (run_hostapd_cli(dut,buf) != 0) { |
| 8811 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 8812 | "hostapd_cli chan_switch failed"); |
| 8813 | } |
| 8814 | |
| 8815 | free(token); |
| 8816 | return 0; |
| 8817 | } |
| 8818 | |
| 8819 | |
| 8820 | static int mac80211_ap_set_rfeature(struct sigma_dut *dut, |
| 8821 | struct sigma_conn *conn, |
| 8822 | struct sigma_cmd *cmd) |
| 8823 | { |
| 8824 | const char *val; |
| 8825 | char *ifname; |
| 8826 | |
| 8827 | ifname = get_main_ifname(); |
| 8828 | val = get_param(cmd, "chnum_band"); |
| 8829 | if (val && mac80211_vht_chnum_band(dut, ifname, val) < 0) |
| 8830 | return -1; |
| 8831 | |
| 8832 | return 1; |
| 8833 | } |
| 8834 | |
| 8835 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8836 | static int cmd_ap_set_rfeature(struct sigma_dut *dut, struct sigma_conn *conn, |
| 8837 | struct sigma_cmd *cmd) |
| 8838 | { |
| 8839 | /* const char *name = get_param(cmd, "NAME"); */ |
| 8840 | /* const char *type = get_param(cmd, "Type"); */ |
| 8841 | |
| 8842 | switch (get_driver_type()) { |
| 8843 | case DRIVER_ATHEROS: |
| 8844 | return ath_ap_set_rfeature(dut, conn, cmd); |
| 8845 | case DRIVER_OPENWRT: |
| 8846 | switch (get_openwrt_driver_type()) { |
| 8847 | case OPENWRT_DRIVER_ATHEROS: |
| 8848 | return ath_ap_set_rfeature(dut, conn, cmd); |
| 8849 | default: |
| 8850 | send_resp(dut, conn, SIGMA_ERROR, |
| 8851 | "errorCode,Unsupported ap_set_rfeature with the current openwrt driver"); |
| 8852 | return 0; |
| 8853 | } |
Sreelakshmi Konamki | 0e4fcf9 | 2016-04-26 19:55:01 +0530 | [diff] [blame] | 8854 | case DRIVER_LINUX_WCN: |
Pradeep Reddy POTTETI | 88fd82c | 2016-03-14 12:20:18 +0530 | [diff] [blame] | 8855 | case DRIVER_WCN: |
| 8856 | return wcn_ap_set_rfeature(dut, conn, cmd); |
Mohammed Shafi Shajakhan | b53d8f9 | 2017-02-28 09:05:15 +0530 | [diff] [blame] | 8857 | case DRIVER_MAC80211: |
| 8858 | return mac80211_ap_set_rfeature(dut, conn, cmd); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8859 | default: |
| 8860 | send_resp(dut, conn, SIGMA_ERROR, |
| 8861 | "errorCode,Unsupported ap_set_rfeature with the current driver"); |
| 8862 | return 0; |
| 8863 | } |
| 8864 | } |
| 8865 | |
| 8866 | |
| 8867 | static int cmd_accesspoint(struct sigma_dut *dut, struct sigma_conn *conn, |
| 8868 | struct sigma_cmd *cmd) |
| 8869 | { |
| 8870 | /* const char *name = get_param(cmd, "NAME"); */ |
| 8871 | return 1; |
| 8872 | } |
| 8873 | |
| 8874 | |
| 8875 | void ap_register_cmds(void) |
| 8876 | { |
| 8877 | sigma_dut_reg_cmd("ap_ca_version", NULL, cmd_ap_ca_version); |
| 8878 | sigma_dut_reg_cmd("ap_set_wireless", NULL, cmd_ap_set_wireless); |
| 8879 | sigma_dut_reg_cmd("ap_send_addba_req", NULL, cmd_ap_send_addba_req); |
| 8880 | sigma_dut_reg_cmd("ap_set_11n_wireless", NULL, cmd_ap_set_wireless); |
| 8881 | sigma_dut_reg_cmd("ap_set_11n", NULL, cmd_ap_set_wireless); |
| 8882 | 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] | 8883 | sigma_dut_reg_cmd("ap_set_11h", NULL, cmd_ap_set_wireless); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8884 | sigma_dut_reg_cmd("ap_set_security", NULL, cmd_ap_set_security); |
| 8885 | sigma_dut_reg_cmd("ap_set_apqos", NULL, cmd_ap_set_apqos); |
| 8886 | sigma_dut_reg_cmd("ap_set_staqos", NULL, cmd_ap_set_staqos); |
| 8887 | sigma_dut_reg_cmd("ap_set_radius", NULL, cmd_ap_set_radius); |
| 8888 | sigma_dut_reg_cmd("ap_reboot", NULL, cmd_ap_reboot); |
| 8889 | sigma_dut_reg_cmd("ap_config_commit", NULL, cmd_ap_config_commit); |
| 8890 | sigma_dut_reg_cmd("ap_reset_default", NULL, cmd_ap_reset_default); |
| 8891 | sigma_dut_reg_cmd("ap_get_info", NULL, cmd_ap_get_info); |
| 8892 | sigma_dut_reg_cmd("ap_deauth_sta", NULL, cmd_ap_deauth_sta); |
| 8893 | sigma_dut_reg_cmd("ap_send_frame", NULL, cmd_ap_send_frame); |
| 8894 | sigma_dut_reg_cmd("ap_get_mac_address", NULL, cmd_ap_get_mac_address); |
| 8895 | sigma_dut_reg_cmd("ap_set_pmf", NULL, cmd_ap_set_pmf); |
| 8896 | sigma_dut_reg_cmd("ap_set_hs2", NULL, cmd_ap_set_hs2); |
| 8897 | sigma_dut_reg_cmd("ap_set_rfeature", NULL, cmd_ap_set_rfeature); |
| 8898 | sigma_dut_reg_cmd("ap_nfc_action", NULL, cmd_ap_nfc_action); |
| 8899 | sigma_dut_reg_cmd("ap_wps_read_pin", NULL, cmd_ap_wps_read_pin); |
| 8900 | sigma_dut_reg_cmd("AccessPoint", NULL, cmd_accesspoint); |
| 8901 | } |