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__ |
| 15 | #include <dirent.h> |
| 16 | #include <string.h> |
| 17 | #include <sys/types.h> |
| 18 | #include <unistd.h> |
| 19 | #endif /* __linux__ */ |
| 20 | #ifdef __QNXNTO__ |
| 21 | #include <ifaddrs.h> |
| 22 | #include <net/if_dl.h> |
| 23 | #endif /* __QNXNTO__ */ |
| 24 | #include "wpa_helpers.h" |
| 25 | #ifdef ANDROID |
| 26 | #include <hardware_legacy/wifi.h> |
Pradeep Reddy POTTETI | a076c30 | 2016-05-16 13:36:07 +0530 | [diff] [blame] | 27 | #include <private/android_filesystem_config.h> |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 28 | #endif /* ANDROID */ |
| 29 | |
| 30 | /* Temporary files for ap_send_addba_req */ |
| 31 | #define VI_QOS_TMP_FILE "/tmp/vi-qos.tmp" |
| 32 | #define VI_QOS_FILE "/tmp/vi-qos.txt" |
| 33 | #define VI_QOS_REFFILE "/etc/vi-qos.txt" |
| 34 | |
| 35 | /* Configuration file name on Android */ |
| 36 | #ifndef ANDROID_CONFIG_FILE |
| 37 | #define ANDROID_CONFIG_FILE "/data/misc/wifi/hostapd.conf" |
| 38 | #endif /* ANDROID_CONFIG_FILE */ |
| 39 | /* Maximum length of the line in the configuration file */ |
| 40 | #define MAX_CONF_LINE_LEN (156) |
| 41 | |
| 42 | /* The following is taken from Hotspot 2.0 testplan Appendix B.1 */ |
| 43 | #define ANQP_VENUE_NAME_1 "02019c0002083d656e6757692d466920416c6c69616e63650a3239383920436f7070657220526f61640a53616e746120436c6172612c2043412039353035312c205553415b63686957692d4669e88194e79b9fe5ae9ee9aa8ce5aea40ae4ba8ce4b99de585abe4b99de5b9b4e5ba93e69f8fe8b7af0ae59ca3e5858be68b89e68b892c20e58aa0e588a9e7a68fe5b0bce4ba9a39353035312c20e7be8ee59bbd" |
| 44 | #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\"" |
| 45 | #define ANQP_IP_ADDR_TYPE_1 "060101000c" |
| 46 | #define ANQP_HS20_OPERATOR_FRIENDLY_NAME_1 "dddd2700506f9a11030011656e6757692d466920416c6c69616e63650e63686957692d4669e88194e79b9f" |
| 47 | #define ANQP_HS20_WAN_METRICS_1 "dddd1300506f9a11040001c40900008001000000000000" |
| 48 | #define ANQP_HS20_CONNECTION_CAPABILITY_1 "dddd3200506f9a1105000100000006140001061600000650000106bb010106bb060006c4130011f4010111c413001194110132000001" |
| 49 | #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" |
| 50 | #define QOS_MAP_SET_2 "8,15,0,7,255,255,16,31,32,39,255,255,40,47,48,63" |
| 51 | |
| 52 | extern char *sigma_main_ifname; |
| 53 | extern char *sigma_wpas_ctrl; |
| 54 | extern char *sigma_hapd_ctrl; |
| 55 | extern char *ap_inet_addr; |
| 56 | extern char *ap_inet_mask; |
| 57 | extern char *sigma_radio_ifname[]; |
| 58 | |
| 59 | static int cmd_ap_config_commit(struct sigma_dut *dut, struct sigma_conn *conn, |
| 60 | struct sigma_cmd *cmd); |
| 61 | static int ath_ap_start_hostapd(struct sigma_dut *dut); |
| 62 | static void ath_ap_set_params(struct sigma_dut *dut); |
| 63 | static int kill_process(struct sigma_dut *dut, char *proc_name, |
| 64 | unsigned char is_proc_instance_one, int sig); |
| 65 | |
| 66 | |
| 67 | static int cmd_ap_ca_version(struct sigma_dut *dut, struct sigma_conn *conn, |
| 68 | struct sigma_cmd *cmd) |
| 69 | { |
| 70 | /* const char *name = get_param(cmd, "NAME"); */ |
| 71 | send_resp(dut, conn, SIGMA_COMPLETE, "version,1.0"); |
| 72 | return 0; |
| 73 | } |
| 74 | |
| 75 | |
| 76 | static int get_hwaddr(const char *ifname, unsigned char *hwaddr) |
| 77 | { |
| 78 | #ifndef __QNXNTO__ |
| 79 | struct ifreq ifr; |
| 80 | int s; |
| 81 | |
| 82 | s = socket(AF_INET, SOCK_DGRAM, 0); |
| 83 | if (s < 0) |
| 84 | return -1; |
| 85 | memset(&ifr, 0, sizeof(ifr)); |
| 86 | strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name)); |
| 87 | if (ioctl(s, SIOCGIFHWADDR, &ifr) < 0) { |
| 88 | perror("ioctl"); |
| 89 | close(s); |
| 90 | return -1; |
| 91 | } |
| 92 | close(s); |
| 93 | memcpy(hwaddr, ifr.ifr_hwaddr.sa_data, 6); |
| 94 | #else /* __QNXNTO__ */ |
| 95 | struct ifaddrs *ifaddrshead = NULL; |
| 96 | int found = 0; |
| 97 | struct ifaddrs *temp_ifap = NULL; |
| 98 | struct sockaddr_dl *sdl = NULL; |
| 99 | |
| 100 | if (getifaddrs(&ifaddrshead) != 0) { |
| 101 | perror("getifaddrs failed"); |
| 102 | return -1; |
| 103 | } |
| 104 | |
| 105 | for (temp_ifap = ifaddrshead; ifaddrshead && !found; |
| 106 | ifaddrshead = ifaddrshead->ifa_next) { |
| 107 | if (ifaddrshead->ifa_addr->sa_family == AF_LINK && |
| 108 | strcmp(ifaddrshead->ifa_name, ifname) == 0) { |
| 109 | found = 1; |
| 110 | sdl = (struct sockaddr_dl *) ifaddrshead->ifa_addr; |
| 111 | if (sdl) |
| 112 | memcpy(hwaddr, LLADDR(sdl), sdl->sdl_alen); |
| 113 | } |
| 114 | } |
| 115 | |
| 116 | if (temp_ifap) |
| 117 | freeifaddrs(temp_ifap); |
| 118 | |
| 119 | if (!found) { |
| 120 | perror("Failed to get the interface"); |
| 121 | return -1; |
| 122 | } |
| 123 | #endif /* __QNXNTO__ */ |
| 124 | return 0; |
| 125 | } |
| 126 | |
| 127 | |
| 128 | static void ath_ap_set_group_id(struct sigma_dut *dut, const char *ifname, |
| 129 | const char *val) |
| 130 | { |
| 131 | char buf[60]; |
| 132 | |
| 133 | snprintf(buf, sizeof(buf), "wifitool %s beeliner_fw_test 55 %d", |
| 134 | ifname, atoi(val)); |
| 135 | if (system(buf) != 0) { |
| 136 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 137 | "wifitool ap_group_id failed"); |
| 138 | } |
| 139 | } |
| 140 | |
| 141 | |
| 142 | void ath_set_cts_width(struct sigma_dut *dut, const char *ifname, |
| 143 | const char *val) |
| 144 | { |
| 145 | char buf[60]; |
| 146 | |
| 147 | /* TODO: Enable support for other values */ |
| 148 | if (strcasecmp(val, "40") == 0) { |
| 149 | snprintf(buf, sizeof(buf), "wifitool %s beeliner_fw_test 54 1", |
| 150 | ifname); |
| 151 | if (system(buf) != 0) { |
| 152 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 153 | "wifitool cts_width failed"); |
| 154 | } |
Priyadharshini Gowthaman | 818afef | 2015-11-09 13:28:15 -0800 | [diff] [blame] | 155 | snprintf(buf, sizeof(buf), |
| 156 | "athdiag --set --address=0x10024 --val=0xd90b8a14"); |
| 157 | if (system(buf) != 0) { |
| 158 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 159 | "disabling phy restart failed"); |
| 160 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 161 | } else { |
| 162 | sigma_dut_print(dut, DUT_MSG_ERROR, "Unsupported CTS_WIDTH"); |
| 163 | } |
| 164 | } |
| 165 | |
| 166 | |
Priyadharshini Gowthaman | 818afef | 2015-11-09 13:28:15 -0800 | [diff] [blame] | 167 | void ath_config_dyn_bw_sig(struct sigma_dut *dut, const char *ifname, |
| 168 | const char *val) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 169 | { |
| 170 | char buf[60]; |
| 171 | |
| 172 | if (strcasecmp(val, "enable") == 0) { |
| 173 | dut->ap_dyn_bw_sig = AP_DYN_BW_SGNL_ENABLED; |
| 174 | snprintf(buf, sizeof(buf), "iwpriv %s cwmenable 1", ifname); |
| 175 | if (system(buf) != 0) { |
| 176 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 177 | "iwpriv cwmenable 1 failed"); |
| 178 | } |
Priyadharshini Gowthaman | 818afef | 2015-11-09 13:28:15 -0800 | [diff] [blame] | 179 | snprintf(buf, sizeof(buf), "wifitool %s beeliner_fw_test 96 1", |
| 180 | ifname); |
| 181 | if (system(buf) != 0) { |
| 182 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 183 | "disabling RTS from rate control logic failed"); |
| 184 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 185 | } else if (strcasecmp(val, "disable") == 0) { |
| 186 | dut->ap_dyn_bw_sig = AP_DYN_BW_SGNL_DISABLED; |
| 187 | snprintf(buf, sizeof(buf), "iwpriv %s cwmenable 0", ifname); |
| 188 | if (system(buf) != 0) { |
| 189 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 190 | "iwpriv cwmenable 0 failed"); |
| 191 | } |
| 192 | } else { |
| 193 | sigma_dut_print(dut, DUT_MSG_ERROR, "Unsupported DYN_BW_SGL"); |
| 194 | } |
| 195 | } |
| 196 | |
| 197 | |
| 198 | static void ath_config_rts_force(struct sigma_dut *dut, const char *ifname, |
| 199 | const char *val) |
| 200 | { |
| 201 | char buf[60]; |
| 202 | |
| 203 | if (strcasecmp(val, "enable") == 0) { |
| 204 | dut->ap_sig_rts = 1; |
| 205 | snprintf(buf, sizeof(buf), "iwconfig %s rts 64", ifname); |
| 206 | if (system(buf) != 0) { |
| 207 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 208 | "iwconfig rts 64 failed"); |
| 209 | } |
priyadharshini gowthaman | 270870e | 2015-12-09 10:10:23 -0800 | [diff] [blame] | 210 | snprintf(buf, sizeof(buf), "wifitool %s beeliner_fw_test 100 1", |
| 211 | ifname); |
| 212 | if (system(buf) != 0) { |
| 213 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 214 | "wifitool beeliner_fw_test 100 1 failed"); |
| 215 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 216 | } else if (strcasecmp(val, "disable") == 0) { |
| 217 | dut->ap_sig_rts = 2; |
| 218 | snprintf(buf, sizeof(buf), "iwconfig %s rts 2347", ifname); |
| 219 | if (system(buf) != 0) { |
| 220 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 221 | "iwpriv rts 2347 failed"); |
| 222 | } |
| 223 | } else { |
| 224 | sigma_dut_print(dut, DUT_MSG_ERROR, "Unsupported RTS_FORCE"); |
| 225 | } |
| 226 | } |
| 227 | |
| 228 | |
| 229 | static enum ap_mode get_mode(const char *str) |
| 230 | { |
| 231 | if (strcasecmp(str, "11a") == 0) |
| 232 | return AP_11a; |
| 233 | else if (strcasecmp(str, "11g") == 0) |
| 234 | return AP_11g; |
| 235 | else if (strcasecmp(str, "11b") == 0) |
| 236 | return AP_11b; |
| 237 | else if (strcasecmp(str, "11na") == 0) |
| 238 | return AP_11na; |
| 239 | else if (strcasecmp(str, "11ng") == 0) |
| 240 | return AP_11ng; |
| 241 | else if (strcasecmp(str, "11ac") == 0 || strcasecmp(str, "ac") == 0) |
| 242 | return AP_11ac; |
| 243 | else |
| 244 | return AP_inval; |
| 245 | } |
| 246 | |
| 247 | |
| 248 | static int run_hostapd_cli(struct sigma_dut *dut, char *buf) |
| 249 | { |
| 250 | char command[1000]; |
| 251 | const char *bin; |
| 252 | enum driver_type drv = get_driver_type(); |
| 253 | |
| 254 | if (file_exists("hostapd_cli")) |
| 255 | bin = "./hostapd_cli"; |
| 256 | else |
| 257 | bin = "hostapd_cli"; |
| 258 | |
| 259 | if (drv == DRIVER_OPENWRT && sigma_hapd_ctrl == NULL) { |
| 260 | sigma_hapd_ctrl = "/var/run/hostapd-wifi0"; |
| 261 | |
| 262 | if (sigma_radio_ifname[0] && |
| 263 | strcmp(sigma_radio_ifname[0], "wifi1") == 0) |
| 264 | sigma_hapd_ctrl = "/var/run/hostapd-wifi1"; |
| 265 | else if (sigma_radio_ifname[0] && |
| 266 | strcmp(sigma_radio_ifname[0], "wifi2") == 0) |
| 267 | sigma_hapd_ctrl = "/var/run/hostapd-wifi2"; |
| 268 | } |
| 269 | |
| 270 | if (sigma_hapd_ctrl) |
| 271 | snprintf(command, sizeof(command), "%s -p %s %s", |
| 272 | bin, sigma_hapd_ctrl, buf); |
| 273 | else |
| 274 | snprintf(command, sizeof(command), "%s %s", bin, buf); |
| 275 | return run_system(dut, command); |
| 276 | } |
| 277 | |
| 278 | |
priyadharshini gowthaman | 8e26ff4 | 2016-06-22 22:47:14 -0700 | [diff] [blame^] | 279 | static int ath_set_lci_config(struct sigma_dut *dut, const char *val, |
| 280 | struct sigma_cmd *cmd) |
| 281 | { |
| 282 | FILE *f; |
| 283 | int i; |
| 284 | |
| 285 | f = fopen("/tmp/lci_cfg.txt", "w"); |
| 286 | if (!f) { |
| 287 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 288 | "Failed to open /tmp/lci_cfg.txt"); |
| 289 | return -1; |
| 290 | } |
| 291 | |
| 292 | for (i = 2; i < cmd->count; i++) |
| 293 | fprintf(f, "%s = %s \n", cmd->params[i], cmd->values[i]); |
| 294 | fprintf(f, "\n"); |
| 295 | fclose(f); |
| 296 | |
| 297 | return 0; |
| 298 | } |
| 299 | |
| 300 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 301 | static int cmd_ap_set_wireless(struct sigma_dut *dut, struct sigma_conn *conn, |
| 302 | struct sigma_cmd *cmd) |
| 303 | { |
| 304 | /* const char *name = get_param(cmd, "NAME"); */ |
| 305 | /* const char *ifname = get_param(cmd, "INTERFACE"); */ |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 306 | const char *val; |
| 307 | unsigned int wlan_tag = 1; |
| 308 | char *ifname = get_main_ifname(); |
| 309 | |
| 310 | val = get_param(cmd, "WLAN_TAG"); |
| 311 | if (val) { |
| 312 | wlan_tag = atoi(val); |
| 313 | if (wlan_tag != 1 && wlan_tag != 2) { |
| 314 | send_resp(dut, conn, SIGMA_INVALID, |
| 315 | "errorCode,Invalid WLAN_TAG"); |
| 316 | return 0; |
| 317 | } |
| 318 | } |
| 319 | |
| 320 | val = get_param(cmd, "CountryCode"); |
| 321 | if (val) { |
| 322 | if (strlen(val) > sizeof(dut->ap_countrycode) - 1) |
| 323 | return -1; |
| 324 | snprintf(dut->ap_countrycode, sizeof(dut->ap_countrycode), |
| 325 | "%s", val); |
| 326 | } |
| 327 | |
Pradeep Reddy POTTETI | fba27db | 2015-11-20 16:42:22 +0530 | [diff] [blame] | 328 | val = get_param(cmd, "regulatory_mode"); |
| 329 | if (val) { |
| 330 | if (strcasecmp(val, "11d") == 0 || strcasecmp(val, "11h") == 0) |
| 331 | dut->ap_regulatory_mode = AP_80211D_MODE_ENABLED; |
| 332 | } |
| 333 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 334 | val = get_param(cmd, "SSID"); |
| 335 | if (val) { |
| 336 | if (strlen(val) > sizeof(dut->ap_ssid) - 1) |
| 337 | return -1; |
| 338 | |
| 339 | if (wlan_tag == 1) { |
| 340 | snprintf(dut->ap_ssid, |
| 341 | sizeof(dut->ap_ssid), "%s", val); |
| 342 | } else if (wlan_tag == 2) { |
| 343 | snprintf(dut->ap2_ssid, |
| 344 | sizeof(dut->ap2_ssid), "%s", val); |
| 345 | } |
| 346 | } |
| 347 | |
| 348 | val = get_param(cmd, "CHANNEL"); |
| 349 | if (val) { |
| 350 | const char *pos; |
| 351 | dut->ap_channel = atoi(val); |
| 352 | pos = strchr(val, ';'); |
| 353 | if (pos) { |
| 354 | pos++; |
| 355 | dut->ap_channel_1 = atoi(pos); |
| 356 | } |
| 357 | } |
| 358 | |
Pradeep Reddy POTTETI | fba27db | 2015-11-20 16:42:22 +0530 | [diff] [blame] | 359 | /* Overwrite the AP channel with DFS channel if configured */ |
| 360 | val = get_param(cmd, "dfs_chan"); |
| 361 | if (val) { |
| 362 | dut->ap_channel = atoi(val); |
| 363 | } |
| 364 | |
| 365 | val = get_param(cmd, "dfs_mode"); |
| 366 | if (val) { |
| 367 | if (strcasecmp(val, "Enable") == 0) |
| 368 | dut->ap_dfs_mode = AP_DFS_MODE_ENABLED; |
| 369 | else if (strcasecmp(val, "Disable") == 0) |
| 370 | dut->ap_dfs_mode = AP_DFS_MODE_DISABLED; |
| 371 | else |
| 372 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 373 | "Unsupported dfs_mode value: %s", val); |
| 374 | } |
| 375 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 376 | val = get_param(cmd, "MODE"); |
| 377 | if (val) { |
| 378 | char *str, *pos; |
| 379 | |
| 380 | str = strdup(val); |
| 381 | if (str == NULL) |
| 382 | return -1; |
| 383 | pos = strchr(str, ';'); |
| 384 | if (pos) |
| 385 | *pos++ = '\0'; |
| 386 | |
| 387 | dut->ap_is_dual = 0; |
| 388 | dut->ap_mode = get_mode(str); |
| 389 | if (dut->ap_mode == AP_inval) { |
| 390 | send_resp(dut, conn, SIGMA_INVALID, |
| 391 | "errorCode,Unsupported MODE"); |
| 392 | free(str); |
| 393 | return 0; |
| 394 | } |
| 395 | if (dut->ap_mode == AP_11ac) |
| 396 | dut->ap_chwidth = AP_80; |
| 397 | |
| 398 | if (pos) { |
| 399 | dut->ap_mode_1 = get_mode(pos); |
| 400 | if (dut->ap_mode_1 == AP_inval) { |
| 401 | send_resp(dut, conn, SIGMA_INVALID, |
| 402 | "errorCode,Unsupported MODE"); |
| 403 | free(str); |
| 404 | return 0; |
| 405 | } |
| 406 | if (dut->ap_mode_1 == AP_11ac) |
| 407 | dut->ap_chwidth_1 = AP_80; |
| 408 | dut->ap_is_dual = 1; |
| 409 | } |
| 410 | |
| 411 | free(str); |
| 412 | } else if (dut->ap_mode == AP_inval) { |
| 413 | if (dut->ap_channel <= 11) |
| 414 | dut->ap_mode = AP_11ng; |
| 415 | else if (dut->program == PROGRAM_VHT) |
| 416 | dut->ap_mode = AP_11ac; |
| 417 | else |
| 418 | dut->ap_mode = AP_11na; |
| 419 | } |
| 420 | |
Pradeep Reddy POTTETI | 0d3db63 | 2016-03-11 15:21:11 +0530 | [diff] [blame] | 421 | val = get_param(cmd, "WME"); |
| 422 | if (val) { |
| 423 | if (strcasecmp(val, "on") == 0) |
| 424 | dut->ap_wme = AP_WME_ON; |
| 425 | else if (strcasecmp(val, "off") == 0) |
| 426 | dut->ap_wme = AP_WME_OFF; |
| 427 | else |
| 428 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 429 | "Unsupported WME value: %s", val); |
| 430 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 431 | |
| 432 | /* TODO: WMMPS */ |
| 433 | |
| 434 | val = get_param(cmd, "RTS"); |
| 435 | if (val) |
| 436 | dut->ap_rts = atoi(val); |
| 437 | |
| 438 | val = get_param(cmd, "FRGMNT"); |
| 439 | if (val) |
| 440 | dut->ap_frgmnt = atoi(val); |
| 441 | |
| 442 | /* TODO: PWRSAVE */ |
| 443 | |
| 444 | val = get_param(cmd, "BCNINT"); |
| 445 | if (val) |
| 446 | dut->ap_bcnint = atoi(val); |
| 447 | |
| 448 | val = get_param(cmd, "RADIO"); |
| 449 | if (val) { |
| 450 | if (strcasecmp(val, "on") == 0) { |
| 451 | enum driver_type drv = get_driver_type(); |
| 452 | if (drv == DRIVER_ATHEROS) |
| 453 | ath_ap_start_hostapd(dut); |
| 454 | else if (cmd_ap_config_commit(dut, conn, cmd) <= 0) |
| 455 | return 0; |
| 456 | } else if (strcasecmp(val, "off") == 0) { |
| 457 | if (kill_process(dut, "(hostapd)", 1, SIGTERM) == 0 || |
| 458 | system("killall hostapd") == 0) { |
| 459 | sigma_dut_print(dut, DUT_MSG_INFO, |
| 460 | "Killed hostapd on radio,off"); |
| 461 | } |
| 462 | } else { |
| 463 | send_resp(dut, conn, SIGMA_INVALID, |
| 464 | "errorCode,Unsupported RADIO value"); |
| 465 | return 0; |
| 466 | } |
| 467 | } |
| 468 | |
| 469 | val = get_param(cmd, "P2PMgmtBit"); |
| 470 | if (val) |
| 471 | dut->ap_p2p_mgmt = atoi(val); |
| 472 | |
| 473 | /* TODO: ChannelUsage */ |
| 474 | |
| 475 | /* TODO: 40_INTOLERANT */ |
| 476 | |
| 477 | val = get_param(cmd, "ADDBA_REJECT"); |
| 478 | if (val) { |
| 479 | if (strcasecmp(val, "Enable") == 0) |
| 480 | dut->ap_addba_reject = 1; |
| 481 | else if (strcasecmp(val, "Disable") == 0) |
| 482 | dut->ap_addba_reject = 2; |
| 483 | } |
| 484 | |
| 485 | val = get_param(cmd, "AMPDU"); |
| 486 | if (val) { |
| 487 | if (strcasecmp(val, "Enable") == 0) |
| 488 | dut->ap_ampdu = 1; |
| 489 | else if (strcasecmp(val, "Disable") == 0) |
| 490 | dut->ap_ampdu = 2; |
| 491 | } |
| 492 | |
| 493 | val = get_param(cmd, "AMPDU_EXP"); |
| 494 | if (val) |
| 495 | dut->ap_ampdu_exp = atoi(val); |
| 496 | |
| 497 | val = get_param(cmd, "AMSDU"); |
| 498 | if (val) { |
| 499 | if (strcasecmp(val, "Enable") == 0) |
| 500 | dut->ap_amsdu = 1; |
| 501 | else if (strcasecmp(val, "Disable") == 0) |
| 502 | dut->ap_amsdu = 2; |
| 503 | } |
| 504 | |
| 505 | val = get_param(cmd, "NoAck"); |
| 506 | if (val) { |
| 507 | if (strcasecmp(val, "on") == 0) |
| 508 | dut->ap_noack = AP_NOACK_ENABLED; |
| 509 | else if (strcasecmp(val, "off") == 0) |
| 510 | dut->ap_noack = AP_NOACK_DISABLED; |
| 511 | } |
| 512 | |
| 513 | /* TODO: GREENFIELD */ |
| 514 | /* TODO: OFFSET */ |
| 515 | /* TODO: MCS_32 */ |
| 516 | |
| 517 | val = get_param(cmd, "MCS_FIXEDRATE"); |
| 518 | if (val) { |
| 519 | dut->ap_fixed_rate = 1; |
| 520 | dut->ap_mcs = atoi(val); |
| 521 | } |
| 522 | |
| 523 | val = get_param(cmd, "SPATIAL_RX_STREAM"); |
| 524 | if (val) { |
| 525 | if (strcasecmp(val, "1SS") == 0 || strcasecmp(val, "1") == 0) { |
| 526 | dut->ap_rx_streams = 1; |
| 527 | if (dut->device_type == AP_testbed) |
| 528 | dut->ap_vhtmcs_map = 0xfffc; |
| 529 | } else if (strcasecmp(val, "2SS") == 0 || |
| 530 | strcasecmp(val, "2") == 0) { |
| 531 | dut->ap_rx_streams = 2; |
| 532 | if (dut->device_type == AP_testbed) |
| 533 | dut->ap_vhtmcs_map = 0xfff0; |
| 534 | } else if (strcasecmp(val, "3SS") == 0 || |
| 535 | strcasecmp(val, "3") == 0) { |
| 536 | dut->ap_rx_streams = 3; |
| 537 | if (dut->device_type == AP_testbed) |
| 538 | dut->ap_vhtmcs_map = 0xffc0; |
| 539 | } else if (strcasecmp(val, "4SS") == 0 || |
| 540 | strcasecmp(val, "4") == 0) { |
| 541 | dut->ap_rx_streams = 4; |
| 542 | } |
| 543 | } |
| 544 | |
| 545 | val = get_param(cmd, "SPATIAL_TX_STREAM"); |
| 546 | if (val) { |
| 547 | if (strcasecmp(val, "1SS") == 0 || |
| 548 | strcasecmp(val, "1") == 0) { |
| 549 | dut->ap_tx_streams = 1; |
| 550 | if (dut->device_type == AP_testbed) |
| 551 | dut->ap_vhtmcs_map = 0xfffc; |
| 552 | } else if (strcasecmp(val, "2SS") == 0 || |
| 553 | strcasecmp(val, "2") == 0) { |
| 554 | dut->ap_tx_streams = 2; |
| 555 | if (dut->device_type == AP_testbed) |
| 556 | dut->ap_vhtmcs_map = 0xfff0; |
| 557 | } else if (strcasecmp(val, "3SS") == 0 || |
| 558 | strcasecmp(val, "3") == 0) { |
| 559 | dut->ap_tx_streams = 3; |
| 560 | if (dut->device_type == AP_testbed) |
| 561 | dut->ap_vhtmcs_map = 0xffc0; |
| 562 | } else if (strcasecmp(val, "4SS") == 0 || |
| 563 | strcasecmp(val, "4") == 0) { |
| 564 | dut->ap_tx_streams = 4; |
| 565 | } |
| 566 | } |
| 567 | |
| 568 | val = get_param(cmd, "nss_mcs_cap"); |
| 569 | if (val) { |
| 570 | int nss, mcs; |
| 571 | char token[20]; |
| 572 | char *result = NULL; |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 573 | char *saveptr; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 574 | |
| 575 | if (strlen(val) >= sizeof(token)) |
| 576 | return -1; |
| 577 | strcpy(token, val); |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 578 | result = strtok_r(token, ";", &saveptr); |
Pradeep Reddy POTTETI | 41b8c54 | 2016-06-15 16:09:46 +0530 | [diff] [blame] | 579 | if (!result) { |
| 580 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 581 | "VHT NSS not specified"); |
| 582 | return 0; |
| 583 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 584 | nss = atoi(result); |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 585 | result = strtok_r(NULL, ";", &saveptr); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 586 | if (result == NULL) { |
| 587 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 588 | "VHTMCS NOT SPECIFIED!"); |
| 589 | return 0; |
| 590 | } |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 591 | result = strtok_r(result, "-", &saveptr); |
| 592 | result = strtok_r(NULL, "-", &saveptr); |
Pradeep Reddy POTTETI | 41b8c54 | 2016-06-15 16:09:46 +0530 | [diff] [blame] | 593 | if (!result) { |
| 594 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 595 | "VHT MCS not specified"); |
| 596 | return 0; |
| 597 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 598 | mcs = atoi(result); |
| 599 | switch (nss) { |
| 600 | case 1: |
| 601 | switch (mcs) { |
| 602 | case 7: |
| 603 | dut->ap_vhtmcs_map = 0xfffc; |
| 604 | break; |
| 605 | case 8: |
| 606 | dut->ap_vhtmcs_map = 0xfffd; |
| 607 | break; |
| 608 | case 9: |
| 609 | dut->ap_vhtmcs_map = 0xfffe; |
| 610 | break; |
| 611 | default: |
| 612 | dut->ap_vhtmcs_map = 0xfffe; |
| 613 | break; |
| 614 | } |
| 615 | break; |
| 616 | case 2: |
| 617 | switch (mcs) { |
| 618 | case 7: |
| 619 | dut->ap_vhtmcs_map = 0xfff0; |
| 620 | break; |
| 621 | case 8: |
| 622 | dut->ap_vhtmcs_map = 0xfff5; |
| 623 | break; |
| 624 | case 9: |
| 625 | dut->ap_vhtmcs_map = 0xfffa; |
| 626 | break; |
| 627 | default: |
| 628 | dut->ap_vhtmcs_map = 0xfffa; |
| 629 | break; |
| 630 | } |
| 631 | break; |
| 632 | case 3: |
| 633 | switch (mcs) { |
| 634 | case 7: |
| 635 | dut->ap_vhtmcs_map = 0xffc0; |
| 636 | break; |
| 637 | case 8: |
| 638 | dut->ap_vhtmcs_map = 0xffd5; |
| 639 | break; |
| 640 | case 9: |
| 641 | dut->ap_vhtmcs_map = 0xffea; |
| 642 | break; |
| 643 | default: |
| 644 | dut->ap_vhtmcs_map = 0xffea; |
| 645 | break; |
| 646 | } |
| 647 | break; |
| 648 | default: |
| 649 | dut->ap_vhtmcs_map = 0xffea; |
| 650 | break; |
| 651 | } |
| 652 | } |
| 653 | |
| 654 | /* TODO: MPDU_MIN_START_SPACING */ |
| 655 | /* TODO: RIFS_TEST */ |
| 656 | /* TODO: SGI20 */ |
| 657 | |
| 658 | val = get_param(cmd, "STBC_TX"); |
| 659 | if (val) |
| 660 | dut->ap_tx_stbc = atoi(val); |
| 661 | |
| 662 | val = get_param(cmd, "WIDTH"); |
| 663 | if (val) { |
| 664 | if (strcasecmp(val, "20") == 0) |
| 665 | dut->ap_chwidth = AP_20; |
| 666 | else if (strcasecmp(val, "40") == 0) |
| 667 | dut->ap_chwidth = AP_40; |
| 668 | else if (strcasecmp(val, "80") == 0) |
| 669 | dut->ap_chwidth = AP_80; |
| 670 | else if (strcasecmp(val, "160") == 0) |
| 671 | dut->ap_chwidth = AP_160; |
| 672 | else if (strcasecmp(val, "Auto") == 0) |
| 673 | dut->ap_chwidth = AP_AUTO; |
| 674 | else { |
| 675 | send_resp(dut, conn, SIGMA_INVALID, |
| 676 | "errorCode,Unsupported WIDTH"); |
| 677 | return 0; |
| 678 | } |
| 679 | } |
| 680 | |
| 681 | /* TODO: WIDTH_SCAN */ |
| 682 | |
| 683 | val = get_param(cmd, "TDLSProhibit"); |
| 684 | dut->ap_tdls_prohibit = val && strcasecmp(val, "Enabled") == 0; |
| 685 | val = get_param(cmd, "TDLSChswitchProhibit"); |
| 686 | dut->ap_tdls_prohibit_chswitch = |
| 687 | val && strcasecmp(val, "Enabled") == 0; |
| 688 | val = get_param(cmd, "HS2"); |
| 689 | if (val && wlan_tag == 1) |
| 690 | dut->ap_hs2 = atoi(val); |
| 691 | val = get_param(cmd, "P2P_CROSS_CONNECT"); |
| 692 | if (val) |
| 693 | dut->ap_p2p_cross_connect = strcasecmp(val, "Enabled") == 0; |
| 694 | |
| 695 | val = get_param(cmd, "FakePubKey"); |
| 696 | dut->ap_fake_pkhash = val && atoi(val); |
| 697 | |
| 698 | val = get_param(cmd, "vht_tkip"); |
| 699 | dut->ap_allow_vht_tkip = val && strcasecmp(val, "Enable") == 0; |
| 700 | val = get_param(cmd, "vht_wep"); |
| 701 | dut->ap_allow_vht_wep = val && strcasecmp(val, "Enable") == 0; |
| 702 | |
| 703 | val = get_param(cmd, "Protect_mode"); |
| 704 | dut->ap_disable_protection = val && strcasecmp(val, "Disable") == 0; |
| 705 | |
| 706 | val = get_param(cmd, "DYN_BW_SGNL"); |
| 707 | if (val) { |
| 708 | switch (get_driver_type()) { |
| 709 | case DRIVER_OPENWRT: |
| 710 | switch (get_openwrt_driver_type()) { |
| 711 | case OPENWRT_DRIVER_ATHEROS: |
| 712 | ath_config_dyn_bw_sig(dut, ifname, val); |
| 713 | break; |
| 714 | default: |
| 715 | send_resp(dut, conn, SIGMA_ERROR, |
| 716 | "errorCode,Unsupported DYN_BW_SGNL with OpenWrt driver"); |
| 717 | return 0; |
| 718 | } |
| 719 | break; |
| 720 | default: |
| 721 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 722 | "Unsupported DYN_BW_SGL with the current driver"); |
| 723 | break; |
| 724 | } |
| 725 | } |
| 726 | |
| 727 | val = get_param(cmd, "SGI80"); |
| 728 | if (val) { |
| 729 | if (strcasecmp(val, "enable") == 0) |
| 730 | dut->ap_sgi80 = 1; |
| 731 | else if (strcasecmp(val, "disable") == 0) |
| 732 | dut->ap_sgi80 = 0; |
| 733 | else { |
| 734 | send_resp(dut, conn, SIGMA_INVALID, |
| 735 | "errorCode,Unsupported SGI80"); |
| 736 | return 0; |
| 737 | } |
| 738 | } |
| 739 | |
| 740 | val = get_param(cmd, "LDPC"); |
| 741 | if (val) { |
| 742 | if (strcasecmp(val, "enable") == 0) |
| 743 | dut->ap_ldpc = 1; |
| 744 | else if (strcasecmp(val, "disable") == 0) |
| 745 | dut->ap_ldpc = 2; |
| 746 | else { |
| 747 | send_resp(dut, conn, SIGMA_INVALID, |
| 748 | "errorCode,Unsupported LDPC"); |
| 749 | return 0; |
| 750 | } |
| 751 | } |
| 752 | |
| 753 | val = get_param(cmd, "BW_SGNL"); |
| 754 | if (val) { |
| 755 | /* |
| 756 | * With dynamic bandwidth signaling enabled we should see |
| 757 | * RTS if the threshold is met. |
| 758 | */ |
| 759 | if (strcasecmp(val, "enable") == 0) { |
| 760 | dut->ap_sig_rts = 1; |
| 761 | } else if (strcasecmp(val, "disable") == 0) { |
| 762 | dut->ap_sig_rts = 2; |
| 763 | } else { |
| 764 | send_resp(dut, conn, SIGMA_INVALID, |
| 765 | "errorCode,Unsupported BW_SGNL"); |
| 766 | return 0; |
| 767 | } |
| 768 | } |
| 769 | |
| 770 | val = get_param(cmd, "RTS_FORCE"); |
| 771 | if (val) { |
| 772 | switch (get_driver_type()) { |
| 773 | case DRIVER_OPENWRT: |
| 774 | switch (get_openwrt_driver_type()) { |
| 775 | case OPENWRT_DRIVER_ATHEROS: |
| 776 | ath_config_rts_force(dut, ifname, val); |
| 777 | break; |
| 778 | default: |
| 779 | send_resp(dut, conn, SIGMA_ERROR, |
| 780 | "errorCode,Unsupported RTS_FORCE with OpenWrt driver"); |
| 781 | return 0; |
| 782 | } |
| 783 | break; |
| 784 | default: |
| 785 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 786 | "Unsupported RTS_FORCE with the current driver"); |
| 787 | break; |
| 788 | } |
| 789 | } |
| 790 | |
| 791 | val = get_param(cmd, "Zero_crc"); |
| 792 | if (val) { |
| 793 | switch (get_driver_type()) { |
| 794 | case DRIVER_ATHEROS: |
| 795 | ath_set_zero_crc(dut, val); |
| 796 | break; |
| 797 | case DRIVER_OPENWRT: |
| 798 | switch (get_openwrt_driver_type()) { |
| 799 | case OPENWRT_DRIVER_ATHEROS: |
| 800 | ath_set_zero_crc(dut, val); |
| 801 | break; |
| 802 | default: |
| 803 | send_resp(dut, conn, SIGMA_ERROR, |
| 804 | "errorCode,Unsupported zero_crc with the current driver"); |
| 805 | return 0; |
| 806 | } |
| 807 | break; |
| 808 | default: |
| 809 | send_resp(dut, conn, SIGMA_ERROR, |
| 810 | "errorCode,Unsupported zero_crc with the current driver"); |
| 811 | return 0; |
| 812 | } |
| 813 | } |
| 814 | |
| 815 | val = get_param(cmd, "TxBF"); |
| 816 | if (val) |
| 817 | dut->ap_txBF = strcasecmp(val, "enable") == 0; |
| 818 | |
| 819 | val = get_param(cmd, "MU_TxBF"); |
| 820 | if (val) |
| 821 | dut->ap_mu_txBF = strcasecmp(val, "enable") == 0; |
| 822 | |
| 823 | /* UNSUPPORTED: tx_lgi_rate */ |
| 824 | |
| 825 | val = get_param(cmd, "wpsnfc"); |
| 826 | if (val) |
| 827 | dut->ap_wpsnfc = atoi(val); |
| 828 | |
| 829 | val = get_param(cmd, "GROUP_ID"); |
| 830 | if (val) { |
| 831 | switch (get_driver_type()) { |
| 832 | case DRIVER_OPENWRT: |
| 833 | switch (get_openwrt_driver_type()) { |
| 834 | case OPENWRT_DRIVER_ATHEROS: |
| 835 | ath_ap_set_group_id(dut, ifname, val); |
| 836 | break; |
| 837 | default: |
| 838 | send_resp(dut, conn, SIGMA_ERROR, |
| 839 | "errorCode,Unsupported group_id with the current driver"); |
| 840 | return 0; |
| 841 | } |
| 842 | break; |
| 843 | default: |
| 844 | send_resp(dut, conn, SIGMA_ERROR, |
| 845 | "errorCode,Unsupported group_id with the current driver"); |
| 846 | return 0; |
| 847 | } |
| 848 | } |
| 849 | |
| 850 | val = get_param(cmd, "CTS_WIDTH"); |
| 851 | if (val) { |
| 852 | switch (get_driver_type()) { |
| 853 | case DRIVER_OPENWRT: |
| 854 | switch (get_openwrt_driver_type()) { |
| 855 | case OPENWRT_DRIVER_ATHEROS: |
| 856 | ath_set_cts_width(dut, ifname, val); |
| 857 | break; |
| 858 | default: |
| 859 | send_resp(dut, conn, SIGMA_ERROR, |
| 860 | "errorCode,Unsupported cts_width with the current driver"); |
| 861 | return 0; |
| 862 | } |
| 863 | break; |
| 864 | default: |
| 865 | send_resp(dut, conn, SIGMA_ERROR, |
| 866 | "errorCode,Unsupported cts_width with the current driver"); |
| 867 | return 0; |
| 868 | } |
| 869 | } |
| 870 | |
priyadharshini gowthaman | 264d544 | 2016-02-25 15:52:22 -0800 | [diff] [blame] | 871 | val = get_param(cmd, "MU_NDPA_FrameFormat"); |
| 872 | if (val) |
| 873 | dut->ap_ndpa_frame = atoi(val); |
| 874 | |
priyadharshini gowthaman | c52fff8 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 875 | val = get_param(cmd, "interworking"); |
| 876 | if (val && strcmp(val, "1") == 0) |
| 877 | dut->ap_interworking = 1; |
| 878 | |
| 879 | val = get_param(cmd, "GAS_CB_DELAY"); |
| 880 | if (val) |
| 881 | dut->ap_gas_cb_delay = atoi(val); |
| 882 | |
priyadharshini gowthaman | 8e26ff4 | 2016-06-22 22:47:14 -0700 | [diff] [blame^] | 883 | val = get_param(cmd, "LCI"); |
| 884 | if (val) { |
| 885 | if (strlen(val) > sizeof(dut->ap_val_lci) - 1) |
| 886 | return -1; |
| 887 | dut->ap_lci = 1; |
| 888 | snprintf(dut->ap_val_lci, sizeof(dut->ap_val_lci), "%s", val); |
| 889 | ath_set_lci_config(dut, val, cmd); |
| 890 | } |
| 891 | |
| 892 | val = get_param(cmd, "LocCivicAddr"); |
| 893 | if (val) { |
| 894 | if (strlen(val) > sizeof(dut->ap_val_lcr) - 1) |
| 895 | return -1; |
| 896 | dut->ap_lcr = 1; |
| 897 | snprintf(dut->ap_val_lcr, sizeof(dut->ap_val_lcr), "%s", val); |
| 898 | if (dut->ap_lci == 0) |
| 899 | ath_set_lci_config(dut, val, cmd); |
| 900 | } |
| 901 | |
| 902 | val = get_param(cmd, "NeighAPBSSID"); |
| 903 | if (val) { |
| 904 | if (dut->ap_neighap < 3) { |
| 905 | if (parse_mac_address( |
| 906 | dut, val, |
| 907 | dut->ap_val_neighap[dut->ap_neighap]) < 0) { |
| 908 | send_resp(dut, conn, SIGMA_INVALID, |
| 909 | "Failed to parse MAC address"); |
| 910 | return 0; |
| 911 | } |
| 912 | dut->ap_neighap++; |
| 913 | if (dut->ap_lci == 1) |
| 914 | dut->ap_scan = 1; |
| 915 | } |
| 916 | } |
| 917 | |
| 918 | val = get_param(cmd, "OpChannel"); |
| 919 | if (val) { |
| 920 | if (dut->ap_opchannel < 3) { |
| 921 | dut->ap_val_opchannel[dut->ap_opchannel] = atoi(val); |
| 922 | dut->ap_opchannel++; |
| 923 | } |
| 924 | } |
| 925 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 926 | return 1; |
| 927 | } |
| 928 | |
| 929 | |
| 930 | static void ath_inject_frame(struct sigma_dut *dut, const char *ifname, int tid) |
| 931 | { |
| 932 | char buf[256]; |
| 933 | int tid_to_dscp[] = { 0x00, 0x20, 0x40, 0x60, 0x80, 0xa0, 0xc0, 0xe0 }; |
| 934 | |
| 935 | snprintf(buf, sizeof(buf), |
| 936 | "wlanconfig %s list sta | grep : | cut -b 1-17 > %s", |
| 937 | ifname, VI_QOS_TMP_FILE); |
| 938 | if (system(buf) != 0) |
| 939 | return; |
| 940 | |
| 941 | snprintf(buf, sizeof(buf), |
| 942 | "ifconfig %s | grep HWaddr | cut -b 39-56 >> %s", |
| 943 | ifname, VI_QOS_TMP_FILE); |
| 944 | if (system(buf) != 0) |
| 945 | sigma_dut_print(dut, DUT_MSG_ERROR, "Retrieve HWaddr failed"); |
| 946 | |
| 947 | snprintf(buf, sizeof(buf), "sed -n '3,$p' %s >> %s", |
| 948 | VI_QOS_REFFILE, VI_QOS_TMP_FILE); |
| 949 | if (system(buf) != 0) { |
| 950 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 951 | "Output redirection to VI_QOS_TMP_FILE failed"); |
| 952 | } |
| 953 | |
| 954 | snprintf(buf, sizeof(buf), "sed '5 c %x' %s > %s", |
| 955 | tid_to_dscp[tid], VI_QOS_TMP_FILE, VI_QOS_FILE); |
| 956 | if (system(buf) != 0) { |
| 957 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 958 | "Append TID to VI_QOS_FILE failed "); |
| 959 | } |
| 960 | |
| 961 | snprintf(buf, sizeof(buf), "ethinject %s %s", ifname, VI_QOS_FILE); |
| 962 | if (system(buf) != 0) |
| 963 | sigma_dut_print(dut, DUT_MSG_ERROR, "Ethinject frame failed"); |
| 964 | } |
| 965 | |
| 966 | |
| 967 | static int ath_ap_send_addba_req(struct sigma_dut *dut, struct sigma_conn *conn, |
| 968 | struct sigma_cmd *cmd) |
| 969 | { |
| 970 | const char *val; |
| 971 | char *ifname; |
| 972 | char buf[256]; |
| 973 | int tid = 0; |
| 974 | |
| 975 | ifname = get_main_ifname(); |
| 976 | val = get_param(cmd, "TID"); |
| 977 | if (val) { |
| 978 | tid = atoi(val); |
| 979 | if (tid) |
| 980 | ath_inject_frame(dut, ifname, tid); |
| 981 | } |
| 982 | |
| 983 | /* NOTE: This is the command sequence on Peregrine for ADDBA */ |
| 984 | snprintf(buf, sizeof(buf), "iwpriv %s setaddbaoper 1", ifname); |
| 985 | if (system(buf) != 0) { |
| 986 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 987 | "iwpriv setaddbaoper failed"); |
| 988 | } |
| 989 | |
| 990 | snprintf(buf, sizeof(buf), "wifitool %s senddelba 1 %d 1 4", |
| 991 | ifname, tid); |
| 992 | if (system(buf) != 0) { |
| 993 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 994 | "wifitool senddelba failed"); |
| 995 | } |
| 996 | |
| 997 | snprintf(buf, sizeof(buf), "wifitool %s sendaddba 1 %d 64", |
| 998 | ifname, tid); |
| 999 | if (system(buf) != 0) { |
| 1000 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 1001 | "wifitool sendaddba failed"); |
| 1002 | } |
| 1003 | |
| 1004 | return 1; |
| 1005 | } |
| 1006 | |
| 1007 | |
Mohammed Shafi Shajakhan | a0535d4 | 2016-06-17 11:55:00 +0530 | [diff] [blame] | 1008 | static int ath10k_debug_enable_addba_req(struct sigma_dut *dut, int tid, |
| 1009 | const char *sta_mac, |
| 1010 | const char *dir_path) |
| 1011 | { |
| 1012 | DIR *dir; |
| 1013 | struct dirent *entry; |
| 1014 | char buf[128], path[128]; |
| 1015 | int ret = 0; |
| 1016 | |
| 1017 | dir = opendir(dir_path); |
| 1018 | if (!dir) |
| 1019 | return 0; |
| 1020 | |
| 1021 | while ((entry = readdir(dir))) { |
| 1022 | ret = 1; |
| 1023 | |
| 1024 | if (strcmp(entry->d_name, ".") == 0 || |
| 1025 | strcmp(entry->d_name, "..") == 0) |
| 1026 | continue; |
| 1027 | |
| 1028 | snprintf(path, sizeof(path) - 1, "%s/%s", |
| 1029 | dir_path, entry->d_name); |
| 1030 | path[sizeof(path) - 1] = 0; |
| 1031 | |
| 1032 | if (strcmp(entry->d_name, sta_mac) == 0) { |
| 1033 | snprintf(buf, sizeof(buf), "echo 1 > %s/aggr_mode", |
| 1034 | path); |
| 1035 | if (system(buf) != 0) { |
| 1036 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 1037 | "Failed to set aggr mode for ath10k"); |
| 1038 | } |
| 1039 | |
| 1040 | snprintf(buf, sizeof(buf), "echo %d 32 > %s/addba", |
| 1041 | tid, path); |
| 1042 | if (system(buf) != 0) { |
| 1043 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 1044 | "Failed to set addbareq for ath10k"); |
| 1045 | } |
| 1046 | |
| 1047 | break; |
| 1048 | } |
| 1049 | |
| 1050 | /* Recursively search subdirectories */ |
| 1051 | ath10k_debug_enable_addba_req(dut, tid, sta_mac, path); |
| 1052 | } |
| 1053 | |
| 1054 | closedir(dir); |
| 1055 | |
| 1056 | return ret; |
| 1057 | } |
| 1058 | |
| 1059 | |
| 1060 | static int ath10k_ap_send_addba_req(struct sigma_dut *dut, |
| 1061 | struct sigma_cmd *cmd) |
| 1062 | { |
| 1063 | const char *val; |
| 1064 | int tid = 0; |
| 1065 | |
| 1066 | val = get_param(cmd, "TID"); |
| 1067 | if (val) |
| 1068 | tid = atoi(val); |
| 1069 | |
| 1070 | val = get_param(cmd, "sta_mac_address"); |
| 1071 | if (!val) { |
| 1072 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 1073 | "Failed to parse station MAC address"); |
| 1074 | return 0; |
| 1075 | } |
| 1076 | |
| 1077 | return ath10k_debug_enable_addba_req(dut, tid, val, |
| 1078 | "/sys/kernel/debug/ieee80211"); |
| 1079 | } |
| 1080 | |
| 1081 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1082 | static int cmd_ap_send_addba_req(struct sigma_dut *dut, struct sigma_conn *conn, |
| 1083 | struct sigma_cmd *cmd) |
| 1084 | { |
| 1085 | /* const char *name = get_param(cmd, "NAME"); */ |
| 1086 | /* const char *ifname = get_param(cmd, "INTERFACE"); */ |
Mohammed Shafi Shajakhan | a0535d4 | 2016-06-17 11:55:00 +0530 | [diff] [blame] | 1087 | struct stat s; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1088 | |
| 1089 | switch (get_driver_type()) { |
| 1090 | case DRIVER_ATHEROS: |
| 1091 | return ath_ap_send_addba_req(dut, conn, cmd); |
| 1092 | case DRIVER_OPENWRT: |
| 1093 | switch (get_openwrt_driver_type()) { |
| 1094 | case OPENWRT_DRIVER_ATHEROS: |
| 1095 | return ath_ap_send_addba_req(dut, conn, cmd); |
| 1096 | default: |
| 1097 | send_resp(dut, conn, SIGMA_ERROR, |
| 1098 | "errorCode,ap_send_addba_req not supported with this driver"); |
| 1099 | return 0; |
| 1100 | } |
Pradeep Reddy POTTETI | fdb0491 | 2016-08-02 14:16:24 +0530 | [diff] [blame] | 1101 | case DRIVER_WCN: |
| 1102 | case DRIVER_LINUX_WCN: |
| 1103 | /* AP automatically sends ADDBA request after association. */ |
| 1104 | sigma_dut_print(dut, DUT_MSG_INFO, |
| 1105 | "ap_send_addba_req command ignored"); |
| 1106 | return 1; |
Mohammed Shafi Shajakhan | a0535d4 | 2016-06-17 11:55:00 +0530 | [diff] [blame] | 1107 | case DRIVER_MAC80211: |
| 1108 | if (stat("/sys/module/ath10k_core", &s) == 0) |
| 1109 | return ath10k_ap_send_addba_req(dut, cmd); |
| 1110 | /* fall through */ |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1111 | default: |
| 1112 | send_resp(dut, conn, SIGMA_ERROR, |
| 1113 | "errorCode,ap_send_addba_req not supported with this driver"); |
| 1114 | return 0; |
| 1115 | } |
| 1116 | } |
| 1117 | |
| 1118 | |
| 1119 | static int cmd_ap_set_security(struct sigma_dut *dut, struct sigma_conn *conn, |
| 1120 | struct sigma_cmd *cmd) |
| 1121 | { |
| 1122 | /* const char *name = get_param(cmd, "NAME"); */ |
| 1123 | const char *val; |
| 1124 | unsigned int wlan_tag = 1; |
| 1125 | |
| 1126 | val = get_param(cmd, "WLAN_TAG"); |
| 1127 | if (val) |
| 1128 | wlan_tag = atoi(val); |
| 1129 | |
| 1130 | if (wlan_tag == 2) { |
| 1131 | val = get_param(cmd, "KEYMGNT"); |
| 1132 | if (val) { |
| 1133 | if (strcasecmp(val, "NONE") == 0) |
| 1134 | dut->ap2_key_mgmt = AP2_OPEN; |
| 1135 | else if (strcasecmp(val, "OSEN") == 0) |
| 1136 | dut->ap2_key_mgmt = AP2_OSEN; |
| 1137 | else { |
| 1138 | send_resp(dut, conn, SIGMA_INVALID, |
| 1139 | "errorCode,Unsupported KEYMGNT"); |
| 1140 | return 0; |
| 1141 | } |
| 1142 | return 1; |
| 1143 | } |
| 1144 | } |
| 1145 | |
| 1146 | val = get_param(cmd, "KEYMGNT"); |
| 1147 | if (val) { |
| 1148 | if (strcasecmp(val, "WPA2-PSK") == 0) { |
| 1149 | dut->ap_key_mgmt = AP_WPA2_PSK; |
| 1150 | dut->ap_cipher = AP_CCMP; |
| 1151 | } else if (strcasecmp(val, "WPA2-EAP") == 0 || |
| 1152 | strcasecmp(val, "WPA2-Ent") == 0) { |
| 1153 | dut->ap_key_mgmt = AP_WPA2_EAP; |
| 1154 | dut->ap_cipher = AP_CCMP; |
| 1155 | } else if (strcasecmp(val, "WPA-PSK") == 0) { |
| 1156 | dut->ap_key_mgmt = AP_WPA_PSK; |
| 1157 | dut->ap_cipher = AP_TKIP; |
| 1158 | } else if (strcasecmp(val, "WPA-EAP") == 0 || |
| 1159 | strcasecmp(val, "WPA-Ent") == 0) { |
| 1160 | dut->ap_key_mgmt = AP_WPA_EAP; |
| 1161 | dut->ap_cipher = AP_TKIP; |
| 1162 | } else if (strcasecmp(val, "WPA2-Mixed") == 0) { |
| 1163 | dut->ap_key_mgmt = AP_WPA2_EAP_MIXED; |
| 1164 | dut->ap_cipher = AP_CCMP_TKIP; |
| 1165 | } else if (strcasecmp(val, "WPA2-PSK-Mixed") == 0) { |
| 1166 | dut->ap_key_mgmt = AP_WPA2_PSK_MIXED; |
| 1167 | dut->ap_cipher = AP_CCMP_TKIP; |
| 1168 | } else if (strcasecmp(val, "NONE") == 0) { |
| 1169 | dut->ap_key_mgmt = AP_OPEN; |
| 1170 | dut->ap_cipher = AP_PLAIN; |
| 1171 | } else { |
| 1172 | send_resp(dut, conn, SIGMA_INVALID, |
| 1173 | "errorCode,Unsupported KEYMGNT"); |
| 1174 | return 0; |
| 1175 | } |
| 1176 | } |
| 1177 | |
| 1178 | val = get_param(cmd, "ENCRYPT"); |
| 1179 | if (val) { |
| 1180 | if (strcasecmp(val, "WEP") == 0) { |
| 1181 | dut->ap_cipher = AP_WEP; |
| 1182 | } else if (strcasecmp(val, "TKIP") == 0) { |
| 1183 | dut->ap_cipher = AP_TKIP; |
| 1184 | } else if (strcasecmp(val, "AES") == 0 || |
| 1185 | strcasecmp(val, "AES-CCMP") == 0) { |
| 1186 | dut->ap_cipher = AP_CCMP; |
| 1187 | } else { |
| 1188 | send_resp(dut, conn, SIGMA_INVALID, |
| 1189 | "errorCode,Unsupported ENCRYPT"); |
| 1190 | return 0; |
| 1191 | } |
| 1192 | } |
| 1193 | |
| 1194 | val = get_param(cmd, "WEPKEY"); |
| 1195 | if (val) { |
| 1196 | size_t len; |
| 1197 | if (dut->ap_cipher != AP_WEP) { |
| 1198 | send_resp(dut, conn, SIGMA_INVALID, |
| 1199 | "errorCode,Unexpected WEPKEY without WEP " |
| 1200 | "configuration"); |
| 1201 | return 0; |
| 1202 | } |
| 1203 | len = strlen(val); |
| 1204 | if (len != 10 && len != 26) { |
| 1205 | send_resp(dut, conn, SIGMA_INVALID, |
| 1206 | "errorCode,Unexpected WEPKEY length"); |
| 1207 | return 0; |
| 1208 | } |
| 1209 | snprintf(dut->ap_wepkey, sizeof(dut->ap_wepkey), "%s", val); |
| 1210 | } |
| 1211 | |
| 1212 | val = get_param(cmd, "PSK"); |
| 1213 | if (val) { |
| 1214 | if (strlen(val) > sizeof(dut->ap_passphrase) - 1) |
| 1215 | return -1; |
| 1216 | snprintf(dut->ap_passphrase, sizeof(dut->ap_passphrase), |
| 1217 | "%s", val); |
| 1218 | } |
| 1219 | |
| 1220 | val = get_param(cmd, "PMF"); |
| 1221 | if (val) { |
| 1222 | if (strcasecmp(val, "Disabled") == 0) { |
| 1223 | dut->ap_pmf = AP_PMF_DISABLED; |
| 1224 | } else if (strcasecmp(val, "Optional") == 0) { |
| 1225 | dut->ap_pmf = AP_PMF_OPTIONAL; |
| 1226 | } else if (strcasecmp(val, "Required") == 0) { |
| 1227 | dut->ap_pmf = AP_PMF_REQUIRED; |
| 1228 | } else { |
| 1229 | send_resp(dut, conn, SIGMA_INVALID, |
| 1230 | "errorCode,Unsupported PMF"); |
| 1231 | return 0; |
| 1232 | } |
| 1233 | } |
| 1234 | |
| 1235 | if (dut->ap_key_mgmt == AP_OPEN) { |
| 1236 | dut->ap_hs2 = 0; |
| 1237 | dut->ap_pmf = AP_PMF_DISABLED; |
| 1238 | } |
| 1239 | |
| 1240 | dut->ap_add_sha256 = 0; |
| 1241 | val = get_param(cmd, "SHA256AD"); |
| 1242 | if (val == NULL) |
| 1243 | val = get_param(cmd, "SHA256"); |
| 1244 | if (val) { |
| 1245 | if (strcasecmp(val, "Disabled") == 0) { |
| 1246 | } else if (strcasecmp(val, "Enabled") == 0) { |
| 1247 | dut->ap_add_sha256 = 1; |
| 1248 | } else { |
| 1249 | send_resp(dut, conn, SIGMA_INVALID, |
| 1250 | "errorCode,Unsupported PMF"); |
| 1251 | return 0; |
| 1252 | } |
| 1253 | } |
| 1254 | |
Sarvepalli, Rajesh Babu | 24dc7e4 | 2016-03-18 21:27:26 +0530 | [diff] [blame] | 1255 | val = get_param(cmd, "PreAuthentication"); |
| 1256 | if (val) { |
| 1257 | if (strcasecmp(val, "disabled") == 0) { |
| 1258 | dut->ap_rsn_preauth = 0; |
| 1259 | } else if (strcasecmp(val, "enabled") == 0) { |
| 1260 | dut->ap_rsn_preauth = 1; |
| 1261 | } else { |
| 1262 | send_resp(dut, conn, SIGMA_INVALID, |
| 1263 | "errorCode,Unsupported PreAuthentication value"); |
| 1264 | return 0; |
| 1265 | } |
| 1266 | } |
| 1267 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1268 | return 1; |
| 1269 | } |
| 1270 | |
| 1271 | |
| 1272 | static int cmd_ap_set_radius(struct sigma_dut *dut, struct sigma_conn *conn, |
| 1273 | struct sigma_cmd *cmd) |
| 1274 | { |
| 1275 | /* const char *name = get_param(cmd, "NAME"); */ |
| 1276 | const char *val; |
| 1277 | unsigned int wlan_tag = 1, radius_port = 0; |
| 1278 | char *radius_ipaddr = NULL, *radius_password = NULL; |
| 1279 | |
| 1280 | val = get_param(cmd, "WLAN_TAG"); |
| 1281 | if (val) { |
| 1282 | wlan_tag = atoi(val); |
| 1283 | if (wlan_tag != 1 && wlan_tag != 2) { |
| 1284 | send_resp(dut, conn, SIGMA_INVALID, |
| 1285 | "errorCode,Invalid WLAN_TAG"); |
| 1286 | return 0; |
| 1287 | } |
| 1288 | } |
| 1289 | |
| 1290 | val = get_param(cmd, "PORT"); |
| 1291 | if (val) |
| 1292 | radius_port = atoi(val); |
| 1293 | |
| 1294 | if (wlan_tag == 1) { |
| 1295 | if (radius_port) |
| 1296 | dut->ap_radius_port = radius_port; |
| 1297 | radius_ipaddr = dut->ap_radius_ipaddr; |
| 1298 | radius_password = dut->ap_radius_password; |
| 1299 | } else if (wlan_tag == 2) { |
| 1300 | if (radius_port) |
| 1301 | dut->ap2_radius_port = radius_port; |
| 1302 | radius_ipaddr = dut->ap2_radius_ipaddr; |
| 1303 | radius_password = dut->ap2_radius_password; |
| 1304 | } |
| 1305 | |
| 1306 | val = get_param(cmd, "IPADDR"); |
| 1307 | if (val) { |
| 1308 | if (strlen(val) > sizeof(dut->ap_radius_ipaddr) - 1) |
| 1309 | return -1; |
| 1310 | snprintf(radius_ipaddr, sizeof(dut->ap_radius_ipaddr), |
| 1311 | "%s", val); |
| 1312 | } |
| 1313 | |
| 1314 | val = get_param(cmd, "PASSWORD"); |
| 1315 | if (val) { |
| 1316 | if (strlen(val) > sizeof(dut->ap_radius_password) - 1) |
| 1317 | return -1; |
| 1318 | snprintf(radius_password, |
| 1319 | sizeof(dut->ap_radius_password), "%s", val); |
| 1320 | } |
| 1321 | |
| 1322 | return 1; |
| 1323 | } |
| 1324 | |
| 1325 | |
| 1326 | static void owrt_ap_set_radio(struct sigma_dut *dut, int id, |
| 1327 | const char *key, const char *val) |
| 1328 | { |
| 1329 | char buf[100]; |
| 1330 | |
| 1331 | if (val == NULL) { |
| 1332 | snprintf(buf, sizeof(buf), |
| 1333 | "uci delete wireless.wifi%d.%s", id, key); |
| 1334 | run_system(dut, buf); |
| 1335 | return; |
| 1336 | } |
| 1337 | |
| 1338 | snprintf(buf, sizeof(buf), "uci set wireless.wifi%d.%s=%s", |
| 1339 | id, key, val); |
| 1340 | run_system(dut, buf); |
| 1341 | } |
| 1342 | |
| 1343 | |
| 1344 | static void owrt_ap_set_list_radio(struct sigma_dut *dut, int id, |
| 1345 | const char *key, const char *val) |
| 1346 | { |
| 1347 | char buf[256]; |
| 1348 | |
| 1349 | if (val == NULL) { |
| 1350 | snprintf(buf, sizeof(buf), |
| 1351 | "uci del_list wireless.wifi%d.%s", id, key); |
| 1352 | run_system(dut, buf); |
| 1353 | return; |
| 1354 | } |
| 1355 | |
| 1356 | snprintf(buf, sizeof(buf), "uci add_list wireless.wifi%d.%s=%s", |
| 1357 | id, key, val); |
| 1358 | run_system(dut, buf); |
| 1359 | } |
| 1360 | |
| 1361 | |
| 1362 | static void owrt_ap_set_vap(struct sigma_dut *dut, int id, const char *key, |
| 1363 | const char *val) |
| 1364 | { |
| 1365 | char buf[256]; |
| 1366 | |
| 1367 | if (val == NULL) { |
| 1368 | snprintf(buf, sizeof(buf), |
| 1369 | "uci delete wireless.@wifi-iface[%d].%s", id, key); |
| 1370 | run_system(dut, buf); |
| 1371 | return; |
| 1372 | } |
| 1373 | |
| 1374 | snprintf(buf, sizeof(buf), "uci set wireless.@wifi-iface[%d].%s=%s", |
| 1375 | id, key, val); |
| 1376 | run_system(dut, buf); |
| 1377 | } |
| 1378 | |
| 1379 | |
| 1380 | static void owrt_ap_set_list_vap(struct sigma_dut *dut, int id, |
| 1381 | const char *key, const char *val) |
| 1382 | { |
| 1383 | char buf[256]; |
| 1384 | |
| 1385 | if (val == NULL) { |
| 1386 | snprintf(buf, sizeof(buf), |
| 1387 | "uci del_list wireless.@wifi-iface[%d].%s", id, key); |
| 1388 | run_system(dut, buf); |
| 1389 | return; |
| 1390 | } |
| 1391 | |
| 1392 | snprintf(buf, sizeof(buf), |
| 1393 | "uci add_list wireless.@wifi-iface[%d].%s=%s", |
| 1394 | id, key, val); |
| 1395 | run_system(dut, buf); |
| 1396 | } |
| 1397 | |
| 1398 | |
| 1399 | static void owrt_ap_add_vap(struct sigma_dut *dut, int id, const char *key, |
| 1400 | const char *val) |
| 1401 | { |
| 1402 | char buf[256]; |
| 1403 | |
| 1404 | if (val == NULL) { |
| 1405 | snprintf(buf, sizeof(buf), |
| 1406 | "uci delete wireless.@wifi-iface[%d].%s", id, key); |
| 1407 | run_system(dut, buf); |
| 1408 | return; |
| 1409 | } |
| 1410 | |
| 1411 | snprintf(buf, sizeof(buf), "uci add wireless wifi-iface"); |
| 1412 | run_system(dut, buf); |
| 1413 | snprintf(buf, sizeof(buf), "uci set wireless.@wifi-iface[%d].%s=%s", |
| 1414 | id, key, val); |
| 1415 | run_system(dut, buf); |
| 1416 | snprintf(buf, sizeof(buf), "uci set wireless.@wifi-iface[%d].%s=%s", |
| 1417 | id, "network", "lan"); |
| 1418 | run_system(dut, buf); |
| 1419 | snprintf(buf, sizeof(buf), "uci set wireless.@wifi-iface[%d].%s=%s", |
| 1420 | id, "mode", "ap"); |
| 1421 | run_system(dut, buf); |
| 1422 | snprintf(buf, sizeof(buf), "uci set wireless.@wifi-iface[%d].%s=%s", |
| 1423 | id, "encryption", "none"); |
| 1424 | run_system(dut, buf); |
| 1425 | } |
| 1426 | |
| 1427 | |
| 1428 | #define OPENWRT_MAX_NUM_RADIOS 3 |
| 1429 | static void owrt_ap_config_radio(struct sigma_dut *dut) |
| 1430 | { |
| 1431 | int radio_id[MAX_RADIO] = { 0, 1 }; |
| 1432 | int radio_count, radio_no; |
| 1433 | char buf[64]; |
| 1434 | |
| 1435 | for (radio_count = 0; radio_count < OPENWRT_MAX_NUM_RADIOS; |
| 1436 | radio_count++) { |
| 1437 | snprintf(buf, sizeof(buf), "%s%d", "wifi", radio_count); |
| 1438 | for (radio_no = 0; radio_no < MAX_RADIO; radio_no++) { |
| 1439 | if (!sigma_radio_ifname[radio_no] || |
| 1440 | strcmp(sigma_radio_ifname[radio_no], buf) != 0) |
| 1441 | continue; |
| 1442 | owrt_ap_set_radio(dut, radio_count, "disabled", "0"); |
| 1443 | owrt_ap_set_vap(dut, radio_count, "device", buf); |
| 1444 | radio_id[radio_no] = radio_count; |
| 1445 | } |
| 1446 | } |
| 1447 | |
| 1448 | /* Hardware mode (11a/b/g/n/ac) & HT mode selection */ |
| 1449 | switch (dut->ap_mode) { |
| 1450 | case AP_11g: |
| 1451 | owrt_ap_set_radio(dut, radio_id[0], "hwmode", "11g"); |
| 1452 | break; |
| 1453 | case AP_11b: |
| 1454 | owrt_ap_set_radio(dut, radio_id[0], "hwmode", "11b"); |
| 1455 | break; |
| 1456 | case AP_11ng: |
| 1457 | owrt_ap_set_radio(dut, radio_id[0], "hwmode", "11ng"); |
| 1458 | owrt_ap_set_radio(dut, radio_id[0], "htmode", "HT20"); |
| 1459 | break; |
| 1460 | case AP_11a: |
| 1461 | owrt_ap_set_radio(dut, radio_id[0], "hwmode", "11a"); |
| 1462 | break; |
| 1463 | case AP_11na: |
| 1464 | owrt_ap_set_radio(dut, radio_id[0], "hwmode", "11na"); |
| 1465 | owrt_ap_set_radio(dut, radio_id[0], "htmode", "HT20"); |
| 1466 | break; |
| 1467 | case AP_11ac: |
| 1468 | owrt_ap_set_radio(dut, radio_id[0], "hwmode", "11ac"); |
| 1469 | owrt_ap_set_radio(dut, radio_id[0], "htmode", "HT80"); |
| 1470 | break; |
| 1471 | case AP_inval: |
| 1472 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 1473 | "MODE NOT SPECIFIED!"); |
| 1474 | return; |
| 1475 | default: |
| 1476 | owrt_ap_set_radio(dut, radio_id[0], "hwmode", "11ng"); |
| 1477 | owrt_ap_set_radio(dut, radio_id[0], "htmode", "HT20"); |
| 1478 | break; |
| 1479 | } |
| 1480 | |
| 1481 | if (dut->ap_is_dual) { |
| 1482 | /* Hardware mode (11a/b/g/n/ac) & HT mode selection */ |
| 1483 | switch (dut->ap_mode_1) { |
| 1484 | case AP_11g: |
| 1485 | owrt_ap_set_radio(dut, radio_id[1], "hwmode", "11g"); |
| 1486 | break; |
| 1487 | case AP_11b: |
| 1488 | owrt_ap_set_radio(dut, radio_id[1], "hwmode", "11b"); |
| 1489 | break; |
| 1490 | case AP_11ng: |
| 1491 | owrt_ap_set_radio(dut, radio_id[1], "hwmode", "11ng"); |
| 1492 | owrt_ap_set_radio(dut, radio_id[1], "htmode", "HT20"); |
| 1493 | break; |
| 1494 | case AP_11a: |
| 1495 | owrt_ap_set_radio(dut, radio_id[1], "hwmode", "11a"); |
| 1496 | break; |
| 1497 | case AP_11na: |
| 1498 | owrt_ap_set_radio(dut, radio_id[1], "hwmode", "11na"); |
| 1499 | owrt_ap_set_radio(dut, radio_id[1], "htmode", "HT20"); |
| 1500 | break; |
| 1501 | case AP_11ac: |
| 1502 | owrt_ap_set_radio(dut, radio_id[1], "hwmode", "11ac"); |
| 1503 | owrt_ap_set_radio(dut, radio_id[1], "htmode", "HT80"); |
| 1504 | break; |
| 1505 | case AP_inval: |
| 1506 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 1507 | "MODE NOT SPECIFIED!"); |
| 1508 | return; |
| 1509 | default: |
| 1510 | owrt_ap_set_radio(dut, radio_id[1], "hwmode", "11ng"); |
| 1511 | owrt_ap_set_radio(dut, radio_id[1], "htmode", "HT20"); |
| 1512 | break; |
| 1513 | } |
| 1514 | |
| 1515 | } |
| 1516 | |
| 1517 | /* Channel */ |
| 1518 | snprintf(buf, sizeof(buf), "%d", dut->ap_channel); |
| 1519 | owrt_ap_set_radio(dut, radio_id[0], "channel", buf); |
| 1520 | |
| 1521 | switch (dut->ap_chwidth) { |
| 1522 | case AP_20: |
| 1523 | owrt_ap_set_radio(dut, radio_id[0], "htmode", "HT20"); |
| 1524 | break; |
| 1525 | case AP_40: |
| 1526 | owrt_ap_set_radio(dut, radio_id[0], "htmode", "HT40"); |
| 1527 | break; |
| 1528 | case AP_80: |
| 1529 | owrt_ap_set_radio(dut, radio_id[0], "htmode", "HT80"); |
| 1530 | break; |
| 1531 | case AP_160: |
| 1532 | owrt_ap_set_radio(dut, radio_id[0], "htmode", "HT160"); |
| 1533 | break; |
| 1534 | case AP_AUTO: |
| 1535 | default: |
| 1536 | break; |
| 1537 | } |
| 1538 | |
| 1539 | if (dut->ap_channel == 140 || dut->ap_channel == 144) { |
| 1540 | if (get_openwrt_driver_type() == OPENWRT_DRIVER_ATHEROS) |
| 1541 | owrt_ap_set_radio(dut, radio_id[0], "set_ch_144", "3"); |
| 1542 | } |
| 1543 | |
| 1544 | if (dut->ap_is_dual) { |
| 1545 | snprintf(buf, sizeof(buf), "%d", dut->ap_channel_1); |
| 1546 | owrt_ap_set_radio(dut, radio_id[1], "channel", buf); |
| 1547 | } |
| 1548 | |
| 1549 | if (dut->ap_countrycode[0]) { |
| 1550 | /* Country Code */ |
| 1551 | snprintf(buf, sizeof(buf), "%s", dut->ap_countrycode); |
| 1552 | owrt_ap_set_radio(dut, radio_id[0], "country", buf); |
| 1553 | } |
| 1554 | |
| 1555 | if (dut->ap_disable_protection == 1) { |
| 1556 | owrt_ap_set_list_radio(dut, radio_id[0], "aggr_burst", "'0 0'"); |
| 1557 | owrt_ap_set_list_radio(dut, radio_id[0], "aggr_burst", "'1 0'"); |
| 1558 | owrt_ap_set_list_radio(dut, radio_id[0], "aggr_burst", "'2 0'"); |
| 1559 | owrt_ap_set_list_radio(dut, radio_id[0], "aggr_burst", "'3 0'"); |
| 1560 | } |
| 1561 | } |
| 1562 | |
| 1563 | |
| 1564 | static int owrt_ap_config_vap_hs2(struct sigma_dut *dut, int vap_id) |
| 1565 | { |
| 1566 | char buf[256]; |
| 1567 | |
| 1568 | snprintf(buf, sizeof(buf), "%d", dut->ap_hs2); |
| 1569 | owrt_ap_set_vap(dut, vap_id, "hs20", buf); |
| 1570 | owrt_ap_set_vap(dut, vap_id, "qbssload", "1"); |
| 1571 | owrt_ap_set_vap(dut, vap_id, "hs20_deauth_req_timeout","3"); |
| 1572 | |
| 1573 | owrt_ap_set_list_vap(dut, vap_id, "hs20_oper_friendly_name", |
| 1574 | "'eng:Wi-Fi Alliance'"); |
| 1575 | |
| 1576 | owrt_ap_set_list_vap(dut, vap_id, "hs20_oper_friendly_name", |
| 1577 | "'chi:Wi-Fi\xe8\x81\x94\xe7\x9b\x9f'"); |
| 1578 | |
| 1579 | if (dut->ap_wan_metrics == 1) |
| 1580 | owrt_ap_set_vap(dut, vap_id, "hs20_wan_metrics", |
| 1581 | "'01:2500:384:0:0:10'"); |
| 1582 | else if (dut->ap_wan_metrics == 1) |
| 1583 | owrt_ap_set_vap(dut, vap_id, "hs20_wan_metrics", |
| 1584 | "'01:1500:384:20:20:10'"); |
| 1585 | else if (dut->ap_wan_metrics == 2) |
| 1586 | owrt_ap_set_vap(dut, vap_id, "hs20_wan_metrics", |
| 1587 | "'01:1500:384:20:20:10'"); |
| 1588 | else if (dut->ap_wan_metrics == 3) |
| 1589 | owrt_ap_set_vap(dut, vap_id, "hs20_wan_metrics", |
| 1590 | "'01:2000:1000:20:20:10'"); |
| 1591 | else if (dut->ap_wan_metrics == 4) |
| 1592 | owrt_ap_set_vap(dut, vap_id, "hs20_wan_metrics", |
| 1593 | "'01:8000:1000:20:20:10'"); |
| 1594 | else if (dut->ap_wan_metrics == 5) |
| 1595 | owrt_ap_set_vap(dut, vap_id, "hs20_wan_metrics", |
| 1596 | "'01:9000:5000:20:20:10'"); |
| 1597 | |
| 1598 | if (dut->ap_conn_capab == 1) { |
| 1599 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", "'1:0:0'"); |
| 1600 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", |
| 1601 | "'6:20:1'"); |
| 1602 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", |
| 1603 | "'6:22:0'"); |
| 1604 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", |
| 1605 | "'6:80:1'"); |
| 1606 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", |
| 1607 | "'6:443:1'"); |
| 1608 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", |
| 1609 | "'6:1723:0'"); |
| 1610 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", |
| 1611 | "'6:5060:0'"); |
| 1612 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", |
| 1613 | "'17:500:1'"); |
| 1614 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", |
| 1615 | "'17:5060:0'"); |
| 1616 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", |
| 1617 | "'17:4500:1'"); |
| 1618 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", |
| 1619 | "'50:0:1'"); |
| 1620 | } else if (dut->ap_conn_capab == 2) { |
| 1621 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", |
| 1622 | "'6:80:1'"); |
| 1623 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", |
| 1624 | "'6:443:1'"); |
| 1625 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", |
| 1626 | "'17:5060:1'"); |
| 1627 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", |
| 1628 | "'6:5060:1'"); |
| 1629 | } else if (dut->ap_conn_capab == 3) { |
| 1630 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", |
| 1631 | "'6:80:1'"); |
| 1632 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", |
| 1633 | "'6:443:1'"); |
| 1634 | } |
| 1635 | |
| 1636 | if (dut->ap_oper_class == 1) |
| 1637 | snprintf(buf, sizeof(buf), "%s", "51"); |
| 1638 | else if (dut->ap_oper_class == 2) |
| 1639 | snprintf(buf, sizeof(buf), "%s", "73"); |
| 1640 | else if (dut->ap_oper_class == 3) |
| 1641 | snprintf(buf, sizeof(buf), "%s", "5173"); |
| 1642 | |
| 1643 | if (dut->ap_oper_class) |
| 1644 | owrt_ap_set_vap(dut, vap_id, "hs20_operating_class", buf); |
| 1645 | |
| 1646 | if (dut->ap_osu_provider_list) { |
| 1647 | char *osu_friendly_name = NULL; |
| 1648 | char *osu_icon = NULL; |
| 1649 | char *osu_ssid = NULL; |
| 1650 | char *osu_nai = NULL; |
| 1651 | char *osu_service_desc = NULL; |
| 1652 | char *hs20_icon_filename = NULL; |
| 1653 | char hs20_icon[150]; |
| 1654 | int osu_method; |
| 1655 | |
| 1656 | hs20_icon_filename = "icon_red_zxx.png"; |
| 1657 | if (dut->ap_osu_icon_tag == 2) |
| 1658 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 1659 | snprintf(hs20_icon, sizeof(hs20_icon), |
| 1660 | "'128:61:zxx:image/png:icon_red_zxx.png:/etc/ath/%s'", |
| 1661 | hs20_icon_filename); |
| 1662 | osu_icon = "icon_red_zxx.png"; |
| 1663 | osu_ssid = "OSU"; |
| 1664 | osu_friendly_name = "'kor:SP 빨강 테스트 전용'"; |
| 1665 | osu_service_desc = "'kor:테스트 목적으로 무료 서비스'"; |
| 1666 | osu_method = (dut->ap_osu_method[0] == 0xFF) ? 1 : |
| 1667 | dut->ap_osu_method[0]; |
| 1668 | |
| 1669 | if (strlen(dut->ap_osu_server_uri[0])) |
| 1670 | owrt_ap_set_list_vap(dut, vap_id, "osu_server_uri", |
| 1671 | dut->ap_osu_server_uri[0]); |
| 1672 | else |
| 1673 | owrt_ap_set_list_vap(dut, vap_id, "osu_server_uri", |
| 1674 | "'https://osu-server.r2-testbed.wi-fi.org/'"); |
| 1675 | switch (dut->ap_osu_provider_list) { |
| 1676 | case 1: |
| 1677 | case 101: |
| 1678 | owrt_ap_set_list_vap(dut, vap_id, "osu_friendly_name", |
| 1679 | "'eng:SP Red Test Only'"); |
| 1680 | owrt_ap_set_list_vap(dut, vap_id, "osu_service_desc", |
| 1681 | "'eng:Free service for test purpose'"); |
| 1682 | owrt_ap_set_list_vap(dut, vap_id, "hs20_icon", |
| 1683 | hs20_icon); |
| 1684 | |
| 1685 | hs20_icon_filename = "icon_red_eng.png"; |
| 1686 | if (dut->ap_osu_icon_tag == 2) |
| 1687 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 1688 | |
| 1689 | snprintf(hs20_icon, sizeof(hs20_icon), |
| 1690 | "'160:76:eng:image/png:icon_red_eng.png:/etc/ath/%s'", |
| 1691 | hs20_icon_filename); |
| 1692 | owrt_ap_set_list_vap(dut, vap_id, "osu_icon", |
| 1693 | "icon_red_eng.png"); |
| 1694 | break; |
| 1695 | case 2: |
| 1696 | case 102: |
| 1697 | owrt_ap_set_list_vap(dut, vap_id, "osu_friendly_name", |
| 1698 | "'eng:Wireless Broadband Alliance'"); |
| 1699 | owrt_ap_set_list_vap(dut, vap_id, "osu_service_desc", |
| 1700 | "'eng:Free service for test purpose'"); |
| 1701 | hs20_icon_filename = "icon_green_zxx.png"; |
| 1702 | if (dut->ap_osu_icon_tag == 2) |
| 1703 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 1704 | |
| 1705 | snprintf(hs20_icon, sizeof(hs20_icon), |
| 1706 | "'128:61:zxx:image/png:icon_green_zxx.png:/etc/ath/%s'", |
| 1707 | hs20_icon_filename); |
| 1708 | osu_icon = "icon_green_zxx.png"; |
| 1709 | osu_friendly_name = "'kor:와이어리스 브로드밴드 얼라이언스'"; |
| 1710 | break; |
| 1711 | case 3: |
| 1712 | case 103: |
| 1713 | osu_friendly_name = "spa:SP Red Test Only"; |
| 1714 | osu_service_desc = "spa:Free service for test purpose"; |
| 1715 | break; |
| 1716 | case 4: |
| 1717 | case 104: |
| 1718 | owrt_ap_set_list_vap(dut, vap_id, "osu_friendly_name", |
| 1719 | "'eng:SP Blue Test Only'"); |
| 1720 | owrt_ap_set_list_vap(dut, vap_id, "osu_service_desc", |
| 1721 | "'eng:Free service for test purpose'"); |
| 1722 | hs20_icon_filename = "icon_blue_eng.png"; |
| 1723 | if (dut->ap_osu_icon_tag == 2) |
| 1724 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 1725 | |
| 1726 | snprintf(hs20_icon, sizeof(hs20_icon), |
| 1727 | "'160:76:eng:image/png:icon_blue_eng.png:/etc/ath/%s'", |
| 1728 | hs20_icon_filename); |
| 1729 | owrt_ap_set_list_vap(dut, vap_id, "hs20_icon", |
| 1730 | hs20_icon); |
| 1731 | osu_friendly_name = "'kor:SP 파랑 테스트 전용'"; |
| 1732 | |
| 1733 | hs20_icon_filename = "icon_blue_zxx.png"; |
| 1734 | if (dut->ap_osu_icon_tag == 2) |
| 1735 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 1736 | |
| 1737 | snprintf(hs20_icon, sizeof(hs20_icon), |
| 1738 | "'128:61:zxx:image/png:icon_blue_zxx.png:/etc/ath/%s'", |
| 1739 | hs20_icon_filename); |
| 1740 | osu_icon = "icon_blue_zxx.png"; |
| 1741 | break; |
| 1742 | case 5: |
| 1743 | case 105: |
| 1744 | owrt_ap_set_list_vap(dut, vap_id, "osu_friendly_name", |
| 1745 | "'eng:SP Blue Test Only'"); |
| 1746 | owrt_ap_set_list_vap(dut, vap_id, "osu_service_desc", |
| 1747 | "'eng:Free service for test purpose'"); |
| 1748 | osu_friendly_name = "'kor:SP 파랑 테스트 전용'"; |
| 1749 | |
| 1750 | hs20_icon_filename = "icon_blue_zxx.png"; |
| 1751 | if (dut->ap_osu_icon_tag == 2) |
| 1752 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 1753 | |
| 1754 | snprintf(hs20_icon, sizeof(hs20_icon), |
| 1755 | "'128:61:zxx:image/png:icon_blue_zxx.png:/etc/ath/%s'", |
| 1756 | hs20_icon_filename); |
| 1757 | osu_icon = "icon_blue_zxx.png"; |
| 1758 | break; |
| 1759 | case 6: |
| 1760 | case 106: |
| 1761 | owrt_ap_set_list_vap(dut, vap_id, "osu_friendly_name", |
| 1762 | "'eng:SP Green Test Only'"); |
| 1763 | owrt_ap_set_list_vap(dut, vap_id, "osu_friendly_name", |
| 1764 | "'kor:SP 초록 테스트 전용'"); |
| 1765 | |
| 1766 | hs20_icon_filename = "icon_green_zxx.png"; |
| 1767 | if (dut->ap_osu_icon_tag == 2) |
| 1768 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 1769 | |
| 1770 | snprintf(hs20_icon, sizeof(hs20_icon), |
| 1771 | "'128:61:zxx:image/png:icon_green_zxx.png:/etc/ath/%s'", |
| 1772 | hs20_icon_filename); |
| 1773 | owrt_ap_set_list_vap(dut, vap_id, "hs20_icon", |
| 1774 | hs20_icon); |
| 1775 | |
| 1776 | owrt_ap_set_list_vap(dut, vap_id, "osu_icon", |
| 1777 | "'icon_green_zxx.png'"); |
| 1778 | osu_method = (dut->ap_osu_method[0] == 0xFF) ? 0 : |
| 1779 | dut->ap_osu_method[0]; |
| 1780 | |
| 1781 | snprintf(buf, sizeof(buf), "%d", osu_method); |
| 1782 | owrt_ap_set_vap(dut, vap_id, "osu_method_list", buf); |
| 1783 | |
| 1784 | if (strlen(dut->ap_osu_server_uri[1])) |
| 1785 | owrt_ap_set_list_vap(dut, vap_id, |
| 1786 | "osu_server_uri", |
| 1787 | dut->ap_osu_server_uri[1]); |
| 1788 | else |
| 1789 | owrt_ap_set_list_vap(dut, vap_id, |
| 1790 | "osu_server_uri", |
| 1791 | "'https://osu-server.r2-testbed.wi-fi.org/'"); |
| 1792 | |
| 1793 | owrt_ap_set_list_vap(dut, vap_id, "osu_friendly_name", |
| 1794 | "'eng:SP Orange Test Only'"); |
| 1795 | |
| 1796 | hs20_icon_filename = "icon_orange_zxx.png"; |
| 1797 | if (dut->ap_osu_icon_tag == 2) |
| 1798 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 1799 | |
| 1800 | snprintf(hs20_icon, sizeof(hs20_icon), |
| 1801 | "'128:61:zxx:image/png:icon_orange_zxx.png:/etc/ath/%s'", |
| 1802 | hs20_icon_filename); |
| 1803 | |
| 1804 | osu_icon = "icon_orange_zxx.png"; |
| 1805 | osu_friendly_name = "'kor:SP 오렌지 테스트 전용'"; |
| 1806 | osu_method = (dut->ap_osu_method[1] == 0xFF) ? 0 : |
| 1807 | dut->ap_osu_method[1]; |
| 1808 | osu_service_desc = NULL; |
| 1809 | break; |
| 1810 | case 7: |
| 1811 | case 107: |
| 1812 | owrt_ap_set_list_vap(dut, vap_id, "osu_friendly_name", |
| 1813 | "'eng:SP Orange Test Only'"); |
| 1814 | owrt_ap_set_list_vap(dut, vap_id, "osu_service_desc", |
| 1815 | "'eng:Free service for test purpose'"); |
| 1816 | |
| 1817 | hs20_icon_filename = "icon_orange_eng.png"; |
| 1818 | if (dut->ap_osu_icon_tag == 2) |
| 1819 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 1820 | |
| 1821 | snprintf(hs20_icon, sizeof(hs20_icon), |
| 1822 | "'160:76:eng:image/png:icon_orange_eng.png:/etc/ath/%s'", |
| 1823 | hs20_icon_filename); |
| 1824 | owrt_ap_set_list_vap(dut, vap_id, "hs20_icon", |
| 1825 | hs20_icon); |
| 1826 | |
| 1827 | owrt_ap_set_list_vap(dut, vap_id, "osu_icon", |
| 1828 | "'icon_orange_eng.png'"); |
| 1829 | osu_friendly_name = "'kor:SP 오렌지 테스트 전용'"; |
| 1830 | |
| 1831 | hs20_icon_filename = "icon_orange_zxx.png"; |
| 1832 | if (dut->ap_osu_icon_tag == 2) |
| 1833 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 1834 | |
| 1835 | snprintf(hs20_icon, sizeof(hs20_icon), |
| 1836 | "'128:61:zxx:image/png:icon_orange_zxx.png:/etc/ath/%s'", |
| 1837 | hs20_icon_filename); |
| 1838 | osu_icon = "icon_orange_zxx.png"; |
| 1839 | break; |
| 1840 | case 8: |
| 1841 | case 108: |
| 1842 | owrt_ap_set_list_vap(dut, vap_id, "osu_friendly_name", |
| 1843 | "'eng:SP Red Test Only'"); |
| 1844 | owrt_ap_set_list_vap(dut, vap_id, "osu_service_desc", |
| 1845 | "'eng:Free service for test purpose'"); |
| 1846 | osu_ssid = "OSU-Encrypted"; |
| 1847 | osu_nai = "'anonymous@hotspot.net'"; |
| 1848 | break; |
| 1849 | case 9: |
| 1850 | case 109: |
| 1851 | osu_ssid = "OSU-OSEN"; |
| 1852 | osu_nai = "'test-anonymous@wi-fi.org'"; |
| 1853 | osu_friendly_name = "'eng:SP Orange Test Only'"; |
| 1854 | hs20_icon_filename = "icon_orange_zxx.png"; |
| 1855 | if (dut->ap_osu_icon_tag == 2) |
| 1856 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 1857 | |
| 1858 | snprintf(hs20_icon, sizeof(hs20_icon), |
| 1859 | "'128:61:zxx:image/png:icon_orange_zxx.png:/etc/ath/%s'", |
| 1860 | hs20_icon_filename); |
| 1861 | osu_icon = "icon_orange_zxx.png"; |
| 1862 | osu_method = (dut->ap_osu_method[0] == 0xFF) ? 1 : |
| 1863 | dut->ap_osu_method[0]; |
| 1864 | osu_service_desc = NULL; |
| 1865 | break; |
| 1866 | default: |
| 1867 | break; |
| 1868 | } |
| 1869 | |
| 1870 | if (strlen(dut->ap_osu_ssid)) { |
| 1871 | if (strcmp(dut->ap2_ssid, dut->ap_osu_ssid) != 0 && |
| 1872 | strcmp(dut->ap2_ssid, osu_ssid) != 0) { |
| 1873 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 1874 | "OSU_SSID and WLAN_TAG2 SSID differ"); |
| 1875 | return -2; |
| 1876 | } |
| 1877 | |
| 1878 | snprintf(buf, sizeof(buf), "'\"%s\"'", |
| 1879 | dut->ap_osu_ssid); |
| 1880 | } else { |
| 1881 | snprintf(buf, sizeof(buf), "'\"%s\"'", osu_ssid); |
| 1882 | } |
| 1883 | |
| 1884 | owrt_ap_set_vap(dut, vap_id, "osu_ssid", buf); |
| 1885 | |
| 1886 | |
| 1887 | if (osu_friendly_name) |
| 1888 | owrt_ap_set_list_vap(dut, vap_id, "osu_friendly_name", |
| 1889 | osu_friendly_name); |
| 1890 | if (osu_service_desc) |
| 1891 | owrt_ap_set_list_vap(dut, vap_id, "osu_service_desc", |
| 1892 | osu_service_desc); |
| 1893 | if (osu_nai) |
| 1894 | owrt_ap_set_vap(dut, vap_id, "osu_nai", osu_nai); |
| 1895 | |
| 1896 | owrt_ap_set_list_vap(dut, vap_id, "hs20_icon", hs20_icon); |
| 1897 | |
| 1898 | if (osu_icon) |
| 1899 | owrt_ap_set_list_vap(dut, vap_id, "osu_icon", |
| 1900 | osu_icon); |
| 1901 | |
| 1902 | if (dut->ap_osu_provider_list > 100) { |
| 1903 | owrt_ap_set_list_vap(dut, vap_id, "osu_method_list", |
| 1904 | "0"); |
| 1905 | } else { |
| 1906 | snprintf(buf, sizeof(buf), "%d", osu_method); |
| 1907 | owrt_ap_set_list_vap(dut, vap_id, "osu_method_list", |
| 1908 | buf); |
| 1909 | } |
| 1910 | } |
| 1911 | |
| 1912 | return 0; |
| 1913 | } |
| 1914 | |
| 1915 | |
| 1916 | static int owrt_ap_config_vap(struct sigma_dut *dut) |
| 1917 | { |
| 1918 | char buf[256], *temp; |
| 1919 | int vap_id = 0, vap_count, i; |
| 1920 | |
| 1921 | for (vap_count = 0; vap_count < OPENWRT_MAX_NUM_RADIOS; vap_count++) { |
| 1922 | snprintf(buf, sizeof(buf), "%s%d", "wifi", vap_count); |
| 1923 | |
| 1924 | for (vap_id = 0; vap_id < MAX_RADIO; vap_id++) { |
| 1925 | if (sigma_radio_ifname[vap_id] && |
| 1926 | strcmp(sigma_radio_ifname[vap_id], buf) == 0) |
| 1927 | break; |
| 1928 | } |
| 1929 | if (vap_id == MAX_RADIO) |
| 1930 | continue; |
| 1931 | |
| 1932 | /* Single VAP configuration */ |
| 1933 | if (!dut->ap_is_dual) |
| 1934 | vap_id = vap_count; |
| 1935 | |
| 1936 | if (strlen(dut->ap2_ssid)) { |
| 1937 | owrt_ap_add_vap(dut, vap_count + 1, "device", buf); |
| 1938 | /* SSID */ |
| 1939 | snprintf(buf, sizeof(buf), "\"%s\"", dut->ap2_ssid); |
| 1940 | owrt_ap_set_vap(dut, vap_count + 1, "ssid", buf); |
| 1941 | |
| 1942 | if (dut->ap2_key_mgmt == AP2_OSEN) { |
| 1943 | owrt_ap_set_vap(dut, vap_count + 1, |
| 1944 | "osen", "1"); |
| 1945 | snprintf(buf, sizeof(buf), "wpa2"); |
| 1946 | owrt_ap_set_vap(dut, vap_count + 1, |
| 1947 | "encryption", buf); |
| 1948 | snprintf(buf, sizeof(buf), "%s", |
| 1949 | dut->ap2_radius_ipaddr); |
| 1950 | owrt_ap_set_vap(dut, vap_count + 1, |
| 1951 | "auth_server", buf); |
| 1952 | snprintf(buf, sizeof(buf), "%d", |
| 1953 | dut->ap2_radius_port); |
| 1954 | owrt_ap_set_vap(dut, vap_count + 1, |
| 1955 | "auth_port", buf); |
| 1956 | snprintf(buf, sizeof(buf), "%s", |
| 1957 | dut->ap2_radius_password); |
| 1958 | owrt_ap_set_vap(dut, vap_count + 1, |
| 1959 | "auth_secret", buf); |
| 1960 | } |
| 1961 | } |
| 1962 | |
| 1963 | /* SSID */ |
| 1964 | snprintf(buf, sizeof(buf), "\"%s\"", dut->ap_ssid); |
| 1965 | owrt_ap_set_vap(dut, vap_count, "ssid", buf); |
| 1966 | |
| 1967 | /* Encryption */ |
| 1968 | switch (dut->ap_key_mgmt) { |
| 1969 | case AP_OPEN: |
| 1970 | if (dut->ap_cipher == AP_WEP) { |
| 1971 | owrt_ap_set_vap(dut, vap_count, "encryption", |
| 1972 | "wep-mixed"); |
| 1973 | owrt_ap_set_vap(dut, vap_count, "key", |
| 1974 | dut->ap_wepkey); |
| 1975 | } else { |
| 1976 | owrt_ap_set_vap(dut, vap_count, "encryption", |
| 1977 | "none"); |
| 1978 | } |
| 1979 | break; |
| 1980 | case AP_WPA2_PSK: |
| 1981 | case AP_WPA2_PSK_MIXED: |
| 1982 | case AP_WPA_PSK: |
| 1983 | if (dut->ap_key_mgmt == AP_WPA2_PSK) { |
| 1984 | snprintf(buf, sizeof(buf), "psk2"); |
| 1985 | } else if (dut->ap_key_mgmt == AP_WPA2_PSK_MIXED) { |
| 1986 | snprintf(buf, sizeof(buf), "psk-mixed"); |
| 1987 | } else { |
| 1988 | snprintf(buf, sizeof(buf), "psk"); |
| 1989 | } |
| 1990 | |
| 1991 | if (dut->ap_cipher == AP_CCMP_TKIP) { |
| 1992 | strncat(buf, "+ccmp+tkip", |
| 1993 | sizeof(buf) - sizeof("+ccmp+tkip")); |
| 1994 | } else if (dut->ap_cipher == AP_TKIP) { |
| 1995 | strncat(buf, "+tkip", |
| 1996 | sizeof(buf) - sizeof("+tkip")); |
| 1997 | } else { |
| 1998 | strncat(buf, "+ccmp", |
| 1999 | sizeof(buf) - sizeof("+ccmp")); |
| 2000 | } |
| 2001 | |
| 2002 | owrt_ap_set_vap(dut, vap_count, "encryption", buf); |
| 2003 | snprintf(buf, sizeof(buf), "\"%s\"", |
| 2004 | dut->ap_passphrase); |
| 2005 | owrt_ap_set_vap(dut, vap_count, "key", buf); |
| 2006 | break; |
| 2007 | case AP_WPA2_EAP: |
| 2008 | case AP_WPA2_EAP_MIXED: |
| 2009 | case AP_WPA_EAP: |
| 2010 | if (dut->ap_key_mgmt == AP_WPA2_EAP) { |
| 2011 | snprintf(buf, sizeof(buf), "wpa2"); |
| 2012 | } else if (dut->ap_key_mgmt == AP_WPA2_EAP_MIXED) { |
| 2013 | snprintf(buf, sizeof(buf), "wpa-mixed"); |
| 2014 | } else { |
| 2015 | snprintf(buf, sizeof(buf), "wpa"); |
| 2016 | } |
| 2017 | |
| 2018 | if (dut->ap_cipher == AP_CCMP_TKIP) { |
| 2019 | strncat(buf, "+ccmp+tkip", sizeof(buf)); |
| 2020 | } else if (dut->ap_cipher == AP_TKIP) { |
| 2021 | strncat(buf, "+tkip", sizeof(buf)); |
| 2022 | } else { |
| 2023 | strncat(buf, "+ccmp", sizeof(buf)); |
| 2024 | } |
| 2025 | owrt_ap_set_vap(dut, vap_count, "encryption", buf); |
| 2026 | snprintf(buf, sizeof(buf), "%s", dut->ap_radius_ipaddr); |
| 2027 | owrt_ap_set_vap(dut, vap_count, "auth_server", buf); |
| 2028 | snprintf(buf, sizeof(buf), "%d", dut->ap_radius_port); |
| 2029 | owrt_ap_set_vap(dut, vap_count, "auth_port", buf); |
| 2030 | snprintf(buf, sizeof(buf), "%s", |
| 2031 | dut->ap_radius_password); |
| 2032 | owrt_ap_set_vap(dut, vap_count, "auth_secret", buf); |
| 2033 | break; |
| 2034 | } |
| 2035 | |
| 2036 | if (!dut->ap_is_dual) |
| 2037 | break; |
| 2038 | } |
| 2039 | |
| 2040 | if (dut->ap_is_dual) |
| 2041 | return 1; |
| 2042 | |
| 2043 | /* PMF */ |
| 2044 | snprintf(buf, sizeof(buf), "%d", dut->ap_pmf); |
| 2045 | owrt_ap_set_vap(dut, vap_id, "ieee80211w", buf); |
| 2046 | |
| 2047 | /* Add SHA256 */ |
| 2048 | snprintf(buf, sizeof(buf), "%d", dut->ap_add_sha256); |
| 2049 | owrt_ap_set_vap(dut, vap_id, "add_sha256", buf); |
| 2050 | |
Sarvepalli, Rajesh Babu | 24dc7e4 | 2016-03-18 21:27:26 +0530 | [diff] [blame] | 2051 | /* Enable RSN preauthentication, if asked to */ |
| 2052 | snprintf(buf, sizeof(buf), "%d", dut->ap_rsn_preauth); |
| 2053 | owrt_ap_set_vap(dut, vap_id, "rsn_preauth", buf); |
| 2054 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2055 | /* Hotspot 2.0 */ |
| 2056 | if (dut->ap_hs2) { |
| 2057 | int ret; |
| 2058 | |
| 2059 | ret = owrt_ap_config_vap_hs2(dut, vap_id); |
| 2060 | if (ret) |
| 2061 | return ret; |
| 2062 | } |
| 2063 | |
| 2064 | /* Interworking */ |
| 2065 | if (dut->ap_interworking) { |
| 2066 | snprintf(buf, sizeof(buf), "%d", dut->ap_access_net_type); |
| 2067 | owrt_ap_set_vap(dut, vap_id, "access_network_type", buf); |
| 2068 | snprintf(buf, sizeof(buf), "%d", dut->ap_internet); |
| 2069 | owrt_ap_set_vap(dut, vap_id, "internet", buf); |
| 2070 | snprintf(buf, sizeof(buf), "%d", dut->ap_venue_group); |
| 2071 | owrt_ap_set_vap(dut, vap_id, "venue_group", buf); |
| 2072 | snprintf(buf, sizeof(buf), "%d", dut->ap_venue_type); |
| 2073 | owrt_ap_set_vap(dut, vap_id, "venue_type", buf); |
| 2074 | snprintf(buf, sizeof(buf), "%s", dut->ap_hessid); |
| 2075 | owrt_ap_set_vap(dut, vap_id, "hessid", buf); |
| 2076 | |
| 2077 | if (dut->ap_gas_cb_delay > 0) { |
| 2078 | snprintf(buf, sizeof(buf), "%d", dut->ap_gas_cb_delay); |
| 2079 | owrt_ap_set_vap(dut, vap_id, "gas_comeback_delay", buf); |
| 2080 | } |
| 2081 | |
| 2082 | if (dut->ap_roaming_cons[0]) { |
| 2083 | char *rcons, *temp_ptr; |
| 2084 | |
| 2085 | rcons = strdup(dut->ap_roaming_cons); |
| 2086 | if (rcons == NULL) |
| 2087 | return 0; |
| 2088 | |
| 2089 | temp_ptr = strchr(rcons, ';'); |
| 2090 | |
| 2091 | if (temp_ptr) |
| 2092 | *temp_ptr++ = '\0'; |
| 2093 | |
| 2094 | owrt_ap_set_list_vap(dut, vap_id, "roaming_consortium", |
| 2095 | rcons); |
| 2096 | |
| 2097 | if (temp_ptr) |
| 2098 | owrt_ap_set_list_vap(dut, vap_id, |
| 2099 | "roaming_consortium", |
| 2100 | temp_ptr); |
| 2101 | |
| 2102 | free(rcons); |
| 2103 | } |
| 2104 | } |
| 2105 | |
| 2106 | if (dut->ap_venue_name) { |
| 2107 | owrt_ap_set_list_vap(dut, vap_id, "venue_name", |
| 2108 | "'P\"eng:Wi-Fi Alliance\\n2989 Copper Road\\nSanta Clara, CA 95051, USA\"'"); |
| 2109 | owrt_ap_set_list_vap(dut, vap_id, "venue_name", |
| 2110 | "\'"ANQP_VENUE_NAME_1_CHI"\'"); |
| 2111 | } |
| 2112 | |
| 2113 | if (dut->ap_net_auth_type == 1) { |
| 2114 | owrt_ap_set_vap(dut, vap_id, "network_auth_type", |
| 2115 | "'00https://tandc-server.wi-fi.org'"); |
| 2116 | } else if (dut->ap_net_auth_type == 2) { |
| 2117 | owrt_ap_set_vap(dut, vap_id, "network_auth_type", "'01'"); |
| 2118 | } |
| 2119 | |
| 2120 | if (dut->ap_nai_realm_list == 1) { |
| 2121 | owrt_ap_set_list_vap(dut, vap_id, "nai_realm", |
| 2122 | "'0,mail.example.com;cisco.com;wi-fi.org,21[2:4][5:7]'"); |
| 2123 | owrt_ap_set_list_vap(dut, vap_id, "nai_realm", |
| 2124 | "'0,wi-fi.org;example.com,13[5:6]'"); |
| 2125 | |
| 2126 | } else if (dut->ap_nai_realm_list == 2) { |
| 2127 | owrt_ap_set_list_vap(dut, vap_id, "nai_realm", |
| 2128 | "'0,wi-fi.org,21[2:4][5:7]'"); |
| 2129 | } else if (dut->ap_nai_realm_list == 3) { |
| 2130 | owrt_ap_set_list_vap(dut, vap_id, "nai_realm", |
| 2131 | "'0,cisco.com;wi-fi.org,21[2:4][5:7]'"); |
| 2132 | owrt_ap_set_list_vap(dut, vap_id, "nai_realm", |
| 2133 | "'0,wi-fi.org;example.com,13[5:6]'"); |
| 2134 | } else if (dut->ap_nai_realm_list == 4) { |
| 2135 | owrt_ap_set_list_vap(dut, vap_id, "nai_realm", |
| 2136 | "'0,mail.example.com,21[2:4][5:7],13[5:6]'"); |
| 2137 | } else if (dut->ap_nai_realm_list == 5) { |
| 2138 | owrt_ap_set_list_vap(dut, vap_id, "nai_realm", |
| 2139 | "'0,wi-fi.org;ruckuswireless.com,21[2:4][5:7]'"); |
| 2140 | } else if (dut->ap_nai_realm_list == 6) { |
| 2141 | owrt_ap_set_list_vap(dut, vap_id, "nai_realm", |
| 2142 | "'0,wi-fi.org;mail.example.com,21[2:4][5:7]'"); |
| 2143 | } else if (dut->ap_nai_realm_list == 7) { |
| 2144 | owrt_ap_set_list_vap(dut, vap_id, "nai_realm", |
| 2145 | "'0,wi-fi.org,13[5:6]'"); |
| 2146 | owrt_ap_set_list_vap(dut, vap_id, "nai_realm", |
| 2147 | "'0,wi-fi.org,21[2:4][5:7]'"); |
| 2148 | } |
| 2149 | |
| 2150 | if (dut->ap_domain_name_list[0]) |
| 2151 | owrt_ap_set_list_vap(dut, vap_id, "domain_name", |
| 2152 | dut->ap_domain_name_list); |
| 2153 | |
| 2154 | if (dut->ap_ip_addr_type_avail) |
| 2155 | owrt_ap_set_vap(dut, vap_id, "ipaddr_type_availability", |
| 2156 | "'0c'"); |
| 2157 | |
| 2158 | temp = buf; |
| 2159 | |
| 2160 | *temp++ = '\''; |
| 2161 | |
| 2162 | for (i = 0; dut->ap_plmn_mcc[i][0] && dut->ap_plmn_mnc[i][0]; i++) { |
| 2163 | if (i) |
| 2164 | *temp++ = ';'; |
| 2165 | |
| 2166 | snprintf(temp, |
| 2167 | sizeof(dut->ap_plmn_mcc[i]) + |
| 2168 | sizeof(dut->ap_plmn_mnc[i]) + 1, |
| 2169 | "%s,%s", |
| 2170 | dut->ap_plmn_mcc[i], |
| 2171 | dut->ap_plmn_mnc[i]); |
| 2172 | |
| 2173 | temp += strlen(dut->ap_plmn_mcc[i]) + |
| 2174 | strlen(dut->ap_plmn_mnc[i]) + 1; |
| 2175 | } |
| 2176 | |
| 2177 | *temp++ = '\''; |
| 2178 | *temp++ = '\0'; |
| 2179 | |
| 2180 | if (i) |
| 2181 | owrt_ap_set_vap(dut, vap_id, "anqp_3gpp_cell_net", buf); |
| 2182 | |
| 2183 | if (dut->ap_qos_map_set == 1) |
| 2184 | owrt_ap_set_vap(dut, vap_id, "qos_map_set", QOS_MAP_SET_1); |
| 2185 | else if (dut->ap_qos_map_set == 2) |
| 2186 | owrt_ap_set_vap(dut, vap_id, "qos_map_set", QOS_MAP_SET_2); |
| 2187 | |
| 2188 | /* Proxy-ARP */ |
| 2189 | snprintf(buf, sizeof(buf), "%d", dut->ap_proxy_arp); |
| 2190 | owrt_ap_set_vap(dut, vap_id, "proxyarp", buf); |
| 2191 | |
| 2192 | /* DGAF */ |
| 2193 | snprintf(buf, sizeof(buf), "%d", dut->ap_dgaf_disable); |
| 2194 | /* parse to hostapd */ |
| 2195 | owrt_ap_set_vap(dut, vap_id, "disable_dgaf", buf); |
| 2196 | /* parse to wifi driver */ |
| 2197 | owrt_ap_set_vap(dut, vap_id, "dgaf_disable", buf); |
| 2198 | |
| 2199 | /* HCBSSLoad */ |
| 2200 | if (dut->ap_bss_load) { |
| 2201 | unsigned int bssload = 0; |
| 2202 | |
| 2203 | if (dut->ap_bss_load == 1) { |
| 2204 | /* STA count: 1, CU: 50, AAC: 65535 */ |
| 2205 | bssload = 0x0132ffff; |
| 2206 | } else if (dut->ap_bss_load == 2) { |
| 2207 | /* STA count: 1, CU: 200, AAC: 65535 */ |
| 2208 | bssload = 0x01c8ffff; |
| 2209 | } else if (dut->ap_bss_load == 3) { |
| 2210 | /* STA count: 1, CU: 75, AAC: 65535 */ |
| 2211 | bssload = 0x014bffff; |
| 2212 | } |
| 2213 | |
| 2214 | snprintf(buf, sizeof(buf), "%d", bssload); |
| 2215 | owrt_ap_set_vap(dut, vap_id, "hcbssload", buf); |
| 2216 | } |
| 2217 | |
| 2218 | /* L2TIF */ |
| 2219 | if (dut->ap_l2tif) |
| 2220 | owrt_ap_set_vap(dut, vap_id, "l2tif", "1"); |
| 2221 | |
| 2222 | if (dut->ap_disable_protection == 1) |
| 2223 | owrt_ap_set_vap(dut, vap_id, "enablertscts", "0"); |
| 2224 | |
| 2225 | if (dut->ap_txBF) { |
| 2226 | owrt_ap_set_vap(dut, vap_id, "vhtsubfee", "1"); |
| 2227 | owrt_ap_set_vap(dut, vap_id, "vhtsubfer", "1"); |
| 2228 | } |
| 2229 | |
Mohammed Shafi Shajakhan | 061af00 | 2016-06-02 20:10:54 +0530 | [diff] [blame] | 2230 | if (dut->ap_mu_txBF) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2231 | owrt_ap_set_vap(dut, vap_id, "vhtmubfer", "1"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2232 | |
Vasanthakumar Pandurangan | 2b5431d | 2016-01-12 15:52:48 +0530 | [diff] [blame] | 2233 | if (dut->ap_tx_stbc) { |
| 2234 | /* STBC and beamforming are mutually exclusive features */ |
| 2235 | owrt_ap_set_vap(dut, vap_id, "implicitbf", "0"); |
| 2236 | } |
| 2237 | |
Priyadharshini Gowthaman | 8fb1504 | 2015-11-25 18:27:41 +0530 | [diff] [blame] | 2238 | /* enable dfsmode */ |
| 2239 | snprintf(buf, sizeof(buf), "%d", dut->ap_dfs_mode); |
| 2240 | owrt_ap_set_vap(dut, vap_id, "doth", buf); |
| 2241 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2242 | return 1; |
| 2243 | } |
| 2244 | |
| 2245 | |
| 2246 | static int owrt_ap_post_config_commit(struct sigma_dut *dut, |
| 2247 | struct sigma_conn *conn, |
| 2248 | struct sigma_cmd *cmd) |
| 2249 | { |
| 2250 | if (dut->ap_key_mgmt != AP_OPEN) { |
| 2251 | /* allow some time for hostapd to start before returning |
| 2252 | * success */ |
| 2253 | usleep(500000); |
| 2254 | |
| 2255 | if (run_hostapd_cli(dut, "ping") != 0) { |
| 2256 | send_resp(dut, conn, SIGMA_ERROR, |
| 2257 | "errorCode,Failed to talk to hostapd"); |
| 2258 | return 0; |
| 2259 | } |
| 2260 | } |
| 2261 | |
| 2262 | if (get_openwrt_driver_type() == OPENWRT_DRIVER_ATHEROS) |
| 2263 | ath_ap_set_params(dut); |
| 2264 | |
| 2265 | /* Send response */ |
| 2266 | return 1; |
| 2267 | } |
| 2268 | |
| 2269 | |
| 2270 | static int cmd_owrt_ap_config_commit(struct sigma_dut *dut, |
| 2271 | struct sigma_conn *conn, |
| 2272 | struct sigma_cmd *cmd) |
| 2273 | { |
| 2274 | /* Stop the AP */ |
| 2275 | run_system(dut, "wifi down"); |
| 2276 | |
| 2277 | /* Reset the wireless configuration */ |
Mohammed Shafi Shajakhan | f789f82 | 2016-04-07 18:53:16 +0530 | [diff] [blame] | 2278 | run_system(dut, "rm -rf /etc/config/wireless"); |
| 2279 | switch (get_openwrt_driver_type()) { |
| 2280 | case OPENWRT_DRIVER_ATHEROS: |
| 2281 | run_system(dut, "wifi detect qcawifi > /etc/config/wireless"); |
| 2282 | break; |
| 2283 | default: |
| 2284 | run_system(dut, "wifi detect > /etc/config/wireless"); |
| 2285 | break; |
| 2286 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2287 | |
| 2288 | /* Configure Radio & VAP, commit the config */ |
| 2289 | owrt_ap_config_radio(dut); |
| 2290 | owrt_ap_config_vap(dut); |
| 2291 | run_system(dut, "uci commit"); |
| 2292 | |
| 2293 | /* Start AP */ |
| 2294 | run_system(dut, "wifi up"); |
| 2295 | |
| 2296 | return owrt_ap_post_config_commit(dut, conn, cmd); |
| 2297 | } |
| 2298 | |
| 2299 | |
| 2300 | static void cmd_owrt_ap_hs2_reset(struct sigma_dut *dut) |
| 2301 | { |
| 2302 | unsigned char bssid[6]; |
| 2303 | char buf[100]; |
| 2304 | char *ifname, *radio_name; |
| 2305 | int vap_id = 0; |
| 2306 | |
| 2307 | if (sigma_radio_ifname[0] && |
| 2308 | strcmp(sigma_radio_ifname[0], "wifi2") == 0) { |
| 2309 | ifname = "ath2"; |
| 2310 | radio_name = "wifi2"; |
| 2311 | vap_id = 2; |
| 2312 | } else if (sigma_radio_ifname[0] && |
| 2313 | strcmp(sigma_radio_ifname[0], "wifi1") == 0) { |
| 2314 | ifname = "ath1"; |
| 2315 | radio_name = "wifi1"; |
| 2316 | vap_id = 1; |
| 2317 | } else { |
| 2318 | ifname = "ath0"; |
| 2319 | radio_name = "wifi0"; |
| 2320 | vap_id = 0; |
| 2321 | } |
| 2322 | |
| 2323 | if (!get_hwaddr(ifname, bssid)) { |
| 2324 | snprintf(buf, sizeof(buf), "%s", bssid); |
| 2325 | owrt_ap_set_vap(dut, vap_id, "hessid", buf); |
| 2326 | snprintf(dut->ap_hessid, sizeof(dut->ap_hessid), |
| 2327 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 2328 | bssid[0], bssid[1], bssid[2], bssid[3], |
| 2329 | bssid[4], bssid[5]); |
| 2330 | } else { |
| 2331 | if (!get_hwaddr(radio_name, bssid)) { |
| 2332 | snprintf(buf, sizeof(buf), "%s", dut->ap_hessid); |
| 2333 | owrt_ap_set_vap(dut, vap_id, "hessid", buf); |
| 2334 | snprintf(dut->ap_hessid, sizeof(dut->ap_hessid), |
| 2335 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 2336 | bssid[0], bssid[1], bssid[2], bssid[3], |
| 2337 | bssid[4], bssid[5]); |
| 2338 | } else { |
| 2339 | /* Select & enable/disable radios */ |
| 2340 | if (sigma_radio_ifname[0] && |
| 2341 | strcmp(sigma_radio_ifname[0], "wifi2") == 0) { |
| 2342 | /* We want to use wifi2 */ |
| 2343 | owrt_ap_set_radio(dut, 0, "disabled", "1"); |
| 2344 | owrt_ap_set_radio(dut, 1, "disabled", "1"); |
| 2345 | owrt_ap_set_radio(dut, 2, "disabled", "0"); |
| 2346 | owrt_ap_set_vap(dut, vap_id, "device", "wifi2"); |
| 2347 | } else if (sigma_radio_ifname[0] && |
| 2348 | strcmp(sigma_radio_ifname[0], "wifi1") == 0) { |
| 2349 | /* We want to use wifi1 */ |
| 2350 | owrt_ap_set_radio(dut, 0, "disabled", "1"); |
| 2351 | owrt_ap_set_radio(dut, 1, "disabled", "0"); |
| 2352 | owrt_ap_set_vap(dut, vap_id, "device", "wifi1"); |
| 2353 | } else { |
| 2354 | /* We want to use wifi0 */ |
| 2355 | owrt_ap_set_radio(dut, 0, "disabled", "0"); |
| 2356 | owrt_ap_set_radio(dut, 1, "disabled", "1"); |
| 2357 | owrt_ap_set_vap(dut, vap_id, "device", "wifi0"); |
| 2358 | } |
| 2359 | |
| 2360 | run_system(dut, "uci commit"); |
| 2361 | run_system(dut, "wifi up"); |
| 2362 | |
| 2363 | if (!get_hwaddr(radio_name, bssid)) { |
| 2364 | snprintf(buf, sizeof(buf), "%s", |
| 2365 | dut->ap_hessid); |
| 2366 | owrt_ap_set_vap(dut, vap_id, "hessid", buf); |
| 2367 | snprintf(dut->ap_hessid, sizeof(dut->ap_hessid), |
| 2368 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 2369 | bssid[0], bssid[1], bssid[2], bssid[3], |
| 2370 | bssid[4], bssid[5]); |
| 2371 | } |
| 2372 | } |
| 2373 | } |
| 2374 | } |
| 2375 | |
| 2376 | |
| 2377 | static int cmd_ap_reboot(struct sigma_dut *dut, struct sigma_conn *conn, |
| 2378 | struct sigma_cmd *cmd) |
| 2379 | { |
| 2380 | switch (get_driver_type()) { |
| 2381 | case DRIVER_ATHEROS: |
| 2382 | run_system(dut, "apdown"); |
| 2383 | sleep(1); |
| 2384 | run_system(dut, "reboot"); |
| 2385 | break; |
| 2386 | case DRIVER_OPENWRT: |
| 2387 | run_system(dut, "wifi down"); |
| 2388 | sleep(1); |
| 2389 | run_system(dut, "reboot"); |
| 2390 | break; |
| 2391 | default: |
| 2392 | sigma_dut_print(dut, DUT_MSG_INFO, "Ignore ap_reboot command"); |
| 2393 | break; |
| 2394 | } |
| 2395 | |
| 2396 | return 1; |
| 2397 | } |
| 2398 | |
| 2399 | |
| 2400 | int ascii2hexstr(const char *str, char *hex) |
| 2401 | { |
| 2402 | int i, length; |
| 2403 | |
| 2404 | length = strlen(str); |
| 2405 | |
| 2406 | for (i = 0; i < length; i++) |
| 2407 | snprintf(hex + i * 2, 3, "%X", str[i]); |
| 2408 | |
| 2409 | hex[length * 2] = '\0'; |
| 2410 | return 1; |
| 2411 | } |
| 2412 | |
| 2413 | |
| 2414 | static int kill_process(struct sigma_dut *dut, char *proc_name, |
| 2415 | unsigned char is_proc_instance_one, int sig) |
| 2416 | { |
| 2417 | #ifdef __linux__ |
| 2418 | struct dirent *dp, *dp_in; |
| 2419 | const char *direc = "/proc/"; |
| 2420 | char buf[100]; |
| 2421 | DIR *dir = opendir(direc); |
| 2422 | DIR *dir_in; |
| 2423 | FILE *fp; |
| 2424 | char *pid, *temp; |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 2425 | char *saveptr; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2426 | |
| 2427 | if (dir == NULL) |
| 2428 | return -1; |
| 2429 | |
| 2430 | while ((dp = readdir(dir)) != NULL) { |
| 2431 | if (dp->d_type != DT_DIR) |
| 2432 | continue; |
| 2433 | |
| 2434 | snprintf(buf, sizeof(buf), "%s%s", direc, dp->d_name); |
| 2435 | dir_in = opendir(buf); |
| 2436 | if (dir_in == NULL) |
| 2437 | continue; |
| 2438 | dp_in = readdir(dir_in); |
| 2439 | closedir(dir_in); |
| 2440 | if (dp_in == NULL) |
| 2441 | continue; |
| 2442 | snprintf(buf, sizeof(buf), "%s%s/stat", direc, dp->d_name); |
| 2443 | fp = fopen(buf, "r"); |
| 2444 | if (fp == NULL) |
| 2445 | continue; |
| 2446 | if (fgets(buf, 100, fp) == NULL) |
| 2447 | buf[0] = '\0'; |
| 2448 | fclose(fp); |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 2449 | pid = strtok_r(buf, " ", &saveptr); |
| 2450 | temp = strtok_r(NULL, " ", &saveptr); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2451 | if (pid && temp && |
| 2452 | strncmp(temp, proc_name, strlen(proc_name)) == 0) { |
| 2453 | sigma_dut_print(dut, DUT_MSG_INFO, |
| 2454 | "killing %s process with PID %s", |
| 2455 | proc_name, pid); |
| 2456 | snprintf(buf, sizeof(buf), "kill -%d %d", sig, |
| 2457 | atoi(pid)); |
| 2458 | run_system(dut, buf); |
| 2459 | if (is_proc_instance_one) |
| 2460 | break; |
| 2461 | } |
| 2462 | } |
| 2463 | |
| 2464 | closedir(dir); |
| 2465 | |
| 2466 | return 0; |
| 2467 | #else /* __linux__ */ |
| 2468 | return -1; |
| 2469 | #endif /* __linux__ */ |
| 2470 | } |
| 2471 | |
| 2472 | |
| 2473 | static int run_ndc(struct sigma_dut *dut, char *buf) |
| 2474 | { |
| 2475 | sigma_dut_print(dut, DUT_MSG_INFO, "CMD NDC:: %s", buf); |
| 2476 | sleep(2); |
| 2477 | return run_system(dut, buf); |
| 2478 | } |
| 2479 | |
| 2480 | |
| 2481 | static int sigma_write_cfg(struct sigma_dut *dut, const char *pfile, |
| 2482 | const char *field, const char *value) |
| 2483 | { |
| 2484 | FILE *fcfg, *ftmp; |
| 2485 | char buf[MAX_CONF_LINE_LEN + 1]; |
| 2486 | int len, found = 0, res; |
| 2487 | |
| 2488 | /* Open the configuration file */ |
| 2489 | fcfg = fopen(pfile, "r"); |
| 2490 | if (!fcfg) { |
| 2491 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 2492 | "Failed to open hostapd conf file"); |
| 2493 | return -1; |
| 2494 | } |
| 2495 | |
| 2496 | snprintf(buf, sizeof(buf), "%s~", pfile); |
| 2497 | /* Open a temporary file */ |
| 2498 | ftmp = fopen(buf, "w+"); |
| 2499 | if (!ftmp) { |
| 2500 | fclose(fcfg); |
| 2501 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 2502 | "Failed to open temp buf"); |
| 2503 | return -1; |
| 2504 | } |
| 2505 | |
| 2506 | /* Read the values from the configuration file */ |
| 2507 | len = strlen(field); |
| 2508 | while (fgets(buf, MAX_CONF_LINE_LEN, fcfg)) { |
| 2509 | char *pline = buf; |
| 2510 | |
| 2511 | /* commented line */ |
| 2512 | if (buf[0] == '#') |
| 2513 | pline++; |
| 2514 | |
| 2515 | /* Identify the configuration parameter to be updated */ |
| 2516 | if (!found && strncmp(pline, field, len) == 0 && |
| 2517 | pline[len] == '=') { |
| 2518 | snprintf(buf, sizeof(buf), "%s=%s\n", field, value); |
| 2519 | found = 1; |
| 2520 | sigma_dut_print(dut, DUT_MSG_INFO, |
| 2521 | "Updated hostapd conf file"); |
| 2522 | } |
| 2523 | |
| 2524 | fprintf(ftmp, "%s", buf); |
| 2525 | } |
| 2526 | |
| 2527 | if (!found) { |
| 2528 | /* Configuration line not found */ |
| 2529 | /* Add the new line at the end of file */ |
| 2530 | fprintf(ftmp, "%s=%s\n", field, value); |
| 2531 | sigma_dut_print(dut, DUT_MSG_INFO, |
| 2532 | "Adding a new line in hostapd conf file"); |
| 2533 | } |
| 2534 | |
| 2535 | fclose(fcfg); |
| 2536 | fclose(ftmp); |
| 2537 | |
| 2538 | snprintf(buf, sizeof(buf), "%s~", pfile); |
| 2539 | |
| 2540 | /* Restore the updated configuration file */ |
| 2541 | res = rename(buf, pfile); |
| 2542 | |
| 2543 | /* Remove the temporary file. Ignore the return value */ |
| 2544 | unlink(buf); |
| 2545 | |
| 2546 | /* chmod is needed because open() may not set permissions properly |
| 2547 | * depending on the current umask */ |
| 2548 | if (chmod(pfile, 0660) < 0) { |
| 2549 | unlink(pfile); |
| 2550 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 2551 | "Error changing permissions"); |
| 2552 | return -1; |
| 2553 | } |
| 2554 | |
| 2555 | if (res < 0) { |
| 2556 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 2557 | "Error restoring conf file"); |
| 2558 | return -1; |
| 2559 | } |
| 2560 | |
| 2561 | return 0; |
| 2562 | } |
| 2563 | |
| 2564 | |
| 2565 | static int cmd_wcn_ap_config_commit(struct sigma_dut *dut, |
| 2566 | struct sigma_conn *conn, |
| 2567 | struct sigma_cmd *cmd) |
| 2568 | { |
| 2569 | char buf[100]; |
| 2570 | struct stat s; |
| 2571 | int num_tries = 0, ret; |
| 2572 | |
| 2573 | kill_process(dut, "(netd)", 1, SIGKILL); |
| 2574 | |
| 2575 | while (num_tries < 10) { |
| 2576 | ret = run_ndc(dut, "ndc softap stopap"); |
| 2577 | num_tries++; |
| 2578 | if (WIFEXITED(ret)) |
| 2579 | ret = WEXITSTATUS(ret); |
| 2580 | /* On success, NDC exits with 0 */ |
| 2581 | if (ret == 0) |
| 2582 | break; |
| 2583 | sigma_dut_print(dut, DUT_MSG_INFO, |
| 2584 | "Try No. %d: ndc softap stopap failed, exit code %d", |
| 2585 | num_tries, ret); |
| 2586 | } |
| 2587 | |
| 2588 | if (ret != 0) |
| 2589 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 2590 | "ndc softap stopap command failed for 10 times - giving up"); |
| 2591 | |
| 2592 | #ifdef ANDROID |
| 2593 | /* Unload/Load driver to cleanup the state of the driver */ |
| 2594 | wifi_unload_driver(); |
| 2595 | wifi_load_driver(); |
| 2596 | #else /* ANDROID */ |
| 2597 | run_ndc(dut, "ndc softap qccmd set enable_softap=0"); |
| 2598 | run_ndc(dut, "ndc softap qccmd set enable_softap=1"); |
| 2599 | #endif /* ANDROID */ |
| 2600 | |
| 2601 | switch (dut->ap_mode) { |
| 2602 | case AP_11g: |
| 2603 | run_ndc(dut, "ndc softap qccmd set hw_mode=g-only"); |
| 2604 | break; |
| 2605 | case AP_11b: |
| 2606 | run_ndc(dut, "ndc softap qccmd set hw_mode=b-only"); |
| 2607 | break; |
| 2608 | case AP_11ng: |
| 2609 | run_ndc(dut, "ndc softap qccmd set hw_mode=n"); |
| 2610 | break; |
| 2611 | case AP_11a: |
| 2612 | run_ndc(dut, "ndc softap qccmd set hw_mode=a-only"); |
| 2613 | break; |
| 2614 | case AP_11na: |
| 2615 | run_ndc(dut, "ndc softap qccmd set hw_mode=n"); |
| 2616 | break; |
| 2617 | case AP_11ac: |
| 2618 | run_ndc(dut, "ndc softap qccmd set hw_mode=ac"); |
| 2619 | break; |
| 2620 | default: |
| 2621 | break; |
| 2622 | } |
| 2623 | |
| 2624 | snprintf(buf, sizeof(buf), "ndc softap qccmd set channel=%d", |
| 2625 | dut->ap_channel); |
| 2626 | run_ndc(dut, buf); |
| 2627 | |
| 2628 | /* |
| 2629 | * ndc doesn't support double quotes as SSID string, so re-write |
| 2630 | * hostapd configuration file to update SSID. |
| 2631 | */ |
| 2632 | if (dut->ap_ssid[0] != '\0') |
| 2633 | sigma_write_cfg(dut, ANDROID_CONFIG_FILE, "ssid", dut->ap_ssid); |
| 2634 | |
| 2635 | switch (dut->ap_key_mgmt) { |
| 2636 | case AP_OPEN: |
| 2637 | if (dut->ap_cipher == AP_WEP) { |
| 2638 | run_ndc(dut, "ndc softap qccmd set security_mode=1"); |
| 2639 | snprintf(buf, sizeof(buf), |
| 2640 | "ndc softap qccmd set wep_key0=%s", |
| 2641 | dut->ap_wepkey); |
| 2642 | run_ndc(dut, buf); |
| 2643 | } else { |
| 2644 | run_ndc(dut, "ndc softap qccmd set security_mode=0"); |
| 2645 | } |
| 2646 | break; |
| 2647 | case AP_WPA2_PSK: |
| 2648 | case AP_WPA2_PSK_MIXED: |
| 2649 | case AP_WPA_PSK: |
| 2650 | if (dut->ap_key_mgmt == AP_WPA2_PSK) |
| 2651 | run_ndc(dut, "ndc softap qccmd set security_mode=3"); |
| 2652 | else if (dut->ap_key_mgmt == AP_WPA2_PSK_MIXED) |
| 2653 | run_ndc(dut, "ndc softap qccmd set security_mode=4"); |
| 2654 | else |
| 2655 | run_ndc(dut, "ndc softap qccmd set security_mode=2"); |
| 2656 | |
| 2657 | /* |
| 2658 | * ndc doesn't support some special characters as passphrase, |
| 2659 | * so re-write hostapd configuration file to update Passphrase. |
| 2660 | */ |
| 2661 | if (dut->ap_passphrase[0] != '\0') |
| 2662 | sigma_write_cfg(dut, ANDROID_CONFIG_FILE, |
| 2663 | "wpa_passphrase", dut->ap_passphrase); |
| 2664 | |
| 2665 | if (dut->ap_cipher == AP_CCMP_TKIP) |
| 2666 | run_ndc(dut, "ndc softap qccmd set wpa_pairwise=" |
| 2667 | "TKIP CCMP"); |
| 2668 | else if (dut->ap_cipher == AP_TKIP) |
| 2669 | run_ndc(dut, "ndc softap qccmd set wpa_pairwise=" |
| 2670 | "TKIP"); |
| 2671 | else |
| 2672 | run_ndc(dut, "ndc softap qccmd set wpa_pairwise=" |
| 2673 | "CCMP &"); |
| 2674 | break; |
| 2675 | case AP_WPA2_EAP: |
| 2676 | case AP_WPA2_EAP_MIXED: |
| 2677 | case AP_WPA_EAP: |
| 2678 | /* Not supported */ |
| 2679 | break; |
| 2680 | } |
| 2681 | |
| 2682 | switch (dut->ap_pmf) { |
| 2683 | case AP_PMF_DISABLED: |
| 2684 | run_ndc(dut, "ndc softap qccmd set ieee80211w=0"); |
| 2685 | break; |
| 2686 | case AP_PMF_OPTIONAL: |
| 2687 | run_ndc(dut, "ndc softap qccmd set ieee80211w=1"); |
| 2688 | if (dut->ap_add_sha256) |
| 2689 | run_ndc(dut, "ndc softap qccmd set wpa_key_mgmt=WPA-PSK WPA-PSK-SHA256"); |
| 2690 | else |
| 2691 | run_ndc(dut, "ndc softap qccmd set wpa_key_mgmt=WPA-PSK"); |
| 2692 | break; |
| 2693 | case AP_PMF_REQUIRED: |
| 2694 | run_ndc(dut, "ndc softap qccmd set ieee80211w=2"); |
| 2695 | run_ndc(dut, "ndc softap qccmd set wpa_key_mgmt=WPA-PSK-SHA256"); |
| 2696 | break; |
| 2697 | } |
| 2698 | |
| 2699 | if (dut->ap_countrycode[0]) { |
| 2700 | snprintf(buf, sizeof(buf), |
| 2701 | "ndc softap qccmd set country_code=%s", |
| 2702 | dut->ap_countrycode); |
| 2703 | run_ndc(dut, buf); |
| 2704 | } |
| 2705 | |
Pradeep Reddy POTTETI | fba27db | 2015-11-20 16:42:22 +0530 | [diff] [blame] | 2706 | if (dut->ap_regulatory_mode == AP_80211D_MODE_ENABLED) |
| 2707 | run_ndc(dut, "ndc softap qccmd set ieee80211d=1"); |
| 2708 | |
| 2709 | if (dut->ap_dfs_mode == AP_DFS_MODE_ENABLED) |
| 2710 | run_ndc(dut, "ndc softap qccmd set ieee80211h=1"); |
| 2711 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2712 | run_ndc(dut, "ndc softap startap"); |
| 2713 | |
| 2714 | snprintf(buf, sizeof(buf), "%s%s", sigma_wpas_ctrl, sigma_main_ifname); |
| 2715 | num_tries = 0; |
| 2716 | while (num_tries < 10 && (ret = stat(buf, &s) != 0)) { |
| 2717 | run_ndc(dut, "ndc softap stopap"); |
| 2718 | run_ndc(dut, "ndc softap startap"); |
| 2719 | num_tries++; |
| 2720 | } |
| 2721 | |
| 2722 | if (num_tries == 10) { |
| 2723 | sigma_dut_print(dut, DUT_MSG_INFO, "Tried 10 times with ctrl " |
| 2724 | "iface %s :: reboot the APDUT", buf); |
| 2725 | return ret; |
| 2726 | } |
| 2727 | |
| 2728 | sigma_dut_print(dut, DUT_MSG_INFO, "setting ip addr %s mask %s", |
| 2729 | ap_inet_addr, ap_inet_mask); |
| 2730 | snprintf(buf, sizeof(buf), "ifconfig %s %s netmask %s up", |
| 2731 | sigma_main_ifname, ap_inet_addr, ap_inet_mask); |
| 2732 | if (system(buf) != 0) { |
| 2733 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 2734 | "Failed to intialize the interface"); |
| 2735 | return -1; |
| 2736 | } |
| 2737 | |
| 2738 | return 1; |
| 2739 | } |
| 2740 | |
| 2741 | |
| 2742 | static int append_hostapd_conf_hs2(struct sigma_dut *dut, FILE *f) |
| 2743 | { |
| 2744 | fprintf(f, "hs20=1\nhs20_deauth_req_timeout=3\n" |
| 2745 | "disable_dgaf=%d\n", dut->ap_dgaf_disable); |
| 2746 | |
| 2747 | if (dut->ap_oper_name) { |
| 2748 | fprintf(f, "hs20_oper_friendly_name=eng:Wi-Fi Alliance\n"); |
| 2749 | fprintf(f, "hs20_oper_friendly_name=chi:Wi-Fi\xe8\x81\x94\xe7\x9b\x9f\n"); |
| 2750 | } |
| 2751 | |
| 2752 | if (dut->ap_wan_metrics == 1) |
| 2753 | fprintf(f, "hs20_wan_metrics=01:2500:384:0:0:10\n"); |
| 2754 | else if (dut->ap_wan_metrics == 2) |
| 2755 | fprintf(f, "hs20_wan_metrics=01:1500:384:20:20:10\n"); |
| 2756 | else if (dut->ap_wan_metrics == 3) |
| 2757 | fprintf(f, "hs20_wan_metrics=01:2000:1000:20:20:10\n"); |
| 2758 | else if (dut->ap_wan_metrics == 4) |
| 2759 | fprintf(f, "hs20_wan_metrics=01:8000:1000:20:20:10\n"); |
| 2760 | else if (dut->ap_wan_metrics == 5) |
| 2761 | fprintf(f, "hs20_wan_metrics=01:9000:5000:20:20:10\n"); |
| 2762 | |
| 2763 | if (dut->ap_conn_capab == 1) { |
| 2764 | fprintf(f, "hs20_conn_capab=1:0:0\n"); |
| 2765 | fprintf(f, "hs20_conn_capab=6:20:1\n"); |
| 2766 | fprintf(f, "hs20_conn_capab=6:22:0\n"); |
| 2767 | fprintf(f, "hs20_conn_capab=6:80:1\n"); |
| 2768 | fprintf(f, "hs20_conn_capab=6:443:1\n"); |
| 2769 | fprintf(f, "hs20_conn_capab=6:1723:0\n"); |
| 2770 | fprintf(f, "hs20_conn_capab=6:5060:0\n"); |
| 2771 | fprintf(f, "hs20_conn_capab=17:500:1\n"); |
| 2772 | fprintf(f, "hs20_conn_capab=17:5060:0\n"); |
| 2773 | fprintf(f, "hs20_conn_capab=17:4500:1\n"); |
| 2774 | fprintf(f, "hs20_conn_capab=50:0:1\n"); |
| 2775 | } else if (dut->ap_conn_capab == 2) { |
| 2776 | fprintf(f, "hs20_conn_capab=6:80:1\n"); |
| 2777 | fprintf(f, "hs20_conn_capab=6:443:1\n"); |
| 2778 | fprintf(f, "hs20_conn_capab=17:5060:1\n"); |
| 2779 | fprintf(f, "hs20_conn_capab=6:5060:1\n"); |
| 2780 | } else if (dut->ap_conn_capab == 3) { |
| 2781 | fprintf(f, "hs20_conn_capab=6:80:1\n"); |
| 2782 | fprintf(f, "hs20_conn_capab=6:443:1\n"); |
| 2783 | } else if (dut->ap_conn_capab == 4) { |
| 2784 | fprintf(f, "hs20_conn_capab=6:80:1\n"); |
| 2785 | fprintf(f, "hs20_conn_capab=6:443:1\n"); |
| 2786 | fprintf(f, "hs20_conn_capab=6:5060:1\n"); |
| 2787 | fprintf(f, "hs20_conn_capab=17:5060:1\n"); |
| 2788 | } |
| 2789 | |
| 2790 | if (dut->ap_oper_class == 1) |
| 2791 | fprintf(f, "hs20_operating_class=51\n"); |
| 2792 | else if (dut->ap_oper_class == 2) |
| 2793 | fprintf(f, "hs20_operating_class=73\n"); |
| 2794 | else if (dut->ap_oper_class == 3) |
| 2795 | fprintf(f, "hs20_operating_class=5173\n"); |
| 2796 | |
| 2797 | if (dut->ap_osu_provider_list) { |
| 2798 | char *osu_friendly_name = NULL; |
| 2799 | char *osu_icon = NULL; |
| 2800 | char *osu_ssid = NULL; |
| 2801 | char *osu_nai = NULL; |
| 2802 | char *osu_service_desc = NULL; |
| 2803 | char *hs20_icon_filename = NULL; |
| 2804 | char hs20_icon[150]; |
| 2805 | int osu_method; |
| 2806 | |
| 2807 | hs20_icon_filename = "icon_red_zxx.png"; |
| 2808 | if (dut->ap_osu_icon_tag == 2) |
| 2809 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 2810 | snprintf(hs20_icon, sizeof(hs20_icon), |
| 2811 | "128:61:zxx:image/png:icon_red_zxx.png:/etc/ath/%s", |
| 2812 | hs20_icon_filename); |
| 2813 | osu_icon = "icon_red_zxx.png"; |
| 2814 | osu_ssid = "OSU"; |
| 2815 | osu_friendly_name = "kor:SP 빨강 테스트 전용"; |
| 2816 | osu_service_desc = "kor:테스트 목적으로 무료 서비스"; |
| 2817 | osu_method = (dut->ap_osu_method[0] == 0xFF) ? 1 : dut->ap_osu_method[0]; |
| 2818 | |
| 2819 | if (strlen(dut->ap_osu_server_uri[0])) |
| 2820 | fprintf(f, "osu_server_uri=%s\n", dut->ap_osu_server_uri[0]); |
| 2821 | else |
| 2822 | fprintf(f, "osu_server_uri=https://osu-server.r2-testbed.wi-fi.org/\n"); |
| 2823 | |
| 2824 | switch (dut->ap_osu_provider_list) { |
| 2825 | case 1: |
| 2826 | case 101: |
| 2827 | fprintf(f, "osu_friendly_name=eng:SP Red Test Only\n"); |
| 2828 | fprintf(f, "osu_service_desc=eng:Free service for test purpose\n"); |
| 2829 | hs20_icon_filename = "icon_red_eng.png"; |
| 2830 | if (dut->ap_osu_icon_tag == 2) |
| 2831 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 2832 | fprintf(f, "hs20_icon=160:76:eng:image/png:icon_red_eng.png:/etc/ath/%s\n", |
| 2833 | hs20_icon_filename); |
| 2834 | fprintf(f, "osu_icon=icon_red_eng.png\n"); |
| 2835 | break; |
| 2836 | case 2: |
| 2837 | case 102: |
| 2838 | fprintf(f, "osu_friendly_name=eng:Wireless Broadband Alliance\n"); |
| 2839 | fprintf(f, "osu_service_desc=eng:Free service for test purpose\n"); |
| 2840 | hs20_icon_filename = "icon_orange_zxx.png"; |
| 2841 | if (dut->ap_osu_icon_tag == 2) |
| 2842 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 2843 | snprintf(hs20_icon, sizeof(hs20_icon), |
| 2844 | "128:61:zxx:image/png:icon_orange_zxx.png:/etc/ath/%s", |
| 2845 | hs20_icon_filename); |
| 2846 | osu_icon = "icon_orange_zxx.png"; |
| 2847 | osu_friendly_name = "kor:와이어리스 브로드밴드 얼라이언스"; |
| 2848 | break; |
| 2849 | case 3: |
| 2850 | case 103: |
| 2851 | osu_friendly_name = "spa:SP Red Test Only"; |
| 2852 | osu_service_desc = "spa:Free service for test purpose"; |
| 2853 | break; |
| 2854 | case 4: |
| 2855 | case 104: |
| 2856 | fprintf(f, "osu_friendly_name=eng:SP Orange Test Only\n"); |
| 2857 | fprintf(f, "osu_service_desc=eng:Free service for test purpose\n"); |
| 2858 | hs20_icon_filename = "icon_orange_eng.png"; |
| 2859 | if (dut->ap_osu_icon_tag == 2) |
| 2860 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 2861 | fprintf(f, "hs20_icon=160:76:eng:image/png:icon_orange_eng.png:/etc/ath/%s\n", |
| 2862 | hs20_icon_filename); |
| 2863 | fprintf(f, "osu_icon=icon_orange_eng.png\n"); |
| 2864 | osu_friendly_name = "kor:SP 오렌지 테스트 전용"; |
| 2865 | |
| 2866 | hs20_icon_filename = "icon_orange_zxx.png"; |
| 2867 | if (dut->ap_osu_icon_tag == 2) |
| 2868 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 2869 | snprintf(hs20_icon, sizeof(hs20_icon), |
| 2870 | "128:61:zxx:image/png:icon_orange_zxx.png:/etc/ath/%s", |
| 2871 | hs20_icon_filename); |
| 2872 | osu_icon = "icon_orange_zxx.png"; |
| 2873 | break; |
| 2874 | case 5: |
| 2875 | case 105: |
| 2876 | fprintf(f, "osu_friendly_name=eng:SP Orange Test Only\n"); |
| 2877 | fprintf(f, "osu_service_desc=eng:Free service for test purpose\n"); |
| 2878 | osu_friendly_name = "kor:SP 오렌지 테스트 전용"; |
| 2879 | hs20_icon_filename = "icon_orange_zxx.png"; |
| 2880 | if (dut->ap_osu_icon_tag == 2) |
| 2881 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 2882 | snprintf(hs20_icon, sizeof(hs20_icon), |
| 2883 | "128:61:zxx:image/png:icon_orange_zxx.png:/etc/ath/%s", |
| 2884 | hs20_icon_filename); |
| 2885 | osu_icon = "icon_orange_zxx.png"; |
| 2886 | break; |
| 2887 | case 6: |
| 2888 | case 106: |
| 2889 | fprintf(f, "osu_friendly_name=eng:SP Green Test Only\n"); |
| 2890 | fprintf(f, "osu_friendly_name=kor:SP 초록 테스트 전용\n"); |
| 2891 | hs20_icon_filename = "icon_green_zxx.png"; |
| 2892 | if (dut->ap_osu_icon_tag == 2) |
| 2893 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 2894 | fprintf(f, "hs20_icon=128:61:zxx:image/png:icon_green_zxx.png:/etc/ath/%s\n", |
| 2895 | hs20_icon_filename); |
| 2896 | fprintf(f, "osu_icon=icon_green_zxx.png\n"); |
| 2897 | osu_method = (dut->ap_osu_method[0] == 0xFF) ? 0 : dut->ap_osu_method[0]; |
| 2898 | fprintf(f, "osu_method_list=%d\n", osu_method); |
| 2899 | |
| 2900 | if (strlen(dut->ap_osu_server_uri[1])) |
| 2901 | fprintf(f, "osu_server_uri=%s\n", dut->ap_osu_server_uri[1]); |
| 2902 | else |
| 2903 | fprintf(f, "osu_server_uri=https://osu-server.r2-testbed.wi-fi.org/\n"); |
| 2904 | fprintf(f, "osu_friendly_name=eng:SP Orange Test Only\n"); |
| 2905 | hs20_icon_filename = "icon_orange_zxx.png"; |
| 2906 | if (dut->ap_osu_icon_tag == 2) |
| 2907 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 2908 | snprintf(hs20_icon, sizeof(hs20_icon), |
| 2909 | "128:61:zxx:image/png:icon_orange_zxx.png:/etc/ath/%s", |
| 2910 | hs20_icon_filename); |
| 2911 | osu_icon = "icon_orange_zxx.png"; |
| 2912 | osu_friendly_name = "kor:SP 오렌지 테스트 전용"; |
| 2913 | osu_method = (dut->ap_osu_method[1] == 0xFF) ? 0 : dut->ap_osu_method[1]; |
| 2914 | osu_service_desc = NULL; |
| 2915 | break; |
| 2916 | case 7: |
| 2917 | case 107: |
| 2918 | fprintf(f, "osu_friendly_name=eng:SP Green Test Only\n"); |
| 2919 | fprintf(f, "osu_service_desc=eng:Free service for test purpose\n"); |
| 2920 | hs20_icon_filename = "icon_green_eng.png"; |
| 2921 | if (dut->ap_osu_icon_tag == 2) |
| 2922 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 2923 | fprintf(f, "hs20_icon=160:76:eng:image/png:icon_green_eng.png:/etc/ath/%s\n", |
| 2924 | hs20_icon_filename); |
| 2925 | fprintf(f, "osu_icon=icon_green_eng.png\n"); |
| 2926 | osu_friendly_name = "kor:SP 초록 테스트 전용"; |
| 2927 | |
| 2928 | hs20_icon_filename = "icon_green_zxx.png"; |
| 2929 | if (dut->ap_osu_icon_tag == 2) |
| 2930 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 2931 | snprintf(hs20_icon, sizeof(hs20_icon), |
| 2932 | "128:61:zxx:image/png:icon_green_zxx.png:/etc/ath/%s", |
| 2933 | hs20_icon_filename); |
| 2934 | osu_icon = "icon_green_zxx.png"; |
| 2935 | break; |
| 2936 | case 8: |
| 2937 | case 108: |
| 2938 | fprintf(f, "osu_friendly_name=eng:SP Red Test Only\n"); |
| 2939 | fprintf(f, "osu_service_desc=eng:Free service for test purpose\n"); |
| 2940 | osu_ssid = "OSU-Encrypted"; |
| 2941 | osu_nai = "anonymous@hotspot.net"; |
| 2942 | break; |
| 2943 | case 9: |
| 2944 | case 109: |
| 2945 | osu_ssid = "OSU-OSEN"; |
| 2946 | osu_nai = "test-anonymous@wi-fi.org"; |
| 2947 | osu_friendly_name = "eng:SP Orange Test Only"; |
| 2948 | hs20_icon_filename = "icon_orange_zxx.png"; |
| 2949 | if (dut->ap_osu_icon_tag == 2) |
| 2950 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; |
| 2951 | snprintf(hs20_icon, sizeof(hs20_icon), |
| 2952 | "128:61:zxx:image/png:icon_orange_zxx.png:/etc/ath/%s", |
| 2953 | hs20_icon_filename); |
| 2954 | osu_icon = "icon_orange_zxx.png"; |
| 2955 | osu_method = (dut->ap_osu_method[0] == 0xFF) ? 1 : dut->ap_osu_method[0]; |
| 2956 | osu_service_desc = NULL; |
| 2957 | break; |
| 2958 | default: |
| 2959 | break; |
| 2960 | } |
| 2961 | |
| 2962 | if (strlen(dut->ap_osu_ssid)) { |
| 2963 | if (strcmp(dut->ap2_ssid, dut->ap_osu_ssid) && |
| 2964 | strcmp(dut->ap2_ssid, osu_ssid)) { |
| 2965 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 2966 | "OSU_SSID and " |
| 2967 | "WLAN_TAG2 SSID differ"); |
| 2968 | return -2; |
| 2969 | } |
| 2970 | fprintf(f, "osu_ssid=\"%s\"\n", dut->ap_osu_ssid); |
| 2971 | } else |
| 2972 | fprintf(f, "osu_ssid=\"%s\"\n", osu_ssid); |
| 2973 | |
| 2974 | |
| 2975 | if (osu_friendly_name) |
| 2976 | fprintf(f, "osu_friendly_name=%s\n", osu_friendly_name); |
| 2977 | |
| 2978 | if (osu_service_desc) |
| 2979 | fprintf(f, "osu_service_desc=%s\n", osu_service_desc); |
| 2980 | |
| 2981 | if (osu_nai) |
| 2982 | fprintf(f, "osu_nai=%s\n", osu_nai); |
| 2983 | |
| 2984 | fprintf(f, "hs20_icon=%s\n", hs20_icon); |
| 2985 | |
| 2986 | if (osu_icon) |
| 2987 | fprintf(f, "osu_icon=%s\n", osu_icon); |
| 2988 | |
| 2989 | if (dut->ap_osu_provider_list > 100) |
| 2990 | fprintf(f, "osu_method_list=0\n"); |
| 2991 | else |
| 2992 | fprintf(f, "osu_method_list=%d\n", osu_method); |
| 2993 | } |
| 2994 | |
| 2995 | return 0; |
| 2996 | } |
| 2997 | |
| 2998 | |
| 2999 | static void write_ap_roaming_cons(FILE *f, const char *list) |
| 3000 | { |
| 3001 | char *buf, *pos, *end; |
| 3002 | |
| 3003 | if (list == NULL || list[0] == '\0') |
| 3004 | return; |
| 3005 | |
| 3006 | buf = strdup(list); |
| 3007 | if (buf == NULL) |
| 3008 | return; |
| 3009 | |
| 3010 | pos = buf; |
| 3011 | while (pos && *pos) { |
| 3012 | end = strchr(pos, ';'); |
| 3013 | if (end) |
| 3014 | *end++ = '\0'; |
| 3015 | fprintf(f, "roaming_consortium=%s\n", pos); |
| 3016 | pos = end; |
| 3017 | } |
| 3018 | |
| 3019 | free(buf); |
| 3020 | } |
| 3021 | |
| 3022 | |
| 3023 | static int append_hostapd_conf_interworking(struct sigma_dut *dut, FILE *f) |
| 3024 | { |
| 3025 | int i; |
| 3026 | char buf[100], *temp; |
| 3027 | |
| 3028 | if (dut->ap_gas_cb_delay > 0) |
| 3029 | fprintf(f, "gas_comeback_delay=%d\n", |
| 3030 | dut->ap_gas_cb_delay); |
| 3031 | |
| 3032 | fprintf(f, "interworking=1\n" |
| 3033 | "access_network_type=%d\n" |
| 3034 | "internet=%d\n" |
| 3035 | "asra=0\n" |
| 3036 | "esr=0\n" |
| 3037 | "uesa=0\n" |
| 3038 | "venue_group=%d\n" |
| 3039 | "venue_type=%d\n", |
| 3040 | dut->ap_access_net_type, |
| 3041 | dut->ap_internet, |
| 3042 | dut->ap_venue_group, |
| 3043 | dut->ap_venue_type); |
| 3044 | if (dut->ap_hessid[0]) |
| 3045 | fprintf(f, "hessid=%s\n", dut->ap_hessid); |
| 3046 | |
| 3047 | write_ap_roaming_cons(f, dut->ap_roaming_cons); |
| 3048 | |
| 3049 | if (dut->ap_venue_name) { |
| 3050 | fprintf(f, "venue_name=P\"eng:Wi-Fi Alliance\\n2989 Copper Road\\nSanta Clara, CA 95051, USA\"\n"); |
| 3051 | fprintf(f, "venue_name=%s\n", ANQP_VENUE_NAME_1_CHI); |
| 3052 | } |
| 3053 | |
| 3054 | if (dut->ap_net_auth_type == 1) |
| 3055 | fprintf(f, "network_auth_type=00https://tandc-server.wi-fi.org\n"); |
| 3056 | else if (dut->ap_net_auth_type == 2) |
| 3057 | fprintf(f, "network_auth_type=01\n"); |
| 3058 | |
| 3059 | if (dut->ap_nai_realm_list == 1) { |
| 3060 | fprintf(f, "nai_realm=0,mail.example.com;cisco.com;wi-fi.org,21[2:4][5:7]\n"); |
| 3061 | fprintf(f, "nai_realm=0,wi-fi.org;example.com,13[5:6]\n"); |
| 3062 | } else if (dut->ap_nai_realm_list == 2) { |
| 3063 | fprintf(f, "nai_realm=0,wi-fi.org,21[2:4][5:7]\n"); |
| 3064 | } else if (dut->ap_nai_realm_list == 3) { |
| 3065 | fprintf(f, "nai_realm=0,cisco.com;wi-fi.org,21[2:4][5:7]\n"); |
| 3066 | fprintf(f, "nai_realm=0,wi-fi.org;example.com,13[5:6]\n"); |
| 3067 | } else if (dut->ap_nai_realm_list == 4) { |
| 3068 | fprintf(f, "nai_realm=0,mail.example.com,21[2:4][5:7],13[5:6]\n"); |
| 3069 | } else if (dut->ap_nai_realm_list == 5) { |
| 3070 | fprintf(f, "nai_realm=0,wi-fi.org;ruckuswireless.com,21[2:4][5:7]\n"); |
| 3071 | } else if (dut->ap_nai_realm_list == 6) { |
| 3072 | fprintf(f, "nai_realm=0,wi-fi.org;mail.example.com,21[2:4][5:7]\n"); |
| 3073 | } else if (dut->ap_nai_realm_list == 7) { |
| 3074 | fprintf(f, "nai_realm=0,wi-fi.org,13[5:6]\n"); |
| 3075 | fprintf(f, "nai_realm=0,wi-fi.org,21[2:4][5:7]\n"); |
| 3076 | } |
| 3077 | |
| 3078 | if (dut->ap_domain_name_list[0]) { |
| 3079 | fprintf(f, "domain_name=%s\n", |
| 3080 | dut->ap_domain_name_list); |
| 3081 | } |
| 3082 | |
| 3083 | if (dut->ap_ip_addr_type_avail == 1) { |
| 3084 | fprintf(f, "ipaddr_type_availability=0c\n"); |
| 3085 | } |
| 3086 | |
| 3087 | temp = buf; |
| 3088 | for (i = 0; dut->ap_plmn_mcc[i][0] && dut->ap_plmn_mnc[i][0]; |
| 3089 | i++) { |
| 3090 | if (i) |
| 3091 | *temp++ = ';'; |
| 3092 | |
| 3093 | snprintf(temp, |
| 3094 | sizeof(dut->ap_plmn_mcc[i]) + |
| 3095 | sizeof(dut->ap_plmn_mnc[i]) + 1, |
| 3096 | "%s,%s", |
| 3097 | dut->ap_plmn_mcc[i], |
| 3098 | dut->ap_plmn_mnc[i]); |
| 3099 | |
| 3100 | temp += strlen(dut->ap_plmn_mcc[i]) + |
| 3101 | strlen(dut->ap_plmn_mnc[i]) + 1; |
| 3102 | } |
| 3103 | if (i) |
| 3104 | fprintf(f, "anqp_3gpp_cell_net=%s\n", buf); |
| 3105 | |
| 3106 | if (dut->ap_qos_map_set == 1) |
| 3107 | fprintf(f, "qos_map_set=%s\n", QOS_MAP_SET_1); |
| 3108 | else if (dut->ap_qos_map_set == 2) |
| 3109 | fprintf(f, "qos_map_set=%s\n", QOS_MAP_SET_2); |
| 3110 | |
| 3111 | return 0; |
| 3112 | } |
| 3113 | |
| 3114 | |
| 3115 | static int ath_ap_append_hostapd_conf(struct sigma_dut *dut) |
| 3116 | { |
| 3117 | FILE *f; |
| 3118 | |
| 3119 | if (kill_process(dut, "(hostapd)", 1, SIGTERM) == 0 || |
| 3120 | system("killall hostapd") == 0) { |
| 3121 | int i; |
| 3122 | |
| 3123 | /* Wait some time to allow hostapd to complete cleanup before |
| 3124 | * starting a new process */ |
| 3125 | for (i = 0; i < 10; i++) { |
| 3126 | usleep(500000); |
| 3127 | if (system("pidof hostapd") != 0) |
| 3128 | break; |
| 3129 | } |
| 3130 | } |
| 3131 | |
| 3132 | f = fopen("/tmp/secath0", "a"); |
| 3133 | if (f == NULL) |
| 3134 | return -2; |
| 3135 | |
| 3136 | if (dut->ap_hs2 && append_hostapd_conf_hs2(dut, f)) { |
| 3137 | fclose(f); |
| 3138 | return -2; |
| 3139 | } |
| 3140 | |
| 3141 | if (dut->ap_interworking && append_hostapd_conf_interworking(dut, f)) { |
| 3142 | fclose(f); |
| 3143 | return -2; |
| 3144 | } |
| 3145 | |
| 3146 | fflush(f); |
| 3147 | fclose(f); |
| 3148 | return ath_ap_start_hostapd(dut); |
| 3149 | } |
| 3150 | |
| 3151 | |
| 3152 | static int ath_ap_start_hostapd(struct sigma_dut *dut) |
| 3153 | { |
| 3154 | if (dut->ap2_key_mgmt == AP2_OSEN) |
| 3155 | run_system(dut, "hostapd -B /tmp/secath0 /tmp/secath1 -e /etc/wpa2/entropy"); |
| 3156 | else |
| 3157 | run_system(dut, "hostapd -B /tmp/secath0 -e /etc/wpa2/entropy"); |
| 3158 | |
| 3159 | return 0; |
| 3160 | } |
| 3161 | |
| 3162 | |
| 3163 | #define LE16(a) ((((a) & 0xff) << 8) | (((a) >> 8) & 0xff)) |
| 3164 | |
| 3165 | static int cmd_ath_ap_anqpserver_start(struct sigma_dut *dut) |
| 3166 | { |
| 3167 | FILE *f; |
| 3168 | int nai_realm = 0, domain_name = 0, oper_name = 0, venue_name = 0, |
| 3169 | wan_metrics = 0, conn_cap = 0, ipaddr_avail = 0, cell_net = 0; |
| 3170 | char buf[100]; |
| 3171 | int i; |
| 3172 | |
| 3173 | f = fopen("/root/anqpserver.conf", "w"); |
| 3174 | if (f == NULL) |
| 3175 | return -1; |
| 3176 | |
| 3177 | if (dut->ap_nai_realm_list == 1) { |
| 3178 | nai_realm = 1; |
| 3179 | 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"); |
| 3180 | } else if (dut->ap_nai_realm_list == 2) { |
| 3181 | nai_realm = 1; |
| 3182 | fprintf(f, "dyn_nai_home_realm=encoding=00realm=wi-fi.org;eap_method=0Dauth_id=05auth_val=06\n"); |
| 3183 | } else if (dut->ap_nai_realm_list == 3) { |
| 3184 | nai_realm = 1; |
| 3185 | 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"); |
| 3186 | } else if (dut->ap_nai_realm_list == 4) { |
| 3187 | nai_realm = 1; |
| 3188 | 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"); |
| 3189 | } else |
| 3190 | sigma_dut_print(dut, DUT_MSG_INFO, "not setting nai_realm"); |
| 3191 | |
| 3192 | if (dut->ap_domain_name_list[0]) { |
| 3193 | char *next, *start, *dnbuf, *dn1, *anqp_dn; |
| 3194 | int len, dn_len_max; |
| 3195 | dnbuf = strdup(dut->ap_domain_name_list); |
Pradeep Reddy POTTETI | 673d85c | 2016-07-26 19:08:07 +0530 | [diff] [blame] | 3196 | if (dnbuf == NULL) { |
| 3197 | fclose(f); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3198 | return 0; |
Pradeep Reddy POTTETI | 673d85c | 2016-07-26 19:08:07 +0530 | [diff] [blame] | 3199 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3200 | |
| 3201 | len = strlen(dnbuf); |
| 3202 | dn_len_max = 50 + len*2; |
| 3203 | anqp_dn = malloc(dn_len_max); |
| 3204 | if (anqp_dn == NULL) { |
| 3205 | free(dnbuf); |
Pradeep Reddy POTTETI | 673d85c | 2016-07-26 19:08:07 +0530 | [diff] [blame] | 3206 | fclose(f); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3207 | return -1; |
| 3208 | } |
| 3209 | start = dnbuf; |
| 3210 | dn1 = anqp_dn; |
| 3211 | while (start && *start) { |
| 3212 | char *hexstr; |
| 3213 | |
| 3214 | next = strchr(start, ','); |
| 3215 | if (next) |
| 3216 | *next++ = '\0'; |
| 3217 | |
| 3218 | len = strlen(start); |
vamsi krishna | 2e88130 | 2016-05-25 15:02:39 +0530 | [diff] [blame] | 3219 | hexstr = malloc(len * 2 + 1); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3220 | if (hexstr == NULL) { |
| 3221 | free(dnbuf); |
| 3222 | free(anqp_dn); |
Pradeep Reddy POTTETI | 673d85c | 2016-07-26 19:08:07 +0530 | [diff] [blame] | 3223 | fclose(f); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3224 | return -1; |
| 3225 | } |
| 3226 | ascii2hexstr(start, hexstr); |
| 3227 | snprintf(dn1, dn_len_max, "%02x%s", len, hexstr); |
| 3228 | free(hexstr); |
| 3229 | dn1 += 2 + len * 2; |
| 3230 | dn_len_max -= 2 + len * 2; |
| 3231 | start = next; |
| 3232 | } |
| 3233 | free(dnbuf); |
| 3234 | if (dut->ap_gas_cb_delay) { |
| 3235 | fprintf(f, "dyn_domain_name=0c01%04x%s", |
| 3236 | LE16((unsigned int) strlen(anqp_dn)), anqp_dn); |
| 3237 | domain_name = 1; |
| 3238 | } else |
| 3239 | fprintf(f, "domain_name=0c01%04x%s", |
| 3240 | LE16((unsigned int) strlen(anqp_dn)), anqp_dn); |
| 3241 | free(anqp_dn); |
| 3242 | } else |
| 3243 | sigma_dut_print(dut, DUT_MSG_INFO, "not setting domain_name"); |
| 3244 | |
| 3245 | sigma_dut_print(dut, DUT_MSG_INFO, "not setting roaming_consortium"); |
| 3246 | |
| 3247 | if (dut->ap_oper_name) { |
| 3248 | if (dut->ap_gas_cb_delay) { |
| 3249 | fprintf(f, "dyn_oper_friendly_name=" |
| 3250 | ANQP_HS20_OPERATOR_FRIENDLY_NAME_1 "\n"); |
| 3251 | oper_name = 1; |
| 3252 | } else |
| 3253 | fprintf(f, "oper_friendly_name=" |
| 3254 | ANQP_HS20_OPERATOR_FRIENDLY_NAME_1 "\n"); |
| 3255 | } else |
| 3256 | sigma_dut_print(dut, DUT_MSG_INFO, "not setting oper_name"); |
| 3257 | |
| 3258 | if (dut->ap_venue_name) { |
| 3259 | if (dut->ap_gas_cb_delay) { |
| 3260 | fprintf(f, "dyn_venue_name=" ANQP_VENUE_NAME_1 "\n"); |
| 3261 | venue_name = 1; |
| 3262 | } else |
| 3263 | fprintf(f, "venue_name=" ANQP_VENUE_NAME_1 "\n"); |
| 3264 | } else |
| 3265 | sigma_dut_print(dut, DUT_MSG_ERROR, "not setting venue_name"); |
| 3266 | |
| 3267 | if (dut->ap_wan_metrics) { |
| 3268 | if (dut->ap_gas_cb_delay) { |
| 3269 | fprintf(f, "dyn_wan_metrics=" ANQP_HS20_WAN_METRICS_1 "\n"); |
| 3270 | wan_metrics = 1; |
| 3271 | } else |
| 3272 | fprintf(f, "wan_metrics=" ANQP_HS20_WAN_METRICS_1 |
| 3273 | "\n"); |
| 3274 | } else |
| 3275 | sigma_dut_print(dut, DUT_MSG_ERROR, "not setting wan_metrics"); |
| 3276 | |
| 3277 | if (dut->ap_conn_capab) { |
| 3278 | if (dut->ap_gas_cb_delay) { |
| 3279 | fprintf(f, "dyn_conn_capability=" |
| 3280 | ANQP_HS20_CONNECTION_CAPABILITY_1 "\n"); |
| 3281 | conn_cap = 1; |
| 3282 | } else |
| 3283 | fprintf(f, "conn_capability=" |
| 3284 | ANQP_HS20_CONNECTION_CAPABILITY_1 "\n"); |
| 3285 | } else |
| 3286 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 3287 | "not setting conn_capability"); |
| 3288 | |
| 3289 | if (dut->ap_ip_addr_type_avail) { |
| 3290 | if (dut->ap_gas_cb_delay) { |
| 3291 | fprintf(f, "dyn_ipaddr_type=" ANQP_IP_ADDR_TYPE_1 |
| 3292 | "\n"); |
| 3293 | ipaddr_avail = 1; |
| 3294 | } else |
| 3295 | fprintf(f, "ipaddr_type=" ANQP_IP_ADDR_TYPE_1 "\n"); |
| 3296 | } else |
| 3297 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 3298 | "not setting ipaddr_type_avail"); |
| 3299 | |
| 3300 | for (i = 0; dut->ap_plmn_mcc[i][0] && dut->ap_plmn_mnc[i][0]; i++) { |
| 3301 | snprintf(buf + i * 6, sizeof(buf) - i * 6, "%c%c%c%c%c%c", |
| 3302 | dut->ap_plmn_mcc[i][1], |
| 3303 | dut->ap_plmn_mcc[i][0], |
| 3304 | dut->ap_plmn_mnc[i][2] == '\0' ? |
| 3305 | 'f' : dut->ap_plmn_mnc[i][2], |
| 3306 | dut->ap_plmn_mcc[i][2], |
| 3307 | dut->ap_plmn_mnc[i][1], |
| 3308 | dut->ap_plmn_mnc[i][0]); |
| 3309 | } |
| 3310 | if (i) { |
| 3311 | uint16_t ie_len = (i * 3) + 5; |
| 3312 | if (dut->ap_gas_cb_delay) { |
| 3313 | fprintf(f, "dyn_cell_net=0801"); |
| 3314 | cell_net = 1; |
| 3315 | } else |
| 3316 | fprintf(f, "cell_net=0801"); |
| 3317 | fprintf(f, "%04x", LE16(ie_len)); |
| 3318 | fprintf(f, "00"); /* version */ |
| 3319 | fprintf(f, "%02x", (i * 3) + 3); /* user data hdr length */ |
| 3320 | fprintf(f, "00"); /* plmn list */ |
| 3321 | fprintf(f, "%02x", (i * 3) + 1); /* length of plmn list */ |
| 3322 | fprintf(f, "%02x", i); /* number of plmns */ |
| 3323 | fprintf(f, "%s\n", buf); /* plmns */ |
| 3324 | } else |
| 3325 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 3326 | "not setting 3gpp_cellular_network"); |
| 3327 | |
| 3328 | if (nai_realm || domain_name || oper_name || venue_name || |
| 3329 | wan_metrics || conn_cap || ipaddr_avail || cell_net) { |
| 3330 | fprintf(f, "anqp_attach="); |
| 3331 | if (venue_name) |
| 3332 | fprintf(f, "00000104%4.4x", dut->ap_gas_cb_delay); |
| 3333 | if (nai_realm) |
| 3334 | fprintf(f, "00000107%4.4x", dut->ap_gas_cb_delay); |
| 3335 | if (cell_net) |
| 3336 | fprintf(f, "00000108%4.4x", dut->ap_gas_cb_delay); |
| 3337 | if (domain_name) |
| 3338 | fprintf(f, "0000010c%4.4x", dut->ap_gas_cb_delay); |
| 3339 | if (oper_name) |
| 3340 | fprintf(f, "00010003%4.4x", dut->ap_gas_cb_delay); |
| 3341 | if (wan_metrics) |
| 3342 | fprintf(f, "00010004%4.4x", dut->ap_gas_cb_delay); |
| 3343 | if (conn_cap) |
| 3344 | fprintf(f, "00010005%4.4x", dut->ap_gas_cb_delay); |
| 3345 | fprintf(f, "00010006%4.4x", dut->ap_gas_cb_delay); |
| 3346 | fprintf(f, "\n"); |
| 3347 | } |
| 3348 | |
| 3349 | fclose(f); |
| 3350 | |
| 3351 | run_system(dut, "anqpserver -i ath0 &"); |
| 3352 | if (!dut->ap_anqpserver_on) |
| 3353 | run_system(dut, "killall anqpserver"); |
| 3354 | |
| 3355 | return 1; |
| 3356 | } |
| 3357 | |
| 3358 | |
| 3359 | static void cmd_ath_ap_radio_config(struct sigma_dut *dut) |
| 3360 | { |
| 3361 | char buf[100]; |
| 3362 | |
| 3363 | run_system(dut, "cfg -a AP_STARTMODE=standard"); |
| 3364 | |
| 3365 | if (sigma_radio_ifname[0] && |
| 3366 | strcmp(sigma_radio_ifname[0], "wifi1") == 0) { |
| 3367 | run_system(dut, "cfg -a AP_RADIO_ID=1"); |
| 3368 | switch (dut->ap_mode) { |
| 3369 | case AP_11g: |
| 3370 | run_system(dut, "cfg -a AP_CHMODE_2=11G"); |
| 3371 | break; |
| 3372 | case AP_11b: |
| 3373 | run_system(dut, "cfg -a AP_CHMODE_2=11B"); |
| 3374 | break; |
| 3375 | case AP_11ng: |
| 3376 | run_system(dut, "cfg -a AP_CHMODE_2=11NGHT20"); |
| 3377 | break; |
| 3378 | case AP_11a: |
| 3379 | run_system(dut, "cfg -a AP_CHMODE_2=11A"); |
| 3380 | break; |
| 3381 | case AP_11na: |
| 3382 | run_system(dut, "cfg -a AP_CHMODE_2=11NAHT20"); |
| 3383 | break; |
| 3384 | case AP_11ac: |
| 3385 | run_system(dut, "cfg -a AP_CHMODE_2=11ACVHT80"); |
| 3386 | break; |
| 3387 | default: |
| 3388 | run_system(dut, "cfg -a AP_CHMODE_2=11ACVHT80"); |
| 3389 | break; |
| 3390 | } |
| 3391 | |
| 3392 | switch (dut->ap_rx_streams) { |
| 3393 | case 1: |
| 3394 | run_system(dut, "cfg -a RX_CHAINMASK_2=1"); |
| 3395 | break; |
| 3396 | case 2: |
| 3397 | run_system(dut, "cfg -a RX_CHAINMASK_2=3"); |
| 3398 | break; |
| 3399 | case 3: |
| 3400 | run_system(dut, "cfg -a RX_CHAINMASK_2=7"); |
| 3401 | break; |
| 3402 | } |
| 3403 | |
| 3404 | switch (dut->ap_tx_streams) { |
| 3405 | case 1: |
| 3406 | run_system(dut, "cfg -a TX_CHAINMASK_2=1"); |
| 3407 | break; |
| 3408 | case 2: |
| 3409 | run_system(dut, "cfg -a TX_CHAINMASK_2=3"); |
| 3410 | break; |
| 3411 | case 3: |
| 3412 | run_system(dut, "cfg -a TX_CHAINMASK_2=7"); |
| 3413 | break; |
| 3414 | } |
| 3415 | |
| 3416 | switch (dut->ap_chwidth) { |
| 3417 | case AP_20: |
| 3418 | run_system(dut, "cfg -a AP_CHMODE_2=11ACVHT20"); |
| 3419 | break; |
| 3420 | case AP_40: |
| 3421 | run_system(dut, "cfg -a AP_CHMODE_2=11ACVHT40"); |
| 3422 | break; |
| 3423 | case AP_80: |
| 3424 | run_system(dut, "cfg -a AP_CHMODE_2=11ACVHT80"); |
| 3425 | break; |
| 3426 | case AP_160: |
| 3427 | case AP_AUTO: |
| 3428 | default: |
| 3429 | run_system(dut, "cfg -a AP_CHMODE_2=11ACVHT80"); |
| 3430 | break; |
| 3431 | } |
| 3432 | |
| 3433 | if (dut->ap_tx_stbc) { |
| 3434 | run_system(dut, "cfg -a TX_STBC_2=1"); |
| 3435 | } |
| 3436 | |
| 3437 | snprintf(buf, sizeof(buf), "cfg -a AP_PRIMARY_CH_2=%d", |
| 3438 | dut->ap_channel); |
| 3439 | |
| 3440 | if (dut->ap_is_dual) { |
| 3441 | switch (dut->ap_mode_1) { |
| 3442 | case AP_11g: |
| 3443 | run_system(dut, "cfg -a AP_CHMODE=11G"); |
| 3444 | break; |
| 3445 | case AP_11b: |
| 3446 | run_system(dut, "cfg -a AP_CHMODE=11B"); |
| 3447 | break; |
| 3448 | case AP_11ng: |
| 3449 | run_system(dut, "cfg -a AP_CHMODE=11NGHT20"); |
| 3450 | break; |
| 3451 | case AP_11a: |
| 3452 | run_system(dut, "cfg -a AP_CHMODE=11A"); |
| 3453 | break; |
| 3454 | case AP_11na: |
| 3455 | run_system(dut, "cfg -a AP_CHMODE=11NAHT20"); |
| 3456 | break; |
| 3457 | case AP_11ac: |
| 3458 | run_system(dut, "cfg -a AP_CHMODE=11ACVHT80"); |
| 3459 | break; |
| 3460 | default: |
| 3461 | run_system(dut, "cfg -a AP_CHMODE=11NGHT20"); |
| 3462 | break; |
| 3463 | } |
| 3464 | snprintf(buf, sizeof(buf), "cfg -a AP_PRIMARY_CH=%d", |
| 3465 | dut->ap_channel_1); |
| 3466 | } |
| 3467 | run_system(dut, buf); |
| 3468 | } else { |
| 3469 | run_system(dut, "cfg -a AP_RADIO_ID=0"); |
| 3470 | switch (dut->ap_mode) { |
| 3471 | case AP_11g: |
| 3472 | run_system(dut, "cfg -a AP_CHMODE=11G"); |
| 3473 | break; |
| 3474 | case AP_11b: |
| 3475 | run_system(dut, "cfg -a AP_CHMODE=11B"); |
| 3476 | break; |
| 3477 | case AP_11ng: |
| 3478 | run_system(dut, "cfg -a AP_CHMODE=11NGHT20"); |
| 3479 | break; |
| 3480 | case AP_11a: |
| 3481 | run_system(dut, "cfg -a AP_CHMODE=11A"); |
| 3482 | break; |
| 3483 | case AP_11na: |
| 3484 | run_system(dut, "cfg -a AP_CHMODE=11NAHT20"); |
| 3485 | break; |
| 3486 | case AP_11ac: |
| 3487 | run_system(dut, "cfg -a AP_CHMODE=11ACVHT80"); |
| 3488 | break; |
| 3489 | default: |
| 3490 | run_system(dut, "cfg -a AP_CHMODE=11NGHT20"); |
| 3491 | break; |
| 3492 | } |
| 3493 | snprintf(buf, sizeof(buf), "cfg -a AP_PRIMARY_CH=%d", |
| 3494 | dut->ap_channel); |
| 3495 | run_system(dut, buf); |
| 3496 | } |
| 3497 | |
| 3498 | if (dut->ap_sgi80 == 1) { |
| 3499 | run_system(dut, "cfg -a SHORTGI=1"); |
| 3500 | run_system(dut, "cfg -a SHORTGI_2=1"); |
| 3501 | } else if (dut->ap_sgi80 == 0) { |
| 3502 | run_system(dut, "cfg -a SHORTGI=0"); |
| 3503 | run_system(dut, "cfg -a SHORTGI_2=0"); |
| 3504 | } |
| 3505 | |
| 3506 | if (dut->ap_ldpc == 1) |
| 3507 | run_system(dut, "cfg -a LDPC=1"); |
| 3508 | else if (dut->ap_ldpc == 2) |
| 3509 | run_system(dut, "cfg -a LDPC=0"); |
| 3510 | } |
| 3511 | |
| 3512 | |
| 3513 | void ath_disable_txbf(struct sigma_dut *dut, const char *intf) |
| 3514 | { |
| 3515 | char buf[50]; |
| 3516 | |
| 3517 | snprintf(buf, sizeof(buf), "iwpriv %s vhtsubfee 0", intf); |
| 3518 | if (system(buf) != 0) |
| 3519 | sigma_dut_print(dut, DUT_MSG_ERROR, "iwpriv vhtsubfee failed"); |
| 3520 | |
| 3521 | snprintf(buf, sizeof(buf), "iwpriv %s vhtsubfer 0", intf); |
| 3522 | if (system(buf) != 0) |
| 3523 | sigma_dut_print(dut, DUT_MSG_ERROR, "iwpriv vhtsubfer failed"); |
| 3524 | |
| 3525 | snprintf(buf, sizeof(buf), "iwpriv %s vhtmubfee 0", intf); |
| 3526 | if (system(buf) != 0) |
| 3527 | sigma_dut_print(dut, DUT_MSG_ERROR, "iwpriv vhtmubfee failed"); |
| 3528 | |
| 3529 | snprintf(buf, sizeof(buf), "iwpriv %s vhtmubfer 0", intf); |
| 3530 | if (system(buf) != 0) |
| 3531 | sigma_dut_print(dut, DUT_MSG_ERROR, "iwpriv vhtmubfer failed"); |
| 3532 | } |
| 3533 | |
| 3534 | |
| 3535 | static void ath_ap_set_params(struct sigma_dut *dut) |
| 3536 | { |
| 3537 | const char *basedev = "wifi1"; |
| 3538 | const char *ifname = dut->ap_is_dual ? "ath1" : "ath0"; |
| 3539 | int i; |
priyadharshini gowthaman | 8e26ff4 | 2016-06-22 22:47:14 -0700 | [diff] [blame^] | 3540 | char buf[300]; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3541 | |
| 3542 | if (dut->ap_countrycode[0]) { |
| 3543 | snprintf(buf, sizeof(buf), "iwpriv %s setCountry %s", |
| 3544 | basedev, dut->ap_countrycode); |
| 3545 | if (system(buf) != 0) { |
| 3546 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 3547 | "iwpriv setCountry failed"); |
| 3548 | } |
| 3549 | sigma_dut_print(dut, DUT_MSG_INFO, "Set countrycode"); |
| 3550 | } |
| 3551 | |
| 3552 | for (i = 0; i < NUM_AP_AC; i++) { |
| 3553 | if (dut->ap_qos[i].ac) { |
| 3554 | snprintf(buf, sizeof(buf), "iwpriv %s cwmin %d 0 %d", |
| 3555 | ifname, i, dut->ap_qos[i].cwmin); |
| 3556 | if (system(buf) != 0) { |
| 3557 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 3558 | "iwpriv cwmin failed"); |
| 3559 | } |
| 3560 | |
| 3561 | snprintf(buf, sizeof(buf), "iwpriv %s cwmax %d 0 %d", |
| 3562 | ifname, i, dut->ap_qos[i].cwmax); |
| 3563 | if (system(buf) != 0) { |
| 3564 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 3565 | "iwpriv cwmax failed"); |
| 3566 | } |
| 3567 | |
| 3568 | snprintf(buf, sizeof(buf), "iwpriv %s aifs %d 0 %d", |
| 3569 | ifname, i, dut->ap_qos[i].aifs); |
| 3570 | if (system(buf) != 0) { |
| 3571 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 3572 | "iwpriv aifs failed"); |
| 3573 | } |
| 3574 | |
| 3575 | snprintf(buf, sizeof(buf), |
| 3576 | "iwpriv %s txoplimit %d 0 %d", |
| 3577 | ifname, i, dut->ap_qos[i].txop); |
| 3578 | if (system(buf) != 0) { |
| 3579 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 3580 | "iwpriv txoplimit failed"); |
| 3581 | } |
| 3582 | |
| 3583 | snprintf(buf, sizeof(buf), "iwpriv %s acm %d 0 %d", |
| 3584 | ifname, i, dut->ap_qos[i].acm); |
| 3585 | if (system(buf) != 0) { |
| 3586 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 3587 | "iwpriv acm failed"); |
| 3588 | } |
| 3589 | } |
| 3590 | } |
| 3591 | |
| 3592 | for (i = 0; i < NUM_AP_AC; i++) { |
| 3593 | if (dut->ap_sta_qos[i].ac) { |
| 3594 | snprintf(buf, sizeof(buf), "iwpriv %s cwmin %d 1 %d", |
| 3595 | ifname, i, dut->ap_sta_qos[i].cwmin); |
| 3596 | if (system(buf) != 0) { |
| 3597 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 3598 | "iwpriv cwmin failed"); |
| 3599 | } |
| 3600 | |
| 3601 | snprintf(buf, sizeof(buf), "iwpriv %s cwmax %d 1 %d", |
| 3602 | ifname, i, dut->ap_sta_qos[i].cwmax); |
| 3603 | if (system(buf) != 0) { |
| 3604 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 3605 | "iwpriv cwmax failed"); |
| 3606 | } |
| 3607 | |
| 3608 | snprintf(buf, sizeof(buf), "iwpriv %s aifs %d 1 %d", |
| 3609 | ifname, i, dut->ap_sta_qos[i].aifs); |
| 3610 | if (system(buf) != 0) { |
| 3611 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 3612 | "iwpriv aifs failed"); |
| 3613 | } |
| 3614 | |
| 3615 | snprintf(buf, sizeof(buf), |
| 3616 | "iwpriv %s txoplimit %d 1 %d", |
| 3617 | ifname, i, dut->ap_sta_qos[i].txop); |
| 3618 | if (system(buf) != 0) { |
| 3619 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 3620 | "iwpriv txoplimit failed"); |
| 3621 | } |
| 3622 | |
| 3623 | snprintf(buf, sizeof(buf), "iwpriv %s acm %d 1 %d", |
| 3624 | ifname, i, dut->ap_sta_qos[i].acm); |
| 3625 | if (system(buf) != 0) { |
| 3626 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 3627 | "iwpriv acm failed"); |
| 3628 | } |
| 3629 | } |
| 3630 | } |
| 3631 | |
| 3632 | if (dut->ap_disable_protection == 1) { |
| 3633 | snprintf(buf, sizeof(buf), "iwpriv %s enablertscts 0", ifname); |
| 3634 | if (system(buf) != 0) { |
| 3635 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 3636 | "iwpriv enablertscts failed"); |
| 3637 | } |
| 3638 | sigma_dut_print(dut, DUT_MSG_INFO, "Disabled rtscts"); |
| 3639 | } |
| 3640 | |
| 3641 | if (dut->ap_ldpc == 1) { |
| 3642 | snprintf(buf, sizeof(buf), "iwpriv %s ldpc 1", ifname); |
| 3643 | if (system(buf) != 0) { |
| 3644 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 3645 | "iwpriv ldpc 1 failed"); |
| 3646 | } |
| 3647 | } else if (dut->ap_ldpc == 2) { |
| 3648 | snprintf(buf, sizeof(buf), "iwpriv %s ldpc 0", ifname); |
| 3649 | if (system(buf) != 0) { |
| 3650 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 3651 | "iwpriv ldpc 0 failed"); |
| 3652 | } |
| 3653 | } |
| 3654 | |
| 3655 | if (dut->ap_ampdu == 1) { |
| 3656 | snprintf(buf, sizeof(buf), "iwpriv %s ampdu 1", ifname); |
| 3657 | if (system(buf) != 0) { |
| 3658 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 3659 | "iwpriv ampdu 1 failed"); |
| 3660 | } |
| 3661 | } else if (dut->ap_ampdu == 2) { |
| 3662 | snprintf(buf, sizeof(buf), "iwpriv %s ampdu 0", ifname); |
| 3663 | if (system(buf) != 0) { |
| 3664 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 3665 | "iwpriv ampdu 0 failed"); |
| 3666 | } |
| 3667 | } |
| 3668 | |
| 3669 | if (dut->ap_ampdu_exp) { |
| 3670 | if (dut->program == PROGRAM_VHT) { |
| 3671 | snprintf(buf, sizeof(buf), "iwpriv %s vhtmaxampdu %d", |
| 3672 | ifname, dut->ap_ampdu_exp); |
| 3673 | if (system(buf) != 0) { |
| 3674 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 3675 | "iwpriv vhtmaxampdu failed"); |
| 3676 | } |
| 3677 | } else { |
| 3678 | /* 11N */ |
| 3679 | snprintf(buf, sizeof(buf), "iwpriv %s maxampdu %d", |
| 3680 | ifname, dut->ap_ampdu_exp); |
| 3681 | if (system(buf) != 0) { |
| 3682 | sigma_dut_print(dut, DUT_MSG_ERROR, "iwpriv maxampdu failed"); |
| 3683 | } |
| 3684 | } |
| 3685 | } |
| 3686 | |
| 3687 | if (dut->ap_noack == AP_NOACK_ENABLED) { |
| 3688 | snprintf(buf, sizeof(buf), "iwpriv %s noackpolicy 0 0 1", ifname); |
| 3689 | if (system(buf) != 0) { |
| 3690 | sigma_dut_print(dut, DUT_MSG_ERROR, "iwpriv noackpolicy 0 0 1 failed"); |
| 3691 | } |
| 3692 | snprintf(buf, sizeof(buf), "iwpriv %s noackpolicy 1 0 1", ifname); |
| 3693 | if (system(buf) != 0) { |
| 3694 | sigma_dut_print(dut, DUT_MSG_ERROR, "iwpriv noackpolicy 1 0 1 failed"); |
| 3695 | } |
| 3696 | snprintf(buf, sizeof(buf), "iwpriv %s noackpolicy 2 0 1", ifname); |
| 3697 | if (system(buf) != 0) { |
| 3698 | sigma_dut_print(dut, DUT_MSG_ERROR, "iwpriv noackpolicy 2 0 1 failed"); |
| 3699 | } |
| 3700 | snprintf(buf, sizeof(buf), "iwpriv %s noackpolicy 3 0 1", ifname); |
| 3701 | if (system(buf) != 0) { |
| 3702 | sigma_dut_print(dut, DUT_MSG_ERROR, "iwpriv noackpolicy 3 0 1 failed"); |
| 3703 | } |
| 3704 | } else if (dut->ap_noack == AP_NOACK_DISABLED) { |
| 3705 | snprintf(buf, sizeof(buf), "iwpriv %s noackpolicy 0 0 0", ifname); |
| 3706 | if (system(buf) != 0) { |
| 3707 | sigma_dut_print(dut, DUT_MSG_ERROR, "iwpriv noackpolicy 0 0 0 failed"); |
| 3708 | } |
| 3709 | snprintf(buf, sizeof(buf), "iwpriv %s noackpolicy 1 0 0", ifname); |
| 3710 | if (system(buf) != 0) { |
| 3711 | sigma_dut_print(dut, DUT_MSG_ERROR, "iwpriv noackpolicy 1 0 0 failed"); |
| 3712 | } |
| 3713 | snprintf(buf, sizeof(buf), "iwpriv %s noackpolicy 2 0 0", ifname); |
| 3714 | if (system(buf) != 0) { |
| 3715 | sigma_dut_print(dut, DUT_MSG_ERROR, "iwpriv noackpolicy 2 0 0 failed"); |
| 3716 | } |
| 3717 | snprintf(buf, sizeof(buf), "iwpriv %s noackpolicy 3 0 0", ifname); |
| 3718 | if (system(buf) != 0) { |
| 3719 | sigma_dut_print(dut, DUT_MSG_ERROR, "iwpriv noackpolicy 3 0 0 failed"); |
| 3720 | } |
| 3721 | } |
| 3722 | |
| 3723 | if (dut->device_type == AP_testbed && dut->ap_vhtmcs_map) { |
| 3724 | snprintf(buf, sizeof(buf), "iwpriv %s vht_mcsmap 0x%04x", |
| 3725 | ifname, dut->ap_vhtmcs_map); |
| 3726 | if (system(buf) != 0) { |
| 3727 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 3728 | "iwpriv vht_mcsmap failed"); |
| 3729 | } |
| 3730 | } |
| 3731 | |
| 3732 | if (dut->ap_amsdu == 1) { |
| 3733 | snprintf(buf, sizeof(buf), "iwpriv %s amsdu 2", ifname); |
| 3734 | if (system(buf) != 0) { |
| 3735 | sigma_dut_print(dut, DUT_MSG_ERROR, "iwpriv amsdu 2 failed"); |
| 3736 | } |
| 3737 | } else if (dut->ap_amsdu == 2) { |
| 3738 | snprintf(buf, sizeof(buf), "iwpriv %s amsdu 1", ifname); |
| 3739 | if (system(buf) != 0) { |
| 3740 | sigma_dut_print(dut, DUT_MSG_ERROR, "iwpriv amsdu 1 failed"); |
| 3741 | } |
| 3742 | } |
| 3743 | |
| 3744 | if (dut->ap_rx_amsdu == 1) { |
| 3745 | snprintf(buf, sizeof(buf), "iwpriv wifi1 rx_amsdu 1"); |
| 3746 | if (system(buf) != 0) { |
| 3747 | sigma_dut_print(dut, DUT_MSG_ERROR, "iwpriv rx_amsdu 1 failed"); |
| 3748 | } |
| 3749 | } else if (dut->ap_rx_amsdu == 2) { |
| 3750 | snprintf(buf, sizeof(buf), "iwpriv wifi1 rx_amsdu 0"); |
| 3751 | if (system(buf) != 0) { |
| 3752 | sigma_dut_print(dut, DUT_MSG_ERROR, "iwpriv rx_amsdu 0 failed"); |
| 3753 | } |
| 3754 | } |
| 3755 | |
| 3756 | /* Command sequence to generate single VHT AMSDU and MPDU */ |
| 3757 | if (dut->ap_addba_reject && dut->ap_ampdu == 2 && dut->ap_amsdu == 1) { |
| 3758 | snprintf(buf, sizeof(buf), "iwpriv %s setaddbaoper 1", ifname); |
| 3759 | if (system(buf) != 0) { |
| 3760 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 3761 | "iwpriv setaddbaoper 1 failed"); |
| 3762 | } |
| 3763 | |
| 3764 | snprintf(buf, sizeof(buf), |
| 3765 | "wifitool %s senddelba 1 0 1 4", ifname); |
| 3766 | if (system(buf) != 0) { |
| 3767 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 3768 | "wifitool senddelba failed"); |
| 3769 | } |
| 3770 | |
| 3771 | snprintf(buf, sizeof(buf), "wifitool %s sendsingleamsdu 1 0", |
| 3772 | ifname); |
| 3773 | if (system(buf) != 0) { |
| 3774 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 3775 | "wifitool sendsingleamsdu failed"); |
| 3776 | } |
| 3777 | |
| 3778 | snprintf(buf, sizeof(buf), "iwpriv %s amsdu 10", ifname); |
| 3779 | if (system(buf) != 0) { |
| 3780 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 3781 | "iwpriv amsdu failed"); |
| 3782 | } |
| 3783 | } |
| 3784 | |
| 3785 | if (dut->ap_mode == AP_11ac) { |
| 3786 | int chwidth, nss; |
| 3787 | |
| 3788 | switch (dut->ap_chwidth) { |
| 3789 | case AP_20: |
| 3790 | chwidth = 0; |
| 3791 | break; |
| 3792 | case AP_40: |
| 3793 | chwidth = 1; |
| 3794 | break; |
| 3795 | case AP_80: |
| 3796 | chwidth = 2; |
| 3797 | break; |
| 3798 | case AP_160: |
| 3799 | chwidth = 3; |
| 3800 | break; |
| 3801 | default: |
| 3802 | chwidth = 0; |
| 3803 | break; |
| 3804 | } |
| 3805 | |
| 3806 | switch (dut->ap_tx_streams) { |
| 3807 | case 1: |
| 3808 | nss = 1; |
| 3809 | break; |
| 3810 | case 2: |
| 3811 | nss = 2; |
| 3812 | break; |
| 3813 | case 3: |
| 3814 | nss = 3; |
| 3815 | break; |
| 3816 | case 4: |
| 3817 | nss = 4; |
| 3818 | break; |
| 3819 | default: |
| 3820 | nss = 3; |
| 3821 | break; |
| 3822 | } |
| 3823 | |
| 3824 | if (dut->ap_fixed_rate) { |
| 3825 | if (nss == 4) |
| 3826 | ath_disable_txbf(dut, ifname); |
| 3827 | |
| 3828 | /* Set the nss */ |
| 3829 | snprintf(buf, sizeof(buf), "iwpriv %s nss %d", |
| 3830 | ifname, nss); |
| 3831 | if (system(buf) != 0) { |
| 3832 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 3833 | "iwpriv nss failed"); |
| 3834 | } |
| 3835 | |
| 3836 | /* Set the channel width */ |
| 3837 | snprintf(buf, sizeof(buf), "iwpriv %s chwidth %d", |
| 3838 | ifname, chwidth); |
| 3839 | if (system(buf) != 0) { |
| 3840 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 3841 | "iwpriv chwidth failed"); |
| 3842 | } |
| 3843 | |
| 3844 | /* Set the VHT MCS */ |
| 3845 | snprintf(buf, sizeof(buf), "iwpriv %s vhtmcs %d", |
| 3846 | ifname, dut->ap_mcs); |
| 3847 | if (system(buf) != 0) { |
| 3848 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 3849 | "iwpriv vhtmcs failed"); |
| 3850 | } |
| 3851 | } |
| 3852 | } |
| 3853 | |
| 3854 | if (dut->ap_dyn_bw_sig == AP_DYN_BW_SGNL_ENABLED) { |
| 3855 | snprintf(buf, sizeof(buf), "iwpriv %s cwmenable 1", ifname); |
| 3856 | if (system(buf) != 0) { |
| 3857 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 3858 | "iwpriv cwmenable 1 failed"); |
| 3859 | } |
| 3860 | } else if (dut->ap_dyn_bw_sig == AP_DYN_BW_SGNL_DISABLED) { |
| 3861 | snprintf(buf, sizeof(buf), "iwpriv %s cwmenable 0", ifname); |
| 3862 | if (system(buf) != 0) { |
| 3863 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 3864 | "iwpriv cwmenable 0 failed"); |
| 3865 | } |
| 3866 | } |
| 3867 | |
| 3868 | if (dut->ap_sig_rts == 1) { |
| 3869 | snprintf(buf, sizeof(buf), "iwconfig %s rts 64", ifname); |
| 3870 | if (system(buf) != 0) { |
| 3871 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 3872 | "iwconfig rts 64 failed"); |
| 3873 | } |
| 3874 | } else if (dut->ap_sig_rts == 2) { |
| 3875 | snprintf(buf, sizeof(buf), "iwconfig %s rts 2347", ifname); |
| 3876 | if (system(buf) != 0) { |
| 3877 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 3878 | "iwpriv rts 2347 failed"); |
| 3879 | } |
| 3880 | } |
| 3881 | |
| 3882 | if (dut->ap_hs2) { |
| 3883 | snprintf(buf, sizeof(buf), "iwpriv %s qbssload 1", ifname); |
| 3884 | if (system(buf) != 0) { |
| 3885 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 3886 | "iwpriv qbssload failed"); |
| 3887 | } |
| 3888 | sigma_dut_print(dut, DUT_MSG_INFO, "Enabled qbssload"); |
| 3889 | } |
| 3890 | |
| 3891 | if (dut->ap_bss_load && dut->ap_bss_load != -1) { |
| 3892 | unsigned int bssload = 0; |
| 3893 | |
| 3894 | if (dut->ap_bss_load == 1) { |
| 3895 | /* STA count: 1, CU: 50, AAC: 65535 */ |
| 3896 | bssload = 0x0132ffff; |
| 3897 | } else if (dut->ap_bss_load == 2) { |
| 3898 | /* STA count: 1, CU: 200, AAC: 65535 */ |
| 3899 | bssload = 0x01c8ffff; |
| 3900 | } else if (dut->ap_bss_load == 3) { |
| 3901 | /* STA count: 1, CU: 75, AAC: 65535 */ |
| 3902 | bssload = 0x014bffff; |
| 3903 | } |
| 3904 | |
| 3905 | snprintf(buf, sizeof(buf), "iwpriv %s hcbssload %u", |
| 3906 | ifname, bssload); |
| 3907 | if (system(buf) != 0) { |
| 3908 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 3909 | "iwpriv hcbssload failed"); |
| 3910 | } |
| 3911 | } else if (dut->ap_bss_load == 0) { |
| 3912 | snprintf(buf, sizeof(buf), "iwpriv %s qbssload 0", ifname); |
| 3913 | if (system(buf) != 0) { |
| 3914 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 3915 | "iwpriv qbssload failed"); |
| 3916 | } |
| 3917 | sigma_dut_print(dut, DUT_MSG_INFO, "Disabled qbssload"); |
| 3918 | } |
| 3919 | |
| 3920 | if (dut->ap_dgaf_disable) { |
| 3921 | snprintf(buf, sizeof(buf), "iwpriv %s dgaf_disable 1", ifname); |
| 3922 | if (system(buf) != 0) { |
| 3923 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 3924 | "iwpriv dgaf_disable failed"); |
| 3925 | } |
| 3926 | sigma_dut_print(dut, DUT_MSG_INFO, "Enabled dgaf_disable"); |
| 3927 | } |
| 3928 | |
| 3929 | if (dut->ap_l2tif) { |
| 3930 | snprintf(buf, sizeof(buf), "iwpriv %s l2tif 1", ifname); |
| 3931 | if (system(buf) != 0) { |
| 3932 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 3933 | "iwpriv l2tif failed"); |
| 3934 | } |
| 3935 | snprintf(buf, sizeof(buf), |
| 3936 | "echo 1 > /sys/class/net/br0/brif/ath0/hotspot_l2tif"); |
| 3937 | if (system(buf) != 0) |
| 3938 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 3939 | "l2tif br failed"); |
| 3940 | |
| 3941 | snprintf(buf, sizeof(buf), |
| 3942 | "echo 1 > /sys/class/net/br0/brif/eth0/hotspot_wan"); |
| 3943 | if (system(buf) != 0) |
| 3944 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 3945 | "l2tif brif failed"); |
| 3946 | sigma_dut_print(dut, DUT_MSG_INFO, "Enabled l2tif"); |
| 3947 | } |
priyadharshini gowthaman | 264d544 | 2016-02-25 15:52:22 -0800 | [diff] [blame] | 3948 | |
| 3949 | if (dut->ap_ndpa_frame == 0) { |
| 3950 | snprintf(buf, sizeof(buf), |
| 3951 | "wifitool %s beeliner_fw_test 117 192", ifname); |
| 3952 | if (system(buf) != 0) { |
| 3953 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 3954 | "wifitool beeliner_fw_test 117 192 failed"); |
| 3955 | } |
| 3956 | snprintf(buf, sizeof(buf), |
| 3957 | "wifitool %s beeliner_fw_test 118 192", ifname); |
| 3958 | if (system(buf) != 0) { |
| 3959 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 3960 | "wifitool beeliner_fw_test 117 192 failed"); |
| 3961 | } |
| 3962 | } else if (dut->ap_ndpa_frame == 1) { |
| 3963 | /* Driver default - no changes needed */ |
| 3964 | } else if (dut->ap_ndpa_frame == 2) { |
| 3965 | snprintf(buf, sizeof(buf), |
| 3966 | "wifitool %s beeliner_fw_test 115 1", ifname); |
| 3967 | if (system(buf) != 0) { |
| 3968 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 3969 | "wifitool beeliner_fw_test 117 192 failed"); |
| 3970 | } |
| 3971 | snprintf(buf, sizeof(buf), |
| 3972 | "wifitool %s beeliner_fw_test 116 1", ifname); |
| 3973 | if (system(buf) != 0) { |
| 3974 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 3975 | "wifitool beeliner_fw_test 117 192 failed"); |
| 3976 | } |
| 3977 | } |
priyadharshini gowthaman | 8e26ff4 | 2016-06-22 22:47:14 -0700 | [diff] [blame^] | 3978 | |
| 3979 | if (dut->ap_rtt == 1) { |
| 3980 | snprintf(buf, sizeof(buf), "iwpriv %s enable_rtt 1", ifname); |
| 3981 | run_system(dut, buf); |
| 3982 | } |
| 3983 | |
| 3984 | if (dut->ap_lci == 1) { |
| 3985 | snprintf(buf, sizeof(buf), "iwpriv %s enable_lci 1", ifname); |
| 3986 | run_system(dut, buf); |
| 3987 | } |
| 3988 | |
| 3989 | if (dut->ap_lcr == 1) { |
| 3990 | snprintf(buf, sizeof(buf), "iwpriv %s enable_lcr 1", ifname); |
| 3991 | run_system(dut, buf); |
| 3992 | } |
| 3993 | |
| 3994 | if (dut->ap_rrm == 1) { |
| 3995 | snprintf(buf, sizeof(buf), "iwpriv %s rrm 1", ifname); |
| 3996 | run_system(dut, buf); |
| 3997 | } |
| 3998 | |
| 3999 | if (dut->ap_lci == 1 || dut->ap_lcr == 1) { |
| 4000 | run_system(dut, "wpc -l /tmp/lci_cfg.txt"); |
| 4001 | } |
| 4002 | |
| 4003 | if (dut->ap_neighap >= 1 && dut->ap_lci == 0) { |
| 4004 | FILE *f; |
| 4005 | |
| 4006 | f = fopen("/tmp/nbr_report.txt", "w"); |
| 4007 | if (!f) { |
| 4008 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4009 | "Failed to open /tmp/nbr_report.txt"); |
| 4010 | return; |
| 4011 | } |
| 4012 | |
| 4013 | fprintf(f, |
| 4014 | "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", |
| 4015 | dut->ap_val_neighap[0][0], dut->ap_val_neighap[0][1], |
| 4016 | dut->ap_val_neighap[0][2], dut->ap_val_neighap[0][3], |
| 4017 | dut->ap_val_neighap[0][4], dut->ap_val_neighap[0][5], |
| 4018 | dut->ap_val_opchannel[0]); |
| 4019 | fclose(f); |
| 4020 | |
| 4021 | f = fopen("/tmp/ftmrr.txt", "w"); |
| 4022 | if (!f) { |
| 4023 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4024 | "Failed to open /tmp/ftmrr.txt"); |
| 4025 | return; |
| 4026 | } |
| 4027 | |
| 4028 | fprintf(f, |
| 4029 | "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", |
| 4030 | dut->ap_val_neighap[0][0], dut->ap_val_neighap[0][1], |
| 4031 | dut->ap_val_neighap[0][2], dut->ap_val_neighap[0][3], |
| 4032 | dut->ap_val_neighap[0][4], dut->ap_val_neighap[0][5], |
| 4033 | dut->ap_val_opchannel[0]); |
| 4034 | fclose(f); |
| 4035 | } |
| 4036 | |
| 4037 | if (dut->ap_neighap >= 2 && dut->ap_lci == 0) { |
| 4038 | FILE *f; |
| 4039 | |
| 4040 | f = fopen("/tmp/nbr_report.txt", "a"); |
| 4041 | if (!f) { |
| 4042 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4043 | "Failed to open /tmp/nbr_report.txt"); |
| 4044 | return; |
| 4045 | } |
| 4046 | fprintf(f, |
| 4047 | "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", |
| 4048 | dut->ap_val_neighap[1][0], dut->ap_val_neighap[1][1], |
| 4049 | dut->ap_val_neighap[1][2], dut->ap_val_neighap[1][3], |
| 4050 | dut->ap_val_neighap[1][4], dut->ap_val_neighap[1][5], |
| 4051 | dut->ap_val_opchannel[1]); |
| 4052 | fclose(f); |
| 4053 | |
| 4054 | f = fopen("/tmp/ftmrr.txt", "a"); |
| 4055 | if (!f) { |
| 4056 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4057 | "Failed to open /tmp/ftmrr.txt"); |
| 4058 | return; |
| 4059 | } |
| 4060 | fprintf(f, |
| 4061 | "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", |
| 4062 | dut->ap_val_neighap[1][0], dut->ap_val_neighap[1][1], |
| 4063 | dut->ap_val_neighap[1][2], dut->ap_val_neighap[1][3], |
| 4064 | dut->ap_val_neighap[1][4], dut->ap_val_neighap[1][5], |
| 4065 | dut->ap_val_opchannel[1]); |
| 4066 | fclose(f); |
| 4067 | } |
| 4068 | |
| 4069 | if (dut->ap_neighap >= 3 && dut->ap_lci == 0) { |
| 4070 | FILE *f; |
| 4071 | |
| 4072 | f = fopen("/tmp/nbr_report.txt", "a"); |
| 4073 | if (!f) { |
| 4074 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4075 | "Failed to open /tmp/nbr_report.txt"); |
| 4076 | return; |
| 4077 | } |
| 4078 | |
| 4079 | fprintf(f, |
| 4080 | "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", |
| 4081 | dut->ap_val_neighap[2][0], dut->ap_val_neighap[2][1], |
| 4082 | dut->ap_val_neighap[2][2], dut->ap_val_neighap[2][3], |
| 4083 | dut->ap_val_neighap[2][4], dut->ap_val_neighap[2][5], |
| 4084 | dut->ap_val_opchannel[2]); |
| 4085 | fclose(f); |
| 4086 | |
| 4087 | f = fopen("/tmp/ftmrr.txt", "a"); |
| 4088 | if (!f) { |
| 4089 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4090 | "Failed to open /tmp/ftmrr.txt"); |
| 4091 | return; |
| 4092 | } |
| 4093 | |
| 4094 | fprintf(f, |
| 4095 | "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", |
| 4096 | dut->ap_val_neighap[2][0], dut->ap_val_neighap[2][1], |
| 4097 | dut->ap_val_neighap[2][2], dut->ap_val_neighap[2][3], |
| 4098 | dut->ap_val_neighap[2][4], dut->ap_val_neighap[2][5], |
| 4099 | dut->ap_val_opchannel[2]); |
| 4100 | fclose(f); |
| 4101 | } |
| 4102 | |
| 4103 | if (dut->ap_neighap) { |
| 4104 | snprintf(buf, sizeof(buf), "iwpriv %s enable_rtt 1", ifname); |
| 4105 | run_system(dut, buf); |
| 4106 | snprintf(buf, sizeof(buf), "iwpriv %s enable_lci 1", ifname); |
| 4107 | run_system(dut, buf); |
| 4108 | snprintf(buf, sizeof(buf), "iwpriv %s enable_lcr 1", ifname); |
| 4109 | run_system(dut, buf); |
| 4110 | snprintf(buf, sizeof(buf), "iwpriv %s rrm 1", ifname); |
| 4111 | run_system(dut, buf); |
| 4112 | } |
| 4113 | |
| 4114 | if (dut->ap_scan == 1) { |
| 4115 | snprintf(buf, sizeof(buf), "iwpriv %s scanentryage 600", |
| 4116 | ifname); |
| 4117 | run_system(dut, buf); |
| 4118 | snprintf(buf, sizeof(buf), "iwlist %s scan", ifname); |
| 4119 | run_system(dut, buf); |
| 4120 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4121 | } |
| 4122 | |
| 4123 | |
| 4124 | static int cmd_ath_ap_config_commit(struct sigma_dut *dut, |
| 4125 | struct sigma_conn *conn, |
| 4126 | struct sigma_cmd *cmd) |
| 4127 | { |
| 4128 | /* const char *name = get_param(cmd, "NAME"); */ |
| 4129 | char buf[100]; |
| 4130 | struct stat s; |
| 4131 | const char *ifname = dut->ap_is_dual ? "ath1" : "ath0"; |
| 4132 | |
| 4133 | if (stat("/proc/athversion", &s) == 0) { |
| 4134 | sigma_dut_print(dut, DUT_MSG_INFO, "Run apdown"); |
| 4135 | run_system(dut, "apdown"); |
| 4136 | } |
| 4137 | |
| 4138 | cmd_ath_ap_radio_config(dut); |
| 4139 | |
| 4140 | snprintf(buf, sizeof(buf), "cfg -a 'AP_SSID=%s'", dut->ap_ssid); |
| 4141 | run_system(dut, buf); |
| 4142 | |
| 4143 | switch (dut->ap_key_mgmt) { |
| 4144 | case AP_OPEN: |
| 4145 | if (dut->ap_cipher == AP_WEP) { |
| 4146 | run_system(dut, "cfg -a AP_SECMODE=WEP"); |
| 4147 | run_system(dut, "cfg -a AP_SECFILE=NONE"); |
| 4148 | /* shared auth mode not supported */ |
| 4149 | run_system(dut, "cfg -a AP_WEP_MODE_0=1"); |
| 4150 | run_system(dut, "cfg -a AP_WEP_MODE_1=1"); |
| 4151 | snprintf(buf, sizeof(buf), |
| 4152 | "cfg -a WEP_RADIO_NUM0_KEY_1=%s", |
| 4153 | dut->ap_wepkey); |
| 4154 | run_system(dut, buf); |
| 4155 | snprintf(buf, sizeof(buf), |
| 4156 | "cfg -a WEP_RADIO_NUM1_KEY_1=%s", |
| 4157 | dut->ap_wepkey); |
| 4158 | run_system(dut, buf); |
| 4159 | } else { |
| 4160 | run_system(dut, "cfg -a AP_SECMODE=None"); |
| 4161 | } |
| 4162 | break; |
| 4163 | case AP_WPA2_PSK: |
| 4164 | case AP_WPA2_PSK_MIXED: |
| 4165 | case AP_WPA_PSK: |
| 4166 | if (dut->ap_key_mgmt == AP_WPA2_PSK) |
| 4167 | run_system(dut, "cfg -a AP_WPA=2"); |
| 4168 | else if (dut->ap_key_mgmt == AP_WPA2_PSK_MIXED) |
| 4169 | run_system(dut, "cfg -a AP_WPA=3"); |
| 4170 | else |
| 4171 | run_system(dut, "cfg -a AP_WPA=1"); |
| 4172 | run_system(dut, "cfg -a AP_SECMODE=WPA"); |
| 4173 | run_system(dut, "cfg -a AP_SECFILE=PSK"); |
| 4174 | snprintf(buf, sizeof(buf), "cfg -a 'PSK_KEY=%s'", |
| 4175 | dut->ap_passphrase); |
| 4176 | run_system(dut, buf); |
| 4177 | if (dut->ap_cipher == AP_CCMP_TKIP) |
| 4178 | run_system(dut, "cfg -a AP_CYPHER=\"CCMP TKIP\""); |
| 4179 | else if (dut->ap_cipher == AP_TKIP) |
| 4180 | run_system(dut, "cfg -a AP_CYPHER=TKIP"); |
| 4181 | else |
| 4182 | run_system(dut, "cfg -a AP_CYPHER=CCMP"); |
| 4183 | break; |
| 4184 | case AP_WPA2_EAP: |
| 4185 | case AP_WPA2_EAP_MIXED: |
| 4186 | case AP_WPA_EAP: |
| 4187 | if (dut->ap_key_mgmt == AP_WPA2_EAP) |
| 4188 | run_system(dut, "cfg -a AP_WPA=2"); |
| 4189 | else if (dut->ap_key_mgmt == AP_WPA2_EAP_MIXED) |
| 4190 | run_system(dut, "cfg -a AP_WPA=3"); |
| 4191 | else |
| 4192 | run_system(dut, "cfg -a AP_WPA=1"); |
| 4193 | run_system(dut, "cfg -a AP_SECMODE=WPA"); |
| 4194 | run_system(dut, "cfg -a AP_SECFILE=EAP"); |
| 4195 | if (dut->ap_cipher == AP_CCMP_TKIP) |
| 4196 | run_system(dut, "cfg -a AP_CYPHER=\"CCMP TKIP\""); |
| 4197 | else if (dut->ap_cipher == AP_TKIP) |
| 4198 | run_system(dut, "cfg -a AP_CYPHER=TKIP"); |
| 4199 | else |
| 4200 | run_system(dut, "cfg -a AP_CYPHER=CCMP"); |
| 4201 | snprintf(buf, sizeof(buf), "cfg -a AP_AUTH_SERVER=%s", |
| 4202 | dut->ap_radius_ipaddr); |
| 4203 | run_system(dut, buf); |
| 4204 | snprintf(buf, sizeof(buf), "cfg -a AP_AUTH_PORT=%d", |
| 4205 | dut->ap_radius_port); |
| 4206 | run_system(dut, buf); |
| 4207 | snprintf(buf, sizeof(buf), "cfg -a AP_AUTH_SECRET=%s", |
| 4208 | dut->ap_radius_password); |
| 4209 | run_system(dut, buf); |
| 4210 | break; |
| 4211 | } |
| 4212 | |
| 4213 | if (dut->ap_is_dual) { |
| 4214 | /* ath1 settings in case of dual */ |
| 4215 | snprintf(buf, sizeof(buf), "cfg -a 'AP_SSID_2=%s'", |
| 4216 | dut->ap_ssid); |
| 4217 | run_system(dut, buf); |
| 4218 | |
| 4219 | switch (dut->ap_key_mgmt) { |
| 4220 | case AP_OPEN: |
| 4221 | if (dut->ap_cipher == AP_WEP) { |
| 4222 | run_system(dut, "cfg -a AP_SECMODE_2=WEP"); |
| 4223 | run_system(dut, "cfg -a AP_SECFILE_2=NONE"); |
| 4224 | /* shared auth mode not supported */ |
| 4225 | run_system(dut, "cfg -a AP_WEP_MODE_0=1"); |
| 4226 | run_system(dut, "cfg -a AP_WEP_MODE_1=1"); |
| 4227 | snprintf(buf, sizeof(buf), |
| 4228 | "cfg -a WEP_RADIO_NUM0_KEY_1=%s", |
| 4229 | dut->ap_wepkey); |
| 4230 | run_system(dut, buf); |
| 4231 | snprintf(buf, sizeof(buf), |
| 4232 | "cfg -a WEP_RADIO_NUM1_KEY_1=%s", |
| 4233 | dut->ap_wepkey); |
| 4234 | run_system(dut, buf); |
| 4235 | } else { |
| 4236 | run_system(dut, "cfg -a AP_SECMODE_2=None"); |
| 4237 | } |
| 4238 | break; |
| 4239 | case AP_WPA2_PSK: |
| 4240 | case AP_WPA2_PSK_MIXED: |
| 4241 | case AP_WPA_PSK: |
| 4242 | if (dut->ap_key_mgmt == AP_WPA2_PSK) |
| 4243 | run_system(dut, "cfg -a AP_WPA_2=2"); |
| 4244 | else if (dut->ap_key_mgmt == AP_WPA2_PSK_MIXED) |
| 4245 | run_system(dut, "cfg -a AP_WPA_2=3"); |
| 4246 | else |
| 4247 | run_system(dut, "cfg -a AP_WPA_2=1"); |
| 4248 | // run_system(dut, "cfg -a AP_WPA_2=2"); |
| 4249 | run_system(dut, "cfg -a AP_SECMODE_2=WPA"); |
| 4250 | run_system(dut, "cfg -a AP_SECFILE_2=PSK"); |
| 4251 | snprintf(buf, sizeof(buf), "cfg -a 'PSK_KEY_2=%s'", |
| 4252 | dut->ap_passphrase); |
| 4253 | run_system(dut, buf); |
| 4254 | if (dut->ap_cipher == AP_CCMP_TKIP) |
| 4255 | run_system(dut, "cfg -a AP_CYPHER_2=\"CCMP TKIP\""); |
| 4256 | else if (dut->ap_cipher == AP_TKIP) |
| 4257 | run_system(dut, "cfg -a AP_CYPHER_2=TKIP"); |
| 4258 | else |
| 4259 | run_system(dut, "cfg -a AP_CYPHER_2=CCMP"); |
| 4260 | break; |
| 4261 | case AP_WPA2_EAP: |
| 4262 | case AP_WPA2_EAP_MIXED: |
| 4263 | case AP_WPA_EAP: |
| 4264 | if (dut->ap_key_mgmt == AP_WPA2_EAP) |
| 4265 | run_system(dut, "cfg -a AP_WPA_2=2"); |
| 4266 | else if (dut->ap_key_mgmt == AP_WPA2_EAP_MIXED) |
| 4267 | run_system(dut, "cfg -a AP_WPA_2=3"); |
| 4268 | else |
| 4269 | run_system(dut, "cfg -a AP_WPA_2=1"); |
| 4270 | run_system(dut, "cfg -a AP_SECMODE_2=WPA"); |
| 4271 | run_system(dut, "cfg -a AP_SECFILE_2=EAP"); |
| 4272 | if (dut->ap_cipher == AP_CCMP_TKIP) |
| 4273 | run_system(dut, "cfg -a AP_CYPHER_2=\"CCMP TKIP\""); |
| 4274 | else if (dut->ap_cipher == AP_TKIP) |
| 4275 | run_system(dut, "cfg -a AP_CYPHER_2=TKIP"); |
| 4276 | else |
| 4277 | run_system(dut, "cfg -a AP_CYPHER_2=CCMP"); |
| 4278 | |
| 4279 | snprintf(buf, sizeof(buf), "cfg -a AP_AUTH_SERVER_2=%s", |
| 4280 | dut->ap_radius_ipaddr); |
| 4281 | run_system(dut, buf); |
| 4282 | snprintf(buf, sizeof(buf), "cfg -a AP_AUTH_PORT_2=%d", |
| 4283 | dut->ap_radius_port); |
| 4284 | run_system(dut, buf); |
| 4285 | snprintf(buf, sizeof(buf), "cfg -a AP_AUTH_SECRET_2=%s", |
| 4286 | dut->ap_radius_password); |
| 4287 | run_system(dut, buf); |
| 4288 | break; |
| 4289 | } |
| 4290 | |
| 4291 | /* wifi0 settings in case of dual */ |
| 4292 | run_system(dut, "cfg -a AP_RADIO_ID=0"); |
| 4293 | run_system(dut, "cfg -a AP_PRIMARY_CH=6"); |
| 4294 | run_system(dut, "cfg -a AP_STARTMODE=dual"); |
| 4295 | run_system(dut, "cfg -a AP_CHMODE=11NGHT40PLUS"); |
| 4296 | run_system(dut, "cfg -a TX_CHAINMASK=7"); |
| 4297 | run_system(dut, "cfg -a RX_CHAINMASK=7"); |
| 4298 | } |
| 4299 | |
| 4300 | switch (dut->ap_pmf) { |
| 4301 | case AP_PMF_DISABLED: |
| 4302 | snprintf(buf, sizeof(buf), "cfg -a AP_PMF=0"); |
| 4303 | run_system(dut, buf); |
| 4304 | break; |
| 4305 | case AP_PMF_OPTIONAL: |
| 4306 | snprintf(buf, sizeof(buf), "cfg -a AP_PMF=1"); |
| 4307 | run_system(dut, buf); |
| 4308 | break; |
| 4309 | case AP_PMF_REQUIRED: |
| 4310 | snprintf(buf, sizeof(buf), "cfg -a AP_PMF=2"); |
| 4311 | run_system(dut, buf); |
| 4312 | break; |
| 4313 | } |
| 4314 | if (dut->ap_add_sha256) { |
| 4315 | snprintf(buf, sizeof(buf), "cfg -a AP_WPA_SHA256=1"); |
| 4316 | run_system(dut, buf); |
| 4317 | } else { |
| 4318 | snprintf(buf, sizeof(buf), "cfg -r AP_WPA_SHA256"); |
| 4319 | run_system(dut, buf); |
| 4320 | } |
| 4321 | |
| 4322 | if (dut->ap_hs2) |
| 4323 | run_system(dut, "cfg -a AP_HOTSPOT=1"); |
| 4324 | else |
| 4325 | run_system(dut, "cfg -r AP_HOTSPOT"); |
| 4326 | |
| 4327 | if (dut->ap_interworking) { |
| 4328 | snprintf(buf, sizeof(buf), "cfg -a AP_HOTSPOT_ANT=%d", |
| 4329 | dut->ap_access_net_type); |
| 4330 | run_system(dut, buf); |
| 4331 | snprintf(buf, sizeof(buf), "cfg -a AP_HOTSPOT_INTERNET=%d", |
| 4332 | dut->ap_internet); |
| 4333 | run_system(dut, buf); |
| 4334 | snprintf(buf, sizeof(buf), "cfg -a AP_HOTSPOT_VENUEGROUP=%d", |
| 4335 | dut->ap_venue_group); |
| 4336 | run_system(dut, buf); |
| 4337 | snprintf(buf, sizeof(buf), "cfg -a AP_HOTSPOT_VENUETYPE=%d", |
| 4338 | dut->ap_venue_type); |
| 4339 | run_system(dut, buf); |
| 4340 | snprintf(buf, sizeof(buf), "cfg -a AP_HOTSPOT_HESSID=%s", |
| 4341 | dut->ap_hessid); |
| 4342 | run_system(dut, buf); |
| 4343 | |
| 4344 | if (dut->ap_roaming_cons[0]) { |
| 4345 | char *second, *rc; |
| 4346 | rc = strdup(dut->ap_roaming_cons); |
| 4347 | if (rc == NULL) |
| 4348 | return 0; |
| 4349 | |
| 4350 | second = strchr(rc, ';'); |
| 4351 | if (second) |
| 4352 | *second++ = '\0'; |
| 4353 | |
| 4354 | snprintf(buf, sizeof(buf), |
| 4355 | "cfg -a AP_HOTSPOT_ROAMINGCONSORTIUM=%s", rc); |
| 4356 | run_system(dut, buf); |
| 4357 | |
| 4358 | if (second) { |
| 4359 | snprintf(buf, sizeof(buf), |
| 4360 | "cfg -a AP_HOTSPOT_ROAMINGCONSORTIUM2" |
| 4361 | "=%s", second); |
| 4362 | run_system(dut, buf); |
| 4363 | } |
| 4364 | free(rc); |
| 4365 | } else { |
| 4366 | run_system(dut, "cfg -r AP_HOTSPOT_ROAMINGCONSORTIUM"); |
| 4367 | run_system(dut, |
| 4368 | "cfg -r AP_HOTSPOT_ROAMINGCONSORTIUM2"); |
| 4369 | } |
| 4370 | } else { |
| 4371 | run_system(dut, "cfg -r AP_HOTSPOT_ANT"); |
| 4372 | run_system(dut, "cfg -r AP_HOTSPOT_INTERNET"); |
| 4373 | run_system(dut, "cfg -r AP_HOTSPOT_VENUEGROUP"); |
| 4374 | run_system(dut, "cfg -r AP_HOTSPOT_VENUETYPE"); |
| 4375 | run_system(dut, "cfg -r AP_HOTSPOT_HESSID"); |
| 4376 | run_system(dut, "cfg -r AP_HOTSPOT_ROAMINGCONSORTIUM"); |
| 4377 | run_system(dut, "cfg -r AP_HOTSPOT_ROAMINGCONSORTIUM2"); |
| 4378 | } |
| 4379 | |
| 4380 | if (dut->ap_proxy_arp) |
| 4381 | run_system(dut, "cfg -a IEEE80211V_PROXYARP=1"); |
| 4382 | else |
| 4383 | run_system(dut, "cfg -a IEEE80211V_PROXYARP=0"); |
| 4384 | if (dut->ap_dgaf_disable) |
| 4385 | run_system(dut, "cfg -a AP_HOTSPOT_DISABLE_DGAF=1"); |
| 4386 | else |
| 4387 | run_system(dut, "cfg -r AP_HOTSPOT_DISABLE_DGAF"); |
| 4388 | |
| 4389 | if (strlen(dut->ap2_ssid)) { |
| 4390 | snprintf(buf, sizeof(buf), |
| 4391 | "cfg -a AP_SSID_2=%s", dut->ap2_ssid); |
| 4392 | run_system(dut, buf); |
| 4393 | |
| 4394 | if (dut->ap2_key_mgmt == AP2_OSEN) { |
| 4395 | run_system(dut, "cfg -a AP_SECMODE_2=WPA"); |
| 4396 | run_system(dut, "cfg -a AP_SECFILE_2=OSEN"); |
| 4397 | |
| 4398 | snprintf(buf, sizeof(buf), "cfg -a AP_AUTH_SERVER_2=%s", |
| 4399 | dut->ap2_radius_ipaddr); |
| 4400 | run_system(dut, buf); |
| 4401 | |
| 4402 | snprintf(buf, sizeof(buf), "cfg -a AP_AUTH_PORT_2=%d", |
| 4403 | dut->ap2_radius_port); |
| 4404 | run_system(dut, buf); |
| 4405 | |
| 4406 | snprintf(buf, sizeof(buf), "cfg -a AP_AUTH_SECRET_2=%s", |
| 4407 | dut->ap2_radius_password); |
| 4408 | run_system(dut, buf); |
| 4409 | } else { |
| 4410 | run_system(dut, "cfg -a AP_SECMODE_2=None"); |
| 4411 | run_system(dut, "cfg -r AP_AUTH_SERVER_2"); |
| 4412 | run_system(dut, "cfg -r AP_AUTH_PORT_2"); |
| 4413 | run_system(dut, "cfg -r AP_AUTH_SECRET_2"); |
| 4414 | } |
| 4415 | |
| 4416 | run_system(dut, "cfg -a AP_STARTMODE=multi"); |
| 4417 | } |
| 4418 | |
| 4419 | run_system(dut, "cfg -c"); |
| 4420 | |
| 4421 | sigma_dut_print(dut, DUT_MSG_INFO, "Starting AP"); |
| 4422 | if (system("apup") != 0) { |
| 4423 | /* to be debugged why apup returns error |
| 4424 | send_resp(dut, conn, SIGMA_ERROR, |
| 4425 | "errorCode,apup failed"); |
| 4426 | return 0; |
| 4427 | */ |
| 4428 | } |
| 4429 | sigma_dut_print(dut, DUT_MSG_INFO, "AP started"); |
| 4430 | |
| 4431 | if (dut->ap_key_mgmt != AP_OPEN) { |
| 4432 | int res; |
| 4433 | /* allow some time for hostapd to start before returning |
| 4434 | * success */ |
| 4435 | usleep(500000); |
| 4436 | if (run_hostapd_cli(dut, "ping") != 0) { |
| 4437 | send_resp(dut, conn, SIGMA_ERROR, |
| 4438 | "errorCode,Failed to talk to hostapd"); |
| 4439 | return 0; |
| 4440 | } |
| 4441 | |
| 4442 | if (dut->ap_hs2 && !dut->ap_anqpserver) { |
| 4443 | /* the cfg app doesn't like ";" in the variables */ |
| 4444 | res = ath_ap_append_hostapd_conf(dut); |
| 4445 | if (res < 0) |
| 4446 | return res; |
| 4447 | |
| 4448 | /* wait for hostapd to be ready */ |
| 4449 | usleep(500000); |
| 4450 | if (run_hostapd_cli(dut, "ping") != 0) { |
| 4451 | send_resp(dut, conn, SIGMA_ERROR, |
| 4452 | "errorCode,Failed to talk to " |
| 4453 | "hostapd"); |
| 4454 | return 0; |
| 4455 | } |
| 4456 | } |
| 4457 | } |
| 4458 | |
| 4459 | ath_ap_set_params(dut); |
| 4460 | |
| 4461 | if (dut->ap_anqpserver) |
| 4462 | return cmd_ath_ap_anqpserver_start(dut); |
| 4463 | |
| 4464 | if (dut->ap2_proxy_arp) |
| 4465 | run_system(dut, "iwpriv ath1 proxy_arp 1"); |
| 4466 | |
| 4467 | if (dut->ap_allow_vht_wep || dut->ap_allow_vht_tkip) { |
| 4468 | snprintf(buf, sizeof(buf), "iwpriv %s htweptkip 1", ifname); |
| 4469 | if (system(buf) != 0) { |
| 4470 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4471 | "iwpriv htweptkip failed"); |
| 4472 | } |
| 4473 | } |
| 4474 | |
| 4475 | return 1; |
| 4476 | } |
| 4477 | |
| 4478 | |
| 4479 | static int set_ebtables_proxy_arp(struct sigma_dut *dut, const char *chain, |
| 4480 | const char *ifname) |
| 4481 | { |
| 4482 | char buf[200]; |
| 4483 | |
| 4484 | if (!chain || !ifname) |
| 4485 | return -2; |
| 4486 | |
| 4487 | snprintf(buf, sizeof(buf), "ebtables -P %s ACCEPT", chain); |
| 4488 | if (system(buf) != 0) { |
| 4489 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4490 | "Failed to set ebtables rules, RULE-1, %s", |
| 4491 | chain); |
| 4492 | return -2; |
| 4493 | } |
| 4494 | |
| 4495 | snprintf(buf, sizeof(buf), |
| 4496 | "ebtables -A %s -p ARP -d Broadcast -o %s -j DROP", |
| 4497 | chain, ifname); |
| 4498 | if (system(buf) != 0) { |
| 4499 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4500 | "Failed to set ebtables rules, RULE-2, %s", |
| 4501 | chain); |
| 4502 | return -2; |
| 4503 | } |
| 4504 | |
| 4505 | snprintf(buf, sizeof(buf), |
| 4506 | "ebtables -A %s -d Multicast -p IPv6 --ip6-protocol ipv6-icmp --ip6-icmp-type neighbor-solicitation -o %s -j DROP", |
| 4507 | chain, ifname); |
| 4508 | if (system(buf) != 0) { |
| 4509 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4510 | "Failed to set ebtables rules, RULE-3, %s", |
| 4511 | chain); |
| 4512 | return -2; |
| 4513 | } |
| 4514 | |
| 4515 | snprintf(buf, sizeof(buf), |
| 4516 | "ebtables -A %s -d Multicast -p IPv6 --ip6-protocol ipv6-icmp --ip6-icmp-type neighbor-advertisement -o %s -j DROP", |
| 4517 | chain, ifname); |
| 4518 | if (system(buf) != 0) { |
| 4519 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4520 | "Failed to set ebtables rules, RULE-4, %s", |
| 4521 | chain); |
| 4522 | return -2; |
| 4523 | } |
| 4524 | |
| 4525 | return 0; |
| 4526 | } |
| 4527 | |
| 4528 | |
| 4529 | static int set_ebtables_disable_dgaf(struct sigma_dut *dut, |
| 4530 | const char *chain, |
| 4531 | const char *ifname) |
| 4532 | { |
| 4533 | char buf[200]; |
| 4534 | |
| 4535 | if (!chain || !ifname) |
| 4536 | return -2; |
| 4537 | |
| 4538 | snprintf(buf, sizeof(buf), "ebtables -P %s ACCEPT", chain); |
| 4539 | if (system(buf) != 0) { |
| 4540 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4541 | "Failed to set ebtables rules, RULE-5, %s", |
| 4542 | chain); |
| 4543 | return -2; |
| 4544 | } |
| 4545 | |
| 4546 | snprintf(buf, sizeof(buf), |
| 4547 | "ebtables -A %s -p ARP -d Broadcast -o %s -j DROP", |
| 4548 | chain, ifname); |
| 4549 | if (system(buf) != 0) { |
| 4550 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4551 | "Failed to set ebtables rules, RULE-6, %s", |
| 4552 | chain); |
| 4553 | return -2; |
| 4554 | } |
| 4555 | |
| 4556 | snprintf(buf, sizeof(buf), |
| 4557 | "ebtables -A %s -p IPv4 -d Multicast -o %s -j DROP", |
| 4558 | chain, ifname); |
| 4559 | if (system(buf) != 0) { |
| 4560 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4561 | "Failed to set ebtables rules, RULE-7, %s", |
| 4562 | chain); |
| 4563 | return -2; |
| 4564 | } |
| 4565 | |
| 4566 | snprintf(buf, sizeof(buf), |
| 4567 | "ebtables -A %s -p IPv6 -d Multicast -o %s -j DROP", |
| 4568 | chain, ifname); |
| 4569 | if (system(buf) != 0) { |
| 4570 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4571 | "Failed to set ebtables rules, RULE-8, %s", |
| 4572 | chain); |
| 4573 | return -2; |
| 4574 | } |
| 4575 | |
| 4576 | return 0; |
| 4577 | } |
| 4578 | |
| 4579 | |
| 4580 | static int check_channel(int channel) |
| 4581 | { |
| 4582 | int channel_list[] = { 36, 40, 44, 48, 52, 60, 64, 100, 104, 108, 112, |
| 4583 | 116, 120, 124, 128, 132, 140, 144, 149, 153, 157, |
| 4584 | 161, 165 }; |
| 4585 | int num_chan = sizeof(channel_list) / sizeof(int); |
| 4586 | int i; |
| 4587 | |
| 4588 | for (i = 0; i < num_chan; i++) { |
| 4589 | if (channel == channel_list[i]) |
| 4590 | return i; |
| 4591 | } |
| 4592 | |
| 4593 | return -1; |
| 4594 | } |
| 4595 | |
| 4596 | |
| 4597 | static int get_oper_centr_freq_seq_idx(int chwidth, int channel) |
| 4598 | { |
| 4599 | int ch_base; |
| 4600 | int period; |
| 4601 | |
| 4602 | if (check_channel(channel) < 0) |
| 4603 | return -1; |
| 4604 | |
| 4605 | if (channel >= 36 && channel <= 64) |
| 4606 | ch_base = 36; |
| 4607 | else if (channel >= 100 && channel <= 144) |
| 4608 | ch_base = 100; |
| 4609 | else |
| 4610 | ch_base = 149; |
| 4611 | |
| 4612 | period = channel % ch_base * 5 / chwidth; |
| 4613 | return ch_base + period * chwidth / 5 + (chwidth - 20) / 10; |
| 4614 | } |
| 4615 | |
| 4616 | |
| 4617 | static int is_ht40plus_chan(int chan) |
| 4618 | { |
| 4619 | return chan == 36 || chan == 44 || chan == 52 || chan == 60 || |
| 4620 | chan == 100 || chan == 108 || chan == 116 || chan == 124 || |
| 4621 | chan == 132 || chan == 149 || chan == 157; |
| 4622 | } |
| 4623 | |
| 4624 | |
| 4625 | static int is_ht40minus_chan(int chan) |
| 4626 | { |
| 4627 | return chan == 40 || chan == 48 || chan == 56 || chan == 64 || |
| 4628 | chan == 104 || chan == 112 || chan == 120 || chan == 128 || |
| 4629 | chan == 136 || chan == 153 || chan == 161; |
| 4630 | } |
| 4631 | |
| 4632 | |
| 4633 | static int cmd_ap_config_commit(struct sigma_dut *dut, struct sigma_conn *conn, |
| 4634 | struct sigma_cmd *cmd) |
| 4635 | { |
| 4636 | /* const char *name = get_param(cmd, "NAME"); */ |
| 4637 | FILE *f; |
| 4638 | const char *ifname; |
| 4639 | char buf[500]; |
| 4640 | char path[100]; |
| 4641 | enum driver_type drv; |
| 4642 | |
| 4643 | drv = get_driver_type(); |
| 4644 | |
| 4645 | if (dut->mode == SIGMA_MODE_STATION) { |
| 4646 | stop_sta_mode(dut); |
| 4647 | sleep(1); |
| 4648 | } |
| 4649 | |
| 4650 | if (dut->mode == SIGMA_MODE_SNIFFER && dut->sniffer_ifname) { |
| 4651 | snprintf(buf, sizeof(buf), "ifconfig %s down", |
| 4652 | dut->sniffer_ifname); |
| 4653 | if (system(buf) != 0) { |
| 4654 | sigma_dut_print(dut, DUT_MSG_INFO, |
| 4655 | "Failed to run '%s'", buf); |
| 4656 | } |
| 4657 | snprintf(buf, sizeof(buf), "iw dev %s set type station", |
| 4658 | dut->sniffer_ifname); |
| 4659 | if (system(buf) != 0) { |
| 4660 | sigma_dut_print(dut, DUT_MSG_INFO, |
| 4661 | "Failed to run '%s'", buf); |
| 4662 | } |
| 4663 | } |
| 4664 | |
| 4665 | dut->mode = SIGMA_MODE_AP; |
| 4666 | |
| 4667 | if (drv == DRIVER_ATHEROS) |
| 4668 | return cmd_ath_ap_config_commit(dut, conn, cmd); |
| 4669 | if (drv == DRIVER_WCN) |
| 4670 | return cmd_wcn_ap_config_commit(dut, conn, cmd); |
| 4671 | if (drv == DRIVER_OPENWRT) |
| 4672 | return cmd_owrt_ap_config_commit(dut, conn, cmd); |
| 4673 | |
| 4674 | f = fopen(SIGMA_TMPDIR "/sigma_dut-ap.conf", "w"); |
| 4675 | if (f == NULL) { |
| 4676 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4677 | "%s: Failed to open sigma_dut-ap.conf", |
| 4678 | __func__); |
| 4679 | return -2; |
| 4680 | } |
| 4681 | switch (dut->ap_mode) { |
| 4682 | case AP_11g: |
| 4683 | case AP_11b: |
| 4684 | case AP_11ng: |
Sreelakshmi Konamki | b692f10 | 2016-04-26 19:47:00 +0530 | [diff] [blame] | 4685 | ifname = (drv == DRIVER_MAC80211 || drv == DRIVER_LINUX_WCN) ? |
| 4686 | "wlan0" : "ath0"; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4687 | if (drv == DRIVER_QNXNTO && sigma_main_ifname) |
| 4688 | ifname = sigma_main_ifname; |
| 4689 | fprintf(f, "hw_mode=g\n"); |
| 4690 | break; |
| 4691 | case AP_11a: |
| 4692 | case AP_11na: |
| 4693 | case AP_11ac: |
| 4694 | if (drv == DRIVER_QNXNTO) { |
| 4695 | if (sigma_main_ifname) |
| 4696 | ifname = sigma_main_ifname; |
| 4697 | else |
| 4698 | ifname = "wlan0"; |
Sreelakshmi Konamki | b692f10 | 2016-04-26 19:47:00 +0530 | [diff] [blame] | 4699 | } else if (drv == DRIVER_MAC80211 || drv == DRIVER_LINUX_WCN) { |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4700 | if (if_nametoindex("wlan1") > 0) |
| 4701 | ifname = "wlan1"; |
| 4702 | else |
| 4703 | ifname = "wlan0"; |
| 4704 | } else { |
| 4705 | ifname = get_main_ifname(); |
| 4706 | } |
| 4707 | fprintf(f, "hw_mode=a\n"); |
| 4708 | break; |
| 4709 | default: |
| 4710 | fclose(f); |
| 4711 | return -1; |
| 4712 | } |
| 4713 | |
Sreelakshmi Konamki | b692f10 | 2016-04-26 19:47:00 +0530 | [diff] [blame] | 4714 | if (drv == DRIVER_MAC80211 || drv == DRIVER_LINUX_WCN) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4715 | fprintf(f, "driver=nl80211\n"); |
| 4716 | |
Sreelakshmi Konamki | b692f10 | 2016-04-26 19:47:00 +0530 | [diff] [blame] | 4717 | if ((drv == DRIVER_MAC80211 || drv == DRIVER_QNXNTO || |
| 4718 | drv == DRIVER_LINUX_WCN) && |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4719 | (dut->ap_mode == AP_11ng || dut->ap_mode == AP_11na)) { |
| 4720 | fprintf(f, "ieee80211n=1\n"); |
Mohammed Shafi Shajakhan | 31d8a15 | 2016-06-02 20:10:55 +0530 | [diff] [blame] | 4721 | fprintf(f, "ht_capab="); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4722 | if (dut->ap_mode == AP_11ng && dut->ap_chwidth == AP_40) { |
| 4723 | if (dut->ap_channel >= 1 && dut->ap_channel <= 7) |
Mohammed Shafi Shajakhan | 31d8a15 | 2016-06-02 20:10:55 +0530 | [diff] [blame] | 4724 | fprintf(f, "[HT40+]"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4725 | else if (dut->ap_channel >= 8 && dut->ap_channel <= 11) |
Mohammed Shafi Shajakhan | 31d8a15 | 2016-06-02 20:10:55 +0530 | [diff] [blame] | 4726 | fprintf(f, "[HT40-]"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4727 | } |
| 4728 | |
| 4729 | /* configure ht_capab based on channel width */ |
| 4730 | if (dut->ap_mode == AP_11na && |
| 4731 | (dut->ap_chwidth == AP_40 || |
| 4732 | (dut->ap_chwidth == AP_AUTO && |
| 4733 | dut->default_ap_chwidth == AP_40))) { |
| 4734 | if (is_ht40plus_chan(dut->ap_channel)) |
Mohammed Shafi Shajakhan | 31d8a15 | 2016-06-02 20:10:55 +0530 | [diff] [blame] | 4735 | fprintf(f, "[HT40+]"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4736 | else if (is_ht40minus_chan(dut->ap_channel)) |
Mohammed Shafi Shajakhan | 31d8a15 | 2016-06-02 20:10:55 +0530 | [diff] [blame] | 4737 | fprintf(f, "[HT40-]"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4738 | } |
Mohammed Shafi Shajakhan | 31d8a15 | 2016-06-02 20:10:55 +0530 | [diff] [blame] | 4739 | |
| 4740 | if (dut->ap_tx_stbc) |
| 4741 | fprintf(f, "[TX-STBC]"); |
| 4742 | |
| 4743 | fprintf(f, "\n"); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4744 | } |
| 4745 | |
Sreelakshmi Konamki | b692f10 | 2016-04-26 19:47:00 +0530 | [diff] [blame] | 4746 | if ((drv == DRIVER_MAC80211 || drv == DRIVER_QNXNTO || |
| 4747 | drv == DRIVER_LINUX_WCN) && |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4748 | dut->ap_mode == AP_11ac) { |
| 4749 | fprintf(f, "ieee80211ac=1\n" |
| 4750 | "ieee80211n=1\n" |
| 4751 | "ht_capab=[HT40+]\n"); |
| 4752 | } |
| 4753 | |
Sreelakshmi Konamki | b692f10 | 2016-04-26 19:47:00 +0530 | [diff] [blame] | 4754 | if ((drv == DRIVER_MAC80211 || drv == DRIVER_QNXNTO || |
| 4755 | drv == DRIVER_LINUX_WCN) && |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4756 | (dut->ap_mode == AP_11ac || dut->ap_mode == AP_11na)) { |
| 4757 | if (dut->ap_countrycode[0]) { |
| 4758 | fprintf(f, "country_code=%s\n", dut->ap_countrycode); |
| 4759 | fprintf(f, "ieee80211d=1\n"); |
| 4760 | fprintf(f, "ieee80211h=1\n"); |
| 4761 | } |
| 4762 | } |
| 4763 | |
| 4764 | fprintf(f, "interface=%s\n", ifname); |
| 4765 | if (dut->bridge) |
| 4766 | fprintf(f, "bridge=%s\n", dut->bridge); |
| 4767 | fprintf(f, "channel=%d\n", dut->ap_channel); |
| 4768 | |
| 4769 | if (sigma_hapd_ctrl) |
| 4770 | fprintf(f, "ctrl_interface=%s\n", sigma_hapd_ctrl); |
| 4771 | else |
| 4772 | fprintf(f, "ctrl_interface=/var/run/hostapd\n"); |
| 4773 | |
| 4774 | if (dut->ap_ssid[0]) |
| 4775 | fprintf(f, "ssid=%s\n", dut->ap_ssid); |
| 4776 | else |
| 4777 | fprintf(f, "ssid=QCA AP OOB\n"); |
| 4778 | if (dut->ap_bcnint) |
| 4779 | fprintf(f, "beacon_int=%d\n", dut->ap_bcnint); |
| 4780 | |
| 4781 | switch (dut->ap_key_mgmt) { |
| 4782 | case AP_OPEN: |
| 4783 | if (dut->ap_cipher == AP_WEP) |
| 4784 | fprintf(f, "wep_key0=%s\n", dut->ap_wepkey); |
| 4785 | break; |
| 4786 | case AP_WPA2_PSK: |
| 4787 | case AP_WPA2_PSK_MIXED: |
| 4788 | case AP_WPA_PSK: |
| 4789 | if (dut->ap_key_mgmt == AP_WPA2_PSK) |
| 4790 | fprintf(f, "wpa=2\n"); |
| 4791 | else if (dut->ap_key_mgmt == AP_WPA2_PSK_MIXED) |
| 4792 | fprintf(f, "wpa=3\n"); |
| 4793 | else |
| 4794 | fprintf(f, "wpa=1\n"); |
| 4795 | fprintf(f, "wpa_key_mgmt=WPA-PSK\n"); |
| 4796 | switch (dut->ap_pmf) { |
| 4797 | case AP_PMF_DISABLED: |
| 4798 | fprintf(f, "wpa_key_mgmt=WPA-PSK%s\n", |
| 4799 | dut->ap_add_sha256 ? " WPA-PSK-SHA256" : ""); |
| 4800 | break; |
| 4801 | case AP_PMF_OPTIONAL: |
| 4802 | fprintf(f, "wpa_key_mgmt=WPA-PSK%s\n", |
| 4803 | dut->ap_add_sha256 ? " WPA-PSK-SHA256" : ""); |
| 4804 | break; |
| 4805 | case AP_PMF_REQUIRED: |
| 4806 | fprintf(f, "wpa_key_mgmt=WPA-PSK-SHA256\n"); |
| 4807 | break; |
| 4808 | } |
| 4809 | if (dut->ap_cipher == AP_CCMP_TKIP) |
| 4810 | fprintf(f, "wpa_pairwise=CCMP TKIP\n"); |
| 4811 | else if (dut->ap_cipher == AP_TKIP) |
| 4812 | fprintf(f, "wpa_pairwise=TKIP\n"); |
| 4813 | else |
| 4814 | fprintf(f, "wpa_pairwise=CCMP\n"); |
| 4815 | fprintf(f, "wpa_passphrase=%s\n", dut->ap_passphrase); |
| 4816 | break; |
| 4817 | case AP_WPA2_EAP: |
| 4818 | case AP_WPA2_EAP_MIXED: |
| 4819 | case AP_WPA_EAP: |
| 4820 | fprintf(f, "ieee8021x=1\n"); |
| 4821 | if (dut->ap_key_mgmt == AP_WPA2_EAP) |
| 4822 | fprintf(f, "wpa=2\n"); |
| 4823 | else if (dut->ap_key_mgmt == AP_WPA2_EAP_MIXED) |
| 4824 | fprintf(f, "wpa=3\n"); |
| 4825 | else |
| 4826 | fprintf(f, "wpa=1\n"); |
| 4827 | switch (dut->ap_pmf) { |
| 4828 | case AP_PMF_DISABLED: |
| 4829 | fprintf(f, "wpa_key_mgmt=WPA-EAP%s\n", |
| 4830 | dut->ap_add_sha256 ? " WPA-EAP-SHA256" : ""); |
| 4831 | break; |
| 4832 | case AP_PMF_OPTIONAL: |
| 4833 | fprintf(f, "wpa_key_mgmt=WPA-EAP%s\n", |
| 4834 | dut->ap_add_sha256 ? " WPA-EAP-SHA256" : ""); |
| 4835 | break; |
| 4836 | case AP_PMF_REQUIRED: |
| 4837 | fprintf(f, "wpa_key_mgmt=WPA-EAP-SHA256\n"); |
| 4838 | break; |
| 4839 | } |
| 4840 | if (dut->ap_cipher == AP_CCMP_TKIP) |
| 4841 | fprintf(f, "wpa_pairwise=CCMP TKIP\n"); |
| 4842 | else if (dut->ap_cipher == AP_TKIP) |
| 4843 | fprintf(f, "wpa_pairwise=TKIP\n"); |
| 4844 | else |
| 4845 | fprintf(f, "wpa_pairwise=CCMP\n"); |
| 4846 | fprintf(f, "auth_server_addr=%s\n", dut->ap_radius_ipaddr); |
| 4847 | if (dut->ap_radius_port) |
| 4848 | fprintf(f, "auth_server_port=%d\n", |
| 4849 | dut->ap_radius_port); |
| 4850 | fprintf(f, "auth_server_shared_secret=%s\n", |
| 4851 | dut->ap_radius_password); |
| 4852 | break; |
| 4853 | } |
| 4854 | |
| 4855 | switch (dut->ap_pmf) { |
| 4856 | case AP_PMF_DISABLED: |
| 4857 | break; |
| 4858 | case AP_PMF_OPTIONAL: |
| 4859 | fprintf(f, "ieee80211w=1\n"); |
| 4860 | break; |
| 4861 | case AP_PMF_REQUIRED: |
| 4862 | fprintf(f, "ieee80211w=2\n"); |
| 4863 | break; |
| 4864 | } |
| 4865 | |
| 4866 | if (dut->ap_p2p_mgmt) |
| 4867 | fprintf(f, "manage_p2p=1\n"); |
| 4868 | |
| 4869 | if (dut->ap_tdls_prohibit || dut->ap_l2tif) |
| 4870 | fprintf(f, "tdls_prohibit=1\n"); |
| 4871 | if (dut->ap_tdls_prohibit_chswitch || dut->ap_l2tif) |
| 4872 | fprintf(f, "tdls_prohibit_chan_switch=1\n"); |
| 4873 | if (dut->ap_p2p_cross_connect >= 0) { |
| 4874 | fprintf(f, "manage_p2p=1\n" |
| 4875 | "allow_cross_connection=%d\n", |
| 4876 | dut->ap_p2p_cross_connect); |
| 4877 | } |
| 4878 | |
| 4879 | if (dut->ap_l2tif || dut->ap_proxy_arp) { |
| 4880 | if (!dut->bridge) { |
| 4881 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4882 | "Bridge must be configured. Run with -b <brname>."); |
| 4883 | fclose(f); |
| 4884 | return -2; |
| 4885 | } |
| 4886 | fprintf(f, "ap_isolate=1\n"); |
| 4887 | } |
| 4888 | |
| 4889 | if (dut->ap_proxy_arp) |
| 4890 | fprintf(f, "proxy_arp=1\n"); |
| 4891 | |
Pradeep Reddy POTTETI | 0d3db63 | 2016-03-11 15:21:11 +0530 | [diff] [blame] | 4892 | if (dut->ap_wme) |
| 4893 | fprintf(f, "wmm_enabled=1\n"); |
| 4894 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4895 | if (dut->ap_hs2) { |
| 4896 | if (dut->ap_bss_load) { |
| 4897 | char *bss_load; |
| 4898 | |
| 4899 | switch (dut->ap_bss_load) { |
| 4900 | case -1: |
| 4901 | bss_load = "bss_load_update_period=10"; |
| 4902 | break; |
| 4903 | case 1: |
| 4904 | /* STA count: 1, CU: 50, AAC: 65535 */ |
| 4905 | bss_load = "bss_load_test=1:50:65535"; |
| 4906 | break; |
| 4907 | case 2: |
| 4908 | /* STA count: 1, CU: 200, AAC: 65535 */ |
| 4909 | bss_load = "bss_load_test=1:200:65535"; |
| 4910 | break; |
| 4911 | case 3: |
| 4912 | /* STA count: 1, CU: 75, AAC: 65535 */ |
| 4913 | bss_load = "bss_load_test=1:75:65535"; |
| 4914 | break; |
| 4915 | default: |
| 4916 | bss_load = NULL; |
| 4917 | break; |
| 4918 | } |
| 4919 | |
| 4920 | if (!bss_load) { |
| 4921 | fclose(f); |
| 4922 | return -2; |
| 4923 | } |
| 4924 | fprintf(f, "%s\n", bss_load); |
| 4925 | } |
| 4926 | |
| 4927 | if (append_hostapd_conf_hs2(dut, f)) { |
| 4928 | fclose(f); |
| 4929 | return -2; |
| 4930 | } |
| 4931 | } |
| 4932 | |
| 4933 | if (dut->ap_interworking && append_hostapd_conf_interworking(dut, f)) { |
| 4934 | fclose(f); |
| 4935 | return -2; |
| 4936 | } |
| 4937 | |
| 4938 | if (dut->ap_hs2 && strlen(dut->ap2_ssid)) { |
| 4939 | unsigned char bssid[6]; |
| 4940 | char ifname2[50]; |
| 4941 | |
Pradeep Reddy POTTETI | 673d85c | 2016-07-26 19:08:07 +0530 | [diff] [blame] | 4942 | if (get_hwaddr(ifname, bssid)) { |
| 4943 | fclose(f); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4944 | return -2; |
Pradeep Reddy POTTETI | 673d85c | 2016-07-26 19:08:07 +0530 | [diff] [blame] | 4945 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4946 | bssid[0] |= 0x02; |
| 4947 | |
| 4948 | snprintf(ifname2, sizeof(ifname2), "%s_1", ifname); |
| 4949 | fprintf(f, "bss=%s_1\n", ifname2); |
| 4950 | fprintf(f, "ssid=%s\n", dut->ap2_ssid); |
| 4951 | if (dut->bridge) |
| 4952 | fprintf(f, "bridge=%s\n", dut->bridge); |
| 4953 | fprintf(f, "bssid=%02x:%02x:%02x:%02x:%02x:%02x\n", |
| 4954 | bssid[0], bssid[1], bssid[2], bssid[3], |
| 4955 | bssid[4], bssid[5]); |
| 4956 | |
| 4957 | if (dut->ap2_key_mgmt == AP2_OSEN) { |
| 4958 | fprintf(f, "osen=1\n"); |
| 4959 | if (strlen(dut->ap2_radius_ipaddr)) |
| 4960 | fprintf(f, "auth_server_addr=%s\n", |
| 4961 | dut->ap2_radius_ipaddr); |
| 4962 | if (dut->ap2_radius_port) |
| 4963 | fprintf(f, "auth_server_port=%d\n", |
| 4964 | dut->ap2_radius_port); |
| 4965 | if (strlen(dut->ap2_radius_password)) |
| 4966 | fprintf(f, "auth_server_shared_secret=%s\n", |
| 4967 | dut->ap2_radius_password); |
| 4968 | } |
| 4969 | |
| 4970 | if (dut->ap2_proxy_arp) { |
| 4971 | if (!dut->bridge) { |
| 4972 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 4973 | "Bridge must be configured. Run with -b <brname>."); |
| 4974 | fclose(f); |
| 4975 | return -2; |
| 4976 | } |
| 4977 | fprintf(f, "ap_isolate=1\n"); |
| 4978 | fprintf(f, "proxy_arp=1\n"); |
| 4979 | |
| 4980 | if (set_ebtables_proxy_arp(dut, "FORWARD", ifname2) || |
| 4981 | set_ebtables_proxy_arp(dut, "OUTPUT", ifname2)) { |
| 4982 | fclose(f); |
| 4983 | return -2; |
| 4984 | } |
| 4985 | |
| 4986 | } |
| 4987 | } |
| 4988 | |
| 4989 | if (dut->program == PROGRAM_WPS) { |
| 4990 | fprintf(f, "eap_server=1\n" |
| 4991 | "wps_state=1\n" |
| 4992 | "device_name=QCA AP\n" |
| 4993 | "manufacturer=QCA\n" |
| 4994 | "device_type=6-0050F204-1\n" |
| 4995 | "config_methods=label virtual_display " |
| 4996 | "virtual_push_button keypad%s\n" |
| 4997 | "ap_pin=12345670\n" |
| 4998 | "friendly_name=QCA Access Point\n" |
| 4999 | "upnp_iface=%s\n", |
| 5000 | dut->ap_wpsnfc ? " nfc_interface ext_nfc_token" : "", |
| 5001 | dut->bridge ? dut->bridge : ifname); |
| 5002 | } |
| 5003 | |
| 5004 | if (dut->program == PROGRAM_VHT) { |
| 5005 | int vht_oper_centr_freq_idx; |
| 5006 | |
| 5007 | if (check_channel(dut->ap_channel) < 0) { |
| 5008 | send_resp(dut, conn, SIGMA_INVALID, |
| 5009 | "errorCode,Invalid channel"); |
Pradeep Reddy POTTETI | 673d85c | 2016-07-26 19:08:07 +0530 | [diff] [blame] | 5010 | fclose(f); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5011 | return 0; |
| 5012 | } |
| 5013 | |
| 5014 | switch (dut->ap_chwidth) { |
| 5015 | case AP_20: |
| 5016 | dut->ap_vht_chwidth = AP_20_40_VHT_OPER_CHWIDTH; |
| 5017 | vht_oper_centr_freq_idx = |
| 5018 | get_oper_centr_freq_seq_idx(20, |
| 5019 | dut->ap_channel); |
| 5020 | break; |
| 5021 | case AP_40: |
| 5022 | dut->ap_vht_chwidth = AP_20_40_VHT_OPER_CHWIDTH; |
| 5023 | vht_oper_centr_freq_idx = |
| 5024 | get_oper_centr_freq_seq_idx(40, |
| 5025 | dut->ap_channel); |
| 5026 | break; |
| 5027 | case AP_80: |
| 5028 | dut->ap_vht_chwidth = AP_80_VHT_OPER_CHWIDTH; |
| 5029 | vht_oper_centr_freq_idx = |
| 5030 | get_oper_centr_freq_seq_idx(80, |
| 5031 | dut->ap_channel); |
| 5032 | break; |
| 5033 | case AP_160: |
| 5034 | dut->ap_vht_chwidth = AP_160_VHT_OPER_CHWIDTH; |
| 5035 | vht_oper_centr_freq_idx = |
| 5036 | get_oper_centr_freq_seq_idx(160, |
| 5037 | dut->ap_channel); |
| 5038 | break; |
| 5039 | default: |
| 5040 | dut->ap_vht_chwidth = VHT_DEFAULT_OPER_CHWIDTH; |
| 5041 | vht_oper_centr_freq_idx = |
| 5042 | get_oper_centr_freq_seq_idx(80, |
| 5043 | dut->ap_channel); |
| 5044 | break; |
| 5045 | } |
| 5046 | fprintf(f, "vht_oper_centr_freq_seg0_idx=%d\n", |
| 5047 | vht_oper_centr_freq_idx); |
| 5048 | fprintf(f, "vht_oper_chwidth=%d\n", dut->ap_vht_chwidth); |
| 5049 | |
| 5050 | if (dut->ap_sgi80 || dut->ap_txBF || dut->ap_ldpc || |
Mohammed Shafi Shajakhan | f3e68d9 | 2016-06-02 20:10:57 +0530 | [diff] [blame] | 5051 | dut->ap_tx_stbc || dut->ap_mu_txBF) { |
| 5052 | fprintf(f, "vht_capab=%s%s%s%s%s\n", |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5053 | dut->ap_sgi80 ? "[SHORT-GI-80]" : "", |
Mohammed Shafi Shajakhan | c039ce3 | 2016-06-02 20:10:58 +0530 | [diff] [blame] | 5054 | dut->ap_txBF ? |
Tamizh chelvam | 8312f6d | 2016-06-02 20:10:59 +0530 | [diff] [blame] | 5055 | "[SU-BEAMFORMER][SU-BEAMFORMEE][BF-ANTENNA-2][SOUNDING-DIMENSION-2]" : "", |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5056 | dut->ap_ldpc ? "[RXLDPC]" : "", |
Mohammed Shafi Shajakhan | f3e68d9 | 2016-06-02 20:10:57 +0530 | [diff] [blame] | 5057 | dut->ap_tx_stbc ? "[TX-STBC-2BY1]" : "", |
| 5058 | dut->ap_mu_txBF ? "[MU-BEAMFORMER]" : ""); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5059 | } |
| 5060 | } |
| 5061 | |
| 5062 | fclose(f); |
| 5063 | #ifdef __QNXNTO__ |
| 5064 | if (system("slay hostapd") == 0) |
| 5065 | #else /* __QNXNTO__ */ |
| 5066 | if (kill_process(dut, "(hostapd)", 1, SIGTERM) == 0 || |
| 5067 | system("killall hostapd") == 0) |
| 5068 | #endif /* __QNXNTO__ */ |
| 5069 | { |
| 5070 | int i; |
| 5071 | /* Wait some time to allow hostapd to complete cleanup before |
| 5072 | * starting a new process */ |
| 5073 | for (i = 0; i < 10; i++) { |
| 5074 | usleep(500000); |
| 5075 | #ifdef __QNXNTO__ |
| 5076 | if (system("pidin | grep hostapd") != 0) |
| 5077 | break; |
| 5078 | #else /* __QNXNTO__ */ |
| 5079 | if (system("pidof hostapd") != 0) |
| 5080 | break; |
| 5081 | #endif /* __QNXNTO__ */ |
| 5082 | } |
| 5083 | } |
| 5084 | |
Pradeep Reddy POTTETI | a076c30 | 2016-05-16 13:36:07 +0530 | [diff] [blame] | 5085 | #ifdef ANDROID |
| 5086 | /* Set proper conf file permissions so that hostapd process |
| 5087 | * can access it. |
| 5088 | */ |
| 5089 | if (chmod(SIGMA_TMPDIR "/sigma_dut-ap.conf", |
| 5090 | S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP) < 0) |
| 5091 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5092 | "Error changing permissions"); |
| 5093 | |
| 5094 | if (chown(SIGMA_TMPDIR "/sigma_dut-ap.conf", -1, AID_WIFI) < 0) |
| 5095 | sigma_dut_print(dut, DUT_MSG_ERROR, "Error changing groupid"); |
| 5096 | #endif /* ANDROID */ |
| 5097 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5098 | if (drv == DRIVER_QNXNTO) { |
| 5099 | snprintf(buf, sizeof(buf), |
Pradeep Reddy POTTETI | bf4a974 | 2016-02-04 12:32:30 +0530 | [diff] [blame] | 5100 | "hostapd -B %s%s %s%s" SIGMA_TMPDIR |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5101 | "/sigma_dut-ap.conf", |
| 5102 | dut->hostapd_debug_log ? "-ddKt -f " : "", |
| 5103 | dut->hostapd_debug_log ? dut->hostapd_debug_log : "", |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5104 | dut->hostapd_entropy_log ? " -e" : "", |
| 5105 | dut->hostapd_entropy_log ? dut->hostapd_entropy_log : |
| 5106 | ""); |
| 5107 | } else { |
| 5108 | /* |
| 5109 | * It looks like a monitor interface can cause some issues for |
| 5110 | * beaconing, so remove it (if injection was used) before |
| 5111 | * starting hostapd. |
| 5112 | */ |
| 5113 | if (if_nametoindex("sigmadut") > 0 && |
| 5114 | system("iw dev sigmadut del") != 0) |
| 5115 | sigma_dut_print(dut, DUT_MSG_ERROR, "Failed to remove " |
| 5116 | "monitor interface"); |
| 5117 | |
| 5118 | snprintf(buf, sizeof(buf), "%shostapd -B%s%s%s%s " SIGMA_TMPDIR |
| 5119 | "/sigma_dut-ap.conf", |
| 5120 | file_exists("hostapd") ? "./" : "", |
| 5121 | dut->hostapd_debug_log ? " -ddKt -f" : "", |
| 5122 | dut->hostapd_debug_log ? dut->hostapd_debug_log : "", |
| 5123 | dut->hostapd_entropy_log ? " -e" : "", |
| 5124 | dut->hostapd_entropy_log ? dut->hostapd_entropy_log : |
| 5125 | ""); |
| 5126 | } |
| 5127 | |
| 5128 | if (system(buf) != 0) { |
| 5129 | send_resp(dut, conn, SIGMA_ERROR, |
| 5130 | "errorCode,Failed to start hostapd"); |
| 5131 | return 0; |
| 5132 | } |
| 5133 | |
| 5134 | /* allow some time for hostapd to start before returning success */ |
| 5135 | usleep(500000); |
| 5136 | if (run_hostapd_cli(dut, "ping") != 0) { |
| 5137 | send_resp(dut, conn, SIGMA_ERROR, |
| 5138 | "errorCode,Failed to talk to hostapd"); |
| 5139 | return 0; |
| 5140 | } |
| 5141 | |
| 5142 | if (dut->ap_l2tif) { |
| 5143 | snprintf(path, sizeof(path), |
| 5144 | "/sys/class/net/%s/brport/hairpin_mode", |
| 5145 | ifname); |
| 5146 | if (!file_exists(path)) { |
| 5147 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5148 | "%s must be binded to the bridge for L2TIF", |
| 5149 | ifname); |
| 5150 | return -2; |
| 5151 | } |
| 5152 | |
| 5153 | snprintf(buf, sizeof(buf), "echo 1 > %s", path); |
| 5154 | if (system(buf) != 0) { |
| 5155 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5156 | "Failed to enable hairpin_mode for L2TIF"); |
| 5157 | return -2; |
| 5158 | } |
| 5159 | |
| 5160 | snprintf(buf, sizeof(buf), "ebtables -P FORWARD ACCEPT"); |
| 5161 | if (system(buf) != 0) { |
| 5162 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5163 | "Failed to set ebtables rules, RULE-9"); |
| 5164 | return -2; |
| 5165 | } |
| 5166 | |
| 5167 | snprintf(buf, sizeof(buf), |
| 5168 | "ebtables -A FORWARD -p IPv4 --ip-proto icmp -i %s -j DROP", |
| 5169 | ifname); |
| 5170 | if (system(buf) != 0) { |
| 5171 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5172 | "Failed to set ebtables rules, RULE-11"); |
| 5173 | return -2; |
| 5174 | } |
| 5175 | } |
| 5176 | |
| 5177 | if (dut->ap_proxy_arp) { |
| 5178 | if (dut->ap_dgaf_disable) { |
| 5179 | if (set_ebtables_disable_dgaf(dut, "FORWARD", ifname) || |
| 5180 | set_ebtables_disable_dgaf(dut, "OUTPUT", ifname)) |
| 5181 | return -2; |
| 5182 | } else { |
| 5183 | if (set_ebtables_proxy_arp(dut, "FORWARD", ifname) || |
| 5184 | set_ebtables_proxy_arp(dut, "OUTPUT", ifname)) |
| 5185 | return -2; |
| 5186 | } |
| 5187 | |
| 5188 | /* For 4.5-(c) */ |
| 5189 | snprintf(buf, sizeof(buf), |
| 5190 | "ebtables -A FORWARD -p ARP --arp-opcode 2 -i %s -j DROP", |
| 5191 | ifname); |
| 5192 | if (system(buf) != 0) { |
| 5193 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5194 | "Failed to set ebtables rules, RULE-10"); |
| 5195 | return -2; |
| 5196 | } |
| 5197 | } |
| 5198 | |
| 5199 | if (dut->ap_tdls_prohibit || dut->ap_l2tif) { |
| 5200 | /* Drop TDLS frames */ |
| 5201 | snprintf(buf, sizeof(buf), |
| 5202 | "ebtables -A FORWARD -p 0x890d -i %s -j DROP", ifname); |
| 5203 | if (system(buf) != 0) { |
| 5204 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5205 | "Failed to set ebtables rules, RULE-13"); |
| 5206 | return -2; |
| 5207 | } |
| 5208 | } |
| 5209 | |
| 5210 | if (dut->ap_fake_pkhash && |
| 5211 | run_hostapd_cli(dut, "set wps_corrupt_pkhash 1") != 0) { |
| 5212 | send_resp(dut, conn, SIGMA_ERROR, |
| 5213 | "errorCode,Could not enable FakePubKey"); |
| 5214 | return 0; |
| 5215 | } |
| 5216 | |
| 5217 | return 1; |
| 5218 | } |
| 5219 | |
| 5220 | |
| 5221 | static void parse_qos_params(struct qos_params *qos, const char *cwmin, |
| 5222 | const char *cwmax, const char *aifs, |
| 5223 | const char *txop, const char *acm) |
| 5224 | { |
| 5225 | if (cwmin) { |
| 5226 | qos->ac = 1; |
| 5227 | qos->cwmin = atoi(cwmin); |
| 5228 | } |
| 5229 | |
| 5230 | if (cwmax) { |
| 5231 | qos->ac = 1; |
| 5232 | qos->cwmax = atoi(cwmax); |
| 5233 | } |
| 5234 | |
| 5235 | if (aifs) { |
| 5236 | qos->ac = 1; |
| 5237 | qos->aifs = atoi(aifs); |
| 5238 | } |
| 5239 | |
| 5240 | if (txop) { |
| 5241 | qos->ac = 1; |
| 5242 | qos->txop = atoi(txop) * 32; |
| 5243 | } |
| 5244 | |
| 5245 | if (acm) { |
| 5246 | qos->ac = 1; |
| 5247 | qos->acm = strcasecmp(acm, "on") == 0; |
| 5248 | } |
| 5249 | } |
| 5250 | |
| 5251 | |
| 5252 | static int cmd_ap_set_apqos(struct sigma_dut *dut, struct sigma_conn *conn, |
| 5253 | struct sigma_cmd *cmd) |
| 5254 | { |
| 5255 | /* TXOP: The values provided here for VHT5G only */ |
| 5256 | parse_qos_params(&dut->ap_qos[AP_AC_VO], get_param(cmd, "cwmin_VO"), |
| 5257 | get_param(cmd, "cwmax_VO"), get_param(cmd, "AIFS_VO"), |
| 5258 | get_param(cmd, "TXOP_VO"), get_param(cmd, "ACM_VO")); |
| 5259 | parse_qos_params(&dut->ap_qos[AP_AC_VI], get_param(cmd, "cwmin_VI"), |
| 5260 | get_param(cmd, "cwmax_VI"), get_param(cmd, "AIFS_VI"), |
| 5261 | get_param(cmd, "TXOP_VI"), get_param(cmd, "ACM_VI")); |
| 5262 | parse_qos_params(&dut->ap_qos[AP_AC_BE], get_param(cmd, "cwmin_BE"), |
| 5263 | get_param(cmd, "cwmax_BE"), get_param(cmd, "AIFS_BE"), |
| 5264 | get_param(cmd, "TXOP_BE"), get_param(cmd, "ACM_BE")); |
| 5265 | parse_qos_params(&dut->ap_qos[AP_AC_BK], get_param(cmd, "cwmin_BK"), |
| 5266 | get_param(cmd, "cwmax_BK"), get_param(cmd, "AIFS_BK"), |
| 5267 | get_param(cmd, "TXOP_BK"), get_param(cmd, "ACM_BK")); |
| 5268 | return 1; |
| 5269 | } |
| 5270 | |
| 5271 | |
| 5272 | static int cmd_ap_set_staqos(struct sigma_dut *dut, struct sigma_conn *conn, |
| 5273 | struct sigma_cmd *cmd) |
| 5274 | { |
| 5275 | parse_qos_params(&dut->ap_sta_qos[AP_AC_VO], get_param(cmd, "cwmin_VO"), |
| 5276 | get_param(cmd, "cwmax_VO"), get_param(cmd, "AIFS_VO"), |
| 5277 | get_param(cmd, "TXOP_VO"), get_param(cmd, "ACM_VO")); |
| 5278 | parse_qos_params(&dut->ap_sta_qos[AP_AC_VI], get_param(cmd, "cwmin_VI"), |
| 5279 | get_param(cmd, "cwmax_VI"), get_param(cmd, "AIFS_VI"), |
| 5280 | get_param(cmd, "TXOP_VI"), get_param(cmd, "ACM_VI")); |
| 5281 | parse_qos_params(&dut->ap_sta_qos[AP_AC_BE], get_param(cmd, "cwmin_BE"), |
| 5282 | get_param(cmd, "cwmax_BE"), get_param(cmd, "AIFS_BE"), |
| 5283 | get_param(cmd, "TXOP_BE"), get_param(cmd, "ACM_BE")); |
| 5284 | parse_qos_params(&dut->ap_sta_qos[AP_AC_BK], get_param(cmd, "cwmin_BK"), |
| 5285 | get_param(cmd, "cwmax_BK"), get_param(cmd, "AIFS_BK"), |
| 5286 | get_param(cmd, "TXOP_BK"), get_param(cmd, "ACM_BK")); |
| 5287 | return 1; |
| 5288 | } |
| 5289 | |
| 5290 | |
| 5291 | static void cmd_ath_ap_hs2_reset(struct sigma_dut *dut) |
| 5292 | { |
| 5293 | unsigned char bssid[6]; |
| 5294 | char buf[100]; |
| 5295 | run_system(dut, "cfg -a AP_SSID=\"Hotspot 2.0\""); |
| 5296 | run_system(dut, "cfg -a AP_PRIMARY_CH=1"); |
| 5297 | run_system(dut, "cfg -a AP_SECMODE=WPA"); |
| 5298 | run_system(dut, "cfg -a AP_SECFILE=EAP"); |
| 5299 | run_system(dut, "cfg -a AP_WPA=2"); |
| 5300 | run_system(dut, "cfg -a AP_CYPHER=CCMP"); |
| 5301 | run_system(dut, "cfg -a AP_HOTSPOT=1"); |
| 5302 | run_system(dut, "cfg -a AP_HOTSPOT_ANT=2"); |
| 5303 | run_system(dut, "cfg -a AP_HOTSPOT_INTERNET=0"); |
| 5304 | run_system(dut, "cfg -a AP_HOTSPOT_VENUEGROUP=2"); |
| 5305 | run_system(dut, "cfg -a AP_HOTSPOT_VENUETYPE=8"); |
| 5306 | run_system(dut, "cfg -a AP_HOTSPOT_ROAMINGCONSORTIUM=506f9a"); |
| 5307 | run_system(dut, "cfg -a AP_HOTSPOT_ROAMINGCONSORTIUM2=001bc504bd"); |
| 5308 | if (!get_hwaddr("ath0", bssid)) { |
| 5309 | snprintf(buf, sizeof(buf), "cfg -a AP_HOTSPOT_HESSID=" |
| 5310 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 5311 | bssid[0], bssid[1], bssid[2], bssid[3], |
| 5312 | bssid[4], bssid[5]); |
| 5313 | run_system(dut, buf); |
| 5314 | snprintf(dut->ap_hessid, sizeof(dut->ap_hessid), |
| 5315 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 5316 | bssid[0], bssid[1], bssid[2], bssid[3], |
| 5317 | bssid[4], bssid[5]); |
| 5318 | } else { |
| 5319 | if (!get_hwaddr("wifi0", bssid)) { |
| 5320 | snprintf(buf, sizeof(buf), "cfg -a AP_HOTSPOT_HESSID=" |
| 5321 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 5322 | bssid[0], bssid[1], bssid[2], bssid[3], |
| 5323 | bssid[4], bssid[5]); |
| 5324 | run_system(dut, buf); |
| 5325 | snprintf(dut->ap_hessid, sizeof(dut->ap_hessid), |
| 5326 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 5327 | bssid[0], bssid[1], bssid[2], bssid[3], |
| 5328 | bssid[4], bssid[5]); |
| 5329 | } else { |
| 5330 | /* load the driver and try again */ |
| 5331 | run_system(dut, "/etc/rc.d/rc.wlan up"); |
| 5332 | |
| 5333 | if (!get_hwaddr("wifi0", bssid)) { |
| 5334 | snprintf(buf, sizeof(buf), |
| 5335 | "cfg -a AP_HOTSPOT_HESSID=" |
| 5336 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 5337 | bssid[0], bssid[1], bssid[2], |
| 5338 | bssid[3], bssid[4], bssid[5]); |
| 5339 | run_system(dut, buf); |
| 5340 | snprintf(dut->ap_hessid, |
| 5341 | sizeof(dut->ap_hessid), |
| 5342 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 5343 | bssid[0], bssid[1], bssid[2], |
| 5344 | bssid[3], bssid[4], bssid[5]); |
| 5345 | } |
| 5346 | } |
| 5347 | } |
| 5348 | |
| 5349 | run_system(dut, "cfg -r AP_SSID_2"); |
| 5350 | run_system(dut, "cfg -c"); |
| 5351 | /* run_system(dut, "cfg -s"); */ |
| 5352 | } |
| 5353 | |
| 5354 | |
| 5355 | static void ath_reset_vht_defaults(struct sigma_dut *dut) |
| 5356 | { |
| 5357 | run_system(dut, "cfg -x"); |
| 5358 | run_system(dut, "cfg -a AP_RADIO_ID=1"); |
| 5359 | run_system(dut, "cfg -a AP_PRIMARY_CH_2=36"); |
| 5360 | run_system(dut, "cfg -a AP_STARTMODE=standard"); |
| 5361 | run_system(dut, "cfg -a AP_CHMODE_2=11ACVHT80"); |
| 5362 | run_system(dut, "cfg -a TX_CHAINMASK_2=7"); |
| 5363 | run_system(dut, "cfg -a RX_CHAINMASK_2=7"); |
| 5364 | run_system(dut, "cfg -a ATH_countrycode=0x348"); |
| 5365 | /* NOTE: For Beeliner we have to turn off MU-MIMO */ |
| 5366 | if (system("rm /tmp/secath*") != 0) { |
| 5367 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5368 | "Failed to remove secath file"); |
| 5369 | } |
| 5370 | } |
| 5371 | |
| 5372 | |
| 5373 | static int cmd_ap_reset_default(struct sigma_dut *dut, struct sigma_conn *conn, |
| 5374 | struct sigma_cmd *cmd) |
| 5375 | { |
| 5376 | const char *type; |
| 5377 | |
| 5378 | dut->program = sigma_program_to_enum(get_param(cmd, "PROGRAM")); |
| 5379 | dut->device_type = AP_unknown; |
| 5380 | type = get_param(cmd, "type"); |
| 5381 | if (type && strcasecmp(type, "Testbed") == 0) |
| 5382 | dut->device_type = AP_testbed; |
| 5383 | if (type && strcasecmp(type, "DUT") == 0) |
| 5384 | dut->device_type = AP_dut; |
| 5385 | |
| 5386 | dut->ap_rts = 0; |
| 5387 | dut->ap_frgmnt = 0; |
| 5388 | dut->ap_bcnint = 0; |
| 5389 | dut->ap_key_mgmt = AP_OPEN; |
| 5390 | dut->ap_ssid[0] = '\0'; |
| 5391 | dut->ap_fake_pkhash = 0; |
| 5392 | memset(dut->ap_qos, 0, sizeof(dut->ap_qos)); |
| 5393 | memset(dut->ap_sta_qos, 0, sizeof(dut->ap_sta_qos)); |
| 5394 | dut->ap_addba_reject = 0; |
| 5395 | dut->ap_noack = AP_NOACK_NOT_SET; |
| 5396 | dut->ap_is_dual = 0; |
| 5397 | dut->ap_mode = AP_inval; |
| 5398 | dut->ap_mode_1 = AP_inval; |
| 5399 | |
| 5400 | dut->ap_allow_vht_wep = 0; |
| 5401 | dut->ap_allow_vht_tkip = 0; |
| 5402 | dut->ap_disable_protection = 0; |
| 5403 | memset(dut->ap_countrycode, 0, sizeof(dut->ap_countrycode)); |
| 5404 | dut->ap_dyn_bw_sig = AP_DYN_BW_SGNL_NOT_SET; |
| 5405 | dut->ap_ldpc = 0; |
| 5406 | dut->ap_sig_rts = 0; |
| 5407 | dut->ap_rx_amsdu = 0; |
| 5408 | dut->ap_txBF = 0; |
Mohammed Shafi Shajakhan | 495fdb2 | 2016-06-02 20:10:56 +0530 | [diff] [blame] | 5409 | dut->ap_mu_txBF = 0; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5410 | dut->ap_chwidth = AP_AUTO; |
| 5411 | |
Sarvepalli, Rajesh Babu | 24dc7e4 | 2016-03-18 21:27:26 +0530 | [diff] [blame] | 5412 | dut->ap_rsn_preauth = 0; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5413 | dut->ap_wpsnfc = 0; |
| 5414 | dut->ap_bss_load = -1; |
| 5415 | dut->ap_p2p_cross_connect = -1; |
| 5416 | |
Pradeep Reddy POTTETI | fba27db | 2015-11-20 16:42:22 +0530 | [diff] [blame] | 5417 | dut->ap_regulatory_mode = AP_80211D_MODE_DISABLED; |
| 5418 | dut->ap_dfs_mode = AP_DFS_MODE_DISABLED; |
| 5419 | |
Pradeep Reddy POTTETI | 0d3db63 | 2016-03-11 15:21:11 +0530 | [diff] [blame] | 5420 | if (dut->program == PROGRAM_HT || dut->program == PROGRAM_VHT) |
| 5421 | dut->ap_wme = AP_WME_ON; |
| 5422 | else |
| 5423 | dut->ap_wme = AP_WME_OFF; |
| 5424 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5425 | if (dut->program == PROGRAM_HS2 || dut->program == PROGRAM_HS2_R2) { |
| 5426 | int i; |
| 5427 | enum driver_type drv; |
| 5428 | |
| 5429 | drv = get_driver_type(); |
| 5430 | if (drv == DRIVER_ATHEROS) |
| 5431 | cmd_ath_ap_hs2_reset(dut); |
| 5432 | else if (drv == DRIVER_OPENWRT) |
| 5433 | cmd_owrt_ap_hs2_reset(dut); |
| 5434 | |
| 5435 | dut->ap_interworking = 1; |
| 5436 | dut->ap_access_net_type = 2; |
| 5437 | dut->ap_internet = 0; |
| 5438 | dut->ap_venue_group = 2; |
| 5439 | dut->ap_venue_type = 8; |
| 5440 | dut->ap_domain_name_list[0] = '\0'; |
| 5441 | dut->ap_hs2 = 1; |
| 5442 | snprintf(dut->ap_roaming_cons, sizeof(dut->ap_roaming_cons), |
| 5443 | "506f9a;001bc504bd"); |
| 5444 | dut->ap_l2tif = 0; |
| 5445 | dut->ap_proxy_arp = 0; |
| 5446 | if (dut->bridge) { |
| 5447 | char buf[50]; |
| 5448 | |
| 5449 | snprintf(buf, sizeof(buf), "ip neigh flush dev %s", |
| 5450 | dut->bridge); |
| 5451 | if (system(buf) != 0) { |
| 5452 | sigma_dut_print(dut, DUT_MSG_DEBUG, |
| 5453 | "%s ip neigh table flushing failed", |
| 5454 | dut->bridge); |
| 5455 | } |
| 5456 | |
| 5457 | snprintf(buf, sizeof(buf), "ebtables -F"); |
| 5458 | if (system(buf) != 0) { |
| 5459 | sigma_dut_print(dut, DUT_MSG_DEBUG, |
| 5460 | "%s ebtables flushing failed", |
| 5461 | dut->bridge); |
| 5462 | } |
| 5463 | } |
| 5464 | dut->ap_dgaf_disable = 0; |
| 5465 | dut->ap_p2p_cross_connect = 0; |
| 5466 | dut->ap_gas_cb_delay = 0; |
| 5467 | dut->ap_nai_realm_list = 0; |
| 5468 | dut->ap_oper_name = 0; |
| 5469 | dut->ap_venue_name = 0; |
| 5470 | for (i = 0; i < 10; i++) { |
| 5471 | dut->ap_plmn_mcc[i][0] = '\0'; |
| 5472 | dut->ap_plmn_mnc[i][0] = '\0'; |
| 5473 | } |
| 5474 | dut->ap_wan_metrics = 0; |
| 5475 | dut->ap_conn_capab = 0; |
| 5476 | dut->ap_ip_addr_type_avail = 0; |
| 5477 | dut->ap_net_auth_type = 0; |
| 5478 | dut->ap_oper_class = 0; |
| 5479 | dut->ap_pmf = 0; |
| 5480 | dut->ap_add_sha256 = 0; |
| 5481 | } |
| 5482 | |
| 5483 | if (dut->program == PROGRAM_HS2_R2) { |
| 5484 | int i; |
| 5485 | const char hessid[] = "50:6f:9a:00:11:22"; |
| 5486 | |
| 5487 | memcpy(dut->ap_hessid, hessid, strlen(hessid) + 1); |
| 5488 | dut->ap_osu_ssid[0] = '\0'; |
| 5489 | dut->ap2_ssid[0] = '\0'; |
| 5490 | dut->ap_pmf = 1; |
| 5491 | dut->ap_osu_provider_list = 0; |
| 5492 | for (i = 0; i < 10; i++) { |
| 5493 | dut->ap_osu_server_uri[i][0] = '\0'; |
| 5494 | dut->ap_osu_method[i] = 0xFF; |
| 5495 | } |
| 5496 | dut->ap_qos_map_set = 0; |
| 5497 | dut->ap2_key_mgmt = AP2_OPEN; |
| 5498 | dut->ap2_proxy_arp = 0; |
| 5499 | dut->ap_osu_icon_tag = 0; |
| 5500 | } |
| 5501 | |
| 5502 | if (dut->program == PROGRAM_VHT) { |
| 5503 | /* Set up the defaults */ |
| 5504 | dut->ap_mode = AP_11ac; |
| 5505 | dut->ap_channel = 36; |
| 5506 | dut->ap_ampdu = 0; |
priyadharshini gowthaman | 264d544 | 2016-02-25 15:52:22 -0800 | [diff] [blame] | 5507 | dut->ap_ndpa_frame = 1; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5508 | if (dut->device_type == AP_testbed) { |
| 5509 | dut->ap_amsdu = 2; |
| 5510 | dut->ap_ldpc = 2; |
| 5511 | dut->ap_rx_amsdu = 2; |
| 5512 | dut->ap_sgi80 = 0; |
| 5513 | } else { |
| 5514 | dut->ap_amsdu = 1; |
| 5515 | dut->ap_ldpc = 1; |
| 5516 | dut->ap_rx_amsdu = 1; |
| 5517 | dut->ap_sgi80 = 1; |
| 5518 | } |
| 5519 | dut->ap_fixed_rate = 0; |
| 5520 | dut->ap_rx_streams = 3; |
| 5521 | dut->ap_tx_streams = 3; |
| 5522 | dut->ap_vhtmcs_map = 0; |
| 5523 | dut->ap_chwidth = AP_80; |
| 5524 | dut->ap_tx_stbc = 1; |
| 5525 | dut->ap_dyn_bw_sig = AP_DYN_BW_SGNL_ENABLED; |
Mohammed Shafi Shajakhan | bae7230 | 2016-03-02 11:56:23 +0530 | [diff] [blame] | 5526 | if (get_openwrt_driver_type() == OPENWRT_DRIVER_ATHEROS) |
| 5527 | dut->ap_dfs_mode = AP_DFS_MODE_ENABLED; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5528 | if (get_driver_type() == DRIVER_ATHEROS) |
| 5529 | ath_reset_vht_defaults(dut); |
| 5530 | } |
| 5531 | |
priyadharshini gowthaman | a27b5b6 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 5532 | if (dut->program == PROGRAM_LOC) { |
priyadharshini gowthaman | 8e26ff4 | 2016-06-22 22:47:14 -0700 | [diff] [blame^] | 5533 | dut->ap_rrm = 1; |
| 5534 | dut->ap_rtt = 1; |
| 5535 | dut->ap_lci = 0; |
| 5536 | dut->ap_val_lci[0] = '\0'; |
| 5537 | dut->ap_lcr = 0; |
| 5538 | dut->ap_val_lcr[0] = '\0'; |
| 5539 | dut->ap_neighap = 0; |
| 5540 | dut->ap_opchannel = 0; |
| 5541 | dut->ap_scan = 0; |
| 5542 | dut->ap2_ssid[0] = '\0'; |
priyadharshini gowthaman | c52fff8 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 5543 | dut->ap_interworking = 0; |
| 5544 | dut->ap_gas_cb_delay = 0; |
priyadharshini gowthaman | a27b5b6 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 5545 | dut->ap_msnt_type = 0; |
| 5546 | } |
| 5547 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5548 | if (kill_process(dut, "(hostapd)", 1, SIGTERM) == 0 || |
| 5549 | system("killall hostapd") == 0) { |
| 5550 | int i; |
| 5551 | /* Wait some time to allow hostapd to complete cleanup before |
| 5552 | * starting a new process */ |
| 5553 | for (i = 0; i < 10; i++) { |
| 5554 | usleep(500000); |
| 5555 | if (system("pidof hostapd") != 0) |
| 5556 | break; |
| 5557 | } |
| 5558 | } |
| 5559 | |
| 5560 | if (if_nametoindex("sigmadut") > 0 && |
| 5561 | system("iw dev sigmadut del") != 0) |
| 5562 | sigma_dut_print(dut, DUT_MSG_ERROR, "Failed to remove " |
| 5563 | "monitor interface"); |
| 5564 | |
| 5565 | return 1; |
| 5566 | } |
| 5567 | |
| 5568 | |
| 5569 | static int cmd_ap_get_info(struct sigma_dut *dut, struct sigma_conn *conn, |
| 5570 | struct sigma_cmd *cmd) |
| 5571 | { |
| 5572 | /* const char *name = get_param(cmd, "NAME"); */ |
| 5573 | struct stat s; |
| 5574 | char resp[200]; |
| 5575 | FILE *f; |
| 5576 | enum driver_type drv = get_driver_type(); |
| 5577 | |
| 5578 | switch (drv) { |
| 5579 | case DRIVER_ATHEROS: { |
| 5580 | /* Atheros AP */ |
| 5581 | struct utsname uts; |
| 5582 | char *version, athver[100]; |
| 5583 | |
| 5584 | if (stat("/proc/athversion", &s) != 0) { |
| 5585 | if (system("/etc/rc.d/rc.wlan up") != 0) { |
| 5586 | } |
| 5587 | } |
| 5588 | |
| 5589 | athver[0] = '\0'; |
| 5590 | f = fopen("/proc/athversion", "r"); |
| 5591 | if (f) { |
| 5592 | if (fgets(athver, sizeof(athver), f)) { |
| 5593 | char *pos = strchr(athver, '\n'); |
| 5594 | if (pos) |
| 5595 | *pos = '\0'; |
| 5596 | } |
| 5597 | fclose(f); |
| 5598 | } |
| 5599 | |
| 5600 | if (uname(&uts) == 0) |
| 5601 | version = uts.release; |
| 5602 | else |
| 5603 | version = "Unknown"; |
| 5604 | |
| 5605 | if (if_nametoindex("ath1") > 0) |
| 5606 | snprintf(resp, sizeof(resp), "interface,ath0_24G " |
| 5607 | "ath1_5G,agent,1.0,version,%s/drv:%s", |
| 5608 | version, athver); |
| 5609 | else |
| 5610 | snprintf(resp, sizeof(resp), "interface,ath0_24G," |
| 5611 | "agent,1.0,version,%s/drv:%s", |
| 5612 | version, athver); |
| 5613 | |
| 5614 | send_resp(dut, conn, SIGMA_COMPLETE, resp); |
| 5615 | return 0; |
| 5616 | } |
Sreelakshmi Konamki | b692f10 | 2016-04-26 19:47:00 +0530 | [diff] [blame] | 5617 | case DRIVER_LINUX_WCN: |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5618 | case DRIVER_MAC80211: { |
| 5619 | struct utsname uts; |
| 5620 | char *version; |
| 5621 | |
| 5622 | if (uname(&uts) == 0) |
| 5623 | version = uts.release; |
| 5624 | else |
| 5625 | version = "Unknown"; |
| 5626 | |
| 5627 | if (if_nametoindex("wlan1") > 0) |
| 5628 | snprintf(resp, sizeof(resp), "interface,wlan0_24G " |
| 5629 | "wlan1_5G,agent,1.0,version,%s", version); |
| 5630 | else |
| 5631 | snprintf(resp, sizeof(resp), "interface,wlan0_any," |
| 5632 | "agent,1.0,version,%s", version); |
| 5633 | |
| 5634 | send_resp(dut, conn, SIGMA_COMPLETE, resp); |
| 5635 | return 0; |
| 5636 | } |
| 5637 | case DRIVER_QNXNTO: { |
| 5638 | struct utsname uts; |
| 5639 | char *version; |
| 5640 | |
| 5641 | if (uname(&uts) == 0) |
| 5642 | version = uts.release; |
| 5643 | else |
| 5644 | version = "Unknown"; |
| 5645 | snprintf(resp, sizeof(resp), |
| 5646 | "interface,%s_any,agent,1.0,version,%s", |
| 5647 | sigma_main_ifname ? sigma_main_ifname : "NA", |
| 5648 | version); |
| 5649 | send_resp(dut, conn, SIGMA_COMPLETE, resp); |
| 5650 | return 0; |
| 5651 | } |
| 5652 | case DRIVER_OPENWRT: { |
| 5653 | switch (get_openwrt_driver_type()) { |
| 5654 | case OPENWRT_DRIVER_ATHEROS: { |
| 5655 | struct utsname uts; |
| 5656 | char *version; |
| 5657 | |
| 5658 | if (uname(&uts) == 0) |
| 5659 | version = uts.release; |
| 5660 | else |
| 5661 | version = "Unknown"; |
| 5662 | |
| 5663 | if (if_nametoindex("ath1") > 0) |
| 5664 | snprintf(resp, sizeof(resp), |
| 5665 | "interface,ath0_5G ath1_24G,agent,1.0,version,%s", |
| 5666 | version); |
| 5667 | else |
| 5668 | snprintf(resp, sizeof(resp), |
| 5669 | "interface,ath0_any,agent,1.0,version,%s", |
| 5670 | version); |
| 5671 | |
| 5672 | send_resp(dut, conn, SIGMA_COMPLETE, resp); |
| 5673 | return 0; |
| 5674 | } |
| 5675 | default: |
| 5676 | send_resp(dut, conn, SIGMA_ERROR, |
| 5677 | "errorCode,Unsupported openwrt driver"); |
| 5678 | return 0; |
| 5679 | } |
| 5680 | } |
| 5681 | default: |
| 5682 | send_resp(dut, conn, SIGMA_ERROR, |
| 5683 | "errorCode,Unsupported driver"); |
| 5684 | return 0; |
| 5685 | } |
| 5686 | } |
| 5687 | |
| 5688 | |
| 5689 | static int cmd_ap_deauth_sta(struct sigma_dut *dut, struct sigma_conn *conn, |
| 5690 | struct sigma_cmd *cmd) |
| 5691 | { |
| 5692 | /* const char *name = get_param(cmd, "NAME"); */ |
| 5693 | /* const char *ifname = get_param(cmd, "INTERFACE"); */ |
| 5694 | const char *val; |
| 5695 | char buf[100]; |
| 5696 | |
| 5697 | val = get_param(cmd, "MinorCode"); |
| 5698 | if (val) { |
| 5699 | /* TODO: add support for P2P minor code */ |
| 5700 | send_resp(dut, conn, SIGMA_ERROR, "errorCode,MinorCode not " |
| 5701 | "yet supported"); |
| 5702 | return 0; |
| 5703 | } |
| 5704 | |
| 5705 | val = get_param(cmd, "STA_MAC_ADDRESS"); |
| 5706 | if (val == NULL) |
| 5707 | return -1; |
| 5708 | snprintf(buf, sizeof(buf), "deauth %s", val); |
| 5709 | if (run_hostapd_cli(dut, buf) != 0) |
| 5710 | return -2; |
| 5711 | |
| 5712 | return 1; |
| 5713 | } |
| 5714 | |
| 5715 | |
| 5716 | #ifdef __linux__ |
| 5717 | int inject_frame(int s, const void *data, size_t len, int encrypt); |
| 5718 | int open_monitor(const char *ifname); |
| 5719 | int hwaddr_aton(const char *txt, unsigned char *addr); |
| 5720 | #endif /* __linux__ */ |
| 5721 | |
| 5722 | enum send_frame_type { |
| 5723 | DISASSOC, DEAUTH, SAQUERY |
| 5724 | }; |
| 5725 | enum send_frame_protection { |
| 5726 | CORRECT_KEY, INCORRECT_KEY, UNPROTECTED |
| 5727 | }; |
| 5728 | |
| 5729 | |
| 5730 | static int ap_inject_frame(struct sigma_dut *dut, struct sigma_conn *conn, |
| 5731 | enum send_frame_type frame, |
| 5732 | enum send_frame_protection protected, |
| 5733 | const char *sta_addr) |
| 5734 | { |
| 5735 | #ifdef __linux__ |
| 5736 | unsigned char buf[1000], *pos; |
| 5737 | int s, res; |
| 5738 | unsigned char addr_sta[6], addr_own[6]; |
| 5739 | char *ifname; |
| 5740 | char cbuf[100]; |
| 5741 | struct ifreq ifr; |
| 5742 | |
| 5743 | if ((dut->ap_mode == AP_11a || dut->ap_mode == AP_11na || |
| 5744 | dut->ap_mode == AP_11ac) && |
| 5745 | if_nametoindex("wlan1") > 0) |
| 5746 | ifname = "wlan1"; |
| 5747 | else |
| 5748 | ifname = "wlan0"; |
| 5749 | |
| 5750 | if (hwaddr_aton(sta_addr, addr_sta) < 0) |
| 5751 | return -1; |
| 5752 | |
| 5753 | s = socket(AF_INET, SOCK_DGRAM, 0); |
| 5754 | if (s < 0) |
| 5755 | return -1; |
| 5756 | memset(&ifr, 0, sizeof(ifr)); |
| 5757 | strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name)); |
| 5758 | if (ioctl(s, SIOCGIFHWADDR, &ifr) < 0) { |
| 5759 | perror("ioctl"); |
| 5760 | close(s); |
| 5761 | return -1; |
| 5762 | } |
| 5763 | close(s); |
| 5764 | memcpy(addr_own, ifr.ifr_hwaddr.sa_data, 6); |
| 5765 | |
| 5766 | if (if_nametoindex("sigmadut") == 0) { |
| 5767 | snprintf(cbuf, sizeof(cbuf), |
| 5768 | "iw dev %s interface add sigmadut type monitor", |
| 5769 | ifname); |
| 5770 | if (system(cbuf) != 0 || |
| 5771 | if_nametoindex("sigmadut") == 0) { |
| 5772 | sigma_dut_print(dut, DUT_MSG_ERROR, "Failed to add " |
| 5773 | "monitor interface with '%s'", cbuf); |
| 5774 | return -2; |
| 5775 | } |
| 5776 | } |
| 5777 | |
| 5778 | if (system("ifconfig sigmadut up") != 0) { |
| 5779 | sigma_dut_print(dut, DUT_MSG_ERROR, "Failed to set " |
| 5780 | "monitor interface up"); |
| 5781 | return -2; |
| 5782 | } |
| 5783 | |
| 5784 | pos = buf; |
| 5785 | |
| 5786 | /* Frame Control */ |
| 5787 | switch (frame) { |
| 5788 | case DISASSOC: |
| 5789 | *pos++ = 0xa0; |
| 5790 | break; |
| 5791 | case DEAUTH: |
| 5792 | *pos++ = 0xc0; |
| 5793 | break; |
| 5794 | case SAQUERY: |
| 5795 | *pos++ = 0xd0; |
| 5796 | break; |
| 5797 | } |
| 5798 | |
| 5799 | if (protected == INCORRECT_KEY) |
| 5800 | *pos++ = 0x40; /* Set Protected field to 1 */ |
| 5801 | else |
| 5802 | *pos++ = 0x00; |
| 5803 | |
| 5804 | /* Duration */ |
| 5805 | *pos++ = 0x00; |
| 5806 | *pos++ = 0x00; |
| 5807 | |
| 5808 | /* addr1 = DA (station) */ |
| 5809 | memcpy(pos, addr_sta, 6); |
| 5810 | pos += 6; |
| 5811 | /* addr2 = SA (own address) */ |
| 5812 | memcpy(pos, addr_own, 6); |
| 5813 | pos += 6; |
| 5814 | /* addr3 = BSSID (own address) */ |
| 5815 | memcpy(pos, addr_own, 6); |
| 5816 | pos += 6; |
| 5817 | |
| 5818 | /* Seq# (to be filled by driver/mac80211) */ |
| 5819 | *pos++ = 0x00; |
| 5820 | *pos++ = 0x00; |
| 5821 | |
| 5822 | if (protected == INCORRECT_KEY) { |
| 5823 | /* CCMP parameters */ |
| 5824 | memcpy(pos, "\x61\x01\x00\x20\x00\x10\x00\x00", 8); |
| 5825 | pos += 8; |
| 5826 | } |
| 5827 | |
| 5828 | if (protected == INCORRECT_KEY) { |
| 5829 | switch (frame) { |
| 5830 | case DEAUTH: |
| 5831 | /* Reason code (encrypted) */ |
| 5832 | memcpy(pos, "\xa7\x39", 2); |
| 5833 | pos += 2; |
| 5834 | break; |
| 5835 | case DISASSOC: |
| 5836 | /* Reason code (encrypted) */ |
| 5837 | memcpy(pos, "\xa7\x39", 2); |
| 5838 | pos += 2; |
| 5839 | break; |
| 5840 | case SAQUERY: |
| 5841 | /* Category|Action|TransID (encrypted) */ |
| 5842 | memcpy(pos, "\x6f\xbd\xe9\x4d", 4); |
| 5843 | pos += 4; |
| 5844 | break; |
| 5845 | default: |
| 5846 | return -1; |
| 5847 | } |
| 5848 | |
| 5849 | /* CCMP MIC */ |
| 5850 | memcpy(pos, "\xc8\xd8\x3b\x06\x5d\xb7\x25\x68", 8); |
| 5851 | pos += 8; |
| 5852 | } else { |
| 5853 | switch (frame) { |
| 5854 | case DEAUTH: |
| 5855 | /* reason code = 8 */ |
| 5856 | *pos++ = 0x08; |
| 5857 | *pos++ = 0x00; |
| 5858 | break; |
| 5859 | case DISASSOC: |
| 5860 | /* reason code = 8 */ |
| 5861 | *pos++ = 0x08; |
| 5862 | *pos++ = 0x00; |
| 5863 | break; |
| 5864 | case SAQUERY: |
| 5865 | /* Category - SA Query */ |
| 5866 | *pos++ = 0x08; |
| 5867 | /* SA query Action - Request */ |
| 5868 | *pos++ = 0x00; |
| 5869 | /* Transaction ID */ |
| 5870 | *pos++ = 0x12; |
| 5871 | *pos++ = 0x34; |
| 5872 | break; |
| 5873 | } |
| 5874 | } |
| 5875 | |
| 5876 | s = open_monitor("sigmadut"); |
| 5877 | if (s < 0) { |
| 5878 | send_resp(dut, conn, SIGMA_ERROR, "errorCode,Failed to open " |
| 5879 | "monitor socket"); |
| 5880 | return 0; |
| 5881 | } |
| 5882 | |
| 5883 | res = inject_frame(s, buf, pos - buf, protected == CORRECT_KEY); |
| 5884 | if (res < 0) { |
| 5885 | send_resp(dut, conn, SIGMA_ERROR, "errorCode,Failed to " |
| 5886 | "inject frame"); |
Pradeep Reddy POTTETI | 673d85c | 2016-07-26 19:08:07 +0530 | [diff] [blame] | 5887 | close(s); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5888 | return 0; |
| 5889 | } |
| 5890 | if (res < pos - buf) { |
| 5891 | send_resp(dut, conn, SIGMA_ERROR, "errorCode,Only partial " |
| 5892 | "frame sent"); |
Pradeep Reddy POTTETI | 673d85c | 2016-07-26 19:08:07 +0530 | [diff] [blame] | 5893 | close(s); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5894 | return 0; |
| 5895 | } |
| 5896 | |
| 5897 | close(s); |
| 5898 | |
| 5899 | return 1; |
| 5900 | #else /* __linux__ */ |
| 5901 | send_resp(dut, conn, SIGMA_ERROR, "errorCode,ap_send_frame not " |
| 5902 | "yet supported"); |
| 5903 | return 0; |
| 5904 | #endif /* __linux__ */ |
| 5905 | } |
| 5906 | |
| 5907 | |
| 5908 | int ap_send_frame_hs2(struct sigma_dut *dut, struct sigma_conn *conn, |
| 5909 | struct sigma_cmd *cmd) |
| 5910 | { |
| 5911 | const char *val, *dest; |
| 5912 | char buf[100]; |
| 5913 | |
| 5914 | val = get_param(cmd, "FrameName"); |
| 5915 | if (val == NULL) |
| 5916 | return -1; |
| 5917 | |
| 5918 | if (strcasecmp(val, "QoSMapConfigure") == 0) { |
| 5919 | dest = get_param(cmd, "Dest"); |
| 5920 | if (!dest) |
| 5921 | return -1; |
| 5922 | |
| 5923 | val = get_param(cmd, "QoS_MAP_SET"); |
| 5924 | if (val) { |
| 5925 | dut->ap_qos_map_set = atoi(val); |
| 5926 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_qos_map_set %d", |
| 5927 | dut->ap_qos_map_set); |
| 5928 | } |
| 5929 | |
| 5930 | if (dut->ap_qos_map_set == 1) |
| 5931 | run_hostapd_cli(dut, "set_qos_map_set " QOS_MAP_SET_1); |
| 5932 | else if (dut->ap_qos_map_set == 2) |
| 5933 | run_hostapd_cli(dut, "set_qos_map_set " QOS_MAP_SET_2); |
| 5934 | |
| 5935 | snprintf(buf, sizeof(buf), "send_qos_map_conf %s", dest); |
| 5936 | if (run_hostapd_cli(dut, buf) != 0) |
| 5937 | return -1; |
| 5938 | } |
| 5939 | |
| 5940 | return 1; |
| 5941 | } |
| 5942 | |
| 5943 | |
| 5944 | static int ath_ap_send_frame_vht(struct sigma_dut *dut, struct sigma_conn *conn, |
| 5945 | struct sigma_cmd *cmd) |
| 5946 | { |
| 5947 | const char *val; |
| 5948 | char *ifname; |
| 5949 | char buf[100]; |
| 5950 | int chwidth, nss; |
| 5951 | |
| 5952 | val = get_param(cmd, "FrameName"); |
| 5953 | if (!val || strcasecmp(val, "op_md_notif_frm") != 0) { |
| 5954 | send_resp(dut, conn, SIGMA_ERROR, |
| 5955 | "errorCode,Unsupported FrameName"); |
| 5956 | return 0; |
| 5957 | } |
| 5958 | |
| 5959 | /* |
| 5960 | * Sequence of commands for Opmode notification on |
| 5961 | * Peregrine based products |
| 5962 | */ |
| 5963 | ifname = get_main_ifname(); |
| 5964 | |
| 5965 | /* Disable STBC */ |
| 5966 | snprintf(buf, sizeof(buf), "iwpriv %s tx_stbc 0", ifname); |
| 5967 | if (system(buf) != 0) { |
| 5968 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5969 | "iwpriv tx_stbc 0 failed!"); |
| 5970 | } |
| 5971 | |
| 5972 | /* Check whether optional arg channel width was passed */ |
| 5973 | val = get_param(cmd, "Channel_width"); |
| 5974 | if (val) { |
| 5975 | switch (atoi(val)) { |
| 5976 | case 20: |
| 5977 | chwidth = 0; |
| 5978 | break; |
| 5979 | case 40: |
| 5980 | chwidth = 1; |
| 5981 | break; |
| 5982 | case 80: |
| 5983 | chwidth = 2; |
| 5984 | break; |
| 5985 | case 160: |
| 5986 | chwidth = 3; |
| 5987 | break; |
| 5988 | default: |
| 5989 | chwidth = 2; |
| 5990 | break; |
| 5991 | } |
| 5992 | snprintf(buf, sizeof(buf), "iwpriv %s chwidth %d", |
| 5993 | ifname, chwidth); |
| 5994 | if (system(buf) != 0) { |
| 5995 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 5996 | "iwpriv chwidth failed!"); |
| 5997 | } |
| 5998 | } |
| 5999 | |
| 6000 | /* Check whether optional arg NSS was passed */ |
| 6001 | val = get_param(cmd, "NSS"); |
| 6002 | if (val) { |
| 6003 | /* Convert nss to chainmask */ |
| 6004 | switch (atoi(val)) { |
| 6005 | case 1: |
| 6006 | nss = 1; |
| 6007 | break; |
| 6008 | case 2: |
| 6009 | nss = 3; |
| 6010 | break; |
| 6011 | case 3: |
| 6012 | nss = 7; |
| 6013 | break; |
| 6014 | default: |
| 6015 | /* We do not support NSS > 3 */ |
| 6016 | nss = 3; |
| 6017 | break; |
| 6018 | } |
| 6019 | snprintf(buf, sizeof(buf), "iwpriv %s rxchainmask %d", |
| 6020 | ifname, nss); |
| 6021 | if (system(buf) != 0) { |
| 6022 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 6023 | "iwpriv rxchainmask failed!"); |
| 6024 | } |
| 6025 | } |
| 6026 | |
| 6027 | /* Send the opmode notification */ |
| 6028 | snprintf(buf, sizeof(buf), "iwpriv %s opmode_notify 1", ifname); |
| 6029 | if (system(buf) != 0) { |
| 6030 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 6031 | "iwpriv opmode_notify failed!"); |
| 6032 | } |
| 6033 | |
| 6034 | return 1; |
| 6035 | } |
| 6036 | |
| 6037 | |
priyadharshini gowthaman | a27b5b6 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 6038 | static int ath_ap_send_frame_loc(struct sigma_dut *dut, struct sigma_conn *conn, |
| 6039 | struct sigma_cmd *cmd) |
| 6040 | { |
| 6041 | const char *val; |
| 6042 | FILE *f; |
| 6043 | |
| 6044 | val = get_param(cmd, "MsntType"); |
| 6045 | if (val) { |
| 6046 | if (dut->ap_msnt_type == 0) |
| 6047 | dut->ap_msnt_type = atoi(val); |
| 6048 | |
| 6049 | if (dut->ap_msnt_type != 5 && dut->ap_msnt_type != 2) { |
| 6050 | dut->ap_msnt_type = atoi(val); |
| 6051 | if (dut->ap_msnt_type == 1) { |
| 6052 | f = fopen("/tmp/ftmrr.txt", "a"); |
| 6053 | if (!f) { |
| 6054 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 6055 | "Failed to open /tmp/ftmrr.txt"); |
| 6056 | return -1; |
| 6057 | } |
| 6058 | |
| 6059 | fprintf(f, "sta_mac = %s\n", cmd->values[3]); |
| 6060 | fprintf(f, "meas_type = 0x10\nrand_inter = 0x0\nmin_ap_count = 0x%s\ndialogtoken = 0x1\nnum_repetitions = 0x0\nmeas_token = 0xf\nmeas_req_mode = 0x00\n", |
| 6061 | cmd->values[7]); |
| 6062 | fclose(f); |
| 6063 | dut->ap_msnt_type = 5; |
| 6064 | run_system(dut, "wpc -f /tmp/ftmrr.txt"); |
| 6065 | } |
| 6066 | } else if (dut->ap_msnt_type == 5) { |
| 6067 | run_system(dut, "wpc -f /tmp/ftmrr.txt"); |
| 6068 | } else if (dut->ap_msnt_type == 2) { |
| 6069 | f = fopen("/tmp/wru.txt", "w"); |
| 6070 | if (!f) { |
| 6071 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 6072 | "Failed to open /tmp/wru.txt"); |
| 6073 | return -1; |
| 6074 | } |
| 6075 | |
| 6076 | fprintf(f, "sta_mac = %s\n", cmd->values[3]); |
| 6077 | fprintf(f, "meas_type = 0x08\ndialogtoken = 0x1\nnum_repetitions = 0x0\nmeas_token = 0x1\nmeas_req_mode = 0x00\nloc_subject = 0x01\n"); |
| 6078 | fclose(f); |
| 6079 | run_system(dut, "wpc -w /tmp/wru.txt"); |
| 6080 | } |
| 6081 | } |
| 6082 | return 1; |
| 6083 | } |
| 6084 | |
| 6085 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6086 | static int ap_send_frame_vht(struct sigma_dut *dut, struct sigma_conn *conn, |
| 6087 | struct sigma_cmd *cmd) |
| 6088 | { |
| 6089 | switch (get_driver_type()) { |
| 6090 | case DRIVER_ATHEROS: |
| 6091 | return ath_ap_send_frame_vht(dut, conn, cmd); |
| 6092 | break; |
| 6093 | case DRIVER_OPENWRT: |
| 6094 | switch (get_openwrt_driver_type()) { |
| 6095 | case OPENWRT_DRIVER_ATHEROS: |
| 6096 | return ath_ap_send_frame_vht(dut, conn, cmd); |
| 6097 | default: |
| 6098 | send_resp(dut, conn, SIGMA_ERROR, |
| 6099 | "errorCode,Unsupported ap_send_frame with the current openwrt driver"); |
| 6100 | return 0; |
| 6101 | } |
| 6102 | default: |
| 6103 | send_resp(dut, conn, SIGMA_ERROR, |
| 6104 | "errorCode,Unsupported ap_send_frame with the current driver"); |
| 6105 | return 0; |
| 6106 | } |
| 6107 | } |
| 6108 | |
| 6109 | |
priyadharshini gowthaman | a27b5b6 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 6110 | static int ap_send_frame_loc(struct sigma_dut *dut, struct sigma_conn *conn, |
| 6111 | struct sigma_cmd *cmd) |
| 6112 | { |
| 6113 | switch (get_driver_type()) { |
| 6114 | case DRIVER_ATHEROS: |
| 6115 | return ath_ap_send_frame_loc(dut, conn, cmd); |
| 6116 | case DRIVER_OPENWRT: |
| 6117 | switch (get_openwrt_driver_type()) { |
| 6118 | case OPENWRT_DRIVER_ATHEROS: |
| 6119 | return ath_ap_send_frame_loc(dut, conn, cmd); |
| 6120 | default: |
| 6121 | send_resp(dut, conn, SIGMA_ERROR, |
| 6122 | "errorCode,Unsupported ap_send_frame_loc with the current openwrt driver"); |
| 6123 | return 0; |
| 6124 | } |
| 6125 | default: |
| 6126 | send_resp(dut, conn, SIGMA_ERROR, |
| 6127 | "errorCode,Unsupported ap_send_frame_loc with the current driver"); |
| 6128 | return 0; |
| 6129 | } |
| 6130 | } |
| 6131 | |
| 6132 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6133 | int cmd_ap_send_frame(struct sigma_dut *dut, struct sigma_conn *conn, |
| 6134 | struct sigma_cmd *cmd) |
| 6135 | { |
| 6136 | /* const char *name = get_param(cmd, "NAME"); */ |
| 6137 | /* const char *ifname = get_param(cmd, "INTERFACE"); */ |
| 6138 | const char *val; |
| 6139 | enum send_frame_type frame; |
| 6140 | enum send_frame_protection protected; |
| 6141 | char buf[100]; |
| 6142 | |
| 6143 | val = get_param(cmd, "Program"); |
| 6144 | if (val) { |
| 6145 | if (strcasecmp(val, "HS2") == 0 || |
| 6146 | strcasecmp(val, "HS2-R2") == 0) |
| 6147 | return ap_send_frame_hs2(dut, conn, cmd); |
| 6148 | if (strcasecmp(val, "VHT") == 0) |
| 6149 | return ap_send_frame_vht(dut, conn, cmd); |
priyadharshini gowthaman | a27b5b6 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 6150 | if (strcasecmp(val, "LOC") == 0) |
| 6151 | return ap_send_frame_loc(dut, conn, cmd); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6152 | } |
| 6153 | |
| 6154 | val = get_param(cmd, "PMFFrameType"); |
| 6155 | if (val == NULL) |
| 6156 | val = get_param(cmd, "FrameName"); |
| 6157 | if (val == NULL) |
| 6158 | val = get_param(cmd, "Type"); |
| 6159 | if (val == NULL) |
| 6160 | return -1; |
| 6161 | if (strcasecmp(val, "disassoc") == 0) |
| 6162 | frame = DISASSOC; |
| 6163 | else if (strcasecmp(val, "deauth") == 0) |
| 6164 | frame = DEAUTH; |
| 6165 | else if (strcasecmp(val, "saquery") == 0) |
| 6166 | frame = SAQUERY; |
| 6167 | else { |
| 6168 | send_resp(dut, conn, SIGMA_ERROR, "errorCode,Unsupported " |
| 6169 | "PMFFrameType"); |
| 6170 | return 0; |
| 6171 | } |
| 6172 | |
| 6173 | val = get_param(cmd, "PMFProtected"); |
| 6174 | if (val == NULL) |
| 6175 | val = get_param(cmd, "Protected"); |
| 6176 | if (val == NULL) |
| 6177 | return -1; |
| 6178 | if (strcasecmp(val, "Correct-key") == 0 || |
| 6179 | strcasecmp(val, "CorrectKey") == 0) |
| 6180 | protected = CORRECT_KEY; |
| 6181 | else if (strcasecmp(val, "IncorrectKey") == 0) |
| 6182 | protected = INCORRECT_KEY; |
| 6183 | else if (strcasecmp(val, "Unprotected") == 0) |
| 6184 | protected = UNPROTECTED; |
| 6185 | else { |
| 6186 | send_resp(dut, conn, SIGMA_ERROR, "errorCode,Unsupported " |
| 6187 | "PMFProtected"); |
| 6188 | return 0; |
| 6189 | } |
| 6190 | |
| 6191 | val = get_param(cmd, "stationID"); |
| 6192 | if (val == NULL) |
| 6193 | return -1; |
| 6194 | |
| 6195 | if (protected == INCORRECT_KEY || |
| 6196 | (protected == UNPROTECTED && frame == SAQUERY)) |
| 6197 | return ap_inject_frame(dut, conn, frame, protected, val); |
| 6198 | |
| 6199 | switch (frame) { |
| 6200 | case DISASSOC: |
| 6201 | snprintf(buf, sizeof(buf), "disassoc %s test=%d", |
| 6202 | val, protected == CORRECT_KEY); |
| 6203 | break; |
| 6204 | case DEAUTH: |
| 6205 | snprintf(buf, sizeof(buf), "deauth %s test=%d", |
| 6206 | val, protected == CORRECT_KEY); |
| 6207 | break; |
| 6208 | case SAQUERY: |
| 6209 | snprintf(buf, sizeof(buf), "sa_query %s", val); |
| 6210 | break; |
| 6211 | } |
| 6212 | |
| 6213 | if (run_hostapd_cli(dut, buf) != 0) |
| 6214 | return -2; |
| 6215 | |
| 6216 | return 1; |
| 6217 | } |
| 6218 | |
| 6219 | |
| 6220 | static int cmd_ap_get_mac_address(struct sigma_dut *dut, |
| 6221 | struct sigma_conn *conn, |
| 6222 | struct sigma_cmd *cmd) |
| 6223 | { |
| 6224 | #if defined( __linux__) |
| 6225 | /* const char *name = get_param(cmd, "NAME"); */ |
| 6226 | /* const char *ifname = get_param(cmd, "INTERFACE"); */ |
| 6227 | char resp[50]; |
| 6228 | unsigned char addr[6]; |
| 6229 | char *ifname; |
| 6230 | struct ifreq ifr; |
| 6231 | int s; |
| 6232 | enum driver_type drv; |
| 6233 | |
| 6234 | drv = get_driver_type(); |
| 6235 | |
| 6236 | if (drv == DRIVER_ATHEROS) { |
| 6237 | if ((dut->ap_mode == AP_11a || dut->ap_mode == AP_11na || |
| 6238 | dut->ap_mode == AP_11ac) && |
| 6239 | if_nametoindex("ath1") > 0) |
| 6240 | ifname = "ath1"; |
| 6241 | else |
| 6242 | ifname = "ath0"; |
| 6243 | } else if (drv == DRIVER_OPENWRT) { |
| 6244 | if (sigma_radio_ifname[0] && |
| 6245 | strcmp(sigma_radio_ifname[0], "wifi2") == 0) |
| 6246 | ifname = "ath2"; |
| 6247 | else if (sigma_radio_ifname[0] && |
| 6248 | strcmp(sigma_radio_ifname[0], "wifi1") == 0) |
| 6249 | ifname = "ath1"; |
| 6250 | else |
| 6251 | ifname = "ath0"; |
| 6252 | } else { |
| 6253 | if ((dut->ap_mode == AP_11a || dut->ap_mode == AP_11na || |
| 6254 | dut->ap_mode == AP_11ac) && |
| 6255 | if_nametoindex("wlan1") > 0) |
| 6256 | ifname = "wlan1"; |
| 6257 | else |
| 6258 | ifname = "wlan0"; |
| 6259 | } |
| 6260 | |
| 6261 | s = socket(AF_INET, SOCK_DGRAM, 0); |
| 6262 | if (s < 0) |
| 6263 | return -1; |
| 6264 | memset(&ifr, 0, sizeof(ifr)); |
| 6265 | strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name)); |
| 6266 | if (ioctl(s, SIOCGIFHWADDR, &ifr) < 0) { |
| 6267 | perror("ioctl"); |
| 6268 | close(s); |
| 6269 | return -1; |
| 6270 | } |
| 6271 | close(s); |
| 6272 | memcpy(addr, ifr.ifr_hwaddr.sa_data, 6); |
| 6273 | |
| 6274 | snprintf(resp, sizeof(resp), "mac,%02x:%02x:%02x:%02x:%02x:%02x", |
| 6275 | addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]); |
| 6276 | send_resp(dut, conn, SIGMA_COMPLETE, resp); |
| 6277 | return 0; |
| 6278 | #elif defined( __QNXNTO__) |
| 6279 | char resp[50]; |
| 6280 | unsigned char addr[6]; |
| 6281 | |
| 6282 | if (!sigma_main_ifname) { |
| 6283 | send_resp(dut, conn, SIGMA_ERROR, "ifname is null"); |
| 6284 | return 0; |
| 6285 | } |
| 6286 | |
| 6287 | if (get_hwaddr(sigma_main_ifname, addr) != 0) { |
| 6288 | send_resp(dut, conn, SIGMA_ERROR, |
| 6289 | "errorCode,Failed to get address"); |
| 6290 | return 0; |
| 6291 | } |
| 6292 | snprintf(resp, sizeof(resp), "mac,%02x:%02x:%02x:%02x:%02x:%02x", |
| 6293 | addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]); |
| 6294 | send_resp(dut, conn, SIGMA_COMPLETE, resp); |
| 6295 | return 0; |
| 6296 | #else /* __linux__ */ |
| 6297 | send_resp(dut, conn, SIGMA_ERROR, "errorCode,ap_get_mac_address not " |
| 6298 | "yet supported"); |
| 6299 | return 0; |
| 6300 | #endif /* __linux__ */ |
| 6301 | } |
| 6302 | |
| 6303 | |
| 6304 | static int cmd_ap_set_pmf(struct sigma_dut *dut, struct sigma_conn *conn, |
| 6305 | struct sigma_cmd *cmd) |
| 6306 | { |
| 6307 | /* |
| 6308 | * Ignore the command since the parameters are already handled through |
| 6309 | * ap_set_security. |
| 6310 | */ |
| 6311 | |
| 6312 | return 1; |
| 6313 | } |
| 6314 | |
| 6315 | |
| 6316 | static int cmd_ap_set_hs2(struct sigma_dut *dut, struct sigma_conn *conn, |
| 6317 | struct sigma_cmd *cmd) |
| 6318 | { |
| 6319 | /* const char *name = get_param(cmd, "NAME"); */ |
| 6320 | /* const char *ifname = get_param(cmd, "INTERFACE"); */ |
| 6321 | const char *val, *dest; |
| 6322 | char *pos, buf[100]; |
| 6323 | int i, wlan_tag = 1; |
| 6324 | |
| 6325 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_set_hs2: Processing the " |
| 6326 | "following parameters"); |
| 6327 | for (i = 0; i < cmd->count; i++) { |
| 6328 | sigma_dut_print(dut, DUT_MSG_INFO, "%s %s", cmd->params[i], |
| 6329 | (cmd->values[i] ? cmd->values[i] : "NULL")); |
| 6330 | } |
| 6331 | |
| 6332 | val = get_param(cmd, "ICMPv4_ECHO"); |
| 6333 | if (val && atoi(val)) { |
| 6334 | snprintf(buf, sizeof(buf), "ebtables -F"); |
| 6335 | if (system(buf) != 0) { |
| 6336 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 6337 | "Failed to set ebtables rules, RULE-12"); |
| 6338 | } |
| 6339 | return 1; |
| 6340 | } |
| 6341 | |
| 6342 | val = get_param(cmd, "WLAN_TAG"); |
| 6343 | if (val) { |
| 6344 | wlan_tag = atoi(val); |
| 6345 | if (wlan_tag != 1 && wlan_tag != 2) { |
| 6346 | send_resp(dut, conn, SIGMA_INVALID, |
| 6347 | "errorCode,Invalid WLAN_TAG"); |
| 6348 | return 0; |
| 6349 | } |
| 6350 | } |
| 6351 | |
| 6352 | if (wlan_tag == 2) { |
| 6353 | val = get_param(cmd, "PROXY_ARP"); |
| 6354 | if (val) |
| 6355 | dut->ap2_proxy_arp = atoi(val); |
| 6356 | return 1; |
| 6357 | } |
| 6358 | |
| 6359 | dest = get_param(cmd, "STA_MAC"); |
| 6360 | if (dest) { |
| 6361 | /* This is a special/ugly way of using this command. |
| 6362 | * If "Dest" MAC is included, assume that this command |
| 6363 | * is being issued after ap_config_commit for dynamically |
| 6364 | * setting the QoS Map Set. |
| 6365 | */ |
| 6366 | val = get_param(cmd, "QoS_MAP_SET"); |
| 6367 | if (val) { |
| 6368 | dut->ap_qos_map_set = atoi(val); |
| 6369 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_qos_map_set %d", |
| 6370 | dut->ap_qos_map_set); |
| 6371 | } |
| 6372 | |
| 6373 | if (dut->ap_qos_map_set == 1) |
| 6374 | run_hostapd_cli(dut, "set_qos_map_set " QOS_MAP_SET_1); |
| 6375 | else if (dut->ap_qos_map_set == 2) |
| 6376 | run_hostapd_cli(dut, "set_qos_map_set " QOS_MAP_SET_2); |
| 6377 | |
| 6378 | snprintf(buf, sizeof(buf), "send_qos_map_conf %s", dest); |
| 6379 | if (run_hostapd_cli(dut, buf) != 0) |
| 6380 | return -1; |
| 6381 | } |
| 6382 | |
| 6383 | val = get_param(cmd, "DGAF_DISABLE"); |
| 6384 | if (val) |
| 6385 | dut->ap_dgaf_disable = atoi(val); |
| 6386 | |
| 6387 | dut->ap_interworking = 1; |
| 6388 | |
| 6389 | val = get_param(cmd, "INTERWORKING"); |
| 6390 | if (val == NULL) |
| 6391 | val = get_param(cmd, "INTERNETWORKING"); |
| 6392 | if (val != NULL && atoi(val) == 0) { |
| 6393 | dut->ap_interworking = 0; |
| 6394 | dut->ap_hs2 = 0; |
| 6395 | return 1; |
| 6396 | } |
| 6397 | |
| 6398 | val = get_param(cmd, "ACCS_NET_TYPE"); |
| 6399 | if (val) { |
| 6400 | if (strcasecmp(val, "Chargeable_Public_Network") == 0 || |
| 6401 | strcasecmp(val, "Chargable_Public_Network") == 0 || |
| 6402 | strcasecmp(val, "Chargable Public Network") == 0) |
| 6403 | dut->ap_access_net_type = 2; |
| 6404 | else |
| 6405 | dut->ap_access_net_type = atoi(val); |
| 6406 | } |
| 6407 | |
| 6408 | val = get_param(cmd, "INTERNET"); |
| 6409 | if (val) |
| 6410 | dut->ap_internet = atoi(val); |
| 6411 | |
| 6412 | val = get_param(cmd, "VENUE_GRP"); |
| 6413 | if (val) { |
| 6414 | if (strcasecmp(val, "Business") == 0) |
| 6415 | dut->ap_venue_group = 2; |
| 6416 | else |
| 6417 | dut->ap_venue_group = atoi(val); |
| 6418 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_venue_name %d", |
| 6419 | dut->ap_venue_name); |
| 6420 | } |
| 6421 | |
| 6422 | val = get_param(cmd, "VENUE_TYPE"); |
| 6423 | if (val) { |
| 6424 | if (strcasecmp(val, "R&D") == 0) |
| 6425 | dut->ap_venue_type = 8; |
| 6426 | else |
| 6427 | dut->ap_venue_type = atoi(val); |
| 6428 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_venue_type %d", |
| 6429 | dut->ap_venue_type); |
| 6430 | } |
| 6431 | |
| 6432 | val = get_param(cmd, "HESSID"); |
| 6433 | if (val) { |
| 6434 | if (strlen(val) >= sizeof(dut->ap_hessid)) { |
| 6435 | send_resp(dut, conn, SIGMA_ERROR, |
| 6436 | "errorCode,Invalid HESSID"); |
| 6437 | return 0; |
| 6438 | } |
| 6439 | snprintf(dut->ap_hessid, sizeof(dut->ap_hessid), "%s", val); |
| 6440 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_hessid %s", |
| 6441 | dut->ap_hessid); |
| 6442 | } |
| 6443 | |
| 6444 | val = get_param(cmd, "ROAMING_CONS"); |
| 6445 | if (val) { |
| 6446 | if (strlen(val) >= sizeof(dut->ap_roaming_cons)) { |
| 6447 | send_resp(dut, conn, SIGMA_ERROR, |
| 6448 | "errorCode,Invalid ROAMING_CONS"); |
| 6449 | return 0; |
| 6450 | } |
| 6451 | if (strcasecmp(val, "Disabled") == 0) { |
| 6452 | dut->ap_roaming_cons[0] = '\0'; |
| 6453 | } else { |
| 6454 | snprintf(dut->ap_roaming_cons, |
| 6455 | sizeof(dut->ap_roaming_cons), "%s", val); |
| 6456 | } |
| 6457 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_roaming_cons %s", |
| 6458 | dut->ap_roaming_cons); |
| 6459 | } |
| 6460 | |
| 6461 | val = get_param(cmd, "ANQP"); |
| 6462 | if (val) |
| 6463 | dut->ap_anqpserver_on = atoi(val); |
| 6464 | |
| 6465 | val = get_param(cmd, "NAI_REALM_LIST"); |
| 6466 | if (val) { |
| 6467 | dut->ap_nai_realm_list = atoi(val); |
| 6468 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_nai_realm_list %d", |
| 6469 | dut->ap_nai_realm_list); |
| 6470 | } |
| 6471 | |
| 6472 | val = get_param(cmd, "3GPP_INFO"); |
| 6473 | if (val) { |
| 6474 | /* What kind of encoding format is used?! */ |
| 6475 | send_resp(dut, conn, SIGMA_ERROR, "errorCode,3GPP_INFO " |
| 6476 | "not yet supported (contents not fully defined)"); |
| 6477 | return 0; |
| 6478 | } |
| 6479 | |
| 6480 | val = get_param(cmd, "DOMAIN_LIST"); |
| 6481 | if (val) { |
| 6482 | if (strlen(val) >= sizeof(dut->ap_domain_name_list)) { |
| 6483 | send_resp(dut, conn, SIGMA_ERROR, "errorCode,Too long " |
| 6484 | "DOMAIN_LIST"); |
| 6485 | return 0; |
| 6486 | } |
| 6487 | snprintf(dut->ap_domain_name_list, |
| 6488 | sizeof(dut->ap_domain_name_list), "%s", val); |
| 6489 | pos = dut->ap_domain_name_list; |
| 6490 | while (*pos) { |
| 6491 | if (*pos == ';') |
| 6492 | *pos = ','; |
| 6493 | pos++; |
| 6494 | } |
| 6495 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_domain_name_list %s", |
| 6496 | dut->ap_domain_name_list); |
| 6497 | } |
| 6498 | |
| 6499 | val = get_param(cmd, "OPER_NAME"); |
| 6500 | if (val) { |
| 6501 | dut->ap_oper_name = atoi(val); |
| 6502 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_oper_name %d", |
| 6503 | dut->ap_oper_name); |
| 6504 | } |
| 6505 | |
| 6506 | val = get_param(cmd, "VENUE_NAME"); |
| 6507 | if (val) { |
| 6508 | dut->ap_venue_name = atoi(val); |
| 6509 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_venue_name %d", |
| 6510 | dut->ap_venue_name); |
| 6511 | } |
| 6512 | |
| 6513 | val = get_param(cmd, "GAS_CB_DELAY"); |
| 6514 | if (val) { |
| 6515 | dut->ap_gas_cb_delay = atoi(val); |
| 6516 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_gas_cb_delay %d", |
| 6517 | dut->ap_gas_cb_delay); |
| 6518 | } |
| 6519 | |
| 6520 | val = get_param(cmd, "MIH"); |
| 6521 | if (val && atoi(val) > 0) { |
| 6522 | send_resp(dut, conn, SIGMA_ERROR, "errorCode,MIH not " |
| 6523 | "supported"); |
| 6524 | return 0; |
| 6525 | } |
| 6526 | |
| 6527 | val = get_param(cmd, "L2_TRAFFIC_INSPECT"); |
| 6528 | if (val) { |
| 6529 | dut->ap_l2tif = atoi(val); |
| 6530 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_l2tif %d", |
| 6531 | dut->ap_l2tif); |
| 6532 | } |
| 6533 | |
| 6534 | val = get_param(cmd, "BCST_UNCST"); |
| 6535 | if (val) { |
| 6536 | send_resp(dut, conn, SIGMA_ERROR, |
| 6537 | "errorCode,BCST_UNCST not yet supported"); |
| 6538 | return 0; |
| 6539 | } |
| 6540 | |
| 6541 | val = get_param(cmd, "PLMN_MCC"); |
| 6542 | if (val) { |
| 6543 | char mcc[100], *start, *end; |
| 6544 | int i = 0; |
| 6545 | if (strlen(val) >= sizeof(mcc)) { |
| 6546 | send_resp(dut, conn, SIGMA_ERROR, |
| 6547 | "errorCode,PLMN_MCC too long"); |
| 6548 | return 0; |
| 6549 | } |
| 6550 | strncpy(mcc, val, sizeof(mcc)); |
| 6551 | start = mcc; |
| 6552 | while ((end = strchr(start, ';'))) { |
| 6553 | /* process all except the last */ |
| 6554 | *end = '\0'; |
| 6555 | if (strlen(start) != 3) { |
| 6556 | send_resp(dut, conn, SIGMA_ERROR, |
| 6557 | "errorCode,Invalid PLMN_MCC"); |
| 6558 | return 0; |
| 6559 | } |
| 6560 | snprintf(dut->ap_plmn_mcc[i], |
| 6561 | sizeof(dut->ap_plmn_mcc[i]), "%s", start); |
| 6562 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_plmn_mcc %s", |
| 6563 | dut->ap_plmn_mcc[i]); |
| 6564 | i++; |
| 6565 | start = end + 1; |
| 6566 | *end = ';'; |
| 6567 | } |
| 6568 | if (strlen(start) != 3) { |
| 6569 | send_resp(dut, conn, SIGMA_ERROR, |
| 6570 | "errorCode,Invalid PLMN_MCC"); |
| 6571 | return 0; |
| 6572 | } |
| 6573 | /* process last or only one */ |
| 6574 | snprintf(dut->ap_plmn_mcc[i], |
| 6575 | sizeof(dut->ap_plmn_mcc[i]), "%s", start); |
| 6576 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_plmn_mcc %s", |
| 6577 | dut->ap_plmn_mcc[i]); |
| 6578 | } |
| 6579 | |
| 6580 | val = get_param(cmd, "PLMN_MNC"); |
| 6581 | if (val) { |
| 6582 | char mnc[100], *start, *end; |
| 6583 | int i = 0; |
| 6584 | if (strlen(val) >= sizeof(mnc)) { |
| 6585 | send_resp(dut, conn, SIGMA_ERROR, |
| 6586 | "errorCode,PLMN_MNC too long"); |
| 6587 | return 0; |
| 6588 | } |
| 6589 | strncpy(mnc, val, sizeof(mnc)); |
| 6590 | start = mnc; |
| 6591 | while ((end = strchr(start, ';'))) { |
| 6592 | *end = '\0'; |
| 6593 | if (strlen(start) != 2 && strlen(start) != 3) { |
| 6594 | send_resp(dut, conn, SIGMA_ERROR, |
| 6595 | "errorCode,Invalid PLMN_MNC"); |
| 6596 | return 0; |
| 6597 | } |
| 6598 | snprintf(dut->ap_plmn_mnc[i], |
| 6599 | sizeof(dut->ap_plmn_mnc[i]), "%s", start); |
| 6600 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_plmn_mnc %s", |
| 6601 | dut->ap_plmn_mnc[i]); |
| 6602 | i++; |
| 6603 | start = end + 1; |
| 6604 | *end = ';'; |
| 6605 | } |
| 6606 | if (strlen(start) != 2 && strlen(start) != 3) { |
| 6607 | send_resp(dut, conn, SIGMA_ERROR, |
| 6608 | "errorCode,Invalid PLMN_MNC"); |
| 6609 | return 0; |
| 6610 | } |
| 6611 | snprintf(dut->ap_plmn_mnc[i], |
| 6612 | sizeof(dut->ap_plmn_mnc[i]), "%s", start); |
| 6613 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_plmn_mnc %s", |
| 6614 | dut->ap_plmn_mnc[i]); |
| 6615 | } |
| 6616 | |
| 6617 | val = get_param(cmd, "PROXY_ARP"); |
| 6618 | if (val) { |
| 6619 | dut->ap_proxy_arp = atoi(val); |
| 6620 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_proxy_arp %d", |
| 6621 | dut->ap_proxy_arp); |
| 6622 | } |
| 6623 | |
| 6624 | val = get_param(cmd, "WAN_METRICS"); |
| 6625 | if (val) { |
| 6626 | dut->ap_wan_metrics = atoi(val); |
| 6627 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_wan_metrics %d", |
| 6628 | dut->ap_wan_metrics); |
| 6629 | } |
| 6630 | |
| 6631 | val = get_param(cmd, "CONN_CAP"); |
| 6632 | if (val) { |
| 6633 | dut->ap_conn_capab = atoi(val); |
| 6634 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_conn_capab %d", |
| 6635 | dut->ap_conn_capab); |
| 6636 | } |
| 6637 | |
| 6638 | val = get_param(cmd, "IP_ADD_TYPE_AVAIL"); |
| 6639 | if (val) { |
| 6640 | dut->ap_ip_addr_type_avail = atoi(val); |
| 6641 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_ip_addr_type_avail %d", |
| 6642 | dut->ap_ip_addr_type_avail); |
| 6643 | } |
| 6644 | |
| 6645 | val = get_param(cmd, "NET_AUTH_TYPE"); |
| 6646 | if (val) { |
| 6647 | dut->ap_net_auth_type = atoi(val); |
| 6648 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_net_auth_type %d", |
| 6649 | dut->ap_net_auth_type); |
| 6650 | } |
| 6651 | |
| 6652 | val = get_param(cmd, "OP_CLASS"); |
| 6653 | if (val == NULL) |
| 6654 | val = get_param(cmd, "OPER_CLASS"); |
| 6655 | if (val) { |
| 6656 | dut->ap_oper_class = atoi(val); |
| 6657 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_oper_class %d", |
| 6658 | dut->ap_oper_class); |
| 6659 | } |
| 6660 | |
| 6661 | val = get_param(cmd, "OSU_PROVIDER_LIST"); |
| 6662 | if (val) { |
| 6663 | dut->ap_osu_provider_list = atoi(val); |
| 6664 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_osu_provider_list %d", |
| 6665 | dut->ap_osu_provider_list); |
| 6666 | } |
| 6667 | |
| 6668 | val = get_param(cmd, "OSU_SERVER_URI"); |
| 6669 | if (val) { |
| 6670 | i = 0; |
| 6671 | do { |
| 6672 | int len; |
| 6673 | const char *uri = val; |
| 6674 | val = strchr(val, ' '); |
| 6675 | len = val ? (val++ - uri) : (int) strlen(uri); |
| 6676 | if (len > 0 && len < 256) { |
| 6677 | memcpy(dut->ap_osu_server_uri[i], uri, len); |
| 6678 | dut->ap_osu_server_uri[i][len] = '\0'; |
| 6679 | sigma_dut_print(dut, DUT_MSG_INFO, |
| 6680 | "ap_osu_server_uri[%d] %s", i, |
| 6681 | dut->ap_osu_server_uri[i]); |
| 6682 | } |
| 6683 | } while (val && ++i < 10); |
| 6684 | } |
| 6685 | |
| 6686 | val = get_param(cmd, "OSU_METHOD"); |
| 6687 | if (val) { |
| 6688 | i = 0; |
| 6689 | do { |
| 6690 | int len; |
| 6691 | const char *method = val; |
| 6692 | val = strchr(val, ' '); |
| 6693 | len = val ? (val++ - method) : (int) strlen(method); |
| 6694 | if (len > 0) { |
| 6695 | if (strncasecmp(method, "SOAP", len) == 0) |
| 6696 | dut->ap_osu_method[i] = 1; |
| 6697 | else if (strncasecmp(method, "OMADM", len) == 0) |
| 6698 | dut->ap_osu_method[i] = 0; |
| 6699 | else |
| 6700 | return -2; |
| 6701 | } |
| 6702 | } while (val && ++i < 10); |
| 6703 | } |
| 6704 | |
| 6705 | val = get_param(cmd, "OSU_SSID"); |
| 6706 | if (val) { |
| 6707 | if (strlen(val) > 0 && strlen(val) <= 32) { |
| 6708 | strncpy(dut->ap_osu_ssid, val, |
| 6709 | sizeof(dut->ap_osu_ssid)); |
| 6710 | sigma_dut_print(dut, DUT_MSG_INFO, |
| 6711 | "ap_osu_ssid %s", |
| 6712 | dut->ap_osu_ssid); |
| 6713 | } |
| 6714 | } |
| 6715 | |
| 6716 | val = get_param(cmd, "OSU_ICON_TAG"); |
| 6717 | if (val) |
| 6718 | dut->ap_osu_icon_tag = atoi(val); |
| 6719 | |
| 6720 | val = get_param(cmd, "QoS_MAP_SET"); |
| 6721 | if (val) { |
| 6722 | dut->ap_qos_map_set = atoi(val); |
| 6723 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_qos_map_set %d", |
| 6724 | dut->ap_qos_map_set); |
| 6725 | } |
| 6726 | |
| 6727 | val = get_param(cmd, "BSS_LOAD"); |
| 6728 | if (val) { |
| 6729 | dut->ap_bss_load = atoi(val); |
| 6730 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_bss_load %d", |
| 6731 | dut->ap_bss_load); |
| 6732 | } |
| 6733 | |
| 6734 | return 1; |
| 6735 | } |
| 6736 | |
| 6737 | |
| 6738 | void nfc_status(struct sigma_dut *dut, const char *state, const char *oper) |
| 6739 | { |
| 6740 | char buf[100]; |
| 6741 | |
| 6742 | if (!file_exists("nfc-status")) |
| 6743 | return; |
| 6744 | |
| 6745 | snprintf(buf, sizeof(buf), "./nfc-status %s %s", state, oper); |
| 6746 | run_system(dut, buf); |
| 6747 | } |
| 6748 | |
| 6749 | |
| 6750 | static int run_nfc_command(struct sigma_dut *dut, const char *cmd, |
| 6751 | const char *info) |
| 6752 | { |
| 6753 | int res; |
| 6754 | |
| 6755 | printf("\n\n\n=====[ NFC operation ]=========================\n\n"); |
| 6756 | printf("%s\n\n", info); |
| 6757 | |
| 6758 | nfc_status(dut, "START", info); |
| 6759 | res = run_system(dut, cmd); |
| 6760 | nfc_status(dut, res ? "FAIL" : "SUCCESS", info); |
| 6761 | if (res) { |
| 6762 | sigma_dut_print(dut, DUT_MSG_INFO, "Failed to run '%s': %d", |
| 6763 | cmd, res); |
| 6764 | return res; |
| 6765 | } |
| 6766 | |
| 6767 | return 0; |
| 6768 | } |
| 6769 | |
| 6770 | |
| 6771 | static int ap_nfc_write_config_token(struct sigma_dut *dut, |
| 6772 | struct sigma_conn *conn, |
| 6773 | struct sigma_cmd *cmd) |
| 6774 | { |
| 6775 | int res; |
| 6776 | char buf[300]; |
| 6777 | |
| 6778 | run_system(dut, "killall wps-ap-nfc.py"); |
| 6779 | unlink("nfc-success"); |
| 6780 | snprintf(buf, sizeof(buf), |
| 6781 | "./wps-ap-nfc.py --no-wait %s%s --success nfc-success write-config", |
| 6782 | dut->summary_log ? "--summary " : "", |
| 6783 | dut->summary_log ? dut->summary_log : ""); |
| 6784 | res = run_nfc_command(dut, buf, |
| 6785 | "Touch NFC Tag to write WPS configuration token"); |
| 6786 | if (res || !file_exists("nfc-success")) { |
| 6787 | send_resp(dut, conn, SIGMA_ERROR, |
| 6788 | "ErrorCode,Failed to write tag"); |
| 6789 | return 0; |
| 6790 | } |
| 6791 | |
| 6792 | return 1; |
| 6793 | } |
| 6794 | |
| 6795 | |
| 6796 | static int ap_nfc_wps_read_passwd(struct sigma_dut *dut, |
| 6797 | struct sigma_conn *conn, |
| 6798 | struct sigma_cmd *cmd) |
| 6799 | { |
| 6800 | int res; |
| 6801 | char buf[300]; |
| 6802 | |
| 6803 | run_system(dut, "killall wps-ap-nfc.py"); |
| 6804 | |
| 6805 | unlink("nfc-success"); |
| 6806 | snprintf(buf, sizeof(buf), |
| 6807 | "./wps-ap-nfc.py -1 --no-wait %s%s --success nfc-success", |
| 6808 | dut->summary_log ? "--summary " : "", |
| 6809 | dut->summary_log ? dut->summary_log : ""); |
| 6810 | res = run_nfc_command(dut, buf, "Touch NFC Tag to read it"); |
| 6811 | if (res || !file_exists("nfc-success")) { |
| 6812 | send_resp(dut, conn, SIGMA_ERROR, |
| 6813 | "ErrorCode,Failed to read tag"); |
| 6814 | return 0; |
| 6815 | } |
| 6816 | |
| 6817 | return 1; |
| 6818 | } |
| 6819 | |
| 6820 | |
| 6821 | static int ap_nfc_write_password_token(struct sigma_dut *dut, |
| 6822 | struct sigma_conn *conn, |
| 6823 | struct sigma_cmd *cmd) |
| 6824 | { |
| 6825 | int res; |
| 6826 | char buf[300]; |
| 6827 | |
| 6828 | run_system(dut, "killall wps-ap-nfc.py"); |
| 6829 | unlink("nfc-success"); |
| 6830 | snprintf(buf, sizeof(buf), |
| 6831 | "./wps-ap-nfc.py --no-wait %s%s --success nfc-success write-password", |
| 6832 | dut->summary_log ? "--summary " : "", |
| 6833 | dut->summary_log ? dut->summary_log : ""); |
| 6834 | res = run_nfc_command(dut, buf, |
| 6835 | "Touch NFC Tag to write WPS password token"); |
| 6836 | if (res || !file_exists("nfc-success")) { |
| 6837 | send_resp(dut, conn, SIGMA_ERROR, |
| 6838 | "ErrorCode,Failed to write tag"); |
| 6839 | return 0; |
| 6840 | } |
| 6841 | |
| 6842 | if (run_hostapd_cli(dut, "wps_nfc_token enable") != 0) { |
| 6843 | send_resp(dut, conn, SIGMA_ERROR, |
| 6844 | "ErrorCode,Failed to enable NFC password token"); |
| 6845 | return 0; |
| 6846 | } |
| 6847 | |
| 6848 | return 1; |
| 6849 | } |
| 6850 | |
| 6851 | |
| 6852 | static int ap_nfc_wps_connection_handover(struct sigma_dut *dut, |
| 6853 | struct sigma_conn *conn, |
| 6854 | struct sigma_cmd *cmd) |
| 6855 | { |
| 6856 | int res; |
| 6857 | char buf[300]; |
| 6858 | |
| 6859 | run_system(dut, "killall wps-ap-nfc.py"); |
| 6860 | unlink("nfc-success"); |
| 6861 | snprintf(buf, sizeof(buf), |
| 6862 | "./wps-ap-nfc.py -1 --no-wait %s%s --success nfc-success", |
| 6863 | dut->summary_log ? "--summary " : "", |
| 6864 | dut->summary_log ? dut->summary_log : ""); |
| 6865 | res = run_nfc_command(dut, buf, |
| 6866 | "Touch NFC Device to respond to WPS connection handover"); |
| 6867 | if (res) { |
| 6868 | send_resp(dut, conn, SIGMA_ERROR, |
| 6869 | "ErrorCode,Failed to enable NFC for connection " |
| 6870 | "handover"); |
| 6871 | return 0; |
| 6872 | } |
| 6873 | if (!file_exists("nfc-success")) { |
| 6874 | send_resp(dut, conn, SIGMA_ERROR, |
| 6875 | "ErrorCode,Failed to complete NFC connection handover"); |
| 6876 | return 0; |
| 6877 | } |
| 6878 | |
| 6879 | return 1; |
| 6880 | } |
| 6881 | |
| 6882 | |
| 6883 | static int cmd_ap_nfc_action(struct sigma_dut *dut, struct sigma_conn *conn, |
| 6884 | struct sigma_cmd *cmd) |
| 6885 | { |
| 6886 | /* const char *name = get_param(cmd, "Name"); */ |
| 6887 | /* const char *intf = get_param(cmd, "Interface"); */ |
| 6888 | const char *oper = get_param(cmd, "Operation"); |
| 6889 | |
| 6890 | if (oper == NULL) |
| 6891 | return -1; |
| 6892 | |
| 6893 | if (strcasecmp(oper, "WRITE_CONFIG") == 0) |
| 6894 | return ap_nfc_write_config_token(dut, conn, cmd); |
| 6895 | if (strcasecmp(oper, "WRITE_PASSWD") == 0) |
| 6896 | return ap_nfc_write_password_token(dut, conn, cmd); |
| 6897 | if (strcasecmp(oper, "WPS_READ_PASSWD") == 0) |
| 6898 | return ap_nfc_wps_read_passwd(dut, conn, cmd); |
| 6899 | if (strcasecmp(oper, "WPS_CONN_HNDOVR") == 0) |
| 6900 | return ap_nfc_wps_connection_handover(dut, conn, cmd); |
| 6901 | |
| 6902 | send_resp(dut, conn, SIGMA_ERROR, "ErrorCode,Unsupported operation"); |
| 6903 | return 0; |
| 6904 | } |
| 6905 | |
| 6906 | |
| 6907 | static int cmd_ap_wps_read_pin(struct sigma_dut *dut, struct sigma_conn *conn, |
| 6908 | struct sigma_cmd *cmd) |
| 6909 | { |
| 6910 | char *pin = "12345670"; /* TODO: use random PIN */ |
| 6911 | char resp[100]; |
| 6912 | |
| 6913 | snprintf(resp, sizeof(resp), "PIN,%s", pin); |
| 6914 | send_resp(dut, conn, SIGMA_COMPLETE, resp); |
| 6915 | |
| 6916 | return 0; |
| 6917 | } |
| 6918 | |
| 6919 | |
| 6920 | static int ath_vht_op_mode_notif(struct sigma_dut *dut, const char *ifname, |
| 6921 | const char *val) |
| 6922 | { |
| 6923 | char *token, *result; |
| 6924 | int nss = 0, chwidth = 0; |
| 6925 | char buf[100]; |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 6926 | char *saveptr; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6927 | |
| 6928 | /* |
| 6929 | * The following commands should be invoked to generate |
| 6930 | * VHT op mode notification |
| 6931 | */ |
| 6932 | |
| 6933 | /* Extract the NSS info */ |
| 6934 | token = strdup(val); |
| 6935 | if (!token) |
| 6936 | return -1; |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 6937 | result = strtok_r(token, ";", &saveptr); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6938 | if (result) { |
| 6939 | int count = atoi(result); |
| 6940 | |
| 6941 | /* We do not support NSS > 3 */ |
| 6942 | if (count < 0 || count > 3) { |
| 6943 | free(token); |
| 6944 | return -1; |
| 6945 | } |
| 6946 | |
| 6947 | /* Convert nss to chainmask */ |
| 6948 | while (count--) |
| 6949 | nss = (nss << 1) | 1; |
| 6950 | |
| 6951 | snprintf(buf, sizeof(buf), "iwpriv %s rxchainmask %d", |
| 6952 | ifname, nss); |
| 6953 | if (system(buf) != 0) { |
| 6954 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 6955 | "iwpriv wifi1 rxchainmask failed!"); |
| 6956 | } |
| 6957 | } |
| 6958 | |
| 6959 | /* Extract the Channel width info */ |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 6960 | result = strtok_r(NULL, ";", &saveptr); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6961 | if (result) { |
| 6962 | switch (atoi(result)) { |
| 6963 | case 20: |
| 6964 | chwidth = 0; |
| 6965 | break; |
| 6966 | case 40: |
| 6967 | chwidth = 1; |
| 6968 | break; |
| 6969 | case 80: |
| 6970 | chwidth = 2; |
| 6971 | break; |
| 6972 | case 160: |
| 6973 | chwidth = 3; |
| 6974 | break; |
| 6975 | default: |
| 6976 | chwidth = 2; |
| 6977 | break; |
| 6978 | } |
| 6979 | snprintf(buf, sizeof(buf), "iwpriv %s chwidth %d", |
| 6980 | ifname, chwidth); |
| 6981 | if (system(buf) != 0) { |
| 6982 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 6983 | "iwpriv chwidth failed!"); |
| 6984 | } |
| 6985 | } |
| 6986 | |
| 6987 | /* Send the opmode notification */ |
| 6988 | snprintf(buf, sizeof(buf), "iwpriv %s opmode_notify 1", ifname); |
| 6989 | if (system(buf) != 0) { |
| 6990 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 6991 | "iwpriv opmode_notify failed!"); |
| 6992 | } |
| 6993 | free(token); |
| 6994 | |
| 6995 | return 0; |
| 6996 | } |
| 6997 | |
| 6998 | |
| 6999 | static int ath_vht_nss_mcs(struct sigma_dut *dut, const char *ifname, |
| 7000 | const char *val) |
| 7001 | { |
| 7002 | /* String (nss_operating_mode; mcs_operating_mode) */ |
| 7003 | int nss, mcs; |
| 7004 | char *token, *result; |
| 7005 | char buf[100]; |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 7006 | char *saveptr; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7007 | |
| 7008 | token = strdup(val); |
| 7009 | if (!token) |
| 7010 | return -1; |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 7011 | result = strtok_r(token, ";", &saveptr); |
Pradeep Reddy POTTETI | 41b8c54 | 2016-06-15 16:09:46 +0530 | [diff] [blame] | 7012 | if (!result) { |
| 7013 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 7014 | "VHT NSS not specified"); |
| 7015 | goto end; |
| 7016 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7017 | if (strcasecmp(result, "def") != 0) { |
| 7018 | nss = atoi(result); |
| 7019 | |
| 7020 | if (nss == 4) |
| 7021 | ath_disable_txbf(dut, ifname); |
| 7022 | |
| 7023 | snprintf(buf, sizeof(buf), "iwpriv %s nss %d", ifname, nss); |
| 7024 | if (system(buf) != 0) { |
| 7025 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 7026 | "iwpriv nss failed"); |
| 7027 | } |
| 7028 | } else { |
| 7029 | if (dut->device_type == AP_testbed && dut->ap_sgi80 == 1) { |
| 7030 | snprintf(buf, sizeof(buf), "iwpriv %s nss 1", ifname); |
| 7031 | if (system(buf) != 0) { |
| 7032 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 7033 | "iwpriv nss failed"); |
| 7034 | } |
| 7035 | } |
| 7036 | } |
| 7037 | |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 7038 | result = strtok_r(NULL, ";", &saveptr); |
Pradeep Reddy POTTETI | 41b8c54 | 2016-06-15 16:09:46 +0530 | [diff] [blame] | 7039 | if (!result) { |
| 7040 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 7041 | "VHT MCS not specified"); |
| 7042 | goto end; |
| 7043 | } |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7044 | if (strcasecmp(result, "def") == 0) { |
| 7045 | if (dut->device_type == AP_testbed && dut->ap_sgi80 == 1) { |
| 7046 | snprintf(buf, sizeof(buf), "iwpriv %s vhtmcs 7", |
| 7047 | ifname); |
| 7048 | if (system(buf) != 0) { |
| 7049 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 7050 | "iwpriv vhtmcs failed"); |
| 7051 | } |
| 7052 | } else { |
| 7053 | snprintf(buf, sizeof(buf), |
| 7054 | "iwpriv %s set11NRates 0", ifname); |
| 7055 | if (system(buf) != 0) { |
| 7056 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 7057 | "iwpriv set11NRates failed"); |
| 7058 | } |
| 7059 | } |
| 7060 | } else { |
| 7061 | mcs = atoi(result); |
| 7062 | snprintf(buf, sizeof(buf), "iwpriv %s vhtmcs %d", ifname, mcs); |
| 7063 | if (system(buf) != 0) { |
| 7064 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 7065 | "iwpriv vhtmcs failed"); |
| 7066 | } |
| 7067 | } |
| 7068 | |
Pradeep Reddy POTTETI | 41b8c54 | 2016-06-15 16:09:46 +0530 | [diff] [blame] | 7069 | end: |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7070 | free(token); |
| 7071 | return 0; |
| 7072 | } |
| 7073 | |
| 7074 | |
| 7075 | static int ath_vht_chnum_band(struct sigma_dut *dut, const char *ifname, |
| 7076 | const char *val) |
| 7077 | { |
| 7078 | char *token, *result; |
| 7079 | int channel = 36; |
| 7080 | int chwidth = 80; |
| 7081 | char buf[100]; |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 7082 | char *saveptr; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7083 | |
| 7084 | /* Extract the channel info */ |
| 7085 | token = strdup(val); |
| 7086 | if (!token) |
| 7087 | return -1; |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 7088 | result = strtok_r(token, ";", &saveptr); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7089 | if (result) |
| 7090 | channel = atoi(result); |
| 7091 | |
| 7092 | /* Extract the channel width info */ |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 7093 | result = strtok_r(NULL, ";", &saveptr); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7094 | if (result) |
| 7095 | chwidth = atoi(result); |
| 7096 | |
| 7097 | /* Issue the channel switch command */ |
| 7098 | snprintf(buf, sizeof(buf), "iwpriv %s doth_ch_chwidth %d 10 %d", |
| 7099 | ifname, channel, chwidth); |
| 7100 | if (system(buf) != 0) { |
| 7101 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 7102 | "iwpriv doth_ch_chwidth failed!"); |
| 7103 | } |
| 7104 | |
| 7105 | free(token); |
| 7106 | return 0; |
| 7107 | } |
| 7108 | |
| 7109 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7110 | static int ath_ndpa_stainfo_mac(struct sigma_dut *dut, const char *ifname, |
| 7111 | const char *val) |
| 7112 | { |
| 7113 | char buf[80]; |
| 7114 | unsigned char mac_addr[6]; |
| 7115 | |
| 7116 | if (parse_mac_address(dut, val, mac_addr) < 0) |
| 7117 | return -1; |
| 7118 | |
| 7119 | snprintf(buf, sizeof(buf), |
| 7120 | "wifitool %s beeliner_fw_test 92 0x%02x%02x%02x%02x", |
| 7121 | ifname, mac_addr[0], mac_addr[1], mac_addr[2], mac_addr[3]); |
| 7122 | run_system(dut, buf); |
| 7123 | |
| 7124 | snprintf(buf, sizeof(buf), "wifitool %s beeliner_fw_test 93 0x%02x%02x", |
| 7125 | ifname, mac_addr[4], mac_addr[5]); |
| 7126 | run_system(dut, buf); |
| 7127 | |
| 7128 | snprintf(buf, sizeof(buf), "wifitool %s beeliner_fw_test 94 1", ifname); |
| 7129 | run_system(dut, buf); |
| 7130 | |
| 7131 | return 0; |
| 7132 | } |
| 7133 | |
| 7134 | |
priyadharshini gowthaman | e5e2517 | 2015-12-08 14:53:48 -0800 | [diff] [blame] | 7135 | void novap_reset(struct sigma_dut *dut, const char *ifname) |
Priyadharshini Gowthaman | 39beafa | 2015-11-09 14:11:25 -0800 | [diff] [blame] | 7136 | { |
| 7137 | char buf[60]; |
| 7138 | |
| 7139 | snprintf(buf, sizeof(buf), "iwpriv %s novap_reset 1", ifname); |
| 7140 | if (system(buf) != 0) { |
| 7141 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 7142 | "disabling novap reset failed"); |
| 7143 | } |
| 7144 | } |
| 7145 | |
| 7146 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7147 | static int ath_ap_set_rfeature(struct sigma_dut *dut, struct sigma_conn *conn, |
| 7148 | struct sigma_cmd *cmd) |
| 7149 | { |
| 7150 | const char *val; |
| 7151 | char *ifname; |
| 7152 | |
| 7153 | ifname = get_main_ifname(); |
| 7154 | |
Priyadharshini Gowthaman | 39beafa | 2015-11-09 14:11:25 -0800 | [diff] [blame] | 7155 | /* Disable vap reset between the commands */ |
| 7156 | novap_reset(dut, ifname); |
| 7157 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7158 | val = get_param(cmd, "Opt_md_notif_ie"); |
| 7159 | if (val && ath_vht_op_mode_notif(dut, ifname, val) < 0) |
| 7160 | return -1; |
| 7161 | |
| 7162 | /* TODO: Optional arguments */ |
| 7163 | |
| 7164 | val = get_param(cmd, "nss_mcs_opt"); |
| 7165 | if (val && ath_vht_nss_mcs(dut, ifname, val) < 0) |
| 7166 | return -1; |
| 7167 | |
| 7168 | val = get_param(cmd, "chnum_band"); |
| 7169 | if (val && ath_vht_chnum_band(dut, ifname, val) < 0) |
| 7170 | return -1; |
| 7171 | |
| 7172 | val = get_param(cmd, "RTS_FORCE"); |
| 7173 | if (val) |
| 7174 | ath_config_rts_force(dut, ifname, val); |
| 7175 | |
| 7176 | val = get_param(cmd, "DYN_BW_SGNL"); |
| 7177 | if (val) |
| 7178 | ath_config_dyn_bw_sig(dut, ifname, val); |
| 7179 | |
| 7180 | val = get_param(cmd, "CTS_WIDTH"); |
| 7181 | if (val) |
| 7182 | ath_set_cts_width(dut, ifname, val); |
| 7183 | |
| 7184 | val = get_param(cmd, "Ndpa_stainfo_mac"); |
| 7185 | if (val && ath_ndpa_stainfo_mac(dut, ifname, val) < 0) |
| 7186 | return -1; |
| 7187 | |
| 7188 | val = get_param(cmd, "txBandwidth"); |
| 7189 | if (val && ath_set_width(dut, conn, ifname, val) < 0) |
| 7190 | return -1; |
| 7191 | |
| 7192 | return 1; |
| 7193 | } |
| 7194 | |
| 7195 | |
Pradeep Reddy POTTETI | 88fd82c | 2016-03-14 12:20:18 +0530 | [diff] [blame] | 7196 | static int wcn_vht_chnum_band(struct sigma_dut *dut, const char *ifname, |
| 7197 | const char *val) |
| 7198 | { |
| 7199 | char *token, *result; |
| 7200 | int channel = 36; |
| 7201 | char buf[100]; |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 7202 | char *saveptr; |
Pradeep Reddy POTTETI | 88fd82c | 2016-03-14 12:20:18 +0530 | [diff] [blame] | 7203 | |
| 7204 | /* Extract the channel info */ |
| 7205 | token = strdup(val); |
| 7206 | if (!token) |
| 7207 | return -1; |
Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 7208 | result = strtok_r(token, ";", &saveptr); |
Pradeep Reddy POTTETI | 88fd82c | 2016-03-14 12:20:18 +0530 | [diff] [blame] | 7209 | if (result) |
| 7210 | channel = atoi(result); |
| 7211 | |
| 7212 | /* Issue the channel switch command */ |
| 7213 | snprintf(buf, sizeof(buf), "iwpriv %s setChanChange %d", |
| 7214 | ifname, channel); |
| 7215 | if (system(buf) != 0) { |
| 7216 | sigma_dut_print(dut, DUT_MSG_ERROR, |
| 7217 | "iwpriv setChanChange failed!"); |
| 7218 | } |
| 7219 | |
| 7220 | free(token); |
| 7221 | return 0; |
| 7222 | } |
| 7223 | |
| 7224 | |
| 7225 | static int wcn_ap_set_rfeature(struct sigma_dut *dut, struct sigma_conn *conn, |
| 7226 | struct sigma_cmd *cmd) |
| 7227 | { |
| 7228 | const char *val; |
| 7229 | char *ifname; |
| 7230 | |
| 7231 | ifname = get_main_ifname(); |
| 7232 | |
| 7233 | val = get_param(cmd, "chnum_band"); |
| 7234 | if (val && wcn_vht_chnum_band(dut, ifname, val) < 0) |
| 7235 | return -1; |
| 7236 | |
| 7237 | return 1; |
| 7238 | } |
| 7239 | |
| 7240 | |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7241 | static int cmd_ap_set_rfeature(struct sigma_dut *dut, struct sigma_conn *conn, |
| 7242 | struct sigma_cmd *cmd) |
| 7243 | { |
| 7244 | /* const char *name = get_param(cmd, "NAME"); */ |
| 7245 | /* const char *type = get_param(cmd, "Type"); */ |
| 7246 | |
| 7247 | switch (get_driver_type()) { |
| 7248 | case DRIVER_ATHEROS: |
| 7249 | return ath_ap_set_rfeature(dut, conn, cmd); |
| 7250 | case DRIVER_OPENWRT: |
| 7251 | switch (get_openwrt_driver_type()) { |
| 7252 | case OPENWRT_DRIVER_ATHEROS: |
| 7253 | return ath_ap_set_rfeature(dut, conn, cmd); |
| 7254 | default: |
| 7255 | send_resp(dut, conn, SIGMA_ERROR, |
| 7256 | "errorCode,Unsupported ap_set_rfeature with the current openwrt driver"); |
| 7257 | return 0; |
| 7258 | } |
Sreelakshmi Konamki | 0e4fcf9 | 2016-04-26 19:55:01 +0530 | [diff] [blame] | 7259 | case DRIVER_LINUX_WCN: |
Pradeep Reddy POTTETI | 88fd82c | 2016-03-14 12:20:18 +0530 | [diff] [blame] | 7260 | case DRIVER_WCN: |
| 7261 | return wcn_ap_set_rfeature(dut, conn, cmd); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7262 | default: |
| 7263 | send_resp(dut, conn, SIGMA_ERROR, |
| 7264 | "errorCode,Unsupported ap_set_rfeature with the current driver"); |
| 7265 | return 0; |
| 7266 | } |
| 7267 | } |
| 7268 | |
| 7269 | |
| 7270 | static int cmd_accesspoint(struct sigma_dut *dut, struct sigma_conn *conn, |
| 7271 | struct sigma_cmd *cmd) |
| 7272 | { |
| 7273 | /* const char *name = get_param(cmd, "NAME"); */ |
| 7274 | return 1; |
| 7275 | } |
| 7276 | |
| 7277 | |
| 7278 | void ap_register_cmds(void) |
| 7279 | { |
| 7280 | sigma_dut_reg_cmd("ap_ca_version", NULL, cmd_ap_ca_version); |
| 7281 | sigma_dut_reg_cmd("ap_set_wireless", NULL, cmd_ap_set_wireless); |
| 7282 | sigma_dut_reg_cmd("ap_send_addba_req", NULL, cmd_ap_send_addba_req); |
| 7283 | sigma_dut_reg_cmd("ap_set_11n_wireless", NULL, cmd_ap_set_wireless); |
| 7284 | sigma_dut_reg_cmd("ap_set_11n", NULL, cmd_ap_set_wireless); |
| 7285 | 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] | 7286 | sigma_dut_reg_cmd("ap_set_11h", NULL, cmd_ap_set_wireless); |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7287 | sigma_dut_reg_cmd("ap_set_security", NULL, cmd_ap_set_security); |
| 7288 | sigma_dut_reg_cmd("ap_set_apqos", NULL, cmd_ap_set_apqos); |
| 7289 | sigma_dut_reg_cmd("ap_set_staqos", NULL, cmd_ap_set_staqos); |
| 7290 | sigma_dut_reg_cmd("ap_set_radius", NULL, cmd_ap_set_radius); |
| 7291 | sigma_dut_reg_cmd("ap_reboot", NULL, cmd_ap_reboot); |
| 7292 | sigma_dut_reg_cmd("ap_config_commit", NULL, cmd_ap_config_commit); |
| 7293 | sigma_dut_reg_cmd("ap_reset_default", NULL, cmd_ap_reset_default); |
| 7294 | sigma_dut_reg_cmd("ap_get_info", NULL, cmd_ap_get_info); |
| 7295 | sigma_dut_reg_cmd("ap_deauth_sta", NULL, cmd_ap_deauth_sta); |
| 7296 | sigma_dut_reg_cmd("ap_send_frame", NULL, cmd_ap_send_frame); |
| 7297 | sigma_dut_reg_cmd("ap_get_mac_address", NULL, cmd_ap_get_mac_address); |
| 7298 | sigma_dut_reg_cmd("ap_set_pmf", NULL, cmd_ap_set_pmf); |
| 7299 | sigma_dut_reg_cmd("ap_set_hs2", NULL, cmd_ap_set_hs2); |
| 7300 | sigma_dut_reg_cmd("ap_set_rfeature", NULL, cmd_ap_set_rfeature); |
| 7301 | sigma_dut_reg_cmd("ap_nfc_action", NULL, cmd_ap_nfc_action); |
| 7302 | sigma_dut_reg_cmd("ap_wps_read_pin", NULL, cmd_ap_wps_read_pin); |
| 7303 | sigma_dut_reg_cmd("AccessPoint", NULL, cmd_accesspoint); |
| 7304 | } |