Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Sigma Control API DUT (station/AP) |
| 3 | * Copyright (c) 2010-2011, Atheros Communications, Inc. |
| 4 | * Copyright (c) 2011-2015, Qualcomm Atheros, Inc. |
| 5 | * All Rights Reserved. |
| 6 | * Licensed under the Clear BSD license. See README for more details. |
| 7 | */ |
| 8 | |
| 9 | #include "sigma_dut.h" |
| 10 | #include <sys/stat.h> |
| 11 | #include <sys/wait.h> |
| 12 | #include <sys/utsname.h> |
| 13 | #include <sys/ioctl.h> |
| 14 | #ifdef __linux__ |
Adil Saeed Musthafa | 33ea287 | 2017-04-10 23:13:24 -0700 | [diff] [blame] | 15 | #include <limits.h> |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 16 | #include <dirent.h> |
| 17 | #include <string.h> |
| 18 | #include <sys/types.h> |
| 19 | #include <unistd.h> |
| 20 | #endif /* __linux__ */ |
| 21 | #ifdef __QNXNTO__ |
| 22 | #include <ifaddrs.h> |
| 23 | #include <net/if_dl.h> |
| 24 | #endif /* __QNXNTO__ */ |
| 25 | #include "wpa_helpers.h" |
| 26 | #ifdef ANDROID |
| 27 | #include <hardware_legacy/wifi.h> |
Pradeep Reddy POTTETI | a076c30 | 2016-05-16 13:36:07 +0530 | [diff] [blame] | 28 | #include <private/android_filesystem_config.h> |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 29 | #endif /* ANDROID */ |
| 30 | |
| 31 | /* Temporary files for ap_send_addba_req */ |
| 32 | #define VI_QOS_TMP_FILE "/tmp/vi-qos.tmp" |
| 33 | #define VI_QOS_FILE "/tmp/vi-qos.txt" |
| 34 | #define VI_QOS_REFFILE "/etc/vi-qos.txt" |
| 35 | |
| 36 | /* Configuration file name on Android */ |
| 37 | #ifndef ANDROID_CONFIG_FILE |
| 38 | #define ANDROID_CONFIG_FILE "/data/misc/wifi/hostapd.conf" |
| 39 | #endif /* ANDROID_CONFIG_FILE */ |
| 40 | /* Maximum length of the line in the configuration file */ |
| 41 | #define MAX_CONF_LINE_LEN (156) |
| 42 | |
Jouni Malinen | d6bf1b4 | 2017-06-23 17:51:01 +0300 | [diff] [blame] | 43 | #ifndef SIGMA_DUT_HOSTAPD_PID_FILE |
| 44 | #define SIGMA_DUT_HOSTAPD_PID_FILE "/tmp/sigma_dut-ap-hostapd.pid" |
| 45 | #endif /* SIGMA_DUT_HOSTAPD_PID_FILE */ |
| 46 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 47 | /* The following is taken from Hotspot 2.0 testplan Appendix B.1 */ |
| 48 | #define ANQP_VENUE_NAME_1 "02019c0002083d656e6757692d466920416c6c69616e63650a3239383920436f7070657220526f61640a53616e746120436c6172612c2043412039353035312c205553415b63686957692d4669e88194e79b9fe5ae9ee9aa8ce5aea40ae4ba8ce4b99de585abe4b99de5b9b4e5ba93e69f8fe8b7af0ae59ca3e5858be68b89e68b892c20e58aa0e588a9e7a68fe5b0bce4ba9a39353035312c20e7be8ee59bbd" |
| 49 | #define ANQP_VENUE_NAME_1_CHI "P\"\x63\x68\x69\x3a\x57\x69\x2d\x46\x69\xe8\x81\x94\xe7\x9b\x9f\xe5\xae\x9e\xe9\xaa\x8c\xe5\xae\xa4\\n\xe4\xba\x8c\xe4\xb9\x9d\xe5\x85\xab\xe4\xb9\x9d\xe5\xb9\xb4\xe5\xba\x93\xe6\x9f\x8f\xe8\xb7\xaf\\n\xe5\x9c\xa3\xe5\x85\x8b\xe6\x8b\x89\xe6\x8b\x89\x2c\x20\xe5\x8a\xa0\xe5\x88\xa9\xe7\xa6\x8f\xe5\xb0\xbc\xe4\xba\x9a\x39\x35\x30\x35\x31\x2c\x20\xe7\xbe\x8e\xe5\x9b\xbd\"" |
| 50 | #define ANQP_IP_ADDR_TYPE_1 "060101000c" |
| 51 | #define ANQP_HS20_OPERATOR_FRIENDLY_NAME_1 "dddd2700506f9a11030011656e6757692d466920416c6c69616e63650e63686957692d4669e88194e79b9f" |
| 52 | #define ANQP_HS20_WAN_METRICS_1 "dddd1300506f9a11040001c40900008001000000000000" |
| 53 | #define ANQP_HS20_CONNECTION_CAPABILITY_1 "dddd3200506f9a1105000100000006140001061600000650000106bb010106bb060006c4130011f4010111c413001194110132000001" |
| 54 | #define QOS_MAP_SET_1 "53,2,22,6,8,15,0,7,255,255,16,31,32,39,255,255,40,47,255,255" |
| 55 | #define QOS_MAP_SET_2 "8,15,0,7,255,255,16,31,32,39,255,255,40,47,48,63" |
| 56 | |
| 57 | extern char *sigma_main_ifname; |
| 58 | extern char *sigma_wpas_ctrl; |
| 59 | extern char *sigma_hapd_ctrl; |
| 60 | extern char *ap_inet_addr; |
| 61 | extern char *ap_inet_mask; |
| 62 | extern char *sigma_radio_ifname[]; |
| 63 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 64 | static int ath_ap_start_hostapd(struct sigma_dut *dut); |
| 65 | static void ath_ap_set_params(struct sigma_dut *dut); |
| 66 | static int kill_process(struct sigma_dut *dut, char *proc_name, |
| 67 | unsigned char is_proc_instance_one, int sig); |
| 68 | |
| 69 | |
| 70 | static int cmd_ap_ca_version(struct sigma_dut *dut, struct sigma_conn *conn, |
| 71 | struct sigma_cmd *cmd) |
| 72 | { |
| 73 | /* const char *name = get_param(cmd, "NAME"); */ |
| 74 | send_resp(dut, conn, SIGMA_COMPLETE, "version,1.0"); |
| 75 | return 0; |
| 76 | } |
| 77 | |
| 78 | |
Jouni Malinen | d6bf1b4 | 2017-06-23 17:51:01 +0300 | [diff] [blame] | 79 | static void kill_hostapd_process_pid(struct sigma_dut *dut) |
| 80 | { |
| 81 | FILE *f; |
| 82 | int pid, res; |
| 83 | char path[100]; |
| 84 | int count; |
| 85 | |
| 86 | f = fopen(SIGMA_DUT_HOSTAPD_PID_FILE, "r"); |
| 87 | if (!f) |
| 88 | return; |
| 89 | res = fscanf(f, "%d", &pid); |
| 90 | fclose(f); |
| 91 | if (res != 1) |
| 92 | return; |
| 93 | sigma_dut_print(dut, DUT_MSG_INFO, "Killing hostapd pid %d", pid); |
| 94 | kill(pid, SIGTERM); |
| 95 | snprintf(path, sizeof(path), "/proc/%d", pid); |
| 96 | for (count = 0; count < 20 && file_exists(path); count++) |
| 97 | usleep(100000); |
| 98 | } |
| 99 | |
| 100 | |
Jouni Malinen | 2e6ccc2 | 2017-09-04 13:43:16 +0300 | [diff] [blame] | 101 | int get_hwaddr(const char *ifname, unsigned char *hwaddr) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 102 | { |
| 103 | #ifndef __QNXNTO__ |
| 104 | struct ifreq ifr; |
| 105 | int s; |
| 106 | |
| 107 | s = socket(AF_INET, SOCK_DGRAM, 0); |
| 108 | if (s < 0) |
| 109 | return -1; |
| 110 | memset(&ifr, 0, sizeof(ifr)); |
Peng Xu | b8fc5cc | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 111 | strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name)); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 112 | if (ioctl(s, SIOCGIFHWADDR, &ifr) < 0) { |
| 113 | perror("ioctl"); |
| 114 | close(s); |
| 115 | return -1; |
| 116 | } |
| 117 | close(s); |
| 118 | memcpy(hwaddr, ifr.ifr_hwaddr.sa_data, 6); |
| 119 | #else /* __QNXNTO__ */ |
| 120 | struct ifaddrs *ifaddrshead = NULL; |
| 121 | int found = 0; |
| 122 | struct ifaddrs *temp_ifap = NULL; |
| 123 | struct sockaddr_dl *sdl = NULL; |
| 124 | |
| 125 | if (getifaddrs(&ifaddrshead) != 0) { |
| 126 | perror("getifaddrs failed"); |
| 127 | return -1; |
| 128 | } |
| 129 | |
| 130 | for (temp_ifap = ifaddrshead; ifaddrshead && !found; |
| 131 | ifaddrshead = ifaddrshead->ifa_next) { |
| 132 | if (ifaddrshead->ifa_addr->sa_family == AF_LINK && |
| 133 | strcmp(ifaddrshead->ifa_name, ifname) == 0) { |
| 134 | found = 1; |
| 135 | sdl = (struct sockaddr_dl *) ifaddrshead->ifa_addr; |
| 136 | if (sdl) |
| 137 | memcpy(hwaddr, LLADDR(sdl), sdl->sdl_alen); |
| 138 | } |
| 139 | } |
| 140 | |
| 141 | if (temp_ifap) |
| 142 | freeifaddrs(temp_ifap); |
| 143 | |
| 144 | if (!found) { |
| 145 | perror("Failed to get the interface"); |
| 146 | return -1; |
| 147 | } |
| 148 | #endif /* __QNXNTO__ */ |
| 149 | return 0; |
| 150 | } |
| 151 | |
| 152 | |
| 153 | static void ath_ap_set_group_id(struct sigma_dut *dut, const char *ifname, |
| 154 | const char *val) |
| 155 | { |
| 156 | char buf[60]; |
| 157 | |
| 158 | snprintf(buf, sizeof(buf), "wifitool %s beeliner_fw_test 55 %d", |
| 159 | ifname, atoi(val)); |
| 160 | if (system(buf) != 0) { |
| 161 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 162 | "wifitool ap_group_id failed"); |
| 163 | } |
| 164 | } |
| 165 | |
| 166 | |
| 167 | void ath_set_cts_width(struct sigma_dut *dut, const char *ifname, |
| 168 | const char *val) |
| 169 | { |
| 170 | char buf[60]; |
| 171 | |
| 172 | /* TODO: Enable support for other values */ |
| 173 | if (strcasecmp(val, "40") == 0) { |
| 174 | snprintf(buf, sizeof(buf), "wifitool %s beeliner_fw_test 54 1", |
| 175 | ifname); |
| 176 | if (system(buf) != 0) { |
| 177 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 178 | "wifitool cts_width failed"); |
| 179 | } |
Priyadharshini Gowthaman | 818afef | 2015-11-09 13:28:15 -0800 | [diff] [blame] | 180 | snprintf(buf, sizeof(buf), |
| 181 | "athdiag --set --address=0x10024 --val=0xd90b8a14"); |
| 182 | if (system(buf) != 0) { |
| 183 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 184 | "disabling phy restart failed"); |
| 185 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 186 | } else { |
| 187 | sigma_dut_print(dut, DUT_MSG_ERROR, "Unsupported CTS_WIDTH"); |
| 188 | } |
| 189 | } |
| 190 | |
| 191 | |
Priyadharshini Gowthaman | 818afef | 2015-11-09 13:28:15 -0800 | [diff] [blame] | 192 | void ath_config_dyn_bw_sig(struct sigma_dut *dut, const char *ifname, |
| 193 | const char *val) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 194 | { |
| 195 | char buf[60]; |
| 196 | |
| 197 | if (strcasecmp(val, "enable") == 0) { |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 198 | dut->ap_dyn_bw_sig = VALUE_ENABLED; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 199 | snprintf(buf, sizeof(buf), "iwpriv %s cwmenable 1", ifname); |
| 200 | if (system(buf) != 0) { |
| 201 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 202 | "iwpriv cwmenable 1 failed"); |
| 203 | } |
Priyadharshini Gowthaman | 818afef | 2015-11-09 13:28:15 -0800 | [diff] [blame] | 204 | snprintf(buf, sizeof(buf), "wifitool %s beeliner_fw_test 96 1", |
| 205 | ifname); |
| 206 | if (system(buf) != 0) { |
| 207 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 208 | "disabling RTS from rate control logic failed"); |
| 209 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 210 | } else if (strcasecmp(val, "disable") == 0) { |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 211 | dut->ap_dyn_bw_sig = VALUE_DISABLED; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 212 | snprintf(buf, sizeof(buf), "iwpriv %s cwmenable 0", ifname); |
| 213 | if (system(buf) != 0) { |
| 214 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 215 | "iwpriv cwmenable 0 failed"); |
| 216 | } |
| 217 | } else { |
| 218 | sigma_dut_print(dut, DUT_MSG_ERROR, "Unsupported DYN_BW_SGL"); |
| 219 | } |
| 220 | } |
| 221 | |
| 222 | |
| 223 | static void ath_config_rts_force(struct sigma_dut *dut, const char *ifname, |
| 224 | const char *val) |
| 225 | { |
| 226 | char buf[60]; |
| 227 | |
| 228 | if (strcasecmp(val, "enable") == 0) { |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 229 | dut->ap_sig_rts = VALUE_ENABLED; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 230 | snprintf(buf, sizeof(buf), "iwconfig %s rts 64", ifname); |
| 231 | if (system(buf) != 0) { |
| 232 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 233 | "iwconfig rts 64 failed"); |
| 234 | } |
priyadharshini gowthaman | 270870e | 2015-12-09 10:10:23 -0800 | [diff] [blame] | 235 | snprintf(buf, sizeof(buf), "wifitool %s beeliner_fw_test 100 1", |
| 236 | ifname); |
| 237 | if (system(buf) != 0) { |
| 238 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 239 | "wifitool beeliner_fw_test 100 1 failed"); |
| 240 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 241 | } else if (strcasecmp(val, "disable") == 0) { |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 242 | dut->ap_sig_rts = VALUE_DISABLED; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 243 | snprintf(buf, sizeof(buf), "iwconfig %s rts 2347", ifname); |
| 244 | if (system(buf) != 0) { |
| 245 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 246 | "iwpriv rts 2347 failed"); |
| 247 | } |
| 248 | } else { |
| 249 | sigma_dut_print(dut, DUT_MSG_ERROR, "Unsupported RTS_FORCE"); |
| 250 | } |
| 251 | } |
| 252 | |
| 253 | |
| 254 | static enum ap_mode get_mode(const char *str) |
| 255 | { |
| 256 | if (strcasecmp(str, "11a") == 0) |
| 257 | return AP_11a; |
| 258 | else if (strcasecmp(str, "11g") == 0) |
| 259 | return AP_11g; |
| 260 | else if (strcasecmp(str, "11b") == 0) |
| 261 | return AP_11b; |
| 262 | else if (strcasecmp(str, "11na") == 0) |
| 263 | return AP_11na; |
| 264 | else if (strcasecmp(str, "11ng") == 0) |
| 265 | return AP_11ng; |
| 266 | else if (strcasecmp(str, "11ac") == 0 || strcasecmp(str, "ac") == 0) |
| 267 | return AP_11ac; |
| 268 | else |
| 269 | return AP_inval; |
| 270 | } |
| 271 | |
| 272 | |
| 273 | static int run_hostapd_cli(struct sigma_dut *dut, char *buf) |
| 274 | { |
| 275 | char command[1000]; |
| 276 | const char *bin; |
| 277 | enum driver_type drv = get_driver_type(); |
Adil Saeed Musthafa | 3dd6ca7 | 2017-05-15 12:45:18 -0700 | [diff] [blame] | 278 | char *sigma_hapd_file = sigma_hapd_ctrl; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 279 | |
| 280 | if (file_exists("hostapd_cli")) |
| 281 | bin = "./hostapd_cli"; |
Jouni Malinen | d6bf1b4 | 2017-06-23 17:51:01 +0300 | [diff] [blame] | 282 | else if (file_exists("../../hostapd/hostapd_cli")) |
| 283 | bin = "../../hostapd/hostapd_cli"; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 284 | else |
| 285 | bin = "hostapd_cli"; |
| 286 | |
| 287 | if (drv == DRIVER_OPENWRT && sigma_hapd_ctrl == NULL) { |
Adil Saeed Musthafa | 3dd6ca7 | 2017-05-15 12:45:18 -0700 | [diff] [blame] | 288 | sigma_hapd_file = "/var/run/hostapd-wifi0"; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 289 | |
| 290 | if (sigma_radio_ifname[0] && |
| 291 | strcmp(sigma_radio_ifname[0], "wifi1") == 0) |
Adil Saeed Musthafa | 3dd6ca7 | 2017-05-15 12:45:18 -0700 | [diff] [blame] | 292 | sigma_hapd_file = "/var/run/hostapd-wifi1"; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 293 | else if (sigma_radio_ifname[0] && |
| 294 | strcmp(sigma_radio_ifname[0], "wifi2") == 0) |
Adil Saeed Musthafa | 3dd6ca7 | 2017-05-15 12:45:18 -0700 | [diff] [blame] | 295 | sigma_hapd_file = "/var/run/hostapd-wifi2"; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 296 | } |
| 297 | |
Adil Saeed Musthafa | 3dd6ca7 | 2017-05-15 12:45:18 -0700 | [diff] [blame] | 298 | if (sigma_hapd_file) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 299 | snprintf(command, sizeof(command), "%s -p %s %s", |
Adil Saeed Musthafa | 3dd6ca7 | 2017-05-15 12:45:18 -0700 | [diff] [blame] | 300 | bin, sigma_hapd_file, buf); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 301 | else |
| 302 | snprintf(command, sizeof(command), "%s %s", bin, buf); |
| 303 | return run_system(dut, command); |
| 304 | } |
| 305 | |
| 306 | |
priyadharshini gowthaman | 8e26ff4 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 307 | static int ath_set_lci_config(struct sigma_dut *dut, const char *val, |
| 308 | struct sigma_cmd *cmd) |
| 309 | { |
| 310 | FILE *f; |
| 311 | int i; |
| 312 | |
| 313 | f = fopen("/tmp/lci_cfg.txt", "w"); |
| 314 | if (!f) { |
| 315 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 316 | "Failed to open /tmp/lci_cfg.txt"); |
| 317 | return -1; |
| 318 | } |
| 319 | |
| 320 | for (i = 2; i < cmd->count; i++) |
| 321 | fprintf(f, "%s = %s \n", cmd->params[i], cmd->values[i]); |
| 322 | fprintf(f, "\n"); |
| 323 | fclose(f); |
| 324 | |
| 325 | return 0; |
| 326 | } |
| 327 | |
| 328 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 329 | static int cmd_ap_set_wireless(struct sigma_dut *dut, struct sigma_conn *conn, |
| 330 | struct sigma_cmd *cmd) |
| 331 | { |
| 332 | /* const char *name = get_param(cmd, "NAME"); */ |
| 333 | /* const char *ifname = get_param(cmd, "INTERFACE"); */ |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 334 | const char *val; |
| 335 | unsigned int wlan_tag = 1; |
| 336 | char *ifname = get_main_ifname(); |
| 337 | |
| 338 | val = get_param(cmd, "WLAN_TAG"); |
| 339 | if (val) { |
| 340 | wlan_tag = atoi(val); |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 341 | if (wlan_tag < 1 || wlan_tag > 3) { |
| 342 | /* |
| 343 | * The only valid WLAN Tags as of now as per the latest |
| 344 | * WFA scripts are 1, 2, and 3. |
| 345 | */ |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 346 | send_resp(dut, conn, SIGMA_INVALID, |
| 347 | "errorCode,Invalid WLAN_TAG"); |
| 348 | return 0; |
| 349 | } |
| 350 | } |
| 351 | |
| 352 | val = get_param(cmd, "CountryCode"); |
| 353 | if (val) { |
| 354 | if (strlen(val) > sizeof(dut->ap_countrycode) - 1) |
| 355 | return -1; |
| 356 | snprintf(dut->ap_countrycode, sizeof(dut->ap_countrycode), |
| 357 | "%s", val); |
| 358 | } |
| 359 | |
Pradeep Reddy POTTETI | fba27db | 2015-11-20 16:42:22 +0530 | [diff] [blame] | 360 | val = get_param(cmd, "regulatory_mode"); |
| 361 | if (val) { |
| 362 | if (strcasecmp(val, "11d") == 0 || strcasecmp(val, "11h") == 0) |
| 363 | dut->ap_regulatory_mode = AP_80211D_MODE_ENABLED; |
| 364 | } |
| 365 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 366 | val = get_param(cmd, "SSID"); |
| 367 | if (val) { |
| 368 | if (strlen(val) > sizeof(dut->ap_ssid) - 1) |
| 369 | return -1; |
| 370 | |
| 371 | if (wlan_tag == 1) { |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 372 | /* |
| 373 | * If tag is not specified, it is deemed to be 1. |
| 374 | * Hence tag of 1 is a special case and the values |
| 375 | * corresponding to wlan-tag=1 are stored separately |
| 376 | * from the values corresponding tags 2 and 3. |
| 377 | * This approach minimises the changes to existing code |
| 378 | * since most of the sigma_dut code does not deal with |
| 379 | * WLAN-TAG CAPI variable. |
| 380 | */ |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 381 | snprintf(dut->ap_ssid, |
| 382 | sizeof(dut->ap_ssid), "%s", val); |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 383 | } else { |
| 384 | snprintf(dut->ap_tag_ssid[wlan_tag - 2], |
| 385 | sizeof(dut->ap_tag_ssid[wlan_tag - 2]), |
| 386 | "%s", val); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 387 | } |
| 388 | } |
| 389 | |
| 390 | val = get_param(cmd, "CHANNEL"); |
| 391 | if (val) { |
| 392 | const char *pos; |
| 393 | dut->ap_channel = atoi(val); |
| 394 | pos = strchr(val, ';'); |
| 395 | if (pos) { |
| 396 | pos++; |
| 397 | dut->ap_channel_1 = atoi(pos); |
| 398 | } |
| 399 | } |
| 400 | |
Pradeep Reddy POTTETI | fba27db | 2015-11-20 16:42:22 +0530 | [diff] [blame] | 401 | /* Overwrite the AP channel with DFS channel if configured */ |
| 402 | val = get_param(cmd, "dfs_chan"); |
| 403 | if (val) { |
| 404 | dut->ap_channel = atoi(val); |
| 405 | } |
| 406 | |
| 407 | val = get_param(cmd, "dfs_mode"); |
| 408 | if (val) { |
| 409 | if (strcasecmp(val, "Enable") == 0) |
| 410 | dut->ap_dfs_mode = AP_DFS_MODE_ENABLED; |
| 411 | else if (strcasecmp(val, "Disable") == 0) |
| 412 | dut->ap_dfs_mode = AP_DFS_MODE_DISABLED; |
| 413 | else |
| 414 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 415 | "Unsupported dfs_mode value: %s", val); |
| 416 | } |
| 417 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 418 | val = get_param(cmd, "MODE"); |
| 419 | if (val) { |
| 420 | char *str, *pos; |
| 421 | |
| 422 | str = strdup(val); |
| 423 | if (str == NULL) |
| 424 | return -1; |
| 425 | pos = strchr(str, ';'); |
| 426 | if (pos) |
| 427 | *pos++ = '\0'; |
| 428 | |
| 429 | dut->ap_is_dual = 0; |
| 430 | dut->ap_mode = get_mode(str); |
| 431 | if (dut->ap_mode == AP_inval) { |
| 432 | send_resp(dut, conn, SIGMA_INVALID, |
| 433 | "errorCode,Unsupported MODE"); |
| 434 | free(str); |
| 435 | return 0; |
| 436 | } |
| 437 | if (dut->ap_mode == AP_11ac) |
| 438 | dut->ap_chwidth = AP_80; |
| 439 | |
| 440 | if (pos) { |
| 441 | dut->ap_mode_1 = get_mode(pos); |
| 442 | if (dut->ap_mode_1 == AP_inval) { |
| 443 | send_resp(dut, conn, SIGMA_INVALID, |
| 444 | "errorCode,Unsupported MODE"); |
| 445 | free(str); |
| 446 | return 0; |
| 447 | } |
| 448 | if (dut->ap_mode_1 == AP_11ac) |
| 449 | dut->ap_chwidth_1 = AP_80; |
| 450 | dut->ap_is_dual = 1; |
| 451 | } |
| 452 | |
| 453 | free(str); |
| 454 | } else if (dut->ap_mode == AP_inval) { |
| 455 | if (dut->ap_channel <= 11) |
| 456 | dut->ap_mode = AP_11ng; |
| 457 | else if (dut->program == PROGRAM_VHT) |
| 458 | dut->ap_mode = AP_11ac; |
| 459 | else |
| 460 | dut->ap_mode = AP_11na; |
| 461 | } |
| 462 | |
Pradeep Reddy POTTETI | 0d3db63 | 2016-03-11 15:21:11 +0530 | [diff] [blame] | 463 | val = get_param(cmd, "WME"); |
| 464 | if (val) { |
| 465 | if (strcasecmp(val, "on") == 0) |
| 466 | dut->ap_wme = AP_WME_ON; |
| 467 | else if (strcasecmp(val, "off") == 0) |
| 468 | dut->ap_wme = AP_WME_OFF; |
| 469 | else |
| 470 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 471 | "Unsupported WME value: %s", val); |
| 472 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 473 | |
Mohammed Shafi Shajakhan | 02e3b82 | 2017-02-23 04:15:02 +0530 | [diff] [blame] | 474 | val = get_param(cmd, "WMMPS"); |
| 475 | if (val) { |
| 476 | if (strcasecmp(val, "on") == 0) |
| 477 | dut->ap_wmmps = AP_WMMPS_ON; |
| 478 | else if (strcasecmp(val, "off") == 0) |
| 479 | dut->ap_wmmps = AP_WMMPS_OFF; |
| 480 | else |
| 481 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 482 | "Unsupported WMMPS value: %s", val); |
| 483 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 484 | |
| 485 | val = get_param(cmd, "RTS"); |
| 486 | if (val) |
| 487 | dut->ap_rts = atoi(val); |
| 488 | |
| 489 | val = get_param(cmd, "FRGMNT"); |
| 490 | if (val) |
| 491 | dut->ap_frgmnt = atoi(val); |
| 492 | |
| 493 | /* TODO: PWRSAVE */ |
| 494 | |
| 495 | val = get_param(cmd, "BCNINT"); |
| 496 | if (val) |
| 497 | dut->ap_bcnint = atoi(val); |
| 498 | |
| 499 | val = get_param(cmd, "RADIO"); |
| 500 | if (val) { |
Mohammed Shafi Shajakhan | 94997f9 | 2017-01-09 21:31:09 +0530 | [diff] [blame] | 501 | enum driver_type drv = get_driver_type(); |
| 502 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 503 | if (strcasecmp(val, "on") == 0) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 504 | if (drv == DRIVER_ATHEROS) |
| 505 | ath_ap_start_hostapd(dut); |
| 506 | else if (cmd_ap_config_commit(dut, conn, cmd) <= 0) |
| 507 | return 0; |
| 508 | } else if (strcasecmp(val, "off") == 0) { |
Mohammed Shafi Shajakhan | 94997f9 | 2017-01-09 21:31:09 +0530 | [diff] [blame] | 509 | if (drv == DRIVER_OPENWRT) { |
| 510 | run_system(dut, "wifi down"); |
| 511 | sigma_dut_print(dut, DUT_MSG_INFO, |
| 512 | "wifi down on radio,off"); |
Jouni Malinen | d6bf1b4 | 2017-06-23 17:51:01 +0300 | [diff] [blame] | 513 | } else if (dut->use_hostapd_pid_file) { |
| 514 | kill_hostapd_process_pid(dut); |
Mohammed Shafi Shajakhan | 94997f9 | 2017-01-09 21:31:09 +0530 | [diff] [blame] | 515 | } else if (kill_process(dut, "(hostapd)", 1, |
| 516 | SIGTERM) == 0 || |
| 517 | system("killall hostapd") == 0) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 518 | sigma_dut_print(dut, DUT_MSG_INFO, |
| 519 | "Killed hostapd on radio,off"); |
| 520 | } |
| 521 | } else { |
| 522 | send_resp(dut, conn, SIGMA_INVALID, |
| 523 | "errorCode,Unsupported RADIO value"); |
| 524 | return 0; |
| 525 | } |
| 526 | } |
| 527 | |
| 528 | val = get_param(cmd, "P2PMgmtBit"); |
| 529 | if (val) |
| 530 | dut->ap_p2p_mgmt = atoi(val); |
| 531 | |
| 532 | /* TODO: ChannelUsage */ |
| 533 | |
| 534 | /* TODO: 40_INTOLERANT */ |
| 535 | |
| 536 | val = get_param(cmd, "ADDBA_REJECT"); |
| 537 | if (val) { |
| 538 | if (strcasecmp(val, "Enable") == 0) |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 539 | dut->ap_addba_reject = VALUE_ENABLED; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 540 | else if (strcasecmp(val, "Disable") == 0) |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 541 | dut->ap_addba_reject = VALUE_DISABLED; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 542 | } |
| 543 | |
| 544 | val = get_param(cmd, "AMPDU"); |
| 545 | if (val) { |
| 546 | if (strcasecmp(val, "Enable") == 0) |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 547 | dut->ap_ampdu = VALUE_ENABLED; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 548 | else if (strcasecmp(val, "Disable") == 0) |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 549 | dut->ap_ampdu = VALUE_DISABLED; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 550 | } |
| 551 | |
| 552 | val = get_param(cmd, "AMPDU_EXP"); |
| 553 | if (val) |
| 554 | dut->ap_ampdu_exp = atoi(val); |
| 555 | |
| 556 | val = get_param(cmd, "AMSDU"); |
| 557 | if (val) { |
| 558 | if (strcasecmp(val, "Enable") == 0) |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 559 | dut->ap_amsdu = VALUE_ENABLED; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 560 | else if (strcasecmp(val, "Disable") == 0) |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 561 | dut->ap_amsdu = VALUE_DISABLED; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 562 | } |
| 563 | |
| 564 | val = get_param(cmd, "NoAck"); |
| 565 | if (val) { |
| 566 | if (strcasecmp(val, "on") == 0) |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 567 | dut->ap_noack = VALUE_ENABLED; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 568 | else if (strcasecmp(val, "off") == 0) |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 569 | dut->ap_noack = VALUE_DISABLED; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 570 | } |
| 571 | |
| 572 | /* TODO: GREENFIELD */ |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 573 | /* TODO: MCS_32 */ |
| 574 | |
Pradeep Reddy Potteti | 4b0cdee | 2017-03-15 12:37:33 +0530 | [diff] [blame] | 575 | val = get_param(cmd, "OFFSET"); |
| 576 | if (val) { |
| 577 | if (strcasecmp(val, "Above") == 0) |
| 578 | dut->ap_chwidth_offset = SEC_CH_40ABOVE; |
| 579 | else if (strcasecmp(val, "Below") == 0) |
| 580 | dut->ap_chwidth_offset = SEC_CH_40BELOW; |
| 581 | } |
| 582 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 583 | val = get_param(cmd, "MCS_FIXEDRATE"); |
| 584 | if (val) { |
| 585 | dut->ap_fixed_rate = 1; |
| 586 | dut->ap_mcs = atoi(val); |
| 587 | } |
| 588 | |
| 589 | val = get_param(cmd, "SPATIAL_RX_STREAM"); |
| 590 | if (val) { |
| 591 | if (strcasecmp(val, "1SS") == 0 || strcasecmp(val, "1") == 0) { |
| 592 | dut->ap_rx_streams = 1; |
| 593 | if (dut->device_type == AP_testbed) |
| 594 | dut->ap_vhtmcs_map = 0xfffc; |
| 595 | } else if (strcasecmp(val, "2SS") == 0 || |
| 596 | strcasecmp(val, "2") == 0) { |
| 597 | dut->ap_rx_streams = 2; |
| 598 | if (dut->device_type == AP_testbed) |
| 599 | dut->ap_vhtmcs_map = 0xfff0; |
| 600 | } else if (strcasecmp(val, "3SS") == 0 || |
| 601 | strcasecmp(val, "3") == 0) { |
| 602 | dut->ap_rx_streams = 3; |
| 603 | if (dut->device_type == AP_testbed) |
| 604 | dut->ap_vhtmcs_map = 0xffc0; |
| 605 | } else if (strcasecmp(val, "4SS") == 0 || |
| 606 | strcasecmp(val, "4") == 0) { |
| 607 | dut->ap_rx_streams = 4; |
| 608 | } |
| 609 | } |
| 610 | |
| 611 | val = get_param(cmd, "SPATIAL_TX_STREAM"); |
| 612 | if (val) { |
| 613 | if (strcasecmp(val, "1SS") == 0 || |
| 614 | strcasecmp(val, "1") == 0) { |
| 615 | dut->ap_tx_streams = 1; |
| 616 | if (dut->device_type == AP_testbed) |
| 617 | dut->ap_vhtmcs_map = 0xfffc; |
| 618 | } else if (strcasecmp(val, "2SS") == 0 || |
| 619 | strcasecmp(val, "2") == 0) { |
| 620 | dut->ap_tx_streams = 2; |
| 621 | if (dut->device_type == AP_testbed) |
| 622 | dut->ap_vhtmcs_map = 0xfff0; |
| 623 | } else if (strcasecmp(val, "3SS") == 0 || |
| 624 | strcasecmp(val, "3") == 0) { |
| 625 | dut->ap_tx_streams = 3; |
| 626 | if (dut->device_type == AP_testbed) |
| 627 | dut->ap_vhtmcs_map = 0xffc0; |
| 628 | } else if (strcasecmp(val, "4SS") == 0 || |
| 629 | strcasecmp(val, "4") == 0) { |
| 630 | dut->ap_tx_streams = 4; |
| 631 | } |
| 632 | } |
| 633 | |
Adil Saeed Musthafa | 33ea287 | 2017-04-10 23:13:24 -0700 | [diff] [blame] | 634 | val = get_param(cmd, "BSS_max_idle"); |
| 635 | if (val) { |
| 636 | if (strncasecmp(val, "Enable", 7) == 0) { |
| 637 | dut->wnm_bss_max_feature = VALUE_ENABLED; |
| 638 | } else if (strncasecmp(val, "Disable", 8) == 0) { |
| 639 | dut->wnm_bss_max_feature = VALUE_DISABLED; |
| 640 | } else { |
| 641 | send_resp(dut, conn, SIGMA_ERROR, |
| 642 | "errorCode,Invalid value for BSS_max_Feature"); |
| 643 | return 0; |
| 644 | } |
| 645 | } |
| 646 | |
| 647 | val = get_param(cmd, "BSS_Idle_Protection_options"); |
| 648 | if (val) { |
| 649 | int protection = (int) strtol(val, (char **) NULL, 10); |
| 650 | |
| 651 | if (protection != 1 && protection != 0) { |
| 652 | send_resp(dut, conn, SIGMA_ERROR, |
| 653 | "errorCode,Invalid value for BSS_Idle_Protection_options"); |
| 654 | return 0; |
| 655 | } |
| 656 | dut->wnm_bss_max_protection = protection ? |
| 657 | VALUE_ENABLED : VALUE_DISABLED; |
| 658 | } |
| 659 | |
| 660 | val = get_param(cmd, "BSS_max_Idle_period"); |
| 661 | if (val) { |
| 662 | int idle_time = (int) strtol(val, (char **) NULL, 10); |
| 663 | |
| 664 | if (idle_time == LONG_MIN || idle_time == LONG_MAX) { |
| 665 | send_resp(dut, conn, SIGMA_ERROR, |
| 666 | "errorCode,Invalid value for BSS_max_Idle_period"); |
| 667 | return 0; |
| 668 | } |
| 669 | dut->wnm_bss_max_idle_time = idle_time; |
| 670 | } |
| 671 | |
| 672 | val = get_param(cmd, "PROXY_ARP"); |
| 673 | if (val) |
| 674 | dut->ap_proxy_arp = (int) strtol(val, (char **) NULL, 10); |
| 675 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 676 | val = get_param(cmd, "nss_mcs_cap"); |
| 677 | if (val) { |
| 678 | int nss, mcs; |
| 679 | char token[20]; |
| 680 | char *result = NULL; |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 681 | char *saveptr; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 682 | |
| 683 | if (strlen(val) >= sizeof(token)) |
| 684 | return -1; |
Jouni Malinen | 947fdf6 | 2017-05-14 22:29:32 +0300 | [diff] [blame] | 685 | strlcpy(token, val, sizeof(token)); |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 686 | result = strtok_r(token, ";", &saveptr); |
Pradeep Reddy POTTETI | 41b8c54 | 2016-06-15 16:09:46 +0530 | [diff] [blame] | 687 | if (!result) { |
| 688 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 689 | "VHT NSS not specified"); |
| 690 | return 0; |
| 691 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 692 | nss = atoi(result); |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 693 | result = strtok_r(NULL, ";", &saveptr); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 694 | if (result == NULL) { |
| 695 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 696 | "VHTMCS NOT SPECIFIED!"); |
| 697 | return 0; |
| 698 | } |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 699 | result = strtok_r(result, "-", &saveptr); |
| 700 | result = strtok_r(NULL, "-", &saveptr); |
Pradeep Reddy POTTETI | 41b8c54 | 2016-06-15 16:09:46 +0530 | [diff] [blame] | 701 | if (!result) { |
| 702 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 703 | "VHT MCS not specified"); |
| 704 | return 0; |
| 705 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 706 | mcs = atoi(result); |
| 707 | switch (nss) { |
| 708 | case 1: |
| 709 | switch (mcs) { |
| 710 | case 7: |
| 711 | dut->ap_vhtmcs_map = 0xfffc; |
| 712 | break; |
| 713 | case 8: |
| 714 | dut->ap_vhtmcs_map = 0xfffd; |
| 715 | break; |
| 716 | case 9: |
| 717 | dut->ap_vhtmcs_map = 0xfffe; |
| 718 | break; |
| 719 | default: |
| 720 | dut->ap_vhtmcs_map = 0xfffe; |
| 721 | break; |
| 722 | } |
| 723 | break; |
| 724 | case 2: |
| 725 | switch (mcs) { |
| 726 | case 7: |
| 727 | dut->ap_vhtmcs_map = 0xfff0; |
| 728 | break; |
| 729 | case 8: |
| 730 | dut->ap_vhtmcs_map = 0xfff5; |
| 731 | break; |
| 732 | case 9: |
| 733 | dut->ap_vhtmcs_map = 0xfffa; |
| 734 | break; |
| 735 | default: |
| 736 | dut->ap_vhtmcs_map = 0xfffa; |
| 737 | break; |
| 738 | } |
| 739 | break; |
| 740 | case 3: |
| 741 | switch (mcs) { |
| 742 | case 7: |
| 743 | dut->ap_vhtmcs_map = 0xffc0; |
| 744 | break; |
| 745 | case 8: |
| 746 | dut->ap_vhtmcs_map = 0xffd5; |
| 747 | break; |
| 748 | case 9: |
| 749 | dut->ap_vhtmcs_map = 0xffea; |
| 750 | break; |
| 751 | default: |
| 752 | dut->ap_vhtmcs_map = 0xffea; |
| 753 | break; |
| 754 | } |
| 755 | break; |
| 756 | default: |
| 757 | dut->ap_vhtmcs_map = 0xffea; |
| 758 | break; |
| 759 | } |
| 760 | } |
| 761 | |
| 762 | /* TODO: MPDU_MIN_START_SPACING */ |
| 763 | /* TODO: RIFS_TEST */ |
| 764 | /* TODO: SGI20 */ |
| 765 | |
| 766 | val = get_param(cmd, "STBC_TX"); |
| 767 | if (val) |
| 768 | dut->ap_tx_stbc = atoi(val); |
| 769 | |
| 770 | val = get_param(cmd, "WIDTH"); |
| 771 | if (val) { |
| 772 | if (strcasecmp(val, "20") == 0) |
| 773 | dut->ap_chwidth = AP_20; |
| 774 | else if (strcasecmp(val, "40") == 0) |
| 775 | dut->ap_chwidth = AP_40; |
| 776 | else if (strcasecmp(val, "80") == 0) |
| 777 | dut->ap_chwidth = AP_80; |
| 778 | else if (strcasecmp(val, "160") == 0) |
| 779 | dut->ap_chwidth = AP_160; |
| 780 | else if (strcasecmp(val, "Auto") == 0) |
| 781 | dut->ap_chwidth = AP_AUTO; |
| 782 | else { |
| 783 | send_resp(dut, conn, SIGMA_INVALID, |
| 784 | "errorCode,Unsupported WIDTH"); |
| 785 | return 0; |
| 786 | } |
| 787 | } |
| 788 | |
| 789 | /* TODO: WIDTH_SCAN */ |
| 790 | |
| 791 | val = get_param(cmd, "TDLSProhibit"); |
| 792 | dut->ap_tdls_prohibit = val && strcasecmp(val, "Enabled") == 0; |
| 793 | val = get_param(cmd, "TDLSChswitchProhibit"); |
| 794 | dut->ap_tdls_prohibit_chswitch = |
| 795 | val && strcasecmp(val, "Enabled") == 0; |
| 796 | val = get_param(cmd, "HS2"); |
| 797 | if (val && wlan_tag == 1) |
| 798 | dut->ap_hs2 = atoi(val); |
| 799 | val = get_param(cmd, "P2P_CROSS_CONNECT"); |
| 800 | if (val) |
| 801 | dut->ap_p2p_cross_connect = strcasecmp(val, "Enabled") == 0; |
| 802 | |
| 803 | val = get_param(cmd, "FakePubKey"); |
| 804 | dut->ap_fake_pkhash = val && atoi(val); |
| 805 | |
| 806 | val = get_param(cmd, "vht_tkip"); |
| 807 | dut->ap_allow_vht_tkip = val && strcasecmp(val, "Enable") == 0; |
| 808 | val = get_param(cmd, "vht_wep"); |
| 809 | dut->ap_allow_vht_wep = val && strcasecmp(val, "Enable") == 0; |
| 810 | |
| 811 | val = get_param(cmd, "Protect_mode"); |
| 812 | dut->ap_disable_protection = val && strcasecmp(val, "Disable") == 0; |
| 813 | |
| 814 | val = get_param(cmd, "DYN_BW_SGNL"); |
| 815 | if (val) { |
| 816 | switch (get_driver_type()) { |
| 817 | case DRIVER_OPENWRT: |
| 818 | switch (get_openwrt_driver_type()) { |
| 819 | case OPENWRT_DRIVER_ATHEROS: |
| 820 | ath_config_dyn_bw_sig(dut, ifname, val); |
| 821 | break; |
| 822 | default: |
| 823 | send_resp(dut, conn, SIGMA_ERROR, |
| 824 | "errorCode,Unsupported DYN_BW_SGNL with OpenWrt driver"); |
| 825 | return 0; |
| 826 | } |
| 827 | break; |
| 828 | default: |
| 829 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 830 | "Unsupported DYN_BW_SGL with the current driver"); |
| 831 | break; |
| 832 | } |
| 833 | } |
| 834 | |
| 835 | val = get_param(cmd, "SGI80"); |
| 836 | if (val) { |
| 837 | if (strcasecmp(val, "enable") == 0) |
| 838 | dut->ap_sgi80 = 1; |
| 839 | else if (strcasecmp(val, "disable") == 0) |
| 840 | dut->ap_sgi80 = 0; |
| 841 | else { |
| 842 | send_resp(dut, conn, SIGMA_INVALID, |
| 843 | "errorCode,Unsupported SGI80"); |
| 844 | return 0; |
| 845 | } |
| 846 | } |
| 847 | |
| 848 | val = get_param(cmd, "LDPC"); |
| 849 | if (val) { |
| 850 | if (strcasecmp(val, "enable") == 0) |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 851 | dut->ap_ldpc = VALUE_ENABLED; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 852 | else if (strcasecmp(val, "disable") == 0) |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 853 | dut->ap_ldpc = VALUE_DISABLED; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 854 | else { |
| 855 | send_resp(dut, conn, SIGMA_INVALID, |
| 856 | "errorCode,Unsupported LDPC"); |
| 857 | return 0; |
| 858 | } |
| 859 | } |
| 860 | |
| 861 | val = get_param(cmd, "BW_SGNL"); |
| 862 | if (val) { |
| 863 | /* |
| 864 | * With dynamic bandwidth signaling enabled we should see |
| 865 | * RTS if the threshold is met. |
| 866 | */ |
| 867 | if (strcasecmp(val, "enable") == 0) { |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 868 | dut->ap_sig_rts = VALUE_ENABLED; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 869 | } else if (strcasecmp(val, "disable") == 0) { |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 870 | dut->ap_sig_rts = VALUE_DISABLED; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 871 | } else { |
| 872 | send_resp(dut, conn, SIGMA_INVALID, |
| 873 | "errorCode,Unsupported BW_SGNL"); |
| 874 | return 0; |
| 875 | } |
| 876 | } |
| 877 | |
| 878 | val = get_param(cmd, "RTS_FORCE"); |
| 879 | if (val) { |
| 880 | switch (get_driver_type()) { |
| 881 | case DRIVER_OPENWRT: |
| 882 | switch (get_openwrt_driver_type()) { |
| 883 | case OPENWRT_DRIVER_ATHEROS: |
| 884 | ath_config_rts_force(dut, ifname, val); |
| 885 | break; |
| 886 | default: |
| 887 | send_resp(dut, conn, SIGMA_ERROR, |
| 888 | "errorCode,Unsupported RTS_FORCE with OpenWrt driver"); |
| 889 | return 0; |
| 890 | } |
| 891 | break; |
| 892 | default: |
| 893 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 894 | "Unsupported RTS_FORCE with the current driver"); |
| 895 | break; |
| 896 | } |
| 897 | } |
| 898 | |
| 899 | val = get_param(cmd, "Zero_crc"); |
| 900 | if (val) { |
| 901 | switch (get_driver_type()) { |
| 902 | case DRIVER_ATHEROS: |
| 903 | ath_set_zero_crc(dut, val); |
| 904 | break; |
| 905 | case DRIVER_OPENWRT: |
| 906 | switch (get_openwrt_driver_type()) { |
| 907 | case OPENWRT_DRIVER_ATHEROS: |
| 908 | ath_set_zero_crc(dut, val); |
| 909 | break; |
| 910 | default: |
| 911 | send_resp(dut, conn, SIGMA_ERROR, |
| 912 | "errorCode,Unsupported zero_crc with the current driver"); |
| 913 | return 0; |
| 914 | } |
| 915 | break; |
| 916 | default: |
| 917 | send_resp(dut, conn, SIGMA_ERROR, |
| 918 | "errorCode,Unsupported zero_crc with the current driver"); |
| 919 | return 0; |
| 920 | } |
| 921 | } |
| 922 | |
| 923 | val = get_param(cmd, "TxBF"); |
| 924 | if (val) |
| 925 | dut->ap_txBF = strcasecmp(val, "enable") == 0; |
| 926 | |
| 927 | val = get_param(cmd, "MU_TxBF"); |
Manikanta Pubbisetty | 210f7c8 | 2017-02-14 12:33:54 +0530 | [diff] [blame] | 928 | if (val) { |
| 929 | if (strcasecmp(val, "enable") == 0) { |
| 930 | dut->ap_txBF = 1; |
| 931 | dut->ap_mu_txBF = 1; |
| 932 | } else if (strcasecmp(val, "disable") == 0) { |
| 933 | dut->ap_txBF = 0; |
| 934 | dut->ap_mu_txBF = 0; |
| 935 | } else { |
| 936 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 937 | "Unsupported MU_TxBF"); |
| 938 | } |
| 939 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 940 | |
| 941 | /* UNSUPPORTED: tx_lgi_rate */ |
| 942 | |
| 943 | val = get_param(cmd, "wpsnfc"); |
| 944 | if (val) |
| 945 | dut->ap_wpsnfc = atoi(val); |
| 946 | |
| 947 | val = get_param(cmd, "GROUP_ID"); |
| 948 | if (val) { |
| 949 | switch (get_driver_type()) { |
| 950 | case DRIVER_OPENWRT: |
| 951 | switch (get_openwrt_driver_type()) { |
| 952 | case OPENWRT_DRIVER_ATHEROS: |
| 953 | ath_ap_set_group_id(dut, ifname, val); |
| 954 | break; |
| 955 | default: |
| 956 | send_resp(dut, conn, SIGMA_ERROR, |
| 957 | "errorCode,Unsupported group_id with the current driver"); |
| 958 | return 0; |
| 959 | } |
| 960 | break; |
| 961 | default: |
| 962 | send_resp(dut, conn, SIGMA_ERROR, |
| 963 | "errorCode,Unsupported group_id with the current driver"); |
| 964 | return 0; |
| 965 | } |
| 966 | } |
| 967 | |
| 968 | val = get_param(cmd, "CTS_WIDTH"); |
| 969 | if (val) { |
| 970 | switch (get_driver_type()) { |
| 971 | case DRIVER_OPENWRT: |
| 972 | switch (get_openwrt_driver_type()) { |
| 973 | case OPENWRT_DRIVER_ATHEROS: |
| 974 | ath_set_cts_width(dut, ifname, val); |
| 975 | break; |
| 976 | default: |
| 977 | send_resp(dut, conn, SIGMA_ERROR, |
| 978 | "errorCode,Unsupported cts_width with the current driver"); |
| 979 | return 0; |
| 980 | } |
| 981 | break; |
| 982 | default: |
| 983 | send_resp(dut, conn, SIGMA_ERROR, |
| 984 | "errorCode,Unsupported cts_width with the current driver"); |
| 985 | return 0; |
| 986 | } |
| 987 | } |
| 988 | |
priyadharshini gowthaman | 264d544 | 2016-02-25 15:52:22 -0800 | [diff] [blame] | 989 | val = get_param(cmd, "MU_NDPA_FrameFormat"); |
| 990 | if (val) |
| 991 | dut->ap_ndpa_frame = atoi(val); |
| 992 | |
priyadharshini gowthaman | c52fff8 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 993 | val = get_param(cmd, "interworking"); |
| 994 | if (val && strcmp(val, "1") == 0) |
| 995 | dut->ap_interworking = 1; |
| 996 | |
| 997 | val = get_param(cmd, "GAS_CB_DELAY"); |
| 998 | if (val) |
| 999 | dut->ap_gas_cb_delay = atoi(val); |
| 1000 | |
priyadharshini gowthaman | 8e26ff4 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 1001 | val = get_param(cmd, "LCI"); |
| 1002 | if (val) { |
| 1003 | if (strlen(val) > sizeof(dut->ap_val_lci) - 1) |
| 1004 | return -1; |
| 1005 | dut->ap_lci = 1; |
| 1006 | snprintf(dut->ap_val_lci, sizeof(dut->ap_val_lci), "%s", val); |
| 1007 | ath_set_lci_config(dut, val, cmd); |
| 1008 | } |
| 1009 | |
priyadharshini gowthaman | c2357bd | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 1010 | val = get_param(cmd, "InfoZ"); |
| 1011 | if (val) { |
| 1012 | if (strlen(val) > sizeof(dut->ap_infoz) - 1) |
| 1013 | return -1; |
| 1014 | snprintf(dut->ap_infoz, sizeof(dut->ap_infoz), "%s", val); |
| 1015 | } |
| 1016 | |
priyadharshini gowthaman | 8e26ff4 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 1017 | val = get_param(cmd, "LocCivicAddr"); |
| 1018 | if (val) { |
| 1019 | if (strlen(val) > sizeof(dut->ap_val_lcr) - 1) |
| 1020 | return -1; |
| 1021 | dut->ap_lcr = 1; |
| 1022 | snprintf(dut->ap_val_lcr, sizeof(dut->ap_val_lcr), "%s", val); |
| 1023 | if (dut->ap_lci == 0) |
| 1024 | ath_set_lci_config(dut, val, cmd); |
| 1025 | } |
| 1026 | |
| 1027 | val = get_param(cmd, "NeighAPBSSID"); |
| 1028 | if (val) { |
| 1029 | if (dut->ap_neighap < 3) { |
| 1030 | if (parse_mac_address( |
| 1031 | dut, val, |
| 1032 | dut->ap_val_neighap[dut->ap_neighap]) < 0) { |
| 1033 | send_resp(dut, conn, SIGMA_INVALID, |
| 1034 | "Failed to parse MAC address"); |
| 1035 | return 0; |
| 1036 | } |
| 1037 | dut->ap_neighap++; |
| 1038 | if (dut->ap_lci == 1) |
| 1039 | dut->ap_scan = 1; |
| 1040 | } |
| 1041 | } |
| 1042 | |
| 1043 | val = get_param(cmd, "OpChannel"); |
| 1044 | if (val) { |
| 1045 | if (dut->ap_opchannel < 3) { |
| 1046 | dut->ap_val_opchannel[dut->ap_opchannel] = atoi(val); |
| 1047 | dut->ap_opchannel++; |
| 1048 | } |
| 1049 | } |
| 1050 | |
priyadharshini gowthaman | c2357bd | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 1051 | val = get_param(cmd, "URI-FQDNdescriptor"); |
| 1052 | if (val) { |
| 1053 | if (strcasecmp(val, "HELD") == 0) { |
| 1054 | dut->ap_fqdn_held = 1; |
| 1055 | } else if (strcasecmp(val, "SUPL") == 0) { |
| 1056 | dut->ap_fqdn_supl = 1; |
| 1057 | } else { |
| 1058 | send_resp(dut, conn, SIGMA_INVALID, |
| 1059 | "errorCode,Unsupported URI-FQDNdescriptor"); |
| 1060 | return 0; |
| 1061 | } |
| 1062 | } |
| 1063 | |
Adil Saeed Musthafa | 604c826 | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 1064 | val = get_param(cmd, "Reg_Domain"); |
| 1065 | if (val) { |
| 1066 | if (strcasecmp(val, "Local") == 0) { |
| 1067 | dut->ap_reg_domain = REG_DOMAIN_LOCAL; |
| 1068 | } else if (strcasecmp(val, "Global") == 0) { |
| 1069 | dut->ap_reg_domain = REG_DOMAIN_GLOBAL; |
| 1070 | } else { |
| 1071 | send_resp(dut, conn, SIGMA_ERROR, |
| 1072 | "errorCode,Wrong value for Reg_Domain"); |
| 1073 | return 0; |
| 1074 | } |
| 1075 | } |
| 1076 | |
Adil Saeed Musthafa | 4ec61bd | 2017-04-10 23:13:41 -0700 | [diff] [blame] | 1077 | val = get_param(cmd, "NAME"); |
| 1078 | if (val) { |
| 1079 | if (strcasecmp(val, "ap1mbo") == 0) |
| 1080 | dut->ap_name = 1; |
| 1081 | else if (strcasecmp(val, "ap2mbo") == 0) |
| 1082 | dut->ap_name = 2; |
| 1083 | else |
| 1084 | dut->ap_name = 0; |
| 1085 | } |
| 1086 | |
| 1087 | val = get_param(cmd, "FT_OA"); |
| 1088 | if (val) { |
| 1089 | if (strcasecmp(val, "Enable") == 0) { |
| 1090 | dut->ap_ft_oa = 1; |
| 1091 | } else if (strcasecmp(val, "Disable") == 0) { |
| 1092 | dut->ap_ft_oa = 0; |
| 1093 | } else { |
| 1094 | send_resp(dut, conn, SIGMA_ERROR, |
| 1095 | "errorCode,Wrong value for FT_OA"); |
| 1096 | return 0; |
| 1097 | } |
| 1098 | } |
| 1099 | |
Adil Saeed Musthafa | 023108a | 2017-04-10 23:13:37 -0700 | [diff] [blame] | 1100 | val = get_param(cmd, "Cellular_Cap_Pref"); |
| 1101 | if (val) |
| 1102 | dut->ap_cell_cap_pref = atoi(val); |
| 1103 | |
Adil Saeed Musthafa | cf752fa | 2017-04-10 23:13:32 -0700 | [diff] [blame] | 1104 | val = get_param(cmd, "DOMAIN"); |
| 1105 | if (val) { |
| 1106 | if (strlen(val) >= sizeof(dut->ap_mobility_domain)) { |
| 1107 | send_resp(dut, conn, SIGMA_ERROR, |
| 1108 | "errorCode,Too long DOMAIN"); |
| 1109 | return 0; |
| 1110 | } |
| 1111 | snprintf(dut->ap_mobility_domain, |
| 1112 | sizeof(dut->ap_mobility_domain), "%s", val); |
| 1113 | } |
| 1114 | |
Adil Saeed Musthafa | 4ec61bd | 2017-04-10 23:13:41 -0700 | [diff] [blame] | 1115 | val = get_param(cmd, "ft_bss_list"); |
| 1116 | if (val) { |
| 1117 | char *mac_str; |
| 1118 | int i; |
| 1119 | char *saveptr; |
| 1120 | char *mac_list_str; |
| 1121 | |
| 1122 | mac_list_str = strdup(val); |
| 1123 | if (!mac_list_str) |
| 1124 | return -1; |
| 1125 | mac_str = strtok_r(mac_list_str, " ", &saveptr); |
| 1126 | for (i = 0; mac_str && i < MAX_FT_BSS_LIST; i++) { |
| 1127 | if (parse_mac_address(dut, mac_str, |
| 1128 | dut->ft_bss_mac_list[i]) < 0) { |
| 1129 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 1130 | "MAC Address not in proper format"); |
| 1131 | break; |
| 1132 | } |
| 1133 | dut->ft_bss_mac_cnt++; |
| 1134 | mac_str = strtok_r(NULL, " ", &saveptr); |
| 1135 | } |
| 1136 | sigma_dut_print(dut, DUT_MSG_DEBUG, |
| 1137 | "Storing the following FT BSS MAC List"); |
| 1138 | for (i = 0; i < dut->ft_bss_mac_cnt; i++) { |
| 1139 | sigma_dut_print(dut, DUT_MSG_DEBUG, |
| 1140 | "MAC[%d] %02x:%02x:%02x:%02x:%02x:%02x", |
| 1141 | i, |
| 1142 | dut->ft_bss_mac_list[i][0], |
| 1143 | dut->ft_bss_mac_list[i][1], |
| 1144 | dut->ft_bss_mac_list[i][2], |
| 1145 | dut->ft_bss_mac_list[i][3], |
| 1146 | dut->ft_bss_mac_list[i][4], |
| 1147 | dut->ft_bss_mac_list[i][5]); |
| 1148 | } |
| 1149 | free(mac_list_str); |
| 1150 | } |
| 1151 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1152 | return 1; |
| 1153 | } |
| 1154 | |
| 1155 | |
| 1156 | static void ath_inject_frame(struct sigma_dut *dut, const char *ifname, int tid) |
| 1157 | { |
| 1158 | char buf[256]; |
| 1159 | int tid_to_dscp[] = { 0x00, 0x20, 0x40, 0x60, 0x80, 0xa0, 0xc0, 0xe0 }; |
| 1160 | |
Pradeep Reddy POTTETI | d31d132 | 2016-10-13 17:22:03 +0530 | [diff] [blame] | 1161 | if (tid < 0 || |
| 1162 | tid >= (int) (sizeof(tid_to_dscp) / sizeof(tid_to_dscp[0]))) { |
| 1163 | sigma_dut_print(dut, DUT_MSG_ERROR, "Unsupported TID: %d", tid); |
| 1164 | return; |
| 1165 | } |
| 1166 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1167 | snprintf(buf, sizeof(buf), |
| 1168 | "wlanconfig %s list sta | grep : | cut -b 1-17 > %s", |
| 1169 | ifname, VI_QOS_TMP_FILE); |
| 1170 | if (system(buf) != 0) |
| 1171 | return; |
| 1172 | |
| 1173 | snprintf(buf, sizeof(buf), |
| 1174 | "ifconfig %s | grep HWaddr | cut -b 39-56 >> %s", |
| 1175 | ifname, VI_QOS_TMP_FILE); |
| 1176 | if (system(buf) != 0) |
| 1177 | sigma_dut_print(dut, DUT_MSG_ERROR, "Retrieve HWaddr failed"); |
| 1178 | |
| 1179 | snprintf(buf, sizeof(buf), "sed -n '3,$p' %s >> %s", |
| 1180 | VI_QOS_REFFILE, VI_QOS_TMP_FILE); |
| 1181 | if (system(buf) != 0) { |
| 1182 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 1183 | "Output redirection to VI_QOS_TMP_FILE failed"); |
| 1184 | } |
| 1185 | |
| 1186 | snprintf(buf, sizeof(buf), "sed '5 c %x' %s > %s", |
| 1187 | tid_to_dscp[tid], VI_QOS_TMP_FILE, VI_QOS_FILE); |
| 1188 | if (system(buf) != 0) { |
| 1189 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 1190 | "Append TID to VI_QOS_FILE failed "); |
| 1191 | } |
| 1192 | |
| 1193 | snprintf(buf, sizeof(buf), "ethinject %s %s", ifname, VI_QOS_FILE); |
| 1194 | if (system(buf) != 0) |
| 1195 | sigma_dut_print(dut, DUT_MSG_ERROR, "Ethinject frame failed"); |
| 1196 | } |
| 1197 | |
| 1198 | |
| 1199 | static int ath_ap_send_addba_req(struct sigma_dut *dut, struct sigma_conn *conn, |
| 1200 | struct sigma_cmd *cmd) |
| 1201 | { |
| 1202 | const char *val; |
| 1203 | char *ifname; |
| 1204 | char buf[256]; |
| 1205 | int tid = 0; |
| 1206 | |
| 1207 | ifname = get_main_ifname(); |
| 1208 | val = get_param(cmd, "TID"); |
| 1209 | if (val) { |
| 1210 | tid = atoi(val); |
| 1211 | if (tid) |
| 1212 | ath_inject_frame(dut, ifname, tid); |
| 1213 | } |
| 1214 | |
| 1215 | /* NOTE: This is the command sequence on Peregrine for ADDBA */ |
| 1216 | snprintf(buf, sizeof(buf), "iwpriv %s setaddbaoper 1", ifname); |
| 1217 | if (system(buf) != 0) { |
| 1218 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 1219 | "iwpriv setaddbaoper failed"); |
| 1220 | } |
| 1221 | |
| 1222 | snprintf(buf, sizeof(buf), "wifitool %s senddelba 1 %d 1 4", |
| 1223 | ifname, tid); |
| 1224 | if (system(buf) != 0) { |
| 1225 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 1226 | "wifitool senddelba failed"); |
| 1227 | } |
| 1228 | |
| 1229 | snprintf(buf, sizeof(buf), "wifitool %s sendaddba 1 %d 64", |
| 1230 | ifname, tid); |
| 1231 | if (system(buf) != 0) { |
| 1232 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 1233 | "wifitool sendaddba failed"); |
| 1234 | } |
| 1235 | |
| 1236 | return 1; |
| 1237 | } |
| 1238 | |
| 1239 | |
Mohammed Shafi Shajakhan | a0535d4 | 2016-06-17 11:55:00 +0530 | [diff] [blame] | 1240 | static int ath10k_debug_enable_addba_req(struct sigma_dut *dut, int tid, |
| 1241 | const char *sta_mac, |
| 1242 | const char *dir_path) |
| 1243 | { |
| 1244 | DIR *dir; |
| 1245 | struct dirent *entry; |
| 1246 | char buf[128], path[128]; |
| 1247 | int ret = 0; |
| 1248 | |
| 1249 | dir = opendir(dir_path); |
| 1250 | if (!dir) |
| 1251 | return 0; |
| 1252 | |
| 1253 | while ((entry = readdir(dir))) { |
| 1254 | ret = 1; |
| 1255 | |
| 1256 | if (strcmp(entry->d_name, ".") == 0 || |
| 1257 | strcmp(entry->d_name, "..") == 0) |
| 1258 | continue; |
| 1259 | |
| 1260 | snprintf(path, sizeof(path) - 1, "%s/%s", |
| 1261 | dir_path, entry->d_name); |
| 1262 | path[sizeof(path) - 1] = 0; |
| 1263 | |
| 1264 | if (strcmp(entry->d_name, sta_mac) == 0) { |
| 1265 | snprintf(buf, sizeof(buf), "echo 1 > %s/aggr_mode", |
| 1266 | path); |
| 1267 | if (system(buf) != 0) { |
| 1268 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 1269 | "Failed to set aggr mode for ath10k"); |
| 1270 | } |
| 1271 | |
| 1272 | snprintf(buf, sizeof(buf), "echo %d 32 > %s/addba", |
| 1273 | tid, path); |
| 1274 | if (system(buf) != 0) { |
| 1275 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 1276 | "Failed to set addbareq for ath10k"); |
| 1277 | } |
| 1278 | |
| 1279 | break; |
| 1280 | } |
| 1281 | |
| 1282 | /* Recursively search subdirectories */ |
| 1283 | ath10k_debug_enable_addba_req(dut, tid, sta_mac, path); |
| 1284 | } |
| 1285 | |
| 1286 | closedir(dir); |
| 1287 | |
| 1288 | return ret; |
| 1289 | } |
| 1290 | |
| 1291 | |
| 1292 | static int ath10k_ap_send_addba_req(struct sigma_dut *dut, |
| 1293 | struct sigma_cmd *cmd) |
| 1294 | { |
| 1295 | const char *val; |
| 1296 | int tid = 0; |
| 1297 | |
| 1298 | val = get_param(cmd, "TID"); |
| 1299 | if (val) |
| 1300 | tid = atoi(val); |
| 1301 | |
| 1302 | val = get_param(cmd, "sta_mac_address"); |
| 1303 | if (!val) { |
| 1304 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 1305 | "Failed to parse station MAC address"); |
| 1306 | return 0; |
| 1307 | } |
| 1308 | |
| 1309 | return ath10k_debug_enable_addba_req(dut, tid, val, |
| 1310 | "/sys/kernel/debug/ieee80211"); |
| 1311 | } |
| 1312 | |
| 1313 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1314 | static int cmd_ap_send_addba_req(struct sigma_dut *dut, struct sigma_conn *conn, |
| 1315 | struct sigma_cmd *cmd) |
| 1316 | { |
| 1317 | /* const char *name = get_param(cmd, "NAME"); */ |
| 1318 | /* const char *ifname = get_param(cmd, "INTERFACE"); */ |
Mohammed Shafi Shajakhan | a0535d4 | 2016-06-17 11:55:00 +0530 | [diff] [blame] | 1319 | struct stat s; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1320 | |
| 1321 | switch (get_driver_type()) { |
| 1322 | case DRIVER_ATHEROS: |
| 1323 | return ath_ap_send_addba_req(dut, conn, cmd); |
| 1324 | case DRIVER_OPENWRT: |
| 1325 | switch (get_openwrt_driver_type()) { |
| 1326 | case OPENWRT_DRIVER_ATHEROS: |
| 1327 | return ath_ap_send_addba_req(dut, conn, cmd); |
| 1328 | default: |
| 1329 | send_resp(dut, conn, SIGMA_ERROR, |
| 1330 | "errorCode,ap_send_addba_req not supported with this driver"); |
| 1331 | return 0; |
| 1332 | } |
Pradeep Reddy POTTETI | fdb0491 | 2016-08-02 14:16:24 +0530 | [diff] [blame] | 1333 | case DRIVER_WCN: |
| 1334 | case DRIVER_LINUX_WCN: |
| 1335 | /* AP automatically sends ADDBA request after association. */ |
| 1336 | sigma_dut_print(dut, DUT_MSG_INFO, |
| 1337 | "ap_send_addba_req command ignored"); |
| 1338 | return 1; |
Mohammed Shafi Shajakhan | a0535d4 | 2016-06-17 11:55:00 +0530 | [diff] [blame] | 1339 | case DRIVER_MAC80211: |
| 1340 | if (stat("/sys/module/ath10k_core", &s) == 0) |
| 1341 | return ath10k_ap_send_addba_req(dut, cmd); |
| 1342 | /* fall through */ |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1343 | default: |
| 1344 | send_resp(dut, conn, SIGMA_ERROR, |
| 1345 | "errorCode,ap_send_addba_req not supported with this driver"); |
| 1346 | return 0; |
| 1347 | } |
| 1348 | } |
| 1349 | |
| 1350 | |
| 1351 | static int cmd_ap_set_security(struct sigma_dut *dut, struct sigma_conn *conn, |
| 1352 | struct sigma_cmd *cmd) |
| 1353 | { |
| 1354 | /* const char *name = get_param(cmd, "NAME"); */ |
| 1355 | const char *val; |
| 1356 | unsigned int wlan_tag = 1; |
| 1357 | |
| 1358 | val = get_param(cmd, "WLAN_TAG"); |
| 1359 | if (val) |
| 1360 | wlan_tag = atoi(val); |
| 1361 | |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 1362 | if (wlan_tag > 1) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1363 | val = get_param(cmd, "KEYMGNT"); |
| 1364 | if (val) { |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 1365 | if (strcasecmp(val, "NONE") == 0) { |
| 1366 | dut->ap_tag_key_mgmt[wlan_tag - 2] = AP2_OPEN; |
| 1367 | } else if (strcasecmp(val, "OSEN") == 0 && |
| 1368 | wlan_tag == 2) { |
| 1369 | /* |
| 1370 | * OSEN only supported on WLAN_TAG = 2 for now |
| 1371 | */ |
| 1372 | dut->ap_tag_key_mgmt[wlan_tag - 2] = AP2_OSEN; |
| 1373 | } else if (strcasecmp(val, "WPA2-PSK") == 0) { |
| 1374 | dut->ap_tag_key_mgmt[wlan_tag - 2] = |
| 1375 | AP2_WPA2_PSK; |
| 1376 | } else { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1377 | send_resp(dut, conn, SIGMA_INVALID, |
| 1378 | "errorCode,Unsupported KEYMGNT"); |
| 1379 | return 0; |
| 1380 | } |
| 1381 | return 1; |
| 1382 | } |
| 1383 | } |
| 1384 | |
| 1385 | val = get_param(cmd, "KEYMGNT"); |
| 1386 | if (val) { |
| 1387 | if (strcasecmp(val, "WPA2-PSK") == 0) { |
| 1388 | dut->ap_key_mgmt = AP_WPA2_PSK; |
| 1389 | dut->ap_cipher = AP_CCMP; |
| 1390 | } else if (strcasecmp(val, "WPA2-EAP") == 0 || |
| 1391 | strcasecmp(val, "WPA2-Ent") == 0) { |
| 1392 | dut->ap_key_mgmt = AP_WPA2_EAP; |
| 1393 | dut->ap_cipher = AP_CCMP; |
Jouni Malinen | ad395a2 | 2017-09-01 21:13:46 +0300 | [diff] [blame] | 1394 | } else if (strcasecmp(val, "SuiteB") == 0) { |
| 1395 | dut->ap_key_mgmt = AP_SUITEB; |
| 1396 | dut->ap_cipher = AP_GCMP_256; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1397 | } else if (strcasecmp(val, "WPA-PSK") == 0) { |
| 1398 | dut->ap_key_mgmt = AP_WPA_PSK; |
| 1399 | dut->ap_cipher = AP_TKIP; |
| 1400 | } else if (strcasecmp(val, "WPA-EAP") == 0 || |
| 1401 | strcasecmp(val, "WPA-Ent") == 0) { |
| 1402 | dut->ap_key_mgmt = AP_WPA_EAP; |
| 1403 | dut->ap_cipher = AP_TKIP; |
| 1404 | } else if (strcasecmp(val, "WPA2-Mixed") == 0) { |
| 1405 | dut->ap_key_mgmt = AP_WPA2_EAP_MIXED; |
| 1406 | dut->ap_cipher = AP_CCMP_TKIP; |
| 1407 | } else if (strcasecmp(val, "WPA2-PSK-Mixed") == 0) { |
| 1408 | dut->ap_key_mgmt = AP_WPA2_PSK_MIXED; |
| 1409 | dut->ap_cipher = AP_CCMP_TKIP; |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 1410 | } else if (strcasecmp(val, "WPA2-SAE") == 0) { |
| 1411 | dut->ap_key_mgmt = AP_WPA2_SAE; |
| 1412 | dut->ap_cipher = AP_CCMP; |
| 1413 | } else if (strcasecmp(val, "WPA2-PSK-SAE") == 0) { |
| 1414 | dut->ap_key_mgmt = AP_WPA2_PSK_SAE; |
| 1415 | dut->ap_cipher = AP_CCMP; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1416 | } else if (strcasecmp(val, "NONE") == 0) { |
| 1417 | dut->ap_key_mgmt = AP_OPEN; |
| 1418 | dut->ap_cipher = AP_PLAIN; |
| 1419 | } else { |
| 1420 | send_resp(dut, conn, SIGMA_INVALID, |
| 1421 | "errorCode,Unsupported KEYMGNT"); |
| 1422 | return 0; |
| 1423 | } |
| 1424 | } |
| 1425 | |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 1426 | val = get_param(cmd, "ECGroupID"); |
| 1427 | if (val) { |
Jouni Malinen | ed670f4 | 2017-08-31 01:39:28 +0300 | [diff] [blame] | 1428 | free(dut->ap_sae_groups); |
| 1429 | dut->ap_sae_groups = strdup(val); |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 1430 | } |
| 1431 | |
Jouni Malinen | 2f524ce | 2017-08-31 01:43:29 +0300 | [diff] [blame] | 1432 | val = get_param(cmd, "AntiCloggingThreshold"); |
| 1433 | if (val) |
| 1434 | dut->sae_anti_clogging_threshold = atoi(val); |
| 1435 | |
Jouni Malinen | b347db0 | 2017-09-02 01:36:03 +0300 | [diff] [blame] | 1436 | val = get_param(cmd, "Reflection"); |
| 1437 | if (val) |
| 1438 | dut->sae_reflection = strcasecmp(val, "SAE") == 0; |
| 1439 | |
Jouni Malinen | 6814313 | 2017-09-02 02:34:08 +0300 | [diff] [blame] | 1440 | val = get_param(cmd, "InvalidSAEElement"); |
| 1441 | if (val) { |
| 1442 | free(dut->sae_commit_override); |
| 1443 | dut->sae_commit_override = strdup(val); |
| 1444 | } |
| 1445 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1446 | val = get_param(cmd, "ENCRYPT"); |
| 1447 | if (val) { |
| 1448 | if (strcasecmp(val, "WEP") == 0) { |
| 1449 | dut->ap_cipher = AP_WEP; |
| 1450 | } else if (strcasecmp(val, "TKIP") == 0) { |
| 1451 | dut->ap_cipher = AP_TKIP; |
| 1452 | } else if (strcasecmp(val, "AES") == 0 || |
| 1453 | strcasecmp(val, "AES-CCMP") == 0) { |
| 1454 | dut->ap_cipher = AP_CCMP; |
| 1455 | } else { |
| 1456 | send_resp(dut, conn, SIGMA_INVALID, |
| 1457 | "errorCode,Unsupported ENCRYPT"); |
| 1458 | return 0; |
| 1459 | } |
| 1460 | } |
| 1461 | |
| 1462 | val = get_param(cmd, "WEPKEY"); |
| 1463 | if (val) { |
| 1464 | size_t len; |
| 1465 | if (dut->ap_cipher != AP_WEP) { |
| 1466 | send_resp(dut, conn, SIGMA_INVALID, |
| 1467 | "errorCode,Unexpected WEPKEY without WEP " |
| 1468 | "configuration"); |
| 1469 | return 0; |
| 1470 | } |
| 1471 | len = strlen(val); |
| 1472 | if (len != 10 && len != 26) { |
| 1473 | send_resp(dut, conn, SIGMA_INVALID, |
| 1474 | "errorCode,Unexpected WEPKEY length"); |
| 1475 | return 0; |
| 1476 | } |
| 1477 | snprintf(dut->ap_wepkey, sizeof(dut->ap_wepkey), "%s", val); |
| 1478 | } |
| 1479 | |
| 1480 | val = get_param(cmd, "PSK"); |
| 1481 | if (val) { |
| 1482 | if (strlen(val) > sizeof(dut->ap_passphrase) - 1) |
| 1483 | return -1; |
| 1484 | snprintf(dut->ap_passphrase, sizeof(dut->ap_passphrase), |
| 1485 | "%s", val); |
| 1486 | } |
| 1487 | |
| 1488 | val = get_param(cmd, "PMF"); |
| 1489 | if (val) { |
| 1490 | if (strcasecmp(val, "Disabled") == 0) { |
| 1491 | dut->ap_pmf = AP_PMF_DISABLED; |
| 1492 | } else if (strcasecmp(val, "Optional") == 0) { |
| 1493 | dut->ap_pmf = AP_PMF_OPTIONAL; |
| 1494 | } else if (strcasecmp(val, "Required") == 0) { |
| 1495 | dut->ap_pmf = AP_PMF_REQUIRED; |
| 1496 | } else { |
| 1497 | send_resp(dut, conn, SIGMA_INVALID, |
| 1498 | "errorCode,Unsupported PMF"); |
| 1499 | return 0; |
| 1500 | } |
| 1501 | } |
| 1502 | |
| 1503 | if (dut->ap_key_mgmt == AP_OPEN) { |
| 1504 | dut->ap_hs2 = 0; |
| 1505 | dut->ap_pmf = AP_PMF_DISABLED; |
| 1506 | } |
| 1507 | |
| 1508 | dut->ap_add_sha256 = 0; |
| 1509 | val = get_param(cmd, "SHA256AD"); |
| 1510 | if (val == NULL) |
| 1511 | val = get_param(cmd, "SHA256"); |
| 1512 | if (val) { |
| 1513 | if (strcasecmp(val, "Disabled") == 0) { |
| 1514 | } else if (strcasecmp(val, "Enabled") == 0) { |
| 1515 | dut->ap_add_sha256 = 1; |
| 1516 | } else { |
| 1517 | send_resp(dut, conn, SIGMA_INVALID, |
| 1518 | "errorCode,Unsupported PMF"); |
| 1519 | return 0; |
| 1520 | } |
| 1521 | } |
| 1522 | |
Sarvepalli, Rajesh Babu | 24dc7e4 | 2016-03-18 21:27:26 +0530 | [diff] [blame] | 1523 | val = get_param(cmd, "PreAuthentication"); |
| 1524 | if (val) { |
| 1525 | if (strcasecmp(val, "disabled") == 0) { |
| 1526 | dut->ap_rsn_preauth = 0; |
| 1527 | } else if (strcasecmp(val, "enabled") == 0) { |
| 1528 | dut->ap_rsn_preauth = 1; |
| 1529 | } else { |
| 1530 | send_resp(dut, conn, SIGMA_INVALID, |
| 1531 | "errorCode,Unsupported PreAuthentication value"); |
| 1532 | return 0; |
| 1533 | } |
| 1534 | } |
| 1535 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1536 | return 1; |
| 1537 | } |
| 1538 | |
| 1539 | |
| 1540 | static int cmd_ap_set_radius(struct sigma_dut *dut, struct sigma_conn *conn, |
| 1541 | struct sigma_cmd *cmd) |
| 1542 | { |
| 1543 | /* const char *name = get_param(cmd, "NAME"); */ |
| 1544 | const char *val; |
| 1545 | unsigned int wlan_tag = 1, radius_port = 0; |
| 1546 | char *radius_ipaddr = NULL, *radius_password = NULL; |
| 1547 | |
| 1548 | val = get_param(cmd, "WLAN_TAG"); |
| 1549 | if (val) { |
| 1550 | wlan_tag = atoi(val); |
| 1551 | if (wlan_tag != 1 && wlan_tag != 2) { |
| 1552 | send_resp(dut, conn, SIGMA_INVALID, |
| 1553 | "errorCode,Invalid WLAN_TAG"); |
| 1554 | return 0; |
| 1555 | } |
| 1556 | } |
| 1557 | |
| 1558 | val = get_param(cmd, "PORT"); |
| 1559 | if (val) |
| 1560 | radius_port = atoi(val); |
| 1561 | |
| 1562 | if (wlan_tag == 1) { |
| 1563 | if (radius_port) |
| 1564 | dut->ap_radius_port = radius_port; |
| 1565 | radius_ipaddr = dut->ap_radius_ipaddr; |
| 1566 | radius_password = dut->ap_radius_password; |
| 1567 | } else if (wlan_tag == 2) { |
| 1568 | if (radius_port) |
| 1569 | dut->ap2_radius_port = radius_port; |
| 1570 | radius_ipaddr = dut->ap2_radius_ipaddr; |
| 1571 | radius_password = dut->ap2_radius_password; |
| 1572 | } |
| 1573 | |
| 1574 | val = get_param(cmd, "IPADDR"); |
| 1575 | if (val) { |
| 1576 | if (strlen(val) > sizeof(dut->ap_radius_ipaddr) - 1) |
| 1577 | return -1; |
| 1578 | snprintf(radius_ipaddr, sizeof(dut->ap_radius_ipaddr), |
| 1579 | "%s", val); |
| 1580 | } |
| 1581 | |
| 1582 | val = get_param(cmd, "PASSWORD"); |
| 1583 | if (val) { |
| 1584 | if (strlen(val) > sizeof(dut->ap_radius_password) - 1) |
| 1585 | return -1; |
| 1586 | snprintf(radius_password, |
| 1587 | sizeof(dut->ap_radius_password), "%s", val); |
| 1588 | } |
| 1589 | |
| 1590 | return 1; |
| 1591 | } |
| 1592 | |
| 1593 | |
| 1594 | static void owrt_ap_set_radio(struct sigma_dut *dut, int id, |
| 1595 | const char *key, const char *val) |
| 1596 | { |
| 1597 | char buf[100]; |
| 1598 | |
| 1599 | if (val == NULL) { |
| 1600 | snprintf(buf, sizeof(buf), |
| 1601 | "uci delete wireless.wifi%d.%s", id, key); |
| 1602 | run_system(dut, buf); |
| 1603 | return; |
| 1604 | } |
| 1605 | |
| 1606 | snprintf(buf, sizeof(buf), "uci set wireless.wifi%d.%s=%s", |
| 1607 | id, key, val); |
| 1608 | run_system(dut, buf); |
| 1609 | } |
| 1610 | |
| 1611 | |
| 1612 | static void owrt_ap_set_list_radio(struct sigma_dut *dut, int id, |
| 1613 | const char *key, const char *val) |
| 1614 | { |
| 1615 | char buf[256]; |
| 1616 | |
| 1617 | if (val == NULL) { |
| 1618 | snprintf(buf, sizeof(buf), |
| 1619 | "uci del_list wireless.wifi%d.%s", id, key); |
| 1620 | run_system(dut, buf); |
| 1621 | return; |
| 1622 | } |
| 1623 | |
| 1624 | snprintf(buf, sizeof(buf), "uci add_list wireless.wifi%d.%s=%s", |
| 1625 | id, key, val); |
| 1626 | run_system(dut, buf); |
| 1627 | } |
| 1628 | |
| 1629 | |
| 1630 | static void owrt_ap_set_vap(struct sigma_dut *dut, int id, const char *key, |
| 1631 | const char *val) |
| 1632 | { |
| 1633 | char buf[256]; |
| 1634 | |
| 1635 | if (val == NULL) { |
| 1636 | snprintf(buf, sizeof(buf), |
| 1637 | "uci delete wireless.@wifi-iface[%d].%s", id, key); |
| 1638 | run_system(dut, buf); |
| 1639 | return; |
| 1640 | } |
| 1641 | |
| 1642 | snprintf(buf, sizeof(buf), "uci set wireless.@wifi-iface[%d].%s=%s", |
| 1643 | id, key, val); |
| 1644 | run_system(dut, buf); |
| 1645 | } |
| 1646 | |
| 1647 | |
| 1648 | static void owrt_ap_set_list_vap(struct sigma_dut *dut, int id, |
| 1649 | const char *key, const char *val) |
| 1650 | { |
priyadharshini gowthaman | 2323d0a | 2016-09-02 15:48:02 -0700 | [diff] [blame] | 1651 | char buf[1024]; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1652 | |
| 1653 | if (val == NULL) { |
| 1654 | snprintf(buf, sizeof(buf), |
| 1655 | "uci del_list wireless.@wifi-iface[%d].%s", id, key); |
| 1656 | run_system(dut, buf); |
| 1657 | return; |
| 1658 | } |
| 1659 | |
| 1660 | snprintf(buf, sizeof(buf), |
| 1661 | "uci add_list wireless.@wifi-iface[%d].%s=%s", |
| 1662 | id, key, val); |
| 1663 | run_system(dut, buf); |
| 1664 | } |
| 1665 | |
| 1666 | |
| 1667 | static void owrt_ap_add_vap(struct sigma_dut *dut, int id, const char *key, |
| 1668 | const char *val) |
| 1669 | { |
| 1670 | char buf[256]; |
| 1671 | |
| 1672 | if (val == NULL) { |
| 1673 | snprintf(buf, sizeof(buf), |
| 1674 | "uci delete wireless.@wifi-iface[%d].%s", id, key); |
| 1675 | run_system(dut, buf); |
| 1676 | return; |
| 1677 | } |
| 1678 | |
| 1679 | snprintf(buf, sizeof(buf), "uci add wireless wifi-iface"); |
| 1680 | run_system(dut, buf); |
| 1681 | snprintf(buf, sizeof(buf), "uci set wireless.@wifi-iface[%d].%s=%s", |
| 1682 | id, key, val); |
| 1683 | run_system(dut, buf); |
| 1684 | snprintf(buf, sizeof(buf), "uci set wireless.@wifi-iface[%d].%s=%s", |
| 1685 | id, "network", "lan"); |
| 1686 | run_system(dut, buf); |
| 1687 | snprintf(buf, sizeof(buf), "uci set wireless.@wifi-iface[%d].%s=%s", |
| 1688 | id, "mode", "ap"); |
| 1689 | run_system(dut, buf); |
| 1690 | snprintf(buf, sizeof(buf), "uci set wireless.@wifi-iface[%d].%s=%s", |
| 1691 | id, "encryption", "none"); |
| 1692 | run_system(dut, buf); |
| 1693 | } |
| 1694 | |
| 1695 | |
| 1696 | #define OPENWRT_MAX_NUM_RADIOS 3 |
| 1697 | static void owrt_ap_config_radio(struct sigma_dut *dut) |
| 1698 | { |
| 1699 | int radio_id[MAX_RADIO] = { 0, 1 }; |
| 1700 | int radio_count, radio_no; |
| 1701 | char buf[64]; |
| 1702 | |
| 1703 | for (radio_count = 0; radio_count < OPENWRT_MAX_NUM_RADIOS; |
| 1704 | radio_count++) { |
| 1705 | snprintf(buf, sizeof(buf), "%s%d", "wifi", radio_count); |
| 1706 | for (radio_no = 0; radio_no < MAX_RADIO; radio_no++) { |
| 1707 | if (!sigma_radio_ifname[radio_no] || |
| 1708 | strcmp(sigma_radio_ifname[radio_no], buf) != 0) |
| 1709 | continue; |
| 1710 | owrt_ap_set_radio(dut, radio_count, "disabled", "0"); |
| 1711 | owrt_ap_set_vap(dut, radio_count, "device", buf); |
| 1712 | radio_id[radio_no] = radio_count; |
| 1713 | } |
| 1714 | } |
| 1715 | |
| 1716 | /* Hardware mode (11a/b/g/n/ac) & HT mode selection */ |
| 1717 | switch (dut->ap_mode) { |
| 1718 | case AP_11g: |
| 1719 | owrt_ap_set_radio(dut, radio_id[0], "hwmode", "11g"); |
| 1720 | break; |
| 1721 | case AP_11b: |
| 1722 | owrt_ap_set_radio(dut, radio_id[0], "hwmode", "11b"); |
| 1723 | break; |
| 1724 | case AP_11ng: |
| 1725 | owrt_ap_set_radio(dut, radio_id[0], "hwmode", "11ng"); |
| 1726 | owrt_ap_set_radio(dut, radio_id[0], "htmode", "HT20"); |
| 1727 | break; |
| 1728 | case AP_11a: |
| 1729 | owrt_ap_set_radio(dut, radio_id[0], "hwmode", "11a"); |
| 1730 | break; |
| 1731 | case AP_11na: |
| 1732 | owrt_ap_set_radio(dut, radio_id[0], "hwmode", "11na"); |
| 1733 | owrt_ap_set_radio(dut, radio_id[0], "htmode", "HT20"); |
| 1734 | break; |
| 1735 | case AP_11ac: |
| 1736 | owrt_ap_set_radio(dut, radio_id[0], "hwmode", "11ac"); |
| 1737 | owrt_ap_set_radio(dut, radio_id[0], "htmode", "HT80"); |
| 1738 | break; |
| 1739 | case AP_inval: |
| 1740 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 1741 | "MODE NOT SPECIFIED!"); |
| 1742 | return; |
| 1743 | default: |
| 1744 | owrt_ap_set_radio(dut, radio_id[0], "hwmode", "11ng"); |
| 1745 | owrt_ap_set_radio(dut, radio_id[0], "htmode", "HT20"); |
| 1746 | break; |
| 1747 | } |
| 1748 | |
| 1749 | if (dut->ap_is_dual) { |
| 1750 | /* Hardware mode (11a/b/g/n/ac) & HT mode selection */ |
| 1751 | switch (dut->ap_mode_1) { |
| 1752 | case AP_11g: |
| 1753 | owrt_ap_set_radio(dut, radio_id[1], "hwmode", "11g"); |
| 1754 | break; |
| 1755 | case AP_11b: |
| 1756 | owrt_ap_set_radio(dut, radio_id[1], "hwmode", "11b"); |
| 1757 | break; |
| 1758 | case AP_11ng: |
| 1759 | owrt_ap_set_radio(dut, radio_id[1], "hwmode", "11ng"); |
| 1760 | owrt_ap_set_radio(dut, radio_id[1], "htmode", "HT20"); |
| 1761 | break; |
| 1762 | case AP_11a: |
| 1763 | owrt_ap_set_radio(dut, radio_id[1], "hwmode", "11a"); |
| 1764 | break; |
| 1765 | case AP_11na: |
| 1766 | owrt_ap_set_radio(dut, radio_id[1], "hwmode", "11na"); |
| 1767 | owrt_ap_set_radio(dut, radio_id[1], "htmode", "HT20"); |
| 1768 | break; |
| 1769 | case AP_11ac: |
| 1770 | owrt_ap_set_radio(dut, radio_id[1], "hwmode", "11ac"); |
| 1771 | owrt_ap_set_radio(dut, radio_id[1], "htmode", "HT80"); |
| 1772 | break; |
| 1773 | case AP_inval: |
| 1774 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 1775 | "MODE NOT SPECIFIED!"); |
| 1776 | return; |
| 1777 | default: |
| 1778 | owrt_ap_set_radio(dut, radio_id[1], "hwmode", "11ng"); |
| 1779 | owrt_ap_set_radio(dut, radio_id[1], "htmode", "HT20"); |
| 1780 | break; |
| 1781 | } |
| 1782 | |
| 1783 | } |
| 1784 | |
| 1785 | /* Channel */ |
| 1786 | snprintf(buf, sizeof(buf), "%d", dut->ap_channel); |
| 1787 | owrt_ap_set_radio(dut, radio_id[0], "channel", buf); |
| 1788 | |
| 1789 | switch (dut->ap_chwidth) { |
| 1790 | case AP_20: |
| 1791 | owrt_ap_set_radio(dut, radio_id[0], "htmode", "HT20"); |
| 1792 | break; |
| 1793 | case AP_40: |
| 1794 | owrt_ap_set_radio(dut, radio_id[0], "htmode", "HT40"); |
| 1795 | break; |
| 1796 | case AP_80: |
| 1797 | owrt_ap_set_radio(dut, radio_id[0], "htmode", "HT80"); |
| 1798 | break; |
| 1799 | case AP_160: |
| 1800 | owrt_ap_set_radio(dut, radio_id[0], "htmode", "HT160"); |
| 1801 | break; |
| 1802 | case AP_AUTO: |
| 1803 | default: |
| 1804 | break; |
| 1805 | } |
| 1806 | |
| 1807 | if (dut->ap_channel == 140 || dut->ap_channel == 144) { |
| 1808 | if (get_openwrt_driver_type() == OPENWRT_DRIVER_ATHEROS) |
| 1809 | owrt_ap_set_radio(dut, radio_id[0], "set_ch_144", "3"); |
| 1810 | } |
| 1811 | |
| 1812 | if (dut->ap_is_dual) { |
| 1813 | snprintf(buf, sizeof(buf), "%d", dut->ap_channel_1); |
| 1814 | owrt_ap_set_radio(dut, radio_id[1], "channel", buf); |
| 1815 | } |
| 1816 | |
Adil Saeed Musthafa | 604c826 | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 1817 | /* Country Code */ |
| 1818 | if (dut->ap_reg_domain == REG_DOMAIN_GLOBAL) { |
| 1819 | const char *country; |
| 1820 | |
| 1821 | country = dut->ap_countrycode[0] ? dut->ap_countrycode : "US"; |
| 1822 | snprintf(buf, sizeof(buf), "%s4", country); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1823 | owrt_ap_set_radio(dut, radio_id[0], "country", buf); |
Adil Saeed Musthafa | 604c826 | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 1824 | } else if (dut->ap_countrycode[0]) { |
| 1825 | owrt_ap_set_radio(dut, radio_id[0], "country", |
| 1826 | dut->ap_countrycode); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1827 | } |
| 1828 | |
| 1829 | if (dut->ap_disable_protection == 1) { |
| 1830 | owrt_ap_set_list_radio(dut, radio_id[0], "aggr_burst", "'0 0'"); |
| 1831 | owrt_ap_set_list_radio(dut, radio_id[0], "aggr_burst", "'1 0'"); |
| 1832 | owrt_ap_set_list_radio(dut, radio_id[0], "aggr_burst", "'2 0'"); |
| 1833 | owrt_ap_set_list_radio(dut, radio_id[0], "aggr_burst", "'3 0'"); |
| 1834 | } |
| 1835 | } |
| 1836 | |
| 1837 | |
| 1838 | static int owrt_ap_config_vap_hs2(struct sigma_dut *dut, int vap_id) |
| 1839 | { |
| 1840 | char buf[256]; |
| 1841 | |
| 1842 | snprintf(buf, sizeof(buf), "%d", dut->ap_hs2); |
| 1843 | owrt_ap_set_vap(dut, vap_id, "hs20", buf); |
| 1844 | owrt_ap_set_vap(dut, vap_id, "qbssload", "1"); |
| 1845 | owrt_ap_set_vap(dut, vap_id, "hs20_deauth_req_timeout","3"); |
| 1846 | |
| 1847 | owrt_ap_set_list_vap(dut, vap_id, "hs20_oper_friendly_name", |
| 1848 | "'eng:Wi-Fi Alliance'"); |
| 1849 | |
| 1850 | owrt_ap_set_list_vap(dut, vap_id, "hs20_oper_friendly_name", |
| 1851 | "'chi:Wi-Fi\xe8\x81\x94\xe7\x9b\x9f'"); |
| 1852 | |
| 1853 | if (dut->ap_wan_metrics == 1) |
| 1854 | owrt_ap_set_vap(dut, vap_id, "hs20_wan_metrics", |
| 1855 | "'01:2500:384:0:0:10'"); |
| 1856 | else if (dut->ap_wan_metrics == 1) |
| 1857 | owrt_ap_set_vap(dut, vap_id, "hs20_wan_metrics", |
| 1858 | "'01:1500:384:20:20:10'"); |
| 1859 | else if (dut->ap_wan_metrics == 2) |
| 1860 | owrt_ap_set_vap(dut, vap_id, "hs20_wan_metrics", |
| 1861 | "'01:1500:384:20:20:10'"); |
| 1862 | else if (dut->ap_wan_metrics == 3) |
| 1863 | owrt_ap_set_vap(dut, vap_id, "hs20_wan_metrics", |
| 1864 | "'01:2000:1000:20:20:10'"); |
| 1865 | else if (dut->ap_wan_metrics == 4) |
| 1866 | owrt_ap_set_vap(dut, vap_id, "hs20_wan_metrics", |
| 1867 | "'01:8000:1000:20:20:10'"); |
| 1868 | else if (dut->ap_wan_metrics == 5) |
| 1869 | owrt_ap_set_vap(dut, vap_id, "hs20_wan_metrics", |
| 1870 | "'01:9000:5000:20:20:10'"); |
| 1871 | |
| 1872 | if (dut->ap_conn_capab == 1) { |
| 1873 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", "'1:0:0'"); |
| 1874 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", |
| 1875 | "'6:20:1'"); |
| 1876 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", |
| 1877 | "'6:22:0'"); |
| 1878 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", |
| 1879 | "'6:80:1'"); |
| 1880 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", |
| 1881 | "'6:443:1'"); |
| 1882 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", |
| 1883 | "'6:1723:0'"); |
| 1884 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", |
| 1885 | "'6:5060:0'"); |
| 1886 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", |
| 1887 | "'17:500:1'"); |
| 1888 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", |
| 1889 | "'17:5060:0'"); |
| 1890 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", |
| 1891 | "'17:4500:1'"); |
| 1892 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", |
| 1893 | "'50:0:1'"); |
| 1894 | } else if (dut->ap_conn_capab == 2) { |
| 1895 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", |
| 1896 | "'6:80:1'"); |
| 1897 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", |
| 1898 | "'6:443:1'"); |
| 1899 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", |
| 1900 | "'17:5060:1'"); |
| 1901 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", |
| 1902 | "'6:5060:1'"); |
| 1903 | } else if (dut->ap_conn_capab == 3) { |
| 1904 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", |
| 1905 | "'6:80:1'"); |
| 1906 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", |
| 1907 | "'6:443:1'"); |
| 1908 | } |
| 1909 | |
| 1910 | if (dut->ap_oper_class == 1) |
| 1911 | snprintf(buf, sizeof(buf), "%s", "51"); |
| 1912 | else if (dut->ap_oper_class == 2) |
| 1913 | snprintf(buf, sizeof(buf), "%s", "73"); |
| 1914 | else if (dut->ap_oper_class == 3) |
| 1915 | snprintf(buf, sizeof(buf), "%s", "5173"); |
| 1916 | |
| 1917 | if (dut->ap_oper_class) |
| 1918 | owrt_ap_set_vap(dut, vap_id, "hs20_operating_class", buf); |
| 1919 | |
| 1920 | if (dut->ap_osu_provider_list) { |
| 1921 | char *osu_friendly_name = NULL; |
| 1922 | char *osu_icon = NULL; |
| 1923 | char *osu_ssid = NULL; |
| 1924 | char *osu_nai = NULL; |
| 1925 | char *osu_service_desc = NULL; |
| 1926 | char *hs20_icon_filename = NULL; |
| 1927 | char hs20_icon[150]; |
| 1928 | int osu_method; |
| 1929 | |
| 1930 | hs20_icon_filename = "icon_red_zxx.png"; |
| 1931 | if (dut->ap_osu_icon_tag == 2) |
| 1932 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 1933 | snprintf(hs20_icon, sizeof(hs20_icon), |
| 1934 | "'128:61:zxx:image/png:icon_red_zxx.png:/etc/ath/%s'", |
| 1935 | hs20_icon_filename); |
| 1936 | osu_icon = "icon_red_zxx.png"; |
| 1937 | osu_ssid = "OSU"; |
| 1938 | osu_friendly_name = "'kor:SP 빨강 테스트 전용'"; |
| 1939 | osu_service_desc = "'kor:테스트 목적으로 무료 서비스'"; |
| 1940 | osu_method = (dut->ap_osu_method[0] == 0xFF) ? 1 : |
| 1941 | dut->ap_osu_method[0]; |
| 1942 | |
| 1943 | if (strlen(dut->ap_osu_server_uri[0])) |
| 1944 | owrt_ap_set_list_vap(dut, vap_id, "osu_server_uri", |
| 1945 | dut->ap_osu_server_uri[0]); |
| 1946 | else |
| 1947 | owrt_ap_set_list_vap(dut, vap_id, "osu_server_uri", |
| 1948 | "'https://osu-server.r2-testbed.wi-fi.org/'"); |
| 1949 | switch (dut->ap_osu_provider_list) { |
| 1950 | case 1: |
| 1951 | case 101: |
| 1952 | owrt_ap_set_list_vap(dut, vap_id, "osu_friendly_name", |
| 1953 | "'eng:SP Red Test Only'"); |
| 1954 | owrt_ap_set_list_vap(dut, vap_id, "osu_service_desc", |
| 1955 | "'eng:Free service for test purpose'"); |
| 1956 | owrt_ap_set_list_vap(dut, vap_id, "hs20_icon", |
| 1957 | hs20_icon); |
| 1958 | |
| 1959 | hs20_icon_filename = "icon_red_eng.png"; |
| 1960 | if (dut->ap_osu_icon_tag == 2) |
| 1961 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 1962 | |
| 1963 | snprintf(hs20_icon, sizeof(hs20_icon), |
| 1964 | "'160:76:eng:image/png:icon_red_eng.png:/etc/ath/%s'", |
| 1965 | hs20_icon_filename); |
| 1966 | owrt_ap_set_list_vap(dut, vap_id, "osu_icon", |
| 1967 | "icon_red_eng.png"); |
| 1968 | break; |
| 1969 | case 2: |
| 1970 | case 102: |
| 1971 | owrt_ap_set_list_vap(dut, vap_id, "osu_friendly_name", |
| 1972 | "'eng:Wireless Broadband Alliance'"); |
| 1973 | owrt_ap_set_list_vap(dut, vap_id, "osu_service_desc", |
| 1974 | "'eng:Free service for test purpose'"); |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 1975 | hs20_icon_filename = "icon_orange_zxx.png"; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1976 | if (dut->ap_osu_icon_tag == 2) |
| 1977 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 1978 | |
| 1979 | snprintf(hs20_icon, sizeof(hs20_icon), |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 1980 | "'128:61:zxx:image/png:icon_orange_zxx.png:/etc/ath/%s'", |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1981 | hs20_icon_filename); |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 1982 | osu_icon = "icon_orange_zxx.png"; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1983 | osu_friendly_name = "'kor:와이어리스 브로드밴드 얼라이언스'"; |
| 1984 | break; |
| 1985 | case 3: |
| 1986 | case 103: |
| 1987 | osu_friendly_name = "spa:SP Red Test Only"; |
| 1988 | osu_service_desc = "spa:Free service for test purpose"; |
| 1989 | break; |
| 1990 | case 4: |
| 1991 | case 104: |
| 1992 | owrt_ap_set_list_vap(dut, vap_id, "osu_friendly_name", |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 1993 | "'eng:SP Orange Test Only'"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1994 | owrt_ap_set_list_vap(dut, vap_id, "osu_service_desc", |
| 1995 | "'eng:Free service for test purpose'"); |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 1996 | hs20_icon_filename = "icon_orange_eng.png"; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1997 | if (dut->ap_osu_icon_tag == 2) |
| 1998 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 1999 | |
| 2000 | snprintf(hs20_icon, sizeof(hs20_icon), |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2001 | "'160:76:eng:image/png:icon_orange_eng.png:/etc/ath/%s'", |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2002 | hs20_icon_filename); |
| 2003 | owrt_ap_set_list_vap(dut, vap_id, "hs20_icon", |
| 2004 | hs20_icon); |
| 2005 | osu_friendly_name = "'kor:SP 파랑 테스트 전용'"; |
| 2006 | |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2007 | hs20_icon_filename = "icon_orange_zxx.png"; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 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), |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2012 | "'128:61:zxx:image/png:icon_orange_zxx.png:/etc/ath/%s'", |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2013 | hs20_icon_filename); |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2014 | osu_icon = "icon_orange_zxx.png"; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2015 | break; |
| 2016 | case 5: |
| 2017 | case 105: |
| 2018 | owrt_ap_set_list_vap(dut, vap_id, "osu_friendly_name", |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2019 | "'eng:SP Orange Test Only'"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2020 | owrt_ap_set_list_vap(dut, vap_id, "osu_service_desc", |
| 2021 | "'eng:Free service for test purpose'"); |
| 2022 | osu_friendly_name = "'kor:SP 파랑 테스트 전용'"; |
| 2023 | |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2024 | hs20_icon_filename = "icon_orange_zxx.png"; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2025 | if (dut->ap_osu_icon_tag == 2) |
| 2026 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 2027 | |
| 2028 | snprintf(hs20_icon, sizeof(hs20_icon), |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2029 | "'128:61:zxx:image/png:icon_orange_zxx.png:/etc/ath/%s'", |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2030 | hs20_icon_filename); |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2031 | osu_icon = "icon_orange_zxx.png"; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2032 | break; |
| 2033 | case 6: |
| 2034 | case 106: |
| 2035 | owrt_ap_set_list_vap(dut, vap_id, "osu_friendly_name", |
| 2036 | "'eng:SP Green Test Only'"); |
| 2037 | owrt_ap_set_list_vap(dut, vap_id, "osu_friendly_name", |
| 2038 | "'kor:SP 초록 테스트 전용'"); |
| 2039 | |
| 2040 | hs20_icon_filename = "icon_green_zxx.png"; |
| 2041 | if (dut->ap_osu_icon_tag == 2) |
| 2042 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 2043 | |
| 2044 | snprintf(hs20_icon, sizeof(hs20_icon), |
| 2045 | "'128:61:zxx:image/png:icon_green_zxx.png:/etc/ath/%s'", |
| 2046 | hs20_icon_filename); |
| 2047 | owrt_ap_set_list_vap(dut, vap_id, "hs20_icon", |
| 2048 | hs20_icon); |
| 2049 | |
| 2050 | owrt_ap_set_list_vap(dut, vap_id, "osu_icon", |
| 2051 | "'icon_green_zxx.png'"); |
| 2052 | osu_method = (dut->ap_osu_method[0] == 0xFF) ? 0 : |
| 2053 | dut->ap_osu_method[0]; |
| 2054 | |
| 2055 | snprintf(buf, sizeof(buf), "%d", osu_method); |
| 2056 | owrt_ap_set_vap(dut, vap_id, "osu_method_list", buf); |
| 2057 | |
| 2058 | if (strlen(dut->ap_osu_server_uri[1])) |
| 2059 | owrt_ap_set_list_vap(dut, vap_id, |
| 2060 | "osu_server_uri", |
| 2061 | dut->ap_osu_server_uri[1]); |
| 2062 | else |
| 2063 | owrt_ap_set_list_vap(dut, vap_id, |
| 2064 | "osu_server_uri", |
| 2065 | "'https://osu-server.r2-testbed.wi-fi.org/'"); |
| 2066 | |
| 2067 | owrt_ap_set_list_vap(dut, vap_id, "osu_friendly_name", |
| 2068 | "'eng:SP Orange Test Only'"); |
| 2069 | |
| 2070 | hs20_icon_filename = "icon_orange_zxx.png"; |
| 2071 | if (dut->ap_osu_icon_tag == 2) |
| 2072 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 2073 | |
| 2074 | snprintf(hs20_icon, sizeof(hs20_icon), |
| 2075 | "'128:61:zxx:image/png:icon_orange_zxx.png:/etc/ath/%s'", |
| 2076 | hs20_icon_filename); |
| 2077 | |
| 2078 | osu_icon = "icon_orange_zxx.png"; |
| 2079 | osu_friendly_name = "'kor:SP 오렌지 테스트 전용'"; |
| 2080 | osu_method = (dut->ap_osu_method[1] == 0xFF) ? 0 : |
| 2081 | dut->ap_osu_method[1]; |
| 2082 | osu_service_desc = NULL; |
| 2083 | break; |
| 2084 | case 7: |
| 2085 | case 107: |
| 2086 | owrt_ap_set_list_vap(dut, vap_id, "osu_friendly_name", |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2087 | "'eng:SP Green Test Only'"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2088 | owrt_ap_set_list_vap(dut, vap_id, "osu_service_desc", |
| 2089 | "'eng:Free service for test purpose'"); |
| 2090 | |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2091 | hs20_icon_filename = "icon_green_eng.png"; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2092 | if (dut->ap_osu_icon_tag == 2) |
| 2093 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 2094 | |
| 2095 | snprintf(hs20_icon, sizeof(hs20_icon), |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2096 | "'160:76:eng:image/png:icon_green_eng.png:/etc/ath/%s'", |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2097 | hs20_icon_filename); |
| 2098 | owrt_ap_set_list_vap(dut, vap_id, "hs20_icon", |
| 2099 | hs20_icon); |
| 2100 | |
| 2101 | owrt_ap_set_list_vap(dut, vap_id, "osu_icon", |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2102 | "'icon_green_eng.png'"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2103 | osu_friendly_name = "'kor:SP 오렌지 테스트 전용'"; |
| 2104 | |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2105 | hs20_icon_filename = "icon_green_zxx.png"; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2106 | if (dut->ap_osu_icon_tag == 2) |
| 2107 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 2108 | |
| 2109 | snprintf(hs20_icon, sizeof(hs20_icon), |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2110 | "'128:61:zxx:image/png:icon_green_zxx.png:/etc/ath/%s'", |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2111 | hs20_icon_filename); |
priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2112 | osu_icon = "icon_green_zxx.png"; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2113 | break; |
| 2114 | case 8: |
| 2115 | case 108: |
| 2116 | owrt_ap_set_list_vap(dut, vap_id, "osu_friendly_name", |
| 2117 | "'eng:SP Red Test Only'"); |
| 2118 | owrt_ap_set_list_vap(dut, vap_id, "osu_service_desc", |
| 2119 | "'eng:Free service for test purpose'"); |
| 2120 | osu_ssid = "OSU-Encrypted"; |
| 2121 | osu_nai = "'anonymous@hotspot.net'"; |
| 2122 | break; |
| 2123 | case 9: |
| 2124 | case 109: |
| 2125 | osu_ssid = "OSU-OSEN"; |
| 2126 | osu_nai = "'test-anonymous@wi-fi.org'"; |
| 2127 | osu_friendly_name = "'eng:SP Orange Test Only'"; |
| 2128 | hs20_icon_filename = "icon_orange_zxx.png"; |
| 2129 | if (dut->ap_osu_icon_tag == 2) |
| 2130 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 2131 | |
| 2132 | snprintf(hs20_icon, sizeof(hs20_icon), |
| 2133 | "'128:61:zxx:image/png:icon_orange_zxx.png:/etc/ath/%s'", |
| 2134 | hs20_icon_filename); |
| 2135 | osu_icon = "icon_orange_zxx.png"; |
| 2136 | osu_method = (dut->ap_osu_method[0] == 0xFF) ? 1 : |
| 2137 | dut->ap_osu_method[0]; |
| 2138 | osu_service_desc = NULL; |
| 2139 | break; |
| 2140 | default: |
| 2141 | break; |
| 2142 | } |
| 2143 | |
| 2144 | if (strlen(dut->ap_osu_ssid)) { |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 2145 | if (strcmp(dut->ap_tag_ssid[0], |
| 2146 | dut->ap_osu_ssid) != 0 && |
| 2147 | strcmp(dut->ap_tag_ssid[0], osu_ssid) != 0) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2148 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 2149 | "OSU_SSID and WLAN_TAG2 SSID differ"); |
| 2150 | return -2; |
| 2151 | } |
| 2152 | |
| 2153 | snprintf(buf, sizeof(buf), "'\"%s\"'", |
| 2154 | dut->ap_osu_ssid); |
| 2155 | } else { |
| 2156 | snprintf(buf, sizeof(buf), "'\"%s\"'", osu_ssid); |
| 2157 | } |
| 2158 | |
| 2159 | owrt_ap_set_vap(dut, vap_id, "osu_ssid", buf); |
| 2160 | |
| 2161 | |
| 2162 | if (osu_friendly_name) |
| 2163 | owrt_ap_set_list_vap(dut, vap_id, "osu_friendly_name", |
| 2164 | osu_friendly_name); |
| 2165 | if (osu_service_desc) |
| 2166 | owrt_ap_set_list_vap(dut, vap_id, "osu_service_desc", |
| 2167 | osu_service_desc); |
| 2168 | if (osu_nai) |
| 2169 | owrt_ap_set_vap(dut, vap_id, "osu_nai", osu_nai); |
| 2170 | |
| 2171 | owrt_ap_set_list_vap(dut, vap_id, "hs20_icon", hs20_icon); |
| 2172 | |
| 2173 | if (osu_icon) |
| 2174 | owrt_ap_set_list_vap(dut, vap_id, "osu_icon", |
| 2175 | osu_icon); |
| 2176 | |
| 2177 | if (dut->ap_osu_provider_list > 100) { |
| 2178 | owrt_ap_set_list_vap(dut, vap_id, "osu_method_list", |
| 2179 | "0"); |
| 2180 | } else { |
| 2181 | snprintf(buf, sizeof(buf), "%d", osu_method); |
| 2182 | owrt_ap_set_list_vap(dut, vap_id, "osu_method_list", |
| 2183 | buf); |
| 2184 | } |
| 2185 | } |
| 2186 | |
| 2187 | return 0; |
| 2188 | } |
| 2189 | |
| 2190 | |
Adil Saeed Musthafa | a8d7484 | 2017-04-10 23:13:39 -0700 | [diff] [blame] | 2191 | static void set_anqp_elem_value(struct sigma_dut *dut, const char *ifname, |
| 2192 | char *anqp_string, size_t str_size) |
| 2193 | { |
| 2194 | unsigned char bssid[ETH_ALEN]; |
| 2195 | unsigned char dummy_mac[] = { 0x00, 0x10, 0x20, 0x30, 0x40, 0x50 }; |
| 2196 | int preference = 0xff; |
| 2197 | |
| 2198 | get_hwaddr(ifname, bssid); |
| 2199 | snprintf(anqp_string, str_size, |
| 2200 | "272:3410%02x%02x%02x%02x%02x%02xf70000007330000301%02x3410%02x%02x%02x%02x%02x%02xf70000007330000301%02x", |
| 2201 | bssid[0], bssid[1], bssid[2], bssid[3], bssid[4], bssid[5], |
| 2202 | preference, |
| 2203 | dummy_mac[0], dummy_mac[1], dummy_mac[2], |
| 2204 | dummy_mac[3], dummy_mac[4], dummy_mac[5], |
| 2205 | preference - 1); |
| 2206 | } |
| 2207 | |
| 2208 | |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 2209 | static void get_if_name(struct sigma_dut *dut, char *ifname_str, |
| 2210 | size_t str_size, int wlan_tag) |
| 2211 | { |
| 2212 | char *ifname; |
| 2213 | enum driver_type drv; |
| 2214 | |
| 2215 | drv = get_driver_type(); |
| 2216 | if (drv == DRIVER_ATHEROS) { |
| 2217 | if ((dut->ap_mode == AP_11a || dut->ap_mode == AP_11na || |
| 2218 | dut->ap_mode == AP_11ac) && |
| 2219 | if_nametoindex("ath1") > 0) |
| 2220 | ifname = "ath1"; |
| 2221 | else |
| 2222 | ifname = "ath0"; |
| 2223 | } else if (drv == DRIVER_OPENWRT) { |
| 2224 | if (sigma_radio_ifname[0] && |
| 2225 | strcmp(sigma_radio_ifname[0], "wifi2") == 0) |
| 2226 | ifname = "ath2"; |
| 2227 | else if (sigma_radio_ifname[0] && |
| 2228 | strcmp(sigma_radio_ifname[0], "wifi1") == 0) |
| 2229 | ifname = "ath1"; |
| 2230 | else |
| 2231 | ifname = "ath0"; |
| 2232 | } else { |
| 2233 | if ((dut->ap_mode == AP_11a || dut->ap_mode == AP_11na || |
| 2234 | dut->ap_mode == AP_11ac) && |
| 2235 | if_nametoindex("wlan1") > 0) |
| 2236 | ifname = "wlan1"; |
| 2237 | else |
| 2238 | ifname = "wlan0"; |
| 2239 | } |
| 2240 | |
| 2241 | if (drv == DRIVER_OPENWRT && wlan_tag > 1) { |
| 2242 | /* Handle tagged-ifname only on OPENWRT for now */ |
| 2243 | snprintf(ifname_str, str_size, "%s%d", ifname, wlan_tag - 1); |
| 2244 | } else { |
| 2245 | snprintf(ifname_str, str_size, "%s", ifname); |
| 2246 | } |
| 2247 | } |
| 2248 | |
| 2249 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2250 | static int owrt_ap_config_vap(struct sigma_dut *dut) |
| 2251 | { |
| 2252 | char buf[256], *temp; |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 2253 | int vap_id = 0, vap_count, i, j; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2254 | |
| 2255 | 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] | 2256 | snprintf(buf, sizeof(buf), "wifi%d", vap_count); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2257 | |
| 2258 | for (vap_id = 0; vap_id < MAX_RADIO; vap_id++) { |
| 2259 | if (sigma_radio_ifname[vap_id] && |
| 2260 | strcmp(sigma_radio_ifname[vap_id], buf) == 0) |
| 2261 | break; |
| 2262 | } |
| 2263 | if (vap_id == MAX_RADIO) |
| 2264 | continue; |
| 2265 | |
| 2266 | /* Single VAP configuration */ |
| 2267 | if (!dut->ap_is_dual) |
| 2268 | vap_id = vap_count; |
| 2269 | |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 2270 | for (j = 0; j < MAX_WLAN_TAGS - 1; j++) { |
| 2271 | /* |
| 2272 | * We keep a separate array of ap_tag_ssid and |
| 2273 | * ap_tag_key_mgmt for tags starting from WLAN_TAG=2. |
| 2274 | * So j=0 => WLAN_TAG = 2 |
| 2275 | */ |
| 2276 | int wlan_tag = j + 2; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2277 | |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 2278 | if (dut->ap_tag_ssid[j][0] == '\0') |
| 2279 | continue; |
| 2280 | |
| 2281 | snprintf(buf, sizeof(buf), "%s%d", "wifi", vap_count); |
| 2282 | owrt_ap_add_vap(dut, vap_count + (wlan_tag - 1), |
| 2283 | "device", buf); |
| 2284 | /* SSID */ |
| 2285 | snprintf(buf, sizeof(buf), "\"%s\"", |
| 2286 | dut->ap_tag_ssid[j]); |
| 2287 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), |
| 2288 | "ssid", buf); |
| 2289 | |
| 2290 | if (dut->ap_tag_key_mgmt[j] == AP2_OSEN && |
| 2291 | wlan_tag == 2) { |
| 2292 | /* Only supported for WLAN_TAG=2 */ |
| 2293 | owrt_ap_set_vap(dut, vap_count + 1, "osen", |
| 2294 | "1"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2295 | snprintf(buf, sizeof(buf), "wpa2"); |
| 2296 | owrt_ap_set_vap(dut, vap_count + 1, |
| 2297 | "encryption", buf); |
| 2298 | snprintf(buf, sizeof(buf), "%s", |
| 2299 | dut->ap2_radius_ipaddr); |
| 2300 | owrt_ap_set_vap(dut, vap_count + 1, |
| 2301 | "auth_server", buf); |
| 2302 | snprintf(buf, sizeof(buf), "%d", |
| 2303 | dut->ap2_radius_port); |
| 2304 | owrt_ap_set_vap(dut, vap_count + 1, |
| 2305 | "auth_port", buf); |
| 2306 | snprintf(buf, sizeof(buf), "%s", |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 2307 | dut->ap2_radius_password); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2308 | owrt_ap_set_vap(dut, vap_count + 1, |
| 2309 | "auth_secret", buf); |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 2310 | } else if (dut->ap_tag_key_mgmt[j] == AP2_WPA2_PSK) { |
| 2311 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), |
| 2312 | "encryption", "psk2+ccmp"); |
| 2313 | snprintf(buf, sizeof(buf), "\"%s\"", |
| 2314 | dut->ap_passphrase); |
| 2315 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), |
| 2316 | "key", buf); |
| 2317 | snprintf(buf, sizeof(buf), "%d", dut->ap_pmf); |
| 2318 | owrt_ap_set_vap(dut, vap_count + 1, |
| 2319 | "ieee80211w", buf); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2320 | } |
| 2321 | } |
| 2322 | |
Adil Saeed Musthafa | a8d7484 | 2017-04-10 23:13:39 -0700 | [diff] [blame] | 2323 | /* Now set anqp_elem for wlan_tag = 1 */ |
| 2324 | if (dut->program == PROGRAM_MBO && |
| 2325 | get_driver_type() == DRIVER_OPENWRT) { |
| 2326 | char anqp_string[200]; |
| 2327 | |
| 2328 | set_anqp_elem_value(dut, sigma_radio_ifname[0], |
| 2329 | anqp_string, sizeof(anqp_string)); |
| 2330 | owrt_ap_set_list_vap(dut, vap_count, "anqp_elem", |
| 2331 | anqp_string); |
| 2332 | } |
| 2333 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2334 | /* SSID */ |
| 2335 | snprintf(buf, sizeof(buf), "\"%s\"", dut->ap_ssid); |
| 2336 | owrt_ap_set_vap(dut, vap_count, "ssid", buf); |
| 2337 | |
| 2338 | /* Encryption */ |
| 2339 | switch (dut->ap_key_mgmt) { |
| 2340 | case AP_OPEN: |
| 2341 | if (dut->ap_cipher == AP_WEP) { |
| 2342 | owrt_ap_set_vap(dut, vap_count, "encryption", |
| 2343 | "wep-mixed"); |
| 2344 | owrt_ap_set_vap(dut, vap_count, "key", |
| 2345 | dut->ap_wepkey); |
| 2346 | } else { |
| 2347 | owrt_ap_set_vap(dut, vap_count, "encryption", |
| 2348 | "none"); |
| 2349 | } |
| 2350 | break; |
| 2351 | case AP_WPA2_PSK: |
| 2352 | case AP_WPA2_PSK_MIXED: |
| 2353 | case AP_WPA_PSK: |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 2354 | case AP_WPA2_SAE: |
| 2355 | case AP_WPA2_PSK_SAE: |
| 2356 | /* TODO: SAE configuration */ |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2357 | if (dut->ap_key_mgmt == AP_WPA2_PSK) { |
| 2358 | snprintf(buf, sizeof(buf), "psk2"); |
| 2359 | } else if (dut->ap_key_mgmt == AP_WPA2_PSK_MIXED) { |
| 2360 | snprintf(buf, sizeof(buf), "psk-mixed"); |
| 2361 | } else { |
| 2362 | snprintf(buf, sizeof(buf), "psk"); |
| 2363 | } |
| 2364 | |
Peng Xu | 591be45 | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 2365 | if (dut->ap_cipher == AP_CCMP_TKIP) |
| 2366 | strlcat(buf, "+ccmp+tkip", sizeof(buf)); |
| 2367 | else if (dut->ap_cipher == AP_TKIP) |
| 2368 | strlcat(buf, "+tkip", sizeof(buf)); |
| 2369 | else |
| 2370 | strlcat(buf, "+ccmp", sizeof(buf)); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2371 | |
| 2372 | owrt_ap_set_vap(dut, vap_count, "encryption", buf); |
| 2373 | snprintf(buf, sizeof(buf), "\"%s\"", |
| 2374 | dut->ap_passphrase); |
| 2375 | owrt_ap_set_vap(dut, vap_count, "key", buf); |
| 2376 | break; |
| 2377 | case AP_WPA2_EAP: |
| 2378 | case AP_WPA2_EAP_MIXED: |
| 2379 | case AP_WPA_EAP: |
| 2380 | if (dut->ap_key_mgmt == AP_WPA2_EAP) { |
| 2381 | snprintf(buf, sizeof(buf), "wpa2"); |
| 2382 | } else if (dut->ap_key_mgmt == AP_WPA2_EAP_MIXED) { |
| 2383 | snprintf(buf, sizeof(buf), "wpa-mixed"); |
| 2384 | } else { |
| 2385 | snprintf(buf, sizeof(buf), "wpa"); |
| 2386 | } |
| 2387 | |
Peng Xu | 591be45 | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 2388 | if (dut->ap_cipher == AP_CCMP_TKIP) |
| 2389 | strlcat(buf, "+ccmp+tkip", sizeof(buf)); |
| 2390 | else if (dut->ap_cipher == AP_TKIP) |
| 2391 | strlcat(buf, "+tkip", sizeof(buf)); |
| 2392 | else |
| 2393 | strlcat(buf, "+ccmp", sizeof(buf)); |
| 2394 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2395 | owrt_ap_set_vap(dut, vap_count, "encryption", buf); |
| 2396 | snprintf(buf, sizeof(buf), "%s", dut->ap_radius_ipaddr); |
| 2397 | owrt_ap_set_vap(dut, vap_count, "auth_server", buf); |
| 2398 | snprintf(buf, sizeof(buf), "%d", dut->ap_radius_port); |
| 2399 | owrt_ap_set_vap(dut, vap_count, "auth_port", buf); |
| 2400 | snprintf(buf, sizeof(buf), "%s", |
| 2401 | dut->ap_radius_password); |
| 2402 | owrt_ap_set_vap(dut, vap_count, "auth_secret", buf); |
| 2403 | break; |
Jouni Malinen | ad395a2 | 2017-09-01 21:13:46 +0300 | [diff] [blame] | 2404 | case AP_SUITEB: |
| 2405 | /* TODO */ |
| 2406 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 2407 | "SuiteB not supported"); |
| 2408 | break; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2409 | } |
| 2410 | |
| 2411 | if (!dut->ap_is_dual) |
| 2412 | break; |
| 2413 | } |
| 2414 | |
| 2415 | if (dut->ap_is_dual) |
| 2416 | return 1; |
| 2417 | |
| 2418 | /* PMF */ |
| 2419 | snprintf(buf, sizeof(buf), "%d", dut->ap_pmf); |
| 2420 | owrt_ap_set_vap(dut, vap_id, "ieee80211w", buf); |
| 2421 | |
| 2422 | /* Add SHA256 */ |
| 2423 | snprintf(buf, sizeof(buf), "%d", dut->ap_add_sha256); |
| 2424 | owrt_ap_set_vap(dut, vap_id, "add_sha256", buf); |
| 2425 | |
Sarvepalli, Rajesh Babu | 24dc7e4 | 2016-03-18 21:27:26 +0530 | [diff] [blame] | 2426 | /* Enable RSN preauthentication, if asked to */ |
| 2427 | snprintf(buf, sizeof(buf), "%d", dut->ap_rsn_preauth); |
| 2428 | owrt_ap_set_vap(dut, vap_id, "rsn_preauth", buf); |
| 2429 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2430 | /* Hotspot 2.0 */ |
| 2431 | if (dut->ap_hs2) { |
| 2432 | int ret; |
| 2433 | |
| 2434 | ret = owrt_ap_config_vap_hs2(dut, vap_id); |
| 2435 | if (ret) |
| 2436 | return ret; |
| 2437 | } |
| 2438 | |
| 2439 | /* Interworking */ |
| 2440 | if (dut->ap_interworking) { |
| 2441 | snprintf(buf, sizeof(buf), "%d", dut->ap_access_net_type); |
| 2442 | owrt_ap_set_vap(dut, vap_id, "access_network_type", buf); |
| 2443 | snprintf(buf, sizeof(buf), "%d", dut->ap_internet); |
| 2444 | owrt_ap_set_vap(dut, vap_id, "internet", buf); |
| 2445 | snprintf(buf, sizeof(buf), "%d", dut->ap_venue_group); |
| 2446 | owrt_ap_set_vap(dut, vap_id, "venue_group", buf); |
| 2447 | snprintf(buf, sizeof(buf), "%d", dut->ap_venue_type); |
| 2448 | owrt_ap_set_vap(dut, vap_id, "venue_type", buf); |
| 2449 | snprintf(buf, sizeof(buf), "%s", dut->ap_hessid); |
| 2450 | owrt_ap_set_vap(dut, vap_id, "hessid", buf); |
| 2451 | |
| 2452 | if (dut->ap_gas_cb_delay > 0) { |
| 2453 | snprintf(buf, sizeof(buf), "%d", dut->ap_gas_cb_delay); |
| 2454 | owrt_ap_set_vap(dut, vap_id, "gas_comeback_delay", buf); |
| 2455 | } |
| 2456 | |
| 2457 | if (dut->ap_roaming_cons[0]) { |
| 2458 | char *rcons, *temp_ptr; |
| 2459 | |
| 2460 | rcons = strdup(dut->ap_roaming_cons); |
| 2461 | if (rcons == NULL) |
| 2462 | return 0; |
| 2463 | |
| 2464 | temp_ptr = strchr(rcons, ';'); |
| 2465 | |
| 2466 | if (temp_ptr) |
| 2467 | *temp_ptr++ = '\0'; |
| 2468 | |
| 2469 | owrt_ap_set_list_vap(dut, vap_id, "roaming_consortium", |
| 2470 | rcons); |
| 2471 | |
| 2472 | if (temp_ptr) |
| 2473 | owrt_ap_set_list_vap(dut, vap_id, |
| 2474 | "roaming_consortium", |
| 2475 | temp_ptr); |
| 2476 | |
| 2477 | free(rcons); |
| 2478 | } |
| 2479 | } |
| 2480 | |
| 2481 | if (dut->ap_venue_name) { |
| 2482 | owrt_ap_set_list_vap(dut, vap_id, "venue_name", |
| 2483 | "'P\"eng:Wi-Fi Alliance\\n2989 Copper Road\\nSanta Clara, CA 95051, USA\"'"); |
| 2484 | owrt_ap_set_list_vap(dut, vap_id, "venue_name", |
| 2485 | "\'"ANQP_VENUE_NAME_1_CHI"\'"); |
| 2486 | } |
| 2487 | |
| 2488 | if (dut->ap_net_auth_type == 1) { |
| 2489 | owrt_ap_set_vap(dut, vap_id, "network_auth_type", |
| 2490 | "'00https://tandc-server.wi-fi.org'"); |
| 2491 | } else if (dut->ap_net_auth_type == 2) { |
| 2492 | owrt_ap_set_vap(dut, vap_id, "network_auth_type", "'01'"); |
| 2493 | } |
| 2494 | |
| 2495 | if (dut->ap_nai_realm_list == 1) { |
| 2496 | owrt_ap_set_list_vap(dut, vap_id, "nai_realm", |
| 2497 | "'0,mail.example.com;cisco.com;wi-fi.org,21[2:4][5:7]'"); |
| 2498 | owrt_ap_set_list_vap(dut, vap_id, "nai_realm", |
| 2499 | "'0,wi-fi.org;example.com,13[5:6]'"); |
| 2500 | |
| 2501 | } else if (dut->ap_nai_realm_list == 2) { |
| 2502 | owrt_ap_set_list_vap(dut, vap_id, "nai_realm", |
| 2503 | "'0,wi-fi.org,21[2:4][5:7]'"); |
| 2504 | } else if (dut->ap_nai_realm_list == 3) { |
| 2505 | owrt_ap_set_list_vap(dut, vap_id, "nai_realm", |
| 2506 | "'0,cisco.com;wi-fi.org,21[2:4][5:7]'"); |
| 2507 | owrt_ap_set_list_vap(dut, vap_id, "nai_realm", |
| 2508 | "'0,wi-fi.org;example.com,13[5:6]'"); |
| 2509 | } else if (dut->ap_nai_realm_list == 4) { |
| 2510 | owrt_ap_set_list_vap(dut, vap_id, "nai_realm", |
| 2511 | "'0,mail.example.com,21[2:4][5:7],13[5:6]'"); |
| 2512 | } else if (dut->ap_nai_realm_list == 5) { |
| 2513 | owrt_ap_set_list_vap(dut, vap_id, "nai_realm", |
| 2514 | "'0,wi-fi.org;ruckuswireless.com,21[2:4][5:7]'"); |
| 2515 | } else if (dut->ap_nai_realm_list == 6) { |
| 2516 | owrt_ap_set_list_vap(dut, vap_id, "nai_realm", |
| 2517 | "'0,wi-fi.org;mail.example.com,21[2:4][5:7]'"); |
| 2518 | } else if (dut->ap_nai_realm_list == 7) { |
| 2519 | owrt_ap_set_list_vap(dut, vap_id, "nai_realm", |
| 2520 | "'0,wi-fi.org,13[5:6]'"); |
| 2521 | owrt_ap_set_list_vap(dut, vap_id, "nai_realm", |
| 2522 | "'0,wi-fi.org,21[2:4][5:7]'"); |
| 2523 | } |
| 2524 | |
| 2525 | if (dut->ap_domain_name_list[0]) |
| 2526 | owrt_ap_set_list_vap(dut, vap_id, "domain_name", |
| 2527 | dut->ap_domain_name_list); |
| 2528 | |
| 2529 | if (dut->ap_ip_addr_type_avail) |
| 2530 | owrt_ap_set_vap(dut, vap_id, "ipaddr_type_availability", |
| 2531 | "'0c'"); |
| 2532 | |
| 2533 | temp = buf; |
| 2534 | |
| 2535 | *temp++ = '\''; |
| 2536 | |
| 2537 | for (i = 0; dut->ap_plmn_mcc[i][0] && dut->ap_plmn_mnc[i][0]; i++) { |
| 2538 | if (i) |
| 2539 | *temp++ = ';'; |
| 2540 | |
| 2541 | snprintf(temp, |
| 2542 | sizeof(dut->ap_plmn_mcc[i]) + |
| 2543 | sizeof(dut->ap_plmn_mnc[i]) + 1, |
| 2544 | "%s,%s", |
| 2545 | dut->ap_plmn_mcc[i], |
| 2546 | dut->ap_plmn_mnc[i]); |
| 2547 | |
| 2548 | temp += strlen(dut->ap_plmn_mcc[i]) + |
| 2549 | strlen(dut->ap_plmn_mnc[i]) + 1; |
| 2550 | } |
| 2551 | |
| 2552 | *temp++ = '\''; |
| 2553 | *temp++ = '\0'; |
| 2554 | |
| 2555 | if (i) |
| 2556 | owrt_ap_set_vap(dut, vap_id, "anqp_3gpp_cell_net", buf); |
| 2557 | |
| 2558 | if (dut->ap_qos_map_set == 1) |
| 2559 | owrt_ap_set_vap(dut, vap_id, "qos_map_set", QOS_MAP_SET_1); |
| 2560 | else if (dut->ap_qos_map_set == 2) |
| 2561 | owrt_ap_set_vap(dut, vap_id, "qos_map_set", QOS_MAP_SET_2); |
| 2562 | |
| 2563 | /* Proxy-ARP */ |
| 2564 | snprintf(buf, sizeof(buf), "%d", dut->ap_proxy_arp); |
| 2565 | owrt_ap_set_vap(dut, vap_id, "proxyarp", buf); |
| 2566 | |
| 2567 | /* DGAF */ |
| 2568 | snprintf(buf, sizeof(buf), "%d", dut->ap_dgaf_disable); |
| 2569 | /* parse to hostapd */ |
| 2570 | owrt_ap_set_vap(dut, vap_id, "disable_dgaf", buf); |
| 2571 | /* parse to wifi driver */ |
| 2572 | owrt_ap_set_vap(dut, vap_id, "dgaf_disable", buf); |
| 2573 | |
| 2574 | /* HCBSSLoad */ |
| 2575 | if (dut->ap_bss_load) { |
| 2576 | unsigned int bssload = 0; |
| 2577 | |
| 2578 | if (dut->ap_bss_load == 1) { |
| 2579 | /* STA count: 1, CU: 50, AAC: 65535 */ |
| 2580 | bssload = 0x0132ffff; |
| 2581 | } else if (dut->ap_bss_load == 2) { |
| 2582 | /* STA count: 1, CU: 200, AAC: 65535 */ |
| 2583 | bssload = 0x01c8ffff; |
| 2584 | } else if (dut->ap_bss_load == 3) { |
| 2585 | /* STA count: 1, CU: 75, AAC: 65535 */ |
| 2586 | bssload = 0x014bffff; |
| 2587 | } |
| 2588 | |
| 2589 | snprintf(buf, sizeof(buf), "%d", bssload); |
| 2590 | owrt_ap_set_vap(dut, vap_id, "hcbssload", buf); |
| 2591 | } |
| 2592 | |
| 2593 | /* L2TIF */ |
| 2594 | if (dut->ap_l2tif) |
| 2595 | owrt_ap_set_vap(dut, vap_id, "l2tif", "1"); |
| 2596 | |
| 2597 | if (dut->ap_disable_protection == 1) |
| 2598 | owrt_ap_set_vap(dut, vap_id, "enablertscts", "0"); |
| 2599 | |
Sunil Dutt | 77b213d | 2017-09-14 18:24:40 +0300 | [diff] [blame] | 2600 | if (dut->ap_txBF) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2601 | owrt_ap_set_vap(dut, vap_id, "vhtsubfee", "1"); |
| 2602 | owrt_ap_set_vap(dut, vap_id, "vhtsubfer", "1"); |
| 2603 | } |
| 2604 | |
Mohammed Shafi Shajakhan | 061af00 | 2016-06-02 20:10:54 +0530 | [diff] [blame] | 2605 | if (dut->ap_mu_txBF) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2606 | owrt_ap_set_vap(dut, vap_id, "vhtmubfer", "1"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2607 | |
Vasanthakumar Pandurangan | 2b5431d | 2016-01-12 15:52:48 +0530 | [diff] [blame] | 2608 | if (dut->ap_tx_stbc) { |
| 2609 | /* STBC and beamforming are mutually exclusive features */ |
| 2610 | owrt_ap_set_vap(dut, vap_id, "implicitbf", "0"); |
| 2611 | } |
| 2612 | |
Priyadharshini Gowthaman | 8fb1504 | 2015-11-25 18:27:41 +0530 | [diff] [blame] | 2613 | /* enable dfsmode */ |
| 2614 | snprintf(buf, sizeof(buf), "%d", dut->ap_dfs_mode); |
| 2615 | owrt_ap_set_vap(dut, vap_id, "doth", buf); |
| 2616 | |
priyadharshini gowthaman | 2323d0a | 2016-09-02 15:48:02 -0700 | [diff] [blame] | 2617 | if (dut->program == PROGRAM_LOC && dut->ap_interworking) { |
| 2618 | char anqpval[1024]; |
| 2619 | |
| 2620 | owrt_ap_set_vap(dut, vap_id, "interworking", "1"); |
| 2621 | |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 2622 | 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] | 2623 | snprintf(anqpval, sizeof(anqpval), |
| 2624 | "'265:0010%s%s060101'", |
priyadharshini gowthaman | 2323d0a | 2016-09-02 15:48:02 -0700 | [diff] [blame] | 2625 | dut->ap_val_lci, dut->ap_infoz); |
| 2626 | owrt_ap_set_list_vap(dut, vap_id, "anqp_elem", anqpval); |
| 2627 | } |
| 2628 | |
| 2629 | if (dut->ap_lcr == 1) { |
Pradeep Reddy Potteti | b48012a | 2016-11-28 16:58:54 +0530 | [diff] [blame] | 2630 | snprintf(anqpval, sizeof(anqpval), |
| 2631 | "'266:0000b2555302ae%s'", |
priyadharshini gowthaman | 2323d0a | 2016-09-02 15:48:02 -0700 | [diff] [blame] | 2632 | dut->ap_val_lcr); |
| 2633 | owrt_ap_set_list_vap(dut, vap_id, "anqp_elem", anqpval); |
| 2634 | } |
| 2635 | |
| 2636 | if (dut->ap_fqdn_held == 1 && dut->ap_fqdn_supl == 1) |
| 2637 | owrt_ap_set_list_vap(dut, vap_id, "anqp_elem", |
| 2638 | "'267:00110168656c642e6578616d706c652e636f6d0011027375706c2e6578616d706c652e636f6d'"); |
| 2639 | } |
| 2640 | |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 2641 | if (dut->program == PROGRAM_MBO) { |
| 2642 | owrt_ap_set_vap(dut, vap_id, "interworking", "1"); |
| 2643 | owrt_ap_set_vap(dut, vap_id, "mbo", "1"); |
| 2644 | owrt_ap_set_vap(dut, vap_id, "rrm", "1"); |
Adil Saeed Musthafa | 65160c0 | 2017-04-10 23:13:38 -0700 | [diff] [blame] | 2645 | owrt_ap_set_vap(dut, vap_id, "mbo_cell_conn_pref", "1"); |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 2646 | |
| 2647 | owrt_ap_set_list_vap(dut, vap_id, "anqp_elem", |
| 2648 | "'272:34108cfdf0020df1f7000000733000030101'"); |
Adil Saeed Musthafa | ed5faae | 2017-04-10 23:13:36 -0700 | [diff] [blame] | 2649 | snprintf(buf, sizeof(buf), "%d", dut->ap_gas_cb_delay); |
| 2650 | owrt_ap_set_vap(dut, vap_id, "gas_comeback_delay", buf); |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 2651 | } |
| 2652 | |
Adil Saeed Musthafa | 4ec61bd | 2017-04-10 23:13:41 -0700 | [diff] [blame] | 2653 | if (dut->ap_ft_oa == 1) { |
| 2654 | unsigned char self_mac[ETH_ALEN]; |
| 2655 | char mac_str[20]; |
| 2656 | |
| 2657 | owrt_ap_set_vap(dut, vap_id, "ft_over_ds", "0"); |
| 2658 | owrt_ap_set_vap(dut, vap_id, "ieee80211r", "1"); |
| 2659 | get_hwaddr(sigma_radio_ifname[0], self_mac); |
| 2660 | snprintf(mac_str, sizeof(mac_str), |
| 2661 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 2662 | self_mac[0], self_mac[1], self_mac[2], |
| 2663 | self_mac[3], self_mac[4], self_mac[5]); |
| 2664 | owrt_ap_set_vap(dut, vap_id, "ap_macaddr", mac_str); |
| 2665 | owrt_ap_set_vap(dut, vap_id, "ft_psk_generate_local", "1"); |
| 2666 | owrt_ap_set_vap(dut, vap_id, "kh_key_hex", |
| 2667 | "000102030405060708090a0b0c0d0e0f"); |
| 2668 | snprintf(mac_str, sizeof(mac_str), |
| 2669 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 2670 | dut->ft_bss_mac_list[0][0], |
| 2671 | dut->ft_bss_mac_list[0][1], |
| 2672 | dut->ft_bss_mac_list[0][2], |
| 2673 | dut->ft_bss_mac_list[0][3], |
| 2674 | dut->ft_bss_mac_list[0][4], |
| 2675 | dut->ft_bss_mac_list[0][5]); |
| 2676 | owrt_ap_set_vap(dut, vap_id, "ap2_macaddr", mac_str); |
| 2677 | } |
| 2678 | |
| 2679 | if ((dut->ap_ft_oa == 1 && dut->ap_name == 0) || |
| 2680 | (dut->ap_ft_oa == 1 && dut->ap_name == 2)) { |
| 2681 | owrt_ap_set_vap(dut, vap_id, "ap2_r1_key_holder", |
| 2682 | "00:01:02:03:04:06"); |
| 2683 | owrt_ap_set_vap(dut, vap_id, "nasid2", "nas2.example.com"); |
| 2684 | owrt_ap_set_vap(dut, vap_id, "nasid", "nas1.example.com"); |
| 2685 | owrt_ap_set_vap(dut, vap_id, "r1_key_holder", "000102030405"); |
| 2686 | } |
| 2687 | |
| 2688 | if (dut->ap_ft_oa == 1 && dut->ap_name == 1) { |
| 2689 | owrt_ap_set_vap(dut, vap_id, "ap2_r1_key_holder", |
| 2690 | "00:01:02:03:04:05"); |
| 2691 | owrt_ap_set_vap(dut, vap_id, "nasid2", "nas1.example.com"); |
| 2692 | owrt_ap_set_vap(dut, vap_id, "nasid", "nas2.example.com"); |
| 2693 | owrt_ap_set_vap(dut, vap_id, "r1_key_holder", "000102030406"); |
| 2694 | } |
| 2695 | |
Adil Saeed Musthafa | cf752fa | 2017-04-10 23:13:32 -0700 | [diff] [blame] | 2696 | if (dut->ap_mobility_domain[0]) |
| 2697 | owrt_ap_set_vap(dut, vap_id, "mobility_domain", |
| 2698 | dut->ap_mobility_domain); |
| 2699 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2700 | return 1; |
| 2701 | } |
| 2702 | |
| 2703 | |
priyadharshini gowthaman | 2500f20 | 2016-10-13 17:13:55 -0700 | [diff] [blame] | 2704 | static int owrt_ap_config_vap_anqp(struct sigma_dut *dut) |
| 2705 | { |
| 2706 | char anqpval[1024]; |
| 2707 | unsigned char addr[6]; |
| 2708 | unsigned char addr2[6]; |
| 2709 | struct ifreq ifr; |
| 2710 | char *ifname; |
| 2711 | int s; |
| 2712 | int vap_id = 0; |
| 2713 | |
| 2714 | s = socket(AF_INET, SOCK_DGRAM, 0); |
| 2715 | if (s < 0) { |
| 2716 | sigma_dut_print(dut, DUT_MSG_ERROR, "Failed to open socket"); |
| 2717 | return -1; |
| 2718 | } |
| 2719 | |
| 2720 | memset(&ifr, 0, sizeof(ifr)); |
| 2721 | ifname = "ath0"; |
Peng Xu | b8fc5cc | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 2722 | strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name)); |
priyadharshini gowthaman | 2500f20 | 2016-10-13 17:13:55 -0700 | [diff] [blame] | 2723 | if (ioctl(s, SIOCGIFHWADDR, &ifr) < 0) { |
| 2724 | perror("ioctl"); |
| 2725 | close(s); |
| 2726 | return -1; |
| 2727 | } |
| 2728 | memcpy(addr, ifr.ifr_hwaddr.sa_data, 6); |
| 2729 | |
| 2730 | memset(&ifr, 0, sizeof(ifr)); |
| 2731 | ifname = "ath01"; |
Peng Xu | b8fc5cc | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 2732 | strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name)); |
priyadharshini gowthaman | 2500f20 | 2016-10-13 17:13:55 -0700 | [diff] [blame] | 2733 | if (ioctl(s, SIOCGIFHWADDR, &ifr) < 0) { |
| 2734 | perror("ioctl"); |
| 2735 | close(s); |
| 2736 | return -1; |
| 2737 | } |
| 2738 | close(s); |
| 2739 | memcpy(addr2, ifr.ifr_hwaddr.sa_data, 6); |
| 2740 | |
| 2741 | snprintf(anqpval, sizeof(anqpval), |
| 2742 | "'265:0010%s%s060101070d00%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x'", |
| 2743 | dut->ap_val_lci, dut->ap_infoz, |
| 2744 | addr[0], addr[1], addr[2], addr[3], addr[4], addr[5], |
| 2745 | addr2[0], addr2[1], addr2[2], addr2[3], addr2[4], addr2[5]); |
| 2746 | |
| 2747 | owrt_ap_set_list_vap(dut, vap_id, "anqp_elem", anqpval); |
| 2748 | return 0; |
| 2749 | } |
| 2750 | |
| 2751 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2752 | static int owrt_ap_post_config_commit(struct sigma_dut *dut, |
| 2753 | struct sigma_conn *conn, |
| 2754 | struct sigma_cmd *cmd) |
| 2755 | { |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 2756 | int ap_security = 0; |
| 2757 | int i; |
| 2758 | |
| 2759 | for (i = 0; i < MAX_WLAN_TAGS - 1; i++) { |
| 2760 | if (dut->ap_tag_key_mgmt[i] != AP2_OPEN) |
| 2761 | ap_security = 1; |
| 2762 | } |
| 2763 | if (dut->ap_key_mgmt != AP_OPEN) |
| 2764 | ap_security = 1; |
| 2765 | if (ap_security) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2766 | /* allow some time for hostapd to start before returning |
| 2767 | * success */ |
| 2768 | usleep(500000); |
| 2769 | |
| 2770 | if (run_hostapd_cli(dut, "ping") != 0) { |
| 2771 | send_resp(dut, conn, SIGMA_ERROR, |
| 2772 | "errorCode,Failed to talk to hostapd"); |
| 2773 | return 0; |
| 2774 | } |
| 2775 | } |
| 2776 | |
| 2777 | if (get_openwrt_driver_type() == OPENWRT_DRIVER_ATHEROS) |
| 2778 | ath_ap_set_params(dut); |
| 2779 | |
| 2780 | /* Send response */ |
| 2781 | return 1; |
| 2782 | } |
| 2783 | |
| 2784 | |
| 2785 | static int cmd_owrt_ap_config_commit(struct sigma_dut *dut, |
| 2786 | struct sigma_conn *conn, |
| 2787 | struct sigma_cmd *cmd) |
| 2788 | { |
| 2789 | /* Stop the AP */ |
| 2790 | run_system(dut, "wifi down"); |
| 2791 | |
| 2792 | /* Reset the wireless configuration */ |
Mohammed Shafi Shajakhan | f789f82 | 2016-04-07 18:53:16 +0530 | [diff] [blame] | 2793 | run_system(dut, "rm -rf /etc/config/wireless"); |
| 2794 | switch (get_openwrt_driver_type()) { |
| 2795 | case OPENWRT_DRIVER_ATHEROS: |
| 2796 | run_system(dut, "wifi detect qcawifi > /etc/config/wireless"); |
| 2797 | break; |
| 2798 | default: |
| 2799 | run_system(dut, "wifi detect > /etc/config/wireless"); |
| 2800 | break; |
| 2801 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2802 | |
| 2803 | /* Configure Radio & VAP, commit the config */ |
| 2804 | owrt_ap_config_radio(dut); |
| 2805 | owrt_ap_config_vap(dut); |
| 2806 | run_system(dut, "uci commit"); |
| 2807 | |
| 2808 | /* Start AP */ |
| 2809 | run_system(dut, "wifi up"); |
Adil Saeed Musthafa | a8d7484 | 2017-04-10 23:13:39 -0700 | [diff] [blame] | 2810 | if (dut->program != PROGRAM_MBO && |
| 2811 | dut->ap_lci == 1 && dut->ap_interworking && |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 2812 | strlen(dut->ap_tag_ssid[0]) > 0) { |
Adil Saeed Musthafa | a8d7484 | 2017-04-10 23:13:39 -0700 | [diff] [blame] | 2813 | /* |
| 2814 | * MBO has a different ANQP element value which is set in |
| 2815 | * owrt_ap_config_vap(). |
| 2816 | */ |
priyadharshini gowthaman | 2500f20 | 2016-10-13 17:13:55 -0700 | [diff] [blame] | 2817 | owrt_ap_config_vap_anqp(dut); |
| 2818 | run_system(dut, "uci commit"); |
| 2819 | run_system(dut, "wifi"); |
| 2820 | } |
| 2821 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2822 | return owrt_ap_post_config_commit(dut, conn, cmd); |
| 2823 | } |
| 2824 | |
| 2825 | |
| 2826 | static void cmd_owrt_ap_hs2_reset(struct sigma_dut *dut) |
| 2827 | { |
| 2828 | unsigned char bssid[6]; |
| 2829 | char buf[100]; |
| 2830 | char *ifname, *radio_name; |
| 2831 | int vap_id = 0; |
| 2832 | |
| 2833 | if (sigma_radio_ifname[0] && |
| 2834 | strcmp(sigma_radio_ifname[0], "wifi2") == 0) { |
| 2835 | ifname = "ath2"; |
| 2836 | radio_name = "wifi2"; |
| 2837 | vap_id = 2; |
| 2838 | } else if (sigma_radio_ifname[0] && |
| 2839 | strcmp(sigma_radio_ifname[0], "wifi1") == 0) { |
| 2840 | ifname = "ath1"; |
| 2841 | radio_name = "wifi1"; |
| 2842 | vap_id = 1; |
| 2843 | } else { |
| 2844 | ifname = "ath0"; |
| 2845 | radio_name = "wifi0"; |
| 2846 | vap_id = 0; |
| 2847 | } |
| 2848 | |
| 2849 | if (!get_hwaddr(ifname, bssid)) { |
| 2850 | snprintf(buf, sizeof(buf), "%s", bssid); |
| 2851 | owrt_ap_set_vap(dut, vap_id, "hessid", buf); |
| 2852 | snprintf(dut->ap_hessid, sizeof(dut->ap_hessid), |
| 2853 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 2854 | bssid[0], bssid[1], bssid[2], bssid[3], |
| 2855 | bssid[4], bssid[5]); |
| 2856 | } else { |
| 2857 | if (!get_hwaddr(radio_name, bssid)) { |
| 2858 | snprintf(buf, sizeof(buf), "%s", dut->ap_hessid); |
| 2859 | owrt_ap_set_vap(dut, vap_id, "hessid", buf); |
| 2860 | snprintf(dut->ap_hessid, sizeof(dut->ap_hessid), |
| 2861 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 2862 | bssid[0], bssid[1], bssid[2], bssid[3], |
| 2863 | bssid[4], bssid[5]); |
| 2864 | } else { |
| 2865 | /* Select & enable/disable radios */ |
| 2866 | if (sigma_radio_ifname[0] && |
| 2867 | strcmp(sigma_radio_ifname[0], "wifi2") == 0) { |
| 2868 | /* We want to use wifi2 */ |
| 2869 | owrt_ap_set_radio(dut, 0, "disabled", "1"); |
| 2870 | owrt_ap_set_radio(dut, 1, "disabled", "1"); |
| 2871 | owrt_ap_set_radio(dut, 2, "disabled", "0"); |
| 2872 | owrt_ap_set_vap(dut, vap_id, "device", "wifi2"); |
| 2873 | } else if (sigma_radio_ifname[0] && |
| 2874 | strcmp(sigma_radio_ifname[0], "wifi1") == 0) { |
| 2875 | /* We want to use wifi1 */ |
| 2876 | owrt_ap_set_radio(dut, 0, "disabled", "1"); |
| 2877 | owrt_ap_set_radio(dut, 1, "disabled", "0"); |
| 2878 | owrt_ap_set_vap(dut, vap_id, "device", "wifi1"); |
| 2879 | } else { |
| 2880 | /* We want to use wifi0 */ |
| 2881 | owrt_ap_set_radio(dut, 0, "disabled", "0"); |
| 2882 | owrt_ap_set_radio(dut, 1, "disabled", "1"); |
| 2883 | owrt_ap_set_vap(dut, vap_id, "device", "wifi0"); |
| 2884 | } |
| 2885 | |
| 2886 | run_system(dut, "uci commit"); |
| 2887 | run_system(dut, "wifi up"); |
| 2888 | |
| 2889 | if (!get_hwaddr(radio_name, bssid)) { |
| 2890 | snprintf(buf, sizeof(buf), "%s", |
| 2891 | dut->ap_hessid); |
| 2892 | owrt_ap_set_vap(dut, vap_id, "hessid", buf); |
| 2893 | snprintf(dut->ap_hessid, sizeof(dut->ap_hessid), |
| 2894 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 2895 | bssid[0], bssid[1], bssid[2], bssid[3], |
| 2896 | bssid[4], bssid[5]); |
| 2897 | } |
| 2898 | } |
| 2899 | } |
| 2900 | } |
| 2901 | |
| 2902 | |
| 2903 | static int cmd_ap_reboot(struct sigma_dut *dut, struct sigma_conn *conn, |
| 2904 | struct sigma_cmd *cmd) |
| 2905 | { |
| 2906 | switch (get_driver_type()) { |
| 2907 | case DRIVER_ATHEROS: |
| 2908 | run_system(dut, "apdown"); |
| 2909 | sleep(1); |
| 2910 | run_system(dut, "reboot"); |
| 2911 | break; |
| 2912 | case DRIVER_OPENWRT: |
| 2913 | run_system(dut, "wifi down"); |
| 2914 | sleep(1); |
| 2915 | run_system(dut, "reboot"); |
| 2916 | break; |
| 2917 | default: |
| 2918 | sigma_dut_print(dut, DUT_MSG_INFO, "Ignore ap_reboot command"); |
| 2919 | break; |
| 2920 | } |
| 2921 | |
| 2922 | return 1; |
| 2923 | } |
| 2924 | |
| 2925 | |
| 2926 | int ascii2hexstr(const char *str, char *hex) |
| 2927 | { |
| 2928 | int i, length; |
| 2929 | |
| 2930 | length = strlen(str); |
| 2931 | |
| 2932 | for (i = 0; i < length; i++) |
| 2933 | snprintf(hex + i * 2, 3, "%X", str[i]); |
| 2934 | |
| 2935 | hex[length * 2] = '\0'; |
| 2936 | return 1; |
| 2937 | } |
| 2938 | |
| 2939 | |
| 2940 | static int kill_process(struct sigma_dut *dut, char *proc_name, |
| 2941 | unsigned char is_proc_instance_one, int sig) |
| 2942 | { |
| 2943 | #ifdef __linux__ |
| 2944 | struct dirent *dp, *dp_in; |
| 2945 | const char *direc = "/proc/"; |
| 2946 | char buf[100]; |
| 2947 | DIR *dir = opendir(direc); |
| 2948 | DIR *dir_in; |
| 2949 | FILE *fp; |
| 2950 | char *pid, *temp; |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 2951 | char *saveptr; |
Pradeep Reddy Potteti | d068e64 | 2017-02-17 20:03:12 +0530 | [diff] [blame] | 2952 | int ret = -1; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2953 | |
| 2954 | if (dir == NULL) |
Pradeep Reddy Potteti | d068e64 | 2017-02-17 20:03:12 +0530 | [diff] [blame] | 2955 | return ret; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2956 | |
| 2957 | while ((dp = readdir(dir)) != NULL) { |
| 2958 | if (dp->d_type != DT_DIR) |
| 2959 | continue; |
| 2960 | |
| 2961 | snprintf(buf, sizeof(buf), "%s%s", direc, dp->d_name); |
| 2962 | dir_in = opendir(buf); |
| 2963 | if (dir_in == NULL) |
| 2964 | continue; |
| 2965 | dp_in = readdir(dir_in); |
| 2966 | closedir(dir_in); |
| 2967 | if (dp_in == NULL) |
| 2968 | continue; |
| 2969 | snprintf(buf, sizeof(buf), "%s%s/stat", direc, dp->d_name); |
| 2970 | fp = fopen(buf, "r"); |
| 2971 | if (fp == NULL) |
| 2972 | continue; |
| 2973 | if (fgets(buf, 100, fp) == NULL) |
| 2974 | buf[0] = '\0'; |
| 2975 | fclose(fp); |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 2976 | pid = strtok_r(buf, " ", &saveptr); |
| 2977 | temp = strtok_r(NULL, " ", &saveptr); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2978 | if (pid && temp && |
| 2979 | strncmp(temp, proc_name, strlen(proc_name)) == 0) { |
| 2980 | sigma_dut_print(dut, DUT_MSG_INFO, |
| 2981 | "killing %s process with PID %s", |
| 2982 | proc_name, pid); |
| 2983 | snprintf(buf, sizeof(buf), "kill -%d %d", sig, |
| 2984 | atoi(pid)); |
| 2985 | run_system(dut, buf); |
Pradeep Reddy Potteti | d068e64 | 2017-02-17 20:03:12 +0530 | [diff] [blame] | 2986 | ret = 0; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2987 | if (is_proc_instance_one) |
| 2988 | break; |
| 2989 | } |
| 2990 | } |
| 2991 | |
| 2992 | closedir(dir); |
| 2993 | |
Pradeep Reddy Potteti | d068e64 | 2017-02-17 20:03:12 +0530 | [diff] [blame] | 2994 | return ret; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2995 | #else /* __linux__ */ |
| 2996 | return -1; |
| 2997 | #endif /* __linux__ */ |
| 2998 | } |
| 2999 | |
| 3000 | |
| 3001 | static int run_ndc(struct sigma_dut *dut, char *buf) |
| 3002 | { |
| 3003 | sigma_dut_print(dut, DUT_MSG_INFO, "CMD NDC:: %s", buf); |
| 3004 | sleep(2); |
| 3005 | return run_system(dut, buf); |
| 3006 | } |
| 3007 | |
| 3008 | |
| 3009 | static int sigma_write_cfg(struct sigma_dut *dut, const char *pfile, |
| 3010 | const char *field, const char *value) |
| 3011 | { |
| 3012 | FILE *fcfg, *ftmp; |
| 3013 | char buf[MAX_CONF_LINE_LEN + 1]; |
| 3014 | int len, found = 0, res; |
| 3015 | |
| 3016 | /* Open the configuration file */ |
| 3017 | fcfg = fopen(pfile, "r"); |
| 3018 | if (!fcfg) { |
| 3019 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 3020 | "Failed to open hostapd conf file"); |
| 3021 | return -1; |
| 3022 | } |
| 3023 | |
| 3024 | snprintf(buf, sizeof(buf), "%s~", pfile); |
| 3025 | /* Open a temporary file */ |
| 3026 | ftmp = fopen(buf, "w+"); |
| 3027 | if (!ftmp) { |
| 3028 | fclose(fcfg); |
| 3029 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 3030 | "Failed to open temp buf"); |
| 3031 | return -1; |
| 3032 | } |
| 3033 | |
| 3034 | /* Read the values from the configuration file */ |
| 3035 | len = strlen(field); |
| 3036 | while (fgets(buf, MAX_CONF_LINE_LEN, fcfg)) { |
| 3037 | char *pline = buf; |
| 3038 | |
| 3039 | /* commented line */ |
| 3040 | if (buf[0] == '#') |
| 3041 | pline++; |
| 3042 | |
| 3043 | /* Identify the configuration parameter to be updated */ |
| 3044 | if (!found && strncmp(pline, field, len) == 0 && |
| 3045 | pline[len] == '=') { |
| 3046 | snprintf(buf, sizeof(buf), "%s=%s\n", field, value); |
| 3047 | found = 1; |
| 3048 | sigma_dut_print(dut, DUT_MSG_INFO, |
| 3049 | "Updated hostapd conf file"); |
| 3050 | } |
| 3051 | |
| 3052 | fprintf(ftmp, "%s", buf); |
| 3053 | } |
| 3054 | |
| 3055 | if (!found) { |
| 3056 | /* Configuration line not found */ |
| 3057 | /* Add the new line at the end of file */ |
| 3058 | fprintf(ftmp, "%s=%s\n", field, value); |
| 3059 | sigma_dut_print(dut, DUT_MSG_INFO, |
| 3060 | "Adding a new line in hostapd conf file"); |
| 3061 | } |
| 3062 | |
| 3063 | fclose(fcfg); |
| 3064 | fclose(ftmp); |
| 3065 | |
| 3066 | snprintf(buf, sizeof(buf), "%s~", pfile); |
| 3067 | |
| 3068 | /* Restore the updated configuration file */ |
| 3069 | res = rename(buf, pfile); |
| 3070 | |
| 3071 | /* Remove the temporary file. Ignore the return value */ |
| 3072 | unlink(buf); |
| 3073 | |
| 3074 | /* chmod is needed because open() may not set permissions properly |
| 3075 | * depending on the current umask */ |
| 3076 | if (chmod(pfile, 0660) < 0) { |
| 3077 | unlink(pfile); |
| 3078 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 3079 | "Error changing permissions"); |
| 3080 | return -1; |
| 3081 | } |
| 3082 | |
| 3083 | if (res < 0) { |
| 3084 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 3085 | "Error restoring conf file"); |
| 3086 | return -1; |
| 3087 | } |
| 3088 | |
| 3089 | return 0; |
| 3090 | } |
| 3091 | |
| 3092 | |
| 3093 | static int cmd_wcn_ap_config_commit(struct sigma_dut *dut, |
| 3094 | struct sigma_conn *conn, |
| 3095 | struct sigma_cmd *cmd) |
| 3096 | { |
| 3097 | char buf[100]; |
| 3098 | struct stat s; |
| 3099 | int num_tries = 0, ret; |
| 3100 | |
Pradeep Reddy Potteti | d068e64 | 2017-02-17 20:03:12 +0530 | [diff] [blame] | 3101 | if (kill_process(dut, "(netd)", 1, SIGKILL) == 0 || |
| 3102 | system("killall netd") == 0) { |
| 3103 | /* Avoid Error: Error connecting (Connection refused) |
| 3104 | * Wait some time to allow netd to reinitialize. |
| 3105 | */ |
| 3106 | usleep(1500000); |
| 3107 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3108 | |
| 3109 | while (num_tries < 10) { |
| 3110 | ret = run_ndc(dut, "ndc softap stopap"); |
| 3111 | num_tries++; |
| 3112 | if (WIFEXITED(ret)) |
| 3113 | ret = WEXITSTATUS(ret); |
| 3114 | /* On success, NDC exits with 0 */ |
| 3115 | if (ret == 0) |
| 3116 | break; |
| 3117 | sigma_dut_print(dut, DUT_MSG_INFO, |
| 3118 | "Try No. %d: ndc softap stopap failed, exit code %d", |
| 3119 | num_tries, ret); |
| 3120 | } |
| 3121 | |
| 3122 | if (ret != 0) |
| 3123 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 3124 | "ndc softap stopap command failed for 10 times - giving up"); |
| 3125 | |
| 3126 | #ifdef ANDROID |
| 3127 | /* Unload/Load driver to cleanup the state of the driver */ |
Ajit Vaishya | 14d1f9a | 2017-09-04 23:24:25 +0530 | [diff] [blame^] | 3128 | system("rmmod -f wlan"); |
| 3129 | usleep(500000); |
| 3130 | system("insmod /system/lib/modules/wlan.ko"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3131 | #else /* ANDROID */ |
| 3132 | run_ndc(dut, "ndc softap qccmd set enable_softap=0"); |
| 3133 | run_ndc(dut, "ndc softap qccmd set enable_softap=1"); |
| 3134 | #endif /* ANDROID */ |
| 3135 | |
| 3136 | switch (dut->ap_mode) { |
| 3137 | case AP_11g: |
| 3138 | run_ndc(dut, "ndc softap qccmd set hw_mode=g-only"); |
| 3139 | break; |
| 3140 | case AP_11b: |
| 3141 | run_ndc(dut, "ndc softap qccmd set hw_mode=b-only"); |
| 3142 | break; |
| 3143 | case AP_11ng: |
| 3144 | run_ndc(dut, "ndc softap qccmd set hw_mode=n"); |
| 3145 | break; |
| 3146 | case AP_11a: |
| 3147 | run_ndc(dut, "ndc softap qccmd set hw_mode=a-only"); |
| 3148 | break; |
| 3149 | case AP_11na: |
| 3150 | run_ndc(dut, "ndc softap qccmd set hw_mode=n"); |
| 3151 | break; |
| 3152 | case AP_11ac: |
| 3153 | run_ndc(dut, "ndc softap qccmd set hw_mode=ac"); |
| 3154 | break; |
| 3155 | default: |
| 3156 | break; |
| 3157 | } |
| 3158 | |
| 3159 | snprintf(buf, sizeof(buf), "ndc softap qccmd set channel=%d", |
| 3160 | dut->ap_channel); |
| 3161 | run_ndc(dut, buf); |
| 3162 | |
| 3163 | /* |
| 3164 | * ndc doesn't support double quotes as SSID string, so re-write |
| 3165 | * hostapd configuration file to update SSID. |
| 3166 | */ |
| 3167 | if (dut->ap_ssid[0] != '\0') |
| 3168 | sigma_write_cfg(dut, ANDROID_CONFIG_FILE, "ssid", dut->ap_ssid); |
| 3169 | |
| 3170 | switch (dut->ap_key_mgmt) { |
| 3171 | case AP_OPEN: |
| 3172 | if (dut->ap_cipher == AP_WEP) { |
| 3173 | run_ndc(dut, "ndc softap qccmd set security_mode=1"); |
| 3174 | snprintf(buf, sizeof(buf), |
| 3175 | "ndc softap qccmd set wep_key0=%s", |
| 3176 | dut->ap_wepkey); |
| 3177 | run_ndc(dut, buf); |
| 3178 | } else { |
| 3179 | run_ndc(dut, "ndc softap qccmd set security_mode=0"); |
| 3180 | } |
| 3181 | break; |
| 3182 | case AP_WPA2_PSK: |
| 3183 | case AP_WPA2_PSK_MIXED: |
| 3184 | case AP_WPA_PSK: |
| 3185 | if (dut->ap_key_mgmt == AP_WPA2_PSK) |
| 3186 | run_ndc(dut, "ndc softap qccmd set security_mode=3"); |
| 3187 | else if (dut->ap_key_mgmt == AP_WPA2_PSK_MIXED) |
| 3188 | run_ndc(dut, "ndc softap qccmd set security_mode=4"); |
| 3189 | else |
| 3190 | run_ndc(dut, "ndc softap qccmd set security_mode=2"); |
| 3191 | |
| 3192 | /* |
| 3193 | * ndc doesn't support some special characters as passphrase, |
| 3194 | * so re-write hostapd configuration file to update Passphrase. |
| 3195 | */ |
| 3196 | if (dut->ap_passphrase[0] != '\0') |
| 3197 | sigma_write_cfg(dut, ANDROID_CONFIG_FILE, |
| 3198 | "wpa_passphrase", dut->ap_passphrase); |
| 3199 | |
| 3200 | if (dut->ap_cipher == AP_CCMP_TKIP) |
| 3201 | run_ndc(dut, "ndc softap qccmd set wpa_pairwise=" |
| 3202 | "TKIP CCMP"); |
| 3203 | else if (dut->ap_cipher == AP_TKIP) |
| 3204 | run_ndc(dut, "ndc softap qccmd set wpa_pairwise=" |
| 3205 | "TKIP"); |
| 3206 | else |
| 3207 | run_ndc(dut, "ndc softap qccmd set wpa_pairwise=" |
| 3208 | "CCMP &"); |
| 3209 | break; |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 3210 | case AP_WPA2_SAE: |
| 3211 | case AP_WPA2_PSK_SAE: |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3212 | case AP_WPA2_EAP: |
| 3213 | case AP_WPA2_EAP_MIXED: |
| 3214 | case AP_WPA_EAP: |
Jouni Malinen | ad395a2 | 2017-09-01 21:13:46 +0300 | [diff] [blame] | 3215 | case AP_SUITEB: |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3216 | /* Not supported */ |
| 3217 | break; |
| 3218 | } |
| 3219 | |
| 3220 | switch (dut->ap_pmf) { |
| 3221 | case AP_PMF_DISABLED: |
| 3222 | run_ndc(dut, "ndc softap qccmd set ieee80211w=0"); |
| 3223 | break; |
| 3224 | case AP_PMF_OPTIONAL: |
| 3225 | run_ndc(dut, "ndc softap qccmd set ieee80211w=1"); |
| 3226 | if (dut->ap_add_sha256) |
| 3227 | run_ndc(dut, "ndc softap qccmd set wpa_key_mgmt=WPA-PSK WPA-PSK-SHA256"); |
| 3228 | else |
| 3229 | run_ndc(dut, "ndc softap qccmd set wpa_key_mgmt=WPA-PSK"); |
| 3230 | break; |
| 3231 | case AP_PMF_REQUIRED: |
| 3232 | run_ndc(dut, "ndc softap qccmd set ieee80211w=2"); |
| 3233 | run_ndc(dut, "ndc softap qccmd set wpa_key_mgmt=WPA-PSK-SHA256"); |
| 3234 | break; |
| 3235 | } |
| 3236 | |
| 3237 | if (dut->ap_countrycode[0]) { |
| 3238 | snprintf(buf, sizeof(buf), |
| 3239 | "ndc softap qccmd set country_code=%s", |
| 3240 | dut->ap_countrycode); |
| 3241 | run_ndc(dut, buf); |
| 3242 | } |
| 3243 | |
Pradeep Reddy POTTETI | fba27db | 2015-11-20 16:42:22 +0530 | [diff] [blame] | 3244 | if (dut->ap_regulatory_mode == AP_80211D_MODE_ENABLED) |
| 3245 | run_ndc(dut, "ndc softap qccmd set ieee80211d=1"); |
| 3246 | |
| 3247 | if (dut->ap_dfs_mode == AP_DFS_MODE_ENABLED) |
| 3248 | run_ndc(dut, "ndc softap qccmd set ieee80211h=1"); |
| 3249 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3250 | run_ndc(dut, "ndc softap startap"); |
| 3251 | |
| 3252 | snprintf(buf, sizeof(buf), "%s%s", sigma_wpas_ctrl, sigma_main_ifname); |
| 3253 | num_tries = 0; |
| 3254 | while (num_tries < 10 && (ret = stat(buf, &s) != 0)) { |
| 3255 | run_ndc(dut, "ndc softap stopap"); |
| 3256 | run_ndc(dut, "ndc softap startap"); |
| 3257 | num_tries++; |
| 3258 | } |
| 3259 | |
| 3260 | if (num_tries == 10) { |
| 3261 | sigma_dut_print(dut, DUT_MSG_INFO, "Tried 10 times with ctrl " |
| 3262 | "iface %s :: reboot the APDUT", buf); |
| 3263 | return ret; |
| 3264 | } |
| 3265 | |
| 3266 | sigma_dut_print(dut, DUT_MSG_INFO, "setting ip addr %s mask %s", |
| 3267 | ap_inet_addr, ap_inet_mask); |
| 3268 | snprintf(buf, sizeof(buf), "ifconfig %s %s netmask %s up", |
| 3269 | sigma_main_ifname, ap_inet_addr, ap_inet_mask); |
| 3270 | if (system(buf) != 0) { |
| 3271 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 3272 | "Failed to intialize the interface"); |
| 3273 | return -1; |
| 3274 | } |
| 3275 | |
| 3276 | return 1; |
| 3277 | } |
| 3278 | |
| 3279 | |
| 3280 | static int append_hostapd_conf_hs2(struct sigma_dut *dut, FILE *f) |
| 3281 | { |
| 3282 | fprintf(f, "hs20=1\nhs20_deauth_req_timeout=3\n" |
| 3283 | "disable_dgaf=%d\n", dut->ap_dgaf_disable); |
| 3284 | |
| 3285 | if (dut->ap_oper_name) { |
| 3286 | fprintf(f, "hs20_oper_friendly_name=eng:Wi-Fi Alliance\n"); |
| 3287 | fprintf(f, "hs20_oper_friendly_name=chi:Wi-Fi\xe8\x81\x94\xe7\x9b\x9f\n"); |
| 3288 | } |
| 3289 | |
| 3290 | if (dut->ap_wan_metrics == 1) |
| 3291 | fprintf(f, "hs20_wan_metrics=01:2500:384:0:0:10\n"); |
| 3292 | else if (dut->ap_wan_metrics == 2) |
| 3293 | fprintf(f, "hs20_wan_metrics=01:1500:384:20:20:10\n"); |
| 3294 | else if (dut->ap_wan_metrics == 3) |
| 3295 | fprintf(f, "hs20_wan_metrics=01:2000:1000:20:20:10\n"); |
| 3296 | else if (dut->ap_wan_metrics == 4) |
| 3297 | fprintf(f, "hs20_wan_metrics=01:8000:1000:20:20:10\n"); |
| 3298 | else if (dut->ap_wan_metrics == 5) |
| 3299 | fprintf(f, "hs20_wan_metrics=01:9000:5000:20:20:10\n"); |
| 3300 | |
| 3301 | if (dut->ap_conn_capab == 1) { |
| 3302 | fprintf(f, "hs20_conn_capab=1:0:0\n"); |
| 3303 | fprintf(f, "hs20_conn_capab=6:20:1\n"); |
| 3304 | fprintf(f, "hs20_conn_capab=6:22:0\n"); |
| 3305 | fprintf(f, "hs20_conn_capab=6:80:1\n"); |
| 3306 | fprintf(f, "hs20_conn_capab=6:443:1\n"); |
| 3307 | fprintf(f, "hs20_conn_capab=6:1723:0\n"); |
| 3308 | fprintf(f, "hs20_conn_capab=6:5060:0\n"); |
| 3309 | fprintf(f, "hs20_conn_capab=17:500:1\n"); |
| 3310 | fprintf(f, "hs20_conn_capab=17:5060:0\n"); |
| 3311 | fprintf(f, "hs20_conn_capab=17:4500:1\n"); |
| 3312 | fprintf(f, "hs20_conn_capab=50:0:1\n"); |
| 3313 | } else if (dut->ap_conn_capab == 2) { |
| 3314 | fprintf(f, "hs20_conn_capab=6:80:1\n"); |
| 3315 | fprintf(f, "hs20_conn_capab=6:443:1\n"); |
| 3316 | fprintf(f, "hs20_conn_capab=17:5060:1\n"); |
| 3317 | fprintf(f, "hs20_conn_capab=6:5060:1\n"); |
| 3318 | } else if (dut->ap_conn_capab == 3) { |
| 3319 | fprintf(f, "hs20_conn_capab=6:80:1\n"); |
| 3320 | fprintf(f, "hs20_conn_capab=6:443:1\n"); |
| 3321 | } else if (dut->ap_conn_capab == 4) { |
| 3322 | fprintf(f, "hs20_conn_capab=6:80:1\n"); |
| 3323 | fprintf(f, "hs20_conn_capab=6:443:1\n"); |
| 3324 | fprintf(f, "hs20_conn_capab=6:5060:1\n"); |
| 3325 | fprintf(f, "hs20_conn_capab=17:5060:1\n"); |
| 3326 | } |
| 3327 | |
| 3328 | if (dut->ap_oper_class == 1) |
| 3329 | fprintf(f, "hs20_operating_class=51\n"); |
| 3330 | else if (dut->ap_oper_class == 2) |
| 3331 | fprintf(f, "hs20_operating_class=73\n"); |
| 3332 | else if (dut->ap_oper_class == 3) |
| 3333 | fprintf(f, "hs20_operating_class=5173\n"); |
| 3334 | |
| 3335 | if (dut->ap_osu_provider_list) { |
| 3336 | char *osu_friendly_name = NULL; |
| 3337 | char *osu_icon = NULL; |
| 3338 | char *osu_ssid = NULL; |
| 3339 | char *osu_nai = NULL; |
| 3340 | char *osu_service_desc = NULL; |
| 3341 | char *hs20_icon_filename = NULL; |
| 3342 | char hs20_icon[150]; |
| 3343 | int osu_method; |
| 3344 | |
| 3345 | hs20_icon_filename = "icon_red_zxx.png"; |
| 3346 | if (dut->ap_osu_icon_tag == 2) |
| 3347 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 3348 | snprintf(hs20_icon, sizeof(hs20_icon), |
| 3349 | "128:61:zxx:image/png:icon_red_zxx.png:/etc/ath/%s", |
| 3350 | hs20_icon_filename); |
| 3351 | osu_icon = "icon_red_zxx.png"; |
| 3352 | osu_ssid = "OSU"; |
| 3353 | osu_friendly_name = "kor:SP 빨강 테스트 전용"; |
| 3354 | osu_service_desc = "kor:테스트 목적으로 무료 서비스"; |
| 3355 | osu_method = (dut->ap_osu_method[0] == 0xFF) ? 1 : dut->ap_osu_method[0]; |
| 3356 | |
| 3357 | if (strlen(dut->ap_osu_server_uri[0])) |
| 3358 | fprintf(f, "osu_server_uri=%s\n", dut->ap_osu_server_uri[0]); |
| 3359 | else |
| 3360 | fprintf(f, "osu_server_uri=https://osu-server.r2-testbed.wi-fi.org/\n"); |
| 3361 | |
| 3362 | switch (dut->ap_osu_provider_list) { |
| 3363 | case 1: |
| 3364 | case 101: |
| 3365 | fprintf(f, "osu_friendly_name=eng:SP Red Test Only\n"); |
| 3366 | fprintf(f, "osu_service_desc=eng:Free service for test purpose\n"); |
| 3367 | hs20_icon_filename = "icon_red_eng.png"; |
| 3368 | if (dut->ap_osu_icon_tag == 2) |
| 3369 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 3370 | fprintf(f, "hs20_icon=160:76:eng:image/png:icon_red_eng.png:/etc/ath/%s\n", |
| 3371 | hs20_icon_filename); |
| 3372 | fprintf(f, "osu_icon=icon_red_eng.png\n"); |
| 3373 | break; |
| 3374 | case 2: |
| 3375 | case 102: |
| 3376 | fprintf(f, "osu_friendly_name=eng:Wireless Broadband Alliance\n"); |
| 3377 | fprintf(f, "osu_service_desc=eng:Free service for test purpose\n"); |
| 3378 | hs20_icon_filename = "icon_orange_zxx.png"; |
| 3379 | if (dut->ap_osu_icon_tag == 2) |
| 3380 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 3381 | snprintf(hs20_icon, sizeof(hs20_icon), |
| 3382 | "128:61:zxx:image/png:icon_orange_zxx.png:/etc/ath/%s", |
| 3383 | hs20_icon_filename); |
| 3384 | osu_icon = "icon_orange_zxx.png"; |
| 3385 | osu_friendly_name = "kor:와이어리스 브로드밴드 얼라이언스"; |
| 3386 | break; |
| 3387 | case 3: |
| 3388 | case 103: |
| 3389 | osu_friendly_name = "spa:SP Red Test Only"; |
| 3390 | osu_service_desc = "spa:Free service for test purpose"; |
| 3391 | break; |
| 3392 | case 4: |
| 3393 | case 104: |
| 3394 | fprintf(f, "osu_friendly_name=eng:SP Orange Test Only\n"); |
| 3395 | fprintf(f, "osu_service_desc=eng:Free service for test purpose\n"); |
| 3396 | hs20_icon_filename = "icon_orange_eng.png"; |
| 3397 | if (dut->ap_osu_icon_tag == 2) |
| 3398 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 3399 | fprintf(f, "hs20_icon=160:76:eng:image/png:icon_orange_eng.png:/etc/ath/%s\n", |
| 3400 | hs20_icon_filename); |
| 3401 | fprintf(f, "osu_icon=icon_orange_eng.png\n"); |
| 3402 | osu_friendly_name = "kor:SP 오렌지 테스트 전용"; |
| 3403 | |
| 3404 | hs20_icon_filename = "icon_orange_zxx.png"; |
| 3405 | if (dut->ap_osu_icon_tag == 2) |
| 3406 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 3407 | snprintf(hs20_icon, sizeof(hs20_icon), |
| 3408 | "128:61:zxx:image/png:icon_orange_zxx.png:/etc/ath/%s", |
| 3409 | hs20_icon_filename); |
| 3410 | osu_icon = "icon_orange_zxx.png"; |
| 3411 | break; |
| 3412 | case 5: |
| 3413 | case 105: |
| 3414 | fprintf(f, "osu_friendly_name=eng:SP Orange Test Only\n"); |
| 3415 | fprintf(f, "osu_service_desc=eng:Free service for test purpose\n"); |
| 3416 | osu_friendly_name = "kor:SP 오렌지 테스트 전용"; |
| 3417 | hs20_icon_filename = "icon_orange_zxx.png"; |
| 3418 | if (dut->ap_osu_icon_tag == 2) |
| 3419 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 3420 | snprintf(hs20_icon, sizeof(hs20_icon), |
| 3421 | "128:61:zxx:image/png:icon_orange_zxx.png:/etc/ath/%s", |
| 3422 | hs20_icon_filename); |
| 3423 | osu_icon = "icon_orange_zxx.png"; |
| 3424 | break; |
| 3425 | case 6: |
| 3426 | case 106: |
| 3427 | fprintf(f, "osu_friendly_name=eng:SP Green Test Only\n"); |
| 3428 | fprintf(f, "osu_friendly_name=kor:SP 초록 테스트 전용\n"); |
| 3429 | hs20_icon_filename = "icon_green_zxx.png"; |
| 3430 | if (dut->ap_osu_icon_tag == 2) |
| 3431 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 3432 | fprintf(f, "hs20_icon=128:61:zxx:image/png:icon_green_zxx.png:/etc/ath/%s\n", |
| 3433 | hs20_icon_filename); |
| 3434 | fprintf(f, "osu_icon=icon_green_zxx.png\n"); |
| 3435 | osu_method = (dut->ap_osu_method[0] == 0xFF) ? 0 : dut->ap_osu_method[0]; |
| 3436 | fprintf(f, "osu_method_list=%d\n", osu_method); |
| 3437 | |
| 3438 | if (strlen(dut->ap_osu_server_uri[1])) |
| 3439 | fprintf(f, "osu_server_uri=%s\n", dut->ap_osu_server_uri[1]); |
| 3440 | else |
| 3441 | fprintf(f, "osu_server_uri=https://osu-server.r2-testbed.wi-fi.org/\n"); |
| 3442 | fprintf(f, "osu_friendly_name=eng:SP Orange Test Only\n"); |
| 3443 | hs20_icon_filename = "icon_orange_zxx.png"; |
| 3444 | if (dut->ap_osu_icon_tag == 2) |
| 3445 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 3446 | snprintf(hs20_icon, sizeof(hs20_icon), |
| 3447 | "128:61:zxx:image/png:icon_orange_zxx.png:/etc/ath/%s", |
| 3448 | hs20_icon_filename); |
| 3449 | osu_icon = "icon_orange_zxx.png"; |
| 3450 | osu_friendly_name = "kor:SP 오렌지 테스트 전용"; |
| 3451 | osu_method = (dut->ap_osu_method[1] == 0xFF) ? 0 : dut->ap_osu_method[1]; |
| 3452 | osu_service_desc = NULL; |
| 3453 | break; |
| 3454 | case 7: |
| 3455 | case 107: |
| 3456 | fprintf(f, "osu_friendly_name=eng:SP Green Test Only\n"); |
| 3457 | fprintf(f, "osu_service_desc=eng:Free service for test purpose\n"); |
| 3458 | hs20_icon_filename = "icon_green_eng.png"; |
| 3459 | if (dut->ap_osu_icon_tag == 2) |
| 3460 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 3461 | fprintf(f, "hs20_icon=160:76:eng:image/png:icon_green_eng.png:/etc/ath/%s\n", |
| 3462 | hs20_icon_filename); |
| 3463 | fprintf(f, "osu_icon=icon_green_eng.png\n"); |
| 3464 | osu_friendly_name = "kor:SP 초록 테스트 전용"; |
| 3465 | |
| 3466 | hs20_icon_filename = "icon_green_zxx.png"; |
| 3467 | if (dut->ap_osu_icon_tag == 2) |
| 3468 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 3469 | snprintf(hs20_icon, sizeof(hs20_icon), |
| 3470 | "128:61:zxx:image/png:icon_green_zxx.png:/etc/ath/%s", |
| 3471 | hs20_icon_filename); |
| 3472 | osu_icon = "icon_green_zxx.png"; |
| 3473 | break; |
| 3474 | case 8: |
| 3475 | case 108: |
| 3476 | fprintf(f, "osu_friendly_name=eng:SP Red Test Only\n"); |
| 3477 | fprintf(f, "osu_service_desc=eng:Free service for test purpose\n"); |
| 3478 | osu_ssid = "OSU-Encrypted"; |
| 3479 | osu_nai = "anonymous@hotspot.net"; |
| 3480 | break; |
| 3481 | case 9: |
| 3482 | case 109: |
| 3483 | osu_ssid = "OSU-OSEN"; |
| 3484 | osu_nai = "test-anonymous@wi-fi.org"; |
| 3485 | osu_friendly_name = "eng:SP Orange Test Only"; |
| 3486 | hs20_icon_filename = "icon_orange_zxx.png"; |
| 3487 | if (dut->ap_osu_icon_tag == 2) |
| 3488 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 3489 | snprintf(hs20_icon, sizeof(hs20_icon), |
| 3490 | "128:61:zxx:image/png:icon_orange_zxx.png:/etc/ath/%s", |
| 3491 | hs20_icon_filename); |
| 3492 | osu_icon = "icon_orange_zxx.png"; |
| 3493 | osu_method = (dut->ap_osu_method[0] == 0xFF) ? 1 : dut->ap_osu_method[0]; |
| 3494 | osu_service_desc = NULL; |
| 3495 | break; |
| 3496 | default: |
| 3497 | break; |
| 3498 | } |
| 3499 | |
| 3500 | if (strlen(dut->ap_osu_ssid)) { |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 3501 | if (strcmp(dut->ap_tag_ssid[0], dut->ap_osu_ssid) && |
| 3502 | strcmp(dut->ap_tag_ssid[0], osu_ssid)) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3503 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 3504 | "OSU_SSID and " |
| 3505 | "WLAN_TAG2 SSID differ"); |
| 3506 | return -2; |
| 3507 | } |
| 3508 | fprintf(f, "osu_ssid=\"%s\"\n", dut->ap_osu_ssid); |
| 3509 | } else |
| 3510 | fprintf(f, "osu_ssid=\"%s\"\n", osu_ssid); |
| 3511 | |
| 3512 | |
| 3513 | if (osu_friendly_name) |
| 3514 | fprintf(f, "osu_friendly_name=%s\n", osu_friendly_name); |
| 3515 | |
| 3516 | if (osu_service_desc) |
| 3517 | fprintf(f, "osu_service_desc=%s\n", osu_service_desc); |
| 3518 | |
| 3519 | if (osu_nai) |
| 3520 | fprintf(f, "osu_nai=%s\n", osu_nai); |
| 3521 | |
| 3522 | fprintf(f, "hs20_icon=%s\n", hs20_icon); |
| 3523 | |
| 3524 | if (osu_icon) |
| 3525 | fprintf(f, "osu_icon=%s\n", osu_icon); |
| 3526 | |
| 3527 | if (dut->ap_osu_provider_list > 100) |
| 3528 | fprintf(f, "osu_method_list=0\n"); |
| 3529 | else |
| 3530 | fprintf(f, "osu_method_list=%d\n", osu_method); |
| 3531 | } |
| 3532 | |
| 3533 | return 0; |
| 3534 | } |
| 3535 | |
| 3536 | |
| 3537 | static void write_ap_roaming_cons(FILE *f, const char *list) |
| 3538 | { |
| 3539 | char *buf, *pos, *end; |
| 3540 | |
| 3541 | if (list == NULL || list[0] == '\0') |
| 3542 | return; |
| 3543 | |
| 3544 | buf = strdup(list); |
| 3545 | if (buf == NULL) |
| 3546 | return; |
| 3547 | |
| 3548 | pos = buf; |
| 3549 | while (pos && *pos) { |
| 3550 | end = strchr(pos, ';'); |
| 3551 | if (end) |
| 3552 | *end++ = '\0'; |
| 3553 | fprintf(f, "roaming_consortium=%s\n", pos); |
| 3554 | pos = end; |
| 3555 | } |
| 3556 | |
| 3557 | free(buf); |
| 3558 | } |
| 3559 | |
| 3560 | |
| 3561 | static int append_hostapd_conf_interworking(struct sigma_dut *dut, FILE *f) |
| 3562 | { |
| 3563 | int i; |
| 3564 | char buf[100], *temp; |
| 3565 | |
| 3566 | if (dut->ap_gas_cb_delay > 0) |
| 3567 | fprintf(f, "gas_comeback_delay=%d\n", |
| 3568 | dut->ap_gas_cb_delay); |
| 3569 | |
| 3570 | fprintf(f, "interworking=1\n" |
| 3571 | "access_network_type=%d\n" |
| 3572 | "internet=%d\n" |
| 3573 | "asra=0\n" |
| 3574 | "esr=0\n" |
| 3575 | "uesa=0\n" |
| 3576 | "venue_group=%d\n" |
| 3577 | "venue_type=%d\n", |
| 3578 | dut->ap_access_net_type, |
| 3579 | dut->ap_internet, |
| 3580 | dut->ap_venue_group, |
| 3581 | dut->ap_venue_type); |
| 3582 | if (dut->ap_hessid[0]) |
| 3583 | fprintf(f, "hessid=%s\n", dut->ap_hessid); |
| 3584 | |
| 3585 | write_ap_roaming_cons(f, dut->ap_roaming_cons); |
| 3586 | |
| 3587 | if (dut->ap_venue_name) { |
| 3588 | fprintf(f, "venue_name=P\"eng:Wi-Fi Alliance\\n2989 Copper Road\\nSanta Clara, CA 95051, USA\"\n"); |
| 3589 | fprintf(f, "venue_name=%s\n", ANQP_VENUE_NAME_1_CHI); |
| 3590 | } |
| 3591 | |
| 3592 | if (dut->ap_net_auth_type == 1) |
| 3593 | fprintf(f, "network_auth_type=00https://tandc-server.wi-fi.org\n"); |
| 3594 | else if (dut->ap_net_auth_type == 2) |
| 3595 | fprintf(f, "network_auth_type=01\n"); |
| 3596 | |
| 3597 | if (dut->ap_nai_realm_list == 1) { |
| 3598 | fprintf(f, "nai_realm=0,mail.example.com;cisco.com;wi-fi.org,21[2:4][5:7]\n"); |
| 3599 | fprintf(f, "nai_realm=0,wi-fi.org;example.com,13[5:6]\n"); |
| 3600 | } else if (dut->ap_nai_realm_list == 2) { |
| 3601 | fprintf(f, "nai_realm=0,wi-fi.org,21[2:4][5:7]\n"); |
| 3602 | } else if (dut->ap_nai_realm_list == 3) { |
| 3603 | fprintf(f, "nai_realm=0,cisco.com;wi-fi.org,21[2:4][5:7]\n"); |
| 3604 | fprintf(f, "nai_realm=0,wi-fi.org;example.com,13[5:6]\n"); |
| 3605 | } else if (dut->ap_nai_realm_list == 4) { |
| 3606 | fprintf(f, "nai_realm=0,mail.example.com,21[2:4][5:7],13[5:6]\n"); |
| 3607 | } else if (dut->ap_nai_realm_list == 5) { |
| 3608 | fprintf(f, "nai_realm=0,wi-fi.org;ruckuswireless.com,21[2:4][5:7]\n"); |
| 3609 | } else if (dut->ap_nai_realm_list == 6) { |
| 3610 | fprintf(f, "nai_realm=0,wi-fi.org;mail.example.com,21[2:4][5:7]\n"); |
| 3611 | } else if (dut->ap_nai_realm_list == 7) { |
| 3612 | fprintf(f, "nai_realm=0,wi-fi.org,13[5:6]\n"); |
| 3613 | fprintf(f, "nai_realm=0,wi-fi.org,21[2:4][5:7]\n"); |
| 3614 | } |
| 3615 | |
| 3616 | if (dut->ap_domain_name_list[0]) { |
| 3617 | fprintf(f, "domain_name=%s\n", |
| 3618 | dut->ap_domain_name_list); |
| 3619 | } |
| 3620 | |
| 3621 | if (dut->ap_ip_addr_type_avail == 1) { |
| 3622 | fprintf(f, "ipaddr_type_availability=0c\n"); |
| 3623 | } |
| 3624 | |
| 3625 | temp = buf; |
| 3626 | for (i = 0; dut->ap_plmn_mcc[i][0] && dut->ap_plmn_mnc[i][0]; |
| 3627 | i++) { |
| 3628 | if (i) |
| 3629 | *temp++ = ';'; |
| 3630 | |
| 3631 | snprintf(temp, |
| 3632 | sizeof(dut->ap_plmn_mcc[i]) + |
| 3633 | sizeof(dut->ap_plmn_mnc[i]) + 1, |
| 3634 | "%s,%s", |
| 3635 | dut->ap_plmn_mcc[i], |
| 3636 | dut->ap_plmn_mnc[i]); |
| 3637 | |
| 3638 | temp += strlen(dut->ap_plmn_mcc[i]) + |
| 3639 | strlen(dut->ap_plmn_mnc[i]) + 1; |
| 3640 | } |
| 3641 | if (i) |
| 3642 | fprintf(f, "anqp_3gpp_cell_net=%s\n", buf); |
| 3643 | |
| 3644 | if (dut->ap_qos_map_set == 1) |
| 3645 | fprintf(f, "qos_map_set=%s\n", QOS_MAP_SET_1); |
| 3646 | else if (dut->ap_qos_map_set == 2) |
| 3647 | fprintf(f, "qos_map_set=%s\n", QOS_MAP_SET_2); |
| 3648 | |
| 3649 | return 0; |
| 3650 | } |
| 3651 | |
| 3652 | |
| 3653 | static int ath_ap_append_hostapd_conf(struct sigma_dut *dut) |
| 3654 | { |
| 3655 | FILE *f; |
| 3656 | |
| 3657 | if (kill_process(dut, "(hostapd)", 1, SIGTERM) == 0 || |
| 3658 | system("killall hostapd") == 0) { |
| 3659 | int i; |
| 3660 | |
| 3661 | /* Wait some time to allow hostapd to complete cleanup before |
| 3662 | * starting a new process */ |
| 3663 | for (i = 0; i < 10; i++) { |
| 3664 | usleep(500000); |
| 3665 | if (system("pidof hostapd") != 0) |
| 3666 | break; |
| 3667 | } |
| 3668 | } |
| 3669 | |
| 3670 | f = fopen("/tmp/secath0", "a"); |
| 3671 | if (f == NULL) |
| 3672 | return -2; |
| 3673 | |
| 3674 | if (dut->ap_hs2 && append_hostapd_conf_hs2(dut, f)) { |
| 3675 | fclose(f); |
| 3676 | return -2; |
| 3677 | } |
| 3678 | |
| 3679 | if (dut->ap_interworking && append_hostapd_conf_interworking(dut, f)) { |
| 3680 | fclose(f); |
| 3681 | return -2; |
| 3682 | } |
| 3683 | |
| 3684 | fflush(f); |
| 3685 | fclose(f); |
| 3686 | return ath_ap_start_hostapd(dut); |
| 3687 | } |
| 3688 | |
| 3689 | |
| 3690 | static int ath_ap_start_hostapd(struct sigma_dut *dut) |
| 3691 | { |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 3692 | if (dut->ap_tag_key_mgmt[0] == AP2_OSEN) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3693 | run_system(dut, "hostapd -B /tmp/secath0 /tmp/secath1 -e /etc/wpa2/entropy"); |
| 3694 | else |
| 3695 | run_system(dut, "hostapd -B /tmp/secath0 -e /etc/wpa2/entropy"); |
| 3696 | |
| 3697 | return 0; |
| 3698 | } |
| 3699 | |
| 3700 | |
| 3701 | #define LE16(a) ((((a) & 0xff) << 8) | (((a) >> 8) & 0xff)) |
| 3702 | |
| 3703 | static int cmd_ath_ap_anqpserver_start(struct sigma_dut *dut) |
| 3704 | { |
| 3705 | FILE *f; |
| 3706 | int nai_realm = 0, domain_name = 0, oper_name = 0, venue_name = 0, |
| 3707 | wan_metrics = 0, conn_cap = 0, ipaddr_avail = 0, cell_net = 0; |
| 3708 | char buf[100]; |
| 3709 | int i; |
| 3710 | |
| 3711 | f = fopen("/root/anqpserver.conf", "w"); |
| 3712 | if (f == NULL) |
| 3713 | return -1; |
| 3714 | |
| 3715 | if (dut->ap_nai_realm_list == 1) { |
| 3716 | nai_realm = 1; |
| 3717 | 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"); |
| 3718 | } else if (dut->ap_nai_realm_list == 2) { |
| 3719 | nai_realm = 1; |
| 3720 | fprintf(f, "dyn_nai_home_realm=encoding=00realm=wi-fi.org;eap_method=0Dauth_id=05auth_val=06\n"); |
| 3721 | } else if (dut->ap_nai_realm_list == 3) { |
| 3722 | nai_realm = 1; |
| 3723 | 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"); |
| 3724 | } else if (dut->ap_nai_realm_list == 4) { |
| 3725 | nai_realm = 1; |
| 3726 | 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"); |
| 3727 | } else |
| 3728 | sigma_dut_print(dut, DUT_MSG_INFO, "not setting nai_realm"); |
| 3729 | |
| 3730 | if (dut->ap_domain_name_list[0]) { |
| 3731 | char *next, *start, *dnbuf, *dn1, *anqp_dn; |
| 3732 | int len, dn_len_max; |
| 3733 | dnbuf = strdup(dut->ap_domain_name_list); |
Pradeep Reddy POTTETI | 673d85c | 2016-07-26 19:08:07 +0530 | [diff] [blame] | 3734 | if (dnbuf == NULL) { |
| 3735 | fclose(f); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3736 | return 0; |
Pradeep Reddy POTTETI | 673d85c | 2016-07-26 19:08:07 +0530 | [diff] [blame] | 3737 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3738 | |
| 3739 | len = strlen(dnbuf); |
| 3740 | dn_len_max = 50 + len*2; |
| 3741 | anqp_dn = malloc(dn_len_max); |
| 3742 | if (anqp_dn == NULL) { |
| 3743 | free(dnbuf); |
Pradeep Reddy POTTETI | 673d85c | 2016-07-26 19:08:07 +0530 | [diff] [blame] | 3744 | fclose(f); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3745 | return -1; |
| 3746 | } |
| 3747 | start = dnbuf; |
| 3748 | dn1 = anqp_dn; |
| 3749 | while (start && *start) { |
| 3750 | char *hexstr; |
| 3751 | |
| 3752 | next = strchr(start, ','); |
| 3753 | if (next) |
| 3754 | *next++ = '\0'; |
| 3755 | |
| 3756 | len = strlen(start); |
vamsi krishna | 2e88130 | 2016-05-25 15:02:39 +0530 | [diff] [blame] | 3757 | hexstr = malloc(len * 2 + 1); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3758 | if (hexstr == NULL) { |
| 3759 | free(dnbuf); |
| 3760 | free(anqp_dn); |
Pradeep Reddy POTTETI | 673d85c | 2016-07-26 19:08:07 +0530 | [diff] [blame] | 3761 | fclose(f); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3762 | return -1; |
| 3763 | } |
| 3764 | ascii2hexstr(start, hexstr); |
| 3765 | snprintf(dn1, dn_len_max, "%02x%s", len, hexstr); |
| 3766 | free(hexstr); |
| 3767 | dn1 += 2 + len * 2; |
| 3768 | dn_len_max -= 2 + len * 2; |
| 3769 | start = next; |
| 3770 | } |
| 3771 | free(dnbuf); |
| 3772 | if (dut->ap_gas_cb_delay) { |
| 3773 | fprintf(f, "dyn_domain_name=0c01%04x%s", |
| 3774 | LE16((unsigned int) strlen(anqp_dn)), anqp_dn); |
| 3775 | domain_name = 1; |
| 3776 | } else |
| 3777 | fprintf(f, "domain_name=0c01%04x%s", |
| 3778 | LE16((unsigned int) strlen(anqp_dn)), anqp_dn); |
| 3779 | free(anqp_dn); |
| 3780 | } else |
| 3781 | sigma_dut_print(dut, DUT_MSG_INFO, "not setting domain_name"); |
| 3782 | |
| 3783 | sigma_dut_print(dut, DUT_MSG_INFO, "not setting roaming_consortium"); |
| 3784 | |
| 3785 | if (dut->ap_oper_name) { |
| 3786 | if (dut->ap_gas_cb_delay) { |
| 3787 | fprintf(f, "dyn_oper_friendly_name=" |
| 3788 | ANQP_HS20_OPERATOR_FRIENDLY_NAME_1 "\n"); |
| 3789 | oper_name = 1; |
| 3790 | } else |
| 3791 | fprintf(f, "oper_friendly_name=" |
| 3792 | ANQP_HS20_OPERATOR_FRIENDLY_NAME_1 "\n"); |
| 3793 | } else |
| 3794 | sigma_dut_print(dut, DUT_MSG_INFO, "not setting oper_name"); |
| 3795 | |
| 3796 | if (dut->ap_venue_name) { |
| 3797 | if (dut->ap_gas_cb_delay) { |
| 3798 | fprintf(f, "dyn_venue_name=" ANQP_VENUE_NAME_1 "\n"); |
| 3799 | venue_name = 1; |
| 3800 | } else |
| 3801 | fprintf(f, "venue_name=" ANQP_VENUE_NAME_1 "\n"); |
| 3802 | } else |
| 3803 | sigma_dut_print(dut, DUT_MSG_ERROR, "not setting venue_name"); |
| 3804 | |
| 3805 | if (dut->ap_wan_metrics) { |
| 3806 | if (dut->ap_gas_cb_delay) { |
| 3807 | fprintf(f, "dyn_wan_metrics=" ANQP_HS20_WAN_METRICS_1 "\n"); |
| 3808 | wan_metrics = 1; |
| 3809 | } else |
| 3810 | fprintf(f, "wan_metrics=" ANQP_HS20_WAN_METRICS_1 |
| 3811 | "\n"); |
| 3812 | } else |
| 3813 | sigma_dut_print(dut, DUT_MSG_ERROR, "not setting wan_metrics"); |
| 3814 | |
| 3815 | if (dut->ap_conn_capab) { |
| 3816 | if (dut->ap_gas_cb_delay) { |
| 3817 | fprintf(f, "dyn_conn_capability=" |
| 3818 | ANQP_HS20_CONNECTION_CAPABILITY_1 "\n"); |
| 3819 | conn_cap = 1; |
| 3820 | } else |
| 3821 | fprintf(f, "conn_capability=" |
| 3822 | ANQP_HS20_CONNECTION_CAPABILITY_1 "\n"); |
| 3823 | } else |
| 3824 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 3825 | "not setting conn_capability"); |
| 3826 | |
| 3827 | if (dut->ap_ip_addr_type_avail) { |
| 3828 | if (dut->ap_gas_cb_delay) { |
| 3829 | fprintf(f, "dyn_ipaddr_type=" ANQP_IP_ADDR_TYPE_1 |
| 3830 | "\n"); |
| 3831 | ipaddr_avail = 1; |
| 3832 | } else |
| 3833 | fprintf(f, "ipaddr_type=" ANQP_IP_ADDR_TYPE_1 "\n"); |
| 3834 | } else |
| 3835 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 3836 | "not setting ipaddr_type_avail"); |
| 3837 | |
| 3838 | for (i = 0; dut->ap_plmn_mcc[i][0] && dut->ap_plmn_mnc[i][0]; i++) { |
| 3839 | snprintf(buf + i * 6, sizeof(buf) - i * 6, "%c%c%c%c%c%c", |
| 3840 | dut->ap_plmn_mcc[i][1], |
| 3841 | dut->ap_plmn_mcc[i][0], |
| 3842 | dut->ap_plmn_mnc[i][2] == '\0' ? |
| 3843 | 'f' : dut->ap_plmn_mnc[i][2], |
| 3844 | dut->ap_plmn_mcc[i][2], |
| 3845 | dut->ap_plmn_mnc[i][1], |
| 3846 | dut->ap_plmn_mnc[i][0]); |
| 3847 | } |
| 3848 | if (i) { |
| 3849 | uint16_t ie_len = (i * 3) + 5; |
| 3850 | if (dut->ap_gas_cb_delay) { |
| 3851 | fprintf(f, "dyn_cell_net=0801"); |
| 3852 | cell_net = 1; |
| 3853 | } else |
| 3854 | fprintf(f, "cell_net=0801"); |
| 3855 | fprintf(f, "%04x", LE16(ie_len)); |
| 3856 | fprintf(f, "00"); /* version */ |
| 3857 | fprintf(f, "%02x", (i * 3) + 3); /* user data hdr length */ |
| 3858 | fprintf(f, "00"); /* plmn list */ |
| 3859 | fprintf(f, "%02x", (i * 3) + 1); /* length of plmn list */ |
| 3860 | fprintf(f, "%02x", i); /* number of plmns */ |
| 3861 | fprintf(f, "%s\n", buf); /* plmns */ |
| 3862 | } else |
| 3863 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 3864 | "not setting 3gpp_cellular_network"); |
| 3865 | |
| 3866 | if (nai_realm || domain_name || oper_name || venue_name || |
| 3867 | wan_metrics || conn_cap || ipaddr_avail || cell_net) { |
| 3868 | fprintf(f, "anqp_attach="); |
| 3869 | if (venue_name) |
| 3870 | fprintf(f, "00000104%4.4x", dut->ap_gas_cb_delay); |
| 3871 | if (nai_realm) |
| 3872 | fprintf(f, "00000107%4.4x", dut->ap_gas_cb_delay); |
| 3873 | if (cell_net) |
| 3874 | fprintf(f, "00000108%4.4x", dut->ap_gas_cb_delay); |
| 3875 | if (domain_name) |
| 3876 | fprintf(f, "0000010c%4.4x", dut->ap_gas_cb_delay); |
| 3877 | if (oper_name) |
| 3878 | fprintf(f, "00010003%4.4x", dut->ap_gas_cb_delay); |
| 3879 | if (wan_metrics) |
| 3880 | fprintf(f, "00010004%4.4x", dut->ap_gas_cb_delay); |
| 3881 | if (conn_cap) |
| 3882 | fprintf(f, "00010005%4.4x", dut->ap_gas_cb_delay); |
| 3883 | fprintf(f, "00010006%4.4x", dut->ap_gas_cb_delay); |
| 3884 | fprintf(f, "\n"); |
| 3885 | } |
| 3886 | |
| 3887 | fclose(f); |
| 3888 | |
| 3889 | run_system(dut, "anqpserver -i ath0 &"); |
| 3890 | if (!dut->ap_anqpserver_on) |
| 3891 | run_system(dut, "killall anqpserver"); |
| 3892 | |
| 3893 | return 1; |
| 3894 | } |
| 3895 | |
| 3896 | |
| 3897 | static void cmd_ath_ap_radio_config(struct sigma_dut *dut) |
| 3898 | { |
| 3899 | char buf[100]; |
| 3900 | |
| 3901 | run_system(dut, "cfg -a AP_STARTMODE=standard"); |
| 3902 | |
| 3903 | if (sigma_radio_ifname[0] && |
| 3904 | strcmp(sigma_radio_ifname[0], "wifi1") == 0) { |
| 3905 | run_system(dut, "cfg -a AP_RADIO_ID=1"); |
| 3906 | switch (dut->ap_mode) { |
| 3907 | case AP_11g: |
| 3908 | run_system(dut, "cfg -a AP_CHMODE_2=11G"); |
| 3909 | break; |
| 3910 | case AP_11b: |
| 3911 | run_system(dut, "cfg -a AP_CHMODE_2=11B"); |
| 3912 | break; |
| 3913 | case AP_11ng: |
| 3914 | run_system(dut, "cfg -a AP_CHMODE_2=11NGHT20"); |
| 3915 | break; |
| 3916 | case AP_11a: |
| 3917 | run_system(dut, "cfg -a AP_CHMODE_2=11A"); |
| 3918 | break; |
| 3919 | case AP_11na: |
| 3920 | run_system(dut, "cfg -a AP_CHMODE_2=11NAHT20"); |
| 3921 | break; |
| 3922 | case AP_11ac: |
| 3923 | run_system(dut, "cfg -a AP_CHMODE_2=11ACVHT80"); |
| 3924 | break; |
| 3925 | default: |
| 3926 | run_system(dut, "cfg -a AP_CHMODE_2=11ACVHT80"); |
| 3927 | break; |
| 3928 | } |
| 3929 | |
| 3930 | switch (dut->ap_rx_streams) { |
| 3931 | case 1: |
| 3932 | run_system(dut, "cfg -a RX_CHAINMASK_2=1"); |
| 3933 | break; |
| 3934 | case 2: |
| 3935 | run_system(dut, "cfg -a RX_CHAINMASK_2=3"); |
| 3936 | break; |
| 3937 | case 3: |
| 3938 | run_system(dut, "cfg -a RX_CHAINMASK_2=7"); |
| 3939 | break; |
| 3940 | } |
| 3941 | |
| 3942 | switch (dut->ap_tx_streams) { |
| 3943 | case 1: |
| 3944 | run_system(dut, "cfg -a TX_CHAINMASK_2=1"); |
| 3945 | break; |
| 3946 | case 2: |
| 3947 | run_system(dut, "cfg -a TX_CHAINMASK_2=3"); |
| 3948 | break; |
| 3949 | case 3: |
| 3950 | run_system(dut, "cfg -a TX_CHAINMASK_2=7"); |
| 3951 | break; |
| 3952 | } |
| 3953 | |
| 3954 | switch (dut->ap_chwidth) { |
| 3955 | case AP_20: |
| 3956 | run_system(dut, "cfg -a AP_CHMODE_2=11ACVHT20"); |
| 3957 | break; |
| 3958 | case AP_40: |
| 3959 | run_system(dut, "cfg -a AP_CHMODE_2=11ACVHT40"); |
| 3960 | break; |
| 3961 | case AP_80: |
| 3962 | run_system(dut, "cfg -a AP_CHMODE_2=11ACVHT80"); |
| 3963 | break; |
| 3964 | case AP_160: |
| 3965 | case AP_AUTO: |
| 3966 | default: |
| 3967 | run_system(dut, "cfg -a AP_CHMODE_2=11ACVHT80"); |
| 3968 | break; |
| 3969 | } |
| 3970 | |
| 3971 | if (dut->ap_tx_stbc) { |
| 3972 | run_system(dut, "cfg -a TX_STBC_2=1"); |
| 3973 | } |
| 3974 | |
| 3975 | snprintf(buf, sizeof(buf), "cfg -a AP_PRIMARY_CH_2=%d", |
| 3976 | dut->ap_channel); |
| 3977 | |
| 3978 | if (dut->ap_is_dual) { |
| 3979 | switch (dut->ap_mode_1) { |
| 3980 | case AP_11g: |
| 3981 | run_system(dut, "cfg -a AP_CHMODE=11G"); |
| 3982 | break; |
| 3983 | case AP_11b: |
| 3984 | run_system(dut, "cfg -a AP_CHMODE=11B"); |
| 3985 | break; |
| 3986 | case AP_11ng: |
| 3987 | run_system(dut, "cfg -a AP_CHMODE=11NGHT20"); |
| 3988 | break; |
| 3989 | case AP_11a: |
| 3990 | run_system(dut, "cfg -a AP_CHMODE=11A"); |
| 3991 | break; |
| 3992 | case AP_11na: |
| 3993 | run_system(dut, "cfg -a AP_CHMODE=11NAHT20"); |
| 3994 | break; |
| 3995 | case AP_11ac: |
| 3996 | run_system(dut, "cfg -a AP_CHMODE=11ACVHT80"); |
| 3997 | break; |
| 3998 | default: |
| 3999 | run_system(dut, "cfg -a AP_CHMODE=11NGHT20"); |
| 4000 | break; |
| 4001 | } |
| 4002 | snprintf(buf, sizeof(buf), "cfg -a AP_PRIMARY_CH=%d", |
| 4003 | dut->ap_channel_1); |
| 4004 | } |
| 4005 | run_system(dut, buf); |
| 4006 | } else { |
| 4007 | run_system(dut, "cfg -a AP_RADIO_ID=0"); |
| 4008 | switch (dut->ap_mode) { |
| 4009 | case AP_11g: |
| 4010 | run_system(dut, "cfg -a AP_CHMODE=11G"); |
| 4011 | break; |
| 4012 | case AP_11b: |
| 4013 | run_system(dut, "cfg -a AP_CHMODE=11B"); |
| 4014 | break; |
| 4015 | case AP_11ng: |
| 4016 | run_system(dut, "cfg -a AP_CHMODE=11NGHT20"); |
| 4017 | break; |
| 4018 | case AP_11a: |
| 4019 | run_system(dut, "cfg -a AP_CHMODE=11A"); |
| 4020 | break; |
| 4021 | case AP_11na: |
| 4022 | run_system(dut, "cfg -a AP_CHMODE=11NAHT20"); |
| 4023 | break; |
| 4024 | case AP_11ac: |
| 4025 | run_system(dut, "cfg -a AP_CHMODE=11ACVHT80"); |
| 4026 | break; |
| 4027 | default: |
| 4028 | run_system(dut, "cfg -a AP_CHMODE=11NGHT20"); |
| 4029 | break; |
| 4030 | } |
| 4031 | snprintf(buf, sizeof(buf), "cfg -a AP_PRIMARY_CH=%d", |
| 4032 | dut->ap_channel); |
| 4033 | run_system(dut, buf); |
| 4034 | } |
| 4035 | |
| 4036 | if (dut->ap_sgi80 == 1) { |
| 4037 | run_system(dut, "cfg -a SHORTGI=1"); |
| 4038 | run_system(dut, "cfg -a SHORTGI_2=1"); |
| 4039 | } else if (dut->ap_sgi80 == 0) { |
| 4040 | run_system(dut, "cfg -a SHORTGI=0"); |
| 4041 | run_system(dut, "cfg -a SHORTGI_2=0"); |
| 4042 | } |
| 4043 | |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 4044 | if (dut->ap_ldpc == VALUE_ENABLED) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4045 | run_system(dut, "cfg -a LDPC=1"); |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 4046 | else if (dut->ap_ldpc == VALUE_DISABLED) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4047 | run_system(dut, "cfg -a LDPC=0"); |
| 4048 | } |
| 4049 | |
| 4050 | |
| 4051 | void ath_disable_txbf(struct sigma_dut *dut, const char *intf) |
| 4052 | { |
| 4053 | char buf[50]; |
| 4054 | |
| 4055 | snprintf(buf, sizeof(buf), "iwpriv %s vhtsubfee 0", intf); |
| 4056 | if (system(buf) != 0) |
| 4057 | sigma_dut_print(dut, DUT_MSG_ERROR, "iwpriv vhtsubfee failed"); |
| 4058 | |
| 4059 | snprintf(buf, sizeof(buf), "iwpriv %s vhtsubfer 0", intf); |
| 4060 | if (system(buf) != 0) |
| 4061 | sigma_dut_print(dut, DUT_MSG_ERROR, "iwpriv vhtsubfer failed"); |
| 4062 | |
| 4063 | snprintf(buf, sizeof(buf), "iwpriv %s vhtmubfee 0", intf); |
| 4064 | if (system(buf) != 0) |
| 4065 | sigma_dut_print(dut, DUT_MSG_ERROR, "iwpriv vhtmubfee failed"); |
| 4066 | |
| 4067 | snprintf(buf, sizeof(buf), "iwpriv %s vhtmubfer 0", intf); |
| 4068 | if (system(buf) != 0) |
| 4069 | sigma_dut_print(dut, DUT_MSG_ERROR, "iwpriv vhtmubfer failed"); |
| 4070 | } |
| 4071 | |
| 4072 | |
Adil Saeed Musthafa | 05ec744 | 2017-04-10 23:13:35 -0700 | [diff] [blame] | 4073 | static void ath_set_assoc_disallow(struct sigma_dut *dut, const char *ifname, |
| 4074 | const char *val) |
| 4075 | { |
| 4076 | if (strcasecmp(val, "enable") == 0) { |
| 4077 | run_system_wrapper(dut, "iwpriv %s mbo_asoc_dis 1", ifname); |
| 4078 | } else if (strcasecmp(val, "disable") == 0) { |
| 4079 | run_system_wrapper(dut, "iwpriv %s mbo_asoc_dis 0", ifname); |
| 4080 | } else { |
| 4081 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4082 | "Unsupported assoc_disallow"); |
| 4083 | } |
| 4084 | } |
| 4085 | |
| 4086 | |
Adil Saeed Musthafa | 6906372 | 2017-04-10 23:13:40 -0700 | [diff] [blame] | 4087 | static void apply_mbo_pref_ap_list(struct sigma_dut *dut) |
| 4088 | { |
| 4089 | int i; |
| 4090 | int least_pref = 1 << 8; |
| 4091 | char ifname[20]; |
| 4092 | uint8_t self_mac[ETH_ALEN]; |
| 4093 | char buf[200]; |
| 4094 | int ap_ne_class, ap_ne_pref, ap_ne_op_ch; |
| 4095 | |
| 4096 | get_if_name(dut, ifname, sizeof(ifname), 1); |
| 4097 | get_hwaddr(ifname, self_mac); |
| 4098 | |
| 4099 | /* Clear off */ |
| 4100 | snprintf(buf, sizeof(buf), |
| 4101 | "wifitool %s setbssidpref 00:00:00:00:00:00 0 0 0", |
| 4102 | ifname); |
| 4103 | run_system(dut, buf); |
| 4104 | |
| 4105 | /* Find the least preference number */ |
| 4106 | for (i = 0; i < dut->mbo_pref_ap_cnt; i++) { |
| 4107 | unsigned char *mac_addr = dut->mbo_pref_aps[i].mac_addr; |
| 4108 | |
| 4109 | ap_ne_class = 1; |
| 4110 | ap_ne_pref = 255; |
| 4111 | ap_ne_op_ch = 1; |
| 4112 | if (dut->mbo_pref_aps[i].ap_ne_pref != -1) |
| 4113 | ap_ne_pref = dut->mbo_pref_aps[i].ap_ne_pref; |
| 4114 | if (dut->mbo_pref_aps[i].ap_ne_class != -1) |
| 4115 | ap_ne_class = dut->mbo_pref_aps[i].ap_ne_class; |
| 4116 | if (dut->mbo_pref_aps[i].ap_ne_op_ch != -1) |
| 4117 | ap_ne_op_ch = dut->mbo_pref_aps[i].ap_ne_op_ch; |
| 4118 | |
| 4119 | if (ap_ne_pref < least_pref) |
| 4120 | least_pref = ap_ne_pref; |
| 4121 | snprintf(buf, sizeof(buf), |
| 4122 | "wifitool %s setbssidpref %02x:%02x:%02x:%02x:%02x:%02x %d %d %d", |
| 4123 | ifname, mac_addr[0], mac_addr[1], mac_addr[2], |
| 4124 | mac_addr[3], mac_addr[4], mac_addr[5], |
| 4125 | ap_ne_pref, ap_ne_class, ap_ne_op_ch); |
| 4126 | run_system(dut, buf); |
| 4127 | } |
| 4128 | |
| 4129 | /* Now add the self AP Address */ |
| 4130 | if (dut->mbo_self_ap_tuple.ap_ne_class == -1) { |
| 4131 | if (dut->ap_channel <= 11) |
| 4132 | ap_ne_class = 81; |
| 4133 | else |
| 4134 | ap_ne_class = 115; |
| 4135 | } else { |
| 4136 | ap_ne_class = dut->mbo_self_ap_tuple.ap_ne_class; |
| 4137 | } |
| 4138 | |
| 4139 | if (dut->mbo_self_ap_tuple.ap_ne_op_ch == -1) |
| 4140 | ap_ne_op_ch = dut->ap_channel; |
| 4141 | else |
| 4142 | ap_ne_op_ch = dut->mbo_self_ap_tuple.ap_ne_op_ch; |
| 4143 | |
| 4144 | if (dut->mbo_self_ap_tuple.ap_ne_pref == -1) |
| 4145 | ap_ne_pref = least_pref - 1; |
| 4146 | else |
| 4147 | ap_ne_pref = dut->mbo_self_ap_tuple.ap_ne_pref; |
| 4148 | |
| 4149 | snprintf(buf, sizeof(buf), |
| 4150 | "wifitool %s setbssidpref %02x:%02x:%02x:%02x:%02x:%02x %d %d %d", |
| 4151 | ifname, self_mac[0], self_mac[1], self_mac[2], |
| 4152 | self_mac[3], self_mac[4], self_mac[5], |
| 4153 | ap_ne_pref, |
| 4154 | ap_ne_class, |
| 4155 | ap_ne_op_ch); |
| 4156 | run_system(dut, buf); |
| 4157 | } |
| 4158 | |
| 4159 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4160 | static void ath_ap_set_params(struct sigma_dut *dut) |
| 4161 | { |
| 4162 | const char *basedev = "wifi1"; |
priyadharshini gowthaman | e161746 | 2017-04-25 12:03:59 -0700 | [diff] [blame] | 4163 | const char *ifname = get_main_ifname(); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4164 | int i; |
priyadharshini gowthaman | 8e26ff4 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 4165 | char buf[300]; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4166 | |
priyadharshini gowthaman | e161746 | 2017-04-25 12:03:59 -0700 | [diff] [blame] | 4167 | if (sigma_radio_ifname[0]) |
| 4168 | basedev = sigma_radio_ifname[0]; |
| 4169 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4170 | if (dut->ap_countrycode[0]) { |
| 4171 | snprintf(buf, sizeof(buf), "iwpriv %s setCountry %s", |
| 4172 | basedev, dut->ap_countrycode); |
| 4173 | if (system(buf) != 0) { |
| 4174 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4175 | "iwpriv setCountry failed"); |
| 4176 | } |
| 4177 | sigma_dut_print(dut, DUT_MSG_INFO, "Set countrycode"); |
| 4178 | } |
| 4179 | |
| 4180 | for (i = 0; i < NUM_AP_AC; i++) { |
| 4181 | if (dut->ap_qos[i].ac) { |
| 4182 | snprintf(buf, sizeof(buf), "iwpriv %s cwmin %d 0 %d", |
| 4183 | ifname, i, dut->ap_qos[i].cwmin); |
| 4184 | if (system(buf) != 0) { |
| 4185 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4186 | "iwpriv cwmin failed"); |
| 4187 | } |
| 4188 | |
| 4189 | snprintf(buf, sizeof(buf), "iwpriv %s cwmax %d 0 %d", |
| 4190 | ifname, i, dut->ap_qos[i].cwmax); |
| 4191 | if (system(buf) != 0) { |
| 4192 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4193 | "iwpriv cwmax failed"); |
| 4194 | } |
| 4195 | |
| 4196 | snprintf(buf, sizeof(buf), "iwpriv %s aifs %d 0 %d", |
| 4197 | ifname, i, dut->ap_qos[i].aifs); |
| 4198 | if (system(buf) != 0) { |
| 4199 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4200 | "iwpriv aifs failed"); |
| 4201 | } |
| 4202 | |
| 4203 | snprintf(buf, sizeof(buf), |
| 4204 | "iwpriv %s txoplimit %d 0 %d", |
| 4205 | ifname, i, dut->ap_qos[i].txop); |
| 4206 | if (system(buf) != 0) { |
| 4207 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4208 | "iwpriv txoplimit failed"); |
| 4209 | } |
| 4210 | |
| 4211 | snprintf(buf, sizeof(buf), "iwpriv %s acm %d 0 %d", |
| 4212 | ifname, i, dut->ap_qos[i].acm); |
| 4213 | if (system(buf) != 0) { |
| 4214 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4215 | "iwpriv acm failed"); |
| 4216 | } |
| 4217 | } |
| 4218 | } |
| 4219 | |
| 4220 | for (i = 0; i < NUM_AP_AC; i++) { |
| 4221 | if (dut->ap_sta_qos[i].ac) { |
| 4222 | snprintf(buf, sizeof(buf), "iwpriv %s cwmin %d 1 %d", |
| 4223 | ifname, i, dut->ap_sta_qos[i].cwmin); |
| 4224 | if (system(buf) != 0) { |
| 4225 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4226 | "iwpriv cwmin failed"); |
| 4227 | } |
| 4228 | |
| 4229 | snprintf(buf, sizeof(buf), "iwpriv %s cwmax %d 1 %d", |
| 4230 | ifname, i, dut->ap_sta_qos[i].cwmax); |
| 4231 | if (system(buf) != 0) { |
| 4232 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4233 | "iwpriv cwmax failed"); |
| 4234 | } |
| 4235 | |
| 4236 | snprintf(buf, sizeof(buf), "iwpriv %s aifs %d 1 %d", |
| 4237 | ifname, i, dut->ap_sta_qos[i].aifs); |
| 4238 | if (system(buf) != 0) { |
| 4239 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4240 | "iwpriv aifs failed"); |
| 4241 | } |
| 4242 | |
| 4243 | snprintf(buf, sizeof(buf), |
| 4244 | "iwpriv %s txoplimit %d 1 %d", |
| 4245 | ifname, i, dut->ap_sta_qos[i].txop); |
| 4246 | if (system(buf) != 0) { |
| 4247 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4248 | "iwpriv txoplimit failed"); |
| 4249 | } |
| 4250 | |
| 4251 | snprintf(buf, sizeof(buf), "iwpriv %s acm %d 1 %d", |
| 4252 | ifname, i, dut->ap_sta_qos[i].acm); |
| 4253 | if (system(buf) != 0) { |
| 4254 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4255 | "iwpriv acm failed"); |
| 4256 | } |
| 4257 | } |
| 4258 | } |
| 4259 | |
| 4260 | if (dut->ap_disable_protection == 1) { |
| 4261 | snprintf(buf, sizeof(buf), "iwpriv %s enablertscts 0", ifname); |
| 4262 | if (system(buf) != 0) { |
| 4263 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4264 | "iwpriv enablertscts failed"); |
| 4265 | } |
| 4266 | sigma_dut_print(dut, DUT_MSG_INFO, "Disabled rtscts"); |
| 4267 | } |
| 4268 | |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 4269 | if (dut->ap_ldpc == VALUE_ENABLED) { |
Sarvepalli, Rajesh Babu | 580572a | 2016-11-29 22:07:14 +0530 | [diff] [blame] | 4270 | snprintf(buf, sizeof(buf), "iwpriv %s ldpc 3", ifname); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4271 | if (system(buf) != 0) { |
| 4272 | sigma_dut_print(dut, DUT_MSG_ERROR, |
priyadharshini gowthaman | 15b299d | 2017-04-20 12:10:45 -0700 | [diff] [blame] | 4273 | "iwpriv ldpc 3 failed"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4274 | } |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 4275 | } else if (dut->ap_ldpc == VALUE_DISABLED) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4276 | snprintf(buf, sizeof(buf), "iwpriv %s ldpc 0", ifname); |
| 4277 | if (system(buf) != 0) { |
| 4278 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4279 | "iwpriv ldpc 0 failed"); |
| 4280 | } |
| 4281 | } |
| 4282 | |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 4283 | if (dut->ap_ampdu == VALUE_ENABLED) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4284 | snprintf(buf, sizeof(buf), "iwpriv %s ampdu 1", ifname); |
| 4285 | if (system(buf) != 0) { |
| 4286 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4287 | "iwpriv ampdu 1 failed"); |
| 4288 | } |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 4289 | } else if (dut->ap_ampdu == VALUE_DISABLED) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4290 | snprintf(buf, sizeof(buf), "iwpriv %s ampdu 0", ifname); |
| 4291 | if (system(buf) != 0) { |
| 4292 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4293 | "iwpriv ampdu 0 failed"); |
| 4294 | } |
| 4295 | } |
| 4296 | |
| 4297 | if (dut->ap_ampdu_exp) { |
| 4298 | if (dut->program == PROGRAM_VHT) { |
| 4299 | snprintf(buf, sizeof(buf), "iwpriv %s vhtmaxampdu %d", |
| 4300 | ifname, dut->ap_ampdu_exp); |
| 4301 | if (system(buf) != 0) { |
| 4302 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4303 | "iwpriv vhtmaxampdu failed"); |
| 4304 | } |
| 4305 | } else { |
| 4306 | /* 11N */ |
| 4307 | snprintf(buf, sizeof(buf), "iwpriv %s maxampdu %d", |
| 4308 | ifname, dut->ap_ampdu_exp); |
| 4309 | if (system(buf) != 0) { |
| 4310 | sigma_dut_print(dut, DUT_MSG_ERROR, "iwpriv maxampdu failed"); |
| 4311 | } |
| 4312 | } |
| 4313 | } |
| 4314 | |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 4315 | if (dut->ap_noack == VALUE_ENABLED) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4316 | snprintf(buf, sizeof(buf), "iwpriv %s noackpolicy 0 0 1", ifname); |
| 4317 | if (system(buf) != 0) { |
| 4318 | sigma_dut_print(dut, DUT_MSG_ERROR, "iwpriv noackpolicy 0 0 1 failed"); |
| 4319 | } |
| 4320 | snprintf(buf, sizeof(buf), "iwpriv %s noackpolicy 1 0 1", ifname); |
| 4321 | if (system(buf) != 0) { |
| 4322 | sigma_dut_print(dut, DUT_MSG_ERROR, "iwpriv noackpolicy 1 0 1 failed"); |
| 4323 | } |
| 4324 | snprintf(buf, sizeof(buf), "iwpriv %s noackpolicy 2 0 1", ifname); |
| 4325 | if (system(buf) != 0) { |
| 4326 | sigma_dut_print(dut, DUT_MSG_ERROR, "iwpriv noackpolicy 2 0 1 failed"); |
| 4327 | } |
| 4328 | snprintf(buf, sizeof(buf), "iwpriv %s noackpolicy 3 0 1", ifname); |
| 4329 | if (system(buf) != 0) { |
| 4330 | sigma_dut_print(dut, DUT_MSG_ERROR, "iwpriv noackpolicy 3 0 1 failed"); |
| 4331 | } |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 4332 | } else if (dut->ap_noack == VALUE_DISABLED) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4333 | snprintf(buf, sizeof(buf), "iwpriv %s noackpolicy 0 0 0", ifname); |
| 4334 | if (system(buf) != 0) { |
| 4335 | sigma_dut_print(dut, DUT_MSG_ERROR, "iwpriv noackpolicy 0 0 0 failed"); |
| 4336 | } |
| 4337 | snprintf(buf, sizeof(buf), "iwpriv %s noackpolicy 1 0 0", ifname); |
| 4338 | if (system(buf) != 0) { |
| 4339 | sigma_dut_print(dut, DUT_MSG_ERROR, "iwpriv noackpolicy 1 0 0 failed"); |
| 4340 | } |
| 4341 | snprintf(buf, sizeof(buf), "iwpriv %s noackpolicy 2 0 0", ifname); |
| 4342 | if (system(buf) != 0) { |
| 4343 | sigma_dut_print(dut, DUT_MSG_ERROR, "iwpriv noackpolicy 2 0 0 failed"); |
| 4344 | } |
| 4345 | snprintf(buf, sizeof(buf), "iwpriv %s noackpolicy 3 0 0", ifname); |
| 4346 | if (system(buf) != 0) { |
| 4347 | sigma_dut_print(dut, DUT_MSG_ERROR, "iwpriv noackpolicy 3 0 0 failed"); |
| 4348 | } |
| 4349 | } |
| 4350 | |
| 4351 | if (dut->device_type == AP_testbed && dut->ap_vhtmcs_map) { |
| 4352 | snprintf(buf, sizeof(buf), "iwpriv %s vht_mcsmap 0x%04x", |
| 4353 | ifname, dut->ap_vhtmcs_map); |
| 4354 | if (system(buf) != 0) { |
| 4355 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4356 | "iwpriv vht_mcsmap failed"); |
| 4357 | } |
| 4358 | } |
| 4359 | |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 4360 | if (dut->ap_amsdu == VALUE_ENABLED) { |
Sunil Dutt | 27ec7f6 | 2017-09-14 18:22:59 +0300 | [diff] [blame] | 4361 | snprintf(buf, sizeof(buf), "iwpriv %s amsdu 2", ifname); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4362 | if (system(buf) != 0) { |
Sunil Dutt | 27ec7f6 | 2017-09-14 18:22:59 +0300 | [diff] [blame] | 4363 | sigma_dut_print(dut, DUT_MSG_ERROR, "iwpriv amsdu 2 failed"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4364 | } |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 4365 | } else if (dut->ap_amsdu == VALUE_DISABLED) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4366 | snprintf(buf, sizeof(buf), "iwpriv %s amsdu 1", ifname); |
| 4367 | if (system(buf) != 0) { |
| 4368 | sigma_dut_print(dut, DUT_MSG_ERROR, "iwpriv amsdu 1 failed"); |
| 4369 | } |
| 4370 | } |
| 4371 | |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 4372 | if (dut->ap_rx_amsdu == VALUE_ENABLED) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4373 | snprintf(buf, sizeof(buf), "iwpriv wifi1 rx_amsdu 1"); |
| 4374 | if (system(buf) != 0) { |
| 4375 | sigma_dut_print(dut, DUT_MSG_ERROR, "iwpriv rx_amsdu 1 failed"); |
| 4376 | } |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 4377 | } else if (dut->ap_rx_amsdu == VALUE_DISABLED) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4378 | snprintf(buf, sizeof(buf), "iwpriv wifi1 rx_amsdu 0"); |
| 4379 | if (system(buf) != 0) { |
| 4380 | sigma_dut_print(dut, DUT_MSG_ERROR, "iwpriv rx_amsdu 0 failed"); |
| 4381 | } |
| 4382 | } |
| 4383 | |
| 4384 | /* Command sequence to generate single VHT AMSDU and MPDU */ |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 4385 | if (dut->ap_addba_reject != VALUE_NOT_SET && |
| 4386 | dut->ap_ampdu == VALUE_DISABLED && |
| 4387 | dut->ap_amsdu == VALUE_ENABLED) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4388 | snprintf(buf, sizeof(buf), "iwpriv %s setaddbaoper 1", ifname); |
| 4389 | if (system(buf) != 0) { |
| 4390 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4391 | "iwpriv setaddbaoper 1 failed"); |
| 4392 | } |
| 4393 | |
| 4394 | snprintf(buf, sizeof(buf), |
| 4395 | "wifitool %s senddelba 1 0 1 4", ifname); |
| 4396 | if (system(buf) != 0) { |
| 4397 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4398 | "wifitool senddelba failed"); |
| 4399 | } |
| 4400 | |
| 4401 | snprintf(buf, sizeof(buf), "wifitool %s sendsingleamsdu 1 0", |
| 4402 | ifname); |
| 4403 | if (system(buf) != 0) { |
| 4404 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4405 | "wifitool sendsingleamsdu failed"); |
| 4406 | } |
| 4407 | |
| 4408 | snprintf(buf, sizeof(buf), "iwpriv %s amsdu 10", ifname); |
| 4409 | if (system(buf) != 0) { |
| 4410 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4411 | "iwpriv amsdu failed"); |
| 4412 | } |
| 4413 | } |
| 4414 | |
| 4415 | if (dut->ap_mode == AP_11ac) { |
| 4416 | int chwidth, nss; |
| 4417 | |
| 4418 | switch (dut->ap_chwidth) { |
| 4419 | case AP_20: |
| 4420 | chwidth = 0; |
| 4421 | break; |
| 4422 | case AP_40: |
| 4423 | chwidth = 1; |
| 4424 | break; |
| 4425 | case AP_80: |
| 4426 | chwidth = 2; |
| 4427 | break; |
| 4428 | case AP_160: |
| 4429 | chwidth = 3; |
| 4430 | break; |
| 4431 | default: |
| 4432 | chwidth = 0; |
| 4433 | break; |
| 4434 | } |
| 4435 | |
| 4436 | switch (dut->ap_tx_streams) { |
| 4437 | case 1: |
| 4438 | nss = 1; |
| 4439 | break; |
| 4440 | case 2: |
| 4441 | nss = 2; |
| 4442 | break; |
| 4443 | case 3: |
| 4444 | nss = 3; |
| 4445 | break; |
| 4446 | case 4: |
| 4447 | nss = 4; |
| 4448 | break; |
| 4449 | default: |
| 4450 | nss = 3; |
| 4451 | break; |
| 4452 | } |
| 4453 | |
| 4454 | if (dut->ap_fixed_rate) { |
| 4455 | if (nss == 4) |
| 4456 | ath_disable_txbf(dut, ifname); |
| 4457 | |
| 4458 | /* Set the nss */ |
| 4459 | snprintf(buf, sizeof(buf), "iwpriv %s nss %d", |
| 4460 | ifname, nss); |
| 4461 | if (system(buf) != 0) { |
| 4462 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4463 | "iwpriv nss failed"); |
| 4464 | } |
| 4465 | |
| 4466 | /* Set the channel width */ |
| 4467 | snprintf(buf, sizeof(buf), "iwpriv %s chwidth %d", |
| 4468 | ifname, chwidth); |
| 4469 | if (system(buf) != 0) { |
| 4470 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4471 | "iwpriv chwidth failed"); |
| 4472 | } |
| 4473 | |
| 4474 | /* Set the VHT MCS */ |
| 4475 | snprintf(buf, sizeof(buf), "iwpriv %s vhtmcs %d", |
| 4476 | ifname, dut->ap_mcs); |
| 4477 | if (system(buf) != 0) { |
| 4478 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4479 | "iwpriv vhtmcs failed"); |
| 4480 | } |
| 4481 | } |
| 4482 | } |
| 4483 | |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 4484 | if (dut->ap_dyn_bw_sig == VALUE_ENABLED) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4485 | snprintf(buf, sizeof(buf), "iwpriv %s cwmenable 1", ifname); |
| 4486 | if (system(buf) != 0) { |
| 4487 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4488 | "iwpriv cwmenable 1 failed"); |
| 4489 | } |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 4490 | } else if (dut->ap_dyn_bw_sig == VALUE_DISABLED) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4491 | snprintf(buf, sizeof(buf), "iwpriv %s cwmenable 0", ifname); |
| 4492 | if (system(buf) != 0) { |
| 4493 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4494 | "iwpriv cwmenable 0 failed"); |
| 4495 | } |
| 4496 | } |
| 4497 | |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 4498 | if (dut->ap_sig_rts == VALUE_ENABLED) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4499 | snprintf(buf, sizeof(buf), "iwconfig %s rts 64", ifname); |
| 4500 | if (system(buf) != 0) { |
| 4501 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4502 | "iwconfig rts 64 failed"); |
| 4503 | } |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 4504 | } else if (dut->ap_sig_rts == VALUE_DISABLED) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4505 | snprintf(buf, sizeof(buf), "iwconfig %s rts 2347", ifname); |
| 4506 | if (system(buf) != 0) { |
| 4507 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4508 | "iwpriv rts 2347 failed"); |
| 4509 | } |
| 4510 | } |
| 4511 | |
| 4512 | if (dut->ap_hs2) { |
| 4513 | snprintf(buf, sizeof(buf), "iwpriv %s qbssload 1", ifname); |
| 4514 | if (system(buf) != 0) { |
| 4515 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4516 | "iwpriv qbssload failed"); |
| 4517 | } |
| 4518 | sigma_dut_print(dut, DUT_MSG_INFO, "Enabled qbssload"); |
| 4519 | } |
| 4520 | |
| 4521 | if (dut->ap_bss_load && dut->ap_bss_load != -1) { |
| 4522 | unsigned int bssload = 0; |
| 4523 | |
| 4524 | if (dut->ap_bss_load == 1) { |
| 4525 | /* STA count: 1, CU: 50, AAC: 65535 */ |
| 4526 | bssload = 0x0132ffff; |
| 4527 | } else if (dut->ap_bss_load == 2) { |
| 4528 | /* STA count: 1, CU: 200, AAC: 65535 */ |
| 4529 | bssload = 0x01c8ffff; |
| 4530 | } else if (dut->ap_bss_load == 3) { |
| 4531 | /* STA count: 1, CU: 75, AAC: 65535 */ |
| 4532 | bssload = 0x014bffff; |
| 4533 | } |
| 4534 | |
| 4535 | snprintf(buf, sizeof(buf), "iwpriv %s hcbssload %u", |
| 4536 | ifname, bssload); |
| 4537 | if (system(buf) != 0) { |
| 4538 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4539 | "iwpriv hcbssload failed"); |
| 4540 | } |
| 4541 | } else if (dut->ap_bss_load == 0) { |
| 4542 | snprintf(buf, sizeof(buf), "iwpriv %s qbssload 0", ifname); |
| 4543 | if (system(buf) != 0) { |
| 4544 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4545 | "iwpriv qbssload failed"); |
| 4546 | } |
| 4547 | sigma_dut_print(dut, DUT_MSG_INFO, "Disabled qbssload"); |
| 4548 | } |
| 4549 | |
| 4550 | if (dut->ap_dgaf_disable) { |
| 4551 | snprintf(buf, sizeof(buf), "iwpriv %s dgaf_disable 1", ifname); |
| 4552 | if (system(buf) != 0) { |
| 4553 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4554 | "iwpriv dgaf_disable failed"); |
| 4555 | } |
| 4556 | sigma_dut_print(dut, DUT_MSG_INFO, "Enabled dgaf_disable"); |
| 4557 | } |
| 4558 | |
| 4559 | if (dut->ap_l2tif) { |
| 4560 | snprintf(buf, sizeof(buf), "iwpriv %s l2tif 1", ifname); |
| 4561 | if (system(buf) != 0) { |
| 4562 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4563 | "iwpriv l2tif failed"); |
| 4564 | } |
| 4565 | snprintf(buf, sizeof(buf), |
| 4566 | "echo 1 > /sys/class/net/br0/brif/ath0/hotspot_l2tif"); |
| 4567 | if (system(buf) != 0) |
| 4568 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4569 | "l2tif br failed"); |
| 4570 | |
| 4571 | snprintf(buf, sizeof(buf), |
| 4572 | "echo 1 > /sys/class/net/br0/brif/eth0/hotspot_wan"); |
| 4573 | if (system(buf) != 0) |
| 4574 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4575 | "l2tif brif failed"); |
| 4576 | sigma_dut_print(dut, DUT_MSG_INFO, "Enabled l2tif"); |
| 4577 | } |
priyadharshini gowthaman | 264d544 | 2016-02-25 15:52:22 -0800 | [diff] [blame] | 4578 | |
| 4579 | if (dut->ap_ndpa_frame == 0) { |
| 4580 | snprintf(buf, sizeof(buf), |
| 4581 | "wifitool %s beeliner_fw_test 117 192", ifname); |
| 4582 | if (system(buf) != 0) { |
| 4583 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4584 | "wifitool beeliner_fw_test 117 192 failed"); |
| 4585 | } |
| 4586 | snprintf(buf, sizeof(buf), |
| 4587 | "wifitool %s beeliner_fw_test 118 192", ifname); |
| 4588 | if (system(buf) != 0) { |
| 4589 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4590 | "wifitool beeliner_fw_test 117 192 failed"); |
| 4591 | } |
| 4592 | } else if (dut->ap_ndpa_frame == 1) { |
| 4593 | /* Driver default - no changes needed */ |
| 4594 | } else if (dut->ap_ndpa_frame == 2) { |
| 4595 | snprintf(buf, sizeof(buf), |
| 4596 | "wifitool %s beeliner_fw_test 115 1", ifname); |
| 4597 | if (system(buf) != 0) { |
| 4598 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4599 | "wifitool beeliner_fw_test 117 192 failed"); |
| 4600 | } |
| 4601 | snprintf(buf, sizeof(buf), |
| 4602 | "wifitool %s beeliner_fw_test 116 1", ifname); |
| 4603 | if (system(buf) != 0) { |
| 4604 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4605 | "wifitool beeliner_fw_test 117 192 failed"); |
| 4606 | } |
| 4607 | } |
priyadharshini gowthaman | 8e26ff4 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 4608 | |
| 4609 | if (dut->ap_rtt == 1) { |
| 4610 | snprintf(buf, sizeof(buf), "iwpriv %s enable_rtt 1", ifname); |
| 4611 | run_system(dut, buf); |
| 4612 | } |
| 4613 | |
| 4614 | if (dut->ap_lci == 1) { |
| 4615 | snprintf(buf, sizeof(buf), "iwpriv %s enable_lci 1", ifname); |
| 4616 | run_system(dut, buf); |
| 4617 | } |
| 4618 | |
| 4619 | if (dut->ap_lcr == 1) { |
| 4620 | snprintf(buf, sizeof(buf), "iwpriv %s enable_lcr 1", ifname); |
| 4621 | run_system(dut, buf); |
| 4622 | } |
| 4623 | |
| 4624 | if (dut->ap_rrm == 1) { |
| 4625 | snprintf(buf, sizeof(buf), "iwpriv %s rrm 1", ifname); |
| 4626 | run_system(dut, buf); |
| 4627 | } |
| 4628 | |
| 4629 | if (dut->ap_lci == 1 || dut->ap_lcr == 1) { |
| 4630 | run_system(dut, "wpc -l /tmp/lci_cfg.txt"); |
| 4631 | } |
| 4632 | |
| 4633 | if (dut->ap_neighap >= 1 && dut->ap_lci == 0) { |
| 4634 | FILE *f; |
| 4635 | |
| 4636 | f = fopen("/tmp/nbr_report.txt", "w"); |
| 4637 | if (!f) { |
| 4638 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4639 | "Failed to open /tmp/nbr_report.txt"); |
| 4640 | return; |
| 4641 | } |
| 4642 | |
| 4643 | fprintf(f, |
| 4644 | "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", |
| 4645 | dut->ap_val_neighap[0][0], dut->ap_val_neighap[0][1], |
| 4646 | dut->ap_val_neighap[0][2], dut->ap_val_neighap[0][3], |
| 4647 | dut->ap_val_neighap[0][4], dut->ap_val_neighap[0][5], |
| 4648 | dut->ap_val_opchannel[0]); |
| 4649 | fclose(f); |
| 4650 | |
| 4651 | f = fopen("/tmp/ftmrr.txt", "w"); |
| 4652 | if (!f) { |
| 4653 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4654 | "Failed to open /tmp/ftmrr.txt"); |
| 4655 | return; |
| 4656 | } |
| 4657 | |
| 4658 | fprintf(f, |
| 4659 | "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", |
| 4660 | dut->ap_val_neighap[0][0], dut->ap_val_neighap[0][1], |
| 4661 | dut->ap_val_neighap[0][2], dut->ap_val_neighap[0][3], |
| 4662 | dut->ap_val_neighap[0][4], dut->ap_val_neighap[0][5], |
| 4663 | dut->ap_val_opchannel[0]); |
| 4664 | fclose(f); |
| 4665 | } |
| 4666 | |
| 4667 | if (dut->ap_neighap >= 2 && dut->ap_lci == 0) { |
| 4668 | FILE *f; |
| 4669 | |
| 4670 | f = fopen("/tmp/nbr_report.txt", "a"); |
| 4671 | if (!f) { |
| 4672 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4673 | "Failed to open /tmp/nbr_report.txt"); |
| 4674 | return; |
| 4675 | } |
| 4676 | fprintf(f, |
| 4677 | "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", |
| 4678 | dut->ap_val_neighap[1][0], dut->ap_val_neighap[1][1], |
| 4679 | dut->ap_val_neighap[1][2], dut->ap_val_neighap[1][3], |
| 4680 | dut->ap_val_neighap[1][4], dut->ap_val_neighap[1][5], |
| 4681 | dut->ap_val_opchannel[1]); |
| 4682 | fclose(f); |
| 4683 | |
| 4684 | f = fopen("/tmp/ftmrr.txt", "a"); |
| 4685 | if (!f) { |
| 4686 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4687 | "Failed to open /tmp/ftmrr.txt"); |
| 4688 | return; |
| 4689 | } |
| 4690 | fprintf(f, |
| 4691 | "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", |
| 4692 | dut->ap_val_neighap[1][0], dut->ap_val_neighap[1][1], |
| 4693 | dut->ap_val_neighap[1][2], dut->ap_val_neighap[1][3], |
| 4694 | dut->ap_val_neighap[1][4], dut->ap_val_neighap[1][5], |
| 4695 | dut->ap_val_opchannel[1]); |
| 4696 | fclose(f); |
| 4697 | } |
| 4698 | |
| 4699 | if (dut->ap_neighap >= 3 && dut->ap_lci == 0) { |
| 4700 | FILE *f; |
| 4701 | |
| 4702 | f = fopen("/tmp/nbr_report.txt", "a"); |
| 4703 | if (!f) { |
| 4704 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4705 | "Failed to open /tmp/nbr_report.txt"); |
| 4706 | return; |
| 4707 | } |
| 4708 | |
| 4709 | fprintf(f, |
| 4710 | "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", |
| 4711 | dut->ap_val_neighap[2][0], dut->ap_val_neighap[2][1], |
| 4712 | dut->ap_val_neighap[2][2], dut->ap_val_neighap[2][3], |
| 4713 | dut->ap_val_neighap[2][4], dut->ap_val_neighap[2][5], |
| 4714 | dut->ap_val_opchannel[2]); |
| 4715 | fclose(f); |
| 4716 | |
| 4717 | f = fopen("/tmp/ftmrr.txt", "a"); |
| 4718 | if (!f) { |
| 4719 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4720 | "Failed to open /tmp/ftmrr.txt"); |
| 4721 | return; |
| 4722 | } |
| 4723 | |
| 4724 | fprintf(f, |
| 4725 | "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", |
| 4726 | dut->ap_val_neighap[2][0], dut->ap_val_neighap[2][1], |
| 4727 | dut->ap_val_neighap[2][2], dut->ap_val_neighap[2][3], |
| 4728 | dut->ap_val_neighap[2][4], dut->ap_val_neighap[2][5], |
| 4729 | dut->ap_val_opchannel[2]); |
| 4730 | fclose(f); |
| 4731 | } |
| 4732 | |
| 4733 | if (dut->ap_neighap) { |
| 4734 | snprintf(buf, sizeof(buf), "iwpriv %s enable_rtt 1", ifname); |
| 4735 | run_system(dut, buf); |
| 4736 | snprintf(buf, sizeof(buf), "iwpriv %s enable_lci 1", ifname); |
| 4737 | run_system(dut, buf); |
| 4738 | snprintf(buf, sizeof(buf), "iwpriv %s enable_lcr 1", ifname); |
| 4739 | run_system(dut, buf); |
| 4740 | snprintf(buf, sizeof(buf), "iwpriv %s rrm 1", ifname); |
| 4741 | run_system(dut, buf); |
| 4742 | } |
| 4743 | |
| 4744 | if (dut->ap_scan == 1) { |
| 4745 | snprintf(buf, sizeof(buf), "iwpriv %s scanentryage 600", |
| 4746 | ifname); |
| 4747 | run_system(dut, buf); |
| 4748 | snprintf(buf, sizeof(buf), "iwlist %s scan", ifname); |
| 4749 | run_system(dut, buf); |
| 4750 | } |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 4751 | |
| 4752 | if (dut->ap_set_bssidpref) { |
| 4753 | snprintf(buf, sizeof(buf), |
| 4754 | "wifitool %s setbssidpref 00:00:00:00:00:00 0 00 00", |
| 4755 | ifname); |
| 4756 | if (system(buf) != 0) { |
| 4757 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4758 | "wifitool clear bssidpref failed"); |
| 4759 | } |
| 4760 | } |
Adil Saeed Musthafa | 33ea287 | 2017-04-10 23:13:24 -0700 | [diff] [blame] | 4761 | |
| 4762 | if (dut->wnm_bss_max_feature != VALUE_NOT_SET) { |
| 4763 | int feature_enable; |
| 4764 | |
| 4765 | feature_enable = dut->wnm_bss_max_feature == VALUE_ENABLED; |
| 4766 | snprintf(buf, sizeof(buf), "iwpriv %s wnm %d", |
| 4767 | ifname, feature_enable); |
| 4768 | run_system(dut, buf); |
| 4769 | snprintf(buf, sizeof(buf), "iwpriv %s wnm_bss %d", |
| 4770 | ifname, feature_enable); |
| 4771 | run_system(dut, buf); |
| 4772 | if (feature_enable) { |
| 4773 | const char *extra = ""; |
| 4774 | |
| 4775 | if (dut->wnm_bss_max_protection != VALUE_NOT_SET) { |
| 4776 | if (dut->wnm_bss_max_protection == |
| 4777 | VALUE_ENABLED) |
| 4778 | extra = " 1"; |
| 4779 | else |
| 4780 | extra = " 0"; |
| 4781 | } |
| 4782 | snprintf(buf, sizeof(buf), |
| 4783 | "wlanconfig %s wnm setbssmax %d%s", |
| 4784 | ifname, dut->wnm_bss_max_idle_time, extra); |
| 4785 | run_system(dut, buf); |
| 4786 | } |
| 4787 | } |
Adil Saeed Musthafa | 05ec744 | 2017-04-10 23:13:35 -0700 | [diff] [blame] | 4788 | |
Adil Saeed Musthafa | 023108a | 2017-04-10 23:13:37 -0700 | [diff] [blame] | 4789 | if (dut->program == PROGRAM_MBO) { |
Adil Saeed Musthafa | 6906372 | 2017-04-10 23:13:40 -0700 | [diff] [blame] | 4790 | apply_mbo_pref_ap_list(dut); |
| 4791 | |
Adil Saeed Musthafa | 023108a | 2017-04-10 23:13:37 -0700 | [diff] [blame] | 4792 | snprintf(buf, sizeof(buf), "iwpriv %s mbo_cel_pref %d", |
| 4793 | ifname, dut->ap_cell_cap_pref); |
| 4794 | run_system(dut, buf); |
Adil Saeed Musthafa | 16d9e63 | 2017-04-10 23:13:38 -0700 | [diff] [blame] | 4795 | |
| 4796 | snprintf(buf, sizeof(buf), "iwpriv %s mbocap 0x40", ifname); |
| 4797 | run_system(dut, buf); |
| 4798 | |
Adil Saeed Musthafa | 05ec744 | 2017-04-10 23:13:35 -0700 | [diff] [blame] | 4799 | ath_set_assoc_disallow(dut, ifname, "disable"); |
Adil Saeed Musthafa | 023108a | 2017-04-10 23:13:37 -0700 | [diff] [blame] | 4800 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4801 | } |
| 4802 | |
| 4803 | |
| 4804 | static int cmd_ath_ap_config_commit(struct sigma_dut *dut, |
| 4805 | struct sigma_conn *conn, |
| 4806 | struct sigma_cmd *cmd) |
| 4807 | { |
| 4808 | /* const char *name = get_param(cmd, "NAME"); */ |
| 4809 | char buf[100]; |
| 4810 | struct stat s; |
| 4811 | const char *ifname = dut->ap_is_dual ? "ath1" : "ath0"; |
| 4812 | |
| 4813 | if (stat("/proc/athversion", &s) == 0) { |
| 4814 | sigma_dut_print(dut, DUT_MSG_INFO, "Run apdown"); |
| 4815 | run_system(dut, "apdown"); |
| 4816 | } |
| 4817 | |
| 4818 | cmd_ath_ap_radio_config(dut); |
| 4819 | |
| 4820 | snprintf(buf, sizeof(buf), "cfg -a 'AP_SSID=%s'", dut->ap_ssid); |
| 4821 | run_system(dut, buf); |
| 4822 | |
| 4823 | switch (dut->ap_key_mgmt) { |
| 4824 | case AP_OPEN: |
| 4825 | if (dut->ap_cipher == AP_WEP) { |
| 4826 | run_system(dut, "cfg -a AP_SECMODE=WEP"); |
| 4827 | run_system(dut, "cfg -a AP_SECFILE=NONE"); |
| 4828 | /* shared auth mode not supported */ |
| 4829 | run_system(dut, "cfg -a AP_WEP_MODE_0=1"); |
| 4830 | run_system(dut, "cfg -a AP_WEP_MODE_1=1"); |
| 4831 | snprintf(buf, sizeof(buf), |
| 4832 | "cfg -a WEP_RADIO_NUM0_KEY_1=%s", |
| 4833 | dut->ap_wepkey); |
| 4834 | run_system(dut, buf); |
| 4835 | snprintf(buf, sizeof(buf), |
| 4836 | "cfg -a WEP_RADIO_NUM1_KEY_1=%s", |
| 4837 | dut->ap_wepkey); |
| 4838 | run_system(dut, buf); |
| 4839 | } else { |
| 4840 | run_system(dut, "cfg -a AP_SECMODE=None"); |
| 4841 | } |
| 4842 | break; |
| 4843 | case AP_WPA2_PSK: |
| 4844 | case AP_WPA2_PSK_MIXED: |
| 4845 | case AP_WPA_PSK: |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 4846 | case AP_WPA2_SAE: |
| 4847 | case AP_WPA2_PSK_SAE: |
| 4848 | if (dut->ap_key_mgmt == AP_WPA2_PSK || |
| 4849 | dut->ap_key_mgmt == AP_WPA2_SAE || |
| 4850 | dut->ap_key_mgmt == AP_WPA2_PSK_SAE) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4851 | run_system(dut, "cfg -a AP_WPA=2"); |
| 4852 | else if (dut->ap_key_mgmt == AP_WPA2_PSK_MIXED) |
| 4853 | run_system(dut, "cfg -a AP_WPA=3"); |
| 4854 | else |
| 4855 | run_system(dut, "cfg -a AP_WPA=1"); |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 4856 | /* TODO: SAE configuration */ |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4857 | run_system(dut, "cfg -a AP_SECMODE=WPA"); |
| 4858 | run_system(dut, "cfg -a AP_SECFILE=PSK"); |
| 4859 | snprintf(buf, sizeof(buf), "cfg -a 'PSK_KEY=%s'", |
| 4860 | dut->ap_passphrase); |
| 4861 | run_system(dut, buf); |
| 4862 | if (dut->ap_cipher == AP_CCMP_TKIP) |
| 4863 | run_system(dut, "cfg -a AP_CYPHER=\"CCMP TKIP\""); |
| 4864 | else if (dut->ap_cipher == AP_TKIP) |
| 4865 | run_system(dut, "cfg -a AP_CYPHER=TKIP"); |
| 4866 | else |
| 4867 | run_system(dut, "cfg -a AP_CYPHER=CCMP"); |
| 4868 | break; |
| 4869 | case AP_WPA2_EAP: |
| 4870 | case AP_WPA2_EAP_MIXED: |
| 4871 | case AP_WPA_EAP: |
| 4872 | if (dut->ap_key_mgmt == AP_WPA2_EAP) |
| 4873 | run_system(dut, "cfg -a AP_WPA=2"); |
| 4874 | else if (dut->ap_key_mgmt == AP_WPA2_EAP_MIXED) |
| 4875 | run_system(dut, "cfg -a AP_WPA=3"); |
| 4876 | else |
| 4877 | run_system(dut, "cfg -a AP_WPA=1"); |
| 4878 | run_system(dut, "cfg -a AP_SECMODE=WPA"); |
| 4879 | run_system(dut, "cfg -a AP_SECFILE=EAP"); |
| 4880 | if (dut->ap_cipher == AP_CCMP_TKIP) |
| 4881 | run_system(dut, "cfg -a AP_CYPHER=\"CCMP TKIP\""); |
| 4882 | else if (dut->ap_cipher == AP_TKIP) |
| 4883 | run_system(dut, "cfg -a AP_CYPHER=TKIP"); |
| 4884 | else |
| 4885 | run_system(dut, "cfg -a AP_CYPHER=CCMP"); |
| 4886 | snprintf(buf, sizeof(buf), "cfg -a AP_AUTH_SERVER=%s", |
| 4887 | dut->ap_radius_ipaddr); |
| 4888 | run_system(dut, buf); |
| 4889 | snprintf(buf, sizeof(buf), "cfg -a AP_AUTH_PORT=%d", |
| 4890 | dut->ap_radius_port); |
| 4891 | run_system(dut, buf); |
| 4892 | snprintf(buf, sizeof(buf), "cfg -a AP_AUTH_SECRET=%s", |
| 4893 | dut->ap_radius_password); |
| 4894 | run_system(dut, buf); |
| 4895 | break; |
Jouni Malinen | ad395a2 | 2017-09-01 21:13:46 +0300 | [diff] [blame] | 4896 | case AP_SUITEB: |
| 4897 | /* TODO */ |
| 4898 | sigma_dut_print(dut, DUT_MSG_ERROR, "SuiteB not supported"); |
| 4899 | break; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4900 | } |
| 4901 | |
| 4902 | if (dut->ap_is_dual) { |
| 4903 | /* ath1 settings in case of dual */ |
| 4904 | snprintf(buf, sizeof(buf), "cfg -a 'AP_SSID_2=%s'", |
| 4905 | dut->ap_ssid); |
| 4906 | run_system(dut, buf); |
| 4907 | |
| 4908 | switch (dut->ap_key_mgmt) { |
| 4909 | case AP_OPEN: |
| 4910 | if (dut->ap_cipher == AP_WEP) { |
| 4911 | run_system(dut, "cfg -a AP_SECMODE_2=WEP"); |
| 4912 | run_system(dut, "cfg -a AP_SECFILE_2=NONE"); |
| 4913 | /* shared auth mode not supported */ |
| 4914 | run_system(dut, "cfg -a AP_WEP_MODE_0=1"); |
| 4915 | run_system(dut, "cfg -a AP_WEP_MODE_1=1"); |
| 4916 | snprintf(buf, sizeof(buf), |
| 4917 | "cfg -a WEP_RADIO_NUM0_KEY_1=%s", |
| 4918 | dut->ap_wepkey); |
| 4919 | run_system(dut, buf); |
| 4920 | snprintf(buf, sizeof(buf), |
| 4921 | "cfg -a WEP_RADIO_NUM1_KEY_1=%s", |
| 4922 | dut->ap_wepkey); |
| 4923 | run_system(dut, buf); |
| 4924 | } else { |
| 4925 | run_system(dut, "cfg -a AP_SECMODE_2=None"); |
| 4926 | } |
| 4927 | break; |
| 4928 | case AP_WPA2_PSK: |
| 4929 | case AP_WPA2_PSK_MIXED: |
| 4930 | case AP_WPA_PSK: |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 4931 | case AP_WPA2_SAE: |
| 4932 | case AP_WPA2_PSK_SAE: |
| 4933 | if (dut->ap_key_mgmt == AP_WPA2_PSK || |
| 4934 | dut->ap_key_mgmt == AP_WPA2_SAE || |
| 4935 | dut->ap_key_mgmt == AP_WPA2_PSK_SAE) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4936 | run_system(dut, "cfg -a AP_WPA_2=2"); |
| 4937 | else if (dut->ap_key_mgmt == AP_WPA2_PSK_MIXED) |
| 4938 | run_system(dut, "cfg -a AP_WPA_2=3"); |
| 4939 | else |
| 4940 | run_system(dut, "cfg -a AP_WPA_2=1"); |
| 4941 | // run_system(dut, "cfg -a AP_WPA_2=2"); |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 4942 | /* TODO: SAE configuration */ |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4943 | run_system(dut, "cfg -a AP_SECMODE_2=WPA"); |
| 4944 | run_system(dut, "cfg -a AP_SECFILE_2=PSK"); |
| 4945 | snprintf(buf, sizeof(buf), "cfg -a 'PSK_KEY_2=%s'", |
| 4946 | dut->ap_passphrase); |
| 4947 | run_system(dut, buf); |
| 4948 | if (dut->ap_cipher == AP_CCMP_TKIP) |
| 4949 | run_system(dut, "cfg -a AP_CYPHER_2=\"CCMP TKIP\""); |
| 4950 | else if (dut->ap_cipher == AP_TKIP) |
| 4951 | run_system(dut, "cfg -a AP_CYPHER_2=TKIP"); |
| 4952 | else |
| 4953 | run_system(dut, "cfg -a AP_CYPHER_2=CCMP"); |
| 4954 | break; |
| 4955 | case AP_WPA2_EAP: |
| 4956 | case AP_WPA2_EAP_MIXED: |
| 4957 | case AP_WPA_EAP: |
| 4958 | if (dut->ap_key_mgmt == AP_WPA2_EAP) |
| 4959 | run_system(dut, "cfg -a AP_WPA_2=2"); |
| 4960 | else if (dut->ap_key_mgmt == AP_WPA2_EAP_MIXED) |
| 4961 | run_system(dut, "cfg -a AP_WPA_2=3"); |
| 4962 | else |
| 4963 | run_system(dut, "cfg -a AP_WPA_2=1"); |
| 4964 | run_system(dut, "cfg -a AP_SECMODE_2=WPA"); |
| 4965 | run_system(dut, "cfg -a AP_SECFILE_2=EAP"); |
| 4966 | if (dut->ap_cipher == AP_CCMP_TKIP) |
| 4967 | run_system(dut, "cfg -a AP_CYPHER_2=\"CCMP TKIP\""); |
| 4968 | else if (dut->ap_cipher == AP_TKIP) |
| 4969 | run_system(dut, "cfg -a AP_CYPHER_2=TKIP"); |
| 4970 | else |
| 4971 | run_system(dut, "cfg -a AP_CYPHER_2=CCMP"); |
| 4972 | |
| 4973 | snprintf(buf, sizeof(buf), "cfg -a AP_AUTH_SERVER_2=%s", |
| 4974 | dut->ap_radius_ipaddr); |
| 4975 | run_system(dut, buf); |
| 4976 | snprintf(buf, sizeof(buf), "cfg -a AP_AUTH_PORT_2=%d", |
| 4977 | dut->ap_radius_port); |
| 4978 | run_system(dut, buf); |
| 4979 | snprintf(buf, sizeof(buf), "cfg -a AP_AUTH_SECRET_2=%s", |
| 4980 | dut->ap_radius_password); |
| 4981 | run_system(dut, buf); |
| 4982 | break; |
Jouni Malinen | ad395a2 | 2017-09-01 21:13:46 +0300 | [diff] [blame] | 4983 | case AP_SUITEB: |
| 4984 | /* TODO */ |
| 4985 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4986 | "SuiteB not supported"); |
| 4987 | break; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4988 | } |
| 4989 | |
| 4990 | /* wifi0 settings in case of dual */ |
| 4991 | run_system(dut, "cfg -a AP_RADIO_ID=0"); |
| 4992 | run_system(dut, "cfg -a AP_PRIMARY_CH=6"); |
| 4993 | run_system(dut, "cfg -a AP_STARTMODE=dual"); |
| 4994 | run_system(dut, "cfg -a AP_CHMODE=11NGHT40PLUS"); |
| 4995 | run_system(dut, "cfg -a TX_CHAINMASK=7"); |
| 4996 | run_system(dut, "cfg -a RX_CHAINMASK=7"); |
| 4997 | } |
| 4998 | |
| 4999 | switch (dut->ap_pmf) { |
| 5000 | case AP_PMF_DISABLED: |
| 5001 | snprintf(buf, sizeof(buf), "cfg -a AP_PMF=0"); |
| 5002 | run_system(dut, buf); |
| 5003 | break; |
| 5004 | case AP_PMF_OPTIONAL: |
| 5005 | snprintf(buf, sizeof(buf), "cfg -a AP_PMF=1"); |
| 5006 | run_system(dut, buf); |
| 5007 | break; |
| 5008 | case AP_PMF_REQUIRED: |
| 5009 | snprintf(buf, sizeof(buf), "cfg -a AP_PMF=2"); |
| 5010 | run_system(dut, buf); |
| 5011 | break; |
| 5012 | } |
| 5013 | if (dut->ap_add_sha256) { |
| 5014 | snprintf(buf, sizeof(buf), "cfg -a AP_WPA_SHA256=1"); |
| 5015 | run_system(dut, buf); |
| 5016 | } else { |
| 5017 | snprintf(buf, sizeof(buf), "cfg -r AP_WPA_SHA256"); |
| 5018 | run_system(dut, buf); |
| 5019 | } |
| 5020 | |
| 5021 | if (dut->ap_hs2) |
| 5022 | run_system(dut, "cfg -a AP_HOTSPOT=1"); |
| 5023 | else |
| 5024 | run_system(dut, "cfg -r AP_HOTSPOT"); |
| 5025 | |
| 5026 | if (dut->ap_interworking) { |
| 5027 | snprintf(buf, sizeof(buf), "cfg -a AP_HOTSPOT_ANT=%d", |
| 5028 | dut->ap_access_net_type); |
| 5029 | run_system(dut, buf); |
| 5030 | snprintf(buf, sizeof(buf), "cfg -a AP_HOTSPOT_INTERNET=%d", |
| 5031 | dut->ap_internet); |
| 5032 | run_system(dut, buf); |
| 5033 | snprintf(buf, sizeof(buf), "cfg -a AP_HOTSPOT_VENUEGROUP=%d", |
| 5034 | dut->ap_venue_group); |
| 5035 | run_system(dut, buf); |
| 5036 | snprintf(buf, sizeof(buf), "cfg -a AP_HOTSPOT_VENUETYPE=%d", |
| 5037 | dut->ap_venue_type); |
| 5038 | run_system(dut, buf); |
| 5039 | snprintf(buf, sizeof(buf), "cfg -a AP_HOTSPOT_HESSID=%s", |
| 5040 | dut->ap_hessid); |
| 5041 | run_system(dut, buf); |
| 5042 | |
| 5043 | if (dut->ap_roaming_cons[0]) { |
| 5044 | char *second, *rc; |
| 5045 | rc = strdup(dut->ap_roaming_cons); |
| 5046 | if (rc == NULL) |
| 5047 | return 0; |
| 5048 | |
| 5049 | second = strchr(rc, ';'); |
| 5050 | if (second) |
| 5051 | *second++ = '\0'; |
| 5052 | |
| 5053 | snprintf(buf, sizeof(buf), |
| 5054 | "cfg -a AP_HOTSPOT_ROAMINGCONSORTIUM=%s", rc); |
| 5055 | run_system(dut, buf); |
| 5056 | |
| 5057 | if (second) { |
| 5058 | snprintf(buf, sizeof(buf), |
| 5059 | "cfg -a AP_HOTSPOT_ROAMINGCONSORTIUM2" |
| 5060 | "=%s", second); |
| 5061 | run_system(dut, buf); |
| 5062 | } |
| 5063 | free(rc); |
| 5064 | } else { |
| 5065 | run_system(dut, "cfg -r AP_HOTSPOT_ROAMINGCONSORTIUM"); |
| 5066 | run_system(dut, |
| 5067 | "cfg -r AP_HOTSPOT_ROAMINGCONSORTIUM2"); |
| 5068 | } |
| 5069 | } else { |
| 5070 | run_system(dut, "cfg -r AP_HOTSPOT_ANT"); |
| 5071 | run_system(dut, "cfg -r AP_HOTSPOT_INTERNET"); |
| 5072 | run_system(dut, "cfg -r AP_HOTSPOT_VENUEGROUP"); |
| 5073 | run_system(dut, "cfg -r AP_HOTSPOT_VENUETYPE"); |
| 5074 | run_system(dut, "cfg -r AP_HOTSPOT_HESSID"); |
| 5075 | run_system(dut, "cfg -r AP_HOTSPOT_ROAMINGCONSORTIUM"); |
| 5076 | run_system(dut, "cfg -r AP_HOTSPOT_ROAMINGCONSORTIUM2"); |
| 5077 | } |
| 5078 | |
| 5079 | if (dut->ap_proxy_arp) |
| 5080 | run_system(dut, "cfg -a IEEE80211V_PROXYARP=1"); |
| 5081 | else |
| 5082 | run_system(dut, "cfg -a IEEE80211V_PROXYARP=0"); |
| 5083 | if (dut->ap_dgaf_disable) |
| 5084 | run_system(dut, "cfg -a AP_HOTSPOT_DISABLE_DGAF=1"); |
| 5085 | else |
| 5086 | run_system(dut, "cfg -r AP_HOTSPOT_DISABLE_DGAF"); |
| 5087 | |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 5088 | if (strlen(dut->ap_tag_ssid[0])) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5089 | snprintf(buf, sizeof(buf), |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 5090 | "cfg -a AP_SSID_2=%s", dut->ap_tag_ssid[0]); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5091 | run_system(dut, buf); |
| 5092 | |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 5093 | if (dut->ap_tag_key_mgmt[0] == AP2_OSEN) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5094 | run_system(dut, "cfg -a AP_SECMODE_2=WPA"); |
| 5095 | run_system(dut, "cfg -a AP_SECFILE_2=OSEN"); |
| 5096 | |
| 5097 | snprintf(buf, sizeof(buf), "cfg -a AP_AUTH_SERVER_2=%s", |
| 5098 | dut->ap2_radius_ipaddr); |
| 5099 | run_system(dut, buf); |
| 5100 | |
| 5101 | snprintf(buf, sizeof(buf), "cfg -a AP_AUTH_PORT_2=%d", |
| 5102 | dut->ap2_radius_port); |
| 5103 | run_system(dut, buf); |
| 5104 | |
| 5105 | snprintf(buf, sizeof(buf), "cfg -a AP_AUTH_SECRET_2=%s", |
| 5106 | dut->ap2_radius_password); |
| 5107 | run_system(dut, buf); |
| 5108 | } else { |
| 5109 | run_system(dut, "cfg -a AP_SECMODE_2=None"); |
| 5110 | run_system(dut, "cfg -r AP_AUTH_SERVER_2"); |
| 5111 | run_system(dut, "cfg -r AP_AUTH_PORT_2"); |
| 5112 | run_system(dut, "cfg -r AP_AUTH_SECRET_2"); |
| 5113 | } |
| 5114 | |
| 5115 | run_system(dut, "cfg -a AP_STARTMODE=multi"); |
| 5116 | } |
| 5117 | |
| 5118 | run_system(dut, "cfg -c"); |
| 5119 | |
| 5120 | sigma_dut_print(dut, DUT_MSG_INFO, "Starting AP"); |
| 5121 | if (system("apup") != 0) { |
| 5122 | /* to be debugged why apup returns error |
| 5123 | send_resp(dut, conn, SIGMA_ERROR, |
| 5124 | "errorCode,apup failed"); |
| 5125 | return 0; |
| 5126 | */ |
| 5127 | } |
| 5128 | sigma_dut_print(dut, DUT_MSG_INFO, "AP started"); |
| 5129 | |
| 5130 | if (dut->ap_key_mgmt != AP_OPEN) { |
| 5131 | int res; |
| 5132 | /* allow some time for hostapd to start before returning |
| 5133 | * success */ |
| 5134 | usleep(500000); |
| 5135 | if (run_hostapd_cli(dut, "ping") != 0) { |
| 5136 | send_resp(dut, conn, SIGMA_ERROR, |
| 5137 | "errorCode,Failed to talk to hostapd"); |
| 5138 | return 0; |
| 5139 | } |
| 5140 | |
| 5141 | if (dut->ap_hs2 && !dut->ap_anqpserver) { |
| 5142 | /* the cfg app doesn't like ";" in the variables */ |
| 5143 | res = ath_ap_append_hostapd_conf(dut); |
| 5144 | if (res < 0) |
| 5145 | return res; |
| 5146 | |
| 5147 | /* wait for hostapd to be ready */ |
| 5148 | usleep(500000); |
| 5149 | if (run_hostapd_cli(dut, "ping") != 0) { |
| 5150 | send_resp(dut, conn, SIGMA_ERROR, |
| 5151 | "errorCode,Failed to talk to " |
| 5152 | "hostapd"); |
| 5153 | return 0; |
| 5154 | } |
| 5155 | } |
| 5156 | } |
| 5157 | |
| 5158 | ath_ap_set_params(dut); |
| 5159 | |
| 5160 | if (dut->ap_anqpserver) |
| 5161 | return cmd_ath_ap_anqpserver_start(dut); |
| 5162 | |
| 5163 | if (dut->ap2_proxy_arp) |
| 5164 | run_system(dut, "iwpriv ath1 proxy_arp 1"); |
| 5165 | |
| 5166 | if (dut->ap_allow_vht_wep || dut->ap_allow_vht_tkip) { |
| 5167 | snprintf(buf, sizeof(buf), "iwpriv %s htweptkip 1", ifname); |
| 5168 | if (system(buf) != 0) { |
| 5169 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5170 | "iwpriv htweptkip failed"); |
| 5171 | } |
| 5172 | } |
| 5173 | |
| 5174 | return 1; |
| 5175 | } |
| 5176 | |
| 5177 | |
| 5178 | static int set_ebtables_proxy_arp(struct sigma_dut *dut, const char *chain, |
| 5179 | const char *ifname) |
| 5180 | { |
| 5181 | char buf[200]; |
| 5182 | |
| 5183 | if (!chain || !ifname) |
| 5184 | return -2; |
| 5185 | |
| 5186 | snprintf(buf, sizeof(buf), "ebtables -P %s ACCEPT", chain); |
| 5187 | if (system(buf) != 0) { |
| 5188 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5189 | "Failed to set ebtables rules, RULE-1, %s", |
| 5190 | chain); |
| 5191 | return -2; |
| 5192 | } |
| 5193 | |
| 5194 | snprintf(buf, sizeof(buf), |
| 5195 | "ebtables -A %s -p ARP -d Broadcast -o %s -j DROP", |
| 5196 | chain, ifname); |
| 5197 | if (system(buf) != 0) { |
| 5198 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5199 | "Failed to set ebtables rules, RULE-2, %s", |
| 5200 | chain); |
| 5201 | return -2; |
| 5202 | } |
| 5203 | |
| 5204 | snprintf(buf, sizeof(buf), |
| 5205 | "ebtables -A %s -d Multicast -p IPv6 --ip6-protocol ipv6-icmp --ip6-icmp-type neighbor-solicitation -o %s -j DROP", |
| 5206 | chain, ifname); |
| 5207 | if (system(buf) != 0) { |
| 5208 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5209 | "Failed to set ebtables rules, RULE-3, %s", |
| 5210 | chain); |
| 5211 | return -2; |
| 5212 | } |
| 5213 | |
| 5214 | snprintf(buf, sizeof(buf), |
| 5215 | "ebtables -A %s -d Multicast -p IPv6 --ip6-protocol ipv6-icmp --ip6-icmp-type neighbor-advertisement -o %s -j DROP", |
| 5216 | chain, ifname); |
| 5217 | if (system(buf) != 0) { |
| 5218 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5219 | "Failed to set ebtables rules, RULE-4, %s", |
| 5220 | chain); |
| 5221 | return -2; |
| 5222 | } |
| 5223 | |
| 5224 | return 0; |
| 5225 | } |
| 5226 | |
| 5227 | |
| 5228 | static int set_ebtables_disable_dgaf(struct sigma_dut *dut, |
| 5229 | const char *chain, |
| 5230 | const char *ifname) |
| 5231 | { |
| 5232 | char buf[200]; |
| 5233 | |
| 5234 | if (!chain || !ifname) |
| 5235 | return -2; |
| 5236 | |
| 5237 | snprintf(buf, sizeof(buf), "ebtables -P %s ACCEPT", chain); |
| 5238 | if (system(buf) != 0) { |
| 5239 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5240 | "Failed to set ebtables rules, RULE-5, %s", |
| 5241 | chain); |
| 5242 | return -2; |
| 5243 | } |
| 5244 | |
| 5245 | snprintf(buf, sizeof(buf), |
| 5246 | "ebtables -A %s -p ARP -d Broadcast -o %s -j DROP", |
| 5247 | chain, ifname); |
| 5248 | if (system(buf) != 0) { |
| 5249 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5250 | "Failed to set ebtables rules, RULE-6, %s", |
| 5251 | chain); |
| 5252 | return -2; |
| 5253 | } |
| 5254 | |
| 5255 | snprintf(buf, sizeof(buf), |
| 5256 | "ebtables -A %s -p IPv4 -d Multicast -o %s -j DROP", |
| 5257 | chain, ifname); |
| 5258 | if (system(buf) != 0) { |
| 5259 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5260 | "Failed to set ebtables rules, RULE-7, %s", |
| 5261 | chain); |
| 5262 | return -2; |
| 5263 | } |
| 5264 | |
| 5265 | snprintf(buf, sizeof(buf), |
| 5266 | "ebtables -A %s -p IPv6 -d Multicast -o %s -j DROP", |
| 5267 | chain, ifname); |
| 5268 | if (system(buf) != 0) { |
| 5269 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5270 | "Failed to set ebtables rules, RULE-8, %s", |
| 5271 | chain); |
| 5272 | return -2; |
| 5273 | } |
| 5274 | |
| 5275 | return 0; |
| 5276 | } |
| 5277 | |
| 5278 | |
| 5279 | static int check_channel(int channel) |
| 5280 | { |
| 5281 | int channel_list[] = { 36, 40, 44, 48, 52, 60, 64, 100, 104, 108, 112, |
| 5282 | 116, 120, 124, 128, 132, 140, 144, 149, 153, 157, |
| 5283 | 161, 165 }; |
| 5284 | int num_chan = sizeof(channel_list) / sizeof(int); |
| 5285 | int i; |
| 5286 | |
| 5287 | for (i = 0; i < num_chan; i++) { |
| 5288 | if (channel == channel_list[i]) |
| 5289 | return i; |
| 5290 | } |
| 5291 | |
| 5292 | return -1; |
| 5293 | } |
| 5294 | |
| 5295 | |
| 5296 | static int get_oper_centr_freq_seq_idx(int chwidth, int channel) |
| 5297 | { |
| 5298 | int ch_base; |
| 5299 | int period; |
| 5300 | |
| 5301 | if (check_channel(channel) < 0) |
| 5302 | return -1; |
| 5303 | |
| 5304 | if (channel >= 36 && channel <= 64) |
| 5305 | ch_base = 36; |
| 5306 | else if (channel >= 100 && channel <= 144) |
| 5307 | ch_base = 100; |
| 5308 | else |
| 5309 | ch_base = 149; |
| 5310 | |
| 5311 | period = channel % ch_base * 5 / chwidth; |
| 5312 | return ch_base + period * chwidth / 5 + (chwidth - 20) / 10; |
| 5313 | } |
| 5314 | |
| 5315 | |
| 5316 | static int is_ht40plus_chan(int chan) |
| 5317 | { |
| 5318 | return chan == 36 || chan == 44 || chan == 52 || chan == 60 || |
| 5319 | chan == 100 || chan == 108 || chan == 116 || chan == 124 || |
| 5320 | chan == 132 || chan == 149 || chan == 157; |
| 5321 | } |
| 5322 | |
| 5323 | |
| 5324 | static int is_ht40minus_chan(int chan) |
| 5325 | { |
| 5326 | return chan == 40 || chan == 48 || chan == 56 || chan == 64 || |
| 5327 | chan == 104 || chan == 112 || chan == 120 || chan == 128 || |
| 5328 | chan == 136 || chan == 153 || chan == 161; |
| 5329 | } |
| 5330 | |
| 5331 | |
Mohammed Shafi Shajakhan | b53d8f9 | 2017-02-28 09:05:15 +0530 | [diff] [blame] | 5332 | static int get_5g_channel_freq(int chan) |
| 5333 | { |
| 5334 | return 5000 + chan * 5; |
| 5335 | } |
| 5336 | |
| 5337 | |
Jouni Malinen | a326d7b | 2017-09-04 13:46:02 +0300 | [diff] [blame] | 5338 | int cmd_ap_config_commit(struct sigma_dut *dut, struct sigma_conn *conn, |
| 5339 | struct sigma_cmd *cmd) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5340 | { |
| 5341 | /* const char *name = get_param(cmd, "NAME"); */ |
| 5342 | FILE *f; |
| 5343 | const char *ifname; |
| 5344 | char buf[500]; |
| 5345 | char path[100]; |
| 5346 | enum driver_type drv; |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 5347 | const char *key_mgmt; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5348 | |
| 5349 | drv = get_driver_type(); |
| 5350 | |
| 5351 | if (dut->mode == SIGMA_MODE_STATION) { |
| 5352 | stop_sta_mode(dut); |
| 5353 | sleep(1); |
| 5354 | } |
| 5355 | |
| 5356 | if (dut->mode == SIGMA_MODE_SNIFFER && dut->sniffer_ifname) { |
| 5357 | snprintf(buf, sizeof(buf), "ifconfig %s down", |
| 5358 | dut->sniffer_ifname); |
| 5359 | if (system(buf) != 0) { |
| 5360 | sigma_dut_print(dut, DUT_MSG_INFO, |
| 5361 | "Failed to run '%s'", buf); |
| 5362 | } |
| 5363 | snprintf(buf, sizeof(buf), "iw dev %s set type station", |
| 5364 | dut->sniffer_ifname); |
| 5365 | if (system(buf) != 0) { |
| 5366 | sigma_dut_print(dut, DUT_MSG_INFO, |
| 5367 | "Failed to run '%s'", buf); |
| 5368 | } |
| 5369 | } |
| 5370 | |
| 5371 | dut->mode = SIGMA_MODE_AP; |
| 5372 | |
| 5373 | if (drv == DRIVER_ATHEROS) |
| 5374 | return cmd_ath_ap_config_commit(dut, conn, cmd); |
| 5375 | if (drv == DRIVER_WCN) |
| 5376 | return cmd_wcn_ap_config_commit(dut, conn, cmd); |
| 5377 | if (drv == DRIVER_OPENWRT) |
| 5378 | return cmd_owrt_ap_config_commit(dut, conn, cmd); |
| 5379 | |
| 5380 | f = fopen(SIGMA_TMPDIR "/sigma_dut-ap.conf", "w"); |
| 5381 | if (f == NULL) { |
| 5382 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5383 | "%s: Failed to open sigma_dut-ap.conf", |
| 5384 | __func__); |
| 5385 | return -2; |
| 5386 | } |
| 5387 | switch (dut->ap_mode) { |
| 5388 | case AP_11g: |
| 5389 | case AP_11b: |
| 5390 | case AP_11ng: |
Pradeep Reddy Potteti | 08eaeba | 2017-06-14 12:43:19 +0530 | [diff] [blame] | 5391 | ifname = (drv == DRIVER_MAC80211) ? "wlan0" : "ath0"; |
| 5392 | if ((drv == DRIVER_QNXNTO || drv == DRIVER_LINUX_WCN) && |
| 5393 | sigma_main_ifname) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5394 | ifname = sigma_main_ifname; |
| 5395 | fprintf(f, "hw_mode=g\n"); |
| 5396 | break; |
| 5397 | case AP_11a: |
| 5398 | case AP_11na: |
| 5399 | case AP_11ac: |
Pradeep Reddy Potteti | 08eaeba | 2017-06-14 12:43:19 +0530 | [diff] [blame] | 5400 | if (drv == DRIVER_QNXNTO || drv == DRIVER_LINUX_WCN) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5401 | if (sigma_main_ifname) |
| 5402 | ifname = sigma_main_ifname; |
| 5403 | else |
| 5404 | ifname = "wlan0"; |
Pradeep Reddy Potteti | 08eaeba | 2017-06-14 12:43:19 +0530 | [diff] [blame] | 5405 | } else if (drv == DRIVER_MAC80211) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5406 | if (if_nametoindex("wlan1") > 0) |
| 5407 | ifname = "wlan1"; |
| 5408 | else |
| 5409 | ifname = "wlan0"; |
| 5410 | } else { |
| 5411 | ifname = get_main_ifname(); |
| 5412 | } |
| 5413 | fprintf(f, "hw_mode=a\n"); |
| 5414 | break; |
| 5415 | default: |
| 5416 | fclose(f); |
| 5417 | return -1; |
| 5418 | } |
Jouni Malinen | d6bf1b4 | 2017-06-23 17:51:01 +0300 | [diff] [blame] | 5419 | if (dut->hostapd_ifname) |
| 5420 | ifname = dut->hostapd_ifname; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5421 | |
Sreelakshmi Konamki | b692f10 | 2016-04-26 19:47:00 +0530 | [diff] [blame] | 5422 | if (drv == DRIVER_MAC80211 || drv == DRIVER_LINUX_WCN) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5423 | fprintf(f, "driver=nl80211\n"); |
| 5424 | |
Sreelakshmi Konamki | b692f10 | 2016-04-26 19:47:00 +0530 | [diff] [blame] | 5425 | if ((drv == DRIVER_MAC80211 || drv == DRIVER_QNXNTO || |
| 5426 | drv == DRIVER_LINUX_WCN) && |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5427 | (dut->ap_mode == AP_11ng || dut->ap_mode == AP_11na)) { |
Tamizh chelvam | 431c600 | 2017-03-07 17:07:16 +0530 | [diff] [blame] | 5428 | int ht40plus = 0, ht40minus = 0, tx_stbc = 0; |
| 5429 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5430 | fprintf(f, "ieee80211n=1\n"); |
Pradeep Reddy Potteti | bf8af29 | 2017-02-15 15:28:39 +0530 | [diff] [blame] | 5431 | if (dut->ap_mode == AP_11ng && |
| 5432 | (dut->ap_chwidth == AP_40 || |
| 5433 | (dut->ap_chwidth == AP_AUTO && |
| 5434 | dut->default_11ng_ap_chwidth == AP_40))) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5435 | if (dut->ap_channel >= 1 && dut->ap_channel <= 7) |
Tamizh chelvam | 431c600 | 2017-03-07 17:07:16 +0530 | [diff] [blame] | 5436 | ht40plus = 1; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5437 | else if (dut->ap_channel >= 8 && dut->ap_channel <= 11) |
Tamizh chelvam | 431c600 | 2017-03-07 17:07:16 +0530 | [diff] [blame] | 5438 | ht40minus = 1; |
| 5439 | fprintf(f, "obss_interval=300\n"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5440 | } |
| 5441 | |
| 5442 | /* configure ht_capab based on channel width */ |
| 5443 | if (dut->ap_mode == AP_11na && |
| 5444 | (dut->ap_chwidth == AP_40 || |
| 5445 | (dut->ap_chwidth == AP_AUTO && |
Pradeep Reddy Potteti | bf8af29 | 2017-02-15 15:28:39 +0530 | [diff] [blame] | 5446 | dut->default_11na_ap_chwidth == AP_40))) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5447 | if (is_ht40plus_chan(dut->ap_channel)) |
Tamizh chelvam | 431c600 | 2017-03-07 17:07:16 +0530 | [diff] [blame] | 5448 | ht40plus = 1; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5449 | else if (is_ht40minus_chan(dut->ap_channel)) |
Tamizh chelvam | 431c600 | 2017-03-07 17:07:16 +0530 | [diff] [blame] | 5450 | ht40minus = 1; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5451 | } |
Mohammed Shafi Shajakhan | 31d8a15 | 2016-06-02 20:10:55 +0530 | [diff] [blame] | 5452 | |
| 5453 | if (dut->ap_tx_stbc) |
Tamizh chelvam | 431c600 | 2017-03-07 17:07:16 +0530 | [diff] [blame] | 5454 | tx_stbc = 1; |
Mohammed Shafi Shajakhan | 31d8a15 | 2016-06-02 20:10:55 +0530 | [diff] [blame] | 5455 | |
Pradeep Reddy Potteti | 4b0cdee | 2017-03-15 12:37:33 +0530 | [diff] [blame] | 5456 | /* Overwrite the ht_capab with offset value if configured */ |
| 5457 | if (dut->ap_chwidth == AP_40 && |
| 5458 | dut->ap_chwidth_offset == SEC_CH_40ABOVE) { |
| 5459 | ht40plus = 1; |
| 5460 | ht40minus = 0; |
| 5461 | } else if (dut->ap_chwidth == AP_40 && |
| 5462 | dut->ap_chwidth_offset == SEC_CH_40BELOW) { |
| 5463 | ht40minus = 1; |
| 5464 | ht40plus = 0; |
| 5465 | } |
| 5466 | |
Tamizh chelvam | 431c600 | 2017-03-07 17:07:16 +0530 | [diff] [blame] | 5467 | fprintf(f, "ht_capab=%s%s%s\n", |
| 5468 | ht40plus ? "[HT40+]" : "", |
| 5469 | ht40minus ? "[HT40-]" : "", |
| 5470 | tx_stbc ? "[TX-STBC]" : ""); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5471 | } |
| 5472 | |
Sreelakshmi Konamki | b692f10 | 2016-04-26 19:47:00 +0530 | [diff] [blame] | 5473 | if ((drv == DRIVER_MAC80211 || drv == DRIVER_QNXNTO || |
| 5474 | drv == DRIVER_LINUX_WCN) && |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5475 | dut->ap_mode == AP_11ac) { |
| 5476 | fprintf(f, "ieee80211ac=1\n" |
| 5477 | "ieee80211n=1\n" |
| 5478 | "ht_capab=[HT40+]\n"); |
| 5479 | } |
| 5480 | |
Sreelakshmi Konamki | b692f10 | 2016-04-26 19:47:00 +0530 | [diff] [blame] | 5481 | if ((drv == DRIVER_MAC80211 || drv == DRIVER_QNXNTO || |
| 5482 | drv == DRIVER_LINUX_WCN) && |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5483 | (dut->ap_mode == AP_11ac || dut->ap_mode == AP_11na)) { |
| 5484 | if (dut->ap_countrycode[0]) { |
| 5485 | fprintf(f, "country_code=%s\n", dut->ap_countrycode); |
| 5486 | fprintf(f, "ieee80211d=1\n"); |
| 5487 | fprintf(f, "ieee80211h=1\n"); |
| 5488 | } |
| 5489 | } |
| 5490 | |
| 5491 | fprintf(f, "interface=%s\n", ifname); |
| 5492 | if (dut->bridge) |
| 5493 | fprintf(f, "bridge=%s\n", dut->bridge); |
| 5494 | fprintf(f, "channel=%d\n", dut->ap_channel); |
| 5495 | |
| 5496 | if (sigma_hapd_ctrl) |
| 5497 | fprintf(f, "ctrl_interface=%s\n", sigma_hapd_ctrl); |
| 5498 | else |
| 5499 | fprintf(f, "ctrl_interface=/var/run/hostapd\n"); |
| 5500 | |
| 5501 | if (dut->ap_ssid[0]) |
| 5502 | fprintf(f, "ssid=%s\n", dut->ap_ssid); |
| 5503 | else |
| 5504 | fprintf(f, "ssid=QCA AP OOB\n"); |
| 5505 | if (dut->ap_bcnint) |
| 5506 | fprintf(f, "beacon_int=%d\n", dut->ap_bcnint); |
| 5507 | |
| 5508 | switch (dut->ap_key_mgmt) { |
| 5509 | case AP_OPEN: |
| 5510 | if (dut->ap_cipher == AP_WEP) |
| 5511 | fprintf(f, "wep_key0=%s\n", dut->ap_wepkey); |
| 5512 | break; |
| 5513 | case AP_WPA2_PSK: |
| 5514 | case AP_WPA2_PSK_MIXED: |
| 5515 | case AP_WPA_PSK: |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 5516 | case AP_WPA2_SAE: |
| 5517 | case AP_WPA2_PSK_SAE: |
| 5518 | if (dut->ap_key_mgmt == AP_WPA2_PSK || |
| 5519 | dut->ap_key_mgmt == AP_WPA2_SAE || |
| 5520 | dut->ap_key_mgmt == AP_WPA2_PSK_SAE) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5521 | fprintf(f, "wpa=2\n"); |
| 5522 | else if (dut->ap_key_mgmt == AP_WPA2_PSK_MIXED) |
| 5523 | fprintf(f, "wpa=3\n"); |
| 5524 | else |
| 5525 | fprintf(f, "wpa=1\n"); |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 5526 | if (dut->ap_key_mgmt == AP_WPA2_SAE) |
| 5527 | key_mgmt = "SAE"; |
| 5528 | else if (dut->ap_key_mgmt == AP_WPA2_PSK_SAE) |
| 5529 | key_mgmt = "WPA-PSK SAE"; |
| 5530 | else |
| 5531 | key_mgmt = "WPA-PSK"; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5532 | switch (dut->ap_pmf) { |
| 5533 | case AP_PMF_DISABLED: |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 5534 | fprintf(f, "wpa_key_mgmt=%s%s\n", key_mgmt, |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5535 | dut->ap_add_sha256 ? " WPA-PSK-SHA256" : ""); |
| 5536 | break; |
| 5537 | case AP_PMF_OPTIONAL: |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 5538 | fprintf(f, "wpa_key_mgmt=%s%s\n", key_mgmt, |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5539 | dut->ap_add_sha256 ? " WPA-PSK-SHA256" : ""); |
| 5540 | break; |
| 5541 | case AP_PMF_REQUIRED: |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 5542 | if (dut->ap_key_mgmt == AP_WPA2_SAE) |
| 5543 | key_mgmt = "SAE"; |
| 5544 | else if (dut->ap_key_mgmt == AP_WPA2_PSK_SAE) |
| 5545 | key_mgmt = "WPA-PSK-SHA256 SAE"; |
| 5546 | else |
| 5547 | key_mgmt = "WPA-PSK-SHA256"; |
| 5548 | fprintf(f, "wpa_key_mgmt=%s\n", key_mgmt); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5549 | break; |
| 5550 | } |
| 5551 | if (dut->ap_cipher == AP_CCMP_TKIP) |
| 5552 | fprintf(f, "wpa_pairwise=CCMP TKIP\n"); |
| 5553 | else if (dut->ap_cipher == AP_TKIP) |
| 5554 | fprintf(f, "wpa_pairwise=TKIP\n"); |
| 5555 | else |
| 5556 | fprintf(f, "wpa_pairwise=CCMP\n"); |
| 5557 | fprintf(f, "wpa_passphrase=%s\n", dut->ap_passphrase); |
| 5558 | break; |
| 5559 | case AP_WPA2_EAP: |
| 5560 | case AP_WPA2_EAP_MIXED: |
| 5561 | case AP_WPA_EAP: |
| 5562 | fprintf(f, "ieee8021x=1\n"); |
| 5563 | if (dut->ap_key_mgmt == AP_WPA2_EAP) |
| 5564 | fprintf(f, "wpa=2\n"); |
| 5565 | else if (dut->ap_key_mgmt == AP_WPA2_EAP_MIXED) |
| 5566 | fprintf(f, "wpa=3\n"); |
| 5567 | else |
| 5568 | fprintf(f, "wpa=1\n"); |
| 5569 | switch (dut->ap_pmf) { |
| 5570 | case AP_PMF_DISABLED: |
| 5571 | fprintf(f, "wpa_key_mgmt=WPA-EAP%s\n", |
| 5572 | dut->ap_add_sha256 ? " WPA-EAP-SHA256" : ""); |
| 5573 | break; |
| 5574 | case AP_PMF_OPTIONAL: |
| 5575 | fprintf(f, "wpa_key_mgmt=WPA-EAP%s\n", |
| 5576 | dut->ap_add_sha256 ? " WPA-EAP-SHA256" : ""); |
| 5577 | break; |
| 5578 | case AP_PMF_REQUIRED: |
| 5579 | fprintf(f, "wpa_key_mgmt=WPA-EAP-SHA256\n"); |
| 5580 | break; |
| 5581 | } |
| 5582 | if (dut->ap_cipher == AP_CCMP_TKIP) |
| 5583 | fprintf(f, "wpa_pairwise=CCMP TKIP\n"); |
| 5584 | else if (dut->ap_cipher == AP_TKIP) |
| 5585 | fprintf(f, "wpa_pairwise=TKIP\n"); |
| 5586 | else |
| 5587 | fprintf(f, "wpa_pairwise=CCMP\n"); |
| 5588 | fprintf(f, "auth_server_addr=%s\n", dut->ap_radius_ipaddr); |
| 5589 | if (dut->ap_radius_port) |
| 5590 | fprintf(f, "auth_server_port=%d\n", |
| 5591 | dut->ap_radius_port); |
| 5592 | fprintf(f, "auth_server_shared_secret=%s\n", |
| 5593 | dut->ap_radius_password); |
| 5594 | break; |
Jouni Malinen | ad395a2 | 2017-09-01 21:13:46 +0300 | [diff] [blame] | 5595 | case AP_SUITEB: |
| 5596 | fprintf(f, "ieee8021x=1\n"); |
| 5597 | fprintf(f, "wpa=2\n"); |
| 5598 | fprintf(f, "wpa_key_mgmt=WPA-EAP-SUITE-B-192\n"); |
| 5599 | fprintf(f, "wpa_pairwise=GCMP-256\n"); |
| 5600 | fprintf(f, "group_mgmt_cipher=BIP-GMAC-256\n"); |
| 5601 | fprintf(f, "auth_server_addr=%s\n", dut->ap_radius_ipaddr); |
| 5602 | if (dut->ap_radius_port) |
| 5603 | fprintf(f, "auth_server_port=%d\n", |
| 5604 | dut->ap_radius_port); |
| 5605 | fprintf(f, "auth_server_shared_secret=%s\n", |
| 5606 | dut->ap_radius_password); |
| 5607 | break; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5608 | } |
| 5609 | |
Anilkumar Kolli | f0fd599 | 2017-02-23 12:54:01 +0530 | [diff] [blame] | 5610 | if (dut->ap_rsn_preauth) |
| 5611 | fprintf(f, "rsn_preauth=1\n"); |
| 5612 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5613 | switch (dut->ap_pmf) { |
| 5614 | case AP_PMF_DISABLED: |
| 5615 | break; |
| 5616 | case AP_PMF_OPTIONAL: |
| 5617 | fprintf(f, "ieee80211w=1\n"); |
| 5618 | break; |
| 5619 | case AP_PMF_REQUIRED: |
| 5620 | fprintf(f, "ieee80211w=2\n"); |
| 5621 | break; |
| 5622 | } |
| 5623 | |
Jouni Malinen | 3c367e8 | 2017-06-23 17:01:47 +0300 | [diff] [blame] | 5624 | if (dut->rsne_override) |
| 5625 | fprintf(f, "own_ie_override=%s\n", dut->rsne_override); |
| 5626 | |
Jouni Malinen | 6814313 | 2017-09-02 02:34:08 +0300 | [diff] [blame] | 5627 | if (dut->sae_commit_override) |
| 5628 | fprintf(f, "sae_commit_override=%s\n", |
| 5629 | dut->sae_commit_override); |
| 5630 | |
Jouni Malinen | ed670f4 | 2017-08-31 01:39:28 +0300 | [diff] [blame] | 5631 | if (dut->ap_sae_groups) |
| 5632 | fprintf(f, "sae_groups=%s\n", dut->ap_sae_groups); |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 5633 | |
Jouni Malinen | 2f524ce | 2017-08-31 01:43:29 +0300 | [diff] [blame] | 5634 | if (dut->sae_anti_clogging_threshold >= 0) |
| 5635 | fprintf(f, "sae_anti_clogging_threshold=%d\n", |
| 5636 | dut->sae_anti_clogging_threshold); |
Jouni Malinen | b347db0 | 2017-09-02 01:36:03 +0300 | [diff] [blame] | 5637 | if (dut->sae_reflection) |
| 5638 | fprintf(f, "sae_reflection_attack=1\n"); |
Jouni Malinen | 2f524ce | 2017-08-31 01:43:29 +0300 | [diff] [blame] | 5639 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5640 | if (dut->ap_p2p_mgmt) |
| 5641 | fprintf(f, "manage_p2p=1\n"); |
| 5642 | |
| 5643 | if (dut->ap_tdls_prohibit || dut->ap_l2tif) |
| 5644 | fprintf(f, "tdls_prohibit=1\n"); |
| 5645 | if (dut->ap_tdls_prohibit_chswitch || dut->ap_l2tif) |
| 5646 | fprintf(f, "tdls_prohibit_chan_switch=1\n"); |
| 5647 | if (dut->ap_p2p_cross_connect >= 0) { |
| 5648 | fprintf(f, "manage_p2p=1\n" |
| 5649 | "allow_cross_connection=%d\n", |
| 5650 | dut->ap_p2p_cross_connect); |
| 5651 | } |
| 5652 | |
| 5653 | if (dut->ap_l2tif || dut->ap_proxy_arp) { |
| 5654 | if (!dut->bridge) { |
| 5655 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5656 | "Bridge must be configured. Run with -b <brname>."); |
| 5657 | fclose(f); |
| 5658 | return -2; |
| 5659 | } |
| 5660 | fprintf(f, "ap_isolate=1\n"); |
| 5661 | } |
| 5662 | |
| 5663 | if (dut->ap_proxy_arp) |
| 5664 | fprintf(f, "proxy_arp=1\n"); |
| 5665 | |
Pradeep Reddy POTTETI | 0d3db63 | 2016-03-11 15:21:11 +0530 | [diff] [blame] | 5666 | if (dut->ap_wme) |
| 5667 | fprintf(f, "wmm_enabled=1\n"); |
| 5668 | |
Mohammed Shafi Shajakhan | 02e3b82 | 2017-02-23 04:15:02 +0530 | [diff] [blame] | 5669 | if (dut->ap_wmmps == AP_WMMPS_ON) |
| 5670 | fprintf(f, "uapsd_advertisement_enabled=1\n"); |
| 5671 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5672 | if (dut->ap_hs2) { |
| 5673 | if (dut->ap_bss_load) { |
| 5674 | char *bss_load; |
| 5675 | |
| 5676 | switch (dut->ap_bss_load) { |
| 5677 | case -1: |
| 5678 | bss_load = "bss_load_update_period=10"; |
| 5679 | break; |
| 5680 | case 1: |
| 5681 | /* STA count: 1, CU: 50, AAC: 65535 */ |
| 5682 | bss_load = "bss_load_test=1:50:65535"; |
| 5683 | break; |
| 5684 | case 2: |
| 5685 | /* STA count: 1, CU: 200, AAC: 65535 */ |
| 5686 | bss_load = "bss_load_test=1:200:65535"; |
| 5687 | break; |
| 5688 | case 3: |
| 5689 | /* STA count: 1, CU: 75, AAC: 65535 */ |
| 5690 | bss_load = "bss_load_test=1:75:65535"; |
| 5691 | break; |
| 5692 | default: |
| 5693 | bss_load = NULL; |
| 5694 | break; |
| 5695 | } |
| 5696 | |
| 5697 | if (!bss_load) { |
| 5698 | fclose(f); |
| 5699 | return -2; |
| 5700 | } |
| 5701 | fprintf(f, "%s\n", bss_load); |
| 5702 | } |
| 5703 | |
| 5704 | if (append_hostapd_conf_hs2(dut, f)) { |
| 5705 | fclose(f); |
| 5706 | return -2; |
| 5707 | } |
| 5708 | } |
| 5709 | |
| 5710 | if (dut->ap_interworking && append_hostapd_conf_interworking(dut, f)) { |
| 5711 | fclose(f); |
| 5712 | return -2; |
| 5713 | } |
| 5714 | |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 5715 | if (dut->ap_hs2 && strlen(dut->ap_tag_ssid[0])) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5716 | unsigned char bssid[6]; |
| 5717 | char ifname2[50]; |
| 5718 | |
Pradeep Reddy POTTETI | 673d85c | 2016-07-26 19:08:07 +0530 | [diff] [blame] | 5719 | if (get_hwaddr(ifname, bssid)) { |
| 5720 | fclose(f); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5721 | return -2; |
Pradeep Reddy POTTETI | 673d85c | 2016-07-26 19:08:07 +0530 | [diff] [blame] | 5722 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5723 | bssid[0] |= 0x02; |
| 5724 | |
| 5725 | snprintf(ifname2, sizeof(ifname2), "%s_1", ifname); |
| 5726 | fprintf(f, "bss=%s_1\n", ifname2); |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 5727 | fprintf(f, "ssid=%s\n", dut->ap_tag_ssid[0]); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5728 | if (dut->bridge) |
| 5729 | fprintf(f, "bridge=%s\n", dut->bridge); |
| 5730 | fprintf(f, "bssid=%02x:%02x:%02x:%02x:%02x:%02x\n", |
| 5731 | bssid[0], bssid[1], bssid[2], bssid[3], |
| 5732 | bssid[4], bssid[5]); |
| 5733 | |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 5734 | if (dut->ap_tag_key_mgmt[0] == AP2_OSEN) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5735 | fprintf(f, "osen=1\n"); |
| 5736 | if (strlen(dut->ap2_radius_ipaddr)) |
| 5737 | fprintf(f, "auth_server_addr=%s\n", |
| 5738 | dut->ap2_radius_ipaddr); |
| 5739 | if (dut->ap2_radius_port) |
| 5740 | fprintf(f, "auth_server_port=%d\n", |
| 5741 | dut->ap2_radius_port); |
| 5742 | if (strlen(dut->ap2_radius_password)) |
| 5743 | fprintf(f, "auth_server_shared_secret=%s\n", |
| 5744 | dut->ap2_radius_password); |
| 5745 | } |
| 5746 | |
| 5747 | if (dut->ap2_proxy_arp) { |
| 5748 | if (!dut->bridge) { |
| 5749 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5750 | "Bridge must be configured. Run with -b <brname>."); |
| 5751 | fclose(f); |
| 5752 | return -2; |
| 5753 | } |
| 5754 | fprintf(f, "ap_isolate=1\n"); |
| 5755 | fprintf(f, "proxy_arp=1\n"); |
| 5756 | |
| 5757 | if (set_ebtables_proxy_arp(dut, "FORWARD", ifname2) || |
| 5758 | set_ebtables_proxy_arp(dut, "OUTPUT", ifname2)) { |
| 5759 | fclose(f); |
| 5760 | return -2; |
| 5761 | } |
| 5762 | |
| 5763 | } |
| 5764 | } |
| 5765 | |
| 5766 | if (dut->program == PROGRAM_WPS) { |
| 5767 | fprintf(f, "eap_server=1\n" |
| 5768 | "wps_state=1\n" |
| 5769 | "device_name=QCA AP\n" |
| 5770 | "manufacturer=QCA\n" |
| 5771 | "device_type=6-0050F204-1\n" |
| 5772 | "config_methods=label virtual_display " |
| 5773 | "virtual_push_button keypad%s\n" |
| 5774 | "ap_pin=12345670\n" |
| 5775 | "friendly_name=QCA Access Point\n" |
| 5776 | "upnp_iface=%s\n", |
| 5777 | dut->ap_wpsnfc ? " nfc_interface ext_nfc_token" : "", |
| 5778 | dut->bridge ? dut->bridge : ifname); |
| 5779 | } |
| 5780 | |
| 5781 | if (dut->program == PROGRAM_VHT) { |
| 5782 | int vht_oper_centr_freq_idx; |
| 5783 | |
| 5784 | if (check_channel(dut->ap_channel) < 0) { |
| 5785 | send_resp(dut, conn, SIGMA_INVALID, |
| 5786 | "errorCode,Invalid channel"); |
Pradeep Reddy POTTETI | 673d85c | 2016-07-26 19:08:07 +0530 | [diff] [blame] | 5787 | fclose(f); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5788 | return 0; |
| 5789 | } |
| 5790 | |
| 5791 | switch (dut->ap_chwidth) { |
| 5792 | case AP_20: |
| 5793 | dut->ap_vht_chwidth = AP_20_40_VHT_OPER_CHWIDTH; |
| 5794 | vht_oper_centr_freq_idx = |
| 5795 | get_oper_centr_freq_seq_idx(20, |
| 5796 | dut->ap_channel); |
| 5797 | break; |
| 5798 | case AP_40: |
| 5799 | dut->ap_vht_chwidth = AP_20_40_VHT_OPER_CHWIDTH; |
| 5800 | vht_oper_centr_freq_idx = |
| 5801 | get_oper_centr_freq_seq_idx(40, |
| 5802 | dut->ap_channel); |
| 5803 | break; |
| 5804 | case AP_80: |
| 5805 | dut->ap_vht_chwidth = AP_80_VHT_OPER_CHWIDTH; |
| 5806 | vht_oper_centr_freq_idx = |
| 5807 | get_oper_centr_freq_seq_idx(80, |
| 5808 | dut->ap_channel); |
| 5809 | break; |
| 5810 | case AP_160: |
| 5811 | dut->ap_vht_chwidth = AP_160_VHT_OPER_CHWIDTH; |
| 5812 | vht_oper_centr_freq_idx = |
| 5813 | get_oper_centr_freq_seq_idx(160, |
| 5814 | dut->ap_channel); |
| 5815 | break; |
| 5816 | default: |
| 5817 | dut->ap_vht_chwidth = VHT_DEFAULT_OPER_CHWIDTH; |
| 5818 | vht_oper_centr_freq_idx = |
| 5819 | get_oper_centr_freq_seq_idx(80, |
| 5820 | dut->ap_channel); |
| 5821 | break; |
| 5822 | } |
| 5823 | fprintf(f, "vht_oper_centr_freq_seg0_idx=%d\n", |
| 5824 | vht_oper_centr_freq_idx); |
| 5825 | fprintf(f, "vht_oper_chwidth=%d\n", dut->ap_vht_chwidth); |
| 5826 | |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 5827 | if (dut->ap_sgi80 || dut->ap_txBF || |
| 5828 | dut->ap_ldpc != VALUE_NOT_SET || |
Mohammed Shafi Shajakhan | f3e68d9 | 2016-06-02 20:10:57 +0530 | [diff] [blame] | 5829 | dut->ap_tx_stbc || dut->ap_mu_txBF) { |
| 5830 | fprintf(f, "vht_capab=%s%s%s%s%s\n", |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5831 | dut->ap_sgi80 ? "[SHORT-GI-80]" : "", |
Mohammed Shafi Shajakhan | c039ce3 | 2016-06-02 20:10:58 +0530 | [diff] [blame] | 5832 | dut->ap_txBF ? |
Tamizh chelvam | 8312f6d | 2016-06-02 20:10:59 +0530 | [diff] [blame] | 5833 | "[SU-BEAMFORMER][SU-BEAMFORMEE][BF-ANTENNA-2][SOUNDING-DIMENSION-2]" : "", |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 5834 | (dut->ap_ldpc == VALUE_ENABLED) ? |
| 5835 | "[RXLDPC]" : "", |
Mohammed Shafi Shajakhan | f3e68d9 | 2016-06-02 20:10:57 +0530 | [diff] [blame] | 5836 | dut->ap_tx_stbc ? "[TX-STBC-2BY1]" : "", |
| 5837 | dut->ap_mu_txBF ? "[MU-BEAMFORMER]" : ""); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5838 | } |
| 5839 | } |
| 5840 | |
| 5841 | fclose(f); |
Jouni Malinen | d6bf1b4 | 2017-06-23 17:51:01 +0300 | [diff] [blame] | 5842 | if (dut->use_hostapd_pid_file) |
| 5843 | kill_hostapd_process_pid(dut); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5844 | #ifdef __QNXNTO__ |
| 5845 | if (system("slay hostapd") == 0) |
| 5846 | #else /* __QNXNTO__ */ |
Jouni Malinen | d6bf1b4 | 2017-06-23 17:51:01 +0300 | [diff] [blame] | 5847 | if (!dut->use_hostapd_pid_file && |
| 5848 | (kill_process(dut, "(hostapd)", 1, SIGTERM) == 0 || |
| 5849 | system("killall hostapd") == 0)) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5850 | #endif /* __QNXNTO__ */ |
| 5851 | { |
| 5852 | int i; |
| 5853 | /* Wait some time to allow hostapd to complete cleanup before |
| 5854 | * starting a new process */ |
| 5855 | for (i = 0; i < 10; i++) { |
| 5856 | usleep(500000); |
| 5857 | #ifdef __QNXNTO__ |
| 5858 | if (system("pidin | grep hostapd") != 0) |
| 5859 | break; |
| 5860 | #else /* __QNXNTO__ */ |
| 5861 | if (system("pidof hostapd") != 0) |
| 5862 | break; |
| 5863 | #endif /* __QNXNTO__ */ |
| 5864 | } |
| 5865 | } |
Jouni Malinen | d86e582 | 2017-08-29 03:55:32 +0300 | [diff] [blame] | 5866 | dut->hostapd_running = 0; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5867 | |
Pradeep Reddy POTTETI | a076c30 | 2016-05-16 13:36:07 +0530 | [diff] [blame] | 5868 | #ifdef ANDROID |
| 5869 | /* Set proper conf file permissions so that hostapd process |
| 5870 | * can access it. |
| 5871 | */ |
| 5872 | if (chmod(SIGMA_TMPDIR "/sigma_dut-ap.conf", |
| 5873 | S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP) < 0) |
| 5874 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5875 | "Error changing permissions"); |
| 5876 | |
| 5877 | if (chown(SIGMA_TMPDIR "/sigma_dut-ap.conf", -1, AID_WIFI) < 0) |
| 5878 | sigma_dut_print(dut, DUT_MSG_ERROR, "Error changing groupid"); |
| 5879 | #endif /* ANDROID */ |
| 5880 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5881 | if (drv == DRIVER_QNXNTO) { |
| 5882 | snprintf(buf, sizeof(buf), |
Pradeep Reddy POTTETI | bf4a974 | 2016-02-04 12:32:30 +0530 | [diff] [blame] | 5883 | "hostapd -B %s%s %s%s" SIGMA_TMPDIR |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5884 | "/sigma_dut-ap.conf", |
| 5885 | dut->hostapd_debug_log ? "-ddKt -f " : "", |
| 5886 | dut->hostapd_debug_log ? dut->hostapd_debug_log : "", |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5887 | dut->hostapd_entropy_log ? " -e" : "", |
| 5888 | dut->hostapd_entropy_log ? dut->hostapd_entropy_log : |
| 5889 | ""); |
| 5890 | } else { |
| 5891 | /* |
| 5892 | * It looks like a monitor interface can cause some issues for |
| 5893 | * beaconing, so remove it (if injection was used) before |
| 5894 | * starting hostapd. |
| 5895 | */ |
| 5896 | if (if_nametoindex("sigmadut") > 0 && |
| 5897 | system("iw dev sigmadut del") != 0) |
| 5898 | sigma_dut_print(dut, DUT_MSG_ERROR, "Failed to remove " |
| 5899 | "monitor interface"); |
| 5900 | |
Jouni Malinen | d6bf1b4 | 2017-06-23 17:51:01 +0300 | [diff] [blame] | 5901 | snprintf(path, sizeof(path), "%shostapd", |
| 5902 | file_exists("hostapd") ? "./" : ""); |
| 5903 | 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] | 5904 | "/sigma_dut-ap.conf", |
Jouni Malinen | d6bf1b4 | 2017-06-23 17:51:01 +0300 | [diff] [blame] | 5905 | dut->hostapd_bin ? dut->hostapd_bin : path, |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5906 | dut->hostapd_debug_log ? " -ddKt -f" : "", |
| 5907 | dut->hostapd_debug_log ? dut->hostapd_debug_log : "", |
| 5908 | dut->hostapd_entropy_log ? " -e" : "", |
| 5909 | dut->hostapd_entropy_log ? dut->hostapd_entropy_log : |
Jouni Malinen | d6bf1b4 | 2017-06-23 17:51:01 +0300 | [diff] [blame] | 5910 | "", |
| 5911 | dut->use_hostapd_pid_file ? |
| 5912 | " -P " SIGMA_DUT_HOSTAPD_PID_FILE : ""); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5913 | } |
| 5914 | |
Jouni Malinen | d6bf1b4 | 2017-06-23 17:51:01 +0300 | [diff] [blame] | 5915 | sigma_dut_print(dut, DUT_MSG_DEBUG, "hostapd command: %s", buf); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5916 | if (system(buf) != 0) { |
| 5917 | send_resp(dut, conn, SIGMA_ERROR, |
| 5918 | "errorCode,Failed to start hostapd"); |
| 5919 | return 0; |
| 5920 | } |
| 5921 | |
| 5922 | /* allow some time for hostapd to start before returning success */ |
| 5923 | usleep(500000); |
| 5924 | if (run_hostapd_cli(dut, "ping") != 0) { |
| 5925 | send_resp(dut, conn, SIGMA_ERROR, |
| 5926 | "errorCode,Failed to talk to hostapd"); |
| 5927 | return 0; |
| 5928 | } |
| 5929 | |
Pradeep Reddy Potteti | 923a9b3 | 2017-06-14 12:18:59 +0530 | [diff] [blame] | 5930 | if (drv == DRIVER_LINUX_WCN) { |
| 5931 | sigma_dut_print(dut, DUT_MSG_INFO, "setting ip addr %s mask %s", |
| 5932 | ap_inet_addr, ap_inet_mask); |
| 5933 | snprintf(buf, sizeof(buf), "ifconfig %s %s netmask %s up", |
| 5934 | ifname, ap_inet_addr, ap_inet_mask); |
| 5935 | if (system(buf) != 0) { |
| 5936 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5937 | "Failed to initialize the interface"); |
| 5938 | return -1; |
| 5939 | } |
| 5940 | } |
| 5941 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5942 | if (dut->ap_l2tif) { |
| 5943 | snprintf(path, sizeof(path), |
| 5944 | "/sys/class/net/%s/brport/hairpin_mode", |
| 5945 | ifname); |
| 5946 | if (!file_exists(path)) { |
| 5947 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5948 | "%s must be binded to the bridge for L2TIF", |
| 5949 | ifname); |
| 5950 | return -2; |
| 5951 | } |
| 5952 | |
| 5953 | snprintf(buf, sizeof(buf), "echo 1 > %s", path); |
| 5954 | if (system(buf) != 0) { |
| 5955 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5956 | "Failed to enable hairpin_mode for L2TIF"); |
| 5957 | return -2; |
| 5958 | } |
| 5959 | |
| 5960 | snprintf(buf, sizeof(buf), "ebtables -P FORWARD ACCEPT"); |
| 5961 | if (system(buf) != 0) { |
| 5962 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5963 | "Failed to set ebtables rules, RULE-9"); |
| 5964 | return -2; |
| 5965 | } |
| 5966 | |
| 5967 | snprintf(buf, sizeof(buf), |
| 5968 | "ebtables -A FORWARD -p IPv4 --ip-proto icmp -i %s -j DROP", |
| 5969 | ifname); |
| 5970 | if (system(buf) != 0) { |
| 5971 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5972 | "Failed to set ebtables rules, RULE-11"); |
| 5973 | return -2; |
| 5974 | } |
| 5975 | } |
| 5976 | |
| 5977 | if (dut->ap_proxy_arp) { |
| 5978 | if (dut->ap_dgaf_disable) { |
| 5979 | if (set_ebtables_disable_dgaf(dut, "FORWARD", ifname) || |
| 5980 | set_ebtables_disable_dgaf(dut, "OUTPUT", ifname)) |
| 5981 | return -2; |
| 5982 | } else { |
| 5983 | if (set_ebtables_proxy_arp(dut, "FORWARD", ifname) || |
| 5984 | set_ebtables_proxy_arp(dut, "OUTPUT", ifname)) |
| 5985 | return -2; |
| 5986 | } |
| 5987 | |
| 5988 | /* For 4.5-(c) */ |
| 5989 | snprintf(buf, sizeof(buf), |
| 5990 | "ebtables -A FORWARD -p ARP --arp-opcode 2 -i %s -j DROP", |
| 5991 | ifname); |
| 5992 | if (system(buf) != 0) { |
| 5993 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5994 | "Failed to set ebtables rules, RULE-10"); |
| 5995 | return -2; |
| 5996 | } |
| 5997 | } |
| 5998 | |
| 5999 | if (dut->ap_tdls_prohibit || dut->ap_l2tif) { |
| 6000 | /* Drop TDLS frames */ |
| 6001 | snprintf(buf, sizeof(buf), |
| 6002 | "ebtables -A FORWARD -p 0x890d -i %s -j DROP", ifname); |
| 6003 | if (system(buf) != 0) { |
| 6004 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 6005 | "Failed to set ebtables rules, RULE-13"); |
| 6006 | return -2; |
| 6007 | } |
| 6008 | } |
| 6009 | |
| 6010 | if (dut->ap_fake_pkhash && |
| 6011 | run_hostapd_cli(dut, "set wps_corrupt_pkhash 1") != 0) { |
| 6012 | send_resp(dut, conn, SIGMA_ERROR, |
| 6013 | "errorCode,Could not enable FakePubKey"); |
| 6014 | return 0; |
| 6015 | } |
| 6016 | |
Jouni Malinen | d86e582 | 2017-08-29 03:55:32 +0300 | [diff] [blame] | 6017 | dut->hostapd_running = 1; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6018 | return 1; |
| 6019 | } |
| 6020 | |
| 6021 | |
Pradeep Reddy POTTETI | eff4611 | 2016-10-13 17:22:03 +0530 | [diff] [blame] | 6022 | static int parse_qos_params(struct sigma_dut *dut, struct sigma_conn *conn, |
| 6023 | struct qos_params *qos, const char *cwmin, |
| 6024 | const char *cwmax, const char *aifs, |
| 6025 | const char *txop, const char *acm) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6026 | { |
Pradeep Reddy POTTETI | eff4611 | 2016-10-13 17:22:03 +0530 | [diff] [blame] | 6027 | int val; |
| 6028 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6029 | if (cwmin) { |
| 6030 | qos->ac = 1; |
Pradeep Reddy POTTETI | eff4611 | 2016-10-13 17:22:03 +0530 | [diff] [blame] | 6031 | val = atoi(cwmin); |
| 6032 | if (val < 0 || val > 15) { |
| 6033 | send_resp(dut, conn, SIGMA_INVALID, |
| 6034 | "errorCode,Invalid cwMin"); |
| 6035 | return 0; |
| 6036 | } |
| 6037 | qos->cwmin = val; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6038 | } |
| 6039 | |
| 6040 | if (cwmax) { |
| 6041 | qos->ac = 1; |
Pradeep Reddy POTTETI | eff4611 | 2016-10-13 17:22:03 +0530 | [diff] [blame] | 6042 | val = atoi(cwmax); |
| 6043 | if (val < 0 || val > 15) { |
| 6044 | send_resp(dut, conn, SIGMA_INVALID, |
| 6045 | "errorCode,Invalid cwMax"); |
| 6046 | return 0; |
| 6047 | } |
| 6048 | qos->cwmax = val; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6049 | } |
| 6050 | |
| 6051 | if (aifs) { |
| 6052 | qos->ac = 1; |
Pradeep Reddy POTTETI | eff4611 | 2016-10-13 17:22:03 +0530 | [diff] [blame] | 6053 | val = atoi(aifs); |
| 6054 | if (val < 1 || val > 255) { |
| 6055 | send_resp(dut, conn, SIGMA_INVALID, |
| 6056 | "errorCode,Invalid AIFS"); |
| 6057 | return 0; |
| 6058 | } |
| 6059 | qos->aifs = val; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6060 | } |
| 6061 | |
| 6062 | if (txop) { |
| 6063 | qos->ac = 1; |
Pradeep Reddy POTTETI | eff4611 | 2016-10-13 17:22:03 +0530 | [diff] [blame] | 6064 | val = atoi(txop); |
| 6065 | if (val < 0 || val > 0xffff) { |
| 6066 | send_resp(dut, conn, SIGMA_INVALID, |
| 6067 | "errorCode,Invalid txop"); |
| 6068 | return 0; |
| 6069 | } |
| 6070 | qos->txop = val * 32; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6071 | } |
| 6072 | |
| 6073 | if (acm) { |
| 6074 | qos->ac = 1; |
| 6075 | qos->acm = strcasecmp(acm, "on") == 0; |
| 6076 | } |
Pradeep Reddy POTTETI | eff4611 | 2016-10-13 17:22:03 +0530 | [diff] [blame] | 6077 | |
| 6078 | return 1; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6079 | } |
| 6080 | |
| 6081 | |
| 6082 | static int cmd_ap_set_apqos(struct sigma_dut *dut, struct sigma_conn *conn, |
| 6083 | struct sigma_cmd *cmd) |
| 6084 | { |
| 6085 | /* TXOP: The values provided here for VHT5G only */ |
Pradeep Reddy POTTETI | eff4611 | 2016-10-13 17:22:03 +0530 | [diff] [blame] | 6086 | if (!parse_qos_params(dut, conn, &dut->ap_qos[AP_AC_VO], |
| 6087 | get_param(cmd, "cwmin_VO"), |
| 6088 | get_param(cmd, "cwmax_VO"), |
| 6089 | get_param(cmd, "AIFS_VO"), |
| 6090 | get_param(cmd, "TXOP_VO"), |
| 6091 | get_param(cmd, "ACM_VO")) || |
| 6092 | !parse_qos_params(dut, conn, &dut->ap_qos[AP_AC_VI], |
| 6093 | get_param(cmd, "cwmin_VI"), |
| 6094 | get_param(cmd, "cwmax_VI"), |
| 6095 | get_param(cmd, "AIFS_VI"), |
| 6096 | get_param(cmd, "TXOP_VI"), |
| 6097 | get_param(cmd, "ACM_VI")) || |
| 6098 | !parse_qos_params(dut, conn, &dut->ap_qos[AP_AC_BE], |
| 6099 | get_param(cmd, "cwmin_BE"), |
| 6100 | get_param(cmd, "cwmax_BE"), |
| 6101 | get_param(cmd, "AIFS_BE"), |
| 6102 | get_param(cmd, "TXOP_BE"), |
| 6103 | get_param(cmd, "ACM_BE")) || |
| 6104 | !parse_qos_params(dut, conn, &dut->ap_qos[AP_AC_BK], |
| 6105 | get_param(cmd, "cwmin_BK"), |
| 6106 | get_param(cmd, "cwmax_BK"), |
| 6107 | get_param(cmd, "AIFS_BK"), |
| 6108 | get_param(cmd, "TXOP_BK"), |
| 6109 | get_param(cmd, "ACM_BK"))) |
| 6110 | return 0; |
| 6111 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6112 | return 1; |
| 6113 | } |
| 6114 | |
| 6115 | |
| 6116 | static int cmd_ap_set_staqos(struct sigma_dut *dut, struct sigma_conn *conn, |
| 6117 | struct sigma_cmd *cmd) |
| 6118 | { |
Pradeep Reddy POTTETI | eff4611 | 2016-10-13 17:22:03 +0530 | [diff] [blame] | 6119 | if (!parse_qos_params(dut, conn, &dut->ap_sta_qos[AP_AC_VO], |
| 6120 | get_param(cmd, "cwmin_VO"), |
| 6121 | get_param(cmd, "cwmax_VO"), |
| 6122 | get_param(cmd, "AIFS_VO"), |
| 6123 | get_param(cmd, "TXOP_VO"), |
| 6124 | get_param(cmd, "ACM_VO")) || |
| 6125 | !parse_qos_params(dut, conn, &dut->ap_sta_qos[AP_AC_VI], |
| 6126 | get_param(cmd, "cwmin_VI"), |
| 6127 | get_param(cmd, "cwmax_VI"), |
| 6128 | get_param(cmd, "AIFS_VI"), |
| 6129 | get_param(cmd, "TXOP_VI"), |
| 6130 | get_param(cmd, "ACM_VI")) || |
| 6131 | !parse_qos_params(dut, conn, &dut->ap_sta_qos[AP_AC_BE], |
| 6132 | get_param(cmd, "cwmin_BE"), |
| 6133 | get_param(cmd, "cwmax_BE"), |
| 6134 | get_param(cmd, "AIFS_BE"), |
| 6135 | get_param(cmd, "TXOP_BE"), |
| 6136 | get_param(cmd, "ACM_BE")) || |
| 6137 | !parse_qos_params(dut, conn, &dut->ap_sta_qos[AP_AC_BK], |
| 6138 | get_param(cmd, "cwmin_BK"), |
| 6139 | get_param(cmd, "cwmax_BK"), |
| 6140 | get_param(cmd, "AIFS_BK"), |
| 6141 | get_param(cmd, "TXOP_BK"), |
| 6142 | get_param(cmd, "ACM_BK"))) |
| 6143 | return 0; |
| 6144 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6145 | return 1; |
| 6146 | } |
| 6147 | |
| 6148 | |
| 6149 | static void cmd_ath_ap_hs2_reset(struct sigma_dut *dut) |
| 6150 | { |
| 6151 | unsigned char bssid[6]; |
| 6152 | char buf[100]; |
| 6153 | run_system(dut, "cfg -a AP_SSID=\"Hotspot 2.0\""); |
| 6154 | run_system(dut, "cfg -a AP_PRIMARY_CH=1"); |
| 6155 | run_system(dut, "cfg -a AP_SECMODE=WPA"); |
| 6156 | run_system(dut, "cfg -a AP_SECFILE=EAP"); |
| 6157 | run_system(dut, "cfg -a AP_WPA=2"); |
| 6158 | run_system(dut, "cfg -a AP_CYPHER=CCMP"); |
| 6159 | run_system(dut, "cfg -a AP_HOTSPOT=1"); |
| 6160 | run_system(dut, "cfg -a AP_HOTSPOT_ANT=2"); |
| 6161 | run_system(dut, "cfg -a AP_HOTSPOT_INTERNET=0"); |
| 6162 | run_system(dut, "cfg -a AP_HOTSPOT_VENUEGROUP=2"); |
| 6163 | run_system(dut, "cfg -a AP_HOTSPOT_VENUETYPE=8"); |
| 6164 | run_system(dut, "cfg -a AP_HOTSPOT_ROAMINGCONSORTIUM=506f9a"); |
| 6165 | run_system(dut, "cfg -a AP_HOTSPOT_ROAMINGCONSORTIUM2=001bc504bd"); |
| 6166 | if (!get_hwaddr("ath0", bssid)) { |
| 6167 | snprintf(buf, sizeof(buf), "cfg -a AP_HOTSPOT_HESSID=" |
| 6168 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 6169 | bssid[0], bssid[1], bssid[2], bssid[3], |
| 6170 | bssid[4], bssid[5]); |
| 6171 | run_system(dut, buf); |
| 6172 | snprintf(dut->ap_hessid, sizeof(dut->ap_hessid), |
| 6173 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 6174 | bssid[0], bssid[1], bssid[2], bssid[3], |
| 6175 | bssid[4], bssid[5]); |
| 6176 | } else { |
| 6177 | if (!get_hwaddr("wifi0", bssid)) { |
| 6178 | snprintf(buf, sizeof(buf), "cfg -a AP_HOTSPOT_HESSID=" |
| 6179 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 6180 | bssid[0], bssid[1], bssid[2], bssid[3], |
| 6181 | bssid[4], bssid[5]); |
| 6182 | run_system(dut, buf); |
| 6183 | snprintf(dut->ap_hessid, sizeof(dut->ap_hessid), |
| 6184 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 6185 | bssid[0], bssid[1], bssid[2], bssid[3], |
| 6186 | bssid[4], bssid[5]); |
| 6187 | } else { |
| 6188 | /* load the driver and try again */ |
| 6189 | run_system(dut, "/etc/rc.d/rc.wlan up"); |
| 6190 | |
| 6191 | if (!get_hwaddr("wifi0", bssid)) { |
| 6192 | snprintf(buf, sizeof(buf), |
| 6193 | "cfg -a AP_HOTSPOT_HESSID=" |
| 6194 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 6195 | bssid[0], bssid[1], bssid[2], |
| 6196 | bssid[3], bssid[4], bssid[5]); |
| 6197 | run_system(dut, buf); |
| 6198 | snprintf(dut->ap_hessid, |
| 6199 | sizeof(dut->ap_hessid), |
| 6200 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 6201 | bssid[0], bssid[1], bssid[2], |
| 6202 | bssid[3], bssid[4], bssid[5]); |
| 6203 | } |
| 6204 | } |
| 6205 | } |
| 6206 | |
| 6207 | run_system(dut, "cfg -r AP_SSID_2"); |
| 6208 | run_system(dut, "cfg -c"); |
| 6209 | /* run_system(dut, "cfg -s"); */ |
| 6210 | } |
| 6211 | |
| 6212 | |
| 6213 | static void ath_reset_vht_defaults(struct sigma_dut *dut) |
| 6214 | { |
| 6215 | run_system(dut, "cfg -x"); |
| 6216 | run_system(dut, "cfg -a AP_RADIO_ID=1"); |
| 6217 | run_system(dut, "cfg -a AP_PRIMARY_CH_2=36"); |
| 6218 | run_system(dut, "cfg -a AP_STARTMODE=standard"); |
| 6219 | run_system(dut, "cfg -a AP_CHMODE_2=11ACVHT80"); |
| 6220 | run_system(dut, "cfg -a TX_CHAINMASK_2=7"); |
| 6221 | run_system(dut, "cfg -a RX_CHAINMASK_2=7"); |
| 6222 | run_system(dut, "cfg -a ATH_countrycode=0x348"); |
| 6223 | /* NOTE: For Beeliner we have to turn off MU-MIMO */ |
| 6224 | if (system("rm /tmp/secath*") != 0) { |
| 6225 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 6226 | "Failed to remove secath file"); |
| 6227 | } |
| 6228 | } |
| 6229 | |
| 6230 | |
| 6231 | static int cmd_ap_reset_default(struct sigma_dut *dut, struct sigma_conn *conn, |
| 6232 | struct sigma_cmd *cmd) |
| 6233 | { |
| 6234 | const char *type; |
Pradeep Reddy POTTETI | 83b8067 | 2016-09-02 13:01:44 +0530 | [diff] [blame] | 6235 | enum driver_type drv; |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 6236 | int i; |
| 6237 | |
| 6238 | for (i = 0; i < MAX_WLAN_TAGS - 1; i++) { |
| 6239 | /* |
| 6240 | * Reset all tagged SSIDs to NULL-string and all key management |
| 6241 | * to open. |
| 6242 | */ |
| 6243 | dut->ap_tag_ssid[i][0] = '\0'; |
| 6244 | dut->ap_tag_key_mgmt[i] = AP2_OPEN; |
| 6245 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6246 | |
Pradeep Reddy POTTETI | 83b8067 | 2016-09-02 13:01:44 +0530 | [diff] [blame] | 6247 | drv = get_driver_type(); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6248 | dut->program = sigma_program_to_enum(get_param(cmd, "PROGRAM")); |
| 6249 | dut->device_type = AP_unknown; |
| 6250 | type = get_param(cmd, "type"); |
| 6251 | if (type && strcasecmp(type, "Testbed") == 0) |
| 6252 | dut->device_type = AP_testbed; |
| 6253 | if (type && strcasecmp(type, "DUT") == 0) |
| 6254 | dut->device_type = AP_dut; |
| 6255 | |
| 6256 | dut->ap_rts = 0; |
| 6257 | dut->ap_frgmnt = 0; |
| 6258 | dut->ap_bcnint = 0; |
| 6259 | dut->ap_key_mgmt = AP_OPEN; |
| 6260 | dut->ap_ssid[0] = '\0'; |
| 6261 | dut->ap_fake_pkhash = 0; |
| 6262 | memset(dut->ap_qos, 0, sizeof(dut->ap_qos)); |
| 6263 | memset(dut->ap_sta_qos, 0, sizeof(dut->ap_sta_qos)); |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 6264 | dut->ap_addba_reject = VALUE_NOT_SET; |
| 6265 | dut->ap_noack = VALUE_NOT_SET; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6266 | dut->ap_is_dual = 0; |
| 6267 | dut->ap_mode = AP_inval; |
| 6268 | dut->ap_mode_1 = AP_inval; |
| 6269 | |
| 6270 | dut->ap_allow_vht_wep = 0; |
| 6271 | dut->ap_allow_vht_tkip = 0; |
| 6272 | dut->ap_disable_protection = 0; |
| 6273 | memset(dut->ap_countrycode, 0, sizeof(dut->ap_countrycode)); |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 6274 | dut->ap_dyn_bw_sig = VALUE_NOT_SET; |
| 6275 | dut->ap_ldpc = VALUE_NOT_SET; |
| 6276 | dut->ap_sig_rts = VALUE_NOT_SET; |
| 6277 | dut->ap_rx_amsdu = VALUE_NOT_SET; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6278 | dut->ap_txBF = 0; |
Mohammed Shafi Shajakhan | 495fdb2 | 2016-06-02 20:10:56 +0530 | [diff] [blame] | 6279 | dut->ap_mu_txBF = 0; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6280 | dut->ap_chwidth = AP_AUTO; |
| 6281 | |
Sarvepalli, Rajesh Babu | 24dc7e4 | 2016-03-18 21:27:26 +0530 | [diff] [blame] | 6282 | dut->ap_rsn_preauth = 0; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6283 | dut->ap_wpsnfc = 0; |
| 6284 | dut->ap_bss_load = -1; |
| 6285 | dut->ap_p2p_cross_connect = -1; |
| 6286 | |
Pradeep Reddy POTTETI | fba27db | 2015-11-20 16:42:22 +0530 | [diff] [blame] | 6287 | dut->ap_regulatory_mode = AP_80211D_MODE_DISABLED; |
| 6288 | dut->ap_dfs_mode = AP_DFS_MODE_DISABLED; |
Pradeep Reddy Potteti | 4b0cdee | 2017-03-15 12:37:33 +0530 | [diff] [blame] | 6289 | dut->ap_chwidth_offset = SEC_CH_NO; |
Pradeep Reddy POTTETI | fba27db | 2015-11-20 16:42:22 +0530 | [diff] [blame] | 6290 | |
Adil Saeed Musthafa | 6906372 | 2017-04-10 23:13:40 -0700 | [diff] [blame] | 6291 | dut->mbo_pref_ap_cnt = 0; |
Adil Saeed Musthafa | 4ec61bd | 2017-04-10 23:13:41 -0700 | [diff] [blame] | 6292 | dut->ft_bss_mac_cnt = 0; |
Adil Saeed Musthafa | 6906372 | 2017-04-10 23:13:40 -0700 | [diff] [blame] | 6293 | |
Mohammed Shafi Shajakhan | 02e3b82 | 2017-02-23 04:15:02 +0530 | [diff] [blame] | 6294 | if (dut->program == PROGRAM_HT || dut->program == PROGRAM_VHT) { |
Pradeep Reddy POTTETI | 0d3db63 | 2016-03-11 15:21:11 +0530 | [diff] [blame] | 6295 | dut->ap_wme = AP_WME_ON; |
Mohammed Shafi Shajakhan | 02e3b82 | 2017-02-23 04:15:02 +0530 | [diff] [blame] | 6296 | dut->ap_wmmps = AP_WMMPS_ON; |
| 6297 | } else { |
Pradeep Reddy POTTETI | 0d3db63 | 2016-03-11 15:21:11 +0530 | [diff] [blame] | 6298 | dut->ap_wme = AP_WME_OFF; |
Mohammed Shafi Shajakhan | 02e3b82 | 2017-02-23 04:15:02 +0530 | [diff] [blame] | 6299 | dut->ap_wmmps = AP_WMMPS_OFF; |
| 6300 | } |
Pradeep Reddy POTTETI | 0d3db63 | 2016-03-11 15:21:11 +0530 | [diff] [blame] | 6301 | |
Adil Saeed Musthafa | 33ea287 | 2017-04-10 23:13:24 -0700 | [diff] [blame] | 6302 | if (dut->program == PROGRAM_HS2 || dut->program == PROGRAM_HS2_R2 || |
| 6303 | dut->program == PROGRAM_IOTLP) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6304 | int i; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6305 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6306 | if (drv == DRIVER_ATHEROS) |
| 6307 | cmd_ath_ap_hs2_reset(dut); |
| 6308 | else if (drv == DRIVER_OPENWRT) |
| 6309 | cmd_owrt_ap_hs2_reset(dut); |
| 6310 | |
| 6311 | dut->ap_interworking = 1; |
| 6312 | dut->ap_access_net_type = 2; |
| 6313 | dut->ap_internet = 0; |
| 6314 | dut->ap_venue_group = 2; |
| 6315 | dut->ap_venue_type = 8; |
| 6316 | dut->ap_domain_name_list[0] = '\0'; |
| 6317 | dut->ap_hs2 = 1; |
| 6318 | snprintf(dut->ap_roaming_cons, sizeof(dut->ap_roaming_cons), |
| 6319 | "506f9a;001bc504bd"); |
| 6320 | dut->ap_l2tif = 0; |
| 6321 | dut->ap_proxy_arp = 0; |
| 6322 | if (dut->bridge) { |
| 6323 | char buf[50]; |
| 6324 | |
| 6325 | snprintf(buf, sizeof(buf), "ip neigh flush dev %s", |
| 6326 | dut->bridge); |
| 6327 | if (system(buf) != 0) { |
| 6328 | sigma_dut_print(dut, DUT_MSG_DEBUG, |
| 6329 | "%s ip neigh table flushing failed", |
| 6330 | dut->bridge); |
| 6331 | } |
| 6332 | |
| 6333 | snprintf(buf, sizeof(buf), "ebtables -F"); |
| 6334 | if (system(buf) != 0) { |
| 6335 | sigma_dut_print(dut, DUT_MSG_DEBUG, |
| 6336 | "%s ebtables flushing failed", |
| 6337 | dut->bridge); |
| 6338 | } |
| 6339 | } |
| 6340 | dut->ap_dgaf_disable = 0; |
| 6341 | dut->ap_p2p_cross_connect = 0; |
| 6342 | dut->ap_gas_cb_delay = 0; |
| 6343 | dut->ap_nai_realm_list = 0; |
| 6344 | dut->ap_oper_name = 0; |
| 6345 | dut->ap_venue_name = 0; |
| 6346 | for (i = 0; i < 10; i++) { |
| 6347 | dut->ap_plmn_mcc[i][0] = '\0'; |
| 6348 | dut->ap_plmn_mnc[i][0] = '\0'; |
| 6349 | } |
| 6350 | dut->ap_wan_metrics = 0; |
| 6351 | dut->ap_conn_capab = 0; |
| 6352 | dut->ap_ip_addr_type_avail = 0; |
| 6353 | dut->ap_net_auth_type = 0; |
| 6354 | dut->ap_oper_class = 0; |
| 6355 | dut->ap_pmf = 0; |
| 6356 | dut->ap_add_sha256 = 0; |
| 6357 | } |
| 6358 | |
Adil Saeed Musthafa | 33ea287 | 2017-04-10 23:13:24 -0700 | [diff] [blame] | 6359 | if (dut->program == PROGRAM_HS2_R2 || dut->program == PROGRAM_IOTLP) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6360 | int i; |
| 6361 | const char hessid[] = "50:6f:9a:00:11:22"; |
| 6362 | |
| 6363 | memcpy(dut->ap_hessid, hessid, strlen(hessid) + 1); |
| 6364 | dut->ap_osu_ssid[0] = '\0'; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6365 | dut->ap_pmf = 1; |
| 6366 | dut->ap_osu_provider_list = 0; |
| 6367 | for (i = 0; i < 10; i++) { |
| 6368 | dut->ap_osu_server_uri[i][0] = '\0'; |
| 6369 | dut->ap_osu_method[i] = 0xFF; |
| 6370 | } |
| 6371 | dut->ap_qos_map_set = 0; |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 6372 | dut->ap_tag_key_mgmt[0] = AP2_OPEN; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6373 | dut->ap2_proxy_arp = 0; |
| 6374 | dut->ap_osu_icon_tag = 0; |
| 6375 | } |
| 6376 | |
| 6377 | if (dut->program == PROGRAM_VHT) { |
| 6378 | /* Set up the defaults */ |
| 6379 | dut->ap_mode = AP_11ac; |
| 6380 | dut->ap_channel = 36; |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 6381 | dut->ap_ampdu = VALUE_NOT_SET; |
priyadharshini gowthaman | 264d544 | 2016-02-25 15:52:22 -0800 | [diff] [blame] | 6382 | dut->ap_ndpa_frame = 1; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6383 | if (dut->device_type == AP_testbed) { |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 6384 | dut->ap_amsdu = VALUE_DISABLED; |
| 6385 | dut->ap_ldpc = VALUE_DISABLED; |
| 6386 | dut->ap_rx_amsdu = VALUE_DISABLED; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6387 | dut->ap_sgi80 = 0; |
| 6388 | } else { |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 6389 | dut->ap_amsdu = VALUE_ENABLED; |
Pradeep Reddy POTTETI | 83b8067 | 2016-09-02 13:01:44 +0530 | [diff] [blame] | 6390 | /* |
| 6391 | * As LDPC is optional, don't enable this by default |
| 6392 | * for LINUX-WCN driver. The ap_set_wireless command |
| 6393 | * can be used to enable LDPC, when needed. |
| 6394 | */ |
| 6395 | if (drv != DRIVER_LINUX_WCN) |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 6396 | dut->ap_ldpc = VALUE_ENABLED; |
| 6397 | dut->ap_rx_amsdu = VALUE_ENABLED; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6398 | dut->ap_sgi80 = 1; |
| 6399 | } |
| 6400 | dut->ap_fixed_rate = 0; |
| 6401 | dut->ap_rx_streams = 3; |
| 6402 | dut->ap_tx_streams = 3; |
| 6403 | dut->ap_vhtmcs_map = 0; |
| 6404 | dut->ap_chwidth = AP_80; |
| 6405 | dut->ap_tx_stbc = 1; |
Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 6406 | dut->ap_dyn_bw_sig = VALUE_ENABLED; |
Mohammed Shafi Shajakhan | bae7230 | 2016-03-02 11:56:23 +0530 | [diff] [blame] | 6407 | if (get_openwrt_driver_type() == OPENWRT_DRIVER_ATHEROS) |
| 6408 | dut->ap_dfs_mode = AP_DFS_MODE_ENABLED; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6409 | if (get_driver_type() == DRIVER_ATHEROS) |
| 6410 | ath_reset_vht_defaults(dut); |
| 6411 | } |
| 6412 | |
Adil Saeed Musthafa | 33ea287 | 2017-04-10 23:13:24 -0700 | [diff] [blame] | 6413 | if (dut->program == PROGRAM_IOTLP) { |
| 6414 | dut->wnm_bss_max_feature = VALUE_DISABLED; |
| 6415 | dut->wnm_bss_max_idle_time = 0; |
| 6416 | dut->wnm_bss_max_protection = VALUE_NOT_SET; |
| 6417 | dut->ap_proxy_arp = 1; |
| 6418 | } else { |
| 6419 | /* |
| 6420 | * Do not touch the BSS-MAX Idle time feature |
| 6421 | * if the program is not IOTLP. |
| 6422 | */ |
| 6423 | dut->wnm_bss_max_feature = VALUE_NOT_SET; |
| 6424 | dut->wnm_bss_max_idle_time = 0; |
| 6425 | dut->wnm_bss_max_protection = VALUE_NOT_SET; |
| 6426 | } |
| 6427 | |
priyadharshini gowthaman | a27b5b6 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 6428 | if (dut->program == PROGRAM_LOC) { |
priyadharshini gowthaman | 8e26ff4 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 6429 | dut->ap_rrm = 1; |
| 6430 | dut->ap_rtt = 1; |
| 6431 | dut->ap_lci = 0; |
| 6432 | dut->ap_val_lci[0] = '\0'; |
priyadharshini gowthaman | c2357bd | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 6433 | dut->ap_infoz[0] = '\0'; |
priyadharshini gowthaman | 8e26ff4 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 6434 | dut->ap_lcr = 0; |
| 6435 | dut->ap_val_lcr[0] = '\0'; |
| 6436 | dut->ap_neighap = 0; |
| 6437 | dut->ap_opchannel = 0; |
| 6438 | dut->ap_scan = 0; |
priyadharshini gowthaman | c2357bd | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 6439 | dut->ap_fqdn_held = 0; |
| 6440 | dut->ap_fqdn_supl = 0; |
priyadharshini gowthaman | c52fff8 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 6441 | dut->ap_interworking = 0; |
| 6442 | dut->ap_gas_cb_delay = 0; |
priyadharshini gowthaman | a27b5b6 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 6443 | dut->ap_msnt_type = 0; |
| 6444 | } |
Adil Saeed Musthafa | 4ec61bd | 2017-04-10 23:13:41 -0700 | [diff] [blame] | 6445 | dut->ap_ft_oa = 0; |
Adil Saeed Musthafa | 604c826 | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 6446 | dut->ap_reg_domain = REG_DOMAIN_NOT_SET; |
Adil Saeed Musthafa | cf752fa | 2017-04-10 23:13:32 -0700 | [diff] [blame] | 6447 | dut->ap_mobility_domain[0] = '\0'; |
priyadharshini gowthaman | a27b5b6 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 6448 | |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 6449 | if (dut->program == PROGRAM_MBO) { |
| 6450 | dut->ap_mbo = 1; |
| 6451 | dut->ap_interworking = 1; |
| 6452 | dut->ap_ne_class = 0; |
| 6453 | dut->ap_ne_op_ch = 0; |
| 6454 | dut->ap_set_bssidpref = 1; |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 6455 | dut->ap_btmreq_disassoc_imnt = 0; |
| 6456 | dut->ap_btmreq_term_bit = 0; |
| 6457 | dut->ap_disassoc_timer = 0; |
| 6458 | dut->ap_btmreq_bss_term_dur = 0; |
Adil Saeed Musthafa | 16d9e63 | 2017-04-10 23:13:38 -0700 | [diff] [blame] | 6459 | dut->ap_channel = 36; |
| 6460 | dut->ap_chwidth = AP_20; |
Adil Saeed Musthafa | 023108a | 2017-04-10 23:13:37 -0700 | [diff] [blame] | 6461 | dut->ap_cell_cap_pref = 0; |
Adil Saeed Musthafa | ed5faae | 2017-04-10 23:13:36 -0700 | [diff] [blame] | 6462 | dut->ap_gas_cb_delay = 0; |
Adil Saeed Musthafa | 6906372 | 2017-04-10 23:13:40 -0700 | [diff] [blame] | 6463 | dut->mbo_self_ap_tuple.ap_ne_class = -1; |
| 6464 | dut->mbo_self_ap_tuple.ap_ne_pref = -1; /* Not set */ |
| 6465 | dut->mbo_self_ap_tuple.ap_ne_op_ch = -1; |
| 6466 | |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 6467 | } |
| 6468 | |
Jouni Malinen | 3c367e8 | 2017-06-23 17:01:47 +0300 | [diff] [blame] | 6469 | free(dut->rsne_override); |
| 6470 | dut->rsne_override = NULL; |
| 6471 | |
Jouni Malinen | 6814313 | 2017-09-02 02:34:08 +0300 | [diff] [blame] | 6472 | free(dut->sae_commit_override); |
| 6473 | dut->sae_commit_override = NULL; |
| 6474 | |
Jouni Malinen | ed670f4 | 2017-08-31 01:39:28 +0300 | [diff] [blame] | 6475 | free(dut->ap_sae_groups); |
| 6476 | dut->ap_sae_groups = NULL; |
Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 6477 | |
Jouni Malinen | 2f524ce | 2017-08-31 01:43:29 +0300 | [diff] [blame] | 6478 | dut->sae_anti_clogging_threshold = -1; |
Jouni Malinen | b347db0 | 2017-09-02 01:36:03 +0300 | [diff] [blame] | 6479 | dut->sae_reflection = 0; |
Jouni Malinen | 2f524ce | 2017-08-31 01:43:29 +0300 | [diff] [blame] | 6480 | |
Jouni Malinen | d86e582 | 2017-08-29 03:55:32 +0300 | [diff] [blame] | 6481 | dut->dpp_conf_id = -1; |
| 6482 | |
| 6483 | dut->hostapd_running = 0; |
Jouni Malinen | d6bf1b4 | 2017-06-23 17:51:01 +0300 | [diff] [blame] | 6484 | if (dut->use_hostapd_pid_file) { |
| 6485 | kill_hostapd_process_pid(dut); |
| 6486 | } else if (kill_process(dut, "(hostapd)", 1, SIGTERM) == 0 || |
| 6487 | system("killall hostapd") == 0) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6488 | int i; |
| 6489 | /* Wait some time to allow hostapd to complete cleanup before |
| 6490 | * starting a new process */ |
| 6491 | for (i = 0; i < 10; i++) { |
| 6492 | usleep(500000); |
| 6493 | if (system("pidof hostapd") != 0) |
| 6494 | break; |
| 6495 | } |
| 6496 | } |
| 6497 | |
| 6498 | if (if_nametoindex("sigmadut") > 0 && |
| 6499 | system("iw dev sigmadut del") != 0) |
| 6500 | sigma_dut_print(dut, DUT_MSG_ERROR, "Failed to remove " |
| 6501 | "monitor interface"); |
| 6502 | |
| 6503 | return 1; |
| 6504 | } |
| 6505 | |
| 6506 | |
| 6507 | static int cmd_ap_get_info(struct sigma_dut *dut, struct sigma_conn *conn, |
| 6508 | struct sigma_cmd *cmd) |
| 6509 | { |
| 6510 | /* const char *name = get_param(cmd, "NAME"); */ |
| 6511 | struct stat s; |
| 6512 | char resp[200]; |
| 6513 | FILE *f; |
| 6514 | enum driver_type drv = get_driver_type(); |
| 6515 | |
| 6516 | switch (drv) { |
| 6517 | case DRIVER_ATHEROS: { |
| 6518 | /* Atheros AP */ |
| 6519 | struct utsname uts; |
| 6520 | char *version, athver[100]; |
| 6521 | |
| 6522 | if (stat("/proc/athversion", &s) != 0) { |
| 6523 | if (system("/etc/rc.d/rc.wlan up") != 0) { |
| 6524 | } |
| 6525 | } |
| 6526 | |
| 6527 | athver[0] = '\0'; |
| 6528 | f = fopen("/proc/athversion", "r"); |
| 6529 | if (f) { |
| 6530 | if (fgets(athver, sizeof(athver), f)) { |
| 6531 | char *pos = strchr(athver, '\n'); |
| 6532 | if (pos) |
| 6533 | *pos = '\0'; |
| 6534 | } |
| 6535 | fclose(f); |
| 6536 | } |
| 6537 | |
| 6538 | if (uname(&uts) == 0) |
| 6539 | version = uts.release; |
| 6540 | else |
| 6541 | version = "Unknown"; |
| 6542 | |
| 6543 | if (if_nametoindex("ath1") > 0) |
| 6544 | snprintf(resp, sizeof(resp), "interface,ath0_24G " |
| 6545 | "ath1_5G,agent,1.0,version,%s/drv:%s", |
| 6546 | version, athver); |
| 6547 | else |
| 6548 | snprintf(resp, sizeof(resp), "interface,ath0_24G," |
| 6549 | "agent,1.0,version,%s/drv:%s", |
| 6550 | version, athver); |
| 6551 | |
| 6552 | send_resp(dut, conn, SIGMA_COMPLETE, resp); |
| 6553 | return 0; |
| 6554 | } |
Sreelakshmi Konamki | b692f10 | 2016-04-26 19:47:00 +0530 | [diff] [blame] | 6555 | case DRIVER_LINUX_WCN: |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6556 | case DRIVER_MAC80211: { |
| 6557 | struct utsname uts; |
| 6558 | char *version; |
| 6559 | |
| 6560 | if (uname(&uts) == 0) |
| 6561 | version = uts.release; |
| 6562 | else |
| 6563 | version = "Unknown"; |
| 6564 | |
| 6565 | if (if_nametoindex("wlan1") > 0) |
| 6566 | snprintf(resp, sizeof(resp), "interface,wlan0_24G " |
| 6567 | "wlan1_5G,agent,1.0,version,%s", version); |
| 6568 | else |
| 6569 | snprintf(resp, sizeof(resp), "interface,wlan0_any," |
| 6570 | "agent,1.0,version,%s", version); |
| 6571 | |
| 6572 | send_resp(dut, conn, SIGMA_COMPLETE, resp); |
| 6573 | return 0; |
| 6574 | } |
| 6575 | case DRIVER_QNXNTO: { |
| 6576 | struct utsname uts; |
| 6577 | char *version; |
| 6578 | |
| 6579 | if (uname(&uts) == 0) |
| 6580 | version = uts.release; |
| 6581 | else |
| 6582 | version = "Unknown"; |
| 6583 | snprintf(resp, sizeof(resp), |
| 6584 | "interface,%s_any,agent,1.0,version,%s", |
| 6585 | sigma_main_ifname ? sigma_main_ifname : "NA", |
| 6586 | version); |
| 6587 | send_resp(dut, conn, SIGMA_COMPLETE, resp); |
| 6588 | return 0; |
| 6589 | } |
| 6590 | case DRIVER_OPENWRT: { |
| 6591 | switch (get_openwrt_driver_type()) { |
| 6592 | case OPENWRT_DRIVER_ATHEROS: { |
| 6593 | struct utsname uts; |
| 6594 | char *version; |
| 6595 | |
| 6596 | if (uname(&uts) == 0) |
| 6597 | version = uts.release; |
| 6598 | else |
| 6599 | version = "Unknown"; |
| 6600 | |
| 6601 | if (if_nametoindex("ath1") > 0) |
| 6602 | snprintf(resp, sizeof(resp), |
| 6603 | "interface,ath0_5G ath1_24G,agent,1.0,version,%s", |
| 6604 | version); |
| 6605 | else |
| 6606 | snprintf(resp, sizeof(resp), |
| 6607 | "interface,ath0_any,agent,1.0,version,%s", |
| 6608 | version); |
| 6609 | |
| 6610 | send_resp(dut, conn, SIGMA_COMPLETE, resp); |
| 6611 | return 0; |
| 6612 | } |
| 6613 | default: |
| 6614 | send_resp(dut, conn, SIGMA_ERROR, |
| 6615 | "errorCode,Unsupported openwrt driver"); |
| 6616 | return 0; |
| 6617 | } |
| 6618 | } |
| 6619 | default: |
| 6620 | send_resp(dut, conn, SIGMA_ERROR, |
| 6621 | "errorCode,Unsupported driver"); |
| 6622 | return 0; |
| 6623 | } |
| 6624 | } |
| 6625 | |
| 6626 | |
| 6627 | static int cmd_ap_deauth_sta(struct sigma_dut *dut, struct sigma_conn *conn, |
| 6628 | struct sigma_cmd *cmd) |
| 6629 | { |
| 6630 | /* const char *name = get_param(cmd, "NAME"); */ |
| 6631 | /* const char *ifname = get_param(cmd, "INTERFACE"); */ |
| 6632 | const char *val; |
| 6633 | char buf[100]; |
| 6634 | |
| 6635 | val = get_param(cmd, "MinorCode"); |
| 6636 | if (val) { |
| 6637 | /* TODO: add support for P2P minor code */ |
| 6638 | send_resp(dut, conn, SIGMA_ERROR, "errorCode,MinorCode not " |
| 6639 | "yet supported"); |
| 6640 | return 0; |
| 6641 | } |
| 6642 | |
| 6643 | val = get_param(cmd, "STA_MAC_ADDRESS"); |
| 6644 | if (val == NULL) |
| 6645 | return -1; |
| 6646 | snprintf(buf, sizeof(buf), "deauth %s", val); |
| 6647 | if (run_hostapd_cli(dut, buf) != 0) |
| 6648 | return -2; |
| 6649 | |
| 6650 | return 1; |
| 6651 | } |
| 6652 | |
| 6653 | |
| 6654 | #ifdef __linux__ |
| 6655 | int inject_frame(int s, const void *data, size_t len, int encrypt); |
| 6656 | int open_monitor(const char *ifname); |
| 6657 | int hwaddr_aton(const char *txt, unsigned char *addr); |
| 6658 | #endif /* __linux__ */ |
| 6659 | |
| 6660 | enum send_frame_type { |
| 6661 | DISASSOC, DEAUTH, SAQUERY |
| 6662 | }; |
| 6663 | enum send_frame_protection { |
| 6664 | CORRECT_KEY, INCORRECT_KEY, UNPROTECTED |
| 6665 | }; |
| 6666 | |
| 6667 | |
| 6668 | static int ap_inject_frame(struct sigma_dut *dut, struct sigma_conn *conn, |
| 6669 | enum send_frame_type frame, |
| 6670 | enum send_frame_protection protected, |
| 6671 | const char *sta_addr) |
| 6672 | { |
| 6673 | #ifdef __linux__ |
| 6674 | unsigned char buf[1000], *pos; |
| 6675 | int s, res; |
| 6676 | unsigned char addr_sta[6], addr_own[6]; |
| 6677 | char *ifname; |
| 6678 | char cbuf[100]; |
| 6679 | struct ifreq ifr; |
| 6680 | |
| 6681 | if ((dut->ap_mode == AP_11a || dut->ap_mode == AP_11na || |
| 6682 | dut->ap_mode == AP_11ac) && |
| 6683 | if_nametoindex("wlan1") > 0) |
| 6684 | ifname = "wlan1"; |
| 6685 | else |
| 6686 | ifname = "wlan0"; |
| 6687 | |
| 6688 | if (hwaddr_aton(sta_addr, addr_sta) < 0) |
| 6689 | return -1; |
| 6690 | |
| 6691 | s = socket(AF_INET, SOCK_DGRAM, 0); |
| 6692 | if (s < 0) |
| 6693 | return -1; |
| 6694 | memset(&ifr, 0, sizeof(ifr)); |
Peng Xu | b8fc5cc | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 6695 | strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name)); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6696 | if (ioctl(s, SIOCGIFHWADDR, &ifr) < 0) { |
| 6697 | perror("ioctl"); |
| 6698 | close(s); |
| 6699 | return -1; |
| 6700 | } |
| 6701 | close(s); |
| 6702 | memcpy(addr_own, ifr.ifr_hwaddr.sa_data, 6); |
| 6703 | |
| 6704 | if (if_nametoindex("sigmadut") == 0) { |
| 6705 | snprintf(cbuf, sizeof(cbuf), |
| 6706 | "iw dev %s interface add sigmadut type monitor", |
| 6707 | ifname); |
| 6708 | if (system(cbuf) != 0 || |
| 6709 | if_nametoindex("sigmadut") == 0) { |
| 6710 | sigma_dut_print(dut, DUT_MSG_ERROR, "Failed to add " |
| 6711 | "monitor interface with '%s'", cbuf); |
| 6712 | return -2; |
| 6713 | } |
| 6714 | } |
| 6715 | |
| 6716 | if (system("ifconfig sigmadut up") != 0) { |
| 6717 | sigma_dut_print(dut, DUT_MSG_ERROR, "Failed to set " |
| 6718 | "monitor interface up"); |
| 6719 | return -2; |
| 6720 | } |
| 6721 | |
| 6722 | pos = buf; |
| 6723 | |
| 6724 | /* Frame Control */ |
| 6725 | switch (frame) { |
| 6726 | case DISASSOC: |
| 6727 | *pos++ = 0xa0; |
| 6728 | break; |
| 6729 | case DEAUTH: |
| 6730 | *pos++ = 0xc0; |
| 6731 | break; |
| 6732 | case SAQUERY: |
| 6733 | *pos++ = 0xd0; |
| 6734 | break; |
| 6735 | } |
| 6736 | |
| 6737 | if (protected == INCORRECT_KEY) |
| 6738 | *pos++ = 0x40; /* Set Protected field to 1 */ |
| 6739 | else |
| 6740 | *pos++ = 0x00; |
| 6741 | |
| 6742 | /* Duration */ |
| 6743 | *pos++ = 0x00; |
| 6744 | *pos++ = 0x00; |
| 6745 | |
| 6746 | /* addr1 = DA (station) */ |
| 6747 | memcpy(pos, addr_sta, 6); |
| 6748 | pos += 6; |
| 6749 | /* addr2 = SA (own address) */ |
| 6750 | memcpy(pos, addr_own, 6); |
| 6751 | pos += 6; |
| 6752 | /* addr3 = BSSID (own address) */ |
| 6753 | memcpy(pos, addr_own, 6); |
| 6754 | pos += 6; |
| 6755 | |
| 6756 | /* Seq# (to be filled by driver/mac80211) */ |
| 6757 | *pos++ = 0x00; |
| 6758 | *pos++ = 0x00; |
| 6759 | |
| 6760 | if (protected == INCORRECT_KEY) { |
| 6761 | /* CCMP parameters */ |
| 6762 | memcpy(pos, "\x61\x01\x00\x20\x00\x10\x00\x00", 8); |
| 6763 | pos += 8; |
| 6764 | } |
| 6765 | |
| 6766 | if (protected == INCORRECT_KEY) { |
| 6767 | switch (frame) { |
| 6768 | case DEAUTH: |
| 6769 | /* Reason code (encrypted) */ |
| 6770 | memcpy(pos, "\xa7\x39", 2); |
| 6771 | pos += 2; |
| 6772 | break; |
| 6773 | case DISASSOC: |
| 6774 | /* Reason code (encrypted) */ |
| 6775 | memcpy(pos, "\xa7\x39", 2); |
| 6776 | pos += 2; |
| 6777 | break; |
| 6778 | case SAQUERY: |
| 6779 | /* Category|Action|TransID (encrypted) */ |
| 6780 | memcpy(pos, "\x6f\xbd\xe9\x4d", 4); |
| 6781 | pos += 4; |
| 6782 | break; |
| 6783 | default: |
| 6784 | return -1; |
| 6785 | } |
| 6786 | |
| 6787 | /* CCMP MIC */ |
| 6788 | memcpy(pos, "\xc8\xd8\x3b\x06\x5d\xb7\x25\x68", 8); |
| 6789 | pos += 8; |
| 6790 | } else { |
| 6791 | switch (frame) { |
| 6792 | case DEAUTH: |
| 6793 | /* reason code = 8 */ |
| 6794 | *pos++ = 0x08; |
| 6795 | *pos++ = 0x00; |
| 6796 | break; |
| 6797 | case DISASSOC: |
| 6798 | /* reason code = 8 */ |
| 6799 | *pos++ = 0x08; |
| 6800 | *pos++ = 0x00; |
| 6801 | break; |
| 6802 | case SAQUERY: |
| 6803 | /* Category - SA Query */ |
| 6804 | *pos++ = 0x08; |
| 6805 | /* SA query Action - Request */ |
| 6806 | *pos++ = 0x00; |
| 6807 | /* Transaction ID */ |
| 6808 | *pos++ = 0x12; |
| 6809 | *pos++ = 0x34; |
| 6810 | break; |
| 6811 | } |
| 6812 | } |
| 6813 | |
| 6814 | s = open_monitor("sigmadut"); |
| 6815 | if (s < 0) { |
| 6816 | send_resp(dut, conn, SIGMA_ERROR, "errorCode,Failed to open " |
| 6817 | "monitor socket"); |
| 6818 | return 0; |
| 6819 | } |
| 6820 | |
| 6821 | res = inject_frame(s, buf, pos - buf, protected == CORRECT_KEY); |
| 6822 | if (res < 0) { |
| 6823 | send_resp(dut, conn, SIGMA_ERROR, "errorCode,Failed to " |
| 6824 | "inject frame"); |
Pradeep Reddy POTTETI | 673d85c | 2016-07-26 19:08:07 +0530 | [diff] [blame] | 6825 | close(s); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6826 | return 0; |
| 6827 | } |
| 6828 | if (res < pos - buf) { |
| 6829 | send_resp(dut, conn, SIGMA_ERROR, "errorCode,Only partial " |
| 6830 | "frame sent"); |
Pradeep Reddy POTTETI | 673d85c | 2016-07-26 19:08:07 +0530 | [diff] [blame] | 6831 | close(s); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6832 | return 0; |
| 6833 | } |
| 6834 | |
| 6835 | close(s); |
| 6836 | |
| 6837 | return 1; |
| 6838 | #else /* __linux__ */ |
| 6839 | send_resp(dut, conn, SIGMA_ERROR, "errorCode,ap_send_frame not " |
| 6840 | "yet supported"); |
| 6841 | return 0; |
| 6842 | #endif /* __linux__ */ |
| 6843 | } |
| 6844 | |
| 6845 | |
| 6846 | int ap_send_frame_hs2(struct sigma_dut *dut, struct sigma_conn *conn, |
| 6847 | struct sigma_cmd *cmd) |
| 6848 | { |
| 6849 | const char *val, *dest; |
| 6850 | char buf[100]; |
| 6851 | |
| 6852 | val = get_param(cmd, "FrameName"); |
| 6853 | if (val == NULL) |
| 6854 | return -1; |
| 6855 | |
| 6856 | if (strcasecmp(val, "QoSMapConfigure") == 0) { |
| 6857 | dest = get_param(cmd, "Dest"); |
| 6858 | if (!dest) |
| 6859 | return -1; |
| 6860 | |
| 6861 | val = get_param(cmd, "QoS_MAP_SET"); |
| 6862 | if (val) { |
| 6863 | dut->ap_qos_map_set = atoi(val); |
| 6864 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_qos_map_set %d", |
| 6865 | dut->ap_qos_map_set); |
| 6866 | } |
| 6867 | |
| 6868 | if (dut->ap_qos_map_set == 1) |
| 6869 | run_hostapd_cli(dut, "set_qos_map_set " QOS_MAP_SET_1); |
| 6870 | else if (dut->ap_qos_map_set == 2) |
| 6871 | run_hostapd_cli(dut, "set_qos_map_set " QOS_MAP_SET_2); |
| 6872 | |
| 6873 | snprintf(buf, sizeof(buf), "send_qos_map_conf %s", dest); |
| 6874 | if (run_hostapd_cli(dut, buf) != 0) |
| 6875 | return -1; |
| 6876 | } |
| 6877 | |
| 6878 | return 1; |
| 6879 | } |
| 6880 | |
| 6881 | |
| 6882 | static int ath_ap_send_frame_vht(struct sigma_dut *dut, struct sigma_conn *conn, |
| 6883 | struct sigma_cmd *cmd) |
| 6884 | { |
| 6885 | const char *val; |
| 6886 | char *ifname; |
| 6887 | char buf[100]; |
| 6888 | int chwidth, nss; |
| 6889 | |
| 6890 | val = get_param(cmd, "FrameName"); |
| 6891 | if (!val || strcasecmp(val, "op_md_notif_frm") != 0) { |
| 6892 | send_resp(dut, conn, SIGMA_ERROR, |
| 6893 | "errorCode,Unsupported FrameName"); |
| 6894 | return 0; |
| 6895 | } |
| 6896 | |
| 6897 | /* |
| 6898 | * Sequence of commands for Opmode notification on |
| 6899 | * Peregrine based products |
| 6900 | */ |
| 6901 | ifname = get_main_ifname(); |
| 6902 | |
| 6903 | /* Disable STBC */ |
| 6904 | snprintf(buf, sizeof(buf), "iwpriv %s tx_stbc 0", ifname); |
| 6905 | if (system(buf) != 0) { |
| 6906 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 6907 | "iwpriv tx_stbc 0 failed!"); |
| 6908 | } |
| 6909 | |
| 6910 | /* Check whether optional arg channel width was passed */ |
| 6911 | val = get_param(cmd, "Channel_width"); |
| 6912 | if (val) { |
| 6913 | switch (atoi(val)) { |
| 6914 | case 20: |
| 6915 | chwidth = 0; |
| 6916 | break; |
| 6917 | case 40: |
| 6918 | chwidth = 1; |
| 6919 | break; |
| 6920 | case 80: |
| 6921 | chwidth = 2; |
| 6922 | break; |
| 6923 | case 160: |
| 6924 | chwidth = 3; |
| 6925 | break; |
| 6926 | default: |
| 6927 | chwidth = 2; |
| 6928 | break; |
| 6929 | } |
| 6930 | snprintf(buf, sizeof(buf), "iwpriv %s chwidth %d", |
| 6931 | ifname, chwidth); |
| 6932 | if (system(buf) != 0) { |
| 6933 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 6934 | "iwpriv chwidth failed!"); |
| 6935 | } |
| 6936 | } |
| 6937 | |
| 6938 | /* Check whether optional arg NSS was passed */ |
| 6939 | val = get_param(cmd, "NSS"); |
| 6940 | if (val) { |
| 6941 | /* Convert nss to chainmask */ |
| 6942 | switch (atoi(val)) { |
| 6943 | case 1: |
| 6944 | nss = 1; |
| 6945 | break; |
| 6946 | case 2: |
| 6947 | nss = 3; |
| 6948 | break; |
| 6949 | case 3: |
| 6950 | nss = 7; |
| 6951 | break; |
| 6952 | default: |
| 6953 | /* We do not support NSS > 3 */ |
| 6954 | nss = 3; |
| 6955 | break; |
| 6956 | } |
| 6957 | snprintf(buf, sizeof(buf), "iwpriv %s rxchainmask %d", |
| 6958 | ifname, nss); |
| 6959 | if (system(buf) != 0) { |
| 6960 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 6961 | "iwpriv rxchainmask failed!"); |
| 6962 | } |
| 6963 | } |
| 6964 | |
| 6965 | /* Send the opmode notification */ |
Sunil Dutt | 27ec7f6 | 2017-09-14 18:22:59 +0300 | [diff] [blame] | 6966 | snprintf(buf, sizeof(buf), "iwpriv %s opmode_notify 1", ifname); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6967 | if (system(buf) != 0) { |
| 6968 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 6969 | "iwpriv opmode_notify failed!"); |
| 6970 | } |
| 6971 | |
| 6972 | return 1; |
| 6973 | } |
| 6974 | |
| 6975 | |
priyadharshini gowthaman | a27b5b6 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 6976 | static int ath_ap_send_frame_loc(struct sigma_dut *dut, struct sigma_conn *conn, |
| 6977 | struct sigma_cmd *cmd) |
| 6978 | { |
| 6979 | const char *val; |
| 6980 | FILE *f; |
priyadharshini gowthaman | a61badd | 2016-08-16 13:37:27 -0700 | [diff] [blame] | 6981 | int rand_int = 0; |
priyadharshini gowthaman | a27b5b6 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 6982 | |
| 6983 | val = get_param(cmd, "MsntType"); |
| 6984 | if (val) { |
| 6985 | if (dut->ap_msnt_type == 0) |
| 6986 | dut->ap_msnt_type = atoi(val); |
| 6987 | |
| 6988 | if (dut->ap_msnt_type != 5 && dut->ap_msnt_type != 2) { |
| 6989 | dut->ap_msnt_type = atoi(val); |
| 6990 | if (dut->ap_msnt_type == 1) { |
priyadharshini gowthaman | a61badd | 2016-08-16 13:37:27 -0700 | [diff] [blame] | 6991 | val = get_param(cmd, "RandInterval"); |
| 6992 | if (val) |
| 6993 | rand_int = atoi(val); |
priyadharshini gowthaman | a27b5b6 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 6994 | f = fopen("/tmp/ftmrr.txt", "a"); |
| 6995 | if (!f) { |
| 6996 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 6997 | "Failed to open /tmp/ftmrr.txt"); |
| 6998 | return -1; |
| 6999 | } |
| 7000 | |
| 7001 | fprintf(f, "sta_mac = %s\n", cmd->values[3]); |
priyadharshini gowthaman | a61badd | 2016-08-16 13:37:27 -0700 | [diff] [blame] | 7002 | 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", |
| 7003 | rand_int, cmd->values[7]); |
priyadharshini gowthaman | a27b5b6 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 7004 | fclose(f); |
| 7005 | dut->ap_msnt_type = 5; |
| 7006 | run_system(dut, "wpc -f /tmp/ftmrr.txt"); |
| 7007 | } |
| 7008 | } else if (dut->ap_msnt_type == 5) { |
| 7009 | run_system(dut, "wpc -f /tmp/ftmrr.txt"); |
| 7010 | } else if (dut->ap_msnt_type == 2) { |
| 7011 | f = fopen("/tmp/wru.txt", "w"); |
| 7012 | if (!f) { |
| 7013 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 7014 | "Failed to open /tmp/wru.txt"); |
| 7015 | return -1; |
| 7016 | } |
| 7017 | |
| 7018 | fprintf(f, "sta_mac = %s\n", cmd->values[3]); |
| 7019 | fprintf(f, "meas_type = 0x08\ndialogtoken = 0x1\nnum_repetitions = 0x0\nmeas_token = 0x1\nmeas_req_mode = 0x00\nloc_subject = 0x01\n"); |
| 7020 | fclose(f); |
| 7021 | run_system(dut, "wpc -w /tmp/wru.txt"); |
| 7022 | } |
| 7023 | } |
| 7024 | return 1; |
| 7025 | } |
| 7026 | |
| 7027 | |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 7028 | /* |
| 7029 | * The following functions parse_send_frame_params_int(), |
| 7030 | * parse_send_frame_params_str(), and parse_send_frame_params_mac() |
| 7031 | * are used by ath_ap_send_frame_bcn_rpt_req(). |
| 7032 | * Beacon Report Request is a frame used as part of the MBO program. |
| 7033 | * The command for sending beacon report has a lot of |
| 7034 | * arguments and having these functions reduces code size. |
| 7035 | * |
| 7036 | */ |
| 7037 | static int parse_send_frame_params_int(char *param, struct sigma_cmd *cmd, |
| 7038 | struct sigma_dut *dut, |
| 7039 | char *buf, size_t buf_size) |
| 7040 | { |
| 7041 | const char *str_val; |
| 7042 | int int_val; |
| 7043 | char temp[100]; |
| 7044 | |
| 7045 | str_val = get_param(cmd, param); |
| 7046 | if (!str_val) { |
| 7047 | sigma_dut_print(dut, DUT_MSG_ERROR, "%s not given", param); |
| 7048 | return -1; |
| 7049 | } |
| 7050 | int_val = atoi(str_val); |
| 7051 | snprintf(temp, sizeof(temp), " %d", int_val); |
Peng Xu | 591be45 | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 7052 | strlcat(buf, temp, buf_size); |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 7053 | return 0; |
| 7054 | } |
| 7055 | |
| 7056 | |
| 7057 | static int parse_send_frame_params_str(char *param, struct sigma_cmd *cmd, |
| 7058 | struct sigma_dut *dut, |
| 7059 | char *buf, size_t buf_size) |
| 7060 | { |
| 7061 | const char *str_val; |
| 7062 | char temp[100]; |
| 7063 | |
| 7064 | str_val = get_param(cmd, param); |
| 7065 | if (!str_val) { |
| 7066 | sigma_dut_print(dut, DUT_MSG_ERROR, "%s not given", param); |
| 7067 | return -1; |
| 7068 | } |
| 7069 | snprintf(temp, sizeof(temp), " %s", str_val); |
| 7070 | temp[sizeof(temp) - 1] = '\0'; |
Peng Xu | 591be45 | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 7071 | strlcat(buf, temp, buf_size); |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 7072 | return 0; |
| 7073 | } |
| 7074 | |
| 7075 | |
| 7076 | static int parse_send_frame_params_mac(char *param, struct sigma_cmd *cmd, |
| 7077 | struct sigma_dut *dut, |
| 7078 | char *buf, size_t buf_size) |
| 7079 | { |
| 7080 | const char *str_val; |
| 7081 | unsigned char mac[6]; |
| 7082 | char temp[100]; |
| 7083 | |
| 7084 | str_val = get_param(cmd, param); |
| 7085 | if (!str_val) { |
| 7086 | sigma_dut_print(dut, DUT_MSG_ERROR, "%s not given", param); |
| 7087 | return -1; |
| 7088 | } |
| 7089 | |
| 7090 | if (parse_mac_address(dut, str_val, mac) < 0) { |
| 7091 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 7092 | "MAC Address not in proper format"); |
| 7093 | return -1; |
| 7094 | } |
| 7095 | snprintf(temp, sizeof(temp), " %02x:%02x:%02x:%02x:%02x:%02x", |
| 7096 | mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]); |
Peng Xu | 591be45 | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 7097 | strlcat(buf, temp, buf_size); |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 7098 | return 0; |
| 7099 | } |
| 7100 | |
| 7101 | |
| 7102 | static void fill_1_or_0_based_on_presence(struct sigma_cmd *cmd, char *param, |
| 7103 | char *buf, size_t buf_size) |
| 7104 | { |
| 7105 | const char *str_val; |
| 7106 | char *value = " 1"; |
| 7107 | |
| 7108 | str_val = get_param(cmd, param); |
| 7109 | if (!str_val || str_val[0] == '\0') |
| 7110 | value = " 0"; |
Peng Xu | 591be45 | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 7111 | strlcat(buf, value, buf_size); |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 7112 | |
| 7113 | } |
| 7114 | |
| 7115 | |
| 7116 | /* |
| 7117 | * wifitool athN sendbcnrpt |
| 7118 | * <STA MAC - Plugs in from Dest_MAC> |
| 7119 | * <regclass - Plugs in from RegClass - int> |
| 7120 | * <channum - Plugs in from Channel PARAM of dev_send_frame - int> |
| 7121 | * <rand_ivl - Plugs in from RandInt - string> |
| 7122 | * <duration - Plugs in from MeaDur - integer> |
| 7123 | * <mode - Plugs in from MeaMode - string> |
| 7124 | * <req_ssid - Plugs in from SSID PARAM of dev_send_frame - string> |
| 7125 | * <rep_cond - Plugs in from RptCond - integer> |
| 7126 | * <rpt_detail - Plugs in from RptDet - integer> |
| 7127 | * <req_ie - Plugs in from ReqInfo PARAM of dev_send_frame - string> |
| 7128 | * <chanrpt_mode - Plugs in from APChanRpt - integer> |
| 7129 | * <specific_bssid - Plugs in from BSSID PARAM of dev_send_frame> |
| 7130 | * [AP channel numbers] |
| 7131 | */ |
| 7132 | static int ath_ap_send_frame_bcn_rpt_req(struct sigma_dut *dut, |
| 7133 | struct sigma_cmd *cmd, |
| 7134 | const char *ifname) |
| 7135 | { |
| 7136 | char buf[100]; |
| 7137 | int rpt_det; |
| 7138 | const char *str_val; |
| 7139 | const char *mea_mode; |
| 7140 | |
| 7141 | snprintf(buf, sizeof(buf), "wifitool %s sendbcnrpt", ifname); |
| 7142 | |
| 7143 | if (parse_send_frame_params_mac("Dest_MAC", cmd, dut, buf, sizeof(buf))) |
| 7144 | return -1; |
| 7145 | if (parse_send_frame_params_int("RegClass", cmd, dut, buf, sizeof(buf))) |
| 7146 | return -1; |
| 7147 | if (parse_send_frame_params_int("Channel", cmd, dut, buf, sizeof(buf))) |
| 7148 | return -1; |
| 7149 | if (parse_send_frame_params_str("RandInt", cmd, dut, buf, sizeof(buf))) |
| 7150 | return -1; |
| 7151 | if (parse_send_frame_params_int("MeaDur", cmd, dut, buf, sizeof(buf))) |
| 7152 | return -1; |
| 7153 | |
| 7154 | str_val = get_param(cmd, "MeaMode"); |
| 7155 | if (!str_val) { |
| 7156 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 7157 | "MeaMode parameter not present in send bcn-rpt-req"); |
| 7158 | return -1; |
| 7159 | } |
| 7160 | if (strcasecmp(str_val, "passive") == 0) { |
| 7161 | mea_mode = " 0"; |
| 7162 | } else if (strcasecmp(str_val, "active") == 0) { |
| 7163 | mea_mode = " 1"; |
| 7164 | } else if (strcasecmp(str_val, "table") == 0) { |
| 7165 | mea_mode = " 2"; |
| 7166 | } else { |
| 7167 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 7168 | "MEA-MODE Value not correctly given"); |
| 7169 | return -1; |
| 7170 | } |
Peng Xu | 591be45 | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 7171 | strlcat(buf, mea_mode, sizeof(buf)); |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 7172 | |
| 7173 | fill_1_or_0_based_on_presence(cmd, "SSID", buf, sizeof(buf)); |
| 7174 | |
| 7175 | if (parse_send_frame_params_int("RptCond", cmd, dut, buf, sizeof(buf))) |
| 7176 | return -1; |
| 7177 | |
| 7178 | if (parse_send_frame_params_int("RptDet", cmd, dut, buf, sizeof(buf))) |
| 7179 | return -1; |
| 7180 | str_val = get_param(cmd, "RptDet"); |
| 7181 | rpt_det = str_val ? atoi(str_val) : 0; |
| 7182 | |
| 7183 | if (rpt_det) |
| 7184 | fill_1_or_0_based_on_presence(cmd, "ReqInfo", buf, sizeof(buf)); |
| 7185 | else |
Peng Xu | 591be45 | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 7186 | strlcat(buf, " 0", sizeof(buf)); |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 7187 | |
| 7188 | if (rpt_det) |
| 7189 | fill_1_or_0_based_on_presence(cmd, "APChanRpt", buf, |
| 7190 | sizeof(buf)); |
| 7191 | else |
Peng Xu | 591be45 | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 7192 | strlcat(buf, " 0", sizeof(buf)); |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 7193 | |
| 7194 | if (parse_send_frame_params_mac("BSSID", cmd, dut, buf, sizeof(buf))) |
| 7195 | return -1; |
| 7196 | |
| 7197 | run_system(dut, buf); |
| 7198 | return 0; |
| 7199 | } |
| 7200 | |
| 7201 | |
| 7202 | static void inform_and_sleep(struct sigma_dut *dut, int seconds) |
| 7203 | { |
| 7204 | sigma_dut_print(dut, DUT_MSG_DEBUG, "sleeping for %d seconds", seconds); |
| 7205 | sleep(seconds); |
| 7206 | sigma_dut_print(dut, DUT_MSG_DEBUG, "woke up after %d seconds", |
| 7207 | seconds); |
| 7208 | } |
| 7209 | |
| 7210 | |
| 7211 | static int ath_ap_send_frame_btm_req(struct sigma_dut *dut, |
| 7212 | struct sigma_cmd *cmd, const char *ifname) |
| 7213 | { |
| 7214 | unsigned char mac_addr[ETH_ALEN]; |
| 7215 | int disassoc_timer; |
| 7216 | char buf[100]; |
| 7217 | const char *val; |
| 7218 | int cand_list = 1; |
| 7219 | int tsf = 2; |
| 7220 | |
| 7221 | val = get_param(cmd, "Dest_MAC"); |
| 7222 | if (!val || parse_mac_address(dut, val, mac_addr) < 0) { |
| 7223 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 7224 | "MAC Address not in proper format"); |
| 7225 | return -1; |
| 7226 | } |
| 7227 | |
| 7228 | val = get_param(cmd, "Disassoc_Timer"); |
| 7229 | if (val) |
| 7230 | disassoc_timer = atoi(val); |
| 7231 | else |
| 7232 | disassoc_timer = dut->ap_disassoc_timer; |
| 7233 | |
| 7234 | val = get_param(cmd, "Cand_List"); |
| 7235 | if (val && val[0]) |
| 7236 | cand_list = atoi(val); |
| 7237 | |
| 7238 | val = get_param(cmd, "BTMQuery_Reason_Code"); |
| 7239 | if (val) { |
| 7240 | snprintf(buf, sizeof(buf), "iwpriv %s mbo_trans_rs %s", |
| 7241 | ifname, val); |
| 7242 | run_system(dut, buf); |
| 7243 | } |
| 7244 | |
| 7245 | snprintf(buf, sizeof(buf), |
| 7246 | "wifitool %s sendbstmreq %02x:%02x:%02x:%02x:%02x:%02x %d %d 3 %d %d %d %d", |
| 7247 | ifname, mac_addr[0], mac_addr[1], mac_addr[2], mac_addr[3], |
| 7248 | mac_addr[4], mac_addr[5], cand_list, disassoc_timer, |
| 7249 | dut->ap_btmreq_disassoc_imnt, |
| 7250 | dut->ap_btmreq_term_bit, |
| 7251 | tsf, |
| 7252 | dut->ap_btmreq_bss_term_dur); |
| 7253 | run_system(dut, buf); |
| 7254 | |
| 7255 | if (dut->ap_btmreq_term_bit) { |
| 7256 | inform_and_sleep(dut, 3); |
| 7257 | run_system_wrapper(dut, "ifconfig %s down", ifname); |
| 7258 | inform_and_sleep(dut, dut->ap_btmreq_bss_term_dur * 60); |
| 7259 | run_system_wrapper(dut, "ifconfig %s up", ifname); |
| 7260 | } else if (dut->ap_btmreq_disassoc_imnt) { |
| 7261 | inform_and_sleep(dut, (disassoc_timer / 1000) + 1); |
| 7262 | run_system_wrapper(dut, |
| 7263 | "iwpriv %s kickmac %02x:%02x:%02x:%02x:%02x:%02x", |
| 7264 | ifname, |
| 7265 | mac_addr[0], mac_addr[1], mac_addr[2], |
| 7266 | mac_addr[3], mac_addr[4], mac_addr[5]); |
| 7267 | } |
| 7268 | return 0; |
| 7269 | } |
| 7270 | |
| 7271 | |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 7272 | static int ath_ap_send_frame_mbo(struct sigma_dut *dut, struct sigma_conn *conn, |
| 7273 | struct sigma_cmd *cmd) |
| 7274 | { |
| 7275 | const char *val; |
| 7276 | char *ifname; |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 7277 | |
| 7278 | ifname = get_main_ifname(); |
| 7279 | |
| 7280 | val = get_param(cmd, "FrameName"); |
| 7281 | if (!val) |
| 7282 | return -1; |
| 7283 | |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 7284 | if (strcasecmp(val, "BTMReq") == 0) |
| 7285 | ath_ap_send_frame_btm_req(dut, cmd, ifname); |
| 7286 | else if (strcasecmp(val, "BcnRptReq") == 0) |
| 7287 | ath_ap_send_frame_bcn_rpt_req(dut, cmd, ifname); |
| 7288 | else |
| 7289 | return -1; |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 7290 | |
| 7291 | return 1; |
| 7292 | } |
| 7293 | |
| 7294 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7295 | static int ap_send_frame_vht(struct sigma_dut *dut, struct sigma_conn *conn, |
| 7296 | struct sigma_cmd *cmd) |
| 7297 | { |
| 7298 | switch (get_driver_type()) { |
| 7299 | case DRIVER_ATHEROS: |
| 7300 | return ath_ap_send_frame_vht(dut, conn, cmd); |
| 7301 | break; |
| 7302 | case DRIVER_OPENWRT: |
| 7303 | switch (get_openwrt_driver_type()) { |
| 7304 | case OPENWRT_DRIVER_ATHEROS: |
| 7305 | return ath_ap_send_frame_vht(dut, conn, cmd); |
| 7306 | default: |
| 7307 | send_resp(dut, conn, SIGMA_ERROR, |
| 7308 | "errorCode,Unsupported ap_send_frame with the current openwrt driver"); |
| 7309 | return 0; |
| 7310 | } |
| 7311 | default: |
| 7312 | send_resp(dut, conn, SIGMA_ERROR, |
| 7313 | "errorCode,Unsupported ap_send_frame with the current driver"); |
| 7314 | return 0; |
| 7315 | } |
| 7316 | } |
| 7317 | |
| 7318 | |
priyadharshini gowthaman | a27b5b6 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 7319 | static int ap_send_frame_loc(struct sigma_dut *dut, struct sigma_conn *conn, |
| 7320 | struct sigma_cmd *cmd) |
| 7321 | { |
| 7322 | switch (get_driver_type()) { |
| 7323 | case DRIVER_ATHEROS: |
| 7324 | return ath_ap_send_frame_loc(dut, conn, cmd); |
| 7325 | case DRIVER_OPENWRT: |
| 7326 | switch (get_openwrt_driver_type()) { |
| 7327 | case OPENWRT_DRIVER_ATHEROS: |
| 7328 | return ath_ap_send_frame_loc(dut, conn, cmd); |
| 7329 | default: |
| 7330 | send_resp(dut, conn, SIGMA_ERROR, |
| 7331 | "errorCode,Unsupported ap_send_frame_loc with the current openwrt driver"); |
| 7332 | return 0; |
| 7333 | } |
| 7334 | default: |
| 7335 | send_resp(dut, conn, SIGMA_ERROR, |
| 7336 | "errorCode,Unsupported ap_send_frame_loc with the current driver"); |
| 7337 | return 0; |
| 7338 | } |
| 7339 | } |
| 7340 | |
| 7341 | |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 7342 | static int ap_send_frame_mbo(struct sigma_dut *dut, struct sigma_conn *conn, |
| 7343 | struct sigma_cmd *cmd) |
| 7344 | { |
| 7345 | switch (get_driver_type()) { |
| 7346 | case DRIVER_ATHEROS: |
| 7347 | return ath_ap_send_frame_mbo(dut, conn, cmd); |
| 7348 | case DRIVER_OPENWRT: |
| 7349 | switch (get_openwrt_driver_type()) { |
| 7350 | case OPENWRT_DRIVER_ATHEROS: |
| 7351 | return ath_ap_send_frame_mbo(dut, conn, cmd); |
| 7352 | default: |
| 7353 | send_resp(dut, conn, SIGMA_ERROR, |
| 7354 | "errorCode,Unsupported ap_send_frame with the current openwrt driver"); |
| 7355 | return 0; |
| 7356 | } |
| 7357 | default: |
| 7358 | send_resp(dut, conn, SIGMA_ERROR, |
| 7359 | "errorCode,Unsupported ap_send_frame with the current driver"); |
| 7360 | return 0; |
| 7361 | } |
| 7362 | } |
| 7363 | |
| 7364 | |
Lior David | 0fe101e | 2017-03-09 16:09:50 +0200 | [diff] [blame] | 7365 | static int ap_send_frame_60g(struct sigma_dut *dut, |
| 7366 | struct sigma_conn *conn, |
| 7367 | struct sigma_cmd *cmd) |
| 7368 | { |
| 7369 | switch (get_driver_type()) { |
| 7370 | #ifdef __linux__ |
| 7371 | case DRIVER_WIL6210: |
| 7372 | return wil6210_send_frame_60g(dut, conn, cmd); |
| 7373 | #endif /* __linux__ */ |
| 7374 | default: |
| 7375 | send_resp(dut, conn, SIGMA_ERROR, |
| 7376 | "errorCode,Unsupported sta_set_frame(60G) with the current driver"); |
| 7377 | return 0; |
| 7378 | } |
| 7379 | } |
| 7380 | |
| 7381 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7382 | int cmd_ap_send_frame(struct sigma_dut *dut, struct sigma_conn *conn, |
| 7383 | struct sigma_cmd *cmd) |
| 7384 | { |
| 7385 | /* const char *name = get_param(cmd, "NAME"); */ |
| 7386 | /* const char *ifname = get_param(cmd, "INTERFACE"); */ |
| 7387 | const char *val; |
| 7388 | enum send_frame_type frame; |
| 7389 | enum send_frame_protection protected; |
| 7390 | char buf[100]; |
| 7391 | |
| 7392 | val = get_param(cmd, "Program"); |
| 7393 | if (val) { |
| 7394 | if (strcasecmp(val, "HS2") == 0 || |
Adil Saeed Musthafa | 33ea287 | 2017-04-10 23:13:24 -0700 | [diff] [blame] | 7395 | strcasecmp(val, "HS2-R2") == 0 || |
| 7396 | strcasecmp(val, "IOTLP") == 0) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7397 | return ap_send_frame_hs2(dut, conn, cmd); |
| 7398 | if (strcasecmp(val, "VHT") == 0) |
| 7399 | return ap_send_frame_vht(dut, conn, cmd); |
priyadharshini gowthaman | a27b5b6 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 7400 | if (strcasecmp(val, "LOC") == 0) |
| 7401 | return ap_send_frame_loc(dut, conn, cmd); |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 7402 | if (strcasecmp(val, "MBO") == 0) |
| 7403 | return ap_send_frame_mbo(dut, conn, cmd); |
Lior David | 0fe101e | 2017-03-09 16:09:50 +0200 | [diff] [blame] | 7404 | if (strcasecmp(val, "60GHz") == 0) |
| 7405 | return ap_send_frame_60g(dut, conn, cmd); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7406 | } |
| 7407 | |
| 7408 | val = get_param(cmd, "PMFFrameType"); |
| 7409 | if (val == NULL) |
| 7410 | val = get_param(cmd, "FrameName"); |
| 7411 | if (val == NULL) |
| 7412 | val = get_param(cmd, "Type"); |
| 7413 | if (val == NULL) |
| 7414 | return -1; |
| 7415 | if (strcasecmp(val, "disassoc") == 0) |
| 7416 | frame = DISASSOC; |
| 7417 | else if (strcasecmp(val, "deauth") == 0) |
| 7418 | frame = DEAUTH; |
| 7419 | else if (strcasecmp(val, "saquery") == 0) |
| 7420 | frame = SAQUERY; |
| 7421 | else { |
| 7422 | send_resp(dut, conn, SIGMA_ERROR, "errorCode,Unsupported " |
| 7423 | "PMFFrameType"); |
| 7424 | return 0; |
| 7425 | } |
| 7426 | |
| 7427 | val = get_param(cmd, "PMFProtected"); |
| 7428 | if (val == NULL) |
| 7429 | val = get_param(cmd, "Protected"); |
| 7430 | if (val == NULL) |
| 7431 | return -1; |
| 7432 | if (strcasecmp(val, "Correct-key") == 0 || |
| 7433 | strcasecmp(val, "CorrectKey") == 0) |
| 7434 | protected = CORRECT_KEY; |
| 7435 | else if (strcasecmp(val, "IncorrectKey") == 0) |
| 7436 | protected = INCORRECT_KEY; |
| 7437 | else if (strcasecmp(val, "Unprotected") == 0) |
| 7438 | protected = UNPROTECTED; |
| 7439 | else { |
| 7440 | send_resp(dut, conn, SIGMA_ERROR, "errorCode,Unsupported " |
| 7441 | "PMFProtected"); |
| 7442 | return 0; |
| 7443 | } |
| 7444 | |
| 7445 | val = get_param(cmd, "stationID"); |
| 7446 | if (val == NULL) |
| 7447 | return -1; |
| 7448 | |
| 7449 | if (protected == INCORRECT_KEY || |
| 7450 | (protected == UNPROTECTED && frame == SAQUERY)) |
| 7451 | return ap_inject_frame(dut, conn, frame, protected, val); |
| 7452 | |
| 7453 | switch (frame) { |
| 7454 | case DISASSOC: |
| 7455 | snprintf(buf, sizeof(buf), "disassoc %s test=%d", |
| 7456 | val, protected == CORRECT_KEY); |
| 7457 | break; |
| 7458 | case DEAUTH: |
| 7459 | snprintf(buf, sizeof(buf), "deauth %s test=%d", |
| 7460 | val, protected == CORRECT_KEY); |
| 7461 | break; |
| 7462 | case SAQUERY: |
| 7463 | snprintf(buf, sizeof(buf), "sa_query %s", val); |
| 7464 | break; |
| 7465 | } |
| 7466 | |
| 7467 | if (run_hostapd_cli(dut, buf) != 0) |
| 7468 | return -2; |
| 7469 | |
| 7470 | return 1; |
| 7471 | } |
| 7472 | |
| 7473 | |
| 7474 | static int cmd_ap_get_mac_address(struct sigma_dut *dut, |
| 7475 | struct sigma_conn *conn, |
| 7476 | struct sigma_cmd *cmd) |
| 7477 | { |
| 7478 | #if defined( __linux__) |
| 7479 | /* const char *name = get_param(cmd, "NAME"); */ |
| 7480 | /* const char *ifname = get_param(cmd, "INTERFACE"); */ |
| 7481 | char resp[50]; |
| 7482 | unsigned char addr[6]; |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 7483 | char ifname[50]; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7484 | struct ifreq ifr; |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 7485 | int s, wlan_tag = 1; |
| 7486 | const char *val; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7487 | |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 7488 | val = get_param(cmd, "WLAN_TAG"); |
| 7489 | if (val) { |
| 7490 | wlan_tag = atoi(val); |
| 7491 | if (wlan_tag < 1 || wlan_tag > 3) { |
| 7492 | /* |
| 7493 | * The only valid WLAN Tags as of now as per the latest |
| 7494 | * WFA scripts are 1, 2, and 3. |
| 7495 | */ |
| 7496 | send_resp(dut, conn, SIGMA_INVALID, |
| 7497 | "errorCode,Unsupported WLAN_TAG"); |
| 7498 | return 0; |
| 7499 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7500 | } |
| 7501 | |
Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 7502 | get_if_name(dut, ifname, sizeof(ifname), wlan_tag); |
| 7503 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7504 | s = socket(AF_INET, SOCK_DGRAM, 0); |
| 7505 | if (s < 0) |
| 7506 | return -1; |
| 7507 | memset(&ifr, 0, sizeof(ifr)); |
Peng Xu | b8fc5cc | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 7508 | strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name)); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7509 | if (ioctl(s, SIOCGIFHWADDR, &ifr) < 0) { |
| 7510 | perror("ioctl"); |
| 7511 | close(s); |
| 7512 | return -1; |
| 7513 | } |
| 7514 | close(s); |
| 7515 | memcpy(addr, ifr.ifr_hwaddr.sa_data, 6); |
| 7516 | |
| 7517 | snprintf(resp, sizeof(resp), "mac,%02x:%02x:%02x:%02x:%02x:%02x", |
| 7518 | addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]); |
| 7519 | send_resp(dut, conn, SIGMA_COMPLETE, resp); |
| 7520 | return 0; |
| 7521 | #elif defined( __QNXNTO__) |
| 7522 | char resp[50]; |
| 7523 | unsigned char addr[6]; |
| 7524 | |
| 7525 | if (!sigma_main_ifname) { |
| 7526 | send_resp(dut, conn, SIGMA_ERROR, "ifname is null"); |
| 7527 | return 0; |
| 7528 | } |
| 7529 | |
| 7530 | if (get_hwaddr(sigma_main_ifname, addr) != 0) { |
| 7531 | send_resp(dut, conn, SIGMA_ERROR, |
| 7532 | "errorCode,Failed to get address"); |
| 7533 | return 0; |
| 7534 | } |
| 7535 | snprintf(resp, sizeof(resp), "mac,%02x:%02x:%02x:%02x:%02x:%02x", |
| 7536 | addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]); |
| 7537 | send_resp(dut, conn, SIGMA_COMPLETE, resp); |
| 7538 | return 0; |
| 7539 | #else /* __linux__ */ |
| 7540 | send_resp(dut, conn, SIGMA_ERROR, "errorCode,ap_get_mac_address not " |
| 7541 | "yet supported"); |
| 7542 | return 0; |
| 7543 | #endif /* __linux__ */ |
| 7544 | } |
| 7545 | |
| 7546 | |
| 7547 | static int cmd_ap_set_pmf(struct sigma_dut *dut, struct sigma_conn *conn, |
| 7548 | struct sigma_cmd *cmd) |
| 7549 | { |
| 7550 | /* |
| 7551 | * Ignore the command since the parameters are already handled through |
| 7552 | * ap_set_security. |
| 7553 | */ |
| 7554 | |
| 7555 | return 1; |
| 7556 | } |
| 7557 | |
| 7558 | |
| 7559 | static int cmd_ap_set_hs2(struct sigma_dut *dut, struct sigma_conn *conn, |
| 7560 | struct sigma_cmd *cmd) |
| 7561 | { |
| 7562 | /* const char *name = get_param(cmd, "NAME"); */ |
| 7563 | /* const char *ifname = get_param(cmd, "INTERFACE"); */ |
| 7564 | const char *val, *dest; |
| 7565 | char *pos, buf[100]; |
| 7566 | int i, wlan_tag = 1; |
| 7567 | |
| 7568 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_set_hs2: Processing the " |
| 7569 | "following parameters"); |
| 7570 | for (i = 0; i < cmd->count; i++) { |
| 7571 | sigma_dut_print(dut, DUT_MSG_INFO, "%s %s", cmd->params[i], |
| 7572 | (cmd->values[i] ? cmd->values[i] : "NULL")); |
| 7573 | } |
| 7574 | |
| 7575 | val = get_param(cmd, "ICMPv4_ECHO"); |
| 7576 | if (val && atoi(val)) { |
| 7577 | snprintf(buf, sizeof(buf), "ebtables -F"); |
| 7578 | if (system(buf) != 0) { |
| 7579 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 7580 | "Failed to set ebtables rules, RULE-12"); |
| 7581 | } |
| 7582 | return 1; |
| 7583 | } |
| 7584 | |
| 7585 | val = get_param(cmd, "WLAN_TAG"); |
| 7586 | if (val) { |
| 7587 | wlan_tag = atoi(val); |
| 7588 | if (wlan_tag != 1 && wlan_tag != 2) { |
| 7589 | send_resp(dut, conn, SIGMA_INVALID, |
| 7590 | "errorCode,Invalid WLAN_TAG"); |
| 7591 | return 0; |
| 7592 | } |
| 7593 | } |
| 7594 | |
| 7595 | if (wlan_tag == 2) { |
| 7596 | val = get_param(cmd, "PROXY_ARP"); |
| 7597 | if (val) |
| 7598 | dut->ap2_proxy_arp = atoi(val); |
| 7599 | return 1; |
| 7600 | } |
| 7601 | |
| 7602 | dest = get_param(cmd, "STA_MAC"); |
| 7603 | if (dest) { |
| 7604 | /* This is a special/ugly way of using this command. |
| 7605 | * If "Dest" MAC is included, assume that this command |
| 7606 | * is being issued after ap_config_commit for dynamically |
| 7607 | * setting the QoS Map Set. |
| 7608 | */ |
| 7609 | val = get_param(cmd, "QoS_MAP_SET"); |
| 7610 | if (val) { |
| 7611 | dut->ap_qos_map_set = atoi(val); |
| 7612 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_qos_map_set %d", |
| 7613 | dut->ap_qos_map_set); |
| 7614 | } |
| 7615 | |
| 7616 | if (dut->ap_qos_map_set == 1) |
| 7617 | run_hostapd_cli(dut, "set_qos_map_set " QOS_MAP_SET_1); |
| 7618 | else if (dut->ap_qos_map_set == 2) |
| 7619 | run_hostapd_cli(dut, "set_qos_map_set " QOS_MAP_SET_2); |
| 7620 | |
| 7621 | snprintf(buf, sizeof(buf), "send_qos_map_conf %s", dest); |
| 7622 | if (run_hostapd_cli(dut, buf) != 0) |
| 7623 | return -1; |
| 7624 | } |
| 7625 | |
| 7626 | val = get_param(cmd, "DGAF_DISABLE"); |
| 7627 | if (val) |
| 7628 | dut->ap_dgaf_disable = atoi(val); |
| 7629 | |
| 7630 | dut->ap_interworking = 1; |
| 7631 | |
| 7632 | val = get_param(cmd, "INTERWORKING"); |
| 7633 | if (val == NULL) |
| 7634 | val = get_param(cmd, "INTERNETWORKING"); |
| 7635 | if (val != NULL && atoi(val) == 0) { |
| 7636 | dut->ap_interworking = 0; |
| 7637 | dut->ap_hs2 = 0; |
| 7638 | return 1; |
| 7639 | } |
| 7640 | |
| 7641 | val = get_param(cmd, "ACCS_NET_TYPE"); |
| 7642 | if (val) { |
| 7643 | if (strcasecmp(val, "Chargeable_Public_Network") == 0 || |
| 7644 | strcasecmp(val, "Chargable_Public_Network") == 0 || |
| 7645 | strcasecmp(val, "Chargable Public Network") == 0) |
| 7646 | dut->ap_access_net_type = 2; |
| 7647 | else |
| 7648 | dut->ap_access_net_type = atoi(val); |
| 7649 | } |
| 7650 | |
| 7651 | val = get_param(cmd, "INTERNET"); |
| 7652 | if (val) |
| 7653 | dut->ap_internet = atoi(val); |
| 7654 | |
| 7655 | val = get_param(cmd, "VENUE_GRP"); |
| 7656 | if (val) { |
| 7657 | if (strcasecmp(val, "Business") == 0) |
| 7658 | dut->ap_venue_group = 2; |
| 7659 | else |
| 7660 | dut->ap_venue_group = atoi(val); |
| 7661 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_venue_name %d", |
| 7662 | dut->ap_venue_name); |
| 7663 | } |
| 7664 | |
| 7665 | val = get_param(cmd, "VENUE_TYPE"); |
| 7666 | if (val) { |
| 7667 | if (strcasecmp(val, "R&D") == 0) |
| 7668 | dut->ap_venue_type = 8; |
| 7669 | else |
| 7670 | dut->ap_venue_type = atoi(val); |
| 7671 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_venue_type %d", |
| 7672 | dut->ap_venue_type); |
| 7673 | } |
| 7674 | |
| 7675 | val = get_param(cmd, "HESSID"); |
| 7676 | if (val) { |
| 7677 | if (strlen(val) >= sizeof(dut->ap_hessid)) { |
| 7678 | send_resp(dut, conn, SIGMA_ERROR, |
| 7679 | "errorCode,Invalid HESSID"); |
| 7680 | return 0; |
| 7681 | } |
| 7682 | snprintf(dut->ap_hessid, sizeof(dut->ap_hessid), "%s", val); |
| 7683 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_hessid %s", |
| 7684 | dut->ap_hessid); |
| 7685 | } |
| 7686 | |
| 7687 | val = get_param(cmd, "ROAMING_CONS"); |
| 7688 | if (val) { |
| 7689 | if (strlen(val) >= sizeof(dut->ap_roaming_cons)) { |
| 7690 | send_resp(dut, conn, SIGMA_ERROR, |
| 7691 | "errorCode,Invalid ROAMING_CONS"); |
| 7692 | return 0; |
| 7693 | } |
| 7694 | if (strcasecmp(val, "Disabled") == 0) { |
| 7695 | dut->ap_roaming_cons[0] = '\0'; |
| 7696 | } else { |
| 7697 | snprintf(dut->ap_roaming_cons, |
| 7698 | sizeof(dut->ap_roaming_cons), "%s", val); |
| 7699 | } |
| 7700 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_roaming_cons %s", |
| 7701 | dut->ap_roaming_cons); |
| 7702 | } |
| 7703 | |
| 7704 | val = get_param(cmd, "ANQP"); |
| 7705 | if (val) |
| 7706 | dut->ap_anqpserver_on = atoi(val); |
| 7707 | |
| 7708 | val = get_param(cmd, "NAI_REALM_LIST"); |
| 7709 | if (val) { |
| 7710 | dut->ap_nai_realm_list = atoi(val); |
| 7711 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_nai_realm_list %d", |
| 7712 | dut->ap_nai_realm_list); |
| 7713 | } |
| 7714 | |
| 7715 | val = get_param(cmd, "3GPP_INFO"); |
| 7716 | if (val) { |
| 7717 | /* What kind of encoding format is used?! */ |
| 7718 | send_resp(dut, conn, SIGMA_ERROR, "errorCode,3GPP_INFO " |
| 7719 | "not yet supported (contents not fully defined)"); |
| 7720 | return 0; |
| 7721 | } |
| 7722 | |
| 7723 | val = get_param(cmd, "DOMAIN_LIST"); |
| 7724 | if (val) { |
| 7725 | if (strlen(val) >= sizeof(dut->ap_domain_name_list)) { |
| 7726 | send_resp(dut, conn, SIGMA_ERROR, "errorCode,Too long " |
| 7727 | "DOMAIN_LIST"); |
| 7728 | return 0; |
| 7729 | } |
| 7730 | snprintf(dut->ap_domain_name_list, |
| 7731 | sizeof(dut->ap_domain_name_list), "%s", val); |
| 7732 | pos = dut->ap_domain_name_list; |
| 7733 | while (*pos) { |
| 7734 | if (*pos == ';') |
| 7735 | *pos = ','; |
| 7736 | pos++; |
| 7737 | } |
| 7738 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_domain_name_list %s", |
| 7739 | dut->ap_domain_name_list); |
| 7740 | } |
| 7741 | |
| 7742 | val = get_param(cmd, "OPER_NAME"); |
| 7743 | if (val) { |
| 7744 | dut->ap_oper_name = atoi(val); |
| 7745 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_oper_name %d", |
| 7746 | dut->ap_oper_name); |
| 7747 | } |
| 7748 | |
| 7749 | val = get_param(cmd, "VENUE_NAME"); |
| 7750 | if (val) { |
| 7751 | dut->ap_venue_name = atoi(val); |
| 7752 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_venue_name %d", |
| 7753 | dut->ap_venue_name); |
| 7754 | } |
| 7755 | |
| 7756 | val = get_param(cmd, "GAS_CB_DELAY"); |
| 7757 | if (val) { |
| 7758 | dut->ap_gas_cb_delay = atoi(val); |
| 7759 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_gas_cb_delay %d", |
| 7760 | dut->ap_gas_cb_delay); |
| 7761 | } |
| 7762 | |
| 7763 | val = get_param(cmd, "MIH"); |
| 7764 | if (val && atoi(val) > 0) { |
| 7765 | send_resp(dut, conn, SIGMA_ERROR, "errorCode,MIH not " |
| 7766 | "supported"); |
| 7767 | return 0; |
| 7768 | } |
| 7769 | |
| 7770 | val = get_param(cmd, "L2_TRAFFIC_INSPECT"); |
| 7771 | if (val) { |
| 7772 | dut->ap_l2tif = atoi(val); |
| 7773 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_l2tif %d", |
| 7774 | dut->ap_l2tif); |
| 7775 | } |
| 7776 | |
| 7777 | val = get_param(cmd, "BCST_UNCST"); |
| 7778 | if (val) { |
| 7779 | send_resp(dut, conn, SIGMA_ERROR, |
| 7780 | "errorCode,BCST_UNCST not yet supported"); |
| 7781 | return 0; |
| 7782 | } |
| 7783 | |
| 7784 | val = get_param(cmd, "PLMN_MCC"); |
| 7785 | if (val) { |
| 7786 | char mcc[100], *start, *end; |
| 7787 | int i = 0; |
| 7788 | if (strlen(val) >= sizeof(mcc)) { |
| 7789 | send_resp(dut, conn, SIGMA_ERROR, |
| 7790 | "errorCode,PLMN_MCC too long"); |
| 7791 | return 0; |
| 7792 | } |
Peng Xu | b8fc5cc | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 7793 | strlcpy(mcc, val, sizeof(mcc)); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7794 | start = mcc; |
| 7795 | while ((end = strchr(start, ';'))) { |
| 7796 | /* process all except the last */ |
| 7797 | *end = '\0'; |
| 7798 | if (strlen(start) != 3) { |
| 7799 | send_resp(dut, conn, SIGMA_ERROR, |
| 7800 | "errorCode,Invalid PLMN_MCC"); |
| 7801 | return 0; |
| 7802 | } |
| 7803 | snprintf(dut->ap_plmn_mcc[i], |
| 7804 | sizeof(dut->ap_plmn_mcc[i]), "%s", start); |
| 7805 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_plmn_mcc %s", |
| 7806 | dut->ap_plmn_mcc[i]); |
| 7807 | i++; |
| 7808 | start = end + 1; |
| 7809 | *end = ';'; |
| 7810 | } |
| 7811 | if (strlen(start) != 3) { |
| 7812 | send_resp(dut, conn, SIGMA_ERROR, |
| 7813 | "errorCode,Invalid PLMN_MCC"); |
| 7814 | return 0; |
| 7815 | } |
| 7816 | /* process last or only one */ |
| 7817 | snprintf(dut->ap_plmn_mcc[i], |
| 7818 | sizeof(dut->ap_plmn_mcc[i]), "%s", start); |
| 7819 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_plmn_mcc %s", |
| 7820 | dut->ap_plmn_mcc[i]); |
| 7821 | } |
| 7822 | |
| 7823 | val = get_param(cmd, "PLMN_MNC"); |
| 7824 | if (val) { |
| 7825 | char mnc[100], *start, *end; |
| 7826 | int i = 0; |
| 7827 | if (strlen(val) >= sizeof(mnc)) { |
| 7828 | send_resp(dut, conn, SIGMA_ERROR, |
| 7829 | "errorCode,PLMN_MNC too long"); |
| 7830 | return 0; |
| 7831 | } |
Peng Xu | b8fc5cc | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 7832 | strlcpy(mnc, val, sizeof(mnc)); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7833 | start = mnc; |
| 7834 | while ((end = strchr(start, ';'))) { |
| 7835 | *end = '\0'; |
| 7836 | if (strlen(start) != 2 && strlen(start) != 3) { |
| 7837 | send_resp(dut, conn, SIGMA_ERROR, |
| 7838 | "errorCode,Invalid PLMN_MNC"); |
| 7839 | return 0; |
| 7840 | } |
| 7841 | snprintf(dut->ap_plmn_mnc[i], |
| 7842 | sizeof(dut->ap_plmn_mnc[i]), "%s", start); |
| 7843 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_plmn_mnc %s", |
| 7844 | dut->ap_plmn_mnc[i]); |
| 7845 | i++; |
| 7846 | start = end + 1; |
| 7847 | *end = ';'; |
| 7848 | } |
| 7849 | if (strlen(start) != 2 && strlen(start) != 3) { |
| 7850 | send_resp(dut, conn, SIGMA_ERROR, |
| 7851 | "errorCode,Invalid PLMN_MNC"); |
| 7852 | return 0; |
| 7853 | } |
| 7854 | snprintf(dut->ap_plmn_mnc[i], |
| 7855 | sizeof(dut->ap_plmn_mnc[i]), "%s", start); |
| 7856 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_plmn_mnc %s", |
| 7857 | dut->ap_plmn_mnc[i]); |
| 7858 | } |
| 7859 | |
| 7860 | val = get_param(cmd, "PROXY_ARP"); |
| 7861 | if (val) { |
| 7862 | dut->ap_proxy_arp = atoi(val); |
| 7863 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_proxy_arp %d", |
| 7864 | dut->ap_proxy_arp); |
| 7865 | } |
| 7866 | |
| 7867 | val = get_param(cmd, "WAN_METRICS"); |
| 7868 | if (val) { |
| 7869 | dut->ap_wan_metrics = atoi(val); |
| 7870 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_wan_metrics %d", |
| 7871 | dut->ap_wan_metrics); |
| 7872 | } |
| 7873 | |
| 7874 | val = get_param(cmd, "CONN_CAP"); |
| 7875 | if (val) { |
| 7876 | dut->ap_conn_capab = atoi(val); |
| 7877 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_conn_capab %d", |
| 7878 | dut->ap_conn_capab); |
| 7879 | } |
| 7880 | |
| 7881 | val = get_param(cmd, "IP_ADD_TYPE_AVAIL"); |
| 7882 | if (val) { |
| 7883 | dut->ap_ip_addr_type_avail = atoi(val); |
| 7884 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_ip_addr_type_avail %d", |
| 7885 | dut->ap_ip_addr_type_avail); |
| 7886 | } |
| 7887 | |
| 7888 | val = get_param(cmd, "NET_AUTH_TYPE"); |
| 7889 | if (val) { |
| 7890 | dut->ap_net_auth_type = atoi(val); |
| 7891 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_net_auth_type %d", |
| 7892 | dut->ap_net_auth_type); |
| 7893 | } |
| 7894 | |
| 7895 | val = get_param(cmd, "OP_CLASS"); |
| 7896 | if (val == NULL) |
| 7897 | val = get_param(cmd, "OPER_CLASS"); |
| 7898 | if (val) { |
| 7899 | dut->ap_oper_class = atoi(val); |
| 7900 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_oper_class %d", |
| 7901 | dut->ap_oper_class); |
| 7902 | } |
| 7903 | |
| 7904 | val = get_param(cmd, "OSU_PROVIDER_LIST"); |
| 7905 | if (val) { |
| 7906 | dut->ap_osu_provider_list = atoi(val); |
| 7907 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_osu_provider_list %d", |
| 7908 | dut->ap_osu_provider_list); |
| 7909 | } |
| 7910 | |
| 7911 | val = get_param(cmd, "OSU_SERVER_URI"); |
| 7912 | if (val) { |
| 7913 | i = 0; |
| 7914 | do { |
| 7915 | int len; |
| 7916 | const char *uri = val; |
| 7917 | val = strchr(val, ' '); |
| 7918 | len = val ? (val++ - uri) : (int) strlen(uri); |
| 7919 | if (len > 0 && len < 256) { |
| 7920 | memcpy(dut->ap_osu_server_uri[i], uri, len); |
| 7921 | dut->ap_osu_server_uri[i][len] = '\0'; |
| 7922 | sigma_dut_print(dut, DUT_MSG_INFO, |
| 7923 | "ap_osu_server_uri[%d] %s", i, |
| 7924 | dut->ap_osu_server_uri[i]); |
| 7925 | } |
| 7926 | } while (val && ++i < 10); |
| 7927 | } |
| 7928 | |
| 7929 | val = get_param(cmd, "OSU_METHOD"); |
| 7930 | if (val) { |
| 7931 | i = 0; |
| 7932 | do { |
| 7933 | int len; |
| 7934 | const char *method = val; |
| 7935 | val = strchr(val, ' '); |
| 7936 | len = val ? (val++ - method) : (int) strlen(method); |
| 7937 | if (len > 0) { |
| 7938 | if (strncasecmp(method, "SOAP", len) == 0) |
| 7939 | dut->ap_osu_method[i] = 1; |
| 7940 | else if (strncasecmp(method, "OMADM", len) == 0) |
| 7941 | dut->ap_osu_method[i] = 0; |
| 7942 | else |
| 7943 | return -2; |
| 7944 | } |
| 7945 | } while (val && ++i < 10); |
| 7946 | } |
| 7947 | |
| 7948 | val = get_param(cmd, "OSU_SSID"); |
| 7949 | if (val) { |
| 7950 | if (strlen(val) > 0 && strlen(val) <= 32) { |
Peng Xu | b8fc5cc | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 7951 | strlcpy(dut->ap_osu_ssid, val, |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7952 | sizeof(dut->ap_osu_ssid)); |
| 7953 | sigma_dut_print(dut, DUT_MSG_INFO, |
| 7954 | "ap_osu_ssid %s", |
| 7955 | dut->ap_osu_ssid); |
| 7956 | } |
| 7957 | } |
| 7958 | |
| 7959 | val = get_param(cmd, "OSU_ICON_TAG"); |
| 7960 | if (val) |
| 7961 | dut->ap_osu_icon_tag = atoi(val); |
| 7962 | |
| 7963 | val = get_param(cmd, "QoS_MAP_SET"); |
| 7964 | if (val) { |
| 7965 | dut->ap_qos_map_set = atoi(val); |
| 7966 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_qos_map_set %d", |
| 7967 | dut->ap_qos_map_set); |
| 7968 | } |
| 7969 | |
| 7970 | val = get_param(cmd, "BSS_LOAD"); |
| 7971 | if (val) { |
| 7972 | dut->ap_bss_load = atoi(val); |
| 7973 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_bss_load %d", |
| 7974 | dut->ap_bss_load); |
| 7975 | } |
| 7976 | |
| 7977 | return 1; |
| 7978 | } |
| 7979 | |
| 7980 | |
| 7981 | void nfc_status(struct sigma_dut *dut, const char *state, const char *oper) |
| 7982 | { |
| 7983 | char buf[100]; |
| 7984 | |
| 7985 | if (!file_exists("nfc-status")) |
| 7986 | return; |
| 7987 | |
| 7988 | snprintf(buf, sizeof(buf), "./nfc-status %s %s", state, oper); |
| 7989 | run_system(dut, buf); |
| 7990 | } |
| 7991 | |
| 7992 | |
| 7993 | static int run_nfc_command(struct sigma_dut *dut, const char *cmd, |
| 7994 | const char *info) |
| 7995 | { |
| 7996 | int res; |
| 7997 | |
| 7998 | printf("\n\n\n=====[ NFC operation ]=========================\n\n"); |
| 7999 | printf("%s\n\n", info); |
| 8000 | |
| 8001 | nfc_status(dut, "START", info); |
| 8002 | res = run_system(dut, cmd); |
| 8003 | nfc_status(dut, res ? "FAIL" : "SUCCESS", info); |
| 8004 | if (res) { |
| 8005 | sigma_dut_print(dut, DUT_MSG_INFO, "Failed to run '%s': %d", |
| 8006 | cmd, res); |
| 8007 | return res; |
| 8008 | } |
| 8009 | |
| 8010 | return 0; |
| 8011 | } |
| 8012 | |
| 8013 | |
| 8014 | static int ap_nfc_write_config_token(struct sigma_dut *dut, |
| 8015 | struct sigma_conn *conn, |
| 8016 | struct sigma_cmd *cmd) |
| 8017 | { |
| 8018 | int res; |
| 8019 | char buf[300]; |
| 8020 | |
| 8021 | run_system(dut, "killall wps-ap-nfc.py"); |
| 8022 | unlink("nfc-success"); |
| 8023 | snprintf(buf, sizeof(buf), |
| 8024 | "./wps-ap-nfc.py --no-wait %s%s --success nfc-success write-config", |
| 8025 | dut->summary_log ? "--summary " : "", |
| 8026 | dut->summary_log ? dut->summary_log : ""); |
| 8027 | res = run_nfc_command(dut, buf, |
| 8028 | "Touch NFC Tag to write WPS configuration token"); |
| 8029 | if (res || !file_exists("nfc-success")) { |
| 8030 | send_resp(dut, conn, SIGMA_ERROR, |
| 8031 | "ErrorCode,Failed to write tag"); |
| 8032 | return 0; |
| 8033 | } |
| 8034 | |
| 8035 | return 1; |
| 8036 | } |
| 8037 | |
| 8038 | |
| 8039 | static int ap_nfc_wps_read_passwd(struct sigma_dut *dut, |
| 8040 | struct sigma_conn *conn, |
| 8041 | struct sigma_cmd *cmd) |
| 8042 | { |
| 8043 | int res; |
| 8044 | char buf[300]; |
| 8045 | |
| 8046 | run_system(dut, "killall wps-ap-nfc.py"); |
| 8047 | |
| 8048 | unlink("nfc-success"); |
| 8049 | snprintf(buf, sizeof(buf), |
| 8050 | "./wps-ap-nfc.py -1 --no-wait %s%s --success nfc-success", |
| 8051 | dut->summary_log ? "--summary " : "", |
| 8052 | dut->summary_log ? dut->summary_log : ""); |
| 8053 | res = run_nfc_command(dut, buf, "Touch NFC Tag to read it"); |
| 8054 | if (res || !file_exists("nfc-success")) { |
| 8055 | send_resp(dut, conn, SIGMA_ERROR, |
| 8056 | "ErrorCode,Failed to read tag"); |
| 8057 | return 0; |
| 8058 | } |
| 8059 | |
| 8060 | return 1; |
| 8061 | } |
| 8062 | |
| 8063 | |
| 8064 | static int ap_nfc_write_password_token(struct sigma_dut *dut, |
| 8065 | struct sigma_conn *conn, |
| 8066 | struct sigma_cmd *cmd) |
| 8067 | { |
| 8068 | int res; |
| 8069 | char buf[300]; |
| 8070 | |
| 8071 | run_system(dut, "killall wps-ap-nfc.py"); |
| 8072 | unlink("nfc-success"); |
| 8073 | snprintf(buf, sizeof(buf), |
| 8074 | "./wps-ap-nfc.py --no-wait %s%s --success nfc-success write-password", |
| 8075 | dut->summary_log ? "--summary " : "", |
| 8076 | dut->summary_log ? dut->summary_log : ""); |
| 8077 | res = run_nfc_command(dut, buf, |
| 8078 | "Touch NFC Tag to write WPS password token"); |
| 8079 | if (res || !file_exists("nfc-success")) { |
| 8080 | send_resp(dut, conn, SIGMA_ERROR, |
| 8081 | "ErrorCode,Failed to write tag"); |
| 8082 | return 0; |
| 8083 | } |
| 8084 | |
| 8085 | if (run_hostapd_cli(dut, "wps_nfc_token enable") != 0) { |
| 8086 | send_resp(dut, conn, SIGMA_ERROR, |
| 8087 | "ErrorCode,Failed to enable NFC password token"); |
| 8088 | return 0; |
| 8089 | } |
| 8090 | |
| 8091 | return 1; |
| 8092 | } |
| 8093 | |
| 8094 | |
| 8095 | static int ap_nfc_wps_connection_handover(struct sigma_dut *dut, |
| 8096 | struct sigma_conn *conn, |
| 8097 | struct sigma_cmd *cmd) |
| 8098 | { |
| 8099 | int res; |
| 8100 | char buf[300]; |
| 8101 | |
| 8102 | run_system(dut, "killall wps-ap-nfc.py"); |
| 8103 | unlink("nfc-success"); |
| 8104 | snprintf(buf, sizeof(buf), |
| 8105 | "./wps-ap-nfc.py -1 --no-wait %s%s --success nfc-success", |
| 8106 | dut->summary_log ? "--summary " : "", |
| 8107 | dut->summary_log ? dut->summary_log : ""); |
| 8108 | res = run_nfc_command(dut, buf, |
| 8109 | "Touch NFC Device to respond to WPS connection handover"); |
| 8110 | if (res) { |
| 8111 | send_resp(dut, conn, SIGMA_ERROR, |
| 8112 | "ErrorCode,Failed to enable NFC for connection " |
| 8113 | "handover"); |
| 8114 | return 0; |
| 8115 | } |
| 8116 | if (!file_exists("nfc-success")) { |
| 8117 | send_resp(dut, conn, SIGMA_ERROR, |
| 8118 | "ErrorCode,Failed to complete NFC connection handover"); |
| 8119 | return 0; |
| 8120 | } |
| 8121 | |
| 8122 | return 1; |
| 8123 | } |
| 8124 | |
| 8125 | |
| 8126 | static int cmd_ap_nfc_action(struct sigma_dut *dut, struct sigma_conn *conn, |
| 8127 | struct sigma_cmd *cmd) |
| 8128 | { |
| 8129 | /* const char *name = get_param(cmd, "Name"); */ |
| 8130 | /* const char *intf = get_param(cmd, "Interface"); */ |
| 8131 | const char *oper = get_param(cmd, "Operation"); |
| 8132 | |
| 8133 | if (oper == NULL) |
| 8134 | return -1; |
| 8135 | |
| 8136 | if (strcasecmp(oper, "WRITE_CONFIG") == 0) |
| 8137 | return ap_nfc_write_config_token(dut, conn, cmd); |
| 8138 | if (strcasecmp(oper, "WRITE_PASSWD") == 0) |
| 8139 | return ap_nfc_write_password_token(dut, conn, cmd); |
| 8140 | if (strcasecmp(oper, "WPS_READ_PASSWD") == 0) |
| 8141 | return ap_nfc_wps_read_passwd(dut, conn, cmd); |
| 8142 | if (strcasecmp(oper, "WPS_CONN_HNDOVR") == 0) |
| 8143 | return ap_nfc_wps_connection_handover(dut, conn, cmd); |
| 8144 | |
| 8145 | send_resp(dut, conn, SIGMA_ERROR, "ErrorCode,Unsupported operation"); |
| 8146 | return 0; |
| 8147 | } |
| 8148 | |
| 8149 | |
| 8150 | static int cmd_ap_wps_read_pin(struct sigma_dut *dut, struct sigma_conn *conn, |
| 8151 | struct sigma_cmd *cmd) |
| 8152 | { |
| 8153 | char *pin = "12345670"; /* TODO: use random PIN */ |
| 8154 | char resp[100]; |
| 8155 | |
| 8156 | snprintf(resp, sizeof(resp), "PIN,%s", pin); |
| 8157 | send_resp(dut, conn, SIGMA_COMPLETE, resp); |
| 8158 | |
| 8159 | return 0; |
| 8160 | } |
| 8161 | |
| 8162 | |
| 8163 | static int ath_vht_op_mode_notif(struct sigma_dut *dut, const char *ifname, |
| 8164 | const char *val) |
| 8165 | { |
| 8166 | char *token, *result; |
| 8167 | int nss = 0, chwidth = 0; |
| 8168 | char buf[100]; |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 8169 | char *saveptr; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8170 | |
| 8171 | /* |
| 8172 | * The following commands should be invoked to generate |
| 8173 | * VHT op mode notification |
| 8174 | */ |
| 8175 | |
| 8176 | /* Extract the NSS info */ |
| 8177 | token = strdup(val); |
| 8178 | if (!token) |
| 8179 | return -1; |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 8180 | result = strtok_r(token, ";", &saveptr); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8181 | if (result) { |
| 8182 | int count = atoi(result); |
| 8183 | |
| 8184 | /* We do not support NSS > 3 */ |
| 8185 | if (count < 0 || count > 3) { |
| 8186 | free(token); |
| 8187 | return -1; |
| 8188 | } |
| 8189 | |
| 8190 | /* Convert nss to chainmask */ |
| 8191 | while (count--) |
| 8192 | nss = (nss << 1) | 1; |
| 8193 | |
| 8194 | snprintf(buf, sizeof(buf), "iwpriv %s rxchainmask %d", |
| 8195 | ifname, nss); |
| 8196 | if (system(buf) != 0) { |
| 8197 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 8198 | "iwpriv wifi1 rxchainmask failed!"); |
| 8199 | } |
| 8200 | } |
| 8201 | |
| 8202 | /* Extract the Channel width info */ |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 8203 | result = strtok_r(NULL, ";", &saveptr); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8204 | if (result) { |
| 8205 | switch (atoi(result)) { |
| 8206 | case 20: |
| 8207 | chwidth = 0; |
| 8208 | break; |
| 8209 | case 40: |
| 8210 | chwidth = 1; |
| 8211 | break; |
| 8212 | case 80: |
| 8213 | chwidth = 2; |
| 8214 | break; |
| 8215 | case 160: |
| 8216 | chwidth = 3; |
| 8217 | break; |
| 8218 | default: |
| 8219 | chwidth = 2; |
| 8220 | break; |
| 8221 | } |
| 8222 | snprintf(buf, sizeof(buf), "iwpriv %s chwidth %d", |
| 8223 | ifname, chwidth); |
| 8224 | if (system(buf) != 0) { |
| 8225 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 8226 | "iwpriv chwidth failed!"); |
| 8227 | } |
| 8228 | } |
| 8229 | |
| 8230 | /* Send the opmode notification */ |
Sunil Dutt | 27ec7f6 | 2017-09-14 18:22:59 +0300 | [diff] [blame] | 8231 | snprintf(buf, sizeof(buf), "iwpriv %s opmode_notify 1", ifname); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8232 | if (system(buf) != 0) { |
| 8233 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 8234 | "iwpriv opmode_notify failed!"); |
| 8235 | } |
| 8236 | free(token); |
| 8237 | |
| 8238 | return 0; |
| 8239 | } |
| 8240 | |
| 8241 | |
| 8242 | static int ath_vht_nss_mcs(struct sigma_dut *dut, const char *ifname, |
| 8243 | const char *val) |
| 8244 | { |
| 8245 | /* String (nss_operating_mode; mcs_operating_mode) */ |
| 8246 | int nss, mcs; |
| 8247 | char *token, *result; |
| 8248 | char buf[100]; |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 8249 | char *saveptr; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8250 | |
| 8251 | token = strdup(val); |
| 8252 | if (!token) |
| 8253 | return -1; |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 8254 | result = strtok_r(token, ";", &saveptr); |
Pradeep Reddy POTTETI | 41b8c54 | 2016-06-15 16:09:46 +0530 | [diff] [blame] | 8255 | if (!result) { |
| 8256 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 8257 | "VHT NSS not specified"); |
| 8258 | goto end; |
| 8259 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8260 | if (strcasecmp(result, "def") != 0) { |
| 8261 | nss = atoi(result); |
| 8262 | |
| 8263 | if (nss == 4) |
| 8264 | ath_disable_txbf(dut, ifname); |
| 8265 | |
| 8266 | snprintf(buf, sizeof(buf), "iwpriv %s nss %d", ifname, nss); |
| 8267 | if (system(buf) != 0) { |
| 8268 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 8269 | "iwpriv nss failed"); |
| 8270 | } |
| 8271 | } else { |
| 8272 | if (dut->device_type == AP_testbed && dut->ap_sgi80 == 1) { |
| 8273 | snprintf(buf, sizeof(buf), "iwpriv %s nss 1", ifname); |
| 8274 | if (system(buf) != 0) { |
| 8275 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 8276 | "iwpriv nss failed"); |
| 8277 | } |
| 8278 | } |
| 8279 | } |
| 8280 | |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 8281 | result = strtok_r(NULL, ";", &saveptr); |
Pradeep Reddy POTTETI | 41b8c54 | 2016-06-15 16:09:46 +0530 | [diff] [blame] | 8282 | if (!result) { |
| 8283 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 8284 | "VHT MCS not specified"); |
| 8285 | goto end; |
| 8286 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8287 | if (strcasecmp(result, "def") == 0) { |
| 8288 | if (dut->device_type == AP_testbed && dut->ap_sgi80 == 1) { |
| 8289 | snprintf(buf, sizeof(buf), "iwpriv %s vhtmcs 7", |
| 8290 | ifname); |
| 8291 | if (system(buf) != 0) { |
| 8292 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 8293 | "iwpriv vhtmcs failed"); |
| 8294 | } |
| 8295 | } else { |
| 8296 | snprintf(buf, sizeof(buf), |
| 8297 | "iwpriv %s set11NRates 0", ifname); |
| 8298 | if (system(buf) != 0) { |
| 8299 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 8300 | "iwpriv set11NRates failed"); |
| 8301 | } |
| 8302 | } |
| 8303 | } else { |
| 8304 | mcs = atoi(result); |
| 8305 | snprintf(buf, sizeof(buf), "iwpriv %s vhtmcs %d", ifname, mcs); |
| 8306 | if (system(buf) != 0) { |
| 8307 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 8308 | "iwpriv vhtmcs failed"); |
| 8309 | } |
| 8310 | } |
| 8311 | |
Pradeep Reddy POTTETI | 41b8c54 | 2016-06-15 16:09:46 +0530 | [diff] [blame] | 8312 | end: |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8313 | free(token); |
| 8314 | return 0; |
| 8315 | } |
| 8316 | |
| 8317 | |
| 8318 | static int ath_vht_chnum_band(struct sigma_dut *dut, const char *ifname, |
| 8319 | const char *val) |
| 8320 | { |
| 8321 | char *token, *result; |
| 8322 | int channel = 36; |
| 8323 | int chwidth = 80; |
| 8324 | char buf[100]; |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 8325 | char *saveptr; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8326 | |
| 8327 | /* Extract the channel info */ |
| 8328 | token = strdup(val); |
| 8329 | if (!token) |
| 8330 | return -1; |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 8331 | result = strtok_r(token, ";", &saveptr); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8332 | if (result) |
| 8333 | channel = atoi(result); |
| 8334 | |
| 8335 | /* Extract the channel width info */ |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 8336 | result = strtok_r(NULL, ";", &saveptr); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8337 | if (result) |
| 8338 | chwidth = atoi(result); |
| 8339 | |
| 8340 | /* Issue the channel switch command */ |
| 8341 | snprintf(buf, sizeof(buf), "iwpriv %s doth_ch_chwidth %d 10 %d", |
| 8342 | ifname, channel, chwidth); |
| 8343 | if (system(buf) != 0) { |
| 8344 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 8345 | "iwpriv doth_ch_chwidth failed!"); |
| 8346 | } |
| 8347 | |
| 8348 | free(token); |
| 8349 | return 0; |
| 8350 | } |
| 8351 | |
| 8352 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8353 | static int ath_ndpa_stainfo_mac(struct sigma_dut *dut, const char *ifname, |
| 8354 | const char *val) |
| 8355 | { |
| 8356 | char buf[80]; |
| 8357 | unsigned char mac_addr[6]; |
| 8358 | |
| 8359 | if (parse_mac_address(dut, val, mac_addr) < 0) |
| 8360 | return -1; |
| 8361 | |
| 8362 | snprintf(buf, sizeof(buf), |
| 8363 | "wifitool %s beeliner_fw_test 92 0x%02x%02x%02x%02x", |
| 8364 | ifname, mac_addr[0], mac_addr[1], mac_addr[2], mac_addr[3]); |
| 8365 | run_system(dut, buf); |
| 8366 | |
| 8367 | snprintf(buf, sizeof(buf), "wifitool %s beeliner_fw_test 93 0x%02x%02x", |
| 8368 | ifname, mac_addr[4], mac_addr[5]); |
| 8369 | run_system(dut, buf); |
| 8370 | |
| 8371 | snprintf(buf, sizeof(buf), "wifitool %s beeliner_fw_test 94 1", ifname); |
| 8372 | run_system(dut, buf); |
| 8373 | |
| 8374 | return 0; |
| 8375 | } |
| 8376 | |
| 8377 | |
priyadharshini gowthaman | e5e2517 | 2015-12-08 14:53:48 -0800 | [diff] [blame] | 8378 | void novap_reset(struct sigma_dut *dut, const char *ifname) |
Priyadharshini Gowthaman | 39beafa | 2015-11-09 14:11:25 -0800 | [diff] [blame] | 8379 | { |
| 8380 | char buf[60]; |
| 8381 | |
| 8382 | snprintf(buf, sizeof(buf), "iwpriv %s novap_reset 1", ifname); |
| 8383 | if (system(buf) != 0) { |
| 8384 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 8385 | "disabling novap reset failed"); |
| 8386 | } |
| 8387 | } |
| 8388 | |
| 8389 | |
Adil Saeed Musthafa | 6906372 | 2017-04-10 23:13:40 -0700 | [diff] [blame] | 8390 | struct mbo_pref_ap * mbo_find_nebor_ap_entry(struct sigma_dut *dut, |
| 8391 | const uint8_t *mac_addr) |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 8392 | { |
Adil Saeed Musthafa | 6906372 | 2017-04-10 23:13:40 -0700 | [diff] [blame] | 8393 | int i; |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 8394 | |
Adil Saeed Musthafa | 6906372 | 2017-04-10 23:13:40 -0700 | [diff] [blame] | 8395 | for (i = 0; i < dut->mbo_pref_ap_cnt; i++) { |
| 8396 | if (memcmp(mac_addr, dut->mbo_pref_aps[i].mac_addr, |
| 8397 | ETH_ALEN) == 0) |
| 8398 | return &dut->mbo_pref_aps[i]; |
| 8399 | } |
| 8400 | return NULL; |
| 8401 | } |
| 8402 | |
| 8403 | |
| 8404 | static void mbo_add_nebor_entry(struct sigma_dut *dut, const uint8_t *mac_addr, |
| 8405 | int ap_ne_class, int ap_ne_op_ch, |
| 8406 | int ap_ne_pref) |
| 8407 | { |
| 8408 | struct mbo_pref_ap *entry; |
| 8409 | uint8_t self_mac[ETH_ALEN]; |
| 8410 | char ifname[50]; |
| 8411 | |
| 8412 | get_if_name(dut, ifname, sizeof(ifname), 1); |
| 8413 | get_hwaddr(ifname, self_mac); |
| 8414 | |
| 8415 | if (memcmp(mac_addr, self_mac, ETH_ALEN) == 0) |
| 8416 | entry = &dut->mbo_self_ap_tuple; |
| 8417 | else |
| 8418 | entry = mbo_find_nebor_ap_entry(dut, mac_addr); |
| 8419 | |
| 8420 | if (!entry) { |
| 8421 | if (dut->mbo_pref_ap_cnt >= MBO_MAX_PREF_BSSIDS) { |
| 8422 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 8423 | "Nebor AP List is full. Not adding"); |
| 8424 | return; |
| 8425 | } |
| 8426 | entry = &dut->mbo_pref_aps[dut->mbo_pref_ap_cnt]; |
| 8427 | dut->mbo_pref_ap_cnt++; |
| 8428 | memcpy(entry->mac_addr, mac_addr, ETH_ALEN); |
| 8429 | entry->ap_ne_class = -1; |
| 8430 | entry->ap_ne_op_ch = -1; |
| 8431 | entry->ap_ne_pref = -1; |
| 8432 | } |
| 8433 | if (ap_ne_class != -1) |
| 8434 | entry->ap_ne_class = ap_ne_class; |
| 8435 | if (ap_ne_op_ch != -1) |
| 8436 | entry->ap_ne_op_ch = ap_ne_op_ch; |
| 8437 | if (ap_ne_pref != -1) |
| 8438 | entry->ap_ne_pref = ap_ne_pref; |
| 8439 | } |
| 8440 | |
| 8441 | |
| 8442 | static int ath_set_nebor_bssid(struct sigma_dut *dut, const char *ifname, |
| 8443 | struct sigma_cmd *cmd) |
| 8444 | { |
| 8445 | unsigned char mac_addr[ETH_ALEN]; |
| 8446 | const char *val; |
| 8447 | /* |
| 8448 | * -1 is invalid value for the following |
| 8449 | * to differentiate between unset and set values |
| 8450 | * -1 => implies not set by CAPI |
| 8451 | */ |
| 8452 | int ap_ne_class = -1, ap_ne_op_ch = -1, ap_ne_pref = -1; |
| 8453 | int list_offset = dut->mbo_pref_ap_cnt; |
| 8454 | |
| 8455 | if (list_offset >= MBO_MAX_PREF_BSSIDS) { |
| 8456 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 8457 | "AP Pref Entry list is full"); |
| 8458 | return -1; |
| 8459 | } |
| 8460 | |
| 8461 | val = get_param(cmd, "Nebor_Op_Class"); |
| 8462 | if (val) |
| 8463 | ap_ne_class = atoi(val); |
| 8464 | |
| 8465 | val = get_param(cmd, "Nebor_Op_Ch"); |
| 8466 | if (val) |
| 8467 | ap_ne_op_ch = atoi(val); |
| 8468 | |
| 8469 | val = get_param(cmd, "Nebor_Pref"); |
| 8470 | if (val) |
| 8471 | ap_ne_pref = atoi(val); |
| 8472 | |
| 8473 | val = get_param(cmd, "Nebor_BSSID"); |
| 8474 | if (!val || parse_mac_address(dut, val, mac_addr) < 0) |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 8475 | return -1; |
| 8476 | |
Adil Saeed Musthafa | 6906372 | 2017-04-10 23:13:40 -0700 | [diff] [blame] | 8477 | mbo_add_nebor_entry(dut, mac_addr, ap_ne_class, ap_ne_op_ch, |
| 8478 | ap_ne_pref); |
| 8479 | apply_mbo_pref_ap_list(dut); |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 8480 | return 0; |
| 8481 | } |
| 8482 | |
| 8483 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8484 | static int ath_ap_set_rfeature(struct sigma_dut *dut, struct sigma_conn *conn, |
| 8485 | struct sigma_cmd *cmd) |
| 8486 | { |
| 8487 | const char *val; |
| 8488 | char *ifname; |
| 8489 | |
| 8490 | ifname = get_main_ifname(); |
| 8491 | |
Priyadharshini Gowthaman | 39beafa | 2015-11-09 14:11:25 -0800 | [diff] [blame] | 8492 | /* Disable vap reset between the commands */ |
| 8493 | novap_reset(dut, ifname); |
| 8494 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8495 | val = get_param(cmd, "Opt_md_notif_ie"); |
| 8496 | if (val && ath_vht_op_mode_notif(dut, ifname, val) < 0) |
| 8497 | return -1; |
| 8498 | |
| 8499 | /* TODO: Optional arguments */ |
| 8500 | |
| 8501 | val = get_param(cmd, "nss_mcs_opt"); |
| 8502 | if (val && ath_vht_nss_mcs(dut, ifname, val) < 0) |
| 8503 | return -1; |
| 8504 | |
| 8505 | val = get_param(cmd, "chnum_band"); |
| 8506 | if (val && ath_vht_chnum_band(dut, ifname, val) < 0) |
| 8507 | return -1; |
| 8508 | |
| 8509 | val = get_param(cmd, "RTS_FORCE"); |
| 8510 | if (val) |
| 8511 | ath_config_rts_force(dut, ifname, val); |
| 8512 | |
| 8513 | val = get_param(cmd, "DYN_BW_SGNL"); |
| 8514 | if (val) |
| 8515 | ath_config_dyn_bw_sig(dut, ifname, val); |
| 8516 | |
| 8517 | val = get_param(cmd, "CTS_WIDTH"); |
| 8518 | if (val) |
| 8519 | ath_set_cts_width(dut, ifname, val); |
| 8520 | |
| 8521 | val = get_param(cmd, "Ndpa_stainfo_mac"); |
| 8522 | if (val && ath_ndpa_stainfo_mac(dut, ifname, val) < 0) |
| 8523 | return -1; |
| 8524 | |
| 8525 | val = get_param(cmd, "txBandwidth"); |
| 8526 | if (val && ath_set_width(dut, conn, ifname, val) < 0) |
| 8527 | return -1; |
| 8528 | |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 8529 | val = get_param(cmd, "Assoc_Disallow"); |
| 8530 | if (val) |
| 8531 | ath_set_assoc_disallow(dut, ifname, val); |
| 8532 | |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 8533 | |
Adil Saeed Musthafa | 6906372 | 2017-04-10 23:13:40 -0700 | [diff] [blame] | 8534 | ath_set_nebor_bssid(dut, ifname, cmd); |
priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 8535 | val = get_param(cmd, "BTMReq_DisAssoc_Imnt"); |
| 8536 | if (val) |
| 8537 | dut->ap_btmreq_disassoc_imnt = atoi(val); |
| 8538 | |
| 8539 | val = get_param(cmd, "BTMReq_Term_Bit"); |
| 8540 | if (val) |
| 8541 | dut->ap_btmreq_term_bit = atoi(val); |
| 8542 | |
Adil Saeed Musthafa | 48c5ab9 | 2017-04-10 23:13:35 -0700 | [diff] [blame] | 8543 | val = get_param(cmd, "Assoc_Delay"); |
| 8544 | if (val) |
| 8545 | run_system_wrapper(dut, "iwpriv %s mbo_asoc_ret %s", |
| 8546 | ifname, val); |
| 8547 | |
Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 8548 | val = get_param(cmd, "Disassoc_Timer"); |
| 8549 | if (val) |
| 8550 | dut->ap_disassoc_timer = atoi(val); |
| 8551 | |
| 8552 | val = get_param(cmd, "BSS_Term_Duration"); |
| 8553 | if (val) |
| 8554 | dut->ap_btmreq_bss_term_dur = atoi(val); |
| 8555 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8556 | return 1; |
| 8557 | } |
| 8558 | |
| 8559 | |
Pradeep Reddy POTTETI | 88fd82c | 2016-03-14 12:20:18 +0530 | [diff] [blame] | 8560 | static int wcn_vht_chnum_band(struct sigma_dut *dut, const char *ifname, |
| 8561 | const char *val) |
| 8562 | { |
| 8563 | char *token, *result; |
| 8564 | int channel = 36; |
| 8565 | char buf[100]; |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 8566 | char *saveptr; |
Pradeep Reddy POTTETI | 88fd82c | 2016-03-14 12:20:18 +0530 | [diff] [blame] | 8567 | |
| 8568 | /* Extract the channel info */ |
| 8569 | token = strdup(val); |
| 8570 | if (!token) |
| 8571 | return -1; |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 8572 | result = strtok_r(token, ";", &saveptr); |
Pradeep Reddy POTTETI | 88fd82c | 2016-03-14 12:20:18 +0530 | [diff] [blame] | 8573 | if (result) |
| 8574 | channel = atoi(result); |
| 8575 | |
| 8576 | /* Issue the channel switch command */ |
| 8577 | snprintf(buf, sizeof(buf), "iwpriv %s setChanChange %d", |
| 8578 | ifname, channel); |
| 8579 | if (system(buf) != 0) { |
| 8580 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 8581 | "iwpriv setChanChange failed!"); |
| 8582 | } |
| 8583 | |
| 8584 | free(token); |
| 8585 | return 0; |
| 8586 | } |
| 8587 | |
| 8588 | |
| 8589 | static int wcn_ap_set_rfeature(struct sigma_dut *dut, struct sigma_conn *conn, |
| 8590 | struct sigma_cmd *cmd) |
| 8591 | { |
| 8592 | const char *val; |
| 8593 | char *ifname; |
| 8594 | |
| 8595 | ifname = get_main_ifname(); |
| 8596 | |
| 8597 | val = get_param(cmd, "chnum_band"); |
| 8598 | if (val && wcn_vht_chnum_band(dut, ifname, val) < 0) |
| 8599 | return -1; |
| 8600 | |
| 8601 | return 1; |
| 8602 | } |
| 8603 | |
| 8604 | |
Mohammed Shafi Shajakhan | b53d8f9 | 2017-02-28 09:05:15 +0530 | [diff] [blame] | 8605 | static int mac80211_vht_chnum_band(struct sigma_dut *dut, const char *ifname, |
| 8606 | const char *val) |
| 8607 | { |
| 8608 | char *token, *result; |
| 8609 | int channel = 36, chwidth = 80, center_freq_idx, center_freq, |
| 8610 | channel_freq; |
| 8611 | char buf[100]; |
| 8612 | char *saveptr; |
| 8613 | |
| 8614 | /* Extract the channel info */ |
| 8615 | token = strdup(val); |
| 8616 | if (!token) |
| 8617 | return -1; |
| 8618 | result = strtok_r(token, ";", &saveptr); |
| 8619 | if (result) |
| 8620 | channel = atoi(result); |
| 8621 | |
| 8622 | /* Extract the channel width info */ |
| 8623 | result = strtok_r(NULL, ";", &saveptr); |
| 8624 | if (result) |
| 8625 | chwidth = atoi(result); |
| 8626 | |
| 8627 | center_freq_idx = get_oper_centr_freq_seq_idx(chwidth, channel); |
| 8628 | if (center_freq_idx < 0) { |
| 8629 | free(token); |
| 8630 | return -1; |
| 8631 | } |
| 8632 | |
| 8633 | center_freq = get_5g_channel_freq(center_freq_idx); |
| 8634 | channel_freq = get_5g_channel_freq(channel); |
| 8635 | |
| 8636 | /* Issue the channel switch command */ |
| 8637 | snprintf(buf, sizeof(buf), |
| 8638 | " -i %s chan_switch 10 %d sec_channel_offset=1 center_freq1=%d bandwidth=%d blocktx vht", |
| 8639 | ifname, channel_freq, center_freq, chwidth); |
| 8640 | if (run_hostapd_cli(dut,buf) != 0) { |
| 8641 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 8642 | "hostapd_cli chan_switch failed"); |
| 8643 | } |
| 8644 | |
| 8645 | free(token); |
| 8646 | return 0; |
| 8647 | } |
| 8648 | |
| 8649 | |
| 8650 | static int mac80211_ap_set_rfeature(struct sigma_dut *dut, |
| 8651 | struct sigma_conn *conn, |
| 8652 | struct sigma_cmd *cmd) |
| 8653 | { |
| 8654 | const char *val; |
| 8655 | char *ifname; |
| 8656 | |
| 8657 | ifname = get_main_ifname(); |
| 8658 | val = get_param(cmd, "chnum_band"); |
| 8659 | if (val && mac80211_vht_chnum_band(dut, ifname, val) < 0) |
| 8660 | return -1; |
| 8661 | |
| 8662 | return 1; |
| 8663 | } |
| 8664 | |
| 8665 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8666 | static int cmd_ap_set_rfeature(struct sigma_dut *dut, struct sigma_conn *conn, |
| 8667 | struct sigma_cmd *cmd) |
| 8668 | { |
| 8669 | /* const char *name = get_param(cmd, "NAME"); */ |
| 8670 | /* const char *type = get_param(cmd, "Type"); */ |
| 8671 | |
| 8672 | switch (get_driver_type()) { |
| 8673 | case DRIVER_ATHEROS: |
| 8674 | return ath_ap_set_rfeature(dut, conn, cmd); |
| 8675 | case DRIVER_OPENWRT: |
| 8676 | switch (get_openwrt_driver_type()) { |
| 8677 | case OPENWRT_DRIVER_ATHEROS: |
| 8678 | return ath_ap_set_rfeature(dut, conn, cmd); |
| 8679 | default: |
| 8680 | send_resp(dut, conn, SIGMA_ERROR, |
| 8681 | "errorCode,Unsupported ap_set_rfeature with the current openwrt driver"); |
| 8682 | return 0; |
| 8683 | } |
Sreelakshmi Konamki | 0e4fcf9 | 2016-04-26 19:55:01 +0530 | [diff] [blame] | 8684 | case DRIVER_LINUX_WCN: |
Pradeep Reddy POTTETI | 88fd82c | 2016-03-14 12:20:18 +0530 | [diff] [blame] | 8685 | case DRIVER_WCN: |
| 8686 | return wcn_ap_set_rfeature(dut, conn, cmd); |
Mohammed Shafi Shajakhan | b53d8f9 | 2017-02-28 09:05:15 +0530 | [diff] [blame] | 8687 | case DRIVER_MAC80211: |
| 8688 | return mac80211_ap_set_rfeature(dut, conn, cmd); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8689 | default: |
| 8690 | send_resp(dut, conn, SIGMA_ERROR, |
| 8691 | "errorCode,Unsupported ap_set_rfeature with the current driver"); |
| 8692 | return 0; |
| 8693 | } |
| 8694 | } |
| 8695 | |
| 8696 | |
| 8697 | static int cmd_accesspoint(struct sigma_dut *dut, struct sigma_conn *conn, |
| 8698 | struct sigma_cmd *cmd) |
| 8699 | { |
| 8700 | /* const char *name = get_param(cmd, "NAME"); */ |
| 8701 | return 1; |
| 8702 | } |
| 8703 | |
| 8704 | |
| 8705 | void ap_register_cmds(void) |
| 8706 | { |
| 8707 | sigma_dut_reg_cmd("ap_ca_version", NULL, cmd_ap_ca_version); |
| 8708 | sigma_dut_reg_cmd("ap_set_wireless", NULL, cmd_ap_set_wireless); |
| 8709 | sigma_dut_reg_cmd("ap_send_addba_req", NULL, cmd_ap_send_addba_req); |
| 8710 | sigma_dut_reg_cmd("ap_set_11n_wireless", NULL, cmd_ap_set_wireless); |
| 8711 | sigma_dut_reg_cmd("ap_set_11n", NULL, cmd_ap_set_wireless); |
| 8712 | 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] | 8713 | sigma_dut_reg_cmd("ap_set_11h", NULL, cmd_ap_set_wireless); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8714 | sigma_dut_reg_cmd("ap_set_security", NULL, cmd_ap_set_security); |
| 8715 | sigma_dut_reg_cmd("ap_set_apqos", NULL, cmd_ap_set_apqos); |
| 8716 | sigma_dut_reg_cmd("ap_set_staqos", NULL, cmd_ap_set_staqos); |
| 8717 | sigma_dut_reg_cmd("ap_set_radius", NULL, cmd_ap_set_radius); |
| 8718 | sigma_dut_reg_cmd("ap_reboot", NULL, cmd_ap_reboot); |
| 8719 | sigma_dut_reg_cmd("ap_config_commit", NULL, cmd_ap_config_commit); |
| 8720 | sigma_dut_reg_cmd("ap_reset_default", NULL, cmd_ap_reset_default); |
| 8721 | sigma_dut_reg_cmd("ap_get_info", NULL, cmd_ap_get_info); |
| 8722 | sigma_dut_reg_cmd("ap_deauth_sta", NULL, cmd_ap_deauth_sta); |
| 8723 | sigma_dut_reg_cmd("ap_send_frame", NULL, cmd_ap_send_frame); |
| 8724 | sigma_dut_reg_cmd("ap_get_mac_address", NULL, cmd_ap_get_mac_address); |
| 8725 | sigma_dut_reg_cmd("ap_set_pmf", NULL, cmd_ap_set_pmf); |
| 8726 | sigma_dut_reg_cmd("ap_set_hs2", NULL, cmd_ap_set_hs2); |
| 8727 | sigma_dut_reg_cmd("ap_set_rfeature", NULL, cmd_ap_set_rfeature); |
| 8728 | sigma_dut_reg_cmd("ap_nfc_action", NULL, cmd_ap_nfc_action); |
| 8729 | sigma_dut_reg_cmd("ap_wps_read_pin", NULL, cmd_ap_wps_read_pin); |
| 8730 | sigma_dut_reg_cmd("AccessPoint", NULL, cmd_accesspoint); |
| 8731 | } |